net/mlx5: fix GRE flow item matching
[dpdk.git] / drivers / net / mlx5 / mlx5_flow_dv.c
index 2f03e59..1a9c040 100644 (file)
@@ -5254,13 +5254,21 @@ mlx5_flow_validate_action_meter(struct rte_eth_dev *dev,
                                                "Flow and meter policy "
                                                "have different src port.");
                } else if (mtr_policy->is_rss) {
-                       struct mlx5_meter_policy_action_container *acg =
-                               &mtr_policy->act_cnt[RTE_COLOR_GREEN];
-                       struct mlx5_meter_policy_action_container *acy =
-                               &mtr_policy->act_cnt[RTE_COLOR_YELLOW];
+                       struct mlx5_flow_meter_policy *fp;
+                       struct mlx5_meter_policy_action_container *acg;
+                       struct mlx5_meter_policy_action_container *acy;
                        const struct rte_flow_action *rss_act;
                        int ret;
 
+                       fp = mlx5_flow_meter_hierarchy_get_final_policy(dev,
+                                                               mtr_policy);
+                       if (fp == NULL)
+                               return rte_flow_error_set(error, EINVAL,
+                                       RTE_FLOW_ERROR_TYPE_ACTION, NULL,
+                                                 "Unable to get the final "
+                                                 "policy in the hierarchy");
+                       acg = &fp->act_cnt[RTE_COLOR_GREEN];
+                       acy = &fp->act_cnt[RTE_COLOR_YELLOW];
                        MLX5_ASSERT(acg->fate_action ==
                                    MLX5_FLOW_FATE_SHARED_RSS ||
                                    acy->fate_action ==
@@ -8815,8 +8823,9 @@ flow_dv_translate_item_gre(void *matcher, void *key,
        protocol_v = rte_be_to_cpu_16(gre_v->protocol);
        if (!protocol_m) {
                /* Force next protocol to prevent matchers duplication */
-               protocol_m = 0xFFFF;
                protocol_v = mlx5_translate_tunnel_etypes(pattern_flags);
+               if (protocol_v)
+                       protocol_m = 0xFFFF;
        }
        MLX5_SET(fte_match_set_misc, misc_m, gre_protocol, protocol_m);
        MLX5_SET(fte_match_set_misc, misc_v, gre_protocol,
@@ -14692,7 +14701,8 @@ __flow_dv_action_rss_setup(struct rte_eth_dev *dev,
        size_t i;
        int err;
 
-       if (mlx5_ind_table_obj_setup(dev, shared_rss->ind_tbl)) {
+       if (mlx5_ind_table_obj_setup(dev, shared_rss->ind_tbl,
+                                    !!dev->data->dev_started)) {
                return rte_flow_error_set(error, rte_errno,
                                          RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
                                          "cannot setup indirection table");
@@ -14732,7 +14742,7 @@ __flow_dv_action_rss_setup(struct rte_eth_dev *dev,
 error_hrxq_new:
        err = rte_errno;
        __flow_dv_action_rss_hrxqs_release(dev, shared_rss);
-       if (!mlx5_ind_table_obj_release(dev, shared_rss->ind_tbl, true))
+       if (!mlx5_ind_table_obj_release(dev, shared_rss->ind_tbl, true, true))
                shared_rss->ind_tbl = NULL;
        rte_errno = err;
        return -rte_errno;
@@ -14875,7 +14885,8 @@ __flow_dv_action_rss_release(struct rte_eth_dev *dev, uint32_t idx,
                                          NULL,
                                          "shared rss hrxq has references");
        queue = shared_rss->ind_tbl->queues;
-       remaining = mlx5_ind_table_obj_release(dev, shared_rss->ind_tbl, true);
+       remaining = mlx5_ind_table_obj_release(dev, shared_rss->ind_tbl, true,
+                                              !!dev->data->dev_started);
        if (remaining)
                return rte_flow_error_set(error, EBUSY,
                                          RTE_FLOW_ERROR_TYPE_ACTION,
@@ -15063,6 +15074,7 @@ __flow_dv_action_rss_update(struct rte_eth_dev *dev, uint32_t idx,
        void *queue = NULL;
        uint16_t *queue_old = NULL;
        uint32_t queue_size = action_conf->queue_num * sizeof(uint16_t);
+       bool dev_started = !!dev->data->dev_started;
 
        if (!shared_rss)
                return rte_flow_error_set(error, EINVAL,
@@ -15085,7 +15097,10 @@ __flow_dv_action_rss_update(struct rte_eth_dev *dev, uint32_t idx,
        rte_spinlock_lock(&shared_rss->action_rss_sl);
        queue_old = shared_rss->ind_tbl->queues;
        ret = mlx5_ind_table_obj_modify(dev, shared_rss->ind_tbl,
-                                       queue, action_conf->queue_num, true);
+                                       queue, action_conf->queue_num,
+                                       true /* standalone */,
+                                       dev_started /* ref_new_qs */,
+                                       dev_started /* deref_old_qs */);
        if (ret) {
                mlx5_free(queue);
                ret = rte_flow_error_set(error, rte_errno,