2022-11-15 21:22:24

by Shenwei Wang

[permalink] [raw]
Subject: [PATCH v5 0/3] net: fec: add xdp and page pool statistics

Changes in V5:
- split the patch into two: one for xdp statistics and one for page
pool
- fix the bug to zero xdp_stats array
- use empty 'page_pool_stats' when CONFIG_PAGE_POOL_STATS is disabled.

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 (3):
net: page_pool: export page_pool_stats definition
net: fec: add xdp statistics
net: fec: add page pool statistics

drivers/net/ethernet/freescale/fec.h | 15 ++++
drivers/net/ethernet/freescale/fec_main.c | 96 +++++++++++++++++++++--
include/net/page_pool.h | 2 +
3 files changed, 107 insertions(+), 6 deletions(-)

--
2.34.1



2022-11-15 22:12:12

by Shenwei Wang

[permalink] [raw]
Subject: [PATCH v5 3/3] net: fec: add page pool statistics

add page pool statistics to ethtool stats.

Signed-off-by: Shenwei Wang <[email protected]>
---
drivers/net/ethernet/freescale/fec_main.c | 24 ++++++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index bb2157022022..ae905ea1ab7d 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -2755,6 +2755,24 @@ static void fec_enet_get_xdp_stats(struct fec_enet_private *fep, u64 *data)
memcpy(data, xdp_stats, sizeof(xdp_stats));
}

+static void fec_enet_page_pool_stats(struct fec_enet_private *fep, u64 *data)
+{
+ struct page_pool_stats stats = {};
+ struct fec_enet_priv_rx_q *rxq;
+ int i;
+
+ for (i = fep->num_rx_queues - 1; i >= 0; i--) {
+ rxq = fep->rx_queue[i];
+
+ if (!rxq->page_pool)
+ continue;
+
+ page_pool_get_stats(rxq->page_pool, &stats);
+ }
+
+ page_pool_ethtool_stats_get(data, &stats);
+}
+
static void fec_enet_get_ethtool_stats(struct net_device *dev,
struct ethtool_stats *stats, u64 *data)
{
@@ -2768,6 +2786,8 @@ static void fec_enet_get_ethtool_stats(struct net_device *dev,

fec_enet_get_xdp_stats(fep, data);
data += XDP_STATS_TOTAL;
+
+ fec_enet_page_pool_stats(fep, data);
}

static void fec_enet_get_strings(struct net_device *netdev,
@@ -2784,6 +2804,7 @@ static void fec_enet_get_strings(struct net_device *netdev,
strscpy(data, fec_xdp_stat_strs[i], ETH_GSTRING_LEN);
data += ETH_GSTRING_LEN;
}
+ page_pool_ethtool_stats_get_strings(data);
break;
case ETH_SS_TEST:
net_selftest_get_strings(data);
@@ -2795,7 +2816,8 @@ static int fec_enet_get_sset_count(struct net_device *dev, int sset)
{
switch (sset) {
case ETH_SS_STATS:
- return (ARRAY_SIZE(fec_stats) + XDP_STATS_TOTAL);
+ return (ARRAY_SIZE(fec_stats) + XDP_STATS_TOTAL
+ + page_pool_ethtool_stats_get_count());
case ETH_SS_TEST:
return net_selftest_get_count();
default:
--
2.34.1


2022-11-16 17:43:15

by Jakub Kicinski

[permalink] [raw]
Subject: Re: [PATCH v5 0/3] net: fec: add xdp and page pool statistics

On Tue, 15 Nov 2022 14:49:48 -0600 Shenwei Wang wrote:
> Changes in V5:
> - split the patch into two: one for xdp statistics and one for page
> pool
> - fix the bug to zero xdp_stats array
> - use empty 'page_pool_stats' when CONFIG_PAGE_POOL_STATS is disabled.

Hi, IIUC there was a previous revision of this set which got applied
too hastily. Unfortunately that means you need to rebase on top of
what's already applied, or add a revert to your series. Otherwise
the patches won't apply cleanly.