mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-23 15:32:33 +00:00
5714660643
Manually rebased:
backport-5.15/603-v5.19-page_pool-Add-recycle-stats-to-page_pool_put_page_bu.patch
pending-5.15/723-net-mt7531-ensure-all-MACs-are-powered-down-before-r.patch*
Removed upstreamed:
generic-backport/610-v6.3-net-page_pool-use-in_softirq-instead.patch[1]
backport-5.15/705-12-v6.0-net-dsa-mt7530-rework-mt753-01-_setup.patch[2]
backport-5.15/790-v6.4-0010-net-dsa-mt7530-split-off-common-parts-from-mt7531_se.patch[3]
backport-5.15/703-10-v5.16-net-dsa-introduce-helpers-for-iterating-through-port.patch[4]
All other patches automatically rebased.
* Modified to define the variable i as suggested by DragonBluep in PR discussion.
See: https://github.com/openwrt/openwrt/pull/12823#issuecomment-1578518576
1. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v5.15.115&id=3af319d5147454dc63665ef451229c674b538377
2. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v5.15.115&id=0753c1ef24194580f7165ae6e259b59a851392f2
3. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v5.15.115&id=5a7266feaa6d708fc6880a161786eaa884ef3c8e
4. 9902f91cf6
Build system: x86_64
Build-tested: bcm2711/RPi4B, ramips/tplink_archer-a6-v3, filogic/xiaomi_redmi-router-ax6000-ubootmod
Run-tested: bcm2711/RPi4B, ramips/tplink_archer-a6-v3, filogic/xiaomi_redmi-router-ax6000-ubootmod
Signed-off-by: John Audia <therealgraysky@proton.me>
148 lines
4.2 KiB
Diff
148 lines
4.2 KiB
Diff
From f3c5264f452a5b0ac1de1f2f657efbabdea3c76a Mon Sep 17 00:00:00 2001
|
|
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
|
Date: Tue, 12 Apr 2022 18:31:58 +0200
|
|
Subject: [PATCH] net: page_pool: introduce ethtool stats
|
|
|
|
Introduce page_pool APIs to report stats through ethtool and reduce
|
|
duplicated code in each driver.
|
|
|
|
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
|
Reviewed-by: Jakub Kicinski <kuba@kernel.org>
|
|
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
|
|
Signed-off-by: David S. Miller <davem@davemloft.net>
|
|
---
|
|
include/net/page_pool.h | 21 ++++++++++++++
|
|
net/core/page_pool.c | 63 ++++++++++++++++++++++++++++++++++++++++-
|
|
2 files changed, 83 insertions(+), 1 deletion(-)
|
|
|
|
--- a/include/net/page_pool.h
|
|
+++ b/include/net/page_pool.h
|
|
@@ -115,6 +115,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
|
|
@@ -122,6 +126,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 {
|
|
--- a/net/core/page_pool.c
|
|
+++ b/net/core/page_pool.c
|
|
@@ -18,6 +18,7 @@
|
|
#include <linux/page-flags.h>
|
|
#include <linux/mm.h> /* for __put_page() */
|
|
#include <linux/poison.h>
|
|
+#include <linux/ethtool.h>
|
|
|
|
#include <trace/events/page_pool.h>
|
|
|
|
@@ -65,6 +66,20 @@ static void page_pool_producer_unlock(st
|
|
this_cpu_add(s->__stat, val); \
|
|
} while (0)
|
|
|
|
+static const char pp_stats[][ETH_GSTRING_LEN] = {
|
|
+ "rx_pp_alloc_fast",
|
|
+ "rx_pp_alloc_slow",
|
|
+ "rx_pp_alloc_slow_ho",
|
|
+ "rx_pp_alloc_empty",
|
|
+ "rx_pp_alloc_refill",
|
|
+ "rx_pp_alloc_waive",
|
|
+ "rx_pp_recycle_cached",
|
|
+ "rx_pp_recycle_cache_full",
|
|
+ "rx_pp_recycle_ring",
|
|
+ "rx_pp_recycle_ring_full",
|
|
+ "rx_pp_recycle_released_ref",
|
|
+};
|
|
+
|
|
bool page_pool_get_stats(struct page_pool *pool,
|
|
struct page_pool_stats *stats)
|
|
{
|
|
@@ -73,7 +88,13 @@ bool page_pool_get_stats(struct page_poo
|
|
if (!stats)
|
|
return false;
|
|
|
|
- memcpy(&stats->alloc_stats, &pool->alloc_stats, sizeof(pool->alloc_stats));
|
|
+ /* The caller is responsible to initialize stats. */
|
|
+ stats->alloc_stats.fast += pool->alloc_stats.fast;
|
|
+ stats->alloc_stats.slow += pool->alloc_stats.slow;
|
|
+ stats->alloc_stats.slow_high_order += pool->alloc_stats.slow_high_order;
|
|
+ stats->alloc_stats.empty += pool->alloc_stats.empty;
|
|
+ stats->alloc_stats.refill += pool->alloc_stats.refill;
|
|
+ stats->alloc_stats.waive += pool->alloc_stats.waive;
|
|
|
|
for_each_possible_cpu(cpu) {
|
|
const struct page_pool_recycle_stats *pcpu =
|
|
@@ -89,6 +110,46 @@ bool page_pool_get_stats(struct page_poo
|
|
return true;
|
|
}
|
|
EXPORT_SYMBOL(page_pool_get_stats);
|
|
+
|
|
+u8 *page_pool_ethtool_stats_get_strings(u8 *data)
|
|
+{
|
|
+ int i;
|
|
+
|
|
+ for (i = 0; i < ARRAY_SIZE(pp_stats); i++) {
|
|
+ memcpy(data, pp_stats[i], ETH_GSTRING_LEN);
|
|
+ data += ETH_GSTRING_LEN;
|
|
+ }
|
|
+
|
|
+ return data;
|
|
+}
|
|
+EXPORT_SYMBOL(page_pool_ethtool_stats_get_strings);
|
|
+
|
|
+int page_pool_ethtool_stats_get_count(void)
|
|
+{
|
|
+ return ARRAY_SIZE(pp_stats);
|
|
+}
|
|
+EXPORT_SYMBOL(page_pool_ethtool_stats_get_count);
|
|
+
|
|
+u64 *page_pool_ethtool_stats_get(u64 *data, void *stats)
|
|
+{
|
|
+ struct page_pool_stats *pool_stats = stats;
|
|
+
|
|
+ *data++ = pool_stats->alloc_stats.fast;
|
|
+ *data++ = pool_stats->alloc_stats.slow;
|
|
+ *data++ = pool_stats->alloc_stats.slow_high_order;
|
|
+ *data++ = pool_stats->alloc_stats.empty;
|
|
+ *data++ = pool_stats->alloc_stats.refill;
|
|
+ *data++ = pool_stats->alloc_stats.waive;
|
|
+ *data++ = pool_stats->recycle_stats.cached;
|
|
+ *data++ = pool_stats->recycle_stats.cache_full;
|
|
+ *data++ = pool_stats->recycle_stats.ring;
|
|
+ *data++ = pool_stats->recycle_stats.ring_full;
|
|
+ *data++ = pool_stats->recycle_stats.released_refcnt;
|
|
+
|
|
+ return data;
|
|
+}
|
|
+EXPORT_SYMBOL(page_pool_ethtool_stats_get);
|
|
+
|
|
#else
|
|
#define alloc_stat_inc(pool, __stat)
|
|
#define recycle_stat_inc(pool, __stat)
|