Home | History | Annotate | Line # | Download | only in ic
isp_netbsd.h revision 1.9
      1 /* $NetBSD: isp_netbsd.h,v 1.9 1999/01/30 07:31:50 mjacob Exp $ */
      2 /* release_01_29_99 */
      3 /*
      4  * NetBSD Specific definitions for the Qlogic ISP Host Adapter
      5  *
      6  *---------------------------------------
      7  * Copyright (c) 1997, 1998 by Matthew Jacob
      8  * NASA/Ames Research Center
      9  * All rights reserved.
     10  *---------------------------------------
     11  *
     12  * Redistribution and use in source and binary forms, with or without
     13  * modification, are permitted provided that the following conditions
     14  * are met:
     15  * 1. Redistributions of source code must retain the above copyright
     16  *    notice immediately at the beginning of the file, without modification,
     17  *    this list of conditions, and the following disclaimer.
     18  * 2. Redistributions in binary form must reproduce the above copyright
     19  *    notice, this list of conditions and the following disclaimer in the
     20  *    documentation and/or other materials provided with the distribution.
     21  * 3. The name of the author may not be used to endorse or promote products
     22  *    derived from this software without specific prior written permission.
     23  *
     24  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     25  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     26  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     27  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
     28  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     29  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     30  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     31  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     33  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     34  * SUCH DAMAGE.
     35  *
     36  */
     37 
     38 #ifndef	_ISP_NETBSD_H
     39 #define	_ISP_NETBSD_H
     40 
     41 #include <sys/types.h>
     42 #include <sys/param.h>
     43 #include <sys/systm.h>
     44 #include <sys/kernel.h>
     45 #include <sys/errno.h>
     46 #include <sys/ioctl.h>
     47 #include <sys/device.h>
     48 #include <sys/malloc.h>
     49 #include <sys/buf.h>
     50 #include <sys/proc.h>
     51 #include <sys/user.h>
     52 
     53 
     54 #include <dev/scsipi/scsi_all.h>
     55 #include <dev/scsipi/scsipi_all.h>
     56 #include <dev/scsipi/scsiconf.h>
     57 
     58 #include <dev/scsipi/scsi_message.h>
     59 #include <dev/scsipi/scsipi_debug.h>
     60 
     61 #include <vm/vm.h>
     62 #include <vm/vm_param.h>
     63 #include <vm/pmap.h>
     64 
     65 #define	ISP_PLATFORM_VERSION_MAJOR	0
     66 #define	ISP_PLATFORM_VERSION_MINOR	99
     67 
     68 #define	ISP_SCSI_XFER_T		struct scsipi_xfer
     69 struct isposinfo {
     70 	struct device		_dev;
     71 	struct scsipi_link	_link;
     72 	struct scsipi_adapter   _adapter;
     73 };
     74 #define	MAXISPREQUEST	256
     75 
     76 #include <dev/ic/ispreg.h>
     77 #include <dev/ic/ispvar.h>
     78 #include <dev/ic/ispmbox.h>
     79 
     80 #define	PRINTF			printf
     81 #define	IDPRINTF(lev, x)	if (isp->isp_dblev >= lev) printf x
     82 
     83 #define	MEMZERO			bzero
     84 #define	MEMCPY(dst, src, count)	bcopy((src), (dst), (count))
     85 
     86 #if	defined(SCSIDEBUG)
     87 #define	DFLT_DBLEVEL		3
     88 #else
     89 #if	defined(DEBUG)
     90 #define	DFLT_DBLEVEL		2
     91 #else
     92 #define	DFLT_DBLEVEL		1
     93 #endif
     94 #endif
     95 
     96 #define	ISP_LOCKVAL_DECL	int isp_spl_save
     97 #define	ISP_ILOCKVAL_DECL	ISP_LOCKVAL_DECL
     98 #define	ISP_LOCK(x)		isp_spl_save = splbio()
     99 #define	ISP_UNLOCK(x)		(void) splx(isp_spl_save)
    100 #define	ISP_ILOCK		ISP_LOCK
    101 #define	ISP_IUNLOCK		ISP_UNLOCK
    102 
    103 
    104 #define	XS_NULL(xs)		xs == NULL || xs->sc_link == NULL
    105 #define	XS_ISP(xs)		(xs)->sc_link->adapter_softc
    106 #define	XS_LUN(xs)		(xs)->sc_link->scsipi_scsi.lun
    107 #define	XS_TGT(xs)		(xs)->sc_link->scsipi_scsi.target
    108 #define	XS_RESID(xs)		(xs)->resid
    109 #define	XS_XFRLEN(xs)		(xs)->datalen
    110 #define	XS_CDBLEN(xs)		(xs)->cmdlen
    111 #define	XS_CDBP(xs)		(xs)->cmd
    112 #define	XS_STS(xs)		(xs)->status
    113 #define	XS_TIME(xs)		(xs)->timeout
    114 #define	XS_SNSP(xs)		(&(xs)->sense.scsi_sense)
    115 #define	XS_SNSLEN(xs)		(sizeof (xs)->sense.scsi_sense)
    116 #define	XS_SNSKEY(xs)		((xs)->sense.scsi_sense.flags)
    117 
    118 #define	HBA_NOERROR		XS_NOERROR
    119 #define	HBA_BOTCH		XS_DRIVER_STUFFUP
    120 #define	HBA_CMDTIMEOUT		XS_TIMEOUT
    121 #define	HBA_SELTIMEOUT		XS_SELTIMEOUT
    122 #define	HBA_TGTBSY		XS_BUSY
    123 #ifdef	XS_RESET
    124 #define	HBA_BUSRESET		XS_RESET
    125 #else
    126 #define	HBA_BUSRESET		XS_DRIVER_STUFFUP
    127 #endif
    128 #define	HBA_ABORTED		XS_DRIVER_STUFFUP
    129 #define	HBA_DATAOVR		XS_DRIVER_STUFFUP
    130 #define	HBA_ARQFAIL		XS_DRIVER_STUFFUP
    131 
    132 #define	XS_SNS_IS_VALID(xs)	(xs)->error = XS_SENSE
    133 #define	XS_IS_SNS_VALID(xs)	((xs)->error == XS_SENSE)
    134 
    135 #define	XS_INITERR(xs)		(xs)->error = 0
    136 #define	XS_SETERR(xs, v)	(xs)->error = v
    137 #define	XS_ERR(xs)		(xs)->error
    138 #define	XS_NOERR(xs)		(xs)->error == XS_NOERROR
    139 
    140 #define	XS_CMD_DONE(xs)		(xs)->flags |= ITSDONE, scsipi_done(xs)
    141 #define	XS_IS_CMD_DONE(xs)	(((xs)->flags & ITSDONE) != 0)
    142 
    143 /*
    144  * We use whether or not we're a polled command to decide about tagging.
    145  */
    146 #define	XS_CANTAG(xs)		(((xs)->flags & SCSI_POLL) != 0)
    147 
    148 /*
    149  * This is our default tag (ordered).
    150  */
    151 #define	XS_KINDOF_TAG(xs)	\
    152 	(((xs)->flags & SCSI_URGENT)? REQFLAG_HTAG : REQFLAG_STAG)
    153 
    154 #define	CMD_COMPLETE		COMPLETE
    155 #define	CMD_EAGAIN		TRY_AGAIN_LATER
    156 #define	CMD_QUEUED		SUCCESSFULLY_QUEUED
    157 
    158 
    159 
    160 #define	isp_name	isp_osinfo._dev.dv_xname
    161 
    162 
    163 #define	SYS_DELAY(x)	delay(x)
    164 
    165 #define	WATCH_INTERVAL	30
    166 
    167 extern void isp_attach __P((struct ispsoftc *));
    168 extern void isp_uninit __P((struct ispsoftc *));
    169 #endif	/* _ISP_NETBSD_H */
    170