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