Merge branch 'x86-mm-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux-2.6.git] / net / core / netpoll.c
index ca6dc31..06be243 100644 (file)
@@ -35,7 +35,6 @@
 
 #define MAX_UDP_CHUNK 1460
 #define MAX_SKBS 32
-#define MAX_QUEUE_DEPTH (MAX_SKBS / 2)
 
 static struct sk_buff_head skb_pool;
 
@@ -49,6 +48,7 @@ static atomic_t trapped;
                (MAX_UDP_CHUNK + sizeof(struct udphdr) + \
                                sizeof(struct iphdr) + sizeof(struct ethhdr))
 
+static void zap_completion_queue(void);
 static void arp_reply(struct sk_buff *skb);
 
 static unsigned int carrier_timeout = 4;
@@ -75,8 +75,7 @@ static void queue_process(struct work_struct *work)
 
                local_irq_save(flags);
                __netif_tx_lock(txq, smp_processor_id());
-               if (netif_tx_queue_stopped(txq) ||
-                   netif_tx_queue_frozen(txq) ||
+               if (netif_tx_queue_frozen_or_stopped(txq) ||
                    ops->ndo_start_xmit(skb, dev) != NETDEV_TX_OK) {
                        skb_queue_head(&npinfo->txq, skb);
                        __netif_tx_unlock(txq);
@@ -194,14 +193,28 @@ void netpoll_poll_dev(struct net_device *dev)
 
        poll_napi(dev);
 
+       if (dev->priv_flags & IFF_SLAVE) {
+               if (dev->npinfo) {
+                       struct net_device *bond_dev = dev->master;
+                       struct sk_buff *skb;
+                       while ((skb = skb_dequeue(&dev->npinfo->arp_tx))) {
+                               skb->dev = bond_dev;
+                               skb_queue_tail(&bond_dev->npinfo->arp_tx, skb);
+                       }
+               }
+       }
+
        service_arp_queue(dev->npinfo);
 
+       zap_completion_queue();
 }
+EXPORT_SYMBOL(netpoll_poll_dev);
 
 void netpoll_poll(struct netpoll *np)
 {
        netpoll_poll_dev(np->dev);
 }
+EXPORT_SYMBOL(netpoll_poll);
 
 static void refill_skbs(void)
 {
@@ -219,11 +232,40 @@ static void refill_skbs(void)
        spin_unlock_irqrestore(&skb_pool.lock, flags);
 }
 
+static void zap_completion_queue(void)
+{
+       unsigned long flags;
+       struct softnet_data *sd = &get_cpu_var(softnet_data);
+
+       if (sd->completion_queue) {
+               struct sk_buff *clist;
+
+               local_irq_save(flags);
+               clist = sd->completion_queue;
+               sd->completion_queue = NULL;
+               local_irq_restore(flags);
+
+               while (clist != NULL) {
+                       struct sk_buff *skb = clist;
+                       clist = clist->next;
+                       if (skb->destructor) {
+                               atomic_inc(&skb->users);
+                               dev_kfree_skb_any(skb); /* put this one back */
+                       } else {
+                               __kfree_skb(skb);
+                       }
+               }
+       }
+
+       put_cpu_var(softnet_data);
+}
+
 static struct sk_buff *find_skb(struct netpoll *np, int len, int reserve)
 {
        int count = 0;
        struct sk_buff *skb;
 
+       zap_completion_queue();
        refill_skbs();
 repeat:
 
@@ -255,11 +297,11 @@ static int netpoll_owner_active(struct net_device *dev)
        return 0;
 }
 
-void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb)
+void netpoll_send_skb_on_dev(struct netpoll *np, struct sk_buff *skb,
+                            struct net_device *dev)
 {
        int status = NETDEV_TX_BUSY;
        unsigned long tries;
-       struct net_device *dev = np->dev;
        const struct net_device_ops *ops = dev->netdev_ops;
        /* It is up to the caller to keep npinfo alive. */
        struct netpoll_info *npinfo = np->dev->npinfo;
@@ -282,9 +324,7 @@ void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb)
                     tries > 0; --tries) {
                        if (__netif_tx_trylock(txq)) {
                                if (!netif_tx_queue_stopped(txq)) {
-                                       dev->priv_flags |= IFF_IN_NETPOLL;
                                        status = ops->ndo_start_xmit(skb, dev);
-                                       dev->priv_flags &= ~IFF_IN_NETPOLL;
                                        if (status == NETDEV_TX_OK)
                                                txq_trans_update(txq);
                                }
@@ -313,6 +353,7 @@ void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb)
                schedule_delayed_work(&npinfo->tx_work,0);
        }
 }
+EXPORT_SYMBOL(netpoll_send_skb_on_dev);
 
 void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
 {
@@ -374,6 +415,7 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
 
        netpoll_send_skb(np, skb);
 }
+EXPORT_SYMBOL(netpoll_send_udp);
 
 static void arp_reply(struct sk_buff *skb)
 {
@@ -600,6 +642,7 @@ void netpoll_print_options(struct netpoll *np)
        printk(KERN_INFO "%s: remote ethernet address %pM\n",
                         np->name, np->remote_mac);
 }
+EXPORT_SYMBOL(netpoll_print_options);
 
 int netpoll_parse_options(struct netpoll *np, char *opt)
 {
@@ -692,6 +735,7 @@ int netpoll_parse_options(struct netpoll *np, char *opt)
               np->name, cur);
        return -1;
 }
+EXPORT_SYMBOL(netpoll_parse_options);
 
 int __netpoll_setup(struct netpoll *np)
 {
@@ -848,6 +892,7 @@ put:
        dev_put(ndev);
        return err;
 }
+EXPORT_SYMBOL(netpoll_setup);
 
 static int __init netpoll_init(void)
 {
@@ -887,7 +932,7 @@ void __netpoll_cleanup(struct netpoll *np)
 
                skb_queue_purge(&npinfo->arp_tx);
                skb_queue_purge(&npinfo->txq);
-               cancel_rearming_delayed_work(&npinfo->tx_work);
+               cancel_delayed_work_sync(&npinfo->tx_work);
 
                /* clean after last, unfinished work */
                __skb_queue_purge(&npinfo->txq);
@@ -908,11 +953,13 @@ void netpoll_cleanup(struct netpoll *np)
        dev_put(np->dev);
        np->dev = NULL;
 }
+EXPORT_SYMBOL(netpoll_cleanup);
 
 int netpoll_trap(void)
 {
        return atomic_read(&trapped);
 }
+EXPORT_SYMBOL(netpoll_trap);
 
 void netpoll_set_trap(int trap)
 {
@@ -921,14 +968,4 @@ void netpoll_set_trap(int trap)
        else
                atomic_dec(&trapped);
 }
-
-EXPORT_SYMBOL(netpoll_send_skb);
 EXPORT_SYMBOL(netpoll_set_trap);
-EXPORT_SYMBOL(netpoll_trap);
-EXPORT_SYMBOL(netpoll_print_options);
-EXPORT_SYMBOL(netpoll_parse_options);
-EXPORT_SYMBOL(netpoll_setup);
-EXPORT_SYMBOL(netpoll_cleanup);
-EXPORT_SYMBOL(netpoll_send_udp);
-EXPORT_SYMBOL(netpoll_poll_dev);
-EXPORT_SYMBOL(netpoll_poll);