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