From 3af6451292d7471fc0e5d8fcfb31bc9cbf11f17d Mon Sep 17 00:00:00 2001 From: Ivan Malov Date: Tue, 20 Oct 2020 10:12:45 +0100 Subject: [PATCH] drivers: init/fini MAE on attach/detach These actions affect MAE supplementary resources which are libefx-internal. Signed-off-by: Ivan Malov Signed-off-by: Andrew Rybchenko Reviewed-by: Andy Moreton --- drivers/common/sfc_efx/efsys.h | 2 +- drivers/net/sfc/sfc_mae.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/common/sfc_efx/efsys.h b/drivers/common/sfc_efx/efsys.h index 8636e73b68..bbe9f2ef12 100644 --- a/drivers/common/sfc_efx/efsys.h +++ b/drivers/common/sfc_efx/efsys.h @@ -167,7 +167,7 @@ prefetch_read_once(const volatile void *addr) #define EFSYS_OPT_DESC_PROXY 0 -#define EFSYS_OPT_MAE 0 +#define EFSYS_OPT_MAE 1 /* ID */ diff --git a/drivers/net/sfc/sfc_mae.c b/drivers/net/sfc/sfc_mae.c index 3ce654c19b..2a7ed6377a 100644 --- a/drivers/net/sfc/sfc_mae.c +++ b/drivers/net/sfc/sfc_mae.c @@ -21,6 +21,7 @@ sfc_mae_attach(struct sfc_adapter *sa) { const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic); struct sfc_mae *mae = &sa->mae; + int rc; sfc_log_init(sa, "entry"); @@ -29,21 +30,37 @@ sfc_mae_attach(struct sfc_adapter *sa) return 0; } + sfc_log_init(sa, "init MAE"); + rc = efx_mae_init(sa->nic); + if (rc != 0) + goto fail_mae_init; + mae->status = SFC_MAE_STATUS_SUPPORTED; sfc_log_init(sa, "done"); return 0; + +fail_mae_init: + sfc_log_init(sa, "failed %d", rc); + + return rc; } void sfc_mae_detach(struct sfc_adapter *sa) { struct sfc_mae *mae = &sa->mae; + enum sfc_mae_status status_prev = mae->status; sfc_log_init(sa, "entry"); mae->status = SFC_MAE_STATUS_UNKNOWN; + if (status_prev != SFC_MAE_STATUS_SUPPORTED) + return; + + efx_mae_fini(sa->nic); + sfc_log_init(sa, "done"); } -- 2.20.1