fc_fcoe.h 3.2 KB

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