net/mlx5: fix RSS flow item expansion for GRE key
[dpdk.git] / drivers / net / mlx5 / mlx5_flow.c
index 528ce3e..32634c9 100644 (file)
@@ -99,6 +99,8 @@ struct mlx5_flow_expand_node {
         * RSS types bit-field associated with this node
         * (see ETH_RSS_* definitions).
         */
+       uint8_t optional;
+       /**< optional expand field. Default 0 to expand, 1 not go deeper. */
 };
 
 /** Object returned by mlx5_flow_expand_rss(). */
@@ -212,7 +214,7 @@ mlx5_flow_expand_rss_item_complete(const struct rte_flow_item *item)
        return ret;
 }
 
-#define MLX5_RSS_EXP_ELT_N 8
+#define MLX5_RSS_EXP_ELT_N 16
 
 /**
  * Expand RSS flows into several possible flows according to the RSS hash
@@ -366,7 +368,7 @@ mlx5_flow_expand_rss(struct mlx5_flow_expand_rss *buf, size_t size,
                        }
                }
                /* Go deeper. */
-               if (node->next) {
+               if (!node->optional && node->next) {
                        next_node = node->next;
                        if (stack_pos++ == MLX5_RSS_EXP_ELT_N) {
                                rte_errno = E2BIG;
@@ -405,6 +407,7 @@ enum mlx5_expansion {
        MLX5_EXPANSION_VXLAN,
        MLX5_EXPANSION_VXLAN_GPE,
        MLX5_EXPANSION_GRE,
+       MLX5_EXPANSION_GRE_KEY,
        MLX5_EXPANSION_MPLS,
        MLX5_EXPANSION_ETH,
        MLX5_EXPANSION_ETH_VLAN,
@@ -513,9 +516,16 @@ static const struct mlx5_flow_expand_node mlx5_support_expansion[] = {
        },
        [MLX5_EXPANSION_GRE] = {
                .next = MLX5_FLOW_EXPAND_RSS_NEXT(MLX5_EXPANSION_IPV4,
-                                                 MLX5_EXPANSION_IPV6),
+                                                 MLX5_EXPANSION_IPV6,
+                                                 MLX5_EXPANSION_GRE_KEY),
                .type = RTE_FLOW_ITEM_TYPE_GRE,
        },
+       [MLX5_EXPANSION_GRE_KEY] = {
+               .next = MLX5_FLOW_EXPAND_RSS_NEXT(MLX5_EXPANSION_IPV4,
+                                                 MLX5_EXPANSION_IPV6),
+               .type = RTE_FLOW_ITEM_TYPE_GRE_KEY,
+               .optional = 1,
+       },
        [MLX5_EXPANSION_MPLS] = {
                .next = MLX5_FLOW_EXPAND_RSS_NEXT(MLX5_EXPANSION_IPV4,
                                                  MLX5_EXPANSION_IPV6),
@@ -1687,6 +1697,37 @@ mlx5_flow_validate_action_count(struct rte_eth_dev *dev __rte_unused,
        return 0;
 }
 
+/*
+ * Validate the ASO CT action.
+ *
+ * @param[in] dev
+ *   Pointer to the Ethernet device structure.
+ * @param[in] conntrack
+ *   Pointer to the CT action profile.
+ * @param[out] error
+ *   Pointer to error structure.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+int
+mlx5_validate_action_ct(struct rte_eth_dev *dev,
+                       const struct rte_flow_action_conntrack *conntrack,
+                       struct rte_flow_error *error)
+{
+       RTE_SET_USED(dev);
+
+       if (conntrack->state > RTE_FLOW_CONNTRACK_STATE_TIME_WAIT)
+               return rte_flow_error_set(error, EINVAL,
+                                         RTE_FLOW_ERROR_TYPE_ACTION, NULL,
+                                         "Invalid CT state");
+       if (conntrack->last_index > RTE_FLOW_CONNTRACK_FLAG_RST)
+               return rte_flow_error_set(error, EINVAL,
+                                         RTE_FLOW_ERROR_TYPE_ACTION, NULL,
+                                         "Invalid last TCP packet flag");
+       return 0;
+}
+
 /**
  * Verify the @p attributes will be correctly understood by the NIC and store
  * them in the @p flow if everything is correct.
@@ -7347,14 +7388,11 @@ mlx5_flow_create_counter_stat_mem_mng(struct mlx5_dev_ctx_shared *sh)
                mlx5_free(mem);
                return -rte_errno;
        }
+       memset(&mkey_attr, 0, sizeof(mkey_attr));
        mkey_attr.addr = (uintptr_t)mem;
        mkey_attr.size = size;
        mkey_attr.umem_id = mlx5_os_get_umem_id(mem_mng->umem);
        mkey_attr.pd = sh->pdn;
-       mkey_attr.log_entity_size = 0;
-       mkey_attr.pg_access = 0;
-       mkey_attr.klm_array = NULL;
-       mkey_attr.klm_num = 0;
        mkey_attr.relaxed_ordering_write = sh->cmng.relaxed_ordering_write;
        mkey_attr.relaxed_ordering_read = sh->cmng.relaxed_ordering_read;
        mem_mng->dm = mlx5_devx_cmd_mkey_create(sh->ctx, &mkey_attr);