Commit c4748ff6 authored by Oleksij Rempel's avatar Oleksij Rempel Committed by Jakub Kicinski

net: dsa: microchip: add pause stats support

Add support for pause specific stats.

Tested on ksz9477.
Signed-off-by: default avatarOleksij Rempel <o.rempel@pengutronix.de>
Reviewed-by: default avatarVladimir Oltean <olteanv@gmail.com>
Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent ea294f39
...@@ -671,12 +671,14 @@ static void ksz_phylink_get_caps(struct dsa_switch *ds, int port, ...@@ -671,12 +671,14 @@ static void ksz_phylink_get_caps(struct dsa_switch *ds, int port,
void ksz_r_mib_stats64(struct ksz_device *dev, int port) void ksz_r_mib_stats64(struct ksz_device *dev, int port)
{ {
struct ethtool_pause_stats *pstats;
struct rtnl_link_stats64 *stats; struct rtnl_link_stats64 *stats;
struct ksz_stats_raw *raw; struct ksz_stats_raw *raw;
struct ksz_port_mib *mib; struct ksz_port_mib *mib;
mib = &dev->ports[port].mib; mib = &dev->ports[port].mib;
stats = &mib->stats64; stats = &mib->stats64;
pstats = &mib->pause_stats;
raw = (struct ksz_stats_raw *)mib->counters; raw = (struct ksz_stats_raw *)mib->counters;
spin_lock(&mib->stats64_lock); spin_lock(&mib->stats64_lock);
...@@ -708,6 +710,9 @@ void ksz_r_mib_stats64(struct ksz_device *dev, int port) ...@@ -708,6 +710,9 @@ void ksz_r_mib_stats64(struct ksz_device *dev, int port)
stats->multicast = raw->rx_mcast; stats->multicast = raw->rx_mcast;
stats->collisions = raw->tx_total_col; stats->collisions = raw->tx_total_col;
pstats->tx_pause_frames = raw->tx_pause;
pstats->rx_pause_frames = raw->rx_pause;
spin_unlock(&mib->stats64_lock); spin_unlock(&mib->stats64_lock);
} }
...@@ -724,6 +729,19 @@ static void ksz_get_stats64(struct dsa_switch *ds, int port, ...@@ -724,6 +729,19 @@ static void ksz_get_stats64(struct dsa_switch *ds, int port,
spin_unlock(&mib->stats64_lock); spin_unlock(&mib->stats64_lock);
} }
static void ksz_get_pause_stats(struct dsa_switch *ds, int port,
struct ethtool_pause_stats *pause_stats)
{
struct ksz_device *dev = ds->priv;
struct ksz_port_mib *mib;
mib = &dev->ports[port].mib;
spin_lock(&mib->stats64_lock);
memcpy(pause_stats, &mib->pause_stats, sizeof(*pause_stats));
spin_unlock(&mib->stats64_lock);
}
static void ksz_get_strings(struct dsa_switch *ds, int port, static void ksz_get_strings(struct dsa_switch *ds, int port,
u32 stringset, uint8_t *buf) u32 stringset, uint8_t *buf)
{ {
...@@ -1336,6 +1354,7 @@ static const struct dsa_switch_ops ksz_switch_ops = { ...@@ -1336,6 +1354,7 @@ static const struct dsa_switch_ops ksz_switch_ops = {
.port_mirror_add = ksz_port_mirror_add, .port_mirror_add = ksz_port_mirror_add,
.port_mirror_del = ksz_port_mirror_del, .port_mirror_del = ksz_port_mirror_del,
.get_stats64 = ksz_get_stats64, .get_stats64 = ksz_get_stats64,
.get_pause_stats = ksz_get_pause_stats,
.port_change_mtu = ksz_change_mtu, .port_change_mtu = ksz_change_mtu,
.port_max_mtu = ksz_max_mtu, .port_max_mtu = ksz_max_mtu,
}; };
......
...@@ -25,6 +25,7 @@ struct ksz_port_mib { ...@@ -25,6 +25,7 @@ struct ksz_port_mib {
u8 cnt_ptr; u8 cnt_ptr;
u64 *counters; u64 *counters;
struct rtnl_link_stats64 stats64; struct rtnl_link_stats64 stats64;
struct ethtool_pause_stats pause_stats;
struct spinlock stats64_lock; struct spinlock stats64_lock;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment