xref: /titanic_50/usr/src/uts/sun4u/opl/sys/dm2s.h (revision 24da5b34f49324ed742a340010ed5bd3d4e06625)
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	_DDM2S_H
27 #define	_DDM2S_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 #define	DM2S_MAX_SG		20	/* Max. scatter-gather elements */
37 #define	DM2S_MAX_RETRIES	3	/* Max. number of retries */
38 
39 /*
40  * Instance structure.
41  */
42 typedef struct dm2s {
43 	dev_info_t	*ms_dip;	/* Devinfo pointer */
44 	major_t		ms_major;	/* Major number */
45 	uint32_t	ms_ppa;		/* Device instance */
46 	mkey_t		ms_key;		/* Mailbox key */
47 	target_id_t	ms_target;	/* Target-id */
48 
49 	ddi_iblock_cookie_t ms_ibcookie;	/* Interrupt block cookie */
50 	kmutex_t	ms_lock;	/* Lock to protect this structure */
51 	kcondvar_t	ms_wait;	/* Cond. var to signal events */
52 
53 	uint32_t	ms_mtu;		/* MTU supported */
54 	queue_t		*ms_rq;		/* Read side queue */
55 	queue_t		*ms_wq;		/* Write side queuee */
56 	uint32_t	ms_state;	/* State of the device */
57 
58 	uint32_t	ms_retries;	/* Number of retries */
59 	timeout_id_t	ms_rq_timeoutid; /* Timeout id for read queue */
60 	timeout_id_t	ms_wq_timeoutid; /* Timeout id for write queue */
61 	bufcall_id_t	ms_rbufcid;	 /* Buffcall-id for the read */
62 
63 	uint64_t	ms_obytes;	/* Number of output bytes */
64 	uint64_t	ms_ibytes;	/* Number of input bytes */
65 
66 	uint32_t	ms_clean;	/* Cleanup flags */
67 	mscat_gath_t	ms_sg_rcv;	/* Scatter-gather for receive */
68 	mscat_gath_t	ms_sg_tx[DM2S_MAX_SG];	/* scatter-gather for Tx */
69 } dm2s_t;
70 
71 /* ms_state flags */
72 #define	DM2S_MB_INITED		0x00000001	/* Mailbox initialized */
73 #define	DM2S_MB_CONN		0x00000002	/* Mailbox in connected state */
74 #define	DM2S_MB_DISC		0x00000004	/* Mailbox is disconnected */
75 #define	DM2S_OPENED		0x00000008	/* Device opened */
76 
77 #define	DM2S_MBOX_READY(x)	((x)->ms_state & DM2S_MB_CONN)
78 
79 /* ms_clean flags */
80 #define	DM2S_CLEAN_LOCK		0x00000001
81 #define	DM2S_CLEAN_CV		0x00000002
82 #define	DM2S_CLEAN_NODE		0x00000004
83 
84 #ifdef DEBUG
85 /*
86  * Debug levels
87  */
88 #define	DBG_DRV		0x01		/* driver related traces */
89 #define	DBG_MBOX	0x02		/* Mailbox traces */
90 #define	DBG_MESG	0x04		/* Mailbox Message traces */
91 #define	DBG_WARN	0x10		/* warning type traces */
92 
93 static void dm2s_dump_bytes(char *str, uint32_t total_len,
94     uint32_t num_sg, mscat_gath_t *sgp);
95 
96 #define	DPRINTF(f, x)		if (f & dm2s_debug) printf x
97 #define	DMPBYTES(s, l, n, sg)	dm2s_dump_bytes(s, l, n, sg)
98 
99 #else /* DEBUG */
100 
101 #define	DPRINTF(f, x)
102 #define	DMPBYTES(s, l, n, sg)
103 
104 #endif /* DEBUG */
105 
106 #ifdef __cplusplus
107 }
108 #endif
109 
110 #endif /* _DDM2S_H */
111