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