X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Fbnxt%2Fbnxt_rxq.c;h=0793820b14e309f74f7e4ec82ab45263363e6642;hb=3b212853e478e45490668ea054ec351da1fbda43;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..0793820b14 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; } @@ -76,6 +76,7 @@ int bnxt_mq_rx_configure(struct bnxt *bp) rc = -ENOMEM; goto err_out; } + vnic->flags |= BNXT_VNIC_INFO_BCAST; STAILQ_INSERT_TAIL(&bp->ff_pool[0], vnic, next); bp->nr_vnics++; @@ -84,9 +85,8 @@ int bnxt_mq_rx_configure(struct bnxt *bp) vnic->func_default = true; vnic->ff_pool_idx = 0; - vnic->start_grp_id = 1; - vnic->end_grp_id = vnic->start_grp_id + - bp->rx_cp_nr_rings - 1; + vnic->start_grp_id = 0; + vnic->end_grp_id = vnic->start_grp_id; filter = bnxt_alloc_filter(bp); if (!filter) { RTE_LOG(ERR, PMD, "L2 filter alloc failed\n"); @@ -121,13 +121,16 @@ int bnxt_mq_rx_configure(struct bnxt *bp) } /* For each pool, allocate MACVLAN CFA rule & VNIC */ if (!pools) { + pools = RTE_MIN(bp->max_vnics, + RTE_MIN(bp->max_l2_ctx, + RTE_MIN(bp->max_rsscos_ctx, ETH_64_POOLS))); RTE_LOG(ERR, PMD, "VMDq pool not set, defaulted to 64\n"); pools = ETH_64_POOLS; } nb_q_per_grp = bp->rx_cp_nr_rings / pools; - start_grp_id = 1; - end_grp_id = start_grp_id + nb_q_per_grp - 1; + start_grp_id = 0; + end_grp_id = nb_q_per_grp; ring_idx = 0; for (i = 0; i < pools; i++) { @@ -138,6 +141,7 @@ int bnxt_mq_rx_configure(struct bnxt *bp) rc = -ENOMEM; goto err_out; } + vnic->flags |= BNXT_VNIC_INFO_BCAST; STAILQ_INSERT_TAIL(&bp->ff_pool[i], vnic, next); bp->nr_vnics++; @@ -178,6 +182,7 @@ int bnxt_mq_rx_configure(struct bnxt *bp) rc = -ENOMEM; goto err_out; } + vnic->flags |= BNXT_VNIC_INFO_BCAST; /* Partition the rx queues for the single pool */ for (i = 0; i < bp->rx_cp_nr_rings; i++) { rxq = bp->eth_dev->data->rx_queues[i]; @@ -188,9 +193,8 @@ int bnxt_mq_rx_configure(struct bnxt *bp) vnic->func_default = true; vnic->ff_pool_idx = 0; - vnic->start_grp_id = 1; - vnic->end_grp_id = vnic->start_grp_id + - bp->rx_cp_nr_rings - 1; + vnic->start_grp_id = 0; + vnic->end_grp_id = bp->rx_cp_nr_rings; filter = bnxt_alloc_filter(bp); if (!filter) { RTE_LOG(ERR, PMD, "L2 filter alloc failed\n"); @@ -213,9 +217,44 @@ 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; + struct bnxt_tpa_info *tpa_info; + 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; + } + } + } + /* Free up mbufs in Agg ring */ + sw_ring = rxq->rx_ring->ag_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; + } + } + } + + /* Free up mbufs in TPA */ + tpa_info = rxq->rx_ring->tpa_info; + if (tpa_info) { + for (i = 0; i < BNXT_TPA_MAX; i++) { + if (tpa_info[i].mbuf) { + rte_pktmbuf_free_seg(tpa_info[i].mbuf); + tpa_info[i].mbuf = NULL; + } + } + } + } } void bnxt_free_rx_mbufs(struct bnxt *bp) @@ -236,7 +275,15 @@ 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 Agg ring hardware descriptors */ + bnxt_free_ring(rxq->rx_ring->ag_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 +298,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; + RTE_LOG(ERR, PMD, "nb_desc %d is invalid\n", nb_desc); + rc = -EINVAL; + goto out; } if (eth_dev->data->rx_queues) { @@ -265,15 +314,21 @@ int bnxt_rx_queue_setup_op(struct rte_eth_dev *eth_dev, rxq = rte_zmalloc_socket("bnxt_rx_queue", sizeof(struct bnxt_rx_queue), RTE_CACHE_LINE_SIZE, socket_id); if (!rxq) { - RTE_LOG(ERR, PMD, "bnxt_rx_queue allocation failed!"); - return -ENOMEM; + RTE_LOG(ERR, PMD, "bnxt_rx_queue allocation failed!\n"); + 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 */ + RTE_LOG(DEBUG, PMD, "RX Buf size is %d\n", rxq->rx_buf_use_size); + RTE_LOG(DEBUG, PMD, "RX Buf MTU %d\n", eth_dev->data->mtu); + + 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 +336,16 @@ 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!\n"); + bnxt_rx_queue_release_op(rxq); + rc = -ENOMEM; + goto out; + } - return 0; +out: + return rc; }