diff options
Diffstat (limited to 'include/linux/netpoll.h')
-rw-r--r-- | include/linux/netpoll.h | 41 |
1 files changed, 30 insertions, 11 deletions
diff --git a/include/linux/netpoll.h b/include/linux/netpoll.h index a765ea898549..50d8009be86c 100644 --- a/include/linux/netpoll.h +++ b/include/linux/netpoll.h | |||
@@ -14,6 +14,7 @@ | |||
14 | 14 | ||
15 | struct netpoll { | 15 | struct netpoll { |
16 | struct net_device *dev; | 16 | struct net_device *dev; |
17 | struct net_device *real_dev; | ||
17 | char dev_name[IFNAMSIZ]; | 18 | char dev_name[IFNAMSIZ]; |
18 | const char *name; | 19 | const char *name; |
19 | void (*rx_hook)(struct netpoll *, int, char *, int); | 20 | void (*rx_hook)(struct netpoll *, int, char *, int); |
@@ -36,41 +37,52 @@ struct netpoll_info { | |||
36 | struct sk_buff_head txq; | 37 | struct sk_buff_head txq; |
37 | 38 | ||
38 | struct delayed_work tx_work; | 39 | struct delayed_work tx_work; |
40 | |||
41 | struct netpoll *netpoll; | ||
39 | }; | 42 | }; |
40 | 43 | ||
44 | void netpoll_poll_dev(struct net_device *dev); | ||
41 | void netpoll_poll(struct netpoll *np); | 45 | void netpoll_poll(struct netpoll *np); |
42 | 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); |
43 | void netpoll_print_options(struct netpoll *np); | 47 | void netpoll_print_options(struct netpoll *np); |
44 | 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); | ||
45 | int netpoll_setup(struct netpoll *np); | 50 | int netpoll_setup(struct netpoll *np); |
46 | int netpoll_trap(void); | 51 | int netpoll_trap(void); |
47 | void netpoll_set_trap(int trap); | 52 | void netpoll_set_trap(int trap); |
53 | void __netpoll_cleanup(struct netpoll *np); | ||
48 | void netpoll_cleanup(struct netpoll *np); | 54 | void netpoll_cleanup(struct netpoll *np); |
49 | int __netpoll_rx(struct sk_buff *skb); | 55 | int __netpoll_rx(struct sk_buff *skb); |
56 | void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb); | ||
50 | 57 | ||
51 | 58 | ||
52 | #ifdef CONFIG_NETPOLL | 59 | #ifdef CONFIG_NETPOLL |
53 | static inline int netpoll_rx(struct sk_buff *skb) | 60 | static inline bool netpoll_rx(struct sk_buff *skb) |
54 | { | 61 | { |
55 | struct netpoll_info *npinfo = skb->dev->npinfo; | 62 | struct netpoll_info *npinfo; |
56 | unsigned long flags; | 63 | unsigned long flags; |
57 | int ret = 0; | 64 | bool ret = false; |
65 | |||
66 | local_irq_save(flags); | ||
67 | npinfo = rcu_dereference_bh(skb->dev->npinfo); | ||
58 | 68 | ||
59 | if (!npinfo || (list_empty(&npinfo->rx_np) && !npinfo->rx_flags)) | 69 | if (!npinfo || (list_empty(&npinfo->rx_np) && !npinfo->rx_flags)) |
60 | return 0; | 70 | goto out; |
61 | 71 | ||
62 | spin_lock_irqsave(&npinfo->rx_lock, flags); | 72 | spin_lock(&npinfo->rx_lock); |
63 | /* check rx_flags again with the lock held */ | 73 | /* check rx_flags again with the lock held */ |
64 | if (npinfo->rx_flags && __netpoll_rx(skb)) | 74 | if (npinfo->rx_flags && __netpoll_rx(skb)) |
65 | ret = 1; | 75 | ret = true; |
66 | spin_unlock_irqrestore(&npinfo->rx_lock, flags); | 76 | spin_unlock(&npinfo->rx_lock); |
67 | 77 | ||
78 | out: | ||
79 | local_irq_restore(flags); | ||
68 | return ret; | 80 | return ret; |
69 | } | 81 | } |
70 | 82 | ||
71 | static inline int netpoll_rx_on(struct sk_buff *skb) | 83 | static inline int netpoll_rx_on(struct sk_buff *skb) |
72 | { | 84 | { |
73 | struct netpoll_info *npinfo = skb->dev->npinfo; | 85 | struct netpoll_info *npinfo = rcu_dereference_bh(skb->dev->npinfo); |
74 | 86 | ||
75 | return npinfo && (!list_empty(&npinfo->rx_np) || npinfo->rx_flags); | 87 | return npinfo && (!list_empty(&npinfo->rx_np) || npinfo->rx_flags); |
76 | } | 88 | } |
@@ -86,7 +98,6 @@ static inline void *netpoll_poll_lock(struct napi_struct *napi) | |||
86 | { | 98 | { |
87 | struct net_device *dev = napi->dev; | 99 | struct net_device *dev = napi->dev; |
88 | 100 | ||
89 | rcu_read_lock(); /* deal with race on ->npinfo */ | ||
90 | if (dev && dev->npinfo) { | 101 | if (dev && dev->npinfo) { |
91 | spin_lock(&napi->poll_lock); | 102 | spin_lock(&napi->poll_lock); |
92 | napi->poll_owner = smp_processor_id(); | 103 | napi->poll_owner = smp_processor_id(); |
@@ -103,11 +114,15 @@ static inline void netpoll_poll_unlock(void *have) | |||
103 | napi->poll_owner = -1; | 114 | napi->poll_owner = -1; |
104 | spin_unlock(&napi->poll_lock); | 115 | spin_unlock(&napi->poll_lock); |
105 | } | 116 | } |
106 | rcu_read_unlock(); | 117 | } |
118 | |||
119 | static inline int netpoll_tx_running(struct net_device *dev) | ||
120 | { | ||
121 | return irqs_disabled(); | ||
107 | } | 122 | } |
108 | 123 | ||
109 | #else | 124 | #else |
110 | static inline int netpoll_rx(struct sk_buff *skb) | 125 | static inline bool netpoll_rx(struct sk_buff *skb) |
111 | { | 126 | { |
112 | return 0; | 127 | return 0; |
113 | } | 128 | } |
@@ -129,6 +144,10 @@ static inline void netpoll_poll_unlock(void *have) | |||
129 | static inline void netpoll_netdev_init(struct net_device *dev) | 144 | static inline void netpoll_netdev_init(struct net_device *dev) |
130 | { | 145 | { |
131 | } | 146 | } |
147 | static inline int netpoll_tx_running(struct net_device *dev) | ||
148 | { | ||
149 | return 0; | ||
150 | } | ||
132 | #endif | 151 | #endif |
133 | 152 | ||
134 | #endif | 153 | #endif |