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.1KB

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