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 1BD6343BED; Mon, 26 Feb 2024 14:19:24 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EDF3A42E30; Mon, 26 Feb 2024 14:19:18 +0100 (CET) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2079.outbound.protection.outlook.com [40.107.94.79]) by mails.dpdk.org (Postfix) with ESMTP id BED8742E20 for ; Mon, 26 Feb 2024 14:19:16 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MVwjw4IiR8bzoI1j7WIWCEg0JW2ktJeq40AUzaVRwuTfm5OyQLvHQyJ7li9GEsGnJL3CYnHEi8747evOsAG66mnqFNeHL91YEDnWLD9X5dTu2jW14kLjE3vIDrcttfZQ6Tu3Nhz8BySTUZOlLN5lBcV2oNF1lGPGL3Q4TD6TgA0B121S9sRT8n6LpkuCA0lsSzL7+qeNFD07rCC+KWAE4n5p7A4wclgy2hItoRu8IExC1QqU3eQqT2SwJqkS4zQTDwno4oOj2UzF4YYpjS1W5yYYvZQHUsjqS5SBOEQno7+7sZ0yGcMHoG47v8aLv6cf3sCOGwEOLPaKXGZugrYdoA== 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=lGZFxIkuX1rIjffvq6FX2PuuC4SyYV23myD8DPwkqig=; b=en0fIo5X53gcEz3hZoooV6f6ORsyHd5HHqjQqvsPBDCvaH9J0TMZ4i8rpUj3zG+i9ErDxA9eB98wP70aIX87gYhwhCdL7ejTZMG1dhY8JRVu19Tvo8dxmGbpMc2pfrGl/Kf8t5URDLeJOrcp/PfvKECJiVqkTzRtOHB1hrxtViaEhvxUfqWF+G4ZC24QHfbDnMBH5iD9oKhJYetMxj14Yxka1COEAP/lceHCc+3A2BKLYJwrD4zuca+LNEsx+5XbwYcdBzV2QzImx7lUCoIIL8ohat2S6qgzhzz2fb61u6ReCvl1b6P+u7z7QlqVp3dYHrtFt7dsPvAkjDcIZ15fcw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) 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=lGZFxIkuX1rIjffvq6FX2PuuC4SyYV23myD8DPwkqig=; b=rwXt/Gn7v0OzHWA493SYNumcF1NTTuIs4VhMsDYRbQ8ycVhW1UefV/aPK+aAh3yZAqCkLmRAK9An9DN0P//9tywG3J2Wv2xMQCq0O7a2tSFhw4E4de/Fiyo+xgfWjjGtETzsVP0rW/HzF58DG9GgeGthYnFgZYW/qSssgRx6QvO8vXGfNurTk1Te8xW3Yq/hzxXes75SutSUXEL95P1Pp8qFi3H99xCSnCrIobDHruTc2ugGtEFl22tjk6jrcmofWKEQyulg8Vh070sE5QTnagMyuoHK8UDaWBQUw0ncjMbvflCZhGuZ3zKQDXplWowF4qQGr9Z4hTLMG5y8i9prMA== Received: from CH2PR14CA0004.namprd14.prod.outlook.com (2603:10b6:610:60::14) by DM4PR12MB6301.namprd12.prod.outlook.com (2603:10b6:8:a5::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.36; Mon, 26 Feb 2024 13:19:13 +0000 Received: from DS3PEPF000099E1.namprd04.prod.outlook.com (2603:10b6:610:60:cafe::ab) by CH2PR14CA0004.outlook.office365.com (2603:10b6:610:60::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.49 via Frontend Transport; Mon, 26 Feb 2024 13:19:13 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) 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.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.233) by DS3PEPF000099E1.mail.protection.outlook.com (10.167.17.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.25 via Frontend Transport; Mon, 26 Feb 2024 13:19:13 +0000 Received: from drhqmail202.nvidia.com (10.126.190.181) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Mon, 26 Feb 2024 05:19:00 -0800 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail202.nvidia.com (10.126.190.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.12; Mon, 26 Feb 2024 05:18:59 -0800 Received: from nvidia.com (10.127.8.13) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.12 via Frontend Transport; Mon, 26 Feb 2024 05:18:57 -0800 From: Michael Baum To: CC: Matan Azrad , Dariusz Sosnowski , Raslan Darawsheh , Viacheslav Ovsiienko , Ori Kam , Suanming Mou Subject: [PATCH v7 2/3] net/mlx5: add support to compare random value Date: Mon, 26 Feb 2024 15:18:47 +0200 Message-ID: <20240226131848.2982242-3-michaelba@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240226131848.2982242-1-michaelba@nvidia.com> References: <20240226130324.2981025-1-michaelba@nvidia.com> <20240226131848.2982242-1-michaelba@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099E1:EE_|DM4PR12MB6301:EE_ X-MS-Office365-Filtering-Correlation-Id: 6ce4f9e6-e21d-47c4-6283-08dc36cd86d4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yMsYpLkjh0k57mdlF0Oy/ADPnxxFUA0p1A+AqjXH6eVmT0lmXyKTC5dZe3A71BuwYgenf2JhRLf5gyY2p2fPR/itJnno/woRiRYS0ghjVIv4i5x0fws/6caUsO9rAknXtYwotzlqOzCZ1NqVtdMDB1EGun4a8WZ3pQi/yF4AY9EHCaPei9oeiSCMmzuYwb3dsRUmc+4m4mBngbAcq5Ge1di+JzWJbhuI3QwWXd9upV2j/PJMaWZ2QJw+buGzJcXmqhsYgcNP2C25co5Z1ll3/uB/+KWQ6a67B+/lJGQdIFYbF1XaFNj2KxVmxiWzfaxn40vRI8ir/Rs7tGVN414GYc7kxjAoNYe0SLy4Q1C5Buf/VRVhCW71VD6wn8dej9r9249IQ1KCU9qzhU7eJ8Jw9xyFxldM49IQ+7zZRiBzTno3IXA1gBb+RneuE+E68Iep0CRFTDRWMFoihisWR2x6J1Bgkv+/t4mMBlSc410IIrUUuH6szbvz53GxSJa2Uo9aY+oKNmVa2FeQ/JWHcjtYuWa0rAIm3ky2VanPsVZoIhuj9qlQk6krZOOORWjxTlVQ9v+Je2yZqYR+sOYpcqNcQKB6YkFaZ+wkn5WjrqG2sqg73dqati6U4KPfdexNxSVX+hF21Duc9yBRBeWxixjtC3GX3e9XZt8wqvmQa2n3GRfUzzNUTwtHgBKc5MtVG5jTxc3LWrU2a6pz2Iensr5TYo6MS9m8rBZgWoaEi52uLewwyZb+ERkEeyW3rz7Lr4E9 X-Forefront-Antispam-Report: CIP:216.228.118.233; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge2.nvidia.com; CAT:NONE; SFS:(13230031)(36860700004); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Feb 2024 13:19:13.6622 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6ce4f9e6-e21d-47c4-6283-08dc36cd86d4 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.233]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS3PEPF000099E1.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6301 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 Add support to use "RTE_FLOW_ITEM_TYPE_COMPARE" with "RTE_FLOW_FIELD_RAMDOM" as an argument. The random field is supported only when base is an immediate value, random field cannot be compared with enother field. Signed-off-by: Michael Baum Acked-by: Suanming Mou --- doc/guides/nics/mlx5.rst | 9 ++++- drivers/net/mlx5/mlx5_flow_hw.c | 70 ++++++++++++++++++++++++--------- 2 files changed, 59 insertions(+), 20 deletions(-) diff --git a/doc/guides/nics/mlx5.rst b/doc/guides/nics/mlx5.rst index 0d2213497a..c0a5768117 100644 --- a/doc/guides/nics/mlx5.rst +++ b/doc/guides/nics/mlx5.rst @@ -431,8 +431,13 @@ Limitations - Only supported in HW steering(``dv_flow_en`` = 2) mode. - Only single flow is supported to the flow table. - - Only 32-bit comparison is supported. - - Only match with compare result between packet fields is supported. + - Only single item is supported per pattern template. + - Only 32-bit comparison is supported or 16-bits for random field. + - Only supported for ``RTE_FLOW_FIELD_META``, ``RTE_FLOW_FIELD_TAG``, + ``RTE_FLOW_FIELD_RANDOM`` and ``RTE_FLOW_FIELD_VALUE``. + - The field type ``RTE_FLOW_FIELD_VALUE`` must be the base (``b``) field. + - The field type ``RTE_FLOW_FIELD_RANDOM`` can only be compared with + ``RTE_FLOW_FIELD_VALUE``. - No Tx metadata go to the E-Switch steering domain for the Flow group 0. The flows within group 0 and set metadata action are rejected by hardware. diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c index 3ae1220587..f31ba2df2b 100644 --- a/drivers/net/mlx5/mlx5_flow_hw.c +++ b/drivers/net/mlx5/mlx5_flow_hw.c @@ -6721,18 +6721,55 @@ flow_hw_prepend_item(const struct rte_flow_item *items, return copied_items; } -static inline bool -flow_hw_item_compare_field_supported(enum rte_flow_field_id field) +static int +flow_hw_item_compare_field_validate(enum rte_flow_field_id arg_field, + enum rte_flow_field_id base_field, + struct rte_flow_error *error) { - switch (field) { + switch (arg_field) { + case RTE_FLOW_FIELD_TAG: + case RTE_FLOW_FIELD_META: + break; + case RTE_FLOW_FIELD_RANDOM: + if (base_field == RTE_FLOW_FIELD_VALUE) + return 0; + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, + "compare random is supported only with immediate value"); + default: + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, + "compare item argument field is not supported"); + } + switch (base_field) { case RTE_FLOW_FIELD_TAG: case RTE_FLOW_FIELD_META: case RTE_FLOW_FIELD_VALUE: - return true; + break; + default: + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, + "compare item base field is not supported"); + } + return 0; +} + +static inline uint32_t +flow_hw_item_compare_width_supported(enum rte_flow_field_id field) +{ + switch (field) { + case RTE_FLOW_FIELD_TAG: + case RTE_FLOW_FIELD_META: + return 32; + case RTE_FLOW_FIELD_RANDOM: + return 16; default: break; } - return false; + return 0; } static int @@ -6741,6 +6778,7 @@ flow_hw_validate_item_compare(const struct rte_flow_item *item, { const struct rte_flow_item_compare *comp_m = item->mask; const struct rte_flow_item_compare *comp_v = item->spec; + int ret; if (unlikely(!comp_m)) return rte_flow_error_set(error, EINVAL, @@ -6752,19 +6790,13 @@ flow_hw_validate_item_compare(const struct rte_flow_item *item, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, "compare item only support full mask"); - if (!flow_hw_item_compare_field_supported(comp_m->a.field) || - !flow_hw_item_compare_field_supported(comp_m->b.field)) - return rte_flow_error_set(error, ENOTSUP, - RTE_FLOW_ERROR_TYPE_UNSPECIFIED, - NULL, - "compare item field not support"); - if (comp_m->a.field == RTE_FLOW_FIELD_VALUE && - comp_m->b.field == RTE_FLOW_FIELD_VALUE) - return rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_UNSPECIFIED, - NULL, - "compare between value is not valid"); + ret = flow_hw_item_compare_field_validate(comp_m->a.field, + comp_m->b.field, error); + if (ret < 0) + return ret; if (comp_v) { + uint32_t width; + if (comp_v->operation != comp_m->operation || comp_v->a.field != comp_m->a.field || comp_v->b.field != comp_m->b.field) @@ -6772,7 +6804,9 @@ flow_hw_validate_item_compare(const struct rte_flow_item *item, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, "compare item spec/mask not matching"); - if ((comp_v->width & comp_m->width) != 32) + width = flow_hw_item_compare_width_supported(comp_v->a.field); + MLX5_ASSERT(width > 0); + if ((comp_v->width & comp_m->width) != width) return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, -- 2.25.1