net: mana: Support HW link state events
Subsystems (5)
PATCH v4 1/1 net: mana: Support HW link state events
From: Haiyang Zhang <[email protected]>
Handle the NIC hardware link state events received from the HW channel, then set the proper link state accordingly.
And, add a feature bit, GDMA_DRV_CAP_FLAG_1_HW_VPORT_LINK_AWARE, to inform the NIC hardware this handler exists.
Our MANA NIC only sends out the link state down/up messages when we need to let the VM rerun DHCP client and change IP address. So, add netif_carrier_on() in the probe(), let the NIC show the right initial state in /sys/class/net/ethX/operstate.
---
v4:
Remove the netif_carrier_ok(), and add READ/WRITE_ONCE. Also, more details in the commit message as suggested by Jakub Kicinski.
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 | 54 +++++++++++++++++-- include/net/mana/gdma.h | 4 +- include/net/mana/hw_channel.h | 2 + include/net/mana/mana.h | 4 ++ 6 files changed, 71 insertions(+), 6 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 +12 -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,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 ; + +WRITE_ONCE (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 +49 -5
108 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 +4 -0
@@ -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
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 9 lines · On Wed, 29 Oct 2025 13:43:10 -0700 you wrote:
From: Haiyang Zhang <[email protected]>
Handle the NIC hardware link state events received from the HW channel, then set the proper link state accordingly.
And, add a feature bit,
GDMA_DRV_CAP_FLAG_1_HW_VPORT_LINK_AWARE, to inform the NIC hardware this handler exists.[...]
Here is the summary with links:
- [net-next,v4] net: mana: Support HW link state events
https://git.kernel.org/netdev/net-next/c/54133f9b4b53
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html