aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/generic
diff options
context:
space:
mode:
authorJohn Crispin <blogic@openwrt.org>2016-03-04 08:33:22 +0000
committerJohn Crispin <blogic@openwrt.org>2016-03-04 08:33:22 +0000
commitb95b864dcfec6ef6a11cb52943ce4903146a6cd9 (patch)
tree287c48940906bd46803bb45701dd0fec9e15e589 /target/linux/generic
parentd3586fb3f1c67b50daf0ac19b398fb5dd324730e (diff)
downloadmaster-187ad058-b95b864dcfec6ef6a11cb52943ce4903146a6cd9.tar.gz
master-187ad058-b95b864dcfec6ef6a11cb52943ce4903146a6cd9.tar.bz2
master-187ad058-b95b864dcfec6ef6a11cb52943ce4903146a6cd9.zip
AR8216: don't display MIB counters if all are empty
For unused switch ports all MIB values are zero. Displaying ~40 empty MIB counters is just confusing and makes it hard to read the output of swconfig dev <dev> show. Therefore, if all MIB counters for a port are zero, just display an info that the MIB counters are empty. Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> git-svn-id: svn://svn.openwrt.org/openwrt/trunk@48910 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux/generic')
-rw-r--r--target/linux/generic/files/drivers/net/phy/ar8216.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/target/linux/generic/files/drivers/net/phy/ar8216.c b/target/linux/generic/files/drivers/net/phy/ar8216.c
index 75db1f120b..daa59083e3 100644
--- a/target/linux/generic/files/drivers/net/phy/ar8216.c
+++ b/target/linux/generic/files/drivers/net/phy/ar8216.c
@@ -1329,6 +1329,7 @@ ar8xxx_sw_get_port_mib(struct switch_dev *dev,
int ret;
char *buf = priv->buf;
int i, len = 0;
+ bool mib_stats_empty = true;
if (!ar8xxx_has_mib_counters(priv))
return -EOPNOTSUPP;
@@ -1349,11 +1350,17 @@ ar8xxx_sw_get_port_mib(struct switch_dev *dev,
port);
mib_stats = &priv->mib_stats[port * chip->num_mibs];
- for (i = 0; i < chip->num_mibs; i++)
+ for (i = 0; i < chip->num_mibs; i++) {
len += snprintf(buf + len, sizeof(priv->buf) - len,
"%-12s: %llu\n",
chip->mib_decs[i].name,
mib_stats[i]);
+ if (mib_stats_empty && mib_stats[i])
+ mib_stats_empty = false;
+ }
+
+ if (mib_stats_empty)
+ len = snprintf(buf, sizeof(priv->buf), "No MIB data");
val->value.s = buf;
val->len = len;