1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2015 6WIND S.A.
3 * Copyright 2015 Mellanox Technologies, Ltd
15 /* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
17 #pragma GCC diagnostic ignored "-Wpedantic"
19 #include <infiniband/verbs.h>
20 #include <infiniband/mlx5dv.h>
22 #pragma GCC diagnostic error "-Wpedantic"
26 #include <rte_malloc.h>
27 #include <rte_ethdev_driver.h>
28 #include <rte_common.h>
30 #include <mlx5_glue.h>
31 #include <mlx5_devx_cmds.h>
32 #include <mlx5_common.h>
33 #include <mlx5_common_mr.h>
35 #include "mlx5_defs.h"
36 #include "mlx5_utils.h"
38 #include "mlx5_rxtx.h"
39 #include "mlx5_autoconf.h"
42 * Allocate TX queue elements.
45 * Pointer to TX queue structure.
48 txq_alloc_elts(struct mlx5_txq_ctrl *txq_ctrl)
50 const unsigned int elts_n = 1 << txq_ctrl->txq.elts_n;
53 for (i = 0; (i != elts_n); ++i)
54 txq_ctrl->txq.elts[i] = NULL;
55 DRV_LOG(DEBUG, "port %u Tx queue %u allocated and configured %u WRs",
56 PORT_ID(txq_ctrl->priv), txq_ctrl->txq.idx, elts_n);
57 txq_ctrl->txq.elts_head = 0;
58 txq_ctrl->txq.elts_tail = 0;
59 txq_ctrl->txq.elts_comp = 0;
63 * Free TX queue elements.
66 * Pointer to TX queue structure.
69 txq_free_elts(struct mlx5_txq_ctrl *txq_ctrl)
71 const uint16_t elts_n = 1 << txq_ctrl->txq.elts_n;
72 const uint16_t elts_m = elts_n - 1;
73 uint16_t elts_head = txq_ctrl->txq.elts_head;
74 uint16_t elts_tail = txq_ctrl->txq.elts_tail;
75 struct rte_mbuf *(*elts)[elts_n] = &txq_ctrl->txq.elts;
77 DRV_LOG(DEBUG, "port %u Tx queue %u freeing WRs",
78 PORT_ID(txq_ctrl->priv), txq_ctrl->txq.idx);
79 txq_ctrl->txq.elts_head = 0;
80 txq_ctrl->txq.elts_tail = 0;
81 txq_ctrl->txq.elts_comp = 0;
83 while (elts_tail != elts_head) {
84 struct rte_mbuf *elt = (*elts)[elts_tail & elts_m];
86 MLX5_ASSERT(elt != NULL);
87 rte_pktmbuf_free_seg(elt);
88 #ifdef RTE_LIBRTE_MLX5_DEBUG
90 memset(&(*elts)[elts_tail & elts_m],
92 sizeof((*elts)[elts_tail & elts_m]));
99 * Returns the per-port supported offloads.
102 * Pointer to Ethernet device.
105 * Supported Tx offloads.
108 mlx5_get_tx_port_offloads(struct rte_eth_dev *dev)
110 struct mlx5_priv *priv = dev->data->dev_private;
111 uint64_t offloads = (DEV_TX_OFFLOAD_MULTI_SEGS |
112 DEV_TX_OFFLOAD_VLAN_INSERT);
113 struct mlx5_dev_config *config = &priv->config;
116 offloads |= (DEV_TX_OFFLOAD_IPV4_CKSUM |
117 DEV_TX_OFFLOAD_UDP_CKSUM |
118 DEV_TX_OFFLOAD_TCP_CKSUM);
120 offloads |= DEV_TX_OFFLOAD_TCP_TSO;
123 offloads |= DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
125 offloads |= (DEV_TX_OFFLOAD_IP_TNL_TSO |
126 DEV_TX_OFFLOAD_UDP_TNL_TSO);
128 if (config->tunnel_en) {
130 offloads |= DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
132 offloads |= (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
133 DEV_TX_OFFLOAD_GRE_TNL_TSO |
134 DEV_TX_OFFLOAD_GENEVE_TNL_TSO);
140 * Tx queue presetup checks.
143 * Pointer to Ethernet device structure.
147 * Number of descriptors to configure in queue.
150 * 0 on success, a negative errno value otherwise and rte_errno is set.
153 mlx5_tx_queue_pre_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t *desc)
155 struct mlx5_priv *priv = dev->data->dev_private;
157 if (*desc <= MLX5_TX_COMP_THRESH) {
159 "port %u number of descriptors requested for Tx queue"
160 " %u must be higher than MLX5_TX_COMP_THRESH, using %u"
161 " instead of %u", dev->data->port_id, idx,
162 MLX5_TX_COMP_THRESH + 1, *desc);
163 *desc = MLX5_TX_COMP_THRESH + 1;
165 if (!rte_is_power_of_2(*desc)) {
166 *desc = 1 << log2above(*desc);
168 "port %u increased number of descriptors in Tx queue"
169 " %u to the next power of two (%d)",
170 dev->data->port_id, idx, *desc);
172 DRV_LOG(DEBUG, "port %u configuring queue %u for %u descriptors",
173 dev->data->port_id, idx, *desc);
174 if (idx >= priv->txqs_n) {
175 DRV_LOG(ERR, "port %u Tx queue index out of range (%u >= %u)",
176 dev->data->port_id, idx, priv->txqs_n);
177 rte_errno = EOVERFLOW;
180 if (!mlx5_txq_releasable(dev, idx)) {
182 DRV_LOG(ERR, "port %u unable to release queue index %u",
183 dev->data->port_id, idx);
186 mlx5_txq_release(dev, idx);
190 * DPDK callback to configure a TX queue.
193 * Pointer to Ethernet device structure.
197 * Number of descriptors to configure in queue.
199 * NUMA socket on which memory must be allocated.
201 * Thresholds parameters.
204 * 0 on success, a negative errno value otherwise and rte_errno is set.
207 mlx5_tx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,
208 unsigned int socket, const struct rte_eth_txconf *conf)
210 struct mlx5_priv *priv = dev->data->dev_private;
211 struct mlx5_txq_data *txq = (*priv->txqs)[idx];
212 struct mlx5_txq_ctrl *txq_ctrl =
213 container_of(txq, struct mlx5_txq_ctrl, txq);
216 res = mlx5_tx_queue_pre_setup(dev, idx, &desc);
219 txq_ctrl = mlx5_txq_new(dev, idx, desc, socket, conf);
221 DRV_LOG(ERR, "port %u unable to allocate queue index %u",
222 dev->data->port_id, idx);
225 DRV_LOG(DEBUG, "port %u adding Tx queue %u to list",
226 dev->data->port_id, idx);
227 (*priv->txqs)[idx] = &txq_ctrl->txq;
232 * DPDK callback to configure a TX hairpin queue.
235 * Pointer to Ethernet device structure.
239 * Number of descriptors to configure in queue.
240 * @param[in] hairpin_conf
241 * The hairpin binding configuration.
244 * 0 on success, a negative errno value otherwise and rte_errno is set.
247 mlx5_tx_hairpin_queue_setup(struct rte_eth_dev *dev, uint16_t idx,
249 const struct rte_eth_hairpin_conf *hairpin_conf)
251 struct mlx5_priv *priv = dev->data->dev_private;
252 struct mlx5_txq_data *txq = (*priv->txqs)[idx];
253 struct mlx5_txq_ctrl *txq_ctrl =
254 container_of(txq, struct mlx5_txq_ctrl, txq);
257 res = mlx5_tx_queue_pre_setup(dev, idx, &desc);
260 if (hairpin_conf->peer_count != 1 ||
261 hairpin_conf->peers[0].port != dev->data->port_id ||
262 hairpin_conf->peers[0].queue >= priv->rxqs_n) {
263 DRV_LOG(ERR, "port %u unable to setup hairpin queue index %u "
264 " invalid hairpind configuration", dev->data->port_id,
269 txq_ctrl = mlx5_txq_hairpin_new(dev, idx, desc, hairpin_conf);
271 DRV_LOG(ERR, "port %u unable to allocate queue index %u",
272 dev->data->port_id, idx);
275 DRV_LOG(DEBUG, "port %u adding Tx queue %u to list",
276 dev->data->port_id, idx);
277 (*priv->txqs)[idx] = &txq_ctrl->txq;
282 * DPDK callback to release a TX queue.
285 * Generic TX queue pointer.
288 mlx5_tx_queue_release(void *dpdk_txq)
290 struct mlx5_txq_data *txq = (struct mlx5_txq_data *)dpdk_txq;
291 struct mlx5_txq_ctrl *txq_ctrl;
292 struct mlx5_priv *priv;
297 txq_ctrl = container_of(txq, struct mlx5_txq_ctrl, txq);
298 priv = txq_ctrl->priv;
299 for (i = 0; (i != priv->txqs_n); ++i)
300 if ((*priv->txqs)[i] == txq) {
301 DRV_LOG(DEBUG, "port %u removing Tx queue %u from list",
302 PORT_ID(priv), txq->idx);
303 mlx5_txq_release(ETH_DEV(priv), i);
309 * Configure the doorbell register non-cached attribute.
312 * Pointer to Tx queue control structure.
317 txq_uar_ncattr_init(struct mlx5_txq_ctrl *txq_ctrl, size_t page_size)
319 struct mlx5_priv *priv = txq_ctrl->priv;
322 txq_ctrl->txq.db_heu = priv->config.dbnc == MLX5_TXDB_HEURISTIC;
323 txq_ctrl->txq.db_nc = 0;
324 /* Check the doorbell register mapping type. */
325 cmd = txq_ctrl->uar_mmap_offset / page_size;
326 cmd >>= MLX5_UAR_MMAP_CMD_SHIFT;
327 cmd &= MLX5_UAR_MMAP_CMD_MASK;
328 if (cmd == MLX5_MMAP_GET_NC_PAGES_CMD)
329 txq_ctrl->txq.db_nc = 1;
333 * Initialize Tx UAR registers for primary process.
336 * Pointer to Tx queue control structure.
339 txq_uar_init(struct mlx5_txq_ctrl *txq_ctrl)
341 struct mlx5_priv *priv = txq_ctrl->priv;
342 struct mlx5_proc_priv *ppriv = MLX5_PROC_PRIV(PORT_ID(priv));
343 const size_t page_size = sysconf(_SC_PAGESIZE);
345 unsigned int lock_idx;
348 if (txq_ctrl->type != MLX5_TXQ_TYPE_STANDARD)
350 MLX5_ASSERT(rte_eal_process_type() == RTE_PROC_PRIMARY);
352 ppriv->uar_table[txq_ctrl->txq.idx] = txq_ctrl->bf_reg;
353 txq_uar_ncattr_init(txq_ctrl, page_size);
355 /* Assign an UAR lock according to UAR page number */
356 lock_idx = (txq_ctrl->uar_mmap_offset / page_size) &
357 MLX5_UAR_PAGE_NUM_MASK;
358 txq_ctrl->txq.uar_lock = &priv->uar_lock[lock_idx];
363 * Remap UAR register of a Tx queue for secondary process.
365 * Remapped address is stored at the table in the process private structure of
366 * the device, indexed by queue index.
369 * Pointer to Tx queue control structure.
371 * Verbs file descriptor to map UAR pages.
374 * 0 on success, a negative errno value otherwise and rte_errno is set.
377 txq_uar_init_secondary(struct mlx5_txq_ctrl *txq_ctrl, int fd)
379 struct mlx5_priv *priv = txq_ctrl->priv;
380 struct mlx5_proc_priv *ppriv = MLX5_PROC_PRIV(PORT_ID(priv));
381 struct mlx5_txq_data *txq = &txq_ctrl->txq;
385 const size_t page_size = sysconf(_SC_PAGESIZE);
387 if (txq_ctrl->type != MLX5_TXQ_TYPE_STANDARD)
391 * As rdma-core, UARs are mapped in size of OS page
392 * size. Ref to libmlx5 function: mlx5_init_context()
394 uar_va = (uintptr_t)txq_ctrl->bf_reg;
395 offset = uar_va & (page_size - 1); /* Offset in page. */
396 addr = mmap(NULL, page_size, PROT_WRITE, MAP_SHARED, fd,
397 txq_ctrl->uar_mmap_offset);
398 if (addr == MAP_FAILED) {
400 "port %u mmap failed for BF reg of txq %u",
401 txq->port_id, txq->idx);
405 addr = RTE_PTR_ADD(addr, offset);
406 ppriv->uar_table[txq->idx] = addr;
407 txq_uar_ncattr_init(txq_ctrl, page_size);
412 * Unmap UAR register of a Tx queue for secondary process.
415 * Pointer to Tx queue control structure.
418 txq_uar_uninit_secondary(struct mlx5_txq_ctrl *txq_ctrl)
420 struct mlx5_proc_priv *ppriv = MLX5_PROC_PRIV(PORT_ID(txq_ctrl->priv));
421 const size_t page_size = sysconf(_SC_PAGESIZE);
424 if (txq_ctrl->type != MLX5_TXQ_TYPE_STANDARD)
426 addr = ppriv->uar_table[txq_ctrl->txq.idx];
427 munmap(RTE_PTR_ALIGN_FLOOR(addr, page_size), page_size);
431 * Deinitialize Tx UAR registers for secondary process.
434 * Pointer to Ethernet device.
437 mlx5_tx_uar_uninit_secondary(struct rte_eth_dev *dev)
439 struct mlx5_priv *priv = dev->data->dev_private;
440 struct mlx5_txq_data *txq;
441 struct mlx5_txq_ctrl *txq_ctrl;
444 MLX5_ASSERT(rte_eal_process_type() == RTE_PROC_SECONDARY);
445 for (i = 0; i != priv->txqs_n; ++i) {
446 if (!(*priv->txqs)[i])
448 txq = (*priv->txqs)[i];
449 txq_ctrl = container_of(txq, struct mlx5_txq_ctrl, txq);
450 txq_uar_uninit_secondary(txq_ctrl);
455 * Initialize Tx UAR registers for secondary process.
458 * Pointer to Ethernet device.
460 * Verbs file descriptor to map UAR pages.
463 * 0 on success, a negative errno value otherwise and rte_errno is set.
466 mlx5_tx_uar_init_secondary(struct rte_eth_dev *dev, int fd)
468 struct mlx5_priv *priv = dev->data->dev_private;
469 struct mlx5_txq_data *txq;
470 struct mlx5_txq_ctrl *txq_ctrl;
474 MLX5_ASSERT(rte_eal_process_type() == RTE_PROC_SECONDARY);
475 for (i = 0; i != priv->txqs_n; ++i) {
476 if (!(*priv->txqs)[i])
478 txq = (*priv->txqs)[i];
479 txq_ctrl = container_of(txq, struct mlx5_txq_ctrl, txq);
480 if (txq_ctrl->type != MLX5_TXQ_TYPE_STANDARD)
482 MLX5_ASSERT(txq->idx == (uint16_t)i);
483 ret = txq_uar_init_secondary(txq_ctrl, fd);
491 if (!(*priv->txqs)[i])
493 txq = (*priv->txqs)[i];
494 txq_ctrl = container_of(txq, struct mlx5_txq_ctrl, txq);
495 txq_uar_uninit_secondary(txq_ctrl);
501 * Create the Tx hairpin queue object.
504 * Pointer to Ethernet device.
506 * Queue index in DPDK Tx queue array
509 * The hairpin DevX object initialised, NULL otherwise and rte_errno is set.
511 static struct mlx5_txq_obj *
512 mlx5_txq_obj_hairpin_new(struct rte_eth_dev *dev, uint16_t idx)
514 struct mlx5_priv *priv = dev->data->dev_private;
515 struct mlx5_txq_data *txq_data = (*priv->txqs)[idx];
516 struct mlx5_txq_ctrl *txq_ctrl =
517 container_of(txq_data, struct mlx5_txq_ctrl, txq);
518 struct mlx5_devx_create_sq_attr attr = { 0 };
519 struct mlx5_txq_obj *tmpl = NULL;
520 uint32_t max_wq_data;
522 MLX5_ASSERT(txq_data);
523 MLX5_ASSERT(!txq_ctrl->obj);
524 tmpl = rte_calloc_socket(__func__, 1, sizeof(*tmpl), 0,
528 "port %u Tx queue %u cannot allocate memory resources",
529 dev->data->port_id, txq_data->idx);
533 tmpl->type = MLX5_TXQ_OBJ_TYPE_DEVX_HAIRPIN;
534 tmpl->txq_ctrl = txq_ctrl;
537 max_wq_data = priv->config.hca_attr.log_max_hairpin_wq_data_sz;
538 /* Jumbo frames > 9KB should be supported, and more packets. */
539 if (priv->config.log_hp_size != (uint32_t)MLX5_ARG_UNSET) {
540 if (priv->config.log_hp_size > max_wq_data) {
541 DRV_LOG(ERR, "total data size %u power of 2 is "
542 "too large for hairpin",
543 priv->config.log_hp_size);
548 attr.wq_attr.log_hairpin_data_sz = priv->config.log_hp_size;
550 attr.wq_attr.log_hairpin_data_sz =
551 (max_wq_data < MLX5_HAIRPIN_JUMBO_LOG_SIZE) ?
552 max_wq_data : MLX5_HAIRPIN_JUMBO_LOG_SIZE;
554 /* Set the packets number to the maximum value for performance. */
555 attr.wq_attr.log_hairpin_num_packets =
556 attr.wq_attr.log_hairpin_data_sz -
557 MLX5_HAIRPIN_QUEUE_STRIDE;
558 attr.tis_num = priv->sh->tis->id;
559 tmpl->sq = mlx5_devx_cmd_create_sq(priv->sh->ctx, &attr);
562 "port %u tx hairpin queue %u can't create sq object",
563 dev->data->port_id, idx);
568 DRV_LOG(DEBUG, "port %u sxq %u updated with %p", dev->data->port_id,
570 rte_atomic32_inc(&tmpl->refcnt);
571 LIST_INSERT_HEAD(&priv->txqsobj, tmpl, next);
576 * Create the Tx queue Verbs object.
579 * Pointer to Ethernet device.
581 * Queue index in DPDK Tx queue array.
583 * Type of the Tx queue object to create.
586 * The Verbs object initialised, NULL otherwise and rte_errno is set.
588 struct mlx5_txq_obj *
589 mlx5_txq_obj_new(struct rte_eth_dev *dev, uint16_t idx,
590 enum mlx5_txq_obj_type type)
592 struct mlx5_priv *priv = dev->data->dev_private;
593 struct mlx5_txq_data *txq_data = (*priv->txqs)[idx];
594 struct mlx5_txq_ctrl *txq_ctrl =
595 container_of(txq_data, struct mlx5_txq_ctrl, txq);
596 struct mlx5_txq_obj tmpl;
597 struct mlx5_txq_obj *txq_obj = NULL;
599 struct ibv_qp_init_attr_ex init;
600 struct ibv_cq_init_attr_ex cq;
601 struct ibv_qp_attr mod;
604 struct mlx5dv_qp qp = { .comp_mask = MLX5DV_QP_MASK_UAR_MMAP_OFFSET };
605 struct mlx5dv_cq cq_info;
606 struct mlx5dv_obj obj;
607 const int desc = 1 << txq_data->elts_n;
610 if (type == MLX5_TXQ_OBJ_TYPE_DEVX_HAIRPIN)
611 return mlx5_txq_obj_hairpin_new(dev, idx);
612 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
613 /* If using DevX, need additional mask to read tisn value. */
614 if (priv->config.devx && !priv->sh->tdn)
615 qp.comp_mask |= MLX5DV_QP_MASK_RAW_QP_HANDLES;
617 MLX5_ASSERT(txq_data);
618 priv->verbs_alloc_ctx.type = MLX5_VERBS_ALLOC_TYPE_TX_QUEUE;
619 priv->verbs_alloc_ctx.obj = txq_ctrl;
620 if (mlx5_getenv_int("MLX5_ENABLE_CQE_COMPRESSION")) {
622 "port %u MLX5_ENABLE_CQE_COMPRESSION must never be set",
627 memset(&tmpl, 0, sizeof(struct mlx5_txq_obj));
628 attr.cq = (struct ibv_cq_init_attr_ex){
631 cqe_n = desc / MLX5_TX_COMP_THRESH +
632 1 + MLX5_TX_COMP_THRESH_INLINE_DIV;
633 tmpl.cq = mlx5_glue->create_cq(priv->sh->ctx, cqe_n, NULL, NULL, 0);
634 if (tmpl.cq == NULL) {
635 DRV_LOG(ERR, "port %u Tx queue %u CQ creation failure",
636 dev->data->port_id, idx);
640 attr.init = (struct ibv_qp_init_attr_ex){
641 /* CQ to be associated with the send queue. */
643 /* CQ to be associated with the receive queue. */
646 /* Max number of outstanding WRs. */
648 ((priv->sh->device_attr.max_qp_wr <
650 priv->sh->device_attr.max_qp_wr :
653 * Max number of scatter/gather elements in a WR,
654 * must be 1 to prevent libmlx5 from trying to affect
655 * too much memory. TX gather is not impacted by the
656 * device_attr.max_sge limit and will still work
661 .qp_type = IBV_QPT_RAW_PACKET,
663 * Do *NOT* enable this, completions events are managed per
668 .comp_mask = IBV_QP_INIT_ATTR_PD,
670 if (txq_data->inlen_send)
671 attr.init.cap.max_inline_data = txq_ctrl->max_inline_data;
672 if (txq_data->tso_en) {
673 attr.init.max_tso_header = txq_ctrl->max_tso_header;
674 attr.init.comp_mask |= IBV_QP_INIT_ATTR_MAX_TSO_HEADER;
676 tmpl.qp = mlx5_glue->create_qp_ex(priv->sh->ctx, &attr.init);
677 if (tmpl.qp == NULL) {
678 DRV_LOG(ERR, "port %u Tx queue %u QP creation failure",
679 dev->data->port_id, idx);
683 attr.mod = (struct ibv_qp_attr){
684 /* Move the QP to this state. */
685 .qp_state = IBV_QPS_INIT,
686 /* IB device port number. */
687 .port_num = (uint8_t)priv->dev_port,
689 ret = mlx5_glue->modify_qp(tmpl.qp, &attr.mod,
690 (IBV_QP_STATE | IBV_QP_PORT));
693 "port %u Tx queue %u QP state to IBV_QPS_INIT failed",
694 dev->data->port_id, idx);
698 attr.mod = (struct ibv_qp_attr){
699 .qp_state = IBV_QPS_RTR
701 ret = mlx5_glue->modify_qp(tmpl.qp, &attr.mod, IBV_QP_STATE);
704 "port %u Tx queue %u QP state to IBV_QPS_RTR failed",
705 dev->data->port_id, idx);
709 attr.mod.qp_state = IBV_QPS_RTS;
710 ret = mlx5_glue->modify_qp(tmpl.qp, &attr.mod, IBV_QP_STATE);
713 "port %u Tx queue %u QP state to IBV_QPS_RTS failed",
714 dev->data->port_id, idx);
718 txq_obj = rte_calloc_socket(__func__, 1, sizeof(struct mlx5_txq_obj), 0,
721 DRV_LOG(ERR, "port %u Tx queue %u cannot allocate memory",
722 dev->data->port_id, idx);
727 obj.cq.out = &cq_info;
730 ret = mlx5_glue->dv_init_obj(&obj, MLX5DV_OBJ_CQ | MLX5DV_OBJ_QP);
735 if (cq_info.cqe_size != RTE_CACHE_LINE_SIZE) {
737 "port %u wrong MLX5_CQE_SIZE environment variable"
738 " value: it should be set to %u",
739 dev->data->port_id, RTE_CACHE_LINE_SIZE);
743 txq_data->cqe_n = log2above(cq_info.cqe_cnt);
744 txq_data->cqe_s = 1 << txq_data->cqe_n;
745 txq_data->cqe_m = txq_data->cqe_s - 1;
746 txq_data->qp_num_8s = tmpl.qp->qp_num << 8;
747 txq_data->wqes = qp.sq.buf;
748 txq_data->wqe_n = log2above(qp.sq.wqe_cnt);
749 txq_data->wqe_s = 1 << txq_data->wqe_n;
750 txq_data->wqe_m = txq_data->wqe_s - 1;
751 txq_data->wqes_end = txq_data->wqes + txq_data->wqe_s;
752 txq_data->qp_db = &qp.dbrec[MLX5_SND_DBR];
753 txq_data->cq_db = cq_info.dbrec;
754 txq_data->cqes = (volatile struct mlx5_cqe *)cq_info.buf;
757 txq_data->wqe_ci = 0;
758 txq_data->wqe_pi = 0;
759 txq_data->wqe_comp = 0;
760 txq_data->wqe_thres = txq_data->wqe_s / MLX5_TX_COMP_THRESH_INLINE_DIV;
761 txq_data->fcqs = rte_calloc_socket(__func__,
763 sizeof(*txq_data->fcqs),
766 if (!txq_data->fcqs) {
767 DRV_LOG(ERR, "port %u Tx queue %u cannot allocate memory (FCQ)",
768 dev->data->port_id, idx);
772 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
774 * If using DevX need to query and store TIS transport domain value.
775 * This is done once per port.
776 * Will use this value on Rx, when creating matching TIR.
778 if (priv->config.devx && !priv->sh->tdn) {
779 ret = mlx5_devx_cmd_qp_query_tis_td(tmpl.qp, qp.tisn,
782 DRV_LOG(ERR, "Fail to query port %u Tx queue %u QP TIS "
783 "transport domain", dev->data->port_id, idx);
787 DRV_LOG(DEBUG, "port %u Tx queue %u TIS number %d "
788 "transport domain %d", dev->data->port_id,
789 idx, qp.tisn, priv->sh->tdn);
793 txq_obj->qp = tmpl.qp;
794 txq_obj->cq = tmpl.cq;
795 rte_atomic32_inc(&txq_obj->refcnt);
796 txq_ctrl->bf_reg = qp.bf.reg;
797 if (qp.comp_mask & MLX5DV_QP_MASK_UAR_MMAP_OFFSET) {
798 txq_ctrl->uar_mmap_offset = qp.uar_mmap_offset;
799 DRV_LOG(DEBUG, "port %u: uar_mmap_offset 0x%"PRIx64,
800 dev->data->port_id, txq_ctrl->uar_mmap_offset);
803 "port %u failed to retrieve UAR info, invalid"
809 txq_uar_init(txq_ctrl);
810 LIST_INSERT_HEAD(&priv->txqsobj, txq_obj, next);
811 txq_obj->txq_ctrl = txq_ctrl;
812 priv->verbs_alloc_ctx.type = MLX5_VERBS_ALLOC_TYPE_NONE;
815 ret = rte_errno; /* Save rte_errno before cleanup. */
817 claim_zero(mlx5_glue->destroy_cq(tmpl.cq));
819 claim_zero(mlx5_glue->destroy_qp(tmpl.qp));
821 rte_free(txq_data->fcqs);
824 priv->verbs_alloc_ctx.type = MLX5_VERBS_ALLOC_TYPE_NONE;
825 rte_errno = ret; /* Restore rte_errno. */
830 * Get an Tx queue Verbs object.
833 * Pointer to Ethernet device.
835 * Queue index in DPDK Tx queue array.
838 * The Verbs object if it exists.
840 struct mlx5_txq_obj *
841 mlx5_txq_obj_get(struct rte_eth_dev *dev, uint16_t idx)
843 struct mlx5_priv *priv = dev->data->dev_private;
844 struct mlx5_txq_ctrl *txq_ctrl;
846 if (idx >= priv->txqs_n)
848 if (!(*priv->txqs)[idx])
850 txq_ctrl = container_of((*priv->txqs)[idx], struct mlx5_txq_ctrl, txq);
852 rte_atomic32_inc(&txq_ctrl->obj->refcnt);
853 return txq_ctrl->obj;
857 * Release an Tx verbs queue object.
860 * Verbs Tx queue object.
863 * 1 while a reference on it exists, 0 when freed.
866 mlx5_txq_obj_release(struct mlx5_txq_obj *txq_obj)
868 MLX5_ASSERT(txq_obj);
869 if (rte_atomic32_dec_and_test(&txq_obj->refcnt)) {
870 if (txq_obj->type == MLX5_TXQ_OBJ_TYPE_DEVX_HAIRPIN) {
872 claim_zero(mlx5_devx_cmd_destroy(txq_obj->tis));
874 claim_zero(mlx5_glue->destroy_qp(txq_obj->qp));
875 claim_zero(mlx5_glue->destroy_cq(txq_obj->cq));
876 if (txq_obj->txq_ctrl->txq.fcqs)
877 rte_free(txq_obj->txq_ctrl->txq.fcqs);
879 LIST_REMOVE(txq_obj, next);
887 * Verify the Verbs Tx queue list is empty
890 * Pointer to Ethernet device.
893 * The number of object not released.
896 mlx5_txq_obj_verify(struct rte_eth_dev *dev)
898 struct mlx5_priv *priv = dev->data->dev_private;
900 struct mlx5_txq_obj *txq_obj;
902 LIST_FOREACH(txq_obj, &priv->txqsobj, next) {
903 DRV_LOG(DEBUG, "port %u Verbs Tx queue %u still referenced",
904 dev->data->port_id, txq_obj->txq_ctrl->txq.idx);
911 * Calculate the total number of WQEBB for Tx queue.
913 * Simplified version of calc_sq_size() in rdma-core.
916 * Pointer to Tx queue control structure.
919 * The number of WQEBB.
922 txq_calc_wqebb_cnt(struct mlx5_txq_ctrl *txq_ctrl)
924 unsigned int wqe_size;
925 const unsigned int desc = 1 << txq_ctrl->txq.elts_n;
927 wqe_size = MLX5_WQE_CSEG_SIZE +
930 MLX5_ESEG_MIN_INLINE_SIZE +
931 txq_ctrl->max_inline_data;
932 return rte_align32pow2(wqe_size * desc) / MLX5_WQE_SIZE;
936 * Calculate the maximal inline data size for Tx queue.
939 * Pointer to Tx queue control structure.
942 * The maximal inline data size.
945 txq_calc_inline_max(struct mlx5_txq_ctrl *txq_ctrl)
947 const unsigned int desc = 1 << txq_ctrl->txq.elts_n;
948 struct mlx5_priv *priv = txq_ctrl->priv;
949 unsigned int wqe_size;
951 wqe_size = priv->sh->device_attr.max_qp_wr / desc;
955 * This calculation is derived from tthe source of
956 * mlx5_calc_send_wqe() in rdma_core library.
958 wqe_size = wqe_size * MLX5_WQE_SIZE -
963 MLX5_DSEG_MIN_INLINE_SIZE;
968 * Set Tx queue parameters from device configuration.
971 * Pointer to Tx queue control structure.
974 txq_set_params(struct mlx5_txq_ctrl *txq_ctrl)
976 struct mlx5_priv *priv = txq_ctrl->priv;
977 struct mlx5_dev_config *config = &priv->config;
978 unsigned int inlen_send; /* Inline data for ordinary SEND.*/
979 unsigned int inlen_empw; /* Inline data for enhanced MPW. */
980 unsigned int inlen_mode; /* Minimal required Inline data. */
981 unsigned int txqs_inline; /* Min Tx queues to enable inline. */
982 uint64_t dev_txoff = priv->dev_data->dev_conf.txmode.offloads;
983 bool tso = txq_ctrl->txq.offloads & (DEV_TX_OFFLOAD_TCP_TSO |
984 DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
985 DEV_TX_OFFLOAD_GRE_TNL_TSO |
986 DEV_TX_OFFLOAD_IP_TNL_TSO |
987 DEV_TX_OFFLOAD_UDP_TNL_TSO);
991 if (config->txqs_inline == MLX5_ARG_UNSET)
993 #if defined(RTE_ARCH_ARM64)
994 (priv->pci_dev->id.device_id ==
995 PCI_DEVICE_ID_MELLANOX_CONNECTX5BF) ?
996 MLX5_INLINE_MAX_TXQS_BLUEFIELD :
998 MLX5_INLINE_MAX_TXQS;
1000 txqs_inline = (unsigned int)config->txqs_inline;
1001 inlen_send = (config->txq_inline_max == MLX5_ARG_UNSET) ?
1002 MLX5_SEND_DEF_INLINE_LEN :
1003 (unsigned int)config->txq_inline_max;
1004 inlen_empw = (config->txq_inline_mpw == MLX5_ARG_UNSET) ?
1005 MLX5_EMPW_DEF_INLINE_LEN :
1006 (unsigned int)config->txq_inline_mpw;
1007 inlen_mode = (config->txq_inline_min == MLX5_ARG_UNSET) ?
1008 0 : (unsigned int)config->txq_inline_min;
1009 if (config->mps != MLX5_MPW_ENHANCED && config->mps != MLX5_MPW)
1012 * If there is requested minimal amount of data to inline
1013 * we MUST enable inlining. This is a case for ConnectX-4
1014 * which usually requires L2 inlined for correct operating
1015 * and ConnectX-4 Lx which requires L2-L4 inlined to
1016 * support E-Switch Flows.
1019 if (inlen_mode <= MLX5_ESEG_MIN_INLINE_SIZE) {
1021 * Optimize minimal inlining for single
1022 * segment packets to fill one WQEBB
1025 temp = MLX5_ESEG_MIN_INLINE_SIZE;
1027 temp = inlen_mode - MLX5_ESEG_MIN_INLINE_SIZE;
1028 temp = RTE_ALIGN(temp, MLX5_WSEG_SIZE) +
1029 MLX5_ESEG_MIN_INLINE_SIZE;
1030 temp = RTE_MIN(temp, MLX5_SEND_MAX_INLINE_LEN);
1032 if (temp != inlen_mode) {
1034 "port %u minimal required inline setting"
1035 " aligned from %u to %u",
1036 PORT_ID(priv), inlen_mode, temp);
1041 * If port is configured to support VLAN insertion and device
1042 * does not support this feature by HW (for NICs before ConnectX-5
1043 * or in case of wqe_vlan_insert flag is not set) we must enable
1044 * data inline on all queues because it is supported by single
1047 txq_ctrl->txq.vlan_en = config->hw_vlan_insert;
1048 vlan_inline = (dev_txoff & DEV_TX_OFFLOAD_VLAN_INSERT) &&
1049 !config->hw_vlan_insert;
1051 * If there are few Tx queues it is prioritized
1052 * to save CPU cycles and disable data inlining at all.
1054 if (inlen_send && priv->txqs_n >= txqs_inline) {
1056 * The data sent with ordinal MLX5_OPCODE_SEND
1057 * may be inlined in Ethernet Segment, align the
1058 * length accordingly to fit entire WQEBBs.
1060 temp = RTE_MAX(inlen_send,
1061 MLX5_ESEG_MIN_INLINE_SIZE + MLX5_WQE_DSEG_SIZE);
1062 temp -= MLX5_ESEG_MIN_INLINE_SIZE + MLX5_WQE_DSEG_SIZE;
1063 temp = RTE_ALIGN(temp, MLX5_WQE_SIZE);
1064 temp += MLX5_ESEG_MIN_INLINE_SIZE + MLX5_WQE_DSEG_SIZE;
1065 temp = RTE_MIN(temp, MLX5_WQE_SIZE_MAX +
1066 MLX5_ESEG_MIN_INLINE_SIZE -
1067 MLX5_WQE_CSEG_SIZE -
1068 MLX5_WQE_ESEG_SIZE -
1069 MLX5_WQE_DSEG_SIZE * 2);
1070 temp = RTE_MIN(temp, MLX5_SEND_MAX_INLINE_LEN);
1071 temp = RTE_MAX(temp, inlen_mode);
1072 if (temp != inlen_send) {
1074 "port %u ordinary send inline setting"
1075 " aligned from %u to %u",
1076 PORT_ID(priv), inlen_send, temp);
1080 * Not aligned to cache lines, but to WQEs.
1081 * First bytes of data (initial alignment)
1082 * is going to be copied explicitly at the
1083 * beginning of inlining buffer in Ethernet
1086 MLX5_ASSERT(inlen_send >= MLX5_ESEG_MIN_INLINE_SIZE);
1087 MLX5_ASSERT(inlen_send <= MLX5_WQE_SIZE_MAX +
1088 MLX5_ESEG_MIN_INLINE_SIZE -
1089 MLX5_WQE_CSEG_SIZE -
1090 MLX5_WQE_ESEG_SIZE -
1091 MLX5_WQE_DSEG_SIZE * 2);
1092 } else if (inlen_mode) {
1094 * If minimal inlining is requested we must
1095 * enable inlining in general, despite the
1096 * number of configured queues. Ignore the
1097 * txq_inline_max devarg, this is not
1098 * full-featured inline.
1100 inlen_send = inlen_mode;
1102 } else if (vlan_inline) {
1104 * Hardware does not report offload for
1105 * VLAN insertion, we must enable data inline
1106 * to implement feature by software.
1108 inlen_send = MLX5_ESEG_MIN_INLINE_SIZE;
1114 txq_ctrl->txq.inlen_send = inlen_send;
1115 txq_ctrl->txq.inlen_mode = inlen_mode;
1116 txq_ctrl->txq.inlen_empw = 0;
1117 if (inlen_send && inlen_empw && priv->txqs_n >= txqs_inline) {
1119 * The data sent with MLX5_OPCODE_ENHANCED_MPSW
1120 * may be inlined in Data Segment, align the
1121 * length accordingly to fit entire WQEBBs.
1123 temp = RTE_MAX(inlen_empw,
1124 MLX5_WQE_SIZE + MLX5_DSEG_MIN_INLINE_SIZE);
1125 temp -= MLX5_DSEG_MIN_INLINE_SIZE;
1126 temp = RTE_ALIGN(temp, MLX5_WQE_SIZE);
1127 temp += MLX5_DSEG_MIN_INLINE_SIZE;
1128 temp = RTE_MIN(temp, MLX5_WQE_SIZE_MAX +
1129 MLX5_DSEG_MIN_INLINE_SIZE -
1130 MLX5_WQE_CSEG_SIZE -
1131 MLX5_WQE_ESEG_SIZE -
1132 MLX5_WQE_DSEG_SIZE);
1133 temp = RTE_MIN(temp, MLX5_EMPW_MAX_INLINE_LEN);
1134 if (temp != inlen_empw) {
1136 "port %u enhanced empw inline setting"
1137 " aligned from %u to %u",
1138 PORT_ID(priv), inlen_empw, temp);
1141 MLX5_ASSERT(inlen_empw >= MLX5_ESEG_MIN_INLINE_SIZE);
1142 MLX5_ASSERT(inlen_empw <= MLX5_WQE_SIZE_MAX +
1143 MLX5_DSEG_MIN_INLINE_SIZE -
1144 MLX5_WQE_CSEG_SIZE -
1145 MLX5_WQE_ESEG_SIZE -
1146 MLX5_WQE_DSEG_SIZE);
1147 txq_ctrl->txq.inlen_empw = inlen_empw;
1149 txq_ctrl->max_inline_data = RTE_MAX(inlen_send, inlen_empw);
1151 txq_ctrl->max_tso_header = MLX5_MAX_TSO_HEADER;
1152 txq_ctrl->max_inline_data = RTE_MAX(txq_ctrl->max_inline_data,
1153 MLX5_MAX_TSO_HEADER);
1154 txq_ctrl->txq.tso_en = 1;
1156 txq_ctrl->txq.tunnel_en = config->tunnel_en | config->swp;
1157 txq_ctrl->txq.swp_en = ((DEV_TX_OFFLOAD_IP_TNL_TSO |
1158 DEV_TX_OFFLOAD_UDP_TNL_TSO |
1159 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &
1160 txq_ctrl->txq.offloads) && config->swp;
1164 * Adjust Tx queue data inline parameters for large queue sizes.
1165 * The data inline feature requires multiple WQEs to fit the packets,
1166 * and if the large amount of Tx descriptors is requested by application
1167 * the total WQE amount may exceed the hardware capabilities. If the
1168 * default inline setting are used we can try to adjust these ones and
1169 * meet the hardware requirements and not exceed the queue size.
1172 * Pointer to Tx queue control structure.
1175 * Zero on success, otherwise the parameters can not be adjusted.
1178 txq_adjust_params(struct mlx5_txq_ctrl *txq_ctrl)
1180 struct mlx5_priv *priv = txq_ctrl->priv;
1181 struct mlx5_dev_config *config = &priv->config;
1182 unsigned int max_inline;
1184 max_inline = txq_calc_inline_max(txq_ctrl);
1185 if (!txq_ctrl->txq.inlen_send) {
1187 * Inline data feature is not engaged at all.
1188 * There is nothing to adjust.
1192 if (txq_ctrl->max_inline_data <= max_inline) {
1194 * The requested inline data length does not
1195 * exceed queue capabilities.
1199 if (txq_ctrl->txq.inlen_mode > max_inline) {
1201 "minimal data inline requirements (%u) are not"
1202 " satisfied (%u) on port %u, try the smaller"
1203 " Tx queue size (%d)",
1204 txq_ctrl->txq.inlen_mode, max_inline,
1205 priv->dev_data->port_id,
1206 priv->sh->device_attr.max_qp_wr);
1209 if (txq_ctrl->txq.inlen_send > max_inline &&
1210 config->txq_inline_max != MLX5_ARG_UNSET &&
1211 config->txq_inline_max > (int)max_inline) {
1213 "txq_inline_max requirements (%u) are not"
1214 " satisfied (%u) on port %u, try the smaller"
1215 " Tx queue size (%d)",
1216 txq_ctrl->txq.inlen_send, max_inline,
1217 priv->dev_data->port_id,
1218 priv->sh->device_attr.max_qp_wr);
1221 if (txq_ctrl->txq.inlen_empw > max_inline &&
1222 config->txq_inline_mpw != MLX5_ARG_UNSET &&
1223 config->txq_inline_mpw > (int)max_inline) {
1225 "txq_inline_mpw requirements (%u) are not"
1226 " satisfied (%u) on port %u, try the smaller"
1227 " Tx queue size (%d)",
1228 txq_ctrl->txq.inlen_empw, max_inline,
1229 priv->dev_data->port_id,
1230 priv->sh->device_attr.max_qp_wr);
1233 if (txq_ctrl->txq.tso_en && max_inline < MLX5_MAX_TSO_HEADER) {
1235 "tso header inline requirements (%u) are not"
1236 " satisfied (%u) on port %u, try the smaller"
1237 " Tx queue size (%d)",
1238 MLX5_MAX_TSO_HEADER, max_inline,
1239 priv->dev_data->port_id,
1240 priv->sh->device_attr.max_qp_wr);
1243 if (txq_ctrl->txq.inlen_send > max_inline) {
1245 "adjust txq_inline_max (%u->%u)"
1246 " due to large Tx queue on port %u",
1247 txq_ctrl->txq.inlen_send, max_inline,
1248 priv->dev_data->port_id);
1249 txq_ctrl->txq.inlen_send = max_inline;
1251 if (txq_ctrl->txq.inlen_empw > max_inline) {
1253 "adjust txq_inline_mpw (%u->%u)"
1254 "due to large Tx queue on port %u",
1255 txq_ctrl->txq.inlen_empw, max_inline,
1256 priv->dev_data->port_id);
1257 txq_ctrl->txq.inlen_empw = max_inline;
1259 txq_ctrl->max_inline_data = RTE_MAX(txq_ctrl->txq.inlen_send,
1260 txq_ctrl->txq.inlen_empw);
1261 MLX5_ASSERT(txq_ctrl->max_inline_data <= max_inline);
1262 MLX5_ASSERT(txq_ctrl->txq.inlen_mode <= max_inline);
1263 MLX5_ASSERT(txq_ctrl->txq.inlen_mode <= txq_ctrl->txq.inlen_send);
1264 MLX5_ASSERT(txq_ctrl->txq.inlen_mode <= txq_ctrl->txq.inlen_empw ||
1265 !txq_ctrl->txq.inlen_empw);
1273 * Create a DPDK Tx queue.
1276 * Pointer to Ethernet device.
1280 * Number of descriptors to configure in queue.
1282 * NUMA socket on which memory must be allocated.
1284 * Thresholds parameters.
1287 * A DPDK queue object on success, NULL otherwise and rte_errno is set.
1289 struct mlx5_txq_ctrl *
1290 mlx5_txq_new(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,
1291 unsigned int socket, const struct rte_eth_txconf *conf)
1293 struct mlx5_priv *priv = dev->data->dev_private;
1294 struct mlx5_txq_ctrl *tmpl;
1296 tmpl = rte_calloc_socket("TXQ", 1,
1298 desc * sizeof(struct rte_mbuf *),
1304 if (mlx5_mr_btree_init(&tmpl->txq.mr_ctrl.cache_bh,
1305 MLX5_MR_BTREE_CACHE_N, socket)) {
1306 /* rte_errno is already set. */
1309 /* Save pointer of global generation number to check memory event. */
1310 tmpl->txq.mr_ctrl.dev_gen_ptr = &priv->sh->share_cache.dev_gen;
1311 MLX5_ASSERT(desc > MLX5_TX_COMP_THRESH);
1312 tmpl->txq.offloads = conf->offloads |
1313 dev->data->dev_conf.txmode.offloads;
1315 tmpl->socket = socket;
1316 tmpl->txq.elts_n = log2above(desc);
1317 tmpl->txq.elts_s = desc;
1318 tmpl->txq.elts_m = desc - 1;
1319 tmpl->txq.port_id = dev->data->port_id;
1320 tmpl->txq.idx = idx;
1321 txq_set_params(tmpl);
1322 if (txq_adjust_params(tmpl))
1324 if (txq_calc_wqebb_cnt(tmpl) >
1325 priv->sh->device_attr.max_qp_wr) {
1327 "port %u Tx WQEBB count (%d) exceeds the limit (%d),"
1328 " try smaller queue size",
1329 dev->data->port_id, txq_calc_wqebb_cnt(tmpl),
1330 priv->sh->device_attr.max_qp_wr);
1334 rte_atomic32_inc(&tmpl->refcnt);
1335 tmpl->type = MLX5_TXQ_TYPE_STANDARD;
1336 LIST_INSERT_HEAD(&priv->txqsctrl, tmpl, next);
1344 * Create a DPDK Tx hairpin queue.
1347 * Pointer to Ethernet device.
1351 * Number of descriptors to configure in queue.
1352 * @param hairpin_conf
1353 * The hairpin configuration.
1356 * A DPDK queue object on success, NULL otherwise and rte_errno is set.
1358 struct mlx5_txq_ctrl *
1359 mlx5_txq_hairpin_new(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,
1360 const struct rte_eth_hairpin_conf *hairpin_conf)
1362 struct mlx5_priv *priv = dev->data->dev_private;
1363 struct mlx5_txq_ctrl *tmpl;
1365 tmpl = rte_calloc_socket("TXQ", 1,
1366 sizeof(*tmpl), 0, SOCKET_ID_ANY);
1372 tmpl->socket = SOCKET_ID_ANY;
1373 tmpl->txq.elts_n = log2above(desc);
1374 tmpl->txq.port_id = dev->data->port_id;
1375 tmpl->txq.idx = idx;
1376 tmpl->hairpin_conf = *hairpin_conf;
1377 tmpl->type = MLX5_TXQ_TYPE_HAIRPIN;
1378 rte_atomic32_inc(&tmpl->refcnt);
1379 LIST_INSERT_HEAD(&priv->txqsctrl, tmpl, next);
1387 * Pointer to Ethernet device.
1392 * A pointer to the queue if it exists.
1394 struct mlx5_txq_ctrl *
1395 mlx5_txq_get(struct rte_eth_dev *dev, uint16_t idx)
1397 struct mlx5_priv *priv = dev->data->dev_private;
1398 struct mlx5_txq_ctrl *ctrl = NULL;
1400 if ((*priv->txqs)[idx]) {
1401 ctrl = container_of((*priv->txqs)[idx], struct mlx5_txq_ctrl,
1403 mlx5_txq_obj_get(dev, idx);
1404 rte_atomic32_inc(&ctrl->refcnt);
1410 * Release a Tx queue.
1413 * Pointer to Ethernet device.
1418 * 1 while a reference on it exists, 0 when freed.
1421 mlx5_txq_release(struct rte_eth_dev *dev, uint16_t idx)
1423 struct mlx5_priv *priv = dev->data->dev_private;
1424 struct mlx5_txq_ctrl *txq;
1426 if (!(*priv->txqs)[idx])
1428 txq = container_of((*priv->txqs)[idx], struct mlx5_txq_ctrl, txq);
1429 if (txq->obj && !mlx5_txq_obj_release(txq->obj))
1431 if (rte_atomic32_dec_and_test(&txq->refcnt)) {
1433 mlx5_mr_btree_free(&txq->txq.mr_ctrl.cache_bh);
1434 LIST_REMOVE(txq, next);
1436 (*priv->txqs)[idx] = NULL;
1443 * Verify if the queue can be released.
1446 * Pointer to Ethernet device.
1451 * 1 if the queue can be released.
1454 mlx5_txq_releasable(struct rte_eth_dev *dev, uint16_t idx)
1456 struct mlx5_priv *priv = dev->data->dev_private;
1457 struct mlx5_txq_ctrl *txq;
1459 if (!(*priv->txqs)[idx])
1461 txq = container_of((*priv->txqs)[idx], struct mlx5_txq_ctrl, txq);
1462 return (rte_atomic32_read(&txq->refcnt) == 1);
1466 * Verify the Tx Queue list is empty
1469 * Pointer to Ethernet device.
1472 * The number of object not released.
1475 mlx5_txq_verify(struct rte_eth_dev *dev)
1477 struct mlx5_priv *priv = dev->data->dev_private;
1478 struct mlx5_txq_ctrl *txq_ctrl;
1481 LIST_FOREACH(txq_ctrl, &priv->txqsctrl, next) {
1482 DRV_LOG(DEBUG, "port %u Tx queue %u still referenced",
1483 dev->data->port_id, txq_ctrl->txq.idx);