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 7177B45C87; Tue, 5 Nov 2024 11:29:46 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D1E954065C; Tue, 5 Nov 2024 11:29:44 +0100 (CET) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2071.outbound.protection.outlook.com [40.107.244.71]) by mails.dpdk.org (Postfix) with ESMTP id C2C4040650 for ; Tue, 5 Nov 2024 11:29:43 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ZBFFAFfpv6Fr/5IHU4IuDQTsk1/XOtqJtyRVDjhHrGFP2J7nlOu788j1SEer/KVWYMBmw5bHEB3Xg2dpQTfMlvDQU82XKKvaSuc9nZITmlajLLXlelmHBni9KMwDpfshz7YqSVhdmRpRmGIPEuRglG0y7pGw1SI1BOU5PbK5rPqeBgVXmaDAFGXOdlYEiiPRJz+kRp7K/h75Mluyo8eSMhJ2EqR59fHivCkEaQ5wZ7EhtII4IdjgXiYR4enqBGAbqn2IvuoB2n+TTTQkAptormtyCKDvZt6hhemmWtNPmRx2l6YA1SpUFK/hx70Pv6cG7QeskYk0WTTgfVlcXNQc8g== 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=ixlXibM8kLuFIJwMqALKVr5Wz6z4/QsO4fZMTVh+JBY=; b=w988Ij5UecbBbNnMKXMOsB2x3gIK+2JP6qPcb44UEb2HfTyio0Y4ZBKgjkN/4HDJEUigA8XpNywBQNcVQsIYZ+K7ST/HYQckWNHSWUz+bQMsdUNhdNHhjxqQ71+oInXQDRTyb/vGBm3Rxw96Quu9L/YQWr+LDzTc6MbEMzMql66hVPD4pwahtbnAHBo6WVI0BJK7dYIchlIzjjHeO2TqRdrKyOB43/vlgywd4LYtDx21eQTgbNnAfeHpHAXvlLpCyKUXKLxYHkGbi024Xq5TpSEzm/n4VGI1mmxa1DbW34oJ8xBXhB+3ilVEmZv5BOKuMAbknlhOJHpHBYR/hbBAww== 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=ixlXibM8kLuFIJwMqALKVr5Wz6z4/QsO4fZMTVh+JBY=; b=aKUNfr5U2Z/o4DgL9b9gloog9hqD79Y6x3sEF03F5mGd++SE09vow1fqCQc12rsmWnjZYwLSdSGqqpzWdlkwhv9s+DTp4dc0WS/U/Q4GxzL2PQWVoWgJoj6rUsMUN7exdfPJcP1jzGBt0Ua/izbUTSGBNqqkwb82EI3Vztqv8FY= Received: from PH7PR10CA0017.namprd10.prod.outlook.com (2603:10b6:510:23d::10) by SN7PR12MB7809.namprd12.prod.outlook.com (2603:10b6:806:34e::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.30; Tue, 5 Nov 2024 10:29:41 +0000 Received: from SN1PEPF000252A1.namprd05.prod.outlook.com (2603:10b6:510:23d:cafe::aa) by PH7PR10CA0017.outlook.office365.com (2603:10b6:510:23d::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.31 via Frontend Transport; Tue, 5 Nov 2024 10:29:40 +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 SN1PEPF000252A1.mail.protection.outlook.com (10.167.242.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8137.17 via Frontend Transport; Tue, 5 Nov 2024 10:29:40 +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, 5 Nov 2024 04:29:36 -0600 From: Vipin Varghese To: , , , , CC: , , , , , , , , , , Subject: [PATCH v4 2/4] test/lcore: enable tests for topology Date: Tue, 5 Nov 2024 15:58:47 +0530 Message-ID: <20241105102849.1947-3-vipin.varghese@amd.com> X-Mailer: git-send-email 2.47.0.windows.1 In-Reply-To: <20241105102849.1947-1-vipin.varghese@amd.com> References: <20241105102849.1947-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: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF000252A1:EE_|SN7PR12MB7809:EE_ X-MS-Office365-Filtering-Correlation-Id: 6be6b745-d1c9-4958-380e-08dcfd84c1b9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|376014|7416014|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?f4+McBsPz6pvZUXwo7SS7K9VNDKdyUDnE7iy9cOLs6ca3po4ctgkLK+++RJG?= =?us-ascii?Q?FrfYou/ZviOS9p9R6XOI/33pqTkG0P6lrIjBOwfNfk2PH7zbupDIyCQRj7hX?= =?us-ascii?Q?kQo279E6lqVXL8+6dzKhMI90FEPifxKU0P2w1p8WhZoh/ge+J8K1pGf+2fCd?= =?us-ascii?Q?/jkEowqg257LCX2zLteyR9svDSNQFWQXEDroPw9NbA7OcHY5iIo3GGQ6pL4c?= =?us-ascii?Q?tsG0CXHatlTrCAOQx+3BzWiOW37XwcBcz/GdafoQ5O2F2COtK7HR1Tct03c+?= =?us-ascii?Q?Sn7Y8g6H/i4c76xm0wuDEBh0+PFaBifBhFONm2OjwkdJKAMRFpuKVc6bEhHJ?= =?us-ascii?Q?tKYFmX5OwDTDaaqh0ztCJMgqCnIDQx3D4IOOPpxfqWOE44bulTTH5S/nwX2i?= =?us-ascii?Q?mTcKre0K4CrQQX5zS9jpL92iqUqQ/XU2u5GHUhiw+YEoLcdNgIWw/QMLTumo?= =?us-ascii?Q?HzOTute9WmequwW39UVMM6Q3GqyqPtWjqAoLkHE4SBYBKUTZzdAo16bOB78M?= =?us-ascii?Q?JNZBTydMwYWBuspF38G6JGiZS1gKm8Ybp7W5FGXv//58iU4NspAax0tAJSoZ?= =?us-ascii?Q?PNVruaStbyxOfFfDWN5VD1lYh950AVHOTbhCplHnvAmVgZt1UaE1dymrk0Nk?= =?us-ascii?Q?anS51dc8oUdf5r5PbaEQ83jzOE9awf0MdPFiN0ZwfYka2VwDtG9YWBaW5+Cy?= =?us-ascii?Q?78y89qVT7e6SLV/t9GQusE+2H7Ic1CLfxpnwf3pLo7S0r/FbWK/Z/fdkSrLT?= =?us-ascii?Q?RYF97fDr9MByBuJO+HbVkd8coNw8tD+aFaNyjSfJIaNS6a/3O8d9mTSrb4uu?= =?us-ascii?Q?bgpdJMOouR0wfhe5F0IqPYo5gk89DWH4teRJzTClvbSDSOYW1rXJ/U76E8Z3?= =?us-ascii?Q?Puhe3WuMj+715MtMiZygssQB/mVUTYVhBSGx62cGfnap6Ci4gx8gQ/jmLUeD?= =?us-ascii?Q?ydkoztji6eIrp5aueVTAiUJrCdCeyjwIhgHhM6j1TAFXSurqevrZqlCNiTVc?= =?us-ascii?Q?j89srUG6NRwPxhWcMsVVnk+kA1seKAn1hySIB/QUViQh987IrheGj8NplTFB?= =?us-ascii?Q?LlNPSCkMrmieUIPHqjPHlI47Z5HdFSBwc7JkaTcyFhfbvxoiE9B9F4d+nvI4?= =?us-ascii?Q?RE8yAB3SKP9RyQoQFEV7txEuueMR/Smbmfus+W0Urf/Id2uDS6d9pMRBw6g7?= =?us-ascii?Q?qEnRq56OTRImVS9AFQXi2R8/ZmO3/UWOkaJ140E7AKKCgRDl+WNa+6Eso4hn?= =?us-ascii?Q?gMul4Css96VgnbjiBqNeXZXimq/jFf/aS5EsqYJsXdDO56zDUCCh3KfPjNE0?= =?us-ascii?Q?Kv2Io1Ty021VFTi71+B6k9KJHwvzOCDVcV6AMS+kODwIF071linM3ikcaYZz?= =?us-ascii?Q?4WJOtGnXAdAAtUBLisFYWM0PdaSyacc62GnW9hxfPlIed8T1EA=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)(376014)(7416014)(82310400026)(1800799024); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Nov 2024 10:29:40.6638 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6be6b745-d1c9-4958-380e-08dcfd84c1b9 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: SN1PEPF000252A1.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7809 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. v4 cahnges: - add MACRO for triggering tests if topology is enabled. - add test cases for * rte_lcore_is_main_in_domain * rte_lcore_cpuset_in_domain * MACRO RTE_LCORE_FORN_NEXT_DOMAIN * MACRO RTE_LCORE_FORN_WORKER_NEXT_DOMAIN v3 changes: - fix test check for RTE_LCORE_FOREACH_DOMAIN Signed-off-by: Vipin Varghese --- app/test/test_lcores.c | 528 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 528 insertions(+) diff --git a/app/test/test_lcores.c b/app/test/test_lcores.c index bd5c0dd94b..15a9417e66 100644 --- a/app/test/test_lcores.c +++ b/app/test/test_lcores.c @@ -389,6 +389,513 @@ test_ctrl_thread(void) return 0; } +#ifdef RTE_EAL_HWLOC_TOPOLOGY_PROBE +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_l4 = 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_l4 = 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_WORKER(lcore) + total_wrkr_lcores += 1; + + if ((total_wrkr_lcores + 1) != total_lcores) { + printf("ERR: failed in MACRO for RTE_LCORE_FOREACH\n"); + return -2; + } + + 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_L4) + total_lcore_l4 += 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("DBG: lcore count: default (%u), io (%u), l4 (%u), l3 (%u), l2 (%u), l1 (%u).\n", + total_lcores, total_lcore_io, + total_lcore_l4, total_lcore_l3, total_lcore_l2, total_lcore_l1); + + + 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_L4) + total_wrkr_lcore_l4 += 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("DBG: worker lcore count: default (%u), io (%u), l4 (%u), l3 (%u), l2 (%u), l1 (%u).\n", + total_wrkr_lcores, total_wrkr_lcore_io, + total_wrkr_lcore_l4, total_wrkr_lcore_l3, + total_wrkr_lcore_l2, total_wrkr_lcore_l1); + + + if ((total_wrkr_lcore_io) > total_lcore_io) { + printf("ERR: failed in MACRO for RTE_LCORE_FOREACH_DOMAIN for IO\n"); + return -2; + } + + if ((total_wrkr_lcore_l4) > total_lcore_l4) { + printf("ERR: failed in MACRO for RTE_LCORE_FOREACH_DOMAIN for L4\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; + } + + total_lcore_io = 0; + total_lcore_l4 = 0; + total_lcore_l3 = 0; + total_lcore_l2 = 0; + total_lcore_l1 = 0; + + lcore = -1; + RTE_LCORE_FORN_NEXT_DOMAIN(lcore, RTE_LCORE_DOMAIN_IO, 0) + total_lcore_io += 1; + + lcore = -1; + RTE_LCORE_FORN_NEXT_DOMAIN(lcore, RTE_LCORE_DOMAIN_L4, 0) + total_lcore_l4 += 1; + + lcore = -1; + RTE_LCORE_FORN_NEXT_DOMAIN(lcore, RTE_LCORE_DOMAIN_L3, 0) + total_lcore_l3 += 1; + + lcore = -1; + RTE_LCORE_FORN_NEXT_DOMAIN(lcore, RTE_LCORE_DOMAIN_L2, 0) + total_lcore_l2 += 1; + + lcore = -1; + RTE_LCORE_FORN_NEXT_DOMAIN(lcore, RTE_LCORE_DOMAIN_L1, 0) + total_lcore_l1 += 1; + + printf("DBG: macro domain lcore: default (%u), io (%u), l4 (%u), l3 (%u), l2 (%u), l1 (%u).\n", + total_lcores, total_lcore_io, + total_lcore_l4, total_lcore_l3, total_lcore_l2, total_lcore_l1); + + total_wrkr_lcore_io = 0; + total_wrkr_lcore_l4 = 0; + total_wrkr_lcore_l3 = 0; + total_wrkr_lcore_l2 = 0; + total_wrkr_lcore_l1 = 0; + + lcore = -1; + RTE_LCORE_FORN_WORKER_NEXT_DOMAIN(lcore, RTE_LCORE_DOMAIN_IO, 0) + total_wrkr_lcore_io += 1; + + lcore = -1; + RTE_LCORE_FORN_WORKER_NEXT_DOMAIN(lcore, RTE_LCORE_DOMAIN_L4, 0) + total_wrkr_lcore_l4 += 1; + + lcore = -1; + RTE_LCORE_FORN_WORKER_NEXT_DOMAIN(lcore, RTE_LCORE_DOMAIN_L3, 0) + total_wrkr_lcore_l3 += 1; + + lcore = -1; + RTE_LCORE_FORN_WORKER_NEXT_DOMAIN(lcore, RTE_LCORE_DOMAIN_L2, 0) + total_wrkr_lcore_l2 += 1; + + lcore = -1; + RTE_LCORE_FORN_WORKER_NEXT_DOMAIN(lcore, RTE_LCORE_DOMAIN_L1, 0) + total_wrkr_lcore_l1 += 1; + + printf("DBG: macro next domain worker count: default (%u), io (%u), l4 (%u), l3 (%u), l2 (%u), l1 (%u).\n", + total_wrkr_lcores, total_wrkr_lcore_io, + total_wrkr_lcore_l4, total_wrkr_lcore_l3, + total_wrkr_lcore_l2, total_wrkr_lcore_l1); + + if ((total_wrkr_lcore_io) > total_lcore_io) { + printf("ERR: failed in MACRO for RTE_LCORE_FORN_NEXT_DOMAIN for IO\n"); + return -2; + } + + if ((total_wrkr_lcore_l4) > total_lcore_l4) { + printf("ERR: failed in MACRO for RTE_LCORE_FORN_NEXT_DOMAIN for L4\n"); + return -2; + } + + if ((total_wrkr_lcore_l3) > total_lcore_l3) { + printf("ERR: failed in MACRO for RTE_LCORE_FORN_NEXT_DOMAIN for L3\n"); + return -2; + } + + if ((total_wrkr_lcore_l2) > total_lcore_l2) { + printf("ERR: failed in MACRO for RTE_LCORE_FORN_NEXT_DOMAIN for L2\n"); + return -2; + } + + if ((total_wrkr_lcore_l1) > total_lcore_l1) { + printf("ERR: failed in MACRO for RTE_LCORE_FORN_NEXT_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_l4 = 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_L4); + for (i = 0; i < domain_count; i++) + total_lcore_l4 += rte_lcore_count_from_domain(RTE_LCORE_DOMAIN_L4, 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("DBG: lcore count: default (%u), io (%u), l4 (%u), l3 (%u), l2 (%u), l1 (%u).\n", + total_lcores, total_lcore_io, + total_lcore_l4, total_lcore_l3, total_lcore_l2, total_lcore_l1); + + if ((total_lcore_l1 && (total_lcores != total_lcore_l1)) || + (total_lcore_l2 && (total_lcores != total_lcore_l2)) || + (total_lcore_l3 && (total_lcores != total_lcore_l3)) || + (total_lcore_l4 && (total_lcores != total_lcore_l4)) || + (total_lcore_io && (total_lcores != total_lcore_io))) { + printf("ERR: failed in domain API\n"); + return -2; + } + + printf("INFO: lcore count domain API: success\n"); + + return 0; +} + +#ifdef RTE_HAS_CPUSET +static int +test_lcore_cpuset_from_domain(void) +{ + unsigned int domain_count; + uint16_t dmn_idx; + rte_cpuset_t cpu_set_list; + + dmn_idx = 0; + domain_count = rte_get_domain_count(RTE_LCORE_DOMAIN_IO); + + for (; dmn_idx < domain_count; dmn_idx++) { + cpu_set_list = rte_lcore_cpuset_in_domain(RTE_LCORE_DOMAIN_IO, dmn_idx); + + for (uint16_t cpu_idx = 0; cpu_idx < RTE_MAX_LCORE; cpu_idx++) { + if (CPU_ISSET(cpu_idx, &cpu_set_list)) { + if (!rte_lcore_is_enabled(cpu_idx)) { + printf("ERR: lcore id: %u, shared from IO (%u) domain is not enabled!\n", + cpu_idx, dmn_idx); + return -1; + } + } + } + } + + dmn_idx = 0; + domain_count = rte_get_domain_count(RTE_LCORE_DOMAIN_L4); + + for (; dmn_idx < domain_count; dmn_idx++) { + cpu_set_list = rte_lcore_cpuset_in_domain(RTE_LCORE_DOMAIN_L4, dmn_idx); + + for (uint16_t cpu_idx = 0; cpu_idx < RTE_MAX_LCORE; cpu_idx++) { + if (CPU_ISSET(cpu_idx, &cpu_set_list)) { + if (!rte_lcore_is_enabled(cpu_idx)) { + printf("ERR: lcore id: %u, shared from L4 (%u) domain is not enabled!\n", + cpu_idx, dmn_idx); + return -1; + } + } + } + } + + dmn_idx = 0; + domain_count = rte_get_domain_count(RTE_LCORE_DOMAIN_L3); + + for (; dmn_idx < domain_count; dmn_idx++) { + cpu_set_list = rte_lcore_cpuset_in_domain(RTE_LCORE_DOMAIN_L3, dmn_idx); + + for (uint16_t cpu_idx = 0; cpu_idx < RTE_MAX_LCORE; cpu_idx++) { + if (CPU_ISSET(cpu_idx, &cpu_set_list)) { + if (!rte_lcore_is_enabled(cpu_idx)) { + printf("ERR: lcore id: %u, shared from L3 (%u) domain is not enabled!\n", + cpu_idx, dmn_idx); + return -1; + } + } + } + } + + dmn_idx = 0; + domain_count = rte_get_domain_count(RTE_LCORE_DOMAIN_L2); + + for (; dmn_idx < domain_count; dmn_idx++) { + cpu_set_list = rte_lcore_cpuset_in_domain(RTE_LCORE_DOMAIN_L2, dmn_idx); + + for (uint16_t cpu_idx = 0; cpu_idx < RTE_MAX_LCORE; cpu_idx++) { + if (CPU_ISSET(cpu_idx, &cpu_set_list)) { + if (!rte_lcore_is_enabled(cpu_idx)) { + printf("ERR: lcore id: %u, shared from L2 (%u) domain is not enabled!\n", + cpu_idx, dmn_idx); + return -1; + } + } + } + } + + dmn_idx = 0; + domain_count = rte_get_domain_count(RTE_LCORE_DOMAIN_L1); + + for (; dmn_idx < domain_count; dmn_idx++) { + cpu_set_list = rte_lcore_cpuset_in_domain(RTE_LCORE_DOMAIN_L1, dmn_idx); + + for (uint16_t cpu_idx = 0; cpu_idx < RTE_MAX_LCORE; cpu_idx++) { + if (CPU_ISSET(cpu_idx, &cpu_set_list)) { + if (!rte_lcore_is_enabled(cpu_idx)) { + printf("ERR: lcore id: %u, shared from IO (%u) domain is not enabled!\n", + cpu_idx, dmn_idx); + return -1; + } + } + } + } + + cpu_set_list = rte_lcore_cpuset_in_domain(RTE_LCORE_DOMAIN_L1, RTE_MAX_LCORE); + if (CPU_COUNT(&cpu_set_list)) { + printf("ERR: RTE_MAX_LCORE (%u) in L1 domain is enabled!\n", RTE_MAX_LCORE); + return -2; + } + + cpu_set_list = rte_lcore_cpuset_in_domain(RTE_LCORE_DOMAIN_L2, RTE_MAX_LCORE); + if (CPU_COUNT(&cpu_set_list)) { + printf("ERR: RTE_MAX_LCORE (%u) in L2 domain is enabled!\n", RTE_MAX_LCORE); + return -2; + } + + cpu_set_list = rte_lcore_cpuset_in_domain(RTE_LCORE_DOMAIN_L3, RTE_MAX_LCORE); + if (CPU_COUNT(&cpu_set_list)) { + printf("ERR: RTE_MAX_LCORE (%u) in L3 domain is enabled!\n", RTE_MAX_LCORE); + return -2; + } + + cpu_set_list = rte_lcore_cpuset_in_domain(RTE_LCORE_DOMAIN_IO, RTE_MAX_LCORE); + if (CPU_COUNT(&cpu_set_list)) { + printf("ERR: RTE_MAX_LCORE (%u) in IO domain is enabled!\n", RTE_MAX_LCORE); + return -2; + } + + printf("INFO: cpuset_in_domain API: success!\n"); + return 0; +} +#endif + +static int +test_main_lcore_in_domain(void) +{ + bool main_lcore_found; + unsigned int domain_count; + uint16_t dmn_idx; + + main_lcore_found = false; + dmn_idx = 0; + domain_count = rte_get_domain_count(RTE_LCORE_DOMAIN_IO); + for (; dmn_idx < domain_count; dmn_idx++) { + main_lcore_found = rte_lcore_is_main_in_domain(RTE_LCORE_DOMAIN_IO, dmn_idx); + if (main_lcore_found) { + printf("DBG: main lcore found in IO domain: %u\n", dmn_idx); + break; + } + } + + if ((domain_count) && (main_lcore_found == false)) { + printf("ERR: main lcore is not found in any of the IO domain!\n"); + return -1; + } + + main_lcore_found = false; + dmn_idx = 0; + domain_count = rte_get_domain_count(RTE_LCORE_DOMAIN_L4); + for (; dmn_idx < domain_count; dmn_idx++) { + main_lcore_found = rte_lcore_is_main_in_domain(RTE_LCORE_DOMAIN_L4, dmn_idx); + if (main_lcore_found) { + printf("DBG: main lcore found in L4 domain: %u\n", dmn_idx); + break; + } + } + + if ((domain_count) && (main_lcore_found == false)) { + printf("ERR: main lcore is not found in any of the L4 domain!\n"); + return -1; + } + + main_lcore_found = false; + dmn_idx = 0; + domain_count = rte_get_domain_count(RTE_LCORE_DOMAIN_L3); + for (; dmn_idx < domain_count; dmn_idx++) { + main_lcore_found = rte_lcore_is_main_in_domain(RTE_LCORE_DOMAIN_L3, dmn_idx); + if (main_lcore_found) { + printf("DBG: main lcore found in L3 domain: %u\n", dmn_idx); + break; + } + } + + if ((domain_count) && (main_lcore_found == false)) { + printf("ERR: main lcore is not found in any of the L3 domain!\n"); + return -1; + } + + main_lcore_found = false; + dmn_idx = 0; + domain_count = rte_get_domain_count(RTE_LCORE_DOMAIN_L2); + for (; dmn_idx < domain_count; dmn_idx++) { + main_lcore_found = rte_lcore_is_main_in_domain(RTE_LCORE_DOMAIN_L2, dmn_idx); + if (main_lcore_found) { + printf("DBG: main lcore is found on the L2 domain: %u\n", dmn_idx); + break; + } + } + + if ((domain_count) && (main_lcore_found == false)) { + printf("ERR: main lcore is not found in any of the L2 domain!\n"); + return -1; + } + + main_lcore_found = false; + dmn_idx = 0; + domain_count = rte_get_domain_count(RTE_LCORE_DOMAIN_L1); + for (; dmn_idx < domain_count; dmn_idx++) { + main_lcore_found = rte_lcore_is_main_in_domain(RTE_LCORE_DOMAIN_L1, dmn_idx); + if (main_lcore_found) { + printf("DBG: main lcore is found on the L1 domain: %u\n", dmn_idx); + break; + } + } + + if ((domain_count) && (main_lcore_found == false)) { + printf("ERR: main lcore is not found in any of the L1 domain!\n"); + return -1; + } + + printf("INFO: is_main_lcore_in_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 ((domain_count) && (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_L4); + if ((domain_count) && (rte_lcore_count_from_domain(RTE_LCORE_DOMAIN_L4, domain_count))) { + printf("ERR: domain API inconsistent for L4\n"); + return -1; + } + + domain_count = rte_get_domain_count(RTE_LCORE_DOMAIN_L3); + if ((domain_count) && (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 ((domain_count) && (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 ((domain_count) && (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; +} +#endif + static int test_lcores(void) { @@ -419,6 +926,27 @@ test_lcores(void) if (test_ctrl_thread() < 0) return TEST_FAILED; +#ifdef RTE_EAL_HWLOC_TOPOLOGY_PROBE + printf("\nTopology test\n"); + + 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; + +#ifdef RTE_HAS_CPUSET + if (test_lcore_cpuset_from_domain() < 0) + return TEST_FAILED; +#endif + + if (test_main_lcore_in_domain() < 0) + return TEST_FAILED; +#endif + return TEST_SUCCESS; } -- 2.34.1