Skip to content

Commit aca14ca

Browse files
author
Maxim Levitsky
committed
net: mana: Add handler for hardware servicing events
JIRA: https://issues.redhat.com/browse/RHEL-109583 commit 7768c5f Author: Haiyang Zhang <haiyangz@microsoft.com> Date: Fri Jun 13 10:00:34 2025 -0700 net: mana: Add handler for hardware servicing events To collaborate with hardware servicing events, upon receiving the special EQE notification from the HW channel, remove the devices on this bus. Then, after a waiting period based on the device specs, rescan the parent bus to recover the devices. Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com> Reviewed-by: Shradha Gupta <shradhagupta@linux.microsoft.com> Reviewed-by: Simon Horman <horms@kernel.org> Link: https://patch.msgid.link/1749834034-18498-1-git-send-email-haiyangz@linux.microsoft.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
1 parent c5de957 commit aca14ca

File tree

2 files changed

+83
-2
lines changed

2 files changed

+83
-2
lines changed

drivers/net/ethernet/microsoft/mana/gdma_main.c

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,11 +357,59 @@ void mana_gd_ring_cq(struct gdma_queue *cq, u8 arm_bit)
357357
}
358358
EXPORT_SYMBOL_NS(mana_gd_ring_cq, NET_MANA);
359359

360+
#define MANA_SERVICE_PERIOD 10
361+
362+
struct mana_serv_work {
363+
struct work_struct serv_work;
364+
struct pci_dev *pdev;
365+
};
366+
367+
static void mana_serv_func(struct work_struct *w)
368+
{
369+
struct mana_serv_work *mns_wk;
370+
struct pci_bus *bus, *parent;
371+
struct pci_dev *pdev;
372+
373+
mns_wk = container_of(w, struct mana_serv_work, serv_work);
374+
pdev = mns_wk->pdev;
375+
376+
pci_lock_rescan_remove();
377+
378+
if (!pdev)
379+
goto out;
380+
381+
bus = pdev->bus;
382+
if (!bus) {
383+
dev_err(&pdev->dev, "MANA service: no bus\n");
384+
goto out;
385+
}
386+
387+
parent = bus->parent;
388+
if (!parent) {
389+
dev_err(&pdev->dev, "MANA service: no parent bus\n");
390+
goto out;
391+
}
392+
393+
pci_stop_and_remove_bus_device(bus->self);
394+
395+
msleep(MANA_SERVICE_PERIOD * 1000);
396+
397+
pci_rescan_bus(parent);
398+
399+
out:
400+
pci_unlock_rescan_remove();
401+
402+
pci_dev_put(pdev);
403+
kfree(mns_wk);
404+
module_put(THIS_MODULE);
405+
}
406+
360407
static void mana_gd_process_eqe(struct gdma_queue *eq)
361408
{
362409
u32 head = eq->head % (eq->queue_size / GDMA_EQE_SIZE);
363410
struct gdma_context *gc = eq->gdma_dev->gdma_context;
364411
struct gdma_eqe *eq_eqe_ptr = eq->queue_mem_ptr;
412+
struct mana_serv_work *mns_wk;
365413
union gdma_eqe_info eqe_info;
366414
enum gdma_eqe_type type;
367415
struct gdma_event event;
@@ -406,6 +454,33 @@ static void mana_gd_process_eqe(struct gdma_queue *eq)
406454
eq->eq.callback(eq->eq.context, eq, &event);
407455
break;
408456

457+
case GDMA_EQE_HWC_FPGA_RECONFIG:
458+
dev_info(gc->dev, "Recv MANA service type:%d\n", type);
459+
460+
if (gc->in_service) {
461+
dev_info(gc->dev, "Already in service\n");
462+
break;
463+
}
464+
465+
if (!try_module_get(THIS_MODULE)) {
466+
dev_info(gc->dev, "Module is unloading\n");
467+
break;
468+
}
469+
470+
mns_wk = kzalloc(sizeof(*mns_wk), GFP_ATOMIC);
471+
if (!mns_wk) {
472+
module_put(THIS_MODULE);
473+
break;
474+
}
475+
476+
dev_info(gc->dev, "Start MANA service type:%d\n", type);
477+
gc->in_service = true;
478+
mns_wk->pdev = to_pci_dev(gc->dev);
479+
pci_dev_get(mns_wk->pdev);
480+
INIT_WORK(&mns_wk->serv_work, mana_serv_func);
481+
schedule_work(&mns_wk->serv_work);
482+
break;
483+
409484
default:
410485
break;
411486
}

include/net/mana/gdma.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ enum gdma_eqe_type {
5858
GDMA_EQE_HWC_INIT_EQ_ID_DB = 129,
5959
GDMA_EQE_HWC_INIT_DATA = 130,
6060
GDMA_EQE_HWC_INIT_DONE = 131,
61-
GDMA_EQE_HWC_SOC_RECONFIG = 132,
61+
GDMA_EQE_HWC_FPGA_RECONFIG = 132,
6262
GDMA_EQE_HWC_SOC_RECONFIG_DATA = 133,
6363
GDMA_EQE_HWC_SOC_SERVICE = 134,
6464
GDMA_EQE_RNIC_QP_FATAL = 176,
@@ -403,6 +403,8 @@ struct gdma_context {
403403
u32 test_event_eq_id;
404404

405405
bool is_pf;
406+
bool in_service;
407+
406408
phys_addr_t bar0_pa;
407409
void __iomem *bar0_va;
408410
void __iomem *shm_base;
@@ -578,12 +580,16 @@ enum {
578580
/* Driver can handle holes (zeros) in the device list */
579581
#define GDMA_DRV_CAP_FLAG_1_DEV_LIST_HOLES_SUP BIT(11)
580582

583+
/* Driver can self reset on FPGA Reconfig EQE notification */
584+
#define GDMA_DRV_CAP_FLAG_1_HANDLE_RECONFIG_EQE BIT(17)
585+
581586
#define GDMA_DRV_CAP_FLAGS1 \
582587
(GDMA_DRV_CAP_FLAG_1_EQ_SHARING_MULTI_VPORT | \
583588
GDMA_DRV_CAP_FLAG_1_NAPI_WKDONE_FIX | \
584589
GDMA_DRV_CAP_FLAG_1_HWC_TIMEOUT_RECONFIG | \
585590
GDMA_DRV_CAP_FLAG_1_VARIABLE_INDIRECTION_TABLE_SUPPORT | \
586-
GDMA_DRV_CAP_FLAG_1_DEV_LIST_HOLES_SUP)
591+
GDMA_DRV_CAP_FLAG_1_DEV_LIST_HOLES_SUP | \
592+
GDMA_DRV_CAP_FLAG_1_HANDLE_RECONFIG_EQE)
587593

588594
#define GDMA_DRV_CAP_FLAGS2 0
589595

0 commit comments

Comments
 (0)