xref: /onnv-gate/usr/src/cmd/fm/modules/sun4/cpumem-diagnosis/cmd_cpu.h (revision 6429:a90bb8316257)
1600Stsien /*
2600Stsien  * CDDL HEADER START
3600Stsien  *
4600Stsien  * The contents of this file are subject to the terms of the
51772Sjl139090  * Common Development and Distribution License (the "License").
61772Sjl139090  * You may not use this file except in compliance with the License.
7600Stsien  *
8600Stsien  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9600Stsien  * or http://www.opensolaris.org/os/licensing.
10600Stsien  * See the License for the specific language governing permissions
11600Stsien  * and limitations under the License.
12600Stsien  *
13600Stsien  * When distributing Covered Code, include this CDDL HEADER in each
14600Stsien  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15600Stsien  * If applicable, add the following below this CDDL HEADER, with the
16600Stsien  * fields enclosed by brackets "[]" replaced with your own identifying
17600Stsien  * information: Portions Copyright [yyyy] [name of copyright owner]
18600Stsien  *
19600Stsien  * CDDL HEADER END
20600Stsien  */
21600Stsien /*
226330Sjc25722  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23600Stsien  * Use is subject to license terms.
24600Stsien  */
25600Stsien 
26600Stsien #ifndef _CMD_CPU_H
27600Stsien #define	_CMD_CPU_H
28600Stsien 
29600Stsien #pragma ident	"%Z%%M%	%I%	%E% SMI"
30600Stsien 
31600Stsien /*
32600Stsien  * Each CPU of interest has a cmd_cpu_t structure.  CPUs become of interest when
33600Stsien  * they are the focus of ereports, or when they detect UEs.  CPUs may be the
34600Stsien  * target of several different kinds of ereport, each of which is tracked
35600Stsien  * differently.  cpu_cases lists the types of cases that can be open against a
36600Stsien  * given CPU.  The life of a CPU is complicated by the fact that xxCs and xxUs
37600Stsien  * received by the DE may in fact be side-effects of earlier UEs, xxCs, or xxUs.
38600Stsien  * Causes of side-effects, and actions taken to resolve them, can be found below
39600Stsien  * and in cmd_memerr.h.
40600Stsien  *
41600Stsien  * Data structures:
42600Stsien  *      ________                                   CMD_PTR_CPU_ICACHE
43600Stsien  *     /        \       ,--------.                 CMD_PTR_CPU_DCACHE
44600Stsien  *     |CPU     | <---- |case_ptr| (one or more of CMD_PTR_CPU_PCACHE         )
45600Stsien  *     |        |       `--------'                 CMD_PTR_CPU_ITLB
46600Stsien  *     |,-------|       ,-------.                  CMD_PTR_CPU_DTLB
47600Stsien  *     ||asru   | ----> |fmri_t |                  CMD_PTR_CPU_L2DATA
48600Stsien  *     |:-------|       :-------:                  CMD_PTR_CPU_L2DATA_UERETRY
49600Stsien  *     ||fru    | ----> |fmri_t |                  CMD_PTR_CPU_L2TAG
50600Stsien  *     |`-------|       `-------'                  CMD_PTR_CPU_L3DATA
51600Stsien  *     |        |       ,---------.                CMD_PTR_CPU_L3DATA_UERETRY
52600Stsien  *     | uec    | ----> |UE cache |                CMD_PTR_CPU_L3TAG
53600Stsien  *     \________/       `---------'                CMD_PTR_CPU_FPU
54962Stsien  *						   CMD_PTR_CPU_IREG
55962Stsien  *						   CMD_PTR_CPU_FREG
56962Stsien  *						   CMD_PTR_CPU_MAU
57962Stsien  *						   CMD_PTR_CPU_L2CTL
58600Stsien  *
59600Stsien  *      ________
60600Stsien  *     /        \       ,--------.
61600Stsien  *     | xr     | <---- |case_ptr| (CMD_PTR_XR_WAITER)
62600Stsien  *     |        |       `--------'
63600Stsien  *     |,-------|       ,-------.
64600Stsien  *     ||rsrc   | ----> |fmri_t |
65600Stsien  *     |`-------|       `-------'
66600Stsien  *     | cpu    | ----> detecting CPU
67600Stsien  *     \________/
68600Stsien  *
69600Stsien  * Data structure	P?  Case- Notes
70600Stsien  *                          Rel?
71600Stsien  * ----------------	--- ----- --------------------------------------
72600Stsien  * cmd_cpu_t		Yes No    Name is derived from CPU ID ("cpu_%d")
73600Stsien  * cmd_case_ptr_t	Yes Yes   Name is case's UUID
74600Stsien  * cpu_asru (fmri_t)	Yes No    Name is derived from CPU ID ("cpu_asru_%d")
75600Stsien  * cpu_fru (fmri_t)	Yes No    Name is derived from CPU ID ("cpu_fru_%d")
76600Stsien  * cpu_uec		Yes No    Name is derived from CPU ID ("cpu_uec_%d")
77600Stsien  * cmd_xr_t		Yes Yes   Name is `redelivery'
78600Stsien  * xr_rsrc (fmri_t)     Yes No    Name is derived from case's UUID ("%s_rsrc")
79600Stsien  */
80600Stsien 
81600Stsien #include <cmd.h>
82600Stsien #include <cmd_state.h>
83600Stsien #include <cmd_fmri.h>
84600Stsien 
85600Stsien #ifdef __cplusplus
86600Stsien extern "C" {
87600Stsien #endif
88600Stsien 
893325Ssd77468 #define	CPU_FRU_FMRI		FM_FMRI_SCHEME_HC":///" \
903325Ssd77468     FM_FMRI_LEGACY_HC"="
913325Ssd77468 
925430Ssd77468 #define	BK_LFUFAULT_CERT	50
935430Ssd77468 
94600Stsien typedef struct cmd_cpu cmd_cpu_t;
95600Stsien 
96600Stsien typedef enum cmd_cpu_type {
97600Stsien 	CPU_ULTRASPARC_III = 1,
98600Stsien 	CPU_ULTRASPARC_IIIplus,
99600Stsien 	CPU_ULTRASPARC_IIIi,
100600Stsien 	CPU_ULTRASPARC_IV,
101600Stsien 	CPU_ULTRASPARC_IVplus,
102600Stsien 	CPU_ULTRASPARC_IIIiplus,
1031772Sjl139090 	CPU_ULTRASPARC_T1,
1042400Stsien 	CPU_SPARC64_VI,
1055037Sjl139090 	CPU_SPARC64_VII,
1064759Ssd77468 	CPU_ULTRASPARC_T2,
1074759Ssd77468 	CPU_ULTRASPARC_T2plus
108600Stsien } cmd_cpu_type_t;
109600Stsien 
110600Stsien typedef struct cmd_cpu_cases {
111600Stsien 	cmd_case_t cpuc_icache;		/* All I$ errors (IPE, IDSPE, etc) */
112600Stsien 	cmd_case_t cpuc_dcache;		/* All D$ errors (DPE, DDSPE, etc) */
113600Stsien 	cmd_case_t cpuc_pcache;		/* All P$ errors (PDSPE) */
114600Stsien 	cmd_case_t cpuc_itlb;		/* ITLB errors (ITLBPE) */
115600Stsien 	cmd_case_t cpuc_dtlb;		/* DTLB errors (DTLBPE) */
116600Stsien 	cmd_case_t cpuc_l2data;		/* All correctable L2$ data errors */
117600Stsien 	cmd_case_t cpuc_l2tag;		/* All correctable L2$ tag errors */
118600Stsien 	cmd_case_t cpuc_l3data;		/* All correctable L3$ data errors */
119600Stsien 	cmd_case_t cpuc_l3tag;		/* All correctable L3$ tag errors */
120600Stsien 	cmd_case_t cpuc_fpu;		/* FPU errors */
121962Stsien 	cmd_case_t cpuc_ireg;		/* Integer reg errors (IRC, IRU) */
122962Stsien 	cmd_case_t cpuc_freg;		/* Floatpnt reg errors (frc, fru) */
123962Stsien 	cmd_case_t cpuc_mau;		/* Modular arith errors (MAU) */
124962Stsien 	cmd_case_t cpuc_l2ctl;		/* L2$ directory, VUAD parity */
1253325Ssd77468 	cmd_case_t cpuc_misc_regs;	/* Scratchpad array (SCA) */
1263325Ssd77468 					/* Tick compare (TC) */
1273325Ssd77468 					/* Store buffer (SBD) */
1283325Ssd77468 					/* Trap stack array errors (TSA) */
1294759Ssd77468 	cmd_case_t cpuc_lfu;		/* Coherency link error (LFU) */
1301794Sav145390 #ifdef sun4u
1311794Sav145390 	cmd_case_t cpuc_opl_invsfsr;	/* Olympus-C cpu inv-sfsr errors */
1321794Sav145390 	cmd_case_t cpuc_oplue_detcpu;	/* Olympus-C cpu det. ue (eid=CPU) */
1331794Sav145390 	cmd_case_t cpuc_oplue_detio;	/* Olympus-C io det. ue (eid=CPU) */
1341772Sjl139090 	cmd_case_t cpuc_opl_mtlb;	/* Olympus-C mtlb errors */
1351772Sjl139090 	cmd_case_t cpuc_opl_tlbp;	/* Olympus-C tlbp errors */
1361772Sjl139090 	cmd_case_t cpuc_opl_inv_urg;	/* Olympus-C inv-urg invalid urgent */
1371772Sjl139090 	cmd_case_t cpuc_opl_cre;	/* Olympus-C cre urgent errors */
1381772Sjl139090 	cmd_case_t cpuc_opl_tsb_ctx;	/* Olympus-C tsb_ctx urgent errors */
1391772Sjl139090 	cmd_case_t cpuc_opl_tsbp;	/* Olympus-C tsbp urgent errors */
1401772Sjl139090 	cmd_case_t cpuc_opl_pstate;	/* Olympus-C pstate urgent errors */
1411772Sjl139090 	cmd_case_t cpuc_opl_tstate;	/* Olympus-C tstate urgent errors */
1421772Sjl139090 	cmd_case_t cpuc_opl_iug_f;	/* Olympus-C iug_f urgent errors */
1431772Sjl139090 	cmd_case_t cpuc_opl_iug_r;	/* Olympus-C iug_r urgent errors */
1441772Sjl139090 	cmd_case_t cpuc_opl_sdc;	/* Olympus-C sdc urgent errors */
1451772Sjl139090 	cmd_case_t cpuc_opl_wdt;	/* Olympus-C wdt urgent errors */
1461772Sjl139090 	cmd_case_t cpuc_opl_dtlb;	/* Olympus-C dtlb urgent errors */
1471772Sjl139090 	cmd_case_t cpuc_opl_itlb;	/* Olympus-C itlb urgent errors */
1481772Sjl139090 	cmd_case_t cpuc_opl_core_err;	/* Olympus-C core-err urgent errors */
1491772Sjl139090 	cmd_case_t cpuc_opl_dae;	/* Olympus-C dae urgent errors */
1501772Sjl139090 	cmd_case_t cpuc_opl_iae;	/* Olympus-C iae urgent errors */
1511772Sjl139090 	cmd_case_t cpuc_opl_uge;	/* Olympus-C uge urgent errors */
1521794Sav145390 #endif	/* sun4u */
153600Stsien } cmd_cpu_cases_t;
154600Stsien 
155600Stsien /*
156600Stsien  * The UE cache.  We actually have two UE caches - the current one and the old
157600Stsien  * one.  When it's time to flush the UE cache, we move the current UE cache to
158600Stsien  * the old position and flush the E$.  Then, we schedule the removal of the old
159600Stsien  * UE cache.  This allows a) xxUs triggered by the flush to match against the
160600Stsien  * old cache, while b) still allowing new UEs to be added to the current UE
161600Stsien  * cache.  UE matches will always search in both caches (if present), but
162600Stsien  * additions will only end up in the current cache.  We go to all of this
163600Stsien  * effort because the cost of a missed ereport (discarding due to a false match
164600Stsien  * in the cache) is much less than that of a missed match.  In the latter case,
165600Stsien  * the CPU will be erroneously offlined.
166600Stsien  *
167600Stsien  * A special case is triggered if we see a UE with a not valid AFAR.  Without
168600Stsien  * the AFAR, we aren't able to properly match subsequent xxU's.  As a result,
169600Stsien  * we need to throw the cache into all-match mode, wherein all subsequent match
170600Stsien  * attempts will succeed until the UE cache is flushed.
171600Stsien  */
172600Stsien 
173600Stsien #define	CPU_UEC_F_ALLMATCH	0x1	/* all-match mode active */
174600Stsien 
175600Stsien typedef struct cmd_cpu_uec {
176600Stsien 	uint64_t *uec_cache;		/* The UE cache */
177600Stsien 	uint_t uec_nent;		/* Number of allocated slots in cache */
178600Stsien 	uint_t uec_flags;		/* CPU_UEC_F_* */
179600Stsien 	char uec_bufname[CMD_BUFNMLEN];	/* Name of buffer used for cache */
180600Stsien } cmd_cpu_uec_t;
181600Stsien 
1826330Sjc25722 extern const char *cmd_cpu_type2name(fmd_hdl_t *, cmd_cpu_type_t);
183600Stsien extern void cmd_cpu_uec_add(fmd_hdl_t *, cmd_cpu_t *, uint64_t);
184600Stsien extern int cmd_cpu_uec_match(cmd_cpu_t *, uint64_t);
185600Stsien extern void cmd_cpu_uec_clear(fmd_hdl_t *, cmd_cpu_t *);
186600Stsien extern void cmd_cpu_uec_set_allmatch(fmd_hdl_t *, cmd_cpu_t *);
187600Stsien 
188600Stsien /*
189600Stsien  * Certain types of xxC and xxU can trigger other types as side-effects.  These
190600Stsien  * secondary ereports need to be discarded, as treating them as legitimate
191600Stsien  * ereports in their own right will cause erroneous diagnosis.  As an example
192600Stsien  * (see cmd_xxcu_trains for more), an L2$ UCC will usually trigger an L2$ WDC
193600Stsien  * resulting from the trap handler's flushing of the L2$.  If we treat both as
194600Stsien  * legitimate, we'll end up adding two ereports to the SERD engine,
195600Stsien  * significantly cutting the threshold for retiring the CPU.
196600Stsien  *
197600Stsien  * Our saving grace is the fact that the side-effect ereports will have the same
198600Stsien  * ENA as the primary.  As such, we can keep track of groups of ereports by ENA.
199600Stsien  * These groups, which we'll call trains, can then be matched against a list of
200600Stsien  * known trains.  The list (an array of cmd_xxcu_train_t structures) has both a
201600Stsien  * description of the composition of the train and an indication as to which of
202600Stsien  * the received ereports is the primary.
203600Stsien  *
204600Stsien  * The cmd_xxcu_trw_t is used to gather the members of the train.  When the
205600Stsien  * first member comes in, we allocate a trw, recording the ENA of the ereport,
206600Stsien  * as well as noting its class in trw_mask.  We then reschedule the delivery of
207600Stsien  * the ereport for some configurable time in the future, trusting that all
208600Stsien  * members of the train will have arrived by that time.  Subsequent ereports in
209600Stsien  * the same train match the recorded ENA, and add themselves to the mask.
210600Stsien  * When the first ereport is redelivered, trw_mask is used to determine whether
211600Stsien  * or not a train has been seen.  An exact match is required.  If a match is
212600Stsien  * made, the ereport indicated as the primary cause is used for diagnosis.
213600Stsien  */
214600Stsien 
215600Stsien #define	CMD_TRW_F_DELETING	0x1	/* reclaiming events */
216600Stsien #define	CMD_TRW_F_CAUSESEEN	0x2	/* cause of train already processed */
217600Stsien #define	CMD_TRW_F_GCSEEN	0x4	/* seen by GC, erased next time */
218600Stsien 
219600Stsien typedef struct cmd_xxcu_trw {
220600Stsien 	uint64_t trw_ena;	/* the ENA for this group of ereports */
2212828Sjc25722 	uint64_t trw_afar;	/* the AFAR for this group of ereports */
222600Stsien 	cmd_errcl_t trw_mask;	/* ereports seen thus far with this ENA */
223600Stsien 	uint16_t trw_cpuid;	/* CPU to which this watcher belongs */
224600Stsien 	uint8_t	 trw_ref;	/* number of ereports with this ENA */
225600Stsien 	uint8_t	 trw_flags;	/* CMD_TRW_F_* */
226600Stsien 	uint32_t trw_pad;
227600Stsien } cmd_xxcu_trw_t;
228600Stsien 
2292828Sjc25722 extern cmd_xxcu_trw_t *cmd_trw_lookup(uint64_t, uint8_t, uint64_t);
2302828Sjc25722 extern cmd_xxcu_trw_t *cmd_trw_alloc(uint64_t, uint64_t);
231600Stsien extern void cmd_trw_restore(fmd_hdl_t *);
232600Stsien extern void cmd_trw_write(fmd_hdl_t *);
233600Stsien extern void cmd_trw_ref(fmd_hdl_t *, cmd_xxcu_trw_t *, cmd_errcl_t);
234600Stsien extern void cmd_trw_deref(fmd_hdl_t *, cmd_xxcu_trw_t *);
235600Stsien 
236600Stsien extern cmd_errcl_t cmd_xxcu_train_match(cmd_errcl_t);
237600Stsien 
238600Stsien /*
239600Stsien  * We don't have access to ereport nvlists when they are redelivered via timer.
240600Stsien  * As such, we have to retrieve everything we might need for diagnosis when we
241600Stsien  * first receive the ereport.  The retrieved information is stored in the
242600Stsien  * cmd_xr_t, which is persisted.
243600Stsien  */
244600Stsien 
245600Stsien typedef struct cmd_xr cmd_xr_t;
246600Stsien 
247600Stsien /*
248600Stsien  * xr_hdlr can't be persisted, so we use these in xr_hdlrid to indicate the
249600Stsien  * handler to be used.  xr_hdlr is then updated so it can be used directly.
250600Stsien  */
251600Stsien #define	CMD_XR_HDLR_XXC		1
252600Stsien #define	CMD_XR_HDLR_XXU		2
2536369Std122701 #define	CMD_XR_HDLR_NOP		3
254600Stsien 
255600Stsien typedef void cmd_xr_hdlr_f(fmd_hdl_t *, cmd_xr_t *, fmd_event_t *);
256600Stsien 
257962Stsien /*
258962Stsien  * For sun4v, the size of xr_synd is expanded to 32 bits in order to
259962Stsien  * accomodate the Niagara L2 syndrome (4x7 bits).
260962Stsien  */
261962Stsien 
262600Stsien struct cmd_xr {
263600Stsien 	cmd_list_t xr_list;
264600Stsien 	id_t xr_id;		/* ID of timer used for redelivery */
265600Stsien 	cmd_cpu_t *xr_cpu;	/* Detecting CPU, recalc'd from cpuid */
266600Stsien 	uint32_t xr_cpuid;	/* ID of detecting CPU */
267600Stsien 	uint64_t xr_ena;	/* ENA from ereport */
268600Stsien 	uint64_t xr_afar;	/* AFAR from ereport nvlist */
269962Stsien #ifdef sun4u
270600Stsien 	uint16_t xr_synd;	/* syndrome from ereport nvlist */
271962Stsien #else /* sun4u */
272962Stsien 	uint32_t xr_synd;	/* for Niagara, enlarged to 32 bits */
273962Stsien #endif /* sun4u */
274600Stsien 	uint8_t xr_afar_status;	/* AFAR status from ereport nvlist */
275600Stsien 	uint8_t xr_synd_status;	/* syndrome status from ereport nvlist */
276600Stsien 	cmd_fmri_t xr_rsrc;	/* resource from ereport nvlist */
277600Stsien 	cmd_errcl_t xr_clcode;	/* CMD_ERRCL_* for this ereport */
278600Stsien 	cmd_xr_hdlr_f *xr_hdlr;	/* handler, recalc'd from hdlrid on restart */
279600Stsien 	uint_t xr_hdlrid;	/* CMD_XR_HDLR_*, used for recalc of hdlr */
280600Stsien 	fmd_case_t *xr_case;	/* Throwaway case used to track redelivery */
281600Stsien 	uint_t xr_ref;		/* Number of references to this struct */
2826330Sjc25722 #ifdef sun4u
2836330Sjc25722 	uint64_t xr_afsr;	/* AFSR from ereport nvlist */
2846330Sjc25722 	uint8_t  xr_num_ways;   /* Number of Cache ways reporting from nvlist */
2856330Sjc25722 	uint32_t xr_error_way;  /* The way from the ereport nvlist payload */
2866330Sjc25722 	uint64_t xr_error_tag;  /* The tag from the ereport nvlist payload */
2876330Sjc25722 	uint32_t xr_error_index; /* the index from the ereport payload */
2886330Sjc25722 	uint64_t *xr_cache_data; /* The cache data */
2896330Sjc25722 	nvlist_t *xr_detector_nvlist; /* The detecting resource */
2906330Sjc25722 #endif
291600Stsien };
292600Stsien 
293600Stsien #define	xr_rsrc_nvl		xr_rsrc.fmri_nvl
294600Stsien 
295600Stsien extern cmd_xr_t *cmd_xr_create(fmd_hdl_t *, fmd_event_t *, nvlist_t *,
296600Stsien     cmd_cpu_t *, cmd_errcl_t);
297600Stsien extern cmd_evdisp_t cmd_xr_reschedule(fmd_hdl_t *, cmd_xr_t *, uint_t);
298600Stsien extern void cmd_xr_deref(fmd_hdl_t *, cmd_xr_t *);
299962Stsien extern void cmd_xr_write(fmd_hdl_t *, cmd_xr_t *);
300600Stsien 
301600Stsien extern void cmd_xxc_resolve(fmd_hdl_t *, cmd_xr_t *, fmd_event_t *);
302600Stsien extern void cmd_xxu_resolve(fmd_hdl_t *, cmd_xr_t *, fmd_event_t *);
3036369Std122701 extern void cmd_nop_resolve(fmd_hdl_t *, cmd_xr_t *, fmd_event_t *);
3046369Std122701 extern cmd_evdisp_t cmd_xxcu_initial(fmd_hdl_t *, fmd_event_t *, nvlist_t *,
3056369Std122701     const char *, cmd_errcl_t,  uint_t);
306600Stsien 
307600Stsien /*
308600Stsien  * The master structure containing or referencing all of the state for a given
309600Stsien  * CPU.
310600Stsien  */
311600Stsien 
312600Stsien /*
313600Stsien  * We periodically flush the E$, thus allowing us to flush the UE cache (see
314600Stsien  * above for a description of the UE cache).  In particular, we flush it
315600Stsien  * whenever we see a UE with a non-valid AFAR.  To keep from overflushing the
316600Stsien  * CPU, we cap the number of flushes that we'll do in response to UEs with
317600Stsien  * non-valid AFARs.  The cap is the number of permitted flushes per GC/restart
318600Stsien  * cycle, and was determined arbitrarily.
319600Stsien  */
320600Stsien #define	CPU_UEC_FLUSH_MAX	3
321600Stsien 
322600Stsien /*
323600Stsien  * The CPU structure started life without a version number.  Making things more
324600Stsien  * complicated, the version number in the new struct occupies the space used for
325600Stsien  * cpu_cpuid in the non-versioned struct.  We therefore have to use somewhat
326600Stsien  * unorthodox version numbers to distinguish between the two types of struct
327600Stsien  * (pre- and post-versioning) -- version numbers that can't be mistaken for
328600Stsien  * CPUIDs.  Our version numbers, therefore, will be negative.
329600Stsien  *
330600Stsien  * For future expansion, the version member must always stay where it is.  At
331600Stsien  * some point in the future, when more structs get versions, the version member
332600Stsien  * should move into the cmd_header_t.
333600Stsien  */
334600Stsien #define	CPU_MKVERSION(version)	((uint_t)(0 - (version)))
335600Stsien 
336600Stsien #define	CMD_CPU_VERSION_1	CPU_MKVERSION(1)	/* -1 */
337600Stsien #define	CMD_CPU_VERSION_2	CPU_MKVERSION(2)	/* -2 */
3382400Stsien #define	CMD_CPU_VERSION_3	CPU_MKVERSION(3)	/* -3 */
3392400Stsien #define	CMD_CPU_VERSION		CMD_CPU_VERSION_3
340600Stsien 
341600Stsien #define	CMD_CPU_VERSIONED(cpu)	((int)(cpu)->cpu_version < 0)
342600Stsien 
343600Stsien #define	CMD_CPU_F_DELETING	0x1
344600Stsien 
345600Stsien typedef struct cmd_cpu_0 {
346600Stsien 	cmd_header_t cpu0_header;	/* Nodetype must be CMD_NT_CPU */
347600Stsien 	uint32_t cpu0_cpuid;		/* Logical ID for this CPU */
348600Stsien 	cmd_cpu_type_t cpu0_type;	/* CPU model */
349600Stsien 	fmd_case_t *cpu0_cases[4];	/* v0 had embedded case_t w/4 cases */
350600Stsien 	uint8_t cpu0_faulting;		/* Set if fault has been issued */
351600Stsien 	cmd_fmri_t cpu0_asru;		/* ASRU for this CPU */
352600Stsien 	cmd_fmri_t cpu0_fru;		/* FRU for this CPU */
353600Stsien 	cmd_cpu_uec_t cpu0_uec;		/* UE cache */
354600Stsien 	cmd_cpu_uec_t cpu0_olduec;	/* To-be-flushed UE cache */
355600Stsien 	id_t cpu0_uec_flush;		/* Timer ID for UE cache flush */
356600Stsien 	uint_t cpu0_uec_nflushes;	/* # of flushes since last restart/GC */
357600Stsien 	cmd_list_t cpu0_xxu_retries;	/* List of pending xxU retries */
358600Stsien } cmd_cpu_0_t;
359600Stsien 
360600Stsien typedef struct cmd_cpu_1 {
361600Stsien 	cmd_header_t cpu1_header;	/* Nodetype must be CMD_NT_CPU */
362600Stsien 	uint_t cpu1_version;		/* struct version - must follow hdr */
363600Stsien 	uint32_t cpu1_cpuid;		/* Logical ID for this CPU */
364600Stsien 	cmd_cpu_type_t cpu1_type;	/* CPU model */
365600Stsien 	uintptr_t *cpu1_cases;		/* v1 had a pointer to a case array */
366600Stsien 	uint8_t cpu1_faulting;		/* Set if fault has been issued */
367600Stsien 	cmd_fmri_t cpu1_asru;		/* ASRU for this CPU */
368600Stsien 	cmd_fmri_t cpu1_fru;		/* FRU for this CPU */
369600Stsien 	cmd_cpu_uec_t cpu1_uec;		/* UE cache */
370600Stsien 	cmd_cpu_uec_t cpu1_olduec;	/* To-be-flushed UE cache */
371600Stsien 	id_t cpu1_uec_flush;		/* Timer ID for UE cache flush */
372600Stsien 	uint_t cpu1_uec_nflushes;	/* # of flushes since last restart/GC */
373600Stsien 	cmd_list_t cpu1_xxu_retries;	/* List of pending xxU retries */
374600Stsien } cmd_cpu_1_t;
375600Stsien 
3762400Stsien typedef struct cmd_cpu_2 {
3772400Stsien 	cmd_header_t cpu2_header;	/* Nodetype must be CMD_NT_CPU */
3782400Stsien 	uint_t cpu2_version;		/* struct version - must follow hdr */
3792400Stsien 	uint32_t cpu2_cpuid;		/* Logical ID for this CPU */
3802400Stsien 	cmd_cpu_type_t cpu2_type;	/* CPU model */
3812400Stsien 	uint8_t cpu2_faulting;		/* Set if fault has been issued */
3822400Stsien 	cmd_fmri_t cpu2_asru;		/* ASRU for this CPU */
3832400Stsien 	cmd_fmri_t cpu2_fru;		/* FRU for this CPU */
3842400Stsien 	cmd_cpu_uec_t cpu2_uec;		/* UE cache */
3852400Stsien 	cmd_cpu_uec_t cpu2_olduec;	/* To-be-flushed UE cache */
3862400Stsien } cmd_cpu_2_t;
3872400Stsien 
3882400Stsien /* Portion of the cpu structure which must be persisted */
389600Stsien typedef struct cmd_cpu_pers {
390600Stsien 	cmd_header_t cpup_header;	/* Nodetype must be CMD_NT_CPU */
391600Stsien 	uint_t cpup_version;		/* struct version - must follow hdr */
392600Stsien 	uint32_t cpup_cpuid;		/* Logical ID for this CPU */
393600Stsien 	cmd_cpu_type_t cpup_type;	/* CPU model */
394600Stsien 	uint8_t cpup_faulting;		/* Set if fault has been issued */
3952400Stsien 	uint8_t cpup_level;		/* cpu group level - 0 == thread */
396600Stsien 	cmd_fmri_t cpup_asru;		/* ASRU for this CPU */
397600Stsien 	cmd_fmri_t cpup_fru;		/* FRU for this CPU */
398600Stsien 	cmd_cpu_uec_t cpup_uec;		/* UE cache */
399600Stsien 	cmd_cpu_uec_t cpup_olduec;	/* To-be-flushed UE cache */
400600Stsien } cmd_cpu_pers_t;
401600Stsien 
402600Stsien /* Persistent and dynamic CPU data */
403600Stsien struct cmd_cpu {
404600Stsien 	cmd_cpu_pers_t cpu_pers;
405600Stsien 	cmd_cpu_cases_t cpu_cases;
406600Stsien 	id_t cpu_uec_flush;		/* Timer ID for UE cache flush */
407600Stsien 	uint_t cpu_uec_nflushes;	/* # of flushes since last restart/GC */
408600Stsien 	cmd_list_t cpu_xxu_retries;	/* List of pending xxU retries */
409600Stsien 	uint_t cpu_flags;
4106330Sjc25722 	cmd_list_t cpu_Lxcaches;	/* List of Lxcache state structures */
4116330Sjc25722 	fmd_stat_t Lxcache_creat;	/* num of Lxcache states created */
412600Stsien };
413600Stsien 
414600Stsien #define	CMD_CPU_MAXSIZE \
415600Stsien 	MAX(MAX(sizeof (cmd_cpu_0_t), sizeof (cmd_cpu_1_t)), \
4162400Stsien 	    MAX(sizeof (cmd_cpu_2_t), sizeof (cmd_cpu_pers_t)))
417600Stsien #define	CMD_CPU_MINSIZE \
418600Stsien 	MIN(MIN(sizeof (cmd_cpu_0_t), sizeof (cmd_cpu_1_t)), \
4192400Stsien 	    MIN(sizeof (cmd_cpu_2_t), sizeof (cmd_cpu_pers_t)))
420600Stsien 
421600Stsien #define	cpu_header		cpu_pers.cpup_header
422600Stsien #define	cpu_nodetype		cpu_pers.cpup_header.hdr_nodetype
423600Stsien #define	cpu_bufname		cpu_pers.cpup_header.hdr_bufname
424600Stsien #define	cpu_version		cpu_pers.cpup_version
425600Stsien #define	cpu_cpuid		cpu_pers.cpup_cpuid
426600Stsien #define	cpu_type		cpu_pers.cpup_type
427600Stsien #define	cpu_faulting		cpu_pers.cpup_faulting
4282400Stsien #define	cpu_level		cpu_pers.cpup_level
429600Stsien #define	cpu_asru		cpu_pers.cpup_asru
430600Stsien #define	cpu_fru			cpu_pers.cpup_fru
431600Stsien #define	cpu_uec			cpu_pers.cpup_uec
432600Stsien #define	cpu_olduec		cpu_pers.cpup_olduec
433600Stsien #define	cpu_icache		cpu_cases.cpuc_icache
434600Stsien #define	cpu_dcache		cpu_cases.cpuc_dcache
435600Stsien #define	cpu_pcache		cpu_cases.cpuc_pcache
436600Stsien #define	cpu_itlb		cpu_cases.cpuc_itlb
437600Stsien #define	cpu_dtlb		cpu_cases.cpuc_dtlb
438600Stsien #define	cpu_l2data		cpu_cases.cpuc_l2data
439600Stsien #define	cpu_l2tag		cpu_cases.cpuc_l2tag
440600Stsien #define	cpu_l3data		cpu_cases.cpuc_l3data
441600Stsien #define	cpu_l3tag		cpu_cases.cpuc_l3tag
442600Stsien #define	cpu_fpu			cpu_cases.cpuc_fpu
443962Stsien #define	cpu_ireg 		cpu_cases.cpuc_ireg
444962Stsien #define	cpu_freg		cpu_cases.cpuc_freg
445962Stsien #define	cpu_mau			cpu_cases.cpuc_mau
446962Stsien #define	cpu_l2ctl		cpu_cases.cpuc_l2ctl
4473325Ssd77468 #define	cpu_misc_regs		cpu_cases.cpuc_misc_regs
4484759Ssd77468 #define	cpu_lfu			cpu_cases.cpuc_lfu
4491794Sav145390 #ifdef sun4u
4501794Sav145390 #define	cpu_opl_invsfsr		cpu_cases.cpuc_opl_invsfsr
4511794Sav145390 #define	cpu_oplue_detcpu	cpu_cases.cpuc_oplue_detcpu
4521794Sav145390 #define	cpu_oplue_detio		cpu_cases.cpuc_oplue_detio
4531772Sjl139090 #define	cpu_opl_mtlb		cpu_cases.cpuc_opl_mtlb
4541772Sjl139090 #define	cpu_opl_tlbp		cpu_cases.cpuc_opl_tlbp
4551772Sjl139090 #define	cpu_opl_inv_urg		cpu_cases.cpuc_opl_inv_urg
4561772Sjl139090 #define	cpu_opl_cre		cpu_cases.cpuc_opl_cre
4571772Sjl139090 #define	cpu_opl_tsb_ctx		cpu_cases.cpuc_opl_tsb_ctx
4581772Sjl139090 #define	cpu_opl_tsbp		cpu_cases.cpuc_opl_tsbp
4591772Sjl139090 #define	cpu_opl_pstate		cpu_cases.cpuc_opl_pstate
4601772Sjl139090 #define	cpu_opl_tstate		cpu_cases.cpuc_opl_tstate
4611772Sjl139090 #define	cpu_opl_iug_f		cpu_cases.cpuc_opl_iug_f
4621772Sjl139090 #define	cpu_opl_iug_r		cpu_cases.cpuc_opl_iug_r
4631772Sjl139090 #define	cpu_opl_sdc		cpu_cases.cpuc_opl_sdc
4641772Sjl139090 #define	cpu_opl_wdt		cpu_cases.cpuc_opl_wdt
4651772Sjl139090 #define	cpu_opl_dtlb		cpu_cases.cpuc_opl_dtlb
4661772Sjl139090 #define	cpu_opl_itlb		cpu_cases.cpuc_opl_itlb
4671772Sjl139090 #define	cpu_opl_core_err	cpu_cases.cpuc_opl_core_err
4681772Sjl139090 #define	cpu_opl_dae		cpu_cases.cpuc_opl_dae
4691772Sjl139090 #define	cpu_opl_iae		cpu_cases.cpuc_opl_iae
4701772Sjl139090 #define	cpu_opl_uge		cpu_cases.cpuc_opl_uge
4711794Sav145390 #endif	/* sun4u */
472962Stsien 
473600Stsien #define	cpu_asru_nvl		cpu_asru.fmri_nvl
474600Stsien #define	cpu_fru_nvl		cpu_fru.fmri_nvl
475600Stsien 
476600Stsien /*
477600Stsien  * L2$ and L3$ Data errors
478600Stsien  *
479600Stsien  *          SERD name
480600Stsien  *   Type   (if any)   Fault
481600Stsien  *  ------ ----------- -------------------------------
482600Stsien  *   xxC   l2cachedata fault.cpu.<cputype>.l2cachedata
483600Stsien  *   xxU        -      fault.cpu.<cputype>.l2cachedata
484600Stsien  *  L3_xxC l3cachedata fault.cpu.<cputype>.l3cachedata
485600Stsien  *  L3_xxU      -      fault.cpu.<cputype>.l3cachedata
486600Stsien  *
487600Stsien  * NOTE: For the purposes of the discussion below, xxC and xxU refer to both
488600Stsien  *       L2$ and L3$ data errors.
489600Stsien  *
490600Stsien  * These ereports will be dropped if (among other things) they are side-effects
491600Stsien  * of UEs (xxUs only) or other xxCs or xxUs.  Whenever UEs are detected, they
492600Stsien  * are added to a per-CPU cache.  xxUs are then compared to this cache.  If a
493600Stsien  * xxU's AFAR refers to an address which recently saw a UE, the xxU is dropped,
494600Stsien  * as it was most likely caused by the UE.  When multiple xxCs and xxUs are seen
495600Stsien  * with the same ENA, all save one are generally side-effects.  We track these
496600Stsien  * groups (referred to as trains), matching them against a premade list.  If one
497600Stsien  * of the trains matches, we drop all but the primary, which is indicated in the
498600Stsien  * list.
499600Stsien  *
500600Stsien  * The expected resolution of l2cachedata and l3cachedata faults is the
501600Stsien  * disabling of the indicated CPU.
502600Stsien  */
503600Stsien extern cmd_evdisp_t cmd_xxc(fmd_hdl_t *, fmd_event_t *, nvlist_t *,
504600Stsien     const char *, cmd_errcl_t);
505600Stsien extern cmd_evdisp_t cmd_xxu(fmd_hdl_t *, fmd_event_t *, nvlist_t *,
506600Stsien     const char *, cmd_errcl_t);
507600Stsien 
508600Stsien /*
5093657Stsien  * As of Niagara-2, we ignore writeback (ldwc, ldwu) errors.  Since these were
5103657Stsien  * the only defined follow-on errors for sun4v trains, sun4v L2 cache data
5113657Stsien  * errors no longer need to use the train mechanism.
5123657Stsien  */
5133657Stsien 
5143657Stsien extern cmd_evdisp_t cmd_l2c(fmd_hdl_t *, fmd_event_t *, nvlist_t *,
5153657Stsien     const char *, cmd_errcl_t);
5163657Stsien extern cmd_evdisp_t cmd_l2u(fmd_hdl_t *, fmd_event_t *, nvlist_t *,
5173657Stsien     const char *, cmd_errcl_t);
5186330Sjc25722 
5196330Sjc25722 /*
5206330Sjc25722  * Common Errdata structure for SERD engines
5216330Sjc25722  */
5226330Sjc25722 typedef struct errdata {
5236330Sjc25722 	cmd_serd_t *ed_serd;
5246330Sjc25722 	const char *ed_fltnm;
5256330Sjc25722 	const cmd_ptrsubtype_t ed_pst;
5266330Sjc25722 } errdata_t;
5276330Sjc25722 
5283657Stsien /*
529600Stsien  * L2$ and L3$ Tag errors
530600Stsien  *
531600Stsien  *           SERD name
532600Stsien  *   Type    (if any)   Fault
533600Stsien  *  ------- ----------- -------------------------------
534600Stsien  *   TxCE   l2cachetag  fault.cpu.<cputype>.l2cachetag
535600Stsien  *  L3_THCE l3cachetag  fault.cpu.<cputype>.l3cachetag
536962Stsien  *    LTC   l2cachetag	fault.cpu.<cputype>.l2cachetag
537600Stsien  *
538600Stsien  * We'll never see the uncorrectable Tag errors - they'll cause the machine to
539600Stsien  * reset, and we'll be ne'er the wiser.
540600Stsien  *
541600Stsien  * The expected resolution of l2cachetag and l3cachetag faults is the disabling
542600Stsien  * of the indicated CPU.
543600Stsien  */
544600Stsien extern cmd_evdisp_t cmd_txce(fmd_hdl_t *, fmd_event_t *, nvlist_t *,
545600Stsien     const char *, cmd_errcl_t);
546600Stsien 
547600Stsien extern cmd_evdisp_t cmd_l3_thce(fmd_hdl_t *, fmd_event_t *, nvlist_t *,
548600Stsien     const char *, cmd_errcl_t);
549600Stsien 
550600Stsien /*
551600Stsien  * L1$ errors
552600Stsien  *
553600Stsien  *          SERD name
554600Stsien  *   Type   (if any)   Fault
555600Stsien  *  ------- --------- -------------------------------
556600Stsien  *   IPE     icache   fault.cpu.<cputype>.icache
557600Stsien  *   IxSPE   icache   fault.cpu.<cputype>.icache
558600Stsien  *   DPE     dcache   fault.cpu.<cputype>.dcache
559600Stsien  *   DxSPE   dcache   fault.cpu.<cputype>.dcache
560600Stsien  *   PDSPE   pcache   fault.cpu.<cputype>.pcache
561600Stsien  *
562600Stsien  * The I$, D$, and P$ are clean, and thus have no uncorrectable errors.
563600Stsien  *
564600Stsien  * The expected resolution of icache, dcache, and pcache faults is the disabling
565600Stsien  * of the indicated CPU.
566600Stsien  */
567600Stsien extern cmd_evdisp_t cmd_icache(fmd_hdl_t *, fmd_event_t *, nvlist_t *,
568600Stsien     const char *, cmd_errcl_t);
569600Stsien extern cmd_evdisp_t cmd_dcache(fmd_hdl_t *, fmd_event_t *, nvlist_t *,
570600Stsien     const char *, cmd_errcl_t);
571600Stsien extern cmd_evdisp_t cmd_pcache(fmd_hdl_t *, fmd_event_t *, nvlist_t *,
572600Stsien     const char *, cmd_errcl_t);
573600Stsien 
574600Stsien /*
575600Stsien  * TLB errors
576600Stsien  *
577600Stsien  *         SERD name
578600Stsien  *   Type  (if any)   Fault
579600Stsien  *  ------ --------- -------------------------------
580600Stsien  *  ITLBPE   itlb    fault.cpu.<cputype>.itlb
581600Stsien  *  DTLBPE   dtlb    fault.cpu.<cputype>.dtlb
582600Stsien  *
583600Stsien  * The expected resolution of itlb and dtlb faults is the disabling of the
584600Stsien  * indicated CPU.
585600Stsien  */
586600Stsien extern cmd_evdisp_t cmd_itlb(fmd_hdl_t *, fmd_event_t *, nvlist_t *,
587600Stsien     const char *, cmd_errcl_t);
588600Stsien extern cmd_evdisp_t cmd_dtlb(fmd_hdl_t *, fmd_event_t *, nvlist_t *,
589600Stsien     const char *, cmd_errcl_t);
590600Stsien 
591600Stsien extern void cmd_cpuerr_close(fmd_hdl_t *, void *);
592600Stsien 
593600Stsien /*
594600Stsien  * FPU errors
595600Stsien  *
596600Stsien  *         SERD name
597600Stsien  *   Type  (if any)   Fault
598600Stsien  *  ------ --------- -------------------------------
599600Stsien  *   FPU       -     fault.cpu.<cputype>.fpu
600600Stsien  *
601600Stsien  * The expected resolution of FPU faults is the disabling of the indicated CPU.
602600Stsien  */
603600Stsien extern cmd_evdisp_t cmd_fpu(fmd_hdl_t *, fmd_event_t *, nvlist_t *,
604600Stsien     const char *, cmd_errcl_t);
605600Stsien 
606*6429Svs195195 
607*6429Svs195195 
608*6429Svs195195 /*
609*6429Svs195195  * FPU (FP-Scrubber) errors
610*6429Svs195195  *
611*6429Svs195195  *         SERD name
612*6429Svs195195  *   Type  (if any)   Fault
613*6429Svs195195  *  ------ --------- -------------------------------
614*6429Svs195195  *   FPU       -     fault.cpu.<cputype>.fpu
615*6429Svs195195  *
616*6429Svs195195  * The expected resolution of FPU faults is the disabling of the CPU
617*6429Svs195195  * indicted in the resource FMRI.
618*6429Svs195195  */
619*6429Svs195195 extern cmd_evdisp_t cmd_fps(fmd_hdl_t *, fmd_event_t *, nvlist_t *,
620*6429Svs195195     const char *, cmd_errcl_t);
621*6429Svs195195 
622*6429Svs195195 
623*6429Svs195195 
624*6429Svs195195 
625*6429Svs195195 
626600Stsien /*
627962Stsien  * ireg errors
628962Stsien  *
629962Stsien  *         SERD name
630962Stsien  *   Type  (if any)   Fault
631962Stsien  *  ------ --------- -------------------------------
632962Stsien  *   IRC     ireg    fault.cpu.<cputype>.ireg
633962Stsien  *   IRU      -				 "
634962Stsien  *
635962Stsien  * The expected resolution of ireg faults is the disabling of the indicated CPU.
636962Stsien  */
637962Stsien extern cmd_evdisp_t cmd_irc(fmd_hdl_t *, fmd_event_t *, nvlist_t *,
638962Stsien     const char *, cmd_errcl_t);
639962Stsien extern cmd_evdisp_t cmd_iru(fmd_hdl_t *, fmd_event_t *, nvlist_t *,
640962Stsien     const char *, cmd_errcl_t);
641962Stsien 
642962Stsien /*
643962Stsien  * freg errors
644962Stsien  *
645962Stsien  *         SERD name
646962Stsien  *   Type  (if any)   Fault
647962Stsien  *  ------ --------- -------------------------------
648962Stsien  *   FRC     freg    fault.cpu.ultraSPARC-T1.frc
649962Stsien  *   FRU      -                           " .fru
650962Stsien  *
651962Stsien  * The expected resolution of freg faults is the repair of the indicated CPU.
652962Stsien  */
653962Stsien extern cmd_evdisp_t cmd_frc(fmd_hdl_t *, fmd_event_t *, nvlist_t *,
654962Stsien     const char *, cmd_errcl_t);
655962Stsien extern cmd_evdisp_t cmd_fru(fmd_hdl_t *, fmd_event_t *, nvlist_t *,
656962Stsien     const char *, cmd_errcl_t);
657962Stsien 
658962Stsien /*
659962Stsien  * MAU errors
660962Stsien  *
661962Stsien  *         SERD name
662962Stsien  *   Type  (if any)   Fault
663962Stsien  *  ------ --------- -------------------------------
664962Stsien  *   MAU     mau    fault.cpu.<cputype>.mau
665962Stsien  *
666962Stsien  * The expected resolution of mau faults is the repair of the indicated CPU.
667962Stsien  */
668962Stsien extern cmd_evdisp_t cmd_mau(fmd_hdl_t *, fmd_event_t *, nvlist_t *,
669962Stsien     const char *, cmd_errcl_t);
670962Stsien 
671962Stsien /*
672962Stsien  * L2CTL errors
673962Stsien  *
674962Stsien  *         SERD name
675962Stsien  *   Type  (if any)   Fault
676962Stsien  *  ------ --------- -------------------------------
677962Stsien  *  L2CTL     -     fault.cpu.<cputype>.l2ctl
678962Stsien  *
679962Stsien  * The expected resolution of l2ctl faults is the repair of the indicated CPU.
680962Stsien  */
681962Stsien extern cmd_evdisp_t cmd_l2ctl(fmd_hdl_t *, fmd_event_t *, nvlist_t *,
682962Stsien     const char *, cmd_errcl_t);
683962Stsien 
684962Stsien /*
6853325Ssd77468  * SBD (Storage Buffer Data) errors
6863325Ssd77468  * SCA (Scratchpath Array) erros
6873325Ssd77468  * TC (Tick compare) errors
6883325Ssd77468  * TSA (Trap stack Array) errors
6893325Ssd77468  *
6903325Ssd77468  *         SERD name
6913325Ssd77468  *   Type  (if any)   Fault
6923325Ssd77468  *  ------ --------- -------------------------------
6933325Ssd77468  *   SBDC     misc_regs    fault.cpu.<cputype>.misc_regs
6943325Ssd77468  *   SBDU
6953325Ssd77468  *   SCAC, SCAU
6963325Ssd77468  *   TCC, TCU
6973325Ssd77468  *   TSAC, TSAU
6983325Ssd77468  *
6993325Ssd77468  * The expected resolution of misc_regs faults is the repair of
7003325Ssd77468  * the indicated CPU.
7013325Ssd77468  */
7023325Ssd77468 extern cmd_evdisp_t cmd_miscregs_ce(fmd_hdl_t *, fmd_event_t *, nvlist_t *,
7033325Ssd77468     const char *, cmd_errcl_t);
7043325Ssd77468 extern cmd_evdisp_t cmd_miscregs_ue(fmd_hdl_t *, fmd_event_t *, nvlist_t *,
7053325Ssd77468     const char *, cmd_errcl_t);
7063325Ssd77468 
7074735Std122701 extern cmd_evdisp_t cmd_miscregs_train(fmd_hdl_t *, fmd_event_t *, nvlist_t *,
7084735Std122701     const char *, cmd_errcl_t);
7093325Ssd77468 
7103325Ssd77468 /*
7114759Ssd77468  * Type                                          Fault
7124759Ssd77468  * ---------------------------------------------------------------------
7134759Ssd77468  * LFU-RTF   uncorrectable link retrain fail error    fault.cpu.T2plus.lfu-u
7144759Ssd77468  * LFU-TTO   uncorrectable training timeout error
7154759Ssd77468  * LFU-CTO   uncorrectable config timeout error
7164759Ssd77468  * LFU-MLF   uncorrectable multi lanes link fail error
7174759Ssd77468  * LFU-SLF   correctable single lane failover	      fault.cpu.T2plus.lfu-f
7184759Ssd77468  *
7194759Ssd77468  * The expected resolution of lfu faults is the repair of the indicated CPU.
7204759Ssd77468  */
7214759Ssd77468 extern cmd_evdisp_t cmd_lfu_ue(fmd_hdl_t *, fmd_event_t *, nvlist_t *,
7224759Ssd77468     const char *, cmd_errcl_t);
7234759Ssd77468 extern cmd_evdisp_t cmd_lfu_ce(fmd_hdl_t *, fmd_event_t *, nvlist_t *,
7244759Ssd77468     const char *, cmd_errcl_t);
7254759Ssd77468 /*
7264759Ssd77468  * Type                                          Fault
7274759Ssd77468  * ---------------------------------------------------------------------
7284759Ssd77468  * Coherency link protocol errors
7294759Ssd77468  * to        Transaction timed out  		fault.cpu.T2plus.lfu-p
7304759Ssd77468  * frack     Invalid or redundant request ack
7314759Ssd77468  * fsr       Invalid or redundant snoop response
7324759Ssd77468  * fdr       Invalid or redundant data return
7334759Ssd77468  * snptyp    Invalid snoop type received from
7344759Ssd77468  *           coherency link
7354759Ssd77468  *
7364759Ssd77468  * The expected resolution of lfu faults is the repair of the indicated CPU.
7374759Ssd77468  */
7384759Ssd77468 extern cmd_evdisp_t cmd_lfu_pe(fmd_hdl_t *, fmd_event_t *, nvlist_t *,
7394759Ssd77468     const char *, cmd_errcl_t);
7404759Ssd77468 
7414759Ssd77468 /*
742600Stsien  * CPUs are described by FMRIs.  This routine will retrieve the CPU state
743600Stsien  * structure (creating a new one if necessary) described by the detector
744600Stsien  * FMRI in the passed ereport.
745600Stsien  */
746600Stsien extern cmd_cpu_t *cmd_cpu_lookup_from_detector(fmd_hdl_t *, nvlist_t *,
7472400Stsien     const char *, uint8_t);
748600Stsien 
7493325Ssd77468 extern char *cmd_cpu_getfrustr(fmd_hdl_t *, cmd_cpu_t *);
7503325Ssd77468 extern char *cmd_cpu_getpartstr(fmd_hdl_t *, cmd_cpu_t *);
7513325Ssd77468 
7523325Ssd77468 extern char *cmd_cpu_getserialstr(fmd_hdl_t *, cmd_cpu_t *);
7535430Ssd77468 extern nvlist_t *cmd_cpu_mkfru(fmd_hdl_t *, char *, char *, char *);
7543325Ssd77468 
7552400Stsien extern cmd_cpu_t *cmd_cpu_lookup(fmd_hdl_t *, nvlist_t *, const char *,
7562400Stsien     uint8_t);
7571772Sjl139090 
7582400Stsien extern void cmd_cpu_create_faultlist(fmd_hdl_t *, fmd_case_t *, cmd_cpu_t *,
7592400Stsien     const char *, nvlist_t *, uint_t);
760600Stsien 
7616330Sjc25722 extern cmd_cpu_t *cmd_restore_cpu_only(fmd_hdl_t *, fmd_case_t *, char *);
762600Stsien extern void cmd_cpu_destroy(fmd_hdl_t *, cmd_cpu_t *);
763600Stsien extern void *cmd_cpu_restore(fmd_hdl_t *, fmd_case_t *, cmd_case_ptr_t *);
764600Stsien extern void cmd_cpu_validate(fmd_hdl_t *);
765600Stsien extern void cmd_cpu_timeout(fmd_hdl_t *, id_t, void *);
766600Stsien extern void cmd_cpu_gc(fmd_hdl_t *);
767600Stsien extern void cmd_cpu_fini(fmd_hdl_t *hdl);
768600Stsien extern char *cmd_cpu_serdnm_create(fmd_hdl_t *, cmd_cpu_t *, const char *);
7691794Sav145390 extern nvlist_t *cmd_cpu_fmri_create(uint32_t, uint8_t);
770600Stsien 
7712400Stsien extern uint32_t cmd_cpu2core(uint32_t, cmd_cpu_type_t, uint8_t);
7722400Stsien 
7732400Stsien #define	CMD_CPU_LEVEL_THREAD		0
7742400Stsien #define	CMD_CPU_LEVEL_CORE		1
7752400Stsien #define	CMD_CPU_LEVEL_CHIP		2
7766330Sjc25722 #define	CMD_CPU_STAT_BUMP(cpu, name)    cpu->name.fmds_value.ui64++
7772400Stsien 
778600Stsien typedef enum {
779600Stsien     CMD_CPU_FAM_UNSUPPORTED,
780600Stsien     CMD_CPU_FAM_CHEETAH,
7811772Sjl139090     CMD_CPU_FAM_NIAGARA,
7821772Sjl139090     CMD_CPU_FAM_SPARC64
783600Stsien } cpu_family_t;
784600Stsien 
7851772Sjl139090 typedef struct faminfo {
7861772Sjl139090 	cpu_family_t fam_value;
7871772Sjl139090 	boolean_t ecache_flush_needed;
7881772Sjl139090 } faminfo_t;
7891772Sjl139090 
790600Stsien extern cpu_family_t cmd_cpu_check_support(void);
7911772Sjl139090 extern boolean_t cmd_cpu_ecache_support(void);
792600Stsien 
793962Stsien extern int cmd_xr_fill(fmd_hdl_t *, nvlist_t *, cmd_xr_t *, cmd_errcl_t);
7946369Std122701 extern void cmd_fill_errdata(cmd_errcl_t, cmd_cpu_t *, cmd_case_t **,
7956369Std122701     const errdata_t **);
7966369Std122701 extern cmd_xxcu_trw_t *cmd_trw_lookup(uint64_t, uint8_t, uint64_t);
7976369Std122701 extern cmd_evdisp_t cmd_nop_train(fmd_hdl_t *, fmd_event_t *, nvlist_t *,
7986369Std122701     const char *, cmd_errcl_t);
7996369Std122701 extern cmd_errcl_t cmd_train_match(cmd_errcl_t, cmd_errcl_t);
8006369Std122701 extern int cmd_afar_status_check(uint8_t, cmd_errcl_t);
801962Stsien 
802962Stsien #ifdef sun4u
8036369Std122701 extern int cmd_cpu_synd_check(uint16_t, cmd_errcl_t clcode);
804962Stsien #else /* sun4u */
8056369Std122701 extern int cmd_cpu_synd_check(uint32_t, cmd_errcl_t clcode);
806962Stsien #endif /* sun4u */
807962Stsien 
8082828Sjc25722 extern int cmd_afar_valid(fmd_hdl_t *hdl, nvlist_t *nvl, cmd_errcl_t,
8092828Sjc25722     uint64_t *afar);
8102828Sjc25722 
811600Stsien #ifdef __cplusplus
812600Stsien }
813600Stsien #endif
814600Stsien 
815600Stsien #endif /* _CMD_CPU_H */
816