kern-abi.h revision 9948fdf7
1/*
2 * Copyright (c) 2005 Topspin Communications.  All rights reserved.
3 * Copyright (c) 2005, 2006 Cisco Systems.  All rights reserved.
4 * Copyright (c) 2005 PathScale, Inc.  All rights reserved.
5 *
6 * This software is available to you under a choice of one of two
7 * licenses.  You may choose to be licensed under the terms of the GNU
8 * General Public License (GPL) Version 2, available from the file
9 * COPYING in the main directory of this source tree, or the
10 * OpenIB.org BSD license below:
11 *
12 *     Redistribution and use in source and binary forms, with or
13 *     without modification, are permitted provided that the following
14 *     conditions are met:
15 *
16 *      - Redistributions of source code must retain the above
17 *        copyright notice, this list of conditions and the following
18 *        disclaimer.
19 *
20 *      - Redistributions in binary form must reproduce the above
21 *        copyright notice, this list of conditions and the following
22 *        disclaimer in the documentation and/or other materials
23 *        provided with the distribution.
24 *
25 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 * SOFTWARE.
33 */
34
35#ifndef KERN_ABI_H
36#define KERN_ABI_H
37
38#include <linux/types.h>
39
40/*
41 * This file must be kept in sync with the kernel's version of
42 * drivers/infiniband/include/ib_user_verbs.h
43 */
44
45/*
46 * The minimum and maximum kernel ABI that we can handle.
47 */
48#define IB_USER_VERBS_MIN_ABI_VERSION	3
49#define IB_USER_VERBS_MAX_ABI_VERSION	6
50
51#define IB_USER_VERBS_CMD_THRESHOLD    50
52
53enum {
54	IB_USER_VERBS_CMD_GET_CONTEXT,
55	IB_USER_VERBS_CMD_QUERY_DEVICE,
56	IB_USER_VERBS_CMD_QUERY_PORT,
57	IB_USER_VERBS_CMD_ALLOC_PD,
58	IB_USER_VERBS_CMD_DEALLOC_PD,
59	IB_USER_VERBS_CMD_CREATE_AH,
60	IB_USER_VERBS_CMD_MODIFY_AH,
61	IB_USER_VERBS_CMD_QUERY_AH,
62	IB_USER_VERBS_CMD_DESTROY_AH,
63	IB_USER_VERBS_CMD_REG_MR,
64	IB_USER_VERBS_CMD_REG_SMR,
65	IB_USER_VERBS_CMD_REREG_MR,
66	IB_USER_VERBS_CMD_QUERY_MR,
67	IB_USER_VERBS_CMD_DEREG_MR,
68	IB_USER_VERBS_CMD_ALLOC_MW,
69	IB_USER_VERBS_CMD_BIND_MW,
70	IB_USER_VERBS_CMD_DEALLOC_MW,
71	IB_USER_VERBS_CMD_CREATE_COMP_CHANNEL,
72	IB_USER_VERBS_CMD_CREATE_CQ,
73	IB_USER_VERBS_CMD_RESIZE_CQ,
74	IB_USER_VERBS_CMD_DESTROY_CQ,
75	IB_USER_VERBS_CMD_POLL_CQ,
76	IB_USER_VERBS_CMD_PEEK_CQ,
77	IB_USER_VERBS_CMD_REQ_NOTIFY_CQ,
78	IB_USER_VERBS_CMD_CREATE_QP,
79	IB_USER_VERBS_CMD_QUERY_QP,
80	IB_USER_VERBS_CMD_MODIFY_QP,
81	IB_USER_VERBS_CMD_DESTROY_QP,
82	IB_USER_VERBS_CMD_POST_SEND,
83	IB_USER_VERBS_CMD_POST_RECV,
84	IB_USER_VERBS_CMD_ATTACH_MCAST,
85	IB_USER_VERBS_CMD_DETACH_MCAST,
86	IB_USER_VERBS_CMD_CREATE_SRQ,
87	IB_USER_VERBS_CMD_MODIFY_SRQ,
88	IB_USER_VERBS_CMD_QUERY_SRQ,
89	IB_USER_VERBS_CMD_DESTROY_SRQ,
90	IB_USER_VERBS_CMD_POST_SRQ_RECV,
91	IB_USER_VERBS_CMD_OPEN_XRCD,
92	IB_USER_VERBS_CMD_CLOSE_XRCD,
93	IB_USER_VERBS_CMD_CREATE_XSRQ,
94	IB_USER_VERBS_CMD_OPEN_QP,
95};
96
97
98#define IB_USER_VERBS_CMD_COMMAND_MASK		0xff
99#define IB_USER_VERBS_CMD_FLAGS_MASK		0xff000000u
100#define IB_USER_VERBS_CMD_FLAGS_SHIFT		24
101
102
103#define IB_USER_VERBS_CMD_FLAG_EXTENDED		0x80ul
104
105/* use this mask for creating extended commands */
106#define IB_USER_VERBS_CMD_EXTENDED_MASK \
107	(IB_USER_VERBS_CMD_FLAG_EXTENDED << \
108	 IB_USER_VERBS_CMD_FLAGS_SHIFT)
109
110
111enum {
112	IB_USER_VERBS_CMD_QUERY_DEVICE_EX = IB_USER_VERBS_CMD_EXTENDED_MASK |
113					    IB_USER_VERBS_CMD_QUERY_DEVICE,
114	IB_USER_VERBS_CMD_CREATE_FLOW = IB_USER_VERBS_CMD_EXTENDED_MASK +
115					IB_USER_VERBS_CMD_THRESHOLD,
116	IB_USER_VERBS_CMD_DESTROY_FLOW
117};
118
119/*
120 * Make sure that all structs defined in this file remain laid out so
121 * that they pack the same way on 32-bit and 64-bit architectures (to
122 * avoid incompatibility between 32-bit userspace and 64-bit kernels).
123 * Specifically:
124 *  - Do not use pointer types -- pass pointers in __u64 instead.
125 *  - Make sure that any structure larger than 4 bytes is padded to a
126 *    multiple of 8 bytes.  Otherwise the structure size will be
127 *    different between 32-bit and 64-bit architectures.
128 */
129
130struct hdr {
131	__u32 command;
132	__u16 in_words;
133	__u16 out_words;
134};
135
136struct response_hdr {
137	__u64 response;
138};
139
140struct ex_hdr {
141	struct {
142		__u32 command;
143		__u16 in_words;
144		__u16 out_words;
145	};
146	struct {
147		__u64 response;
148	};
149	struct {
150		__u16 provider_in_words;
151		__u16 provider_out_words;
152		__u32 reserved;
153	};
154};
155
156struct ibv_kern_async_event {
157	__u64 element;
158	__u32 event_type;
159	__u32 reserved;
160};
161
162struct ibv_comp_event {
163	__u64 cq_handle;
164};
165
166/*
167 * All commands from userspace should start with a __u32 command field
168 * followed by __u16 in_words and out_words fields (which give the
169 * length of the command block and response buffer if any in 32-bit
170 * words).  The kernel driver will read these fields first and read
171 * the rest of the command struct based on these value.
172 */
173
174#define IBV_RESP_TO_VERBS_RESP_EX_RAW(ex_ptr, ex_type, ibv_type, field) \
175	((ibv_type *)((void *)(ex_ptr) + offsetof(ex_type,		\
176	field) + sizeof((ex_ptr)->field)))
177
178#define IBV_RESP_TO_VERBS_RESP_EX(ex_ptr, ex_type, ibv_type) \
179	IBV_RESP_TO_VERBS_RESP_EX_RAW(ex_ptr, ex_type, ibv_type, comp_mask)
180
181struct ibv_query_params {
182	__u32 command;
183	__u16 in_words;
184	__u16 out_words;
185	__u64 response;
186};
187
188struct ibv_query_params_resp {
189	__u32 num_cq_events;
190};
191
192struct ibv_get_context {
193	__u32 command;
194	__u16 in_words;
195	__u16 out_words;
196	__u64 response;
197	__u64 driver_data[0];
198};
199
200struct ibv_get_context_resp {
201	__u32 async_fd;
202	__u32 num_comp_vectors;
203};
204
205struct ibv_query_device {
206	__u32 command;
207	__u16 in_words;
208	__u16 out_words;
209	__u64 response;
210	__u64 driver_data[0];
211};
212
213struct ibv_query_device_resp {
214	__u64 fw_ver;
215	__u64 node_guid;
216	__u64 sys_image_guid;
217	__u64 max_mr_size;
218	__u64 page_size_cap;
219	__u32 vendor_id;
220	__u32 vendor_part_id;
221	__u32 hw_ver;
222	__u32 max_qp;
223	__u32 max_qp_wr;
224	__u32 device_cap_flags;
225	__u32 max_sge;
226	__u32 max_sge_rd;
227	__u32 max_cq;
228	__u32 max_cqe;
229	__u32 max_mr;
230	__u32 max_pd;
231	__u32 max_qp_rd_atom;
232	__u32 max_ee_rd_atom;
233	__u32 max_res_rd_atom;
234	__u32 max_qp_init_rd_atom;
235	__u32 max_ee_init_rd_atom;
236	__u32 atomic_cap;
237	__u32 max_ee;
238	__u32 max_rdd;
239	__u32 max_mw;
240	__u32 max_raw_ipv6_qp;
241	__u32 max_raw_ethy_qp;
242	__u32 max_mcast_grp;
243	__u32 max_mcast_qp_attach;
244	__u32 max_total_mcast_qp_attach;
245	__u32 max_ah;
246	__u32 max_fmr;
247	__u32 max_map_per_fmr;
248	__u32 max_srq;
249	__u32 max_srq_wr;
250	__u32 max_srq_sge;
251	__u16 max_pkeys;
252	__u8  local_ca_ack_delay;
253	__u8  phys_port_cnt;
254	__u8  reserved[4];
255};
256
257struct ibv_query_device_ex {
258	struct ex_hdr	hdr;
259	__u32		comp_mask;
260	__u32		reserved;
261};
262
263struct ibv_odp_caps_resp {
264	__u64 general_caps;
265	struct {
266		__u32 rc_odp_caps;
267		__u32 uc_odp_caps;
268		__u32 ud_odp_caps;
269	} per_transport_caps;
270	__u32 reserved;
271};
272
273struct ibv_query_device_resp_ex {
274	struct ibv_query_device_resp base;
275	__u32 comp_mask;
276	__u32 response_length;
277	struct ibv_odp_caps_resp odp_caps;
278};
279
280struct ibv_query_port {
281	__u32 command;
282	__u16 in_words;
283	__u16 out_words;
284	__u64 response;
285	__u8  port_num;
286	__u8  reserved[7];
287	__u64 driver_data[0];
288};
289
290struct ibv_query_port_resp {
291	__u32 port_cap_flags;
292	__u32 max_msg_sz;
293	__u32 bad_pkey_cntr;
294	__u32 qkey_viol_cntr;
295	__u32 gid_tbl_len;
296	__u16 pkey_tbl_len;
297	__u16 lid;
298	__u16 sm_lid;
299	__u8  state;
300	__u8  max_mtu;
301	__u8  active_mtu;
302	__u8  lmc;
303	__u8  max_vl_num;
304	__u8  sm_sl;
305	__u8  subnet_timeout;
306	__u8  init_type_reply;
307	__u8  active_width;
308	__u8  active_speed;
309	__u8  phys_state;
310	__u8  link_layer;
311	__u8  reserved[2];
312};
313
314struct ibv_alloc_pd {
315	__u32 command;
316	__u16 in_words;
317	__u16 out_words;
318	__u64 response;
319	__u64 driver_data[0];
320};
321
322struct ibv_alloc_pd_resp {
323	__u32 pd_handle;
324};
325
326struct ibv_dealloc_pd {
327	__u32 command;
328	__u16 in_words;
329	__u16 out_words;
330	__u32 pd_handle;
331};
332
333struct ibv_open_xrcd {
334	__u32 command;
335	__u16 in_words;
336	__u16 out_words;
337	__u64 response;
338	__u32 fd;
339	__u32 oflags;
340	__u64 driver_data[0];
341};
342
343struct ibv_open_xrcd_resp {
344	__u32 xrcd_handle;
345};
346
347struct ibv_close_xrcd {
348	__u32 command;
349	__u16 in_words;
350	__u16 out_words;
351	__u32 xrcd_handle;
352};
353
354struct ibv_reg_mr {
355	__u32 command;
356	__u16 in_words;
357	__u16 out_words;
358	__u64 response;
359	__u64 start;
360	__u64 length;
361	__u64 hca_va;
362	__u32 pd_handle;
363	__u32 access_flags;
364	__u64 driver_data[0];
365};
366
367struct ibv_reg_mr_resp {
368	__u32 mr_handle;
369	__u32 lkey;
370	__u32 rkey;
371};
372
373struct ibv_rereg_mr {
374	__u32 command;
375	__u16 in_words;
376	__u16 out_words;
377	__u64 response;
378	__u32 mr_handle;
379	__u32 flags;
380	__u64 start;
381	__u64 length;
382	__u64 hca_va;
383	__u32 pd_handle;
384	__u32 access_flags;
385	__u64 driver_data[0];
386};
387
388struct ibv_rereg_mr_resp {
389	__u32 lkey;
390	__u32 rkey;
391};
392
393struct ibv_dereg_mr {
394	__u32 command;
395	__u16 in_words;
396	__u16 out_words;
397	__u32 mr_handle;
398};
399
400struct ibv_alloc_mw {
401	__u32 command;
402	__u16 in_words;
403	__u16 out_words;
404	__u64 response;
405	__u32 pd_handle;
406	__u8  mw_type;
407	__u8  reserved[3];
408};
409
410struct ibv_alloc_mw_resp {
411	__u32 mw_handle;
412	__u32 rkey;
413};
414
415struct ibv_dealloc_mw {
416	__u32 command;
417	__u16 in_words;
418	__u16 out_words;
419	__u32 mw_handle;
420	__u32 reserved;
421};
422
423struct ibv_create_comp_channel {
424	__u32 command;
425	__u16 in_words;
426	__u16 out_words;
427	__u64 response;
428};
429
430struct ibv_create_comp_channel_resp {
431	__u32 fd;
432};
433
434struct ibv_create_cq {
435	__u32 command;
436	__u16 in_words;
437	__u16 out_words;
438	__u64 response;
439	__u64 user_handle;
440	__u32 cqe;
441	__u32 comp_vector;
442	__s32 comp_channel;
443	__u32 reserved;
444	__u64 driver_data[0];
445};
446
447struct ibv_create_cq_resp {
448	__u32 cq_handle;
449	__u32 cqe;
450};
451
452struct ibv_kern_wc {
453	__u64  wr_id;
454	__u32  status;
455	__u32  opcode;
456	__u32  vendor_err;
457	__u32  byte_len;
458	__u32  imm_data;
459	__u32  qp_num;
460	__u32  src_qp;
461	__u32  wc_flags;
462	__u16  pkey_index;
463	__u16  slid;
464	__u8   sl;
465	__u8   dlid_path_bits;
466	__u8   port_num;
467	__u8   reserved;
468};
469
470struct ibv_poll_cq {
471	__u32 command;
472	__u16 in_words;
473	__u16 out_words;
474	__u64 response;
475	__u32 cq_handle;
476	__u32 ne;
477};
478
479struct ibv_poll_cq_resp {
480	__u32 count;
481	__u32 reserved;
482	struct ibv_kern_wc wc[0];
483};
484
485struct ibv_req_notify_cq {
486	__u32 command;
487	__u16 in_words;
488	__u16 out_words;
489	__u32 cq_handle;
490	__u32 solicited;
491};
492
493struct ibv_resize_cq {
494	__u32 command;
495	__u16 in_words;
496	__u16 out_words;
497	__u64 response;
498	__u32 cq_handle;
499	__u32 cqe;
500	__u64 driver_data[0];
501};
502
503struct ibv_resize_cq_resp {
504	__u32 cqe;
505	__u32 reserved;
506	__u64 driver_data[0];
507};
508
509struct ibv_destroy_cq {
510	__u32 command;
511	__u16 in_words;
512	__u16 out_words;
513	__u64 response;
514	__u32 cq_handle;
515	__u32 reserved;
516};
517
518struct ibv_destroy_cq_resp {
519	__u32 comp_events_reported;
520	__u32 async_events_reported;
521};
522
523struct ibv_kern_global_route {
524	__u8  dgid[16];
525	__u32 flow_label;
526	__u8  sgid_index;
527	__u8  hop_limit;
528	__u8  traffic_class;
529	__u8  reserved;
530};
531
532struct ibv_kern_ah_attr {
533	struct ibv_kern_global_route grh;
534	__u16 dlid;
535	__u8  sl;
536	__u8  src_path_bits;
537	__u8  static_rate;
538	__u8  is_global;
539	__u8  port_num;
540	__u8  reserved;
541};
542
543struct ibv_kern_qp_attr {
544	__u32	qp_attr_mask;
545	__u32	qp_state;
546	__u32	cur_qp_state;
547	__u32	path_mtu;
548	__u32	path_mig_state;
549	__u32	qkey;
550	__u32	rq_psn;
551	__u32	sq_psn;
552	__u32	dest_qp_num;
553	__u32	qp_access_flags;
554
555	struct ibv_kern_ah_attr ah_attr;
556	struct ibv_kern_ah_attr alt_ah_attr;
557
558	/* ib_qp_cap */
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
565	__u16	pkey_index;
566	__u16	alt_pkey_index;
567	__u8	en_sqd_async_notify;
568	__u8	sq_draining;
569	__u8	max_rd_atomic;
570	__u8	max_dest_rd_atomic;
571	__u8	min_rnr_timer;
572	__u8	port_num;
573	__u8	timeout;
574	__u8	retry_cnt;
575	__u8	rnr_retry;
576	__u8	alt_port_num;
577	__u8	alt_timeout;
578	__u8	reserved[5];
579};
580
581struct ibv_create_qp {
582	__u32 command;
583	__u16 in_words;
584	__u16 out_words;
585	__u64 response;
586	__u64 user_handle;
587	__u32 pd_handle;
588	__u32 send_cq_handle;
589	__u32 recv_cq_handle;
590	__u32 srq_handle;
591	__u32 max_send_wr;
592	__u32 max_recv_wr;
593	__u32 max_send_sge;
594	__u32 max_recv_sge;
595	__u32 max_inline_data;
596	__u8  sq_sig_all;
597	__u8  qp_type;
598	__u8  is_srq;
599	__u8  reserved;
600	__u64 driver_data[0];
601};
602
603struct ibv_open_qp {
604	__u32 command;
605	__u16 in_words;
606	__u16 out_words;
607	__u64 response;
608	__u64 user_handle;
609	__u32 pd_handle;
610	__u32 qpn;
611	__u8  qp_type;
612	__u8  reserved[7];
613	__u64 driver_data[0];
614};
615
616/* also used for open response */
617struct ibv_create_qp_resp {
618	__u32 qp_handle;
619	__u32 qpn;
620	__u32 max_send_wr;
621	__u32 max_recv_wr;
622	__u32 max_send_sge;
623	__u32 max_recv_sge;
624	__u32 max_inline_data;
625	__u32 reserved;
626};
627
628enum ibv_create_qp_ex_comp_mask {
629	IBV_CREATE_QP_EX_CAP_FLAGS          = (1ULL << 0)
630};
631
632struct ibv_create_qp_ex {
633	__u32 command;
634	__u16 in_words;
635	__u16 out_words;
636	__u16 provider_in_words;
637	__u16 provider_out_words;
638	__u32 cmd_hdr_reserved;
639	__u64 comp_mask;
640	__u64 response;
641	__u64 user_handle;
642	__u32 pd_handle;
643	__u32 send_cq_handle;
644	__u32 recv_cq_handle;
645	__u32 srq_handle;
646	__u32 max_send_wr;
647	__u32 max_recv_wr;
648	__u32 max_send_sge;
649	__u32 max_recv_sge;
650	__u32 max_inline_data;
651	__u8  sq_sig_all;
652	__u8  qp_type;
653	__u8  is_srq;
654	__u8  reserved;
655	__u64 qp_cap_flags;
656	__u64 driver_data[0];
657};
658
659struct ibv_create_qp_resp_ex {
660	__u64 comp_mask;
661	__u32 qp_handle;
662	__u32 qpn;
663	__u32 max_send_wr;
664	__u32 max_recv_wr;
665	__u32 max_send_sge;
666	__u32 max_recv_sge;
667	__u32 max_inline_data;
668	__u32 reserved;
669};
670
671struct ibv_qp_dest {
672	__u8  dgid[16];
673	__u32 flow_label;
674	__u16 dlid;
675	__u16 reserved;
676	__u8  sgid_index;
677	__u8  hop_limit;
678	__u8  traffic_class;
679	__u8  sl;
680	__u8  src_path_bits;
681	__u8  static_rate;
682	__u8  is_global;
683	__u8  port_num;
684};
685
686struct ibv_query_qp {
687	__u32 command;
688	__u16 in_words;
689	__u16 out_words;
690	__u64 response;
691	__u32 qp_handle;
692	__u32 attr_mask;
693	__u64 driver_data[0];
694};
695
696struct ibv_query_qp_resp {
697	struct ibv_qp_dest dest;
698	struct ibv_qp_dest alt_dest;
699	__u32 max_send_wr;
700	__u32 max_recv_wr;
701	__u32 max_send_sge;
702	__u32 max_recv_sge;
703	__u32 max_inline_data;
704	__u32 qkey;
705	__u32 rq_psn;
706	__u32 sq_psn;
707	__u32 dest_qp_num;
708	__u32 qp_access_flags;
709	__u16 pkey_index;
710	__u16 alt_pkey_index;
711	__u8  qp_state;
712	__u8  cur_qp_state;
713	__u8  path_mtu;
714	__u8  path_mig_state;
715	__u8  sq_draining;
716	__u8  max_rd_atomic;
717	__u8  max_dest_rd_atomic;
718	__u8  min_rnr_timer;
719	__u8  port_num;
720	__u8  timeout;
721	__u8  retry_cnt;
722	__u8  rnr_retry;
723	__u8  alt_port_num;
724	__u8  alt_timeout;
725	__u8  sq_sig_all;
726	__u8  reserved[5];
727	__u64 driver_data[0];
728};
729
730struct ibv_modify_qp {
731	__u32 command;
732	__u16 in_words;
733	__u16 out_words;
734	struct ibv_qp_dest dest;
735	struct ibv_qp_dest alt_dest;
736	__u32 qp_handle;
737	__u32 attr_mask;
738	__u32 qkey;
739	__u32 rq_psn;
740	__u32 sq_psn;
741	__u32 dest_qp_num;
742	__u32 qp_access_flags;
743	__u16 pkey_index;
744	__u16 alt_pkey_index;
745	__u8  qp_state;
746	__u8  cur_qp_state;
747	__u8  path_mtu;
748	__u8  path_mig_state;
749	__u8  en_sqd_async_notify;
750	__u8  max_rd_atomic;
751	__u8  max_dest_rd_atomic;
752	__u8  min_rnr_timer;
753	__u8  port_num;
754	__u8  timeout;
755	__u8  retry_cnt;
756	__u8  rnr_retry;
757	__u8  alt_port_num;
758	__u8  alt_timeout;
759	__u8  reserved[2];
760	__u64 driver_data[0];
761};
762
763struct ibv_destroy_qp {
764	__u32 command;
765	__u16 in_words;
766	__u16 out_words;
767	__u64 response;
768	__u32 qp_handle;
769	__u32 reserved;
770};
771
772struct ibv_destroy_qp_resp {
773	__u32 events_reported;
774};
775
776struct ibv_kern_send_wr {
777	__u64 wr_id;
778	__u32 num_sge;
779	__u32 opcode;
780	__u32 send_flags;
781	__u32 imm_data;
782	union {
783		struct {
784			__u64 remote_addr;
785			__u32 rkey;
786			__u32 reserved;
787		} rdma;
788		struct {
789			__u64 remote_addr;
790			__u64 compare_add;
791			__u64 swap;
792			__u32 rkey;
793			__u32 reserved;
794		} atomic;
795		struct {
796			__u32 ah;
797			__u32 remote_qpn;
798			__u32 remote_qkey;
799			__u32 reserved;
800		} ud;
801	} wr;
802	union {
803		struct {
804			__u32 remote_srqn;
805		} xrc;
806	} qp_type;
807};
808
809struct ibv_kern_eth_filter {
810	__u8  dst_mac[6];
811	__u8  src_mac[6];
812	__u16  ether_type;
813	__u16  vlan_tag;
814};
815
816struct ibv_kern_spec_eth {
817	__u32 type;
818	__u16  size;
819	__u16 reserved;
820	struct ibv_kern_eth_filter val;
821	struct ibv_kern_eth_filter mask;
822};
823
824struct ibv_kern_ib_filter {
825	__u32 qpn;
826	__u8  dst_gid[16];
827};
828
829struct ibv_kern_spec_ib {
830	__u32  type;
831	__u16  size;
832	__u16 reserved;
833	struct ibv_kern_ib_filter val;
834	struct ibv_kern_ib_filter mask;
835};
836
837struct ibv_kern_ipv4_filter {
838	__u32 src_ip;
839	__u32 dst_ip;
840};
841
842struct ibv_kern_spec_ipv4 {
843	__u32  type;
844	__u16  size;
845	__u16 reserved;
846	struct ibv_kern_ipv4_filter val;
847	struct ibv_kern_ipv4_filter mask;
848};
849
850struct ibv_kern_tcp_udp_filter {
851	__u16 dst_port;
852	__u16 src_port;
853};
854
855struct ibv_kern_spec_tcp_udp {
856	__u32  type;
857	__u16  size;
858	__u16 reserved;
859	struct ibv_kern_tcp_udp_filter val;
860	struct ibv_kern_tcp_udp_filter mask;
861};
862
863
864struct ibv_kern_spec {
865	union {
866		struct {
867			__u32 type;
868			__u16 size;
869			__u16 reserved;
870		} hdr;
871		struct ibv_kern_spec_ib ib;
872		struct ibv_kern_spec_eth eth;
873		struct ibv_kern_spec_ipv4 ipv4;
874		struct ibv_kern_spec_tcp_udp tcp_udp;
875	};
876
877};
878
879struct ibv_kern_flow_attr {
880	__u32 type;
881	__u16 size;
882	__u16 priority;
883	__u8 num_of_specs;
884	__u8 reserved[2];
885	__u8 port;
886	__u32 flags;
887	/* Following are the optional layers according to user request
888	 * struct ibv_kern_flow_spec_xxx
889	 * struct ibv_kern_flow_spec_yyy
890	 */
891};
892
893struct ibv_post_send {
894	__u32 command;
895	__u16 in_words;
896	__u16 out_words;
897	__u64 response;
898	__u32 qp_handle;
899	__u32 wr_count;
900	__u32 sge_count;
901	__u32 wqe_size;
902	struct ibv_kern_send_wr send_wr[0];
903};
904
905struct ibv_post_send_resp {
906	__u32 bad_wr;
907};
908
909struct ibv_kern_recv_wr {
910	__u64 wr_id;
911	__u32 num_sge;
912	__u32 reserved;
913};
914
915struct ibv_post_recv {
916	__u32 command;
917	__u16 in_words;
918	__u16 out_words;
919	__u64 response;
920	__u32 qp_handle;
921	__u32 wr_count;
922	__u32 sge_count;
923	__u32 wqe_size;
924	struct ibv_kern_recv_wr recv_wr[0];
925};
926
927struct ibv_post_recv_resp {
928	__u32 bad_wr;
929};
930
931struct ibv_post_srq_recv {
932	__u32 command;
933	__u16 in_words;
934	__u16 out_words;
935	__u64 response;
936	__u32 srq_handle;
937	__u32 wr_count;
938	__u32 sge_count;
939	__u32 wqe_size;
940	struct ibv_kern_recv_wr recv_wr[0];
941};
942
943struct ibv_post_srq_recv_resp {
944	__u32 bad_wr;
945};
946
947struct ibv_create_ah {
948	__u32 command;
949	__u16 in_words;
950	__u16 out_words;
951	__u64 response;
952	__u64 user_handle;
953	__u32 pd_handle;
954	__u32 reserved;
955	struct ibv_kern_ah_attr attr;
956};
957
958struct ibv_create_ah_resp {
959	__u32 handle;
960};
961
962struct ibv_destroy_ah {
963	__u32 command;
964	__u16 in_words;
965	__u16 out_words;
966	__u32 ah_handle;
967};
968
969struct ibv_attach_mcast {
970	__u32 command;
971	__u16 in_words;
972	__u16 out_words;
973	__u8  gid[16];
974	__u32 qp_handle;
975	__u16 mlid;
976	__u16 reserved;
977	__u64 driver_data[0];
978};
979
980struct ibv_detach_mcast {
981	__u32 command;
982	__u16 in_words;
983	__u16 out_words;
984	__u8  gid[16];
985	__u32 qp_handle;
986	__u16 mlid;
987	__u16 reserved;
988	__u64 driver_data[0];
989};
990
991struct ibv_create_flow  {
992	struct ex_hdr hdr;
993	__u32 comp_mask;
994	__u32 qp_handle;
995	struct ibv_kern_flow_attr flow_attr;
996};
997
998struct ibv_create_flow_resp {
999	__u32 comp_mask;
1000	__u32 flow_handle;
1001};
1002
1003struct ibv_destroy_flow  {
1004	struct ex_hdr hdr;
1005	__u32 comp_mask;
1006	__u32 flow_handle;
1007};
1008
1009struct ibv_create_srq {
1010	__u32 command;
1011	__u16 in_words;
1012	__u16 out_words;
1013	__u64 response;
1014	__u64 user_handle;
1015	__u32 pd_handle;
1016	__u32 max_wr;
1017	__u32 max_sge;
1018	__u32 srq_limit;
1019	__u64 driver_data[0];
1020};
1021
1022struct ibv_create_xsrq {
1023	__u32 command;
1024	__u16 in_words;
1025	__u16 out_words;
1026	__u64 response;
1027	__u64 user_handle;
1028	__u32 srq_type;
1029	__u32 pd_handle;
1030	__u32 max_wr;
1031	__u32 max_sge;
1032	__u32 srq_limit;
1033	__u32 reserved;
1034	__u32 xrcd_handle;
1035	__u32 cq_handle;
1036	__u64 driver_data[0];
1037};
1038
1039struct ibv_create_srq_resp {
1040	__u32 srq_handle;
1041	__u32 max_wr;
1042	__u32 max_sge;
1043	__u32 srqn;
1044};
1045
1046struct ibv_modify_srq {
1047	__u32 command;
1048	__u16 in_words;
1049	__u16 out_words;
1050	__u32 srq_handle;
1051	__u32 attr_mask;
1052	__u32 max_wr;
1053	__u32 srq_limit;
1054	__u64 driver_data[0];
1055};
1056
1057struct ibv_query_srq {
1058	__u32 command;
1059	__u16 in_words;
1060	__u16 out_words;
1061	__u64 response;
1062	__u32 srq_handle;
1063	__u32 reserved;
1064	__u64 driver_data[0];
1065};
1066
1067struct ibv_query_srq_resp {
1068	__u32 max_wr;
1069	__u32 max_sge;
1070	__u32 srq_limit;
1071	__u32 reserved;
1072};
1073
1074struct ibv_destroy_srq {
1075	__u32 command;
1076	__u16 in_words;
1077	__u16 out_words;
1078	__u64 response;
1079	__u32 srq_handle;
1080	__u32 reserved;
1081};
1082
1083struct ibv_destroy_srq_resp {
1084	__u32 events_reported;
1085};
1086
1087/*
1088 * Compatibility with older ABI versions
1089 */
1090
1091enum {
1092	IB_USER_VERBS_CMD_QUERY_PARAMS_V2,
1093	IB_USER_VERBS_CMD_GET_CONTEXT_V2,
1094	IB_USER_VERBS_CMD_QUERY_DEVICE_V2,
1095	IB_USER_VERBS_CMD_QUERY_PORT_V2,
1096	IB_USER_VERBS_CMD_QUERY_GID_V2,
1097	IB_USER_VERBS_CMD_QUERY_PKEY_V2,
1098	IB_USER_VERBS_CMD_ALLOC_PD_V2,
1099	IB_USER_VERBS_CMD_DEALLOC_PD_V2,
1100	IB_USER_VERBS_CMD_CREATE_AH_V2,
1101	IB_USER_VERBS_CMD_MODIFY_AH_V2,
1102	IB_USER_VERBS_CMD_QUERY_AH_V2,
1103	IB_USER_VERBS_CMD_DESTROY_AH_V2,
1104	IB_USER_VERBS_CMD_REG_MR_V2,
1105	IB_USER_VERBS_CMD_REG_SMR_V2,
1106	IB_USER_VERBS_CMD_REREG_MR_V2,
1107	IB_USER_VERBS_CMD_QUERY_MR_V2,
1108	IB_USER_VERBS_CMD_DEREG_MR_V2,
1109	IB_USER_VERBS_CMD_ALLOC_MW_V2,
1110	IB_USER_VERBS_CMD_BIND_MW_V2,
1111	IB_USER_VERBS_CMD_DEALLOC_MW_V2,
1112	IB_USER_VERBS_CMD_CREATE_CQ_V2,
1113	IB_USER_VERBS_CMD_RESIZE_CQ_V2,
1114	IB_USER_VERBS_CMD_DESTROY_CQ_V2,
1115	IB_USER_VERBS_CMD_POLL_CQ_V2,
1116	IB_USER_VERBS_CMD_PEEK_CQ_V2,
1117	IB_USER_VERBS_CMD_REQ_NOTIFY_CQ_V2,
1118	IB_USER_VERBS_CMD_CREATE_QP_V2,
1119	IB_USER_VERBS_CMD_QUERY_QP_V2,
1120	IB_USER_VERBS_CMD_MODIFY_QP_V2,
1121	IB_USER_VERBS_CMD_DESTROY_QP_V2,
1122	IB_USER_VERBS_CMD_POST_SEND_V2,
1123	IB_USER_VERBS_CMD_POST_RECV_V2,
1124	IB_USER_VERBS_CMD_ATTACH_MCAST_V2,
1125	IB_USER_VERBS_CMD_DETACH_MCAST_V2,
1126	IB_USER_VERBS_CMD_CREATE_SRQ_V2,
1127	IB_USER_VERBS_CMD_MODIFY_SRQ_V2,
1128	IB_USER_VERBS_CMD_QUERY_SRQ_V2,
1129	IB_USER_VERBS_CMD_DESTROY_SRQ_V2,
1130	IB_USER_VERBS_CMD_POST_SRQ_RECV_V2,
1131	/*
1132	 * Set commands that didn't exist to -1 so our compile-time
1133	 * trick opcodes in IBV_INIT_CMD() doesn't break.
1134	 */
1135	IB_USER_VERBS_CMD_CREATE_COMP_CHANNEL_V2 = -1,
1136	IB_USER_VERBS_CMD_CREATE_QP_EX_V2 = -1,
1137	IB_USER_VERBS_CMD_MODIFY_CQ_EX_V2 = -1,
1138	IB_USER_VERBS_CMD_CREATE_FLOW_V2 = -1,
1139	IB_USER_VERBS_CMD_DESTROY_FLOW_V2 = -1,
1140	IB_USER_VERBS_CMD_OPEN_XRCD_V2 = -1,
1141	IB_USER_VERBS_CMD_CLOSE_XRCD_V2 = -1,
1142	IB_USER_VERBS_CMD_CREATE_XSRQ_V2 = -1,
1143	IB_USER_VERBS_CMD_OPEN_QP_V2 = -1,
1144	IB_USER_VERBS_CMD_MODIFY_QP_EX_V2 = -1,
1145	IB_USER_VERBS_CMD_CREATE_CQ_EX_V2 = -1,
1146	IB_USER_VERBS_CMD_QUERY_DEVICE_EX_V2 = -1,
1147	IB_USER_VERBS_CMD_CREATE_DCT_V2 = -1,
1148	IB_USER_VERBS_CMD_DESTROY_DCT_V2 = -1,
1149	IB_USER_VERBS_CMD_QUERY_DCT_V2 = -1,
1150	IB_USER_VERBS_CMD_EXP_REG_MR_V2 = -1,
1151	IB_USER_VERBS_CMD_EXP_PREFETCH_MR_V2 = -1,
1152};
1153
1154struct ibv_modify_srq_v3 {
1155	__u32 command;
1156	__u16 in_words;
1157	__u16 out_words;
1158	__u32 srq_handle;
1159	__u32 attr_mask;
1160	__u32 max_wr;
1161	__u32 max_sge;
1162	__u32 srq_limit;
1163	__u32 reserved;
1164	__u64 driver_data[0];
1165};
1166
1167struct ibv_create_qp_resp_v3 {
1168	__u32 qp_handle;
1169	__u32 qpn;
1170};
1171
1172struct ibv_create_qp_resp_v4 {
1173	__u32 qp_handle;
1174	__u32 qpn;
1175	__u32 max_send_wr;
1176	__u32 max_recv_wr;
1177	__u32 max_send_sge;
1178	__u32 max_recv_sge;
1179	__u32 max_inline_data;
1180};
1181
1182struct ibv_create_srq_resp_v5 {
1183	__u32 srq_handle;
1184};
1185
1186#endif /* KERN_ABI_H */
1187