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 403AAA04DD; Thu, 22 Oct 2020 10:51:00 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 4C6DCA946; Thu, 22 Oct 2020 10:50:36 +0200 (CEST) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id C82B4A941 for ; Thu, 22 Oct 2020 10:50:29 +0200 (CEST) IronPort-SDR: N5zqkPCJgFI4icJljjfjRC2mZv8kF3ud2EN4jZrs5Nk4Ia6Qwu7hJXIkUvQ6F7vd8SMESQSSyQ hllZBbdlyuEw== X-IronPort-AV: E=McAfee;i="6000,8403,9781"; a="229124192" X-IronPort-AV: E=Sophos;i="5.77,404,1596524400"; d="scan'208";a="229124192" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2020 01:50:29 -0700 IronPort-SDR: UsBhOxeRnvw53F8CoqWu2sqac2UfhXyH0Ws8EOYRuYnrgQx0s28A0wMEWjEWdHJ6PpFWHNbw1d cUC3nNxaxeQg== X-IronPort-AV: E=Sophos;i="5.77,404,1596524400"; d="scan'208";a="466609018" Received: from intel-npg-odc-srv01.cd.intel.com ([10.240.178.136]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2020 01:50:26 -0700 From: SteveX Yang To: dev@dpdk.org Cc: ferruh.yigit@intel.com, konstantin.ananyev@intel.com, beilei.xing@intel.com, wenzhuo.lu@intel.com, bernard.iremonger@intel.com, thomas@monjalon.net, andrew.rybchenko@oktetlabs.ru, qiming.yang@intel.com, qi.z.zhang@intel.com, SteveX Yang Date: Thu, 22 Oct 2020 08:48:51 +0000 Message-Id: <20201022084851.35134-3-stevex.yang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201022084851.35134-1-stevex.yang@intel.com> References: <20201014091945.1934-1-stevex.yang@intel.com> <20201022084851.35134-1-stevex.yang@intel.com> Subject: [dpdk-dev] [PATCH v6 2/2] librte_ethdev: fix MTU size exceeds max rx packet length 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" If max rx packet length is smaller then MTU + Ether overhead, that will drop all MTU size packets. Update the MTU size according to the max rx packet and Ether overhead. Fixes: 59d0ecdbf0e1 ("ethdev: MTU accessors") Signed-off-by: SteveX Yang --- lib/librte_ethdev/rte_ethdev.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index b12bb3854..17f1c33ac 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -1290,6 +1290,8 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q, struct rte_eth_dev *dev; struct rte_eth_dev_info dev_info; struct rte_eth_conf orig_conf; + uint16_t overhead_len; + uint16_t max_rx_pktlen; int diag; int ret; @@ -1415,6 +1417,18 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q, RTE_ETHER_MAX_LEN; } + /* + * Update MTU value if MTU + OVERHEAD exceeds the max_rx_pkt_len + */ + max_rx_pktlen = dev->data->dev_conf.rxmode.max_rx_pkt_len; + if (dev_info.max_rx_pktlen && dev_info.max_mtu) + overhead_len = dev_info.max_rx_pktlen - dev_info.max_mtu; + else + overhead_len = RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN; + + if (max_rx_pktlen < dev->data->mtu + overhead_len) + dev->data->mtu = max_rx_pktlen - overhead_len; + /* * If LRO is enabled, check that the maximum aggregated packet * size is supported by the configured device. -- 2.17.1