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 4F8D343238; Sun, 29 Oct 2023 17:34:19 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B13B1410D0; Sun, 29 Oct 2023 17:33:16 +0100 (CET) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2082.outbound.protection.outlook.com [40.107.220.82]) by mails.dpdk.org (Postfix) with ESMTP id C3048411F3 for ; Sun, 29 Oct 2023 17:33:14 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hqGfnx8NS4LQOFNOehfSnaaq9UwdueeXJID1/LCOBgIYHdXpMX2CtPIjIYBE+goqlf+ttT8oQyuwj+IzEWa3KlA2SOhOjeQ7SKLp0qqR2rzgdJGAvwgSJPtzTlZ/3FuuOXeuN5ueUVc6f2bz0AKl6KXjnohr6/AqBmXjGarnvId8qIiAvtdCJVoOeEkHQKAK9VIcMx5vvVkOIUNoq//yWs1YAP1fDKJO50pHGwpkCSM+0digM+QQfTGx0lCDotpTFyp0I/gWR1qKPYej1U0+8IqbERmo7dPtdVIUX8xftOfr+STUBdSq7u0mG8YpqqawzxbaKMANJa0JjWW2yuBK0w== 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=0aVBD2mtzeAL8YMyqf6ag3r3vixxiNKYrTyVrlUAmHo=; b=Xr8fRyorIRV6709GAgIdWLjDtg/8uHXq4KzL7jZFLuh5YBAE2XJGZihhZ6F/40/J9R9tOj21CG2inYiVyxZeoR2fqP60Ra5mIQV+6u1NMeun96L56Y3+Aln6i93gbtQg9QLlucRrmjRRSYjq82SJ/P77/7e49p+5pIw8yhp9aBYqv+xTDNe2ZA/Y5mTKUtW4hHjrkciYnXeYE/vPSQYFN7dXJ60ZCq+jmD7pgzB2OWVPOj1+G0gIGuCXu6jnpia/tnObt0dBGlxoFro9yk69GyNd1+GDIB2suyjDMpWvIBVZTDIO8RX22jiT7GNhE7YRU79eVsvhTz13XrtlbtpYNQ== 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 (0) 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=0aVBD2mtzeAL8YMyqf6ag3r3vixxiNKYrTyVrlUAmHo=; b=M/j1ppZ4U6agJtBz/msJOGzfyusFg5Kqy9y8M+VZOucd7xFZ0l4Kxt1GHPnDttBBnyfHDvAgXHBg9No6eygQ+S5ata95jfGURKtbTIFAAFY2fDbzfCwtRDpJmNRQ1+Flx2C7X1m+kbmeW1jC0gwMzAladniuZ5ioBCUBdJczGTXco1YDF2GWq5RrzwSZmubjmfm70D69Cu0xnMIwH/E/7I7L937ioaAT4PjpetYBb85UoMcg8fbayeUjw2zhmnKB9WnFxlgBxBWs45ySOsBVZ6ic7wFxHamvwhwwuf1+6A5DsQiFYd/66mNiaQTLrt1qvhjYVnPS6qYnn4FNFRyJIw== Received: from BL1PR13CA0082.namprd13.prod.outlook.com (2603:10b6:208:2b8::27) by SJ1PR12MB6025.namprd12.prod.outlook.com (2603:10b6:a03:48c::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.26; Sun, 29 Oct 2023 16:33:11 +0000 Received: from BL02EPF0001A100.namprd03.prod.outlook.com (2603:10b6:208:2b8:cafe::17) by BL1PR13CA0082.outlook.office365.com (2603:10b6:208:2b8::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.14 via Frontend Transport; Sun, 29 Oct 2023 16:33:10 +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 BL02EPF0001A100.mail.protection.outlook.com (10.167.242.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.15 via Frontend Transport; Sun, 29 Oct 2023 16:33:10 +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.41; Sun, 29 Oct 2023 09:32:58 -0700 Received: from nvidia.com (10.126.231.35) 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.41; Sun, 29 Oct 2023 09:32:55 -0700 From: Gregory Etelson To: CC: , , , "Ori Kam" , Matan Azrad , Viacheslav Ovsiienko , Suanming Mou Subject: [PATCH 13/30] net/mlx5: add validation support for tags Date: Sun, 29 Oct 2023 18:31:45 +0200 Message-ID: <20231029163202.216450-13-getelson@nvidia.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231029163202.216450-1-getelson@nvidia.com> References: <20231029163202.216450-1-getelson@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.231.35] 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: BL02EPF0001A100:EE_|SJ1PR12MB6025:EE_ X-MS-Office365-Filtering-Correlation-Id: 437a1206-a456-4aae-0d39-08dbd89cbd77 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hhxPniEptXL8AOQ11fHqk2Yl/brRniJKghlROMMEksGsFn7qhmakwugtNWoZXP3s643zt/Dd5ckvrJDJi+YUr138R6e9rVHLKiFVwSOhPPKUd6aQtiYI6z9CFkpI74L19F9y+RaAF3RIU0CdwWYVuCLZIJTMjhoxqZewAnFQTX2gWWbfF2LztaY/Cl2x/eIbqLBc8m9QW618ncbzbMnKD5Ko1HGXffT0IbY9ZtYKWO5a/uJXOG/tS7s8R/A6JTh+JATH77nT7YG/z6d1/UOSmD7ySEU858zZQCBzK+QTXDd7AA52iI2g3GiOZrLQgtUbFI8BdcIfkisrX6b5jpiVTnULkhuecTui5vPkzOGGaMa5ECNAD2soN/yb1+pgWpanuqiRhxx+saazXLRgQYhnXEWUYykZlJVauu+Sn7BQ92b6Uk1bRFToUeZuZxrYIEFs/+Xeko9z7Bo+m+iqZTdw0FS+WPEZuu+glQAeAPi3CrZHHxMxtH4GV5ggBSAYZaaB116q8YE3ynbT4nJSpfenc+COLWU0AZ2N9b5aOzOAXRRaXdwNtCyu7r7bjW7xtSIB9Zoojj+XtBhF+AyIQgoPTdmkm1hSaPJo+ZFaFOJza1Uo35mBZ7zorwTQrxUSX+m5YyhJU0yzmdK15xfyTdCwmeWnqgKqgu7fp69YF3q9x4EdIG/W0pUFIVTkNtFW1u9M8WlPl3dDPo262hL4ehPmaPZaAE8ZcIziXi/Abz/IkXxkfoddazC4meYhVnovmeL+ 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:(13230031)(4636009)(346002)(396003)(136003)(39860400002)(376002)(230922051799003)(82310400011)(451199024)(64100799003)(186009)(1800799009)(40470700004)(36840700001)(46966006)(40460700003)(36756003)(26005)(16526019)(6286002)(1076003)(83380400001)(7636003)(426003)(336012)(5660300002)(356005)(6666004)(7696005)(2616005)(107886003)(82740400003)(8936002)(8676002)(47076005)(54906003)(316002)(41300700001)(6916009)(36860700001)(55016003)(40480700001)(70586007)(86362001)(478600001)(70206006)(2906002)(4326008); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2023 16:33:10.6375 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 437a1206-a456-4aae-0d39-08dbd89cbd77 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: BL02EPF0001A100.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ1PR12MB6025 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 From: Ori Kam This commit introduce validation for invalid tags Signed-off-by: Ori Kam --- drivers/net/mlx5/mlx5_flow_hw.c | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c index ceeb82a649..6fc649d736 100644 --- a/drivers/net/mlx5/mlx5_flow_hw.c +++ b/drivers/net/mlx5/mlx5_flow_hw.c @@ -4049,7 +4049,8 @@ flow_hw_modify_field_is_used(const struct rte_flow_action_modify_field *action, } static int -flow_hw_validate_action_modify_field(const struct rte_flow_action *action, +flow_hw_validate_action_modify_field(struct rte_eth_dev *dev, + const struct rte_flow_action *action, const struct rte_flow_action *mask, struct rte_flow_error *error) { @@ -4118,6 +4119,22 @@ flow_hw_validate_action_modify_field(const struct rte_flow_action *action, if (ret) return ret; } + if ((action_conf->dst.field == RTE_FLOW_FIELD_TAG && + action_conf->dst.tag_index >= MLX5_FLOW_HW_TAGS_MAX && + action_conf->dst.tag_index != MLX5_LINEAR_HASH_TAG_INDEX) || + (action_conf->src.field == RTE_FLOW_FIELD_TAG && + action_conf->src.tag_index >= MLX5_FLOW_HW_TAGS_MAX && + action_conf->src.tag_index != MLX5_LINEAR_HASH_TAG_INDEX)) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, action, + "tag index is out of range"); + if ((action_conf->dst.field == RTE_FLOW_FIELD_TAG && + flow_hw_get_reg_id(dev, RTE_FLOW_ITEM_TYPE_TAG, action_conf->dst.tag_index) == REG_NON) || + (action_conf->src.field == RTE_FLOW_FIELD_TAG && + flow_hw_get_reg_id(dev, RTE_FLOW_ITEM_TYPE_TAG, action_conf->src.tag_index) == REG_NON)) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, action, + "tag index is out of range"); if (mask_conf->width != UINT32_MAX) return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, action, @@ -4728,7 +4745,7 @@ mlx5_flow_hw_actions_validate(struct rte_eth_dev *dev, action_flags |= MLX5_FLOW_ACTION_METER; break; case RTE_FLOW_ACTION_TYPE_MODIFY_FIELD: - ret = flow_hw_validate_action_modify_field(action, mask, + ret = flow_hw_validate_action_modify_field(dev, action, mask, error); if (ret < 0) return ret; @@ -5596,7 +5613,14 @@ flow_hw_pattern_validate(struct rte_eth_dev *dev, if (tag == NULL) return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, - NULL, "Tag spec is NULL"); + NULL, + "Tag spec is NULL"); + if (tag->index >= MLX5_FLOW_HW_TAGS_MAX && + tag->index != MLX5_LINEAR_HASH_TAG_INDEX) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, + "Invalid tag index"); tag_idx = flow_hw_get_reg_id(dev, RTE_FLOW_ITEM_TYPE_TAG, tag->index); if (tag_idx == REG_NON) return rte_flow_error_set(error, EINVAL, -- 2.39.2