diff options
| author | Jarod Wilson <jarod@redhat.com> | 2016-10-17 15:54:09 -0400 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2016-10-18 11:34:20 -0400 |
| commit | c7315a95c2a3c8a5a5e31c72755d7505e92f0872 (patch) | |
| tree | 58bdfa1da0b8f12b65ba33429fc130d4c2a4d995 | |
| parent | caff2a87f60ab15ce872e65d577d7577c9121026 (diff) | |
ethernet/realtek: use core min/max MTU checking
8139cp: min_mtu 60, max_mtu 4096
8139too: min_mtu 68, max_mtu 1770
r8169: min_mtu 60, max_mtu depends on chipset, 1500 to 9k-ish
CC: netdev@vger.kernel.org
CC: Realtek linux nic maintainers <nic_swsd@realtek.com>
Signed-off-by: Jarod Wilson <jarod@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
| -rw-r--r-- | drivers/net/ethernet/realtek/8139cp.c | 8 | ||||
| -rw-r--r-- | drivers/net/ethernet/realtek/8139too.c | 13 | ||||
| -rw-r--r-- | drivers/net/ethernet/realtek/r8169.c | 8 |
3 files changed, 12 insertions, 17 deletions
diff --git a/drivers/net/ethernet/realtek/8139cp.c b/drivers/net/ethernet/realtek/8139cp.c index 5297bf77211c..b7c89ebcf4a2 100644 --- a/drivers/net/ethernet/realtek/8139cp.c +++ b/drivers/net/ethernet/realtek/8139cp.c | |||
| @@ -1277,10 +1277,6 @@ static int cp_change_mtu(struct net_device *dev, int new_mtu) | |||
| 1277 | { | 1277 | { |
| 1278 | struct cp_private *cp = netdev_priv(dev); | 1278 | struct cp_private *cp = netdev_priv(dev); |
| 1279 | 1279 | ||
| 1280 | /* check for invalid MTU, according to hardware limits */ | ||
| 1281 | if (new_mtu < CP_MIN_MTU || new_mtu > CP_MAX_MTU) | ||
| 1282 | return -EINVAL; | ||
| 1283 | |||
| 1284 | /* if network interface not up, no need for complexity */ | 1280 | /* if network interface not up, no need for complexity */ |
| 1285 | if (!netif_running(dev)) { | 1281 | if (!netif_running(dev)) { |
| 1286 | dev->mtu = new_mtu; | 1282 | dev->mtu = new_mtu; |
| @@ -2010,6 +2006,10 @@ static int cp_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
| 2010 | dev->vlan_features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO | | 2006 | dev->vlan_features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO | |
| 2011 | NETIF_F_HIGHDMA; | 2007 | NETIF_F_HIGHDMA; |
| 2012 | 2008 | ||
| 2009 | /* MTU range: 60 - 4096 */ | ||
| 2010 | dev->min_mtu = CP_MIN_MTU; | ||
| 2011 | dev->max_mtu = CP_MAX_MTU; | ||
| 2012 | |||
| 2013 | rc = register_netdev(dev); | 2013 | rc = register_netdev(dev); |
| 2014 | if (rc) | 2014 | if (rc) |
| 2015 | goto err_out_iomap; | 2015 | goto err_out_iomap; |
diff --git a/drivers/net/ethernet/realtek/8139too.c b/drivers/net/ethernet/realtek/8139too.c index da4c2d8a4173..9bc047ac883b 100644 --- a/drivers/net/ethernet/realtek/8139too.c +++ b/drivers/net/ethernet/realtek/8139too.c | |||
| @@ -924,19 +924,10 @@ static int rtl8139_set_features(struct net_device *dev, netdev_features_t featur | |||
| 924 | return 0; | 924 | return 0; |
| 925 | } | 925 | } |
| 926 | 926 | ||
| 927 | static int rtl8139_change_mtu(struct net_device *dev, int new_mtu) | ||
| 928 | { | ||
| 929 | if (new_mtu < 68 || new_mtu > MAX_ETH_DATA_SIZE) | ||
| 930 | return -EINVAL; | ||
| 931 | dev->mtu = new_mtu; | ||
| 932 | return 0; | ||
| 933 | } | ||
| 934 | |||
| 935 | static const struct net_device_ops rtl8139_netdev_ops = { | 927 | static const struct net_device_ops rtl8139_netdev_ops = { |
| 936 | .ndo_open = rtl8139_open, | 928 | .ndo_open = rtl8139_open, |
| 937 | .ndo_stop = rtl8139_close, | 929 | .ndo_stop = rtl8139_close, |
| 938 | .ndo_get_stats64 = rtl8139_get_stats64, | 930 | .ndo_get_stats64 = rtl8139_get_stats64, |
| 939 | .ndo_change_mtu = rtl8139_change_mtu, | ||
| 940 | .ndo_validate_addr = eth_validate_addr, | 931 | .ndo_validate_addr = eth_validate_addr, |
| 941 | .ndo_set_mac_address = rtl8139_set_mac_address, | 932 | .ndo_set_mac_address = rtl8139_set_mac_address, |
| 942 | .ndo_start_xmit = rtl8139_start_xmit, | 933 | .ndo_start_xmit = rtl8139_start_xmit, |
| @@ -1022,6 +1013,10 @@ static int rtl8139_init_one(struct pci_dev *pdev, | |||
| 1022 | dev->hw_features |= NETIF_F_RXALL; | 1013 | dev->hw_features |= NETIF_F_RXALL; |
| 1023 | dev->hw_features |= NETIF_F_RXFCS; | 1014 | dev->hw_features |= NETIF_F_RXFCS; |
| 1024 | 1015 | ||
| 1016 | /* MTU range: 68 - 1770 */ | ||
| 1017 | dev->min_mtu = ETH_MIN_MTU; | ||
| 1018 | dev->max_mtu = MAX_ETH_DATA_SIZE; | ||
| 1019 | |||
| 1025 | /* tp zeroed and aligned in alloc_etherdev */ | 1020 | /* tp zeroed and aligned in alloc_etherdev */ |
| 1026 | tp = netdev_priv(dev); | 1021 | tp = netdev_priv(dev); |
| 1027 | 1022 | ||
diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c index e55638c7505a..b698ea544bfc 100644 --- a/drivers/net/ethernet/realtek/r8169.c +++ b/drivers/net/ethernet/realtek/r8169.c | |||
| @@ -6673,10 +6673,6 @@ static int rtl8169_change_mtu(struct net_device *dev, int new_mtu) | |||
| 6673 | { | 6673 | { |
| 6674 | struct rtl8169_private *tp = netdev_priv(dev); | 6674 | struct rtl8169_private *tp = netdev_priv(dev); |
| 6675 | 6675 | ||
| 6676 | if (new_mtu < ETH_ZLEN || | ||
| 6677 | new_mtu > rtl_chip_infos[tp->mac_version].jumbo_max) | ||
| 6678 | return -EINVAL; | ||
| 6679 | |||
| 6680 | if (new_mtu > ETH_DATA_LEN) | 6676 | if (new_mtu > ETH_DATA_LEN) |
| 6681 | rtl_hw_jumbo_enable(tp); | 6677 | rtl_hw_jumbo_enable(tp); |
| 6682 | else | 6678 | else |
| @@ -8430,6 +8426,10 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
| 8430 | dev->hw_features |= NETIF_F_RXALL; | 8426 | dev->hw_features |= NETIF_F_RXALL; |
| 8431 | dev->hw_features |= NETIF_F_RXFCS; | 8427 | dev->hw_features |= NETIF_F_RXFCS; |
| 8432 | 8428 | ||
| 8429 | /* MTU range: 60 - hw-specific max */ | ||
| 8430 | dev->min_mtu = ETH_ZLEN; | ||
| 8431 | dev->max_mtu = rtl_chip_infos[chipset].jumbo_max; | ||
| 8432 | |||
| 8433 | tp->hw_start = cfg->hw_start; | 8433 | tp->hw_start = cfg->hw_start; |
| 8434 | tp->event_slow = cfg->event_slow; | 8434 | tp->event_slow = cfg->event_slow; |
| 8435 | 8435 | ||
