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 1526543C27; Wed, 28 Feb 2024 14:33:49 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DE1354111C; Wed, 28 Feb 2024 14:33:48 +0100 (CET) Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2069.outbound.protection.outlook.com [40.107.100.69]) by mails.dpdk.org (Postfix) with ESMTP id 9CB2B40A70 for ; Wed, 28 Feb 2024 14:33:47 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=StjHNJYyE7fNHrtOMRDHq9v1WJ/MGgAWI6MdZjX+tiCKw/g2FRlAXTD+poi8Kth7kO1XrhmnaoBnOoJJA2TP4Fh6SGAo1RBTVyZKnVcEgSTLgu+Kr7tcyWu4FMfFd3xktMkOYh2LL38SF2pS1dfLNfSJ41AHKvXBQo9ItjlRiYcmIJp7FGQErjN4SOUOwr5rYHOIgk6MIGqP1ium5K976UIOVSUNS6Ol7+j9MTfAlUwTRdNGRTPU5t/t/l96jGmtZj++loTdyTLvhj3x/oFOkRcQyWrtdHptRASg/2uVQXkBpQY5x3/Gy/zGIDytMY2ClAu+BGd5WshfmrDfZqvyiA== 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=/NHocJFdwyH7kRXN3FYPhBnacIMi3VasUtxeVf2V30o=; b=T0pwFx5GrxnPnxhXzTBN7CL4ug8GPDZkHR8dfXSNly4PShZgIgELB2Ca7fuR0oVuD+7kVjg/sDWNY5oIrCo2sSuvYguZsbZq4k+86rpslBH/7csXCfTJnUzjH9RBJUnoFFTqplcW9oueJXpsk1beWHLzYt5O5c9kzySPZvUkn00Ar9vlbkMDZgF4KRiLh2/cEK0mthL+k8A6BKrXdU7wZAUvSV6PFsmyzKQJGNY5ioG0cxE0oFkPhi9b3aOCUp/4yuy6JYI+IXrdZUA2Brw5kambfGtL+2UqHmYUn8gl+9FE/KKiyhIJPdlvxEtfEyEGBBScn2PKWDPrGPTR7HzW4g== 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=/NHocJFdwyH7kRXN3FYPhBnacIMi3VasUtxeVf2V30o=; b=JxzrjwRRCywulQad2mz7vQKs0X94EJC9+zIa9kEbeUE+Z15MfiQiuydy06Fyzp8J80DKFI+lUjDPLktXjW+MSujd2gJRoGWM6CepgfzVhU1cqol7Xpf06ujpQohulp87DzT7pEc3Vdxlj+fUGlDGD5Vonons/hxxJ9l+++CGIl9IvQ88oXB/2/uz0kuT33KtXJXjrXh1ENZSnALj4MHdwPw1Pxrz2ljzLnj0hDOrY6LC4ip3BbWNQ1L5JaSWv3YG1gb6nHCyfQ1K9ZRi68M0FntrSdqSCu27sHcspOojKIZ4kIpOYyshDWNGXHX1xeBGzBwKK1gvAus06Ij2dgQzOQ== Received: from CH2PR05CA0027.namprd05.prod.outlook.com (2603:10b6:610::40) by SN7PR12MB6862.namprd12.prod.outlook.com (2603:10b6:806:265::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.34; Wed, 28 Feb 2024 13:33:45 +0000 Received: from CH2PEPF000000A0.namprd02.prod.outlook.com (2603:10b6:610:0:cafe::4b) by CH2PR05CA0027.outlook.office365.com (2603:10b6:610::40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.25 via Frontend Transport; Wed, 28 Feb 2024 13:33:44 +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 CH2PEPF000000A0.mail.protection.outlook.com (10.167.244.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.25 via Frontend Transport; Wed, 28 Feb 2024 13:33:44 +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; Wed, 28 Feb 2024 05:33:32 -0800 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.1258.12; Wed, 28 Feb 2024 05:33:28 -0800 From: Gregory Etelson To: CC: , , , Dariusz Sosnowski , Viacheslav Ovsiienko , Ori Kam , Suanming Mou , Matan Azrad Subject: [PATCH v3 1/4] net/mlx5: add resize function to ipool Date: Wed, 28 Feb 2024 15:33:09 +0200 Message-ID: <20240228133312.474474-2-getelson@nvidia.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240228133312.474474-1-getelson@nvidia.com> References: <20240202115611.288892-2-getelson@nvidia.com> <20240228133312.474474-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: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF000000A0:EE_|SN7PR12MB6862:EE_ X-MS-Office365-Filtering-Correlation-Id: b3e05261-3aa4-417d-ab12-08dc3861e2dd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: e+anZkjrweNaxvboMyHrRMZNZCzC5nj5sODEo4TVwsx/we3OXkGgN6Qr6fgvnqoYtD0U/77+jxCtAdE9TkthW4qFGvI3H1o+YDAdvcb0cM0t1SInJ2dKHHySzFMfjVqaVjfCtzYhxeks9rqnY26IIozZCBZwzRn/hSMVB9ARlXhCHIY3BtIuG4osA7Q8nh4hD/5Fzm3TohfZzPACtGhiytCg2SnaSnIc9I73baCLm/l2p8s+CnJLz3QmR156nDNgQfMc3UpU2KeZnywC/ypquh5kV7wsTvx/RZM033KLVyFGyqsEf0eWOi9Dm43LmQBGF2VNPDbF42/U36lIQbJclJ5TlxtlWuklgsDZbar16P0h9Kp1qO76ZwWtyAP3jsRM6Po/a9wQlxPgQ/LJsexDMhvs6dNbW9eBNs2CvVMLpgCsu0PL5u7TViDaZWIbUH6eWtAQ+IqAXRZQI8DcN07/DZO6g0E5VtNCoSmq2PD6vnoynKbgu5OXBQgLYT9TiBcO4qValE4XwP/vtOyy+fzQisVb1LJbYNBvwuC7jW9doEFw3f8hi5mz1MhwjgZGd3v5GDHYfRzGEDz8rqz++NuZwVm0jW9WbavGr00HR1lzVV5vm5Aly/UbscxFc/zMlQHsB7lQFyDO4EQLl8qkqmedA5VmVslkq5hpk4iu7QRBuTlseBb4OivHRtuMnwuO1ARTrIUkBHEVc07yqSO7cxpGOafiX9wag3j7Pm5WibG+4k9prd1v+O+yXd0zyHbmDFOD 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)(82310400014)(36860700004); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Feb 2024 13:33:44.7366 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b3e05261-3aa4-417d-ab12-08dc3861e2dd 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: CH2PEPF000000A0.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB6862 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: Maayan Kashani Before this patch, ipool size could be fixed by setting max_idx in mlx5_indexed_pool_config upon ipool creation. Or it can be auto resized to the maximum limit by setting max_idx to zero upon ipool creation and the saved value is the maximum index possible. This patch adds ipool_resize API that enables to update the value of max_idx in case it is not set to maximum, meaning not in auto resize mode. It enables the allocation of new trunk when using malloc/zmalloc up to the max_idx limit. Please notice the resize number of entries should be divisible by trunk_size. Signed-off-by: Maayan Kashani Acked-by: Dariusz Sosnowski --- drivers/net/mlx5/mlx5_utils.c | 29 +++++++++++++++++++++++++++++ drivers/net/mlx5/mlx5_utils.h | 16 ++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/drivers/net/mlx5/mlx5_utils.c b/drivers/net/mlx5/mlx5_utils.c index 4db738785f..e28db2ec43 100644 --- a/drivers/net/mlx5/mlx5_utils.c +++ b/drivers/net/mlx5/mlx5_utils.c @@ -809,6 +809,35 @@ mlx5_ipool_get_next(struct mlx5_indexed_pool *pool, uint32_t *pos) return NULL; } +int +mlx5_ipool_resize(struct mlx5_indexed_pool *pool, uint32_t num_entries) +{ + uint32_t cur_max_idx; + uint32_t max_index = mlx5_trunk_idx_offset_get(pool, TRUNK_MAX_IDX + 1); + + if (num_entries % pool->cfg.trunk_size) { + DRV_LOG(ERR, "num_entries param should be trunk_size(=%u) multiplication\n", + pool->cfg.trunk_size); + return -EINVAL; + } + + mlx5_ipool_lock(pool); + cur_max_idx = pool->cfg.max_idx + num_entries; + /* If the ipool max idx is above maximum or uint overflow occurred. */ + if (cur_max_idx > max_index || cur_max_idx < num_entries) { + DRV_LOG(ERR, "Ipool resize failed\n"); + DRV_LOG(ERR, "Adding %u entries to existing %u entries, will cross max limit(=%u)\n", + num_entries, cur_max_idx, max_index); + mlx5_ipool_unlock(pool); + return -EINVAL; + } + + /* Update maximum entries number. */ + pool->cfg.max_idx = cur_max_idx; + mlx5_ipool_unlock(pool); + return 0; +} + void mlx5_ipool_dump(struct mlx5_indexed_pool *pool) { diff --git a/drivers/net/mlx5/mlx5_utils.h b/drivers/net/mlx5/mlx5_utils.h index 82e8298781..f3c0d76a6d 100644 --- a/drivers/net/mlx5/mlx5_utils.h +++ b/drivers/net/mlx5/mlx5_utils.h @@ -427,6 +427,22 @@ void mlx5_ipool_flush_cache(struct mlx5_indexed_pool *pool); */ void *mlx5_ipool_get_next(struct mlx5_indexed_pool *pool, uint32_t *pos); +/** + * This function resize the ipool. + * + * @param pool + * Pointer to the index memory pool handler. + * @param num_entries + * Number of entries to be added to the pool. + * This number should be divisible by trunk_size. + * + * @return + * - non-zero value on error. + * - 0 on success. + * + */ +int mlx5_ipool_resize(struct mlx5_indexed_pool *pool, uint32_t num_entries); + /** * This function allocates new empty Three-level table. * -- 2.39.2