From: Gerhard Engleder <gerhard@engleder-embedded.com>
To: andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk,
davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com
Cc: netdev@vger.kernel.org,
Gerhard Engleder <gerhard@engleder-embedded.com>,
Oleksij Rempel <o.rempel@pengutronix.de>
Subject: [PATCH net-next v5 6/7] net: selftests: Export net_test_phy_loopback_*
Date: Wed, 5 Feb 2025 20:08:22 +0100 [thread overview]
Message-ID: <20250205190823.23528-7-gerhard@engleder-embedded.com> (raw)
In-Reply-To: <20250205190823.23528-1-gerhard@engleder-embedded.com>
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@engleder-embedded.com>
CC: Oleksij Rempel <o.rempel@pengutronix.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..a13237c33e58 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 inline int net_test_phy_loopback_udp_mtu(struct net_device *ndev)
+{
+ return 0;
+}
+
+static inline 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
next prev parent reply other threads:[~2025-02-05 19:34 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-05 19:08 [PATCH net-next v5 0/7] Support loopback mode speed selection Gerhard Engleder
2025-02-05 19:08 ` [PATCH net-next v5 1/7] net: phy: Allow loopback speed selection for PHY drivers Gerhard Engleder
2025-02-05 19:08 ` [PATCH net-next v5 2/7] net: phy: Support speed selection for PHY loopback Gerhard Engleder
2025-02-08 0:16 ` Jakub Kicinski
2025-02-09 18:52 ` Gerhard Engleder
2025-02-05 19:08 ` [PATCH net-next v5 3/7] net: phy: micrel: Add loopback support Gerhard Engleder
2025-02-05 19:08 ` [PATCH net-next v5 4/7] net: phy: marvell: Align set_loopback() implementation Gerhard Engleder
2025-02-05 19:08 ` [PATCH net-next v5 5/7] tsnep: Select speed for loopback Gerhard Engleder
2025-02-05 19:08 ` Gerhard Engleder [this message]
2025-02-05 19:08 ` [PATCH net-next v5 7/7] tsnep: Add PHY loopback selftests Gerhard Engleder
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250205190823.23528-7-gerhard@engleder-embedded.com \
--to=gerhard@engleder-embedded.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hkallweit1@gmail.com \
--cc=kuba@kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=o.rempel@pengutronix.de \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.