net/bnxt: fix forwarding with higher mbuf size
authorSantoshkumar Karanappa Rastapur <santosh.rastapur@broadcom.com>
Wed, 2 Oct 2019 17:17:31 +0000 (10:17 -0700)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 8 Oct 2019 10:14:30 +0000 (12:14 +0200)
Maximum frame length supported by hw is 9600 bytes.
When user launches testpmd with --mbuf-size=9729,
we are posting buffer descriptors of size 9601 to the ring.
This was causing packets getting discarded.

Fixes: daef48efe5e5 ("net/bnxt: support set MTU")
Cc: stable@dpdk.org
Signed-off-by: Santoshkumar Karanappa Rastapur <santosh.rastapur@broadcom.com>
Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
Reviewed-by: Lance Richardson <lance.richardson@broadcom.com>
drivers/net/bnxt/bnxt.h
drivers/net/bnxt/bnxt_ethdev.c
drivers/net/bnxt/bnxt_hwrm.c
drivers/net/bnxt/bnxt_ring.c
drivers/net/bnxt/bnxt_rxq.c
drivers/net/bnxt/bnxt_rxq.h
drivers/net/bnxt/bnxt_rxr.c

index 818a49f..68ac30b 100644 (file)
 
 #define BNXT_MAX_MTU           9574
 #define VLAN_TAG_SIZE          4
+#define BNXT_NUM_VLANS         2
+#define BNXT_MAX_PKT_LEN       (BNXT_MAX_MTU + RTE_ETHER_HDR_LEN +\
+                                RTE_ETHER_CRC_LEN +\
+                                (BNXT_NUM_VLANS * VLAN_TAG_SIZE))
 #define BNXT_VF_RSV_NUM_RSS_CTX        1
 #define BNXT_VF_RSV_NUM_L2_CTX 4
 /* TODO: For now, do not support VMDq/RFS on VFs. */
 #define BNXT_VF_RSV_NUM_VNIC   1
 #define BNXT_MAX_LED           4
-#define BNXT_NUM_VLANS         2
 #define BNXT_MIN_RING_DESC     16
 #define BNXT_MAX_TX_RING_DESC  4096
 #define BNXT_MAX_RX_RING_DESC  8192
