aboutsummaryrefslogtreecommitdiffstats
path: root/net/dsa/master.c
diff options
context:
space:
mode:
authorFlorian Fainelli <f.fainelli@gmail.com>2018-04-25 15:12:50 -0400
committerDavid S. Miller <davem@davemloft.net>2018-04-27 11:53:03 -0400
commit89f09048348936a9a8c5131c8538cc6ed26fd44c (patch)
tree8b44dd664df9b03217bc751a9319e129dbe2c47a /net/dsa/master.c
parent1d1e79f1c6a57dc3750d328ea38a4c385d4edee8 (diff)
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/master.c')
-rw-r--r--net/dsa/master.c21
1 files changed, 13 insertions, 8 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)
38 struct dsa_switch *ds = cpu_dp->ds; 38 struct dsa_switch *ds = cpu_dp->ds;
39 int count = 0; 39 int count = 0;
40 40
41 if (ops->get_sset_count) 41 if (ops->get_sset_count) {
42 count += ops->get_sset_count(dev, sset); 42 count = ops->get_sset_count(dev, sset);
43 if (count < 0)
44 count = 0;
45 }
43 46
44 if (sset == ETH_SS_STATS && ds->ops->get_sset_count) 47 if (ds->ops->get_sset_count)
45 count += ds->ops->get_sset_count(ds, cpu_dp->index); 48 count += ds->ops->get_sset_count(ds, cpu_dp->index, sset);
46 49
47 return count; 50 return count;
48} 51}
@@ -65,18 +68,20 @@ static void dsa_master_get_strings(struct net_device *dev, uint32_t stringset,
65 pfx[sizeof(pfx) - 1] = '_'; 68 pfx[sizeof(pfx) - 1] = '_';
66 69
67 if (ops->get_sset_count && ops->get_strings) { 70 if (ops->get_sset_count && ops->get_strings) {
68 mcount = ops->get_sset_count(dev, ETH_SS_STATS); 71 mcount = ops->get_sset_count(dev, stringset);
72 if (mcount < 0)
73 mcount = 0;
69 ops->get_strings(dev, stringset, data); 74 ops->get_strings(dev, stringset, data);
70 } 75 }
71 76
72 if (stringset == ETH_SS_STATS && ds->ops->get_strings) { 77 if (ds->ops->get_strings) {
73 ndata = data + mcount * len; 78 ndata = data + mcount * len;
74 /* This function copies ETH_GSTRINGS_LEN bytes, we will mangle 79 /* This function copies ETH_GSTRINGS_LEN bytes, we will mangle
75 * the output after to prepend our CPU port prefix we 80 * the output after to prepend our CPU port prefix we
76 * constructed earlier 81 * constructed earlier
77 */ 82 */
78 ds->ops->get_strings(ds, port, ndata); 83 ds->ops->get_strings(ds, port, stringset, ndata);
79 count = ds->ops->get_sset_count(ds, port); 84 count = ds->ops->get_sset_count(ds, port, stringset);
80 for (i = 0; i < count; i++) { 85 for (i = 0; i < count; i++) {
81 memmove(ndata + (i * len + sizeof(pfx)), 86 memmove(ndata + (i * len + sizeof(pfx)),
82 ndata + i * len, len - sizeof(pfx)); 87 ndata + i * len, len - sizeof(pfx));