pipeline: add check against loops
[dpdk.git] / drivers / net / mlx5 / mlx5_flow_dv.c
index 8022d7d..ef9c66e 100644 (file)
@@ -93,20 +93,6 @@ static int
 flow_dv_jump_tbl_resource_release(struct rte_eth_dev *dev,
                                  uint32_t rix_jump);
 
-static inline uint16_t
-mlx5_translate_tunnel_etypes(uint64_t pattern_flags)
-{
-       if (pattern_flags & MLX5_FLOW_LAYER_INNER_L2)
-               return RTE_ETHER_TYPE_TEB;
-       else if (pattern_flags & MLX5_FLOW_LAYER_INNER_L3_IPV4)
-               return RTE_ETHER_TYPE_IPV4;
-       else if (pattern_flags & MLX5_FLOW_LAYER_INNER_L3_IPV6)
-               return RTE_ETHER_TYPE_IPV6;
-       else if (pattern_flags & MLX5_FLOW_LAYER_MPLS)
-               return RTE_ETHER_TYPE_MPLS;
-       return 0;
-}
-
 static int16_t
 flow_dv_get_esw_manager_vport_id(struct rte_eth_dev *dev)
 {
@@ -1465,7 +1451,7 @@ static void
 mlx5_flow_field_id_to_modify_info
                (const struct rte_flow_action_modify_data *data,
                 struct field_modify_info *info, uint32_t *mask,
-                uint32_t width, uint32_t *shift, struct rte_eth_dev *dev,
+                uint32_t width, struct rte_eth_dev *dev,
                 const struct rte_flow_attr *attr, struct rte_flow_error *error)
 {
        struct mlx5_priv *priv = dev->data->dev_private;
@@ -1503,7 +1489,7 @@ mlx5_flow_field_id_to_modify_info
                        if (data->offset < 16)
                                info[idx++] = (struct field_modify_info){2, 0,
                                                MLX5_MODI_OUT_DMAC_15_0};
-                       info[idx] = (struct field_modify_info){4, 0,
+                       info[idx] = (struct field_modify_info){4, off,
                                                MLX5_MODI_OUT_DMAC_47_16};
                }
                break;
@@ -1533,7 +1519,7 @@ mlx5_flow_field_id_to_modify_info
                        if (data->offset < 16)
                                info[idx++] = (struct field_modify_info){2, 0,
                                                MLX5_MODI_OUT_SMAC_15_0};
-                       info[idx] = (struct field_modify_info){4, 0,
+                       info[idx] = (struct field_modify_info){4, off,
                                                MLX5_MODI_OUT_SMAC_47_16};
                }
                break;
@@ -1820,16 +1806,11 @@ mlx5_flow_field_id_to_modify_info
                {
                        uint32_t meta_mask = priv->sh->dv_meta_mask;
                        uint32_t meta_count = __builtin_popcount(meta_mask);
-                       uint32_t msk_c0 =
-                               rte_cpu_to_be_32(priv->sh->dv_regc0_mask);
-                       uint32_t shl_c0 = rte_bsf32(msk_c0);
                        int reg = flow_dv_get_metadata_reg(dev, attr, error);
                        if (reg < 0)
                                return;
                        MLX5_ASSERT(reg != REG_NON);
                        MLX5_ASSERT((unsigned int)reg < RTE_DIM(reg_to_field));
-                       if (reg == REG_C_0)
-                               *shift = shl_c0;
                        info[idx] = (struct field_modify_info){4, 0,
                                                reg_to_field[reg]};
                        if (mask)
@@ -1881,29 +1862,33 @@ flow_dv_convert_action_modify_field
        struct field_modify_info dcopy[MLX5_ACT_MAX_MOD_FIELDS] = {
                                                                {0, 0, 0} };
        uint32_t mask[MLX5_ACT_MAX_MOD_FIELDS] = {0, 0, 0, 0, 0};
-       uint32_t type;
-       uint32_t shift = 0;
+       uint32_t type, meta = 0;
 
        if (conf->src.field == RTE_FLOW_FIELD_POINTER ||
            conf->src.field == RTE_FLOW_FIELD_VALUE) {
                type = MLX5_MODIFICATION_TYPE_SET;
                /** For SET fill the destination field (field) first. */
                mlx5_flow_field_id_to_modify_info(&conf->dst, field, mask,
-                                                 conf->width, &shift, dev,
+                                                 conf->width, dev,
                                                  attr, error);
                item.spec = conf->src.field == RTE_FLOW_FIELD_POINTER ?
                                        (void *)(uintptr_t)conf->src.pvalue :
                                        (void *)(uintptr_t)&conf->src.value;
+               if (conf->dst.field == RTE_FLOW_FIELD_META) {
+                       meta = *(const unaligned_uint32_t *)item.spec;
+                       meta = rte_cpu_to_be_32(meta);
+                       item.spec = &meta;
+               }
        } else {
                type = MLX5_MODIFICATION_TYPE_COPY;
                /** For COPY fill the destination field (dcopy) without mask. */
                mlx5_flow_field_id_to_modify_info(&conf->dst, dcopy, NULL,
-                                                 conf->width, &shift, dev,
+                                                 conf->width, dev,
                                                  attr, error);
                /** Then construct the source field (field) with mask. */
                mlx5_flow_field_id_to_modify_info(&conf->src, field, mask,
-                                                 conf->width, &shift,
-                                                 dev, attr, error);
+                                                 conf->width, dev,
+                                                 attr, error);
        }
        item.mask = &mask;
        return flow_dv_convert_modify_action(&item,
@@ -4982,7 +4967,7 @@ flow_dv_validate_action_jump(struct rte_eth_dev *dev,
                             const struct rte_flow_attr *attributes,
                             bool external, struct rte_flow_error *error)
 {
-       uint32_t target_group, table;
+       uint32_t target_group, table = 0;
        int ret = 0;
        struct flow_grp_info grp_info = {
                .external = !!external,
@@ -5013,6 +4998,10 @@ flow_dv_validate_action_jump(struct rte_eth_dev *dev,
                                          RTE_FLOW_ERROR_TYPE_ACTION, NULL,
                                          "target group must be other than"
                                          " the current flow group");
+       if (table == 0)
+               return rte_flow_error_set(error, EINVAL,
+                                         RTE_FLOW_ERROR_TYPE_ACTION_CONF,
+                                         NULL, "root table shouldn't be destination");
        return 0;
 }
 
@@ -11660,7 +11649,7 @@ flow_dv_translate_action_sample(struct rte_eth_dev *dev,
                                (((const struct rte_flow_action_mark *)
                                (sub_actions->conf))->id);
 
-                       dev_flow->handle->mark = 1;
+                       wks->mark = 1;
                        pre_rix = dev_flow->handle->dvh.rix_tag;
                        /* Save the mark resource before sample */
                        pre_r = dev_flow->dv.tag_resource;
@@ -12820,7 +12809,7 @@ flow_dv_translate(struct rte_eth_dev *dev,
                        break;
                case RTE_FLOW_ACTION_TYPE_FLAG:
                        action_flags |= MLX5_FLOW_ACTION_FLAG;
-                       dev_flow->handle->mark = 1;
+                       wks->mark = 1;
                        if (dev_conf->dv_xmeta_en != MLX5_XMETA_MODE_LEGACY) {
                                struct rte_flow_action_mark mark = {
                                        .id = MLX5_FLOW_MARK_DEFAULT,
@@ -12849,7 +12838,7 @@ flow_dv_translate(struct rte_eth_dev *dev,
                        break;
                case RTE_FLOW_ACTION_TYPE_MARK:
                        action_flags |= MLX5_FLOW_ACTION_MARK;
-                       dev_flow->handle->mark = 1;
+                       wks->mark = 1;
                        if (dev_conf->dv_xmeta_en != MLX5_XMETA_MODE_LEGACY) {
                                const struct rte_flow_action_mark *mark =
                                        (const struct rte_flow_action_mark *)
@@ -15417,7 +15406,9 @@ __flow_dv_create_domain_policy_acts(struct rte_eth_dev *dev,
                            (MLX5_MAX_MODIFY_NUM + 1)];
        } mhdr_dummy;
        struct mlx5_flow_dv_modify_hdr_resource *mhdr_res = &mhdr_dummy.res;
+       struct mlx5_flow_workspace *wks = mlx5_flow_get_thread_workspace();
 
+       MLX5_ASSERT(wks);
        egress = (domain == MLX5_MTR_DOMAIN_EGRESS) ? 1 : 0;
        transfer = (domain == MLX5_MTR_DOMAIN_TRANSFER) ? 1 : 0;
        memset(&dh, 0, sizeof(struct mlx5_flow_handle));
@@ -15455,7 +15446,7 @@ __flow_dv_create_domain_policy_acts(struct rte_eth_dev *dev,
                                          NULL,
                                          "cannot create policy "
                                          "mark action for this color");
-                               dev_flow.handle->mark = 1;
+                               wks->mark = 1;
                                if (flow_dv_tag_resource_register(dev, tag_be,
                                                  &dev_flow, &flow_err))
                                        return -rte_mtr_error_set(error,
@@ -16880,7 +16871,9 @@ __flow_dv_meter_get_rss_sub_policy(struct rte_eth_dev *dev,
        struct mlx5_meter_policy_action_container *act_cnt;
        uint32_t domain = MLX5_MTR_DOMAIN_INGRESS;
        uint16_t sub_policy_num;
+       struct mlx5_flow_workspace *wks = mlx5_flow_get_thread_workspace();
 
+       MLX5_ASSERT(wks);
        rte_spinlock_lock(&mtr_policy->sl);
        for (i = 0; i < MLX5_MTR_RTE_COLORS; i++) {
                if (!rss_desc[i])
@@ -16954,7 +16947,7 @@ __flow_dv_meter_get_rss_sub_policy(struct rte_eth_dev *dev,
                        if (act_cnt->rix_mark || act_cnt->modify_hdr) {
                                memset(&dh, 0, sizeof(struct mlx5_flow_handle));
                                if (act_cnt->rix_mark)
-                                       dh.mark = 1;
+                                       wks->mark = 1;
                                dh.fate_action = MLX5_FLOW_FATE_QUEUE;
                                dh.rix_hrxq = hrxq_idx[i];
                                flow_drv_rxq_flags_set(dev, &dh);