ispvar.h revision 87635
150477Speter/* $FreeBSD: head/sys/dev/isp/ispvar.h 87635 2001-12-11 00:18:45Z mjacob $ */
235388Smjacob/*
335388Smjacob * Soft Definitions for for Qlogic ISP SCSI adapters.
435388Smjacob *
566189Smjacob * Copyright (c) 1997, 1998, 1999, 2000 by Matthew Jacob
635388Smjacob * All rights reserved.
752347Smjacob *
835388Smjacob * Redistribution and use in source and binary forms, with or without
935388Smjacob * modification, are permitted provided that the following conditions
1035388Smjacob * are met:
1135388Smjacob * 1. Redistributions of source code must retain the above copyright
1235388Smjacob *    notice immediately at the beginning of the file, without modification,
1335388Smjacob *    this list of conditions, and the following disclaimer.
1466189Smjacob * 2. The name of the author may not be used to endorse or promote products
1535388Smjacob *    derived from this software without specific prior written permission.
1635388Smjacob *
1735388Smjacob * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1835388Smjacob * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1935388Smjacob * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2035388Smjacob * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
2135388Smjacob * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2235388Smjacob * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2335388Smjacob * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2435388Smjacob * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2535388Smjacob * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2635388Smjacob * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2735388Smjacob * SUCH DAMAGE.
2835388Smjacob *
2935388Smjacob */
3035388Smjacob
3135388Smjacob#ifndef	_ISPVAR_H
3235388Smjacob#define	_ISPVAR_H
3335388Smjacob
3444819Smjacob#if defined(__NetBSD__) || defined(__OpenBSD__)
3535388Smjacob#include <dev/ic/ispmbox.h>
3653487Smjacob#ifdef	ISP_TARGET_MODE
3753487Smjacob#include <dev/ic/isp_target.h>
3856004Smjacob#include <dev/ic/isp_tpublic.h>
3935388Smjacob#endif
4053487Smjacob#endif
4135388Smjacob#ifdef	__FreeBSD__
4235388Smjacob#include <dev/isp/ispmbox.h>
4353487Smjacob#ifdef	ISP_TARGET_MODE
4453487Smjacob#include <dev/isp/isp_target.h>
4556004Smjacob#include <dev/isp/isp_tpublic.h>
4635388Smjacob#endif
4753487Smjacob#endif
4835388Smjacob#ifdef	__linux__
4942131Smjacob#include "ispmbox.h"
5053487Smjacob#ifdef	ISP_TARGET_MODE
5153487Smjacob#include "isp_target.h"
5256004Smjacob#include "isp_tpublic.h"
5335388Smjacob#endif
5453487Smjacob#endif
5535388Smjacob
5664087Smjacob#define	ISP_CORE_VERSION_MAJOR	2
5787635Smjacob#define	ISP_CORE_VERSION_MINOR	5
5839235Sgibbs
5935388Smjacob/*
6043420Smjacob * Vector for bus specific code to provide specific services.
6135388Smjacob */
6235388Smjacobstruct ispsoftc;
6335388Smjacobstruct ispmdvec {
6482689Smjacob	int		(*dv_rd_isr)
6582689Smjacob	    (struct ispsoftc *, u_int16_t *, u_int16_t *, u_int16_t *);
6674229Smjacob	u_int16_t	(*dv_rd_reg) (struct ispsoftc *, int);
6774229Smjacob	void		(*dv_wr_reg) (struct ispsoftc *, int, u_int16_t);
6874229Smjacob	int		(*dv_mbxdma) (struct ispsoftc *);
6974229Smjacob	int		(*dv_dmaset) (struct ispsoftc *,
7082689Smjacob	    XS_T *, ispreq_t *, u_int16_t *, u_int16_t);
7135388Smjacob	void		(*dv_dmaclr)
7282689Smjacob	    (struct ispsoftc *, XS_T *, u_int16_t);
7374229Smjacob	void		(*dv_reset0) (struct ispsoftc *);
7474229Smjacob	void		(*dv_reset1) (struct ispsoftc *);
7574229Smjacob	void		(*dv_dregs) (struct ispsoftc *, const char *);
7661772Smjacob	const u_int16_t	*dv_ispfw;	/* ptr to f/w */
7735388Smjacob	u_int16_t	dv_conf1;
7835388Smjacob	u_int16_t	dv_clock;	/* clock frequency */
7935388Smjacob};
8035388Smjacob
8164087Smjacob/*
8264087Smjacob * Overall parameters
8364087Smjacob */
8482689Smjacob#define	MAX_TARGETS		16
8582689Smjacob#define	MAX_FC_TARG		256
8649909Smjacob#define	ISP_MAX_TARGETS(isp)	(IS_FC(isp)? MAX_FC_TARG : MAX_TARGETS)
8761772Smjacob#define	ISP_MAX_LUNS(isp)	(isp)->isp_maxluns
8849909Smjacob
8982689Smjacob/*
9082689Smjacob * 'Types'
9182689Smjacob */
9282689Smjacob#ifndef	ISP_DMA_ADDR_T
9382689Smjacob#define	ISP_DMA_ADDR_T	u_int32_t
9482689Smjacob#endif
9553487Smjacob
9653487Smjacob/*
9764087Smjacob * Macros to access ISP registers through bus specific layers-
9864087Smjacob * mostly wrappers to vector through the mdvec structure.
9953487Smjacob */
10082689Smjacob#define	ISP_READ_ISR(isp, isrp, semap, mbox0p)	\
10182689Smjacob	(*(isp)->isp_mdvec->dv_rd_isr)(isp, isrp, semap, mbox0p)
10253487Smjacob
10353487Smjacob#define	ISP_READ(isp, reg)	\
10453487Smjacob	(*(isp)->isp_mdvec->dv_rd_reg)((isp), (reg))
10553487Smjacob
10653487Smjacob#define	ISP_WRITE(isp, reg, val)	\
10753487Smjacob	(*(isp)->isp_mdvec->dv_wr_reg)((isp), (reg), (val))
10853487Smjacob
10953487Smjacob#define	ISP_MBOXDMASETUP(isp)	\
11053487Smjacob	(*(isp)->isp_mdvec->dv_mbxdma)((isp))
11153487Smjacob
11253487Smjacob#define	ISP_DMASETUP(isp, xs, req, iptrp, optr)	\
11353487Smjacob	(*(isp)->isp_mdvec->dv_dmaset)((isp), (xs), (req), (iptrp), (optr))
11453487Smjacob
11553487Smjacob#define	ISP_DMAFREE(isp, xs, hndl)	\
11653487Smjacob	if ((isp)->isp_mdvec->dv_dmaclr) \
11753487Smjacob	    (*(isp)->isp_mdvec->dv_dmaclr)((isp), (xs), (hndl))
11853487Smjacob
11953487Smjacob#define	ISP_RESET0(isp)	\
12053487Smjacob	if ((isp)->isp_mdvec->dv_reset0) (*(isp)->isp_mdvec->dv_reset0)((isp))
12153487Smjacob#define	ISP_RESET1(isp)	\
12253487Smjacob	if ((isp)->isp_mdvec->dv_reset1) (*(isp)->isp_mdvec->dv_reset1)((isp))
12364087Smjacob#define	ISP_DUMPREGS(isp, m)	\
12464087Smjacob	if ((isp)->isp_mdvec->dv_dregs) (*(isp)->isp_mdvec->dv_dregs)((isp),(m))
12553487Smjacob
12653487Smjacob#define	ISP_SETBITS(isp, reg, val)	\
12753487Smjacob (*(isp)->isp_mdvec->dv_wr_reg)((isp), (reg), ISP_READ((isp), (reg)) | (val))
12853487Smjacob
12953487Smjacob#define	ISP_CLRBITS(isp, reg, val)	\
13053487Smjacob (*(isp)->isp_mdvec->dv_wr_reg)((isp), (reg), ISP_READ((isp), (reg)) & ~(val))
13153487Smjacob
13264087Smjacob/*
13364087Smjacob * The MEMORYBARRIER macro is defined per platform (to provide synchronization
13464087Smjacob * on Request and Response Queues, Scratch DMA areas, and Registers)
13564087Smjacob *
13664087Smjacob * Defined Memory Barrier Synchronization Types
13764087Smjacob */
13864087Smjacob#define	SYNC_REQUEST	0	/* request queue synchronization */
13964087Smjacob#define	SYNC_RESULT	1	/* result queue synchronization */
14064087Smjacob#define	SYNC_SFORDEV	2	/* scratch, sync for ISP */
14164087Smjacob#define	SYNC_SFORCPU	3	/* scratch, sync for CPU */
14264087Smjacob#define	SYNC_REG	4	/* for registers */
14364087Smjacob
14464087Smjacob/*
14564087Smjacob * Request/Response Queue defines and macros.
14664087Smjacob * The maximum is defined per platform (and can be based on board type).
14764087Smjacob */
14864087Smjacob/* This is the size of a queue entry (request and response) */
14939235Sgibbs#define	QENTRY_LEN			64
15064087Smjacob/* Both request and result queue length must be a power of two */
15164087Smjacob#define	RQUEST_QUEUE_LEN(x)		MAXISPREQUEST(x)
15264087Smjacob#define	RESULT_QUEUE_LEN(x)		\
15364087Smjacob	(((MAXISPREQUEST(x) >> 2) < 64)? 64 : MAXISPREQUEST(x) >> 2)
15439235Sgibbs#define	ISP_QUEUE_ENTRY(q, idx)		((q) + ((idx) * QENTRY_LEN))
15539235Sgibbs#define	ISP_QUEUE_SIZE(n)		((n) * QENTRY_LEN)
15639235Sgibbs#define	ISP_NXT_QENTRY(idx, qlen)	(((idx) + 1) & ((qlen)-1))
15765140Smjacob#define	ISP_QFREE(in, out, qlen)	\
15839235Sgibbs	((in == out)? (qlen - 1) : ((in > out)? \
15952347Smjacob	((qlen - 1) - (in - out)) : (out - in - 1)))
16065140Smjacob#define	ISP_QAVAIL(isp)	\
16165140Smjacob	ISP_QFREE(isp->isp_reqidx, isp->isp_reqodx, RQUEST_QUEUE_LEN(isp))
16253487Smjacob
16387635Smjacob#define	ISP_ADD_REQUEST(isp, nxti)					\
16487635Smjacob	MEMORYBARRIER(isp, SYNC_REQUEST, isp->isp_reqidx, QENTRY_LEN);	\
16587635Smjacob	WRITE_REQUEST_QUEUE_IN_POINTER(isp, nxti);			\
16687635Smjacob	isp->isp_reqidx = nxti
16753487Smjacob
16835388Smjacob/*
16946968Smjacob * SCSI Specific Host Adapter Parameters- per bus, per target
17035388Smjacob */
17135388Smjacob
17235388Smjacobtypedef struct {
17346968Smjacob	u_int		isp_gotdparms		: 1,
17452347Smjacob			isp_req_ack_active_neg	: 1,
17552347Smjacob			isp_data_line_active_neg: 1,
17635388Smjacob			isp_cmd_dma_burst_enable: 1,
17735388Smjacob			isp_data_dma_burst_enabl: 1,
17842461Smjacob			isp_fifo_threshold	: 3,
17943420Smjacob			isp_ultramode		: 1,
18035388Smjacob			isp_diffmode		: 1,
18145040Smjacob			isp_lvdmode		: 1,
18265140Smjacob			isp_fast_mttr		: 1,	/* fast sram */
18335388Smjacob			isp_initiator_id	: 4,
18452347Smjacob			isp_async_data_setup	: 4;
18552347Smjacob	u_int16_t	isp_selection_timeout;
18652347Smjacob	u_int16_t	isp_max_queue_depth;
18735388Smjacob	u_int8_t	isp_tag_aging;
18852347Smjacob	u_int8_t	isp_bus_reset_delay;
18952347Smjacob	u_int8_t	isp_retry_count;
19052347Smjacob	u_int8_t	isp_retry_delay;
19135388Smjacob	struct {
19280582Smjacob		u_int32_t
19380582Smjacob			exc_throttle	:	8,
19446968Smjacob					:	1,
19580582Smjacob			dev_enable	:	1,	/* ignored */
19643420Smjacob			dev_update	:	1,
19743420Smjacob			dev_refresh	:	1,
19880582Smjacob			actv_offset	:	4,
19980582Smjacob			goal_offset	:	4,
20080582Smjacob			nvrm_offset	:	4;
20180582Smjacob		u_int8_t	actv_period;	/* current sync period */
20280582Smjacob		u_int8_t	goal_period;	/* goal sync period */
20380582Smjacob		u_int8_t	nvrm_period;	/* nvram sync period */
20480582Smjacob		u_int16_t	actv_flags;	/* current device flags */
20580582Smjacob		u_int16_t	goal_flags;	/* goal device flags */
20680582Smjacob		u_int16_t	nvrm_flags;	/* nvram device flags */
20735388Smjacob	} isp_devparam[MAX_TARGETS];
20846968Smjacob} sdparam;
20935388Smjacob
21035388Smjacob/*
21135388Smjacob * Device Flags
21235388Smjacob */
21339235Sgibbs#define	DPARM_DISC	0x8000
21439235Sgibbs#define	DPARM_PARITY	0x4000
21539235Sgibbs#define	DPARM_WIDE	0x2000
21639235Sgibbs#define	DPARM_SYNC	0x1000
21739235Sgibbs#define	DPARM_TQING	0x0800
21839235Sgibbs#define	DPARM_ARQ	0x0400
21939235Sgibbs#define	DPARM_QFRZ	0x0200
22039235Sgibbs#define	DPARM_RENEG	0x0100
22165140Smjacob#define	DPARM_NARROW	0x0080
22265140Smjacob#define	DPARM_ASYNC	0x0040
22365140Smjacob#define	DPARM_PPR	0x0020
22443793Smjacob#define	DPARM_DEFAULT	(0xFF00 & ~DPARM_QFRZ)
22539235Sgibbs#define	DPARM_SAFE_DFLT	(DPARM_DEFAULT & ~(DPARM_WIDE|DPARM_SYNC|DPARM_TQING))
22635388Smjacob
22739235Sgibbs
22845040Smjacob/* technically, not really correct, as they need to be rated based upon clock */
22965140Smjacob#define	ISP_80M_SYNCPARMS	0x0c09
23065140Smjacob#define	ISP_40M_SYNCPARMS	0x0c0a
23165140Smjacob#define	ISP_20M_SYNCPARMS	0x0c0c
23265140Smjacob#define	ISP_20M_SYNCPARMS_1040	0x080c
23352347Smjacob#define	ISP_10M_SYNCPARMS	0x0c19
23452347Smjacob#define	ISP_08M_SYNCPARMS	0x0c25
23552347Smjacob#define	ISP_05M_SYNCPARMS	0x0c32
23652347Smjacob#define	ISP_04M_SYNCPARMS	0x0c41
23735388Smjacob
23835388Smjacob/*
23935388Smjacob * Fibre Channel Specifics
24035388Smjacob */
24152347Smjacob#define	FL_PORT_ID		0x7e	/* FL_Port Special ID */
24252347Smjacob#define	FC_PORT_ID		0x7f	/* Fabric Controller Special ID */
24352347Smjacob#define	FC_SNS_ID		0x80	/* SNS Server Special ID */
24452347Smjacob
24535388Smjacobtypedef struct {
24652347Smjacob	u_int32_t		isp_fwoptions	: 16,
24784241Smjacob				isp_gbspeed	: 2,
24872355Smjacob				isp_iid_set	: 1,
24948484Smjacob				loop_seen_once	: 1,
25077776Smjacob				isp_loopstate	: 4,	/* Current Loop State */
25148484Smjacob				isp_fwstate	: 3,	/* ISP F/W state */
25248484Smjacob				isp_gotdparms	: 1,
25359454Smjacob				isp_topo	: 3,
25448484Smjacob				isp_onfabric	: 1;
25572355Smjacob	u_int8_t		isp_iid;	/* 'initiator' id */
25639235Sgibbs	u_int8_t		isp_loopid;	/* hard loop id */
25739235Sgibbs	u_int8_t		isp_alpa;	/* ALPA */
25872355Smjacob	u_int32_t		isp_portid;
25952347Smjacob	volatile u_int16_t	isp_lipseq;	/* LIP sequence # */
26082841Smjacob	u_int16_t		isp_fwattr;	/* firmware attributes */
26139235Sgibbs	u_int8_t		isp_execthrottle;
26252347Smjacob	u_int8_t		isp_retry_delay;
26352347Smjacob	u_int8_t		isp_retry_count;
26452347Smjacob	u_int8_t		isp_reserved;
26539235Sgibbs	u_int16_t		isp_maxalloc;
26639235Sgibbs	u_int16_t		isp_maxfrmlen;
26748484Smjacob	u_int64_t		isp_nodewwn;
26848484Smjacob	u_int64_t		isp_portwwn;
26935388Smjacob	/*
27048484Smjacob	 * Port Data Base. This is indexed by 'target', which is invariate.
27148484Smjacob	 * However, elements within can move around due to loop changes,
27248484Smjacob	 * so the actual loop ID passed to the F/W is in this structure.
27348484Smjacob	 * The first time the loop is seen up, loopid will match the index
27448484Smjacob	 * (except for fabric nodes which are above mapped above FC_SNS_ID
27548484Smjacob	 * and are completely virtual), but subsequent LIPs can cause things
27648484Smjacob	 * to move around.
27744819Smjacob	 */
27848484Smjacob	struct lportdb {
27952347Smjacob		u_int
28060221Smjacob					loopid		: 8,
28177776Smjacob							: 1,
28277776Smjacob					force_logout	: 1,
28371079Smjacob					was_fabric_dev	: 1,
28471079Smjacob					fabric_dev	: 1,
28560221Smjacob					loggedin	: 1,
28660221Smjacob					roles		: 2,
28760221Smjacob					valid		: 1;
28852347Smjacob		u_int32_t		portid;
28948484Smjacob		u_int64_t		node_wwn;
29048484Smjacob		u_int64_t		port_wwn;
29172355Smjacob	} portdb[MAX_FC_TARG], tport[FC_PORT_ID];
29244819Smjacob
29344819Smjacob	/*
29435388Smjacob	 * Scratch DMA mapped in area to fetch Port Database stuff, etc.
29535388Smjacob	 */
29648195Smjacob	caddr_t			isp_scratch;
29782689Smjacob	ISP_DMA_ADDR_T		isp_scdma;
29835388Smjacob} fcparam;
29935388Smjacob
30048484Smjacob#define	FW_CONFIG_WAIT		0
30148484Smjacob#define	FW_WAIT_AL_PA		1
30248484Smjacob#define	FW_WAIT_LOGIN		2
30348484Smjacob#define	FW_READY		3
30448484Smjacob#define	FW_LOSS_OF_SYNC		4
30548484Smjacob#define	FW_ERROR		5
30648484Smjacob#define	FW_REINIT		6
30748484Smjacob#define	FW_NON_PART		7
30835388Smjacob
30948484Smjacob#define	LOOP_NIL		0
31048484Smjacob#define	LOOP_LIP_RCVD		1
31148484Smjacob#define	LOOP_PDB_RCVD		2
31272355Smjacob#define	LOOP_SCANNING_FABRIC	3
31372355Smjacob#define	LOOP_FSCAN_DONE		4
31472355Smjacob#define	LOOP_SCANNING_LOOP	5
31577776Smjacob#define	LOOP_LSCAN_DONE		6
31677776Smjacob#define	LOOP_SYNCING_PDB	7
31777776Smjacob#define	LOOP_READY		8
31835388Smjacob
31959454Smjacob#define	TOPO_NL_PORT		0
32059454Smjacob#define	TOPO_FL_PORT		1
32159454Smjacob#define	TOPO_N_PORT		2
32259454Smjacob#define	TOPO_F_PORT		3
32359454Smjacob#define	TOPO_PTP_STUB		4
32459454Smjacob
32542131Smjacob/*
32635388Smjacob * Soft Structure per host adapter
32735388Smjacob */
32865140Smjacobtypedef struct ispsoftc {
32935388Smjacob	/*
33035388Smjacob	 * Platform (OS) specific data
33135388Smjacob	 */
33235388Smjacob	struct isposinfo	isp_osinfo;
33335388Smjacob
33435388Smjacob	/*
33553487Smjacob	 * Pointer to bus specific functions and data
33635388Smjacob	 */
33735388Smjacob	struct ispmdvec *	isp_mdvec;
33835388Smjacob
33935388Smjacob	/*
34053487Smjacob	 * (Mostly) nonvolatile state. Board specific parameters
34153487Smjacob	 * may contain some volatile state (e.g., current loop state).
34235388Smjacob	 */
34335388Smjacob
34453487Smjacob	void * 			isp_param;	/* type specific */
34553487Smjacob	u_int16_t		isp_fwrev[3];	/* Loaded F/W revision */
34653487Smjacob	u_int16_t		isp_romfw_rev[3]; /* PROM F/W revision */
34753487Smjacob	u_int16_t		isp_maxcmds;	/* max possible I/O cmds */
34853487Smjacob	u_int8_t		isp_type;	/* HBA Chip Type */
34953487Smjacob	u_int8_t		isp_revision;	/* HBA Chip H/W Revision */
35061772Smjacob	u_int32_t		isp_maxluns;	/* maximum luns supported */
35135388Smjacob
35271079Smjacob	u_int32_t		isp_clock	: 8,	/* input clock */
35387635Smjacob						: 5,
35487635Smjacob				isp_failed	: 1,	/* board failed */
35587635Smjacob				isp_open	: 1,	/* opened (ioctl) */
35653487Smjacob				isp_touched	: 1,	/* board ever seen? */
35753487Smjacob				isp_bustype	: 1,	/* SBus or PCI */
35865140Smjacob				isp_loaded_fw	: 1,	/* loaded firmware */
35987635Smjacob				isp_role	: 2,	/* roles supported */
36071079Smjacob				isp_dblev	: 12;	/* debug log mask */
36171079Smjacob
36271079Smjacob	u_int32_t		isp_confopts;		/* config options */
36371079Smjacob
36482689Smjacob	u_int16_t		isp_rqstinrp;	/* register for REQINP */
36582689Smjacob	u_int16_t		isp_rqstoutrp;	/* register for REQOUTP */
36682689Smjacob	u_int16_t		isp_respinrp;	/* register for RESINP */
36782689Smjacob	u_int16_t		isp_respoutrp;	/* register for RESOUTP */
36882689Smjacob
36969522Smjacob	/*
37069522Smjacob	 * Instrumentation
37169522Smjacob	 */
37269522Smjacob	u_int64_t		isp_intcnt;		/* total int count */
37369522Smjacob	u_int64_t		isp_intbogus;		/* spurious int count */
37439235Sgibbs
37535388Smjacob	/*
37639235Sgibbs	 * Volatile state
37735388Smjacob	 */
37835388Smjacob
37962171Smjacob	volatile u_int32_t
38087635Smjacob		isp_obits	:	8,	/* mailbox command output */
38187635Smjacob		isp_mboxbsy	:	1,	/* mailbox command active */
38239235Sgibbs		isp_state	:	3,
38346968Smjacob		isp_sendmarker	:	2,	/* send a marker entry */
38446968Smjacob		isp_update	:	2,	/* update parameters */
38552347Smjacob		isp_nactive	:	16;	/* how many commands active */
38652347Smjacob	volatile u_int16_t	isp_reqodx;	/* index of last ISP pickup */
38752347Smjacob	volatile u_int16_t	isp_reqidx;	/* index of next request */
38852347Smjacob	volatile u_int16_t	isp_residx;	/* index of next result */
38952347Smjacob	volatile u_int16_t	isp_lasthdls;	/* last handle seed */
39062171Smjacob	volatile u_int16_t	isp_mboxtmp[MAX_MAILBOX];
39171079Smjacob	volatile u_int16_t	isp_lastmbxcmd;	/* last mbox command sent */
39235388Smjacob
39335388Smjacob	/*
39453487Smjacob	 * Active commands are stored here, indexed by handle functions.
39535388Smjacob	 */
39664087Smjacob	XS_T **isp_xflist;
39735388Smjacob
39835388Smjacob	/*
39952347Smjacob	 * request/result queue pointers and dma handles for them.
40035388Smjacob	 */
40148195Smjacob	caddr_t			isp_rquest;
40248195Smjacob	caddr_t			isp_result;
40382689Smjacob	ISP_DMA_ADDR_T		isp_rquest_dma;
40482689Smjacob	ISP_DMA_ADDR_T		isp_result_dma;
40565140Smjacob} ispsoftc_t;
40635388Smjacob
40749909Smjacob#define	SDPARAM(isp)	((sdparam *) (isp)->isp_param)
40849909Smjacob#define	FCPARAM(isp)	((fcparam *) (isp)->isp_param)
40949909Smjacob
41035388Smjacob/*
41164087Smjacob * ISP Driver Run States
41235388Smjacob */
41335388Smjacob#define	ISP_NILSTATE	0
41435388Smjacob#define	ISP_RESETSTATE	1
41535388Smjacob#define	ISP_INITSTATE	2
41635388Smjacob#define	ISP_RUNSTATE	3
41735388Smjacob
41835388Smjacob/*
41935388Smjacob * ISP Configuration Options
42035388Smjacob */
42135388Smjacob#define	ISP_CFG_NORELOAD	0x80	/* don't download f/w */
42243793Smjacob#define	ISP_CFG_NONVRAM		0x40	/* ignore NVRAM */
42384241Smjacob#define	ISP_CFG_TWOGB		0x20	/* force 2GB connection (23XX only) */
42484241Smjacob#define	ISP_CFG_ONEGB		0x10	/* force 1GB connection (23XX only) */
42553487Smjacob#define	ISP_CFG_FULL_DUPLEX	0x01	/* Full Duplex (Fibre Channel only) */
42653487Smjacob#define	ISP_CFG_OWNWWN		0x02	/* override NVRAM wwn */
42769522Smjacob#define	ISP_CFG_PORT_PREF	0x0C	/* Mask for Port Prefs (2200 only) */
42869522Smjacob#define	ISP_CFG_LPORT		0x00	/* prefer {N/F}L-Port connection */
42969522Smjacob#define	ISP_CFG_NPORT		0x04	/* prefer {N/F}-Port connection */
43069522Smjacob#define	ISP_CFG_NPORT_ONLY	0x08	/* insist on {N/F}-Port connection */
43169522Smjacob#define	ISP_CFG_LPORT_ONLY	0x0C	/* insist on {N/F}L-Port connection */
43235388Smjacob
43364087Smjacob/*
43471079Smjacob * Prior to calling isp_reset for the first time, the outer layer
43571079Smjacob * should set isp_role to one of NONE, INITIATOR, TARGET, BOTH.
43671079Smjacob *
43771079Smjacob * If you set ISP_ROLE_NONE, the cards will be reset, new firmware loaded,
43871079Smjacob * NVRAM read, and defaults set, but any further initialization (e.g.
43971079Smjacob * INITIALIZE CONTROL BLOCK commands for 2X00 cards) won't be done.
44071079Smjacob *
44171079Smjacob * If INITIATOR MODE isn't set, attempts to run commands will be stopped
44271079Smjacob * at isp_start and completed with the moral equivalent of SELECTION TIMEOUT.
44371079Smjacob *
44471079Smjacob * If TARGET MODE is set, it doesn't mean that the rest of target mode support
44571079Smjacob * needs to be enabled, or will even work. What happens with the 2X00 cards
44671079Smjacob * here is that if you have enabled it with TARGET MODE as part of the ICB
44771079Smjacob * options, but you haven't given the f/w any ram resources for ATIOs or
44871079Smjacob * Immediate Notifies, the f/w just handles what it can and you never see
44971079Smjacob * anything. Basically, it sends a single byte of data (the first byte,
45071079Smjacob * which you can set as part of the INITIALIZE CONTROL BLOCK command) for
45171079Smjacob * INQUIRY, and sends back QUEUE FULL status for any other command.
45279235Smjacob *
45371079Smjacob */
45471079Smjacob#define	ISP_ROLE_NONE		0x0
45571079Smjacob#define	ISP_ROLE_INITIATOR	0x1
45671079Smjacob#define	ISP_ROLE_TARGET		0x2
45771079Smjacob#define	ISP_ROLE_BOTH		(ISP_ROLE_TARGET|ISP_ROLE_INITIATOR)
45871079Smjacob#define	ISP_ROLE_EITHER		ISP_ROLE_BOTH
45971079Smjacob#ifndef	ISP_DEFAULT_ROLES
46071079Smjacob#define	ISP_DEFAULT_ROLES	ISP_ROLE_INITIATOR
46171079Smjacob#endif
46271079Smjacob
46371079Smjacob
46471079Smjacob/*
46564087Smjacob * Firmware related defines
46664087Smjacob */
46771079Smjacob#define	ISP_CODE_ORG			0x1000	/* default f/w code start */
46882689Smjacob#define	ISP_CODE_ORG_2300		0x0800	/* ..except for 2300s */
46945282Smjacob#define	ISP_FW_REV(maj, min, mic)	((maj << 24) | (min << 16) | mic)
47082841Smjacob#define	ISP_FW_MAJOR(code)		((code >> 24) & 0xff)
47182841Smjacob#define	ISP_FW_MINOR(code)		((code >> 16) & 0xff)
47282841Smjacob#define	ISP_FW_MICRO(code)		((code >>  8) & 0xff)
47371079Smjacob#define	ISP_FW_REVX(xp)			((xp[0]<<24) | (xp[1] << 16) | xp[2])
47482841Smjacob#define	ISP_FW_MAJORX(xp)		(xp[0])
47582841Smjacob#define	ISP_FW_MINORX(xp)		(xp[1])
47682841Smjacob#define	ISP_FW_MICROX(xp)		(xp[2])
47739235Sgibbs
47835388Smjacob/*
47939235Sgibbs * Bus (implementation) types
48035388Smjacob */
48139235Sgibbs#define	ISP_BT_PCI		0	/* PCI Implementations */
48239235Sgibbs#define	ISP_BT_SBUS		1	/* SBus Implementations */
48339235Sgibbs
48439235Sgibbs/*
48587635Smjacob * If we have not otherwise defined SBus support away make sure
48687635Smjacob * it is defined here such that the code is included as default
48787635Smjacob */
48887635Smjacob#ifndef	ISP_SBUS_SUPPORTED
48987635Smjacob#define	ISP_SBUS_SUPPORTED	1
49087635Smjacob#endif
49187635Smjacob
49287635Smjacob/*
49339235Sgibbs * Chip Types
49439235Sgibbs */
49535388Smjacob#define	ISP_HA_SCSI		0xf
49639235Sgibbs#define	ISP_HA_SCSI_UNKNOWN	0x1
49739235Sgibbs#define	ISP_HA_SCSI_1020	0x2
49839235Sgibbs#define	ISP_HA_SCSI_1020A	0x3
49939235Sgibbs#define	ISP_HA_SCSI_1040	0x4
50039235Sgibbs#define	ISP_HA_SCSI_1040A	0x5
50139235Sgibbs#define	ISP_HA_SCSI_1040B	0x6
50245282Smjacob#define	ISP_HA_SCSI_1040C	0x7
50354671Smjacob#define	ISP_HA_SCSI_1240	0x8
50454671Smjacob#define	ISP_HA_SCSI_1080	0x9
50554671Smjacob#define	ISP_HA_SCSI_1280	0xa
50657145Smjacob#define	ISP_HA_SCSI_12160	0xb
50735388Smjacob#define	ISP_HA_FC		0xf0
50835388Smjacob#define	ISP_HA_FC_2100		0x10
50948484Smjacob#define	ISP_HA_FC_2200		0x20
51077365Smjacob#define	ISP_HA_FC_2300		0x30
51135388Smjacob
51244819Smjacob#define	IS_SCSI(isp)	(isp->isp_type & ISP_HA_SCSI)
51354671Smjacob#define	IS_1240(isp)	(isp->isp_type == ISP_HA_SCSI_1240)
51444819Smjacob#define	IS_1080(isp)	(isp->isp_type == ISP_HA_SCSI_1080)
51554671Smjacob#define	IS_1280(isp)	(isp->isp_type == ISP_HA_SCSI_1280)
51657145Smjacob#define	IS_12160(isp)	(isp->isp_type == ISP_HA_SCSI_12160)
51757145Smjacob
51857145Smjacob#define	IS_12X0(isp)	(IS_1240(isp) || IS_1280(isp))
51957145Smjacob#define	IS_DUALBUS(isp)	(IS_12X0(isp) || IS_12160(isp))
52057145Smjacob#define	IS_ULTRA2(isp)	(IS_1080(isp) || IS_1280(isp) || IS_12160(isp))
52157145Smjacob#define	IS_ULTRA3(isp)	(IS_12160(isp))
52257145Smjacob
52377365Smjacob#define	IS_FC(isp)	((isp)->isp_type & ISP_HA_FC)
52477365Smjacob#define	IS_2100(isp)	((isp)->isp_type == ISP_HA_FC_2100)
52577365Smjacob#define	IS_2200(isp)	((isp)->isp_type == ISP_HA_FC_2200)
52682689Smjacob#define	IS_2300(isp)	((isp)->isp_type >= ISP_HA_FC_2300)
52744819Smjacob
52864087Smjacob/*
52964087Smjacob * DMA cookie macros
53064087Smjacob */
53182689Smjacob#define	DMA_WD3(x)	0
53282689Smjacob#define	DMA_WD2(x)	0
53382689Smjacob#define	DMA_WD1(x)	(((x) >> 16) & 0xffff)
53482689Smjacob#define	DMA_WD0(x)	(((x) & 0xffff))
53557145Smjacob
53635388Smjacob/*
53764087Smjacob * Core System Function Prototypes
53835388Smjacob */
53935388Smjacob
54035388Smjacob/*
54139235Sgibbs * Reset Hardware. Totally. Assumes that you'll follow this with
54239235Sgibbs * a call to isp_init.
54335388Smjacob */
54474229Smjacobvoid isp_reset(struct ispsoftc *);
54535388Smjacob
54635388Smjacob/*
54735388Smjacob * Initialize Hardware to known state
54835388Smjacob */
54974229Smjacobvoid isp_init(struct ispsoftc *);
55035388Smjacob
55135388Smjacob/*
55239235Sgibbs * Reset the ISP and call completion for any orphaned commands.
55339235Sgibbs */
55474229Smjacobvoid isp_reinit(struct ispsoftc *);
55539235Sgibbs
55639235Sgibbs/*
55782689Smjacob * Internal Interrupt Service Routine
55882689Smjacob *
55982689Smjacob * The outer layers do the spade work to get the appropriate status register,
56082689Smjacob * semaphore register and first mailbox register (if appropriate). This also
56182689Smjacob * means that most spurious/bogus interrupts not for us can be filtered first.
56235388Smjacob */
56382689Smjacobvoid isp_intr(struct ispsoftc *, u_int16_t, u_int16_t, u_int16_t);
56435388Smjacob
56582689Smjacob
56635388Smjacob/*
56764087Smjacob * Command Entry Point- Platform Dependent layers call into this
56835388Smjacob */
56974229Smjacobint isp_start(XS_T *);
57064087Smjacob/* these values are what isp_start returns */
57164087Smjacob#define	CMD_COMPLETE	101	/* command completed */
57264087Smjacob#define	CMD_EAGAIN	102	/* busy- maybe retry later */
57364087Smjacob#define	CMD_QUEUED	103	/* command has been queued for execution */
57464087Smjacob#define	CMD_RQLATER 	104	/* requeue this command later */
57535388Smjacob
57639235Sgibbs/*
57764087Smjacob * Command Completion Point- Core layers call out from this with completed cmds
57864087Smjacob */
57974229Smjacobvoid isp_done(XS_T *);
58064087Smjacob
58164087Smjacob/*
58243420Smjacob * Platform Dependent to External to Internal Control Function
58339235Sgibbs *
58472355Smjacob * Assumes locks are held on entry. You should note that with many of
58572355Smjacob * these commands and locks may be released while this is occurring.
58639235Sgibbs *
58772355Smjacob * A few notes about some of these functions:
58872355Smjacob *
58972355Smjacob * ISPCTL_FCLINK_TEST tests to make sure we have good fibre channel link.
59072355Smjacob * The argument is a pointer to an integer which is the time, in microseconds,
59172355Smjacob * we should wait to see whether we have good link. This test, if successful,
59272355Smjacob * lets us know our connection topology and our Loop ID/AL_PA and so on.
59372355Smjacob * You can't get anywhere without this.
59472355Smjacob *
59572355Smjacob * ISPCTL_SCAN_FABRIC queries the name server (if we're on a fabric) for
59672355Smjacob * all entities using the FC Generic Services subcommand GET ALL NEXT.
59772355Smjacob * For each found entity, an ISPASYNC_FABRICDEV event is generated (see
59872355Smjacob * below).
59972355Smjacob *
60072355Smjacob * ISPCTL_SCAN_LOOP does a local loop scan. This is only done if the connection
60172355Smjacob * topology is NL or FL port (private or public loop). Since the Qlogic f/w
60272355Smjacob * 'automatically' manages local loop connections, this function essentially
60372355Smjacob * notes the arrival, departure, and possible shuffling around of local loop
60472355Smjacob * entities. Thus for each arrival and departure this generates an isp_async
60572355Smjacob * event of ISPASYNC_PROMENADE (see below).
60672355Smjacob *
60772355Smjacob * ISPCTL_PDB_SYNC is somewhat misnamed. It actually is the final step, in
60872355Smjacob * order, of ISPCTL_FCLINK_TEST, ISPCTL_SCAN_FABRIC, and ISPCTL_SCAN_LOOP.
60972355Smjacob * The main purpose of ISPCTL_PDB_SYNC is to complete management of logging
61072355Smjacob * and logging out of fabric devices (if one is on a fabric) and then marking
61172355Smjacob * the 'loop state' as being ready to now be used for sending commands to
61272355Smjacob * devices. Originally fabric name server and local loop scanning were
61381794Smjacob * part of this function. It's now been separated to allow for finer control.
61439235Sgibbs */
61539235Sgibbstypedef enum {
61648484Smjacob	ISPCTL_RESET_BUS,		/* Reset Bus */
61748484Smjacob	ISPCTL_RESET_DEV,		/* Reset Device */
61848484Smjacob	ISPCTL_ABORT_CMD,		/* Abort Command */
61972355Smjacob	ISPCTL_UPDATE_PARAMS,		/* Update Operating Parameters (SCSI) */
62055364Smjacob	ISPCTL_FCLINK_TEST,		/* Test FC Link Status */
62172355Smjacob	ISPCTL_SCAN_FABRIC,		/* (Re)scan Fabric Name Server */
62272355Smjacob	ISPCTL_SCAN_LOOP,		/* (Re)scan Local Loop */
62355364Smjacob	ISPCTL_PDB_SYNC,		/* Synchronize Port Database */
62472355Smjacob	ISPCTL_SEND_LIP,		/* Send a LIP */
62572355Smjacob	ISPCTL_GET_POSMAP,		/* Get FC-AL position map */
62672938Smjacob	ISPCTL_RUN_MBOXCMD,		/* run a mailbox command */
62755364Smjacob	ISPCTL_TOGGLE_TMODE		/* toggle target mode */
62839235Sgibbs} ispctl_t;
62974229Smjacobint isp_control(struct ispsoftc *, ispctl_t, void *);
63039235Sgibbs
63143420Smjacob
63239235Sgibbs/*
63343420Smjacob * Platform Dependent to Internal to External Control Function
63443420Smjacob * (each platform must provide such a function)
63543420Smjacob *
63672355Smjacob * Assumes locks are held.
63772355Smjacob *
63872355Smjacob * A few notes about some of these functions:
63972355Smjacob *
64072355Smjacob * ISPASYNC_CHANGE_NOTIFY notifies the outer layer that a change has
64172355Smjacob * occurred that invalidates the list of fabric devices known and/or
64272355Smjacob * the list of known loop devices. The argument passed is a pointer
64372355Smjacob * whose values are defined below  (local loop change, name server
64472355Smjacob * change, other). 'Other' may simply be a LIP, or a change in
64572355Smjacob * connection topology.
64672355Smjacob *
64772355Smjacob * ISPASYNC_FABRIC_DEV announces the next element in a list of
64872355Smjacob * fabric device names we're getting out of the name server. The
64972355Smjacob * argument points to a GET ALL NEXT response structure. The list
65072355Smjacob * is known to terminate with an entry that refers to ourselves.
65172355Smjacob * One of the main purposes of this function is to allow outer
65272355Smjacob * layers, which are OS dependent, to set policy as to which fabric
65372355Smjacob * devices might actually be logged into (and made visible) later
65472355Smjacob * at ISPCTL_PDB_SYNC time. Since there's a finite number of fabric
65572355Smjacob * devices that we can log into (256 less 3 'reserved' for F-port
65672355Smjacob * topologies), and fabrics can grow up to 8 million or so entries
65772355Smjacob * (24 bits of Port Address, less a wad of reserved spaces), clearly
65872355Smjacob * we had better let the OS determine login policy.
65972355Smjacob *
66072355Smjacob * ISPASYNC_PROMENADE has an argument that is a pointer to an integer which
66172355Smjacob * is an index into the portdb in the softc ('target'). Whether that entrie's
66272355Smjacob * valid tag is set or not says whether something has arrived or departed.
66372355Smjacob * The name refers to a favorite pastime of many city dwellers- watching
66472355Smjacob * people come and go, talking of Michaelangelo, and so on..
66572938Smjacob *
66672938Smjacob * ISPASYNC_UNHANDLED_RESPONSE gives outer layers a chance to parse a
66772938Smjacob * response queue entry not otherwise handled. The outer layer should
66887635Smjacob * return non-zero if it handled it. The 'arg' points to an unmassaged
66987635Smjacob * response queue entry.
67043420Smjacob */
67143420Smjacob
67243420Smjacobtypedef enum {
67372355Smjacob	ISPASYNC_NEW_TGT_PARAMS,	/* New Target Parameters Negotiated */
67448484Smjacob	ISPASYNC_BUS_RESET,		/* Bus Was Reset */
67548484Smjacob	ISPASYNC_LOOP_DOWN,		/* FC Loop Down */
67648484Smjacob	ISPASYNC_LOOP_UP,		/* FC Loop Up */
67777365Smjacob	ISPASYNC_LIP,			/* LIP Received */
67877365Smjacob	ISPASYNC_LOOP_RESET,		/* Loop Reset Received */
67972355Smjacob	ISPASYNC_CHANGE_NOTIFY,		/* FC Change Notification */
68072355Smjacob	ISPASYNC_FABRIC_DEV,		/* FC Fabric Device Arrival */
68172355Smjacob	ISPASYNC_PROMENADE,		/* FC Objects coming && going */
68255364Smjacob	ISPASYNC_TARGET_MESSAGE,	/* target message */
68355364Smjacob	ISPASYNC_TARGET_EVENT,		/* target asynchronous event */
68472355Smjacob	ISPASYNC_TARGET_ACTION,		/* other target command action */
68572938Smjacob	ISPASYNC_CONF_CHANGE,		/* Platform Configuration Change */
68679235Smjacob	ISPASYNC_UNHANDLED_RESPONSE,	/* Unhandled Response Entry */
68779235Smjacob	ISPASYNC_FW_CRASH		/* Firmware has crashed */
68843420Smjacob} ispasync_t;
68974229Smjacobint isp_async(struct ispsoftc *, ispasync_t, void *);
69043420Smjacob
69172355Smjacob#define	ISPASYNC_CHANGE_PDB	((void *) 0)
69272355Smjacob#define	ISPASYNC_CHANGE_SNS	((void *) 1)
69372355Smjacob#define	ISPASYNC_CHANGE_OTHER	((void *) 2)
69472355Smjacob
69543420Smjacob/*
69664087Smjacob * Platform Dependent Error and Debug Printout
69739235Sgibbs */
69870490Smjacob#ifdef	__GNUC__
69974229Smjacobvoid isp_prt(struct ispsoftc *, int level, const char *, ...)
70070490Smjacob	__attribute__((__format__(__printf__,3,4)));
70170490Smjacob#else
70274229Smjacobvoid isp_prt(struct ispsoftc *, int level, const char *, ...);
70370490Smjacob#endif
70470490Smjacob
70564087Smjacob#define	ISP_LOGALL	0x0	/* log always */
70664087Smjacob#define	ISP_LOGCONFIG	0x1	/* log configuration messages */
70764087Smjacob#define	ISP_LOGINFO	0x2	/* log informational messages */
70864087Smjacob#define	ISP_LOGWARN	0x4	/* log warning messages */
70964087Smjacob#define	ISP_LOGERR	0x8	/* log error messages */
71064087Smjacob#define	ISP_LOGDEBUG0	0x10	/* log simple debug messages */
71164087Smjacob#define	ISP_LOGDEBUG1	0x20	/* log intermediate debug messages */
71264087Smjacob#define	ISP_LOGDEBUG2	0x40	/* log most debug messages */
71379235Smjacob#define	ISP_LOGDEBUG3	0x80	/* log high frequency debug messages */
71479235Smjacob#define	ISP_LOGDEBUG4	0x100	/* log high frequency debug messages */
71564087Smjacob#define	ISP_LOGTDEBUG0	0x200	/* log simple debug messages (target mode) */
71664087Smjacob#define	ISP_LOGTDEBUG1	0x400	/* log intermediate debug messages (target) */
71764087Smjacob#define	ISP_LOGTDEBUG2	0x800	/* log all debug messages (target) */
71839235Sgibbs
71964087Smjacob/*
72064087Smjacob * Each Platform provides it's own isposinfo substructure of the ispsoftc
72164087Smjacob * defined above.
72264087Smjacob *
72364087Smjacob * Each platform must also provide the following macros/defines:
72464087Smjacob *
72564087Smjacob *
72664087Smjacob *	INLINE		-	platform specific define for 'inline' functions
72764087Smjacob *
72882689Smjacob *	ISP_DMA_ADDR_T	-	platform specific dma address coookie- basically
72982689Smjacob *				the largest integer that can hold the 32 or
73082689Smjacob *				64 bit value appropriate for the QLogic's DMA
73182689Smjacob *				addressing. Defaults to u_int32_t.
73282689Smjacob *
73364087Smjacob *	ISP2100_SCRLEN	-	length for the Fibre Channel scratch DMA area
73464087Smjacob *
73564087Smjacob *	MEMZERO(dst, src)			platform zeroing function
73664087Smjacob *	MEMCPY(dst, src, count)			platform copying function
73764087Smjacob *	SNPRINTF(buf, bufsize, fmt, ...)	snprintf
73864087Smjacob *	STRNCAT(dstbuf, size, srcbuf)		strncat
73964087Smjacob *	USEC_DELAY(usecs)			microsecond spindelay function
74069522Smjacob *	USEC_SLEEP(isp, usecs)			microsecond sleep function
74164087Smjacob *
74264087Smjacob *	NANOTIME_T				nanosecond time type
74364087Smjacob *
74464087Smjacob *	GET_NANOTIME(NANOTIME_T *)		get current nanotime.
74564087Smjacob *
74664087Smjacob *	GET_NANOSEC(NANOTIME_T *)		get u_int64_t from NANOTIME_T
74764087Smjacob *
74864087Smjacob *	NANOTIME_SUB(NANOTIME_T *, NANOTIME_T *)
74964087Smjacob *						subtract two NANOTIME_T values
75064087Smjacob *
75164087Smjacob *
75264087Smjacob *	MAXISPREQUEST(struct ispsoftc *)	maximum request queue size
75364087Smjacob *						for this particular board type
75464087Smjacob *
75564087Smjacob *	MEMORYBARRIER(struct ispsoftc *, barrier_type, offset, size)
75664087Smjacob *
75764087Smjacob *		Function/Macro the provides memory synchronization on
75864087Smjacob *		various objects so that the ISP's and the system's view
75964087Smjacob *		of the same object is consistent.
76064087Smjacob *
76164087Smjacob *	MBOX_ACQUIRE(struct ispsoftc *)		acquire lock on mailbox regs
76264087Smjacob *	MBOX_WAIT_COMPLETE(struct ispsoftc *)	wait for mailbox cmd to be done
76364087Smjacob *	MBOX_NOTIFY_COMPLETE(struct ispsoftc *)	notification of mbox cmd donee
76464087Smjacob *	MBOX_RELEASE(struct ispsoftc *)		release lock on mailbox regs
76564087Smjacob *
76672355Smjacob *
76764087Smjacob *	SCSI_GOOD	SCSI 'Good' Status
76864087Smjacob *	SCSI_CHECK	SCSI 'Check Condition' Status
76964087Smjacob *	SCSI_BUSY	SCSI 'Busy' Status
77064087Smjacob *	SCSI_QFULL	SCSI 'Queue Full' Status
77164087Smjacob *
77264087Smjacob *	XS_T		Platform SCSI transaction type (i.e., command for HBA)
77364087Smjacob *	XS_ISP(xs)	gets an instance out of an XS_T
77464087Smjacob *	XS_CHANNEL(xs)	gets the channel (bus # for DUALBUS cards) ""
77564087Smjacob *	XS_TGT(xs)	gets the target ""
77664087Smjacob *	XS_LUN(xs)	gets the lun ""
77764087Smjacob *	XS_CDBP(xs)	gets a pointer to the scsi CDB ""
77864087Smjacob *	XS_CDBLEN(xs)	gets the CDB's length ""
77964087Smjacob *	XS_XFRLEN(xs)	gets the associated data transfer length ""
78064087Smjacob *	XS_TIME(xs)	gets the time (in milliseconds) for this command
78164087Smjacob *	XS_RESID(xs)	gets the current residual count
78264087Smjacob *	XS_STSP(xs)	gets a pointer to the SCSI status byte ""
78364087Smjacob *	XS_SNSP(xs)	gets a pointer to the associate sense data
78464087Smjacob *	XS_SNSLEN(xs)	gets the length of sense data storage
78564087Smjacob *	XS_SNSKEY(xs)	dereferences XS_SNSP to get the current stored Sense Key
78664087Smjacob *	XS_TAG_P(xs)	predicate of whether this command should be tagged
78764087Smjacob *	XS_TAG_TYPE(xs)	which type of tag to use
78864087Smjacob *	XS_SETERR(xs)	set error state
78964087Smjacob *
79064087Smjacob *		HBA_NOERROR	command has no erros
79164087Smjacob *		HBA_BOTCH	hba botched something
79264087Smjacob *		HBA_CMDTIMEOUT	command timed out
79364087Smjacob *		HBA_SELTIMEOUT	selection timed out (also port logouts for FC)
79464087Smjacob *		HBA_TGTBSY	target returned a BUSY status
79564087Smjacob *		HBA_BUSRESET	bus reset destroyed command
79664087Smjacob *		HBA_ABORTED	command was aborted (by request)
79764087Smjacob *		HBA_DATAOVR	a data overrun was detected
79864087Smjacob *		HBA_ARQFAIL	Automatic Request Sense failed
79964087Smjacob *
80064087Smjacob *	XS_ERR(xs)	return current error state
80164087Smjacob *	XS_NOERR(xs)	there is no error currently set
80264087Smjacob *	XS_INITERR(xs)	initialize error state
80364087Smjacob *
80464087Smjacob *	XS_SAVE_SENSE(xs, sp)		save sense data
80564087Smjacob *
80664087Smjacob *	XS_SET_STATE_STAT(isp, sp, xs)	platform dependent interpreter of
80764087Smjacob *					response queue entry status bits
80864087Smjacob *
80964087Smjacob *
81064087Smjacob *	DEFAULT_IID(struct ispsoftc *)		Default SCSI initiator ID
81164087Smjacob *	DEFAULT_LOOPID(struct ispsoftc *)	Default FC Loop ID
81267047Smjacob *	DEFAULT_NODEWWN(struct ispsoftc *)	Default Node WWN
81367047Smjacob *	DEFAULT_PORTWWN(struct ispsoftc *)	Default Port WWN
81467047Smjacob *		These establish reasonable defaults for each platform.
81567047Smjacob * 		These must be available independent of card NVRAM and are
81667047Smjacob *		to be used should NVRAM not be readable.
81764087Smjacob *
81867047Smjacob *	ISP_NODEWWN(struct ispsoftc *)	FC Node WWN to use
81967047Smjacob *	ISP_PORTWWN(struct ispsoftc *)	FC Port WWN to use
82064087Smjacob *
82167047Smjacob *		These are to be used after NVRAM is read. The tags
82267047Smjacob *		in fcparam.isp_{node,port}wwn reflect the values
82367047Smjacob *		read from NVRAM (possibly corrected for card botches).
82467047Smjacob *		Each platform can take that information and override
82567047Smjacob *		it or ignore and return the Node and Port WWNs to be
82667047Smjacob * 		used when sending the Qlogic f/w the Initialization Control
82767047Smjacob *		Block.
82864087Smjacob *
82964087Smjacob *	(XXX these do endian specific transformations- in transition XXX)
83087635Smjacob *
83187635Smjacob *	ISP_IOXPUT_8(struct ispsoftc *, u_int8_t srcval, u_int8_t *dstptr)
83287635Smjacob *	ISP_IOXPUT_16(struct ispsoftc *, u_int16_t srcval, u_int16_t *dstptr)
83387635Smjacob *	ISP_IOXPUT_32(struct ispsoftc *, u_int32_t srcval, u_int32_t *dstptr)
83487635Smjacob *
83587635Smjacob *	ISP_IOXGET_8(struct ispsoftc *, u_int8_t *srcptr, u_int8_t dstrval)
83687635Smjacob *	ISP_IOXGET_16(struct ispsoftc *, u_int16_t *srcptr, u_int16_t dstrval)
83787635Smjacob *	ISP_IOXGET_32(struct ispsoftc *, u_int32_t *srcptr, u_int32_t dstrval)
83887635Smjacob *
83987635Smjacob *	ISP_SWIZZLE_NVRAM_WORD(struct ispsoftc *, u_int16_t *)
84064087Smjacob */
84177365Smjacob
84235388Smjacob#endif	/* _ISPVAR_H */
843