xref: /linux/include/scsi/libfcoe.h (revision 848b8977)
1a61127c2SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
285b4aa49SRobert Love /*
397c8389dSJoe Eykholt  * Copyright (c) 2008-2009 Cisco Systems, Inc.  All rights reserved.
485b4aa49SRobert Love  * Copyright (c) 2007-2008 Intel Corporation.  All rights reserved.
585b4aa49SRobert Love  *
685b4aa49SRobert Love  * Maintained at www.Open-FCoE.org
785b4aa49SRobert Love  */
885b4aa49SRobert Love 
985b4aa49SRobert Love #ifndef _LIBFCOE_H
1085b4aa49SRobert Love #define _LIBFCOE_H
1185b4aa49SRobert Love 
1297c8389dSJoe Eykholt #include <linux/etherdevice.h>
1397c8389dSJoe Eykholt #include <linux/if_ether.h>
1485b4aa49SRobert Love #include <linux/netdevice.h>
1585b4aa49SRobert Love #include <linux/skbuff.h>
1697c8389dSJoe Eykholt #include <linux/workqueue.h>
17*848b8977SDavidlohr Bueso #include <linux/local_lock.h>
18e10f8c66SJoe Eykholt #include <linux/random.h>
1985b4aa49SRobert Love #include <scsi/fc/fc_fcoe.h>
2085b4aa49SRobert Love #include <scsi/libfc.h>
219a74e884SRobert Love #include <scsi/fcoe_sysfs.h>
2285b4aa49SRobert Love 
23da87bfabSVasu Dev #define FCOE_MAX_CMD_LEN	16	/* Supported CDB length */
24da87bfabSVasu Dev 
2597c8389dSJoe Eykholt /*
26f4d2b2b6SBhanu Prakash Gollapudi  * Max MTU for FCoE: 14 (FCoE header) + 24 (FC header) + 2112 (max FC payload)
27f4d2b2b6SBhanu Prakash Gollapudi  * + 4 (FC CRC) + 4 (FCoE trailer) =  2158 bytes
28f4d2b2b6SBhanu Prakash Gollapudi  */
29f4d2b2b6SBhanu Prakash Gollapudi #define FCOE_MTU	2158
30f4d2b2b6SBhanu Prakash Gollapudi 
31f4d2b2b6SBhanu Prakash Gollapudi /*
3297c8389dSJoe Eykholt  * FIP tunable parameters.
3397c8389dSJoe Eykholt  */
3497c8389dSJoe Eykholt #define FCOE_CTLR_START_DELAY	2000	/* mS after first adv. to choose FCF */
355523ca8fSChristophe JAILLET #define FCOE_CTLR_SOL_TOV	2000	/* min. solicitation interval (mS) */
3697c8389dSJoe Eykholt #define FCOE_CTLR_FCF_LIMIT	20	/* max. number of FCF entries */
37e10f8c66SJoe Eykholt #define FCOE_CTLR_VN2VN_LOGIN_LIMIT 3	/* max. VN2VN rport login retries */
3897c8389dSJoe Eykholt 
3997c8389dSJoe Eykholt /**
4097c8389dSJoe Eykholt  * enum fip_state - internal state of FCoE controller.
4197c8389dSJoe Eykholt  * @FIP_ST_DISABLED: 	controller has been disabled or not yet enabled.
4297c8389dSJoe Eykholt  * @FIP_ST_LINK_WAIT:	the physical link is down or unusable.
4397c8389dSJoe Eykholt  * @FIP_ST_AUTO:	determining whether to use FIP or non-FIP mode.
4497c8389dSJoe Eykholt  * @FIP_ST_NON_FIP:	non-FIP mode selected.
4597c8389dSJoe Eykholt  * @FIP_ST_ENABLED:	FIP mode selected.
46e10f8c66SJoe Eykholt  * @FIP_ST_VNMP_START:	VN2VN multipath mode start, wait
47e10f8c66SJoe Eykholt  * @FIP_ST_VNMP_PROBE1:	VN2VN sent first probe, listening
48e10f8c66SJoe Eykholt  * @FIP_ST_VNMP_PROBE2:	VN2VN sent second probe, listening
49e10f8c66SJoe Eykholt  * @FIP_ST_VNMP_CLAIM:	VN2VN sent claim, waiting for responses
50e10f8c66SJoe Eykholt  * @FIP_ST_VNMP_UP:	VN2VN multipath mode operation
5197c8389dSJoe Eykholt  */
5297c8389dSJoe Eykholt enum fip_state {
5397c8389dSJoe Eykholt 	FIP_ST_DISABLED,
5497c8389dSJoe Eykholt 	FIP_ST_LINK_WAIT,
5597c8389dSJoe Eykholt 	FIP_ST_AUTO,
5697c8389dSJoe Eykholt 	FIP_ST_NON_FIP,
5797c8389dSJoe Eykholt 	FIP_ST_ENABLED,
58e10f8c66SJoe Eykholt 	FIP_ST_VNMP_START,
59e10f8c66SJoe Eykholt 	FIP_ST_VNMP_PROBE1,
60e10f8c66SJoe Eykholt 	FIP_ST_VNMP_PROBE2,
61e10f8c66SJoe Eykholt 	FIP_ST_VNMP_CLAIM,
62e10f8c66SJoe Eykholt 	FIP_ST_VNMP_UP,
6397c8389dSJoe Eykholt };
6497c8389dSJoe Eykholt 
653d902ac0SJoe Eykholt /*
663d902ac0SJoe Eykholt  * Modes:
673d902ac0SJoe Eykholt  * The mode is the state that is to be entered after link up.
683d902ac0SJoe Eykholt  * It must not change after fcoe_ctlr_init() sets it.
693d902ac0SJoe Eykholt  */
701917d42dSHannes Reinecke enum fip_mode {
718beb90aaSSedat Dilek 	FIP_MODE_AUTO,
721917d42dSHannes Reinecke 	FIP_MODE_NON_FIP,
731917d42dSHannes Reinecke 	FIP_MODE_FABRIC,
741917d42dSHannes Reinecke 	FIP_MODE_VN2VN,
751917d42dSHannes Reinecke };
763d902ac0SJoe Eykholt 
7797c8389dSJoe Eykholt /**
7870b51aabSRobert Love  * struct fcoe_ctlr - FCoE Controller and FIP state
7997c8389dSJoe Eykholt  * @state:	   internal FIP state for network link and FIP or non-FIP mode.
8022bcd225SJoe Eykholt  * @mode:	   LLD-selected mode.
8197c8389dSJoe Eykholt  * @lp:		   &fc_lport: libfc local port.
8297c8389dSJoe Eykholt  * @sel_fcf:	   currently selected FCF, or NULL.
8397c8389dSJoe Eykholt  * @fcfs:	   list of discovered FCFs.
849d34876fSRobert Love  * @cdev:          (Optional) pointer to sysfs fcoe_ctlr_device.
8597c8389dSJoe Eykholt  * @fcf_count:	   number of discovered FCF entries.
8697c8389dSJoe Eykholt  * @sol_time:	   time when a multicast solicitation was last sent.
8797c8389dSJoe Eykholt  * @sel_time:	   time after which to select an FCF.
8897c8389dSJoe Eykholt  * @port_ka_time:  time of next port keep-alive.
8997c8389dSJoe Eykholt  * @ctlr_ka_time:  time of next controller keep-alive.
9097c8389dSJoe Eykholt  * @timer:	   timer struct used for all delayed events.
9142913657SJoe Eykholt  * @timer_work:	   &work_struct for doing keep-alives and resets.
9297c8389dSJoe Eykholt  * @recv_work:	   &work_struct for receiving FIP frames.
9397c8389dSJoe Eykholt  * @fip_recv_list: list of received FIP frames.
94794d98e7SJoe Eykholt  * @flogi_req:	   clone of FLOGI request sent
95e10f8c66SJoe Eykholt  * @rnd_state:	   state for pseudo-random number generator.
96e10f8c66SJoe Eykholt  * @port_id:	   proposed or selected local-port ID.
9797c8389dSJoe Eykholt  * @user_mfs:	   configured maximum FC frame size, including FC header.
9897c8389dSJoe Eykholt  * @flogi_oxid:    exchange ID of most recent fabric login.
99794d98e7SJoe Eykholt  * @flogi_req_send: send of FLOGI requested
10097c8389dSJoe Eykholt  * @flogi_count:   number of FLOGI attempts in AUTO mode.
10197c8389dSJoe Eykholt  * @map_dest:	   use the FC_MAP mode for destination MAC addresses.
1029a6cf881SHannes Reinecke  * @fip_resp:	   start FIP VLAN discovery responder
103184dd345SVasu Dev  * @spma:	   supports SPMA server-provided MACs mode
104e10f8c66SJoe Eykholt  * @probe_tries:   number of FC_IDs probed
1059a6cf881SHannes Reinecke  * @priority:      DCBx FCoE APP priority
10697c8389dSJoe Eykholt  * @dest_addr:	   MAC address of the selected FC forwarder.
10797c8389dSJoe Eykholt  * @ctl_src_addr:  the native MAC address of our local port.
10870b51aabSRobert Love  * @send:	   LLD-supplied function to handle sending FIP Ethernet frames
10997c8389dSJoe Eykholt  * @update_mac:    LLD-supplied function to handle changes to MAC addresses.
11011b56188SChris Leech  * @get_src_addr:  LLD-supplied function to supply a source MAC address.
111fdb068c6SJoe Eykholt  * @ctlr_mutex:	   lock protecting this structure.
112794d98e7SJoe Eykholt  * @ctlr_lock:     spinlock covering flogi_req
11397c8389dSJoe Eykholt  *
11497c8389dSJoe Eykholt  * This structure is used by all FCoE drivers.  It contains information
11597c8389dSJoe Eykholt  * needed by all FCoE low-level drivers (LLDs) as well as internal state
11697c8389dSJoe Eykholt  * for FIP, and fields shared with the LLDS.
11797c8389dSJoe Eykholt  */
11897c8389dSJoe Eykholt struct fcoe_ctlr {
11997c8389dSJoe Eykholt 	enum fip_state state;
1201917d42dSHannes Reinecke 	enum fip_mode mode;
12197c8389dSJoe Eykholt 	struct fc_lport *lp;
12297c8389dSJoe Eykholt 	struct fcoe_fcf *sel_fcf;
12397c8389dSJoe Eykholt 	struct list_head fcfs;
1249d34876fSRobert Love 	struct fcoe_ctlr_device *cdev;
12597c8389dSJoe Eykholt 	u16 fcf_count;
12697c8389dSJoe Eykholt 	unsigned long sol_time;
12797c8389dSJoe Eykholt 	unsigned long sel_time;
12897c8389dSJoe Eykholt 	unsigned long port_ka_time;
12997c8389dSJoe Eykholt 	unsigned long ctlr_ka_time;
13097c8389dSJoe Eykholt 	struct timer_list timer;
13142913657SJoe Eykholt 	struct work_struct timer_work;
13297c8389dSJoe Eykholt 	struct work_struct recv_work;
13397c8389dSJoe Eykholt 	struct sk_buff_head fip_recv_list;
134794d98e7SJoe Eykholt 	struct sk_buff *flogi_req;
135e10f8c66SJoe Eykholt 
136e10f8c66SJoe Eykholt 	struct rnd_state rnd_state;
137e10f8c66SJoe Eykholt 	u32 port_id;
138e10f8c66SJoe Eykholt 
13997c8389dSJoe Eykholt 	u16 user_mfs;
14097c8389dSJoe Eykholt 	u16 flogi_oxid;
141794d98e7SJoe Eykholt 	u8 flogi_req_send;
14297c8389dSJoe Eykholt 	u8 flogi_count;
1439a6cf881SHannes Reinecke 	bool map_dest;
1449a6cf881SHannes Reinecke 	bool fip_resp;
145184dd345SVasu Dev 	u8 spma;
146e10f8c66SJoe Eykholt 	u8 probe_tries;
1476f6c2aa3Sjohn fastabend 	u8 priority;
14897c8389dSJoe Eykholt 	u8 dest_addr[ETH_ALEN];
14997c8389dSJoe Eykholt 	u8 ctl_src_addr[ETH_ALEN];
15097c8389dSJoe Eykholt 
15197c8389dSJoe Eykholt 	void (*send)(struct fcoe_ctlr *, struct sk_buff *);
15211b56188SChris Leech 	void (*update_mac)(struct fc_lport *, u8 *addr);
15311b56188SChris Leech 	u8 * (*get_src_addr)(struct fc_lport *);
154fdb068c6SJoe Eykholt 	struct mutex ctlr_mutex;
155794d98e7SJoe Eykholt 	spinlock_t ctlr_lock;
15697c8389dSJoe Eykholt };
15797c8389dSJoe Eykholt 
15870b51aabSRobert Love /**
159619fe4beSRobert Love  * fcoe_ctlr_priv() - Return the private data from a fcoe_ctlr
160619fe4beSRobert Love  * @cltr: The fcoe_ctlr whose private data will be returned
161619fe4beSRobert Love  */
162619fe4beSRobert Love static inline void *fcoe_ctlr_priv(const struct fcoe_ctlr *ctlr)
163619fe4beSRobert Love {
164619fe4beSRobert Love 	return (void *)(ctlr + 1);
165619fe4beSRobert Love }
166619fe4beSRobert Love 
1679d34876fSRobert Love /*
1689d34876fSRobert Love  * This assumes that the fcoe_ctlr (x) is allocated with the fcoe_ctlr_device.
1699d34876fSRobert Love  */
1708d55e507SRobert Love #define fcoe_ctlr_to_ctlr_dev(x)					\
1719d34876fSRobert Love 	(x)->cdev
1728d55e507SRobert Love 
173619fe4beSRobert Love /**
17470b51aabSRobert Love  * struct fcoe_fcf - Fibre-Channel Forwarder
17570b51aabSRobert Love  * @list:	 list linkage
1768d55e507SRobert Love  * @event_work:  Work for FC Transport actions queue
1778d55e507SRobert Love  * @event:       The event to be processed
1788d55e507SRobert Love  * @fip:         The controller that the FCF was discovered on
1798d55e507SRobert Love  * @fcf_dev:     The associated fcoe_fcf_device instance
18070b51aabSRobert Love  * @time:	 system time (jiffies) when an advertisement was last received
18170b51aabSRobert Love  * @switch_name: WWN of switch from advertisement
18270b51aabSRobert Love  * @fabric_name: WWN of fabric from advertisement
18370b51aabSRobert Love  * @fc_map:	 FC_MAP value from advertisement
18481c11dd2SBhanu Prakash Gollapudi  * @fcf_mac:	 Ethernet address of the FCF for FIP traffic
18581c11dd2SBhanu Prakash Gollapudi  * @fcoe_mac:	 Ethernet address of the FCF for FCoE traffic
18670b51aabSRobert Love  * @vfid:	 virtual fabric ID
18770b51aabSRobert Love  * @pri:	 selection priority, smaller values are better
188794d98e7SJoe Eykholt  * @flogi_sent:	 current FLOGI sent to this FCF
18970b51aabSRobert Love  * @flags:	 flags received from advertisement
19070b51aabSRobert Love  * @fka_period:	 keep-alive period, in jiffies
19197c8389dSJoe Eykholt  *
19297c8389dSJoe Eykholt  * A Fibre-Channel Forwarder (FCF) is the entity on the Ethernet that
19397c8389dSJoe Eykholt  * passes FCoE frames on to an FC fabric.  This structure represents
19497c8389dSJoe Eykholt  * one FCF from which advertisements have been received.
19597c8389dSJoe Eykholt  *
19697c8389dSJoe Eykholt  * When looking up an FCF, @switch_name, @fabric_name, @fc_map, @vfid, and
19797c8389dSJoe Eykholt  * @fcf_mac together form the lookup key.
19897c8389dSJoe Eykholt  */
19997c8389dSJoe Eykholt struct fcoe_fcf {
20097c8389dSJoe Eykholt 	struct list_head list;
2018d55e507SRobert Love 	struct work_struct event_work;
2028d55e507SRobert Love 	struct fcoe_ctlr *fip;
2038d55e507SRobert Love 	struct fcoe_fcf_device *fcf_dev;
20497c8389dSJoe Eykholt 	unsigned long time;
20597c8389dSJoe Eykholt 
20697c8389dSJoe Eykholt 	u64 switch_name;
20797c8389dSJoe Eykholt 	u64 fabric_name;
20897c8389dSJoe Eykholt 	u32 fc_map;
20997c8389dSJoe Eykholt 	u16 vfid;
21097c8389dSJoe Eykholt 	u8 fcf_mac[ETH_ALEN];
21181c11dd2SBhanu Prakash Gollapudi 	u8 fcoe_mac[ETH_ALEN];
21297c8389dSJoe Eykholt 
21397c8389dSJoe Eykholt 	u8 pri;
214794d98e7SJoe Eykholt 	u8 flogi_sent;
21597c8389dSJoe Eykholt 	u16 flags;
21697c8389dSJoe Eykholt 	u32 fka_period;
2178cdffdccSYi Zou 	u8 fd_flags:1;
21897c8389dSJoe Eykholt };
21997c8389dSJoe Eykholt 
2208d55e507SRobert Love #define fcoe_fcf_to_fcf_dev(x)			\
2218d55e507SRobert Love 	((x)->fcf_dev)
2228d55e507SRobert Love 
223e10f8c66SJoe Eykholt /**
224e10f8c66SJoe Eykholt  * struct fcoe_rport - VN2VN remote port
225e10f8c66SJoe Eykholt  * @time:	time of create or last beacon packet received from node
226e10f8c66SJoe Eykholt  * @fcoe_len:	max FCoE frame size, not including VLAN or Ethernet headers
227e10f8c66SJoe Eykholt  * @flags:	flags from probe or claim
228e10f8c66SJoe Eykholt  * @login_count: number of unsuccessful rport logins to this port
229e10f8c66SJoe Eykholt  * @enode_mac:	E_Node control MAC address
230e10f8c66SJoe Eykholt  * @vn_mac:	VN_Node assigned MAC address for data
231e10f8c66SJoe Eykholt  */
232e10f8c66SJoe Eykholt struct fcoe_rport {
233023358b1SHannes Reinecke 	struct fc_rport_priv rdata;
234e10f8c66SJoe Eykholt 	unsigned long time;
235e10f8c66SJoe Eykholt 	u16 fcoe_len;
236e10f8c66SJoe Eykholt 	u16 flags;
237e10f8c66SJoe Eykholt 	u8 login_count;
238e10f8c66SJoe Eykholt 	u8 enode_mac[ETH_ALEN];
239e10f8c66SJoe Eykholt 	u8 vn_mac[ETH_ALEN];
240e10f8c66SJoe Eykholt };
241e10f8c66SJoe Eykholt 
24297c8389dSJoe Eykholt /* FIP API functions */
2438beb90aaSSedat Dilek void fcoe_ctlr_init(struct fcoe_ctlr *, enum fip_mode);
24497c8389dSJoe Eykholt void fcoe_ctlr_destroy(struct fcoe_ctlr *);
24597c8389dSJoe Eykholt void fcoe_ctlr_link_up(struct fcoe_ctlr *);
24697c8389dSJoe Eykholt int fcoe_ctlr_link_down(struct fcoe_ctlr *);
24711b56188SChris Leech int fcoe_ctlr_els_send(struct fcoe_ctlr *, struct fc_lport *, struct sk_buff *);
24897c8389dSJoe Eykholt void fcoe_ctlr_recv(struct fcoe_ctlr *, struct sk_buff *);
24970b51aabSRobert Love int fcoe_ctlr_recv_flogi(struct fcoe_ctlr *, struct fc_lport *,
250386309ceSJoe Eykholt 			 struct fc_frame *);
25197c8389dSJoe Eykholt 
25285b4aa49SRobert Love /* libfcoe funcs */
253e7c6e405SLinus Torvalds u64 fcoe_wwn_from_mac(unsigned char mac[MAX_ADDR_LEN], unsigned int, unsigned int);
254e10f8c66SJoe Eykholt int fcoe_libfc_config(struct fc_lport *, struct fcoe_ctlr *,
255e10f8c66SJoe Eykholt 		      const struct libfc_function_template *, int init_fcp);
2568597ae8bSBhanu Prakash Gollapudi u32 fcoe_fc_crc(struct fc_frame *fp);
2578597ae8bSBhanu Prakash Gollapudi int fcoe_start_io(struct sk_buff *skb);
258d834895cSBhanu Prakash Gollapudi int fcoe_get_wwn(struct net_device *netdev, u64 *wwn, int type);
259814740d5SBhanu Prakash Gollapudi void __fcoe_get_lesb(struct fc_lport *lport, struct fc_els_lesb *fc_lesb,
260814740d5SBhanu Prakash Gollapudi 		     struct net_device *netdev);
261d834895cSBhanu Prakash Gollapudi void fcoe_wwn_to_str(u64 wwn, char *buf, int len);
262d834895cSBhanu Prakash Gollapudi int fcoe_validate_vport_create(struct fc_vport *vport);
26303702689SYi Zou int fcoe_link_speed_update(struct fc_lport *);
26457c2728fSYi Zou void fcoe_get_lesb(struct fc_lport *, struct fc_els_lesb *);
26557c2728fSYi Zou void fcoe_ctlr_get_lesb(struct fcoe_ctlr_device *ctlr_dev);
266fdd78027SVasu Dev 
267519e5135SVasu Dev /**
268519e5135SVasu Dev  * is_fip_mode() - returns true if FIP mode selected.
269519e5135SVasu Dev  * @fip:	FCoE controller.
270519e5135SVasu Dev  */
271519e5135SVasu Dev static inline bool is_fip_mode(struct fcoe_ctlr *fip)
272519e5135SVasu Dev {
273519e5135SVasu Dev 	return fip->state == FIP_ST_ENABLED;
274519e5135SVasu Dev }
275519e5135SVasu Dev 
2760ade7d29SYi Zou /* helper for FCoE SW HBA drivers, can include subven and subdev if needed. The
2770ade7d29SYi Zou  * modpost would use pci_device_id table to auto-generate formatted module alias
2780ade7d29SYi Zou  * into the corresponding .mod.c file, but there may or may not be a pci device
2790ade7d29SYi Zou  * id table for FCoE drivers so we use the following helper for build the fcoe
2800ade7d29SYi Zou  * driver module alias.
2810ade7d29SYi Zou  */
2820ade7d29SYi Zou #define MODULE_ALIAS_FCOE_PCI(ven, dev) \
2830ade7d29SYi Zou 	MODULE_ALIAS("fcoe-pci:"	\
2840ade7d29SYi Zou 		"v" __stringify(ven)	\
2850ade7d29SYi Zou 		"d" __stringify(dev) "sv*sd*bc*sc*i*")
2860ade7d29SYi Zou 
2870ade7d29SYi Zou /* the name of the default FCoE transport driver fcoe.ko */
2880ade7d29SYi Zou #define FCOE_TRANSPORT_DEFAULT	"fcoe"
2890ade7d29SYi Zou 
2900ade7d29SYi Zou /* struct fcoe_transport - The FCoE transport interface
2910ade7d29SYi Zou  * @name:	a vendor specific name for their FCoE transport driver
2920ade7d29SYi Zou  * @attached:	whether this transport is already attached
2930ade7d29SYi Zou  * @list:	list linkage to all attached transports
2940ade7d29SYi Zou  * @match:	handler to allow the transport driver to match up a given netdev
2956a891b07SRobert Love  * @alloc:      handler to allocate per-instance FCoE structures
2966a891b07SRobert Love  *		(no discovery or login)
2970ade7d29SYi Zou  * @create:	handler to sysfs entry of create for FCoE instances
2986a891b07SRobert Love  * @destroy:    handler to delete per-instance FCoE structures
2996a891b07SRobert Love  *		(frees all memory)
3000ade7d29SYi Zou  * @enable:	handler to sysfs entry of enable for FCoE instances
3010ade7d29SYi Zou  * @disable:	handler to sysfs entry of disable for FCoE instances
3020ade7d29SYi Zou  */
3030ade7d29SYi Zou struct fcoe_transport {
3040ade7d29SYi Zou 	char name[IFNAMSIZ];
3050ade7d29SYi Zou 	bool attached;
3060ade7d29SYi Zou 	struct list_head list;
3070ade7d29SYi Zou 	bool (*match) (struct net_device *device);
3086a891b07SRobert Love 	int (*alloc) (struct net_device *device);
3091917d42dSHannes Reinecke 	int (*create) (struct net_device *device, enum fip_mode fip_mode);
3100ade7d29SYi Zou 	int (*destroy) (struct net_device *device);
3110ade7d29SYi Zou 	int (*enable) (struct net_device *device);
3120ade7d29SYi Zou 	int (*disable) (struct net_device *device);
3130ade7d29SYi Zou };
3140ade7d29SYi Zou 
3150ade7d29SYi Zou /**
3168597ae8bSBhanu Prakash Gollapudi  * struct fcoe_percpu_s - The context for FCoE receive thread(s)
3174b9bc86dSSebastian Andrzej Siewior  * @kthread:	    The thread context (used by bnx2fc)
3184b9bc86dSSebastian Andrzej Siewior  * @work:	    The work item (used by fcoe)
3198597ae8bSBhanu Prakash Gollapudi  * @fcoe_rx_list:   The queue of pending packets to process
3208597ae8bSBhanu Prakash Gollapudi  * @page:	    The memory page for calculating frame trailer CRCs
3218597ae8bSBhanu Prakash Gollapudi  * @crc_eof_offset: The offset into the CRC page pointing to available
3228597ae8bSBhanu Prakash Gollapudi  *		    memory for a new trailer
3238597ae8bSBhanu Prakash Gollapudi  */
3248597ae8bSBhanu Prakash Gollapudi struct fcoe_percpu_s {
3254b9bc86dSSebastian Andrzej Siewior 	struct task_struct *kthread;
3264b9bc86dSSebastian Andrzej Siewior 	struct work_struct work;
3278597ae8bSBhanu Prakash Gollapudi 	struct sk_buff_head fcoe_rx_list;
3288597ae8bSBhanu Prakash Gollapudi 	struct page *crc_eof_page;
3298597ae8bSBhanu Prakash Gollapudi 	int crc_eof_offset;
330*848b8977SDavidlohr Bueso 	local_lock_t lock;
3318597ae8bSBhanu Prakash Gollapudi };
3328597ae8bSBhanu Prakash Gollapudi 
3338597ae8bSBhanu Prakash Gollapudi /**
3348597ae8bSBhanu Prakash Gollapudi  * struct fcoe_port - The FCoE private structure
3358597ae8bSBhanu Prakash Gollapudi  * @priv:		       The associated fcoe interface. The structure is
3368597ae8bSBhanu Prakash Gollapudi  *			       defined by the low level driver
3378597ae8bSBhanu Prakash Gollapudi  * @lport:		       The associated local port
3388597ae8bSBhanu Prakash Gollapudi  * @fcoe_pending_queue:	       The pending Rx queue of skbs
3398597ae8bSBhanu Prakash Gollapudi  * @fcoe_pending_queue_active: Indicates if the pending queue is active
3408597ae8bSBhanu Prakash Gollapudi  * @max_queue_depth:	       Max queue depth of pending queue
3418597ae8bSBhanu Prakash Gollapudi  * @min_queue_depth:	       Min queue depth of pending queue
3428597ae8bSBhanu Prakash Gollapudi  * @timer:		       The queue timer
3438597ae8bSBhanu Prakash Gollapudi  * @destroy_work:	       Handle for work context
3448597ae8bSBhanu Prakash Gollapudi  *			       (to prevent RTNL deadlocks)
3458597ae8bSBhanu Prakash Gollapudi  * @data_srt_addr:	       Source address for data
3468597ae8bSBhanu Prakash Gollapudi  *
3478597ae8bSBhanu Prakash Gollapudi  * An instance of this structure is to be allocated along with the
3488597ae8bSBhanu Prakash Gollapudi  * Scsi_Host and libfc fc_lport structures.
3498597ae8bSBhanu Prakash Gollapudi  */
3508597ae8bSBhanu Prakash Gollapudi struct fcoe_port {
3518597ae8bSBhanu Prakash Gollapudi 	void		      *priv;
3528597ae8bSBhanu Prakash Gollapudi 	struct fc_lport	      *lport;
3538597ae8bSBhanu Prakash Gollapudi 	struct sk_buff_head   fcoe_pending_queue;
3548597ae8bSBhanu Prakash Gollapudi 	u8		      fcoe_pending_queue_active;
3558597ae8bSBhanu Prakash Gollapudi 	u32		      max_queue_depth;
3568597ae8bSBhanu Prakash Gollapudi 	u32		      min_queue_depth;
3578597ae8bSBhanu Prakash Gollapudi 	struct timer_list     timer;
3588597ae8bSBhanu Prakash Gollapudi 	struct work_struct    destroy_work;
3598597ae8bSBhanu Prakash Gollapudi 	u8		      data_src_addr[ETH_ALEN];
3608106fb47SYi Zou 	struct net_device * (*get_netdev)(const struct fc_lport *lport);
3618597ae8bSBhanu Prakash Gollapudi };
36266524ec9SYi Zou 
36366524ec9SYi Zou /**
36466524ec9SYi Zou  * fcoe_get_netdev() - Return the net device associated with a local port
36566524ec9SYi Zou  * @lport: The local port to get the net device from
36666524ec9SYi Zou  */
36766524ec9SYi Zou static inline struct net_device *fcoe_get_netdev(const struct fc_lport *lport)
36866524ec9SYi Zou {
36966524ec9SYi Zou 	struct fcoe_port *port = ((struct fcoe_port *)lport_priv(lport));
37066524ec9SYi Zou 
37166524ec9SYi Zou 	return (port->get_netdev) ? port->get_netdev(lport) : NULL;
37266524ec9SYi Zou }
37366524ec9SYi Zou 
3748597ae8bSBhanu Prakash Gollapudi void fcoe_clean_pending_queue(struct fc_lport *);
3758597ae8bSBhanu Prakash Gollapudi void fcoe_check_wait_queue(struct fc_lport *lport, struct sk_buff *skb);
37613059106SKees Cook void fcoe_queue_timer(struct timer_list *t);
3778597ae8bSBhanu Prakash Gollapudi int fcoe_get_paged_crc_eof(struct sk_buff *skb, int tlen,
3788597ae8bSBhanu Prakash Gollapudi 			   struct fcoe_percpu_s *fps);
3798597ae8bSBhanu Prakash Gollapudi 
3808d55e507SRobert Love /* FCoE Sysfs helpers */
3818d55e507SRobert Love void fcoe_fcf_get_selected(struct fcoe_fcf_device *);
3826a891b07SRobert Love void fcoe_ctlr_set_fip_mode(struct fcoe_ctlr_device *);
3838d55e507SRobert Love 
3848597ae8bSBhanu Prakash Gollapudi /**
3850ade7d29SYi Zou  * struct netdev_list
3860ade7d29SYi Zou  * A mapping from netdevice to fcoe_transport
3870ade7d29SYi Zou  */
3880ade7d29SYi Zou struct fcoe_netdev_mapping {
3890ade7d29SYi Zou 	struct list_head list;
3900ade7d29SYi Zou 	struct net_device *netdev;
3910ade7d29SYi Zou 	struct fcoe_transport *ft;
3920ade7d29SYi Zou };
3930ade7d29SYi Zou 
3940ade7d29SYi Zou /* fcoe transports registration and deregistration */
3950ade7d29SYi Zou int fcoe_transport_attach(struct fcoe_transport *ft);
3960ade7d29SYi Zou int fcoe_transport_detach(struct fcoe_transport *ft);
397519e5135SVasu Dev 
3986a891b07SRobert Love /* sysfs store handler for ctrl_control interface */
3996a891b07SRobert Love ssize_t fcoe_ctlr_create_store(struct bus_type *bus,
4006a891b07SRobert Love 			       const char *buf, size_t count);
4016a891b07SRobert Love ssize_t fcoe_ctlr_destroy_store(struct bus_type *bus,
4026a891b07SRobert Love 				const char *buf, size_t count);
4036a891b07SRobert Love 
40485b4aa49SRobert Love #endif /* _LIBFCOE_H */
4056a891b07SRobert Love 
4066a891b07SRobert Love 
407