xref: /titanic_44/usr/src/cmd/fm/modules/sun4/cpumem-diagnosis/cmd.h (revision 5ebc22727c394636ca1111875be60eb4705d818f)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _CMD_H
28 #define	_CMD_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <stdarg.h>
33 #include <fm/fmd_api.h>
34 #include <sys/param.h>
35 
36 #include <cmd_list.h>
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
42 /*
43  * Diagnosis of certain errors requires that either a) the type of ereport be
44  * recorded in a persistent buffer or b) that a single value be used to
45  * represent multiple ereport classes.  We start the values at 0x8 to avoid
46  * collisions with an earlier class code enum.  While we have 64 bits available
47  * to us, cmd_errcl_t's are saved in persistent buffers, and thus can't easily
48  * grow beyond that size.  As such, ereports should only be assigned class codes
49  * when needed.
50  */
51 #define	CMD_ERRCL_UCC		0x0000000000000008ULL
52 #define	CMD_ERRCL_UCU		0x0000000000000010ULL
53 #define	CMD_ERRCL_CPC		0x0000000000000020ULL
54 #define	CMD_ERRCL_CPU		0x0000000000000040ULL
55 #define	CMD_ERRCL_WDC		0x0000000000000080ULL
56 #define	CMD_ERRCL_WDU		0x0000000000000100ULL
57 #define	CMD_ERRCL_EDC		0x0000000000000200ULL
58 #define	CMD_ERRCL_EDU_ST	0x0000000000000400ULL
59 #define	CMD_ERRCL_EDU_BL	0x0000000000000800ULL
60 #define	CMD_ERRCL_L3_UCC	0x0000000000001000ULL
61 #define	CMD_ERRCL_L3_UCU	0x0000000000002000ULL
62 #define	CMD_ERRCL_L3_CPC	0x0000000000004000ULL
63 #define	CMD_ERRCL_L3_CPU	0x0000000000008000ULL
64 #define	CMD_ERRCL_L3_WDC	0x0000000000010000ULL
65 #define	CMD_ERRCL_L3_WDU	0x0000000000020000ULL
66 #define	CMD_ERRCL_L3_EDC	0x0000000000040000ULL
67 #define	CMD_ERRCL_L3_EDU_ST	0x0000000000080000ULL
68 #define	CMD_ERRCL_L3_EDU_BL	0x0000000000100000ULL
69 #define	CMD_ERRCL_L3_MECC	0x0000000000200000ULL
70 				/* hole for sequential expansion */
71 #define	CMD_ERRCL_RCE		0x0000040000000000ULL
72 #define	CMD_ERRCL_RUE		0x0000080000000000ULL
73 #define	CMD_ERRCL_FRC		0x0000100000000000ULL
74 #define	CMD_ERRCL_FRU		0x0000200000000000ULL
75 #define	CMD_ERRCL_IOCE		0x0000400000000000ULL
76 #define	CMD_ERRCL_IOUE		0x0000800000000000ULL
77 #define	CMD_ERRCL_DAC		0x0001000000000000ULL
78 #define	CMD_ERRCL_DSC		0x0002000000000000ULL
79 #define	CMD_ERRCL_DAU		0x0004000000000000ULL
80 #define	CMD_ERRCL_DSU		0x0008000000000000ULL
81 
82 #define	CMD_ERRCL_ISL2XXCU(clcode) \
83 	((clcode) >= CMD_ERRCL_UCC && (clcode) <= CMD_ERRCL_EDU_BL)
84 #define	CMD_ERRCL_ISL3XXCU(clcode) \
85 	((clcode) >= CMD_ERRCL_L3_UCC && (clcode) <= CMD_ERRCL_L3_MECC)
86 
87 #define	CMD_ERRCL_ISIOXE(clcode) \
88 	(((clcode) & (CMD_ERRCL_IOCE | CMD_ERRCL_IOUE)) != 0)
89 
90 #define	CMD_ERRCL_MATCH(clcode, mask) \
91 	(((clcode) & (mask)) != 0)
92 
93 typedef uint64_t cmd_errcl_t;
94 
95 #define	CMD_STAT_BUMP(name)		cmd.cmd_stats->name.fmds_value.ui64++
96 
97 #define	CMD_FLTMAXCONF		95	/* maximum confidence for faults */
98 
99 struct cmd_xxcu_trw;
100 
101 typedef struct cmd_stat {
102 	fmd_stat_t bad_det;		/* # of malformed detectors */
103 	fmd_stat_t bad_cpu_asru;	/* # of malformed cpu-scheme ASRUs */
104 	fmd_stat_t bad_mem_asru;	/* # of malformed mem-scheme ASRUs */
105 	fmd_stat_t bad_close;		/* # of inapplicable case closes */
106 	fmd_stat_t old_erpt;		/* # of erpts for removed components */
107 	fmd_stat_t cpu_creat;		/* # of CPU state structs created */
108 	fmd_stat_t dimm_creat;		/* # of DIMM state structs created */
109 	fmd_stat_t bank_creat;		/* # of bank state structs created */
110 	fmd_stat_t page_creat;		/* # of page state structs created */
111 	fmd_stat_t ce_unknown;		/* # of unknown CEs seen */
112 	fmd_stat_t ce_interm;		/* # of intermittent CEs seen */
113 	fmd_stat_t ce_ppersis;		/* # of possible persistent CEs seen */
114 	fmd_stat_t ce_persis;		/* # of persistent CEs seen */
115 	fmd_stat_t ce_leaky;		/* # of leaky CEs seen */
116 					/* # of possible sticky CEs: */
117 	fmd_stat_t ce_psticky_noptnr;		/* - no valid partner test */
118 	fmd_stat_t ce_psticky_ptnrnoerr;	/* - partner could not see CE */
119 	fmd_stat_t ce_psticky_ptnrclrd;		/* - partner could fix CE */
120 	fmd_stat_t ce_sticky;		/* # of sticky CEs seen */
121 	fmd_stat_t xxu_ue_match;	/* # of xxUs that matched in a UE $ */
122 	fmd_stat_t xxu_retr_flt;	/* # of xxUs unnecessary by fault */
123 	fmd_stat_t cpu_migrat;		/* # of CPUs migrated to new version */
124 	fmd_stat_t dimm_migrat;		/* # of DIMMs migrated to new version */
125 	fmd_stat_t bank_migrat;		/* # of banks migrated to new version */
126 } cmd_stat_t;
127 
128 typedef struct cmd_serd {
129 	const char *cs_name;
130 	uint_t cs_n;
131 	hrtime_t cs_t;
132 } cmd_serd_t;
133 
134 typedef struct cmd {
135 	cmd_list_t cmd_cpus;		/* List of CPU state structures */
136 	cmd_list_t cmd_dimms;		/* List of DIMM state structures */
137 	cmd_list_t cmd_banks;		/* List of bank state structures */
138 	cmd_list_t cmd_pages;		/* List of page state structures */
139 	cmd_list_t cmd_iorxefrx;	/* List of IOxE/RxE/FRx correlation */
140 	hrtime_t cmd_iorxefrx_window;	/* Max int between IOxE/RxE/FRx pairs */
141 	cmd_stat_t *cmd_stats;		/* Module statistics */
142 	size_t cmd_pagesize;		/* Page size, in bytes */
143 	uint64_t cmd_pagemask;		/* Mask for page alignments */
144 	char cmd_ecache_dev[MAXPATHLEN]; /* Mem ctrlr drv path for E$ flush */
145 	struct cmd_xxcu_trw *cmd_xxcu_trw; /* Array of xxC/U train waiters */
146 	size_t cmd_xxcu_ntrw;		/* Number of waiters in array */
147 	hrtime_t cmd_xxcu_trdelay;	/* Delay for xxC/U redelivery */
148 	cmd_list_t cmd_xxcu_redelivs;	/* Pending xxC/U redeliveries */
149 	cmd_serd_t cmd_l2data_serd;	/* Params for L2$ SERD engine */
150 	cmd_serd_t cmd_l3data_serd;	/* Params for L3$ SERD engine */
151 	uint64_t cmd_thresh_tpct_sysmem; /* Pg ret warning thresh (% of mem) */
152 	uint64_t cmd_thresh_abs_sysmem;	/* Pg ret warning thresh (# of pages) */
153 	uint64_t cmd_thresh_abs_badrw;	/* Bad r/w retire thresh (# of pages) */
154 } cmd_t;
155 
156 extern cmd_t cmd;
157 
158 extern int cmd_set_errno(int);
159 
160 extern void *cmd_buf_read(fmd_hdl_t *, fmd_case_t *, const char *, size_t);
161 extern void cmd_bufname(char *, size_t, const char *, ...);
162 extern void cmd_vbufname(char *, size_t, const char *, va_list);
163 
164 #ifdef __cplusplus
165 }
166 #endif
167 
168 #endif /* _CMD_H */
169