net: mvneta: add support for page_pool_get_stats
Subsystems (4)
v5 cover net: mvneta: add support for page_pool_get_stats
Introduce page_pool stats ethtool APIs in order to avoid driver duplicated code.
Changes since v4:
- rebase on top of net-next
Changes since v3:
- get rid of wrong for loop in page_pool_ethtool_stats_get()
- add API stubs when page_pool_stats are not compiled in
Changes since v2:
- remove enum list of page_pool stats in page_pool.h
- remove leftover change in mvneta.c for ethtool_stats array allocation
Changes since v1:
- move stats accounting to page_pool code
- move stats string management to page_pool code
Lorenzo Bianconi (2):
net: page_pool: introduce ethtool stats
net: mvneta: add support for page_pool_get_stats
drivers/net/ethernet/marvell/Kconfig | 1 + drivers/net/ethernet/marvell/mvneta.c | 20 ++++++++- include/net/page_pool.h | 21 +++++++++ net/core/page_pool.c | 63 ++++++++++++++++++++++++++- 4 files changed, 103 insertions(+), 2 deletions(-)
Signature · 1 line
2.35.1
PATCH v5 1/2 net: page_pool: introduce ethtool stats
Introduce page_pool APIs to report stats through ethtool and reduce duplicated code in each driver.
--- include/net/page_pool.h | 21 ++++++++++++++ net/core/page_pool.c | 63 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 83 insertions(+), 1 deletion(-)
include/net/page_pool.h +21 -0
@@ -117,6 +117,10 @@ struct page_pool_stats {struct page_pool_recycle_stats recycle_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); +/* * Drivers that wish to harvest page pool stats and report them to users * (perhaps via ethtool, debugfs, or another mechanism) can allocate a
@@ -124,6 +128,23 @@ struct page_pool_stats {*/ bool page_pool_get_stats (struct page_pool *pool,struct page_pool_stats *stats); +#else + +static inline int page_pool_ethtool_stats_get_count (void ) +{ +return 0 ; +} + +static inline u8 *page_pool_ethtool_stats_get_strings (u8 *data) +{ +return data; +} + +static inline u64 *page_pool_ethtool_stats_get (u64 *data,void *stats) +{ +return data; +} +#endif struct page_pool {
net/core/page_pool.c +62 -1
87 lines not on this page · raw message
Signature · 1 line
2.35.1
Re: [PATCH v5 net-next 1/2] net: page_pool: introduce ethtool stats
Quoted 4 lines · On Tue, 12 Apr 2022 18:31:58 +0200 Lorenzo Bianconi wrote:
Introduce
page_poolAPIs to report stats through ethtool and reduce duplicated code in each driver.Signed-off-by Lorenzo Bianconi <[email protected]>
Re: [PATCH v5 net-next 1/2] net: page_pool: introduce ethtool stats
Quoted 8 lines · Jakub Kicinski
Quoted 4 lines · On Tue, 12 Apr 2022 18:31:58 +0200 Lorenzo Bianconi wrote:
Introduce
page_poolAPIs to report stats through ethtool and reduce duplicated code in each driver.Signed-off-by Lorenzo Bianconi <[email protected]>Reviewed-by Jakub Kicinski <[email protected]>
PATCH v5 2/2 net: mvneta: add support for page_pool_get_stats
In reply to Lorenzo BianconiIntroduce support for the page_pool stats API into mvneta driver. Report page_pool stats through ethtool.
--- drivers/net/ethernet/marvell/Kconfig | 1 + drivers/net/ethernet/marvell/mvneta.c | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-)
drivers/net/ethernet/marvell/Kconfig +1 -0
@@ -62,6 +62,7 @@ config MVNETA select MVMDIO select PHYLINK select PAGE_POOL + select PAGE_POOL_STATS help This driver supports the network interface units in the Marvell ARMADA XP, ARMADA 370, ARMADA 38x and
drivers/net/ethernet/marvell/mvneta.c +19 -1
@@ -4735,6 +4735,9 @@ static void mvneta_ethtool_get_strings(struct net_device *netdev, u32 sset,for (i =0 ; i <ARRAY_SIZE (mvneta_statistics); i++)memcpy (data + i *ETH_GSTRING_LEN , mvneta_statistics[i].name,ETH_GSTRING_LEN ); + + data +=ETH_GSTRING_LEN *ARRAY_SIZE (mvneta_statistics); +page_pool_ethtool_stats_get_strings (data); } }
@@ -4847,6 +4850,17 @@ static void mvneta_ethtool_update_stats(struct mvneta_port *pp) } } +static void mvneta_ethtool_pp_stats (struct mvneta_port *pp,u64 *data) +{ +struct page_pool_stats stats = {}; +int i; + +for (i =0 ; i < rxq_number; i++) +page_pool_get_stats (pp->rxqs[i].page_pool, &stats); + +page_pool_ethtool_stats_get (data, &stats); +} +static void mvneta_ethtool_get_stats (struct net_device *dev,struct ethtool_stats *stats,u64 *data) {
@@ -4857,12 +4871,16 @@ static void mvneta_ethtool_get_stats(struct net_device *dev,for (i =0 ; i <ARRAY_SIZE (mvneta_statistics); i++) *data++ = pp->ethtool_stats[i]; + +mvneta_ethtool_pp_stats (pp, data); }static int mvneta_ethtool_get_sset_count (struct net_device *dev,int sset) {if (sset ==ETH_SS_STATS ) -return ARRAY_SIZE (mvneta_statistics); +return ARRAY_SIZE (mvneta_statistics) + +page_pool_ethtool_stats_get_count (); +return -EOPNOTSUPP ; }
Signature · 1 line
2.35.1
This series was applied to netdev/net-next.git (master) by David S. Miller <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (master) by David S. Miller <[email protected]>:
Quoted 11 lines · On Tue, 12 Apr 2022 18:31:57 +0200 you wrote:
Introduce
page_poolstats ethtool APIs in order to avoid driver duplicated code.Changes since v4:
- rebase on top of net-nextChanges since v3:
- get rid of wrong for loop inpage_pool_ethtool_stats_get()
- add API stubs whenpage_pool_statsare not compiled in[...]
Here is the summary with links:
- [v5,net-next,1/2] net: page_pool: introduce ethtool stats
https://git.kernel.org/netdev/net-next/c/f3c5264f452a - [v5,net-next,2/2] net: mvneta: add support for page_pool_get_stats https://git.kernel.org/netdev/net-next/c/b3fc79225f05
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html