Skip to contentSkip to conversation

net: mana: Support HW link state events

PATCH Superseded Haiyang Zhang 4 participants 5 messages Oct 24, 2025 – Oct 29, 2025

Subsystems (5)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 net: mana: Support HW link state events

From: Haiyang Zhang <[email protected]>

Handle the HW link state events received from HW channel, and set the proper link state accordingly.

---
v3:
Don't stop / start the queues, and use disable_work_sync() as suggested by Jakub Kicinski.

v2:
Updated link up/down to be symmetric, and other minor changes based on comments from Andrew Lunn.

---
 .../net/ethernet/microsoft/mana/gdma_main.c   |  1 +
 .../net/ethernet/microsoft/mana/hw_channel.c  | 12 +++++
 drivers/net/ethernet/microsoft/mana/mana_en.c | 53 +++++++++++++++++--
 include/net/mana/gdma.h                       |  4 +-
 include/net/mana/hw_channel.h                 |  2 +
 include/net/mana/mana.h                       |  4 ++
 6 files changed, 70 insertions(+), 6 deletions(-)
drivers/net/ethernet/microsoft/mana/gdma_main.c +1 -0
index 43f034e180c4..effe0a2f207a 100644
@@ -528,6 +528,7 @@ static void mana_gd_process_eqe(struct gdma_queue *eq)
 	case GDMA_EQE_HWC_INIT_DONE:
 	case GDMA_EQE_HWC_SOC_SERVICE:
 	case GDMA_EQE_RNIC_QP_FATAL:
+	case GDMA_EQE_HWC_SOC_RECONFIG_DATA:
 		if (!eq->eq.callback)
 			break;
 
