1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019 Intel Corporation
7 #include <rte_common.h>
9 #include "eal_private.h"
10 #include "eal_thread.h"
12 /* global data structure that contains the CPU map */
13 static struct _wcpu_map {
14 unsigned int total_procs;
15 unsigned int proc_sockets;
16 unsigned int proc_cores;
17 unsigned int reserved;
18 struct _win_lcore_map {
21 } wlcore_map[RTE_MAX_LCORE];
25 * Create a map of all processors and associated cores on the system
30 wcpu_map.total_procs =
31 GetActiveProcessorCount(ALL_PROCESSOR_GROUPS);
33 LOGICAL_PROCESSOR_RELATIONSHIP lprocRel;
34 DWORD lprocInfoSize = 0;
35 BOOL ht_enabled = FALSE;
37 /* First get the processor package information */
38 lprocRel = RelationProcessorPackage;
39 /* Determine the size of buffer we need (pass NULL) */
40 GetLogicalProcessorInformationEx(lprocRel, NULL, &lprocInfoSize);
41 wcpu_map.proc_sockets = lprocInfoSize / 48;
44 /* Next get the processor core information */
45 lprocRel = RelationProcessorCore;
46 GetLogicalProcessorInformationEx(lprocRel, NULL, &lprocInfoSize);
47 wcpu_map.proc_cores = lprocInfoSize / 48;
49 if (wcpu_map.total_procs > wcpu_map.proc_cores)
52 /* Distribute the socket and core ids appropriately
53 * across the logical cores. For now, split the cores
54 * equally across the sockets.
56 unsigned int lcore = 0;
57 for (unsigned int socket = 0; socket <
58 wcpu_map.proc_sockets; ++socket) {
59 for (unsigned int core = 0;
60 core < (wcpu_map.proc_cores / wcpu_map.proc_sockets);
62 wcpu_map.wlcore_map[lcore]
64 wcpu_map.wlcore_map[lcore]
68 wcpu_map.wlcore_map[lcore]
70 wcpu_map.wlcore_map[lcore]
79 * Check if a cpu is present by the presence of the cpu information for it
82 eal_cpu_detected(unsigned int lcore_id)
84 return (lcore_id < wcpu_map.total_procs);
88 * Get CPU socket id for a logical core
91 eal_cpu_socket_id(unsigned int lcore_id)
93 return wcpu_map.wlcore_map[lcore_id].socket_id;
97 * Get CPU socket id (NUMA node) for a logical core
100 eal_cpu_core_id(unsigned int lcore_id)
102 return wcpu_map.wlcore_map[lcore_id].core_id;