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 00759A04DD; Thu, 22 Oct 2020 18:31:19 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 94D5372F8; Thu, 22 Oct 2020 18:31:18 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by dpdk.org (Postfix) with ESMTP id 6F2AD5F69 for ; Thu, 22 Oct 2020 18:31:16 +0200 (CEST) IronPort-SDR: Mxl2J4Dohk33ekty0rIo7KqE+2NpOIxnKlVwthEhvZXOsMwWTtHowhNnYkP3VZ6U3aiO+3glP9 yJ5sf/A/bwZA== X-IronPort-AV: E=McAfee;i="6000,8403,9781"; a="155342277" X-IronPort-AV: E=Sophos;i="5.77,404,1596524400"; d="scan'208";a="155342277" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2020 09:31:09 -0700 IronPort-SDR: NjpSLykoI5gyEU0Rdl5I6rVWyXOaEkrKfo1cjBG7yInRVfEXKOl6aGAXF84K788CL/PKZLJ7tE 1nHKj/hgFRnA== X-IronPort-AV: E=Sophos;i="5.77,404,1596524400"; d="scan'208";a="534035939" Received: from fyigit-mobl1.ger.corp.intel.com (HELO [10.213.248.224]) ([10.213.248.224]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2020 09:31:06 -0700 To: SteveX Yang , dev@dpdk.org Cc: 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 References: <20201014091945.1934-1-stevex.yang@intel.com> <20201022084851.35134-1-stevex.yang@intel.com> <20201022084851.35134-3-stevex.yang@intel.com> From: Ferruh Yigit Message-ID: Date: Thu, 22 Oct 2020 17:31:03 +0100 MIME-Version: 1.0 In-Reply-To: <20201022084851.35134-3-stevex.yang@intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Subject: Re: [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" On 10/22/2020 9:48 AM, SteveX Yang wrote: > 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 > + */ I am not sure this conditional update is required, the target is keep 'max_rx_pktlen' & 'mtu' in sync. So why not just: dev->data->mtu = max_rx_pktlen - overhead_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. >