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