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