isp_target.h revision 1.1 1 1.1 mjacob /* $NetBSD: isp_target.h,v 1.1 2000/01/05 19:50:06 mjacob Exp $ */
2 1.1 mjacob /*
3 1.1 mjacob * Qlogic Target Mode Structure and Flag Definitions
4 1.1 mjacob *
5 1.1 mjacob * Copyright (c) 1997, 1998
6 1.1 mjacob * Patrick Stirling
7 1.1 mjacob * pms (at) psconsult.com
8 1.1 mjacob * All rights reserved.
9 1.1 mjacob *
10 1.1 mjacob * Additional Copyright (c) 1999
11 1.1 mjacob * Matthew Jacob
12 1.1 mjacob * mjacob (at) feral.com
13 1.1 mjacob * All rights reserved.
14 1.1 mjacob *
15 1.1 mjacob *
16 1.1 mjacob * Redistribution and use in source and binary forms, with or without
17 1.1 mjacob * modification, are permitted provided that the following conditions
18 1.1 mjacob * are met:
19 1.1 mjacob * 1. Redistributions of source code must retain the above copyright
20 1.1 mjacob * notice immediately at the beginning of the file, without modification,
21 1.1 mjacob * this list of conditions, and the following disclaimer.
22 1.1 mjacob * 2. Redistributions in binary form must reproduce the above copyright
23 1.1 mjacob * notice, this list of conditions and the following disclaimer in the
24 1.1 mjacob * documentation and/or other materials provided with the distribution.
25 1.1 mjacob * 3. The name of the author may not be used to endorse or promote products
26 1.1 mjacob * derived from this software without specific prior written permission.
27 1.1 mjacob *
28 1.1 mjacob * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
29 1.1 mjacob * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30 1.1 mjacob * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31 1.1 mjacob * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
32 1.1 mjacob * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33 1.1 mjacob * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
34 1.1 mjacob * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 1.1 mjacob * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 1.1 mjacob * SUCH DAMAGE.
37 1.1 mjacob *
38 1.1 mjacob */
39 1.1 mjacob #ifndef _ISPTARGET_H
40 1.1 mjacob #define _ISPTARGET_H
41 1.1 mjacob
42 1.1 mjacob /*
43 1.1 mjacob * Defines for all entry types
44 1.1 mjacob */
45 1.1 mjacob #define QLTM_SVALID 0x80
46 1.1 mjacob #define QLTM_SENSELEN 18
47 1.1 mjacob
48 1.1 mjacob /*
49 1.1 mjacob * Structure for Enable Lun and Modify Lun queue entries
50 1.1 mjacob */
51 1.1 mjacob typedef struct {
52 1.1 mjacob isphdr_t le_header;
53 1.1 mjacob u_int32_t le_reserved;
54 1.1 mjacob u_int8_t le_lun;
55 1.1 mjacob u_int8_t le_rsvd;
56 1.1 mjacob u_int8_t le_ops; /* Modify LUN only */
57 1.1 mjacob u_int8_t le_tgt; /* Not for FC */
58 1.1 mjacob u_int32_t le_flags; /* Not for FC */
59 1.1 mjacob u_int8_t le_status;
60 1.1 mjacob u_int8_t le_reserved2;
61 1.1 mjacob u_int8_t le_cmd_count;
62 1.1 mjacob u_int8_t le_in_count;
63 1.1 mjacob u_int8_t le_cdb6len; /* Not for FC */
64 1.1 mjacob u_int8_t le_cdb7len; /* Not for FC */
65 1.1 mjacob u_int16_t le_timeout;
66 1.1 mjacob u_int16_t le_reserved3[20];
67 1.1 mjacob } lun_entry_t;
68 1.1 mjacob
69 1.1 mjacob /*
70 1.1 mjacob * le_flags values
71 1.1 mjacob */
72 1.1 mjacob #define LUN_TQAE 0x00000001 /* bit1 Tagged Queue Action Enable */
73 1.1 mjacob #define LUN_DSSM 0x01000000 /* bit24 Disable Sending SDP Message */
74 1.1 mjacob #define LUN_DM 0x40000000 /* bit30 Disconnects Mandatory */
75 1.1 mjacob
76 1.1 mjacob /*
77 1.1 mjacob * le_ops values
78 1.1 mjacob */
79 1.1 mjacob #define LUN_CCINCR 0x01 /* increment command count */
80 1.1 mjacob #define LUN_CCDECR 0x02 /* decrement command count */
81 1.1 mjacob #define LUN_ININCR 0x40 /* increment immed. notify count */
82 1.1 mjacob #define LUN_INDECR 0x80 /* decrement immed. notify count */
83 1.1 mjacob
84 1.1 mjacob /*
85 1.1 mjacob * le_status values
86 1.1 mjacob */
87 1.1 mjacob #define LUN_OK 0x01 /* we be rockin' */
88 1.1 mjacob #define LUN_ERR 0x04 /* request completed with error */
89 1.1 mjacob #define LUN_INVAL 0x06 /* invalid request */
90 1.1 mjacob #define LUN_NOCAP 0x16 /* can't provide requested capability */
91 1.1 mjacob #define LUN_ENABLED 0x3E /* LUN already enabled */
92 1.1 mjacob
93 1.1 mjacob /*
94 1.1 mjacob * Immediate Notify Entry structure
95 1.1 mjacob */
96 1.1 mjacob #define IN_MSGLEN 8 /* 8 bytes */
97 1.1 mjacob #define IN_RSVDLEN 8 /* 8 words */
98 1.1 mjacob typedef struct {
99 1.1 mjacob isphdr_t in_header;
100 1.1 mjacob u_int32_t in_reserved;
101 1.1 mjacob u_int8_t in_lun; /* lun */
102 1.1 mjacob u_int8_t in_iid; /* initiator */
103 1.1 mjacob u_int8_t in_reserved2;
104 1.1 mjacob u_int8_t in_tgt; /* target */
105 1.1 mjacob u_int32_t in_flags;
106 1.1 mjacob u_int8_t in_status;
107 1.1 mjacob u_int8_t in_rsvd2;
108 1.1 mjacob u_int8_t in_tag_val; /* tag value */
109 1.1 mjacob u_int8_t in_tag_type; /* tag type */
110 1.1 mjacob u_int16_t in_seqid; /* sequence id */
111 1.1 mjacob u_int8_t in_msg[IN_MSGLEN]; /* SCSI message bytes */
112 1.1 mjacob u_int16_t in_reserved3[IN_RSVDLEN];
113 1.1 mjacob u_int8_t in_sense[QLTM_SENSELEN];/* suggested sense data */
114 1.1 mjacob } in_entry_t;
115 1.1 mjacob
116 1.1 mjacob typedef struct {
117 1.1 mjacob isphdr_t in_header;
118 1.1 mjacob u_int32_t in_reserved;
119 1.1 mjacob u_int8_t in_lun; /* lun */
120 1.1 mjacob u_int8_t in_iid; /* initiator */
121 1.1 mjacob u_int16_t in_scclun;
122 1.1 mjacob u_int32_t in_reserved2;
123 1.1 mjacob u_int16_t in_status;
124 1.1 mjacob u_int16_t in_task_flags;
125 1.1 mjacob u_int16_t in_seqid; /* sequence id */
126 1.1 mjacob } in_fcentry_t;
127 1.1 mjacob
128 1.1 mjacob /*
129 1.1 mjacob * Values for the in_status field
130 1.1 mjacob */
131 1.1 mjacob #define IN_RESET 0x0E /* Bus Reset occurred */
132 1.1 mjacob #define IN_NO_RCAP 0x16 /* requested capability not available */
133 1.1 mjacob #define IN_IDE_RECEIVED 0x33 /* Initiator Detected Error msg received */
134 1.1 mjacob #define IN_RSRC_UNAVAIL 0x34 /* resource unavailable */
135 1.1 mjacob #define IN_MSG_RECEIVED 0x36 /* SCSI message received */
136 1.1 mjacob #define IN_ABORT_TASK 0x20 /* task named in RX_ID is being aborted (FC) */
137 1.1 mjacob #define IN_PORT_LOGOUT 0x29 /* port has logged out (FC) */
138 1.1 mjacob #define IN_PORT_CHANGED 0x2A /* port changed */
139 1.1 mjacob #define IN_GLOBAL_LOGO 0x2E /* all ports logged out */
140 1.1 mjacob
141 1.1 mjacob /*
142 1.1 mjacob * Values for the in_task_flags field- should only get one at a time!
143 1.1 mjacob */
144 1.1 mjacob #define TASK_FLAGS_ABORT_TASK (1<<9)
145 1.1 mjacob #define TASK_FLAGS_CLEAR_TASK_SET (1<<10)
146 1.1 mjacob #define TASK_FLAGS_TARGET_RESET (1<<13)
147 1.1 mjacob #define TASK_FLAGS_CLEAR_ACA (1<<14)
148 1.1 mjacob #define TASK_FLAGS_TERMINATE_TASK (1<<15)
149 1.1 mjacob
150 1.1 mjacob #ifndef MSG_ABORT_TAG
151 1.1 mjacob #define MSG_ABORT_TAG 0x06
152 1.1 mjacob #endif
153 1.1 mjacob #ifndef MSG_CLEAR_QUEUE
154 1.1 mjacob #define MSG_CLEAR_QUEUE 0x0e
155 1.1 mjacob #endif
156 1.1 mjacob #ifndef MSG_BUS_DEV_RESET
157 1.1 mjacob #define MSG_BUS_DEV_RESET 0x0b
158 1.1 mjacob #endif
159 1.1 mjacob #ifndef MSG_REL_RECOVERY
160 1.1 mjacob #define MSG_REL_RECOVERY 0x10
161 1.1 mjacob #endif
162 1.1 mjacob #ifndef MSG_TERM_IO_PROC
163 1.1 mjacob #define MSG_TERM_IO_PROC 0x11
164 1.1 mjacob #endif
165 1.1 mjacob
166 1.1 mjacob
167 1.1 mjacob /*
168 1.1 mjacob * Notify Acknowledge Entry structure
169 1.1 mjacob */
170 1.1 mjacob #define NA_RSVDLEN 22
171 1.1 mjacob typedef struct {
172 1.1 mjacob isphdr_t na_header;
173 1.1 mjacob u_int32_t na_reserved;
174 1.1 mjacob u_int8_t na_lun; /* lun */
175 1.1 mjacob u_int8_t na_iid; /* initiator */
176 1.1 mjacob u_int8_t na_reserved2;
177 1.1 mjacob u_int8_t na_tgt; /* target */
178 1.1 mjacob u_int32_t na_flags;
179 1.1 mjacob u_int8_t na_status;
180 1.1 mjacob u_int8_t na_event;
181 1.1 mjacob u_int16_t na_seqid; /* sequence id */
182 1.1 mjacob u_int16_t na_reserved3[NA_RSVDLEN];
183 1.1 mjacob } na_entry_t;
184 1.1 mjacob
185 1.1 mjacob /*
186 1.1 mjacob * Value for the na_event field
187 1.1 mjacob */
188 1.1 mjacob #define NA_RST_CLRD 0x80 /* Clear an async event notification */
189 1.1 mjacob
190 1.1 mjacob #define NA2_RSVDLEN 21
191 1.1 mjacob typedef struct {
192 1.1 mjacob isphdr_t na_header;
193 1.1 mjacob u_int32_t na_reserved;
194 1.1 mjacob u_int8_t na_lun; /* lun */
195 1.1 mjacob u_int8_t na_iid; /* initiator */
196 1.1 mjacob u_int16_t na_scclun;
197 1.1 mjacob u_int16_t na_flags;
198 1.1 mjacob u_int16_t na_reserved2;
199 1.1 mjacob u_int16_t na_status;
200 1.1 mjacob u_int16_t na_task_flags;
201 1.1 mjacob u_int16_t na_seqid; /* sequence id */
202 1.1 mjacob u_int16_t na_reserved3[NA2_RSVDLEN];
203 1.1 mjacob } na_fcentry_t;
204 1.1 mjacob #define NAFC_RCOUNT 0x80 /* increment resource count */
205 1.1 mjacob #define NAFC_RST_CLRD 0x20 /* Clear LIP Reset */
206 1.1 mjacob /*
207 1.1 mjacob * Accept Target I/O Entry structure
208 1.1 mjacob */
209 1.1 mjacob #define ATIO_CDBLEN 26
210 1.1 mjacob
211 1.1 mjacob typedef struct {
212 1.1 mjacob isphdr_t at_header;
213 1.1 mjacob u_int32_t at_reserved;
214 1.1 mjacob u_int8_t at_lun; /* lun */
215 1.1 mjacob u_int8_t at_iid; /* initiator */
216 1.1 mjacob u_int8_t at_cdblen; /* cdb length */
217 1.1 mjacob u_int8_t at_tgt; /* target */
218 1.1 mjacob u_int32_t at_flags;
219 1.1 mjacob u_int8_t at_status; /* firmware status */
220 1.1 mjacob u_int8_t at_scsi_status; /* scsi status */
221 1.1 mjacob u_int8_t at_tag_val; /* tag value */
222 1.1 mjacob u_int8_t at_tag_type; /* tag type */
223 1.1 mjacob u_int8_t at_cdb[ATIO_CDBLEN]; /* received CDB */
224 1.1 mjacob u_int8_t at_sense[QLTM_SENSELEN];/* suggested sense data */
225 1.1 mjacob } at_entry_t;
226 1.1 mjacob
227 1.1 mjacob /*
228 1.1 mjacob * at_flags values
229 1.1 mjacob */
230 1.1 mjacob #define AT_NODISC 0x00008000 /* disconnect disabled */
231 1.1 mjacob #define AT_TQAE 0x00000001 /* Tagged Queue Action enabled */
232 1.1 mjacob
233 1.1 mjacob /*
234 1.1 mjacob * at_status values
235 1.1 mjacob */
236 1.1 mjacob #define AT_PATH_INVALID 0x07 /* ATIO sent to firmware for disabled lun */
237 1.1 mjacob #define AT_RESET 0x0E /* SCSI Bus Reset Occurred */
238 1.1 mjacob #define AT_PHASE_ERROR 0x14 /* Bus phase sequence error */
239 1.1 mjacob #define AT_NOCAP 0x16 /* Requested capability not available */
240 1.1 mjacob #define AT_BDR_MSG 0x17 /* Bus Device Reset msg received */
241 1.1 mjacob #define AT_CDB 0x3D /* CDB received */
242 1.1 mjacob
243 1.1 mjacob /*
244 1.1 mjacob * Accept Target I/O Entry structure, Type 2
245 1.1 mjacob */
246 1.1 mjacob #define ATIO2_CDBLEN 16
247 1.1 mjacob
248 1.1 mjacob typedef struct {
249 1.1 mjacob isphdr_t at_header;
250 1.1 mjacob u_int32_t at_reserved;
251 1.1 mjacob u_int8_t at_lun; /* lun or reserved */
252 1.1 mjacob u_int8_t at_iid; /* initiator */
253 1.1 mjacob u_int16_t at_rxid; /* response ID */
254 1.1 mjacob u_int16_t at_flags;
255 1.1 mjacob u_int16_t at_status; /* firmware status */
256 1.1 mjacob u_int8_t at_reserved1;
257 1.1 mjacob u_int8_t at_taskcodes;
258 1.1 mjacob u_int8_t at_taskflags;
259 1.1 mjacob u_int8_t at_execodes;
260 1.1 mjacob u_int8_t at_cdb[ATIO2_CDBLEN]; /* received CDB */
261 1.1 mjacob u_int32_t at_datalen; /* allocated data len */
262 1.1 mjacob u_int16_t at_scclun; /* SCC Lun or reserved */
263 1.1 mjacob u_int16_t at_reserved2;
264 1.1 mjacob u_int16_t at_scsi_status;
265 1.1 mjacob u_int8_t at_sense[QLTM_SENSELEN];
266 1.1 mjacob } at2_entry_t;
267 1.1 mjacob
268 1.1 mjacob #define ATIO2_TC_ATTR_MASK 0x7
269 1.1 mjacob #define ATIO2_TC_ATTR_SIMPLEQ 0
270 1.1 mjacob #define ATIO2_TC_ATTR_HEADOFQ 1
271 1.1 mjacob #define ATIO2_TC_ATTR_ORDERED 2
272 1.1 mjacob #define ATIO2_TC_ATTR_ACAQ 4
273 1.1 mjacob #define ATIO2_TC_ATTR_UNTAGGED 5
274 1.1 mjacob
275 1.1 mjacob /*
276 1.1 mjacob * Continue Target I/O Entry structure
277 1.1 mjacob * Request from driver. The response from the
278 1.1 mjacob * ISP firmware is the same except that the last 18
279 1.1 mjacob * bytes are overwritten by suggested sense data if
280 1.1 mjacob * the 'autosense valid' bit is set in the status byte.
281 1.1 mjacob */
282 1.1 mjacob typedef struct {
283 1.1 mjacob isphdr_t ct_header;
284 1.1 mjacob u_int32_t ct_reserved;
285 1.1 mjacob u_int8_t ct_lun; /* lun */
286 1.1 mjacob u_int8_t ct_iid; /* initiator id */
287 1.1 mjacob u_int8_t ct_reserved2;
288 1.1 mjacob u_int8_t ct_tgt; /* our target id */
289 1.1 mjacob u_int32_t ct_flags;
290 1.1 mjacob u_int8_t ct_status; /* isp status */
291 1.1 mjacob u_int8_t ct_scsi_status; /* scsi status */
292 1.1 mjacob u_int8_t ct_tag_val; /* tag value */
293 1.1 mjacob u_int8_t ct_tag_type; /* tag type */
294 1.1 mjacob u_int32_t ct_xfrlen; /* transfer length */
295 1.1 mjacob u_int32_t ct_resid; /* residual length */
296 1.1 mjacob u_int16_t ct_timeout;
297 1.1 mjacob u_int16_t ct_seg_count;
298 1.1 mjacob ispds_t ct_dataseg[ISP_RQDSEG];
299 1.1 mjacob } ct_entry_t;
300 1.1 mjacob
301 1.1 mjacob /*
302 1.1 mjacob * ct_flags values
303 1.1 mjacob */
304 1.1 mjacob #define CT_TQAE 0x00000001 /* bit 1, Tagged Queue Action enable */
305 1.1 mjacob #define CT_DATA_IN 0x00000040 /* bits 6&7, Data direction */
306 1.1 mjacob #define CT_DATA_OUT 0x00000080 /* bits 6&7, Data direction */
307 1.1 mjacob #define CT_NO_DATA 0x000000C0 /* bits 6&7, Data direction */
308 1.1 mjacob #define CT_CCINCR 0x00000100 /* bit 8, autoincrement atio count */
309 1.1 mjacob #define CT_DATAMASK 0x000000C0 /* bits 6&7, Data direction */
310 1.1 mjacob #define CT_NODISC 0x00008000 /* bit 15, Disconnects disabled */
311 1.1 mjacob #define CT_DSDP 0x01000000 /* bit 24, Disable Save Data Pointers */
312 1.1 mjacob #define CT_SENDRDP 0x04000000 /* bit 26, Send Restore Pointers msg */
313 1.1 mjacob #define CT_SENDSTATUS 0x80000000 /* bit 31, Send SCSI status byte */
314 1.1 mjacob
315 1.1 mjacob /*
316 1.1 mjacob * ct_status values
317 1.1 mjacob * - set by the firmware when it returns the CTIO
318 1.1 mjacob */
319 1.1 mjacob #define CT_OK 0x01 /* completed without error */
320 1.1 mjacob #define CT_ABORTED 0x02 /* aborted by host */
321 1.1 mjacob #define CT_ERR 0x04 /* see sense data for error */
322 1.1 mjacob #define CT_INVAL 0x06 /* request for disabled lun */
323 1.1 mjacob #define CT_NOPATH 0x07 /* invalid ITL nexus */
324 1.1 mjacob #define CT_INVRXID 0x08 /* (FC only) Invalid RX_ID */
325 1.1 mjacob #define CT_RSELTMO 0x0A /* reselection timeout after 2 tries */
326 1.1 mjacob #define CT_TIMEOUT 0x0B /* timed out */
327 1.1 mjacob #define CT_RESET 0x0E /* SCSI Bus Reset occurred */
328 1.1 mjacob #define CT_PHASE_ERROR 0x14 /* Bus phase sequence error */
329 1.1 mjacob #define CT_BDR_MSG 0x17 /* Bus Device Reset msg received */
330 1.1 mjacob #define CT_TERMINATED 0x19 /* due to Terminate Transfer mbox cmd */
331 1.1 mjacob #define CT_PORTNOTAVAIL 0x28 /* port not available */
332 1.1 mjacob #define CT_LOGOUT 0x29 /* port logout */
333 1.1 mjacob #define CT_PORTCHANGED 0x2A /* port changed */
334 1.1 mjacob #define CT_NOACK 0x35 /* Outstanding Immed. Notify. entry */
335 1.1 mjacob
336 1.1 mjacob /*
337 1.1 mjacob * When the firmware returns a CTIO entry, it may overwrite the last
338 1.1 mjacob * part of the structure with sense data. This starts at offset 0x2E
339 1.1 mjacob * into the entry, which is in the middle of ct_dataseg[1]. Rather
340 1.1 mjacob * than define a new struct for this, I'm just using the sense data
341 1.1 mjacob * offset.
342 1.1 mjacob */
343 1.1 mjacob #define CTIO_SENSE_OFFSET 0x2E
344 1.1 mjacob
345 1.1 mjacob /*
346 1.1 mjacob * Entry length in u_longs. All entries are the same size so
347 1.1 mjacob * any one will do as the numerator.
348 1.1 mjacob */
349 1.1 mjacob #define UINT32_ENTRY_SIZE (sizeof(at_entry_t)/sizeof(u_int32_t))
350 1.1 mjacob
351 1.1 mjacob /*
352 1.1 mjacob * QLA2100 CTIO (type 2) entry
353 1.1 mjacob */
354 1.1 mjacob #define MAXRESPLEN 26
355 1.1 mjacob typedef struct {
356 1.1 mjacob isphdr_t ct_header;
357 1.1 mjacob u_int32_t ct_reserved;
358 1.1 mjacob u_int8_t ct_lun; /* lun */
359 1.1 mjacob u_int8_t ct_iid; /* initiator id */
360 1.1 mjacob u_int16_t ct_rxid; /* response ID */
361 1.1 mjacob u_int16_t ct_flags;
362 1.1 mjacob u_int16_t ct_status; /* isp status */
363 1.1 mjacob u_int16_t ct_timeout;
364 1.1 mjacob u_int16_t ct_seg_count;
365 1.1 mjacob u_int32_t ct_reloff; /* relative offset */
366 1.1 mjacob u_int32_t ct_resid; /* residual length */
367 1.1 mjacob union {
368 1.1 mjacob /*
369 1.1 mjacob * The three different modes that the target driver
370 1.1 mjacob * can set the CTIO2 up as.
371 1.1 mjacob *
372 1.1 mjacob * The first is for sending FCP_DATA_IUs as well as
373 1.1 mjacob * (optionally) sending a terminal SCSI status FCP_RSP_IU.
374 1.1 mjacob *
375 1.1 mjacob * The second is for sending SCSI sense data in an FCP_RSP_IU.
376 1.1 mjacob * Note that no FCP_DATA_IUs will be sent.
377 1.1 mjacob *
378 1.1 mjacob * The third is for sending FCP_RSP_IUs as built specifically
379 1.1 mjacob * in system memory as located by the isp_dataseg.
380 1.1 mjacob */
381 1.1 mjacob struct {
382 1.1 mjacob u_int32_t _reserved;
383 1.1 mjacob u_int16_t _reserved2;
384 1.1 mjacob u_int16_t ct_scsi_status;
385 1.1 mjacob u_int32_t ct_xfrlen;
386 1.1 mjacob ispds_t ct_dataseg[ISP_RQDSEG_T2];
387 1.1 mjacob } m0;
388 1.1 mjacob struct {
389 1.1 mjacob u_int16_t _reserved;
390 1.1 mjacob u_int16_t _reserved2;
391 1.1 mjacob u_int16_t ct_senselen;
392 1.1 mjacob u_int16_t ct_scsi_status;
393 1.1 mjacob u_int16_t ct_resplen;
394 1.1 mjacob u_int8_t ct_resp[MAXRESPLEN];
395 1.1 mjacob } m1;
396 1.1 mjacob struct {
397 1.1 mjacob u_int32_t _reserved;
398 1.1 mjacob u_int16_t _reserved2;
399 1.1 mjacob u_int16_t _reserved3;
400 1.1 mjacob u_int32_t ct_datalen;
401 1.1 mjacob ispds_t ct_fcp_rsp_iudata;
402 1.1 mjacob } m2;
403 1.1 mjacob /*
404 1.1 mjacob * CTIO2 returned from F/W...
405 1.1 mjacob */
406 1.1 mjacob struct {
407 1.1 mjacob u_int32_t _reserved[4];
408 1.1 mjacob u_int16_t ct_scsi_status;
409 1.1 mjacob u_int8_t ct_sense[QLTM_SENSELEN];
410 1.1 mjacob } fw;
411 1.1 mjacob } rsp;
412 1.1 mjacob } ct2_entry_t;
413 1.1 mjacob
414 1.1 mjacob /*
415 1.1 mjacob * ct_flags values for CTIO2
416 1.1 mjacob */
417 1.1 mjacob #define CT2_FLAG_MMASK 0x0003
418 1.1 mjacob #define CT2_FLAG_MODE0 0x0000
419 1.1 mjacob #define CT2_FLAG_MODE1 0x0001
420 1.1 mjacob #define CT2_FLAG_MODE2 0x0002
421 1.1 mjacob #define CT2_DATA_IN CT_DATA_IN
422 1.1 mjacob #define CT2_DATA_OUT CT_DATA_OUT
423 1.1 mjacob #define CT2_NO_DATA CT_NO_DATA
424 1.1 mjacob #define CT2_DATAMASK CT_DATAMASK
425 1.1 mjacob #define CT2_CCINCR 0x0100
426 1.1 mjacob #define CT2_FASTPOST 0x0200
427 1.1 mjacob #define CT2_SENDSTATUS 0x8000
428 1.1 mjacob
429 1.1 mjacob /*
430 1.1 mjacob * ct_status values are (mostly) the same as that for ct_entry.
431 1.1 mjacob */
432 1.1 mjacob
433 1.1 mjacob /*
434 1.1 mjacob * ct_scsi_status values- the low 8 bits are the normal SCSI status
435 1.1 mjacob * we know and love. The upper 8 bits are validity markers for FCP_RSP_IU
436 1.1 mjacob * fields.
437 1.1 mjacob */
438 1.1 mjacob #define CT2_RSPLEN_VALID 0x0100
439 1.1 mjacob #define CT2_SNSLEN_VALID 0x0200
440 1.1 mjacob #define CT2_DATA_OVER 0x0400
441 1.1 mjacob #define CT2_DATA_UNDER 0x0800
442 1.1 mjacob
443 1.1 mjacob /*
444 1.1 mjacob * Macros for packing/unpacking the above structures
445 1.1 mjacob */
446 1.1 mjacob
447 1.1 mjacob #ifdef __sparc__
448 1.1 mjacob #define ISP_SBUS_SWOZZLE(isp, src, dest, taga, tagb) \
449 1.1 mjacob if (isp->isp_bus == ISP_SBUS) { \
450 1.1 mjacob source -> taga = dest -> tagb; \
451 1.1 mjacob source -> tagb = dest -> taga; \
452 1.1 mjacob } else { \
453 1.1 mjacob source -> taga = dest -> taga; \
454 1.1 mjacob source -> tagb = dest -> taga; \
455 1.1 mjacob }
456 1.1 mjacob #else
457 1.1 mjacob #define ISP_SBUS_SWOZZLE(isp, src, dest, taga, tagb) \
458 1.1 mjacob source -> taga = dest -> taga; \
459 1.1 mjacob source -> tagb = dest -> taga;
460 1.1 mjacob #endif
461 1.1 mjacob
462 1.1 mjacob /* This is really only for SBus cards on a sparc */
463 1.1 mjacob #ifdef __sparc__
464 1.1 mjacob #define ISP_SWIZ_ATIO(isp, dest, vsrc) \
465 1.1 mjacob { \
466 1.1 mjacob at_entry_t *source = (at_entry_t *) vsrc; \
467 1.1 mjacob dest->at_header = source->at_header; \
468 1.1 mjacob dest->at_reserved2 = source->at_reserved2; \
469 1.1 mjacob ISP_SBUS_SWOZZLE(isp, source, dest, at_lun, at_iid); \
470 1.1 mjacob ISP_SBUS_SWOZZLE(isp, source, dest, at_cdblen, at_tgt); \
471 1.1 mjacob dest->at_flags = source->at_flags; \
472 1.1 mjacob ISP_SBUS_SWOZZLE(isp, source, dest, at_status, at_scsi_status); \
473 1.1 mjacob ISP_SBUS_SWOZZLE(isp, source, dest, at_tag_val, at_tag_type); \
474 1.1 mjacob MEMCPY(dest->at_cdb, source->at_cdb, ATIO_CDBLEN); \
475 1.1 mjacob MEMCPY(dest->at_sense, source->at_sense, QLTM_SENSELEN); \
476 1.1 mjacob }
477 1.1 mjacob
478 1.1 mjacob #define ISP_SWIZ_CTIO(isp, dest, vsrc) \
479 1.1 mjacob { \
480 1.1 mjacob ct_entry_t *source = (ct_entry-t *) vsrc; \
481 1.1 mjacob dest->ct_header = source->ct_header; \
482 1.1 mjacob dest->ct_reserved = source->ct_reserved; \
483 1.1 mjacob ISP_SBUS_SWOZZLE(isp, source, dest, ct_lun, ct_iid); \
484 1.1 mjacob ISP_SBUS_SWOZZLE(isp, source, dest, ct_rsvd, ct_tgt); \
485 1.1 mjacob dest->ct_flags = source->ct_flags; \
486 1.1 mjacob ISP_SBUS_SWOZZLE(isp, source, dest, ct_status, ct_scsi_status); \
487 1.1 mjacob ISP_SBUS_SWOZZLE(isp, source, dest, ct_tag_val, ct_tag_type); \
488 1.1 mjacob dest->ct_xfrlen = source->ct_xfrlen; \
489 1.1 mjacob dest->ct_resid = source->ct_resid; \
490 1.1 mjacob dest->ct_timeout = source->ct_timeout; \
491 1.1 mjacob dest->ct_seg_count = source->ct_seg_count; \
492 1.1 mjacob MEMCPY(dest->ct_cdb, source->ct_cdb, ATIO_CDBLEN); \
493 1.1 mjacob MEMCPY(dest->ct_sense, source->ct_sense, QLTM_SENSELEN); \
494 1.1 mjacob dest->ct_dataseg = source->ct_dataseg; \
495 1.1 mjacob }
496 1.1 mjacob #define ISP_SWIZ_ENABLE_LUN(isp, dest, vsrc) \
497 1.1 mjacob { \
498 1.1 mjacob lun_entry_t *source = (lun_entry_t *)vsrc; \
499 1.1 mjacob dest->le_header = source->le_header; \
500 1.1 mjacob dest->le_reserved2 = source->le_reserved2; \
501 1.1 mjacob ISP_SBUS_SWOZZLE(isp, source, dest, le_lun, le_rsvd); \
502 1.1 mjacob ISP_SBUS_SWOZZLE(isp, source, dest, le_ops, le_tgt); \
503 1.1 mjacob dest->le_flags = source->le_flags; \
504 1.1 mjacob ISP_SBUS_SWOZZLE(isp, source, dest, le_status, le_rsvd2); \
505 1.1 mjacob ISP_SBUS_SWOZZLE(isp, source, dest, le_cmd_count, le_in_count); \
506 1.1 mjacob ISP_SBUS_SWOZZLE(isp, source, dest, le_cdb6len, le_cdb7len); \
507 1.1 mjacob dest->le_timeout = source->le_timeout; \
508 1.1 mjacob dest->le_reserved = source->le_reserved; \
509 1.1 mjacob }
510 1.1 mjacob #define ISP_SWIZ_NOTIFY(isp, dest, vsrc) \
511 1.1 mjacob { \
512 1.1 mjacob in_entry_type *source = (in_entry_t *)vsrc; \
513 1.1 mjacob dest->in_header = source->in_header; \
514 1.1 mjacob dest->in_reserved2 = source->in_reserved2; \
515 1.1 mjacob ISP_SBUS_SWOZZLE(isp, source, dest, in_lun, in_iid); \
516 1.1 mjacob ISP_SBUS_SWOZZLE(isp, source, dest, in_rsvd, in_tgt); \
517 1.1 mjacob dest->in_flags = source->in_flags; \
518 1.1 mjacob ISP_SBUS_SWOZZLE(isp, source, dest, in_status, in_rsvd2); \
519 1.1 mjacob ISP_SBUS_SWOZZLE(isp, source, dest, in_tag_val, in_tag_type); \
520 1.1 mjacob dest->in_seqid = source->in_seqid; \
521 1.1 mjacob MEMCPY(dest->in_msg, source->in_msg, IN_MSGLEN); \
522 1.1 mjacob MEMCPY(dest->in_reserved, source->in_reserved, IN_RESERVED); \
523 1.1 mjacob MEMCPY(dest->in_sense, source->in_sense, QLTM_SENSELEN); \
524 1.1 mjacob }
525 1.1 mjacob #define ISP_SWIZ_NOT_ACK(isp, dest) \
526 1.1 mjacob { \
527 1.1 mjacob na_entry_t *source = (na_entry_t *)vsrc; \
528 1.1 mjacob dest->na_header = source->na_header; \
529 1.1 mjacob dest->na_reserved2 = source->na_reserved2; \
530 1.1 mjacob ISP_SBUS_SWOZZLE(isp, source, dest, na_lun, na_iid); \
531 1.1 mjacob ISP_SBUS_SWOZZLE(isp, source, dest, na_rsvd, na_tgt); \
532 1.1 mjacob dest->na_flags = source->na_flags; \
533 1.1 mjacob ISP_SBUS_SWOZZLE(isp, source, dest, na_status, na_event); \
534 1.1 mjacob dest->na_seqid = source->na_seqid; \
535 1.1 mjacob MEMCPY(dest->na_reserved, source->na_reserved, NA_RSVDLEN); \
536 1.1 mjacob }
537 1.1 mjacob #define ISP_SWIZ_NOT_ACK_FC(isp, d, s) MEMCPY((void *)d, (void *)s, QENTRY_LEN)
538 1.1 mjacob #else
539 1.1 mjacob #define ISP_SWIZ_ATIO(isp, d, s) MEMCPY((void *)d, (void *)s, QENTRY_LEN)
540 1.1 mjacob #define ISP_SWIZ_CTIO(isp, d, s) MEMCPY((void *)d, (void *)s, QENTRY_LEN)
541 1.1 mjacob #define ISP_SWIZ_ENABLE_LUN(isp, d, s) MEMCPY((void *)d, (void *)s, QENTRY_LEN)
542 1.1 mjacob #define ISP_SWIZ_NOTIFY(isp, d, s) MEMCPY((void *)d, (void *)s, QENTRY_LEN)
543 1.1 mjacob #define ISP_SWIZ_NOT_ACK(isp, d, s) MEMCPY((void *)d, (void *)s, QENTRY_LEN)
544 1.1 mjacob #define ISP_SWIZ_NOT_ACK_FC(isp, d, s) MEMCPY((void *)d, (void *)s, QENTRY_LEN)
545 1.1 mjacob #endif
546 1.1 mjacob #define ISP_SWIZ_ATIO2(isp, d, s) MEMCPY((void *)d, (void *)s, QENTRY_LEN)
547 1.1 mjacob #define ISP_SWIZ_CTIO2(isp, d, s) MEMCPY((void *)d, (void *)s, QENTRY_LEN)
548 1.1 mjacob
549 1.1 mjacob /*
550 1.1 mjacob * Debug macros
551 1.1 mjacob */
552 1.1 mjacob
553 1.1 mjacob extern int isp_tdebug;
554 1.1 mjacob #define ISP_TDQE(isp, msg, idx, arg) \
555 1.1 mjacob if (isp_tdebug > 3) isp_print_qentry(isp, msg, idx, arg)
556 1.1 mjacob
557 1.1 mjacob #define ITDEBUG(level, msg) if (level > isp_tdebug) PRINTF msg
558 1.1 mjacob
559 1.1 mjacob /*
560 1.1 mjacob * Common (for all platfoms) software SCSI msg/event structures.
561 1.1 mjacob */
562 1.1 mjacob
563 1.1 mjacob typedef struct {
564 1.1 mjacob u_int8_t nt_iid; /* inititator id */
565 1.1 mjacob u_int8_t nt_tgt; /* target id */
566 1.1 mjacob u_int16_t nt_lun; /* logical unit */
567 1.1 mjacob u_int8_t nt_bus; /* bus */
568 1.1 mjacob u_int8_t nt_tagtype; /* tag type */
569 1.1 mjacob u_int16_t nt_tagval; /* tag value */
570 1.1 mjacob u_int8_t nt_msg[IN_MSGLEN]; /* message content */
571 1.1 mjacob } tmd_msg_t;
572 1.1 mjacob
573 1.1 mjacob typedef struct {
574 1.1 mjacob u_int16_t ev_bus; /* bus */
575 1.1 mjacob u_int16_t ev_event; /* type of async event */
576 1.1 mjacob } tmd_event_t;
577 1.1 mjacob
578 1.1 mjacob /*
579 1.1 mjacob * Target Mode functions
580 1.1 mjacob */
581 1.1 mjacob
582 1.1 mjacob /*
583 1.1 mjacob * This function handles new response queue entry appropriate for target mode.
584 1.1 mjacob */
585 1.1 mjacob int isp_target_notify __P((struct ispsoftc *, void *, u_int16_t *));
586 1.1 mjacob
587 1.1 mjacob /*
588 1.1 mjacob * Enable/Disable/Modify a logical unit.
589 1.1 mjacob */
590 1.1 mjacob #define DFLT_CMD_CNT (RESULT_QUEUE_LEN >> 1)
591 1.1 mjacob #define DFLT_INOTIFY (4)
592 1.1 mjacob int isp_lun_cmd __P((struct ispsoftc *isp, int, int, int, int, u_int32_t));
593 1.1 mjacob
594 1.1 mjacob /*
595 1.1 mjacob * General request queue 'put' routine for target mode entries.
596 1.1 mjacob */
597 1.1 mjacob int isp_target_put_entry __P((struct ispsoftc *isp, void *));
598 1.1 mjacob
599 1.1 mjacob /*
600 1.1 mjacob * General routine to put back an ATIO entry-
601 1.1 mjacob * used for replenishing f/w resource counts.
602 1.1 mjacob */
603 1.1 mjacob int
604 1.1 mjacob isp_target_put_atio __P((struct ispsoftc *isp, int, int, int, int, int));
605 1.1 mjacob
606 1.1 mjacob /*
607 1.1 mjacob * General routine to send a final CTIO for a command- used mostly for
608 1.1 mjacob * local responses.
609 1.1 mjacob */
610 1.1 mjacob int
611 1.1 mjacob isp_endcmd __P((struct ispsoftc *isp, void *, u_int32_t, u_int32_t));
612 1.1 mjacob
613 1.1 mjacob /*
614 1.1 mjacob * Handle an asynchronous event
615 1.1 mjacob */
616 1.1 mjacob
617 1.1 mjacob void isp_target_async __P((struct ispsoftc *, int, int));
618 1.1 mjacob
619 1.1 mjacob #endif /* _ISPTARGET_H */
620