1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2020 Mellanox Technologies, Ltd
10 #include <sys/queue.h>
12 #include <rte_malloc.h>
13 #include <rte_common.h>
14 #include <rte_eal_paging.h>
16 #include <mlx5_glue.h>
17 #include <mlx5_devx_cmds.h>
18 #include <mlx5_malloc.h>
21 #include "mlx5_common_os.h"
22 #include "mlx5_rxtx.h"
23 #include "mlx5_utils.h"
24 #include "mlx5_devx.h"
25 #include "mlx5_flow.h"
29 * Modify RQ vlan stripping offload
35 * 0 on success, non-0 otherwise
38 mlx5_rxq_obj_modify_rq_vlan_strip(struct mlx5_rxq_obj *rxq_obj, int on)
40 struct mlx5_devx_modify_rq_attr rq_attr;
42 memset(&rq_attr, 0, sizeof(rq_attr));
43 rq_attr.rq_state = MLX5_RQC_STATE_RDY;
44 rq_attr.state = MLX5_RQC_STATE_RDY;
45 rq_attr.vsd = (on ? 0 : 1);
46 rq_attr.modify_bitmask = MLX5_MODIFY_RQ_IN_MODIFY_BITMASK_VSD;
47 return mlx5_devx_cmd_modify_rq(rxq_obj->rq, &rq_attr);
51 * Modify RQ using DevX API.
54 * DevX Rx queue object.
56 * Type of change queue state.
59 * 0 on success, a negative errno value otherwise and rte_errno is set.
62 mlx5_devx_modify_rq(struct mlx5_rxq_obj *rxq_obj, uint8_t type)
64 struct mlx5_devx_modify_rq_attr rq_attr;
66 memset(&rq_attr, 0, sizeof(rq_attr));
68 case MLX5_RXQ_MOD_ERR2RST:
69 rq_attr.rq_state = MLX5_RQC_STATE_ERR;
70 rq_attr.state = MLX5_RQC_STATE_RST;
72 case MLX5_RXQ_MOD_RST2RDY:
73 rq_attr.rq_state = MLX5_RQC_STATE_RST;
74 rq_attr.state = MLX5_RQC_STATE_RDY;
76 case MLX5_RXQ_MOD_RDY2ERR:
77 rq_attr.rq_state = MLX5_RQC_STATE_RDY;
78 rq_attr.state = MLX5_RQC_STATE_ERR;
80 case MLX5_RXQ_MOD_RDY2RST:
81 rq_attr.rq_state = MLX5_RQC_STATE_RDY;
82 rq_attr.state = MLX5_RQC_STATE_RST;
87 return mlx5_devx_cmd_modify_rq(rxq_obj->rq, &rq_attr);
91 * Modify SQ using DevX API.
94 * DevX Tx queue object.
96 * Type of change queue state.
101 * 0 on success, a negative errno value otherwise and rte_errno is set.
104 mlx5_devx_modify_sq(struct mlx5_txq_obj *obj, enum mlx5_txq_modify_type type,
107 struct mlx5_devx_modify_sq_attr msq_attr = { 0 };
110 if (type != MLX5_TXQ_MOD_RST2RDY) {
111 /* Change queue state to reset. */
112 if (type == MLX5_TXQ_MOD_ERR2RDY)
113 msq_attr.sq_state = MLX5_SQC_STATE_ERR;
115 msq_attr.sq_state = MLX5_SQC_STATE_RDY;
116 msq_attr.state = MLX5_SQC_STATE_RST;
117 ret = mlx5_devx_cmd_modify_sq(obj->sq_devx, &msq_attr);
119 DRV_LOG(ERR, "Cannot change the Tx SQ state to RESET"
120 " %s", strerror(errno));
125 if (type != MLX5_TXQ_MOD_RDY2RST) {
126 /* Change queue state to ready. */
127 msq_attr.sq_state = MLX5_SQC_STATE_RST;
128 msq_attr.state = MLX5_SQC_STATE_RDY;
129 ret = mlx5_devx_cmd_modify_sq(obj->sq_devx, &msq_attr);
131 DRV_LOG(ERR, "Cannot change the Tx SQ state to READY"
132 " %s", strerror(errno));
138 * The dev_port variable is relevant only in Verbs API, and there is a
139 * pointer that points to this function and a parallel function in verbs
140 * intermittently, so they should have the same parameters.
147 * Release the resources allocated for an RQ DevX object.
150 * DevX Rx queue object.
153 mlx5_rxq_release_devx_rq_resources(struct mlx5_rxq_ctrl *rxq_ctrl)
155 struct mlx5_devx_dbr_page *dbr_page = rxq_ctrl->rq_dbrec_page;
157 if (rxq_ctrl->rxq.wqes) {
158 mlx5_free((void *)(uintptr_t)rxq_ctrl->rxq.wqes);
159 rxq_ctrl->rxq.wqes = NULL;
161 if (rxq_ctrl->wq_umem) {
162 mlx5_glue->devx_umem_dereg(rxq_ctrl->wq_umem);
163 rxq_ctrl->wq_umem = NULL;
166 claim_zero(mlx5_release_dbr(&rxq_ctrl->priv->dbrpgs,
167 mlx5_os_get_umem_id(dbr_page->umem),
168 rxq_ctrl->rq_dbr_offset));
169 rxq_ctrl->rq_dbrec_page = NULL;
174 * Release the resources allocated for the Rx CQ DevX object.
177 * DevX Rx queue object.
180 mlx5_rxq_release_devx_cq_resources(struct mlx5_rxq_ctrl *rxq_ctrl)
182 struct mlx5_devx_dbr_page *dbr_page = rxq_ctrl->cq_dbrec_page;
184 if (rxq_ctrl->rxq.cqes) {
185 rte_free((void *)(uintptr_t)rxq_ctrl->rxq.cqes);
186 rxq_ctrl->rxq.cqes = NULL;
188 if (rxq_ctrl->cq_umem) {
189 mlx5_glue->devx_umem_dereg(rxq_ctrl->cq_umem);
190 rxq_ctrl->cq_umem = NULL;
193 claim_zero(mlx5_release_dbr(&rxq_ctrl->priv->dbrpgs,
194 mlx5_os_get_umem_id(dbr_page->umem),
195 rxq_ctrl->cq_dbr_offset));
196 rxq_ctrl->cq_dbrec_page = NULL;
201 * Release an Rx DevX queue object.
204 * DevX Rx queue object.
207 mlx5_rxq_devx_obj_release(struct mlx5_rxq_obj *rxq_obj)
209 MLX5_ASSERT(rxq_obj);
210 MLX5_ASSERT(rxq_obj->rq);
211 if (rxq_obj->rxq_ctrl->type == MLX5_RXQ_TYPE_HAIRPIN) {
212 mlx5_devx_modify_rq(rxq_obj, MLX5_RXQ_MOD_RDY2RST);
213 claim_zero(mlx5_devx_cmd_destroy(rxq_obj->rq));
215 MLX5_ASSERT(rxq_obj->devx_cq);
216 claim_zero(mlx5_devx_cmd_destroy(rxq_obj->rq));
217 claim_zero(mlx5_devx_cmd_destroy(rxq_obj->devx_cq));
218 if (rxq_obj->devx_channel)
219 mlx5_glue->devx_destroy_event_channel
220 (rxq_obj->devx_channel);
221 mlx5_rxq_release_devx_rq_resources(rxq_obj->rxq_ctrl);
222 mlx5_rxq_release_devx_cq_resources(rxq_obj->rxq_ctrl);
227 * Get event for an Rx DevX queue object.
230 * DevX Rx queue object.
233 * 0 on success, a negative errno value otherwise and rte_errno is set.
236 mlx5_rx_devx_get_event(struct mlx5_rxq_obj *rxq_obj)
238 #ifdef HAVE_IBV_DEVX_EVENT
240 struct mlx5dv_devx_async_event_hdr event_resp;
241 uint8_t buf[sizeof(struct mlx5dv_devx_async_event_hdr) + 128];
243 int ret = mlx5_glue->devx_get_event(rxq_obj->devx_channel,
251 if (out.event_resp.cookie != (uint64_t)(uintptr_t)rxq_obj->devx_cq) {
260 #endif /* HAVE_IBV_DEVX_EVENT */
264 * Fill common fields of create RQ attributes structure.
267 * Pointer to Rx queue data.
269 * CQ number to use with this RQ.
271 * RQ attributes structure to fill..
274 mlx5_devx_create_rq_attr_fill(struct mlx5_rxq_data *rxq_data, uint32_t cqn,
275 struct mlx5_devx_create_rq_attr *rq_attr)
277 rq_attr->state = MLX5_RQC_STATE_RST;
278 rq_attr->vsd = (rxq_data->vlan_strip) ? 0 : 1;
280 rq_attr->scatter_fcs = (rxq_data->crc_present) ? 1 : 0;
284 * Fill common fields of DevX WQ attributes structure.
287 * Pointer to device private data.
289 * Pointer to Rx queue control structure.
291 * WQ attributes structure to fill..
294 mlx5_devx_wq_attr_fill(struct mlx5_priv *priv, struct mlx5_rxq_ctrl *rxq_ctrl,
295 struct mlx5_devx_wq_attr *wq_attr)
297 wq_attr->end_padding_mode = priv->config.cqe_pad ?
298 MLX5_WQ_END_PAD_MODE_ALIGN :
299 MLX5_WQ_END_PAD_MODE_NONE;
300 wq_attr->pd = priv->sh->pdn;
301 wq_attr->dbr_addr = rxq_ctrl->rq_dbr_offset;
302 wq_attr->dbr_umem_id =
303 mlx5_os_get_umem_id(rxq_ctrl->rq_dbrec_page->umem);
304 wq_attr->dbr_umem_valid = 1;
305 wq_attr->wq_umem_id = mlx5_os_get_umem_id(rxq_ctrl->wq_umem);
306 wq_attr->wq_umem_valid = 1;
310 * Create a RQ object using DevX.
313 * Pointer to Ethernet device.
315 * Queue index in DPDK Rx queue array.
318 * The DevX RQ object initialized, NULL otherwise and rte_errno is set.
320 static struct mlx5_devx_obj *
321 mlx5_rxq_create_devx_rq_resources(struct rte_eth_dev *dev, uint16_t idx)
323 struct mlx5_priv *priv = dev->data->dev_private;
324 struct mlx5_rxq_data *rxq_data = (*priv->rxqs)[idx];
325 struct mlx5_rxq_ctrl *rxq_ctrl =
326 container_of(rxq_data, struct mlx5_rxq_ctrl, rxq);
327 struct mlx5_devx_create_rq_attr rq_attr = { 0 };
328 uint32_t wqe_n = 1 << (rxq_data->elts_n - rxq_data->sges_n);
329 uint32_t cqn = rxq_ctrl->obj->devx_cq->id;
330 struct mlx5_devx_dbr_page *dbr_page;
332 uint32_t wq_size = 0;
333 uint32_t wqe_size = 0;
334 uint32_t log_wqe_size = 0;
336 struct mlx5_devx_obj *rq;
338 /* Fill RQ attributes. */
339 rq_attr.mem_rq_type = MLX5_RQC_MEM_RQ_TYPE_MEMORY_RQ_INLINE;
340 rq_attr.flush_in_error_en = 1;
341 mlx5_devx_create_rq_attr_fill(rxq_data, cqn, &rq_attr);
342 /* Fill WQ attributes for this RQ. */
343 if (mlx5_rxq_mprq_enabled(rxq_data)) {
344 rq_attr.wq_attr.wq_type = MLX5_WQ_TYPE_CYCLIC_STRIDING_RQ;
346 * Number of strides in each WQE:
347 * 512*2^single_wqe_log_num_of_strides.
349 rq_attr.wq_attr.single_wqe_log_num_of_strides =
350 rxq_data->strd_num_n -
351 MLX5_MIN_SINGLE_WQE_LOG_NUM_STRIDES;
352 /* Stride size = (2^single_stride_log_num_of_bytes)*64B. */
353 rq_attr.wq_attr.single_stride_log_num_of_bytes =
354 rxq_data->strd_sz_n -
355 MLX5_MIN_SINGLE_STRIDE_LOG_NUM_BYTES;
356 wqe_size = sizeof(struct mlx5_wqe_mprq);
358 rq_attr.wq_attr.wq_type = MLX5_WQ_TYPE_CYCLIC;
359 wqe_size = sizeof(struct mlx5_wqe_data_seg);
361 log_wqe_size = log2above(wqe_size) + rxq_data->sges_n;
362 rq_attr.wq_attr.log_wq_stride = log_wqe_size;
363 rq_attr.wq_attr.log_wq_sz = rxq_data->elts_n - rxq_data->sges_n;
364 /* Calculate and allocate WQ memory space. */
365 wqe_size = 1 << log_wqe_size; /* round up power of two.*/
366 wq_size = wqe_n * wqe_size;
367 size_t alignment = MLX5_WQE_BUF_ALIGNMENT;
368 if (alignment == (size_t)-1) {
369 DRV_LOG(ERR, "Failed to get mem page size");
373 buf = mlx5_malloc(MLX5_MEM_RTE | MLX5_MEM_ZERO, wq_size,
374 alignment, rxq_ctrl->socket);
377 rxq_data->wqes = buf;
378 rxq_ctrl->wq_umem = mlx5_glue->devx_umem_reg(priv->sh->ctx,
380 if (!rxq_ctrl->wq_umem)
382 /* Allocate RQ door-bell. */
383 dbr_offset = mlx5_get_dbr(priv->sh->ctx, &priv->dbrpgs, &dbr_page);
384 if (dbr_offset < 0) {
385 DRV_LOG(ERR, "Failed to allocate RQ door-bell.");
388 rxq_ctrl->rq_dbr_offset = dbr_offset;
389 rxq_ctrl->rq_dbrec_page = dbr_page;
390 rxq_data->rq_db = (uint32_t *)((uintptr_t)dbr_page->dbrs +
391 (uintptr_t)rxq_ctrl->rq_dbr_offset);
392 /* Create RQ using DevX API. */
393 mlx5_devx_wq_attr_fill(priv, rxq_ctrl, &rq_attr.wq_attr);
394 rq = mlx5_devx_cmd_create_rq(priv->sh->ctx, &rq_attr, rxq_ctrl->socket);
399 mlx5_rxq_release_devx_rq_resources(rxq_ctrl);
404 * Create a DevX CQ object for an Rx queue.
407 * Pointer to Ethernet device.
409 * Queue index in DPDK Rx queue array.
412 * The DevX CQ object initialized, NULL otherwise and rte_errno is set.
414 static struct mlx5_devx_obj *
415 mlx5_rxq_create_devx_cq_resources(struct rte_eth_dev *dev, uint16_t idx)
417 struct mlx5_devx_obj *cq_obj = 0;
418 struct mlx5_devx_cq_attr cq_attr = { 0 };
419 struct mlx5_priv *priv = dev->data->dev_private;
420 struct mlx5_rxq_data *rxq_data = (*priv->rxqs)[idx];
421 struct mlx5_rxq_ctrl *rxq_ctrl =
422 container_of(rxq_data, struct mlx5_rxq_ctrl, rxq);
423 size_t page_size = rte_mem_page_size();
424 unsigned int cqe_n = mlx5_rxq_cqe_num(rxq_data);
425 struct mlx5_devx_dbr_page *dbr_page;
428 uint16_t event_nums[1] = {0};
433 if (page_size == (size_t)-1) {
434 DRV_LOG(ERR, "Failed to get page_size.");
437 if (priv->config.cqe_comp && !rxq_data->hw_timestamp &&
439 cq_attr.cqe_comp_en = 1u;
440 cq_attr.mini_cqe_res_format =
441 mlx5_rxq_mprq_enabled(rxq_data) ?
442 MLX5_CQE_RESP_FORMAT_CSUM_STRIDX :
443 MLX5_CQE_RESP_FORMAT_HASH;
445 * For vectorized Rx, it must not be doubled in order to
446 * make cq_ci and rq_ci aligned.
448 if (mlx5_rxq_check_vec_support(rxq_data) < 0)
450 } else if (priv->config.cqe_comp && rxq_data->hw_timestamp) {
452 "Port %u Rx CQE compression is disabled for HW"
455 } else if (priv->config.cqe_comp && rxq_data->lro) {
457 "Port %u Rx CQE compression is disabled for LRO.",
460 if (priv->config.cqe_pad)
461 cq_attr.cqe_size = MLX5_CQE_SIZE_128B;
462 log_cqe_n = log2above(cqe_n);
463 cq_size = sizeof(struct mlx5_cqe) * (1 << log_cqe_n);
464 buf = rte_calloc_socket(__func__, 1, cq_size, page_size,
467 DRV_LOG(ERR, "Failed to allocate memory for CQ.");
470 rxq_data->cqes = (volatile struct mlx5_cqe (*)[])(uintptr_t)buf;
471 rxq_ctrl->cq_umem = mlx5_glue->devx_umem_reg(priv->sh->ctx, buf,
473 IBV_ACCESS_LOCAL_WRITE);
474 if (!rxq_ctrl->cq_umem) {
475 DRV_LOG(ERR, "Failed to register umem for CQ.");
478 /* Allocate CQ door-bell. */
479 dbr_offset = mlx5_get_dbr(priv->sh->ctx, &priv->dbrpgs, &dbr_page);
480 if (dbr_offset < 0) {
481 DRV_LOG(ERR, "Failed to allocate CQ door-bell.");
484 rxq_ctrl->cq_dbr_offset = dbr_offset;
485 rxq_ctrl->cq_dbrec_page = dbr_page;
486 rxq_data->cq_db = (uint32_t *)((uintptr_t)dbr_page->dbrs +
487 (uintptr_t)rxq_ctrl->cq_dbr_offset);
489 mlx5_os_get_devx_uar_base_addr(priv->sh->devx_rx_uar);
490 /* Create CQ using DevX API. */
491 cq_attr.eqn = priv->sh->eqn;
492 cq_attr.uar_page_id =
493 mlx5_os_get_devx_uar_page_id(priv->sh->devx_rx_uar);
494 cq_attr.q_umem_id = mlx5_os_get_umem_id(rxq_ctrl->cq_umem);
495 cq_attr.q_umem_valid = 1;
496 cq_attr.log_cq_size = log_cqe_n;
497 cq_attr.log_page_size = rte_log2_u32(page_size);
498 cq_attr.db_umem_offset = rxq_ctrl->cq_dbr_offset;
499 cq_attr.db_umem_id = mlx5_os_get_umem_id(dbr_page->umem);
500 cq_attr.db_umem_valid = 1;
501 cq_obj = mlx5_devx_cmd_create_cq(priv->sh->ctx, &cq_attr);
504 rxq_data->cqe_n = log_cqe_n;
505 rxq_data->cqn = cq_obj->id;
506 if (rxq_ctrl->obj->devx_channel) {
507 ret = mlx5_glue->devx_subscribe_devx_event
508 (rxq_ctrl->obj->devx_channel,
512 (uint64_t)(uintptr_t)cq_obj);
514 DRV_LOG(ERR, "Fail to subscribe CQ to event channel.");
519 /* Initialise CQ to 1's to mark HW ownership for all CQEs. */
520 memset((void *)(uintptr_t)rxq_data->cqes, 0xFF, cq_size);
524 mlx5_devx_cmd_destroy(cq_obj);
525 mlx5_rxq_release_devx_cq_resources(rxq_ctrl);
530 * Create the Rx hairpin queue object.
533 * Pointer to Ethernet device.
535 * Queue index in DPDK Rx queue array.
538 * 0 on success, a negative errno value otherwise and rte_errno is set.
541 mlx5_rxq_obj_hairpin_new(struct rte_eth_dev *dev, uint16_t idx)
543 struct mlx5_priv *priv = dev->data->dev_private;
544 struct mlx5_rxq_data *rxq_data = (*priv->rxqs)[idx];
545 struct mlx5_rxq_ctrl *rxq_ctrl =
546 container_of(rxq_data, struct mlx5_rxq_ctrl, rxq);
547 struct mlx5_devx_create_rq_attr attr = { 0 };
548 struct mlx5_rxq_obj *tmpl = rxq_ctrl->obj;
549 uint32_t max_wq_data;
551 MLX5_ASSERT(rxq_data);
553 tmpl->rxq_ctrl = rxq_ctrl;
555 max_wq_data = priv->config.hca_attr.log_max_hairpin_wq_data_sz;
556 /* Jumbo frames > 9KB should be supported, and more packets. */
557 if (priv->config.log_hp_size != (uint32_t)MLX5_ARG_UNSET) {
558 if (priv->config.log_hp_size > max_wq_data) {
559 DRV_LOG(ERR, "Total data size %u power of 2 is "
560 "too large for hairpin.",
561 priv->config.log_hp_size);
565 attr.wq_attr.log_hairpin_data_sz = priv->config.log_hp_size;
567 attr.wq_attr.log_hairpin_data_sz =
568 (max_wq_data < MLX5_HAIRPIN_JUMBO_LOG_SIZE) ?
569 max_wq_data : MLX5_HAIRPIN_JUMBO_LOG_SIZE;
571 /* Set the packets number to the maximum value for performance. */
572 attr.wq_attr.log_hairpin_num_packets =
573 attr.wq_attr.log_hairpin_data_sz -
574 MLX5_HAIRPIN_QUEUE_STRIDE;
575 tmpl->rq = mlx5_devx_cmd_create_rq(priv->sh->ctx, &attr,
579 "Port %u Rx hairpin queue %u can't create rq object.",
580 dev->data->port_id, idx);
584 dev->data->rx_queue_state[idx] = RTE_ETH_QUEUE_STATE_HAIRPIN;
589 * Create the Rx queue DevX object.
592 * Pointer to Ethernet device.
594 * Queue index in DPDK Rx queue array.
597 * 0 on success, a negative errno value otherwise and rte_errno is set.
600 mlx5_rxq_devx_obj_new(struct rte_eth_dev *dev, uint16_t idx)
602 struct mlx5_priv *priv = dev->data->dev_private;
603 struct mlx5_rxq_data *rxq_data = (*priv->rxqs)[idx];
604 struct mlx5_rxq_ctrl *rxq_ctrl =
605 container_of(rxq_data, struct mlx5_rxq_ctrl, rxq);
606 struct mlx5_rxq_obj *tmpl = rxq_ctrl->obj;
609 MLX5_ASSERT(rxq_data);
611 if (rxq_ctrl->type == MLX5_RXQ_TYPE_HAIRPIN)
612 return mlx5_rxq_obj_hairpin_new(dev, idx);
613 tmpl->rxq_ctrl = rxq_ctrl;
616 MLX5DV_DEVX_CREATE_EVENT_CHANNEL_FLAGS_OMIT_EV_DATA;
618 tmpl->devx_channel = mlx5_glue->devx_create_event_channel
621 if (!tmpl->devx_channel) {
623 DRV_LOG(ERR, "Failed to create event channel %d.",
627 tmpl->fd = mlx5_os_get_devx_channel_fd(tmpl->devx_channel);
629 /* Create CQ using DevX API. */
630 tmpl->devx_cq = mlx5_rxq_create_devx_cq_resources(dev, idx);
631 if (!tmpl->devx_cq) {
632 DRV_LOG(ERR, "Failed to create CQ.");
635 /* Create RQ using DevX API. */
636 tmpl->rq = mlx5_rxq_create_devx_rq_resources(dev, idx);
638 DRV_LOG(ERR, "Port %u Rx queue %u RQ creation failure.",
639 dev->data->port_id, idx);
643 /* Change queue state to ready. */
644 ret = mlx5_devx_modify_rq(tmpl, MLX5_RXQ_MOD_RST2RDY);
647 rxq_data->cq_arm_sn = 0;
648 mlx5_rxq_initialize(rxq_data);
650 dev->data->rx_queue_state[idx] = RTE_ETH_QUEUE_STATE_STARTED;
651 rxq_ctrl->wqn = tmpl->rq->id;
654 ret = rte_errno; /* Save rte_errno before cleanup. */
656 claim_zero(mlx5_devx_cmd_destroy(tmpl->rq));
658 claim_zero(mlx5_devx_cmd_destroy(tmpl->devx_cq));
659 if (tmpl->devx_channel)
660 mlx5_glue->devx_destroy_event_channel(tmpl->devx_channel);
661 mlx5_rxq_release_devx_rq_resources(rxq_ctrl);
662 mlx5_rxq_release_devx_cq_resources(rxq_ctrl);
663 rte_errno = ret; /* Restore rte_errno. */
668 * Create RQT using DevX API as a filed of indirection table.
671 * Pointer to Ethernet device.
673 * Log of number of queues in the array.
675 * DevX indirection table object.
678 * 0 on success, a negative errno value otherwise and rte_errno is set.
681 mlx5_devx_ind_table_new(struct rte_eth_dev *dev, const unsigned int log_n,
682 struct mlx5_ind_table_obj *ind_tbl)
684 struct mlx5_priv *priv = dev->data->dev_private;
685 struct mlx5_devx_rqt_attr *rqt_attr = NULL;
686 const unsigned int rqt_n = 1 << log_n;
689 MLX5_ASSERT(ind_tbl);
690 rqt_attr = mlx5_malloc(MLX5_MEM_ZERO, sizeof(*rqt_attr) +
691 rqt_n * sizeof(uint32_t), 0, SOCKET_ID_ANY);
693 DRV_LOG(ERR, "Port %u cannot allocate RQT resources.",
698 rqt_attr->rqt_max_size = priv->config.ind_table_max_size;
699 rqt_attr->rqt_actual_size = rqt_n;
700 for (i = 0; i != ind_tbl->queues_n; ++i) {
701 struct mlx5_rxq_data *rxq = (*priv->rxqs)[ind_tbl->queues[i]];
702 struct mlx5_rxq_ctrl *rxq_ctrl =
703 container_of(rxq, struct mlx5_rxq_ctrl, rxq);
705 rqt_attr->rq_list[i] = rxq_ctrl->obj->rq->id;
708 for (j = 0; i != rqt_n; ++j, ++i)
709 rqt_attr->rq_list[i] = rqt_attr->rq_list[j];
710 ind_tbl->rqt = mlx5_devx_cmd_create_rqt(priv->sh->ctx, rqt_attr);
713 DRV_LOG(ERR, "Port %u cannot create DevX RQT.",
722 * Destroy the DevX RQT object.
725 * Indirection table to release.
728 mlx5_devx_ind_table_destroy(struct mlx5_ind_table_obj *ind_tbl)
730 claim_zero(mlx5_devx_cmd_destroy(ind_tbl->rqt));
734 * Create an Rx Hash queue.
737 * Pointer to Ethernet device.
739 * Pointer to Rx Hash queue.
744 * 0 on success, a negative errno value otherwise and rte_errno is set.
747 mlx5_devx_hrxq_new(struct rte_eth_dev *dev, struct mlx5_hrxq *hrxq,
748 int tunnel __rte_unused)
750 struct mlx5_priv *priv = dev->data->dev_private;
751 struct mlx5_ind_table_obj *ind_tbl = hrxq->ind_table;
752 struct mlx5_rxq_data *rxq_data = (*priv->rxqs)[ind_tbl->queues[0]];
753 struct mlx5_rxq_ctrl *rxq_ctrl =
754 container_of(rxq_data, struct mlx5_rxq_ctrl, rxq);
755 struct mlx5_devx_tir_attr tir_attr;
756 const uint8_t *rss_key = hrxq->rss_key;
757 uint64_t hash_fields = hrxq->hash_fields;
762 /* Enable TIR LRO only if all the queues were configured for. */
763 for (i = 0; i < ind_tbl->queues_n; ++i) {
764 if (!(*priv->rxqs)[ind_tbl->queues[i]]->lro) {
769 memset(&tir_attr, 0, sizeof(tir_attr));
770 tir_attr.disp_type = MLX5_TIRC_DISP_TYPE_INDIRECT;
771 tir_attr.rx_hash_fn = MLX5_RX_HASH_FN_TOEPLITZ;
772 tir_attr.tunneled_offload_en = !!tunnel;
773 /* If needed, translate hash_fields bitmap to PRM format. */
775 struct mlx5_rx_hash_field_select *rx_hash_field_select = NULL;
776 #ifdef HAVE_IBV_DEVICE_TUNNEL_SUPPORT
777 rx_hash_field_select = hash_fields & IBV_RX_HASH_INNER ?
778 &tir_attr.rx_hash_field_selector_inner :
779 &tir_attr.rx_hash_field_selector_outer;
781 rx_hash_field_select = &tir_attr.rx_hash_field_selector_outer;
783 /* 1 bit: 0: IPv4, 1: IPv6. */
784 rx_hash_field_select->l3_prot_type =
785 !!(hash_fields & MLX5_IPV6_IBV_RX_HASH);
786 /* 1 bit: 0: TCP, 1: UDP. */
787 rx_hash_field_select->l4_prot_type =
788 !!(hash_fields & MLX5_UDP_IBV_RX_HASH);
789 /* Bitmask which sets which fields to use in RX Hash. */
790 rx_hash_field_select->selected_fields =
791 ((!!(hash_fields & MLX5_L3_SRC_IBV_RX_HASH)) <<
792 MLX5_RX_HASH_FIELD_SELECT_SELECTED_FIELDS_SRC_IP) |
793 (!!(hash_fields & MLX5_L3_DST_IBV_RX_HASH)) <<
794 MLX5_RX_HASH_FIELD_SELECT_SELECTED_FIELDS_DST_IP |
795 (!!(hash_fields & MLX5_L4_SRC_IBV_RX_HASH)) <<
796 MLX5_RX_HASH_FIELD_SELECT_SELECTED_FIELDS_L4_SPORT |
797 (!!(hash_fields & MLX5_L4_DST_IBV_RX_HASH)) <<
798 MLX5_RX_HASH_FIELD_SELECT_SELECTED_FIELDS_L4_DPORT;
800 if (rxq_ctrl->type == MLX5_RXQ_TYPE_HAIRPIN)
801 tir_attr.transport_domain = priv->sh->td->id;
803 tir_attr.transport_domain = priv->sh->tdn;
804 memcpy(tir_attr.rx_hash_toeplitz_key, rss_key, MLX5_RSS_HASH_KEY_LEN);
805 tir_attr.indirect_table = ind_tbl->rqt->id;
806 if (dev->data->dev_conf.lpbk_mode)
807 tir_attr.self_lb_block = MLX5_TIRC_SELF_LB_BLOCK_BLOCK_UNICAST;
809 tir_attr.lro_timeout_period_usecs = priv->config.lro.timeout;
810 tir_attr.lro_max_msg_sz = priv->max_lro_msg_size;
811 tir_attr.lro_enable_mask = MLX5_TIRC_LRO_ENABLE_MASK_IPV4_LRO |
812 MLX5_TIRC_LRO_ENABLE_MASK_IPV6_LRO;
814 hrxq->tir = mlx5_devx_cmd_create_tir(priv->sh->ctx, &tir_attr);
816 DRV_LOG(ERR, "Port %u cannot create DevX TIR.",
821 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
822 hrxq->action = mlx5_glue->dv_create_flow_action_dest_devx_tir
831 err = rte_errno; /* Save rte_errno before cleanup. */
833 claim_zero(mlx5_devx_cmd_destroy(hrxq->tir));
834 rte_errno = err; /* Restore rte_errno. */
839 * Destroy a DevX TIR object.
842 * Hash Rx queue to release its tir.
845 mlx5_devx_tir_destroy(struct mlx5_hrxq *hrxq)
847 claim_zero(mlx5_devx_cmd_destroy(hrxq->tir));
851 * Create a DevX drop action for Rx Hash queue.
854 * Pointer to Ethernet device.
857 * 0 on success, a negative errno value otherwise and rte_errno is set.
860 mlx5_devx_drop_action_create(struct rte_eth_dev *dev)
863 DRV_LOG(ERR, "DevX drop action is not supported yet.");
869 * Release a drop hash Rx queue.
872 * Pointer to Ethernet device.
875 mlx5_devx_drop_action_destroy(struct rte_eth_dev *dev)
878 DRV_LOG(ERR, "DevX drop action is not supported yet.");
883 * Create the Tx hairpin queue object.
886 * Pointer to Ethernet device.
888 * Queue index in DPDK Tx queue array.
891 * 0 on success, a negative errno value otherwise and rte_errno is set.
894 mlx5_txq_obj_hairpin_new(struct rte_eth_dev *dev, uint16_t idx)
896 struct mlx5_priv *priv = dev->data->dev_private;
897 struct mlx5_txq_data *txq_data = (*priv->txqs)[idx];
898 struct mlx5_txq_ctrl *txq_ctrl =
899 container_of(txq_data, struct mlx5_txq_ctrl, txq);
900 struct mlx5_devx_create_sq_attr attr = { 0 };
901 struct mlx5_txq_obj *tmpl = txq_ctrl->obj;
902 uint32_t max_wq_data;
904 MLX5_ASSERT(txq_data);
906 tmpl->txq_ctrl = txq_ctrl;
909 max_wq_data = priv->config.hca_attr.log_max_hairpin_wq_data_sz;
910 /* Jumbo frames > 9KB should be supported, and more packets. */
911 if (priv->config.log_hp_size != (uint32_t)MLX5_ARG_UNSET) {
912 if (priv->config.log_hp_size > max_wq_data) {
913 DRV_LOG(ERR, "Total data size %u power of 2 is "
914 "too large for hairpin.",
915 priv->config.log_hp_size);
919 attr.wq_attr.log_hairpin_data_sz = priv->config.log_hp_size;
921 attr.wq_attr.log_hairpin_data_sz =
922 (max_wq_data < MLX5_HAIRPIN_JUMBO_LOG_SIZE) ?
923 max_wq_data : MLX5_HAIRPIN_JUMBO_LOG_SIZE;
925 /* Set the packets number to the maximum value for performance. */
926 attr.wq_attr.log_hairpin_num_packets =
927 attr.wq_attr.log_hairpin_data_sz -
928 MLX5_HAIRPIN_QUEUE_STRIDE;
929 attr.tis_num = priv->sh->tis->id;
930 tmpl->sq = mlx5_devx_cmd_create_sq(priv->sh->ctx, &attr);
933 "Port %u tx hairpin queue %u can't create SQ object.",
934 dev->data->port_id, idx);
941 #ifdef HAVE_MLX5DV_DEVX_UAR_OFFSET
943 * Release DevX SQ resources.
946 * DevX Tx queue object.
949 mlx5_txq_release_devx_sq_resources(struct mlx5_txq_obj *txq_obj)
951 if (txq_obj->sq_devx)
952 claim_zero(mlx5_devx_cmd_destroy(txq_obj->sq_devx));
953 if (txq_obj->sq_umem)
954 claim_zero(mlx5_glue->devx_umem_dereg(txq_obj->sq_umem));
956 mlx5_free(txq_obj->sq_buf);
957 if (txq_obj->sq_dbrec_page)
958 claim_zero(mlx5_release_dbr(&txq_obj->txq_ctrl->priv->dbrpgs,
960 (txq_obj->sq_dbrec_page->umem),
961 txq_obj->sq_dbrec_offset));
965 * Release DevX Tx CQ resources.
968 * DevX Tx queue object.
971 mlx5_txq_release_devx_cq_resources(struct mlx5_txq_obj *txq_obj)
973 if (txq_obj->cq_devx)
974 claim_zero(mlx5_devx_cmd_destroy(txq_obj->cq_devx));
975 if (txq_obj->cq_umem)
976 claim_zero(mlx5_glue->devx_umem_dereg(txq_obj->cq_umem));
978 mlx5_free(txq_obj->cq_buf);
979 if (txq_obj->cq_dbrec_page)
980 claim_zero(mlx5_release_dbr(&txq_obj->txq_ctrl->priv->dbrpgs,
982 (txq_obj->cq_dbrec_page->umem),
983 txq_obj->cq_dbrec_offset));
987 * Destroy the Tx queue DevX object.
990 * Txq object to destroy.
993 mlx5_txq_release_devx_resources(struct mlx5_txq_obj *txq_obj)
995 mlx5_txq_release_devx_cq_resources(txq_obj);
996 mlx5_txq_release_devx_sq_resources(txq_obj);
1000 * Create a DevX CQ object and its resources for an Tx queue.
1003 * Pointer to Ethernet device.
1005 * Queue index in DPDK Tx queue array.
1008 * Number of CQEs in CQ, 0 otherwise and rte_errno is set.
1011 mlx5_txq_create_devx_cq_resources(struct rte_eth_dev *dev, uint16_t idx)
1013 struct mlx5_priv *priv = dev->data->dev_private;
1014 struct mlx5_txq_data *txq_data = (*priv->txqs)[idx];
1015 struct mlx5_txq_ctrl *txq_ctrl =
1016 container_of(txq_data, struct mlx5_txq_ctrl, txq);
1017 struct mlx5_txq_obj *txq_obj = txq_ctrl->obj;
1018 struct mlx5_devx_cq_attr cq_attr = { 0 };
1019 struct mlx5_cqe *cqe;
1026 MLX5_ASSERT(txq_data);
1027 MLX5_ASSERT(txq_obj);
1028 page_size = rte_mem_page_size();
1029 if (page_size == (size_t)-1) {
1030 DRV_LOG(ERR, "Failed to get mem page size.");
1034 /* Allocate memory buffer for CQEs. */
1035 alignment = MLX5_CQE_BUF_ALIGNMENT;
1036 if (alignment == (size_t)-1) {
1037 DRV_LOG(ERR, "Failed to get CQE buf alignment.");
1041 /* Create the Completion Queue. */
1042 cqe_n = (1UL << txq_data->elts_n) / MLX5_TX_COMP_THRESH +
1043 1 + MLX5_TX_COMP_THRESH_INLINE_DIV;
1044 cqe_n = 1UL << log2above(cqe_n);
1045 if (cqe_n > UINT16_MAX) {
1047 "Port %u Tx queue %u requests to many CQEs %u.",
1048 dev->data->port_id, txq_data->idx, cqe_n);
1052 txq_obj->cq_buf = mlx5_malloc(MLX5_MEM_RTE | MLX5_MEM_ZERO,
1053 cqe_n * sizeof(struct mlx5_cqe),
1055 priv->sh->numa_node);
1056 if (!txq_obj->cq_buf) {
1058 "Port %u Tx queue %u cannot allocate memory (CQ).",
1059 dev->data->port_id, txq_data->idx);
1063 /* Register allocated buffer in user space with DevX. */
1064 txq_obj->cq_umem = mlx5_glue->devx_umem_reg(priv->sh->ctx,
1065 (void *)txq_obj->cq_buf,
1066 cqe_n * sizeof(struct mlx5_cqe),
1067 IBV_ACCESS_LOCAL_WRITE);
1068 if (!txq_obj->cq_umem) {
1071 "Port %u Tx queue %u cannot register memory (CQ).",
1072 dev->data->port_id, txq_data->idx);
1075 /* Allocate doorbell record for completion queue. */
1076 txq_obj->cq_dbrec_offset = mlx5_get_dbr(priv->sh->ctx,
1078 &txq_obj->cq_dbrec_page);
1079 if (txq_obj->cq_dbrec_offset < 0) {
1081 DRV_LOG(ERR, "Failed to allocate CQ door-bell.");
1084 cq_attr.cqe_size = (sizeof(struct mlx5_cqe) == 128) ?
1085 MLX5_CQE_SIZE_128B : MLX5_CQE_SIZE_64B;
1086 cq_attr.uar_page_id = mlx5_os_get_devx_uar_page_id(priv->sh->tx_uar);
1087 cq_attr.eqn = priv->sh->eqn;
1088 cq_attr.q_umem_valid = 1;
1089 cq_attr.q_umem_offset = (uintptr_t)txq_obj->cq_buf % page_size;
1090 cq_attr.q_umem_id = mlx5_os_get_umem_id(txq_obj->cq_umem);
1091 cq_attr.db_umem_valid = 1;
1092 cq_attr.db_umem_offset = txq_obj->cq_dbrec_offset;
1093 cq_attr.db_umem_id = mlx5_os_get_umem_id(txq_obj->cq_dbrec_page->umem);
1094 cq_attr.log_cq_size = rte_log2_u32(cqe_n);
1095 cq_attr.log_page_size = rte_log2_u32(page_size);
1096 /* Create completion queue object with DevX. */
1097 txq_obj->cq_devx = mlx5_devx_cmd_create_cq(priv->sh->ctx, &cq_attr);
1098 if (!txq_obj->cq_devx) {
1100 DRV_LOG(ERR, "Port %u Tx queue %u CQ creation failure.",
1101 dev->data->port_id, idx);
1104 /* Initial fill CQ buffer with invalid CQE opcode. */
1105 cqe = (struct mlx5_cqe *)txq_obj->cq_buf;
1106 for (i = 0; i < cqe_n; i++) {
1107 cqe->op_own = (MLX5_CQE_INVALID << 4) | MLX5_CQE_OWNER_MASK;
1113 mlx5_txq_release_devx_cq_resources(txq_obj);
1119 * Create a SQ object and its resources using DevX.
1122 * Pointer to Ethernet device.
1124 * Queue index in DPDK Tx queue array.
1127 * Number of WQEs in SQ, 0 otherwise and rte_errno is set.
1130 mlx5_txq_create_devx_sq_resources(struct rte_eth_dev *dev, uint16_t idx)
1132 struct mlx5_priv *priv = dev->data->dev_private;
1133 struct mlx5_txq_data *txq_data = (*priv->txqs)[idx];
1134 struct mlx5_txq_ctrl *txq_ctrl =
1135 container_of(txq_data, struct mlx5_txq_ctrl, txq);
1136 struct mlx5_txq_obj *txq_obj = txq_ctrl->obj;
1137 struct mlx5_devx_create_sq_attr sq_attr = { 0 };
1142 MLX5_ASSERT(txq_data);
1143 MLX5_ASSERT(txq_obj);
1144 page_size = rte_mem_page_size();
1145 if (page_size == (size_t)-1) {
1146 DRV_LOG(ERR, "Failed to get mem page size.");
1150 wqe_n = RTE_MIN(1UL << txq_data->elts_n,
1151 (uint32_t)priv->sh->device_attr.max_qp_wr);
1152 txq_obj->sq_buf = mlx5_malloc(MLX5_MEM_RTE | MLX5_MEM_ZERO,
1153 wqe_n * sizeof(struct mlx5_wqe),
1154 page_size, priv->sh->numa_node);
1155 if (!txq_obj->sq_buf) {
1157 "Port %u Tx queue %u cannot allocate memory (SQ).",
1158 dev->data->port_id, txq_data->idx);
1162 /* Register allocated buffer in user space with DevX. */
1163 txq_obj->sq_umem = mlx5_glue->devx_umem_reg
1165 (void *)txq_obj->sq_buf,
1166 wqe_n * sizeof(struct mlx5_wqe),
1167 IBV_ACCESS_LOCAL_WRITE);
1168 if (!txq_obj->sq_umem) {
1171 "Port %u Tx queue %u cannot register memory (SQ).",
1172 dev->data->port_id, txq_data->idx);
1175 /* Allocate doorbell record for send queue. */
1176 txq_obj->sq_dbrec_offset = mlx5_get_dbr(priv->sh->ctx,
1178 &txq_obj->sq_dbrec_page);
1179 if (txq_obj->sq_dbrec_offset < 0) {
1181 DRV_LOG(ERR, "Failed to allocate SQ door-bell.");
1184 sq_attr.tis_lst_sz = 1;
1185 sq_attr.tis_num = priv->sh->tis->id;
1186 sq_attr.state = MLX5_SQC_STATE_RST;
1187 sq_attr.cqn = txq_obj->cq_devx->id;
1188 sq_attr.flush_in_error_en = 1;
1189 sq_attr.allow_multi_pkt_send_wqe = !!priv->config.mps;
1190 sq_attr.allow_swp = !!priv->config.swp;
1191 sq_attr.min_wqe_inline_mode = priv->config.hca_attr.vport_inline_mode;
1192 sq_attr.wq_attr.uar_page =
1193 mlx5_os_get_devx_uar_page_id(priv->sh->tx_uar);
1194 sq_attr.wq_attr.wq_type = MLX5_WQ_TYPE_CYCLIC;
1195 sq_attr.wq_attr.pd = priv->sh->pdn;
1196 sq_attr.wq_attr.log_wq_stride = rte_log2_u32(MLX5_WQE_SIZE);
1197 sq_attr.wq_attr.log_wq_sz = log2above(wqe_n);
1198 sq_attr.wq_attr.dbr_umem_valid = 1;
1199 sq_attr.wq_attr.dbr_addr = txq_obj->sq_dbrec_offset;
1200 sq_attr.wq_attr.dbr_umem_id =
1201 mlx5_os_get_umem_id(txq_obj->sq_dbrec_page->umem);
1202 sq_attr.wq_attr.wq_umem_valid = 1;
1203 sq_attr.wq_attr.wq_umem_id = mlx5_os_get_umem_id(txq_obj->sq_umem);
1204 sq_attr.wq_attr.wq_umem_offset = (uintptr_t)txq_obj->sq_buf % page_size;
1205 /* Create Send Queue object with DevX. */
1206 txq_obj->sq_devx = mlx5_devx_cmd_create_sq(priv->sh->ctx, &sq_attr);
1207 if (!txq_obj->sq_devx) {
1209 DRV_LOG(ERR, "Port %u Tx queue %u SQ creation failure.",
1210 dev->data->port_id, idx);
1216 mlx5_txq_release_devx_sq_resources(txq_obj);
1223 * Create the Tx queue DevX object.
1226 * Pointer to Ethernet device.
1228 * Queue index in DPDK Tx queue array.
1231 * 0 on success, a negative errno value otherwise and rte_errno is set.
1234 mlx5_txq_devx_obj_new(struct rte_eth_dev *dev, uint16_t idx)
1236 struct mlx5_priv *priv = dev->data->dev_private;
1237 struct mlx5_txq_data *txq_data = (*priv->txqs)[idx];
1238 struct mlx5_txq_ctrl *txq_ctrl =
1239 container_of(txq_data, struct mlx5_txq_ctrl, txq);
1241 if (txq_ctrl->type == MLX5_TXQ_TYPE_HAIRPIN)
1242 return mlx5_txq_obj_hairpin_new(dev, idx);
1243 #ifndef HAVE_MLX5DV_DEVX_UAR_OFFSET
1244 DRV_LOG(ERR, "Port %u Tx queue %u cannot create with DevX, no UAR.",
1245 dev->data->port_id, idx);
1249 struct mlx5_dev_ctx_shared *sh = priv->sh;
1250 struct mlx5_txq_obj *txq_obj = txq_ctrl->obj;
1256 MLX5_ASSERT(txq_data);
1257 MLX5_ASSERT(txq_obj);
1258 txq_obj->txq_ctrl = txq_ctrl;
1260 cqe_n = mlx5_txq_create_devx_cq_resources(dev, idx);
1265 txq_data->cqe_n = log2above(cqe_n);
1266 txq_data->cqe_s = 1 << txq_data->cqe_n;
1267 txq_data->cqe_m = txq_data->cqe_s - 1;
1268 txq_data->cqes = (volatile struct mlx5_cqe *)txq_obj->cq_buf;
1269 txq_data->cq_ci = 0;
1270 txq_data->cq_pi = 0;
1271 txq_data->cq_db = (volatile uint32_t *)(txq_obj->cq_dbrec_page->dbrs +
1272 txq_obj->cq_dbrec_offset);
1273 *txq_data->cq_db = 0;
1274 /* Create Send Queue object with DevX. */
1275 wqe_n = mlx5_txq_create_devx_sq_resources(dev, idx);
1280 /* Create the Work Queue. */
1281 txq_data->wqe_n = log2above(wqe_n);
1282 txq_data->wqe_s = 1 << txq_data->wqe_n;
1283 txq_data->wqe_m = txq_data->wqe_s - 1;
1284 txq_data->wqes = (struct mlx5_wqe *)txq_obj->sq_buf;
1285 txq_data->wqes_end = txq_data->wqes + txq_data->wqe_s;
1286 txq_data->wqe_ci = 0;
1287 txq_data->wqe_pi = 0;
1288 txq_data->wqe_comp = 0;
1289 txq_data->wqe_thres = txq_data->wqe_s / MLX5_TX_COMP_THRESH_INLINE_DIV;
1290 txq_data->qp_db = (volatile uint32_t *)
1291 (txq_obj->sq_dbrec_page->dbrs +
1292 txq_obj->sq_dbrec_offset +
1293 MLX5_SND_DBR * sizeof(uint32_t));
1294 *txq_data->qp_db = 0;
1295 txq_data->qp_num_8s = txq_obj->sq_devx->id << 8;
1296 /* Change Send Queue state to Ready-to-Send. */
1297 ret = mlx5_devx_modify_sq(txq_obj, MLX5_TXQ_MOD_RST2RDY, 0);
1301 "Port %u Tx queue %u SQ state to SQC_STATE_RDY failed.",
1302 dev->data->port_id, idx);
1305 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
1307 * If using DevX need to query and store TIS transport domain value.
1308 * This is done once per port.
1309 * Will use this value on Rx, when creating matching TIR.
1312 priv->sh->tdn = priv->sh->td->id;
1314 MLX5_ASSERT(sh->tx_uar);
1315 reg_addr = mlx5_os_get_devx_uar_reg_addr(sh->tx_uar);
1316 MLX5_ASSERT(reg_addr);
1317 txq_ctrl->bf_reg = reg_addr;
1318 txq_ctrl->uar_mmap_offset =
1319 mlx5_os_get_devx_uar_mmap_offset(sh->tx_uar);
1320 txq_uar_init(txq_ctrl);
1323 ret = rte_errno; /* Save rte_errno before cleanup. */
1324 mlx5_txq_release_devx_resources(txq_obj);
1325 rte_errno = ret; /* Restore rte_errno. */
1331 * Release an Tx DevX queue object.
1334 * DevX Tx queue object.
1337 mlx5_txq_devx_obj_release(struct mlx5_txq_obj *txq_obj)
1339 MLX5_ASSERT(txq_obj);
1340 if (txq_obj->txq_ctrl->type == MLX5_TXQ_TYPE_HAIRPIN) {
1342 claim_zero(mlx5_devx_cmd_destroy(txq_obj->tis));
1343 #ifdef HAVE_MLX5DV_DEVX_UAR_OFFSET
1345 mlx5_txq_release_devx_resources(txq_obj);
1350 struct mlx5_obj_ops devx_obj_ops = {
1351 .rxq_obj_modify_vlan_strip = mlx5_rxq_obj_modify_rq_vlan_strip,
1352 .rxq_obj_new = mlx5_rxq_devx_obj_new,
1353 .rxq_event_get = mlx5_rx_devx_get_event,
1354 .rxq_obj_modify = mlx5_devx_modify_rq,
1355 .rxq_obj_release = mlx5_rxq_devx_obj_release,
1356 .ind_table_new = mlx5_devx_ind_table_new,
1357 .ind_table_destroy = mlx5_devx_ind_table_destroy,
1358 .hrxq_new = mlx5_devx_hrxq_new,
1359 .hrxq_destroy = mlx5_devx_tir_destroy,
1360 .drop_action_create = mlx5_devx_drop_action_create,
1361 .drop_action_destroy = mlx5_devx_drop_action_destroy,
1362 .txq_obj_new = mlx5_txq_devx_obj_new,
1363 .txq_obj_modify = mlx5_devx_modify_sq,
1364 .txq_obj_release = mlx5_txq_devx_obj_release,