napi_synchronize: waiting for NAPI
authorStephen Hemminger <shemminger@linux-foundation.org>
Wed, 17 Oct 2007 20:26:41 +0000 (13:26 -0700)
committerJeff Garzik <jeff@garzik.org>
Thu, 18 Oct 2007 00:17:34 +0000 (20:17 -0400)
Some drivers with shared NAPI need a synchronization barrier.
Also suggested by Benjamin Herrenschmidt for EMAC.

Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
include/linux/netdevice.h

index 39dd83b..a5e2dc1 100644 (file)
@@ -407,6 +407,24 @@ static inline void napi_enable(struct napi_struct *n)
        clear_bit(NAPI_STATE_SCHED, &n->state);
 }
 
+#ifdef CONFIG_SMP
+/**
+ *     napi_synchronize - wait until NAPI is not running
+ *     @n: napi context
+ *
+ * Wait until NAPI is done being scheduled on this context.
+ * Waits till any outstanding processing completes but
+ * does not disable future activations.
+ */
+static inline void napi_synchronize(const struct napi_struct *n)
+{
+       while (test_bit(NAPI_STATE_SCHED, &n->state))
+               msleep(1);
+}
+#else
+# define napi_synchronize(n)   barrier()
+#endif
+
 /*
  *     The DEVICE structure.
  *     Actually, this whole structure is a big mistake.  It mixes I/O