[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250124220516.113798-7-gerhard@engleder-embedded.com>
Date: Fri, 24 Jan 2025 23:05:15 +0100
From: Gerhard Engleder <gerhard@...leder-embedded.com>
To: andrew@...n.ch,
hkallweit1@...il.com,
linux@...linux.org.uk,
davem@...emloft.net,
edumazet@...gle.com,
kuba@...nel.org,
pabeni@...hat.com
Cc: netdev@...r.kernel.org,
Gerhard Engleder <gerhard@...leder-embedded.com>,
Oleksij Rempel <o.rempel@...gutronix.de>
Subject: [RFC PATCH net-next v3 6/7] net: selftests: Export net_test_phy_loopback_*
net_selftests() provides a generic set of selftests for netdevs with
PHY. Those selftests rely on an existing link to inherit the speed for
the loopback mode.
net_selftests() is not designed to extend existing selftests of drivers,
but with net_test_phy_loopback_* it contains useful test infrastructure.
Export net_test_phy_loopback_* to enable reuse in existing selftests of
other drivers. This also enables driver specific loopback modes, which
don't rely on an existing link.
Signed-off-by: Gerhard Engleder <gerhard@...leder-embedded.com>
CC: Oleksij Rempel <o.rempel@...gutronix.de>
---
include/net/selftests.h | 19 +++++++++++++++++++
net/core/selftests.c | 9 ++++++---
2 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/include/net/selftests.h b/include/net/selftests.h
index e65e8d230d33..38459af4962b 100644
--- a/include/net/selftests.h
+++ b/include/net/selftests.h
@@ -6,6 +6,10 @@
#if IS_ENABLED(CONFIG_NET_SELFTESTS)
+int net_test_phy_loopback_udp(struct net_device *ndev);
+int net_test_phy_loopback_udp_mtu(struct net_device *ndev);
+int net_test_phy_loopback_tcp(struct net_device *ndev);
+
void net_selftest(struct net_device *ndev, struct ethtool_test *etest,
u64 *buf);
int net_selftest_get_count(void);
@@ -13,6 +17,21 @@ void net_selftest_get_strings(u8 *data);
#else
+static inline int net_test_phy_loopback_udp(struct net_device *ndev)
+{
+ return 0;
+}
+
+static int net_test_phy_loopback_udp_mtu(struct net_device *ndev)
+{
+ return 0;
+}
+
+static int net_test_phy_loopback_tcp(struct net_device *ndev)
+{
+ return 0;
+}
+
static inline void net_selftest(struct net_device *ndev, struct ethtool_test *etest,
u64 *buf)
{
diff --git a/net/core/selftests.c b/net/core/selftests.c
index e99ae983fca9..d4e0e2eff991 100644
--- a/net/core/selftests.c
+++ b/net/core/selftests.c
@@ -310,15 +310,16 @@ static int net_test_phy_loopback_disable(struct net_device *ndev)
return phy_loopback(ndev->phydev, false, 0);
}
-static int net_test_phy_loopback_udp(struct net_device *ndev)
+int net_test_phy_loopback_udp(struct net_device *ndev)
{
struct net_packet_attrs attr = { };
attr.dst = ndev->dev_addr;
return __net_test_loopback(ndev, &attr);
}
+EXPORT_SYMBOL_GPL(net_test_phy_loopback_udp);
-static int net_test_phy_loopback_udp_mtu(struct net_device *ndev)
+int net_test_phy_loopback_udp_mtu(struct net_device *ndev)
{
struct net_packet_attrs attr = { };
@@ -326,8 +327,9 @@ static int net_test_phy_loopback_udp_mtu(struct net_device *ndev)
attr.max_size = ndev->mtu;
return __net_test_loopback(ndev, &attr);
}
+EXPORT_SYMBOL_GPL(net_test_phy_loopback_udp_mtu);
-static int net_test_phy_loopback_tcp(struct net_device *ndev)
+int net_test_phy_loopback_tcp(struct net_device *ndev)
{
struct net_packet_attrs attr = { };
@@ -335,6 +337,7 @@ static int net_test_phy_loopback_tcp(struct net_device *ndev)
attr.tcp = true;
return __net_test_loopback(ndev, &attr);
}
+EXPORT_SYMBOL_GPL(net_test_phy_loopback_tcp);
static const struct net_test {
char name[ETH_GSTRING_LEN];
--
2.39.5
Powered by blists - more mailing lists