]> git.droids-corp.org - dpdk.git/commitdiff
ethdev: move jumbo frame offload check to library
authorFerruh Yigit <ferruh.yigit@intel.com>
Mon, 18 Oct 2021 13:48:49 +0000 (14:48 +0100)
committerFerruh Yigit <ferruh.yigit@intel.com>
Mon, 18 Oct 2021 17:20:21 +0000 (19:20 +0200)
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 <ferruh.yigit@intel.com>
Reviewed-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Reviewed-by: Rosen Xu <rosen.xu@intel.com>
Acked-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
Acked-by: Somnath Kotur <somnath.kotur@broadcom.com>
Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
Acked-by: Huisong Li <lihuisong@huawei.com>
27 files changed:
drivers/net/axgbe/axgbe_ethdev.c
drivers/net/bnxt/bnxt_ethdev.c
drivers/net/cnxk/cnxk_ethdev_ops.c
drivers/net/cxgbe/cxgbe_ethdev.c
drivers/net/dpaa/dpaa_ethdev.c
drivers/net/dpaa2/dpaa2_ethdev.c
drivers/net/e1000/em_ethdev.c
drivers/net/e1000/igb_ethdev.c
drivers/net/enetc/enetc_ethdev.c
drivers/net/hinic/hinic_pmd_ethdev.c
drivers/net/hns3/hns3_ethdev.c
drivers/net/hns3/hns3_ethdev_vf.c
drivers/net/i40e/i40e_ethdev.c
drivers/net/iavf/iavf_ethdev.c
drivers/net/ice/ice_ethdev.c
drivers/net/igc/igc_ethdev.c
drivers/net/ipn3ke/ipn3ke_representor.c
drivers/net/ixgbe/ixgbe_ethdev.c
drivers/net/liquidio/lio_ethdev.c
drivers/net/nfp/nfp_common.c
drivers/net/octeontx/octeontx_ethdev.c
drivers/net/octeontx2/otx2_ethdev_ops.c
drivers/net/qede/qede_ethdev.c
drivers/net/sfc/sfc_ethdev.c
drivers/net/thunderx/nicvf_ethdev.c
drivers/net/txgbe/txgbe_ethdev.c
lib/ethdev/rte_ethdev.c

index 76cd892eec7b74836996c37acb7b5afa404c8e30..2dc5fa245bd85bcd510f0baee18aa087afc5bc5c 100644 (file)
@@ -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;
 }
index 890197d340376818796d4d91499820de74454284..6a66ed824a4787935bf5eea7e05ca0fd6c839e1b 100644 (file)
@@ -3056,15 +3056,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)
index 695d0d6fd3e2e7f38b32f1a919a5f048136b77ac..349896f6a1bf557a02e6093114ae5a82b5ac48d5 100644 (file)
@@ -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;
 }
index 458111ae5b160bca966906f47848346ee04fee0c..cdecf6b512ef0d4cc0df5f816c3daa4cd907fe3a 100644 (file)
@@ -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;
index c244c6f5a422e2105f6ac6c14cc6a654d80bfa33..f24ec55bee8bdd2c1c286db28f2c42d9278f15f4 100644 (file)
@@ -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;
index b2a0c2dd40c59c814847a3037201ae45d10947ed..02e1647d1f42816d94c5c0c2c6fb3a81cc9d9b77 100644 (file)
@@ -1465,13 +1465,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
         */
index c9692bd7b7bc026bf489537e32b349d3841f0525..de4267bf599584a1c603c608f53f2cf5a9f59c02 100644 (file)
@@ -1816,15 +1816,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;
index 9b75b5d08b3a3f2c6e74d4248e514ccd962c451e..72bdd1087cdf32a62ca68e993ef31eec10483993 100644 (file)
@@ -4392,15 +4392,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);
index 16c83914e8ce053e5a399962e3d3919f285cd72e..52c89aa038400fcd8764106cdc22b8ecb47b9362 100644 (file)
@@ -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);
 
index aef8adc2e1e0eeb1f8a97dc2e5bbe9ec4ac321ab..5d6700c183035ef2e1c4f0846ac60e5420d64fb2 100644 (file)
@@ -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;
index e1fcba9e9482aa3dec8222ebea0055fb5f0978cb..8cf6a98c56908d37e30901687daabf887a09401f 100644 (file)
@@ -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;
index b10fa2d5ad8ad2f1bf5e9962dd1c21bda77e2146..7e016917769bd98ed7077237877a06e6ccb7524e 100644 (file)
@@ -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;
index 57abc2cf747d4ccebb5f786988019732d0869150..208e60ed8c62056900b4a2487a095512055eca1d 100644 (file)
@@ -11437,11 +11437,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;
 }
 
index 5fc663f6bd46c57daacd1e8fc6d7841a8533e4c3..1df4cf17ab9220944d599e6130da708e860fbdc3 100644 (file)
@@ -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;
 }
 
index 878b3b1410c9eca00b2132d93ac256e68183f75e..4929fc7d3a1c531e0e7a19b587c49fab4fec44ae 100644 (file)
@@ -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;
 }
 
index 2b1f2f5a39d999a00bd0c988d8d36580620a2fd2..c36f0c879ef9a88171fbffbdd7a49e4e906e4a61 100644 (file)
@@ -1591,15 +1591,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);
index 0d1aaa6449b96d23db7010036b036be63277dc68..6bf139c85dea7479990868c2238bd3172facd66b 100644 (file)
@@ -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);
index 29456ab59502e6d9ef32e61187aa62a355b48903..4fbc70b4ca748575f9f48746b5330f6eddd2b619 100644 (file)
@@ -5189,13 +5189,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);
index 3fac28dcfcf955e92f877915a91f0cb5a60a191d..5e3b2aa7a3168aeb7e94d675d8f236771e1afda6 100644 (file)
@@ -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;
 }
 
index 928b4983a07a388daf3fa306bc4f38764d5c237d..d7bd5883b107ca4001e1ecfbc6aa12718ca52737 100644 (file)
@@ -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);
 
index 67c7d8929eb28332496ee0c4bf21f24e961c67a7..c5dbcc45d86b0a431e38d0c013fb4ac47d1056bd 100644 (file)
@@ -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);
 
index 3c591c8fbaa09ed5c1cc17cedce6cd2b57697f69..fa6d4030b827ce4afd6e5d88515653f1aac84684 100644 (file)
@@ -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;
 }
 
index a1cf913dc8ed49f9f5750b3ec1b2c03a6883e116..7b12794405a16a772eb9813e5f1026ba8cd4cf96 100644 (file)
@@ -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);
index d3b12675e5bf64392ebf12b8a5998ddd334e355a..de0fac899f775bae9d8e4cea292ad0f7bccd65b4 100644 (file)
@@ -1140,15 +1140,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");
index 80f51c0d9f6ce165237dbee49c060596a94c36d1..0624efcbb8663be9d208045a3037de6b9fc0704b 100644 (file)
@@ -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;
 
index 45afe872bde0c61085ab8431a04650ec078afcca..cc1d4a623818133a81e69624d9f035f894e6a163 100644 (file)
@@ -3482,12 +3482,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);
index 8d1ccf6f732c04fc6b89a45521466111ed5714cf..850208b640dda931bf8edf6d0042929e36708a76 100644 (file)
@@ -3647,6 +3647,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];
@@ -3665,12 +3666,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);
 }