1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019 Intel Corporation
8 #include <rte_common.h>
10 #include "eal_private.h"
11 #include "eal_thread.h"
12 #include "eal_windows.h"
14 /* global data structure that contains the CPU map */
15 static struct _wcpu_map {
16 unsigned int total_procs;
17 unsigned int proc_sockets;
18 unsigned int proc_cores;
19 unsigned int reserved;
20 struct _win_lcore_map {
23 } wlcore_map[RTE_MAX_LCORE];
27 * Create a map of all processors and associated cores on the system
30 eal_create_cpu_map(void)
32 wcpu_map.total_procs =
33 GetActiveProcessorCount(ALL_PROCESSOR_GROUPS);
35 LOGICAL_PROCESSOR_RELATIONSHIP lprocRel;
36 DWORD lprocInfoSize = 0;
37 BOOL ht_enabled = FALSE;
39 /* First get the processor package information */
40 lprocRel = RelationProcessorPackage;
41 /* Determine the size of buffer we need (pass NULL) */
42 GetLogicalProcessorInformationEx(lprocRel, NULL, &lprocInfoSize);
43 wcpu_map.proc_sockets = lprocInfoSize / 48;
46 /* Next get the processor core information */
47 lprocRel = RelationProcessorCore;
48 GetLogicalProcessorInformationEx(lprocRel, NULL, &lprocInfoSize);
49 wcpu_map.proc_cores = lprocInfoSize / 48;
51 if (wcpu_map.total_procs > wcpu_map.proc_cores)
54 /* Distribute the socket and core ids appropriately
55 * across the logical cores. For now, split the cores
56 * equally across the sockets.
58 unsigned int lcore = 0;
59 for (unsigned int socket = 0; socket <
60 wcpu_map.proc_sockets; ++socket) {
61 for (unsigned int core = 0;
62 core < (wcpu_map.proc_cores / wcpu_map.proc_sockets);
64 wcpu_map.wlcore_map[lcore]
66 wcpu_map.wlcore_map[lcore]
70 wcpu_map.wlcore_map[lcore]
72 wcpu_map.wlcore_map[lcore]
81 * Check if a cpu is present by the presence of the cpu information for it
84 eal_cpu_detected(unsigned int lcore_id)
86 return (lcore_id < wcpu_map.total_procs);
90 * Get CPU socket id for a logical core
93 eal_cpu_socket_id(unsigned int lcore_id)
95 return wcpu_map.wlcore_map[lcore_id].socket_id;
99 * Get CPU socket id (NUMA node) for a logical core
102 eal_cpu_core_id(unsigned int lcore_id)
104 return wcpu_map.wlcore_map[lcore_id].core_id;