[06/12] net/bnxt: use smaller cq when agg ring not needed
diff mbox series

Message ID 20200909155302.28656-7-lance.richardson@broadcom.com
State Accepted
Delegated to: Ajit Khaparde
Headers show
Series
  • net/bnxt: vector PMD improvements
Related show

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Lance Richardson Sept. 9, 2020, 3:52 p.m. UTC
Don't allocate extra completion queue entries for aggregation
ring when aggregation ring will not be used.

Reviewed-by: Ajit Kumar Khaparde <ajit.khaparde@broadcom.com>
Signed-off-by: Lance Richardson <lance.richardson@broadcom.com>
---
 drivers/net/bnxt/bnxt_ethdev.c | 11 +++++------
 drivers/net/bnxt/bnxt_rxr.c    | 21 +++++++++++++++++++--
 2 files changed, 24 insertions(+), 8 deletions(-)

Patch
diff mbox series

diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 1ad9bfc0a6..27eba431b8 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -1295,6 +1295,8 @@  static void bnxt_dev_stop_op(struct rte_eth_dev *eth_dev)
 	struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
 
 	eth_dev->data->dev_started = 0;
+	eth_dev->data->scattered_rx = 0;
+
 	/* Prevent crashes when queues are still in use */
 	eth_dev->rx_pkt_burst = &bnxt_dummy_recv_pkts;
 	eth_dev->tx_pkt_burst = &bnxt_dummy_xmit_pkts;
@@ -2695,14 +2697,12 @@  int bnxt_mtu_set_op(struct rte_eth_dev *eth_dev, uint16_t new_mtu)
 	new_pkt_size = new_mtu + RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN +
 		       VLAN_TAG_SIZE * BNXT_NUM_VLANS;
 
-#if defined(RTE_ARCH_X86) || defined(RTE_ARCH_ARM64)
 	/*
-	 * If vector-mode tx/rx is active, disallow any MTU change that would
-	 * require scattered receive support.
+	 * Disallow any MTU change that would require scattered receive support
+	 * if it is not already enabled.
 	 */
 	if (eth_dev->data->dev_started &&
-	    (eth_dev->rx_pkt_burst == bnxt_recv_pkts_vec ||
-	     eth_dev->tx_pkt_burst == bnxt_xmit_pkts_vec) &&
+	    !eth_dev->data->scattered_rx &&
 	    (new_pkt_size >
 	     eth_dev->data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM)) {
 		PMD_DRV_LOG(ERR,
@@ -2710,7 +2710,6 @@  int bnxt_mtu_set_op(struct rte_eth_dev *eth_dev, uint16_t new_mtu)
 		PMD_DRV_LOG(ERR, "Stop port before changing MTU.\n");
 		return -EINVAL;
 	}
-#endif
 
 	if (new_mtu > RTE_ETHER_MTU) {
 		bp->flags |= BNXT_FLAG_JUMBO;
diff --git a/drivers/net/bnxt/bnxt_rxr.c b/drivers/net/bnxt/bnxt_rxr.c
index 92102e3d57..5673e2b50f 100644
--- a/drivers/net/bnxt/bnxt_rxr.c
+++ b/drivers/net/bnxt/bnxt_rxr.c
@@ -938,9 +938,12 @@  void bnxt_free_rx_rings(struct bnxt *bp)
 
 int bnxt_init_rx_ring_struct(struct bnxt_rx_queue *rxq, unsigned int socket_id)
 {
+	struct rte_eth_dev *eth_dev = rxq->bp->eth_dev;
+	struct rte_eth_rxmode *rxmode;
 	struct bnxt_cp_ring_info *cpr;
 	struct bnxt_rx_ring_info *rxr;
 	struct bnxt_ring *ring;
+	bool use_agg_ring;
 
 	rxq->rx_buf_size = BNXT_MAX_PKT_LEN + sizeof(struct rte_mbuf);
 
@@ -978,8 +981,22 @@  int bnxt_init_rx_ring_struct(struct bnxt_rx_queue *rxq, unsigned int socket_id)
 	if (ring == NULL)
 		return -ENOMEM;
 	cpr->cp_ring_struct = ring;
-	ring->ring_size = rte_align32pow2(rxr->rx_ring_struct->ring_size *
-					  (2 + AGG_RING_SIZE_FACTOR));
+
+	rxmode = &eth_dev->data->dev_conf.rxmode;
+	use_agg_ring = (rxmode->offloads & DEV_RX_OFFLOAD_SCATTER) ||
+		       (rxmode->offloads & DEV_RX_OFFLOAD_TCP_LRO) ||
+		       (rxmode->max_rx_pkt_len >
+			 (uint32_t)(rte_pktmbuf_data_room_size(rxq->mb_pool) -
+				    RTE_PKTMBUF_HEADROOM));
+
+	/* Allocate two completion slots per entry in desc ring. */
+	ring->ring_size = rxr->rx_ring_struct->ring_size * 2;
+
+	/* Allocate additional slots if aggregation ring is in use. */
+	if (use_agg_ring)
+		ring->ring_size *= AGG_RING_SIZE_FACTOR;
+
+	ring->ring_size = rte_align32pow2(ring->ring_size);
 	ring->ring_mask = ring->ring_size - 1;
 	ring->bd = (void *)cpr->cp_desc_ring;
 	ring->bd_dma = cpr->cp_desc_mapping;