blob: 09d00e6f7ad65122c5a520392ca36471463ed5d7 [file] [log] [blame]
Fenghua Yu113c6092016-10-22 06:19:54 -07001#ifndef _ASM_X86_INTEL_RDT_H
2#define _ASM_X86_INTEL_RDT_H
3
Fenghua Yu5ff193f2016-10-28 15:04:42 -07004#include <linux/jump_label.h>
5
6#define IA32_L3_QOS_CFG 0xc81
Fenghua Yu113c6092016-10-22 06:19:54 -07007#define IA32_L3_CBM_BASE 0xc90
Fenghua Yuc1c7c3f2016-10-22 06:19:55 -07008#define IA32_L2_CBM_BASE 0xd10
Fenghua Yu113c6092016-10-22 06:19:54 -07009
Fenghua Yu5ff193f2016-10-28 15:04:42 -070010#define L3_QOS_CDP_ENABLE 0x01ULL
11
12/**
13 * struct rdtgroup - store rdtgroup's data in resctrl file system.
14 * @kn: kernfs node
15 * @rdtgroup_list: linked list for all rdtgroups
16 * @closid: closid for this rdtgroup
17 */
18struct rdtgroup {
19 struct kernfs_node *kn;
20 struct list_head rdtgroup_list;
21 int closid;
22};
23
24/* List of all resource groups */
25extern struct list_head rdt_all_groups;
26
27int __init rdtgroup_init(void);
28
Fenghua Yuc1c7c3f2016-10-22 06:19:55 -070029/**
30 * struct rdt_resource - attributes of an RDT resource
31 * @enabled: Is this feature enabled on this machine
32 * @capable: Is this feature available on this machine
33 * @name: Name to use in "schemata" file
34 * @num_closid: Number of CLOSIDs available
35 * @max_cbm: Largest Cache Bit Mask allowed
36 * @min_cbm_bits: Minimum number of consecutive bits to be set
37 * in a cache bit mask
38 * @domains: All domains for this resource
39 * @num_domains: Number of domains active
40 * @msr_base: Base MSR address for CBMs
41 * @tmp_cbms: Scratch space when updating schemata
42 * @cache_level: Which cache level defines scope of this domain
43 * @cbm_idx_multi: Multiplier of CBM index
44 * @cbm_idx_offset: Offset of CBM index. CBM index is computed by:
45 * closid * cbm_idx_multi + cbm_idx_offset
46 */
47struct rdt_resource {
48 bool enabled;
49 bool capable;
50 char *name;
51 int num_closid;
52 int cbm_len;
53 int min_cbm_bits;
54 u32 max_cbm;
55 struct list_head domains;
56 int num_domains;
57 int msr_base;
58 u32 *tmp_cbms;
59 int cache_level;
60 int cbm_idx_multi;
61 int cbm_idx_offset;
62};
63
Tony Luck2264d9c2016-10-28 15:04:41 -070064/**
65 * struct rdt_domain - group of cpus sharing an RDT resource
66 * @list: all instances of this resource
67 * @id: unique id for this instance
68 * @cpu_mask: which cpus share this resource
69 * @cbm: array of cache bit masks (indexed by CLOSID)
70 */
71struct rdt_domain {
72 struct list_head list;
73 int id;
74 struct cpumask cpu_mask;
75 u32 *cbm;
76};
77
78/**
79 * struct msr_param - set a range of MSRs from a domain
80 * @res: The resource to use
81 * @low: Beginning index from base MSR
82 * @high: End index
83 */
84struct msr_param {
85 struct rdt_resource *res;
86 int low;
87 int high;
88};
89
90extern struct mutex rdtgroup_mutex;
91
Fenghua Yuc1c7c3f2016-10-22 06:19:55 -070092extern struct rdt_resource rdt_resources_all[];
Fenghua Yu5ff193f2016-10-28 15:04:42 -070093extern struct rdtgroup rdtgroup_default;
94DECLARE_STATIC_KEY_FALSE(rdt_enable_key);
95
96int __init rdtgroup_init(void);
Fenghua Yuc1c7c3f2016-10-22 06:19:55 -070097
98enum {
99 RDT_RESOURCE_L3,
100 RDT_RESOURCE_L3DATA,
101 RDT_RESOURCE_L3CODE,
102 RDT_RESOURCE_L2,
103
104 /* Must be the last */
105 RDT_NUM_RESOURCES,
106};
107
108#define for_each_capable_rdt_resource(r) \
109 for (r = rdt_resources_all; r < rdt_resources_all + RDT_NUM_RESOURCES;\
110 r++) \
111 if (r->capable)
112
Tony Luck2264d9c2016-10-28 15:04:41 -0700113#define for_each_enabled_rdt_resource(r) \
114 for (r = rdt_resources_all; r < rdt_resources_all + RDT_NUM_RESOURCES;\
115 r++) \
116 if (r->enabled)
117
Fenghua Yuc1c7c3f2016-10-22 06:19:55 -0700118/* CPUID.(EAX=10H, ECX=ResID=1).EAX */
119union cpuid_0x10_1_eax {
120 struct {
121 unsigned int cbm_len:5;
122 } split;
123 unsigned int full;
124};
125
126/* CPUID.(EAX=10H, ECX=ResID=1).EDX */
127union cpuid_0x10_1_edx {
128 struct {
129 unsigned int cos_max:16;
130 } split;
131 unsigned int full;
132};
Tony Luck2264d9c2016-10-28 15:04:41 -0700133
134void rdt_cbm_update(void *arg);
Fenghua Yu113c6092016-10-22 06:19:54 -0700135#endif /* _ASM_X86_INTEL_RDT_H */