Skip to content

Commit d24c282

Browse files
emuslndavem330
authored andcommitted
pds_core: publish events to the clients
When the Core device gets an event from the device, or notices the device FW to be up or down, it needs to send those events on to the clients that have an event handler. Add the code to pass along the events to the clients. The entry points pdsc_register_notify() and pdsc_unregister_notify() are EXPORTed for other drivers that want to listen for these events. Signed-off-by: Shannon Nelson <shannon.nelson@amd.com> Acked-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 1065903 commit d24c282

4 files changed

Lines changed: 39 additions & 0 deletions

File tree

drivers/net/ethernet/amd/pds_core/adminq.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,13 @@ static int pdsc_process_notifyq(struct pdsc_qcq *qcq)
2929
case PDS_EVENT_LINK_CHANGE:
3030
dev_info(pdsc->dev, "NotifyQ LINK_CHANGE ecode %d eid %lld\n",
3131
ecode, eid);
32+
pdsc_notify(PDS_EVENT_LINK_CHANGE, comp);
3233
break;
3334

3435
case PDS_EVENT_RESET:
3536
dev_info(pdsc->dev, "NotifyQ RESET ecode %d eid %lld\n",
3637
ecode, eid);
38+
pdsc_notify(PDS_EVENT_RESET, comp);
3739
break;
3840

3941
case PDS_EVENT_XCVR:

drivers/net/ethernet/amd/pds_core/core.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,25 @@
66

77
#include "core.h"
88

9+
static BLOCKING_NOTIFIER_HEAD(pds_notify_chain);
10+
11+
int pdsc_register_notify(struct notifier_block *nb)
12+
{
13+
return blocking_notifier_chain_register(&pds_notify_chain, nb);
14+
}
15+
EXPORT_SYMBOL_GPL(pdsc_register_notify);
16+
17+
void pdsc_unregister_notify(struct notifier_block *nb)
18+
{
19+
blocking_notifier_chain_unregister(&pds_notify_chain, nb);
20+
}
21+
EXPORT_SYMBOL_GPL(pdsc_unregister_notify);
22+
23+
void pdsc_notify(unsigned long event, void *data)
24+
{
25+
blocking_notifier_call_chain(&pds_notify_chain, event, data);
26+
}
27+
928
void pdsc_intr_free(struct pdsc *pdsc, int index)
1029
{
1130
struct pdsc_intr_info *intr_info;
@@ -494,19 +513,30 @@ void pdsc_stop(struct pdsc *pdsc)
494513

495514
static void pdsc_fw_down(struct pdsc *pdsc)
496515
{
516+
union pds_core_notifyq_comp reset_event = {
517+
.reset.ecode = cpu_to_le16(PDS_EVENT_RESET),
518+
.reset.state = 0,
519+
};
520+
497521
if (test_and_set_bit(PDSC_S_FW_DEAD, &pdsc->state)) {
498522
dev_err(pdsc->dev, "%s: already happening\n", __func__);
499523
return;
500524
}
501525

526+
/* Notify clients of fw_down */
502527
devlink_health_report(pdsc->fw_reporter, "FW down reported", pdsc);
528+
pdsc_notify(PDS_EVENT_RESET, &reset_event);
503529

504530
pdsc_stop(pdsc);
505531
pdsc_teardown(pdsc, PDSC_TEARDOWN_RECOVERY);
506532
}
507533

508534
static void pdsc_fw_up(struct pdsc *pdsc)
509535
{
536+
union pds_core_notifyq_comp reset_event = {
537+
.reset.ecode = cpu_to_le16(PDS_EVENT_RESET),
538+
.reset.state = 1,
539+
};
510540
int err;
511541

512542
if (!test_bit(PDSC_S_FW_DEAD, &pdsc->state)) {
@@ -522,9 +552,11 @@ static void pdsc_fw_up(struct pdsc *pdsc)
522552
if (err)
523553
goto err_out;
524554

555+
/* Notify clients of fw_up */
525556
pdsc->fw_recoveries++;
526557
devlink_health_reporter_state_update(pdsc->fw_reporter,
527558
DEVLINK_HEALTH_REPORTER_STATE_HEALTHY);
559+
pdsc_notify(PDS_EVENT_RESET, &reset_event);
528560

529561
return;
530562

drivers/net/ethernet/amd/pds_core/core.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,9 @@ int pdsc_start(struct pdsc *pdsc);
297297
void pdsc_stop(struct pdsc *pdsc);
298298
void pdsc_health_thread(struct work_struct *work);
299299

300+
int pdsc_register_notify(struct notifier_block *nb);
301+
void pdsc_unregister_notify(struct notifier_block *nb);
302+
void pdsc_notify(unsigned long event, void *data);
300303
int pdsc_auxbus_dev_add(struct pdsc *cf, struct pdsc *pf);
301304
int pdsc_auxbus_dev_del(struct pdsc *cf, struct pdsc *pf);
302305

include/linux/pds/pds_common.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ enum pds_core_logical_qtype {
6060
PDS_CORE_QTYPE_MAX = 16 /* don't change - used in struct size */
6161
};
6262

63+
int pdsc_register_notify(struct notifier_block *nb);
64+
void pdsc_unregister_notify(struct notifier_block *nb);
6365
void *pdsc_get_pf_struct(struct pci_dev *vf_pdev);
6466
int pds_client_register(struct pci_dev *pf_pdev, char *devname);
6567
int pds_client_unregister(struct pci_dev *pf_pdev, u16 client_id);

0 commit comments

Comments
 (0)