xref: /onnv-gate/usr/src/uts/common/sys/ddi_intr_impl.h (revision 10053:79ff8cfc9153)
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 /*
228561SScott.Carter@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #ifndef	_SYS_DDI_INTR_IMPL_H
270Sstevel@tonic-gate #define	_SYS_DDI_INTR_IMPL_H
280Sstevel@tonic-gate 
290Sstevel@tonic-gate /*
300Sstevel@tonic-gate  * Sun DDI interrupt implementation specific definitions
310Sstevel@tonic-gate  */
320Sstevel@tonic-gate 
338561SScott.Carter@Sun.COM #include <sys/list.h>
348561SScott.Carter@Sun.COM #include <sys/ksynch.h>
358561SScott.Carter@Sun.COM 
360Sstevel@tonic-gate #ifdef	__cplusplus
370Sstevel@tonic-gate extern "C" {
380Sstevel@tonic-gate #endif
390Sstevel@tonic-gate 
400Sstevel@tonic-gate #ifdef _KERNEL
410Sstevel@tonic-gate 
420Sstevel@tonic-gate /*
430Sstevel@tonic-gate  * Typedef for interrupt ops
440Sstevel@tonic-gate  */
450Sstevel@tonic-gate typedef enum {
460Sstevel@tonic-gate 	DDI_INTROP_SUPPORTED_TYPES = 1,	/* 1 get supported interrupts types */
470Sstevel@tonic-gate 	DDI_INTROP_NINTRS,		/* 2 get num of interrupts supported */
480Sstevel@tonic-gate 	DDI_INTROP_ALLOC,		/* 3 allocate interrupt handle */
490Sstevel@tonic-gate 	DDI_INTROP_GETPRI,		/* 4 get priority */
500Sstevel@tonic-gate 	DDI_INTROP_SETPRI,		/* 5 set priority */
510Sstevel@tonic-gate 	DDI_INTROP_ADDISR,		/* 6 add interrupt handler */
520Sstevel@tonic-gate 	DDI_INTROP_DUPVEC,		/* 7 duplicate interrupt handler */
530Sstevel@tonic-gate 	DDI_INTROP_ENABLE,		/* 8 enable interrupt */
540Sstevel@tonic-gate 	DDI_INTROP_BLOCKENABLE,		/* 9 block enable interrupts */
550Sstevel@tonic-gate 	DDI_INTROP_BLOCKDISABLE,	/* 10 block disable interrupts */
560Sstevel@tonic-gate 	DDI_INTROP_DISABLE,		/* 11 disable interrupt */
570Sstevel@tonic-gate 	DDI_INTROP_REMISR,		/* 12 remove interrupt handler */
580Sstevel@tonic-gate 	DDI_INTROP_FREE,		/* 13 free interrupt handle */
590Sstevel@tonic-gate 	DDI_INTROP_GETCAP,		/* 14 get capacity */
600Sstevel@tonic-gate 	DDI_INTROP_SETCAP,		/* 15 set capacity */
610Sstevel@tonic-gate 	DDI_INTROP_SETMASK,		/* 16 set mask */
620Sstevel@tonic-gate 	DDI_INTROP_CLRMASK,		/* 17 clear mask */
630Sstevel@tonic-gate 	DDI_INTROP_GETPENDING,		/* 18 get pending interrupt */
648561SScott.Carter@Sun.COM 	DDI_INTROP_NAVAIL,		/* 19 get num of available interrupts */
65*10053SEvan.Yan@Sun.COM 	DDI_INTROP_GETPOOL,		/* 20 get resource management pool */
66*10053SEvan.Yan@Sun.COM 	DDI_INTROP_GETTARGET,		/* 21 get target for a given intr(s) */
67*10053SEvan.Yan@Sun.COM 	DDI_INTROP_SETTARGET		/* 22 set target for a given intr(s) */
680Sstevel@tonic-gate } ddi_intr_op_t;
690Sstevel@tonic-gate 
700Sstevel@tonic-gate /* Version number used in the handles */
710Sstevel@tonic-gate #define	DDI_INTR_VERSION_1	1
720Sstevel@tonic-gate #define	DDI_INTR_VERSION	DDI_INTR_VERSION_1
730Sstevel@tonic-gate 
740Sstevel@tonic-gate /*
750Sstevel@tonic-gate  * One such data structure is allocated per ddi_intr_handle_t
760Sstevel@tonic-gate  * This is the incore copy of the regular interrupt info.
770Sstevel@tonic-gate  */
780Sstevel@tonic-gate typedef struct ddi_intr_handle_impl {
790Sstevel@tonic-gate 	dev_info_t		*ih_dip;	/* dip associated with handle */
800Sstevel@tonic-gate 	uint16_t		ih_type;	/* interrupt type being used */
810Sstevel@tonic-gate 	ushort_t		ih_inum;	/* interrupt number */
82693Sgovinda 	uint32_t		ih_vector;	/* vector number */
830Sstevel@tonic-gate 	uint16_t		ih_ver;		/* Version */
840Sstevel@tonic-gate 	uint_t			ih_state;	/* interrupt handle state */
850Sstevel@tonic-gate 	uint_t			ih_cap;		/* interrupt capabilities */
860Sstevel@tonic-gate 	uint_t			ih_pri;		/* priority - bus dependent */
870Sstevel@tonic-gate 	krwlock_t		ih_rwlock;	/* read/write lock per handle */
880Sstevel@tonic-gate 
890Sstevel@tonic-gate 	uint_t			(*ih_cb_func)(caddr_t, caddr_t);
900Sstevel@tonic-gate 	void			*ih_cb_arg1;
910Sstevel@tonic-gate 	void			*ih_cb_arg2;
920Sstevel@tonic-gate 
930Sstevel@tonic-gate 	/*
941725Segillett 	 * The following 3 members are used to support MSI-X specific features
951725Segillett 	 */
961725Segillett 	uint_t			ih_flags;	/* Misc flags */
971725Segillett 	uint_t			ih_dup_cnt;	/* # of dupped msi-x vectors */
981725Segillett 	struct ddi_intr_handle_impl	*ih_main;
991725Segillett 						/* pntr to the main vector */
1001725Segillett 	/*
1010Sstevel@tonic-gate 	 * The next set of members are for 'scratch' purpose only.
1020Sstevel@tonic-gate 	 * The DDI interrupt framework uses them internally and their
1030Sstevel@tonic-gate 	 * interpretation is left to the framework. For now,
1040Sstevel@tonic-gate 	 *	scratch1	- used to send NINTRs information
1050Sstevel@tonic-gate 	 *			  to various nexus drivers.
1060Sstevel@tonic-gate 	 *	scratch2	- used to send 'behavior' flag
1070Sstevel@tonic-gate 	 *			  information to the nexus drivers
1081542Sjohnny 	 *			  from ddi_intr_alloc().  It is also
1091542Sjohnny 	 *			  used to send 'h_array' to the nexus drivers
1101542Sjohnny 	 *			  for ddi_intr_block_enable/disable() on x86.
111916Sschwartz 	 *	private		- On X86 it usually carries a pointer to
112916Sschwartz 	 *			  ihdl_plat_t.  Not used on SPARC platforms.
1130Sstevel@tonic-gate 	 */
1140Sstevel@tonic-gate 	void			*ih_private;	/* Platform specific data */
1150Sstevel@tonic-gate 	uint_t			ih_scratch1;	/* Scratch1: #interrupts */
1161542Sjohnny 	void			*ih_scratch2;	/* Scratch2: flag/h_array */
117*10053SEvan.Yan@Sun.COM 
118*10053SEvan.Yan@Sun.COM 	/*
119*10053SEvan.Yan@Sun.COM 	 * The ih_target field may not reflect the actual target that is
120*10053SEvan.Yan@Sun.COM 	 * currently being used for the given interrupt. This field is just a
121*10053SEvan.Yan@Sun.COM 	 * snapshot taken either during ddi_intr_add_handler() or
122*10053SEvan.Yan@Sun.COM 	 * ddi_intr_get/set_affinity() calls.
123*10053SEvan.Yan@Sun.COM 	 */
124*10053SEvan.Yan@Sun.COM 	ddi_intr_target_t	ih_target;	/* Target ID */
1250Sstevel@tonic-gate } ddi_intr_handle_impl_t;
1260Sstevel@tonic-gate 
1270Sstevel@tonic-gate /* values for ih_state (strictly for interrupt handle) */
1280Sstevel@tonic-gate #define	DDI_IHDL_STATE_ALLOC	0x01	/* Allocated. ddi_intr_alloc() called */
1290Sstevel@tonic-gate #define	DDI_IHDL_STATE_ADDED	0x02	/* Added interrupt handler */
1300Sstevel@tonic-gate 					/* ddi_intr_add_handler() called */
1310Sstevel@tonic-gate #define	DDI_IHDL_STATE_ENABLE	0x04	/* Enabled. ddi_intr_enable() called */
1320Sstevel@tonic-gate 
1330Sstevel@tonic-gate #define	DDI_INTR_IS_MSI_OR_MSIX(type) \
1340Sstevel@tonic-gate 	((type) == DDI_INTR_TYPE_MSI || (type) == DDI_INTR_TYPE_MSIX)
1350Sstevel@tonic-gate 
1362404Sanish #define	DDI_INTR_BEHAVIOR_FLAG_VALID(f) \
1372404Sanish 	    (((f) == DDI_INTR_ALLOC_NORMAL) || ((f) == DDI_INTR_ALLOC_STRICT))
1382404Sanish 
1392433Sanish #define	DDI_INTR_TYPE_FLAG_VALID(t) \
1402433Sanish 	    (((t) == DDI_INTR_TYPE_FIXED) || \
1412433Sanish 	    ((t) == DDI_INTR_TYPE_MSI) || \
1422433Sanish 	    ((t) == DDI_INTR_TYPE_MSIX))
1432433Sanish 
1441725Segillett /* values for ih_flags */
1451725Segillett #define	DDI_INTR_MSIX_DUP	0x01	/* MSI-X vector which has been dupped */
1461725Segillett 
1474974Segillett /* Maximum number of MSI resources to allocate */
1484974Segillett #define	DDI_MAX_MSI_ALLOC	2
1494974Segillett 
1504974Segillett /* Default number of MSI-X resources to allocate */
1514974Segillett #define	DDI_DEFAULT_MSIX_ALLOC	2
1524974Segillett 
1538925SEvan.Yan@Sun.COM #define	DDI_MSIX_ALLOC_DIVIDER	32
1548925SEvan.Yan@Sun.COM #define	DDI_MIN_MSIX_ALLOC	8
1558925SEvan.Yan@Sun.COM #define	DDI_MAX_MSIX_ALLOC	2048
1563625Segillett 
157999Slq150181 struct av_softinfo;
158999Slq150181 
1590Sstevel@tonic-gate /*
1600Sstevel@tonic-gate  * One such data structure is allocated per ddi_soft_intr_handle
1610Sstevel@tonic-gate  * This is the incore copy of the softint info.
1620Sstevel@tonic-gate  */
1630Sstevel@tonic-gate typedef struct ddi_softint_hdl_impl {
1640Sstevel@tonic-gate 	dev_info_t	*ih_dip;		/* dip associated with handle */
1650Sstevel@tonic-gate 	uint_t		ih_pri;			/* priority - bus dependent */
1660Sstevel@tonic-gate 	krwlock_t	ih_rwlock;		/* read/write lock per handle */
167999Slq150181 	struct av_softinfo *ih_pending;		/* whether softint is pending */
1680Sstevel@tonic-gate 
1690Sstevel@tonic-gate 	uint_t		(*ih_cb_func)(caddr_t, caddr_t);
1700Sstevel@tonic-gate 						/* cb function for soft ints */
1710Sstevel@tonic-gate 	void		*ih_cb_arg1;		/* arg1 of callback function */
1720Sstevel@tonic-gate 	void		*ih_cb_arg2;		/* arg2 passed to "trigger" */
1730Sstevel@tonic-gate 
1740Sstevel@tonic-gate 	/*
1750Sstevel@tonic-gate 	 * The next member is for 'scratch' purpose only.
1760Sstevel@tonic-gate 	 * The DDI interrupt framework uses it internally and its
1770Sstevel@tonic-gate 	 * interpretation is left to the framework.
1780Sstevel@tonic-gate 	 *	private		- used by the DDI framework to pass back
1790Sstevel@tonic-gate 	 *			  and forth 'softid' information on SPARC
1800Sstevel@tonic-gate 	 *			  side only. Not used on X86 platform.
1810Sstevel@tonic-gate 	 */
1820Sstevel@tonic-gate 	void		*ih_private;		/* Platform specific data */
1830Sstevel@tonic-gate } ddi_softint_hdl_impl_t;
1840Sstevel@tonic-gate 
1850Sstevel@tonic-gate /* Softint internal implementation defines */
1860Sstevel@tonic-gate #define	DDI_SOFT_INTR_PRI_M	4
1870Sstevel@tonic-gate #define	DDI_SOFT_INTR_PRI_H	6
1880Sstevel@tonic-gate 
1890Sstevel@tonic-gate /*
1900Sstevel@tonic-gate  * One such data structure is allocated for MSI-X enabled
1910Sstevel@tonic-gate  * device. If no MSI-X is enabled then it is NULL
1920Sstevel@tonic-gate  */
1930Sstevel@tonic-gate typedef struct ddi_intr_msix {
1940Sstevel@tonic-gate 	/* MSI-X Table related information */
1950Sstevel@tonic-gate 	ddi_acc_handle_t	msix_tbl_hdl;		/* MSI-X table handle */
196965Sgovinda 	uint32_t		*msix_tbl_addr;		/* MSI-X table addr */
197965Sgovinda 	uint32_t		msix_tbl_offset;	/* MSI-X table offset */
1980Sstevel@tonic-gate 
1990Sstevel@tonic-gate 	/* MSI-X PBA Table related information */
2000Sstevel@tonic-gate 	ddi_acc_handle_t	msix_pba_hdl;		/* MSI-X PBA handle */
201965Sgovinda 	uint32_t		*msix_pba_addr;		/* MSI-X PBA addr */
202965Sgovinda 	uint32_t		msix_pba_offset;	/* MSI-X PBA offset */
2030Sstevel@tonic-gate 
2040Sstevel@tonic-gate 	ddi_device_acc_attr_t	msix_dev_attr;		/* MSI-X device attr */
2050Sstevel@tonic-gate } ddi_intr_msix_t;
2060Sstevel@tonic-gate 
2078561SScott.Carter@Sun.COM /*
2088561SScott.Carter@Sun.COM  * Interrupt Resource Management (IRM).
2098561SScott.Carter@Sun.COM  */
2108561SScott.Carter@Sun.COM 
2118561SScott.Carter@Sun.COM #define	DDI_IRM_POLICY_LARGE	1
2128561SScott.Carter@Sun.COM #define	DDI_IRM_POLICY_EVEN	2
2138561SScott.Carter@Sun.COM 
2148561SScott.Carter@Sun.COM #define	DDI_IRM_POLICY_VALID(p)	(((p) == DDI_IRM_POLICY_LARGE) || \
2158561SScott.Carter@Sun.COM 				((p) == DDI_IRM_POLICY_EVEN))
2168561SScott.Carter@Sun.COM 
2178561SScott.Carter@Sun.COM #define	DDI_IRM_FLAG_ACTIVE	0x1		/* Pool is active */
2188561SScott.Carter@Sun.COM #define	DDI_IRM_FLAG_QUEUED	0x2		/* Pool is queued */
2198561SScott.Carter@Sun.COM #define	DDI_IRM_FLAG_WAITERS	0x4		/* Pool has waiters */
2208561SScott.Carter@Sun.COM #define	DDI_IRM_FLAG_EXIT	0x8		/* Balance thread must exit */
2218561SScott.Carter@Sun.COM #define	DDI_IRM_FLAG_NEW	0x10		/* Request is new */
2228561SScott.Carter@Sun.COM #define	DDI_IRM_FLAG_CALLBACK	0x20		/* Request has callback */
2238561SScott.Carter@Sun.COM 
2248561SScott.Carter@Sun.COM /*
2258561SScott.Carter@Sun.COM  * One such data structure for each supply of interrupt vectors.
2268561SScott.Carter@Sun.COM  * Contains information about the size and policies defining the
2278561SScott.Carter@Sun.COM  * supply, and a list of associated device-specific requests.
2288561SScott.Carter@Sun.COM  */
2298561SScott.Carter@Sun.COM typedef struct ddi_irm_pool {
2308561SScott.Carter@Sun.COM 	int		ipool_flags;		/* Status flags of the pool */
2318561SScott.Carter@Sun.COM 	int		ipool_types;		/* Types of interrupts */
2328561SScott.Carter@Sun.COM 	int		ipool_policy;		/* Rebalancing policy */
2338561SScott.Carter@Sun.COM 	uint_t		ipool_totsz;		/* Total size of the pool */
2348561SScott.Carter@Sun.COM 	uint_t		ipool_defsz;		/* Default allocation size */
2358561SScott.Carter@Sun.COM 	uint_t		ipool_minno;		/* Minimum number consumed */
2368561SScott.Carter@Sun.COM 	uint_t		ipool_reqno;		/* Total number requested */
2378561SScott.Carter@Sun.COM 	uint_t		ipool_resno;		/* Total number reserved */
2388561SScott.Carter@Sun.COM 	kmutex_t	ipool_lock;		/* Protects all pool usage */
2398561SScott.Carter@Sun.COM 	kmutex_t	ipool_navail_lock;	/* Protects 'navail' of reqs */
2408561SScott.Carter@Sun.COM 	kcondvar_t	ipool_cv;		/* Condition variable */
2418561SScott.Carter@Sun.COM 	kthread_t	*ipool_thread;		/* Balancing thread */
2428561SScott.Carter@Sun.COM 	dev_info_t	*ipool_owner;		/* Device that created pool */
2438561SScott.Carter@Sun.COM 	list_t		ipool_req_list;		/* All requests in pool */
2448561SScott.Carter@Sun.COM 	list_t		ipool_scratch_list;	/* Requests being reduced */
2458561SScott.Carter@Sun.COM 	list_node_t	ipool_link;		/* Links in global pool list */
2468561SScott.Carter@Sun.COM } ddi_irm_pool_t;
2478561SScott.Carter@Sun.COM 
2488561SScott.Carter@Sun.COM /*
2498561SScott.Carter@Sun.COM  * One such data structure for each dip's devinfo_intr_t.
2508561SScott.Carter@Sun.COM  * Contains information about vectors requested from IRM.
2518561SScott.Carter@Sun.COM  */
2528561SScott.Carter@Sun.COM typedef struct ddi_irm_req {
2538561SScott.Carter@Sun.COM 	int		ireq_flags;		/* Flags for request */
2548561SScott.Carter@Sun.COM 	int		ireq_type;		/* Type requested */
2558561SScott.Carter@Sun.COM 	uint_t		ireq_nreq;		/* Number requested */
2568561SScott.Carter@Sun.COM 	uint_t		ireq_navail;		/* Number available */
2578561SScott.Carter@Sun.COM 	uint_t		ireq_scratch;		/* Scratch value */
2588561SScott.Carter@Sun.COM 	dev_info_t	*ireq_dip;		/* Requesting device */
2598561SScott.Carter@Sun.COM 	ddi_irm_pool_t	*ireq_pool_p;		/* Supplying pool */
2608561SScott.Carter@Sun.COM 	list_node_t	ireq_link;		/* Request list link */
2618561SScott.Carter@Sun.COM 	list_node_t	ireq_scratch_link;	/* Scratch list link */
2628561SScott.Carter@Sun.COM } ddi_irm_req_t;
2638561SScott.Carter@Sun.COM 
2648561SScott.Carter@Sun.COM /*
2658561SScott.Carter@Sun.COM  * This structure is used to pass parameters to ndi_create_irm(),
2668561SScott.Carter@Sun.COM  * and describes the operating parameters of an IRM pool.
2678561SScott.Carter@Sun.COM  */
2688561SScott.Carter@Sun.COM typedef struct ddi_irm_params {
2698561SScott.Carter@Sun.COM 	int	iparams_types;		/* Types of interrupts in pool */
2708561SScott.Carter@Sun.COM 	uint_t	iparams_total;		/* Total size of the pool */
2718561SScott.Carter@Sun.COM } ddi_irm_params_t;
2720Sstevel@tonic-gate 
2730Sstevel@tonic-gate /*
2740Sstevel@tonic-gate  * One such data structure is allocated for each dip.
2750Sstevel@tonic-gate  * It has interrupt related information that can be
2760Sstevel@tonic-gate  * stored/retrieved for convenience.
2770Sstevel@tonic-gate  */
2780Sstevel@tonic-gate typedef struct devinfo_intr {
2790Sstevel@tonic-gate 	/* These three fields show what the device is capable of */
2800Sstevel@tonic-gate 	uint_t		devi_intr_sup_types;	/* Intrs supported by device */
2810Sstevel@tonic-gate 
2820Sstevel@tonic-gate 	ddi_intr_msix_t	*devi_msix_p;		/* MSI-X info, if supported */
2830Sstevel@tonic-gate 
2840Sstevel@tonic-gate 	/* Next three fields show current status for the device */
2850Sstevel@tonic-gate 	uint_t		devi_intr_curr_type;	/* Interrupt type being used */
2860Sstevel@tonic-gate 	uint_t		devi_intr_sup_nintrs;	/* #intr supported */
2870Sstevel@tonic-gate 	uint_t		devi_intr_curr_nintrs;	/* #intr currently being used */
2888817SKerry.Shu@Sun.COM 	/*
2898817SKerry.Shu@Sun.COM 	 * #intr currently being enabled
2908817SKerry.Shu@Sun.COM 	 * (for MSI block enable, the valuse is either 1 or 0.)
2918817SKerry.Shu@Sun.COM 	 */
2928817SKerry.Shu@Sun.COM 	uint_t		devi_intr_curr_nenables;
2930Sstevel@tonic-gate 
2948561SScott.Carter@Sun.COM 	ddi_intr_handle_t *devi_intr_handle_p;	/* Hdl for legacy intr APIs */
2951997Sanish 
2961997Sanish #if defined(__i386) || defined(__amd64)
2971997Sanish 	/* Save the PCI config space handle */
2981997Sanish 	ddi_acc_handle_t devi_cfg_handle;
2991997Sanish 	int		 devi_cap_ptr;		/* MSI or MSI-X cap pointer */
3001997Sanish #endif
3018561SScott.Carter@Sun.COM 
3028561SScott.Carter@Sun.COM 	ddi_irm_req_t	*devi_irm_req_p;	/* IRM request information */
3030Sstevel@tonic-gate } devinfo_intr_t;
3040Sstevel@tonic-gate 
3050Sstevel@tonic-gate #define	NEXUS_HAS_INTR_OP(dip)	\
3060Sstevel@tonic-gate 	((DEVI(dip)->devi_ops->devo_bus_ops) && \
3070Sstevel@tonic-gate 	(DEVI(dip)->devi_ops->devo_bus_ops->busops_rev >= BUSO_REV_9) && \
3080Sstevel@tonic-gate 	(DEVI(dip)->devi_ops->devo_bus_ops->bus_intr_op))
3090Sstevel@tonic-gate 
3100Sstevel@tonic-gate int	i_ddi_intr_ops(dev_info_t *dip, dev_info_t *rdip, ddi_intr_op_t op,
3110Sstevel@tonic-gate 	    ddi_intr_handle_impl_t *hdlp, void *result);
3120Sstevel@tonic-gate 
3130Sstevel@tonic-gate int	i_ddi_add_softint(ddi_softint_hdl_impl_t *);
3140Sstevel@tonic-gate void	i_ddi_remove_softint(ddi_softint_hdl_impl_t *);
315278Sgovinda int	i_ddi_trigger_softint(ddi_softint_hdl_impl_t *, void *);
3160Sstevel@tonic-gate int	i_ddi_set_softint_pri(ddi_softint_hdl_impl_t *, uint_t);
3170Sstevel@tonic-gate 
3180Sstevel@tonic-gate void	i_ddi_intr_devi_init(dev_info_t *dip);
3190Sstevel@tonic-gate void	i_ddi_intr_devi_fini(dev_info_t *dip);
3200Sstevel@tonic-gate 
3210Sstevel@tonic-gate uint_t	i_ddi_intr_get_supported_types(dev_info_t *dip);
3220Sstevel@tonic-gate void	i_ddi_intr_set_supported_types(dev_info_t *dip, int sup_type);
3230Sstevel@tonic-gate uint_t	i_ddi_intr_get_current_type(dev_info_t *dip);
3240Sstevel@tonic-gate void	i_ddi_intr_set_current_type(dev_info_t *dip, int intr_type);
3250Sstevel@tonic-gate uint_t	i_ddi_intr_get_supported_nintrs(dev_info_t *dip, int intr_type);
3260Sstevel@tonic-gate void	i_ddi_intr_set_supported_nintrs(dev_info_t *dip, int nintrs);
3270Sstevel@tonic-gate uint_t	i_ddi_intr_get_current_nintrs(dev_info_t *dip);
3280Sstevel@tonic-gate void	i_ddi_intr_set_current_nintrs(dev_info_t *dip, int nintrs);
3298817SKerry.Shu@Sun.COM uint_t	i_ddi_intr_get_current_nenables(dev_info_t *dip);
3308817SKerry.Shu@Sun.COM void	i_ddi_intr_set_current_nenables(dev_info_t *dip, int nintrs);
3318561SScott.Carter@Sun.COM uint_t	i_ddi_intr_get_current_navail(dev_info_t *dip, int intr_type);
3320Sstevel@tonic-gate 
3338561SScott.Carter@Sun.COM ddi_irm_pool_t	*i_ddi_intr_get_pool(dev_info_t *dip, int intr_type);
3348561SScott.Carter@Sun.COM 
3358561SScott.Carter@Sun.COM void	irm_init(void);
3368561SScott.Carter@Sun.COM int	i_ddi_irm_insert(dev_info_t *dip, int intr_type, int count);
3378561SScott.Carter@Sun.COM int	i_ddi_irm_modify(dev_info_t *dip, int nreq);
3388561SScott.Carter@Sun.COM int	i_ddi_irm_remove(dev_info_t *dip);
3398561SScott.Carter@Sun.COM void	i_ddi_irm_set_cb(dev_info_t *dip, boolean_t cb_flag);
3408561SScott.Carter@Sun.COM 
3418561SScott.Carter@Sun.COM ddi_intr_handle_t i_ddi_get_intr_handle(dev_info_t *dip, int inum);
3428561SScott.Carter@Sun.COM void	i_ddi_set_intr_handle(dev_info_t *dip, int inum, ddi_intr_handle_t hdl);
3430Sstevel@tonic-gate 
3440Sstevel@tonic-gate ddi_intr_msix_t	*i_ddi_get_msix(dev_info_t *dip);
3450Sstevel@tonic-gate void	i_ddi_set_msix(dev_info_t *dip, ddi_intr_msix_t *msix_p);
3460Sstevel@tonic-gate 
3471997Sanish #if defined(__i386) || defined(__amd64)
3481997Sanish ddi_acc_handle_t	i_ddi_get_pci_config_handle(dev_info_t *dip);
3491997Sanish void	i_ddi_set_pci_config_handle(dev_info_t *dip, ddi_acc_handle_t handle);
3501997Sanish int	i_ddi_get_msi_msix_cap_ptr(dev_info_t *dip);
3511997Sanish void	i_ddi_set_msi_msix_cap_ptr(dev_info_t *dip, int cap_ptr);
3521997Sanish #endif
3531997Sanish 
3540Sstevel@tonic-gate int32_t i_ddi_get_intr_weight(dev_info_t *);
3550Sstevel@tonic-gate int32_t i_ddi_set_intr_weight(dev_info_t *, int32_t);
3560Sstevel@tonic-gate 
357916Sschwartz void	i_ddi_alloc_intr_phdl(ddi_intr_handle_impl_t *);
358916Sschwartz void	i_ddi_free_intr_phdl(ddi_intr_handle_impl_t *);
359916Sschwartz 
3600Sstevel@tonic-gate #define	DDI_INTR_ASSIGN_HDLR_N_ARGS(hdlp, func, arg1, arg2) \
3610Sstevel@tonic-gate 	hdlp->ih_cb_func = func; \
3620Sstevel@tonic-gate 	hdlp->ih_cb_arg1 = arg1; \
3630Sstevel@tonic-gate 	hdlp->ih_cb_arg2 = arg2;
3640Sstevel@tonic-gate 
3651725Segillett #ifdef DEBUG
3661725Segillett #define	I_DDI_VERIFY_MSIX_HANDLE(hdlp)					\
3671725Segillett 	if ((hdlp->ih_type == DDI_INTR_TYPE_MSIX) && 			\
3681725Segillett 	    (hdlp->ih_flags & DDI_INTR_MSIX_DUP)) {			\
3691725Segillett 		ASSERT(hdlp->ih_dip == hdlp->ih_main->ih_dip);		\
3701725Segillett 		ASSERT(hdlp->ih_type == hdlp->ih_main->ih_type);	\
3711725Segillett 		ASSERT(hdlp->ih_vector == hdlp->ih_main->ih_vector);	\
3721725Segillett 		ASSERT(hdlp->ih_ver == hdlp->ih_main->ih_ver);		\
3731725Segillett 		ASSERT(hdlp->ih_cap == hdlp->ih_main->ih_cap);		\
3741725Segillett 		ASSERT(hdlp->ih_pri == hdlp->ih_main->ih_pri);		\
3751725Segillett 	}
3761725Segillett #else
3771725Segillett #define	I_DDI_VERIFY_MSIX_HANDLE(hdlp)
3781725Segillett #endif
3791725Segillett 
3800Sstevel@tonic-gate #else	/* _KERNEL */
3810Sstevel@tonic-gate 
3820Sstevel@tonic-gate typedef struct devinfo_intr devinfo_intr_t;
3830Sstevel@tonic-gate 
3840Sstevel@tonic-gate #endif	/* _KERNEL */
3850Sstevel@tonic-gate 
3860Sstevel@tonic-gate /*
3870Sstevel@tonic-gate  * Used only by old DDI interrupt interfaces.
3880Sstevel@tonic-gate  */
3890Sstevel@tonic-gate 
3900Sstevel@tonic-gate /*
3910Sstevel@tonic-gate  * This structure represents one interrupt possible from the given
3920Sstevel@tonic-gate  * device. It is used in an array for devices with multiple interrupts.
3930Sstevel@tonic-gate  */
3940Sstevel@tonic-gate struct intrspec {
3950Sstevel@tonic-gate 	uint_t intrspec_pri;		/* interrupt priority */
3960Sstevel@tonic-gate 	uint_t intrspec_vec;		/* vector # (0 if none) */
3970Sstevel@tonic-gate 	uint_t (*intrspec_func)();	/* function to call for interrupt, */
3980Sstevel@tonic-gate 					/* If (uint_t (*)()) 0, none. */
3990Sstevel@tonic-gate 					/* If (uint_t (*)()) 1, then */
4000Sstevel@tonic-gate };
4010Sstevel@tonic-gate 
4020Sstevel@tonic-gate #ifdef _KERNEL
4030Sstevel@tonic-gate 
4040Sstevel@tonic-gate /*
4052580Sanish  * Figure out how many FIXED nintrs are supported
4062580Sanish  */
4072580Sanish int	i_ddi_get_intx_nintrs(dev_info_t *dip);
4082580Sanish 
4092580Sanish /*
4100Sstevel@tonic-gate  * NOTE:
4110Sstevel@tonic-gate  *	The following 4 busops entry points are obsoleted with version
4120Sstevel@tonic-gate  *	9 or greater. Use i_ddi_intr_op interface in place of these
4130Sstevel@tonic-gate  *	obsolete interfaces.
4140Sstevel@tonic-gate  *
4150Sstevel@tonic-gate  *	Remove these busops entry points and all related data structures
4160Sstevel@tonic-gate  *	in future minor/major solaris release.
4170Sstevel@tonic-gate  */
4180Sstevel@tonic-gate typedef enum {DDI_INTR_CTLOPS_NONE} ddi_intr_ctlop_t;
4190Sstevel@tonic-gate 
4203625Segillett /* The following are obsolete interfaces */
4210Sstevel@tonic-gate ddi_intrspec_t	i_ddi_get_intrspec(dev_info_t *dip, dev_info_t *rdip,
4220Sstevel@tonic-gate 	    uint_t inumber);
4230Sstevel@tonic-gate 
4240Sstevel@tonic-gate int	i_ddi_add_intrspec(dev_info_t *dip, dev_info_t *rdip,
4250Sstevel@tonic-gate 	    ddi_intrspec_t intrspec, ddi_iblock_cookie_t *iblock_cookiep,
4260Sstevel@tonic-gate 	    ddi_idevice_cookie_t *idevice_cookiep,
4270Sstevel@tonic-gate 	    uint_t (*int_handler)(caddr_t int_handler_arg),
4280Sstevel@tonic-gate 	    caddr_t int_handler_arg, int kind);
4290Sstevel@tonic-gate 
4300Sstevel@tonic-gate void	i_ddi_remove_intrspec(dev_info_t *dip, dev_info_t *rdip,
4310Sstevel@tonic-gate 	    ddi_intrspec_t intrspec, ddi_iblock_cookie_t iblock_cookie);
4320Sstevel@tonic-gate 
4330Sstevel@tonic-gate int	i_ddi_intr_ctlops(dev_info_t *dip, dev_info_t *rdip,
4340Sstevel@tonic-gate 	    ddi_intr_ctlop_t op, void *arg, void *val);
4350Sstevel@tonic-gate 
4360Sstevel@tonic-gate #endif	/* _KERNEL */
4370Sstevel@tonic-gate 
4380Sstevel@tonic-gate #ifdef	__cplusplus
4390Sstevel@tonic-gate }
4400Sstevel@tonic-gate #endif
4410Sstevel@tonic-gate 
4420Sstevel@tonic-gate #endif	/* _SYS_DDI_INTR_IMPL_H */
443