ib_user_verbs.h 11 KB

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