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