1 /* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) */
2 /*
3  * Copyright 2018-2024 Amazon.com, Inc. or its affiliates. All rights reserved.
4  */
5 
6 #ifndef EFA_ABI_USER_H
7 #define EFA_ABI_USER_H
8 
9 #include <linux/types.h>
10 #include <rdma/ib_user_ioctl_cmds.h>
11 
12 /*
13  * Increment this value if any changes that break userspace ABI
14  * compatibility are made.
15  */
16 #define EFA_UVERBS_ABI_VERSION 1
17 
18 /*
19  * Keep structs aligned to 8 bytes.
20  * Keep reserved fields as arrays of __u8 named reserved_XXX where XXX is the
21  * hex bit offset of the field.
22  */
23 
24 enum {
25 	EFA_ALLOC_UCONTEXT_CMD_COMP_TX_BATCH  = 1 << 0,
26 	EFA_ALLOC_UCONTEXT_CMD_COMP_MIN_SQ_WR = 1 << 1,
27 };
28 
29 struct efa_ibv_alloc_ucontext_cmd {
30 	__u32 comp_mask;
31 	__u8 reserved_20[4];
32 };
33 
34 enum efa_ibv_user_cmds_supp_udata {
35 	EFA_USER_CMDS_SUPP_UDATA_QUERY_DEVICE = 1 << 0,
36 	EFA_USER_CMDS_SUPP_UDATA_CREATE_AH    = 1 << 1,
37 };
38 
39 struct efa_ibv_alloc_ucontext_resp {
40 	__u32 comp_mask;
41 	__u32 cmds_supp_udata_mask;
42 	__u16 sub_cqs_per_cq;
43 	__u16 inline_buf_size;
44 	__u32 max_llq_size; /* bytes */
45 	__u16 max_tx_batch; /* units of 64 bytes */
46 	__u16 min_sq_wr;
47 	__u8 reserved_a0[4];
48 };
49 
50 struct efa_ibv_alloc_pd_resp {
51 	__u32 comp_mask;
52 	__u16 pdn;
53 	__u8 reserved_30[2];
54 };
55 
56 enum {
57 	EFA_CREATE_CQ_WITH_COMPLETION_CHANNEL = 1 << 0,
58 	EFA_CREATE_CQ_WITH_SGID               = 1 << 1,
59 };
60 
61 struct efa_ibv_create_cq {
62 	__u32 comp_mask;
63 	__u32 cq_entry_size;
64 	__u16 num_sub_cqs;
65 	__u8 flags;
66 	__u8 reserved_58[5];
67 };
68 
69 enum {
70 	EFA_CREATE_CQ_RESP_DB_OFF = 1 << 0,
71 };
72 
73 struct efa_ibv_create_cq_resp {
74 	__u32 comp_mask;
75 	__u8 reserved_20[4];
76 	__aligned_u64 q_mmap_key;
77 	__aligned_u64 q_mmap_size;
78 	__u16 cq_idx;
79 	__u8 reserved_d0[2];
80 	__u32 db_off;
81 	__aligned_u64 db_mmap_key;
82 };
83 
84 enum {
85 	EFA_QP_DRIVER_TYPE_SRD = 0,
86 };
87 
88 enum {
89 	EFA_CREATE_QP_WITH_UNSOLICITED_WRITE_RECV = 1 << 0,
90 };
91 
92 struct efa_ibv_create_qp {
93 	__u32 comp_mask;
94 	__u32 rq_ring_size; /* bytes */
95 	__u32 sq_ring_size; /* bytes */
96 	__u32 driver_qp_type;
97 	__u16 flags;
98 	__u8 reserved_90[6];
99 };
100 
101 struct efa_ibv_create_qp_resp {
102 	__u32 comp_mask;
103 	/* the offset inside the page of the rq db */
104 	__u32 rq_db_offset;
105 	/* the offset inside the page of the sq db */
106 	__u32 sq_db_offset;
107 	/* the offset inside the page of descriptors buffer */
108 	__u32 llq_desc_offset;
109 	__aligned_u64 rq_mmap_key;
110 	__aligned_u64 rq_mmap_size;
111 	__aligned_u64 rq_db_mmap_key;
112 	__aligned_u64 sq_db_mmap_key;
113 	__aligned_u64 llq_desc_mmap_key;
114 	__u16 send_sub_cq_idx;
115 	__u16 recv_sub_cq_idx;
116 	__u8 reserved_1e0[4];
117 };
118 
119 struct efa_ibv_create_ah_resp {
120 	__u32 comp_mask;
121 	__u16 efa_address_handle;
122 	__u8 reserved_30[2];
123 };
124 
125 enum {
126 	EFA_QUERY_DEVICE_CAPS_RDMA_READ = 1 << 0,
127 	EFA_QUERY_DEVICE_CAPS_RNR_RETRY = 1 << 1,
128 	EFA_QUERY_DEVICE_CAPS_CQ_NOTIFICATIONS = 1 << 2,
129 	EFA_QUERY_DEVICE_CAPS_CQ_WITH_SGID     = 1 << 3,
130 	EFA_QUERY_DEVICE_CAPS_DATA_POLLING_128 = 1 << 4,
131 	EFA_QUERY_DEVICE_CAPS_RDMA_WRITE = 1 << 5,
132 	EFA_QUERY_DEVICE_CAPS_UNSOLICITED_WRITE_RECV = 1 << 6,
133 };
134 
135 struct efa_ibv_ex_query_device_resp {
136 	__u32 comp_mask;
137 	__u32 max_sq_wr;
138 	__u32 max_rq_wr;
139 	__u16 max_sq_sge;
140 	__u16 max_rq_sge;
141 	__u32 max_rdma_size;
142 	__u32 device_caps;
143 };
144 
145 enum {
146 	EFA_QUERY_MR_VALIDITY_RECV_IC_ID = 1 << 0,
147 	EFA_QUERY_MR_VALIDITY_RDMA_READ_IC_ID = 1 << 1,
148 	EFA_QUERY_MR_VALIDITY_RDMA_RECV_IC_ID = 1 << 2,
149 };
150 
151 enum efa_query_mr_attrs {
152 	EFA_IB_ATTR_QUERY_MR_HANDLE = (1U << UVERBS_ID_NS_SHIFT),
153 	EFA_IB_ATTR_QUERY_MR_RESP_IC_ID_VALIDITY,
154 	EFA_IB_ATTR_QUERY_MR_RESP_RECV_IC_ID,
155 	EFA_IB_ATTR_QUERY_MR_RESP_RDMA_READ_IC_ID,
156 	EFA_IB_ATTR_QUERY_MR_RESP_RDMA_RECV_IC_ID,
157 };
158 
159 enum efa_mr_methods {
160 	EFA_IB_METHOD_MR_QUERY = (1U << UVERBS_ID_NS_SHIFT),
161 };
162 
163 #endif /* EFA_ABI_USER_H */
164