ispvar.h revision 297991
150477Speter/* $FreeBSD: head/sys/dev/isp/ispvar.h 297991 2016-04-14 20:49:01Z mav $ */
2139749Simp/*-
3196008Smjacob *  Copyright (c) 1997-2009 by Matthew Jacob
4167403Smjacob *  All rights reserved.
5196008Smjacob *
6167403Smjacob *  Redistribution and use in source and binary forms, with or without
7167403Smjacob *  modification, are permitted provided that the following conditions
8167403Smjacob *  are met:
9196008Smjacob *
10167403Smjacob *  1. Redistributions of source code must retain the above copyright
11167403Smjacob *     notice, this list of conditions and the following disclaimer.
12167403Smjacob *  2. Redistributions in binary form must reproduce the above copyright
13167403Smjacob *     notice, this list of conditions and the following disclaimer in the
14167403Smjacob *     documentation and/or other materials provided with the distribution.
15196008Smjacob *
16167403Smjacob *  THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17167403Smjacob *  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18167403Smjacob *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19167403Smjacob *  ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
20167403Smjacob *  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21167403Smjacob *  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22167403Smjacob *  OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23167403Smjacob *  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24167403Smjacob *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25167403Smjacob *  OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26167403Smjacob *  SUCH DAMAGE.
27196008Smjacob *
28167403Smjacob */
29167403Smjacob/*
3035388Smjacob * Soft Definitions for for Qlogic ISP SCSI adapters.
3135388Smjacob */
3235388Smjacob
3335388Smjacob#ifndef	_ISPVAR_H
3435388Smjacob#define	_ISPVAR_H
3535388Smjacob
3644819Smjacob#if defined(__NetBSD__) || defined(__OpenBSD__)
37163899Smjacob#include <dev/ic/isp_stds.h>
3835388Smjacob#include <dev/ic/ispmbox.h>
3935388Smjacob#endif
4035388Smjacob#ifdef	__FreeBSD__
41163899Smjacob#include <dev/isp/isp_stds.h>
4235388Smjacob#include <dev/isp/ispmbox.h>
4335388Smjacob#endif
4435388Smjacob#ifdef	__linux__
45163899Smjacob#include "isp_stds.h"
4642131Smjacob#include "ispmbox.h"
4735388Smjacob#endif
48155704Smjacob#ifdef	__svr4__
49163899Smjacob#include "isp_stds.h"
50155704Smjacob#include "ispmbox.h"
5153487Smjacob#endif
5235388Smjacob
53203444Smjacob#define	ISP_CORE_VERSION_MAJOR	7
54163899Smjacob#define	ISP_CORE_VERSION_MINOR	0
5539235Sgibbs
5635388Smjacob/*
5743420Smjacob * Vector for bus specific code to provide specific services.
5835388Smjacob */
59155704Smjacobtypedef struct ispsoftc ispsoftc_t;
6035388Smjacobstruct ispmdvec {
61289812Smav	int		(*dv_rd_isr) (ispsoftc_t *, uint16_t *, uint16_t *, uint16_t *);
62163899Smjacob	uint32_t	(*dv_rd_reg) (ispsoftc_t *, int);
63163899Smjacob	void		(*dv_wr_reg) (ispsoftc_t *, int, uint32_t);
64155704Smjacob	int		(*dv_mbxdma) (ispsoftc_t *);
65196008Smjacob	int		(*dv_dmaset) (ispsoftc_t *, XS_T *, void *);
66163899Smjacob	void		(*dv_dmaclr) (ispsoftc_t *, XS_T *, uint32_t);
67155704Smjacob	void		(*dv_reset0) (ispsoftc_t *);
68155704Smjacob	void		(*dv_reset1) (ispsoftc_t *);
69155704Smjacob	void		(*dv_dregs) (ispsoftc_t *, const char *);
70167821Smjacob	const void *	dv_ispfw;	/* ptr to f/w */
71155704Smjacob	uint16_t	dv_conf1;
72155704Smjacob	uint16_t	dv_clock;	/* clock frequency */
7335388Smjacob};
7435388Smjacob
7564087Smjacob/*
7664087Smjacob * Overall parameters
7764087Smjacob */
7882689Smjacob#define	MAX_TARGETS		16
79196008Smjacob#ifndef	MAX_FC_TARG
80292765Smav#define	MAX_FC_TARG		1024
81196008Smjacob#endif
8249909Smjacob#define	ISP_MAX_TARGETS(isp)	(IS_FC(isp)? MAX_FC_TARG : MAX_TARGETS)
8361772Smjacob#define	ISP_MAX_LUNS(isp)	(isp)->isp_maxluns
8449909Smjacob
8582689Smjacob/*
8664087Smjacob * Macros to access ISP registers through bus specific layers-
8764087Smjacob * mostly wrappers to vector through the mdvec structure.
8853487Smjacob */
89289812Smav#define	ISP_READ_ISR(isp, isrp, semap, info)	\
90289812Smav	(*(isp)->isp_mdvec->dv_rd_isr)(isp, isrp, semap, info)
9153487Smjacob
9253487Smjacob#define	ISP_READ(isp, reg)	\
9353487Smjacob	(*(isp)->isp_mdvec->dv_rd_reg)((isp), (reg))
9453487Smjacob
9553487Smjacob#define	ISP_WRITE(isp, reg, val)	\
9653487Smjacob	(*(isp)->isp_mdvec->dv_wr_reg)((isp), (reg), (val))
9753487Smjacob
9853487Smjacob#define	ISP_MBOXDMASETUP(isp)	\
9953487Smjacob	(*(isp)->isp_mdvec->dv_mbxdma)((isp))
10053487Smjacob
101196008Smjacob#define	ISP_DMASETUP(isp, xs, req)	\
102196008Smjacob	(*(isp)->isp_mdvec->dv_dmaset)((isp), (xs), (req))
10353487Smjacob
104155704Smjacob#define	ISP_DMAFREE(isp, xs, hndl)		\
105155704Smjacob	if ((isp)->isp_mdvec->dv_dmaclr)	\
10653487Smjacob	    (*(isp)->isp_mdvec->dv_dmaclr)((isp), (xs), (hndl))
10753487Smjacob
10853487Smjacob#define	ISP_RESET0(isp)	\
10953487Smjacob	if ((isp)->isp_mdvec->dv_reset0) (*(isp)->isp_mdvec->dv_reset0)((isp))
11053487Smjacob#define	ISP_RESET1(isp)	\
11153487Smjacob	if ((isp)->isp_mdvec->dv_reset1) (*(isp)->isp_mdvec->dv_reset1)((isp))
11264087Smjacob#define	ISP_DUMPREGS(isp, m)	\
11364087Smjacob	if ((isp)->isp_mdvec->dv_dregs) (*(isp)->isp_mdvec->dv_dregs)((isp),(m))
11453487Smjacob
11553487Smjacob#define	ISP_SETBITS(isp, reg, val)	\
11653487Smjacob (*(isp)->isp_mdvec->dv_wr_reg)((isp), (reg), ISP_READ((isp), (reg)) | (val))
11753487Smjacob
11853487Smjacob#define	ISP_CLRBITS(isp, reg, val)	\
11953487Smjacob (*(isp)->isp_mdvec->dv_wr_reg)((isp), (reg), ISP_READ((isp), (reg)) & ~(val))
12053487Smjacob
12164087Smjacob/*
12264087Smjacob * The MEMORYBARRIER macro is defined per platform (to provide synchronization
12364087Smjacob * on Request and Response Queues, Scratch DMA areas, and Registers)
12464087Smjacob *
12564087Smjacob * Defined Memory Barrier Synchronization Types
12664087Smjacob */
12764087Smjacob#define	SYNC_REQUEST	0	/* request queue synchronization */
12864087Smjacob#define	SYNC_RESULT	1	/* result queue synchronization */
12964087Smjacob#define	SYNC_SFORDEV	2	/* scratch, sync for ISP */
13064087Smjacob#define	SYNC_SFORCPU	3	/* scratch, sync for CPU */
13164087Smjacob#define	SYNC_REG	4	/* for registers */
132163899Smjacob#define	SYNC_ATIOQ	5	/* atio result queue (24xx) */
133297858Smav#define	SYNC_IFORDEV	6	/* synchrounous IOCB, sync for ISP */
134297858Smav#define	SYNC_IFORCPU	7	/* synchrounous IOCB, sync for CPU */
13564087Smjacob
13664087Smjacob/*
13764087Smjacob * Request/Response Queue defines and macros.
13864087Smjacob * The maximum is defined per platform (and can be based on board type).
13964087Smjacob */
14064087Smjacob/* This is the size of a queue entry (request and response) */
14139235Sgibbs#define	QENTRY_LEN			64
14264087Smjacob/* Both request and result queue length must be a power of two */
14364087Smjacob#define	RQUEST_QUEUE_LEN(x)		MAXISPREQUEST(x)
14493706Smjacob#ifdef	ISP_TARGET_MODE
14593706Smjacob#define	RESULT_QUEUE_LEN(x)		MAXISPREQUEST(x)
14693706Smjacob#else
14764087Smjacob#define	RESULT_QUEUE_LEN(x)		\
14864087Smjacob	(((MAXISPREQUEST(x) >> 2) < 64)? 64 : MAXISPREQUEST(x) >> 2)
14993706Smjacob#endif
150155704Smjacob#define	ISP_QUEUE_ENTRY(q, idx)		(((uint8_t *)q) + ((idx) * QENTRY_LEN))
15139235Sgibbs#define	ISP_QUEUE_SIZE(n)		((n) * QENTRY_LEN)
15239235Sgibbs#define	ISP_NXT_QENTRY(idx, qlen)	(((idx) + 1) & ((qlen)-1))
15365140Smjacob#define	ISP_QFREE(in, out, qlen)	\
15439235Sgibbs	((in == out)? (qlen - 1) : ((in > out)? \
15552347Smjacob	((qlen - 1) - (in - out)) : (out - in - 1)))
15665140Smjacob#define	ISP_QAVAIL(isp)	\
15765140Smjacob	ISP_QFREE(isp->isp_reqidx, isp->isp_reqodx, RQUEST_QUEUE_LEN(isp))
15853487Smjacob
159218691Smarius#define	ISP_ADD_REQUEST(isp, nxti)						\
160218691Smarius	MEMORYBARRIER(isp, SYNC_REQUEST, isp->isp_reqidx, QENTRY_LEN, -1);	\
161218691Smarius	ISP_WRITE(isp, isp->isp_rqstinrp, nxti);				\
16287635Smjacob	isp->isp_reqidx = nxti
16353487Smjacob
164196008Smjacob#define	ISP_SYNC_REQUEST(isp)								\
165218691Smarius	MEMORYBARRIER(isp, SYNC_REQUEST, isp->isp_reqidx, QENTRY_LEN, -1);		\
166196008Smjacob	isp->isp_reqidx = ISP_NXT_QENTRY(isp->isp_reqidx, RQUEST_QUEUE_LEN(isp));	\
167196008Smjacob	ISP_WRITE(isp, isp->isp_rqstinrp, isp->isp_reqidx)
168196008Smjacob
16935388Smjacob/*
17046968Smjacob * SCSI Specific Host Adapter Parameters- per bus, per target
17135388Smjacob */
17235388Smjacobtypedef struct {
173196008Smjacob	uint32_t 				: 8,
174196008Smjacob			update			: 1,
175196008Smjacob			sendmarker		: 1,
17652347Smjacob			isp_req_ack_active_neg	: 1,
17752347Smjacob			isp_data_line_active_neg: 1,
17835388Smjacob			isp_cmd_dma_burst_enable: 1,
17935388Smjacob			isp_data_dma_burst_enabl: 1,
18042461Smjacob			isp_fifo_threshold	: 3,
181163899Smjacob			isp_ptisp		: 1,
18243420Smjacob			isp_ultramode		: 1,
18335388Smjacob			isp_diffmode		: 1,
18445040Smjacob			isp_lvdmode		: 1,
18565140Smjacob			isp_fast_mttr		: 1,	/* fast sram */
18635388Smjacob			isp_initiator_id	: 4,
18752347Smjacob			isp_async_data_setup	: 4;
188155704Smjacob	uint16_t	isp_selection_timeout;
189155704Smjacob	uint16_t	isp_max_queue_depth;
190155704Smjacob	uint8_t		isp_tag_aging;
191155704Smjacob	uint8_t		isp_bus_reset_delay;
192155704Smjacob	uint8_t		isp_retry_count;
193155704Smjacob	uint8_t		isp_retry_delay;
19435388Smjacob	struct {
195196008Smjacob		uint32_t
19680582Smjacob			exc_throttle	:	8,
19746968Smjacob					:	1,
19880582Smjacob			dev_enable	:	1,	/* ignored */
19943420Smjacob			dev_update	:	1,
20043420Smjacob			dev_refresh	:	1,
20180582Smjacob			actv_offset	:	4,
20280582Smjacob			goal_offset	:	4,
20380582Smjacob			nvrm_offset	:	4;
204155704Smjacob		uint8_t		actv_period;	/* current sync period */
205155704Smjacob		uint8_t		goal_period;	/* goal sync period */
206155704Smjacob		uint8_t		nvrm_period;	/* nvram sync period */
207155704Smjacob		uint16_t	actv_flags;	/* current device flags */
208155704Smjacob		uint16_t	goal_flags;	/* goal device flags */
209155704Smjacob		uint16_t	nvrm_flags;	/* nvram device flags */
21035388Smjacob	} isp_devparam[MAX_TARGETS];
21146968Smjacob} sdparam;
21235388Smjacob
21335388Smjacob/*
21435388Smjacob * Device Flags
21535388Smjacob */
21639235Sgibbs#define	DPARM_DISC	0x8000
21739235Sgibbs#define	DPARM_PARITY	0x4000
21839235Sgibbs#define	DPARM_WIDE	0x2000
21939235Sgibbs#define	DPARM_SYNC	0x1000
22039235Sgibbs#define	DPARM_TQING	0x0800
22139235Sgibbs#define	DPARM_ARQ	0x0400
22239235Sgibbs#define	DPARM_QFRZ	0x0200
22339235Sgibbs#define	DPARM_RENEG	0x0100
22465140Smjacob#define	DPARM_NARROW	0x0080
22565140Smjacob#define	DPARM_ASYNC	0x0040
22665140Smjacob#define	DPARM_PPR	0x0020
22743793Smjacob#define	DPARM_DEFAULT	(0xFF00 & ~DPARM_QFRZ)
22839235Sgibbs#define	DPARM_SAFE_DFLT	(DPARM_DEFAULT & ~(DPARM_WIDE|DPARM_SYNC|DPARM_TQING))
22935388Smjacob
23045040Smjacob/* technically, not really correct, as they need to be rated based upon clock */
23165140Smjacob#define	ISP_80M_SYNCPARMS	0x0c09
23265140Smjacob#define	ISP_40M_SYNCPARMS	0x0c0a
23365140Smjacob#define	ISP_20M_SYNCPARMS	0x0c0c
23465140Smjacob#define	ISP_20M_SYNCPARMS_1040	0x080c
23552347Smjacob#define	ISP_10M_SYNCPARMS	0x0c19
23652347Smjacob#define	ISP_08M_SYNCPARMS	0x0c25
23752347Smjacob#define	ISP_05M_SYNCPARMS	0x0c32
23852347Smjacob#define	ISP_04M_SYNCPARMS	0x0c41
23935388Smjacob
24035388Smjacob/*
24135388Smjacob * Fibre Channel Specifics
24235388Smjacob */
243164909Smjacob/* These are for non-2K Login Firmware cards */
244163899Smjacob#define	FL_ID			0x7e	/* FL_Port Special ID */
245163899Smjacob#define	SNS_ID			0x80	/* SNS Server Special ID */
246163899Smjacob#define	NPH_MAX			0xfe
24752347Smjacob
248164909Smjacob/* These are for 2K Login Firmware cards */
249163899Smjacob#define	NPH_RESERVED		0x7F0	/* begin of reserved N-port handles */
250163899Smjacob#define	NPH_MGT_ID		0x7FA	/* Management Server Special ID */
251163899Smjacob#define	NPH_SNS_ID		0x7FC	/* SNS Server Special ID */
252196008Smjacob#define	NPH_FABRIC_CTLR		0x7FD	/* Fabric Controller (0xFFFFFD) */
253196008Smjacob#define	NPH_FL_ID		0x7FE	/* F Port Special ID (0xFFFFFE) */
254289890Smav#define	NPH_IP_BCST		0x7FF	/* IP Broadcast Special ID (0xFFFFFF) */
255164909Smjacob#define	NPH_MAX_2K		0x800
25693837Smjacob
257163899Smjacob/*
258164909Smjacob * "Unassigned" handle to be used internally
259164909Smjacob */
260164909Smjacob#define	NIL_HANDLE		0xffff
261164909Smjacob
262164909Smjacob/*
263163899Smjacob * Limit for devices on an arbitrated loop.
264163899Smjacob */
265163899Smjacob#define	LOCAL_LOOP_LIM		126
266163899Smjacob
267163899Smjacob/*
268196008Smjacob * Limit for (2K login) N-port handle amounts
269196008Smjacob */
270196008Smjacob#define	MAX_NPORT_HANDLE	2048
271196008Smjacob
272196008Smjacob/*
273196008Smjacob * Special Constants
274196008Smjacob */
275196008Smjacob#define	INI_NONE    		((uint64_t) 0)
276196008Smjacob#define	ISP_NOCHAN		0xff
277196008Smjacob
278196008Smjacob/*
279163899Smjacob * Special Port IDs
280163899Smjacob */
281163899Smjacob#define	MANAGEMENT_PORT_ID	0xFFFFFA
282163899Smjacob#define	SNS_PORT_ID		0xFFFFFC
283163899Smjacob#define	FABRIC_PORT_ID		0xFFFFFE
284196008Smjacob#define	PORT_ANY		0xFFFFFF
285196008Smjacob#define	PORT_NONE		0
286291144Smav#define	VALID_PORT(port)	(port != PORT_NONE && port != PORT_ANY)
287196008Smjacob#define	DOMAIN_CONTROLLER_BASE	0xFFFC00
288196008Smjacob#define	DOMAIN_CONTROLLER_END	0xFFFCFF
289163899Smjacob
290203444Smjacob/*
291203444Smjacob * Command Handles
292203444Smjacob *
293203444Smjacob * Most QLogic initiator or target have 32 bit handles associated with them.
294203444Smjacob * We want to have a quick way to index back and forth between a local SCSI
295203444Smjacob * command context and what the firmware is passing back to us. We also
296203444Smjacob * want to avoid working on stale information. This structure handles both
297203444Smjacob * at the expense of some local memory.
298203444Smjacob *
299203444Smjacob * The handle is architected thusly:
300203444Smjacob *
301203444Smjacob *	0 means "free handle"
302203444Smjacob *	bits  0..12 index commands
303203444Smjacob *	bits 13..15 bits index usage
304203444Smjacob *	bits 16..31 contain a rolling sequence
305203444Smjacob *
306203444Smjacob *
307203444Smjacob */
308203444Smjacobtypedef struct {
309203444Smjacob	void *		cmd;	/* associated command context */
310203444Smjacob	uint32_t	handle;	/* handle associated with this command */
311203444Smjacob} isp_hdl_t;
312203444Smjacob#define	ISP_HANDLE_FREE		0x00000000
313203444Smjacob#define	ISP_HANDLE_CMD_MASK	0x00001fff
314203444Smjacob#define	ISP_HANDLE_USAGE_MASK	0x0000e000
315203444Smjacob#define	ISP_HANDLE_USAGE_SHIFT	13
316203444Smjacob#define	ISP_H2HT(hdl)	((hdl & ISP_HANDLE_USAGE_MASK) >> ISP_HANDLE_USAGE_SHIFT)
317203444Smjacob#	define	ISP_HANDLE_NONE		0
318203444Smjacob#	define	ISP_HANDLE_INITIATOR	1
319203444Smjacob#	define	ISP_HANDLE_TARGET	2
320292739Smav#	define	ISP_HANDLE_CTRL		3
321203444Smjacob#define	ISP_HANDLE_SEQ_MASK	0xffff0000
322203444Smjacob#define	ISP_HANDLE_SEQ_SHIFT	16
323203444Smjacob#define	ISP_H2SEQ(hdl)	((hdl & ISP_HANDLE_SEQ_MASK) >> ISP_HANDLE_SEQ_SHIFT)
324203444Smjacob#define	ISP_VALID_HANDLE(c, hdl)	\
325292725Smav	((ISP_H2HT(hdl) == ISP_HANDLE_INITIATOR || \
326292739Smav	  ISP_H2HT(hdl) == ISP_HANDLE_TARGET || \
327292739Smav	  ISP_H2HT(hdl) == ISP_HANDLE_CTRL) && \
328292725Smav	 ((hdl) & ISP_HANDLE_CMD_MASK) < (c)->isp_maxcmds && \
329292725Smav	 (hdl) == ((c)->isp_xflist[(hdl) & ISP_HANDLE_CMD_MASK].handle))
330203444Smjacob#define	ISP_BAD_HANDLE_INDEX	0xffffffff
331163899Smjacob
332203444Smjacob
333163899Smjacob/*
334163899Smjacob * FC Port Database entry.
335163899Smjacob *
336163899Smjacob * It has a handle that the f/w uses to address commands to a device.
337163899Smjacob * This handle's value may be assigned by the firmware (e.g., for local loop
338163899Smjacob * devices) or by the driver (e.g., for fabric devices).
339163899Smjacob *
340163899Smjacob * It has a state. If the state if VALID, that means that we've logged into
341285154Smav * the device.
342163899Smjacob *
343163899Smjacob * Local loop devices the firmware automatically performs PLOGI on for us
344163899Smjacob * (which is why that handle is imposed upon us). Fabric devices we assign
345163899Smjacob * a handle to and perform the PLOGI on.
346163899Smjacob *
347163899Smjacob * When a PORT DATABASE CHANGED asynchronous event occurs, we mark all VALID
348163899Smjacob * entries as PROBATIONAL. This allows us, if policy says to, just keep track
349163899Smjacob * of devices whose handles change but are otherwise the same device (and
350163899Smjacob * thus keep 'target' constant).
351163899Smjacob *
352163899Smjacob * In any case, we search all possible local loop handles. For each one that
353163899Smjacob * has a port database entity returned, we search for any PROBATIONAL entry
354163899Smjacob * that matches it and update as appropriate. Otherwise, as a new entry, we
355163899Smjacob * find room for it in the Port Database. We *try* and use the handle as the
356163899Smjacob * index to put it into the Database, but that's just an optimization. We mark
357163899Smjacob * the entry VALID and make sure that the target index is updated and correct.
358163899Smjacob *
359163899Smjacob * When we get done searching the local loop, we then search similarily for
360163899Smjacob * a list of devices we've gotten from the fabric name controller (if we're
361163899Smjacob * on a fabric). VALID marking is also done similarily.
362163899Smjacob *
363163899Smjacob * When all of this is done, we can march through the database and clean up
364163899Smjacob * any entry that is still PROBATIONAL (these represent devices which have
365163899Smjacob * departed). Then we're done and can resume normal operations.
366163899Smjacob *
367163899Smjacob * Negative invariants that we try and test for are:
368163899Smjacob *
369163899Smjacob *  + There can never be two non-NIL entries with the same { Port, Node } WWN
370163899Smjacob *    duples.
371163899Smjacob *
372163899Smjacob *  + There can never be two non-NIL entries with the same handle.
373163899Smjacob */
37435388Smjacobtypedef struct {
375164272Smjacob	/*
376164272Smjacob	 * This is the handle that the firmware needs in order for us to
377164272Smjacob	 * send commands to the device. For pre-24XX cards, this would be
378164272Smjacob	 * the 'loopid'.
379164272Smjacob	 */
380163899Smjacob	uint16_t	handle;
381196008Smjacob
382164272Smjacob	/*
383164272Smjacob	 * A device is 'autologin' if the firmware automatically logs into
384164272Smjacob	 * it (re-logins as needed). Basically, local private loop devices.
385164272Smjacob	 *
386238869Smjacob	 * PRLI word 3 parameters contains role as well as other things.
387238869Smjacob	 *
388196008Smjacob	 * The state is the current state of this entry.
389164272Smjacob	 *
390285459Smav	 * The is_target is the current state of target on this port.
391285459Smav	 *
392285459Smav	 * The is_initiator is the current state of initiator on this port.
393285459Smav	 *
394196008Smjacob	 * Portid is obvious, as are node && port WWNs. The new_role and
395164272Smjacob	 * new_portid is for when we are pending a change.
396164272Smjacob	 */
397238869Smjacob	uint16_t	prli_word3;		/* PRLI parameters */
398238869Smjacob	uint16_t	new_prli_word3;		/* Incoming new PRLI parameters */
399291080Smav	uint16_t			: 11,
400163899Smjacob			autologin	: 1,	/* F/W does PLOGI/PLOGO */
401291080Smav			probational	: 1,
402163899Smjacob			state		: 3;
403285459Smav	uint32_t			: 6,
404285459Smav			is_target	: 1,
405285459Smav			is_initiator	: 1,
406163899Smjacob			portid		: 24;
407196008Smjacob	uint32_t
408285459Smav					: 8,
409163899Smjacob			new_portid	: 24;
410163899Smjacob	uint64_t	node_wwn;
411163899Smjacob	uint64_t	port_wwn;
412208119Smjacob	uint32_t	gone_timer;
413163899Smjacob} fcportdb_t;
414163899Smjacob
415291080Smav#define	FC_PORTDB_STATE_NIL		0	/* Empty DB slot */
416291080Smav#define	FC_PORTDB_STATE_DEAD		1	/* Was valid, but no more. */
417291080Smav#define	FC_PORTDB_STATE_CHANGED		2	/* Was valid, but changed. */
418291080Smav#define	FC_PORTDB_STATE_NEW		3	/* Logged in, not announced. */
419291080Smav#define	FC_PORTDB_STATE_ZOMBIE		4	/* Invalid, but announced. */
420291080Smav#define	FC_PORTDB_STATE_VALID		5	/* Valid */
421163899Smjacob
422285459Smav#define	FC_PORTDB_TGT(isp, bus, pdb)		(int)(lp - FCPARAM(isp, bus)->portdb)
423285459Smav
424163899Smjacob/*
425163899Smjacob * FC card specific information
426196008Smjacob *
427196008Smjacob * This structure is replicated across multiple channels for multi-id
428196008Smjacob * capapble chipsets, with some entities different on a per-channel basis.
429163899Smjacob */
430196008Smjacob
431163899Smjacobtypedef struct {
432289219Smav	int			isp_gbspeed;		/* Connection speed */
433289219Smav	int			isp_linkstate;		/* Link state */
434289219Smav	int			isp_fwstate;		/* ISP F/W state */
435289219Smav	int			isp_loopstate;		/* Loop State */
436289219Smav	int			isp_topo;		/* Connection Type */
437289219Smav
438291365Smav	uint32_t				: 4,
439238869Smjacob				fctape_enabled	: 1,
440196008Smjacob				sendmarker	: 1,
441196008Smjacob				role		: 2,
442154704Smjacob				isp_portid	: 24;	/* S_ID */
443196008Smjacob
444155704Smjacob	uint16_t		isp_fwoptions;
445160080Smjacob	uint16_t		isp_xfwoptions;
446160080Smjacob	uint16_t		isp_zfwoptions;
447196008Smjacob	uint16_t		isp_loopid;		/* hard loop id */
448196008Smjacob	uint16_t		isp_sns_hdl;		/* N-port handle for SNS */
449196008Smjacob	uint16_t		isp_lasthdl;		/* only valid for channel 0 */
450196008Smjacob	uint16_t		isp_maxalloc;
451237210Smjacob	uint16_t		isp_fabric_params;
452297915Smav	uint16_t		isp_login_hdl;		/* Logging in handle */
453155704Smjacob	uint8_t			isp_retry_delay;
454155704Smjacob	uint8_t			isp_retry_count;
455196008Smjacob
456196008Smjacob	/*
457196008Smjacob	 * Current active WWNN/WWPN
458196008Smjacob	 */
459196008Smjacob	uint64_t		isp_wwnn;
460196008Smjacob	uint64_t		isp_wwpn;
461196008Smjacob
462196008Smjacob	/*
463196008Smjacob	 * NVRAM WWNN/WWPN
464196008Smjacob	 */
465166120Smjacob	uint64_t		isp_wwnn_nvram;
466166120Smjacob	uint64_t		isp_wwpn_nvram;
467164272Smjacob
468164272Smjacob	/*
469164272Smjacob	 * Our Port Data Base
470164272Smjacob	 */
471163899Smjacob	fcportdb_t		portdb[MAX_FC_TARG];
472164272Smjacob
47335388Smjacob	/*
47435388Smjacob	 * Scratch DMA mapped in area to fetch Port Database stuff, etc.
47535388Smjacob	 */
476155704Smjacob	void *			isp_scratch;
477155704Smjacob	XS_DMA_ADDR_T		isp_scdma;
478292765Smav
479292765Smav	uint8_t			isp_scanscratch[ISP_FC_SCRLEN];
48035388Smjacob} fcparam;
48135388Smjacob
48248484Smjacob#define	FW_CONFIG_WAIT		0
483290993Smav#define	FW_WAIT_LINK		1
48448484Smjacob#define	FW_WAIT_LOGIN		2
48548484Smjacob#define	FW_READY		3
48648484Smjacob#define	FW_LOSS_OF_SYNC		4
48748484Smjacob#define	FW_ERROR		5
48848484Smjacob#define	FW_REINIT		6
48948484Smjacob#define	FW_NON_PART		7
49035388Smjacob
49148484Smjacob#define	LOOP_NIL		0
492291365Smav#define	LOOP_HAVE_LINK		1
493297991Smav#define	LOOP_HAVE_ADDR		2
494297991Smav#define	LOOP_TESTING_LINK	3
495297991Smav#define	LOOP_LTEST_DONE		4
496297991Smav#define	LOOP_SCANNING_LOOP	5
497297991Smav#define	LOOP_LSCAN_DONE		6
498297991Smav#define	LOOP_SCANNING_FABRIC	7
499297991Smav#define	LOOP_FSCAN_DONE		8
500297991Smav#define	LOOP_SYNCING_PDB	9
501297991Smav#define	LOOP_READY		10
50235388Smjacob
50359454Smjacob#define	TOPO_NL_PORT		0
50459454Smjacob#define	TOPO_FL_PORT		1
50559454Smjacob#define	TOPO_N_PORT		2
50659454Smjacob#define	TOPO_F_PORT		3
50759454Smjacob#define	TOPO_PTP_STUB		4
50859454Smjacob
509291080Smav#define TOPO_IS_FABRIC(x)	((x) == TOPO_FL_PORT || (x) == TOPO_F_PORT)
510291080Smav
51142131Smjacob/*
51235388Smjacob * Soft Structure per host adapter
51335388Smjacob */
514155704Smjacobstruct ispsoftc {
51535388Smjacob	/*
51635388Smjacob	 * Platform (OS) specific data
51735388Smjacob	 */
51835388Smjacob	struct isposinfo	isp_osinfo;
51935388Smjacob
52035388Smjacob	/*
52153487Smjacob	 * Pointer to bus specific functions and data
52235388Smjacob	 */
52335388Smjacob	struct ispmdvec *	isp_mdvec;
52435388Smjacob
52535388Smjacob	/*
52653487Smjacob	 * (Mostly) nonvolatile state. Board specific parameters
52753487Smjacob	 * may contain some volatile state (e.g., current loop state).
52835388Smjacob	 */
52935388Smjacob
53053487Smjacob	void * 			isp_param;	/* type specific */
531237210Smjacob	uint64_t		isp_fwattr;	/* firmware attributes */
532155704Smjacob	uint16_t		isp_fwrev[3];	/* Loaded F/W revision */
533155704Smjacob	uint16_t		isp_maxcmds;	/* max possible I/O cmds */
534155704Smjacob	uint8_t			isp_type;	/* HBA Chip Type */
535155704Smjacob	uint8_t			isp_revision;	/* HBA Chip H/W Revision */
536237210Smjacob	uint16_t		isp_nchan;	/* number of channels */
537155704Smjacob	uint32_t		isp_maxluns;	/* maximum luns supported */
53835388Smjacob
539155704Smjacob	uint32_t		isp_clock	: 8,	/* input clock */
54090224Smjacob						: 4,
541163899Smjacob				isp_port	: 1,	/* 23XX/24XX only */
54287635Smjacob				isp_open	: 1,	/* opened (ioctl) */
54353487Smjacob				isp_bustype	: 1,	/* SBus or PCI */
54465140Smjacob				isp_loaded_fw	: 1,	/* loaded firmware */
545196008Smjacob				isp_dblev	: 16;	/* debug log mask */
54671079Smjacob
54771079Smjacob
548196008Smjacob	uint32_t		isp_confopts;	/* config options */
549196008Smjacob
550163899Smjacob	uint32_t		isp_rqstinrp;	/* register for REQINP */
551163899Smjacob	uint32_t		isp_rqstoutrp;	/* register for REQOUTP */
552163899Smjacob	uint32_t		isp_respinrp;	/* register for RESINP */
553163899Smjacob	uint32_t		isp_respoutrp;	/* register for RESOUTP */
55482689Smjacob
55569522Smjacob	/*
55669522Smjacob	 * Instrumentation
55769522Smjacob	 */
558155704Smjacob	uint64_t		isp_intcnt;		/* total int count */
559155704Smjacob	uint64_t		isp_intbogus;		/* spurious int count */
560155704Smjacob	uint64_t		isp_intmboxc;		/* mbox completions */
561155704Smjacob	uint64_t		isp_intoasync;		/* other async */
562155704Smjacob	uint64_t		isp_rsltccmplt;		/* CMDs on result q */
563155704Smjacob	uint64_t		isp_fphccmplt;		/* CMDs via fastpost */
564155704Smjacob	uint16_t		isp_rscchiwater;
565155704Smjacob	uint16_t		isp_fpcchiwater;
566196008Smjacob	NANOTIME_T		isp_init_time;		/* time were last initialized */
56739235Sgibbs
56835388Smjacob	/*
56939235Sgibbs	 * Volatile state
57035388Smjacob	 */
57135388Smjacob
572160080Smjacob	volatile uint32_t	:	8,
573196008Smjacob				:	2,
574196008Smjacob		isp_dead	:	1,
575196008Smjacob				:	1,
57687635Smjacob		isp_mboxbsy	:	1,	/* mailbox command active */
57739235Sgibbs		isp_state	:	3,
57852347Smjacob		isp_nactive	:	16;	/* how many commands active */
579203444Smjacob	volatile mbreg_t	isp_curmbx;	/* currently active mailbox command */
580163899Smjacob	volatile uint32_t	isp_reqodx;	/* index of last ISP pickup */
581163899Smjacob	volatile uint32_t	isp_reqidx;	/* index of next request */
582256705Smav	volatile uint32_t	isp_residx;	/* index of last ISP write */
583163899Smjacob	volatile uint32_t	isp_resodx;	/* index of next result */
584256705Smav	volatile uint32_t	isp_atioodx;	/* index of next ATIO */
585163899Smjacob	volatile uint32_t	isp_obits;	/* mailbox command output */
586196008Smjacob	volatile uint32_t	isp_serno;	/* rolling serial number */
587237210Smjacob	volatile uint16_t	isp_mboxtmp[MAX_MAILBOX];
588155704Smjacob	volatile uint16_t	isp_lastmbxcmd;	/* last mbox command sent */
589155704Smjacob	volatile uint16_t	isp_mbxwrk0;
590155704Smjacob	volatile uint16_t	isp_mbxwrk1;
591155704Smjacob	volatile uint16_t	isp_mbxwrk2;
592160080Smjacob	volatile uint16_t	isp_mbxwrk8;
593203444Smjacob	volatile uint16_t	isp_seqno;	/* running sequence number */
59490224Smjacob	void *			isp_mbxworkp;
59535388Smjacob
59635388Smjacob	/*
59753487Smjacob	 * Active commands are stored here, indexed by handle functions.
59835388Smjacob	 */
599203444Smjacob	isp_hdl_t		*isp_xflist;
600203444Smjacob	isp_hdl_t		*isp_xffree;
60135388Smjacob
60235388Smjacob	/*
603297858Smav	 * DMA mapped in area for synchronous IOCB requests.
604297858Smav	 */
605297858Smav	void *			isp_iocb;
606297858Smav	XS_DMA_ADDR_T		isp_iocb_dma;
607297858Smav
608297858Smav	/*
609120018Smjacob	 * request/result queue pointers and DMA handles for them.
61035388Smjacob	 */
611155704Smjacob	void *			isp_rquest;
612155704Smjacob	void *			isp_result;
613155704Smjacob	XS_DMA_ADDR_T		isp_rquest_dma;
614155704Smjacob	XS_DMA_ADDR_T		isp_result_dma;
615163899Smjacob#ifdef	ISP_TARGET_MODE
616163899Smjacob	/* for 24XX only */
617163899Smjacob	void *			isp_atioq;
618163899Smjacob	XS_DMA_ADDR_T		isp_atioq_dma;
619163899Smjacob#endif
620155704Smjacob};
62135388Smjacob
622196008Smjacob#define	SDPARAM(isp, chan)	(&((sdparam *)(isp)->isp_param)[(chan)])
623196008Smjacob#define	FCPARAM(isp, chan)	(&((fcparam *)(isp)->isp_param)[(chan)])
62449909Smjacob
625196008Smjacob#define	ISP_SET_SENDMARKER(isp, chan, val)	\
626196008Smjacob    if (IS_FC(isp)) {				\
627196008Smjacob	FCPARAM(isp, chan)->sendmarker = val;	\
628196008Smjacob    } else {					\
629196008Smjacob	SDPARAM(isp, chan)->sendmarker = val;	\
630196008Smjacob    }
631196008Smjacob
632196008Smjacob#define	ISP_TST_SENDMARKER(isp, chan)		\
633196008Smjacob    (IS_FC(isp)?				\
634196008Smjacob	FCPARAM(isp, chan)->sendmarker != 0 :	\
635196008Smjacob	SDPARAM(isp, chan)->sendmarker != 0)
636196008Smjacob
63735388Smjacob/*
63864087Smjacob * ISP Driver Run States
63935388Smjacob */
64035388Smjacob#define	ISP_NILSTATE	0
641160080Smjacob#define	ISP_CRASHED	1
642160080Smjacob#define	ISP_RESETSTATE	2
643160080Smjacob#define	ISP_INITSTATE	3
644160080Smjacob#define	ISP_RUNSTATE	4
64535388Smjacob
64635388Smjacob/*
647237537Smjacob * ISP Runtime Configuration Options
64835388Smjacob */
64953487Smjacob#define	ISP_CFG_FULL_DUPLEX	0x01	/* Full Duplex (Fibre Channel only) */
650297912Smav#define	ISP_CFG_PORT_PREF	0x0e	/* Mask for Port Prefs (all FC except 2100) */
651297912Smav#define	ISP_CFG_PORT_DEF	0x00	/* prefer connection type from NVRAM */
652297912Smav#define	ISP_CFG_LPORT_ONLY	0x02	/* insist on {N/F}L-Port connection */
653297912Smav#define	ISP_CFG_NPORT_ONLY	0x04	/* insist on {N/F}-Port connection */
654297912Smav#define	ISP_CFG_LPORT		0x06	/* prefer {N/F}L-Port connection */
655297912Smav#define	ISP_CFG_NPORT		0x08	/* prefer {N/F}-Port connection */
656291654Smav#define	ISP_CFG_1GB		0x10	/* force 1GB connection (23XX only) */
657291654Smav#define	ISP_CFG_2GB		0x20	/* force 2GB connection (23XX only) */
658238869Smjacob#define	ISP_CFG_NORELOAD	0x80	/* don't download f/w */
659238869Smjacob#define	ISP_CFG_NONVRAM		0x40	/* ignore NVRAM */
660238869Smjacob#define	ISP_CFG_NOFCTAPE	0x100	/* disable FC-Tape */
661238869Smjacob#define	ISP_CFG_FCTAPE		0x200	/* enable FC-Tape */
66298281Smjacob#define	ISP_CFG_OWNFSZ		0x400	/* override NVRAM frame size */
66398281Smjacob#define	ISP_CFG_OWNLOOPID	0x800	/* override NVRAM loopid */
66498281Smjacob#define	ISP_CFG_OWNEXCTHROTTLE	0x1000	/* override NVRAM execution throttle */
665291654Smav#define	ISP_CFG_4GB		0x2000	/* force 4GB connection (24XX only) */
666291654Smav#define	ISP_CFG_8GB		0x4000	/* force 8GB connection (25XX only) */
667291654Smav#define	ISP_CFG_16GB		0x8000	/* force 16GB connection (82XX only) */
66835388Smjacob
66964087Smjacob/*
670196008Smjacob * For each channel, the outer layers should know what role that channel
671196008Smjacob * will take: ISP_ROLE_NONE, ISP_ROLE_INITIATOR, ISP_ROLE_TARGET,
672196008Smjacob * ISP_ROLE_BOTH.
67371079Smjacob *
67471079Smjacob * If you set ISP_ROLE_NONE, the cards will be reset, new firmware loaded,
67571079Smjacob * NVRAM read, and defaults set, but any further initialization (e.g.
67671079Smjacob * INITIALIZE CONTROL BLOCK commands for 2X00 cards) won't be done.
67771079Smjacob *
67871079Smjacob * If INITIATOR MODE isn't set, attempts to run commands will be stopped
679196008Smjacob * at isp_start and completed with the equivalent of SELECTION TIMEOUT.
68071079Smjacob *
68171079Smjacob * If TARGET MODE is set, it doesn't mean that the rest of target mode support
68271079Smjacob * needs to be enabled, or will even work. What happens with the 2X00 cards
68371079Smjacob * here is that if you have enabled it with TARGET MODE as part of the ICB
68471079Smjacob * options, but you haven't given the f/w any ram resources for ATIOs or
68571079Smjacob * Immediate Notifies, the f/w just handles what it can and you never see
68671079Smjacob * anything. Basically, it sends a single byte of data (the first byte,
68771079Smjacob * which you can set as part of the INITIALIZE CONTROL BLOCK command) for
68871079Smjacob * INQUIRY, and sends back QUEUE FULL status for any other command.
68979235Smjacob *
69071079Smjacob */
69171079Smjacob#define	ISP_ROLE_NONE		0x0
692125544Smjacob#define	ISP_ROLE_TARGET		0x1
693125544Smjacob#define	ISP_ROLE_INITIATOR	0x2
69471079Smjacob#define	ISP_ROLE_BOTH		(ISP_ROLE_TARGET|ISP_ROLE_INITIATOR)
69571079Smjacob#define	ISP_ROLE_EITHER		ISP_ROLE_BOTH
69671079Smjacob#ifndef	ISP_DEFAULT_ROLES
697236427Smjacob/*
698236427Smjacob * Counterintuitively, we prefer to default to role 'none'
699236427Smjacob * if we are enable target mode support. This gives us the
700236427Smjacob * maximum flexibility as to which port will do what.
701236427Smjacob */
702236427Smjacob#ifdef	ISP_TARGET_MODE
703236427Smjacob#define	ISP_DEFAULT_ROLES	ISP_ROLE_NONE
704236427Smjacob#else
70571079Smjacob#define	ISP_DEFAULT_ROLES	ISP_ROLE_INITIATOR
70671079Smjacob#endif
707236427Smjacob#endif
70871079Smjacob
70971079Smjacob
71071079Smjacob/*
71164087Smjacob * Firmware related defines
71264087Smjacob */
71371079Smjacob#define	ISP_CODE_ORG			0x1000	/* default f/w code start */
71482689Smjacob#define	ISP_CODE_ORG_2300		0x0800	/* ..except for 2300s */
715163899Smjacob#define	ISP_CODE_ORG_2400		0x100000 /* ..and 2400s */
71645282Smjacob#define	ISP_FW_REV(maj, min, mic)	((maj << 24) | (min << 16) | mic)
71782841Smjacob#define	ISP_FW_MAJOR(code)		((code >> 24) & 0xff)
71882841Smjacob#define	ISP_FW_MINOR(code)		((code >> 16) & 0xff)
71982841Smjacob#define	ISP_FW_MICRO(code)		((code >>  8) & 0xff)
72071079Smjacob#define	ISP_FW_REVX(xp)			((xp[0]<<24) | (xp[1] << 16) | xp[2])
72182841Smjacob#define	ISP_FW_MAJORX(xp)		(xp[0])
72282841Smjacob#define	ISP_FW_MINORX(xp)		(xp[1])
72382841Smjacob#define	ISP_FW_MICROX(xp)		(xp[2])
724102012Smjacob#define	ISP_FW_NEWER_THAN(i, major, minor, micro)		\
725102012Smjacob (ISP_FW_REVX((i)->isp_fwrev) > ISP_FW_REV(major, minor, micro))
726163899Smjacob#define	ISP_FW_OLDER_THAN(i, major, minor, micro)		\
727163899Smjacob (ISP_FW_REVX((i)->isp_fwrev) < ISP_FW_REV(major, minor, micro))
72839235Sgibbs
72935388Smjacob/*
73039235Sgibbs * Bus (implementation) types
73135388Smjacob */
73239235Sgibbs#define	ISP_BT_PCI		0	/* PCI Implementations */
73339235Sgibbs#define	ISP_BT_SBUS		1	/* SBus Implementations */
73439235Sgibbs
73539235Sgibbs/*
73687635Smjacob * If we have not otherwise defined SBus support away make sure
73787635Smjacob * it is defined here such that the code is included as default
73887635Smjacob */
73987635Smjacob#ifndef	ISP_SBUS_SUPPORTED
74087635Smjacob#define	ISP_SBUS_SUPPORTED	1
74187635Smjacob#endif
74287635Smjacob
74387635Smjacob/*
74439235Sgibbs * Chip Types
74539235Sgibbs */
74635388Smjacob#define	ISP_HA_SCSI		0xf
74739235Sgibbs#define	ISP_HA_SCSI_UNKNOWN	0x1
74839235Sgibbs#define	ISP_HA_SCSI_1020	0x2
74939235Sgibbs#define	ISP_HA_SCSI_1020A	0x3
75039235Sgibbs#define	ISP_HA_SCSI_1040	0x4
75139235Sgibbs#define	ISP_HA_SCSI_1040A	0x5
75239235Sgibbs#define	ISP_HA_SCSI_1040B	0x6
75345282Smjacob#define	ISP_HA_SCSI_1040C	0x7
75454671Smjacob#define	ISP_HA_SCSI_1240	0x8
75554671Smjacob#define	ISP_HA_SCSI_1080	0x9
75654671Smjacob#define	ISP_HA_SCSI_1280	0xa
757104916Smjacob#define	ISP_HA_SCSI_10160	0xb
758104916Smjacob#define	ISP_HA_SCSI_12160	0xc
75935388Smjacob#define	ISP_HA_FC		0xf0
76035388Smjacob#define	ISP_HA_FC_2100		0x10
76148484Smjacob#define	ISP_HA_FC_2200		0x20
76277365Smjacob#define	ISP_HA_FC_2300		0x30
76388855Smjacob#define	ISP_HA_FC_2312		0x40
764154704Smjacob#define	ISP_HA_FC_2322		0x50
765154704Smjacob#define	ISP_HA_FC_2400		0x60
766196008Smjacob#define	ISP_HA_FC_2500		0x70
767291654Smav#define	ISP_HA_FC_2600		0x80
76835388Smjacob
76944819Smjacob#define	IS_SCSI(isp)	(isp->isp_type & ISP_HA_SCSI)
770196008Smjacob#define	IS_1020(isp)	(isp->isp_type < ISP_HA_SCSI_1240)
77154671Smjacob#define	IS_1240(isp)	(isp->isp_type == ISP_HA_SCSI_1240)
77244819Smjacob#define	IS_1080(isp)	(isp->isp_type == ISP_HA_SCSI_1080)
77354671Smjacob#define	IS_1280(isp)	(isp->isp_type == ISP_HA_SCSI_1280)
774104916Smjacob#define	IS_10160(isp)	(isp->isp_type == ISP_HA_SCSI_10160)
77557145Smjacob#define	IS_12160(isp)	(isp->isp_type == ISP_HA_SCSI_12160)
77657145Smjacob
77757145Smjacob#define	IS_12X0(isp)	(IS_1240(isp) || IS_1280(isp))
778104916Smjacob#define	IS_1X160(isp)	(IS_10160(isp) || IS_12160(isp))
77957145Smjacob#define	IS_DUALBUS(isp)	(IS_12X0(isp) || IS_12160(isp))
780104916Smjacob#define	IS_ULTRA2(isp)	(IS_1080(isp) || IS_1280(isp) || IS_1X160(isp))
781104916Smjacob#define	IS_ULTRA3(isp)	(IS_1X160(isp))
78257145Smjacob
78377365Smjacob#define	IS_FC(isp)	((isp)->isp_type & ISP_HA_FC)
78477365Smjacob#define	IS_2100(isp)	((isp)->isp_type == ISP_HA_FC_2100)
78577365Smjacob#define	IS_2200(isp)	((isp)->isp_type == ISP_HA_FC_2200)
786163899Smjacob#define	IS_23XX(isp)	((isp)->isp_type >= ISP_HA_FC_2300 && \
787163899Smjacob				(isp)->isp_type < ISP_HA_FC_2400)
78888855Smjacob#define	IS_2300(isp)	((isp)->isp_type == ISP_HA_FC_2300)
78988855Smjacob#define	IS_2312(isp)	((isp)->isp_type == ISP_HA_FC_2312)
790154704Smjacob#define	IS_2322(isp)	((isp)->isp_type == ISP_HA_FC_2322)
791154704Smjacob#define	IS_24XX(isp)	((isp)->isp_type >= ISP_HA_FC_2400)
792196008Smjacob#define	IS_25XX(isp)	((isp)->isp_type >= ISP_HA_FC_2500)
793291654Smav#define	IS_26XX(isp)	((isp)->isp_type >= ISP_HA_FC_2600)
79444819Smjacob
79564087Smjacob/*
796155704Smjacob * DMA related macros
79764087Smjacob */
798163899Smjacob#define	DMA_WD3(x)	(((uint16_t)(((uint64_t)x) >> 48)) & 0xffff)
799163899Smjacob#define	DMA_WD2(x)	(((uint16_t)(((uint64_t)x) >> 32)) & 0xffff)
800163899Smjacob#define	DMA_WD1(x)	((uint16_t)((x) >> 16) & 0xffff)
801163899Smjacob#define	DMA_WD0(x)	((uint16_t)((x) & 0xffff))
80257145Smjacob
803155704Smjacob#define	DMA_LO32(x)	((uint32_t) (x))
804155704Smjacob#define	DMA_HI32(x)	((uint32_t)(((uint64_t)x) >> 32))
805155704Smjacob
80635388Smjacob/*
80764087Smjacob * Core System Function Prototypes
80835388Smjacob */
80935388Smjacob
81035388Smjacob/*
811196008Smjacob * Reset Hardware. Totally. Assumes that you'll follow this with a call to isp_init.
81235388Smjacob */
813196008Smjacobvoid isp_reset(ispsoftc_t *, int);
81435388Smjacob
81535388Smjacob/*
81635388Smjacob * Initialize Hardware to known state
81735388Smjacob */
818155704Smjacobvoid isp_init(ispsoftc_t *);
81935388Smjacob
82035388Smjacob/*
82139235Sgibbs * Reset the ISP and call completion for any orphaned commands.
82239235Sgibbs */
823285459Smavint isp_reinit(ispsoftc_t *, int);
82439235Sgibbs
82539235Sgibbs/*
82682689Smjacob * Internal Interrupt Service Routine
82782689Smjacob *
82882689Smjacob * The outer layers do the spade work to get the appropriate status register,
82982689Smjacob * semaphore register and first mailbox register (if appropriate). This also
83082689Smjacob * means that most spurious/bogus interrupts not for us can be filtered first.
83135388Smjacob */
832289812Smavvoid isp_intr(ispsoftc_t *, uint16_t, uint16_t, uint16_t);
83335388Smjacob
83482689Smjacob
83535388Smjacob/*
83664087Smjacob * Command Entry Point- Platform Dependent layers call into this
83735388Smjacob */
83874229Smjacobint isp_start(XS_T *);
839155704Smjacob
84064087Smjacob/* these values are what isp_start returns */
84164087Smjacob#define	CMD_COMPLETE	101	/* command completed */
84264087Smjacob#define	CMD_EAGAIN	102	/* busy- maybe retry later */
84364087Smjacob#define	CMD_QUEUED	103	/* command has been queued for execution */
84464087Smjacob#define	CMD_RQLATER 	104	/* requeue this command later */
84535388Smjacob
84639235Sgibbs/*
84764087Smjacob * Command Completion Point- Core layers call out from this with completed cmds
84864087Smjacob */
84974229Smjacobvoid isp_done(XS_T *);
85064087Smjacob
85164087Smjacob/*
85243420Smjacob * Platform Dependent to External to Internal Control Function
85339235Sgibbs *
85472355Smjacob * Assumes locks are held on entry. You should note that with many of
855196008Smjacob * these commands locks may be released while this function is called.
85639235Sgibbs *
857196008Smjacob * ... ISPCTL_RESET_BUS, int channel);
858196008Smjacob *        Reset BUS on this channel
859196008Smjacob * ... ISPCTL_RESET_DEV, int channel, int target);
860196008Smjacob *        Reset Device on this channel at this target.
861196008Smjacob * ... ISPCTL_ABORT_CMD, XS_T *xs);
862196008Smjacob *        Abort active transaction described by xs.
863196008Smjacob * ... IPCTL_UPDATE_PARAMS);
864196008Smjacob *        Update any operating parameters (speed, etc.)
865196008Smjacob * ... ISPCTL_FCLINK_TEST, int channel);
866196008Smjacob *        Test FC link status on this channel
867290993Smav * ... ISPCTL_SCAN_LOOP, int channel);
868290993Smav *        Scan local loop on this channel
869196008Smjacob * ... ISPCTL_SCAN_FABRIC, int channel);
870196008Smjacob *        Scan fabric on this channel
871196008Smjacob * ... ISPCTL_PDB_SYNC, int channel);
872196008Smjacob *        Synchronize port database on this channel
873196008Smjacob * ... ISPCTL_SEND_LIP, int channel);
874196008Smjacob *        Send a LIP on this channel
875196008Smjacob * ... ISPCTL_GET_NAMES, int channel, int np, uint64_t *wwnn, uint64_t *wwpn)
876196008Smjacob *        Get a WWNN/WWPN for this N-port handle on this channel
877196008Smjacob * ... ISPCTL_RUN_MBOXCMD, mbreg_t *mbp)
878196008Smjacob *        Run this mailbox command
879196008Smjacob * ... ISPCTL_GET_PDB, int channel, int nphandle, isp_pdb_t *pdb)
880196008Smjacob *        Get PDB on this channel for this N-port handle
881196008Smjacob * ... ISPCTL_PLOGX, isp_plcmd_t *)
882196008Smjacob *        Performa a port login/logout
883285146Smav * ... ISPCTL_CHANGE_ROLE, int channel, int role);
884285146Smav *        Change role of specified channel
88572355Smjacob *
88672355Smjacob * ISPCTL_PDB_SYNC is somewhat misnamed. It actually is the final step, in
887290993Smav * order, of ISPCTL_FCLINK_TEST, ISPCTL_SCAN_LOOP, and ISPCTL_SCAN_FABRIC.
88872355Smjacob * The main purpose of ISPCTL_PDB_SYNC is to complete management of logging
88972355Smjacob * and logging out of fabric devices (if one is on a fabric) and then marking
89072355Smjacob * the 'loop state' as being ready to now be used for sending commands to
891290993Smav * devices.
89239235Sgibbs */
89339235Sgibbstypedef enum {
894196008Smjacob	ISPCTL_RESET_BUS,
895196008Smjacob	ISPCTL_RESET_DEV,
896196008Smjacob	ISPCTL_ABORT_CMD,
897196008Smjacob	ISPCTL_UPDATE_PARAMS,
898196008Smjacob	ISPCTL_FCLINK_TEST,
899196008Smjacob	ISPCTL_SCAN_FABRIC,
900196008Smjacob	ISPCTL_SCAN_LOOP,
901196008Smjacob	ISPCTL_PDB_SYNC,
902196008Smjacob	ISPCTL_SEND_LIP,
903196008Smjacob	ISPCTL_GET_NAMES,
904196008Smjacob	ISPCTL_RUN_MBOXCMD,
905196008Smjacob	ISPCTL_GET_PDB,
906285146Smav	ISPCTL_PLOGX,
907285146Smav	ISPCTL_CHANGE_ROLE
90839235Sgibbs} ispctl_t;
909196008Smjacobint isp_control(ispsoftc_t *, ispctl_t, ...);
91039235Sgibbs
91139235Sgibbs/*
91243420Smjacob * Platform Dependent to Internal to External Control Function
91343420Smjacob */
91443420Smjacob
91543420Smjacobtypedef enum {
916196008Smjacob	ISPASYNC_NEW_TGT_PARAMS,	/* SPI New Target Parameters */
917196008Smjacob	ISPASYNC_BUS_RESET,		/* All Bus Was Reset */
91848484Smjacob	ISPASYNC_LOOP_DOWN,		/* FC Loop Down */
91948484Smjacob	ISPASYNC_LOOP_UP,		/* FC Loop Up */
920196008Smjacob	ISPASYNC_LIP,			/* FC LIP Received */
921196008Smjacob	ISPASYNC_LOOP_RESET,		/* FC Loop Reset Received */
92272355Smjacob	ISPASYNC_CHANGE_NOTIFY,		/* FC Change Notification */
923196008Smjacob	ISPASYNC_DEV_ARRIVED,		/* FC Device Arrived */
924196008Smjacob	ISPASYNC_DEV_CHANGED,		/* FC Device Changed */
925196008Smjacob	ISPASYNC_DEV_STAYED,		/* FC Device Stayed */
926196008Smjacob	ISPASYNC_DEV_GONE,		/* FC Device Departure */
927196008Smjacob	ISPASYNC_TARGET_NOTIFY,		/* All target async notification */
928238869Smjacob	ISPASYNC_TARGET_NOTIFY_ACK,	/* All target notify ack required */
929196008Smjacob	ISPASYNC_TARGET_ACTION,		/* All target action requested */
930196008Smjacob	ISPASYNC_FW_CRASH,		/* All Firmware has crashed */
931196008Smjacob	ISPASYNC_FW_RESTARTED		/* All Firmware has been restarted */
93243420Smjacob} ispasync_t;
933196008Smjacobvoid isp_async(ispsoftc_t *, ispasync_t, ...);
93443420Smjacob
935196008Smjacob#define	ISPASYNC_CHANGE_PDB	0
936196008Smjacob#define	ISPASYNC_CHANGE_SNS	1
937196008Smjacob#define	ISPASYNC_CHANGE_OTHER	2
93872355Smjacob
93943420Smjacob/*
940224856Smjacob * Platform Independent Error Prinout
941224856Smjacob */
942224856Smjacobvoid isp_prt_endcmd(ispsoftc_t *, XS_T *);
943224856Smjacob
944224856Smjacob/*
94564087Smjacob * Platform Dependent Error and Debug Printout
946146073Smjacob *
947205698Smjacob * Two required functions for each platform must be provided:
948146073Smjacob *
949155704Smjacob *    void isp_prt(ispsoftc_t *, int level, const char *, ...)
950205698Smjacob *    void isp_xs_prt(ispsoftc_t *, XS_T *, int level, const char *, ...)
951146073Smjacob *
952146073Smjacob * but due to compiler differences on different platforms this won't be
953205698Smjacob * formally defined here. Instead, they go in each platform definition file.
95439235Sgibbs */
95570490Smjacob
95664087Smjacob#define	ISP_LOGALL	0x0	/* log always */
95764087Smjacob#define	ISP_LOGCONFIG	0x1	/* log configuration messages */
95864087Smjacob#define	ISP_LOGINFO	0x2	/* log informational messages */
95964087Smjacob#define	ISP_LOGWARN	0x4	/* log warning messages */
96064087Smjacob#define	ISP_LOGERR	0x8	/* log error messages */
96164087Smjacob#define	ISP_LOGDEBUG0	0x10	/* log simple debug messages */
96264087Smjacob#define	ISP_LOGDEBUG1	0x20	/* log intermediate debug messages */
96364087Smjacob#define	ISP_LOGDEBUG2	0x40	/* log most debug messages */
96479235Smjacob#define	ISP_LOGDEBUG3	0x80	/* log high frequency debug messages */
965238869Smjacob#define	ISP_LOG_SANCFG	0x100	/* log SAN configuration */
966205698Smjacob#define	ISP_LOG_CWARN	0x200	/* log SCSI command "warnings" (e.g., check conditions) */
967238869Smjacob#define	ISP_LOG_WARN1	0x400	/* log WARNS we might be interested at some time */
968196008Smjacob#define	ISP_LOGTINFO	0x1000	/* log informational messages (target mode) */
969196008Smjacob#define	ISP_LOGTDEBUG0	0x2000	/* log simple debug messages (target mode) */
970196008Smjacob#define	ISP_LOGTDEBUG1	0x4000	/* log intermediate debug messages (target) */
971196008Smjacob#define	ISP_LOGTDEBUG2	0x8000	/* log all debug messages (target) */
97239235Sgibbs
97364087Smjacob/*
97464087Smjacob * Each Platform provides it's own isposinfo substructure of the ispsoftc
97564087Smjacob * defined above.
97664087Smjacob *
97764087Smjacob * Each platform must also provide the following macros/defines:
97864087Smjacob *
97964087Smjacob *
980196008Smjacob *	ISP_FC_SCRLEN				FC scratch area DMA length
98164087Smjacob *
982196008Smjacob *	ISP_MEMZERO(dst, src)			platform zeroing function
983196008Smjacob *	ISP_MEMCPY(dst, src, count)		platform copying function
984196008Smjacob *	ISP_SNPRINTF(buf, bufsize, fmt, ...)	snprintf
985196008Smjacob *	ISP_DELAY(usecs)			microsecond spindelay function
986196008Smjacob *	ISP_SLEEP(isp, usecs)			microsecond sleep function
98764087Smjacob *
988196008Smjacob *	ISP_INLINE				___inline or not- depending on how
989196008Smjacob *						good your debugger is
990219098Smjacob *	ISP_MIN					shorthand for ((a) < (b))? (a) : (b)
991196008Smjacob *
99264087Smjacob *	NANOTIME_T				nanosecond time type
99364087Smjacob *
99464087Smjacob *	GET_NANOTIME(NANOTIME_T *)		get current nanotime.
99564087Smjacob *
996155704Smjacob *	GET_NANOSEC(NANOTIME_T *)		get uint64_t from NANOTIME_T
99764087Smjacob *
99864087Smjacob *	NANOTIME_SUB(NANOTIME_T *, NANOTIME_T *)
99964087Smjacob *						subtract two NANOTIME_T values
100064087Smjacob *
1001196008Smjacob *	MAXISPREQUEST(ispsoftc_t *)		maximum request queue size
100264087Smjacob *						for this particular board type
100364087Smjacob *
1004218691Smarius *	MEMORYBARRIER(ispsoftc_t *, barrier_type, offset, size, chan)
100564087Smjacob *
100664087Smjacob *		Function/Macro the provides memory synchronization on
100764087Smjacob *		various objects so that the ISP's and the system's view
100864087Smjacob *		of the same object is consistent.
100964087Smjacob *
1010155704Smjacob *	MBOX_ACQUIRE(ispsoftc_t *)		acquire lock on mailbox regs
1011163899Smjacob *	MBOX_WAIT_COMPLETE(ispsoftc_t *, mbreg_t *) wait for cmd to be done
1012155704Smjacob *	MBOX_NOTIFY_COMPLETE(ispsoftc_t *)	notification of mbox cmd donee
1013155704Smjacob *	MBOX_RELEASE(ispsoftc_t *)		release lock on mailbox regs
101464087Smjacob *
1015196008Smjacob *	FC_SCRATCH_ACQUIRE(ispsoftc_t *, chan)	acquire lock on FC scratch area
1016196008Smjacob *						return -1 if you cannot
1017196008Smjacob *	FC_SCRATCH_RELEASE(ispsoftc_t *, chan)	acquire lock on FC scratch area
101872355Smjacob *
1019237210Smjacob *	FCP_NEXT_CRN(ispsoftc_t *, XS_T *, rslt, channel, target, lun)	generate the next command reference number. XS_T * may be null.
1020237210Smjacob *
102164087Smjacob *	SCSI_GOOD	SCSI 'Good' Status
102264087Smjacob *	SCSI_CHECK	SCSI 'Check Condition' Status
102364087Smjacob *	SCSI_BUSY	SCSI 'Busy' Status
102464087Smjacob *	SCSI_QFULL	SCSI 'Queue Full' Status
102564087Smjacob *
1026196008Smjacob *	XS_T			Platform SCSI transaction type (i.e., command for HBA)
1027196008Smjacob *	XS_DMA_ADDR_T		Platform PCI DMA Address Type
1028196008Smjacob *	XS_GET_DMA_SEG(..)	Get 32 bit dma segment list value
1029196008Smjacob *	XS_GET_DMA64_SEG(..)	Get 64 bit dma segment list value
1030196008Smjacob *	XS_ISP(xs)		gets an instance out of an XS_T
1031196008Smjacob *	XS_CHANNEL(xs)		gets the channel (bus # for DUALBUS cards) ""
1032196008Smjacob *	XS_TGT(xs)		gets the target ""
1033196008Smjacob *	XS_LUN(xs)		gets the lun ""
1034196008Smjacob *	XS_CDBP(xs)		gets a pointer to the scsi CDB ""
1035196008Smjacob *	XS_CDBLEN(xs)		gets the CDB's length ""
1036196008Smjacob *	XS_XFRLEN(xs)		gets the associated data transfer length ""
1037196008Smjacob *	XS_TIME(xs)		gets the time (in milliseconds) for this command
1038196008Smjacob *	XS_GET_RESID(xs)	gets the current residual count
1039196008Smjacob *	XS_GET_RESID(xs, resid)	sets the current residual count
1040196008Smjacob *	XS_STSP(xs)		gets a pointer to the SCSI status byte ""
1041196008Smjacob *	XS_SNSP(xs)		gets a pointer to the associate sense data
1042238869Smjacob *	XS_TOT_SNSLEN(xs)	gets the total length of sense data storage
1043238869Smjacob *	XS_CUR_SNSLEN(xs)	gets the currently used lenght of sense data storage
1044196008Smjacob *	XS_SNSKEY(xs)		dereferences XS_SNSP to get the current stored Sense Key
1045205698Smjacob *	XS_SNSASC(xs)		dereferences XS_SNSP to get the current stored Additional Sense Code
1046205698Smjacob *	XS_SNSASCQ(xs)		dereferences XS_SNSP to get the current stored Additional Sense Code Qualifier
1047196008Smjacob *	XS_TAG_P(xs)		predicate of whether this command should be tagged
1048196008Smjacob *	XS_TAG_TYPE(xs)		which type of tag to use
1049196008Smjacob *	XS_SETERR(xs)		set error state
105064087Smjacob *
105164087Smjacob *		HBA_NOERROR	command has no erros
105264087Smjacob *		HBA_BOTCH	hba botched something
105364087Smjacob *		HBA_CMDTIMEOUT	command timed out
105464087Smjacob *		HBA_SELTIMEOUT	selection timed out (also port logouts for FC)
105564087Smjacob *		HBA_TGTBSY	target returned a BUSY status
105664087Smjacob *		HBA_BUSRESET	bus reset destroyed command
105764087Smjacob *		HBA_ABORTED	command was aborted (by request)
105864087Smjacob *		HBA_DATAOVR	a data overrun was detected
105964087Smjacob *		HBA_ARQFAIL	Automatic Request Sense failed
106064087Smjacob *
106164087Smjacob *	XS_ERR(xs)	return current error state
106264087Smjacob *	XS_NOERR(xs)	there is no error currently set
106364087Smjacob *	XS_INITERR(xs)	initialize error state
106464087Smjacob *
1065238869Smjacob *	XS_SAVE_SENSE(xs, sp, total_len, this_len)	save sense data (total and current amount)
106664087Smjacob *
1067238869Smjacob *	XS_APPEND_SENSE(xs, sp, len)	append more sense data
1068238869Smjacob *
1069205698Smjacob *	XS_SENSE_VALID(xs)		indicates whether sense is valid
1070205698Smjacob *
1071196008Smjacob *	DEFAULT_FRAMESIZE(ispsoftc_t *)		Default Frame Size
1072196008Smjacob *	DEFAULT_EXEC_THROTTLE(ispsoftc_t *)	Default Execution Throttle
107364087Smjacob *
1074291188Smav *	DEFAULT_ROLE(ispsoftc_t *, int)		Get Default Role for a channel
1075196008Smjacob *	DEFAULT_IID(ispsoftc_t *, int)		Default SCSI initiator ID
1076196008Smjacob *	DEFAULT_LOOPID(ispsoftc_t *, int)	Default FC Loop ID
107764087Smjacob *
107867047Smjacob *		These establish reasonable defaults for each platform.
107967047Smjacob * 		These must be available independent of card NVRAM and are
108067047Smjacob *		to be used should NVRAM not be readable.
108164087Smjacob *
1082196008Smjacob *	DEFAULT_NODEWWN(ispsoftc_t *, chan)	Default FC Node WWN to use
1083196008Smjacob *	DEFAULT_PORTWWN(ispsoftc_t *, chan)	Default FC Port WWN to use
108464087Smjacob *
1085196008Smjacob *		These defines are hooks to allow the setting of node and
1086196008Smjacob *		port WWNs when NVRAM cannot be read or is to be overriden.
108764087Smjacob *
1088196008Smjacob *	ACTIVE_NODEWWN(ispsoftc_t *, chan)	FC Node WWN to use
1089196008Smjacob *	ACTIVE_PORTWWN(ispsoftc_t *, chan)	FC Port WWN to use
109087635Smjacob *
1091196008Smjacob *		After NVRAM is read, these will be invoked to get the
1092196008Smjacob *		node and port WWNs that will actually be used for this
1093196008Smjacob *		channel.
1094196008Smjacob *
1095196008Smjacob *
1096155704Smjacob *	ISP_IOXPUT_8(ispsoftc_t *, uint8_t srcval, uint8_t *dstptr)
1097155704Smjacob *	ISP_IOXPUT_16(ispsoftc_t *, uint16_t srcval, uint16_t *dstptr)
1098155704Smjacob *	ISP_IOXPUT_32(ispsoftc_t *, uint32_t srcval, uint32_t *dstptr)
109987635Smjacob *
1100155704Smjacob *	ISP_IOXGET_8(ispsoftc_t *, uint8_t *srcptr, uint8_t dstrval)
1101155704Smjacob *	ISP_IOXGET_16(ispsoftc_t *, uint16_t *srcptr, uint16_t dstrval)
1102155704Smjacob *	ISP_IOXGET_32(ispsoftc_t *, uint32_t *srcptr, uint32_t dstrval)
110387635Smjacob *
1104155704Smjacob *	ISP_SWIZZLE_NVRAM_WORD(ispsoftc_t *, uint16_t *)
1105171159Smjacob *	ISP_SWIZZLE_NVRAM_LONG(ispsoftc_t *, uint32_t *)
1106171159Smjacob *	ISP_SWAP16(ispsoftc_t *, uint16_t srcval)
1107171159Smjacob *	ISP_SWAP32(ispsoftc_t *, uint32_t srcval)
110864087Smjacob */
110977365Smjacob
1110196008Smjacob#ifdef	ISP_TARGET_MODE
1111196008Smjacob/*
1112196008Smjacob * The functions below are for the publicly available
1113196008Smjacob * target mode functions that are internal to the Qlogic driver.
1114196008Smjacob */
1115196008Smjacob
1116196008Smjacob/*
1117196008Smjacob * This function handles new response queue entry appropriate for target mode.
1118196008Smjacob */
1119196008Smjacobint isp_target_notify(ispsoftc_t *, void *, uint32_t *);
1120196008Smjacob
1121196008Smjacob/*
1122196008Smjacob * This function externalizes the ability to acknowledge an Immediate Notify request.
1123196008Smjacob */
1124196008Smjacobint isp_notify_ack(ispsoftc_t *, void *);
1125196008Smjacob
1126196008Smjacob/*
1127196008Smjacob * This function externalized acknowledging (success/fail) an ABTS frame
1128196008Smjacob */
1129196008Smjacobint isp_acknak_abts(ispsoftc_t *, void *, int);
1130196008Smjacob
1131196008Smjacob/*
1132196008Smjacob * General request queue 'put' routine for target mode entries.
1133196008Smjacob */
1134196008Smjacobint isp_target_put_entry(ispsoftc_t *isp, void *);
1135196008Smjacob
1136196008Smjacob/*
1137196008Smjacob * General routine to put back an ATIO entry-
1138196008Smjacob * used for replenishing f/w resource counts.
1139196008Smjacob * The argument is a pointer to a source ATIO
1140196008Smjacob * or ATIO2.
1141196008Smjacob */
1142196008Smjacobint isp_target_put_atio(ispsoftc_t *, void *);
1143196008Smjacob
1144196008Smjacob/*
1145196008Smjacob * General routine to send a final CTIO for a command- used mostly for
1146196008Smjacob * local responses.
1147196008Smjacob */
1148196008Smjacobint isp_endcmd(ispsoftc_t *, ...);
1149196008Smjacob#define	ECMD_SVALID	0x100
1150196008Smjacob#define	ECMD_TERMINATE	0x200
1151196008Smjacob
1152196008Smjacob/*
1153196008Smjacob * Handle an asynchronous event
1154196008Smjacob *
1155196008Smjacob * Return nonzero if the interrupt that generated this event has been dismissed.
1156196008Smjacob */
1157196008Smjacobint isp_target_async(ispsoftc_t *, int, int);
1158196008Smjacob#endif
115935388Smjacob#endif	/* _ISPVAR_H */
1160