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.h141
1 files changed, 103 insertions, 38 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 46c36ffe20ee..d8fd2c23a1b9 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -228,9 +228,9 @@ struct netdev_hw_addr {
228#define NETDEV_HW_ADDR_T_SLAVE 3 228#define NETDEV_HW_ADDR_T_SLAVE 3
229#define NETDEV_HW_ADDR_T_UNICAST 4 229#define NETDEV_HW_ADDR_T_UNICAST 4
230#define NETDEV_HW_ADDR_T_MULTICAST 5 230#define NETDEV_HW_ADDR_T_MULTICAST 5
231 int refcount;
232 bool synced; 231 bool synced;
233 bool global_use; 232 bool global_use;
233 int refcount;
234 struct rcu_head rcu_head; 234 struct rcu_head rcu_head;
235}; 235};
236 236
@@ -281,6 +281,12 @@ struct hh_cache {
281 unsigned long hh_data[HH_DATA_ALIGN(LL_MAX_HEADER) / sizeof(long)]; 281 unsigned long hh_data[HH_DATA_ALIGN(LL_MAX_HEADER) / sizeof(long)];
282}; 282};
283 283
284static inline void hh_cache_put(struct hh_cache *hh)
285{
286 if (atomic_dec_and_test(&hh->hh_refcnt))
287 kfree(hh);
288}
289
284/* Reserve HH_DATA_MOD byte aligned hard_header_len, but at least that much. 290/* Reserve HH_DATA_MOD byte aligned hard_header_len, but at least that much.
285 * Alternative is: 291 * Alternative is:
286 * dev->hard_header_len ? (dev->hard_header_len + 292 * dev->hard_header_len ? (dev->hard_header_len +
@@ -579,15 +585,15 @@ static inline void rps_reset_sock_flow(struct rps_sock_flow_table *table,
579 table->ents[hash & table->mask] = RPS_NO_CPU; 585 table->ents[hash & table->mask] = RPS_NO_CPU;
580} 586}
581 587
582extern struct rps_sock_flow_table *rps_sock_flow_table; 588extern struct rps_sock_flow_table __rcu *rps_sock_flow_table;
583 589
584/* This structure contains an instance of an RX queue. */ 590/* This structure contains an instance of an RX queue. */
585struct netdev_rx_queue { 591struct netdev_rx_queue {
586 struct rps_map *rps_map; 592 struct rps_map __rcu *rps_map;
587 struct rps_dev_flow_table *rps_flow_table; 593 struct rps_dev_flow_table __rcu *rps_flow_table;
588 struct kobject kobj; 594 struct kobject kobj;
589 struct netdev_rx_queue *first; 595 struct netdev_rx_queue *first;
590 atomic_t count; 596 atomic_t count;
591} ____cacheline_aligned_in_smp; 597} ____cacheline_aligned_in_smp;
592#endif /* CONFIG_RPS */ 598#endif /* CONFIG_RPS */
593 599
@@ -884,6 +890,9 @@ struct net_device {
884 int iflink; 890 int iflink;
885 891
886 struct net_device_stats stats; 892 struct net_device_stats stats;
893 atomic_long_t rx_dropped; /* dropped packets by core network
894 * Do not use this in drivers.
895 */
887 896
888#ifdef CONFIG_WIRELESS_EXT 897#ifdef CONFIG_WIRELESS_EXT
889 /* List of functions to handle Wireless Extensions (instead of ioctl). 898 /* List of functions to handle Wireless Extensions (instead of ioctl).
@@ -901,7 +910,7 @@ struct net_device {
901 910
902 unsigned int flags; /* interface flags (a la BSD) */ 911 unsigned int flags; /* interface flags (a la BSD) */
903 unsigned short gflags; 912 unsigned short gflags;
904 unsigned short priv_flags; /* Like 'flags' but invisible to userspace. */ 913 unsigned int priv_flags; /* Like 'flags' but invisible to userspace. */
905 unsigned short padded; /* How much padding added by alloc_netdev() */ 914 unsigned short padded; /* How much padding added by alloc_netdev() */
906 915
907 unsigned char operstate; /* RFC2863 operstate */ 916 unsigned char operstate; /* RFC2863 operstate */
@@ -918,10 +927,6 @@ struct net_device {
918 unsigned short needed_headroom; 927 unsigned short needed_headroom;
919 unsigned short needed_tailroom; 928 unsigned short needed_tailroom;
920 929
921 struct net_device *master; /* Pointer to master device of a group,
922 * which this device is member of.
923 */
924
925 /* Interface address info. */ 930 /* Interface address info. */
926 unsigned char perm_addr[MAX_ADDR_LEN]; /* permanent hw address */ 931 unsigned char perm_addr[MAX_ADDR_LEN]; /* permanent hw address */
927 unsigned char addr_assign_type; /* hw address assignment type */ 932 unsigned char addr_assign_type; /* hw address assignment type */
@@ -937,23 +942,37 @@ struct net_device {
937 942
938 943
939 /* Protocol specific pointers */ 944 /* Protocol specific pointers */
940 945
946#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
947 struct vlan_group __rcu *vlgrp; /* VLAN group */
948#endif
941#ifdef CONFIG_NET_DSA 949#ifdef CONFIG_NET_DSA
942 void *dsa_ptr; /* dsa specific data */ 950 void *dsa_ptr; /* dsa specific data */
943#endif 951#endif
944 void *atalk_ptr; /* AppleTalk link */ 952 void *atalk_ptr; /* AppleTalk link */
945 void *ip_ptr; /* IPv4 specific data */ 953 struct in_device __rcu *ip_ptr; /* IPv4 specific data */
946 void *dn_ptr; /* DECnet specific data */ 954 void *dn_ptr; /* DECnet specific data */
947 void *ip6_ptr; /* IPv6 specific data */ 955 struct inet6_dev __rcu *ip6_ptr; /* IPv6 specific data */
948 void *ec_ptr; /* Econet specific data */ 956 void *ec_ptr; /* Econet specific data */
949 void *ax25_ptr; /* AX.25 specific data */ 957 void *ax25_ptr; /* AX.25 specific data */
950 struct wireless_dev *ieee80211_ptr; /* IEEE 802.11 specific data, 958 struct wireless_dev *ieee80211_ptr; /* IEEE 802.11 specific data,
951 assign before registering */ 959 assign before registering */
952 960
953/* 961/*
954 * Cache line mostly used on receive path (including eth_type_trans()) 962 * Cache lines mostly used on receive path (including eth_type_trans())
955 */ 963 */
956 unsigned long last_rx; /* Time of last Rx */ 964 unsigned long last_rx; /* Time of last Rx
965 * This should not be set in
966 * drivers, unless really needed,
967 * because network stack (bonding)
968 * use it if/when necessary, to
969 * avoid dirtying this cache line.
970 */
971
972 struct net_device *master; /* Pointer to master device of a group,
973 * which this device is member of.
974 */
975
957 /* Interface address info used in eth_type_trans() */ 976 /* Interface address info used in eth_type_trans() */
958 unsigned char *dev_addr; /* hw address, (before bcast 977 unsigned char *dev_addr; /* hw address, (before bcast
959 because most packets are 978 because most packets are
@@ -969,14 +988,21 @@ struct net_device {
969 988
970 struct netdev_rx_queue *_rx; 989 struct netdev_rx_queue *_rx;
971 990
972 /* Number of RX queues allocated at alloc_netdev_mq() time */ 991 /* Number of RX queues allocated at register_netdev() time */
973 unsigned int num_rx_queues; 992 unsigned int num_rx_queues;
993
994 /* Number of RX queues currently active in device */
995 unsigned int real_num_rx_queues;
974#endif 996#endif
975 997
976 struct netdev_queue rx_queue;
977 rx_handler_func_t *rx_handler; 998 rx_handler_func_t *rx_handler;
978 void *rx_handler_data; 999 void *rx_handler_data;
979 1000
1001 struct netdev_queue __rcu *ingress_queue;
1002
1003/*
1004 * Cache lines mostly used on transmit path
1005 */
980 struct netdev_queue *_tx ____cacheline_aligned_in_smp; 1006 struct netdev_queue *_tx ____cacheline_aligned_in_smp;
981 1007
982 /* Number of TX queues allocated at alloc_netdev_mq() time */ 1008 /* Number of TX queues allocated at alloc_netdev_mq() time */
@@ -990,9 +1016,7 @@ struct net_device {
990 1016
991 unsigned long tx_queue_len; /* Max frames per queue allowed */ 1017 unsigned long tx_queue_len; /* Max frames per queue allowed */
992 spinlock_t tx_global_lock; 1018 spinlock_t tx_global_lock;
993/* 1019
994 * One part is mostly used on xmit path (device)
995 */
996 /* These may be needed for future network-power-down code. */ 1020 /* These may be needed for future network-power-down code. */
997 1021
998 /* 1022 /*
@@ -1005,7 +1029,7 @@ struct net_device {
1005 struct timer_list watchdog_timer; 1029 struct timer_list watchdog_timer;
1006 1030
1007 /* Number of references to this device */ 1031 /* Number of references to this device */
1008 atomic_t refcnt ____cacheline_aligned_in_smp; 1032 int __percpu *pcpu_refcnt;
1009 1033
1010 /* delayed register/unregister */ 1034 /* delayed register/unregister */
1011 struct list_head todo_list; 1035 struct list_head todo_list;
@@ -1041,10 +1065,14 @@ struct net_device {
1041#endif 1065#endif
1042 1066
1043 /* mid-layer private */ 1067 /* mid-layer private */
1044 void *ml_priv; 1068 union {
1045 1069 void *ml_priv;
1070 struct pcpu_lstats __percpu *lstats; /* loopback stats */
1071 struct pcpu_tstats __percpu *tstats; /* tunnel stats */
1072 struct pcpu_dstats __percpu *dstats; /* dummy stats */
1073 };
1046 /* GARP */ 1074 /* GARP */
1047 struct garp_port *garp_port; 1075 struct garp_port __rcu *garp_port;
1048 1076
1049 /* class/net/name entry */ 1077 /* class/net/name entry */
1050 struct device dev; 1078 struct device dev;
@@ -1305,6 +1333,7 @@ static inline void unregister_netdevice(struct net_device *dev)
1305 unregister_netdevice_queue(dev, NULL); 1333 unregister_netdevice_queue(dev, NULL);
1306} 1334}
1307 1335
1336extern int netdev_refcnt_read(const struct net_device *dev);
1308extern void free_netdev(struct net_device *dev); 1337extern void free_netdev(struct net_device *dev);
1309extern void synchronize_net(void); 1338extern void synchronize_net(void);
1310extern int register_netdevice_notifier(struct notifier_block *nb); 1339extern int register_netdevice_notifier(struct notifier_block *nb);
@@ -1525,6 +1554,11 @@ static inline void netif_tx_wake_all_queues(struct net_device *dev)
1525 1554
1526static inline void netif_tx_stop_queue(struct netdev_queue *dev_queue) 1555static inline void netif_tx_stop_queue(struct netdev_queue *dev_queue)
1527{ 1556{
1557 if (WARN_ON(!dev_queue)) {
1558 printk(KERN_INFO "netif_stop_queue() cannot be called before "
1559 "register_netdev()");
1560 return;
1561 }
1528 set_bit(__QUEUE_STATE_XOFF, &dev_queue->state); 1562 set_bit(__QUEUE_STATE_XOFF, &dev_queue->state);
1529} 1563}
1530 1564
@@ -1667,11 +1701,34 @@ static inline void netif_wake_subqueue(struct net_device *dev, u16 queue_index)
1667 */ 1701 */
1668static inline int netif_is_multiqueue(const struct net_device *dev) 1702static inline int netif_is_multiqueue(const struct net_device *dev)
1669{ 1703{
1670 return (dev->num_tx_queues > 1); 1704 return dev->num_tx_queues > 1;
1671} 1705}
1672 1706
1673extern void netif_set_real_num_tx_queues(struct net_device *dev, 1707extern int netif_set_real_num_tx_queues(struct net_device *dev,
1674 unsigned int txq); 1708 unsigned int txq);
1709
1710#ifdef CONFIG_RPS
1711extern int netif_set_real_num_rx_queues(struct net_device *dev,
1712 unsigned int rxq);
1713#else
1714static inline int netif_set_real_num_rx_queues(struct net_device *dev,
1715 unsigned int rxq)
1716{
1717 return 0;
1718}
1719#endif
1720
1721static inline int netif_copy_real_num_queues(struct net_device *to_dev,
1722 const struct net_device *from_dev)
1723{
1724 netif_set_real_num_tx_queues(to_dev, from_dev->real_num_tx_queues);
1725#ifdef CONFIG_RPS
1726 return netif_set_real_num_rx_queues(to_dev,
1727 from_dev->real_num_rx_queues);
1728#else
1729 return 0;
1730#endif
1731}
1675 1732
1676/* Use this variant when it is known for sure that it 1733/* Use this variant when it is known for sure that it
1677 * is executing from hardware interrupt context or with hardware interrupts 1734 * is executing from hardware interrupt context or with hardware interrupts
@@ -1695,8 +1752,7 @@ extern gro_result_t dev_gro_receive(struct napi_struct *napi,
1695extern gro_result_t napi_skb_finish(gro_result_t ret, struct sk_buff *skb); 1752extern gro_result_t napi_skb_finish(gro_result_t ret, struct sk_buff *skb);
1696extern gro_result_t napi_gro_receive(struct napi_struct *napi, 1753extern gro_result_t napi_gro_receive(struct napi_struct *napi,
1697 struct sk_buff *skb); 1754 struct sk_buff *skb);
1698extern void napi_reuse_skb(struct napi_struct *napi, 1755extern void napi_gro_flush(struct napi_struct *napi);
1699 struct sk_buff *skb);
1700extern struct sk_buff * napi_get_frags(struct napi_struct *napi); 1756extern struct sk_buff * napi_get_frags(struct napi_struct *napi);
1701extern gro_result_t napi_frags_finish(struct napi_struct *napi, 1757extern gro_result_t napi_frags_finish(struct napi_struct *napi,
1702 struct sk_buff *skb, 1758 struct sk_buff *skb,
@@ -1715,7 +1771,6 @@ extern int netdev_rx_handler_register(struct net_device *dev,
1715 void *rx_handler_data); 1771 void *rx_handler_data);
1716extern void netdev_rx_handler_unregister(struct net_device *dev); 1772extern void netdev_rx_handler_unregister(struct net_device *dev);
1717 1773
1718extern void netif_nit_deliver(struct sk_buff *skb);
1719extern int dev_valid_name(const char *name); 1774extern int dev_valid_name(const char *name);
1720extern int dev_ioctl(struct net *net, unsigned int cmd, void __user *); 1775extern int dev_ioctl(struct net *net, unsigned int cmd, void __user *);
1721extern int dev_ethtool(struct net *net, struct ifreq *); 1776extern int dev_ethtool(struct net *net, struct ifreq *);
@@ -1749,7 +1804,7 @@ extern void netdev_run_todo(void);
1749 */ 1804 */
1750static inline void dev_put(struct net_device *dev) 1805static inline void dev_put(struct net_device *dev)
1751{ 1806{
1752 atomic_dec(&dev->refcnt); 1807 irqsafe_cpu_dec(*dev->pcpu_refcnt);
1753} 1808}
1754 1809
1755/** 1810/**
@@ -1760,7 +1815,7 @@ static inline void dev_put(struct net_device *dev)
1760 */ 1815 */
1761static inline void dev_hold(struct net_device *dev) 1816static inline void dev_hold(struct net_device *dev)
1762{ 1817{
1763 atomic_inc(&dev->refcnt); 1818 irqsafe_cpu_inc(*dev->pcpu_refcnt);
1764} 1819}
1765 1820
1766/* Carrier loss detection, dial on demand. The functions netif_carrier_on 1821/* Carrier loss detection, dial on demand. The functions netif_carrier_on
@@ -2171,6 +2226,8 @@ extern void dev_seq_stop(struct seq_file *seq, void *v);
2171extern int netdev_class_create_file(struct class_attribute *class_attr); 2226extern int netdev_class_create_file(struct class_attribute *class_attr);
2172extern void netdev_class_remove_file(struct class_attribute *class_attr); 2227extern void netdev_class_remove_file(struct class_attribute *class_attr);
2173 2228
2229extern struct kobj_ns_type_operations net_ns_type_operations;
2230
2174extern char *netdev_drivername(const struct net_device *dev, char *buffer, int len); 2231extern char *netdev_drivername(const struct net_device *dev, char *buffer, int len);
2175 2232
2176extern void linkwatch_run_queue(void); 2233extern void linkwatch_run_queue(void);
@@ -2191,14 +2248,22 @@ static inline int net_gso_ok(int features, int gso_type)
2191static inline int skb_gso_ok(struct sk_buff *skb, int features) 2248static inline int skb_gso_ok(struct sk_buff *skb, int features)
2192{ 2249{
2193 return net_gso_ok(features, skb_shinfo(skb)->gso_type) && 2250 return net_gso_ok(features, skb_shinfo(skb)->gso_type) &&
2194 (!skb_has_frags(skb) || (features & NETIF_F_FRAGLIST)); 2251 (!skb_has_frag_list(skb) || (features & NETIF_F_FRAGLIST));
2195} 2252}
2196 2253
2197static inline int netif_needs_gso(struct net_device *dev, struct sk_buff *skb) 2254static inline int netif_needs_gso(struct net_device *dev, struct sk_buff *skb)
2198{ 2255{
2199 return skb_is_gso(skb) && 2256 if (skb_is_gso(skb)) {
2200 (!skb_gso_ok(skb, dev->features) || 2257 int features = dev->features;
2201 unlikely(skb->ip_summed != CHECKSUM_PARTIAL)); 2258
2259 if (skb->protocol == htons(ETH_P_8021Q) || skb->vlan_tci)
2260 features &= dev->vlan_features;
2261
2262 return (!skb_gso_ok(skb, features) ||
2263 unlikely(skb->ip_summed != CHECKSUM_PARTIAL));
2264 }
2265
2266 return 0;
2202} 2267}
2203 2268
2204static inline void netif_set_gso_max_size(struct net_device *dev, 2269static inline void netif_set_gso_max_size(struct net_device *dev,