Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'net-phy-add-open-alliance-tc14-10base-t1s-phy-cable-diagnostic-support'

Parthiban Veerasooran says:

====================
net: phy: Add Open Alliance TC14 10Base-T1S PHY cable diagnostic support

This patch series adds Open Alliance TC14 (OATC14) 10BASE-T1S cable
diagnostic feature support to the Linux kernel PHY subsystem and enable
this feature for Microchip LAN867x Rev.D0 PHYs. These patches provide
standardized cable test functionality for 10BASE-T1S Ethernet PHYs,
allowing users to perform cable diagnostics via ethtool.

Patch Summary:
1. add OATC14 10BASE-T1S PHY cable diagnostic support
- Implements support for the OATC14 cable diagnostic feature in
Clause 45 PHYs.
- Adds functions to start a cable test and retrieve its status,
mapping hardware results to ethtool codes.
- Exports these functions for use by PHY drivers.
- Open Alliance TC14 10BASE-T1S Advanced Diagnostic PHY Features.
https://opensig.org/wp-content/uploads/2025/06/OPEN_Alliance_10BASE-T1S_Advanced_PHY_features_for-automotive_Ethernet_V2.1b.pdf

2. add cable diagnostic support for LAN867x Rev.D0
- Integrates the generic OATC14 cable test functions into the
Microchip LAN867x Rev.D0 PHY driver.
- Enables ethtool cable diagnostics for this PHY, improving
troubleshooting and maintenance.
====================

