net: mana: Support HW link state events
Subsystems (5)
PATCH v2 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, also stop/wake queues accordingly.
---
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 | 19 +++++ drivers/net/ethernet/microsoft/mana/mana_en.c | 76 +++++++++++++++++-- include/net/mana/gdma.h | 4 +- include/net/mana/hw_channel.h | 2 + include/net/mana/mana.h | 6 ++ 6 files changed, 99 insertions(+), 9 deletions(-)
drivers/net/ethernet/microsoft/mana/gdma_main.c +1 -0
@@ -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 +19 -0
@@ -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,24 @@ 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 ; + +if (ac->mana_removing) { +dev_info (hwc->dev, +"Removing: skip link event %u\n" , + type); +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 +68 -8
130 lines not on this page · raw message
include/net/mana/gdma.h +3 -1
@@ -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
@@ -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 +6 -0
@@ -477,6 +477,12 @@ 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; + +bool mana_removing; };struct mana_port_context {
Signature · 1 line
2.34.1
Jakub Kicinski
maintainerQuoted 4 lines · On Tue, 14 Oct 2025 14:26:49 -0700 Haiyang Zhang wrote:
From: Haiyang Zhang <[email protected]>
Handle the HW link state events received from HW channel, and set the proper link state, also stop/wake queues accordingly.
Why do you have to stop / start the queues? I think it's unusual. Let the packets get dropped, sending out potentially old packets when link comes back is not going to make anyone happier.
Quoted 17 lines
drivers/net/ethernet/microsoft/mana/mana_en.c +15
-0+static void mana_link_state_handle (struct work_struct *w) +{ +struct mana_port_context *apc; +struct mana_context *ac; +struct net_device *ndev; +bool link_up; +int i; + + ac = container_of(w, struct mana_context, link_change_work); + +if (ac->mana_removing) +return ; + +rtnl_lock (); +
drivers/net/ethernet/microsoft/mana/mana_en.c void mana_remove(struct gdma_dev *gd, bool suspending) · line 3561
Quoted 6 lines
drivers/net/ethernet/microsoft/mana/mana_en.c +3
-0@@ -3500,6 +3556,10 @@ void mana_remove(struct gdma_dev *gd, bool suspending)int err;int i; + ac->mana_removing = true; + +cancel_work_sync (&ac->link_change_work);
Looks racy, the work needs @ac to check the ->mana_removing but mana_remove() frees @ac. Just use disable_work_sync() please.
Signature · 1 line
pw-bot: cr
Haiyang Zhang
maintainerQuoted 22 lines
-----Original Message-----
From: Jakub Kicinski <[email protected]>
Sent: Friday, October 17, 2025 7:06 PM
To: Haiyang Zhang <[email protected]>
Cc: [email protected]; [email protected]; 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: [PATCH net-next,v2] net: mana: Support HW link state eventsOn Tue, 14 Oct 2025 14:26:49 -0700 Haiyang Zhang wrote:
Quoted 8 lines
Quoted 4 lines
From: Haiyang Zhang <[email protected]>
Handle the HW link state events received from HW channel, and set the proper link state, also stop/wake queues accordingly.
Why do you have to stop / start the queues? I think it's unusual. Let the packets get dropped, sending out potentially old packets when link comes back is not going to make anyone happier.
Will do.
Quoted 22 lines
drivers/net/ethernet/microsoft/mana/mana_en.c void mana_remove(struct gdma_dev *gd, bool
Quoted 18 lines
drivers/net/ethernet/microsoft/mana/mana_en.c +15
-0+static void mana_link_state_handle (struct work_struct *w) +{ +struct mana_port_context *apc; +struct mana_context *ac; +struct net_device *ndev; +bool link_up; +int i; + + ac = container_of(w, struct mana_context, link_change_work); + +if (ac->mana_removing) +return ; + +rtnl_lock (); +@@ -3500,6 +3556,10 @@ void mana_remove(struct gdma_dev *gd, boolsuspending)
Quoted 3 lines
drivers/net/ethernet/microsoft/mana/mana_en.c +0
-0int err;int i;
Quoted 6 lines
drivers/net/ethernet/microsoft/mana/mana_en.c void mana_remove(struct gdma_dev *gd, bool suspending) · line 3561
Quoted 3 lines
drivers/net/ethernet/microsoft/mana/mana_en.c +3
-0+ ac->mana_removing = true; + +cancel_work_sync (&ac->link_change_work);Looks racy, the work needs @ac to check the ->mana_removing but
mana_remove()frees @ac. Just usedisable_work_sync()please.
Good idea. Will update the patch.
Thanks,
- Haiyang