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 3.4KB

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