Link: https://patch.msgid.link/20251105051213.50443-1-parthiban.veerasooran@microchip.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+163
+36
drivers/net/phy/mdio-open-alliance.h
··· 43 43 /* Version Identifiers */ 44 44 #define OATC14_IDM 0x0a00 45 45 46 + /* 47 + * Open Alliance TC14 (10BASE-T1S) - Advanced Diagnostic Features Registers 48 + * 49 + * Refer to the OPEN Alliance documentation: 50 + * https://opensig.org/automotive-ethernet-specifications/ 51 + * 52 + * Specification: 53 + * "10BASE-T1S Advanced Diagnostic PHY Features" 54 + * https://opensig.org/wp-content/uploads/2025/06/OPEN_Alliance_10BASE-T1S_Advanced_PHY_features_for-automotive_Ethernet_V2.1b.pdf 55 + */ 56 + /* Advanced Diagnostic Features Capability Register*/ 57 + #define MDIO_OATC14_ADFCAP 0xcc00 58 + #define OATC14_ADFCAP_HDD_CAPABILITY GENMASK(10, 8) 59 + 60 + /* Harness Defect Detection Register */ 61 + #define MDIO_OATC14_HDD 0xcc01 62 + #define OATC14_HDD_CONTROL BIT(15) 63 + #define OATC14_HDD_READY BIT(14) 64 + #define OATC14_HDD_START_CONTROL BIT(13) 65 + #define OATC14_HDD_VALID BIT(2) 66 + #define OATC14_HDD_SHORT_OPEN_STATUS GENMASK(1, 0) 67 + 68 + /* Bus Short/Open Status: 69 + * 0 0 - no fault; everything is ok. (Default) 70 + * 0 1 - detected as an open or missing termination(s) 71 + * 1 0 - detected as a short or extra termination(s) 72 + * 1 1 - fault but fault type not detectable. More details can be available by 73 + * vender specific register if supported. 74 + */ 75 + enum oatc14_hdd_status { 76 + OATC14_HDD_STATUS_CABLE_OK = 0, 77 + OATC14_HDD_STATUS_OPEN, 78 + OATC14_HDD_STATUS_SHORT, 79 + OATC14_HDD_STATUS_NOT_DETECTABLE, 80 + }; 81 + 46 82 #endif /* __MDIO_OPEN_ALLIANCE__ */
+2
drivers/net/phy/microchip_t1s.c
··· 573 573 .get_plca_cfg = genphy_c45_plca_get_cfg, 574 574 .set_plca_cfg = lan86xx_plca_set_cfg, 575 575 .get_plca_status = genphy_c45_plca_get_status, 576 + .cable_test_start = genphy_c45_oatc14_cable_test_start, 577 + .cable_test_get_status = genphy_c45_oatc14_cable_test_get_status, 576 578 }, 577 579 { 578 580 PHY_ID_MATCH_EXACT(PHY_ID_LAN865X_REVB),
+122
drivers/net/phy/phy-c45.c
··· 7 7 #include <linux/mdio.h> 8 8 #include <linux/mii.h> 9 9 #include <linux/phy.h> 10 + #include <linux/ethtool_netlink.h> 10 11 11 12 #include "mdio-open-alliance.h" 12 13 #include "phylib-internal.h" ··· 1574 1573 return ret; 1575 1574 } 1576 1575 EXPORT_SYMBOL(genphy_c45_ethtool_set_eee); 1576 + 1577 + /** 1578 + * oatc14_cable_test_get_result_code - Convert hardware cable test status to 1579 + * ethtool result code. 1580 + * @status: The hardware-reported cable test status 1581 + * 1582 + * This helper function maps the OATC14 HDD cable test status to the 1583 + * corresponding ethtool cable test result code. It provides a translation 1584 + * between the device-specific status values and the standardized ethtool 1585 + * result codes. 1586 + * 1587 + * Return: 1588 + * * ETHTOOL_A_CABLE_RESULT_CODE_OK - Cable is OK 1589 + * * ETHTOOL_A_CABLE_RESULT_CODE_OPEN - Open circuit detected 1590 + * * ETHTOOL_A_CABLE_RESULT_CODE_SAME_SHORT - Short circuit detected 1591 + * * ETHTOOL_A_CABLE_RESULT_CODE_UNSPEC - Status not detectable or invalid 1592 + */ 1593 + static int oatc14_cable_test_get_result_code(enum oatc14_hdd_status status) 1594 + { 1595 + switch (status) { 1596 + case OATC14_HDD_STATUS_CABLE_OK: 1597 + return ETHTOOL_A_CABLE_RESULT_CODE_OK; 1598 + case OATC14_HDD_STATUS_OPEN: 1599 + return ETHTOOL_A_CABLE_RESULT_CODE_OPEN; 1600 + case OATC14_HDD_STATUS_SHORT: 1601 + return ETHTOOL_A_CABLE_RESULT_CODE_SAME_SHORT; 1602 + case OATC14_HDD_STATUS_NOT_DETECTABLE: 1603 + default: 1604 + return ETHTOOL_A_CABLE_RESULT_CODE_UNSPEC; 1605 + } 1606 + } 1607 + 1608 + /** 1609 + * genphy_c45_oatc14_cable_test_get_status - Get status of OATC14 10Base-T1S 1610 + * PHY cable test. 1611 + * @phydev: pointer to the PHY device structure 1612 + * @finished: pointer to a boolean set true if the test is complete 1613 + * 1614 + * Retrieves the current status of the OATC14 10Base-T1S PHY cable test. 1615 + * This function reads the OATC14 HDD register to determine whether the test 1616 + * results are valid and whether the test has finished. 1617 + * 1618 + * If the test is complete, the function reports the cable test result via 1619 + * the ethtool cable test interface using ethnl_cable_test_result(), and then 1620 + * clears the test control bit in the PHY register to reset the test state. 1621 + * 1622 + * Return: 0 on success, or a negative error code on failure (e.g. register 1623 + * read/write error). 1624 + */ 1625 + int genphy_c45_oatc14_cable_test_get_status(struct phy_device *phydev, 1626 + bool *finished) 1627 + { 1628 + int ret; 1629 + u8 sts; 1630 + 1631 + *finished = false; 1632 + 1633 + ret = phy_read_mmd(phydev, MDIO_MMD_VEND2, MDIO_OATC14_HDD); 1634 + if (ret < 0) 1635 + return ret; 1636 + 1637 + if (!(ret & OATC14_HDD_VALID)) 1638 + return 0; 1639 + 1640 + *finished = true; 1641 + 1642 + sts = FIELD_GET(OATC14_HDD_SHORT_OPEN_STATUS, ret); 1643 + 1644 + ret = ethnl_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_A, 1645 + oatc14_cable_test_get_result_code(sts)); 1646 + if (ret) 1647 + return ret; 1648 + 1649 + return phy_clear_bits_mmd(phydev, MDIO_MMD_VEND2, 1650 + MDIO_OATC14_HDD, OATC14_HDD_CONTROL); 1651 + } 1652 + EXPORT_SYMBOL(genphy_c45_oatc14_cable_test_get_status); 1653 + 1654 + /** 1655 + * genphy_c45_oatc14_cable_test_start - Start a cable test on an OATC14 1656 + * 10Base-T1S PHY. 1657 + * @phydev: Pointer to the PHY device structure 1658 + * 1659 + * This function initiates a cable diagnostic test on a Clause 45 OATC14 1660 + * 10Base-T1S capable PHY device. It first reads the PHY’s advanced diagnostic 1661 + * capability register to check if High Definition Diagnostics (HDD) mode is 1662 + * supported. If the PHY does not report HDD capability, cable testing is not 1663 + * supported and the function returns -EOPNOTSUPP. 1664 + * 1665 + * For PHYs that support HDD, the function sets the appropriate control bits in 1666 + * the OATC14_HDD register to enable and start the cable diagnostic test. 1667 + * 1668 + * Return: 1669 + * * 0 on success 1670 + * * -EOPNOTSUPP if the PHY does not support HDD capability 1671 + * * A negative error code on I/O or register access failures 1672 + */ 1673 + int genphy_c45_oatc14_cable_test_start(struct phy_device *phydev) 1674 + { 1675 + int ret; 1676 + 1677 + ret = phy_read_mmd(phydev, MDIO_MMD_VEND2, MDIO_OATC14_ADFCAP); 1678 + if (ret < 0) 1679 + return ret; 1680 + 1681 + if (!(ret & OATC14_ADFCAP_HDD_CAPABILITY)) 1682 + return -EOPNOTSUPP; 1683 + 1684 + ret = phy_set_bits_mmd(phydev, MDIO_MMD_VEND2, MDIO_OATC14_HDD, 1685 + OATC14_HDD_CONTROL); 1686 + if (ret) 1687 + return ret; 1688 + 1689 + ret = phy_read_mmd(phydev, MDIO_MMD_VEND2, MDIO_OATC14_HDD); 1690 + if (ret < 0) 1691 + return ret; 1692 + 1693 + return phy_set_bits_mmd(phydev, MDIO_MMD_VEND2, MDIO_OATC14_HDD, 1694 + OATC14_HDD_START_CONTROL); 1695 + } 1696 + EXPORT_SYMBOL(genphy_c45_oatc14_cable_test_start);
+3
include/linux/phy.h
··· 2251 2251 int genphy_c45_ethtool_set_eee(struct phy_device *phydev, 2252 2252 struct ethtool_keee *data); 2253 2253 int genphy_c45_an_config_eee_aneg(struct phy_device *phydev); 2254 + int genphy_c45_oatc14_cable_test_start(struct phy_device *phydev); 2255 + int genphy_c45_oatc14_cable_test_get_status(struct phy_device *phydev, 2256 + bool *finished); 2254 2257 2255 2258 /* The gen10g_* functions are the old Clause 45 stub */ 2256 2259 int gen10g_config_aneg(struct phy_device *phydev);