drivers/net/ethernet/microsoft/mana/hw_channel.c +12 -0
index ada6c78a2bef..367e18d71413 100644
@@ -118,6 +118,7 @@ static void mana_hwc_init_event_handler(void *ctx, struct gdma_queue *q_self,
 	struct gdma_dev *gd = hwc->gdma_dev;
 	union hwc_init_type_data type_data;
 	union hwc_init_eq_id_db eq_db;
+	struct mana_context *ac;
 	u32 type, val;
 	int ret;
 
@@ -196,6 +197,17 @@ static void mana_hwc_init_event_handler(void *ctx, struct gdma_queue *q_self,
 			hwc->hwc_timeout = val;
 			break;
 
+		case HWC_DATA_HW_LINK_CONNECT:
+		case HWC_DATA_HW_LINK_DISCONNECT:
+			ac = gd->gdma_context->mana.driver_data;
+			if (!ac)
+				break;
+
+			ac->link_event = type;
+			schedule_work(&ac->link_change_work);
+
+			break;
+
 		default:
 			dev_warn(hwc->dev, "Received unknown reconfig type %u\n", type);
 			break;
drivers/net/ethernet/microsoft/mana/mana_en.c +48 -5

107 lines not on this page · raw message

include/net/mana/gdma.h +3 -1
index 57df78cfbf82..637f42485dba 100644
@@ -590,6 +590,7 @@ enum {
 
 /* Driver can self reset on FPGA Reconfig EQE notification */
 #define GDMA_DRV_CAP_FLAG_1_HANDLE_RECONFIG_EQE BIT(17)
+#define GDMA_DRV_CAP_FLAG_1_HW_VPORT_LINK_AWARE BIT(6)
 
 #define GDMA_DRV_CAP_FLAGS1 \
 	(GDMA_DRV_CAP_FLAG_1_EQ_SHARING_MULTI_VPORT | \
@@ -599,7 +600,8 @@ enum {
 	 GDMA_DRV_CAP_FLAG_1_DEV_LIST_HOLES_SUP | \
 	 GDMA_DRV_CAP_FLAG_1_DYNAMIC_IRQ_ALLOC_SUPPORT | \
 	 GDMA_DRV_CAP_FLAG_1_SELF_RESET_ON_EQE | \
-	 GDMA_DRV_CAP_FLAG_1_HANDLE_RECONFIG_EQE)
+	 GDMA_DRV_CAP_FLAG_1_HANDLE_RECONFIG_EQE | \
+	 GDMA_DRV_CAP_FLAG_1_HW_VPORT_LINK_AWARE)
 
 #define GDMA_DRV_CAP_FLAGS2 0
 
include/net/mana/hw_channel.h +2 -0
index 83cf93338eb3..16feb39616c1 100644
@@ -24,6 +24,8 @@
 #define HWC_INIT_DATA_PF_DEST_CQ_ID	11
 
 #define HWC_DATA_CFG_HWC_TIMEOUT 1
+#define HWC_DATA_HW_LINK_CONNECT 2
+#define HWC_DATA_HW_LINK_DISCONNECT 3
 
 #define HW_CHANNEL_WAIT_RESOURCE_TIMEOUT_MS 30000
 
include/net/mana/mana.h +4 -0
index 0921485565c0..8906901535f5 100644
@@ -477,6 +477,10 @@ struct mana_context {
 	struct dentry *mana_eqs_debugfs;
 
 	struct net_device *ports[MAX_PORTS_IN_MANA_DEV];
+
+	/* Link state change work */
+	struct work_struct link_change_work;
+	u32 link_event;
 };
 
 struct mana_port_context {
Signature · 1 line
2.34.1
maintainer
#1 lore raw

drivers/net/ethernet/microsoft/mana/mana_en.c static int mana_probe_port(struct mana_context *ac, int port_idx, · line 3281

Quoted 5 lines · Haiyang Zhang
drivers/net/ethernet/microsoft/mana/mana_en.c +1 -0
@@ -3243,6 +3278,8 @@ static int mana_probe_port(struct mana_context *ac, int port_idx,
 		goto free_indir;
 	}
 
+	netif_carrier_on(ndev);

Why is the above needed? I thought mana_link_state_handle() should kick and set the carrier on as needed???

/P

maintainer
#2 lore raw
Quoted 24 lines

-----Original Message-----
From: Paolo Abeni <[email protected]>
Sent: Tuesday, October 28, 2025 10:31 AM
To: Haiyang Zhang <[email protected]>; linux- [email protected]; [email protected]
Cc: Haiyang Zhang <[email protected]>; Paul Rosswurm <[email protected]>; Dexuan Cui <[email protected]>; KY Srinivasan <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Long Li <[email protected]>; [email protected]; [email protected]; [email protected]; Konstantin Taranov <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Shiraz Saleem <[email protected]>; [email protected]; [email protected]; linux- [email protected]
Subject: [EXTERNAL] Re: [net-next, v3] net: mana: Support HW link state events

Review static int mana_probe_port(struct mana_context

Quoted 1 line · Haiyang Zhang
(quoted diff) +0 -0
@@ -3243,6 +3278,8 @@ static int mana_probe_port(struct mana_context

*ac, int port_idx,

Quoted 7 lines

drivers/net/ethernet/microsoft/mana/mana_en.c static int mana_probe_port(struct mana_context *ac, int port_idx, · line 3281

Quoted 4 lines
drivers/net/ethernet/microsoft/mana/mana_en.c +1 -0
 		goto free_indir;
 	}
 
+	netif_carrier_on(ndev);

Why is the above needed? I thought mana_link_state_handle() should kick and set the carrier on as needed???

Thanks for the question -- our MANA NIC only sends out the link state down/up messages when need to let the VM rerun DHCP client and change IP address...

So, I need to add netif_carrier_on(ndev) in the probe(), otherwise the /sys/class/net/ethX/operstate will remain "unknown" until it receives the Link down/up messages which do NOT always happen.

Cc @Paul Rosswurm

- Haiyang

maintainer
#3 lore raw
Quoted 9 lines · On Tue, 28 Oct 2025 19:36:02 +0000 Haiyang Zhang wrote:
Quoted 2 lines

Why is the above needed? I thought mana_link_state_handle() should kick and set the carrier on as needed???

Thanks for the question -- our MANA NIC only sends out the link state down/up messages when need to let the VM rerun DHCP client and change IP address...

So, I need to add netif_carrier_on(ndev) in the probe(), otherwise the /sys/class/net/ethX/operstate will remain "unknown" until it receives the Link down/up messages which do NOT always happen.

Oh that makes the code make much more sense. Please add this and more detail into the commit message.

drivers/net/ethernet/microsoft/mana/mana_en.c static int mana_close(struct net_device *ndev) · line 129

Quoted 2 lines
drivers/net/ethernet/microsoft/mana/mana_en.c +2 -0
+			if (!netif_carrier_ok(ndev))
+				netif_carrier_on(ndev);

Testing carrier_ok() before calling carrier_on/off is entirely pointless, please see the relevant implementations.

BTW I think the ac->link_event accesses are technically racy, wrap them in READ_ONCE() / WRITE_ONCE() while you respin. (Unless mana_hwc_init_event_handler() is somehow under rtnl_lock)

Signature · 1 line
pw-bot: cr
maintainer
#4 lore raw
Quoted 31 lines

-----Original Message-----
From: Jakub Kicinski <[email protected]>
Sent: Tuesday, October 28, 2025 6:02 PM
To: Haiyang Zhang <[email protected]>
Cc: Paolo Abeni <[email protected]>; Haiyang Zhang <[email protected]>; [email protected]; [email protected]; Paul Rosswurm <[email protected]>; Dexuan Cui <[email protected]>; KY Srinivasan <[email protected]>; [email protected]; [email protected]; [email protected]; Long Li <[email protected]>; [email protected]; [email protected]; [email protected]; Konstantin Taranov <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Shiraz Saleem <[email protected]>; [email protected]; [email protected]; linux- [email protected]
Subject: Re: [EXTERNAL] Re: [net-next, v3] net: mana: Support HW link state events

Quoted 1 line · On Tue, 28 Oct 2025 19:36:02 +0000 Haiyang Zhang wrote:
Quoted 1 line

Why is the above needed? I thought mana_link_state_handle() should

kick

Quoted 3 lines
Quoted 1 line

and set the carrier on as needed???

Thanks for the question -- our MANA NIC only sends out the link state

down/up

Quoted 1 line

messages when need to let the VM rerun DHCP client and change IP

address...

Quoted 1 line
Quoted 7 lines
Quoted 2 lines

So, I need to add netif_carrier_on(ndev) in the probe(), otherwise the /sys/class/net/ethX/operstate will remain "unknown" until it receives

the

Quoted 1 line

Link down/up messages which do NOT always happen.

Oh that makes the code make much more sense. Please add this and more detail into the commit message.

Will do.

Quoted 10 lines

drivers/net/ethernet/microsoft/mana/mana_en.c static int mana_close(struct net_device *ndev) · line 129

Quoted 3 lines
drivers/net/ethernet/microsoft/mana/mana_en.c +2 -0
+			if (!netif_carrier_ok(ndev))
+				netif_carrier_on(ndev);

Testing carrier_ok() before calling carrier_on/off is entirely pointless, please see the relevant implementations.

BTW I think the ac->link_event accesses are technically racy, wrap them in READ_ONCE() / WRITE_ONCE() while you respin. (Unless mana_hwc_init_event_handler() is somehow under rtnl_lock)

I will remove the netif_carrier_ok(), and add READ/WRITE_ONCE.

Thanks,
- Haiyang