diff mbox series

[net-next,v2,4/5] tsnep: Select speed for loopback

Message ID 20250110144828.4943-5-gerhard@engleder-embedded.com (mailing list archive)
State New
Delegated to: Netdev Maintainers
Headers show
Series Support loopback mode speed selection | expand

Commit Message

Gerhard Engleder Jan. 10, 2025, 2:48 p.m. UTC
Use 100 Mbps only if the PHY is configured to this speed. Otherwise use
always the maximum speed of 1000 Mbps.

Signed-off-by: Gerhard Engleder <gerhard@engleder-embedded.com>
---
 drivers/net/ethernet/engleder/tsnep_main.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/net/ethernet/engleder/tsnep_main.c b/drivers/net/ethernet/engleder/tsnep_main.c
index 5c501e4f9e3e..45b9f5780902 100644
--- a/drivers/net/ethernet/engleder/tsnep_main.c
+++ b/drivers/net/ethernet/engleder/tsnep_main.c
@@ -229,8 +229,19 @@  static void tsnep_phy_link_status_change(struct net_device *netdev)
 static int tsnep_phy_loopback(struct tsnep_adapter *adapter, bool enable)
 {
 	int retval;
+	int speed;
 
-	retval = phy_loopback(adapter->phydev, enable, 0);
+	if (enable) {
+		if (adapter->phydev->autoneg == AUTONEG_DISABLE &&
+		    adapter->phydev->speed == SPEED_100)
+			speed = SPEED_100;
+		else
+			speed = SPEED_1000;
+	} else {
+		speed = 0;
+	}
+
+	retval = phy_loopback(adapter->phydev, enable, speed);
 
 	/* PHY link state change is not signaled if loopback is enabled, it
 	 * would delay a working loopback anyway, let's ensure that loopback