|
@@ -134,6 +134,7 @@
|
|
|
#include <linux/vmalloc.h>
|
|
|
#include <linux/if_macvlan.h>
|
|
|
#include <linux/errqueue.h>
|
|
|
+#include <linux/hrtimer.h>
|
|
|
|
|
|
#include "net-sysfs.h"
|
|
|
|
|
@@ -4412,7 +4413,6 @@ EXPORT_SYMBOL(__napi_schedule_irqoff);
|
|
|
void __napi_complete(struct napi_struct *n)
|
|
|
{
|
|
|
BUG_ON(!test_bit(NAPI_STATE_SCHED, &n->state));
|
|
|
- BUG_ON(n->gro_list);
|
|
|
|
|
|
list_del_init(&n->poll_list);
|
|
|
smp_mb__before_atomic();
|
|
@@ -4420,7 +4420,7 @@ void __napi_complete(struct napi_struct *n)
|
|
|
}
|
|
|
EXPORT_SYMBOL(__napi_complete);
|
|
|
|
|
|
-void napi_complete(struct napi_struct *n)
|
|
|
+void napi_complete_done(struct napi_struct *n, int work_done)
|
|
|
{
|
|
|
unsigned long flags;
|
|
|
|
|
@@ -4431,8 +4431,18 @@ void napi_complete(struct napi_struct *n)
|
|
|
if (unlikely(test_bit(NAPI_STATE_NPSVC, &n->state)))
|
|
|
return;
|
|
|
|
|
|
- napi_gro_flush(n, false);
|
|
|
+ if (n->gro_list) {
|
|
|
+ unsigned long timeout = 0;
|
|
|
|
|
|
+ if (work_done)
|
|
|
+ timeout = n->dev->gro_flush_timeout;
|
|
|
+
|
|
|
+ if (timeout)
|
|
|
+ hrtimer_start(&n->timer, ns_to_ktime(timeout),
|
|
|
+ HRTIMER_MODE_REL_PINNED);
|
|
|
+ else
|
|
|
+ napi_gro_flush(n, false);
|
|
|
+ }
|
|
|
if (likely(list_empty(&n->poll_list))) {
|
|
|
WARN_ON_ONCE(!test_and_clear_bit(NAPI_STATE_SCHED, &n->state));
|
|
|
} else {
|
|
@@ -4442,7 +4452,7 @@ void napi_complete(struct napi_struct *n)
|
|
|
local_irq_restore(flags);
|
|
|
}
|
|
|
}
|
|
|
-EXPORT_SYMBOL(napi_complete);
|
|
|
+EXPORT_SYMBOL(napi_complete_done);
|
|
|
|
|
|
/* must be called under rcu_read_lock(), as we dont take a reference */
|
|
|
struct napi_struct *napi_by_id(unsigned int napi_id)
|
|
@@ -4496,10 +4506,23 @@ void napi_hash_del(struct napi_struct *napi)
|
|
|
}
|
|
|
EXPORT_SYMBOL_GPL(napi_hash_del);
|
|
|
|
|
|
+static enum hrtimer_restart napi_watchdog(struct hrtimer *timer)
|
|
|
+{
|
|
|
+ struct napi_struct *napi;
|
|
|
+
|
|
|
+ napi = container_of(timer, struct napi_struct, timer);
|
|
|
+ if (napi->gro_list)
|
|
|
+ napi_schedule(napi);
|
|
|
+
|
|
|
+ return HRTIMER_NORESTART;
|
|
|
+}
|
|
|
+
|
|
|
void netif_napi_add(struct net_device *dev, struct napi_struct *napi,
|
|
|
int (*poll)(struct napi_struct *, int), int weight)
|
|
|
{
|
|
|
INIT_LIST_HEAD(&napi->poll_list);
|
|
|
+ hrtimer_init(&napi->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_PINNED);
|
|
|
+ napi->timer.function = napi_watchdog;
|
|
|
napi->gro_count = 0;
|
|
|
napi->gro_list = NULL;
|
|
|
napi->skb = NULL;
|
|
@@ -4518,6 +4541,20 @@ void netif_napi_add(struct net_device *dev, struct napi_struct *napi,
|
|
|
}
|
|
|
EXPORT_SYMBOL(netif_napi_add);
|
|
|
|
|
|
+void napi_disable(struct napi_struct *n)
|
|
|
+{
|
|
|
+ might_sleep();
|
|
|
+ set_bit(NAPI_STATE_DISABLE, &n->state);
|
|
|
+
|
|
|
+ while (test_and_set_bit(NAPI_STATE_SCHED, &n->state))
|
|
|
+ msleep(1);
|
|
|
+
|
|
|
+ hrtimer_cancel(&n->timer);
|
|
|
+
|
|
|
+ clear_bit(NAPI_STATE_DISABLE, &n->state);
|
|
|
+}
|
|
|
+EXPORT_SYMBOL(napi_disable);
|
|
|
+
|
|
|
void netif_napi_del(struct napi_struct *napi)
|
|
|
{
|
|
|
list_del_init(&napi->dev_list);
|