summaryrefslogtreecommitdiff
path: root/usr/src/uts/sun4/io/px/px_msi.h
blob: 8ccbe28565e18b486a88a1555348058d7053d579 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/*
 * 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
 * or http://www.opensolaris.org/os/licensing.
 * 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_PX_MSI_H
#define	_SYS_PX_MSI_H

#ifdef	__cplusplus
extern "C" {
#endif

/*
 * MSI data structure.
 */
typedef struct px_msi {
	dev_info_t	*msi_dip;	/* MSI consumer dip */
	int		msi_inum;	/* INUM for this device */
	uint_t		msi_state;	/* MSI alloc state */
	msinum_t	msi_msinum;	/* MSI number */
	msiqid_t	msi_msiq_id;	/* MSIQ used */
} px_msi_t;

#define	MSI_STATE_FREE		0x1
#define	MSI_STATE_INUSE		0x2

/*
 * MSI soft state structure.
 */
typedef struct px_msi_state {
	uint_t		msi_cnt;	/* No of MSIs */
	msinum_t	msi_1st_msinum;	/* First MSI number */
	uint_t		msi_data_mask;	/* MSI data mask */
	uint_t		msi_data_width; /* MSI data width */
	uint64_t	msi_addr32;	/* MSI 32 address */
	uint64_t	msi_addr32_len; /* MSI 32 length */
	uint64_t	msi_addr64;	/* MSI 64 address */
	uint64_t	msi_addr64_len; /* MSI 64 length */

	px_msi_t	*msi_p;		/* Pointer to MSIs array */
	kmutex_t	msi_mutex;	/* Mutex for MSI alloc/free */
	uint_t		msi_type;	/* MSI or MSI-X */
	boolean_t	msi_mem_flg;	/* TRUE if driver allocates memory */

	ddi_irm_pool_t	*msi_pool_p;	/* IRM Pool */
} px_msi_state_t;

/*
 * px_msi_ranges
 */
typedef struct px_msi_ranges {
	int	msi_no;
	int	no_msis;
} px_msi_ranges_t;

/*
 * px_msi_address_ranges
 */
typedef struct px_msi_address_ranges {
	uint32_t	msi_addr32_hi;
	uint32_t	msi_addr32_lo;
	uint32_t	msi_addr32_len;
	uint32_t	msi_addr64_hi;
	uint32_t	msi_addr64_lo;
	uint32_t	msi_addr64_len;
} px_msi_address_ranges_t;

#define	PX_MSI_WIDTH			16
#define	PX_MSIX_WIDTH			32

extern	int	px_msi_attach(px_t *px_p);
extern	void	px_msi_detach(px_t *px_p);

extern	int	px_msi_alloc(px_t *px_p, dev_info_t *rdip, int type, int inum,
		    int msi_count, int flag, int *actual_msi_count_p);
extern	int	px_msi_free(px_t *px_p, dev_info_t *rdip, int inum,
		    int msi_count);

extern	int	px_msi_get_msinum(px_t *px_p, dev_info_t *rdip,
		    int inum, msinum_t *msi_num_p);

#ifdef	__cplusplus
}
#endif

#endif	/* _SYS_PX_MSI_H */