lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240416121032.52108-3-eichest@gmail.com>
Date: Tue, 16 Apr 2024 14:10:32 +0200
From: Stefan Eichenberger <eichest@...il.com>
To: davem@...emloft.net,
	edumazet@...gle.com,
	kuba@...nel.org,
	pabeni@...hat.com,
	robh@...nel.org,
	krzysztof.kozlowski+dt@...aro.org,
	conor+dt@...nel.org,
	lxu@...linear.com,
	andrew@...n.ch,
	hkallweit1@...il.com,
	linux@...linux.org.uk,
	michael@...le.cc
Cc: netdev@...r.kernel.org,
	devicetree@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: [RFC PATCH 2/2] net: phy: mxl-gpy: add new device tree property to disable SGMII autoneg

Add a new device tree property to disable SGMII autonegotiation and
instead use the option to match the SGMII speed to what was negotiated
on the twisted pair interface (tpi). This allows us to disable SGMII
autonegotiation on Ethernet controllers that are not compatible with
this mode.

Signed-off-by: Stefan Eichenberger <eichest@...il.com>
---
 drivers/net/phy/mxl-gpy.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/drivers/net/phy/mxl-gpy.c b/drivers/net/phy/mxl-gpy.c
index b2d36a3a96f1..4147b4c29eaf 100644
--- a/drivers/net/phy/mxl-gpy.c
+++ b/drivers/net/phy/mxl-gpy.c
@@ -114,6 +114,7 @@ struct gpy_priv {
 	 * is enabled.
 	 */
 	u64 lb_dis_to;
+	bool sgmii_match_tpi_speed;
 };
 
 static const struct {
@@ -262,8 +263,17 @@ static int gpy_mbox_read(struct phy_device *phydev, u32 addr)
 
 static int gpy_config_init(struct phy_device *phydev)
 {
+	struct gpy_priv *priv = phydev->priv;
 	int ret;
 
+	/* Disalbe SGMII Autoneg if we want to match SGMII to TPI speed */
+	if (priv->sgmii_match_tpi_speed) {
+		ret = phy_modify_mmd(phydev, MDIO_MMD_VEND1, VSPEC1_SGMII_CTRL,
+				     VSPEC1_SGMII_CTRL_ANEN, 0);
+		if (ret < 0)
+			return ret;
+	}
+
 	/* Mask all interrupts */
 	ret = phy_write(phydev, PHY_IMASK, 0);
 	if (ret)
@@ -304,6 +314,9 @@ static int gpy_probe(struct phy_device *phydev)
 	if (!device_property_present(dev, "maxlinear,use-broken-interrupts"))
 		phydev->dev_flags |= PHY_F_NO_IRQ;
 
+	priv->sgmii_match_tpi_speed =
+		device_property_present(dev, "maxlinear,sgmii-match-tpi-speed");
+
 	fw_version = phy_read(phydev, PHY_FWV);
 	if (fw_version < 0)
 		return fw_version;
@@ -516,6 +529,7 @@ static int gpy_update_mdix(struct phy_device *phydev)
 
 static int gpy_update_interface(struct phy_device *phydev)
 {
+	struct gpy_priv *priv = phydev->priv;
 	int ret;
 
 	/* Interface mode is fixed for USXGMII and integrated PHY */
@@ -529,6 +543,8 @@ static int gpy_update_interface(struct phy_device *phydev)
 	switch (phydev->speed) {
 	case SPEED_2500:
 		phydev->interface = PHY_INTERFACE_MODE_2500BASEX;
+		if (!gpy_sgmii_aneg_en(phydev))
+			break;
 		ret = phy_modify_mmd(phydev, MDIO_MMD_VEND1, VSPEC1_SGMII_CTRL,
 				     VSPEC1_SGMII_CTRL_ANEN, 0);
 		if (ret < 0) {
@@ -542,7 +558,7 @@ static int gpy_update_interface(struct phy_device *phydev)
 	case SPEED_100:
 	case SPEED_10:
 		phydev->interface = PHY_INTERFACE_MODE_SGMII;
-		if (gpy_sgmii_aneg_en(phydev))
+		if (gpy_sgmii_aneg_en(phydev) || priv->sgmii_match_tpi_speed)
 			break;
 		/* Enable and restart SGMII ANEG for 10/100/1000Mbps link speed
 		 * if ANEG is disabled (in 2500-BaseX mode).
-- 
2.40.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