X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Fbnxt%2Fbnxt_rxq.c;h=7625fb1bfe7b8a824c02f44a61eb91c08505453b;hb=7236d2bfe0acc48330e3c2a3dfac4ada9a792cd8;hp=d5c3173b358693dea6f531bc5c24e96fb6d35917;hpb=6133f207970c5091c7b010f4542b80f5f628a7f0;p=dpdk.git diff --git a/drivers/net/bnxt/bnxt_rxq.c b/drivers/net/bnxt/bnxt_rxq.c index d5c3173b35..7625fb1bfe 100644 --- a/drivers/net/bnxt/bnxt_rxq.c +++ b/drivers/net/bnxt/bnxt_rxq.c @@ -36,10 +36,12 @@ #include #include "bnxt.h" +#include "bnxt_cpr.h" #include "bnxt_filter.h" #include "bnxt_hwrm.h" #include "bnxt_ring.h" #include "bnxt_rxq.h" +#include "bnxt_rxr.h" #include "bnxt_vnic.h" #include "hsi_struct_def_dpdk.h" @@ -51,8 +53,6 @@ void bnxt_free_rxq_stats(struct bnxt_rx_queue *rxq) { struct bnxt_cp_ring_info *cpr = rxq->cp_ring; - /* 'Unreserve' rte_memzone */ - if (cpr->hw_stats) cpr->hw_stats = NULL; } @@ -213,9 +213,22 @@ err_out: return rc; } -static void bnxt_rx_queue_release_mbufs(struct bnxt_rx_queue *rxq __rte_unused) +static void bnxt_rx_queue_release_mbufs(struct bnxt_rx_queue *rxq) { - /* TODO: Requires interaction with TX ring */ + struct bnxt_sw_rx_bd *sw_ring; + uint16_t i; + + if (rxq) { + sw_ring = rxq->rx_ring->rx_buf_ring; + if (sw_ring) { + for (i = 0; i < rxq->nb_rx_desc; i++) { + if (sw_ring[i].mbuf) { + rte_pktmbuf_free_seg(sw_ring[i].mbuf); + sw_ring[i].mbuf = NULL; + } + } + } + } } void bnxt_free_rx_mbufs(struct bnxt *bp) @@ -236,7 +249,13 @@ void bnxt_rx_queue_release_op(void *rx_queue) if (rxq) { bnxt_rx_queue_release_mbufs(rxq); - /* TODO: Free ring and stats here */ + /* Free RX ring hardware descriptors */ + bnxt_free_ring(rxq->rx_ring->rx_ring_struct); + + /* Free RX completion ring hardware descriptors */ + bnxt_free_ring(rxq->cp_ring->cp_ring_struct); + + bnxt_free_rxq_stats(rxq); rte_free(rxq); } @@ -251,10 +270,12 @@ int bnxt_rx_queue_setup_op(struct rte_eth_dev *eth_dev, { struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private; struct bnxt_rx_queue *rxq; + int rc = 0; if (!nb_desc || nb_desc > MAX_RX_DESC_CNT) { RTE_LOG(ERR, PMD, "nb_desc %d is invalid", nb_desc); - return -EINVAL; + rc = -EINVAL; + goto out; } if (eth_dev->data->rx_queues) { @@ -266,14 +287,17 @@ int bnxt_rx_queue_setup_op(struct rte_eth_dev *eth_dev, RTE_CACHE_LINE_SIZE, socket_id); if (!rxq) { RTE_LOG(ERR, PMD, "bnxt_rx_queue allocation failed!"); - return -ENOMEM; + rc = -ENOMEM; + goto out; } rxq->bp = bp; rxq->mb_pool = mp; rxq->nb_rx_desc = nb_desc; rxq->rx_free_thresh = rx_conf->rx_free_thresh; - /* TODO: Initialize ring structure */ + rc = bnxt_init_rx_ring_struct(rxq, socket_id); + if (rc) + goto out; rxq->queue_id = queue_idx; rxq->port_id = eth_dev->data->port_id; @@ -281,7 +305,15 @@ int bnxt_rx_queue_setup_op(struct rte_eth_dev *eth_dev, 0 : ETHER_CRC_LEN); eth_dev->data->rx_queues[queue_idx] = rxq; - /* TODO: Allocate RX ring hardware descriptors */ + /* Allocate RX ring hardware descriptors */ + if (bnxt_alloc_rings(bp, queue_idx, NULL, rxq->rx_ring, rxq->cp_ring, + "rxr")) { + RTE_LOG(ERR, PMD, "ring_dma_zone_reserve for rx_ring failed!"); + bnxt_rx_queue_release_op(rxq); + rc = -ENOMEM; + goto out; + } - return 0; +out: + return rc; }