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 D54DCA034F; Tue, 12 Oct 2021 01:54:19 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 95CCA410E8; Tue, 12 Oct 2021 01:54:18 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mails.dpdk.org (Postfix) with ESMTP id 90F05410E5 for ; Tue, 12 Oct 2021 01:54:16 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10134"; a="313190892" X-IronPort-AV: E=Sophos;i="5.85,366,1624345200"; d="scan'208";a="313190892" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2021 16:54:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,366,1624345200"; d="scan'208";a="591518257" Received: from silpixa00399752.ir.intel.com (HELO silpixa00399752.ger.corp.intel.com) ([10.237.222.27]) by orsmga004.jf.intel.com with ESMTP; 11 Oct 2021 16:54:06 -0700 From: Ferruh Yigit To: 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 , Andrew Rybchenko , Maciej Czekaj , Jiawen Wu , Jian Wang , Thomas Monjalon Cc: Ferruh Yigit , dev@dpdk.org, Konstantin Ananyev , Huisong Li Date: Tue, 12 Oct 2021 00:53:40 +0100 Message-Id: <20211011235345.851742-2-ferruh.yigit@intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211011235345.851742-1-ferruh.yigit@intel.com> References: <20211001143624.3744505-1-ferruh.yigit@intel.com> <20211011235345.851742-1-ferruh.yigit@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v6 2/6] 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" 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 Reviewed-by: Andrew Rybchenko Reviewed-by: Rosen Xu Acked-by: Ajit Khaparde Acked-by: Somnath Kotur Acked-by: Konstantin Ananyev Acked-by: Huisong Li --- drivers/net/axgbe/axgbe_ethdev.c | 9 ++------- drivers/net/bnxt/bnxt_ethdev.c | 9 ++------- drivers/net/cnxk/cnxk_ethdev_ops.c | 5 ----- drivers/net/cxgbe/cxgbe_ethdev.c | 8 -------- drivers/net/dpaa/dpaa_ethdev.c | 7 ------- drivers/net/dpaa2/dpaa2_ethdev.c | 7 ------- drivers/net/e1000/em_ethdev.c | 9 ++------- drivers/net/e1000/igb_ethdev.c | 9 ++------- drivers/net/enetc/enetc_ethdev.c | 7 ------- drivers/net/hinic/hinic_pmd_ethdev.c | 7 ------- drivers/net/hns3/hns3_ethdev.c | 8 -------- drivers/net/hns3/hns3_ethdev_vf.c | 6 ------ drivers/net/i40e/i40e_ethdev.c | 5 ----- drivers/net/iavf/iavf_ethdev.c | 7 ------- drivers/net/ice/ice_ethdev.c | 5 ----- drivers/net/igc/igc_ethdev.c | 9 ++------- drivers/net/ipn3ke/ipn3ke_representor.c | 5 ----- drivers/net/ixgbe/ixgbe_ethdev.c | 7 ++----- drivers/net/liquidio/lio_ethdev.c | 7 ------- drivers/net/nfp/nfp_common.c | 6 ------ drivers/net/octeontx/octeontx_ethdev.c | 5 ----- drivers/net/octeontx2/otx2_ethdev_ops.c | 5 ----- drivers/net/qede/qede_ethdev.c | 4 ---- drivers/net/sfc/sfc_ethdev.c | 9 --------- drivers/net/thunderx/nicvf_ethdev.c | 6 ------ drivers/net/txgbe/txgbe_ethdev.c | 6 ------ lib/ethdev/rte_ethdev.c | 18 +++++++++++++++++- 27 files changed, 29 insertions(+), 166 deletions(-) diff --git a/drivers/net/axgbe/axgbe_ethdev.c b/drivers/net/axgbe/axgbe_ethdev.c index 76cd892eec7b..2dc5fa245bd8 100644 --- a/drivers/net/axgbe/axgbe_ethdev.c +++ b/drivers/net/axgbe/axgbe_ethdev.c @@ -1492,15 +1492,10 @@ static int axgb_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) dev->data->port_id); return -EBUSY; } - if (mtu > RTE_ETHER_MTU) { - dev->data->dev_conf.rxmode.offloads |= - DEV_RX_OFFLOAD_JUMBO_FRAME; + if (mtu > RTE_ETHER_MTU) val = 1; - } else { - dev->data->dev_conf.rxmode.offloads &= - ~DEV_RX_OFFLOAD_JUMBO_FRAME; + else val = 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 8c6f20b75aed..07ee19938930 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -3052,15 +3052,10 @@ int bnxt_mtu_set_op(struct rte_eth_dev *eth_dev, uint16_t new_mtu) return -EINVAL; } - if (new_mtu > RTE_ETHER_MTU) { + if (new_mtu > RTE_ETHER_MTU) bp->flags |= BNXT_FLAG_JUMBO; - bp->eth_dev->data->dev_conf.rxmode.offloads |= - DEV_RX_OFFLOAD_JUMBO_FRAME; - } else { - bp->eth_dev->data->dev_conf.rxmode.offloads &= - ~DEV_RX_OFFLOAD_JUMBO_FRAME; + else bp->flags &= ~BNXT_FLAG_JUMBO; - } /* Is there a change in mtu setting? */ if (eth_dev->data->mtu == new_mtu) diff --git a/drivers/net/cnxk/cnxk_ethdev_ops.c b/drivers/net/cnxk/cnxk_ethdev_ops.c index 695d0d6fd3e2..349896f6a1bf 100644 --- a/drivers/net/cnxk/cnxk_ethdev_ops.c +++ b/drivers/net/cnxk/cnxk_ethdev_ops.c @@ -439,11 +439,6 @@ cnxk_nix_mtu_set(struct rte_eth_dev *eth_dev, uint16_t mtu) plt_err("Failed to max Rx frame length, rc=%d", rc); goto exit; } - - if (mtu > RTE_ETHER_MTU) - dev->rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME; - else - dev->rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME; exit: return rc; } diff --git a/drivers/net/cxgbe/cxgbe_ethdev.c b/drivers/net/cxgbe/cxgbe_ethdev.c index 458111ae5b16..cdecf6b512ef 100644 --- a/drivers/net/cxgbe/cxgbe_ethdev.c +++ b/drivers/net/cxgbe/cxgbe_ethdev.c @@ -313,14 +313,6 @@ int cxgbe_dev_mtu_set(struct rte_eth_dev *eth_dev, uint16_t mtu) if (mtu < RTE_ETHER_MIN_MTU || new_mtu > dev_info.max_rx_pktlen) return -EINVAL; - /* set to jumbo mode if needed */ - if (mtu > RTE_ETHER_MTU) - eth_dev->data->dev_conf.rxmode.offloads |= - DEV_RX_OFFLOAD_JUMBO_FRAME; - else - eth_dev->data->dev_conf.rxmode.offloads &= - ~DEV_RX_OFFLOAD_JUMBO_FRAME; - err = 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 0c2b3fbf552f..d0013e7f5b67 100644 --- a/drivers/net/dpaa/dpaa_ethdev.c +++ b/drivers/net/dpaa/dpaa_ethdev.c @@ -187,13 +187,6 @@ dpaa_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) return -EINVAL; } - 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; - fman_if_set_maxfrm(dev->process_private, frame_size); return 0; diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c index ef709bba4793..4245db78cf12 100644 --- a/drivers/net/dpaa2/dpaa2_ethdev.c +++ b/drivers/net/dpaa2/dpaa2_ethdev.c @@ -1466,13 +1466,6 @@ dpaa2_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) if (mtu < RTE_ETHER_MIN_MTU || frame_size > DPAA2_MAX_RX_PKT_LEN) return -EINVAL; - 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; - /* 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 6f418a36aa04..1b41dd04df5a 100644 --- a/drivers/net/e1000/em_ethdev.c +++ b/drivers/net/e1000/em_ethdev.c @@ -1818,15 +1818,10 @@ eth_em_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) rctl = E1000_READ_REG(hw, E1000_RCTL); /* switch to jumbo mode if needed */ - if (mtu > RTE_ETHER_MTU) { - dev->data->dev_conf.rxmode.offloads |= - DEV_RX_OFFLOAD_JUMBO_FRAME; + if (mtu > RTE_ETHER_MTU) rctl |= E1000_RCTL_LPE; - } else { - dev->data->dev_conf.rxmode.offloads &= - ~DEV_RX_OFFLOAD_JUMBO_FRAME; + else rctl &= ~E1000_RCTL_LPE; - } E1000_WRITE_REG(hw, E1000_RCTL, rctl); return 0; diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c index 867e5008ac20..36e71b5e7561 100644 --- a/drivers/net/e1000/igb_ethdev.c +++ b/drivers/net/e1000/igb_ethdev.c @@ -4396,15 +4396,10 @@ eth_igb_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) rctl = E1000_READ_REG(hw, E1000_RCTL); /* switch to jumbo mode if needed */ - if (mtu > RTE_ETHER_MTU) { - dev->data->dev_conf.rxmode.offloads |= - DEV_RX_OFFLOAD_JUMBO_FRAME; + if (mtu > RTE_ETHER_MTU) rctl |= E1000_RCTL_LPE; - } else { - dev->data->dev_conf.rxmode.offloads &= - ~DEV_RX_OFFLOAD_JUMBO_FRAME; + else rctl &= ~E1000_RCTL_LPE; - } E1000_WRITE_REG(hw, E1000_RCTL, rctl); E1000_WRITE_REG(hw, E1000_RLPML, frame_size); diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c index 1e27ed298354..61bb009c403f 100644 --- a/drivers/net/enetc/enetc_ethdev.c +++ b/drivers/net/enetc/enetc_ethdev.c @@ -681,13 +681,6 @@ enetc_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) return -EINVAL; } - 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; - enetc_port_wr(enetc_hw, ENETC_PTCMSDUR(0), ENETC_MAC_MAXFRM_SIZE); enetc_port_wr(enetc_hw, ENETC_PTXMBAR, 2 * ENETC_MAC_MAXFRM_SIZE); diff --git a/drivers/net/hinic/hinic_pmd_ethdev.c b/drivers/net/hinic/hinic_pmd_ethdev.c index aef8adc2e1e0..5d6700c18303 100644 --- a/drivers/net/hinic/hinic_pmd_ethdev.c +++ b/drivers/net/hinic/hinic_pmd_ethdev.c @@ -1551,13 +1551,6 @@ static int hinic_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu) return ret; } - 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; - nic_dev->mtu_size = mtu; return ret; diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index 81cad6e4305f..5b3ac9d2fa3f 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -2566,7 +2566,6 @@ hns3_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) struct hns3_adapter *hns = dev->data->dev_private; uint32_t frame_size = mtu + HNS3_ETH_OVERHEAD; struct hns3_hw *hw = &hns->hw; - bool is_jumbo_frame; int ret; if (dev->data->dev_started) { @@ -2576,7 +2575,6 @@ hns3_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) } rte_spinlock_lock(&hw->lock); - is_jumbo_frame = mtu > RTE_ETHER_MTU ? true : false; frame_size = RTE_MAX(frame_size, HNS3_DEFAULT_FRAME_LEN); /* @@ -2591,12 +2589,6 @@ hns3_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) return ret; } - if (is_jumbo_frame) - dev->data->dev_conf.rxmode.offloads |= - DEV_RX_OFFLOAD_JUMBO_FRAME; - else - dev->data->dev_conf.rxmode.offloads &= - ~DEV_RX_OFFLOAD_JUMBO_FRAME; rte_spinlock_unlock(&hw->lock); return 0; diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c index 0b5db486f8d6..3438b3650de6 100644 --- a/drivers/net/hns3/hns3_ethdev_vf.c +++ b/drivers/net/hns3/hns3_ethdev_vf.c @@ -908,12 +908,6 @@ hns3vf_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) rte_spinlock_unlock(&hw->lock); return ret; } - 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; rte_spinlock_unlock(&hw->lock); return 0; diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index cfefef4746e9..25e924bca2b0 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -11423,11 +11423,6 @@ i40e_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) return -EBUSY; } - 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 ret; } diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c index 0eabce275d92..844d26d87ba6 100644 --- a/drivers/net/iavf/iavf_ethdev.c +++ b/drivers/net/iavf/iavf_ethdev.c @@ -1473,13 +1473,6 @@ iavf_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) return -EBUSY; } - 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 ret; } diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c index ebe9834e6097..001868f321c7 100644 --- a/drivers/net/ice/ice_ethdev.c +++ b/drivers/net/ice/ice_ethdev.c @@ -3992,11 +3992,6 @@ ice_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) return -EBUSY; } - 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 0; } diff --git a/drivers/net/igc/igc_ethdev.c b/drivers/net/igc/igc_ethdev.c index 1ebe7a02ce57..044200f58354 100644 --- a/drivers/net/igc/igc_ethdev.c +++ b/drivers/net/igc/igc_ethdev.c @@ -1592,15 +1592,10 @@ eth_igc_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) } rctl = IGC_READ_REG(hw, IGC_RCTL); - - /* switch to jumbo mode if needed */ - if (mtu > RTE_ETHER_MTU) { - dev->data->dev_conf.rxmode.offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME; + if (mtu > RTE_ETHER_MTU) rctl |= IGC_RCTL_LPE; - } else { - dev->data->dev_conf.rxmode.offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME; + else rctl &= ~IGC_RCTL_LPE; - } IGC_WRITE_REG(hw, IGC_RCTL, rctl); IGC_WRITE_REG(hw, IGC_RLPML, frame_size); diff --git a/drivers/net/ipn3ke/ipn3ke_representor.c b/drivers/net/ipn3ke/ipn3ke_representor.c index 0d1aaa6449b9..6bf139c85dea 100644 --- a/drivers/net/ipn3ke/ipn3ke_representor.c +++ b/drivers/net/ipn3ke/ipn3ke_representor.c @@ -2791,11 +2791,6 @@ ipn3ke_rpst_mtu_set(struct rte_eth_dev *ethdev, uint16_t mtu) return -EBUSY; } - 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; - if (rpst->i40e_pf_eth) { ret = rpst->i40e_pf_eth->dev_ops->mtu_set(rpst->i40e_pf_eth, mtu); diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c index 0ceb42a5cd9e..9acd4a43aad7 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -5191,13 +5191,10 @@ ixgbe_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) hlreg0 = IXGBE_READ_REG(hw, IXGBE_HLREG0); /* switch to jumbo mode if needed */ - if (mtu > RTE_ETHER_MTU) { - dev->data->dev_conf.rxmode.offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME; + if (mtu > RTE_ETHER_MTU) hlreg0 |= IXGBE_HLREG0_JUMBOEN; - } else { - dev->data->dev_conf.rxmode.offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME; + else hlreg0 &= ~IXGBE_HLREG0_JUMBOEN; - } IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg0); maxfrs = IXGBE_READ_REG(hw, IXGBE_MAXFRS); diff --git a/drivers/net/liquidio/lio_ethdev.c b/drivers/net/liquidio/lio_ethdev.c index f235653718fc..3045508fa9b9 100644 --- a/drivers/net/liquidio/lio_ethdev.c +++ b/drivers/net/liquidio/lio_ethdev.c @@ -480,13 +480,6 @@ lio_dev_mtu_set(struct rte_eth_dev *eth_dev, uint16_t mtu) return -1; } - if (mtu > RTE_ETHER_MTU) - eth_dev->data->dev_conf.rxmode.offloads |= - DEV_RX_OFFLOAD_JUMBO_FRAME; - else - eth_dev->data->dev_conf.rxmode.offloads &= - ~DEV_RX_OFFLOAD_JUMBO_FRAME; - return 0; } diff --git a/drivers/net/nfp/nfp_common.c b/drivers/net/nfp/nfp_common.c index 928b4983a07a..d7bd5883b107 100644 --- a/drivers/net/nfp/nfp_common.c +++ b/drivers/net/nfp/nfp_common.c @@ -962,12 +962,6 @@ nfp_net_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) return -EBUSY; } - /* 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; - /* writing to configuration space */ nn_cfg_writel(hw, NFP_NET_CFG_MTU, mtu); diff --git a/drivers/net/octeontx/octeontx_ethdev.c b/drivers/net/octeontx/octeontx_ethdev.c index 10151a748d5d..5c6e5d201528 100644 --- a/drivers/net/octeontx/octeontx_ethdev.c +++ b/drivers/net/octeontx/octeontx_ethdev.c @@ -552,11 +552,6 @@ octeontx_dev_mtu_set(struct rte_eth_dev *eth_dev, uint16_t mtu) if (rc) return rc; - if (mtu > RTE_ETHER_MTU) - nic->rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME; - else - nic->rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME; - octeontx_log_info("Received pkt beyond maxlen %d will be dropped", frame_size); diff --git a/drivers/net/octeontx2/otx2_ethdev_ops.c b/drivers/net/octeontx2/otx2_ethdev_ops.c index cf7804157198..293306c7be2a 100644 --- a/drivers/net/octeontx2/otx2_ethdev_ops.c +++ b/drivers/net/octeontx2/otx2_ethdev_ops.c @@ -59,11 +59,6 @@ otx2_nix_mtu_set(struct rte_eth_dev *eth_dev, uint16_t mtu) if (rc) return rc; - if (mtu > RTE_ETHER_MTU) - dev->rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME; - else - dev->rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME; - return rc; } diff --git a/drivers/net/qede/qede_ethdev.c b/drivers/net/qede/qede_ethdev.c index a1cf913dc8ed..7b12794405a1 100644 --- a/drivers/net/qede/qede_ethdev.c +++ b/drivers/net/qede/qede_ethdev.c @@ -2361,10 +2361,6 @@ static int qede_set_mtu(struct rte_eth_dev *dev, uint16_t mtu) fp->rxq->rx_buf_size = rc; } } - 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; if (!dev->data->dev_started && restart) { qede_dev_start(dev); diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c index 09146f741952..29236a3a5c0a 100644 --- a/drivers/net/sfc/sfc_ethdev.c +++ b/drivers/net/sfc/sfc_ethdev.c @@ -1065,15 +1065,6 @@ sfc_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu) } } - /* - * The driver does not use it, but other PMDs update jumbo frame - * flag when MTU is set. - */ - if (mtu > RTE_ETHER_MTU) { - struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode; - rxmode->offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME; - } - sfc_adapter_unlock(sa); sfc_log_init(sa, "done"); diff --git a/drivers/net/thunderx/nicvf_ethdev.c b/drivers/net/thunderx/nicvf_ethdev.c index 1000d9855ad3..3ea3699784d2 100644 --- a/drivers/net/thunderx/nicvf_ethdev.c +++ b/drivers/net/thunderx/nicvf_ethdev.c @@ -151,7 +151,6 @@ nicvf_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu) struct nicvf *nic = nicvf_pmd_priv(dev); uint32_t buffsz, frame_size = mtu + NIC_HW_L2_OVERHEAD; size_t i; - struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode; PMD_INIT_FUNC_TRACE(); @@ -176,11 +175,6 @@ nicvf_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu) (frame_size + 2 * VLAN_TAG_SIZE > buffsz * NIC_HW_MAX_SEGS)) return -EINVAL; - if (mtu > RTE_ETHER_MTU) - rxmode->offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME; - else - rxmode->offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME; - if (nicvf_mbox_update_hw_max_frs(nic, mtu)) return -EINVAL; diff --git a/drivers/net/txgbe/txgbe_ethdev.c b/drivers/net/txgbe/txgbe_ethdev.c index 9427ac738f1b..003ce0d196da 100644 --- a/drivers/net/txgbe/txgbe_ethdev.c +++ b/drivers/net/txgbe/txgbe_ethdev.c @@ -3486,12 +3486,6 @@ txgbe_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) return -EINVAL; } - /* 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; - if (hw->mode) wr32m(hw, TXGBE_FRMSZ, TXGBE_FRMSZ_MAX_MASK, TXGBE_FRAME_SIZE_MAX); diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c index 634e4d7d7fd6..37c7ea49bd63 100644 --- a/lib/ethdev/rte_ethdev.c +++ b/lib/ethdev/rte_ethdev.c @@ -3619,6 +3619,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]; @@ -3637,12 +3638,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) != 0) + 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 == 0) { 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); } -- 2.31.1