/*1* Copyright(c) 2007 Intel Corporation. All rights reserved.2*3* This program is free software; you can redistribute it and/or modify it4* under the terms and conditions of the GNU General Public License,5* version 2, as published by the Free Software Foundation.6*7* This program is distributed in the hope it will be useful, but WITHOUT8* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or9* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for10* more details.11*12* You should have received a copy of the GNU General Public License along with13* this program; if not, write to the Free Software Foundation, Inc.,14* 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.15*16* Maintained at www.Open-FCoE.org17*/1819#ifndef _FC_FCOE_H_20#define _FC_FCOE_H_2122/*23* FCoE - Fibre Channel over Ethernet.24* See T11 FC-BB-5 Rev 2.00 (09-056v5.pdf)25*/2627/*28* Default FC_FCOE_OUI / FC-MAP value.29*/30#define FC_FCOE_OUI 0x0efc00 /* upper 24 bits of FCOE MAC */3132/*33* Fabric Login (FLOGI) MAC for non-FIP use. Non-FIP use is deprecated.34*/35#define FC_FCOE_FLOGI_MAC { 0x0e, 0xfc, 0x00, 0xff, 0xff, 0xfe }3637#define FC_FCOE_VER 0 /* version */3839/*40* Ethernet Addresses based on FC S_ID and D_ID.41* Generated by FC_FCOE_OUI | S_ID/D_ID42*/43#define FC_FCOE_ENCAPS_ID(n) (((u64) FC_FCOE_OUI << 24) | (n))44#define FC_FCOE_DECAPS_ID(n) ((n) >> 24)4546/*47* FCoE frame header - 14 bytes48* This follows the VLAN header, which includes the ethertype.49*/50struct fcoe_hdr {51__u8 fcoe_ver; /* version field - upper 4 bits */52__u8 fcoe_resvd[12]; /* reserved - send zero and ignore */53__u8 fcoe_sof; /* start of frame per RFC 3643 */54};5556#define FC_FCOE_DECAPS_VER(hp) ((hp)->fcoe_ver >> 4)57#define FC_FCOE_ENCAPS_VER(hp, ver) ((hp)->fcoe_ver = (ver) << 4)5859/*60* FCoE CRC & EOF - 8 bytes.61*/62struct fcoe_crc_eof {63__le32 fcoe_crc32; /* CRC for FC packet */64__u8 fcoe_eof; /* EOF from RFC 3643 */65__u8 fcoe_resvd[3]; /* reserved - send zero and ignore */66} __attribute__((packed));6768/*69* Minimum FCoE + FC header length70* 14 bytes FCoE header + 24 byte FC header = 38 bytes71*/72#define FCOE_HEADER_LEN 387374/*75* Minimum FCoE frame size76* 14 bytes FCoE header + 24 byte FC header + 8 byte FCoE trailer = 46 bytes77*/78#define FCOE_MIN_FRAME 467980/*81* FCoE Link Error Status Block: T11 FC-BB-5 Rev2.0, Clause 7.10.82*/83struct fcoe_fc_els_lesb {84__be32 lesb_link_fail; /* link failure count */85__be32 lesb_vlink_fail; /* virtual link failure count */86__be32 lesb_miss_fka; /* missing FIP keep-alive count */87__be32 lesb_symb_err; /* symbol error during carrier count */88__be32 lesb_err_block; /* errored block count */89__be32 lesb_fcs_error; /* frame check sequence error count */90};9192/*93* fc_fcoe_set_mac - Store OUI + DID into MAC address field.94* @mac: mac address to be set95* @did: fc dest id to use96*/97static inline void fc_fcoe_set_mac(u8 *mac, u8 *did)98{99mac[0] = (u8) (FC_FCOE_OUI >> 16);100mac[1] = (u8) (FC_FCOE_OUI >> 8);101mac[2] = (u8) FC_FCOE_OUI;102mac[3] = did[0];103mac[4] = did[1];104mac[5] = did[2];105}106107#endif /* _FC_FCOE_H_ */108109110