net/mlx5: fix sample flow action on trusted device
authorJiawei Wang <jiaweiw@nvidia.com>
Wed, 9 Mar 2022 10:19:46 +0000 (12:19 +0200)
committerRaslan Darawsheh <rasland@nvidia.com>
Wed, 9 Mar 2022 12:31:06 +0000 (13:31 +0100)
A flow rule with sample action will be split into two sub flows,
and a tag action was added implicitly in the sample prefix sub flow,
the reserved metadata regC index was used for this tag action.

The reserved metadata regC was shared with metering action,
for ConnectX-5 trusted device (VF/SF), the reserved metadata regC was
invalid since PF only supported the legacy metering.

This patch adds the checking for the tag index and back to use the
application tag if a failure happened.

Fixes: a9b6ea45bed6 ("net/mlx5: fix tag ID conflict with sample action")
Cc: stable@dpdk.org
Signed-off-by: Jiawei Wang <jiaweiw@nvidia.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
doc/guides/nics/mlx5.rst
drivers/net/mlx5/mlx5_flow.c
drivers/net/mlx5/mlx5_flow_dv.c

index a734d10..ca7ebbe 100644 (file)
@@ -400,6 +400,8 @@ Limitations
     sample actions list.
   - For E-Switch mirroring flow, supports ``RAW ENCAP``, ``Port ID``,
     ``VXLAN ENCAP``, ``NVGRE ENCAP`` in the sample actions list.
+  - For ConnectX-5 trusted device, the application metadata with SET_TAG index 0
+    is not supported before ``RTE_FLOW_ACTION_TYPE_SAMPLE`` action.
 
 - Modify Field flow:
 
index ffcaef0..e2bc6ce 100644 (file)
@@ -5881,6 +5881,12 @@ flow_sample_split_prep(struct rte_eth_dev *dev,
                append_index++;
                set_tag = (void *)(actions_pre + actions_n + append_index);
                ret = mlx5_flow_get_reg_id(dev, MLX5_SAMPLE_ID, 0, error);
+               /* Trust VF/SF on CX5 not supported meter so that the reserved
+                * metadata regC is REG_NON, back to use application tag
+                * index 0.
+                */
+               if (unlikely(ret == REG_NON))
+                       ret = mlx5_flow_get_reg_id(dev, MLX5_APP_TAG, 0, error);
                if (ret < 0)
                        return ret;
                mlx5_ipool_malloc(priv->sh->ipool
index 1746ef3..d553e9d 100644 (file)
@@ -6913,6 +6913,7 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
        bool def_policy = false;
        bool shared_count = false;
        uint16_t udp_dport = 0;
+       uint32_t tag_id = 0;
 
        if (items == NULL)
                return -1;
@@ -7389,6 +7390,8 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
                                ++actions_n;
                        if (action_flags & MLX5_FLOW_ACTION_SAMPLE)
                                modify_after_mirror = 1;
+                       tag_id = ((const struct rte_flow_action_set_tag *)
+                                 actions->conf)->index;
                        action_flags |= MLX5_FLOW_ACTION_SET_TAG;
                        rw_act_num += MLX5_ACT_NUM_SET_TAG;
                        break;
@@ -7823,6 +7826,11 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
                                                             error);
                        if (ret < 0)
                                return ret;
+                       if ((action_flags & MLX5_FLOW_ACTION_SET_TAG) &&
+                           tag_id == 0 && priv->mtr_color_reg == REG_NON)
+                               return rte_flow_error_set(error, EINVAL,
+                                       RTE_FLOW_ERROR_TYPE_ACTION, NULL,
+                                       "sample after tag action causes metadata tag index 0 corruption");
                        action_flags |= MLX5_FLOW_ACTION_SAMPLE;
                        ++actions_n;
                        break;