ispmbox.h revision 1.14 1 1.14 mjacob /* $NetBSD: ispmbox.h,v 1.14 1999/03/17 06:15:48 mjacob Exp $ */
2 1.14 mjacob /* release_03_16_99 */
3 1.1 cgd /*
4 1.8 mjacob * Mailbox and Queue Entry Definitions for for Qlogic ISP SCSI adapters.
5 1.1 cgd *
6 1.6 mjacob *---------------------------------------
7 1.6 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.6 mjacob *---------------------------------------
11 1.1 cgd *
12 1.1 cgd * Redistribution and use in source and binary forms, with or without
13 1.1 cgd * modification, are permitted provided that the following conditions
14 1.1 cgd * are met:
15 1.1 cgd * 1. Redistributions of source code must retain the above copyright
16 1.1 cgd * notice immediately at the beginning of the file, without modification,
17 1.1 cgd * this list of conditions, and the following disclaimer.
18 1.1 cgd * 2. Redistributions in binary form must reproduce the above copyright
19 1.1 cgd * notice, this list of conditions and the following disclaimer in the
20 1.1 cgd * documentation and/or other materials provided with the distribution.
21 1.1 cgd * 3. The name of the author may not be used to endorse or promote products
22 1.1 cgd * derived from this software without specific prior written permission.
23 1.1 cgd *
24 1.1 cgd * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
25 1.1 cgd * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 1.1 cgd * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 1.1 cgd * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
28 1.1 cgd * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 1.1 cgd * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 1.1 cgd * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 1.1 cgd * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 1.1 cgd * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 1.1 cgd * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 1.1 cgd * SUCH DAMAGE.
35 1.6 mjacob *
36 1.1 cgd */
37 1.1 cgd #ifndef _ISPMBOX_H
38 1.1 cgd #define _ISPMBOX_H
39 1.1 cgd
40 1.1 cgd /*
41 1.1 cgd * Mailbox Command Opcodes
42 1.1 cgd */
43 1.1 cgd
44 1.1 cgd #define MBOX_NO_OP 0x0000
45 1.1 cgd #define MBOX_LOAD_RAM 0x0001
46 1.1 cgd #define MBOX_EXEC_FIRMWARE 0x0002
47 1.1 cgd #define MBOX_DUMP_RAM 0x0003
48 1.1 cgd #define MBOX_WRITE_RAM_WORD 0x0004
49 1.1 cgd #define MBOX_READ_RAM_WORD 0x0005
50 1.1 cgd #define MBOX_MAILBOX_REG_TEST 0x0006
51 1.1 cgd #define MBOX_VERIFY_CHECKSUM 0x0007
52 1.1 cgd #define MBOX_ABOUT_FIRMWARE 0x0008
53 1.1 cgd /* 9 */
54 1.1 cgd /* a */
55 1.1 cgd /* b */
56 1.1 cgd /* c */
57 1.1 cgd /* d */
58 1.1 cgd #define MBOX_CHECK_FIRMWARE 0x000e
59 1.1 cgd /* f */
60 1.1 cgd #define MBOX_INIT_REQ_QUEUE 0x0010
61 1.1 cgd #define MBOX_INIT_RES_QUEUE 0x0011
62 1.1 cgd #define MBOX_EXECUTE_IOCB 0x0012
63 1.1 cgd #define MBOX_WAKE_UP 0x0013
64 1.1 cgd #define MBOX_STOP_FIRMWARE 0x0014
65 1.1 cgd #define MBOX_ABORT 0x0015
66 1.1 cgd #define MBOX_ABORT_DEVICE 0x0016
67 1.1 cgd #define MBOX_ABORT_TARGET 0x0017
68 1.1 cgd #define MBOX_BUS_RESET 0x0018
69 1.1 cgd #define MBOX_STOP_QUEUE 0x0019
70 1.1 cgd #define MBOX_START_QUEUE 0x001a
71 1.1 cgd #define MBOX_SINGLE_STEP_QUEUE 0x001b
72 1.1 cgd #define MBOX_ABORT_QUEUE 0x001c
73 1.1 cgd #define MBOX_GET_DEV_QUEUE_STATUS 0x001d
74 1.1 cgd /* 1e */
75 1.1 cgd #define MBOX_GET_FIRMWARE_STATUS 0x001f
76 1.1 cgd #define MBOX_GET_INIT_SCSI_ID 0x0020
77 1.1 cgd #define MBOX_GET_SELECT_TIMEOUT 0x0021
78 1.1 cgd #define MBOX_GET_RETRY_COUNT 0x0022
79 1.1 cgd #define MBOX_GET_TAG_AGE_LIMIT 0x0023
80 1.1 cgd #define MBOX_GET_CLOCK_RATE 0x0024
81 1.1 cgd #define MBOX_GET_ACT_NEG_STATE 0x0025
82 1.1 cgd #define MBOX_GET_ASYNC_DATA_SETUP_TIME 0x0026
83 1.1 cgd #define MBOX_GET_SBUS_PARAMS 0x0027
84 1.1 cgd #define MBOX_GET_TARGET_PARAMS 0x0028
85 1.1 cgd #define MBOX_GET_DEV_QUEUE_PARAMS 0x0029
86 1.1 cgd /* 2a */
87 1.1 cgd /* 2b */
88 1.1 cgd /* 2c */
89 1.1 cgd /* 2d */
90 1.1 cgd /* 2e */
91 1.1 cgd /* 2f */
92 1.1 cgd #define MBOX_SET_INIT_SCSI_ID 0x0030
93 1.1 cgd #define MBOX_SET_SELECT_TIMEOUT 0x0031
94 1.1 cgd #define MBOX_SET_RETRY_COUNT 0x0032
95 1.1 cgd #define MBOX_SET_TAG_AGE_LIMIT 0x0033
96 1.1 cgd #define MBOX_SET_CLOCK_RATE 0x0034
97 1.1 cgd #define MBOX_SET_ACTIVE_NEG_STATE 0x0035
98 1.1 cgd #define MBOX_SET_ASYNC_DATA_SETUP_TIME 0x0036
99 1.1 cgd #define MBOX_SET_SBUS_CONTROL_PARAMS 0x0037
100 1.3 mjacob #define MBOX_SET_PCI_PARAMETERS 0x0037
101 1.1 cgd #define MBOX_SET_TARGET_PARAMS 0x0038
102 1.1 cgd #define MBOX_SET_DEV_QUEUE_PARAMS 0x0039
103 1.1 cgd /* 3a */
104 1.1 cgd /* 3b */
105 1.1 cgd /* 3c */
106 1.1 cgd /* 3d */
107 1.1 cgd /* 3e */
108 1.1 cgd /* 3f */
109 1.1 cgd #define MBOX_RETURN_BIOS_BLOCK_ADDR 0x0040
110 1.1 cgd #define MBOX_WRITE_FOUR_RAM_WORDS 0x0041
111 1.1 cgd #define MBOX_EXEC_BIOS_IOCB 0x0042
112 1.12 mjacob #define MBOX_SET_FW_FEATURES 0x004a
113 1.12 mjacob #define MBOX_GET_FW_FEATURES 0x004b
114 1.12 mjacob #define FW_FEATURE_LVD_NOTIFY 0x2
115 1.12 mjacob #define FW_FEATURE_FAST_POST 0x1
116 1.1 cgd
117 1.3 mjacob /* These are for the ISP2100 FC cards */
118 1.4 mjacob #define MBOX_GET_LOOP_ID 0x20
119 1.4 mjacob #define MBOX_EXEC_COMMAND_IOCB_A64 0x54
120 1.3 mjacob #define MBOX_INIT_FIRMWARE 0x60
121 1.3 mjacob #define MBOX_GET_INIT_CONTROL_BLOCK 0x61
122 1.3 mjacob #define MBOX_INIT_LIP 0x62
123 1.3 mjacob #define MBOX_GET_FC_AL_POSITION_MAP 0x63
124 1.3 mjacob #define MBOX_GET_PORT_DB 0x64
125 1.3 mjacob #define MBOX_CLEAR_ACA 0x65
126 1.3 mjacob #define MBOX_TARGET_RESET 0x66
127 1.3 mjacob #define MBOX_CLEAR_TASK_SET 0x67
128 1.3 mjacob #define MBOX_ABORT_TASK_SET 0x68
129 1.4 mjacob #define MBOX_GET_FW_STATE 0x69
130 1.14 mjacob #define MBOX_GET_PORT_NAME 0x6a
131 1.14 mjacob #define MBOX_GET_LINK_STATUS 0x6b
132 1.8 mjacob #define MBOX_INIT_LIP_RESET 0x6c
133 1.8 mjacob #define MBOX_INIT_LIP_LOGIN 0x72
134 1.3 mjacob
135 1.3 mjacob #define ISP2100_SET_PCI_PARAM 0x00ff
136 1.3 mjacob
137 1.1 cgd #define MBOX_BUSY 0x04
138 1.1 cgd
139 1.1 cgd typedef struct {
140 1.3 mjacob u_int16_t param[8];
141 1.1 cgd } mbreg_t;
142 1.1 cgd
143 1.1 cgd /*
144 1.8 mjacob * Mailbox Command Complete Status Codes
145 1.8 mjacob */
146 1.8 mjacob #define MBOX_COMMAND_COMPLETE 0x4000
147 1.8 mjacob #define MBOX_INVALID_COMMAND 0x4001
148 1.8 mjacob #define MBOX_HOST_INTERFACE_ERROR 0x4002
149 1.8 mjacob #define MBOX_TEST_FAILED 0x4003
150 1.8 mjacob #define MBOX_COMMAND_ERROR 0x4005
151 1.8 mjacob #define MBOX_COMMAND_PARAM_ERROR 0x4006
152 1.8 mjacob
153 1.8 mjacob /*
154 1.8 mjacob * Asynchronous event status codes
155 1.8 mjacob */
156 1.8 mjacob #define ASYNC_BUS_RESET 0x8001
157 1.8 mjacob #define ASYNC_SYSTEM_ERROR 0x8002
158 1.8 mjacob #define ASYNC_RQS_XFER_ERR 0x8003
159 1.8 mjacob #define ASYNC_RSP_XFER_ERR 0x8004
160 1.8 mjacob #define ASYNC_QWAKEUP 0x8005
161 1.8 mjacob #define ASYNC_TIMEOUT_RESET 0x8006
162 1.10 mjacob #define ASYNC_DEVICE_RESET 0x8007
163 1.8 mjacob #define ASYNC_EXTMSG_UNDERRUN 0x800A
164 1.8 mjacob #define ASYNC_SCAM_INT 0x800B
165 1.8 mjacob #define ASYNC_HUNG_SCSI 0x800C
166 1.8 mjacob #define ASYNC_KILLED_BUS 0x800D
167 1.8 mjacob #define ASYNC_BUS_TRANSIT 0x800E /* LVD -> HVD, eg. */
168 1.8 mjacob #define ASYNC_CMD_CMPLT 0x8020
169 1.8 mjacob #define ASYNC_CTIO_DONE 0x8021
170 1.8 mjacob
171 1.8 mjacob /* for ISP2100 only */
172 1.8 mjacob #define ASYNC_LIP_OCCURRED 0x8010
173 1.8 mjacob #define ASYNC_LOOP_UP 0x8011
174 1.8 mjacob #define ASYNC_LOOP_DOWN 0x8012
175 1.8 mjacob #define ASYNC_LOOP_RESET 0x8013
176 1.10 mjacob #define ASYNC_PDB_CHANGED 0x8014
177 1.8 mjacob #define ASYNC_CHANGE_NOTIFY 0x8015
178 1.8 mjacob
179 1.8 mjacob /*
180 1.1 cgd * Command Structure Definitions
181 1.1 cgd */
182 1.1 cgd
183 1.1 cgd typedef struct {
184 1.1 cgd u_int32_t ds_base;
185 1.1 cgd u_int32_t ds_count;
186 1.1 cgd } ispds_t;
187 1.1 cgd
188 1.1 cgd typedef struct {
189 1.1 cgd #if BYTE_ORDER == BIG_ENDIAN
190 1.1 cgd u_int8_t rqs_entry_count;
191 1.1 cgd u_int8_t rqs_entry_type;
192 1.1 cgd u_int8_t rqs_flags;
193 1.1 cgd u_int8_t rqs_seqno;
194 1.1 cgd #else
195 1.1 cgd u_int8_t rqs_entry_type;
196 1.1 cgd u_int8_t rqs_entry_count;
197 1.1 cgd u_int8_t rqs_seqno;
198 1.1 cgd u_int8_t rqs_flags;
199 1.1 cgd #endif
200 1.1 cgd } isphdr_t;
201 1.1 cgd
202 1.1 cgd /* RQS Flag definitions */
203 1.1 cgd #define RQSFLAG_CONTINUATION 0x01
204 1.1 cgd #define RQSFLAG_FULL 0x02
205 1.1 cgd #define RQSFLAG_BADHEADER 0x04
206 1.1 cgd #define RQSFLAG_BADPACKET 0x08
207 1.3 mjacob
208 1.1 cgd /* RQS entry_type definitions */
209 1.8 mjacob #define RQSTYPE_REQUEST 0x01
210 1.8 mjacob #define RQSTYPE_DATASEG 0x02
211 1.8 mjacob #define RQSTYPE_RESPONSE 0x03
212 1.8 mjacob #define RQSTYPE_MARKER 0x04
213 1.8 mjacob #define RQSTYPE_CMDONLY 0x05
214 1.8 mjacob #define RQSTYPE_ATIO 0x06 /* Target Mode */
215 1.8 mjacob #define RQSTYPE_CTIO0 0x07 /* Target Mode */
216 1.8 mjacob #define RQSTYPE_SCAM 0x08
217 1.8 mjacob #define RQSTYPE_A64 0x09
218 1.8 mjacob #define RQSTYPE_A64_CONT 0x0a
219 1.8 mjacob #define RQSTYPE_ENABLE_LUN 0x0b /* Target Mode */
220 1.8 mjacob #define RQSTYPE_MODIFY_LUN 0x0c /* Target Mode */
221 1.8 mjacob #define RQSTYPE_NOTIFY 0x0d /* Target Mode */
222 1.8 mjacob #define RQSTYPE_NOTIFY_ACK 0x0e /* Target Mode */
223 1.8 mjacob #define RQSTYPE_CTIO1 0x0f /* Target Mode */
224 1.8 mjacob #define RQSTYPE_STATUS_CONT 0x10
225 1.8 mjacob #define RQSTYPE_T2RQS 0x11
226 1.8 mjacob
227 1.8 mjacob #define RQSTYPE_T4RQS 0x15
228 1.8 mjacob #define RQSTYPE_ATIO2 0x16
229 1.8 mjacob #define RQSTYPE_CTIO2 0x17
230 1.8 mjacob #define RQSTYPE_CSET0 0x18
231 1.8 mjacob #define RQSTYPE_T3RQS 0x19
232 1.8 mjacob
233 1.8 mjacob #define RQSTYPE_CTIO3 0x1f
234 1.1 cgd
235 1.1 cgd
236 1.1 cgd #define ISP_RQDSEG 4
237 1.1 cgd typedef struct {
238 1.1 cgd isphdr_t req_header;
239 1.1 cgd u_int32_t req_handle;
240 1.1 cgd #if BYTE_ORDER == BIG_ENDIAN
241 1.1 cgd u_int8_t req_target;
242 1.1 cgd u_int8_t req_lun_trn;
243 1.1 cgd #else
244 1.1 cgd u_int8_t req_lun_trn;
245 1.1 cgd u_int8_t req_target;
246 1.1 cgd #endif
247 1.1 cgd u_int16_t req_cdblen;
248 1.1 cgd #define req_modifier req_cdblen /* marker packet */
249 1.1 cgd u_int16_t req_flags;
250 1.10 mjacob u_int16_t req_reserved;
251 1.1 cgd u_int16_t req_time;
252 1.1 cgd u_int16_t req_seg_count;
253 1.1 cgd u_int8_t req_cdb[12];
254 1.1 cgd ispds_t req_dataseg[ISP_RQDSEG];
255 1.1 cgd } ispreq_t;
256 1.1 cgd
257 1.3 mjacob #define ISP_RQDSEG_T2 3
258 1.3 mjacob typedef struct {
259 1.3 mjacob isphdr_t req_header;
260 1.3 mjacob u_int32_t req_handle;
261 1.3 mjacob #if BYTE_ORDER == BIG_ENDIAN
262 1.3 mjacob u_int8_t req_target;
263 1.3 mjacob u_int8_t req_lun_trn;
264 1.3 mjacob #else
265 1.3 mjacob u_int8_t req_lun_trn;
266 1.3 mjacob u_int8_t req_target;
267 1.3 mjacob #endif
268 1.10 mjacob u_int16_t req_scclun;
269 1.4 mjacob u_int16_t req_flags;
270 1.4 mjacob u_int16_t _res2;
271 1.3 mjacob u_int16_t req_time;
272 1.3 mjacob u_int16_t req_seg_count;
273 1.3 mjacob u_int32_t req_cdb[4];
274 1.3 mjacob u_int32_t req_totalcnt;
275 1.3 mjacob ispds_t req_dataseg[ISP_RQDSEG_T2];
276 1.3 mjacob } ispreqt2_t;
277 1.3 mjacob
278 1.1 cgd /* req_flag values */
279 1.1 cgd #define REQFLAG_NODISCON 0x0001
280 1.1 cgd #define REQFLAG_HTAG 0x0002
281 1.1 cgd #define REQFLAG_OTAG 0x0004
282 1.1 cgd #define REQFLAG_STAG 0x0008
283 1.1 cgd #define REQFLAG_TARGET_RTN 0x0010
284 1.1 cgd
285 1.1 cgd #define REQFLAG_NODATA 0x0000
286 1.1 cgd #define REQFLAG_DATA_IN 0x0020
287 1.1 cgd #define REQFLAG_DATA_OUT 0x0040
288 1.1 cgd #define REQFLAG_DATA_UNKNOWN 0x0060
289 1.1 cgd
290 1.1 cgd #define REQFLAG_DISARQ 0x0100
291 1.8 mjacob #define REQFLAG_FRC_ASYNC 0x0200
292 1.8 mjacob #define REQFLAG_FRC_SYNC 0x0400
293 1.8 mjacob #define REQFLAG_FRC_WIDE 0x0800
294 1.8 mjacob #define REQFLAG_NOPARITY 0x1000
295 1.8 mjacob #define REQFLAG_STOPQ 0x2000
296 1.8 mjacob #define REQFLAG_XTRASNS 0x4000
297 1.8 mjacob #define REQFLAG_PRIORITY 0x8000
298 1.1 cgd
299 1.1 cgd typedef struct {
300 1.1 cgd isphdr_t req_header;
301 1.1 cgd u_int32_t req_handle;
302 1.1 cgd #if BYTE_ORDER == BIG_ENDIAN
303 1.1 cgd u_int8_t req_target;
304 1.1 cgd u_int8_t req_lun_trn;
305 1.1 cgd #else
306 1.1 cgd u_int8_t req_lun_trn;
307 1.1 cgd u_int8_t req_target;
308 1.1 cgd #endif
309 1.1 cgd u_int16_t req_cdblen;
310 1.1 cgd u_int16_t req_flags;
311 1.1 cgd u_int16_t _res1;
312 1.1 cgd u_int16_t req_time;
313 1.1 cgd u_int16_t req_seg_count;
314 1.1 cgd u_int8_t req_cdb[44];
315 1.1 cgd } ispextreq_t;
316 1.1 cgd
317 1.1 cgd #define ISP_CDSEG 7
318 1.1 cgd typedef struct {
319 1.1 cgd isphdr_t req_header;
320 1.1 cgd u_int32_t _res1;
321 1.1 cgd ispds_t req_dataseg[ISP_CDSEG];
322 1.1 cgd } ispcontreq_t;
323 1.1 cgd
324 1.1 cgd typedef struct {
325 1.1 cgd isphdr_t req_header;
326 1.1 cgd u_int32_t _res1;
327 1.1 cgd #if BYTE_ORDER == BIG_ENDIAN
328 1.1 cgd u_int8_t req_target;
329 1.1 cgd u_int8_t req_lun_trn;
330 1.1 cgd u_int8_t _res2;
331 1.1 cgd u_int8_t req_modifier;
332 1.1 cgd #else
333 1.1 cgd u_int8_t req_lun_trn;
334 1.1 cgd u_int8_t req_target;
335 1.1 cgd u_int8_t req_modifier;
336 1.1 cgd u_int8_t _res2;
337 1.1 cgd #endif
338 1.3 mjacob } ispmarkreq_t;
339 1.1 cgd
340 1.1 cgd #define SYNC_DEVICE 0
341 1.1 cgd #define SYNC_TARGET 1
342 1.1 cgd #define SYNC_ALL 2
343 1.1 cgd
344 1.1 cgd typedef struct {
345 1.1 cgd isphdr_t req_header;
346 1.1 cgd u_int32_t req_handle;
347 1.1 cgd u_int16_t req_scsi_status;
348 1.1 cgd u_int16_t req_completion_status;
349 1.1 cgd u_int16_t req_state_flags;
350 1.1 cgd u_int16_t req_status_flags;
351 1.1 cgd u_int16_t req_time;
352 1.1 cgd u_int16_t req_sense_len;
353 1.1 cgd u_int32_t req_resid;
354 1.1 cgd u_int8_t _res1[8];
355 1.1 cgd u_int8_t req_sense_data[32];
356 1.1 cgd } ispstatusreq_t;
357 1.1 cgd
358 1.3 mjacob /*
359 1.3 mjacob * For Qlogic 2100, the high order byte of SCSI status has
360 1.3 mjacob * additional meaning.
361 1.3 mjacob */
362 1.3 mjacob #define RQCS_RU 0x800 /* Residual Under */
363 1.3 mjacob #define RQCS_RO 0x400 /* Residual Over */
364 1.3 mjacob #define RQCS_SV 0x200 /* Sense Length Valid */
365 1.3 mjacob #define RQCS_RV 0x100 /* Residual Valid */
366 1.3 mjacob
367 1.3 mjacob /*
368 1.3 mjacob * Completion Status Codes.
369 1.3 mjacob */
370 1.1 cgd #define RQCS_COMPLETE 0x0000
371 1.1 cgd #define RQCS_INCOMPLETE 0x0001
372 1.1 cgd #define RQCS_DMA_ERROR 0x0002
373 1.1 cgd #define RQCS_TRANSPORT_ERROR 0x0003
374 1.1 cgd #define RQCS_RESET_OCCURRED 0x0004
375 1.1 cgd #define RQCS_ABORTED 0x0005
376 1.1 cgd #define RQCS_TIMEOUT 0x0006
377 1.1 cgd #define RQCS_DATA_OVERRUN 0x0007
378 1.1 cgd #define RQCS_COMMAND_OVERRUN 0x0008
379 1.1 cgd #define RQCS_STATUS_OVERRUN 0x0009
380 1.1 cgd #define RQCS_BAD_MESSAGE 0x000a
381 1.1 cgd #define RQCS_NO_MESSAGE_OUT 0x000b
382 1.1 cgd #define RQCS_EXT_ID_FAILED 0x000c
383 1.1 cgd #define RQCS_IDE_MSG_FAILED 0x000d
384 1.1 cgd #define RQCS_ABORT_MSG_FAILED 0x000e
385 1.1 cgd #define RQCS_REJECT_MSG_FAILED 0x000f
386 1.1 cgd #define RQCS_NOP_MSG_FAILED 0x0010
387 1.1 cgd #define RQCS_PARITY_ERROR_MSG_FAILED 0x0011
388 1.1 cgd #define RQCS_DEVICE_RESET_MSG_FAILED 0x0012
389 1.1 cgd #define RQCS_ID_MSG_FAILED 0x0013
390 1.1 cgd #define RQCS_UNEXP_BUS_FREE 0x0014
391 1.1 cgd #define RQCS_DATA_UNDERRUN 0x0015
392 1.8 mjacob #define RQCS_XACT_ERR1 0x0018
393 1.8 mjacob #define RQCS_XACT_ERR2 0x0019
394 1.8 mjacob #define RQCS_XACT_ERR3 0x001A
395 1.8 mjacob #define RQCS_BAD_ENTRY 0x001B
396 1.8 mjacob #define RQCS_QUEUE_FULL 0x001C
397 1.8 mjacob #define RQCS_PHASE_SKIPPED 0x001D
398 1.8 mjacob #define RQCS_ARQS_FAILED 0x001E
399 1.8 mjacob #define RQCS_WIDE_FAILED 0x001F
400 1.8 mjacob #define RQCS_SYNCXFER_FAILED 0x0020
401 1.8 mjacob #define RQCS_LVD_BUSERR 0x0021
402 1.8 mjacob
403 1.3 mjacob /* 2100 Only Completion Codes */
404 1.3 mjacob #define RQCS_PORT_UNAVAILABLE 0x0028
405 1.3 mjacob #define RQCS_PORT_LOGGED_OUT 0x0029
406 1.3 mjacob #define RQCS_PORT_CHANGED 0x002A
407 1.3 mjacob #define RQCS_PORT_BUSY 0x002B
408 1.1 cgd
409 1.3 mjacob /*
410 1.3 mjacob * State Flags (not applicable to 2100)
411 1.3 mjacob */
412 1.1 cgd #define RQSF_GOT_BUS 0x0100
413 1.1 cgd #define RQSF_GOT_TARGET 0x0200
414 1.1 cgd #define RQSF_SENT_CDB 0x0400
415 1.5 mjacob #define RQSF_XFRD_DATA 0x0800
416 1.1 cgd #define RQSF_GOT_STATUS 0x1000
417 1.1 cgd #define RQSF_GOT_SENSE 0x2000
418 1.5 mjacob #define RQSF_XFER_COMPLETE 0x4000
419 1.1 cgd
420 1.3 mjacob /*
421 1.3 mjacob * Status Flags (not applicable to 2100)
422 1.3 mjacob */
423 1.1 cgd #define RQSTF_DISCONNECT 0x0001
424 1.1 cgd #define RQSTF_SYNCHRONOUS 0x0002
425 1.1 cgd #define RQSTF_PARITY_ERROR 0x0004
426 1.1 cgd #define RQSTF_BUS_RESET 0x0008
427 1.1 cgd #define RQSTF_DEVICE_RESET 0x0010
428 1.1 cgd #define RQSTF_ABORTED 0x0020
429 1.1 cgd #define RQSTF_TIMEOUT 0x0040
430 1.1 cgd #define RQSTF_NEGOTIATION 0x0080
431 1.3 mjacob
432 1.3 mjacob /*
433 1.14 mjacob * FC (ISP2100) specific data structures
434 1.3 mjacob */
435 1.3 mjacob
436 1.3 mjacob /*
437 1.3 mjacob * Initialization Control Block
438 1.8 mjacob *
439 1.8 mjacob * Version One format.
440 1.3 mjacob */
441 1.3 mjacob typedef struct {
442 1.3 mjacob #if BYTE_ORDER == BIG_ENDIAN
443 1.3 mjacob u_int8_t _reserved0;
444 1.3 mjacob u_int8_t icb_version;
445 1.3 mjacob #else
446 1.3 mjacob u_int8_t icb_version;
447 1.3 mjacob u_int8_t _reserved0;
448 1.3 mjacob #endif
449 1.3 mjacob u_int16_t icb_fwoptions;
450 1.3 mjacob u_int16_t icb_maxfrmlen;
451 1.3 mjacob u_int16_t icb_maxalloc;
452 1.3 mjacob u_int16_t icb_execthrottle;
453 1.3 mjacob #if BYTE_ORDER == BIG_ENDIAN
454 1.3 mjacob u_int8_t icb_retry_delay;
455 1.3 mjacob u_int8_t icb_retry_count;
456 1.3 mjacob #else
457 1.3 mjacob u_int8_t icb_retry_count;
458 1.3 mjacob u_int8_t icb_retry_delay;
459 1.3 mjacob #endif
460 1.8 mjacob u_int8_t icb_nodename[8];
461 1.3 mjacob u_int16_t icb_hardaddr;
462 1.8 mjacob #if BYTE_ORDER == BIG_ENDIAN
463 1.8 mjacob u_int8_t _reserved1;
464 1.8 mjacob u_int8_t icb_iqdevtype;
465 1.8 mjacob #else
466 1.8 mjacob u_int8_t icb_iqdevtype;
467 1.8 mjacob u_int8_t _reserved1;
468 1.8 mjacob #endif
469 1.8 mjacob u_int8_t icb_portname[8];
470 1.3 mjacob u_int16_t icb_rqstout;
471 1.3 mjacob u_int16_t icb_rspnsin;
472 1.3 mjacob u_int16_t icb_rqstqlen;
473 1.3 mjacob u_int16_t icb_rsltqlen;
474 1.3 mjacob u_int16_t icb_rqstaddr[4];
475 1.3 mjacob u_int16_t icb_respaddr[4];
476 1.3 mjacob } isp_icb_t;
477 1.8 mjacob #define ICB_VERSION1 1
478 1.8 mjacob
479 1.8 mjacob #define ICBOPT_HARD_ADDRESS (1<<0)
480 1.8 mjacob #define ICBOPT_FAIRNESS (1<<1)
481 1.8 mjacob #define ICBOPT_FULL_DUPLEX (1<<2)
482 1.8 mjacob #define ICBOPT_FAST_POST (1<<3)
483 1.8 mjacob #define ICBOPT_TGT_ENABLE (1<<4)
484 1.8 mjacob #define ICBOPT_INI_DISABLE (1<<5)
485 1.8 mjacob #define ICBOPT_INI_ADISC (1<<6)
486 1.8 mjacob #define ICBOPT_INI_TGTTYPE (1<<7)
487 1.8 mjacob #define ICBOPT_PDBCHANGE_AE (1<<8)
488 1.8 mjacob #define ICBOPT_NOLIP (1<<9)
489 1.8 mjacob #define ICBOPT_SRCHDOWN (1<<10)
490 1.8 mjacob #define ICBOPT_PREVLOOP (1<<11)
491 1.8 mjacob #define ICBOPT_STOP_ON_QFULL (1<<12)
492 1.8 mjacob #define ICBOPT_FULL_LOGIN (1<<13)
493 1.8 mjacob #define ICBOPT_USE_PORTNAME (1<<14)
494 1.8 mjacob
495 1.8 mjacob
496 1.8 mjacob #define ICB_MIN_FRMLEN 256
497 1.8 mjacob #define ICB_MAX_FRMLEN 2112
498 1.8 mjacob #define ICB_DFLT_FRMLEN 1024
499 1.8 mjacob
500 1.8 mjacob #define RQRSP_ADDR0015 0
501 1.8 mjacob #define RQRSP_ADDR1631 1
502 1.8 mjacob #define RQRSP_ADDR3247 2
503 1.8 mjacob #define RQRSP_ADDR4863 3
504 1.8 mjacob
505 1.8 mjacob
506 1.8 mjacob #define ICB_NNM0 7
507 1.8 mjacob #define ICB_NNM1 6
508 1.8 mjacob #define ICB_NNM2 5
509 1.8 mjacob #define ICB_NNM3 4
510 1.8 mjacob #define ICB_NNM4 3
511 1.8 mjacob #define ICB_NNM5 2
512 1.8 mjacob #define ICB_NNM6 1
513 1.8 mjacob #define ICB_NNM7 0
514 1.3 mjacob
515 1.8 mjacob #define MAKE_NODE_NAME_FROM_WWN(array, wwn) \
516 1.8 mjacob array[ICB_NNM0] = (u_int8_t) ((wwn >> 0) & 0xff), \
517 1.8 mjacob array[ICB_NNM1] = (u_int8_t) ((wwn >> 8) & 0xff), \
518 1.8 mjacob array[ICB_NNM2] = (u_int8_t) ((wwn >> 16) & 0xff), \
519 1.8 mjacob array[ICB_NNM3] = (u_int8_t) ((wwn >> 24) & 0xff), \
520 1.8 mjacob array[ICB_NNM4] = (u_int8_t) ((wwn >> 32) & 0xff), \
521 1.8 mjacob array[ICB_NNM5] = (u_int8_t) ((wwn >> 40) & 0xff), \
522 1.8 mjacob array[ICB_NNM6] = (u_int8_t) ((wwn >> 48) & 0xff), \
523 1.8 mjacob array[ICB_NNM7] = (u_int8_t) ((wwn >> 56) & 0xff)
524 1.14 mjacob
525 1.14 mjacob /*
526 1.14 mjacob * Port Data Base Element
527 1.14 mjacob */
528 1.14 mjacob
529 1.14 mjacob typedef struct {
530 1.14 mjacob u_int16_t pdb_options;
531 1.14 mjacob #if BYTE_ORDER == BIG_ENDIAN
532 1.14 mjacob u_int8_t pdb_sstate;
533 1.14 mjacob u_int8_t pdb_mstate;
534 1.14 mjacob #else
535 1.14 mjacob u_int8_t pdb_mstate;
536 1.14 mjacob u_int8_t pdb_sstate;
537 1.14 mjacob #endif
538 1.14 mjacob #if BYTE_ORDER == BIG_ENDIAN
539 1.14 mjacob #define BITS2WORD(x) \
540 1.14 mjacob (x)[1] << 16 | (x)[2] << 8 | (x)[3]
541 1.14 mjacob #else
542 1.14 mjacob #define BITS2WORD(x) \
543 1.14 mjacob (x)[0] << 16 | (x)[3] << 8 | (x)[2]
544 1.14 mjacob #endif
545 1.14 mjacob u_int8_t pdb_hardaddr_bits[4];
546 1.14 mjacob u_int8_t pdb_portid_bits[4];
547 1.14 mjacob u_int8_t pdb_nodename[8];
548 1.14 mjacob u_int8_t pdb_portname[8];
549 1.14 mjacob u_int16_t pdb_execthrottle;
550 1.14 mjacob u_int16_t pdb_exec_count;
551 1.14 mjacob #if BYTE_ORDER == BIG_ENDIAN
552 1.14 mjacob u_int8_t pdb_retry_delay;
553 1.14 mjacob u_int8_t pdb_retry_count;
554 1.14 mjacob #else
555 1.14 mjacob u_int8_t pdb_retry_count;
556 1.14 mjacob u_int8_t pdb_retry_delay;
557 1.14 mjacob #endif
558 1.14 mjacob u_int16_t pdb_resalloc;
559 1.14 mjacob u_int16_t pdb_curalloc;
560 1.14 mjacob u_int16_t pdb_qhead;
561 1.14 mjacob u_int16_t pdb_qtail;
562 1.14 mjacob u_int16_t pdb_tl_next;
563 1.14 mjacob u_int16_t pdb_tl_last;
564 1.14 mjacob u_int16_t pdb_features; /* PLOGI, Common Service */
565 1.14 mjacob u_int16_t pdb_pconcurrnt; /* PLOGI, Common Service */
566 1.14 mjacob u_int16_t pdb_roi; /* PLOGI, Common Service */
567 1.14 mjacob #if BYTE_ORDER == BIG_ENDIAN
568 1.14 mjacob u_int8_t pdb_initiator; /* PLOGI, Class 3 Control Flags */
569 1.14 mjacob u_int8_t pdb_target;
570 1.14 mjacob #else
571 1.14 mjacob u_int8_t pdb_target;
572 1.14 mjacob u_int8_t pdb_initiator; /* PLOGI, Class 3 Control Flags */
573 1.14 mjacob #endif
574 1.14 mjacob u_int16_t pdb_rdsiz; /* PLOGI, Class 3 */
575 1.14 mjacob u_int16_t pdb_ncseq; /* PLOGI, Class 3 */
576 1.14 mjacob u_int16_t pdb_noseq; /* PLOGI, Class 3 */
577 1.14 mjacob u_int16_t pdb_labrtflg;
578 1.14 mjacob u_int16_t pdb_lstopflg;
579 1.14 mjacob u_int16_t pdb_sqhead;
580 1.14 mjacob u_int16_t pdb_sqtail;
581 1.14 mjacob u_int16_t pdb_ptimer;
582 1.14 mjacob u_int16_t pdb_nxt_seqid;
583 1.14 mjacob u_int16_t pdb_fcount;
584 1.14 mjacob u_int16_t pdb_prli_len;
585 1.14 mjacob u_int16_t pdb_prli_svc0;
586 1.14 mjacob u_int16_t pdb_prli_svc3;
587 1.14 mjacob u_int16_t pdb_loopid;
588 1.14 mjacob u_int16_t pdb_il_ptr;
589 1.14 mjacob u_int16_t pdb_sl_ptr;
590 1.14 mjacob } isp_pdb_t;
591 1.14 mjacob
592 1.14 mjacob #define INVALID_PDB_OPTIONS 0xDEAD
593 1.14 mjacob
594 1.14 mjacob #define PDB_OPTIONS_XMITTING (1<<11)
595 1.14 mjacob #define PDB_OPTIONS_LNKXMIT (1<<10)
596 1.14 mjacob #define PDB_OPTIONS_ABORTED (1<<9)
597 1.14 mjacob #define PDB_OPTIONS_ADISC (1<<1)
598 1.14 mjacob
599 1.14 mjacob #define PDB_STATE_DISCOVERY 0
600 1.14 mjacob #define PDB_STATE_WDISC_ACK 1
601 1.14 mjacob #define PDB_STATE_PLOGI 2
602 1.14 mjacob #define PDB_STATE_PLOGI_ACK 3
603 1.14 mjacob #define PDB_STATE_PRLI 4
604 1.14 mjacob #define PDB_STATE_PRLI_ACK 5
605 1.14 mjacob #define PDB_STATE_LOGGED_IN 6
606 1.14 mjacob #define PDB_STATE_PORT_UNAVAIL 7
607 1.14 mjacob #define PDB_STATE_PRLO 8
608 1.14 mjacob #define PDB_STATE_PRLO_ACK 9
609 1.14 mjacob #define PDB_STATE_PLOGO 10
610 1.14 mjacob #define PDB_STATE_PLOG_ACK 11
611 1.14 mjacob
612 1.14 mjacob #define SVC3_TGT_ROLE 0x10
613 1.14 mjacob #define SVC3_INI_ROLE 0x20
614 1.14 mjacob #define SVC3_ROLE_MASK 0x30
615 1.10 mjacob
616 1.10 mjacob /*
617 1.10 mjacob * Target Mode Structures
618 1.10 mjacob */
619 1.10 mjacob #define TGTSVALID 0x80 /* scsi status & sense data valid */
620 1.10 mjacob #define SUGGSENSELEN 18
621 1.10 mjacob
622 1.10 mjacob /*
623 1.10 mjacob * Structure for Enable Lun and Modify Lun queue entries
624 1.10 mjacob */
625 1.10 mjacob typedef struct {
626 1.10 mjacob isphdr_t le_header;
627 1.10 mjacob u_int32_t le_reserved2;
628 1.10 mjacob #if BYTE_ORDER == BIG_ENDIAN
629 1.10 mjacob #else
630 1.10 mjacob u_int8_t le_lun;
631 1.10 mjacob u_int8_t le_rsvd;
632 1.10 mjacob u_int8_t le_ops; /* Modify LUN only */
633 1.10 mjacob u_int8_t le_tgt; /* Not for FC */
634 1.10 mjacob #endif
635 1.10 mjacob u_int32_t le_flags; /* Not for FC */
636 1.10 mjacob #if BYTE_ORDER == BIG_ENDIAN
637 1.10 mjacob #else
638 1.10 mjacob u_int8_t le_status;
639 1.10 mjacob u_int8_t le_rsvd2;
640 1.10 mjacob u_int8_t le_cmd_count;
641 1.10 mjacob u_int8_t le_in_count;
642 1.10 mjacob u_int8_t le_cdb6len; /* Not for FC */
643 1.10 mjacob u_int8_t le_cdb7len; /* Not for FC */
644 1.10 mjacob #endif
645 1.10 mjacob u_int16_t le_timeout;
646 1.10 mjacob u_int16_t le_reserved[20];
647 1.10 mjacob } lun_entry_t;
648 1.10 mjacob
649 1.10 mjacob /*
650 1.10 mjacob * le_flags values
651 1.10 mjacob */
652 1.10 mjacob #define LUN_TQAE 0x00000001 /* Tagged Queue Action Enable */
653 1.10 mjacob #define LUN_DSSM 0x01000000 /* Disable Sending SDP Message */
654 1.10 mjacob #define LUN_DM 0x40000000 /* Disconnects Mandatory */
655 1.10 mjacob
656 1.10 mjacob /*
657 1.10 mjacob * le_ops values
658 1.10 mjacob */
659 1.10 mjacob #define LUN_CCINCR 0x01 /* increment command count */
660 1.10 mjacob #define LUN_CCDECR 0x02 /* decrement command count */
661 1.10 mjacob #define LUN_ININCR 0x40 /* increment immed. notify count */
662 1.10 mjacob #define LUN_INDECR 0x80 /* decrement immed. notify count */
663 1.10 mjacob
664 1.10 mjacob /*
665 1.10 mjacob * le_status values
666 1.10 mjacob */
667 1.10 mjacob #define LUN_ERR 0x04 /* request completed with error */
668 1.10 mjacob #define LUN_INVAL 0x06 /* invalid request */
669 1.10 mjacob #define LUN_NOCAP 0x16 /* can't provide requested capability */
670 1.10 mjacob #define LUN_ENABLED 0x3E /* LUN already enabled */
671 1.10 mjacob
672 1.10 mjacob /*
673 1.10 mjacob * Immediate Notify Entry structure
674 1.10 mjacob */
675 1.10 mjacob #define IN_MSGLEN 8 /* 8 bytes */
676 1.10 mjacob #define IN_RSVDLEN 8 /* 8 words */
677 1.10 mjacob typedef struct {
678 1.10 mjacob isphdr_t in_header;
679 1.10 mjacob u_int32_t in_reserved2;
680 1.10 mjacob #if BYTE_ORDER == BIG_ENDIAN
681 1.10 mjacob #else
682 1.10 mjacob u_int8_t in_lun; /* lun */
683 1.10 mjacob u_int8_t in_iid; /* initiator */
684 1.10 mjacob u_int8_t in_rsvd;
685 1.10 mjacob u_int8_t in_tgt; /* target */
686 1.10 mjacob #endif
687 1.10 mjacob u_int32_t in_flags;
688 1.10 mjacob #if BYTE_ORDER == BIG_ENDIAN
689 1.10 mjacob #else
690 1.10 mjacob u_int8_t in_status;
691 1.10 mjacob u_int8_t in_rsvd2;
692 1.10 mjacob u_int8_t in_tag_val; /* tag value */
693 1.10 mjacob u_int8_t in_tag_type; /* tag type */
694 1.10 mjacob #endif
695 1.10 mjacob u_int16_t in_seqid; /* sequence id */
696 1.10 mjacob u_int8_t in_msg[IN_MSGLEN]; /* SCSI message bytes */
697 1.10 mjacob u_int16_t in_reserved[IN_RSVDLEN];
698 1.10 mjacob u_int8_t in_sense[SUGGSENSELEN]; /* suggested sense data */
699 1.10 mjacob } in_entry_t;
700 1.10 mjacob
701 1.10 mjacob typedef struct {
702 1.10 mjacob isphdr_t in_header;
703 1.10 mjacob u_int32_t in_reserved2;
704 1.10 mjacob #if BYTE_ORDER == BIG_ENDIAN
705 1.10 mjacob #else
706 1.10 mjacob u_int8_t in_lun; /* lun */
707 1.10 mjacob u_int8_t in_iid; /* initiator */
708 1.10 mjacob #endif
709 1.10 mjacob u_int16_t in_rsvd;
710 1.10 mjacob u_int32_t in_rsvd2;
711 1.10 mjacob u_int16_t in_status;
712 1.10 mjacob u_int16_t in_task_flags;
713 1.10 mjacob u_int16_t in_seqid; /* sequence id */
714 1.10 mjacob } in_fcentry_t;
715 1.10 mjacob
716 1.10 mjacob /*
717 1.10 mjacob * Values for the in_status field
718 1.10 mjacob */
719 1.10 mjacob #define IN_NO_RCAP 0x16 /* requested capability not available */
720 1.10 mjacob #define IN_IDE_RECEIVED 0x33 /* Initiator Detected Error msg received */
721 1.10 mjacob #define IN_RSRC_UNAVAIL 0x34 /* resource unavailable */
722 1.10 mjacob #define IN_MSG_RECEIVED 0x36 /* SCSI message received */
723 1.10 mjacob #define IN_PORT_LOGOUT 0x29 /* port has logged out (FC) */
724 1.10 mjacob #define IN_ABORT_TASK 0x20 /* task named in RX_ID is being aborted (FC) */
725 1.10 mjacob
726 1.10 mjacob /*
727 1.10 mjacob * Notify Acknowledge Entry structure
728 1.10 mjacob */
729 1.10 mjacob #define NA_RSVDLEN 22
730 1.10 mjacob typedef struct {
731 1.10 mjacob isphdr_t na_header;
732 1.10 mjacob u_int32_t na_reserved2;
733 1.10 mjacob #if BYTE_ORDER == BIG_ENDIAN
734 1.10 mjacob #else
735 1.10 mjacob u_int8_t na_lun; /* lun */
736 1.10 mjacob u_int8_t na_iid; /* initiator */
737 1.10 mjacob u_int8_t na_rsvd;
738 1.10 mjacob u_int8_t na_tgt; /* target */
739 1.10 mjacob #endif
740 1.10 mjacob u_int32_t na_flags;
741 1.10 mjacob #if BYTE_ORDER == BIG_ENDIAN
742 1.10 mjacob #else
743 1.10 mjacob u_int8_t na_status;
744 1.10 mjacob u_int8_t na_event;
745 1.10 mjacob #endif
746 1.10 mjacob u_int16_t na_seqid; /* sequence id */
747 1.10 mjacob u_int16_t na_reserved[NA_RSVDLEN];
748 1.10 mjacob } na_entry_t;
749 1.10 mjacob
750 1.10 mjacob /*
751 1.10 mjacob * Value for the na_event field
752 1.10 mjacob */
753 1.10 mjacob #define NA_RST_CLRD 0x80 /* Clear an async event notification */
754 1.10 mjacob
755 1.10 mjacob #define NA2_RSVDLEN 21
756 1.10 mjacob typedef struct {
757 1.10 mjacob isphdr_t na_header;
758 1.10 mjacob u_int32_t na_reserved2;
759 1.10 mjacob #if BYTE_ORDER == BIG_ENDIAN
760 1.10 mjacob #else
761 1.10 mjacob u_int8_t na_lun; /* lun */
762 1.10 mjacob u_int8_t na_iid; /* initiator */
763 1.10 mjacob #endif
764 1.10 mjacob u_int16_t na_rsvd;
765 1.10 mjacob u_int16_t na_flags;
766 1.10 mjacob u_int16_t na_rsvd2;
767 1.10 mjacob u_int16_t na_status;
768 1.10 mjacob u_int16_t na_task_flags;
769 1.10 mjacob u_int16_t na_seqid; /* sequence id */
770 1.10 mjacob u_int16_t na_reserved[NA2_RSVDLEN];
771 1.10 mjacob } na_fcentry_t;
772 1.10 mjacob #define NAFC_RST_CLRD 0x40
773 1.10 mjacob
774 1.10 mjacob /*
775 1.10 mjacob * Value for the na_event field
776 1.10 mjacob */
777 1.10 mjacob #define NA_RST_CLRD 0x80 /* Clear an async event notification */
778 1.10 mjacob /*
779 1.10 mjacob * Accept Target I/O Entry structure
780 1.10 mjacob */
781 1.10 mjacob #define ATIO_CDBLEN 26
782 1.10 mjacob
783 1.10 mjacob typedef struct {
784 1.10 mjacob isphdr_t at_header;
785 1.10 mjacob u_int32_t at_reserved2;
786 1.10 mjacob #if BYTE_ORDER == BIG_ENDIAN
787 1.10 mjacob #else
788 1.10 mjacob u_int8_t at_lun; /* lun */
789 1.10 mjacob u_int8_t at_iid; /* initiator */
790 1.10 mjacob u_int8_t at_cdblen; /* cdb length */
791 1.10 mjacob u_int8_t at_tgt; /* target */
792 1.10 mjacob #endif
793 1.10 mjacob u_int32_t at_flags;
794 1.10 mjacob #if BYTE_ORDER == BIG_ENDIAN
795 1.10 mjacob #else
796 1.10 mjacob u_int8_t at_status; /* firmware status */
797 1.10 mjacob u_int8_t at_scsi_status; /* scsi status */
798 1.10 mjacob u_int8_t at_tag_val; /* tag value */
799 1.10 mjacob u_int8_t at_tag_type; /* tag type */
800 1.10 mjacob #endif
801 1.10 mjacob u_int8_t at_cdb[ATIO_CDBLEN]; /* received CDB */
802 1.10 mjacob u_int8_t at_sense[SUGGSENSELEN]; /* suggested sense data */
803 1.10 mjacob } at_entry_t;
804 1.10 mjacob
805 1.10 mjacob /*
806 1.10 mjacob * at_flags values
807 1.10 mjacob */
808 1.10 mjacob #define AT_NODISC 0x00008000 /* disconnect disabled */
809 1.10 mjacob #define AT_TQAE 0x00000001 /* Tagged Queue Action enabled */
810 1.10 mjacob
811 1.10 mjacob /*
812 1.10 mjacob * at_status values
813 1.10 mjacob */
814 1.10 mjacob #define AT_PATH_INVALID 0x07 /* ATIO sent to firmware for disabled lun */
815 1.10 mjacob #define AT_PHASE_ERROR 0x14 /* Bus phase sequence error */
816 1.10 mjacob #define AT_NOCAP 0x16 /* Requested capability not available */
817 1.10 mjacob #define AT_BDR_MSG 0x17 /* Bus Device Reset msg received */
818 1.10 mjacob #define AT_CDB 0x3D /* CDB received */
819 1.10 mjacob
820 1.10 mjacob /*
821 1.10 mjacob * Accept Target I/O Entry structure, Type 2
822 1.10 mjacob */
823 1.10 mjacob #define ATIO2_CDBLEN 16
824 1.10 mjacob
825 1.10 mjacob typedef struct {
826 1.10 mjacob isphdr_t at_header;
827 1.10 mjacob u_int32_t at_reserved2;
828 1.10 mjacob #if BYTE_ORDER == BIG_ENDIAN
829 1.10 mjacob #else
830 1.10 mjacob u_int8_t at_lun; /* lun */
831 1.10 mjacob u_int8_t at_iid; /* initiator */
832 1.10 mjacob #endif
833 1.10 mjacob u_int16_t at_rxid; /* response ID */
834 1.10 mjacob u_int16_t at_flags;
835 1.10 mjacob u_int16_t at_status; /* firmware status */
836 1.10 mjacob #if BYTE_ORDER == BIG_ENDIAN
837 1.10 mjacob #else
838 1.10 mjacob u_int8_t at_reserved1;
839 1.10 mjacob u_int8_t at_taskcodes;
840 1.10 mjacob u_int8_t at_taskflags;
841 1.10 mjacob u_int8_t at_execodes;
842 1.10 mjacob #endif
843 1.10 mjacob u_int8_t at_cdb[ATIO2_CDBLEN]; /* received CDB */
844 1.10 mjacob u_int32_t at_datalen; /* allocated data len */
845 1.10 mjacob u_int16_t at_scclun;
846 1.10 mjacob u_int16_t at_reserved3;
847 1.10 mjacob u_int16_t at_scsi_status;
848 1.10 mjacob u_int8_t at_sense[SUGGSENSELEN]; /* suggested sense data */
849 1.10 mjacob } at2_entry_t;
850 1.10 mjacob
851 1.10 mjacob #define ATIO2_TC_ATTR_MASK 0x7
852 1.10 mjacob #define ATIO2_TC_ATTR_SIMPLEQ 0
853 1.10 mjacob #define ATIO2_TC_ATTR_HEADOFQ 1
854 1.10 mjacob #define ATIO2_TC_ATTR_ORDERED 2
855 1.10 mjacob #define ATIO2_TC_ATTR_ACAQ 4
856 1.10 mjacob #define ATIO2_TC_ATTR_UNTAGGED 5
857 1.10 mjacob #define TC2TT(code) \
858 1.10 mjacob (((code) == ATIO2_TC_ATTR_SIMPLEQ)? 0x20 : \
859 1.10 mjacob (((code) == ATIO2_TC_ATTR_HEADOFQ)? 0x21 : \
860 1.10 mjacob (((code) == ATIO2_TC_ATTR_ORDERED)? 0x22 : \
861 1.10 mjacob (((code) == ATIO2_TC_ATTR_ACAQ)? 0x24 : 0))))
862 1.10 mjacob
863 1.10 mjacob
864 1.10 mjacob /*
865 1.10 mjacob * Continue Target I/O Entry structure
866 1.10 mjacob * Request from driver. The response from the
867 1.10 mjacob * ISP firmware is the same except that the last 18
868 1.10 mjacob * bytes are overwritten by suggested sense data if
869 1.10 mjacob * the 'autosense valid' bit is set in the status byte.
870 1.10 mjacob */
871 1.10 mjacob typedef struct {
872 1.10 mjacob isphdr_t ct_header;
873 1.10 mjacob u_int32_t ct_reserved;
874 1.10 mjacob #if BYTE_ORDER == BIG_ENDIAN
875 1.10 mjacob #else
876 1.10 mjacob u_int8_t ct_lun; /* lun */
877 1.10 mjacob u_int8_t ct_iid; /* initiator id */
878 1.10 mjacob u_int8_t ct_rsvd;
879 1.10 mjacob u_int8_t ct_tgt; /* our target id */
880 1.10 mjacob #endif
881 1.10 mjacob u_int32_t ct_flags;
882 1.10 mjacob #if BYTE_ORDER == BIG_ENDIAN
883 1.10 mjacob #else
884 1.10 mjacob u_int8_t ct_status; /* isp status */
885 1.10 mjacob u_int8_t ct_scsi_status; /* scsi status */
886 1.10 mjacob u_int8_t ct_tag_val; /* tag value */
887 1.10 mjacob u_int8_t ct_tag_type; /* tag type */
888 1.10 mjacob #endif
889 1.10 mjacob u_int32_t ct_xfrlen; /* transfer length */
890 1.10 mjacob u_int32_t ct_resid; /* residual length */
891 1.10 mjacob u_int16_t ct_timeout;
892 1.10 mjacob u_int16_t ct_seg_count;
893 1.10 mjacob ispds_t ct_dataseg[ISP_RQDSEG];
894 1.10 mjacob } ct_entry_t;
895 1.10 mjacob
896 1.10 mjacob /*
897 1.10 mjacob * ct_flags values
898 1.10 mjacob */
899 1.10 mjacob #define CT_TQAE 0x00000001 /* Tagged Queue Action enable */
900 1.10 mjacob #define CT_DATA_IN 0x00000040 /* Data direction */
901 1.10 mjacob #define CT_DATA_OUT 0x00000080 /* Data direction */
902 1.10 mjacob #define CT_NO_DATA 0x000000C0 /* Data direction */
903 1.10 mjacob #define CT_DATAMASK 0x000000C0 /* Data direction */
904 1.10 mjacob #define CT_NODISC 0x00008000 /* Disconnects disabled */
905 1.10 mjacob #define CT_DSDP 0x01000000 /* Disable Save Data Pointers */
906 1.10 mjacob #define CT_SENDRDP 0x04000000 /* Send Restore Pointers msg */
907 1.10 mjacob #define CT_SENDSTATUS 0x80000000 /* Send SCSI status byte */
908 1.10 mjacob
909 1.10 mjacob /*
910 1.10 mjacob * ct_status values
911 1.10 mjacob * - set by the firmware when it returns the CTIO
912 1.10 mjacob */
913 1.10 mjacob #define CT_OK 0x01 /* completed without error */
914 1.10 mjacob #define CT_ABORTED 0x02 /* aborted by host */
915 1.10 mjacob #define CT_ERR 0x04 /* see sense data for error */
916 1.10 mjacob #define CT_INVAL 0x06 /* request for disabled lun */
917 1.10 mjacob #define CT_NOPATH 0x07 /* invalid ITL nexus */
918 1.10 mjacob #define CT_INVRXID 0x08 /* (FC only) Invalid RX_ID */
919 1.10 mjacob #define CT_RSELTMO 0x0A /* reselection timeout after 2 tries */
920 1.10 mjacob #define CT_TIMEOUT 0x0B /* timed out */
921 1.10 mjacob #define CT_RESET 0x0E /* SCSI Bus Reset occurred */
922 1.10 mjacob #define CT_PHASE_ERROR 0x14 /* Bus phase sequence error */
923 1.10 mjacob #define CT_BDR_MSG 0x17 /* Bus Device Reset msg received */
924 1.10 mjacob #define CT_TERMINATED 0x19 /* due to Terminate Transfer mbox cmd */
925 1.10 mjacob #define CT_LOGOUT 0x29 /* port logout not acknowledged yet */
926 1.10 mjacob #define CT_NOACK 0x35 /* Outstanding Immed. Notify. entry */
927 1.10 mjacob
928 1.10 mjacob /*
929 1.10 mjacob * When the firmware returns a CTIO entry, it may overwrite the last
930 1.10 mjacob * part of the structure with sense data. This starts at offset 0x2E
931 1.10 mjacob * into the entry, which is in the middle of ct_dataseg[1]. Rather
932 1.10 mjacob * than define a new struct for this, I'm just using the sense data
933 1.10 mjacob * offset.
934 1.10 mjacob */
935 1.10 mjacob #define CTIO_SENSE_OFFSET 0x2E
936 1.10 mjacob
937 1.10 mjacob /*
938 1.10 mjacob * Entry length in u_longs. All entries are the same size so
939 1.10 mjacob * any one will do as the numerator.
940 1.10 mjacob */
941 1.10 mjacob #define UINT32_ENTRY_SIZE (sizeof(at_entry_t)/sizeof(u_int32_t))
942 1.10 mjacob
943 1.10 mjacob /*
944 1.10 mjacob * QLA2100 CTIO (type 2) entry
945 1.10 mjacob */
946 1.10 mjacob #define MAXRESPLEN 26
947 1.10 mjacob typedef struct {
948 1.10 mjacob isphdr_t ct_header;
949 1.10 mjacob u_int32_t ct_reserved;
950 1.10 mjacob #if BYTE_ORDER == BIG_ENDIAN
951 1.10 mjacob #else
952 1.10 mjacob u_int8_t ct_lun; /* lun */
953 1.10 mjacob u_int8_t ct_iid; /* initiator id */
954 1.10 mjacob #endif
955 1.10 mjacob u_int16_t ct_rxid; /* response ID */
956 1.10 mjacob u_int16_t ct_flags;
957 1.10 mjacob u_int16_t ct_status; /* isp status */
958 1.10 mjacob u_int16_t ct_timeout;
959 1.10 mjacob u_int16_t ct_seg_count;
960 1.10 mjacob u_int32_t ct_reloff; /* relative offset */
961 1.10 mjacob u_int32_t ct_resid; /* residual length */
962 1.10 mjacob union {
963 1.10 mjacob /*
964 1.10 mjacob * The three different modes that the target driver
965 1.10 mjacob * can set the CTIO2 up as.
966 1.10 mjacob *
967 1.10 mjacob * The first is for sending FCP_DATA_IUs as well as
968 1.10 mjacob * (optionally) sending a terminal SCSI status FCP_RSP_IU.
969 1.10 mjacob *
970 1.10 mjacob * The second is for sending SCSI sense data in an FCP_RSP_IU.
971 1.10 mjacob * Note that no FCP_DATA_IUs will be sent.
972 1.10 mjacob *
973 1.10 mjacob * The third is for sending FCP_RSP_IUs as built specifically
974 1.10 mjacob * in system memory as located by the isp_dataseg.
975 1.10 mjacob */
976 1.10 mjacob struct {
977 1.10 mjacob u_int32_t _reserved;
978 1.10 mjacob u_int16_t _reserved2;
979 1.10 mjacob u_int16_t ct_scsi_status;
980 1.10 mjacob u_int32_t ct_xfrlen;
981 1.10 mjacob ispds_t ct_dataseg[ISP_RQDSEG_T2];
982 1.10 mjacob } m0;
983 1.10 mjacob struct {
984 1.10 mjacob u_int16_t _reserved;
985 1.10 mjacob u_int16_t _reserved2;
986 1.10 mjacob u_int16_t ct_senselen;
987 1.10 mjacob u_int16_t ct_scsi_status;
988 1.10 mjacob u_int16_t ct_resplen;
989 1.10 mjacob u_int8_t ct_resp[MAXRESPLEN];
990 1.10 mjacob } m1;
991 1.10 mjacob struct {
992 1.10 mjacob u_int32_t _reserved;
993 1.10 mjacob u_int16_t _reserved2;
994 1.10 mjacob u_int16_t _reserved3;
995 1.10 mjacob u_int32_t ct_datalen;
996 1.10 mjacob ispds_t ct_fcp_rsp_iudata;
997 1.10 mjacob } m2;
998 1.10 mjacob /*
999 1.10 mjacob * CTIO2 returned from F/W...
1000 1.10 mjacob */
1001 1.10 mjacob struct {
1002 1.10 mjacob u_int32_t _reserved[4];
1003 1.10 mjacob u_int16_t ct_scsi_status;
1004 1.10 mjacob u_int8_t ct_sense[SUGGSENSELEN];
1005 1.10 mjacob } fw;
1006 1.10 mjacob } rsp;
1007 1.10 mjacob } ct2_entry_t;
1008 1.10 mjacob /*
1009 1.10 mjacob * ct_flags values for CTIO2
1010 1.10 mjacob */
1011 1.10 mjacob #define CT2_FLAG_MMASK 0x0003
1012 1.10 mjacob #define CT2_FLAG_MODE0 0x0000
1013 1.10 mjacob #define CT2_FLAG_MODE1 0x0001
1014 1.10 mjacob #define CT2_FLAG_MODE2 0x0002
1015 1.10 mjacob #define CT2_DATA_IN CT_DATA_IN
1016 1.10 mjacob #define CT2_DATA_OUT CT_DATA_OUT
1017 1.10 mjacob #define CT2_NO_DATA CT_NO_DATA
1018 1.10 mjacob #define CT2_DATAMASK CT_DATA_MASK
1019 1.10 mjacob #define CT2_CCINCR 0x0100
1020 1.10 mjacob #define CT2_FASTPOST 0x0200
1021 1.10 mjacob #define CT2_SENDSTATUS 0x8000
1022 1.10 mjacob
1023 1.10 mjacob /*
1024 1.10 mjacob * ct_status values are (mostly) the same as that for ct_entry.
1025 1.10 mjacob */
1026 1.10 mjacob
1027 1.10 mjacob /*
1028 1.10 mjacob * ct_scsi_status values- the low 8 bits are the normal SCSI status
1029 1.10 mjacob * we know and love. The upper 8 bits are validity markers for FCP_RSP_IU
1030 1.10 mjacob * fields.
1031 1.10 mjacob */
1032 1.10 mjacob #define CT2_RSPLEN_VALID 0x0100
1033 1.10 mjacob #define CT2_SNSLEN_VALID 0x0200
1034 1.10 mjacob #define CT2_DATA_OVER 0x0400
1035 1.10 mjacob #define CT2_DATA_UNDER 0x0800
1036 1.1 cgd
1037 1.1 cgd #endif /* _ISPMBOX_H */
1038