Changes in V4:
- Using u64 to record the XDP statistics
- Changing strncpy to strscpy
- Remove the "PAGE_POOL_STATS" select per Alexander's feedback
- Export the page_pool_stats definition in the page_pool.h
Changes in v3:
- change memcpy to strncpy to fix the warning reported by Paolo Abeni
- fix the compile errors on powerpc
Changes in v2:
- clean up and restructure the codes per Andrew Lunn's review comments
- clear the statistics when the adaptor is down
Shenwei Wang (2):
net: page_pool: export page_pool_stats definition
net: fec: add xdp and page pool statistics
drivers/net/ethernet/freescale/fec.h | 15 ++++
drivers/net/ethernet/freescale/fec_main.c | 100 ++++++++++++++++++++--
include/net/page_pool.h | 2 +-
3 files changed, 110 insertions(+), 7 deletions(-)
--
2.34.1
The definition of the 'struct page_pool_stats' is required even when
the CONFIG_PAGE_POOL_STATS is not defined. Otherwise, it is required
the drivers to handle the case of CONFIG_PAGE_POOL_STATS undefined.
Signed-off-by: Shenwei Wang <[email protected]>
---
include/net/page_pool.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/net/page_pool.h b/include/net/page_pool.h
index 813c93499f20..adfd4bb609a7 100644
--- a/include/net/page_pool.h
+++ b/include/net/page_pool.h
@@ -84,7 +84,6 @@ struct page_pool_params {
void *init_arg;
};
-#ifdef CONFIG_PAGE_POOL_STATS
struct page_pool_alloc_stats {
u64 fast; /* fast path allocations */
u64 slow; /* slow-path order 0 allocations */
@@ -117,6 +116,7 @@ struct page_pool_stats {
struct page_pool_recycle_stats recycle_stats;
};
+#ifdef CONFIG_PAGE_POOL_STATS
int page_pool_ethtool_stats_get_count(void);
u8 *page_pool_ethtool_stats_get_strings(u8 *data);
u64 *page_pool_ethtool_stats_get(u64 *data, void *stats);
--
2.34.1
On Tue, Nov 15, 2022 at 09:57:43AM -0600, Shenwei Wang wrote:
> The definition of the 'struct page_pool_stats' is required even when
> the CONFIG_PAGE_POOL_STATS is not defined. Otherwise, it is required
> the drivers to handle the case of CONFIG_PAGE_POOL_STATS undefined.
I agree the API is broken, but i think there is a better fix.
There should be a stub of page_pool_get_stats() for when
CONFIG_PAGE_POOL_STATS is disabled.
Nothing actually dereferences struct page_pool_stats when you have
this stub. So it might be enough to simply have
struct page_pool_stats{
};
Andrew
> -----Original Message-----
> From: Andrew Lunn <[email protected]>
> Sent: Tuesday, November 15, 2022 11:12 AM
> To: Shenwei Wang <[email protected]>
> Cc: David S. Miller <[email protected]>; Eric Dumazet
> <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni
> <[email protected]>; Jesper Dangaard Brouer <[email protected]>; Ilias
> Apalodimas <[email protected]>; Alexei Starovoitov
> <[email protected]>; Daniel Borkmann <[email protected]>; John Fastabend
> <[email protected]>; [email protected]; linux-
> [email protected]; [email protected]
> Subject: [EXT] Re: [PATCH v4 1/2] net: page_pool: export page_pool_stats
> definition
>
> Caution: EXT Email
>
> On Tue, Nov 15, 2022 at 09:57:43AM -0600, Shenwei Wang wrote:
> > The definition of the 'struct page_pool_stats' is required even when
> > the CONFIG_PAGE_POOL_STATS is not defined. Otherwise, it is required
> > the drivers to handle the case of CONFIG_PAGE_POOL_STATS undefined.
>
> I agree the API is broken, but i think there is a better fix.
>
> There should be a stub of page_pool_get_stats() for when
> CONFIG_PAGE_POOL_STATS is disabled.
>
> Nothing actually dereferences struct page_pool_stats when you have this stub.
> So it might be enough to simply have
>
> struct page_pool_stats{
> };
>
As the structure is open when the CONFIG_PAGE_POOL_STATS is enabled, you can not
prevent a user to access its members. The empty stub will still have problems in this
kind of situations.
Regards,
Shenwei
> Andrew
> > I agree the API is broken, but i think there is a better fix.
> >
> > There should be a stub of page_pool_get_stats() for when
> > CONFIG_PAGE_POOL_STATS is disabled.
> >
> > Nothing actually dereferences struct page_pool_stats when you have this stub.
> > So it might be enough to simply have
> >
> > struct page_pool_stats{
> > };
> >
>
> As the structure is open when the CONFIG_PAGE_POOL_STATS is enabled, you can not
> prevent a user to access its members. The empty stub will still have problems in this
> kind of situations.
The users, i.e. the driver, has no need to access its members. The
members can change, new ones can be added, and it will not cause a
problem, given the way this API is defined. Ideally, page_pool_stats
would of been an opaque cookie, but that is not how it was
implemented :-(
Andrew
On 15 Nov 09:57, Shenwei Wang wrote:
> Changes in V4:
> - Using u64 to record the XDP statistics
> - Changing strncpy to strscpy
> - Remove the "PAGE_POOL_STATS" select per Alexander's feedback
> - Export the page_pool_stats definition in the page_pool.h
>
Reviewed-by: Saeed Mahameed <[email protected]>