aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorStephen Hemminger <shemminger@linux-foundation.org>2007-11-19 22:18:11 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 17:54:16 -0500
commit5106930bd6b57402205e3de54dae9476e215b622 (patch)
tree180a77fe9a8bed0718a849ac91c4bc7866912a1e /net
parent0adc9add7709f87995c003c0ccb085076afdc923 (diff)
[NETPOLL]: netpoll_poll() cleanup
Restructure code slightly to improve readability: * dereference device once * change obvious while() loop * let poll_napi() handle null list itself Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/core/netpoll.c32
1 files changed, 14 insertions, 18 deletions
diff --git a/net/core/netpoll.c b/net/core/netpoll.c
index f63a70be3cd0..250868f68762 100644
--- a/net/core/netpoll.c
+++ b/net/core/netpoll.c
@@ -139,16 +139,15 @@ static int poll_one_napi(struct netpoll_info *npinfo,
139 return budget - work; 139 return budget - work;
140} 140}
141 141
142static void poll_napi(struct netpoll *np) 142static void poll_napi(struct net_device *dev)
143{ 143{
144 struct netpoll_info *npinfo = np->dev->npinfo;
145 struct napi_struct *napi; 144 struct napi_struct *napi;
146 int budget = 16; 145 int budget = 16;
147 146
148 list_for_each_entry(napi, &np->dev->napi_list, dev_list) { 147 list_for_each_entry(napi, &dev->napi_list, dev_list) {
149 if (napi->poll_owner != smp_processor_id() && 148 if (napi->poll_owner != smp_processor_id() &&
150 spin_trylock(&napi->poll_lock)) { 149 spin_trylock(&napi->poll_lock)) {
151 budget = poll_one_napi(npinfo, napi, budget); 150 budget = poll_one_napi(dev->npinfo, napi, budget);
152 spin_unlock(&napi->poll_lock); 151 spin_unlock(&napi->poll_lock);
153 152
154 if (!budget) 153 if (!budget)
@@ -159,30 +158,27 @@ static void poll_napi(struct netpoll *np)
159 158
160static void service_arp_queue(struct netpoll_info *npi) 159static void service_arp_queue(struct netpoll_info *npi)
161{ 160{
162 struct sk_buff *skb; 161 if (npi) {
163 162 struct sk_buff *skb;
164 if (unlikely(!npi))
165 return;
166 163
167 skb = skb_dequeue(&npi->arp_tx); 164 while ((skb = skb_dequeue(&npi->arp_tx)))
168 165 arp_reply(skb);
169 while (skb != NULL) {
170 arp_reply(skb);
171 skb = skb_dequeue(&npi->arp_tx);
172 } 166 }
173} 167}
174 168
175void netpoll_poll(struct netpoll *np) 169void netpoll_poll(struct netpoll *np)
176{ 170{
177 if (!np->dev || !netif_running(np->dev) || !np->dev->poll_controller) 171 struct net_device *dev = np->dev;
172
173 if (!dev || !netif_running(dev) || !dev->poll_controller)
178 return; 174 return;
179 175
180 /* Process pending work on NIC */ 176 /* Process pending work on NIC */
181 np->dev->poll_controller(np->dev); 177 dev->poll_controller(dev);
182 if (!list_empty(&np->dev->napi_list)) 178
183 poll_napi(np); 179 poll_napi(dev);
184 180
185 service_arp_queue(np->dev->npinfo); 181 service_arp_queue(dev->npinfo);
186 182
187 zap_completion_queue(); 183 zap_completion_queue();
188} 184}