From 11b561886643d4e23d0fd58c205d830a448dd0a2 Mon Sep 17 00:00:00 2001 From: Chris Leech Date: Tue, 3 Nov 2009 11:46:29 -0800 Subject: [SCSI] libfcoe, fcoe: libfcoe NPIV support The FIP code in libfcoe needed several changes to support NPIV 1) dst_src_addr needs to be managed per-n_port-ID for FPMA fabrics with NPIV enabled. Managing the MAC address is now handled in fcoe, with some slight changes to update_mac() and a new get_src_addr() function pointer. 2) The libfc elsct_send() hook is used to setup FCoE specific response handlers for FIP encapsulated ELS exchanges. This lets the FCoE specific handling know which VN_Port the exchange is for, and doesn't require tracking OX_IDs. It might be possible to roll back to the full FIP frame in these, but for now I've just stashed the contents of the MAC address descriptor in the skb context block for later use. Also, because fcoe_elsct_send() just passes control on to fc_elsct_send(), all transmits still come through the normal frame_send() path. 3) The NPIV changes added a mutex hold in the keep alive sending, the lport mutex is protecting the vport list. We can't take a mutex from a timer, so move the FIP keep alive logic to the link work struct. Signed-off-by: Chris Leech Signed-off-by: Robert Love Signed-off-by: James Bottomley --- include/scsi/libfcoe.h | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'include/scsi/libfcoe.h') diff --git a/include/scsi/libfcoe.h b/include/scsi/libfcoe.h index b2410605b74..8ef5e209c21 100644 --- a/include/scsi/libfcoe.h +++ b/include/scsi/libfcoe.h @@ -74,11 +74,13 @@ enum fip_state { * @last_link: last link state reported to libfc. * @map_dest: use the FC_MAP mode for destination MAC addresses. * @spma: supports SPMA server-provided MACs mode + * @send_ctlr_ka: need to send controller keep alive + * @send_port_ka: need to send port keep alives * @dest_addr: MAC address of the selected FC forwarder. * @ctl_src_addr: the native MAC address of our local port. - * @data_src_addr: the assigned MAC address for the local port after FLOGI. * @send: LLD-supplied function to handle sending of FIP Ethernet frames. * @update_mac: LLD-supplied function to handle changes to MAC addresses. + * @get_src_addr: LLD-supplied function to supply a source MAC address. * @lock: lock protecting this structure. * * This structure is used by all FCoE drivers. It contains information @@ -106,12 +108,14 @@ struct fcoe_ctlr { u8 last_link; u8 map_dest; u8 spma; + u8 send_ctlr_ka; + u8 send_port_ka; u8 dest_addr[ETH_ALEN]; u8 ctl_src_addr[ETH_ALEN]; - u8 data_src_addr[ETH_ALEN]; void (*send)(struct fcoe_ctlr *, struct sk_buff *); - void (*update_mac)(struct fcoe_ctlr *, u8 *old, u8 *new); + void (*update_mac)(struct fc_lport *, u8 *addr); + u8 * (*get_src_addr)(struct fc_lport *); spinlock_t lock; }; @@ -155,9 +159,10 @@ void fcoe_ctlr_init(struct fcoe_ctlr *); void fcoe_ctlr_destroy(struct fcoe_ctlr *); void fcoe_ctlr_link_up(struct fcoe_ctlr *); int fcoe_ctlr_link_down(struct fcoe_ctlr *); -int fcoe_ctlr_els_send(struct fcoe_ctlr *, struct sk_buff *); +int fcoe_ctlr_els_send(struct fcoe_ctlr *, struct fc_lport *, struct sk_buff *); void fcoe_ctlr_recv(struct fcoe_ctlr *, struct sk_buff *); -int fcoe_ctlr_recv_flogi(struct fcoe_ctlr *, struct fc_frame *fp, u8 *sa); +int fcoe_ctlr_recv_flogi(struct fcoe_ctlr *, struct fc_lport *lport, + struct fc_frame *fp, u8 *sa); /* libfcoe funcs */ u64 fcoe_wwn_from_mac(unsigned char mac[], unsigned int, unsigned int); -- cgit v1.2.3 From 70b51aabf3b03fbf8d61c14847ccce4c69fb0cdd Mon Sep 17 00:00:00 2001 From: Robert Love Date: Tue, 3 Nov 2009 11:47:45 -0800 Subject: [SCSI] libfcoe: formatting and comment cleanups Ensures that there are kernel-doc style comments for all routines and structures. There were also a few instances of fc_lport's named 'lp' which were switched to 'lport' as per the libfc/libfcoe/fcoe naming convention. Also, emacs 'indent-region' and 'tabify' were ran on libfcoe.c. Signed-off-by: Robert Love Signed-off-by: James Bottomley --- include/scsi/libfcoe.h | 84 +++++++++++++++++++++++++------------------------- 1 file changed, 42 insertions(+), 42 deletions(-) (limited to 'include/scsi/libfcoe.h') diff --git a/include/scsi/libfcoe.h b/include/scsi/libfcoe.h index 8ef5e209c21..76d08c9a767 100644 --- a/include/scsi/libfcoe.h +++ b/include/scsi/libfcoe.h @@ -53,35 +53,35 @@ enum fip_state { }; /** - * struct fcoe_ctlr - FCoE Controller and FIP state. - * @state: internal FIP state for network link and FIP or non-FIP mode. - * @lp: &fc_lport: libfc local port. - * @sel_fcf: currently selected FCF, or NULL. - * @fcfs: list of discovered FCFs. - * @fcf_count: number of discovered FCF entries. - * @sol_time: time when a multicast solicitation was last sent. - * @sel_time: time after which to select an FCF. - * @port_ka_time: time of next port keep-alive. - * @ctlr_ka_time: time of next controller keep-alive. - * @timer: timer struct used for all delayed events. - * @link_work: &work_struct for doing FCF selection. - * @recv_work: &work_struct for receiving FIP frames. + * struct fcoe_ctlr - FCoE Controller and FIP state + * @state: internal FIP state for network link and FIP or non-FIP mode. + * @lp: &fc_lport: libfc local port. + * @sel_fcf: currently selected FCF, or NULL. + * @fcfs: list of discovered FCFs. + * @fcf_count: number of discovered FCF entries. + * @sol_time: time when a multicast solicitation was last sent. + * @sel_time: time after which to select an FCF. + * @port_ka_time: time of next port keep-alive. + * @ctlr_ka_time: time of next controller keep-alive. + * @timer: timer struct used for all delayed events. + * @link_work: &work_struct for doing FCF selection. + * @recv_work: &work_struct for receiving FIP frames. * @fip_recv_list: list of received FIP frames. - * @user_mfs: configured maximum FC frame size, including FC header. - * @flogi_oxid: exchange ID of most recent fabric login. - * @flogi_count: number of FLOGI attempts in AUTO mode. - * @link: current link status for libfc. - * @last_link: last link state reported to libfc. - * @map_dest: use the FC_MAP mode for destination MAC addresses. - * @spma: supports SPMA server-provided MACs mode - * @send_ctlr_ka: need to send controller keep alive - * @send_port_ka: need to send port keep alives - * @dest_addr: MAC address of the selected FC forwarder. - * @ctl_src_addr: the native MAC address of our local port. - * @send: LLD-supplied function to handle sending of FIP Ethernet frames. - * @update_mac: LLD-supplied function to handle changes to MAC addresses. - * @get_src_addr: LLD-supplied function to supply a source MAC address. - * @lock: lock protecting this structure. + * @user_mfs: configured maximum FC frame size, including FC header. + * @flogi_oxid: exchange ID of most recent fabric login. + * @flogi_count: number of FLOGI attempts in AUTO mode. + * @link: current link status for libfc. + * @last_link: last link state reported to libfc. + * @map_dest: use the FC_MAP mode for destination MAC addresses. + * @spma: supports SPMA server-provided MACs mode + * @send_ctlr_ka: need to send controller keep alive + * @send_port_ka: need to send port keep alives + * @dest_addr: MAC address of the selected FC forwarder. + * @ctl_src_addr: the native MAC address of our local port. + * @send: LLD-supplied function to handle sending FIP Ethernet frames + * @update_mac: LLD-supplied function to handle changes to MAC addresses. + * @get_src_addr: LLD-supplied function to supply a source MAC address. + * @lock: lock protecting this structure. * * This structure is used by all FCoE drivers. It contains information * needed by all FCoE low-level drivers (LLDs) as well as internal state @@ -119,18 +119,18 @@ struct fcoe_ctlr { spinlock_t lock; }; -/* - * struct fcoe_fcf - Fibre-Channel Forwarder. - * @list: list linkage. - * @time: system time (jiffies) when an advertisement was last received. - * @switch_name: WWN of switch from advertisement. - * @fabric_name: WWN of fabric from advertisement. - * @fc_map: FC_MAP value from advertisement. - * @fcf_mac: Ethernet address of the FCF. - * @vfid: virtual fabric ID. - * @pri: seletion priority, smaller values are better. - * @flags: flags received from advertisement. - * @fka_period: keep-alive period, in jiffies. +/** + * struct fcoe_fcf - Fibre-Channel Forwarder + * @list: list linkage + * @time: system time (jiffies) when an advertisement was last received + * @switch_name: WWN of switch from advertisement + * @fabric_name: WWN of fabric from advertisement + * @fc_map: FC_MAP value from advertisement + * @fcf_mac: Ethernet address of the FCF + * @vfid: virtual fabric ID + * @pri: selection priority, smaller values are better + * @flags: flags received from advertisement + * @fka_period: keep-alive period, in jiffies * * A Fibre-Channel Forwarder (FCF) is the entity on the Ethernet that * passes FCoE frames on to an FC fabric. This structure represents @@ -161,8 +161,8 @@ void fcoe_ctlr_link_up(struct fcoe_ctlr *); int fcoe_ctlr_link_down(struct fcoe_ctlr *); int fcoe_ctlr_els_send(struct fcoe_ctlr *, struct fc_lport *, struct sk_buff *); void fcoe_ctlr_recv(struct fcoe_ctlr *, struct sk_buff *); -int fcoe_ctlr_recv_flogi(struct fcoe_ctlr *, struct fc_lport *lport, - struct fc_frame *fp, u8 *sa); +int fcoe_ctlr_recv_flogi(struct fcoe_ctlr *, struct fc_lport *, + struct fc_frame *, u8 *); /* libfcoe funcs */ u64 fcoe_wwn_from_mac(unsigned char mac[], unsigned int, unsigned int); -- cgit v1.2.3 From 22bcd225bfe2107725228758137d2109befa942a Mon Sep 17 00:00:00 2001 From: Joe Eykholt Date: Tue, 3 Nov 2009 11:48:11 -0800 Subject: [SCSI] libfcoe: Allow FIP to be disabled by the driver Allow FIP to be disabled by the driver for devices that want to use libfcoe in non-FIP mode. The driver merely sets the fcoe_ctlr mode to the state which should be entered when the link comes up. The default is auto. No change is needed for fcoe.c which uses auto mode. Signed-off-by: Joe Eykholt Signed-off-by: Robert Love Signed-off-by: James Bottomley --- include/scsi/libfcoe.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include/scsi/libfcoe.h') diff --git a/include/scsi/libfcoe.h b/include/scsi/libfcoe.h index 76d08c9a767..2344a00e92e 100644 --- a/include/scsi/libfcoe.h +++ b/include/scsi/libfcoe.h @@ -55,6 +55,7 @@ enum fip_state { /** * struct fcoe_ctlr - FCoE Controller and FIP state * @state: internal FIP state for network link and FIP or non-FIP mode. + * @mode: LLD-selected mode. * @lp: &fc_lport: libfc local port. * @sel_fcf: currently selected FCF, or NULL. * @fcfs: list of discovered FCFs. @@ -89,6 +90,7 @@ enum fip_state { */ struct fcoe_ctlr { enum fip_state state; + enum fip_state mode; struct fc_lport *lp; struct fcoe_fcf *sel_fcf; struct list_head fcfs; -- cgit v1.2.3 From dd42dac4ecd1799077c132aab35d3c36b26d4d8c Mon Sep 17 00:00:00 2001 From: Joe Eykholt Date: Tue, 3 Nov 2009 11:48:27 -0800 Subject: [SCSI] libfcoe: FIP should report link to libfc whether selected or not The fnic driver with FIP is reporting link up, even though it's down. When the interface is shut down by the switch, we receive a clear virtual link, and set the state reported to libfc as down, although we still report it up. Clearly wrong. That causes the subsequent link down event not to be reported, and /sys shows the host "Online". Currently, in FIP mode, if an FCF times out, then link to libfc is reported as down, to stop FLOGIs. That interferes with the LLD link down being reported. Users really need to know the physical link information, to diagnose cabling issues, so physical link status should be reported to libfc. If the selected FCF needs to be reported, that should be done separately, in a later patch. Signed-off-by: Joe Eykholt Signed-off-by: Robert Love Signed-off-by: James Bottomley --- include/scsi/libfcoe.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include/scsi/libfcoe.h') diff --git a/include/scsi/libfcoe.h b/include/scsi/libfcoe.h index 2344a00e92e..e38ffa05dc2 100644 --- a/include/scsi/libfcoe.h +++ b/include/scsi/libfcoe.h @@ -108,6 +108,7 @@ struct fcoe_ctlr { u8 flogi_count; u8 link; u8 last_link; + u8 reset_req; u8 map_dest; u8 spma; u8 send_ctlr_ka; -- cgit v1.2.3 From 386309ce927a308d7742a6fb24a536d3383fbd49 Mon Sep 17 00:00:00 2001 From: Joe Eykholt Date: Tue, 3 Nov 2009 11:49:16 -0800 Subject: [SCSI] libfcoe: fcoe: simplify receive FLOGI response There was a locking problem where the fip->lock was held during the call to update_mac(). The rtnl_lock() must be taken before the fip->lock, not the other way around. This fixes that. Now that fcoe_ctlr_recv_flog() is called only from the response handler to a FLOGI request, some checking can be eliminated. Instead of calling update_mac(), just fill in the granted_mac address for the passed-in frame (skb). Eliminate the passed-in source MAC address since it is also in the skb. Also, in fcoe, call fcoe_set_src_mac() directly instead of going thru the fip function pointer. This will generate less code. Then, since fip isn't needed for LOGO response, use lport as the arg. Signed-off-by: Joe Eykholt Signed-off-by: Robert Love Signed-off-by: James Bottomley --- include/scsi/libfcoe.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/scsi/libfcoe.h') diff --git a/include/scsi/libfcoe.h b/include/scsi/libfcoe.h index e38ffa05dc2..3837872f196 100644 --- a/include/scsi/libfcoe.h +++ b/include/scsi/libfcoe.h @@ -165,7 +165,7 @@ int fcoe_ctlr_link_down(struct fcoe_ctlr *); int fcoe_ctlr_els_send(struct fcoe_ctlr *, struct fc_lport *, struct sk_buff *); void fcoe_ctlr_recv(struct fcoe_ctlr *, struct sk_buff *); int fcoe_ctlr_recv_flogi(struct fcoe_ctlr *, struct fc_lport *, - struct fc_frame *, u8 *); + struct fc_frame *); /* libfcoe funcs */ u64 fcoe_wwn_from_mac(unsigned char mac[], unsigned int, unsigned int); -- cgit v1.2.3 From 8cdffdccd948ea4872b7b65280bc04f2fa93fc96 Mon Sep 17 00:00:00 2001 From: Yi Zou Date: Fri, 20 Nov 2009 14:54:57 -0800 Subject: [SCSI] libfcoe: add checking disable flag in FIP_FKA_ADV When the D bit is set if the FKA_ADV_Period of the FIP Discovery Advertisement, the ENode should not transmit period ENode FIP Keep Alive and VN_Port FIP Keep Alive (FC-BB-5 Rev2, 7.8.3.13). Note that fcf->flags is taken directly from the fip_header, I am claiming one bit for the purpose of the FIP_FKA_Period D bit as FIP_FL_FK_ADV_B, and use FIP_HEADER_FLAGS as bitmask for bits used in fip_header. Signed-off-by: Yi Zou Signed-off-by: Robert Love Signed-off-by: James Bottomley --- include/scsi/libfcoe.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include/scsi/libfcoe.h') diff --git a/include/scsi/libfcoe.h b/include/scsi/libfcoe.h index 3837872f196..c603f4a7e7f 100644 --- a/include/scsi/libfcoe.h +++ b/include/scsi/libfcoe.h @@ -155,6 +155,7 @@ struct fcoe_fcf { u8 pri; u16 flags; u32 fka_period; + u8 fd_flags:1; }; /* FIP API functions */ -- cgit v1.2.3