diff options
author | Florian Fainelli <f.fainelli@gmail.com> | 2018-04-25 12:12:50 -0700 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-04-27 11:53:03 -0400 |
commit | 89f09048348936a9a8c5131c8538cc6ed26fd44c (patch) | |
tree | 8b44dd664df9b03217bc751a9319e129dbe2c47a /net/dsa | |
parent | 1d1e79f1c6a57dc3750d328ea38a4c385d4edee8 (diff) | |
download | linux-89f09048348936a9a8c5131c8538cc6ed26fd44c.tar.gz linux-89f09048348936a9a8c5131c8538cc6ed26fd44c.tar.bz2 linux-89f09048348936a9a8c5131c8538cc6ed26fd44c.zip |
net: dsa: Pass stringset to ethtool operations
Up until now we largely assumed that we were interested in ETH_SS_STATS
type of strings for all ethtool operations, this is about to change with
the introduction of additional string sets, e.g: ETH_SS_PHY_STATS.
Update all functions to take an appropriate stringset argument and act
on it when it is different than ETH_SS_STATS for now.
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dsa')
-rw-r--r-- | net/dsa/master.c | 21 | ||||
-rw-r--r-- | net/dsa/slave.c | 5 |
2 files changed, 16 insertions, 10 deletions
diff --git a/net/dsa/master.c b/net/dsa/master.c index 9ec16b39ed15..8d27687fd0ca 100644 --- a/net/dsa/master.c +++ b/net/dsa/master.c @@ -38,11 +38,14 @@ static int dsa_master_get_sset_count(struct net_device *dev, int sset) struct dsa_switch *ds = cpu_dp->ds; int count = 0; - if (ops->get_sset_count) - count += ops->get_sset_count(dev, sset); + if (ops->get_sset_count) { + count = ops->get_sset_count(dev, sset); + if (count < 0) + count = 0; + } - if (sset == ETH_SS_STATS && ds->ops->get_sset_count) - count += ds->ops->get_sset_count(ds, cpu_dp->index); + if (ds->ops->get_sset_count) + count += ds->ops->get_sset_count(ds, cpu_dp->index, sset); return count; } @@ -65,18 +68,20 @@ static void dsa_master_get_strings(struct net_device *dev, uint32_t stringset, pfx[sizeof(pfx) - 1] = '_'; if (ops->get_sset_count && ops->get_strings) { - mcount = ops->get_sset_count(dev, ETH_SS_STATS); + mcount = ops->get_sset_count(dev, stringset); + if (mcount < 0) + mcount = 0; ops->get_strings(dev, stringset, data); } - if (stringset == ETH_SS_STATS && ds->ops->get_strings) { + if (ds->ops->get_strings) { ndata = data + mcount * len; /* This function copies ETH_GSTRINGS_LEN bytes, we will mangle * the output after to prepend our CPU port prefix we * constructed earlier */ - ds->ops->get_strings(ds, port, ndata); - count = ds->ops->get_sset_count(ds, port); + ds->ops->get_strings(ds, port, stringset, ndata); + count = ds->ops->get_sset_count(ds, port, stringset); for (i = 0; i < count; i++) { memmove(ndata + (i * len + sizeof(pfx)), ndata + i * len, len - sizeof(pfx)); diff --git a/net/dsa/slave.c b/net/dsa/slave.c index 18561af7a8f1..f3fb3a0880b1 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -560,7 +560,8 @@ static void dsa_slave_get_strings(struct net_device *dev, strncpy(data + 2 * len, "rx_packets", len); strncpy(data + 3 * len, "rx_bytes", len); if (ds->ops->get_strings) - ds->ops->get_strings(ds, dp->index, data + 4 * len); + ds->ops->get_strings(ds, dp->index, stringset, + data + 4 * len); } } @@ -605,7 +606,7 @@ static int dsa_slave_get_sset_count(struct net_device *dev, int sset) count = 4; if (ds->ops->get_sset_count) - count += ds->ops->get_sset_count(ds, dp->index); + count += ds->ops->get_sset_count(ds, dp->index, sset); return count; } |