Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: dsa: ar9331: add support for pause stats

Add support for pause stats.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Oleksij Rempel and committed by
Jakub Kicinski
ea294f39 3d410403

+17
+17
drivers/net/dsa/qca/ar9331.c
··· 231 231 int idx; 232 232 struct delayed_work mib_read; 233 233 struct rtnl_link_stats64 stats; 234 + struct ethtool_pause_stats pause_stats; 234 235 struct spinlock stats_lock; 235 236 }; 236 237 ··· 605 604 static void ar9331_read_stats(struct ar9331_sw_port *port) 606 605 { 607 606 struct ar9331_sw_priv *priv = ar9331_sw_port_to_priv(port); 607 + struct ethtool_pause_stats *pstats = &port->pause_stats; 608 608 struct rtnl_link_stats64 *stats = &port->stats; 609 609 struct ar9331_sw_stats_raw raw; 610 610 int ret; ··· 646 644 stats->multicast += raw.rxmulti; 647 645 stats->collisions += raw.txcollision; 648 646 647 + pstats->tx_pause_frames += raw.txpause; 648 + pstats->rx_pause_frames += raw.rxpause; 649 + 649 650 spin_unlock(&port->stats_lock); 650 651 } 651 652 ··· 673 668 spin_unlock(&p->stats_lock); 674 669 } 675 670 671 + static void ar9331_get_pause_stats(struct dsa_switch *ds, int port, 672 + struct ethtool_pause_stats *pause_stats) 673 + { 674 + struct ar9331_sw_priv *priv = (struct ar9331_sw_priv *)ds->priv; 675 + struct ar9331_sw_port *p = &priv->port[port]; 676 + 677 + spin_lock(&p->stats_lock); 678 + memcpy(pause_stats, &p->pause_stats, sizeof(*pause_stats)); 679 + spin_unlock(&p->stats_lock); 680 + } 681 + 676 682 static const struct dsa_switch_ops ar9331_sw_ops = { 677 683 .get_tag_protocol = ar9331_sw_get_tag_protocol, 678 684 .setup = ar9331_sw_setup, ··· 693 677 .phylink_mac_link_down = ar9331_sw_phylink_mac_link_down, 694 678 .phylink_mac_link_up = ar9331_sw_phylink_mac_link_up, 695 679 .get_stats64 = ar9331_get_stats64, 680 + .get_pause_stats = ar9331_get_pause_stats, 696 681 }; 697 682 698 683 static irqreturn_t ar9331_sw_irq(int irq, void *data)