[2/5] net/mlx5: add mlx5_hw_create_mirror function.
Checks
Commit Message
The new mlx5_hw_create_mirror() function separates existing HWS mirror
functionality into mirror action creation and indirect list
handle creation.
The new mirror creation function will be used in non-template SAMPLE
action implementation.
Signed-off-by: Gregory Etelson <getelson@nvidia.com>
---
drivers/net/mlx5/mlx5_flow.h | 21 +++++++++++++++++++++
drivers/net/mlx5/mlx5_flow_hw.c | 29 ++++++++++++++++++++---------
2 files changed, 41 insertions(+), 9 deletions(-)
@@ -201,6 +201,21 @@ enum mlx5_feature_name {
MLX5_SAMPLE_ID,
};
+#define MLX5_MIRROR_MAX_CLONES_NUM 3
+#define MLX5_MIRROR_MAX_SAMPLE_ACTIONS_LEN 4
+
+struct mlx5_mirror_clone {
+ enum rte_flow_action_type type;
+ void *action_ctx;
+};
+
+struct mlx5_mirror {
+ struct mlx5_indirect_list indirect;
+ uint32_t clones_num;
+ struct mlx5dr_action *mirror_action;
+ struct mlx5_mirror_clone clone[MLX5_MIRROR_MAX_CLONES_NUM];
+};
+
/* Default queue number. */
#define MLX5_RSSQ_DEFAULT_NUM 16
@@ -3722,5 +3737,11 @@ mlx5_flow_nta_update_copy_table(struct rte_eth_dev *dev,
struct mlx5_ecpri_parser_profile *flow_hw_get_ecpri_parser_profile(void *dr_ctx);
+struct mlx5_mirror *
+mlx5_hw_create_mirror(struct rte_eth_dev *dev,
+ const struct mlx5_flow_template_table_cfg *table_cfg,
+ const struct rte_flow_action *actions,
+ struct rte_flow_error *error);
+
#endif
#endif /* RTE_PMD_MLX5_FLOW_H_ */
@@ -14589,11 +14589,11 @@ hw_mirror_format_clone(struct rte_eth_dev *dev,
return 0;
}
-static struct rte_flow_action_list_handle *
-mlx5_hw_mirror_handle_create(struct rte_eth_dev *dev,
- const struct mlx5_flow_template_table_cfg *table_cfg,
- const struct rte_flow_action *actions,
- struct rte_flow_error *error)
+struct mlx5_mirror *
+mlx5_hw_create_mirror(struct rte_eth_dev *dev,
+ const struct mlx5_flow_template_table_cfg *table_cfg,
+ const struct rte_flow_action *actions,
+ struct rte_flow_error *error)
{
uint32_t hws_flags;
int ret = 0, i, clones_num;
@@ -14656,15 +14656,26 @@ mlx5_hw_mirror_handle_create(struct rte_eth_dev *dev,
actions, "Failed to create HWS mirror action");
goto error;
}
-
- mlx5_indirect_list_add_entry(&priv->indirect_list_head, &mirror->indirect);
- return (struct rte_flow_action_list_handle *)mirror;
-
+ return mirror;
error:
mlx5_hw_mirror_destroy(dev, mirror);
return NULL;
}
+static struct rte_flow_action_list_handle *
+mlx5_hw_mirror_handle_create(struct rte_eth_dev *dev,
+ const struct mlx5_flow_template_table_cfg *table_cfg,
+ const struct rte_flow_action *actions,
+ struct rte_flow_error *error)
+{
+ struct mlx5_priv *priv = dev->data->dev_private;
+ struct mlx5_mirror *mirror = mlx5_hw_create_mirror(dev, table_cfg, actions, error);
+
+ if (mirror)
+ mlx5_indirect_list_add_entry(&priv->indirect_list_head, &mirror->indirect);
+ return (struct rte_flow_action_list_handle *)mirror;
+}
+
void
mlx5_destroy_legacy_indirect(__rte_unused struct rte_eth_dev *dev,
struct mlx5_indirect_list *ptr)