diff options
Diffstat (limited to 'include/linux/netpoll.h')
-rw-r--r-- | include/linux/netpoll.h | 56 |
1 files changed, 42 insertions, 14 deletions
diff --git a/include/linux/netpoll.h b/include/linux/netpoll.h index 29930b71a9aa..20250d963d72 100644 --- a/include/linux/netpoll.h +++ b/include/linux/netpoll.h | |||
@@ -25,8 +25,6 @@ struct netpoll { | |||
25 | 25 | ||
26 | struct netpoll_info { | 26 | struct netpoll_info { |
27 | atomic_t refcnt; | 27 | atomic_t refcnt; |
28 | spinlock_t poll_lock; | ||
29 | int poll_owner; | ||
30 | int rx_flags; | 28 | int rx_flags; |
31 | spinlock_t rx_lock; | 29 | spinlock_t rx_lock; |
32 | struct netpoll *rx_np; /* netpoll that registered an rx_hook */ | 30 | struct netpoll *rx_np; /* netpoll that registered an rx_hook */ |
@@ -37,6 +35,7 @@ struct netpoll_info { | |||
37 | 35 | ||
38 | void netpoll_poll(struct netpoll *np); | 36 | void netpoll_poll(struct netpoll *np); |
39 | void netpoll_send_udp(struct netpoll *np, const char *msg, int len); | 37 | void netpoll_send_udp(struct netpoll *np, const char *msg, int len); |
38 | void netpoll_print_options(struct netpoll *np); | ||
40 | int netpoll_parse_options(struct netpoll *np, char *opt); | 39 | int netpoll_parse_options(struct netpoll *np, char *opt); |
41 | int netpoll_setup(struct netpoll *np); | 40 | int netpoll_setup(struct netpoll *np); |
42 | int netpoll_trap(void); | 41 | int netpoll_trap(void); |
@@ -64,32 +63,61 @@ static inline int netpoll_rx(struct sk_buff *skb) | |||
64 | return ret; | 63 | return ret; |
65 | } | 64 | } |
66 | 65 | ||
67 | static inline void *netpoll_poll_lock(struct net_device *dev) | 66 | static inline int netpoll_receive_skb(struct sk_buff *skb) |
68 | { | 67 | { |
68 | if (!list_empty(&skb->dev->napi_list)) | ||
69 | return netpoll_rx(skb); | ||
70 | return 0; | ||
71 | } | ||
72 | |||
73 | static inline void *netpoll_poll_lock(struct napi_struct *napi) | ||
74 | { | ||
75 | struct net_device *dev = napi->dev; | ||
76 | |||
69 | rcu_read_lock(); /* deal with race on ->npinfo */ | 77 | rcu_read_lock(); /* deal with race on ->npinfo */ |
70 | if (dev->npinfo) { | 78 | if (dev && dev->npinfo) { |
71 | spin_lock(&dev->npinfo->poll_lock); | 79 | spin_lock(&napi->poll_lock); |
72 | dev->npinfo->poll_owner = smp_processor_id(); | 80 | napi->poll_owner = smp_processor_id(); |
73 | return dev->npinfo; | 81 | return napi; |
74 | } | 82 | } |
75 | return NULL; | 83 | return NULL; |
76 | } | 84 | } |
77 | 85 | ||
78 | static inline void netpoll_poll_unlock(void *have) | 86 | static inline void netpoll_poll_unlock(void *have) |
79 | { | 87 | { |
80 | struct netpoll_info *npi = have; | 88 | struct napi_struct *napi = have; |
81 | 89 | ||
82 | if (npi) { | 90 | if (napi) { |
83 | npi->poll_owner = -1; | 91 | napi->poll_owner = -1; |
84 | spin_unlock(&npi->poll_lock); | 92 | spin_unlock(&napi->poll_lock); |
85 | } | 93 | } |
86 | rcu_read_unlock(); | 94 | rcu_read_unlock(); |
87 | } | 95 | } |
88 | 96 | ||
97 | static inline void netpoll_netdev_init(struct net_device *dev) | ||
98 | { | ||
99 | INIT_LIST_HEAD(&dev->napi_list); | ||
100 | } | ||
101 | |||
89 | #else | 102 | #else |
90 | #define netpoll_rx(a) 0 | 103 | static inline int netpoll_rx(struct sk_buff *skb) |
91 | #define netpoll_poll_lock(a) NULL | 104 | { |
92 | #define netpoll_poll_unlock(a) | 105 | return 0; |
106 | } | ||
107 | static inline int netpoll_receive_skb(struct sk_buff *skb) | ||
108 | { | ||
109 | return 0; | ||
110 | } | ||
111 | static inline void *netpoll_poll_lock(struct napi_struct *napi) | ||
112 | { | ||
113 | return NULL; | ||
114 | } | ||
115 | static inline void netpoll_poll_unlock(void *have) | ||
116 | { | ||
117 | } | ||
118 | static inline void netpoll_netdev_init(struct net_device *dev) | ||
119 | { | ||
120 | } | ||
93 | #endif | 121 | #endif |
94 | 122 | ||
95 | #endif | 123 | #endif |