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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803
  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/refcnt.h>
  10. #include <gpxe/device.h>
  11. /** Subnet administrator QPN */
  12. #define IB_SA_QPN 1
  13. /** Broadcast QPN */
  14. #define IB_BROADCAST_QPN 0xffffffUL
  15. /** Subnet administrator queue key */
  16. #define IB_GLOBAL_QKEY 0x80010000UL
  17. /** An Infiniband Global Identifier */
  18. struct ib_gid {
  19. union {
  20. uint8_t bytes[16];
  21. uint16_t words[8];
  22. uint32_t dwords[4];
  23. } u;
  24. };
  25. /** An Infiniband Global Route Header */
  26. struct ib_global_route_header {
  27. /** IP version, traffic class, and flow label
  28. *
  29. * 4 bits : Version of the GRH
  30. * 8 bits : Traffic class
  31. * 20 bits : Flow label
  32. */
  33. uint32_t ipver_tclass_flowlabel;
  34. /** Payload length */
  35. uint16_t paylen;
  36. /** Next header */
  37. uint8_t nxthdr;
  38. /** Hop limit */
  39. uint8_t hoplmt;
  40. /** Source GID */
  41. struct ib_gid sgid;
  42. /** Destiniation GID */
  43. struct ib_gid dgid;
  44. } __attribute__ (( packed ));
  45. struct ib_device;
  46. struct ib_queue_pair;
  47. struct ib_completion_queue;
  48. /** An Infiniband Work Queue */
  49. struct ib_work_queue {
  50. /** Containing queue pair */
  51. struct ib_queue_pair *qp;
  52. /** "Is a send queue" flag */
  53. int is_send;
  54. /** Associated completion queue */
  55. struct ib_completion_queue *cq;
  56. /** List of work queues on this completion queue */
  57. struct list_head list;
  58. /** Number of work queue entries */
  59. unsigned int num_wqes;
  60. /** Next work queue entry index
  61. *
  62. * This is the index of the next entry to be filled (i.e. the
  63. * first empty entry). This value is not bounded by num_wqes;
  64. * users must logical-AND with (num_wqes-1) to generate an
  65. * array index.
  66. */
  67. unsigned long next_idx;
  68. /** I/O buffers assigned to work queue */
  69. struct io_buffer **iobufs;
  70. /** Driver private data */
  71. void *drv_priv;
  72. };
  73. /** An Infiniband Queue Pair */
  74. struct ib_queue_pair {
  75. /** Queue Pair Number */
  76. unsigned long qpn;
  77. /** Queue key */
  78. unsigned long qkey;
  79. /** Send queue */
  80. struct ib_work_queue send;
  81. /** Receive queue */
  82. struct ib_work_queue recv;
  83. /** Driver private data */
  84. void *drv_priv;
  85. /** Queue owner private data */
  86. void *owner_priv;
  87. };
  88. /** Infiniband queue pair modification flags */
  89. enum ib_queue_pair_mods {
  90. IB_MODIFY_QKEY = 0x0001,
  91. };
  92. /** An Infiniband Completion Queue */
  93. struct ib_completion_queue {
  94. /** Completion queue number */
  95. unsigned long cqn;
  96. /** Number of completion queue entries */
  97. unsigned int num_cqes;
  98. /** Next completion queue entry index
  99. *
  100. * This is the index of the next entry to be filled (i.e. the
  101. * first empty entry). This value is not bounded by num_wqes;
  102. * users must logical-AND with (num_wqes-1) to generate an
  103. * array index.
  104. */
  105. unsigned long next_idx;
  106. /** List of work queues completing to this queue */
  107. struct list_head work_queues;
  108. /** Driver private data */
  109. void *drv_priv;
  110. };
  111. /** An Infiniband completion */
  112. struct ib_completion {
  113. /** Syndrome
  114. *
  115. * If non-zero, then the completion is in error.
  116. */
  117. unsigned int syndrome;
  118. /** Length */
  119. size_t len;
  120. };
  121. /** An Infiniband completion handler
  122. *
  123. * @v ibdev Infiniband device
  124. * @v qp Queue pair
  125. * @v completion Completion
  126. * @v iobuf I/O buffer
  127. */
  128. typedef void ( * ib_completer_t ) ( struct ib_device *ibdev,
  129. struct ib_queue_pair *qp,
  130. struct ib_completion *completion,
  131. struct io_buffer *iobuf );
  132. /** An Infiniband Address Vector */
  133. struct ib_address_vector {
  134. /** Destination Queue Pair */
  135. unsigned int dest_qp;
  136. /** Queue key */
  137. unsigned long qkey;
  138. /** Destination Local ID */
  139. unsigned int dlid;
  140. /** Rate */
  141. unsigned int rate;
  142. /** Service level */
  143. unsigned int sl;
  144. /** GID is present */
  145. unsigned int gid_present;
  146. /** GID */
  147. struct ib_gid gid;
  148. };
  149. struct ib_mad_hdr;
  150. /**
  151. * Infiniband device operations
  152. *
  153. * These represent a subset of the Infiniband Verbs.
  154. */
  155. struct ib_device_operations {
  156. /** Create completion queue
  157. *
  158. * @v ibdev Infiniband device
  159. * @v cq Completion queue
  160. * @ret rc Return status code
  161. */
  162. int ( * create_cq ) ( struct ib_device *ibdev,
  163. struct ib_completion_queue *cq );
  164. /** Destroy completion queue
  165. *
  166. * @v ibdev Infiniband device
  167. * @v cq Completion queue
  168. */
  169. void ( * destroy_cq ) ( struct ib_device *ibdev,
  170. struct ib_completion_queue *cq );
  171. /** Create queue pair
  172. *
  173. * @v ibdev Infiniband device
  174. * @v qp Queue pair
  175. * @ret rc Return status code
  176. */
  177. int ( * create_qp ) ( struct ib_device *ibdev,
  178. struct ib_queue_pair *qp );
  179. /** Modify queue pair
  180. *
  181. * @v ibdev Infiniband device
  182. * @v qp Queue pair
  183. * @v mod_list Modification list
  184. * @ret rc Return status code
  185. */
  186. int ( * modify_qp ) ( struct ib_device *ibdev,
  187. struct ib_queue_pair *qp,
  188. unsigned long mod_list );
  189. /** Destroy queue pair
  190. *
  191. * @v ibdev Infiniband device
  192. * @v qp Queue pair
  193. */
  194. void ( * destroy_qp ) ( struct ib_device *ibdev,
  195. struct ib_queue_pair *qp );
  196. /** Post send work queue entry
  197. *
  198. * @v ibdev Infiniband device
  199. * @v qp Queue pair
  200. * @v av Address vector
  201. * @v iobuf I/O buffer
  202. * @ret rc Return status code
  203. *
  204. * If this method returns success, the I/O buffer remains
  205. * owned by the queue pair. If this method returns failure,
  206. * the I/O buffer is immediately released; the failure is
  207. * interpreted as "failure to enqueue buffer".
  208. */
  209. int ( * post_send ) ( struct ib_device *ibdev,
  210. struct ib_queue_pair *qp,
  211. struct ib_address_vector *av,
  212. struct io_buffer *iobuf );
  213. /** Post receive work queue entry
  214. *
  215. * @v ibdev Infiniband device
  216. * @v qp Queue pair
  217. * @v iobuf I/O buffer
  218. * @ret rc Return status code
  219. *
  220. * If this method returns success, the I/O buffer remains
  221. * owned by the queue pair. If this method returns failure,
  222. * the I/O buffer is immediately released; the failure is
  223. * interpreted as "failure to enqueue buffer".
  224. */
  225. int ( * post_recv ) ( struct ib_device *ibdev,
  226. struct ib_queue_pair *qp,
  227. struct io_buffer *iobuf );
  228. /** Poll completion queue
  229. *
  230. * @v ibdev Infiniband device
  231. * @v cq Completion queue
  232. * @v complete_send Send completion handler
  233. * @v complete_recv Receive completion handler
  234. *
  235. * The completion handler takes ownership of the I/O buffer.
  236. */
  237. void ( * poll_cq ) ( struct ib_device *ibdev,
  238. struct ib_completion_queue *cq,
  239. ib_completer_t complete_send,
  240. ib_completer_t complete_recv );
  241. /**
  242. * Poll event queue
  243. *
  244. * @v ibdev Infiniband device
  245. */
  246. void ( * poll_eq ) ( struct ib_device *ibdev );
  247. /**
  248. * Open port
  249. *
  250. * @v ibdev Infiniband device
  251. * @ret rc Return status code
  252. */
  253. int ( * open ) ( struct ib_device *ibdev );
  254. /**
  255. * Close port
  256. *
  257. * @v ibdev Infiniband device
  258. */
  259. void ( * close ) ( struct ib_device *ibdev );
  260. /** Attach to multicast group
  261. *
  262. * @v ibdev Infiniband device
  263. * @v qp Queue pair
  264. * @v gid Multicast GID
  265. * @ret rc Return status code
  266. */
  267. int ( * mcast_attach ) ( struct ib_device *ibdev,
  268. struct ib_queue_pair *qp,
  269. struct ib_gid *gid );
  270. /** Detach from multicast group
  271. *
  272. * @v ibdev Infiniband device
  273. * @v qp Queue pair
  274. * @v gid Multicast GID
  275. */
  276. void ( * mcast_detach ) ( struct ib_device *ibdev,
  277. struct ib_queue_pair *qp,
  278. struct ib_gid *gid );
  279. /**
  280. * Issue management datagram
  281. *
  282. * @v ibdev Infiniband device
  283. * @v mad Management datagram
  284. * @v len Length of management datagram
  285. * @ret rc Return status code
  286. */
  287. int ( * mad ) ( struct ib_device *ibdev, struct ib_mad_hdr *mad,
  288. size_t len );
  289. };
  290. /** An Infiniband device */
  291. struct ib_device {
  292. /** Reference counter */
  293. struct refcnt refcnt;
  294. /** List of Infiniband devices */
  295. struct list_head list;
  296. /** Underlying device */
  297. struct device *dev;
  298. /** Infiniband operations */
  299. struct ib_device_operations *op;
  300. /** Port number */
  301. unsigned int port;
  302. /** Link state */
  303. int link_up;
  304. /** Port GID */
  305. struct ib_gid port_gid;
  306. /** Subnet manager LID */
  307. unsigned long sm_lid;
  308. /** Partition key */
  309. unsigned int pkey;
  310. /** Driver private data */
  311. void *drv_priv;
  312. /** Owner private data */
  313. void *owner_priv;
  314. };
  315. extern struct ib_completion_queue * ib_create_cq ( struct ib_device *ibdev,
  316. unsigned int num_cqes );
  317. extern void ib_destroy_cq ( struct ib_device *ibdev,
  318. struct ib_completion_queue *cq );
  319. extern struct ib_queue_pair *
  320. ib_create_qp ( struct ib_device *ibdev, unsigned int num_send_wqes,
  321. struct ib_completion_queue *send_cq, unsigned int num_recv_wqes,
  322. struct ib_completion_queue *recv_cq, unsigned long qkey );
  323. extern int ib_modify_qp ( struct ib_device *ibdev, struct ib_queue_pair *qp,
  324. unsigned long mod_list, unsigned long qkey );
  325. extern void ib_destroy_qp ( struct ib_device *ibdev,
  326. struct ib_queue_pair *qp );
  327. extern struct ib_work_queue * ib_find_wq ( struct ib_completion_queue *cq,
  328. unsigned long qpn, int is_send );
  329. extern struct ib_device * alloc_ibdev ( size_t priv_size );
  330. extern int register_ibdev ( struct ib_device *ibdev );
  331. extern void unregister_ibdev ( struct ib_device *ibdev );
  332. extern void ib_link_state_changed ( struct ib_device *ibdev );
  333. /**
  334. * Post send work queue entry
  335. *
  336. * @v ibdev Infiniband device
  337. * @v qp Queue pair
  338. * @v av Address vector
  339. * @v iobuf I/O buffer
  340. * @ret rc Return status code
  341. */
  342. static inline __attribute__ (( always_inline )) int
  343. ib_post_send ( struct ib_device *ibdev, struct ib_queue_pair *qp,
  344. struct ib_address_vector *av, struct io_buffer *iobuf ) {
  345. return ibdev->op->post_send ( ibdev, qp, av, iobuf );
  346. }
  347. /**
  348. * Post receive work queue entry
  349. *
  350. * @v ibdev Infiniband device
  351. * @v qp Queue pair
  352. * @v iobuf I/O buffer
  353. * @ret rc Return status code
  354. */
  355. static inline __attribute__ (( always_inline )) int
  356. ib_post_recv ( struct ib_device *ibdev, struct ib_queue_pair *qp,
  357. struct io_buffer *iobuf ) {
  358. return ibdev->op->post_recv ( ibdev, qp, iobuf );
  359. }
  360. /**
  361. * Poll completion queue
  362. *
  363. * @v ibdev Infiniband device
  364. * @v cq Completion queue
  365. * @v complete_send Send completion handler
  366. * @v complete_recv Receive completion handler
  367. */
  368. static inline __attribute__ (( always_inline )) void
  369. ib_poll_cq ( struct ib_device *ibdev, struct ib_completion_queue *cq,
  370. ib_completer_t complete_send, ib_completer_t complete_recv ) {
  371. ibdev->op->poll_cq ( ibdev, cq, complete_send, complete_recv );
  372. }
  373. /**
  374. * Open port
  375. *
  376. * @v ibdev Infiniband device
  377. * @ret rc Return status code
  378. */
  379. static inline __attribute__ (( always_inline )) int
  380. ib_open ( struct ib_device *ibdev ) {
  381. return ibdev->op->open ( ibdev );
  382. }
  383. /**
  384. * Close port
  385. *
  386. * @v ibdev Infiniband device
  387. */
  388. static inline __attribute__ (( always_inline )) void
  389. ib_close ( struct ib_device *ibdev ) {
  390. ibdev->op->close ( ibdev );
  391. }
  392. /**
  393. * Attach to multicast group
  394. *
  395. * @v ibdev Infiniband device
  396. * @v qp Queue pair
  397. * @v gid Multicast GID
  398. * @ret rc Return status code
  399. */
  400. static inline __attribute__ (( always_inline )) int
  401. ib_mcast_attach ( struct ib_device *ibdev, struct ib_queue_pair *qp,
  402. struct ib_gid *gid ) {
  403. return ibdev->op->mcast_attach ( ibdev, qp, gid );
  404. }
  405. /**
  406. * Detach from multicast group
  407. *
  408. * @v ibdev Infiniband device
  409. * @v qp Queue pair
  410. * @v gid Multicast GID
  411. */
  412. static inline __attribute__ (( always_inline )) void
  413. ib_mcast_detach ( struct ib_device *ibdev, struct ib_queue_pair *qp,
  414. struct ib_gid *gid ) {
  415. ibdev->op->mcast_detach ( ibdev, qp, gid );
  416. }
  417. /**
  418. * Issue management datagram
  419. *
  420. * @v ibdev Infiniband device
  421. * @v mad Management datagram
  422. * @v len Length of management datagram
  423. * @ret rc Return status code
  424. */
  425. static inline __attribute__ (( always_inline )) int
  426. ib_mad ( struct ib_device *ibdev, struct ib_mad_hdr *mad, size_t len ) {
  427. return ibdev->op->mad ( ibdev, mad, len );
  428. }
  429. /**
  430. * Get reference to Infiniband device
  431. *
  432. * @v ibdev Infiniband device
  433. * @ret ibdev Infiniband device
  434. */
  435. static inline __attribute__ (( always_inline )) struct ib_device *
  436. ibdev_get ( struct ib_device *ibdev ) {
  437. ref_get ( &ibdev->refcnt );
  438. return ibdev;
  439. }
  440. /**
  441. * Drop reference to Infiniband device
  442. *
  443. * @v ibdev Infiniband device
  444. */
  445. static inline __attribute__ (( always_inline )) void
  446. ibdev_put ( struct ib_device *ibdev ) {
  447. ref_put ( &ibdev->refcnt );
  448. }
  449. /**
  450. * Set Infiniband work queue driver-private data
  451. *
  452. * @v wq Work queue
  453. * @v priv Private data
  454. */
  455. static inline __attribute__ (( always_inline )) void
  456. ib_wq_set_drvdata ( struct ib_work_queue *wq, void *priv ) {
  457. wq->drv_priv = priv;
  458. }
  459. /**
  460. * Get Infiniband work queue driver-private data
  461. *
  462. * @v wq Work queue
  463. * @ret priv Private data
  464. */
  465. static inline __attribute__ (( always_inline )) void *
  466. ib_wq_get_drvdata ( struct ib_work_queue *wq ) {
  467. return wq->drv_priv;
  468. }
  469. /**
  470. * Set Infiniband queue pair driver-private data
  471. *
  472. * @v qp Queue pair
  473. * @v priv Private data
  474. */
  475. static inline __attribute__ (( always_inline )) void
  476. ib_qp_set_drvdata ( struct ib_queue_pair *qp, void *priv ) {
  477. qp->drv_priv = priv;
  478. }
  479. /**
  480. * Get Infiniband queue pair driver-private data
  481. *
  482. * @v qp Queue pair
  483. * @ret priv Private data
  484. */
  485. static inline __attribute__ (( always_inline )) void *
  486. ib_qp_get_drvdata ( struct ib_queue_pair *qp ) {
  487. return qp->drv_priv;
  488. }
  489. /**
  490. * Set Infiniband queue pair owner-private data
  491. *
  492. * @v qp Queue pair
  493. * @v priv Private data
  494. */
  495. static inline __attribute__ (( always_inline )) void
  496. ib_qp_set_ownerdata ( struct ib_queue_pair *qp, void *priv ) {
  497. qp->owner_priv = priv;
  498. }
  499. /**
  500. * Get Infiniband queue pair owner-private data
  501. *
  502. * @v qp Queue pair
  503. * @ret priv Private data
  504. */
  505. static inline __attribute__ (( always_inline )) void *
  506. ib_qp_get_ownerdata ( struct ib_queue_pair *qp ) {
  507. return qp->owner_priv;
  508. }
  509. /**
  510. * Set Infiniband completion queue driver-private data
  511. *
  512. * @v cq Completion queue
  513. * @v priv Private data
  514. */
  515. static inline __attribute__ (( always_inline )) void
  516. ib_cq_set_drvdata ( struct ib_completion_queue *cq, void *priv ) {
  517. cq->drv_priv = priv;
  518. }
  519. /**
  520. * Get Infiniband completion queue driver-private data
  521. *
  522. * @v cq Completion queue
  523. * @ret priv Private data
  524. */
  525. static inline __attribute__ (( always_inline )) void *
  526. ib_cq_get_drvdata ( struct ib_completion_queue *cq ) {
  527. return cq->drv_priv;
  528. }
  529. /**
  530. * Set Infiniband device driver-private data
  531. *
  532. * @v ibdev Infiniband device
  533. * @v priv Private data
  534. */
  535. static inline __attribute__ (( always_inline )) void
  536. ib_set_drvdata ( struct ib_device *ibdev, void *priv ) {
  537. ibdev->drv_priv = priv;
  538. }
  539. /**
  540. * Get Infiniband device driver-private data
  541. *
  542. * @v ibdev Infiniband device
  543. * @ret priv Private data
  544. */
  545. static inline __attribute__ (( always_inline )) void *
  546. ib_get_drvdata ( struct ib_device *ibdev ) {
  547. return ibdev->drv_priv;
  548. }
  549. /**
  550. * Set Infiniband device owner-private data
  551. *
  552. * @v ibdev Infiniband device
  553. * @v priv Private data
  554. */
  555. static inline __attribute__ (( always_inline )) void
  556. ib_set_ownerdata ( struct ib_device *ibdev, void *priv ) {
  557. ibdev->owner_priv = priv;
  558. }
  559. /**
  560. * Get Infiniband device owner-private data
  561. *
  562. * @v ibdev Infiniband device
  563. * @ret priv Private data
  564. */
  565. static inline __attribute__ (( always_inline )) void *
  566. ib_get_ownerdata ( struct ib_device *ibdev ) {
  567. return ibdev->owner_priv;
  568. }
  569. /*****************************************************************************
  570. *
  571. * Management datagrams
  572. *
  573. * Portions Copyright (c) 2004 Mellanox Technologies Ltd. All rights
  574. * reserved.
  575. *
  576. */
  577. /* Management base version */
  578. #define IB_MGMT_BASE_VERSION 1
  579. /* Management classes */
  580. #define IB_MGMT_CLASS_SUBN_LID_ROUTED 0x01
  581. #define IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE 0x81
  582. #define IB_MGMT_CLASS_SUBN_ADM 0x03
  583. #define IB_MGMT_CLASS_PERF_MGMT 0x04
  584. #define IB_MGMT_CLASS_BM 0x05
  585. #define IB_MGMT_CLASS_DEVICE_MGMT 0x06
  586. #define IB_MGMT_CLASS_CM 0x07
  587. #define IB_MGMT_CLASS_SNMP 0x08
  588. #define IB_MGMT_CLASS_VENDOR_RANGE2_START 0x30
  589. #define IB_MGMT_CLASS_VENDOR_RANGE2_END 0x4F
  590. /* Management methods */
  591. #define IB_MGMT_METHOD_GET 0x01
  592. #define IB_MGMT_METHOD_SET 0x02
  593. #define IB_MGMT_METHOD_GET_RESP 0x81
  594. #define IB_MGMT_METHOD_SEND 0x03
  595. #define IB_MGMT_METHOD_TRAP 0x05
  596. #define IB_MGMT_METHOD_REPORT 0x06
  597. #define IB_MGMT_METHOD_REPORT_RESP 0x86
  598. #define IB_MGMT_METHOD_TRAP_REPRESS 0x07
  599. #define IB_MGMT_METHOD_DELETE 0x15
  600. #define IB_MGMT_METHOD_RESP 0x80
  601. /* Subnet management attributes */
  602. #define IB_SMP_ATTR_NOTICE 0x0002
  603. #define IB_SMP_ATTR_NODE_DESC 0x0010
  604. #define IB_SMP_ATTR_NODE_INFO 0x0011
  605. #define IB_SMP_ATTR_SWITCH_INFO 0x0012
  606. #define IB_SMP_ATTR_GUID_INFO 0x0014
  607. #define IB_SMP_ATTR_PORT_INFO 0x0015
  608. #define IB_SMP_ATTR_PKEY_TABLE 0x0016
  609. #define IB_SMP_ATTR_SL_TO_VL_TABLE 0x0017
  610. #define IB_SMP_ATTR_VL_ARB_TABLE 0x0018
  611. #define IB_SMP_ATTR_LINEAR_FORWARD_TABLE 0x0019
  612. #define IB_SMP_ATTR_RANDOM_FORWARD_TABLE 0x001A
  613. #define IB_SMP_ATTR_MCAST_FORWARD_TABLE 0x001B
  614. #define IB_SMP_ATTR_SM_INFO 0x0020
  615. #define IB_SMP_ATTR_VENDOR_DIAG 0x0030
  616. #define IB_SMP_ATTR_LED_INFO 0x0031
  617. #define IB_SMP_ATTR_VENDOR_MASK 0xFF00
  618. #define IB_SA_ATTR_MC_MEMBER_REC 0x38
  619. #define IB_SA_ATTR_PATH_REC 0x35
  620. #define IB_SA_MCMEMBER_REC_MGID (1<<0)
  621. #define IB_SA_MCMEMBER_REC_PORT_GID (1<<1)
  622. #define IB_SA_MCMEMBER_REC_QKEY (1<<2)
  623. #define IB_SA_MCMEMBER_REC_MLID (1<<3)
  624. #define IB_SA_MCMEMBER_REC_MTU_SELECTOR (1<<4)
  625. #define IB_SA_MCMEMBER_REC_MTU (1<<5)
  626. #define IB_SA_MCMEMBER_REC_TRAFFIC_CLASS (1<<6)
  627. #define IB_SA_MCMEMBER_REC_PKEY (1<<7)
  628. #define IB_SA_MCMEMBER_REC_RATE_SELECTOR (1<<8)
  629. #define IB_SA_MCMEMBER_REC_RATE (1<<9)
  630. #define IB_SA_MCMEMBER_REC_PACKET_LIFE_TIME_SELECTOR (1<<10)
  631. #define IB_SA_MCMEMBER_REC_PACKET_LIFE_TIME (1<<11)
  632. #define IB_SA_MCMEMBER_REC_SL (1<<12)
  633. #define IB_SA_MCMEMBER_REC_FLOW_LABEL (1<<13)
  634. #define IB_SA_MCMEMBER_REC_HOP_LIMIT (1<<14)
  635. #define IB_SA_MCMEMBER_REC_SCOPE (1<<15)
  636. #define IB_SA_MCMEMBER_REC_JOIN_STATE (1<<16)
  637. #define IB_SA_MCMEMBER_REC_PROXY_JOIN (1<<17)
  638. #define IB_SA_PATH_REC_DGID (1<<2)
  639. #define IB_SA_PATH_REC_SGID (1<<3)
  640. struct ib_mad_hdr {
  641. uint8_t base_version;
  642. uint8_t mgmt_class;
  643. uint8_t class_version;
  644. uint8_t method;
  645. uint16_t status;
  646. uint16_t class_specific;
  647. uint32_t tid[2];
  648. uint16_t attr_id;
  649. uint16_t resv;
  650. uint32_t attr_mod;
  651. } __attribute__ (( packed ));
  652. struct ib_sa_hdr {
  653. uint32_t sm_key[2];
  654. uint16_t reserved;
  655. uint16_t attrib_offset;
  656. uint32_t comp_mask[2];
  657. } __attribute__ (( packed ));
  658. struct ib_rmpp_hdr {
  659. uint32_t raw[3];
  660. } __attribute__ (( packed ));
  661. struct ib_mad_data {
  662. struct ib_mad_hdr mad_hdr;
  663. uint8_t data[232];
  664. } __attribute__ (( packed ));
  665. struct ib_mad_guid_info {
  666. struct ib_mad_hdr mad_hdr;
  667. uint32_t mkey[2];
  668. uint32_t reserved[8];
  669. uint8_t gid_local[8];
  670. } __attribute__ (( packed ));
  671. struct ib_mad_port_info {
  672. struct ib_mad_hdr mad_hdr;
  673. uint32_t mkey[2];
  674. uint32_t reserved[8];
  675. uint32_t mkey2[2];
  676. uint8_t gid_prefix[8];
  677. uint16_t lid;
  678. uint16_t mastersm_lid;
  679. uint32_t cap_mask;
  680. uint16_t diag_code;
  681. uint16_t mkey_lease_period;
  682. uint8_t local_port_num;
  683. uint8_t link_width_enabled;
  684. uint8_t link_width_supported;
  685. uint8_t link_width_active;
  686. uint8_t port_state__link_speed_supported;
  687. uint8_t link_down_def_state__port_phys_state;
  688. uint8_t lmc__r1__mkey_prot_bits;
  689. uint8_t link_speed_enabled__link_speed_active;
  690. } __attribute__ (( packed ));
  691. struct ib_mad_pkey_table {
  692. struct ib_mad_hdr mad_hdr;
  693. uint32_t mkey[2];
  694. uint32_t reserved[8];
  695. uint16_t pkey[16][2];
  696. } __attribute__ (( packed ));
  697. struct ib_mad_path_record {
  698. struct ib_mad_hdr mad_hdr;
  699. struct ib_rmpp_hdr rmpp_hdr;
  700. struct ib_sa_hdr sa_hdr;
  701. uint32_t reserved0[2];
  702. struct ib_gid dgid;
  703. struct ib_gid sgid;
  704. uint16_t dlid;
  705. uint16_t slid;
  706. uint32_t hop_limit__flow_label__raw_traffic;
  707. uint32_t pkey__numb_path__reversible__tclass;
  708. uint8_t reserved1;
  709. uint8_t reserved__sl;
  710. uint8_t mtu_selector__mtu;
  711. uint8_t rate_selector__rate;
  712. uint32_t preference__packet_lifetime__packet_lifetime_selector;
  713. uint32_t reserved2[35];
  714. } __attribute__ (( packed ));
  715. struct ib_mad_mc_member_record {
  716. struct ib_mad_hdr mad_hdr;
  717. struct ib_rmpp_hdr rmpp_hdr;
  718. struct ib_sa_hdr sa_hdr;
  719. struct ib_gid mgid;
  720. struct ib_gid port_gid;
  721. uint32_t qkey;
  722. uint16_t mlid;
  723. uint8_t mtu_selector__mtu;
  724. uint8_t tclass;
  725. uint16_t pkey;
  726. uint8_t rate_selector__rate;
  727. uint8_t packet_lifetime_selector__packet_lifetime;
  728. uint32_t sl__flow_label__hop_limit;
  729. uint8_t scope__join_state;
  730. uint8_t proxy_join__reserved;
  731. uint16_t reserved0;
  732. uint32_t reserved1[37];
  733. } __attribute__ (( packed ));
  734. union ib_mad {
  735. struct ib_mad_hdr mad_hdr;
  736. struct ib_mad_data data;
  737. struct ib_mad_guid_info guid_info;
  738. struct ib_mad_port_info port_info;
  739. struct ib_mad_pkey_table pkey_table;
  740. struct ib_mad_path_record path_record;
  741. struct ib_mad_mc_member_record mc_member_record;
  742. } __attribute__ (( packed ));
  743. #endif /* _GPXE_INFINIBAND_H */