| Robert Love | f032c2f | 2008-12-09 15:10:11 -0800 | [diff] [blame] | 1 | /* | 
 | 2 |  * Copyright(c) 2007 Intel Corporation. All rights reserved. | 
 | 3 |  * | 
 | 4 |  * This program is free software; you can redistribute it and/or modify it | 
 | 5 |  * under the terms and conditions of the GNU General Public License, | 
 | 6 |  * version 2, as published by the Free Software Foundation. | 
 | 7 |  * | 
 | 8 |  * This program is distributed in the hope it will be useful, but WITHOUT | 
 | 9 |  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | 
 | 10 |  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for | 
 | 11 |  * more details. | 
 | 12 |  * | 
 | 13 |  * You should have received a copy of the GNU General Public License along with | 
 | 14 |  * this program; if not, write to the Free Software Foundation, Inc., | 
 | 15 |  * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. | 
 | 16 |  * | 
 | 17 |  * Maintained at www.Open-FCoE.org | 
 | 18 |  */ | 
 | 19 |  | 
 | 20 | #ifndef _FC_FCOE_H_ | 
 | 21 | #define	_FC_FCOE_H_ | 
 | 22 |  | 
 | 23 | /* | 
 | 24 |  * FCoE - Fibre Channel over Ethernet. | 
 | 25 |  */ | 
 | 26 |  | 
 | 27 | /* | 
| Robert Love | f032c2f | 2008-12-09 15:10:11 -0800 | [diff] [blame] | 28 |  * FC_FCOE_OUI hasn't been standardized yet.   XXX TBD. | 
 | 29 |  */ | 
 | 30 | #ifndef FC_FCOE_OUI | 
 | 31 | #define	FC_FCOE_OUI	0x0efc00	/* upper 24 bits of FCOE dest MAC TBD */ | 
 | 32 | #endif | 
 | 33 |  | 
 | 34 | /* | 
 | 35 |  * The destination MAC address for the fabric login may get a different OUI. | 
 | 36 |  * This isn't standardized yet. | 
 | 37 |  */ | 
 | 38 | #ifndef FC_FCOE_FLOGI_MAC | 
 | 39 | /* gateway MAC - TBD */ | 
 | 40 | #define	FC_FCOE_FLOGI_MAC { 0x0e, 0xfc, 0x00, 0xff, 0xff, 0xfe } | 
 | 41 | #endif | 
 | 42 |  | 
 | 43 | #define	FC_FCOE_VER	0			/* version */ | 
 | 44 |  | 
 | 45 | /* | 
 | 46 |  * Ethernet Addresses based on FC S_ID and D_ID. | 
 | 47 |  * Generated by FC_FCOE_OUI | S_ID/D_ID | 
 | 48 |  */ | 
 | 49 | #define	FC_FCOE_ENCAPS_ID(n)	(((u64) FC_FCOE_OUI << 24) | (n)) | 
 | 50 | #define	FC_FCOE_DECAPS_ID(n)	((n) >> 24) | 
 | 51 |  | 
 | 52 | /* | 
 | 53 |  * FCoE frame header - 14 bytes | 
 | 54 |  * | 
 | 55 |  * This is the August 2007 version of the FCoE header as defined by T11. | 
 | 56 |  * This follows the VLAN header, which includes the ethertype. | 
 | 57 |  */ | 
 | 58 | struct fcoe_hdr { | 
 | 59 | 	__u8		fcoe_ver;	/* version field - upper 4 bits */ | 
 | 60 | 	__u8		fcoe_resvd[12];	/* reserved - send zero and ignore */ | 
 | 61 | 	__u8		fcoe_sof;	/* start of frame per RFC 3643 */ | 
 | 62 | }; | 
 | 63 |  | 
 | 64 | #define FC_FCOE_DECAPS_VER(hp)	    ((hp)->fcoe_ver >> 4) | 
 | 65 | #define FC_FCOE_ENCAPS_VER(hp, ver) ((hp)->fcoe_ver = (ver) << 4) | 
 | 66 |  | 
 | 67 | /* | 
 | 68 |  * FCoE CRC & EOF - 8 bytes. | 
 | 69 |  */ | 
 | 70 | struct fcoe_crc_eof { | 
 | 71 | 	__le32		fcoe_crc32;	/* CRC for FC packet */ | 
 | 72 | 	__u8		fcoe_eof;	/* EOF from RFC 3643 */ | 
 | 73 | 	__u8		fcoe_resvd[3];	/* reserved - send zero and ignore */ | 
 | 74 | } __attribute__((packed)); | 
 | 75 |  | 
 | 76 | /* | 
 | 77 |  * Minimum FCoE + FC header length | 
 | 78 |  * 14 bytes FCoE header + 24 byte FC header = 38 bytes | 
 | 79 |  */ | 
 | 80 | #define FCOE_HEADER_LEN 38 | 
 | 81 |  | 
 | 82 | /* | 
 | 83 |  * Minimum FCoE frame size | 
 | 84 |  * 14 bytes FCoE header + 24 byte FC header + 8 byte FCoE trailer = 46 bytes | 
 | 85 |  */ | 
 | 86 | #define FCOE_MIN_FRAME 46 | 
 | 87 |  | 
 | 88 | /* | 
 | 89 |  * fc_fcoe_set_mac - Store OUI + DID into MAC address field. | 
 | 90 |  * @mac: mac address to be set | 
 | 91 |  * @did: fc dest id to use | 
 | 92 |  */ | 
 | 93 | static inline void fc_fcoe_set_mac(u8 *mac, u8 *did) | 
 | 94 | { | 
 | 95 | 	mac[0] = (u8) (FC_FCOE_OUI >> 16); | 
 | 96 | 	mac[1] = (u8) (FC_FCOE_OUI >> 8); | 
 | 97 | 	mac[2] = (u8) FC_FCOE_OUI; | 
 | 98 | 	mac[3] = did[0]; | 
 | 99 | 	mac[4] = did[1]; | 
 | 100 | 	mac[5] = did[2]; | 
 | 101 | } | 
 | 102 |  | 
 | 103 | #endif /* _FC_FCOE_H_ */ |