From c92d8a70ae39dcb00e95092715f03adf80dd0e34 Mon Sep 17 00:00:00 2001 From: Ashwin Sekhar T K Date: Tue, 6 Apr 2021 20:10:56 +0530 Subject: [PATCH] common/cnxk: add roc plt init callback support Add support for registering callbacks for roc plt init. Signed-off-by: Ashwin Sekhar T K Acked-by: Nithin Dabilpuram --- drivers/common/cnxk/roc_platform.c | 22 ++++++++++++++++++++++ drivers/common/cnxk/roc_platform.h | 4 ++++ drivers/common/cnxk/version.map | 1 + 3 files changed, 27 insertions(+) diff --git a/drivers/common/cnxk/roc_platform.c b/drivers/common/cnxk/roc_platform.c index 5baec95bc1..0aed76bc0e 100644 --- a/drivers/common/cnxk/roc_platform.c +++ b/drivers/common/cnxk/roc_platform.c @@ -4,10 +4,26 @@ #include "roc_api.h" +#define PLT_INIT_CB_MAX 8 + +static int plt_init_cb_num; +static roc_plt_init_cb_t plt_init_cbs[PLT_INIT_CB_MAX]; + +int +roc_plt_init_cb_register(roc_plt_init_cb_t cb) +{ + if (plt_init_cb_num >= PLT_INIT_CB_MAX) + return -ERANGE; + + plt_init_cbs[plt_init_cb_num++] = cb; + return 0; +} + int roc_plt_init(void) { const struct rte_memzone *mz; + int i, rc; mz = rte_memzone_lookup(PLT_MODEL_MZ_NAME); if (rte_eal_process_type() == RTE_PROC_PRIMARY) { @@ -29,5 +45,11 @@ roc_plt_init(void) roc_model = mz->addr; } + for (i = 0; i < plt_init_cb_num; i++) { + rc = (*plt_init_cbs[i])(); + if (rc) + return rc; + } + return 0; } diff --git a/drivers/common/cnxk/roc_platform.h b/drivers/common/cnxk/roc_platform.h index 1d06435314..2987713e9c 100644 --- a/drivers/common/cnxk/roc_platform.h +++ b/drivers/common/cnxk/roc_platform.h @@ -161,4 +161,8 @@ __rte_internal int roc_plt_init(void); +/* Init callbacks */ +typedef int (*roc_plt_init_cb_t)(void); +int __roc_api roc_plt_init_cb_register(roc_plt_init_cb_t cb); + #endif /* _ROC_PLATFORM_H_ */ diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map index 1798b48545..984feb3072 100644 --- a/drivers/common/cnxk/version.map +++ b/drivers/common/cnxk/version.map @@ -4,6 +4,7 @@ INTERNAL { roc_error_msg_get; roc_model; roc_plt_init; + roc_plt_init_cb_register; local: *; }; -- 2.20.1