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.h157
1 files changed, 116 insertions, 41 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index daafd9561cbc..775cc956ff78 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -63,13 +63,6 @@ struct wireless_dev;
63void netdev_set_default_ethtool_ops(struct net_device *dev, 63void netdev_set_default_ethtool_ops(struct net_device *dev,
64 const struct ethtool_ops *ops); 64 const struct ethtool_ops *ops);
65 65
66/* hardware address assignment types */
67#define NET_ADDR_PERM 0 /* address is permanent (default) */
68#define NET_ADDR_RANDOM 1 /* address is generated randomly */
69#define NET_ADDR_STOLEN 2 /* address is stolen from other device */
70#define NET_ADDR_SET 3 /* address is set using
71 * dev_set_mac_address() */
72
73/* Backlog congestion levels */ 66/* Backlog congestion levels */
74#define NET_RX_SUCCESS 0 /* keep 'em coming, baby */ 67#define NET_RX_SUCCESS 0 /* keep 'em coming, baby */
75#define NET_RX_DROP 1 /* packet dropped */ 68#define NET_RX_DROP 1 /* packet dropped */
@@ -1037,8 +1030,7 @@ struct net_device_ops {
1037#ifdef CONFIG_NET_POLL_CONTROLLER 1030#ifdef CONFIG_NET_POLL_CONTROLLER
1038 void (*ndo_poll_controller)(struct net_device *dev); 1031 void (*ndo_poll_controller)(struct net_device *dev);
1039 int (*ndo_netpoll_setup)(struct net_device *dev, 1032 int (*ndo_netpoll_setup)(struct net_device *dev,
1040 struct netpoll_info *info, 1033 struct netpoll_info *info);
1041 gfp_t gfp);
1042 void (*ndo_netpoll_cleanup)(struct net_device *dev); 1034 void (*ndo_netpoll_cleanup)(struct net_device *dev);
1043#endif 1035#endif
1044#ifdef CONFIG_NET_RX_BUSY_POLL 1036#ifdef CONFIG_NET_RX_BUSY_POLL
@@ -1147,6 +1139,89 @@ struct net_device_ops {
1147 void *priv); 1139 void *priv);
1148}; 1140};
1149 1141
1142/**
1143 * enum net_device_priv_flags - &struct net_device priv_flags
1144 *
1145 * These are the &struct net_device, they are only set internally
1146 * by drivers and used in the kernel. These flags are invisible to
1147 * userspace, this means that the order of these flags can change
1148 * during any kernel release.
1149 *
1150 * You should have a pretty good reason to be extending these flags.
1151 *
1152 * @IFF_802_1Q_VLAN: 802.1Q VLAN device
1153 * @IFF_EBRIDGE: Ethernet bridging device
1154 * @IFF_SLAVE_INACTIVE: bonding slave not the curr. active
1155 * @IFF_MASTER_8023AD: bonding master, 802.3ad
1156 * @IFF_MASTER_ALB: bonding master, balance-alb
1157 * @IFF_BONDING: bonding master or slave
1158 * @IFF_SLAVE_NEEDARP: need ARPs for validation
1159 * @IFF_ISATAP: ISATAP interface (RFC4214)
1160 * @IFF_MASTER_ARPMON: bonding master, ARP mon in use
1161 * @IFF_WAN_HDLC: WAN HDLC device
1162 * @IFF_XMIT_DST_RELEASE: dev_hard_start_xmit() is allowed to
1163 * release skb->dst
1164 * @IFF_DONT_BRIDGE: disallow bridging this ether dev
1165 * @IFF_DISABLE_NETPOLL: disable netpoll at run-time
1166 * @IFF_MACVLAN_PORT: device used as macvlan port
1167 * @IFF_BRIDGE_PORT: device used as bridge port
1168 * @IFF_OVS_DATAPATH: device used as Open vSwitch datapath port
1169 * @IFF_TX_SKB_SHARING: The interface supports sharing skbs on transmit
1170 * @IFF_UNICAST_FLT: Supports unicast filtering
1171 * @IFF_TEAM_PORT: device used as team port
1172 * @IFF_SUPP_NOFCS: device supports sending custom FCS
1173 * @IFF_LIVE_ADDR_CHANGE: device supports hardware address
1174 * change when it's running
1175 * @IFF_MACVLAN: Macvlan device
1176 */
1177enum netdev_priv_flags {
1178 IFF_802_1Q_VLAN = 1<<0,
1179 IFF_EBRIDGE = 1<<1,
1180 IFF_SLAVE_INACTIVE = 1<<2,
1181 IFF_MASTER_8023AD = 1<<3,
1182 IFF_MASTER_ALB = 1<<4,
1183 IFF_BONDING = 1<<5,
1184 IFF_SLAVE_NEEDARP = 1<<6,
1185 IFF_ISATAP = 1<<7,
1186 IFF_MASTER_ARPMON = 1<<8,
1187 IFF_WAN_HDLC = 1<<9,
1188 IFF_XMIT_DST_RELEASE = 1<<10,
1189 IFF_DONT_BRIDGE = 1<<11,
1190 IFF_DISABLE_NETPOLL = 1<<12,
1191 IFF_MACVLAN_PORT = 1<<13,
1192 IFF_BRIDGE_PORT = 1<<14,
1193 IFF_OVS_DATAPATH = 1<<15,
1194 IFF_TX_SKB_SHARING = 1<<16,
1195 IFF_UNICAST_FLT = 1<<17,
1196 IFF_TEAM_PORT = 1<<18,
1197 IFF_SUPP_NOFCS = 1<<19,
1198 IFF_LIVE_ADDR_CHANGE = 1<<20,
1199 IFF_MACVLAN = 1<<21,
1200};
1201
1202#define IFF_802_1Q_VLAN IFF_802_1Q_VLAN
1203#define IFF_EBRIDGE IFF_EBRIDGE
1204#define IFF_SLAVE_INACTIVE IFF_SLAVE_INACTIVE
1205#define IFF_MASTER_8023AD IFF_MASTER_8023AD
1206#define IFF_MASTER_ALB IFF_MASTER_ALB
1207#define IFF_BONDING IFF_BONDING
1208#define IFF_SLAVE_NEEDARP IFF_SLAVE_NEEDARP
1209#define IFF_ISATAP IFF_ISATAP
1210#define IFF_MASTER_ARPMON IFF_MASTER_ARPMON
1211#define IFF_WAN_HDLC IFF_WAN_HDLC
1212#define IFF_XMIT_DST_RELEASE IFF_XMIT_DST_RELEASE
1213#define IFF_DONT_BRIDGE IFF_DONT_BRIDGE
1214#define IFF_DISABLE_NETPOLL IFF_DISABLE_NETPOLL
1215#define IFF_MACVLAN_PORT IFF_MACVLAN_PORT
1216#define IFF_BRIDGE_PORT IFF_BRIDGE_PORT
1217#define IFF_OVS_DATAPATH IFF_OVS_DATAPATH
1218#define IFF_TX_SKB_SHARING IFF_TX_SKB_SHARING
1219#define IFF_UNICAST_FLT IFF_UNICAST_FLT
1220#define IFF_TEAM_PORT IFF_TEAM_PORT
1221#define IFF_SUPP_NOFCS IFF_SUPP_NOFCS
1222#define IFF_LIVE_ADDR_CHANGE IFF_LIVE_ADDR_CHANGE
1223#define IFF_MACVLAN IFF_MACVLAN
1224
1150/* 1225/*
1151 * The DEVICE structure. 1226 * The DEVICE structure.
1152 * Actually, this whole structure is a big mistake. It mixes I/O 1227 * Actually, this whole structure is a big mistake. It mixes I/O
@@ -1228,9 +1303,13 @@ struct net_device {
1228 int iflink; 1303 int iflink;
1229 1304
1230 struct net_device_stats stats; 1305 struct net_device_stats stats;
1231 atomic_long_t rx_dropped; /* dropped packets by core network 1306
1232 * Do not use this in drivers. 1307 /* dropped packets by core network, Do not use this in drivers */
1233 */ 1308 atomic_long_t rx_dropped;
1309 atomic_long_t tx_dropped;
1310
1311 /* Stats to monitor carrier on<->off transitions */
1312 atomic_t carrier_changes;
1234 1313
1235#ifdef CONFIG_WIRELESS_EXT 1314#ifdef CONFIG_WIRELESS_EXT
1236 /* List of functions to handle Wireless Extensions (instead of ioctl). 1315 /* List of functions to handle Wireless Extensions (instead of ioctl).
@@ -1279,6 +1358,10 @@ struct net_device {
1279 * that share the same link 1358 * that share the same link
1280 * layer address 1359 * layer address
1281 */ 1360 */
1361 unsigned short dev_port; /* Used to differentiate
1362 * devices that share the same
1363 * function
1364 */
1282 spinlock_t addr_list_lock; 1365 spinlock_t addr_list_lock;
1283 struct netdev_hw_addr_list uc; /* Unicast mac addresses */ 1366 struct netdev_hw_addr_list uc; /* Unicast mac addresses */
1284 struct netdev_hw_addr_list mc; /* Multicast mac addresses */ 1367 struct netdev_hw_addr_list mc; /* Multicast mac addresses */
@@ -1316,13 +1399,7 @@ struct net_device {
1316/* 1399/*
1317 * Cache lines mostly used on receive path (including eth_type_trans()) 1400 * Cache lines mostly used on receive path (including eth_type_trans())
1318 */ 1401 */
1319 unsigned long last_rx; /* Time of last Rx 1402 unsigned long last_rx; /* Time of last Rx */
1320 * This should not be set in
1321 * drivers, unless really needed,
1322 * because network stack (bonding)
1323 * use it if/when necessary, to
1324 * avoid dirtying this cache line.
1325 */
1326 1403
1327 /* Interface address info used in eth_type_trans() */ 1404 /* Interface address info used in eth_type_trans() */
1328 unsigned char *dev_addr; /* hw address, (before bcast 1405 unsigned char *dev_addr; /* hw address, (before bcast
@@ -1729,6 +1806,20 @@ struct pcpu_sw_netstats {
1729 struct u64_stats_sync syncp; 1806 struct u64_stats_sync syncp;
1730}; 1807};
1731 1808
1809#define netdev_alloc_pcpu_stats(type) \
1810({ \
1811 typeof(type) __percpu *pcpu_stats = alloc_percpu(type); \
1812 if (pcpu_stats) { \
1813 int i; \
1814 for_each_possible_cpu(i) { \
1815 typeof(type) *stat; \
1816 stat = per_cpu_ptr(pcpu_stats, i); \
1817 u64_stats_init(&stat->syncp); \
1818 } \
1819 } \
1820 pcpu_stats; \
1821})
1822
1732#include <linux/notifier.h> 1823#include <linux/notifier.h>
1733 1824
1734/* netdevice notifier chain. Please remember to update the rtnetlink 1825/* netdevice notifier chain. Please remember to update the rtnetlink
@@ -1884,9 +1975,6 @@ struct net_device *__dev_get_by_index(struct net *net, int ifindex);
1884struct net_device *dev_get_by_index_rcu(struct net *net, int ifindex); 1975struct net_device *dev_get_by_index_rcu(struct net *net, int ifindex);
1885int netdev_get_name(struct net *net, char *name, int ifindex); 1976int netdev_get_name(struct net *net, char *name, int ifindex);
1886int dev_restart(struct net_device *dev); 1977int dev_restart(struct net_device *dev);
1887#ifdef CONFIG_NETPOLL_TRAP
1888int netpoll_trap(void);
1889#endif
1890int skb_gro_receive(struct sk_buff **head, struct sk_buff *skb); 1978int skb_gro_receive(struct sk_buff **head, struct sk_buff *skb);
1891 1979
1892static inline unsigned int skb_gro_offset(const struct sk_buff *skb) 1980static inline unsigned int skb_gro_offset(const struct sk_buff *skb)
@@ -1926,11 +2014,6 @@ static inline void *skb_gro_header_slow(struct sk_buff *skb, unsigned int hlen,
1926 return skb->data + offset; 2014 return skb->data + offset;
1927} 2015}
1928 2016
1929static inline void *skb_gro_mac_header(struct sk_buff *skb)
1930{
1931 return NAPI_GRO_CB(skb)->frag0 ?: skb_mac_header(skb);
1932}
1933
1934static inline void *skb_gro_network_header(struct sk_buff *skb) 2017static inline void *skb_gro_network_header(struct sk_buff *skb)
1935{ 2018{
1936 return (NAPI_GRO_CB(skb)->frag0 ?: skb->data) + 2019 return (NAPI_GRO_CB(skb)->frag0 ?: skb->data) +
@@ -2091,12 +2174,6 @@ static inline void netif_tx_start_all_queues(struct net_device *dev)
2091 2174
2092static inline void netif_tx_wake_queue(struct netdev_queue *dev_queue) 2175static inline void netif_tx_wake_queue(struct netdev_queue *dev_queue)
2093{ 2176{
2094#ifdef CONFIG_NETPOLL_TRAP
2095 if (netpoll_trap()) {
2096 netif_tx_start_queue(dev_queue);
2097 return;
2098 }
2099#endif
2100 if (test_and_clear_bit(__QUEUE_STATE_DRV_XOFF, &dev_queue->state)) 2177 if (test_and_clear_bit(__QUEUE_STATE_DRV_XOFF, &dev_queue->state))
2101 __netif_schedule(dev_queue->qdisc); 2178 __netif_schedule(dev_queue->qdisc);
2102} 2179}
@@ -2340,10 +2417,6 @@ static inline void netif_start_subqueue(struct net_device *dev, u16 queue_index)
2340static inline void netif_stop_subqueue(struct net_device *dev, u16 queue_index) 2417static inline void netif_stop_subqueue(struct net_device *dev, u16 queue_index)
2341{ 2418{
2342 struct netdev_queue *txq = netdev_get_tx_queue(dev, queue_index); 2419 struct netdev_queue *txq = netdev_get_tx_queue(dev, queue_index);
2343#ifdef CONFIG_NETPOLL_TRAP
2344 if (netpoll_trap())
2345 return;
2346#endif
2347 netif_tx_stop_queue(txq); 2420 netif_tx_stop_queue(txq);
2348} 2421}
2349 2422
@@ -2378,10 +2451,6 @@ static inline bool netif_subqueue_stopped(const struct net_device *dev,
2378static inline void netif_wake_subqueue(struct net_device *dev, u16 queue_index) 2451static inline void netif_wake_subqueue(struct net_device *dev, u16 queue_index)
2379{ 2452{
2380 struct netdev_queue *txq = netdev_get_tx_queue(dev, queue_index); 2453 struct netdev_queue *txq = netdev_get_tx_queue(dev, queue_index);
2381#ifdef CONFIG_NETPOLL_TRAP
2382 if (netpoll_trap())
2383 return;
2384#endif
2385 if (test_and_clear_bit(__QUEUE_STATE_DRV_XOFF, &txq->state)) 2454 if (test_and_clear_bit(__QUEUE_STATE_DRV_XOFF, &txq->state))
2386 __netif_schedule(txq->qdisc); 2455 __netif_schedule(txq->qdisc);
2387} 2456}
@@ -2551,6 +2620,7 @@ int dev_get_phys_port_id(struct net_device *dev,
2551int dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev, 2620int dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev,
2552 struct netdev_queue *txq); 2621 struct netdev_queue *txq);
2553int dev_forward_skb(struct net_device *dev, struct sk_buff *skb); 2622int dev_forward_skb(struct net_device *dev, struct sk_buff *skb);
2623bool is_skb_forwardable(struct net_device *dev, struct sk_buff *skb);
2554 2624
2555extern int netdev_budget; 2625extern int netdev_budget;
2556 2626
@@ -2831,6 +2901,11 @@ static inline void netif_tx_unlock_bh(struct net_device *dev)
2831 } \ 2901 } \
2832} 2902}
2833 2903
2904#define HARD_TX_TRYLOCK(dev, txq) \
2905 (((dev->features & NETIF_F_LLTX) == 0) ? \
2906 __netif_tx_trylock(txq) : \
2907 true )
2908
2834#define HARD_TX_UNLOCK(dev, txq) { \ 2909#define HARD_TX_UNLOCK(dev, txq) { \
2835 if ((dev->features & NETIF_F_LLTX) == 0) { \ 2910 if ((dev->features & NETIF_F_LLTX) == 0) { \
2836 __netif_tx_unlock(txq); \ 2911 __netif_tx_unlock(txq); \