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