diff mbox series

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

Message ID 20210406114131.25874-5-ndabilpuram@marvell.com (mailing list archive)
State Superseded
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, 11:40 a.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 | 19 +++++++++++++++++++
 drivers/common/cnxk/roc_platform.h |  4 ++++
 drivers/common/cnxk/version.map    |  1 +
 3 files changed, 24 insertions(+)

Comments

Jerin Jacob April 6, 2021, 12:17 p.m. UTC | #1
On Tue, Apr 6, 2021 at 5:12 PM Nithin Dabilpuram
<ndabilpuram@marvell.com> wrote:
>
> 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 | 19 +++++++++++++++++++
>  drivers/common/cnxk/roc_platform.h |  4 ++++
>  drivers/common/cnxk/version.map    |  1 +
>  3 files changed, 24 insertions(+)
>
> diff --git a/drivers/common/cnxk/roc_platform.c b/drivers/common/cnxk/roc_platform.c
> index 5baec95..3eba1a7 100644
> --- a/drivers/common/cnxk/roc_platform.c
> +++ b/drivers/common/cnxk/roc_platform.c
> @@ -4,10 +4,23 @@
>
>  #include "roc_api.h"
>
> +#define ROC_PLT_INIT_CB_MAX 8

Since it local to this file. Please change to PLT_INIT_CB_MAX

> +
> +static int plt_init_cb_num;
> +static roc_plt_init_cb_t plt_init_cbs[ROC_PLT_INIT_CB_MAX];
> +
> +void
> +roc_plt_init_cb_register(roc_plt_init_cb_t cb)
> +{
> +       RTE_ASSERT(plt_init_cb_num < ROC_PLT_INIT_CB_MAX);

RTE_ASSERT not allowed in the library, please return the "-ERANGE" or
so for this function in case of error.

the caller can put some error print on failure as it is called from
the constructor.

Rest of the series looks good.
diff mbox series

Patch

diff --git a/drivers/common/cnxk/roc_platform.c b/drivers/common/cnxk/roc_platform.c
index 5baec95..3eba1a7 100644
--- a/drivers/common/cnxk/roc_platform.c
+++ b/drivers/common/cnxk/roc_platform.c
@@ -4,10 +4,23 @@ 
 
 #include "roc_api.h"
 
+#define ROC_PLT_INIT_CB_MAX 8
+
+static int plt_init_cb_num;
+static roc_plt_init_cb_t plt_init_cbs[ROC_PLT_INIT_CB_MAX];
+
+void
+roc_plt_init_cb_register(roc_plt_init_cb_t cb)
+{
+	RTE_ASSERT(plt_init_cb_num < ROC_PLT_INIT_CB_MAX);
+	plt_init_cbs[plt_init_cb_num++] = cb;
+}
+
 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 +42,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..b358efe 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);
+void __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: *;
 };