ib_user_verbs.h 26 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292
  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 */