ib_user_verbs.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689
  1. /*
  2. * Copyright (c) 2005 Topspin Communications. All rights reserved.
  3. * Copyright (c) 2005, 2006 Cisco Systems. All rights reserved.
  4. * Copyright (c) 2005 PathScale, Inc. All rights reserved.
  5. * Copyright (c) 2006 Mellanox Technologies. All rights reserved.
  6. *
  7. * This software is available to you under a choice of one of two
  8. * licenses. You may choose to be licensed under the terms of the GNU
  9. * General Public License (GPL) Version 2, available from the file
  10. * COPYING in the main directory of this source tree, or the
  11. * OpenIB.org BSD license below:
  12. *
  13. * Redistribution and use in source and binary forms, with or
  14. * without modification, are permitted provided that the following
  15. * conditions are met:
  16. *
  17. * - Redistributions of source code must retain the above
  18. * copyright notice, this list of conditions and the following
  19. * disclaimer.
  20. *
  21. * - Redistributions in binary form must reproduce the above
  22. * copyright notice, this list of conditions and the following
  23. * disclaimer in the documentation and/or other materials
  24. * provided with the distribution.
  25. *
  26. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  27. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  28. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  29. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  30. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  31. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  32. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  33. * SOFTWARE.
  34. */
  35. #ifndef IB_USER_VERBS_H
  36. #define IB_USER_VERBS_H
  37. #include <linux/types.h>
  38. /*
  39. * Increment this value if any changes that break userspace ABI
  40. * compatibility are made.
  41. */
  42. #define IB_USER_VERBS_ABI_VERSION 6
  43. enum {
  44. IB_USER_VERBS_CMD_GET_CONTEXT,
  45. IB_USER_VERBS_CMD_QUERY_DEVICE,
  46. IB_USER_VERBS_CMD_QUERY_PORT,
  47. IB_USER_VERBS_CMD_ALLOC_PD,
  48. IB_USER_VERBS_CMD_DEALLOC_PD,
  49. IB_USER_VERBS_CMD_CREATE_AH,
  50. IB_USER_VERBS_CMD_MODIFY_AH,
  51. IB_USER_VERBS_CMD_QUERY_AH,
  52. IB_USER_VERBS_CMD_DESTROY_AH,
  53. IB_USER_VERBS_CMD_REG_MR,
  54. IB_USER_VERBS_CMD_REG_SMR,
  55. IB_USER_VERBS_CMD_REREG_MR,
  56. IB_USER_VERBS_CMD_QUERY_MR,
  57. IB_USER_VERBS_CMD_DEREG_MR,
  58. IB_USER_VERBS_CMD_ALLOC_MW,
  59. IB_USER_VERBS_CMD_BIND_MW,
  60. IB_USER_VERBS_CMD_DEALLOC_MW,
  61. IB_USER_VERBS_CMD_CREATE_COMP_CHANNEL,
  62. IB_USER_VERBS_CMD_CREATE_CQ,
  63. IB_USER_VERBS_CMD_RESIZE_CQ,
  64. IB_USER_VERBS_CMD_DESTROY_CQ,
  65. IB_USER_VERBS_CMD_POLL_CQ,
  66. IB_USER_VERBS_CMD_PEEK_CQ,
  67. IB_USER_VERBS_CMD_REQ_NOTIFY_CQ,
  68. IB_USER_VERBS_CMD_CREATE_QP,
  69. IB_USER_VERBS_CMD_QUERY_QP,
  70. IB_USER_VERBS_CMD_MODIFY_QP,
  71. IB_USER_VERBS_CMD_DESTROY_QP,
  72. IB_USER_VERBS_CMD_POST_SEND,
  73. IB_USER_VERBS_CMD_POST_RECV,
  74. IB_USER_VERBS_CMD_ATTACH_MCAST,
  75. IB_USER_VERBS_CMD_DETACH_MCAST,
  76. IB_USER_VERBS_CMD_CREATE_SRQ,
  77. IB_USER_VERBS_CMD_MODIFY_SRQ,
  78. IB_USER_VERBS_CMD_QUERY_SRQ,
  79. IB_USER_VERBS_CMD_DESTROY_SRQ,
  80. IB_USER_VERBS_CMD_POST_SRQ_RECV
  81. };
  82. /*
  83. * Make sure that all structs defined in this file remain laid out so
  84. * that they pack the same way on 32-bit and 64-bit architectures (to
  85. * avoid incompatibility between 32-bit userspace and 64-bit kernels).
  86. * Specifically:
  87. * - Do not use pointer types -- pass pointers in __u64 instead.
  88. * - Make sure that any structure larger than 4 bytes is padded to a
  89. * multiple of 8 bytes. Otherwise the structure size will be
  90. * different between 32-bit and 64-bit architectures.
  91. */
  92. struct ib_uverbs_async_event_desc {
  93. __u64 element;
  94. __u32 event_type; /* enum ib_event_type */
  95. __u32 reserved;
  96. };
  97. struct ib_uverbs_comp_event_desc {
  98. __u64 cq_handle;
  99. };
  100. /*
  101. * All commands from userspace should start with a __u32 command field
  102. * followed by __u16 in_words and out_words fields (which give the
  103. * length of the command block and response buffer if any in 32-bit
  104. * words). The kernel driver will read these fields first and read
  105. * the rest of the command struct based on these value.
  106. */
  107. struct ib_uverbs_cmd_hdr {
  108. __u32 command;
  109. __u16 in_words;
  110. __u16 out_words;
  111. };
  112. struct ib_uverbs_get_context {
  113. __u64 response;
  114. __u64 driver_data[0];
  115. };
  116. struct ib_uverbs_get_context_resp {
  117. __u32 async_fd;
  118. __u32 num_comp_vectors;
  119. };
  120. struct ib_uverbs_query_device {
  121. __u64 response;
  122. __u64 driver_data[0];
  123. };
  124. struct ib_uverbs_query_device_resp {
  125. __u64 fw_ver;
  126. __be64 node_guid;
  127. __be64 sys_image_guid;
  128. __u64 max_mr_size;
  129. __u64 page_size_cap;
  130. __u32 vendor_id;
  131. __u32 vendor_part_id;
  132. __u32 hw_ver;
  133. __u32 max_qp;
  134. __u32 max_qp_wr;
  135. __u32 device_cap_flags;
  136. __u32 max_sge;
  137. __u32 max_sge_rd;
  138. __u32 max_cq;
  139. __u32 max_cqe;
  140. __u32 max_mr;
  141. __u32 max_pd;
  142. __u32 max_qp_rd_atom;
  143. __u32 max_ee_rd_atom;
  144. __u32 max_res_rd_atom;
  145. __u32 max_qp_init_rd_atom;
  146. __u32 max_ee_init_rd_atom;
  147. __u32 atomic_cap;
  148. __u32 max_ee;
  149. __u32 max_rdd;
  150. __u32 max_mw;
  151. __u32 max_raw_ipv6_qp;
  152. __u32 max_raw_ethy_qp;
  153. __u32 max_mcast_grp;
  154. __u32 max_mcast_qp_attach;
  155. __u32 max_total_mcast_qp_attach;
  156. __u32 max_ah;
  157. __u32 max_fmr;
  158. __u32 max_map_per_fmr;
  159. __u32 max_srq;
  160. __u32 max_srq_wr;
  161. __u32 max_srq_sge;
  162. __u16 max_pkeys;
  163. __u8 local_ca_ack_delay;
  164. __u8 phys_port_cnt;
  165. __u8 reserved[4];
  166. };
  167. struct ib_uverbs_query_port {
  168. __u64 response;
  169. __u8 port_num;
  170. __u8 reserved[7];
  171. __u64 driver_data[0];
  172. };
  173. struct ib_uverbs_query_port_resp {
  174. __u32 port_cap_flags;
  175. __u32 max_msg_sz;
  176. __u32 bad_pkey_cntr;
  177. __u32 qkey_viol_cntr;
  178. __u32 gid_tbl_len;
  179. __u16 pkey_tbl_len;
  180. __u16 lid;
  181. __u16 sm_lid;
  182. __u8 state;
  183. __u8 max_mtu;
  184. __u8 active_mtu;
  185. __u8 lmc;
  186. __u8 max_vl_num;
  187. __u8 sm_sl;
  188. __u8 subnet_timeout;
  189. __u8 init_type_reply;
  190. __u8 active_width;
  191. __u8 active_speed;
  192. __u8 phys_state;
  193. __u8 reserved[3];
  194. };
  195. struct ib_uverbs_alloc_pd {
  196. __u64 response;
  197. __u64 driver_data[0];
  198. };
  199. struct ib_uverbs_alloc_pd_resp {
  200. __u32 pd_handle;
  201. };
  202. struct ib_uverbs_dealloc_pd {
  203. __u32 pd_handle;
  204. };
  205. struct ib_uverbs_reg_mr {
  206. __u64 response;
  207. __u64 start;
  208. __u64 length;
  209. __u64 hca_va;
  210. __u32 pd_handle;
  211. __u32 access_flags;
  212. __u64 driver_data[0];
  213. };
  214. struct ib_uverbs_reg_mr_resp {
  215. __u32 mr_handle;
  216. __u32 lkey;
  217. __u32 rkey;
  218. };
  219. struct ib_uverbs_dereg_mr {
  220. __u32 mr_handle;
  221. };
  222. struct ib_uverbs_create_comp_channel {
  223. __u64 response;
  224. };
  225. struct ib_uverbs_create_comp_channel_resp {
  226. __u32 fd;
  227. };
  228. struct ib_uverbs_create_cq {
  229. __u64 response;
  230. __u64 user_handle;
  231. __u32 cqe;
  232. __u32 comp_vector;
  233. __s32 comp_channel;
  234. __u32 reserved;
  235. __u64 driver_data[0];
  236. };
  237. struct ib_uverbs_create_cq_resp {
  238. __u32 cq_handle;
  239. __u32 cqe;
  240. };
  241. struct ib_uverbs_resize_cq {
  242. __u64 response;
  243. __u32 cq_handle;
  244. __u32 cqe;
  245. __u64 driver_data[0];
  246. };
  247. struct ib_uverbs_resize_cq_resp {
  248. __u32 cqe;
  249. __u32 reserved;
  250. __u64 driver_data[0];
  251. };
  252. struct ib_uverbs_poll_cq {
  253. __u64 response;
  254. __u32 cq_handle;
  255. __u32 ne;
  256. };
  257. struct ib_uverbs_wc {
  258. __u64 wr_id;
  259. __u32 status;
  260. __u32 opcode;
  261. __u32 vendor_err;
  262. __u32 byte_len;
  263. union {
  264. __u32 imm_data;
  265. __u32 invalidate_rkey;
  266. } ex;
  267. __u32 qp_num;
  268. __u32 src_qp;
  269. __u32 wc_flags;
  270. __u16 pkey_index;
  271. __u16 slid;
  272. __u8 sl;
  273. __u8 dlid_path_bits;
  274. __u8 port_num;
  275. __u8 reserved;
  276. };
  277. struct ib_uverbs_poll_cq_resp {
  278. __u32 count;
  279. __u32 reserved;
  280. struct ib_uverbs_wc wc[0];
  281. };
  282. struct ib_uverbs_req_notify_cq {
  283. __u32 cq_handle;
  284. __u32 solicited_only;
  285. };
  286. struct ib_uverbs_destroy_cq {
  287. __u64 response;
  288. __u32 cq_handle;
  289. __u32 reserved;
  290. };
  291. struct ib_uverbs_destroy_cq_resp {
  292. __u32 comp_events_reported;
  293. __u32 async_events_reported;
  294. };
  295. struct ib_uverbs_global_route {
  296. __u8 dgid[16];
  297. __u32 flow_label;
  298. __u8 sgid_index;
  299. __u8 hop_limit;
  300. __u8 traffic_class;
  301. __u8 reserved;
  302. };
  303. struct ib_uverbs_ah_attr {
  304. struct ib_uverbs_global_route grh;
  305. __u16 dlid;
  306. __u8 sl;
  307. __u8 src_path_bits;
  308. __u8 static_rate;
  309. __u8 is_global;
  310. __u8 port_num;
  311. __u8 reserved;
  312. };
  313. struct ib_uverbs_qp_attr {
  314. __u32 qp_attr_mask;
  315. __u32 qp_state;
  316. __u32 cur_qp_state;
  317. __u32 path_mtu;
  318. __u32 path_mig_state;
  319. __u32 qkey;
  320. __u32 rq_psn;
  321. __u32 sq_psn;
  322. __u32 dest_qp_num;
  323. __u32 qp_access_flags;
  324. struct ib_uverbs_ah_attr ah_attr;
  325. struct ib_uverbs_ah_attr alt_ah_attr;
  326. /* ib_qp_cap */
  327. __u32 max_send_wr;
  328. __u32 max_recv_wr;
  329. __u32 max_send_sge;
  330. __u32 max_recv_sge;
  331. __u32 max_inline_data;
  332. __u16 pkey_index;
  333. __u16 alt_pkey_index;
  334. __u8 en_sqd_async_notify;
  335. __u8 sq_draining;
  336. __u8 max_rd_atomic;
  337. __u8 max_dest_rd_atomic;
  338. __u8 min_rnr_timer;
  339. __u8 port_num;
  340. __u8 timeout;
  341. __u8 retry_cnt;
  342. __u8 rnr_retry;
  343. __u8 alt_port_num;
  344. __u8 alt_timeout;
  345. __u8 reserved[5];
  346. };
  347. struct ib_uverbs_create_qp {
  348. __u64 response;
  349. __u64 user_handle;
  350. __u32 pd_handle;
  351. __u32 send_cq_handle;
  352. __u32 recv_cq_handle;
  353. __u32 srq_handle;
  354. __u32 max_send_wr;
  355. __u32 max_recv_wr;
  356. __u32 max_send_sge;
  357. __u32 max_recv_sge;
  358. __u32 max_inline_data;
  359. __u8 sq_sig_all;
  360. __u8 qp_type;
  361. __u8 is_srq;
  362. __u8 reserved;
  363. __u64 driver_data[0];
  364. };
  365. struct ib_uverbs_create_qp_resp {
  366. __u32 qp_handle;
  367. __u32 qpn;
  368. __u32 max_send_wr;
  369. __u32 max_recv_wr;
  370. __u32 max_send_sge;
  371. __u32 max_recv_sge;
  372. __u32 max_inline_data;
  373. __u32 reserved;
  374. };
  375. /*
  376. * This struct needs to remain a multiple of 8 bytes to keep the
  377. * alignment of the modify QP parameters.
  378. */
  379. struct ib_uverbs_qp_dest {
  380. __u8 dgid[16];
  381. __u32 flow_label;
  382. __u16 dlid;
  383. __u16 reserved;
  384. __u8 sgid_index;
  385. __u8 hop_limit;
  386. __u8 traffic_class;
  387. __u8 sl;
  388. __u8 src_path_bits;
  389. __u8 static_rate;
  390. __u8 is_global;
  391. __u8 port_num;
  392. };
  393. struct ib_uverbs_query_qp {
  394. __u64 response;
  395. __u32 qp_handle;
  396. __u32 attr_mask;
  397. __u64 driver_data[0];
  398. };
  399. struct ib_uverbs_query_qp_resp {
  400. struct ib_uverbs_qp_dest dest;
  401. struct ib_uverbs_qp_dest alt_dest;
  402. __u32 max_send_wr;
  403. __u32 max_recv_wr;
  404. __u32 max_send_sge;
  405. __u32 max_recv_sge;
  406. __u32 max_inline_data;
  407. __u32 qkey;
  408. __u32 rq_psn;
  409. __u32 sq_psn;
  410. __u32 dest_qp_num;
  411. __u32 qp_access_flags;
  412. __u16 pkey_index;
  413. __u16 alt_pkey_index;
  414. __u8 qp_state;
  415. __u8 cur_qp_state;
  416. __u8 path_mtu;
  417. __u8 path_mig_state;
  418. __u8 sq_draining;
  419. __u8 max_rd_atomic;
  420. __u8 max_dest_rd_atomic;
  421. __u8 min_rnr_timer;
  422. __u8 port_num;
  423. __u8 timeout;
  424. __u8 retry_cnt;
  425. __u8 rnr_retry;
  426. __u8 alt_port_num;
  427. __u8 alt_timeout;
  428. __u8 sq_sig_all;
  429. __u8 reserved[5];
  430. __u64 driver_data[0];
  431. };
  432. struct ib_uverbs_modify_qp {
  433. struct ib_uverbs_qp_dest dest;
  434. struct ib_uverbs_qp_dest alt_dest;
  435. __u32 qp_handle;
  436. __u32 attr_mask;
  437. __u32 qkey;
  438. __u32 rq_psn;
  439. __u32 sq_psn;
  440. __u32 dest_qp_num;
  441. __u32 qp_access_flags;
  442. __u16 pkey_index;
  443. __u16 alt_pkey_index;
  444. __u8 qp_state;
  445. __u8 cur_qp_state;
  446. __u8 path_mtu;
  447. __u8 path_mig_state;
  448. __u8 en_sqd_async_notify;
  449. __u8 max_rd_atomic;
  450. __u8 max_dest_rd_atomic;
  451. __u8 min_rnr_timer;
  452. __u8 port_num;
  453. __u8 timeout;
  454. __u8 retry_cnt;
  455. __u8 rnr_retry;
  456. __u8 alt_port_num;
  457. __u8 alt_timeout;
  458. __u8 reserved[2];
  459. __u64 driver_data[0];
  460. };
  461. struct ib_uverbs_modify_qp_resp {
  462. };
  463. struct ib_uverbs_destroy_qp {
  464. __u64 response;
  465. __u32 qp_handle;
  466. __u32 reserved;
  467. };
  468. struct ib_uverbs_destroy_qp_resp {
  469. __u32 events_reported;
  470. };
  471. /*
  472. * The ib_uverbs_sge structure isn't used anywhere, since we assume
  473. * the ib_sge structure is packed the same way on 32-bit and 64-bit
  474. * architectures in both kernel and user space. It's just here to
  475. * document the ABI.
  476. */
  477. struct ib_uverbs_sge {
  478. __u64 addr;
  479. __u32 length;
  480. __u32 lkey;
  481. };
  482. struct ib_uverbs_send_wr {
  483. __u64 wr_id;
  484. __u32 num_sge;
  485. __u32 opcode;
  486. __u32 send_flags;
  487. union {
  488. __u32 imm_data;
  489. __u32 invalidate_rkey;
  490. } ex;
  491. union {
  492. struct {
  493. __u64 remote_addr;
  494. __u32 rkey;
  495. __u32 reserved;
  496. } rdma;
  497. struct {
  498. __u64 remote_addr;
  499. __u64 compare_add;
  500. __u64 swap;
  501. __u32 rkey;
  502. __u32 reserved;
  503. } atomic;
  504. struct {
  505. __u32 ah;
  506. __u32 remote_qpn;
  507. __u32 remote_qkey;
  508. __u32 reserved;
  509. } ud;
  510. } wr;
  511. };
  512. struct ib_uverbs_post_send {
  513. __u64 response;
  514. __u32 qp_handle;
  515. __u32 wr_count;
  516. __u32 sge_count;
  517. __u32 wqe_size;
  518. struct ib_uverbs_send_wr send_wr[0];
  519. };
  520. struct ib_uverbs_post_send_resp {
  521. __u32 bad_wr;
  522. };
  523. struct ib_uverbs_recv_wr {
  524. __u64 wr_id;
  525. __u32 num_sge;
  526. __u32 reserved;
  527. };
  528. struct ib_uverbs_post_recv {
  529. __u64 response;
  530. __u32 qp_handle;
  531. __u32 wr_count;
  532. __u32 sge_count;
  533. __u32 wqe_size;
  534. struct ib_uverbs_recv_wr recv_wr[0];
  535. };
  536. struct ib_uverbs_post_recv_resp {
  537. __u32 bad_wr;
  538. };
  539. struct ib_uverbs_post_srq_recv {
  540. __u64 response;
  541. __u32 srq_handle;
  542. __u32 wr_count;
  543. __u32 sge_count;
  544. __u32 wqe_size;
  545. struct ib_uverbs_recv_wr recv[0];
  546. };
  547. struct ib_uverbs_post_srq_recv_resp {
  548. __u32 bad_wr;
  549. };
  550. struct ib_uverbs_create_ah {
  551. __u64 response;
  552. __u64 user_handle;
  553. __u32 pd_handle;
  554. __u32 reserved;
  555. struct ib_uverbs_ah_attr attr;
  556. };
  557. struct ib_uverbs_create_ah_resp {
  558. __u32 ah_handle;
  559. };
  560. struct ib_uverbs_destroy_ah {
  561. __u32 ah_handle;
  562. };
  563. struct ib_uverbs_attach_mcast {
  564. __u8 gid[16];
  565. __u32 qp_handle;
  566. __u16 mlid;
  567. __u16 reserved;
  568. __u64 driver_data[0];
  569. };
  570. struct ib_uverbs_detach_mcast {
  571. __u8 gid[16];
  572. __u32 qp_handle;
  573. __u16 mlid;
  574. __u16 reserved;
  575. __u64 driver_data[0];
  576. };
  577. struct ib_uverbs_create_srq {
  578. __u64 response;
  579. __u64 user_handle;
  580. __u32 pd_handle;
  581. __u32 max_wr;
  582. __u32 max_sge;
  583. __u32 srq_limit;
  584. __u64 driver_data[0];
  585. };
  586. struct ib_uverbs_create_srq_resp {
  587. __u32 srq_handle;
  588. __u32 max_wr;
  589. __u32 max_sge;
  590. __u32 reserved;
  591. };
  592. struct ib_uverbs_modify_srq {
  593. __u32 srq_handle;
  594. __u32 attr_mask;
  595. __u32 max_wr;
  596. __u32 srq_limit;
  597. __u64 driver_data[0];
  598. };
  599. struct ib_uverbs_query_srq {
  600. __u64 response;
  601. __u32 srq_handle;
  602. __u32 reserved;
  603. __u64 driver_data[0];
  604. };
  605. struct ib_uverbs_query_srq_resp {
  606. __u32 max_wr;
  607. __u32 max_sge;
  608. __u32 srq_limit;
  609. __u32 reserved;
  610. };
  611. struct ib_uverbs_destroy_srq {
  612. __u64 response;
  613. __u32 srq_handle;
  614. __u32 reserved;
  615. };
  616. struct ib_uverbs_destroy_srq_resp {
  617. __u32 events_reported;
  618. };
  619. #endif /* IB_USER_VERBS_H */