Loading...
1/* SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause */
2/*
3 * Copyright 2018-2024 Amazon.com, Inc. or its affiliates. All rights reserved.
4 */
5
6#ifndef _EFA_COM_CMD_H_
7#define _EFA_COM_CMD_H_
8
9#include "efa_com.h"
10
11#define EFA_GID_SIZE 16
12
13struct efa_com_create_qp_params {
14 u64 rq_base_addr;
15 u32 send_cq_idx;
16 u32 recv_cq_idx;
17 /*
18 * Send descriptor ring size in bytes,
19 * sufficient for user-provided number of WQEs and SGL size
20 */
21 u32 sq_ring_size_in_bytes;
22 /* Max number of WQEs that will be posted on send queue */
23 u32 sq_depth;
24 /* Recv descriptor ring size in bytes */
25 u32 rq_ring_size_in_bytes;
26 u32 rq_depth;
27 u16 pd;
28 u16 uarn;
29 u8 qp_type;
30};
31
32struct efa_com_create_qp_result {
33 u32 qp_handle;
34 u32 qp_num;
35 u32 sq_db_offset;
36 u32 rq_db_offset;
37 u32 llq_descriptors_offset;
38 u16 send_sub_cq_idx;
39 u16 recv_sub_cq_idx;
40};
41
42struct efa_com_modify_qp_params {
43 u32 modify_mask;
44 u32 qp_handle;
45 u32 qp_state;
46 u32 cur_qp_state;
47 u32 qkey;
48 u32 sq_psn;
49 u8 sq_drained_async_notify;
50 u8 rnr_retry;
51};
52
53struct efa_com_query_qp_params {
54 u32 qp_handle;
55};
56
57struct efa_com_query_qp_result {
58 u32 qp_state;
59 u32 qkey;
60 u32 sq_draining;
61 u32 sq_psn;
62 u8 rnr_retry;
63};
64
65struct efa_com_destroy_qp_params {
66 u32 qp_handle;
67};
68
69struct efa_com_create_cq_params {
70 /* cq physical base address in OS memory */
71 dma_addr_t dma_addr;
72 /* completion queue depth in # of entries */
73 u16 cq_depth;
74 u16 num_sub_cqs;
75 u16 uarn;
76 u16 eqn;
77 u8 entry_size_in_bytes;
78 u8 interrupt_mode_enabled : 1;
79 u8 set_src_addr : 1;
80};
81
82struct efa_com_create_cq_result {
83 /* cq identifier */
84 u16 cq_idx;
85 /* actual cq depth in # of entries */
86 u16 actual_depth;
87 u32 db_off;
88 bool db_valid;
89};
90
91struct efa_com_destroy_cq_params {
92 u16 cq_idx;
93};
94
95struct efa_com_create_ah_params {
96 u16 pdn;
97 /* Destination address in network byte order */
98 u8 dest_addr[EFA_GID_SIZE];
99};
100
101struct efa_com_create_ah_result {
102 u16 ah;
103};
104
105struct efa_com_destroy_ah_params {
106 u16 ah;
107 u16 pdn;
108};
109
110struct efa_com_get_device_attr_result {
111 u8 addr[EFA_GID_SIZE];
112 u64 page_size_cap;
113 u64 max_mr_pages;
114 u32 mtu;
115 u32 fw_version;
116 u32 admin_api_version;
117 u32 device_version;
118 u32 supported_features;
119 u32 phys_addr_width;
120 u32 virt_addr_width;
121 u32 max_qp;
122 u32 max_sq_depth; /* wqes */
123 u32 max_rq_depth; /* wqes */
124 u32 max_cq;
125 u32 max_cq_depth; /* cqes */
126 u32 inline_buf_size;
127 u32 max_mr;
128 u32 max_pd;
129 u32 max_ah;
130 u32 max_llq_size;
131 u32 max_rdma_size;
132 u32 device_caps;
133 u32 max_eq;
134 u32 max_eq_depth;
135 u32 event_bitmask; /* EQ events bitmask */
136 u16 sub_cqs_per_cq;
137 u16 max_sq_sge;
138 u16 max_rq_sge;
139 u16 max_wr_rdma_sge;
140 u16 max_tx_batch;
141 u16 min_sq_depth;
142 u8 db_bar;
143};
144
145struct efa_com_get_hw_hints_result {
146 u16 mmio_read_timeout;
147 u16 driver_watchdog_timeout;
148 u16 admin_completion_timeout;
149 u16 poll_interval;
150 u32 reserved[4];
151};
152
153struct efa_com_mem_addr {
154 u32 mem_addr_low;
155 u32 mem_addr_high;
156};
157
158/* Used at indirect mode page list chunks for chaining */
159struct efa_com_ctrl_buff_info {
160 /* indicates length of the buffer pointed by control_buffer_address. */
161 u32 length;
162 /* points to control buffer (direct or indirect) */
163 struct efa_com_mem_addr address;
164};
165
166struct efa_com_reg_mr_params {
167 /* Memory region length, in bytes. */
168 u64 mr_length_in_bytes;
169 /* IO Virtual Address associated with this MR. */
170 u64 iova;
171 /* words 8:15: Physical Buffer List, each element is page-aligned. */
172 union {
173 /*
174 * Inline array of physical addresses of app pages
175 * (optimization for short region reservations)
176 */
177 u64 inline_pbl_array[4];
178 /*
179 * Describes the next physically contiguous chunk of indirect
180 * page list. A page list contains physical addresses of command
181 * data pages. Data pages are 4KB; page list chunks are
182 * variable-sized.
183 */
184 struct efa_com_ctrl_buff_info pbl;
185 } pbl;
186 /* number of pages in PBL (redundant, could be calculated) */
187 u32 page_num;
188 /* Protection Domain */
189 u16 pd;
190 /*
191 * phys_page_size_shift - page size is (1 << phys_page_size_shift)
192 * Page size is used for building the Virtual to Physical
193 * address mapping
194 */
195 u8 page_shift;
196 /* see permissions field of struct efa_admin_reg_mr_cmd */
197 u8 permissions;
198 u8 inline_pbl;
199 u8 indirect;
200};
201
202struct efa_com_mr_interconnect_info {
203 u16 recv_ic_id;
204 u16 rdma_read_ic_id;
205 u16 rdma_recv_ic_id;
206 u8 recv_ic_id_valid : 1;
207 u8 rdma_read_ic_id_valid : 1;
208 u8 rdma_recv_ic_id_valid : 1;
209};
210
211struct efa_com_reg_mr_result {
212 /*
213 * To be used in conjunction with local buffers references in SQ and
214 * RQ WQE
215 */
216 u32 l_key;
217 /*
218 * To be used in incoming RDMA semantics messages to refer to remotely
219 * accessed memory region
220 */
221 u32 r_key;
222 struct efa_com_mr_interconnect_info ic_info;
223};
224
225struct efa_com_dereg_mr_params {
226 u32 l_key;
227};
228
229struct efa_com_alloc_pd_result {
230 u16 pdn;
231};
232
233struct efa_com_dealloc_pd_params {
234 u16 pdn;
235};
236
237struct efa_com_alloc_uar_result {
238 u16 uarn;
239};
240
241struct efa_com_dealloc_uar_params {
242 u16 uarn;
243};
244
245struct efa_com_get_stats_params {
246 /* see enum efa_admin_get_stats_type */
247 u8 type;
248 /* see enum efa_admin_get_stats_scope */
249 u8 scope;
250 u16 scope_modifier;
251};
252
253struct efa_com_basic_stats {
254 u64 tx_bytes;
255 u64 tx_pkts;
256 u64 rx_bytes;
257 u64 rx_pkts;
258 u64 rx_drops;
259};
260
261struct efa_com_messages_stats {
262 u64 send_bytes;
263 u64 send_wrs;
264 u64 recv_bytes;
265 u64 recv_wrs;
266};
267
268struct efa_com_rdma_read_stats {
269 u64 read_wrs;
270 u64 read_bytes;
271 u64 read_wr_err;
272 u64 read_resp_bytes;
273};
274
275struct efa_com_rdma_write_stats {
276 u64 write_wrs;
277 u64 write_bytes;
278 u64 write_wr_err;
279 u64 write_recv_bytes;
280};
281
282union efa_com_get_stats_result {
283 struct efa_com_basic_stats basic_stats;
284 struct efa_com_messages_stats messages_stats;
285 struct efa_com_rdma_read_stats rdma_read_stats;
286 struct efa_com_rdma_write_stats rdma_write_stats;
287};
288
289int efa_com_create_qp(struct efa_com_dev *edev,
290 struct efa_com_create_qp_params *params,
291 struct efa_com_create_qp_result *res);
292int efa_com_modify_qp(struct efa_com_dev *edev,
293 struct efa_com_modify_qp_params *params);
294int efa_com_query_qp(struct efa_com_dev *edev,
295 struct efa_com_query_qp_params *params,
296 struct efa_com_query_qp_result *result);
297int efa_com_destroy_qp(struct efa_com_dev *edev,
298 struct efa_com_destroy_qp_params *params);
299int efa_com_create_cq(struct efa_com_dev *edev,
300 struct efa_com_create_cq_params *params,
301 struct efa_com_create_cq_result *result);
302int efa_com_destroy_cq(struct efa_com_dev *edev,
303 struct efa_com_destroy_cq_params *params);
304int efa_com_register_mr(struct efa_com_dev *edev,
305 struct efa_com_reg_mr_params *params,
306 struct efa_com_reg_mr_result *result);
307int efa_com_dereg_mr(struct efa_com_dev *edev,
308 struct efa_com_dereg_mr_params *params);
309int efa_com_create_ah(struct efa_com_dev *edev,
310 struct efa_com_create_ah_params *params,
311 struct efa_com_create_ah_result *result);
312int efa_com_destroy_ah(struct efa_com_dev *edev,
313 struct efa_com_destroy_ah_params *params);
314int efa_com_get_device_attr(struct efa_com_dev *edev,
315 struct efa_com_get_device_attr_result *result);
316int efa_com_get_hw_hints(struct efa_com_dev *edev,
317 struct efa_com_get_hw_hints_result *result);
318bool
319efa_com_check_supported_feature_id(struct efa_com_dev *edev,
320 enum efa_admin_aq_feature_id feature_id);
321int efa_com_set_feature_ex(struct efa_com_dev *edev,
322 struct efa_admin_set_feature_resp *set_resp,
323 struct efa_admin_set_feature_cmd *set_cmd,
324 enum efa_admin_aq_feature_id feature_id,
325 dma_addr_t control_buf_dma_addr,
326 u32 control_buff_size);
327int efa_com_set_aenq_config(struct efa_com_dev *edev, u32 groups);
328int efa_com_alloc_pd(struct efa_com_dev *edev,
329 struct efa_com_alloc_pd_result *result);
330int efa_com_dealloc_pd(struct efa_com_dev *edev,
331 struct efa_com_dealloc_pd_params *params);
332int efa_com_alloc_uar(struct efa_com_dev *edev,
333 struct efa_com_alloc_uar_result *result);
334int efa_com_dealloc_uar(struct efa_com_dev *edev,
335 struct efa_com_dealloc_uar_params *params);
336int efa_com_get_stats(struct efa_com_dev *edev,
337 struct efa_com_get_stats_params *params,
338 union efa_com_get_stats_result *result);
339
340#endif /* _EFA_COM_CMD_H_ */
1/* SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause */
2/*
3 * Copyright 2018-2019 Amazon.com, Inc. or its affiliates. All rights reserved.
4 */
5
6#ifndef _EFA_COM_CMD_H_
7#define _EFA_COM_CMD_H_
8
9#include "efa_com.h"
10
11#define EFA_GID_SIZE 16
12
13struct efa_com_create_qp_params {
14 u64 rq_base_addr;
15 u32 send_cq_idx;
16 u32 recv_cq_idx;
17 /*
18 * Send descriptor ring size in bytes,
19 * sufficient for user-provided number of WQEs and SGL size
20 */
21 u32 sq_ring_size_in_bytes;
22 /* Max number of WQEs that will be posted on send queue */
23 u32 sq_depth;
24 /* Recv descriptor ring size in bytes */
25 u32 rq_ring_size_in_bytes;
26 u32 rq_depth;
27 u16 pd;
28 u16 uarn;
29 u8 qp_type;
30};
31
32struct efa_com_create_qp_result {
33 u32 qp_handle;
34 u32 qp_num;
35 u32 sq_db_offset;
36 u32 rq_db_offset;
37 u32 llq_descriptors_offset;
38 u16 send_sub_cq_idx;
39 u16 recv_sub_cq_idx;
40};
41
42struct efa_com_modify_qp_params {
43 u32 modify_mask;
44 u32 qp_handle;
45 u32 qp_state;
46 u32 cur_qp_state;
47 u32 qkey;
48 u32 sq_psn;
49 u8 sq_drained_async_notify;
50};
51
52struct efa_com_query_qp_params {
53 u32 qp_handle;
54};
55
56struct efa_com_query_qp_result {
57 u32 qp_state;
58 u32 qkey;
59 u32 sq_draining;
60 u32 sq_psn;
61};
62
63struct efa_com_destroy_qp_params {
64 u32 qp_handle;
65};
66
67struct efa_com_create_cq_params {
68 /* cq physical base address in OS memory */
69 dma_addr_t dma_addr;
70 /* completion queue depth in # of entries */
71 u16 cq_depth;
72 u16 num_sub_cqs;
73 u16 uarn;
74 u8 entry_size_in_bytes;
75};
76
77struct efa_com_create_cq_result {
78 /* cq identifier */
79 u16 cq_idx;
80 /* actual cq depth in # of entries */
81 u16 actual_depth;
82};
83
84struct efa_com_destroy_cq_params {
85 u16 cq_idx;
86};
87
88struct efa_com_create_ah_params {
89 u16 pdn;
90 /* Destination address in network byte order */
91 u8 dest_addr[EFA_GID_SIZE];
92};
93
94struct efa_com_create_ah_result {
95 u16 ah;
96};
97
98struct efa_com_destroy_ah_params {
99 u16 ah;
100 u16 pdn;
101};
102
103struct efa_com_get_network_attr_result {
104 u8 addr[EFA_GID_SIZE];
105 u32 mtu;
106};
107
108struct efa_com_get_device_attr_result {
109 u64 page_size_cap;
110 u64 max_mr_pages;
111 u32 fw_version;
112 u32 admin_api_version;
113 u32 device_version;
114 u32 supported_features;
115 u32 phys_addr_width;
116 u32 virt_addr_width;
117 u32 max_qp;
118 u32 max_sq_depth; /* wqes */
119 u32 max_rq_depth; /* wqes */
120 u32 max_cq;
121 u32 max_cq_depth; /* cqes */
122 u32 inline_buf_size;
123 u32 max_mr;
124 u32 max_pd;
125 u32 max_ah;
126 u32 max_llq_size;
127 u16 sub_cqs_per_cq;
128 u16 max_sq_sge;
129 u16 max_rq_sge;
130 u8 db_bar;
131};
132
133struct efa_com_get_hw_hints_result {
134 u16 mmio_read_timeout;
135 u16 driver_watchdog_timeout;
136 u16 admin_completion_timeout;
137 u16 poll_interval;
138 u32 reserved[4];
139};
140
141struct efa_com_mem_addr {
142 u32 mem_addr_low;
143 u32 mem_addr_high;
144};
145
146/* Used at indirect mode page list chunks for chaining */
147struct efa_com_ctrl_buff_info {
148 /* indicates length of the buffer pointed by control_buffer_address. */
149 u32 length;
150 /* points to control buffer (direct or indirect) */
151 struct efa_com_mem_addr address;
152};
153
154struct efa_com_reg_mr_params {
155 /* Memory region length, in bytes. */
156 u64 mr_length_in_bytes;
157 /* IO Virtual Address associated with this MR. */
158 u64 iova;
159 /* words 8:15: Physical Buffer List, each element is page-aligned. */
160 union {
161 /*
162 * Inline array of physical addresses of app pages
163 * (optimization for short region reservations)
164 */
165 u64 inline_pbl_array[4];
166 /*
167 * Describes the next physically contiguous chunk of indirect
168 * page list. A page list contains physical addresses of command
169 * data pages. Data pages are 4KB; page list chunks are
170 * variable-sized.
171 */
172 struct efa_com_ctrl_buff_info pbl;
173 } pbl;
174 /* number of pages in PBL (redundant, could be calculated) */
175 u32 page_num;
176 /* Protection Domain */
177 u16 pd;
178 /*
179 * phys_page_size_shift - page size is (1 << phys_page_size_shift)
180 * Page size is used for building the Virtual to Physical
181 * address mapping
182 */
183 u8 page_shift;
184 /*
185 * permissions
186 * 0: local_write_enable - Write permissions: value of 1 needed
187 * for RQ buffers and for RDMA write:1: reserved1 - remote
188 * access flags, etc
189 */
190 u8 permissions;
191 u8 inline_pbl;
192 u8 indirect;
193};
194
195struct efa_com_reg_mr_result {
196 /*
197 * To be used in conjunction with local buffers references in SQ and
198 * RQ WQE
199 */
200 u32 l_key;
201 /*
202 * To be used in incoming RDMA semantics messages to refer to remotely
203 * accessed memory region
204 */
205 u32 r_key;
206};
207
208struct efa_com_dereg_mr_params {
209 u32 l_key;
210};
211
212struct efa_com_alloc_pd_result {
213 u16 pdn;
214};
215
216struct efa_com_dealloc_pd_params {
217 u16 pdn;
218};
219
220struct efa_com_alloc_uar_result {
221 u16 uarn;
222};
223
224struct efa_com_dealloc_uar_params {
225 u16 uarn;
226};
227
228struct efa_com_get_stats_params {
229 /* see enum efa_admin_get_stats_type */
230 u8 type;
231 /* see enum efa_admin_get_stats_scope */
232 u8 scope;
233 u16 scope_modifier;
234};
235
236struct efa_com_basic_stats {
237 u64 tx_bytes;
238 u64 tx_pkts;
239 u64 rx_bytes;
240 u64 rx_pkts;
241 u64 rx_drops;
242};
243
244union efa_com_get_stats_result {
245 struct efa_com_basic_stats basic_stats;
246};
247
248void efa_com_set_dma_addr(dma_addr_t addr, u32 *addr_high, u32 *addr_low);
249int efa_com_create_qp(struct efa_com_dev *edev,
250 struct efa_com_create_qp_params *params,
251 struct efa_com_create_qp_result *res);
252int efa_com_modify_qp(struct efa_com_dev *edev,
253 struct efa_com_modify_qp_params *params);
254int efa_com_query_qp(struct efa_com_dev *edev,
255 struct efa_com_query_qp_params *params,
256 struct efa_com_query_qp_result *result);
257int efa_com_destroy_qp(struct efa_com_dev *edev,
258 struct efa_com_destroy_qp_params *params);
259int efa_com_create_cq(struct efa_com_dev *edev,
260 struct efa_com_create_cq_params *params,
261 struct efa_com_create_cq_result *result);
262int efa_com_destroy_cq(struct efa_com_dev *edev,
263 struct efa_com_destroy_cq_params *params);
264int efa_com_register_mr(struct efa_com_dev *edev,
265 struct efa_com_reg_mr_params *params,
266 struct efa_com_reg_mr_result *result);
267int efa_com_dereg_mr(struct efa_com_dev *edev,
268 struct efa_com_dereg_mr_params *params);
269int efa_com_create_ah(struct efa_com_dev *edev,
270 struct efa_com_create_ah_params *params,
271 struct efa_com_create_ah_result *result);
272int efa_com_destroy_ah(struct efa_com_dev *edev,
273 struct efa_com_destroy_ah_params *params);
274int efa_com_get_network_attr(struct efa_com_dev *edev,
275 struct efa_com_get_network_attr_result *result);
276int efa_com_get_device_attr(struct efa_com_dev *edev,
277 struct efa_com_get_device_attr_result *result);
278int efa_com_get_hw_hints(struct efa_com_dev *edev,
279 struct efa_com_get_hw_hints_result *result);
280int efa_com_set_aenq_config(struct efa_com_dev *edev, u32 groups);
281int efa_com_alloc_pd(struct efa_com_dev *edev,
282 struct efa_com_alloc_pd_result *result);
283int efa_com_dealloc_pd(struct efa_com_dev *edev,
284 struct efa_com_dealloc_pd_params *params);
285int efa_com_alloc_uar(struct efa_com_dev *edev,
286 struct efa_com_alloc_uar_result *result);
287int efa_com_dealloc_uar(struct efa_com_dev *edev,
288 struct efa_com_dealloc_uar_params *params);
289int efa_com_get_stats(struct efa_com_dev *edev,
290 struct efa_com_get_stats_params *params,
291 union efa_com_get_stats_result *result);
292
293#endif /* _EFA_COM_CMD_H_ */