10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 51542Sjohnny * Common Development and Distribution License (the "License"). 61542Sjohnny * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 2212473SScott.Carter@Oracle.COM * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 230Sstevel@tonic-gate */ 240Sstevel@tonic-gate 250Sstevel@tonic-gate #ifndef _SYS_DDI_INTR_IMPL_H 260Sstevel@tonic-gate #define _SYS_DDI_INTR_IMPL_H 270Sstevel@tonic-gate 280Sstevel@tonic-gate /* 290Sstevel@tonic-gate * Sun DDI interrupt implementation specific definitions 300Sstevel@tonic-gate */ 310Sstevel@tonic-gate 328561SScott.Carter@Sun.COM #include <sys/list.h> 338561SScott.Carter@Sun.COM #include <sys/ksynch.h> 348561SScott.Carter@Sun.COM 350Sstevel@tonic-gate #ifdef __cplusplus 360Sstevel@tonic-gate extern "C" { 370Sstevel@tonic-gate #endif 380Sstevel@tonic-gate 390Sstevel@tonic-gate #ifdef _KERNEL 400Sstevel@tonic-gate 410Sstevel@tonic-gate /* 420Sstevel@tonic-gate * Typedef for interrupt ops 430Sstevel@tonic-gate */ 440Sstevel@tonic-gate typedef enum { 450Sstevel@tonic-gate DDI_INTROP_SUPPORTED_TYPES = 1, /* 1 get supported interrupts types */ 460Sstevel@tonic-gate DDI_INTROP_NINTRS, /* 2 get num of interrupts supported */ 470Sstevel@tonic-gate DDI_INTROP_ALLOC, /* 3 allocate interrupt handle */ 480Sstevel@tonic-gate DDI_INTROP_GETPRI, /* 4 get priority */ 490Sstevel@tonic-gate DDI_INTROP_SETPRI, /* 5 set priority */ 500Sstevel@tonic-gate DDI_INTROP_ADDISR, /* 6 add interrupt handler */ 510Sstevel@tonic-gate DDI_INTROP_DUPVEC, /* 7 duplicate interrupt handler */ 520Sstevel@tonic-gate DDI_INTROP_ENABLE, /* 8 enable interrupt */ 530Sstevel@tonic-gate DDI_INTROP_BLOCKENABLE, /* 9 block enable interrupts */ 540Sstevel@tonic-gate DDI_INTROP_BLOCKDISABLE, /* 10 block disable interrupts */ 550Sstevel@tonic-gate DDI_INTROP_DISABLE, /* 11 disable interrupt */ 560Sstevel@tonic-gate DDI_INTROP_REMISR, /* 12 remove interrupt handler */ 570Sstevel@tonic-gate DDI_INTROP_FREE, /* 13 free interrupt handle */ 580Sstevel@tonic-gate DDI_INTROP_GETCAP, /* 14 get capacity */ 590Sstevel@tonic-gate DDI_INTROP_SETCAP, /* 15 set capacity */ 600Sstevel@tonic-gate DDI_INTROP_SETMASK, /* 16 set mask */ 610Sstevel@tonic-gate DDI_INTROP_CLRMASK, /* 17 clear mask */ 620Sstevel@tonic-gate DDI_INTROP_GETPENDING, /* 18 get pending interrupt */ 638561SScott.Carter@Sun.COM DDI_INTROP_NAVAIL, /* 19 get num of available interrupts */ 6410053SEvan.Yan@Sun.COM DDI_INTROP_GETPOOL, /* 20 get resource management pool */ 6510053SEvan.Yan@Sun.COM DDI_INTROP_GETTARGET, /* 21 get target for a given intr(s) */ 6610053SEvan.Yan@Sun.COM DDI_INTROP_SETTARGET /* 22 set target for a given intr(s) */ 670Sstevel@tonic-gate } ddi_intr_op_t; 680Sstevel@tonic-gate 690Sstevel@tonic-gate /* Version number used in the handles */ 700Sstevel@tonic-gate #define DDI_INTR_VERSION_1 1 710Sstevel@tonic-gate #define DDI_INTR_VERSION DDI_INTR_VERSION_1 720Sstevel@tonic-gate 730Sstevel@tonic-gate /* 740Sstevel@tonic-gate * One such data structure is allocated per ddi_intr_handle_t 750Sstevel@tonic-gate * This is the incore copy of the regular interrupt info. 760Sstevel@tonic-gate */ 770Sstevel@tonic-gate typedef struct ddi_intr_handle_impl { 780Sstevel@tonic-gate dev_info_t *ih_dip; /* dip associated with handle */ 790Sstevel@tonic-gate uint16_t ih_type; /* interrupt type being used */ 800Sstevel@tonic-gate ushort_t ih_inum; /* interrupt number */ 81693Sgovinda uint32_t ih_vector; /* vector number */ 820Sstevel@tonic-gate uint16_t ih_ver; /* Version */ 830Sstevel@tonic-gate uint_t ih_state; /* interrupt handle state */ 840Sstevel@tonic-gate uint_t ih_cap; /* interrupt capabilities */ 850Sstevel@tonic-gate uint_t ih_pri; /* priority - bus dependent */ 860Sstevel@tonic-gate krwlock_t ih_rwlock; /* read/write lock per handle */ 870Sstevel@tonic-gate 880Sstevel@tonic-gate uint_t (*ih_cb_func)(caddr_t, caddr_t); 890Sstevel@tonic-gate void *ih_cb_arg1; 900Sstevel@tonic-gate void *ih_cb_arg2; 910Sstevel@tonic-gate 920Sstevel@tonic-gate /* 931725Segillett * The following 3 members are used to support MSI-X specific features 941725Segillett */ 951725Segillett uint_t ih_flags; /* Misc flags */ 961725Segillett uint_t ih_dup_cnt; /* # of dupped msi-x vectors */ 971725Segillett struct ddi_intr_handle_impl *ih_main; 981725Segillett /* pntr to the main vector */ 991725Segillett /* 1000Sstevel@tonic-gate * The next set of members are for 'scratch' purpose only. 1010Sstevel@tonic-gate * The DDI interrupt framework uses them internally and their 1020Sstevel@tonic-gate * interpretation is left to the framework. For now, 1030Sstevel@tonic-gate * scratch1 - used to send NINTRs information 1040Sstevel@tonic-gate * to various nexus drivers. 1050Sstevel@tonic-gate * scratch2 - used to send 'behavior' flag 1060Sstevel@tonic-gate * information to the nexus drivers 1071542Sjohnny * from ddi_intr_alloc(). It is also 1081542Sjohnny * used to send 'h_array' to the nexus drivers 1091542Sjohnny * for ddi_intr_block_enable/disable() on x86. 110916Sschwartz * private - On X86 it usually carries a pointer to 111916Sschwartz * ihdl_plat_t. Not used on SPARC platforms. 1120Sstevel@tonic-gate */ 1130Sstevel@tonic-gate void *ih_private; /* Platform specific data */ 1140Sstevel@tonic-gate uint_t ih_scratch1; /* Scratch1: #interrupts */ 1151542Sjohnny void *ih_scratch2; /* Scratch2: flag/h_array */ 11610053SEvan.Yan@Sun.COM 11710053SEvan.Yan@Sun.COM /* 11810053SEvan.Yan@Sun.COM * The ih_target field may not reflect the actual target that is 11910053SEvan.Yan@Sun.COM * currently being used for the given interrupt. This field is just a 12010053SEvan.Yan@Sun.COM * snapshot taken either during ddi_intr_add_handler() or 12112564SGongtian.Zhao@Sun.COM * get/set_intr_affinity() calls. 12210053SEvan.Yan@Sun.COM */ 12312564SGongtian.Zhao@Sun.COM processorid_t ih_target; /* Target ID */ 1240Sstevel@tonic-gate } ddi_intr_handle_impl_t; 1250Sstevel@tonic-gate 1260Sstevel@tonic-gate /* values for ih_state (strictly for interrupt handle) */ 1270Sstevel@tonic-gate #define DDI_IHDL_STATE_ALLOC 0x01 /* Allocated. ddi_intr_alloc() called */ 1280Sstevel@tonic-gate #define DDI_IHDL_STATE_ADDED 0x02 /* Added interrupt handler */ 1290Sstevel@tonic-gate /* ddi_intr_add_handler() called */ 1300Sstevel@tonic-gate #define DDI_IHDL_STATE_ENABLE 0x04 /* Enabled. ddi_intr_enable() called */ 1310Sstevel@tonic-gate 1320Sstevel@tonic-gate #define DDI_INTR_IS_MSI_OR_MSIX(type) \ 1330Sstevel@tonic-gate ((type) == DDI_INTR_TYPE_MSI || (type) == DDI_INTR_TYPE_MSIX) 1340Sstevel@tonic-gate 1352404Sanish #define DDI_INTR_BEHAVIOR_FLAG_VALID(f) \ 1362404Sanish (((f) == DDI_INTR_ALLOC_NORMAL) || ((f) == DDI_INTR_ALLOC_STRICT)) 1372404Sanish 1382433Sanish #define DDI_INTR_TYPE_FLAG_VALID(t) \ 1392433Sanish (((t) == DDI_INTR_TYPE_FIXED) || \ 1402433Sanish ((t) == DDI_INTR_TYPE_MSI) || \ 1412433Sanish ((t) == DDI_INTR_TYPE_MSIX)) 1422433Sanish 1431725Segillett /* values for ih_flags */ 1441725Segillett #define DDI_INTR_MSIX_DUP 0x01 /* MSI-X vector which has been dupped */ 1451725Segillett 1464974Segillett /* Maximum number of MSI resources to allocate */ 1474974Segillett #define DDI_MAX_MSI_ALLOC 2 1484974Segillett 1494974Segillett /* Default number of MSI-X resources to allocate */ 1504974Segillett #define DDI_DEFAULT_MSIX_ALLOC 2 1514974Segillett 1528925SEvan.Yan@Sun.COM #define DDI_MSIX_ALLOC_DIVIDER 32 1538925SEvan.Yan@Sun.COM #define DDI_MIN_MSIX_ALLOC 8 1548925SEvan.Yan@Sun.COM #define DDI_MAX_MSIX_ALLOC 2048 1553625Segillett 156999Slq150181 struct av_softinfo; 157999Slq150181 1580Sstevel@tonic-gate /* 1590Sstevel@tonic-gate * One such data structure is allocated per ddi_soft_intr_handle 1600Sstevel@tonic-gate * This is the incore copy of the softint info. 1610Sstevel@tonic-gate */ 1620Sstevel@tonic-gate typedef struct ddi_softint_hdl_impl { 1630Sstevel@tonic-gate dev_info_t *ih_dip; /* dip associated with handle */ 1640Sstevel@tonic-gate uint_t ih_pri; /* priority - bus dependent */ 1650Sstevel@tonic-gate krwlock_t ih_rwlock; /* read/write lock per handle */ 166999Slq150181 struct av_softinfo *ih_pending; /* whether softint is pending */ 1670Sstevel@tonic-gate 1680Sstevel@tonic-gate uint_t (*ih_cb_func)(caddr_t, caddr_t); 1690Sstevel@tonic-gate /* cb function for soft ints */ 1700Sstevel@tonic-gate void *ih_cb_arg1; /* arg1 of callback function */ 1710Sstevel@tonic-gate void *ih_cb_arg2; /* arg2 passed to "trigger" */ 1720Sstevel@tonic-gate 1730Sstevel@tonic-gate /* 1740Sstevel@tonic-gate * The next member is for 'scratch' purpose only. 1750Sstevel@tonic-gate * The DDI interrupt framework uses it internally and its 1760Sstevel@tonic-gate * interpretation is left to the framework. 1770Sstevel@tonic-gate * private - used by the DDI framework to pass back 1780Sstevel@tonic-gate * and forth 'softid' information on SPARC 1790Sstevel@tonic-gate * side only. Not used on X86 platform. 1800Sstevel@tonic-gate */ 1810Sstevel@tonic-gate void *ih_private; /* Platform specific data */ 1820Sstevel@tonic-gate } ddi_softint_hdl_impl_t; 1830Sstevel@tonic-gate 1840Sstevel@tonic-gate /* Softint internal implementation defines */ 1850Sstevel@tonic-gate #define DDI_SOFT_INTR_PRI_M 4 1860Sstevel@tonic-gate #define DDI_SOFT_INTR_PRI_H 6 1870Sstevel@tonic-gate 1880Sstevel@tonic-gate /* 1890Sstevel@tonic-gate * One such data structure is allocated for MSI-X enabled 1900Sstevel@tonic-gate * device. If no MSI-X is enabled then it is NULL 1910Sstevel@tonic-gate */ 1920Sstevel@tonic-gate typedef struct ddi_intr_msix { 1930Sstevel@tonic-gate /* MSI-X Table related information */ 1940Sstevel@tonic-gate ddi_acc_handle_t msix_tbl_hdl; /* MSI-X table handle */ 195965Sgovinda uint32_t *msix_tbl_addr; /* MSI-X table addr */ 196965Sgovinda uint32_t msix_tbl_offset; /* MSI-X table offset */ 1970Sstevel@tonic-gate 1980Sstevel@tonic-gate /* MSI-X PBA Table related information */ 1990Sstevel@tonic-gate ddi_acc_handle_t msix_pba_hdl; /* MSI-X PBA handle */ 200965Sgovinda uint32_t *msix_pba_addr; /* MSI-X PBA addr */ 201965Sgovinda uint32_t msix_pba_offset; /* MSI-X PBA offset */ 2020Sstevel@tonic-gate 2030Sstevel@tonic-gate ddi_device_acc_attr_t msix_dev_attr; /* MSI-X device attr */ 2040Sstevel@tonic-gate } ddi_intr_msix_t; 2050Sstevel@tonic-gate 2068561SScott.Carter@Sun.COM /* 2078561SScott.Carter@Sun.COM * Interrupt Resource Management (IRM). 2088561SScott.Carter@Sun.COM */ 2098561SScott.Carter@Sun.COM 2108561SScott.Carter@Sun.COM #define DDI_IRM_POLICY_LARGE 1 2118561SScott.Carter@Sun.COM #define DDI_IRM_POLICY_EVEN 2 2128561SScott.Carter@Sun.COM 2138561SScott.Carter@Sun.COM #define DDI_IRM_POLICY_VALID(p) (((p) == DDI_IRM_POLICY_LARGE) || \ 2148561SScott.Carter@Sun.COM ((p) == DDI_IRM_POLICY_EVEN)) 2158561SScott.Carter@Sun.COM 2168561SScott.Carter@Sun.COM #define DDI_IRM_FLAG_ACTIVE 0x1 /* Pool is active */ 2178561SScott.Carter@Sun.COM #define DDI_IRM_FLAG_QUEUED 0x2 /* Pool is queued */ 2188561SScott.Carter@Sun.COM #define DDI_IRM_FLAG_WAITERS 0x4 /* Pool has waiters */ 2198561SScott.Carter@Sun.COM #define DDI_IRM_FLAG_EXIT 0x8 /* Balance thread must exit */ 2208561SScott.Carter@Sun.COM #define DDI_IRM_FLAG_NEW 0x10 /* Request is new */ 2218561SScott.Carter@Sun.COM #define DDI_IRM_FLAG_CALLBACK 0x20 /* Request has callback */ 2228561SScott.Carter@Sun.COM 2238561SScott.Carter@Sun.COM /* 2248561SScott.Carter@Sun.COM * One such data structure for each supply of interrupt vectors. 2258561SScott.Carter@Sun.COM * Contains information about the size and policies defining the 2268561SScott.Carter@Sun.COM * supply, and a list of associated device-specific requests. 2278561SScott.Carter@Sun.COM */ 2288561SScott.Carter@Sun.COM typedef struct ddi_irm_pool { 2298561SScott.Carter@Sun.COM int ipool_flags; /* Status flags of the pool */ 2308561SScott.Carter@Sun.COM int ipool_types; /* Types of interrupts */ 2318561SScott.Carter@Sun.COM int ipool_policy; /* Rebalancing policy */ 2328561SScott.Carter@Sun.COM uint_t ipool_totsz; /* Total size of the pool */ 2338561SScott.Carter@Sun.COM uint_t ipool_defsz; /* Default allocation size */ 2348561SScott.Carter@Sun.COM uint_t ipool_minno; /* Minimum number consumed */ 2358561SScott.Carter@Sun.COM uint_t ipool_reqno; /* Total number requested */ 2368561SScott.Carter@Sun.COM uint_t ipool_resno; /* Total number reserved */ 2378561SScott.Carter@Sun.COM kmutex_t ipool_lock; /* Protects all pool usage */ 2388561SScott.Carter@Sun.COM kmutex_t ipool_navail_lock; /* Protects 'navail' of reqs */ 2398561SScott.Carter@Sun.COM kcondvar_t ipool_cv; /* Condition variable */ 2408561SScott.Carter@Sun.COM kthread_t *ipool_thread; /* Balancing thread */ 2418561SScott.Carter@Sun.COM dev_info_t *ipool_owner; /* Device that created pool */ 2428561SScott.Carter@Sun.COM list_t ipool_req_list; /* All requests in pool */ 2438561SScott.Carter@Sun.COM list_t ipool_scratch_list; /* Requests being reduced */ 2448561SScott.Carter@Sun.COM list_node_t ipool_link; /* Links in global pool list */ 2458561SScott.Carter@Sun.COM } ddi_irm_pool_t; 2468561SScott.Carter@Sun.COM 2478561SScott.Carter@Sun.COM /* 2488561SScott.Carter@Sun.COM * One such data structure for each dip's devinfo_intr_t. 2498561SScott.Carter@Sun.COM * Contains information about vectors requested from IRM. 2508561SScott.Carter@Sun.COM */ 2518561SScott.Carter@Sun.COM typedef struct ddi_irm_req { 2528561SScott.Carter@Sun.COM int ireq_flags; /* Flags for request */ 2538561SScott.Carter@Sun.COM int ireq_type; /* Type requested */ 2548561SScott.Carter@Sun.COM uint_t ireq_nreq; /* Number requested */ 2558561SScott.Carter@Sun.COM uint_t ireq_navail; /* Number available */ 2568561SScott.Carter@Sun.COM uint_t ireq_scratch; /* Scratch value */ 2578561SScott.Carter@Sun.COM dev_info_t *ireq_dip; /* Requesting device */ 2588561SScott.Carter@Sun.COM ddi_irm_pool_t *ireq_pool_p; /* Supplying pool */ 2598561SScott.Carter@Sun.COM list_node_t ireq_link; /* Request list link */ 2608561SScott.Carter@Sun.COM list_node_t ireq_scratch_link; /* Scratch list link */ 2618561SScott.Carter@Sun.COM } ddi_irm_req_t; 2628561SScott.Carter@Sun.COM 2638561SScott.Carter@Sun.COM /* 2648561SScott.Carter@Sun.COM * This structure is used to pass parameters to ndi_create_irm(), 2658561SScott.Carter@Sun.COM * and describes the operating parameters of an IRM pool. 2668561SScott.Carter@Sun.COM */ 2678561SScott.Carter@Sun.COM typedef struct ddi_irm_params { 2688561SScott.Carter@Sun.COM int iparams_types; /* Types of interrupts in pool */ 2698561SScott.Carter@Sun.COM uint_t iparams_total; /* Total size of the pool */ 2708561SScott.Carter@Sun.COM } ddi_irm_params_t; 2710Sstevel@tonic-gate 2720Sstevel@tonic-gate /* 2730Sstevel@tonic-gate * One such data structure is allocated for each dip. 2740Sstevel@tonic-gate * It has interrupt related information that can be 2750Sstevel@tonic-gate * stored/retrieved for convenience. 2760Sstevel@tonic-gate */ 2770Sstevel@tonic-gate typedef struct devinfo_intr { 2780Sstevel@tonic-gate /* These three fields show what the device is capable of */ 2790Sstevel@tonic-gate uint_t devi_intr_sup_types; /* Intrs supported by device */ 2800Sstevel@tonic-gate 2810Sstevel@tonic-gate ddi_intr_msix_t *devi_msix_p; /* MSI-X info, if supported */ 2820Sstevel@tonic-gate 2830Sstevel@tonic-gate /* Next three fields show current status for the device */ 2840Sstevel@tonic-gate uint_t devi_intr_curr_type; /* Interrupt type being used */ 2850Sstevel@tonic-gate uint_t devi_intr_sup_nintrs; /* #intr supported */ 2860Sstevel@tonic-gate uint_t devi_intr_curr_nintrs; /* #intr currently being used */ 2878817SKerry.Shu@Sun.COM /* 2888817SKerry.Shu@Sun.COM * #intr currently being enabled 2898817SKerry.Shu@Sun.COM * (for MSI block enable, the valuse is either 1 or 0.) 2908817SKerry.Shu@Sun.COM */ 2918817SKerry.Shu@Sun.COM uint_t devi_intr_curr_nenables; 2920Sstevel@tonic-gate 2938561SScott.Carter@Sun.COM ddi_intr_handle_t *devi_intr_handle_p; /* Hdl for legacy intr APIs */ 2941997Sanish 2951997Sanish #if defined(__i386) || defined(__amd64) 2961997Sanish /* Save the PCI config space handle */ 2971997Sanish ddi_acc_handle_t devi_cfg_handle; 2981997Sanish int devi_cap_ptr; /* MSI or MSI-X cap pointer */ 2991997Sanish #endif 3008561SScott.Carter@Sun.COM 3018561SScott.Carter@Sun.COM ddi_irm_req_t *devi_irm_req_p; /* IRM request information */ 3020Sstevel@tonic-gate } devinfo_intr_t; 3030Sstevel@tonic-gate 3040Sstevel@tonic-gate #define NEXUS_HAS_INTR_OP(dip) \ 3050Sstevel@tonic-gate ((DEVI(dip)->devi_ops->devo_bus_ops) && \ 3060Sstevel@tonic-gate (DEVI(dip)->devi_ops->devo_bus_ops->busops_rev >= BUSO_REV_9) && \ 3070Sstevel@tonic-gate (DEVI(dip)->devi_ops->devo_bus_ops->bus_intr_op)) 3080Sstevel@tonic-gate 3090Sstevel@tonic-gate int i_ddi_intr_ops(dev_info_t *dip, dev_info_t *rdip, ddi_intr_op_t op, 3100Sstevel@tonic-gate ddi_intr_handle_impl_t *hdlp, void *result); 3110Sstevel@tonic-gate 3120Sstevel@tonic-gate int i_ddi_add_softint(ddi_softint_hdl_impl_t *); 3130Sstevel@tonic-gate void i_ddi_remove_softint(ddi_softint_hdl_impl_t *); 314278Sgovinda int i_ddi_trigger_softint(ddi_softint_hdl_impl_t *, void *); 3150Sstevel@tonic-gate int i_ddi_set_softint_pri(ddi_softint_hdl_impl_t *, uint_t); 3160Sstevel@tonic-gate 3170Sstevel@tonic-gate void i_ddi_intr_devi_init(dev_info_t *dip); 3180Sstevel@tonic-gate void i_ddi_intr_devi_fini(dev_info_t *dip); 3190Sstevel@tonic-gate 3200Sstevel@tonic-gate uint_t i_ddi_intr_get_supported_types(dev_info_t *dip); 3210Sstevel@tonic-gate void i_ddi_intr_set_supported_types(dev_info_t *dip, int sup_type); 3220Sstevel@tonic-gate uint_t i_ddi_intr_get_current_type(dev_info_t *dip); 3230Sstevel@tonic-gate void i_ddi_intr_set_current_type(dev_info_t *dip, int intr_type); 3240Sstevel@tonic-gate uint_t i_ddi_intr_get_supported_nintrs(dev_info_t *dip, int intr_type); 3250Sstevel@tonic-gate void i_ddi_intr_set_supported_nintrs(dev_info_t *dip, int nintrs); 3260Sstevel@tonic-gate uint_t i_ddi_intr_get_current_nintrs(dev_info_t *dip); 3270Sstevel@tonic-gate void i_ddi_intr_set_current_nintrs(dev_info_t *dip, int nintrs); 3288817SKerry.Shu@Sun.COM uint_t i_ddi_intr_get_current_nenables(dev_info_t *dip); 3298817SKerry.Shu@Sun.COM void i_ddi_intr_set_current_nenables(dev_info_t *dip, int nintrs); 3308561SScott.Carter@Sun.COM uint_t i_ddi_intr_get_current_navail(dev_info_t *dip, int intr_type); 33112473SScott.Carter@Oracle.COM uint_t i_ddi_intr_get_limit(dev_info_t *dip, int intr_type, 33212473SScott.Carter@Oracle.COM ddi_irm_pool_t *pool_p); 3330Sstevel@tonic-gate 3348561SScott.Carter@Sun.COM ddi_irm_pool_t *i_ddi_intr_get_pool(dev_info_t *dip, int intr_type); 3358561SScott.Carter@Sun.COM 3368561SScott.Carter@Sun.COM void irm_init(void); 3378561SScott.Carter@Sun.COM int i_ddi_irm_insert(dev_info_t *dip, int intr_type, int count); 3388561SScott.Carter@Sun.COM int i_ddi_irm_modify(dev_info_t *dip, int nreq); 3398561SScott.Carter@Sun.COM int i_ddi_irm_remove(dev_info_t *dip); 3408561SScott.Carter@Sun.COM void i_ddi_irm_set_cb(dev_info_t *dip, boolean_t cb_flag); 34112473SScott.Carter@Oracle.COM int i_ddi_irm_supported(dev_info_t *dip, int type); 3428561SScott.Carter@Sun.COM 3438561SScott.Carter@Sun.COM ddi_intr_handle_t i_ddi_get_intr_handle(dev_info_t *dip, int inum); 3448561SScott.Carter@Sun.COM void i_ddi_set_intr_handle(dev_info_t *dip, int inum, ddi_intr_handle_t hdl); 3450Sstevel@tonic-gate 3460Sstevel@tonic-gate ddi_intr_msix_t *i_ddi_get_msix(dev_info_t *dip); 3470Sstevel@tonic-gate void i_ddi_set_msix(dev_info_t *dip, ddi_intr_msix_t *msix_p); 3480Sstevel@tonic-gate 3491997Sanish #if defined(__i386) || defined(__amd64) 3501997Sanish ddi_acc_handle_t i_ddi_get_pci_config_handle(dev_info_t *dip); 3511997Sanish void i_ddi_set_pci_config_handle(dev_info_t *dip, ddi_acc_handle_t handle); 3521997Sanish int i_ddi_get_msi_msix_cap_ptr(dev_info_t *dip); 3531997Sanish void i_ddi_set_msi_msix_cap_ptr(dev_info_t *dip, int cap_ptr); 3541997Sanish #endif 3551997Sanish 3560Sstevel@tonic-gate int32_t i_ddi_get_intr_weight(dev_info_t *); 3570Sstevel@tonic-gate int32_t i_ddi_set_intr_weight(dev_info_t *, int32_t); 3580Sstevel@tonic-gate 359916Sschwartz void i_ddi_alloc_intr_phdl(ddi_intr_handle_impl_t *); 360916Sschwartz void i_ddi_free_intr_phdl(ddi_intr_handle_impl_t *); 361916Sschwartz 362*12683SJimmy.Vetayases@oracle.com extern int irm_enable; /* global flag for IRM */ 363*12683SJimmy.Vetayases@oracle.com 3640Sstevel@tonic-gate #define DDI_INTR_ASSIGN_HDLR_N_ARGS(hdlp, func, arg1, arg2) \ 3650Sstevel@tonic-gate hdlp->ih_cb_func = func; \ 3660Sstevel@tonic-gate hdlp->ih_cb_arg1 = arg1; \ 3670Sstevel@tonic-gate hdlp->ih_cb_arg2 = arg2; 3680Sstevel@tonic-gate 3691725Segillett #ifdef DEBUG 3701725Segillett #define I_DDI_VERIFY_MSIX_HANDLE(hdlp) \ 3711725Segillett if ((hdlp->ih_type == DDI_INTR_TYPE_MSIX) && \ 3721725Segillett (hdlp->ih_flags & DDI_INTR_MSIX_DUP)) { \ 3731725Segillett ASSERT(hdlp->ih_dip == hdlp->ih_main->ih_dip); \ 3741725Segillett ASSERT(hdlp->ih_type == hdlp->ih_main->ih_type); \ 3751725Segillett ASSERT(hdlp->ih_vector == hdlp->ih_main->ih_vector); \ 3761725Segillett ASSERT(hdlp->ih_ver == hdlp->ih_main->ih_ver); \ 3771725Segillett ASSERT(hdlp->ih_cap == hdlp->ih_main->ih_cap); \ 3781725Segillett ASSERT(hdlp->ih_pri == hdlp->ih_main->ih_pri); \ 3791725Segillett } 3801725Segillett #else 3811725Segillett #define I_DDI_VERIFY_MSIX_HANDLE(hdlp) 3821725Segillett #endif 3831725Segillett 3840Sstevel@tonic-gate #else /* _KERNEL */ 3850Sstevel@tonic-gate 3860Sstevel@tonic-gate typedef struct devinfo_intr devinfo_intr_t; 3870Sstevel@tonic-gate 3880Sstevel@tonic-gate #endif /* _KERNEL */ 3890Sstevel@tonic-gate 3900Sstevel@tonic-gate /* 3910Sstevel@tonic-gate * Used only by old DDI interrupt interfaces. 3920Sstevel@tonic-gate */ 3930Sstevel@tonic-gate 3940Sstevel@tonic-gate /* 3950Sstevel@tonic-gate * This structure represents one interrupt possible from the given 3960Sstevel@tonic-gate * device. It is used in an array for devices with multiple interrupts. 3970Sstevel@tonic-gate */ 3980Sstevel@tonic-gate struct intrspec { 3990Sstevel@tonic-gate uint_t intrspec_pri; /* interrupt priority */ 4000Sstevel@tonic-gate uint_t intrspec_vec; /* vector # (0 if none) */ 4010Sstevel@tonic-gate uint_t (*intrspec_func)(); /* function to call for interrupt, */ 4020Sstevel@tonic-gate /* If (uint_t (*)()) 0, none. */ 4030Sstevel@tonic-gate /* If (uint_t (*)()) 1, then */ 4040Sstevel@tonic-gate }; 4050Sstevel@tonic-gate 4060Sstevel@tonic-gate #ifdef _KERNEL 4070Sstevel@tonic-gate 4080Sstevel@tonic-gate /* 4092580Sanish * Figure out how many FIXED nintrs are supported 4102580Sanish */ 4112580Sanish int i_ddi_get_intx_nintrs(dev_info_t *dip); 4122580Sanish 4132580Sanish /* 4140Sstevel@tonic-gate * NOTE: 4150Sstevel@tonic-gate * The following 4 busops entry points are obsoleted with version 4160Sstevel@tonic-gate * 9 or greater. Use i_ddi_intr_op interface in place of these 4170Sstevel@tonic-gate * obsolete interfaces. 4180Sstevel@tonic-gate * 4190Sstevel@tonic-gate * Remove these busops entry points and all related data structures 4200Sstevel@tonic-gate * in future minor/major solaris release. 4210Sstevel@tonic-gate */ 4220Sstevel@tonic-gate typedef enum {DDI_INTR_CTLOPS_NONE} ddi_intr_ctlop_t; 4230Sstevel@tonic-gate 42412564SGongtian.Zhao@Sun.COM /* 42512564SGongtian.Zhao@Sun.COM * Interrupt get/set affinity functions 42612564SGongtian.Zhao@Sun.COM */ 42712564SGongtian.Zhao@Sun.COM int get_intr_affinity(ddi_intr_handle_t h, processorid_t *tgt_p); 42812564SGongtian.Zhao@Sun.COM int set_intr_affinity(ddi_intr_handle_t h, processorid_t tgt); 42912564SGongtian.Zhao@Sun.COM 4303625Segillett /* The following are obsolete interfaces */ 4310Sstevel@tonic-gate ddi_intrspec_t i_ddi_get_intrspec(dev_info_t *dip, dev_info_t *rdip, 4320Sstevel@tonic-gate uint_t inumber); 4330Sstevel@tonic-gate 4340Sstevel@tonic-gate int i_ddi_add_intrspec(dev_info_t *dip, dev_info_t *rdip, 4350Sstevel@tonic-gate ddi_intrspec_t intrspec, ddi_iblock_cookie_t *iblock_cookiep, 4360Sstevel@tonic-gate ddi_idevice_cookie_t *idevice_cookiep, 4370Sstevel@tonic-gate uint_t (*int_handler)(caddr_t int_handler_arg), 4380Sstevel@tonic-gate caddr_t int_handler_arg, int kind); 4390Sstevel@tonic-gate 4400Sstevel@tonic-gate void i_ddi_remove_intrspec(dev_info_t *dip, dev_info_t *rdip, 4410Sstevel@tonic-gate ddi_intrspec_t intrspec, ddi_iblock_cookie_t iblock_cookie); 4420Sstevel@tonic-gate 4430Sstevel@tonic-gate int i_ddi_intr_ctlops(dev_info_t *dip, dev_info_t *rdip, 4440Sstevel@tonic-gate ddi_intr_ctlop_t op, void *arg, void *val); 4450Sstevel@tonic-gate 4460Sstevel@tonic-gate #endif /* _KERNEL */ 4470Sstevel@tonic-gate 4480Sstevel@tonic-gate #ifdef __cplusplus 4490Sstevel@tonic-gate } 4500Sstevel@tonic-gate #endif 4510Sstevel@tonic-gate 4520Sstevel@tonic-gate #endif /* _SYS_DDI_INTR_IMPL_H */ 453