xref: /onnv-gate/usr/src/cmd/fm/modules/sun4/cpumem-diagnosis/cmd_state.h (revision 1772:78cca3d2cc4b)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _CMD_STATE_H
27 #define	_CMD_STATE_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 /*
32  * Case management and saved state restoration
33  */
34 
35 #include <cmd_list.h>
36 
37 #include <fm/fmd_api.h>
38 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
43 /*
44  * Our maximum persistent buffer name length, used to allocate fixed-size
45  * arrays for name storage.
46  */
47 #define	CMD_BUFNMLEN		48
48 
49 /* cmd_evdisp_t, cmd_evdisp_stat_t, and cmd_evdisp_names must be in sync */
50 typedef enum cmd_evdisp {
51 	CMD_EVD_OK,
52 	CMD_EVD_BAD,
53 	CMD_EVD_UNUSED,
54 	CMD_EVD_REDUND
55 } cmd_evdisp_t;
56 
57 /*
58  * Each handled ereport type has four statistics, designed to indicate the
59  * eventual disposition of the ereport.
60  */
61 typedef struct cmd_evdisp_stat {
62 	fmd_stat_t evs_ok;		/* # of erpts processed successfully */
63 	fmd_stat_t evs_bad;		/* # of malformed ereports */
64 	fmd_stat_t evs_unused;		/* # of erpts unusable or not needed */
65 	fmd_stat_t evs_redund;		/* # of erpts already explained */
66 } cmd_evdisp_stat_t;
67 
68 /* Must be in sync with cmd_case_restorers */
69 typedef enum cmd_nodetype {
70 	CMD_NT_CPU = 1,
71 	CMD_NT_DIMM,
72 	CMD_NT_BANK,
73 	CMD_NT_PAGE,
74 	CMD_NT_DP
75 } cmd_nodetype_t;
76 
77 /*
78  * Must be in sync with cmd_case_closers.  Additional types must be
79  * appended to this enum otherwise interpretation of existing logs
80  * and checkpoints will be confused.
81  */
82 typedef enum cmd_ptrsubtype {
83 	CMD_PTR_CPU_ICACHE = 1,
84 	CMD_PTR_CPU_DCACHE,
85 	CMD_PTR_CPU_PCACHE,
86 	CMD_PTR_CPU_ITLB,
87 	CMD_PTR_CPU_DTLB,
88 	CMD_PTR_CPU_L2DATA,
89 	CMD_PTR_CPU_L2DATA_UERETRY,	/* no longer used */
90 	CMD_PTR_CPU_L2TAG,
91 	CMD_PTR_CPU_L3DATA,
92 	CMD_PTR_CPU_L3DATA_UERETRY,	/* no longer used */
93 	CMD_PTR_CPU_L3TAG,
94 	CMD_PTR_DIMM_CASE,
95 	CMD_PTR_BANK_CASE,
96 	CMD_PTR_PAGE_CASE,
97 	CMD_PTR_CPU_FPU,
98 	CMD_PTR_CPU_XR_RETRY,
99 	CMD_PTR_CPU_IREG,
100 	CMD_PTR_CPU_FREG,
101 	CMD_PTR_CPU_MAU,
102 	CMD_PTR_CPU_L2CTL,
103 	CMD_PTR_DP_CASE,
104 	CMD_PTR_DP_PAGE_DEFER,
105 	CMD_PTR_CPU_INV_SFSR,
106 	CMD_PTR_CPU_UE_DET_CPU,
107 	CMD_PTR_CPU_UE_DET_IO,
108 	CMD_PTR_CPU_MTLB,
109 	CMD_PTR_CPU_TLBP,
110 	CMD_PTR_CPU_UGESR_INV_URG,
111 	CMD_PTR_CPU_UGESR_CRE,
112 	CMD_PTR_CPU_UGESR_TSB_CTX,
113 	CMD_PTR_CPU_UGESR_TSBP,
114 	CMD_PTR_CPU_UGESR_PSTATE,
115 	CMD_PTR_CPU_UGESR_TSTATE,
116 	CMD_PTR_CPU_UGESR_IUG_F,
117 	CMD_PTR_CPU_UGESR_IUG_R,
118 	CMD_PTR_CPU_UGESR_SDC,
119 	CMD_PTR_CPU_UGESR_WDT,
120 	CMD_PTR_CPU_UGESR_DTLB,
121 	CMD_PTR_CPU_UGESR_ITLB,
122 	CMD_PTR_CPU_UGESR_CORE_ERR,
123 	CMD_PTR_CPU_UGESR_DAE,
124 	CMD_PTR_CPU_UGESR_IAE,
125 	CMD_PTR_CPU_UGESR_UGE
126 } cmd_ptrsubtype_t;
127 
128 /*
129  * A change was made to the above enum that violated the ordering requirement
130  * described in the comment.  As such, there exist development machines in
131  * the wild that have pre-violation pointer buffers.  Attempts to run the DE
132  * on those machines will cause the state-restoration code to fail, as it
133  * won't know what to do with the old pointer types.  Unfortunately, the old
134  * and new values overlapped for the CPU pointers, so there's not much we
135  * can do there.  The memory pointers, on the other hand, changed from 6-8 to
136  * 12-14, thus allowing us to make the dimm, bank, and page restoration code
137  * check for both values.
138  *
139  * This should go away soon into the next release.
140  */
141 typedef enum cmd_BUG_ptrsubtype {
142 	BUG_PTR_DIMM_CASE = 6,
143 	BUG_PTR_BANK_CASE = 7,
144 	BUG_PTR_PAGE_CASE = 8
145 } cmd_BUG_ptrsubtype_t;
146 
147 #define	CMD_TIMERTYPE_CPU_UEC_FLUSH	1
148 #define	CMD_TIMERTYPE_CPU_XR_WAITER	2
149 #define	CMD_TIMERTYPE_MEM		3
150 #define	CMD_TIMERTYPE_DP		4
151 
152 #define	CMD_TIMERTYPE_ISCPU(timer)	((timer) != CMD_TIMERTYPE_MEM && \
153 					(timer) != CMD_TIMERTYPE_DP)
154 
155 /*
156  * There are three types of general-purpose buffers, used to track CPUs, DIMMs,
157  * and pages.  Created on-demand as ereports arrive, one buffer is created for
158  * each thing tracked.  The general-purpose buffers are used to track common
159  * state, and are used to support case-specific buffers.  Each open case has
160  * a case-specific pointer buffer, used to aid in the rediscovery of the
161  * associated general-purpose buffer.  When restoration begins, we iterate
162  * through each of the open cases, restoring the case-specific pointer buffers
163  * for each.  The pointer buffers are then used to restore the general-purpose
164  * buffers.
165  */
166 
167 typedef	struct cmd_case_ptr {
168 	cmd_nodetype_t ptr_type;	/* The type of associated G.P. buffer */
169 	cmd_ptrsubtype_t ptr_subtype;	/* The case within the G.P. buffer */
170 	char ptr_name[CMD_BUFNMLEN];	/* G.P. buffer name */
171 } cmd_case_ptr_t;
172 
173 /*
174  * All general-purpose buffers begin with a common header.  This header contains
175  * identification information used in the construction of new cases.
176  *
177  * Note that versioned structs (currently cmd_cpu_t) depend upon the size of
178  * this struct remaining fixed.
179  */
180 typedef struct cmd_header {
181 	cmd_list_t hdr_list;		/* List of G.P. structs of this type */
182 	cmd_nodetype_t hdr_nodetype;	/* Type of this G.P. struct */
183 	char hdr_bufname[CMD_BUFNMLEN]; /* G.P. buffer name */
184 } cmd_header_t;
185 
186 /*
187  * Per-case-subtype case closing routines.  Stored in per-case state when the
188  * case is generated, and regenerated from saved state upon restore.
189  */
190 typedef void cmd_case_closer_f(fmd_hdl_t *, void *);
191 typedef void *cmd_case_restorer_f(fmd_hdl_t *, fmd_case_t *, cmd_case_ptr_t *);
192 
193 typedef struct cmd_case_closer {
194 	cmd_case_closer_f *cl_func;
195 	void *cl_arg;
196 } cmd_case_closer_t;
197 
198 typedef struct cmd_case {
199 	fmd_case_t *cc_cp;
200 	char *cc_serdnm;
201 } cmd_case_t;
202 
203 /*
204  * Utility functions which ease the management of cases.
205  */
206 extern fmd_case_t *cmd_case_create(fmd_hdl_t *, cmd_header_t *,
207     cmd_ptrsubtype_t, const char **);
208 extern void cmd_case_redirect(fmd_hdl_t *, fmd_case_t *, cmd_ptrsubtype_t);
209 extern void cmd_case_fini(fmd_hdl_t *, fmd_case_t *, int);
210 extern void cmd_case_restore(fmd_hdl_t *, cmd_case_t *, fmd_case_t *, char *);
211 
212 extern int cmd_state_restore(fmd_hdl_t *);
213 
214 #ifdef __cplusplus
215 }
216 #endif
217 
218 #endif /* _CMD_STATE_H */
219