diff options
Diffstat (limited to 'include/linux/netpoll.h')
-rw-r--r-- | include/linux/netpoll.h | 26 |
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); | |||
46 | void netpoll_send_udp(struct netpoll *np, const char *msg, int len); | 46 | void netpoll_send_udp(struct netpoll *np, const char *msg, int len); |
47 | void netpoll_print_options(struct netpoll *np); | 47 | void netpoll_print_options(struct netpoll *np); |
48 | int netpoll_parse_options(struct netpoll *np, char *opt); | 48 | int netpoll_parse_options(struct netpoll *np, char *opt); |
49 | int __netpoll_setup(struct netpoll *np); | ||
49 | int netpoll_setup(struct netpoll *np); | 50 | int netpoll_setup(struct netpoll *np); |
50 | int netpoll_trap(void); | 51 | int netpoll_trap(void); |
51 | void netpoll_set_trap(int trap); | 52 | void netpoll_set_trap(int trap); |
53 | void __netpoll_cleanup(struct netpoll *np); | ||
52 | void netpoll_cleanup(struct netpoll *np); | 54 | void netpoll_cleanup(struct netpoll *np); |
53 | int __netpoll_rx(struct sk_buff *skb); | 55 | int __netpoll_rx(struct sk_buff *skb); |
54 | void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb); | 56 | void 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 |
58 | static inline bool netpoll_rx(struct sk_buff *skb) | 60 | static 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 | ||
78 | out: | ||
79 | rcu_read_unlock_bh(); | ||
73 | return ret; | 80 | return ret; |
74 | } | 81 | } |
75 | 82 | ||
76 | static inline int netpoll_rx_on(struct sk_buff *skb) | 83 | static 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 | |||
119 | static inline int netpoll_tx_running(struct net_device *dev) | ||
120 | { | ||
121 | return irqs_disabled(); | ||
112 | } | 122 | } |
113 | 123 | ||
114 | #else | 124 | #else |
115 | static inline int netpoll_rx(struct sk_buff *skb) | 125 | static 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) | |||
134 | static inline void netpoll_netdev_init(struct net_device *dev) | 144 | static inline void netpoll_netdev_init(struct net_device *dev) |
135 | { | 145 | { |
136 | } | 146 | } |
147 | static inline int netpoll_tx_running(struct net_device *dev) | ||
148 | { | ||
149 | return 0; | ||
150 | } | ||
137 | #endif | 151 | #endif |
138 | 152 | ||
139 | #endif | 153 | #endif |