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
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.
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]
23 * Copyright (c) 2001 by Sun Microsystems, Inc.
24 * All rights reserved.
30 #pragma ident "%Z%%M% %I% %E% SMI"
41 * Header file for the FC-AL LEDs PICL plugin.
42 * Contains message texts, constant definitions, typedefs for enums and
43 * structs, global data and function templates.
51 #define EM_CANT_OPEN \
52 gettext("SUNW_fcal_leds: open fail: %s\n")
53 #define EM_NONALF_TOK \
54 gettext("SUNW_fcal_leds: line %d token begins non-alpha\n")
56 gettext("SUNW_fcal_leds: line %d token too long\n")
58 gettext("SUNW_fcal_leds: line %d unknown token\n")
59 #define EM_INVAL_TOK \
60 gettext("SUNW_fcal_leds: line %d invalid token at start of line\n")
62 gettext("SUNW_fcal_leds: line %d leading token not followed by ':'\n")
64 gettext("SUNW_fcal_leds: first token not VERSION\n")
66 gettext("SUNW_fcal_leds: invalid number terminator\n")
67 #define EM_LOGIC_LVL \
68 gettext("SUNW_fcal_leds: logic level specified as neither 0 nor 1\n")
70 gettext("SUNW_fcal_leds: numeric field greater than 0 expected\n")
71 #define EM_DISK_RANGE \
72 gettext("SUNW_fcal_leds: disk number out of range\n")
73 #define EM_NDISKS_DBL \
74 gettext("SUNW_fcal_leds: number of disks defined twice\n")
76 gettext("SUNW_fcal_leds: no disks defined\n")
78 gettext("SUNW_fcal_leds: format error in VERSION string\n")
80 gettext("SUNW_fcal_leds: config version %d.%d not supported\n")
82 gettext("SUNW_fcal_leds: path names must be absolute\n")
84 gettext("SUNW_fcal_leds: error on line %d\n")
85 #define EM_NO_LED_PROP \
86 gettext("SUNW_fcal_leds: LED property name missing\n")
87 #define EM_PROP_TERM \
88 gettext("SUNW_fcal_leds: expected comma (',') after property name\n")
89 #define EM_STR_NOT_SET \
90 gettext("SUNW_fcal_leds: %s not defined")
91 #define EM_I2C_GET_PORT \
92 gettext("SUNW_fcal_leds: I2C_GET_PORT: %s\n")
93 #define EM_DI_INIT_FAIL \
94 gettext("SUNW_fcal_leds: di_init failed: %s\n")
95 #define EM_THREAD_CREATE_FAILED \
96 gettext("SUNW_fcal_leds: pthread_create() call failed: %s\n")
97 #define EM_MUTEX_FAIL \
98 gettext("SUNW_fcal_leds: pthread_mutex_lock returned: %s\n")
99 #define EM_CONDWAITFAIL \
100 gettext("SUNW_fcal_leds: pthread_cond_wait returned: %s\n")
101 #define EM_SPURIOUS_FP \
102 gettext("SUNW_fcal_leds: deleting spurious PICL fp node\n")
103 #define EM_NO_FP_NODE \
105 "SUNW_fcal_leds: cannot get PICL disk node for hot plug disk %d\n")
106 #define EM_POLL_FAIL \
107 gettext("SUNW_fcal_leds: poll() returned: %s, no more timed events\n")
110 * config file terminal name
112 #define FCAL_LEDS_CONF_FILE "fcal_leds.conf"
115 * devinfo hardware properties
117 #define HW_PROP_TARGET "target"
118 #define HW_PROP_PORT "port-wwn"
123 #define FCAL_PICL_DISK_UNIT "disk-unit"
126 * PICL property names
128 #define FCAL_PICL_REF "_"
129 #define FCAL_PICL_PROP_BUS_ADDR "bus-addr"
130 #define FCAL_PICL_PROP_TARGET "target"
131 #define FCAL_PICL_LED_REF FCAL_PICL_REF PICL_CLASS_LED FCAL_PICL_REF
132 #define FCAL_PICL_BLOCK_REF FCAL_PICL_REF PICL_CLASS_BLOCK FCAL_PICL_REF
135 * String values for led State property
137 #define FCAL_PICL_LED_ON "on"
138 #define FCAL_PICL_LED_OFF "off"
139 #define FCAL_PICL_LED_TEST "led test"
141 * MAX_LEN_LED_STATE is (strlen(FCAL_PICL_LED_TEST) + 1)
143 #define MAX_LEN_LED_STATE 9
146 * Space for 0123456789ABCDEF,0123456789ABCDEF<nul>
148 #define MAX_LEN_UNIT_ADDRESS 34
151 * properties per row in Device table
153 #define FCAL_DEVTABLE_NCOLS 2
156 * number of LEDs per disk
158 #define FCAL_LED_CNT 3
161 * special values for status when ioctl fails
163 #define I2C_IOCTL_FAIL (-1)
164 #define I2C_IOCTL_INIT (-2)
165 #define MINORS_UNKNOWN (-1)
168 * other status values
176 #define FCAL_EV_POLL 1
177 #define FCAL_EV_CONFIG 2
180 * default timer values - overridden by .conf file
182 #define DFLT_SLOW_POLL 59
183 #define DFLT_FAST_POLL 2
184 #define DFLT_RELAX_TIME 300
185 #define DFLT_TEST_TIME 10
191 LED_PROPS_START
, /* next enums are for led properties */
195 LED_PROPS_END
, /* no more led properties */
196 LINE_DEFS
, /* next enums define configuration lines */
216 typedef enum led_state_enum
{
223 typedef const char *cstr
;
226 * Note on disk_prev and disk_ready flags.
227 * The following entries are dynamically created arrays:
228 * presence, faults, disk_detected, disk_ready, disk_prev, led_test_end,
229 * disk_port, led_addr.
230 * The disk_prev and disk_ready flags (one per disk) are used as follows:
231 * disk removed (disk_detected = 0), disk_ready[d] = 0, disk_prev[d] = 0
232 * disk present (disk_detected = 1) use this table:
233 * disk_ready[d] | disk_prev[d] | meaning
234 * 0 | 0 | driver not (yet) attached (show green led)
235 * 0 | 1 | driver has been detached (show blue led)
236 * 1 | 0 | driver attached, PICL update needed (green)
237 * 1 | 1 | driver attached, normal running (green)
238 * OK to remove (blue) is only lit for the attached -> detached transition
239 * state 1 0 (PICL update needed) is really transient and is cleared after
240 * calling update_picl.
242 typedef struct led_dtls
{
245 cstr fcal_leds
; /* path name of leds board */
246 cstr fcal_status
; /* path of back-plane status board */
247 cstr fcal_driver
; /* name of fcal disk driver */
248 int n_disks
; /* number of fcal disks */
249 int *presence
; /* presence detection masks */
250 int *faults
; /* fault status masks */
251 int *disk_detected
; /* working store for detected disks */
252 int *disk_ready
; /* working store for disk ready */
253 int *disk_prev
; /* previous ready state */
254 volatile int *led_test_end
; /* (per disk) ticks to end led test */
255 boolean_t
*picl_retry
; /* (per disk) retry picl update flag */
256 uchar_t
**disk_port
; /* for FC-AL this is WWN */
257 int assert_presence
; /* status value for presence */
258 int assert_fault
; /* status value for fault */
259 int assert_led_on
; /* level required to light led */
260 uint_t
*led_addr
[FCAL_LED_CNT
]; /* 2D array to leds */
261 led_state_t
*led_state
[FCAL_LED_CNT
]; /* current states */
262 boolean_t led_retry
; /* flag set after led ioctl failure */
263 volatile boolean_t polling
; /* set to B_FALSE after poll failure */
264 volatile int fast_poll_end
; /* fast_poll ticks left */
265 int fast_poll
; /* fast_poll interval in seconds */
266 int slow_poll_ticks
; /* fast polls per slow poll */
267 int relax_time_ticks
; /* time interval to do fast polling */
268 int led_test_time
; /* fast polls in led test interval */
269 cstr fcal_disk_parent
; /* search string for /platform */
270 cstr disk_unit_parent
; /* search template for disk-slots */
271 cstr disk_led_nodes
; /* search template for disk-leds */
274 typedef int (*actfun_t
)(str
*p_str
, led_dtls_t
*dtls
);
276 typedef struct lookup
{
285 extern led_dtls_t
*g_led_dtls
;
286 extern pthread_cond_t g_cv
;
287 extern pthread_cond_t g_cv_ack
;
288 extern pthread_mutex_t g_mutex
;
289 extern volatile int g_event_flag
;
290 extern volatile boolean_t g_finish_now
;
291 extern volatile boolean_t g_leds_thread_ack
;
292 extern volatile boolean_t g_poll_thread_ack
;
297 char *mystrerror(int err
);
298 void *fcal_leds_thread(void *args
);
299 int fc_led_parse(FILE *fp
, led_dtls_t
**p_dtls
);
300 void free_led_dtls(led_dtls_t
*dtls
);
301 int find_disk_slot(led_dtls_t
*dtls
, int disk
, picl_nodehdl_t
*nodeh
);
302 void delete_disk_unit(led_dtls_t
*dtls
, int disk
);
303 boolean_t
is_led_test(led_dtls_t
*dtls
);
304 int create_Device_table(picl_prophdl_t
*tbl_h
, picl_prophdl_t
*tableh
);
305 void clr_led(int diskNo
, token_t led_tok
, led_dtls_t
*dtls
);
311 #endif /* _FCAL_LEDS_H */