[PATCH v3 1/6] net/mlx5: update NTA rule pattern and actions flags
Maayan Kashani
mkashani at nvidia.com
Mon Jun 3 12:52:36 CEST 2024
From: Gregory Etelson <getelson at nvidia.com>
Move pattern flags bitmap to flow_hw_list_create.
Create actions flags bitmap in flow_hw_list_create.
PMD uses pattern and actions bitmaps for direct queries instead of
iterating arrays.
Signed-off-by: Gregory Etelson <getelson at nvidia.com>
---
drivers/net/mlx5/mlx5_flow_hw.c | 147 +++++++++++++++++++++++++++-----
1 file changed, 126 insertions(+), 21 deletions(-)
diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c
index d938b5976a..696f675f63 100644
--- a/drivers/net/mlx5/mlx5_flow_hw.c
+++ b/drivers/net/mlx5/mlx5_flow_hw.c
@@ -568,6 +568,111 @@ flow_hw_matching_item_flags_get(const struct rte_flow_item items[])
return item_flags;
}
+static uint64_t
+flow_hw_action_flags_get(const struct rte_flow_action actions[],
+ struct rte_flow_error *error)
+{
+ uint64_t action_flags = 0;
+ const struct rte_flow_action *action;
+
+ for (action = actions; action->type != RTE_FLOW_ACTION_TYPE_END; action++) {
+ int type = (int)action->type;
+ switch (type) {
+ case RTE_FLOW_ACTION_TYPE_INDIRECT:
+ switch (MLX5_INDIRECT_ACTION_TYPE_GET(action->conf)) {
+ case MLX5_INDIRECT_ACTION_TYPE_RSS:
+ goto rss;
+ case MLX5_INDIRECT_ACTION_TYPE_AGE:
+ goto age;
+ case MLX5_INDIRECT_ACTION_TYPE_COUNT:
+ goto count;
+ case MLX5_INDIRECT_ACTION_TYPE_CT:
+ goto ct;
+ case MLX5_INDIRECT_ACTION_TYPE_METER_MARK:
+ goto meter;
+ default:
+ goto error;
+ }
+ break;
+ case RTE_FLOW_ACTION_TYPE_DROP:
+ action_flags |= MLX5_FLOW_ACTION_DROP;
+ break;
+ case RTE_FLOW_ACTION_TYPE_MARK:
+ action_flags |= MLX5_FLOW_ACTION_MARK;
+ break;
+ case RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN:
+ action_flags |= MLX5_FLOW_ACTION_OF_PUSH_VLAN;
+ break;
+ case RTE_FLOW_ACTION_TYPE_OF_POP_VLAN:
+ action_flags |= MLX5_FLOW_ACTION_OF_POP_VLAN;
+ break;
+ case RTE_FLOW_ACTION_TYPE_JUMP:
+ action_flags |= MLX5_FLOW_ACTION_JUMP;
+ break;
+ case RTE_FLOW_ACTION_TYPE_QUEUE:
+ action_flags |= MLX5_FLOW_ACTION_QUEUE;
+ break;
+ case RTE_FLOW_ACTION_TYPE_RSS:
+rss:
+ action_flags |= MLX5_FLOW_ACTION_RSS;
+ break;
+ case RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP:
+ case RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP:
+ action_flags |= MLX5_FLOW_ACTION_ENCAP;
+ break;
+ case RTE_FLOW_ACTION_TYPE_RAW_ENCAP:
+ action_flags |= MLX5_FLOW_ACTION_ENCAP;
+ break;
+ case RTE_FLOW_ACTION_TYPE_VXLAN_DECAP:
+ case RTE_FLOW_ACTION_TYPE_NVGRE_DECAP:
+ action_flags |= MLX5_FLOW_ACTION_DECAP;
+ break;
+ case RTE_FLOW_ACTION_TYPE_RAW_DECAP:
+ action_flags |= MLX5_FLOW_ACTION_DECAP;
+ break;
+ case RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL:
+ action_flags |= MLX5_FLOW_ACTION_SEND_TO_KERNEL;
+ break;
+ case RTE_FLOW_ACTION_TYPE_MODIFY_FIELD:
+ action_flags |= MLX5_FLOW_ACTION_MODIFY_FIELD;
+ break;
+ case RTE_FLOW_ACTION_TYPE_PORT_ID:
+ case RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT:
+ action_flags |= MLX5_FLOW_ACTION_PORT_ID;
+ break;
+ case RTE_FLOW_ACTION_TYPE_AGE:
+age:
+ action_flags |= MLX5_FLOW_ACTION_AGE;
+ break;
+ case RTE_FLOW_ACTION_TYPE_COUNT:
+count:
+ action_flags |= MLX5_FLOW_ACTION_COUNT;
+ break;
+ case RTE_FLOW_ACTION_TYPE_CONNTRACK:
+ct:
+ action_flags |= MLX5_FLOW_ACTION_CT;
+ break;
+ case RTE_FLOW_ACTION_TYPE_METER_MARK:
+meter:
+ action_flags |= MLX5_FLOW_ACTION_METER;
+ break;
+ case MLX5_RTE_FLOW_ACTION_TYPE_DEFAULT_MISS:
+ action_flags |= MLX5_FLOW_ACTION_DEFAULT_MISS;
+ break;
+ case RTE_FLOW_ACTION_TYPE_VOID:
+ case RTE_FLOW_ACTION_TYPE_END:
+ break;
+ default:
+ goto error;
+ }
+ }
+ return action_flags;
+error:
+ rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION,
+ action, "invalid flow action");
+ return 0;
+}
+
/**
* Register destination table DR jump action.
*
@@ -12339,21 +12444,20 @@ flow_hw_encap_decap_resource_register
static int
flow_hw_translate_flow_actions(struct rte_eth_dev *dev,
- const struct rte_flow_attr *attr,
- const struct rte_flow_action actions[],
- struct rte_flow_hw *flow,
- struct mlx5_flow_hw_action_params *ap,
- struct mlx5_hw_actions *hw_acts,
- uint64_t item_flags,
- bool external,
- struct rte_flow_error *error)
+ const struct rte_flow_attr *attr,
+ const struct rte_flow_action actions[],
+ struct rte_flow_hw *flow,
+ struct mlx5_flow_hw_action_params *ap,
+ struct mlx5_hw_actions *hw_acts,
+ uint64_t item_flags, uint64_t action_flags,
+ bool external,
+ struct rte_flow_error *error)
{
int ret = 0;
uint32_t src_group = 0;
enum mlx5dr_table_type table_type;
struct rte_flow_template_table *table = NULL;
struct mlx5_flow_group grp;
- uint64_t action_flags = 0;
struct rte_flow_actions_template *at = NULL;
struct rte_flow_actions_template_attr template_attr = {
.egress = attr->egress,
@@ -12631,14 +12735,13 @@ static int flow_hw_apply(struct rte_eth_dev *dev __rte_unused,
* @return
* 0 on success, negative errno value otherwise and rte_errno set.
*/
-static int flow_hw_create_flow(struct rte_eth_dev *dev,
- enum mlx5_flow_type type,
- const struct rte_flow_attr *attr,
- const struct rte_flow_item items[],
- const struct rte_flow_action actions[],
- bool external,
- struct rte_flow_hw **flow,
- struct rte_flow_error *error)
+static int
+flow_hw_create_flow(struct rte_eth_dev *dev, enum mlx5_flow_type type,
+ const struct rte_flow_attr *attr,
+ const struct rte_flow_item items[],
+ const struct rte_flow_action actions[],
+ uint64_t item_flags, uint64_t action_flags, bool external,
+ struct rte_flow_hw **flow, struct rte_flow_error *error)
{
int ret;
struct mlx5_hw_actions hw_act;
@@ -12668,8 +12771,6 @@ static int flow_hw_create_flow(struct rte_eth_dev *dev,
.tbl_type = 0,
};
- uint64_t item_flags = 0;
-
memset(&hw_act, 0, sizeof(hw_act));
if (attr->transfer)
tbl_type = MLX5DR_TABLE_TYPE_FDB;
@@ -12710,7 +12811,7 @@ static int flow_hw_create_flow(struct rte_eth_dev *dev,
/* Note: the actions should be saved in the sub-flow rule itself for reference. */
ret = flow_hw_translate_flow_actions(dev, attr, actions, *flow, &ap, &hw_act,
- item_flags, external, error);
+ item_flags, action_flags, external, error);
if (ret)
goto error;
@@ -12848,11 +12949,15 @@ static uintptr_t flow_hw_list_create(struct rte_eth_dev *dev,
{
int ret;
struct rte_flow_hw *flow = NULL;
+ uint64_t item_flags = flow_hw_matching_item_flags_get(items);
+ uint64_t action_flags = flow_hw_action_flags_get(actions, error);
/*TODO: Handle split/expand to num_flows. */
/* Create single flow. */
- ret = flow_hw_create_flow(dev, type, attr, items, actions, external, &flow, error);
+ ret = flow_hw_create_flow(dev, type, attr, items, actions,
+ item_flags, action_flags,
+ external, &flow, error);
if (ret)
goto free;
if (flow)
--
2.25.1
More information about the dev
mailing list