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