Path: blob/master/arch/x86/kernel/cpu/resctrl/internal.h
26516 views
/* SPDX-License-Identifier: GPL-2.0 */1#ifndef _ASM_X86_RESCTRL_INTERNAL_H2#define _ASM_X86_RESCTRL_INTERNAL_H34#include <linux/resctrl.h>56#define L3_QOS_CDP_ENABLE 0x01ULL78#define L2_QOS_CDP_ENABLE 0x01ULL910#define MBM_CNTR_WIDTH_BASE 241112#define MBA_IS_LINEAR 0x41314#define MBM_CNTR_WIDTH_OFFSET_AMD 201516#define RMID_VAL_ERROR BIT_ULL(63)1718#define RMID_VAL_UNAVAIL BIT_ULL(62)1920/*21* With the above fields in use 62 bits remain in MSR_IA32_QM_CTR for22* data to be returned. The counter width is discovered from the hardware23* as an offset from MBM_CNTR_WIDTH_BASE.24*/25#define MBM_CNTR_WIDTH_OFFSET_MAX (62 - MBM_CNTR_WIDTH_BASE)2627/**28* struct arch_mbm_state - values used to compute resctrl_arch_rmid_read()s29* return value.30* @chunks: Total data moved (multiply by rdt_group.mon_scale to get bytes)31* @prev_msr: Value of IA32_QM_CTR last time it was read for the RMID used to32* find this struct.33*/34struct arch_mbm_state {35u64 chunks;36u64 prev_msr;37};3839/**40* struct rdt_hw_ctrl_domain - Arch private attributes of a set of CPUs that share41* a resource for a control function42* @d_resctrl: Properties exposed to the resctrl file system43* @ctrl_val: array of cache or mem ctrl values (indexed by CLOSID)44*45* Members of this structure are accessed via helpers that provide abstraction.46*/47struct rdt_hw_ctrl_domain {48struct rdt_ctrl_domain d_resctrl;49u32 *ctrl_val;50};5152/**53* struct rdt_hw_mon_domain - Arch private attributes of a set of CPUs that share54* a resource for a monitor function55* @d_resctrl: Properties exposed to the resctrl file system56* @arch_mbm_total: arch private state for MBM total bandwidth57* @arch_mbm_local: arch private state for MBM local bandwidth58*59* Members of this structure are accessed via helpers that provide abstraction.60*/61struct rdt_hw_mon_domain {62struct rdt_mon_domain d_resctrl;63struct arch_mbm_state *arch_mbm_total;64struct arch_mbm_state *arch_mbm_local;65};6667static inline struct rdt_hw_ctrl_domain *resctrl_to_arch_ctrl_dom(struct rdt_ctrl_domain *r)68{69return container_of(r, struct rdt_hw_ctrl_domain, d_resctrl);70}7172static inline struct rdt_hw_mon_domain *resctrl_to_arch_mon_dom(struct rdt_mon_domain *r)73{74return container_of(r, struct rdt_hw_mon_domain, d_resctrl);75}7677/**78* struct msr_param - set a range of MSRs from a domain79* @res: The resource to use80* @dom: The domain to update81* @low: Beginning index from base MSR82* @high: End index83*/84struct msr_param {85struct rdt_resource *res;86struct rdt_ctrl_domain *dom;87u32 low;88u32 high;89};9091/**92* struct rdt_hw_resource - arch private attributes of a resctrl resource93* @r_resctrl: Attributes of the resource used directly by resctrl.94* @num_closid: Maximum number of closid this hardware can support,95* regardless of CDP. This is exposed via96* resctrl_arch_get_num_closid() to avoid confusion97* with struct resctrl_schema's property of the same name,98* which has been corrected for features like CDP.99* @msr_base: Base MSR address for CBMs100* @msr_update: Function pointer to update QOS MSRs101* @mon_scale: cqm counter * mon_scale = occupancy in bytes102* @mbm_width: Monitor width, to detect and correct for overflow.103* @cdp_enabled: CDP state of this resource104*105* Members of this structure are either private to the architecture106* e.g. mbm_width, or accessed via helpers that provide abstraction. e.g.107* msr_update and msr_base.108*/109struct rdt_hw_resource {110struct rdt_resource r_resctrl;111u32 num_closid;112unsigned int msr_base;113void (*msr_update)(struct msr_param *m);114unsigned int mon_scale;115unsigned int mbm_width;116bool cdp_enabled;117};118119static inline struct rdt_hw_resource *resctrl_to_arch_res(struct rdt_resource *r)120{121return container_of(r, struct rdt_hw_resource, r_resctrl);122}123124extern struct rdt_hw_resource rdt_resources_all[];125126void arch_mon_domain_online(struct rdt_resource *r, struct rdt_mon_domain *d);127128/* CPUID.(EAX=10H, ECX=ResID=1).EAX */129union cpuid_0x10_1_eax {130struct {131unsigned int cbm_len:5;132} split;133unsigned int full;134};135136/* CPUID.(EAX=10H, ECX=ResID=3).EAX */137union cpuid_0x10_3_eax {138struct {139unsigned int max_delay:12;140} split;141unsigned int full;142};143144/* CPUID.(EAX=10H, ECX=ResID).ECX */145union cpuid_0x10_x_ecx {146struct {147unsigned int reserved:3;148unsigned int noncont:1;149} split;150unsigned int full;151};152153/* CPUID.(EAX=10H, ECX=ResID).EDX */154union cpuid_0x10_x_edx {155struct {156unsigned int cos_max:16;157} split;158unsigned int full;159};160161void rdt_ctrl_update(void *arg);162163int rdt_get_mon_l3_config(struct rdt_resource *r);164165bool rdt_cpu_has(int flag);166167void __init intel_rdt_mbm_apply_quirk(void);168169void rdt_domain_reconfigure_cdp(struct rdt_resource *r);170171#endif /* _ASM_X86_RESCTRL_INTERNAL_H */172173174