]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - net/core/netpoll.c
[CORE] Stack changes to add multiqueue hardware support API
[net-next-2.6.git] / net / core / netpoll.c
index 4581ece48bb24e1308854525306ce4a86f92c56e..4b06d1936375b9789b3ce538933edd2dc1701fba 100644 (file)
@@ -9,7 +9,6 @@
  * Copyright (C) 2002  Red Hat, Inc.
  */
 
-#include <linux/smp_lock.h>
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/string.h>
@@ -67,8 +66,9 @@ static void queue_process(struct work_struct *work)
 
                local_irq_save(flags);
                netif_tx_lock(dev);
-               if (netif_queue_stopped(dev) ||
-                   dev->hard_start_xmit(skb, dev) != NETDEV_TX_OK) {
+               if ((netif_queue_stopped(dev) ||
+                    netif_subqueue_stopped(dev, skb->queue_mapping)) ||
+                    dev->hard_start_xmit(skb, dev) != NETDEV_TX_OK) {
                        skb_queue_head(&npinfo->txq, skb);
                        netif_tx_unlock(dev);
                        local_irq_restore(flags);
@@ -86,7 +86,7 @@ static __sum16 checksum_udp(struct sk_buff *skb, struct udphdr *uh,
 {
        __wsum psum;
 
-       if (uh->check == 0 || skb->ip_summed == CHECKSUM_UNNECESSARY)
+       if (uh->check == 0 || skb_csum_unnecessary(skb))
                return 0;
 
        psum = csum_tcpudp_nofold(saddr, daddr, ulen, IPPROTO_UDP, 0);
@@ -251,22 +251,24 @@ static void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb)
                unsigned long flags;
 
                local_irq_save(flags);
-               if (netif_tx_trylock(dev)) {
-                       /* try until next clock tick */
-                       for (tries = jiffies_to_usecs(1)/USEC_PER_POLL;
-                                       tries > 0; --tries) {
-                               if (!netif_queue_stopped(dev))
+               /* try until next clock tick */
+               for (tries = jiffies_to_usecs(1)/USEC_PER_POLL;
+                    tries > 0; --tries) {
+                       if (netif_tx_trylock(dev)) {
+                               if (!netif_queue_stopped(dev) &&
+                                   !netif_subqueue_stopped(dev, skb->queue_mapping))
                                        status = dev->hard_start_xmit(skb, dev);
+                               netif_tx_unlock(dev);
 
                                if (status == NETDEV_TX_OK)
                                        break;
 
-                               /* tickle device maybe there is some cleanup */
-                               netpoll_poll(np);
-
-                               udelay(USEC_PER_POLL);
                        }
-                       netif_tx_unlock(dev);
+
+                       /* tickle device maybe there is some cleanup */
+                       netpoll_poll(np);
+
+                       udelay(USEC_PER_POLL);
                }
                local_irq_restore(flags);
        }
@@ -293,10 +295,12 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
        if (!skb)
                return;
 
-       memcpy(skb->data, msg, len);
+       skb_copy_to_linear_data(skb, msg, len);
        skb->len += len;
 
-       skb->h.uh = udph = (struct udphdr *) skb_push(skb, sizeof(*udph));
+       skb_push(skb, sizeof(*udph));
+       skb_reset_transport_header(skb);
+       udph = udp_hdr(skb);
        udph->source = htons(np->local_port);
        udph->dest = htons(np->remote_port);
        udph->len = htons(udp_len);
@@ -308,7 +312,9 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
        if (udph->check == 0)
                udph->check = CSUM_MANGLED_0;
 
-       skb->nh.iph = iph = (struct iphdr *)skb_push(skb, sizeof(*iph));
+       skb_push(skb, sizeof(*iph));
+       skb_reset_network_header(skb);
+       iph = ip_hdr(skb);
 
        /* iph->version = 4; iph->ihl = 5; */
        put_unaligned(0x45, (unsigned char *)iph);
@@ -324,7 +330,7 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
        iph->check    = ip_fast_csum((unsigned char *)iph, iph->ihl);
 
        eth = (struct ethhdr *) skb_push(skb, ETH_HLEN);
-       skb->mac.raw = skb->data;
+       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);
@@ -359,8 +365,9 @@ static void arp_reply(struct sk_buff *skb)
                                 (2 * sizeof(u32)))))
                return;
 
-       skb->h.raw = skb->nh.raw = skb->data;
-       arp = skb->nh.arph;
+       skb_reset_network_header(skb);
+       skb_reset_transport_header(skb);
+       arp = arp_hdr(skb);
 
        if ((arp->ar_hrd != htons(ARPHRD_ETHER) &&
             arp->ar_hrd != htons(ARPHRD_IEEE802)) ||
@@ -389,7 +396,7 @@ static void arp_reply(struct sk_buff *skb)
        if (!send_skb)
                return;
 
-       send_skb->nh.raw = send_skb->data;
+       skb_reset_network_header(send_skb);
        arp = (struct arphdr *) skb_put(send_skb, size);
        send_skb->dev = skb->dev;
        send_skb->protocol = htons(ETH_P_ARP);
@@ -443,7 +450,7 @@ int __netpoll_rx(struct sk_buff *skb)
                goto out;
 
        /* check if netpoll clients need ARP */
-       if (skb->protocol == __constant_htons(ETH_P_ARP) &&
+       if (skb->protocol == htons(ETH_P_ARP) &&
            atomic_read(&trapped)) {
                skb_queue_tail(&npi->arp_tx, skb);
                return 1;
@@ -781,8 +788,13 @@ void netpoll_cleanup(struct netpoll *np)
                                skb_queue_purge(&npinfo->arp_tx);
                                skb_queue_purge(&npinfo->txq);
                                cancel_rearming_delayed_work(&npinfo->tx_work);
-                               flush_scheduled_work();
 
+                               /* clean after last, unfinished work */
+                               if (!skb_queue_empty(&npinfo->txq)) {
+                                       struct sk_buff *skb;
+                                       skb = __skb_dequeue(&npinfo->txq);
+                                       kfree_skb(skb);
+                               }
                                kfree(npinfo);
                        }
                }