xref: /onnv-gate/usr/src/uts/sun4/sys/errclassify.h (revision 962:cdddbf5988d6)
1*962Stsien /*
2*962Stsien  * CDDL HEADER START
3*962Stsien  *
4*962Stsien  * The contents of this file are subject to the terms of the
5*962Stsien  * Common Development and Distribution License, Version 1.0 only
6*962Stsien  * (the "License").  You may not use this file except in compliance
7*962Stsien  * with the License.
8*962Stsien  *
9*962Stsien  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*962Stsien  * or http://www.opensolaris.org/os/licensing.
11*962Stsien  * See the License for the specific language governing permissions
12*962Stsien  * and limitations under the License.
13*962Stsien  *
14*962Stsien  * When distributing Covered Code, include this CDDL HEADER in each
15*962Stsien  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*962Stsien  * If applicable, add the following below this CDDL HEADER, with the
17*962Stsien  * fields enclosed by brackets "[]" replaced with your own identifying
18*962Stsien  * information: Portions Copyright [yyyy] [name of copyright owner]
19*962Stsien  *
20*962Stsien  * CDDL HEADER END
21*962Stsien  */
22*962Stsien /*
23*962Stsien  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24*962Stsien  * Use is subject to license terms.
25*962Stsien  */
26*962Stsien 
27*962Stsien #ifndef	_SYS_ERRCLASSIFY_H
28*962Stsien #define	_SYS_ERRCLASSIFY_H
29*962Stsien 
30*962Stsien #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*962Stsien 
32*962Stsien #ifdef	__cplusplus
33*962Stsien extern "C" {
34*962Stsien #endif
35*962Stsien 
36*962Stsien #ifndef	_ASM
37*962Stsien 
38*962Stsien #include <sys/errorq.h>
39*962Stsien 
40*962Stsien /*
41*962Stsien  * Note that the order in the following must be kept in sync with that
42*962Stsien  * in the sun4u DE cmd_memerr.c and with the cetypes array of us3_common.c
43*962Stsien  */
44*962Stsien typedef enum {
45*962Stsien 	/*
46*962Stsien 	 * The first byte (256 values) is for type and can be sequential.
47*962Stsien 	 */
48*962Stsien 	CE_DISP_UNKNOWN,
49*962Stsien 	CE_DISP_INTERMITTENT,
50*962Stsien 	CE_DISP_POSS_PERS,
51*962Stsien 	CE_DISP_PERS,
52*962Stsien 	CE_DISP_LEAKY,
53*962Stsien 	CE_DISP_POSS_STICKY,
54*962Stsien 	CE_DISP_STICKY,
55*962Stsien 	/*
56*962Stsien 	 * The next byte encodes the next action as a bitmask
57*962Stsien 	 */
58*962Stsien 	CE_ACT_DONE = 0x100,
59*962Stsien 	CE_ACT_LKYCHK = 0x200,
60*962Stsien 	CE_ACT_PTNRCHK = 0x400,
61*962Stsien 	/*
62*962Stsien 	 * Keep this as the last entry.  Not all entries of the type lookup
63*962Stsien 	 * table are used and this value is the "uninitialized" pattern.
64*962Stsien 	 */
65*962Stsien 	CE_DISP_BAD = 0xbadbad1
66*962Stsien } ce_dispact_t;
67*962Stsien 
68*962Stsien /*
69*962Stsien  * Extract disposition or action from a ce_dispact_t
70*962Stsien  */
71*962Stsien #define	CE_DISP(dispact) \
72*962Stsien 	(dispact & 0xff)
73*962Stsien #define	CE_ACT(dispact) \
74*962Stsien 	(dispact & 0xff00)
75*962Stsien 
76*962Stsien /*
77*962Stsien  * Short string names for classification types.
78*962Stsien  */
79*962Stsien #define	CE_DISP_DESC_U		"U"
80*962Stsien #define	CE_DISP_DESC_I		"I"
81*962Stsien #define	CE_DISP_DESC_PP		"PP"
82*962Stsien #define	CE_DISP_DESC_P		"P"
83*962Stsien #define	CE_DISP_DESC_L		"L"
84*962Stsien #define	CE_DISP_DESC_PS		"PS"
85*962Stsien #define	CE_DISP_DESC_S		"S"
86*962Stsien 
87*962Stsien /*
88*962Stsien  * Various sun4u CPU types use different Ecache state encodings.
89*962Stsien  * For CE classification the following unified scheme is used.
90*962Stsien  */
91*962Stsien #define	EC_STATE_M		0x4
92*962Stsien #define	EC_STATE_O		0x3
93*962Stsien #define	EC_STATE_E		0x2
94*962Stsien #define	EC_STATE_S		0x1
95*962Stsien #define	EC_STATE_I		0x0
96*962Stsien 
97*962Stsien /*
98*962Stsien  * Macros to generate the initial CE classification table (in both kernel and
99*962Stsien  * userland).  An array size CE_INITDISPTBL_SIZE of ce_dispact_t should be
100*962Stsien  * defined and passed by name to ECC_INITDISPTBL_POPULATE which will populate
101*962Stsien  * the array slots that are use and set the unused ones to CE_DISP_BAD.
102*962Stsien  *
103*962Stsien  * To perform a lookup use CE_DISPACT passing the name of the same
104*962Stsien  * array and the afarmatch, ecstate, ce1 and ce2 information.
105*962Stsien  *
106*962Stsien  * Other macros defined here should not be used directly.
107*962Stsien  *
108*962Stsien  * CE_INITDISPTBL_INDEX will generate an index as follows:
109*962Stsien  *
110*962Stsien  *	<5>	afar match
111*962Stsien  *	<4:2>	line state
112*962Stsien  *	<1>	ce2 - CE seen on lddphys of scrub algorithm (after writeback)
113*962Stsien  *	<0>	ce1 - CE seen on CASXA of scrub algorithm (before writeback)
114*962Stsien  *
115*962Stsien  * When the afar does not match line state must be zero.
116*962Stsien  */
117*962Stsien #define	CE_INITDISPTBL_SIZE	(1 << 6)
118*962Stsien #define	CE_INITDISPTBL_INDEX(afarmatch, ecstate, ce1, ce2) \
119*962Stsien 	((afarmatch) << 5 | (ecstate) << 2 | (ce2) << 1 | (ce1))
120*962Stsien 
121*962Stsien #define	CE_DISPACT(array, afarmatch, ecstate, ce1, ce2) \
122*962Stsien 	(array[CE_INITDISPTBL_INDEX(afarmatch, ecstate, ce1, ce2)])
123*962Stsien 
124*962Stsien #define	CE_INITDISPTBL_POPULATE(a)					\
125*962Stsien {									\
126*962Stsien 	int i;								\
127*962Stsien 	for (i = 0; i < CE_INITDISPTBL_SIZE; ++i)			\
128*962Stsien 		a[i] = CE_DISP_BAD;					\
129*962Stsien /*									\
130*962Stsien  *	   afar  ec	      ce1  ce2	initial disp and next action	\
131*962Stsien  *	  match  state							\
132*962Stsien  */									\
133*962Stsien CE_DISPACT(a, 0, 0,		0, 0) = CE_DISP_UNKNOWN | CE_ACT_DONE; \
134*962Stsien CE_DISPACT(a, 0, 0,		0, 1) = CE_DISP_POSS_STICKY | CE_ACT_PTNRCHK; \
135*962Stsien CE_DISPACT(a, 0, 0,		1, 0) = CE_DISP_POSS_PERS | CE_ACT_LKYCHK; \
136*962Stsien CE_DISPACT(a, 0, 0,		1, 1) = CE_DISP_POSS_STICKY | CE_ACT_PTNRCHK; \
137*962Stsien CE_DISPACT(a, 1, EC_STATE_M,	0, 0) = CE_DISP_UNKNOWN | CE_ACT_DONE; \
138*962Stsien CE_DISPACT(a, 1, EC_STATE_M,	0, 1) = CE_DISP_UNKNOWN | CE_ACT_DONE; \
139*962Stsien CE_DISPACT(a, 1, EC_STATE_M,	1, 0) = CE_DISP_UNKNOWN | CE_ACT_DONE; \
140*962Stsien CE_DISPACT(a, 1, EC_STATE_M,	1, 1) = CE_DISP_POSS_STICKY | CE_ACT_PTNRCHK; \
141*962Stsien CE_DISPACT(a, 1, EC_STATE_O,	0, 0) = CE_DISP_UNKNOWN | CE_ACT_DONE; \
142*962Stsien CE_DISPACT(a, 1, EC_STATE_O,	0, 1) = CE_DISP_UNKNOWN | CE_ACT_DONE; \
143*962Stsien CE_DISPACT(a, 1, EC_STATE_O,	1, 0) = CE_DISP_UNKNOWN | CE_ACT_DONE; \
144*962Stsien CE_DISPACT(a, 1, EC_STATE_O,	1, 1) = CE_DISP_POSS_STICKY | CE_ACT_PTNRCHK; \
145*962Stsien CE_DISPACT(a, 1, EC_STATE_E,	0, 0) = CE_DISP_INTERMITTENT | CE_ACT_DONE; \
146*962Stsien CE_DISPACT(a, 1, EC_STATE_E,	0, 1) = CE_DISP_UNKNOWN | CE_ACT_DONE; \
147*962Stsien CE_DISPACT(a, 1, EC_STATE_E,	1, 0) = CE_DISP_POSS_PERS | CE_ACT_LKYCHK; \
148*962Stsien CE_DISPACT(a, 1, EC_STATE_E,	1, 1) = CE_DISP_POSS_STICKY | CE_ACT_PTNRCHK; \
149*962Stsien CE_DISPACT(a, 1, EC_STATE_S,	0, 0) = CE_DISP_INTERMITTENT | CE_ACT_DONE; \
150*962Stsien CE_DISPACT(a, 1, EC_STATE_S,	0, 1) = CE_DISP_POSS_STICKY | CE_ACT_PTNRCHK; \
151*962Stsien CE_DISPACT(a, 1, EC_STATE_S,	1, 0) = CE_DISP_POSS_PERS | CE_ACT_LKYCHK; \
152*962Stsien CE_DISPACT(a, 1, EC_STATE_S,	1, 1) = CE_DISP_POSS_STICKY | CE_ACT_PTNRCHK; \
153*962Stsien CE_DISPACT(a, 1, EC_STATE_I,	0, 0) = CE_DISP_UNKNOWN | CE_ACT_DONE; \
154*962Stsien CE_DISPACT(a, 1, EC_STATE_I,	0, 1) = CE_DISP_POSS_STICKY | CE_ACT_PTNRCHK; \
155*962Stsien CE_DISPACT(a, 1, EC_STATE_I,	1, 0) = CE_DISP_POSS_PERS | CE_ACT_LKYCHK; \
156*962Stsien CE_DISPACT(a, 1, EC_STATE_I,	1, 1) = CE_DISP_POSS_STICKY | CE_ACT_PTNRCHK; \
157*962Stsien }
158*962Stsien 
159*962Stsien #endif	/* !_ASM */
160*962Stsien 
161*962Stsien /*
162*962Stsien  * Legacy error type names corresponding to the flt_status bits
163*962Stsien  */
164*962Stsien #define	ERR_TYPE_DESC_INTERMITTENT	"Intermittent"
165*962Stsien #define	ERR_TYPE_DESC_PERSISTENT	"Persistent"
166*962Stsien #define	ERR_TYPE_DESC_STICKY		"Sticky"
167*962Stsien #define	ERR_TYPE_DESC_UNKNOWN		"Unknown"
168*962Stsien 
169*962Stsien /*
170*962Stsien  * flt_disp for a CE will record all scrub test data for the extended
171*962Stsien  * classification attempt.
172*962Stsien  *
173*962Stsien  * --------------------------------------------------------------------------
174*962Stsien  * |            | partner |   |          | leaky   | partner | detector     |
175*962Stsien  * | partner id | type    | - | skipcode | results | results | results      |
176*962Stsien  * |63	      32|31     30|   |27      24|23     16|15      8|7            0|
177*962Stsien  * --------------------------------------------------------------------------
178*962Stsien  */
179*962Stsien #define	CE_XDIAG_DTCRMASK		0xffULL
180*962Stsien #define	CE_XDIAG_PTNRSHIFT		8
181*962Stsien #define	CE_XDIAG_PTNRMASK		(0xffULL << CE_XDIAG_PTNRSHIFT)
182*962Stsien #define	CE_XDIAG_LKYSHIFT		16
183*962Stsien #define	CE_XDIAG_LKYMASK		(0xffULL << CE_XDIAG_LKYSHIFT)
184*962Stsien #define	CE_XDIAG_SKIPCODESHIFT		24
185*962Stsien #define	CE_XDIAG_SKIPCODEMASK		(0xfULL << CE_XDIAG_SKIPCODESHIFT)
186*962Stsien #define	CE_XDIAG_PTNRTYPESHIFT		30
187*962Stsien #define	CE_XDIAG_PTNRTYPEMASK		(0x3ULL << CE_XDIAG_PTNRTYPESHIFT)
188*962Stsien #define	CE_XDIAG_PTNRIDSHIFT		32
189*962Stsien 
190*962Stsien /*
191*962Stsien  * Given a CE flt_disp set the given field
192*962Stsien  */
193*962Stsien #define	CE_XDIAG_SETPTNRID(disp, id) \
194*962Stsien 	((disp) |= (uint64_t)(id) << CE_XDIAG_PTNRIDSHIFT)
195*962Stsien #define	CE_XDIAG_SETPTNRTYPE(disp, type) \
196*962Stsien 	((disp) |= (uint64_t)type << CE_XDIAG_PTNRTYPESHIFT)
197*962Stsien #define	CE_XDIAG_SETSKIPCODE(disp, code) \
198*962Stsien 	((disp) |= (uint64_t)code << CE_XDIAG_SKIPCODESHIFT)
199*962Stsien #define	CE_XDIAG_SETLKYINFO(disp, result) \
200*962Stsien 	((disp) |= (uint64_t)result << CE_XDIAG_LKYSHIFT)
201*962Stsien #define	CE_XDIAG_SETPTNRINFO(disp, result) \
202*962Stsien 	((disp) |= (uint64_t)result << CE_XDIAG_PTNRSHIFT)
203*962Stsien #define	CE_XDIAG_SETDTCRINFO(disp, result) \
204*962Stsien 	((disp) |= (uint64_t)result)
205*962Stsien 
206*962Stsien /*
207*962Stsien  * Given a CE flt_disp extract the requested component
208*962Stsien  */
209*962Stsien #define	CE_XDIAG_DTCRINFO(disp)	((disp) & CE_XDIAG_DTCRMASK)
210*962Stsien #define	CE_XDIAG_PTNRINFO(disp)	(((disp) & CE_XDIAG_PTNRMASK) >> \
211*962Stsien     CE_XDIAG_PTNRSHIFT)
212*962Stsien #define	CE_XDIAG_LKYINFO(disp)	(((disp) & CE_XDIAG_LKYMASK) >> \
213*962Stsien     CE_XDIAG_LKYSHIFT)
214*962Stsien #define	CE_XDIAG_SKIPCODE(disp)	(((disp) & CE_XDIAG_SKIPCODEMASK) >> \
215*962Stsien     CE_XDIAG_SKIPCODESHIFT)
216*962Stsien #define	CE_XDIAG_PTNRTYPE(disp)	(((disp) & CE_XDIAG_PTNRTYPEMASK) >> \
217*962Stsien     CE_XDIAG_PTNRTYPESHIFT)
218*962Stsien #define	CE_XDIAG_PTNRID(disp)	((disp) >> CE_XDIAG_PTNRIDSHIFT)
219*962Stsien 
220*962Stsien /*
221*962Stsien  * Format of individual detector/partner/leaky test results.  CE_XDIAG_EXTALG
222*962Stsien  * in the detector case indicates that the extended classification algorithm
223*962Stsien  * has been applied;  common code uses this to distinguish between old and new.
224*962Stsien  * In the partner check and leaky check cases CE_XDIAG_EXTALG is used to
225*962Stsien  * indicate that the given test has run and recorded its results in its
226*962Stsien  * result field.
227*962Stsien  */
228*962Stsien #define	CE_XDIAG_STATE_MASK	0x7	/* Low 3 bits are for MOESI state */
229*962Stsien #define	CE_XDIAG_AFARMATCH	0x08	/* Line at e$ index matched AFAR */
230*962Stsien #define	CE_XDIAG_NOLOGOUT	0x10	/* Logout data unavailable */
231*962Stsien #define	CE_XDIAG_CE1		0x20	/* CE logged on casx during scrub */
232*962Stsien #define	CE_XDIAG_CE2		0x40	/* CE logged on post-scrub reread */
233*962Stsien #define	CE_XDIAG_EXTALG		0x80	/* Extended algorithm applied */
234*962Stsien 
235*962Stsien /*
236*962Stsien  * Extract classification information for detector/partner.  Expects
237*962Stsien  * a value from one of CE_XDIAG_{DTCR,PTNR,LKY}_INFO.
238*962Stsien  */
239*962Stsien #define	CE_XDIAG_AFARMATCHED(c)		(((c) & CE_XDIAG_AFARMATCH) != 0)
240*962Stsien #define	CE_XDIAG_LOGOUTVALID(c)		(((c) & CE_XDIAG_NOLOGOUT) == 0)
241*962Stsien #define	CE_XDIAG_CE1SEEN(c)		(((c) & CE_XDIAG_CE1) != 0)
242*962Stsien #define	CE_XDIAG_CE2SEEN(c)		(((c) & CE_XDIAG_CE2) != 0)
243*962Stsien #define	CE_XDIAG_STATE(c)		(CE_XDIAG_AFARMATCHED(c) ? \
244*962Stsien 	((c) & CE_XDIAG_STATE_MASK) : 0)
245*962Stsien #define	CE_XDIAG_EXT_ALG_APPLIED(c)	(((c) & CE_XDIAG_EXTALG) != 0)
246*962Stsien 
247*962Stsien /*
248*962Stsien  * A leaky or partner test is considered valid if the line was not present
249*962Stsien  * in cache, or was present but Invalid, at the time of the additional scrub.
250*962Stsien  */
251*962Stsien #define	CE_XDIAG_TESTVALID(c) (CE_XDIAG_EXT_ALG_APPLIED(c) && \
252*962Stsien 	(!CE_XDIAG_AFARMATCHED(c) || CE_XDIAG_STATE(c) == EC_STATE_I))
253*962Stsien 
254*962Stsien /*
255*962Stsien  * Skipcodes - reasons for not applying extended diags; 4 bits
256*962Stsien  */
257*962Stsien #define	CE_XDIAG_SKIP_NOPP		0x1	/* Can't lookup page pointer */
258*962Stsien #define	CE_XDIAG_SKIP_PAGEDET		0x2	/* Page deteriorating/retired */
259*962Stsien #define	CE_XDIAG_SKIP_NOTMEM		0x3	/* AFAR is not memory */
260*962Stsien #define	CE_XDIAG_SKIP_DUPFAIL		0x4	/* errorq recirculate failed */
261*962Stsien #define	CE_XDIAG_SKIP_NOPTNR		0x5	/* no suitable partner avail */
262*962Stsien #define	CE_XDIAG_SKIP_UNIPROC		0x6	/* test needs 2 or more cpus */
263*962Stsien #define	CE_XDIAG_SKIP_ACTBAD		0x7	/* bad action lookup - bug */
264*962Stsien #define	CE_XDIAG_SKIP_NOSCRUB		0x8	/* detector did not scrub */
265*962Stsien 
266*962Stsien /*
267*962Stsien  * Partner type information.
268*962Stsien  */
269*962Stsien #define	CE_XDIAG_PTNR_REMOTE	0x0	/* partner in different lgroup */
270*962Stsien #define	CE_XDIAG_PTNR_LOCAL	0x1	/* partner in same lgroup */
271*962Stsien #define	CE_XDIAG_PTNR_SIBLING	0x2	/* partner is a sibling core */
272*962Stsien #define	CE_XDIAG_PTNR_SELF	0x3	/* partnered self */
273*962Stsien 
274*962Stsien #ifdef	__cplusplus
275*962Stsien }
276*962Stsien #endif
277*962Stsien 
278*962Stsien #endif	/* _SYS_ERRCLASSIFY_H */
279