dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / cmd / fm / modules / common / disk-monitor / diskmon_conf.h
blob4c0a9bec83a8ecabfe734c57e071e2ba802e2444
1 /*
2 * CDDL HEADER START
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.
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.
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]
19 * CDDL HEADER END
23 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #ifndef _DISKMOND_CONF_H
28 #define _DISKMOND_CONF_H
30 #pragma ident "%Z%%M% %I% %E% SMI"
33 * Configuration File data
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
40 #include <sys/types.h>
41 #include <pthread.h>
42 #include <libnvpair.h>
43 #include <fm/fmd_api.h>
44 #include "dm_types.h"
45 #include "util.h"
47 #ifndef MIN
48 #define MIN(x, y) ((x) < (y) ? (x) : (y))
49 #endif
51 #ifndef MAX
52 #define MAX(x, y) ((x) > (y) ? (x) : (y))
53 #endif
55 #define DEVICES_PREFIX "/devices"
57 #define GLOBAL_PROP_LOG_LEVEL "log-level"
59 /* Property names (and values) for the disk configuration file entity */
60 #define DISK_PROP_DEVPATH "dev-path"
61 #define DISK_PROP_LOGNAME "logical-path"
62 #define DISK_PROP_FRUACTION "fru-update-action"
63 #define DISK_PROP_OTEMPACTION "overtemp-action"
64 #define DISK_PROP_STFAILACTION "selftest-fail-action"
66 /* Properties for the "ap" subentity */
67 #define DISK_AP_PROP_APID "path"
69 #define DEVPATH_MINOR_SEPARATOR ':'
71 #define DEFAULT_FAULT_POLLING_INTERVAL 3600 /* seconds */
73 #define INDICATOR_FAULT_IDENTIFIER "FAULT"
75 typedef enum conf_err_e {
76 E_NO_ERROR = 0,
77 E_MULTIPLE_IND_LISTS_DEFINED,
78 E_MULTIPLE_INDRULE_LISTS_DEFINED,
79 E_INVALID_STATE_CHANGE,
80 E_IND_MULTIPLY_DEFINED,
81 E_IND_ACTION_REDUNDANT,
82 E_IND_ACTION_CONFLICT,
83 E_IND_MISSING_FAULT_ON,
84 E_IND_MISSING_FAULT_OFF,
85 E_INDRULE_REFERENCES_NONEXISTENT_IND_ACTION,
86 E_DUPLICATE_STATE_TRANSITION
87 } conf_err_t;
89 typedef enum {
90 INDICATOR_UNKNOWN,
91 INDICATOR_ON,
92 INDICATOR_OFF
93 } ind_state_t;
95 typedef enum {
96 TS_NOT_RUNNING,
97 TS_RUNNING,
98 TS_EXIT_REQUESTED,
99 TS_EXITED
100 } thread_state_t;
102 typedef struct ind_action {
103 ind_state_t ind_state;
104 char *ind_name;
105 struct ind_action *next;
106 } ind_action_t;
108 typedef struct state_transition {
109 hotplug_state_t begin;
110 hotplug_state_t end;
111 } state_transition_t;
113 typedef struct indrule {
114 state_transition_t strans;
115 ind_action_t *action_list;
116 struct indrule *next;
117 } indrule_t;
119 typedef struct indicator {
120 ind_state_t ind_state;
121 char *ind_name;
122 char *ind_instr_spec;
123 struct indicator *next;
124 } indicator_t;
126 typedef struct diskmon {
128 * Static configuration data
130 nvlist_t *props;
131 char *location; /* descriptive location */
132 nvlist_t *app_props;
133 indicator_t *ind_list;
134 indrule_t *indrule_list;
136 * Dynamic data
138 hotplug_state_t state;
141 * Only one manager can be manipulating the
142 * state in the diskmon at one time (either the
143 * state-change manager or the fault-polling manager)
145 pthread_mutex_t manager_mutex;
148 * Set to true only during initialization, and
149 * cleared the next time a fru update needs to
150 * occur, this flag enabled an optimization of
151 * NOT calling libtopo for a configuration update
152 * when the DE starts up. This allows a HUGE
153 * savings (since only a single snapshot-- the
154 * initial snapshot) is used as the source of
155 * the FRU information.
157 boolean_t initial_configuration;
159 /* For the state-change manager: */
162 * Current state of the fault indicator.
164 pthread_mutex_t fault_indicator_mutex;
165 ind_state_t fault_indicator_state;
168 * Set to TRUE when a disk transitions to the CONFIGURED state
169 * and remains TRUE until the disk is physically removed.
171 boolean_t configured_yet;
174 * The number of disk hotplug state transitions since the disk
175 * was inserted.
177 uint_t state_change_count;
179 /* Disk FRU (model, manufacturer, etc) information */
180 pthread_mutex_t fru_mutex;
181 dm_fru_t *frup;
183 struct diskmon *next;
184 } diskmon_t;
186 typedef struct cfgdata {
187 nvlist_t *props;
188 diskmon_t *disk_list;
189 } cfgdata_t;
191 typedef struct namevalpr {
192 char *name;
193 char *value;
194 } namevalpr_t;
197 extern indicator_t *new_indicator(ind_state_t lstate, char *namep,
198 char *actionp);
199 extern void link_indicator(indicator_t **first,
200 indicator_t *to_add);
201 extern void ind_free(indicator_t *indp);
203 extern ind_action_t *new_indaction(ind_state_t state, char *namep);
204 extern void link_indaction(ind_action_t **first,
205 ind_action_t *to_add);
206 extern void indaction_free(ind_action_t *lap);
208 extern indrule_t *new_indrule(state_transition_t *st,
209 ind_action_t *actionp);
210 extern void link_indrule(indrule_t **first, indrule_t *to_add);
211 extern void indrule_free(indrule_t *lrp);
213 extern diskmon_t *new_diskmon(nvlist_t *app_props, indicator_t *indp,
214 indrule_t *indrp, nvlist_t *nvlp);
215 extern void diskmon_free(diskmon_t *dmp);
217 extern dm_fru_t *new_dmfru(char *manu, char *modl, char *firmrev,
218 char *serno, uint64_t capa);
219 extern void dmfru_free(dm_fru_t *frup);
221 extern nvlist_t *namevalpr_to_nvlist(namevalpr_t *nvprp);
223 extern conf_err_t check_state_transition(hotplug_state_t s1,
224 hotplug_state_t s2);
225 extern conf_err_t check_inds(indicator_t *indp);
226 extern conf_err_t check_indactions(ind_action_t *indap);
227 extern conf_err_t check_indrules(indrule_t *indrp,
228 state_transition_t **offender);
229 extern conf_err_t check_consistent_ind_indrules(indicator_t *indp,
230 indrule_t *indrp, ind_action_t **offender);
232 extern void cfgdata_add_diskmon(cfgdata_t *cfgp, diskmon_t *dmp);
234 extern void conf_error_msg(conf_err_t err, char *buf, int buflen,
235 void *arg);
237 extern const char *dm_prop_lookup(nvlist_t *props, const char *prop_name);
238 extern int dm_prop_lookup_int(nvlist_t *props,
239 const char *prop_name, int *value);
241 extern int config_init(void);
242 extern int config_get(fmd_hdl_t *hdl, const fmd_prop_t *fmd_props);
243 extern void config_fini(void);
245 extern const char *hotplug_state_string(hotplug_state_t state);
247 extern nvlist_t *dm_global_proplist(void);
249 #ifdef __cplusplus
251 #endif
253 #endif /* _DISKMOND_CONF_H */