fc_fip.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. /*
  2. * Copyright 2008 Cisco Systems, Inc. All rights reserved.
  3. *
  4. * This program is free software; you may redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; version 2 of the License.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  9. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  10. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  11. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  12. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  13. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  14. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  15. * SOFTWARE.
  16. */
  17. #ifndef _FC_FIP_H_
  18. #define _FC_FIP_H_
  19. /*
  20. * This version is based on:
  21. * http://www.t11.org/ftp/t11/pub/fc/bb-5/08-543v1.pdf
  22. */
  23. /*
  24. * The FIP ethertype eventually goes in net/if_ether.h.
  25. */
  26. #ifndef ETH_P_FIP
  27. #define ETH_P_FIP 0x8914 /* FIP Ethertype */
  28. #endif
  29. #define FIP_DEF_PRI 128 /* default selection priority */
  30. #define FIP_DEF_FC_MAP 0x0efc00 /* default FCoE MAP (MAC OUI) value */
  31. #define FIP_DEF_FKA 8000 /* default FCF keep-alive/advert period (mS) */
  32. #define FIP_VN_KA_PERIOD 90000 /* required VN_port keep-alive period (mS) */
  33. #define FIP_FCF_FUZZ 100 /* random time added by FCF (mS) */
  34. /*
  35. * Multicast MAC addresses. T11-adopted.
  36. */
  37. #define FIP_ALL_FCOE_MACS ((u8[6]) { 1, 0x10, 0x18, 1, 0, 0 })
  38. #define FIP_ALL_ENODE_MACS ((u8[6]) { 1, 0x10, 0x18, 1, 0, 1 })
  39. #define FIP_ALL_FCF_MACS ((u8[6]) { 1, 0x10, 0x18, 1, 0, 2 })
  40. #define FIP_VER 1 /* version for fip_header */
  41. struct fip_header {
  42. __u8 fip_ver; /* upper 4 bits are the version */
  43. __u8 fip_resv1; /* reserved */
  44. __be16 fip_op; /* operation code */
  45. __u8 fip_resv2; /* reserved */
  46. __u8 fip_subcode; /* lower 4 bits are sub-code */
  47. __be16 fip_dl_len; /* length of descriptors in words */
  48. __be16 fip_flags; /* header flags */
  49. } __attribute__((packed));
  50. #define FIP_VER_SHIFT 4
  51. #define FIP_VER_ENCAPS(v) ((v) << FIP_VER_SHIFT)
  52. #define FIP_VER_DECAPS(v) ((v) >> FIP_VER_SHIFT)
  53. #define FIP_BPW 4 /* bytes per word for lengths */
  54. /*
  55. * fip_op.
  56. */
  57. enum fip_opcode {
  58. FIP_OP_DISC = 1, /* discovery, advertisement, etc. */
  59. FIP_OP_LS = 2, /* Link Service request or reply */
  60. FIP_OP_CTRL = 3, /* Keep Alive / Link Reset */
  61. FIP_OP_VLAN = 4, /* VLAN discovery */
  62. FIP_OP_VENDOR_MIN = 0xfff8, /* min vendor-specific opcode */
  63. FIP_OP_VENDOR_MAX = 0xfffe, /* max vendor-specific opcode */
  64. };
  65. /*
  66. * Subcodes for FIP_OP_DISC.
  67. */
  68. enum fip_disc_subcode {
  69. FIP_SC_SOL = 1, /* solicitation */
  70. FIP_SC_ADV = 2, /* advertisement */
  71. };
  72. /*
  73. * Subcodes for FIP_OP_LS.
  74. */
  75. enum fip_trans_subcode {
  76. FIP_SC_REQ = 1, /* request */
  77. FIP_SC_REP = 2, /* reply */
  78. };
  79. /*
  80. * Subcodes for FIP_OP_RESET.
  81. */
  82. enum fip_reset_subcode {
  83. FIP_SC_KEEP_ALIVE = 1, /* keep-alive from VN_Port */
  84. FIP_SC_CLR_VLINK = 2, /* clear virtual link from VF_Port */
  85. };
  86. /*
  87. * Subcodes for FIP_OP_VLAN.
  88. */
  89. enum fip_vlan_subcode {
  90. FIP_SC_VL_REQ = 1, /* request */
  91. FIP_SC_VL_REP = 2, /* reply */
  92. };
  93. /*
  94. * flags in header fip_flags.
  95. */
  96. enum fip_flag {
  97. FIP_FL_FPMA = 0x8000, /* supports FPMA fabric-provided MACs */
  98. FIP_FL_SPMA = 0x4000, /* supports SPMA server-provided MACs */
  99. FIP_FL_AVAIL = 0x0004, /* available for FLOGI/ELP */
  100. FIP_FL_SOL = 0x0002, /* this is a solicited message */
  101. FIP_FL_FPORT = 0x0001, /* sent from an F port */
  102. };
  103. /*
  104. * Common descriptor header format.
  105. */
  106. struct fip_desc {
  107. __u8 fip_dtype; /* type - see below */
  108. __u8 fip_dlen; /* length - in 32-bit words */
  109. };
  110. enum fip_desc_type {
  111. FIP_DT_PRI = 1, /* priority for forwarder selection */
  112. FIP_DT_MAC = 2, /* MAC address */
  113. FIP_DT_MAP_OUI = 3, /* FC-MAP OUI */
  114. FIP_DT_NAME = 4, /* switch name or node name */
  115. FIP_DT_FAB = 5, /* fabric descriptor */
  116. FIP_DT_FCOE_SIZE = 6, /* max FCoE frame size */
  117. FIP_DT_FLOGI = 7, /* FLOGI request or response */
  118. FIP_DT_FDISC = 8, /* FDISC request or response */
  119. FIP_DT_LOGO = 9, /* LOGO request or response */
  120. FIP_DT_ELP = 10, /* ELP request or response */
  121. FIP_DT_VN_ID = 11, /* VN_Node Identifier */
  122. FIP_DT_FKA = 12, /* advertisement keep-alive period */
  123. FIP_DT_VENDOR = 13, /* vendor ID */
  124. FIP_DT_VLAN = 14, /* vlan number */
  125. FIP_DT_LIMIT, /* max defined desc_type + 1 */
  126. FIP_DT_VENDOR_BASE = 128, /* first vendor-specific desc_type */
  127. };
  128. /*
  129. * FIP_DT_PRI - priority descriptor.
  130. */
  131. struct fip_pri_desc {
  132. struct fip_desc fd_desc;
  133. __u8 fd_resvd;
  134. __u8 fd_pri; /* FCF priority: higher is better */
  135. } __attribute__((packed));
  136. /*
  137. * FIP_DT_MAC - MAC address descriptor.
  138. */
  139. struct fip_mac_desc {
  140. struct fip_desc fd_desc;
  141. __u8 fd_mac[ETH_ALEN];
  142. } __attribute__((packed));
  143. /*
  144. * FIP_DT_MAP - descriptor.
  145. */
  146. struct fip_map_desc {
  147. struct fip_desc fd_desc;
  148. __u8 fd_resvd[3];
  149. __u8 fd_map[3];
  150. } __attribute__((packed));
  151. /*
  152. * FIP_DT_NAME descriptor.
  153. */
  154. struct fip_wwn_desc {
  155. struct fip_desc fd_desc;
  156. __u8 fd_resvd[2];
  157. __be64 fd_wwn; /* 64-bit WWN, unaligned */
  158. } __attribute__((packed));
  159. /*
  160. * FIP_DT_FAB descriptor.
  161. */
  162. struct fip_fab_desc {
  163. struct fip_desc fd_desc;
  164. __be16 fd_vfid; /* virtual fabric ID */
  165. __u8 fd_resvd;
  166. __u8 fd_map[3]; /* FC-MAP value */
  167. __be64 fd_wwn; /* fabric name, unaligned */
  168. } __attribute__((packed));
  169. /*
  170. * FIP_DT_FCOE_SIZE descriptor.
  171. */
  172. struct fip_size_desc {
  173. struct fip_desc fd_desc;
  174. __be16 fd_size;
  175. } __attribute__((packed));
  176. /*
  177. * Descriptor that encapsulates an ELS or ILS frame.
  178. * The encapsulated frame immediately follows this header, without
  179. * SOF, EOF, or CRC.
  180. */
  181. struct fip_encaps {
  182. struct fip_desc fd_desc;
  183. __u8 fd_resvd[2];
  184. } __attribute__((packed));
  185. /*
  186. * FIP_DT_VN_ID - VN_Node Identifier descriptor.
  187. */
  188. struct fip_vn_desc {
  189. struct fip_desc fd_desc;
  190. __u8 fd_mac[ETH_ALEN];
  191. __u8 fd_resvd;
  192. __u8 fd_fc_id[3];
  193. __be64 fd_wwpn; /* port name, unaligned */
  194. } __attribute__((packed));
  195. /*
  196. * FIP_DT_FKA - Advertisement keep-alive period.
  197. */
  198. struct fip_fka_desc {
  199. struct fip_desc fd_desc;
  200. __u8 fd_resvd[2];
  201. __be32 fd_fka_period; /* adv./keep-alive period in mS */
  202. } __attribute__((packed));
  203. /*
  204. * FIP_DT_VENDOR descriptor.
  205. */
  206. struct fip_vendor_desc {
  207. struct fip_desc fd_desc;
  208. __u8 fd_resvd[2];
  209. __u8 fd_vendor_id[8];
  210. } __attribute__((packed));
  211. #endif /* _FC_FIP_H_ */