xref: /titanic_41/usr/src/uts/common/sys/fm/protocol.h (revision 635216b673cf196ac523ff2a7ab715717e553292)
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 /*
23  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_SYS_FM_PROTOCOL_H
28 #define	_SYS_FM_PROTOCOL_H
29 
30 #ifdef	__cplusplus
31 extern "C" {
32 #endif
33 
34 #ifdef _KERNEL
35 #include <sys/varargs.h>
36 #include <sys/nvpair.h>
37 #else
38 #include <libnvpair.h>
39 #include <stdarg.h>
40 #endif
41 #include <sys/processor.h>
42 
43 /* FM common member names */
44 #define	FM_CLASS			"class"
45 #define	FM_VERSION			"version"
46 
47 /* FM event class values */
48 #define	FM_EREPORT_CLASS		"ereport"
49 #define	FM_FAULT_CLASS			"fault"
50 #define	FM_RSRC_CLASS			"resource"
51 #define	FM_LIST_EVENT			"list"
52 
53 /* FM list.* event class values */
54 #define	FM_LIST_SUSPECT_CLASS		FM_LIST_EVENT ".suspect"
55 #define	FM_LIST_ISOLATED_CLASS		FM_LIST_EVENT ".isolated"
56 #define	FM_LIST_REPAIRED_CLASS		FM_LIST_EVENT ".repaired"
57 #define	FM_LIST_UPDATED_CLASS		FM_LIST_EVENT ".updated"
58 #define	FM_LIST_RESOLVED_CLASS		FM_LIST_EVENT ".resolved"
59 
60 /* ereport class subcategory values */
61 #define	FM_ERROR_CPU			"cpu"
62 #define	FM_ERROR_IO			"io"
63 
64 /* ereport version and payload member names */
65 #define	FM_EREPORT_VERS0		0
66 #define	FM_EREPORT_VERSION		FM_EREPORT_VERS0
67 
68 /* ereport payload member names */
69 #define	FM_EREPORT_DETECTOR		"detector"
70 #define	FM_EREPORT_ENA			"ena"
71 
72 /* list.* event payload member names */
73 #define	FM_LIST_EVENT_SIZE		"list-sz"
74 
75 /*
76  * list.suspect, isolated, updated, repaired and resolved
77  * versions/payload member names.
78  */
79 #define	FM_SUSPECT_UUID			"uuid"
80 #define	FM_SUSPECT_DIAG_CODE		"code"
81 #define	FM_SUSPECT_DIAG_TIME		"diag-time"
82 #define	FM_SUSPECT_DE			"de"
83 #define	FM_SUSPECT_FAULT_LIST		"fault-list"
84 #define	FM_SUSPECT_FAULT_SZ		"fault-list-sz"
85 #define	FM_SUSPECT_FAULT_STATUS		"fault-status"
86 #define	FM_SUSPECT_MESSAGE		"message"
87 #define	FM_SUSPECT_RETIRE		"retire"
88 #define	FM_SUSPECT_RESPONSE		"response"
89 #define	FM_SUSPECT_SEVERITY		"severity"
90 
91 #define	FM_SUSPECT_VERS0		0
92 #define	FM_SUSPECT_VERSION		FM_SUSPECT_VERS0
93 
94 #define	FM_SUSPECT_FAULTY		0x1
95 #define	FM_SUSPECT_UNUSABLE		0x2
96 #define	FM_SUSPECT_NOT_PRESENT		0x4
97 #define	FM_SUSPECT_DEGRADED		0x8
98 #define	FM_SUSPECT_REPAIRED		0x10
99 #define	FM_SUSPECT_REPLACED		0x20
100 #define	FM_SUSPECT_ACQUITTED		0x40
101 
102 /* fault event versions and payload member names */
103 #define	FM_FAULT_VERS0			0
104 #define	FM_FAULT_VERSION		FM_FAULT_VERS0
105 
106 #define	FM_FAULT_ASRU			"asru"
107 #define	FM_FAULT_FRU			"fru"
108 #define	FM_FAULT_FRU_LABEL		"fru-label"
109 #define	FM_FAULT_CERTAINTY		"certainty"
110 #define	FM_FAULT_RESOURCE		"resource"
111 #define	FM_FAULT_LOCATION		"location"
112 
113 /* resource event versions and payload member names */
114 #define	FM_RSRC_VERS0			0
115 #define	FM_RSRC_VERSION			FM_RSRC_VERS0
116 #define	FM_RSRC_RESOURCE		"resource"
117 
118 /* resource.fm.asru.* payload member names */
119 #define	FM_RSRC_ASRU_UUID		"uuid"
120 #define	FM_RSRC_ASRU_CODE		"code"
121 #define	FM_RSRC_ASRU_FAULTY		"faulty"
122 #define	FM_RSRC_ASRU_REPAIRED		"repaired"
123 #define	FM_RSRC_ASRU_REPLACED		"replaced"
124 #define	FM_RSRC_ASRU_ACQUITTED		"acquitted"
125 #define	FM_RSRC_ASRU_RESOLVED		"resolved"
126 #define	FM_RSRC_ASRU_UNUSABLE		"unusable"
127 #define	FM_RSRC_ASRU_EVENT		"event"
128 
129 /* resource.fm.xprt.* versions and payload member names */
130 #define	FM_RSRC_XPRT_VERS0		0
131 #define	FM_RSRC_XPRT_VERSION		FM_RSRC_XPRT_VERS0
132 #define	FM_RSRC_XPRT_UUID		"uuid"
133 #define	FM_RSRC_XPRT_SUBCLASS		"subclass"
134 #define	FM_RSRC_XPRT_FAULT_STATUS	"fault-status"
135 #define	FM_RSRC_XPRT_FAULT_HAS_ASRU	"fault-has-asru"
136 
137 /*
138  * FM ENA Format Macros
139  */
140 #define	ENA_FORMAT_MASK			0x3
141 #define	ENA_FORMAT(ena)			((ena) & ENA_FORMAT_MASK)
142 
143 /* ENA format types */
144 #define	FM_ENA_FMT0			0
145 #define	FM_ENA_FMT1			1
146 #define	FM_ENA_FMT2			2
147 
148 /* Format 1 */
149 #define	ENA_FMT1_GEN_MASK		0x00000000000003FCull
150 #define	ENA_FMT1_ID_MASK		0xFFFFFFFFFFFFFC00ull
151 #define	ENA_FMT1_CPUID_MASK		0x00000000000FFC00ull
152 #define	ENA_FMT1_TIME_MASK		0xFFFFFFFFFFF00000ull
153 #define	ENA_FMT1_GEN_SHFT		2
154 #define	ENA_FMT1_ID_SHFT		10
155 #define	ENA_FMT1_CPUID_SHFT		ENA_FMT1_ID_SHFT
156 #define	ENA_FMT1_TIME_SHFT		20
157 
158 /* Format 2 */
159 #define	ENA_FMT2_GEN_MASK		0x00000000000003FCull
160 #define	ENA_FMT2_ID_MASK		0xFFFFFFFFFFFFFC00ull
161 #define	ENA_FMT2_TIME_MASK		ENA_FMT2_ID_MASK
162 #define	ENA_FMT2_GEN_SHFT		2
163 #define	ENA_FMT2_ID_SHFT		10
164 #define	ENA_FMT2_TIME_SHFT		ENA_FMT2_ID_SHFT
165 
166 /* Common FMRI type names */
167 #define	FM_FMRI_AUTHORITY		"authority"
168 #define	FM_FMRI_SCHEME			"scheme"
169 #define	FM_FMRI_SVC_AUTHORITY		"svc-authority"
170 #define	FM_FMRI_FACILITY		"facility"
171 
172 /* FMRI authority-type member names */
173 #define	FM_FMRI_AUTH_CHASSIS		"chassis-id"
174 #define	FM_FMRI_AUTH_PRODUCT_SN		"product-sn"
175 #define	FM_FMRI_AUTH_PRODUCT		"product-id"
176 #define	FM_FMRI_AUTH_DOMAIN		"domain-id"
177 #define	FM_FMRI_AUTH_SERVER		"server-id"
178 #define	FM_FMRI_AUTH_HOST		"host-id"
179 
180 #define	FM_AUTH_VERS0			0
181 #define	FM_FMRI_AUTH_VERSION		FM_AUTH_VERS0
182 
183 /* scheme name values */
184 #define	FM_FMRI_SCHEME_FMD		"fmd"
185 #define	FM_FMRI_SCHEME_DEV		"dev"
186 #define	FM_FMRI_SCHEME_HC		"hc"
187 #define	FM_FMRI_SCHEME_SVC		"svc"
188 #define	FM_FMRI_SCHEME_CPU		"cpu"
189 #define	FM_FMRI_SCHEME_MEM		"mem"
190 #define	FM_FMRI_SCHEME_MOD		"mod"
191 #define	FM_FMRI_SCHEME_PKG		"pkg"
192 #define	FM_FMRI_SCHEME_LEGACY		"legacy-hc"
193 #define	FM_FMRI_SCHEME_ZFS		"zfs"
194 
195 /* Scheme versions */
196 #define	FMD_SCHEME_VERSION0		0
197 #define	FM_FMD_SCHEME_VERSION		FMD_SCHEME_VERSION0
198 #define	DEV_SCHEME_VERSION0		0
199 #define	FM_DEV_SCHEME_VERSION		DEV_SCHEME_VERSION0
200 #define	FM_HC_VERS0			0
201 #define	FM_HC_SCHEME_VERSION		FM_HC_VERS0
202 #define	CPU_SCHEME_VERSION0		0
203 #define	CPU_SCHEME_VERSION1		1
204 #define	FM_CPU_SCHEME_VERSION		CPU_SCHEME_VERSION1
205 #define	MEM_SCHEME_VERSION0		0
206 #define	FM_MEM_SCHEME_VERSION		MEM_SCHEME_VERSION0
207 #define	MOD_SCHEME_VERSION0		0
208 #define	FM_MOD_SCHEME_VERSION		MOD_SCHEME_VERSION0
209 #define	PKG_SCHEME_VERSION0		0
210 #define	FM_PKG_SCHEME_VERSION		PKG_SCHEME_VERSION0
211 #define	LEGACY_SCHEME_VERSION0		0
212 #define	FM_LEGACY_SCHEME_VERSION	LEGACY_SCHEME_VERSION0
213 #define	SVC_SCHEME_VERSION0		0
214 #define	FM_SVC_SCHEME_VERSION		SVC_SCHEME_VERSION0
215 #define	ZFS_SCHEME_VERSION0		0
216 #define	FM_ZFS_SCHEME_VERSION		ZFS_SCHEME_VERSION0
217 
218 /* hc scheme member names */
219 #define	FM_FMRI_HC_SERIAL_ID		"serial"
220 #define	FM_FMRI_HC_PART			"part"
221 #define	FM_FMRI_HC_REVISION		"revision"
222 #define	FM_FMRI_HC_ROOT			"hc-root"
223 #define	FM_FMRI_HC_LIST_SZ		"hc-list-sz"
224 #define	FM_FMRI_HC_LIST			"hc-list"
225 #define	FM_FMRI_HC_SPECIFIC		"hc-specific"
226 
227 /* facility member names */
228 #define	FM_FMRI_FACILITY_NAME		"facility-name"
229 #define	FM_FMRI_FACILITY_TYPE		"facility-type"
230 
231 /* hc-list version and member names */
232 #define	FM_FMRI_HC_NAME			"hc-name"
233 #define	FM_FMRI_HC_ID			"hc-id"
234 
235 #define	HC_LIST_VERSION0		0
236 #define	FM_HC_LIST_VERSION		HC_LIST_VERSION0
237 
238 /* hc-specific member names */
239 #define	FM_FMRI_HC_SPECIFIC_OFFSET	"offset"
240 #define	FM_FMRI_HC_SPECIFIC_PHYSADDR	"physaddr"
241 
242 /* fmd module scheme member names */
243 #define	FM_FMRI_FMD_NAME		"mod-name"
244 #define	FM_FMRI_FMD_VERSION		"mod-version"
245 
246 /* dev scheme member names */
247 #define	FM_FMRI_DEV_ID			"devid"
248 #define	FM_FMRI_DEV_PATH		"device-path"
249 
250 /* pkg scheme member names */
251 #define	FM_FMRI_PKG_BASEDIR		"pkg-basedir"
252 #define	FM_FMRI_PKG_INST		"pkg-inst"
253 #define	FM_FMRI_PKG_VERSION		"pkg-version"
254 
255 /* svc scheme member names */
256 #define	FM_FMRI_SVC_NAME		"svc-name"
257 #define	FM_FMRI_SVC_INSTANCE		"svc-instance"
258 #define	FM_FMRI_SVC_CONTRACT_ID		"svc-contract-id"
259 
260 /* svc-authority member names */
261 #define	FM_FMRI_SVC_AUTH_SCOPE		"scope"
262 #define	FM_FMRI_SVC_AUTH_SYSTEM_FQN	"system-fqn"
263 
264 /* cpu scheme member names */
265 #define	FM_FMRI_CPU_ID			"cpuid"
266 #define	FM_FMRI_CPU_SERIAL_ID		"serial"
267 #define	FM_FMRI_CPU_MASK		"cpumask"
268 #define	FM_FMRI_CPU_VID			"cpuvid"
269 #define	FM_FMRI_CPU_CPUFRU		"cpufru"
270 #define	FM_FMRI_CPU_CACHE_INDEX		"cacheindex"
271 #define	FM_FMRI_CPU_CACHE_WAY		"cacheway"
272 #define	FM_FMRI_CPU_CACHE_BIT		"cachebit"
273 #define	FM_FMRI_CPU_CACHE_TYPE		"cachetype"
274 
275 #define	FM_FMRI_CPU_CACHE_TYPE_L2	0
276 #define	FM_FMRI_CPU_CACHE_TYPE_L3	1
277 
278 /* legacy-hc scheme member names */
279 #define	FM_FMRI_LEGACY_HC		"component"
280 #define	FM_FMRI_LEGACY_HC_PREFIX	FM_FMRI_SCHEME_HC":///" \
281     FM_FMRI_LEGACY_HC"="
282 
283 /* mem scheme member names */
284 #define	FM_FMRI_MEM_UNUM		"unum"
285 #define	FM_FMRI_MEM_SERIAL_ID		"serial"
286 #define	FM_FMRI_MEM_PHYSADDR		"physaddr"
287 #define	FM_FMRI_MEM_MEMCONFIG		"memconfig"
288 #define	FM_FMRI_MEM_OFFSET		"offset"
289 
290 /* mod scheme member names */
291 #define	FM_FMRI_MOD_PKG			"mod-pkg"
292 #define	FM_FMRI_MOD_NAME		"mod-name"
293 #define	FM_FMRI_MOD_ID			"mod-id"
294 #define	FM_FMRI_MOD_DESC		"mod-desc"
295 
296 /* zfs scheme member names */
297 #define	FM_FMRI_ZFS_POOL		"pool"
298 #define	FM_FMRI_ZFS_VDEV		"vdev"
299 
300 extern nv_alloc_t *fm_nva_xcreate(char *, size_t);
301 extern void fm_nva_xdestroy(nv_alloc_t *);
302 
303 extern nvlist_t *fm_nvlist_create(nv_alloc_t *);
304 extern void fm_nvlist_destroy(nvlist_t *, int);
305 
306 #define	FM_NVA_FREE	0		/* free allocator on nvlist_destroy */
307 #define	FM_NVA_RETAIN	1		/* keep allocator on nvlist_destroy */
308 
309 extern void fm_ereport_set(nvlist_t *, int, const char *, uint64_t,
310     const nvlist_t *, ...);
311 extern void fm_payload_set(nvlist_t *, ...);
312 extern int i_fm_payload_set(nvlist_t *, const char *, va_list);
313 extern void fm_fmri_hc_set(nvlist_t *, int, const nvlist_t *, nvlist_t *,
314     int, ...);
315 extern void fm_fmri_dev_set(nvlist_t *, int, const nvlist_t *, const char *,
316     const char *);
317 extern void fm_fmri_de_set(nvlist_t *, int, const nvlist_t *, const char *);
318 extern void fm_fmri_cpu_set(nvlist_t *, int, const nvlist_t *, uint32_t,
319     uint8_t *, const char *);
320 extern void fm_fmri_mem_set(nvlist_t *, int, const nvlist_t *, const char *,
321     const char *, uint64_t);
322 extern void fm_authority_set(nvlist_t *, int, const char *, const char *,
323     const char *, const char *);
324 extern void fm_fmri_zfs_set(nvlist_t *, int, uint64_t, uint64_t);
325 
326 extern uint64_t fm_ena_increment(uint64_t);
327 extern uint64_t fm_ena_generate(uint64_t, uchar_t);
328 extern uint64_t fm_ena_generate_cpu(uint64_t, processorid_t, uchar_t);
329 extern uint64_t fm_ena_generation_get(uint64_t);
330 extern uchar_t fm_ena_format_get(uint64_t);
331 extern uint64_t fm_ena_id_get(uint64_t);
332 extern uint64_t fm_ena_time_get(uint64_t);
333 
334 #ifdef	__cplusplus
335 }
336 #endif
337 
338 #endif /* _SYS_FM_PROTOCOL_H */
339