17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5102cb92eSjohnny * Common Development and Distribution License (the "License"). 6102cb92eSjohnny * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22*5febcb4aSScott Carter, SD IOSW * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef _SYS_DDI_INTR_IMPL_H 277c478bd9Sstevel@tonic-gate #define _SYS_DDI_INTR_IMPL_H 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate /* 307c478bd9Sstevel@tonic-gate * Sun DDI interrupt implementation specific definitions 317c478bd9Sstevel@tonic-gate */ 327c478bd9Sstevel@tonic-gate 33*5febcb4aSScott Carter, SD IOSW #include <sys/list.h> 34*5febcb4aSScott Carter, SD IOSW #include <sys/ksynch.h> 35*5febcb4aSScott Carter, SD IOSW 367c478bd9Sstevel@tonic-gate #ifdef __cplusplus 377c478bd9Sstevel@tonic-gate extern "C" { 387c478bd9Sstevel@tonic-gate #endif 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gate #ifdef _KERNEL 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gate /* 437c478bd9Sstevel@tonic-gate * Typedef for interrupt ops 447c478bd9Sstevel@tonic-gate */ 457c478bd9Sstevel@tonic-gate typedef enum { 467c478bd9Sstevel@tonic-gate DDI_INTROP_SUPPORTED_TYPES = 1, /* 1 get supported interrupts types */ 477c478bd9Sstevel@tonic-gate DDI_INTROP_NINTRS, /* 2 get num of interrupts supported */ 487c478bd9Sstevel@tonic-gate DDI_INTROP_ALLOC, /* 3 allocate interrupt handle */ 497c478bd9Sstevel@tonic-gate DDI_INTROP_GETPRI, /* 4 get priority */ 507c478bd9Sstevel@tonic-gate DDI_INTROP_SETPRI, /* 5 set priority */ 517c478bd9Sstevel@tonic-gate DDI_INTROP_ADDISR, /* 6 add interrupt handler */ 527c478bd9Sstevel@tonic-gate DDI_INTROP_DUPVEC, /* 7 duplicate interrupt handler */ 537c478bd9Sstevel@tonic-gate DDI_INTROP_ENABLE, /* 8 enable interrupt */ 547c478bd9Sstevel@tonic-gate DDI_INTROP_BLOCKENABLE, /* 9 block enable interrupts */ 557c478bd9Sstevel@tonic-gate DDI_INTROP_BLOCKDISABLE, /* 10 block disable interrupts */ 567c478bd9Sstevel@tonic-gate DDI_INTROP_DISABLE, /* 11 disable interrupt */ 577c478bd9Sstevel@tonic-gate DDI_INTROP_REMISR, /* 12 remove interrupt handler */ 587c478bd9Sstevel@tonic-gate DDI_INTROP_FREE, /* 13 free interrupt handle */ 597c478bd9Sstevel@tonic-gate DDI_INTROP_GETCAP, /* 14 get capacity */ 607c478bd9Sstevel@tonic-gate DDI_INTROP_SETCAP, /* 15 set capacity */ 617c478bd9Sstevel@tonic-gate DDI_INTROP_SETMASK, /* 16 set mask */ 627c478bd9Sstevel@tonic-gate DDI_INTROP_CLRMASK, /* 17 clear mask */ 637c478bd9Sstevel@tonic-gate DDI_INTROP_GETPENDING, /* 18 get pending interrupt */ 64*5febcb4aSScott Carter, SD IOSW DDI_INTROP_NAVAIL, /* 19 get num of available interrupts */ 65*5febcb4aSScott Carter, SD IOSW DDI_INTROP_GETPOOL /* 20 get resource management pool */ 667c478bd9Sstevel@tonic-gate } ddi_intr_op_t; 677c478bd9Sstevel@tonic-gate 687c478bd9Sstevel@tonic-gate /* Version number used in the handles */ 697c478bd9Sstevel@tonic-gate #define DDI_INTR_VERSION_1 1 707c478bd9Sstevel@tonic-gate #define DDI_INTR_VERSION DDI_INTR_VERSION_1 717c478bd9Sstevel@tonic-gate 727c478bd9Sstevel@tonic-gate /* 737c478bd9Sstevel@tonic-gate * One such data structure is allocated per ddi_intr_handle_t 747c478bd9Sstevel@tonic-gate * This is the incore copy of the regular interrupt info. 757c478bd9Sstevel@tonic-gate */ 767c478bd9Sstevel@tonic-gate typedef struct ddi_intr_handle_impl { 777c478bd9Sstevel@tonic-gate dev_info_t *ih_dip; /* dip associated with handle */ 787c478bd9Sstevel@tonic-gate uint16_t ih_type; /* interrupt type being used */ 797c478bd9Sstevel@tonic-gate ushort_t ih_inum; /* interrupt number */ 80a195726fSgovinda uint32_t ih_vector; /* vector number */ 817c478bd9Sstevel@tonic-gate uint16_t ih_ver; /* Version */ 827c478bd9Sstevel@tonic-gate uint_t ih_state; /* interrupt handle state */ 837c478bd9Sstevel@tonic-gate uint_t ih_cap; /* interrupt capabilities */ 847c478bd9Sstevel@tonic-gate uint_t ih_pri; /* priority - bus dependent */ 857c478bd9Sstevel@tonic-gate krwlock_t ih_rwlock; /* read/write lock per handle */ 867c478bd9Sstevel@tonic-gate 877c478bd9Sstevel@tonic-gate uint_t (*ih_cb_func)(caddr_t, caddr_t); 887c478bd9Sstevel@tonic-gate void *ih_cb_arg1; 897c478bd9Sstevel@tonic-gate void *ih_cb_arg2; 907c478bd9Sstevel@tonic-gate 9120036fe5Segillett /* 9220036fe5Segillett * The following 3 members are used to support MSI-X specific features 9320036fe5Segillett */ 9420036fe5Segillett uint_t ih_flags; /* Misc flags */ 9520036fe5Segillett uint_t ih_dup_cnt; /* # of dupped msi-x vectors */ 9620036fe5Segillett struct ddi_intr_handle_impl *ih_main; 9720036fe5Segillett /* pntr to the main vector */ 987c478bd9Sstevel@tonic-gate /* 997c478bd9Sstevel@tonic-gate * The next set of members are for 'scratch' purpose only. 1007c478bd9Sstevel@tonic-gate * The DDI interrupt framework uses them internally and their 1017c478bd9Sstevel@tonic-gate * interpretation is left to the framework. For now, 1027c478bd9Sstevel@tonic-gate * scratch1 - used to send NINTRs information 1037c478bd9Sstevel@tonic-gate * to various nexus drivers. 1047c478bd9Sstevel@tonic-gate * scratch2 - used to send 'behavior' flag 1057c478bd9Sstevel@tonic-gate * information to the nexus drivers 106102cb92eSjohnny * from ddi_intr_alloc(). It is also 107102cb92eSjohnny * used to send 'h_array' to the nexus drivers 108102cb92eSjohnny * for ddi_intr_block_enable/disable() on x86. 1097a364d25Sschwartz * private - On X86 it usually carries a pointer to 1107a364d25Sschwartz * ihdl_plat_t. Not used on SPARC platforms. 1117c478bd9Sstevel@tonic-gate */ 1127c478bd9Sstevel@tonic-gate void *ih_private; /* Platform specific data */ 1137c478bd9Sstevel@tonic-gate uint_t ih_scratch1; /* Scratch1: #interrupts */ 114102cb92eSjohnny void *ih_scratch2; /* Scratch2: flag/h_array */ 1157c478bd9Sstevel@tonic-gate } ddi_intr_handle_impl_t; 1167c478bd9Sstevel@tonic-gate 1177c478bd9Sstevel@tonic-gate /* values for ih_state (strictly for interrupt handle) */ 1187c478bd9Sstevel@tonic-gate #define DDI_IHDL_STATE_ALLOC 0x01 /* Allocated. ddi_intr_alloc() called */ 1197c478bd9Sstevel@tonic-gate #define DDI_IHDL_STATE_ADDED 0x02 /* Added interrupt handler */ 1207c478bd9Sstevel@tonic-gate /* ddi_intr_add_handler() called */ 1217c478bd9Sstevel@tonic-gate #define DDI_IHDL_STATE_ENABLE 0x04 /* Enabled. ddi_intr_enable() called */ 1227c478bd9Sstevel@tonic-gate 1237c478bd9Sstevel@tonic-gate #define DDI_INTR_IS_MSI_OR_MSIX(type) \ 1247c478bd9Sstevel@tonic-gate ((type) == DDI_INTR_TYPE_MSI || (type) == DDI_INTR_TYPE_MSIX) 1257c478bd9Sstevel@tonic-gate 1262326332eSanish #define DDI_INTR_BEHAVIOR_FLAG_VALID(f) \ 1272326332eSanish (((f) == DDI_INTR_ALLOC_NORMAL) || ((f) == DDI_INTR_ALLOC_STRICT)) 1282326332eSanish 129d626b9f5Sanish #define DDI_INTR_TYPE_FLAG_VALID(t) \ 130d626b9f5Sanish (((t) == DDI_INTR_TYPE_FIXED) || \ 131d626b9f5Sanish ((t) == DDI_INTR_TYPE_MSI) || \ 132d626b9f5Sanish ((t) == DDI_INTR_TYPE_MSIX)) 133d626b9f5Sanish 13420036fe5Segillett /* values for ih_flags */ 13520036fe5Segillett #define DDI_INTR_MSIX_DUP 0x01 /* MSI-X vector which has been dupped */ 13620036fe5Segillett 137ef643aefSegillett /* Maximum number of MSI resources to allocate */ 138ef643aefSegillett #define DDI_MAX_MSI_ALLOC 2 139ef643aefSegillett 140ef643aefSegillett /* 141ef643aefSegillett * The following MSI-X limits will change with Interrupt Resource Management 142ef643aefSegillett * (IRM) support. 143ef643aefSegillett */ 144ef643aefSegillett /* Default number of MSI-X resources to allocate */ 145ef643aefSegillett #define DDI_DEFAULT_MSIX_ALLOC 2 146ef643aefSegillett 147ef643aefSegillett /* Maximum number of MSI-X resources to allocate */ 148ef643aefSegillett #define DDI_MAX_MSIX_ALLOC 8 149d84bdf75Segillett 150e23a7e34Slq struct av_softinfo; 151e23a7e34Slq 1527c478bd9Sstevel@tonic-gate /* 1537c478bd9Sstevel@tonic-gate * One such data structure is allocated per ddi_soft_intr_handle 1547c478bd9Sstevel@tonic-gate * This is the incore copy of the softint info. 1557c478bd9Sstevel@tonic-gate */ 1567c478bd9Sstevel@tonic-gate typedef struct ddi_softint_hdl_impl { 1577c478bd9Sstevel@tonic-gate dev_info_t *ih_dip; /* dip associated with handle */ 1587c478bd9Sstevel@tonic-gate uint_t ih_pri; /* priority - bus dependent */ 1597c478bd9Sstevel@tonic-gate krwlock_t ih_rwlock; /* read/write lock per handle */ 160e23a7e34Slq struct av_softinfo *ih_pending; /* whether softint is pending */ 1617c478bd9Sstevel@tonic-gate 1627c478bd9Sstevel@tonic-gate uint_t (*ih_cb_func)(caddr_t, caddr_t); 1637c478bd9Sstevel@tonic-gate /* cb function for soft ints */ 1647c478bd9Sstevel@tonic-gate void *ih_cb_arg1; /* arg1 of callback function */ 1657c478bd9Sstevel@tonic-gate void *ih_cb_arg2; /* arg2 passed to "trigger" */ 1667c478bd9Sstevel@tonic-gate 1677c478bd9Sstevel@tonic-gate /* 1687c478bd9Sstevel@tonic-gate * The next member is for 'scratch' purpose only. 1697c478bd9Sstevel@tonic-gate * The DDI interrupt framework uses it internally and its 1707c478bd9Sstevel@tonic-gate * interpretation is left to the framework. 1717c478bd9Sstevel@tonic-gate * private - used by the DDI framework to pass back 1727c478bd9Sstevel@tonic-gate * and forth 'softid' information on SPARC 1737c478bd9Sstevel@tonic-gate * side only. Not used on X86 platform. 1747c478bd9Sstevel@tonic-gate */ 1757c478bd9Sstevel@tonic-gate void *ih_private; /* Platform specific data */ 1767c478bd9Sstevel@tonic-gate } ddi_softint_hdl_impl_t; 1777c478bd9Sstevel@tonic-gate 1787c478bd9Sstevel@tonic-gate /* Softint internal implementation defines */ 1797c478bd9Sstevel@tonic-gate #define DDI_SOFT_INTR_PRI_M 4 1807c478bd9Sstevel@tonic-gate #define DDI_SOFT_INTR_PRI_H 6 1817c478bd9Sstevel@tonic-gate 1827c478bd9Sstevel@tonic-gate /* 1837c478bd9Sstevel@tonic-gate * One such data structure is allocated for MSI-X enabled 1847c478bd9Sstevel@tonic-gate * device. If no MSI-X is enabled then it is NULL 1857c478bd9Sstevel@tonic-gate */ 1867c478bd9Sstevel@tonic-gate typedef struct ddi_intr_msix { 1877c478bd9Sstevel@tonic-gate /* MSI-X Table related information */ 1887c478bd9Sstevel@tonic-gate ddi_acc_handle_t msix_tbl_hdl; /* MSI-X table handle */ 1899c75c6bfSgovinda uint32_t *msix_tbl_addr; /* MSI-X table addr */ 1909c75c6bfSgovinda uint32_t msix_tbl_offset; /* MSI-X table offset */ 1917c478bd9Sstevel@tonic-gate 1927c478bd9Sstevel@tonic-gate /* MSI-X PBA Table related information */ 1937c478bd9Sstevel@tonic-gate ddi_acc_handle_t msix_pba_hdl; /* MSI-X PBA handle */ 1949c75c6bfSgovinda uint32_t *msix_pba_addr; /* MSI-X PBA addr */ 1959c75c6bfSgovinda uint32_t msix_pba_offset; /* MSI-X PBA offset */ 1967c478bd9Sstevel@tonic-gate 1977c478bd9Sstevel@tonic-gate ddi_device_acc_attr_t msix_dev_attr; /* MSI-X device attr */ 1987c478bd9Sstevel@tonic-gate } ddi_intr_msix_t; 1997c478bd9Sstevel@tonic-gate 200*5febcb4aSScott Carter, SD IOSW /* 201*5febcb4aSScott Carter, SD IOSW * Interrupt Resource Management (IRM). 202*5febcb4aSScott Carter, SD IOSW */ 203*5febcb4aSScott Carter, SD IOSW 204*5febcb4aSScott Carter, SD IOSW #define DDI_IRM_POLICY_LARGE 1 205*5febcb4aSScott Carter, SD IOSW #define DDI_IRM_POLICY_EVEN 2 206*5febcb4aSScott Carter, SD IOSW 207*5febcb4aSScott Carter, SD IOSW #define DDI_IRM_POLICY_VALID(p) (((p) == DDI_IRM_POLICY_LARGE) || \ 208*5febcb4aSScott Carter, SD IOSW ((p) == DDI_IRM_POLICY_EVEN)) 209*5febcb4aSScott Carter, SD IOSW 210*5febcb4aSScott Carter, SD IOSW #define DDI_IRM_FLAG_ACTIVE 0x1 /* Pool is active */ 211*5febcb4aSScott Carter, SD IOSW #define DDI_IRM_FLAG_QUEUED 0x2 /* Pool is queued */ 212*5febcb4aSScott Carter, SD IOSW #define DDI_IRM_FLAG_WAITERS 0x4 /* Pool has waiters */ 213*5febcb4aSScott Carter, SD IOSW #define DDI_IRM_FLAG_EXIT 0x8 /* Balance thread must exit */ 214*5febcb4aSScott Carter, SD IOSW #define DDI_IRM_FLAG_NEW 0x10 /* Request is new */ 215*5febcb4aSScott Carter, SD IOSW #define DDI_IRM_FLAG_CALLBACK 0x20 /* Request has callback */ 216*5febcb4aSScott Carter, SD IOSW 217*5febcb4aSScott Carter, SD IOSW /* 218*5febcb4aSScott Carter, SD IOSW * One such data structure for each supply of interrupt vectors. 219*5febcb4aSScott Carter, SD IOSW * Contains information about the size and policies defining the 220*5febcb4aSScott Carter, SD IOSW * supply, and a list of associated device-specific requests. 221*5febcb4aSScott Carter, SD IOSW */ 222*5febcb4aSScott Carter, SD IOSW typedef struct ddi_irm_pool { 223*5febcb4aSScott Carter, SD IOSW int ipool_flags; /* Status flags of the pool */ 224*5febcb4aSScott Carter, SD IOSW int ipool_types; /* Types of interrupts */ 225*5febcb4aSScott Carter, SD IOSW int ipool_policy; /* Rebalancing policy */ 226*5febcb4aSScott Carter, SD IOSW uint_t ipool_totsz; /* Total size of the pool */ 227*5febcb4aSScott Carter, SD IOSW uint_t ipool_defsz; /* Default allocation size */ 228*5febcb4aSScott Carter, SD IOSW uint_t ipool_minno; /* Minimum number consumed */ 229*5febcb4aSScott Carter, SD IOSW uint_t ipool_reqno; /* Total number requested */ 230*5febcb4aSScott Carter, SD IOSW uint_t ipool_resno; /* Total number reserved */ 231*5febcb4aSScott Carter, SD IOSW kmutex_t ipool_lock; /* Protects all pool usage */ 232*5febcb4aSScott Carter, SD IOSW kmutex_t ipool_navail_lock; /* Protects 'navail' of reqs */ 233*5febcb4aSScott Carter, SD IOSW kcondvar_t ipool_cv; /* Condition variable */ 234*5febcb4aSScott Carter, SD IOSW kthread_t *ipool_thread; /* Balancing thread */ 235*5febcb4aSScott Carter, SD IOSW dev_info_t *ipool_owner; /* Device that created pool */ 236*5febcb4aSScott Carter, SD IOSW list_t ipool_req_list; /* All requests in pool */ 237*5febcb4aSScott Carter, SD IOSW list_t ipool_scratch_list; /* Requests being reduced */ 238*5febcb4aSScott Carter, SD IOSW list_node_t ipool_link; /* Links in global pool list */ 239*5febcb4aSScott Carter, SD IOSW } ddi_irm_pool_t; 240*5febcb4aSScott Carter, SD IOSW 241*5febcb4aSScott Carter, SD IOSW /* 242*5febcb4aSScott Carter, SD IOSW * One such data structure for each dip's devinfo_intr_t. 243*5febcb4aSScott Carter, SD IOSW * Contains information about vectors requested from IRM. 244*5febcb4aSScott Carter, SD IOSW */ 245*5febcb4aSScott Carter, SD IOSW typedef struct ddi_irm_req { 246*5febcb4aSScott Carter, SD IOSW int ireq_flags; /* Flags for request */ 247*5febcb4aSScott Carter, SD IOSW int ireq_type; /* Type requested */ 248*5febcb4aSScott Carter, SD IOSW uint_t ireq_nreq; /* Number requested */ 249*5febcb4aSScott Carter, SD IOSW uint_t ireq_navail; /* Number available */ 250*5febcb4aSScott Carter, SD IOSW uint_t ireq_scratch; /* Scratch value */ 251*5febcb4aSScott Carter, SD IOSW dev_info_t *ireq_dip; /* Requesting device */ 252*5febcb4aSScott Carter, SD IOSW ddi_irm_pool_t *ireq_pool_p; /* Supplying pool */ 253*5febcb4aSScott Carter, SD IOSW list_node_t ireq_link; /* Request list link */ 254*5febcb4aSScott Carter, SD IOSW list_node_t ireq_scratch_link; /* Scratch list link */ 255*5febcb4aSScott Carter, SD IOSW } ddi_irm_req_t; 256*5febcb4aSScott Carter, SD IOSW 257*5febcb4aSScott Carter, SD IOSW /* 258*5febcb4aSScott Carter, SD IOSW * This structure is used to pass parameters to ndi_create_irm(), 259*5febcb4aSScott Carter, SD IOSW * and describes the operating parameters of an IRM pool. 260*5febcb4aSScott Carter, SD IOSW */ 261*5febcb4aSScott Carter, SD IOSW typedef struct ddi_irm_params { 262*5febcb4aSScott Carter, SD IOSW int iparams_types; /* Types of interrupts in pool */ 263*5febcb4aSScott Carter, SD IOSW uint_t iparams_total; /* Total size of the pool */ 264*5febcb4aSScott Carter, SD IOSW uint_t iparams_default; /* Default allocation size */ 265*5febcb4aSScott Carter, SD IOSW } ddi_irm_params_t; 2667c478bd9Sstevel@tonic-gate 2677c478bd9Sstevel@tonic-gate /* 2687c478bd9Sstevel@tonic-gate * One such data structure is allocated for each dip. 2697c478bd9Sstevel@tonic-gate * It has interrupt related information that can be 2707c478bd9Sstevel@tonic-gate * stored/retrieved for convenience. 2717c478bd9Sstevel@tonic-gate */ 2727c478bd9Sstevel@tonic-gate typedef struct devinfo_intr { 2737c478bd9Sstevel@tonic-gate /* These three fields show what the device is capable of */ 2747c478bd9Sstevel@tonic-gate uint_t devi_intr_sup_types; /* Intrs supported by device */ 2757c478bd9Sstevel@tonic-gate 2767c478bd9Sstevel@tonic-gate ddi_intr_msix_t *devi_msix_p; /* MSI-X info, if supported */ 2777c478bd9Sstevel@tonic-gate 2787c478bd9Sstevel@tonic-gate /* Next three fields show current status for the device */ 2797c478bd9Sstevel@tonic-gate uint_t devi_intr_curr_type; /* Interrupt type being used */ 2807c478bd9Sstevel@tonic-gate uint_t devi_intr_sup_nintrs; /* #intr supported */ 2817c478bd9Sstevel@tonic-gate uint_t devi_intr_curr_nintrs; /* #intr currently being used */ 2827c478bd9Sstevel@tonic-gate 283*5febcb4aSScott Carter, SD IOSW ddi_intr_handle_t *devi_intr_handle_p; /* Hdl for legacy intr APIs */ 284d12abe7cSanish 285d12abe7cSanish #if defined(__i386) || defined(__amd64) 286d12abe7cSanish /* Save the PCI config space handle */ 287d12abe7cSanish ddi_acc_handle_t devi_cfg_handle; 288d12abe7cSanish int devi_cap_ptr; /* MSI or MSI-X cap pointer */ 289d12abe7cSanish #endif 290*5febcb4aSScott Carter, SD IOSW 291*5febcb4aSScott Carter, SD IOSW ddi_irm_req_t *devi_irm_req_p; /* IRM request information */ 2927c478bd9Sstevel@tonic-gate } devinfo_intr_t; 2937c478bd9Sstevel@tonic-gate 2947c478bd9Sstevel@tonic-gate #define NEXUS_HAS_INTR_OP(dip) \ 2957c478bd9Sstevel@tonic-gate ((DEVI(dip)->devi_ops->devo_bus_ops) && \ 2967c478bd9Sstevel@tonic-gate (DEVI(dip)->devi_ops->devo_bus_ops->busops_rev >= BUSO_REV_9) && \ 2977c478bd9Sstevel@tonic-gate (DEVI(dip)->devi_ops->devo_bus_ops->bus_intr_op)) 2987c478bd9Sstevel@tonic-gate 2997c478bd9Sstevel@tonic-gate int i_ddi_intr_ops(dev_info_t *dip, dev_info_t *rdip, ddi_intr_op_t op, 3007c478bd9Sstevel@tonic-gate ddi_intr_handle_impl_t *hdlp, void *result); 3017c478bd9Sstevel@tonic-gate 3027c478bd9Sstevel@tonic-gate int i_ddi_add_softint(ddi_softint_hdl_impl_t *); 3037c478bd9Sstevel@tonic-gate void i_ddi_remove_softint(ddi_softint_hdl_impl_t *); 304b08160e2Sgovinda int i_ddi_trigger_softint(ddi_softint_hdl_impl_t *, void *); 3057c478bd9Sstevel@tonic-gate int i_ddi_set_softint_pri(ddi_softint_hdl_impl_t *, uint_t); 3067c478bd9Sstevel@tonic-gate 3077c478bd9Sstevel@tonic-gate void i_ddi_intr_devi_init(dev_info_t *dip); 3087c478bd9Sstevel@tonic-gate void i_ddi_intr_devi_fini(dev_info_t *dip); 3097c478bd9Sstevel@tonic-gate 3107c478bd9Sstevel@tonic-gate uint_t i_ddi_intr_get_supported_types(dev_info_t *dip); 3117c478bd9Sstevel@tonic-gate void i_ddi_intr_set_supported_types(dev_info_t *dip, int sup_type); 3127c478bd9Sstevel@tonic-gate uint_t i_ddi_intr_get_current_type(dev_info_t *dip); 3137c478bd9Sstevel@tonic-gate void i_ddi_intr_set_current_type(dev_info_t *dip, int intr_type); 3147c478bd9Sstevel@tonic-gate uint_t i_ddi_intr_get_supported_nintrs(dev_info_t *dip, int intr_type); 3157c478bd9Sstevel@tonic-gate void i_ddi_intr_set_supported_nintrs(dev_info_t *dip, int nintrs); 3167c478bd9Sstevel@tonic-gate uint_t i_ddi_intr_get_current_nintrs(dev_info_t *dip); 3177c478bd9Sstevel@tonic-gate void i_ddi_intr_set_current_nintrs(dev_info_t *dip, int nintrs); 318*5febcb4aSScott Carter, SD IOSW uint_t i_ddi_intr_get_current_navail(dev_info_t *dip, int intr_type); 319*5febcb4aSScott Carter, SD IOSW 320*5febcb4aSScott Carter, SD IOSW ddi_irm_pool_t *i_ddi_intr_get_pool(dev_info_t *dip, int intr_type); 321*5febcb4aSScott Carter, SD IOSW 322*5febcb4aSScott Carter, SD IOSW void irm_init(void); 323*5febcb4aSScott Carter, SD IOSW int i_ddi_irm_insert(dev_info_t *dip, int intr_type, int count); 324*5febcb4aSScott Carter, SD IOSW int i_ddi_irm_modify(dev_info_t *dip, int nreq); 325*5febcb4aSScott Carter, SD IOSW int i_ddi_irm_remove(dev_info_t *dip); 326*5febcb4aSScott Carter, SD IOSW void i_ddi_irm_set_cb(dev_info_t *dip, boolean_t cb_flag); 3277c478bd9Sstevel@tonic-gate 328*5febcb4aSScott Carter, SD IOSW ddi_intr_handle_t i_ddi_get_intr_handle(dev_info_t *dip, int inum); 329*5febcb4aSScott Carter, SD IOSW void i_ddi_set_intr_handle(dev_info_t *dip, int inum, ddi_intr_handle_t hdl); 3307c478bd9Sstevel@tonic-gate 3317c478bd9Sstevel@tonic-gate ddi_intr_msix_t *i_ddi_get_msix(dev_info_t *dip); 3327c478bd9Sstevel@tonic-gate void i_ddi_set_msix(dev_info_t *dip, ddi_intr_msix_t *msix_p); 3337c478bd9Sstevel@tonic-gate 334d12abe7cSanish #if defined(__i386) || defined(__amd64) 335d12abe7cSanish ddi_acc_handle_t i_ddi_get_pci_config_handle(dev_info_t *dip); 336d12abe7cSanish void i_ddi_set_pci_config_handle(dev_info_t *dip, ddi_acc_handle_t handle); 337d12abe7cSanish int i_ddi_get_msi_msix_cap_ptr(dev_info_t *dip); 338d12abe7cSanish void i_ddi_set_msi_msix_cap_ptr(dev_info_t *dip, int cap_ptr); 339d12abe7cSanish #endif 340d12abe7cSanish 341ef643aefSegillett uint_t i_ddi_get_msix_alloc_limit(dev_info_t *dip); 342ef643aefSegillett 3437c478bd9Sstevel@tonic-gate int32_t i_ddi_get_intr_weight(dev_info_t *); 3447c478bd9Sstevel@tonic-gate int32_t i_ddi_set_intr_weight(dev_info_t *, int32_t); 3457c478bd9Sstevel@tonic-gate 3467a364d25Sschwartz void i_ddi_alloc_intr_phdl(ddi_intr_handle_impl_t *); 3477a364d25Sschwartz void i_ddi_free_intr_phdl(ddi_intr_handle_impl_t *); 3487a364d25Sschwartz 3497c478bd9Sstevel@tonic-gate #define DDI_INTR_ASSIGN_HDLR_N_ARGS(hdlp, func, arg1, arg2) \ 3507c478bd9Sstevel@tonic-gate hdlp->ih_cb_func = func; \ 3517c478bd9Sstevel@tonic-gate hdlp->ih_cb_arg1 = arg1; \ 3527c478bd9Sstevel@tonic-gate hdlp->ih_cb_arg2 = arg2; 3537c478bd9Sstevel@tonic-gate 35420036fe5Segillett #ifdef DEBUG 35520036fe5Segillett #define I_DDI_VERIFY_MSIX_HANDLE(hdlp) \ 35620036fe5Segillett if ((hdlp->ih_type == DDI_INTR_TYPE_MSIX) && \ 35720036fe5Segillett (hdlp->ih_flags & DDI_INTR_MSIX_DUP)) { \ 35820036fe5Segillett ASSERT(hdlp->ih_dip == hdlp->ih_main->ih_dip); \ 35920036fe5Segillett ASSERT(hdlp->ih_type == hdlp->ih_main->ih_type); \ 36020036fe5Segillett ASSERT(hdlp->ih_vector == hdlp->ih_main->ih_vector); \ 36120036fe5Segillett ASSERT(hdlp->ih_ver == hdlp->ih_main->ih_ver); \ 36220036fe5Segillett ASSERT(hdlp->ih_cap == hdlp->ih_main->ih_cap); \ 36320036fe5Segillett ASSERT(hdlp->ih_pri == hdlp->ih_main->ih_pri); \ 36420036fe5Segillett } 36520036fe5Segillett #else 36620036fe5Segillett #define I_DDI_VERIFY_MSIX_HANDLE(hdlp) 36720036fe5Segillett #endif 36820036fe5Segillett 3697c478bd9Sstevel@tonic-gate #else /* _KERNEL */ 3707c478bd9Sstevel@tonic-gate 3717c478bd9Sstevel@tonic-gate typedef struct devinfo_intr devinfo_intr_t; 3727c478bd9Sstevel@tonic-gate 3737c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 3747c478bd9Sstevel@tonic-gate 3757c478bd9Sstevel@tonic-gate /* 3767c478bd9Sstevel@tonic-gate * Used only by old DDI interrupt interfaces. 3777c478bd9Sstevel@tonic-gate */ 3787c478bd9Sstevel@tonic-gate 3797c478bd9Sstevel@tonic-gate /* 3807c478bd9Sstevel@tonic-gate * This structure represents one interrupt possible from the given 3817c478bd9Sstevel@tonic-gate * device. It is used in an array for devices with multiple interrupts. 3827c478bd9Sstevel@tonic-gate */ 3837c478bd9Sstevel@tonic-gate struct intrspec { 3847c478bd9Sstevel@tonic-gate uint_t intrspec_pri; /* interrupt priority */ 3857c478bd9Sstevel@tonic-gate uint_t intrspec_vec; /* vector # (0 if none) */ 3867c478bd9Sstevel@tonic-gate uint_t (*intrspec_func)(); /* function to call for interrupt, */ 3877c478bd9Sstevel@tonic-gate /* If (uint_t (*)()) 0, none. */ 3887c478bd9Sstevel@tonic-gate /* If (uint_t (*)()) 1, then */ 3897c478bd9Sstevel@tonic-gate }; 3907c478bd9Sstevel@tonic-gate 3917c478bd9Sstevel@tonic-gate #ifdef _KERNEL 3927c478bd9Sstevel@tonic-gate 393a54f81fbSanish /* 394a54f81fbSanish * Figure out how many FIXED nintrs are supported 395a54f81fbSanish */ 396a54f81fbSanish int i_ddi_get_intx_nintrs(dev_info_t *dip); 397a54f81fbSanish 3987c478bd9Sstevel@tonic-gate /* 3997c478bd9Sstevel@tonic-gate * NOTE: 4007c478bd9Sstevel@tonic-gate * The following 4 busops entry points are obsoleted with version 4017c478bd9Sstevel@tonic-gate * 9 or greater. Use i_ddi_intr_op interface in place of these 4027c478bd9Sstevel@tonic-gate * obsolete interfaces. 4037c478bd9Sstevel@tonic-gate * 4047c478bd9Sstevel@tonic-gate * Remove these busops entry points and all related data structures 4057c478bd9Sstevel@tonic-gate * in future minor/major solaris release. 4067c478bd9Sstevel@tonic-gate */ 4077c478bd9Sstevel@tonic-gate typedef enum {DDI_INTR_CTLOPS_NONE} ddi_intr_ctlop_t; 4087c478bd9Sstevel@tonic-gate 409d84bdf75Segillett /* The following are obsolete interfaces */ 4107c478bd9Sstevel@tonic-gate ddi_intrspec_t i_ddi_get_intrspec(dev_info_t *dip, dev_info_t *rdip, 4117c478bd9Sstevel@tonic-gate uint_t inumber); 4127c478bd9Sstevel@tonic-gate 4137c478bd9Sstevel@tonic-gate int i_ddi_add_intrspec(dev_info_t *dip, dev_info_t *rdip, 4147c478bd9Sstevel@tonic-gate ddi_intrspec_t intrspec, ddi_iblock_cookie_t *iblock_cookiep, 4157c478bd9Sstevel@tonic-gate ddi_idevice_cookie_t *idevice_cookiep, 4167c478bd9Sstevel@tonic-gate uint_t (*int_handler)(caddr_t int_handler_arg), 4177c478bd9Sstevel@tonic-gate caddr_t int_handler_arg, int kind); 4187c478bd9Sstevel@tonic-gate 4197c478bd9Sstevel@tonic-gate void i_ddi_remove_intrspec(dev_info_t *dip, dev_info_t *rdip, 4207c478bd9Sstevel@tonic-gate ddi_intrspec_t intrspec, ddi_iblock_cookie_t iblock_cookie); 4217c478bd9Sstevel@tonic-gate 4227c478bd9Sstevel@tonic-gate int i_ddi_intr_ctlops(dev_info_t *dip, dev_info_t *rdip, 4237c478bd9Sstevel@tonic-gate ddi_intr_ctlop_t op, void *arg, void *val); 4247c478bd9Sstevel@tonic-gate 4257c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 4267c478bd9Sstevel@tonic-gate 4277c478bd9Sstevel@tonic-gate #ifdef __cplusplus 4287c478bd9Sstevel@tonic-gate } 4297c478bd9Sstevel@tonic-gate #endif 4307c478bd9Sstevel@tonic-gate 4317c478bd9Sstevel@tonic-gate #endif /* _SYS_DDI_INTR_IMPL_H */ 432