fc_fcoe.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright(c) 2007 Intel Corporation. All rights reserved.
  4. *
  5. * Maintained at www.Open-FCoE.org
  6. */
  7. #ifndef _FC_FCOE_H_
  8. #define _FC_FCOE_H_
  9. /*
  10. * FCoE - Fibre Channel over Ethernet.
  11. * See T11 FC-BB-5 Rev 2.00 (09-056v5.pdf)
  12. */
  13. /*
  14. * Default FC_FCOE_OUI / FC-MAP value.
  15. */
  16. #define FC_FCOE_OUI 0x0efc00 /* upper 24 bits of FCOE MAC */
  17. /*
  18. * Fabric Login (FLOGI) MAC for non-FIP use. Non-FIP use is deprecated.
  19. */
  20. #define FC_FCOE_FLOGI_MAC { 0x0e, 0xfc, 0x00, 0xff, 0xff, 0xfe }
  21. #define FC_FCOE_VER 0 /* version */
  22. /*
  23. * Ethernet Addresses based on FC S_ID and D_ID.
  24. * Generated by FC_FCOE_OUI | S_ID/D_ID
  25. */
  26. #define FC_FCOE_ENCAPS_ID(n) (((u64) FC_FCOE_OUI << 24) | (n))
  27. #define FC_FCOE_DECAPS_ID(n) ((n) >> 24)
  28. /*
  29. * FCoE frame header - 14 bytes
  30. * This follows the VLAN header, which includes the ethertype.
  31. */
  32. struct fcoe_hdr {
  33. __u8 fcoe_ver; /* version field - upper 4 bits */
  34. __u8 fcoe_resvd[12]; /* reserved - send zero and ignore */
  35. __u8 fcoe_sof; /* start of frame per RFC 3643 */
  36. };
  37. #define FC_FCOE_DECAPS_VER(hp) ((hp)->fcoe_ver >> 4)
  38. #define FC_FCOE_ENCAPS_VER(hp, ver) ((hp)->fcoe_ver = (ver) << 4)
  39. /*
  40. * FCoE CRC & EOF - 8 bytes.
  41. */
  42. struct fcoe_crc_eof {
  43. __le32 fcoe_crc32; /* CRC for FC packet */
  44. __u8 fcoe_eof; /* EOF from RFC 3643 */
  45. __u8 fcoe_resvd[3]; /* reserved - send zero and ignore */
  46. } __attribute__((packed));
  47. /*
  48. * Minimum FCoE + FC header length
  49. * 14 bytes FCoE header + 24 byte FC header = 38 bytes
  50. */
  51. #define FCOE_HEADER_LEN 38
  52. /*
  53. * Minimum FCoE frame size
  54. * 14 bytes FCoE header + 24 byte FC header + 8 byte FCoE trailer = 46 bytes
  55. */
  56. #define FCOE_MIN_FRAME 46
  57. /*
  58. * FCoE Link Error Status Block: T11 FC-BB-5 Rev2.0, Clause 7.10.
  59. */
  60. struct fcoe_fc_els_lesb {
  61. __be32 lesb_link_fail; /* link failure count */
  62. __be32 lesb_vlink_fail; /* virtual link failure count */
  63. __be32 lesb_miss_fka; /* missing FIP keep-alive count */
  64. __be32 lesb_symb_err; /* symbol error during carrier count */
  65. __be32 lesb_err_block; /* errored block count */
  66. __be32 lesb_fcs_error; /* frame check sequence error count */
  67. };
  68. /*
  69. * fc_fcoe_set_mac - Store OUI + DID into MAC address field.
  70. * @mac: mac address to be set
  71. * @did: fc dest id to use
  72. */
  73. static inline void fc_fcoe_set_mac(u8 *mac, u8 *did)
  74. {
  75. mac[0] = (u8) (FC_FCOE_OUI >> 16);
  76. mac[1] = (u8) (FC_FCOE_OUI >> 8);
  77. mac[2] = (u8) FC_FCOE_OUI;
  78. mac[3] = did[0];
  79. mac[4] = did[1];
  80. mac[5] = did[2];
  81. }
  82. #endif /* _FC_FCOE_H_ */