netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v2] mlxbf_gige: report unknown speed and duplex when link is down
@ 2025-10-14 16:16 Chris Babroski
  2025-10-17 22:54 ` Jakub Kicinski
  0 siblings, 1 reply; 4+ messages in thread
From: Chris Babroski @ 2025-10-14 16:16 UTC (permalink / raw)
  To: andrew+netdev, davem, edumazet, kuba, pabeni, netdev,
	linux-kernel
  Cc: cbabroski, davthompson, hkallweit1, linux

The "Speed" and "Duplex" fields displayed by ethtool for the OOB
interface should report "Unknown" when the link is down to match the
behavior of other network interfaces on BlueField (implemented by the
mlx5 driver). Currently, the mlxbf_gige driver always reports the
initially configured link speed and duplex, regardless of the actual
link state.

The link speed and duplex are not updated for two reasons:
  1. On BlueField the OOB phy is internally hardwired to a three port
     switch. This means the physical link between the phy and link
     partner is always up, regardless of the administrative link state
     configured with ifconfig.
  2. phy_ethtool_get_link_ksettings() reads cached values that are only
     updated when phy_read_status() is called by the phy state machine.
     Doing "ifconfig down" will trigger phy_stop() in the
     ndo_stop() handler. This halts the phy state machine and sets
     phydev->link without calling phy_read_status() or explicitly
     updating other values, so the speed and duplex returned by
     future phy_ethtool_get_link_ksettings() calls will be stale.

While #2 could potentially be fixed (assuming this is even an issue for
other devices), #1 is unique to BlueField.

Implement a custom get_link_ksettings() handler in mlxbf_gige that calls
phy_ethtool_get_link_ksettings() and updates the speed and duplex based
on the link state. When the link is brought down with ifconfig, the
driver now reports unknown speed and duplex to ethtool as expected.

Signed-off-by: Chris Babroski <cbabroski@nvidia.com>
---
v2:
  - Update commit message to clarify why phy_ethtool_get_link_ksettings()
    does not return unknown link speed and duplex when the link is down
    on BlueField.
v1: https://lore.kernel.org/netdev/20250813163346.302186-1-cbabroski@nvidia.com/#t

 .../mellanox/mlxbf_gige/mlxbf_gige_ethtool.c  | 26 ++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_ethtool.c b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_ethtool.c
index 8b63968bbee9..c519eeb8ec48 100644
--- a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_ethtool.c
@@ -159,6 +159,30 @@ static void mlxbf_gige_get_pause_stats(struct net_device *netdev,
 	}
 }
 
+static int mlxbf_gige_get_link_ksettings(struct net_device *ndev,
+					 struct ethtool_link_ksettings *cmd)
+{
+	struct phy_device *phydev;
+	int ret;
+
+	ret = phy_ethtool_get_link_ksettings(ndev, cmd);
+	if (ret)
+		return ret;
+
+	phydev = ndev->phydev;
+	if (!phydev)
+		return -ENODEV;
+
+	mutex_lock(&phydev->lock);
+	if (!phydev->link) {
+		cmd->base.speed = SPEED_UNKNOWN;
+		cmd->base.duplex = DUPLEX_UNKNOWN;
+	}
+	mutex_unlock(&phydev->lock);
+
+	return 0;
+}
+
 const struct ethtool_ops mlxbf_gige_ethtool_ops = {
 	.get_link		= ethtool_op_get_link,
 	.get_ringparam		= mlxbf_gige_get_ringparam,
@@ -170,6 +194,6 @@ const struct ethtool_ops mlxbf_gige_ethtool_ops = {
 	.nway_reset		= phy_ethtool_nway_reset,
 	.get_pauseparam		= mlxbf_gige_get_pauseparam,
 	.get_pause_stats	= mlxbf_gige_get_pause_stats,
-	.get_link_ksettings	= phy_ethtool_get_link_ksettings,
+	.get_link_ksettings	= mlxbf_gige_get_link_ksettings,
 	.set_link_ksettings	= phy_ethtool_set_link_ksettings,
 };
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next v2] mlxbf_gige: report unknown speed and duplex when link is down
  2025-10-14 16:16 [PATCH net-next v2] mlxbf_gige: report unknown speed and duplex when link is down Chris Babroski
@ 2025-10-17 22:54 ` Jakub Kicinski
  2025-10-22 17:08   ` Chris Babroski
  0 siblings, 1 reply; 4+ messages in thread
From: Jakub Kicinski @ 2025-10-17 22:54 UTC (permalink / raw)
  To: Chris Babroski
  Cc: andrew+netdev, davem, edumazet, pabeni, netdev, linux-kernel,
	davthompson, hkallweit1, linux

On Tue, 14 Oct 2025 12:16:31 -0400 Chris Babroski wrote:
> The "Speed" and "Duplex" fields displayed by ethtool for the OOB
> interface should report "Unknown" when the link is down to match the
> behavior of other network interfaces on BlueField (implemented by the
> mlx5 driver). Currently, the mlxbf_gige driver always reports the
> initially configured link speed and duplex, regardless of the actual
> link state.
> 
> The link speed and duplex are not updated for two reasons:
>   1. On BlueField the OOB phy is internally hardwired to a three port
>      switch. This means the physical link between the phy and link
>      partner is always up, regardless of the administrative link state
>      configured with ifconfig.
>   2. phy_ethtool_get_link_ksettings() reads cached values that are only
>      updated when phy_read_status() is called by the phy state machine.
>      Doing "ifconfig down" will trigger phy_stop() in the
>      ndo_stop() handler. This halts the phy state machine and sets
>      phydev->link without calling phy_read_status() or explicitly
>      updating other values, so the speed and duplex returned by
>      future phy_ethtool_get_link_ksettings() calls will be stale.
> 
> While #2 could potentially be fixed (assuming this is even an issue for
> other devices), #1 is unique to BlueField.
> 
> Implement a custom get_link_ksettings() handler in mlxbf_gige that calls
> phy_ethtool_get_link_ksettings() and updates the speed and duplex based
> on the link state. When the link is brought down with ifconfig, the
> driver now reports unknown speed and duplex to ethtool as expected.

Are you sure you still need this now that 60f887b1290b has been applied?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next v2] mlxbf_gige: report unknown speed and duplex when link is down
  2025-10-17 22:54 ` Jakub Kicinski
