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