* [PATCH net-next v1] mlxbf_gige: report unknown speed and duplex when link is down
@ 2025-08-13 16:33 Chris Babroski
2025-08-15 19:11 ` Jakub Kicinski
0 siblings, 1 reply; 3+ messages in thread
From: Chris Babroski @ 2025-08-13 16:33 UTC (permalink / raw)
To: andrew+netdev, davem, edumazet, kuba, pabeni
Cc: davthompson, cbabroski, netdev, linux-kernel
The "Speed" and "Duplex" fields displayed by ethtool should report
"Unknown" when the link is down. Currently, the driver always reports
the initially configured link speed and duplex, regardless of the actual
link state.
Implement a get_link_ksettings() callback to update the values reported
to ethtool based on the link state. When the link is down, the driver
now reports unknown speed and duplex as expected.
Signed-off-by: Chris Babroski <cbabroski@nvidia.com>
---
.../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,
};
base-commit: d9104cec3e8fe4b458b74709853231385779001f
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next v1] mlxbf_gige: report unknown speed and duplex when link is down
2025-08-13 16:33 [PATCH net-next v1] mlxbf_gige: report unknown speed and duplex when link is down Chris Babroski
@ 2025-08-15 19:11 ` Jakub Kicinski
2025-08-26 18:45 ` Chris Babroski
0 siblings, 1 reply; 3+ messages in thread
From: Jakub Kicinski @ 2025-08-15 19:11 UTC (permalink / raw)
To: Chris Babroski
Cc: andrew+netdev, davem, edumazet, pabeni, davthompson, netdev,
linux-kernel
On Wed, 13 Aug 2025 12:33:46 -0400 Chris Babroski wrote:
> The "Speed" and "Duplex" fields displayed by ethtool should report
> "Unknown" when the link is down. Currently, the driver always reports
> the initially configured link speed and duplex, regardless of the actual
> link state.
>
> Implement a get_link_ksettings() callback to update the values reported
> to ethtool based on the link state. When the link is down, the driver
> now reports unknown speed and duplex as expected.
If that's the correct thing to do why is
phy_ethtool_get_link_ksettings() not doing it?
Please explain what makes mlxbf special, and make sure to CC PHY
maintainers on v2.
--
pw-bot: cr
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next v1] mlxbf_gige: report unknown speed and duplex when link is down
2025-08-15 19:11 ` Jakub Kicinski
@ 2025-08-26 18:45 ` Chris Babroski
0 siblings, 0 replies; 3+ messages in thread
From: Chris Babroski @ 2025-08-26 18:45 UTC (permalink / raw)
To: kuba
Cc: andrew+netdev, cbabroski, davem, davthompson, edumazet,
linux-kernel, netdev, pabeni, hkallweit1, linux
Hi Jakub,
Thanks for the feedback.
> If that's the correct thing to do why is
> phy_ethtool_get_link_ksettings() not doing it?
If I understand correctly, phy_ethtool_get_link_ksettings() reads
cached values that are updated when phy_read_status() is called by the
phy state machine. Doing "ifconfig down" will eventually 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
setting other values, like speed and duplex.
It seems this is expected behavior with phylib, but I'm not familiar
with the implementation history. CC'd PHY maintainers for additional
input.
> Please explain what makes mlxbf special
BlueField is unique in that the phy is hardwired to an internal switch
and so the physical link between the phy and link partner is always
up. This will also affect what link settings are reported by the phy.
This patch comes from a desire for ethtool output behavior to be the
same when an administrative link down is issued on the BlueField OOB
(mlxbf_gige) and NIC (mlx5) interfaces. The mlx5 driver implements
custom get_link_ksettings() handlers and does not use phylib.
Best,
Chris
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-08-26 18:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-13 16:33 [PATCH net-next v1] mlxbf_gige: report unknown speed and duplex when link is down Chris Babroski
2025-08-15 19:11 ` Jakub Kicinski
2025-08-26 18:45 ` Chris Babroski
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).