Hi, comments inline
On 23/07/2016 17:01, p.wa...@gmx.at wrote: > From: P.Wassi <p.wa...@gmx.at> > > Add get_port_stats function to mt7530 swconfig driver. > Signed-off-by: P.Wassi <p.wa...@gmx.at> > --- > If one uses "switch" as a trigger for the LEDs, in order to have > the LEDs blinking when there's traffic, swconfig_leds.c needs to > have a get_port_stats function from the swconfig driver. > The function added here is tested on MT7620A, implemented (register > offsets) according to "MT7620 Programming Guide", page 334, 335. > > linux/ramips/patches-4.4/0513-net-mediatek-add-swconfig-driver-for-gsw_mt762x.patch > | 21 +++++++++- > 1 file changed, 19 insertions(+), 2 deletions(-) > > diff -rupN > a/target/linux/ramips/patches-4.4/0513-net-mediatek-add-swconfig-driver-for-gsw_mt762x.patch > > b/target/linux/ramips/patches-4.4/0513-net-mediatek-add-swconfig-driver-for-gsw_mt762x.patch > --- > a/target/linux/ramips/patches-4.4/0513-net-mediatek-add-swconfig-driver-for-gsw_mt762x.patch > +++ > b/target/linux/ramips/patches-4.4/0513-net-mediatek-add-swconfig-driver-for-gsw_mt762x.patch > @@ -6,7 +6,7 @@ Subject: [PATCH 513/513] net: mediatek: > Signed-off-by: John Crispin <blo...@openwrt.org> > --- > drivers/net/ethernet/mediatek/Makefile | 4 +- > - drivers/net/ethernet/mediatek/mt7530.c | 804 > +++++++++++++++++++++++++++ > + drivers/net/ethernet/mediatek/mt7530.c | 821 > +++++++++++++++++++++++++++ > drivers/net/ethernet/mediatek/mt7530.h | 20 + > drivers/net/ethernet/mediatek/mtk_eth_soc.c | 9 +- > drivers/net/ethernet/mediatek/mtk_eth_soc.h | 1 + > @@ -28,7 +28,7 @@ Signed-off-by: John Crispin <blogic@open > obj-$(CONFIG_NET_MEDIATEK_SOC) += mtk-eth-soc.o > --- /dev/null > +++ b/drivers/net/ethernet/mediatek/mt7530.c > -@@ -0,0 +1,804 @@ > +@@ -0,0 +1,821 @@ > +/* > + * This program is free software; you can redistribute it and/or > + * modify it under the terms of the GNU General Public License > @@ -650,6 +650,21 @@ Signed-off-by: John Crispin <blogic@open > + 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->rx_bytes = mt7530_r32(priv, 0x4028 + (0x100 * port)); > ++ stats->tx_bytes = mt7530_r32(priv, 0x4018 + (0x100 * port)); please add macros for the register offsets in the header file and use them here. there should be 2 defines for the registers and one for the port offset. John > ++ > ++ return 0; > ++} > ++ > +static const struct switch_attr mt7530_global[] = { > + { > + .type = SWITCH_TYPE_INT, > @@ -751,6 +766,7 @@ Signed-off-by: John Crispin <blogic@open > + .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, > +}; > @@ -773,6 +789,7 @@ Signed-off-by: John Crispin <blogic@open > + .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, > +}; > > _______________________________________________ > Lede-dev mailing list > Lede-dev@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/lede-dev > _______________________________________________ Lede-dev mailing list Lede-dev@lists.infradead.org http://lists.infradead.org/mailman/listinfo/lede-dev