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 7CBC0A00BE for ; Tue, 29 Oct 2019 06:15:09 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3AE181BEE7; Tue, 29 Oct 2019 06:15:09 +0100 (CET) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 19F621BECD; Tue, 29 Oct 2019 06:15:05 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Oct 2019 22:15:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,242,1569308400"; d="scan'208";a="189827892" Received: from npg-dpdk-zhangxiao.sh.intel.com ([10.67.110.203]) by orsmga007.jf.intel.com with ESMTP; 28 Oct 2019 22:15:03 -0700 From: Xiao Zhang To: dev@dpdk.org Cc: beilei.xing@intel.com, qi.z.zhang@intel.com, ktraynor@redhat.com, ian.stokes@intel.com, Xiao Zhang , stable@dpdk.org Date: Tue, 29 Oct 2019 13:12:22 +0800 Message-Id: <1572325942-72488-1-git-send-email-xiao.zhang@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1571039632-5524-1-git-send-email-xiao.zhang@intel.com> References: <1571039632-5524-1-git-send-email-xiao.zhang@intel.com> Subject: [dpdk-stable] [v3] net/i40e: fix vlan packets drop X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" VLAN packets with ip length bigger than 1496 will not be received by i40e/i40evf due to wrong packets size checking. This patch fixes the issue by correcting the maximum frame size during checking. Fixes: 43e5488c0ac6 ("net/i40e: support MTU configuration") Cc: stable@dpdk.org Signed-off-by: Xiao Zhang --- v3 Checking more places using max packet len. v2 Add fix for i40evf and correct the checking when using the max_pkt_len. --- drivers/net/i40e/i40e_ethdev.c | 2 +- drivers/net/i40e/i40e_ethdev_vf.c | 11 +++++++---- drivers/net/i40e/i40e_fdir.c | 2 +- drivers/net/i40e/i40e_rxtx.c | 9 ++++++--- lib/librte_ethdev/rte_ethdev.c | 10 ++++++++-- lib/librte_net/rte_ether.h | 1 + 6 files changed, 24 insertions(+), 11 deletions(-) diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index 77a4683..b0e23c7 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -12105,7 +12105,7 @@ i40e_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) return -EBUSY; } - if (frame_size > RTE_ETHER_MAX_LEN) + if (frame_size > RTE_ETHER_MAX_LEN + I40E_VLAN_TAG_SIZE * 2) dev_data->dev_conf.rxmode.offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME; else diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c index 5dba092..1e0b50f 100644 --- a/drivers/net/i40e/i40e_ethdev_vf.c +++ b/drivers/net/i40e/i40e_ethdev_vf.c @@ -1772,7 +1772,8 @@ i40evf_rxq_init(struct rte_eth_dev *dev, struct i40e_rx_queue *rxq) * Check if the jumbo frame and maximum packet length are set correctly */ if (dev_data->dev_conf.rxmode.offloads & DEV_RX_OFFLOAD_JUMBO_FRAME) { - if (rxq->max_pkt_len <= RTE_ETHER_MAX_LEN || + if (rxq->max_pkt_len <= RTE_ETHER_MAX_LEN + + I40E_VLAN_TAG_SIZE * 2 || rxq->max_pkt_len > I40E_FRAME_SIZE_MAX) { PMD_DRV_LOG(ERR, "maximum packet length must be " "larger than %u and smaller than %u, as jumbo " @@ -1782,12 +1783,14 @@ i40evf_rxq_init(struct rte_eth_dev *dev, struct i40e_rx_queue *rxq) } } else { if (rxq->max_pkt_len < RTE_ETHER_MIN_LEN || - rxq->max_pkt_len > RTE_ETHER_MAX_LEN) { + rxq->max_pkt_len > RTE_ETHER_MAX_LEN + + I40E_VLAN_TAG_SIZE * 2) { PMD_DRV_LOG(ERR, "maximum packet length must be " "larger than %u and smaller than %u, as jumbo " "frame is disabled", (uint32_t)RTE_ETHER_MIN_LEN, - (uint32_t)RTE_ETHER_MAX_LEN); + (uint32_t)RTE_ETHER_MAX_LEN + + I40E_VLAN_TAG_SIZE * 2); return I40E_ERR_CONFIG; } } @@ -2747,7 +2750,7 @@ i40evf_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) return -EBUSY; } - if (frame_size > RTE_ETHER_MAX_LEN) + if (frame_size > RTE_ETHER_MAX_LEN + I40E_VLAN_TAG_SIZE * 2) dev_data->dev_conf.rxmode.offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME; else diff --git a/drivers/net/i40e/i40e_fdir.c b/drivers/net/i40e/i40e_fdir.c index dee007d..8b813cb 100644 --- a/drivers/net/i40e/i40e_fdir.c +++ b/drivers/net/i40e/i40e_fdir.c @@ -113,7 +113,7 @@ i40e_fdir_rx_queue_init(struct i40e_rx_queue *rxq) #endif rx_ctx.dtype = i40e_header_split_none; rx_ctx.hsplit_0 = I40E_HEADER_SPLIT_NONE; - rx_ctx.rxmax = RTE_ETHER_MAX_LEN; + rx_ctx.rxmax = RTE_ETHER_MAX_LEN + I40E_VLAN_TAG_SIZE * 2; rx_ctx.tphrdesc_ena = 1; rx_ctx.tphwdesc_ena = 1; rx_ctx.tphdata_ena = 1; diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c index 6a66cec..a93b11f 100644 --- a/drivers/net/i40e/i40e_rxtx.c +++ b/drivers/net/i40e/i40e_rxtx.c @@ -2617,7 +2617,8 @@ i40e_rx_queue_config(struct i40e_rx_queue *rxq) RTE_MIN((uint32_t)(hw->func_caps.rx_buf_chain_len * rxq->rx_buf_len), data->dev_conf.rxmode.max_rx_pkt_len); if (data->dev_conf.rxmode.offloads & DEV_RX_OFFLOAD_JUMBO_FRAME) { - if (rxq->max_pkt_len <= RTE_ETHER_MAX_LEN || + if (rxq->max_pkt_len <= RTE_ETHER_MAX_LEN + + I40E_VLAN_TAG_SIZE * 2 || rxq->max_pkt_len > I40E_FRAME_SIZE_MAX) { PMD_DRV_LOG(ERR, "maximum packet length must " "be larger than %u and smaller than %u," @@ -2628,12 +2629,14 @@ i40e_rx_queue_config(struct i40e_rx_queue *rxq) } } else { if (rxq->max_pkt_len < RTE_ETHER_MIN_LEN || - rxq->max_pkt_len > RTE_ETHER_MAX_LEN) { + rxq->max_pkt_len > RTE_ETHER_MAX_LEN + + I40E_VLAN_TAG_SIZE * 2) { PMD_DRV_LOG(ERR, "maximum packet length must be " "larger than %u and smaller than %u, " "as jumbo frame is disabled", (uint32_t)RTE_ETHER_MIN_LEN, - (uint32_t)RTE_ETHER_MAX_LEN); + (uint32_t)RTE_ETHER_MAX_LEN + + I40E_VLAN_TAG_SIZE * 2); return I40E_ERR_CONFIG; } } diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index 7743205..f6722be 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -1257,11 +1257,17 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q, goto rollback; } } else { + /** + * The overhead from MTU to max frame size. + * Considering VLAN and QinQ packet, the VLAN tag size + * needs to be added to RTE_ETHER_MAX_LEN. + */ if (dev_conf->rxmode.max_rx_pkt_len < RTE_ETHER_MIN_LEN || - dev_conf->rxmode.max_rx_pkt_len > RTE_ETHER_MAX_LEN) + dev_conf->rxmode.max_rx_pkt_len > RTE_ETHER_MAX_LEN + + RTE_ETHER_VLAN_LEN * 2) /* Use default value */ dev->data->dev_conf.rxmode.max_rx_pkt_len = - RTE_ETHER_MAX_LEN; + RTE_ETHER_MAX_LEN + RTE_ETHER_VLAN_LEN * 2; } /* Any requested offloading must be within its device capabilities */ diff --git a/lib/librte_net/rte_ether.h b/lib/librte_net/rte_ether.h index e069dc7..9c5eee7 100644 --- a/lib/librte_net/rte_ether.h +++ b/lib/librte_net/rte_ether.h @@ -26,6 +26,7 @@ extern "C" { #define RTE_ETHER_ADDR_LEN 6 /**< Length of Ethernet address. */ #define RTE_ETHER_TYPE_LEN 2 /**< Length of Ethernet type field. */ #define RTE_ETHER_CRC_LEN 4 /**< Length of Ethernet CRC. */ +#define RTE_ETHER_VLAN_LEN 4 /**< Length of Ethernet VLAN tag. */ #define RTE_ETHER_HDR_LEN \ (RTE_ETHER_ADDR_LEN * 2 + \ RTE_ETHER_TYPE_LEN) /**< Length of Ethernet header. */ -- 2.7.4