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 BDC81439EC; Sun, 28 Jan 2024 11:23:12 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 709FA40DCD; Sun, 28 Jan 2024 11:23:03 +0100 (CET) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2079.outbound.protection.outlook.com [40.107.244.79]) by mails.dpdk.org (Postfix) with ESMTP id 30D8940A70 for ; Sun, 28 Jan 2024 11:23:02 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ksCUhXBUxi5Lez1D8386fgHrWXFGxZPQlVtsoA2DxAU5NWnHdXrq31pKynXBbSMmGsy4Zl07Q7ZWA//ero+UJsk0oNvrTODlC+qkhMogrmhX4AqBUaO99YRFk9nTNBvi5wN1SSxm8FTAubveB14JZ0mG0Do0duLrJgptzaJCM4zB3Xj8vF1w/0ewcsVSloXbC3UMhXuMD5iTjZPKS52eFGvycsVleU/DDNoEO+eFk9rVKPFqjOKDoD/6K8hcPfv7OHuEjF6SbhewJm4ONnynEjgEu7z9W9/5ObYFVIHxRiNS4NbmkqJfRRvBwh3tKO5iuzePj0wgFxitWhtaoDF+7Q== 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=ELfq3JM4ZMsXeGNNzSSj4MwLJk49O50Xu+D/1Tppa7M=; b=UGudceasCbCTjJTy9hsIrK8kQU8iDrL+kzVXS4iqlIQ1086K1XXUynEh/h/qSp+sKr16Jm4scXFlzoUqzLG9tFzWkVn514FZaFVbWz+cg3xeRg248jNlXdyVaxte+bPgxy/lhSKzQD7rzZsvyja7KcHyFafYAXx3PFsOsctg4F+OCHLPQaFwRzU564OZ34l+FxgSfUaibGDvNH+1vLijlCxVrrVfZEumw17AFi4w9cgiowzm3bp+mFtfY/DPnCd/AEDSY/jjwkzIVrRyDzW7O7s1KlCZGMQ0aQIywagNlaT6GEonBURDHD4+wVU+A0g52pLMqP4Noxtv/SbnznCd9w== 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=ELfq3JM4ZMsXeGNNzSSj4MwLJk49O50Xu+D/1Tppa7M=; b=S4MielFsoKiqQQQ7hcD4TRpsQSuOjd4BFZcYuem5qSC4JZQGuzp6nB7V6JcYwqDPczoreZJB6PR6O8ONOdnwbJHC2LASnQb5Yi7UTcQTuRnJp9WuUHvjA0tH0XK7cO7lea3q/ynofP/S5xkSHxg3ZhKpNsEXBAiGqGGj83+ltfUzzzjkWk4PMvgWcSLKZpLwiced1Tff+sIt6t24oId2CxZvSbc9CQHolIgkEUjvykbx8CXaK3lATiQrMErVrdG+12NYPVfx7dcFKs2zrFQ5iXhq3OMKIxzXSisNKdNGn4NtrEUvDYtKMR5xGOsK2ao1Bs1v2YL6R6VAZ8vyvwPouQ== Received: from MN2PR10CA0020.namprd10.prod.outlook.com (2603:10b6:208:120::33) by DM4PR12MB7526.namprd12.prod.outlook.com (2603:10b6:8:112::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.27; Sun, 28 Jan 2024 10:22:59 +0000 Received: from BL6PEPF0001AB4B.namprd04.prod.outlook.com (2603:10b6:208:120:cafe::c9) by MN2PR10CA0020.outlook.office365.com (2603:10b6:208:120::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.31 via Frontend Transport; Sun, 28 Jan 2024 10:22: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 BL6PEPF0001AB4B.mail.protection.outlook.com (10.167.242.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.19 via Frontend Transport; Sun, 28 Jan 2024 10:22:59 +0000 Received: from rnnvmail204.nvidia.com (10.129.68.6) 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, 28 Jan 2024 02:22:46 -0800 Received: from rnnvmail204.nvidia.com (10.129.68.6) by rnnvmail204.nvidia.com (10.129.68.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Sun, 28 Jan 2024 02:22:46 -0800 Received: from nvidia.com (10.127.8.13) by mail.nvidia.com (10.129.68.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41 via Frontend Transport; Sun, 28 Jan 2024 02:22:44 -0800 From: Michael Baum To: CC: Matan Azrad , Dariusz Sosnowski , Raslan Darawsheh , Viacheslav Ovsiienko , Ori Kam , Suanming Mou Subject: [PATCH v2 2/2] net/mlx5: add support to compare random value Date: Sun, 28 Jan 2024 12:22:34 +0200 Message-ID: <20240128102234.776861-3-michaelba@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240128102234.776861-1-michaelba@nvidia.com> References: <20231225104534.2420737-1-michaelba@nvidia.com> <20240128102234.776861-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: BL6PEPF0001AB4B:EE_|DM4PR12MB7526:EE_ X-MS-Office365-Filtering-Correlation-Id: 2988f5a9-f651-4962-40ab-08dc1feb1a04 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AR8Bbj1AEanpNmHl40uY7ihynQLQfSfIS+ObMLKrlVCQ3vavK/oRpnDe5SWi9UIoz7hztuXykHJFEyiCOJjO+mtr3iknsQOFFP8qGwGe/3g7ekyB1mH4SBi6XVy6Sn6FWOi09s4/GTM5RAt9GiUCp2LSTuNIcCVcMCgBpvw0PyvbgpluoaWaw8MRp0IGbwTqMum40AvjXKmlF399akvOQ6bQF10rkLRVRl3/5jxJbIRzLUROnpmdbC5cea7XKdIkyRuXzx301ZhsOfwqZoqrti/PXRV72bOHaVN3JT14uD2Y1sjHE58T19l5qH/5jfsQZpMLry9DBpZGelLxPW4Oq6b5+9KxXHsuXGDi2zyyiEp6WYvOT5TY4sc3qS8L/9NnVlPinws48Vs4zmbLKglpjLlZz2KsBg5LEwejE7qvqfnl+jAmp/eXFNfyCg9iqJXifKsvu23Ey98Yo5KdFCDrric/v5TYOcuDRjy2IgXTyX/ewkBtBeKRWS1Y/6QPBQI9y6S59+OkH6kZ+lR3lJ+J8dNRLGtSv7nB5GmJI2nkx6QmcSJXGdQke8Zbj8YPCDAxMPmH6nOHyduxNciV57w8CIrQb/Fs+vtZae7ETJ9Ddl5ny2O42kqbaEQhsGyPIQt/raRXipjANf8ep+GPZ2SeiatmHEfZn7g+AzyebaveqYf7d5XCQfq+Rv9TQ/VtbgObKuK3YtWtape7sAiZKdbWISPlFEvmcJyATWZ6rqA7ol2NVWQ5G8HnzkV1MW3mt/6a 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)(376002)(346002)(39860400002)(396003)(136003)(230922051799003)(1800799012)(82310400011)(186009)(451199024)(64100799003)(46966006)(40470700004)(36840700001)(40460700003)(40480700001)(55016003)(1076003)(6916009)(2616005)(107886003)(7696005)(6666004)(426003)(26005)(478600001)(6286002)(336012)(86362001)(54906003)(70206006)(70586007)(316002)(4326008)(83380400001)(8676002)(8936002)(47076005)(82740400003)(41300700001)(36756003)(5660300002)(356005)(7636003)(2906002)(36860700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jan 2024 10:22:59.1998 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2988f5a9-f651-4962-40ab-08dc1feb1a04 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: BL6PEPF0001AB4B.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB7526 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 --- drivers/net/mlx5/mlx5_flow_hw.c | 70 ++++++++++++++++++++++++--------- 1 file changed, 52 insertions(+), 18 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c index 01fdcbfed9..be303ea3a8 100644 --- a/drivers/net/mlx5/mlx5_flow_hw.c +++ b/drivers/net/mlx5/mlx5_flow_hw.c @@ -6686,18 +6686,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 @@ -6706,6 +6743,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, @@ -6717,19 +6755,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) @@ -6737,7 +6769,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