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