ib_user_verbs.h 26 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304
  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 ib_uverbs_write_cmds {
  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. __aligned_u64 driver_data[0];
  153. };
  154. struct ib_uverbs_query_device {
  155. __aligned_u64 response;
  156. __aligned_u64 driver_data[0];
  157. };
  158. struct ib_uverbs_query_device_resp {
  159. __aligned_u64 fw_ver;
  160. __be64 node_guid;
  161. __be64 sys_image_guid;
  162. __aligned_u64 max_mr_size;
  163. __aligned_u64 page_size_cap;
  164. __u32 vendor_id;
  165. __u32 vendor_part_id;
  166. __u32 hw_ver;
  167. __u32 max_qp;
  168. __u32 max_qp_wr;
  169. __u32 device_cap_flags;
  170. __u32 max_sge;
  171. __u32 max_sge_rd;
  172. __u32 max_cq;
  173. __u32 max_cqe;
  174. __u32 max_mr;
  175. __u32 max_pd;
  176. __u32 max_qp_rd_atom;
  177. __u32 max_ee_rd_atom;
  178. __u32 max_res_rd_atom;
  179. __u32 max_qp_init_rd_atom;
  180. __u32 max_ee_init_rd_atom;
  181. __u32 atomic_cap;
  182. __u32 max_ee;
  183. __u32 max_rdd;
  184. __u32 max_mw;
  185. __u32 max_raw_ipv6_qp;
  186. __u32 max_raw_ethy_qp;
  187. __u32 max_mcast_grp;
  188. __u32 max_mcast_qp_attach;
  189. __u32 max_total_mcast_qp_attach;
  190. __u32 max_ah;
  191. __u32 max_fmr;
  192. __u32 max_map_per_fmr;
  193. __u32 max_srq;
  194. __u32 max_srq_wr;
  195. __u32 max_srq_sge;
  196. __u16 max_pkeys;
  197. __u8 local_ca_ack_delay;
  198. __u8 phys_port_cnt;
  199. __u8 reserved[4];
  200. };
  201. struct ib_uverbs_ex_query_device {
  202. __u32 comp_mask;
  203. __u32 reserved;
  204. };
  205. struct ib_uverbs_odp_caps {
  206. __aligned_u64 general_caps;
  207. struct {
  208. __u32 rc_odp_caps;
  209. __u32 uc_odp_caps;
  210. __u32 ud_odp_caps;
  211. } per_transport_caps;
  212. __u32 reserved;
  213. };
  214. struct ib_uverbs_rss_caps {
  215. /* Corresponding bit will be set if qp type from
  216. * 'enum ib_qp_type' is supported, e.g.
  217. * supported_qpts |= 1 << IB_QPT_UD
  218. */
  219. __u32 supported_qpts;
  220. __u32 max_rwq_indirection_tables;
  221. __u32 max_rwq_indirection_table_size;
  222. __u32 reserved;
  223. };
  224. struct ib_uverbs_tm_caps {
  225. /* Max size of rendezvous request message */
  226. __u32 max_rndv_hdr_size;
  227. /* Max number of entries in tag matching list */
  228. __u32 max_num_tags;
  229. /* TM flags */
  230. __u32 flags;
  231. /* Max number of outstanding list operations */
  232. __u32 max_ops;
  233. /* Max number of SGE in tag matching entry */
  234. __u32 max_sge;
  235. __u32 reserved;
  236. };
  237. struct ib_uverbs_ex_query_device_resp {
  238. struct ib_uverbs_query_device_resp base;
  239. __u32 comp_mask;
  240. __u32 response_length;
  241. struct ib_uverbs_odp_caps odp_caps;
  242. __aligned_u64 timestamp_mask;
  243. __aligned_u64 hca_core_clock; /* in KHZ */
  244. __aligned_u64 device_cap_flags_ex;
  245. struct ib_uverbs_rss_caps rss_caps;
  246. __u32 max_wq_type_rq;
  247. __u32 raw_packet_caps;
  248. struct ib_uverbs_tm_caps tm_caps;
  249. struct ib_uverbs_cq_moderation_caps cq_moderation_caps;
  250. __aligned_u64 max_dm_size;
  251. __u32 xrc_odp_caps;
  252. __u32 reserved;
  253. };
  254. struct ib_uverbs_query_port {
  255. __aligned_u64 response;
  256. __u8 port_num;
  257. __u8 reserved[7];
  258. __aligned_u64 driver_data[0];
  259. };
  260. struct ib_uverbs_query_port_resp {
  261. __u32 port_cap_flags; /* see ib_uverbs_query_port_cap_flags */
  262. __u32 max_msg_sz;
  263. __u32 bad_pkey_cntr;
  264. __u32 qkey_viol_cntr;
  265. __u32 gid_tbl_len;
  266. __u16 pkey_tbl_len;
  267. __u16 lid;
  268. __u16 sm_lid;
  269. __u8 state;
  270. __u8 max_mtu;
  271. __u8 active_mtu;
  272. __u8 lmc;
  273. __u8 max_vl_num;
  274. __u8 sm_sl;
  275. __u8 subnet_timeout;
  276. __u8 init_type_reply;
  277. __u8 active_width;
  278. __u8 active_speed;
  279. __u8 phys_state;
  280. __u8 link_layer;
  281. __u8 flags; /* see ib_uverbs_query_port_flags */
  282. __u8 reserved;
  283. };
  284. struct ib_uverbs_alloc_pd {
  285. __aligned_u64 response;
  286. __aligned_u64 driver_data[0];
  287. };
  288. struct ib_uverbs_alloc_pd_resp {
  289. __u32 pd_handle;
  290. __u32 driver_data[0];
  291. };
  292. struct ib_uverbs_dealloc_pd {
  293. __u32 pd_handle;
  294. };
  295. struct ib_uverbs_open_xrcd {
  296. __aligned_u64 response;
  297. __u32 fd;
  298. __u32 oflags;
  299. __aligned_u64 driver_data[0];
  300. };
  301. struct ib_uverbs_open_xrcd_resp {
  302. __u32 xrcd_handle;
  303. __u32 driver_data[0];
  304. };
  305. struct ib_uverbs_close_xrcd {
  306. __u32 xrcd_handle;
  307. };
  308. struct ib_uverbs_reg_mr {
  309. __aligned_u64 response;
  310. __aligned_u64 start;
  311. __aligned_u64 length;
  312. __aligned_u64 hca_va;
  313. __u32 pd_handle;
  314. __u32 access_flags;
  315. __aligned_u64 driver_data[0];
  316. };
  317. struct ib_uverbs_reg_mr_resp {
  318. __u32 mr_handle;
  319. __u32 lkey;
  320. __u32 rkey;
  321. __u32 driver_data[0];
  322. };
  323. struct ib_uverbs_rereg_mr {
  324. __aligned_u64 response;
  325. __u32 mr_handle;
  326. __u32 flags;
  327. __aligned_u64 start;
  328. __aligned_u64 length;
  329. __aligned_u64 hca_va;
  330. __u32 pd_handle;
  331. __u32 access_flags;
  332. __aligned_u64 driver_data[0];
  333. };
  334. struct ib_uverbs_rereg_mr_resp {
  335. __u32 lkey;
  336. __u32 rkey;
  337. __aligned_u64 driver_data[0];
  338. };
  339. struct ib_uverbs_dereg_mr {
  340. __u32 mr_handle;
  341. };
  342. struct ib_uverbs_alloc_mw {
  343. __aligned_u64 response;
  344. __u32 pd_handle;
  345. __u8 mw_type;
  346. __u8 reserved[3];
  347. __aligned_u64 driver_data[0];
  348. };
  349. struct ib_uverbs_alloc_mw_resp {
  350. __u32 mw_handle;
  351. __u32 rkey;
  352. __aligned_u64 driver_data[0];
  353. };
  354. struct ib_uverbs_dealloc_mw {
  355. __u32 mw_handle;
  356. };
  357. struct ib_uverbs_create_comp_channel {
  358. __aligned_u64 response;
  359. };
  360. struct ib_uverbs_create_comp_channel_resp {
  361. __u32 fd;
  362. };
  363. struct ib_uverbs_create_cq {
  364. __aligned_u64 response;
  365. __aligned_u64 user_handle;
  366. __u32 cqe;
  367. __u32 comp_vector;
  368. __s32 comp_channel;
  369. __u32 reserved;
  370. __aligned_u64 driver_data[0];
  371. };
  372. enum ib_uverbs_ex_create_cq_flags {
  373. IB_UVERBS_CQ_FLAGS_TIMESTAMP_COMPLETION = 1 << 0,
  374. IB_UVERBS_CQ_FLAGS_IGNORE_OVERRUN = 1 << 1,
  375. };
  376. struct ib_uverbs_ex_create_cq {
  377. __aligned_u64 user_handle;
  378. __u32 cqe;
  379. __u32 comp_vector;
  380. __s32 comp_channel;
  381. __u32 comp_mask;
  382. __u32 flags; /* bitmask of ib_uverbs_ex_create_cq_flags */
  383. __u32 reserved;
  384. };
  385. struct ib_uverbs_create_cq_resp {
  386. __u32 cq_handle;
  387. __u32 cqe;
  388. __aligned_u64 driver_data[0];
  389. };
  390. struct ib_uverbs_ex_create_cq_resp {
  391. struct ib_uverbs_create_cq_resp base;
  392. __u32 comp_mask;
  393. __u32 response_length;
  394. };
  395. struct ib_uverbs_resize_cq {
  396. __aligned_u64 response;
  397. __u32 cq_handle;
  398. __u32 cqe;
  399. __aligned_u64 driver_data[0];
  400. };
  401. struct ib_uverbs_resize_cq_resp {
  402. __u32 cqe;
  403. __u32 reserved;
  404. __aligned_u64 driver_data[0];
  405. };
  406. struct ib_uverbs_poll_cq {
  407. __aligned_u64 response;
  408. __u32 cq_handle;
  409. __u32 ne;
  410. };
  411. struct ib_uverbs_wc {
  412. __aligned_u64 wr_id;
  413. __u32 status;
  414. __u32 opcode;
  415. __u32 vendor_err;
  416. __u32 byte_len;
  417. union {
  418. __be32 imm_data;
  419. __u32 invalidate_rkey;
  420. } ex;
  421. __u32 qp_num;
  422. __u32 src_qp;
  423. __u32 wc_flags;
  424. __u16 pkey_index;
  425. __u16 slid;
  426. __u8 sl;
  427. __u8 dlid_path_bits;
  428. __u8 port_num;
  429. __u8 reserved;
  430. };
  431. struct ib_uverbs_poll_cq_resp {
  432. __u32 count;
  433. __u32 reserved;
  434. struct ib_uverbs_wc wc[0];
  435. };
  436. struct ib_uverbs_req_notify_cq {
  437. __u32 cq_handle;
  438. __u32 solicited_only;
  439. };
  440. struct ib_uverbs_destroy_cq {
  441. __aligned_u64 response;
  442. __u32 cq_handle;
  443. __u32 reserved;
  444. };
  445. struct ib_uverbs_destroy_cq_resp {
  446. __u32 comp_events_reported;
  447. __u32 async_events_reported;
  448. };
  449. struct ib_uverbs_global_route {
  450. __u8 dgid[16];
  451. __u32 flow_label;
  452. __u8 sgid_index;
  453. __u8 hop_limit;
  454. __u8 traffic_class;
  455. __u8 reserved;
  456. };
  457. struct ib_uverbs_ah_attr {
  458. struct ib_uverbs_global_route grh;
  459. __u16 dlid;
  460. __u8 sl;
  461. __u8 src_path_bits;
  462. __u8 static_rate;
  463. __u8 is_global;
  464. __u8 port_num;
  465. __u8 reserved;
  466. };
  467. struct ib_uverbs_qp_attr {
  468. __u32 qp_attr_mask;
  469. __u32 qp_state;
  470. __u32 cur_qp_state;
  471. __u32 path_mtu;
  472. __u32 path_mig_state;
  473. __u32 qkey;
  474. __u32 rq_psn;
  475. __u32 sq_psn;
  476. __u32 dest_qp_num;
  477. __u32 qp_access_flags;
  478. struct ib_uverbs_ah_attr ah_attr;
  479. struct ib_uverbs_ah_attr alt_ah_attr;
  480. /* ib_qp_cap */
  481. __u32 max_send_wr;
  482. __u32 max_recv_wr;
  483. __u32 max_send_sge;
  484. __u32 max_recv_sge;
  485. __u32 max_inline_data;
  486. __u16 pkey_index;
  487. __u16 alt_pkey_index;
  488. __u8 en_sqd_async_notify;
  489. __u8 sq_draining;
  490. __u8 max_rd_atomic;
  491. __u8 max_dest_rd_atomic;
  492. __u8 min_rnr_timer;
  493. __u8 port_num;
  494. __u8 timeout;
  495. __u8 retry_cnt;
  496. __u8 rnr_retry;
  497. __u8 alt_port_num;
  498. __u8 alt_timeout;
  499. __u8 reserved[5];
  500. };
  501. struct ib_uverbs_create_qp {
  502. __aligned_u64 response;
  503. __aligned_u64 user_handle;
  504. __u32 pd_handle;
  505. __u32 send_cq_handle;
  506. __u32 recv_cq_handle;
  507. __u32 srq_handle;
  508. __u32 max_send_wr;
  509. __u32 max_recv_wr;
  510. __u32 max_send_sge;
  511. __u32 max_recv_sge;
  512. __u32 max_inline_data;
  513. __u8 sq_sig_all;
  514. __u8 qp_type;
  515. __u8 is_srq;
  516. __u8 reserved;
  517. __aligned_u64 driver_data[0];
  518. };
  519. enum ib_uverbs_create_qp_mask {
  520. IB_UVERBS_CREATE_QP_MASK_IND_TABLE = 1UL << 0,
  521. };
  522. enum {
  523. IB_UVERBS_CREATE_QP_SUP_COMP_MASK = IB_UVERBS_CREATE_QP_MASK_IND_TABLE,
  524. };
  525. enum {
  526. /*
  527. * This value is equal to IB_QP_DEST_QPN.
  528. */
  529. IB_USER_LEGACY_LAST_QP_ATTR_MASK = 1ULL << 20,
  530. };
  531. enum {
  532. /*
  533. * This value is equal to IB_QP_RATE_LIMIT.
  534. */
  535. IB_USER_LAST_QP_ATTR_MASK = 1ULL << 25,
  536. };
  537. struct ib_uverbs_ex_create_qp {
  538. __aligned_u64 user_handle;
  539. __u32 pd_handle;
  540. __u32 send_cq_handle;
  541. __u32 recv_cq_handle;
  542. __u32 srq_handle;
  543. __u32 max_send_wr;
  544. __u32 max_recv_wr;
  545. __u32 max_send_sge;
  546. __u32 max_recv_sge;
  547. __u32 max_inline_data;
  548. __u8 sq_sig_all;
  549. __u8 qp_type;
  550. __u8 is_srq;
  551. __u8 reserved;
  552. __u32 comp_mask;
  553. __u32 create_flags;
  554. __u32 rwq_ind_tbl_handle;
  555. __u32 source_qpn;
  556. };
  557. struct ib_uverbs_open_qp {
  558. __aligned_u64 response;
  559. __aligned_u64 user_handle;
  560. __u32 pd_handle;
  561. __u32 qpn;
  562. __u8 qp_type;
  563. __u8 reserved[7];
  564. __aligned_u64 driver_data[0];
  565. };
  566. /* also used for open response */
  567. struct ib_uverbs_create_qp_resp {
  568. __u32 qp_handle;
  569. __u32 qpn;
  570. __u32 max_send_wr;
  571. __u32 max_recv_wr;
  572. __u32 max_send_sge;
  573. __u32 max_recv_sge;
  574. __u32 max_inline_data;
  575. __u32 reserved;
  576. __u32 driver_data[0];
  577. };
  578. struct ib_uverbs_ex_create_qp_resp {
  579. struct ib_uverbs_create_qp_resp base;
  580. __u32 comp_mask;
  581. __u32 response_length;
  582. };
  583. /*
  584. * This struct needs to remain a multiple of 8 bytes to keep the
  585. * alignment of the modify QP parameters.
  586. */
  587. struct ib_uverbs_qp_dest {
  588. __u8 dgid[16];
  589. __u32 flow_label;
  590. __u16 dlid;
  591. __u16 reserved;
  592. __u8 sgid_index;
  593. __u8 hop_limit;
  594. __u8 traffic_class;
  595. __u8 sl;
  596. __u8 src_path_bits;
  597. __u8 static_rate;
  598. __u8 is_global;
  599. __u8 port_num;
  600. };
  601. struct ib_uverbs_query_qp {
  602. __aligned_u64 response;
  603. __u32 qp_handle;
  604. __u32 attr_mask;
  605. __aligned_u64 driver_data[0];
  606. };
  607. struct ib_uverbs_query_qp_resp {
  608. struct ib_uverbs_qp_dest dest;
  609. struct ib_uverbs_qp_dest alt_dest;
  610. __u32 max_send_wr;
  611. __u32 max_recv_wr;
  612. __u32 max_send_sge;
  613. __u32 max_recv_sge;
  614. __u32 max_inline_data;
  615. __u32 qkey;
  616. __u32 rq_psn;
  617. __u32 sq_psn;
  618. __u32 dest_qp_num;
  619. __u32 qp_access_flags;
  620. __u16 pkey_index;
  621. __u16 alt_pkey_index;
  622. __u8 qp_state;
  623. __u8 cur_qp_state;
  624. __u8 path_mtu;
  625. __u8 path_mig_state;
  626. __u8 sq_draining;
  627. __u8 max_rd_atomic;
  628. __u8 max_dest_rd_atomic;
  629. __u8 min_rnr_timer;
  630. __u8 port_num;
  631. __u8 timeout;
  632. __u8 retry_cnt;
  633. __u8 rnr_retry;
  634. __u8 alt_port_num;
  635. __u8 alt_timeout;
  636. __u8 sq_sig_all;
  637. __u8 reserved[5];
  638. __aligned_u64 driver_data[0];
  639. };
  640. struct ib_uverbs_modify_qp {
  641. struct ib_uverbs_qp_dest dest;
  642. struct ib_uverbs_qp_dest alt_dest;
  643. __u32 qp_handle;
  644. __u32 attr_mask;
  645. __u32 qkey;
  646. __u32 rq_psn;
  647. __u32 sq_psn;
  648. __u32 dest_qp_num;
  649. __u32 qp_access_flags;
  650. __u16 pkey_index;
  651. __u16 alt_pkey_index;
  652. __u8 qp_state;
  653. __u8 cur_qp_state;
  654. __u8 path_mtu;
  655. __u8 path_mig_state;
  656. __u8 en_sqd_async_notify;
  657. __u8 max_rd_atomic;
  658. __u8 max_dest_rd_atomic;
  659. __u8 min_rnr_timer;
  660. __u8 port_num;
  661. __u8 timeout;
  662. __u8 retry_cnt;
  663. __u8 rnr_retry;
  664. __u8 alt_port_num;
  665. __u8 alt_timeout;
  666. __u8 reserved[2];
  667. __aligned_u64 driver_data[0];
  668. };
  669. struct ib_uverbs_ex_modify_qp {
  670. struct ib_uverbs_modify_qp base;
  671. __u32 rate_limit;
  672. __u32 reserved;
  673. };
  674. struct ib_uverbs_ex_modify_qp_resp {
  675. __u32 comp_mask;
  676. __u32 response_length;
  677. };
  678. struct ib_uverbs_destroy_qp {
  679. __aligned_u64 response;
  680. __u32 qp_handle;
  681. __u32 reserved;
  682. };
  683. struct ib_uverbs_destroy_qp_resp {
  684. __u32 events_reported;
  685. };
  686. /*
  687. * The ib_uverbs_sge structure isn't used anywhere, since we assume
  688. * the ib_sge structure is packed the same way on 32-bit and 64-bit
  689. * architectures in both kernel and user space. It's just here to
  690. * document the ABI.
  691. */
  692. struct ib_uverbs_sge {
  693. __aligned_u64 addr;
  694. __u32 length;
  695. __u32 lkey;
  696. };
  697. enum ib_uverbs_wr_opcode {
  698. IB_UVERBS_WR_RDMA_WRITE = 0,
  699. IB_UVERBS_WR_RDMA_WRITE_WITH_IMM = 1,
  700. IB_UVERBS_WR_SEND = 2,
  701. IB_UVERBS_WR_SEND_WITH_IMM = 3,
  702. IB_UVERBS_WR_RDMA_READ = 4,
  703. IB_UVERBS_WR_ATOMIC_CMP_AND_SWP = 5,
  704. IB_UVERBS_WR_ATOMIC_FETCH_AND_ADD = 6,
  705. IB_UVERBS_WR_LOCAL_INV = 7,
  706. IB_UVERBS_WR_BIND_MW = 8,
  707. IB_UVERBS_WR_SEND_WITH_INV = 9,
  708. IB_UVERBS_WR_TSO = 10,
  709. IB_UVERBS_WR_RDMA_READ_WITH_INV = 11,
  710. IB_UVERBS_WR_MASKED_ATOMIC_CMP_AND_SWP = 12,
  711. IB_UVERBS_WR_MASKED_ATOMIC_FETCH_AND_ADD = 13,
  712. /* Review enum ib_wr_opcode before modifying this */
  713. };
  714. struct ib_uverbs_send_wr {
  715. __aligned_u64 wr_id;
  716. __u32 num_sge;
  717. __u32 opcode; /* see enum ib_uverbs_wr_opcode */
  718. __u32 send_flags;
  719. union {
  720. __be32 imm_data;
  721. __u32 invalidate_rkey;
  722. } ex;
  723. union {
  724. struct {
  725. __aligned_u64 remote_addr;
  726. __u32 rkey;
  727. __u32 reserved;
  728. } rdma;
  729. struct {
  730. __aligned_u64 remote_addr;
  731. __aligned_u64 compare_add;
  732. __aligned_u64 swap;
  733. __u32 rkey;
  734. __u32 reserved;
  735. } atomic;
  736. struct {
  737. __u32 ah;
  738. __u32 remote_qpn;
  739. __u32 remote_qkey;
  740. __u32 reserved;
  741. } ud;
  742. } wr;
  743. };
  744. struct ib_uverbs_post_send {
  745. __aligned_u64 response;
  746. __u32 qp_handle;
  747. __u32 wr_count;
  748. __u32 sge_count;
  749. __u32 wqe_size;
  750. struct ib_uverbs_send_wr send_wr[0];
  751. };
  752. struct ib_uverbs_post_send_resp {
  753. __u32 bad_wr;
  754. };
  755. struct ib_uverbs_recv_wr {
  756. __aligned_u64 wr_id;
  757. __u32 num_sge;
  758. __u32 reserved;
  759. };
  760. struct ib_uverbs_post_recv {
  761. __aligned_u64 response;
  762. __u32 qp_handle;
  763. __u32 wr_count;
  764. __u32 sge_count;
  765. __u32 wqe_size;
  766. struct ib_uverbs_recv_wr recv_wr[0];
  767. };
  768. struct ib_uverbs_post_recv_resp {
  769. __u32 bad_wr;
  770. };
  771. struct ib_uverbs_post_srq_recv {
  772. __aligned_u64 response;
  773. __u32 srq_handle;
  774. __u32 wr_count;
  775. __u32 sge_count;
  776. __u32 wqe_size;
  777. struct ib_uverbs_recv_wr recv[0];
  778. };
  779. struct ib_uverbs_post_srq_recv_resp {
  780. __u32 bad_wr;
  781. };
  782. struct ib_uverbs_create_ah {
  783. __aligned_u64 response;
  784. __aligned_u64 user_handle;
  785. __u32 pd_handle;
  786. __u32 reserved;
  787. struct ib_uverbs_ah_attr attr;
  788. __aligned_u64 driver_data[0];
  789. };
  790. struct ib_uverbs_create_ah_resp {
  791. __u32 ah_handle;
  792. __u32 driver_data[0];
  793. };
  794. struct ib_uverbs_destroy_ah {
  795. __u32 ah_handle;
  796. };
  797. struct ib_uverbs_attach_mcast {
  798. __u8 gid[16];
  799. __u32 qp_handle;
  800. __u16 mlid;
  801. __u16 reserved;
  802. __aligned_u64 driver_data[0];
  803. };
  804. struct ib_uverbs_detach_mcast {
  805. __u8 gid[16];
  806. __u32 qp_handle;
  807. __u16 mlid;
  808. __u16 reserved;
  809. __aligned_u64 driver_data[0];
  810. };
  811. struct ib_uverbs_flow_spec_hdr {
  812. __u32 type;
  813. __u16 size;
  814. __u16 reserved;
  815. /* followed by flow_spec */
  816. __aligned_u64 flow_spec_data[0];
  817. };
  818. struct ib_uverbs_flow_eth_filter {
  819. __u8 dst_mac[6];
  820. __u8 src_mac[6];
  821. __be16 ether_type;
  822. __be16 vlan_tag;
  823. };
  824. struct ib_uverbs_flow_spec_eth {
  825. union {
  826. struct ib_uverbs_flow_spec_hdr hdr;
  827. struct {
  828. __u32 type;
  829. __u16 size;
  830. __u16 reserved;
  831. };
  832. };
  833. struct ib_uverbs_flow_eth_filter val;
  834. struct ib_uverbs_flow_eth_filter mask;
  835. };
  836. struct ib_uverbs_flow_ipv4_filter {
  837. __be32 src_ip;
  838. __be32 dst_ip;
  839. __u8 proto;
  840. __u8 tos;
  841. __u8 ttl;
  842. __u8 flags;
  843. };
  844. struct ib_uverbs_flow_spec_ipv4 {
  845. union {
  846. struct ib_uverbs_flow_spec_hdr hdr;
  847. struct {
  848. __u32 type;
  849. __u16 size;
  850. __u16 reserved;
  851. };
  852. };
  853. struct ib_uverbs_flow_ipv4_filter val;
  854. struct ib_uverbs_flow_ipv4_filter mask;
  855. };
  856. struct ib_uverbs_flow_tcp_udp_filter {
  857. __be16 dst_port;
  858. __be16 src_port;
  859. };
  860. struct ib_uverbs_flow_spec_tcp_udp {
  861. union {
  862. struct ib_uverbs_flow_spec_hdr hdr;
  863. struct {
  864. __u32 type;
  865. __u16 size;
  866. __u16 reserved;
  867. };
  868. };
  869. struct ib_uverbs_flow_tcp_udp_filter val;
  870. struct ib_uverbs_flow_tcp_udp_filter mask;
  871. };
  872. struct ib_uverbs_flow_ipv6_filter {
  873. __u8 src_ip[16];
  874. __u8 dst_ip[16];
  875. __be32 flow_label;
  876. __u8 next_hdr;
  877. __u8 traffic_class;
  878. __u8 hop_limit;
  879. __u8 reserved;
  880. };
  881. struct ib_uverbs_flow_spec_ipv6 {
  882. union {
  883. struct ib_uverbs_flow_spec_hdr hdr;
  884. struct {
  885. __u32 type;
  886. __u16 size;
  887. __u16 reserved;
  888. };
  889. };
  890. struct ib_uverbs_flow_ipv6_filter val;
  891. struct ib_uverbs_flow_ipv6_filter mask;
  892. };
  893. struct ib_uverbs_flow_spec_action_tag {
  894. union {
  895. struct ib_uverbs_flow_spec_hdr hdr;
  896. struct {
  897. __u32 type;
  898. __u16 size;
  899. __u16 reserved;
  900. };
  901. };
  902. __u32 tag_id;
  903. __u32 reserved1;
  904. };
  905. struct ib_uverbs_flow_spec_action_drop {
  906. union {
  907. struct ib_uverbs_flow_spec_hdr hdr;
  908. struct {
  909. __u32 type;
  910. __u16 size;
  911. __u16 reserved;
  912. };
  913. };
  914. };
  915. struct ib_uverbs_flow_spec_action_handle {
  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_spec_action_count {
  928. union {
  929. struct ib_uverbs_flow_spec_hdr hdr;
  930. struct {
  931. __u32 type;
  932. __u16 size;
  933. __u16 reserved;
  934. };
  935. };
  936. __u32 handle;
  937. __u32 reserved1;
  938. };
  939. struct ib_uverbs_flow_tunnel_filter {
  940. __be32 tunnel_id;
  941. };
  942. struct ib_uverbs_flow_spec_tunnel {
  943. union {
  944. struct ib_uverbs_flow_spec_hdr hdr;
  945. struct {
  946. __u32 type;
  947. __u16 size;
  948. __u16 reserved;
  949. };
  950. };
  951. struct ib_uverbs_flow_tunnel_filter val;
  952. struct ib_uverbs_flow_tunnel_filter mask;
  953. };
  954. struct ib_uverbs_flow_spec_esp_filter {
  955. __u32 spi;
  956. __u32 seq;
  957. };
  958. struct ib_uverbs_flow_spec_esp {
  959. union {
  960. struct ib_uverbs_flow_spec_hdr hdr;
  961. struct {
  962. __u32 type;
  963. __u16 size;
  964. __u16 reserved;
  965. };
  966. };
  967. struct ib_uverbs_flow_spec_esp_filter val;
  968. struct ib_uverbs_flow_spec_esp_filter mask;
  969. };
  970. struct ib_uverbs_flow_gre_filter {
  971. /* c_ks_res0_ver field is bits 0-15 in offset 0 of a standard GRE header:
  972. * bit 0 - C - checksum bit.
  973. * bit 1 - reserved. set to 0.
  974. * bit 2 - key bit.
  975. * bit 3 - sequence number bit.
  976. * bits 4:12 - reserved. set to 0.
  977. * bits 13:15 - GRE version.
  978. */
  979. __be16 c_ks_res0_ver;
  980. __be16 protocol;
  981. __be32 key;
  982. };
  983. struct ib_uverbs_flow_spec_gre {
  984. union {
  985. struct ib_uverbs_flow_spec_hdr hdr;
  986. struct {
  987. __u32 type;
  988. __u16 size;
  989. __u16 reserved;
  990. };
  991. };
  992. struct ib_uverbs_flow_gre_filter val;
  993. struct ib_uverbs_flow_gre_filter mask;
  994. };
  995. struct ib_uverbs_flow_mpls_filter {
  996. /* The field includes the entire MPLS label:
  997. * bits 0:19 - label field.
  998. * bits 20:22 - traffic class field.
  999. * bits 23 - bottom of stack bit.
  1000. * bits 24:31 - ttl field.
  1001. */
  1002. __be32 label;
  1003. };
  1004. struct ib_uverbs_flow_spec_mpls {
  1005. union {
  1006. struct ib_uverbs_flow_spec_hdr hdr;
  1007. struct {
  1008. __u32 type;
  1009. __u16 size;
  1010. __u16 reserved;
  1011. };
  1012. };
  1013. struct ib_uverbs_flow_mpls_filter val;
  1014. struct ib_uverbs_flow_mpls_filter mask;
  1015. };
  1016. struct ib_uverbs_flow_attr {
  1017. __u32 type;
  1018. __u16 size;
  1019. __u16 priority;
  1020. __u8 num_of_specs;
  1021. __u8 reserved[2];
  1022. __u8 port;
  1023. __u32 flags;
  1024. /* Following are the optional layers according to user request
  1025. * struct ib_flow_spec_xxx
  1026. * struct ib_flow_spec_yyy
  1027. */
  1028. struct ib_uverbs_flow_spec_hdr flow_specs[0];
  1029. };
  1030. struct ib_uverbs_create_flow {
  1031. __u32 comp_mask;
  1032. __u32 qp_handle;
  1033. struct ib_uverbs_flow_attr flow_attr;
  1034. };
  1035. struct ib_uverbs_create_flow_resp {
  1036. __u32 comp_mask;
  1037. __u32 flow_handle;
  1038. };
  1039. struct ib_uverbs_destroy_flow {
  1040. __u32 comp_mask;
  1041. __u32 flow_handle;
  1042. };
  1043. struct ib_uverbs_create_srq {
  1044. __aligned_u64 response;
  1045. __aligned_u64 user_handle;
  1046. __u32 pd_handle;
  1047. __u32 max_wr;
  1048. __u32 max_sge;
  1049. __u32 srq_limit;
  1050. __aligned_u64 driver_data[0];
  1051. };
  1052. struct ib_uverbs_create_xsrq {
  1053. __aligned_u64 response;
  1054. __aligned_u64 user_handle;
  1055. __u32 srq_type;
  1056. __u32 pd_handle;
  1057. __u32 max_wr;
  1058. __u32 max_sge;
  1059. __u32 srq_limit;
  1060. __u32 max_num_tags;
  1061. __u32 xrcd_handle;
  1062. __u32 cq_handle;
  1063. __aligned_u64 driver_data[0];
  1064. };
  1065. struct ib_uverbs_create_srq_resp {
  1066. __u32 srq_handle;
  1067. __u32 max_wr;
  1068. __u32 max_sge;
  1069. __u32 srqn;
  1070. __u32 driver_data[0];
  1071. };
  1072. struct ib_uverbs_modify_srq {
  1073. __u32 srq_handle;
  1074. __u32 attr_mask;
  1075. __u32 max_wr;
  1076. __u32 srq_limit;
  1077. __aligned_u64 driver_data[0];
  1078. };
  1079. struct ib_uverbs_query_srq {
  1080. __aligned_u64 response;
  1081. __u32 srq_handle;
  1082. __u32 reserved;
  1083. __aligned_u64 driver_data[0];
  1084. };
  1085. struct ib_uverbs_query_srq_resp {
  1086. __u32 max_wr;
  1087. __u32 max_sge;
  1088. __u32 srq_limit;
  1089. __u32 reserved;
  1090. };
  1091. struct ib_uverbs_destroy_srq {
  1092. __aligned_u64 response;
  1093. __u32 srq_handle;
  1094. __u32 reserved;
  1095. };
  1096. struct ib_uverbs_destroy_srq_resp {
  1097. __u32 events_reported;
  1098. };
  1099. struct ib_uverbs_ex_create_wq {
  1100. __u32 comp_mask;
  1101. __u32 wq_type;
  1102. __aligned_u64 user_handle;
  1103. __u32 pd_handle;
  1104. __u32 cq_handle;
  1105. __u32 max_wr;
  1106. __u32 max_sge;
  1107. __u32 create_flags; /* Use enum ib_wq_flags */
  1108. __u32 reserved;
  1109. };
  1110. struct ib_uverbs_ex_create_wq_resp {
  1111. __u32 comp_mask;
  1112. __u32 response_length;
  1113. __u32 wq_handle;
  1114. __u32 max_wr;
  1115. __u32 max_sge;
  1116. __u32 wqn;
  1117. };
  1118. struct ib_uverbs_ex_destroy_wq {
  1119. __u32 comp_mask;
  1120. __u32 wq_handle;
  1121. };
  1122. struct ib_uverbs_ex_destroy_wq_resp {
  1123. __u32 comp_mask;
  1124. __u32 response_length;
  1125. __u32 events_reported;
  1126. __u32 reserved;
  1127. };
  1128. struct ib_uverbs_ex_modify_wq {
  1129. __u32 attr_mask;
  1130. __u32 wq_handle;
  1131. __u32 wq_state;
  1132. __u32 curr_wq_state;
  1133. __u32 flags; /* Use enum ib_wq_flags */
  1134. __u32 flags_mask; /* Use enum ib_wq_flags */
  1135. };
  1136. /* Prevent memory allocation rather than max expected size */
  1137. #define IB_USER_VERBS_MAX_LOG_IND_TBL_SIZE 0x0d
  1138. struct ib_uverbs_ex_create_rwq_ind_table {
  1139. __u32 comp_mask;
  1140. __u32 log_ind_tbl_size;
  1141. /* Following are the wq handles according to log_ind_tbl_size
  1142. * wq_handle1
  1143. * wq_handle2
  1144. */
  1145. __u32 wq_handles[0];
  1146. };
  1147. struct ib_uverbs_ex_create_rwq_ind_table_resp {
  1148. __u32 comp_mask;
  1149. __u32 response_length;
  1150. __u32 ind_tbl_handle;
  1151. __u32 ind_tbl_num;
  1152. };
  1153. struct ib_uverbs_ex_destroy_rwq_ind_table {
  1154. __u32 comp_mask;
  1155. __u32 ind_tbl_handle;
  1156. };
  1157. struct ib_uverbs_cq_moderation {
  1158. __u16 cq_count;
  1159. __u16 cq_period;
  1160. };
  1161. struct ib_uverbs_ex_modify_cq {
  1162. __u32 cq_handle;
  1163. __u32 attr_mask;
  1164. struct ib_uverbs_cq_moderation attr;
  1165. __u32 reserved;
  1166. };
  1167. #define IB_DEVICE_NAME_MAX 64
  1168. #endif /* IB_USER_VERBS_H */