xref: /titanic_41/usr/src/uts/sun4/io/px/px_msi.h (revision 269473047d747f7815af570197e4ef7322d3632c)
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 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_SYS_PX_MSI_H
27 #define	_SYS_PX_MSI_H
28 
29 #ifdef	__cplusplus
30 extern "C" {
31 #endif
32 
33 /*
34  * MSI data structure.
35  */
36 typedef struct px_msi {
37 	dev_info_t	*msi_dip;	/* MSI consumer dip */
38 	int		msi_inum;	/* INUM for this device */
39 	uint_t		msi_state;	/* MSI alloc state */
40 	msinum_t	msi_msinum;	/* MSI number */
41 	msiqid_t	msi_msiq_id;	/* MSIQ used */
42 } px_msi_t;
43 
44 #define	MSI_STATE_FREE		0x1
45 #define	MSI_STATE_INUSE		0x2
46 
47 /*
48  * MSI soft state structure.
49  */
50 typedef struct px_msi_state {
51 	uint_t		msi_cnt;	/* No of MSIs */
52 	msinum_t	msi_1st_msinum;	/* First MSI number */
53 	uint_t		msi_data_mask;	/* MSI data mask */
54 	uint_t		msi_data_width; /* MSI data width */
55 	uint64_t	msi_addr32;	/* MSI 32 address */
56 	uint64_t	msi_addr32_len; /* MSI 32 length */
57 	uint64_t	msi_addr64;	/* MSI 64 address */
58 	uint64_t	msi_addr64_len; /* MSI 64 length */
59 
60 	px_msi_t	*msi_p;		/* Pointer to MSIs array */
61 	kmutex_t	msi_mutex;	/* Mutex for MSI alloc/free */
62 	uint_t		msi_type;	/* MSI or MSI-X */
63 	boolean_t	msi_mem_flg;	/* TRUE if driver allocates memory */
64 
65 	ddi_irm_pool_t	*msi_pool_p;	/* IRM Pool */
66 } px_msi_state_t;
67 
68 /*
69  * px_msi_ranges
70  */
71 typedef struct px_msi_ranges {
72 	int	msi_no;
73 	int	no_msis;
74 } px_msi_ranges_t;
75 
76 /*
77  * px_msi_address_ranges
78  */
79 typedef struct px_msi_address_ranges {
80 	uint32_t	msi_addr32_hi;
81 	uint32_t	msi_addr32_lo;
82 	uint32_t	msi_addr32_len;
83 	uint32_t	msi_addr64_hi;
84 	uint32_t	msi_addr64_lo;
85 	uint32_t	msi_addr64_len;
86 } px_msi_address_ranges_t;
87 
88 #define	PX_MSI_WIDTH			16
89 #define	PX_MSIX_WIDTH			32
90 
91 extern	int	px_msi_attach(px_t *px_p);
92 extern	void	px_msi_detach(px_t *px_p);
93 
94 extern	int	px_msi_alloc(px_t *px_p, dev_info_t *rdip, int type, int inum,
95 		    int msi_count, int flag, int *actual_msi_count_p);
96 extern	int	px_msi_free(px_t *px_p, dev_info_t *rdip, int inum,
97 		    int msi_count);
98 
99 extern	int	px_msi_get_msinum(px_t *px_p, dev_info_t *rdip,
100 		    int inum, msinum_t *msi_num_p);
101 
102 #ifdef	__cplusplus
103 }
104 #endif
105 
106 #endif	/* _SYS_PX_MSI_H */
107