xref: /titanic_41/usr/src/uts/sun4u/opl/sys/oplkm.h (revision 25cf1a301a396c38e8adf52c15f537b80d2483f7)
1*25cf1a30Sjl139090 /*
2*25cf1a30Sjl139090  * CDDL HEADER START
3*25cf1a30Sjl139090  *
4*25cf1a30Sjl139090  * The contents of this file are subject to the terms of the
5*25cf1a30Sjl139090  * Common Development and Distribution License (the "License").
6*25cf1a30Sjl139090  * You may not use this file except in compliance with the License.
7*25cf1a30Sjl139090  *
8*25cf1a30Sjl139090  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*25cf1a30Sjl139090  * or http://www.opensolaris.org/os/licensing.
10*25cf1a30Sjl139090  * See the License for the specific language governing permissions
11*25cf1a30Sjl139090  * and limitations under the License.
12*25cf1a30Sjl139090  *
13*25cf1a30Sjl139090  * When distributing Covered Code, include this CDDL HEADER in each
14*25cf1a30Sjl139090  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*25cf1a30Sjl139090  * If applicable, add the following below this CDDL HEADER, with the
16*25cf1a30Sjl139090  * fields enclosed by brackets "[]" replaced with your own identifying
17*25cf1a30Sjl139090  * information: Portions Copyright [yyyy] [name of copyright owner]
18*25cf1a30Sjl139090  *
19*25cf1a30Sjl139090  * CDDL HEADER END
20*25cf1a30Sjl139090  */
21*25cf1a30Sjl139090 /*
22*25cf1a30Sjl139090  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23*25cf1a30Sjl139090  * Use is subject to license terms.
24*25cf1a30Sjl139090  */
25*25cf1a30Sjl139090 
26*25cf1a30Sjl139090 #ifndef	_SYS_OPLKM_H
27*25cf1a30Sjl139090 #define	_SYS_OPLKM_H
28*25cf1a30Sjl139090 
29*25cf1a30Sjl139090 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30*25cf1a30Sjl139090 
31*25cf1a30Sjl139090 #ifdef	__cplusplus
32*25cf1a30Sjl139090 extern "C" {
33*25cf1a30Sjl139090 #endif
34*25cf1a30Sjl139090 
35*25cf1a30Sjl139090 
36*25cf1a30Sjl139090 /*
37*25cf1a30Sjl139090  * Device instance structure.
38*25cf1a30Sjl139090  */
39*25cf1a30Sjl139090 typedef struct okms {
40*25cf1a30Sjl139090 	dev_info_t	*km_dip;	/* Devinfo pointer */
41*25cf1a30Sjl139090 	major_t		km_major;	/* Major number */
42*25cf1a30Sjl139090 	uint32_t	km_inst;	/* Device instance */
43*25cf1a30Sjl139090 	mkey_t		km_key;		/* Mailbox key */
44*25cf1a30Sjl139090 	target_id_t	km_target;	/* Target-id */
45*25cf1a30Sjl139090 
46*25cf1a30Sjl139090 	ddi_iblock_cookie_t km_ibcookie;	/* Interrupt block cookie */
47*25cf1a30Sjl139090 	kmutex_t	km_lock;	/* Lock to protect this structure */
48*25cf1a30Sjl139090 	kcondvar_t	km_wait;	/* Cond. var to signal events */
49*25cf1a30Sjl139090 	uint32_t	km_state;	/* State of the device */
50*25cf1a30Sjl139090 	uint32_t	km_maxsz;	/* Max msg size */
51*25cf1a30Sjl139090 
52*25cf1a30Sjl139090 	uint32_t	km_retries;	/* Number of retries */
53*25cf1a30Sjl139090 	uint32_t	km_clean;	/* Cleanup flags */
54*25cf1a30Sjl139090 	mscat_gath_t	km_sg_rcv;	/* Scatter-gather for Rx */
55*25cf1a30Sjl139090 	mscat_gath_t	km_sg_tx;	/* Scatter-gather for Tx */
56*25cf1a30Sjl139090 
57*25cf1a30Sjl139090 	okm_req_hdr_t	*km_reqp;	/* Cached request */
58*25cf1a30Sjl139090 	int		km_reqlen;	/* Request length */
59*25cf1a30Sjl139090 } okms_t;
60*25cf1a30Sjl139090 
61*25cf1a30Sjl139090 /* km_state flags */
62*25cf1a30Sjl139090 #define	OKM_MB_INITED		0x00000001	/* Mailbox initialized */
63*25cf1a30Sjl139090 #define	OKM_MB_CONN		0x00000002	/* Mailbox in connected state */
64*25cf1a30Sjl139090 #define	OKM_MB_DISC		0x00000004	/* Mailbox is disconnected */
65*25cf1a30Sjl139090 #define	OKM_OPENED		0x00000008	/* Device opened */
66*25cf1a30Sjl139090 
67*25cf1a30Sjl139090 #define	OKM_MBOX_READY(x)	(((x)->km_state & OKM_MB_CONN) && \
68*25cf1a30Sjl139090 				    !((x)->km_state & OKM_MB_DISC))
69*25cf1a30Sjl139090 
70*25cf1a30Sjl139090 /* km_clean flags */
71*25cf1a30Sjl139090 #define	OKM_CLEAN_LOCK		0x00000001
72*25cf1a30Sjl139090 #define	OKM_CLEAN_CV		0x00000002
73*25cf1a30Sjl139090 #define	OKM_CLEAN_NODE		0x00000004
74*25cf1a30Sjl139090 
75*25cf1a30Sjl139090 #ifdef DEBUG
76*25cf1a30Sjl139090 /*
77*25cf1a30Sjl139090  * Debug levels
78*25cf1a30Sjl139090  */
79*25cf1a30Sjl139090 #define	DBG_DRV		0x01		/* driver related traces */
80*25cf1a30Sjl139090 #define	DBG_MBOX	0x02		/* Mailbox traces */
81*25cf1a30Sjl139090 #define	DBG_MESG	0x04		/* Mailbox Message traces */
82*25cf1a30Sjl139090 #define	DBG_WARN	0x10		/* warning type traces */
83*25cf1a30Sjl139090 
84*25cf1a30Sjl139090 static void okm_print_req(okm_req_hdr_t *reqp, uint32_t len);
85*25cf1a30Sjl139090 static void okm_print_rep(okm_rep_hdr_t *repp);
86*25cf1a30Sjl139090 
87*25cf1a30Sjl139090 #define	DPRINTF(f, x)		if (f & okm_debug) printf x
88*25cf1a30Sjl139090 #define	DUMP_REQ(r, l)		okm_print_req(r, l)
89*25cf1a30Sjl139090 #define	DUMP_REPLY(r)		okm_print_rep(r)
90*25cf1a30Sjl139090 
91*25cf1a30Sjl139090 #else /* DEBUG */
92*25cf1a30Sjl139090 
93*25cf1a30Sjl139090 #define	DPRINTF(f, x)
94*25cf1a30Sjl139090 #define	DUMP_REQ(r, l)
95*25cf1a30Sjl139090 #define	DUMP_REPLY(r)
96*25cf1a30Sjl139090 
97*25cf1a30Sjl139090 #endif /* DEBUG */
98*25cf1a30Sjl139090 
99*25cf1a30Sjl139090 #ifdef	__cplusplus
100*25cf1a30Sjl139090 }
101*25cf1a30Sjl139090 #endif
102*25cf1a30Sjl139090 
103*25cf1a30Sjl139090 #endif	/* _SYS_OPLKM_H */
104