]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/core/netpoll.c
Merge current mainline tree into linux-omap tree
[linux-2.6-omap-h63xx.git] / net / core / netpoll.c
index c499b5c69bedbce96611baaec02eb9cfcb0798a6..c635de52526c9ddcd155cbf12d87b315a116c80f 100644 (file)
@@ -139,16 +139,15 @@ static int poll_one_napi(struct netpoll_info *npinfo,
        return budget - work;
 }
 
-static void poll_napi(struct netpoll *np)
+static void poll_napi(struct net_device *dev)
 {
-       struct netpoll_info *npinfo = np->dev->npinfo;
        struct napi_struct *napi;
        int budget = 16;
 
-       list_for_each_entry(napi, &np->dev->napi_list, dev_list) {
+       list_for_each_entry(napi, &dev->napi_list, dev_list) {
                if (napi->poll_owner != smp_processor_id() &&
                    spin_trylock(&napi->poll_lock)) {
-                       budget = poll_one_napi(npinfo, napi, budget);
+                       budget = poll_one_napi(dev->npinfo, napi, budget);
                        spin_unlock(&napi->poll_lock);
 
                        if (!budget)
@@ -159,30 +158,27 @@ static void poll_napi(struct netpoll *np)
 
 static void service_arp_queue(struct netpoll_info *npi)
 {
-       struct sk_buff *skb;
-
-       if (unlikely(!npi))
-               return;
-
-       skb = skb_dequeue(&npi->arp_tx);
+       if (npi) {
+               struct sk_buff *skb;
 
-       while (skb != NULL) {
-               arp_reply(skb);
-               skb = skb_dequeue(&npi->arp_tx);
+               while ((skb = skb_dequeue(&npi->arp_tx)))
+                       arp_reply(skb);
        }
 }
 
 void netpoll_poll(struct netpoll *np)
 {
-       if (!np->dev || !netif_running(np->dev) || !np->dev->poll_controller)
+       struct net_device *dev = np->dev;
+
+       if (!dev || !netif_running(dev) || !dev->poll_controller)
                return;
 
        /* Process pending work on NIC */
-       np->dev->poll_controller(np->dev);
-       if (!list_empty(&np->dev->napi_list))
-               poll_napi(np);
+       dev->poll_controller(dev);
+
+       poll_napi(dev);
 
-       service_arp_queue(np->dev->npinfo);
+       service_arp_queue(dev->npinfo);
 
        zap_completion_queue();
 }
@@ -219,10 +215,12 @@ static void zap_completion_queue(void)
                while (clist != NULL) {
                        struct sk_buff *skb = clist;
                        clist = clist->next;
-                       if (skb->destructor)
+                       if (skb->destructor) {
+                               atomic_inc(&skb->users);
                                dev_kfree_skb_any(skb); /* put this one back */
-                       else
+                       } else {
                                __kfree_skb(skb);
+                       }
                }
        }
 
@@ -364,8 +362,8 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
        eth = (struct ethhdr *) skb_push(skb, ETH_HLEN);
        skb_reset_mac_header(skb);
        skb->protocol = eth->h_proto = htons(ETH_P_IP);
-       memcpy(eth->h_source, np->local_mac, 6);
-       memcpy(eth->h_dest, np->remote_mac, 6);
+       memcpy(eth->h_source, np->dev->dev_addr, ETH_ALEN);
+       memcpy(eth->h_dest, np->remote_mac, ETH_ALEN);
 
        skb->dev = np->dev;
 
@@ -418,7 +416,8 @@ static void arp_reply(struct sk_buff *skb)
        memcpy(&tip, arp_ptr, 4);
 
        /* Should we ignore arp? */
-       if (tip != htonl(np->local_ip) || LOOPBACK(tip) || MULTICAST(tip))
+       if (tip != htonl(np->local_ip) ||
+           ipv4_is_loopback(tip) || ipv4_is_multicast(tip))
                return;
 
        size = sizeof(struct arphdr) + 2 * (skb->dev->addr_len + 4);
@@ -435,7 +434,7 @@ static void arp_reply(struct sk_buff *skb)
 
        /* Fill the device header for the ARP frame */
        if (dev_hard_header(send_skb, skb->dev, ptype,
-                           sha, np->local_mac,
+                           sha, np->dev->dev_addr,
                            send_skb->len) < 0) {
                kfree_skb(send_skb);
                return;
@@ -741,9 +740,6 @@ int netpoll_setup(struct netpoll *np)
                }
        }
 
-       if (is_zero_ether_addr(np->local_mac) && ndev->dev_addr)
-               memcpy(np->local_mac, ndev->dev_addr, 6);
-
        if (!np->local_ip) {
                rcu_read_lock();
                in_dev = __in_dev_get_rcu(ndev);
@@ -816,11 +812,7 @@ void netpoll_cleanup(struct netpoll *np)
                                cancel_rearming_delayed_work(&npinfo->tx_work);
 
                                /* clean after last, unfinished work */
-                               if (!skb_queue_empty(&npinfo->txq)) {
-                                       struct sk_buff *skb;
-                                       skb = __skb_dequeue(&npinfo->txq);
-                                       kfree_skb(skb);
-                               }
+                               __skb_queue_purge(&npinfo->txq);
                                kfree(npinfo);
                                np->dev->npinfo = NULL;
                        }