xref: /titanic_44/usr/src/uts/sun4/io/px/px_msiq.h (revision ea8dc4b6d2251b437950c0056bc626b311c73c27)
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_MSIQ_H
28 #define	_SYS_PX_MSIQ_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 /*
37  * MSIQ data structure.
38  */
39 struct px_msiq {
40 	msiqid_t	msiq_id;	/* MSIQ ID */
41 	uint_t		msiq_state;	/* MSIQ alloc state */
42 	msiqhead_t	msiq_base;	/* MSIQ base pointer */
43 	msiqtail_t	msiq_curr;	/* MSIQ Curr pointer */
44 };
45 
46 #define	MSIQ_STATE_FREE		0x1
47 #define	MSIQ_STATE_INUSE	0x2
48 
49 /*
50  * MSIQ soft state structure.
51  */
52 typedef struct px_msiq_state {
53 	/* Available MSIQs */
54 	uint_t		msiq_cnt;	/* # of MSIQs */
55 	uint_t		msiq_rec_cnt;	/* # of records per MSIQ */
56 	msiqid_t	msiq_1st_msiq_id; /* First MSIQ ID */
57 	devino_t	msiq_1st_devino; /* First devino */
58 
59 	/* MSIQs specific reserved for MSI/Xs */
60 	uint_t		msiq_msi_qcnt;	/* # of MSIQs for MSI/Xs */
61 	msiqid_t	msiq_1st_msi_qid; /* First MSIQ ID for MSI/Xs */
62 	msiqid_t	msiq_next_msi_qid; /* Next MSIQ index for MSI/Xs */
63 
64 	/* MSIQs specific reserved for PCIe messages */
65 	uint_t		msiq_msg_qcnt;	/* # of MSIQs for PCIe msgs */
66 	msiqid_t	msiq_1st_msg_qid; /* First MSIQ ID for PCIe msgs */
67 	msiqid_t	msiq_next_msg_qid; /* Next MSIQ index for PCIe msgs */
68 
69 	px_msiq_t	*msiq_p;	/* Pointer to MSIQs array */
70 	void		*msiq_buf_p; /* Pointer to MSIQs array */
71 	kmutex_t	msiq_mutex;	/* Mutex for MSIQ alloc/free */
72 } px_msiq_state_t;
73 
74 /*
75  * px_msi_eq_to_devino
76  */
77 typedef struct px_msi_eq_to_devino {
78 	int	msi_eq_no;
79 	int	no_msi_eqs;
80 	int	devino_no;
81 } px_msi_eq_to_devino_t;
82 
83 /*
84  * Default MSIQ Configurations
85  */
86 #define	PX_DEFAULT_MSIQ_CNT		36
87 #define	PX_DEFAULT_MSIQ_REC_CNT		128
88 #define	PX_DEFAULT_MSIQ_1ST_MSIQ_ID	0
89 #define	PX_DEFAULT_MSIQ_1ST_DEVINO	24
90 
91 extern	int	px_msiq_attach(px_t *px_p);
92 extern	void	px_msiq_detach(px_t *px_p);
93 
94 extern	int	px_msiq_alloc(px_t *px_p, msiq_rec_type_t rec_type,
95 		    msiqid_t *msiq_id_p);
96 extern	int	px_msiq_free(px_t *px_p, msiqid_t msiq_id);
97 
98 extern  devino_t px_msiqid_to_devino(px_t *px_p, msiqid_t msiq_id);
99 extern  msiqid_t px_devino_to_msiqid(px_t *px_p, devino_t devino);
100 
101 #ifdef	__cplusplus
102 }
103 #endif
104 
105 #endif	/* _SYS_PX_MSIQ_H */
106