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.

infiniband.h 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. #ifndef _GPXE_INFINIBAND_H
  2. #define _GPXE_INFINIBAND_H
  3. /** @file
  4. *
  5. * Infiniband protocol
  6. *
  7. */
  8. #include <stdint.h>
  9. #include <gpxe/netdevice.h>
  10. /** An Infiniband Global Identifier */
  11. struct ib_gid {
  12. uint8_t bytes[16];
  13. };
  14. /** An Infiniband Global Route Header */
  15. struct ib_global_route_header {
  16. /** IP version, traffic class, and flow label
  17. *
  18. * 4 bits : Version of the GRH
  19. * 8 bits : Traffic class
  20. * 20 bits : Flow label
  21. */
  22. uint32_t ipver_tclass_flowlabel;
  23. /** Payload length */
  24. uint16_t paylen;
  25. /** Next header */
  26. uint8_t nxthdr;
  27. /** Hop limit */
  28. uint8_t hoplmt;
  29. /** Source GID */
  30. struct ib_gid sgid;
  31. /** Destiniation GID */
  32. struct ib_gid dgid;
  33. } __attribute__ (( packed ));
  34. /** Infiniband MAC address length */
  35. #define IB_ALEN 20
  36. /** An Infiniband MAC address */
  37. struct ib_mac {
  38. /** Queue pair number
  39. *
  40. * MSB must be zero; QPNs are only 24-bit.
  41. */
  42. uint32_t qpn;
  43. /** Port GID */
  44. struct ib_gid gid;
  45. } __attribute__ (( packed ));
  46. /** Infiniband link-layer header length */
  47. #define IB_HLEN 4
  48. /** An Infiniband link-layer header */
  49. struct ibhdr {
  50. /** Network-layer protocol */
  51. uint16_t proto;
  52. /** Reserved, must be zero */
  53. uint16_t reserved;
  54. } __attribute__ (( packed ));
  55. /** An Infiniband Work Queue */
  56. struct ib_work_queue {
  57. /** Number of work queue entries */
  58. unsigned int num_wqes;
  59. /** Posted index
  60. *
  61. * This is the index of the most recently posted entry.
  62. */
  63. unsigned int posted;
  64. /** I/O buffers assigned to work queue */
  65. struct io_buffer **iobufs;
  66. /** Driver private data */
  67. void *priv;
  68. };
  69. /** An Infiniband Queue Pair */
  70. struct ib_queue_pair {
  71. /** Queue Pair Number */
  72. uint32_t qpn;
  73. /** Send queue */
  74. struct ib_work_queue send;
  75. /** Receive queue */
  76. struct ib_work_queue recv;
  77. /** Driver private data */
  78. void *priv;
  79. };
  80. /** An Infiniband Address Vector */
  81. struct ib_address_vector {
  82. /** Destination Queue Pair */
  83. unsigned int dest_qp;
  84. /** Queue key */
  85. unsigned int qkey;
  86. /** Destination Local ID */
  87. unsigned int dlid;
  88. /** Rate */
  89. unsigned int rate;
  90. /** Service level */
  91. unsigned int sl;
  92. /** GID is present */
  93. unsigned int gid_present;
  94. /** GID */
  95. struct ib_gid gid;
  96. };
  97. struct ib_device;
  98. /**
  99. * Infiniband device operations
  100. *
  101. * These represent a subset of the Infiniband Verbs.
  102. */
  103. struct ib_device_operations {
  104. /** Post Send work queue entry
  105. *
  106. * @v ibdev Infiniband device
  107. * @v iobuf I/O buffer
  108. * @v av Address vector
  109. * @v qp Queue pair
  110. * @ret rc Return status code
  111. *
  112. * If this method returns success, the I/O buffer remains
  113. * owned by the queue pair. If this method returns failure,
  114. * the I/O buffer is immediately released; the failure is
  115. * interpreted as "failure to enqueue buffer".
  116. */
  117. int ( * post_send ) ( struct ib_device *ibdev,
  118. struct io_buffer *iobuf,
  119. struct ib_address_vector *av,
  120. struct ib_queue_pair *qp );
  121. };
  122. /** An Infiniband device */
  123. struct ib_device {
  124. /** Driver private data */
  125. void *priv;
  126. };
  127. extern struct ll_protocol infiniband_protocol;
  128. extern const char * ib_ntoa ( const void *ll_addr );
  129. /**
  130. * Allocate Infiniband device
  131. *
  132. * @v priv_size Size of driver private data
  133. * @ret netdev Network device, or NULL
  134. */
  135. static inline struct net_device * alloc_ibdev ( size_t priv_size ) {
  136. struct net_device *netdev;
  137. netdev = alloc_netdev ( priv_size );
  138. if ( netdev ) {
  139. netdev->ll_protocol = &infiniband_protocol;
  140. }
  141. return netdev;
  142. }
  143. #endif /* _GPXE_INFINIBAND_H */