xref: /linux/drivers/scsi/fcoe/fcoe.h (revision 8e07e0e3964ca4e23ce7b68e2096fe660a888942)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Copyright(c) 2009 Intel Corporation. All rights reserved.
4  *
5  * Maintained at www.Open-FCoE.org
6  */
7 
8 #ifndef _FCOE_H_
9 #define _FCOE_H_
10 
11 #include <linux/skbuff.h>
12 #include <linux/kthread.h>
13 
14 #define FCOE_MAX_QUEUE_DEPTH	256
15 #define FCOE_MIN_QUEUE_DEPTH	32
16 
17 #define FCOE_WORD_TO_BYTE	4
18 
19 #define FCOE_VERSION	"0.1"
20 #define FCOE_NAME	"fcoe"
21 #define FCOE_VENDOR	"Open-FCoE.org"
22 
23 #define FCOE_MAX_LUN		0xFFFF
24 #define FCOE_MAX_FCP_TARGET	256
25 
26 #define FCOE_MAX_OUTSTANDING_COMMANDS	1024
27 
28 #define FCOE_MIN_XID		0x0000	/* the min xid supported by fcoe_sw */
29 #define FCOE_MAX_XID		0x0FFF	/* the max xid supported by fcoe_sw */
30 
31 extern unsigned int fcoe_debug_logging;
32 
33 #define FCOE_LOGGING	    0x01 /* General logging, not categorized */
34 #define FCOE_NETDEV_LOGGING 0x02 /* Netdevice logging */
35 
36 #define FCOE_CHECK_LOGGING(LEVEL, CMD)					\
37 do {                                                            	\
38 	if (unlikely(fcoe_debug_logging & LEVEL))			\
39 		do {							\
40 			CMD;						\
41 		} while (0);						\
42 } while (0)
43 
44 #define FCOE_DBG(fmt, args...)						\
45 	FCOE_CHECK_LOGGING(FCOE_LOGGING,				\
46 			   pr_info("fcoe: " fmt, ##args);)
47 
48 #define FCOE_NETDEV_DBG(netdev, fmt, args...)			\
49 	FCOE_CHECK_LOGGING(FCOE_NETDEV_LOGGING,			\
50 			   pr_info("fcoe: %s: " fmt,		\
51 				   netdev->name, ##args);)
52 
53 /**
54  * struct fcoe_interface - A FCoE interface
55  * @list:	      Handle for a list of FCoE interfaces
56  * @netdev:	      The associated net device
57  * @fcoe_packet_type: FCoE packet type
58  * @fip_packet_type:  FIP packet type
59  * @oem:	      The offload exchange manager for all local port
60  *		      instances associated with this port
61  * @removed:	      Indicates fcoe interface removed from net device
62  * @priority:	      Priority for the FCoE packet (DCB)
63  * This structure is 1:1 with a net device.
64  */
65 struct fcoe_interface {
66 	struct list_head   list;
67 	struct net_device  *netdev;
68 	struct net_device  *realdev;
69 	struct packet_type fcoe_packet_type;
70 	struct packet_type fip_packet_type;
71 	struct packet_type fip_vlan_packet_type;
72 	struct fc_exch_mgr *oem;
73 	u8	removed;
74 	u8	priority;
75 };
76 
77 #define fcoe_to_ctlr(x)						\
78 	(struct fcoe_ctlr *)(((struct fcoe_ctlr *)(x)) - 1)
79 
80 #define fcoe_from_ctlr(x)			\
81 	((struct fcoe_interface *)((x) + 1))
82 
83 /**
84  * fcoe_netdev() - Return the net device associated with a local port
85  * @lport: The local port to get the net device from
86  */
87 static inline struct net_device *fcoe_netdev(const struct fc_lport *lport)
88 {
89 	return ((struct fcoe_interface *)
90 			((struct fcoe_port *)lport_priv(lport))->priv)->netdev;
91 }
92 
93 #endif /* _FCOE_H_ */
94