Print this page
NEX-2846 Enable Automatic/Intelligent Hot Sparing capability
Reviewed by: Jeffry Molanus <jeffry.molanus@nexenta.com>
Reviewed by: Roman Strashkin <roman.strashkin@nexenta.com>
Reviewed by: Saso Kiselkov <saso.kiselkov@nexenta.com>
re #13388 rb4382 fmd_api.h uses bool which is a C99/C++ keyword
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/cmd/fm/fmd/common/fmd_api.h
+++ new/usr/src/cmd/fm/fmd/common/fmd_api.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
|
↓ open down ↓ |
13 lines elided |
↑ open up ↑ |
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 23 * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
24 + * Copyright 2016 Nexenta Systems, Inc. All rights reserved.
24 25 */
25 26
26 27 #ifndef _FMD_API_H
27 28 #define _FMD_API_H
28 29
29 30 #include <sys/types.h>
30 31 #include <libnvpair.h>
31 32 #include <stdarg.h>
32 33 #include <door.h>
33 34
34 35 #ifdef __cplusplus
35 36 extern "C" {
36 37 #endif
37 38
38 39 /*
39 40 * Fault Management Daemon Client Interfaces
40 41 *
41 42 * Note: The contents of this file are private to the implementation of the
42 43 * Solaris system and FMD subsystem and are subject to change at any time
43 44 * without notice. Applications and drivers using these interfaces will fail
44 45 * to run on future releases. These interfaces should not be used for any
45 46 * purpose until they are publicly documented for use outside of Sun.
46 47 */
47 48
48 49 #define FMD_API_VERSION_1 1
49 50 #define FMD_API_VERSION_2 2
50 51 #define FMD_API_VERSION_3 3
51 52 #define FMD_API_VERSION_4 4
52 53 #define FMD_API_VERSION_5 5
53 54
54 55 #define FMD_API_VERSION FMD_API_VERSION_5
55 56
56 57 typedef struct fmd_hdl fmd_hdl_t;
57 58 typedef struct fmd_event fmd_event_t;
58 59 typedef struct fmd_case fmd_case_t;
59 60 typedef struct fmd_xprt fmd_xprt_t;
60 61
61 62 struct topo_hdl;
62 63
63 64 #define FMD_B_FALSE 0 /* false value for booleans as int */
64 65 #define FMD_B_TRUE 1 /* true value for booleans as int */
65 66
66 67 #ifndef MIN
67 68 #define MIN(x, y) ((x) < (y) ? (x) : (y))
68 69 #endif
69 70
70 71 #ifndef MAX
71 72 #define MAX(x, y) ((x) > (y) ? (x) : (y))
72 73 #endif
73 74
74 75 #define FMD_TYPE_BOOL 0 /* int */
75 76 #define FMD_TYPE_INT32 1 /* int32_t */
76 77 #define FMD_TYPE_UINT32 2 /* uint32_t */
77 78 #define FMD_TYPE_INT64 3 /* int64_t */
78 79 #define FMD_TYPE_UINT64 4 /* uint64_t */
79 80 #define FMD_TYPE_STRING 5 /* const char* */
80 81 #define FMD_TYPE_TIME 6 /* uint64_t */
81 82 #define FMD_TYPE_SIZE 7 /* uint64_t */
82 83
83 84 typedef struct fmd_prop {
|
↓ open down ↓ |
50 lines elided |
↑ open up ↑ |
84 85 const char *fmdp_name; /* property name */
85 86 uint_t fmdp_type; /* property type (see above) */
86 87 const char *fmdp_defv; /* default value */
87 88 } fmd_prop_t;
88 89
89 90 typedef struct fmd_stat {
90 91 char fmds_name[32]; /* statistic name */
91 92 uint_t fmds_type; /* statistic type (see above) */
92 93 char fmds_desc[64]; /* statistic description */
93 94 union {
94 - int bool; /* FMD_TYPE_BOOL */
95 + int b; /* FMD_TYPE_BOOL */
95 96 int32_t i32; /* FMD_TYPE_INT32 */
96 97 uint32_t ui32; /* FMD_TYPE_UINT32 */
97 98 int64_t i64; /* FMD_TYPE_INT64 */
98 99 uint64_t ui64; /* FMD_TYPE_UINT64, TIME, SIZE */
99 100 char *str; /* FMD_TYPE_STRING */
100 101 } fmds_value;
101 102 } fmd_stat_t;
102 103
103 104 typedef struct fmd_hdl_ops {
104 105 void (*fmdo_recv)(fmd_hdl_t *, fmd_event_t *, nvlist_t *, const char *);
105 106 void (*fmdo_timeout)(fmd_hdl_t *, id_t, void *);
106 107 void (*fmdo_close)(fmd_hdl_t *, fmd_case_t *);
107 108 void (*fmdo_stats)(fmd_hdl_t *);
108 109 void (*fmdo_gc)(fmd_hdl_t *);
109 110 int (*fmdo_send)(fmd_hdl_t *, fmd_xprt_t *, fmd_event_t *, nvlist_t *);
110 111 void (*fmdo_topo)(fmd_hdl_t *, struct topo_hdl *);
111 112 } fmd_hdl_ops_t;
112 113
113 114 #define FMD_SEND_SUCCESS 0 /* fmdo_send queued event */
114 115 #define FMD_SEND_FAILED 1 /* fmdo_send unrecoverable error */
115 116 #define FMD_SEND_RETRY 2 /* fmdo_send requests retry */
116 117
117 118 typedef struct fmd_hdl_info {
118 119 const char *fmdi_desc; /* fmd client description string */
119 120 const char *fmdi_vers; /* fmd client version string */
120 121 const fmd_hdl_ops_t *fmdi_ops; /* ops vector for client */
121 122 const fmd_prop_t *fmdi_props; /* array of configuration props */
122 123 } fmd_hdl_info_t;
123 124
124 125 extern void _fmd_init(fmd_hdl_t *);
125 126 extern void _fmd_fini(fmd_hdl_t *);
126 127
127 128 extern int fmd_hdl_register(fmd_hdl_t *, int, const fmd_hdl_info_t *);
128 129 extern void fmd_hdl_unregister(fmd_hdl_t *);
129 130
|
↓ open down ↓ |
25 lines elided |
↑ open up ↑ |
130 131 extern void fmd_hdl_subscribe(fmd_hdl_t *, const char *);
131 132 extern void fmd_hdl_unsubscribe(fmd_hdl_t *, const char *);
132 133
133 134 extern void fmd_hdl_setspecific(fmd_hdl_t *, void *);
134 135 extern void *fmd_hdl_getspecific(fmd_hdl_t *);
135 136
136 137 extern void fmd_hdl_opendict(fmd_hdl_t *, const char *);
137 138 extern struct topo_hdl *fmd_hdl_topo_hold(fmd_hdl_t *, int);
138 139 extern void fmd_hdl_topo_rele(fmd_hdl_t *, struct topo_hdl *);
139 140
141 +typedef struct fmd_hdl_topo_node_info {
142 + const char *device;
143 + nvlist_t *fru;
144 + nvlist_t *resource;
145 +} fmd_hdl_topo_node_info_t;
146 +
147 +extern fmd_hdl_topo_node_info_t *fmd_hdl_topo_node_get_by_devid(
148 + fmd_hdl_t *hdl, char *device);
149 +
140 150 #define FMD_NOSLEEP 0x0 /* do not sleep or retry on failure */
141 151 #define FMD_SLEEP 0x1 /* sleep or retry if alloc fails */
142 152
143 153 extern void *fmd_hdl_alloc(fmd_hdl_t *, size_t, int);
144 154 extern void *fmd_hdl_zalloc(fmd_hdl_t *, size_t, int);
145 155 extern void fmd_hdl_free(fmd_hdl_t *, void *, size_t);
146 156
147 157 extern char *fmd_hdl_strdup(fmd_hdl_t *, const char *, int);
148 158 extern void fmd_hdl_strfree(fmd_hdl_t *, char *);
149 159
150 160 extern void fmd_hdl_vabort(fmd_hdl_t *, const char *, va_list) __NORETURN;
151 161 extern void fmd_hdl_abort(fmd_hdl_t *, const char *, ...) __NORETURN;
152 162
153 163 extern void fmd_hdl_verror(fmd_hdl_t *, const char *, va_list);
154 164 extern void fmd_hdl_error(fmd_hdl_t *, const char *, ...);
155 165
156 166 extern void fmd_hdl_vdebug(fmd_hdl_t *, const char *, va_list);
157 167 extern void fmd_hdl_debug(fmd_hdl_t *, const char *, ...);
158 168
159 169 extern int32_t fmd_prop_get_int32(fmd_hdl_t *, const char *);
160 170 extern int64_t fmd_prop_get_int64(fmd_hdl_t *, const char *);
161 171 extern char *fmd_prop_get_string(fmd_hdl_t *, const char *);
162 172 extern void fmd_prop_free_string(fmd_hdl_t *, char *);
163 173
164 174 #define FMD_STAT_NOALLOC 0x0 /* fmd should use caller's memory */
165 175 #define FMD_STAT_ALLOC 0x1 /* fmd should allocate stats memory */
166 176
167 177 extern fmd_stat_t *fmd_stat_create(fmd_hdl_t *, uint_t, uint_t, fmd_stat_t *);
168 178 extern void fmd_stat_destroy(fmd_hdl_t *, uint_t, fmd_stat_t *);
169 179 extern void fmd_stat_setstr(fmd_hdl_t *, fmd_stat_t *, const char *);
170 180
171 181 extern fmd_case_t *fmd_case_open(fmd_hdl_t *, void *);
172 182 extern fmd_case_t *fmd_case_open_uuid(fmd_hdl_t *, const char *, void *);
173 183 extern void fmd_case_reset(fmd_hdl_t *, fmd_case_t *);
174 184 extern void fmd_case_solve(fmd_hdl_t *, fmd_case_t *);
175 185 extern void fmd_case_close(fmd_hdl_t *, fmd_case_t *);
176 186
177 187 extern const char *fmd_case_uuid(fmd_hdl_t *, fmd_case_t *);
178 188 extern fmd_case_t *fmd_case_uulookup(fmd_hdl_t *, const char *);
179 189 extern void fmd_case_uuclose(fmd_hdl_t *, const char *);
180 190 extern int fmd_case_uuclosed(fmd_hdl_t *, const char *);
181 191 extern int fmd_case_uuisresolved(fmd_hdl_t *, const char *);
182 192 extern void fmd_case_uuresolved(fmd_hdl_t *, const char *);
183 193
184 194 extern int fmd_case_solved(fmd_hdl_t *, fmd_case_t *);
185 195 extern int fmd_case_closed(fmd_hdl_t *, fmd_case_t *);
186 196
187 197 extern void fmd_case_add_ereport(fmd_hdl_t *, fmd_case_t *, fmd_event_t *);
188 198 extern void fmd_case_add_serd(fmd_hdl_t *, fmd_case_t *, const char *);
189 199 extern void fmd_case_add_suspect(fmd_hdl_t *, fmd_case_t *, nvlist_t *);
190 200
191 201 extern void fmd_case_setspecific(fmd_hdl_t *, fmd_case_t *, void *);
192 202 extern void *fmd_case_getspecific(fmd_hdl_t *, fmd_case_t *);
193 203
194 204 extern void fmd_case_setprincipal(fmd_hdl_t *, fmd_case_t *, fmd_event_t *);
195 205 extern fmd_event_t *fmd_case_getprincipal(fmd_hdl_t *, fmd_case_t *);
196 206
197 207 extern fmd_case_t *fmd_case_next(fmd_hdl_t *, fmd_case_t *);
198 208 extern fmd_case_t *fmd_case_prev(fmd_hdl_t *, fmd_case_t *);
199 209
200 210 extern void fmd_buf_create(fmd_hdl_t *, fmd_case_t *, const char *, size_t);
201 211 extern void fmd_buf_destroy(fmd_hdl_t *, fmd_case_t *, const char *);
202 212 extern void fmd_buf_read(fmd_hdl_t *, fmd_case_t *,
203 213 const char *, void *, size_t);
204 214 extern void fmd_buf_write(fmd_hdl_t *, fmd_case_t *,
205 215 const char *, const void *, size_t);
206 216 extern size_t fmd_buf_size(fmd_hdl_t *, fmd_case_t *, const char *);
207 217
208 218 extern void fmd_serd_create(fmd_hdl_t *, const char *, uint_t, hrtime_t);
209 219 extern void fmd_serd_destroy(fmd_hdl_t *, const char *);
210 220 extern int fmd_serd_exists(fmd_hdl_t *, const char *);
211 221 extern void fmd_serd_reset(fmd_hdl_t *, const char *);
212 222 extern int fmd_serd_record(fmd_hdl_t *, const char *, fmd_event_t *);
213 223 extern int fmd_serd_fired(fmd_hdl_t *, const char *);
214 224 extern int fmd_serd_empty(fmd_hdl_t *, const char *);
215 225
216 226 extern pthread_t fmd_thr_create(fmd_hdl_t *, void (*)(void *), void *);
217 227 extern void fmd_thr_destroy(fmd_hdl_t *, pthread_t);
218 228 extern void fmd_thr_signal(fmd_hdl_t *, pthread_t);
219 229 extern void fmd_thr_checkpoint(fmd_hdl_t *);
220 230
221 231 extern door_xcreate_server_func_t fmd_doorthr_create;
222 232 extern door_xcreate_thrsetup_func_t fmd_doorthr_setup;
223 233
224 234 extern id_t fmd_timer_install(fmd_hdl_t *, void *, fmd_event_t *, hrtime_t);
225 235 extern void fmd_timer_remove(fmd_hdl_t *, id_t);
226 236
227 237 extern nvlist_t *fmd_nvl_create_defect(fmd_hdl_t *,
228 238 const char *, uint8_t, nvlist_t *, nvlist_t *, nvlist_t *);
229 239 extern nvlist_t *fmd_nvl_create_fault(fmd_hdl_t *,
230 240 const char *, uint8_t, nvlist_t *, nvlist_t *, nvlist_t *);
231 241
232 242 extern const nvlist_t *fmd_hdl_fmauth(fmd_hdl_t *);
233 243 extern const nvlist_t *fmd_hdl_modauth(fmd_hdl_t *);
234 244
235 245 extern int fmd_nvl_class_match(fmd_hdl_t *, nvlist_t *, const char *);
236 246 extern int fmd_nvl_fmri_expand(fmd_hdl_t *, nvlist_t *);
237 247 extern int fmd_nvl_fmri_present(fmd_hdl_t *, nvlist_t *);
238 248 extern int fmd_nvl_fmri_unusable(fmd_hdl_t *, nvlist_t *);
239 249 extern int fmd_nvl_fmri_retire(fmd_hdl_t *, nvlist_t *);
240 250 extern int fmd_nvl_fmri_unretire(fmd_hdl_t *, nvlist_t *);
241 251 extern int fmd_nvl_fmri_replaced(fmd_hdl_t *, nvlist_t *);
242 252 extern int fmd_nvl_fmri_service_state(fmd_hdl_t *, nvlist_t *);
243 253 extern int fmd_nvl_fmri_has_fault(fmd_hdl_t *, nvlist_t *, int, char *);
244 254
245 255 #define FMD_HAS_FAULT_FRU 0
246 256 #define FMD_HAS_FAULT_ASRU 1
247 257 #define FMD_HAS_FAULT_RESOURCE 2
248 258
249 259 extern void fmd_repair_fru(fmd_hdl_t *, const char *);
250 260 extern int fmd_repair_asru(fmd_hdl_t *, const char *);
251 261
252 262 extern int fmd_nvl_fmri_contains(fmd_hdl_t *, nvlist_t *, nvlist_t *);
253 263 extern nvlist_t *fmd_nvl_fmri_translate(fmd_hdl_t *, nvlist_t *, nvlist_t *);
254 264
255 265 extern nvlist_t *fmd_nvl_alloc(fmd_hdl_t *, int);
256 266 extern nvlist_t *fmd_nvl_dup(fmd_hdl_t *, nvlist_t *, int);
257 267
258 268 extern int fmd_event_local(fmd_hdl_t *, fmd_event_t *);
259 269 extern uint64_t fmd_event_ena_create(fmd_hdl_t *);
260 270
261 271
262 272 #define FMD_XPRT_RDONLY 0x1 /* transport is read-only */
263 273 #define FMD_XPRT_RDWR 0x3 /* transport is read-write */
264 274 #define FMD_XPRT_ACCEPT 0x4 /* transport is accepting connection */
265 275 #define FMD_XPRT_SUSPENDED 0x8 /* transport starts suspended */
266 276 #define FMD_XPRT_EXTERNAL 0x80 /* xprt is external to a chassis */
267 277 #define FMD_XPRT_NO_REMOTE_REPAIR 0x100 /* xprt does not allow remote repair */
268 278 #define FMD_XPRT_CACHE_AS_LOCAL 0x200 /* xprt caches fault as if local */
269 279 #define FMD_XPRT_HCONLY 0x400 /* xprt only proxies hc-scheme faults */
270 280 #define FMD_XPRT_HC_PRESENT_ONLY 0x800 /* only locally present hc faults */
271 281
272 282 extern fmd_xprt_t *fmd_xprt_open(fmd_hdl_t *, uint_t, nvlist_t *, void *);
273 283 extern void fmd_xprt_close(fmd_hdl_t *, fmd_xprt_t *);
274 284 extern void fmd_xprt_post(fmd_hdl_t *, fmd_xprt_t *, nvlist_t *, hrtime_t);
275 285 extern void fmd_xprt_log(fmd_hdl_t *, fmd_xprt_t *, nvlist_t *, hrtime_t);
276 286 extern void fmd_xprt_suspend(fmd_hdl_t *, fmd_xprt_t *);
277 287 extern void fmd_xprt_resume(fmd_hdl_t *, fmd_xprt_t *);
278 288 extern int fmd_xprt_error(fmd_hdl_t *, fmd_xprt_t *);
279 289 extern nvlist_t *fmd_xprt_translate(fmd_hdl_t *, fmd_xprt_t *, fmd_event_t *);
280 290 extern void fmd_xprt_add_domain(fmd_hdl_t *, nvlist_t *, char *);
281 291 extern void fmd_xprt_setspecific(fmd_hdl_t *, fmd_xprt_t *, void *);
282 292 extern void *fmd_xprt_getspecific(fmd_hdl_t *, fmd_xprt_t *);
283 293
284 294 #ifdef __cplusplus
285 295 }
286 296 #endif
287 297
288 298 #endif /* _FMD_API_H */
|
↓ open down ↓ |
139 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX