Print this page
NEX-17446 cleanup of hot unplugged disks fails intermittently
Reviewed by: Dan Fields <dan.fields@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Rick McNeal <rick.mcneal@nexenta.com>
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/uts/common/sys/sunndi.h
+++ new/usr/src/uts/common/sys/sunndi.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
|
↓ open down ↓ |
10 lines elided |
↑ open up ↑ |
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 23 * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
24 + * Copyright 2018 Nexenta Systems, Inc.
23 25 */
24 26
25 27 #ifndef _SYS_SUNNDI_H
26 28 #define _SYS_SUNNDI_H
27 29
28 30 /*
29 31 * Sun Specific NDI definitions
30 32 */
31 33
32 34 #include <sys/esunddi.h>
33 35 #include <sys/sunddi.h>
34 36 #include <sys/obpdefs.h>
35 37
36 38 #ifdef __cplusplus
37 39 extern "C" {
38 40 #endif
39 41
40 42 #ifdef _KERNEL
41 43
42 44 #define NDI_SUCCESS DDI_SUCCESS /* successful return */
43 45 #define NDI_FAILURE DDI_FAILURE /* unsuccessful return */
44 46 #define NDI_NOMEM -2 /* failed to allocate resources */
45 47 #define NDI_BADHANDLE -3 /* bad handle passed to in function */
46 48 #define NDI_FAULT -4 /* fault during copyin/copyout */
47 49 #define NDI_BUSY -5 /* device busy - could not offline */
48 50 #define NDI_UNBOUND -6 /* device not bound to a driver */
49 51 #define NDI_EINVAL -7 /* invalid request or arguments */
50 52 #define NDI_ENOTSUP -8 /* operation or event not supported */
51 53 #define NDI_CLAIMED NDI_SUCCESS /* event is claimed */
52 54 #define NDI_UNCLAIMED -9 /* event is not claimed */
53 55
54 56 /*
55 57 * Property functions: See also, ddipropdefs.h.
56 58 * In general, the underlying driver MUST be held
57 59 * to call it's property functions.
58 60 */
59 61
60 62 /*
61 63 * Used to create boolean properties
62 64 */
63 65 int
64 66 ndi_prop_create_boolean(dev_t match_dev, dev_info_t *dip, char *name);
65 67
66 68 /*
67 69 * Used to create, modify, and lookup integer properties
68 70 */
69 71 int
70 72 ndi_prop_update_int(dev_t match_dev, dev_info_t *dip, char *name, int data);
71 73
72 74 int
73 75 ndi_prop_update_int_array(dev_t match_dev, dev_info_t *dip, char *name,
74 76 int *data, uint_t nelements);
75 77
76 78 int
77 79 ndi_prop_update_int64(dev_t match_dev, dev_info_t *dip, char *name,
78 80 int64_t data);
79 81
80 82 int
81 83 ndi_prop_update_int64_array(dev_t match_dev, dev_info_t *dip, char *name,
82 84 int64_t *data, uint_t nelements);
83 85
84 86 /*
85 87 * Used to create, modify, and lookup string properties
86 88 */
87 89 int
88 90 ndi_prop_update_string(dev_t match_dev, dev_info_t *dip, char *name,
89 91 char *data);
90 92
91 93 int
92 94 ndi_prop_update_string_array(dev_t match_dev, dev_info_t *dip,
93 95 char *name, char **data, uint_t nelements);
94 96
95 97 /*
96 98 * Used to create, modify, and lookup byte properties
97 99 */
98 100 int
99 101 ndi_prop_update_byte_array(dev_t match_dev, dev_info_t *dip,
100 102 char *name, uchar_t *data, uint_t nelements);
101 103
102 104 /*
103 105 * Used to remove properties
104 106 */
105 107 int
106 108 ndi_prop_remove(dev_t dev, dev_info_t *dip, char *name);
107 109
108 110 void
109 111 ndi_prop_remove_all(dev_info_t *dip);
110 112
111 113 /*
112 114 * Nexus Driver Functions
113 115 */
114 116 /*
115 117 * Allocate and initialize a new dev_info structure.
116 118 * This routine will often be called at interrupt time by a nexus in
117 119 * response to a hotplug event, therefore memory allocations are
118 120 * not allowed to sleep.
119 121 */
120 122 int
121 123 ndi_devi_alloc(dev_info_t *parent, char *node_name, pnode_t nodeid,
122 124 dev_info_t **ret_dip);
123 125
124 126 void
125 127 ndi_devi_alloc_sleep(dev_info_t *parent, char *node_name, pnode_t nodeid,
126 128 dev_info_t **ret_dip);
127 129
128 130 /*
129 131 * Remove an initialized (but not yet attached) dev_info
130 132 * node from it's parent.
131 133 */
132 134 int
133 135 ndi_devi_free(dev_info_t *dip);
134 136
135 137 /* devinfo locking: use DEVI_BUSY_OWNED in ASSERTs to verify */
136 138 void ndi_devi_enter(dev_info_t *dip, int *circ);
137 139 void ndi_devi_exit(dev_info_t *dip, int circ);
138 140 int ndi_devi_tryenter(dev_info_t *dip, int *circ);
139 141
140 142 /* devinfo ref counting */
141 143 void ndi_hold_devi(dev_info_t *dip);
142 144 void ndi_rele_devi(dev_info_t *dip);
143 145
144 146 /* driver ref counting */
145 147 struct dev_ops *ndi_hold_driver(dev_info_t *dip);
146 148 void ndi_rele_driver(dev_info_t *dip);
147 149
148 150 /*
149 151 * Change the node name
150 152 */
151 153 int
152 154 ndi_devi_set_nodename(dev_info_t *dip, char *name, int flags);
153 155
154 156 /*
155 157 * Place the devinfo in the DS_BOUND state,
156 158 * binding a driver to the device
157 159 *
158 160 * Flags:
159 161 * all flags are ignored.
160 162 */
161 163 int
162 164 ndi_devi_bind_driver(dev_info_t *dip, uint_t flags);
163 165
164 166 /*
165 167 * Asynchronous version of ndi_devi_bind_driver, callable from
166 168 * interrupt context. The dip must be a persistent node.
167 169 */
168 170 int
169 171 ndi_devi_bind_driver_async(dev_info_t *dip, uint_t flags);
170 172
171 173 /*
172 174 * Return devctl state of the child addressed by "name@addr".
173 175 * For use by a driver's DEVCTL_DEVICE_GETSTATE handler.
174 176 */
175 177 int
176 178 ndi_devctl_device_getstate(dev_info_t *parent, struct devctl_iocdata *dcp,
177 179 uint_t *state);
178 180
179 181 /*
180 182 * Transition the child addressed by "name@addr" to the online state.
181 183 * For use by a driver's DEVCTL_DEVICE_ONLINE handler.
182 184 */
183 185 int
184 186 ndi_devctl_device_online(dev_info_t *dip, struct devctl_iocdata *dcp,
185 187 uint_t flags);
186 188
187 189 /*
188 190 * Transition the child addressed by "name@addr" to the offline state.
189 191 * For use by a driver's DEVCTL_DEVICE_OFFLINE handler.
190 192 */
191 193 int
192 194 ndi_devctl_device_offline(dev_info_t *dip, struct devctl_iocdata *dcp,
193 195 uint_t flags);
194 196
195 197 /*
196 198 * Remove the child addressed by name@addr.
197 199 * For use by a driver's DEVCTL_DEVICE_REMOVE handler.
198 200 */
199 201 int
200 202 ndi_devctl_device_remove(dev_info_t *dip, struct devctl_iocdata *dcp,
201 203 uint_t flags);
202 204
203 205 /*
204 206 * Bus get state
205 207 * For use by a driver's DEVCTL_BUS_GETSTATE handler.
206 208 */
207 209 int
208 210 ndi_devctl_bus_getstate(dev_info_t *dip, struct devctl_iocdata *dcp,
209 211 uint_t *state);
210 212
211 213 /*
212 214 * Place the devinfo in the ONLINE state
213 215 */
214 216 int
215 217 ndi_devi_online(dev_info_t *dip, uint_t flags);
216 218
217 219 /*
218 220 * Generic devctl ioctl handler
219 221 */
220 222 int
221 223 ndi_devctl_ioctl(dev_info_t *dip, int cmd, intptr_t arg, int mode,
222 224 uint_t flags);
223 225
224 226 /*
225 227 * Asynchronous version of ndi_devi_online, callable from interrupt
226 228 * context. The dip must be a persistent node.
227 229 */
228 230 int
229 231 ndi_devi_online_async(dev_info_t *dip, uint_t flags);
230 232
231 233
232 234 /*
233 235 * Configure children of a nexus node.
234 236 *
235 237 * Flags:
236 238 * NDI_ONLINE_ATTACH - Attach driver to devinfo node when placing
237 239 * the device Online.
238 240 * NDI_CONFIG - Recursively configure children if child is nexus node
239 241 */
240 242 int
241 243 ndi_devi_config(dev_info_t *dip, int flags);
242 244
243 245 int
244 246 ndi_devi_config_driver(dev_info_t *dip, int flags, major_t major);
245 247
246 248 int
247 249 ndi_devi_config_one(dev_info_t *dip, char *devnm, dev_info_t **dipp, int flags);
248 250
249 251 /*
250 252 * Unconfigure children of a nexus node.
251 253 *
252 254 * Flags:
253 255 * NDI_DEVI_REMOVE - Remove child devinfo nodes
254 256 *
255 257 * NDI_UNCONFIG - Put child devinfo nodes to uninitialized state,
256 258 * release resources held by child nodes.
257 259 */
258 260 int
259 261 ndi_devi_unconfig(dev_info_t *dip, int flags);
260 262
261 263 int
262 264 e_ddi_devi_unconfig(dev_info_t *dip, dev_info_t **dipp, int flags);
263 265
264 266 int
265 267 ndi_devi_unconfig_one(dev_info_t *dip, char *devnm, dev_info_t **dipp,
266 268 int flags);
267 269
268 270 int
269 271 ndi_devi_unconfig_driver(dev_info_t *dip, int flags, major_t major);
270 272
271 273 void
272 274 ndi_set_bus_private(dev_info_t *dip, boolean_t up, uint32_t port_type,
273 275 void *data);
274 276
275 277 void *
276 278 ndi_get_bus_private(dev_info_t *dip, boolean_t up);
277 279
278 280 boolean_t
279 281 ndi_port_type(dev_info_t *dip, boolean_t up, uint32_t port_type);
280 282
281 283 /*
282 284 * Interrupt Resource Management (IRM) Pools.
283 285 */
284 286 int
285 287 ndi_irm_create(dev_info_t *dip, ddi_irm_params_t *paramsp,
286 288 ddi_irm_pool_t **pool_retp);
287 289
288 290 int
289 291 ndi_irm_destroy(ddi_irm_pool_t *poolp);
290 292
291 293 int
292 294 ndi_irm_resize_pool(ddi_irm_pool_t *poolp, uint_t newsize);
293 295
294 296 /*
295 297 * Take a device node "Offline".
296 298 *
297 299 * Offline means to detach the device instance from the bound
298 300 * driver and setting the devinfo state to prevent deferred attach
299 301 * from re-attaching the device instance.
300 302 *
301 303 * Flags:
302 304 * NDI_DEVI_REMOVE - Remove the node from the devinfo tree after
303 305 * first taking it Offline.
304 306 */
305 307
306 308 #define NDI_DEVI_REMOVE 0x00000001 /* remove after unconfig */
307 309 #define NDI_ONLINE_ATTACH 0x00000002 /* online/attach after config */
308 310 #define NDI_MDI_FALLBACK 0x00000004 /* Leadville to fallback to phci */
309 311 #define NDI_CONFIG 0x00000008 /* recursively config descendants */
310 312 #define NDI_UNCONFIG 0x00000010 /* unconfig to uninitialized state */
311 313 #define NDI_DEVI_BIND 0x00000020 /* transition to DS_BOUND state */
312 314 #define NDI_DEVI_PERSIST 0x00000040 /* do not config offlined nodes */
313 315 #define NDI_PROMNAME 0x00000080 /* name comes from prom */
314 316 #define NDI_DEVFS_CLEAN 0x00001000 /* clean dv_nodes only, no detach */
315 317 #define NDI_AUTODETACH 0x00002000 /* moduninstall daemon */
316 318 #define NDI_NO_EVENT 0x00004000 /* don't devfs add/remove events */
317 319 #define NDI_DEVI_DEBUG 0x00008000 /* turn on observability */
|
↓ open down ↓ |
285 lines elided |
↑ open up ↑ |
318 320 #define NDI_CONFIG_REPROBE 0x00010000 /* force reprobe (deferred attach) */
319 321 #define NDI_DEVI_ONLINE 0x00020000 /* force offlined device to online */
320 322 #define NDI_DEVI_OFFLINE 0x00040000 /* set detached device to offline */
321 323 #define NDI_POST_EVENT 0x00080000 /* Post NDI events before remove */
322 324 #define NDI_BRANCH_EVENT_OP 0x01000000 /* branch op needs branch event */
323 325 #define NDI_NO_EVENT_STATE_CHNG 0x02000000 /* don't change the event state */
324 326 #define NDI_DRV_CONF_REPROBE 0x04000000 /* reprobe conf-enum'd nodes only */
325 327 #define NDI_DETACH_DRIVER 0x08000000 /* performing driver_detach */
326 328 #define NDI_MTC_OFF 0x10000000 /* disable multi-threading */
327 329 #define NDI_USER_REQ 0x20000000 /* user requested operation */
330 +#define NDI_DEVI_GONE 0x40000000 /* device is gone */
328 331
329 332 /* ndi interface flag values */
330 333 #define NDI_SLEEP 0x000000
331 334 #define NDI_NOSLEEP 0x100000
332 335 #define NDI_EVENT_NOPASS 0x200000 /* do not pass event req up the tree */
333 336
334 337 int
335 338 ndi_devi_offline(dev_info_t *dip, uint_t flags);
336 339
337 340 /*
338 341 * Find the child dev_info node of parent nexus 'p' whose name
339 342 * matches "cname"@"caddr". Use ndi_devi_findchild() instead.
340 343 */
341 344 dev_info_t *
342 345 ndi_devi_find(dev_info_t *p, char *cname, char *caddr);
343 346
344 347 /*
345 348 * Find the child dev_info node of parent nexus 'p' whose name
346 349 * matches device name "name"@"addr".
347 350 */
348 351 dev_info_t *
349 352 ndi_devi_findchild(dev_info_t *p, char *devname);
350 353
351 354 /*
352 355 * Find the child dev_info node of parent nexus 'p' whose name
353 356 * matches "dname"@"ua". If a child doesn't have a "ua"
354 357 * value, it calls the function "make_ua" to create it.
355 358 */
356 359 dev_info_t *
357 360 ndi_devi_findchild_by_callback(dev_info_t *p, char *dname, char *ua,
358 361 int (*make_ua)(dev_info_t *, char *, int));
359 362
360 363 /*
361 364 * Maintain DEVI_DEVICE_REMOVED hotplug devi_state for remove/reinsert hotplug
362 365 * of open devices.
363 366 */
364 367 int
365 368 ndi_devi_device_isremoved(dev_info_t *dip);
366 369 int
367 370 ndi_devi_device_remove(dev_info_t *dip);
368 371 int
369 372 ndi_devi_device_insert(dev_info_t *dip);
370 373
371 374 /*
372 375 * generate debug msg via NDI_DEVI_DEBUG flag
373 376 */
374 377 #define NDI_DEBUG(flags, args) \
375 378 if (flags & NDI_DEVI_DEBUG) cmn_err args
376 379
377 380 /*
378 381 * Copy in the devctl IOCTL data structure and the strings referenced
379 382 * by the structure.
380 383 *
381 384 * Convenience functions for use by nexus drivers as part of the
382 385 * implementation of devctl IOCTL handling.
383 386 */
384 387 int
385 388 ndi_dc_allochdl(void *iocarg, struct devctl_iocdata **rdcp);
386 389
387 390 void
388 391 ndi_dc_freehdl(struct devctl_iocdata *dcp);
389 392
390 393 char *
391 394 ndi_dc_getpath(struct devctl_iocdata *dcp);
392 395
393 396 char *
394 397 ndi_dc_getname(struct devctl_iocdata *dcp);
395 398
396 399 char *
397 400 ndi_dc_getaddr(struct devctl_iocdata *dcp);
398 401
399 402 nvlist_t *
400 403 ndi_dc_get_ap_data(struct devctl_iocdata *dcp);
401 404
402 405 char *
403 406 ndi_dc_getminorname(struct devctl_iocdata *dcp);
404 407
405 408 int
406 409 ndi_dc_return_dev_state(dev_info_t *dip, struct devctl_iocdata *dcp);
407 410
408 411 int
409 412 ndi_dc_return_ap_state(devctl_ap_state_t *ap, struct devctl_iocdata *dcp);
410 413
411 414 int
412 415 ndi_dc_return_bus_state(dev_info_t *dip, struct devctl_iocdata *dcp);
413 416
414 417 int
415 418 ndi_dc_devi_create(struct devctl_iocdata *dcp, dev_info_t *pdip, int flags,
416 419 dev_info_t **rdip);
417 420
418 421 int
419 422 ndi_get_bus_state(dev_info_t *dip, uint_t *rstate);
420 423
421 424 int
422 425 ndi_set_bus_state(dev_info_t *dip, uint_t state);
423 426
424 427 /*
425 428 * Post an event notification up the device tree hierarchy to the
426 429 * parent nexus, until claimed by a bus nexus driver or the top
427 430 * of the dev_info tree is reached.
428 431 */
429 432 int
430 433 ndi_post_event(dev_info_t *dip, dev_info_t *rdip, ddi_eventcookie_t eventhdl,
431 434 void *impl_data);
432 435
433 436 /*
434 437 * Called by the NDI Event Framework to deliver a registration request to the
435 438 * appropriate bus nexus driver.
436 439 */
437 440 int
438 441 ndi_busop_add_eventcall(dev_info_t *dip, dev_info_t *rdip,
439 442 ddi_eventcookie_t eventhdl, void (*callback)(), void *arg,
440 443 ddi_callback_id_t *cb_id);
441 444
442 445 /*
443 446 * Called by the NDI Event Framework to deliver an unregister request to the
444 447 * appropriate bus nexus driver.
445 448 */
446 449 int
447 450 ndi_busop_remove_eventcall(dev_info_t *ddip, ddi_callback_id_t id);
448 451
449 452 /*
450 453 * Called by the NDI Event Framework and/or a bus nexus driver's
451 454 * implementation of the (*bus_get_eventcookie)() interface up the device tree
452 455 * hierarchy, until claimed by a bus nexus driver or the top of the dev_info
453 456 * tree is reached. The NDI Event Framework will skip nexus drivers which are
454 457 * not configured to handle NDI events.
455 458 */
456 459 int
457 460 ndi_busop_get_eventcookie(dev_info_t *dip, dev_info_t *rdip, char *name,
458 461 ddi_eventcookie_t *event_cookiep);
459 462
460 463 /*
461 464 * ndi event callback support routines:
462 465 *
463 466 * these functions require an opaque ndi event handle
464 467 */
465 468 typedef struct ndi_event_hdl *ndi_event_hdl_t;
466 469
467 470 /*
468 471 * structure for maintaining each registered callback
469 472 */
470 473 typedef struct ndi_event_callbacks {
471 474 struct ndi_event_callbacks *ndi_evtcb_next;
472 475 struct ndi_event_callbacks *ndi_evtcb_prev;
473 476 dev_info_t *ndi_evtcb_dip;
474 477 char *devname; /* name of device defining this callback */
475 478 void (*ndi_evtcb_callback)();
476 479 void *ndi_evtcb_arg;
477 480 ddi_eventcookie_t ndi_evtcb_cookie;
478 481 } ndi_event_callbacks_t;
479 482
480 483 /*
481 484 * a nexus driver defines events that it can support using the
482 485 * following structure
483 486 */
484 487 typedef struct ndi_event_definition {
485 488 int ndi_event_tag;
486 489 char *ndi_event_name;
487 490 ddi_plevel_t ndi_event_plevel;
488 491 uint_t ndi_event_attributes;
489 492 } ndi_event_definition_t;
490 493
491 494 typedef struct ndi_event_cookie {
492 495 ndi_event_definition_t *definition; /* Event Description */
493 496 dev_info_t *ddip; /* Devi defining this event */
494 497 ndi_event_callbacks_t *callback_list; /* Cb's reg'd to w/ this evt */
495 498 struct ndi_event_cookie *next_cookie; /* Next cookie def'd in hdl */
496 499 } ndi_event_cookie_t;
497 500
498 501
499 502 #define NDI_EVENT(cookie) ((struct ndi_event_cookie *)(void *)(cookie))
500 503 #define NDI_EVENT_NAME(cookie) (NDI_EVENT(cookie)->definition->ndi_event_name)
501 504 #define NDI_EVENT_TAG(cookie) (NDI_EVENT(cookie)->definition->ndi_event_tag)
502 505 #define NDI_EVENT_ATTRIBUTES(cookie) \
503 506 (NDI_EVENT(cookie)->definition->ndi_event_attributes)
504 507 #define NDI_EVENT_PLEVEL(cookie) \
505 508 (NDI_EVENT(cookie)->definition->ndi_event_plevel)
506 509 #define NDI_EVENT_DDIP(cookie) (NDI_EVENT(cookie)->ddip)
507 510
508 511 /* ndi_event_attributes */
509 512 #define NDI_EVENT_POST_TO_ALL 0x0 /* broadcast: post to all handlers */
510 513 #define NDI_EVENT_POST_TO_TGT 0x1 /* call only specific child's hdlr */
511 514
512 515 typedef struct ndi_event_set {
513 516 ushort_t ndi_events_version;
514 517 ushort_t ndi_n_events;
515 518 ndi_event_definition_t *ndi_event_defs;
516 519 } ndi_event_set_t;
517 520
518 521
519 522 #define NDI_EVENTS_REV0 0
520 523 #define NDI_EVENTS_REV1 1
521 524
522 525 /*
523 526 * allocate an ndi event handle
524 527 */
525 528 int
526 529 ndi_event_alloc_hdl(dev_info_t *dip, ddi_iblock_cookie_t cookie,
527 530 ndi_event_hdl_t *ndi_event_hdl, uint_t flag);
528 531
529 532 /*
530 533 * free the ndi event handle
531 534 */
532 535 int
533 536 ndi_event_free_hdl(ndi_event_hdl_t handle);
534 537
535 538 /*
536 539 * bind or unbind a set of events to/from the event handle
537 540 */
538 541 int
539 542 ndi_event_bind_set(ndi_event_hdl_t handle,
540 543 ndi_event_set_t *ndi_event_set,
541 544 uint_t flag);
542 545
543 546 int
544 547 ndi_event_unbind_set(ndi_event_hdl_t handle,
545 548 ndi_event_set_t *ndi_event_set,
546 549 uint_t flag);
547 550
548 551 /*
549 552 * get an event cookie
550 553 */
551 554 int
552 555 ndi_event_retrieve_cookie(ndi_event_hdl_t handle,
553 556 dev_info_t *child_dip,
554 557 char *eventname,
555 558 ddi_eventcookie_t *cookiep,
556 559 uint_t flag);
557 560
558 561 /*
559 562 * add an event callback info to the ndi event handle
560 563 */
561 564 int
562 565 ndi_event_add_callback(ndi_event_hdl_t handle,
563 566 dev_info_t *child_dip,
564 567 ddi_eventcookie_t cookie,
565 568 void (*event_callback)
566 569 (dev_info_t *,
567 570 ddi_eventcookie_t,
568 571 void *arg,
569 572 void *impldata),
570 573 void *arg,
571 574 uint_t flag,
572 575 ddi_callback_id_t *cb_id);
573 576
574 577 /*
575 578 * remove an event callback registration from the ndi event handle
576 579 */
577 580 int
578 581 ndi_event_remove_callback(ndi_event_hdl_t handle, ddi_callback_id_t id);
579 582
580 583 /*
581 584 * perform callbacks for a specified cookie
582 585 */
583 586 int
584 587 ndi_event_run_callbacks(ndi_event_hdl_t handle, dev_info_t *child_dip,
585 588 ddi_eventcookie_t cookie, void *bus_impldata);
586 589
587 590 /*
588 591 * do callback for just one child_dip, regardless of attributes
589 592 */
590 593 int ndi_event_do_callback(ndi_event_hdl_t handle, dev_info_t *child_dip,
591 594 ddi_eventcookie_t cookie, void *bus_impldata);
592 595
593 596 /*
594 597 * ndi_event_tag_to_cookie: utility function to find an event cookie
595 598 * given an event tag
596 599 */
597 600 ddi_eventcookie_t
598 601 ndi_event_tag_to_cookie(ndi_event_hdl_t handle, int event_tag);
599 602
600 603 /*
601 604 * ndi_event_cookie_to_tag: utility function to find an event tag
602 605 * given an event_cookie
603 606 */
604 607 int
605 608 ndi_event_cookie_to_tag(ndi_event_hdl_t handle,
606 609 ddi_eventcookie_t cookie);
607 610
608 611 /*
609 612 * ndi_event_cookie_to_name: utility function to find an event
610 613 * name given an event_cookie
611 614 */
612 615 char *
613 616 ndi_event_cookie_to_name(ndi_event_hdl_t handle,
614 617 ddi_eventcookie_t cookie);
615 618
616 619 /*
617 620 * ndi_event_tag_to_name: utility function to find an event
618 621 * name given an event_tag
619 622 */
620 623 char *
621 624 ndi_event_tag_to_name(ndi_event_hdl_t handle, int event_tag);
622 625
623 626 dev_info_t *
624 627 ndi_devi_config_vhci(char *, int);
625 628
626 629 #ifdef DEBUG
627 630 /*
628 631 * ndi_event_dump_hdl: debug functionality used to display event handle
629 632 */
630 633 void
631 634 ndi_event_dump_hdl(struct ndi_event_hdl *hdl, char *location);
632 635 #endif
633 636
634 637 /*
635 638 * Default busop bus_config helper functions
636 639 */
637 640 int
638 641 ndi_busop_bus_config(dev_info_t *pdip, uint_t flags, ddi_bus_config_op_t op,
639 642 void *arg, dev_info_t **child, clock_t reset_delay);
640 643
641 644 int
642 645 ndi_busop_bus_unconfig(dev_info_t *dip, uint_t flags, ddi_bus_config_op_t op,
643 646 void *arg);
644 647
645 648 /*
646 649 * Called by the Nexus/HPC drivers to register, unregister and interact
647 650 * with the hotplug framework for the specified hotplug connection.
648 651 */
649 652 int
650 653 ndi_hp_register(dev_info_t *dip, ddi_hp_cn_info_t *info_p);
651 654
652 655 int
653 656 ndi_hp_unregister(dev_info_t *dip, char *cn_name);
654 657
655 658 int
656 659 ndi_hp_state_change_req(dev_info_t *dip, char *cn_name,
657 660 ddi_hp_cn_state_t state, uint_t flag);
658 661
659 662 void
660 663 ndi_hp_walk_cn(dev_info_t *dip, int (*f)(ddi_hp_cn_info_t *, void *),
661 664 void *arg);
662 665
663 666 /*
664 667 * Bus Resource allocation structures and function prototypes exported
665 668 * by busra module
666 669 */
667 670
668 671 /* structure for specifying a request */
669 672 typedef struct ndi_ra_request {
670 673 uint_t ra_flags; /* General flags */
671 674 /* see bit definitions below */
672 675
673 676 uint64_t ra_len; /* Requested allocation length */
674 677
675 678 uint64_t ra_addr; /* Specific base address requested */
676 679
677 680 uint64_t ra_boundbase; /* Base address of the area for */
678 681 /* the allocated resource to be */
679 682 /* restricted to */
680 683
681 684 uint64_t ra_boundlen; /* Length of the area, starting */
682 685 /* from ra_boundbase, for the */
683 686 /* allocated resource to be */
684 687 /* restricted to. */
685 688
686 689 uint64_t ra_align_mask; /* Alignment mask used for */
687 690 /* allocated base address */
688 691 } ndi_ra_request_t;
689 692
690 693
691 694 /* ra_flags bit definitions */
692 695 #define NDI_RA_ALIGN_SIZE 0x0001 /* Set the alignment of the */
693 696 /* allocated resource address */
694 697 /* according to the ra_len */
695 698 /* value (alignment mask will */
696 699 /* be (ra_len - 1)). Value of */
697 700 /* ra_len has to be power of 2. */
698 701 /* If this flag is set, value of */
699 702 /* ra_align_mask will be ignored. */
700 703
701 704
702 705 #define NDI_RA_ALLOC_BOUNDED 0x0002 /* Indicates that the resource */
703 706 /* should be restricted to the */
704 707 /* area specified by ra_boundbase */
705 708 /* and ra_boundlen */
706 709
707 710 #define NDI_RA_ALLOC_SPECIFIED 0x0004 /* Indicates that a specific */
708 711 /* address (ra_addr value) is */
709 712 /* requested. */
710 713
711 714 #define NDI_RA_ALLOC_PARTIAL_OK 0x0008 /* Indicates if requested size */
712 715 /* (ra_len) chunk is not available */
713 716 /* then allocate as big chunk as */
714 717 /* possible which is less than or */
715 718 /* equal to ra_len size. */
716 719
717 720
718 721 /* return values specific to bus resource allocator */
719 722 #define NDI_RA_PARTIAL_REQ -7
720 723
721 724
722 725
723 726
724 727 /* Predefined types for generic type of resources */
725 728 #define NDI_RA_TYPE_MEM "memory"
726 729 #define NDI_RA_TYPE_IO "io"
727 730 #define NDI_RA_TYPE_PCI_BUSNUM "pci_bus_number"
728 731 #define NDI_RA_TYPE_PCI_PREFETCH_MEM "pci_prefetchable_memory"
729 732 #define NDI_RA_TYPE_INTR "interrupt"
730 733
731 734 /* flag bit definition */
732 735 #define NDI_RA_PASS 0x0001 /* pass request up the dev tree */
733 736
734 737 /*
735 738 * Prototype definitions for functions exported
736 739 */
737 740
738 741 int
739 742 ndi_ra_map_setup(dev_info_t *dip, char *type);
740 743
741 744 int
742 745 ndi_ra_map_destroy(dev_info_t *dip, char *type);
743 746
744 747 int
745 748 ndi_ra_alloc(dev_info_t *dip, ndi_ra_request_t *req, uint64_t *basep,
746 749 uint64_t *lenp, char *type, uint_t flag);
747 750
748 751 int
749 752 ndi_ra_free(dev_info_t *dip, uint64_t base, uint64_t len, char *type,
750 753 uint_t flag);
751 754
752 755 /*
753 756 * ndi_dev_is_prom_node: Return non-zero if the node is a prom node
754 757 */
755 758 int ndi_dev_is_prom_node(dev_info_t *);
756 759
757 760 /*
758 761 * ndi_dev_is_pseudo_node: Return non-zero if the node is a pseudo node.
759 762 * NB: all non-prom nodes are pseudo nodes.
760 763 * c.f. ndi_dev_is_persistent_node
761 764 */
762 765 int ndi_dev_is_pseudo_node(dev_info_t *);
763 766
764 767 /*
765 768 * ndi_dev_is_persistent_node: Return non-zero if the node has the
766 769 * property of persistence.
767 770 */
768 771 int ndi_dev_is_persistent_node(dev_info_t *);
769 772
770 773 /*
771 774 * ndi_dev_is_hotplug_node: Return non-zero if the node was created by hotplug.
772 775 */
773 776 int ndi_dev_is_hotplug_node(dev_info_t *);
774 777
775 778 /*
776 779 * ndi_dev_is_hidden_node: Return non-zero if the node is hidden.
777 780 */
778 781 int ndi_dev_is_hidden_node(dev_info_t *);
779 782
780 783 /*
781 784 * ndi_devi_set_hidden: mark a node as hidden
782 785 * ndi_devi_clr_hidden: mark a node as visible
783 786 */
784 787 void ndi_devi_set_hidden(dev_info_t *);
785 788 void ndi_devi_clr_hidden(dev_info_t *);
786 789
787 790 /*
788 791 * Event posted when a fault is reported
789 792 */
790 793 #define DDI_DEVI_FAULT_EVENT "DDI:DEVI_FAULT"
791 794
792 795 struct ddi_fault_event_data {
793 796 dev_info_t *f_dip;
794 797 ddi_fault_impact_t f_impact;
795 798 ddi_fault_location_t f_location;
796 799 const char *f_message;
797 800 ddi_devstate_t f_oldstate;
798 801 };
799 802
800 803 /*
801 804 * Access handle/DMA handle fault flag setting/clearing functions for nexi
802 805 */
803 806 void ndi_set_acc_fault(ddi_acc_handle_t ah);
804 807 void ndi_clr_acc_fault(ddi_acc_handle_t ah);
805 808 void ndi_set_dma_fault(ddi_dma_handle_t dh);
806 809 void ndi_clr_dma_fault(ddi_dma_handle_t dh);
807 810
808 811 /* Driver.conf property merging */
809 812 int ndi_merge_node(dev_info_t *, int (*)(dev_info_t *, char *, int));
810 813 void ndi_merge_wildcard_node(dev_info_t *);
811 814
812 815 /*
813 816 * Ndi 'flavor' support: These interfaces are to support a nexus driver
814 817 * with multiple 'flavors' of children (devi_flavor of child), coupled
815 818 * with a child flavor-specifc private data mechanism (via devi_flavor_v
816 819 * of parent). This is provided as an extension to ddi_[sg]et_driver_private,
817 820 * where the vanilla 'flavor' is what is stored or retrieved via
818 821 * ddi_[sg]et_driver_private.
819 822 *
820 823 * Flavors are indexed with a small integer. The first flavor, flavor
821 824 * zero, is always present and reserved as the 'vanilla' flavor.
822 825 * Space for extra flavors can be allocated and private pointers
823 826 * with respect to each flavor set and retrieved.
824 827 *
825 828 * NOTE:For a nexus driver, if the need to support multiple flavors of
826 829 * children is understood from the begining, then a private 'flavor'
827 830 * mechanism can be implemented via ddi_[sg]et_driver_private.
828 831 *
829 832 * With SCSA, the need to support multiple flavors of children was not
830 833 * anticipated, and ddi_get_driver_private(9F) of an initiator port
831 834 * devinfo node was publicly defined in the DDI to return a
832 835 * scsi_device(9S) child-flavor specific value: a pointer to
833 836 * scsi_hba_tran(9S). Over the years, each time the need to support
834 837 * a new flavor of child has occurred, a new form of overload/kludge
835 838 * has been devised. The ndi 'flavors' interfaces provide a simple way
836 839 * to address this issue that can be used by both SCSA nexus support,
837 840 * and by other nexus drivers.
838 841 */
839 842
840 843 /*
841 844 * Interfaces to maintain flavor-specific private data for children of self
842 845 */
843 846 #define NDI_FLAVOR_VANILLA 0
844 847
845 848 void ndi_flavorv_alloc(dev_info_t *self, int nflavors);
846 849 void ndi_flavorv_set(dev_info_t *self, ndi_flavor_t child_flavor, void *);
847 850 void *ndi_flavorv_get(dev_info_t *self, ndi_flavor_t child_flavor);
848 851
849 852 /* Interfaces for 'self' nexus driver to get/set flavor of child */
850 853 void ndi_flavor_set(dev_info_t *child, ndi_flavor_t child_flavor);
851 854 ndi_flavor_t ndi_flavor_get(dev_info_t *child);
852 855
853 856 #endif /* _KERNEL */
854 857
855 858 #ifdef __cplusplus
856 859 }
857 860 #endif
858 861
859 862 #endif /* _SYS_SUNNDI_H */
|
↓ open down ↓ |
522 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX