@@ -74,6 +74,21 @@ struct flow_nic_dev {
struct flow_nic_dev *next;
};
+enum flow_nic_err_msg_e {
+ ERR_SUCCESS = 0,
+ ERR_FAILED = 1,
+ ERR_OUTPUT_TOO_MANY = 3,
+ ERR_MATCH_INVALID_OR_UNSUPPORTED_ELEM = 12,
+ ERR_MATCH_RESOURCE_EXHAUSTION = 14,
+ ERR_ACTION_UNSUPPORTED = 28,
+ ERR_REMOVE_FLOW_FAILED = 29,
+ ERR_OUTPUT_INVALID = 33,
+ ERR_ACTION_MULTIPLE_PORT_ID_UNSUPPORTED = 40,
+ ERR_MSG_NO_MSG
+};
+
+void flow_nic_set_error(enum flow_nic_err_msg_e msg, struct rte_flow_error *error);
+
/*
* Resources
*/
@@ -47,6 +47,7 @@ sources = files(
'nthw/core/nthw_sdc.c',
'nthw/core/nthw_si5340.c',
'nthw/flow_api/flow_api.c',
+ 'nthw/flow_api/profile_inline/flow_api_profile_inline.c',
'nthw/flow_api/flow_backend/flow_backend.c',
'nthw/flow_api/flow_filter.c',
'nthw/flow_api/flow_kcc.c',
@@ -36,6 +36,29 @@ const char *dbg_res_descr[] = {
static struct flow_nic_dev *dev_base;
static pthread_mutex_t base_mtx = PTHREAD_MUTEX_INITIALIZER;
+/*
+ * Error handling
+ */
+
+static const struct {
+ const char *message;
+} err_msg[] = {
+ /* 00 */ { "Operation successfully completed" },
+ /* 01 */ { "Operation failed" },
+ /* 29 */ { "Removing flow failed" },
+};
+
+void flow_nic_set_error(enum flow_nic_err_msg_e msg, struct rte_flow_error *error)
+{
+ assert(msg < ERR_MSG_NO_MSG);
+
+ if (error) {
+ error->message = err_msg[msg].message;
+ error->type = (msg == ERR_SUCCESS) ? RTE_FLOW_ERROR_TYPE_NONE :
+ RTE_FLOW_ERROR_TYPE_UNSPECIFIED;
+ }
+}
+
/*
* Resources
*/
@@ -136,7 +159,8 @@ static struct flow_handle *flow_create(struct flow_eth_dev *dev __rte_unused,
return NULL;
}
- return NULL;
+ return profile_inline_ops->flow_create_profile_inline(dev, attr,
+ forced_vlan_vid, caller_id, item, action, error);
}
static int flow_destroy(struct flow_eth_dev *dev __rte_unused,
@@ -149,7 +173,7 @@ static int flow_destroy(struct flow_eth_dev *dev __rte_unused,
return -1;
}
- return -1;
+ return profile_inline_ops->flow_destroy_profile_inline(dev, flow, error);
}
/*
new file mode 100644
@@ -0,0 +1,65 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#include "ntlog.h"
+
+#include "flow_api_profile_inline.h"
+#include "ntnic_mod_reg.h"
+
+struct flow_handle *flow_create_profile_inline(struct flow_eth_dev *dev __rte_unused,
+ const struct rte_flow_attr *attr __rte_unused,
+ uint16_t forced_vlan_vid __rte_unused,
+ uint16_t caller_id __rte_unused,
+ const struct rte_flow_item elem[] __rte_unused,
+ const struct rte_flow_action action[] __rte_unused,
+ struct rte_flow_error *error __rte_unused)
+{
+ return NULL;
+}
+
+int flow_destroy_locked_profile_inline(struct flow_eth_dev *dev,
+ struct flow_handle *fh,
+ struct rte_flow_error *error)
+{
+ assert(dev);
+ assert(fh);
+
+ int err = 0;
+
+ flow_nic_set_error(ERR_SUCCESS, error);
+
+ return err;
+}
+
+int flow_destroy_profile_inline(struct flow_eth_dev *dev, struct flow_handle *flow,
+ struct rte_flow_error *error)
+{
+ int err = 0;
+
+ flow_nic_set_error(ERR_SUCCESS, error);
+
+ if (flow) {
+ /* Delete this flow */
+ pthread_mutex_lock(&dev->ndev->mtx);
+ err = flow_destroy_locked_profile_inline(dev, flow, error);
+ pthread_mutex_unlock(&dev->ndev->mtx);
+ }
+
+ return err;
+}
+
+static const struct profile_inline_ops ops = {
+ /*
+ * Flow functionality
+ */
+ .flow_destroy_locked_profile_inline = flow_destroy_locked_profile_inline,
+ .flow_create_profile_inline = flow_create_profile_inline,
+ .flow_destroy_profile_inline = flow_destroy_profile_inline,
+};
+
+void profile_inline_init(void)
+{
+ register_profile_inline_ops(&ops);
+}
new file mode 100644
@@ -0,0 +1,33 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#ifndef _FLOW_API_PROFILE_INLINE_H_
+#define _FLOW_API_PROFILE_INLINE_H_
+
+#include <stdint.h>
+
+#include "flow_api.h"
+#include "stream_binary_flow_api.h"
+
+/*
+ * Flow functionality
+ */
+int flow_destroy_locked_profile_inline(struct flow_eth_dev *dev,
+ struct flow_handle *fh,
+ struct rte_flow_error *error);
+
+struct flow_handle *flow_create_profile_inline(struct flow_eth_dev *dev,
+ const struct rte_flow_attr *attr,
+ uint16_t forced_vlan_vid,
+ uint16_t caller_id,
+ const struct rte_flow_item elem[],
+ const struct rte_flow_action action[],
+ struct rte_flow_error *error);
+
+int flow_destroy_profile_inline(struct flow_eth_dev *dev,
+ struct flow_handle *flow,
+ struct rte_flow_error *error);
+
+#endif /* _FLOW_API_PROFILE_INLINE_H_ */
@@ -118,9 +118,19 @@ const struct flow_backend_ops *get_flow_backend_ops(void)
return flow_backend_ops;
}
+static const struct profile_inline_ops *profile_inline_ops;
+
+void register_profile_inline_ops(const struct profile_inline_ops *ops)
+{
+ profile_inline_ops = ops;
+}
+
const struct profile_inline_ops *get_profile_inline_ops(void)
{
- return NULL;
+ if (profile_inline_ops == NULL)
+ profile_inline_init();
+
+ return profile_inline_ops;
}
static const struct flow_filter_ops *flow_filter_ops;
@@ -225,7 +225,30 @@ void register_flow_backend_ops(const struct flow_backend_ops *ops);
const struct flow_backend_ops *get_flow_backend_ops(void);
void flow_backend_init(void);
+struct profile_inline_ops {
+ /*
+ * Flow functionality
+ */
+ int (*flow_destroy_locked_profile_inline)(struct flow_eth_dev *dev,
+ struct flow_handle *fh,
+ struct rte_flow_error *error);
+
+ struct flow_handle *(*flow_create_profile_inline)(struct flow_eth_dev *dev,
+ const struct rte_flow_attr *attr,
+ uint16_t forced_vlan_vid,
+ uint16_t caller_id,
+ const struct rte_flow_item elem[],
+ const struct rte_flow_action action[],
+ struct rte_flow_error *error);
+
+ int (*flow_destroy_profile_inline)(struct flow_eth_dev *dev,
+ struct flow_handle *flow,
+ struct rte_flow_error *error);
+};
+
+void register_profile_inline_ops(const struct profile_inline_ops *ops);
const struct profile_inline_ops *get_profile_inline_ops(void);
+void profile_inline_init(void);
struct flow_filter_ops {
int (*flow_filter_init)(nthw_fpga_t *p_fpga, struct flow_nic_dev **p_flow_device,