xref: /titanic_52/usr/src/cmd/fm/modules/sun4/cpumem-diagnosis/cmd.h (revision d4ac42a1cd3016618a9ba0330862d410f0058f89)
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 (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
23  */
24 
25 #ifndef _CMD_H
26 #define	_CMD_H
27 
28 #include <stdarg.h>
29 #include <fm/fmd_api.h>
30 #include <sys/param.h>
31 
32 #include <cmd_list.h>
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38 /*
39  * Diagnosis of certain errors requires that either a) the type of ereport be
40  * recorded in a persistent buffer or b) that a single value be used to
41  * represent multiple ereport classes.  We start the values at 0x8 to avoid
42  * collisions with an earlier class code enum.  While we have 64 bits available
43  * to us, cmd_errcl_t's are saved in persistent buffers, and thus can't easily
44  * grow beyond that size.  As such, ereports should only be assigned class codes
45  * when needed.  NEVER CHANGE the values of these constants once assigned.
46  */
47 #ifdef sun4u
48 #define	CMD_ERRCL_UCC		0x0000000000000008ULL
49 #define	CMD_ERRCL_UCU		0x0000000000000010ULL
50 #define	CMD_ERRCL_CPC		0x0000000000000020ULL
51 #define	CMD_ERRCL_CPU		0x0000000000000040ULL
52 #define	CMD_ERRCL_WDC		0x0000000000000080ULL
53 #define	CMD_ERRCL_WDU		0x0000000000000100ULL
54 #define	CMD_ERRCL_EDC		0x0000000000000200ULL
55 #define	CMD_ERRCL_EDU_ST	0x0000000000000400ULL
56 #define	CMD_ERRCL_EDU_BL	0x0000000000000800ULL
57 #define	CMD_ERRCL_L3_UCC	0x0000000000001000ULL
58 #define	CMD_ERRCL_L3_UCU	0x0000000000002000ULL
59 #define	CMD_ERRCL_L3_CPC	0x0000000000004000ULL
60 #define	CMD_ERRCL_L3_CPU	0x0000000000008000ULL
61 #define	CMD_ERRCL_L3_WDC	0x0000000000010000ULL
62 #define	CMD_ERRCL_L3_WDU	0x0000000000020000ULL
63 #define	CMD_ERRCL_L3_EDC	0x0000000000040000ULL
64 #define	CMD_ERRCL_L3_EDU_ST	0x0000000000080000ULL
65 #define	CMD_ERRCL_L3_EDU_BL	0x0000000000100000ULL
66 #define	CMD_ERRCL_L3_MECC	0x0000000000200000ULL
67 				/* hole for sequential expansion */
68 #define	CMD_ERRCL_RCE		0x0000040000000000ULL
69 #define	CMD_ERRCL_RUE		0x0000080000000000ULL
70 #define	CMD_ERRCL_FRC		0x0000100000000000ULL
71 #define	CMD_ERRCL_FRU		0x0000200000000000ULL
72 #define	CMD_ERRCL_IOCE		0x0000400000000000ULL
73 #define	CMD_ERRCL_IOUE		0x0000800000000000ULL
74 #else /* sun4u */
75 #define	CMD_ERRCL_IL2U		0x0000000000000008ULL
76 #define	CMD_ERRCL_DL2U		0x0000000000000010ULL
77 #define	CMD_ERRCL_L2ND		0x0000000000000020ULL
78 #define	CMD_ERRCL_IL2ND		0x0000000000000040ULL
79 #define	CMD_ERRCL_DL2ND		0x0000000000000080ULL
80 #define	CMD_ERRCL_DBU		0x0000000000000100ULL
81 #define	CMD_ERRCL_FBU		0x0000000000000200ULL
82 #define	CMD_ERRCL_DCDP		0x0000000000000400ULL
83 #define	CMD_ERRCL_ICDP		0x0000000000000800ULL
84 #define	CMD_ERRCL_WBUE		0x0000000000001000ULL
85 #define	CMD_ERRCL_CBCE		0x0000000000002000ULL
86 #define	CMD_ERRCL_DAC		0x0001000000000000ULL
87 #define	CMD_ERRCL_DSC		0x0002000000000000ULL
88 #define	CMD_ERRCL_DAU		0x0004000000000000ULL
89 #define	CMD_ERRCL_DSU		0x0008000000000000ULL
90 #define	CMD_ERRCL_LDAC		0x0010000000000000ULL
91 #define	CMD_ERRCL_LDWC		0x0020000000000000ULL
92 #define	CMD_ERRCL_LDRC		0x0040000000000000ULL
93 #define	CMD_ERRCL_LDSC		0x0080000000000000ULL
94 #define	CMD_ERRCL_LDAU		0x0100000000000000ULL
95 #define	CMD_ERRCL_LDWU		0x0200000000000000ULL
96 #define	CMD_ERRCL_LDRU		0x0400000000000000ULL
97 #define	CMD_ERRCL_LDSU		0x0800000000000000ULL
98 
99 #define	CMD_ERRCL_SBDPC		0x1000000000000000ULL
100 #define	CMD_ERRCL_SBDLC		0x2000000000000000ULL
101 #define	CMD_ERRCL_TCCP		0x4000000000000000ULL
102 #define	CMD_ERRCL_TCCD		0x8000000000000000ULL
103 #endif /* sun4u */
104 
105 #ifdef sun4u
106 #define	CMD_ERRCL_ISL2XXCU(clcode) \
107 	((clcode) >= CMD_ERRCL_UCC && (clcode) <= CMD_ERRCL_EDU_BL)
108 #define	CMD_ERRCL_ISL3XXCU(clcode) \
109 	((clcode) >= CMD_ERRCL_L3_UCC && (clcode) <= CMD_ERRCL_L3_MECC)
110 
111 #define	CMD_ERRCL_ISIOXE(clcode) \
112 	(((clcode) & (CMD_ERRCL_IOCE | CMD_ERRCL_IOUE)) != 0)
113 #else /* sun4u */
114 /*
115  * If changing the CMD_ERRCL_ISL2XXCU definition, should also
116  * change all the lines below it.
117  */
118 #define	CMD_ERRCL_ISL2XXCU(clcode) \
119 	(((clcode) >= CMD_ERRCL_LDAC && (clcode) <= CMD_ERRCL_LDSU) || \
120 	((clcode) >= CMD_ERRCL_IL2U && (clcode) <= CMD_ERRCL_DL2U))
121 
122 #define	CMD_ERRCL_ISMISCREGS(clcode) \
123 	((clcode) >= CMD_ERRCL_SBDPC && (clcode) <= CMD_ERRCL_TCCD)
124 
125 #define	CMD_ERRCL_ISL2CE(clcode) \
126 	(((clcode) >= CMD_ERRCL_LDAC && (clcode) <= CMD_ERRCL_LDSC) || \
127 	(clcode == CMD_ERRCL_CBCE))
128 
129 #define	CMD_ERRCL_ISL2ND(clcode) \
130 	((clcode) >= CMD_ERRCL_L2ND && (clcode) <= CMD_ERRCL_DL2ND)
131 
132 #define	CMD_ERRCL_ISMEM(clcode) \
133 	((clcode & (CMD_ERRCL_DAU | CMD_ERRCL_DBU | CMD_ERRCL_FBU)) != 0)
134 
135 #define	CMD_ERRCL_ISDCDP(clcode) \
136 	(clcode == CMD_ERRCL_DCDP)
137 
138 #define	CMD_ERRCL_ISICDP(clcode) \
139 	(clcode == CMD_ERRCL_ICDP)
140 
141 #define	CMD_ERRCL_L2UE_WRITEBACK(clcode) \
142 	((clcode & (CMD_ERRCL_LDWU | CMD_ERRCL_WBUE)) != 0)
143 
144 #define	CMD_ERRCL_REMOTEL2(clcode) \
145 	((clcode & (CMD_ERRCL_WBUE | CMD_ERRCL_CBCE)) != 0)
146 
147 #endif /* sun4u */
148 
149 #ifdef sun4v
150 #define	L2_ERR		1
151 #define	MISCREGS_ERR	2
152 #define	L2ND_ERR	3
153 #define	MEM_ERR		4
154 #define	DCDP_ERR	5
155 #define	ICDP_ERR	6
156 #define	REMOTE_L2ERR	7
157 #define	UNKNOWN_ERR	8
158 #endif
159 
160 
161 #define	CMD_ERRCL_MATCH(clcode, mask) \
162 	(((clcode) & (mask)) != 0)
163 
164 typedef uint64_t cmd_errcl_t;
165 
166 /*
167  * Use low order 2 bits of cmd_errcl_t in order to pass cpu grouping level.
168  * The DE never shipped with code using low order 3 bits.
169  */
170 
171 #define	CMD_ERRCL_LEVEL_EXTRACT		0X0000000000000003ULL
172 #define	CMD_ERRCL_LEVEL_MASK		0XFFFFFFFFFFFFFFF8ULL
173 
174 #define	CMD_STAT_BUMP(name)		cmd.cmd_stats->name.fmds_value.ui64++
175 
176 #define	CMD_FLTMAXCONF		95	/* maximum confidence for faults */
177 
178 struct cmd_xxcu_trw;
179 
180 typedef struct cmd_stat {
181 	fmd_stat_t bad_det;		/* # of malformed detectors */
182 	fmd_stat_t bad_cpu_asru;	/* # of malformed cpu-scheme ASRUs */
183 	fmd_stat_t bad_mem_asru;	/* # of malformed mem-scheme ASRUs */
184 	fmd_stat_t bad_close;		/* # of inapplicable case closes */
185 	fmd_stat_t old_erpt;		/* # of erpts for removed components */
186 	fmd_stat_t cpu_creat;		/* # of CPU state structs created */
187 	fmd_stat_t dimm_creat;		/* # of DIMM state structs created */
188 	fmd_stat_t bank_creat;		/* # of bank state structs created */
189 	fmd_stat_t page_creat;		/* # of page state structs created */
190 	fmd_stat_t cache_creat;		/* # of cache state structs created */
191 	fmd_stat_t ce_unknown;		/* # of unknown CEs seen */
192 	fmd_stat_t ce_interm;		/* # of intermittent CEs seen */
193 	fmd_stat_t ce_ppersis;		/* # of possible persistent CEs seen */
194 	fmd_stat_t ce_persis;		/* # of persistent CEs seen */
195 	fmd_stat_t ce_leaky;		/* # of leaky CEs seen */
196 					/* # of possible sticky CEs: */
197 	fmd_stat_t ce_psticky_noptnr;		/* - no valid partner test */
198 	fmd_stat_t ce_psticky_ptnrnoerr;	/* - partner could not see CE */
199 	fmd_stat_t ce_psticky_ptnrclrd;		/* - partner could fix CE */
200 	fmd_stat_t ce_sticky;		/* # of sticky CEs seen */
201 	fmd_stat_t xxu_ue_match;	/* # of xxUs that matched in a UE $ */
202 	fmd_stat_t xxu_retr_flt;	/* # of xxUs unnecessary by fault */
203 	fmd_stat_t cpu_migrat;		/* # of CPUs migrated to new version */
204 	fmd_stat_t dimm_migrat;		/* # of DIMMs migrated to new version */
205 	fmd_stat_t bank_migrat;		/* # of banks migrated to new version */
206 #ifdef sun4u
207 	fmd_stat_t dp_ignored_ce;	/* # of CEs ignored due to DP flt/err */
208 	fmd_stat_t dp_ignored_ue;	/* # of UEs ignored due to DP fault */
209 	fmd_stat_t dp_deferred_ue;	/* # of UEs deferred due to DP error */
210 #endif
211 #ifdef sun4v
212 	fmd_stat_t branch_creat;	/* # of branch state structs created */
213 #endif
214 } cmd_stat_t;
215 
216 typedef struct cmd_serd {
217 	const char *cs_name;
218 	uint_t cs_n;
219 	hrtime_t cs_t;
220 } cmd_serd_t;
221 
222 typedef struct cmd {
223 	cmd_list_t cmd_cpus;		/* List of CPU state structures */
224 	cmd_list_t cmd_dimms;		/* List of DIMM state structures */
225 	cmd_list_t cmd_banks;		/* List of bank state structures */
226 	cmd_list_t cmd_pages;		/* List of page state structures */
227 	cmd_list_t cmd_iorxefrx;	/* List of IOxE/RxE/FRx correlation */
228 #ifdef sun4u
229 	cmd_list_t cmd_datapaths;	/* List of datapath state structures */
230 	cmd_list_t cmd_deferred_pages;	/* Pages deferred due to a DP error */
231 #endif
232 	hrtime_t cmd_iorxefrx_window;	/* Max int between IOxE/RxE/FRx pairs */
233 	cmd_stat_t *cmd_stats;		/* Module statistics */
234 	size_t cmd_pagesize;		/* Page size, in bytes */
235 	uint64_t cmd_pagemask;		/* Mask for page alignments */
236 	char cmd_ecache_dev[MAXPATHLEN]; /* Mem ctrlr drv path for E$ flush */
237 	struct cmd_xxcu_trw *cmd_xxcu_trw; /* Array of xxC/U train waiters */
238 	size_t cmd_xxcu_ntrw;		/* Number of waiters in array */
239 	hrtime_t cmd_xxcu_trdelay;	/* Delay for xxC/U redelivery */
240 	cmd_list_t cmd_xxcu_redelivs;	/* Pending xxC/U redeliveries */
241 	cmd_serd_t cmd_l2data_serd;	/* Params for L2$ SERD engine */
242 	cmd_serd_t cmd_l3data_serd;	/* Params for L3$ SERD engine */
243 	uint64_t cmd_thresh_tpct_sysmem; /* Pg ret warning thresh (% of mem) */
244 	uint64_t cmd_thresh_abs_sysmem;	/* Pg ret warning thresh (# of pages) */
245 	uint64_t cmd_thresh_abs_badrw;	/* Bad r/w retire thresh (# of pages) */
246 	cmd_serd_t cmd_miscregs_serd;   /* params for misregs serd */
247 	cmd_serd_t cmd_dcache_serd;	/* params for dcache serd */
248 	cmd_serd_t cmd_icache_serd;	/* params for icache serd */
249 	uint32_t cmd_low_ce_thresh;	/* low ce thershold */
250 	uint32_t cmd_hi_ce_thresh;	/* hi ce threshold */
251 	uint32_t cmd_dupce;		/* max 5b CEs */
252 	uint32_t cmd_nupos;		/* min number of equal upos */
253 #ifdef sun4u
254 	uint16_t cmd_dp_flag;		/* datapath error in progress if set */
255 #endif
256 #ifdef sun4v
257 	cmd_list_t cmd_branches;	/* List of branches state structures */
258 	uint64_t cmd_delta_ena;		/* the sun4v train delta ena */
259 #endif
260 	nvlist_t *cmd_auth;		/* DE's fault authority value */
261 } cmd_t;
262 
263 extern cmd_t cmd;
264 
265 extern int cmd_set_errno(int);
266 
267 extern void *cmd_buf_read(fmd_hdl_t *, fmd_case_t *, const char *, size_t);
268 extern void cmd_bufname(char *, size_t, const char *, ...);
269 extern void cmd_vbufname(char *, size_t, const char *, va_list);
270 extern nvlist_t *cmd_nvl_create_fault(fmd_hdl_t *,
271     const char *, uint8_t, nvlist_t *, nvlist_t *, nvlist_t *);
272 
273 #ifdef __cplusplus
274 }
275 #endif
276 
277 #endif /* _CMD_H */
278