Print this page
XXXX introduce drv_sectohz
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/sys/bscv_impl.h
+++ new/usr/src/uts/common/sys/bscv_impl.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
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 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 23 * Use is subject to license terms.
24 24 */
25 25
26 26 #ifndef _SYS_BSCV_IMPL_H
27 27 #define _SYS_BSCV_IMPL_H
28 28
29 29 #pragma ident "%Z%%M% %I% %E% SMI"
30 30
31 31 /*
32 32 * Implementation private header file for bscv driver.
33 33 */
34 34
35 35 #ifdef __cplusplus
36 36 extern "C" {
37 37 #endif
38 38
39 39 #include <sys/lom_priv.h>
40 40
41 41
42 42 /*
43 43 * Local #defines
44 44 */
45 45
46 46 #define BSCV_SUCCESS DDI_SUCCESS
47 47 #define BSCV_FAILURE DDI_FAILURE
48 48
49 49 /*
50 50 * The following are used as progress indicators in bscv_attach()
51 51 */
52 52
53 53 #define BSCV_LOCKS 0x01
54 54 #define BSCV_MAPPED_REGS 0x02
55 55 #define BSCV_NODES 0x04
56 56 #define BSCV_THREAD 0x08
57 57 #define BSCV_HOSTNAME_DONE 0x10
58 58 #define BSCV_WDOG_CFG 0x20
59 59 #define BSCV_SIG_SENT 0x40
60 60
61 61 /*
62 62 * macros to encode device minors and provide mapping to device instances.
63 63 * The following is designed to get around the problem of a 32-bit app not
64 64 * supporting a 32-bit minor number on an LP64 model system.
65 65 */
66 66
67 67 #ifdef NBITSMINOR
68 68 #undef NBITSMINOR
69 69 #define NBITSMINOR 18
70 70 #endif
71 71
72 72 #define BSCV_MONITOR_NODE 0
73 73 #define BSCV_CONTROL_NODE (1 << (NBITSMINOR - 1))
74 74
75 75 #define DEVICETOINSTANCE(x) ((getminor(x)) & (~BSCV_CONTROL_NODE));
76 76
77 77 /*
78 78 * The maximum number of leds which are supported by this lom implementation.
79 79 */
80 80 #define MAX_LED_ID 7
81 81
82 82 /*
83 83 * general driver configuration constants which may be changed to improve
84 84 * performance/efficiency.
85 85 */
86 86
87 87 #define INIT_BUSY_WAIT 10 /* 10 microsecs */
88 88
89 89 #define MAX_WDOGTIMEOUT 127 /* maximum wdog timout - 127s */
90 90
91 91
92 92 /*
93 93 * Event processing task status flags.
94 94 */
95 95 #define TASK_ALIVE_FLG 0x01
96 96 #define TASK_STOP_FLG 0x02
97 97 #define TASK_SLEEPING_FLG 0x04
98 98 #define TASK_PAUSE_FLG 0x08
99 99 #define TASK_EVENT_PENDING_FLG 0x10
100 100 #define TASK_EVENT_CONSUMER_FLG 0x20
101 101
102 102 /*
103 103 * strace(1M) prints out the debug data once the debug value is set in
104 104 * the bscv.conf file and the debug driver is installed.
105 105 *
106 106 * Debug flags
107 107 *
108 108 * '@' - Register (@)ccess
109 109 * 'A' - (A)ttach
110 110 * 'B' - (B)lom1 attach extra
111 111 * 'C' - lom1 (C)allback
112 112 * 'D' - (D)aemon
113 113 * 'E' - (E)vents
114 114 * 'F' - Sel(F)test
115 115 * 'I' - (I)octl
116 116 * 'L' - TSa(L)arms
117 117 * 'M' - (M)odel parameters
118 118 * 'N' - I(N)terrupt Service Routine
119 119 * 'O' - (O)pen/Close
120 120 * 'P' - (P)rogramming
121 121 * 'Q' - (Q)ueue things
122 122 * 'R' - Read/Write (R)etry summary.
123 123 * 'S' - Event (S)trings
124 124 * 'U' - Programming ioctls
125 125 * 'V' - ???
126 126 * 'W' - (W)atchdog
127 127 * 'X' - additional X86 functional calls
128 128 * 'Z' - Temporary - just log things
129 129 */
130 130
131 131 /*
132 132 * Debug tips :
133 133 *
134 134 * strace(1M) prints out the debug data.
135 135 * A nice way to work out the debug value set in bscv.conf is to use mdb
136 136 * Say we want to show 'D' Daemon and 'I' IOCTL processing,
137 137 * you calculate the debug value with the following mdb session :
138 138 * # mdb
139 139 * > 1<<('D'-'@') | 1<<('I'-'@') = X
140 140 * 210
141 141 * > $q
142 142 * When you insert "debug=0x210;" into bscv.conf, it causes the next
143 143 * reboot with the debug driver to trace Daemon and IOCTL functionality.
144 144 */
145 145
146 146 /*
147 147 * Xbus channel access data
148 148 */
149 149
150 150 struct xbus_channel {
151 151 ddi_acc_handle_t handle;
152 152 uint8_t *regs;
153 153 };
154 154
155 155 #define BSCV_MINCHANNELS 2
156 156 #define BSCV_MAXCHANNELS 16
157 157
158 158 /*
159 159 * soft state structure
160 160 */
161 161
162 162 typedef
163 163 struct {
164 164 /*
165 165 * Hardware instance variables
166 166 */
167 167 uint64_t debug; /* debugging turned on */
168 168 major_t majornum; /* debugging - major number */
169 169 minor_t minornum; /* debugging - minor number */
170 170
171 171 dev_info_t *dip; /* pointer to device info tree */
172 172 int instance; /* instance number for the device */
173 173 ddi_device_acc_attr_t attr; /* device access attributes */
174 174
175 175 struct xbus_channel channel[BSCV_MAXCHANNELS];
176 176 int nchannels;
177 177
178 178 int progress; /* progress indicator for attach */
179 179
180 180 int bad_resync; /* Number of bad resyncs */
181 181
182 182 /*
183 183 * lom data variables/arrays
184 184 */
185 185 uint8_t lom_regs[0x80]; /* registers on the lomlite */
186 186 int serial_reporting;
187 187 int reporting_level;
188 188
189 189 /*
190 190 * lom2 static information.
191 191 * setup at driver attach and restart after programming.
192 192 */
193 193 int num_fans;
194 194 char fan_names[MAX_FANS][MAX_LOM2_NAME_STR];
195 195 uint8_t fanspeed[MAX_FANS];
196 196 char led_names[MAX_LED_ID][MAX_LOM2_NAME_STR];
197 197 lom_volts_t volts; /* keep a static copy of this so */
198 198 /* dont have to re-read names */
199 199 lom_temp_t temps; /* keep a static copy of this so */
200 200 /* dont have to re-read names */
201 201 lom_sflags_t sflags; /* keep a static copy of this so */
202 202 /* dont have to re-read names */
203 203 char escape_chars[6]; /* local copy */
204 204
205 205 uint_t watchdog_timeout;
206 206 uint8_t watchdog_reset_on_timeout;
207 207
208 208 /*
209 209 * lom2 firmware communication
210 210 */
211 211
212 212 /*
213 213 * cmd_mutex protects the lom2 command progress variables.
214 214 * These should only be read/updated with the mutex held.
215 215 *
216 216 * command_error - acts as a return code and may be read
217 217 * without the mutex held if a command is not in progress.
218 218 * Note a read only returns failure if the lom does not respond.
219 219 * So you might need to check the error code to see if things really
220 220 * did work!
221 221 *
222 222 * addr_mu is used to protect stopping and starting of the queue.
223 223 * BUT when programming it has different semantics and relies
224 224 * on only the programming thread being in the ioctl routine
225 225 * whilst programming is in progress. The event queue must also
226 226 * be paused at this time.
227 227 */
228 228 kmutex_t cmd_mutex; /* LOM command mutual exclusion */
229 229
230 230 int command_error; /* error code from last command */
231 231 /* valid until the next command */
232 232 /* starts. */
233 233
234 234 boolean_t had_fault; /* Current command sequence faulted */
235 235 boolean_t had_session_error; /* Current session had error */
236 236
237 237 uint8_t pat_seq; /* Watchdog patting sequence number */
238 238 uint8_t cap0; /* capability byte */
239 239 uint8_t cap1; /* capability byte */
240 240 uint8_t cap2; /* capability byte */
241 241
242 242 /*
243 243 * Programming variables
244 244 */
245 245 kmutex_t prog_mu; /* Programming mutex. - lom 2 */
246 246 boolean_t prog_mode_only; /* If true we can only reprogram */
247 247 /* the lom */
248 248 boolean_t programming; /* TRUE is actually programming */
249 249 /* the BSC */
250 250 boolean_t cssp_prog; /* TRUE is CSSP programming the BSC */
251 251
252 252 int prog_index; /* data buffer number - bit */
253 253 /* 0x8000 set if last buffer */
254 254 int image_ptr; /* ptr to next byte in image buffer */
255 255 /* for programming */
256 256 uint8_t *image; /* ptr to image buffer for */
257 257 /* programming */
258 258 boolean_t image2_processing; /* boolean to say which of */
259 259 /* 2 BSC images being processed */
260 260 boolean_t loader_running; /* Still have the loader running */
261 261
262 262 /*
263 263 * LOM eeprom window access state
264 264 * Access under bscv_enter/bscv_exit protection.
265 265 */
266 266 boolean_t eeinfo_valid;
267 267 uint32_t eeprom_size;
268 268 uint32_t eventlog_start;
269 269 uint32_t eventlog_size;
270 270 boolean_t oldeeptr_valid;
271 271 uint16_t oldeeptr;
272 272
273 273 /*
274 274 * Communication with the event processing thread
275 275 *
276 276 * Change these variables with task_mu held and signal task_cv
277 277 * if an event/task needs processing.
278 278 */
279 279 kmutex_t task_mu; /* mutex for wait on event thread */
280 280 kcondvar_t task_cv; /* cv for wait on event thread */
281 281 kcondvar_t task_evnt_cv; /* cv for lom2 wait on event */
282 282 int task_flags; /* To monitor/stop the event thread */
283 283 volatile int event_active_count; /* Count of event thread runs */
284 284 boolean_t event_waiting; /* New events are waiting in the lom */
285 285 boolean_t status_change; /* A status change is waiting */
286 286 boolean_t nodename_change; /* Nodename has changed */
287 287 boolean_t event_sleep; /* Error reading events - wait a bit */
288 288 boolean_t event_fault_reported; /* Event fault reported */
289 289 boolean_t watchdog_change; /* Watchdog config has changed */
290 290 #ifdef __sparc
291 291 bscv_sig_t last_sig; /* Record of last signature sent */
292 292 #endif /* __sparc */
293 293 uint8_t last_event[8]; /* last event read and reported */
294 294 #if defined(__i386) || defined(__amd64)
295 295 ddi_periodic_t periodic_id; /* watchdog patter periodical callback */
296 296 callb_id_t callb_id; /* Need to store the ID so we can */
297 297 /* unschedule the panic callback */
298 298 char last_nodename[128]; /* copy of last utsname.nodename */
299 299 #endif /* __i386 || __amd64 */
300 300 } bscv_soft_state_t;
301 301
302 302 struct bscv_idi_callout {
303 303 enum bscv_idi_type type; /* Type of service */
304 304 boolean_t (*fn)(struct bscv_idi_info); /* Function's address */
305 305 };
306 306
307 307 #define BSCV_IDI_CALLOUT_MAGIC 0xb5c1ca11
308 308 #define BSCV_IDI_ERR_MSG_THRESHOLD 10
309 309 struct bscv_idi_callout_mgr {
310 310 /*
311 311 * To allow for sanity check.
312 312 */
313 313 uint32_t magic;
314 314
315 315 /*
316 316 * The instance number of "an" instance of the driver. This is assigned
317 317 * during driver attach.
318 318 */
319 319 uint32_t valid_inst;
320 320
321 321 /*
322 322 * Table of services offered via the idi interface.
323 323 */
324 324 struct bscv_idi_callout *tbl;
325 325
326 326 /*
↓ open down ↓ |
326 lines elided |
↑ open up ↑ |
327 327 * Error message count since last successful use of the idi interface.
328 328 */
329 329 uint64_t errs;
330 330 };
331 331
332 332
333 333
334 334 #define BSC_IMAGE_MAX_SIZE (0x20000 + sizeof (lom_prog_data_t))
335 335
336 336 #define BSC_PROBE_FAULT_LIMIT 8 /* Tries before declaring lom dead */
337 -#define BSC_EVENT_POLL_NORMAL (drv_usectohz(1000000)) /* 1 second */
338 -#define BSC_EVENT_POLL_FAULTY (drv_usectohz(10000000)) /* 10 second */
337 +#define BSC_EVENT_POLL_NORMAL drv_sectohz(1)
338 +#define BSC_EVENT_POLL_FAULTY drv_sectohz(10)
339 339
340 340 #define BSC_FAILURE_RETRY_LIMIT 5 /* Access retries before giving up */
341 341 #define BSC_ERASE_RETRY_LIMIT 5 /* Erase retries */
342 342 #define BSC_PAGE_RETRY_LIMIT 5 /* Page write retries */
343 343
344 344 #define BSC_ADDR_CACHE_LIMIT \
345 345 (sizeof (((bscv_soft_state_t *)NULL)->lom_regs))
346 346 #define BSC_INFORM_ONLINE 0x4f530100
347 347 #define BSC_INFORM_OFFLINE 0x4f530201
348 348 #define BSC_INFORM_PANIC 0x4f530204
349 349
350 350 #include <sys/lom_ebuscodes.h>
351 351
352 352 typedef uint32_t bscv_addr_t;
353 353
354 354 #define BSC_NEXUS_ADDR(ssp, chan, as, index) \
355 355 (&((ssp)->channel[chan].regs[((as) * 256) + (index)]))
356 356
357 357 #define BSC_NEXUS_OFFSET(as, index) (((as) * 256) + (index))
358 358
359 359 #define BSCVA(as, index) (((as) * 256) + (index))
360 360
361 361 #define PSR_SUCCESS(status) (((status) & EBUS_PROGRAM_PSR_STATUS_MASK) == \
362 362 EBUS_PROGRAM_PSR_SUCCESS)
363 363
364 364 #define PSR_PROG(status) (((status) & EBUS_PROGRAM_PSR_PROG_MODE) != 0)
365 365 #ifdef __cplusplus
366 366 }
367 367 #endif
368 368
369 369 #endif /* _SYS_BSCV_IMPL_H */
↓ open down ↓ |
21 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX