Print this page
NEX-18214 unplug of multipathed disks doesn't produce EC_DEV_REMOVE/ESC_DISK event
Reviewed by: Rick McNeal <rick.mcneal@nexenta.com>
Reviewed by: Dan Fields <dan.fields@nexenta.com>
Revert "NEX-18214 unplug of multipathed disks doesn't produce EC_DEV_REMOVE/ESC_DISK event"
This reverts commit b0f7e47b60b115c1bb6c07dc5aa150cc519790e7.
NEX-18214 unplug of multipathed disks doesn't produce EC_DEV_REMOVE/ESC_DISK event
Reviewed by: Rick McNeal <rick.mcneal@nexenta.com>
Reviewed by: Dan Fields <dan.fields@nexenta.com>
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>
NEX-17521 Unable to install Nexentastor on Lenovo SR650 platform
8702 PCI addresses with physaddr > 0xffffffff can't be mapped in
8703 pci/npe DDI_CTLOPS_REGSIZE should be 64-bit aware
8704 want OFF_MAX in the kernel
8705 unsupported 64-bit prefetch memory on pci-pci bridge
Contributed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Patrick Mooney <patrick.mooney@joyent.com>
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Albert Lee <trisk@forkgnu.org>
9550 Create hub symlinks for xhci devices
Contributed by: Alexander Pyhalov <apyhalov@gmail.com>
Reviewed by: Andy Stormont <astormont@racktopsystems.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Toomas Soome <tsoome@me.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/uts/common/sys/ddi_impldefs.h
+++ new/usr/src/uts/common/sys/ddi_impldefs.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) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
23 24 * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
24 25 * Copyright 2016 Joyent, Inc.
25 26 * Copyright (c) 2016 by Delphix. All rights reserved.
27 + * Copyright 2018 Nexenta Systems, Inc.
26 28 */
27 29
28 30 #ifndef _SYS_DDI_IMPLDEFS_H
29 31 #define _SYS_DDI_IMPLDEFS_H
30 32
31 33 #include <sys/types.h>
32 34 #include <sys/param.h>
33 35 #include <sys/t_lock.h>
34 36 #include <sys/ddipropdefs.h>
35 37 #include <sys/devops.h>
36 38 #include <sys/autoconf.h>
37 39 #include <sys/mutex.h>
38 40 #include <vm/page.h>
39 41 #include <sys/dacf_impl.h>
40 42 #include <sys/ndifm.h>
41 43 #include <sys/epm.h>
42 44 #include <sys/ddidmareq.h>
43 45 #include <sys/ddi_intr.h>
44 46 #include <sys/ddi_hp.h>
45 47 #include <sys/ddi_hp_impl.h>
46 48 #include <sys/ddi_isa.h>
47 49 #include <sys/id_space.h>
48 50 #include <sys/modhash.h>
49 51 #include <sys/bitset.h>
50 52
51 53 #ifdef __cplusplus
52 54 extern "C" {
53 55 #endif
54 56
55 57 /*
56 58 * The device id implementation has been switched to be based on properties.
57 59 * For compatibility with di_devid libdevinfo interface the following
58 60 * must be defined:
59 61 */
60 62 #define DEVID_COMPATIBILITY ((ddi_devid_t)-1)
61 63
62 64 /*
63 65 * Definitions for node class.
64 66 * DDI_NC_PROM: a node with a nodeid that may be used in a promif call.
65 67 * DDI_NC_PSEUDO: a software created node with a software assigned nodeid.
66 68 */
67 69 typedef enum {
68 70 DDI_NC_PROM = 0,
69 71 DDI_NC_PSEUDO
70 72 } ddi_node_class_t;
71 73
72 74 /*
73 75 * Definitions for generic callback mechanism.
74 76 */
75 77 typedef enum {
76 78 DDI_CB_INTR_ADD, /* More available interrupts */
77 79 DDI_CB_INTR_REMOVE /* Fewer available interrupts */
78 80 } ddi_cb_action_t;
79 81
80 82 typedef enum {
81 83 DDI_CB_FLAG_INTR = 0x1 /* Driver is IRM aware */
82 84 } ddi_cb_flags_t;
83 85
84 86 #define DDI_CB_FLAG_VALID(f) ((f) & DDI_CB_FLAG_INTR)
85 87
86 88 typedef int (*ddi_cb_func_t)(dev_info_t *dip, ddi_cb_action_t action,
87 89 void *cbarg, void *arg1, void *arg2);
88 90
89 91 typedef struct ddi_cb {
90 92 uint64_t cb_flags;
91 93 dev_info_t *cb_dip;
92 94 ddi_cb_func_t cb_func;
93 95 void *cb_arg1;
94 96 void *cb_arg2;
95 97 } ddi_cb_t;
96 98
97 99 /*
98 100 * dev_info: The main device information structure this is intended to be
99 101 * opaque to drivers and drivers should use ddi functions to
100 102 * access *all* driver accessible fields.
101 103 *
102 104 * devi_parent_data includes property lists (interrupts, registers, etc.)
103 105 * devi_driver_data includes whatever the driver wants to place there.
104 106 */
105 107 struct devinfo_audit;
106 108
107 109 typedef struct devi_port {
108 110 union {
109 111 struct {
110 112 uint32_t type;
111 113 uint32_t pad;
112 114 } port;
113 115 uint64_t type64;
114 116 } info;
115 117 void *priv_p;
116 118 } devi_port_t;
117 119
118 120 typedef struct devi_bus_priv {
119 121 devi_port_t port_up;
120 122 devi_port_t port_down;
121 123 } devi_bus_priv_t;
122 124
123 125 #if defined(__x86)
124 126 struct iommulib_unit;
125 127 typedef struct iommulib_unit *iommulib_handle_t;
126 128 struct iommulib_nex;
127 129 typedef struct iommulib_nex *iommulib_nexhandle_t;
128 130 #endif
129 131
130 132 typedef uint8_t ndi_flavor_t;
131 133 struct ddi_hp_cn_handle;
132 134
133 135 struct in_node;
134 136
135 137 struct dev_info {
136 138
137 139 struct dev_info *devi_parent; /* my parent node in tree */
138 140 struct dev_info *devi_child; /* my child list head */
139 141 struct dev_info *devi_sibling; /* next element on my level */
140 142
141 143 char *devi_binding_name; /* name used to bind driver: */
142 144 /* shared storage, points to */
143 145 /* devi_node_name, devi_compat_names */
144 146 /* or devi_rebinding_name */
145 147
146 148 char *devi_addr; /* address part of name */
147 149
148 150 int devi_nodeid; /* device nodeid */
149 151 int devi_instance; /* device instance number */
150 152
151 153 struct dev_ops *devi_ops; /* driver operations */
152 154
153 155 void *devi_parent_data; /* parent private data */
154 156 void *devi_driver_data; /* driver private data */
155 157
156 158 ddi_prop_t *devi_drv_prop_ptr; /* head of driver prop list */
157 159 ddi_prop_t *devi_sys_prop_ptr; /* head of system prop list */
158 160
159 161 struct ddi_minor_data *devi_minor; /* head of minor list */
160 162 struct dev_info *devi_next; /* Next instance of this device */
161 163 kmutex_t devi_lock; /* Protects per-devinfo data */
162 164
163 165 /* logical parents for busop primitives */
164 166
165 167 struct dev_info *devi_bus_map_fault; /* bus_map_fault parent */
166 168 void *devi_obsolete; /* obsolete placeholder */
167 169 struct dev_info *devi_bus_dma_allochdl; /* bus_dma_newhdl parent */
168 170 struct dev_info *devi_bus_dma_freehdl; /* bus_dma_freehdl parent */
169 171 struct dev_info *devi_bus_dma_bindhdl; /* bus_dma_bindhdl parent */
170 172 struct dev_info *devi_bus_dma_unbindhdl; /* bus_dma_unbindhdl parent */
171 173 struct dev_info *devi_bus_dma_flush; /* bus_dma_flush parent */
172 174 struct dev_info *devi_bus_dma_win; /* bus_dma_win parent */
173 175 struct dev_info *devi_bus_dma_ctl; /* bus_dma_ctl parent */
174 176 struct dev_info *devi_bus_ctl; /* bus_ctl parent */
175 177
176 178 ddi_prop_t *devi_hw_prop_ptr; /* head of hw prop list */
177 179
178 180 char *devi_node_name; /* The 'name' of the node */
179 181 char *devi_compat_names; /* A list of driver names */
180 182 size_t devi_compat_length; /* Size of compat_names */
181 183
182 184 int (*devi_bus_dma_bindfunc)(dev_info_t *, dev_info_t *,
183 185 ddi_dma_handle_t, struct ddi_dma_req *, ddi_dma_cookie_t *,
184 186 uint_t *);
185 187 int (*devi_bus_dma_unbindfunc)(dev_info_t *, dev_info_t *,
186 188 ddi_dma_handle_t);
187 189
188 190 char *devi_devid_str; /* registered device id */
189 191
190 192 /*
191 193 * power management entries
192 194 * components exist even if the device is not currently power managed
193 195 */
194 196 struct pm_info *devi_pm_info; /* 0 => dev not power managed */
195 197 uint_t devi_pm_flags; /* pm flags */
196 198 int devi_pm_num_components; /* number of components */
197 199 size_t devi_pm_comp_size; /* size of devi_components */
198 200 struct pm_component *devi_pm_components; /* array of pm components */
199 201 struct dev_info *devi_pm_ppm; /* ppm attached to this one */
200 202 void *devi_pm_ppm_private; /* for use by ppm driver */
201 203 int devi_pm_dev_thresh; /* "device" threshold */
202 204 uint_t devi_pm_kidsupcnt; /* # of kids powered up */
203 205 struct pm_scan *devi_pm_scan; /* pm scan info */
204 206 uint_t devi_pm_noinvolpm; /* # of descendents no-invol */
205 207 uint_t devi_pm_volpmd; /* # of voluntarily pm'ed */
206 208 kmutex_t devi_pm_lock; /* pm lock for state */
207 209 kmutex_t devi_pm_busy_lock; /* for component busy count */
208 210
209 211 uint_t devi_state; /* device/bus state flags */
210 212 /* see below for definitions */
211 213 kcondvar_t devi_cv; /* cv */
212 214 int devi_ref; /* reference count */
213 215
214 216 dacf_rsrvlist_t *devi_dacf_tasks; /* dacf reservation queue */
215 217
216 218 ddi_node_class_t devi_node_class; /* Node class */
217 219 int devi_node_attributes; /* Node attributes: See below */
218 220
219 221 char *devi_device_class;
220 222
221 223 /*
222 224 * New mpxio kernel hooks entries
223 225 */
224 226 int devi_mdi_component; /* mpxio component type */
225 227 void *devi_mdi_client; /* mpxio client information */
226 228 void *devi_mdi_xhci; /* vhci/phci info */
227 229
228 230 ddi_prop_list_t *devi_global_prop_list; /* driver global properties */
229 231 major_t devi_major; /* driver major number */
230 232 ddi_node_state_t devi_node_state; /* state of node */
231 233 uint_t devi_flags; /* configuration flags */
232 234 int devi_circular; /* for recursive operations */
233 235 void *devi_busy_thread; /* thread operating on node */
234 236 void *devi_taskq; /* hotplug taskq */
235 237
236 238 /* device driver statistical and audit info */
237 239 struct devinfo_audit *devi_audit; /* last state change */
238 240
239 241 /*
240 242 * FMA support for resource caches and error handlers
241 243 */
242 244 struct i_ddi_fmhdl *devi_fmhdl;
243 245
244 246 uint_t devi_cpr_flags;
245 247
246 248 /* Owned by DDI interrupt framework */
247 249 devinfo_intr_t *devi_intr_p;
248 250
249 251 void *devi_nex_pm; /* nexus PM private */
250 252
251 253 char *devi_addr_buf; /* buffer for devi_addr */
252 254
253 255 char *devi_rebinding_name; /* binding_name of rebind */
254 256
255 257 /* For device contracts that have this dip's minor node as resource */
256 258 kmutex_t devi_ct_lock; /* contract lock */
257 259 kcondvar_t devi_ct_cv; /* contract cv */
258 260 int devi_ct_count; /* # of outstanding responses */
259 261 int devi_ct_neg; /* neg. occurred on dip */
260 262 list_t devi_ct;
261 263
262 264 /* owned by bus framework */
263 265 devi_bus_priv_t devi_bus; /* bus private data */
264 266
265 267 /* Declarations of the pure dynamic properties to snapshot */
266 268 struct i_ddi_prop_dyn *devi_prop_dyn_driver; /* prop_op */
267 269 struct i_ddi_prop_dyn *devi_prop_dyn_parent; /* bus_prop_op */
268 270
269 271 #if defined(__x86)
270 272 /* For x86 (Intel and AMD) IOMMU support */
271 273 void *devi_iommu;
272 274 iommulib_handle_t devi_iommulib_handle;
273 275 iommulib_nexhandle_t devi_iommulib_nex_handle;
274 276 #endif
275 277
276 278 /* Generic callback mechanism */
277 279 ddi_cb_t *devi_cb_p;
|
↓ open down ↓ |
242 lines elided |
↑ open up ↑ |
278 280
279 281 /* ndi 'flavors' */
280 282 ndi_flavor_t devi_flavor; /* flavor assigned by parent */
281 283 ndi_flavor_t devi_flavorv_n; /* number of child-flavors */
282 284 void **devi_flavorv; /* child-flavor specific data */
283 285
284 286 /* Owned by hotplug framework */
285 287 struct ddi_hp_cn_handle *devi_hp_hdlp; /* hotplug handle list */
286 288
287 289 struct in_node *devi_in_node; /* pointer to devinfo node's in_node_t */
288 -
289 - /* detach event data */
290 - char *devi_ev_path;
291 - int devi_ev_instance;
292 290 };
293 291
294 292 #define DEVI(dev_info_type) ((struct dev_info *)(dev_info_type))
295 293
296 294 /*
297 295 * NB: The 'name' field, for compatibility with old code (both existing
298 296 * device drivers and userland code), is now defined as the name used
299 297 * to bind the node to a device driver, and not the device node name.
300 298 * If the device node name does not define a binding to a device driver,
301 299 * and the framework uses a different algorithm to create the binding to
302 300 * the driver, the node name and binding name will be different.
303 301 *
304 302 * Note that this implies that the node name plus instance number does
305 303 * NOT create a unique driver id; only the binding name plus instance
306 304 * number creates a unique driver id.
307 305 *
308 306 * New code should not use 'devi_name'; use 'devi_binding_name' or
309 307 * 'devi_node_name' and/or the routines that access those fields.
310 308 */
311 309
312 310 #define devi_name devi_binding_name
313 311
314 312 /*
315 313 * DDI_CF1, DDI_CF2 and DDI_DRV_UNLOADED are obsolete. They are kept
316 314 * around to allow legacy drivers to to compile.
317 315 */
318 316 #define DDI_CF1(devi) (DEVI(devi)->devi_addr != NULL)
319 317 #define DDI_CF2(devi) (DEVI(devi)->devi_ops != NULL)
320 318 #define DDI_DRV_UNLOADED(devi) (DEVI(devi)->devi_ops == &mod_nodev_ops)
321 319
322 320 /*
323 321 * The device state flags (devi_state) contains information regarding
324 322 * the state of the device (Online/Offline/Down). For bus nexus
325 323 * devices, the device state also contains state information regarding
326 324 * the state of the bus represented by this nexus node.
327 325 *
328 326 * Device state information is stored in bits [0-7], bus state in bits
329 327 * [8-15].
330 328 *
331 329 * NOTE: all devi_state updates should be protected by devi_lock.
332 330 */
333 331 #define DEVI_DEVICE_OFFLINE 0x00000001
334 332 #define DEVI_DEVICE_DOWN 0x00000002
335 333 #define DEVI_DEVICE_DEGRADED 0x00000004
336 334 #define DEVI_DEVICE_REMOVED 0x00000008 /* hardware removed */
337 335
338 336 #define DEVI_BUS_QUIESCED 0x00000100
339 337 #define DEVI_BUS_DOWN 0x00000200
340 338 #define DEVI_NDI_CONFIG 0x00000400 /* perform config when attaching */
341 339
342 340 #define DEVI_S_ATTACHING 0x00010000
343 341 #define DEVI_S_DETACHING 0x00020000
344 342 #define DEVI_S_ONLINING 0x00040000
345 343 #define DEVI_S_OFFLINING 0x00080000
346 344
347 345 #define DEVI_S_INVOKING_DACF 0x00100000 /* busy invoking a dacf task */
348 346
349 347 #define DEVI_S_UNBOUND 0x00200000
350 348 #define DEVI_S_REPORT 0x08000000 /* report status change */
351 349
352 350 #define DEVI_S_EVADD 0x10000000 /* state of devfs event */
353 351 #define DEVI_S_EVREMOVE 0x20000000 /* state of devfs event */
354 352 #define DEVI_S_NEED_RESET 0x40000000 /* devo_reset should be called */
355 353
356 354 /*
357 355 * Device state macros.
358 356 * o All SET/CLR/DONE users must protect context with devi_lock.
359 357 * o DEVI_SET_DEVICE_ONLINE users must do their own DEVI_SET_REPORT.
360 358 * o DEVI_SET_DEVICE_{DOWN|DEGRADED|UP} should only be used when !OFFLINE.
361 359 * o DEVI_SET_DEVICE_UP clears DOWN and DEGRADED.
362 360 */
363 361 #define DEVI_IS_DEVICE_OFFLINE(dip) \
364 362 ((DEVI(dip)->devi_state & DEVI_DEVICE_OFFLINE) == DEVI_DEVICE_OFFLINE)
365 363
366 364 #define DEVI_SET_DEVICE_ONLINE(dip) { \
367 365 ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \
368 366 if (DEVI(dip)->devi_state & DEVI_DEVICE_DEGRADED) { \
369 367 mutex_exit(&DEVI(dip)->devi_lock); \
370 368 e_ddi_undegrade_finalize(dip); \
371 369 mutex_enter(&DEVI(dip)->devi_lock); \
372 370 } \
373 371 /* setting ONLINE clears DOWN, DEGRADED, OFFLINE */ \
374 372 DEVI(dip)->devi_state &= ~(DEVI_DEVICE_DOWN | \
375 373 DEVI_DEVICE_DEGRADED | DEVI_DEVICE_OFFLINE); \
376 374 }
377 375
378 376 #define DEVI_SET_DEVICE_OFFLINE(dip) { \
379 377 ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \
380 378 DEVI(dip)->devi_state |= (DEVI_DEVICE_OFFLINE | DEVI_S_REPORT); \
381 379 }
382 380
383 381 #define DEVI_IS_DEVICE_DOWN(dip) \
384 382 ((DEVI(dip)->devi_state & DEVI_DEVICE_DOWN) == DEVI_DEVICE_DOWN)
385 383
386 384 #define DEVI_SET_DEVICE_DOWN(dip) { \
387 385 ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \
388 386 ASSERT(!DEVI_IS_DEVICE_OFFLINE(dip)); \
389 387 DEVI(dip)->devi_state |= (DEVI_DEVICE_DOWN | DEVI_S_REPORT); \
390 388 }
391 389
392 390 #define DEVI_IS_DEVICE_DEGRADED(dip) \
393 391 ((DEVI(dip)->devi_state & \
394 392 (DEVI_DEVICE_DEGRADED|DEVI_DEVICE_DOWN)) == DEVI_DEVICE_DEGRADED)
395 393
396 394 #define DEVI_SET_DEVICE_DEGRADED(dip) { \
397 395 ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \
398 396 ASSERT(!DEVI_IS_DEVICE_OFFLINE(dip)); \
399 397 mutex_exit(&DEVI(dip)->devi_lock); \
400 398 e_ddi_degrade_finalize(dip); \
401 399 mutex_enter(&DEVI(dip)->devi_lock); \
402 400 DEVI(dip)->devi_state |= (DEVI_DEVICE_DEGRADED | DEVI_S_REPORT); \
403 401 }
404 402
405 403 #define DEVI_SET_DEVICE_UP(dip) { \
406 404 ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \
407 405 ASSERT(!DEVI_IS_DEVICE_OFFLINE(dip)); \
408 406 if (DEVI(dip)->devi_state & DEVI_DEVICE_DEGRADED) { \
409 407 mutex_exit(&DEVI(dip)->devi_lock); \
410 408 e_ddi_undegrade_finalize(dip); \
411 409 mutex_enter(&DEVI(dip)->devi_lock); \
412 410 } \
413 411 DEVI(dip)->devi_state &= ~(DEVI_DEVICE_DEGRADED | DEVI_DEVICE_DOWN); \
414 412 DEVI(dip)->devi_state |= DEVI_S_REPORT; \
415 413 }
416 414
417 415 /* Device removal and insertion */
418 416 #define DEVI_IS_DEVICE_REMOVED(dip) \
419 417 ((DEVI(dip)->devi_state & DEVI_DEVICE_REMOVED) == DEVI_DEVICE_REMOVED)
420 418
421 419 #define DEVI_SET_DEVICE_REMOVED(dip) { \
422 420 ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \
423 421 DEVI(dip)->devi_state |= DEVI_DEVICE_REMOVED | DEVI_S_REPORT; \
424 422 }
425 423
426 424 #define DEVI_SET_DEVICE_REINSERTED(dip) { \
427 425 ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \
428 426 DEVI(dip)->devi_state &= ~DEVI_DEVICE_REMOVED; \
429 427 DEVI(dip)->devi_state |= DEVI_S_REPORT; \
430 428 }
431 429
432 430 /* Bus state change macros */
433 431 #define DEVI_IS_BUS_QUIESCED(dip) \
434 432 ((DEVI(dip)->devi_state & DEVI_BUS_QUIESCED) == DEVI_BUS_QUIESCED)
435 433
436 434 #define DEVI_SET_BUS_ACTIVE(dip) { \
437 435 ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \
438 436 DEVI(dip)->devi_state &= ~DEVI_BUS_QUIESCED; \
439 437 DEVI(dip)->devi_state |= DEVI_S_REPORT; \
440 438 }
441 439
442 440 #define DEVI_SET_BUS_QUIESCE(dip) { \
443 441 ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \
444 442 DEVI(dip)->devi_state |= (DEVI_BUS_QUIESCED | DEVI_S_REPORT); \
445 443 }
446 444
447 445 #define DEVI_IS_BUS_DOWN(dip) \
448 446 ((DEVI(dip)->devi_state & DEVI_BUS_DOWN) == DEVI_BUS_DOWN)
449 447
450 448 #define DEVI_SET_BUS_UP(dip) { \
451 449 ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \
452 450 DEVI(dip)->devi_state &= ~DEVI_BUS_DOWN; \
453 451 DEVI(dip)->devi_state |= DEVI_S_REPORT; \
454 452 }
455 453
456 454 #define DEVI_SET_BUS_DOWN(dip) { \
457 455 ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \
458 456 DEVI(dip)->devi_state |= (DEVI_BUS_DOWN | DEVI_S_REPORT); \
459 457 }
460 458
461 459 /* Status change report needed */
462 460 #define DEVI_NEED_REPORT(dip) \
463 461 ((DEVI(dip)->devi_state & DEVI_S_REPORT) == DEVI_S_REPORT)
464 462
465 463 #define DEVI_SET_REPORT(dip) { \
466 464 ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \
467 465 DEVI(dip)->devi_state |= DEVI_S_REPORT; \
468 466 }
469 467
470 468 #define DEVI_REPORT_DONE(dip) { \
471 469 ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \
472 470 DEVI(dip)->devi_state &= ~DEVI_S_REPORT; \
473 471 }
474 472
475 473 /* Do an NDI_CONFIG for its children */
476 474 #define DEVI_NEED_NDI_CONFIG(dip) \
477 475 ((DEVI(dip)->devi_state & DEVI_NDI_CONFIG) == DEVI_NDI_CONFIG)
478 476
479 477 #define DEVI_SET_NDI_CONFIG(dip) { \
480 478 ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \
481 479 DEVI(dip)->devi_state |= DEVI_NDI_CONFIG; \
482 480 }
483 481
484 482 #define DEVI_CLR_NDI_CONFIG(dip) { \
485 483 ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \
486 484 DEVI(dip)->devi_state &= ~DEVI_NDI_CONFIG; \
487 485 }
488 486
489 487 /* Attaching or detaching state */
490 488 #define DEVI_IS_ATTACHING(dip) \
491 489 ((DEVI(dip)->devi_state & DEVI_S_ATTACHING) == DEVI_S_ATTACHING)
492 490
493 491 #define DEVI_SET_ATTACHING(dip) { \
494 492 ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \
495 493 DEVI(dip)->devi_state |= DEVI_S_ATTACHING; \
496 494 }
497 495
498 496 #define DEVI_CLR_ATTACHING(dip) { \
499 497 ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \
500 498 DEVI(dip)->devi_state &= ~DEVI_S_ATTACHING; \
501 499 }
502 500
503 501 #define DEVI_IS_DETACHING(dip) \
504 502 ((DEVI(dip)->devi_state & DEVI_S_DETACHING) == DEVI_S_DETACHING)
505 503
506 504 #define DEVI_SET_DETACHING(dip) { \
507 505 ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \
508 506 DEVI(dip)->devi_state |= DEVI_S_DETACHING; \
509 507 }
510 508
511 509 #define DEVI_CLR_DETACHING(dip) { \
512 510 ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \
513 511 DEVI(dip)->devi_state &= ~DEVI_S_DETACHING; \
514 512 }
515 513
516 514 /* Onlining or offlining state */
517 515 #define DEVI_IS_ONLINING(dip) \
518 516 ((DEVI(dip)->devi_state & DEVI_S_ONLINING) == DEVI_S_ONLINING)
519 517
520 518 #define DEVI_SET_ONLINING(dip) { \
521 519 ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \
522 520 DEVI(dip)->devi_state |= DEVI_S_ONLINING; \
523 521 }
524 522
525 523 #define DEVI_CLR_ONLINING(dip) { \
526 524 ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \
527 525 DEVI(dip)->devi_state &= ~DEVI_S_ONLINING; \
528 526 }
529 527
530 528 #define DEVI_IS_OFFLINING(dip) \
531 529 ((DEVI(dip)->devi_state & DEVI_S_OFFLINING) == DEVI_S_OFFLINING)
532 530
533 531 #define DEVI_SET_OFFLINING(dip) { \
534 532 ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \
535 533 DEVI(dip)->devi_state |= DEVI_S_OFFLINING; \
536 534 }
537 535
538 536 #define DEVI_CLR_OFFLINING(dip) { \
539 537 ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \
540 538 DEVI(dip)->devi_state &= ~DEVI_S_OFFLINING; \
541 539 }
542 540
543 541 #define DEVI_IS_IN_RECONFIG(dip) \
544 542 (DEVI(dip)->devi_state & (DEVI_S_OFFLINING | DEVI_S_ONLINING))
545 543
546 544 /* Busy invoking a dacf task against this node */
547 545 #define DEVI_IS_INVOKING_DACF(dip) \
548 546 ((DEVI(dip)->devi_state & DEVI_S_INVOKING_DACF) == DEVI_S_INVOKING_DACF)
549 547
550 548 #define DEVI_SET_INVOKING_DACF(dip) { \
551 549 ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \
552 550 DEVI(dip)->devi_state |= DEVI_S_INVOKING_DACF; \
553 551 }
554 552
555 553 #define DEVI_CLR_INVOKING_DACF(dip) { \
556 554 ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \
557 555 DEVI(dip)->devi_state &= ~DEVI_S_INVOKING_DACF; \
558 556 }
559 557
560 558 /* Events for add/remove */
561 559 #define DEVI_EVADD(dip) \
562 560 ((DEVI(dip)->devi_state & DEVI_S_EVADD) == DEVI_S_EVADD)
563 561
564 562 #define DEVI_SET_EVADD(dip) { \
565 563 ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \
566 564 DEVI(dip)->devi_state &= ~DEVI_S_EVREMOVE; \
567 565 DEVI(dip)->devi_state |= DEVI_S_EVADD; \
568 566 }
569 567
570 568 #define DEVI_EVREMOVE(dip) \
571 569 ((DEVI(dip)->devi_state & DEVI_S_EVREMOVE) == DEVI_S_EVREMOVE)
572 570
573 571 #define DEVI_SET_EVREMOVE(dip) { \
574 572 ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \
575 573 DEVI(dip)->devi_state &= ~DEVI_S_EVADD; \
576 574 DEVI(dip)->devi_state |= DEVI_S_EVREMOVE; \
577 575 }
578 576
579 577 #define DEVI_SET_EVUNINIT(dip) { \
580 578 ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \
581 579 DEVI(dip)->devi_state &= ~(DEVI_S_EVADD | DEVI_S_EVREMOVE); \
582 580 }
583 581
584 582 /* Need to call the devo_reset entry point for this device at shutdown */
585 583 #define DEVI_NEED_RESET(dip) \
586 584 ((DEVI(dip)->devi_state & DEVI_S_NEED_RESET) == DEVI_S_NEED_RESET)
587 585
588 586 #define DEVI_SET_NEED_RESET(dip) { \
589 587 ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \
590 588 DEVI(dip)->devi_state |= DEVI_S_NEED_RESET; \
591 589 }
592 590
593 591 #define DEVI_CLR_NEED_RESET(dip) { \
594 592 ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \
595 593 DEVI(dip)->devi_state &= ~DEVI_S_NEED_RESET; \
596 594 }
597 595
598 596 /*
599 597 * devi_flags bits
600 598 *
601 599 * NOTE: all devi_state updates should be protected by devi_lock.
602 600 */
603 601 #define DEVI_BUSY 0x00000001 /* busy configuring children */
604 602 #define DEVI_MADE_CHILDREN 0x00000002 /* children made from specs */
605 603 #define DEVI_ATTACHED_CHILDREN 0x00000004 /* attached all existing children */
606 604 #define DEVI_BRANCH_HELD 0x00000008 /* branch rooted at this dip held */
|
↓ open down ↓ |
305 lines elided |
↑ open up ↑ |
607 605 #define DEVI_NO_BIND 0x00000010 /* prevent driver binding */
608 606 #define DEVI_CACHED_DEVID 0x00000020 /* devid cached in devid cache */
609 607 #define DEVI_PHCI_SIGNALS_VHCI 0x00000040 /* pHCI ndi_devi_exit signals vHCI */
610 608 #define DEVI_REBIND 0x00000080 /* post initchild driver rebind */
611 609 #define DEVI_RETIRED 0x00000100 /* device is retired */
612 610 #define DEVI_RETIRING 0x00000200 /* being evaluated for retire */
613 611 #define DEVI_R_CONSTRAINT 0x00000400 /* constraints have been applied */
614 612 #define DEVI_R_BLOCKED 0x00000800 /* constraints block retire */
615 613 #define DEVI_CT_NOP 0x00001000 /* NOP contract event occurred */
616 614 #define DEVI_PCI_DEVICE 0x00002000 /* dip is PCI */
615 +#define DEVI_GONE 0x00004000 /* device is physically removed */
617 616
618 617 #define DEVI_BUSY_CHANGING(dip) (DEVI(dip)->devi_flags & DEVI_BUSY)
619 618 #define DEVI_BUSY_OWNED(dip) (DEVI_BUSY_CHANGING(dip) && \
620 619 ((DEVI(dip))->devi_busy_thread == curthread))
621 620
622 621 #define DEVI_IS_PCI(dip) (DEVI(dip)->devi_flags & DEVI_PCI_DEVICE)
623 622 #define DEVI_SET_PCI(dip) (DEVI(dip)->devi_flags |= (DEVI_PCI_DEVICE))
624 623
624 +#define DEVI_IS_GONE(dip) (DEVI(dip)->devi_flags & DEVI_GONE)
625 +#define DEVI_SET_GONE(dip) (DEVI(dip)->devi_flags |= DEVI_GONE)
626 +#define DEVI_UNSET_GONE(dip) (DEVI(dip)->devi_flags &= ~DEVI_GONE)
627 +
625 628 char *i_ddi_devi_class(dev_info_t *);
626 629 int i_ddi_set_devi_class(dev_info_t *, char *, int);
627 630
628 631 /*
629 632 * This structure represents one piece of bus space occupied by a given
630 633 * device. It is used in an array for devices with multiple address windows.
631 634 */
632 635 struct regspec {
633 636 uint_t regspec_bustype; /* cookie for bus type it's on */
634 637 uint_t regspec_addr; /* address of reg relative to bus */
635 638 uint_t regspec_size; /* size of this register set */
636 639 };
637 640
638 641 /*
639 642 * This is a version of the above structure that works for 64-bit mappings and
640 643 * doesn't rely on overloading of fields as is done on SPARC. Eventually the
641 644 * struct regspec should be replaced with this.
642 645 */
643 646 struct regspec64 {
644 647 uint64_t regspec_bustype; /* cookie for bus type it's on */
645 648 uint64_t regspec_addr; /* address of reg relative to bus */
646 649 uint64_t regspec_size; /* size of this register set */
647 650 };
648 651
649 652 /*
650 653 * This structure represents one piece of nexus bus space.
651 654 * It is used in an array for nexi with multiple bus spaces
652 655 * to define the childs offsets in the parents bus space.
653 656 */
654 657 struct rangespec {
655 658 uint_t rng_cbustype; /* Child's address, hi order */
656 659 uint_t rng_coffset; /* Child's address, lo order */
657 660 uint_t rng_bustype; /* Parent's address, hi order */
658 661 uint_t rng_offset; /* Parent's address, lo order */
659 662 uint_t rng_size; /* size of space for this entry */
660 663 };
661 664
662 665 #ifdef _KERNEL
663 666
664 667 typedef enum {
665 668 DDI_PRE = 0,
666 669 DDI_POST = 1
667 670 } ddi_pre_post_t;
668 671
669 672 /*
670 673 * This structure represents notification of a child attach event
671 674 * These could both be the same if attach/detach commands were in the
672 675 * same name space.
673 676 * Note that the target dip is passed as an arg already.
674 677 */
675 678 struct attachspec {
676 679 ddi_attach_cmd_t cmd; /* type of event */
677 680 ddi_pre_post_t when; /* one of DDI_PRE or DDI_POST */
678 681 dev_info_t *pdip; /* parent of attaching node */
679 682 int result; /* result of attach op (post command only) */
680 683 };
681 684
682 685 /*
683 686 * This structure represents notification of a child detach event
684 687 * Note that the target dip is passed as an arg already.
685 688 */
686 689 struct detachspec {
687 690 ddi_detach_cmd_t cmd; /* type of event */
688 691 ddi_pre_post_t when; /* one of DDI_PRE or DDI_POST */
689 692 dev_info_t *pdip; /* parent of detaching node */
690 693 int result; /* result of detach op (post command only) */
691 694 };
692 695
693 696 #endif /* _KERNEL */
694 697
695 698 typedef enum {
696 699 DDM_MINOR = 0,
697 700 DDM_ALIAS,
698 701 DDM_DEFAULT,
699 702 DDM_INTERNAL_PATH
700 703 } ddi_minor_type;
701 704
702 705 /* implementation flags for driver specified device access control */
703 706 #define DM_NO_FSPERM 0x1
704 707
705 708 struct devplcy;
706 709
707 710 struct ddi_minor {
708 711 char *name; /* name of node */
709 712 dev_t dev; /* device number */
710 713 int spec_type; /* block or char */
711 714 int flags; /* access flags */
712 715 char *node_type; /* block, byte, serial, network */
713 716 struct devplcy *node_priv; /* privilege for this minor */
714 717 mode_t priv_mode; /* default apparent privilege mode */
715 718 };
716 719
717 720 /*
718 721 * devi_node_attributes contains node attributes private to the
719 722 * ddi implementation. As a consumer, do not use these bit definitions
720 723 * directly, use the ndi functions that check for the existence of the
721 724 * specific node attributes.
722 725 *
723 726 * DDI_PERSISTENT indicates a 'persistent' node; one that is not
724 727 * automatically freed by the framework if the driver is unloaded
725 728 * or the driver fails to attach to this node.
726 729 *
727 730 * DDI_AUTO_ASSIGNED_NODEID indicates that the nodeid was auto-assigned
728 731 * by the framework and should be auto-freed if the node is removed.
729 732 *
730 733 * DDI_VHCI_NODE indicates that the node type is VHCI. This flag
731 734 * must be set by ndi_devi_config_vhci() routine only.
732 735 *
733 736 * DDI_HIDDEN_NODE indicates that the node should not show up in snapshots
734 737 * or in /devices.
735 738 *
736 739 * DDI_HOTPLUG_NODE indicates that the node created by nexus hotplug.
737 740 */
738 741 #define DDI_PERSISTENT 0x01
739 742 #define DDI_AUTO_ASSIGNED_NODEID 0x02
740 743 #define DDI_VHCI_NODE 0x04
741 744 #define DDI_HIDDEN_NODE 0x08
742 745 #define DDI_HOTPLUG_NODE 0x10
743 746
744 747 #define DEVI_VHCI_NODE(dip) \
745 748 (DEVI(dip)->devi_node_attributes & DDI_VHCI_NODE)
746 749
747 750 /*
748 751 * The ddi_minor_data structure gets filled in by ddi_create_minor_node.
749 752 * It then gets attached to the devinfo node as a property.
750 753 */
751 754 struct ddi_minor_data {
752 755 struct ddi_minor_data *next; /* next one in the chain */
753 756 dev_info_t *dip; /* pointer to devinfo node */
754 757 ddi_minor_type type; /* Following data type */
755 758 struct ddi_minor d_minor; /* Actual minor node data */
756 759 };
757 760
758 761 #define ddm_name d_minor.name
759 762 #define ddm_dev d_minor.dev
760 763 #define ddm_flags d_minor.flags
761 764 #define ddm_spec_type d_minor.spec_type
762 765 #define ddm_node_type d_minor.node_type
763 766 #define ddm_node_priv d_minor.node_priv
764 767 #define ddm_priv_mode d_minor.priv_mode
765 768
766 769 /*
767 770 * parent private data structure contains register, interrupt, property
768 771 * and range information.
769 772 */
770 773 struct ddi_parent_private_data {
771 774 int par_nreg; /* number of regs */
772 775 struct regspec *par_reg; /* array of regs */
773 776 int par_nintr; /* number of interrupts */
774 777 struct intrspec *par_intr; /* array of possible interrupts */
775 778 int par_nrng; /* number of ranges */
776 779 struct rangespec *par_rng; /* array of ranges */
777 780 };
778 781 #define DEVI_PD(d) \
779 782 ((struct ddi_parent_private_data *)DEVI((d))->devi_parent_data)
780 783
781 784 #define sparc_pd_getnreg(dev) (DEVI_PD(dev)->par_nreg)
782 785 #define sparc_pd_getnintr(dev) (DEVI_PD(dev)->par_nintr)
783 786 #define sparc_pd_getnrng(dev) (DEVI_PD(dev)->par_nrng)
784 787 #define sparc_pd_getreg(dev, n) (&DEVI_PD(dev)->par_reg[(n)])
785 788 #define sparc_pd_getintr(dev, n) (&DEVI_PD(dev)->par_intr[(n)])
786 789 #define sparc_pd_getrng(dev, n) (&DEVI_PD(dev)->par_rng[(n)])
787 790
788 791 #ifdef _KERNEL
789 792 /*
790 793 * This data structure is private to the indexed soft state allocator.
791 794 */
792 795 typedef struct i_ddi_soft_state {
793 796 void **array; /* the array of pointers */
794 797 kmutex_t lock; /* serialize access to this struct */
795 798 size_t size; /* how many bytes per state struct */
796 799 size_t n_items; /* how many structs herein */
797 800 struct i_ddi_soft_state *next; /* 'dirty' elements */
798 801 } i_ddi_soft_state;
799 802
800 803 /*
801 804 * This data structure is private to the stringhashed soft state allocator.
802 805 */
803 806 typedef struct i_ddi_soft_state_bystr {
804 807 size_t ss_size; /* how many bytes per state struct */
805 808 mod_hash_t *ss_mod_hash; /* hash implementation */
806 809 } i_ddi_soft_state_bystr;
807 810
808 811 /*
809 812 * This data structure is private to the ddi_strid_* implementation
810 813 */
811 814 typedef struct i_ddi_strid {
812 815 size_t strid_chunksz;
813 816 size_t strid_spacesz;
814 817 id_space_t *strid_space;
815 818 mod_hash_t *strid_byid;
816 819 mod_hash_t *strid_bystr;
817 820 } i_ddi_strid;
818 821 #endif /* _KERNEL */
819 822
820 823 /*
821 824 * Solaris DDI DMA implementation structure and function definitions.
822 825 *
823 826 * Note: no callers of DDI functions must depend upon data structures
824 827 * declared below. They are not guaranteed to remain constant.
825 828 */
826 829
827 830 /*
828 831 * Implementation DMA mapping structure.
829 832 *
830 833 * The publicly visible ddi_dma_req structure is filled
831 834 * in by a caller that wishes to map a memory object
832 835 * for DMA. Internal to this implementation of the public
833 836 * DDI DMA functions this request structure is put together
834 837 * with bus nexus specific functions that have additional
835 838 * information and constraints as to how to go about doing
836 839 * the requested mapping function
837 840 *
838 841 * In this implementation, some of the information from the
839 842 * original requester is retained throughout the lifetime
840 843 * of the I/O mapping being active.
841 844 */
842 845
843 846 /*
844 847 * This is the implementation specific description
845 848 * of how we've mapped an object for DMA.
846 849 */
847 850 #if defined(__sparc)
848 851 typedef struct ddi_dma_impl {
849 852 /*
850 853 * DMA mapping information
851 854 */
852 855 ulong_t dmai_mapping; /* mapping cookie */
853 856
854 857 /*
855 858 * Size of the current mapping, in bytes.
856 859 *
857 860 * Note that this is distinct from the size of the object being mapped
858 861 * for DVMA. We might have only a portion of the object mapped at any
859 862 * given point in time.
860 863 */
861 864 uint_t dmai_size;
862 865
863 866 /*
864 867 * Offset, in bytes, into object that is currently mapped.
865 868 */
866 869 off_t dmai_offset;
867 870
868 871 /*
869 872 * Information gathered from the original DMA mapping
870 873 * request and saved for the lifetime of the mapping.
871 874 */
872 875 uint_t dmai_minxfer;
873 876 uint_t dmai_burstsizes;
874 877 uint_t dmai_ndvmapages;
875 878 uint_t dmai_pool; /* cached DVMA space */
876 879 uint_t dmai_rflags; /* requester's flags + ours */
877 880 uint_t dmai_inuse; /* active handle? */
878 881 uint_t dmai_nwin;
879 882 uint_t dmai_winsize;
880 883 caddr_t dmai_nexus_private;
881 884 void *dmai_iopte;
882 885 uint_t *dmai_sbi;
883 886 void *dmai_minfo; /* random mapping information */
884 887 dev_info_t *dmai_rdip; /* original requester's dev_info_t */
885 888 ddi_dma_obj_t dmai_object; /* requester's object */
886 889 ddi_dma_attr_t dmai_attr; /* DMA attributes */
887 890 ddi_dma_cookie_t *dmai_cookie; /* pointer to first DMA cookie */
888 891
889 892 int (*dmai_fault_check)(struct ddi_dma_impl *handle);
890 893 void (*dmai_fault_notify)(struct ddi_dma_impl *handle);
891 894 int dmai_fault;
892 895 ndi_err_t dmai_error;
893 896
894 897 } ddi_dma_impl_t;
895 898
896 899 #elif defined(__x86)
897 900
898 901 /*
899 902 * ddi_dma_impl portion that genunix (sunddi.c) depends on. x86 rootnex
900 903 * implementation specific state is in dmai_private.
901 904 */
902 905 typedef struct ddi_dma_impl {
903 906 ddi_dma_cookie_t *dmai_cookie; /* array of DMA cookies */
904 907 void *dmai_private;
905 908
906 909 /*
907 910 * Information gathered from the original dma mapping
908 911 * request and saved for the lifetime of the mapping.
909 912 */
910 913 uint_t dmai_minxfer;
911 914 uint_t dmai_burstsizes;
912 915 uint_t dmai_rflags; /* requester's flags + ours */
913 916 int dmai_nwin;
914 917 dev_info_t *dmai_rdip; /* original requester's dev_info_t */
915 918
916 919 ddi_dma_attr_t dmai_attr; /* DMA attributes */
917 920
918 921 int (*dmai_fault_check)(struct ddi_dma_impl *handle);
919 922 void (*dmai_fault_notify)(struct ddi_dma_impl *handle);
920 923 int dmai_fault;
921 924 ndi_err_t dmai_error;
922 925 } ddi_dma_impl_t;
923 926
924 927 #else
925 928 #error "struct ddi_dma_impl not defined for this architecture"
926 929 #endif /* defined(__sparc) */
927 930
928 931 /*
929 932 * For now DMA segments share state with the DMA handle
930 933 */
931 934 typedef ddi_dma_impl_t ddi_dma_seg_impl_t;
932 935
933 936 /*
934 937 * These flags use reserved bits from the dma request flags.
935 938 *
936 939 * A note about the DMP_NOSYNC flags: the root nexus will
937 940 * set these as it sees best. If an intermediate nexus
938 941 * actually needs these operations, then during the unwind
939 942 * from the call to ddi_dma_bind, the nexus driver *must*
940 943 * clear the appropriate flag(s). This is because, as an
941 944 * optimization, ddi_dma_sync(9F) looks at these flags before
942 945 * deciding to spend the time going back up the tree.
943 946 */
944 947
945 948 #define _DMCM1 DDI_DMA_RDWR|DDI_DMA_REDZONE|DDI_DMA_PARTIAL
946 949 #define _DMCM2 DDI_DMA_CONSISTENT|DMP_VMEREQ
947 950 #define DMP_DDIFLAGS (_DMCM1|_DMCM2)
948 951 #define DMP_SHADOW 0x20
949 952 #define DMP_LKIOPB 0x40
950 953 #define DMP_LKSYSV 0x80
951 954 #define DMP_IOCACHE 0x100
952 955 #define DMP_USEHAT 0x200
953 956 #define DMP_PHYSADDR 0x400
954 957 #define DMP_INVALID 0x800
955 958 #define DMP_NOLIMIT 0x1000
956 959 #define DMP_VMEREQ 0x10000000
957 960 #define DMP_BYPASSNEXUS 0x20000000
958 961 #define DMP_NODEVSYNC 0x40000000
959 962 #define DMP_NOCPUSYNC 0x80000000
960 963 #define DMP_NOSYNC (DMP_NODEVSYNC|DMP_NOCPUSYNC)
961 964
962 965 /*
963 966 * In order to complete a device to device mapping that
964 967 * has percolated as high as an IU nexus (gone that high
965 968 * because the DMA request is a VADDR type), we define
966 969 * structure to use with the DDI_CTLOPS_DMAPMAPC request
967 970 * that re-traverses the request tree to finish the
968 971 * DMA 'mapping' for a device.
969 972 */
970 973 struct dma_phys_mapc {
971 974 struct ddi_dma_req *dma_req; /* original request */
972 975 ddi_dma_impl_t *mp; /* current handle, or none */
973 976 int nptes; /* number of ptes */
974 977 void *ptes; /* ptes already read */
975 978 };
976 979
977 980 #define MAXCALLBACK 20
978 981
979 982 /*
980 983 * Callback definitions
981 984 */
982 985 struct ddi_callback {
983 986 struct ddi_callback *c_nfree;
984 987 struct ddi_callback *c_nlist;
985 988 int (*c_call)();
986 989 int c_count;
987 990 caddr_t c_arg;
988 991 size_t c_size;
989 992 };
990 993
991 994 /*
992 995 * Pure dynamic property declaration. A pure dynamic property is a property
993 996 * for which a driver's prop_op(9E) implementation will return a value on
994 997 * demand, but the property name does not exist on a property list (global,
995 998 * driver, system, or hardware) - the person asking for the value must know
996 999 * the name and type information.
997 1000 *
998 1001 * For a pure dynamic property to show up in a di_init() devinfo shapshot, the
999 1002 * devinfo driver must know name and type. The i_ddi_prop_dyn_t mechanism
1000 1003 * allows a driver to define an array of the name/type information of its
1001 1004 * dynamic properties. When a driver declares its dynamic properties in a
1002 1005 * i_ddi_prop_dyn_t array, and registers that array using
1003 1006 * i_ddi_prop_dyn_driver_set() the devinfo driver has sufficient information
1004 1007 * to represent the properties in a snapshot - calling the driver's
1005 1008 * prop_op(9E) to obtain values.
1006 1009 *
1007 1010 * The last element of a i_ddi_prop_dyn_t is detected via a NULL dp_name value.
1008 1011 *
1009 1012 * A pure dynamic property name associated with a minor_node/dev_t should be
1010 1013 * defined with a dp_spec_type of S_IFCHR or S_IFBLK, as appropriate. The
1011 1014 * driver's prop_op(9E) entry point will be called for all
1012 1015 * ddi_create_minor_node(9F) nodes of the specified spec_type. For a driver
1013 1016 * where not all minor_node/dev_t combinations support the same named
1014 1017 * properties, it is the responsibility of the prop_op(9E) implementation to
1015 1018 * sort out what combinations are appropriate.
1016 1019 *
1017 1020 * A pure dynamic property of a devinfo node should be defined with a
1018 1021 * dp_spec_type of 0.
1019 1022 *
1020 1023 * NB: Public DDI property interfaces no longer support pure dynamic
1021 1024 * properties, but they are still still used. A prime example is the cmlb
1022 1025 * implementation of size(9P) properties. Using pure dynamic properties
1023 1026 * reduces the space required to maintain per-partition information. Since
1024 1027 * there are no public interfaces to create pure dynamic properties,
1025 1028 * the i_ddi_prop_dyn_t mechanism should remain private.
1026 1029 */
1027 1030 typedef struct i_ddi_prop_dyn {
1028 1031 char *dp_name; /* name of dynamic property */
1029 1032 int dp_type; /* DDI_PROP_TYPE_ of property */
1030 1033 int dp_spec_type; /* 0, S_IFCHR, S_IFBLK */
1031 1034 } i_ddi_prop_dyn_t;
1032 1035 void i_ddi_prop_dyn_driver_set(dev_info_t *,
1033 1036 i_ddi_prop_dyn_t *);
1034 1037 i_ddi_prop_dyn_t *i_ddi_prop_dyn_driver_get(dev_info_t *);
1035 1038 void i_ddi_prop_dyn_parent_set(dev_info_t *,
1036 1039 i_ddi_prop_dyn_t *);
1037 1040 i_ddi_prop_dyn_t *i_ddi_prop_dyn_parent_get(dev_info_t *);
1038 1041 void i_ddi_prop_dyn_cache_invalidate(dev_info_t *,
1039 1042 i_ddi_prop_dyn_t *);
1040 1043
1041 1044 /*
1042 1045 * Device id - Internal definition.
1043 1046 */
1044 1047 #define DEVID_MAGIC_MSB 0x69
1045 1048 #define DEVID_MAGIC_LSB 0x64
1046 1049 #define DEVID_REV_MSB 0x00
1047 1050 #define DEVID_REV_LSB 0x01
1048 1051 #define DEVID_HINT_SIZE 4
1049 1052
1050 1053 typedef struct impl_devid {
1051 1054 uchar_t did_magic_hi; /* device id magic # (msb) */
1052 1055 uchar_t did_magic_lo; /* device id magic # (lsb) */
1053 1056 uchar_t did_rev_hi; /* device id revision # (msb) */
1054 1057 uchar_t did_rev_lo; /* device id revision # (lsb) */
1055 1058 uchar_t did_type_hi; /* device id type (msb) */
1056 1059 uchar_t did_type_lo; /* device id type (lsb) */
1057 1060 uchar_t did_len_hi; /* length of devid data (msb) */
1058 1061 uchar_t did_len_lo; /* length of devid data (lsb) */
1059 1062 char did_driver[DEVID_HINT_SIZE]; /* driver name - HINT */
1060 1063 char did_id[1]; /* start of device id data */
1061 1064 } impl_devid_t;
1062 1065
1063 1066 #define DEVID_GETTYPE(devid) ((ushort_t) \
1064 1067 (((devid)->did_type_hi << NBBY) + \
1065 1068 (devid)->did_type_lo))
1066 1069
1067 1070 #define DEVID_FORMTYPE(devid, type) (devid)->did_type_hi = hibyte((type)); \
1068 1071 (devid)->did_type_lo = lobyte((type));
1069 1072
1070 1073 #define DEVID_GETLEN(devid) ((ushort_t) \
1071 1074 (((devid)->did_len_hi << NBBY) + \
1072 1075 (devid)->did_len_lo))
1073 1076
1074 1077 #define DEVID_FORMLEN(devid, len) (devid)->did_len_hi = hibyte((len)); \
1075 1078 (devid)->did_len_lo = lobyte((len));
1076 1079
1077 1080 /*
1078 1081 * Per PSARC/1995/352, a binary devid contains fields for <magic number>,
1079 1082 * <revision>, <driver_hint>, <type>, <id_length>, and the <id> itself.
1080 1083 * This proposal would encode the binary devid into a string consisting
1081 1084 * of "<magic><revision>,<driver_hint>@<type><id>" as indicated below
1082 1085 * (<id_length> is rederived from the length of the string
1083 1086 * representation of the <id>):
1084 1087 *
1085 1088 * <magic> ->"id"
1086 1089 *
1087 1090 * <rev> ->"%d" // "0" -> type of DEVID_NONE "id0"
1088 1091 * // NOTE: PSARC/1995/352 <revision> is "1".
1089 1092 * // NOTE: support limited to 10 revisions
1090 1093 * // in current implementation
1091 1094 *
1092 1095 * <driver_hint> ->"%s" // "sd"/"ssd"
1093 1096 * // NOTE: driver names limited to 4
1094 1097 * // characters for <revision> "1"
1095 1098 *
1096 1099 * <type> ->'w' | // DEVID_SCSI3_WWN <hex_id>
1097 1100 * 'W' | // DEVID_SCSI3_WWN <ascii_id>
1098 1101 * 't' | // DEVID_SCSI3_VPD_T10 <hex_id>
1099 1102 * 'T' | // DEVID_SCSI3_VPD_T10 <ascii_id>
1100 1103 * 'x' | // DEVID_SCSI3_VPD_EUI <hex_id>
1101 1104 * 'X' | // DEVID_SCSI3_VPD_EUI <ascii_id>
1102 1105 * 'n' | // DEVID_SCSI3_VPD_NAA <hex_id>
1103 1106 * 'N' | // DEVID_SCSI3_VPD_NAA <ascii_id>
1104 1107 * 's' | // DEVID_SCSI_SERIAL <hex_id>
1105 1108 * 'S' | // DEVID_SCSI_SERIAL <ascii_id>
1106 1109 * 'f' | // DEVID_FAB <hex_id>
1107 1110 * 'F' | // DEVID_FAB <ascii_id>
1108 1111 * 'e' | // DEVID_ENCAP <hex_id>
1109 1112 * 'E' | // DEVID_ENCAP <ascii_id>
1110 1113 * 'a' | // DEVID_ATA_SERIAL <hex_id>
1111 1114 * 'A' | // DEVID_ATA_SERIAL <ascii_id>
1112 1115 * 'u' | // unknown <hex_id>
1113 1116 * 'U' // unknown <ascii_id>
1114 1117 * // NOTE:lower case -> <hex_id>
1115 1118 * // upper case -> <ascii_id>
1116 1119 * // NOTE:this covers all types currently
1117 1120 * // defined for <revision> 1.
1118 1121 * // NOTE:a <type> can be added
1119 1122 * // without changing the <revision>.
1120 1123 *
1121 1124 * <id> -> <ascii_id> | // <type> is upper case
1122 1125 * <hex_id> // <type> is lower case
1123 1126 *
1124 1127 * <ascii_id> // only if all bytes of binary <id> field
1125 1128 * // are in the set:
1126 1129 * // [A-Z][a-z][0-9]+-.= and space and 0x00
1127 1130 * // the encoded form is:
1128 1131 * // [A-Z][a-z][0-9]+-.= and _ and ~
1129 1132 * // NOTE: ' ' <=> '_', 0x00 <=> '~'
1130 1133 * // these sets are chosen to avoid shell
1131 1134 * // and conflicts with DDI node names.
1132 1135 *
1133 1136 * <hex_id> // if not <ascii_id>; each byte of binary
1134 1137 * // <id> maps a to 2 digit ascii hex
1135 1138 * // representation in the string.
1136 1139 *
1137 1140 * This encoding provides a meaningful correlation between the /devices
1138 1141 * path and the devid string where possible.
1139 1142 *
1140 1143 * Fibre:
1141 1144 * sbus@6,0/SUNW,socal@d,10000/sf@1,0/ssd@w21000020370bb488,0:c,raw
1142 1145 * id1,ssd@w20000020370bb488:c,raw
1143 1146 *
1144 1147 * Copper:
1145 1148 * sbus@7,0/SUNW,fas@3,8800000/sd@a,0:c
1146 1149 * id1,sd@SIBM_____1XY210__________:c
1147 1150 */
1148 1151 /* determine if a byte of an id meets ASCII representation requirements */
1149 1152 #define DEVID_IDBYTE_ISASCII(b) ( \
1150 1153 (((b) >= 'a') && ((b) <= 'z')) || \
1151 1154 (((b) >= 'A') && ((b) <= 'Z')) || \
1152 1155 (((b) >= '0') && ((b) <= '9')) || \
1153 1156 (b == '+') || (b == '-') || (b == '.') || (b == '=') || \
1154 1157 (b == ' ') || (b == 0x00))
1155 1158
1156 1159 /* set type to lower case to indicate that the did_id field is ascii */
1157 1160 #define DEVID_TYPE_SETASCII(c) (c - 0x20) /* 'a' -> 'A' */
1158 1161
1159 1162 /* determine from type if did_id field is binary or ascii */
1160 1163 #define DEVID_TYPE_ISASCII(c) (((c) >= 'A') && ((c) <= 'Z'))
1161 1164
1162 1165 /* convert type field from binary to ascii */
1163 1166 #define DEVID_TYPE_BINTOASCII(b) ( \
1164 1167 ((b) == DEVID_SCSI3_WWN) ? 'w' : \
1165 1168 ((b) == DEVID_SCSI3_VPD_T10) ? 't' : \
1166 1169 ((b) == DEVID_SCSI3_VPD_EUI) ? 'x' : \
1167 1170 ((b) == DEVID_SCSI3_VPD_NAA) ? 'n' : \
1168 1171 ((b) == DEVID_SCSI_SERIAL) ? 's' : \
1169 1172 ((b) == DEVID_FAB) ? 'f' : \
1170 1173 ((b) == DEVID_ENCAP) ? 'e' : \
1171 1174 ((b) == DEVID_ATA_SERIAL) ? 'a' : \
1172 1175 'u') /* unknown */
1173 1176
1174 1177 /* convert type field from ascii to binary */
1175 1178 #define DEVID_TYPE_ASCIITOBIN(c) ( \
1176 1179 (((c) == 'w') || ((c) == 'W')) ? DEVID_SCSI3_WWN : \
1177 1180 (((c) == 't') || ((c) == 'T')) ? DEVID_SCSI3_VPD_T10 : \
1178 1181 (((c) == 'x') || ((c) == 'X')) ? DEVID_SCSI3_VPD_EUI : \
1179 1182 (((c) == 'n') || ((c) == 'N')) ? DEVID_SCSI3_VPD_NAA : \
1180 1183 (((c) == 's') || ((c) == 'S')) ? DEVID_SCSI_SERIAL : \
1181 1184 (((c) == 'f') || ((c) == 'F')) ? DEVID_FAB : \
1182 1185 (((c) == 'e') || ((c) == 'E')) ? DEVID_ENCAP : \
1183 1186 (((c) == 'a') || ((c) == 'A')) ? DEVID_ATA_SERIAL : \
1184 1187 DEVID_MAXTYPE +1) /* unknown */
1185 1188
1186 1189 /* determine if the type should be forced to hex encoding (non-ascii) */
1187 1190 #define DEVID_TYPE_BIN_FORCEHEX(b) ( \
1188 1191 ((b) == DEVID_SCSI3_WWN) || \
1189 1192 ((b) == DEVID_SCSI3_VPD_EUI) || \
1190 1193 ((b) == DEVID_SCSI3_VPD_NAA) || \
1191 1194 ((b) == DEVID_FAB))
1192 1195
1193 1196 /* determine if the type is from a scsi3 vpd */
1194 1197 #define IS_DEVID_SCSI3_VPD_TYPE(b) ( \
1195 1198 ((b) == DEVID_SCSI3_VPD_T10) || \
1196 1199 ((b) == DEVID_SCSI3_VPD_EUI) || \
1197 1200 ((b) == DEVID_SCSI3_VPD_NAA))
1198 1201
1199 1202 /* convert rev field from binary to ascii (only supports 10 revs) */
1200 1203 #define DEVID_REV_BINTOASCII(b) (b + '0')
1201 1204
1202 1205 /* convert rev field from ascii to binary (only supports 10 revs) */
1203 1206 #define DEVID_REV_ASCIITOBIN(c) (c - '0')
1204 1207
1205 1208 /* name of devid property */
1206 1209 #define DEVID_PROP_NAME "devid"
1207 1210
1208 1211 /*
1209 1212 * prop_name used by pci_{save,restore}_config_regs()
1210 1213 */
1211 1214 #define SAVED_CONFIG_REGS "pci-config-regs"
1212 1215 #define SAVED_CONFIG_REGS_MASK "pcie-config-regs-mask"
1213 1216 #define SAVED_CONFIG_REGS_CAPINFO "pci-cap-info"
1214 1217
1215 1218 typedef struct pci_config_header_state {
1216 1219 uint16_t chs_command;
1217 1220 uint8_t chs_cache_line_size;
1218 1221 uint8_t chs_latency_timer;
1219 1222 uint8_t chs_header_type;
1220 1223 uint8_t chs_sec_latency_timer;
1221 1224 uint8_t chs_bridge_control;
1222 1225 uint32_t chs_base0;
1223 1226 uint32_t chs_base1;
1224 1227 uint32_t chs_base2;
1225 1228 uint32_t chs_base3;
1226 1229 uint32_t chs_base4;
1227 1230 uint32_t chs_base5;
1228 1231 } pci_config_header_state_t;
1229 1232
1230 1233 #ifdef _KERNEL
1231 1234
1232 1235 typedef struct pci_cap_save_desc {
1233 1236 uint16_t cap_offset;
1234 1237 uint16_t cap_id;
1235 1238 uint32_t cap_nregs;
1236 1239 } pci_cap_save_desc_t;
1237 1240
1238 1241 typedef struct pci_cap_entry {
1239 1242 uint16_t cap_id;
1240 1243 uint16_t cap_reg;
1241 1244 uint16_t cap_mask;
1242 1245 uint32_t cap_ndwords;
1243 1246 uint32_t (*cap_save_func)(ddi_acc_handle_t confhdl, uint16_t cap_ptr,
1244 1247 uint32_t *regbuf, uint32_t ndwords);
1245 1248 } pci_cap_entry_t;
1246 1249
1247 1250 #endif /* _KERNEL */
1248 1251
1249 1252 #ifdef __cplusplus
1250 1253 }
1251 1254 #endif
1252 1255
1253 1256 #endif /* _SYS_DDI_IMPLDEFS_H */
|
↓ open down ↓ |
619 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX