xref: /titanic_52/usr/src/uts/sun4v/sys/niagararegs.h (revision 4df55fde49134f9735f84011f23a767c75e393c7)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
580ab886dSwesolows  * Common Development and Distribution License (the "License").
680ab886dSwesolows  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
2180ab886dSwesolows 
227c478bd9Sstevel@tonic-gate /*
23*4df55fdeSJanie Lu  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate #ifndef _SYS_NIAGARAREGS_H
287c478bd9Sstevel@tonic-gate #define	_SYS_NIAGARAREGS_H
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate #ifdef __cplusplus
317c478bd9Sstevel@tonic-gate extern "C" {
327c478bd9Sstevel@tonic-gate #endif
337c478bd9Sstevel@tonic-gate 
347c478bd9Sstevel@tonic-gate /*
357c478bd9Sstevel@tonic-gate  * Niagara SPARC Performance Instrumentation Counter
367c478bd9Sstevel@tonic-gate  */
377c478bd9Sstevel@tonic-gate #define	PIC0_MASK (((uint64_t)1 << 32) - 1)	/* pic0 in bits 31:0 */
387c478bd9Sstevel@tonic-gate #define	PIC1_SHIFT 32				/* pic1 in bits 64:32 */
397c478bd9Sstevel@tonic-gate 
407c478bd9Sstevel@tonic-gate /*
417c478bd9Sstevel@tonic-gate  * Niagara SPARC Performance Control Register
427c478bd9Sstevel@tonic-gate  */
437c478bd9Sstevel@tonic-gate 
44*4df55fdeSJanie Lu #define	CPC_PCR_PRIVPIC		0
45*4df55fdeSJanie Lu #define	CPC_PCR_SYS		1
46*4df55fdeSJanie Lu #define	CPC_PCR_USR		2
477c478bd9Sstevel@tonic-gate 
48*4df55fdeSJanie Lu #define	CPC_PCR_PIC0_SHIFT	4
49*4df55fdeSJanie Lu #define	CPC_PCR_PIC1_SHIFT	0
50*4df55fdeSJanie Lu #define	CPC_PCR_PIC0_MASK	UINT64_C(0x7)
51*4df55fdeSJanie Lu #define	CPC_PCR_PIC1_MASK	UINT64_C(0)
527c478bd9Sstevel@tonic-gate 
53*4df55fdeSJanie Lu #define	CPC_PCR_OVF_MASK	UINT64_C(0x300)
54*4df55fdeSJanie Lu #define	CPC_PCR_OVF_SHIFT	8
557c478bd9Sstevel@tonic-gate 
567c478bd9Sstevel@tonic-gate /*
577c478bd9Sstevel@tonic-gate  * Niagara DRAM performance counters
587c478bd9Sstevel@tonic-gate  */
59*4df55fdeSJanie Lu #define	DRAM_BANKS		0x4
607c478bd9Sstevel@tonic-gate 
61*4df55fdeSJanie Lu #define	DRAM_PIC0_SEL_SHIFT	0x4
62*4df55fdeSJanie Lu #define	DRAM_PIC1_SEL_SHIFT	0x0
637c478bd9Sstevel@tonic-gate 
64*4df55fdeSJanie Lu #define	DRAM_PIC0_SHIFT		0x20
65*4df55fdeSJanie Lu #define	DRAM_PIC0_MASK		0x7fffffff
66*4df55fdeSJanie Lu #define	DRAM_PIC1_SHIFT		0x0
67*4df55fdeSJanie Lu #define	DRAM_PIC1_MASK		0x7fffffff
687c478bd9Sstevel@tonic-gate 
697c478bd9Sstevel@tonic-gate /*
707c478bd9Sstevel@tonic-gate  * Niagara JBUS performance counters
717c478bd9Sstevel@tonic-gate  */
727c478bd9Sstevel@tonic-gate #define	NIAGARA_JBUS_PIC0_SEL_SHIFT	0x4
737c478bd9Sstevel@tonic-gate #define	NIAGARA_JBUS_PIC1_SEL_SHIFT	0x0
747c478bd9Sstevel@tonic-gate 
757c478bd9Sstevel@tonic-gate #define	NIAGARA_JBUS_PIC0_SHIFT		0x20
767c478bd9Sstevel@tonic-gate #define	NIAGARA_JBUS_PIC0_MASK		0x7fffffff
777c478bd9Sstevel@tonic-gate #define	NIAGARA_JBUS_PIC1_SHIFT		0x0
787c478bd9Sstevel@tonic-gate #define	NIAGARA_JBUS_PIC1_MASK		0x7fffffff
797c478bd9Sstevel@tonic-gate 
807c478bd9Sstevel@tonic-gate 
817c478bd9Sstevel@tonic-gate /*
827c478bd9Sstevel@tonic-gate  * Hypervisor FAST_TRAP API function numbers to get/set DRAM and
837c478bd9Sstevel@tonic-gate  * JBUS performance counters
847c478bd9Sstevel@tonic-gate  */
857c478bd9Sstevel@tonic-gate #define	HV_NIAGARA_GETPERF	0x100
867c478bd9Sstevel@tonic-gate #define	HV_NIAGARA_SETPERF	0x101
877c478bd9Sstevel@tonic-gate 
88ce0352ebSgirish /*
89ce0352ebSgirish  * Hypervisor FAST_TRAP API function numbers for Niagara MMU statistics
90ce0352ebSgirish  */
91ce0352ebSgirish #define	HV_NIAGARA_MMUSTAT_CONF	0x102
92ce0352ebSgirish #define	HV_NIAGARA_MMUSTAT_INFO	0x103
937c478bd9Sstevel@tonic-gate 
947c478bd9Sstevel@tonic-gate /*
957c478bd9Sstevel@tonic-gate  * DRAM/JBUS performance counter register numbers for HV_NIAGARA_GETPERF
967c478bd9Sstevel@tonic-gate  * and HV_NIAGARA_SETPERF
977c478bd9Sstevel@tonic-gate  */
987c478bd9Sstevel@tonic-gate #define	HV_NIAGARA_JBUS_CTL		0x0
997c478bd9Sstevel@tonic-gate #define	HV_NIAGARA_JBUS_COUNT		0x1
100*4df55fdeSJanie Lu #define	HV_DRAM_CTL0		0x2
101*4df55fdeSJanie Lu #define	HV_DRAM_COUNT0		0x3
102*4df55fdeSJanie Lu #define	HV_DRAM_CTL1		0x4
103*4df55fdeSJanie Lu #define	HV_DRAM_COUNT1		0x5
104*4df55fdeSJanie Lu #define	HV_DRAM_CTL2		0x6
105*4df55fdeSJanie Lu #define	HV_DRAM_COUNT2		0x7
106*4df55fdeSJanie Lu #define	HV_DRAM_CTL3		0x8
107*4df55fdeSJanie Lu #define	HV_DRAM_COUNT3		0x9
1087c478bd9Sstevel@tonic-gate 
109ce0352ebSgirish #ifndef _ASM
110ce0352ebSgirish 
111ce0352ebSgirish /*
112ce0352ebSgirish  * Niagara MMU statistics data structure
113ce0352ebSgirish  */
114ce0352ebSgirish 
115ce0352ebSgirish #define	NIAGARA_MMUSTAT_PGSZS	8
116ce0352ebSgirish 
117ce0352ebSgirish typedef struct niagara_tsbinfo {
118ce0352ebSgirish 	uint64_t	tsbhit_count;
119ce0352ebSgirish 	uint64_t	tsbhit_time;
120ce0352ebSgirish } niagara_tsbinfo_t;
121ce0352ebSgirish 
122ce0352ebSgirish typedef struct niagara_mmustat {
123ce0352ebSgirish 	niagara_tsbinfo_t	kitsb[NIAGARA_MMUSTAT_PGSZS];
124ce0352ebSgirish 	niagara_tsbinfo_t	uitsb[NIAGARA_MMUSTAT_PGSZS];
125ce0352ebSgirish 	niagara_tsbinfo_t	kdtsb[NIAGARA_MMUSTAT_PGSZS];
126ce0352ebSgirish 	niagara_tsbinfo_t	udtsb[NIAGARA_MMUSTAT_PGSZS];
127ce0352ebSgirish } niagara_mmustat_t;
128ce0352ebSgirish 
129ce0352ebSgirish 
1307c478bd9Sstevel@tonic-gate /*
1317c478bd9Sstevel@tonic-gate  * prototypes for hypervisor interface to get/set DRAM and JBUS
1327c478bd9Sstevel@tonic-gate  * performance counters
1337c478bd9Sstevel@tonic-gate  */
1347c478bd9Sstevel@tonic-gate extern uint64_t hv_niagara_setperf(uint64_t regnum, uint64_t val);
1357c478bd9Sstevel@tonic-gate extern uint64_t hv_niagara_getperf(uint64_t regnum, uint64_t *val);
136ce0352ebSgirish extern uint64_t hv_niagara_mmustat_conf(uint64_t buf, uint64_t *prev_buf);
137ce0352ebSgirish extern uint64_t hv_niagara_mmustat_info(uint64_t *buf);
138ce0352ebSgirish 
139ce0352ebSgirish #endif /* _ASM */
1407c478bd9Sstevel@tonic-gate 
1416dfee483Stsien /*
1426dfee483Stsien  * Bits defined in L2 Error Status Register
1436dfee483Stsien  *
14414ea4bb7Ssd77468  *	(Niagara 1)
1456dfee483Stsien  * +---+---+---+---+----+----+----+----+----+----+----+----+----+----+
1466dfee483Stsien  * |MEU|MEC|RW |RSV|MODA|VCID|LDAC|LDAU|LDWC|LDWU|LDRC|LDRU|LDSC|LDSU|
1476dfee483Stsien  * +---+---+---+---+----+----+----+----+----+----+----+----+----+----+
1486dfee483Stsien  *  63  62  61  60   59 58-54  53   52   51   50   49   48   47   46
1496dfee483Stsien  *
15014ea4bb7Ssd77468  *	(Niagara 2)
15114ea4bb7Ssd77468  * +---+---+---+----+--------+----+----+----+----+----+----+----+----+
15214ea4bb7Ssd77468  * |MEU|MEC|RW |MODA|  VCID  |LDAC|LDAU|LDWC|LDWU|LDRC|LDRU|LDSC|LDSU|
15314ea4bb7Ssd77468  * +---+---+---+----+--------+----+----+----+----+----+----+----+----+
15414ea4bb7Ssd77468  *  63  62  61  60     59-54   53   52   51   50   49   48   47   46
15514ea4bb7Ssd77468  *
15614ea4bb7Ssd77468  *      (Niagara 1)
1576dfee483Stsien  * +---+---+---+---+---+---+---+---+---+---+---+-------+------+
1586dfee483Stsien  * |LTC|LRU|LVU|DAC|DAU|DRC|DRU|DSC|DSU|VEC|VEU| RSVD1 | SYND |
1596dfee483Stsien  * +---+---+---+---+---+---+---+---+---+---+---+-------+------+
1606dfee483Stsien  *  45  44  43  42  41  40  39  38  37  36  35   34-32   31-0
16114ea4bb7Ssd77468  *
16214ea4bb7Ssd77468  *      (Niagara 2)
16314ea4bb7Ssd77468  * +---+---+---+---+---+---+---+---+---+---+---+---+----+-----+
16414ea4bb7Ssd77468  * |LTC|LRU|LVU|DAC|DAU|DRC|DRU|DSC|DSU|VEC|VEU|LVC|RSVD| SYND|
16514ea4bb7Ssd77468  * +---+---+---+---+---+---+---+---+---+---+---+---+----+-----+
16614ea4bb7Ssd77468  *  45  44  43  42  41  40  39  38  37  36  35  34  33-28 27-0
16714ea4bb7Ssd77468  *
16814ea4bb7Ssd77468  * Note that relative to error status bits, Niagara-1 is a strict subset of
16914ea4bb7Ssd77468  * Niagara-2.
1706dfee483Stsien  */
17114ea4bb7Ssd77468 
17280ab886dSwesolows #define	NI_L2AFSR_MEU 	0x8000000000000000ULL
17380ab886dSwesolows #define	NI_L2AFSR_MEC	0x4000000000000000ULL
17480ab886dSwesolows #define	NI_L2AFSR_RW 	0x2000000000000000ULL
17514ea4bb7Ssd77468 #define	NI2_L2AFSR_MODA	0x1000000000000000ULL
17614ea4bb7Ssd77468 #define	NI1_L2AFSR_MODA	0x0800000000000000ULL
17780ab886dSwesolows #define	NI_L2AFSR_VCID	0x07C0000000000000ULL
17880ab886dSwesolows #define	NI_L2AFSR_LDAC	0x0020000000000000ULL
17980ab886dSwesolows #define	NI_L2AFSR_LDAU	0x0010000000000000ULL
18080ab886dSwesolows #define	NI_L2AFSR_LDWC	0x0008000000000000ULL
18180ab886dSwesolows #define	NI_L2AFSR_LDWU	0x0004000000000000ULL
18280ab886dSwesolows #define	NI_L2AFSR_LDRC	0x0002000000000000ULL
18380ab886dSwesolows #define	NI_L2AFSR_LDRU	0x0001000000000000ULL
18480ab886dSwesolows #define	NI_L2AFSR_LDSC	0x0000800000000000ULL
18580ab886dSwesolows #define	NI_L2AFSR_LDSU	0x0000400000000000ULL
18680ab886dSwesolows #define	NI_L2AFSR_LTC	0x0000200000000000ULL
18780ab886dSwesolows #define	NI_L2AFSR_LRU	0x0000100000000000ULL
18880ab886dSwesolows #define	NI_L2AFSR_LVU	0x0000080000000000ULL
18980ab886dSwesolows #define	NI_L2AFSR_DAC	0x0000040000000000ULL
19080ab886dSwesolows #define	NI_L2AFSR_DAU	0x0000020000000000ULL
19180ab886dSwesolows #define	NI_L2AFSR_DRC	0x0000010000000000ULL
19280ab886dSwesolows #define	NI_L2AFSR_DRU	0x0000008000000000ULL
19380ab886dSwesolows #define	NI_L2AFSR_DSC	0x0000004000000000ULL
19480ab886dSwesolows #define	NI_L2AFSR_DSU	0x0000002000000000ULL
19580ab886dSwesolows #define	NI_L2AFSR_VEC	0x0000001000000000ULL
19680ab886dSwesolows #define	NI_L2AFSR_VEU	0x0000000800000000ULL
19714ea4bb7Ssd77468 #define	NI_L2AFSR_LVC	0x0000000400000000ULL
19814ea4bb7Ssd77468 #define	NI1_L2AFSR_SYND	0x00000000FFFFFFFFULL
19914ea4bb7Ssd77468 #define	NI2_L2AFSR_SYND	0x000000000FFFFFFFULL
2006dfee483Stsien 
2016dfee483Stsien /*
2026dfee483Stsien  * These L2 bit masks are used to determine if another bit of higher priority
2036dfee483Stsien  * is set.  This tells us whether the reported syndrome and address are valid
2046dfee483Stsien  * for this ereport. If the error in hand is Pn, use Pn-1 to bitwise & with
2056dfee483Stsien  * the l2-afsr value.  If result is 0, then this ereport's afsr is valid.
2066dfee483Stsien  */
2076dfee483Stsien #define	NI_L2AFSR_P01	(NI_L2AFSR_LVU)
2086dfee483Stsien #define	NI_L2AFSR_P02	(NI_L2AFSR_P01 | NI_L2AFSR_LRU)
2096dfee483Stsien #define	NI_L2AFSR_P03	(NI_L2AFSR_P02 | NI_L2AFSR_LDAU | NI_L2AFSR_LDSU)
2106dfee483Stsien #define	NI_L2AFSR_P04	(NI_L2AFSR_P03 | NI_L2AFSR_LDWU)
2116dfee483Stsien #define	NI_L2AFSR_P05	(NI_L2AFSR_P04 | NI_L2AFSR_LDRU)
2126dfee483Stsien #define	NI_L2AFSR_P06	(NI_L2AFSR_P05 | NI_L2AFSR_DAU | NI_L2AFSR_DRU)
21314ea4bb7Ssd77468 #define	NI_L2AFSR_P07   (NI_L2AFSR_P06 | NI_L2AFSR_LVC)
21414ea4bb7Ssd77468 #define	NI_L2AFSR_P08	(NI_L2AFSR_P07 | NI_L2AFSR_LTC)
21514ea4bb7Ssd77468 #define	NI_L2AFSR_P09	(NI_L2AFSR_P08 | NI_L2AFSR_LDAC | NI_L2AFSR_LDSC)
21614ea4bb7Ssd77468 #define	NI_L2AFSR_P10	(NI_L2AFSR_P09 | NI_L2AFSR_LDWC)
21714ea4bb7Ssd77468 #define	NI_L2AFSR_P11	(NI_L2AFSR_P10 | NI_L2AFSR_LDRC)
21814ea4bb7Ssd77468 #define	NI_L2AFSR_P12	(NI_L2AFSR_P11 | NI_L2AFSR_DAC | NI_L2AFSR_DRC)
2196dfee483Stsien 
2206dfee483Stsien /*
22114ea4bb7Ssd77468  * Bits defined in DRAM Error Status Register (Niagara-2)
22214ea4bb7Ssd77468  * Niagara-1 is strict subset
2236dfee483Stsien  *
22414ea4bb7Ssd77468  * +---+---+---+---+---+---+---+---+---+---+----------+------+
22514ea4bb7Ssd77468  * |MEU|MEC|DAC|DAU|DSC|DSU|DBU|MEB|FBU|FBR| RESERVED | SYND |
22614ea4bb7Ssd77468  * +---+---+---+---+---+---+---+---+---+---+----------+------+
22714ea4bb7Ssd77468  *  63  62  61  60  59  58  57  56  55  54    53-16     15-0
2286dfee483Stsien  *
2296dfee483Stsien  */
23080ab886dSwesolows #define	NI_DMAFSR_MEU 	0x8000000000000000ULL
23180ab886dSwesolows #define	NI_DMAFSR_MEC	0x4000000000000000ULL
23280ab886dSwesolows #define	NI_DMAFSR_DAC 	0x2000000000000000ULL
23380ab886dSwesolows #define	NI_DMAFSR_DAU	0x1000000000000000ULL
23480ab886dSwesolows #define	NI_DMAFSR_DSC	0x0800000000000000ULL
23580ab886dSwesolows #define	NI_DMAFSR_DSU	0x0400000000000000ULL
23680ab886dSwesolows #define	NI_DMAFSR_DBU	0x0200000000000000ULL
23714ea4bb7Ssd77468 #define	NI_DMAFSR_MEB	0x0100000000000000ULL
23814ea4bb7Ssd77468 #define	NI_DMAFSR_FBU	0x0080000000000000ULL
23914ea4bb7Ssd77468 #define	NI_DMAFSR_FBR	0x0040000000000000ULL
24080ab886dSwesolows #define	NI_DMAFSR_SYND	0x000000000000FFFFULL
2416dfee483Stsien 
2426dfee483Stsien /* Bit mask for DRAM priority determination */
24314ea4bb7Ssd77468 #define	NI_DMAFSR_P01	(NI_DMAFSR_DSU | NI_DMAFSR_DAU | NI_DMAFSR_FBU)
2446dfee483Stsien 
2456dfee483Stsien /*
2466dfee483Stsien  * The following is the syndrome value placed in memory
2476dfee483Stsien  * when an uncorrectable error is written back from L2 cache.
2486dfee483Stsien  */
2496dfee483Stsien #define	NI_DRAM_POISON_SYND_FROM_LDWU		0x1118
25050e6accbStd122701 #define	N2_DRAM_POISON_SYND_FROM_LDWU		0x8221
2516dfee483Stsien 
2526dfee483Stsien /*
2536dfee483Stsien  * This L2 poison syndrome is placed on 4 byte checkwords of L2
2546dfee483Stsien  * when a UE is loaded or DMA'ed into L2
2556dfee483Stsien  */
2566dfee483Stsien #define	NI_L2_POISON_SYND_FROM_DAU		0x3
2576dfee483Stsien #define	NI_L2_POISON_SYND_MASK			0x7F
2586dfee483Stsien #define	NI_L2_POISON_SYND_SIZE			7
2596dfee483Stsien 
2607c478bd9Sstevel@tonic-gate #ifdef __cplusplus
2617c478bd9Sstevel@tonic-gate }
2627c478bd9Sstevel@tonic-gate #endif
2637c478bd9Sstevel@tonic-gate 
2647c478bd9Sstevel@tonic-gate #endif /* _SYS_NIAGARAREGS_H */
265