xref: /titanic_44/usr/src/uts/sun4/io/px/px_msi.h (revision 75ce41a57ff334bd8fe2cb9ed51eea835892f944)
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 /*
92  * Default MSI configurations
93  */
94 #define	PX_DEFAULT_MSI_CNT		256
95 #define	PX_DEFAULT_MSI_1ST_MSINUM	0
96 #define	PX_DEFAULT_MSI_DATA_MASK	0xff
97 #define	PX_DEFAULT_MSI_DATA_WIDTH	PX_MSIX_WIDTH
98 
99 #define	PX_MSI_4GIG_LIMIT		0xFFFFFFFFUL
100 #define	PX_MSI_ADDR_LEN			0x10000	/* 64K bytes */
101 
102 extern	int	px_msi_attach(px_t *px_p);
103 extern	void	px_msi_detach(px_t *px_p);
104 
105 extern	int	px_msi_alloc(px_t *px_p, dev_info_t *rdip, int type, int inum,
106 		    int msi_count, int flag, int *actual_msi_count_p);
107 extern	int	px_msi_free(px_t *px_p, dev_info_t *rdip, int inum,
108 		    int msi_count);
109 
110 extern	int	px_msi_get_msinum(px_t *px_p, dev_info_t *rdip,
111 		    int inum, msinum_t *msi_num_p);
112 
113 #ifdef	__cplusplus
114 }
115 #endif
116 
117 #endif	/* _SYS_PX_MSI_H */
118