From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 89364A0C4F; Tue, 13 Jul 2021 15:48:05 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7A15A412D2; Tue, 13 Jul 2021 15:48:05 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 4FE79412D6 for ; Tue, 13 Jul 2021 15:48:04 +0200 (CEST) Received: from [192.168.38.17] (aros.oktetlabs.ru [192.168.38.17]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by shelob.oktetlabs.ru (Postfix) with ESMTPSA id D2C6E7F529; Tue, 13 Jul 2021 16:48:03 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru D2C6E7F529 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=oktetlabs.ru; s=default; t=1626184083; bh=rpkg2MDHfmu6oa9okfJNDdQO03HajKLIY+mCucwhKrA=; h=Subject:To:Cc:References:From:Date:In-Reply-To; b=Kt+4GDS1bqjQhGEIiUwu7SeRlRhVK5sAyQvhu4LVr5KOpSnuiNMqvvVrJnY69ejCH oMrK7D6TBR5jddigTQINue5E65+c22Zl01b/9jvE8ejNNurrEh9tSvJszrgZqnGuJC 9ECgp5TOAcWK76y+T4Iv4VxBdQrXcnMAzDbF/tMo= To: Ferruh Yigit , Somalapuram Amaranath , Ajit Khaparde , Somnath Kotur , Nithin Dabilpuram , Kiran Kumar K , Sunil Kumar Kori , Satha Rao , Rahul Lakkireddy , Hemant Agrawal , Sachin Saxena , Haiyue Wang , Gagandeep Singh , Ziyang Xuan , Xiaoyun Wang , Guoyang Zhou , "Min Hu (Connor)" , Yisen Zhuang , Lijun Ou , Beilei Xing , Jingjing Wu , Qiming Yang , Qi Zhang , Rosen Xu , Shijith Thotton , Srisivasubramanian Srinivasan , Heinrich Kuhn , Harman Kalra , Jerin Jacob , Rasesh Mody , Devendra Singh Rawat , Igor Russkikh , Maciej Czekaj , Jiawen Wu , Jian Wang , Thomas Monjalon Cc: dev@dpdk.org References: <20210709172923.3369846-1-ferruh.yigit@intel.com> <20210709172923.3369846-2-ferruh.yigit@intel.com> From: Andrew Rybchenko Organization: OKTET Labs Message-ID: <8399aaa2-22e8-c2cd-a5ca-9da7bd8990d7@oktetlabs.ru> Date: Tue, 13 Jul 2021 16:48:03 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20210709172923.3369846-2-ferruh.yigit@intel.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH 2/4] ethdev: move jumbo frame offload check to library X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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 7/9/21 8:29 PM, Ferruh Yigit wrote: > Setting MTU bigger than RTE_ETHER_MTU requires the jumbo frame support, > and application should enable the jumbo frame offload support for it. > > When jumbo frame offload is not enabled by application, but MTU bigger > than RTE_ETHER_MTU is requested there are two options, either fail or > enable jumbo frame offload implicitly. > > Enabling jumbo frame offload implicitly is selected by many drivers > since setting a big MTU value already implies it, and this increases > usability. > > This patch moves this logic from drivers to the library, both to reduce > the duplicated code in the drivers and to make behaviour more visible. > > Signed-off-by: Ferruh Yigit Very good cleanup, many thanks. Reviewed-by: Andrew Rybchenko [snip] > diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c > index 3451125639f9..d649a5dd69a9 100644 > --- a/lib/ethdev/rte_ethdev.c > +++ b/lib/ethdev/rte_ethdev.c > @@ -3625,6 +3625,7 @@ rte_eth_dev_set_mtu(uint16_t port_id, uint16_t mtu) > int ret; > struct rte_eth_dev_info dev_info; > struct rte_eth_dev *dev; > + int is_jumbo_frame_capable = 0; > > RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); > dev = &rte_eth_devices[port_id]; > @@ -3643,12 +3644,27 @@ rte_eth_dev_set_mtu(uint16_t port_id, uint16_t mtu) > > if (mtu < dev_info.min_mtu || mtu > dev_info.max_mtu) > return -EINVAL; > + > + if (dev_info.rx_offload_capa & DEV_RX_OFFLOAD_JUMBO_FRAME) > + is_jumbo_frame_capable = 1; > } > > + if (mtu > RTE_ETHER_MTU && is_jumbo_frame_capable == 0) > + return -EINVAL; > + > ret = (*dev->dev_ops->mtu_set)(dev, mtu); > - if (!ret) > + if (!ret) { Since line it updated anyway, may I ask to use explicit comparison vs 0 as coding style says. > dev->data->mtu = mtu; > > + /* switch to jumbo mode if needed */ > + if (mtu > RTE_ETHER_MTU) > + dev->data->dev_conf.rxmode.offloads |= > + DEV_RX_OFFLOAD_JUMBO_FRAME; > + else > + dev->data->dev_conf.rxmode.offloads &= > + ~DEV_RX_OFFLOAD_JUMBO_FRAME; > + } > + > return eth_err(port_id, ret); > } > >