diff mbox series

[v4,net-next,7/8] net: phy: at803x: validate in-band autoneg for AT8031/AT8033

Message ID 20221118000124.2754581-8-vladimir.oltean@nxp.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series Let phylink manage in-band AN for the PHY | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 8 of 8 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 22 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Vladimir Oltean Nov. 18, 2022, 12:01 a.m. UTC
Allow drivers which migrate from phylib to phylink and have old device
tree blobs to work with the AR8031/AT8033 on-board PHY in the SGMII
SERDES side mode.

This would allow DT breakage like the one fixed by commit df392aefe96b
("arm64: dts: fsl-ls1028a-kontron-sl28: specify in-band mode for ENETC")
to be avoided in the future.

We know from experimentation with NXP SoCs that the PHY doesn't pass
traffic if in-band autoneg is enabled but fails to complete. We also
know that it is in principle possible to disable in-band autoneg in the
PHY. This would require disabling autoneg in the fiber page, and then
keeping the fiber and copper page speeds in sync, as explained by
Michael Walle here:
https://patchwork.kernel.org/project/netdevbpf/patch/20210212172341.3489046-2-olteanv@gmail.com/

But since the PHY driver does not currently handle the complexity of
keeping those speeds in sync, we can safely say that no MAC attached to
the AT8031/AT8033 in SGMII mode has in-band autoneg disabled.

I have no motivation to add support for disabled in-band autoneg. I just
need the driver to report that it requires this enabled, which will
make phylink promote a MLO_AN_PHY connection to MLO_AN_INBAND. This is
enough to keep everyone happy.

These PHYs also support RGMII, and for that mode, we report that in-band
AN is unknown, which means that phylink will not change the mode from
the device tree. Since commit d73ffc08824d ("net: phylink: allow
RGMII/RTBI in-band status"), RGMII in-band status is a thing, and I
don't want to meddle with that unless I have a reason for it.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
v3->v4:
- s/inband_aneg/an_inband/
- drop unnecessary support for PHY_AN_INBAND_OFF

 drivers/net/phy/at803x.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
diff mbox series

Patch

diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c
index 349b7b1dbbf2..2ef6ac92fecb 100644
--- a/drivers/net/phy/at803x.c
+++ b/drivers/net/phy/at803x.c
@@ -1355,6 +1355,15 @@  static int at803x_config_aneg(struct phy_device *phydev)
 	return __genphy_config_aneg(phydev, ret);
 }
 
+static int at803x_validate_an_inband(struct phy_device *phydev,
+				     phy_interface_t interface)
+{
+	if (interface == PHY_INTERFACE_MODE_SGMII)
+		return PHY_AN_INBAND_ON;
+
+	return PHY_AN_INBAND_UNKNOWN;
+}
+
 static int at803x_get_downshift(struct phy_device *phydev, u8 *d)
 {
 	int val;
@@ -2076,6 +2085,7 @@  static struct phy_driver at803x_driver[] = {
 	.set_tunable		= at803x_set_tunable,
 	.cable_test_start	= at803x_cable_test_start,
 	.cable_test_get_status	= at803x_cable_test_get_status,
+	.validate_an_inband	= at803x_validate_an_inband,
 }, {
 	/* Qualcomm Atheros AR8032 */
 	PHY_ID_MATCH_EXACT(ATH8032_PHY_ID),