18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Netburst Performance Events (P4, old Xeon) 48c2ecf20Sopenharmony_ci */ 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci#ifndef PERF_EVENT_P4_H 78c2ecf20Sopenharmony_ci#define PERF_EVENT_P4_H 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#include <linux/cpu.h> 108c2ecf20Sopenharmony_ci#include <linux/bitops.h> 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci/* 138c2ecf20Sopenharmony_ci * NetBurst has performance MSRs shared between 148c2ecf20Sopenharmony_ci * threads if HT is turned on, ie for both logical 158c2ecf20Sopenharmony_ci * processors (mem: in turn in Atom with HT support 168c2ecf20Sopenharmony_ci * perf-MSRs are not shared and every thread has its 178c2ecf20Sopenharmony_ci * own perf-MSRs set) 188c2ecf20Sopenharmony_ci */ 198c2ecf20Sopenharmony_ci#define ARCH_P4_TOTAL_ESCR (46) 208c2ecf20Sopenharmony_ci#define ARCH_P4_RESERVED_ESCR (2) /* IQ_ESCR(0,1) not always present */ 218c2ecf20Sopenharmony_ci#define ARCH_P4_MAX_ESCR (ARCH_P4_TOTAL_ESCR - ARCH_P4_RESERVED_ESCR) 228c2ecf20Sopenharmony_ci#define ARCH_P4_MAX_CCCR (18) 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci#define ARCH_P4_CNTRVAL_BITS (40) 258c2ecf20Sopenharmony_ci#define ARCH_P4_CNTRVAL_MASK ((1ULL << ARCH_P4_CNTRVAL_BITS) - 1) 268c2ecf20Sopenharmony_ci#define ARCH_P4_UNFLAGGED_BIT ((1ULL) << (ARCH_P4_CNTRVAL_BITS - 1)) 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci#define P4_ESCR_EVENT_MASK 0x7e000000ULL 298c2ecf20Sopenharmony_ci#define P4_ESCR_EVENT_SHIFT 25 308c2ecf20Sopenharmony_ci#define P4_ESCR_EVENTMASK_MASK 0x01fffe00ULL 318c2ecf20Sopenharmony_ci#define P4_ESCR_EVENTMASK_SHIFT 9 328c2ecf20Sopenharmony_ci#define P4_ESCR_TAG_MASK 0x000001e0ULL 338c2ecf20Sopenharmony_ci#define P4_ESCR_TAG_SHIFT 5 348c2ecf20Sopenharmony_ci#define P4_ESCR_TAG_ENABLE 0x00000010ULL 358c2ecf20Sopenharmony_ci#define P4_ESCR_T0_OS 0x00000008ULL 368c2ecf20Sopenharmony_ci#define P4_ESCR_T0_USR 0x00000004ULL 378c2ecf20Sopenharmony_ci#define P4_ESCR_T1_OS 0x00000002ULL 388c2ecf20Sopenharmony_ci#define P4_ESCR_T1_USR 0x00000001ULL 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci#define P4_ESCR_EVENT(v) ((v) << P4_ESCR_EVENT_SHIFT) 418c2ecf20Sopenharmony_ci#define P4_ESCR_EMASK(v) ((v) << P4_ESCR_EVENTMASK_SHIFT) 428c2ecf20Sopenharmony_ci#define P4_ESCR_TAG(v) ((v) << P4_ESCR_TAG_SHIFT) 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci#define P4_CCCR_OVF 0x80000000ULL 458c2ecf20Sopenharmony_ci#define P4_CCCR_CASCADE 0x40000000ULL 468c2ecf20Sopenharmony_ci#define P4_CCCR_OVF_PMI_T0 0x04000000ULL 478c2ecf20Sopenharmony_ci#define P4_CCCR_OVF_PMI_T1 0x08000000ULL 488c2ecf20Sopenharmony_ci#define P4_CCCR_FORCE_OVF 0x02000000ULL 498c2ecf20Sopenharmony_ci#define P4_CCCR_EDGE 0x01000000ULL 508c2ecf20Sopenharmony_ci#define P4_CCCR_THRESHOLD_MASK 0x00f00000ULL 518c2ecf20Sopenharmony_ci#define P4_CCCR_THRESHOLD_SHIFT 20 528c2ecf20Sopenharmony_ci#define P4_CCCR_COMPLEMENT 0x00080000ULL 538c2ecf20Sopenharmony_ci#define P4_CCCR_COMPARE 0x00040000ULL 548c2ecf20Sopenharmony_ci#define P4_CCCR_ESCR_SELECT_MASK 0x0000e000ULL 558c2ecf20Sopenharmony_ci#define P4_CCCR_ESCR_SELECT_SHIFT 13 568c2ecf20Sopenharmony_ci#define P4_CCCR_ENABLE 0x00001000ULL 578c2ecf20Sopenharmony_ci#define P4_CCCR_THREAD_SINGLE 0x00010000ULL 588c2ecf20Sopenharmony_ci#define P4_CCCR_THREAD_BOTH 0x00020000ULL 598c2ecf20Sopenharmony_ci#define P4_CCCR_THREAD_ANY 0x00030000ULL 608c2ecf20Sopenharmony_ci#define P4_CCCR_RESERVED 0x00000fffULL 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ci#define P4_CCCR_THRESHOLD(v) ((v) << P4_CCCR_THRESHOLD_SHIFT) 638c2ecf20Sopenharmony_ci#define P4_CCCR_ESEL(v) ((v) << P4_CCCR_ESCR_SELECT_SHIFT) 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ci#define P4_GEN_ESCR_EMASK(class, name, bit) \ 668c2ecf20Sopenharmony_ci class##__##name = ((1ULL << bit) << P4_ESCR_EVENTMASK_SHIFT) 678c2ecf20Sopenharmony_ci#define P4_ESCR_EMASK_BIT(class, name) class##__##name 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ci/* 708c2ecf20Sopenharmony_ci * config field is 64bit width and consists of 718c2ecf20Sopenharmony_ci * HT << 63 | ESCR << 32 | CCCR 728c2ecf20Sopenharmony_ci * where HT is HyperThreading bit (since ESCR 738c2ecf20Sopenharmony_ci * has it reserved we may use it for own purpose) 748c2ecf20Sopenharmony_ci * 758c2ecf20Sopenharmony_ci * note that this is NOT the addresses of respective 768c2ecf20Sopenharmony_ci * ESCR and CCCR but rather an only packed value should 778c2ecf20Sopenharmony_ci * be unpacked and written to a proper addresses 788c2ecf20Sopenharmony_ci * 798c2ecf20Sopenharmony_ci * the base idea is to pack as much info as possible 808c2ecf20Sopenharmony_ci */ 818c2ecf20Sopenharmony_ci#define p4_config_pack_escr(v) (((u64)(v)) << 32) 828c2ecf20Sopenharmony_ci#define p4_config_pack_cccr(v) (((u64)(v)) & 0xffffffffULL) 838c2ecf20Sopenharmony_ci#define p4_config_unpack_escr(v) (((u64)(v)) >> 32) 848c2ecf20Sopenharmony_ci#define p4_config_unpack_cccr(v) (((u64)(v)) & 0xffffffffULL) 858c2ecf20Sopenharmony_ci 868c2ecf20Sopenharmony_ci#define p4_config_unpack_emask(v) \ 878c2ecf20Sopenharmony_ci ({ \ 888c2ecf20Sopenharmony_ci u32 t = p4_config_unpack_escr((v)); \ 898c2ecf20Sopenharmony_ci t = t & P4_ESCR_EVENTMASK_MASK; \ 908c2ecf20Sopenharmony_ci t = t >> P4_ESCR_EVENTMASK_SHIFT; \ 918c2ecf20Sopenharmony_ci t; \ 928c2ecf20Sopenharmony_ci }) 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_ci#define p4_config_unpack_event(v) \ 958c2ecf20Sopenharmony_ci ({ \ 968c2ecf20Sopenharmony_ci u32 t = p4_config_unpack_escr((v)); \ 978c2ecf20Sopenharmony_ci t = t & P4_ESCR_EVENT_MASK; \ 988c2ecf20Sopenharmony_ci t = t >> P4_ESCR_EVENT_SHIFT; \ 998c2ecf20Sopenharmony_ci t; \ 1008c2ecf20Sopenharmony_ci }) 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_ci#define P4_CONFIG_HT_SHIFT 63 1038c2ecf20Sopenharmony_ci#define P4_CONFIG_HT (1ULL << P4_CONFIG_HT_SHIFT) 1048c2ecf20Sopenharmony_ci 1058c2ecf20Sopenharmony_ci/* 1068c2ecf20Sopenharmony_ci * If an event has alias it should be marked 1078c2ecf20Sopenharmony_ci * with a special bit. (Don't forget to check 1088c2ecf20Sopenharmony_ci * P4_PEBS_CONFIG_MASK and related bits on 1098c2ecf20Sopenharmony_ci * modification.) 1108c2ecf20Sopenharmony_ci */ 1118c2ecf20Sopenharmony_ci#define P4_CONFIG_ALIASABLE (1ULL << 9) 1128c2ecf20Sopenharmony_ci 1138c2ecf20Sopenharmony_ci/* 1148c2ecf20Sopenharmony_ci * The bits we allow to pass for RAW events 1158c2ecf20Sopenharmony_ci */ 1168c2ecf20Sopenharmony_ci#define P4_CONFIG_MASK_ESCR \ 1178c2ecf20Sopenharmony_ci P4_ESCR_EVENT_MASK | \ 1188c2ecf20Sopenharmony_ci P4_ESCR_EVENTMASK_MASK | \ 1198c2ecf20Sopenharmony_ci P4_ESCR_TAG_MASK | \ 1208c2ecf20Sopenharmony_ci P4_ESCR_TAG_ENABLE 1218c2ecf20Sopenharmony_ci 1228c2ecf20Sopenharmony_ci#define P4_CONFIG_MASK_CCCR \ 1238c2ecf20Sopenharmony_ci P4_CCCR_EDGE | \ 1248c2ecf20Sopenharmony_ci P4_CCCR_THRESHOLD_MASK | \ 1258c2ecf20Sopenharmony_ci P4_CCCR_COMPLEMENT | \ 1268c2ecf20Sopenharmony_ci P4_CCCR_COMPARE | \ 1278c2ecf20Sopenharmony_ci P4_CCCR_THREAD_ANY | \ 1288c2ecf20Sopenharmony_ci P4_CCCR_RESERVED 1298c2ecf20Sopenharmony_ci 1308c2ecf20Sopenharmony_ci/* some dangerous bits are reserved for kernel internals */ 1318c2ecf20Sopenharmony_ci#define P4_CONFIG_MASK \ 1328c2ecf20Sopenharmony_ci (p4_config_pack_escr(P4_CONFIG_MASK_ESCR)) | \ 1338c2ecf20Sopenharmony_ci (p4_config_pack_cccr(P4_CONFIG_MASK_CCCR)) 1348c2ecf20Sopenharmony_ci 1358c2ecf20Sopenharmony_ci/* 1368c2ecf20Sopenharmony_ci * In case of event aliasing we need to preserve some 1378c2ecf20Sopenharmony_ci * caller bits, otherwise the mapping won't be complete. 1388c2ecf20Sopenharmony_ci */ 1398c2ecf20Sopenharmony_ci#define P4_CONFIG_EVENT_ALIAS_MASK \ 1408c2ecf20Sopenharmony_ci (p4_config_pack_escr(P4_CONFIG_MASK_ESCR) | \ 1418c2ecf20Sopenharmony_ci p4_config_pack_cccr(P4_CCCR_EDGE | \ 1428c2ecf20Sopenharmony_ci P4_CCCR_THRESHOLD_MASK | \ 1438c2ecf20Sopenharmony_ci P4_CCCR_COMPLEMENT | \ 1448c2ecf20Sopenharmony_ci P4_CCCR_COMPARE)) 1458c2ecf20Sopenharmony_ci 1468c2ecf20Sopenharmony_ci#define P4_CONFIG_EVENT_ALIAS_IMMUTABLE_BITS \ 1478c2ecf20Sopenharmony_ci ((P4_CONFIG_HT) | \ 1488c2ecf20Sopenharmony_ci p4_config_pack_escr(P4_ESCR_T0_OS | \ 1498c2ecf20Sopenharmony_ci P4_ESCR_T0_USR | \ 1508c2ecf20Sopenharmony_ci P4_ESCR_T1_OS | \ 1518c2ecf20Sopenharmony_ci P4_ESCR_T1_USR) | \ 1528c2ecf20Sopenharmony_ci p4_config_pack_cccr(P4_CCCR_OVF | \ 1538c2ecf20Sopenharmony_ci P4_CCCR_CASCADE | \ 1548c2ecf20Sopenharmony_ci P4_CCCR_FORCE_OVF | \ 1558c2ecf20Sopenharmony_ci P4_CCCR_THREAD_ANY | \ 1568c2ecf20Sopenharmony_ci P4_CCCR_OVF_PMI_T0 | \ 1578c2ecf20Sopenharmony_ci P4_CCCR_OVF_PMI_T1 | \ 1588c2ecf20Sopenharmony_ci P4_CONFIG_ALIASABLE)) 1598c2ecf20Sopenharmony_ci 1608c2ecf20Sopenharmony_cistatic inline bool p4_is_event_cascaded(u64 config) 1618c2ecf20Sopenharmony_ci{ 1628c2ecf20Sopenharmony_ci u32 cccr = p4_config_unpack_cccr(config); 1638c2ecf20Sopenharmony_ci return !!(cccr & P4_CCCR_CASCADE); 1648c2ecf20Sopenharmony_ci} 1658c2ecf20Sopenharmony_ci 1668c2ecf20Sopenharmony_cistatic inline int p4_ht_config_thread(u64 config) 1678c2ecf20Sopenharmony_ci{ 1688c2ecf20Sopenharmony_ci return !!(config & P4_CONFIG_HT); 1698c2ecf20Sopenharmony_ci} 1708c2ecf20Sopenharmony_ci 1718c2ecf20Sopenharmony_cistatic inline u64 p4_set_ht_bit(u64 config) 1728c2ecf20Sopenharmony_ci{ 1738c2ecf20Sopenharmony_ci return config | P4_CONFIG_HT; 1748c2ecf20Sopenharmony_ci} 1758c2ecf20Sopenharmony_ci 1768c2ecf20Sopenharmony_cistatic inline u64 p4_clear_ht_bit(u64 config) 1778c2ecf20Sopenharmony_ci{ 1788c2ecf20Sopenharmony_ci return config & ~P4_CONFIG_HT; 1798c2ecf20Sopenharmony_ci} 1808c2ecf20Sopenharmony_ci 1818c2ecf20Sopenharmony_cistatic inline int p4_ht_active(void) 1828c2ecf20Sopenharmony_ci{ 1838c2ecf20Sopenharmony_ci#ifdef CONFIG_SMP 1848c2ecf20Sopenharmony_ci return smp_num_siblings > 1; 1858c2ecf20Sopenharmony_ci#endif 1868c2ecf20Sopenharmony_ci return 0; 1878c2ecf20Sopenharmony_ci} 1888c2ecf20Sopenharmony_ci 1898c2ecf20Sopenharmony_cistatic inline int p4_ht_thread(int cpu) 1908c2ecf20Sopenharmony_ci{ 1918c2ecf20Sopenharmony_ci#ifdef CONFIG_SMP 1928c2ecf20Sopenharmony_ci if (smp_num_siblings == 2) 1938c2ecf20Sopenharmony_ci return cpu != cpumask_first(this_cpu_cpumask_var_ptr(cpu_sibling_map)); 1948c2ecf20Sopenharmony_ci#endif 1958c2ecf20Sopenharmony_ci return 0; 1968c2ecf20Sopenharmony_ci} 1978c2ecf20Sopenharmony_ci 1988c2ecf20Sopenharmony_cistatic inline int p4_should_swap_ts(u64 config, int cpu) 1998c2ecf20Sopenharmony_ci{ 2008c2ecf20Sopenharmony_ci return p4_ht_config_thread(config) ^ p4_ht_thread(cpu); 2018c2ecf20Sopenharmony_ci} 2028c2ecf20Sopenharmony_ci 2038c2ecf20Sopenharmony_cistatic inline u32 p4_default_cccr_conf(int cpu) 2048c2ecf20Sopenharmony_ci{ 2058c2ecf20Sopenharmony_ci /* 2068c2ecf20Sopenharmony_ci * Note that P4_CCCR_THREAD_ANY is "required" on 2078c2ecf20Sopenharmony_ci * non-HT machines (on HT machines we count TS events 2088c2ecf20Sopenharmony_ci * regardless the state of second logical processor 2098c2ecf20Sopenharmony_ci */ 2108c2ecf20Sopenharmony_ci u32 cccr = P4_CCCR_THREAD_ANY; 2118c2ecf20Sopenharmony_ci 2128c2ecf20Sopenharmony_ci if (!p4_ht_thread(cpu)) 2138c2ecf20Sopenharmony_ci cccr |= P4_CCCR_OVF_PMI_T0; 2148c2ecf20Sopenharmony_ci else 2158c2ecf20Sopenharmony_ci cccr |= P4_CCCR_OVF_PMI_T1; 2168c2ecf20Sopenharmony_ci 2178c2ecf20Sopenharmony_ci return cccr; 2188c2ecf20Sopenharmony_ci} 2198c2ecf20Sopenharmony_ci 2208c2ecf20Sopenharmony_cistatic inline u32 p4_default_escr_conf(int cpu, int exclude_os, int exclude_usr) 2218c2ecf20Sopenharmony_ci{ 2228c2ecf20Sopenharmony_ci u32 escr = 0; 2238c2ecf20Sopenharmony_ci 2248c2ecf20Sopenharmony_ci if (!p4_ht_thread(cpu)) { 2258c2ecf20Sopenharmony_ci if (!exclude_os) 2268c2ecf20Sopenharmony_ci escr |= P4_ESCR_T0_OS; 2278c2ecf20Sopenharmony_ci if (!exclude_usr) 2288c2ecf20Sopenharmony_ci escr |= P4_ESCR_T0_USR; 2298c2ecf20Sopenharmony_ci } else { 2308c2ecf20Sopenharmony_ci if (!exclude_os) 2318c2ecf20Sopenharmony_ci escr |= P4_ESCR_T1_OS; 2328c2ecf20Sopenharmony_ci if (!exclude_usr) 2338c2ecf20Sopenharmony_ci escr |= P4_ESCR_T1_USR; 2348c2ecf20Sopenharmony_ci } 2358c2ecf20Sopenharmony_ci 2368c2ecf20Sopenharmony_ci return escr; 2378c2ecf20Sopenharmony_ci} 2388c2ecf20Sopenharmony_ci 2398c2ecf20Sopenharmony_ci/* 2408c2ecf20Sopenharmony_ci * This are the events which should be used in "Event Select" 2418c2ecf20Sopenharmony_ci * field of ESCR register, they are like unique keys which allow 2428c2ecf20Sopenharmony_ci * the kernel to determinate which CCCR and COUNTER should be 2438c2ecf20Sopenharmony_ci * used to track an event 2448c2ecf20Sopenharmony_ci */ 2458c2ecf20Sopenharmony_cienum P4_EVENTS { 2468c2ecf20Sopenharmony_ci P4_EVENT_TC_DELIVER_MODE, 2478c2ecf20Sopenharmony_ci P4_EVENT_BPU_FETCH_REQUEST, 2488c2ecf20Sopenharmony_ci P4_EVENT_ITLB_REFERENCE, 2498c2ecf20Sopenharmony_ci P4_EVENT_MEMORY_CANCEL, 2508c2ecf20Sopenharmony_ci P4_EVENT_MEMORY_COMPLETE, 2518c2ecf20Sopenharmony_ci P4_EVENT_LOAD_PORT_REPLAY, 2528c2ecf20Sopenharmony_ci P4_EVENT_STORE_PORT_REPLAY, 2538c2ecf20Sopenharmony_ci P4_EVENT_MOB_LOAD_REPLAY, 2548c2ecf20Sopenharmony_ci P4_EVENT_PAGE_WALK_TYPE, 2558c2ecf20Sopenharmony_ci P4_EVENT_BSQ_CACHE_REFERENCE, 2568c2ecf20Sopenharmony_ci P4_EVENT_IOQ_ALLOCATION, 2578c2ecf20Sopenharmony_ci P4_EVENT_IOQ_ACTIVE_ENTRIES, 2588c2ecf20Sopenharmony_ci P4_EVENT_FSB_DATA_ACTIVITY, 2598c2ecf20Sopenharmony_ci P4_EVENT_BSQ_ALLOCATION, 2608c2ecf20Sopenharmony_ci P4_EVENT_BSQ_ACTIVE_ENTRIES, 2618c2ecf20Sopenharmony_ci P4_EVENT_SSE_INPUT_ASSIST, 2628c2ecf20Sopenharmony_ci P4_EVENT_PACKED_SP_UOP, 2638c2ecf20Sopenharmony_ci P4_EVENT_PACKED_DP_UOP, 2648c2ecf20Sopenharmony_ci P4_EVENT_SCALAR_SP_UOP, 2658c2ecf20Sopenharmony_ci P4_EVENT_SCALAR_DP_UOP, 2668c2ecf20Sopenharmony_ci P4_EVENT_64BIT_MMX_UOP, 2678c2ecf20Sopenharmony_ci P4_EVENT_128BIT_MMX_UOP, 2688c2ecf20Sopenharmony_ci P4_EVENT_X87_FP_UOP, 2698c2ecf20Sopenharmony_ci P4_EVENT_TC_MISC, 2708c2ecf20Sopenharmony_ci P4_EVENT_GLOBAL_POWER_EVENTS, 2718c2ecf20Sopenharmony_ci P4_EVENT_TC_MS_XFER, 2728c2ecf20Sopenharmony_ci P4_EVENT_UOP_QUEUE_WRITES, 2738c2ecf20Sopenharmony_ci P4_EVENT_RETIRED_MISPRED_BRANCH_TYPE, 2748c2ecf20Sopenharmony_ci P4_EVENT_RETIRED_BRANCH_TYPE, 2758c2ecf20Sopenharmony_ci P4_EVENT_RESOURCE_STALL, 2768c2ecf20Sopenharmony_ci P4_EVENT_WC_BUFFER, 2778c2ecf20Sopenharmony_ci P4_EVENT_B2B_CYCLES, 2788c2ecf20Sopenharmony_ci P4_EVENT_BNR, 2798c2ecf20Sopenharmony_ci P4_EVENT_SNOOP, 2808c2ecf20Sopenharmony_ci P4_EVENT_RESPONSE, 2818c2ecf20Sopenharmony_ci P4_EVENT_FRONT_END_EVENT, 2828c2ecf20Sopenharmony_ci P4_EVENT_EXECUTION_EVENT, 2838c2ecf20Sopenharmony_ci P4_EVENT_REPLAY_EVENT, 2848c2ecf20Sopenharmony_ci P4_EVENT_INSTR_RETIRED, 2858c2ecf20Sopenharmony_ci P4_EVENT_UOPS_RETIRED, 2868c2ecf20Sopenharmony_ci P4_EVENT_UOP_TYPE, 2878c2ecf20Sopenharmony_ci P4_EVENT_BRANCH_RETIRED, 2888c2ecf20Sopenharmony_ci P4_EVENT_MISPRED_BRANCH_RETIRED, 2898c2ecf20Sopenharmony_ci P4_EVENT_X87_ASSIST, 2908c2ecf20Sopenharmony_ci P4_EVENT_MACHINE_CLEAR, 2918c2ecf20Sopenharmony_ci P4_EVENT_INSTR_COMPLETED, 2928c2ecf20Sopenharmony_ci}; 2938c2ecf20Sopenharmony_ci 2948c2ecf20Sopenharmony_ci#define P4_OPCODE(event) event##_OPCODE 2958c2ecf20Sopenharmony_ci#define P4_OPCODE_ESEL(opcode) ((opcode & 0x00ff) >> 0) 2968c2ecf20Sopenharmony_ci#define P4_OPCODE_EVNT(opcode) ((opcode & 0xff00) >> 8) 2978c2ecf20Sopenharmony_ci#define P4_OPCODE_PACK(event, sel) (((event) << 8) | sel) 2988c2ecf20Sopenharmony_ci 2998c2ecf20Sopenharmony_ci/* 3008c2ecf20Sopenharmony_ci * Comments below the event represent ESCR restriction 3018c2ecf20Sopenharmony_ci * for this event and counter index per ESCR 3028c2ecf20Sopenharmony_ci * 3038c2ecf20Sopenharmony_ci * MSR_P4_IQ_ESCR0 and MSR_P4_IQ_ESCR1 are available only on early 3048c2ecf20Sopenharmony_ci * processor builds (family 0FH, models 01H-02H). These MSRs 3058c2ecf20Sopenharmony_ci * are not available on later versions, so that we don't use 3068c2ecf20Sopenharmony_ci * them completely 3078c2ecf20Sopenharmony_ci * 3088c2ecf20Sopenharmony_ci * Also note that CCCR1 do not have P4_CCCR_ENABLE bit properly 3098c2ecf20Sopenharmony_ci * working so that we should not use this CCCR and respective 3108c2ecf20Sopenharmony_ci * counter as result 3118c2ecf20Sopenharmony_ci */ 3128c2ecf20Sopenharmony_cienum P4_EVENT_OPCODES { 3138c2ecf20Sopenharmony_ci P4_OPCODE(P4_EVENT_TC_DELIVER_MODE) = P4_OPCODE_PACK(0x01, 0x01), 3148c2ecf20Sopenharmony_ci /* 3158c2ecf20Sopenharmony_ci * MSR_P4_TC_ESCR0: 4, 5 3168c2ecf20Sopenharmony_ci * MSR_P4_TC_ESCR1: 6, 7 3178c2ecf20Sopenharmony_ci */ 3188c2ecf20Sopenharmony_ci 3198c2ecf20Sopenharmony_ci P4_OPCODE(P4_EVENT_BPU_FETCH_REQUEST) = P4_OPCODE_PACK(0x03, 0x00), 3208c2ecf20Sopenharmony_ci /* 3218c2ecf20Sopenharmony_ci * MSR_P4_BPU_ESCR0: 0, 1 3228c2ecf20Sopenharmony_ci * MSR_P4_BPU_ESCR1: 2, 3 3238c2ecf20Sopenharmony_ci */ 3248c2ecf20Sopenharmony_ci 3258c2ecf20Sopenharmony_ci P4_OPCODE(P4_EVENT_ITLB_REFERENCE) = P4_OPCODE_PACK(0x18, 0x03), 3268c2ecf20Sopenharmony_ci /* 3278c2ecf20Sopenharmony_ci * MSR_P4_ITLB_ESCR0: 0, 1 3288c2ecf20Sopenharmony_ci * MSR_P4_ITLB_ESCR1: 2, 3 3298c2ecf20Sopenharmony_ci */ 3308c2ecf20Sopenharmony_ci 3318c2ecf20Sopenharmony_ci P4_OPCODE(P4_EVENT_MEMORY_CANCEL) = P4_OPCODE_PACK(0x02, 0x05), 3328c2ecf20Sopenharmony_ci /* 3338c2ecf20Sopenharmony_ci * MSR_P4_DAC_ESCR0: 8, 9 3348c2ecf20Sopenharmony_ci * MSR_P4_DAC_ESCR1: 10, 11 3358c2ecf20Sopenharmony_ci */ 3368c2ecf20Sopenharmony_ci 3378c2ecf20Sopenharmony_ci P4_OPCODE(P4_EVENT_MEMORY_COMPLETE) = P4_OPCODE_PACK(0x08, 0x02), 3388c2ecf20Sopenharmony_ci /* 3398c2ecf20Sopenharmony_ci * MSR_P4_SAAT_ESCR0: 8, 9 3408c2ecf20Sopenharmony_ci * MSR_P4_SAAT_ESCR1: 10, 11 3418c2ecf20Sopenharmony_ci */ 3428c2ecf20Sopenharmony_ci 3438c2ecf20Sopenharmony_ci P4_OPCODE(P4_EVENT_LOAD_PORT_REPLAY) = P4_OPCODE_PACK(0x04, 0x02), 3448c2ecf20Sopenharmony_ci /* 3458c2ecf20Sopenharmony_ci * MSR_P4_SAAT_ESCR0: 8, 9 3468c2ecf20Sopenharmony_ci * MSR_P4_SAAT_ESCR1: 10, 11 3478c2ecf20Sopenharmony_ci */ 3488c2ecf20Sopenharmony_ci 3498c2ecf20Sopenharmony_ci P4_OPCODE(P4_EVENT_STORE_PORT_REPLAY) = P4_OPCODE_PACK(0x05, 0x02), 3508c2ecf20Sopenharmony_ci /* 3518c2ecf20Sopenharmony_ci * MSR_P4_SAAT_ESCR0: 8, 9 3528c2ecf20Sopenharmony_ci * MSR_P4_SAAT_ESCR1: 10, 11 3538c2ecf20Sopenharmony_ci */ 3548c2ecf20Sopenharmony_ci 3558c2ecf20Sopenharmony_ci P4_OPCODE(P4_EVENT_MOB_LOAD_REPLAY) = P4_OPCODE_PACK(0x03, 0x02), 3568c2ecf20Sopenharmony_ci /* 3578c2ecf20Sopenharmony_ci * MSR_P4_MOB_ESCR0: 0, 1 3588c2ecf20Sopenharmony_ci * MSR_P4_MOB_ESCR1: 2, 3 3598c2ecf20Sopenharmony_ci */ 3608c2ecf20Sopenharmony_ci 3618c2ecf20Sopenharmony_ci P4_OPCODE(P4_EVENT_PAGE_WALK_TYPE) = P4_OPCODE_PACK(0x01, 0x04), 3628c2ecf20Sopenharmony_ci /* 3638c2ecf20Sopenharmony_ci * MSR_P4_PMH_ESCR0: 0, 1 3648c2ecf20Sopenharmony_ci * MSR_P4_PMH_ESCR1: 2, 3 3658c2ecf20Sopenharmony_ci */ 3668c2ecf20Sopenharmony_ci 3678c2ecf20Sopenharmony_ci P4_OPCODE(P4_EVENT_BSQ_CACHE_REFERENCE) = P4_OPCODE_PACK(0x0c, 0x07), 3688c2ecf20Sopenharmony_ci /* 3698c2ecf20Sopenharmony_ci * MSR_P4_BSU_ESCR0: 0, 1 3708c2ecf20Sopenharmony_ci * MSR_P4_BSU_ESCR1: 2, 3 3718c2ecf20Sopenharmony_ci */ 3728c2ecf20Sopenharmony_ci 3738c2ecf20Sopenharmony_ci P4_OPCODE(P4_EVENT_IOQ_ALLOCATION) = P4_OPCODE_PACK(0x03, 0x06), 3748c2ecf20Sopenharmony_ci /* 3758c2ecf20Sopenharmony_ci * MSR_P4_FSB_ESCR0: 0, 1 3768c2ecf20Sopenharmony_ci * MSR_P4_FSB_ESCR1: 2, 3 3778c2ecf20Sopenharmony_ci */ 3788c2ecf20Sopenharmony_ci 3798c2ecf20Sopenharmony_ci P4_OPCODE(P4_EVENT_IOQ_ACTIVE_ENTRIES) = P4_OPCODE_PACK(0x1a, 0x06), 3808c2ecf20Sopenharmony_ci /* 3818c2ecf20Sopenharmony_ci * MSR_P4_FSB_ESCR1: 2, 3 3828c2ecf20Sopenharmony_ci */ 3838c2ecf20Sopenharmony_ci 3848c2ecf20Sopenharmony_ci P4_OPCODE(P4_EVENT_FSB_DATA_ACTIVITY) = P4_OPCODE_PACK(0x17, 0x06), 3858c2ecf20Sopenharmony_ci /* 3868c2ecf20Sopenharmony_ci * MSR_P4_FSB_ESCR0: 0, 1 3878c2ecf20Sopenharmony_ci * MSR_P4_FSB_ESCR1: 2, 3 3888c2ecf20Sopenharmony_ci */ 3898c2ecf20Sopenharmony_ci 3908c2ecf20Sopenharmony_ci P4_OPCODE(P4_EVENT_BSQ_ALLOCATION) = P4_OPCODE_PACK(0x05, 0x07), 3918c2ecf20Sopenharmony_ci /* 3928c2ecf20Sopenharmony_ci * MSR_P4_BSU_ESCR0: 0, 1 3938c2ecf20Sopenharmony_ci */ 3948c2ecf20Sopenharmony_ci 3958c2ecf20Sopenharmony_ci P4_OPCODE(P4_EVENT_BSQ_ACTIVE_ENTRIES) = P4_OPCODE_PACK(0x06, 0x07), 3968c2ecf20Sopenharmony_ci /* 3978c2ecf20Sopenharmony_ci * NOTE: no ESCR name in docs, it's guessed 3988c2ecf20Sopenharmony_ci * MSR_P4_BSU_ESCR1: 2, 3 3998c2ecf20Sopenharmony_ci */ 4008c2ecf20Sopenharmony_ci 4018c2ecf20Sopenharmony_ci P4_OPCODE(P4_EVENT_SSE_INPUT_ASSIST) = P4_OPCODE_PACK(0x34, 0x01), 4028c2ecf20Sopenharmony_ci /* 4038c2ecf20Sopenharmony_ci * MSR_P4_FIRM_ESCR0: 8, 9 4048c2ecf20Sopenharmony_ci * MSR_P4_FIRM_ESCR1: 10, 11 4058c2ecf20Sopenharmony_ci */ 4068c2ecf20Sopenharmony_ci 4078c2ecf20Sopenharmony_ci P4_OPCODE(P4_EVENT_PACKED_SP_UOP) = P4_OPCODE_PACK(0x08, 0x01), 4088c2ecf20Sopenharmony_ci /* 4098c2ecf20Sopenharmony_ci * MSR_P4_FIRM_ESCR0: 8, 9 4108c2ecf20Sopenharmony_ci * MSR_P4_FIRM_ESCR1: 10, 11 4118c2ecf20Sopenharmony_ci */ 4128c2ecf20Sopenharmony_ci 4138c2ecf20Sopenharmony_ci P4_OPCODE(P4_EVENT_PACKED_DP_UOP) = P4_OPCODE_PACK(0x0c, 0x01), 4148c2ecf20Sopenharmony_ci /* 4158c2ecf20Sopenharmony_ci * MSR_P4_FIRM_ESCR0: 8, 9 4168c2ecf20Sopenharmony_ci * MSR_P4_FIRM_ESCR1: 10, 11 4178c2ecf20Sopenharmony_ci */ 4188c2ecf20Sopenharmony_ci 4198c2ecf20Sopenharmony_ci P4_OPCODE(P4_EVENT_SCALAR_SP_UOP) = P4_OPCODE_PACK(0x0a, 0x01), 4208c2ecf20Sopenharmony_ci /* 4218c2ecf20Sopenharmony_ci * MSR_P4_FIRM_ESCR0: 8, 9 4228c2ecf20Sopenharmony_ci * MSR_P4_FIRM_ESCR1: 10, 11 4238c2ecf20Sopenharmony_ci */ 4248c2ecf20Sopenharmony_ci 4258c2ecf20Sopenharmony_ci P4_OPCODE(P4_EVENT_SCALAR_DP_UOP) = P4_OPCODE_PACK(0x0e, 0x01), 4268c2ecf20Sopenharmony_ci /* 4278c2ecf20Sopenharmony_ci * MSR_P4_FIRM_ESCR0: 8, 9 4288c2ecf20Sopenharmony_ci * MSR_P4_FIRM_ESCR1: 10, 11 4298c2ecf20Sopenharmony_ci */ 4308c2ecf20Sopenharmony_ci 4318c2ecf20Sopenharmony_ci P4_OPCODE(P4_EVENT_64BIT_MMX_UOP) = P4_OPCODE_PACK(0x02, 0x01), 4328c2ecf20Sopenharmony_ci /* 4338c2ecf20Sopenharmony_ci * MSR_P4_FIRM_ESCR0: 8, 9 4348c2ecf20Sopenharmony_ci * MSR_P4_FIRM_ESCR1: 10, 11 4358c2ecf20Sopenharmony_ci */ 4368c2ecf20Sopenharmony_ci 4378c2ecf20Sopenharmony_ci P4_OPCODE(P4_EVENT_128BIT_MMX_UOP) = P4_OPCODE_PACK(0x1a, 0x01), 4388c2ecf20Sopenharmony_ci /* 4398c2ecf20Sopenharmony_ci * MSR_P4_FIRM_ESCR0: 8, 9 4408c2ecf20Sopenharmony_ci * MSR_P4_FIRM_ESCR1: 10, 11 4418c2ecf20Sopenharmony_ci */ 4428c2ecf20Sopenharmony_ci 4438c2ecf20Sopenharmony_ci P4_OPCODE(P4_EVENT_X87_FP_UOP) = P4_OPCODE_PACK(0x04, 0x01), 4448c2ecf20Sopenharmony_ci /* 4458c2ecf20Sopenharmony_ci * MSR_P4_FIRM_ESCR0: 8, 9 4468c2ecf20Sopenharmony_ci * MSR_P4_FIRM_ESCR1: 10, 11 4478c2ecf20Sopenharmony_ci */ 4488c2ecf20Sopenharmony_ci 4498c2ecf20Sopenharmony_ci P4_OPCODE(P4_EVENT_TC_MISC) = P4_OPCODE_PACK(0x06, 0x01), 4508c2ecf20Sopenharmony_ci /* 4518c2ecf20Sopenharmony_ci * MSR_P4_TC_ESCR0: 4, 5 4528c2ecf20Sopenharmony_ci * MSR_P4_TC_ESCR1: 6, 7 4538c2ecf20Sopenharmony_ci */ 4548c2ecf20Sopenharmony_ci 4558c2ecf20Sopenharmony_ci P4_OPCODE(P4_EVENT_GLOBAL_POWER_EVENTS) = P4_OPCODE_PACK(0x13, 0x06), 4568c2ecf20Sopenharmony_ci /* 4578c2ecf20Sopenharmony_ci * MSR_P4_FSB_ESCR0: 0, 1 4588c2ecf20Sopenharmony_ci * MSR_P4_FSB_ESCR1: 2, 3 4598c2ecf20Sopenharmony_ci */ 4608c2ecf20Sopenharmony_ci 4618c2ecf20Sopenharmony_ci P4_OPCODE(P4_EVENT_TC_MS_XFER) = P4_OPCODE_PACK(0x05, 0x00), 4628c2ecf20Sopenharmony_ci /* 4638c2ecf20Sopenharmony_ci * MSR_P4_MS_ESCR0: 4, 5 4648c2ecf20Sopenharmony_ci * MSR_P4_MS_ESCR1: 6, 7 4658c2ecf20Sopenharmony_ci */ 4668c2ecf20Sopenharmony_ci 4678c2ecf20Sopenharmony_ci P4_OPCODE(P4_EVENT_UOP_QUEUE_WRITES) = P4_OPCODE_PACK(0x09, 0x00), 4688c2ecf20Sopenharmony_ci /* 4698c2ecf20Sopenharmony_ci * MSR_P4_MS_ESCR0: 4, 5 4708c2ecf20Sopenharmony_ci * MSR_P4_MS_ESCR1: 6, 7 4718c2ecf20Sopenharmony_ci */ 4728c2ecf20Sopenharmony_ci 4738c2ecf20Sopenharmony_ci P4_OPCODE(P4_EVENT_RETIRED_MISPRED_BRANCH_TYPE) = P4_OPCODE_PACK(0x05, 0x02), 4748c2ecf20Sopenharmony_ci /* 4758c2ecf20Sopenharmony_ci * MSR_P4_TBPU_ESCR0: 4, 5 4768c2ecf20Sopenharmony_ci * MSR_P4_TBPU_ESCR1: 6, 7 4778c2ecf20Sopenharmony_ci */ 4788c2ecf20Sopenharmony_ci 4798c2ecf20Sopenharmony_ci P4_OPCODE(P4_EVENT_RETIRED_BRANCH_TYPE) = P4_OPCODE_PACK(0x04, 0x02), 4808c2ecf20Sopenharmony_ci /* 4818c2ecf20Sopenharmony_ci * MSR_P4_TBPU_ESCR0: 4, 5 4828c2ecf20Sopenharmony_ci * MSR_P4_TBPU_ESCR1: 6, 7 4838c2ecf20Sopenharmony_ci */ 4848c2ecf20Sopenharmony_ci 4858c2ecf20Sopenharmony_ci P4_OPCODE(P4_EVENT_RESOURCE_STALL) = P4_OPCODE_PACK(0x01, 0x01), 4868c2ecf20Sopenharmony_ci /* 4878c2ecf20Sopenharmony_ci * MSR_P4_ALF_ESCR0: 12, 13, 16 4888c2ecf20Sopenharmony_ci * MSR_P4_ALF_ESCR1: 14, 15, 17 4898c2ecf20Sopenharmony_ci */ 4908c2ecf20Sopenharmony_ci 4918c2ecf20Sopenharmony_ci P4_OPCODE(P4_EVENT_WC_BUFFER) = P4_OPCODE_PACK(0x05, 0x05), 4928c2ecf20Sopenharmony_ci /* 4938c2ecf20Sopenharmony_ci * MSR_P4_DAC_ESCR0: 8, 9 4948c2ecf20Sopenharmony_ci * MSR_P4_DAC_ESCR1: 10, 11 4958c2ecf20Sopenharmony_ci */ 4968c2ecf20Sopenharmony_ci 4978c2ecf20Sopenharmony_ci P4_OPCODE(P4_EVENT_B2B_CYCLES) = P4_OPCODE_PACK(0x16, 0x03), 4988c2ecf20Sopenharmony_ci /* 4998c2ecf20Sopenharmony_ci * MSR_P4_FSB_ESCR0: 0, 1 5008c2ecf20Sopenharmony_ci * MSR_P4_FSB_ESCR1: 2, 3 5018c2ecf20Sopenharmony_ci */ 5028c2ecf20Sopenharmony_ci 5038c2ecf20Sopenharmony_ci P4_OPCODE(P4_EVENT_BNR) = P4_OPCODE_PACK(0x08, 0x03), 5048c2ecf20Sopenharmony_ci /* 5058c2ecf20Sopenharmony_ci * MSR_P4_FSB_ESCR0: 0, 1 5068c2ecf20Sopenharmony_ci * MSR_P4_FSB_ESCR1: 2, 3 5078c2ecf20Sopenharmony_ci */ 5088c2ecf20Sopenharmony_ci 5098c2ecf20Sopenharmony_ci P4_OPCODE(P4_EVENT_SNOOP) = P4_OPCODE_PACK(0x06, 0x03), 5108c2ecf20Sopenharmony_ci /* 5118c2ecf20Sopenharmony_ci * MSR_P4_FSB_ESCR0: 0, 1 5128c2ecf20Sopenharmony_ci * MSR_P4_FSB_ESCR1: 2, 3 5138c2ecf20Sopenharmony_ci */ 5148c2ecf20Sopenharmony_ci 5158c2ecf20Sopenharmony_ci P4_OPCODE(P4_EVENT_RESPONSE) = P4_OPCODE_PACK(0x04, 0x03), 5168c2ecf20Sopenharmony_ci /* 5178c2ecf20Sopenharmony_ci * MSR_P4_FSB_ESCR0: 0, 1 5188c2ecf20Sopenharmony_ci * MSR_P4_FSB_ESCR1: 2, 3 5198c2ecf20Sopenharmony_ci */ 5208c2ecf20Sopenharmony_ci 5218c2ecf20Sopenharmony_ci P4_OPCODE(P4_EVENT_FRONT_END_EVENT) = P4_OPCODE_PACK(0x08, 0x05), 5228c2ecf20Sopenharmony_ci /* 5238c2ecf20Sopenharmony_ci * MSR_P4_CRU_ESCR2: 12, 13, 16 5248c2ecf20Sopenharmony_ci * MSR_P4_CRU_ESCR3: 14, 15, 17 5258c2ecf20Sopenharmony_ci */ 5268c2ecf20Sopenharmony_ci 5278c2ecf20Sopenharmony_ci P4_OPCODE(P4_EVENT_EXECUTION_EVENT) = P4_OPCODE_PACK(0x0c, 0x05), 5288c2ecf20Sopenharmony_ci /* 5298c2ecf20Sopenharmony_ci * MSR_P4_CRU_ESCR2: 12, 13, 16 5308c2ecf20Sopenharmony_ci * MSR_P4_CRU_ESCR3: 14, 15, 17 5318c2ecf20Sopenharmony_ci */ 5328c2ecf20Sopenharmony_ci 5338c2ecf20Sopenharmony_ci P4_OPCODE(P4_EVENT_REPLAY_EVENT) = P4_OPCODE_PACK(0x09, 0x05), 5348c2ecf20Sopenharmony_ci /* 5358c2ecf20Sopenharmony_ci * MSR_P4_CRU_ESCR2: 12, 13, 16 5368c2ecf20Sopenharmony_ci * MSR_P4_CRU_ESCR3: 14, 15, 17 5378c2ecf20Sopenharmony_ci */ 5388c2ecf20Sopenharmony_ci 5398c2ecf20Sopenharmony_ci P4_OPCODE(P4_EVENT_INSTR_RETIRED) = P4_OPCODE_PACK(0x02, 0x04), 5408c2ecf20Sopenharmony_ci /* 5418c2ecf20Sopenharmony_ci * MSR_P4_CRU_ESCR0: 12, 13, 16 5428c2ecf20Sopenharmony_ci * MSR_P4_CRU_ESCR1: 14, 15, 17 5438c2ecf20Sopenharmony_ci */ 5448c2ecf20Sopenharmony_ci 5458c2ecf20Sopenharmony_ci P4_OPCODE(P4_EVENT_UOPS_RETIRED) = P4_OPCODE_PACK(0x01, 0x04), 5468c2ecf20Sopenharmony_ci /* 5478c2ecf20Sopenharmony_ci * MSR_P4_CRU_ESCR0: 12, 13, 16 5488c2ecf20Sopenharmony_ci * MSR_P4_CRU_ESCR1: 14, 15, 17 5498c2ecf20Sopenharmony_ci */ 5508c2ecf20Sopenharmony_ci 5518c2ecf20Sopenharmony_ci P4_OPCODE(P4_EVENT_UOP_TYPE) = P4_OPCODE_PACK(0x02, 0x02), 5528c2ecf20Sopenharmony_ci /* 5538c2ecf20Sopenharmony_ci * MSR_P4_RAT_ESCR0: 12, 13, 16 5548c2ecf20Sopenharmony_ci * MSR_P4_RAT_ESCR1: 14, 15, 17 5558c2ecf20Sopenharmony_ci */ 5568c2ecf20Sopenharmony_ci 5578c2ecf20Sopenharmony_ci P4_OPCODE(P4_EVENT_BRANCH_RETIRED) = P4_OPCODE_PACK(0x06, 0x05), 5588c2ecf20Sopenharmony_ci /* 5598c2ecf20Sopenharmony_ci * MSR_P4_CRU_ESCR2: 12, 13, 16 5608c2ecf20Sopenharmony_ci * MSR_P4_CRU_ESCR3: 14, 15, 17 5618c2ecf20Sopenharmony_ci */ 5628c2ecf20Sopenharmony_ci 5638c2ecf20Sopenharmony_ci P4_OPCODE(P4_EVENT_MISPRED_BRANCH_RETIRED) = P4_OPCODE_PACK(0x03, 0x04), 5648c2ecf20Sopenharmony_ci /* 5658c2ecf20Sopenharmony_ci * MSR_P4_CRU_ESCR0: 12, 13, 16 5668c2ecf20Sopenharmony_ci * MSR_P4_CRU_ESCR1: 14, 15, 17 5678c2ecf20Sopenharmony_ci */ 5688c2ecf20Sopenharmony_ci 5698c2ecf20Sopenharmony_ci P4_OPCODE(P4_EVENT_X87_ASSIST) = P4_OPCODE_PACK(0x03, 0x05), 5708c2ecf20Sopenharmony_ci /* 5718c2ecf20Sopenharmony_ci * MSR_P4_CRU_ESCR2: 12, 13, 16 5728c2ecf20Sopenharmony_ci * MSR_P4_CRU_ESCR3: 14, 15, 17 5738c2ecf20Sopenharmony_ci */ 5748c2ecf20Sopenharmony_ci 5758c2ecf20Sopenharmony_ci P4_OPCODE(P4_EVENT_MACHINE_CLEAR) = P4_OPCODE_PACK(0x02, 0x05), 5768c2ecf20Sopenharmony_ci /* 5778c2ecf20Sopenharmony_ci * MSR_P4_CRU_ESCR2: 12, 13, 16 5788c2ecf20Sopenharmony_ci * MSR_P4_CRU_ESCR3: 14, 15, 17 5798c2ecf20Sopenharmony_ci */ 5808c2ecf20Sopenharmony_ci 5818c2ecf20Sopenharmony_ci P4_OPCODE(P4_EVENT_INSTR_COMPLETED) = P4_OPCODE_PACK(0x07, 0x04), 5828c2ecf20Sopenharmony_ci /* 5838c2ecf20Sopenharmony_ci * MSR_P4_CRU_ESCR0: 12, 13, 16 5848c2ecf20Sopenharmony_ci * MSR_P4_CRU_ESCR1: 14, 15, 17 5858c2ecf20Sopenharmony_ci */ 5868c2ecf20Sopenharmony_ci}; 5878c2ecf20Sopenharmony_ci 5888c2ecf20Sopenharmony_ci/* 5898c2ecf20Sopenharmony_ci * a caller should use P4_ESCR_EMASK_NAME helper to 5908c2ecf20Sopenharmony_ci * pick the EventMask needed, for example 5918c2ecf20Sopenharmony_ci * 5928c2ecf20Sopenharmony_ci * P4_ESCR_EMASK_BIT(P4_EVENT_TC_DELIVER_MODE, DD) 5938c2ecf20Sopenharmony_ci */ 5948c2ecf20Sopenharmony_cienum P4_ESCR_EMASKS { 5958c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_TC_DELIVER_MODE, DD, 0), 5968c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_TC_DELIVER_MODE, DB, 1), 5978c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_TC_DELIVER_MODE, DI, 2), 5988c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_TC_DELIVER_MODE, BD, 3), 5998c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_TC_DELIVER_MODE, BB, 4), 6008c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_TC_DELIVER_MODE, BI, 5), 6018c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_TC_DELIVER_MODE, ID, 6), 6028c2ecf20Sopenharmony_ci 6038c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_BPU_FETCH_REQUEST, TCMISS, 0), 6048c2ecf20Sopenharmony_ci 6058c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_ITLB_REFERENCE, HIT, 0), 6068c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_ITLB_REFERENCE, MISS, 1), 6078c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_ITLB_REFERENCE, HIT_UK, 2), 6088c2ecf20Sopenharmony_ci 6098c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_MEMORY_CANCEL, ST_RB_FULL, 2), 6108c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_MEMORY_CANCEL, 64K_CONF, 3), 6118c2ecf20Sopenharmony_ci 6128c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_MEMORY_COMPLETE, LSC, 0), 6138c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_MEMORY_COMPLETE, SSC, 1), 6148c2ecf20Sopenharmony_ci 6158c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_LOAD_PORT_REPLAY, SPLIT_LD, 1), 6168c2ecf20Sopenharmony_ci 6178c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_STORE_PORT_REPLAY, SPLIT_ST, 1), 6188c2ecf20Sopenharmony_ci 6198c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_MOB_LOAD_REPLAY, NO_STA, 1), 6208c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_MOB_LOAD_REPLAY, NO_STD, 3), 6218c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_MOB_LOAD_REPLAY, PARTIAL_DATA, 4), 6228c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_MOB_LOAD_REPLAY, UNALGN_ADDR, 5), 6238c2ecf20Sopenharmony_ci 6248c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_PAGE_WALK_TYPE, DTMISS, 0), 6258c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_PAGE_WALK_TYPE, ITMISS, 1), 6268c2ecf20Sopenharmony_ci 6278c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_CACHE_REFERENCE, RD_2ndL_HITS, 0), 6288c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_CACHE_REFERENCE, RD_2ndL_HITE, 1), 6298c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_CACHE_REFERENCE, RD_2ndL_HITM, 2), 6308c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_CACHE_REFERENCE, RD_3rdL_HITS, 3), 6318c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_CACHE_REFERENCE, RD_3rdL_HITE, 4), 6328c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_CACHE_REFERENCE, RD_3rdL_HITM, 5), 6338c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_CACHE_REFERENCE, RD_2ndL_MISS, 8), 6348c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_CACHE_REFERENCE, RD_3rdL_MISS, 9), 6358c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_CACHE_REFERENCE, WR_2ndL_MISS, 10), 6368c2ecf20Sopenharmony_ci 6378c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_IOQ_ALLOCATION, DEFAULT, 0), 6388c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_IOQ_ALLOCATION, ALL_READ, 5), 6398c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_IOQ_ALLOCATION, ALL_WRITE, 6), 6408c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_IOQ_ALLOCATION, MEM_UC, 7), 6418c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_IOQ_ALLOCATION, MEM_WC, 8), 6428c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_IOQ_ALLOCATION, MEM_WT, 9), 6438c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_IOQ_ALLOCATION, MEM_WP, 10), 6448c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_IOQ_ALLOCATION, MEM_WB, 11), 6458c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_IOQ_ALLOCATION, OWN, 13), 6468c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_IOQ_ALLOCATION, OTHER, 14), 6478c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_IOQ_ALLOCATION, PREFETCH, 15), 6488c2ecf20Sopenharmony_ci 6498c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_IOQ_ACTIVE_ENTRIES, DEFAULT, 0), 6508c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_IOQ_ACTIVE_ENTRIES, ALL_READ, 5), 6518c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_IOQ_ACTIVE_ENTRIES, ALL_WRITE, 6), 6528c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_IOQ_ACTIVE_ENTRIES, MEM_UC, 7), 6538c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_IOQ_ACTIVE_ENTRIES, MEM_WC, 8), 6548c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_IOQ_ACTIVE_ENTRIES, MEM_WT, 9), 6558c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_IOQ_ACTIVE_ENTRIES, MEM_WP, 10), 6568c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_IOQ_ACTIVE_ENTRIES, MEM_WB, 11), 6578c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_IOQ_ACTIVE_ENTRIES, OWN, 13), 6588c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_IOQ_ACTIVE_ENTRIES, OTHER, 14), 6598c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_IOQ_ACTIVE_ENTRIES, PREFETCH, 15), 6608c2ecf20Sopenharmony_ci 6618c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_FSB_DATA_ACTIVITY, DRDY_DRV, 0), 6628c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_FSB_DATA_ACTIVITY, DRDY_OWN, 1), 6638c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_FSB_DATA_ACTIVITY, DRDY_OTHER, 2), 6648c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_FSB_DATA_ACTIVITY, DBSY_DRV, 3), 6658c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_FSB_DATA_ACTIVITY, DBSY_OWN, 4), 6668c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_FSB_DATA_ACTIVITY, DBSY_OTHER, 5), 6678c2ecf20Sopenharmony_ci 6688c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_ALLOCATION, REQ_TYPE0, 0), 6698c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_ALLOCATION, REQ_TYPE1, 1), 6708c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_ALLOCATION, REQ_LEN0, 2), 6718c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_ALLOCATION, REQ_LEN1, 3), 6728c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_ALLOCATION, REQ_IO_TYPE, 5), 6738c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_ALLOCATION, REQ_LOCK_TYPE, 6), 6748c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_ALLOCATION, REQ_CACHE_TYPE, 7), 6758c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_ALLOCATION, REQ_SPLIT_TYPE, 8), 6768c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_ALLOCATION, REQ_DEM_TYPE, 9), 6778c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_ALLOCATION, REQ_ORD_TYPE, 10), 6788c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_ALLOCATION, MEM_TYPE0, 11), 6798c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_ALLOCATION, MEM_TYPE1, 12), 6808c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_ALLOCATION, MEM_TYPE2, 13), 6818c2ecf20Sopenharmony_ci 6828c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_ACTIVE_ENTRIES, REQ_TYPE0, 0), 6838c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_ACTIVE_ENTRIES, REQ_TYPE1, 1), 6848c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_ACTIVE_ENTRIES, REQ_LEN0, 2), 6858c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_ACTIVE_ENTRIES, REQ_LEN1, 3), 6868c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_ACTIVE_ENTRIES, REQ_IO_TYPE, 5), 6878c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_ACTIVE_ENTRIES, REQ_LOCK_TYPE, 6), 6888c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_ACTIVE_ENTRIES, REQ_CACHE_TYPE, 7), 6898c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_ACTIVE_ENTRIES, REQ_SPLIT_TYPE, 8), 6908c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_ACTIVE_ENTRIES, REQ_DEM_TYPE, 9), 6918c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_ACTIVE_ENTRIES, REQ_ORD_TYPE, 10), 6928c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_ACTIVE_ENTRIES, MEM_TYPE0, 11), 6938c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_ACTIVE_ENTRIES, MEM_TYPE1, 12), 6948c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_ACTIVE_ENTRIES, MEM_TYPE2, 13), 6958c2ecf20Sopenharmony_ci 6968c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_SSE_INPUT_ASSIST, ALL, 15), 6978c2ecf20Sopenharmony_ci 6988c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_PACKED_SP_UOP, ALL, 15), 6998c2ecf20Sopenharmony_ci 7008c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_PACKED_DP_UOP, ALL, 15), 7018c2ecf20Sopenharmony_ci 7028c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_SCALAR_SP_UOP, ALL, 15), 7038c2ecf20Sopenharmony_ci 7048c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_SCALAR_DP_UOP, ALL, 15), 7058c2ecf20Sopenharmony_ci 7068c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_64BIT_MMX_UOP, ALL, 15), 7078c2ecf20Sopenharmony_ci 7088c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_128BIT_MMX_UOP, ALL, 15), 7098c2ecf20Sopenharmony_ci 7108c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_X87_FP_UOP, ALL, 15), 7118c2ecf20Sopenharmony_ci 7128c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_TC_MISC, FLUSH, 4), 7138c2ecf20Sopenharmony_ci 7148c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_GLOBAL_POWER_EVENTS, RUNNING, 0), 7158c2ecf20Sopenharmony_ci 7168c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_TC_MS_XFER, CISC, 0), 7178c2ecf20Sopenharmony_ci 7188c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_UOP_QUEUE_WRITES, FROM_TC_BUILD, 0), 7198c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_UOP_QUEUE_WRITES, FROM_TC_DELIVER, 1), 7208c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_UOP_QUEUE_WRITES, FROM_ROM, 2), 7218c2ecf20Sopenharmony_ci 7228c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_RETIRED_MISPRED_BRANCH_TYPE, CONDITIONAL, 1), 7238c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_RETIRED_MISPRED_BRANCH_TYPE, CALL, 2), 7248c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_RETIRED_MISPRED_BRANCH_TYPE, RETURN, 3), 7258c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_RETIRED_MISPRED_BRANCH_TYPE, INDIRECT, 4), 7268c2ecf20Sopenharmony_ci 7278c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_RETIRED_BRANCH_TYPE, CONDITIONAL, 1), 7288c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_RETIRED_BRANCH_TYPE, CALL, 2), 7298c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_RETIRED_BRANCH_TYPE, RETURN, 3), 7308c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_RETIRED_BRANCH_TYPE, INDIRECT, 4), 7318c2ecf20Sopenharmony_ci 7328c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_RESOURCE_STALL, SBFULL, 5), 7338c2ecf20Sopenharmony_ci 7348c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_WC_BUFFER, WCB_EVICTS, 0), 7358c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_WC_BUFFER, WCB_FULL_EVICTS, 1), 7368c2ecf20Sopenharmony_ci 7378c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_FRONT_END_EVENT, NBOGUS, 0), 7388c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_FRONT_END_EVENT, BOGUS, 1), 7398c2ecf20Sopenharmony_ci 7408c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_EXECUTION_EVENT, NBOGUS0, 0), 7418c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_EXECUTION_EVENT, NBOGUS1, 1), 7428c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_EXECUTION_EVENT, NBOGUS2, 2), 7438c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_EXECUTION_EVENT, NBOGUS3, 3), 7448c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_EXECUTION_EVENT, BOGUS0, 4), 7458c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_EXECUTION_EVENT, BOGUS1, 5), 7468c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_EXECUTION_EVENT, BOGUS2, 6), 7478c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_EXECUTION_EVENT, BOGUS3, 7), 7488c2ecf20Sopenharmony_ci 7498c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_REPLAY_EVENT, NBOGUS, 0), 7508c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_REPLAY_EVENT, BOGUS, 1), 7518c2ecf20Sopenharmony_ci 7528c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_INSTR_RETIRED, NBOGUSNTAG, 0), 7538c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_INSTR_RETIRED, NBOGUSTAG, 1), 7548c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_INSTR_RETIRED, BOGUSNTAG, 2), 7558c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_INSTR_RETIRED, BOGUSTAG, 3), 7568c2ecf20Sopenharmony_ci 7578c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_UOPS_RETIRED, NBOGUS, 0), 7588c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_UOPS_RETIRED, BOGUS, 1), 7598c2ecf20Sopenharmony_ci 7608c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_UOP_TYPE, TAGLOADS, 1), 7618c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_UOP_TYPE, TAGSTORES, 2), 7628c2ecf20Sopenharmony_ci 7638c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_BRANCH_RETIRED, MMNP, 0), 7648c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_BRANCH_RETIRED, MMNM, 1), 7658c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_BRANCH_RETIRED, MMTP, 2), 7668c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_BRANCH_RETIRED, MMTM, 3), 7678c2ecf20Sopenharmony_ci 7688c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_MISPRED_BRANCH_RETIRED, NBOGUS, 0), 7698c2ecf20Sopenharmony_ci 7708c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_X87_ASSIST, FPSU, 0), 7718c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_X87_ASSIST, FPSO, 1), 7728c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_X87_ASSIST, POAO, 2), 7738c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_X87_ASSIST, POAU, 3), 7748c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_X87_ASSIST, PREA, 4), 7758c2ecf20Sopenharmony_ci 7768c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_MACHINE_CLEAR, CLEAR, 0), 7778c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_MACHINE_CLEAR, MOCLEAR, 1), 7788c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_MACHINE_CLEAR, SMCLEAR, 2), 7798c2ecf20Sopenharmony_ci 7808c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_INSTR_COMPLETED, NBOGUS, 0), 7818c2ecf20Sopenharmony_ci P4_GEN_ESCR_EMASK(P4_EVENT_INSTR_COMPLETED, BOGUS, 1), 7828c2ecf20Sopenharmony_ci}; 7838c2ecf20Sopenharmony_ci 7848c2ecf20Sopenharmony_ci/* 7858c2ecf20Sopenharmony_ci * Note we have UOP and PEBS bits reserved for now 7868c2ecf20Sopenharmony_ci * just in case if we will need them once 7878c2ecf20Sopenharmony_ci */ 7888c2ecf20Sopenharmony_ci#define P4_PEBS_CONFIG_ENABLE (1ULL << 7) 7898c2ecf20Sopenharmony_ci#define P4_PEBS_CONFIG_UOP_TAG (1ULL << 8) 7908c2ecf20Sopenharmony_ci#define P4_PEBS_CONFIG_METRIC_MASK 0x3FLL 7918c2ecf20Sopenharmony_ci#define P4_PEBS_CONFIG_MASK 0xFFLL 7928c2ecf20Sopenharmony_ci 7938c2ecf20Sopenharmony_ci/* 7948c2ecf20Sopenharmony_ci * mem: Only counters MSR_IQ_COUNTER4 (16) and 7958c2ecf20Sopenharmony_ci * MSR_IQ_COUNTER5 (17) are allowed for PEBS sampling 7968c2ecf20Sopenharmony_ci */ 7978c2ecf20Sopenharmony_ci#define P4_PEBS_ENABLE 0x02000000ULL 7988c2ecf20Sopenharmony_ci#define P4_PEBS_ENABLE_UOP_TAG 0x01000000ULL 7998c2ecf20Sopenharmony_ci 8008c2ecf20Sopenharmony_ci#define p4_config_unpack_metric(v) (((u64)(v)) & P4_PEBS_CONFIG_METRIC_MASK) 8018c2ecf20Sopenharmony_ci#define p4_config_unpack_pebs(v) (((u64)(v)) & P4_PEBS_CONFIG_MASK) 8028c2ecf20Sopenharmony_ci 8038c2ecf20Sopenharmony_ci#define p4_config_pebs_has(v, mask) (p4_config_unpack_pebs(v) & (mask)) 8048c2ecf20Sopenharmony_ci 8058c2ecf20Sopenharmony_cienum P4_PEBS_METRIC { 8068c2ecf20Sopenharmony_ci P4_PEBS_METRIC__none, 8078c2ecf20Sopenharmony_ci 8088c2ecf20Sopenharmony_ci P4_PEBS_METRIC__1stl_cache_load_miss_retired, 8098c2ecf20Sopenharmony_ci P4_PEBS_METRIC__2ndl_cache_load_miss_retired, 8108c2ecf20Sopenharmony_ci P4_PEBS_METRIC__dtlb_load_miss_retired, 8118c2ecf20Sopenharmony_ci P4_PEBS_METRIC__dtlb_store_miss_retired, 8128c2ecf20Sopenharmony_ci P4_PEBS_METRIC__dtlb_all_miss_retired, 8138c2ecf20Sopenharmony_ci P4_PEBS_METRIC__tagged_mispred_branch, 8148c2ecf20Sopenharmony_ci P4_PEBS_METRIC__mob_load_replay_retired, 8158c2ecf20Sopenharmony_ci P4_PEBS_METRIC__split_load_retired, 8168c2ecf20Sopenharmony_ci P4_PEBS_METRIC__split_store_retired, 8178c2ecf20Sopenharmony_ci 8188c2ecf20Sopenharmony_ci P4_PEBS_METRIC__max 8198c2ecf20Sopenharmony_ci}; 8208c2ecf20Sopenharmony_ci 8218c2ecf20Sopenharmony_ci/* 8228c2ecf20Sopenharmony_ci * Notes on internal configuration of ESCR+CCCR tuples 8238c2ecf20Sopenharmony_ci * 8248c2ecf20Sopenharmony_ci * Since P4 has quite the different architecture of 8258c2ecf20Sopenharmony_ci * performance registers in compare with "architectural" 8268c2ecf20Sopenharmony_ci * once and we have on 64 bits to keep configuration 8278c2ecf20Sopenharmony_ci * of performance event, the following trick is used. 8288c2ecf20Sopenharmony_ci * 8298c2ecf20Sopenharmony_ci * 1) Since both ESCR and CCCR registers have only low 8308c2ecf20Sopenharmony_ci * 32 bits valuable, we pack them into a single 64 bit 8318c2ecf20Sopenharmony_ci * configuration. Low 32 bits of such config correspond 8328c2ecf20Sopenharmony_ci * to low 32 bits of CCCR register and high 32 bits 8338c2ecf20Sopenharmony_ci * correspond to low 32 bits of ESCR register. 8348c2ecf20Sopenharmony_ci * 8358c2ecf20Sopenharmony_ci * 2) The meaning of every bit of such config field can 8368c2ecf20Sopenharmony_ci * be found in Intel SDM but it should be noted that 8378c2ecf20Sopenharmony_ci * we "borrow" some reserved bits for own usage and 8388c2ecf20Sopenharmony_ci * clean them or set to a proper value when we do 8398c2ecf20Sopenharmony_ci * a real write to hardware registers. 8408c2ecf20Sopenharmony_ci * 8418c2ecf20Sopenharmony_ci * 3) The format of bits of config is the following 8428c2ecf20Sopenharmony_ci * and should be either 0 or set to some predefined 8438c2ecf20Sopenharmony_ci * values: 8448c2ecf20Sopenharmony_ci * 8458c2ecf20Sopenharmony_ci * Low 32 bits 8468c2ecf20Sopenharmony_ci * ----------- 8478c2ecf20Sopenharmony_ci * 0-6: P4_PEBS_METRIC enum 8488c2ecf20Sopenharmony_ci * 7-11: reserved 8498c2ecf20Sopenharmony_ci * 12: reserved (Enable) 8508c2ecf20Sopenharmony_ci * 13-15: reserved (ESCR select) 8518c2ecf20Sopenharmony_ci * 16-17: Active Thread 8528c2ecf20Sopenharmony_ci * 18: Compare 8538c2ecf20Sopenharmony_ci * 19: Complement 8548c2ecf20Sopenharmony_ci * 20-23: Threshold 8558c2ecf20Sopenharmony_ci * 24: Edge 8568c2ecf20Sopenharmony_ci * 25: reserved (FORCE_OVF) 8578c2ecf20Sopenharmony_ci * 26: reserved (OVF_PMI_T0) 8588c2ecf20Sopenharmony_ci * 27: reserved (OVF_PMI_T1) 8598c2ecf20Sopenharmony_ci * 28-29: reserved 8608c2ecf20Sopenharmony_ci * 30: reserved (Cascade) 8618c2ecf20Sopenharmony_ci * 31: reserved (OVF) 8628c2ecf20Sopenharmony_ci * 8638c2ecf20Sopenharmony_ci * High 32 bits 8648c2ecf20Sopenharmony_ci * ------------ 8658c2ecf20Sopenharmony_ci * 0: reserved (T1_USR) 8668c2ecf20Sopenharmony_ci * 1: reserved (T1_OS) 8678c2ecf20Sopenharmony_ci * 2: reserved (T0_USR) 8688c2ecf20Sopenharmony_ci * 3: reserved (T0_OS) 8698c2ecf20Sopenharmony_ci * 4: Tag Enable 8708c2ecf20Sopenharmony_ci * 5-8: Tag Value 8718c2ecf20Sopenharmony_ci * 9-24: Event Mask (may use P4_ESCR_EMASK_BIT helper) 8728c2ecf20Sopenharmony_ci * 25-30: enum P4_EVENTS 8738c2ecf20Sopenharmony_ci * 31: reserved (HT thread) 8748c2ecf20Sopenharmony_ci */ 8758c2ecf20Sopenharmony_ci 8768c2ecf20Sopenharmony_ci#endif /* PERF_EVENT_P4_H */ 8778c2ecf20Sopenharmony_ci 878