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