You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ib_packet.h 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. #ifndef _IPXE_IB_PACKET_H
  2. #define _IPXE_IB_PACKET_H
  3. /** @file
  4. *
  5. * Infiniband packet format
  6. *
  7. */
  8. FILE_LICENCE ( GPL2_OR_LATER );
  9. struct ib_device;
  10. struct ib_queue_pair;
  11. struct ib_address_vector;
  12. struct io_buffer;
  13. /** An Infiniband Globally Unique Identifier */
  14. union ib_guid {
  15. uint8_t bytes[8];
  16. uint16_t words[4];
  17. uint32_t dwords[2];
  18. };
  19. /** Infiniband Globally Unique Identifier debug message format */
  20. #define IB_GUID_FMT "%08x:%08x"
  21. /** Infiniband Globally Unique Identifier debug message arguments */
  22. #define IB_GUID_ARGS( guid ) \
  23. ntohl ( (guid)->dwords[0] ), ntohl ( (guid)->dwords[1] )
  24. /** An Infiniband Global Identifier */
  25. union ib_gid {
  26. uint8_t bytes[16];
  27. uint16_t words[8];
  28. uint32_t dwords[4];
  29. struct {
  30. union ib_guid prefix;
  31. union ib_guid guid;
  32. } s;
  33. };
  34. /** Infiniband Global Identifier debug message format */
  35. #define IB_GID_FMT IB_GUID_FMT ":" IB_GUID_FMT
  36. /** Infiniband Global Identifier debug message arguments */
  37. #define IB_GID_ARGS( gid ) \
  38. IB_GUID_ARGS ( &(gid)->s.prefix ), IB_GUID_ARGS ( &(gid)->s.guid )
  39. /** An Infiniband Local Route Header */
  40. struct ib_local_route_header {
  41. /** Virtual lane and link version */
  42. uint8_t vl__lver;
  43. /** Service level and next link header */
  44. uint8_t sl__lnh;
  45. /** Destination LID */
  46. uint16_t dlid;
  47. /** Packet length */
  48. uint16_t length;
  49. /** Source LID */
  50. uint16_t slid;
  51. } __attribute__ (( packed ));
  52. /** Infiniband virtual lanes */
  53. enum ib_vl {
  54. IB_VL_DEFAULT = 0,
  55. IB_VL_SMP = 15,
  56. };
  57. /** An Infiniband Link Next Header value */
  58. enum ib_lnh {
  59. IB_LNH_RAW = 0,
  60. IB_LNH_IPv6 = 1,
  61. IB_LNH_BTH = 2,
  62. IB_LNH_GRH = 3
  63. };
  64. /** Default Infiniband LID */
  65. #define IB_LID_NONE 0xffff
  66. /** Test for multicast LID */
  67. #define IB_LID_MULTICAST( lid ) ( ( (lid) >= 0xc000 ) && ( (lid) <= 0xfffe ) )
  68. /** An Infiniband Global Route Header */
  69. struct ib_global_route_header {
  70. /** IP version, traffic class, and flow label
  71. *
  72. * 4 bits : Version of the GRH
  73. * 8 bits : Traffic class
  74. * 20 bits : Flow label
  75. */
  76. uint32_t ipver__tclass__flowlabel;
  77. /** Payload length */
  78. uint16_t paylen;
  79. /** Next header */
  80. uint8_t nxthdr;
  81. /** Hop limit */
  82. uint8_t hoplmt;
  83. /** Source GID */
  84. union ib_gid sgid;
  85. /** Destiniation GID */
  86. union ib_gid dgid;
  87. } __attribute__ (( packed ));
  88. #define IB_GRH_IPVER_IPv6 0x06
  89. #define IB_GRH_NXTHDR_IBA 0x1b
  90. /** An Infiniband Base Transport Header */
  91. struct ib_base_transport_header {
  92. /** Opcode */
  93. uint8_t opcode;
  94. /** Transport header version, pad count, migration and solicitation */
  95. uint8_t se__m__padcnt__tver;
  96. /** Partition key */
  97. uint16_t pkey;
  98. /** Destination queue pair */
  99. uint32_t dest_qp;
  100. /** Packet sequence number and acknowledge request */
  101. uint32_t ack__psn;
  102. } __attribute__ (( packed ));
  103. /** An Infiniband BTH opcode */
  104. enum ib_bth_opcode {
  105. BTH_OPCODE_UD_SEND = 0x64,
  106. };
  107. /** An Infiniband Datagram Extended Transport Header */
  108. struct ib_datagram_extended_transport_header {
  109. /** Queue key */
  110. uint32_t qkey;
  111. /** Source queue pair */
  112. uint32_t src_qp;
  113. } __attribute__ (( packed ));
  114. /** All known IB header formats */
  115. union ib_headers {
  116. struct ib_local_route_header lrh;
  117. struct {
  118. struct ib_local_route_header lrh;
  119. struct ib_global_route_header grh;
  120. struct ib_base_transport_header bth;
  121. struct ib_datagram_extended_transport_header deth;
  122. } __attribute__ (( packed )) lrh__grh__bth__deth;
  123. struct {
  124. struct ib_local_route_header lrh;
  125. struct ib_base_transport_header bth;
  126. struct ib_datagram_extended_transport_header deth;
  127. } __attribute__ (( packed )) lrh__bth__deth;
  128. } __attribute__ (( packed ));
  129. /** Maximum size required for IB headers */
  130. #define IB_MAX_HEADER_SIZE sizeof ( union ib_headers )
  131. extern int ib_push ( struct ib_device *ibdev, struct io_buffer *iobuf,
  132. struct ib_queue_pair *qp, size_t payload_len,
  133. const struct ib_address_vector *dest );
  134. extern int ib_pull ( struct ib_device *ibdev, struct io_buffer *iobuf,
  135. struct ib_queue_pair **qp, size_t *payload_len,
  136. struct ib_address_vector *dest,
  137. struct ib_address_vector *source );
  138. #endif /* _IPXE_IB_PACKET_H */