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>
39 #include "bnxt_ring.h"
46 void bnxt_free_txq_stats(struct bnxt_tx_queue *txq)
48 struct bnxt_cp_ring_info *cpr = txq->cp_ring;
50 /* 'Unreserve' rte_memzone */
56 static void bnxt_tx_queue_release_mbufs(struct bnxt_tx_queue *txq __rte_unused)
58 /* TODO: Requires interaction with TX ring */
61 void bnxt_free_tx_mbufs(struct bnxt *bp)
63 struct bnxt_tx_queue *txq;
66 for (i = 0; i < (int)bp->tx_nr_rings; i++) {
67 txq = bp->tx_queues[i];
68 bnxt_tx_queue_release_mbufs(txq);
72 void bnxt_tx_queue_release_op(void *tx_queue)
74 struct bnxt_tx_queue *txq = (struct bnxt_tx_queue *)tx_queue;
77 /* TODO: Free ring and stats here */
82 int bnxt_tx_queue_setup_op(struct rte_eth_dev *eth_dev,
85 unsigned int socket_id,
86 const struct rte_eth_txconf *tx_conf)
88 struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private;
89 struct bnxt_tx_queue *txq;
91 if (!nb_desc || nb_desc > MAX_TX_DESC_CNT) {
92 RTE_LOG(ERR, PMD, "nb_desc %d is invalid", nb_desc);
96 if (eth_dev->data->tx_queues) {
97 txq = eth_dev->data->tx_queues[queue_idx];
99 bnxt_tx_queue_release_op(txq);
103 txq = rte_zmalloc_socket("bnxt_tx_queue", sizeof(struct bnxt_tx_queue),
104 RTE_CACHE_LINE_SIZE, socket_id);
106 RTE_LOG(ERR, PMD, "bnxt_tx_queue allocation failed!");
110 txq->nb_tx_desc = nb_desc;
111 txq->tx_free_thresh = tx_conf->tx_free_thresh;
113 /* TODO: Initialize ring structure */
115 txq->queue_id = queue_idx;
116 txq->port_id = eth_dev->data->port_id;
118 /* TODO: Allocate TX ring hardware descriptors */
120 /* TODO: Initialize the ring */
122 eth_dev->data->tx_queues[queue_idx] = txq;