4aff0dcf7846bb8c1c6597f5af559eb1efcbd8ce
[dragonfly.git] / sys / sys / cpu_topology.h
1 #ifndef _CPU_TOPOLOGY_H_
2 #define _CPU_TOPOLOGY_H_
3
4 #ifdef _KERNEL
5
6 /* CPU TOPOLOGY DATA AND FUNCTIONS */
7 struct cpu_node {
8         struct cpu_node * parent_node;
9         struct cpu_node * child_node;
10         uint32_t child_no;
11         cpumask_t members;
12         uint8_t type;
13 };
14 typedef struct cpu_node cpu_node_t;
15
16 extern int cpu_topology_levels_number;
17
18 cpumask_t get_cpumask_from_level(int cpuid,
19                         uint8_t level_type);
20
21 cpu_node_t *
22 get_cpu_node_by_cpuid(int cpuid);
23
24 #define LEVEL_NO 4
25
26 /* Level type for CPU siblings */
27 #define PACKAGE_LEVEL   1
28 #define CHIP_LEVEL      2
29 #define CORE_LEVEL      3
30 #define THREAD_LEVEL    4
31
32 #define CPU_ISSET(n, p) ((CPUMASK(n) & p) != 0)
33
34 #define CPUSET_FOREACH(cpu, mask)                       \
35         for ((cpu) = 0; (cpu) < ncpus; (cpu)++)         \
36                 if (CPU_ISSET(cpu, mask))
37
38
39 #endif /* _KERNEL */
40 #endif /* _CPU_TOPOLOGY_H_ */