xref: /freebsd/sys/dev/isp/ispvar.h (revision 156c1ebe3bc4ec8063790ed9c8d46ce00903cee4)
1c3aac50fSPeter Wemm /* $FreeBSD$ */
2098ca2bdSWarner Losh /*-
3718cf2ccSPedro F. Giffuni  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4718cf2ccSPedro F. Giffuni  *
51b760be4SAlexander Motin  *  Copyright (c) 2009-2020 Alexander Motin <mav@FreeBSD.org>
62df76c16SMatt Jacob  *  Copyright (c) 1997-2009 by Matthew Jacob
76054c3f6SMatt Jacob  *  All rights reserved.
87e90346eSMatt Jacob  *
96054c3f6SMatt Jacob  *  Redistribution and use in source and binary forms, with or without
106054c3f6SMatt Jacob  *  modification, are permitted provided that the following conditions
116054c3f6SMatt Jacob  *  are met:
126054c3f6SMatt Jacob  *
13e48b2487SMatt Jacob  *  1. Redistributions of source code must retain the above copyright
14e48b2487SMatt Jacob  *     notice, this list of conditions and the following disclaimer.
15e48b2487SMatt Jacob  *  2. Redistributions in binary form must reproduce the above copyright
16e48b2487SMatt Jacob  *     notice, this list of conditions and the following disclaimer in the
17e48b2487SMatt Jacob  *     documentation and/or other materials provided with the distribution.
18e48b2487SMatt Jacob  *
19e48b2487SMatt Jacob  *  THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
206054c3f6SMatt Jacob  *  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
216054c3f6SMatt Jacob  *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22e48b2487SMatt Jacob  *  ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
23e48b2487SMatt Jacob  *  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
246054c3f6SMatt Jacob  *  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
256054c3f6SMatt Jacob  *  OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
266054c3f6SMatt Jacob  *  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
276054c3f6SMatt Jacob  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
286054c3f6SMatt Jacob  *  OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
296054c3f6SMatt Jacob  *  SUCH DAMAGE.
302df76c16SMatt Jacob  *
316054c3f6SMatt Jacob  */
32e48b2487SMatt Jacob /*
33e48b2487SMatt Jacob  * Soft Definitions for for Qlogic ISP SCSI adapters.
34e48b2487SMatt Jacob  */
356054c3f6SMatt Jacob 
366054c3f6SMatt Jacob #ifndef	_ISPVAR_H
376054c3f6SMatt Jacob #define	_ISPVAR_H
386054c3f6SMatt Jacob 
3957c801f5SMatt Jacob #if defined(__NetBSD__) || defined(__OpenBSD__)
4010365e5aSMatt Jacob #include <dev/ic/isp_stds.h>
416054c3f6SMatt Jacob #include <dev/ic/ispmbox.h>
426054c3f6SMatt Jacob #endif
436054c3f6SMatt Jacob #ifdef	__FreeBSD__
4410365e5aSMatt Jacob #include <dev/isp/isp_stds.h>
456054c3f6SMatt Jacob #include <dev/isp/ispmbox.h>
466054c3f6SMatt Jacob #endif
476054c3f6SMatt Jacob #ifdef	__linux__
4810365e5aSMatt Jacob #include "isp_stds.h"
49c3055363SMatt Jacob #include "ispmbox.h"
5080ae5655SMatt Jacob #endif
511dae40ebSMatt Jacob #ifdef	__svr4__
5210365e5aSMatt Jacob #include "isp_stds.h"
531dae40ebSMatt Jacob #include "ispmbox.h"
546054c3f6SMatt Jacob #endif
556054c3f6SMatt Jacob 
56c8b8a2c4SMatt Jacob #define	ISP_CORE_VERSION_MAJOR	7
5710365e5aSMatt Jacob #define	ISP_CORE_VERSION_MINOR	0
58478f8a96SJustin T. Gibbs 
596054c3f6SMatt Jacob /*
60cbf57b47SMatt Jacob  * Vector for bus specific code to provide specific services.
616054c3f6SMatt Jacob  */
621dae40ebSMatt Jacob typedef struct ispsoftc ispsoftc_t;
636054c3f6SMatt Jacob struct ispmdvec {
640e6bc811SAlexander Motin 	void		(*dv_run_isr) (ispsoftc_t *);
6510365e5aSMatt Jacob 	uint32_t	(*dv_rd_reg) (ispsoftc_t *, int);
6610365e5aSMatt Jacob 	void		(*dv_wr_reg) (ispsoftc_t *, int, uint32_t);
671dae40ebSMatt Jacob 	int		(*dv_mbxdma) (ispsoftc_t *);
68f6854a0cSAlexander Motin 	int		(*dv_send_cmd) (ispsoftc_t *, void *, void *, uint32_t);
69a1fa0267SAlexander Motin 	int		(*dv_irqsetup) (ispsoftc_t *);
701dae40ebSMatt Jacob 	void		(*dv_dregs) (ispsoftc_t *, const char *);
715f634111SMatt Jacob 	const void *	dv_ispfw;	/* ptr to f/w */
726054c3f6SMatt Jacob };
736054c3f6SMatt Jacob 
7453cff3bbSMatt Jacob /*
7553cff3bbSMatt Jacob  * Overall parameters
7653cff3bbSMatt Jacob  */
776054c3f6SMatt Jacob #define	MAX_TARGETS		16
782df76c16SMatt Jacob #ifndef	MAX_FC_TARG
795d084976SAlexander Motin #define	MAX_FC_TARG		1024
802df76c16SMatt Jacob #endif
811b760be4SAlexander Motin #define	ISP_MAX_TARGETS(isp)	MAX_FC_TARG
8208826086SAlexander Motin #define	ISP_MAX_IRQS		3
830f747d72SMatt Jacob 
84126ec864SMatt Jacob /*
8553cff3bbSMatt Jacob  * Macros to access ISP registers through bus specific layers-
8653cff3bbSMatt Jacob  * mostly wrappers to vector through the mdvec structure.
8780ae5655SMatt Jacob  */
880e6bc811SAlexander Motin #define	ISP_RUN_ISR(isp)	\
890e6bc811SAlexander Motin 	(*(isp)->isp_mdvec->dv_run_isr)(isp)
9080ae5655SMatt Jacob 
9180ae5655SMatt Jacob #define	ISP_READ(isp, reg)	\
9280ae5655SMatt Jacob 	(*(isp)->isp_mdvec->dv_rd_reg)((isp), (reg))
9380ae5655SMatt Jacob 
9480ae5655SMatt Jacob #define	ISP_WRITE(isp, reg, val)	\
9580ae5655SMatt Jacob 	(*(isp)->isp_mdvec->dv_wr_reg)((isp), (reg), (val))
9680ae5655SMatt Jacob 
9780ae5655SMatt Jacob #define	ISP_MBOXDMASETUP(isp)	\
9880ae5655SMatt Jacob 	(*(isp)->isp_mdvec->dv_mbxdma)((isp))
9980ae5655SMatt Jacob 
100f6854a0cSAlexander Motin #define	ISP_SEND_CMD(isp, qe, segp, nseg)	\
101f6854a0cSAlexander Motin 	(*(isp)->isp_mdvec->dv_send_cmd)((isp), (qe), (segp), (nseg))
10280ae5655SMatt Jacob 
103a1fa0267SAlexander Motin #define	ISP_IRQSETUP(isp)	\
104a1fa0267SAlexander Motin 	(((isp)->isp_mdvec->dv_irqsetup) ? (*(isp)->isp_mdvec->dv_irqsetup)(isp) : 0)
10553cff3bbSMatt Jacob #define	ISP_DUMPREGS(isp, m)	\
10653cff3bbSMatt Jacob 	if ((isp)->isp_mdvec->dv_dregs) (*(isp)->isp_mdvec->dv_dregs)((isp),(m))
10780ae5655SMatt Jacob 
10880ae5655SMatt Jacob #define	ISP_SETBITS(isp, reg, val)	\
10980ae5655SMatt Jacob  (*(isp)->isp_mdvec->dv_wr_reg)((isp), (reg), ISP_READ((isp), (reg)) | (val))
11080ae5655SMatt Jacob 
11180ae5655SMatt Jacob #define	ISP_CLRBITS(isp, reg, val)	\
11280ae5655SMatt Jacob  (*(isp)->isp_mdvec->dv_wr_reg)((isp), (reg), ISP_READ((isp), (reg)) & ~(val))
11380ae5655SMatt Jacob 
11453cff3bbSMatt Jacob /*
11553cff3bbSMatt Jacob  * The MEMORYBARRIER macro is defined per platform (to provide synchronization
11653cff3bbSMatt Jacob  * on Request and Response Queues, Scratch DMA areas, and Registers)
11753cff3bbSMatt Jacob  *
11853cff3bbSMatt Jacob  * Defined Memory Barrier Synchronization Types
11953cff3bbSMatt Jacob  */
12053cff3bbSMatt Jacob #define	SYNC_REQUEST	0	/* request queue synchronization */
12153cff3bbSMatt Jacob #define	SYNC_RESULT	1	/* result queue synchronization */
12253cff3bbSMatt Jacob #define	SYNC_SFORDEV	2	/* scratch, sync for ISP */
12353cff3bbSMatt Jacob #define	SYNC_SFORCPU	3	/* scratch, sync for CPU */
12453cff3bbSMatt Jacob #define	SYNC_REG	4	/* for registers */
12510365e5aSMatt Jacob #define	SYNC_ATIOQ	5	/* atio result queue (24xx) */
1264ff970c4SAlexander Motin #define	SYNC_IFORDEV	6	/* synchrounous IOCB, sync for ISP */
1274ff970c4SAlexander Motin #define	SYNC_IFORCPU	7	/* synchrounous IOCB, sync for CPU */
12853cff3bbSMatt Jacob 
12953cff3bbSMatt Jacob /*
13053cff3bbSMatt Jacob  * Request/Response Queue defines and macros.
13153cff3bbSMatt Jacob  */
13253cff3bbSMatt Jacob /* This is the size of a queue entry (request and response) */
1336054c3f6SMatt Jacob #define	QENTRY_LEN			64
1340f99cb55SAlexander Motin /*
1350f99cb55SAlexander Motin  * Hardware requires queue lengths of at least 8 elements.  Driver requires
1360f99cb55SAlexander Motin  * lengths to be a power of two, and request queue of at least 256 elements.
1370f99cb55SAlexander Motin  */
138b8e2395eSAlexander Motin #define	RQUEST_QUEUE_LEN(x)		8192
139b8e2395eSAlexander Motin #define	RESULT_QUEUE_LEN(x)		1024
140b8e2395eSAlexander Motin #define	ATIO_QUEUE_LEN(x)		1024
141b8e2395eSAlexander Motin #define	ISP_QUEUE_ENTRY(q, idx)		(((uint8_t *)q) + ((size_t)(idx) * QENTRY_LEN))
142b8e2395eSAlexander Motin #define	ISP_QUEUE_SIZE(n)		((size_t)(n) * QENTRY_LEN)
143478f8a96SJustin T. Gibbs #define	ISP_NXT_QENTRY(idx, qlen)	(((idx) + 1) & ((qlen)-1))
1440f99cb55SAlexander Motin #define	ISP_QFREE(in, out, qlen)	((out - in - 1) & ((qlen) - 1))
145b6b6ad2fSMatt Jacob #define	ISP_QAVAIL(isp)	\
146b6b6ad2fSMatt Jacob 	ISP_QFREE(isp->isp_reqidx, isp->isp_reqodx, RQUEST_QUEUE_LEN(isp))
14780ae5655SMatt Jacob 
1484fd13c1bSMatt Jacob #define	ISP_ADD_REQUEST(isp, nxti)						\
14937bb79f1SMarius Strobl 	MEMORYBARRIER(isp, SYNC_REQUEST, isp->isp_reqidx, QENTRY_LEN, -1);	\
1501b760be4SAlexander Motin 	ISP_WRITE(isp, BIU2400_REQINP, nxti);					\
1514fd13c1bSMatt Jacob 	isp->isp_reqidx = nxti
15280ae5655SMatt Jacob 
1532df76c16SMatt Jacob #define	ISP_SYNC_REQUEST(isp)								\
15437bb79f1SMarius Strobl 	MEMORYBARRIER(isp, SYNC_REQUEST, isp->isp_reqidx, QENTRY_LEN, -1);		\
1552df76c16SMatt Jacob 	isp->isp_reqidx = ISP_NXT_QENTRY(isp->isp_reqidx, RQUEST_QUEUE_LEN(isp));	\
1561b760be4SAlexander Motin 	ISP_WRITE(isp, BIU2400_REQINP, isp->isp_reqidx)
1576054c3f6SMatt Jacob 
1586054c3f6SMatt Jacob /*
1596054c3f6SMatt Jacob  * Fibre Channel Specifics
1606054c3f6SMatt Jacob  */
16110365e5aSMatt Jacob #define	NPH_RESERVED		0x7F0	/* begin of reserved N-port handles */
16210365e5aSMatt Jacob #define	NPH_MGT_ID		0x7FA	/* Management Server Special ID */
16310365e5aSMatt Jacob #define	NPH_SNS_ID		0x7FC	/* SNS Server Special ID */
1642df76c16SMatt Jacob #define	NPH_FABRIC_CTLR		0x7FD	/* Fabric Controller (0xFFFFFD) */
1652df76c16SMatt Jacob #define	NPH_FL_ID		0x7FE	/* F Port Special ID (0xFFFFFE) */
1665b355b12SAlexander Motin #define	NPH_IP_BCST		0x7FF	/* IP Broadcast Special ID (0xFFFFFF) */
167dd9fc7c3SMatt Jacob #define	NPH_MAX_2K		0x800
168dd9fc7c3SMatt Jacob 
169dd9fc7c3SMatt Jacob /*
170dd9fc7c3SMatt Jacob  * "Unassigned" handle to be used internally
171dd9fc7c3SMatt Jacob  */
172dd9fc7c3SMatt Jacob #define	NIL_HANDLE		0xffff
173029f13c6SMatt Jacob 
17410365e5aSMatt Jacob /*
17510365e5aSMatt Jacob  * Limit for devices on an arbitrated loop.
17610365e5aSMatt Jacob  */
17710365e5aSMatt Jacob #define	LOCAL_LOOP_LIM		126
17810365e5aSMatt Jacob 
17910365e5aSMatt Jacob /*
1802df76c16SMatt Jacob  * Limit for (2K login) N-port handle amounts
1812df76c16SMatt Jacob  */
1822df76c16SMatt Jacob #define	MAX_NPORT_HANDLE	2048
1832df76c16SMatt Jacob 
1842df76c16SMatt Jacob /*
1852df76c16SMatt Jacob  * Special Constants
1862df76c16SMatt Jacob  */
1872df76c16SMatt Jacob #define	INI_NONE    		((uint64_t) 0)
1882df76c16SMatt Jacob #define	ISP_NOCHAN		0xff
1892df76c16SMatt Jacob 
1902df76c16SMatt Jacob /*
19110365e5aSMatt Jacob  * Special Port IDs
19210365e5aSMatt Jacob  */
19310365e5aSMatt Jacob #define	MANAGEMENT_PORT_ID	0xFFFFFA
19410365e5aSMatt Jacob #define	SNS_PORT_ID		0xFFFFFC
19510365e5aSMatt Jacob #define	FABRIC_PORT_ID		0xFFFFFE
1962df76c16SMatt Jacob #define	PORT_ANY		0xFFFFFF
1972df76c16SMatt Jacob #define	PORT_NONE		0
1984187a965SAlexander Motin #define	VALID_PORT(port)	(port != PORT_NONE && port != PORT_ANY)
1992df76c16SMatt Jacob #define	DOMAIN_CONTROLLER_BASE	0xFFFC00
2002df76c16SMatt Jacob #define	DOMAIN_CONTROLLER_END	0xFFFCFF
20110365e5aSMatt Jacob 
202c8b8a2c4SMatt Jacob /*
203c8b8a2c4SMatt Jacob  * Command Handles
204c8b8a2c4SMatt Jacob  *
205c8b8a2c4SMatt Jacob  * Most QLogic initiator or target have 32 bit handles associated with them.
206c8b8a2c4SMatt Jacob  * We want to have a quick way to index back and forth between a local SCSI
207c8b8a2c4SMatt Jacob  * command context and what the firmware is passing back to us. We also
208c8b8a2c4SMatt Jacob  * want to avoid working on stale information. This structure handles both
209c8b8a2c4SMatt Jacob  * at the expense of some local memory.
210c8b8a2c4SMatt Jacob  *
211c8b8a2c4SMatt Jacob  * The handle is architected thusly:
212c8b8a2c4SMatt Jacob  *
213c8b8a2c4SMatt Jacob  *	0 means "free handle"
214c8b8a2c4SMatt Jacob  *	bits  0..12 index commands
215c8b8a2c4SMatt Jacob  *	bits 13..15 bits index usage
216c8b8a2c4SMatt Jacob  *	bits 16..31 contain a rolling sequence
217c8b8a2c4SMatt Jacob  *
218c8b8a2c4SMatt Jacob  *
219c8b8a2c4SMatt Jacob  */
220c8b8a2c4SMatt Jacob typedef struct {
221c8b8a2c4SMatt Jacob 	void *		cmd;	/* associated command context */
222c8b8a2c4SMatt Jacob 	uint32_t	handle;	/* handle associated with this command */
223c8b8a2c4SMatt Jacob } isp_hdl_t;
224c8b8a2c4SMatt Jacob #define	ISP_HANDLE_FREE		0x00000000
2250b19f90aSAlexander Motin #define	ISP_HANDLE_CMD_MASK	0x00003fff
2260b19f90aSAlexander Motin #define	ISP_HANDLE_USAGE_MASK	0x0000c000
2270b19f90aSAlexander Motin #define	ISP_HANDLE_USAGE_SHIFT	14
228c8b8a2c4SMatt Jacob #define	ISP_H2HT(hdl)	((hdl & ISP_HANDLE_USAGE_MASK) >> ISP_HANDLE_USAGE_SHIFT)
229c8b8a2c4SMatt Jacob #	define	ISP_HANDLE_NONE		0
230c8b8a2c4SMatt Jacob #	define	ISP_HANDLE_INITIATOR	1
231c8b8a2c4SMatt Jacob #	define	ISP_HANDLE_TARGET	2
23266e979f1SAlexander Motin #	define	ISP_HANDLE_CTRL		3
233c8b8a2c4SMatt Jacob #define	ISP_HANDLE_SEQ_MASK	0xffff0000
234c8b8a2c4SMatt Jacob #define	ISP_HANDLE_SEQ_SHIFT	16
235c8b8a2c4SMatt Jacob #define	ISP_H2SEQ(hdl)	((hdl & ISP_HANDLE_SEQ_MASK) >> ISP_HANDLE_SEQ_SHIFT)
2360b19f90aSAlexander Motin #define	ISP_HANDLE_MAX		(ISP_HANDLE_CMD_MASK + 1)
2370b19f90aSAlexander Motin #define	ISP_HANDLE_RESERVE	256
2380b19f90aSAlexander Motin #define	ISP_HANDLE_NUM(isp)	((isp)->isp_maxcmds + ISP_HANDLE_RESERVE)
2390b19f90aSAlexander Motin #define	ISP_VALID_HANDLE(isp, hdl)	\
240970ceb2fSAlexander Motin 	((ISP_H2HT(hdl) == ISP_HANDLE_INITIATOR || \
24166e979f1SAlexander Motin 	  ISP_H2HT(hdl) == ISP_HANDLE_TARGET || \
24266e979f1SAlexander Motin 	  ISP_H2HT(hdl) == ISP_HANDLE_CTRL) && \
2430b19f90aSAlexander Motin 	 ((hdl) & ISP_HANDLE_CMD_MASK) < ISP_HANDLE_NUM(isp) && \
2440b19f90aSAlexander Motin 	 (hdl) == ((isp)->isp_xflist[(hdl) & ISP_HANDLE_CMD_MASK].handle))
245c8b8a2c4SMatt Jacob 
24610365e5aSMatt Jacob 
24710365e5aSMatt Jacob /*
24810365e5aSMatt Jacob  * FC Port Database entry.
24910365e5aSMatt Jacob  *
25010365e5aSMatt Jacob  * It has a handle that the f/w uses to address commands to a device.
25110365e5aSMatt Jacob  * This handle's value may be assigned by the firmware (e.g., for local loop
25210365e5aSMatt Jacob  * devices) or by the driver (e.g., for fabric devices).
25310365e5aSMatt Jacob  *
25410365e5aSMatt Jacob  * It has a state. If the state if VALID, that means that we've logged into
255766a65a5SAlexander Motin  * the device.
25610365e5aSMatt Jacob  *
25710365e5aSMatt Jacob  * Local loop devices the firmware automatically performs PLOGI on for us
25810365e5aSMatt Jacob  * (which is why that handle is imposed upon us). Fabric devices we assign
25910365e5aSMatt Jacob  * a handle to and perform the PLOGI on.
26010365e5aSMatt Jacob  *
26110365e5aSMatt Jacob  * When a PORT DATABASE CHANGED asynchronous event occurs, we mark all VALID
26210365e5aSMatt Jacob  * entries as PROBATIONAL. This allows us, if policy says to, just keep track
26310365e5aSMatt Jacob  * of devices whose handles change but are otherwise the same device (and
26410365e5aSMatt Jacob  * thus keep 'target' constant).
26510365e5aSMatt Jacob  *
26610365e5aSMatt Jacob  * In any case, we search all possible local loop handles. For each one that
26710365e5aSMatt Jacob  * has a port database entity returned, we search for any PROBATIONAL entry
26810365e5aSMatt Jacob  * that matches it and update as appropriate. Otherwise, as a new entry, we
26910365e5aSMatt Jacob  * find room for it in the Port Database. We *try* and use the handle as the
27010365e5aSMatt Jacob  * index to put it into the Database, but that's just an optimization. We mark
27110365e5aSMatt Jacob  * the entry VALID and make sure that the target index is updated and correct.
27210365e5aSMatt Jacob  *
273453130d9SPedro F. Giffuni  * When we get done searching the local loop, we then search similarly for
27410365e5aSMatt Jacob  * a list of devices we've gotten from the fabric name controller (if we're
275453130d9SPedro F. Giffuni  * on a fabric). VALID marking is also done similarly.
27610365e5aSMatt Jacob  *
27710365e5aSMatt Jacob  * When all of this is done, we can march through the database and clean up
27810365e5aSMatt Jacob  * any entry that is still PROBATIONAL (these represent devices which have
27910365e5aSMatt Jacob  * departed). Then we're done and can resume normal operations.
28010365e5aSMatt Jacob  *
28110365e5aSMatt Jacob  * Negative invariants that we try and test for are:
28210365e5aSMatt Jacob  *
28310365e5aSMatt Jacob  *  + There can never be two non-NIL entries with the same { Port, Node } WWN
28410365e5aSMatt Jacob  *    duples.
28510365e5aSMatt Jacob  *
28610365e5aSMatt Jacob  *  + There can never be two non-NIL entries with the same handle.
28710365e5aSMatt Jacob  */
2886054c3f6SMatt Jacob typedef struct {
289f7c631bcSMatt Jacob 	/*
290f7c631bcSMatt Jacob 	 * This is the handle that the firmware needs in order for us to
291f7c631bcSMatt Jacob 	 * send commands to the device. For pre-24XX cards, this would be
292f7c631bcSMatt Jacob 	 * the 'loopid'.
293f7c631bcSMatt Jacob 	 */
29410365e5aSMatt Jacob 	uint16_t	handle;
2952df76c16SMatt Jacob 
296f7c631bcSMatt Jacob 	/*
2976f9dbc0eSKenneth D. Merry 	 * PRLI word 0 contains the Establish Image Pair bit, which is
2986f9dbc0eSKenneth D. Merry 	 * important for knowing when to reset the CRN.
2996f9dbc0eSKenneth D. Merry 	 *
300387d8239SMatt Jacob 	 * PRLI word 3 parameters contains role as well as other things.
301f7c631bcSMatt Jacob 	 *
302387d8239SMatt Jacob 	 * The state is the current state of this entry.
303f7c631bcSMatt Jacob 	 *
304e68eef14SAlexander Motin 	 * The is_target is the current state of target on this port.
305e68eef14SAlexander Motin 	 *
306e68eef14SAlexander Motin 	 * The is_initiator is the current state of initiator on this port.
307e68eef14SAlexander Motin 	 *
3082df76c16SMatt Jacob 	 * Portid is obvious, as are node && port WWNs. The new_role and
309f7c631bcSMatt Jacob 	 * new_portid is for when we are pending a change.
310f7c631bcSMatt Jacob 	 */
3116f9dbc0eSKenneth D. Merry 	uint16_t	prli_word0;		/* PRLI parameters */
312387d8239SMatt Jacob 	uint16_t	prli_word3;		/* PRLI parameters */
3136f9dbc0eSKenneth D. Merry 	uint16_t	new_prli_word0;		/* Incoming new PRLI parameters */
314387d8239SMatt Jacob 	uint16_t	new_prli_word3;		/* Incoming new PRLI parameters */
3155fa351edSAlexander Motin 	uint16_t			: 12,
316eea52482SAlexander Motin 			probational	: 1,
31710365e5aSMatt Jacob 			state		: 3;
318e68eef14SAlexander Motin 	uint32_t			: 6,
319e68eef14SAlexander Motin 			is_target	: 1,
320e68eef14SAlexander Motin 			is_initiator	: 1,
32110365e5aSMatt Jacob 			portid		: 24;
3222df76c16SMatt Jacob 	uint32_t
323e68eef14SAlexander Motin 					: 8,
32410365e5aSMatt Jacob 			new_portid	: 24;
32510365e5aSMatt Jacob 	uint64_t	node_wwn;
32610365e5aSMatt Jacob 	uint64_t	port_wwn;
327427fa8f9SMatt Jacob 	uint32_t	gone_timer;
32810365e5aSMatt Jacob } fcportdb_t;
32910365e5aSMatt Jacob 
330eea52482SAlexander Motin #define	FC_PORTDB_STATE_NIL		0	/* Empty DB slot */
331eea52482SAlexander Motin #define	FC_PORTDB_STATE_DEAD		1	/* Was valid, but no more. */
332eea52482SAlexander Motin #define	FC_PORTDB_STATE_CHANGED		2	/* Was valid, but changed. */
333eea52482SAlexander Motin #define	FC_PORTDB_STATE_NEW		3	/* Logged in, not announced. */
334eea52482SAlexander Motin #define	FC_PORTDB_STATE_ZOMBIE		4	/* Invalid, but announced. */
335eea52482SAlexander Motin #define	FC_PORTDB_STATE_VALID		5	/* Valid */
33610365e5aSMatt Jacob 
337e68eef14SAlexander Motin #define	FC_PORTDB_TGT(isp, bus, pdb)		(int)(lp - FCPARAM(isp, bus)->portdb)
338e68eef14SAlexander Motin 
33910365e5aSMatt Jacob /*
34010365e5aSMatt Jacob  * FC card specific information
3412df76c16SMatt Jacob  *
3422df76c16SMatt Jacob  * This structure is replicated across multiple channels for multi-id
3432df76c16SMatt Jacob  * capapble chipsets, with some entities different on a per-channel basis.
34410365e5aSMatt Jacob  */
3452df76c16SMatt Jacob 
34610365e5aSMatt Jacob typedef struct {
347e596ff7aSAlexander Motin 	int			isp_gbspeed;		/* Connection speed */
348e596ff7aSAlexander Motin 	int			isp_linkstate;		/* Link state */
349e596ff7aSAlexander Motin 	int			isp_fwstate;		/* ISP F/W state */
350e596ff7aSAlexander Motin 	int			isp_loopstate;		/* Loop State */
351e596ff7aSAlexander Motin 	int			isp_topo;		/* Connection Type */
352e596ff7aSAlexander Motin 
353e561aa79SAlexander Motin 	uint32_t				: 4,
354387d8239SMatt Jacob 				fctape_enabled	: 1,
3552df76c16SMatt Jacob 				sendmarker	: 1,
3562df76c16SMatt Jacob 				role		: 2,
357e5265237SMatt Jacob 				isp_portid	: 24;	/* S_ID */
3582df76c16SMatt Jacob 
3591dae40ebSMatt Jacob 	uint16_t		isp_fwoptions;
3608a97c03aSMatt Jacob 	uint16_t		isp_xfwoptions;
3618a97c03aSMatt Jacob 	uint16_t		isp_zfwoptions;
3621dae40ebSMatt Jacob 	uint16_t		isp_loopid;		/* hard loop id */
3632df76c16SMatt Jacob 	uint16_t		isp_sns_hdl;		/* N-port handle for SNS */
3642df76c16SMatt Jacob 	uint16_t		isp_lasthdl;		/* only valid for channel 0 */
365ad0ab753SMatt Jacob 	uint16_t		isp_fabric_params;
366ace7039eSAlexander Motin 	uint16_t		isp_login_hdl;		/* Logging in handle */
3671dae40ebSMatt Jacob 	uint8_t			isp_retry_delay;
3681dae40ebSMatt Jacob 	uint8_t			isp_retry_count;
369a94fab67SAlexander Motin 	int			isp_use_gft_id;		/* Use GFT_ID */
370a94fab67SAlexander Motin 	int			isp_use_gff_id;		/* Use GFF_ID */
3712df76c16SMatt Jacob 
3722df76c16SMatt Jacob 	/*
3732df76c16SMatt Jacob 	 * Current active WWNN/WWPN
3742df76c16SMatt Jacob 	 */
3752df76c16SMatt Jacob 	uint64_t		isp_wwnn;
3762df76c16SMatt Jacob 	uint64_t		isp_wwpn;
3772df76c16SMatt Jacob 
3782df76c16SMatt Jacob 	/*
3792df76c16SMatt Jacob 	 * NVRAM WWNN/WWPN
3802df76c16SMatt Jacob 	 */
3816c81a0aeSMatt Jacob 	uint64_t		isp_wwnn_nvram;
3826c81a0aeSMatt Jacob 	uint64_t		isp_wwpn_nvram;
383f7c631bcSMatt Jacob 
384f7c631bcSMatt Jacob 	/*
385f7c631bcSMatt Jacob 	 * Our Port Data Base
386f7c631bcSMatt Jacob 	 */
38710365e5aSMatt Jacob 	fcportdb_t		portdb[MAX_FC_TARG];
388f7c631bcSMatt Jacob 
38957c801f5SMatt Jacob 	/*
3906054c3f6SMatt Jacob 	 * Scratch DMA mapped in area to fetch Port Database stuff, etc.
3916054c3f6SMatt Jacob 	 */
3921dae40ebSMatt Jacob 	void *			isp_scratch;
3931dae40ebSMatt Jacob 	XS_DMA_ADDR_T		isp_scdma;
3945d084976SAlexander Motin 
3955d084976SAlexander Motin 	uint8_t			isp_scanscratch[ISP_FC_SCRLEN];
3966054c3f6SMatt Jacob } fcparam;
3976054c3f6SMatt Jacob 
39877d4e836SMatt Jacob #define	FW_CONFIG_WAIT		0
399b6bd5f7fSAlexander Motin #define	FW_WAIT_LINK		1
40077d4e836SMatt Jacob #define	FW_WAIT_LOGIN		2
40177d4e836SMatt Jacob #define	FW_READY		3
40277d4e836SMatt Jacob #define	FW_LOSS_OF_SYNC		4
40377d4e836SMatt Jacob #define	FW_ERROR		5
40477d4e836SMatt Jacob #define	FW_REINIT		6
40577d4e836SMatt Jacob #define	FW_NON_PART		7
4066054c3f6SMatt Jacob 
40777d4e836SMatt Jacob #define	LOOP_NIL		0
408e561aa79SAlexander Motin #define	LOOP_HAVE_LINK		1
409212fad74SAlexander Motin #define	LOOP_HAVE_ADDR		2
410212fad74SAlexander Motin #define	LOOP_TESTING_LINK	3
411212fad74SAlexander Motin #define	LOOP_LTEST_DONE		4
412212fad74SAlexander Motin #define	LOOP_SCANNING_LOOP	5
413212fad74SAlexander Motin #define	LOOP_LSCAN_DONE		6
414212fad74SAlexander Motin #define	LOOP_SCANNING_FABRIC	7
415212fad74SAlexander Motin #define	LOOP_FSCAN_DONE		8
416212fad74SAlexander Motin #define	LOOP_SYNCING_PDB	9
417212fad74SAlexander Motin #define	LOOP_READY		10
41877d4e836SMatt Jacob 
419d465588aSMatt Jacob #define	TOPO_NL_PORT		0
420d465588aSMatt Jacob #define	TOPO_FL_PORT		1
421d465588aSMatt Jacob #define	TOPO_N_PORT		2
422d465588aSMatt Jacob #define	TOPO_F_PORT		3
423d465588aSMatt Jacob #define	TOPO_PTP_STUB		4
424d465588aSMatt Jacob 
425eea52482SAlexander Motin #define TOPO_IS_FABRIC(x)	((x) == TOPO_FL_PORT || (x) == TOPO_F_PORT)
426eea52482SAlexander Motin 
42757b6261fSKenneth D. Merry #define FCP_AL_DA_ALL		0xFF
42857b6261fSKenneth D. Merry #define FCP_AL_PA(fcp) ((uint8_t)(fcp->isp_portid))
42957b6261fSKenneth D. Merry #define FCP_IS_DEST_ALPD(fcp, alpd) (FCP_AL_PA((fcp)) == FCP_AL_DA_ALL || FCP_AL_PA((fcp)) == alpd)
43057b6261fSKenneth D. Merry 
4316054c3f6SMatt Jacob /*
4326054c3f6SMatt Jacob  * Soft Structure per host adapter
4336054c3f6SMatt Jacob  */
4341dae40ebSMatt Jacob struct ispsoftc {
4356054c3f6SMatt Jacob 	/*
4366054c3f6SMatt Jacob 	 * Platform (OS) specific data
4376054c3f6SMatt Jacob 	 */
4386054c3f6SMatt Jacob 	struct isposinfo	isp_osinfo;
4396054c3f6SMatt Jacob 
4406054c3f6SMatt Jacob 	/*
44180ae5655SMatt Jacob 	 * Pointer to bus specific functions and data
4426054c3f6SMatt Jacob 	 */
4436054c3f6SMatt Jacob 	struct ispmdvec *	isp_mdvec;
4446054c3f6SMatt Jacob 
4456054c3f6SMatt Jacob 	/*
44680ae5655SMatt Jacob 	 * (Mostly) nonvolatile state. Board specific parameters
44780ae5655SMatt Jacob 	 * may contain some volatile state (e.g., current loop state).
4486054c3f6SMatt Jacob 	 */
4496054c3f6SMatt Jacob 
450a6222dd7SAlexander Motin 	fcparam			*isp_param;	/* Per-channel storage. */
451ad0ab753SMatt Jacob 	uint64_t		isp_fwattr;	/* firmware attributes */
4521dae40ebSMatt Jacob 	uint16_t		isp_fwrev[3];	/* Loaded F/W revision */
4531dae40ebSMatt Jacob 	uint16_t		isp_maxcmds;	/* max possible I/O cmds */
454a6222dd7SAlexander Motin 	uint16_t		isp_nchan;	/* number of channels */
455a6222dd7SAlexander Motin 	uint16_t		isp_dblev;	/* debug log mask */
4561dae40ebSMatt Jacob 	uint8_t			isp_type;	/* HBA Chip Type */
4571dae40ebSMatt Jacob 	uint8_t			isp_revision;	/* HBA Chip H/W Revision */
45808826086SAlexander Motin 	uint8_t			isp_nirq;	/* number of IRQs */
459a6222dd7SAlexander Motin 	uint8_t			isp_port;	/* physical port on a card */
4601dae40ebSMatt Jacob 	uint32_t		isp_confopts;	/* config options */
4617afb656fSMatt Jacob 
4626054c3f6SMatt Jacob 	/*
463478f8a96SJustin T. Gibbs 	 * Volatile state
4646054c3f6SMatt Jacob 	 */
465a1fa0267SAlexander Motin 	volatile u_int		isp_mboxbsy;	/* mailbox command active */
466a1fa0267SAlexander Motin 	volatile u_int		isp_state;
46710365e5aSMatt Jacob 	volatile uint32_t	isp_reqodx;	/* index of last ISP pickup */
46810365e5aSMatt Jacob 	volatile uint32_t	isp_reqidx;	/* index of next request */
46910365e5aSMatt Jacob 	volatile uint32_t	isp_resodx;	/* index of next result */
470523ea374SAlexander Motin 	volatile uint32_t	isp_atioodx;	/* index of next ATIO */
47110365e5aSMatt Jacob 	volatile uint32_t	isp_obits;	/* mailbox command output */
4722df76c16SMatt Jacob 	volatile uint32_t	isp_serno;	/* rolling serial number */
473ad0ab753SMatt Jacob 	volatile uint16_t	isp_mboxtmp[MAX_MAILBOX];
474c8b8a2c4SMatt Jacob 	volatile uint16_t	isp_seqno;	/* running sequence number */
4750f99cb55SAlexander Motin 	u_int			isp_rqovf;	/* request queue overflow */
476478f8a96SJustin T. Gibbs 
477478f8a96SJustin T. Gibbs 	/*
47880ae5655SMatt Jacob 	 * Active commands are stored here, indexed by handle functions.
479478f8a96SJustin T. Gibbs 	 */
480c8b8a2c4SMatt Jacob 	isp_hdl_t		*isp_xflist;
481c8b8a2c4SMatt Jacob 	isp_hdl_t		*isp_xffree;
4826054c3f6SMatt Jacob 
4836054c3f6SMatt Jacob 	/*
4844ff970c4SAlexander Motin 	 * DMA mapped in area for synchronous IOCB requests.
4854ff970c4SAlexander Motin 	 */
4864ff970c4SAlexander Motin 	void *			isp_iocb;
4874ff970c4SAlexander Motin 	XS_DMA_ADDR_T		isp_iocb_dma;
4884ff970c4SAlexander Motin 
4894ff970c4SAlexander Motin 	/*
4904b39f27dSMatt Jacob 	 * request/result queue pointers and DMA handles for them.
4916054c3f6SMatt Jacob 	 */
4921dae40ebSMatt Jacob 	void *			isp_rquest;
4931dae40ebSMatt Jacob 	void *			isp_result;
4941dae40ebSMatt Jacob 	XS_DMA_ADDR_T		isp_rquest_dma;
4951dae40ebSMatt Jacob 	XS_DMA_ADDR_T		isp_result_dma;
49610365e5aSMatt Jacob #ifdef	ISP_TARGET_MODE
49710365e5aSMatt Jacob 	/* for 24XX only */
49810365e5aSMatt Jacob 	void *			isp_atioq;
49910365e5aSMatt Jacob 	XS_DMA_ADDR_T		isp_atioq_dma;
50010365e5aSMatt Jacob #endif
5011dae40ebSMatt Jacob };
5026054c3f6SMatt Jacob 
503a6222dd7SAlexander Motin #define	FCPARAM(isp, chan)	(&(isp)->isp_param[(chan)])
5042df76c16SMatt Jacob 
5052df76c16SMatt Jacob #define	ISP_SET_SENDMARKER(isp, chan, val)	\
5061b760be4SAlexander Motin     FCPARAM(isp, chan)->sendmarker = val	\
5072df76c16SMatt Jacob 
5082df76c16SMatt Jacob #define	ISP_TST_SENDMARKER(isp, chan)		\
5091b760be4SAlexander Motin     (FCPARAM(isp, chan)->sendmarker != 0)
5100f747d72SMatt Jacob 
5116054c3f6SMatt Jacob /*
51253cff3bbSMatt Jacob  * ISP Driver Run States
5136054c3f6SMatt Jacob  */
5146054c3f6SMatt Jacob #define	ISP_NILSTATE	0
5158a97c03aSMatt Jacob #define	ISP_CRASHED	1
5168a97c03aSMatt Jacob #define	ISP_RESETSTATE	2
5178a97c03aSMatt Jacob #define	ISP_INITSTATE	3
5188a97c03aSMatt Jacob #define	ISP_RUNSTATE	4
5196054c3f6SMatt Jacob 
5206054c3f6SMatt Jacob /*
5219e7d423dSMatt Jacob  * ISP Runtime Configuration Options
5226054c3f6SMatt Jacob  */
52380ae5655SMatt Jacob #define	ISP_CFG_FULL_DUPLEX	0x01	/* Full Duplex (Fibre Channel only) */
5245f2638daSAlexander Motin #define	ISP_CFG_PORT_PREF	0x0e	/* Mask for Port Prefs (all FC except 2100) */
5255f2638daSAlexander Motin #define	ISP_CFG_PORT_DEF	0x00	/* prefer connection type from NVRAM */
5265f2638daSAlexander Motin #define	ISP_CFG_LPORT_ONLY	0x02	/* insist on {N/F}L-Port connection */
5275f2638daSAlexander Motin #define	ISP_CFG_NPORT_ONLY	0x04	/* insist on {N/F}-Port connection */
5285f2638daSAlexander Motin #define	ISP_CFG_LPORT		0x06	/* prefer {N/F}L-Port connection */
5295f2638daSAlexander Motin #define	ISP_CFG_NPORT		0x08	/* prefer {N/F}-Port connection */
53014e084adSAlexander Motin #define	ISP_CFG_1GB		0x10	/* force 1Gb connection (23XX only) */
53114e084adSAlexander Motin #define	ISP_CFG_2GB		0x20	/* force 2Gb connection (23XX only) */
532387d8239SMatt Jacob #define	ISP_CFG_NORELOAD	0x80	/* don't download f/w */
533387d8239SMatt Jacob #define	ISP_CFG_NONVRAM		0x40	/* ignore NVRAM */
534387d8239SMatt Jacob #define	ISP_CFG_NOFCTAPE	0x100	/* disable FC-Tape */
535387d8239SMatt Jacob #define	ISP_CFG_FCTAPE		0x200	/* enable FC-Tape */
5360499ae00SMatt Jacob #define	ISP_CFG_OWNFSZ		0x400	/* override NVRAM frame size */
5370499ae00SMatt Jacob #define	ISP_CFG_OWNLOOPID	0x800	/* override NVRAM loopid */
53814e084adSAlexander Motin #define	ISP_CFG_4GB		0x2000	/* force 4Gb connection (24XX only) */
53914e084adSAlexander Motin #define	ISP_CFG_8GB		0x4000	/* force 8Gb connection (25XX only) */
54014e084adSAlexander Motin #define	ISP_CFG_16GB		0x8000	/* force 16Gb connection (26XX only) */
54114e084adSAlexander Motin #define	ISP_CFG_32GB		0x10000	/* force 32Gb connection (27XX only) */
5426054c3f6SMatt Jacob 
54353cff3bbSMatt Jacob /*
5442df76c16SMatt Jacob  * For each channel, the outer layers should know what role that channel
5452df76c16SMatt Jacob  * will take: ISP_ROLE_NONE, ISP_ROLE_INITIATOR, ISP_ROLE_TARGET,
5462df76c16SMatt Jacob  * ISP_ROLE_BOTH.
5477afb656fSMatt Jacob  *
5487afb656fSMatt Jacob  * If you set ISP_ROLE_NONE, the cards will be reset, new firmware loaded,
5497afb656fSMatt Jacob  * NVRAM read, and defaults set, but any further initialization (e.g.
5507afb656fSMatt Jacob  * INITIALIZE CONTROL BLOCK commands for 2X00 cards) won't be done.
5517afb656fSMatt Jacob  *
5527afb656fSMatt Jacob  * If INITIATOR MODE isn't set, attempts to run commands will be stopped
5532df76c16SMatt Jacob  * at isp_start and completed with the equivalent of SELECTION TIMEOUT.
5547afb656fSMatt Jacob  *
5557afb656fSMatt Jacob  * If TARGET MODE is set, it doesn't mean that the rest of target mode support
5567afb656fSMatt Jacob  * needs to be enabled, or will even work. What happens with the 2X00 cards
5577afb656fSMatt Jacob  * here is that if you have enabled it with TARGET MODE as part of the ICB
5587afb656fSMatt Jacob  * options, but you haven't given the f/w any ram resources for ATIOs or
5597afb656fSMatt Jacob  * Immediate Notifies, the f/w just handles what it can and you never see
5607afb656fSMatt Jacob  * anything. Basically, it sends a single byte of data (the first byte,
5617afb656fSMatt Jacob  * which you can set as part of the INITIALIZE CONTROL BLOCK command) for
5627afb656fSMatt Jacob  * INQUIRY, and sends back QUEUE FULL status for any other command.
5637afb656fSMatt Jacob  *
5647afb656fSMatt Jacob  */
5657afb656fSMatt Jacob #define	ISP_ROLE_NONE		0x0
566e0d3cfb7SMatt Jacob #define	ISP_ROLE_TARGET		0x1
567e0d3cfb7SMatt Jacob #define	ISP_ROLE_INITIATOR	0x2
5687afb656fSMatt Jacob #define	ISP_ROLE_BOTH		(ISP_ROLE_TARGET|ISP_ROLE_INITIATOR)
5697afb656fSMatt Jacob #define	ISP_ROLE_EITHER		ISP_ROLE_BOTH
5707afb656fSMatt Jacob #ifndef	ISP_DEFAULT_ROLES
571e2873b76SMatt Jacob /*
572e2873b76SMatt Jacob  * Counterintuitively, we prefer to default to role 'none'
573e2873b76SMatt Jacob  * if we are enable target mode support. This gives us the
574e2873b76SMatt Jacob  * maximum flexibility as to which port will do what.
575e2873b76SMatt Jacob  */
576e2873b76SMatt Jacob #ifdef	ISP_TARGET_MODE
577e2873b76SMatt Jacob #define	ISP_DEFAULT_ROLES	ISP_ROLE_NONE
578e2873b76SMatt Jacob #else
5797afb656fSMatt Jacob #define	ISP_DEFAULT_ROLES	ISP_ROLE_INITIATOR
5807afb656fSMatt Jacob #endif
581e2873b76SMatt Jacob #endif
5827afb656fSMatt Jacob 
5837afb656fSMatt Jacob 
5847afb656fSMatt Jacob /*
58553cff3bbSMatt Jacob  * Firmware related defines
58653cff3bbSMatt Jacob  */
58753cff3bbSMatt Jacob #define	ISP_CODE_ORG			0x1000	/* default f/w code start */
588126ec864SMatt Jacob #define	ISP_CODE_ORG_2300		0x0800	/* ..except for 2300s */
58910365e5aSMatt Jacob #define	ISP_CODE_ORG_2400		0x100000 /* ..and 2400s */
59012b36e2dSMatt Jacob #define	ISP_FW_REV(maj, min, mic)	((maj << 24) | (min << 16) | mic)
591f8597b62SMatt Jacob #define	ISP_FW_MAJOR(code)		((code >> 24) & 0xff)
592f8597b62SMatt Jacob #define	ISP_FW_MINOR(code)		((code >> 16) & 0xff)
593f8597b62SMatt Jacob #define	ISP_FW_MICRO(code)		((code >>  8) & 0xff)
59412b36e2dSMatt Jacob #define	ISP_FW_REVX(xp)			((xp[0]<<24) | (xp[1] << 16) | xp[2])
595f8597b62SMatt Jacob #define	ISP_FW_MAJORX(xp)		(xp[0])
596f8597b62SMatt Jacob #define	ISP_FW_MINORX(xp)		(xp[1])
597f8597b62SMatt Jacob #define	ISP_FW_MICROX(xp)		(xp[2])
598e347e2c9SMatt Jacob #define	ISP_FW_NEWER_THAN(i, major, minor, micro)		\
599e347e2c9SMatt Jacob  (ISP_FW_REVX((i)->isp_fwrev) > ISP_FW_REV(major, minor, micro))
60010365e5aSMatt Jacob #define	ISP_FW_OLDER_THAN(i, major, minor, micro)		\
60110365e5aSMatt Jacob  (ISP_FW_REVX((i)->isp_fwrev) < ISP_FW_REV(major, minor, micro))
60212b36e2dSMatt Jacob 
6036054c3f6SMatt Jacob /*
604478f8a96SJustin T. Gibbs  * Chip Types
6056054c3f6SMatt Jacob  */
6061b760be4SAlexander Motin #define	ISP_HA_FC_2400		0x04
6071b760be4SAlexander Motin #define	ISP_HA_FC_2500		0x05
6081b760be4SAlexander Motin #define	ISP_HA_FC_2600		0x06
6091b760be4SAlexander Motin #define	ISP_HA_FC_2700		0x07
6106054c3f6SMatt Jacob 
6112df76c16SMatt Jacob #define	IS_25XX(isp)	((isp)->isp_type >= ISP_HA_FC_2500)
612218be0b2SAlexander Motin #define	IS_26XX(isp)	((isp)->isp_type >= ISP_HA_FC_2600)
61314e084adSAlexander Motin #define	IS_27XX(isp)	((isp)->isp_type >= ISP_HA_FC_2700)
61483fbc566SMatt Jacob 
61553cff3bbSMatt Jacob /*
6161dae40ebSMatt Jacob  * DMA related macros
61753cff3bbSMatt Jacob  */
61810365e5aSMatt Jacob #define	DMA_WD3(x)	(((uint16_t)(((uint64_t)x) >> 48)) & 0xffff)
61910365e5aSMatt Jacob #define	DMA_WD2(x)	(((uint16_t)(((uint64_t)x) >> 32)) & 0xffff)
62010365e5aSMatt Jacob #define	DMA_WD1(x)	((uint16_t)((x) >> 16) & 0xffff)
62110365e5aSMatt Jacob #define	DMA_WD0(x)	((uint16_t)((x) & 0xffff))
62257c801f5SMatt Jacob 
6231dae40ebSMatt Jacob #define	DMA_LO32(x)	((uint32_t) (x))
6241dae40ebSMatt Jacob #define	DMA_HI32(x)	((uint32_t)(((uint64_t)x) >> 32))
6251dae40ebSMatt Jacob 
6266054c3f6SMatt Jacob /*
62753cff3bbSMatt Jacob  * Core System Function Prototypes
6286054c3f6SMatt Jacob  */
6296054c3f6SMatt Jacob 
6306054c3f6SMatt Jacob /*
6312df76c16SMatt Jacob  * Reset Hardware. Totally. Assumes that you'll follow this with a call to isp_init.
6326054c3f6SMatt Jacob  */
6332df76c16SMatt Jacob void isp_reset(ispsoftc_t *, int);
6346054c3f6SMatt Jacob 
6356054c3f6SMatt Jacob /*
6366054c3f6SMatt Jacob  * Initialize Hardware to known state
6376054c3f6SMatt Jacob  */
6381dae40ebSMatt Jacob void isp_init(ispsoftc_t *);
6396054c3f6SMatt Jacob 
6406054c3f6SMatt Jacob /*
641478f8a96SJustin T. Gibbs  * Reset the ISP and call completion for any orphaned commands.
642478f8a96SJustin T. Gibbs  */
643e68eef14SAlexander Motin int isp_reinit(ispsoftc_t *, int);
64401ff579dSMatt Jacob 
645478f8a96SJustin T. Gibbs /*
646a1fa0267SAlexander Motin  * Shutdown hardware after use.
647a1fa0267SAlexander Motin  */
648a1fa0267SAlexander Motin void isp_shutdown(ispsoftc_t *);
649a1fa0267SAlexander Motin 
650a1fa0267SAlexander Motin /*
651126ec864SMatt Jacob  * Internal Interrupt Service Routine
6526054c3f6SMatt Jacob  */
6530e6bc811SAlexander Motin #ifdef	ISP_TARGET_MODE
6540e6bc811SAlexander Motin void isp_intr_atioq(ispsoftc_t *);
6550e6bc811SAlexander Motin #endif
6560e6bc811SAlexander Motin void isp_intr_async(ispsoftc_t *, uint16_t event);
6570e6bc811SAlexander Motin void isp_intr_mbox(ispsoftc_t *, uint16_t mbox0);
6580e6bc811SAlexander Motin void isp_intr_respq(ispsoftc_t *);
659126ec864SMatt Jacob 
6606054c3f6SMatt Jacob 
6616054c3f6SMatt Jacob /*
66253cff3bbSMatt Jacob  * Command Entry Point- Platform Dependent layers call into this
6636054c3f6SMatt Jacob  */
664e2ec5cf0SMatt Jacob int isp_start(XS_T *);
6651dae40ebSMatt Jacob 
66653cff3bbSMatt Jacob /* these values are what isp_start returns */
66753cff3bbSMatt Jacob #define	CMD_COMPLETE	101	/* command completed */
66853cff3bbSMatt Jacob #define	CMD_EAGAIN	102	/* busy- maybe retry later */
669f6854a0cSAlexander Motin #define	CMD_RQLATER	103	/* requeue this command later */
67053cff3bbSMatt Jacob 
67153cff3bbSMatt Jacob /*
67253cff3bbSMatt Jacob  * Command Completion Point- Core layers call out from this with completed cmds
67353cff3bbSMatt Jacob  */
674e2ec5cf0SMatt Jacob void isp_done(XS_T *);
675478f8a96SJustin T. Gibbs 
676478f8a96SJustin T. Gibbs /*
677cbf57b47SMatt Jacob  * Platform Dependent to External to Internal Control Function
678478f8a96SJustin T. Gibbs  *
679410b5567SMatt Jacob  * Assumes locks are held on entry. You should note that with many of
6802df76c16SMatt Jacob  * these commands locks may be released while this function is called.
681478f8a96SJustin T. Gibbs  *
6822df76c16SMatt Jacob  * ... ISPCTL_RESET_BUS, int channel);
6832df76c16SMatt Jacob  *        Reset BUS on this channel
6842df76c16SMatt Jacob  * ... ISPCTL_RESET_DEV, int channel, int target);
6852df76c16SMatt Jacob  *        Reset Device on this channel at this target.
6862df76c16SMatt Jacob  * ... ISPCTL_ABORT_CMD, XS_T *xs);
6872df76c16SMatt Jacob  *        Abort active transaction described by xs.
6882df76c16SMatt Jacob  * ... IPCTL_UPDATE_PARAMS);
6892df76c16SMatt Jacob  *        Update any operating parameters (speed, etc.)
6902df76c16SMatt Jacob  * ... ISPCTL_FCLINK_TEST, int channel);
6912df76c16SMatt Jacob  *        Test FC link status on this channel
6922df76c16SMatt Jacob  * ... ISPCTL_SCAN_LOOP, int channel);
6932df76c16SMatt Jacob  *        Scan local loop on this channel
694b6bd5f7fSAlexander Motin  * ... ISPCTL_SCAN_FABRIC, int channel);
695b6bd5f7fSAlexander Motin  *        Scan fabric on this channel
6962df76c16SMatt Jacob  * ... ISPCTL_PDB_SYNC, int channel);
6972df76c16SMatt Jacob  *        Synchronize port database on this channel
6982df76c16SMatt Jacob  * ... ISPCTL_SEND_LIP, int channel);
6992df76c16SMatt Jacob  *        Send a LIP on this channel
7002df76c16SMatt Jacob  * ... ISPCTL_GET_NAMES, int channel, int np, uint64_t *wwnn, uint64_t *wwpn)
7012df76c16SMatt Jacob  *        Get a WWNN/WWPN for this N-port handle on this channel
702*156c1ebeSAlexander Motin  * ... ISPCTL_RUN_MBOXCMD, mbreg_t *mbp)
703*156c1ebeSAlexander Motin  *        Run this mailbox command
7042df76c16SMatt Jacob  * ... ISPCTL_GET_PDB, int channel, int nphandle, isp_pdb_t *pdb)
7052df76c16SMatt Jacob  *        Get PDB on this channel for this N-port handle
7062df76c16SMatt Jacob  * ... ISPCTL_PLOGX, isp_plcmd_t *)
7072df76c16SMatt Jacob  *        Performa a port login/logout
7086bef0aa0SAlexander Motin  * ... ISPCTL_CHANGE_ROLE, int channel, int role);
7096bef0aa0SAlexander Motin  *        Change role of specified channel
710410b5567SMatt Jacob  *
711410b5567SMatt Jacob  * ISPCTL_PDB_SYNC is somewhat misnamed. It actually is the final step, in
712b6bd5f7fSAlexander Motin  * order, of ISPCTL_FCLINK_TEST, ISPCTL_SCAN_LOOP, and ISPCTL_SCAN_FABRIC.
713410b5567SMatt Jacob  * The main purpose of ISPCTL_PDB_SYNC is to complete management of logging
714410b5567SMatt Jacob  * and logging out of fabric devices (if one is on a fabric) and then marking
715410b5567SMatt Jacob  * the 'loop state' as being ready to now be used for sending commands to
716b6bd5f7fSAlexander Motin  * devices.
717478f8a96SJustin T. Gibbs  */
718478f8a96SJustin T. Gibbs typedef enum {
7192df76c16SMatt Jacob 	ISPCTL_RESET_BUS,
7202df76c16SMatt Jacob 	ISPCTL_RESET_DEV,
7212df76c16SMatt Jacob 	ISPCTL_ABORT_CMD,
7222df76c16SMatt Jacob 	ISPCTL_UPDATE_PARAMS,
7232df76c16SMatt Jacob 	ISPCTL_FCLINK_TEST,
7242df76c16SMatt Jacob 	ISPCTL_SCAN_FABRIC,
7252df76c16SMatt Jacob 	ISPCTL_SCAN_LOOP,
7262df76c16SMatt Jacob 	ISPCTL_PDB_SYNC,
7272df76c16SMatt Jacob 	ISPCTL_SEND_LIP,
7282df76c16SMatt Jacob 	ISPCTL_GET_NAMES,
729*156c1ebeSAlexander Motin 	ISPCTL_RUN_MBOXCMD,
7302df76c16SMatt Jacob 	ISPCTL_GET_PDB,
7316bef0aa0SAlexander Motin 	ISPCTL_PLOGX,
7326bef0aa0SAlexander Motin 	ISPCTL_CHANGE_ROLE
733478f8a96SJustin T. Gibbs } ispctl_t;
7342df76c16SMatt Jacob int isp_control(ispsoftc_t *, ispctl_t, ...);
735cbf57b47SMatt Jacob 
736cbf57b47SMatt Jacob /*
737cbf57b47SMatt Jacob  * Platform Dependent to Internal to External Control Function
738cbf57b47SMatt Jacob  */
739cbf57b47SMatt Jacob 
740cbf57b47SMatt Jacob typedef enum {
74177d4e836SMatt Jacob 	ISPASYNC_LOOP_DOWN,		/* FC Loop Down */
74277d4e836SMatt Jacob 	ISPASYNC_LOOP_UP,		/* FC Loop Up */
7432df76c16SMatt Jacob 	ISPASYNC_LIP,			/* FC LIP Received */
7442df76c16SMatt Jacob 	ISPASYNC_LOOP_RESET,		/* FC Loop Reset Received */
745410b5567SMatt Jacob 	ISPASYNC_CHANGE_NOTIFY,		/* FC Change Notification */
7462df76c16SMatt Jacob 	ISPASYNC_DEV_ARRIVED,		/* FC Device Arrived */
7472df76c16SMatt Jacob 	ISPASYNC_DEV_CHANGED,		/* FC Device Changed */
7482df76c16SMatt Jacob 	ISPASYNC_DEV_STAYED,		/* FC Device Stayed */
7492df76c16SMatt Jacob 	ISPASYNC_DEV_GONE,		/* FC Device Departure */
7502df76c16SMatt Jacob 	ISPASYNC_TARGET_NOTIFY,		/* All target async notification */
751387d8239SMatt Jacob 	ISPASYNC_TARGET_NOTIFY_ACK,	/* All target notify ack required */
7522df76c16SMatt Jacob 	ISPASYNC_TARGET_ACTION,		/* All target action requested */
7532df76c16SMatt Jacob 	ISPASYNC_FW_CRASH,		/* All Firmware has crashed */
7542df76c16SMatt Jacob 	ISPASYNC_FW_RESTARTED		/* All Firmware has been restarted */
755cbf57b47SMatt Jacob } ispasync_t;
7562df76c16SMatt Jacob void isp_async(ispsoftc_t *, ispasync_t, ...);
757cbf57b47SMatt Jacob 
7582df76c16SMatt Jacob #define	ISPASYNC_CHANGE_PDB	0
7592df76c16SMatt Jacob #define	ISPASYNC_CHANGE_SNS	1
7602df76c16SMatt Jacob #define	ISPASYNC_CHANGE_OTHER	2
761410b5567SMatt Jacob 
762478f8a96SJustin T. Gibbs /*
76353cff3bbSMatt Jacob  * Platform Dependent Error and Debug Printout
764547725beSMatt Jacob  *
765670508b1SMatt Jacob  * Two required functions for each platform must be provided:
766547725beSMatt Jacob  *
7671dae40ebSMatt Jacob  *    void isp_prt(ispsoftc_t *, int level, const char *, ...)
768670508b1SMatt Jacob  *    void isp_xs_prt(ispsoftc_t *, XS_T *, int level, const char *, ...)
769547725beSMatt Jacob  *
770547725beSMatt Jacob  * but due to compiler differences on different platforms this won't be
771670508b1SMatt Jacob  * formally defined here. Instead, they go in each platform definition file.
772478f8a96SJustin T. Gibbs  */
773e9423e21SMatt Jacob 
77453cff3bbSMatt Jacob #define	ISP_LOGALL	0x0	/* log always */
77553cff3bbSMatt Jacob #define	ISP_LOGCONFIG	0x1	/* log configuration messages */
77653cff3bbSMatt Jacob #define	ISP_LOGINFO	0x2	/* log informational messages */
77753cff3bbSMatt Jacob #define	ISP_LOGWARN	0x4	/* log warning messages */
77853cff3bbSMatt Jacob #define	ISP_LOGERR	0x8	/* log error messages */
77953cff3bbSMatt Jacob #define	ISP_LOGDEBUG0	0x10	/* log simple debug messages */
78053cff3bbSMatt Jacob #define	ISP_LOGDEBUG1	0x20	/* log intermediate debug messages */
78153cff3bbSMatt Jacob #define	ISP_LOGDEBUG2	0x40	/* log most debug messages */
782b91862efSMatt Jacob #define	ISP_LOGDEBUG3	0x80	/* log high frequency debug messages */
783387d8239SMatt Jacob #define	ISP_LOG_SANCFG	0x100	/* log SAN configuration */
784670508b1SMatt Jacob #define	ISP_LOG_CWARN	0x200	/* log SCSI command "warnings" (e.g., check conditions) */
785387d8239SMatt Jacob #define	ISP_LOG_WARN1	0x400	/* log WARNS we might be interested at some time */
7862df76c16SMatt Jacob #define	ISP_LOGTINFO	0x1000	/* log informational messages (target mode) */
7872df76c16SMatt Jacob #define	ISP_LOGTDEBUG0	0x2000	/* log simple debug messages (target mode) */
7882df76c16SMatt Jacob #define	ISP_LOGTDEBUG1	0x4000	/* log intermediate debug messages (target) */
7892df76c16SMatt Jacob #define	ISP_LOGTDEBUG2	0x8000	/* log all debug messages (target) */
790478f8a96SJustin T. Gibbs 
79153cff3bbSMatt Jacob /*
79253cff3bbSMatt Jacob  * Each Platform provides it's own isposinfo substructure of the ispsoftc
79353cff3bbSMatt Jacob  * defined above.
79453cff3bbSMatt Jacob  *
79553cff3bbSMatt Jacob  * Each platform must also provide the following macros/defines:
79653cff3bbSMatt Jacob  *
79753cff3bbSMatt Jacob  *
7982df76c16SMatt Jacob  *	ISP_FC_SCRLEN				FC scratch area DMA length
79953cff3bbSMatt Jacob  *
8002df76c16SMatt Jacob  *	ISP_MEMZERO(dst, src)			platform zeroing function
8012df76c16SMatt Jacob  *	ISP_MEMCPY(dst, src, count)		platform copying function
8022df76c16SMatt Jacob  *	ISP_SNPRINTF(buf, bufsize, fmt, ...)	snprintf
8032df76c16SMatt Jacob  *	ISP_DELAY(usecs)			microsecond spindelay function
8042df76c16SMatt Jacob  *	ISP_SLEEP(isp, usecs)			microsecond sleep function
8052df76c16SMatt Jacob  *
8062df76c16SMatt Jacob  *	ISP_INLINE				___inline or not- depending on how
8072df76c16SMatt Jacob  *						good your debugger is
808898899d9SMatt Jacob  *	ISP_MIN					shorthand for ((a) < (b))? (a) : (b)
80953cff3bbSMatt Jacob  *
81053cff3bbSMatt Jacob  *	NANOTIME_T				nanosecond time type
81153cff3bbSMatt Jacob  *
81253cff3bbSMatt Jacob  *	GET_NANOTIME(NANOTIME_T *)		get current nanotime.
81353cff3bbSMatt Jacob  *
8141dae40ebSMatt Jacob  *	GET_NANOSEC(NANOTIME_T *)		get uint64_t from NANOTIME_T
81553cff3bbSMatt Jacob  *
81653cff3bbSMatt Jacob  *	NANOTIME_SUB(NANOTIME_T *, NANOTIME_T *)
81753cff3bbSMatt Jacob  *						subtract two NANOTIME_T values
81853cff3bbSMatt Jacob  *
8191dae40ebSMatt Jacob  *	MAXISPREQUEST(ispsoftc_t *)		maximum request queue size
82053cff3bbSMatt Jacob  *						for this particular board type
82153cff3bbSMatt Jacob  *
82237bb79f1SMarius Strobl  *	MEMORYBARRIER(ispsoftc_t *, barrier_type, offset, size, chan)
82353cff3bbSMatt Jacob  *
82453cff3bbSMatt Jacob  *		Function/Macro the provides memory synchronization on
82553cff3bbSMatt Jacob  *		various objects so that the ISP's and the system's view
82653cff3bbSMatt Jacob  *		of the same object is consistent.
82753cff3bbSMatt Jacob  *
8282df76c16SMatt Jacob  *	FC_SCRATCH_ACQUIRE(ispsoftc_t *, chan)	acquire lock on FC scratch area
8292df76c16SMatt Jacob  *						return -1 if you cannot
8302df76c16SMatt Jacob  *	FC_SCRATCH_RELEASE(ispsoftc_t *, chan)	acquire lock on FC scratch area
83153cff3bbSMatt Jacob  *
832ad0ab753SMatt Jacob  *	FCP_NEXT_CRN(ispsoftc_t *, XS_T *, rslt, channel, target, lun)	generate the next command reference number. XS_T * may be null.
833ad0ab753SMatt Jacob  *
83453cff3bbSMatt Jacob  *	SCSI_GOOD	SCSI 'Good' Status
83553cff3bbSMatt Jacob  *	SCSI_CHECK	SCSI 'Check Condition' Status
83653cff3bbSMatt Jacob  *	SCSI_BUSY	SCSI 'Busy' Status
83753cff3bbSMatt Jacob  *	SCSI_QFULL	SCSI 'Queue Full' Status
83853cff3bbSMatt Jacob  *
83953cff3bbSMatt Jacob  *	XS_T			Platform SCSI transaction type (i.e., command for HBA)
8401dae40ebSMatt Jacob  *	XS_DMA_ADDR_T		Platform PCI DMA Address Type
8412df76c16SMatt Jacob  *	XS_GET_DMA64_SEG(..)	Get 64 bit dma segment list value
84253cff3bbSMatt Jacob  *	XS_ISP(xs)		gets an instance out of an XS_T
84353cff3bbSMatt Jacob  *	XS_CHANNEL(xs)		gets the channel (bus # for DUALBUS cards) ""
84453cff3bbSMatt Jacob  *	XS_TGT(xs)		gets the target ""
84553cff3bbSMatt Jacob  *	XS_LUN(xs)		gets the lun ""
84653cff3bbSMatt Jacob  *	XS_CDBP(xs)		gets a pointer to the scsi CDB ""
84753cff3bbSMatt Jacob  *	XS_CDBLEN(xs)		gets the CDB's length ""
84853cff3bbSMatt Jacob  *	XS_XFRLEN(xs)		gets the associated data transfer length ""
849f6854a0cSAlexander Motin  *	XS_XFRIN(xs)		gets IN direction
850f6854a0cSAlexander Motin  *	XS_XFROUT(xs)		gets OUT direction
85131c161a6SAlexander Motin  *	XS_TIME(xs)		gets the time (in seconds) for this command
8522df76c16SMatt Jacob  *	XS_GET_RESID(xs)	gets the current residual count
8532df76c16SMatt Jacob  *	XS_GET_RESID(xs, resid)	sets the current residual count
85453cff3bbSMatt Jacob  *	XS_STSP(xs)		gets a pointer to the SCSI status byte ""
85553cff3bbSMatt Jacob  *	XS_SNSP(xs)		gets a pointer to the associate sense data
856387d8239SMatt Jacob  *	XS_TOT_SNSLEN(xs)	gets the total length of sense data storage
857453130d9SPedro F. Giffuni  *	XS_CUR_SNSLEN(xs)	gets the currently used length of sense data storage
85853cff3bbSMatt Jacob  *	XS_SNSKEY(xs)		dereferences XS_SNSP to get the current stored Sense Key
859670508b1SMatt Jacob  *	XS_SNSASC(xs)		dereferences XS_SNSP to get the current stored Additional Sense Code
860670508b1SMatt Jacob  *	XS_SNSASCQ(xs)		dereferences XS_SNSP to get the current stored Additional Sense Code Qualifier
86153cff3bbSMatt Jacob  *	XS_TAG_P(xs)		predicate of whether this command should be tagged
86253cff3bbSMatt Jacob  *	XS_TAG_TYPE(xs)		which type of tag to use
86388364968SAlexander Motin  *	XS_PRIORITY(xs)		command priority for SIMPLE tag
86453cff3bbSMatt Jacob  *	XS_SETERR(xs)		set error state
86553cff3bbSMatt Jacob  *
86653cff3bbSMatt Jacob  *		HBA_NOERROR	command has no erros
86753cff3bbSMatt Jacob  *		HBA_BOTCH	hba botched something
86853cff3bbSMatt Jacob  *		HBA_CMDTIMEOUT	command timed out
86953cff3bbSMatt Jacob  *		HBA_SELTIMEOUT	selection timed out (also port logouts for FC)
87053cff3bbSMatt Jacob  *		HBA_TGTBSY	target returned a BUSY status
87153cff3bbSMatt Jacob  *		HBA_BUSRESET	bus reset destroyed command
87253cff3bbSMatt Jacob  *		HBA_ABORTED	command was aborted (by request)
87353cff3bbSMatt Jacob  *		HBA_DATAOVR	a data overrun was detected
87453cff3bbSMatt Jacob  *		HBA_ARQFAIL	Automatic Request Sense failed
87553cff3bbSMatt Jacob  *
87653cff3bbSMatt Jacob  *	XS_ERR(xs)	return current error state
87753cff3bbSMatt Jacob  *	XS_NOERR(xs)	there is no error currently set
87853cff3bbSMatt Jacob  *	XS_INITERR(xs)	initialize error state
87953cff3bbSMatt Jacob  *
8802d24b6afSAlexander Motin  *	XS_SAVE_SENSE(xs, sp, len)	save sense data
881387d8239SMatt Jacob  *	XS_APPEND_SENSE(xs, sp, len)	append more sense data
88253cff3bbSMatt Jacob  *
883670508b1SMatt Jacob  *	XS_SENSE_VALID(xs)		indicates whether sense is valid
884670508b1SMatt Jacob  *
8851dae40ebSMatt Jacob  *	DEFAULT_FRAMESIZE(ispsoftc_t *)		Default Frame Size
8862df76c16SMatt Jacob  *
8873e6deb33SAlexander Motin  *	DEFAULT_ROLE(ispsoftc_t *, int)		Get Default Role for a channel
8882df76c16SMatt Jacob  *	DEFAULT_LOOPID(ispsoftc_t *, int)	Default FC Loop ID
8892df76c16SMatt Jacob  *
8909cf43b97SMatt Jacob  *		These establish reasonable defaults for each platform.
8919cf43b97SMatt Jacob  * 		These must be available independent of card NVRAM and are
8929cf43b97SMatt Jacob  *		to be used should NVRAM not be readable.
89353cff3bbSMatt Jacob  *
8942df76c16SMatt Jacob  *	DEFAULT_NODEWWN(ispsoftc_t *, chan)	Default FC Node WWN to use
8952df76c16SMatt Jacob  *	DEFAULT_PORTWWN(ispsoftc_t *, chan)	Default FC Port WWN to use
89653cff3bbSMatt Jacob  *
8972df76c16SMatt Jacob  *		These defines are hooks to allow the setting of node and
8982df76c16SMatt Jacob  *		port WWNs when NVRAM cannot be read or is to be overriden.
89953cff3bbSMatt Jacob  *
9002df76c16SMatt Jacob  *	ACTIVE_NODEWWN(ispsoftc_t *, chan)	FC Node WWN to use
9012df76c16SMatt Jacob  *	ACTIVE_PORTWWN(ispsoftc_t *, chan)	FC Port WWN to use
9022df76c16SMatt Jacob  *
9032df76c16SMatt Jacob  *		After NVRAM is read, these will be invoked to get the
9042df76c16SMatt Jacob  *		node and port WWNs that will actually be used for this
9052df76c16SMatt Jacob  *		channel.
9062df76c16SMatt Jacob  *
9074fd13c1bSMatt Jacob  *
9081dae40ebSMatt Jacob  *	ISP_IOXPUT_8(ispsoftc_t *, uint8_t srcval, uint8_t *dstptr)
9091dae40ebSMatt Jacob  *	ISP_IOXPUT_16(ispsoftc_t *, uint16_t srcval, uint16_t *dstptr)
9101dae40ebSMatt Jacob  *	ISP_IOXPUT_32(ispsoftc_t *, uint32_t srcval, uint32_t *dstptr)
9114fd13c1bSMatt Jacob  *
9121dae40ebSMatt Jacob  *	ISP_IOXGET_8(ispsoftc_t *, uint8_t *srcptr, uint8_t dstrval)
9131dae40ebSMatt Jacob  *	ISP_IOXGET_16(ispsoftc_t *, uint16_t *srcptr, uint16_t dstrval)
9141dae40ebSMatt Jacob  *	ISP_IOXGET_32(ispsoftc_t *, uint32_t *srcptr, uint32_t dstrval)
9154fd13c1bSMatt Jacob  *
9161dae40ebSMatt Jacob  *	ISP_SWIZZLE_NVRAM_WORD(ispsoftc_t *, uint16_t *)
9174607e8eeSMatt Jacob  *	ISP_SWIZZLE_NVRAM_LONG(ispsoftc_t *, uint32_t *)
9184607e8eeSMatt Jacob  *	ISP_SWAP16(ispsoftc_t *, uint16_t srcval)
9194607e8eeSMatt Jacob  *	ISP_SWAP32(ispsoftc_t *, uint32_t srcval)
92053cff3bbSMatt Jacob  */
9215d571944SMatt Jacob 
9222df76c16SMatt Jacob #ifdef	ISP_TARGET_MODE
9232df76c16SMatt Jacob /*
9242df76c16SMatt Jacob  * The functions below are for the publicly available
9252df76c16SMatt Jacob  * target mode functions that are internal to the Qlogic driver.
9262df76c16SMatt Jacob  */
9272df76c16SMatt Jacob 
9282df76c16SMatt Jacob /*
9292df76c16SMatt Jacob  * This function handles new response queue entry appropriate for target mode.
9302df76c16SMatt Jacob  */
931b8e2395eSAlexander Motin int isp_target_notify(ispsoftc_t *, void *, uint32_t *, uint16_t);
9322df76c16SMatt Jacob 
9332df76c16SMatt Jacob /*
9342df76c16SMatt Jacob  * This function externalizes the ability to acknowledge an Immediate Notify request.
9352df76c16SMatt Jacob  */
9362df76c16SMatt Jacob int isp_notify_ack(ispsoftc_t *, void *);
9372df76c16SMatt Jacob 
9382df76c16SMatt Jacob /*
9392df76c16SMatt Jacob  * This function externalized acknowledging (success/fail) an ABTS frame
9402df76c16SMatt Jacob  */
9412df76c16SMatt Jacob int isp_acknak_abts(ispsoftc_t *, void *, int);
9422df76c16SMatt Jacob 
9432df76c16SMatt Jacob /*
9442df76c16SMatt Jacob  * General routine to send a final CTIO for a command- used mostly for
9452df76c16SMatt Jacob  * local responses.
9462df76c16SMatt Jacob  */
9472df76c16SMatt Jacob int isp_endcmd(ispsoftc_t *, ...);
9482df76c16SMatt Jacob #define	ECMD_SVALID	0x100
949352427b3SAlexander Motin #define	ECMD_RVALID	0x200
950352427b3SAlexander Motin #define	ECMD_TERMINATE	0x400
9512df76c16SMatt Jacob 
9522df76c16SMatt Jacob /*
9532df76c16SMatt Jacob  * Handle an asynchronous event
9542df76c16SMatt Jacob  */
9559c2e9bcfSAlexander Motin void isp_target_async(ispsoftc_t *, int, int);
9562df76c16SMatt Jacob #endif
9576054c3f6SMatt Jacob #endif	/* _ISPVAR_H */
958