From 0369e358916ef092a1644334f5dd1412051b68a4 Mon Sep 17 00:00:00 2001 From: Thibaut VARENE Date: Fri, 4 Aug 2017 12:29:52 +0200 Subject: generic: provide get_port_stats() on rtl836x 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 --- .../generic/files/drivers/net/phy/rtl8366_smi.c | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'target/linux/generic/files/drivers/net/phy/rtl8366_smi.c') 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 b8cdf30..ae04597 100644 --- a/target/linux/generic/files/drivers/net/phy/rtl8366_smi.c +++ b/target/linux/generic/files/drivers/net/phy/rtl8366_smi.c @@ -1030,6 +1030,33 @@ int rtl8366_sw_get_port_mib(struct switch_dev *dev, } EXPORT_SYMBOL_GPL(rtl8366_sw_get_port_mib); +int rtl8366_sw_get_port_stats(struct switch_dev *dev, int port, + struct switch_port_stats *stats, + int txb_id, int rxb_id) +{ + struct rtl8366_smi *smi = sw_to_rtl8366_smi(dev); + unsigned long long counter = 0; + int ret; + + if (port >= smi->num_ports) + return -EINVAL; + + ret = smi->ops->get_mib_counter(smi, txb_id, port, &counter); + if (ret) + return ret; + + stats->tx_bytes = counter; + + ret = smi->ops->get_mib_counter(smi, rxb_id, port, &counter); + if (ret) + return ret; + + stats->rx_bytes = counter; + + return 0; +} +EXPORT_SYMBOL_GPL(rtl8366_sw_get_port_stats); + int rtl8366_sw_get_vlan_info(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val) -- cgit v1.1