aboutsummaryrefslogtreecommitdiffstats
path: root/target
diff options
context:
space:
mode:
authorThibaut VARENE <hacks@slashdirt.org>2017-08-04 12:28:56 +0200
committerJohn Crispin <john@phrozen.org>2017-09-01 09:30:35 +0200
commit4ddbc43cc15c2fa128a2f169964ef7eb508cf2c5 (patch)
treef2d7805f672368386a0de47ec10ad00956fc3074 /target
parent4d8a66d9346373c2a7fcac5bdae3f662a9dbd9df (diff)
downloadupstream-4ddbc43cc15c2fa128a2f169964ef7eb508cf2c5.tar.gz
upstream-4ddbc43cc15c2fa128a2f169964ef7eb508cf2c5.tar.bz2
upstream-4ddbc43cc15c2fa128a2f169964ef7eb508cf2c5.zip
generic: provide get_port_stats() on adm6996 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>
Diffstat (limited to 'target')
-rw-r--r--target/linux/generic/files/drivers/net/phy/adm6996.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/target/linux/generic/files/drivers/net/phy/adm6996.c b/target/linux/generic/files/drivers/net/phy/adm6996.c
index d9ea828929..42928bab07 100644
--- a/target/linux/generic/files/drivers/net/phy/adm6996.c
+++ b/target/linux/generic/files/drivers/net/phy/adm6996.c
@@ -112,6 +112,9 @@ static const struct adm6996_mib_desc adm6996_mibs[] = {
MIB_DESC(ADM_CL30, "Error"),
};
+#define ADM6996_MIB_RXB_ID 1
+#define ADM6996_MIB_TXB_ID 3
+
static inline u16
r16(struct adm6996_priv *priv, enum admreg reg)
{
@@ -888,6 +891,34 @@ adm6996_sw_get_port_mib(struct switch_dev *dev,
return 0;
}
+static int
+adm6996_get_port_stats(struct switch_dev *dev, int port,
+ struct switch_port_stats *stats)
+{
+ struct adm6996_priv *priv = to_adm(dev);
+ int id;
+ u32 reg = 0;
+
+ if (port >= ADM_NUM_PORTS)
+ return -EINVAL;
+
+ mutex_lock(&priv->mib_lock);
+
+ id = ADM6996_MIB_TXB_ID;
+ reg = r16(priv, adm6996_mibs[id].offset + ADM_OFFSET_PORT(port));
+ reg += r16(priv, adm6996_mibs[id].offset + ADM_OFFSET_PORT(port) + 1) << 16;
+ stats->tx_bytes = reg;
+
+ id = ADM6996_MIB_RXB_ID;
+ reg = r16(priv, adm6996_mibs[id].offset + ADM_OFFSET_PORT(port));
+ reg += r16(priv, adm6996_mibs[id].offset + ADM_OFFSET_PORT(port) + 1) << 16;
+ stats->rx_bytes = reg;
+
+ mutex_unlock(&priv->mib_lock);
+
+ return 0;
+}
+
static struct switch_attr adm6996_globals[] = {
{
.type = SWITCH_TYPE_INT,
@@ -956,6 +987,7 @@ static struct switch_dev_ops adm6996_ops = {
.apply_config = adm6996_hw_apply,
.reset_switch = adm6996_reset_switch,
.get_port_link = adm6996_get_port_link,
+ .get_port_stats = adm6996_get_port_stats,
};
static int adm6996_switch_init(struct adm6996_priv *priv, const char *alias, struct net_device *netdev)