From: Florian Fainelli <florian.fainelli@broadcom.com>
To: netdev@vger.kernel.org
Cc: Nicolai Buchwitz <nb@tipi-net.de>,
Florian Fainelli <florian.fainelli@broadcom.com>,
Broadcom internal kernel review list
<bcm-kernel-feedback-list@broadcom.com>,
Andrew Lunn <andrew@lunn.ch>,
Heiner Kallweit <hkallweit1@gmail.com>,
Russell King <linux@armlinux.org.uk>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Subject: [PATCH net-next v2 1/4] net: phy: broadcom: Report failed ECD pairs as unspecified
Date: Fri, 4 Dec 2026 15:36:30 -0800 [thread overview]
Message-ID: <20261204233633.3790143-2-florian.fainelli@broadcom.com> (raw)
In-Reply-To: <20261204233633.3790143-1-florian.fainelli@broadcom.com>
From: Nicolai Buchwitz <nb@tipi-net.de>
The ECD engine can return the saturated value 0x47ae in a pair's
length register when the measurement fails. The shared result
handler currently reports it as a fault distance of 18350 cm.
The fault type is also invalid in this case. Check the length
before reporting the pair, report an unspecified result on
failure, and omit the distance.
Signed-off-by: Nicolai Buchwitz <nb@tipi-net.de>
Co-developed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
---
drivers/net/phy/bcm-phy-lib.c | 46 +++++++++++++++--------------------
include/linux/brcmphy.h | 1 +
2 files changed, 20 insertions(+), 27 deletions(-)
diff --git a/drivers/net/phy/bcm-phy-lib.c b/drivers/net/phy/bcm-phy-lib.c
index b64beade8dd9..4911dc8210cd 100644
--- a/drivers/net/phy/bcm-phy-lib.c
+++ b/drivers/net/phy/bcm-phy-lib.c
@@ -722,21 +722,26 @@ static bool bcm_phy_distance_valid(int result)
return false;
}
-static int bcm_phy_report_length(struct phy_device *phydev, int pair)
+static void bcm_phy_cable_test_report_pair(struct phy_device *phydev,
+ u8 pair, int fault)
{
- int val;
+ int code = bcm_phy_cable_test_report_trans(fault);
+ int len = -ENODATA;
- val = __bcm_phy_read_exp(phydev,
- BCM54XX_EXP_ECD_PAIR_A_LENGTH_RESULTS + pair);
- if (val < 0)
- return val;
+ if (bcm_phy_distance_valid(fault))
+ len = __bcm_phy_read_exp(phydev,
+ BCM54XX_EXP_ECD_PAIR_A_LENGTH_RESULTS +
+ pair);
- if (val == BCM54XX_ECD_LENGTH_RESULTS_INVALID)
- return 0;
+ /* The fault type is not valid either when the engine failed */
+ if (len == BCM54XX_ECD_LENGTH_RESULTS_FAILED)
+ code = ETHTOOL_A_CABLE_RESULT_CODE_UNSPEC;
- ethnl_cable_test_fault_length(phydev, pair, val);
+ ethnl_cable_test_result(phydev, pair, code);
- return 0;
+ if (len >= 0 && len != BCM54XX_ECD_LENGTH_RESULTS_INVALID &&
+ len != BCM54XX_ECD_LENGTH_RESULTS_FAILED)
+ ethnl_cable_test_fault_length(phydev, pair, len);
}
static int _bcm_phy_cable_test_get_status(struct phy_device *phydev,
@@ -772,23 +777,10 @@ static int _bcm_phy_cable_test_get_status(struct phy_device *phydev,
pair_c = FIELD_GET(BCM54XX_ECD_FAULT_TYPE_PAIR_C_MASK, ret);
pair_d = FIELD_GET(BCM54XX_ECD_FAULT_TYPE_PAIR_D_MASK, ret);
- ethnl_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_A,
- bcm_phy_cable_test_report_trans(pair_a));
- ethnl_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_B,
- bcm_phy_cable_test_report_trans(pair_b));
- ethnl_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_C,
- bcm_phy_cable_test_report_trans(pair_c));
- ethnl_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_D,
- bcm_phy_cable_test_report_trans(pair_d));
-
- if (bcm_phy_distance_valid(pair_a))
- bcm_phy_report_length(phydev, 0);
- if (bcm_phy_distance_valid(pair_b))
- bcm_phy_report_length(phydev, 1);
- if (bcm_phy_distance_valid(pair_c))
- bcm_phy_report_length(phydev, 2);
- if (bcm_phy_distance_valid(pair_d))
- bcm_phy_report_length(phydev, 3);
+ bcm_phy_cable_test_report_pair(phydev, ETHTOOL_A_CABLE_PAIR_A, pair_a);
+ bcm_phy_cable_test_report_pair(phydev, ETHTOOL_A_CABLE_PAIR_B, pair_b);
+ bcm_phy_cable_test_report_pair(phydev, ETHTOOL_A_CABLE_PAIR_C, pair_c);
+ bcm_phy_cable_test_report_pair(phydev, ETHTOOL_A_CABLE_PAIR_D, pair_d);
ret = 0;
*finished = true;
diff --git a/include/linux/brcmphy.h b/include/linux/brcmphy.h
index 174687c4c80a..e90b0f7fc7b8 100644
--- a/include/linux/brcmphy.h
+++ b/include/linux/brcmphy.h
@@ -527,5 +527,6 @@
#define BCM54XX_RDB_ECD_PAIR_D_LENGTH_RESULTS 0x2a5
#define BCM54XX_EXP_ECD_PAIR_D_LENGTH_RESULTS (MII_BCM54XX_EXP_SEL_ER + 0xc5)
#define BCM54XX_ECD_LENGTH_RESULTS_INVALID 0xffff
+#define BCM54XX_ECD_LENGTH_RESULTS_FAILED 0x47ae /* saturated, ECD failure */
#endif /* _LINUX_BRCMPHY_H */
--
2.56.1
next prev parent reply other threads:[~2026-12-04 23:36 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 23:36 [PATCH net-next v2 0/4] net: phy: Cable tests for BCM54210E Florian Fainelli
2026-12-04 23:36 ` Florian Fainelli [this message]
2026-12-04 23:36 ` [PATCH net-next v2 2/4] net: phy: broadcom: Implement cable test initialization " Florian Fainelli
2026-12-04 23:36 ` [PATCH net-next v2 3/4] net: phy: broadcom: Wire-up cable tests " Florian Fainelli
2026-12-04 23:36 ` [PATCH net-next v2 4/4] net: phy: broadcom: Recover BCM54210E from aborted cable tests Florian Fainelli
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=20261204233633.3790143-2-florian.fainelli@broadcom.com \
--to=florian.fainelli@broadcom.com \
--cc=andrew@lunn.ch \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=hkallweit1@gmail.com \
--cc=kuba@kernel.org \
--cc=linux@armlinux.org.uk \
--cc=nb@tipi-net.de \
--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