index 0083ba6..4095e9c 100644 (file)
@@ -545,10 +545,13 @@ static int bnxt_dev_info_get_op(struct rte_eth_dev *eth_dev,
        dev_info->hash_key_size = 40;
        max_vnics = bp->max_vnics;
 
+       /* MTU specifics */
+       dev_info->min_mtu = RTE_ETHER_MIN_MTU;
+       dev_info->max_mtu = BNXT_MAX_MTU;
+
        /* Fast path specifics */
        dev_info->min_rx_bufsize = 1;
-       dev_info->max_rx_pktlen = BNXT_MAX_MTU + RTE_ETHER_HDR_LEN +
-               RTE_ETHER_CRC_LEN + VLAN_TAG_SIZE * 2;
+       dev_info->max_rx_pktlen = BNXT_MAX_PKT_LEN;
 
        dev_info->rx_offload_capa = BNXT_DEV_RX_OFFLOAD_SUPPORT;
        if (bp->flags & BNXT_FLAG_PTP_SUPPORTED)
@@ -1967,7 +1970,6 @@ bnxt_txq_info_get_op(struct rte_eth_dev *dev, uint16_t queue_id,
 static int bnxt_mtu_set_op(struct rte_eth_dev *eth_dev, uint16_t new_mtu)
 {
        struct bnxt *bp = eth_dev->data->dev_private;
-       struct rte_eth_dev_info dev_info;
        uint32_t new_pkt_size;
        uint32_t rc = 0;
        uint32_t i;
@@ -1979,18 +1981,6 @@ static 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;
 
-       rc = bnxt_dev_info_get_op(eth_dev, &dev_info);
-       if (rc != 0) {
-               PMD_DRV_LOG(ERR, "Error during getting ethernet device info\n");
-               return rc;
-       }
-
-       if (new_mtu < RTE_ETHER_MIN_MTU || new_mtu > BNXT_MAX_MTU) {
-               PMD_DRV_LOG(ERR, "MTU requested must be within (%d, %d)\n",
-                       RTE_ETHER_MIN_MTU, BNXT_MAX_MTU);
-               return -EINVAL;
-       }
-
 #ifdef RTE_ARCH_X86
        /*
         * If vector-mode tx/rx is active, disallow any MTU change that would
@@ -2020,15 +2010,12 @@ static int bnxt_mtu_set_op(struct rte_eth_dev *eth_dev, uint16_t new_mtu)
 
        eth_dev->data->dev_conf.rxmode.max_rx_pkt_len = new_pkt_size;
 
-       eth_dev->data->mtu = new_mtu;
-       PMD_DRV_LOG(INFO, "New MTU is %d\n", eth_dev->data->mtu);
-
        for (i = 0; i < bp->nr_vnics; i++) {
                struct bnxt_vnic_info *vnic = &bp->vnic_info[i];
                uint16_t size = 0;
 
-               vnic->mru = bp->eth_dev->data->mtu + RTE_ETHER_HDR_LEN +
-                                       RTE_ETHER_CRC_LEN + VLAN_TAG_SIZE * 2;
+               vnic->mru = new_mtu + RTE_ETHER_HDR_LEN +
+                               RTE_ETHER_CRC_LEN + VLAN_TAG_SIZE * 2;
                rc = bnxt_hwrm_vnic_cfg(bp, vnic);
                if (rc)
                        break;
@@ -2043,6 +2030,8 @@ static int bnxt_mtu_set_op(struct rte_eth_dev *eth_dev, uint16_t new_mtu)
                }
        }
 
+       PMD_DRV_LOG(INFO, "New MTU is %d\n", new_mtu);
+
        return rc;
 }
 
index cdb6fa4..c62524c 100644 (file)
@@ -1236,6 +1236,7 @@ int bnxt_hwrm_ring_alloc(struct bnxt *bp,
                        mb_pool = bp->rx_queues[0]->mb_pool;
                        rx_buf_size = rte_pktmbuf_data_room_size(mb_pool) -
                                      RTE_PKTMBUF_HEADROOM;
+                       rx_buf_size = RTE_MIN(BNXT_MAX_PKT_LEN, rx_buf_size);
                        req.rx_buf_size = rte_cpu_to_le_16(rx_buf_size);
                        enables |=
                                HWRM_RING_ALLOC_INPUT_ENABLES_RX_BUF_SIZE_VALID;
@@ -1266,6 +1267,7 @@ int bnxt_hwrm_ring_alloc(struct bnxt *bp,
                mb_pool = bp->rx_queues[0]->mb_pool;
                rx_buf_size = rte_pktmbuf_data_room_size(mb_pool) -
                              RTE_PKTMBUF_HEADROOM;
+               rx_buf_size = RTE_MIN(BNXT_MAX_PKT_LEN, rx_buf_size);
                req.rx_buf_size = rte_cpu_to_le_16(rx_buf_size);
 
                req.stat_ctx_id = rte_cpu_to_le_32(stats_ctx_id);
@@ -1882,6 +1884,7 @@ int bnxt_hwrm_vnic_plcmode_cfg(struct bnxt *bp,
 
        size = rte_pktmbuf_data_room_size(bp->rx_queues[0]->mb_pool);
        size -= RTE_PKTMBUF_HEADROOM;
+       size = RTE_MIN(BNXT_MAX_PKT_LEN, size);
 
        req.jumbo_thresh = rte_cpu_to_le_16(size);
        req.vnic_id = rte_cpu_to_le_16(vnic->fw_vnic_id);
index ec17783..73eee43 100644 (file)
@@ -561,9 +561,6 @@ int bnxt_alloc_hwrm_rx_ring(struct bnxt *bp, int queue_index)
        if (rc)
                goto err_out;
 
-       rxq->rx_buf_use_size = BNXT_MAX_MTU + RTE_ETHER_HDR_LEN +
-               RTE_ETHER_CRC_LEN + (2 * VLAN_TAG_SIZE);
-
        if (bp->eth_dev->data->rx_queue_state[queue_index] ==
            RTE_ETH_QUEUE_STATE_STARTED) {
                if (bnxt_init_one_rx_ring(rxq)) {
@@ -640,8 +637,6 @@ int bnxt_alloc_hwrm_rings(struct bnxt *bp)
                if (bnxt_alloc_rx_agg_ring(bp, i))
                        goto err_out;
 
-               rxq->rx_buf_use_size = BNXT_MAX_MTU + RTE_ETHER_HDR_LEN +
-                                       RTE_ETHER_CRC_LEN + (2 * VLAN_TAG_SIZE);
                if (bnxt_init_one_rx_ring(rxq)) {
                        PMD_DRV_LOG(ERR, "bnxt_init_one_rx_ring failed!\n");
                        bnxt_rx_queue_release_op(rxq);
index d5fc526..192ffd8 100644 (file)
@@ -331,13 +331,13 @@ int bnxt_rx_queue_setup_op(struct rte_eth_dev *eth_dev,
        rxq->nb_rx_desc = nb_desc;
        rxq->rx_free_thresh = rx_conf->rx_free_thresh;
 
-       PMD_DRV_LOG(DEBUG, "RX Buf size is %d\n", rxq->rx_buf_use_size);
        PMD_DRV_LOG(DEBUG, "RX Buf MTU %d\n", eth_dev->data->mtu);
 
        rc = bnxt_init_rx_ring_struct(rxq, socket_id);
        if (rc)
                goto out;
 
+       PMD_DRV_LOG(DEBUG, "RX Buf size is %d\n", rxq->rx_buf_size);
        rxq->queue_id = queue_idx;
        rxq->port_id = eth_dev->data->port_id;
        if (rx_offloads & DEV_RX_OFFLOAD_KEEP_CRC)
index b5e42d0..c60b044 100644 (file)
@@ -36,7 +36,6 @@ struct bnxt_rx_queue {
        struct bnxt_vnic_info   *vnic;
 
        uint32_t                        rx_buf_size;
-       uint32_t                        rx_buf_use_size;  /* useable size */
        struct bnxt_rx_ring_info        *rx_ring;
        struct bnxt_cp_ring_info        *cp_ring;
        struct bnxt_cp_ring_info        *nq_ring;
index 28487fb..f60880c 100644 (file)
@@ -713,9 +713,7 @@ int bnxt_init_rx_ring_struct(struct bnxt_rx_queue *rxq, unsigned int socket_id)
        struct bnxt_rx_ring_info *rxr;
        struct bnxt_ring *ring;
 
-       rxq->rx_buf_use_size = BNXT_MAX_MTU + RTE_ETHER_HDR_LEN +
-               RTE_ETHER_CRC_LEN + (2 * VLAN_TAG_SIZE);
-       rxq->rx_buf_size = rxq->rx_buf_use_size + sizeof(struct rte_mbuf);
+       rxq->rx_buf_size = BNXT_MAX_PKT_LEN + sizeof(struct rte_mbuf);
 
        rxr = rte_zmalloc_socket("bnxt_rx_ring",
                                 sizeof(struct bnxt_rx_ring_info),
@@ -826,8 +824,7 @@ int bnxt_init_one_rx_ring(struct bnxt_rx_queue *rxq)
        uint16_t size;
 
        size = rte_pktmbuf_data_room_size(rxq->mb_pool) - RTE_PKTMBUF_HEADROOM;
-       if (rxq->rx_buf_use_size <= size)
-               size = rxq->rx_buf_use_size;
+       size = RTE_MIN(BNXT_MAX_PKT_LEN, size);
 
        type = RX_PROD_PKT_BD_TYPE_RX_PROD_PKT | RX_PROD_PKT_BD_FLAGS_EOP_PAD;