1 From foo@baz Thu Mar 28 21:54:17 CET 2019
2 From: Dean Nelson <dnelson@redhat.com>
3 Date: Tue, 26 Mar 2019 11:53:19 -0400
4 Subject: thunderx: enable page recycling for non-XDP case
6 From: Dean Nelson <dnelson@redhat.com>
8 [ Upstream commit b3e208069477588c06f4d5d986164b435bb06e6d ]
10 Commit 773225388dae15e72790 ("net: thunderx: Optimize page recycling for XDP")
11 added code to nicvf_alloc_page() that inadvertently disables receive buffer
12 page recycling for the non-XDP case by always NULL'ng the page pointer.
14 This patch corrects two if-conditionals to allow for the recycling of non-XDP
15 mode pages by only setting the page pointer to NULL when the page is not ready
18 Fixes: 773225388dae ("net: thunderx: Optimize page recycling for XDP")
19 Signed-off-by: Dean Nelson <dnelson@redhat.com>
20 Signed-off-by: David S. Miller <davem@davemloft.net>
21 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
23 drivers/net/ethernet/cavium/thunder/nicvf_queues.c | 23 ++++++++++-----------
24 1 file changed, 11 insertions(+), 12 deletions(-)
26 --- a/drivers/net/ethernet/cavium/thunder/nicvf_queues.c
27 +++ b/drivers/net/ethernet/cavium/thunder/nicvf_queues.c
28 @@ -105,20 +105,19 @@ static inline struct pgcache *nicvf_allo
29 /* Check if page can be recycled */
31 ref_count = page_ref_count(page);
32 - /* Check if this page has been used once i.e 'put_page'
33 - * called after packet transmission i.e internal ref_count
34 - * and page's ref_count are equal i.e page can be recycled.
35 + /* This page can be recycled if internal ref_count and page's
36 + * ref_count are equal, indicating that the page has been used
37 + * once for packet transmission. For non-XDP mode, internal
38 + * ref_count is always '1'.
40 - if (rbdr->is_xdp && (ref_count == pgcache->ref_count))
41 - pgcache->ref_count--;
45 - /* In non-XDP mode, page's ref_count needs to be '1' for it
48 - if (!rbdr->is_xdp && (ref_count != 1))
50 + if (ref_count == pgcache->ref_count)
51 + pgcache->ref_count--;
54 + } else if (ref_count != 1) {