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 29BA242B1C; Tue, 16 May 2023 07:44:02 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1D9B342D3A; Tue, 16 May 2023 07:44:02 +0200 (CEST) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2069.outbound.protection.outlook.com [40.107.237.69]) by mails.dpdk.org (Postfix) with ESMTP id DF73342D38; Tue, 16 May 2023 07:44:00 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gTv4iCW549PnU0nmoWYznccKm1cob/IZsSJiZGbTRKT3Ykvafv20McZ0oGOHYhuAfK43viFK00EKOsGS3ItUcqvigyBnyxI9KPqyJov0wVkCdCMJApLuXc6uPMJlnbKlHoFKbTtT9vaMWySUu8uXfkN/GO2QVhvaWwzOzL9UwZK11iyZ1JGLKAywacibGbDjryJ4QVtG0h+9EbZ20ECQDvza47zWcVkFAstZCTPWfNqYkzvicZgwxBgQm3zZwZ+Y4UUxV5Zy1zKaV9CNZpPpEtNNK2unnEFlzQCyWx/X8Y5uT2CpNJrO6V24gwkfaKT5uAeJDFUSpzwRW5nwqmve2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=2qyfM7sWoSdFBtESPd1TiCfTNPvwTEu9SX5T5hYUmpI=; b=GbZBWg24Lr1lMlaPHdnGRk/mkQtBmqH+Se6MeFPw8ddaM+5ttbFRYr0IfWkBmQc1DZFHD0n7ca/HT3c3uFJgts94uJqwPBv8xoP1PgFdE5sCCSaYTPtyXz8AW/TJP5YfHdn8MJyAAuDjkY+krCLcwkMZw1fRFtfEUd1kh4Zf77QIFXSad2/CEfq719Lgu2CAPzp7K6iCUdV/8MTsPzjm/MAs53VTp/iInXDEfQ5fQQzAt0Lvh0iG7XNgr6hopyK2sBQADX8IOrolyAae39V3JNMeO6/AuWqaIkvq8OUXoUDzCid7AlVCsffVaX6gML4h1r4askkt3Q4cb8FAS1raFw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2qyfM7sWoSdFBtESPd1TiCfTNPvwTEu9SX5T5hYUmpI=; b=uPuMWQAMw4yXPmDemKZdIe6Q1UNC0YRb0A5AllDsCgz0qtlhPjmFcl9vyeUDYWLRIbC+8JgQWD4ciMkmti0jggJeKvUceFOXZUe4yLQzS4KJRiEpUgPzNyKt6Hhe574NOogxz5LkwHviokOrUuSdFoppwJdrjirvFcdB034ssIGKO+T+iV19WmfabSqnnsJeI4c8nGGrKQFpXJGQBj6Ym20B9jF9rqIS7yfv8QMxKBw3UsBHBI5TGoc7cUxFfn74oOfPwG1ylWOoUZZNnZkAcXM5V0lfh4o2EhwC7FlvKq9ieyYNGYUp/HagS3qFzpK/PkQ4zTE9mOfev7PFGy/M7Q== Received: from SJ0PR03CA0108.namprd03.prod.outlook.com (2603:10b6:a03:333::23) by CY8PR12MB7243.namprd12.prod.outlook.com (2603:10b6:930:58::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.32; Tue, 16 May 2023 05:43:59 +0000 Received: from DM6NAM11FT107.eop-nam11.prod.protection.outlook.com (2603:10b6:a03:333:cafe::c2) by SJ0PR03CA0108.outlook.office365.com (2603:10b6:a03:333::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.30 via Frontend Transport; Tue, 16 May 2023 05:43:59 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by DM6NAM11FT107.mail.protection.outlook.com (10.13.172.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.15 via Frontend Transport; Tue, 16 May 2023 05:43:58 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Mon, 15 May 2023 22:43:48 -0700 Received: from nvidia.com (10.126.230.37) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Mon, 15 May 2023 22:43:45 -0700 From: Rongwei Liu To: , , , , CC: , Yongseok Koh Subject: [PATCH v1 2/2] net/mlx5: fix sws duplicated tag index matching Date: Tue, 16 May 2023 08:43:29 +0300 Message-ID: <20230516054329.1397016-3-rongweil@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230516054329.1397016-1-rongweil@nvidia.com> References: <20230516054329.1397016-1-rongweil@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.230.37] X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT107:EE_|CY8PR12MB7243:EE_ X-MS-Office365-Filtering-Correlation-Id: 608add54-0dac-4b22-9cc7-08db55d08bcd X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hRqp256oGYMhzXKxSvqBTZ62xE1/y363SfS75Z5iC4fNYeVJAGYfdxwKNNny3c+dA/0ZdKoC5JFK6EV1JM5/iqp+jJ44T+pWukIxIzQn0wX2lTyXllxKwC4rvPVS/mS/ndWDQKj1nqnywWNw+5CjA3P0AKP6Y/gCCOJVyOKdHwF5QwoxmEGk114J2JHA9XTRVGHCqAgQ+tB/ioY59HZ4rb8xIpTzXRiUQKjWllqS2MjlgefteL02q2m9ieAfUiDyZd0WWZo904Ql896lkm96zqZeBNOUphU/67bGGMPbLs1h3ztJfT7MOnpiLqGZSVMe3MP3DMWrca2FFSocBhXTqjtxakPh+Z1CcKdI46QoYTU6ozSFdThAPEsR86ereM1hOwz6PdbH6pSpd6icA3EXkIE138UWQ22vaKviHpvkkhCwyLN6oMMXrqkRVkMw57N4eHB1Mg3H5NHCvQm6RQVQogGAJc4XR5cweTTDi3zgKnS1+9oqGTC1UZkgzQ3HuTNqVHp97d9+gg9eoReWu/Em+CpP2PBF91J6NlhVLLc+gpAokI5zA7Qh/6kJVuxEBK/TvQ/cTEEMIdAkS7gH/k/SBDJKy0PyOvDyCjun3iISVoaUO+vzbV3AO01CdVa8/FO4mscOGD7V3LUpNzOU/ZyBf3w9X/x3G6X3Nmx5WjCWq4PR83aZ36KCFTrxW/VyiqKVUbEMEPzGU5isV8tomQzwfS/auIlueRG8v5Rcn4B4siKV0Vi7TmN/RVIRoltBCXsb X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230028)(4636009)(136003)(39860400002)(346002)(396003)(376002)(451199021)(46966006)(40470700004)(36840700001)(8676002)(8936002)(86362001)(41300700001)(70586007)(478600001)(316002)(4326008)(2906002)(70206006)(110136005)(5660300002)(54906003)(82310400005)(6666004)(7696005)(82740400003)(40460700003)(7636003)(356005)(55016003)(336012)(2616005)(47076005)(426003)(1076003)(186003)(16526019)(26005)(6286002)(40480700001)(107886003)(36756003)(36860700001)(83380400001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 May 2023 05:43:58.8561 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 608add54-0dac-4b22-9cc7-08db55d08bcd X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT107.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7243 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Duplicated matching tag index is not allowed in sws because they are using the same matching field in the underlayer layout. For example: "tag index is 0 data spec 0x12 mask 0xff / tag index is 0 data spec 0x1234 mask 0xffff" is paradoxical matching condition and "tag index is 0 data spec 0x12 mask 0xff / tag index is 0 data spec 0x3400 mask 0xff00" should be "tag index is 0 data spec 0x3412 mask 0xffff" Add checking logic against it. Fixes: e554b672aa05 ("net/mlx5: support flow tag") Cc: viacheslavo@nvidia.com Cc: stable@dpdk.org Signed-off-by: Rongwei Liu Acked-by: Viacheslav Ovsiienko --- drivers/net/mlx5/mlx5_flow_dv.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index 1abc4acad7..db2bf615db 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -2294,6 +2294,8 @@ flow_dv_validate_item_meta(struct rte_eth_dev *dev __rte_unused, * Pointer to the rte_eth_dev structure. * @param[in] item * Item specification. + * @param[in] tag_bitmap + * Tag index bitmap. * @param[in] attr * Attributes of flow that includes this item. * @param[out] error @@ -2305,6 +2307,7 @@ flow_dv_validate_item_meta(struct rte_eth_dev *dev __rte_unused, static int flow_dv_validate_item_tag(struct rte_eth_dev *dev, const struct rte_flow_item *item, + uint32_t *tag_bitmap, const struct rte_flow_attr *attr __rte_unused, struct rte_flow_error *error) { @@ -2348,6 +2351,12 @@ flow_dv_validate_item_tag(struct rte_eth_dev *dev, if (ret < 0) return ret; MLX5_ASSERT(ret != REG_NON); + if (*tag_bitmap & (1 << ret)) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM_SPEC, + item->spec, + "Duplicated tag index"); + *tag_bitmap |= 1 << ret; return 0; } @@ -7290,9 +7299,10 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, bool def_policy = false; bool shared_count = false; uint16_t udp_dport = 0; - uint32_t tag_id = 0; + uint32_t tag_id = 0, tag_bitmap = 0; const struct rte_flow_action_age *non_shared_age = NULL; const struct rte_flow_action_count *count = NULL; + const struct mlx5_rte_flow_item_tag *mlx5_tag; struct mlx5_priv *act_priv = NULL; int aso_after_sample = 0; @@ -7621,7 +7631,7 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, last_item = MLX5_FLOW_LAYER_ICMP6; break; case RTE_FLOW_ITEM_TYPE_TAG: - ret = flow_dv_validate_item_tag(dev, items, + ret = flow_dv_validate_item_tag(dev, items, &tag_bitmap, attr, error); if (ret < 0) return ret; @@ -7631,6 +7641,13 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, last_item = MLX5_FLOW_ITEM_SQ; break; case MLX5_RTE_FLOW_ITEM_TYPE_TAG: + mlx5_tag = (const struct mlx5_rte_flow_item_tag *)items->spec; + if (tag_bitmap & (1 << mlx5_tag->id)) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM_SPEC, + items->spec, + "Duplicated tag index"); + tag_bitmap |= 1 << mlx5_tag->id; break; case RTE_FLOW_ITEM_TYPE_GTP: ret = flow_dv_validate_item_gtp(dev, items, item_flags, -- 2.27.0