@ 2025-10-22 17:08   ` Chris Babroski
  2025-10-23  0:09     ` Jakub Kicinski
  0 siblings, 1 reply; 4+ messages in thread
From: Chris Babroski @ 2025-10-22 17:08 UTC (permalink / raw)
  To: kuba
  Cc: andrew+netdev, cbabroski, davem, davthompson, edumazet,
	hkallweit1, linux-kernel, linux, netdev, pabeni

Hi Jakub,

Thank you for pointing 60f887b1290b out - this commit resolves
the issue and our patch is no longer needed. Please disregard.

Chris

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next v2] mlxbf_gige: report unknown speed and duplex when link is down
  2025-10-22 17:08   ` Chris Babroski
@ 2025-10-23  0:09     ` Jakub Kicinski
  0 siblings, 0 replies; 4+ messages in thread
From: Jakub Kicinski @ 2025-10-23  0:09 UTC (permalink / raw)
  To: Chris Babroski
  Cc: andrew+netdev, davem, davthompson, edumazet, hkallweit1,
	linux-kernel, linux, netdev, pabeni

On Wed, 22 Oct 2025 13:08:25 -0400 Chris Babroski wrote:
> Hi Jakub,
> 
> Thank you for pointing 60f887b1290b out - this commit resolves
> the issue and our patch is no longer needed. Please disregard.

Lucky timing :) Thanks for confirming

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-10-23  0:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-14 16:16 [PATCH net-next v2] mlxbf_gige: report unknown speed and duplex when link is down Chris Babroski
2025-10-17 22:54 ` Jakub Kicinski
2025-10-22 17:08   ` Chris Babroski
2025-10-23  0:09     ` Jakub Kicinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).