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.h32
1 files changed, 27 insertions, 5 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 9b0c8f12373e..047d432bde55 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -319,21 +319,29 @@ struct napi_struct {
319enum 319enum
320{ 320{
321 NAPI_STATE_SCHED, /* Poll is scheduled */ 321 NAPI_STATE_SCHED, /* Poll is scheduled */
322 NAPI_STATE_DISABLE, /* Disable pending */
322}; 323};
323 324
324extern void FASTCALL(__napi_schedule(struct napi_struct *n)); 325extern void FASTCALL(__napi_schedule(struct napi_struct *n));
325 326
327static inline int napi_disable_pending(struct napi_struct *n)
328{
329 return test_bit(NAPI_STATE_DISABLE, &n->state);
330}
331
326/** 332/**
327 * napi_schedule_prep - check if napi can be scheduled 333 * napi_schedule_prep - check if napi can be scheduled
328 * @n: napi context 334 * @n: napi context
329 * 335 *
330 * Test if NAPI routine is already running, and if not mark 336 * Test if NAPI routine is already running, and if not mark
331 * it as running. This is used as a condition variable 337 * it as running. This is used as a condition variable
332 * insure only one NAPI poll instance runs 338 * insure only one NAPI poll instance runs. We also make
339 * sure there is no pending NAPI disable.
333 */ 340 */
334static inline int napi_schedule_prep(struct napi_struct *n) 341static inline int napi_schedule_prep(struct napi_struct *n)
335{ 342{
336 return !test_and_set_bit(NAPI_STATE_SCHED, &n->state); 343 return !napi_disable_pending(n) &&
344 !test_and_set_bit(NAPI_STATE_SCHED, &n->state);
337} 345}
338 346
339/** 347/**
@@ -389,8 +397,10 @@ static inline void napi_complete(struct napi_struct *n)
389 */ 397 */
390static inline void napi_disable(struct napi_struct *n) 398static inline void napi_disable(struct napi_struct *n)
391{ 399{
400 set_bit(NAPI_STATE_DISABLE, &n->state);
392 while (test_and_set_bit(NAPI_STATE_SCHED, &n->state)) 401 while (test_and_set_bit(NAPI_STATE_SCHED, &n->state))
393 msleep(1); 402 msleep(1);
403 clear_bit(NAPI_STATE_DISABLE, &n->state);
394} 404}
395 405
396/** 406/**
@@ -739,6 +749,16 @@ static inline void *netdev_priv(const struct net_device *dev)
739 */ 749 */
740#define SET_NETDEV_DEV(net, pdev) ((net)->dev.parent = (pdev)) 750#define SET_NETDEV_DEV(net, pdev) ((net)->dev.parent = (pdev))
741 751
752/**
753 * netif_napi_add - initialize a napi context
754 * @dev: network device
755 * @napi: napi context
756 * @poll: polling function
757 * @weight: default weight
758 *
759 * netif_napi_add() must be used to initialize a napi context prior to calling
760 * *any* of the other napi related functions.
761 */
742static inline void netif_napi_add(struct net_device *dev, 762static inline void netif_napi_add(struct net_device *dev,
743 struct napi_struct *napi, 763 struct napi_struct *napi,
744 int (*poll)(struct napi_struct *, int), 764 int (*poll)(struct napi_struct *, int),
@@ -1258,7 +1278,7 @@ static inline u32 netif_msg_init(int debug_value, int default_msg_enable_bits)
1258static inline int netif_rx_schedule_prep(struct net_device *dev, 1278static inline int netif_rx_schedule_prep(struct net_device *dev,
1259 struct napi_struct *napi) 1279 struct napi_struct *napi)
1260{ 1280{
1261 return netif_running(dev) && napi_schedule_prep(napi); 1281 return napi_schedule_prep(napi);
1262} 1282}
1263 1283
1264/* Add interface to tail of rx poll list. This assumes that _prep has 1284/* Add interface to tail of rx poll list. This assumes that _prep has
@@ -1267,7 +1287,6 @@ static inline int netif_rx_schedule_prep(struct net_device *dev,
1267static inline void __netif_rx_schedule(struct net_device *dev, 1287static inline void __netif_rx_schedule(struct net_device *dev,
1268 struct napi_struct *napi) 1288 struct napi_struct *napi)
1269{ 1289{
1270 dev_hold(dev);
1271 __napi_schedule(napi); 1290 __napi_schedule(napi);
1272} 1291}
1273 1292
@@ -1298,7 +1317,6 @@ static inline void __netif_rx_complete(struct net_device *dev,
1298 struct napi_struct *napi) 1317 struct napi_struct *napi)
1299{ 1318{
1300 __napi_complete(napi); 1319 __napi_complete(napi);
1301 dev_put(dev);
1302} 1320}
1303 1321
1304/* Remove interface from poll list: it must be in the poll list 1322/* Remove interface from poll list: it must be in the poll list
@@ -1396,12 +1414,16 @@ extern void dev_set_rx_mode(struct net_device *dev);
1396extern void __dev_set_rx_mode(struct net_device *dev); 1414extern void __dev_set_rx_mode(struct net_device *dev);
1397extern int dev_unicast_delete(struct net_device *dev, void *addr, int alen); 1415extern int dev_unicast_delete(struct net_device *dev, void *addr, int alen);
1398extern int dev_unicast_add(struct net_device *dev, void *addr, int alen); 1416extern int dev_unicast_add(struct net_device *dev, void *addr, int alen);
1417extern int dev_unicast_sync(struct net_device *to, struct net_device *from);
1418extern void dev_unicast_unsync(struct net_device *to, struct net_device *from);
1399extern int dev_mc_delete(struct net_device *dev, void *addr, int alen, int all); 1419extern int dev_mc_delete(struct net_device *dev, void *addr, int alen, int all);
1400extern int dev_mc_add(struct net_device *dev, void *addr, int alen, int newonly); 1420extern int dev_mc_add(struct net_device *dev, void *addr, int alen, int newonly);
1401extern int dev_mc_sync(struct net_device *to, struct net_device *from); 1421extern int dev_mc_sync(struct net_device *to, struct net_device *from);
1402extern void dev_mc_unsync(struct net_device *to, struct net_device *from); 1422extern void dev_mc_unsync(struct net_device *to, struct net_device *from);
1403extern int __dev_addr_delete(struct dev_addr_list **list, int *count, void *addr, int alen, int all); 1423extern int __dev_addr_delete(struct dev_addr_list **list, int *count, void *addr, int alen, int all);
1404extern int __dev_addr_add(struct dev_addr_list **list, int *count, void *addr, int alen, int newonly); 1424extern int __dev_addr_add(struct dev_addr_list **list, int *count, void *addr, int alen, int newonly);
1425extern int __dev_addr_sync(struct dev_addr_list **to, int *to_count, struct dev_addr_list **from, int *from_count);
1426extern void __dev_addr_unsync(struct dev_addr_list **to, int *to_count, struct dev_addr_list **from, int *from_count);
1405extern void dev_set_promiscuity(struct net_device *dev, int inc); 1427extern void dev_set_promiscuity(struct net_device *dev, int inc);
1406extern void dev_set_allmulti(struct net_device *dev, int inc); 1428extern void dev_set_allmulti(struct net_device *dev, int inc);
1407extern void netdev_state_change(struct net_device *dev); 1429extern void netdev_state_change(struct net_device *dev);