162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Netburst Performance Events (P4, old Xeon)
462306a36Sopenharmony_ci */
562306a36Sopenharmony_ci
662306a36Sopenharmony_ci#ifndef PERF_EVENT_P4_H
762306a36Sopenharmony_ci#define PERF_EVENT_P4_H
862306a36Sopenharmony_ci
962306a36Sopenharmony_ci#include <linux/cpu.h>
1062306a36Sopenharmony_ci#include <linux/bitops.h>
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_ci/*
1362306a36Sopenharmony_ci * NetBurst has performance MSRs shared between
1462306a36Sopenharmony_ci * threads if HT is turned on, ie for both logical
1562306a36Sopenharmony_ci * processors (mem: in turn in Atom with HT support
1662306a36Sopenharmony_ci * perf-MSRs are not shared and every thread has its
1762306a36Sopenharmony_ci * own perf-MSRs set)
1862306a36Sopenharmony_ci */
1962306a36Sopenharmony_ci#define ARCH_P4_TOTAL_ESCR	(46)
2062306a36Sopenharmony_ci#define ARCH_P4_RESERVED_ESCR	(2) /* IQ_ESCR(0,1) not always present */
2162306a36Sopenharmony_ci#define ARCH_P4_MAX_ESCR	(ARCH_P4_TOTAL_ESCR - ARCH_P4_RESERVED_ESCR)
2262306a36Sopenharmony_ci#define ARCH_P4_MAX_CCCR	(18)
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_ci#define ARCH_P4_CNTRVAL_BITS	(40)
2562306a36Sopenharmony_ci#define ARCH_P4_CNTRVAL_MASK	((1ULL << ARCH_P4_CNTRVAL_BITS) - 1)
2662306a36Sopenharmony_ci#define ARCH_P4_UNFLAGGED_BIT	((1ULL) << (ARCH_P4_CNTRVAL_BITS - 1))
2762306a36Sopenharmony_ci
2862306a36Sopenharmony_ci#define P4_ESCR_EVENT_MASK	0x7e000000ULL
2962306a36Sopenharmony_ci#define P4_ESCR_EVENT_SHIFT	25
3062306a36Sopenharmony_ci#define P4_ESCR_EVENTMASK_MASK	0x01fffe00ULL
3162306a36Sopenharmony_ci#define P4_ESCR_EVENTMASK_SHIFT	9
3262306a36Sopenharmony_ci#define P4_ESCR_TAG_MASK	0x000001e0ULL
3362306a36Sopenharmony_ci#define P4_ESCR_TAG_SHIFT	5
3462306a36Sopenharmony_ci#define P4_ESCR_TAG_ENABLE	0x00000010ULL
3562306a36Sopenharmony_ci#define P4_ESCR_T0_OS		0x00000008ULL
3662306a36Sopenharmony_ci#define P4_ESCR_T0_USR		0x00000004ULL
3762306a36Sopenharmony_ci#define P4_ESCR_T1_OS		0x00000002ULL
3862306a36Sopenharmony_ci#define P4_ESCR_T1_USR		0x00000001ULL
3962306a36Sopenharmony_ci
4062306a36Sopenharmony_ci#define P4_ESCR_EVENT(v)	((v) << P4_ESCR_EVENT_SHIFT)
4162306a36Sopenharmony_ci#define P4_ESCR_EMASK(v)	((v) << P4_ESCR_EVENTMASK_SHIFT)
4262306a36Sopenharmony_ci#define P4_ESCR_TAG(v)		((v) << P4_ESCR_TAG_SHIFT)
4362306a36Sopenharmony_ci
4462306a36Sopenharmony_ci#define P4_CCCR_OVF			0x80000000ULL
4562306a36Sopenharmony_ci#define P4_CCCR_CASCADE			0x40000000ULL
4662306a36Sopenharmony_ci#define P4_CCCR_OVF_PMI_T0		0x04000000ULL
4762306a36Sopenharmony_ci#define P4_CCCR_OVF_PMI_T1		0x08000000ULL
4862306a36Sopenharmony_ci#define P4_CCCR_FORCE_OVF		0x02000000ULL
4962306a36Sopenharmony_ci#define P4_CCCR_EDGE			0x01000000ULL
5062306a36Sopenharmony_ci#define P4_CCCR_THRESHOLD_MASK		0x00f00000ULL
5162306a36Sopenharmony_ci#define P4_CCCR_THRESHOLD_SHIFT		20
5262306a36Sopenharmony_ci#define P4_CCCR_COMPLEMENT		0x00080000ULL
5362306a36Sopenharmony_ci#define P4_CCCR_COMPARE			0x00040000ULL
5462306a36Sopenharmony_ci#define P4_CCCR_ESCR_SELECT_MASK	0x0000e000ULL
5562306a36Sopenharmony_ci#define P4_CCCR_ESCR_SELECT_SHIFT	13
5662306a36Sopenharmony_ci#define P4_CCCR_ENABLE			0x00001000ULL
5762306a36Sopenharmony_ci#define P4_CCCR_THREAD_SINGLE		0x00010000ULL
5862306a36Sopenharmony_ci#define P4_CCCR_THREAD_BOTH		0x00020000ULL
5962306a36Sopenharmony_ci#define P4_CCCR_THREAD_ANY		0x00030000ULL
6062306a36Sopenharmony_ci#define P4_CCCR_RESERVED		0x00000fffULL
6162306a36Sopenharmony_ci
6262306a36Sopenharmony_ci#define P4_CCCR_THRESHOLD(v)		((v) << P4_CCCR_THRESHOLD_SHIFT)
6362306a36Sopenharmony_ci#define P4_CCCR_ESEL(v)			((v) << P4_CCCR_ESCR_SELECT_SHIFT)
6462306a36Sopenharmony_ci
6562306a36Sopenharmony_ci#define P4_GEN_ESCR_EMASK(class, name, bit)	\
6662306a36Sopenharmony_ci	class##__##name = ((1ULL << bit) << P4_ESCR_EVENTMASK_SHIFT)
6762306a36Sopenharmony_ci#define P4_ESCR_EMASK_BIT(class, name)		class##__##name
6862306a36Sopenharmony_ci
6962306a36Sopenharmony_ci/*
7062306a36Sopenharmony_ci * config field is 64bit width and consists of
7162306a36Sopenharmony_ci * HT << 63 | ESCR << 32 | CCCR
7262306a36Sopenharmony_ci * where HT is HyperThreading bit (since ESCR
7362306a36Sopenharmony_ci * has it reserved we may use it for own purpose)
7462306a36Sopenharmony_ci *
7562306a36Sopenharmony_ci * note that this is NOT the addresses of respective
7662306a36Sopenharmony_ci * ESCR and CCCR but rather an only packed value should
7762306a36Sopenharmony_ci * be unpacked and written to a proper addresses
7862306a36Sopenharmony_ci *
7962306a36Sopenharmony_ci * the base idea is to pack as much info as possible
8062306a36Sopenharmony_ci */
8162306a36Sopenharmony_ci#define p4_config_pack_escr(v)		(((u64)(v)) << 32)
8262306a36Sopenharmony_ci#define p4_config_pack_cccr(v)		(((u64)(v)) & 0xffffffffULL)
8362306a36Sopenharmony_ci#define p4_config_unpack_escr(v)	(((u64)(v)) >> 32)
8462306a36Sopenharmony_ci#define p4_config_unpack_cccr(v)	(((u64)(v)) & 0xffffffffULL)
8562306a36Sopenharmony_ci
8662306a36Sopenharmony_ci#define p4_config_unpack_emask(v)			\
8762306a36Sopenharmony_ci	({						\
8862306a36Sopenharmony_ci		u32 t = p4_config_unpack_escr((v));	\
8962306a36Sopenharmony_ci		t = t &  P4_ESCR_EVENTMASK_MASK;	\
9062306a36Sopenharmony_ci		t = t >> P4_ESCR_EVENTMASK_SHIFT;	\
9162306a36Sopenharmony_ci		t;					\
9262306a36Sopenharmony_ci	})
9362306a36Sopenharmony_ci
9462306a36Sopenharmony_ci#define p4_config_unpack_event(v)			\
9562306a36Sopenharmony_ci	({						\
9662306a36Sopenharmony_ci		u32 t = p4_config_unpack_escr((v));	\
9762306a36Sopenharmony_ci		t = t &  P4_ESCR_EVENT_MASK;		\
9862306a36Sopenharmony_ci		t = t >> P4_ESCR_EVENT_SHIFT;		\
9962306a36Sopenharmony_ci		t;					\
10062306a36Sopenharmony_ci	})
10162306a36Sopenharmony_ci
10262306a36Sopenharmony_ci#define P4_CONFIG_HT_SHIFT		63
10362306a36Sopenharmony_ci#define P4_CONFIG_HT			(1ULL << P4_CONFIG_HT_SHIFT)
10462306a36Sopenharmony_ci
10562306a36Sopenharmony_ci/*
10662306a36Sopenharmony_ci * If an event has alias it should be marked
10762306a36Sopenharmony_ci * with a special bit. (Don't forget to check
10862306a36Sopenharmony_ci * P4_PEBS_CONFIG_MASK and related bits on
10962306a36Sopenharmony_ci * modification.)
11062306a36Sopenharmony_ci */
11162306a36Sopenharmony_ci#define P4_CONFIG_ALIASABLE		(1ULL << 9)
11262306a36Sopenharmony_ci
11362306a36Sopenharmony_ci/*
11462306a36Sopenharmony_ci * The bits we allow to pass for RAW events
11562306a36Sopenharmony_ci */
11662306a36Sopenharmony_ci#define P4_CONFIG_MASK_ESCR		\
11762306a36Sopenharmony_ci	P4_ESCR_EVENT_MASK	|	\
11862306a36Sopenharmony_ci	P4_ESCR_EVENTMASK_MASK	|	\
11962306a36Sopenharmony_ci	P4_ESCR_TAG_MASK	|	\
12062306a36Sopenharmony_ci	P4_ESCR_TAG_ENABLE
12162306a36Sopenharmony_ci
12262306a36Sopenharmony_ci#define P4_CONFIG_MASK_CCCR		\
12362306a36Sopenharmony_ci	P4_CCCR_EDGE		|	\
12462306a36Sopenharmony_ci	P4_CCCR_THRESHOLD_MASK	|	\
12562306a36Sopenharmony_ci	P4_CCCR_COMPLEMENT	|	\
12662306a36Sopenharmony_ci	P4_CCCR_COMPARE		|	\
12762306a36Sopenharmony_ci	P4_CCCR_THREAD_ANY	|	\
12862306a36Sopenharmony_ci	P4_CCCR_RESERVED
12962306a36Sopenharmony_ci
13062306a36Sopenharmony_ci/* some dangerous bits are reserved for kernel internals */
13162306a36Sopenharmony_ci#define P4_CONFIG_MASK				  	  \
13262306a36Sopenharmony_ci	(p4_config_pack_escr(P4_CONFIG_MASK_ESCR))	| \
13362306a36Sopenharmony_ci	(p4_config_pack_cccr(P4_CONFIG_MASK_CCCR))
13462306a36Sopenharmony_ci
13562306a36Sopenharmony_ci/*
13662306a36Sopenharmony_ci * In case of event aliasing we need to preserve some
13762306a36Sopenharmony_ci * caller bits, otherwise the mapping won't be complete.
13862306a36Sopenharmony_ci */
13962306a36Sopenharmony_ci#define P4_CONFIG_EVENT_ALIAS_MASK			  \
14062306a36Sopenharmony_ci	(p4_config_pack_escr(P4_CONFIG_MASK_ESCR)	| \
14162306a36Sopenharmony_ci	 p4_config_pack_cccr(P4_CCCR_EDGE		| \
14262306a36Sopenharmony_ci			     P4_CCCR_THRESHOLD_MASK	| \
14362306a36Sopenharmony_ci			     P4_CCCR_COMPLEMENT		| \
14462306a36Sopenharmony_ci			     P4_CCCR_COMPARE))
14562306a36Sopenharmony_ci
14662306a36Sopenharmony_ci#define  P4_CONFIG_EVENT_ALIAS_IMMUTABLE_BITS		  \
14762306a36Sopenharmony_ci	((P4_CONFIG_HT)					| \
14862306a36Sopenharmony_ci	 p4_config_pack_escr(P4_ESCR_T0_OS		| \
14962306a36Sopenharmony_ci			     P4_ESCR_T0_USR		| \
15062306a36Sopenharmony_ci			     P4_ESCR_T1_OS		| \
15162306a36Sopenharmony_ci			     P4_ESCR_T1_USR)		| \
15262306a36Sopenharmony_ci	 p4_config_pack_cccr(P4_CCCR_OVF		| \
15362306a36Sopenharmony_ci			     P4_CCCR_CASCADE		| \
15462306a36Sopenharmony_ci			     P4_CCCR_FORCE_OVF		| \
15562306a36Sopenharmony_ci			     P4_CCCR_THREAD_ANY		| \
15662306a36Sopenharmony_ci			     P4_CCCR_OVF_PMI_T0		| \
15762306a36Sopenharmony_ci			     P4_CCCR_OVF_PMI_T1		| \
15862306a36Sopenharmony_ci			     P4_CONFIG_ALIASABLE))
15962306a36Sopenharmony_ci
16062306a36Sopenharmony_cistatic inline bool p4_is_event_cascaded(u64 config)
16162306a36Sopenharmony_ci{
16262306a36Sopenharmony_ci	u32 cccr = p4_config_unpack_cccr(config);
16362306a36Sopenharmony_ci	return !!(cccr & P4_CCCR_CASCADE);
16462306a36Sopenharmony_ci}
16562306a36Sopenharmony_ci
16662306a36Sopenharmony_cistatic inline int p4_ht_config_thread(u64 config)
16762306a36Sopenharmony_ci{
16862306a36Sopenharmony_ci	return !!(config & P4_CONFIG_HT);
16962306a36Sopenharmony_ci}
17062306a36Sopenharmony_ci
17162306a36Sopenharmony_cistatic inline u64 p4_set_ht_bit(u64 config)
17262306a36Sopenharmony_ci{
17362306a36Sopenharmony_ci	return config | P4_CONFIG_HT;
17462306a36Sopenharmony_ci}
17562306a36Sopenharmony_ci
17662306a36Sopenharmony_cistatic inline u64 p4_clear_ht_bit(u64 config)
17762306a36Sopenharmony_ci{
17862306a36Sopenharmony_ci	return config & ~P4_CONFIG_HT;
17962306a36Sopenharmony_ci}
18062306a36Sopenharmony_ci
18162306a36Sopenharmony_cistatic inline int p4_ht_active(void)
18262306a36Sopenharmony_ci{
18362306a36Sopenharmony_ci#ifdef CONFIG_SMP
18462306a36Sopenharmony_ci	return smp_num_siblings > 1;
18562306a36Sopenharmony_ci#endif
18662306a36Sopenharmony_ci	return 0;
18762306a36Sopenharmony_ci}
18862306a36Sopenharmony_ci
18962306a36Sopenharmony_cistatic inline int p4_ht_thread(int cpu)
19062306a36Sopenharmony_ci{
19162306a36Sopenharmony_ci#ifdef CONFIG_SMP
19262306a36Sopenharmony_ci	if (smp_num_siblings == 2)
19362306a36Sopenharmony_ci		return cpu != cpumask_first(this_cpu_cpumask_var_ptr(cpu_sibling_map));
19462306a36Sopenharmony_ci#endif
19562306a36Sopenharmony_ci	return 0;
19662306a36Sopenharmony_ci}
19762306a36Sopenharmony_ci
19862306a36Sopenharmony_cistatic inline int p4_should_swap_ts(u64 config, int cpu)
19962306a36Sopenharmony_ci{
20062306a36Sopenharmony_ci	return p4_ht_config_thread(config) ^ p4_ht_thread(cpu);
20162306a36Sopenharmony_ci}
20262306a36Sopenharmony_ci
20362306a36Sopenharmony_cistatic inline u32 p4_default_cccr_conf(int cpu)
20462306a36Sopenharmony_ci{
20562306a36Sopenharmony_ci	/*
20662306a36Sopenharmony_ci	 * Note that P4_CCCR_THREAD_ANY is "required" on
20762306a36Sopenharmony_ci	 * non-HT machines (on HT machines we count TS events
20862306a36Sopenharmony_ci	 * regardless the state of second logical processor
20962306a36Sopenharmony_ci	 */
21062306a36Sopenharmony_ci	u32 cccr = P4_CCCR_THREAD_ANY;
21162306a36Sopenharmony_ci
21262306a36Sopenharmony_ci	if (!p4_ht_thread(cpu))
21362306a36Sopenharmony_ci		cccr |= P4_CCCR_OVF_PMI_T0;
21462306a36Sopenharmony_ci	else
21562306a36Sopenharmony_ci		cccr |= P4_CCCR_OVF_PMI_T1;
21662306a36Sopenharmony_ci
21762306a36Sopenharmony_ci	return cccr;
21862306a36Sopenharmony_ci}
21962306a36Sopenharmony_ci
22062306a36Sopenharmony_cistatic inline u32 p4_default_escr_conf(int cpu, int exclude_os, int exclude_usr)
22162306a36Sopenharmony_ci{
22262306a36Sopenharmony_ci	u32 escr = 0;
22362306a36Sopenharmony_ci
22462306a36Sopenharmony_ci	if (!p4_ht_thread(cpu)) {
22562306a36Sopenharmony_ci		if (!exclude_os)
22662306a36Sopenharmony_ci			escr |= P4_ESCR_T0_OS;
22762306a36Sopenharmony_ci		if (!exclude_usr)
22862306a36Sopenharmony_ci			escr |= P4_ESCR_T0_USR;
22962306a36Sopenharmony_ci	} else {
23062306a36Sopenharmony_ci		if (!exclude_os)
23162306a36Sopenharmony_ci			escr |= P4_ESCR_T1_OS;
23262306a36Sopenharmony_ci		if (!exclude_usr)
23362306a36Sopenharmony_ci			escr |= P4_ESCR_T1_USR;
23462306a36Sopenharmony_ci	}
23562306a36Sopenharmony_ci
23662306a36Sopenharmony_ci	return escr;
23762306a36Sopenharmony_ci}
23862306a36Sopenharmony_ci
23962306a36Sopenharmony_ci/*
24062306a36Sopenharmony_ci * This are the events which should be used in "Event Select"
24162306a36Sopenharmony_ci * field of ESCR register, they are like unique keys which allow
24262306a36Sopenharmony_ci * the kernel to determinate which CCCR and COUNTER should be
24362306a36Sopenharmony_ci * used to track an event
24462306a36Sopenharmony_ci */
24562306a36Sopenharmony_cienum P4_EVENTS {
24662306a36Sopenharmony_ci	P4_EVENT_TC_DELIVER_MODE,
24762306a36Sopenharmony_ci	P4_EVENT_BPU_FETCH_REQUEST,
24862306a36Sopenharmony_ci	P4_EVENT_ITLB_REFERENCE,
24962306a36Sopenharmony_ci	P4_EVENT_MEMORY_CANCEL,
25062306a36Sopenharmony_ci	P4_EVENT_MEMORY_COMPLETE,
25162306a36Sopenharmony_ci	P4_EVENT_LOAD_PORT_REPLAY,
25262306a36Sopenharmony_ci	P4_EVENT_STORE_PORT_REPLAY,
25362306a36Sopenharmony_ci	P4_EVENT_MOB_LOAD_REPLAY,
25462306a36Sopenharmony_ci	P4_EVENT_PAGE_WALK_TYPE,
25562306a36Sopenharmony_ci	P4_EVENT_BSQ_CACHE_REFERENCE,
25662306a36Sopenharmony_ci	P4_EVENT_IOQ_ALLOCATION,
25762306a36Sopenharmony_ci	P4_EVENT_IOQ_ACTIVE_ENTRIES,
25862306a36Sopenharmony_ci	P4_EVENT_FSB_DATA_ACTIVITY,
25962306a36Sopenharmony_ci	P4_EVENT_BSQ_ALLOCATION,
26062306a36Sopenharmony_ci	P4_EVENT_BSQ_ACTIVE_ENTRIES,
26162306a36Sopenharmony_ci	P4_EVENT_SSE_INPUT_ASSIST,
26262306a36Sopenharmony_ci	P4_EVENT_PACKED_SP_UOP,
26362306a36Sopenharmony_ci	P4_EVENT_PACKED_DP_UOP,
26462306a36Sopenharmony_ci	P4_EVENT_SCALAR_SP_UOP,
26562306a36Sopenharmony_ci	P4_EVENT_SCALAR_DP_UOP,
26662306a36Sopenharmony_ci	P4_EVENT_64BIT_MMX_UOP,
26762306a36Sopenharmony_ci	P4_EVENT_128BIT_MMX_UOP,
26862306a36Sopenharmony_ci	P4_EVENT_X87_FP_UOP,
26962306a36Sopenharmony_ci	P4_EVENT_TC_MISC,
27062306a36Sopenharmony_ci	P4_EVENT_GLOBAL_POWER_EVENTS,
27162306a36Sopenharmony_ci	P4_EVENT_TC_MS_XFER,
27262306a36Sopenharmony_ci	P4_EVENT_UOP_QUEUE_WRITES,
27362306a36Sopenharmony_ci	P4_EVENT_RETIRED_MISPRED_BRANCH_TYPE,
27462306a36Sopenharmony_ci	P4_EVENT_RETIRED_BRANCH_TYPE,
27562306a36Sopenharmony_ci	P4_EVENT_RESOURCE_STALL,
27662306a36Sopenharmony_ci	P4_EVENT_WC_BUFFER,
27762306a36Sopenharmony_ci	P4_EVENT_B2B_CYCLES,
27862306a36Sopenharmony_ci	P4_EVENT_BNR,
27962306a36Sopenharmony_ci	P4_EVENT_SNOOP,
28062306a36Sopenharmony_ci	P4_EVENT_RESPONSE,
28162306a36Sopenharmony_ci	P4_EVENT_FRONT_END_EVENT,
28262306a36Sopenharmony_ci	P4_EVENT_EXECUTION_EVENT,
28362306a36Sopenharmony_ci	P4_EVENT_REPLAY_EVENT,
28462306a36Sopenharmony_ci	P4_EVENT_INSTR_RETIRED,
28562306a36Sopenharmony_ci	P4_EVENT_UOPS_RETIRED,
28662306a36Sopenharmony_ci	P4_EVENT_UOP_TYPE,
28762306a36Sopenharmony_ci	P4_EVENT_BRANCH_RETIRED,
28862306a36Sopenharmony_ci	P4_EVENT_MISPRED_BRANCH_RETIRED,
28962306a36Sopenharmony_ci	P4_EVENT_X87_ASSIST,
29062306a36Sopenharmony_ci	P4_EVENT_MACHINE_CLEAR,
29162306a36Sopenharmony_ci	P4_EVENT_INSTR_COMPLETED,
29262306a36Sopenharmony_ci};
29362306a36Sopenharmony_ci
29462306a36Sopenharmony_ci#define P4_OPCODE(event)		event##_OPCODE
29562306a36Sopenharmony_ci#define P4_OPCODE_ESEL(opcode)		((opcode & 0x00ff) >> 0)
29662306a36Sopenharmony_ci#define P4_OPCODE_EVNT(opcode)		((opcode & 0xff00) >> 8)
29762306a36Sopenharmony_ci#define P4_OPCODE_PACK(event, sel)	(((event) << 8) | sel)
29862306a36Sopenharmony_ci
29962306a36Sopenharmony_ci/*
30062306a36Sopenharmony_ci * Comments below the event represent ESCR restriction
30162306a36Sopenharmony_ci * for this event and counter index per ESCR
30262306a36Sopenharmony_ci *
30362306a36Sopenharmony_ci * MSR_P4_IQ_ESCR0 and MSR_P4_IQ_ESCR1 are available only on early
30462306a36Sopenharmony_ci * processor builds (family 0FH, models 01H-02H). These MSRs
30562306a36Sopenharmony_ci * are not available on later versions, so that we don't use
30662306a36Sopenharmony_ci * them completely
30762306a36Sopenharmony_ci *
30862306a36Sopenharmony_ci * Also note that CCCR1 do not have P4_CCCR_ENABLE bit properly
30962306a36Sopenharmony_ci * working so that we should not use this CCCR and respective
31062306a36Sopenharmony_ci * counter as result
31162306a36Sopenharmony_ci */
31262306a36Sopenharmony_cienum P4_EVENT_OPCODES {
31362306a36Sopenharmony_ci	P4_OPCODE(P4_EVENT_TC_DELIVER_MODE)		= P4_OPCODE_PACK(0x01, 0x01),
31462306a36Sopenharmony_ci	/*
31562306a36Sopenharmony_ci	 * MSR_P4_TC_ESCR0:	4, 5
31662306a36Sopenharmony_ci	 * MSR_P4_TC_ESCR1:	6, 7
31762306a36Sopenharmony_ci	 */
31862306a36Sopenharmony_ci
31962306a36Sopenharmony_ci	P4_OPCODE(P4_EVENT_BPU_FETCH_REQUEST)		= P4_OPCODE_PACK(0x03, 0x00),
32062306a36Sopenharmony_ci	/*
32162306a36Sopenharmony_ci	 * MSR_P4_BPU_ESCR0:	0, 1
32262306a36Sopenharmony_ci	 * MSR_P4_BPU_ESCR1:	2, 3
32362306a36Sopenharmony_ci	 */
32462306a36Sopenharmony_ci
32562306a36Sopenharmony_ci	P4_OPCODE(P4_EVENT_ITLB_REFERENCE)		= P4_OPCODE_PACK(0x18, 0x03),
32662306a36Sopenharmony_ci	/*
32762306a36Sopenharmony_ci	 * MSR_P4_ITLB_ESCR0:	0, 1
32862306a36Sopenharmony_ci	 * MSR_P4_ITLB_ESCR1:	2, 3
32962306a36Sopenharmony_ci	 */
33062306a36Sopenharmony_ci
33162306a36Sopenharmony_ci	P4_OPCODE(P4_EVENT_MEMORY_CANCEL)		= P4_OPCODE_PACK(0x02, 0x05),
33262306a36Sopenharmony_ci	/*
33362306a36Sopenharmony_ci	 * MSR_P4_DAC_ESCR0:	8, 9
33462306a36Sopenharmony_ci	 * MSR_P4_DAC_ESCR1:	10, 11
33562306a36Sopenharmony_ci	 */
33662306a36Sopenharmony_ci
33762306a36Sopenharmony_ci	P4_OPCODE(P4_EVENT_MEMORY_COMPLETE)		= P4_OPCODE_PACK(0x08, 0x02),
33862306a36Sopenharmony_ci	/*
33962306a36Sopenharmony_ci	 * MSR_P4_SAAT_ESCR0:	8, 9
34062306a36Sopenharmony_ci	 * MSR_P4_SAAT_ESCR1:	10, 11
34162306a36Sopenharmony_ci	 */
34262306a36Sopenharmony_ci
34362306a36Sopenharmony_ci	P4_OPCODE(P4_EVENT_LOAD_PORT_REPLAY)		= P4_OPCODE_PACK(0x04, 0x02),
34462306a36Sopenharmony_ci	/*
34562306a36Sopenharmony_ci	 * MSR_P4_SAAT_ESCR0:	8, 9
34662306a36Sopenharmony_ci	 * MSR_P4_SAAT_ESCR1:	10, 11
34762306a36Sopenharmony_ci	 */
34862306a36Sopenharmony_ci
34962306a36Sopenharmony_ci	P4_OPCODE(P4_EVENT_STORE_PORT_REPLAY)		= P4_OPCODE_PACK(0x05, 0x02),
35062306a36Sopenharmony_ci	/*
35162306a36Sopenharmony_ci	 * MSR_P4_SAAT_ESCR0:	8, 9
35262306a36Sopenharmony_ci	 * MSR_P4_SAAT_ESCR1:	10, 11
35362306a36Sopenharmony_ci	 */
35462306a36Sopenharmony_ci
35562306a36Sopenharmony_ci	P4_OPCODE(P4_EVENT_MOB_LOAD_REPLAY)		= P4_OPCODE_PACK(0x03, 0x02),
35662306a36Sopenharmony_ci	/*
35762306a36Sopenharmony_ci	 * MSR_P4_MOB_ESCR0:	0, 1
35862306a36Sopenharmony_ci	 * MSR_P4_MOB_ESCR1:	2, 3
35962306a36Sopenharmony_ci	 */
36062306a36Sopenharmony_ci
36162306a36Sopenharmony_ci	P4_OPCODE(P4_EVENT_PAGE_WALK_TYPE)		= P4_OPCODE_PACK(0x01, 0x04),
36262306a36Sopenharmony_ci	/*
36362306a36Sopenharmony_ci	 * MSR_P4_PMH_ESCR0:	0, 1
36462306a36Sopenharmony_ci	 * MSR_P4_PMH_ESCR1:	2, 3
36562306a36Sopenharmony_ci	 */
36662306a36Sopenharmony_ci
36762306a36Sopenharmony_ci	P4_OPCODE(P4_EVENT_BSQ_CACHE_REFERENCE)		= P4_OPCODE_PACK(0x0c, 0x07),
36862306a36Sopenharmony_ci	/*
36962306a36Sopenharmony_ci	 * MSR_P4_BSU_ESCR0:	0, 1
37062306a36Sopenharmony_ci	 * MSR_P4_BSU_ESCR1:	2, 3
37162306a36Sopenharmony_ci	 */
37262306a36Sopenharmony_ci
37362306a36Sopenharmony_ci	P4_OPCODE(P4_EVENT_IOQ_ALLOCATION)		= P4_OPCODE_PACK(0x03, 0x06),
37462306a36Sopenharmony_ci	/*
37562306a36Sopenharmony_ci	 * MSR_P4_FSB_ESCR0:	0, 1
37662306a36Sopenharmony_ci	 * MSR_P4_FSB_ESCR1:	2, 3
37762306a36Sopenharmony_ci	 */
37862306a36Sopenharmony_ci
37962306a36Sopenharmony_ci	P4_OPCODE(P4_EVENT_IOQ_ACTIVE_ENTRIES)		= P4_OPCODE_PACK(0x1a, 0x06),
38062306a36Sopenharmony_ci	/*
38162306a36Sopenharmony_ci	 * MSR_P4_FSB_ESCR1:	2, 3
38262306a36Sopenharmony_ci	 */
38362306a36Sopenharmony_ci
38462306a36Sopenharmony_ci	P4_OPCODE(P4_EVENT_FSB_DATA_ACTIVITY)		= P4_OPCODE_PACK(0x17, 0x06),
38562306a36Sopenharmony_ci	/*
38662306a36Sopenharmony_ci	 * MSR_P4_FSB_ESCR0:	0, 1
38762306a36Sopenharmony_ci	 * MSR_P4_FSB_ESCR1:	2, 3
38862306a36Sopenharmony_ci	 */
38962306a36Sopenharmony_ci
39062306a36Sopenharmony_ci	P4_OPCODE(P4_EVENT_BSQ_ALLOCATION)		= P4_OPCODE_PACK(0x05, 0x07),
39162306a36Sopenharmony_ci	/*
39262306a36Sopenharmony_ci	 * MSR_P4_BSU_ESCR0:	0, 1
39362306a36Sopenharmony_ci	 */
39462306a36Sopenharmony_ci
39562306a36Sopenharmony_ci	P4_OPCODE(P4_EVENT_BSQ_ACTIVE_ENTRIES)		= P4_OPCODE_PACK(0x06, 0x07),
39662306a36Sopenharmony_ci	/*
39762306a36Sopenharmony_ci	 * NOTE: no ESCR name in docs, it's guessed
39862306a36Sopenharmony_ci	 * MSR_P4_BSU_ESCR1:	2, 3
39962306a36Sopenharmony_ci	 */
40062306a36Sopenharmony_ci
40162306a36Sopenharmony_ci	P4_OPCODE(P4_EVENT_SSE_INPUT_ASSIST)		= P4_OPCODE_PACK(0x34, 0x01),
40262306a36Sopenharmony_ci	/*
40362306a36Sopenharmony_ci	 * MSR_P4_FIRM_ESCR0:	8, 9
40462306a36Sopenharmony_ci	 * MSR_P4_FIRM_ESCR1:	10, 11
40562306a36Sopenharmony_ci	 */
40662306a36Sopenharmony_ci
40762306a36Sopenharmony_ci	P4_OPCODE(P4_EVENT_PACKED_SP_UOP)		= P4_OPCODE_PACK(0x08, 0x01),
40862306a36Sopenharmony_ci	/*
40962306a36Sopenharmony_ci	 * MSR_P4_FIRM_ESCR0:	8, 9
41062306a36Sopenharmony_ci	 * MSR_P4_FIRM_ESCR1:	10, 11
41162306a36Sopenharmony_ci	 */
41262306a36Sopenharmony_ci
41362306a36Sopenharmony_ci	P4_OPCODE(P4_EVENT_PACKED_DP_UOP)		= P4_OPCODE_PACK(0x0c, 0x01),
41462306a36Sopenharmony_ci	/*
41562306a36Sopenharmony_ci	 * MSR_P4_FIRM_ESCR0:	8, 9
41662306a36Sopenharmony_ci	 * MSR_P4_FIRM_ESCR1:	10, 11
41762306a36Sopenharmony_ci	 */
41862306a36Sopenharmony_ci
41962306a36Sopenharmony_ci	P4_OPCODE(P4_EVENT_SCALAR_SP_UOP)		= P4_OPCODE_PACK(0x0a, 0x01),
42062306a36Sopenharmony_ci	/*
42162306a36Sopenharmony_ci	 * MSR_P4_FIRM_ESCR0:	8, 9
42262306a36Sopenharmony_ci	 * MSR_P4_FIRM_ESCR1:	10, 11
42362306a36Sopenharmony_ci	 */
42462306a36Sopenharmony_ci
42562306a36Sopenharmony_ci	P4_OPCODE(P4_EVENT_SCALAR_DP_UOP)		= P4_OPCODE_PACK(0x0e, 0x01),
42662306a36Sopenharmony_ci	/*
42762306a36Sopenharmony_ci	 * MSR_P4_FIRM_ESCR0:	8, 9
42862306a36Sopenharmony_ci	 * MSR_P4_FIRM_ESCR1:	10, 11
42962306a36Sopenharmony_ci	 */
43062306a36Sopenharmony_ci
43162306a36Sopenharmony_ci	P4_OPCODE(P4_EVENT_64BIT_MMX_UOP)		= P4_OPCODE_PACK(0x02, 0x01),
43262306a36Sopenharmony_ci	/*
43362306a36Sopenharmony_ci	 * MSR_P4_FIRM_ESCR0:	8, 9
43462306a36Sopenharmony_ci	 * MSR_P4_FIRM_ESCR1:	10, 11
43562306a36Sopenharmony_ci	 */
43662306a36Sopenharmony_ci
43762306a36Sopenharmony_ci	P4_OPCODE(P4_EVENT_128BIT_MMX_UOP)		= P4_OPCODE_PACK(0x1a, 0x01),
43862306a36Sopenharmony_ci	/*
43962306a36Sopenharmony_ci	 * MSR_P4_FIRM_ESCR0:	8, 9
44062306a36Sopenharmony_ci	 * MSR_P4_FIRM_ESCR1:	10, 11
44162306a36Sopenharmony_ci	 */
44262306a36Sopenharmony_ci
44362306a36Sopenharmony_ci	P4_OPCODE(P4_EVENT_X87_FP_UOP)			= P4_OPCODE_PACK(0x04, 0x01),
44462306a36Sopenharmony_ci	/*
44562306a36Sopenharmony_ci	 * MSR_P4_FIRM_ESCR0:	8, 9
44662306a36Sopenharmony_ci	 * MSR_P4_FIRM_ESCR1:	10, 11
44762306a36Sopenharmony_ci	 */
44862306a36Sopenharmony_ci
44962306a36Sopenharmony_ci	P4_OPCODE(P4_EVENT_TC_MISC)			= P4_OPCODE_PACK(0x06, 0x01),
45062306a36Sopenharmony_ci	/*
45162306a36Sopenharmony_ci	 * MSR_P4_TC_ESCR0:	4, 5
45262306a36Sopenharmony_ci	 * MSR_P4_TC_ESCR1:	6, 7
45362306a36Sopenharmony_ci	 */
45462306a36Sopenharmony_ci
45562306a36Sopenharmony_ci	P4_OPCODE(P4_EVENT_GLOBAL_POWER_EVENTS)		= P4_OPCODE_PACK(0x13, 0x06),
45662306a36Sopenharmony_ci	/*
45762306a36Sopenharmony_ci	 * MSR_P4_FSB_ESCR0:	0, 1
45862306a36Sopenharmony_ci	 * MSR_P4_FSB_ESCR1:	2, 3
45962306a36Sopenharmony_ci	 */
46062306a36Sopenharmony_ci
46162306a36Sopenharmony_ci	P4_OPCODE(P4_EVENT_TC_MS_XFER)			= P4_OPCODE_PACK(0x05, 0x00),
46262306a36Sopenharmony_ci	/*
46362306a36Sopenharmony_ci	 * MSR_P4_MS_ESCR0:	4, 5
46462306a36Sopenharmony_ci	 * MSR_P4_MS_ESCR1:	6, 7
46562306a36Sopenharmony_ci	 */
46662306a36Sopenharmony_ci
46762306a36Sopenharmony_ci	P4_OPCODE(P4_EVENT_UOP_QUEUE_WRITES)		= P4_OPCODE_PACK(0x09, 0x00),
46862306a36Sopenharmony_ci	/*
46962306a36Sopenharmony_ci	 * MSR_P4_MS_ESCR0:	4, 5
47062306a36Sopenharmony_ci	 * MSR_P4_MS_ESCR1:	6, 7
47162306a36Sopenharmony_ci	 */
47262306a36Sopenharmony_ci
47362306a36Sopenharmony_ci	P4_OPCODE(P4_EVENT_RETIRED_MISPRED_BRANCH_TYPE)	= P4_OPCODE_PACK(0x05, 0x02),
47462306a36Sopenharmony_ci	/*
47562306a36Sopenharmony_ci	 * MSR_P4_TBPU_ESCR0:	4, 5
47662306a36Sopenharmony_ci	 * MSR_P4_TBPU_ESCR1:	6, 7
47762306a36Sopenharmony_ci	 */
47862306a36Sopenharmony_ci
47962306a36Sopenharmony_ci	P4_OPCODE(P4_EVENT_RETIRED_BRANCH_TYPE)		= P4_OPCODE_PACK(0x04, 0x02),
48062306a36Sopenharmony_ci	/*
48162306a36Sopenharmony_ci	 * MSR_P4_TBPU_ESCR0:	4, 5
48262306a36Sopenharmony_ci	 * MSR_P4_TBPU_ESCR1:	6, 7
48362306a36Sopenharmony_ci	 */
48462306a36Sopenharmony_ci
48562306a36Sopenharmony_ci	P4_OPCODE(P4_EVENT_RESOURCE_STALL)		= P4_OPCODE_PACK(0x01, 0x01),
48662306a36Sopenharmony_ci	/*
48762306a36Sopenharmony_ci	 * MSR_P4_ALF_ESCR0:	12, 13, 16
48862306a36Sopenharmony_ci	 * MSR_P4_ALF_ESCR1:	14, 15, 17
48962306a36Sopenharmony_ci	 */
49062306a36Sopenharmony_ci
49162306a36Sopenharmony_ci	P4_OPCODE(P4_EVENT_WC_BUFFER)			= P4_OPCODE_PACK(0x05, 0x05),
49262306a36Sopenharmony_ci	/*
49362306a36Sopenharmony_ci	 * MSR_P4_DAC_ESCR0:	8, 9
49462306a36Sopenharmony_ci	 * MSR_P4_DAC_ESCR1:	10, 11
49562306a36Sopenharmony_ci	 */
49662306a36Sopenharmony_ci
49762306a36Sopenharmony_ci	P4_OPCODE(P4_EVENT_B2B_CYCLES)			= P4_OPCODE_PACK(0x16, 0x03),
49862306a36Sopenharmony_ci	/*
49962306a36Sopenharmony_ci	 * MSR_P4_FSB_ESCR0:	0, 1
50062306a36Sopenharmony_ci	 * MSR_P4_FSB_ESCR1:	2, 3
50162306a36Sopenharmony_ci	 */
50262306a36Sopenharmony_ci
50362306a36Sopenharmony_ci	P4_OPCODE(P4_EVENT_BNR)				= P4_OPCODE_PACK(0x08, 0x03),
50462306a36Sopenharmony_ci	/*
50562306a36Sopenharmony_ci	 * MSR_P4_FSB_ESCR0:	0, 1
50662306a36Sopenharmony_ci	 * MSR_P4_FSB_ESCR1:	2, 3
50762306a36Sopenharmony_ci	 */
50862306a36Sopenharmony_ci
50962306a36Sopenharmony_ci	P4_OPCODE(P4_EVENT_SNOOP)			= P4_OPCODE_PACK(0x06, 0x03),
51062306a36Sopenharmony_ci	/*
51162306a36Sopenharmony_ci	 * MSR_P4_FSB_ESCR0:	0, 1
51262306a36Sopenharmony_ci	 * MSR_P4_FSB_ESCR1:	2, 3
51362306a36Sopenharmony_ci	 */
51462306a36Sopenharmony_ci
51562306a36Sopenharmony_ci	P4_OPCODE(P4_EVENT_RESPONSE)			= P4_OPCODE_PACK(0x04, 0x03),
51662306a36Sopenharmony_ci	/*
51762306a36Sopenharmony_ci	 * MSR_P4_FSB_ESCR0:	0, 1
51862306a36Sopenharmony_ci	 * MSR_P4_FSB_ESCR1:	2, 3
51962306a36Sopenharmony_ci	 */
52062306a36Sopenharmony_ci
52162306a36Sopenharmony_ci	P4_OPCODE(P4_EVENT_FRONT_END_EVENT)		= P4_OPCODE_PACK(0x08, 0x05),
52262306a36Sopenharmony_ci	/*
52362306a36Sopenharmony_ci	 * MSR_P4_CRU_ESCR2:	12, 13, 16
52462306a36Sopenharmony_ci	 * MSR_P4_CRU_ESCR3:	14, 15, 17
52562306a36Sopenharmony_ci	 */
52662306a36Sopenharmony_ci
52762306a36Sopenharmony_ci	P4_OPCODE(P4_EVENT_EXECUTION_EVENT)		= P4_OPCODE_PACK(0x0c, 0x05),
52862306a36Sopenharmony_ci	/*
52962306a36Sopenharmony_ci	 * MSR_P4_CRU_ESCR2:	12, 13, 16
53062306a36Sopenharmony_ci	 * MSR_P4_CRU_ESCR3:	14, 15, 17
53162306a36Sopenharmony_ci	 */
53262306a36Sopenharmony_ci
53362306a36Sopenharmony_ci	P4_OPCODE(P4_EVENT_REPLAY_EVENT)		= P4_OPCODE_PACK(0x09, 0x05),
53462306a36Sopenharmony_ci	/*
53562306a36Sopenharmony_ci	 * MSR_P4_CRU_ESCR2:	12, 13, 16
53662306a36Sopenharmony_ci	 * MSR_P4_CRU_ESCR3:	14, 15, 17
53762306a36Sopenharmony_ci	 */
53862306a36Sopenharmony_ci
53962306a36Sopenharmony_ci	P4_OPCODE(P4_EVENT_INSTR_RETIRED)		= P4_OPCODE_PACK(0x02, 0x04),
54062306a36Sopenharmony_ci	/*
54162306a36Sopenharmony_ci	 * MSR_P4_CRU_ESCR0:	12, 13, 16
54262306a36Sopenharmony_ci	 * MSR_P4_CRU_ESCR1:	14, 15, 17
54362306a36Sopenharmony_ci	 */
54462306a36Sopenharmony_ci
54562306a36Sopenharmony_ci	P4_OPCODE(P4_EVENT_UOPS_RETIRED)		= P4_OPCODE_PACK(0x01, 0x04),
54662306a36Sopenharmony_ci	/*
54762306a36Sopenharmony_ci	 * MSR_P4_CRU_ESCR0:	12, 13, 16
54862306a36Sopenharmony_ci	 * MSR_P4_CRU_ESCR1:	14, 15, 17
54962306a36Sopenharmony_ci	 */
55062306a36Sopenharmony_ci
55162306a36Sopenharmony_ci	P4_OPCODE(P4_EVENT_UOP_TYPE)			= P4_OPCODE_PACK(0x02, 0x02),
55262306a36Sopenharmony_ci	/*
55362306a36Sopenharmony_ci	 * MSR_P4_RAT_ESCR0:	12, 13, 16
55462306a36Sopenharmony_ci	 * MSR_P4_RAT_ESCR1:	14, 15, 17
55562306a36Sopenharmony_ci	 */
55662306a36Sopenharmony_ci
55762306a36Sopenharmony_ci	P4_OPCODE(P4_EVENT_BRANCH_RETIRED)		= P4_OPCODE_PACK(0x06, 0x05),
55862306a36Sopenharmony_ci	/*
55962306a36Sopenharmony_ci	 * MSR_P4_CRU_ESCR2:	12, 13, 16
56062306a36Sopenharmony_ci	 * MSR_P4_CRU_ESCR3:	14, 15, 17
56162306a36Sopenharmony_ci	 */
56262306a36Sopenharmony_ci
56362306a36Sopenharmony_ci	P4_OPCODE(P4_EVENT_MISPRED_BRANCH_RETIRED)	= P4_OPCODE_PACK(0x03, 0x04),
56462306a36Sopenharmony_ci	/*
56562306a36Sopenharmony_ci	 * MSR_P4_CRU_ESCR0:	12, 13, 16
56662306a36Sopenharmony_ci	 * MSR_P4_CRU_ESCR1:	14, 15, 17
56762306a36Sopenharmony_ci	 */
56862306a36Sopenharmony_ci
56962306a36Sopenharmony_ci	P4_OPCODE(P4_EVENT_X87_ASSIST)			= P4_OPCODE_PACK(0x03, 0x05),
57062306a36Sopenharmony_ci	/*
57162306a36Sopenharmony_ci	 * MSR_P4_CRU_ESCR2:	12, 13, 16
57262306a36Sopenharmony_ci	 * MSR_P4_CRU_ESCR3:	14, 15, 17
57362306a36Sopenharmony_ci	 */
57462306a36Sopenharmony_ci
57562306a36Sopenharmony_ci	P4_OPCODE(P4_EVENT_MACHINE_CLEAR)		= P4_OPCODE_PACK(0x02, 0x05),
57662306a36Sopenharmony_ci	/*
57762306a36Sopenharmony_ci	 * MSR_P4_CRU_ESCR2:	12, 13, 16
57862306a36Sopenharmony_ci	 * MSR_P4_CRU_ESCR3:	14, 15, 17
57962306a36Sopenharmony_ci	 */
58062306a36Sopenharmony_ci
58162306a36Sopenharmony_ci	P4_OPCODE(P4_EVENT_INSTR_COMPLETED)		= P4_OPCODE_PACK(0x07, 0x04),
58262306a36Sopenharmony_ci	/*
58362306a36Sopenharmony_ci	 * MSR_P4_CRU_ESCR0:	12, 13, 16
58462306a36Sopenharmony_ci	 * MSR_P4_CRU_ESCR1:	14, 15, 17
58562306a36Sopenharmony_ci	 */
58662306a36Sopenharmony_ci};
58762306a36Sopenharmony_ci
58862306a36Sopenharmony_ci/*
58962306a36Sopenharmony_ci * a caller should use P4_ESCR_EMASK_NAME helper to
59062306a36Sopenharmony_ci * pick the EventMask needed, for example
59162306a36Sopenharmony_ci *
59262306a36Sopenharmony_ci *	P4_ESCR_EMASK_BIT(P4_EVENT_TC_DELIVER_MODE, DD)
59362306a36Sopenharmony_ci */
59462306a36Sopenharmony_cienum P4_ESCR_EMASKS {
59562306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_TC_DELIVER_MODE, DD, 0),
59662306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_TC_DELIVER_MODE, DB, 1),
59762306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_TC_DELIVER_MODE, DI, 2),
59862306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_TC_DELIVER_MODE, BD, 3),
59962306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_TC_DELIVER_MODE, BB, 4),
60062306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_TC_DELIVER_MODE, BI, 5),
60162306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_TC_DELIVER_MODE, ID, 6),
60262306a36Sopenharmony_ci
60362306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_BPU_FETCH_REQUEST, TCMISS, 0),
60462306a36Sopenharmony_ci
60562306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_ITLB_REFERENCE, HIT, 0),
60662306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_ITLB_REFERENCE, MISS, 1),
60762306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_ITLB_REFERENCE, HIT_UK, 2),
60862306a36Sopenharmony_ci
60962306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_MEMORY_CANCEL, ST_RB_FULL, 2),
61062306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_MEMORY_CANCEL, 64K_CONF, 3),
61162306a36Sopenharmony_ci
61262306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_MEMORY_COMPLETE, LSC, 0),
61362306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_MEMORY_COMPLETE, SSC, 1),
61462306a36Sopenharmony_ci
61562306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_LOAD_PORT_REPLAY, SPLIT_LD, 1),
61662306a36Sopenharmony_ci
61762306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_STORE_PORT_REPLAY, SPLIT_ST, 1),
61862306a36Sopenharmony_ci
61962306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_MOB_LOAD_REPLAY, NO_STA, 1),
62062306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_MOB_LOAD_REPLAY, NO_STD, 3),
62162306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_MOB_LOAD_REPLAY, PARTIAL_DATA, 4),
62262306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_MOB_LOAD_REPLAY, UNALGN_ADDR, 5),
62362306a36Sopenharmony_ci
62462306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_PAGE_WALK_TYPE, DTMISS, 0),
62562306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_PAGE_WALK_TYPE, ITMISS, 1),
62662306a36Sopenharmony_ci
62762306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_CACHE_REFERENCE, RD_2ndL_HITS, 0),
62862306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_CACHE_REFERENCE, RD_2ndL_HITE, 1),
62962306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_CACHE_REFERENCE, RD_2ndL_HITM, 2),
63062306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_CACHE_REFERENCE, RD_3rdL_HITS, 3),
63162306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_CACHE_REFERENCE, RD_3rdL_HITE, 4),
63262306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_CACHE_REFERENCE, RD_3rdL_HITM, 5),
63362306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_CACHE_REFERENCE, RD_2ndL_MISS, 8),
63462306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_CACHE_REFERENCE, RD_3rdL_MISS, 9),
63562306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_CACHE_REFERENCE, WR_2ndL_MISS, 10),
63662306a36Sopenharmony_ci
63762306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_IOQ_ALLOCATION, DEFAULT, 0),
63862306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_IOQ_ALLOCATION, ALL_READ, 5),
63962306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_IOQ_ALLOCATION, ALL_WRITE, 6),
64062306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_IOQ_ALLOCATION, MEM_UC, 7),
64162306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_IOQ_ALLOCATION, MEM_WC, 8),
64262306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_IOQ_ALLOCATION, MEM_WT, 9),
64362306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_IOQ_ALLOCATION, MEM_WP, 10),
64462306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_IOQ_ALLOCATION, MEM_WB, 11),
64562306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_IOQ_ALLOCATION, OWN, 13),
64662306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_IOQ_ALLOCATION, OTHER, 14),
64762306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_IOQ_ALLOCATION, PREFETCH, 15),
64862306a36Sopenharmony_ci
64962306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_IOQ_ACTIVE_ENTRIES, DEFAULT, 0),
65062306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_IOQ_ACTIVE_ENTRIES, ALL_READ, 5),
65162306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_IOQ_ACTIVE_ENTRIES, ALL_WRITE, 6),
65262306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_IOQ_ACTIVE_ENTRIES, MEM_UC, 7),
65362306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_IOQ_ACTIVE_ENTRIES, MEM_WC, 8),
65462306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_IOQ_ACTIVE_ENTRIES, MEM_WT, 9),
65562306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_IOQ_ACTIVE_ENTRIES, MEM_WP, 10),
65662306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_IOQ_ACTIVE_ENTRIES, MEM_WB, 11),
65762306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_IOQ_ACTIVE_ENTRIES, OWN, 13),
65862306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_IOQ_ACTIVE_ENTRIES, OTHER, 14),
65962306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_IOQ_ACTIVE_ENTRIES, PREFETCH, 15),
66062306a36Sopenharmony_ci
66162306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_FSB_DATA_ACTIVITY, DRDY_DRV, 0),
66262306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_FSB_DATA_ACTIVITY, DRDY_OWN, 1),
66362306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_FSB_DATA_ACTIVITY, DRDY_OTHER, 2),
66462306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_FSB_DATA_ACTIVITY, DBSY_DRV, 3),
66562306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_FSB_DATA_ACTIVITY, DBSY_OWN, 4),
66662306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_FSB_DATA_ACTIVITY, DBSY_OTHER, 5),
66762306a36Sopenharmony_ci
66862306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_ALLOCATION, REQ_TYPE0, 0),
66962306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_ALLOCATION, REQ_TYPE1, 1),
67062306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_ALLOCATION, REQ_LEN0, 2),
67162306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_ALLOCATION, REQ_LEN1, 3),
67262306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_ALLOCATION, REQ_IO_TYPE, 5),
67362306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_ALLOCATION, REQ_LOCK_TYPE, 6),
67462306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_ALLOCATION, REQ_CACHE_TYPE, 7),
67562306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_ALLOCATION, REQ_SPLIT_TYPE, 8),
67662306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_ALLOCATION, REQ_DEM_TYPE, 9),
67762306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_ALLOCATION, REQ_ORD_TYPE, 10),
67862306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_ALLOCATION, MEM_TYPE0, 11),
67962306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_ALLOCATION, MEM_TYPE1, 12),
68062306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_ALLOCATION, MEM_TYPE2, 13),
68162306a36Sopenharmony_ci
68262306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_ACTIVE_ENTRIES, REQ_TYPE0, 0),
68362306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_ACTIVE_ENTRIES, REQ_TYPE1, 1),
68462306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_ACTIVE_ENTRIES, REQ_LEN0, 2),
68562306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_ACTIVE_ENTRIES, REQ_LEN1, 3),
68662306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_ACTIVE_ENTRIES, REQ_IO_TYPE, 5),
68762306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_ACTIVE_ENTRIES, REQ_LOCK_TYPE, 6),
68862306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_ACTIVE_ENTRIES, REQ_CACHE_TYPE, 7),
68962306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_ACTIVE_ENTRIES, REQ_SPLIT_TYPE, 8),
69062306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_ACTIVE_ENTRIES, REQ_DEM_TYPE, 9),
69162306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_ACTIVE_ENTRIES, REQ_ORD_TYPE, 10),
69262306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_ACTIVE_ENTRIES, MEM_TYPE0, 11),
69362306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_ACTIVE_ENTRIES, MEM_TYPE1, 12),
69462306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_BSQ_ACTIVE_ENTRIES, MEM_TYPE2, 13),
69562306a36Sopenharmony_ci
69662306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_SSE_INPUT_ASSIST, ALL, 15),
69762306a36Sopenharmony_ci
69862306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_PACKED_SP_UOP, ALL, 15),
69962306a36Sopenharmony_ci
70062306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_PACKED_DP_UOP, ALL, 15),
70162306a36Sopenharmony_ci
70262306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_SCALAR_SP_UOP, ALL, 15),
70362306a36Sopenharmony_ci
70462306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_SCALAR_DP_UOP, ALL, 15),
70562306a36Sopenharmony_ci
70662306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_64BIT_MMX_UOP, ALL, 15),
70762306a36Sopenharmony_ci
70862306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_128BIT_MMX_UOP, ALL, 15),
70962306a36Sopenharmony_ci
71062306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_X87_FP_UOP, ALL, 15),
71162306a36Sopenharmony_ci
71262306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_TC_MISC, FLUSH, 4),
71362306a36Sopenharmony_ci
71462306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_GLOBAL_POWER_EVENTS, RUNNING, 0),
71562306a36Sopenharmony_ci
71662306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_TC_MS_XFER, CISC, 0),
71762306a36Sopenharmony_ci
71862306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_UOP_QUEUE_WRITES, FROM_TC_BUILD, 0),
71962306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_UOP_QUEUE_WRITES, FROM_TC_DELIVER, 1),
72062306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_UOP_QUEUE_WRITES, FROM_ROM, 2),
72162306a36Sopenharmony_ci
72262306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_RETIRED_MISPRED_BRANCH_TYPE, CONDITIONAL, 1),
72362306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_RETIRED_MISPRED_BRANCH_TYPE, CALL, 2),
72462306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_RETIRED_MISPRED_BRANCH_TYPE, RETURN, 3),
72562306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_RETIRED_MISPRED_BRANCH_TYPE, INDIRECT, 4),
72662306a36Sopenharmony_ci
72762306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_RETIRED_BRANCH_TYPE, CONDITIONAL, 1),
72862306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_RETIRED_BRANCH_TYPE, CALL, 2),
72962306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_RETIRED_BRANCH_TYPE, RETURN, 3),
73062306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_RETIRED_BRANCH_TYPE, INDIRECT, 4),
73162306a36Sopenharmony_ci
73262306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_RESOURCE_STALL, SBFULL, 5),
73362306a36Sopenharmony_ci
73462306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_WC_BUFFER, WCB_EVICTS, 0),
73562306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_WC_BUFFER, WCB_FULL_EVICTS, 1),
73662306a36Sopenharmony_ci
73762306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_FRONT_END_EVENT, NBOGUS, 0),
73862306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_FRONT_END_EVENT, BOGUS, 1),
73962306a36Sopenharmony_ci
74062306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_EXECUTION_EVENT, NBOGUS0, 0),
74162306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_EXECUTION_EVENT, NBOGUS1, 1),
74262306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_EXECUTION_EVENT, NBOGUS2, 2),
74362306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_EXECUTION_EVENT, NBOGUS3, 3),
74462306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_EXECUTION_EVENT, BOGUS0, 4),
74562306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_EXECUTION_EVENT, BOGUS1, 5),
74662306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_EXECUTION_EVENT, BOGUS2, 6),
74762306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_EXECUTION_EVENT, BOGUS3, 7),
74862306a36Sopenharmony_ci
74962306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_REPLAY_EVENT, NBOGUS, 0),
75062306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_REPLAY_EVENT, BOGUS, 1),
75162306a36Sopenharmony_ci
75262306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_INSTR_RETIRED, NBOGUSNTAG, 0),
75362306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_INSTR_RETIRED, NBOGUSTAG, 1),
75462306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_INSTR_RETIRED, BOGUSNTAG, 2),
75562306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_INSTR_RETIRED, BOGUSTAG, 3),
75662306a36Sopenharmony_ci
75762306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_UOPS_RETIRED, NBOGUS, 0),
75862306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_UOPS_RETIRED, BOGUS, 1),
75962306a36Sopenharmony_ci
76062306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_UOP_TYPE, TAGLOADS, 1),
76162306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_UOP_TYPE, TAGSTORES, 2),
76262306a36Sopenharmony_ci
76362306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_BRANCH_RETIRED, MMNP, 0),
76462306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_BRANCH_RETIRED, MMNM, 1),
76562306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_BRANCH_RETIRED, MMTP, 2),
76662306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_BRANCH_RETIRED, MMTM, 3),
76762306a36Sopenharmony_ci
76862306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_MISPRED_BRANCH_RETIRED, NBOGUS, 0),
76962306a36Sopenharmony_ci
77062306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_X87_ASSIST, FPSU, 0),
77162306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_X87_ASSIST, FPSO, 1),
77262306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_X87_ASSIST, POAO, 2),
77362306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_X87_ASSIST, POAU, 3),
77462306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_X87_ASSIST, PREA, 4),
77562306a36Sopenharmony_ci
77662306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_MACHINE_CLEAR, CLEAR, 0),
77762306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_MACHINE_CLEAR, MOCLEAR, 1),
77862306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_MACHINE_CLEAR, SMCLEAR, 2),
77962306a36Sopenharmony_ci
78062306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_INSTR_COMPLETED, NBOGUS, 0),
78162306a36Sopenharmony_ci	P4_GEN_ESCR_EMASK(P4_EVENT_INSTR_COMPLETED, BOGUS, 1),
78262306a36Sopenharmony_ci};
78362306a36Sopenharmony_ci
78462306a36Sopenharmony_ci/*
78562306a36Sopenharmony_ci * Note we have UOP and PEBS bits reserved for now
78662306a36Sopenharmony_ci * just in case if we will need them once
78762306a36Sopenharmony_ci */
78862306a36Sopenharmony_ci#define P4_PEBS_CONFIG_ENABLE		(1ULL << 7)
78962306a36Sopenharmony_ci#define P4_PEBS_CONFIG_UOP_TAG		(1ULL << 8)
79062306a36Sopenharmony_ci#define P4_PEBS_CONFIG_METRIC_MASK	0x3FLL
79162306a36Sopenharmony_ci#define P4_PEBS_CONFIG_MASK		0xFFLL
79262306a36Sopenharmony_ci
79362306a36Sopenharmony_ci/*
79462306a36Sopenharmony_ci * mem: Only counters MSR_IQ_COUNTER4 (16) and
79562306a36Sopenharmony_ci * MSR_IQ_COUNTER5 (17) are allowed for PEBS sampling
79662306a36Sopenharmony_ci */
79762306a36Sopenharmony_ci#define P4_PEBS_ENABLE			0x02000000ULL
79862306a36Sopenharmony_ci#define P4_PEBS_ENABLE_UOP_TAG		0x01000000ULL
79962306a36Sopenharmony_ci
80062306a36Sopenharmony_ci#define p4_config_unpack_metric(v)	(((u64)(v)) & P4_PEBS_CONFIG_METRIC_MASK)
80162306a36Sopenharmony_ci#define p4_config_unpack_pebs(v)	(((u64)(v)) & P4_PEBS_CONFIG_MASK)
80262306a36Sopenharmony_ci
80362306a36Sopenharmony_ci#define p4_config_pebs_has(v, mask)	(p4_config_unpack_pebs(v) & (mask))
80462306a36Sopenharmony_ci
80562306a36Sopenharmony_cienum P4_PEBS_METRIC {
80662306a36Sopenharmony_ci	P4_PEBS_METRIC__none,
80762306a36Sopenharmony_ci
80862306a36Sopenharmony_ci	P4_PEBS_METRIC__1stl_cache_load_miss_retired,
80962306a36Sopenharmony_ci	P4_PEBS_METRIC__2ndl_cache_load_miss_retired,
81062306a36Sopenharmony_ci	P4_PEBS_METRIC__dtlb_load_miss_retired,
81162306a36Sopenharmony_ci	P4_PEBS_METRIC__dtlb_store_miss_retired,
81262306a36Sopenharmony_ci	P4_PEBS_METRIC__dtlb_all_miss_retired,
81362306a36Sopenharmony_ci	P4_PEBS_METRIC__tagged_mispred_branch,
81462306a36Sopenharmony_ci	P4_PEBS_METRIC__mob_load_replay_retired,
81562306a36Sopenharmony_ci	P4_PEBS_METRIC__split_load_retired,
81662306a36Sopenharmony_ci	P4_PEBS_METRIC__split_store_retired,
81762306a36Sopenharmony_ci
81862306a36Sopenharmony_ci	P4_PEBS_METRIC__max
81962306a36Sopenharmony_ci};
82062306a36Sopenharmony_ci
82162306a36Sopenharmony_ci/*
82262306a36Sopenharmony_ci * Notes on internal configuration of ESCR+CCCR tuples
82362306a36Sopenharmony_ci *
82462306a36Sopenharmony_ci * Since P4 has quite the different architecture of
82562306a36Sopenharmony_ci * performance registers in compare with "architectural"
82662306a36Sopenharmony_ci * once and we have on 64 bits to keep configuration
82762306a36Sopenharmony_ci * of performance event, the following trick is used.
82862306a36Sopenharmony_ci *
82962306a36Sopenharmony_ci * 1) Since both ESCR and CCCR registers have only low
83062306a36Sopenharmony_ci *    32 bits valuable, we pack them into a single 64 bit
83162306a36Sopenharmony_ci *    configuration. Low 32 bits of such config correspond
83262306a36Sopenharmony_ci *    to low 32 bits of CCCR register and high 32 bits
83362306a36Sopenharmony_ci *    correspond to low 32 bits of ESCR register.
83462306a36Sopenharmony_ci *
83562306a36Sopenharmony_ci * 2) The meaning of every bit of such config field can
83662306a36Sopenharmony_ci *    be found in Intel SDM but it should be noted that
83762306a36Sopenharmony_ci *    we "borrow" some reserved bits for own usage and
83862306a36Sopenharmony_ci *    clean them or set to a proper value when we do
83962306a36Sopenharmony_ci *    a real write to hardware registers.
84062306a36Sopenharmony_ci *
84162306a36Sopenharmony_ci * 3) The format of bits of config is the following
84262306a36Sopenharmony_ci *    and should be either 0 or set to some predefined
84362306a36Sopenharmony_ci *    values:
84462306a36Sopenharmony_ci *
84562306a36Sopenharmony_ci *    Low 32 bits
84662306a36Sopenharmony_ci *    -----------
84762306a36Sopenharmony_ci *      0-6: P4_PEBS_METRIC enum
84862306a36Sopenharmony_ci *     7-11:                    reserved
84962306a36Sopenharmony_ci *       12:                    reserved (Enable)
85062306a36Sopenharmony_ci *    13-15:                    reserved (ESCR select)
85162306a36Sopenharmony_ci *    16-17: Active Thread
85262306a36Sopenharmony_ci *       18: Compare
85362306a36Sopenharmony_ci *       19: Complement
85462306a36Sopenharmony_ci *    20-23: Threshold
85562306a36Sopenharmony_ci *       24: Edge
85662306a36Sopenharmony_ci *       25:                    reserved (FORCE_OVF)
85762306a36Sopenharmony_ci *       26:                    reserved (OVF_PMI_T0)
85862306a36Sopenharmony_ci *       27:                    reserved (OVF_PMI_T1)
85962306a36Sopenharmony_ci *    28-29:                    reserved
86062306a36Sopenharmony_ci *       30:                    reserved (Cascade)
86162306a36Sopenharmony_ci *       31:                    reserved (OVF)
86262306a36Sopenharmony_ci *
86362306a36Sopenharmony_ci *    High 32 bits
86462306a36Sopenharmony_ci *    ------------
86562306a36Sopenharmony_ci *        0:                    reserved (T1_USR)
86662306a36Sopenharmony_ci *        1:                    reserved (T1_OS)
86762306a36Sopenharmony_ci *        2:                    reserved (T0_USR)
86862306a36Sopenharmony_ci *        3:                    reserved (T0_OS)
86962306a36Sopenharmony_ci *        4: Tag Enable
87062306a36Sopenharmony_ci *      5-8: Tag Value
87162306a36Sopenharmony_ci *     9-24: Event Mask (may use P4_ESCR_EMASK_BIT helper)
87262306a36Sopenharmony_ci *    25-30: enum P4_EVENTS
87362306a36Sopenharmony_ci *       31:                    reserved (HT thread)
87462306a36Sopenharmony_ci */
87562306a36Sopenharmony_ci
87662306a36Sopenharmony_ci#endif /* PERF_EVENT_P4_H */
87762306a36Sopenharmony_ci
878