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