Home | History | Annotate | Line # | Download | only in ic
ispvar.h revision 1.22
      1  1.22   mjacob /* $NetBSD: ispvar.h,v 1.22 1999/05/12 18:59:24 mjacob Exp $ */
      2  1.22   mjacob /* release_5_11_99 */
      3   1.1      cgd /*
      4   1.1      cgd  * Soft Definitions for for Qlogic ISP SCSI adapters.
      5   1.1      cgd  *
      6   1.9   mjacob  *---------------------------------------
      7   1.9   mjacob  * Copyright (c) 1997, 1998 by Matthew Jacob
      8   1.2      cgd  * NASA/Ames Research Center
      9   1.1      cgd  * All rights reserved.
     10   1.9   mjacob  *---------------------------------------
     11   1.1      cgd  * Redistribution and use in source and binary forms, with or without
     12   1.1      cgd  * modification, are permitted provided that the following conditions
     13   1.1      cgd  * are met:
     14   1.1      cgd  * 1. Redistributions of source code must retain the above copyright
     15   1.1      cgd  *    notice immediately at the beginning of the file, without modification,
     16   1.1      cgd  *    this list of conditions, and the following disclaimer.
     17   1.1      cgd  * 2. Redistributions in binary form must reproduce the above copyright
     18   1.1      cgd  *    notice, this list of conditions and the following disclaimer in the
     19   1.1      cgd  *    documentation and/or other materials provided with the distribution.
     20   1.1      cgd  * 3. The name of the author may not be used to endorse or promote products
     21   1.1      cgd  *    derived from this software without specific prior written permission.
     22   1.1      cgd  *
     23   1.1      cgd  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     24   1.1      cgd  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     25   1.1      cgd  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     26   1.1      cgd  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
     27   1.1      cgd  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     28   1.1      cgd  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     29   1.1      cgd  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     30   1.1      cgd  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     31   1.1      cgd  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     32   1.1      cgd  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     33   1.1      cgd  * SUCH DAMAGE.
     34   1.9   mjacob  *
     35   1.1      cgd  */
     36   1.2      cgd 
     37   1.1      cgd #ifndef	_ISPVAR_H
     38   1.1      cgd #define	_ISPVAR_H
     39   1.1      cgd 
     40  1.19   mjacob #if defined(__NetBSD__) || defined(__OpenBSD__)
     41   1.1      cgd #include <dev/ic/ispmbox.h>
     42   1.9   mjacob #endif
     43   1.9   mjacob #ifdef	__FreeBSD__
     44   1.9   mjacob #include <dev/isp/ispmbox.h>
     45   1.9   mjacob #endif
     46   1.9   mjacob #ifdef	__linux__
     47  1.15   mjacob #include "ispmbox.h"
     48   1.9   mjacob #endif
     49   1.1      cgd 
     50  1.10   mjacob #define	ISP_CORE_VERSION_MAJOR	1
     51  1.22   mjacob #define	ISP_CORE_VERSION_MINOR	8
     52  1.10   mjacob 
     53   1.1      cgd /*
     54  1.17   mjacob  * Vector for bus specific code to provide specific services.
     55   1.1      cgd  */
     56   1.1      cgd struct ispsoftc;
     57   1.1      cgd struct ispmdvec {
     58   1.1      cgd 	u_int16_t	(*dv_rd_reg) __P((struct ispsoftc *, int));
     59   1.1      cgd 	void		(*dv_wr_reg) __P((struct ispsoftc *, int, u_int16_t));
     60   1.5  thorpej 	int		(*dv_mbxdma) __P((struct ispsoftc *));
     61   1.1      cgd 	int		(*dv_dmaset) __P((struct ispsoftc *,
     62   1.9   mjacob 		ISP_SCSI_XFER_T *, ispreq_t *, u_int8_t *, u_int8_t));
     63   1.1      cgd 	void		(*dv_dmaclr)
     64   1.9   mjacob 		__P((struct ispsoftc *, ISP_SCSI_XFER_T *, u_int32_t));
     65   1.1      cgd 	void		(*dv_reset0) __P((struct ispsoftc *));
     66   1.1      cgd 	void		(*dv_reset1) __P((struct ispsoftc *));
     67   1.6   mjacob 	void		(*dv_dregs) __P((struct ispsoftc *));
     68   1.3  mycroft 	const u_int16_t *dv_ispfw;	/* ptr to f/w */
     69   1.1      cgd 	u_int16_t 	dv_fwlen;	/* length of f/w */
     70   1.1      cgd 	u_int16_t	dv_codeorg;	/* code ORG for f/w */
     71   1.6   mjacob 	u_int16_t	dv_fwrev;	/* f/w revision */
     72   1.1      cgd 	/*
     73   1.1      cgd 	 * Initial values for conf1 register
     74   1.1      cgd 	 */
     75   1.1      cgd 	u_int16_t	dv_conf1;
     76   1.4   mjacob 	u_int16_t	dv_clock;	/* clock frequency */
     77   1.1      cgd };
     78   1.1      cgd 
     79   1.1      cgd #define	MAX_TARGETS	16
     80  1.19   mjacob #ifdef	ISP2100_FABRIC
     81  1.19   mjacob #define	MAX_FC_TARG	256
     82  1.19   mjacob #else
     83   1.6   mjacob #define	MAX_FC_TARG	126
     84  1.19   mjacob #endif
     85  1.14   mjacob #define	DEFAULT_LOOPID	113
     86   1.1      cgd 
     87  1.11   mjacob /* queue length must be a power of two */
     88  1.11   mjacob #define	QENTRY_LEN			64
     89  1.11   mjacob #define	RQUEST_QUEUE_LEN		MAXISPREQUEST
     90  1.19   mjacob #define	RESULT_QUEUE_LEN		(MAXISPREQUEST/2)
     91  1.11   mjacob #define	ISP_QUEUE_ENTRY(q, idx)		((q) + ((idx) * QENTRY_LEN))
     92  1.11   mjacob #define	ISP_QUEUE_SIZE(n)		((n) * QENTRY_LEN)
     93  1.11   mjacob #define	ISP_NXT_QENTRY(idx, qlen)	(((idx) + 1) & ((qlen)-1))
     94  1.13   mjacob #define ISP_QAVAIL(in, out, qlen)	\
     95  1.13   mjacob 	((in == out)? (qlen - 1) : ((in > out)? \
     96  1.13   mjacob 		((qlen - 1) - (in - out)) : (out - in - 1)))
     97   1.1      cgd /*
     98  1.22   mjacob  * SCSI Specific Host Adapter Parameters- per bus, per target
     99   1.6   mjacob  */
    100   1.6   mjacob 
    101   1.6   mjacob typedef struct {
    102  1.22   mjacob 	u_int		isp_gotdparms		: 1,
    103  1.22   mjacob         		isp_req_ack_active_neg	: 1,
    104   1.6   mjacob 	        	isp_data_line_active_neg: 1,
    105   1.6   mjacob 			isp_cmd_dma_burst_enable: 1,
    106   1.6   mjacob 			isp_data_dma_burst_enabl: 1,
    107  1.16   mjacob 			isp_fifo_threshold	: 3,
    108  1.17   mjacob 			isp_ultramode		: 1,
    109   1.6   mjacob 			isp_diffmode		: 1,
    110  1.20   mjacob 			isp_lvdmode		: 1,
    111  1.22   mjacob 						: 1,
    112   1.6   mjacob 			isp_initiator_id	: 4,
    113   1.6   mjacob         		isp_async_data_setup	: 4;
    114   1.6   mjacob         u_int16_t	isp_selection_timeout;
    115   1.6   mjacob         u_int16_t	isp_max_queue_depth;
    116   1.6   mjacob 	u_int8_t	isp_tag_aging;
    117   1.6   mjacob        	u_int8_t	isp_bus_reset_delay;
    118   1.6   mjacob         u_int8_t	isp_retry_count;
    119   1.6   mjacob         u_int8_t	isp_retry_delay;
    120   1.6   mjacob 	struct {
    121  1.22   mjacob 		u_int	dev_enable	:	1,	/* ignored */
    122  1.22   mjacob 					:	1,
    123  1.17   mjacob 			dev_update	:	1,
    124  1.17   mjacob 			dev_refresh	:	1,
    125  1.20   mjacob 			exc_throttle	:	8,
    126  1.20   mjacob 			cur_offset	:	4,
    127  1.20   mjacob 			sync_offset	:	4;
    128  1.20   mjacob 		u_int8_t	cur_period;	/* current sync period */
    129  1.20   mjacob 		u_int8_t	sync_period;	/* goal sync period */
    130  1.20   mjacob 		u_int16_t	dev_flags;	/* goal device flags */
    131  1.20   mjacob 		u_int16_t	cur_dflags;	/* current device flags */
    132   1.6   mjacob 	} isp_devparam[MAX_TARGETS];
    133  1.22   mjacob } sdparam;
    134   1.6   mjacob 
    135   1.6   mjacob /*
    136   1.6   mjacob  * Device Flags
    137   1.6   mjacob  */
    138  1.11   mjacob #define	DPARM_DISC	0x8000
    139  1.11   mjacob #define	DPARM_PARITY	0x4000
    140  1.11   mjacob #define	DPARM_WIDE	0x2000
    141  1.11   mjacob #define	DPARM_SYNC	0x1000
    142  1.11   mjacob #define	DPARM_TQING	0x0800
    143  1.11   mjacob #define	DPARM_ARQ	0x0400
    144  1.11   mjacob #define	DPARM_QFRZ	0x0200
    145  1.11   mjacob #define	DPARM_RENEG	0x0100
    146  1.11   mjacob #define	DPARM_NARROW	0x0080	/* Possibly only available with >= 7.55 fw */
    147  1.11   mjacob #define	DPARM_ASYNC	0x0040	/* Possibly only available with >= 7.55 fw */
    148  1.18   mjacob #define	DPARM_DEFAULT	(0xFF00 & ~DPARM_QFRZ)
    149  1.11   mjacob #define	DPARM_SAFE_DFLT	(DPARM_DEFAULT & ~(DPARM_WIDE|DPARM_SYNC|DPARM_TQING))
    150  1.11   mjacob 
    151   1.6   mjacob 
    152  1.20   mjacob /* technically, not really correct, as they need to be rated based upon clock */
    153  1.20   mjacob #define	ISP_40M_SYNCPARMS	0x080a
    154   1.6   mjacob #define ISP_20M_SYNCPARMS	0x080c
    155   1.6   mjacob #define ISP_10M_SYNCPARMS	0x0c19
    156   1.6   mjacob #define ISP_08M_SYNCPARMS	0x0c25
    157   1.6   mjacob #define ISP_05M_SYNCPARMS	0x0c32
    158   1.6   mjacob #define ISP_04M_SYNCPARMS	0x0c41
    159   1.6   mjacob 
    160   1.6   mjacob /*
    161   1.6   mjacob  * Fibre Channel Specifics
    162   1.6   mjacob  */
    163   1.6   mjacob typedef struct {
    164  1.22   mjacob 	u_int8_t		isp_gotdparms;
    165  1.22   mjacob 	u_int8_t		isp_reserved;
    166  1.11   mjacob 	u_int8_t		isp_loopid;	/* hard loop id */
    167  1.11   mjacob 	u_int8_t		isp_alpa;	/* ALPA */
    168  1.11   mjacob 	u_int8_t		isp_execthrottle;
    169  1.11   mjacob         u_int8_t		isp_retry_delay;
    170   1.6   mjacob         u_int8_t		isp_retry_count;
    171   1.6   mjacob 	u_int8_t		isp_fwstate;	/* ISP F/W state */
    172  1.22   mjacob 	u_int64_t		isp_wwn;	/* WWN of adapter */
    173  1.11   mjacob 	u_int16_t		isp_maxalloc;
    174  1.11   mjacob 	u_int16_t		isp_maxfrmlen;
    175  1.11   mjacob 	u_int16_t		isp_fwoptions;
    176   1.6   mjacob 	/*
    177  1.19   mjacob 	 * Port Data Base
    178  1.19   mjacob 	 */
    179  1.19   mjacob 	isp_pdb_t		isp_pdb[MAX_FC_TARG];
    180  1.19   mjacob 
    181  1.19   mjacob 	/*
    182   1.6   mjacob 	 * Scratch DMA mapped in area to fetch Port Database stuff, etc.
    183   1.6   mjacob 	 */
    184   1.6   mjacob 	volatile caddr_t	isp_scratch;
    185   1.6   mjacob 	u_int32_t		isp_scdma;
    186   1.6   mjacob } fcparam;
    187   1.6   mjacob 
    188   1.6   mjacob #define	ISP2100_SCRLEN		0x100
    189   1.6   mjacob 
    190   1.6   mjacob #define	FW_CONFIG_WAIT		0x0000
    191   1.6   mjacob #define	FW_WAIT_AL_PA		0x0001
    192   1.6   mjacob #define	FW_WAIT_LOGIN		0x0002
    193   1.6   mjacob #define	FW_READY		0x0003
    194   1.6   mjacob #define	FW_LOSS_OF_SYNC		0x0004
    195   1.6   mjacob #define	FW_ERROR		0x0005
    196   1.6   mjacob #define	FW_REINIT		0x0006
    197   1.6   mjacob #define	FW_NON_PART		0x0007
    198   1.6   mjacob 
    199  1.15   mjacob #ifdef	ISP_TARGET_MODE
    200  1.15   mjacob /*
    201  1.15   mjacob  * Some temporary Target Mode definitions
    202  1.15   mjacob  */
    203  1.15   mjacob typedef struct tmd_cmd {
    204  1.15   mjacob 	u_int8_t	cd_iid;		/* initiator */
    205  1.15   mjacob 	u_int8_t	cd_tgt;		/* target */
    206  1.15   mjacob 	u_int8_t	cd_lun;		/* LUN for this command */
    207  1.15   mjacob 	u_int8_t	cd_state;
    208  1.15   mjacob 	u_int8_t	cd_cdb[16];	/* command bytes */
    209  1.15   mjacob 	u_int8_t	cd_sensedata[20];
    210  1.15   mjacob 	u_int16_t	cd_rxid;
    211  1.15   mjacob 	u_int32_t	cd_datalen;
    212  1.15   mjacob 	u_int32_t	cd_totbytes;
    213  1.15   mjacob 	void *		cd_hba;
    214  1.15   mjacob } tmd_cmd_t;
    215  1.15   mjacob 
    216  1.15   mjacob /*
    217  1.15   mjacob  * Async Target Mode Event Definitions
    218  1.15   mjacob  */
    219  1.15   mjacob #define	TMD_BUS_RESET	0
    220  1.15   mjacob #define	TMD_BDR		1
    221  1.15   mjacob 
    222  1.15   mjacob /*
    223  1.15   mjacob  * Immediate Notify data structure.
    224  1.15   mjacob  */
    225  1.15   mjacob #define NOTIFY_MSGLEN	5
    226  1.15   mjacob typedef struct {
    227  1.15   mjacob 	u_int8_t	nt_iid;			/* initiator */
    228  1.15   mjacob 	u_int8_t	nt_tgt;			/* target */
    229  1.15   mjacob 	u_int8_t	nt_lun;			/* LUN for this command */
    230  1.15   mjacob 	u_int8_t	nt_msg[NOTIFY_MSGLEN];	/* SCSI message byte(s) */
    231  1.15   mjacob } tmd_notify_t;
    232  1.15   mjacob 
    233  1.15   mjacob #endif
    234   1.9   mjacob 
    235   1.6   mjacob /*
    236   1.1      cgd  * Soft Structure per host adapter
    237   1.1      cgd  */
    238   1.1      cgd struct ispsoftc {
    239   1.9   mjacob 	/*
    240   1.9   mjacob 	 * Platform (OS) specific data
    241   1.9   mjacob 	 */
    242   1.9   mjacob 	struct isposinfo	isp_osinfo;
    243   1.9   mjacob 
    244   1.9   mjacob 	/*
    245   1.9   mjacob 	 * Pointer to bus specific data
    246   1.9   mjacob 	 */
    247   1.1      cgd 	struct ispmdvec *	isp_mdvec;
    248   1.9   mjacob 
    249   1.9   mjacob 	/*
    250  1.22   mjacob 	 * Mostly nonvolatile state.
    251   1.9   mjacob 	 */
    252   1.9   mjacob 
    253  1.22   mjacob 	u_int		isp_clock	: 8,
    254  1.11   mjacob 			isp_confopts	: 8,
    255  1.22   mjacob 			isp_fast_mttr	: 1,
    256  1.22   mjacob 					: 1,
    257  1.19   mjacob 			isp_used	: 1,
    258  1.11   mjacob 			isp_dblev	: 3,
    259   1.9   mjacob 			isp_dogactive	: 1,
    260  1.11   mjacob 			isp_bustype	: 1,	/* BUS Implementation */
    261  1.11   mjacob 			isp_type	: 8;	/* HBA Type and Revision */
    262  1.11   mjacob 
    263  1.21   mjacob 	u_int16_t		isp_fwrev[3];	/* Running F/W revision */
    264  1.21   mjacob 	u_int16_t		isp_romfw_rev[3]; /* 'ROM' F/W revision */
    265  1.11   mjacob 	void * 			isp_param;
    266   1.6   mjacob 
    267   1.1      cgd 	/*
    268  1.11   mjacob 	 * Volatile state
    269   1.1      cgd 	 */
    270  1.11   mjacob 
    271  1.11   mjacob 	volatile u_int
    272  1.22   mjacob 				:	13,
    273  1.11   mjacob 		isp_state	:	3,
    274  1.22   mjacob 				:	2,
    275  1.22   mjacob 		isp_sendmarker	:	2,	/* send a marker entry */
    276  1.22   mjacob 		isp_update	:	2,	/* update parameters */
    277  1.22   mjacob 		isp_nactive	:	10;	/* how many commands active */
    278   1.6   mjacob 
    279   1.1      cgd 	/*
    280  1.11   mjacob 	 * Result and Request Queue indices.
    281   1.1      cgd 	 */
    282  1.11   mjacob 	volatile u_int8_t	isp_reqodx;	/* index of last ISP pickup */
    283   1.1      cgd 	volatile u_int8_t	isp_reqidx;	/* index of next request */
    284   1.1      cgd 	volatile u_int8_t	isp_residx;	/* index of next result */
    285  1.11   mjacob 	volatile u_int8_t	isp_seqno;	/* rolling sequence # */
    286   1.6   mjacob 
    287   1.1      cgd 	/*
    288   1.1      cgd 	 * Sheer laziness, but it gets us around the problem
    289   1.1      cgd 	 * where we don't have a clean way of remembering
    290   1.9   mjacob 	 * which transaction is bound to which ISP queue entry.
    291   1.1      cgd 	 *
    292   1.1      cgd 	 * There are other more clever ways to do this, but,
    293   1.1      cgd 	 * jeez, so I blow a couple of KB per host adapter...
    294   1.1      cgd 	 * and it *is* faster.
    295   1.1      cgd 	 */
    296  1.17   mjacob 	ISP_SCSI_XFER_T *isp_xflist[RQUEST_QUEUE_LEN];
    297   1.6   mjacob 
    298   1.1      cgd 	/*
    299  1.11   mjacob 	 * request/result queues and dma handles for them.
    300   1.1      cgd 	 */
    301   1.5  thorpej 	volatile caddr_t	isp_rquest;
    302   1.5  thorpej 	volatile caddr_t	isp_result;
    303   1.5  thorpej 	u_int32_t		isp_rquest_dma;
    304   1.5  thorpej 	u_int32_t		isp_result_dma;
    305  1.14   mjacob 
    306  1.15   mjacob #ifdef	ISP_TARGET_MODE
    307  1.15   mjacob 	/*
    308  1.15   mjacob 	 * Vectors for handling target mode support.
    309  1.15   mjacob 	 *
    310  1.15   mjacob 	 * isp_tmd_newcmd is for feeding a newly arrived command to some
    311  1.15   mjacob 	 * upper layer.
    312  1.15   mjacob 	 *
    313  1.15   mjacob 	 * isp_tmd_event is for notifying some upper layer that an event has
    314  1.15   mjacob 	 * occurred that is not necessarily tied to any target (e.g., a SCSI
    315  1.15   mjacob 	 * Bus Reset).
    316  1.15   mjacob 	 *
    317  1.15   mjacob 	 * isp_tmd_notify is for notifying some upper layer that some
    318  1.15   mjacob 	 * event is now occurring that is either pertinent for a specific
    319  1.15   mjacob 	 * device or for a specific command (e.g., BDR or ABORT TAG).
    320  1.15   mjacob 	 *
    321  1.15   mjacob 	 * It is left undefined (for now) how pools of commands are managed.
    322  1.15   mjacob 	 */
    323  1.15   mjacob 	void		(*isp_tmd_newcmd) __P((void *, tmd_cmd_t *));
    324  1.15   mjacob 	void		(*isp_tmd_event) __P((void *, int));
    325  1.15   mjacob 	void		(*isp_tmd_notify) __P((void *, tmd_notify_t *));
    326  1.15   mjacob #endif
    327   1.1      cgd };
    328   1.1      cgd 
    329   1.1      cgd /*
    330   1.9   mjacob  * ISP States
    331   1.9   mjacob  */
    332   1.9   mjacob #define	ISP_NILSTATE	0
    333   1.9   mjacob #define	ISP_RESETSTATE	1
    334   1.9   mjacob #define	ISP_INITSTATE	2
    335   1.9   mjacob #define	ISP_RUNSTATE	3
    336   1.9   mjacob 
    337   1.9   mjacob /*
    338   1.9   mjacob  * ISP Configuration Options
    339   1.9   mjacob  */
    340   1.9   mjacob #define	ISP_CFG_NORELOAD	0x80	/* don't download f/w */
    341  1.18   mjacob #define	ISP_CFG_NONVRAM		0x40	/* ignore NVRAM */
    342   1.9   mjacob 
    343  1.21   mjacob #define	ISP_FW_REV(maj, min, mic)	((maj << 24) | (min << 16) | mic)
    344  1.22   mjacob #define	ISP_FW_REVX(xp)	((xp[0]<<24) | (xp[1] << 16) | xp[2])
    345  1.11   mjacob 
    346  1.21   mjacob 
    347   1.9   mjacob /*
    348  1.11   mjacob  * Bus (implementation) types
    349  1.11   mjacob  */
    350  1.11   mjacob #define	ISP_BT_PCI		0	/* PCI Implementations */
    351  1.11   mjacob #define	ISP_BT_SBUS		1	/* SBus Implementations */
    352  1.11   mjacob 
    353  1.11   mjacob /*
    354  1.11   mjacob  * Chip Types
    355   1.6   mjacob  */
    356   1.6   mjacob #define	ISP_HA_SCSI		0xf
    357  1.11   mjacob #define	ISP_HA_SCSI_UNKNOWN	0x1
    358  1.11   mjacob #define	ISP_HA_SCSI_1020	0x2
    359  1.11   mjacob #define	ISP_HA_SCSI_1020A	0x3
    360  1.11   mjacob #define	ISP_HA_SCSI_1040	0x4
    361  1.11   mjacob #define	ISP_HA_SCSI_1040A	0x5
    362  1.11   mjacob #define	ISP_HA_SCSI_1040B	0x6
    363  1.21   mjacob #define	ISP_HA_SCSI_1040C	0x7
    364  1.20   mjacob #define	ISP_HA_SCSI_1080	0xd
    365  1.20   mjacob #define	ISP_HA_SCSI_12X0	0xe
    366   1.6   mjacob #define	ISP_HA_FC		0xf0
    367   1.6   mjacob #define	ISP_HA_FC_2100		0x10
    368   1.6   mjacob 
    369  1.19   mjacob #define	IS_SCSI(isp)	(isp->isp_type & ISP_HA_SCSI)
    370  1.19   mjacob #define	IS_1080(isp)	(isp->isp_type == ISP_HA_SCSI_1080)
    371  1.20   mjacob #define	IS_12X0(isp)	(isp->isp_type == ISP_HA_SCSI_12X0)
    372  1.19   mjacob #define	IS_FC(isp)	(isp->isp_type & ISP_HA_FC)
    373  1.19   mjacob 
    374   1.6   mjacob /*
    375  1.17   mjacob  * Macros to read, write ISP registers through bus specific code.
    376   1.1      cgd  */
    377   1.1      cgd 
    378   1.1      cgd #define	ISP_READ(isp, reg)	\
    379   1.1      cgd 	(*(isp)->isp_mdvec->dv_rd_reg)((isp), (reg))
    380   1.1      cgd 
    381   1.1      cgd #define	ISP_WRITE(isp, reg, val)	\
    382   1.1      cgd 	(*(isp)->isp_mdvec->dv_wr_reg)((isp), (reg), (val))
    383   1.1      cgd 
    384   1.5  thorpej #define	ISP_MBOXDMASETUP(isp)	\
    385   1.5  thorpej 	(*(isp)->isp_mdvec->dv_mbxdma)((isp))
    386   1.1      cgd 
    387   1.1      cgd #define	ISP_DMASETUP(isp, xs, req, iptrp, optr)	\
    388   1.1      cgd 	(*(isp)->isp_mdvec->dv_dmaset)((isp), (xs), (req), (iptrp), (optr))
    389   1.1      cgd 
    390   1.1      cgd #define	ISP_DMAFREE(isp, xs, seqno)	\
    391   1.1      cgd 	if ((isp)->isp_mdvec->dv_dmaclr) \
    392   1.1      cgd 		 (*(isp)->isp_mdvec->dv_dmaclr)((isp), (xs), (seqno))
    393   1.1      cgd 
    394   1.1      cgd #define	ISP_RESET0(isp)	\
    395   1.1      cgd 	if ((isp)->isp_mdvec->dv_reset0) (*(isp)->isp_mdvec->dv_reset0)((isp))
    396   1.1      cgd #define	ISP_RESET1(isp)	\
    397   1.1      cgd 	if ((isp)->isp_mdvec->dv_reset1) (*(isp)->isp_mdvec->dv_reset1)((isp))
    398   1.6   mjacob #define	ISP_DUMPREGS(isp)	\
    399   1.6   mjacob 	if ((isp)->isp_mdvec->dv_dregs) (*(isp)->isp_mdvec->dv_dregs)((isp))
    400   1.1      cgd 
    401   1.1      cgd #define	ISP_SETBITS(isp, reg, val)	\
    402   1.1      cgd  (*(isp)->isp_mdvec->dv_wr_reg)((isp), (reg), ISP_READ((isp), (reg)) | (val))
    403   1.1      cgd 
    404   1.1      cgd #define	ISP_CLRBITS(isp, reg, val)	\
    405   1.1      cgd  (*(isp)->isp_mdvec->dv_wr_reg)((isp), (reg), ISP_READ((isp), (reg)) & ~(val))
    406   1.1      cgd 
    407   1.1      cgd /*
    408   1.1      cgd  * Function Prototypes
    409   1.1      cgd  */
    410   1.9   mjacob 
    411   1.1      cgd /*
    412   1.9   mjacob  * Reset Hardware. Totally. Assumes that you'll follow this with
    413   1.9   mjacob  * a call to isp_init.
    414   1.1      cgd  */
    415   1.1      cgd void isp_reset __P((struct ispsoftc *));
    416   1.1      cgd 
    417   1.1      cgd /*
    418   1.1      cgd  * Initialize Hardware to known state
    419   1.1      cgd  */
    420   1.1      cgd void isp_init __P((struct ispsoftc *));
    421   1.1      cgd 
    422   1.1      cgd /*
    423  1.10   mjacob  * Reset the ISP and call completion for any orphaned commands.
    424  1.10   mjacob  */
    425  1.10   mjacob void isp_restart __P((struct ispsoftc *));
    426   1.1      cgd 
    427   1.1      cgd /*
    428   1.1      cgd  * Interrupt Service Routine
    429   1.1      cgd  */
    430   1.1      cgd int isp_intr __P((void *));
    431   1.9   mjacob 
    432   1.9   mjacob /*
    433   1.9   mjacob  * Command Entry Point
    434   1.9   mjacob  */
    435  1.11   mjacob int32_t ispscsicmd __P((ISP_SCSI_XFER_T *));
    436   1.1      cgd 
    437   1.9   mjacob /*
    438  1.17   mjacob  * Platform Dependent to External to Internal Control Function
    439   1.9   mjacob  *
    440   1.9   mjacob  * For: 	Aborting a running command	- arg is an ISP_SCSI_XFER_T *
    441   1.9   mjacob  *		Resetting a Device		- arg is target to reset
    442   1.9   mjacob  *		Resetting a BUS			- arg is ignored
    443  1.12   mjacob  *		Updating parameters		- arg is ignored
    444   1.9   mjacob  *
    445  1.17   mjacob  * First argument is this instance's softc pointer.
    446   1.9   mjacob  * Second argument is an index into xflist array.
    447   1.9   mjacob  * Assumes all locks must be held already.
    448   1.9   mjacob  */
    449   1.9   mjacob typedef enum {
    450   1.9   mjacob 	ISPCTL_RESET_BUS,
    451   1.9   mjacob 	ISPCTL_RESET_DEV,
    452  1.12   mjacob 	ISPCTL_ABORT_CMD,
    453  1.12   mjacob 	ISPCTL_UPDATE_PARAMS,
    454  1.19   mjacob 	ISPCTL_FCLINK_TEST
    455   1.9   mjacob } ispctl_t;
    456   1.9   mjacob int isp_control __P((struct ispsoftc *, ispctl_t, void *));
    457  1.17   mjacob 
    458  1.17   mjacob 
    459  1.17   mjacob /*
    460  1.17   mjacob  * Platform Dependent to Internal to External Control Function
    461  1.17   mjacob  * (each platform must provide such a function)
    462  1.17   mjacob  *
    463  1.17   mjacob  * For: 	Announcing Target Paramter Changes (arg is target)
    464  1.17   mjacob  *
    465  1.17   mjacob  * Assumes all locks are held.
    466  1.17   mjacob  */
    467  1.17   mjacob 
    468  1.17   mjacob typedef enum {
    469  1.18   mjacob 	ISPASYNC_NEW_TGT_PARAMS,
    470  1.19   mjacob 	ISPASYNC_BUS_RESET,		/* Bus Reset */
    471  1.18   mjacob 	ISPASYNC_LOOP_DOWN,		/* Obvious FC only */
    472  1.19   mjacob 	ISPASYNC_LOOP_UP,		/* "" */
    473  1.19   mjacob 	ISPASYNC_PDB_CHANGE_COMPLETE,	/* "" */
    474  1.19   mjacob 	ISPASYNC_CHANGE_NOTIFY		/* "" */
    475  1.17   mjacob } ispasync_t;
    476  1.17   mjacob int isp_async __P((struct ispsoftc *, ispasync_t, void *));
    477   1.1      cgd 
    478   1.9   mjacob /*
    479   1.9   mjacob  * lost command routine (XXXX IN TRANSITION XXXX)
    480   1.9   mjacob  */
    481  1.11   mjacob void isp_lostcmd __P((struct ispsoftc *, ISP_SCSI_XFER_T *));
    482  1.11   mjacob 
    483   1.1      cgd 
    484   1.1      cgd #endif	/* _ISPVAR_H */
    485