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 * Copyright 2005 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 #define FM_LIST_SUSPECT_CLASS FM_LIST_EVENT ".suspect" 55 56 /* ereport class subcategory values */ 57 #define FM_ERROR_CPU "cpu" 58 #define FM_ERROR_IO "io" 59 60 /* ereport version and payload member names */ 61 #define FM_EREPORT_VERS0 0 62 #define FM_EREPORT_VERSION FM_EREPORT_VERS0 63 64 /* ereport payload member names */ 65 #define FM_EREPORT_DETECTOR "detector" 66 #define FM_EREPORT_ENA "ena" 67 68 /* list event payload member names */ 69 #define FM_LIST_EVENT_SIZE "list-sz" 70 71 /* list.suspect versions and payload member names */ 72 #define FM_SUSPECT_UUID "uuid" 73 #define FM_SUSPECT_DIAG_CODE "code" 74 #define FM_SUSPECT_DIAG_TIME "diag-time" 75 #define FM_SUSPECT_DE "de" 76 #define FM_SUSPECT_FAULT_LIST "fault-list" 77 #define FM_SUSPECT_FAULT_SZ "fault-list-sz" 78 #define FM_SUSPECT_MESSAGE "message" 79 80 #define FM_SUSPECT_VERS0 0 81 #define FM_SUSPECT_VERSION FM_SUSPECT_VERS0 82 83 /* fault event versions and payload member names */ 84 #define FM_FAULT_VERS0 0 85 #define FM_FAULT_VERSION FM_FAULT_VERS0 86 87 #define FM_FAULT_ASRU "asru" 88 #define FM_FAULT_FRU "fru" 89 #define FM_FAULT_FRU_LABEL "fru-label" 90 #define FM_FAULT_CERTAINTY "certainty" 91 #define FM_FAULT_RESOURCE "resource" 92 93 /* resource event versions and payload member names */ 94 #define FM_RSRC_VERS0 0 95 #define FM_RSRC_VERSION FM_RSRC_VERS0 96 #define FM_RSRC_RESOURCE "resource" 97 98 /* resource.*.asru.* payload member names */ 99 #define FM_RSRC_ASRU_UUID "uuid" 100 #define FM_RSRC_ASRU_FAULTY "faulty" 101 #define FM_RSRC_ASRU_UNUSABLE "unusable" 102 #define FM_RSRC_ASRU_EVENT "event" 103 104 /* 105 * FM ENA Format Macros 106 */ 107 #define ENA_FORMAT_MASK 0x3 108 #define ENA_FORMAT(ena) ((ena) & ENA_FORMAT_MASK) 109 110 /* ENA format types */ 111 #define FM_ENA_FMT0 0 112 #define FM_ENA_FMT1 1 113 #define FM_ENA_FMT2 2 114 115 /* Format 1 */ 116 #define ENA_FMT1_GEN_MASK 0x00000000000003FCull 117 #define ENA_FMT1_ID_MASK 0xFFFFFFFFFFFFFC00ull 118 #define ENA_FMT1_CPUID_MASK 0x00000000000FFC00ull 119 #define ENA_FMT1_TIME_MASK 0xFFFFFFFFFFF00000ull 120 #define ENA_FMT1_GEN_SHFT 2 121 #define ENA_FMT1_ID_SHFT 10 122 #define ENA_FMT1_CPUID_SHFT ENA_FMT1_ID_SHFT 123 #define ENA_FMT1_TIME_SHFT 20 124 125 /* Format 2 */ 126 #define ENA_FMT2_GEN_MASK 0x00000000000003FCull 127 #define ENA_FMT2_ID_MASK 0xFFFFFFFFFFFFFC00ull 128 #define ENA_FMT2_TIME_MASK ENA_FMT2_ID_MASK 129 #define ENA_FMT2_GEN_SHFT 2 130 #define ENA_FMT2_ID_SHFT 10 131 #define ENA_FMT2_TIME_SHFT ENA_FMT2_ID_SHFT 132 133 /* Common FMRI type names */ 134 #define FM_FMRI_AUTHORITY "authority" 135 #define FM_FMRI_SCHEME "scheme" 136 #define FM_FMRI_SVC_AUTHORITY "svc-authority" 137 138 /* FMRI authority-type member names */ 139 #define FM_FMRI_AUTH_CHASSIS "chassis-id" 140 #define FM_FMRI_AUTH_PRODUCT "product-id" 141 #define FM_FMRI_AUTH_DOMAIN "domain-id" 142 #define FM_FMRI_AUTH_SERVER "server-id" 143 #define FM_FMRI_AUTH_HOST "host-id" 144 145 #define FM_AUTH_VERS0 0 146 #define FM_FMRI_AUTH_VERSION FM_AUTH_VERS0 147 148 /* scheme name values */ 149 #define FM_FMRI_SCHEME_FMD "fmd" 150 #define FM_FMRI_SCHEME_DEV "dev" 151 #define FM_FMRI_SCHEME_HC "hc" 152 #define FM_FMRI_SCHEME_SVC "svc" 153 #define FM_FMRI_SCHEME_CPU "cpu" 154 #define FM_FMRI_SCHEME_MEM "mem" 155 #define FM_FMRI_SCHEME_MOD "mod" 156 #define FM_FMRI_SCHEME_PKG "pkg" 157 #define FM_FMRI_SCHEME_LEGACY "legacy-hc" 158 159 /* Scheme versions */ 160 #define FMD_SCHEME_VERSION0 0 161 #define FM_FMD_SCHEME_VERSION FMD_SCHEME_VERSION0 162 #define DEV_SCHEME_VERSION0 0 163 #define FM_DEV_SCHEME_VERSION DEV_SCHEME_VERSION0 164 #define FM_HC_VERS0 0 165 #define FM_HC_SCHEME_VERSION FM_HC_VERS0 166 #define CPU_SCHEME_VERSION0 0 167 #define FM_CPU_SCHEME_VERSION CPU_SCHEME_VERSION0 168 #define MEM_SCHEME_VERSION0 0 169 #define FM_MEM_SCHEME_VERSION MEM_SCHEME_VERSION0 170 #define MOD_SCHEME_VERSION0 0 171 #define FM_MOD_SCHEME_VERSION MOD_SCHEME_VERSION0 172 #define PKG_SCHEME_VERSION0 0 173 #define FM_PKG_SCHEME_VERSION PKG_SCHEME_VERSION0 174 #define LEGACY_SCHEME_VERSION0 0 175 #define FM_LEGACY_SCHEME_VERSION LEGACY_SCHEME_VERSION0 176 177 /* hc scheme member names */ 178 #define FM_FMRI_HC_SERIAL_ID "serial" 179 #define FM_FMRI_HC_PART "part" 180 #define FM_FMRI_HC_REVISION "revision" 181 #define FM_FMRI_HC_ROOT "hc-root" 182 #define FM_FMRI_HC_LIST_SZ "hc-list-sz" 183 #define FM_FMRI_HC_LIST "hc-list" 184 185 /* hc-list version and member names */ 186 #define FM_FMRI_HC_NAME "hc-name" 187 #define FM_FMRI_HC_ID "hc-id" 188 189 #define HC_LIST_VERSION0 0 190 #define FM_HC_LIST_VERSION HC_LIST_VERSION0 191 192 /* fmd module scheme member names */ 193 #define FM_FMRI_FMD_NAME "mod-name" 194 #define FM_FMRI_FMD_VERSION "mod-version" 195 196 /* dev scheme member names */ 197 #define FM_FMRI_DEV_ID "devid" 198 #define FM_FMRI_DEV_PATH "device-path" 199 200 /* pkg scheme member names */ 201 #define FM_FMRI_PKG_BASEDIR "pkg-basedir" 202 #define FM_FMRI_PKG_INST "pkg-inst" 203 #define FM_FMRI_PKG_VERSION "pkg-version" 204 205 /* svc scheme member names */ 206 #define FM_FMRI_SVC_NAME "service-name" 207 #define FM_FMRI_SVC_VERSION "service-version" 208 #define FM_FMRI_SVC_INSTANCE "instance" 209 #define FM_FMRI_SVC_CONTRACT_ID "contract-id" 210 211 /* svc-authority member names */ 212 #define FM_FMRI_SVC_AUTH_SCOPE "scope" 213 #define FM_FMRI_SVC_AUTH_SYSTEM_FQN "system-FQN" 214 215 /* cpu scheme member names */ 216 #define FM_FMRI_CPU_ID "cpuid" 217 #define FM_FMRI_CPU_SERIAL_ID "serial" 218 #define FM_FMRI_CPU_MASK "cpumask" 219 220 /* legacy-hc scheme member names */ 221 #define FM_FMRI_LEGACY_HC "component" 222 223 /* mem scheme member names */ 224 #define FM_FMRI_MEM_UNUM "unum" 225 #define FM_FMRI_MEM_SERIAL_ID "serial" 226 #define FM_FMRI_MEM_PHYSADDR "physaddr" 227 228 /* mod scheme member names */ 229 #define FM_FMRI_MOD_PKG "mod-pkg" 230 #define FM_FMRI_MOD_NAME "mod-name" 231 #define FM_FMRI_MOD_ID "mod-id" 232 #define FM_FMRI_MOD_DESC "mod-desc" 233 234 extern nv_alloc_t *fm_nva_xcreate(char *, size_t); 235 extern void fm_nva_xdestroy(nv_alloc_t *); 236 237 extern nvlist_t *fm_nvlist_create(nv_alloc_t *); 238 extern void fm_nvlist_destroy(nvlist_t *, int); 239 240 #define FM_NVA_FREE 0 /* free allocator on nvlist_destroy */ 241 #define FM_NVA_RETAIN 1 /* keep allocator on nvlist_destroy */ 242 243 extern void fm_ereport_set(nvlist_t *, int, const char *, uint64_t, 244 const nvlist_t *, ...); 245 extern void fm_payload_set(nvlist_t *, ...); 246 extern int i_fm_payload_set(nvlist_t *, const char *, va_list); 247 extern void fm_fmri_hc_set(nvlist_t *, int, const nvlist_t *, const char *, 248 const char *, const char *, const char *, uint32_t, ...); 249 extern void fm_fmri_dev_set(nvlist_t *, int, const nvlist_t *, const char *, 250 const char *); 251 extern void fm_fmri_de_set(nvlist_t *, int, const nvlist_t *, const char *); 252 extern void fm_fmri_cpu_set(nvlist_t *, int, const nvlist_t *, uint32_t, 253 uint8_t, uint64_t); 254 extern void fm_fmri_mem_set(nvlist_t *, int, const nvlist_t *, const char *, 255 const char *); 256 extern void fm_authority_set(nvlist_t *, int, const char *, const char *, 257 const char *, const char *); 258 259 extern uint64_t fm_ena_increment(uint64_t); 260 extern uint64_t fm_ena_generate(uint64_t, uchar_t); 261 extern uint64_t fm_ena_generate_cpu(uint64_t, processorid_t, uchar_t); 262 extern uint64_t fm_ena_generation_get(uint64_t); 263 extern uchar_t fm_ena_format_get(uint64_t); 264 extern uint64_t fm_ena_id_get(uint64_t); 265 extern uint64_t fm_ena_time_get(uint64_t); 266 267 #ifdef __cplusplus 268 } 269 #endif 270 271 #endif /* _SYS_FM_PROTOCOL_H */ 272