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 <getel...@nvidia.com> Acked-by: Dariusz Sosnowski <dsosnow...@nvidia.com> --- drivers/net/mlx5/mlx5_flow.h | 21 +++++++++++++++++ drivers/net/mlx5/mlx5_flow_hw.c | 41 ++++++++++++++++----------------- 2 files changed, 41 insertions(+), 21 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index 9816ed9238..23c5833290 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -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_ */ diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c index a8a3f3872a..a7162d5859 100644 --- a/drivers/net/mlx5/mlx5_flow_hw.c +++ b/drivers/net/mlx5/mlx5_flow_hw.c @@ -327,18 +327,6 @@ get_mlx5dr_table_type(const struct rte_flow_attr *attr, uint32_t specialize, /* Non template default queue size used for inner ctrl queue. */ #define MLX5_NT_DEFAULT_QUEUE_SIZE 32 -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]; -}; - static int flow_hw_flush_all_ctrl_flows(struct rte_eth_dev *dev); static int flow_hw_translate_group(struct rte_eth_dev *dev, const struct mlx5_flow_template_table_cfg *cfg, @@ -14589,11 +14577,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 +14644,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) -- 2.48.1