xref: /dragonfly/sys/sys/cpu_topology.h (revision 61c0377f)
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[MAXCPU];
10 	uint32_t child_no;
11 	cpumask_t members;
12 	uint8_t type;
13 	uint8_t compute_unit_id; /* AMD compute unit ID */
14 };
15 typedef struct cpu_node cpu_node_t;
16 
17 extern int cpu_topology_levels_number;
18 extern cpu_node_t *root_cpu_node;
19 
20 cpumask_t get_cpumask_from_level(int cpuid, uint8_t level_type);
21 cpu_node_t *get_cpu_node_by_cpuid(int cpuid);
22 
23 #define LEVEL_NO 4
24 
25 /* Level type for CPU siblings */
26 #define	PACKAGE_LEVEL	1
27 #define	CHIP_LEVEL	2
28 #define	CORE_LEVEL	3
29 #define	THREAD_LEVEL	4
30 
31 #define	CPU_ISSET(n, p)	((CPUMASK(n) & p) != 0)
32 
33 #define CPUSET_FOREACH(cpu, mask)			\
34 	for ((cpu) = 0; (cpu) < ncpus; (cpu)++)		\
35 		if (CPU_ISSET(cpu, mask))
36 
37 
38 #endif /* _KERNEL */
39 #endif /* _CPU_TOPOLOGY_H_ */
40