diff options
author | Jarod Wilson <jarod@redhat.com> | 2016-10-17 15:54:10 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-10-18 11:34:20 -0400 |
commit | 540bfe30dc3f0b365c3a859eecad66ef468e167c (patch) | |
tree | ef6f1f7e8991d9b390ebeee8cc4e73a30503b82e | |
parent | c7315a95c2a3c8a5a5e31c72755d7505e92f0872 (diff) |
ethernet/sun: use core min/max MTU checking
cassini: min_mtu 60, max_mtu 9000
niu: min_mtu 68, max_mtu 9216
sungem: min_mtu 68, max_mtu 1500 (comments say jumbo mode is broken)
sunvnet: min_mtu 68, max_mtu 65535
- removed sunvnet_change_mut_common as it does nothing now
CC: netdev@vger.kernel.org
Signed-off-by: Jarod Wilson <jarod@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/ethernet/sun/cassini.c | 7 | ||||
-rw-r--r-- | drivers/net/ethernet/sun/ldmvsw.c | 5 | ||||
-rw-r--r-- | drivers/net/ethernet/sun/niu.c | 7 | ||||
-rw-r--r-- | drivers/net/ethernet/sun/sungem.c | 11 | ||||
-rw-r--r-- | drivers/net/ethernet/sun/sunvnet.c | 5 | ||||
-rw-r--r-- | drivers/net/ethernet/sun/sunvnet_common.c | 10 | ||||
-rw-r--r-- | drivers/net/ethernet/sun/sunvnet_common.h | 3 |
7 files changed, 24 insertions, 24 deletions
diff --git a/drivers/net/ethernet/sun/cassini.c b/drivers/net/ethernet/sun/cassini.c index 062bce9acde6..e9e5ef241c6f 100644 --- a/drivers/net/ethernet/sun/cassini.c +++ b/drivers/net/ethernet/sun/cassini.c | |||
@@ -3863,9 +3863,6 @@ static int cas_change_mtu(struct net_device *dev, int new_mtu) | |||
3863 | { | 3863 | { |
3864 | struct cas *cp = netdev_priv(dev); | 3864 | struct cas *cp = netdev_priv(dev); |
3865 | 3865 | ||
3866 | if (new_mtu < CAS_MIN_MTU || new_mtu > CAS_MAX_MTU) | ||
3867 | return -EINVAL; | ||
3868 | |||
3869 | dev->mtu = new_mtu; | 3866 | dev->mtu = new_mtu; |
3870 | if (!netif_running(dev) || !netif_device_present(dev)) | 3867 | if (!netif_running(dev) || !netif_device_present(dev)) |
3871 | return 0; | 3868 | return 0; |
@@ -5115,6 +5112,10 @@ static int cas_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
5115 | if (pci_using_dac) | 5112 | if (pci_using_dac) |
5116 | dev->features |= NETIF_F_HIGHDMA; | 5113 | dev->features |= NETIF_F_HIGHDMA; |
5117 | 5114 | ||
5115 | /* MTU range: 60 - varies or 9000 */ | ||
5116 | dev->min_mtu = CAS_MIN_MTU; | ||
5117 | dev->max_mtu = CAS_MAX_MTU; | ||
5118 | |||
5118 | if (register_netdev(dev)) { | 5119 | if (register_netdev(dev)) { |
5119 | dev_err(&pdev->dev, "Cannot register net device, aborting\n"); | 5120 | dev_err(&pdev->dev, "Cannot register net device, aborting\n"); |
5120 | goto err_out_free_consistent; | 5121 | goto err_out_free_consistent; |
diff --git a/drivers/net/ethernet/sun/ldmvsw.c b/drivers/net/ethernet/sun/ldmvsw.c index 0ac449acaf5b..335b87660638 100644 --- a/drivers/net/ethernet/sun/ldmvsw.c +++ b/drivers/net/ethernet/sun/ldmvsw.c | |||
@@ -139,7 +139,6 @@ static const struct net_device_ops vsw_ops = { | |||
139 | .ndo_set_mac_address = sunvnet_set_mac_addr_common, | 139 | .ndo_set_mac_address = sunvnet_set_mac_addr_common, |
140 | .ndo_validate_addr = eth_validate_addr, | 140 | .ndo_validate_addr = eth_validate_addr, |
141 | .ndo_tx_timeout = sunvnet_tx_timeout_common, | 141 | .ndo_tx_timeout = sunvnet_tx_timeout_common, |
142 | .ndo_change_mtu = sunvnet_change_mtu_common, | ||
143 | .ndo_start_xmit = vsw_start_xmit, | 142 | .ndo_start_xmit = vsw_start_xmit, |
144 | .ndo_select_queue = vsw_select_queue, | 143 | .ndo_select_queue = vsw_select_queue, |
145 | #ifdef CONFIG_NET_POLL_CONTROLLER | 144 | #ifdef CONFIG_NET_POLL_CONTROLLER |
@@ -239,6 +238,10 @@ static struct net_device *vsw_alloc_netdev(u8 hwaddr[], | |||
239 | NETIF_F_HW_CSUM | NETIF_F_SG; | 238 | NETIF_F_HW_CSUM | NETIF_F_SG; |
240 | dev->features = dev->hw_features; | 239 | dev->features = dev->hw_features; |
241 | 240 | ||
241 | /* MTU range: 68 - 65535 */ | ||
242 | dev->min_mtu = ETH_MIN_MTU; | ||
243 | dev->max_mtu = VNET_MAX_MTU; | ||
244 | |||
242 | SET_NETDEV_DEV(dev, &vdev->dev); | 245 | SET_NETDEV_DEV(dev, &vdev->dev); |
243 | 246 | ||
244 | return dev; | 247 | return dev; |
diff --git a/drivers/net/ethernet/sun/niu.c b/drivers/net/ethernet/sun/niu.c index a2371aa14a49..f90d1af6d390 100644 --- a/drivers/net/ethernet/sun/niu.c +++ b/drivers/net/ethernet/sun/niu.c | |||
@@ -6754,9 +6754,6 @@ static int niu_change_mtu(struct net_device *dev, int new_mtu) | |||
6754 | struct niu *np = netdev_priv(dev); | 6754 | struct niu *np = netdev_priv(dev); |
6755 | int err, orig_jumbo, new_jumbo; | 6755 | int err, orig_jumbo, new_jumbo; |
6756 | 6756 | ||
6757 | if (new_mtu < 68 || new_mtu > NIU_MAX_MTU) | ||
6758 | return -EINVAL; | ||
6759 | |||
6760 | orig_jumbo = (dev->mtu > ETH_DATA_LEN); | 6757 | orig_jumbo = (dev->mtu > ETH_DATA_LEN); |
6761 | new_jumbo = (new_mtu > ETH_DATA_LEN); | 6758 | new_jumbo = (new_mtu > ETH_DATA_LEN); |
6762 | 6759 | ||
@@ -9823,6 +9820,10 @@ static int niu_pci_init_one(struct pci_dev *pdev, | |||
9823 | 9820 | ||
9824 | dev->irq = pdev->irq; | 9821 | dev->irq = pdev->irq; |
9825 | 9822 | ||
9823 | /* MTU range: 68 - 9216 */ | ||
9824 | dev->min_mtu = ETH_MIN_MTU; | ||
9825 | dev->max_mtu = NIU_MAX_MTU; | ||
9826 | |||
9826 | niu_assign_netdev_ops(dev); | 9827 | niu_assign_netdev_ops(dev); |
9827 | 9828 | ||
9828 | err = niu_get_invariants(np); | 9829 | err = niu_get_invariants(np); |
diff --git a/drivers/net/ethernet/sun/sungem.c b/drivers/net/ethernet/sun/sungem.c index d6ad0fbd054e..66ecf0fcc330 100644 --- a/drivers/net/ethernet/sun/sungem.c +++ b/drivers/net/ethernet/sun/sungem.c | |||
@@ -2476,9 +2476,9 @@ static void gem_set_multicast(struct net_device *dev) | |||
2476 | } | 2476 | } |
2477 | 2477 | ||
2478 | /* Jumbo-grams don't seem to work :-( */ | 2478 | /* Jumbo-grams don't seem to work :-( */ |
2479 | #define GEM_MIN_MTU 68 | 2479 | #define GEM_MIN_MTU ETH_MIN_MTU |
2480 | #if 1 | 2480 | #if 1 |
2481 | #define GEM_MAX_MTU 1500 | 2481 | #define GEM_MAX_MTU ETH_DATA_LEN |
2482 | #else | 2482 | #else |
2483 | #define GEM_MAX_MTU 9000 | 2483 | #define GEM_MAX_MTU 9000 |
2484 | #endif | 2484 | #endif |
@@ -2487,9 +2487,6 @@ static int gem_change_mtu(struct net_device *dev, int new_mtu) | |||
2487 | { | 2487 | { |
2488 | struct gem *gp = netdev_priv(dev); | 2488 | struct gem *gp = netdev_priv(dev); |
2489 | 2489 | ||
2490 | if (new_mtu < GEM_MIN_MTU || new_mtu > GEM_MAX_MTU) | ||
2491 | return -EINVAL; | ||
2492 | |||
2493 | dev->mtu = new_mtu; | 2490 | dev->mtu = new_mtu; |
2494 | 2491 | ||
2495 | /* We'll just catch it later when the device is up'd or resumed */ | 2492 | /* We'll just catch it later when the device is up'd or resumed */ |
@@ -2977,6 +2974,10 @@ static int gem_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
2977 | if (pci_using_dac) | 2974 | if (pci_using_dac) |
2978 | dev->features |= NETIF_F_HIGHDMA; | 2975 | dev->features |= NETIF_F_HIGHDMA; |
2979 | 2976 | ||
2977 | /* MTU range: 68 - 1500 (Jumbo mode is broken) */ | ||
2978 | dev->min_mtu = GEM_MIN_MTU; | ||
2979 | dev->max_mtu = GEM_MAX_MTU; | ||
2980 | |||
2980 | /* Register with kernel */ | 2981 | /* Register with kernel */ |
2981 | if (register_netdev(dev)) { | 2982 | if (register_netdev(dev)) { |
2982 | pr_err("Cannot register net device, aborting\n"); | 2983 | pr_err("Cannot register net device, aborting\n"); |
diff --git a/drivers/net/ethernet/sun/sunvnet.c b/drivers/net/ethernet/sun/sunvnet.c index a2f9b47de187..5356a7074796 100644 --- a/drivers/net/ethernet/sun/sunvnet.c +++ b/drivers/net/ethernet/sun/sunvnet.c | |||
@@ -159,7 +159,6 @@ static const struct net_device_ops vnet_ops = { | |||
159 | .ndo_set_mac_address = sunvnet_set_mac_addr_common, | 159 | .ndo_set_mac_address = sunvnet_set_mac_addr_common, |
160 | .ndo_validate_addr = eth_validate_addr, | 160 | .ndo_validate_addr = eth_validate_addr, |
161 | .ndo_tx_timeout = sunvnet_tx_timeout_common, | 161 | .ndo_tx_timeout = sunvnet_tx_timeout_common, |
162 | .ndo_change_mtu = sunvnet_change_mtu_common, | ||
163 | .ndo_start_xmit = vnet_start_xmit, | 162 | .ndo_start_xmit = vnet_start_xmit, |
164 | .ndo_select_queue = vnet_select_queue, | 163 | .ndo_select_queue = vnet_select_queue, |
165 | #ifdef CONFIG_NET_POLL_CONTROLLER | 164 | #ifdef CONFIG_NET_POLL_CONTROLLER |
@@ -202,6 +201,10 @@ static struct vnet *vnet_new(const u64 *local_mac, | |||
202 | NETIF_F_HW_CSUM | NETIF_F_SG; | 201 | NETIF_F_HW_CSUM | NETIF_F_SG; |
203 | dev->features = dev->hw_features; | 202 | dev->features = dev->hw_features; |
204 | 203 | ||
204 | /* MTU range: 68 - 65535 */ | ||
205 | dev->min_mtu = ETH_MIN_MTU; | ||
206 | dev->max_mtu = VNET_MAX_MTU; | ||
207 | |||
205 | SET_NETDEV_DEV(dev, &vdev->dev); | 208 | SET_NETDEV_DEV(dev, &vdev->dev); |
206 | 209 | ||
207 | err = register_netdev(dev); | 210 | err = register_netdev(dev); |
diff --git a/drivers/net/ethernet/sun/sunvnet_common.c b/drivers/net/ethernet/sun/sunvnet_common.c index 904a5a12a85d..58efe69b7ba7 100644 --- a/drivers/net/ethernet/sun/sunvnet_common.c +++ b/drivers/net/ethernet/sun/sunvnet_common.c | |||
@@ -1583,16 +1583,6 @@ void sunvnet_set_rx_mode_common(struct net_device *dev, struct vnet *vp) | |||
1583 | } | 1583 | } |
1584 | EXPORT_SYMBOL_GPL(sunvnet_set_rx_mode_common); | 1584 | EXPORT_SYMBOL_GPL(sunvnet_set_rx_mode_common); |
1585 | 1585 | ||
1586 | int sunvnet_change_mtu_common(struct net_device *dev, int new_mtu) | ||
1587 | { | ||
1588 | if (new_mtu < 68 || new_mtu > 65535) | ||
1589 | return -EINVAL; | ||
1590 | |||
1591 | dev->mtu = new_mtu; | ||
1592 | return 0; | ||
1593 | } | ||
1594 | EXPORT_SYMBOL_GPL(sunvnet_change_mtu_common); | ||
1595 | |||
1596 | int sunvnet_set_mac_addr_common(struct net_device *dev, void *p) | 1586 | int sunvnet_set_mac_addr_common(struct net_device *dev, void *p) |
1597 | { | 1587 | { |
1598 | return -EINVAL; | 1588 | return -EINVAL; |
diff --git a/drivers/net/ethernet/sun/sunvnet_common.h b/drivers/net/ethernet/sun/sunvnet_common.h index bd36528af972..ce5c824128a3 100644 --- a/drivers/net/ethernet/sun/sunvnet_common.h +++ b/drivers/net/ethernet/sun/sunvnet_common.h | |||
@@ -15,6 +15,8 @@ | |||
15 | #define VNET_MINTSO 2048 /* VIO protocol's minimum TSO len */ | 15 | #define VNET_MINTSO 2048 /* VIO protocol's minimum TSO len */ |
16 | #define VNET_MAXTSO 65535 /* VIO protocol's maximum TSO len */ | 16 | #define VNET_MAXTSO 65535 /* VIO protocol's maximum TSO len */ |
17 | 17 | ||
18 | #define VNET_MAX_MTU 65535 | ||
19 | |||
18 | /* VNET packets are sent in buffers with the first 6 bytes skipped | 20 | /* VNET packets are sent in buffers with the first 6 bytes skipped |
19 | * so that after the ethernet header the IPv4/IPv6 headers are aligned | 21 | * so that after the ethernet header the IPv4/IPv6 headers are aligned |
20 | * properly. | 22 | * properly. |
@@ -125,7 +127,6 @@ int sunvnet_close_common(struct net_device *dev); | |||
125 | void sunvnet_set_rx_mode_common(struct net_device *dev, struct vnet *vp); | 127 | void sunvnet_set_rx_mode_common(struct net_device *dev, struct vnet *vp); |
126 | int sunvnet_set_mac_addr_common(struct net_device *dev, void *p); | 128 | int sunvnet_set_mac_addr_common(struct net_device *dev, void *p); |
127 | void sunvnet_tx_timeout_common(struct net_device *dev); | 129 | void sunvnet_tx_timeout_common(struct net_device *dev); |
128 | int sunvnet_change_mtu_common(struct net_device *dev, int new_mtu); | ||
129 | int sunvnet_start_xmit_common(struct sk_buff *skb, struct net_device *dev, | 130 | int sunvnet_start_xmit_common(struct sk_buff *skb, struct net_device *dev, |
130 | struct vnet_port *(*vnet_tx_port) | 131 | struct vnet_port *(*vnet_tx_port) |
131 | (struct sk_buff *, struct net_device *)); | 132 | (struct sk_buff *, struct net_device *)); |