ispvar.h revision 55364
150477Speter/* $FreeBSD: head/sys/dev/isp/ispvar.h 55364 2000-01-03 22:13:40Z mjacob $ */
235388Smjacob/*
335388Smjacob * Soft Definitions for for Qlogic ISP SCSI adapters.
435388Smjacob *
548484Smjacob * Copyright (c) 1997, 1998, 1999 by Matthew Jacob
635388Smjacob * NASA/Ames Research Center
735388Smjacob * All rights reserved.
852347Smjacob *
935388Smjacob * Redistribution and use in source and binary forms, with or without
1035388Smjacob * modification, are permitted provided that the following conditions
1135388Smjacob * are met:
1235388Smjacob * 1. Redistributions of source code must retain the above copyright
1335388Smjacob *    notice immediately at the beginning of the file, without modification,
1435388Smjacob *    this list of conditions, and the following disclaimer.
1535388Smjacob * 2. Redistributions in binary form must reproduce the above copyright
1635388Smjacob *    notice, this list of conditions and the following disclaimer in the
1735388Smjacob *    documentation and/or other materials provided with the distribution.
1835388Smjacob * 3. The name of the author may not be used to endorse or promote products
1935388Smjacob *    derived from this software without specific prior written permission.
2035388Smjacob *
2135388Smjacob * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
2235388Smjacob * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2335388Smjacob * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2435388Smjacob * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
2535388Smjacob * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2635388Smjacob * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2735388Smjacob * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2835388Smjacob * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2935388Smjacob * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3035388Smjacob * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3135388Smjacob * SUCH DAMAGE.
3235388Smjacob *
3335388Smjacob */
3435388Smjacob
3535388Smjacob#ifndef	_ISPVAR_H
3635388Smjacob#define	_ISPVAR_H
3735388Smjacob
3844819Smjacob#if defined(__NetBSD__) || defined(__OpenBSD__)
3935388Smjacob#include <dev/ic/ispmbox.h>
4053487Smjacob#ifdef	ISP_TARGET_MODE
4153487Smjacob#include <dev/ic/isp_target.h>
4235388Smjacob#endif
4353487Smjacob#endif
4435388Smjacob#ifdef	__FreeBSD__
4535388Smjacob#include <dev/isp/ispmbox.h>
4653487Smjacob#ifdef	ISP_TARGET_MODE
4753487Smjacob#include <dev/isp/isp_target.h>
4835388Smjacob#endif
4953487Smjacob#endif
5035388Smjacob#ifdef	__linux__
5142131Smjacob#include "ispmbox.h"
5253487Smjacob#ifdef	ISP_TARGET_MODE
5353487Smjacob#include "isp_target.h"
5435388Smjacob#endif
5553487Smjacob#endif
5635388Smjacob
5739235Sgibbs#define	ISP_CORE_VERSION_MAJOR	1
5855364Smjacob#define	ISP_CORE_VERSION_MINOR	12
5939235Sgibbs
6035388Smjacob/*
6143420Smjacob * Vector for bus specific code to provide specific services.
6235388Smjacob */
6335388Smjacobstruct ispsoftc;
6435388Smjacobstruct ispmdvec {
6535388Smjacob	u_int16_t	(*dv_rd_reg) __P((struct ispsoftc *, int));
6635388Smjacob	void		(*dv_wr_reg) __P((struct ispsoftc *, int, u_int16_t));
6735388Smjacob	int		(*dv_mbxdma) __P((struct ispsoftc *));
6835388Smjacob	int		(*dv_dmaset) __P((struct ispsoftc *,
6953487Smjacob		ISP_SCSI_XFER_T *, ispreq_t *, u_int16_t *, u_int16_t));
7035388Smjacob	void		(*dv_dmaclr)
7135388Smjacob		__P((struct ispsoftc *, ISP_SCSI_XFER_T *, u_int32_t));
7235388Smjacob	void		(*dv_reset0) __P((struct ispsoftc *));
7335388Smjacob	void		(*dv_reset1) __P((struct ispsoftc *));
7435388Smjacob	void		(*dv_dregs) __P((struct ispsoftc *));
7535388Smjacob	const u_int16_t *dv_ispfw;	/* ptr to f/w */
7635388Smjacob	u_int16_t 	dv_fwlen;	/* length of f/w */
7735388Smjacob	u_int16_t	dv_codeorg;	/* code ORG for f/w */
7849909Smjacob	u_int32_t	dv_fwrev;	/* f/w revision */
7935388Smjacob	/*
8035388Smjacob	 * Initial values for conf1 register
8135388Smjacob	 */
8235388Smjacob	u_int16_t	dv_conf1;
8335388Smjacob	u_int16_t	dv_clock;	/* clock frequency */
8435388Smjacob};
8535388Smjacob
8635388Smjacob#define	MAX_TARGETS	16
8744819Smjacob#ifdef	ISP2100_FABRIC
8844819Smjacob#define	MAX_FC_TARG	256
8944819Smjacob#else
9035388Smjacob#define	MAX_FC_TARG	126
9144819Smjacob#endif
9235388Smjacob
9349909Smjacob#define	ISP_MAX_TARGETS(isp)	(IS_FC(isp)? MAX_FC_TARG : MAX_TARGETS)
9449909Smjacob#ifdef	ISP2100_SCCLUN
9549909Smjacob#define	_ISP_FC_LUN(isp)	65536
9649909Smjacob#else
9749909Smjacob#define	_ISP_FC_LUN(isp)	16
9849909Smjacob#endif
9949909Smjacob#define	_ISP_SCSI_LUN(isp)	\
10052347Smjacob	((ISP_FW_REVX(isp->isp_fwrev) >= ISP_FW_REV(7, 55, 0))? 32 : 8)
10149909Smjacob#define	ISP_MAX_LUNS(isp)	\
10249909Smjacob	(IS_FC(isp)? _ISP_FC_LUN(isp) : _ISP_SCSI_LUN(isp))
10349909Smjacob
10453487Smjacob
10553487Smjacob/*
10653487Smjacob * Macros to read, write ISP registers through bus specific code.
10753487Smjacob */
10853487Smjacob
10953487Smjacob#define	ISP_READ(isp, reg)	\
11053487Smjacob	(*(isp)->isp_mdvec->dv_rd_reg)((isp), (reg))
11153487Smjacob
11253487Smjacob#define	ISP_WRITE(isp, reg, val)	\
11353487Smjacob	(*(isp)->isp_mdvec->dv_wr_reg)((isp), (reg), (val))
11453487Smjacob
11553487Smjacob#define	ISP_MBOXDMASETUP(isp)	\
11653487Smjacob	(*(isp)->isp_mdvec->dv_mbxdma)((isp))
11753487Smjacob
11853487Smjacob#define	ISP_DMASETUP(isp, xs, req, iptrp, optr)	\
11953487Smjacob	(*(isp)->isp_mdvec->dv_dmaset)((isp), (xs), (req), (iptrp), (optr))
12053487Smjacob
12153487Smjacob#define	ISP_DMAFREE(isp, xs, hndl)	\
12253487Smjacob	if ((isp)->isp_mdvec->dv_dmaclr) \
12353487Smjacob	    (*(isp)->isp_mdvec->dv_dmaclr)((isp), (xs), (hndl))
12453487Smjacob
12553487Smjacob#define	ISP_RESET0(isp)	\
12653487Smjacob	if ((isp)->isp_mdvec->dv_reset0) (*(isp)->isp_mdvec->dv_reset0)((isp))
12753487Smjacob#define	ISP_RESET1(isp)	\
12853487Smjacob	if ((isp)->isp_mdvec->dv_reset1) (*(isp)->isp_mdvec->dv_reset1)((isp))
12953487Smjacob#define	ISP_DUMPREGS(isp)	\
13053487Smjacob	if ((isp)->isp_mdvec->dv_dregs) (*(isp)->isp_mdvec->dv_dregs)((isp))
13153487Smjacob
13253487Smjacob#define	ISP_SETBITS(isp, reg, val)	\
13353487Smjacob (*(isp)->isp_mdvec->dv_wr_reg)((isp), (reg), ISP_READ((isp), (reg)) | (val))
13453487Smjacob
13553487Smjacob#define	ISP_CLRBITS(isp, reg, val)	\
13653487Smjacob (*(isp)->isp_mdvec->dv_wr_reg)((isp), (reg), ISP_READ((isp), (reg)) & ~(val))
13753487Smjacob
13852347Smjacob/* this is the size of a queue entry (request and response) */
13939235Sgibbs#define	QENTRY_LEN			64
14052347Smjacob/* both request and result queue length must be a power of two */
14139235Sgibbs#define	RQUEST_QUEUE_LEN		MAXISPREQUEST
14252347Smjacob/* I've seen wierdnesses with the result queue < 64 */
14352347Smjacob#if	MAXISPREQUEST > 64
14444819Smjacob#define	RESULT_QUEUE_LEN		(MAXISPREQUEST/2)
14552347Smjacob#else
14652347Smjacob#define	RESULT_QUEUE_LEN		MAXISPREQUEST
14752347Smjacob#endif
14839235Sgibbs#define	ISP_QUEUE_ENTRY(q, idx)		((q) + ((idx) * QENTRY_LEN))
14939235Sgibbs#define	ISP_QUEUE_SIZE(n)		((n) * QENTRY_LEN)
15039235Sgibbs#define	ISP_NXT_QENTRY(idx, qlen)	(((idx) + 1) & ((qlen)-1))
15152347Smjacob#define	ISP_QAVAIL(in, out, qlen)	\
15239235Sgibbs	((in == out)? (qlen - 1) : ((in > out)? \
15352347Smjacob	((qlen - 1) - (in - out)) : (out - in - 1)))
15453487Smjacob
15553487Smjacob#define	ISP_ADD_REQUEST(isp, iptr)	\
15653487Smjacob	ISP_WRITE(isp, INMAILBOX4, iptr), isp->isp_reqidx = iptr
15753487Smjacob
15835388Smjacob/*
15946968Smjacob * SCSI Specific Host Adapter Parameters- per bus, per target
16035388Smjacob */
16135388Smjacob
16235388Smjacobtypedef struct {
16346968Smjacob	u_int		isp_gotdparms		: 1,
16452347Smjacob			isp_req_ack_active_neg	: 1,
16552347Smjacob			isp_data_line_active_neg: 1,
16635388Smjacob			isp_cmd_dma_burst_enable: 1,
16735388Smjacob			isp_data_dma_burst_enabl: 1,
16842461Smjacob			isp_fifo_threshold	: 3,
16943420Smjacob			isp_ultramode		: 1,
17035388Smjacob			isp_diffmode		: 1,
17145040Smjacob			isp_lvdmode		: 1,
17246968Smjacob						: 1,
17335388Smjacob			isp_initiator_id	: 4,
17452347Smjacob			isp_async_data_setup	: 4;
17552347Smjacob	u_int16_t	isp_selection_timeout;
17652347Smjacob	u_int16_t	isp_max_queue_depth;
17735388Smjacob	u_int8_t	isp_tag_aging;
17852347Smjacob	u_int8_t	isp_bus_reset_delay;
17952347Smjacob	u_int8_t	isp_retry_count;
18052347Smjacob	u_int8_t	isp_retry_delay;
18135388Smjacob	struct {
18246968Smjacob		u_int	dev_enable	:	1,	/* ignored */
18346968Smjacob					:	1,
18443420Smjacob			dev_update	:	1,
18543420Smjacob			dev_refresh	:	1,
18645040Smjacob			exc_throttle	:	8,
18745040Smjacob			cur_offset	:	4,
18845040Smjacob			sync_offset	:	4;
18945040Smjacob		u_int8_t	cur_period;	/* current sync period */
19045040Smjacob		u_int8_t	sync_period;	/* goal sync period */
19145040Smjacob		u_int16_t	dev_flags;	/* goal device flags */
19245040Smjacob		u_int16_t	cur_dflags;	/* current device flags */
19335388Smjacob	} isp_devparam[MAX_TARGETS];
19446968Smjacob} sdparam;
19535388Smjacob
19635388Smjacob/*
19735388Smjacob * Device Flags
19835388Smjacob */
19939235Sgibbs#define	DPARM_DISC	0x8000
20039235Sgibbs#define	DPARM_PARITY	0x4000
20139235Sgibbs#define	DPARM_WIDE	0x2000
20239235Sgibbs#define	DPARM_SYNC	0x1000
20339235Sgibbs#define	DPARM_TQING	0x0800
20439235Sgibbs#define	DPARM_ARQ	0x0400
20539235Sgibbs#define	DPARM_QFRZ	0x0200
20639235Sgibbs#define	DPARM_RENEG	0x0100
20739235Sgibbs#define	DPARM_NARROW	0x0080	/* Possibly only available with >= 7.55 fw */
20839235Sgibbs#define	DPARM_ASYNC	0x0040	/* Possibly only available with >= 7.55 fw */
20943793Smjacob#define	DPARM_DEFAULT	(0xFF00 & ~DPARM_QFRZ)
21039235Sgibbs#define	DPARM_SAFE_DFLT	(DPARM_DEFAULT & ~(DPARM_WIDE|DPARM_SYNC|DPARM_TQING))
21135388Smjacob
21239235Sgibbs
21345040Smjacob/* technically, not really correct, as they need to be rated based upon clock */
21445040Smjacob#define	ISP_40M_SYNCPARMS	0x080a
21552347Smjacob#define	ISP_20M_SYNCPARMS	0x080c
21652347Smjacob#define	ISP_10M_SYNCPARMS	0x0c19
21752347Smjacob#define	ISP_08M_SYNCPARMS	0x0c25
21852347Smjacob#define	ISP_05M_SYNCPARMS	0x0c32
21952347Smjacob#define	ISP_04M_SYNCPARMS	0x0c41
22035388Smjacob
22135388Smjacob/*
22235388Smjacob * Fibre Channel Specifics
22335388Smjacob */
22452347Smjacob#define	FL_PORT_ID		0x7e	/* FL_Port Special ID */
22552347Smjacob#define	FC_PORT_ID		0x7f	/* Fabric Controller Special ID */
22652347Smjacob#define	FC_SNS_ID		0x80	/* SNS Server Special ID */
22752347Smjacob
22835388Smjacobtypedef struct {
22952347Smjacob	u_int32_t		isp_fwoptions	: 16,
23048484Smjacob						: 7,
23148484Smjacob				loop_seen_once	: 1,
23248484Smjacob				isp_loopstate	: 3,	/* Current Loop State */
23348484Smjacob				isp_fwstate	: 3,	/* ISP F/W state */
23448484Smjacob				isp_gotdparms	: 1,
23548484Smjacob				isp_onfabric	: 1;
23639235Sgibbs	u_int8_t		isp_loopid;	/* hard loop id */
23739235Sgibbs	u_int8_t		isp_alpa;	/* ALPA */
23852347Smjacob	volatile u_int16_t	isp_lipseq;	/* LIP sequence # */
23948484Smjacob	u_int32_t		isp_portid;
24039235Sgibbs	u_int8_t		isp_execthrottle;
24152347Smjacob	u_int8_t		isp_retry_delay;
24252347Smjacob	u_int8_t		isp_retry_count;
24352347Smjacob	u_int8_t		isp_reserved;
24439235Sgibbs	u_int16_t		isp_maxalloc;
24539235Sgibbs	u_int16_t		isp_maxfrmlen;
24648484Smjacob	u_int64_t		isp_nodewwn;
24748484Smjacob	u_int64_t		isp_portwwn;
24835388Smjacob	/*
24948484Smjacob	 * Port Data Base. This is indexed by 'target', which is invariate.
25048484Smjacob	 * However, elements within can move around due to loop changes,
25148484Smjacob	 * so the actual loop ID passed to the F/W is in this structure.
25248484Smjacob	 * The first time the loop is seen up, loopid will match the index
25348484Smjacob	 * (except for fabric nodes which are above mapped above FC_SNS_ID
25448484Smjacob	 * and are completely virtual), but subsequent LIPs can cause things
25548484Smjacob	 * to move around.
25644819Smjacob	 */
25748484Smjacob	struct lportdb {
25852347Smjacob		u_int
25948484Smjacob					loopid	: 8,
26048484Smjacob						: 4,
26148484Smjacob					fabdev	: 1,
26248484Smjacob					roles	: 2,
26348484Smjacob					valid	: 1;
26452347Smjacob		u_int32_t		portid;
26548484Smjacob		u_int64_t		node_wwn;
26648484Smjacob		u_int64_t		port_wwn;
26752347Smjacob	} portdb[MAX_FC_TARG], tport[FL_PORT_ID];
26844819Smjacob
26944819Smjacob	/*
27035388Smjacob	 * Scratch DMA mapped in area to fetch Port Database stuff, etc.
27135388Smjacob	 */
27248195Smjacob	caddr_t			isp_scratch;
27335388Smjacob	u_int32_t		isp_scdma;
27435388Smjacob} fcparam;
27535388Smjacob
27648484Smjacob#define	FW_CONFIG_WAIT		0
27748484Smjacob#define	FW_WAIT_AL_PA		1
27848484Smjacob#define	FW_WAIT_LOGIN		2
27948484Smjacob#define	FW_READY		3
28048484Smjacob#define	FW_LOSS_OF_SYNC		4
28148484Smjacob#define	FW_ERROR		5
28248484Smjacob#define	FW_REINIT		6
28348484Smjacob#define	FW_NON_PART		7
28435388Smjacob
28548484Smjacob#define	LOOP_NIL		0
28648484Smjacob#define	LOOP_LIP_RCVD		1
28748484Smjacob#define	LOOP_PDB_RCVD		2
28848484Smjacob#define	LOOP_READY		7
28935388Smjacob
29042131Smjacob/*
29135388Smjacob * Soft Structure per host adapter
29235388Smjacob */
29335388Smjacobstruct ispsoftc {
29435388Smjacob	/*
29535388Smjacob	 * Platform (OS) specific data
29635388Smjacob	 */
29735388Smjacob	struct isposinfo	isp_osinfo;
29835388Smjacob
29935388Smjacob	/*
30053487Smjacob	 * Pointer to bus specific functions and data
30135388Smjacob	 */
30235388Smjacob	struct ispmdvec *	isp_mdvec;
30335388Smjacob
30435388Smjacob	/*
30553487Smjacob	 * (Mostly) nonvolatile state. Board specific parameters
30653487Smjacob	 * may contain some volatile state (e.g., current loop state).
30735388Smjacob	 */
30835388Smjacob
30953487Smjacob	void * 			isp_param;	/* type specific */
31053487Smjacob	u_int16_t		isp_fwrev[3];	/* Loaded F/W revision */
31153487Smjacob	u_int16_t		isp_romfw_rev[3]; /* PROM F/W revision */
31253487Smjacob	u_int16_t		isp_maxcmds;	/* max possible I/O cmds */
31353487Smjacob	u_int8_t		isp_type;	/* HBA Chip Type */
31453487Smjacob	u_int8_t		isp_revision;	/* HBA Chip H/W Revision */
31535388Smjacob
31653487Smjacob	u_int32_t				: 4,
31753487Smjacob				isp_touched	: 1,	/* board ever seen? */
31853487Smjacob				isp_fast_mttr	: 1,	/* fast sram */
31953487Smjacob				isp_bustype	: 1,	/* SBus or PCI */
32053487Smjacob				isp_dogactive	: 1,	/* watchdog running */
32153487Smjacob				isp_dblev	: 8,	/* debug level */
32253487Smjacob				isp_clock	: 8,	/* input clock */
32353487Smjacob				isp_confopts	: 8;	/* config options */
32439235Sgibbs
32535388Smjacob	/*
32639235Sgibbs	 * Volatile state
32735388Smjacob	 */
32835388Smjacob
32953487Smjacob	volatile u_int32_t	:	9,
33039235Sgibbs		isp_state	:	3,
33146968Smjacob		isp_sendmarker	:	2,	/* send a marker entry */
33246968Smjacob		isp_update	:	2,	/* update parameters */
33352347Smjacob		isp_nactive	:	16;	/* how many commands active */
33439235Sgibbs
33552347Smjacob	volatile u_int16_t	isp_reqodx;	/* index of last ISP pickup */
33652347Smjacob	volatile u_int16_t	isp_reqidx;	/* index of next request */
33752347Smjacob	volatile u_int16_t	isp_residx;	/* index of next result */
33852347Smjacob	volatile u_int16_t	isp_lasthdls;	/* last handle seed */
33935388Smjacob
34035388Smjacob	/*
34153487Smjacob	 * Active commands are stored here, indexed by handle functions.
34235388Smjacob	 */
34352347Smjacob	ISP_SCSI_XFER_T **isp_xflist;
34435388Smjacob
34535388Smjacob	/*
34652347Smjacob	 * request/result queue pointers and dma handles for them.
34735388Smjacob	 */
34848195Smjacob	caddr_t			isp_rquest;
34948195Smjacob	caddr_t			isp_result;
35035388Smjacob	u_int32_t		isp_rquest_dma;
35135388Smjacob	u_int32_t		isp_result_dma;
35235388Smjacob};
35335388Smjacob
35449909Smjacob#define	SDPARAM(isp)	((sdparam *) (isp)->isp_param)
35549909Smjacob#define	FCPARAM(isp)	((fcparam *) (isp)->isp_param)
35649909Smjacob
35735388Smjacob/*
35835388Smjacob * ISP States
35935388Smjacob */
36035388Smjacob#define	ISP_NILSTATE	0
36135388Smjacob#define	ISP_RESETSTATE	1
36235388Smjacob#define	ISP_INITSTATE	2
36335388Smjacob#define	ISP_RUNSTATE	3
36435388Smjacob
36535388Smjacob/*
36635388Smjacob * ISP Configuration Options
36735388Smjacob */
36835388Smjacob#define	ISP_CFG_NORELOAD	0x80	/* don't download f/w */
36943793Smjacob#define	ISP_CFG_NONVRAM		0x40	/* ignore NVRAM */
37053487Smjacob#define	ISP_CFG_FULL_DUPLEX	0x01	/* Full Duplex (Fibre Channel only) */
37153487Smjacob#define	ISP_CFG_OWNWWN		0x02	/* override NVRAM wwn */
37235388Smjacob
37345282Smjacob#define	ISP_FW_REV(maj, min, mic)	((maj << 24) | (min << 16) | mic)
37446968Smjacob#define	ISP_FW_REVX(xp)	((xp[0]<<24) | (xp[1] << 16) | xp[2])
37539235Sgibbs
37635388Smjacob/*
37739235Sgibbs * Bus (implementation) types
37835388Smjacob */
37939235Sgibbs#define	ISP_BT_PCI		0	/* PCI Implementations */
38039235Sgibbs#define	ISP_BT_SBUS		1	/* SBus Implementations */
38139235Sgibbs
38239235Sgibbs/*
38339235Sgibbs * Chip Types
38439235Sgibbs */
38535388Smjacob#define	ISP_HA_SCSI		0xf
38639235Sgibbs#define	ISP_HA_SCSI_UNKNOWN	0x1
38739235Sgibbs#define	ISP_HA_SCSI_1020	0x2
38839235Sgibbs#define	ISP_HA_SCSI_1020A	0x3
38939235Sgibbs#define	ISP_HA_SCSI_1040	0x4
39039235Sgibbs#define	ISP_HA_SCSI_1040A	0x5
39139235Sgibbs#define	ISP_HA_SCSI_1040B	0x6
39245282Smjacob#define	ISP_HA_SCSI_1040C	0x7
39354671Smjacob#define	ISP_HA_SCSI_1240	0x8
39454671Smjacob#define	ISP_HA_SCSI_1080	0x9
39554671Smjacob#define	ISP_HA_SCSI_1280	0xa
39635388Smjacob#define	ISP_HA_FC		0xf0
39735388Smjacob#define	ISP_HA_FC_2100		0x10
39848484Smjacob#define	ISP_HA_FC_2200		0x20
39935388Smjacob
40044819Smjacob#define	IS_SCSI(isp)	(isp->isp_type & ISP_HA_SCSI)
40154671Smjacob#define	IS_1240(isp)	(isp->isp_type == ISP_HA_SCSI_1240)
40244819Smjacob#define	IS_1080(isp)	(isp->isp_type == ISP_HA_SCSI_1080)
40354671Smjacob#define	IS_1280(isp)	(isp->isp_type == ISP_HA_SCSI_1280)
40454671Smjacob#define	IS_12X0(isp)	\
40554671Smjacob	(isp->isp_type == ISP_HA_SCSI_1240 || isp->isp_type == ISP_HA_SCSI_1280)
40654671Smjacob#define	IS_DUALBUS(isp)	IS_12X0(isp)
40754671Smjacob#define	IS_ULTRA2(isp)	\
40854671Smjacob	(isp->isp_type == ISP_HA_SCSI_1080 || isp->isp_type == ISP_HA_SCSI_1280)
40944819Smjacob#define	IS_FC(isp)	(isp->isp_type & ISP_HA_FC)
41044819Smjacob
41135388Smjacob/*
41235388Smjacob * Function Prototypes
41335388Smjacob */
41435388Smjacob
41535388Smjacob/*
41639235Sgibbs * Reset Hardware. Totally. Assumes that you'll follow this with
41739235Sgibbs * a call to isp_init.
41835388Smjacob */
41935388Smjacobvoid isp_reset __P((struct ispsoftc *));
42035388Smjacob
42135388Smjacob/*
42235388Smjacob * Initialize Hardware to known state
42335388Smjacob */
42435388Smjacobvoid isp_init __P((struct ispsoftc *));
42535388Smjacob
42635388Smjacob/*
42739235Sgibbs * Reset the ISP and call completion for any orphaned commands.
42839235Sgibbs */
42939235Sgibbsvoid isp_restart __P((struct ispsoftc *));
43039235Sgibbs
43139235Sgibbs/*
43235388Smjacob * Interrupt Service Routine
43335388Smjacob */
43435388Smjacobint isp_intr __P((void *));
43535388Smjacob
43635388Smjacob/*
43735388Smjacob * Command Entry Point
43835388Smjacob */
43939235Sgibbsint32_t ispscsicmd __P((ISP_SCSI_XFER_T *));
44035388Smjacob
44139235Sgibbs/*
44243420Smjacob * Platform Dependent to External to Internal Control Function
44339235Sgibbs *
44448484Smjacob * Assumes all locks are held and that no reentrancy issues need be dealt with.
44539235Sgibbs *
44639235Sgibbs */
44739235Sgibbstypedef enum {
44848484Smjacob	ISPCTL_RESET_BUS,		/* Reset Bus */
44948484Smjacob	ISPCTL_RESET_DEV,		/* Reset Device */
45048484Smjacob	ISPCTL_ABORT_CMD,		/* Abort Command */
45148484Smjacob	ISPCTL_UPDATE_PARAMS,		/* Update Operating Parameters */
45255364Smjacob	ISPCTL_FCLINK_TEST,		/* Test FC Link Status */
45355364Smjacob	ISPCTL_PDB_SYNC,		/* Synchronize Port Database */
45455364Smjacob	ISPCTL_TOGGLE_TMODE		/* toggle target mode */
45539235Sgibbs} ispctl_t;
45639235Sgibbsint isp_control __P((struct ispsoftc *, ispctl_t, void *));
45739235Sgibbs
45843420Smjacob
45939235Sgibbs/*
46043420Smjacob * Platform Dependent to Internal to External Control Function
46143420Smjacob * (each platform must provide such a function)
46243420Smjacob *
46348484Smjacob * Assumes all locks are held and that no reentrancy issues need be dealt with.
46443420Smjacob *
46543420Smjacob */
46643420Smjacob
46743420Smjacobtypedef enum {
46843793Smjacob	ISPASYNC_NEW_TGT_PARAMS,
46948484Smjacob	ISPASYNC_BUS_RESET,		/* Bus Was Reset */
47048484Smjacob	ISPASYNC_LOOP_DOWN,		/* FC Loop Down */
47148484Smjacob	ISPASYNC_LOOP_UP,		/* FC Loop Up */
47248484Smjacob	ISPASYNC_PDB_CHANGED,		/* FC Port Data Base Changed */
47348484Smjacob	ISPASYNC_CHANGE_NOTIFY,		/* FC SNS Change Notification */
47448484Smjacob	ISPASYNC_FABRIC_DEV,		/* FC New Fabric Device */
47555364Smjacob	ISPASYNC_TARGET_MESSAGE,	/* target message */
47655364Smjacob	ISPASYNC_TARGET_EVENT,		/* target asynchronous event */
47755364Smjacob	ISPASYNC_TARGET_ACTION		/* other target command action */
47843420Smjacob} ispasync_t;
47943420Smjacobint isp_async __P((struct ispsoftc *, ispasync_t, void *));
48043420Smjacob
48143420Smjacob/*
48239235Sgibbs * lost command routine (XXXX IN TRANSITION XXXX)
48339235Sgibbs */
48439235Sgibbsvoid isp_lostcmd __P((struct ispsoftc *, ISP_SCSI_XFER_T *));
48539235Sgibbs
48635388Smjacob#endif	/* _ISPVAR_H */
487