Skip to content

Commit abe6f6d

Browse files
oleremNipaLocal
authored andcommitted
net: phy: dp83td510: add MSE interface support for 10BASE-T1L
Implement get_mse_capability() and get_mse_snapshot() for the DP83TD510E to expose its Mean Square Error (MSE) register via the new PHY MSE UAPI. The DP83TD510E does not document any peak MSE values; it only exposes a single average MSE register used internally to derive SQI. This implementation therefore advertises only PHY_MSE_CAP_AVG, along with LINK and channel-A selectors. Scaling is fixed to 0xFFFF, and the refresh interval/number of symbols are estimated from 10BASE-T1L symbol rate (7.5 MBd) and typical diagnostic intervals (~1 ms). For 10BASE-T1L deployments, SQI is a reliable indicator of link modulation quality once the link is established, but it does not indicate whether autonegotiation pulses will be correctly received in marginal conditions. MSE provides a direct measurement of slicer error rate that can be used to evaluate if autonegotiation is likely to succeed under a given cable length and condition. In practice, testing such scenarios often requires forcing a fixed-link setup to isolate MSE behaviour from the autonegotiation process. Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com> Signed-off-by: NipaLocal <nipa@local>
1 parent 64f2a87 commit abe6f6d

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

drivers/net/phy/dp83td510.c

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
#define DP83TD510E_MASTER_SLAVE_RESOL_FAIL BIT(15)
6262

6363
#define DP83TD510E_MSE_DETECT 0xa85
64+
#define DP83TD510E_MSE_MAX U16_MAX
6465

6566
#define DP83TD510_SQI_MAX 7
6667

@@ -249,6 +250,64 @@ struct dp83td510_priv {
249250
#define DP83TD510E_ALCD_COMPLETE BIT(15)
250251
#define DP83TD510E_ALCD_CABLE_LENGTH GENMASK(10, 0)
251252

253+
static int dp83td510_get_mse_capability(struct phy_device *phydev,
254+
struct phy_mse_capability *cap)
255+
{
256+
/* DP83TD510E documents only a single (average) MSE register
257+
* (used to derive SQI); no peak or worst-peak counters are
258+
* described. Advertise only PHY_MSE_CAP_AVG.
259+
*/
260+
cap->supported_caps = PHY_MSE_CAP_AVG;
261+
/* 10BASE-T1L is a single-pair medium, so there are no B/C/D channels.
262+
* We still advertise PHY_MSE_CAP_CHANNEL_A to indicate that the PHY
263+
* can attribute the measurement to a specific pair (the only one),
264+
* rather than exposing it only as a link-aggregate.
265+
*
266+
* Rationale:
267+
* - Keeps the ethtool MSE_GET selection logic consistent: per-channel
268+
* (A/B/C/D) is preferred over WORST/LINK, so userspace receives a
269+
* CHANNEL_A nest instead of LINK.
270+
* - Signals to tools that "per-pair" data is available (even if there's
271+
* just one pair), avoiding the impression that only aggregate values
272+
* are supported.
273+
* - Remains compatible with multi-pair PHYs and uniform UI handling.
274+
*
275+
* Note: WORST and other channels are not advertised on 10BASE-T1L.
276+
*/
277+
cap->supported_caps |= PHY_MSE_CHANNEL_A | PHY_MSE_CAP_LINK;
278+
cap->max_average_mse = DP83TD510E_MSE_MAX;
279+
280+
/* The datasheet does not specify the refresh rate or symbol count,
281+
* but based on similar PHYs and standards, we can assume a common
282+
* value. For 10BASE-T1L, the symbol rate is 7.5 MBd. A common
283+
* diagnostic interval is around 1ms.
284+
* 7.5e6 symbols/sec * 0.001 sec = 7500 symbols.
285+
*/
286+
cap->refresh_rate_ps = 1000000000; /* 1 ms */
287+
cap->num_symbols = 7500;
288+
289+
return 0;
290+
}
291+
292+
static int dp83td510_get_mse_snapshot(struct phy_device *phydev,
293+
enum phy_mse_channel channel,
294+
struct phy_mse_snapshot *snapshot)
295+
{
296+
int ret;
297+
298+
if (channel != PHY_MSE_CHANNEL_LINK &&
299+
channel != PHY_MSE_CHANNEL_A)
300+
return -EOPNOTSUPP;
301+
302+
ret = phy_read_mmd(phydev, MDIO_MMD_VEND2, DP83TD510E_MSE_DETECT);
303+
if (ret < 0)
304+
return ret;
305+
306+
snapshot->average_mse = ret;
307+
308+
return 0;
309+
}
310+
252311
static int dp83td510_led_brightness_set(struct phy_device *phydev, u8 index,
253312
enum led_brightness brightness)
254313
{
@@ -893,6 +952,9 @@ static struct phy_driver dp83td510_driver[] = {
893952
.get_phy_stats = dp83td510_get_phy_stats,
894953
.update_stats = dp83td510_update_stats,
895954

955+
.get_mse_capability = dp83td510_get_mse_capability,
956+
.get_mse_snapshot = dp83td510_get_mse_snapshot,
957+
896958
.led_brightness_set = dp83td510_led_brightness_set,
897959
.led_hw_is_supported = dp83td510_led_hw_is_supported,
898960
.led_hw_control_set = dp83td510_led_hw_control_set,

0 commit comments

Comments
 (0)