Home | History | Annotate | Line # | Download | only in ic
isp_netbsd.h revision 1.12.4.1
      1  1.12.4.1  thorpej /* $NetBSD: isp_netbsd.h,v 1.12.4.1 1999/06/21 01:17:48 thorpej Exp $ */
      2  1.12.4.1  thorpej /* release_5_11_99 */
      3       1.1   mjacob /*
      4       1.1   mjacob  * NetBSD Specific definitions for the Qlogic ISP Host Adapter
      5       1.1   mjacob  *
      6       1.1   mjacob  *---------------------------------------
      7       1.1   mjacob  * Copyright (c) 1997, 1998 by Matthew Jacob
      8       1.1   mjacob  * NASA/Ames Research Center
      9       1.1   mjacob  * All rights reserved.
     10       1.1   mjacob  *---------------------------------------
     11       1.1   mjacob  *
     12       1.1   mjacob  * Redistribution and use in source and binary forms, with or without
     13       1.1   mjacob  * modification, are permitted provided that the following conditions
     14       1.1   mjacob  * are met:
     15       1.1   mjacob  * 1. Redistributions of source code must retain the above copyright
     16       1.1   mjacob  *    notice immediately at the beginning of the file, without modification,
     17       1.1   mjacob  *    this list of conditions, and the following disclaimer.
     18       1.1   mjacob  * 2. Redistributions in binary form must reproduce the above copyright
     19       1.1   mjacob  *    notice, this list of conditions and the following disclaimer in the
     20       1.1   mjacob  *    documentation and/or other materials provided with the distribution.
     21       1.1   mjacob  * 3. The name of the author may not be used to endorse or promote products
     22       1.1   mjacob  *    derived from this software without specific prior written permission.
     23       1.1   mjacob  *
     24       1.1   mjacob  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     25       1.1   mjacob  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     26       1.1   mjacob  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     27       1.1   mjacob  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
     28       1.1   mjacob  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     29       1.1   mjacob  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     30       1.1   mjacob  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     31       1.1   mjacob  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     32       1.1   mjacob  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     33       1.1   mjacob  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     34       1.1   mjacob  * SUCH DAMAGE.
     35       1.1   mjacob  *
     36       1.1   mjacob  */
     37       1.1   mjacob 
     38       1.1   mjacob #ifndef	_ISP_NETBSD_H
     39       1.1   mjacob #define	_ISP_NETBSD_H
     40       1.1   mjacob 
     41       1.1   mjacob #include <sys/types.h>
     42       1.1   mjacob #include <sys/param.h>
     43       1.1   mjacob #include <sys/systm.h>
     44       1.1   mjacob #include <sys/kernel.h>
     45       1.1   mjacob #include <sys/errno.h>
     46       1.1   mjacob #include <sys/ioctl.h>
     47       1.1   mjacob #include <sys/device.h>
     48       1.1   mjacob #include <sys/malloc.h>
     49       1.1   mjacob #include <sys/buf.h>
     50       1.1   mjacob #include <sys/proc.h>
     51       1.1   mjacob #include <sys/user.h>
     52       1.1   mjacob 
     53       1.1   mjacob 
     54       1.1   mjacob #include <dev/scsipi/scsi_all.h>
     55       1.1   mjacob #include <dev/scsipi/scsipi_all.h>
     56       1.1   mjacob #include <dev/scsipi/scsiconf.h>
     57       1.1   mjacob 
     58       1.1   mjacob #include <dev/scsipi/scsi_message.h>
     59       1.1   mjacob #include <dev/scsipi/scsipi_debug.h>
     60       1.1   mjacob 
     61       1.1   mjacob #include <vm/vm.h>
     62       1.1   mjacob #include <vm/vm_param.h>
     63       1.1   mjacob #include <vm/pmap.h>
     64       1.1   mjacob 
     65       1.2   mjacob #define	ISP_PLATFORM_VERSION_MAJOR	0
     66  1.12.4.1  thorpej #define	ISP_PLATFORM_VERSION_MINOR	995
     67       1.1   mjacob 
     68       1.1   mjacob #define	ISP_SCSI_XFER_T		struct scsipi_xfer
     69       1.1   mjacob struct isposinfo {
     70       1.1   mjacob 	struct device		_dev;
     71       1.1   mjacob 	struct scsipi_link	_link;
     72  1.12.4.1  thorpej 	struct scsipi_link	_link_b;
     73       1.6   mjacob 	struct scsipi_adapter   _adapter;
     74      1.10   mjacob 	int			blocked;
     75      1.10   mjacob 	TAILQ_HEAD(, scsipi_xfer) waitq;
     76       1.1   mjacob };
     77       1.1   mjacob #define	MAXISPREQUEST	256
     78       1.1   mjacob 
     79       1.1   mjacob #include <dev/ic/ispreg.h>
     80       1.1   mjacob #include <dev/ic/ispvar.h>
     81       1.1   mjacob #include <dev/ic/ispmbox.h>
     82       1.1   mjacob 
     83       1.1   mjacob #define	PRINTF			printf
     84       1.1   mjacob #define	IDPRINTF(lev, x)	if (isp->isp_dblev >= lev) printf x
     85       1.8   mjacob 
     86       1.8   mjacob #define	MEMZERO			bzero
     87       1.9   mjacob #define	MEMCPY(dst, src, count)	bcopy((src), (dst), (count))
     88      1.11   mjacob #ifdef	__alpha__
     89      1.11   mjacob #define	MemoryBarrier	alpha_mb
     90      1.11   mjacob #else
     91      1.11   mjacob #define	MemoryBarrier()
     92      1.11   mjacob #endif
     93       1.3   mjacob 
     94  1.12.4.1  thorpej #define	DMA_MSW(x)	(((x) >> 16) & 0xffff)
     95  1.12.4.1  thorpej #define	DMA_LSW(x)	(((x) & 0xffff))
     96  1.12.4.1  thorpej 
     97       1.3   mjacob #if	defined(SCSIDEBUG)
     98       1.3   mjacob #define	DFLT_DBLEVEL		3
     99       1.3   mjacob #else
    100       1.3   mjacob #if	defined(DEBUG)
    101       1.1   mjacob #define	DFLT_DBLEVEL		2
    102       1.1   mjacob #else
    103       1.1   mjacob #define	DFLT_DBLEVEL		1
    104       1.1   mjacob #endif
    105       1.3   mjacob #endif
    106       1.1   mjacob 
    107       1.1   mjacob #define	ISP_LOCKVAL_DECL	int isp_spl_save
    108       1.7   mjacob #define	ISP_ILOCKVAL_DECL	ISP_LOCKVAL_DECL
    109       1.1   mjacob #define	ISP_LOCK(x)		isp_spl_save = splbio()
    110       1.1   mjacob #define	ISP_UNLOCK(x)		(void) splx(isp_spl_save)
    111       1.1   mjacob #define	ISP_ILOCK		ISP_LOCK
    112       1.1   mjacob #define	ISP_IUNLOCK		ISP_UNLOCK
    113       1.1   mjacob 
    114       1.1   mjacob 
    115       1.1   mjacob #define	XS_NULL(xs)		xs == NULL || xs->sc_link == NULL
    116       1.1   mjacob #define	XS_ISP(xs)		(xs)->sc_link->adapter_softc
    117      1.11   mjacob #define	XS_LUN(xs)		((int) (xs)->sc_link->scsipi_scsi.lun)
    118      1.11   mjacob #define	XS_TGT(xs)		((int) (xs)->sc_link->scsipi_scsi.target)
    119  1.12.4.1  thorpej #define	XS_CHANNEL(xs)		\
    120  1.12.4.1  thorpej     (((xs)->sc_link == &(((struct ispsoftc *)XS_ISP(xs))->isp_osinfo._link_b))?\
    121  1.12.4.1  thorpej     1 : 0)
    122       1.1   mjacob #define	XS_RESID(xs)		(xs)->resid
    123       1.1   mjacob #define	XS_XFRLEN(xs)		(xs)->datalen
    124       1.1   mjacob #define	XS_CDBLEN(xs)		(xs)->cmdlen
    125  1.12.4.1  thorpej #define	XS_CDBP(xs)		((caddr_t) (xs)->cmd)
    126       1.1   mjacob #define	XS_STS(xs)		(xs)->status
    127       1.1   mjacob #define	XS_TIME(xs)		(xs)->timeout
    128       1.1   mjacob #define	XS_SNSP(xs)		(&(xs)->sense.scsi_sense)
    129       1.1   mjacob #define	XS_SNSLEN(xs)		(sizeof (xs)->sense.scsi_sense)
    130       1.1   mjacob #define	XS_SNSKEY(xs)		((xs)->sense.scsi_sense.flags)
    131       1.1   mjacob 
    132       1.1   mjacob #define	HBA_NOERROR		XS_NOERROR
    133       1.1   mjacob #define	HBA_BOTCH		XS_DRIVER_STUFFUP
    134       1.1   mjacob #define	HBA_CMDTIMEOUT		XS_TIMEOUT
    135       1.1   mjacob #define	HBA_SELTIMEOUT		XS_SELTIMEOUT
    136       1.1   mjacob #define	HBA_TGTBSY		XS_BUSY
    137       1.3   mjacob #ifdef	XS_RESET
    138       1.3   mjacob #define	HBA_BUSRESET		XS_RESET
    139       1.3   mjacob #else
    140       1.1   mjacob #define	HBA_BUSRESET		XS_DRIVER_STUFFUP
    141       1.3   mjacob #endif
    142       1.1   mjacob #define	HBA_ABORTED		XS_DRIVER_STUFFUP
    143       1.1   mjacob #define	HBA_DATAOVR		XS_DRIVER_STUFFUP
    144       1.1   mjacob #define	HBA_ARQFAIL		XS_DRIVER_STUFFUP
    145       1.1   mjacob 
    146       1.1   mjacob #define	XS_SNS_IS_VALID(xs)	(xs)->error = XS_SENSE
    147       1.1   mjacob #define	XS_IS_SNS_VALID(xs)	((xs)->error == XS_SENSE)
    148       1.1   mjacob 
    149       1.1   mjacob #define	XS_INITERR(xs)		(xs)->error = 0
    150       1.1   mjacob #define	XS_SETERR(xs, v)	(xs)->error = v
    151       1.1   mjacob #define	XS_ERR(xs)		(xs)->error
    152       1.1   mjacob #define	XS_NOERR(xs)		(xs)->error == XS_NOERROR
    153       1.1   mjacob 
    154       1.1   mjacob #define	XS_CMD_DONE(xs)		(xs)->flags |= ITSDONE, scsipi_done(xs)
    155       1.1   mjacob #define	XS_IS_CMD_DONE(xs)	(((xs)->flags & ITSDONE) != 0)
    156       1.1   mjacob 
    157       1.1   mjacob /*
    158       1.1   mjacob  * We use whether or not we're a polled command to decide about tagging.
    159       1.1   mjacob  */
    160       1.1   mjacob #define	XS_CANTAG(xs)		(((xs)->flags & SCSI_POLL) != 0)
    161       1.1   mjacob 
    162       1.1   mjacob /*
    163       1.1   mjacob  * This is our default tag (ordered).
    164       1.1   mjacob  */
    165       1.1   mjacob #define	XS_KINDOF_TAG(xs)	\
    166       1.3   mjacob 	(((xs)->flags & SCSI_URGENT)? REQFLAG_HTAG : REQFLAG_STAG)
    167       1.1   mjacob 
    168       1.1   mjacob #define	CMD_COMPLETE		COMPLETE
    169       1.1   mjacob #define	CMD_EAGAIN		TRY_AGAIN_LATER
    170       1.1   mjacob #define	CMD_QUEUED		SUCCESSFULLY_QUEUED
    171       1.1   mjacob 
    172       1.1   mjacob 
    173       1.1   mjacob 
    174       1.1   mjacob #define	isp_name	isp_osinfo._dev.dv_xname
    175       1.1   mjacob 
    176  1.12.4.1  thorpej #define	SCSI_QFULL	0x28
    177  1.12.4.1  thorpej 
    178       1.1   mjacob 
    179       1.1   mjacob #define	SYS_DELAY(x)	delay(x)
    180       1.1   mjacob 
    181       1.7   mjacob #define	WATCH_INTERVAL	30
    182       1.1   mjacob 
    183      1.11   mjacob #define	FC_FW_READY_DELAY	(12 * 1000000)
    184      1.11   mjacob 
    185       1.1   mjacob extern void isp_attach __P((struct ispsoftc *));
    186       1.7   mjacob extern void isp_uninit __P((struct ispsoftc *));
    187      1.11   mjacob 
    188      1.11   mjacob static inline void isp_prtstst(ispstatusreq_t *sp)
    189      1.11   mjacob {
    190      1.11   mjacob 	char buf[128];
    191      1.11   mjacob 	sprintf(buf, "states->");
    192      1.11   mjacob 	if (sp->req_state_flags & RQSF_GOT_BUS)
    193      1.11   mjacob 		sprintf(buf, "%s%s", buf, "GOT_BUS ");
    194      1.11   mjacob 	if (sp->req_state_flags & RQSF_GOT_TARGET)
    195      1.11   mjacob 		sprintf(buf, "%s%s", buf, "GOT_TGT ");
    196      1.11   mjacob 	if (sp->req_state_flags & RQSF_SENT_CDB)
    197      1.11   mjacob 		sprintf(buf, "%s%s", buf, "SENT_CDB ");
    198      1.11   mjacob 	if (sp->req_state_flags & RQSF_XFRD_DATA)
    199      1.11   mjacob 		sprintf(buf, "%s%s", buf, "XFRD_DATA ");
    200      1.11   mjacob 	if (sp->req_state_flags & RQSF_GOT_STATUS)
    201      1.11   mjacob 		sprintf(buf, "%s%s", buf, "GOT_STS ");
    202      1.11   mjacob 	if (sp->req_state_flags & RQSF_GOT_SENSE)
    203      1.11   mjacob 		sprintf(buf, "%s%s", buf, "GOT_SNS ");
    204      1.11   mjacob 	if (sp->req_state_flags & RQSF_XFER_COMPLETE)
    205      1.11   mjacob 		sprintf(buf, "%s%s", buf, "XFR_CMPLT ");
    206      1.11   mjacob 	sprintf(buf, "%s%s", buf, "\n");
    207      1.11   mjacob 	sprintf(buf, "%s%s", buf, "status->");
    208      1.11   mjacob 	if (sp->req_status_flags & RQSTF_DISCONNECT)
    209      1.11   mjacob 		sprintf(buf, "%s%s", buf, "Disconnect ");
    210      1.11   mjacob 	if (sp->req_status_flags & RQSTF_SYNCHRONOUS)
    211      1.11   mjacob 		sprintf(buf, "%s%s", buf, "Sync_xfr ");
    212      1.11   mjacob 	if (sp->req_status_flags & RQSTF_PARITY_ERROR)
    213      1.11   mjacob 		sprintf(buf, "%s%s", buf, "Parity ");
    214      1.11   mjacob 	if (sp->req_status_flags & RQSTF_BUS_RESET)
    215      1.11   mjacob 		sprintf(buf, "%s%s", buf, "Bus_Reset ");
    216      1.11   mjacob 	if (sp->req_status_flags & RQSTF_DEVICE_RESET)
    217      1.11   mjacob 		sprintf(buf, "%s%s", buf, "Device_Reset ");
    218      1.11   mjacob 	if (sp->req_status_flags & RQSTF_ABORTED)
    219      1.11   mjacob 		sprintf(buf, "%s%s", buf, "Aborted ");
    220      1.11   mjacob 	if (sp->req_status_flags & RQSTF_TIMEOUT)
    221      1.11   mjacob 		sprintf(buf, "%s%s", buf, "Timeout ");
    222      1.11   mjacob 	if (sp->req_status_flags & RQSTF_NEGOTIATION)
    223      1.11   mjacob 		sprintf(buf, "%s%s", buf, "Negotiation ");
    224  1.12.4.1  thorpej 	printf("%s\n", buf);
    225      1.11   mjacob }
    226      1.11   mjacob 
    227      1.11   mjacob static inline const char *isp2100_fw_statename(int state)
    228      1.11   mjacob {
    229      1.11   mjacob 	static char buf[16];
    230      1.11   mjacob 	switch(state) {
    231      1.11   mjacob 	case FW_CONFIG_WAIT:	return "Config Wait";
    232      1.11   mjacob 	case FW_WAIT_AL_PA:	return "Waiting for AL_PA";
    233      1.11   mjacob 	case FW_WAIT_LOGIN:	return "Wait Login";
    234      1.11   mjacob 	case FW_READY:		return "Ready";
    235      1.11   mjacob 	case FW_LOSS_OF_SYNC:	return "Loss Of Sync";
    236      1.11   mjacob 	case FW_ERROR:		return "Error";
    237      1.11   mjacob 	case FW_REINIT:		return "Re-Init";
    238      1.11   mjacob 	case FW_NON_PART:	return "Nonparticipating";
    239      1.11   mjacob 	default:
    240  1.12.4.1  thorpej 		sprintf(buf, "0x%x", state);
    241      1.11   mjacob 		return buf;
    242      1.11   mjacob     }
    243      1.11   mjacob }
    244      1.11   mjacob 
    245      1.11   mjacob static inline const char *isp2100_pdb_statename(int pdb_state)
    246      1.11   mjacob {
    247      1.11   mjacob 	static char buf[16];
    248      1.11   mjacob 	switch(pdb_state) {
    249      1.11   mjacob 	case PDB_STATE_DISCOVERY:	return "Port Discovery";
    250      1.11   mjacob 	case PDB_STATE_WDISC_ACK:	return "Waiting Port Discovery ACK";
    251      1.11   mjacob 	case PDB_STATE_PLOGI:		return "Port Login";
    252      1.11   mjacob 	case PDB_STATE_PLOGI_ACK:	return "Wait Port Login ACK";
    253      1.11   mjacob 	case PDB_STATE_PRLI:		return "Process Login";
    254      1.11   mjacob 	case PDB_STATE_PRLI_ACK:	return "Wait Process Login ACK";
    255      1.11   mjacob 	case PDB_STATE_LOGGED_IN:	return "Logged In";
    256      1.11   mjacob 	case PDB_STATE_PORT_UNAVAIL:	return "Port Unavailable";
    257      1.11   mjacob 	case PDB_STATE_PRLO:		return "Process Logout";
    258      1.11   mjacob 	case PDB_STATE_PRLO_ACK:	return "Wait Process Logout ACK";
    259      1.11   mjacob 	case PDB_STATE_PLOGO:		return "Port Logout";
    260      1.11   mjacob 	case PDB_STATE_PLOG_ACK:	return "Wait Port Logout ACK";
    261      1.11   mjacob 	default:
    262  1.12.4.1  thorpej 		sprintf(buf, "0x%x", pdb_state);
    263      1.11   mjacob 		return buf;
    264      1.11   mjacob 	}
    265      1.11   mjacob }
    266      1.11   mjacob 
    267      1.11   mjacob /*
    268      1.11   mjacob  * Keep these off for now...
    269      1.11   mjacob  */
    270  1.12.4.1  thorpej 
    271  1.12.4.1  thorpej #define	ISP_NO_FASTPOST_SCSI	1
    272  1.12.4.1  thorpej #define	ISP_NO_FASTPOST_FC	1
    273      1.11   mjacob 
    274       1.1   mjacob #endif	/* _ISP_NETBSD_H */
    275