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.
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.
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]
23 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #ifndef _SYS_FM_PROTOCOL_H
28 #define _SYS_FM_PROTOCOL_H
30 #pragma ident "%Z%%M% %I% %E% SMI"
37 #include <sys/varargs.h>
38 #include <sys/nvpair.h>
40 #include <libnvpair.h>
44 /* FM common member names */
45 #define FM_CLASS "class"
46 #define FM_VERSION "version"
48 /* FM event class values */
49 #define FM_EREPORT_CLASS "ereport"
50 #define FM_FAULT_CLASS "fault"
51 #define FM_RSRC_CLASS "resource"
52 #define FM_LIST_EVENT "list"
54 /* FM list.* event class values */
55 #define FM_LIST_SUSPECT_CLASS FM_LIST_EVENT ".suspect"
56 #define FM_LIST_ISOLATED_CLASS FM_LIST_EVENT ".isolated"
57 #define FM_LIST_REPAIRED_CLASS FM_LIST_EVENT ".repaired"
59 /* ereport class subcategory values */
60 #define FM_ERROR_CPU "cpu"
61 #define FM_ERROR_IO "io"
63 /* ereport version and payload member names */
64 #define FM_EREPORT_VERS0 0
65 #define FM_EREPORT_VERSION FM_EREPORT_VERS0
67 /* ereport payload member names */
68 #define FM_EREPORT_DETECTOR "detector"
69 #define FM_EREPORT_ENA "ena"
71 /* list.* event payload member names */
72 #define FM_LIST_EVENT_SIZE "list-sz"
74 /* list.suspect, isolated, and repaired versions and payload member names */
75 #define FM_SUSPECT_UUID "uuid"
76 #define FM_SUSPECT_DIAG_CODE "code"
77 #define FM_SUSPECT_DIAG_TIME "diag-time"
78 #define FM_SUSPECT_DE "de"
79 #define FM_SUSPECT_FAULT_LIST "fault-list"
80 #define FM_SUSPECT_FAULT_SZ "fault-list-sz"
81 #define FM_SUSPECT_FAULT_STATUS "fault-status"
82 #define FM_SUSPECT_MESSAGE "message"
84 #define FM_SUSPECT_VERS0 0
85 #define FM_SUSPECT_VERSION FM_SUSPECT_VERS0
87 /* fault event versions and payload member names */
88 #define FM_FAULT_VERS0 0
89 #define FM_FAULT_VERSION FM_FAULT_VERS0
91 #define FM_FAULT_ASRU "asru"
92 #define FM_FAULT_FRU "fru"
93 #define FM_FAULT_FRU_LABEL "fru-label"
94 #define FM_FAULT_CERTAINTY "certainty"
95 #define FM_FAULT_RESOURCE "resource"
96 #define FM_FAULT_LOCATION "location"
98 /* resource event versions and payload member names */
99 #define FM_RSRC_VERS0 0
100 #define FM_RSRC_VERSION FM_RSRC_VERS0
101 #define FM_RSRC_RESOURCE "resource"
103 /* resource.fm.asru.* payload member names */
104 #define FM_RSRC_ASRU_UUID "uuid"
105 #define FM_RSRC_ASRU_CODE "code"
106 #define FM_RSRC_ASRU_FAULTY "faulty"
107 #define FM_RSRC_ASRU_UNUSABLE "unusable"
108 #define FM_RSRC_ASRU_EVENT "event"
110 /* resource.fm.xprt.* versions and payload member names */
111 #define FM_RSRC_XPRT_VERS0 0
112 #define FM_RSRC_XPRT_VERSION FM_RSRC_XPRT_VERS0
113 #define FM_RSRC_XPRT_UUID "uuid"
114 #define FM_RSRC_XPRT_SUBCLASS "subclass"
117 * FM ENA Format Macros
119 #define ENA_FORMAT_MASK 0x3
120 #define ENA_FORMAT(ena) ((ena) & ENA_FORMAT_MASK)
122 /* ENA format types */
123 #define FM_ENA_FMT0 0
124 #define FM_ENA_FMT1 1
125 #define FM_ENA_FMT2 2
128 #define ENA_FMT1_GEN_MASK 0x00000000000003FCull
129 #define ENA_FMT1_ID_MASK 0xFFFFFFFFFFFFFC00ull
130 #define ENA_FMT1_CPUID_MASK 0x00000000000FFC00ull
131 #define ENA_FMT1_TIME_MASK 0xFFFFFFFFFFF00000ull
132 #define ENA_FMT1_GEN_SHFT 2
133 #define ENA_FMT1_ID_SHFT 10
134 #define ENA_FMT1_CPUID_SHFT ENA_FMT1_ID_SHFT
135 #define ENA_FMT1_TIME_SHFT 20
138 #define ENA_FMT2_GEN_MASK 0x00000000000003FCull
139 #define ENA_FMT2_ID_MASK 0xFFFFFFFFFFFFFC00ull
140 #define ENA_FMT2_TIME_MASK ENA_FMT2_ID_MASK
141 #define ENA_FMT2_GEN_SHFT 2
142 #define ENA_FMT2_ID_SHFT 10
143 #define ENA_FMT2_TIME_SHFT ENA_FMT2_ID_SHFT
145 /* Common FMRI type names */
146 #define FM_FMRI_AUTHORITY "authority"
147 #define FM_FMRI_SCHEME "scheme"
148 #define FM_FMRI_SVC_AUTHORITY "svc-authority"
150 /* FMRI authority-type member names */
151 #define FM_FMRI_AUTH_CHASSIS "chassis-id"
152 #define FM_FMRI_AUTH_PRODUCT "product-id"
153 #define FM_FMRI_AUTH_DOMAIN "domain-id"
154 #define FM_FMRI_AUTH_SERVER "server-id"
155 #define FM_FMRI_AUTH_HOST "host-id"
157 #define FM_AUTH_VERS0 0
158 #define FM_FMRI_AUTH_VERSION FM_AUTH_VERS0
160 /* scheme name values */
161 #define FM_FMRI_SCHEME_FMD "fmd"
162 #define FM_FMRI_SCHEME_DEV "dev"
163 #define FM_FMRI_SCHEME_HC "hc"
164 #define FM_FMRI_SCHEME_SVC "svc"
165 #define FM_FMRI_SCHEME_CPU "cpu"
166 #define FM_FMRI_SCHEME_MEM "mem"
167 #define FM_FMRI_SCHEME_MOD "mod"
168 #define FM_FMRI_SCHEME_PKG "pkg"
169 #define FM_FMRI_SCHEME_LEGACY "legacy-hc"
170 #define FM_FMRI_SCHEME_ZFS "zfs"
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 #define ZFS_SCHEME_VERSION0 0
191 #define FM_ZFS_SCHEME_VERSION ZFS_SCHEME_VERSION0
193 /* hc scheme member names */
194 #define FM_FMRI_HC_SERIAL_ID "serial"
195 #define FM_FMRI_HC_PART "part"
196 #define FM_FMRI_HC_REVISION "revision"
197 #define FM_FMRI_HC_ROOT "hc-root"
198 #define FM_FMRI_HC_LIST_SZ "hc-list-sz"
199 #define FM_FMRI_HC_LIST "hc-list"
200 #define FM_FMRI_HC_SPECIFIC "hc-specific"
202 /* hc-list version and member names */
203 #define FM_FMRI_HC_NAME "hc-name"
204 #define FM_FMRI_HC_ID "hc-id"
206 #define HC_LIST_VERSION0 0
207 #define FM_HC_LIST_VERSION HC_LIST_VERSION0
209 /* hc-specific member names */
210 #define FM_FMRI_HC_SPECIFIC_OFFSET "offset"
212 /* fmd module scheme member names */
213 #define FM_FMRI_FMD_NAME "mod-name"
214 #define FM_FMRI_FMD_VERSION "mod-version"
216 /* dev scheme member names */
217 #define FM_FMRI_DEV_ID "devid"
218 #define FM_FMRI_DEV_PATH "device-path"
220 /* pkg scheme member names */
221 #define FM_FMRI_PKG_BASEDIR "pkg-basedir"
222 #define FM_FMRI_PKG_INST "pkg-inst"
223 #define FM_FMRI_PKG_VERSION "pkg-version"
225 /* svc scheme member names */
226 #define FM_FMRI_SVC_NAME "service-name"
227 #define FM_FMRI_SVC_VERSION "service-version"
228 #define FM_FMRI_SVC_INSTANCE "instance"
229 #define FM_FMRI_SVC_CONTRACT_ID "contract-id"
231 /* svc-authority member names */
232 #define FM_FMRI_SVC_AUTH_SCOPE "scope"
233 #define FM_FMRI_SVC_AUTH_SYSTEM_FQN "system-FQN"
235 /* cpu scheme member names */
236 #define FM_FMRI_CPU_ID "cpuid"
237 #define FM_FMRI_CPU_SERIAL_ID "serial"
238 #define FM_FMRI_CPU_MASK "cpumask"
239 #define FM_FMRI_CPU_VID "cpuvid"
240 #define FM_FMRI_CPU_CPUFRU "cpufru"
242 /* legacy-hc scheme member names */
243 #define FM_FMRI_LEGACY_HC "component"
244 #define FM_FMRI_LEGACY_HC_PREFIX FM_FMRI_SCHEME_HC":///" \
247 /* mem scheme member names */
248 #define FM_FMRI_MEM_UNUM "unum"
249 #define FM_FMRI_MEM_SERIAL_ID "serial"
250 #define FM_FMRI_MEM_PHYSADDR "physaddr"
251 #define FM_FMRI_MEM_MEMCONFIG "memconfig"
252 #define FM_FMRI_MEM_OFFSET "offset"
254 /* mod scheme member names */
255 #define FM_FMRI_MOD_PKG "mod-pkg"
256 #define FM_FMRI_MOD_NAME "mod-name"
257 #define FM_FMRI_MOD_ID "mod-id"
258 #define FM_FMRI_MOD_DESC "mod-desc"
260 /* zfs scheme member names */
261 #define FM_FMRI_ZFS_POOL "pool"
262 #define FM_FMRI_ZFS_VDEV "vdev"
264 extern nv_alloc_t *fm_nva_xcreate(char *, size_t);
265 extern void fm_nva_xdestroy(nv_alloc_t *);
267 extern nvlist_t *fm_nvlist_create(nv_alloc_t *);
268 extern void fm_nvlist_destroy(nvlist_t *, int);
270 #define FM_NVA_FREE 0 /* free allocator on nvlist_destroy */
271 #define FM_NVA_RETAIN 1 /* keep allocator on nvlist_destroy */
273 extern void fm_ereport_set(nvlist_t *, int, const char *, uint64_t,
274 const nvlist_t *, ...);
275 extern void fm_payload_set(nvlist_t *, ...);
276 extern int i_fm_payload_set(nvlist_t *, const char *, va_list);
277 extern void fm_fmri_hc_set(nvlist_t *, int, const nvlist_t *, nvlist_t *,
279 extern void fm_fmri_dev_set(nvlist_t *, int, const nvlist_t *, const char *,
281 extern void fm_fmri_de_set(nvlist_t *, int, const nvlist_t *, const char *);
282 extern void fm_fmri_cpu_set(nvlist_t *, int, const nvlist_t *, uint32_t,
283 uint8_t *, const char *);
284 extern void fm_fmri_mem_set(nvlist_t *, int, const nvlist_t *, const char *,
285 const char *, uint64_t);
286 extern void fm_authority_set(nvlist_t *, int, const char *, const char *,
287 const char *, const char *);
288 extern void fm_fmri_zfs_set(nvlist_t *, int, uint64_t, uint64_t);
290 extern uint64_t fm_ena_increment(uint64_t);
291 extern uint64_t fm_ena_generate(uint64_t, uchar_t);
292 extern uint64_t fm_ena_generation_get(uint64_t);
293 extern uchar_t fm_ena_format_get(uint64_t);
294 extern uint64_t fm_ena_id_get(uint64_t);
295 extern uint64_t fm_ena_time_get(uint64_t);
301 #endif /* _SYS_FM_PROTOCOL_H */