125cf1a3jl/*
225cf1a3jl * CDDL HEADER START
325cf1a3jl *
425cf1a3jl * The contents of this file are subject to the terms of the
525cf1a3jl * Common Development and Distribution License (the "License").
625cf1a3jl * You may not use this file except in compliance with the License.
725cf1a3jl *
825cf1a3jl * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
925cf1a3jl * or http://www.opensolaris.org/os/licensing.
1025cf1a3jl * See the License for the specific language governing permissions
1125cf1a3jl * and limitations under the License.
1225cf1a3jl *
1325cf1a3jl * When distributing Covered Code, include this CDDL HEADER in each
1425cf1a3jl * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1525cf1a3jl * If applicable, add the following below this CDDL HEADER, with the
1625cf1a3jl * fields enclosed by brackets "[]" replaced with your own identifying
1725cf1a3jl * information: Portions Copyright [yyyy] [name of copyright owner]
1825cf1a3jl *
1925cf1a3jl * CDDL HEADER END
2025cf1a3jl */
2125cf1a3jl/*
2225cf1a3jl * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
2325cf1a3jl * Use is subject to license terms.
2425cf1a3jl */
2525cf1a3jl
2625cf1a3jl#ifndef	_DDM2S_H
2725cf1a3jl#define	_DDM2S_H
2825cf1a3jl
2925cf1a3jl#pragma ident	"%Z%%M%	%I%	%E% SMI"
3025cf1a3jl
3125cf1a3jl
3225cf1a3jl#ifdef __cplusplus
3325cf1a3jlextern "C" {
3425cf1a3jl#endif
3525cf1a3jl
3625cf1a3jl#define	DM2S_MAX_SG		20	/* Max. scatter-gather elements */
3725cf1a3jl#define	DM2S_MAX_RETRIES	3	/* Max. number of retries */
3825cf1a3jl
3925cf1a3jl/*
4025cf1a3jl * Instance structure.
4125cf1a3jl */
4225cf1a3jltypedef struct dm2s {
4325cf1a3jl	dev_info_t	*ms_dip;	/* Devinfo pointer */
4425cf1a3jl	major_t		ms_major;	/* Major number */
4525cf1a3jl	uint32_t	ms_ppa;		/* Device instance */
4625cf1a3jl	mkey_t		ms_key;		/* Mailbox key */
4725cf1a3jl	target_id_t	ms_target;	/* Target-id */
4825cf1a3jl
4925cf1a3jl	ddi_iblock_cookie_t ms_ibcookie;	/* Interrupt block cookie */
5025cf1a3jl	kmutex_t	ms_lock;	/* Lock to protect this structure */
5125cf1a3jl	kcondvar_t	ms_wait;	/* Cond. var to signal events */
5225cf1a3jl
5325cf1a3jl	uint32_t	ms_mtu;		/* MTU supported */
5425cf1a3jl	queue_t		*ms_rq;		/* Read side queue */
5525cf1a3jl	queue_t		*ms_wq;		/* Write side queuee */
5625cf1a3jl	uint32_t	ms_state;	/* State of the device */
5725cf1a3jl
5825cf1a3jl	uint32_t	ms_retries;	/* Number of retries */
5925cf1a3jl	timeout_id_t	ms_rq_timeoutid; /* Timeout id for read queue */
6025cf1a3jl	timeout_id_t	ms_wq_timeoutid; /* Timeout id for write queue */
6125cf1a3jl	bufcall_id_t	ms_rbufcid;	 /* Buffcall-id for the read */
6225cf1a3jl
6325cf1a3jl	uint64_t	ms_obytes;	/* Number of output bytes */
6425cf1a3jl	uint64_t	ms_ibytes;	/* Number of input bytes */
6525cf1a3jl
6625cf1a3jl	uint32_t	ms_clean;	/* Cleanup flags */
6725cf1a3jl	mscat_gath_t	ms_sg_rcv;	/* Scatter-gather for receive */
6825cf1a3jl	mscat_gath_t	ms_sg_tx[DM2S_MAX_SG];	/* scatter-gather for Tx */
6925cf1a3jl} dm2s_t;
7025cf1a3jl
7125cf1a3jl/* ms_state flags */
7225cf1a3jl#define	DM2S_MB_INITED		0x00000001	/* Mailbox initialized */
7325cf1a3jl#define	DM2S_MB_CONN		0x00000002	/* Mailbox in connected state */
7425cf1a3jl#define	DM2S_MB_DISC		0x00000004	/* Mailbox is disconnected */
7525cf1a3jl#define	DM2S_OPENED		0x00000008	/* Device opened */
7625cf1a3jl
7725cf1a3jl#define	DM2S_MBOX_READY(x)	((x)->ms_state & DM2S_MB_CONN)
7825cf1a3jl
7925cf1a3jl/* ms_clean flags */
8025cf1a3jl#define	DM2S_CLEAN_LOCK		0x00000001
8125cf1a3jl#define	DM2S_CLEAN_CV		0x00000002
8225cf1a3jl#define	DM2S_CLEAN_NODE		0x00000004
8325cf1a3jl
8425cf1a3jl#ifdef DEBUG
8525cf1a3jl/*
8625cf1a3jl * Debug levels
8725cf1a3jl */
8825cf1a3jl#define	DBG_DRV		0x01		/* driver related traces */
8925cf1a3jl#define	DBG_MBOX	0x02		/* Mailbox traces */
9025cf1a3jl#define	DBG_MESG	0x04		/* Mailbox Message traces */
9125cf1a3jl#define	DBG_WARN	0x10		/* warning type traces */
9225cf1a3jl
9325cf1a3jlstatic void dm2s_dump_bytes(char *str, uint32_t total_len,
9425cf1a3jl    uint32_t num_sg, mscat_gath_t *sgp);
9525cf1a3jl
9625cf1a3jl#define	DPRINTF(f, x)		if (f & dm2s_debug) printf x
9725cf1a3jl#define	DMPBYTES(s, l, n, sg)	dm2s_dump_bytes(s, l, n, sg)
9825cf1a3jl
9925cf1a3jl#else /* DEBUG */
10025cf1a3jl
10125cf1a3jl#define	DPRINTF(f, x)
10225cf1a3jl#define	DMPBYTES(s, l, n, sg)
10325cf1a3jl
10425cf1a3jl#endif /* DEBUG */
10525cf1a3jl
10625cf1a3jl#ifdef __cplusplus
10725cf1a3jl}
10825cf1a3jl#endif
10925cf1a3jl
11025cf1a3jl#endif /* _DDM2S_H */
111