diff options
Diffstat (limited to 'include/linux/netdevice.h')
-rw-r--r-- | include/linux/netdevice.h | 103 |
1 files changed, 51 insertions, 52 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 2d15e3831440..67bfac1abfc1 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h | |||
@@ -718,8 +718,8 @@ struct xps_map { | |||
718 | u16 queues[0]; | 718 | u16 queues[0]; |
719 | }; | 719 | }; |
720 | #define XPS_MAP_SIZE(_num) (sizeof(struct xps_map) + ((_num) * sizeof(u16))) | 720 | #define XPS_MAP_SIZE(_num) (sizeof(struct xps_map) + ((_num) * sizeof(u16))) |
721 | #define XPS_MIN_MAP_ALLOC ((L1_CACHE_BYTES - sizeof(struct xps_map)) \ | 721 | #define XPS_MIN_MAP_ALLOC ((L1_CACHE_ALIGN(offsetof(struct xps_map, queues[1])) \ |
722 | / sizeof(u16)) | 722 | - sizeof(struct xps_map)) / sizeof(u16)) |
723 | 723 | ||
724 | /* | 724 | /* |
725 | * This structure holds all XPS maps for device. Maps are indexed by CPU. | 725 | * This structure holds all XPS maps for device. Maps are indexed by CPU. |
@@ -881,6 +881,7 @@ typedef u16 (*select_queue_fallback_t)(struct net_device *dev, | |||
881 | * int (*ndo_set_vf_rate)(struct net_device *dev, int vf, int min_tx_rate, | 881 | * int (*ndo_set_vf_rate)(struct net_device *dev, int vf, int min_tx_rate, |
882 | * int max_tx_rate); | 882 | * int max_tx_rate); |
883 | * int (*ndo_set_vf_spoofchk)(struct net_device *dev, int vf, bool setting); | 883 | * int (*ndo_set_vf_spoofchk)(struct net_device *dev, int vf, bool setting); |
884 | * int (*ndo_set_vf_trust)(struct net_device *dev, int vf, bool setting); | ||
884 | * int (*ndo_get_vf_config)(struct net_device *dev, | 885 | * int (*ndo_get_vf_config)(struct net_device *dev, |
885 | * int vf, struct ifla_vf_info *ivf); | 886 | * int vf, struct ifla_vf_info *ivf); |
886 | * int (*ndo_set_vf_link_state)(struct net_device *dev, int vf, int link_state); | 887 | * int (*ndo_set_vf_link_state)(struct net_device *dev, int vf, int link_state); |
@@ -1054,6 +1055,10 @@ typedef u16 (*select_queue_fallback_t)(struct net_device *dev, | |||
1054 | * This function is used to pass protocol port error state information | 1055 | * This function is used to pass protocol port error state information |
1055 | * to the switch driver. The switch driver can react to the proto_down | 1056 | * to the switch driver. The switch driver can react to the proto_down |
1056 | * by doing a phys down on the associated switch port. | 1057 | * by doing a phys down on the associated switch port. |
1058 | * int (*ndo_fill_metadata_dst)(struct net_device *dev, struct sk_buff *skb); | ||
1059 | * This function is used to get egress tunnel information for given skb. | ||
1060 | * This is useful for retrieving outer tunnel header parameters while | ||
1061 | * sampling packet. | ||
1057 | * | 1062 | * |
1058 | */ | 1063 | */ |
1059 | struct net_device_ops { | 1064 | struct net_device_ops { |
@@ -1109,6 +1114,8 @@ struct net_device_ops { | |||
1109 | int max_tx_rate); | 1114 | int max_tx_rate); |
1110 | int (*ndo_set_vf_spoofchk)(struct net_device *dev, | 1115 | int (*ndo_set_vf_spoofchk)(struct net_device *dev, |
1111 | int vf, bool setting); | 1116 | int vf, bool setting); |
1117 | int (*ndo_set_vf_trust)(struct net_device *dev, | ||
1118 | int vf, bool setting); | ||
1112 | int (*ndo_get_vf_config)(struct net_device *dev, | 1119 | int (*ndo_get_vf_config)(struct net_device *dev, |
1113 | int vf, | 1120 | int vf, |
1114 | struct ifla_vf_info *ivf); | 1121 | struct ifla_vf_info *ivf); |
@@ -1227,6 +1234,8 @@ struct net_device_ops { | |||
1227 | int (*ndo_get_iflink)(const struct net_device *dev); | 1234 | int (*ndo_get_iflink)(const struct net_device *dev); |
1228 | int (*ndo_change_proto_down)(struct net_device *dev, | 1235 | int (*ndo_change_proto_down)(struct net_device *dev, |
1229 | bool proto_down); | 1236 | bool proto_down); |
1237 | int (*ndo_fill_metadata_dst)(struct net_device *dev, | ||
1238 | struct sk_buff *skb); | ||
1230 | }; | 1239 | }; |
1231 | 1240 | ||
1232 | /** | 1241 | /** |
@@ -1258,9 +1267,10 @@ struct net_device_ops { | |||
1258 | * @IFF_LIVE_ADDR_CHANGE: device supports hardware address | 1267 | * @IFF_LIVE_ADDR_CHANGE: device supports hardware address |
1259 | * change when it's running | 1268 | * change when it's running |
1260 | * @IFF_MACVLAN: Macvlan device | 1269 | * @IFF_MACVLAN: Macvlan device |
1261 | * @IFF_VRF_MASTER: device is a VRF master | 1270 | * @IFF_L3MDEV_MASTER: device is an L3 master device |
1262 | * @IFF_NO_QUEUE: device can run without qdisc attached | 1271 | * @IFF_NO_QUEUE: device can run without qdisc attached |
1263 | * @IFF_OPENVSWITCH: device is a Open vSwitch master | 1272 | * @IFF_OPENVSWITCH: device is a Open vSwitch master |
1273 | * @IFF_L3MDEV_SLAVE: device is enslaved to an L3 master device | ||
1264 | */ | 1274 | */ |
1265 | enum netdev_priv_flags { | 1275 | enum netdev_priv_flags { |
1266 | IFF_802_1Q_VLAN = 1<<0, | 1276 | IFF_802_1Q_VLAN = 1<<0, |
@@ -1283,9 +1293,10 @@ enum netdev_priv_flags { | |||
1283 | IFF_XMIT_DST_RELEASE_PERM = 1<<17, | 1293 | IFF_XMIT_DST_RELEASE_PERM = 1<<17, |
1284 | IFF_IPVLAN_MASTER = 1<<18, | 1294 | IFF_IPVLAN_MASTER = 1<<18, |
1285 | IFF_IPVLAN_SLAVE = 1<<19, | 1295 | IFF_IPVLAN_SLAVE = 1<<19, |
1286 | IFF_VRF_MASTER = 1<<20, | 1296 | IFF_L3MDEV_MASTER = 1<<20, |
1287 | IFF_NO_QUEUE = 1<<21, | 1297 | IFF_NO_QUEUE = 1<<21, |
1288 | IFF_OPENVSWITCH = 1<<22, | 1298 | IFF_OPENVSWITCH = 1<<22, |
1299 | IFF_L3MDEV_SLAVE = 1<<23, | ||
1289 | }; | 1300 | }; |
1290 | 1301 | ||
1291 | #define IFF_802_1Q_VLAN IFF_802_1Q_VLAN | 1302 | #define IFF_802_1Q_VLAN IFF_802_1Q_VLAN |
@@ -1308,9 +1319,10 @@ enum netdev_priv_flags { | |||
1308 | #define IFF_XMIT_DST_RELEASE_PERM IFF_XMIT_DST_RELEASE_PERM | 1319 | #define IFF_XMIT_DST_RELEASE_PERM IFF_XMIT_DST_RELEASE_PERM |
1309 | #define IFF_IPVLAN_MASTER IFF_IPVLAN_MASTER | 1320 | #define IFF_IPVLAN_MASTER IFF_IPVLAN_MASTER |
1310 | #define IFF_IPVLAN_SLAVE IFF_IPVLAN_SLAVE | 1321 | #define IFF_IPVLAN_SLAVE IFF_IPVLAN_SLAVE |
1311 | #define IFF_VRF_MASTER IFF_VRF_MASTER | 1322 | #define IFF_L3MDEV_MASTER IFF_L3MDEV_MASTER |
1312 | #define IFF_NO_QUEUE IFF_NO_QUEUE | 1323 | #define IFF_NO_QUEUE IFF_NO_QUEUE |
1313 | #define IFF_OPENVSWITCH IFF_OPENVSWITCH | 1324 | #define IFF_OPENVSWITCH IFF_OPENVSWITCH |
1325 | #define IFF_L3MDEV_SLAVE IFF_L3MDEV_SLAVE | ||
1314 | 1326 | ||
1315 | /** | 1327 | /** |
1316 | * struct net_device - The DEVICE structure. | 1328 | * struct net_device - The DEVICE structure. |
@@ -1427,7 +1439,6 @@ enum netdev_priv_flags { | |||
1427 | * @dn_ptr: DECnet specific data | 1439 | * @dn_ptr: DECnet specific data |
1428 | * @ip6_ptr: IPv6 specific data | 1440 | * @ip6_ptr: IPv6 specific data |
1429 | * @ax25_ptr: AX.25 specific data | 1441 | * @ax25_ptr: AX.25 specific data |
1430 | * @vrf_ptr: VRF specific data | ||
1431 | * @ieee80211_ptr: IEEE 802.11 specific data, assign before registering | 1442 | * @ieee80211_ptr: IEEE 802.11 specific data, assign before registering |
1432 | * | 1443 | * |
1433 | * @last_rx: Time of last Rx | 1444 | * @last_rx: Time of last Rx |
@@ -1587,6 +1598,9 @@ struct net_device { | |||
1587 | #ifdef CONFIG_NET_SWITCHDEV | 1598 | #ifdef CONFIG_NET_SWITCHDEV |
1588 | const struct switchdev_ops *switchdev_ops; | 1599 | const struct switchdev_ops *switchdev_ops; |
1589 | #endif | 1600 | #endif |
1601 | #ifdef CONFIG_NET_L3_MASTER_DEV | ||
1602 | const struct l3mdev_ops *l3mdev_ops; | ||
1603 | #endif | ||
1590 | 1604 | ||
1591 | const struct header_ops *header_ops; | 1605 | const struct header_ops *header_ops; |
1592 | 1606 | ||
@@ -1646,7 +1660,6 @@ struct net_device { | |||
1646 | struct dn_dev __rcu *dn_ptr; | 1660 | struct dn_dev __rcu *dn_ptr; |
1647 | struct inet6_dev __rcu *ip6_ptr; | 1661 | struct inet6_dev __rcu *ip6_ptr; |
1648 | void *ax25_ptr; | 1662 | void *ax25_ptr; |
1649 | struct net_vrf_dev __rcu *vrf_ptr; | ||
1650 | struct wireless_dev *ieee80211_ptr; | 1663 | struct wireless_dev *ieee80211_ptr; |
1651 | struct wpan_dev *ieee802154_ptr; | 1664 | struct wpan_dev *ieee802154_ptr; |
1652 | #if IS_ENABLED(CONFIG_MPLS_ROUTING) | 1665 | #if IS_ENABLED(CONFIG_MPLS_ROUTING) |
@@ -2055,20 +2068,23 @@ struct pcpu_sw_netstats { | |||
2055 | struct u64_stats_sync syncp; | 2068 | struct u64_stats_sync syncp; |
2056 | }; | 2069 | }; |
2057 | 2070 | ||
2058 | #define netdev_alloc_pcpu_stats(type) \ | 2071 | #define __netdev_alloc_pcpu_stats(type, gfp) \ |
2059 | ({ \ | 2072 | ({ \ |
2060 | typeof(type) __percpu *pcpu_stats = alloc_percpu(type); \ | 2073 | typeof(type) __percpu *pcpu_stats = alloc_percpu_gfp(type, gfp);\ |
2061 | if (pcpu_stats) { \ | 2074 | if (pcpu_stats) { \ |
2062 | int __cpu; \ | 2075 | int __cpu; \ |
2063 | for_each_possible_cpu(__cpu) { \ | 2076 | for_each_possible_cpu(__cpu) { \ |
2064 | typeof(type) *stat; \ | 2077 | typeof(type) *stat; \ |
2065 | stat = per_cpu_ptr(pcpu_stats, __cpu); \ | 2078 | stat = per_cpu_ptr(pcpu_stats, __cpu); \ |
2066 | u64_stats_init(&stat->syncp); \ | 2079 | u64_stats_init(&stat->syncp); \ |
2067 | } \ | 2080 | } \ |
2068 | } \ | 2081 | } \ |
2069 | pcpu_stats; \ | 2082 | pcpu_stats; \ |
2070 | }) | 2083 | }) |
2071 | 2084 | ||
2085 | #define netdev_alloc_pcpu_stats(type) \ | ||
2086 | __netdev_alloc_pcpu_stats(type, GFP_KERNEL); | ||
2087 | |||
2072 | #include <linux/notifier.h> | 2088 | #include <linux/notifier.h> |
2073 | 2089 | ||
2074 | /* netdevice notifier chain. Please remember to update the rtnetlink | 2090 | /* netdevice notifier chain. Please remember to update the rtnetlink |
@@ -2103,6 +2119,7 @@ struct pcpu_sw_netstats { | |||
2103 | #define NETDEV_PRECHANGEMTU 0x0017 /* notify before mtu change happened */ | 2119 | #define NETDEV_PRECHANGEMTU 0x0017 /* notify before mtu change happened */ |
2104 | #define NETDEV_CHANGEINFODATA 0x0018 | 2120 | #define NETDEV_CHANGEINFODATA 0x0018 |
2105 | #define NETDEV_BONDING_INFO 0x0019 | 2121 | #define NETDEV_BONDING_INFO 0x0019 |
2122 | #define NETDEV_PRECHANGEUPPER 0x001A | ||
2106 | 2123 | ||
2107 | int register_netdevice_notifier(struct notifier_block *nb); | 2124 | int register_netdevice_notifier(struct notifier_block *nb); |
2108 | int unregister_netdevice_notifier(struct notifier_block *nb); | 2125 | int unregister_netdevice_notifier(struct notifier_block *nb); |
@@ -2203,6 +2220,7 @@ void dev_add_offload(struct packet_offload *po); | |||
2203 | void dev_remove_offload(struct packet_offload *po); | 2220 | void dev_remove_offload(struct packet_offload *po); |
2204 | 2221 | ||
2205 | int dev_get_iflink(const struct net_device *dev); | 2222 | int dev_get_iflink(const struct net_device *dev); |
2223 | int dev_fill_metadata_dst(struct net_device *dev, struct sk_buff *skb); | ||
2206 | struct net_device *__dev_get_by_flags(struct net *net, unsigned short flags, | 2224 | struct net_device *__dev_get_by_flags(struct net *net, unsigned short flags, |
2207 | unsigned short mask); | 2225 | unsigned short mask); |
2208 | struct net_device *dev_get_by_name(struct net *net, const char *name); | 2226 | struct net_device *dev_get_by_name(struct net *net, const char *name); |
@@ -2213,12 +2231,8 @@ int dev_open(struct net_device *dev); | |||
2213 | int dev_close(struct net_device *dev); | 2231 | int dev_close(struct net_device *dev); |
2214 | int dev_close_many(struct list_head *head, bool unlink); | 2232 | int dev_close_many(struct list_head *head, bool unlink); |
2215 | void dev_disable_lro(struct net_device *dev); | 2233 | void dev_disable_lro(struct net_device *dev); |
2216 | int dev_loopback_xmit(struct sock *sk, struct sk_buff *newskb); | 2234 | int dev_loopback_xmit(struct net *net, struct sock *sk, struct sk_buff *newskb); |
2217 | int dev_queue_xmit_sk(struct sock *sk, struct sk_buff *skb); | 2235 | int dev_queue_xmit(struct sk_buff *skb); |
2218 | static inline int dev_queue_xmit(struct sk_buff *skb) | ||
2219 | { | ||
2220 | return dev_queue_xmit_sk(skb->sk, skb); | ||
2221 | } | ||
2222 | int dev_queue_xmit_accel(struct sk_buff *skb, void *accel_priv); | 2236 | int dev_queue_xmit_accel(struct sk_buff *skb, void *accel_priv); |
2223 | int register_netdevice(struct net_device *dev); | 2237 | int register_netdevice(struct net_device *dev); |
2224 | void unregister_netdevice_queue(struct net_device *dev, struct list_head *head); | 2238 | void unregister_netdevice_queue(struct net_device *dev, struct list_head *head); |
@@ -2990,11 +3004,7 @@ static inline void dev_consume_skb_any(struct sk_buff *skb) | |||
2990 | 3004 | ||
2991 | int netif_rx(struct sk_buff *skb); | 3005 | int netif_rx(struct sk_buff *skb); |
2992 | int netif_rx_ni(struct sk_buff *skb); | 3006 | int netif_rx_ni(struct sk_buff *skb); |
2993 | int netif_receive_skb_sk(struct sock *sk, struct sk_buff *skb); | 3007 | int netif_receive_skb(struct sk_buff *skb); |
2994 | static inline int netif_receive_skb(struct sk_buff *skb) | ||
2995 | { | ||
2996 | return netif_receive_skb_sk(skb->sk, skb); | ||
2997 | } | ||
2998 | gro_result_t napi_gro_receive(struct napi_struct *napi, struct sk_buff *skb); | 3008 | gro_result_t napi_gro_receive(struct napi_struct *napi, struct sk_buff *skb); |
2999 | void napi_gro_flush(struct napi_struct *napi, bool flush_old); | 3009 | void napi_gro_flush(struct napi_struct *napi, bool flush_old); |
3000 | struct sk_buff *napi_get_frags(struct napi_struct *napi); | 3010 | struct sk_buff *napi_get_frags(struct napi_struct *napi); |
@@ -3832,9 +3842,14 @@ static inline bool netif_supports_nofcs(struct net_device *dev) | |||
3832 | return dev->priv_flags & IFF_SUPP_NOFCS; | 3842 | return dev->priv_flags & IFF_SUPP_NOFCS; |
3833 | } | 3843 | } |
3834 | 3844 | ||
3835 | static inline bool netif_is_vrf(const struct net_device *dev) | 3845 | static inline bool netif_is_l3_master(const struct net_device *dev) |
3846 | { | ||
3847 | return dev->priv_flags & IFF_L3MDEV_MASTER; | ||
3848 | } | ||
3849 | |||
3850 | static inline bool netif_is_l3_slave(const struct net_device *dev) | ||
3836 | { | 3851 | { |
3837 | return dev->priv_flags & IFF_VRF_MASTER; | 3852 | return dev->priv_flags & IFF_L3MDEV_SLAVE; |
3838 | } | 3853 | } |
3839 | 3854 | ||
3840 | static inline bool netif_is_bridge_master(const struct net_device *dev) | 3855 | static inline bool netif_is_bridge_master(const struct net_device *dev) |
@@ -3842,30 +3857,14 @@ static inline bool netif_is_bridge_master(const struct net_device *dev) | |||
3842 | return dev->priv_flags & IFF_EBRIDGE; | 3857 | return dev->priv_flags & IFF_EBRIDGE; |
3843 | } | 3858 | } |
3844 | 3859 | ||
3845 | static inline bool netif_is_ovs_master(const struct net_device *dev) | 3860 | static inline bool netif_is_bridge_port(const struct net_device *dev) |
3846 | { | 3861 | { |
3847 | return dev->priv_flags & IFF_OPENVSWITCH; | 3862 | return dev->priv_flags & IFF_BRIDGE_PORT; |
3848 | } | 3863 | } |
3849 | 3864 | ||
3850 | static inline bool netif_index_is_vrf(struct net *net, int ifindex) | 3865 | static inline bool netif_is_ovs_master(const struct net_device *dev) |
3851 | { | 3866 | { |
3852 | bool rc = false; | 3867 | return dev->priv_flags & IFF_OPENVSWITCH; |
3853 | |||
3854 | #if IS_ENABLED(CONFIG_NET_VRF) | ||
3855 | struct net_device *dev; | ||
3856 | |||
3857 | if (ifindex == 0) | ||
3858 | return false; | ||
3859 | |||
3860 | rcu_read_lock(); | ||
3861 | |||
3862 | dev = dev_get_by_index_rcu(net, ifindex); | ||
3863 | if (dev) | ||
3864 | rc = netif_is_vrf(dev); | ||
3865 | |||
3866 | rcu_read_unlock(); | ||
3867 | #endif | ||
3868 | return rc; | ||
3869 | } | 3868 | } |
3870 | 3869 | ||
3871 | /* This device needs to keep skb dst for qdisc enqueue or ndo_start_xmit() */ | 3870 | /* This device needs to keep skb dst for qdisc enqueue or ndo_start_xmit() */ |