Commit a71acad9 authored by Oleksij Rempel's avatar Oleksij Rempel Committed by David S. Miller

net: dsa: enable selftest support for all switches by default

Most of generic selftest should be able to work with probably all ethernet
controllers. The DSA switches are not exception, so enable it by default at
least for DSA.

This patch was tested with SJA1105 and AR9331.
Signed-off-by: default avatarOleksij Rempel <o.rempel@pengutronix.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b62a12fc
...@@ -577,6 +577,8 @@ struct dsa_switch_ops { ...@@ -577,6 +577,8 @@ struct dsa_switch_ops {
int port, uint64_t *data); int port, uint64_t *data);
void (*get_stats64)(struct dsa_switch *ds, int port, void (*get_stats64)(struct dsa_switch *ds, int port,
struct rtnl_link_stats64 *s); struct rtnl_link_stats64 *s);
void (*self_test)(struct dsa_switch *ds, int port,
struct ethtool_test *etest, u64 *data);
/* /*
* ethtool Wake-on-LAN * ethtool Wake-on-LAN
......
...@@ -9,6 +9,7 @@ menuconfig NET_DSA ...@@ -9,6 +9,7 @@ menuconfig NET_DSA
select NET_SWITCHDEV select NET_SWITCHDEV
select PHYLINK select PHYLINK
select NET_DEVLINK select NET_DEVLINK
select NET_SELFTESTS
help help
Say Y if you want to enable support for the hardware switches supported Say Y if you want to enable support for the hardware switches supported
by the Distributed Switch Architecture. by the Distributed Switch Architecture.
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include <linux/mdio.h> #include <linux/mdio.h>
#include <net/rtnetlink.h> #include <net/rtnetlink.h>
#include <net/pkt_cls.h> #include <net/pkt_cls.h>
#include <net/selftests.h>
#include <net/tc_act/tc_mirred.h> #include <net/tc_act/tc_mirred.h>
#include <linux/if_bridge.h> #include <linux/if_bridge.h>
#include <linux/if_hsr.h> #include <linux/if_hsr.h>
...@@ -748,7 +749,10 @@ static void dsa_slave_get_strings(struct net_device *dev, ...@@ -748,7 +749,10 @@ static void dsa_slave_get_strings(struct net_device *dev,
if (ds->ops->get_strings) if (ds->ops->get_strings)
ds->ops->get_strings(ds, dp->index, stringset, ds->ops->get_strings(ds, dp->index, stringset,
data + 4 * len); data + 4 * len);
} else if (stringset == ETH_SS_TEST) {
net_selftest_get_strings(data);
} }
} }
static void dsa_slave_get_ethtool_stats(struct net_device *dev, static void dsa_slave_get_ethtool_stats(struct net_device *dev,
...@@ -794,11 +798,27 @@ static int dsa_slave_get_sset_count(struct net_device *dev, int sset) ...@@ -794,11 +798,27 @@ static int dsa_slave_get_sset_count(struct net_device *dev, int sset)
count += ds->ops->get_sset_count(ds, dp->index, sset); count += ds->ops->get_sset_count(ds, dp->index, sset);
return count; return count;
} else if (sset == ETH_SS_TEST) {
return net_selftest_get_count();
} }
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
static void dsa_slave_net_selftest(struct net_device *ndev,
struct ethtool_test *etest, u64 *buf)
{
struct dsa_port *dp = dsa_slave_to_port(ndev);
struct dsa_switch *ds = dp->ds;
if (ds->ops->self_test) {
ds->ops->self_test(ds, dp->index, etest, buf);
return;
}
net_selftest(ndev, etest, buf);
}
static void dsa_slave_get_wol(struct net_device *dev, struct ethtool_wolinfo *w) static void dsa_slave_get_wol(struct net_device *dev, struct ethtool_wolinfo *w)
{ {
struct dsa_port *dp = dsa_slave_to_port(dev); struct dsa_port *dp = dsa_slave_to_port(dev);
...@@ -1630,6 +1650,7 @@ static const struct ethtool_ops dsa_slave_ethtool_ops = { ...@@ -1630,6 +1650,7 @@ static const struct ethtool_ops dsa_slave_ethtool_ops = {
.get_rxnfc = dsa_slave_get_rxnfc, .get_rxnfc = dsa_slave_get_rxnfc,
.set_rxnfc = dsa_slave_set_rxnfc, .set_rxnfc = dsa_slave_set_rxnfc,
.get_ts_info = dsa_slave_get_ts_info, .get_ts_info = dsa_slave_get_ts_info,
.self_test = dsa_slave_net_selftest,
}; };
/* legacy way, bypassing the bridge *****************************************/ /* legacy way, bypassing the bridge *****************************************/
......
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