1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Mon, 8 Feb 2021 11:34:08 -0800
3 Subject: [PATCH] net: extract napi poll functionality to __napi_poll()
5 This commit introduces a new function __napi_poll() which does the main
6 logic of the existing napi_poll() function, and will be called by other
7 functions in later commits.
8 This idea and implementation is done by Felix Fietkau <nbd@nbd.name> and
9 is proposed as part of the patch to move napi work to work_queue
11 This commit by itself is a code restructure.
13 Signed-off-by: Felix Fietkau <nbd@nbd.name>
14 Signed-off-by: Wei Wang <weiwan@google.com>
15 Reviewed-by: Alexander Duyck <alexanderduyck@fb.com>
16 Signed-off-by: David S. Miller <davem@davemloft.net>
21 @@ -6810,15 +6810,10 @@ void __netif_napi_del(struct napi_struct
23 EXPORT_SYMBOL(__netif_napi_del);
25 -static int napi_poll(struct napi_struct *n, struct list_head *repoll)
26 +static int __napi_poll(struct napi_struct *n, bool *repoll)
31 - list_del_init(&n->poll_list);
33 - have = netpoll_poll_lock(n);
37 /* This NAPI_STATE_SCHED test is for avoiding a race
38 @@ -6838,7 +6833,7 @@ static int napi_poll(struct napi_struct
39 n->poll, work, weight);
41 if (likely(work < weight))
45 /* Drivers must not modify the NAPI state if they
46 * consume the entire weight. In such cases this code
47 @@ -6847,7 +6842,7 @@ static int napi_poll(struct napi_struct
49 if (unlikely(napi_disable_pending(n))) {
56 @@ -6865,12 +6860,29 @@ static int napi_poll(struct napi_struct
57 if (unlikely(!list_empty(&n->poll_list))) {
58 pr_warn_once("%s: Budget exhausted after napi rescheduled\n",
59 n->dev ? n->dev->name : "backlog");
64 - list_add_tail(&n->poll_list, repoll);
70 +static int napi_poll(struct napi_struct *n, struct list_head *repoll)
72 + bool do_repoll = false;
76 + list_del_init(&n->poll_list);
78 + have = netpoll_poll_lock(n);
80 + work = __napi_poll(n, &do_repoll);
83 + list_add_tail(&n->poll_list, repoll);
86 netpoll_poll_unlock(have);