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
@@ -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
@@ -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__ */
new file mode 100644
@@ -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_ */
@@ -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)
new file mode 100644
@@ -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__ */
@@ -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;
+}
@@ -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);