Support IPv6 protocol as new flex item input link.

Signed-off-by: Rongwei Liu <rongw...@nvidia.com>
Acked-by: Viacheslav Ovsiienko <viachesl...@nvidia.com>
---
 drivers/net/mlx5/mlx5_flow_flex.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/drivers/net/mlx5/mlx5_flow_flex.c 
b/drivers/net/mlx5/mlx5_flow_flex.c
index fb08910ddb..bec07b13c1 100644
--- a/drivers/net/mlx5/mlx5_flow_flex.c
+++ b/drivers/net/mlx5/mlx5_flow_flex.c
@@ -1043,6 +1043,22 @@ mlx5_flex_arc_in_udp(const struct rte_flow_item *item,
        return rte_be_to_cpu_16(spec->hdr.dst_port);
 }
 
+static int
+mlx5_flex_arc_in_ipv6(const struct rte_flow_item *item,
+                     struct rte_flow_error *error)
+{
+       const struct rte_flow_item_ipv6 *spec = item->spec;
+       const struct rte_flow_item_ipv6 *mask = item->mask;
+       struct rte_flow_item_ipv6 ip = { .hdr.proto = 0xff };
+
+       if (memcmp(mask, &ip, sizeof(struct rte_flow_item_ipv6))) {
+               return rte_flow_error_set
+                       (error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, item,
+                        "invalid ipv6 item mask, full mask is desired");
+       }
+       return spec->hdr.proto;
+}
+
 static int
 mlx5_flex_translate_arc_in(struct mlx5_hca_flex_attr *attr,
                           const struct rte_flow_item_flex_conf *conf,
@@ -1089,6 +1105,9 @@ mlx5_flex_translate_arc_in(struct mlx5_hca_flex_attr 
*attr,
                case RTE_FLOW_ITEM_TYPE_UDP:
                        ret = mlx5_flex_arc_in_udp(rte_item, error);
                        break;
+               case RTE_FLOW_ITEM_TYPE_IPV6:
+                       ret = mlx5_flex_arc_in_ipv6(rte_item, error);
+                       break;
                default:
                        MLX5_ASSERT(false);
                        return rte_flow_error_set
-- 
2.27.0

Reply via email to