[LEDE-DEV] [PATCH] ramips: add get_port_stats to mt7530 swconfig driver
p.wassi at gmx.at
p.wassi at gmx.at
Sat Jul 23 08:01:01 PDT 2016
From: P.Wassi <p.wassi at gmx.at>
Add get_port_stats function to mt7530 swconfig driver.
Signed-off-by: P.Wassi <p.wassi at gmx.at>
---
If one uses "switch" as a trigger for the LEDs, in order to have
the LEDs blinking when there's traffic, swconfig_leds.c needs to
have a get_port_stats function from the swconfig driver.
The function added here is tested on MT7620A, implemented (register
offsets) according to "MT7620 Programming Guide", page 334, 335.
linux/ramips/patches-4.4/0513-net-mediatek-add-swconfig-driver-for-gsw_mt762x.patch | 21 +++++++++-
1 file changed, 19 insertions(+), 2 deletions(-)
diff -rupN a/target/linux/ramips/patches-4.4/0513-net-mediatek-add-swconfig-driver-for-gsw_mt762x.patch b/target/linux/ramips/patches-4.4/0513-net-mediatek-add-swconfig-driver-for-gsw_mt762x.patch
--- a/target/linux/ramips/patches-4.4/0513-net-mediatek-add-swconfig-driver-for-gsw_mt762x.patch
+++ b/target/linux/ramips/patches-4.4/0513-net-mediatek-add-swconfig-driver-for-gsw_mt762x.patch
@@ -6,7 +6,7 @@ Subject: [PATCH 513/513] net: mediatek:
Signed-off-by: John Crispin <blogic at openwrt.org>
---
drivers/net/ethernet/mediatek/Makefile | 4 +-
- drivers/net/ethernet/mediatek/mt7530.c | 804 +++++++++++++++++++++++++++
+ drivers/net/ethernet/mediatek/mt7530.c | 821 +++++++++++++++++++++++++++
drivers/net/ethernet/mediatek/mt7530.h | 20 +
drivers/net/ethernet/mediatek/mtk_eth_soc.c | 9 +-
drivers/net/ethernet/mediatek/mtk_eth_soc.h | 1 +
@@ -28,7 +28,7 @@ Signed-off-by: John Crispin <blogic at open
obj-$(CONFIG_NET_MEDIATEK_SOC) += mtk-eth-soc.o
--- /dev/null
+++ b/drivers/net/ethernet/mediatek/mt7530.c
-@@ -0,0 +1,804 @@
+@@ -0,0 +1,821 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
@@ -650,6 +650,21 @@ Signed-off-by: John Crispin <blogic at open
+ return 0;
+}
+
++static int
++mt7530_get_port_stats(struct switch_dev *dev, int port,
++ struct switch_port_stats *stats)
++{
++struct mt7530_priv *priv = container_of(dev, struct mt7530_priv, swdev);
++
++ if (port < 0 || port >= MT7530_NUM_PORTS)
++ return -EINVAL;
++
++ stats->rx_bytes = mt7530_r32(priv, 0x4028 + (0x100 * port));
++ stats->tx_bytes = mt7530_r32(priv, 0x4018 + (0x100 * port));
++
++ return 0;
++}
++
+static const struct switch_attr mt7530_global[] = {
+ {
+ .type = SWITCH_TYPE_INT,
@@ -751,6 +766,7 @@ Signed-off-by: John Crispin <blogic at open
+ .get_port_pvid = mt7530_get_port_pvid,
+ .set_port_pvid = mt7530_set_port_pvid,
+ .get_port_link = mt7530_get_port_link,
++ .get_port_stats = mt7530_get_port_stats,
+ .apply_config = mt7530_apply_config,
+ .reset_switch = mt7530_reset_switch,
+};
@@ -773,6 +789,7 @@ Signed-off-by: John Crispin <blogic at open
+ .get_port_pvid = mt7530_get_port_pvid,
+ .set_port_pvid = mt7530_set_port_pvid,
+ .get_port_link = mt7530_get_port_link,
++ .get_port_stats = mt7530_get_port_stats,
+ .apply_config = mt7530_apply_config,
+ .reset_switch = mt7530_reset_switch,
+};
More information about the Lede-dev
mailing list