aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThibaut VARENE <hacks@slashdirt.org>2017-08-04 12:27:32 +0200
committerJohn Crispin <john@phrozen.org>2017-09-01 09:30:35 +0200
commit2b3ab0208eddadbf4413576eb57e608ee6e45d5c (patch)
tree715eb3aec8f7b08bba2a6b1e7f6d093782ef6dab
parent7a423c389a162d2945901f0b5e7c604d36c64526 (diff)
downloadupstream-2b3ab0208eddadbf4413576eb57e608ee6e45d5c.tar.gz
upstream-2b3ab0208eddadbf4413576eb57e608ee6e45d5c.tar.bz2
upstream-2b3ab0208eddadbf4413576eb57e608ee6e45d5c.zip
ramips: provide get_port_stats() on mt7530/762x switches
This patch provides a generic switch_dev_ops 'get_port_stats()' callback by taping into the relevant port MIB counters. This callback is used by swconfig_leds led trigger to blink LEDs with port network traffic. Signed-off-by: Thibaut VARENE <hacks@slashdirt.org>
-rw-r--r--target/linux/ramips/files-4.9/drivers/net/ethernet/mtk/mt7530.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/target/linux/ramips/files-4.9/drivers/net/ethernet/mtk/mt7530.c b/target/linux/ramips/files-4.9/drivers/net/ethernet/mtk/mt7530.c
index 1ec62e06d7..74b4a7103c 100644
--- a/target/linux/ramips/files-4.9/drivers/net/ethernet/mtk/mt7530.c
+++ b/target/linux/ramips/files-4.9/drivers/net/ethernet/mtk/mt7530.c
@@ -44,6 +44,12 @@
#define MT7530_MAX_VID 4095
#define MT7530_MIN_VID 0
+#define MT7530_PORT_MIB_TXB_ID 2 /* TxGOC */
+#define MT7530_PORT_MIB_RXB_ID 6 /* RxGOC */
+
+#define MT7621_PORT_MIB_TXB_ID 18 /* TxByte */
+#define MT7621_PORT_MIB_RXB_ID 37 /* RxByte */
+
/* registers */
#define REG_ESW_VLAN_VTCR 0x90
#define REG_ESW_VLAN_VAWD1 0x94
@@ -744,6 +750,34 @@ static int mt7530_sw_get_port_mib(struct switch_dev *dev,
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->tx_bytes = get_mib_counter_port_7620(priv, MT7530_PORT_MIB_TXB_ID, port);
+ stats->rx_bytes = get_mib_counter_port_7620(priv, MT7530_PORT_MIB_RXB_ID, port);
+
+ return 0;
+}
+
+static int mt7621_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->tx_bytes = get_mib_counter(priv, MT7621_PORT_MIB_TXB_ID, port);
+ stats->rx_bytes = get_mib_counter(priv, MT7621_PORT_MIB_RXB_ID, port);
+
+ return 0;
+}
+
static const struct switch_attr mt7530_global[] = {
{
.type = SWITCH_TYPE_INT,
@@ -811,6 +845,7 @@ static const struct switch_dev_ops mt7621_ops = {
.get_port_pvid = mt7530_get_port_pvid,
.set_port_pvid = mt7530_set_port_pvid,
.get_port_link = mt7530_get_port_link,
+ .get_port_stats = mt7621_get_port_stats,
.apply_config = mt7530_apply_config,
.reset_switch = mt7530_reset_switch,
};
@@ -833,6 +868,7 @@ static const struct switch_dev_ops mt7530_ops = {
.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,
};