kernel: add compatibility with upstream threaded NAPI patch

Enable threading if dev->threaded is set. This will be used to bring mt76 back
in sync with upstream

Signed-off-by: Felix Fietkau <nbd@nbd.name>
(cherry-picked from commit 3d1ea0d77f)
This commit is contained in:
Felix Fietkau 2021-03-12 14:45:19 +01:00
parent e17e212b51
commit 1eb1d5e0bb

View File

@ -50,7 +50,15 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
}; };
enum gro_result { enum gro_result {
@@ -2249,6 +2252,26 @@ void netif_napi_add(struct net_device *d @@ -2092,6 +2095,7 @@ struct net_device {
struct lock_class_key addr_list_lock_key;
bool proto_down;
unsigned wol_enabled:1;
+ unsigned threaded:1;
};
#define to_net_dev(d) container_of(d, struct net_device, dev)
@@ -2249,6 +2253,26 @@ void netif_napi_add(struct net_device *d
int (*poll)(struct napi_struct *, int), int weight); int (*poll)(struct napi_struct *, int), int weight);
/** /**
@ -111,7 +119,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
____napi_schedule(this_cpu_ptr(&softnet_data), n); ____napi_schedule(this_cpu_ptr(&softnet_data), n);
} }
EXPORT_SYMBOL(__napi_schedule_irqoff); EXPORT_SYMBOL(__napi_schedule_irqoff);
@@ -6219,6 +6230,84 @@ static void init_gro_hash(struct napi_st @@ -6219,9 +6230,89 @@ static void init_gro_hash(struct napi_st
napi->gro_bitmask = 0; napi->gro_bitmask = 0;
} }
@ -196,7 +204,12 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
void netif_napi_add(struct net_device *dev, struct napi_struct *napi, void netif_napi_add(struct net_device *dev, struct napi_struct *napi,
int (*poll)(struct napi_struct *, int), int weight) int (*poll)(struct napi_struct *, int), int weight)
{ {
@@ -6238,6 +6327,7 @@ void netif_napi_add(struct net_device *d + if (dev->threaded)
+ set_bit(NAPI_STATE_THREADED, &napi->state);
INIT_LIST_HEAD(&napi->poll_list);
hrtimer_init(&napi->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_PINNED);
napi->timer.function = napi_watchdog;
@@ -6238,6 +6329,7 @@ void netif_napi_add(struct net_device *d
#ifdef CONFIG_NETPOLL #ifdef CONFIG_NETPOLL
napi->poll_owner = -1; napi->poll_owner = -1;
#endif #endif
@ -204,7 +217,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
set_bit(NAPI_STATE_SCHED, &napi->state); set_bit(NAPI_STATE_SCHED, &napi->state);
set_bit(NAPI_STATE_NPSVC, &napi->state); set_bit(NAPI_STATE_NPSVC, &napi->state);
list_add_rcu(&napi->dev_list, &dev->napi_list); list_add_rcu(&napi->dev_list, &dev->napi_list);
@@ -6278,6 +6368,7 @@ static void flush_gro_hash(struct napi_s @@ -6278,6 +6370,7 @@ static void flush_gro_hash(struct napi_s
void netif_napi_del(struct napi_struct *napi) void netif_napi_del(struct napi_struct *napi)
{ {
might_sleep(); might_sleep();
@ -212,7 +225,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
if (napi_hash_del(napi)) if (napi_hash_del(napi))
synchronize_net(); synchronize_net();
list_del_init(&napi->dev_list); list_del_init(&napi->dev_list);
@@ -6290,50 +6381,18 @@ EXPORT_SYMBOL(netif_napi_del); @@ -6290,50 +6383,18 @@ EXPORT_SYMBOL(netif_napi_del);
static int napi_poll(struct napi_struct *n, struct list_head *repoll) static int napi_poll(struct napi_struct *n, struct list_head *repoll)
{ {
@ -267,7 +280,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
/* Some drivers may have called napi_schedule /* Some drivers may have called napi_schedule
* prior to exhausting their budget. * prior to exhausting their budget.
@@ -10271,6 +10330,10 @@ static int __init net_dev_init(void) @@ -10271,6 +10332,10 @@ static int __init net_dev_init(void)
sd->backlog.weight = weight_p; sd->backlog.weight = weight_p;
} }