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.h354
1 files changed, 199 insertions, 155 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index cbeb5867cff7..0eac07c95255 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -43,6 +43,7 @@
43#include <linux/rculist.h> 43#include <linux/rculist.h>
44#include <linux/dmaengine.h> 44#include <linux/dmaengine.h>
45#include <linux/workqueue.h> 45#include <linux/workqueue.h>
46#include <linux/dynamic_queue_limits.h>
46 47
47#include <linux/ethtool.h> 48#include <linux/ethtool.h>
48#include <net/net_namespace.h> 49#include <net/net_namespace.h>
@@ -50,8 +51,10 @@
50#ifdef CONFIG_DCB 51#ifdef CONFIG_DCB
51#include <net/dcbnl.h> 52#include <net/dcbnl.h>
52#endif 53#endif
54#include <net/netprio_cgroup.h>
55
56#include <linux/netdev_features.h>
53 57
54struct vlan_group;
55struct netpoll_info; 58struct netpoll_info;
56struct phy_device; 59struct phy_device;
57/* 802.11 specific */ 60/* 802.11 specific */
@@ -141,22 +144,20 @@ static inline bool dev_xmit_complete(int rc)
141 * used. 144 * used.
142 */ 145 */
143 146
144#if defined(CONFIG_WLAN) || defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE) 147#if defined(CONFIG_WLAN) || IS_ENABLED(CONFIG_AX25)
145# if defined(CONFIG_MAC80211_MESH) 148# if defined(CONFIG_MAC80211_MESH)
146# define LL_MAX_HEADER 128 149# define LL_MAX_HEADER 128
147# else 150# else
148# define LL_MAX_HEADER 96 151# define LL_MAX_HEADER 96
149# endif 152# endif
150#elif defined(CONFIG_TR) || defined(CONFIG_TR_MODULE) 153#elif IS_ENABLED(CONFIG_TR)
151# define LL_MAX_HEADER 48 154# define LL_MAX_HEADER 48
152#else 155#else
153# define LL_MAX_HEADER 32 156# define LL_MAX_HEADER 32
154#endif 157#endif
155 158
156#if !defined(CONFIG_NET_IPIP) && !defined(CONFIG_NET_IPIP_MODULE) && \ 159#if !IS_ENABLED(CONFIG_NET_IPIP) && !IS_ENABLED(CONFIG_NET_IPGRE) && \
157 !defined(CONFIG_NET_IPGRE) && !defined(CONFIG_NET_IPGRE_MODULE) && \ 160 !IS_ENABLED(CONFIG_IPV6_SIT) && !IS_ENABLED(CONFIG_IPV6_TUNNEL)
158 !defined(CONFIG_IPV6_SIT) && !defined(CONFIG_IPV6_SIT_MODULE) && \
159 !defined(CONFIG_IPV6_TUNNEL) && !defined(CONFIG_IPV6_TUNNEL_MODULE)
160#define MAX_HEADER LL_MAX_HEADER 161#define MAX_HEADER LL_MAX_HEADER
161#else 162#else
162#define MAX_HEADER (LL_MAX_HEADER + 48) 163#define MAX_HEADER (LL_MAX_HEADER + 48)
@@ -212,6 +213,11 @@ enum {
212#include <linux/cache.h> 213#include <linux/cache.h>
213#include <linux/skbuff.h> 214#include <linux/skbuff.h>
214 215
216#ifdef CONFIG_RPS
217#include <linux/jump_label.h>
218extern struct jump_label_key rps_needed;
219#endif
220
215struct neighbour; 221struct neighbour;
216struct neigh_parms; 222struct neigh_parms;
217struct sk_buff; 223struct sk_buff;
@@ -272,16 +278,11 @@ struct hh_cache {
272 * 278 *
273 * We could use other alignment values, but we must maintain the 279 * We could use other alignment values, but we must maintain the
274 * relationship HH alignment <= LL alignment. 280 * relationship HH alignment <= LL alignment.
275 *
276 * LL_ALLOCATED_SPACE also takes into account the tailroom the device
277 * may need.
278 */ 281 */
279#define LL_RESERVED_SPACE(dev) \ 282#define LL_RESERVED_SPACE(dev) \
280 ((((dev)->hard_header_len+(dev)->needed_headroom)&~(HH_DATA_MOD - 1)) + HH_DATA_MOD) 283 ((((dev)->hard_header_len+(dev)->needed_headroom)&~(HH_DATA_MOD - 1)) + HH_DATA_MOD)
281#define LL_RESERVED_SPACE_EXTRA(dev,extra) \ 284#define LL_RESERVED_SPACE_EXTRA(dev,extra) \
282 ((((dev)->hard_header_len+(dev)->needed_headroom+(extra))&~(HH_DATA_MOD - 1)) + HH_DATA_MOD) 285 ((((dev)->hard_header_len+(dev)->needed_headroom+(extra))&~(HH_DATA_MOD - 1)) + HH_DATA_MOD)
283#define LL_ALLOCATED_SPACE(dev) \
284 ((((dev)->hard_header_len+(dev)->needed_headroom+(dev)->needed_tailroom)&~(HH_DATA_MOD - 1)) + HH_DATA_MOD)
285 286
286struct header_ops { 287struct header_ops {
287 int (*create) (struct sk_buff *skb, struct net_device *dev, 288 int (*create) (struct sk_buff *skb, struct net_device *dev,
@@ -516,11 +517,23 @@ static inline void napi_synchronize(const struct napi_struct *n)
516#endif 517#endif
517 518
518enum netdev_queue_state_t { 519enum netdev_queue_state_t {
519 __QUEUE_STATE_XOFF, 520 __QUEUE_STATE_DRV_XOFF,
521 __QUEUE_STATE_STACK_XOFF,
520 __QUEUE_STATE_FROZEN, 522 __QUEUE_STATE_FROZEN,
521#define QUEUE_STATE_XOFF_OR_FROZEN ((1 << __QUEUE_STATE_XOFF) | \ 523#define QUEUE_STATE_ANY_XOFF ((1 << __QUEUE_STATE_DRV_XOFF) | \
522 (1 << __QUEUE_STATE_FROZEN)) 524 (1 << __QUEUE_STATE_STACK_XOFF))
525#define QUEUE_STATE_ANY_XOFF_OR_FROZEN (QUEUE_STATE_ANY_XOFF | \
526 (1 << __QUEUE_STATE_FROZEN))
523}; 527};
528/*
529 * __QUEUE_STATE_DRV_XOFF is used by drivers to stop the transmit queue. The
530 * netif_tx_* functions below are used to manipulate this flag. The
531 * __QUEUE_STATE_STACK_XOFF flag is used by the stack to stop the transmit
532 * queue independently. The netif_xmit_*stopped functions below are called
533 * to check if the queue has been stopped by the driver or stack (either
534 * of the XOFF bits are set in the state). Drivers should not need to call
535 * netif_xmit*stopped functions, they should only be using netif_tx_*.
536 */
524 537
525struct netdev_queue { 538struct netdev_queue {
526/* 539/*
@@ -528,9 +541,8 @@ struct netdev_queue {
528 */ 541 */
529 struct net_device *dev; 542 struct net_device *dev;
530 struct Qdisc *qdisc; 543 struct Qdisc *qdisc;
531 unsigned long state;
532 struct Qdisc *qdisc_sleeping; 544 struct Qdisc *qdisc_sleeping;
533#if defined(CONFIG_RPS) || defined(CONFIG_XPS) 545#ifdef CONFIG_SYSFS
534 struct kobject kobj; 546 struct kobject kobj;
535#endif 547#endif
536#if defined(CONFIG_XPS) && defined(CONFIG_NUMA) 548#if defined(CONFIG_XPS) && defined(CONFIG_NUMA)
@@ -545,6 +557,18 @@ struct netdev_queue {
545 * please use this field instead of dev->trans_start 557 * please use this field instead of dev->trans_start
546 */ 558 */
547 unsigned long trans_start; 559 unsigned long trans_start;
560
561 /*
562 * Number of TX timeouts for this queue
563 * (/sys/class/net/DEV/Q/trans_timeout)
564 */
565 unsigned long trans_timeout;
566
567 unsigned long state;
568
569#ifdef CONFIG_BQL
570 struct dql dql;
571#endif
548} ____cacheline_aligned_in_smp; 572} ____cacheline_aligned_in_smp;
549 573
550static inline int netdev_queue_numa_node_read(const struct netdev_queue *q) 574static inline int netdev_queue_numa_node_read(const struct netdev_queue *q)
@@ -573,7 +597,7 @@ struct rps_map {
573 struct rcu_head rcu; 597 struct rcu_head rcu;
574 u16 cpus[0]; 598 u16 cpus[0];
575}; 599};
576#define RPS_MAP_SIZE(_num) (sizeof(struct rps_map) + (_num * sizeof(u16))) 600#define RPS_MAP_SIZE(_num) (sizeof(struct rps_map) + ((_num) * sizeof(u16)))
577 601
578/* 602/*
579 * The rps_dev_flow structure contains the mapping of a flow to a CPU, the 603 * The rps_dev_flow structure contains the mapping of a flow to a CPU, the
@@ -597,7 +621,7 @@ struct rps_dev_flow_table {
597 struct rps_dev_flow flows[0]; 621 struct rps_dev_flow flows[0];
598}; 622};
599#define RPS_DEV_FLOW_TABLE_SIZE(_num) (sizeof(struct rps_dev_flow_table) + \ 623#define RPS_DEV_FLOW_TABLE_SIZE(_num) (sizeof(struct rps_dev_flow_table) + \
600 (_num * sizeof(struct rps_dev_flow))) 624 ((_num) * sizeof(struct rps_dev_flow)))
601 625
602/* 626/*
603 * The rps_sock_flow_table contains mappings of flows to the last CPU 627 * The rps_sock_flow_table contains mappings of flows to the last CPU
@@ -608,7 +632,7 @@ struct rps_sock_flow_table {
608 u16 ents[0]; 632 u16 ents[0];
609}; 633};
610#define RPS_SOCK_FLOW_TABLE_SIZE(_num) (sizeof(struct rps_sock_flow_table) + \ 634#define RPS_SOCK_FLOW_TABLE_SIZE(_num) (sizeof(struct rps_sock_flow_table) + \
611 (_num * sizeof(u16))) 635 ((_num) * sizeof(u16)))
612 636
613#define RPS_NO_CPU 0xffff 637#define RPS_NO_CPU 0xffff
614 638
@@ -660,7 +684,7 @@ struct xps_map {
660 struct rcu_head rcu; 684 struct rcu_head rcu;
661 u16 queues[0]; 685 u16 queues[0];
662}; 686};
663#define XPS_MAP_SIZE(_num) (sizeof(struct xps_map) + (_num * sizeof(u16))) 687#define XPS_MAP_SIZE(_num) (sizeof(struct xps_map) + ((_num) * sizeof(u16)))
664#define XPS_MIN_MAP_ALLOC ((L1_CACHE_BYTES - sizeof(struct xps_map)) \ 688#define XPS_MIN_MAP_ALLOC ((L1_CACHE_BYTES - sizeof(struct xps_map)) \
665 / sizeof(u16)) 689 / sizeof(u16))
666 690
@@ -683,6 +707,23 @@ struct netdev_tc_txq {
683 u16 offset; 707 u16 offset;
684}; 708};
685 709
710#if defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE)
711/*
712 * This structure is to hold information about the device
713 * configured to run FCoE protocol stack.
714 */
715struct netdev_fcoe_hbainfo {
716 char manufacturer[64];
717 char serial_number[64];
718 char hardware_version[64];
719 char driver_version[64];
720 char optionrom_version[64];
721 char firmware_version[64];
722 char model[256];
723 char model_description[256];
724};
725#endif
726
686/* 727/*
687 * This structure defines the management hooks for network devices. 728 * This structure defines the management hooks for network devices.
688 * The following hooks can be defined; unless noted otherwise, they are 729 * The following hooks can be defined; unless noted otherwise, they are
@@ -767,11 +808,11 @@ struct netdev_tc_txq {
767 * 3. Update dev->stats asynchronously and atomically, and define 808 * 3. Update dev->stats asynchronously and atomically, and define
768 * neither operation. 809 * neither operation.
769 * 810 *
770 * void (*ndo_vlan_rx_add_vid)(struct net_device *dev, unsigned short vid); 811 * int (*ndo_vlan_rx_add_vid)(struct net_device *dev, unsigned short vid);
771 * If device support VLAN filtering (dev->features & NETIF_F_HW_VLAN_FILTER) 812 * If device support VLAN filtering (dev->features & NETIF_F_HW_VLAN_FILTER)
772 * this function is called when a VLAN id is registered. 813 * this function is called when a VLAN id is registered.
773 * 814 *
774 * void (*ndo_vlan_rx_kill_vid)(struct net_device *dev, unsigned short vid); 815 * int (*ndo_vlan_rx_kill_vid)(struct net_device *dev, unsigned short vid);
775 * If device support VLAN filtering (dev->features & NETIF_F_HW_VLAN_FILTER) 816 * If device support VLAN filtering (dev->features & NETIF_F_HW_VLAN_FILTER)
776 * this function is called when a VLAN id is unregistered. 817 * this function is called when a VLAN id is unregistered.
777 * 818 *
@@ -823,6 +864,13 @@ struct netdev_tc_txq {
823 * perform necessary setup and returns 1 to indicate the device is set up 864 * perform necessary setup and returns 1 to indicate the device is set up
824 * successfully to perform DDP on this I/O, otherwise this returns 0. 865 * successfully to perform DDP on this I/O, otherwise this returns 0.
825 * 866 *
867 * int (*ndo_fcoe_get_hbainfo)(struct net_device *dev,
868 * struct netdev_fcoe_hbainfo *hbainfo);
869 * Called when the FCoE Protocol stack wants information on the underlying
870 * device. This information is utilized by the FCoE protocol stack to
871 * register attributes with Fiber Channel management service as per the
872 * FC-GS Fabric Device Management Information(FDMI) specification.
873 *
826 * int (*ndo_fcoe_get_wwn)(struct net_device *dev, u64 *wwn, int type); 874 * int (*ndo_fcoe_get_wwn)(struct net_device *dev, u64 *wwn, int type);
827 * Called when the underlying device wants to override default World Wide 875 * Called when the underlying device wants to override default World Wide
828 * Name (WWN) generation mechanism in FCoE protocol stack to pass its own 876 * Name (WWN) generation mechanism in FCoE protocol stack to pass its own
@@ -845,12 +893,13 @@ struct netdev_tc_txq {
845 * Called to release previously enslaved netdev. 893 * Called to release previously enslaved netdev.
846 * 894 *
847 * Feature/offload setting functions. 895 * Feature/offload setting functions.
848 * u32 (*ndo_fix_features)(struct net_device *dev, u32 features); 896 * netdev_features_t (*ndo_fix_features)(struct net_device *dev,
897 * netdev_features_t features);
849 * Adjusts the requested feature flags according to device-specific 898 * Adjusts the requested feature flags according to device-specific
850 * constraints, and returns the resulting flags. Must not modify 899 * constraints, and returns the resulting flags. Must not modify
851 * the device state. 900 * the device state.
852 * 901 *
853 * int (*ndo_set_features)(struct net_device *dev, u32 features); 902 * int (*ndo_set_features)(struct net_device *dev, netdev_features_t features);
854 * Called to update device configuration to new features. Passed 903 * Called to update device configuration to new features. Passed
855 * feature set might be less than what was returned by ndo_fix_features()). 904 * feature set might be less than what was returned by ndo_fix_features()).
856 * Must return >0 or -errno if it changed dev->features itself. 905 * Must return >0 or -errno if it changed dev->features itself.
@@ -885,9 +934,9 @@ struct net_device_ops {
885 struct rtnl_link_stats64 *storage); 934 struct rtnl_link_stats64 *storage);
886 struct net_device_stats* (*ndo_get_stats)(struct net_device *dev); 935 struct net_device_stats* (*ndo_get_stats)(struct net_device *dev);
887 936
888 void (*ndo_vlan_rx_add_vid)(struct net_device *dev, 937 int (*ndo_vlan_rx_add_vid)(struct net_device *dev,
889 unsigned short vid); 938 unsigned short vid);
890 void (*ndo_vlan_rx_kill_vid)(struct net_device *dev, 939 int (*ndo_vlan_rx_kill_vid)(struct net_device *dev,
891 unsigned short vid); 940 unsigned short vid);
892#ifdef CONFIG_NET_POLL_CONTROLLER 941#ifdef CONFIG_NET_POLL_CONTROLLER
893 void (*ndo_poll_controller)(struct net_device *dev); 942 void (*ndo_poll_controller)(struct net_device *dev);
@@ -912,7 +961,7 @@ struct net_device_ops {
912 int (*ndo_get_vf_port)(struct net_device *dev, 961 int (*ndo_get_vf_port)(struct net_device *dev,
913 int vf, struct sk_buff *skb); 962 int vf, struct sk_buff *skb);
914 int (*ndo_setup_tc)(struct net_device *dev, u8 tc); 963 int (*ndo_setup_tc)(struct net_device *dev, u8 tc);
915#if defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE) 964#if IS_ENABLED(CONFIG_FCOE)
916 int (*ndo_fcoe_enable)(struct net_device *dev); 965 int (*ndo_fcoe_enable)(struct net_device *dev);
917 int (*ndo_fcoe_disable)(struct net_device *dev); 966 int (*ndo_fcoe_disable)(struct net_device *dev);
918 int (*ndo_fcoe_ddp_setup)(struct net_device *dev, 967 int (*ndo_fcoe_ddp_setup)(struct net_device *dev,
@@ -925,9 +974,11 @@ struct net_device_ops {
925 u16 xid, 974 u16 xid,
926 struct scatterlist *sgl, 975 struct scatterlist *sgl,
927 unsigned int sgc); 976 unsigned int sgc);
977 int (*ndo_fcoe_get_hbainfo)(struct net_device *dev,
978 struct netdev_fcoe_hbainfo *hbainfo);
928#endif 979#endif
929 980
930#if defined(CONFIG_LIBFCOE) || defined(CONFIG_LIBFCOE_MODULE) 981#if IS_ENABLED(CONFIG_LIBFCOE)
931#define NETDEV_FCOE_WWNN 0 982#define NETDEV_FCOE_WWNN 0
932#define NETDEV_FCOE_WWPN 1 983#define NETDEV_FCOE_WWPN 1
933 int (*ndo_fcoe_get_wwn)(struct net_device *dev, 984 int (*ndo_fcoe_get_wwn)(struct net_device *dev,
@@ -944,10 +995,12 @@ struct net_device_ops {
944 struct net_device *slave_dev); 995 struct net_device *slave_dev);
945 int (*ndo_del_slave)(struct net_device *dev, 996 int (*ndo_del_slave)(struct net_device *dev,
946 struct net_device *slave_dev); 997 struct net_device *slave_dev);
947 u32 (*ndo_fix_features)(struct net_device *dev, 998 netdev_features_t (*ndo_fix_features)(struct net_device *dev,
948 u32 features); 999 netdev_features_t features);
949 int (*ndo_set_features)(struct net_device *dev, 1000 int (*ndo_set_features)(struct net_device *dev,
950 u32 features); 1001 netdev_features_t features);
1002 int (*ndo_neigh_construct)(struct neighbour *n);
1003 void (*ndo_neigh_destroy)(struct neighbour *n);
951}; 1004};
952 1005
953/* 1006/*
@@ -997,91 +1050,13 @@ struct net_device {
997 struct list_head unreg_list; 1050 struct list_head unreg_list;
998 1051
999 /* currently active device features */ 1052 /* currently active device features */
1000 u32 features; 1053 netdev_features_t features;
1001 /* user-changeable features */ 1054 /* user-changeable features */
1002 u32 hw_features; 1055 netdev_features_t hw_features;
1003 /* user-requested features */ 1056 /* user-requested features */
1004 u32 wanted_features; 1057 netdev_features_t wanted_features;
1005 /* mask of features inheritable by VLAN devices */ 1058 /* mask of features inheritable by VLAN devices */
1006 u32 vlan_features; 1059 netdev_features_t vlan_features;
1007
1008 /* Net device feature bits; if you change something,
1009 * also update netdev_features_strings[] in ethtool.c */
1010
1011#define NETIF_F_SG 1 /* Scatter/gather IO. */
1012#define NETIF_F_IP_CSUM 2 /* Can checksum TCP/UDP over IPv4. */
1013#define NETIF_F_NO_CSUM 4 /* Does not require checksum. F.e. loopack. */
1014#define NETIF_F_HW_CSUM 8 /* Can checksum all the packets. */
1015#define NETIF_F_IPV6_CSUM 16 /* Can checksum TCP/UDP over IPV6 */
1016#define NETIF_F_HIGHDMA 32 /* Can DMA to high memory. */
1017#define NETIF_F_FRAGLIST 64 /* Scatter/gather IO. */
1018#define NETIF_F_HW_VLAN_TX 128 /* Transmit VLAN hw acceleration */
1019#define NETIF_F_HW_VLAN_RX 256 /* Receive VLAN hw acceleration */
1020#define NETIF_F_HW_VLAN_FILTER 512 /* Receive filtering on VLAN */
1021#define NETIF_F_VLAN_CHALLENGED 1024 /* Device cannot handle VLAN packets */
1022#define NETIF_F_GSO 2048 /* Enable software GSO. */
1023#define NETIF_F_LLTX 4096 /* LockLess TX - deprecated. Please */
1024 /* do not use LLTX in new drivers */
1025#define NETIF_F_NETNS_LOCAL 8192 /* Does not change network namespaces */
1026#define NETIF_F_GRO 16384 /* Generic receive offload */
1027#define NETIF_F_LRO 32768 /* large receive offload */
1028
1029/* the GSO_MASK reserves bits 16 through 23 */
1030#define NETIF_F_FCOE_CRC (1 << 24) /* FCoE CRC32 */
1031#define NETIF_F_SCTP_CSUM (1 << 25) /* SCTP checksum offload */
1032#define NETIF_F_FCOE_MTU (1 << 26) /* Supports max FCoE MTU, 2158 bytes*/
1033#define NETIF_F_NTUPLE (1 << 27) /* N-tuple filters supported */
1034#define NETIF_F_RXHASH (1 << 28) /* Receive hashing offload */
1035#define NETIF_F_RXCSUM (1 << 29) /* Receive checksumming offload */
1036#define NETIF_F_NOCACHE_COPY (1 << 30) /* Use no-cache copyfromuser */
1037#define NETIF_F_LOOPBACK (1 << 31) /* Enable loopback */
1038
1039 /* Segmentation offload features */
1040#define NETIF_F_GSO_SHIFT 16
1041#define NETIF_F_GSO_MASK 0x00ff0000
1042#define NETIF_F_TSO (SKB_GSO_TCPV4 << NETIF_F_GSO_SHIFT)
1043#define NETIF_F_UFO (SKB_GSO_UDP << NETIF_F_GSO_SHIFT)
1044#define NETIF_F_GSO_ROBUST (SKB_GSO_DODGY << NETIF_F_GSO_SHIFT)
1045#define NETIF_F_TSO_ECN (SKB_GSO_TCP_ECN << NETIF_F_GSO_SHIFT)
1046#define NETIF_F_TSO6 (SKB_GSO_TCPV6 << NETIF_F_GSO_SHIFT)
1047#define NETIF_F_FSO (SKB_GSO_FCOE << NETIF_F_GSO_SHIFT)
1048
1049 /* Features valid for ethtool to change */
1050 /* = all defined minus driver/device-class-related */
1051#define NETIF_F_NEVER_CHANGE (NETIF_F_VLAN_CHALLENGED | \
1052 NETIF_F_LLTX | NETIF_F_NETNS_LOCAL)
1053#define NETIF_F_ETHTOOL_BITS (0xff3fffff & ~NETIF_F_NEVER_CHANGE)
1054
1055 /* List of features with software fallbacks. */
1056#define NETIF_F_GSO_SOFTWARE (NETIF_F_TSO | NETIF_F_TSO_ECN | \
1057 NETIF_F_TSO6 | NETIF_F_UFO)
1058
1059
1060#define NETIF_F_GEN_CSUM (NETIF_F_NO_CSUM | NETIF_F_HW_CSUM)
1061#define NETIF_F_V4_CSUM (NETIF_F_GEN_CSUM | NETIF_F_IP_CSUM)
1062#define NETIF_F_V6_CSUM (NETIF_F_GEN_CSUM | NETIF_F_IPV6_CSUM)
1063#define NETIF_F_ALL_CSUM (NETIF_F_V4_CSUM | NETIF_F_V6_CSUM)
1064
1065#define NETIF_F_ALL_TSO (NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_TSO_ECN)
1066
1067#define NETIF_F_ALL_FCOE (NETIF_F_FCOE_CRC | NETIF_F_FCOE_MTU | \
1068 NETIF_F_FSO)
1069
1070 /*
1071 * If one device supports one of these features, then enable them
1072 * for all in netdev_increment_features.
1073 */
1074#define NETIF_F_ONE_FOR_ALL (NETIF_F_GSO_SOFTWARE | NETIF_F_GSO_ROBUST | \
1075 NETIF_F_SG | NETIF_F_HIGHDMA | \
1076 NETIF_F_FRAGLIST | NETIF_F_VLAN_CHALLENGED)
1077 /*
1078 * If one device doesn't support one of these features, then disable it
1079 * for all in netdev_increment_features.
1080 */
1081#define NETIF_F_ALL_FOR_ALL (NETIF_F_NOCACHE_COPY | NETIF_F_FSO)
1082
1083 /* changeable features with no special hardware requirements */
1084#define NETIF_F_SOFT_FEATURES (NETIF_F_GSO | NETIF_F_GRO)
1085 1060
1086 /* Interface index. Unique device identifier */ 1061 /* Interface index. Unique device identifier */
1087 int ifindex; 1062 int ifindex;
@@ -1132,6 +1107,7 @@ struct net_device {
1132 unsigned char perm_addr[MAX_ADDR_LEN]; /* permanent hw address */ 1107 unsigned char perm_addr[MAX_ADDR_LEN]; /* permanent hw address */
1133 unsigned char addr_assign_type; /* hw address assignment type */ 1108 unsigned char addr_assign_type; /* hw address assignment type */
1134 unsigned char addr_len; /* hardware address length */ 1109 unsigned char addr_len; /* hardware address length */
1110 unsigned char neigh_priv_len;
1135 unsigned short dev_id; /* for shared network cards */ 1111 unsigned short dev_id; /* for shared network cards */
1136 1112
1137 spinlock_t addr_list_lock; 1113 spinlock_t addr_list_lock;
@@ -1144,11 +1120,11 @@ struct net_device {
1144 1120
1145 /* Protocol specific pointers */ 1121 /* Protocol specific pointers */
1146 1122
1147#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE) 1123#if IS_ENABLED(CONFIG_VLAN_8021Q)
1148 struct vlan_group __rcu *vlgrp; /* VLAN group */ 1124 struct vlan_info __rcu *vlan_info; /* VLAN info */
1149#endif 1125#endif
1150#ifdef CONFIG_NET_DSA 1126#if IS_ENABLED(CONFIG_NET_DSA)
1151 void *dsa_ptr; /* dsa specific data */ 1127 struct dsa_switch_tree *dsa_ptr; /* dsa specific data */
1152#endif 1128#endif
1153 void *atalk_ptr; /* AppleTalk link */ 1129 void *atalk_ptr; /* AppleTalk link */
1154 struct in_device __rcu *ip_ptr; /* IPv4 specific data */ 1130 struct in_device __rcu *ip_ptr; /* IPv4 specific data */
@@ -1184,9 +1160,11 @@ struct net_device {
1184 1160
1185 unsigned char broadcast[MAX_ADDR_LEN]; /* hw bcast add */ 1161 unsigned char broadcast[MAX_ADDR_LEN]; /* hw bcast add */
1186 1162
1187#if defined(CONFIG_RPS) || defined(CONFIG_XPS) 1163#ifdef CONFIG_SYSFS
1188 struct kset *queues_kset; 1164 struct kset *queues_kset;
1165#endif
1189 1166
1167#ifdef CONFIG_RPS
1190 struct netdev_rx_queue *_rx; 1168 struct netdev_rx_queue *_rx;
1191 1169
1192 /* Number of RX queues allocated at register_netdev() time */ 1170 /* Number of RX queues allocated at register_netdev() time */
@@ -1308,10 +1286,13 @@ struct net_device {
1308 struct netdev_tc_txq tc_to_txq[TC_MAX_QUEUE]; 1286 struct netdev_tc_txq tc_to_txq[TC_MAX_QUEUE];
1309 u8 prio_tc_map[TC_BITMASK + 1]; 1287 u8 prio_tc_map[TC_BITMASK + 1];
1310 1288
1311#if defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE) 1289#if IS_ENABLED(CONFIG_FCOE)
1312 /* max exchange id for FCoE LRO by ddp */ 1290 /* max exchange id for FCoE LRO by ddp */
1313 unsigned int fcoe_ddp_xid; 1291 unsigned int fcoe_ddp_xid;
1314#endif 1292#endif
1293#if IS_ENABLED(CONFIG_NETPRIO_CGROUP)
1294 struct netprio_map __rcu *priomap;
1295#endif
1315 /* phy device may attach itself for hardware timestamping */ 1296 /* phy device may attach itself for hardware timestamping */
1316 struct phy_device *phydev; 1297 struct phy_device *phydev;
1317 1298
@@ -1515,7 +1496,7 @@ struct packet_type {
1515 struct packet_type *, 1496 struct packet_type *,
1516 struct net_device *); 1497 struct net_device *);
1517 struct sk_buff *(*gso_segment)(struct sk_buff *skb, 1498 struct sk_buff *(*gso_segment)(struct sk_buff *skb,
1518 u32 features); 1499 netdev_features_t features);
1519 int (*gso_send_check)(struct sk_buff *skb); 1500 int (*gso_send_check)(struct sk_buff *skb);
1520 struct sk_buff **(*gro_receive)(struct sk_buff **head, 1501 struct sk_buff **(*gro_receive)(struct sk_buff **head,
1521 struct sk_buff *skb); 1502 struct sk_buff *skb);
@@ -1783,7 +1764,7 @@ extern void __netif_schedule(struct Qdisc *q);
1783 1764
1784static inline void netif_schedule_queue(struct netdev_queue *txq) 1765static inline void netif_schedule_queue(struct netdev_queue *txq)
1785{ 1766{
1786 if (!test_bit(__QUEUE_STATE_XOFF, &txq->state)) 1767 if (!(txq->state & QUEUE_STATE_ANY_XOFF))
1787 __netif_schedule(txq->qdisc); 1768 __netif_schedule(txq->qdisc);
1788} 1769}
1789 1770
@@ -1797,7 +1778,7 @@ static inline void netif_tx_schedule_all(struct net_device *dev)
1797 1778
1798static inline void netif_tx_start_queue(struct netdev_queue *dev_queue) 1779static inline void netif_tx_start_queue(struct netdev_queue *dev_queue)
1799{ 1780{
1800 clear_bit(__QUEUE_STATE_XOFF, &dev_queue->state); 1781 clear_bit(__QUEUE_STATE_DRV_XOFF, &dev_queue->state);
1801} 1782}
1802 1783
1803/** 1784/**
@@ -1829,7 +1810,7 @@ static inline void netif_tx_wake_queue(struct netdev_queue *dev_queue)
1829 return; 1810 return;
1830 } 1811 }
1831#endif 1812#endif
1832 if (test_and_clear_bit(__QUEUE_STATE_XOFF, &dev_queue->state)) 1813 if (test_and_clear_bit(__QUEUE_STATE_DRV_XOFF, &dev_queue->state))
1833 __netif_schedule(dev_queue->qdisc); 1814 __netif_schedule(dev_queue->qdisc);
1834} 1815}
1835 1816
@@ -1861,7 +1842,7 @@ static inline void netif_tx_stop_queue(struct netdev_queue *dev_queue)
1861 pr_info("netif_stop_queue() cannot be called before register_netdev()\n"); 1842 pr_info("netif_stop_queue() cannot be called before register_netdev()\n");
1862 return; 1843 return;
1863 } 1844 }
1864 set_bit(__QUEUE_STATE_XOFF, &dev_queue->state); 1845 set_bit(__QUEUE_STATE_DRV_XOFF, &dev_queue->state);
1865} 1846}
1866 1847
1867/** 1848/**
@@ -1888,7 +1869,7 @@ static inline void netif_tx_stop_all_queues(struct net_device *dev)
1888 1869
1889static inline int netif_tx_queue_stopped(const struct netdev_queue *dev_queue) 1870static inline int netif_tx_queue_stopped(const struct netdev_queue *dev_queue)
1890{ 1871{
1891 return test_bit(__QUEUE_STATE_XOFF, &dev_queue->state); 1872 return test_bit(__QUEUE_STATE_DRV_XOFF, &dev_queue->state);
1892} 1873}
1893 1874
1894/** 1875/**
@@ -1902,9 +1883,68 @@ static inline int netif_queue_stopped(const struct net_device *dev)
1902 return netif_tx_queue_stopped(netdev_get_tx_queue(dev, 0)); 1883 return netif_tx_queue_stopped(netdev_get_tx_queue(dev, 0));
1903} 1884}
1904 1885
1905static inline int netif_tx_queue_frozen_or_stopped(const struct netdev_queue *dev_queue) 1886static inline int netif_xmit_stopped(const struct netdev_queue *dev_queue)
1906{ 1887{
1907 return dev_queue->state & QUEUE_STATE_XOFF_OR_FROZEN; 1888 return dev_queue->state & QUEUE_STATE_ANY_XOFF;
1889}
1890
1891static inline int netif_xmit_frozen_or_stopped(const struct netdev_queue *dev_queue)
1892{
1893 return dev_queue->state & QUEUE_STATE_ANY_XOFF_OR_FROZEN;
1894}
1895
1896static inline void netdev_tx_sent_queue(struct netdev_queue *dev_queue,
1897 unsigned int bytes)
1898{
1899#ifdef CONFIG_BQL
1900 dql_queued(&dev_queue->dql, bytes);
1901 if (unlikely(dql_avail(&dev_queue->dql) < 0)) {
1902 set_bit(__QUEUE_STATE_STACK_XOFF, &dev_queue->state);
1903 if (unlikely(dql_avail(&dev_queue->dql) >= 0))
1904 clear_bit(__QUEUE_STATE_STACK_XOFF,
1905 &dev_queue->state);
1906 }
1907#endif
1908}
1909
1910static inline void netdev_sent_queue(struct net_device *dev, unsigned int bytes)
1911{
1912 netdev_tx_sent_queue(netdev_get_tx_queue(dev, 0), bytes);
1913}
1914
1915static inline void netdev_tx_completed_queue(struct netdev_queue *dev_queue,
1916 unsigned pkts, unsigned bytes)
1917{
1918#ifdef CONFIG_BQL
1919 if (likely(bytes)) {
1920 dql_completed(&dev_queue->dql, bytes);
1921 if (unlikely(test_bit(__QUEUE_STATE_STACK_XOFF,
1922 &dev_queue->state) &&
1923 dql_avail(&dev_queue->dql) >= 0)) {
1924 if (test_and_clear_bit(__QUEUE_STATE_STACK_XOFF,
1925 &dev_queue->state))
1926 netif_schedule_queue(dev_queue);
1927 }
1928 }
1929#endif
1930}
1931
1932static inline void netdev_completed_queue(struct net_device *dev,
1933 unsigned pkts, unsigned bytes)
1934{
1935 netdev_tx_completed_queue(netdev_get_tx_queue(dev, 0), pkts, bytes);
1936}
1937
1938static inline void netdev_tx_reset_queue(struct netdev_queue *q)
1939{
1940#ifdef CONFIG_BQL
1941 dql_reset(&q->dql);
1942#endif
1943}
1944
1945static inline void netdev_reset_queue(struct net_device *dev_queue)
1946{
1947 netdev_tx_reset_queue(netdev_get_tx_queue(dev_queue, 0));
1908} 1948}
1909 1949
1910/** 1950/**
@@ -1991,7 +2031,7 @@ static inline void netif_wake_subqueue(struct net_device *dev, u16 queue_index)
1991 if (netpoll_trap()) 2031 if (netpoll_trap())
1992 return; 2032 return;
1993#endif 2033#endif
1994 if (test_and_clear_bit(__QUEUE_STATE_XOFF, &txq->state)) 2034 if (test_and_clear_bit(__QUEUE_STATE_DRV_XOFF, &txq->state))
1995 __netif_schedule(txq->qdisc); 2035 __netif_schedule(txq->qdisc);
1996} 2036}
1997 2037
@@ -2115,7 +2155,7 @@ extern void netdev_run_todo(void);
2115 */ 2155 */
2116static inline void dev_put(struct net_device *dev) 2156static inline void dev_put(struct net_device *dev)
2117{ 2157{
2118 irqsafe_cpu_dec(*dev->pcpu_refcnt); 2158 this_cpu_dec(*dev->pcpu_refcnt);
2119} 2159}
2120 2160
2121/** 2161/**
@@ -2126,7 +2166,7 @@ static inline void dev_put(struct net_device *dev)
2126 */ 2166 */
2127static inline void dev_hold(struct net_device *dev) 2167static inline void dev_hold(struct net_device *dev)
2128{ 2168{
2129 irqsafe_cpu_inc(*dev->pcpu_refcnt); 2169 this_cpu_inc(*dev->pcpu_refcnt);
2130} 2170}
2131 2171
2132/* Carrier loss detection, dial on demand. The functions netif_carrier_on 2172/* Carrier loss detection, dial on demand. The functions netif_carrier_on
@@ -2410,6 +2450,11 @@ static inline void netif_addr_lock(struct net_device *dev)
2410 spin_lock(&dev->addr_list_lock); 2450 spin_lock(&dev->addr_list_lock);
2411} 2451}
2412 2452
2453static inline void netif_addr_lock_nested(struct net_device *dev)
2454{
2455 spin_lock_nested(&dev->addr_list_lock, SINGLE_DEPTH_NESTING);
2456}
2457
2413static inline void netif_addr_lock_bh(struct net_device *dev) 2458static inline void netif_addr_lock_bh(struct net_device *dev)
2414{ 2459{
2415 spin_lock_bh(&dev->addr_list_lock); 2460 spin_lock_bh(&dev->addr_list_lock);
@@ -2520,7 +2565,8 @@ extern int netdev_set_master(struct net_device *dev, struct net_device *master)
2520extern int netdev_set_bond_master(struct net_device *dev, 2565extern int netdev_set_bond_master(struct net_device *dev,
2521 struct net_device *master); 2566 struct net_device *master);
2522extern int skb_checksum_help(struct sk_buff *skb); 2567extern int skb_checksum_help(struct sk_buff *skb);
2523extern struct sk_buff *skb_gso_segment(struct sk_buff *skb, u32 features); 2568extern struct sk_buff *skb_gso_segment(struct sk_buff *skb,
2569 netdev_features_t features);
2524#ifdef CONFIG_BUG 2570#ifdef CONFIG_BUG
2525extern void netdev_rx_csum_fault(struct net_device *dev); 2571extern void netdev_rx_csum_fault(struct net_device *dev);
2526#else 2572#else
@@ -2536,6 +2582,8 @@ extern void net_disable_timestamp(void);
2536extern void *dev_seq_start(struct seq_file *seq, loff_t *pos); 2582extern void *dev_seq_start(struct seq_file *seq, loff_t *pos);
2537extern void *dev_seq_next(struct seq_file *seq, void *v, loff_t *pos); 2583extern void *dev_seq_next(struct seq_file *seq, void *v, loff_t *pos);
2538extern void dev_seq_stop(struct seq_file *seq, void *v); 2584extern void dev_seq_stop(struct seq_file *seq, void *v);
2585extern int dev_seq_open_ops(struct inode *inode, struct file *file,
2586 const struct seq_operations *ops);
2539#endif 2587#endif
2540 2588
2541extern int netdev_class_create_file(struct class_attribute *class_attr); 2589extern int netdev_class_create_file(struct class_attribute *class_attr);
@@ -2547,11 +2595,13 @@ extern const char *netdev_drivername(const struct net_device *dev);
2547 2595
2548extern void linkwatch_run_queue(void); 2596extern void linkwatch_run_queue(void);
2549 2597
2550static inline u32 netdev_get_wanted_features(struct net_device *dev) 2598static inline netdev_features_t netdev_get_wanted_features(
2599 struct net_device *dev)
2551{ 2600{
2552 return (dev->features & ~dev->hw_features) | dev->wanted_features; 2601 return (dev->features & ~dev->hw_features) | dev->wanted_features;
2553} 2602}
2554u32 netdev_increment_features(u32 all, u32 one, u32 mask); 2603netdev_features_t netdev_increment_features(netdev_features_t all,
2604 netdev_features_t one, netdev_features_t mask);
2555int __netdev_update_features(struct net_device *dev); 2605int __netdev_update_features(struct net_device *dev);
2556void netdev_update_features(struct net_device *dev); 2606void netdev_update_features(struct net_device *dev);
2557void netdev_change_features(struct net_device *dev); 2607void netdev_change_features(struct net_device *dev);
@@ -2559,21 +2609,31 @@ void netdev_change_features(struct net_device *dev);
2559void netif_stacked_transfer_operstate(const struct net_device *rootdev, 2609void netif_stacked_transfer_operstate(const struct net_device *rootdev,
2560 struct net_device *dev); 2610 struct net_device *dev);
2561 2611
2562u32 netif_skb_features(struct sk_buff *skb); 2612netdev_features_t netif_skb_features(struct sk_buff *skb);
2563 2613
2564static inline int net_gso_ok(u32 features, int gso_type) 2614static inline int net_gso_ok(netdev_features_t features, int gso_type)
2565{ 2615{
2566 int feature = gso_type << NETIF_F_GSO_SHIFT; 2616 netdev_features_t feature = gso_type << NETIF_F_GSO_SHIFT;
2617
2618 /* check flags correspondence */
2619 BUILD_BUG_ON(SKB_GSO_TCPV4 != (NETIF_F_TSO >> NETIF_F_GSO_SHIFT));
2620 BUILD_BUG_ON(SKB_GSO_UDP != (NETIF_F_UFO >> NETIF_F_GSO_SHIFT));
2621 BUILD_BUG_ON(SKB_GSO_DODGY != (NETIF_F_GSO_ROBUST >> NETIF_F_GSO_SHIFT));
2622 BUILD_BUG_ON(SKB_GSO_TCP_ECN != (NETIF_F_TSO_ECN >> NETIF_F_GSO_SHIFT));
2623 BUILD_BUG_ON(SKB_GSO_TCPV6 != (NETIF_F_TSO6 >> NETIF_F_GSO_SHIFT));
2624 BUILD_BUG_ON(SKB_GSO_FCOE != (NETIF_F_FSO >> NETIF_F_GSO_SHIFT));
2625
2567 return (features & feature) == feature; 2626 return (features & feature) == feature;
2568} 2627}
2569 2628
2570static inline int skb_gso_ok(struct sk_buff *skb, u32 features) 2629static inline int skb_gso_ok(struct sk_buff *skb, netdev_features_t features)
2571{ 2630{
2572 return net_gso_ok(features, skb_shinfo(skb)->gso_type) && 2631 return net_gso_ok(features, skb_shinfo(skb)->gso_type) &&
2573 (!skb_has_frag_list(skb) || (features & NETIF_F_FRAGLIST)); 2632 (!skb_has_frag_list(skb) || (features & NETIF_F_FRAGLIST));
2574} 2633}
2575 2634
2576static inline int netif_needs_gso(struct sk_buff *skb, int features) 2635static inline int netif_needs_gso(struct sk_buff *skb,
2636 netdev_features_t features)
2577{ 2637{
2578 return skb_is_gso(skb) && (!skb_gso_ok(skb, features) || 2638 return skb_is_gso(skb) && (!skb_gso_ok(skb, features) ||
2579 unlikely(skb->ip_summed != CHECKSUM_PARTIAL)); 2639 unlikely(skb->ip_summed != CHECKSUM_PARTIAL));
@@ -2592,22 +2652,6 @@ static inline int netif_is_bond_slave(struct net_device *dev)
2592 2652
2593extern struct pernet_operations __net_initdata loopback_net_ops; 2653extern struct pernet_operations __net_initdata loopback_net_ops;
2594 2654
2595static inline u32 dev_ethtool_get_rx_csum(struct net_device *dev)
2596{
2597 if (dev->features & NETIF_F_RXCSUM)
2598 return 1;
2599 if (!dev->ethtool_ops || !dev->ethtool_ops->get_rx_csum)
2600 return 0;
2601 return dev->ethtool_ops->get_rx_csum(dev);
2602}
2603
2604static inline u32 dev_ethtool_get_flags(struct net_device *dev)
2605{
2606 if (!dev->ethtool_ops || !dev->ethtool_ops->get_flags)
2607 return 0;
2608 return dev->ethtool_ops->get_flags(dev);
2609}
2610
2611/* Logging, debugging and troubleshooting/diagnostic helpers. */ 2655/* Logging, debugging and troubleshooting/diagnostic helpers. */
2612 2656
2613/* netdev_printk helpers, similar to dev_printk */ 2657/* netdev_printk helpers, similar to dev_printk */