macvlan.c (0898782247ae533d1f4e47a06bc5d4870931b284) macvlan.c (ab92d68fc22f9afab480153bd82a20f6e2533769)
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * Copyright (c) 2007 Patrick McHardy <kaber@trash.net>
4 *
5 * The code this is based on carried the following copyright notice:
6 * ---
7 * (C) Copyright 2001-2006
8 * Alex Zeffertt, Cambridge Broadband Ltd, ajz@cambridgebroadband.com

--- 838 unchanged lines hidden (view full) ---

847 return err;
848}
849
850/*
851 * macvlan network devices have devices nesting below it and are a special
852 * "super class" of normal network devices; split their locks off into a
853 * separate class since they always nest.
854 */
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * Copyright (c) 2007 Patrick McHardy <kaber@trash.net>
4 *
5 * The code this is based on carried the following copyright notice:
6 * ---
7 * (C) Copyright 2001-2006
8 * Alex Zeffertt, Cambridge Broadband Ltd, ajz@cambridgebroadband.com

--- 838 unchanged lines hidden (view full) ---

847 return err;
848}
849
850/*
851 * macvlan network devices have devices nesting below it and are a special
852 * "super class" of normal network devices; split their locks off into a
853 * separate class since they always nest.
854 */
855static struct lock_class_key macvlan_netdev_addr_lock_key;
856
857#define ALWAYS_ON_OFFLOADS \
858 (NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_GSO_SOFTWARE | \
859 NETIF_F_GSO_ROBUST | NETIF_F_GSO_ENCAP_ALL)
860
861#define ALWAYS_ON_FEATURES (ALWAYS_ON_OFFLOADS | NETIF_F_LLTX)
862
863#define MACVLAN_FEATURES \
864 (NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_HIGHDMA | NETIF_F_FRAGLIST | \

--- 4 unchanged lines hidden (view full) ---

869#define MACVLAN_STATE_MASK \
870 ((1<<__LINK_STATE_NOCARRIER) | (1<<__LINK_STATE_DORMANT))
871
872static int macvlan_get_nest_level(struct net_device *dev)
873{
874 return ((struct macvlan_dev *)netdev_priv(dev))->nest_level;
875}
876
855#define ALWAYS_ON_OFFLOADS \
856 (NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_GSO_SOFTWARE | \
857 NETIF_F_GSO_ROBUST | NETIF_F_GSO_ENCAP_ALL)
858
859#define ALWAYS_ON_FEATURES (ALWAYS_ON_OFFLOADS | NETIF_F_LLTX)
860
861#define MACVLAN_FEATURES \
862 (NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_HIGHDMA | NETIF_F_FRAGLIST | \

--- 4 unchanged lines hidden (view full) ---

867#define MACVLAN_STATE_MASK \
868 ((1<<__LINK_STATE_NOCARRIER) | (1<<__LINK_STATE_DORMANT))
869
870static int macvlan_get_nest_level(struct net_device *dev)
871{
872 return ((struct macvlan_dev *)netdev_priv(dev))->nest_level;
873}
874
877static void macvlan_set_lockdep_class(struct net_device *dev)
878{
879 netdev_lockdep_set_classes(dev);
880 lockdep_set_class_and_subclass(&dev->addr_list_lock,
881 &macvlan_netdev_addr_lock_key,
882 macvlan_get_nest_level(dev));
883}
884
885static int macvlan_init(struct net_device *dev)
886{
887 struct macvlan_dev *vlan = netdev_priv(dev);
888 const struct net_device *lowerdev = vlan->lowerdev;
889 struct macvlan_port *port = vlan->port;
890
891 dev->state = (dev->state & ~MACVLAN_STATE_MASK) |
892 (lowerdev->state & MACVLAN_STATE_MASK);
893 dev->features = lowerdev->features & MACVLAN_FEATURES;
894 dev->features |= ALWAYS_ON_FEATURES;
895 dev->hw_features |= NETIF_F_LRO;
896 dev->vlan_features = lowerdev->vlan_features & MACVLAN_FEATURES;
897 dev->vlan_features |= ALWAYS_ON_OFFLOADS;
898 dev->hw_enc_features |= dev->features;
899 dev->gso_max_size = lowerdev->gso_max_size;
900 dev->gso_max_segs = lowerdev->gso_max_segs;
901 dev->hard_header_len = lowerdev->hard_header_len;
902
875static int macvlan_init(struct net_device *dev)
876{
877 struct macvlan_dev *vlan = netdev_priv(dev);
878 const struct net_device *lowerdev = vlan->lowerdev;
879 struct macvlan_port *port = vlan->port;
880
881 dev->state = (dev->state & ~MACVLAN_STATE_MASK) |
882 (lowerdev->state & MACVLAN_STATE_MASK);
883 dev->features = lowerdev->features & MACVLAN_FEATURES;
884 dev->features |= ALWAYS_ON_FEATURES;
885 dev->hw_features |= NETIF_F_LRO;
886 dev->vlan_features = lowerdev->vlan_features & MACVLAN_FEATURES;
887 dev->vlan_features |= ALWAYS_ON_OFFLOADS;
888 dev->hw_enc_features |= dev->features;
889 dev->gso_max_size = lowerdev->gso_max_size;
890 dev->gso_max_segs = lowerdev->gso_max_segs;
891 dev->hard_header_len = lowerdev->hard_header_len;
892
903 macvlan_set_lockdep_class(dev);
904
905 vlan->pcpu_stats = netdev_alloc_pcpu_stats(struct vlan_pcpu_stats);
906 if (!vlan->pcpu_stats)
907 return -ENOMEM;
908
909 port->count += 1;
910
911 return 0;
912}

--- 868 unchanged lines hidden ---
893 vlan->pcpu_stats = netdev_alloc_pcpu_stats(struct vlan_pcpu_stats);
894 if (!vlan->pcpu_stats)
895 return -ENOMEM;
896
897 port->count += 1;
898
899 return 0;
900}

--- 868 unchanged lines hidden ---