[27/28] raw/cnxk_bphy: add support for registering irq handlers

Message ID 20210531214142.30167-28-tduszynski@marvell.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series add support for baseband phy |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Tomasz Duszynski May 31, 2021, 9:41 p.m. UTC
  Custom irq handlers may be registered/removed on demand.
This adds support for doing that. Since registration
and removal are related they are in the same patch.

Signed-off-by: Jakub Palider <jpalider@marvell.com>
Signed-off-by: Tomasz Duszynski <tduszynski@marvell.com>
---
 drivers/raw/cnxk_bphy/cnxk_bphy.c     | 14 ++++++++++++
 drivers/raw/cnxk_bphy/cnxk_bphy_irq.c | 33 +++++++++++++++++++++++++++
 drivers/raw/cnxk_bphy/cnxk_bphy_irq.h | 12 ++++++++--
 drivers/raw/cnxk_bphy/rte_pmd_bphy.h  |  6 +++++
 drivers/raw/cnxk_bphy/version.map     |  4 ++++
 5 files changed, 67 insertions(+), 2 deletions(-)
  

Patch

diff --git a/drivers/raw/cnxk_bphy/cnxk_bphy.c b/drivers/raw/cnxk_bphy/cnxk_bphy.c
index c3aed3018..a6bbdd986 100644
--- a/drivers/raw/cnxk_bphy/cnxk_bphy.c
+++ b/drivers/raw/cnxk_bphy/cnxk_bphy.c
@@ -40,6 +40,20 @@  rte_pmd_bphy_intr_mem_get(uint16_t dev_id)
 	return cnxk_bphy_mem_get(dev_id);
 }
 
+int
+rte_pmd_bphy_intr_register(uint16_t dev_id, int irq_num,
+			    cnxk_bphy_intr_handler_t handler, void *data,
+			    int cpu)
+{
+	return cnxk_bphy_intr_register(dev_id, irq_num, handler, data, cpu);
+}
+
+void
+rte_pmd_bphy_intr_unregister(uint16_t dev_id, int irq_num)
+{
+	cnxk_bphy_intr_unregister(dev_id, irq_num);
+}
+
 static const struct rte_rawdev_ops bphy_rawdev_ops = {
 };
 
diff --git a/drivers/raw/cnxk_bphy/cnxk_bphy_irq.c b/drivers/raw/cnxk_bphy/cnxk_bphy_irq.c
index 5a7698f23..45aada7bf 100644
--- a/drivers/raw/cnxk_bphy/cnxk_bphy_irq.c
+++ b/drivers/raw/cnxk_bphy/cnxk_bphy_irq.c
@@ -58,6 +58,39 @@  cnxk_bphy_intr_fini(uint16_t dev_id)
 	bphy_dev->irq_chip = NULL;
 }
 
+int
+cnxk_bphy_intr_register(uint16_t dev_id, int irq_num,
+			cnxk_bphy_intr_handler_t handler, void *data, int cpu)
+{
+	struct roc_bphy_intr intr = {
+		.irq_num = irq_num,
+		.intr_handler = handler,
+		.isr_data = data,
+		.cpu = cpu
+	};
+
+	struct bphy_device *bphy_dev = cnxk_bphy_get_bphy_dev_by_dev_id(dev_id);
+	struct roc_bphy_irq_chip *irq_chip = bphy_dev->irq_chip;
+
+	if (!irq_chip)
+		return -ENODEV;
+	if (!handler || !data)
+		return -EINVAL;
+
+	return roc_bphy_intr_register(irq_chip, &intr);
+}
+
+void
+cnxk_bphy_intr_unregister(uint16_t dev_id, int irq_num)
+{
+	struct bphy_device *bphy_dev = cnxk_bphy_get_bphy_dev_by_dev_id(dev_id);
+
+	if (bphy_dev->irq_chip)
+		roc_bphy_handler_clear(bphy_dev->irq_chip, irq_num);
+	else
+		plt_err("Missing irq chip");
+}
+
 struct bphy_mem *
 cnxk_bphy_mem_get(uint16_t dev_id)
 {
diff --git a/drivers/raw/cnxk_bphy/cnxk_bphy_irq.h b/drivers/raw/cnxk_bphy/cnxk_bphy_irq.h
index e52106bc8..6eeb567ed 100644
--- a/drivers/raw/cnxk_bphy/cnxk_bphy_irq.h
+++ b/drivers/raw/cnxk_bphy/cnxk_bphy_irq.h
@@ -10,6 +10,8 @@ 
 
 #include <roc_api.h>
 
+typedef void (*cnxk_bphy_intr_handler_t)(int irq_num, void *isr_data);
+
 struct bphy_mem {
 	struct rte_mem_resource res0;
 	struct rte_mem_resource res2;
@@ -25,8 +27,14 @@  int cnxk_bphy_intr_init(uint16_t dev_id);
 __rte_internal
 void cnxk_bphy_intr_fini(uint16_t dev_id);
 __rte_internal
-uint64_t cnxk_bphy_irq_max_get(uint16_t dev_id);
-__rte_internal
 struct bphy_mem *cnxk_bphy_mem_get(uint16_t dev_id);
+__rte_internal
+int cnxk_bphy_intr_register(uint16_t dev_id, int irq_num,
+			    cnxk_bphy_intr_handler_t handler, void *isr_data,
+			    int cpu);
+__rte_internal
+void cnxk_bphy_intr_unregister(uint16_t dev_id, int irq_num);
+__rte_internal
+uint64_t cnxk_bphy_irq_max_get(uint16_t dev_id);
 
 #endif /* _CNXK_BPHY_IRQ_ */
diff --git a/drivers/raw/cnxk_bphy/rte_pmd_bphy.h b/drivers/raw/cnxk_bphy/rte_pmd_bphy.h
index 783b63471..d77bb3b23 100644
--- a/drivers/raw/cnxk_bphy/rte_pmd_bphy.h
+++ b/drivers/raw/cnxk_bphy/rte_pmd_bphy.h
@@ -110,6 +110,12 @@  int rte_pmd_bphy_intr_init(uint16_t dev_id);
 __rte_experimental
 struct cnxk_bphy_mem *rte_pmd_bphy_intr_mem_get(uint16_t dev_id);
 __rte_experimental
+int rte_pmd_bphy_intr_register(uint16_t dev_id, int irq_num,
+			       cnxk_bphy_intr_handler_t handler, void *isr_data,
+			       int cpu);
+__rte_experimental
 void rte_pmd_bphy_intr_fini(uint16_t dev_id);
+__rte_experimental
+void rte_pmd_bphy_intr_unregister(uint16_t dev_id, int irq_num);
 
 #endif /* _CNXK_BPHY_H_ */
diff --git a/drivers/raw/cnxk_bphy/version.map b/drivers/raw/cnxk_bphy/version.map
index c7600a863..c4f9b20d0 100644
--- a/drivers/raw/cnxk_bphy/version.map
+++ b/drivers/raw/cnxk_bphy/version.map
@@ -6,6 +6,8 @@  INTERNAL {
 
 	cnxk_bphy_intr_init;
 	cnxk_bphy_intr_fini;
+	cnxk_bphy_intr_register;
+	cnxk_bphy_intr_unregister;
 	cnxk_bphy_irq_max_get;
 	cnxk_bphy_mem_get;
 };
@@ -15,4 +17,6 @@  EXPERIMENTAL {
 	rte_pmd_bphy_intr_fini;
 	rte_pmd_bphy_intr_init;
 	rte_pmd_bphy_intr_mem_get;
+	rte_pmd_bphy_intr_register;
+	rte_pmd_bphy_intr_unregister;
 };