Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: ethernet: mtk_eth_soc: add support for page_pool_get_stats

Introduce support for the page_pool stats API into mtk_eth_soc driver.
Report page_pool stats through ethtool.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Lorenzo Bianconi and committed by
David S. Miller
84b9cd38 5886d26f

+35 -3
+1
drivers/net/ethernet/mediatek/Kconfig
··· 18 18 select PHYLINK 19 19 select DIMLIB 20 20 select PAGE_POOL 21 + select PAGE_POOL_STATS 21 22 help 22 23 This driver supports the gigabit ethernet MACs in the 23 24 MediaTek SoC family.
+34 -3
drivers/net/ethernet/mediatek/mtk_eth_soc.c
··· 3528 3528 int i; 3529 3529 3530 3530 switch (stringset) { 3531 - case ETH_SS_STATS: 3531 + case ETH_SS_STATS: { 3532 + struct mtk_mac *mac = netdev_priv(dev); 3533 + 3532 3534 for (i = 0; i < ARRAY_SIZE(mtk_ethtool_stats); i++) { 3533 3535 memcpy(data, mtk_ethtool_stats[i].str, ETH_GSTRING_LEN); 3534 3536 data += ETH_GSTRING_LEN; 3535 3537 } 3538 + if (mtk_page_pool_enabled(mac->hw)) 3539 + page_pool_ethtool_stats_get_strings(data); 3540 + break; 3541 + } 3542 + default: 3536 3543 break; 3537 3544 } 3538 3545 } ··· 3547 3540 static int mtk_get_sset_count(struct net_device *dev, int sset) 3548 3541 { 3549 3542 switch (sset) { 3550 - case ETH_SS_STATS: 3551 - return ARRAY_SIZE(mtk_ethtool_stats); 3543 + case ETH_SS_STATS: { 3544 + int count = ARRAY_SIZE(mtk_ethtool_stats); 3545 + struct mtk_mac *mac = netdev_priv(dev); 3546 + 3547 + if (mtk_page_pool_enabled(mac->hw)) 3548 + count += page_pool_ethtool_stats_get_count(); 3549 + return count; 3550 + } 3552 3551 default: 3553 3552 return -EOPNOTSUPP; 3554 3553 } 3554 + } 3555 + 3556 + static void mtk_ethtool_pp_stats(struct mtk_eth *eth, u64 *data) 3557 + { 3558 + struct page_pool_stats stats = {}; 3559 + int i; 3560 + 3561 + for (i = 0; i < ARRAY_SIZE(eth->rx_ring); i++) { 3562 + struct mtk_rx_ring *ring = &eth->rx_ring[i]; 3563 + 3564 + if (!ring->page_pool) 3565 + continue; 3566 + 3567 + page_pool_get_stats(ring->page_pool, &stats); 3568 + } 3569 + page_pool_ethtool_stats_get(data, &stats); 3555 3570 } 3556 3571 3557 3572 static void mtk_get_ethtool_stats(struct net_device *dev, ··· 3603 3574 3604 3575 for (i = 0; i < ARRAY_SIZE(mtk_ethtool_stats); i++) 3605 3576 *data_dst++ = *(data_src + mtk_ethtool_stats[i].offset); 3577 + if (mtk_page_pool_enabled(mac->hw)) 3578 + mtk_ethtool_pp_stats(mac->hw, data_dst); 3606 3579 } while (u64_stats_fetch_retry_irq(&hwstats->syncp, start)); 3607 3580 } 3608 3581