ddi_intr_impl.h revision 09b1eac246a4e627fcbd1ce5bf8005746cbe45ea
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYS_DDI_INTR_IMPL_H
#define _SYS_DDI_INTR_IMPL_H
/*
* Sun DDI interrupt implementation specific definitions
*/
#ifdef __cplusplus
extern "C" {
#endif
#ifdef _KERNEL
/*
* Typedef for interrupt ops
*/
typedef enum {
DDI_INTROP_NINTRS, /* 2 get num of interrupts supported */
DDI_INTROP_ALLOC, /* 3 allocate interrupt handle */
DDI_INTROP_GETPRI, /* 4 get priority */
DDI_INTROP_SETPRI, /* 5 set priority */
DDI_INTROP_ADDISR, /* 6 add interrupt handler */
DDI_INTROP_DUPVEC, /* 7 duplicate interrupt handler */
DDI_INTROP_ENABLE, /* 8 enable interrupt */
DDI_INTROP_BLOCKENABLE, /* 9 block enable interrupts */
DDI_INTROP_BLOCKDISABLE, /* 10 block disable interrupts */
DDI_INTROP_DISABLE, /* 11 disable interrupt */
DDI_INTROP_REMISR, /* 12 remove interrupt handler */
DDI_INTROP_FREE, /* 13 free interrupt handle */
DDI_INTROP_GETCAP, /* 14 get capacity */
DDI_INTROP_SETCAP, /* 15 set capacity */
DDI_INTROP_SETMASK, /* 16 set mask */
DDI_INTROP_CLRMASK, /* 17 clear mask */
DDI_INTROP_GETPENDING, /* 18 get pending interrupt */
DDI_INTROP_NAVAIL, /* 19 get num of available interrupts */
DDI_INTROP_GETPOOL, /* 20 get resource management pool */
DDI_INTROP_GETTARGET, /* 21 get target for a given intr(s) */
DDI_INTROP_SETTARGET /* 22 set target for a given intr(s) */
/* Version number used in the handles */
#define DDI_INTR_VERSION_1 1
#define DDI_INTR_VERSION DDI_INTR_VERSION_1
/*
* One such data structure is allocated per ddi_intr_handle_t
* This is the incore copy of the regular interrupt info.
*/
typedef struct ddi_intr_handle_impl {
void *ih_cb_arg1;
void *ih_cb_arg2;
/*
* The following 3 members are used to support MSI-X specific features
*/
struct ddi_intr_handle_impl *ih_main;
/* pntr to the main vector */
/*
* The next set of members are for 'scratch' purpose only.
* The DDI interrupt framework uses them internally and their
* interpretation is left to the framework. For now,
* scratch1 - used to send NINTRs information
* to various nexus drivers.
* scratch2 - used to send 'behavior' flag
* information to the nexus drivers
* from ddi_intr_alloc(). It is also
* used to send 'h_array' to the nexus drivers
* for ddi_intr_block_enable/disable() on x86.
* private - On X86 it usually carries a pointer to
* ihdl_plat_t. Not used on SPARC platforms.
*/
void *ih_private; /* Platform specific data */
void *ih_scratch2; /* Scratch2: flag/h_array */
/*
* The ih_target field may not reflect the actual target that is
* currently being used for the given interrupt. This field is just a
* snapshot taken either during ddi_intr_add_handler() or
* ddi_intr_get/set_affinity() calls.
*/
/* values for ih_state (strictly for interrupt handle) */
/* ddi_intr_add_handler() called */
#define DDI_INTR_IS_MSI_OR_MSIX(type) \
#define DDI_INTR_BEHAVIOR_FLAG_VALID(f) \
(((f) == DDI_INTR_ALLOC_NORMAL) || ((f) == DDI_INTR_ALLOC_STRICT))
#define DDI_INTR_TYPE_FLAG_VALID(t) \
(((t) == DDI_INTR_TYPE_FIXED) || \
((t) == DDI_INTR_TYPE_MSI) || \
((t) == DDI_INTR_TYPE_MSIX))
/* values for ih_flags */
/* Maximum number of MSI resources to allocate */
#define DDI_MAX_MSI_ALLOC 2
/* Default number of MSI-X resources to allocate */
#define DDI_DEFAULT_MSIX_ALLOC 2
#define DDI_MSIX_ALLOC_DIVIDER 32
#define DDI_MIN_MSIX_ALLOC 8
#define DDI_MAX_MSIX_ALLOC 2048
struct av_softinfo;
/*
* One such data structure is allocated per ddi_soft_intr_handle
* This is the incore copy of the softint info.
*/
typedef struct ddi_softint_hdl_impl {
/* cb function for soft ints */
void *ih_cb_arg1; /* arg1 of callback function */
void *ih_cb_arg2; /* arg2 passed to "trigger" */
/*
* The next member is for 'scratch' purpose only.
* The DDI interrupt framework uses it internally and its
* interpretation is left to the framework.
* private - used by the DDI framework to pass back
* and forth 'softid' information on SPARC
* side only. Not used on X86 platform.
*/
void *ih_private; /* Platform specific data */
/* Softint internal implementation defines */
#define DDI_SOFT_INTR_PRI_M 4
#define DDI_SOFT_INTR_PRI_H 6
/*
* One such data structure is allocated for MSI-X enabled
* device. If no MSI-X is enabled then it is NULL
*/
typedef struct ddi_intr_msix {
/* MSI-X Table related information */
/* MSI-X PBA Table related information */
/*
* Interrupt Resource Management (IRM).
*/
#define DDI_IRM_POLICY_LARGE 1
#define DDI_IRM_POLICY_EVEN 2
#define DDI_IRM_POLICY_VALID(p) (((p) == DDI_IRM_POLICY_LARGE) || \
((p) == DDI_IRM_POLICY_EVEN))
/*
* One such data structure for each supply of interrupt vectors.
* Contains information about the size and policies defining the
* supply, and a list of associated device-specific requests.
*/
typedef struct ddi_irm_pool {
int ipool_flags; /* Status flags of the pool */
int ipool_types; /* Types of interrupts */
int ipool_policy; /* Rebalancing policy */
/*
* One such data structure for each dip's devinfo_intr_t.
* Contains information about vectors requested from IRM.
*/
typedef struct ddi_irm_req {
int ireq_flags; /* Flags for request */
int ireq_type; /* Type requested */
/*
* This structure is used to pass parameters to ndi_create_irm(),
* and describes the operating parameters of an IRM pool.
*/
typedef struct ddi_irm_params {
int iparams_types; /* Types of interrupts in pool */
/*
* One such data structure is allocated for each dip.
* It has interrupt related information that can be
*/
typedef struct devinfo_intr {
/* These three fields show what the device is capable of */
/* Next three fields show current status for the device */
/*
* #intr currently being enabled
* (for MSI block enable, the valuse is either 1 or 0.)
*/
/* Save the PCI config space handle */
int devi_cap_ptr; /* MSI or MSI-X cap pointer */
#endif
#define NEXUS_HAS_INTR_OP(dip) \
int i_ddi_trigger_softint(ddi_softint_hdl_impl_t *, void *);
void irm_init(void);
#endif
#ifdef DEBUG
#define I_DDI_VERIFY_MSIX_HANDLE(hdlp) \
}
#else
#define I_DDI_VERIFY_MSIX_HANDLE(hdlp)
#endif
#else /* _KERNEL */
typedef struct devinfo_intr devinfo_intr_t;
#endif /* _KERNEL */
/*
* Used only by old DDI interrupt interfaces.
*/
/*
* This structure represents one interrupt possible from the given
* device. It is used in an array for devices with multiple interrupts.
*/
struct intrspec {
/* If (uint_t (*)()) 0, none. */
/* If (uint_t (*)()) 1, then */
};
#ifdef _KERNEL
/*
* Figure out how many FIXED nintrs are supported
*/
/*
* NOTE:
* The following 4 busops entry points are obsoleted with version
* 9 or greater. Use i_ddi_intr_op interface in place of these
* obsolete interfaces.
*
* Remove these busops entry points and all related data structures
*/
typedef enum {DDI_INTR_CTLOPS_NONE} ddi_intr_ctlop_t;
/* The following are obsolete interfaces */
#endif /* _KERNEL */
#ifdef __cplusplus
}
#endif
#endif /* _SYS_DDI_INTR_IMPL_H */