Path: blob/master/arch/x86/kernel/cpu/resctrl/internal.h
29271 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/* Setting bit 0 in L3_QOS_EXT_CFG enables the ABMC feature. */40#define ABMC_ENABLE_BIT 04142/*43* Qos Event Identifiers.44*/45#define ABMC_EXTENDED_EVT_ID BIT(31)46#define ABMC_EVT_ID BIT(0)4748/**49* struct rdt_hw_ctrl_domain - Arch private attributes of a set of CPUs that share50* a resource for a control function51* @d_resctrl: Properties exposed to the resctrl file system52* @ctrl_val: array of cache or mem ctrl values (indexed by CLOSID)53*54* Members of this structure are accessed via helpers that provide abstraction.55*/56struct rdt_hw_ctrl_domain {57struct rdt_ctrl_domain d_resctrl;58u32 *ctrl_val;59};6061/**62* struct rdt_hw_mon_domain - Arch private attributes of a set of CPUs that share63* a resource for a monitor function64* @d_resctrl: Properties exposed to the resctrl file system65* @arch_mbm_states: Per-event pointer to the MBM event's saved state.66* An MBM event's state is an array of struct arch_mbm_state67* indexed by RMID on x86.68*69* Members of this structure are accessed via helpers that provide abstraction.70*/71struct rdt_hw_mon_domain {72struct rdt_mon_domain d_resctrl;73struct arch_mbm_state *arch_mbm_states[QOS_NUM_L3_MBM_EVENTS];74};7576static inline struct rdt_hw_ctrl_domain *resctrl_to_arch_ctrl_dom(struct rdt_ctrl_domain *r)77{78return container_of(r, struct rdt_hw_ctrl_domain, d_resctrl);79}8081static inline struct rdt_hw_mon_domain *resctrl_to_arch_mon_dom(struct rdt_mon_domain *r)82{83return container_of(r, struct rdt_hw_mon_domain, d_resctrl);84}8586/**87* struct msr_param - set a range of MSRs from a domain88* @res: The resource to use89* @dom: The domain to update90* @low: Beginning index from base MSR91* @high: End index92*/93struct msr_param {94struct rdt_resource *res;95struct rdt_ctrl_domain *dom;96u32 low;97u32 high;98};99100/**101* struct rdt_hw_resource - arch private attributes of a resctrl resource102* @r_resctrl: Attributes of the resource used directly by resctrl.103* @num_closid: Maximum number of closid this hardware can support,104* regardless of CDP. This is exposed via105* resctrl_arch_get_num_closid() to avoid confusion106* with struct resctrl_schema's property of the same name,107* which has been corrected for features like CDP.108* @msr_base: Base MSR address for CBMs109* @msr_update: Function pointer to update QOS MSRs110* @mon_scale: cqm counter * mon_scale = occupancy in bytes111* @mbm_width: Monitor width, to detect and correct for overflow.112* @cdp_enabled: CDP state of this resource113* @mbm_cntr_assign_enabled: ABMC feature is enabled114*115* Members of this structure are either private to the architecture116* e.g. mbm_width, or accessed via helpers that provide abstraction. e.g.117* msr_update and msr_base.118*/119struct rdt_hw_resource {120struct rdt_resource r_resctrl;121u32 num_closid;122unsigned int msr_base;123void (*msr_update)(struct msr_param *m);124unsigned int mon_scale;125unsigned int mbm_width;126bool cdp_enabled;127bool mbm_cntr_assign_enabled;128};129130static inline struct rdt_hw_resource *resctrl_to_arch_res(struct rdt_resource *r)131{132return container_of(r, struct rdt_hw_resource, r_resctrl);133}134135extern struct rdt_hw_resource rdt_resources_all[];136137void arch_mon_domain_online(struct rdt_resource *r, struct rdt_mon_domain *d);138139/* CPUID.(EAX=10H, ECX=ResID=1).EAX */140union cpuid_0x10_1_eax {141struct {142unsigned int cbm_len:5;143} split;144unsigned int full;145};146147/* CPUID.(EAX=10H, ECX=ResID=3).EAX */148union cpuid_0x10_3_eax {149struct {150unsigned int max_delay:12;151} split;152unsigned int full;153};154155/* CPUID.(EAX=10H, ECX=ResID).ECX */156union cpuid_0x10_x_ecx {157struct {158unsigned int reserved:3;159unsigned int noncont:1;160} split;161unsigned int full;162};163164/* CPUID.(EAX=10H, ECX=ResID).EDX */165union cpuid_0x10_x_edx {166struct {167unsigned int cos_max:16;168} split;169unsigned int full;170};171172/*173* ABMC counters are configured by writing to MSR_IA32_L3_QOS_ABMC_CFG.174*175* @bw_type : Event configuration that represents the memory176* transactions being tracked by the @cntr_id.177* @bw_src : Bandwidth source (RMID or CLOSID).178* @reserved1 : Reserved.179* @is_clos : @bw_src field is a CLOSID (not an RMID).180* @cntr_id : Counter identifier.181* @reserved : Reserved.182* @cntr_en : Counting enable bit.183* @cfg_en : Configuration enable bit.184*185* Configuration and counting:186* Counter can be configured across multiple writes to MSR. Configuration187* is applied only when @cfg_en = 1. Counter @cntr_id is reset when the188* configuration is applied.189* @cfg_en = 1, @cntr_en = 0 : Apply @cntr_id configuration but do not190* count events.191* @cfg_en = 1, @cntr_en = 1 : Apply @cntr_id configuration and start192* counting events.193*/194union l3_qos_abmc_cfg {195struct {196unsigned long bw_type :32,197bw_src :12,198reserved1: 3,199is_clos : 1,200cntr_id : 5,201reserved : 9,202cntr_en : 1,203cfg_en : 1;204} split;205unsigned long full;206};207208void rdt_ctrl_update(void *arg);209210int rdt_get_mon_l3_config(struct rdt_resource *r);211212bool rdt_cpu_has(int flag);213214void __init intel_rdt_mbm_apply_quirk(void);215216void rdt_domain_reconfigure_cdp(struct rdt_resource *r);217void resctrl_arch_mbm_cntr_assign_set_one(struct rdt_resource *r);218219#endif /* _ASM_X86_RESCTRL_INTERNAL_H */220221222