[v1,08/50] net/ntnic: add flow backend initialization API

Message ID 20241006203728.330792-9-sil-plv@napatech.com (mailing list archive)
State Superseded
Delegated to: Ferruh Yigit
Headers
Series Provide: flow filter init API, Enable virtual queues, fix ntnic issues for release 24.07 |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Serhii Iliushyk Oct. 6, 2024, 8:36 p.m. UTC
From: Oleksandr Kolomeiets <okl-plv@napatech.com>

Add high-level interfaces for the initialization of the backend.

Signed-off-by: Oleksandr Kolomeiets <okl-plv@napatech.com>
---
 drivers/net/ntnic/include/flow_api.h          |  2 ++
 drivers/net/ntnic/include/flow_filter.h       | 14 ++++++++++
 drivers/net/ntnic/meson.build                 |  2 ++
 drivers/net/ntnic/nthw/flow_api/flow_api.c    | 17 ++++++++++++
 drivers/net/ntnic/nthw/flow_api/flow_filter.c | 27 +++++++++++++++++++
 drivers/net/ntnic/ntnic_mod_reg.c             | 15 +++++++++++
 drivers/net/ntnic/ntnic_mod_reg.h             |  9 +++++++
 7 files changed, 86 insertions(+)
 create mode 100644 drivers/net/ntnic/include/flow_filter.h
 create mode 100644 drivers/net/ntnic/nthw/flow_api/flow_api.c
 create mode 100644 drivers/net/ntnic/nthw/flow_api/flow_filter.c
  

Patch

diff --git a/drivers/net/ntnic/include/flow_api.h b/drivers/net/ntnic/include/flow_api.h
index 036e652b76..112bcabdb5 100644
--- a/drivers/net/ntnic/include/flow_api.h
+++ b/drivers/net/ntnic/include/flow_api.h
@@ -6,6 +6,8 @@ 
 #ifndef _FLOW_API_H_
 #define _FLOW_API_H_
 
+#include "ntlog.h"
+
 /* registered NIC backends */
 struct flow_nic_dev;
 
diff --git a/drivers/net/ntnic/include/flow_filter.h b/drivers/net/ntnic/include/flow_filter.h
new file mode 100644
index 0000000000..01cfce03d7
--- /dev/null
+++ b/drivers/net/ntnic/include/flow_filter.h
@@ -0,0 +1,14 @@ 
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#ifndef __FLOW_FILTER_HPP__
+#define __FLOW_FILTER_HPP__
+
+#include "flow_api.h"
+#include "nthw_fpga_model.h"
+
+int flow_filter_init(nthw_fpga_t *p_fpga, struct flow_nic_dev **p_flow_device, int adapter_no);
+
+#endif  /* __FLOW_FILTER_HPP__ */
diff --git a/drivers/net/ntnic/meson.build b/drivers/net/ntnic/meson.build
index e9f2110b8f..00b1ae4c70 100644
--- a/drivers/net/ntnic/meson.build
+++ b/drivers/net/ntnic/meson.build
@@ -42,6 +42,8 @@  sources = files(
         'nthw/core/nthw_pcie3.c',
         'nthw/core/nthw_sdc.c',
         'nthw/core/nthw_si5340.c',
+        'nthw/flow_api/flow_api.c',
+        'nthw/flow_api/flow_filter.c',
         'nthw/model/nthw_fpga_model.c',
         'nthw/nthw_platform.c',
         'nthw/nthw_rac.c',
diff --git a/drivers/net/ntnic/nthw/flow_api/flow_api.c b/drivers/net/ntnic/nthw/flow_api/flow_api.c
new file mode 100644
index 0000000000..b4866d4bdf
--- /dev/null
+++ b/drivers/net/ntnic/nthw/flow_api/flow_api.c
@@ -0,0 +1,17 @@ 
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#include "ntnic_mod_reg.h"
+
+#include "flow_filter.h"
+
+static const struct flow_filter_ops ops = {
+	.flow_filter_init = flow_filter_init,
+};
+
+void init_flow_filter(void)
+{
+	register_flow_filter_ops(&ops);
+}
diff --git a/drivers/net/ntnic/nthw/flow_api/flow_filter.c b/drivers/net/ntnic/nthw/flow_api/flow_filter.c
new file mode 100644
index 0000000000..7b6e122190
--- /dev/null
+++ b/drivers/net/ntnic/nthw/flow_api/flow_filter.c
@@ -0,0 +1,27 @@ 
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#include "flow_filter.h"
+#include "ntnic_mod_reg.h"
+
+int flow_filter_init(nthw_fpga_t *p_fpga, struct flow_nic_dev **p_flow_device, int adapter_no)
+{
+	(void)p_flow_device;
+	(void)adapter_no;
+
+	void *be_dev = NULL;
+
+	const struct flow_backend_ops *flow_backend_ops = get_flow_backend_ops();
+
+	if (flow_backend_ops == NULL) {
+		NT_LOG(ERR, FILTER, "%s: flow_backend module uninitialized\n", __func__);
+		return -1;
+	}
+
+	NT_LOG(DBG, FILTER, "Initializing flow filter api\n");
+	flow_backend_ops->bin_flow_backend_init(p_fpga, &be_dev);
+
+	return 0;
+}
diff --git a/drivers/net/ntnic/ntnic_mod_reg.c b/drivers/net/ntnic/ntnic_mod_reg.c
index 45cc767c90..2094e1fbb9 100644
--- a/drivers/net/ntnic/ntnic_mod_reg.c
+++ b/drivers/net/ntnic/ntnic_mod_reg.c
@@ -89,9 +89,24 @@  struct rst9563_ops *get_rst9563_ops(void)
 	return rst9563_ops;
 }
 
+static const struct flow_backend_ops *flow_backend_ops;
+
+const struct flow_backend_ops *get_flow_backend_ops(void)
+{
+	return flow_backend_ops;
+}
+
 static const struct flow_filter_ops *flow_filter_ops;
 
+void register_flow_filter_ops(const struct flow_filter_ops *ops)
+{
+	flow_filter_ops = ops;
+}
+
 const struct flow_filter_ops *get_flow_filter_ops(void)
 {
+	if (flow_filter_ops == NULL)
+		init_flow_filter();
+
 	return flow_filter_ops;
 }
diff --git a/drivers/net/ntnic/ntnic_mod_reg.h b/drivers/net/ntnic/ntnic_mod_reg.h
index fd9e595f50..3251f651be 100644
--- a/drivers/net/ntnic/ntnic_mod_reg.h
+++ b/drivers/net/ntnic/ntnic_mod_reg.h
@@ -118,12 +118,21 @@  void register_rst9563_ops(struct rst9563_ops *ops);
 struct rst9563_ops *get_rst9563_ops(void);
 void rst9563_ops_init(void);
 
+struct flow_backend_ops {
+	const struct flow_api_backend_ops *(*bin_flow_backend_init)(nthw_fpga_t *p_fpga,
+		void **be_dev);
+};
+
+const struct flow_backend_ops *get_flow_backend_ops(void);
+
 struct flow_filter_ops {
 	int (*flow_filter_init)(nthw_fpga_t *p_fpga, struct flow_nic_dev **p_flow_device,
 		int adapter_no);
 	int (*flow_filter_done)(struct flow_nic_dev *dev);
 };
 
+void register_flow_filter_ops(const struct flow_filter_ops *ops);
 const struct flow_filter_ops *get_flow_filter_ops(void);
+void init_flow_filter(void);
 
 #endif	/* __NTNIC_MOD_REG_H__ */