Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright 2017 6WIND S.A.
3 : : * Copyright 2017 Mellanox Technologies, Ltd
4 : : */
5 : :
6 : : /**
7 : : * @file
8 : : * Tx queues configuration for mlx4 driver.
9 : : */
10 : :
11 : : #include <errno.h>
12 : : #include <stddef.h>
13 : : #include <stdint.h>
14 : : #include <string.h>
15 : : #include <sys/mman.h>
16 : : #include <inttypes.h>
17 : : #include <unistd.h>
18 : :
19 : : /* Verbs headers do not support -pedantic. */
20 : : #ifdef PEDANTIC
21 : : #pragma GCC diagnostic ignored "-Wpedantic"
22 : : #endif
23 : : #include <infiniband/verbs.h>
24 : : #ifdef PEDANTIC
25 : : #pragma GCC diagnostic error "-Wpedantic"
26 : : #endif
27 : :
28 : : #include <rte_common.h>
29 : : #include <rte_errno.h>
30 : : #include <ethdev_driver.h>
31 : : #include <rte_malloc.h>
32 : : #include <rte_mbuf.h>
33 : : #include <rte_mempool.h>
34 : :
35 : : #include "mlx4.h"
36 : : #include "mlx4_glue.h"
37 : : #include "mlx4_prm.h"
38 : : #include "mlx4_rxtx.h"
39 : : #include "mlx4_utils.h"
40 : :
41 : : /**
42 : : * Initialize Tx UAR registers for primary process.
43 : : *
44 : : * @param txq
45 : : * Pointer to Tx queue structure.
46 : : */
47 : : static void
48 : : txq_uar_init(struct txq *txq)
49 : : {
50 : 0 : struct mlx4_priv *priv = txq->priv;
51 : 0 : struct mlx4_proc_priv *ppriv = MLX4_PROC_PRIV(PORT_ID(priv));
52 : :
53 : : MLX4_ASSERT(rte_eal_process_type() == RTE_PROC_PRIMARY);
54 : : MLX4_ASSERT(ppriv);
55 : 0 : ppriv->uar_table[txq->stats.idx] = txq->msq.db;
56 : : }
57 : :
58 : : #ifdef HAVE_IBV_MLX4_UAR_MMAP_OFFSET
59 : : /**
60 : : * Remap UAR register of a Tx queue for secondary process.
61 : : *
62 : : * Remapped address is stored at the table in the process private structure of
63 : : * the device, indexed by queue index.
64 : : *
65 : : * @param txq
66 : : * Pointer to Tx queue structure.
67 : : * @param fd
68 : : * Verbs file descriptor to map UAR pages.
69 : : *
70 : : * @return
71 : : * 0 on success, a negative errno value otherwise and rte_errno is set.
72 : : */
73 : : static int
74 : 0 : txq_uar_init_secondary(struct txq *txq, int fd)
75 : : {
76 : 0 : struct mlx4_priv *priv = txq->priv;
77 : 0 : struct mlx4_proc_priv *ppriv = MLX4_PROC_PRIV(PORT_ID(priv));
78 : : void *addr;
79 : : uintptr_t uar_va;
80 : : uintptr_t offset;
81 : 0 : const size_t page_size = sysconf(_SC_PAGESIZE);
82 : :
83 : : MLX4_ASSERT(ppriv);
84 : : /*
85 : : * As rdma-core, UARs are mapped in size of OS page
86 : : * size. Ref to libmlx4 function: mlx4_init_context()
87 : : */
88 : 0 : uar_va = (uintptr_t)txq->msq.db;
89 : 0 : offset = uar_va & (page_size - 1); /* Offset in page. */
90 : 0 : addr = mmap(NULL, page_size, PROT_WRITE, MAP_SHARED, fd,
91 : : txq->msq.uar_mmap_offset);
92 [ # # ]: 0 : if (addr == MAP_FAILED) {
93 : 0 : ERROR("port %u mmap failed for BF reg of txq %u",
94 : : txq->port_id, txq->stats.idx);
95 : 0 : rte_errno = ENXIO;
96 : 0 : return -rte_errno;
97 : : }
98 : 0 : addr = RTE_PTR_ADD(addr, offset);
99 : 0 : ppriv->uar_table[txq->stats.idx] = addr;
100 : 0 : return 0;
101 : : }
102 : :
103 : : /**
104 : : * Unmap UAR register of a Tx queue for secondary process.
105 : : *
106 : : * @param txq
107 : : * Pointer to Tx queue structure.
108 : : */
109 : : static void
110 : 0 : txq_uar_uninit_secondary(struct txq *txq)
111 : : {
112 : 0 : struct mlx4_proc_priv *ppriv = MLX4_PROC_PRIV(PORT_ID(txq->priv));
113 : 0 : const size_t page_size = sysconf(_SC_PAGESIZE);
114 : : void *addr;
115 : :
116 : 0 : addr = ppriv->uar_table[txq->stats.idx];
117 [ # # ]: 0 : if (addr != NULL)
118 : 0 : munmap(RTE_PTR_ALIGN_FLOOR(addr, page_size), page_size);
119 : 0 : }
120 : :
121 : : /**
122 : : * Initialize Tx UAR registers for secondary process.
123 : : *
124 : : * @param dev
125 : : * Pointer to Ethernet device.
126 : : * @param fd
127 : : * Verbs file descriptor to map UAR pages.
128 : : *
129 : : * @return
130 : : * 0 on success, a negative errno value otherwise and rte_errno is set.
131 : : */
132 : : int
133 : 0 : mlx4_tx_uar_init_secondary(struct rte_eth_dev *dev, int fd)
134 : : {
135 : 0 : const unsigned int txqs_n = dev->data->nb_tx_queues;
136 : : struct txq *txq;
137 : : unsigned int i;
138 : : int ret;
139 : :
140 : : MLX4_ASSERT(rte_eal_process_type() == RTE_PROC_SECONDARY);
141 [ # # ]: 0 : for (i = 0; i != txqs_n; ++i) {
142 : 0 : txq = dev->data->tx_queues[i];
143 [ # # ]: 0 : if (!txq)
144 : 0 : continue;
145 : : MLX4_ASSERT(txq->stats.idx == (uint16_t)i);
146 : 0 : ret = txq_uar_init_secondary(txq, fd);
147 [ # # ]: 0 : if (ret)
148 : 0 : goto error;
149 : : }
150 : : return 0;
151 : : error:
152 : : /* Rollback. */
153 : : do {
154 : 0 : txq = dev->data->tx_queues[i];
155 [ # # ]: 0 : if (!txq)
156 : 0 : continue;
157 : 0 : txq_uar_uninit_secondary(txq);
158 [ # # ]: 0 : } while (i--);
159 : 0 : return -rte_errno;
160 : : }
161 : :
162 : : void
163 : 0 : mlx4_tx_uar_uninit_secondary(struct rte_eth_dev *dev)
164 : : {
165 : 0 : struct mlx4_proc_priv *ppriv =
166 : : (struct mlx4_proc_priv *)dev->process_private;
167 : 0 : const size_t page_size = sysconf(_SC_PAGESIZE);
168 : : void *addr;
169 : : size_t i;
170 : :
171 [ # # ]: 0 : if (page_size == (size_t)-1) {
172 : 0 : ERROR("Failed to get mem page size");
173 : 0 : return;
174 : : }
175 [ # # ]: 0 : for (i = 0; i < ppriv->uar_table_sz; i++) {
176 : 0 : addr = ppriv->uar_table[i];
177 [ # # ]: 0 : if (addr)
178 : 0 : munmap(RTE_PTR_ALIGN_FLOOR(addr, page_size), page_size);
179 : : }
180 : : }
181 : :
182 : : #else
183 : : int
184 : : mlx4_tx_uar_init_secondary(struct rte_eth_dev *dev __rte_unused,
185 : : int fd __rte_unused)
186 : : {
187 : : MLX4_ASSERT(rte_eal_process_type() == RTE_PROC_SECONDARY);
188 : : ERROR("UAR remap is not supported");
189 : : rte_errno = ENOTSUP;
190 : : return -rte_errno;
191 : : }
192 : :
193 : : void
194 : : mlx4_tx_uar_uninit_secondary(struct rte_eth_dev *dev __rte_unused)
195 : : {
196 : : assert(rte_eal_process_type() == RTE_PROC_SECONDARY);
197 : : ERROR("UAR remap is not supported");
198 : : }
199 : : #endif
200 : :
201 : : /**
202 : : * Free Tx queue elements.
203 : : *
204 : : * @param txq
205 : : * Pointer to Tx queue structure.
206 : : */
207 : : static void
208 : 0 : mlx4_txq_free_elts(struct txq *txq)
209 : : {
210 : 0 : struct txq_elt (*elts)[txq->elts_n] = txq->elts;
211 : : unsigned int n = txq->elts_n;
212 : :
213 : 0 : DEBUG("%p: freeing WRs, %u", (void *)txq, n);
214 [ # # ]: 0 : while (n--) {
215 : : struct txq_elt *elt = &(*elts)[n];
216 : :
217 [ # # ]: 0 : if (elt->buf) {
218 : 0 : rte_pktmbuf_free(elt->buf);
219 : 0 : elt->buf = NULL;
220 : 0 : elt->wqe = NULL;
221 : : }
222 : : }
223 : 0 : txq->elts_tail = txq->elts_head;
224 : 0 : }
225 : :
226 : : /**
227 : : * Retrieves information needed in order to directly access the Tx queue.
228 : : *
229 : : * @param txq
230 : : * Pointer to Tx queue structure.
231 : : * @param mlxdv
232 : : * Pointer to device information for this Tx queue.
233 : : */
234 : : static void
235 : 0 : mlx4_txq_fill_dv_obj_info(struct txq *txq, struct mlx4dv_obj *mlxdv)
236 : : {
237 : : struct mlx4_sq *sq = &txq->msq;
238 : : struct mlx4_cq *cq = &txq->mcq;
239 : 0 : struct mlx4dv_qp *dqp = mlxdv->qp.out;
240 : 0 : struct mlx4dv_cq *dcq = mlxdv->cq.out;
241 : :
242 : : /* Total length, including headroom and spare WQEs. */
243 : 0 : sq->size = (uint32_t)dqp->rq.offset - (uint32_t)dqp->sq.offset;
244 : 0 : sq->buf = (uint8_t *)dqp->buf.buf + dqp->sq.offset;
245 : 0 : sq->eob = sq->buf + sq->size;
246 : 0 : uint32_t headroom_size = 2048 + (1 << dqp->sq.wqe_shift);
247 : : /* Continuous headroom size bytes must always stay freed. */
248 : 0 : sq->remain_size = sq->size - headroom_size;
249 : 0 : sq->owner_opcode = MLX4_OPCODE_SEND | (0u << MLX4_SQ_OWNER_BIT);
250 : 0 : sq->stamp = rte_cpu_to_be_32(MLX4_SQ_STAMP_VAL |
251 : : (0u << MLX4_SQ_OWNER_BIT));
252 : : #ifdef HAVE_IBV_MLX4_UAR_MMAP_OFFSET
253 : 0 : sq->uar_mmap_offset = dqp->uar_mmap_offset;
254 : : #else
255 : : sq->uar_mmap_offset = -1; /* Make mmap() fail. */
256 : : #endif
257 : 0 : sq->db = dqp->sdb;
258 : 0 : sq->doorbell_qpn = dqp->doorbell_qpn;
259 : 0 : cq->buf = dcq->buf.buf;
260 : 0 : cq->cqe_cnt = dcq->cqe_cnt;
261 : 0 : cq->set_ci_db = dcq->set_ci_db;
262 : 0 : cq->cqe_64 = (dcq->cqe_size & 64) ? 1 : 0;
263 : 0 : }
264 : :
265 : : /**
266 : : * Returns the per-port supported offloads.
267 : : *
268 : : * @param priv
269 : : * Pointer to private structure.
270 : : *
271 : : * @return
272 : : * Supported Tx offloads.
273 : : */
274 : : uint64_t
275 : 0 : mlx4_get_tx_port_offloads(struct mlx4_priv *priv)
276 : : {
277 : : uint64_t offloads = RTE_ETH_TX_OFFLOAD_MULTI_SEGS;
278 : :
279 [ # # ]: 0 : if (priv->hw_csum) {
280 : : offloads |= (RTE_ETH_TX_OFFLOAD_IPV4_CKSUM |
281 : : RTE_ETH_TX_OFFLOAD_UDP_CKSUM |
282 : : RTE_ETH_TX_OFFLOAD_TCP_CKSUM);
283 : : }
284 [ # # ]: 0 : if (priv->tso)
285 : 0 : offloads |= RTE_ETH_TX_OFFLOAD_TCP_TSO;
286 [ # # ]: 0 : if (priv->hw_csum_l2tun) {
287 : 0 : offloads |= RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM;
288 [ # # ]: 0 : if (priv->tso)
289 : 0 : offloads |= (RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO |
290 : : RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO);
291 : : }
292 : 0 : return offloads;
293 : : }
294 : :
295 : : /**
296 : : * DPDK callback to configure a Tx queue.
297 : : *
298 : : * @param dev
299 : : * Pointer to Ethernet device structure.
300 : : * @param idx
301 : : * Tx queue index.
302 : : * @param desc
303 : : * Number of descriptors to configure in queue.
304 : : * @param socket
305 : : * NUMA socket on which memory must be allocated.
306 : : * @param[in] conf
307 : : * Thresholds parameters.
308 : : *
309 : : * @return
310 : : * 0 on success, negative errno value otherwise and rte_errno is set.
311 : : */
312 : : int
313 : 0 : mlx4_tx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,
314 : : unsigned int socket, const struct rte_eth_txconf *conf)
315 : : {
316 : 0 : struct mlx4_priv *priv = dev->data->dev_private;
317 : : struct mlx4dv_obj mlxdv;
318 : : struct mlx4dv_qp dv_qp;
319 : : struct mlx4dv_cq dv_cq;
320 : 0 : struct txq_elt (*elts)[rte_align32pow2(desc)];
321 : : struct ibv_qp_init_attr qp_init_attr;
322 : : struct txq *txq;
323 : : uint8_t *bounce_buf;
324 : 0 : struct mlx4_malloc_vec vec[] = {
325 : : {
326 : : .align = RTE_CACHE_LINE_SIZE,
327 : : .size = sizeof(*txq),
328 : : .addr = (void **)&txq,
329 : : },
330 : : {
331 : : .align = RTE_CACHE_LINE_SIZE,
332 : : .size = sizeof(*elts),
333 : : .addr = (void **)&elts,
334 : : },
335 : : {
336 : : .align = RTE_CACHE_LINE_SIZE,
337 : : .size = MLX4_MAX_WQE_SIZE,
338 : : .addr = (void **)&bounce_buf,
339 : : },
340 : : };
341 : : int ret;
342 : : uint64_t offloads;
343 : :
344 : 0 : offloads = conf->offloads | dev->data->dev_conf.txmode.offloads;
345 : 0 : DEBUG("%p: configuring queue %u for %u descriptors",
346 : : (void *)dev, idx, desc);
347 [ # # ]: 0 : if (idx >= dev->data->nb_tx_queues) {
348 : 0 : rte_errno = EOVERFLOW;
349 : 0 : ERROR("%p: queue index out of range (%u >= %u)",
350 : : (void *)dev, idx, dev->data->nb_tx_queues);
351 : 0 : return -rte_errno;
352 : : }
353 : 0 : txq = dev->data->tx_queues[idx];
354 [ # # ]: 0 : if (txq) {
355 : 0 : rte_errno = EEXIST;
356 : 0 : DEBUG("%p: Tx queue %u already configured, release it first",
357 : : (void *)dev, idx);
358 : 0 : return -rte_errno;
359 : : }
360 [ # # ]: 0 : if (!desc) {
361 : 0 : rte_errno = EINVAL;
362 : 0 : ERROR("%p: invalid number of Tx descriptors", (void *)dev);
363 : 0 : return -rte_errno;
364 : : }
365 [ # # ]: 0 : if (desc != RTE_DIM(*elts)) {
366 : 0 : desc = RTE_DIM(*elts);
367 : 0 : WARN("%p: increased number of descriptors in Tx queue %u"
368 : : " to the next power of two (%u)",
369 : : (void *)dev, idx, desc);
370 : : }
371 : : /* Allocate and initialize Tx queue. */
372 : 0 : mlx4_zmallocv_socket("TXQ", vec, RTE_DIM(vec), socket);
373 [ # # ]: 0 : if (!txq) {
374 : 0 : ERROR("%p: unable to allocate queue index %u",
375 : : (void *)dev, idx);
376 : 0 : return -rte_errno;
377 : : }
378 : 0 : *txq = (struct txq){
379 : : .priv = priv,
380 : 0 : .port_id = dev->data->port_id,
381 : : .stats = {
382 : : .idx = idx,
383 : : },
384 : : .socket = socket,
385 : : .elts_n = desc,
386 : : .elts = elts,
387 : : .elts_head = 0,
388 : : .elts_tail = 0,
389 : : /*
390 : : * Request send completion every MLX4_PMD_TX_PER_COMP_REQ
391 : : * packets or at least 4 times per ring.
392 : : */
393 : : .elts_comp_cd =
394 : 0 : RTE_MIN(MLX4_PMD_TX_PER_COMP_REQ, desc / 4),
395 : : .elts_comp_cd_init =
396 : 0 : RTE_MIN(MLX4_PMD_TX_PER_COMP_REQ, desc / 4),
397 [ # # ]: 0 : .csum = priv->hw_csum &&
398 [ # # ]: 0 : (offloads & (RTE_ETH_TX_OFFLOAD_IPV4_CKSUM |
399 : : RTE_ETH_TX_OFFLOAD_UDP_CKSUM |
400 : : RTE_ETH_TX_OFFLOAD_TCP_CKSUM)),
401 [ # # ]: 0 : .csum_l2tun = priv->hw_csum_l2tun &&
402 [ # # ]: 0 : (offloads &
403 : : RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM),
404 : : /* Enable Tx loopback for VF devices. */
405 : 0 : .lb = !!priv->vf,
406 : : .bounce_buf = bounce_buf,
407 : : };
408 : 0 : dev->data->tx_queues[idx] = txq;
409 : 0 : priv->verbs_alloc_ctx.type = MLX4_VERBS_ALLOC_TYPE_TX_QUEUE;
410 : 0 : priv->verbs_alloc_ctx.obj = txq;
411 : 0 : txq->cq = mlx4_glue->create_cq(priv->ctx, desc, NULL, NULL, 0);
412 [ # # ]: 0 : if (!txq->cq) {
413 : 0 : rte_errno = ENOMEM;
414 : 0 : ERROR("%p: CQ creation failure: %s",
415 : : (void *)dev, strerror(rte_errno));
416 : 0 : goto error;
417 : : }
418 : 0 : qp_init_attr = (struct ibv_qp_init_attr){
419 : : .send_cq = txq->cq,
420 : : .recv_cq = txq->cq,
421 : : .cap = {
422 : : .max_send_wr =
423 : 0 : RTE_MIN(priv->device_attr.max_qp_wr, desc),
424 : : .max_send_sge = 1,
425 : : .max_inline_data = MLX4_PMD_MAX_INLINE,
426 : : },
427 : : .qp_type = IBV_QPT_RAW_PACKET,
428 : : /* No completion events must occur by default. */
429 : : .sq_sig_all = 0,
430 : : };
431 : 0 : txq->qp = mlx4_glue->create_qp(priv->pd, &qp_init_attr);
432 [ # # ]: 0 : if (!txq->qp) {
433 [ # # ]: 0 : rte_errno = errno ? errno : EINVAL;
434 : 0 : ERROR("%p: QP creation failure: %s",
435 : : (void *)dev, strerror(rte_errno));
436 : 0 : goto error;
437 : : }
438 : 0 : txq->max_inline = qp_init_attr.cap.max_inline_data;
439 : 0 : ret = mlx4_glue->modify_qp
440 : : (txq->qp,
441 : 0 : &(struct ibv_qp_attr){
442 : : .qp_state = IBV_QPS_INIT,
443 : 0 : .port_num = priv->port,
444 : : },
445 : : IBV_QP_STATE | IBV_QP_PORT);
446 [ # # ]: 0 : if (ret) {
447 : 0 : rte_errno = ret;
448 : 0 : ERROR("%p: QP state to IBV_QPS_INIT failed: %s",
449 : : (void *)dev, strerror(rte_errno));
450 : 0 : goto error;
451 : : }
452 : 0 : ret = mlx4_glue->modify_qp
453 : 0 : (txq->qp,
454 : 0 : &(struct ibv_qp_attr){
455 : : .qp_state = IBV_QPS_RTR,
456 : : },
457 : : IBV_QP_STATE);
458 [ # # ]: 0 : if (ret) {
459 : 0 : rte_errno = ret;
460 : 0 : ERROR("%p: QP state to IBV_QPS_RTR failed: %s",
461 : : (void *)dev, strerror(rte_errno));
462 : 0 : goto error;
463 : : }
464 : 0 : ret = mlx4_glue->modify_qp
465 : 0 : (txq->qp,
466 : 0 : &(struct ibv_qp_attr){
467 : : .qp_state = IBV_QPS_RTS,
468 : : },
469 : : IBV_QP_STATE);
470 [ # # ]: 0 : if (ret) {
471 : 0 : rte_errno = ret;
472 : 0 : ERROR("%p: QP state to IBV_QPS_RTS failed: %s",
473 : : (void *)dev, strerror(rte_errno));
474 : 0 : goto error;
475 : : }
476 : : /* Retrieve device queue information. */
477 : : #ifdef HAVE_IBV_MLX4_UAR_MMAP_OFFSET
478 : 0 : dv_qp = (struct mlx4dv_qp){
479 : : .comp_mask = MLX4DV_QP_MASK_UAR_MMAP_OFFSET,
480 : : };
481 : : #endif
482 : 0 : mlxdv.cq.in = txq->cq;
483 : 0 : mlxdv.cq.out = &dv_cq;
484 : 0 : mlxdv.qp.in = txq->qp;
485 : 0 : mlxdv.qp.out = &dv_qp;
486 : 0 : ret = mlx4_glue->dv_init_obj(&mlxdv, MLX4DV_OBJ_QP | MLX4DV_OBJ_CQ);
487 [ # # ]: 0 : if (ret) {
488 : 0 : rte_errno = EINVAL;
489 : 0 : ERROR("%p: failed to obtain information needed for"
490 : : " accessing the device queues", (void *)dev);
491 : 0 : goto error;
492 : : }
493 : : #ifdef HAVE_IBV_MLX4_UAR_MMAP_OFFSET
494 [ # # ]: 0 : if (!(dv_qp.comp_mask & MLX4DV_QP_MASK_UAR_MMAP_OFFSET)) {
495 : 0 : WARN("%p: failed to obtain UAR mmap offset", (void *)dev);
496 : 0 : dv_qp.uar_mmap_offset = -1; /* Make mmap() fail. */
497 : : }
498 : : #endif
499 : 0 : mlx4_txq_fill_dv_obj_info(txq, &mlxdv);
500 : : txq_uar_init(txq);
501 : : /* Save first wqe pointer in the first element. */
502 : 0 : (&(*txq->elts)[0])->wqe =
503 : 0 : (volatile struct mlx4_wqe_ctrl_seg *)txq->msq.buf;
504 [ # # ]: 0 : if (mlx4_mr_btree_init(&txq->mr_ctrl.cache_bh,
505 : : MLX4_MR_BTREE_CACHE_N, socket)) {
506 : : /* rte_errno is already set. */
507 : 0 : goto error;
508 : : }
509 : : /* Save pointer of global generation number to check memory event. */
510 : 0 : txq->mr_ctrl.dev_gen_ptr = &priv->mr.dev_gen;
511 : 0 : DEBUG("%p: adding Tx queue %p to list", (void *)dev, (void *)txq);
512 : 0 : priv->verbs_alloc_ctx.type = MLX4_VERBS_ALLOC_TYPE_NONE;
513 : 0 : return 0;
514 : 0 : error:
515 : 0 : ret = rte_errno;
516 : 0 : mlx4_tx_queue_release(dev, idx);
517 : 0 : rte_errno = ret;
518 : : MLX4_ASSERT(rte_errno > 0);
519 : 0 : priv->verbs_alloc_ctx.type = MLX4_VERBS_ALLOC_TYPE_NONE;
520 : 0 : return -rte_errno;
521 : : }
522 : :
523 : : /**
524 : : * DPDK callback to release a Tx queue.
525 : : *
526 : : * @param dev
527 : : * Pointer to Ethernet device structure.
528 : : * @param idx
529 : : * Transmit queue index.
530 : : */
531 : : void
532 : 0 : mlx4_tx_queue_release(struct rte_eth_dev *dev, uint16_t idx)
533 : : {
534 : 0 : struct txq *txq = dev->data->tx_queues[idx];
535 : :
536 [ # # ]: 0 : if (txq == NULL)
537 : : return;
538 : 0 : DEBUG("%p: removing Tx queue %hu from list", (void *)dev, idx);
539 : 0 : dev->data->tx_queues[idx] = NULL;
540 : 0 : mlx4_txq_free_elts(txq);
541 [ # # ]: 0 : if (txq->qp)
542 : 0 : claim_zero(mlx4_glue->destroy_qp(txq->qp));
543 [ # # ]: 0 : if (txq->cq)
544 : 0 : claim_zero(mlx4_glue->destroy_cq(txq->cq));
545 : 0 : mlx4_mr_btree_free(&txq->mr_ctrl.cache_bh);
546 : 0 : rte_free(txq);
547 : : }
|