net/mlx5: support IPv4 time-to-live filter
[dpdk.git] / drivers / net / mlx5 / mlx5_flow.c
index 13b6483..bf8eff8 100644 (file)
@@ -353,6 +353,7 @@ static const struct mlx5_flow_items mlx5_flow_items[] = {
                                .dst_addr = -1,
                                .type_of_service = -1,
                                .next_proto_id = -1,
+                               .time_to_live = -1,
                        },
                },
                .default_mask = &rte_flow_item_ipv4_mask,
@@ -529,7 +530,7 @@ mlx5_flow_item_validate(const struct rte_flow_item *item,
        }
        if (item->mask) {
                unsigned int i;
-               const uint8_t *spec = item->mask;
+               const uint8_t *spec = item->spec;
 
                for (i = 0; i < size; ++i)
                        if ((spec[i] | mask[i]) != mask[i])
@@ -1168,16 +1169,6 @@ priv_flow_convert(struct priv *priv,
                        attr->priority +
                        hash_rxq_init[parser->layer].flow_priority;
        }
-exit_free:
-       /* Only verification is expected, all resources should be released. */
-       if (!parser->create) {
-               for (i = 0; i != hash_rxq_init_n; ++i) {
-                       if (parser->queue[i].ibv_attr) {
-                               rte_free(parser->queue[i].ibv_attr);
-                               parser->queue[i].ibv_attr = NULL;
-                       }
-               }
-       }
        if (parser->allmulti &&
            parser->layer == HASH_RXQ_ETH) {
                for (i = 0; i != hash_rxq_init_n; ++i) {
@@ -1189,6 +1180,16 @@ exit_free:
                                                IBV_FLOW_ATTR_MC_DEFAULT;
                }
        }
+exit_free:
+       /* Only verification is expected, all resources should be released. */
+       if (!parser->create) {
+               for (i = 0; i != hash_rxq_init_n; ++i) {
+                       if (parser->queue[i].ibv_attr) {
+                               rte_free(parser->queue[i].ibv_attr);
+                               parser->queue[i].ibv_attr = NULL;
+                       }
+               }
+       }
        return ret;
 exit_enomem:
        for (i = 0; i != hash_rxq_init_n; ++i) {
@@ -2656,10 +2657,12 @@ priv_fdir_filter_convert(struct priv *priv,
                attributes->items[1] = (struct rte_flow_item){
                        .type = RTE_FLOW_ITEM_TYPE_IPV4,
                        .spec = &attributes->l3,
+                       .mask = &attributes->l3,
                };
                attributes->items[2] = (struct rte_flow_item){
                        .type = RTE_FLOW_ITEM_TYPE_UDP,
                        .spec = &attributes->l4,
+                       .mask = &attributes->l4,
                };
                break;
        case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
@@ -2677,10 +2680,12 @@ priv_fdir_filter_convert(struct priv *priv,
                attributes->items[1] = (struct rte_flow_item){
                        .type = RTE_FLOW_ITEM_TYPE_IPV4,
                        .spec = &attributes->l3,
+                       .mask = &attributes->l3,
                };
                attributes->items[2] = (struct rte_flow_item){
                        .type = RTE_FLOW_ITEM_TYPE_TCP,
                        .spec = &attributes->l4,
+                       .mask = &attributes->l4,
                };
                break;
        case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
@@ -2694,6 +2699,7 @@ priv_fdir_filter_convert(struct priv *priv,
                attributes->items[1] = (struct rte_flow_item){
                        .type = RTE_FLOW_ITEM_TYPE_IPV4,
                        .spec = &attributes->l3,
+                       .mask = &attributes->l3,
                };
                break;
        case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
@@ -2714,10 +2720,12 @@ priv_fdir_filter_convert(struct priv *priv,
                attributes->items[1] = (struct rte_flow_item){
                        .type = RTE_FLOW_ITEM_TYPE_IPV6,
                        .spec = &attributes->l3,
+                       .mask = &attributes->l3,
                };
                attributes->items[2] = (struct rte_flow_item){
                        .type = RTE_FLOW_ITEM_TYPE_UDP,
                        .spec = &attributes->l4,
+                       .mask = &attributes->l4,
                };
                break;
        case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
@@ -2738,10 +2746,12 @@ priv_fdir_filter_convert(struct priv *priv,
                attributes->items[1] = (struct rte_flow_item){
                        .type = RTE_FLOW_ITEM_TYPE_IPV6,
                        .spec = &attributes->l3,
+                       .mask = &attributes->l3,
                };
                attributes->items[2] = (struct rte_flow_item){
                        .type = RTE_FLOW_ITEM_TYPE_TCP,
                        .spec = &attributes->l4,
+                       .mask = &attributes->l4,
                };
                break;
        case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
@@ -2758,6 +2768,7 @@ priv_fdir_filter_convert(struct priv *priv,
                attributes->items[1] = (struct rte_flow_item){
                        .type = RTE_FLOW_ITEM_TYPE_IPV6,
                        .spec = &attributes->l3,
+                       .mask = &attributes->l3,
                };
                break;
        default: