[v3,09/50] net/ntnic: add flow backend deinitialization API

Message ID 20241010141416.4063591-10-sil-plv@napatech.com (mailing list archive)
State Accepted
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. 10, 2024, 2:13 p.m. UTC
From: Oleksandr Kolomeiets <okl-plv@napatech.com>

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

Signed-off-by: Oleksandr Kolomeiets <okl-plv@napatech.com>
---
v3
* Remove newline characters from logs.
---
 drivers/net/ntnic/include/flow_api.h          |  7 ++++++-
 drivers/net/ntnic/include/flow_filter.h       |  1 +
 drivers/net/ntnic/include/hw_mod_backend.h    | 13 ++++++++++++
 drivers/net/ntnic/nthw/flow_api/flow_api.c    | 12 +++++++++++
 .../ntnic/nthw/flow_api/flow_api_nic_setup.h  | 14 +++++++++++++
 drivers/net/ntnic/nthw/flow_api/flow_filter.c | 21 +++++++++++++++++++
 drivers/net/ntnic/ntnic_mod_reg.h             |  1 +
 7 files changed, 68 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/ntnic/include/hw_mod_backend.h
 create mode 100644 drivers/net/ntnic/nthw/flow_api/flow_api_nic_setup.h
  

Patch

diff --git a/drivers/net/ntnic/include/flow_api.h b/drivers/net/ntnic/include/flow_api.h
index 112bcabdb5..6a2277c2ca 100644
--- a/drivers/net/ntnic/include/flow_api.h
+++ b/drivers/net/ntnic/include/flow_api.h
@@ -8,7 +8,12 @@ 
 
 #include "ntlog.h"
 
+#include "hw_mod_backend.h"
+
 /* registered NIC backends */
-struct flow_nic_dev;
+struct flow_nic_dev {
+	/* NIC backend API */
+	struct flow_api_backend_s be;
+};
 
 #endif
diff --git a/drivers/net/ntnic/include/flow_filter.h b/drivers/net/ntnic/include/flow_filter.h
index 01cfce03d7..d204c0d882 100644
--- a/drivers/net/ntnic/include/flow_filter.h
+++ b/drivers/net/ntnic/include/flow_filter.h
@@ -10,5 +10,6 @@ 
 #include "nthw_fpga_model.h"
 
 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);
 
 #endif  /* __FLOW_FILTER_HPP__ */
diff --git a/drivers/net/ntnic/include/hw_mod_backend.h b/drivers/net/ntnic/include/hw_mod_backend.h
new file mode 100644
index 0000000000..46054a6a85
--- /dev/null
+++ b/drivers/net/ntnic/include/hw_mod_backend.h
@@ -0,0 +1,13 @@ 
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#ifndef _HW_MOD_BACKEND_H_
+#define _HW_MOD_BACKEND_H_
+
+struct flow_api_backend_s {
+	void *be_dev;
+};
+
+#endif  /* _HW_MOD_BACKEND_H_ */
diff --git a/drivers/net/ntnic/nthw/flow_api/flow_api.c b/drivers/net/ntnic/nthw/flow_api/flow_api.c
index b4866d4bdf..78dede2f39 100644
--- a/drivers/net/ntnic/nthw/flow_api/flow_api.c
+++ b/drivers/net/ntnic/nthw/flow_api/flow_api.c
@@ -3,12 +3,24 @@ 
  * Copyright(c) 2023 Napatech A/S
  */
 
+#include "flow_api_nic_setup.h"
 #include "ntnic_mod_reg.h"
 
 #include "flow_filter.h"
 
+void *flow_api_get_be_dev(struct flow_nic_dev *ndev)
+{
+	if (!ndev) {
+		NT_LOG(DBG, FILTER, "ERR: %s", __func__);
+		return NULL;
+	}
+
+	return ndev->be.be_dev;
+}
+
 static const struct flow_filter_ops ops = {
 	.flow_filter_init = flow_filter_init,
+	.flow_filter_done = flow_filter_done,
 };
 
 void init_flow_filter(void)
diff --git a/drivers/net/ntnic/nthw/flow_api/flow_api_nic_setup.h b/drivers/net/ntnic/nthw/flow_api/flow_api_nic_setup.h
new file mode 100644
index 0000000000..da083f050a
--- /dev/null
+++ b/drivers/net/ntnic/nthw/flow_api/flow_api_nic_setup.h
@@ -0,0 +1,14 @@ 
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#ifndef __FLOW_API_NIC_SETUP_H__
+#define __FLOW_API_NIC_SETUP_H__
+
+#include "hw_mod_backend.h"
+#include "flow_api.h"
+
+void *flow_api_get_be_dev(struct flow_nic_dev *dev);
+
+#endif  /* __FLOW_API_NIC_SETUP_H__ */
diff --git a/drivers/net/ntnic/nthw/flow_api/flow_filter.c b/drivers/net/ntnic/nthw/flow_api/flow_filter.c
index 63e217ba13..3bec51051b 100644
--- a/drivers/net/ntnic/nthw/flow_api/flow_filter.c
+++ b/drivers/net/ntnic/nthw/flow_api/flow_filter.c
@@ -5,6 +5,7 @@ 
 
 #include "flow_filter.h"
 #include "ntnic_mod_reg.h"
+#include "flow_api_nic_setup.h"
 
 int flow_filter_init(nthw_fpga_t *p_fpga, struct flow_nic_dev **p_flow_device, int adapter_no)
 {
@@ -25,3 +26,23 @@  int flow_filter_init(nthw_fpga_t *p_fpga, struct flow_nic_dev **p_flow_device, i
 
 	return 0;
 }
+
+int flow_filter_done(struct flow_nic_dev *dev)
+{
+	void *be_dev = flow_api_get_be_dev(dev);
+
+	int res = 0;
+
+	if (be_dev) {
+		const struct flow_backend_ops *flow_backend_ops = get_flow_backend_ops();
+
+		if (flow_backend_ops == NULL) {
+			NT_LOG(WRN, FILTER, "%s: flow_backend module uninitialized", __func__);
+			return res;
+		}
+
+		flow_backend_ops->bin_flow_backend_done(be_dev);
+	}
+
+	return res;
+}
diff --git a/drivers/net/ntnic/ntnic_mod_reg.h b/drivers/net/ntnic/ntnic_mod_reg.h
index 3251f651be..90d9c73f9f 100644
--- a/drivers/net/ntnic/ntnic_mod_reg.h
+++ b/drivers/net/ntnic/ntnic_mod_reg.h
@@ -121,6 +121,7 @@  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);
+	void (*bin_flow_backend_done)(void *be_dev);
 };
 
 const struct flow_backend_ops *get_flow_backend_ops(void);