Home | History | Annotate | Line # | Download | only in ic
ispvar.h revision 1.29
      1  1.29   mjacob /* $NetBSD: ispvar.h,v 1.29 2000/02/12 02:29:00 mjacob Exp $ */
      2   1.1      cgd /*
      3  1.24   mjacob  * Copyright (C) 1999 National Aeronautics & Space Administration
      4  1.23   mjacob  * All rights reserved.
      5   1.1      cgd  *
      6   1.1      cgd  * Redistribution and use in source and binary forms, with or without
      7   1.1      cgd  * modification, are permitted provided that the following conditions
      8   1.1      cgd  * are met:
      9   1.1      cgd  * 1. Redistributions of source code must retain the above copyright
     10  1.23   mjacob  *    notice, this list of conditions and the following disclaimer.
     11   1.1      cgd  * 2. Redistributions in binary form must reproduce the above copyright
     12   1.1      cgd  *    notice, this list of conditions and the following disclaimer in the
     13   1.1      cgd  *    documentation and/or other materials provided with the distribution.
     14   1.1      cgd  * 3. The name of the author may not be used to endorse or promote products
     15  1.23   mjacob  *    derived from this software without specific prior written permission
     16   1.9   mjacob  *
     17  1.23   mjacob  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     18  1.23   mjacob  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     19  1.23   mjacob  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     20  1.23   mjacob  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     21  1.23   mjacob  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     22  1.23   mjacob  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     23  1.23   mjacob  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     24  1.23   mjacob  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     25  1.23   mjacob  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     26  1.23   mjacob  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     27   1.1      cgd  */
     28   1.2      cgd 
     29  1.23   mjacob /*
     30  1.23   mjacob  * Soft Definitions for for Qlogic ISP SCSI adapters.
     31  1.23   mjacob  * Matthew Jacob <mjacob (at) nas.nasa.gov>
     32  1.23   mjacob  */
     33   1.1      cgd #ifndef	_ISPVAR_H
     34   1.1      cgd #define	_ISPVAR_H
     35   1.1      cgd 
     36  1.19   mjacob #if defined(__NetBSD__) || defined(__OpenBSD__)
     37   1.1      cgd #include <dev/ic/ispmbox.h>
     38  1.26   mjacob #ifdef	ISP_TARGET_MODE
     39  1.26   mjacob #include <dev/ic/isp_target.h>
     40  1.29   mjacob #include <dev/ic/isp_tpublic.h>
     41  1.26   mjacob #endif
     42   1.9   mjacob #endif
     43   1.9   mjacob #ifdef	__FreeBSD__
     44   1.9   mjacob #include <dev/isp/ispmbox.h>
     45  1.26   mjacob #ifdef	ISP_TARGET_MODE
     46  1.26   mjacob #include <dev/isp/isp_target.h>
     47  1.29   mjacob #include <dev/isp/isp_tpublic.h>
     48  1.26   mjacob #endif
     49   1.9   mjacob #endif
     50   1.9   mjacob #ifdef	__linux__
     51  1.15   mjacob #include "ispmbox.h"
     52  1.26   mjacob #ifdef	ISP_TARGET_MODE
     53  1.26   mjacob #include "isp_target.h"
     54  1.29   mjacob #include "isp_tpublic.h"
     55  1.26   mjacob #endif
     56   1.9   mjacob #endif
     57   1.1      cgd 
     58  1.10   mjacob #define	ISP_CORE_VERSION_MAJOR	1
     59  1.28   mjacob #define	ISP_CORE_VERSION_MINOR	12
     60  1.10   mjacob 
     61   1.1      cgd /*
     62  1.17   mjacob  * Vector for bus specific code to provide specific services.
     63   1.1      cgd  */
     64   1.1      cgd struct ispsoftc;
     65   1.1      cgd struct ispmdvec {
     66   1.1      cgd 	u_int16_t	(*dv_rd_reg) __P((struct ispsoftc *, int));
     67   1.1      cgd 	void		(*dv_wr_reg) __P((struct ispsoftc *, int, u_int16_t));
     68   1.5  thorpej 	int		(*dv_mbxdma) __P((struct ispsoftc *));
     69   1.1      cgd 	int		(*dv_dmaset) __P((struct ispsoftc *,
     70  1.26   mjacob 		ISP_SCSI_XFER_T *, ispreq_t *, u_int16_t *, u_int16_t));
     71   1.1      cgd 	void		(*dv_dmaclr)
     72   1.9   mjacob 		__P((struct ispsoftc *, ISP_SCSI_XFER_T *, u_int32_t));
     73   1.1      cgd 	void		(*dv_reset0) __P((struct ispsoftc *));
     74   1.1      cgd 	void		(*dv_reset1) __P((struct ispsoftc *));
     75   1.6   mjacob 	void		(*dv_dregs) __P((struct ispsoftc *));
     76   1.3  mycroft 	const u_int16_t *dv_ispfw;	/* ptr to f/w */
     77   1.1      cgd 	u_int16_t 	dv_fwlen;	/* length of f/w */
     78   1.1      cgd 	u_int16_t	dv_codeorg;	/* code ORG for f/w */
     79  1.24   mjacob 	u_int32_t	dv_fwrev;	/* f/w revision */
     80   1.1      cgd 	/*
     81   1.1      cgd 	 * Initial values for conf1 register
     82   1.1      cgd 	 */
     83   1.1      cgd 	u_int16_t	dv_conf1;
     84   1.4   mjacob 	u_int16_t	dv_clock;	/* clock frequency */
     85   1.1      cgd };
     86   1.1      cgd 
     87   1.1      cgd #define	MAX_TARGETS	16
     88  1.19   mjacob #ifdef	ISP2100_FABRIC
     89  1.19   mjacob #define	MAX_FC_TARG	256
     90  1.19   mjacob #else
     91   1.6   mjacob #define	MAX_FC_TARG	126
     92  1.19   mjacob #endif
     93   1.1      cgd 
     94  1.24   mjacob #define	ISP_MAX_TARGETS(isp)	(IS_FC(isp)? MAX_FC_TARG : MAX_TARGETS)
     95  1.24   mjacob #ifdef	ISP2100_SCCLUN
     96  1.24   mjacob #define	_ISP_FC_LUN(isp)	65536
     97  1.24   mjacob #else
     98  1.24   mjacob #define	_ISP_FC_LUN(isp)	16
     99  1.24   mjacob #endif
    100  1.24   mjacob #define	_ISP_SCSI_LUN(isp)	\
    101  1.25   mjacob 	((ISP_FW_REVX(isp->isp_fwrev) >= ISP_FW_REV(7, 55, 0))? 32 : 8)
    102  1.24   mjacob #define	ISP_MAX_LUNS(isp)	\
    103  1.24   mjacob 	(IS_FC(isp)? _ISP_FC_LUN(isp) : _ISP_SCSI_LUN(isp))
    104  1.24   mjacob 
    105  1.26   mjacob 
    106  1.26   mjacob /*
    107  1.26   mjacob  * Macros to read, write ISP registers through bus specific code.
    108  1.26   mjacob  */
    109  1.26   mjacob 
    110  1.26   mjacob #define	ISP_READ(isp, reg)	\
    111  1.26   mjacob 	(*(isp)->isp_mdvec->dv_rd_reg)((isp), (reg))
    112  1.26   mjacob 
    113  1.26   mjacob #define	ISP_WRITE(isp, reg, val)	\
    114  1.26   mjacob 	(*(isp)->isp_mdvec->dv_wr_reg)((isp), (reg), (val))
    115  1.26   mjacob 
    116  1.26   mjacob #define	ISP_MBOXDMASETUP(isp)	\
    117  1.26   mjacob 	(*(isp)->isp_mdvec->dv_mbxdma)((isp))
    118  1.26   mjacob 
    119  1.26   mjacob #define	ISP_DMASETUP(isp, xs, req, iptrp, optr)	\
    120  1.26   mjacob 	(*(isp)->isp_mdvec->dv_dmaset)((isp), (xs), (req), (iptrp), (optr))
    121  1.26   mjacob 
    122  1.26   mjacob #define	ISP_DMAFREE(isp, xs, hndl)	\
    123  1.26   mjacob 	if ((isp)->isp_mdvec->dv_dmaclr) \
    124  1.26   mjacob 	    (*(isp)->isp_mdvec->dv_dmaclr)((isp), (xs), (hndl))
    125  1.26   mjacob 
    126  1.26   mjacob #define	ISP_RESET0(isp)	\
    127  1.26   mjacob 	if ((isp)->isp_mdvec->dv_reset0) (*(isp)->isp_mdvec->dv_reset0)((isp))
    128  1.26   mjacob #define	ISP_RESET1(isp)	\
    129  1.26   mjacob 	if ((isp)->isp_mdvec->dv_reset1) (*(isp)->isp_mdvec->dv_reset1)((isp))
    130  1.26   mjacob #define	ISP_DUMPREGS(isp)	\
    131  1.26   mjacob 	if ((isp)->isp_mdvec->dv_dregs) (*(isp)->isp_mdvec->dv_dregs)((isp))
    132  1.26   mjacob 
    133  1.26   mjacob #define	ISP_SETBITS(isp, reg, val)	\
    134  1.26   mjacob  (*(isp)->isp_mdvec->dv_wr_reg)((isp), (reg), ISP_READ((isp), (reg)) | (val))
    135  1.26   mjacob 
    136  1.26   mjacob #define	ISP_CLRBITS(isp, reg, val)	\
    137  1.26   mjacob  (*(isp)->isp_mdvec->dv_wr_reg)((isp), (reg), ISP_READ((isp), (reg)) & ~(val))
    138  1.26   mjacob 
    139  1.24   mjacob /* this is the size of a queue entry (request and response) */
    140  1.11   mjacob #define	QENTRY_LEN			64
    141  1.24   mjacob /* both request and result queue length must be a power of two */
    142  1.11   mjacob #define	RQUEST_QUEUE_LEN		MAXISPREQUEST
    143  1.24   mjacob /* I've seen wierdnesses with the result queue < 64 */
    144  1.24   mjacob #if	MAXISPREQUEST > 64
    145  1.19   mjacob #define	RESULT_QUEUE_LEN		(MAXISPREQUEST/2)
    146  1.24   mjacob #else
    147  1.24   mjacob #define	RESULT_QUEUE_LEN		MAXISPREQUEST
    148  1.24   mjacob #endif
    149  1.11   mjacob #define	ISP_QUEUE_ENTRY(q, idx)		((q) + ((idx) * QENTRY_LEN))
    150  1.11   mjacob #define	ISP_QUEUE_SIZE(n)		((n) * QENTRY_LEN)
    151  1.11   mjacob #define	ISP_NXT_QENTRY(idx, qlen)	(((idx) + 1) & ((qlen)-1))
    152  1.25   mjacob #define	ISP_QAVAIL(in, out, qlen)	\
    153  1.13   mjacob 	((in == out)? (qlen - 1) : ((in > out)? \
    154  1.25   mjacob 	((qlen - 1) - (in - out)) : (out - in - 1)))
    155  1.26   mjacob 
    156  1.26   mjacob #define	ISP_ADD_REQUEST(isp, iptr)	\
    157  1.26   mjacob 	ISP_WRITE(isp, INMAILBOX4, iptr), isp->isp_reqidx = iptr
    158  1.26   mjacob 
    159   1.1      cgd /*
    160  1.22   mjacob  * SCSI Specific Host Adapter Parameters- per bus, per target
    161   1.6   mjacob  */
    162   1.6   mjacob 
    163   1.6   mjacob typedef struct {
    164  1.22   mjacob 	u_int		isp_gotdparms		: 1,
    165  1.25   mjacob 			isp_req_ack_active_neg	: 1,
    166  1.25   mjacob 			isp_data_line_active_neg: 1,
    167   1.6   mjacob 			isp_cmd_dma_burst_enable: 1,
    168   1.6   mjacob 			isp_data_dma_burst_enabl: 1,
    169  1.16   mjacob 			isp_fifo_threshold	: 3,
    170  1.17   mjacob 			isp_ultramode		: 1,
    171   1.6   mjacob 			isp_diffmode		: 1,
    172  1.20   mjacob 			isp_lvdmode		: 1,
    173  1.22   mjacob 						: 1,
    174   1.6   mjacob 			isp_initiator_id	: 4,
    175  1.25   mjacob 			isp_async_data_setup	: 4;
    176  1.25   mjacob 	u_int16_t	isp_selection_timeout;
    177  1.25   mjacob 	u_int16_t	isp_max_queue_depth;
    178   1.6   mjacob 	u_int8_t	isp_tag_aging;
    179  1.25   mjacob 	u_int8_t	isp_bus_reset_delay;
    180  1.25   mjacob 	u_int8_t	isp_retry_count;
    181  1.25   mjacob 	u_int8_t	isp_retry_delay;
    182   1.6   mjacob 	struct {
    183  1.22   mjacob 		u_int	dev_enable	:	1,	/* ignored */
    184  1.22   mjacob 					:	1,
    185  1.17   mjacob 			dev_update	:	1,
    186  1.17   mjacob 			dev_refresh	:	1,
    187  1.20   mjacob 			exc_throttle	:	8,
    188  1.20   mjacob 			cur_offset	:	4,
    189  1.20   mjacob 			sync_offset	:	4;
    190  1.20   mjacob 		u_int8_t	cur_period;	/* current sync period */
    191  1.20   mjacob 		u_int8_t	sync_period;	/* goal sync period */
    192  1.20   mjacob 		u_int16_t	dev_flags;	/* goal device flags */
    193  1.20   mjacob 		u_int16_t	cur_dflags;	/* current device flags */
    194   1.6   mjacob 	} isp_devparam[MAX_TARGETS];
    195  1.22   mjacob } sdparam;
    196   1.6   mjacob 
    197   1.6   mjacob /*
    198   1.6   mjacob  * Device Flags
    199   1.6   mjacob  */
    200  1.11   mjacob #define	DPARM_DISC	0x8000
    201  1.11   mjacob #define	DPARM_PARITY	0x4000
    202  1.11   mjacob #define	DPARM_WIDE	0x2000
    203  1.11   mjacob #define	DPARM_SYNC	0x1000
    204  1.11   mjacob #define	DPARM_TQING	0x0800
    205  1.11   mjacob #define	DPARM_ARQ	0x0400
    206  1.11   mjacob #define	DPARM_QFRZ	0x0200
    207  1.11   mjacob #define	DPARM_RENEG	0x0100
    208  1.11   mjacob #define	DPARM_NARROW	0x0080	/* Possibly only available with >= 7.55 fw */
    209  1.11   mjacob #define	DPARM_ASYNC	0x0040	/* Possibly only available with >= 7.55 fw */
    210  1.18   mjacob #define	DPARM_DEFAULT	(0xFF00 & ~DPARM_QFRZ)
    211  1.11   mjacob #define	DPARM_SAFE_DFLT	(DPARM_DEFAULT & ~(DPARM_WIDE|DPARM_SYNC|DPARM_TQING))
    212  1.11   mjacob 
    213   1.6   mjacob 
    214  1.20   mjacob /* technically, not really correct, as they need to be rated based upon clock */
    215  1.20   mjacob #define	ISP_40M_SYNCPARMS	0x080a
    216  1.25   mjacob #define	ISP_20M_SYNCPARMS	0x080c
    217  1.25   mjacob #define	ISP_10M_SYNCPARMS	0x0c19
    218  1.25   mjacob #define	ISP_08M_SYNCPARMS	0x0c25
    219  1.25   mjacob #define	ISP_05M_SYNCPARMS	0x0c32
    220  1.25   mjacob #define	ISP_04M_SYNCPARMS	0x0c41
    221   1.6   mjacob 
    222   1.6   mjacob /*
    223   1.6   mjacob  * Fibre Channel Specifics
    224   1.6   mjacob  */
    225  1.24   mjacob #define	FL_PORT_ID		0x7e	/* FL_Port Special ID */
    226  1.24   mjacob #define	FC_PORT_ID		0x7f	/* Fabric Controller Special ID */
    227  1.24   mjacob #define	FC_SNS_ID		0x80	/* SNS Server Special ID */
    228  1.24   mjacob 
    229   1.6   mjacob typedef struct {
    230  1.25   mjacob 	u_int32_t		isp_fwoptions	: 16,
    231  1.23   mjacob 						: 7,
    232  1.23   mjacob 				loop_seen_once	: 1,
    233  1.23   mjacob 				isp_loopstate	: 3,	/* Current Loop State */
    234  1.23   mjacob 				isp_fwstate	: 3,	/* ISP F/W state */
    235  1.23   mjacob 				isp_gotdparms	: 1,
    236  1.23   mjacob 				isp_onfabric	: 1;
    237  1.11   mjacob 	u_int8_t		isp_loopid;	/* hard loop id */
    238  1.11   mjacob 	u_int8_t		isp_alpa;	/* ALPA */
    239  1.25   mjacob 	volatile u_int16_t	isp_lipseq;	/* LIP sequence # */
    240  1.23   mjacob 	u_int32_t		isp_portid;
    241  1.11   mjacob 	u_int8_t		isp_execthrottle;
    242  1.25   mjacob 	u_int8_t		isp_retry_delay;
    243  1.25   mjacob 	u_int8_t		isp_retry_count;
    244  1.25   mjacob 	u_int8_t		isp_reserved;
    245  1.11   mjacob 	u_int16_t		isp_maxalloc;
    246  1.11   mjacob 	u_int16_t		isp_maxfrmlen;
    247  1.23   mjacob 	u_int64_t		isp_nodewwn;
    248  1.23   mjacob 	u_int64_t		isp_portwwn;
    249   1.6   mjacob 	/*
    250  1.23   mjacob 	 * Port Data Base. This is indexed by 'target', which is invariate.
    251  1.23   mjacob 	 * However, elements within can move around due to loop changes,
    252  1.23   mjacob 	 * so the actual loop ID passed to the F/W is in this structure.
    253  1.23   mjacob 	 * The first time the loop is seen up, loopid will match the index
    254  1.23   mjacob 	 * (except for fabric nodes which are above mapped above FC_SNS_ID
    255  1.23   mjacob 	 * and are completely virtual), but subsequent LIPs can cause things
    256  1.23   mjacob 	 * to move around.
    257  1.23   mjacob 	 */
    258  1.23   mjacob 	struct lportdb {
    259  1.25   mjacob 		u_int
    260  1.23   mjacob 					loopid	: 8,
    261  1.23   mjacob 						: 4,
    262  1.23   mjacob 					fabdev	: 1,
    263  1.23   mjacob 					roles	: 2,
    264  1.23   mjacob 					valid	: 1;
    265  1.25   mjacob 		u_int32_t		portid;
    266  1.23   mjacob 		u_int64_t		node_wwn;
    267  1.23   mjacob 		u_int64_t		port_wwn;
    268  1.24   mjacob 	} portdb[MAX_FC_TARG], tport[FL_PORT_ID];
    269  1.19   mjacob 
    270  1.19   mjacob 	/*
    271   1.6   mjacob 	 * Scratch DMA mapped in area to fetch Port Database stuff, etc.
    272   1.6   mjacob 	 */
    273  1.23   mjacob 	caddr_t			isp_scratch;
    274   1.6   mjacob 	u_int32_t		isp_scdma;
    275   1.6   mjacob } fcparam;
    276   1.6   mjacob 
    277  1.23   mjacob #define	FW_CONFIG_WAIT		0
    278  1.23   mjacob #define	FW_WAIT_AL_PA		1
    279  1.23   mjacob #define	FW_WAIT_LOGIN		2
    280  1.23   mjacob #define	FW_READY		3
    281  1.23   mjacob #define	FW_LOSS_OF_SYNC		4
    282  1.23   mjacob #define	FW_ERROR		5
    283  1.23   mjacob #define	FW_REINIT		6
    284  1.23   mjacob #define	FW_NON_PART		7
    285  1.23   mjacob 
    286  1.23   mjacob #define	LOOP_NIL		0
    287  1.23   mjacob #define	LOOP_LIP_RCVD		1
    288  1.23   mjacob #define	LOOP_PDB_RCVD		2
    289  1.23   mjacob #define	LOOP_READY		7
    290  1.23   mjacob 
    291   1.6   mjacob /*
    292   1.1      cgd  * Soft Structure per host adapter
    293   1.1      cgd  */
    294   1.1      cgd struct ispsoftc {
    295   1.9   mjacob 	/*
    296   1.9   mjacob 	 * Platform (OS) specific data
    297   1.9   mjacob 	 */
    298   1.9   mjacob 	struct isposinfo	isp_osinfo;
    299   1.9   mjacob 
    300   1.9   mjacob 	/*
    301  1.26   mjacob 	 * Pointer to bus specific functions and data
    302   1.9   mjacob 	 */
    303   1.1      cgd 	struct ispmdvec *	isp_mdvec;
    304   1.9   mjacob 
    305   1.9   mjacob 	/*
    306  1.26   mjacob 	 * (Mostly) nonvolatile state. Board specific parameters
    307  1.26   mjacob 	 * may contain some volatile state (e.g., current loop state).
    308   1.9   mjacob 	 */
    309   1.9   mjacob 
    310  1.26   mjacob 	void * 			isp_param;	/* type specific */
    311  1.26   mjacob 	u_int16_t		isp_fwrev[3];	/* Loaded F/W revision */
    312  1.26   mjacob 	u_int16_t		isp_romfw_rev[3]; /* PROM F/W revision */
    313  1.26   mjacob 	u_int16_t		isp_maxcmds;	/* max possible I/O cmds */
    314  1.26   mjacob 	u_int8_t		isp_type;	/* HBA Chip Type */
    315  1.26   mjacob 	u_int8_t		isp_revision;	/* HBA Chip H/W Revision */
    316  1.26   mjacob 
    317  1.26   mjacob 	u_int32_t				: 4,
    318  1.26   mjacob 				isp_touched	: 1,	/* board ever seen? */
    319  1.26   mjacob 				isp_fast_mttr	: 1,	/* fast sram */
    320  1.26   mjacob 				isp_bustype	: 1,	/* SBus or PCI */
    321  1.26   mjacob 				isp_dogactive	: 1,	/* watchdog running */
    322  1.26   mjacob 				isp_dblev	: 8,	/* debug level */
    323  1.26   mjacob 				isp_clock	: 8,	/* input clock */
    324  1.26   mjacob 				isp_confopts	: 8;	/* config options */
    325   1.6   mjacob 
    326   1.1      cgd 	/*
    327  1.11   mjacob 	 * Volatile state
    328   1.1      cgd 	 */
    329  1.11   mjacob 
    330  1.26   mjacob 	volatile u_int32_t	:	9,
    331  1.11   mjacob 		isp_state	:	3,
    332  1.22   mjacob 		isp_sendmarker	:	2,	/* send a marker entry */
    333  1.22   mjacob 		isp_update	:	2,	/* update parameters */
    334  1.24   mjacob 		isp_nactive	:	16;	/* how many commands active */
    335   1.6   mjacob 
    336  1.24   mjacob 	volatile u_int16_t	isp_reqodx;	/* index of last ISP pickup */
    337  1.24   mjacob 	volatile u_int16_t	isp_reqidx;	/* index of next request */
    338  1.24   mjacob 	volatile u_int16_t	isp_residx;	/* index of next result */
    339  1.24   mjacob 	volatile u_int16_t	isp_lasthdls;	/* last handle seed */
    340   1.6   mjacob 
    341   1.1      cgd 	/*
    342  1.26   mjacob 	 * Active commands are stored here, indexed by handle functions.
    343   1.1      cgd 	 */
    344  1.24   mjacob 	ISP_SCSI_XFER_T **isp_xflist;
    345   1.6   mjacob 
    346   1.1      cgd 	/*
    347  1.24   mjacob 	 * request/result queue pointers and dma handles for them.
    348   1.1      cgd 	 */
    349  1.23   mjacob 	caddr_t			isp_rquest;
    350  1.23   mjacob 	caddr_t			isp_result;
    351   1.5  thorpej 	u_int32_t		isp_rquest_dma;
    352   1.5  thorpej 	u_int32_t		isp_result_dma;
    353  1.24   mjacob };
    354  1.14   mjacob 
    355  1.24   mjacob #define	SDPARAM(isp)	((sdparam *) (isp)->isp_param)
    356  1.24   mjacob #define	FCPARAM(isp)	((fcparam *) (isp)->isp_param)
    357   1.1      cgd 
    358   1.1      cgd /*
    359   1.9   mjacob  * ISP States
    360   1.9   mjacob  */
    361   1.9   mjacob #define	ISP_NILSTATE	0
    362   1.9   mjacob #define	ISP_RESETSTATE	1
    363   1.9   mjacob #define	ISP_INITSTATE	2
    364   1.9   mjacob #define	ISP_RUNSTATE	3
    365   1.9   mjacob 
    366   1.9   mjacob /*
    367   1.9   mjacob  * ISP Configuration Options
    368   1.9   mjacob  */
    369   1.9   mjacob #define	ISP_CFG_NORELOAD	0x80	/* don't download f/w */
    370  1.18   mjacob #define	ISP_CFG_NONVRAM		0x40	/* ignore NVRAM */
    371  1.26   mjacob #define	ISP_CFG_FULL_DUPLEX	0x01	/* Full Duplex (Fibre Channel only) */
    372  1.26   mjacob #define	ISP_CFG_OWNWWN		0x02	/* override NVRAM wwn */
    373  1.29   mjacob #define	ISP_CFG_NPORT		0x04	/* try to force N- instead of L-Port */
    374   1.9   mjacob 
    375  1.21   mjacob #define	ISP_FW_REV(maj, min, mic)	((maj << 24) | (min << 16) | mic)
    376  1.22   mjacob #define	ISP_FW_REVX(xp)	((xp[0]<<24) | (xp[1] << 16) | xp[2])
    377  1.11   mjacob 
    378   1.9   mjacob /*
    379  1.11   mjacob  * Bus (implementation) types
    380  1.11   mjacob  */
    381  1.11   mjacob #define	ISP_BT_PCI		0	/* PCI Implementations */
    382  1.11   mjacob #define	ISP_BT_SBUS		1	/* SBus Implementations */
    383  1.11   mjacob 
    384  1.11   mjacob /*
    385  1.11   mjacob  * Chip Types
    386   1.6   mjacob  */
    387   1.6   mjacob #define	ISP_HA_SCSI		0xf
    388  1.11   mjacob #define	ISP_HA_SCSI_UNKNOWN	0x1
    389  1.11   mjacob #define	ISP_HA_SCSI_1020	0x2
    390  1.11   mjacob #define	ISP_HA_SCSI_1020A	0x3
    391  1.11   mjacob #define	ISP_HA_SCSI_1040	0x4
    392  1.11   mjacob #define	ISP_HA_SCSI_1040A	0x5
    393  1.11   mjacob #define	ISP_HA_SCSI_1040B	0x6
    394  1.21   mjacob #define	ISP_HA_SCSI_1040C	0x7
    395  1.27   mjacob #define	ISP_HA_SCSI_1240	0x8
    396  1.27   mjacob #define	ISP_HA_SCSI_1080	0x9
    397  1.27   mjacob #define	ISP_HA_SCSI_1280	0xa
    398  1.29   mjacob #define	ISP_HA_SCSI_12160	0xb
    399   1.6   mjacob #define	ISP_HA_FC		0xf0
    400   1.6   mjacob #define	ISP_HA_FC_2100		0x10
    401  1.23   mjacob #define	ISP_HA_FC_2200		0x20
    402   1.6   mjacob 
    403  1.19   mjacob #define	IS_SCSI(isp)	(isp->isp_type & ISP_HA_SCSI)
    404  1.27   mjacob #define	IS_1240(isp)	(isp->isp_type == ISP_HA_SCSI_1240)
    405  1.19   mjacob #define	IS_1080(isp)	(isp->isp_type == ISP_HA_SCSI_1080)
    406  1.27   mjacob #define	IS_1280(isp)	(isp->isp_type == ISP_HA_SCSI_1280)
    407  1.29   mjacob #define	IS_12160(isp)	(isp->isp_type == ISP_HA_SCSI_12160)
    408  1.29   mjacob 
    409  1.29   mjacob #define	IS_12X0(isp)	(IS_1240(isp) || IS_1280(isp))
    410  1.29   mjacob #define	IS_DUALBUS(isp)	(IS_12X0(isp) || IS_12160(isp))
    411  1.29   mjacob #define	IS_ULTRA2(isp)	(IS_1080(isp) || IS_1280(isp) || IS_12160(isp))
    412  1.29   mjacob #define	IS_ULTRA3(isp)	(IS_12160(isp))
    413  1.29   mjacob 
    414  1.19   mjacob #define	IS_FC(isp)	(isp->isp_type & ISP_HA_FC)
    415  1.29   mjacob #define	IS_2100(isp)	(isp->isp_type == ISP_HA_FC_2100)
    416  1.29   mjacob #define	IS_2200(isp)	(isp->isp_type == ISP_HA_FC_2200)
    417  1.29   mjacob 
    418  1.19   mjacob 
    419   1.6   mjacob /*
    420   1.1      cgd  * Function Prototypes
    421   1.1      cgd  */
    422   1.9   mjacob 
    423   1.1      cgd /*
    424   1.9   mjacob  * Reset Hardware. Totally. Assumes that you'll follow this with
    425   1.9   mjacob  * a call to isp_init.
    426   1.1      cgd  */
    427   1.1      cgd void isp_reset __P((struct ispsoftc *));
    428   1.1      cgd 
    429   1.1      cgd /*
    430   1.1      cgd  * Initialize Hardware to known state
    431   1.1      cgd  */
    432   1.1      cgd void isp_init __P((struct ispsoftc *));
    433   1.1      cgd 
    434   1.1      cgd /*
    435  1.10   mjacob  * Reset the ISP and call completion for any orphaned commands.
    436  1.10   mjacob  */
    437  1.10   mjacob void isp_restart __P((struct ispsoftc *));
    438   1.1      cgd 
    439   1.1      cgd /*
    440   1.1      cgd  * Interrupt Service Routine
    441   1.1      cgd  */
    442   1.1      cgd int isp_intr __P((void *));
    443   1.9   mjacob 
    444   1.9   mjacob /*
    445   1.9   mjacob  * Command Entry Point
    446   1.9   mjacob  */
    447  1.11   mjacob int32_t ispscsicmd __P((ISP_SCSI_XFER_T *));
    448   1.1      cgd 
    449   1.9   mjacob /*
    450  1.17   mjacob  * Platform Dependent to External to Internal Control Function
    451   1.9   mjacob  *
    452  1.23   mjacob  * Assumes all locks are held and that no reentrancy issues need be dealt with.
    453   1.9   mjacob  *
    454   1.9   mjacob  */
    455   1.9   mjacob typedef enum {
    456  1.23   mjacob 	ISPCTL_RESET_BUS,		/* Reset Bus */
    457  1.23   mjacob 	ISPCTL_RESET_DEV,		/* Reset Device */
    458  1.23   mjacob 	ISPCTL_ABORT_CMD,		/* Abort Command */
    459  1.23   mjacob 	ISPCTL_UPDATE_PARAMS,		/* Update Operating Parameters */
    460  1.28   mjacob 	ISPCTL_FCLINK_TEST,		/* Test FC Link Status */
    461  1.28   mjacob 	ISPCTL_PDB_SYNC,		/* Synchronize Port Database */
    462  1.28   mjacob 	ISPCTL_TOGGLE_TMODE		/* toggle target mode */
    463   1.9   mjacob } ispctl_t;
    464   1.9   mjacob int isp_control __P((struct ispsoftc *, ispctl_t, void *));
    465  1.17   mjacob 
    466  1.17   mjacob 
    467  1.17   mjacob /*
    468  1.17   mjacob  * Platform Dependent to Internal to External Control Function
    469  1.17   mjacob  * (each platform must provide such a function)
    470  1.17   mjacob  *
    471  1.23   mjacob  * Assumes all locks are held and that no reentrancy issues need be dealt with.
    472  1.17   mjacob  *
    473  1.17   mjacob  */
    474  1.17   mjacob 
    475  1.17   mjacob typedef enum {
    476  1.18   mjacob 	ISPASYNC_NEW_TGT_PARAMS,
    477  1.23   mjacob 	ISPASYNC_BUS_RESET,		/* Bus Was Reset */
    478  1.23   mjacob 	ISPASYNC_LOOP_DOWN,		/* FC Loop Down */
    479  1.23   mjacob 	ISPASYNC_LOOP_UP,		/* FC Loop Up */
    480  1.23   mjacob 	ISPASYNC_PDB_CHANGED,		/* FC Port Data Base Changed */
    481  1.23   mjacob 	ISPASYNC_CHANGE_NOTIFY,		/* FC SNS Change Notification */
    482  1.23   mjacob 	ISPASYNC_FABRIC_DEV,		/* FC New Fabric Device */
    483  1.28   mjacob 	ISPASYNC_TARGET_MESSAGE,	/* target message */
    484  1.28   mjacob 	ISPASYNC_TARGET_EVENT,		/* target asynchronous event */
    485  1.28   mjacob 	ISPASYNC_TARGET_ACTION		/* other target command action */
    486  1.17   mjacob } ispasync_t;
    487  1.17   mjacob int isp_async __P((struct ispsoftc *, ispasync_t, void *));
    488   1.1      cgd 
    489   1.9   mjacob /*
    490   1.9   mjacob  * lost command routine (XXXX IN TRANSITION XXXX)
    491   1.9   mjacob  */
    492  1.11   mjacob void isp_lostcmd __P((struct ispsoftc *, ISP_SCSI_XFER_T *));
    493   1.1      cgd 
    494   1.1      cgd #endif	/* _ISPVAR_H */
    495