diff options
author | Mathias Kresin <dev@kresin.me> | 2018-02-18 22:48:44 +0100 |
---|---|---|
committer | Mathias Kresin <dev@kresin.me> | 2018-06-16 10:08:51 +0200 |
commit | 5da2c68d001ee44b15a58639ed03a0ebb6f68020 (patch) | |
tree | b2246780b2d1312d0a53c59a301e7d1d6ee13029 /target/linux/ramips | |
parent | 2f3c5fe9628a3c4f11d14d67a66923014d4dab8c (diff) | |
download | upstream-5da2c68d001ee44b15a58639ed03a0ebb6f68020.tar.gz upstream-5da2c68d001ee44b15a58639ed03a0ebb6f68020.tar.bz2 upstream-5da2c68d001ee44b15a58639ed03a0ebb6f68020.zip |
ramips: mt7621: fix mtu setting with kernel 4.14
Since kernel 4.10 commit 61e84623ace3 ("net: centralize net_device
min/max MTU checking"), the range of mtu is [min_mtu, max_mtu], which
is [68, 1500] by default.
It's necessary to set a max_mtu if a mtu > 1500 is supported.
Signed-off-by: Mathias Kresin <dev@kresin.me>
Diffstat (limited to 'target/linux/ramips')
-rw-r--r-- | target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/mtk_eth_soc.c | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/mtk_eth_soc.c index c806e289b5..d298fa9a97 100644 --- a/target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -1373,20 +1373,12 @@ static int fe_change_mtu(struct net_device *dev, int new_mtu) int frag_size, old_mtu; u32 fwd_cfg; - if (!(priv->flags & FE_FLAG_JUMBO_FRAME)) - return eth_change_mtu(dev, new_mtu); - - if (IS_ENABLED(CONFIG_SOC_MT7621)) - if (new_mtu > 2048) - return -EINVAL; - - frag_size = fe_max_frag_size(new_mtu); - if (new_mtu < 68 || frag_size > PAGE_SIZE) - return -EINVAL; - old_mtu = dev->mtu; dev->mtu = new_mtu; + if (!(priv->flags & FE_FLAG_JUMBO_FRAME)) + return 0; + /* return early if the buffer sizes will not change */ if (old_mtu <= ETH_DATA_LEN && new_mtu <= ETH_DATA_LEN) return 0; @@ -1408,6 +1400,7 @@ static int fe_change_mtu(struct net_device *dev, int new_mtu) if (new_mtu <= ETH_DATA_LEN) { fwd_cfg &= ~FE_GDM1_JMB_EN; } else { + frag_size = fe_max_frag_size(new_mtu); fwd_cfg &= ~(FE_GDM1_JMB_LEN_MASK << FE_GDM1_JMB_LEN_SHIFT); fwd_cfg |= (DIV_ROUND_UP(frag_size, 1024) << FE_GDM1_JMB_LEN_SHIFT) | FE_GDM1_JMB_EN; @@ -1541,6 +1534,9 @@ static int fe_probe(struct platform_device *pdev) netdev->vlan_features = netdev->hw_features & ~NETIF_F_HW_VLAN_CTAG_TX; netdev->features |= netdev->hw_features; + if (IS_ENABLED(CONFIG_SOC_MT7621)) + netdev->max_mtu = 2048; + /* fake rx vlan filter func. to support tx vlan offload func */ if (fe_reg_table[FE_REG_FE_DMA_VID_BASE]) netdev->features |= NETIF_F_HW_VLAN_CTAG_FILTER; |