ispvar.h revision 103826
150477Speter/* $FreeBSD: head/sys/dev/isp/ispvar.h 103826 2002-09-23 05:09:23Z 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
5798281Smjacob#define	ISP_CORE_VERSION_MINOR	7
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 *);
7692893Smjacob	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 */
92103826Smjacob#ifdef	ISP_DAC_SUPPORTED
93103826Smjacobtypedef	u_int64_t	isp_dma_addr_t;
94103826Smjacob#else
95103826Smjacobtypedef	u_int32_t	isp_dma_addr_t;
9682689Smjacob#endif
9753487Smjacob
9853487Smjacob/*
9964087Smjacob * Macros to access ISP registers through bus specific layers-
10064087Smjacob * mostly wrappers to vector through the mdvec structure.
10153487Smjacob */
10282689Smjacob#define	ISP_READ_ISR(isp, isrp, semap, mbox0p)	\
10382689Smjacob	(*(isp)->isp_mdvec->dv_rd_isr)(isp, isrp, semap, mbox0p)
10453487Smjacob
10553487Smjacob#define	ISP_READ(isp, reg)	\
10653487Smjacob	(*(isp)->isp_mdvec->dv_rd_reg)((isp), (reg))
10753487Smjacob
10853487Smjacob#define	ISP_WRITE(isp, reg, val)	\
10953487Smjacob	(*(isp)->isp_mdvec->dv_wr_reg)((isp), (reg), (val))
11053487Smjacob
11153487Smjacob#define	ISP_MBOXDMASETUP(isp)	\
11253487Smjacob	(*(isp)->isp_mdvec->dv_mbxdma)((isp))
11353487Smjacob
11453487Smjacob#define	ISP_DMASETUP(isp, xs, req, iptrp, optr)	\
11553487Smjacob	(*(isp)->isp_mdvec->dv_dmaset)((isp), (xs), (req), (iptrp), (optr))
11653487Smjacob
11753487Smjacob#define	ISP_DMAFREE(isp, xs, hndl)	\
11853487Smjacob	if ((isp)->isp_mdvec->dv_dmaclr) \
11953487Smjacob	    (*(isp)->isp_mdvec->dv_dmaclr)((isp), (xs), (hndl))
12053487Smjacob
12153487Smjacob#define	ISP_RESET0(isp)	\
12253487Smjacob	if ((isp)->isp_mdvec->dv_reset0) (*(isp)->isp_mdvec->dv_reset0)((isp))
12353487Smjacob#define	ISP_RESET1(isp)	\
12453487Smjacob	if ((isp)->isp_mdvec->dv_reset1) (*(isp)->isp_mdvec->dv_reset1)((isp))
12564087Smjacob#define	ISP_DUMPREGS(isp, m)	\
12664087Smjacob	if ((isp)->isp_mdvec->dv_dregs) (*(isp)->isp_mdvec->dv_dregs)((isp),(m))
12753487Smjacob
12853487Smjacob#define	ISP_SETBITS(isp, reg, val)	\
12953487Smjacob (*(isp)->isp_mdvec->dv_wr_reg)((isp), (reg), ISP_READ((isp), (reg)) | (val))
13053487Smjacob
13153487Smjacob#define	ISP_CLRBITS(isp, reg, val)	\
13253487Smjacob (*(isp)->isp_mdvec->dv_wr_reg)((isp), (reg), ISP_READ((isp), (reg)) & ~(val))
13353487Smjacob
13464087Smjacob/*
13564087Smjacob * The MEMORYBARRIER macro is defined per platform (to provide synchronization
13664087Smjacob * on Request and Response Queues, Scratch DMA areas, and Registers)
13764087Smjacob *
13864087Smjacob * Defined Memory Barrier Synchronization Types
13964087Smjacob */
14064087Smjacob#define	SYNC_REQUEST	0	/* request queue synchronization */
14164087Smjacob#define	SYNC_RESULT	1	/* result queue synchronization */
14264087Smjacob#define	SYNC_SFORDEV	2	/* scratch, sync for ISP */
14364087Smjacob#define	SYNC_SFORCPU	3	/* scratch, sync for CPU */
14464087Smjacob#define	SYNC_REG	4	/* for registers */
14564087Smjacob
14664087Smjacob/*
14764087Smjacob * Request/Response Queue defines and macros.
14864087Smjacob * The maximum is defined per platform (and can be based on board type).
14964087Smjacob */
15064087Smjacob/* This is the size of a queue entry (request and response) */
15139235Sgibbs#define	QENTRY_LEN			64
15264087Smjacob/* Both request and result queue length must be a power of two */
15364087Smjacob#define	RQUEST_QUEUE_LEN(x)		MAXISPREQUEST(x)
15493706Smjacob#ifdef	ISP_TARGET_MODE
15593706Smjacob#define	RESULT_QUEUE_LEN(x)		MAXISPREQUEST(x)
15693706Smjacob#else
15764087Smjacob#define	RESULT_QUEUE_LEN(x)		\
15864087Smjacob	(((MAXISPREQUEST(x) >> 2) < 64)? 64 : MAXISPREQUEST(x) >> 2)
15993706Smjacob#endif
16039235Sgibbs#define	ISP_QUEUE_ENTRY(q, idx)		((q) + ((idx) * QENTRY_LEN))
16139235Sgibbs#define	ISP_QUEUE_SIZE(n)		((n) * QENTRY_LEN)
16239235Sgibbs#define	ISP_NXT_QENTRY(idx, qlen)	(((idx) + 1) & ((qlen)-1))
16365140Smjacob#define	ISP_QFREE(in, out, qlen)	\
16439235Sgibbs	((in == out)? (qlen - 1) : ((in > out)? \
16552347Smjacob	((qlen - 1) - (in - out)) : (out - in - 1)))
16665140Smjacob#define	ISP_QAVAIL(isp)	\
16765140Smjacob	ISP_QFREE(isp->isp_reqidx, isp->isp_reqodx, RQUEST_QUEUE_LEN(isp))
16853487Smjacob
16987635Smjacob#define	ISP_ADD_REQUEST(isp, nxti)					\
17087635Smjacob	MEMORYBARRIER(isp, SYNC_REQUEST, isp->isp_reqidx, QENTRY_LEN);	\
17187635Smjacob	WRITE_REQUEST_QUEUE_IN_POINTER(isp, nxti);			\
17287635Smjacob	isp->isp_reqidx = nxti
17353487Smjacob
17435388Smjacob/*
17546968Smjacob * SCSI Specific Host Adapter Parameters- per bus, per target
17635388Smjacob */
17735388Smjacob
17835388Smjacobtypedef struct {
17946968Smjacob	u_int		isp_gotdparms		: 1,
18052347Smjacob			isp_req_ack_active_neg	: 1,
18152347Smjacob			isp_data_line_active_neg: 1,
18235388Smjacob			isp_cmd_dma_burst_enable: 1,
18335388Smjacob			isp_data_dma_burst_enabl: 1,
18442461Smjacob			isp_fifo_threshold	: 3,
18543420Smjacob			isp_ultramode		: 1,
18635388Smjacob			isp_diffmode		: 1,
18745040Smjacob			isp_lvdmode		: 1,
18865140Smjacob			isp_fast_mttr		: 1,	/* fast sram */
18935388Smjacob			isp_initiator_id	: 4,
19052347Smjacob			isp_async_data_setup	: 4;
19152347Smjacob	u_int16_t	isp_selection_timeout;
19252347Smjacob	u_int16_t	isp_max_queue_depth;
19335388Smjacob	u_int8_t	isp_tag_aging;
19452347Smjacob	u_int8_t	isp_bus_reset_delay;
19552347Smjacob	u_int8_t	isp_retry_count;
19652347Smjacob	u_int8_t	isp_retry_delay;
19735388Smjacob	struct {
19880582Smjacob		u_int32_t
19980582Smjacob			exc_throttle	:	8,
20046968Smjacob					:	1,
20180582Smjacob			dev_enable	:	1,	/* ignored */
20243420Smjacob			dev_update	:	1,
20343420Smjacob			dev_refresh	:	1,
20480582Smjacob			actv_offset	:	4,
20580582Smjacob			goal_offset	:	4,
20680582Smjacob			nvrm_offset	:	4;
20780582Smjacob		u_int8_t	actv_period;	/* current sync period */
20880582Smjacob		u_int8_t	goal_period;	/* goal sync period */
20980582Smjacob		u_int8_t	nvrm_period;	/* nvram sync period */
21080582Smjacob		u_int16_t	actv_flags;	/* current device flags */
21180582Smjacob		u_int16_t	goal_flags;	/* goal device flags */
21280582Smjacob		u_int16_t	nvrm_flags;	/* nvram device flags */
21335388Smjacob	} isp_devparam[MAX_TARGETS];
21446968Smjacob} sdparam;
21535388Smjacob
21635388Smjacob/*
21735388Smjacob * Device Flags
21835388Smjacob */
21939235Sgibbs#define	DPARM_DISC	0x8000
22039235Sgibbs#define	DPARM_PARITY	0x4000
22139235Sgibbs#define	DPARM_WIDE	0x2000
22239235Sgibbs#define	DPARM_SYNC	0x1000
22339235Sgibbs#define	DPARM_TQING	0x0800
22439235Sgibbs#define	DPARM_ARQ	0x0400
22539235Sgibbs#define	DPARM_QFRZ	0x0200
22639235Sgibbs#define	DPARM_RENEG	0x0100
22765140Smjacob#define	DPARM_NARROW	0x0080
22865140Smjacob#define	DPARM_ASYNC	0x0040
22965140Smjacob#define	DPARM_PPR	0x0020
23043793Smjacob#define	DPARM_DEFAULT	(0xFF00 & ~DPARM_QFRZ)
23139235Sgibbs#define	DPARM_SAFE_DFLT	(DPARM_DEFAULT & ~(DPARM_WIDE|DPARM_SYNC|DPARM_TQING))
23235388Smjacob
23339235Sgibbs
23445040Smjacob/* technically, not really correct, as they need to be rated based upon clock */
23565140Smjacob#define	ISP_80M_SYNCPARMS	0x0c09
23665140Smjacob#define	ISP_40M_SYNCPARMS	0x0c0a
23765140Smjacob#define	ISP_20M_SYNCPARMS	0x0c0c
23865140Smjacob#define	ISP_20M_SYNCPARMS_1040	0x080c
23952347Smjacob#define	ISP_10M_SYNCPARMS	0x0c19
24052347Smjacob#define	ISP_08M_SYNCPARMS	0x0c25
24152347Smjacob#define	ISP_05M_SYNCPARMS	0x0c32
24252347Smjacob#define	ISP_04M_SYNCPARMS	0x0c41
24335388Smjacob
24435388Smjacob/*
24535388Smjacob * Fibre Channel Specifics
24635388Smjacob */
24752347Smjacob#define	FL_PORT_ID		0x7e	/* FL_Port Special ID */
24852347Smjacob#define	FC_PORT_ID		0x7f	/* Fabric Controller Special ID */
24952347Smjacob#define	FC_SNS_ID		0x80	/* SNS Server Special ID */
25052347Smjacob
25193837Smjacob/* #define	ISP_USE_GA_NXT	1 */	/* Use GA_NXT with switches */
25293837Smjacob#ifndef	GA_NXT_MAX
25393837Smjacob#define	GA_NXT_MAX	256
25493837Smjacob#endif
25593837Smjacob
25635388Smjacobtypedef struct {
25752347Smjacob	u_int32_t		isp_fwoptions	: 16,
25884241Smjacob				isp_gbspeed	: 2,
25972355Smjacob				isp_iid_set	: 1,
26048484Smjacob				loop_seen_once	: 1,
26177776Smjacob				isp_loopstate	: 4,	/* Current Loop State */
26248484Smjacob				isp_fwstate	: 3,	/* ISP F/W state */
26348484Smjacob				isp_gotdparms	: 1,
26459454Smjacob				isp_topo	: 3,
26548484Smjacob				isp_onfabric	: 1;
26672355Smjacob	u_int8_t		isp_iid;	/* 'initiator' id */
26739235Sgibbs	u_int8_t		isp_loopid;	/* hard loop id */
26839235Sgibbs	u_int8_t		isp_alpa;	/* ALPA */
26972355Smjacob	u_int32_t		isp_portid;
27052347Smjacob	volatile u_int16_t	isp_lipseq;	/* LIP sequence # */
27182841Smjacob	u_int16_t		isp_fwattr;	/* firmware attributes */
27239235Sgibbs	u_int8_t		isp_execthrottle;
27352347Smjacob	u_int8_t		isp_retry_delay;
27452347Smjacob	u_int8_t		isp_retry_count;
27552347Smjacob	u_int8_t		isp_reserved;
27639235Sgibbs	u_int16_t		isp_maxalloc;
27739235Sgibbs	u_int16_t		isp_maxfrmlen;
27848484Smjacob	u_int64_t		isp_nodewwn;
27948484Smjacob	u_int64_t		isp_portwwn;
28035388Smjacob	/*
28148484Smjacob	 * Port Data Base. This is indexed by 'target', which is invariate.
28248484Smjacob	 * However, elements within can move around due to loop changes,
28348484Smjacob	 * so the actual loop ID passed to the F/W is in this structure.
28448484Smjacob	 * The first time the loop is seen up, loopid will match the index
28548484Smjacob	 * (except for fabric nodes which are above mapped above FC_SNS_ID
28648484Smjacob	 * and are completely virtual), but subsequent LIPs can cause things
28748484Smjacob	 * to move around.
28844819Smjacob	 */
28948484Smjacob	struct lportdb {
29093837Smjacob		u_int32_t
29193837Smjacob					port_type	: 8,
29298281Smjacob					loopid		: 8,
29393837Smjacob					fc4_type	: 4,
29493837Smjacob					last_fabric_dev	: 1,
29598281Smjacob							: 2,
29698281Smjacob					relogin		: 1,
29777776Smjacob					force_logout	: 1,
29871079Smjacob					was_fabric_dev	: 1,
29971079Smjacob					fabric_dev	: 1,
30060221Smjacob					loggedin	: 1,
30160221Smjacob					roles		: 2,
30260221Smjacob					valid		: 1;
30352347Smjacob		u_int32_t		portid;
30448484Smjacob		u_int64_t		node_wwn;
30548484Smjacob		u_int64_t		port_wwn;
30672355Smjacob	} portdb[MAX_FC_TARG], tport[FC_PORT_ID];
30744819Smjacob
30844819Smjacob	/*
30935388Smjacob	 * Scratch DMA mapped in area to fetch Port Database stuff, etc.
31035388Smjacob	 */
31148195Smjacob	caddr_t			isp_scratch;
312103826Smjacob	isp_dma_addr_t		isp_scdma;
31390752Smjacob#ifdef	ISP_FW_CRASH_DUMP
31490752Smjacob	u_int16_t		*isp_dump_data;
31590752Smjacob#endif
31635388Smjacob} fcparam;
31735388Smjacob
31848484Smjacob#define	FW_CONFIG_WAIT		0
31948484Smjacob#define	FW_WAIT_AL_PA		1
32048484Smjacob#define	FW_WAIT_LOGIN		2
32148484Smjacob#define	FW_READY		3
32248484Smjacob#define	FW_LOSS_OF_SYNC		4
32348484Smjacob#define	FW_ERROR		5
32448484Smjacob#define	FW_REINIT		6
32548484Smjacob#define	FW_NON_PART		7
32635388Smjacob
32748484Smjacob#define	LOOP_NIL		0
32848484Smjacob#define	LOOP_LIP_RCVD		1
32948484Smjacob#define	LOOP_PDB_RCVD		2
33072355Smjacob#define	LOOP_SCANNING_FABRIC	3
33172355Smjacob#define	LOOP_FSCAN_DONE		4
33272355Smjacob#define	LOOP_SCANNING_LOOP	5
33377776Smjacob#define	LOOP_LSCAN_DONE		6
33477776Smjacob#define	LOOP_SYNCING_PDB	7
33577776Smjacob#define	LOOP_READY		8
33635388Smjacob
33759454Smjacob#define	TOPO_NL_PORT		0
33859454Smjacob#define	TOPO_FL_PORT		1
33959454Smjacob#define	TOPO_N_PORT		2
34059454Smjacob#define	TOPO_F_PORT		3
34159454Smjacob#define	TOPO_PTP_STUB		4
34259454Smjacob
34342131Smjacob/*
34435388Smjacob * Soft Structure per host adapter
34535388Smjacob */
34665140Smjacobtypedef struct ispsoftc {
34735388Smjacob	/*
34835388Smjacob	 * Platform (OS) specific data
34935388Smjacob	 */
35035388Smjacob	struct isposinfo	isp_osinfo;
35135388Smjacob
35235388Smjacob	/*
35353487Smjacob	 * Pointer to bus specific functions and data
35435388Smjacob	 */
35535388Smjacob	struct ispmdvec *	isp_mdvec;
35635388Smjacob
35735388Smjacob	/*
35853487Smjacob	 * (Mostly) nonvolatile state. Board specific parameters
35953487Smjacob	 * may contain some volatile state (e.g., current loop state).
36035388Smjacob	 */
36135388Smjacob
36253487Smjacob	void * 			isp_param;	/* type specific */
36353487Smjacob	u_int16_t		isp_fwrev[3];	/* Loaded F/W revision */
36453487Smjacob	u_int16_t		isp_romfw_rev[3]; /* PROM F/W revision */
36553487Smjacob	u_int16_t		isp_maxcmds;	/* max possible I/O cmds */
36653487Smjacob	u_int8_t		isp_type;	/* HBA Chip Type */
36753487Smjacob	u_int8_t		isp_revision;	/* HBA Chip H/W Revision */
36861772Smjacob	u_int32_t		isp_maxluns;	/* maximum luns supported */
36935388Smjacob
37071079Smjacob	u_int32_t		isp_clock	: 8,	/* input clock */
37190224Smjacob						: 4,
37290224Smjacob				isp_port	: 1,	/* 23XX only */
37387635Smjacob				isp_failed	: 1,	/* board failed */
37487635Smjacob				isp_open	: 1,	/* opened (ioctl) */
37553487Smjacob				isp_touched	: 1,	/* board ever seen? */
37653487Smjacob				isp_bustype	: 1,	/* SBus or PCI */
37765140Smjacob				isp_loaded_fw	: 1,	/* loaded firmware */
37887635Smjacob				isp_role	: 2,	/* roles supported */
37971079Smjacob				isp_dblev	: 12;	/* debug log mask */
38071079Smjacob
38171079Smjacob	u_int32_t		isp_confopts;		/* config options */
38271079Smjacob
38382689Smjacob	u_int16_t		isp_rqstinrp;	/* register for REQINP */
38482689Smjacob	u_int16_t		isp_rqstoutrp;	/* register for REQOUTP */
38582689Smjacob	u_int16_t		isp_respinrp;	/* register for RESINP */
38682689Smjacob	u_int16_t		isp_respoutrp;	/* register for RESOUTP */
38782689Smjacob
38869522Smjacob	/*
38969522Smjacob	 * Instrumentation
39069522Smjacob	 */
39169522Smjacob	u_int64_t		isp_intcnt;		/* total int count */
39269522Smjacob	u_int64_t		isp_intbogus;		/* spurious int count */
39388855Smjacob	u_int64_t		isp_intmboxc;		/* mbox completions */
39488855Smjacob	u_int64_t		isp_intoasync;		/* other async */
39588855Smjacob	u_int64_t		isp_rsltccmplt;		/* CMDs on result q */
39688855Smjacob	u_int64_t		isp_fphccmplt;		/* CMDs via fastpost */
39788855Smjacob	u_int16_t		isp_rscchiwater;
39888855Smjacob	u_int16_t		isp_fpcchiwater;
39939235Sgibbs
40035388Smjacob	/*
40139235Sgibbs	 * Volatile state
40235388Smjacob	 */
40335388Smjacob
40462171Smjacob	volatile u_int32_t
40587635Smjacob		isp_obits	:	8,	/* mailbox command output */
40687635Smjacob		isp_mboxbsy	:	1,	/* mailbox command active */
40739235Sgibbs		isp_state	:	3,
40846968Smjacob		isp_sendmarker	:	2,	/* send a marker entry */
40946968Smjacob		isp_update	:	2,	/* update parameters */
41052347Smjacob		isp_nactive	:	16;	/* how many commands active */
41152347Smjacob	volatile u_int16_t	isp_reqodx;	/* index of last ISP pickup */
41252347Smjacob	volatile u_int16_t	isp_reqidx;	/* index of next request */
41352347Smjacob	volatile u_int16_t	isp_residx;	/* index of next result */
41492893Smjacob	volatile u_int16_t	isp_resodx;	/* index of next result */
41592893Smjacob	volatile u_int16_t	isp_rspbsy;
41652347Smjacob	volatile u_int16_t	isp_lasthdls;	/* last handle seed */
41762171Smjacob	volatile u_int16_t	isp_mboxtmp[MAX_MAILBOX];
41871079Smjacob	volatile u_int16_t	isp_lastmbxcmd;	/* last mbox command sent */
41990224Smjacob	volatile u_int16_t	isp_mbxwrk0;
42090224Smjacob	volatile u_int16_t	isp_mbxwrk1;
42190224Smjacob	volatile u_int16_t	isp_mbxwrk2;
42290224Smjacob	void *			isp_mbxworkp;
42335388Smjacob
42435388Smjacob	/*
42553487Smjacob	 * Active commands are stored here, indexed by handle functions.
42635388Smjacob	 */
42764087Smjacob	XS_T **isp_xflist;
42835388Smjacob
42935388Smjacob	/*
43052347Smjacob	 * request/result queue pointers and dma handles for them.
43135388Smjacob	 */
43248195Smjacob	caddr_t			isp_rquest;
43348195Smjacob	caddr_t			isp_result;
434103826Smjacob	isp_dma_addr_t		isp_rquest_dma;
435103826Smjacob	isp_dma_addr_t		isp_result_dma;
43665140Smjacob} ispsoftc_t;
43735388Smjacob
43849909Smjacob#define	SDPARAM(isp)	((sdparam *) (isp)->isp_param)
43949909Smjacob#define	FCPARAM(isp)	((fcparam *) (isp)->isp_param)
44049909Smjacob
44135388Smjacob/*
44264087Smjacob * ISP Driver Run States
44335388Smjacob */
44435388Smjacob#define	ISP_NILSTATE	0
44535388Smjacob#define	ISP_RESETSTATE	1
44635388Smjacob#define	ISP_INITSTATE	2
44735388Smjacob#define	ISP_RUNSTATE	3
44835388Smjacob
44935388Smjacob/*
45035388Smjacob * ISP Configuration Options
45135388Smjacob */
45235388Smjacob#define	ISP_CFG_NORELOAD	0x80	/* don't download f/w */
45343793Smjacob#define	ISP_CFG_NONVRAM		0x40	/* ignore NVRAM */
45484241Smjacob#define	ISP_CFG_TWOGB		0x20	/* force 2GB connection (23XX only) */
45584241Smjacob#define	ISP_CFG_ONEGB		0x10	/* force 1GB connection (23XX only) */
45653487Smjacob#define	ISP_CFG_FULL_DUPLEX	0x01	/* Full Duplex (Fibre Channel only) */
45769522Smjacob#define	ISP_CFG_PORT_PREF	0x0C	/* Mask for Port Prefs (2200 only) */
45869522Smjacob#define	ISP_CFG_LPORT		0x00	/* prefer {N/F}L-Port connection */
45969522Smjacob#define	ISP_CFG_NPORT		0x04	/* prefer {N/F}-Port connection */
46069522Smjacob#define	ISP_CFG_NPORT_ONLY	0x08	/* insist on {N/F}-Port connection */
46169522Smjacob#define	ISP_CFG_LPORT_ONLY	0x0C	/* insist on {N/F}L-Port connection */
46290752Smjacob#define	ISP_CFG_OWNWWPN		0x100	/* override NVRAM wwpn */
46390752Smjacob#define	ISP_CFG_OWNWWNN		0x200	/* override NVRAM wwnn */
46498281Smjacob#define	ISP_CFG_OWNFSZ		0x400	/* override NVRAM frame size */
46598281Smjacob#define	ISP_CFG_OWNLOOPID	0x800	/* override NVRAM loopid */
46698281Smjacob#define	ISP_CFG_OWNEXCTHROTTLE	0x1000	/* override NVRAM execution throttle */
46735388Smjacob
46864087Smjacob/*
46971079Smjacob * Prior to calling isp_reset for the first time, the outer layer
47071079Smjacob * should set isp_role to one of NONE, INITIATOR, TARGET, BOTH.
47171079Smjacob *
47271079Smjacob * If you set ISP_ROLE_NONE, the cards will be reset, new firmware loaded,
47371079Smjacob * NVRAM read, and defaults set, but any further initialization (e.g.
47471079Smjacob * INITIALIZE CONTROL BLOCK commands for 2X00 cards) won't be done.
47571079Smjacob *
47671079Smjacob * If INITIATOR MODE isn't set, attempts to run commands will be stopped
47771079Smjacob * at isp_start and completed with the moral equivalent of SELECTION TIMEOUT.
47871079Smjacob *
47971079Smjacob * If TARGET MODE is set, it doesn't mean that the rest of target mode support
48071079Smjacob * needs to be enabled, or will even work. What happens with the 2X00 cards
48171079Smjacob * here is that if you have enabled it with TARGET MODE as part of the ICB
48271079Smjacob * options, but you haven't given the f/w any ram resources for ATIOs or
48371079Smjacob * Immediate Notifies, the f/w just handles what it can and you never see
48471079Smjacob * anything. Basically, it sends a single byte of data (the first byte,
48571079Smjacob * which you can set as part of the INITIALIZE CONTROL BLOCK command) for
48671079Smjacob * INQUIRY, and sends back QUEUE FULL status for any other command.
48779235Smjacob *
48871079Smjacob */
48971079Smjacob#define	ISP_ROLE_NONE		0x0
49071079Smjacob#define	ISP_ROLE_INITIATOR	0x1
49171079Smjacob#define	ISP_ROLE_TARGET		0x2
49271079Smjacob#define	ISP_ROLE_BOTH		(ISP_ROLE_TARGET|ISP_ROLE_INITIATOR)
49371079Smjacob#define	ISP_ROLE_EITHER		ISP_ROLE_BOTH
49471079Smjacob#ifndef	ISP_DEFAULT_ROLES
49571079Smjacob#define	ISP_DEFAULT_ROLES	ISP_ROLE_INITIATOR
49671079Smjacob#endif
49771079Smjacob
49871079Smjacob
49971079Smjacob/*
50064087Smjacob * Firmware related defines
50164087Smjacob */
50271079Smjacob#define	ISP_CODE_ORG			0x1000	/* default f/w code start */
50382689Smjacob#define	ISP_CODE_ORG_2300		0x0800	/* ..except for 2300s */
50445282Smjacob#define	ISP_FW_REV(maj, min, mic)	((maj << 24) | (min << 16) | mic)
50582841Smjacob#define	ISP_FW_MAJOR(code)		((code >> 24) & 0xff)
50682841Smjacob#define	ISP_FW_MINOR(code)		((code >> 16) & 0xff)
50782841Smjacob#define	ISP_FW_MICRO(code)		((code >>  8) & 0xff)
50871079Smjacob#define	ISP_FW_REVX(xp)			((xp[0]<<24) | (xp[1] << 16) | xp[2])
50982841Smjacob#define	ISP_FW_MAJORX(xp)		(xp[0])
51082841Smjacob#define	ISP_FW_MINORX(xp)		(xp[1])
51182841Smjacob#define	ISP_FW_MICROX(xp)		(xp[2])
512102012Smjacob#define	ISP_FW_NEWER_THAN(i, major, minor, micro)		\
513102012Smjacob (ISP_FW_REVX((i)->isp_fwrev) > ISP_FW_REV(major, minor, micro))
51439235Sgibbs
51535388Smjacob/*
51639235Sgibbs * Bus (implementation) types
51735388Smjacob */
51839235Sgibbs#define	ISP_BT_PCI		0	/* PCI Implementations */
51939235Sgibbs#define	ISP_BT_SBUS		1	/* SBus Implementations */
52039235Sgibbs
52139235Sgibbs/*
52287635Smjacob * If we have not otherwise defined SBus support away make sure
52387635Smjacob * it is defined here such that the code is included as default
52487635Smjacob */
52587635Smjacob#ifndef	ISP_SBUS_SUPPORTED
52687635Smjacob#define	ISP_SBUS_SUPPORTED	1
52787635Smjacob#endif
52887635Smjacob
52987635Smjacob/*
53039235Sgibbs * Chip Types
53139235Sgibbs */
53235388Smjacob#define	ISP_HA_SCSI		0xf
53339235Sgibbs#define	ISP_HA_SCSI_UNKNOWN	0x1
53439235Sgibbs#define	ISP_HA_SCSI_1020	0x2
53539235Sgibbs#define	ISP_HA_SCSI_1020A	0x3
53639235Sgibbs#define	ISP_HA_SCSI_1040	0x4
53739235Sgibbs#define	ISP_HA_SCSI_1040A	0x5
53839235Sgibbs#define	ISP_HA_SCSI_1040B	0x6
53945282Smjacob#define	ISP_HA_SCSI_1040C	0x7
54054671Smjacob#define	ISP_HA_SCSI_1240	0x8
54154671Smjacob#define	ISP_HA_SCSI_1080	0x9
54254671Smjacob#define	ISP_HA_SCSI_1280	0xa
54357145Smjacob#define	ISP_HA_SCSI_12160	0xb
54435388Smjacob#define	ISP_HA_FC		0xf0
54535388Smjacob#define	ISP_HA_FC_2100		0x10
54648484Smjacob#define	ISP_HA_FC_2200		0x20
54777365Smjacob#define	ISP_HA_FC_2300		0x30
54888855Smjacob#define	ISP_HA_FC_2312		0x40
54935388Smjacob
55044819Smjacob#define	IS_SCSI(isp)	(isp->isp_type & ISP_HA_SCSI)
55154671Smjacob#define	IS_1240(isp)	(isp->isp_type == ISP_HA_SCSI_1240)
55244819Smjacob#define	IS_1080(isp)	(isp->isp_type == ISP_HA_SCSI_1080)
55354671Smjacob#define	IS_1280(isp)	(isp->isp_type == ISP_HA_SCSI_1280)
55457145Smjacob#define	IS_12160(isp)	(isp->isp_type == ISP_HA_SCSI_12160)
55557145Smjacob
55657145Smjacob#define	IS_12X0(isp)	(IS_1240(isp) || IS_1280(isp))
55757145Smjacob#define	IS_DUALBUS(isp)	(IS_12X0(isp) || IS_12160(isp))
55857145Smjacob#define	IS_ULTRA2(isp)	(IS_1080(isp) || IS_1280(isp) || IS_12160(isp))
55957145Smjacob#define	IS_ULTRA3(isp)	(IS_12160(isp))
56057145Smjacob
56177365Smjacob#define	IS_FC(isp)	((isp)->isp_type & ISP_HA_FC)
56277365Smjacob#define	IS_2100(isp)	((isp)->isp_type == ISP_HA_FC_2100)
56377365Smjacob#define	IS_2200(isp)	((isp)->isp_type == ISP_HA_FC_2200)
56488855Smjacob#define	IS_23XX(isp)	((isp)->isp_type >= ISP_HA_FC_2300)
56588855Smjacob#define	IS_2300(isp)	((isp)->isp_type == ISP_HA_FC_2300)
56688855Smjacob#define	IS_2312(isp)	((isp)->isp_type == ISP_HA_FC_2312)
56744819Smjacob
56864087Smjacob/*
56964087Smjacob * DMA cookie macros
57064087Smjacob */
571103826Smjacob#ifdef	ISP_DAC_SUPPORTRED
572103826Smjacob#define	DMA_WD3(x)	(((x) >> 48) & 0xffff)
573103826Smjacob#define	DMA_WD2(x)	(((x) >> 32) & 0xffff)
574103826Smjacob#else
57582689Smjacob#define	DMA_WD3(x)	0
57682689Smjacob#define	DMA_WD2(x)	0
577103826Smjacob#endif
57882689Smjacob#define	DMA_WD1(x)	(((x) >> 16) & 0xffff)
57982689Smjacob#define	DMA_WD0(x)	(((x) & 0xffff))
58057145Smjacob
58135388Smjacob/*
58264087Smjacob * Core System Function Prototypes
58335388Smjacob */
58435388Smjacob
58535388Smjacob/*
58639235Sgibbs * Reset Hardware. Totally. Assumes that you'll follow this with
58739235Sgibbs * a call to isp_init.
58835388Smjacob */
58974229Smjacobvoid isp_reset(struct ispsoftc *);
59035388Smjacob
59135388Smjacob/*
59235388Smjacob * Initialize Hardware to known state
59335388Smjacob */
59474229Smjacobvoid isp_init(struct ispsoftc *);
59535388Smjacob
59635388Smjacob/*
59739235Sgibbs * Reset the ISP and call completion for any orphaned commands.
59839235Sgibbs */
59974229Smjacobvoid isp_reinit(struct ispsoftc *);
60039235Sgibbs
60190752Smjacob#ifdef	ISP_FW_CRASH_DUMP
60239235Sgibbs/*
60390752Smjacob * Dump firmware entry point.
60490752Smjacob */
60590752Smjacobvoid isp_fw_dump(struct ispsoftc *isp);
60690752Smjacob#endif
60790752Smjacob
60890752Smjacob/*
60982689Smjacob * Internal Interrupt Service Routine
61082689Smjacob *
61182689Smjacob * The outer layers do the spade work to get the appropriate status register,
61282689Smjacob * semaphore register and first mailbox register (if appropriate). This also
61382689Smjacob * means that most spurious/bogus interrupts not for us can be filtered first.
61435388Smjacob */
61582689Smjacobvoid isp_intr(struct ispsoftc *, u_int16_t, u_int16_t, u_int16_t);
61635388Smjacob
61782689Smjacob
61835388Smjacob/*
61964087Smjacob * Command Entry Point- Platform Dependent layers call into this
62035388Smjacob */
62174229Smjacobint isp_start(XS_T *);
62264087Smjacob/* these values are what isp_start returns */
62364087Smjacob#define	CMD_COMPLETE	101	/* command completed */
62464087Smjacob#define	CMD_EAGAIN	102	/* busy- maybe retry later */
62564087Smjacob#define	CMD_QUEUED	103	/* command has been queued for execution */
62664087Smjacob#define	CMD_RQLATER 	104	/* requeue this command later */
62735388Smjacob
62839235Sgibbs/*
62964087Smjacob * Command Completion Point- Core layers call out from this with completed cmds
63064087Smjacob */
63174229Smjacobvoid isp_done(XS_T *);
63264087Smjacob
63364087Smjacob/*
63443420Smjacob * Platform Dependent to External to Internal Control Function
63539235Sgibbs *
63672355Smjacob * Assumes locks are held on entry. You should note that with many of
63772355Smjacob * these commands and locks may be released while this is occurring.
63839235Sgibbs *
63972355Smjacob * A few notes about some of these functions:
64072355Smjacob *
64172355Smjacob * ISPCTL_FCLINK_TEST tests to make sure we have good fibre channel link.
64272355Smjacob * The argument is a pointer to an integer which is the time, in microseconds,
64372355Smjacob * we should wait to see whether we have good link. This test, if successful,
64472355Smjacob * lets us know our connection topology and our Loop ID/AL_PA and so on.
64572355Smjacob * You can't get anywhere without this.
64672355Smjacob *
64772355Smjacob * ISPCTL_SCAN_FABRIC queries the name server (if we're on a fabric) for
64872355Smjacob * all entities using the FC Generic Services subcommand GET ALL NEXT.
64972355Smjacob * For each found entity, an ISPASYNC_FABRICDEV event is generated (see
65072355Smjacob * below).
65172355Smjacob *
65272355Smjacob * ISPCTL_SCAN_LOOP does a local loop scan. This is only done if the connection
65372355Smjacob * topology is NL or FL port (private or public loop). Since the Qlogic f/w
65472355Smjacob * 'automatically' manages local loop connections, this function essentially
65572355Smjacob * notes the arrival, departure, and possible shuffling around of local loop
65672355Smjacob * entities. Thus for each arrival and departure this generates an isp_async
65772355Smjacob * event of ISPASYNC_PROMENADE (see below).
65872355Smjacob *
65972355Smjacob * ISPCTL_PDB_SYNC is somewhat misnamed. It actually is the final step, in
66072355Smjacob * order, of ISPCTL_FCLINK_TEST, ISPCTL_SCAN_FABRIC, and ISPCTL_SCAN_LOOP.
66172355Smjacob * The main purpose of ISPCTL_PDB_SYNC is to complete management of logging
66272355Smjacob * and logging out of fabric devices (if one is on a fabric) and then marking
66372355Smjacob * the 'loop state' as being ready to now be used for sending commands to
66472355Smjacob * devices. Originally fabric name server and local loop scanning were
66581794Smjacob * part of this function. It's now been separated to allow for finer control.
66639235Sgibbs */
66739235Sgibbstypedef enum {
66848484Smjacob	ISPCTL_RESET_BUS,		/* Reset Bus */
66948484Smjacob	ISPCTL_RESET_DEV,		/* Reset Device */
67048484Smjacob	ISPCTL_ABORT_CMD,		/* Abort Command */
67172355Smjacob	ISPCTL_UPDATE_PARAMS,		/* Update Operating Parameters (SCSI) */
67255364Smjacob	ISPCTL_FCLINK_TEST,		/* Test FC Link Status */
67372355Smjacob	ISPCTL_SCAN_FABRIC,		/* (Re)scan Fabric Name Server */
67472355Smjacob	ISPCTL_SCAN_LOOP,		/* (Re)scan Local Loop */
67555364Smjacob	ISPCTL_PDB_SYNC,		/* Synchronize Port Database */
67672355Smjacob	ISPCTL_SEND_LIP,		/* Send a LIP */
67772355Smjacob	ISPCTL_GET_POSMAP,		/* Get FC-AL position map */
67872938Smjacob	ISPCTL_RUN_MBOXCMD,		/* run a mailbox command */
67955364Smjacob	ISPCTL_TOGGLE_TMODE		/* toggle target mode */
68039235Sgibbs} ispctl_t;
68174229Smjacobint isp_control(struct ispsoftc *, ispctl_t, void *);
68239235Sgibbs
68343420Smjacob
68439235Sgibbs/*
68543420Smjacob * Platform Dependent to Internal to External Control Function
68643420Smjacob * (each platform must provide such a function)
68743420Smjacob *
68872355Smjacob * Assumes locks are held.
68972355Smjacob *
69072355Smjacob * A few notes about some of these functions:
69172355Smjacob *
69272355Smjacob * ISPASYNC_CHANGE_NOTIFY notifies the outer layer that a change has
69372355Smjacob * occurred that invalidates the list of fabric devices known and/or
69472355Smjacob * the list of known loop devices. The argument passed is a pointer
69572355Smjacob * whose values are defined below  (local loop change, name server
69672355Smjacob * change, other). 'Other' may simply be a LIP, or a change in
69772355Smjacob * connection topology.
69872355Smjacob *
69972355Smjacob * ISPASYNC_FABRIC_DEV announces the next element in a list of
70072355Smjacob * fabric device names we're getting out of the name server. The
70172355Smjacob * argument points to a GET ALL NEXT response structure. The list
70272355Smjacob * is known to terminate with an entry that refers to ourselves.
70372355Smjacob * One of the main purposes of this function is to allow outer
70472355Smjacob * layers, which are OS dependent, to set policy as to which fabric
70572355Smjacob * devices might actually be logged into (and made visible) later
70672355Smjacob * at ISPCTL_PDB_SYNC time. Since there's a finite number of fabric
70772355Smjacob * devices that we can log into (256 less 3 'reserved' for F-port
70872355Smjacob * topologies), and fabrics can grow up to 8 million or so entries
70972355Smjacob * (24 bits of Port Address, less a wad of reserved spaces), clearly
71072355Smjacob * we had better let the OS determine login policy.
71172355Smjacob *
71272355Smjacob * ISPASYNC_PROMENADE has an argument that is a pointer to an integer which
713103826Smjacob * is an index into the portdb in the softc ('target'). Whether that entry's
71472355Smjacob * valid tag is set or not says whether something has arrived or departed.
71572355Smjacob * The name refers to a favorite pastime of many city dwellers- watching
71672355Smjacob * people come and go, talking of Michaelangelo, and so on..
71772938Smjacob *
71872938Smjacob * ISPASYNC_UNHANDLED_RESPONSE gives outer layers a chance to parse a
71972938Smjacob * response queue entry not otherwise handled. The outer layer should
72087635Smjacob * return non-zero if it handled it. The 'arg' points to an unmassaged
72187635Smjacob * response queue entry.
72243420Smjacob */
72343420Smjacob
72443420Smjacobtypedef enum {
72572355Smjacob	ISPASYNC_NEW_TGT_PARAMS,	/* New Target Parameters Negotiated */
72648484Smjacob	ISPASYNC_BUS_RESET,		/* Bus Was Reset */
72748484Smjacob	ISPASYNC_LOOP_DOWN,		/* FC Loop Down */
72848484Smjacob	ISPASYNC_LOOP_UP,		/* FC Loop Up */
72977365Smjacob	ISPASYNC_LIP,			/* LIP Received */
73077365Smjacob	ISPASYNC_LOOP_RESET,		/* Loop Reset Received */
73172355Smjacob	ISPASYNC_CHANGE_NOTIFY,		/* FC Change Notification */
73272355Smjacob	ISPASYNC_FABRIC_DEV,		/* FC Fabric Device Arrival */
73372355Smjacob	ISPASYNC_PROMENADE,		/* FC Objects coming && going */
73455364Smjacob	ISPASYNC_TARGET_MESSAGE,	/* target message */
73555364Smjacob	ISPASYNC_TARGET_EVENT,		/* target asynchronous event */
73672355Smjacob	ISPASYNC_TARGET_ACTION,		/* other target command action */
73772938Smjacob	ISPASYNC_CONF_CHANGE,		/* Platform Configuration Change */
73879235Smjacob	ISPASYNC_UNHANDLED_RESPONSE,	/* Unhandled Response Entry */
73998281Smjacob	ISPASYNC_FW_CRASH,		/* Firmware has crashed */
740102012Smjacob	ISPASYNC_FW_DUMPED,		/* Firmware crashdump taken */
74198281Smjacob	ISPASYNC_FW_RESTARTED		/* Firmware has been restarted */
74243420Smjacob} ispasync_t;
74374229Smjacobint isp_async(struct ispsoftc *, ispasync_t, void *);
74443420Smjacob
74572355Smjacob#define	ISPASYNC_CHANGE_PDB	((void *) 0)
74672355Smjacob#define	ISPASYNC_CHANGE_SNS	((void *) 1)
74772355Smjacob#define	ISPASYNC_CHANGE_OTHER	((void *) 2)
74872355Smjacob
74943420Smjacob/*
75064087Smjacob * Platform Dependent Error and Debug Printout
75139235Sgibbs */
75270490Smjacob#ifdef	__GNUC__
75374229Smjacobvoid isp_prt(struct ispsoftc *, int level, const char *, ...)
75470490Smjacob	__attribute__((__format__(__printf__,3,4)));
75570490Smjacob#else
75674229Smjacobvoid isp_prt(struct ispsoftc *, int level, const char *, ...);
75770490Smjacob#endif
75870490Smjacob
75964087Smjacob#define	ISP_LOGALL	0x0	/* log always */
76064087Smjacob#define	ISP_LOGCONFIG	0x1	/* log configuration messages */
76164087Smjacob#define	ISP_LOGINFO	0x2	/* log informational messages */
76264087Smjacob#define	ISP_LOGWARN	0x4	/* log warning messages */
76364087Smjacob#define	ISP_LOGERR	0x8	/* log error messages */
76464087Smjacob#define	ISP_LOGDEBUG0	0x10	/* log simple debug messages */
76564087Smjacob#define	ISP_LOGDEBUG1	0x20	/* log intermediate debug messages */
76664087Smjacob#define	ISP_LOGDEBUG2	0x40	/* log most debug messages */
76779235Smjacob#define	ISP_LOGDEBUG3	0x80	/* log high frequency debug messages */
76879235Smjacob#define	ISP_LOGDEBUG4	0x100	/* log high frequency debug messages */
76964087Smjacob#define	ISP_LOGTDEBUG0	0x200	/* log simple debug messages (target mode) */
77064087Smjacob#define	ISP_LOGTDEBUG1	0x400	/* log intermediate debug messages (target) */
77164087Smjacob#define	ISP_LOGTDEBUG2	0x800	/* log all debug messages (target) */
77239235Sgibbs
77364087Smjacob/*
77464087Smjacob * Each Platform provides it's own isposinfo substructure of the ispsoftc
77564087Smjacob * defined above.
77664087Smjacob *
77764087Smjacob * Each platform must also provide the following macros/defines:
77864087Smjacob *
77964087Smjacob *
78064087Smjacob *	INLINE		-	platform specific define for 'inline' functions
78164087Smjacob *
782103826Smjacob *	ISP_DAC_SUPPORTED -	Is DAC (Dual Address Cycle) is supported?
783103826Smjacob *				Basically means whether or not DMA for PCI
784103826Smjacob *				PCI cards (Ultra2 or better or FC) works
785103826Smjacob *				above 4GB.
78682689Smjacob *
78764087Smjacob *	ISP2100_SCRLEN	-	length for the Fibre Channel scratch DMA area
78864087Smjacob *
78964087Smjacob *	MEMZERO(dst, src)			platform zeroing function
79064087Smjacob *	MEMCPY(dst, src, count)			platform copying function
79164087Smjacob *	SNPRINTF(buf, bufsize, fmt, ...)	snprintf
79264087Smjacob *	USEC_DELAY(usecs)			microsecond spindelay function
79369522Smjacob *	USEC_SLEEP(isp, usecs)			microsecond sleep function
79464087Smjacob *
79564087Smjacob *	NANOTIME_T				nanosecond time type
79664087Smjacob *
79764087Smjacob *	GET_NANOTIME(NANOTIME_T *)		get current nanotime.
79864087Smjacob *
79964087Smjacob *	GET_NANOSEC(NANOTIME_T *)		get u_int64_t from NANOTIME_T
80064087Smjacob *
80164087Smjacob *	NANOTIME_SUB(NANOTIME_T *, NANOTIME_T *)
80264087Smjacob *						subtract two NANOTIME_T values
80364087Smjacob *
80464087Smjacob *
80564087Smjacob *	MAXISPREQUEST(struct ispsoftc *)	maximum request queue size
80664087Smjacob *						for this particular board type
80764087Smjacob *
80864087Smjacob *	MEMORYBARRIER(struct ispsoftc *, barrier_type, offset, size)
80964087Smjacob *
81064087Smjacob *		Function/Macro the provides memory synchronization on
81164087Smjacob *		various objects so that the ISP's and the system's view
81264087Smjacob *		of the same object is consistent.
81364087Smjacob *
81464087Smjacob *	MBOX_ACQUIRE(struct ispsoftc *)		acquire lock on mailbox regs
81564087Smjacob *	MBOX_WAIT_COMPLETE(struct ispsoftc *)	wait for mailbox cmd to be done
81664087Smjacob *	MBOX_NOTIFY_COMPLETE(struct ispsoftc *)	notification of mbox cmd donee
81764087Smjacob *	MBOX_RELEASE(struct ispsoftc *)		release lock on mailbox regs
81864087Smjacob *
81990224Smjacob *	FC_SCRATCH_ACQUIRE(struct ispsoftc *)	acquire lock on FC scratch area
82090224Smjacob *	FC_SCRATCH_RELEASE(struct ispsoftc *)	acquire lock on FC scratch area
82172355Smjacob *
82264087Smjacob *	SCSI_GOOD	SCSI 'Good' Status
82364087Smjacob *	SCSI_CHECK	SCSI 'Check Condition' Status
82464087Smjacob *	SCSI_BUSY	SCSI 'Busy' Status
82564087Smjacob *	SCSI_QFULL	SCSI 'Queue Full' Status
82664087Smjacob *
82764087Smjacob *	XS_T		Platform SCSI transaction type (i.e., command for HBA)
82864087Smjacob *	XS_ISP(xs)	gets an instance out of an XS_T
82964087Smjacob *	XS_CHANNEL(xs)	gets the channel (bus # for DUALBUS cards) ""
83064087Smjacob *	XS_TGT(xs)	gets the target ""
83164087Smjacob *	XS_LUN(xs)	gets the lun ""
83264087Smjacob *	XS_CDBP(xs)	gets a pointer to the scsi CDB ""
83364087Smjacob *	XS_CDBLEN(xs)	gets the CDB's length ""
83464087Smjacob *	XS_XFRLEN(xs)	gets the associated data transfer length ""
83564087Smjacob *	XS_TIME(xs)	gets the time (in milliseconds) for this command
83664087Smjacob *	XS_RESID(xs)	gets the current residual count
83764087Smjacob *	XS_STSP(xs)	gets a pointer to the SCSI status byte ""
83864087Smjacob *	XS_SNSP(xs)	gets a pointer to the associate sense data
83964087Smjacob *	XS_SNSLEN(xs)	gets the length of sense data storage
84064087Smjacob *	XS_SNSKEY(xs)	dereferences XS_SNSP to get the current stored Sense Key
84164087Smjacob *	XS_TAG_P(xs)	predicate of whether this command should be tagged
84264087Smjacob *	XS_TAG_TYPE(xs)	which type of tag to use
84364087Smjacob *	XS_SETERR(xs)	set error state
84464087Smjacob *
84564087Smjacob *		HBA_NOERROR	command has no erros
84664087Smjacob *		HBA_BOTCH	hba botched something
84764087Smjacob *		HBA_CMDTIMEOUT	command timed out
84864087Smjacob *		HBA_SELTIMEOUT	selection timed out (also port logouts for FC)
84964087Smjacob *		HBA_TGTBSY	target returned a BUSY status
85064087Smjacob *		HBA_BUSRESET	bus reset destroyed command
85164087Smjacob *		HBA_ABORTED	command was aborted (by request)
85264087Smjacob *		HBA_DATAOVR	a data overrun was detected
85364087Smjacob *		HBA_ARQFAIL	Automatic Request Sense failed
85464087Smjacob *
85564087Smjacob *	XS_ERR(xs)	return current error state
85664087Smjacob *	XS_NOERR(xs)	there is no error currently set
85764087Smjacob *	XS_INITERR(xs)	initialize error state
85864087Smjacob *
85964087Smjacob *	XS_SAVE_SENSE(xs, sp)		save sense data
86064087Smjacob *
86164087Smjacob *	XS_SET_STATE_STAT(isp, sp, xs)	platform dependent interpreter of
86264087Smjacob *					response queue entry status bits
86364087Smjacob *
86464087Smjacob *
86564087Smjacob *	DEFAULT_IID(struct ispsoftc *)		Default SCSI initiator ID
86664087Smjacob *	DEFAULT_LOOPID(struct ispsoftc *)	Default FC Loop ID
86767047Smjacob *	DEFAULT_NODEWWN(struct ispsoftc *)	Default Node WWN
86867047Smjacob *	DEFAULT_PORTWWN(struct ispsoftc *)	Default Port WWN
86998281Smjacob *	DEFAULT_FRAMESIZE(struct ispsoftc *)	Default Frame Size
87098281Smjacob *	DEFAULT_EXEC_THROTTLE(struct ispsoftc *) Default Execution Throttle
87167047Smjacob *		These establish reasonable defaults for each platform.
87267047Smjacob * 		These must be available independent of card NVRAM and are
87367047Smjacob *		to be used should NVRAM not be readable.
87464087Smjacob *
87567047Smjacob *	ISP_NODEWWN(struct ispsoftc *)	FC Node WWN to use
87667047Smjacob *	ISP_PORTWWN(struct ispsoftc *)	FC Port WWN to use
87764087Smjacob *
87867047Smjacob *		These are to be used after NVRAM is read. The tags
87967047Smjacob *		in fcparam.isp_{node,port}wwn reflect the values
88067047Smjacob *		read from NVRAM (possibly corrected for card botches).
88167047Smjacob *		Each platform can take that information and override
88267047Smjacob *		it or ignore and return the Node and Port WWNs to be
88367047Smjacob * 		used when sending the Qlogic f/w the Initialization Control
88467047Smjacob *		Block.
88564087Smjacob *
88664087Smjacob *	(XXX these do endian specific transformations- in transition XXX)
88787635Smjacob *
88887635Smjacob *	ISP_IOXPUT_8(struct ispsoftc *, u_int8_t srcval, u_int8_t *dstptr)
88987635Smjacob *	ISP_IOXPUT_16(struct ispsoftc *, u_int16_t srcval, u_int16_t *dstptr)
89087635Smjacob *	ISP_IOXPUT_32(struct ispsoftc *, u_int32_t srcval, u_int32_t *dstptr)
89187635Smjacob *
89287635Smjacob *	ISP_IOXGET_8(struct ispsoftc *, u_int8_t *srcptr, u_int8_t dstrval)
89387635Smjacob *	ISP_IOXGET_16(struct ispsoftc *, u_int16_t *srcptr, u_int16_t dstrval)
89487635Smjacob *	ISP_IOXGET_32(struct ispsoftc *, u_int32_t *srcptr, u_int32_t dstrval)
89587635Smjacob *
89687635Smjacob *	ISP_SWIZZLE_NVRAM_WORD(struct ispsoftc *, u_int16_t *)
89764087Smjacob */
89877365Smjacob
89935388Smjacob#endif	/* _ISPVAR_H */
900