Netdev List
 help / color / mirror / Atom feed
From: Manjunath Patil <manjunath.b.patil@oracle.com>
To: netdev@vger.kernel.org
Cc: saeedm@nvidia.com, tariqt@nvidia.com, mbloch@nvidia.com,
	leon@kernel.org, andrew+netdev@lunn.ch, davem@davemloft.net,
	edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
	linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org,
	manjunath.b.patil@oracle.com
Subject: [PATCH net-next] net/mlx5e: Report link down on administrative close
Date: Mon,  8 Jun 2026 16:42:23 -0700	[thread overview]
Message-ID: <20260608234223.3731557-1-manjunath.b.patil@oracle.com> (raw)

mlx5e_update_carrier() reports both link-up and link-down carrier
changes, but an administrative down does not reach it in practice. The
close path first changes the port admin state and then clears
MLX5E_STATE_OPENED and drops carrier silently in mlx5e_close_locked().
Any queued carrier worker will skip update_carrier() once the device is
no longer opened.

This leaves "ip link set dev <dev> down" without a matching netdev
"Link down" message, while reopening the device still reports "Link up".

Report the link-down transition in mlx5e_close() before the common close
helper clears the opened state and drops carrier. Guard the message with
the current opened and carrier state to avoid duplicates when the netdev
is already closed or carrier is already down.

Assisted-by: Codex:gpt-5
Signed-off-by: Manjunath Patil <manjunath.b.patil@oracle.com>
---
Validation:
- Built an OL8 mainline test kernel from this change.
- Booted 7.1.0-rc6.bug123456.el8.v1.x86_64 on an mlx5-backed VM.
- Confirmed `ip link set dev re0 down/up` and `re1 down/up` now emit
  netdev `Link down` and `Link up` messages, alongside the existing RDMA
  port state notifications.

 drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index 8f2b3abe0092..a04a89f0eddf 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -3628,6 +3628,9 @@ int mlx5e_close(struct net_device *netdev)
 
 	mutex_lock(&priv->state_lock);
 	mlx5e_modify_admin_state(priv->mdev, MLX5_PORT_DOWN);
+	if (test_bit(MLX5E_STATE_OPENED, &priv->state) &&
+	    netif_carrier_ok(netdev))
+		netdev_info(netdev, "Link down\n");
 	err = mlx5e_close_locked(netdev);
 	mutex_unlock(&priv->state_lock);
 

base-commit: e43ffb69e0438cddd72aaa30898b4dc446f664f8
-- 
2.47.3

             reply	other threads:[~2026-06-08 23:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-08 23:42 Manjunath Patil [this message]
2026-06-10 12:06 ` [PATCH net-next] net/mlx5e: Report link down on administrative close Tariq Toukan
2026-06-11 20:13   ` manjunath.b.patil
2026-08-19 17:35     ` manjunath.b.patil
2026-10-06 20:01       ` manjunath.b.patil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260608234223.3731557-1-manjunath.b.patil@oracle.com \
    --to=manjunath.b.patil@oracle.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=mbloch@nvidia.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=saeedm@nvidia.com \
    --cc=tariqt@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox