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 A6F2845BA1; Wed, 30 Oct 2024 05:42:59 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9671D42FB9; Wed, 30 Oct 2024 05:42:59 +0100 (CET) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2086.outbound.protection.outlook.com [40.107.236.86]) by mails.dpdk.org (Postfix) with ESMTP id 4072A42EC5 for ; Wed, 30 Oct 2024 05:42:58 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=hH2eooUjlXpwzTTmXGaSI3fuoJYAdwsbiR6pVwTerIYIceE1FO8GENMHr321/jnmHx5JdFxMuRmdVNpl/G6HgPSpGWxfwIzWQFm1c0lzW1QqKcaIbUIlUbd/Dzf9zhJQyxBYOLUCXKoo5K0r4jeF2Bz3GDJp64JDAa+dqVHU+V4FxAVYLjDbkgUKUMd6bKkGxur8rHCo5hPs55404oosuxtg7KlZR1/Oewji94ppFzA8E2ZdbYKMYP4PADNj0+0fFUjKXVxfSPJllJuNj1S5rvdEMyovJeBA4rF6Ogu89wrmcCBAtVLpmXICTsSpP+aJC4L2SbZghHaDrTbV8ryngg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=nWD9ajWJjTDfGPu8m/UN2qeJgjvtZczbQeqqmF8///8=; b=eVHmvKHDfM/M3Td2Uh2coIzhX9wOKSBo9eMeFmZN0arFomgn2Z8yhsjrDeMdCSE73/K8jbF/PVCqJVdN2YxhzE4prHibxroSDSDsF41eBlrTcFnUB7BAcnFGhkJHPKzhhRJgh+SPmUF5BljzWoN96IeSmrb1UsJAyzX5M3hMcbnKRRvFaS8MmLmFiENa9Ylrzo41GBk/xzLKOYP1ikch28sN+IlhLeL9MJdApHxHc1TrhpKZC96KdFOXYyyVl08omo/1WmuwonEXzXnD4PpN7JChjLJu/zmTRwMA5uZTqjnIt/RaoaBHJhHaOgTcPcsatD+Z+h2VKQaTnnBmQvuhZA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=dpdk.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nWD9ajWJjTDfGPu8m/UN2qeJgjvtZczbQeqqmF8///8=; b=aZEC8JOPKtNLNBWm1hutGnJQByBVMX6FS99sshuT6eaeaVWEEdrYuN8bDlh4NyQO8icAgJmVtHxs2OXbk0yF1ZcG6RKko2T7YQCk6f371h6svnMylvIXgfSrin9pGrq7G1y3hwc6HZYjQZX/pEnFmX92U+rjvLGxP1xpGNFqgAk= Received: from MN2PR01CA0025.prod.exchangelabs.com (2603:10b6:208:10c::38) by IA0PR12MB8375.namprd12.prod.outlook.com (2603:10b6:208:3dd::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20; Wed, 30 Oct 2024 04:42:52 +0000 Received: from BL02EPF0001A103.namprd05.prod.outlook.com (2603:10b6:208:10c:cafe::30) by MN2PR01CA0025.outlook.office365.com (2603:10b6:208:10c::38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.17 via Frontend Transport; Wed, 30 Oct 2024 04:42:52 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL02EPF0001A103.mail.protection.outlook.com (10.167.241.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Wed, 30 Oct 2024 04:42:51 +0000 Received: from BLRVIVARGHE.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 29 Oct 2024 23:41:36 -0500 From: Vipin Varghese To: , , , , , CC: , , , , , , , Subject: [RFC v2 2/3] test/lcore: enable tests for topology Date: Wed, 30 Oct 2024 10:10:26 +0530 Message-ID: <20241030044035.1201-3-vipin.varghese@amd.com> X-Mailer: git-send-email 2.47.0.windows.1 In-Reply-To: <20241030044035.1201-1-vipin.varghese@amd.com> References: <20241030044035.1201-1-vipin.varghese@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0001A103:EE_|IA0PR12MB8375:EE_ X-MS-Office365-Filtering-Correlation-Id: 8af31d91-af5f-445d-8617-08dcf89d5047 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|7416014|376014|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?p3qRkOxIyIUsGDGb0i05nfzvqRhL/gnNZuEpEFUABVBYlSEIkwGbwddnEazZ?= =?us-ascii?Q?+jJtrl3rN84C0erEtNZaDLeVcxmntc9NCB1HLKDQ0B6iIeGLEdb8INrq8Tzk?= =?us-ascii?Q?ga/AJAfAQw3oUT11QBjqTrqWd3BHO/zgVK4fQsMOGJH/5tySTv5Exm2rOT93?= =?us-ascii?Q?vvqWNl/awFsXZIvRQ/GE3pNTB8pYT9IKzYoYOinv1yLMLotNk1c8/4TyfkJ9?= =?us-ascii?Q?qM4A07dAcy8LrDO5M57umTw9AbWjWjchDOw6mZ9VXZ5hgMK9VdiAFuNXWmOI?= =?us-ascii?Q?aD38m2TF6DOQ/iEu/PRe68EI1qD+LxUkyts7IV696Ear16Gu8HOKTQDDpDEp?= =?us-ascii?Q?mgvvB1yRogz4Hhk62BpFwFyjd1auiyR/Pp/a81WFkmsBfOn8raroONl8fHre?= =?us-ascii?Q?c3BRtkqsAFpZF6+lscyFAWqubc7gUvWlkyM/SZ4b23EA6h5bLuTQS/1k2oQs?= =?us-ascii?Q?fRrhHFBRFAmzPcWoHLbpLrSITI5OMwxya5f/PfF4SwqIj5bypU5aPsQUu3nC?= =?us-ascii?Q?VfWQNWsjclrpCzKWo0sDb1JDxsRrPDIwbf2sdsji3NE2n8/+3rhb5EVW8x7c?= =?us-ascii?Q?8qS6gKcU7HygH5JPFz+G9iIVopicon57JN9z5oRY3jV89f8F9YrZIW7q1+TV?= =?us-ascii?Q?csYTT8iRMd8pugVB5smKrll0LILMvEHEv65EspWNWPf9y9ZASIGJkYEOc6yz?= =?us-ascii?Q?sEabrftWpxg5xn3TzXnj/xuYz7UI4tLmWwbrwgpIjhKsKZcTVOklhMuI5HXj?= =?us-ascii?Q?JInvUnwgOzDqaEwXCaiWRWwEE5U43I40004QdNckbfm26r/0b42RgapMRo9v?= =?us-ascii?Q?TTidVXKmtHuedVUZicFjeZ6G7CunFpLstMakofyix3Z7IEqpCOqtZsOvmTns?= =?us-ascii?Q?qt7ruN5atF75CjkQYM2aZi0Hd0JrAhEbaz5KWuKfKPcLExv2ZZTzrpVoN6kt?= =?us-ascii?Q?1cBLuWnUlMrKfviPtLiQQg3qZAeswlpST661X7nabjfjQz3ryJ9klQcvqIkf?= =?us-ascii?Q?ZsNhXfnLu/9lKXaGFTsQLE9q25gQW4haP/GDA45JxM0BJEDtNSzM3TvfbMV7?= =?us-ascii?Q?W2GUkkeoJZtuJmmDiLGoEKtUlje4TjHwykYuyvcRoTy4lYzuJ1xQMFpGrys6?= =?us-ascii?Q?uC+VUJZ7jxPFvsdJf0Hs0BMkb0EnSA69swlOCvqOXOOVW6FJJbizuI4JWcvL?= =?us-ascii?Q?kmlcHm27kzpftq6u5jle3HXAK3Fmwda1JQ3GX1c3FRPg094O6w78WlkXnnVa?= =?us-ascii?Q?NQ9ljqO9i6+UBJh91yvI0zMpRRcxv7qPd2LwY2n3EmXdgef4MFBk+VjBxk1E?= =?us-ascii?Q?KczLOfF3UTSwA8J8pUTkTStOIfpm91HdvKzyx4LAYjhJkn88jvsqxXvJAxPZ?= =?us-ascii?Q?xBOkmEvHi7ViKEJmJVNQMuQTg1mTN+QdvPk+YLzcM0ZAYdAL/A=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(36860700013)(7416014)(376014)(82310400026)(1800799024); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 04:42:51.9561 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8af31d91-af5f-445d-8617-08dcf89d5047 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL02EPF0001A103.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8375 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 functional test cases to validate topology supported lcore API. Signed-off-by: Vipin Varghese --- app/test/test_lcores.c | 189 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 189 insertions(+) diff --git a/app/test/test_lcores.c b/app/test/test_lcores.c index bd5c0dd94b..3e57a3f272 100644 --- a/app/test/test_lcores.c +++ b/app/test/test_lcores.c @@ -389,6 +389,186 @@ test_ctrl_thread(void) return 0; } +static int +test_topology_macro(void) +{ + unsigned int total_lcores = 0; + unsigned int total_wrkr_lcores = 0; + + unsigned int total_lcore_io = 0; + unsigned int total_lcore_l3 = 0; + unsigned int total_lcore_l2 = 0; + unsigned int total_lcore_l1 = 0; + + unsigned int total_wrkr_lcore_io = 0; + unsigned int total_wrkr_lcore_l3 = 0; + unsigned int total_wrkr_lcore_l2 = 0; + unsigned int total_wrkr_lcore_l1 = 0; + + unsigned int lcore; + + /* get topology core count */ + lcore = -1; + RTE_LCORE_FOREACH(lcore) + total_lcores += 1; + + lcore = -1; + RTE_LCORE_FOREACH_DOMAIN(lcore, RTE_LCORE_DOMAIN_IO) + total_lcore_io += 1; + + lcore = -1; + RTE_LCORE_FOREACH_DOMAIN(lcore, RTE_LCORE_DOMAIN_L3) + total_lcore_l3 += 1; + + lcore = -1; + RTE_LCORE_FOREACH_DOMAIN(lcore, RTE_LCORE_DOMAIN_L2) + total_lcore_l2 += 1; + + lcore = -1; + RTE_LCORE_FOREACH_DOMAIN(lcore, RTE_LCORE_DOMAIN_L1) + total_lcore_l1 += 1; + + printf("INFO: lcore count topology: none (%u), io (%u), l3 (%u), l2 (%u), l1 (%u).\n", + total_lcores, total_lcore_io, + total_lcore_l3, total_lcore_l2, + total_lcore_l1); + + lcore = -1; + RTE_LCORE_FOREACH_WORKER(lcore) + total_wrkr_lcores += 1; + + lcore = -1; + RTE_LCORE_FOREACH_WORKER_DOMAIN(lcore, RTE_LCORE_DOMAIN_IO) + total_wrkr_lcore_io += 1; + + lcore = -1; + RTE_LCORE_FOREACH_WORKER_DOMAIN(lcore, RTE_LCORE_DOMAIN_L3) + total_wrkr_lcore_l3 += 1; + + lcore = -1; + RTE_LCORE_FOREACH_WORKER_DOMAIN(lcore, RTE_LCORE_DOMAIN_L2) + total_wrkr_lcore_l2 += 1; + + lcore = -1; + RTE_LCORE_FOREACH_WORKER_DOMAIN(lcore, RTE_LCORE_DOMAIN_L1) + total_wrkr_lcore_l1 += 1; + + printf("INFO: worker lcore count topology: none (%u), io (%u), l3 (%u), l2 (%u), l1 (%u).\n", + total_wrkr_lcores, total_wrkr_lcore_io, + total_wrkr_lcore_l3, total_wrkr_lcore_l2, + total_wrkr_lcore_l1); + + if ((total_wrkr_lcores + 1) != total_lcores) { + printf("ERR: failed in MACRO for RTE_LCORE_FOREACH\n"); + return -2; + } + + if ((total_wrkr_lcore_io + 1) > total_lcore_io) { + printf("ERR: failed in MACRO for RTE_LCORE_FOREACH_DOMAIN for IO\n"); + return -2; + } + + if ((total_wrkr_lcore_l3) > total_lcore_l3) { + printf("ERR: failed in MACRO for RTE_LCORE_FOREACH_DOMAIN for L3\n"); + return -2; + } + + if ((total_wrkr_lcore_l2) > total_lcore_l2) { + printf("ERR: failed in MACRO for RTE_LCORE_FOREACH_DOMAIN for L2\n"); + return -2; + } + + if ((total_wrkr_lcore_l1) > total_lcore_l1) { + printf("ERR: failed in MACRO for RTE_LCORE_FOREACH_DOMAIN for L1\n"); + return -2; + } + + printf("INFO: lcore DOMAIN macro: success!\n"); + + return 0; +} + +static int +test_lcore_count_from_domain(void) +{ + unsigned int total_lcores = 0; + unsigned int total_lcore_io = 0; + unsigned int total_lcore_l3 = 0; + unsigned int total_lcore_l2 = 0; + unsigned int total_lcore_l1 = 0; + + unsigned int domain_count; + unsigned int i; + + /* get topology core count */ + total_lcores = rte_lcore_count(); + + domain_count = rte_get_domain_count(RTE_LCORE_DOMAIN_IO); + for (i = 0; i < domain_count; i++) + total_lcore_io += rte_lcore_count_from_domain(RTE_LCORE_DOMAIN_IO, i); + + domain_count = rte_get_domain_count(RTE_LCORE_DOMAIN_L3); + for (i = 0; i < domain_count; i++) + total_lcore_l3 += rte_lcore_count_from_domain(RTE_LCORE_DOMAIN_L3, i); + + domain_count = rte_get_domain_count(RTE_LCORE_DOMAIN_L2); + for (i = 0; i < domain_count; i++) + total_lcore_l2 += rte_lcore_count_from_domain(RTE_LCORE_DOMAIN_L2, i); + + domain_count = rte_get_domain_count(RTE_LCORE_DOMAIN_L1); + for (i = 0; i < domain_count; i++) + total_lcore_l1 += rte_lcore_count_from_domain(RTE_LCORE_DOMAIN_L1, i); + + printf("INFO: lcore count: none (%u), io (%u), l3 (%u), l2 (%u), l1 (%u).\n", + total_lcores, total_lcore_io, total_lcore_l3, total_lcore_l2, total_lcore_l1); + + if ((total_lcores != total_lcore_l1) || + (total_lcores != total_lcore_l2) || + (total_lcores != total_lcore_l3) || + (total_lcores != total_lcore_io)) { + printf("ERR: failed in domain API\n"); + return -2; + } + + printf("INFO: lcore count domain API: success\n"); + + return 0; +} + +static int +test_lcore_from_domain_negative(void) +{ + unsigned int domain_count; + + domain_count = rte_get_domain_count(RTE_LCORE_DOMAIN_IO); + if (rte_lcore_count_from_domain(RTE_LCORE_DOMAIN_IO, domain_count)) { + printf("ERR: domain API inconsistent for IO\n"); + return -1; + } + + domain_count = rte_get_domain_count(RTE_LCORE_DOMAIN_L3); + if (rte_lcore_count_from_domain(RTE_LCORE_DOMAIN_L3, domain_count)) { + printf("ERR: domain API inconsistent for L3\n"); + return -1; + } + + domain_count = rte_get_domain_count(RTE_LCORE_DOMAIN_L2); + if (rte_lcore_count_from_domain(RTE_LCORE_DOMAIN_L2, domain_count)) { + printf("ERR: domain API inconsistent for L2\n"); + return -1; + } + + domain_count = rte_get_domain_count(RTE_LCORE_DOMAIN_L1); + if (rte_lcore_count_from_domain(RTE_LCORE_DOMAIN_L1, domain_count)) { + printf("ERR: domain API inconsistent for L1\n"); + return -1; + } + + printf("INFO: lcore domain API: success!\n"); + + return 0; +} + static int test_lcores(void) { @@ -419,6 +599,15 @@ test_lcores(void) if (test_ctrl_thread() < 0) return TEST_FAILED; + if (test_topology_macro() < 0) + return TEST_FAILED; + + if (test_lcore_count_from_domain() < 0) + return TEST_FAILED; + + if (test_lcore_from_domain_negative() < 0) + return TEST_FAILED; + return TEST_SUCCESS; } -- 2.34.1