diff mbox series

[v5,04/52] common/cnxk: add roc plt init callback support

Message ID 20210406144144.19925-5-ndabilpuram@marvell.com (mailing list archive)
State Accepted
Delegated to: Jerin Jacob
Headers show
Series Add Marvell CNXK common driver | expand

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Nithin Dabilpuram April 6, 2021, 2:40 p.m. UTC
From: Ashwin Sekhar T K <asekhar@marvell.com>

Add support for registering callbacks for roc plt init.

Signed-off-by: Ashwin Sekhar T K <asekhar@marvell.com>
---
 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 mbox series

Patch

diff --git a/drivers/common/cnxk/roc_platform.c b/drivers/common/cnxk/roc_platform.c
index 5baec95..0aed76b 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 1d06435..2987713 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 1798b48..984feb3 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: *;
 };