1 // SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause
3 * Copyright 2018-2020 Amazon.com, Inc. or its affiliates. All rights reserved.
7 #include "efa_com_cmd.h"
9 void efa_com_set_dma_addr(dma_addr_t addr
, u32
*addr_high
, u32
*addr_low
)
11 *addr_low
= lower_32_bits(addr
);
12 *addr_high
= upper_32_bits(addr
);
15 int efa_com_create_qp(struct efa_com_dev
*edev
,
16 struct efa_com_create_qp_params
*params
,
17 struct efa_com_create_qp_result
*res
)
19 struct efa_admin_create_qp_cmd create_qp_cmd
= {};
20 struct efa_admin_create_qp_resp cmd_completion
;
21 struct efa_com_admin_queue
*aq
= &edev
->aq
;
24 create_qp_cmd
.aq_common_desc
.opcode
= EFA_ADMIN_CREATE_QP
;
26 create_qp_cmd
.pd
= params
->pd
;
27 create_qp_cmd
.qp_type
= params
->qp_type
;
28 create_qp_cmd
.rq_base_addr
= params
->rq_base_addr
;
29 create_qp_cmd
.send_cq_idx
= params
->send_cq_idx
;
30 create_qp_cmd
.recv_cq_idx
= params
->recv_cq_idx
;
31 create_qp_cmd
.qp_alloc_size
.send_queue_ring_size
=
32 params
->sq_ring_size_in_bytes
;
33 create_qp_cmd
.qp_alloc_size
.send_queue_depth
=
35 create_qp_cmd
.qp_alloc_size
.recv_queue_ring_size
=
36 params
->rq_ring_size_in_bytes
;
37 create_qp_cmd
.qp_alloc_size
.recv_queue_depth
=
39 create_qp_cmd
.uar
= params
->uarn
;
41 err
= efa_com_cmd_exec(aq
,
42 (struct efa_admin_aq_entry
*)&create_qp_cmd
,
43 sizeof(create_qp_cmd
),
44 (struct efa_admin_acq_entry
*)&cmd_completion
,
45 sizeof(cmd_completion
));
47 ibdev_err_ratelimited(edev
->efa_dev
,
48 "Failed to create qp [%d]\n", err
);
52 res
->qp_handle
= cmd_completion
.qp_handle
;
53 res
->qp_num
= cmd_completion
.qp_num
;
54 res
->sq_db_offset
= cmd_completion
.sq_db_offset
;
55 res
->rq_db_offset
= cmd_completion
.rq_db_offset
;
56 res
->llq_descriptors_offset
= cmd_completion
.llq_descriptors_offset
;
57 res
->send_sub_cq_idx
= cmd_completion
.send_sub_cq_idx
;
58 res
->recv_sub_cq_idx
= cmd_completion
.recv_sub_cq_idx
;
63 int efa_com_modify_qp(struct efa_com_dev
*edev
,
64 struct efa_com_modify_qp_params
*params
)
66 struct efa_com_admin_queue
*aq
= &edev
->aq
;
67 struct efa_admin_modify_qp_cmd cmd
= {};
68 struct efa_admin_modify_qp_resp resp
;
71 cmd
.aq_common_desc
.opcode
= EFA_ADMIN_MODIFY_QP
;
72 cmd
.modify_mask
= params
->modify_mask
;
73 cmd
.qp_handle
= params
->qp_handle
;
74 cmd
.qp_state
= params
->qp_state
;
75 cmd
.cur_qp_state
= params
->cur_qp_state
;
76 cmd
.qkey
= params
->qkey
;
77 cmd
.sq_psn
= params
->sq_psn
;
78 cmd
.sq_drained_async_notify
= params
->sq_drained_async_notify
;
80 err
= efa_com_cmd_exec(aq
,
81 (struct efa_admin_aq_entry
*)&cmd
,
83 (struct efa_admin_acq_entry
*)&resp
,
86 ibdev_err_ratelimited(
88 "Failed to modify qp-%u modify_mask[%#x] [%d]\n",
89 cmd
.qp_handle
, cmd
.modify_mask
, err
);
96 int efa_com_query_qp(struct efa_com_dev
*edev
,
97 struct efa_com_query_qp_params
*params
,
98 struct efa_com_query_qp_result
*result
)
100 struct efa_com_admin_queue
*aq
= &edev
->aq
;
101 struct efa_admin_query_qp_cmd cmd
= {};
102 struct efa_admin_query_qp_resp resp
;
105 cmd
.aq_common_desc
.opcode
= EFA_ADMIN_QUERY_QP
;
106 cmd
.qp_handle
= params
->qp_handle
;
108 err
= efa_com_cmd_exec(aq
,
109 (struct efa_admin_aq_entry
*)&cmd
,
111 (struct efa_admin_acq_entry
*)&resp
,
114 ibdev_err_ratelimited(edev
->efa_dev
,
115 "Failed to query qp-%u [%d]\n",
120 result
->qp_state
= resp
.qp_state
;
121 result
->qkey
= resp
.qkey
;
122 result
->sq_draining
= resp
.sq_draining
;
123 result
->sq_psn
= resp
.sq_psn
;
128 int efa_com_destroy_qp(struct efa_com_dev
*edev
,
129 struct efa_com_destroy_qp_params
*params
)
131 struct efa_admin_destroy_qp_resp cmd_completion
;
132 struct efa_admin_destroy_qp_cmd qp_cmd
= {};
133 struct efa_com_admin_queue
*aq
= &edev
->aq
;
136 qp_cmd
.aq_common_desc
.opcode
= EFA_ADMIN_DESTROY_QP
;
137 qp_cmd
.qp_handle
= params
->qp_handle
;
139 err
= efa_com_cmd_exec(aq
,
140 (struct efa_admin_aq_entry
*)&qp_cmd
,
142 (struct efa_admin_acq_entry
*)&cmd_completion
,
143 sizeof(cmd_completion
));
145 ibdev_err_ratelimited(edev
->efa_dev
,
146 "Failed to destroy qp-%u [%d]\n",
147 qp_cmd
.qp_handle
, err
);
154 int efa_com_create_cq(struct efa_com_dev
*edev
,
155 struct efa_com_create_cq_params
*params
,
156 struct efa_com_create_cq_result
*result
)
158 struct efa_admin_create_cq_resp cmd_completion
;
159 struct efa_admin_create_cq_cmd create_cmd
= {};
160 struct efa_com_admin_queue
*aq
= &edev
->aq
;
163 create_cmd
.aq_common_desc
.opcode
= EFA_ADMIN_CREATE_CQ
;
164 EFA_SET(&create_cmd
.cq_caps_2
,
165 EFA_ADMIN_CREATE_CQ_CMD_CQ_ENTRY_SIZE_WORDS
,
166 params
->entry_size_in_bytes
/ 4);
167 create_cmd
.cq_depth
= params
->cq_depth
;
168 create_cmd
.num_sub_cqs
= params
->num_sub_cqs
;
169 create_cmd
.uar
= params
->uarn
;
171 efa_com_set_dma_addr(params
->dma_addr
,
172 &create_cmd
.cq_ba
.mem_addr_high
,
173 &create_cmd
.cq_ba
.mem_addr_low
);
175 err
= efa_com_cmd_exec(aq
,
176 (struct efa_admin_aq_entry
*)&create_cmd
,
178 (struct efa_admin_acq_entry
*)&cmd_completion
,
179 sizeof(cmd_completion
));
181 ibdev_err_ratelimited(edev
->efa_dev
,
182 "Failed to create cq[%d]\n", err
);
186 result
->cq_idx
= cmd_completion
.cq_idx
;
187 result
->actual_depth
= params
->cq_depth
;
192 int efa_com_destroy_cq(struct efa_com_dev
*edev
,
193 struct efa_com_destroy_cq_params
*params
)
195 struct efa_admin_destroy_cq_cmd destroy_cmd
= {};
196 struct efa_admin_destroy_cq_resp destroy_resp
;
197 struct efa_com_admin_queue
*aq
= &edev
->aq
;
200 destroy_cmd
.cq_idx
= params
->cq_idx
;
201 destroy_cmd
.aq_common_desc
.opcode
= EFA_ADMIN_DESTROY_CQ
;
203 err
= efa_com_cmd_exec(aq
,
204 (struct efa_admin_aq_entry
*)&destroy_cmd
,
206 (struct efa_admin_acq_entry
*)&destroy_resp
,
207 sizeof(destroy_resp
));
210 ibdev_err_ratelimited(edev
->efa_dev
,
211 "Failed to destroy CQ-%u [%d]\n",
212 params
->cq_idx
, err
);
219 int efa_com_register_mr(struct efa_com_dev
*edev
,
220 struct efa_com_reg_mr_params
*params
,
221 struct efa_com_reg_mr_result
*result
)
223 struct efa_admin_reg_mr_resp cmd_completion
;
224 struct efa_com_admin_queue
*aq
= &edev
->aq
;
225 struct efa_admin_reg_mr_cmd mr_cmd
= {};
228 mr_cmd
.aq_common_desc
.opcode
= EFA_ADMIN_REG_MR
;
229 mr_cmd
.pd
= params
->pd
;
230 mr_cmd
.mr_length
= params
->mr_length_in_bytes
;
231 EFA_SET(&mr_cmd
.flags
, EFA_ADMIN_REG_MR_CMD_PHYS_PAGE_SIZE_SHIFT
,
233 mr_cmd
.iova
= params
->iova
;
234 mr_cmd
.permissions
= params
->permissions
;
236 if (params
->inline_pbl
) {
237 memcpy(mr_cmd
.pbl
.inline_pbl_array
,
238 params
->pbl
.inline_pbl_array
,
239 sizeof(mr_cmd
.pbl
.inline_pbl_array
));
241 mr_cmd
.pbl
.pbl
.length
= params
->pbl
.pbl
.length
;
242 mr_cmd
.pbl
.pbl
.address
.mem_addr_low
=
243 params
->pbl
.pbl
.address
.mem_addr_low
;
244 mr_cmd
.pbl
.pbl
.address
.mem_addr_high
=
245 params
->pbl
.pbl
.address
.mem_addr_high
;
246 EFA_SET(&mr_cmd
.aq_common_desc
.flags
,
247 EFA_ADMIN_AQ_COMMON_DESC_CTRL_DATA
, 1);
248 if (params
->indirect
)
249 EFA_SET(&mr_cmd
.aq_common_desc
.flags
,
250 EFA_ADMIN_AQ_COMMON_DESC_CTRL_DATA_INDIRECT
, 1);
253 err
= efa_com_cmd_exec(aq
,
254 (struct efa_admin_aq_entry
*)&mr_cmd
,
256 (struct efa_admin_acq_entry
*)&cmd_completion
,
257 sizeof(cmd_completion
));
259 ibdev_err_ratelimited(edev
->efa_dev
,
260 "Failed to register mr [%d]\n", err
);
264 result
->l_key
= cmd_completion
.l_key
;
265 result
->r_key
= cmd_completion
.r_key
;
270 int efa_com_dereg_mr(struct efa_com_dev
*edev
,
271 struct efa_com_dereg_mr_params
*params
)
273 struct efa_admin_dereg_mr_resp cmd_completion
;
274 struct efa_com_admin_queue
*aq
= &edev
->aq
;
275 struct efa_admin_dereg_mr_cmd mr_cmd
= {};
278 mr_cmd
.aq_common_desc
.opcode
= EFA_ADMIN_DEREG_MR
;
279 mr_cmd
.l_key
= params
->l_key
;
281 err
= efa_com_cmd_exec(aq
,
282 (struct efa_admin_aq_entry
*)&mr_cmd
,
284 (struct efa_admin_acq_entry
*)&cmd_completion
,
285 sizeof(cmd_completion
));
287 ibdev_err_ratelimited(edev
->efa_dev
,
288 "Failed to de-register mr(lkey-%u) [%d]\n",
296 int efa_com_create_ah(struct efa_com_dev
*edev
,
297 struct efa_com_create_ah_params
*params
,
298 struct efa_com_create_ah_result
*result
)
300 struct efa_admin_create_ah_resp cmd_completion
;
301 struct efa_com_admin_queue
*aq
= &edev
->aq
;
302 struct efa_admin_create_ah_cmd ah_cmd
= {};
305 ah_cmd
.aq_common_desc
.opcode
= EFA_ADMIN_CREATE_AH
;
307 memcpy(ah_cmd
.dest_addr
, params
->dest_addr
, sizeof(ah_cmd
.dest_addr
));
308 ah_cmd
.pd
= params
->pdn
;
310 err
= efa_com_cmd_exec(aq
,
311 (struct efa_admin_aq_entry
*)&ah_cmd
,
313 (struct efa_admin_acq_entry
*)&cmd_completion
,
314 sizeof(cmd_completion
));
316 ibdev_err_ratelimited(edev
->efa_dev
,
317 "Failed to create ah for %pI6 [%d]\n",
318 ah_cmd
.dest_addr
, err
);
322 result
->ah
= cmd_completion
.ah
;
327 int efa_com_destroy_ah(struct efa_com_dev
*edev
,
328 struct efa_com_destroy_ah_params
*params
)
330 struct efa_admin_destroy_ah_resp cmd_completion
;
331 struct efa_admin_destroy_ah_cmd ah_cmd
= {};
332 struct efa_com_admin_queue
*aq
= &edev
->aq
;
335 ah_cmd
.aq_common_desc
.opcode
= EFA_ADMIN_DESTROY_AH
;
336 ah_cmd
.ah
= params
->ah
;
337 ah_cmd
.pd
= params
->pdn
;
339 err
= efa_com_cmd_exec(aq
,
340 (struct efa_admin_aq_entry
*)&ah_cmd
,
342 (struct efa_admin_acq_entry
*)&cmd_completion
,
343 sizeof(cmd_completion
));
345 ibdev_err_ratelimited(edev
->efa_dev
,
346 "Failed to destroy ah-%d pd-%d [%d]\n",
347 ah_cmd
.ah
, ah_cmd
.pd
, err
);
355 efa_com_check_supported_feature_id(struct efa_com_dev
*edev
,
356 enum efa_admin_aq_feature_id feature_id
)
358 u32 feature_mask
= 1 << feature_id
;
360 /* Device attributes is always supported */
361 if (feature_id
!= EFA_ADMIN_DEVICE_ATTR
&&
362 !(edev
->supported_features
& feature_mask
))
368 static int efa_com_get_feature_ex(struct efa_com_dev
*edev
,
369 struct efa_admin_get_feature_resp
*get_resp
,
370 enum efa_admin_aq_feature_id feature_id
,
371 dma_addr_t control_buf_dma_addr
,
372 u32 control_buff_size
)
374 struct efa_admin_get_feature_cmd get_cmd
= {};
375 struct efa_com_admin_queue
*aq
;
378 if (!efa_com_check_supported_feature_id(edev
, feature_id
)) {
379 ibdev_err_ratelimited(edev
->efa_dev
,
380 "Feature %d isn't supported\n",
387 get_cmd
.aq_common_descriptor
.opcode
= EFA_ADMIN_GET_FEATURE
;
389 if (control_buff_size
)
390 EFA_SET(&get_cmd
.aq_common_descriptor
.flags
,
391 EFA_ADMIN_AQ_COMMON_DESC_CTRL_DATA
, 1);
393 efa_com_set_dma_addr(control_buf_dma_addr
,
394 &get_cmd
.control_buffer
.address
.mem_addr_high
,
395 &get_cmd
.control_buffer
.address
.mem_addr_low
);
397 get_cmd
.control_buffer
.length
= control_buff_size
;
398 get_cmd
.feature_common
.feature_id
= feature_id
;
399 err
= efa_com_cmd_exec(aq
,
400 (struct efa_admin_aq_entry
*)
403 (struct efa_admin_acq_entry
*)
408 ibdev_err_ratelimited(
410 "Failed to submit get_feature command %d [%d]\n",
418 static int efa_com_get_feature(struct efa_com_dev
*edev
,
419 struct efa_admin_get_feature_resp
*get_resp
,
420 enum efa_admin_aq_feature_id feature_id
)
422 return efa_com_get_feature_ex(edev
, get_resp
, feature_id
, 0, 0);
425 int efa_com_get_device_attr(struct efa_com_dev
*edev
,
426 struct efa_com_get_device_attr_result
*result
)
428 struct efa_admin_get_feature_resp resp
;
431 err
= efa_com_get_feature(edev
, &resp
, EFA_ADMIN_DEVICE_ATTR
);
433 ibdev_err_ratelimited(edev
->efa_dev
,
434 "Failed to get device attributes %d\n",
439 result
->page_size_cap
= resp
.u
.device_attr
.page_size_cap
;
440 result
->fw_version
= resp
.u
.device_attr
.fw_version
;
441 result
->admin_api_version
= resp
.u
.device_attr
.admin_api_version
;
442 result
->device_version
= resp
.u
.device_attr
.device_version
;
443 result
->supported_features
= resp
.u
.device_attr
.supported_features
;
444 result
->phys_addr_width
= resp
.u
.device_attr
.phys_addr_width
;
445 result
->virt_addr_width
= resp
.u
.device_attr
.virt_addr_width
;
446 result
->db_bar
= resp
.u
.device_attr
.db_bar
;
447 result
->max_rdma_size
= resp
.u
.device_attr
.max_rdma_size
;
448 result
->device_caps
= resp
.u
.device_attr
.device_caps
;
450 if (result
->admin_api_version
< 1) {
451 ibdev_err_ratelimited(
453 "Failed to get device attr api version [%u < 1]\n",
454 result
->admin_api_version
);
458 edev
->supported_features
= resp
.u
.device_attr
.supported_features
;
459 err
= efa_com_get_feature(edev
, &resp
,
460 EFA_ADMIN_QUEUE_ATTR
);
462 ibdev_err_ratelimited(edev
->efa_dev
,
463 "Failed to get queue attributes %d\n",
468 result
->max_qp
= resp
.u
.queue_attr
.max_qp
;
469 result
->max_sq_depth
= resp
.u
.queue_attr
.max_sq_depth
;
470 result
->max_rq_depth
= resp
.u
.queue_attr
.max_rq_depth
;
471 result
->max_cq
= resp
.u
.queue_attr
.max_cq
;
472 result
->max_cq_depth
= resp
.u
.queue_attr
.max_cq_depth
;
473 result
->inline_buf_size
= resp
.u
.queue_attr
.inline_buf_size
;
474 result
->max_sq_sge
= resp
.u
.queue_attr
.max_wr_send_sges
;
475 result
->max_rq_sge
= resp
.u
.queue_attr
.max_wr_recv_sges
;
476 result
->max_mr
= resp
.u
.queue_attr
.max_mr
;
477 result
->max_mr_pages
= resp
.u
.queue_attr
.max_mr_pages
;
478 result
->max_pd
= resp
.u
.queue_attr
.max_pd
;
479 result
->max_ah
= resp
.u
.queue_attr
.max_ah
;
480 result
->max_llq_size
= resp
.u
.queue_attr
.max_llq_size
;
481 result
->sub_cqs_per_cq
= resp
.u
.queue_attr
.sub_cqs_per_cq
;
482 result
->max_wr_rdma_sge
= resp
.u
.queue_attr
.max_wr_rdma_sges
;
484 err
= efa_com_get_feature(edev
, &resp
, EFA_ADMIN_NETWORK_ATTR
);
486 ibdev_err_ratelimited(edev
->efa_dev
,
487 "Failed to get network attributes %d\n",
492 memcpy(result
->addr
, resp
.u
.network_attr
.addr
,
493 sizeof(resp
.u
.network_attr
.addr
));
494 result
->mtu
= resp
.u
.network_attr
.mtu
;
499 int efa_com_get_hw_hints(struct efa_com_dev
*edev
,
500 struct efa_com_get_hw_hints_result
*result
)
502 struct efa_admin_get_feature_resp resp
;
505 err
= efa_com_get_feature(edev
, &resp
, EFA_ADMIN_HW_HINTS
);
507 ibdev_err_ratelimited(edev
->efa_dev
,
508 "Failed to get hw hints %d\n", err
);
512 result
->admin_completion_timeout
= resp
.u
.hw_hints
.admin_completion_timeout
;
513 result
->driver_watchdog_timeout
= resp
.u
.hw_hints
.driver_watchdog_timeout
;
514 result
->mmio_read_timeout
= resp
.u
.hw_hints
.mmio_read_timeout
;
515 result
->poll_interval
= resp
.u
.hw_hints
.poll_interval
;
520 static int efa_com_set_feature_ex(struct efa_com_dev
*edev
,
521 struct efa_admin_set_feature_resp
*set_resp
,
522 struct efa_admin_set_feature_cmd
*set_cmd
,
523 enum efa_admin_aq_feature_id feature_id
,
524 dma_addr_t control_buf_dma_addr
,
525 u32 control_buff_size
)
527 struct efa_com_admin_queue
*aq
;
530 if (!efa_com_check_supported_feature_id(edev
, feature_id
)) {
531 ibdev_err_ratelimited(edev
->efa_dev
,
532 "Feature %d isn't supported\n",
539 set_cmd
->aq_common_descriptor
.opcode
= EFA_ADMIN_SET_FEATURE
;
540 if (control_buff_size
) {
541 set_cmd
->aq_common_descriptor
.flags
= 0;
542 EFA_SET(&set_cmd
->aq_common_descriptor
.flags
,
543 EFA_ADMIN_AQ_COMMON_DESC_CTRL_DATA
, 1);
544 efa_com_set_dma_addr(control_buf_dma_addr
,
545 &set_cmd
->control_buffer
.address
.mem_addr_high
,
546 &set_cmd
->control_buffer
.address
.mem_addr_low
);
549 set_cmd
->control_buffer
.length
= control_buff_size
;
550 set_cmd
->feature_common
.feature_id
= feature_id
;
551 err
= efa_com_cmd_exec(aq
,
552 (struct efa_admin_aq_entry
*)set_cmd
,
554 (struct efa_admin_acq_entry
*)set_resp
,
558 ibdev_err_ratelimited(
560 "Failed to submit set_feature command %d error: %d\n",
568 static int efa_com_set_feature(struct efa_com_dev
*edev
,
569 struct efa_admin_set_feature_resp
*set_resp
,
570 struct efa_admin_set_feature_cmd
*set_cmd
,
571 enum efa_admin_aq_feature_id feature_id
)
573 return efa_com_set_feature_ex(edev
, set_resp
, set_cmd
, feature_id
,
577 int efa_com_set_aenq_config(struct efa_com_dev
*edev
, u32 groups
)
579 struct efa_admin_get_feature_resp get_resp
;
580 struct efa_admin_set_feature_resp set_resp
;
581 struct efa_admin_set_feature_cmd cmd
= {};
584 ibdev_dbg(edev
->efa_dev
, "Configuring aenq with groups[%#x]\n", groups
);
586 err
= efa_com_get_feature(edev
, &get_resp
, EFA_ADMIN_AENQ_CONFIG
);
588 ibdev_err_ratelimited(edev
->efa_dev
,
589 "Failed to get aenq attributes: %d\n",
594 ibdev_dbg(edev
->efa_dev
,
595 "Get aenq groups: supported[%#x] enabled[%#x]\n",
596 get_resp
.u
.aenq
.supported_groups
,
597 get_resp
.u
.aenq
.enabled_groups
);
599 if ((get_resp
.u
.aenq
.supported_groups
& groups
) != groups
) {
600 ibdev_err_ratelimited(
602 "Trying to set unsupported aenq groups[%#x] supported[%#x]\n",
603 groups
, get_resp
.u
.aenq
.supported_groups
);
607 cmd
.u
.aenq
.enabled_groups
= groups
;
608 err
= efa_com_set_feature(edev
, &set_resp
, &cmd
,
609 EFA_ADMIN_AENQ_CONFIG
);
611 ibdev_err_ratelimited(edev
->efa_dev
,
612 "Failed to set aenq attributes: %d\n",
620 int efa_com_alloc_pd(struct efa_com_dev
*edev
,
621 struct efa_com_alloc_pd_result
*result
)
623 struct efa_com_admin_queue
*aq
= &edev
->aq
;
624 struct efa_admin_alloc_pd_cmd cmd
= {};
625 struct efa_admin_alloc_pd_resp resp
;
628 cmd
.aq_common_descriptor
.opcode
= EFA_ADMIN_ALLOC_PD
;
630 err
= efa_com_cmd_exec(aq
,
631 (struct efa_admin_aq_entry
*)&cmd
,
633 (struct efa_admin_acq_entry
*)&resp
,
636 ibdev_err_ratelimited(edev
->efa_dev
,
637 "Failed to allocate pd[%d]\n", err
);
641 result
->pdn
= resp
.pd
;
646 int efa_com_dealloc_pd(struct efa_com_dev
*edev
,
647 struct efa_com_dealloc_pd_params
*params
)
649 struct efa_com_admin_queue
*aq
= &edev
->aq
;
650 struct efa_admin_dealloc_pd_cmd cmd
= {};
651 struct efa_admin_dealloc_pd_resp resp
;
654 cmd
.aq_common_descriptor
.opcode
= EFA_ADMIN_DEALLOC_PD
;
655 cmd
.pd
= params
->pdn
;
657 err
= efa_com_cmd_exec(aq
,
658 (struct efa_admin_aq_entry
*)&cmd
,
660 (struct efa_admin_acq_entry
*)&resp
,
663 ibdev_err_ratelimited(edev
->efa_dev
,
664 "Failed to deallocate pd-%u [%d]\n",
672 int efa_com_alloc_uar(struct efa_com_dev
*edev
,
673 struct efa_com_alloc_uar_result
*result
)
675 struct efa_com_admin_queue
*aq
= &edev
->aq
;
676 struct efa_admin_alloc_uar_cmd cmd
= {};
677 struct efa_admin_alloc_uar_resp resp
;
680 cmd
.aq_common_descriptor
.opcode
= EFA_ADMIN_ALLOC_UAR
;
682 err
= efa_com_cmd_exec(aq
,
683 (struct efa_admin_aq_entry
*)&cmd
,
685 (struct efa_admin_acq_entry
*)&resp
,
688 ibdev_err_ratelimited(edev
->efa_dev
,
689 "Failed to allocate uar[%d]\n", err
);
693 result
->uarn
= resp
.uar
;
698 int efa_com_dealloc_uar(struct efa_com_dev
*edev
,
699 struct efa_com_dealloc_uar_params
*params
)
701 struct efa_com_admin_queue
*aq
= &edev
->aq
;
702 struct efa_admin_dealloc_uar_cmd cmd
= {};
703 struct efa_admin_dealloc_uar_resp resp
;
706 cmd
.aq_common_descriptor
.opcode
= EFA_ADMIN_DEALLOC_UAR
;
707 cmd
.uar
= params
->uarn
;
709 err
= efa_com_cmd_exec(aq
,
710 (struct efa_admin_aq_entry
*)&cmd
,
712 (struct efa_admin_acq_entry
*)&resp
,
715 ibdev_err_ratelimited(edev
->efa_dev
,
716 "Failed to deallocate uar-%u [%d]\n",
724 int efa_com_get_stats(struct efa_com_dev
*edev
,
725 struct efa_com_get_stats_params
*params
,
726 union efa_com_get_stats_result
*result
)
728 struct efa_com_admin_queue
*aq
= &edev
->aq
;
729 struct efa_admin_aq_get_stats_cmd cmd
= {};
730 struct efa_admin_acq_get_stats_resp resp
;
733 cmd
.aq_common_descriptor
.opcode
= EFA_ADMIN_GET_STATS
;
734 cmd
.type
= params
->type
;
735 cmd
.scope
= params
->scope
;
736 cmd
.scope_modifier
= params
->scope_modifier
;
738 err
= efa_com_cmd_exec(aq
,
739 (struct efa_admin_aq_entry
*)&cmd
,
741 (struct efa_admin_acq_entry
*)&resp
,
744 ibdev_err_ratelimited(
746 "Failed to get stats type-%u scope-%u.%u [%d]\n",
747 cmd
.type
, cmd
.scope
, cmd
.scope_modifier
, err
);
751 result
->basic_stats
.tx_bytes
= resp
.basic_stats
.tx_bytes
;
752 result
->basic_stats
.tx_pkts
= resp
.basic_stats
.tx_pkts
;
753 result
->basic_stats
.rx_bytes
= resp
.basic_stats
.rx_bytes
;
754 result
->basic_stats
.rx_pkts
= resp
.basic_stats
.rx_pkts
;
755 result
->basic_stats
.rx_drops
= resp
.basic_stats
.rx_drops
;