diff options
author | Gabor Juhos <juhosg@openwrt.org> | 2010-07-15 13:05:36 +0000 |
---|---|---|
committer | Gabor Juhos <juhosg@openwrt.org> | 2010-07-15 13:05:36 +0000 |
commit | dffd45dc610c71caecaf79fc512e203aadda2b8b (patch) | |
tree | 83843fc1a26e35c66e4d620df11c37c60d987cf4 /target/linux/generic/files/drivers/net/phy/rtl8366_smi.c | |
parent | 0049e74882769e613cc0247dda1d316ac271c0cf (diff) | |
download | upstream-dffd45dc610c71caecaf79fc512e203aadda2b8b.tar.gz upstream-dffd45dc610c71caecaf79fc512e203aadda2b8b.tar.bz2 upstream-dffd45dc610c71caecaf79fc512e203aadda2b8b.zip |
generic: rtl8366: add common rtl8366_sw_get_port_mib function
SVN-Revision: 22200
Diffstat (limited to 'target/linux/generic/files/drivers/net/phy/rtl8366_smi.c')
-rw-r--r-- | target/linux/generic/files/drivers/net/phy/rtl8366_smi.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/target/linux/generic/files/drivers/net/phy/rtl8366_smi.c b/target/linux/generic/files/drivers/net/phy/rtl8366_smi.c index a596c311c1..a45c844cad 100644 --- a/target/linux/generic/files/drivers/net/phy/rtl8366_smi.c +++ b/target/linux/generic/files/drivers/net/phy/rtl8366_smi.c @@ -754,6 +754,40 @@ int rtl8366_sw_set_port_pvid(struct switch_dev *dev, int port, int val) } EXPORT_SYMBOL_GPL(rtl8366_sw_set_port_pvid); +int rtl8366_sw_get_port_mib(struct switch_dev *dev, + const struct switch_attr *attr, + struct switch_val *val) +{ + struct rtl8366_smi *smi = sw_to_rtl8366_smi(dev); + int i, len = 0; + unsigned long long counter = 0; + char *buf = smi->buf; + + if (val->port_vlan >= smi->num_ports) + return -EINVAL; + + len += snprintf(buf + len, sizeof(smi->buf) - len, + "Port %d MIB counters\n", + val->port_vlan); + + for (i = 0; i < smi->num_mib_counters; ++i) { + len += snprintf(buf + len, sizeof(smi->buf) - len, + "%-36s: ", smi->mib_counters[i].name); + if (!smi->ops->get_mib_counter(smi, i, val->port_vlan, + &counter)) + len += snprintf(buf + len, sizeof(smi->buf) - len, + "%llu\n", counter); + else + len += snprintf(buf + len, sizeof(smi->buf) - len, + "%s\n", "error"); + } + + val->value.s = buf; + val->len = len; + return 0; +} +EXPORT_SYMBOL_GPL(rtl8366_sw_get_port_mib); + struct rtl8366_smi *rtl8366_smi_alloc(struct device *parent) { struct rtl8366_smi *smi; |