net/mlx5: fix zero metadata action
[dpdk.git] / drivers / net / mlx5 / mlx5_flow_dv.c
index 06592b5..e2d6690 100644 (file)
@@ -1771,7 +1771,7 @@ flow_dev_get_vlan_info_from_items(const struct rte_flow_item *items,
                /* Only full match values are accepted */
                if ((vlan_m->tci & MLX5DV_FLOW_VLAN_PCP_MASK_BE) ==
                     MLX5DV_FLOW_VLAN_PCP_MASK_BE) {
-                       vlan->vlan_tci &= MLX5DV_FLOW_VLAN_PCP_MASK;
+                       vlan->vlan_tci &= ~MLX5DV_FLOW_VLAN_PCP_MASK;
                        vlan->vlan_tci |=
                                rte_be_to_cpu_16(vlan_v->tci &
                                                 MLX5DV_FLOW_VLAN_PCP_MASK_BE);
@@ -2109,10 +2109,6 @@ flow_dv_validate_action_set_meta(struct rte_eth_dev *dev,
                return rte_flow_error_set(error, EINVAL,
                                          RTE_FLOW_ERROR_TYPE_ACTION, action,
                                          "meta data must be within reg C0");
-       if (!(conf->data & conf->mask))
-               return rte_flow_error_set(error, EINVAL,
-                                         RTE_FLOW_ERROR_TYPE_ACTION, action,
-                                         "zero value has no effect");
        return 0;
 }
 
@@ -4490,13 +4486,35 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
        const struct rte_flow_action_raw_decap *decap;
        const struct rte_flow_action_raw_encap *encap;
        const struct rte_flow_action_rss *rss;
-       struct rte_flow_item_tcp nic_tcp_mask = {
+       const struct rte_flow_item_tcp nic_tcp_mask = {
                .hdr = {
                        .tcp_flags = 0xFF,
                        .src_port = RTE_BE16(UINT16_MAX),
                        .dst_port = RTE_BE16(UINT16_MAX),
                }
        };
+       const struct rte_flow_item_ipv4 nic_ipv4_mask = {
+               .hdr = {
+                       .src_addr = RTE_BE32(0xffffffff),
+                       .dst_addr = RTE_BE32(0xffffffff),
+                       .type_of_service = 0xff,
+                       .next_proto_id = 0xff,
+                       .time_to_live = 0xff,
+               },
+       };
+       const struct rte_flow_item_ipv6 nic_ipv6_mask = {
+               .hdr = {
+                       .src_addr =
+                       "\xff\xff\xff\xff\xff\xff\xff\xff"
+                       "\xff\xff\xff\xff\xff\xff\xff\xff",
+                       .dst_addr =
+                       "\xff\xff\xff\xff\xff\xff\xff\xff"
+                       "\xff\xff\xff\xff\xff\xff\xff\xff",
+                       .vtc_flow = RTE_BE32(0xffffffff),
+                       .proto = 0xff,
+                       .hop_limits = 0xff,
+               },
+       };
        struct mlx5_priv *priv = dev->data->dev_private;
        struct mlx5_dev_config *dev_conf = &priv->config;
        uint16_t queue_index = 0xFFFF;
@@ -4563,7 +4581,8 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
                                                  &item_flags, &tunnel);
                        ret = mlx5_flow_validate_item_ipv4(items, item_flags,
                                                           last_item,
-                                                          ether_type, NULL,
+                                                          ether_type,
+                                                          &nic_ipv4_mask,
                                                           error);
                        if (ret < 0)
                                return ret;
@@ -4588,7 +4607,8 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
                                                  &item_flags, &tunnel);
                        ret = mlx5_flow_validate_item_ipv6(items, item_flags,
                                                           last_item,
-                                                          ether_type, NULL,
+                                                          ether_type,
+                                                          &nic_ipv6_mask,
                                                           error);
                        if (ret < 0)
                                return ret;
@@ -5421,6 +5441,7 @@ flow_dv_translate_item_ipv4(void *matcher, void *key,
                        .dst_addr = RTE_BE32(0xffffffff),
                        .type_of_service = 0xff,
                        .next_proto_id = 0xff,
+                       .time_to_live = 0xff,
                },
        };
        void *headers_m;
@@ -5470,6 +5491,10 @@ flow_dv_translate_item_ipv4(void *matcher, void *key,
                 ipv4_m->hdr.next_proto_id);
        MLX5_SET(fte_match_set_lyr_2_4, headers_v, ip_protocol,
                 ipv4_v->hdr.next_proto_id & ipv4_m->hdr.next_proto_id);
+       MLX5_SET(fte_match_set_lyr_2_4, headers_m, ip_ttl_hoplimit,
+                ipv4_m->hdr.time_to_live);
+       MLX5_SET(fte_match_set_lyr_2_4, headers_v, ip_ttl_hoplimit,
+                ipv4_v->hdr.time_to_live & ipv4_m->hdr.time_to_live);
        /*
         * On outer header (which must contains L2), or inner header with L2,
         * set cvlan_tag mask bit to mark this packet as untagged.
@@ -5583,6 +5608,11 @@ flow_dv_translate_item_ipv6(void *matcher, void *key,
                 ipv6_m->hdr.proto);
        MLX5_SET(fte_match_set_lyr_2_4, headers_v, ip_protocol,
                 ipv6_v->hdr.proto & ipv6_m->hdr.proto);
+       /* Hop limit. */
+       MLX5_SET(fte_match_set_lyr_2_4, headers_m, ip_ttl_hoplimit,
+                ipv6_m->hdr.hop_limits);
+       MLX5_SET(fte_match_set_lyr_2_4, headers_v, ip_ttl_hoplimit,
+                ipv6_v->hdr.hop_limits & ipv6_m->hdr.hop_limits);
        /*
         * On outer header (which must contains L2), or inner header with L2,
         * set cvlan_tag mask bit to mark this packet as untagged.