xref: /titanic_41/usr/src/cmd/fm/modules/sun4/cpumem-diagnosis/cmd_Lxcache.h (revision a62774df315360f02521d6470eab7d5080137dad)
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 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _CMD_LxCACHE_H
27 #define	_CMD_LxCACHE_H
28 
29 /*
30  * Routines for the creation of Lxcache retirement faults and for the
31  * management of Lxcache-related state.
32  */
33 
34 #include <cmd_state.h>
35 #include <cmd_cpu.h>
36 #include <cmd_fmri.h>
37 
38 #include <fm/fmd_api.h>
39 #include <sys/types.h>
40 
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
45 #define	QTCLR		1
46 #define	CMD_ANON_WAY	-1
47 #define	MAX_WAYS	8
48 #define	HUNDRED_PERCENT	100
49 #define	SUSPECT_PERCENT	50
50 
51 #define	CMD_LxCACHE_F_ACTIVE	0x0
52 #define	CMD_LxCACHE_F_FAULTING	0x1
53 #define	CMD_LxCACHE_F_RETIRED	0x2
54 #define	CMD_LxCACHE_F_UNRETIRED	0x4
55 #define	CMD_LxCACHE_F_RERETIRED	0x8
56 
57 #define	LxCACHE_MKVERSION(version)	((version) << 4 | 1)
58 
59 #define	CMD_LxCACHE_VERSION_1	LxCACHE_MKVERSION(1)	/* 17 */
60 #define	CMD_LxCACHE_VERSION	CMD_LxCACHE_VERSION_1
61 
62 #define	CMD_LxCACHE_VERSIONED(Lxcache)	((Lxcache)->Lxcache_version & 1)
63 
64 #define	MAX_FMRI_LEN	128
65 
66 #define	IS_TAG(type)	((type == CMD_PTR_CPU_L2TAG) ||\
67 			    (type == CMD_PTR_CPU_L3TAG))
68 
69 typedef struct cmd_Lxcache_pers {
70 	cmd_header_t Lxcachep_header;	/* Nodetype must be CMD_NT_LxCACHE */
71 	/*
72 	 * We need the cpu_hdr_bufname  in order to restore the Lxcache.
73 	 */
74 	char Lxcachep_cpu_hdr_bufname[CMD_BUFNMLEN];
75 	uint_t Lxcachep_version;
76 	cmd_fmri_t Lxcachep_asru;	/* ASRU for this LxCACHE */
77 	char	Lxcachep_retired_fmri[MAX_FMRI_LEN];
78 	cmd_ptrsubtype_t Lxcachep_type;	/* L2 or L3 */
79 	uint32_t Lxcachep_index;	/* cache index Lxcache represents */
80 	uint32_t Lxcachep_way;		/* cache way this Lxcache represents */
81 	uint16_t Lxcachep_bit;		/* bit in Lxcache that has fault */
82 	uint_t Lxcachep_flags;		/* CMD_MEM_F_* */
83 	uint_t	Lxreason;		/* Suspicion or convicted */
84 } cmd_Lxcache_pers_t;
85 
86 #define	CMD_LXFUNCTIONING	0	/* Initial value */
87 #define	CMD_LXSUSPICIOUS	0x1
88 #define	CMD_LXSUSPECT_DATA	0x1
89 #define	CMD_LXCONVICTED		0x2
90 #define	CMD_LXSUSPECT_0_TAG	0x4
91 #define	CMD_LXSUSPECT_1_TAG	0x8
92 #define	CMD_LXSUSPICIOUS_BY_ASSOCIATION		0x10
93 #define	CMD_LXCONVICTED_BY_ASSOCIATION		0x20
94 
95 typedef struct cmd_Lxcache {
96 	cmd_Lxcache_pers_t Lxcache_pers;
97 	int	Lxcache_retry_count;	/* retry count for recheck taga */
98 	id_t	Lxcache_timeout_id;
99 	cmd_errcl_t	Lxcache_clcode;
100 	char	*Lxcache_class;
101 	fmd_event_t	*Lxcache_ep;
102 	nvlist_t	*Lxcache_nvl;
103 	char	*Lxcache_serdnm;	/* SERD to hold the ep during */
104 					/* recheck of tags */
105 	cmd_case_t Lxcache_case;	/* Open CE case against this Lxcache */
106 	cmd_xr_t	*xr;		/* The associated XR struct */
107 } cmd_Lxcache_t;
108 
109 #define	Lxcache_header		Lxcache_pers.Lxcachep_header
110 #define	Lxcache_nodetype	Lxcache_pers.Lxcachep_header.hdr_nodetype
111 #define	Lxcache_bufname		Lxcache_pers.Lxcachep_header.hdr_bufname
112 #define	Lxcache_cpu_bufname	Lxcache_pers.Lxcachep_cpu_hdr_bufname
113 #define	Lxcache_version		Lxcache_pers.Lxcachep_version
114 #define	Lxcache_asru		Lxcache_pers.Lxcachep_asru
115 #define	Lxcache_asru_nvl	Lxcache_pers.Lxcachep_asru.fmri_nvl
116 #define	Lxcache_flags		Lxcache_pers.Lxcachep_flags
117 #define	Lxcache_type		Lxcache_pers.Lxcachep_type
118 #define	Lxcache_index		Lxcache_pers.Lxcachep_index
119 #define	Lxcache_way		Lxcache_pers.Lxcachep_way
120 #define	Lxcache_bit		Lxcache_pers.Lxcachep_bit
121 #define	Lxcache_retired_fmri	Lxcache_pers.Lxcachep_retired_fmri
122 #define	Lxcache_reason		Lxcache_pers.Lxreason
123 #define	Lxcache_list		Lxcache_header.hdr_list
124 
125 /*
126  * Lxcache retirement
127  *
128  * When a Lxcache is to be retired, these routines are called to generate and
129  * manage a fault.memory.Lxcache against the Lxcache.
130  */
131 #ifdef sun4u
132 extern int cmd_cache_ce_panther(fmd_hdl_t *, fmd_event_t *, cmd_xr_t *);
133 extern int cmd_xr_pn_cache_fill(fmd_hdl_t *, nvlist_t *, cmd_xr_t *,
134     cmd_cpu_t *, cmd_errcl_t);
135 #endif
136 extern cmd_evdisp_t cmd_us4plus_tag_err(fmd_hdl_t *, fmd_event_t *, nvlist_t *,
137 	cmd_cpu_t *, cmd_ptrsubtype_t,
138 	const char *, const char *, const char *, cmd_errcl_t);
139 extern void cmd_Lxcache_close(fmd_hdl_t *, void *);
140 extern void cmd_Lxcache_write(fmd_hdl_t *, cmd_Lxcache_t *);
141 
142 extern cmd_Lxcache_t *cmd_Lxcache_create(fmd_hdl_t *,  cmd_xr_t *xr,
143     cmd_cpu_t *, nvlist_t *, cmd_ptrsubtype_t, int32_t, int8_t, int16_t);
144 
145 extern cmd_Lxcache_t *cmd_Lxcache_lookup_by_type_index_way_bit(cmd_cpu_t *,
146 	cmd_ptrsubtype_t, int32_t, int8_t, int16_t);
147 
148 extern cmd_Lxcache_t *
149 cmd_Lxcache_lookup_by_index_way(cmd_cpu_t *, cmd_ptrsubtype_t,
150 	int32_t, int8_t);
151 extern cmd_Lxcache_t *
152 cmd_Lxcache_lookup_by_type_index_way_reason(cmd_cpu_t *, cmd_ptrsubtype_t,
153 	int32_t, int8_t, int32_t);
154 extern cmd_Lxcache_t *
155 cmd_Lxcache_lookup_by_type_index_bit_reason(cmd_cpu_t *, cmd_ptrsubtype_t,
156 	int32_t, int16_t, int32_t);
157 extern int8_t cmd_Lxcache_get_next_retirable_way(cmd_cpu_t *, int32_t,
158 	cmd_ptrsubtype_t, int8_t);
159 extern int8_t cmd_Lxcache_get_lowest_retirable_way(cmd_cpu_t *,
160 	int32_t, cmd_ptrsubtype_t);
161 extern void cmd_Lxcache_destroy_anonymous_serd_engines(fmd_hdl_t *,
162 	cmd_cpu_t *, cmd_ptrsubtype_t, int32_t, int16_t);
163 extern const char *cmd_type_to_str(cmd_ptrsubtype_t);
164 extern const char *cmd_reason_to_str(int);
165 extern const char *cmd_flags_to_str(int);
166 extern boolean_t cmd_Lxcache_unretire(fmd_hdl_t *, cmd_cpu_t *,
167 	cmd_Lxcache_t *, const char *);
168 extern boolean_t cmd_Lxcache_retire(fmd_hdl_t *, cmd_cpu_t *,
169 	cmd_Lxcache_t *, const char *, uint_t);
170 extern int cmd_Lx_repair_rsrc(fmd_hdl_t *, nvlist_t *);
171 extern ssize_t cmd_fmri_nvl2str(fmd_hdl_t *hdl, nvlist_t *nvl, char *,
172 	size_t);
173 extern void cmd_Lxcache_dirty(fmd_hdl_t *, cmd_Lxcache_t *);
174 extern void *cmd_Lxcache_restore(fmd_hdl_t *, fmd_case_t *, cmd_case_ptr_t *);
175 extern void cmd_Lxcache_validate(fmd_hdl_t *, cmd_cpu_t *);
176 extern void cmd_Lxcache_destroy(fmd_hdl_t *, cmd_cpu_t *, cmd_Lxcache_t *);
177 extern void cmd_Lxcache_free(fmd_hdl_t *, cmd_cpu_t *, cmd_Lxcache_t *, int);
178 extern void cmd_Lxcache_fini(fmd_hdl_t *, cmd_cpu_t *);
179 extern char *cmd_Lxcache_serdnm_create(fmd_hdl_t *, uint32_t, cmd_ptrsubtype_t,
180 				int32_t, int8_t, int16_t);
181 extern char *cmd_Lxcache_anonymous_serdnm_create(fmd_hdl_t *, uint32_t,
182 		cmd_ptrsubtype_t, int32_t, int8_t, int16_t);
183 extern void cmd_Lxcache_gc(fmd_hdl_t *);
184 extern void cmd_Lxcache_fault(fmd_hdl_t *, cmd_cpu_t *, cmd_Lxcache_t *,
185 				const char *, nvlist_t *, uint_t);
186 extern cmd_evdisp_t get_tagdata(cmd_cpu_t *, cmd_ptrsubtype_t,
187     int32_t, uint64_t *);
188 
189 extern int get_cpu_retired_ways(cmd_cpu_t *, cmd_ptrsubtype_t);
190 extern int get_index_retired_ways(cmd_cpu_t *, cmd_ptrsubtype_t, int32_t);
191 extern int is_index_way_retired(cmd_cpu_t *, cmd_ptrsubtype_t, int32_t,
192     int8_t);
193 extern void cmd_fault_the_cpu(fmd_hdl_t *, cmd_cpu_t *, cmd_ptrsubtype_t,
194 	    const char *);
195 extern uint32_t cmd_Lx_index_count_type1_ways(cmd_cpu_t *);
196 extern uint32_t cmd_Lx_index_count_type2_ways(cmd_cpu_t *);
197 extern void cmd_Lxcache_anonymous_tag_error_timeout(fmd_hdl_t *, id_t);
198 extern cmd_Lxcache_t *cmd_Lxcache_lookup_by_timeout_id(id_t);
199 extern boolean_t cmd_create_case_for_Lxcache(fmd_hdl_t *, cmd_cpu_t *,
200 	cmd_Lxcache_t *);
201 extern int test_mode;
202 #ifdef __cplusplus
203 }
204 #endif
205 
206 #endif /* _CMD_LxCACHE_H */
207