1 /*
   2  * CDDL HEADER START
   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
  23  * Copyright 2012 Garrett D'Amore <garrett@damore.org>.  All rights reserved.
  24  * Copyright 2016 Joyent, Inc.
  25  * Copyright (c) 2016 by Delphix. All rights reserved.
  26  */
  27 
  28 #ifndef _SYS_DDI_IMPLDEFS_H
  29 #define _SYS_DDI_IMPLDEFS_H
  30 
  31 #include <sys/types.h>
  32 #include <sys/param.h>
  33 #include <sys/t_lock.h>
  34 #include <sys/ddipropdefs.h>
  35 #include <sys/devops.h>
  36 #include <sys/autoconf.h>
  37 #include <sys/mutex.h>
  38 #include <vm/page.h>
  39 #include <sys/dacf_impl.h>
  40 #include <sys/ndifm.h>
  41 #include <sys/epm.h>
  42 #include <sys/ddidmareq.h>
  43 #include <sys/ddi_intr.h>
  44 #include <sys/ddi_hp.h>
  45 #include <sys/ddi_hp_impl.h>
 
 
 268 
 269 #if defined(__x86)
 270         /* For x86 (Intel and AMD) IOMMU support */
 271         void            *devi_iommu;
 272         iommulib_handle_t       devi_iommulib_handle;
 273         iommulib_nexhandle_t    devi_iommulib_nex_handle;
 274 #endif
 275 
 276         /* Generic callback mechanism */
 277         ddi_cb_t        *devi_cb_p;
 278 
 279         /* ndi 'flavors' */
 280         ndi_flavor_t    devi_flavor;            /* flavor assigned by parent */
 281         ndi_flavor_t    devi_flavorv_n;         /* number of child-flavors */
 282         void            **devi_flavorv;         /* child-flavor specific data */
 283 
 284         /* Owned by hotplug framework */
 285         struct ddi_hp_cn_handle *devi_hp_hdlp;   /* hotplug handle list */
 286 
 287         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 };
 293 
 294 #define DEVI(dev_info_type)     ((struct dev_info *)(dev_info_type))
 295 
 296 /*
 297  * NB: The 'name' field, for compatibility with old code (both existing
 298  * device drivers and userland code), is now defined as the name used
 299  * to bind the node to a device driver, and not the device node name.
 300  * If the device node name does not define a binding to a device driver,
 301  * and the framework uses a different algorithm to create the binding to
 302  * the driver, the node name and binding name will be different.
 303  *
 304  * Note that this implies that the node name plus instance number does
 305  * NOT create a unique driver id; only the binding name plus instance
 306  * number creates a unique driver id.
 307  *
 308  * New code should not use 'devi_name'; use 'devi_binding_name' or
 309  * 'devi_node_name' and/or the routines that access those fields.
 310  */
 311 
 
 
 597 
 598 /*
 599  * devi_flags bits
 600  *
 601  * NOTE: all devi_state updates should be protected by devi_lock.
 602  */
 603 #define DEVI_BUSY               0x00000001 /* busy configuring children */
 604 #define DEVI_MADE_CHILDREN      0x00000002 /* children made from specs */
 605 #define DEVI_ATTACHED_CHILDREN  0x00000004 /* attached all existing children */
 606 #define DEVI_BRANCH_HELD        0x00000008 /* branch rooted at this dip held */
 607 #define DEVI_NO_BIND            0x00000010 /* prevent driver binding */
 608 #define DEVI_CACHED_DEVID       0x00000020 /* devid cached in devid cache */
 609 #define DEVI_PHCI_SIGNALS_VHCI  0x00000040 /* pHCI ndi_devi_exit signals vHCI */
 610 #define DEVI_REBIND             0x00000080 /* post initchild driver rebind */
 611 #define DEVI_RETIRED            0x00000100 /* device is retired */
 612 #define DEVI_RETIRING           0x00000200 /* being evaluated for retire */
 613 #define DEVI_R_CONSTRAINT       0x00000400 /* constraints have been applied  */
 614 #define DEVI_R_BLOCKED          0x00000800 /* constraints block retire  */
 615 #define DEVI_CT_NOP             0x00001000 /* NOP contract event occurred */
 616 #define DEVI_PCI_DEVICE         0x00002000 /* dip is PCI */
 617 
 618 #define DEVI_BUSY_CHANGING(dip) (DEVI(dip)->devi_flags & DEVI_BUSY)
 619 #define DEVI_BUSY_OWNED(dip)    (DEVI_BUSY_CHANGING(dip) &&     \
 620         ((DEVI(dip))->devi_busy_thread == curthread))
 621 
 622 #define DEVI_IS_PCI(dip)        (DEVI(dip)->devi_flags & DEVI_PCI_DEVICE)
 623 #define DEVI_SET_PCI(dip)       (DEVI(dip)->devi_flags |= (DEVI_PCI_DEVICE))
 624 
 625 char    *i_ddi_devi_class(dev_info_t *);
 626 int     i_ddi_set_devi_class(dev_info_t *, char *, int);
 627 
 628 /*
 629  * This structure represents one piece of bus space occupied by a given
 630  * device. It is used in an array for devices with multiple address windows.
 631  */
 632 struct regspec {
 633         uint_t regspec_bustype;         /* cookie for bus type it's on */
 634         uint_t regspec_addr;            /* address of reg relative to bus */
 635         uint_t regspec_size;            /* size of this register set */
 636 };
 637 
 638 /*
 639  * This is a version of the above structure that works for 64-bit mappings and
 640  * doesn't rely on overloading of fields as is done on SPARC. Eventually the
 641  * struct regspec should be replaced with this.
 642  */
 643 struct regspec64 {
 644         uint64_t regspec_bustype;       /* cookie for bus type it's on */
 
 | 
   1 /*
   2  * CDDL HEADER START
   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
  24  * Copyright 2012 Garrett D'Amore <garrett@damore.org>.  All rights reserved.
  25  * Copyright 2016 Joyent, Inc.
  26  * Copyright (c) 2016 by Delphix. All rights reserved.
  27  * Copyright 2018 Nexenta Systems, Inc.
  28  */
  29 
  30 #ifndef _SYS_DDI_IMPLDEFS_H
  31 #define _SYS_DDI_IMPLDEFS_H
  32 
  33 #include <sys/types.h>
  34 #include <sys/param.h>
  35 #include <sys/t_lock.h>
  36 #include <sys/ddipropdefs.h>
  37 #include <sys/devops.h>
  38 #include <sys/autoconf.h>
  39 #include <sys/mutex.h>
  40 #include <vm/page.h>
  41 #include <sys/dacf_impl.h>
  42 #include <sys/ndifm.h>
  43 #include <sys/epm.h>
  44 #include <sys/ddidmareq.h>
  45 #include <sys/ddi_intr.h>
  46 #include <sys/ddi_hp.h>
  47 #include <sys/ddi_hp_impl.h>
 
 
 270 
 271 #if defined(__x86)
 272         /* For x86 (Intel and AMD) IOMMU support */
 273         void            *devi_iommu;
 274         iommulib_handle_t       devi_iommulib_handle;
 275         iommulib_nexhandle_t    devi_iommulib_nex_handle;
 276 #endif
 277 
 278         /* Generic callback mechanism */
 279         ddi_cb_t        *devi_cb_p;
 280 
 281         /* ndi 'flavors' */
 282         ndi_flavor_t    devi_flavor;            /* flavor assigned by parent */
 283         ndi_flavor_t    devi_flavorv_n;         /* number of child-flavors */
 284         void            **devi_flavorv;         /* child-flavor specific data */
 285 
 286         /* Owned by hotplug framework */
 287         struct ddi_hp_cn_handle *devi_hp_hdlp;   /* hotplug handle list */
 288 
 289         struct in_node  *devi_in_node; /* pointer to devinfo node's in_node_t */
 290 };
 291 
 292 #define DEVI(dev_info_type)     ((struct dev_info *)(dev_info_type))
 293 
 294 /*
 295  * NB: The 'name' field, for compatibility with old code (both existing
 296  * device drivers and userland code), is now defined as the name used
 297  * to bind the node to a device driver, and not the device node name.
 298  * If the device node name does not define a binding to a device driver,
 299  * and the framework uses a different algorithm to create the binding to
 300  * the driver, the node name and binding name will be different.
 301  *
 302  * Note that this implies that the node name plus instance number does
 303  * NOT create a unique driver id; only the binding name plus instance
 304  * number creates a unique driver id.
 305  *
 306  * New code should not use 'devi_name'; use 'devi_binding_name' or
 307  * 'devi_node_name' and/or the routines that access those fields.
 308  */
 309 
 
 
 595 
 596 /*
 597  * devi_flags bits
 598  *
 599  * NOTE: all devi_state updates should be protected by devi_lock.
 600  */
 601 #define DEVI_BUSY               0x00000001 /* busy configuring children */
 602 #define DEVI_MADE_CHILDREN      0x00000002 /* children made from specs */
 603 #define DEVI_ATTACHED_CHILDREN  0x00000004 /* attached all existing children */
 604 #define DEVI_BRANCH_HELD        0x00000008 /* branch rooted at this dip held */
 605 #define DEVI_NO_BIND            0x00000010 /* prevent driver binding */
 606 #define DEVI_CACHED_DEVID       0x00000020 /* devid cached in devid cache */
 607 #define DEVI_PHCI_SIGNALS_VHCI  0x00000040 /* pHCI ndi_devi_exit signals vHCI */
 608 #define DEVI_REBIND             0x00000080 /* post initchild driver rebind */
 609 #define DEVI_RETIRED            0x00000100 /* device is retired */
 610 #define DEVI_RETIRING           0x00000200 /* being evaluated for retire */
 611 #define DEVI_R_CONSTRAINT       0x00000400 /* constraints have been applied  */
 612 #define DEVI_R_BLOCKED          0x00000800 /* constraints block retire  */
 613 #define DEVI_CT_NOP             0x00001000 /* NOP contract event occurred */
 614 #define DEVI_PCI_DEVICE         0x00002000 /* dip is PCI */
 615 #define DEVI_GONE               0x00004000 /* device is physically removed */
 616 
 617 #define DEVI_BUSY_CHANGING(dip) (DEVI(dip)->devi_flags & DEVI_BUSY)
 618 #define DEVI_BUSY_OWNED(dip)    (DEVI_BUSY_CHANGING(dip) &&     \
 619         ((DEVI(dip))->devi_busy_thread == curthread))
 620 
 621 #define DEVI_IS_PCI(dip)        (DEVI(dip)->devi_flags & DEVI_PCI_DEVICE)
 622 #define DEVI_SET_PCI(dip)       (DEVI(dip)->devi_flags |= (DEVI_PCI_DEVICE))
 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 
 628 char    *i_ddi_devi_class(dev_info_t *);
 629 int     i_ddi_set_devi_class(dev_info_t *, char *, int);
 630 
 631 /*
 632  * This structure represents one piece of bus space occupied by a given
 633  * device. It is used in an array for devices with multiple address windows.
 634  */
 635 struct regspec {
 636         uint_t regspec_bustype;         /* cookie for bus type it's on */
 637         uint_t regspec_addr;            /* address of reg relative to bus */
 638         uint_t regspec_size;            /* size of this register set */
 639 };
 640 
 641 /*
 642  * This is a version of the above structure that works for 64-bit mappings and
 643  * doesn't rely on overloading of fields as is done on SPARC. Eventually the
 644  * struct regspec should be replaced with this.
 645  */
 646 struct regspec64 {
 647         uint64_t regspec_bustype;       /* cookie for bus type it's on */
 
 |