xref: /aosp_15_r20/external/coreboot/src/soc/intel/xeon_sp/include/soc/numa.h (revision b9411a12aaaa7e1e6a6fb7c5e057f44ee179a49c)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 /*
4  * This header file defines data structures and operations related
5  * to NUMA proximity domains.
6  */
7 #ifndef NUMA_H
8 #define NUMA_H
9 
10 #include <soc/soc_util.h>
11 #include <types.h>
12 
13 #define XEONSP_INVALID_PD_INDEX	UINT32_MAX
14 
15 enum proximity_domain_type {
16 	PD_TYPE_PROCESSOR,
17 	/*
18 	 * The Generic Initiator concept is used in ACPI spec. A typical
19 	 * Generic Initiator domain is a CXL memory device.
20 	 */
21 	PD_TYPE_GENERIC_INITIATOR,
22 	/*
23 	 * PD_TYPE_CLUSTER is for Sub-NUMA cluster (SNC). SNC is localization
24 	 * domain within a socket, composed of a set of CPU cores, last-level
25 	 * cache pieces and memory controllers, which are close to each other.
26 	 * SNC will be reported as NUMA nodes to OS so that the performance
27 	 * proximity could be fully exploited for task assignment and scheduling.
28 	 *
29 	 * For more, please refer to
30 	 * https://www.intel.com/content/www/us/en/developer/articles/technical/xeon-processor-scalable-family-technical-overview.html
31 	 */
32 	PD_TYPE_CLUSTER,
33 	PD_TYPE_MAX
34 };
35 
36 /*
37  * This proximity domain structure records all data related to
38  * a proximity doamin needed for following purpose:
39  * a. Device resource allocation. IIO stack involving CXL device
40  *    needs to have different resource allocation method.
41  * b. e820 table setup. For example, CXL memory region may need to
42  *    be set as soft reserved, since it is specific purpose memory.
43  * c. ACPI NUMA tables (SRAT, SLIT, HMAT).
44  */
45 struct proximity_domain {
46 	enum proximity_domain_type pd_type;
47 	/*
48 	 * For processor domain, this holds the socket #.
49 	 * For generic initiator domain, this indicates to which socket the
50 	 * device is attached to. CXL 2.0 allows interleaving within and between
51 	 * sockets, so we need a bitmap.
52 	 */
53 	uint8_t socket_bitmap;
54 	uint8_t cluster_bitmap;
55 	/* Relative distances (memory latency) from all domains */
56 	uint8_t *distances;
57 	/*
58 	 * Below fields are set to 0 for processor domains.
59 	 */
60 	struct device *dev;
61 	uint32_t base; /* Memory region base address in the unit of 64MB */
62 	uint32_t size; /* Memory region size in the unit of 64MB */
63 };
64 
65 struct proximity_domains {
66 	uint8_t num_pds;
67 	struct proximity_domain *pds;
68 };
69 
70 extern struct proximity_domains pds;
71 
72 void setup_pds(void);
73 
74 /*
75  * Return the total size of memory regions in generic initiator affinity
76  * domains.  The size is in unit of 64MB.
77  */
78 uint32_t get_generic_initiator_mem_size(void);
79 
80 uint32_t memory_to_pd(const struct SystemMemoryMapElement *mem);
81 uint32_t device_to_pd(const struct device *dev);
82 
83 uint8_t soc_get_cluster_count(void);
84 void soc_set_cpu_node_id(struct device *cpu);
85 
86 #endif /* NUMA_H */
87