aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/netdevice.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/netdevice.h')
-rw-r--r--include/linux/netdevice.h172
1 files changed, 131 insertions, 41 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index c31f74d76ebd..5897b4ea5a3f 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -51,6 +51,7 @@
51#include <linux/netdev_features.h> 51#include <linux/netdev_features.h>
52#include <linux/neighbour.h> 52#include <linux/neighbour.h>
53#include <uapi/linux/netdevice.h> 53#include <uapi/linux/netdevice.h>
54#include <uapi/linux/if_bonding.h>
54 55
55struct netpoll_info; 56struct netpoll_info;
56struct device; 57struct device;
@@ -643,39 +644,40 @@ struct rps_dev_flow_table {
643/* 644/*
644 * The rps_sock_flow_table contains mappings of flows to the last CPU 645 * The rps_sock_flow_table contains mappings of flows to the last CPU
645 * on which they were processed by the application (set in recvmsg). 646 * on which they were processed by the application (set in recvmsg).
647 * Each entry is a 32bit value. Upper part is the high order bits
648 * of flow hash, lower part is cpu number.
649 * rps_cpu_mask is used to partition the space, depending on number of
650 * possible cpus : rps_cpu_mask = roundup_pow_of_two(nr_cpu_ids) - 1
651 * For example, if 64 cpus are possible, rps_cpu_mask = 0x3f,
652 * meaning we use 32-6=26 bits for the hash.
646 */ 653 */
647struct rps_sock_flow_table { 654struct rps_sock_flow_table {
648 unsigned int mask; 655 u32 mask;
649 u16 ents[0]; 656
657 u32 ents[0] ____cacheline_aligned_in_smp;
650}; 658};
651#define RPS_SOCK_FLOW_TABLE_SIZE(_num) (sizeof(struct rps_sock_flow_table) + \ 659#define RPS_SOCK_FLOW_TABLE_SIZE(_num) (offsetof(struct rps_sock_flow_table, ents[_num]))
652 ((_num) * sizeof(u16)))
653 660
654#define RPS_NO_CPU 0xffff 661#define RPS_NO_CPU 0xffff
655 662
663extern u32 rps_cpu_mask;
664extern struct rps_sock_flow_table __rcu *rps_sock_flow_table;
665
656static inline void rps_record_sock_flow(struct rps_sock_flow_table *table, 666static inline void rps_record_sock_flow(struct rps_sock_flow_table *table,
657 u32 hash) 667 u32 hash)
658{ 668{
659 if (table && hash) { 669 if (table && hash) {
660 unsigned int cpu, index = hash & table->mask; 670 unsigned int index = hash & table->mask;
671 u32 val = hash & ~rps_cpu_mask;
661 672
662 /* We only give a hint, preemption can change cpu under us */ 673 /* We only give a hint, preemption can change cpu under us */
663 cpu = raw_smp_processor_id(); 674 val |= raw_smp_processor_id();
664 675
665 if (table->ents[index] != cpu) 676 if (table->ents[index] != val)
666 table->ents[index] = cpu; 677 table->ents[index] = val;
667 } 678 }
668} 679}
669 680
670static inline void rps_reset_sock_flow(struct rps_sock_flow_table *table,
671 u32 hash)
672{
673 if (table && hash)
674 table->ents[hash & table->mask] = RPS_NO_CPU;
675}
676
677extern struct rps_sock_flow_table __rcu *rps_sock_flow_table;
678
679#ifdef CONFIG_RFS_ACCEL 681#ifdef CONFIG_RFS_ACCEL
680bool rps_may_expire_flow(struct net_device *dev, u16 rxq_index, u32 flow_id, 682bool rps_may_expire_flow(struct net_device *dev, u16 rxq_index, u32 flow_id,
681 u16 filter_id); 683 u16 filter_id);
@@ -852,11 +854,11 @@ typedef u16 (*select_queue_fallback_t)(struct net_device *dev,
852 * 3. Update dev->stats asynchronously and atomically, and define 854 * 3. Update dev->stats asynchronously and atomically, and define
853 * neither operation. 855 * neither operation.
854 * 856 *
855 * int (*ndo_vlan_rx_add_vid)(struct net_device *dev, __be16 proto, u16t vid); 857 * int (*ndo_vlan_rx_add_vid)(struct net_device *dev, __be16 proto, u16 vid);
856 * If device support VLAN filtering this function is called when a 858 * If device support VLAN filtering this function is called when a
857 * VLAN id is registered. 859 * VLAN id is registered.
858 * 860 *
859 * int (*ndo_vlan_rx_kill_vid)(struct net_device *dev, unsigned short vid); 861 * int (*ndo_vlan_rx_kill_vid)(struct net_device *dev, __be16 proto, u16 vid);
860 * If device support VLAN filtering this function is called when a 862 * If device support VLAN filtering this function is called when a
861 * VLAN id is unregistered. 863 * VLAN id is unregistered.
862 * 864 *
@@ -1012,12 +1014,15 @@ typedef u16 (*select_queue_fallback_t)(struct net_device *dev,
1012 * Callback to use for xmit over the accelerated station. This 1014 * Callback to use for xmit over the accelerated station. This
1013 * is used in place of ndo_start_xmit on accelerated net 1015 * is used in place of ndo_start_xmit on accelerated net
1014 * devices. 1016 * devices.
1015 * bool (*ndo_gso_check) (struct sk_buff *skb, 1017 * netdev_features_t (*ndo_features_check) (struct sk_buff *skb,
1016 * struct net_device *dev); 1018 * struct net_device *dev
1019 * netdev_features_t features);
1017 * Called by core transmit path to determine if device is capable of 1020 * Called by core transmit path to determine if device is capable of
1018 * performing GSO on a packet. The device returns true if it is 1021 * performing offload operations on a given packet. This is to give
1019 * able to GSO the packet, false otherwise. If the return value is 1022 * the device an opportunity to implement any restrictions that cannot
1020 * false the stack will do software GSO. 1023 * be otherwise expressed by feature flags. The check is called with
1024 * the set of features that the stack has calculated and it returns
1025 * those the driver believes to be appropriate.
1021 * 1026 *
1022 * int (*ndo_switch_parent_id_get)(struct net_device *dev, 1027 * int (*ndo_switch_parent_id_get)(struct net_device *dev,
1023 * struct netdev_phys_item_id *psid); 1028 * struct netdev_phys_item_id *psid);
@@ -1151,13 +1156,15 @@ struct net_device_ops {
1151 int idx); 1156 int idx);
1152 1157
1153 int (*ndo_bridge_setlink)(struct net_device *dev, 1158 int (*ndo_bridge_setlink)(struct net_device *dev,
1154 struct nlmsghdr *nlh); 1159 struct nlmsghdr *nlh,
1160 u16 flags);
1155 int (*ndo_bridge_getlink)(struct sk_buff *skb, 1161 int (*ndo_bridge_getlink)(struct sk_buff *skb,
1156 u32 pid, u32 seq, 1162 u32 pid, u32 seq,
1157 struct net_device *dev, 1163 struct net_device *dev,
1158 u32 filter_mask); 1164 u32 filter_mask);
1159 int (*ndo_bridge_dellink)(struct net_device *dev, 1165 int (*ndo_bridge_dellink)(struct net_device *dev,
1160 struct nlmsghdr *nlh); 1166 struct nlmsghdr *nlh,
1167 u16 flags);
1161 int (*ndo_change_carrier)(struct net_device *dev, 1168 int (*ndo_change_carrier)(struct net_device *dev,
1162 bool new_carrier); 1169 bool new_carrier);
1163 int (*ndo_get_phys_port_id)(struct net_device *dev, 1170 int (*ndo_get_phys_port_id)(struct net_device *dev,
@@ -1178,8 +1185,9 @@ struct net_device_ops {
1178 struct net_device *dev, 1185 struct net_device *dev,
1179 void *priv); 1186 void *priv);
1180 int (*ndo_get_lock_subclass)(struct net_device *dev); 1187 int (*ndo_get_lock_subclass)(struct net_device *dev);
1181 bool (*ndo_gso_check) (struct sk_buff *skb, 1188 netdev_features_t (*ndo_features_check) (struct sk_buff *skb,
1182 struct net_device *dev); 1189 struct net_device *dev,
1190 netdev_features_t features);
1183#ifdef CONFIG_NET_SWITCHDEV 1191#ifdef CONFIG_NET_SWITCHDEV
1184 int (*ndo_switch_parent_id_get)(struct net_device *dev, 1192 int (*ndo_switch_parent_id_get)(struct net_device *dev,
1185 struct netdev_phys_item_id *psid); 1193 struct netdev_phys_item_id *psid);
@@ -1510,6 +1518,8 @@ struct net_device {
1510 struct list_head napi_list; 1518 struct list_head napi_list;
1511 struct list_head unreg_list; 1519 struct list_head unreg_list;
1512 struct list_head close_list; 1520 struct list_head close_list;
1521 struct list_head ptype_all;
1522 struct list_head ptype_specific;
1513 1523
1514 struct { 1524 struct {
1515 struct list_head upper; 1525 struct list_head upper;
@@ -1913,13 +1923,8 @@ struct napi_gro_cb {
1913 /* Number of segments aggregated. */ 1923 /* Number of segments aggregated. */
1914 u16 count; 1924 u16 count;
1915 1925
1916 /* This is non-zero if the packet may be of the same flow. */ 1926 /* Start offset for remote checksum offload */
1917 u8 same_flow; 1927 u16 gro_remcsum_start;
1918
1919 /* Free the skb? */
1920 u8 free;
1921#define NAPI_GRO_FREE 1
1922#define NAPI_GRO_FREE_STOLEN_HEAD 2
1923 1928
1924 /* jiffies when first packet was created/queued */ 1929 /* jiffies when first packet was created/queued */
1925 unsigned long age; 1930 unsigned long age;
@@ -1927,6 +1932,9 @@ struct napi_gro_cb {
1927 /* Used in ipv6_gro_receive() and foo-over-udp */ 1932 /* Used in ipv6_gro_receive() and foo-over-udp */
1928 u16 proto; 1933 u16 proto;
1929 1934
1935 /* This is non-zero if the packet may be of the same flow. */
1936 u8 same_flow:1;
1937
1930 /* Used in udp_gro_receive */ 1938 /* Used in udp_gro_receive */
1931 u8 udp_mark:1; 1939 u8 udp_mark:1;
1932 1940
@@ -1936,9 +1944,16 @@ struct napi_gro_cb {
1936 /* Number of checksums via CHECKSUM_UNNECESSARY */ 1944 /* Number of checksums via CHECKSUM_UNNECESSARY */
1937 u8 csum_cnt:3; 1945 u8 csum_cnt:3;
1938 1946
1947 /* Free the skb? */
1948 u8 free:2;
1949#define NAPI_GRO_FREE 1
1950#define NAPI_GRO_FREE_STOLEN_HEAD 2
1951
1939 /* Used in foo-over-udp, set in udp[46]_gro_receive */ 1952 /* Used in foo-over-udp, set in udp[46]_gro_receive */
1940 u8 is_ipv6:1; 1953 u8 is_ipv6:1;
1941 1954
1955 /* 7 bit hole */
1956
1942 /* used to support CHECKSUM_COMPLETE for tunneling protocols */ 1957 /* used to support CHECKSUM_COMPLETE for tunneling protocols */
1943 __wsum csum; 1958 __wsum csum;
1944 1959
@@ -1965,7 +1980,7 @@ struct offload_callbacks {
1965 struct sk_buff *(*gso_segment)(struct sk_buff *skb, 1980 struct sk_buff *(*gso_segment)(struct sk_buff *skb,
1966 netdev_features_t features); 1981 netdev_features_t features);
1967 struct sk_buff **(*gro_receive)(struct sk_buff **head, 1982 struct sk_buff **(*gro_receive)(struct sk_buff **head,
1968 struct sk_buff *skb); 1983 struct sk_buff *skb);
1969 int (*gro_complete)(struct sk_buff *skb, int nhoff); 1984 int (*gro_complete)(struct sk_buff *skb, int nhoff);
1970}; 1985};
1971 1986
@@ -1975,10 +1990,21 @@ struct packet_offload {
1975 struct list_head list; 1990 struct list_head list;
1976}; 1991};
1977 1992
1993struct udp_offload;
1994
1995struct udp_offload_callbacks {
1996 struct sk_buff **(*gro_receive)(struct sk_buff **head,
1997 struct sk_buff *skb,
1998 struct udp_offload *uoff);
1999 int (*gro_complete)(struct sk_buff *skb,
2000 int nhoff,
2001 struct udp_offload *uoff);
2002};
2003
1978struct udp_offload { 2004struct udp_offload {
1979 __be16 port; 2005 __be16 port;
1980 u8 ipproto; 2006 u8 ipproto;
1981 struct offload_callbacks callbacks; 2007 struct udp_offload_callbacks callbacks;
1982}; 2008};
1983 2009
1984/* often modified stats are per cpu, other are shared (netdev->stats) */ 2010/* often modified stats are per cpu, other are shared (netdev->stats) */
@@ -2037,6 +2063,7 @@ struct pcpu_sw_netstats {
2037#define NETDEV_RESEND_IGMP 0x0016 2063#define NETDEV_RESEND_IGMP 0x0016
2038#define NETDEV_PRECHANGEMTU 0x0017 /* notify before mtu change happened */ 2064#define NETDEV_PRECHANGEMTU 0x0017 /* notify before mtu change happened */
2039#define NETDEV_CHANGEINFODATA 0x0018 2065#define NETDEV_CHANGEINFODATA 0x0018
2066#define NETDEV_BONDING_INFO 0x0019
2040 2067
2041int register_netdevice_notifier(struct notifier_block *nb); 2068int register_netdevice_notifier(struct notifier_block *nb);
2042int unregister_netdevice_notifier(struct notifier_block *nb); 2069int unregister_netdevice_notifier(struct notifier_block *nb);
@@ -2081,7 +2108,7 @@ extern rwlock_t dev_base_lock; /* Device list lock */
2081 list_for_each_entry_continue_rcu(d, &(net)->dev_base_head, dev_list) 2108 list_for_each_entry_continue_rcu(d, &(net)->dev_base_head, dev_list)
2082#define for_each_netdev_in_bond_rcu(bond, slave) \ 2109#define for_each_netdev_in_bond_rcu(bond, slave) \
2083 for_each_netdev_rcu(&init_net, slave) \ 2110 for_each_netdev_rcu(&init_net, slave) \
2084 if (netdev_master_upper_dev_get_rcu(slave) == bond) 2111 if (netdev_master_upper_dev_get_rcu(slave) == (bond))
2085#define net_device_entry(lh) list_entry(lh, struct net_device, dev_list) 2112#define net_device_entry(lh) list_entry(lh, struct net_device, dev_list)
2086 2113
2087static inline struct net_device *next_net_device(struct net_device *dev) 2114static inline struct net_device *next_net_device(struct net_device *dev)
@@ -2220,11 +2247,20 @@ static inline void skb_gro_postpull_rcsum(struct sk_buff *skb,
2220 2247
2221__sum16 __skb_gro_checksum_complete(struct sk_buff *skb); 2248__sum16 __skb_gro_checksum_complete(struct sk_buff *skb);
2222 2249
2250static inline bool skb_at_gro_remcsum_start(struct sk_buff *skb)
2251{
2252 return (NAPI_GRO_CB(skb)->gro_remcsum_start - skb_headroom(skb) ==
2253 skb_gro_offset(skb));
2254}
2255
2223static inline bool __skb_gro_checksum_validate_needed(struct sk_buff *skb, 2256static inline bool __skb_gro_checksum_validate_needed(struct sk_buff *skb,
2224 bool zero_okay, 2257 bool zero_okay,
2225 __sum16 check) 2258 __sum16 check)
2226{ 2259{
2227 return (skb->ip_summed != CHECKSUM_PARTIAL && 2260 return ((skb->ip_summed != CHECKSUM_PARTIAL ||
2261 skb_checksum_start_offset(skb) <
2262 skb_gro_offset(skb)) &&
2263 !skb_at_gro_remcsum_start(skb) &&
2228 NAPI_GRO_CB(skb)->csum_cnt == 0 && 2264 NAPI_GRO_CB(skb)->csum_cnt == 0 &&
2229 (!zero_okay || check)); 2265 (!zero_okay || check));
2230} 2266}
@@ -2299,6 +2335,49 @@ do { \
2299 compute_pseudo(skb, proto)); \ 2335 compute_pseudo(skb, proto)); \
2300} while (0) 2336} while (0)
2301 2337
2338struct gro_remcsum {
2339 int offset;
2340 __wsum delta;
2341};
2342
2343static inline void skb_gro_remcsum_init(struct gro_remcsum *grc)
2344{
2345 grc->delta = 0;
2346}
2347
2348static inline void skb_gro_remcsum_process(struct sk_buff *skb, void *ptr,
2349 int start, int offset,
2350 struct gro_remcsum *grc,
2351 bool nopartial)
2352{
2353 __wsum delta;
2354
2355 BUG_ON(!NAPI_GRO_CB(skb)->csum_valid);
2356
2357 if (!nopartial) {
2358 NAPI_GRO_CB(skb)->gro_remcsum_start =
2359 ((unsigned char *)ptr + start) - skb->head;
2360 return;
2361 }
2362
2363 delta = remcsum_adjust(ptr, NAPI_GRO_CB(skb)->csum, start, offset);
2364
2365 /* Adjust skb->csum since we changed the packet */
2366 NAPI_GRO_CB(skb)->csum = csum_add(NAPI_GRO_CB(skb)->csum, delta);
2367
2368 grc->offset = (ptr + offset) - (void *)skb->head;
2369 grc->delta = delta;
2370}
2371
2372static inline void skb_gro_remcsum_cleanup(struct sk_buff *skb,
2373 struct gro_remcsum *grc)
2374{
2375 if (!grc->delta)
2376 return;
2377
2378 remcsum_unadjust((__sum16 *)(skb->head + grc->offset), grc->delta);
2379}
2380
2302static inline int dev_hard_header(struct sk_buff *skb, struct net_device *dev, 2381static inline int dev_hard_header(struct sk_buff *skb, struct net_device *dev,
2303 unsigned short type, 2382 unsigned short type,
2304 const void *daddr, const void *saddr, 2383 const void *daddr, const void *saddr,
@@ -3460,6 +3539,19 @@ struct sk_buff *__skb_gso_segment(struct sk_buff *skb,
3460struct sk_buff *skb_mac_gso_segment(struct sk_buff *skb, 3539struct sk_buff *skb_mac_gso_segment(struct sk_buff *skb,
3461 netdev_features_t features); 3540 netdev_features_t features);
3462 3541
3542struct netdev_bonding_info {
3543 ifslave slave;
3544 ifbond master;
3545};
3546
3547struct netdev_notifier_bonding_info {
3548 struct netdev_notifier_info info; /* must be first */
3549 struct netdev_bonding_info bonding_info;
3550};
3551
3552void netdev_bonding_info_change(struct net_device *dev,
3553 struct netdev_bonding_info *bonding_info);
3554
3463static inline 3555static inline
3464struct sk_buff *skb_gso_segment(struct sk_buff *skb, netdev_features_t features) 3556struct sk_buff *skb_gso_segment(struct sk_buff *skb, netdev_features_t features)
3465{ 3557{
@@ -3611,8 +3703,6 @@ static inline bool netif_needs_gso(struct net_device *dev, struct sk_buff *skb,
3611 netdev_features_t features) 3703 netdev_features_t features)
3612{ 3704{
3613 return skb_is_gso(skb) && (!skb_gso_ok(skb, features) || 3705 return skb_is_gso(skb) && (!skb_gso_ok(skb, features) ||
3614 (dev->netdev_ops->ndo_gso_check &&
3615 !dev->netdev_ops->ndo_gso_check(skb, dev)) ||
3616 unlikely((skb->ip_summed != CHECKSUM_PARTIAL) && 3706 unlikely((skb->ip_summed != CHECKSUM_PARTIAL) &&
3617 (skb->ip_summed != CHECKSUM_UNNECESSARY))); 3707 (skb->ip_summed != CHECKSUM_UNNECESSARY)));
3618} 3708}