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 7C90FA0C4B; Mon, 4 Oct 2021 07:09:41 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4EFC8412A4; Mon, 4 Oct 2021 07:09:41 +0200 (CEST) Received: from mail-yb1-f170.google.com (mail-yb1-f170.google.com [209.85.219.170]) by mails.dpdk.org (Postfix) with ESMTP id A230440688 for ; Mon, 4 Oct 2021 07:09:40 +0200 (CEST) Received: by mail-yb1-f170.google.com with SMTP id q189so16772276ybq.1 for ; Sun, 03 Oct 2021 22:09:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=UKkJlTVQTlqqZcG65cJnovP1+Uh5Cy+0Ndh7Ef1NYdk=; b=Xt5betoHs+Rn6oJkNUaWqhYct1r+E3UxNb7UxD99spIcZ1oItRCnm3IhWZ2qCxtn05 yqhSBeNxnFtEMAz5rrwJjXqCnpRfkM9+akr+sPEU4RUJK3Z9RotH5WyU/f8TprmokVYC svxWUhm2WJohntU+HyOsLXz82iTCkuxVQVXEg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=UKkJlTVQTlqqZcG65cJnovP1+Uh5Cy+0Ndh7Ef1NYdk=; b=haDbkitFP3OhWm+iDZXSnvX79whTZ/3Fmv+zE+jQT1LxXOkxGS9qQp91jgz7Z05/2n vFOw9fE4MFP8g3A2eI+oLvPKhBDVjRBJ6pnvXEtOW32mvdJ/YdulhB+TcXHb89DpIlQz LtPf8V9FA+D9HMGR2jcy/awb9mf0ctXwbWdeCpYGtm+9mAEkssKsrqIsxKtkX2NO5CdR 5a6KQXE5Ob2RMUkKX8fjGCF6t4VFG33s87r/UVQDgMfzJxxPcR972HRRebOtQMjSXjSH ZJpc+EQEuDg1jLKjLe+p+SZogsIOnK7cBNltDZ003+vv052ZEoengFN3BJ8xZZ+uvLPO thHw== X-Gm-Message-State: AOAM5334DzpCnLyd1Nsc+2Nqz9IpCMNOty8MthDdabB1WeN8tfrTnRay F4Dt2kXPaFDpZwrJef/A4nNe0P2Dq45Sdpya2X4kYA== X-Google-Smtp-Source: ABdhPJxJmiCumqxi2mDiWbt4G08FsmVgUIu2uSB8ruqmxwqNTkZJRSrfnsySKvCaazjBW8f6I8OnjML7ScPBrG4K+W4= X-Received: by 2002:a25:6150:: with SMTP id v77mr12509048ybb.530.1633324179759; Sun, 03 Oct 2021 22:09:39 -0700 (PDT) MIME-Version: 1.0 References: <20210722172113.3236450-1-ferruh.yigit@intel.com> <20211001143624.3744505-1-ferruh.yigit@intel.com> <20211001143624.3744505-3-ferruh.yigit@intel.com> In-Reply-To: <20211001143624.3744505-3-ferruh.yigit@intel.com> From: Somnath Kotur Date: Mon, 4 Oct 2021 10:39:28 +0530 Message-ID: To: Ferruh Yigit Cc: Andrew Rybchenko , Thomas Monjalon , Somalapuram Amaranath , Ajit Khaparde , Rahul Lakkireddy , Hemant Agrawal , Sachin Saxena , Haiyue Wang , Gagandeep Singh , Ziyang Xuan , Xiaoyun Wang , Guoyang Zhou , Beilei Xing , Jingjing Wu , Qiming Yang , Qi Zhang , Rosen Xu , Shijith Thotton , Srisivasubramanian Srinivasan , Heinrich Kuhn , Harman Kalra , Jerin Jacob , Nithin Dabilpuram , Kiran Kumar K , Rasesh Mody , Devendra Singh Rawat , Maciej Czekaj , Jiawen Wu , Jian Wang , dev Content-Type: multipart/signed; protocol="application/pkcs7-signature"; micalg=sha-256; boundary="00000000000091866c05cd7feb99" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 Subject: Re: [dpdk-dev] [PATCH v3 3/6] ethdev: move check to library for MTU set 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" --00000000000091866c05cd7feb99 Content-Type: text/plain; charset="UTF-8" On Fri, Oct 1, 2021 at 8:07 PM Ferruh Yigit wrote: > > Move requested MTU value check to the API to prevent the duplicated > code. > > Signed-off-by: Ferruh Yigit > Reviewed-by: Andrew Rybchenko > Reviewed-by: Rosen Xu > --- > drivers/net/axgbe/axgbe_ethdev.c | 15 ++++----------- > drivers/net/bnxt/bnxt_ethdev.c | 2 +- > drivers/net/cxgbe/cxgbe_ethdev.c | 13 +------------ > drivers/net/dpaa/dpaa_ethdev.c | 2 -- > drivers/net/dpaa2/dpaa2_ethdev.c | 4 ---- > drivers/net/e1000/em_ethdev.c | 10 ---------- > drivers/net/e1000/igb_ethdev.c | 11 ----------- > drivers/net/enetc/enetc_ethdev.c | 4 ---- > drivers/net/hinic/hinic_pmd_ethdev.c | 8 +------- > drivers/net/i40e/i40e_ethdev.c | 17 ++++------------- > drivers/net/iavf/iavf_ethdev.c | 10 ++-------- > drivers/net/ice/ice_ethdev.c | 14 +++----------- > drivers/net/igc/igc_ethdev.c | 5 ----- > drivers/net/ipn3ke/ipn3ke_representor.c | 6 ------ > drivers/net/liquidio/lio_ethdev.c | 10 ---------- > drivers/net/nfp/nfp_common.c | 4 ---- > drivers/net/octeontx/octeontx_ethdev.c | 4 ---- > drivers/net/octeontx2/otx2_ethdev_ops.c | 4 ---- > drivers/net/qede/qede_ethdev.c | 12 ------------ > drivers/net/thunderx/nicvf_ethdev.c | 6 ------ > drivers/net/txgbe/txgbe_ethdev.c | 10 ---------- > lib/ethdev/rte_ethdev.c | 9 +++++++++ > 22 files changed, 25 insertions(+), 155 deletions(-) > > diff --git a/drivers/net/axgbe/axgbe_ethdev.c b/drivers/net/axgbe/axgbe_ethdev.c > index 2960834b4539..c36cd7b1d2f0 100644 > --- a/drivers/net/axgbe/axgbe_ethdev.c > +++ b/drivers/net/axgbe/axgbe_ethdev.c > @@ -1478,25 +1478,18 @@ axgbe_dev_supported_ptypes_get(struct rte_eth_dev *dev) > > static int axgb_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) > { > - struct rte_eth_dev_info dev_info; > struct axgbe_port *pdata = dev->data->dev_private; > - uint32_t frame_size = mtu + RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN; > - unsigned int val = 0; > - axgbe_dev_info_get(dev, &dev_info); > - /* check that mtu is within the allowed range */ > - if (mtu < RTE_ETHER_MIN_MTU || frame_size > dev_info.max_rx_pktlen) > - return -EINVAL; > + unsigned int val; > + > /* mtu setting is forbidden if port is start */ > if (dev->data->dev_started) { > PMD_DRV_LOG(ERR, "port %d must be stopped before configuration", > dev->data->port_id); > return -EBUSY; > } > - if (mtu > RTE_ETHER_MTU) > - val = 1; > - else > - val = 0; > + val = mtu > RTE_ETHER_MTU ? 1 : 0; > AXGMAC_IOWRITE_BITS(pdata, MAC_RCR, JE, val); > + > return 0; > } > > diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c > index 07ee19938930..dc33b961320a 100644 > --- a/drivers/net/bnxt/bnxt_ethdev.c > +++ b/drivers/net/bnxt/bnxt_ethdev.c > @@ -3025,7 +3025,7 @@ int bnxt_mtu_set_op(struct rte_eth_dev *eth_dev, uint16_t new_mtu) > uint32_t overhead = BNXT_MAX_PKT_LEN - BNXT_MAX_MTU; > struct bnxt *bp = eth_dev->data->dev_private; > uint32_t new_pkt_size; > - uint32_t rc = 0; > + uint32_t rc; > uint32_t i; > > rc = is_bnxt_in_error(bp); Acked-by: Somnath Kotur > diff --git a/drivers/net/cxgbe/cxgbe_ethdev.c b/drivers/net/cxgbe/cxgbe_ethdev.c > index 0c9cc2f5bb3f..70b879fed100 100644 > --- a/drivers/net/cxgbe/cxgbe_ethdev.c > +++ b/drivers/net/cxgbe/cxgbe_ethdev.c > @@ -301,21 +301,10 @@ int cxgbe_dev_mtu_set(struct rte_eth_dev *eth_dev, uint16_t mtu) > { > struct port_info *pi = eth_dev->data->dev_private; > struct adapter *adapter = pi->adapter; > - struct rte_eth_dev_info dev_info; > - int err; > uint16_t new_mtu = mtu + RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN; > > - err = cxgbe_dev_info_get(eth_dev, &dev_info); > - if (err != 0) > - return err; > - > - /* Must accommodate at least RTE_ETHER_MIN_MTU */ > - if (mtu < RTE_ETHER_MIN_MTU || new_mtu > dev_info.max_rx_pktlen) > - return -EINVAL; > - > - err = t4_set_rxmode(adapter, adapter->mbox, pi->viid, new_mtu, -1, -1, > + return t4_set_rxmode(adapter, adapter->mbox, pi->viid, new_mtu, -1, -1, > -1, -1, true); > - return err; > } > > /* > diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c > index 57b09f16ba44..3172e3b2de87 100644 > --- a/drivers/net/dpaa/dpaa_ethdev.c > +++ b/drivers/net/dpaa/dpaa_ethdev.c > @@ -167,8 +167,6 @@ dpaa_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) > > PMD_INIT_FUNC_TRACE(); > > - if (mtu < RTE_ETHER_MIN_MTU || frame_size > DPAA_MAX_RX_PKT_LEN) > - return -EINVAL; > /* > * Refuse mtu that requires the support of scattered packets > * when this feature has not been enabled before. > diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c > index df44bb204f65..c28f03641bbc 100644 > --- a/drivers/net/dpaa2/dpaa2_ethdev.c > +++ b/drivers/net/dpaa2/dpaa2_ethdev.c > @@ -1466,10 +1466,6 @@ dpaa2_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) > return -EINVAL; > } > > - /* check that mtu is within the allowed range */ > - if (mtu < RTE_ETHER_MIN_MTU || frame_size > DPAA2_MAX_RX_PKT_LEN) > - return -EINVAL; > - > /* Set the Max Rx frame length as 'mtu' + > * Maximum Ethernet header length > */ > diff --git a/drivers/net/e1000/em_ethdev.c b/drivers/net/e1000/em_ethdev.c > index 1b41dd04df5a..6ebef55588bc 100644 > --- a/drivers/net/e1000/em_ethdev.c > +++ b/drivers/net/e1000/em_ethdev.c > @@ -1788,22 +1788,12 @@ eth_em_default_mac_addr_set(struct rte_eth_dev *dev, > static int > eth_em_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) > { > - struct rte_eth_dev_info dev_info; > struct e1000_hw *hw; > uint32_t frame_size; > uint32_t rctl; > - int ret; > - > - ret = eth_em_infos_get(dev, &dev_info); > - if (ret != 0) > - return ret; > > frame_size = mtu + E1000_ETH_OVERHEAD; > > - /* check that mtu is within the allowed range */ > - if (mtu < RTE_ETHER_MIN_MTU || frame_size > dev_info.max_rx_pktlen) > - return -EINVAL; > - > /* > * If device is started, refuse mtu that requires the support of > * scattered packets when this feature has not been enabled before. > diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c > index a061d0529dd1..3164fde5b939 100644 > --- a/drivers/net/e1000/igb_ethdev.c > +++ b/drivers/net/e1000/igb_ethdev.c > @@ -4363,9 +4363,7 @@ eth_igb_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) > { > uint32_t rctl; > struct e1000_hw *hw; > - struct rte_eth_dev_info dev_info; > uint32_t frame_size = mtu + E1000_ETH_OVERHEAD; > - int ret; > > hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private); > > @@ -4374,15 +4372,6 @@ eth_igb_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) > if (hw->mac.type == e1000_82571) > return -ENOTSUP; > #endif > - ret = eth_igb_infos_get(dev, &dev_info); > - if (ret != 0) > - return ret; > - > - /* check that mtu is within the allowed range */ > - if (mtu < RTE_ETHER_MIN_MTU || > - frame_size > dev_info.max_rx_pktlen) > - return -EINVAL; > - > /* > * If device is started, refuse mtu that requires the support of > * scattered packets when this feature has not been enabled before. > diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c > index fbcbbb6c0533..a7372c1787c7 100644 > --- a/drivers/net/enetc/enetc_ethdev.c > +++ b/drivers/net/enetc/enetc_ethdev.c > @@ -662,10 +662,6 @@ enetc_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) > struct enetc_hw *enetc_hw = &hw->hw; > uint32_t frame_size = mtu + RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN; > > - /* check that mtu is within the allowed range */ > - if (mtu < ENETC_MAC_MINFRM_SIZE || frame_size > ENETC_MAC_MAXFRM_SIZE) > - return -EINVAL; > - > /* > * Refuse mtu that requires the support of scattered packets > * when this feature has not been enabled before. > diff --git a/drivers/net/hinic/hinic_pmd_ethdev.c b/drivers/net/hinic/hinic_pmd_ethdev.c > index 4b30dfa222a8..79987bec273c 100644 > --- a/drivers/net/hinic/hinic_pmd_ethdev.c > +++ b/drivers/net/hinic/hinic_pmd_ethdev.c > @@ -1530,17 +1530,11 @@ static void hinic_deinit_mac_addr(struct rte_eth_dev *eth_dev) > static int hinic_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu) > { > struct hinic_nic_dev *nic_dev = HINIC_ETH_DEV_TO_PRIVATE_NIC_DEV(dev); > - int ret = 0; > + int ret; > > PMD_DRV_LOG(INFO, "Set port mtu, port_id: %d, mtu: %d, max_pkt_len: %d", > dev->data->port_id, mtu, HINIC_MTU_TO_PKTLEN(mtu)); > > - if (mtu < HINIC_MIN_MTU_SIZE || mtu > HINIC_MAX_MTU_SIZE) { > - PMD_DRV_LOG(ERR, "Invalid mtu: %d, must between %d and %d", > - mtu, HINIC_MIN_MTU_SIZE, HINIC_MAX_MTU_SIZE); > - return -EINVAL; > - } > - > ret = hinic_set_port_mtu(nic_dev->hwdev, mtu); > if (ret) { > PMD_DRV_LOG(ERR, "Set port mtu failed, ret: %d", ret); > diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c > index e14859db9cfd..b93e314d3d0c 100644 > --- a/drivers/net/i40e/i40e_ethdev.c > +++ b/drivers/net/i40e/i40e_ethdev.c > @@ -11756,25 +11756,16 @@ static int i40e_set_default_mac_addr(struct rte_eth_dev *dev, > } > > static int > -i40e_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) > +i40e_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu __rte_unused) > { > - struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private); > - struct rte_eth_dev_data *dev_data = pf->dev_data; > - uint32_t frame_size = mtu + I40E_ETH_OVERHEAD; > - int ret = 0; > - > - /* check if mtu is within the allowed range */ > - if (mtu < RTE_ETHER_MIN_MTU || frame_size > I40E_FRAME_SIZE_MAX) > - return -EINVAL; > - > /* mtu setting is forbidden if port is start */ > - if (dev_data->dev_started) { > + if (dev->data->dev_started != 0) { > PMD_DRV_LOG(ERR, "port %d must be stopped before configuration", > - dev_data->port_id); > + dev->data->port_id); > return -EBUSY; > } > > - return ret; > + return 0; > } > > /* Restore ethertype filter */ > diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c > index 844d26d87ba6..2d43c666fdbb 100644 > --- a/drivers/net/iavf/iavf_ethdev.c > +++ b/drivers/net/iavf/iavf_ethdev.c > @@ -1459,21 +1459,15 @@ iavf_dev_rss_hash_conf_get(struct rte_eth_dev *dev, > } > > static int > -iavf_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) > +iavf_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu __rte_unused) > { > - uint32_t frame_size = mtu + IAVF_ETH_OVERHEAD; > - int ret = 0; > - > - if (mtu < RTE_ETHER_MIN_MTU || frame_size > IAVF_FRAME_SIZE_MAX) > - return -EINVAL; > - > /* mtu setting is forbidden if port is start */ > if (dev->data->dev_started) { > PMD_DRV_LOG(ERR, "port must be stopped before configuration"); > return -EBUSY; > } > > - return ret; > + return 0; > } > > static int > diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c > index 83e8f0da687c..02c06d4da8bc 100644 > --- a/drivers/net/ice/ice_ethdev.c > +++ b/drivers/net/ice/ice_ethdev.c > @@ -3974,21 +3974,13 @@ ice_dev_set_link_down(struct rte_eth_dev *dev) > } > > static int > -ice_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) > +ice_mtu_set(struct rte_eth_dev *dev, uint16_t mtu __rte_unused) > { > - struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private); > - struct rte_eth_dev_data *dev_data = pf->dev_data; > - uint32_t frame_size = mtu + ICE_ETH_OVERHEAD; > - > - /* check if mtu is within the allowed range */ > - if (mtu < RTE_ETHER_MIN_MTU || frame_size > ICE_FRAME_SIZE_MAX) > - return -EINVAL; > - > /* mtu setting is forbidden if port is start */ > - if (dev_data->dev_started) { > + if (dev->data->dev_started != 0) { > PMD_DRV_LOG(ERR, > "port %d must be stopped before configuration", > - dev_data->port_id); > + dev->data->port_id); > return -EBUSY; > } > > diff --git a/drivers/net/igc/igc_ethdev.c b/drivers/net/igc/igc_ethdev.c > index dcbc26b8186e..e279ae1fff1d 100644 > --- a/drivers/net/igc/igc_ethdev.c > +++ b/drivers/net/igc/igc_ethdev.c > @@ -1576,11 +1576,6 @@ eth_igc_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) > if (IGC_READ_REG(hw, IGC_CTRL_EXT) & IGC_CTRL_EXT_EXT_VLAN) > frame_size += VLAN_TAG_SIZE; > > - /* check that mtu is within the allowed range */ > - if (mtu < RTE_ETHER_MIN_MTU || > - frame_size > MAX_RX_JUMBO_FRAME_SIZE) > - return -EINVAL; > - > /* > * If device is started, refuse mtu that requires the support of > * scattered packets when this feature has not been enabled before. > diff --git a/drivers/net/ipn3ke/ipn3ke_representor.c b/drivers/net/ipn3ke/ipn3ke_representor.c > index e8a33f04bd69..377b96c0236a 100644 > --- a/drivers/net/ipn3ke/ipn3ke_representor.c > +++ b/drivers/net/ipn3ke/ipn3ke_representor.c > @@ -2778,12 +2778,6 @@ ipn3ke_rpst_mtu_set(struct rte_eth_dev *ethdev, uint16_t mtu) > int ret = 0; > struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(ethdev); > struct rte_eth_dev_data *dev_data = ethdev->data; > - uint32_t frame_size = mtu + IPN3KE_ETH_OVERHEAD; > - > - /* check if mtu is within the allowed range */ > - if (mtu < RTE_ETHER_MIN_MTU || > - frame_size > IPN3KE_MAC_FRAME_SIZE_MAX) > - return -EINVAL; > > /* mtu setting is forbidden if port is start */ > /* make sure NIC port is stopped */ > diff --git a/drivers/net/liquidio/lio_ethdev.c b/drivers/net/liquidio/lio_ethdev.c > index 3a516c52d199..9d1d811a2e37 100644 > --- a/drivers/net/liquidio/lio_ethdev.c > +++ b/drivers/net/liquidio/lio_ethdev.c > @@ -434,7 +434,6 @@ static int > lio_dev_mtu_set(struct rte_eth_dev *eth_dev, uint16_t mtu) > { > struct lio_device *lio_dev = LIO_DEV(eth_dev); > - uint16_t pf_mtu = lio_dev->linfo.link.s.mtu; > struct lio_dev_ctrl_cmd ctrl_cmd; > struct lio_ctrl_pkt ctrl_pkt; > > @@ -446,15 +445,6 @@ lio_dev_mtu_set(struct rte_eth_dev *eth_dev, uint16_t mtu) > return -EINVAL; > } > > - /* check if VF MTU is within allowed range. > - * New value should not exceed PF MTU. > - */ > - if (mtu < RTE_ETHER_MIN_MTU || mtu > pf_mtu) { > - lio_dev_err(lio_dev, "VF MTU should be >= %d and <= %d\n", > - RTE_ETHER_MIN_MTU, pf_mtu); > - return -EINVAL; > - } > - > /* flush added to prevent cmd failure > * incase the queue is full > */ > diff --git a/drivers/net/nfp/nfp_common.c b/drivers/net/nfp/nfp_common.c > index 850ec7655f82..b1ce35b334da 100644 > --- a/drivers/net/nfp/nfp_common.c > +++ b/drivers/net/nfp/nfp_common.c > @@ -951,10 +951,6 @@ nfp_net_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) > > hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); > > - /* check that mtu is within the allowed range */ > - if (mtu < RTE_ETHER_MIN_MTU || (uint32_t)mtu > hw->max_mtu) > - return -EINVAL; > - > /* mtu setting is forbidden if port is started */ > if (dev->data->dev_started) { > PMD_DRV_LOG(ERR, "port %d must be stopped before configuration", > diff --git a/drivers/net/octeontx/octeontx_ethdev.c b/drivers/net/octeontx/octeontx_ethdev.c > index fb65be2c2dc3..b2355fa695bc 100644 > --- a/drivers/net/octeontx/octeontx_ethdev.c > +++ b/drivers/net/octeontx/octeontx_ethdev.c > @@ -524,10 +524,6 @@ octeontx_dev_mtu_set(struct rte_eth_dev *eth_dev, uint16_t mtu) > struct rte_eth_dev_data *data = eth_dev->data; > int rc = 0; > > - /* Check if MTU is within the allowed range */ > - if (frame_size < OCCTX_MIN_FRS || frame_size > OCCTX_MAX_FRS) > - return -EINVAL; > - > buffsz = data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM; > > /* Refuse MTU that requires the support of scattered packets > diff --git a/drivers/net/octeontx2/otx2_ethdev_ops.c b/drivers/net/octeontx2/otx2_ethdev_ops.c > index 293306c7be2a..206da6f7cfda 100644 > --- a/drivers/net/octeontx2/otx2_ethdev_ops.c > +++ b/drivers/net/octeontx2/otx2_ethdev_ops.c > @@ -20,10 +20,6 @@ otx2_nix_mtu_set(struct rte_eth_dev *eth_dev, uint16_t mtu) > if (dev->configured && otx2_ethdev_is_ptp_en(dev)) > frame_size += NIX_TIMESYNC_RX_OFFSET; > > - /* Check if MTU is within the allowed range */ > - if (frame_size < NIX_MIN_FRS || frame_size > NIX_MAX_FRS) > - return -EINVAL; > - > buffsz = data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM; > > /* Refuse MTU that requires the support of scattered packets > diff --git a/drivers/net/qede/qede_ethdev.c b/drivers/net/qede/qede_ethdev.c > index 6886a4e5efb4..84e23ff03418 100644 > --- a/drivers/net/qede/qede_ethdev.c > +++ b/drivers/net/qede/qede_ethdev.c > @@ -2307,7 +2307,6 @@ static int qede_set_mtu(struct rte_eth_dev *dev, uint16_t mtu) > { > struct qede_dev *qdev = QEDE_INIT_QDEV(dev); > struct ecore_dev *edev = QEDE_INIT_EDEV(qdev); > - struct rte_eth_dev_info dev_info = {0}; > struct qede_fastpath *fp; > uint32_t frame_size; > uint16_t bufsz; > @@ -2315,19 +2314,8 @@ static int qede_set_mtu(struct rte_eth_dev *dev, uint16_t mtu) > int i, rc; > > PMD_INIT_FUNC_TRACE(edev); > - rc = qede_dev_info_get(dev, &dev_info); > - if (rc != 0) { > - DP_ERR(edev, "Error during getting ethernet device info\n"); > - return rc; > - } > > frame_size = mtu + QEDE_MAX_ETHER_HDR_LEN; > - if (mtu < RTE_ETHER_MIN_MTU || frame_size > dev_info.max_rx_pktlen) { > - DP_ERR(edev, "MTU %u out of range, %u is maximum allowable\n", > - mtu, dev_info.max_rx_pktlen - RTE_ETHER_HDR_LEN - > - QEDE_ETH_OVERHEAD); > - return -EINVAL; > - } > if (!dev->data->scattered_rx && > frame_size > dev->data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM) { > DP_INFO(edev, "MTU greater than minimum RX buffer size of %u\n", > diff --git a/drivers/net/thunderx/nicvf_ethdev.c b/drivers/net/thunderx/nicvf_ethdev.c > index b501fee5332c..44c6b1c72354 100644 > --- a/drivers/net/thunderx/nicvf_ethdev.c > +++ b/drivers/net/thunderx/nicvf_ethdev.c > @@ -154,12 +154,6 @@ nicvf_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu) > > PMD_INIT_FUNC_TRACE(); > > - if (frame_size > NIC_HW_MAX_FRS) > - return -EINVAL; > - > - if (frame_size < NIC_HW_MIN_FRS) > - return -EINVAL; > - > buffsz = dev->data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM; > > /* > diff --git a/drivers/net/txgbe/txgbe_ethdev.c b/drivers/net/txgbe/txgbe_ethdev.c > index 35b98097c3a4..c6fcb1871981 100644 > --- a/drivers/net/txgbe/txgbe_ethdev.c > +++ b/drivers/net/txgbe/txgbe_ethdev.c > @@ -3463,18 +3463,8 @@ static int > txgbe_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) > { > struct txgbe_hw *hw = TXGBE_DEV_HW(dev); > - struct rte_eth_dev_info dev_info; > uint32_t frame_size = mtu + RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN; > struct rte_eth_dev_data *dev_data = dev->data; > - int ret; > - > - ret = txgbe_dev_info_get(dev, &dev_info); > - if (ret != 0) > - return ret; > - > - /* check that mtu is within the allowed range */ > - if (mtu < RTE_ETHER_MIN_MTU || frame_size > dev_info.max_rx_pktlen) > - return -EINVAL; > > /* If device is started, refuse mtu that requires the support of > * scattered packets when this feature has not been enabled before. > diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c > index 1740bab98a83..ce0ed509d28f 100644 > --- a/lib/ethdev/rte_ethdev.c > +++ b/lib/ethdev/rte_ethdev.c > @@ -3652,6 +3652,9 @@ rte_eth_dev_set_mtu(uint16_t port_id, uint16_t mtu) > * which relies on dev->dev_ops->dev_infos_get. > */ > if (*dev->dev_ops->dev_infos_get != NULL) { > + uint16_t overhead_len; > + uint32_t frame_size; > + > ret = rte_eth_dev_info_get(port_id, &dev_info); > if (ret != 0) > return ret; > @@ -3659,6 +3662,12 @@ 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; > > + overhead_len = eth_dev_get_overhead_len(dev_info.max_rx_pktlen, > + dev_info.max_mtu); > + frame_size = mtu + overhead_len; > + if (mtu < RTE_ETHER_MIN_MTU || frame_size > dev_info.max_rx_pktlen) > + return -EINVAL; > + > if ((dev_info.rx_offload_capa & DEV_RX_OFFLOAD_JUMBO_FRAME) != 0) > is_jumbo_frame_capable = 1; > } > -- > 2.31.1 > --00000000000091866c05cd7feb99--