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>hifive-unleashed-5.1
parent
1d1e79f1c6
commit
89f0904834
|
@ -806,13 +806,17 @@ static unsigned int b53_get_mib_size(struct b53_device *dev)
|
||||||
return B53_MIBS_SIZE;
|
return B53_MIBS_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void b53_get_strings(struct dsa_switch *ds, int port, uint8_t *data)
|
void b53_get_strings(struct dsa_switch *ds, int port, u32 stringset,
|
||||||
|
uint8_t *data)
|
||||||
{
|
{
|
||||||
struct b53_device *dev = ds->priv;
|
struct b53_device *dev = ds->priv;
|
||||||
const struct b53_mib_desc *mibs = b53_get_mib(dev);
|
const struct b53_mib_desc *mibs = b53_get_mib(dev);
|
||||||
unsigned int mib_size = b53_get_mib_size(dev);
|
unsigned int mib_size = b53_get_mib_size(dev);
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
|
if (stringset != ETH_SS_STATS)
|
||||||
|
return;
|
||||||
|
|
||||||
for (i = 0; i < mib_size; i++)
|
for (i = 0; i < mib_size; i++)
|
||||||
strlcpy(data + i * ETH_GSTRING_LEN,
|
strlcpy(data + i * ETH_GSTRING_LEN,
|
||||||
mibs[i].name, ETH_GSTRING_LEN);
|
mibs[i].name, ETH_GSTRING_LEN);
|
||||||
|
@ -852,10 +856,13 @@ void b53_get_ethtool_stats(struct dsa_switch *ds, int port, uint64_t *data)
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(b53_get_ethtool_stats);
|
EXPORT_SYMBOL(b53_get_ethtool_stats);
|
||||||
|
|
||||||
int b53_get_sset_count(struct dsa_switch *ds, int port)
|
int b53_get_sset_count(struct dsa_switch *ds, int port, int sset)
|
||||||
{
|
{
|
||||||
struct b53_device *dev = ds->priv;
|
struct b53_device *dev = ds->priv;
|
||||||
|
|
||||||
|
if (sset != ETH_SS_STATS)
|
||||||
|
return 0;
|
||||||
|
|
||||||
return b53_get_mib_size(dev);
|
return b53_get_mib_size(dev);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(b53_get_sset_count);
|
EXPORT_SYMBOL(b53_get_sset_count);
|
||||||
|
|
|
@ -286,9 +286,10 @@ static inline int b53_switch_get_reset_gpio(struct b53_device *dev)
|
||||||
/* Exported functions towards other drivers */
|
/* Exported functions towards other drivers */
|
||||||
void b53_imp_vlan_setup(struct dsa_switch *ds, int cpu_port);
|
void b53_imp_vlan_setup(struct dsa_switch *ds, int cpu_port);
|
||||||
int b53_configure_vlan(struct dsa_switch *ds);
|
int b53_configure_vlan(struct dsa_switch *ds);
|
||||||
void b53_get_strings(struct dsa_switch *ds, int port, uint8_t *data);
|
void b53_get_strings(struct dsa_switch *ds, int port, u32 stringset,
|
||||||
|
uint8_t *data);
|
||||||
void b53_get_ethtool_stats(struct dsa_switch *ds, int port, uint64_t *data);
|
void b53_get_ethtool_stats(struct dsa_switch *ds, int port, uint64_t *data);
|
||||||
int b53_get_sset_count(struct dsa_switch *ds, int port);
|
int b53_get_sset_count(struct dsa_switch *ds, int port, int sset);
|
||||||
int b53_br_join(struct dsa_switch *ds, int port, struct net_device *bridge);
|
int b53_br_join(struct dsa_switch *ds, int port, struct net_device *bridge);
|
||||||
void b53_br_leave(struct dsa_switch *ds, int port, struct net_device *bridge);
|
void b53_br_leave(struct dsa_switch *ds, int port, struct net_device *bridge);
|
||||||
void b53_br_set_stp_state(struct dsa_switch *ds, int port, u8 state);
|
void b53_br_set_stp_state(struct dsa_switch *ds, int port, u8 state);
|
||||||
|
|
|
@ -86,16 +86,23 @@ static int dsa_loop_setup(struct dsa_switch *ds)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dsa_loop_get_sset_count(struct dsa_switch *ds, int port)
|
static int dsa_loop_get_sset_count(struct dsa_switch *ds, int port, int sset)
|
||||||
{
|
{
|
||||||
|
if (sset != ETH_SS_STATS)
|
||||||
|
return 0;
|
||||||
|
|
||||||
return __DSA_LOOP_CNT_MAX;
|
return __DSA_LOOP_CNT_MAX;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dsa_loop_get_strings(struct dsa_switch *ds, int port, uint8_t *data)
|
static void dsa_loop_get_strings(struct dsa_switch *ds, int port,
|
||||||
|
u32 stringset, uint8_t *data)
|
||||||
{
|
{
|
||||||
struct dsa_loop_priv *ps = ds->priv;
|
struct dsa_loop_priv *ps = ds->priv;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
|
if (stringset != ETH_SS_STATS)
|
||||||
|
return;
|
||||||
|
|
||||||
for (i = 0; i < __DSA_LOOP_CNT_MAX; i++)
|
for (i = 0; i < __DSA_LOOP_CNT_MAX; i++)
|
||||||
memcpy(data + i * ETH_GSTRING_LEN,
|
memcpy(data + i * ETH_GSTRING_LEN,
|
||||||
ps->ports[port].mib[i].name, ETH_GSTRING_LEN);
|
ps->ports[port].mib[i].name, ETH_GSTRING_LEN);
|
||||||
|
|
|
@ -977,10 +977,14 @@ static const struct lan9303_mib_desc lan9303_mib[] = {
|
||||||
{ .offset = LAN9303_MAC_TX_LATECOL_0, .name = "TxLateCol", },
|
{ .offset = LAN9303_MAC_TX_LATECOL_0, .name = "TxLateCol", },
|
||||||
};
|
};
|
||||||
|
|
||||||
static void lan9303_get_strings(struct dsa_switch *ds, int port, uint8_t *data)
|
static void lan9303_get_strings(struct dsa_switch *ds, int port,
|
||||||
|
u32 stringset, uint8_t *data)
|
||||||
{
|
{
|
||||||
unsigned int u;
|
unsigned int u;
|
||||||
|
|
||||||
|
if (stringset != ETH_SS_STATS)
|
||||||
|
return;
|
||||||
|
|
||||||
for (u = 0; u < ARRAY_SIZE(lan9303_mib); u++) {
|
for (u = 0; u < ARRAY_SIZE(lan9303_mib); u++) {
|
||||||
strncpy(data + u * ETH_GSTRING_LEN, lan9303_mib[u].name,
|
strncpy(data + u * ETH_GSTRING_LEN, lan9303_mib[u].name,
|
||||||
ETH_GSTRING_LEN);
|
ETH_GSTRING_LEN);
|
||||||
|
@ -1007,8 +1011,11 @@ static void lan9303_get_ethtool_stats(struct dsa_switch *ds, int port,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int lan9303_get_sset_count(struct dsa_switch *ds, int port)
|
static int lan9303_get_sset_count(struct dsa_switch *ds, int port, int sset)
|
||||||
{
|
{
|
||||||
|
if (sset != ETH_SS_STATS)
|
||||||
|
return 0;
|
||||||
|
|
||||||
return ARRAY_SIZE(lan9303_mib);
|
return ARRAY_SIZE(lan9303_mib);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -439,15 +439,22 @@ static void ksz_disable_port(struct dsa_switch *ds, int port,
|
||||||
ksz_port_cfg(dev, port, REG_PORT_CTRL_0, PORT_MAC_LOOPBACK, true);
|
ksz_port_cfg(dev, port, REG_PORT_CTRL_0, PORT_MAC_LOOPBACK, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ksz_sset_count(struct dsa_switch *ds, int port)
|
static int ksz_sset_count(struct dsa_switch *ds, int port, int sset)
|
||||||
{
|
{
|
||||||
|
if (sset != ETH_SS_STATS)
|
||||||
|
return 0;
|
||||||
|
|
||||||
return TOTAL_SWITCH_COUNTER_NUM;
|
return TOTAL_SWITCH_COUNTER_NUM;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ksz_get_strings(struct dsa_switch *ds, int port, uint8_t *buf)
|
static void ksz_get_strings(struct dsa_switch *ds, int port,
|
||||||
|
u32 stringset, uint8_t *buf)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
if (stringset != ETH_SS_STATS)
|
||||||
|
return;
|
||||||
|
|
||||||
for (i = 0; i < TOTAL_SWITCH_COUNTER_NUM; i++) {
|
for (i = 0; i < TOTAL_SWITCH_COUNTER_NUM; i++) {
|
||||||
memcpy(buf + i * ETH_GSTRING_LEN, mib_names[i].string,
|
memcpy(buf + i * ETH_GSTRING_LEN, mib_names[i].string,
|
||||||
ETH_GSTRING_LEN);
|
ETH_GSTRING_LEN);
|
||||||
|
|
|
@ -573,10 +573,14 @@ static int mt7530_phy_write(struct dsa_switch *ds, int port, int regnum,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
mt7530_get_strings(struct dsa_switch *ds, int port, uint8_t *data)
|
mt7530_get_strings(struct dsa_switch *ds, int port, u32 stringset,
|
||||||
|
uint8_t *data)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
if (stringset != ETH_SS_STATS)
|
||||||
|
return;
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(mt7530_mib); i++)
|
for (i = 0; i < ARRAY_SIZE(mt7530_mib); i++)
|
||||||
strncpy(data + i * ETH_GSTRING_LEN, mt7530_mib[i].name,
|
strncpy(data + i * ETH_GSTRING_LEN, mt7530_mib[i].name,
|
||||||
ETH_GSTRING_LEN);
|
ETH_GSTRING_LEN);
|
||||||
|
@ -604,8 +608,11 @@ mt7530_get_ethtool_stats(struct dsa_switch *ds, int port,
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
mt7530_get_sset_count(struct dsa_switch *ds, int port)
|
mt7530_get_sset_count(struct dsa_switch *ds, int port, int sset)
|
||||||
{
|
{
|
||||||
|
if (sset != ETH_SS_STATS)
|
||||||
|
return 0;
|
||||||
|
|
||||||
return ARRAY_SIZE(mt7530_mib);
|
return ARRAY_SIZE(mt7530_mib);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -742,11 +742,14 @@ static void mv88e6xxx_atu_vtu_get_strings(uint8_t *data)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port,
|
static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port,
|
||||||
uint8_t *data)
|
u32 stringset, uint8_t *data)
|
||||||
{
|
{
|
||||||
struct mv88e6xxx_chip *chip = ds->priv;
|
struct mv88e6xxx_chip *chip = ds->priv;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
|
if (stringset != ETH_SS_STATS)
|
||||||
|
return;
|
||||||
|
|
||||||
mutex_lock(&chip->reg_lock);
|
mutex_lock(&chip->reg_lock);
|
||||||
|
|
||||||
if (chip->info->ops->stats_get_strings)
|
if (chip->info->ops->stats_get_strings)
|
||||||
|
@ -789,12 +792,15 @@ static int mv88e6320_stats_get_sset_count(struct mv88e6xxx_chip *chip)
|
||||||
STATS_TYPE_BANK1);
|
STATS_TYPE_BANK1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mv88e6xxx_get_sset_count(struct dsa_switch *ds, int port)
|
static int mv88e6xxx_get_sset_count(struct dsa_switch *ds, int port, int sset)
|
||||||
{
|
{
|
||||||
struct mv88e6xxx_chip *chip = ds->priv;
|
struct mv88e6xxx_chip *chip = ds->priv;
|
||||||
int serdes_count = 0;
|
int serdes_count = 0;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
|
if (sset != ETH_SS_STATS)
|
||||||
|
return 0;
|
||||||
|
|
||||||
mutex_lock(&chip->reg_lock);
|
mutex_lock(&chip->reg_lock);
|
||||||
if (chip->info->ops->stats_get_sset_count)
|
if (chip->info->ops->stats_get_sset_count)
|
||||||
count = chip->info->ops->stats_get_sset_count(chip);
|
count = chip->info->ops->stats_get_sset_count(chip);
|
||||||
|
|
|
@ -600,10 +600,13 @@ qca8k_phy_write(struct dsa_switch *ds, int phy, int regnum, u16 val)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
qca8k_get_strings(struct dsa_switch *ds, int port, uint8_t *data)
|
qca8k_get_strings(struct dsa_switch *ds, int port, u32 stringset, uint8_t *data)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
if (stringset != ETH_SS_STATS)
|
||||||
|
return;
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(ar8327_mib); i++)
|
for (i = 0; i < ARRAY_SIZE(ar8327_mib); i++)
|
||||||
strncpy(data + i * ETH_GSTRING_LEN, ar8327_mib[i].name,
|
strncpy(data + i * ETH_GSTRING_LEN, ar8327_mib[i].name,
|
||||||
ETH_GSTRING_LEN);
|
ETH_GSTRING_LEN);
|
||||||
|
@ -631,8 +634,11 @@ qca8k_get_ethtool_stats(struct dsa_switch *ds, int port,
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qca8k_get_sset_count(struct dsa_switch *ds, int port)
|
qca8k_get_sset_count(struct dsa_switch *ds, int port, int sset)
|
||||||
{
|
{
|
||||||
|
if (sset != ETH_SS_STATS)
|
||||||
|
return 0;
|
||||||
|
|
||||||
return ARRAY_SIZE(ar8327_mib);
|
return ARRAY_SIZE(ar8327_mib);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -356,10 +356,11 @@ struct dsa_switch_ops {
|
||||||
/*
|
/*
|
||||||
* ethtool hardware statistics.
|
* ethtool hardware statistics.
|
||||||
*/
|
*/
|
||||||
void (*get_strings)(struct dsa_switch *ds, int port, uint8_t *data);
|
void (*get_strings)(struct dsa_switch *ds, int port,
|
||||||
|
u32 stringset, uint8_t *data);
|
||||||
void (*get_ethtool_stats)(struct dsa_switch *ds,
|
void (*get_ethtool_stats)(struct dsa_switch *ds,
|
||||||
int port, uint64_t *data);
|
int port, uint64_t *data);
|
||||||
int (*get_sset_count)(struct dsa_switch *ds, int port);
|
int (*get_sset_count)(struct dsa_switch *ds, int port, int sset);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ethtool Wake-on-LAN
|
* ethtool Wake-on-LAN
|
||||||
|
|
|
@ -38,11 +38,14 @@ static int dsa_master_get_sset_count(struct net_device *dev, int sset)
|
||||||
struct dsa_switch *ds = cpu_dp->ds;
|
struct dsa_switch *ds = cpu_dp->ds;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
if (ops->get_sset_count)
|
if (ops->get_sset_count) {
|
||||||
count += ops->get_sset_count(dev, sset);
|
count = ops->get_sset_count(dev, sset);
|
||||||
|
if (count < 0)
|
||||||
|
count = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (sset == ETH_SS_STATS && ds->ops->get_sset_count)
|
if (ds->ops->get_sset_count)
|
||||||
count += ds->ops->get_sset_count(ds, cpu_dp->index);
|
count += ds->ops->get_sset_count(ds, cpu_dp->index, sset);
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
@ -65,18 +68,20 @@ static void dsa_master_get_strings(struct net_device *dev, uint32_t stringset,
|
||||||
pfx[sizeof(pfx) - 1] = '_';
|
pfx[sizeof(pfx) - 1] = '_';
|
||||||
|
|
||||||
if (ops->get_sset_count && ops->get_strings) {
|
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);
|
ops->get_strings(dev, stringset, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stringset == ETH_SS_STATS && ds->ops->get_strings) {
|
if (ds->ops->get_strings) {
|
||||||
ndata = data + mcount * len;
|
ndata = data + mcount * len;
|
||||||
/* This function copies ETH_GSTRINGS_LEN bytes, we will mangle
|
/* This function copies ETH_GSTRINGS_LEN bytes, we will mangle
|
||||||
* the output after to prepend our CPU port prefix we
|
* the output after to prepend our CPU port prefix we
|
||||||
* constructed earlier
|
* constructed earlier
|
||||||
*/
|
*/
|
||||||
ds->ops->get_strings(ds, port, ndata);
|
ds->ops->get_strings(ds, port, stringset, ndata);
|
||||||
count = ds->ops->get_sset_count(ds, port);
|
count = ds->ops->get_sset_count(ds, port, stringset);
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
memmove(ndata + (i * len + sizeof(pfx)),
|
memmove(ndata + (i * len + sizeof(pfx)),
|
||||||
ndata + i * len, len - sizeof(pfx));
|
ndata + i * len, len - sizeof(pfx));
|
||||||
|
|
|
@ -560,7 +560,8 @@ static void dsa_slave_get_strings(struct net_device *dev,
|
||||||
strncpy(data + 2 * len, "rx_packets", len);
|
strncpy(data + 2 * len, "rx_packets", len);
|
||||||
strncpy(data + 3 * len, "rx_bytes", len);
|
strncpy(data + 3 * len, "rx_bytes", len);
|
||||||
if (ds->ops->get_strings)
|
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;
|
count = 4;
|
||||||
if (ds->ops->get_sset_count)
|
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;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue