From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B0B1843CE7 for ; Mon, 18 Mar 2024 16:40:26 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A6A6A402B8; Mon, 18 Mar 2024 16:40:26 +0100 (CET) Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) by mails.dpdk.org (Postfix) with ESMTP id 5605D40697 for ; Mon, 18 Mar 2024 16:40:24 +0100 (CET) Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-33e672e10cfso2317112f8f.0 for ; Mon, 18 Mar 2024 08:40:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710776424; x=1711381224; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=htODJYRd1H1pjStujI0gTZz4gnUXZnMSls1+8yv09J8=; b=Hw6jbr+2EftR5ld8ZTrUHqsmmHzkCR2NwtNByqiEFasAxGi9I0/GxYHrjTmc39knFr CFN/j0oHd0P3dYeWthflQ/tQY0X3HoNswvWM+qR9HYAomHTVQlJ1LdvU8AM3SpEQMNFJ 2D5EmDZjdtg7l2AcPfc5a/2G28OF2bmxixBKihsieTYDIZSv3mCIUohfZX+zvw4R90wq +GWjVDf/OzTSikRv0YAVuEgs9lIJi0PrWHvPlcz55wzD7Esl3n3Ni3I2M+93dVh4FLea mLTRcvLEPGC9pAoz46upSgUEnB05saLseKoWucDGIA5kckh3lWFMowOjG4FSHrhJvPaO mM5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710776424; x=1711381224; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=htODJYRd1H1pjStujI0gTZz4gnUXZnMSls1+8yv09J8=; b=jn0J8qxDo/GvdFkQDsPXafnfB/UNGl4y+mSd8ZPnAHXgKcOIgp+nC/k7+lQLrh14Tt toSQoDaHGbXKePloIlbLfthRv/CyDexAVIlKruQj8DHMuXhGKzG40GQKHgNh64iI8iF1 hmmXaadggs6JWkI5G+OOiooqxPXPRnUvpWgIEVeVRYfarnGRNeU6gbLDu+c4B8iyCmYp +ISrwOSgf9EldDvcL3vrU0x3bvXCDmzOy+/Ipk+YDpBzU/FSdK21n2JHk9rB+JjqnFG0 OOtFVt+2QGlrbChxjx4rdRrOW+9tQZNm+QFR+kMQ7x+YnXQrnFhy9G0n40wbMgzRGCYR xL9A== X-Forwarded-Encrypted: i=1; AJvYcCV+CCq8pb7/zC8+LejBX2LK8rtfQiej28EtyW7S9qMKYLSg5WE8rklIUitf9bv5sYVYOYbjf8yZA6mDt4NRXuM= X-Gm-Message-State: AOJu0YyoXd/vY98SuyGLodtXvMQ5ZTrFHrLJBMTGhgOR6KNWWmTRV3qF yfdY2xG+3TlgAeucnZgleVqcjwYjo0G9Vkp4YD7q46NXXt/5G2dgVkf1YKi5doU= X-Google-Smtp-Source: AGHT+IFoF8DsgMvN/AL1LeIukqRK+lIQxJcDIuIsiiJ84ut++kS48CFAf0UAdVAMsnso4bXH/5yY3w== X-Received: by 2002:adf:e582:0:b0:33e:c2a5:15c3 with SMTP id l2-20020adfe582000000b0033ec2a515c3mr9186058wrm.41.1710776423931; Mon, 18 Mar 2024 08:40:23 -0700 (PDT) Received: from localhost ([137.220.120.171]) by smtp.gmail.com with ESMTPSA id y13-20020a056000108d00b0033d202abf01sm10031256wrw.28.2024.03.18.08.40.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 08:40:23 -0700 (PDT) From: luca.boccassi@gmail.com To: Gregory Etelson Cc: Ori Kam , dpdk stable Subject: patch 'net/mlx5: remove duplication of L3 flow item validation' has been queued to stable release 22.11.5 Date: Mon, 18 Mar 2024 15:39:09 +0000 Message-Id: <20240318153919.3407921-19-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240318153919.3407921-1-luca.boccassi@gmail.com> References: <20240314000957.2810803-61-luca.boccassi@gmail.com> <20240318153919.3407921-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Hi, FYI, your patch has been queued to stable release 22.11.5 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 03/20/24. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/bluca/dpdk-stable This queued commit can be viewed at: https://github.com/bluca/dpdk-stable/commit/03243a27739ee97b02d23050b4a6245c239428a1 Thanks. Luca Boccassi --- >From 03243a27739ee97b02d23050b4a6245c239428a1 Mon Sep 17 00:00:00 2001 From: Gregory Etelson Date: Thu, 29 Feb 2024 18:05:03 +0200 Subject: [PATCH] net/mlx5: remove duplication of L3 flow item validation [ upstream commit 27e44a6f53eccc7d2ce80f6466fa214158f0ee81 ] Remove code duplications in DV L3 items validation translation. Fixes: 3193c2494eea ("net/mlx5: fix L4 protocol validation") Signed-off-by: Gregory Etelson Acked-by: Ori Kam --- drivers/net/mlx5/mlx5_flow_dv.c | 151 +++++++++----------------------- 1 file changed, 43 insertions(+), 108 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index f5f33a9eca..a4fca70b07 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -6971,6 +6971,40 @@ flow_dv_validate_item_flex(struct rte_eth_dev *dev, return 0; } +static __rte_always_inline uint8_t +mlx5_flow_l3_next_protocol(const struct rte_flow_item *l3_item, + enum MLX5_SET_MATCHER key_type) +{ +#define MLX5_L3_NEXT_PROTOCOL(i, ms) \ + ((i)->type == RTE_FLOW_ITEM_TYPE_IPV4 ? \ + ((const struct rte_flow_item_ipv4 *)(i)->ms)->hdr.next_proto_id : \ + (i)->type == RTE_FLOW_ITEM_TYPE_IPV6 ? \ + ((const struct rte_flow_item_ipv6 *)(i)->ms)->hdr.proto : \ + (i)->type == RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT ? \ + ((const struct rte_flow_item_ipv6_frag_ext *)(i)->ms)->hdr.next_header :\ + 0xff) + + uint8_t next_protocol; + + if (l3_item->mask != NULL && l3_item->spec != NULL) { + next_protocol = MLX5_L3_NEXT_PROTOCOL(l3_item, mask); + if (next_protocol) + next_protocol &= MLX5_L3_NEXT_PROTOCOL(l3_item, spec); + else + next_protocol = 0xff; + } else if (key_type == MLX5_SET_MATCHER_HS_M && l3_item->mask != NULL) { + next_protocol = MLX5_L3_NEXT_PROTOCOL(l3_item, mask); + } else if (key_type == MLX5_SET_MATCHER_HS_V && l3_item->spec != NULL) { + next_protocol = MLX5_L3_NEXT_PROTOCOL(l3_item, spec); + } else { + /* Reset for inner layer. */ + next_protocol = 0xff; + } + return next_protocol; + +#undef MLX5_L3_NEXT_PROTOCOL +} + /** * Internal validation function. For validating both actions and items. * @@ -7194,19 +7228,8 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, return ret; last_item = tunnel ? MLX5_FLOW_LAYER_INNER_L3_IPV4 : MLX5_FLOW_LAYER_OUTER_L3_IPV4; - if (items->mask != NULL && - ((const struct rte_flow_item_ipv4 *) - items->mask)->hdr.next_proto_id) { - next_protocol = - ((const struct rte_flow_item_ipv4 *) - (items->spec))->hdr.next_proto_id; - next_protocol &= - ((const struct rte_flow_item_ipv4 *) - (items->mask))->hdr.next_proto_id; - } else { - /* Reset for inner layer. */ - next_protocol = 0xff; - } + next_protocol = mlx5_flow_l3_next_protocol + (items, (enum MLX5_SET_MATCHER)-1); break; case RTE_FLOW_ITEM_TYPE_IPV6: mlx5_flow_tunnel_ip_check(items, next_protocol, @@ -7220,22 +7243,8 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, return ret; last_item = tunnel ? MLX5_FLOW_LAYER_INNER_L3_IPV6 : MLX5_FLOW_LAYER_OUTER_L3_IPV6; - if (items->mask != NULL && - ((const struct rte_flow_item_ipv6 *) - items->mask)->hdr.proto) { - item_ipv6_proto = - ((const struct rte_flow_item_ipv6 *) - items->spec)->hdr.proto; - next_protocol = - ((const struct rte_flow_item_ipv6 *) - items->spec)->hdr.proto; - next_protocol &= - ((const struct rte_flow_item_ipv6 *) - items->mask)->hdr.proto; - } else { - /* Reset for inner layer. */ - next_protocol = 0xff; - } + next_protocol = mlx5_flow_l3_next_protocol + (items, (enum MLX5_SET_MATCHER)-1); break; case RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT: ret = flow_dv_validate_item_ipv6_frag_ext(items, @@ -7246,19 +7255,8 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, last_item = tunnel ? MLX5_FLOW_LAYER_INNER_L3_IPV6_FRAG_EXT : MLX5_FLOW_LAYER_OUTER_L3_IPV6_FRAG_EXT; - if (items->mask != NULL && - ((const struct rte_flow_item_ipv6_frag_ext *) - items->mask)->hdr.next_header) { - next_protocol = - ((const struct rte_flow_item_ipv6_frag_ext *) - items->spec)->hdr.next_header; - next_protocol &= - ((const struct rte_flow_item_ipv6_frag_ext *) - items->mask)->hdr.next_header; - } else { - /* Reset for inner layer. */ - next_protocol = 0xff; - } + next_protocol = mlx5_flow_l3_next_protocol + (items, (enum MLX5_SET_MATCHER)-1); break; case RTE_FLOW_ITEM_TYPE_TCP: ret = mlx5_flow_validate_item_tcp @@ -13249,28 +13247,7 @@ flow_dv_translate_items(struct rte_eth_dev *dev, wks->priority = MLX5_PRIORITY_MAP_L3; last_item = tunnel ? MLX5_FLOW_LAYER_INNER_L3_IPV4 : MLX5_FLOW_LAYER_OUTER_L3_IPV4; - if (items->mask != NULL && - items->spec != NULL && - ((const struct rte_flow_item_ipv4 *) - items->mask)->hdr.next_proto_id) { - next_protocol = - ((const struct rte_flow_item_ipv4 *) - (items->spec))->hdr.next_proto_id; - next_protocol &= - ((const struct rte_flow_item_ipv4 *) - (items->mask))->hdr.next_proto_id; - } else if (key_type == MLX5_SET_MATCHER_HS_M && - items->mask != NULL) { - next_protocol = ((const struct rte_flow_item_ipv4 *) - (items->mask))->hdr.next_proto_id; - } else if (key_type == MLX5_SET_MATCHER_HS_V && - items->spec != NULL) { - next_protocol = ((const struct rte_flow_item_ipv4 *) - (items->spec))->hdr.next_proto_id; - } else { - /* Reset for inner layer. */ - next_protocol = 0xff; - } + next_protocol = mlx5_flow_l3_next_protocol(items, key_type); break; case RTE_FLOW_ITEM_TYPE_IPV6: mlx5_flow_tunnel_ip_check(items, next_protocol, @@ -13280,56 +13257,14 @@ flow_dv_translate_items(struct rte_eth_dev *dev, wks->priority = MLX5_PRIORITY_MAP_L3; last_item = tunnel ? MLX5_FLOW_LAYER_INNER_L3_IPV6 : MLX5_FLOW_LAYER_OUTER_L3_IPV6; - if (items->mask != NULL && - items->spec != NULL && - ((const struct rte_flow_item_ipv6 *) - items->mask)->hdr.proto) { - next_protocol = - ((const struct rte_flow_item_ipv6 *) - items->spec)->hdr.proto; - next_protocol &= - ((const struct rte_flow_item_ipv6 *) - items->mask)->hdr.proto; - } else if (key_type == MLX5_SET_MATCHER_HS_M && - items->mask != NULL) { - next_protocol = ((const struct rte_flow_item_ipv6 *) - (items->mask))->hdr.proto; - } else if (key_type == MLX5_SET_MATCHER_HS_V && - items->spec != NULL) { - next_protocol = ((const struct rte_flow_item_ipv6 *) - (items->spec))->hdr.proto; - } else { - /* Reset for inner layer. */ - next_protocol = 0xff; - } + next_protocol = mlx5_flow_l3_next_protocol(items, key_type); break; case RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT: flow_dv_translate_item_ipv6_frag_ext (key, items, tunnel, key_type); last_item = tunnel ? MLX5_FLOW_LAYER_INNER_L3_IPV6_FRAG_EXT : MLX5_FLOW_LAYER_OUTER_L3_IPV6_FRAG_EXT; - if (items->mask != NULL && - items->spec != NULL && - ((const struct rte_flow_item_ipv6_frag_ext *) - items->mask)->hdr.next_header) { - next_protocol = - ((const struct rte_flow_item_ipv6_frag_ext *) - items->spec)->hdr.next_header; - next_protocol &= - ((const struct rte_flow_item_ipv6_frag_ext *) - items->mask)->hdr.next_header; - } else if (key_type == MLX5_SET_MATCHER_HS_M && - items->mask != NULL) { - next_protocol = ((const struct rte_flow_item_ipv6_frag_ext *) - (items->mask))->hdr.next_header; - } else if (key_type == MLX5_SET_MATCHER_HS_V && - items->spec != NULL) { - next_protocol = ((const struct rte_flow_item_ipv6_frag_ext *) - (items->spec))->hdr.next_header; - } else { - /* Reset for inner layer. */ - next_protocol = 0xff; - } + next_protocol = mlx5_flow_l3_next_protocol(items, key_type); break; case RTE_FLOW_ITEM_TYPE_TCP: flow_dv_translate_item_tcp(key, items, tunnel, key_type); -- 2.39.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2024-03-18 12:58:40.069485295 +0000 +++ 0019-net-mlx5-remove-duplication-of-L3-flow-item-validati.patch 2024-03-18 12:58:39.183346646 +0000 @@ -1 +1 @@ -From 27e44a6f53eccc7d2ce80f6466fa214158f0ee81 Mon Sep 17 00:00:00 2001 +From 03243a27739ee97b02d23050b4a6245c239428a1 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 27e44a6f53eccc7d2ce80f6466fa214158f0ee81 ] + @@ -9 +10,0 @@ -Cc: stable@dpdk.org @@ -18 +19 @@ -index f1584ed6e0..9e444c8a1c 100644 +index f5f33a9eca..a4fca70b07 100644 @@ -21 +22 @@ -@@ -7488,6 +7488,40 @@ flow_dv_validate_item_flex(struct rte_eth_dev *dev, +@@ -6971,6 +6971,40 @@ flow_dv_validate_item_flex(struct rte_eth_dev *dev, @@ -60 +61 @@ - * Validate IB BTH item. + * Internal validation function. For validating both actions and items. @@ -62 +63 @@ -@@ -7770,19 +7804,8 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, +@@ -7194,19 +7228,8 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, @@ -84 +85 @@ -@@ -7796,22 +7819,8 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, +@@ -7220,22 +7243,8 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, @@ -109 +110 @@ -@@ -7822,19 +7831,8 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, +@@ -7246,19 +7255,8 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, @@ -131 +132 @@ -@@ -13997,28 +13995,7 @@ flow_dv_translate_items(struct rte_eth_dev *dev, +@@ -13249,28 +13247,7 @@ flow_dv_translate_items(struct rte_eth_dev *dev, @@ -161 +162 @@ -@@ -14028,56 +14005,14 @@ flow_dv_translate_items(struct rte_eth_dev *dev, +@@ -13280,56 +13257,14 @@ flow_dv_translate_items(struct rte_eth_dev *dev,