ib_user_verbs.h 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293
  1. /* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR Linux-OpenIB) */
  2. /*
  3. * Copyright (c) 2005 Topspin Communications. All rights reserved.
  4. * Copyright (c) 2005, 2006 Cisco Systems. All rights reserved.
  5. * Copyright (c) 2005 PathScale, Inc. All rights reserved.
  6. * Copyright (c) 2006 Mellanox Technologies. All rights reserved.
  7. *
  8. * This software is available to you under a choice of one of two
  9. * licenses. You may choose to be licensed under the terms of the GNU
  10. * General Public License (GPL) Version 2, available from the file
  11. * COPYING in the main directory of this source tree, or the
  12. * OpenIB.org BSD license below:
  13. *
  14. * Redistribution and use in source and binary forms, with or
  15. * without modification, are permitted provided that the following
  16. * conditions are met:
  17. *
  18. * - Redistributions of source code must retain the above
  19. * copyright notice, this list of conditions and the following
  20. * disclaimer.
  21. *
  22. * - Redistributions in binary form must reproduce the above
  23. * copyright notice, this list of conditions and the following
  24. * disclaimer in the documentation and/or other materials
  25. * provided with the distribution.
  26. *
  27. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  28. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  29. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  30. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  31. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  32. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  33. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  34. * SOFTWARE.
  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 6
  44. #define IB_USER_VERBS_CMD_THRESHOLD 50
  45. enum {
  46. IB_USER_VERBS_CMD_GET_CONTEXT,
  47. IB_USER_VERBS_CMD_QUERY_DEVICE,
  48. IB_USER_VERBS_CMD_QUERY_PORT,
  49. IB_USER_VERBS_CMD_ALLOC_PD,
  50. IB_USER_VERBS_CMD_DEALLOC_PD,
  51. IB_USER_VERBS_CMD_CREATE_AH,
  52. IB_USER_VERBS_CMD_MODIFY_AH,
  53. IB_USER_VERBS_CMD_QUERY_AH,
  54. IB_USER_VERBS_CMD_DESTROY_AH,
  55. IB_USER_VERBS_CMD_REG_MR,
  56. IB_USER_VERBS_CMD_REG_SMR,
  57. IB_USER_VERBS_CMD_REREG_MR,
  58. IB_USER_VERBS_CMD_QUERY_MR,
  59. IB_USER_VERBS_CMD_DEREG_MR,
  60. IB_USER_VERBS_CMD_ALLOC_MW,
  61. IB_USER_VERBS_CMD_BIND_MW,
  62. IB_USER_VERBS_CMD_DEALLOC_MW,
  63. IB_USER_VERBS_CMD_CREATE_COMP_CHANNEL,
  64. IB_USER_VERBS_CMD_CREATE_CQ,
  65. IB_USER_VERBS_CMD_RESIZE_CQ,
  66. IB_USER_VERBS_CMD_DESTROY_CQ,
  67. IB_USER_VERBS_CMD_POLL_CQ,
  68. IB_USER_VERBS_CMD_PEEK_CQ,
  69. IB_USER_VERBS_CMD_REQ_NOTIFY_CQ,
  70. IB_USER_VERBS_CMD_CREATE_QP,
  71. IB_USER_VERBS_CMD_QUERY_QP,
  72. IB_USER_VERBS_CMD_MODIFY_QP,
  73. IB_USER_VERBS_CMD_DESTROY_QP,
  74. IB_USER_VERBS_CMD_POST_SEND,
  75. IB_USER_VERBS_CMD_POST_RECV,
  76. IB_USER_VERBS_CMD_ATTACH_MCAST,
  77. IB_USER_VERBS_CMD_DETACH_MCAST,
  78. IB_USER_VERBS_CMD_CREATE_SRQ,
  79. IB_USER_VERBS_CMD_MODIFY_SRQ,
  80. IB_USER_VERBS_CMD_QUERY_SRQ,
  81. IB_USER_VERBS_CMD_DESTROY_SRQ,
  82. IB_USER_VERBS_CMD_POST_SRQ_RECV,
  83. IB_USER_VERBS_CMD_OPEN_XRCD,
  84. IB_USER_VERBS_CMD_CLOSE_XRCD,
  85. IB_USER_VERBS_CMD_CREATE_XSRQ,
  86. IB_USER_VERBS_CMD_OPEN_QP,
  87. };
  88. enum {
  89. IB_USER_VERBS_EX_CMD_QUERY_DEVICE = IB_USER_VERBS_CMD_QUERY_DEVICE,
  90. IB_USER_VERBS_EX_CMD_CREATE_CQ = IB_USER_VERBS_CMD_CREATE_CQ,
  91. IB_USER_VERBS_EX_CMD_CREATE_QP = IB_USER_VERBS_CMD_CREATE_QP,
  92. IB_USER_VERBS_EX_CMD_MODIFY_QP = IB_USER_VERBS_CMD_MODIFY_QP,
  93. IB_USER_VERBS_EX_CMD_CREATE_FLOW = IB_USER_VERBS_CMD_THRESHOLD,
  94. IB_USER_VERBS_EX_CMD_DESTROY_FLOW,
  95. IB_USER_VERBS_EX_CMD_CREATE_WQ,
  96. IB_USER_VERBS_EX_CMD_MODIFY_WQ,
  97. IB_USER_VERBS_EX_CMD_DESTROY_WQ,
  98. IB_USER_VERBS_EX_CMD_CREATE_RWQ_IND_TBL,
  99. IB_USER_VERBS_EX_CMD_DESTROY_RWQ_IND_TBL,
  100. IB_USER_VERBS_EX_CMD_MODIFY_CQ
  101. };
  102. /*
  103. * Make sure that all structs defined in this file remain laid out so
  104. * that they pack the same way on 32-bit and 64-bit architectures (to
  105. * avoid incompatibility between 32-bit userspace and 64-bit kernels).
  106. * Specifically:
  107. * - Do not use pointer types -- pass pointers in __u64 instead.
  108. * - Make sure that any structure larger than 4 bytes is padded to a
  109. * multiple of 8 bytes. Otherwise the structure size will be
  110. * different between 32-bit and 64-bit architectures.
  111. */
  112. struct ib_uverbs_async_event_desc {
  113. __aligned_u64 element;
  114. __u32 event_type; /* enum ib_event_type */
  115. __u32 reserved;
  116. };
  117. struct ib_uverbs_comp_event_desc {
  118. __aligned_u64 cq_handle;
  119. };
  120. struct ib_uverbs_cq_moderation_caps {
  121. __u16 max_cq_moderation_count;
  122. __u16 max_cq_moderation_period;
  123. __u32 reserved;
  124. };
  125. /*
  126. * All commands from userspace should start with a __u32 command field
  127. * followed by __u16 in_words and out_words fields (which give the
  128. * length of the command block and response buffer if any in 32-bit
  129. * words). The kernel driver will read these fields first and read
  130. * the rest of the command struct based on these value.
  131. */
  132. #define IB_USER_VERBS_CMD_COMMAND_MASK 0xff
  133. #define IB_USER_VERBS_CMD_FLAG_EXTENDED 0x80000000u
  134. struct ib_uverbs_cmd_hdr {
  135. __u32 command;
  136. __u16 in_words;
  137. __u16 out_words;
  138. };
  139. struct ib_uverbs_ex_cmd_hdr {
  140. __aligned_u64 response;
  141. __u16 provider_in_words;
  142. __u16 provider_out_words;
  143. __u32 cmd_hdr_reserved;
  144. };
  145. struct ib_uverbs_get_context {
  146. __aligned_u64 response;
  147. __aligned_u64 driver_data[0];
  148. };
  149. struct ib_uverbs_get_context_resp {
  150. __u32 async_fd;
  151. __u32 num_comp_vectors;
  152. };
  153. struct ib_uverbs_query_device {
  154. __aligned_u64 response;
  155. __aligned_u64 driver_data[0];
  156. };
  157. struct ib_uverbs_query_device_resp {
  158. __aligned_u64 fw_ver;
  159. __be64 node_guid;
  160. __be64 sys_image_guid;
  161. __aligned_u64 max_mr_size;
  162. __aligned_u64 page_size_cap;
  163. __u32 vendor_id;
  164. __u32 vendor_part_id;
  165. __u32 hw_ver;
  166. __u32 max_qp;
  167. __u32 max_qp_wr;
  168. __u32 device_cap_flags;
  169. __u32 max_sge;
  170. __u32 max_sge_rd;
  171. __u32 max_cq;
  172. __u32 max_cqe;
  173. __u32 max_mr;
  174. __u32 max_pd;
  175. __u32 max_qp_rd_atom;
  176. __u32 max_ee_rd_atom;
  177. __u32 max_res_rd_atom;
  178. __u32 max_qp_init_rd_atom;
  179. __u32 max_ee_init_rd_atom;
  180. __u32 atomic_cap;
  181. __u32 max_ee;
  182. __u32 max_rdd;
  183. __u32 max_mw;
  184. __u32 max_raw_ipv6_qp;
  185. __u32 max_raw_ethy_qp;
  186. __u32 max_mcast_grp;
  187. __u32 max_mcast_qp_attach;
  188. __u32 max_total_mcast_qp_attach;
  189. __u32 max_ah;
  190. __u32 max_fmr;
  191. __u32 max_map_per_fmr;
  192. __u32 max_srq;
  193. __u32 max_srq_wr;
  194. __u32 max_srq_sge;
  195. __u16 max_pkeys;
  196. __u8 local_ca_ack_delay;
  197. __u8 phys_port_cnt;
  198. __u8 reserved[4];
  199. };
  200. struct ib_uverbs_ex_query_device {
  201. __u32 comp_mask;
  202. __u32 reserved;
  203. };
  204. struct ib_uverbs_odp_caps {
  205. __aligned_u64 general_caps;
  206. struct {
  207. __u32 rc_odp_caps;
  208. __u32 uc_odp_caps;
  209. __u32 ud_odp_caps;
  210. } per_transport_caps;
  211. __u32 reserved;
  212. };
  213. struct ib_uverbs_rss_caps {
  214. /* Corresponding bit will be set if qp type from
  215. * 'enum ib_qp_type' is supported, e.g.
  216. * supported_qpts |= 1 << IB_QPT_UD
  217. */
  218. __u32 supported_qpts;
  219. __u32 max_rwq_indirection_tables;
  220. __u32 max_rwq_indirection_table_size;
  221. __u32 reserved;
  222. };
  223. struct ib_uverbs_tm_caps {
  224. /* Max size of rendezvous request message */
  225. __u32 max_rndv_hdr_size;
  226. /* Max number of entries in tag matching list */
  227. __u32 max_num_tags;
  228. /* TM flags */
  229. __u32 flags;
  230. /* Max number of outstanding list operations */
  231. __u32 max_ops;
  232. /* Max number of SGE in tag matching entry */
  233. __u32 max_sge;
  234. __u32 reserved;
  235. };
  236. struct ib_uverbs_ex_query_device_resp {
  237. struct ib_uverbs_query_device_resp base;
  238. __u32 comp_mask;
  239. __u32 response_length;
  240. struct ib_uverbs_odp_caps odp_caps;
  241. __aligned_u64 timestamp_mask;
  242. __aligned_u64 hca_core_clock; /* in KHZ */
  243. __aligned_u64 device_cap_flags_ex;
  244. struct ib_uverbs_rss_caps rss_caps;
  245. __u32 max_wq_type_rq;
  246. __u32 raw_packet_caps;
  247. struct ib_uverbs_tm_caps tm_caps;
  248. struct ib_uverbs_cq_moderation_caps cq_moderation_caps;
  249. __aligned_u64 max_dm_size;
  250. };
  251. struct ib_uverbs_query_port {
  252. __aligned_u64 response;
  253. __u8 port_num;
  254. __u8 reserved[7];
  255. __aligned_u64 driver_data[0];
  256. };
  257. struct ib_uverbs_query_port_resp {
  258. __u32 port_cap_flags; /* see ib_uverbs_query_port_cap_flags */
  259. __u32 max_msg_sz;
  260. __u32 bad_pkey_cntr;
  261. __u32 qkey_viol_cntr;
  262. __u32 gid_tbl_len;
  263. __u16 pkey_tbl_len;
  264. __u16 lid;
  265. __u16 sm_lid;
  266. __u8 state;
  267. __u8 max_mtu;
  268. __u8 active_mtu;
  269. __u8 lmc;
  270. __u8 max_vl_num;
  271. __u8 sm_sl;
  272. __u8 subnet_timeout;
  273. __u8 init_type_reply;
  274. __u8 active_width;
  275. __u8 active_speed;
  276. __u8 phys_state;
  277. __u8 link_layer;
  278. __u8 flags; /* see ib_uverbs_query_port_flags */
  279. __u8 reserved;
  280. };
  281. struct ib_uverbs_alloc_pd {
  282. __aligned_u64 response;
  283. __aligned_u64 driver_data[0];
  284. };
  285. struct ib_uverbs_alloc_pd_resp {
  286. __u32 pd_handle;
  287. };
  288. struct ib_uverbs_dealloc_pd {
  289. __u32 pd_handle;
  290. };
  291. struct ib_uverbs_open_xrcd {
  292. __aligned_u64 response;
  293. __u32 fd;
  294. __u32 oflags;
  295. __aligned_u64 driver_data[0];
  296. };
  297. struct ib_uverbs_open_xrcd_resp {
  298. __u32 xrcd_handle;
  299. };
  300. struct ib_uverbs_close_xrcd {
  301. __u32 xrcd_handle;
  302. };
  303. struct ib_uverbs_reg_mr {
  304. __aligned_u64 response;
  305. __aligned_u64 start;
  306. __aligned_u64 length;
  307. __aligned_u64 hca_va;
  308. __u32 pd_handle;
  309. __u32 access_flags;
  310. __aligned_u64 driver_data[0];
  311. };
  312. struct ib_uverbs_reg_mr_resp {
  313. __u32 mr_handle;
  314. __u32 lkey;
  315. __u32 rkey;
  316. };
  317. struct ib_uverbs_rereg_mr {
  318. __aligned_u64 response;
  319. __u32 mr_handle;
  320. __u32 flags;
  321. __aligned_u64 start;
  322. __aligned_u64 length;
  323. __aligned_u64 hca_va;
  324. __u32 pd_handle;
  325. __u32 access_flags;
  326. };
  327. struct ib_uverbs_rereg_mr_resp {
  328. __u32 lkey;
  329. __u32 rkey;
  330. };
  331. struct ib_uverbs_dereg_mr {
  332. __u32 mr_handle;
  333. };
  334. struct ib_uverbs_alloc_mw {
  335. __aligned_u64 response;
  336. __u32 pd_handle;
  337. __u8 mw_type;
  338. __u8 reserved[3];
  339. };
  340. struct ib_uverbs_alloc_mw_resp {
  341. __u32 mw_handle;
  342. __u32 rkey;
  343. };
  344. struct ib_uverbs_dealloc_mw {
  345. __u32 mw_handle;
  346. };
  347. struct ib_uverbs_create_comp_channel {
  348. __aligned_u64 response;
  349. };
  350. struct ib_uverbs_create_comp_channel_resp {
  351. __u32 fd;
  352. };
  353. struct ib_uverbs_create_cq {
  354. __aligned_u64 response;
  355. __aligned_u64 user_handle;
  356. __u32 cqe;
  357. __u32 comp_vector;
  358. __s32 comp_channel;
  359. __u32 reserved;
  360. __aligned_u64 driver_data[0];
  361. };
  362. enum ib_uverbs_ex_create_cq_flags {
  363. IB_UVERBS_CQ_FLAGS_TIMESTAMP_COMPLETION = 1 << 0,
  364. IB_UVERBS_CQ_FLAGS_IGNORE_OVERRUN = 1 << 1,
  365. };
  366. struct ib_uverbs_ex_create_cq {
  367. __aligned_u64 user_handle;
  368. __u32 cqe;
  369. __u32 comp_vector;
  370. __s32 comp_channel;
  371. __u32 comp_mask;
  372. __u32 flags; /* bitmask of ib_uverbs_ex_create_cq_flags */
  373. __u32 reserved;
  374. };
  375. struct ib_uverbs_create_cq_resp {
  376. __u32 cq_handle;
  377. __u32 cqe;
  378. };
  379. struct ib_uverbs_ex_create_cq_resp {
  380. struct ib_uverbs_create_cq_resp base;
  381. __u32 comp_mask;
  382. __u32 response_length;
  383. };
  384. struct ib_uverbs_resize_cq {
  385. __aligned_u64 response;
  386. __u32 cq_handle;
  387. __u32 cqe;
  388. __aligned_u64 driver_data[0];
  389. };
  390. struct ib_uverbs_resize_cq_resp {
  391. __u32 cqe;
  392. __u32 reserved;
  393. __aligned_u64 driver_data[0];
  394. };
  395. struct ib_uverbs_poll_cq {
  396. __aligned_u64 response;
  397. __u32 cq_handle;
  398. __u32 ne;
  399. };
  400. struct ib_uverbs_wc {
  401. __aligned_u64 wr_id;
  402. __u32 status;
  403. __u32 opcode;
  404. __u32 vendor_err;
  405. __u32 byte_len;
  406. union {
  407. __be32 imm_data;
  408. __u32 invalidate_rkey;
  409. } ex;
  410. __u32 qp_num;
  411. __u32 src_qp;
  412. __u32 wc_flags;
  413. __u16 pkey_index;
  414. __u16 slid;
  415. __u8 sl;
  416. __u8 dlid_path_bits;
  417. __u8 port_num;
  418. __u8 reserved;
  419. };
  420. struct ib_uverbs_poll_cq_resp {
  421. __u32 count;
  422. __u32 reserved;
  423. struct ib_uverbs_wc wc[0];
  424. };
  425. struct ib_uverbs_req_notify_cq {
  426. __u32 cq_handle;
  427. __u32 solicited_only;
  428. };
  429. struct ib_uverbs_destroy_cq {
  430. __aligned_u64 response;
  431. __u32 cq_handle;
  432. __u32 reserved;
  433. };
  434. struct ib_uverbs_destroy_cq_resp {
  435. __u32 comp_events_reported;
  436. __u32 async_events_reported;
  437. };
  438. struct ib_uverbs_global_route {
  439. __u8 dgid[16];
  440. __u32 flow_label;
  441. __u8 sgid_index;
  442. __u8 hop_limit;
  443. __u8 traffic_class;
  444. __u8 reserved;
  445. };
  446. struct ib_uverbs_ah_attr {
  447. struct ib_uverbs_global_route grh;
  448. __u16 dlid;
  449. __u8 sl;
  450. __u8 src_path_bits;
  451. __u8 static_rate;
  452. __u8 is_global;
  453. __u8 port_num;
  454. __u8 reserved;
  455. };
  456. struct ib_uverbs_qp_attr {
  457. __u32 qp_attr_mask;
  458. __u32 qp_state;
  459. __u32 cur_qp_state;
  460. __u32 path_mtu;
  461. __u32 path_mig_state;
  462. __u32 qkey;
  463. __u32 rq_psn;
  464. __u32 sq_psn;
  465. __u32 dest_qp_num;
  466. __u32 qp_access_flags;
  467. struct ib_uverbs_ah_attr ah_attr;
  468. struct ib_uverbs_ah_attr alt_ah_attr;
  469. /* ib_qp_cap */
  470. __u32 max_send_wr;
  471. __u32 max_recv_wr;
  472. __u32 max_send_sge;
  473. __u32 max_recv_sge;
  474. __u32 max_inline_data;
  475. __u16 pkey_index;
  476. __u16 alt_pkey_index;
  477. __u8 en_sqd_async_notify;
  478. __u8 sq_draining;
  479. __u8 max_rd_atomic;
  480. __u8 max_dest_rd_atomic;
  481. __u8 min_rnr_timer;
  482. __u8 port_num;
  483. __u8 timeout;
  484. __u8 retry_cnt;
  485. __u8 rnr_retry;
  486. __u8 alt_port_num;
  487. __u8 alt_timeout;
  488. __u8 reserved[5];
  489. };
  490. struct ib_uverbs_create_qp {
  491. __aligned_u64 response;
  492. __aligned_u64 user_handle;
  493. __u32 pd_handle;
  494. __u32 send_cq_handle;
  495. __u32 recv_cq_handle;
  496. __u32 srq_handle;
  497. __u32 max_send_wr;
  498. __u32 max_recv_wr;
  499. __u32 max_send_sge;
  500. __u32 max_recv_sge;
  501. __u32 max_inline_data;
  502. __u8 sq_sig_all;
  503. __u8 qp_type;
  504. __u8 is_srq;
  505. __u8 reserved;
  506. __aligned_u64 driver_data[0];
  507. };
  508. enum ib_uverbs_create_qp_mask {
  509. IB_UVERBS_CREATE_QP_MASK_IND_TABLE = 1UL << 0,
  510. };
  511. enum {
  512. IB_UVERBS_CREATE_QP_SUP_COMP_MASK = IB_UVERBS_CREATE_QP_MASK_IND_TABLE,
  513. };
  514. enum {
  515. /*
  516. * This value is equal to IB_QP_DEST_QPN.
  517. */
  518. IB_USER_LEGACY_LAST_QP_ATTR_MASK = 1ULL << 20,
  519. };
  520. enum {
  521. /*
  522. * This value is equal to IB_QP_RATE_LIMIT.
  523. */
  524. IB_USER_LAST_QP_ATTR_MASK = 1ULL << 25,
  525. };
  526. struct ib_uverbs_ex_create_qp {
  527. __aligned_u64 user_handle;
  528. __u32 pd_handle;
  529. __u32 send_cq_handle;
  530. __u32 recv_cq_handle;
  531. __u32 srq_handle;
  532. __u32 max_send_wr;
  533. __u32 max_recv_wr;
  534. __u32 max_send_sge;
  535. __u32 max_recv_sge;
  536. __u32 max_inline_data;
  537. __u8 sq_sig_all;
  538. __u8 qp_type;
  539. __u8 is_srq;
  540. __u8 reserved;
  541. __u32 comp_mask;
  542. __u32 create_flags;
  543. __u32 rwq_ind_tbl_handle;
  544. __u32 source_qpn;
  545. };
  546. struct ib_uverbs_open_qp {
  547. __aligned_u64 response;
  548. __aligned_u64 user_handle;
  549. __u32 pd_handle;
  550. __u32 qpn;
  551. __u8 qp_type;
  552. __u8 reserved[7];
  553. __aligned_u64 driver_data[0];
  554. };
  555. /* also used for open response */
  556. struct ib_uverbs_create_qp_resp {
  557. __u32 qp_handle;
  558. __u32 qpn;
  559. __u32 max_send_wr;
  560. __u32 max_recv_wr;
  561. __u32 max_send_sge;
  562. __u32 max_recv_sge;
  563. __u32 max_inline_data;
  564. __u32 reserved;
  565. };
  566. struct ib_uverbs_ex_create_qp_resp {
  567. struct ib_uverbs_create_qp_resp base;
  568. __u32 comp_mask;
  569. __u32 response_length;
  570. };
  571. /*
  572. * This struct needs to remain a multiple of 8 bytes to keep the
  573. * alignment of the modify QP parameters.
  574. */
  575. struct ib_uverbs_qp_dest {
  576. __u8 dgid[16];
  577. __u32 flow_label;
  578. __u16 dlid;
  579. __u16 reserved;
  580. __u8 sgid_index;
  581. __u8 hop_limit;
  582. __u8 traffic_class;
  583. __u8 sl;
  584. __u8 src_path_bits;
  585. __u8 static_rate;
  586. __u8 is_global;
  587. __u8 port_num;
  588. };
  589. struct ib_uverbs_query_qp {
  590. __aligned_u64 response;
  591. __u32 qp_handle;
  592. __u32 attr_mask;
  593. __aligned_u64 driver_data[0];
  594. };
  595. struct ib_uverbs_query_qp_resp {
  596. struct ib_uverbs_qp_dest dest;
  597. struct ib_uverbs_qp_dest alt_dest;
  598. __u32 max_send_wr;
  599. __u32 max_recv_wr;
  600. __u32 max_send_sge;
  601. __u32 max_recv_sge;
  602. __u32 max_inline_data;
  603. __u32 qkey;
  604. __u32 rq_psn;
  605. __u32 sq_psn;
  606. __u32 dest_qp_num;
  607. __u32 qp_access_flags;
  608. __u16 pkey_index;
  609. __u16 alt_pkey_index;
  610. __u8 qp_state;
  611. __u8 cur_qp_state;
  612. __u8 path_mtu;
  613. __u8 path_mig_state;
  614. __u8 sq_draining;
  615. __u8 max_rd_atomic;
  616. __u8 max_dest_rd_atomic;
  617. __u8 min_rnr_timer;
  618. __u8 port_num;
  619. __u8 timeout;
  620. __u8 retry_cnt;
  621. __u8 rnr_retry;
  622. __u8 alt_port_num;
  623. __u8 alt_timeout;
  624. __u8 sq_sig_all;
  625. __u8 reserved[5];
  626. __aligned_u64 driver_data[0];
  627. };
  628. struct ib_uverbs_modify_qp {
  629. struct ib_uverbs_qp_dest dest;
  630. struct ib_uverbs_qp_dest alt_dest;
  631. __u32 qp_handle;
  632. __u32 attr_mask;
  633. __u32 qkey;
  634. __u32 rq_psn;
  635. __u32 sq_psn;
  636. __u32 dest_qp_num;
  637. __u32 qp_access_flags;
  638. __u16 pkey_index;
  639. __u16 alt_pkey_index;
  640. __u8 qp_state;
  641. __u8 cur_qp_state;
  642. __u8 path_mtu;
  643. __u8 path_mig_state;
  644. __u8 en_sqd_async_notify;
  645. __u8 max_rd_atomic;
  646. __u8 max_dest_rd_atomic;
  647. __u8 min_rnr_timer;
  648. __u8 port_num;
  649. __u8 timeout;
  650. __u8 retry_cnt;
  651. __u8 rnr_retry;
  652. __u8 alt_port_num;
  653. __u8 alt_timeout;
  654. __u8 reserved[2];
  655. __aligned_u64 driver_data[0];
  656. };
  657. struct ib_uverbs_ex_modify_qp {
  658. struct ib_uverbs_modify_qp base;
  659. __u32 rate_limit;
  660. __u32 reserved;
  661. };
  662. struct ib_uverbs_modify_qp_resp {
  663. };
  664. struct ib_uverbs_ex_modify_qp_resp {
  665. __u32 comp_mask;
  666. __u32 response_length;
  667. };
  668. struct ib_uverbs_destroy_qp {
  669. __aligned_u64 response;
  670. __u32 qp_handle;
  671. __u32 reserved;
  672. };
  673. struct ib_uverbs_destroy_qp_resp {
  674. __u32 events_reported;
  675. };
  676. /*
  677. * The ib_uverbs_sge structure isn't used anywhere, since we assume
  678. * the ib_sge structure is packed the same way on 32-bit and 64-bit
  679. * architectures in both kernel and user space. It's just here to
  680. * document the ABI.
  681. */
  682. struct ib_uverbs_sge {
  683. __aligned_u64 addr;
  684. __u32 length;
  685. __u32 lkey;
  686. };
  687. enum ib_uverbs_wr_opcode {
  688. IB_UVERBS_WR_RDMA_WRITE = 0,
  689. IB_UVERBS_WR_RDMA_WRITE_WITH_IMM = 1,
  690. IB_UVERBS_WR_SEND = 2,
  691. IB_UVERBS_WR_SEND_WITH_IMM = 3,
  692. IB_UVERBS_WR_RDMA_READ = 4,
  693. IB_UVERBS_WR_ATOMIC_CMP_AND_SWP = 5,
  694. IB_UVERBS_WR_ATOMIC_FETCH_AND_ADD = 6,
  695. IB_UVERBS_WR_LOCAL_INV = 7,
  696. IB_UVERBS_WR_BIND_MW = 8,
  697. IB_UVERBS_WR_SEND_WITH_INV = 9,
  698. IB_UVERBS_WR_TSO = 10,
  699. IB_UVERBS_WR_RDMA_READ_WITH_INV = 11,
  700. IB_UVERBS_WR_MASKED_ATOMIC_CMP_AND_SWP = 12,
  701. IB_UVERBS_WR_MASKED_ATOMIC_FETCH_AND_ADD = 13,
  702. /* Review enum ib_wr_opcode before modifying this */
  703. };
  704. struct ib_uverbs_send_wr {
  705. __aligned_u64 wr_id;
  706. __u32 num_sge;
  707. __u32 opcode; /* see enum ib_uverbs_wr_opcode */
  708. __u32 send_flags;
  709. union {
  710. __be32 imm_data;
  711. __u32 invalidate_rkey;
  712. } ex;
  713. union {
  714. struct {
  715. __aligned_u64 remote_addr;
  716. __u32 rkey;
  717. __u32 reserved;
  718. } rdma;
  719. struct {
  720. __aligned_u64 remote_addr;
  721. __aligned_u64 compare_add;
  722. __aligned_u64 swap;
  723. __u32 rkey;
  724. __u32 reserved;
  725. } atomic;
  726. struct {
  727. __u32 ah;
  728. __u32 remote_qpn;
  729. __u32 remote_qkey;
  730. __u32 reserved;
  731. } ud;
  732. } wr;
  733. };
  734. struct ib_uverbs_post_send {
  735. __aligned_u64 response;
  736. __u32 qp_handle;
  737. __u32 wr_count;
  738. __u32 sge_count;
  739. __u32 wqe_size;
  740. struct ib_uverbs_send_wr send_wr[0];
  741. };
  742. struct ib_uverbs_post_send_resp {
  743. __u32 bad_wr;
  744. };
  745. struct ib_uverbs_recv_wr {
  746. __aligned_u64 wr_id;
  747. __u32 num_sge;
  748. __u32 reserved;
  749. };
  750. struct ib_uverbs_post_recv {
  751. __aligned_u64 response;
  752. __u32 qp_handle;
  753. __u32 wr_count;
  754. __u32 sge_count;
  755. __u32 wqe_size;
  756. struct ib_uverbs_recv_wr recv_wr[0];
  757. };
  758. struct ib_uverbs_post_recv_resp {
  759. __u32 bad_wr;
  760. };
  761. struct ib_uverbs_post_srq_recv {
  762. __aligned_u64 response;
  763. __u32 srq_handle;
  764. __u32 wr_count;
  765. __u32 sge_count;
  766. __u32 wqe_size;
  767. struct ib_uverbs_recv_wr recv[0];
  768. };
  769. struct ib_uverbs_post_srq_recv_resp {
  770. __u32 bad_wr;
  771. };
  772. struct ib_uverbs_create_ah {
  773. __aligned_u64 response;
  774. __aligned_u64 user_handle;
  775. __u32 pd_handle;
  776. __u32 reserved;
  777. struct ib_uverbs_ah_attr attr;
  778. };
  779. struct ib_uverbs_create_ah_resp {
  780. __u32 ah_handle;
  781. };
  782. struct ib_uverbs_destroy_ah {
  783. __u32 ah_handle;
  784. };
  785. struct ib_uverbs_attach_mcast {
  786. __u8 gid[16];
  787. __u32 qp_handle;
  788. __u16 mlid;
  789. __u16 reserved;
  790. __aligned_u64 driver_data[0];
  791. };
  792. struct ib_uverbs_detach_mcast {
  793. __u8 gid[16];
  794. __u32 qp_handle;
  795. __u16 mlid;
  796. __u16 reserved;
  797. __aligned_u64 driver_data[0];
  798. };
  799. struct ib_uverbs_flow_spec_hdr {
  800. __u32 type;
  801. __u16 size;
  802. __u16 reserved;
  803. /* followed by flow_spec */
  804. __aligned_u64 flow_spec_data[0];
  805. };
  806. struct ib_uverbs_flow_eth_filter {
  807. __u8 dst_mac[6];
  808. __u8 src_mac[6];
  809. __be16 ether_type;
  810. __be16 vlan_tag;
  811. };
  812. struct ib_uverbs_flow_spec_eth {
  813. union {
  814. struct ib_uverbs_flow_spec_hdr hdr;
  815. struct {
  816. __u32 type;
  817. __u16 size;
  818. __u16 reserved;
  819. };
  820. };
  821. struct ib_uverbs_flow_eth_filter val;
  822. struct ib_uverbs_flow_eth_filter mask;
  823. };
  824. struct ib_uverbs_flow_ipv4_filter {
  825. __be32 src_ip;
  826. __be32 dst_ip;
  827. __u8 proto;
  828. __u8 tos;
  829. __u8 ttl;
  830. __u8 flags;
  831. };
  832. struct ib_uverbs_flow_spec_ipv4 {
  833. union {
  834. struct ib_uverbs_flow_spec_hdr hdr;
  835. struct {
  836. __u32 type;
  837. __u16 size;
  838. __u16 reserved;
  839. };
  840. };
  841. struct ib_uverbs_flow_ipv4_filter val;
  842. struct ib_uverbs_flow_ipv4_filter mask;
  843. };
  844. struct ib_uverbs_flow_tcp_udp_filter {
  845. __be16 dst_port;
  846. __be16 src_port;
  847. };
  848. struct ib_uverbs_flow_spec_tcp_udp {
  849. union {
  850. struct ib_uverbs_flow_spec_hdr hdr;
  851. struct {
  852. __u32 type;
  853. __u16 size;
  854. __u16 reserved;
  855. };
  856. };
  857. struct ib_uverbs_flow_tcp_udp_filter val;
  858. struct ib_uverbs_flow_tcp_udp_filter mask;
  859. };
  860. struct ib_uverbs_flow_ipv6_filter {
  861. __u8 src_ip[16];
  862. __u8 dst_ip[16];
  863. __be32 flow_label;
  864. __u8 next_hdr;
  865. __u8 traffic_class;
  866. __u8 hop_limit;
  867. __u8 reserved;
  868. };
  869. struct ib_uverbs_flow_spec_ipv6 {
  870. union {
  871. struct ib_uverbs_flow_spec_hdr hdr;
  872. struct {
  873. __u32 type;
  874. __u16 size;
  875. __u16 reserved;
  876. };
  877. };
  878. struct ib_uverbs_flow_ipv6_filter val;
  879. struct ib_uverbs_flow_ipv6_filter mask;
  880. };
  881. struct ib_uverbs_flow_spec_action_tag {
  882. union {
  883. struct ib_uverbs_flow_spec_hdr hdr;
  884. struct {
  885. __u32 type;
  886. __u16 size;
  887. __u16 reserved;
  888. };
  889. };
  890. __u32 tag_id;
  891. __u32 reserved1;
  892. };
  893. struct ib_uverbs_flow_spec_action_drop {
  894. union {
  895. struct ib_uverbs_flow_spec_hdr hdr;
  896. struct {
  897. __u32 type;
  898. __u16 size;
  899. __u16 reserved;
  900. };
  901. };
  902. };
  903. struct ib_uverbs_flow_spec_action_handle {
  904. union {
  905. struct ib_uverbs_flow_spec_hdr hdr;
  906. struct {
  907. __u32 type;
  908. __u16 size;
  909. __u16 reserved;
  910. };
  911. };
  912. __u32 handle;
  913. __u32 reserved1;
  914. };
  915. struct ib_uverbs_flow_spec_action_count {
  916. union {
  917. struct ib_uverbs_flow_spec_hdr hdr;
  918. struct {
  919. __u32 type;
  920. __u16 size;
  921. __u16 reserved;
  922. };
  923. };
  924. __u32 handle;
  925. __u32 reserved1;
  926. };
  927. struct ib_uverbs_flow_tunnel_filter {
  928. __be32 tunnel_id;
  929. };
  930. struct ib_uverbs_flow_spec_tunnel {
  931. union {
  932. struct ib_uverbs_flow_spec_hdr hdr;
  933. struct {
  934. __u32 type;
  935. __u16 size;
  936. __u16 reserved;
  937. };
  938. };
  939. struct ib_uverbs_flow_tunnel_filter val;
  940. struct ib_uverbs_flow_tunnel_filter mask;
  941. };
  942. struct ib_uverbs_flow_spec_esp_filter {
  943. __u32 spi;
  944. __u32 seq;
  945. };
  946. struct ib_uverbs_flow_spec_esp {
  947. union {
  948. struct ib_uverbs_flow_spec_hdr hdr;
  949. struct {
  950. __u32 type;
  951. __u16 size;
  952. __u16 reserved;
  953. };
  954. };
  955. struct ib_uverbs_flow_spec_esp_filter val;
  956. struct ib_uverbs_flow_spec_esp_filter mask;
  957. };
  958. struct ib_uverbs_flow_gre_filter {
  959. /* c_ks_res0_ver field is bits 0-15 in offset 0 of a standard GRE header:
  960. * bit 0 - C - checksum bit.
  961. * bit 1 - reserved. set to 0.
  962. * bit 2 - key bit.
  963. * bit 3 - sequence number bit.
  964. * bits 4:12 - reserved. set to 0.
  965. * bits 13:15 - GRE version.
  966. */
  967. __be16 c_ks_res0_ver;
  968. __be16 protocol;
  969. __be32 key;
  970. };
  971. struct ib_uverbs_flow_spec_gre {
  972. union {
  973. struct ib_uverbs_flow_spec_hdr hdr;
  974. struct {
  975. __u32 type;
  976. __u16 size;
  977. __u16 reserved;
  978. };
  979. };
  980. struct ib_uverbs_flow_gre_filter val;
  981. struct ib_uverbs_flow_gre_filter mask;
  982. };
  983. struct ib_uverbs_flow_mpls_filter {
  984. /* The field includes the entire MPLS label:
  985. * bits 0:19 - label field.
  986. * bits 20:22 - traffic class field.
  987. * bits 23 - bottom of stack bit.
  988. * bits 24:31 - ttl field.
  989. */
  990. __be32 label;
  991. };
  992. struct ib_uverbs_flow_spec_mpls {
  993. union {
  994. struct ib_uverbs_flow_spec_hdr hdr;
  995. struct {
  996. __u32 type;
  997. __u16 size;
  998. __u16 reserved;
  999. };
  1000. };
  1001. struct ib_uverbs_flow_mpls_filter val;
  1002. struct ib_uverbs_flow_mpls_filter mask;
  1003. };
  1004. struct ib_uverbs_flow_attr {
  1005. __u32 type;
  1006. __u16 size;
  1007. __u16 priority;
  1008. __u8 num_of_specs;
  1009. __u8 reserved[2];
  1010. __u8 port;
  1011. __u32 flags;
  1012. /* Following are the optional layers according to user request
  1013. * struct ib_flow_spec_xxx
  1014. * struct ib_flow_spec_yyy
  1015. */
  1016. struct ib_uverbs_flow_spec_hdr flow_specs[0];
  1017. };
  1018. struct ib_uverbs_create_flow {
  1019. __u32 comp_mask;
  1020. __u32 qp_handle;
  1021. struct ib_uverbs_flow_attr flow_attr;
  1022. };
  1023. struct ib_uverbs_create_flow_resp {
  1024. __u32 comp_mask;
  1025. __u32 flow_handle;
  1026. };
  1027. struct ib_uverbs_destroy_flow {
  1028. __u32 comp_mask;
  1029. __u32 flow_handle;
  1030. };
  1031. struct ib_uverbs_create_srq {
  1032. __aligned_u64 response;
  1033. __aligned_u64 user_handle;
  1034. __u32 pd_handle;
  1035. __u32 max_wr;
  1036. __u32 max_sge;
  1037. __u32 srq_limit;
  1038. __aligned_u64 driver_data[0];
  1039. };
  1040. struct ib_uverbs_create_xsrq {
  1041. __aligned_u64 response;
  1042. __aligned_u64 user_handle;
  1043. __u32 srq_type;
  1044. __u32 pd_handle;
  1045. __u32 max_wr;
  1046. __u32 max_sge;
  1047. __u32 srq_limit;
  1048. __u32 max_num_tags;
  1049. __u32 xrcd_handle;
  1050. __u32 cq_handle;
  1051. __aligned_u64 driver_data[0];
  1052. };
  1053. struct ib_uverbs_create_srq_resp {
  1054. __u32 srq_handle;
  1055. __u32 max_wr;
  1056. __u32 max_sge;
  1057. __u32 srqn;
  1058. };
  1059. struct ib_uverbs_modify_srq {
  1060. __u32 srq_handle;
  1061. __u32 attr_mask;
  1062. __u32 max_wr;
  1063. __u32 srq_limit;
  1064. __aligned_u64 driver_data[0];
  1065. };
  1066. struct ib_uverbs_query_srq {
  1067. __aligned_u64 response;
  1068. __u32 srq_handle;
  1069. __u32 reserved;
  1070. __aligned_u64 driver_data[0];
  1071. };
  1072. struct ib_uverbs_query_srq_resp {
  1073. __u32 max_wr;
  1074. __u32 max_sge;
  1075. __u32 srq_limit;
  1076. __u32 reserved;
  1077. };
  1078. struct ib_uverbs_destroy_srq {
  1079. __aligned_u64 response;
  1080. __u32 srq_handle;
  1081. __u32 reserved;
  1082. };
  1083. struct ib_uverbs_destroy_srq_resp {
  1084. __u32 events_reported;
  1085. };
  1086. struct ib_uverbs_ex_create_wq {
  1087. __u32 comp_mask;
  1088. __u32 wq_type;
  1089. __aligned_u64 user_handle;
  1090. __u32 pd_handle;
  1091. __u32 cq_handle;
  1092. __u32 max_wr;
  1093. __u32 max_sge;
  1094. __u32 create_flags; /* Use enum ib_wq_flags */
  1095. __u32 reserved;
  1096. };
  1097. struct ib_uverbs_ex_create_wq_resp {
  1098. __u32 comp_mask;
  1099. __u32 response_length;
  1100. __u32 wq_handle;
  1101. __u32 max_wr;
  1102. __u32 max_sge;
  1103. __u32 wqn;
  1104. };
  1105. struct ib_uverbs_ex_destroy_wq {
  1106. __u32 comp_mask;
  1107. __u32 wq_handle;
  1108. };
  1109. struct ib_uverbs_ex_destroy_wq_resp {
  1110. __u32 comp_mask;
  1111. __u32 response_length;
  1112. __u32 events_reported;
  1113. __u32 reserved;
  1114. };
  1115. struct ib_uverbs_ex_modify_wq {
  1116. __u32 attr_mask;
  1117. __u32 wq_handle;
  1118. __u32 wq_state;
  1119. __u32 curr_wq_state;
  1120. __u32 flags; /* Use enum ib_wq_flags */
  1121. __u32 flags_mask; /* Use enum ib_wq_flags */
  1122. };
  1123. /* Prevent memory allocation rather than max expected size */
  1124. #define IB_USER_VERBS_MAX_LOG_IND_TBL_SIZE 0x0d
  1125. struct ib_uverbs_ex_create_rwq_ind_table {
  1126. __u32 comp_mask;
  1127. __u32 log_ind_tbl_size;
  1128. /* Following are the wq handles according to log_ind_tbl_size
  1129. * wq_handle1
  1130. * wq_handle2
  1131. */
  1132. __u32 wq_handles[0];
  1133. };
  1134. struct ib_uverbs_ex_create_rwq_ind_table_resp {
  1135. __u32 comp_mask;
  1136. __u32 response_length;
  1137. __u32 ind_tbl_handle;
  1138. __u32 ind_tbl_num;
  1139. };
  1140. struct ib_uverbs_ex_destroy_rwq_ind_table {
  1141. __u32 comp_mask;
  1142. __u32 ind_tbl_handle;
  1143. };
  1144. struct ib_uverbs_cq_moderation {
  1145. __u16 cq_count;
  1146. __u16 cq_period;
  1147. };
  1148. struct ib_uverbs_ex_modify_cq {
  1149. __u32 cq_handle;
  1150. __u32 attr_mask;
  1151. struct ib_uverbs_cq_moderation attr;
  1152. __u32 reserved;
  1153. };
  1154. #define IB_DEVICE_NAME_MAX 64
  1155. #endif /* IB_USER_VERBS_H */