xref: /onnv-gate/usr/src/cmd/fm/modules/sun4/cpumem-diagnosis/cmd_state.h (revision 10784:15baf8dd1081)
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 /*
22*10784Ssinanallur.balasubramanian@sun.com  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23600Stsien  * Use is subject to license terms.
24600Stsien  */
25600Stsien 
26600Stsien #ifndef _CMD_STATE_H
27600Stsien #define	_CMD_STATE_H
28600Stsien 
29600Stsien /*
30600Stsien  * Case management and saved state restoration
31600Stsien  */
32600Stsien 
33600Stsien #include <cmd_list.h>
34600Stsien 
35600Stsien #include <fm/fmd_api.h>
36600Stsien 
37600Stsien #ifdef __cplusplus
38600Stsien extern "C" {
39600Stsien #endif
40600Stsien 
41600Stsien /*
42600Stsien  * Our maximum persistent buffer name length, used to allocate fixed-size
43600Stsien  * arrays for name storage.
44600Stsien  */
45600Stsien #define	CMD_BUFNMLEN		48
46600Stsien 
47600Stsien /* cmd_evdisp_t, cmd_evdisp_stat_t, and cmd_evdisp_names must be in sync */
48600Stsien typedef enum cmd_evdisp {
49600Stsien 	CMD_EVD_OK,
50600Stsien 	CMD_EVD_BAD,
51600Stsien 	CMD_EVD_UNUSED,
52600Stsien 	CMD_EVD_REDUND
53600Stsien } cmd_evdisp_t;
54600Stsien 
55600Stsien /*
56600Stsien  * Each handled ereport type has four statistics, designed to indicate the
57600Stsien  * eventual disposition of the ereport.
58600Stsien  */
59600Stsien typedef struct cmd_evdisp_stat {
60600Stsien 	fmd_stat_t evs_ok;		/* # of erpts processed successfully */
61600Stsien 	fmd_stat_t evs_bad;		/* # of malformed ereports */
62600Stsien 	fmd_stat_t evs_unused;		/* # of erpts unusable or not needed */
63600Stsien 	fmd_stat_t evs_redund;		/* # of erpts already explained */
64600Stsien } cmd_evdisp_stat_t;
65600Stsien 
66600Stsien /* Must be in sync with cmd_case_restorers */
67600Stsien typedef enum cmd_nodetype {
68600Stsien 	CMD_NT_CPU = 1,
69600Stsien 	CMD_NT_DIMM,
70600Stsien 	CMD_NT_BANK,
711186Sayznaga 	CMD_NT_PAGE,
724759Ssd77468 #ifdef sun4u
736330Sjc25722 	CMD_NT_DP,
746330Sjc25722 	CMD_NT_LxCACHE
754759Ssd77468 #endif
764759Ssd77468 #ifdef sun4v
774759Ssd77468 	CMD_NT_BRANCH
784759Ssd77468 #endif
79600Stsien } cmd_nodetype_t;
80600Stsien 
81600Stsien /*
82600Stsien  * Must be in sync with cmd_case_closers.  Additional types must be
83600Stsien  * appended to this enum otherwise interpretation of existing logs
84600Stsien  * and checkpoints will be confused.
85600Stsien  */
86600Stsien typedef enum cmd_ptrsubtype {
87600Stsien 	CMD_PTR_CPU_ICACHE = 1,
88600Stsien 	CMD_PTR_CPU_DCACHE,
89600Stsien 	CMD_PTR_CPU_PCACHE,
90600Stsien 	CMD_PTR_CPU_ITLB,
91600Stsien 	CMD_PTR_CPU_DTLB,
92600Stsien 	CMD_PTR_CPU_L2DATA,
93600Stsien 	CMD_PTR_CPU_L2DATA_UERETRY,	/* no longer used */
94600Stsien 	CMD_PTR_CPU_L2TAG,
95600Stsien 	CMD_PTR_CPU_L3DATA,
96600Stsien 	CMD_PTR_CPU_L3DATA_UERETRY,	/* no longer used */
97600Stsien 	CMD_PTR_CPU_L3TAG,
98600Stsien 	CMD_PTR_DIMM_CASE,
99600Stsien 	CMD_PTR_BANK_CASE,
100600Stsien 	CMD_PTR_PAGE_CASE,
101600Stsien 	CMD_PTR_CPU_FPU,
102962Stsien 	CMD_PTR_CPU_XR_RETRY,
103962Stsien 	CMD_PTR_CPU_IREG,
104962Stsien 	CMD_PTR_CPU_FREG,
105962Stsien 	CMD_PTR_CPU_MAU,
1061186Sayznaga 	CMD_PTR_CPU_L2CTL,
1071186Sayznaga 	CMD_PTR_DP_CASE,
1081772Sjl139090 	CMD_PTR_DP_PAGE_DEFER,
1091772Sjl139090 	CMD_PTR_CPU_INV_SFSR,
1101772Sjl139090 	CMD_PTR_CPU_UE_DET_CPU,
1111772Sjl139090 	CMD_PTR_CPU_UE_DET_IO,
1121772Sjl139090 	CMD_PTR_CPU_MTLB,
1131772Sjl139090 	CMD_PTR_CPU_TLBP,
1141772Sjl139090 	CMD_PTR_CPU_UGESR_INV_URG,
1151772Sjl139090 	CMD_PTR_CPU_UGESR_CRE,
1161772Sjl139090 	CMD_PTR_CPU_UGESR_TSB_CTX,
1171772Sjl139090 	CMD_PTR_CPU_UGESR_TSBP,
1181772Sjl139090 	CMD_PTR_CPU_UGESR_PSTATE,
1191772Sjl139090 	CMD_PTR_CPU_UGESR_TSTATE,
1201772Sjl139090 	CMD_PTR_CPU_UGESR_IUG_F,
1211772Sjl139090 	CMD_PTR_CPU_UGESR_IUG_R,
1221772Sjl139090 	CMD_PTR_CPU_UGESR_SDC,
1231772Sjl139090 	CMD_PTR_CPU_UGESR_WDT,
1241772Sjl139090 	CMD_PTR_CPU_UGESR_DTLB,
1251772Sjl139090 	CMD_PTR_CPU_UGESR_ITLB,
1261772Sjl139090 	CMD_PTR_CPU_UGESR_CORE_ERR,
1271772Sjl139090 	CMD_PTR_CPU_UGESR_DAE,
1281772Sjl139090 	CMD_PTR_CPU_UGESR_IAE,
1293325Ssd77468 	CMD_PTR_CPU_UGESR_UGE,
1304759Ssd77468 	CMD_PTR_CPU_MISC_REGS,
1314759Ssd77468 	CMD_PTR_CPU_LFU,
1326330Sjc25722 	CMD_PTR_BRANCH_CASE,
1336330Sjc25722 	CMD_PTR_LxCACHE_CASE
134600Stsien } cmd_ptrsubtype_t;
135600Stsien 
136600Stsien /*
137600Stsien  * A change was made to the above enum that violated the ordering requirement
138600Stsien  * described in the comment.  As such, there exist development machines in
139600Stsien  * the wild that have pre-violation pointer buffers.  Attempts to run the DE
140600Stsien  * on those machines will cause the state-restoration code to fail, as it
141600Stsien  * won't know what to do with the old pointer types.  Unfortunately, the old
142600Stsien  * and new values overlapped for the CPU pointers, so there's not much we
143600Stsien  * can do there.  The memory pointers, on the other hand, changed from 6-8 to
144600Stsien  * 12-14, thus allowing us to make the dimm, bank, and page restoration code
145600Stsien  * check for both values.
146600Stsien  *
147600Stsien  * This should go away soon into the next release.
148600Stsien  */
149600Stsien typedef enum cmd_BUG_ptrsubtype {
150600Stsien 	BUG_PTR_DIMM_CASE = 6,
151600Stsien 	BUG_PTR_BANK_CASE = 7,
152600Stsien 	BUG_PTR_PAGE_CASE = 8
153600Stsien } cmd_BUG_ptrsubtype_t;
154600Stsien 
1551186Sayznaga #define	CMD_TIMERTYPE_CPU_UEC_FLUSH	1
1561186Sayznaga #define	CMD_TIMERTYPE_CPU_XR_WAITER	2
1571186Sayznaga #define	CMD_TIMERTYPE_MEM		3
1581186Sayznaga #define	CMD_TIMERTYPE_DP		4
159*10784Ssinanallur.balasubramanian@sun.com #define	CMD_TIMERTYPE_ANONYMOUS_TAG_ERROR 	5
160600Stsien 
1611186Sayznaga #define	CMD_TIMERTYPE_ISCPU(timer)	((timer) != CMD_TIMERTYPE_MEM && \
1621186Sayznaga 					(timer) != CMD_TIMERTYPE_DP)
163600Stsien 
164600Stsien /*
165600Stsien  * There are three types of general-purpose buffers, used to track CPUs, DIMMs,
166600Stsien  * and pages.  Created on-demand as ereports arrive, one buffer is created for
167600Stsien  * each thing tracked.  The general-purpose buffers are used to track common
168600Stsien  * state, and are used to support case-specific buffers.  Each open case has
169600Stsien  * a case-specific pointer buffer, used to aid in the rediscovery of the
170600Stsien  * associated general-purpose buffer.  When restoration begins, we iterate
171600Stsien  * through each of the open cases, restoring the case-specific pointer buffers
172600Stsien  * for each.  The pointer buffers are then used to restore the general-purpose
173600Stsien  * buffers.
174600Stsien  */
175600Stsien 
176600Stsien typedef	struct cmd_case_ptr {
177600Stsien 	cmd_nodetype_t ptr_type;	/* The type of associated G.P. buffer */
178600Stsien 	cmd_ptrsubtype_t ptr_subtype;	/* The case within the G.P. buffer */
179600Stsien 	char ptr_name[CMD_BUFNMLEN];	/* G.P. buffer name */
180600Stsien } cmd_case_ptr_t;
181600Stsien 
182600Stsien /*
183600Stsien  * All general-purpose buffers begin with a common header.  This header contains
184600Stsien  * identification information used in the construction of new cases.
185600Stsien  *
186600Stsien  * Note that versioned structs (currently cmd_cpu_t) depend upon the size of
187600Stsien  * this struct remaining fixed.
188600Stsien  */
189600Stsien typedef struct cmd_header {
190600Stsien 	cmd_list_t hdr_list;		/* List of G.P. structs of this type */
191600Stsien 	cmd_nodetype_t hdr_nodetype;	/* Type of this G.P. struct */
192600Stsien 	char hdr_bufname[CMD_BUFNMLEN]; /* G.P. buffer name */
193600Stsien } cmd_header_t;
194600Stsien 
195600Stsien /*
196600Stsien  * Per-case-subtype case closing routines.  Stored in per-case state when the
197600Stsien  * case is generated, and regenerated from saved state upon restore.
198600Stsien  */
199600Stsien typedef void cmd_case_closer_f(fmd_hdl_t *, void *);
200600Stsien typedef void *cmd_case_restorer_f(fmd_hdl_t *, fmd_case_t *, cmd_case_ptr_t *);
201600Stsien 
202600Stsien typedef struct cmd_case_closer {
203600Stsien 	cmd_case_closer_f *cl_func;
204600Stsien 	void *cl_arg;
205600Stsien } cmd_case_closer_t;
206600Stsien 
207600Stsien typedef struct cmd_case {
208600Stsien 	fmd_case_t *cc_cp;
209600Stsien 	char *cc_serdnm;
210600Stsien } cmd_case_t;
211600Stsien 
212600Stsien /*
213600Stsien  * Utility functions which ease the management of cases.
214600Stsien  */
215600Stsien extern fmd_case_t *cmd_case_create(fmd_hdl_t *, cmd_header_t *,
216600Stsien     cmd_ptrsubtype_t, const char **);
217600Stsien extern void cmd_case_redirect(fmd_hdl_t *, fmd_case_t *, cmd_ptrsubtype_t);
218600Stsien extern void cmd_case_fini(fmd_hdl_t *, fmd_case_t *, int);
219600Stsien extern void cmd_case_restore(fmd_hdl_t *, cmd_case_t *, fmd_case_t *, char *);
220600Stsien 
221600Stsien extern int cmd_state_restore(fmd_hdl_t *);
222600Stsien 
223600Stsien #ifdef __cplusplus
224600Stsien }
225600Stsien #endif
226600Stsien 
227600Stsien #endif /* _CMD_STATE_H */
228