X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Fbnxt%2Fbnxt_txq.c;h=99dddddfc50ff8be2f15d32f5d9d428cbfa672ee;hb=4ad5b94e0d13771a48cdf395d0c8b26e5f8cbe91;hp=892898410f1dc6118654ee3719b3979657b73e7e;hpb=51c87ebafc7d70258aaae54bc047f66ef61e8b5a;p=dpdk.git diff --git a/drivers/net/bnxt/bnxt_txq.c b/drivers/net/bnxt/bnxt_txq.c index 892898410f..99dddddfc5 100644 --- a/drivers/net/bnxt/bnxt_txq.c +++ b/drivers/net/bnxt/bnxt_txq.c @@ -36,8 +36,10 @@ #include #include "bnxt.h" +#include "bnxt_cpr.h" #include "bnxt_ring.h" #include "bnxt_txq.h" +#include "bnxt_txr.h" /* * TX Queues @@ -47,15 +49,24 @@ void bnxt_free_txq_stats(struct bnxt_tx_queue *txq) { struct bnxt_cp_ring_info *cpr = txq->cp_ring; - /* 'Unreserve' rte_memzone */ - if (cpr->hw_stats) cpr->hw_stats = NULL; } -static void bnxt_tx_queue_release_mbufs(struct bnxt_tx_queue *txq __rte_unused) +static void bnxt_tx_queue_release_mbufs(struct bnxt_tx_queue *txq) { - /* TODO: Requires interaction with TX ring */ + struct bnxt_sw_tx_bd *sw_ring; + uint16_t i; + + sw_ring = txq->tx_ring->tx_buf_ring; + if (sw_ring) { + for (i = 0; i < txq->tx_ring->tx_ring_struct->ring_size; i++) { + if (sw_ring[i].mbuf) { + rte_pktmbuf_free(sw_ring[i].mbuf); + sw_ring[i].mbuf = NULL; + } + } + } } void bnxt_free_tx_mbufs(struct bnxt *bp) @@ -74,7 +85,15 @@ void bnxt_tx_queue_release_op(void *tx_queue) struct bnxt_tx_queue *txq = (struct bnxt_tx_queue *)tx_queue; if (txq) { - /* TODO: Free ring and stats here */ + /* Free TX ring hardware descriptors */ + bnxt_tx_queue_release_mbufs(txq); + bnxt_free_ring(txq->tx_ring->tx_ring_struct); + + /* Free TX completion ring hardware descriptors */ + bnxt_free_ring(txq->cp_ring->cp_ring_struct); + + bnxt_free_txq_stats(txq); + rte_free(txq); } } @@ -87,10 +106,12 @@ int bnxt_tx_queue_setup_op(struct rte_eth_dev *eth_dev, { struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private; struct bnxt_tx_queue *txq; + int rc = 0; if (!nb_desc || nb_desc > MAX_TX_DESC_CNT) { RTE_LOG(ERR, PMD, "nb_desc %d is invalid", nb_desc); - return -EINVAL; + rc = -EINVAL; + goto out; } if (eth_dev->data->tx_queues) { @@ -102,23 +123,40 @@ int bnxt_tx_queue_setup_op(struct rte_eth_dev *eth_dev, } txq = rte_zmalloc_socket("bnxt_tx_queue", sizeof(struct bnxt_tx_queue), RTE_CACHE_LINE_SIZE, socket_id); - if (txq == NULL) { + if (!txq) { RTE_LOG(ERR, PMD, "bnxt_tx_queue allocation failed!"); - return -ENOMEM; + rc = -ENOMEM; + goto out; } txq->bp = bp; txq->nb_tx_desc = nb_desc; txq->tx_free_thresh = tx_conf->tx_free_thresh; - /* TODO: Initialize ring structure */ + rc = bnxt_init_tx_ring_struct(txq, socket_id); + if (rc) + goto out; txq->queue_id = queue_idx; txq->port_id = eth_dev->data->port_id; - /* TODO: Allocate TX ring hardware descriptors */ + /* Allocate TX ring hardware descriptors */ + if (bnxt_alloc_rings(bp, queue_idx, txq->tx_ring, NULL, txq->cp_ring, + "txr")) { + RTE_LOG(ERR, PMD, "ring_dma_zone_reserve for tx_ring failed!"); + bnxt_tx_queue_release_op(txq); + rc = -ENOMEM; + goto out; + } - /* TODO: Initialize the ring */ + if (bnxt_init_one_tx_ring(txq)) { + RTE_LOG(ERR, PMD, "bnxt_init_one_tx_ring failed!"); + bnxt_tx_queue_release_op(txq); + rc = -ENOMEM; + goto out; + } eth_dev->data->tx_queues[queue_idx] = txq; - return 0; + +out: + return rc; }