proc: remove docbook and example
[safe/jmp/linux-2.6] / net / core / netpoll.c
index b5873bd..0b4d0d3 100644 (file)
@@ -9,6 +9,7 @@
  * Copyright (C) 2002  Red Hat, Inc.
  */
 
+#include <linux/moduleparam.h>
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/string.h>
@@ -24,6 +25,7 @@
 #include <net/tcp.h>
 #include <net/udp.h>
 #include <asm/unaligned.h>
+#include <trace/events/napi.h>
 
 /*
  * We maintain a small pool of fully-sized skbs, to make sure the
@@ -49,6 +51,9 @@ static atomic_t trapped;
 static void zap_completion_queue(void);
 static void arp_reply(struct sk_buff *skb);
 
+static unsigned int carrier_timeout = 4;
+module_param(carrier_timeout, uint, 0644);
+
 static void queue_process(struct work_struct *work)
 {
        struct netpoll_info *npinfo =
@@ -137,6 +142,7 @@ static int poll_one_napi(struct netpoll_info *npinfo,
        set_bit(NAPI_STATE_NPSVC, &napi->state);
 
        work = napi->poll(napi, budget);
+       trace_napi_poll(napi);
 
        clear_bit(NAPI_STATE_NPSVC, &napi->state);
        atomic_dec(&trapped);
@@ -175,9 +181,13 @@ static void service_arp_queue(struct netpoll_info *npi)
 void netpoll_poll(struct netpoll *np)
 {
        struct net_device *dev = np->dev;
-       const struct net_device_ops *ops = dev->netdev_ops;
+       const struct net_device_ops *ops;
+
+       if (!dev || !netif_running(dev))
+               return;
 
-       if (!dev || !netif_running(dev) || !ops->ndo_poll_controller)
+       ops = dev->netdev_ops;
+       if (!ops->ndo_poll_controller)
                return;
 
        /* Process pending work on NIC */
@@ -296,8 +306,11 @@ static void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb)
                for (tries = jiffies_to_usecs(1)/USEC_PER_POLL;
                     tries > 0; --tries) {
                        if (__netif_tx_trylock(txq)) {
-                               if (!netif_tx_queue_stopped(txq))
+                               if (!netif_tx_queue_stopped(txq)) {
                                        status = ops->ndo_start_xmit(skb, dev);
+                                       if (status == NETDEV_TX_OK)
+                                               txq_trans_update(txq);
+                               }
                                __netif_tx_unlock(txq);
 
                                if (status == NETDEV_TX_OK)
@@ -310,6 +323,11 @@ static void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb)
 
                        udelay(USEC_PER_POLL);
                }
+
+               WARN_ONCE(!irqs_disabled(),
+                       "netpoll_send_skb(): %s enabled interrupts in poll (%pF)\n",
+                       dev->name, ops->ndo_start_xmit);
+
                local_irq_restore(flags);
        }
 
@@ -723,7 +741,7 @@ int netpoll_setup(struct netpoll *np)
                }
 
                atleast = jiffies + HZ/10;
-               atmost = jiffies + 4*HZ;
+               atmost = jiffies + carrier_timeout * HZ;
                while (!netif_carrier_ok(ndev)) {
                        if (time_after(jiffies, atmost)) {
                                printk(KERN_NOTICE
@@ -731,7 +749,7 @@ int netpoll_setup(struct netpoll *np)
                                       np->name);
                                break;
                        }
-                       cond_resched();
+                       msleep(1);
                }
 
                /* If carrier appears to come up instantly, we don't