mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-21 06:33:41 +00:00
d59d69f9e1
Manually rebased: backport-5.15/704-15-v5.19-net-mtk_eth_soc-move-MAC_MCR-setting-to-mac_finish.patch Removed upstreamed: backport-5.15/060-v6.0-01-tools-build-Add-feature-test-for-init_disassemble_in.patch[1] backport-5.15/060-v6.0-02-tools-include-add-dis-asm-compat.h-to-handle-version.patch[2] backport-5.15/060-v6.0-03-tools-perf-Fix-compilation-error-with-new-binutils.patch[3] backport-5.15/060-v6.0-04-tools-bpf_jit_disasm-Fix-compilation-error-with-new-.patch[4] backport-5.15/060-v6.0-05-tools-bpftool-Fix-compilation-error-with-new-binutil.patch[5] pending-5.15/733-02-net-ethernet-mtk_eth_soc-fix-RX-data-corruption-issu.patch[6] bcm47xx/patches-5.15/170-bgmac-fix-initial-chip-reset-to-support-BCM5358.patch[7] All other patches automatically rebased. 1. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v5.15.103&id=51b99dc38c1a053e2e732d7f9e2740e343ae7eae 2. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v5.15.103&id=451c9d7b16169645ed291ebb2ca9844caa088f2d 3. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v5.15.103&id=97f005c0bdbaf656a7808586d234965385a06c58 4. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v5.15.103&id=1c27fab243333821375e4d63128d60093fdbe149 5. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v5.15.103&id=4441a90091931fd81607567961dc122f24f735bb 6. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v5.15.103&id=2adc29350a5b4669544566f71f208d2abaec60ab 7. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v5.15.103&id=04bfc5bcdfc0fdb73587487c71b04d63807ae15a 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>
111 lines
3.4 KiB
Diff
111 lines
3.4 KiB
Diff
From 916a6ee836d6b7b8ef1ed5f0515e256ca60e9968 Mon Sep 17 00:00:00 2001
|
|
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
|
Date: Fri, 22 Jul 2022 09:19:38 +0200
|
|
Subject: [PATCH] net: ethernet: mtk_eth_soc: introduce xdp ethtool counters
|
|
|
|
Report xdp stats through ethtool
|
|
|
|
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
|
Signed-off-by: David S. Miller <davem@davemloft.net>
|
|
---
|
|
drivers/net/ethernet/mediatek/mtk_eth_soc.c | 26 +++++++++++++++++++--
|
|
drivers/net/ethernet/mediatek/mtk_eth_soc.h | 12 ++++++++++
|
|
2 files changed, 36 insertions(+), 2 deletions(-)
|
|
|
|
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
|
|
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
|
|
@@ -34,6 +34,10 @@ MODULE_PARM_DESC(msg_level, "Message lev
|
|
#define MTK_ETHTOOL_STAT(x) { #x, \
|
|
offsetof(struct mtk_hw_stats, x) / sizeof(u64) }
|
|
|
|
+#define MTK_ETHTOOL_XDP_STAT(x) { #x, \
|
|
+ offsetof(struct mtk_hw_stats, xdp_stats.x) / \
|
|
+ sizeof(u64) }
|
|
+
|
|
static const struct mtk_reg_map mtk_reg_map = {
|
|
.tx_irq_mask = 0x1a1c,
|
|
.tx_irq_status = 0x1a18,
|
|
@@ -141,6 +145,13 @@ static const struct mtk_ethtool_stats {
|
|
MTK_ETHTOOL_STAT(rx_long_errors),
|
|
MTK_ETHTOOL_STAT(rx_checksum_errors),
|
|
MTK_ETHTOOL_STAT(rx_flow_control_packets),
|
|
+ MTK_ETHTOOL_XDP_STAT(rx_xdp_redirect),
|
|
+ MTK_ETHTOOL_XDP_STAT(rx_xdp_pass),
|
|
+ MTK_ETHTOOL_XDP_STAT(rx_xdp_drop),
|
|
+ MTK_ETHTOOL_XDP_STAT(rx_xdp_tx),
|
|
+ MTK_ETHTOOL_XDP_STAT(rx_xdp_tx_errors),
|
|
+ MTK_ETHTOOL_XDP_STAT(tx_xdp_xmit),
|
|
+ MTK_ETHTOOL_XDP_STAT(tx_xdp_xmit_errors),
|
|
};
|
|
|
|
static const char * const mtk_clks_source_name[] = {
|
|
@@ -1459,6 +1470,9 @@ static void mtk_rx_put_buff(struct mtk_r
|
|
static u32 mtk_xdp_run(struct mtk_eth *eth, struct mtk_rx_ring *ring,
|
|
struct xdp_buff *xdp, struct net_device *dev)
|
|
{
|
|
+ struct mtk_mac *mac = netdev_priv(dev);
|
|
+ struct mtk_hw_stats *hw_stats = mac->hw_stats;
|
|
+ u64 *count = &hw_stats->xdp_stats.rx_xdp_drop;
|
|
struct bpf_prog *prog;
|
|
u32 act = XDP_PASS;
|
|
|
|
@@ -1471,13 +1485,16 @@ static u32 mtk_xdp_run(struct mtk_eth *e
|
|
act = bpf_prog_run_xdp(prog, xdp);
|
|
switch (act) {
|
|
case XDP_PASS:
|
|
- goto out;
|
|
+ count = &hw_stats->xdp_stats.rx_xdp_pass;
|
|
+ goto update_stats;
|
|
case XDP_REDIRECT:
|
|
if (unlikely(xdp_do_redirect(dev, xdp, prog))) {
|
|
act = XDP_DROP;
|
|
break;
|
|
}
|
|
- goto out;
|
|
+
|
|
+ count = &hw_stats->xdp_stats.rx_xdp_redirect;
|
|
+ goto update_stats;
|
|
default:
|
|
bpf_warn_invalid_xdp_action(act);
|
|
fallthrough;
|
|
@@ -1490,6 +1507,11 @@ static u32 mtk_xdp_run(struct mtk_eth *e
|
|
|
|
page_pool_put_full_page(ring->page_pool,
|
|
virt_to_head_page(xdp->data), true);
|
|
+
|
|
+update_stats:
|
|
+ u64_stats_update_begin(&hw_stats->syncp);
|
|
+ *count = *count + 1;
|
|
+ u64_stats_update_end(&hw_stats->syncp);
|
|
out:
|
|
rcu_read_unlock();
|
|
|
|
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h
|
|
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
|
|
@@ -568,6 +568,16 @@ struct mtk_tx_dma_v2 {
|
|
struct mtk_eth;
|
|
struct mtk_mac;
|
|
|
|
+struct mtk_xdp_stats {
|
|
+ u64 rx_xdp_redirect;
|
|
+ u64 rx_xdp_pass;
|
|
+ u64 rx_xdp_drop;
|
|
+ u64 rx_xdp_tx;
|
|
+ u64 rx_xdp_tx_errors;
|
|
+ u64 tx_xdp_xmit;
|
|
+ u64 tx_xdp_xmit_errors;
|
|
+};
|
|
+
|
|
/* struct mtk_hw_stats - the structure that holds the traffic statistics.
|
|
* @stats_lock: make sure that stats operations are atomic
|
|
* @reg_offset: the status register offset of the SoC
|
|
@@ -591,6 +601,8 @@ struct mtk_hw_stats {
|
|
u64 rx_checksum_errors;
|
|
u64 rx_flow_control_packets;
|
|
|
|
+ struct mtk_xdp_stats xdp_stats;
|
|
+
|
|
spinlock_t stats_lock;
|
|
u32 reg_offset;
|
|
struct u64_stats_sync syncp;
|