^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) 2007 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 _FC_FCOE_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #define _FC_FCOE_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * FCoE - Fibre Channel over Ethernet.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * See T11 FC-BB-5 Rev 2.00 (09-056v5.pdf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * Default FC_FCOE_OUI / FC-MAP value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #define FC_FCOE_OUI 0x0efc00 /* upper 24 bits of FCOE MAC */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * Fabric Login (FLOGI) MAC for non-FIP use. Non-FIP use is deprecated.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #define FC_FCOE_FLOGI_MAC { 0x0e, 0xfc, 0x00, 0xff, 0xff, 0xfe }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #define FC_FCOE_VER 0 /* version */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) * Ethernet Addresses based on FC S_ID and D_ID.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) * Generated by FC_FCOE_OUI | S_ID/D_ID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #define FC_FCOE_ENCAPS_ID(n) (((u64) FC_FCOE_OUI << 24) | (n))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #define FC_FCOE_DECAPS_ID(n) ((n) >> 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) * FCoE frame header - 14 bytes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) * This follows the VLAN header, which includes the ethertype.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) struct fcoe_hdr {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) __u8 fcoe_ver; /* version field - upper 4 bits */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) __u8 fcoe_resvd[12]; /* reserved - send zero and ignore */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) __u8 fcoe_sof; /* start of frame per RFC 3643 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) #define FC_FCOE_DECAPS_VER(hp) ((hp)->fcoe_ver >> 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) #define FC_FCOE_ENCAPS_VER(hp, ver) ((hp)->fcoe_ver = (ver) << 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) * FCoE CRC & EOF - 8 bytes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) struct fcoe_crc_eof {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) __le32 fcoe_crc32; /* CRC for FC packet */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) __u8 fcoe_eof; /* EOF from RFC 3643 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) __u8 fcoe_resvd[3]; /* reserved - send zero and ignore */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) } __attribute__((packed));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) * Minimum FCoE + FC header length
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) * 14 bytes FCoE header + 24 byte FC header = 38 bytes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) #define FCOE_HEADER_LEN 38
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) * Minimum FCoE frame size
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) * 14 bytes FCoE header + 24 byte FC header + 8 byte FCoE trailer = 46 bytes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) #define FCOE_MIN_FRAME 46
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) * FCoE Link Error Status Block: T11 FC-BB-5 Rev2.0, Clause 7.10.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) struct fcoe_fc_els_lesb {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) __be32 lesb_link_fail; /* link failure count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) __be32 lesb_vlink_fail; /* virtual link failure count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) __be32 lesb_miss_fka; /* missing FIP keep-alive count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) __be32 lesb_symb_err; /* symbol error during carrier count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) __be32 lesb_err_block; /* errored block count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) __be32 lesb_fcs_error; /* frame check sequence error count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) * fc_fcoe_set_mac - Store OUI + DID into MAC address field.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) * @mac: mac address to be set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) * @did: fc dest id to use
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) static inline void fc_fcoe_set_mac(u8 *mac, u8 *did)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) mac[0] = (u8) (FC_FCOE_OUI >> 16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) mac[1] = (u8) (FC_FCOE_OUI >> 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) mac[2] = (u8) FC_FCOE_OUI;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) mac[3] = did[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) mac[4] = did[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) mac[5] = did[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) #endif /* _FC_FCOE_H_ */