4 * Copyright(c) Broadcom Limited.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of Broadcom Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 #include <rte_malloc.h>
40 #include "bnxt_ring.h"
47 void bnxt_free_txq_stats(struct bnxt_tx_queue *txq)
49 struct bnxt_cp_ring_info *cpr = txq->cp_ring;
51 /* 'Unreserve' rte_memzone */
57 static void bnxt_tx_queue_release_mbufs(struct bnxt_tx_queue *txq __rte_unused)
59 /* TODO: Requires interaction with TX ring */
62 void bnxt_free_tx_mbufs(struct bnxt *bp)
64 struct bnxt_tx_queue *txq;
67 for (i = 0; i < (int)bp->tx_nr_rings; i++) {
68 txq = bp->tx_queues[i];
69 bnxt_tx_queue_release_mbufs(txq);
73 void bnxt_tx_queue_release_op(void *tx_queue)
75 struct bnxt_tx_queue *txq = (struct bnxt_tx_queue *)tx_queue;
78 /* TODO: Free ring and stats here */
83 int bnxt_tx_queue_setup_op(struct rte_eth_dev *eth_dev,
86 unsigned int socket_id,
87 const struct rte_eth_txconf *tx_conf)
89 struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private;
90 struct bnxt_tx_queue *txq;
92 if (!nb_desc || nb_desc > MAX_TX_DESC_CNT) {
93 RTE_LOG(ERR, PMD, "nb_desc %d is invalid", nb_desc);
97 if (eth_dev->data->tx_queues) {
98 txq = eth_dev->data->tx_queues[queue_idx];
100 bnxt_tx_queue_release_op(txq);
104 txq = rte_zmalloc_socket("bnxt_tx_queue", sizeof(struct bnxt_tx_queue),
105 RTE_CACHE_LINE_SIZE, socket_id);
107 RTE_LOG(ERR, PMD, "bnxt_tx_queue allocation failed!");
111 txq->nb_tx_desc = nb_desc;
112 txq->tx_free_thresh = tx_conf->tx_free_thresh;
114 /* TODO: Initialize ring structure */
116 txq->queue_id = queue_idx;
117 txq->port_id = eth_dev->data->port_id;
119 /* TODO: Allocate TX ring hardware descriptors */
121 /* TODO: Initialize the ring */
123 eth_dev->data->tx_queues[queue_idx] = txq;