Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Copyright(c) 2007 Intel Corporation. All rights reserved.
0004  *
0005  * Maintained at www.Open-FCoE.org
0006  */
0007 
0008 #ifndef _FC_FCOE_H_
0009 #define _FC_FCOE_H_
0010 
0011 /*
0012  * FCoE - Fibre Channel over Ethernet.
0013  * See T11 FC-BB-5 Rev 2.00 (09-056v5.pdf)
0014  */
0015 
0016 /*
0017  * Default FC_FCOE_OUI / FC-MAP value.
0018  */
0019 #define FC_FCOE_OUI 0x0efc00    /* upper 24 bits of FCOE MAC */
0020 
0021 /*
0022  * Fabric Login (FLOGI) MAC for non-FIP use.  Non-FIP use is deprecated.
0023  */
0024 #define FC_FCOE_FLOGI_MAC { 0x0e, 0xfc, 0x00, 0xff, 0xff, 0xfe }
0025 
0026 #define FC_FCOE_VER 0           /* version */
0027 
0028 /*
0029  * Ethernet Addresses based on FC S_ID and D_ID.
0030  * Generated by FC_FCOE_OUI | S_ID/D_ID
0031  */
0032 #define FC_FCOE_ENCAPS_ID(n)    (((u64) FC_FCOE_OUI << 24) | (n))
0033 #define FC_FCOE_DECAPS_ID(n)    ((n) >> 24)
0034 
0035 /*
0036  * FCoE frame header - 14 bytes
0037  * This follows the VLAN header, which includes the ethertype.
0038  */
0039 struct fcoe_hdr {
0040     __u8        fcoe_ver;   /* version field - upper 4 bits */
0041     __u8        fcoe_resvd[12]; /* reserved - send zero and ignore */
0042     __u8        fcoe_sof;   /* start of frame per RFC 3643 */
0043 };
0044 
0045 #define FC_FCOE_DECAPS_VER(hp)      ((hp)->fcoe_ver >> 4)
0046 #define FC_FCOE_ENCAPS_VER(hp, ver) ((hp)->fcoe_ver = (ver) << 4)
0047 
0048 /*
0049  * FCoE CRC & EOF - 8 bytes.
0050  */
0051 struct fcoe_crc_eof {
0052     __le32      fcoe_crc32; /* CRC for FC packet */
0053     __u8        fcoe_eof;   /* EOF from RFC 3643 */
0054     __u8        fcoe_resvd[3];  /* reserved - send zero and ignore */
0055 } __attribute__((packed));
0056 
0057 /*
0058  * Minimum FCoE + FC header length
0059  * 14 bytes FCoE header + 24 byte FC header = 38 bytes
0060  */
0061 #define FCOE_HEADER_LEN 38
0062 
0063 /*
0064  * Minimum FCoE frame size
0065  * 14 bytes FCoE header + 24 byte FC header + 8 byte FCoE trailer = 46 bytes
0066  */
0067 #define FCOE_MIN_FRAME 46
0068 
0069 /*
0070  * FCoE Link Error Status Block: T11 FC-BB-5 Rev2.0, Clause 7.10.
0071  */
0072 struct fcoe_fc_els_lesb {
0073     __be32      lesb_link_fail; /* link failure count */
0074     __be32      lesb_vlink_fail; /* virtual link failure count */
0075     __be32      lesb_miss_fka;  /* missing FIP keep-alive count */
0076     __be32      lesb_symb_err;  /* symbol error during carrier count */
0077     __be32      lesb_err_block; /* errored block count */
0078     __be32      lesb_fcs_error; /* frame check sequence error count */
0079 };
0080 
0081 /*
0082  * fc_fcoe_set_mac - Store OUI + DID into MAC address field.
0083  * @mac: mac address to be set
0084  * @did: fc dest id to use
0085  */
0086 static inline void fc_fcoe_set_mac(u8 *mac, u8 *did)
0087 {
0088     mac[0] = (u8) (FC_FCOE_OUI >> 16);
0089     mac[1] = (u8) (FC_FCOE_OUI >> 8);
0090     mac[2] = (u8) FC_FCOE_OUI;
0091     mac[3] = did[0];
0092     mac[4] = did[1];
0093     mac[5] = did[2];
0094 }
0095 
0096 #endif /* _FC_FCOE_H_ */