ispvar.h revision 48484
148484Smjacob/* $Id: ispvar.h,v 1.15 1999/06/24 16:34:00 mjacob Exp $ */
248484Smjacob/* release_6_2_99 */
335388Smjacob/*
435388Smjacob * Soft Definitions for for Qlogic ISP SCSI adapters.
535388Smjacob *
635388Smjacob *---------------------------------------
748484Smjacob * Copyright (c) 1997, 1998, 1999 by Matthew Jacob
835388Smjacob * NASA/Ames Research Center
935388Smjacob * All rights reserved.
1035388Smjacob *---------------------------------------
1135388Smjacob * Redistribution and use in source and binary forms, with or without
1235388Smjacob * modification, are permitted provided that the following conditions
1335388Smjacob * are met:
1435388Smjacob * 1. Redistributions of source code must retain the above copyright
1535388Smjacob *    notice immediately at the beginning of the file, without modification,
1635388Smjacob *    this list of conditions, and the following disclaimer.
1735388Smjacob * 2. Redistributions in binary form must reproduce the above copyright
1835388Smjacob *    notice, this list of conditions and the following disclaimer in the
1935388Smjacob *    documentation and/or other materials provided with the distribution.
2035388Smjacob * 3. The name of the author may not be used to endorse or promote products
2135388Smjacob *    derived from this software without specific prior written permission.
2235388Smjacob *
2335388Smjacob * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
2435388Smjacob * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2535388Smjacob * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2635388Smjacob * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
2735388Smjacob * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2835388Smjacob * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2935388Smjacob * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3035388Smjacob * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3135388Smjacob * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3235388Smjacob * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3335388Smjacob * SUCH DAMAGE.
3435388Smjacob *
3535388Smjacob */
3635388Smjacob
3735388Smjacob#ifndef	_ISPVAR_H
3835388Smjacob#define	_ISPVAR_H
3935388Smjacob
4044819Smjacob#if defined(__NetBSD__) || defined(__OpenBSD__)
4135388Smjacob#include <dev/ic/ispmbox.h>
4235388Smjacob#endif
4335388Smjacob#ifdef	__FreeBSD__
4435388Smjacob#include <dev/isp/ispmbox.h>
4535388Smjacob#endif
4635388Smjacob#ifdef	__linux__
4742131Smjacob#include "ispmbox.h"
4835388Smjacob#endif
4935388Smjacob
5039235Sgibbs#define	ISP_CORE_VERSION_MAJOR	1
5148484Smjacob#define	ISP_CORE_VERSION_MINOR	9
5239235Sgibbs
5335388Smjacob/*
5443420Smjacob * Vector for bus specific code to provide specific services.
5535388Smjacob */
5635388Smjacobstruct ispsoftc;
5735388Smjacobstruct ispmdvec {
5835388Smjacob	u_int16_t	(*dv_rd_reg) __P((struct ispsoftc *, int));
5935388Smjacob	void		(*dv_wr_reg) __P((struct ispsoftc *, int, u_int16_t));
6035388Smjacob	int		(*dv_mbxdma) __P((struct ispsoftc *));
6135388Smjacob	int		(*dv_dmaset) __P((struct ispsoftc *,
6235388Smjacob		ISP_SCSI_XFER_T *, ispreq_t *, u_int8_t *, u_int8_t));
6335388Smjacob	void		(*dv_dmaclr)
6435388Smjacob		__P((struct ispsoftc *, ISP_SCSI_XFER_T *, u_int32_t));
6535388Smjacob	void		(*dv_reset0) __P((struct ispsoftc *));
6635388Smjacob	void		(*dv_reset1) __P((struct ispsoftc *));
6735388Smjacob	void		(*dv_dregs) __P((struct ispsoftc *));
6835388Smjacob	const u_int16_t *dv_ispfw;	/* ptr to f/w */
6935388Smjacob	u_int16_t 	dv_fwlen;	/* length of f/w */
7035388Smjacob	u_int16_t	dv_codeorg;	/* code ORG for f/w */
7135388Smjacob	u_int16_t	dv_fwrev;	/* f/w revision */
7235388Smjacob	/*
7335388Smjacob	 * Initial values for conf1 register
7435388Smjacob	 */
7535388Smjacob	u_int16_t	dv_conf1;
7635388Smjacob	u_int16_t	dv_clock;	/* clock frequency */
7735388Smjacob};
7835388Smjacob
7935388Smjacob#define	MAX_TARGETS	16
8044819Smjacob#ifdef	ISP2100_FABRIC
8144819Smjacob#define	MAX_FC_TARG	256
8244819Smjacob#else
8335388Smjacob#define	MAX_FC_TARG	126
8444819Smjacob#endif
8535388Smjacob
8639235Sgibbs/* queue length must be a power of two */
8739235Sgibbs#define	QENTRY_LEN			64
8839235Sgibbs#define	RQUEST_QUEUE_LEN		MAXISPREQUEST
8944819Smjacob#define	RESULT_QUEUE_LEN		(MAXISPREQUEST/2)
9039235Sgibbs#define	ISP_QUEUE_ENTRY(q, idx)		((q) + ((idx) * QENTRY_LEN))
9139235Sgibbs#define	ISP_QUEUE_SIZE(n)		((n) * QENTRY_LEN)
9239235Sgibbs#define	ISP_NXT_QENTRY(idx, qlen)	(((idx) + 1) & ((qlen)-1))
9339235Sgibbs#define ISP_QAVAIL(in, out, qlen)	\
9439235Sgibbs	((in == out)? (qlen - 1) : ((in > out)? \
9539235Sgibbs		((qlen - 1) - (in - out)) : (out - in - 1)))
9635388Smjacob/*
9746968Smjacob * SCSI Specific Host Adapter Parameters- per bus, per target
9835388Smjacob */
9935388Smjacob
10035388Smjacobtypedef struct {
10146968Smjacob	u_int		isp_gotdparms		: 1,
10246968Smjacob        		isp_req_ack_active_neg	: 1,
10335388Smjacob	        	isp_data_line_active_neg: 1,
10435388Smjacob			isp_cmd_dma_burst_enable: 1,
10535388Smjacob			isp_data_dma_burst_enabl: 1,
10642461Smjacob			isp_fifo_threshold	: 3,
10743420Smjacob			isp_ultramode		: 1,
10835388Smjacob			isp_diffmode		: 1,
10945040Smjacob			isp_lvdmode		: 1,
11046968Smjacob						: 1,
11135388Smjacob			isp_initiator_id	: 4,
11235388Smjacob        		isp_async_data_setup	: 4;
11335388Smjacob        u_int16_t	isp_selection_timeout;
11435388Smjacob        u_int16_t	isp_max_queue_depth;
11535388Smjacob	u_int8_t	isp_tag_aging;
11635388Smjacob       	u_int8_t	isp_bus_reset_delay;
11735388Smjacob        u_int8_t	isp_retry_count;
11835388Smjacob        u_int8_t	isp_retry_delay;
11935388Smjacob	struct {
12046968Smjacob		u_int	dev_enable	:	1,	/* ignored */
12146968Smjacob					:	1,
12243420Smjacob			dev_update	:	1,
12343420Smjacob			dev_refresh	:	1,
12445040Smjacob			exc_throttle	:	8,
12545040Smjacob			cur_offset	:	4,
12645040Smjacob			sync_offset	:	4;
12745040Smjacob		u_int8_t	cur_period;	/* current sync period */
12845040Smjacob		u_int8_t	sync_period;	/* goal sync period */
12945040Smjacob		u_int16_t	dev_flags;	/* goal device flags */
13045040Smjacob		u_int16_t	cur_dflags;	/* current device flags */
13135388Smjacob	} isp_devparam[MAX_TARGETS];
13246968Smjacob} sdparam;
13335388Smjacob
13435388Smjacob/*
13535388Smjacob * Device Flags
13635388Smjacob */
13739235Sgibbs#define	DPARM_DISC	0x8000
13839235Sgibbs#define	DPARM_PARITY	0x4000
13939235Sgibbs#define	DPARM_WIDE	0x2000
14039235Sgibbs#define	DPARM_SYNC	0x1000
14139235Sgibbs#define	DPARM_TQING	0x0800
14239235Sgibbs#define	DPARM_ARQ	0x0400
14339235Sgibbs#define	DPARM_QFRZ	0x0200
14439235Sgibbs#define	DPARM_RENEG	0x0100
14539235Sgibbs#define	DPARM_NARROW	0x0080	/* Possibly only available with >= 7.55 fw */
14639235Sgibbs#define	DPARM_ASYNC	0x0040	/* Possibly only available with >= 7.55 fw */
14743793Smjacob#define	DPARM_DEFAULT	(0xFF00 & ~DPARM_QFRZ)
14839235Sgibbs#define	DPARM_SAFE_DFLT	(DPARM_DEFAULT & ~(DPARM_WIDE|DPARM_SYNC|DPARM_TQING))
14935388Smjacob
15039235Sgibbs
15145040Smjacob/* technically, not really correct, as they need to be rated based upon clock */
15245040Smjacob#define	ISP_40M_SYNCPARMS	0x080a
15335388Smjacob#define ISP_20M_SYNCPARMS	0x080c
15435388Smjacob#define ISP_10M_SYNCPARMS	0x0c19
15535388Smjacob#define ISP_08M_SYNCPARMS	0x0c25
15635388Smjacob#define ISP_05M_SYNCPARMS	0x0c32
15735388Smjacob#define ISP_04M_SYNCPARMS	0x0c41
15835388Smjacob
15935388Smjacob/*
16035388Smjacob * Fibre Channel Specifics
16135388Smjacob */
16235388Smjacobtypedef struct {
16348484Smjacob	u_int			isp_fwoptions	: 16,
16448484Smjacob						: 7,
16548484Smjacob				loop_seen_once	: 1,
16648484Smjacob				isp_loopstate	: 3,	/* Current Loop State */
16748484Smjacob				isp_fwstate	: 3,	/* ISP F/W state */
16848484Smjacob				isp_gotdparms	: 1,
16948484Smjacob				isp_onfabric	: 1;
17039235Sgibbs	u_int8_t		isp_loopid;	/* hard loop id */
17139235Sgibbs	u_int8_t		isp_alpa;	/* ALPA */
17248484Smjacob	u_int32_t		isp_portid;
17339235Sgibbs	u_int8_t		isp_execthrottle;
17439235Sgibbs        u_int8_t		isp_retry_delay;
17535388Smjacob        u_int8_t		isp_retry_count;
17639235Sgibbs	u_int16_t		isp_maxalloc;
17739235Sgibbs	u_int16_t		isp_maxfrmlen;
17848484Smjacob	u_int64_t		isp_nodewwn;
17948484Smjacob	u_int64_t		isp_portwwn;
18035388Smjacob	/*
18148484Smjacob	 * Port Data Base. This is indexed by 'target', which is invariate.
18248484Smjacob	 * However, elements within can move around due to loop changes,
18348484Smjacob	 * so the actual loop ID passed to the F/W is in this structure.
18448484Smjacob	 * The first time the loop is seen up, loopid will match the index
18548484Smjacob	 * (except for fabric nodes which are above mapped above FC_SNS_ID
18648484Smjacob	 * and are completely virtual), but subsequent LIPs can cause things
18748484Smjacob	 * to move around.
18844819Smjacob	 */
18948484Smjacob	struct lportdb {
19048484Smjacob		u_int
19148484Smjacob					loopid	: 8,
19248484Smjacob						: 4,
19348484Smjacob					fabdev	: 1,
19448484Smjacob					roles	: 2,
19548484Smjacob					valid	: 1;
19648484Smjacob		u_int32_t		portid;
19748484Smjacob		u_int64_t		node_wwn;
19848484Smjacob		u_int64_t		port_wwn;
19948484Smjacob	} portdb[MAX_FC_TARG];
20044819Smjacob
20144819Smjacob	/*
20235388Smjacob	 * Scratch DMA mapped in area to fetch Port Database stuff, etc.
20335388Smjacob	 */
20448195Smjacob	caddr_t			isp_scratch;
20535388Smjacob	u_int32_t		isp_scdma;
20635388Smjacob} fcparam;
20735388Smjacob
20848484Smjacob#define	FW_CONFIG_WAIT		0
20948484Smjacob#define	FW_WAIT_AL_PA		1
21048484Smjacob#define	FW_WAIT_LOGIN		2
21148484Smjacob#define	FW_READY		3
21248484Smjacob#define	FW_LOSS_OF_SYNC		4
21348484Smjacob#define	FW_ERROR		5
21448484Smjacob#define	FW_REINIT		6
21548484Smjacob#define	FW_NON_PART		7
21635388Smjacob
21748484Smjacob#define	LOOP_NIL		0
21848484Smjacob#define	LOOP_LIP_RCVD		1
21948484Smjacob#define	LOOP_PDB_RCVD		2
22048484Smjacob#define	LOOP_READY		7
22135388Smjacob
22248484Smjacob#define	FL_PORT_ID		0x7e	/* FL_Port Special ID */
22348484Smjacob#define	FC_PORT_ID		0x7f	/* Fabric Controller Special ID */
22448484Smjacob#define	FC_SNS_ID		0x80	/* SNS Server Special ID */
22548484Smjacob
22642131Smjacob#ifdef	ISP_TARGET_MODE
22742131Smjacob/*
22842131Smjacob * Some temporary Target Mode definitions
22942131Smjacob */
23042131Smjacobtypedef struct tmd_cmd {
23142131Smjacob	u_int8_t	cd_iid;		/* initiator */
23242131Smjacob	u_int8_t	cd_tgt;		/* target */
23342131Smjacob	u_int8_t	cd_lun;		/* LUN for this command */
23442131Smjacob	u_int8_t	cd_state;
23542131Smjacob	u_int8_t	cd_cdb[16];	/* command bytes */
23642131Smjacob	u_int8_t	cd_sensedata[20];
23742131Smjacob	u_int16_t	cd_rxid;
23842131Smjacob	u_int32_t	cd_datalen;
23942131Smjacob	u_int32_t	cd_totbytes;
24042131Smjacob	void *		cd_hba;
24142131Smjacob} tmd_cmd_t;
24241519Smjacob
24335388Smjacob/*
24442131Smjacob * Async Target Mode Event Definitions
24542131Smjacob */
24642131Smjacob#define	TMD_BUS_RESET	0
24742131Smjacob#define	TMD_BDR		1
24842131Smjacob
24942131Smjacob/*
25042131Smjacob * Immediate Notify data structure.
25142131Smjacob */
25242131Smjacob#define NOTIFY_MSGLEN	5
25342131Smjacobtypedef struct {
25442131Smjacob	u_int8_t	nt_iid;			/* initiator */
25542131Smjacob	u_int8_t	nt_tgt;			/* target */
25642131Smjacob	u_int8_t	nt_lun;			/* LUN for this command */
25742131Smjacob	u_int8_t	nt_msg[NOTIFY_MSGLEN];	/* SCSI message byte(s) */
25842131Smjacob} tmd_notify_t;
25942131Smjacob
26042131Smjacob#endif
26142131Smjacob
26242131Smjacob/*
26335388Smjacob * Soft Structure per host adapter
26435388Smjacob */
26535388Smjacobstruct ispsoftc {
26635388Smjacob	/*
26735388Smjacob	 * Platform (OS) specific data
26835388Smjacob	 */
26935388Smjacob	struct isposinfo	isp_osinfo;
27035388Smjacob
27135388Smjacob	/*
27235388Smjacob	 * Pointer to bus specific data
27335388Smjacob	 */
27435388Smjacob	struct ispmdvec *	isp_mdvec;
27535388Smjacob
27635388Smjacob	/*
27746968Smjacob	 * Mostly nonvolatile state.
27835388Smjacob	 */
27935388Smjacob
28046968Smjacob	u_int		isp_clock	: 8,
28139235Sgibbs			isp_confopts	: 8,
28246968Smjacob			isp_fast_mttr	: 1,
28346968Smjacob					: 1,
28444819Smjacob			isp_used	: 1,
28539235Sgibbs			isp_dblev	: 3,
28635388Smjacob			isp_dogactive	: 1,
28739235Sgibbs			isp_bustype	: 1,	/* BUS Implementation */
28839235Sgibbs			isp_type	: 8;	/* HBA Type and Revision */
28935388Smjacob
29045282Smjacob	u_int16_t		isp_fwrev[3];	/* Running F/W revision */
29145282Smjacob	u_int16_t		isp_romfw_rev[3]; /* 'ROM' F/W revision */
29239235Sgibbs	void * 			isp_param;
29339235Sgibbs
29435388Smjacob	/*
29539235Sgibbs	 * Volatile state
29635388Smjacob	 */
29735388Smjacob
29839235Sgibbs	volatile u_int
29946968Smjacob				:	13,
30039235Sgibbs		isp_state	:	3,
30146968Smjacob				:	2,
30246968Smjacob		isp_sendmarker	:	2,	/* send a marker entry */
30346968Smjacob		isp_update	:	2,	/* update parameters */
30446968Smjacob		isp_nactive	:	10;	/* how many commands active */
30539235Sgibbs
30635388Smjacob	/*
30739235Sgibbs	 * Result and Request Queue indices.
30835388Smjacob	 */
30939235Sgibbs	volatile u_int8_t	isp_reqodx;	/* index of last ISP pickup */
31035388Smjacob	volatile u_int8_t	isp_reqidx;	/* index of next request */
31135388Smjacob	volatile u_int8_t	isp_residx;	/* index of next result */
31239235Sgibbs	volatile u_int8_t	isp_seqno;	/* rolling sequence # */
31335388Smjacob
31435388Smjacob	/*
31535388Smjacob	 * Sheer laziness, but it gets us around the problem
31635388Smjacob	 * where we don't have a clean way of remembering
31735388Smjacob	 * which transaction is bound to which ISP queue entry.
31835388Smjacob	 *
31935388Smjacob	 * There are other more clever ways to do this, but,
32035388Smjacob	 * jeez, so I blow a couple of KB per host adapter...
32135388Smjacob	 * and it *is* faster.
32235388Smjacob	 */
32343420Smjacob	ISP_SCSI_XFER_T *isp_xflist[RQUEST_QUEUE_LEN];
32435388Smjacob
32535388Smjacob	/*
32639235Sgibbs	 * request/result queues and dma handles for them.
32735388Smjacob	 */
32848195Smjacob	caddr_t			isp_rquest;
32948195Smjacob	caddr_t			isp_result;
33035388Smjacob	u_int32_t		isp_rquest_dma;
33135388Smjacob	u_int32_t		isp_result_dma;
33241519Smjacob
33342131Smjacob#ifdef	ISP_TARGET_MODE
33442131Smjacob	/*
33542131Smjacob	 * Vectors for handling target mode support.
33642131Smjacob	 *
33742131Smjacob	 * isp_tmd_newcmd is for feeding a newly arrived command to some
33842131Smjacob	 * upper layer.
33942131Smjacob	 *
34042131Smjacob	 * isp_tmd_event is for notifying some upper layer that an event has
34142131Smjacob	 * occurred that is not necessarily tied to any target (e.g., a SCSI
34242131Smjacob	 * Bus Reset).
34342131Smjacob	 *
34442131Smjacob	 * isp_tmd_notify is for notifying some upper layer that some
34542131Smjacob	 * event is now occurring that is either pertinent for a specific
34642131Smjacob	 * device or for a specific command (e.g., BDR or ABORT TAG).
34742131Smjacob	 *
34842131Smjacob	 * It is left undefined (for now) how pools of commands are managed.
34942131Smjacob	 */
35042131Smjacob	void		(*isp_tmd_newcmd) __P((void *, tmd_cmd_t *));
35142131Smjacob	void		(*isp_tmd_event) __P((void *, int));
35242131Smjacob	void		(*isp_tmd_notify) __P((void *, tmd_notify_t *));
35342131Smjacob#endif
35435388Smjacob};
35535388Smjacob
35635388Smjacob/*
35735388Smjacob * ISP States
35835388Smjacob */
35935388Smjacob#define	ISP_NILSTATE	0
36035388Smjacob#define	ISP_RESETSTATE	1
36135388Smjacob#define	ISP_INITSTATE	2
36235388Smjacob#define	ISP_RUNSTATE	3
36335388Smjacob
36435388Smjacob/*
36535388Smjacob * ISP Configuration Options
36635388Smjacob */
36735388Smjacob#define	ISP_CFG_NORELOAD	0x80	/* don't download f/w */
36843793Smjacob#define	ISP_CFG_NONVRAM		0x40	/* ignore NVRAM */
36948484Smjacob#define	ISP_CFG_FULL_DUPLEX	0x01	/* Fibre Channel Only */
37035388Smjacob
37145282Smjacob#define	ISP_FW_REV(maj, min, mic)	((maj << 24) | (min << 16) | mic)
37246968Smjacob#define	ISP_FW_REVX(xp)	((xp[0]<<24) | (xp[1] << 16) | xp[2])
37339235Sgibbs
37445282Smjacob
37535388Smjacob/*
37639235Sgibbs * Bus (implementation) types
37735388Smjacob */
37839235Sgibbs#define	ISP_BT_PCI		0	/* PCI Implementations */
37939235Sgibbs#define	ISP_BT_SBUS		1	/* SBus Implementations */
38039235Sgibbs
38139235Sgibbs/*
38239235Sgibbs * Chip Types
38339235Sgibbs */
38435388Smjacob#define	ISP_HA_SCSI		0xf
38539235Sgibbs#define	ISP_HA_SCSI_UNKNOWN	0x1
38639235Sgibbs#define	ISP_HA_SCSI_1020	0x2
38739235Sgibbs#define	ISP_HA_SCSI_1020A	0x3
38839235Sgibbs#define	ISP_HA_SCSI_1040	0x4
38939235Sgibbs#define	ISP_HA_SCSI_1040A	0x5
39039235Sgibbs#define	ISP_HA_SCSI_1040B	0x6
39145282Smjacob#define	ISP_HA_SCSI_1040C	0x7
39245040Smjacob#define	ISP_HA_SCSI_1080	0xd
39345040Smjacob#define	ISP_HA_SCSI_12X0	0xe
39435388Smjacob#define	ISP_HA_FC		0xf0
39535388Smjacob#define	ISP_HA_FC_2100		0x10
39648484Smjacob#define	ISP_HA_FC_2200		0x20
39735388Smjacob
39844819Smjacob#define	IS_SCSI(isp)	(isp->isp_type & ISP_HA_SCSI)
39944819Smjacob#define	IS_1080(isp)	(isp->isp_type == ISP_HA_SCSI_1080)
40045040Smjacob#define	IS_12X0(isp)	(isp->isp_type == ISP_HA_SCSI_12X0)
40144819Smjacob#define	IS_FC(isp)	(isp->isp_type & ISP_HA_FC)
40244819Smjacob
40335388Smjacob/*
40443420Smjacob * Macros to read, write ISP registers through bus specific code.
40535388Smjacob */
40635388Smjacob
40735388Smjacob#define	ISP_READ(isp, reg)	\
40835388Smjacob	(*(isp)->isp_mdvec->dv_rd_reg)((isp), (reg))
40935388Smjacob
41035388Smjacob#define	ISP_WRITE(isp, reg, val)	\
41135388Smjacob	(*(isp)->isp_mdvec->dv_wr_reg)((isp), (reg), (val))
41235388Smjacob
41335388Smjacob#define	ISP_MBOXDMASETUP(isp)	\
41435388Smjacob	(*(isp)->isp_mdvec->dv_mbxdma)((isp))
41535388Smjacob
41635388Smjacob#define	ISP_DMASETUP(isp, xs, req, iptrp, optr)	\
41735388Smjacob	(*(isp)->isp_mdvec->dv_dmaset)((isp), (xs), (req), (iptrp), (optr))
41835388Smjacob
41935388Smjacob#define	ISP_DMAFREE(isp, xs, seqno)	\
42035388Smjacob	if ((isp)->isp_mdvec->dv_dmaclr) \
42135388Smjacob		 (*(isp)->isp_mdvec->dv_dmaclr)((isp), (xs), (seqno))
42235388Smjacob
42335388Smjacob#define	ISP_RESET0(isp)	\
42435388Smjacob	if ((isp)->isp_mdvec->dv_reset0) (*(isp)->isp_mdvec->dv_reset0)((isp))
42535388Smjacob#define	ISP_RESET1(isp)	\
42635388Smjacob	if ((isp)->isp_mdvec->dv_reset1) (*(isp)->isp_mdvec->dv_reset1)((isp))
42735388Smjacob#define	ISP_DUMPREGS(isp)	\
42835388Smjacob	if ((isp)->isp_mdvec->dv_dregs) (*(isp)->isp_mdvec->dv_dregs)((isp))
42935388Smjacob
43035388Smjacob#define	ISP_SETBITS(isp, reg, val)	\
43135388Smjacob (*(isp)->isp_mdvec->dv_wr_reg)((isp), (reg), ISP_READ((isp), (reg)) | (val))
43235388Smjacob
43335388Smjacob#define	ISP_CLRBITS(isp, reg, val)	\
43435388Smjacob (*(isp)->isp_mdvec->dv_wr_reg)((isp), (reg), ISP_READ((isp), (reg)) & ~(val))
43535388Smjacob
43635388Smjacob/*
43735388Smjacob * Function Prototypes
43835388Smjacob */
43935388Smjacob
44035388Smjacob/*
44139235Sgibbs * Reset Hardware. Totally. Assumes that you'll follow this with
44239235Sgibbs * a call to isp_init.
44335388Smjacob */
44435388Smjacobvoid isp_reset __P((struct ispsoftc *));
44535388Smjacob
44635388Smjacob/*
44735388Smjacob * Initialize Hardware to known state
44835388Smjacob */
44935388Smjacobvoid isp_init __P((struct ispsoftc *));
45035388Smjacob
45135388Smjacob/*
45239235Sgibbs * Reset the ISP and call completion for any orphaned commands.
45339235Sgibbs */
45439235Sgibbsvoid isp_restart __P((struct ispsoftc *));
45539235Sgibbs
45639235Sgibbs/*
45735388Smjacob * Interrupt Service Routine
45835388Smjacob */
45935388Smjacobint isp_intr __P((void *));
46035388Smjacob
46135388Smjacob/*
46235388Smjacob * Command Entry Point
46335388Smjacob */
46439235Sgibbsint32_t ispscsicmd __P((ISP_SCSI_XFER_T *));
46535388Smjacob
46639235Sgibbs/*
46743420Smjacob * Platform Dependent to External to Internal Control Function
46839235Sgibbs *
46948484Smjacob * Assumes all locks are held and that no reentrancy issues need be dealt with.
47039235Sgibbs *
47139235Sgibbs */
47239235Sgibbstypedef enum {
47348484Smjacob	ISPCTL_RESET_BUS,		/* Reset Bus */
47448484Smjacob	ISPCTL_RESET_DEV,		/* Reset Device */
47548484Smjacob	ISPCTL_ABORT_CMD,		/* Abort Command */
47648484Smjacob	ISPCTL_UPDATE_PARAMS,		/* Update Operating Parameters */
47748484Smjacob	ISPCTL_FCLINK_TEST		/* Test FC Link Status */
47839235Sgibbs} ispctl_t;
47939235Sgibbsint isp_control __P((struct ispsoftc *, ispctl_t, void *));
48039235Sgibbs
48143420Smjacob
48239235Sgibbs/*
48343420Smjacob * Platform Dependent to Internal to External Control Function
48443420Smjacob * (each platform must provide such a function)
48543420Smjacob *
48648484Smjacob * Assumes all locks are held and that no reentrancy issues need be dealt with.
48743420Smjacob *
48843420Smjacob */
48943420Smjacob
49043420Smjacobtypedef enum {
49143793Smjacob	ISPASYNC_NEW_TGT_PARAMS,
49248484Smjacob	ISPASYNC_BUS_RESET,		/* Bus Was Reset */
49348484Smjacob	ISPASYNC_LOOP_DOWN,		/* FC Loop Down */
49448484Smjacob	ISPASYNC_LOOP_UP,		/* FC Loop Up */
49548484Smjacob	ISPASYNC_PDB_CHANGED,		/* FC Port Data Base Changed */
49648484Smjacob	ISPASYNC_CHANGE_NOTIFY,		/* FC SNS Change Notification */
49748484Smjacob	ISPASYNC_FABRIC_DEV,		/* FC New Fabric Device */
49843420Smjacob} ispasync_t;
49943420Smjacobint isp_async __P((struct ispsoftc *, ispasync_t, void *));
50043420Smjacob
50143420Smjacob/*
50239235Sgibbs * lost command routine (XXXX IN TRANSITION XXXX)
50339235Sgibbs */
50439235Sgibbsvoid isp_lostcmd __P((struct ispsoftc *, ISP_SCSI_XFER_T *));
50539235Sgibbs
50639235Sgibbs
50735388Smjacob#endif	/* _ISPVAR_H */
508