Home | History | Annotate | Line # | Download | only in ic
isp_netbsd.h revision 1.18
      1 /* $NetBSD: isp_netbsd.h,v 1.18 1999/10/14 02:33:38 mjacob Exp $ */
      2 /* release_6_5_99 */
      3 /*
      4  * NetBSD Specific definitions for the Qlogic ISP Host Adapter
      5  * Matthew Jacob <mjacob (at) nas.nasa.gov>
      6  */
      7 /*
      8  * Copyright (C) 1997, 1998, 1999 National Aeronautics & Space Administration
      9  * All rights reserved.
     10  *
     11  * Redistribution and use in source and binary forms, with or without
     12  * modification, are permitted provided that the following conditions
     13  * are met:
     14  * 1. Redistributions of source code must retain the above copyright
     15  *    notice, this list of conditions and the following disclaimer.
     16  * 2. Redistributions in binary form must reproduce the above copyright
     17  *    notice, this list of conditions and the following disclaimer in the
     18  *    documentation and/or other materials provided with the distribution.
     19  * 3. The name of the author may not be used to endorse or promote products
     20  *    derived from this software without specific prior written permission
     21  *
     22  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     23  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     24  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     25  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     27  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     28  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     29  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     30  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     31  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     32  */
     33 #ifndef	_ISP_NETBSD_H
     34 #define	_ISP_NETBSD_H
     35 
     36 #include <sys/types.h>
     37 #include <sys/param.h>
     38 #include <sys/systm.h>
     39 #include <sys/kernel.h>
     40 #include <sys/errno.h>
     41 #include <sys/ioctl.h>
     42 #include <sys/device.h>
     43 #include <sys/malloc.h>
     44 #include <sys/buf.h>
     45 #include <sys/proc.h>
     46 #include <sys/user.h>
     47 
     48 
     49 #include <dev/scsipi/scsi_all.h>
     50 #include <dev/scsipi/scsipi_all.h>
     51 #include <dev/scsipi/scsiconf.h>
     52 
     53 #include <dev/scsipi/scsi_message.h>
     54 #include <dev/scsipi/scsipi_debug.h>
     55 
     56 #include <vm/vm.h>
     57 #include <vm/vm_param.h>
     58 #include <vm/pmap.h>
     59 
     60 #include "opt_isp.h"
     61 
     62 #define	ISP_PLATFORM_VERSION_MAJOR	0
     63 #define	ISP_PLATFORM_VERSION_MINOR	997
     64 
     65 #define	ISP_SCSI_XFER_T		struct scsipi_xfer
     66 struct isposinfo {
     67 	struct device		_dev;
     68 	struct scsipi_link	_link;
     69 	struct scsipi_link	_link_b;
     70 	struct scsipi_adapter   _adapter;
     71 	int			blocked;
     72 	union {
     73 		int		_seed;
     74 		u_int16_t	_discovered[2];
     75 	} un;
     76 #define	seed		un._seed
     77 #define	discovered	un._discovered
     78 	TAILQ_HEAD(, scsipi_xfer) waitq;
     79 };
     80 
     81 #define	MAXISPREQUEST	256
     82 #ifdef	ISP2100_FABRIC
     83 #define	ISP2100_SCRLEN		0x400
     84 #else
     85 #define	ISP2100_SCRLEN		0x100
     86 #endif
     87 
     88 #include <dev/ic/ispreg.h>
     89 #include <dev/ic/ispvar.h>
     90 #include <dev/ic/ispmbox.h>
     91 
     92 #define	PRINTF			printf
     93 #define	IDPRINTF(lev, x)	if (isp->isp_dblev >= lev) printf x
     94 #ifdef	DIAGNOSTIC
     95 #else
     96 #endif
     97 
     98 #define	MEMZERO			bzero
     99 #define	MEMCPY(dst, src, count)	bcopy((src), (dst), (count))
    100 #ifdef	__alpha__
    101 #define	MemoryBarrier	alpha_mb
    102 #else
    103 #define	MemoryBarrier()
    104 #endif
    105 
    106 #define	DMA_MSW(x)	(((x) >> 16) & 0xffff)
    107 #define	DMA_LSW(x)	(((x) & 0xffff))
    108 
    109 #if	defined(SCSIDEBUG)
    110 #define	DFLT_DBLEVEL		3
    111 #define	CFGPRINTF		printf
    112 #else
    113 #if	defined(DIAGNOSTIC) || defined(DEBUG)
    114 #define	DFLT_DBLEVEL		1
    115 #define	CFGPRINTF		printf
    116 #else
    117 #define	DFLT_DBLEVEL		0
    118 #define	CFGPRINTF		if (0) printf
    119 #endif
    120 #endif
    121 
    122 #define	ISP_LOCKVAL_DECL	int isp_spl_save
    123 #define	ISP_ILOCKVAL_DECL	ISP_LOCKVAL_DECL
    124 #define	ISP_LOCK(x)		isp_spl_save = splbio()
    125 #define	ISP_UNLOCK(x)		(void) splx(isp_spl_save)
    126 #define	ISP_ILOCK		ISP_LOCK
    127 #define	ISP_IUNLOCK		ISP_UNLOCK
    128 
    129 
    130 #define	XS_NULL(xs)		xs == NULL || xs->sc_link == NULL
    131 #define	XS_ISP(xs)		(xs)->sc_link->adapter_softc
    132 #define	XS_LUN(xs)		((int) (xs)->sc_link->scsipi_scsi.lun)
    133 #define	XS_TGT(xs)		((int) (xs)->sc_link->scsipi_scsi.target)
    134 #define	XS_CHANNEL(xs)		\
    135     (((xs)->sc_link == &(((struct ispsoftc *)XS_ISP(xs))->isp_osinfo._link_b))?\
    136     1 : 0)
    137 #define	XS_RESID(xs)		(xs)->resid
    138 #define	XS_XFRLEN(xs)		(xs)->datalen
    139 #define	XS_CDBLEN(xs)		(xs)->cmdlen
    140 #define	XS_CDBP(xs)		((caddr_t) (xs)->cmd)
    141 #define	XS_STS(xs)		(xs)->status
    142 #define	XS_TIME(xs)		(xs)->timeout
    143 #define	XS_SNSP(xs)		(&(xs)->sense.scsi_sense)
    144 #define	XS_SNSLEN(xs)		(sizeof (xs)->sense.scsi_sense)
    145 #define	XS_SNSKEY(xs)		((xs)->sense.scsi_sense.flags)
    146 
    147 #define	HBA_NOERROR		XS_NOERROR
    148 #define	HBA_BOTCH		XS_DRIVER_STUFFUP
    149 #define	HBA_CMDTIMEOUT		XS_TIMEOUT
    150 #define	HBA_SELTIMEOUT		XS_SELTIMEOUT
    151 #define	HBA_TGTBSY		XS_BUSY
    152 #ifdef	XS_RESET
    153 #define	HBA_BUSRESET		XS_RESET
    154 #else
    155 #define	HBA_BUSRESET		XS_DRIVER_STUFFUP
    156 #endif
    157 #define	HBA_ABORTED		XS_DRIVER_STUFFUP
    158 #define	HBA_DATAOVR		XS_DRIVER_STUFFUP
    159 #define	HBA_ARQFAIL		XS_DRIVER_STUFFUP
    160 
    161 #define	XS_SNS_IS_VALID(xs)	(xs)->error = XS_SENSE
    162 #define	XS_IS_SNS_VALID(xs)	((xs)->error == XS_SENSE)
    163 
    164 #define	XS_INITERR(xs)		(xs)->error = 0
    165 #define	XS_SETERR(xs, v)	(xs)->error = v
    166 #define	XS_ERR(xs)		(xs)->error
    167 #define	XS_NOERR(xs)		(xs)->error == XS_NOERROR
    168 
    169 #define	XS_CMD_DONE(xs)		(xs)->xs_status |= XS_STS_DONE, scsipi_done(xs)
    170 #define	XS_IS_CMD_DONE(xs)	(((xs)->xs_status & XS_STS_DONE) != 0)
    171 
    172 /*
    173  * We use whether or not we're a polled command to decide about tagging.
    174  */
    175 #define	XS_CANTAG(xs)		(((xs)->xs_control & XS_CTL_POLL) != 0)
    176 
    177 /*
    178  * This is our default tag (simple).
    179  */
    180 #define	XS_KINDOF_TAG(xs)	\
    181 	(((xs)->xs_control & XS_CTL_URGENT) ? REQFLAG_HTAG : REQFLAG_OTAG)
    182 
    183 /*
    184  * These get turned into NetBSD midlayer codes
    185  */
    186 #define	CMD_COMPLETE		100
    187 #define	CMD_EAGAIN		101
    188 #define	CMD_QUEUED		102
    189 #define	CMD_RQLATER		103
    190 
    191 
    192 #define	isp_name	isp_osinfo._dev.dv_xname
    193 #define	isp_unit	isp_osinfo._dev.dv_unit
    194 
    195 #define	SCSI_QFULL	0x28
    196 
    197 #define	SYS_DELAY(x)	delay(x)
    198 
    199 #define	WATCH_INTERVAL	30
    200 
    201 #define	FC_FW_READY_DELAY	(12 * 1000000)
    202 #define	DEFAULT_LOOPID(x)	108
    203 #define	DEFAULT_WWN(x)		(0x1000beed00000000LL + (x)->isp_osinfo.seed)
    204 
    205 extern void isp_attach __P((struct ispsoftc *));
    206 extern void isp_uninit __P((struct ispsoftc *));
    207 
    208 #define ISP_UNSWIZZLE_AND_COPY_PDBP(isp, dest, src)	\
    209         bcopy(src, dest, sizeof (isp_pdb_t))
    210 #define ISP_SWIZZLE_ICB(a, b)
    211 #ifdef	__sparc__
    212 #define ISP_SWIZZLE_REQUEST(a, b)			\
    213 	ISP_SBUSIFY_ISPHDR(a, &(b)->req_header);	\
    214         ISP_SBUSIFY_ISPREQ(a, b)
    215 #define ISP_UNSWIZZLE_RESPONSE(a, b)			\
    216 	ISP_SBUSIFY_ISPHDR(a, &(b)->req_header)
    217 #else
    218 #define ISP_SWIZZLE_REQUEST(a, b)
    219 #define ISP_UNSWIZZLE_RESPONSE(a, b)
    220 #endif
    221 #define	ISP_SWIZZLE_SNS_REQ(a, b)
    222 #define	ISP_UNSWIZZLE_SNS_RSP(a, b, c)
    223 
    224 #define	INLINE	inline
    225 #include <dev/ic/isp_inline.h>
    226 
    227 #endif	/* _ISP_NETBSD_H */
    228