From: Oleksandr Kolomeiets <okl-plv@napatech.com>
Add high-level interfaces for the initialization of the flow filter.
Signed-off-by: Oleksandr Kolomeiets <okl-plv@napatech.com>
---
v2
* Update release notes
v3
* Remove new line characters from logs
---
doc/guides/rel_notes/release_24_11.rst | 1 +
drivers/net/ntnic/adapter/nt4ga_adapter.c | 18 ++++++++++++++++++
drivers/net/ntnic/include/flow_api.h | 12 ++++++++++++
drivers/net/ntnic/include/nt4ga_adapter.h | 6 ++++++
drivers/net/ntnic/include/nt4ga_filter.h | 13 +++++++++++++
drivers/net/ntnic/ntnic_mod_reg.c | 7 +++++++
drivers/net/ntnic/ntnic_mod_reg.h | 8 ++++++++
7 files changed, 65 insertions(+)
create mode 100644 drivers/net/ntnic/include/flow_api.h
create mode 100644 drivers/net/ntnic/include/nt4ga_filter.h
@@ -104,6 +104,7 @@ New Features
* Fix Coverity issues
* Fix issues related to release 24.07
* Extended and fixed the implementation of the logging
+ * Added NT flow filter init API
Removed Items
-------------
@@ -75,6 +75,11 @@ static int nt4ga_adapter_show_info(struct adapter_info_s *p_adapter_info, FILE *
static int nt4ga_adapter_init(struct adapter_info_s *p_adapter_info)
{
+ const struct flow_filter_ops *flow_filter_ops = get_flow_filter_ops();
+
+ if (flow_filter_ops == NULL)
+ NT_LOG(ERR, NTNIC, "%s: flow_filter module uninitialized", __func__);
+
char *const p_dev_name = malloc(24);
char *const p_adapter_id_str = malloc(24);
fpga_info_t *fpga_info = &p_adapter_info->fpga_info;
@@ -155,6 +160,19 @@ static int nt4ga_adapter_init(struct adapter_info_s *p_adapter_info)
n_nim_ports = fpga_info->n_nims;
assert(n_nim_ports >= 1);
+ /* Nt4ga Init Filter */
+ nt4ga_filter_t *p_filter = &p_adapter_info->nt4ga_filter;
+
+ if (flow_filter_ops != NULL) {
+ res = flow_filter_ops->flow_filter_init(p_fpga, &p_filter->mp_flow_device,
+ p_adapter_info->adapter_no);
+
+ if (res != 0) {
+ NT_LOG(ERR, NTNIC, "%s: Cannot initialize filter", p_adapter_id_str);
+ return res;
+ }
+ }
+
{
int i;
const struct link_ops_s *link_ops = NULL;
new file mode 100644
@@ -0,0 +1,12 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#ifndef _FLOW_API_H_
+#define _FLOW_API_H_
+
+/* registered NIC backends */
+struct flow_nic_dev;
+
+#endif
@@ -23,7 +23,13 @@ typedef struct hw_info_s {
int hw_reserved1;
} hw_info_t;
+/*
+ * Services provided by the adapter module
+ */
+#include "nt4ga_filter.h"
+
typedef struct adapter_info_s {
+ struct nt4ga_filter_s nt4ga_filter;
struct nt4ga_link_s nt4ga_link;
struct hw_info_s hw_info;
new file mode 100644
@@ -0,0 +1,13 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#ifndef NT4GA_FILTER_H_
+#define NT4GA_FILTER_H_
+
+typedef struct nt4ga_filter_s {
+ struct flow_nic_dev *mp_flow_device;
+} nt4ga_filter_t;
+
+#endif /* NT4GA_FILTER_H_ */
@@ -88,3 +88,10 @@ struct rst9563_ops *get_rst9563_ops(void)
rst9563_ops_init();
return rst9563_ops;
}
+
+static const struct flow_filter_ops *flow_filter_ops;
+
+const struct flow_filter_ops *get_flow_filter_ops(void)
+{
+ return flow_filter_ops;
+}
@@ -7,6 +7,7 @@
#define __NTNIC_MOD_REG_H__
#include <stdint.h>
+#include "flow_api.h"
#include "nthw_fpga_model.h"
#include "nthw_platform_drv.h"
#include "nthw_drv.h"
@@ -117,4 +118,11 @@ void register_rst9563_ops(struct rst9563_ops *ops);
struct rst9563_ops *get_rst9563_ops(void);
void rst9563_ops_init(void);
+struct flow_filter_ops {
+ int (*flow_filter_init)(nthw_fpga_t *p_fpga, struct flow_nic_dev **p_flow_device,
+ int adapter_no);
+};
+
+const struct flow_filter_ops *get_flow_filter_ops(void);
+
#endif /* __NTNIC_MOD_REG_H__ */