@@ -1801,7 +1801,7 @@ flow_hw_represented_port_compile(struct rte_eth_dev *dev,
18011801
18021802static __rte_always_inline int
18031803flow_hw_cnt_compile(struct rte_eth_dev *dev, uint32_t start_pos,
1804- struct mlx5_hw_actions *acts)
1804+ struct mlx5_hw_actions *acts, bool is_root )
18051805{
18061806 struct mlx5_priv *priv = dev->data->dev_private;
18071807 uint32_t pos = start_pos;
@@ -1815,7 +1815,8 @@ flow_hw_cnt_compile(struct rte_eth_dev *dev, uint32_t start_pos,
18151815 (priv->hws_cpool,
18161816 cnt_id,
18171817 &acts->rule_acts[pos].action,
1818- &acts->rule_acts[pos].counter.offset);
1818+ &acts->rule_acts[pos].counter.offset,
1819+ is_root);
18191820 if (ret != 0)
18201821 return ret;
18211822 acts->cnt_id = cnt_id;
@@ -2463,6 +2464,18 @@ mlx5_create_ipv6_ext_reformat(struct rte_eth_dev *dev,
24632464 return -EINVAL;
24642465}
24652466
2467+ static bool
2468+ is_indirect_action_type_supported_root(const enum rte_flow_action_type type)
2469+ {
2470+ switch (type) {
2471+ case RTE_FLOW_ACTION_TYPE_COUNT:
2472+ case RTE_FLOW_ACTION_TYPE_AGE:
2473+ return mlx5dr_action_counter_root_is_supported();
2474+ default:
2475+ return false;
2476+ }
2477+ }
2478+
24662479/**
24672480 * Translate rte_flow actions to DR action.
24682481 *
@@ -2547,8 +2560,9 @@ __flow_hw_translate_actions_template(struct rte_eth_dev *dev,
25472560 goto err;
25482561 break;
25492562 case RTE_FLOW_ACTION_TYPE_INDIRECT:
2550- if (is_root) {
2551- DRV_LOG(ERR, "Indirect action is not supported in root table.");
2563+ if (is_root && !is_indirect_action_type_supported_root(masks->type)) {
2564+ DRV_LOG(ERR, "Indirect action type (%d) is not supported on root.",
2565+ masks->type);
25522566 goto err;
25532567 }
25542568 if (actions->conf && masks->conf) {
@@ -2787,12 +2801,10 @@ __flow_hw_translate_actions_template(struct rte_eth_dev *dev,
27872801 goto err;
27882802 break;
27892803 case RTE_FLOW_ACTION_TYPE_AGE:
2790- if (is_root) {
2791- __flow_hw_action_template_destroy(dev, acts);
2804+ if (is_root && !mlx5dr_action_counter_root_is_supported()) {
27922805 rte_flow_error_set(&sub_error, ENOTSUP,
2793- RTE_FLOW_ERROR_TYPE_ACTION,
2794- NULL,
2795- "Age action on root table is not supported in HW steering mode");
2806+ RTE_FLOW_ERROR_TYPE_ACTION, NULL,
2807+ "Age action is not supported on group 0");
27962808 goto err;
27972809 }
27982810 if (__flow_hw_act_data_general_append(priv, acts,
@@ -2802,12 +2814,10 @@ __flow_hw_translate_actions_template(struct rte_eth_dev *dev,
28022814 goto err;
28032815 break;
28042816 case RTE_FLOW_ACTION_TYPE_COUNT:
2805- if (is_root) {
2806- __flow_hw_action_template_destroy(dev, acts);
2817+ if (is_root && !mlx5dr_action_counter_root_is_supported()) {
28072818 rte_flow_error_set(&sub_error, ENOTSUP,
2808- RTE_FLOW_ERROR_TYPE_ACTION,
2809- NULL,
2810- "Counter action on root table is not supported in HW steering mode");
2819+ RTE_FLOW_ERROR_TYPE_ACTION, NULL,
2820+ "Count action is not supported on root table");
28112821 goto err;
28122822 }
28132823 if ((at->action_flags & MLX5_FLOW_ACTION_AGE) ||
@@ -2821,7 +2831,7 @@ __flow_hw_translate_actions_template(struct rte_eth_dev *dev,
28212831 if (masks->conf &&
28222832 ((const struct rte_flow_action_count *)
28232833 masks->conf)->id) {
2824- err = flow_hw_cnt_compile(dev, dr_pos, acts);
2834+ err = flow_hw_cnt_compile(dev, dr_pos, acts, is_root );
28252835 if (err)
28262836 goto err;
28272837 } else if (__flow_hw_act_data_general_append
@@ -3163,7 +3173,7 @@ flow_hw_construct_quota(struct mlx5_priv *priv,
31633173static __rte_always_inline int
31643174flow_hw_shared_action_construct(struct rte_eth_dev *dev, uint32_t queue,
31653175 const struct rte_flow_action *action,
3166- struct rte_flow_template_table *table __rte_unused ,
3176+ struct rte_flow_template_table *table,
31673177 const uint64_t item_flags, uint64_t action_flags,
31683178 struct rte_flow_hw *flow,
31693179 struct mlx5dr_rule_action *rule_act)
@@ -3182,6 +3192,7 @@ flow_hw_shared_action_construct(struct rte_eth_dev *dev, uint32_t queue,
31823192 ((1u << MLX5_INDIRECT_ACTION_TYPE_OFFSET) - 1);
31833193 uint32_t *cnt_queue;
31843194 cnt_id_t age_cnt;
3195+ bool is_root = mlx5_group_id_is_root(table->grp->group_id);
31853196
31863197 memset(&act_data, 0, sizeof(act_data));
31873198 switch (type) {
@@ -3207,7 +3218,8 @@ flow_hw_shared_action_construct(struct rte_eth_dev *dev, uint32_t queue,
32073218 if (mlx5_hws_cnt_pool_get_action_offset(priv->hws_cpool,
32083219 act_idx,
32093220 &rule_act->action,
3210- &rule_act->counter.offset))
3221+ &rule_act->counter.offset,
3222+ is_root))
32113223 return -1;
32123224 flow->flags |= MLX5_FLOW_HW_FLOW_FLAG_CNT_ID;
32133225 flow->cnt_id = act_idx;
@@ -3248,7 +3260,7 @@ flow_hw_shared_action_construct(struct rte_eth_dev *dev, uint32_t queue,
32483260 }
32493261 if (mlx5_hws_cnt_pool_get_action_offset(priv->hws_cpool,
32503262 age_cnt, &rule_act->action,
3251- &rule_act->counter.offset))
3263+ &rule_act->counter.offset, is_root ))
32523264 return -1;
32533265 break;
32543266 case MLX5_INDIRECT_ACTION_TYPE_CT:
@@ -3482,6 +3494,7 @@ flow_hw_actions_construct(struct rte_eth_dev *dev,
34823494 struct mlx5_aso_mtr *aso_mtr;
34833495 struct mlx5_multi_pattern_segment *mp_segment = NULL;
34843496 struct rte_flow_hw_aux *aux;
3497+ bool is_root = mlx5_group_id_is_root(table->grp->group_id);
34853498
34863499 attr.group = table->grp->group_id;
34873500 ft_flag = mlx5_hw_act_flag[!!table->grp->group_id][table->type];
@@ -3679,7 +3692,8 @@ flow_hw_actions_construct(struct rte_eth_dev *dev,
36793692 (priv->hws_cpool,
36803693 cnt_id,
36813694 &rule_acts[act_data->action_dst].action,
3682- &rule_acts[act_data->action_dst].counter.offset
3695+ &rule_acts[act_data->action_dst].counter.offset,
3696+ is_root
36833697 );
36843698 if (ret != 0)
36853699 goto error;
@@ -3691,7 +3705,8 @@ flow_hw_actions_construct(struct rte_eth_dev *dev,
36913705 (priv->hws_cpool,
36923706 act_data->shared_counter.id,
36933707 &rule_acts[act_data->action_dst].action,
3694- &rule_acts[act_data->action_dst].counter.offset
3708+ &rule_acts[act_data->action_dst].counter.offset,
3709+ is_root
36953710 );
36963711 if (ret != 0)
36973712 goto error;
0 commit comments