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 21CC343238; Sun, 29 Oct 2023 17:33:40 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6140440EE1; Sun, 29 Oct 2023 17:33:07 +0100 (CET) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2080.outbound.protection.outlook.com [40.107.243.80]) by mails.dpdk.org (Postfix) with ESMTP id 36E9A40A67 for ; Sun, 29 Oct 2023 17:33:05 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CZLyBpyv99PaBrJxh/ntm1P4/8Th/w2O+Ro0ud8eZJ+IEhAph71RNvi357I/C6PzxotJDZUMN1ju64m4+Ws8j6Id9URzjX1apaOAkVp3oIH8AGUJfvKHxYi01PdlP10risC840ThTC3E+OGNgEzFNTub/3dBMW+ceISNlOu+RgNujNOFXCOvGnoavYzwfhV38/svlAYAjj2ovanDBlrv+584PxZvqNbfD2mNOUCatmLmznQoc38TrMIafiFwpnqYZcf+rSNfG6Fy3YCt+fK3xvU5S+knP8MZQkrBoIlwdT0/gcYfnvW9PWLBkCwoz21gHv1QO7m7tt8gAjjeUlhxGg== 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=Zd+b1YEtUO1NkuFwywG555Uf2A5f61eNLYCa+q39Z6U=; b=oM5yggUJT3iYrXC9mjjb4eSHDnIA2towZ/ghwwugFOkivrw49GPZj5TGRtbyjOevNnq6xO2VOjDZ6T6XNUMPXd9xSZ0iqIAXGVHKDDJHU+O1Ypk672lki8bsFbcjU1Tzvz33HQ8A3M8PKRAaMBXZ12oR8yLY3HSo443cWbcerv1GjLZEgPka8+P+oPx8HyWuOt+919t1lRrAIASBpXRZH0NJnGCc2MyE6q6OpaE/OcH7RJdKC1iuSgAXMG8WmDSnM2pqccQVyBLu16A33X+Ig/+poIo0Yn7yE57Ph+swt9XcugCq8WrqAnyAIA0AmSZU72Ji0DG25MIB5iy4ayiP7g== 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=Zd+b1YEtUO1NkuFwywG555Uf2A5f61eNLYCa+q39Z6U=; b=Yp8CP5myou0ebCFn34nE1VHocButHWJ+ZGQZ13+72HwE7oLiQnFQ13+bNsRk7r8xjYUZUA7TfaHqdJqbC2s22YTLoRMDTNNPADftzT1/QgxksaNEhsYpvRiYjhyuQxCIVlVDz9SPqqeDZbzcb7NhLJNOAIgsQ6o51rbzGhTYdgxAUWrESgTETbKpE9UuKiVqkJq8whz0Te++kENBfTMjWzOpVtOgcf2wgHsGaY2o1Hf6utlywTy22wcUHxyUoBZjfuw8eaMobmYubDOzbHx3kZ9p7ZwLE7WuJZIiDUECHcKiMZDWTumZtT1fsqPXXbAMUuY7Z2Kbyrjfd82Hdi75tQ== Received: from MN2PR16CA0019.namprd16.prod.outlook.com (2603:10b6:208:134::32) by PH7PR12MB5783.namprd12.prod.outlook.com (2603:10b6:510:1d2::9) 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:01 +0000 Received: from BL02EPF0001A0FC.namprd03.prod.outlook.com (2603:10b6:208:134:cafe::12) by MN2PR16CA0019.outlook.office365.com (2603:10b6:208:134::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.34 via Frontend Transport; Sun, 29 Oct 2023 16:33:01 +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 BL02EPF0001A0FC.mail.protection.outlook.com (10.167.242.103) 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:00 +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:45 -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:42 -0700 From: Gregory Etelson To: CC: , , , "Ori Kam" , Matan Azrad , Viacheslav Ovsiienko , Suanming Mou Subject: [PATCH 09/30] net/mlx5: add support for calc hash Date: Sun, 29 Oct 2023 18:31:41 +0200 Message-ID: <20231029163202.216450-9-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: BL02EPF0001A0FC:EE_|PH7PR12MB5783:EE_ X-MS-Office365-Filtering-Correlation-Id: 9de97d29-dc93-4fbe-3072-08dbd89cb7b5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /El+sayswO28vB74jNm8exBHQFlgAYbfbsd85Sf5Ebvaa2mpHcs+r0LRQCIokaHkAmcasKJVpG0No0QYxM7EW8m/NXrV3EL6QK7BZO/luEe9shTcDOc468bFp8Gkn90O4hvb/QLhtR0pMwDH7f6bNGfJ1ITLmWsiOxvonqy9a/JXsx/m51NaWuOUShVXV0ioovY3hIQ8bukUjNHKfI3DlnIf+xFd5u6/4OkiYAjLa4ZoA/1x3Ahua/6Ku3BAUcveFrB+BHiGhZxgwLi1cF1GtNVL36KgNLnLmPsAK+PVjheeP7hzmbnHS45cjXDBQ1qO1vBu7zg5QnJGV7EDETBRKMitVACYA9pV1CSKeVCHWYq2pQ62YKjSSgVcT8RSIt6o5CSw0MqlReR4ckeafoaEA24wdJV4jWZGGH4+HxfDtCsszQFj43jVpNoyl/0a4n9CE1YaEoT/glrpgQB8bsgT3OE0mRBZKXg7LkSo4rOo2Wgd5cc/f+YiTsgUHlW2OZEtWfW5o8Et+7TJCJ+Jhkr3hPK6E7YfhL1wJqrVHppkLR3G1FunJYOmwG5suVsVyESyEMx4M85A1B/f2STGRryUAMbgOhlbN1wu+5uSPX9OPx86gX5BZMCcToHq5OmQ8Seeep4IlKverPNRYqt247rFrAT5RHdioSa7kIKLebVKm+40+PUenll93rA8kWOnQwDpZG//ougzPrm5NNLvhGdGuUQyseT85AxFhP5FsKaGsxk= 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)(451199024)(64100799003)(1800799009)(82310400011)(186009)(40470700004)(46966006)(36840700001)(55016003)(2906002)(40460700003)(36860700001)(6916009)(54906003)(70206006)(70586007)(47076005)(356005)(7636003)(82740400003)(316002)(107886003)(7696005)(26005)(478600001)(83380400001)(2616005)(426003)(16526019)(6286002)(1076003)(336012)(41300700001)(5660300002)(8936002)(8676002)(4326008)(86362001)(40480700001)(36756003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2023 16:33:00.9784 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9de97d29-dc93-4fbe-3072-08dbd89cb7b5 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: BL02EPF0001A0FC.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB5783 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 adds calculate hash function support for mlx5 PMD. Signed-off-by: Ori Kam --- drivers/net/mlx5/mlx5_flow.c | 32 ++++++++++++++++++++++++++++++++ drivers/net/mlx5/mlx5_flow.h | 8 ++++++++ drivers/net/mlx5/mlx5_flow_hw.c | 31 ++++++++++++++++++++++++++++++- 3 files changed, 70 insertions(+), 1 deletion(-) diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index ad9a2f2273..819831cff8 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -1178,6 +1178,13 @@ mlx5_flow_async_action_list_handle_query_update(struct rte_eth_dev *dev, enum rte_flow_query_update_mode mode, void *user_data, struct rte_flow_error *error); +static int +mlx5_flow_calc_table_hash(struct rte_eth_dev *dev, + const struct rte_flow_template_table *table, + const struct rte_flow_item pattern[], + uint8_t pattern_template_index, + uint32_t *hash, struct rte_flow_error *error); + static const struct rte_flow_ops mlx5_flow_ops = { .validate = mlx5_flow_validate, .create = mlx5_flow_create, @@ -1231,6 +1238,7 @@ static const struct rte_flow_ops mlx5_flow_ops = { mlx5_flow_action_list_handle_query_update, .async_action_list_handle_query_update = mlx5_flow_async_action_list_handle_query_update, + .flow_calc_table_hash = mlx5_flow_calc_table_hash, }; /* Tunnel information. */ @@ -11058,6 +11066,30 @@ mlx5_flow_async_action_list_handle_query_update(struct rte_eth_dev *dev, } +static int +mlx5_flow_calc_table_hash(struct rte_eth_dev *dev, + const struct rte_flow_template_table *table, + const struct rte_flow_item pattern[], + uint8_t pattern_template_index, + uint32_t *hash, struct rte_flow_error *error) +{ + struct rte_flow_attr attr = { .transfer = 0 }; + enum mlx5_flow_drv_type drv_type = flow_get_drv_type(dev, &attr); + const struct mlx5_flow_driver_ops *fops; + + if (drv_type == MLX5_FLOW_TYPE_MIN || drv_type == MLX5_FLOW_TYPE_MAX) + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ACTION, + NULL, "invalid driver type"); + fops = flow_get_drv_ops(drv_type); + if (!fops || !fops->action_query_update) + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ACTION, + NULL, "no query_update handler"); + return fops->flow_calc_table_hash(dev, table, pattern, pattern_template_index, + hash, error); +} + /** * Destroy all indirect actions (shared RSS). * diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index aea8b38f39..64e2fc6f04 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -2059,6 +2059,13 @@ typedef int const void **update, void **query, enum rte_flow_query_update_mode mode, void *user_data, struct rte_flow_error *error); +typedef int +(*mlx5_flow_calc_table_hash_t) + (struct rte_eth_dev *dev, + const struct rte_flow_template_table *table, + const struct rte_flow_item pattern[], + uint8_t pattern_template_index, + uint32_t *hash, struct rte_flow_error *error); struct mlx5_flow_driver_ops { mlx5_flow_validate_t validate; @@ -2130,6 +2137,7 @@ struct mlx5_flow_driver_ops { action_list_handle_query_update; mlx5_flow_async_action_list_handle_query_update_t async_action_list_handle_query_update; + mlx5_flow_calc_table_hash_t flow_calc_table_hash; }; /* mlx5_flow.c */ diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c index b0ef14c14e..67ef272a2d 100644 --- a/drivers/net/mlx5/mlx5_flow_hw.c +++ b/drivers/net/mlx5/mlx5_flow_hw.c @@ -2773,7 +2773,7 @@ flow_hw_actions_construct(struct rte_eth_dev *dev, static const struct rte_flow_item * flow_hw_get_rule_items(struct rte_eth_dev *dev, - struct rte_flow_template_table *table, + const struct rte_flow_template_table *table, const struct rte_flow_item items[], uint8_t pattern_template_index, struct mlx5_hw_q_job *job) @@ -10143,6 +10143,34 @@ flow_hw_action_list_handle_query_update(struct rte_eth_dev *dev, update, query, mode, NULL, error); } +static int +flow_hw_calc_table_hash(struct rte_eth_dev *dev, + const struct rte_flow_template_table *table, + const struct rte_flow_item pattern[], + uint8_t pattern_template_index, + uint32_t *hash, struct rte_flow_error *error) +{ + const struct rte_flow_item *items; + /* Temp job to allow adding missing items */ + static struct rte_flow_item tmp_items[MLX5_HW_MAX_ITEMS]; + static struct mlx5_hw_q_job job = {.items = tmp_items}; + int res; + + items = flow_hw_get_rule_items(dev, table, pattern, + pattern_template_index, + &job); + res = mlx5dr_rule_hash_calculate(table->matcher, items, + pattern_template_index, + MLX5DR_RULE_HASH_CALC_MODE_RAW, + hash); + if (res) + return rte_flow_error_set(error, res, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, + "hash could not be calculated"); + return 0; +} + const struct mlx5_flow_driver_ops mlx5_flow_hw_drv_ops = { .info_get = flow_hw_info_get, .configure = flow_hw_configure, @@ -10186,6 +10214,7 @@ const struct mlx5_flow_driver_ops mlx5_flow_hw_drv_ops = { .get_q_aged_flows = flow_hw_get_q_aged_flows, .item_create = flow_dv_item_create, .item_release = flow_dv_item_release, + .flow_calc_table_hash = flow_hw_calc_table_hash, }; /** -- 2.39.2