From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by inbox.dpdk.org (Postfix) with ESMTP id CA490A04DE;
	Tue, 22 Sep 2020 03:43:25 +0200 (CEST)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id 40BC71DA9C;
	Tue, 22 Sep 2020 03:43:04 +0200 (CEST)
Received: from mga18.intel.com (mga18.intel.com [134.134.136.126])
 by dpdk.org (Postfix) with ESMTP id 133B71DA8C
 for <dev@dpdk.org>; Tue, 22 Sep 2020 03:43:00 +0200 (CEST)
IronPort-SDR: 8E5S31jiArmYaEnbx662qP9+pxgQECnmErkDBPy51BaW00dGr4WLMPSg0F2agFflDLub3fKx1k
 L1CyT86qdzsA==
X-IronPort-AV: E=McAfee;i="6000,8403,9751"; a="148265200"
X-IronPort-AV: E=Sophos;i="5.77,288,1596524400"; d="scan'208";a="148265200"
X-Amp-Result: SKIPPED(no attachment in message)
X-Amp-File-Uploaded: False
Received: from orsmga002.jf.intel.com ([10.7.209.21])
 by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
 21 Sep 2020 18:43:00 -0700
IronPort-SDR: O2daw5eGgNjmpFBVkdybmY2aHLau22t4ZlKQd5pFlB989WA+DT35JZEj+TD6RYw99s6UasFZus
 kNp8RcunCMoQ==
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.77,288,1596524400"; d="scan'208";a="322045754"
Received: from intel-npg-odc-srv01.cd.intel.com ([10.240.178.136])
 by orsmga002.jf.intel.com with ESMTP; 21 Sep 2020 18:42:58 -0700
From: SteveX Yang <stevex.yang@intel.com>
To: dev@dpdk.org
Cc: wei.zhao1@intel.com, jia.guo@intel.com, qiming.yang@intel.com,
 qi.z.zhang@intel.com, jingjing.wu@intel.com, beilei.xing@intel.com,
 konstantin.ananyev@intel.com, SteveX Yang <stevex.yang@intel.com>
Date: Tue, 22 Sep 2020 01:23:37 +0000
Message-Id: <20200922012338.11277-5-stevex.yang@intel.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20200922012338.11277-1-stevex.yang@intel.com>
References: <20200916055212.25019-1-stevex.yang@intel.com>
 <20200922012338.11277-1-stevex.yang@intel.com>
Subject: [dpdk-dev] [PATCH v2 4/5] net/i40e: fix max mtu size packets with
	vlan tag cannot be received by default
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

testpmd will initialize default max packet length to 1518 which doesn't
include vlan tag size in ether overheader. Once, send the max mtu length
packet with vlan tag, the max packet length will exceed 1518 that will
cause packets dropped directly from NIC hw side. But for i40e/i40evf,
they should support dual vlan tags that need more 8 bytes for max packet
size, so, configure the correct max packet size in dev_config ops.

Fixes: ff8282f4bbcd ("net/i40e: consider QinQ when setting MTU")

Signed-off-by: SteveX Yang <stevex.yang@intel.com>
---
 drivers/net/i40e/i40e_ethdev.c    |  5 +++++
 drivers/net/i40e/i40e_ethdev_vf.c | 11 +++++++++++
 2 files changed, 16 insertions(+)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 563f21d9d..023c86d66 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -1930,6 +1930,11 @@ i40e_dev_configure(struct rte_eth_dev *dev)
 	ad->tx_simple_allowed = true;
 	ad->tx_vec_allowed = true;
 
+	/* Considering QinQ packet, max frame size should be MTU and
+	 * corresponding ether overhead.
+	 */
+	i40e_dev_mtu_set(dev, dev->data->mtu);
+
 	if (dev->data->dev_conf.rxmode.mq_mode & ETH_MQ_RX_RSS_FLAG)
 		dev->data->dev_conf.rxmode.offloads |= DEV_RX_OFFLOAD_RSS_HASH;
 
diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c
index 8531cf6b1..b268b3d00 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -1669,6 +1669,7 @@ i40evf_dev_configure(struct rte_eth_dev *dev)
 		I40E_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
 	uint16_t num_queue_pairs = RTE_MAX(dev->data->nb_rx_queues,
 				dev->data->nb_tx_queues);
+	struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode;
 
 	/* Initialize to TRUE. If any of Rx queues doesn't meet the bulk
 	 * allocation or vector Rx preconditions we will reset it.
@@ -1681,6 +1682,16 @@ i40evf_dev_configure(struct rte_eth_dev *dev)
 	dev->data->dev_conf.intr_conf.lsc =
 		!!(dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC);
 
+
+	/* Considering QinQ packet, max frame size should be MTU and
+	 * corresponding ether overhead.
+	 */
+	if (dev->data->mtu == RTE_ETHER_MTU &&
+		rxmode->max_rx_pkt_len == RTE_ETHER_MAX_LEN) {
+		rxmode->max_rx_pkt_len = RTE_ETHER_MTU + I40E_ETH_OVERHEAD;
+		rxmode->offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
+	}
+
 	if (num_queue_pairs > vf->vsi_res->num_queue_pairs) {
 		struct i40e_hw *hw;
 		int ret;
-- 
2.17.1