summaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--drivers/net/dsa/b53/b53_common.c11
-rw-r--r--drivers/net/dsa/b53/b53_priv.h5
-rw-r--r--drivers/net/dsa/dsa_loop.c11
-rw-r--r--drivers/net/dsa/lan9303-core.c11
-rw-r--r--drivers/net/dsa/microchip/ksz_common.c11
-rw-r--r--drivers/net/dsa/mt7530.c11
-rw-r--r--drivers/net/dsa/mv88e6xxx/chip.c10
-rw-r--r--drivers/net/dsa/qca8k.c10
-rw-r--r--include/net/dsa.h5
-rw-r--r--net/dsa/master.c21
-rw-r--r--net/dsa/slave.c5
11 files changed, 83 insertions, 28 deletions
diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
index 78616787f2a3..726b2d8c6fe9 100644
--- a/drivers/net/dsa/b53/b53_common.c
+++ b/drivers/net/dsa/b53/b53_common.c
@@ -806,13 +806,17 @@ static unsigned int b53_get_mib_size(struct b53_device *dev)
806 return B53_MIBS_SIZE; 806 return B53_MIBS_SIZE;
807} 807}
808 808
809void b53_get_strings(struct dsa_switch *ds, int port, uint8_t *data) 809void b53_get_strings(struct dsa_switch *ds, int port, u32 stringset,
810 uint8_t *data)
810{ 811{
811 struct b53_device *dev = ds->priv; 812 struct b53_device *dev = ds->priv;
812 const struct b53_mib_desc *mibs = b53_get_mib(dev); 813 const struct b53_mib_desc *mibs = b53_get_mib(dev);
813 unsigned int mib_size = b53_get_mib_size(dev); 814 unsigned int mib_size = b53_get_mib_size(dev);
814 unsigned int i; 815 unsigned int i;
815 816
817 if (stringset != ETH_SS_STATS)
818 return;
819
816 for (i = 0; i < mib_size; i++) 820 for (i = 0; i < mib_size; i++)
817 strlcpy(data + i * ETH_GSTRING_LEN, 821 strlcpy(data + i * ETH_GSTRING_LEN,
818 mibs[i].name, ETH_GSTRING_LEN); 822 mibs[i].name, ETH_GSTRING_LEN);
@@ -852,10 +856,13 @@ void b53_get_ethtool_stats(struct dsa_switch *ds, int port, uint64_t *data)
852} 856}
853EXPORT_SYMBOL(b53_get_ethtool_stats); 857EXPORT_SYMBOL(b53_get_ethtool_stats);
854 858
855int b53_get_sset_count(struct dsa_switch *ds, int port) 859int b53_get_sset_count(struct dsa_switch *ds, int port, int sset)
856{ 860{
857 struct b53_device *dev = ds->priv; 861 struct b53_device *dev = ds->priv;
858 862
863 if (sset != ETH_SS_STATS)
864 return 0;
865
859 return b53_get_mib_size(dev); 866 return b53_get_mib_size(dev);
860} 867}
861EXPORT_SYMBOL(b53_get_sset_count); 868EXPORT_SYMBOL(b53_get_sset_count);
diff --git a/drivers/net/dsa/b53/b53_priv.h b/drivers/net/dsa/b53/b53_priv.h
index 1187ebd79287..b933d5cb5c2d 100644
--- a/drivers/net/dsa/b53/b53_priv.h
+++ b/drivers/net/dsa/b53/b53_priv.h
@@ -286,9 +286,10 @@ static inline int b53_switch_get_reset_gpio(struct b53_device *dev)
286/* Exported functions towards other drivers */ 286/* Exported functions towards other drivers */
287void b53_imp_vlan_setup(struct dsa_switch *ds, int cpu_port); 287void b53_imp_vlan_setup(struct dsa_switch *ds, int cpu_port);
288int b53_configure_vlan(struct dsa_switch *ds); 288int b53_configure_vlan(struct dsa_switch *ds);
289void b53_get_strings(struct dsa_switch *ds, int port, uint8_t *data); 289void b53_get_strings(struct dsa_switch *ds, int port, u32 stringset,
290 uint8_t *data);
290void b53_get_ethtool_stats(struct dsa_switch *ds, int port, uint64_t *data); 291void b53_get_ethtool_stats(struct dsa_switch *ds, int port, uint64_t *data);
291int b53_get_sset_count(struct dsa_switch *ds, int port); 292int b53_get_sset_count(struct dsa_switch *ds, int port, int sset);
292int b53_br_join(struct dsa_switch *ds, int port, struct net_device *bridge); 293int b53_br_join(struct dsa_switch *ds, int port, struct net_device *bridge);
293void b53_br_leave(struct dsa_switch *ds, int port, struct net_device *bridge); 294void b53_br_leave(struct dsa_switch *ds, int port, struct net_device *bridge);
294void b53_br_set_stp_state(struct dsa_switch *ds, int port, u8 state); 295void b53_br_set_stp_state(struct dsa_switch *ds, int port, u8 state);
diff --git a/drivers/net/dsa/dsa_loop.c b/drivers/net/dsa/dsa_loop.c
index f77be9f85cb3..9354cc08d3fd 100644
--- a/drivers/net/dsa/dsa_loop.c
+++ b/drivers/net/dsa/dsa_loop.c
@@ -86,16 +86,23 @@ static int dsa_loop_setup(struct dsa_switch *ds)
86 return 0; 86 return 0;
87} 87}
88 88
89static int dsa_loop_get_sset_count(struct dsa_switch *ds, int port) 89static int dsa_loop_get_sset_count(struct dsa_switch *ds, int port, int sset)
90{ 90{
91 if (sset != ETH_SS_STATS)
92 return 0;
93
91 return __DSA_LOOP_CNT_MAX; 94 return __DSA_LOOP_CNT_MAX;
92} 95}
93 96
94static void dsa_loop_get_strings(struct dsa_switch *ds, int port, uint8_t *data) 97static void dsa_loop_get_strings(struct dsa_switch *ds, int port,
98 u32 stringset, uint8_t *data)
95{ 99{
96 struct dsa_loop_priv *ps = ds->priv; 100 struct dsa_loop_priv *ps = ds->priv;
97 unsigned int i; 101 unsigned int i;
98 102
103 if (stringset != ETH_SS_STATS)
104 return;
105
99 for (i = 0; i < __DSA_LOOP_CNT_MAX; i++) 106 for (i = 0; i < __DSA_LOOP_CNT_MAX; i++)
100 memcpy(data + i * ETH_GSTRING_LEN, 107 memcpy(data + i * ETH_GSTRING_LEN,
101 ps->ports[port].mib[i].name, ETH_GSTRING_LEN); 108 ps->ports[port].mib[i].name, ETH_GSTRING_LEN);
diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c
index fefa454f3e56..b4f6e1a67dd9 100644
--- a/drivers/net/dsa/lan9303-core.c
+++ b/drivers/net/dsa/lan9303-core.c
@@ -977,10 +977,14 @@ static const struct lan9303_mib_desc lan9303_mib[] = {
977 { .offset = LAN9303_MAC_TX_LATECOL_0, .name = "TxLateCol", }, 977 { .offset = LAN9303_MAC_TX_LATECOL_0, .name = "TxLateCol", },
978}; 978};
979 979
980static void lan9303_get_strings(struct dsa_switch *ds, int port, uint8_t *data) 980static void lan9303_get_strings(struct dsa_switch *ds, int port,
981 u32 stringset, uint8_t *data)
981{ 982{
982 unsigned int u; 983 unsigned int u;
983 984
985 if (stringset != ETH_SS_STATS)
986 return;
987
984 for (u = 0; u < ARRAY_SIZE(lan9303_mib); u++) { 988 for (u = 0; u < ARRAY_SIZE(lan9303_mib); u++) {
985 strncpy(data + u * ETH_GSTRING_LEN, lan9303_mib[u].name, 989 strncpy(data + u * ETH_GSTRING_LEN, lan9303_mib[u].name,
986 ETH_GSTRING_LEN); 990 ETH_GSTRING_LEN);
@@ -1007,8 +1011,11 @@ static void lan9303_get_ethtool_stats(struct dsa_switch *ds, int port,
1007 } 1011 }
1008} 1012}
1009 1013
1010static int lan9303_get_sset_count(struct dsa_switch *ds, int port) 1014static int lan9303_get_sset_count(struct dsa_switch *ds, int port, int sset)
1011{ 1015{
1016 if (sset != ETH_SS_STATS)
1017 return 0;
1018
1012 return ARRAY_SIZE(lan9303_mib); 1019 return ARRAY_SIZE(lan9303_mib);
1013} 1020}
1014 1021
diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c
index bcb3e6c734f2..7210c49b7922 100644
--- a/drivers/net/dsa/microchip/ksz_common.c
+++ b/drivers/net/dsa/microchip/ksz_common.c
@@ -439,15 +439,22 @@ static void ksz_disable_port(struct dsa_switch *ds, int port,
439 ksz_port_cfg(dev, port, REG_PORT_CTRL_0, PORT_MAC_LOOPBACK, true); 439 ksz_port_cfg(dev, port, REG_PORT_CTRL_0, PORT_MAC_LOOPBACK, true);
440} 440}
441 441
442static int ksz_sset_count(struct dsa_switch *ds, int port) 442static int ksz_sset_count(struct dsa_switch *ds, int port, int sset)
443{ 443{
444 if (sset != ETH_SS_STATS)
445 return 0;
446
444 return TOTAL_SWITCH_COUNTER_NUM; 447 return TOTAL_SWITCH_COUNTER_NUM;
445} 448}
446 449
447static void ksz_get_strings(struct dsa_switch *ds, int port, uint8_t *buf) 450static void ksz_get_strings(struct dsa_switch *ds, int port,
451 u32 stringset, uint8_t *buf)
448{ 452{
449 int i; 453 int i;
450 454
455 if (stringset != ETH_SS_STATS)
456 return;
457
451 for (i = 0; i < TOTAL_SWITCH_COUNTER_NUM; i++) { 458 for (i = 0; i < TOTAL_SWITCH_COUNTER_NUM; i++) {
452 memcpy(buf + i * ETH_GSTRING_LEN, mib_names[i].string, 459 memcpy(buf + i * ETH_GSTRING_LEN, mib_names[i].string,
453 ETH_GSTRING_LEN); 460 ETH_GSTRING_LEN);
diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c
index 80a4dbc3a499..62e486652e62 100644
--- a/drivers/net/dsa/mt7530.c
+++ b/drivers/net/dsa/mt7530.c
@@ -573,10 +573,14 @@ static int mt7530_phy_write(struct dsa_switch *ds, int port, int regnum,
573} 573}
574 574
575static void 575static void
576mt7530_get_strings(struct dsa_switch *ds, int port, uint8_t *data) 576mt7530_get_strings(struct dsa_switch *ds, int port, u32 stringset,
577 uint8_t *data)
577{ 578{
578 int i; 579 int i;
579 580
581 if (stringset != ETH_SS_STATS)
582 return;
583
580 for (i = 0; i < ARRAY_SIZE(mt7530_mib); i++) 584 for (i = 0; i < ARRAY_SIZE(mt7530_mib); i++)
581 strncpy(data + i * ETH_GSTRING_LEN, mt7530_mib[i].name, 585 strncpy(data + i * ETH_GSTRING_LEN, mt7530_mib[i].name,
582 ETH_GSTRING_LEN); 586 ETH_GSTRING_LEN);
@@ -604,8 +608,11 @@ mt7530_get_ethtool_stats(struct dsa_switch *ds, int port,
604} 608}
605 609
606static int 610static int
607mt7530_get_sset_count(struct dsa_switch *ds, int port) 611mt7530_get_sset_count(struct dsa_switch *ds, int port, int sset)
608{ 612{
613 if (sset != ETH_SS_STATS)
614 return 0;
615
609 return ARRAY_SIZE(mt7530_mib); 616 return ARRAY_SIZE(mt7530_mib);
610} 617}
611 618
diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index 3d2091099f7f..8f92ccc0dd54 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -742,11 +742,14 @@ static void mv88e6xxx_atu_vtu_get_strings(uint8_t *data)
742} 742}
743 743
744static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port, 744static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port,
745 uint8_t *data) 745 u32 stringset, uint8_t *data)
746{ 746{
747 struct mv88e6xxx_chip *chip = ds->priv; 747 struct mv88e6xxx_chip *chip = ds->priv;
748 int count = 0; 748 int count = 0;
749 749
750 if (stringset != ETH_SS_STATS)
751 return;
752
750 mutex_lock(&chip->reg_lock); 753 mutex_lock(&chip->reg_lock);
751 754
752 if (chip->info->ops->stats_get_strings) 755 if (chip->info->ops->stats_get_strings)
@@ -789,12 +792,15 @@ static int mv88e6320_stats_get_sset_count(struct mv88e6xxx_chip *chip)
789 STATS_TYPE_BANK1); 792 STATS_TYPE_BANK1);
790} 793}
791 794
792static int mv88e6xxx_get_sset_count(struct dsa_switch *ds, int port) 795static int mv88e6xxx_get_sset_count(struct dsa_switch *ds, int port, int sset)
793{ 796{
794 struct mv88e6xxx_chip *chip = ds->priv; 797 struct mv88e6xxx_chip *chip = ds->priv;
795 int serdes_count = 0; 798 int serdes_count = 0;
796 int count = 0; 799 int count = 0;
797 800
801 if (sset != ETH_SS_STATS)
802 return 0;
803
798 mutex_lock(&chip->reg_lock); 804 mutex_lock(&chip->reg_lock);
799 if (chip->info->ops->stats_get_sset_count) 805 if (chip->info->ops->stats_get_sset_count)
800 count = chip->info->ops->stats_get_sset_count(chip); 806 count = chip->info->ops->stats_get_sset_count(chip);
diff --git a/drivers/net/dsa/qca8k.c b/drivers/net/dsa/qca8k.c
index 600d5ad1fbde..757b6d90ea36 100644
--- a/drivers/net/dsa/qca8k.c
+++ b/drivers/net/dsa/qca8k.c
@@ -600,10 +600,13 @@ qca8k_phy_write(struct dsa_switch *ds, int phy, int regnum, u16 val)
600} 600}
601 601
602static void 602static void
603qca8k_get_strings(struct dsa_switch *ds, int port, uint8_t *data) 603qca8k_get_strings(struct dsa_switch *ds, int port, u32 stringset, uint8_t *data)
604{ 604{
605 int i; 605 int i;
606 606
607 if (stringset != ETH_SS_STATS)
608 return;
609
607 for (i = 0; i < ARRAY_SIZE(ar8327_mib); i++) 610 for (i = 0; i < ARRAY_SIZE(ar8327_mib); i++)
608 strncpy(data + i * ETH_GSTRING_LEN, ar8327_mib[i].name, 611 strncpy(data + i * ETH_GSTRING_LEN, ar8327_mib[i].name,
609 ETH_GSTRING_LEN); 612 ETH_GSTRING_LEN);
@@ -631,8 +634,11 @@ qca8k_get_ethtool_stats(struct dsa_switch *ds, int port,
631} 634}
632 635
633static int 636static int
634qca8k_get_sset_count(struct dsa_switch *ds, int port) 637qca8k_get_sset_count(struct dsa_switch *ds, int port, int sset)
635{ 638{
639 if (sset != ETH_SS_STATS)
640 return 0;
641
636 return ARRAY_SIZE(ar8327_mib); 642 return ARRAY_SIZE(ar8327_mib);
637} 643}
638 644
diff --git a/include/net/dsa.h b/include/net/dsa.h
index 60fb4ec8ba61..0bc0aad1b02e 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -356,10 +356,11 @@ struct dsa_switch_ops {
356 /* 356 /*
357 * ethtool hardware statistics. 357 * ethtool hardware statistics.
358 */ 358 */
359 void (*get_strings)(struct dsa_switch *ds, int port, uint8_t *data); 359 void (*get_strings)(struct dsa_switch *ds, int port,
360 u32 stringset, uint8_t *data);
360 void (*get_ethtool_stats)(struct dsa_switch *ds, 361 void (*get_ethtool_stats)(struct dsa_switch *ds,
361 int port, uint64_t *data); 362 int port, uint64_t *data);
362 int (*get_sset_count)(struct dsa_switch *ds, int port); 363 int (*get_sset_count)(struct dsa_switch *ds, int port, int sset);
363 364
364 /* 365 /*
365 * ethtool Wake-on-LAN 366 * ethtool Wake-on-LAN
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));
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,
560 strncpy(data + 2 * len, "rx_packets", len); 560 strncpy(data + 2 * len, "rx_packets", len);
561 strncpy(data + 3 * len, "rx_bytes", len); 561 strncpy(data + 3 * len, "rx_bytes", len);
562 if (ds->ops->get_strings) 562 if (ds->ops->get_strings)
563 ds->ops->get_strings(ds, dp->index, data + 4 * len); 563 ds->ops->get_strings(ds, dp->index, stringset,
564 data + 4 * len);
564 } 565 }
565} 566}
566 567
@@ -605,7 +606,7 @@ static int dsa_slave_get_sset_count(struct net_device *dev, int sset)
605 606
606 count = 4; 607 count = 4;
607 if (ds->ops->get_sset_count) 608 if (ds->ops->get_sset_count)
608 count += ds->ops->get_sset_count(ds, dp->index); 609 count += ds->ops->get_sset_count(ds, dp->index, sset);
609 610
610 return count; 611 return count;
611 } 612 }