aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/netpoll.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/netpoll.h')
-rw-r--r--include/linux/netpoll.h26
1 files changed, 20 insertions, 6 deletions
diff --git a/include/linux/netpoll.h b/include/linux/netpoll.h
index e9e231215865..791d5109f34c 100644
--- a/include/linux/netpoll.h
+++ b/include/linux/netpoll.h
@@ -46,9 +46,11 @@ void netpoll_poll(struct netpoll *np);
46void netpoll_send_udp(struct netpoll *np, const char *msg, int len); 46void netpoll_send_udp(struct netpoll *np, const char *msg, int len);
47void netpoll_print_options(struct netpoll *np); 47void netpoll_print_options(struct netpoll *np);
48int netpoll_parse_options(struct netpoll *np, char *opt); 48int netpoll_parse_options(struct netpoll *np, char *opt);
49int __netpoll_setup(struct netpoll *np);
49int netpoll_setup(struct netpoll *np); 50int netpoll_setup(struct netpoll *np);
50int netpoll_trap(void); 51int netpoll_trap(void);
51void netpoll_set_trap(int trap); 52void netpoll_set_trap(int trap);
53void __netpoll_cleanup(struct netpoll *np);
52void netpoll_cleanup(struct netpoll *np); 54void netpoll_cleanup(struct netpoll *np);
53int __netpoll_rx(struct sk_buff *skb); 55int __netpoll_rx(struct sk_buff *skb);
54void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb); 56void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb);
@@ -57,12 +59,15 @@ void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb);
57#ifdef CONFIG_NETPOLL 59#ifdef CONFIG_NETPOLL
58static inline bool netpoll_rx(struct sk_buff *skb) 60static inline bool netpoll_rx(struct sk_buff *skb)
59{ 61{
60 struct netpoll_info *npinfo = skb->dev->npinfo; 62 struct netpoll_info *npinfo;
61 unsigned long flags; 63 unsigned long flags;
62 bool ret = false; 64 bool ret = false;
63 65
66 rcu_read_lock_bh();
67 npinfo = rcu_dereference_bh(skb->dev->npinfo);
68
64 if (!npinfo || (list_empty(&npinfo->rx_np) && !npinfo->rx_flags)) 69 if (!npinfo || (list_empty(&npinfo->rx_np) && !npinfo->rx_flags))
65 return false; 70 goto out;
66 71
67 spin_lock_irqsave(&npinfo->rx_lock, flags); 72 spin_lock_irqsave(&npinfo->rx_lock, flags);
68 /* check rx_flags again with the lock held */ 73 /* check rx_flags again with the lock held */
@@ -70,12 +75,14 @@ static inline bool netpoll_rx(struct sk_buff *skb)
70 ret = true; 75 ret = true;
71 spin_unlock_irqrestore(&npinfo->rx_lock, flags); 76 spin_unlock_irqrestore(&npinfo->rx_lock, flags);
72 77
78out:
79 rcu_read_unlock_bh();
73 return ret; 80 return ret;
74} 81}
75 82
76static inline int netpoll_rx_on(struct sk_buff *skb) 83static inline int netpoll_rx_on(struct sk_buff *skb)
77{ 84{
78 struct netpoll_info *npinfo = skb->dev->npinfo; 85 struct netpoll_info *npinfo = rcu_dereference_bh(skb->dev->npinfo);
79 86
80 return npinfo && (!list_empty(&npinfo->rx_np) || npinfo->rx_flags); 87 return npinfo && (!list_empty(&npinfo->rx_np) || npinfo->rx_flags);
81} 88}
@@ -91,7 +98,6 @@ static inline void *netpoll_poll_lock(struct napi_struct *napi)
91{ 98{
92 struct net_device *dev = napi->dev; 99 struct net_device *dev = napi->dev;
93 100
94 rcu_read_lock(); /* deal with race on ->npinfo */
95 if (dev && dev->npinfo) { 101 if (dev && dev->npinfo) {
96 spin_lock(&napi->poll_lock); 102 spin_lock(&napi->poll_lock);
97 napi->poll_owner = smp_processor_id(); 103 napi->poll_owner = smp_processor_id();
@@ -108,11 +114,15 @@ static inline void netpoll_poll_unlock(void *have)
108 napi->poll_owner = -1; 114 napi->poll_owner = -1;
109 spin_unlock(&napi->poll_lock); 115 spin_unlock(&napi->poll_lock);
110 } 116 }
111 rcu_read_unlock(); 117}
118
119static inline int netpoll_tx_running(struct net_device *dev)
120{
121 return irqs_disabled();
112} 122}
113 123
114#else 124#else
115static inline int netpoll_rx(struct sk_buff *skb) 125static inline bool netpoll_rx(struct sk_buff *skb)
116{ 126{
117 return 0; 127 return 0;
118} 128}
@@ -134,6 +144,10 @@ static inline void netpoll_poll_unlock(void *have)
134static inline void netpoll_netdev_init(struct net_device *dev) 144static inline void netpoll_netdev_init(struct net_device *dev)
135{ 145{
136} 146}
147static inline int netpoll_tx_running(struct net_device *dev)
148{
149 return 0;
150}
137#endif 151#endif
138 152
139#endif 153#endif