Commit e655bbf9 authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'net-generic-selftest-support'



Oleksij Rempel says:

====================
provide generic net selftest support

changes v3:
- make more granular tests
- enable loopback for all PHYs by default
- fix allmodconfig build errors
- poll for link status update after switching to the loopback mode

changes v2:
- make generic selftests available for all networking devices.
- make use of net_selftest* on FEC, ag71xx and all DSA switches.
- add loopback support on more PHYs.

This patch set provides diagnostic capabilities for some iMX, ag71xx or
any DSA based devices. For proper functionality, PHY loopback support is
needed.
So far there is only initial infrastructure with basic tests.
====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents e9377a91 a71acad9
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ if NET_VENDOR_ATHEROS
config AG71XX
	tristate "Atheros AR7XXX/AR9XXX built-in ethernet mac support"
	depends on ATH79
	select NET_SELFTESTS
	select PHYLINK
	help
	  If you wish to compile a kernel for AR7XXX/91XXX and enable
+16 −4
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@
#include <linux/reset.h>
#include <linux/clk.h>
#include <linux/io.h>
#include <net/selftests.h>

/* For our NAPI weight bigger does *NOT* mean better - it means more
 * D-cache misses and lots more wasted cycles than we'll ever
@@ -497,12 +498,17 @@ static int ag71xx_ethtool_set_pauseparam(struct net_device *ndev,
static void ag71xx_ethtool_get_strings(struct net_device *netdev, u32 sset,
				       u8 *data)
{
	if (sset == ETH_SS_STATS) {
	int i;

	switch (sset) {
	case ETH_SS_STATS:
		for (i = 0; i < ARRAY_SIZE(ag71xx_statistics); i++)
			memcpy(data + i * ETH_GSTRING_LEN,
			       ag71xx_statistics[i].name, ETH_GSTRING_LEN);
		break;
	case ETH_SS_TEST:
		net_selftest_get_strings(data);
		break;
	}
}

@@ -519,10 +525,15 @@ static void ag71xx_ethtool_get_stats(struct net_device *ndev,

static int ag71xx_ethtool_get_sset_count(struct net_device *ndev, int sset)
{
	if (sset == ETH_SS_STATS)
	switch (sset) {
	case ETH_SS_STATS:
		return ARRAY_SIZE(ag71xx_statistics);
	case ETH_SS_TEST:
		return net_selftest_get_count();
	default:
		return -EOPNOTSUPP;
	}
}

static const struct ethtool_ops ag71xx_ethtool_ops = {
	.get_drvinfo			= ag71xx_get_drvinfo,
@@ -536,6 +547,7 @@ static const struct ethtool_ops ag71xx_ethtool_ops = {
	.get_strings			= ag71xx_ethtool_get_strings,
	.get_ethtool_stats		= ag71xx_ethtool_get_stats,
	.get_sset_count			= ag71xx_ethtool_get_sset_count,
	.self_test			= net_selftest,
};

static int ag71xx_mdio_wait_busy(struct ag71xx *ag)
+1 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ config FEC
		   ARCH_MXC || SOC_IMX28 || COMPILE_TEST)
	default ARCH_MXC || SOC_IMX28 if ARM
	select CRC32
	select NET_SELFTESTS
	select PHYLIB
	imply PTP_1588_CLOCK
	help
+7 −0
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@
#include <linux/in.h>
#include <linux/ip.h>
#include <net/ip.h>
#include <net/selftests.h>
#include <net/tso.h>
#include <linux/tcp.h>
#include <linux/udp.h>
@@ -2482,6 +2483,9 @@ static void fec_enet_get_strings(struct net_device *netdev,
			memcpy(data + i * ETH_GSTRING_LEN,
				fec_stats[i].name, ETH_GSTRING_LEN);
		break;
	case ETH_SS_TEST:
		net_selftest_get_strings(data);
		break;
	}
}

@@ -2490,6 +2494,8 @@ static int fec_enet_get_sset_count(struct net_device *dev, int sset)
	switch (sset) {
	case ETH_SS_STATS:
		return ARRAY_SIZE(fec_stats);
	case ETH_SS_TEST:
		return net_selftest_get_count();
	default:
		return -EOPNOTSUPP;
	}
@@ -2741,6 +2747,7 @@ static const struct ethtool_ops fec_enet_ethtool_ops = {
	.set_wol		= fec_enet_set_wol,
	.get_link_ksettings	= phy_ethtool_get_link_ksettings,
	.set_link_ksettings	= phy_ethtool_set_link_ksettings,
	.self_test		= net_selftest,
};

static int fec_enet_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd)
+2 −1
Original line number Diff line number Diff line
@@ -701,7 +701,7 @@ int phy_start_cable_test_tdr(struct phy_device *phydev,
}
EXPORT_SYMBOL(phy_start_cable_test_tdr);

static int phy_config_aneg(struct phy_device *phydev)
int phy_config_aneg(struct phy_device *phydev)
{
	if (phydev->drv->config_aneg)
		return phydev->drv->config_aneg(phydev);
@@ -714,6 +714,7 @@ static int phy_config_aneg(struct phy_device *phydev)

	return genphy_config_aneg(phydev);
}
EXPORT_SYMBOL(phy_config_aneg);

/**
 * phy_check_link_status - check link status and set state accordingly
Loading