common/cnxk: add roc npa init callback support

Message ID 20211028212046.2452092-1-vfialko@marvell.com (mailing list archive)
State Rejected, archived
Headers
Series common/cnxk: add roc npa init callback support |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS

Commit Message

Volodymyr Fialko Oct. 28, 2021, 9:20 p.m. UTC
  Add support for registering callback for roc npa init

Signed-off-by: Volodymyr Fialko <vfialko@marvell.com>
Reviewed-by: Jerin Jacob <jerinj@marvell.com>
---
Depends-on: series-20004 ("mempool/cnxk: fix max pools argument parsing")
 drivers/common/cnxk/roc_npa.c   | 18 ++++++++++++++++++
 drivers/common/cnxk/roc_npa.h   |  4 ++++
 drivers/common/cnxk/version.map |  1 +
 3 files changed, 23 insertions(+)
  

Patch

diff --git a/drivers/common/cnxk/roc_npa.c b/drivers/common/cnxk/roc_npa.c
index cb32ee177f..eb24057bc6 100644
--- a/drivers/common/cnxk/roc_npa.c
+++ b/drivers/common/cnxk/roc_npa.c
@@ -5,6 +5,18 @@ 
 #include "roc_api.h"
 #include "roc_priv.h"
 
+static roc_npa_lf_init_cb_t lf_init_cb;
+
+int
+roc_npa_lf_init_cb_register(roc_npa_lf_init_cb_t cb)
+{
+	if (lf_init_cb != NULL)
+		return -EEXIST;
+
+	lf_init_cb = cb;
+	return 0;
+}
+
 void
 roc_npa_aura_op_range_set(uint64_t aura_handle, uint64_t start_iova,
 			  uint64_t end_iova)
@@ -695,6 +707,12 @@  npa_lf_init(struct dev *dev, struct plt_pci_device *pci_dev)
 	if (__atomic_fetch_add(&idev->npa_refcnt, 1, __ATOMIC_SEQ_CST) != 0)
 		return 0;
 
+	if (lf_init_cb) {
+		rc = (*lf_init_cb)(pci_dev);
+		if (rc)
+			goto fail;
+	}
+
 	rc = npa_attach(dev->mbox);
 	if (rc)
 		goto fail;
diff --git a/drivers/common/cnxk/roc_npa.h b/drivers/common/cnxk/roc_npa.h
index 1cf50e5c4e..46350fdb48 100644
--- a/drivers/common/cnxk/roc_npa.h
+++ b/drivers/common/cnxk/roc_npa.h
@@ -648,6 +648,10 @@  void __roc_api roc_npa_aura_op_range_set(uint64_t aura_handle,
 					 uint64_t start_iova,
 					 uint64_t end_iova);
 
+/* Init callbacks */
+typedef int (*roc_npa_lf_init_cb_t)(struct plt_pci_device *pci_dev);
+int __roc_api roc_npa_lf_init_cb_register(roc_npa_lf_init_cb_t cb);
+
 /* Debug */
 int __roc_api roc_npa_ctx_dump(void);
 int __roc_api roc_npa_dump(void);
diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map
index d1ab342ba7..7348e772cb 100644
--- a/drivers/common/cnxk/version.map
+++ b/drivers/common/cnxk/version.map
@@ -287,6 +287,7 @@  INTERNAL {
 	roc_npa_dev_fini;
 	roc_npa_dev_init;
 	roc_npa_dump;
+	roc_npa_lf_init_cb_register;
 	roc_npa_pool_create;
 	roc_npa_pool_destroy;
 	roc_npa_pool_op_pc_reset;