From: Raju Rangoju <Raju.Rangoju@amd.com>
To: <netdev@vger.kernel.org>
Cc: <pabeni@redhat.com>, <kuba@kernel.org>, <edumazet@google.com>,
<davem@davemloft.net>, <andrew+netdev@lunn.ch>,
<Shyam-sundar.S-k@amd.com>, Raju Rangoju <Raju.Rangoju@amd.com>
Subject: [PATCH net-next v3 2/4] amd-xgbe: add ethtool phy selftest
Date: Mon, 20 Oct 2025 20:52:26 +0530 [thread overview]
Message-ID: <20251020152228.1670070-3-Raju.Rangoju@amd.com> (raw)
In-Reply-To: <20251020152228.1670070-1-Raju.Rangoju@amd.com>
Adds support for ethtool PHY loopback selftest. It uses
genphy_loopback function, which use BMCR loopback bit to
enable or disable loopback.
Signed-off-by: Raju Rangoju <Raju.Rangoju@amd.com>
---
Changes since v2:
- fix build warnings for alpha arch
drivers/net/ethernet/amd/xgbe/xgbe-selftest.c | 40 +++++++++++++++++++
1 file changed, 40 insertions(+)
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-selftest.c b/drivers/net/ethernet/amd/xgbe/xgbe-selftest.c
index 54a08f5c4ed8..16909c98bad4 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-selftest.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-selftest.c
@@ -25,6 +25,7 @@
#define XGBE_LOOPBACK_NONE 0
#define XGBE_LOOPBACK_MAC 1
+#define XGBE_LOOPBACK_PHY 2
struct xgbe_hdr {
__be32 version;
@@ -315,11 +316,36 @@ static int xgbe_test_mac_loopback(struct xgbe_prv_data *pdata)
return __xgbe_test_loopback(pdata, &attr);
}
+static int xgbe_test_phy_loopback(struct xgbe_prv_data *pdata)
+{
+ struct xgbe_pkt_attrs attr = {};
+ int ret;
+
+ if (!pdata->netdev->phydev) {
+ netdev_err(pdata->netdev, "phydev not found: cannot start PHY loopback test\n");
+ return -EOPNOTSUPP;
+ }
+
+ ret = phy_loopback(pdata->netdev->phydev, true, 0);
+ if (ret)
+ return ret;
+
+ attr.dst = pdata->netdev->dev_addr;
+ ret = __xgbe_test_loopback(pdata, &attr);
+
+ phy_loopback(pdata->netdev->phydev, false, 0);
+ return ret;
+}
+
static const struct xgbe_test xgbe_selftests[] = {
{
.name = "MAC Loopback ",
.lb = XGBE_LOOPBACK_MAC,
.fn = xgbe_test_mac_loopback,
+ }, {
+ .name = "PHY Loopback ",
+ .lb = XGBE_LOOPBACK_NONE,
+ .fn = xgbe_test_phy_loopback,
},
};
@@ -351,6 +377,13 @@ void xgbe_selftest_run(struct net_device *dev,
ret = 0;
switch (xgbe_selftests[i].lb) {
+ case XGBE_LOOPBACK_PHY:
+ ret = -EOPNOTSUPP;
+ if (dev->phydev)
+ ret = phy_loopback(dev->phydev, true, 0);
+ if (!ret)
+ break;
+ fallthrough;
case XGBE_LOOPBACK_MAC:
ret = xgbe_config_mac_loopback(pdata, true);
break;
@@ -377,6 +410,13 @@ void xgbe_selftest_run(struct net_device *dev,
buf[i] = ret;
switch (xgbe_selftests[i].lb) {
+ case XGBE_LOOPBACK_PHY:
+ ret = -EOPNOTSUPP;
+ if (dev->phydev)
+ ret = phy_loopback(dev->phydev, false, 0);
+ if (!ret)
+ break;
+ fallthrough;
case XGBE_LOOPBACK_MAC:
xgbe_config_mac_loopback(pdata, false);
break;
--
2.34.1
next prev parent reply other threads:[~2025-10-20 15:23 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-20 15:22 [PATCH net-next v3 0/4] amd-xgbe: introduce support for ethtool selftests Raju Rangoju
2025-10-20 15:22 ` [PATCH net-next v3 1/4] amd-xgbe: introduce support ethtool selftest Raju Rangoju
2025-10-20 15:22 ` Raju Rangoju [this message]
2025-10-20 16:19 ` [PATCH net-next v3 2/4] amd-xgbe: add ethtool phy selftest Maxime Chevallier
2025-10-20 19:07 ` Andrew Lunn
2025-10-21 9:32 ` Maxime Chevallier
2025-10-21 16:40 ` Rangoju, Raju
2025-10-20 15:22 ` [PATCH net-next v3 3/4] amd-xgbe: add ethtool split header selftest Raju Rangoju
2025-10-20 15:22 ` [PATCH net-next v3 4/4] amd-xgbe: add ethtool jumbo frame selftest Raju Rangoju
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=20251020152228.1670070-3-Raju.Rangoju@amd.com \
--to=raju.rangoju@amd.com \
--cc=Shyam-sundar.S-k@amd.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).