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