1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019 Intel Corporation
7 #include <rte_common.h>
9 /* global data structure that contains the CPU map */
10 static struct _wcpu_map {
11 unsigned int total_procs;
12 unsigned int proc_sockets;
13 unsigned int proc_cores;
14 unsigned int reserved;
15 struct _win_lcore_map {
18 } wlcore_map[RTE_MAX_LCORE];
22 * Create a map of all processors and associated cores on the system
27 wcpu_map.total_procs =
28 GetActiveProcessorCount(ALL_PROCESSOR_GROUPS);
30 LOGICAL_PROCESSOR_RELATIONSHIP lprocRel;
31 DWORD lprocInfoSize = 0;
32 BOOL ht_enabled = FALSE;
34 /* First get the processor package information */
35 lprocRel = RelationProcessorPackage;
36 /* Determine the size of buffer we need (pass NULL) */
37 GetLogicalProcessorInformationEx(lprocRel, NULL, &lprocInfoSize);
38 wcpu_map.proc_sockets = lprocInfoSize / 48;
41 /* Next get the processor core information */
42 lprocRel = RelationProcessorCore;
43 GetLogicalProcessorInformationEx(lprocRel, NULL, &lprocInfoSize);
44 wcpu_map.proc_cores = lprocInfoSize / 48;
46 if (wcpu_map.total_procs > wcpu_map.proc_cores)
49 /* Distribute the socket and core ids appropriately
50 * across the logical cores. For now, split the cores
51 * equally across the sockets.
53 unsigned int lcore = 0;
54 for (unsigned int socket = 0; socket <
55 wcpu_map.proc_sockets; ++socket) {
56 for (unsigned int core = 0;
57 core < (wcpu_map.proc_cores / wcpu_map.proc_sockets);
59 wcpu_map.wlcore_map[lcore]
61 wcpu_map.wlcore_map[lcore]
65 wcpu_map.wlcore_map[lcore]
67 wcpu_map.wlcore_map[lcore]
76 * Check if a cpu is present by the presence of the cpu information for it
79 eal_cpu_detected(unsigned int lcore_id)
81 return (lcore_id < wcpu_map.total_procs);
85 * Get CPU socket id for a logical core
88 eal_cpu_socket_id(unsigned int lcore_id)
90 return wcpu_map.wlcore_map[lcore_id].socket_id;
94 * Get CPU socket id (NUMA node) for a logical core
97 eal_cpu_core_id(unsigned int lcore_id)
99 return wcpu_map.wlcore_map[lcore_id].core_id;