xref: /titanic_44/usr/src/uts/sun4/io/px/px_msi.h (revision f56c1286e5113aa46bd6e723da14d30c123153f2)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_SYS_PX_MSI_H
28 #define	_SYS_PX_MSI_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 /*
37  * MSI data structure.
38  */
39 typedef struct px_msi {
40 	dev_info_t	*msi_dip;	/* MSI consumer dip */
41 	int		msi_inum;	/* INUM for this device */
42 	uint_t		msi_state;	/* MSI alloc state */
43 	msinum_t	msi_msinum;	/* MSI number */
44 	msiqid_t	msi_msiq_id;	/* MSIQ used */
45 } px_msi_t;
46 
47 #define	MSI_STATE_FREE		0x1
48 #define	MSI_STATE_INUSE		0x2
49 
50 /*
51  * MSI soft state structure.
52  */
53 typedef struct px_msi_state {
54 	uint_t		msi_cnt;	/* No of MSIs */
55 	msinum_t	msi_1st_msinum;	/* First MSI number */
56 	uint_t		msi_data_mask;	/* MSI data mask */
57 	uint_t		msi_data_width; /* MSI data width */
58 	uint64_t	msi_addr32;	/* MSI 32 address */
59 	uint64_t	msi_addr32_len; /* MSI 32 length */
60 	uint64_t	msi_addr64;	/* MSI 64 address */
61 	uint64_t	msi_addr64_len; /* MSI 64 length */
62 
63 	px_msi_t	*msi_p;		/* Pointer to MSIs array */
64 	kmutex_t	msi_mutex;	/* Mutex for MSI alloc/free */
65 	uint_t		msi_type;	/* MSI or MSI-X */
66 	boolean_t	msi_mem_flg;	/* TRUE if driver allocates memory */
67 } px_msi_state_t;
68 
69 /*
70  * px_msi_ranges
71  */
72 typedef struct px_msi_ranges {
73 	int	msi_no;
74 	int	no_msis;
75 } px_msi_ranges_t;
76 
77 /*
78  * px_msi_address_ranges
79  */
80 typedef struct px_msi_address_ranges {
81 	uint32_t	msi_addr32_hi;
82 	uint32_t	msi_addr32_lo;
83 	uint32_t	msi_addr32_len;
84 	uint32_t	msi_addr64_hi;
85 	uint32_t	msi_addr64_lo;
86 	uint32_t	msi_addr64_len;
87 } px_msi_address_ranges_t;
88 
89 #define	PX_MSI_WIDTH			16
90 #define	PX_MSIX_WIDTH			32
91 
92 /*
93  * Default MSI configurations
94  */
95 #define	PX_DEFAULT_MSI_CNT		256
96 #define	PX_DEFAULT_MSI_1ST_MSINUM	0
97 #define	PX_DEFAULT_MSI_DATA_MASK	0xff
98 #define	PX_DEFAULT_MSI_DATA_WIDTH	PX_MSIX_WIDTH
99 
100 #define	PX_MSI_4GIG_LIMIT		0xFFFFFFFFUL
101 #define	PX_MSI_ADDR_LEN			0x10000	/* 64K bytes */
102 
103 extern	int	px_msi_attach(px_t *px_p);
104 extern	void	px_msi_detach(px_t *px_p);
105 
106 extern	int	px_msi_alloc(px_t *px_p, dev_info_t *rdip, int inum,
107 		    int msi_count, int flag, msinum_t *msi_num_p,
108 		    int *actual_msi_count_p);
109 extern	int	px_msi_free(px_t *px_p, dev_info_t *rdip, int inum,
110 		    int msi_count);
111 
112 extern	int	px_msi_get_msinum(px_t *px_p, dev_info_t *rdip,
113 		    int inum, msinum_t *msi_num_p);
114 
115 #ifdef	__cplusplus
116 }
117 #endif
118 
119 #endif	/* _SYS_PX_MSI_H */
120