xref: /dragonfly/sys/sys/cpu_topology.h (revision 902c1039)
1 #ifndef _CPU_TOPOLOGY_H_
2 #define _CPU_TOPOLOGY_H_
3 
4 #if defined(_KERNEL) || defined(_KERNEL_STRUCTURES)
5 
6 #include <machine/cpumask.h>
7 
8 /* CPU TOPOLOGY DATA AND FUNCTIONS */
9 struct cpu_node {
10 	struct cpu_node * parent_node;
11 	struct cpu_node * child_node[MAXCPU];
12 	uint32_t child_no;
13 	uint32_t unused01;
14 	cpumask_t members;
15 	uint8_t type;
16 	uint8_t compute_unit_id; /* AMD compute unit ID */
17 	uint8_t unused02;
18 	uint8_t unused03;
19 	long	phys_mem;	/* supplied from vm_numa_organize() */
20 };
21 typedef struct cpu_node cpu_node_t;
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 CPUSET_FOREACH(cpu, mask)			\
32 	for ((cpu) = 0; (cpu) < ncpus; (cpu)++)		\
33 		if (CPUMASK_TESTBIT(mask, cpu))
34 
35 #endif
36 
37 #if defined(_KERNEL)
38 
39 extern int cpu_topology_levels_number;
40 extern int cpu_topology_core_ids;
41 extern int cpu_topology_phys_ids;
42 extern cpu_node_t *root_cpu_node;
43 
44 cpumask_t get_cpumask_from_level(int cpuid, uint8_t level_type);
45 cpu_node_t *get_cpu_node_by_cpuid(int cpuid);
46 const cpu_node_t *get_cpu_node_by_chipid(int chip_id);
47 long get_highest_node_memory(void);
48 int get_cpu_core_id(int cpuid);
49 int get_cpu_phys_id(int cpuid);
50 
51 #endif /* _KERNEL */
52 #endif /* _CPU_TOPOLOGY_H_ */
53