]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ethernet/sun: use core min/max MTU checking
authorJarod Wilson <jarod@redhat.com>
Mon, 17 Oct 2016 19:54:10 +0000 (15:54 -0400)
committerDavid S. Miller <davem@davemloft.net>
Tue, 18 Oct 2016 15:34:20 +0000 (11:34 -0400)
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>
drivers/net/ethernet/sun/cassini.c
drivers/net/ethernet/sun/ldmvsw.c
drivers/net/ethernet/sun/niu.c
drivers/net/ethernet/sun/sungem.c
drivers/net/ethernet/sun/sunvnet.c
drivers/net/ethernet/sun/sunvnet_common.c
drivers/net/ethernet/sun/sunvnet_common.h

index 062bce9acde6f555794376cc25e24981033e0868..e9e5ef241c6f9f37bc14766611e21dee728088f9 100644 (file)
@@ -3863,9 +3863,6 @@ static int cas_change_mtu(struct net_device *dev, int new_mtu)
 {
        struct cas *cp = netdev_priv(dev);
 
-       if (new_mtu < CAS_MIN_MTU || new_mtu > CAS_MAX_MTU)
-               return -EINVAL;
-
        dev->mtu = new_mtu;
        if (!netif_running(dev) || !netif_device_present(dev))
                return 0;
@@ -5115,6 +5112,10 @@ static int cas_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
        if (pci_using_dac)
                dev->features |= NETIF_F_HIGHDMA;
 
+       /* MTU range: 60 - varies or 9000 */
+       dev->min_mtu = CAS_MIN_MTU;
+       dev->max_mtu = CAS_MAX_MTU;
+
        if (register_netdev(dev)) {
                dev_err(&pdev->dev, "Cannot register net device, aborting\n");
                goto err_out_free_consistent;
index 0ac449acaf5b734052ee3d4d2b98e90475148c9a..335b8766063807a42ae9a9cb0b82aa7ea396a809 100644 (file)
@@ -139,7 +139,6 @@ static const struct net_device_ops vsw_ops = {
        .ndo_set_mac_address    = sunvnet_set_mac_addr_common,
        .ndo_validate_addr      = eth_validate_addr,
        .ndo_tx_timeout         = sunvnet_tx_timeout_common,
-       .ndo_change_mtu         = sunvnet_change_mtu_common,
        .ndo_start_xmit         = vsw_start_xmit,
        .ndo_select_queue       = vsw_select_queue,
 #ifdef CONFIG_NET_POLL_CONTROLLER
@@ -239,6 +238,10 @@ static struct net_device *vsw_alloc_netdev(u8 hwaddr[],
                           NETIF_F_HW_CSUM | NETIF_F_SG;
        dev->features = dev->hw_features;
 
+       /* MTU range: 68 - 65535 */
+       dev->min_mtu = ETH_MIN_MTU;
+       dev->max_mtu = VNET_MAX_MTU;
+
        SET_NETDEV_DEV(dev, &vdev->dev);
 
        return dev;
index a2371aa14a49f840702b5867f5ad80f6b520ee16..f90d1af6d390654cec17a52572191df4ddc4b4ba 100644 (file)
@@ -6754,9 +6754,6 @@ static int niu_change_mtu(struct net_device *dev, int new_mtu)
        struct niu *np = netdev_priv(dev);
        int err, orig_jumbo, new_jumbo;
 
-       if (new_mtu < 68 || new_mtu > NIU_MAX_MTU)
-               return -EINVAL;
-
        orig_jumbo = (dev->mtu > ETH_DATA_LEN);
        new_jumbo = (new_mtu > ETH_DATA_LEN);
 
@@ -9823,6 +9820,10 @@ static int niu_pci_init_one(struct pci_dev *pdev,
 
        dev->irq = pdev->irq;
 
+       /* MTU range: 68 - 9216 */
+       dev->min_mtu = ETH_MIN_MTU;
+       dev->max_mtu = NIU_MAX_MTU;
+
        niu_assign_netdev_ops(dev);
 
        err = niu_get_invariants(np);
index d6ad0fbd054e10bf34d48d2f522b0660781de02d..66ecf0fcc3309f89b832770d3c7644871170c0fa 100644 (file)
@@ -2476,9 +2476,9 @@ static void gem_set_multicast(struct net_device *dev)
 }
 
 /* Jumbo-grams don't seem to work :-( */
-#define GEM_MIN_MTU    68
+#define GEM_MIN_MTU    ETH_MIN_MTU
 #if 1
-#define GEM_MAX_MTU    1500
+#define GEM_MAX_MTU    ETH_DATA_LEN
 #else
 #define GEM_MAX_MTU    9000
 #endif
@@ -2487,9 +2487,6 @@ static int gem_change_mtu(struct net_device *dev, int new_mtu)
 {
        struct gem *gp = netdev_priv(dev);
 
-       if (new_mtu < GEM_MIN_MTU || new_mtu > GEM_MAX_MTU)
-               return -EINVAL;
-
        dev->mtu = new_mtu;
 
        /* 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)
        if (pci_using_dac)
                dev->features |= NETIF_F_HIGHDMA;
 
+       /* MTU range: 68 - 1500 (Jumbo mode is broken) */
+       dev->min_mtu = GEM_MIN_MTU;
+       dev->max_mtu = GEM_MAX_MTU;
+
        /* Register with kernel */
        if (register_netdev(dev)) {
                pr_err("Cannot register net device, aborting\n");
index a2f9b47de1873110f6c2a3037de520105930afc3..5356a7074796caafe0ce30284dc859ab75a61e05 100644 (file)
@@ -159,7 +159,6 @@ static const struct net_device_ops vnet_ops = {
        .ndo_set_mac_address    = sunvnet_set_mac_addr_common,
        .ndo_validate_addr      = eth_validate_addr,
        .ndo_tx_timeout         = sunvnet_tx_timeout_common,
-       .ndo_change_mtu         = sunvnet_change_mtu_common,
        .ndo_start_xmit         = vnet_start_xmit,
        .ndo_select_queue       = vnet_select_queue,
 #ifdef CONFIG_NET_POLL_CONTROLLER
@@ -202,6 +201,10 @@ static struct vnet *vnet_new(const u64 *local_mac,
                           NETIF_F_HW_CSUM | NETIF_F_SG;
        dev->features = dev->hw_features;
 
+       /* MTU range: 68 - 65535 */
+       dev->min_mtu = ETH_MIN_MTU;
+       dev->max_mtu = VNET_MAX_MTU;
+
        SET_NETDEV_DEV(dev, &vdev->dev);
 
        err = register_netdev(dev);
index 904a5a12a85d0a8480f65a7f1ea2c109b3bcd8d3..58efe69b7ba7ea6b326d7082e70465ca57e2c24a 100644 (file)
@@ -1583,16 +1583,6 @@ void sunvnet_set_rx_mode_common(struct net_device *dev, struct vnet *vp)
 }
 EXPORT_SYMBOL_GPL(sunvnet_set_rx_mode_common);
 
-int sunvnet_change_mtu_common(struct net_device *dev, int new_mtu)
-{
-       if (new_mtu < 68 || new_mtu > 65535)
-               return -EINVAL;
-
-       dev->mtu = new_mtu;
-       return 0;
-}
-EXPORT_SYMBOL_GPL(sunvnet_change_mtu_common);
-
 int sunvnet_set_mac_addr_common(struct net_device *dev, void *p)
 {
        return -EINVAL;
index bd36528af97213adc2048b8c1e447840e3d52f46..ce5c824128a3698acb31ddbac42555657863b10f 100644 (file)
@@ -15,6 +15,8 @@
 #define        VNET_MINTSO      2048   /* VIO protocol's minimum TSO len */
 #define        VNET_MAXTSO     65535   /* VIO protocol's maximum TSO len */
 
+#define VNET_MAX_MTU   65535
+
 /* VNET packets are sent in buffers with the first 6 bytes skipped
  * so that after the ethernet header the IPv4/IPv6 headers are aligned
  * properly.
@@ -125,7 +127,6 @@ int sunvnet_close_common(struct net_device *dev);
 void sunvnet_set_rx_mode_common(struct net_device *dev, struct vnet *vp);
 int sunvnet_set_mac_addr_common(struct net_device *dev, void *p);
 void sunvnet_tx_timeout_common(struct net_device *dev);
-int sunvnet_change_mtu_common(struct net_device *dev, int new_mtu);
 int sunvnet_start_xmit_common(struct sk_buff *skb, struct net_device *dev,
                           struct vnet_port *(*vnet_tx_port)
                           (struct sk_buff *, struct net_device *));