From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id ADDC8A2EDB for ; Wed, 2 Oct 2019 19:18:05 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8ED8D1BF2E; Wed, 2 Oct 2019 19:17:58 +0200 (CEST) Received: from rnd-relay.smtp.broadcom.com (unknown [192.19.229.170]) by dpdk.org (Postfix) with ESMTP id 570BC1BF13; Wed, 2 Oct 2019 19:17:53 +0200 (CEST) Received: from mail-irv-17.broadcom.com (mail-irv-17.lvn.broadcom.net [10.75.242.48]) by rnd-relay.smtp.broadcom.com (Postfix) with ESMTP id 05D3130D31F; Wed, 2 Oct 2019 10:16:36 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.10.3 rnd-relay.smtp.broadcom.com 05D3130D31F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1570036596; bh=r77+LPnLPPBmeUhagTMgRimBJPsOFGZvYRw1wXfVsSM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OYPAiR/yfBgMsAPPgAg1e0jrHjvfcueObjpBoscUlJGUay52gtHhjtgy0ez3MSx8E T96VsQ2ZRe7eZoyaPdPFmiz2KZjD5Xy1YGb09ZEJ2zEiKNwgvX5NYVhH56l68yXIlM 53iIWh6qm720tt/BZisb3Et98Sb+DPjiSpzjmTeA= Received: from C02VPB22HTD6.wifi.broadcom.net (c02vpb22htd6.wifi.broadcom.net [10.69.74.102]) by mail-irv-17.broadcom.com (Postfix) with ESMTP id CDDB2140069; Wed, 2 Oct 2019 10:17:47 -0700 (PDT) From: Ajit Khaparde To: dev@dpdk.org Cc: ferruh.yigit@intel.com, Santoshkumar Karanappa Rastapur , stable@dpdk.org, Kalesh AP , Somnath Kotur , Lance Richardson Date: Wed, 2 Oct 2019 10:17:31 -0700 Message-Id: <20191002171745.4504-3-ajit.khaparde@broadcom.com> X-Mailer: git-send-email 2.20.1 (Apple Git-117) In-Reply-To: <20191002171745.4504-1-ajit.khaparde@broadcom.com> References: <20191002055423.99659-1-ajit.khaparde@broadcom.com> <20191002171745.4504-1-ajit.khaparde@broadcom.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v3 02/16] net/bnxt: fix traffic failure with higher mbuf size X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Santoshkumar Karanappa Rastapur 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 Signed-off-by: Kalesh AP Reviewed-by: Somnath Kotur Reviewed-by: Lance Richardson Signed-off-by: Ajit Khaparde --- drivers/net/bnxt/bnxt.h | 5 ++++- drivers/net/bnxt/bnxt_ethdev.c | 29 +++++++++-------------------- drivers/net/bnxt/bnxt_hwrm.c | 3 +++ drivers/net/bnxt/bnxt_ring.c | 5 ----- drivers/net/bnxt/bnxt_rxq.c | 2 +- drivers/net/bnxt/bnxt_rxq.h | 1 - drivers/net/bnxt/bnxt_rxr.c | 7 ++----- 7 files changed, 19 insertions(+), 33 deletions(-) diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h index 818a49f461..68ac30bb58 100644 --- a/drivers/net/bnxt/bnxt.h +++ b/drivers/net/bnxt/bnxt.h @@ -23,12 +23,15 @@ #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 diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 0083ba6e83..4095e9c720 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -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; } diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index 174dc75d54..09330e2382 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -1233,6 +1233,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; @@ -1263,6 +1264,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); @@ -1879,6 +1881,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); diff --git a/drivers/net/bnxt/bnxt_ring.c b/drivers/net/bnxt/bnxt_ring.c index ec17783cf8..73eee43148 100644 --- a/drivers/net/bnxt/bnxt_ring.c +++ b/drivers/net/bnxt/bnxt_ring.c @@ -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); diff --git a/drivers/net/bnxt/bnxt_rxq.c b/drivers/net/bnxt/bnxt_rxq.c index d5fc5268db..192ffd8780 100644 --- a/drivers/net/bnxt/bnxt_rxq.c +++ b/drivers/net/bnxt/bnxt_rxq.c @@ -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) diff --git a/drivers/net/bnxt/bnxt_rxq.h b/drivers/net/bnxt/bnxt_rxq.h index b5e42d01c0..c60b04426c 100644 --- a/drivers/net/bnxt/bnxt_rxq.h +++ b/drivers/net/bnxt/bnxt_rxq.h @@ -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; diff --git a/drivers/net/bnxt/bnxt_rxr.c b/drivers/net/bnxt/bnxt_rxr.c index 28487fb38e..f60880c63e 100644 --- a/drivers/net/bnxt/bnxt_rxr.c +++ b/drivers/net/bnxt/bnxt_rxr.c @@ -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; -- 2.20.1 (Apple Git-117)