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