1 -/* $NetBSD: isp_target.h,v 1.25 2008/03/11 05:33:30 mjacob Exp $ */
2 /*-
3 * Copyright (c) 1997-2008 by Matthew Jacob
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 *
28 */
29 /*
30 * Qlogic Target Mode Structure and Flag Definitions
31 */
32 #ifndef _ISP_TARGET_H
33 #define _ISP_TARGET_H
34
35 #define QLTM_SENSELEN 18 /* non-FC cards only */
36 #define QLTM_SVALID 0x80
37
38 /*
39 * Structure for Enable Lun and Modify Lun queue entries
40 */
41 typedef struct {
42 isphdr_t le_header;
43 uint32_t le_reserved;
44 uint8_t le_lun;
45 uint8_t le_rsvd;
46 uint8_t le_ops; /* Modify LUN only */
47 uint8_t le_tgt; /* Not for FC */
48 uint32_t le_flags; /* Not for FC */
49 uint8_t le_status;
50 uint8_t le_reserved2;
51 uint8_t le_cmd_count;
52 uint8_t le_in_count;
53 uint8_t le_cdb6len; /* Not for FC */
54 uint8_t le_cdb7len; /* Not for FC */
55 uint16_t le_timeout;
56 uint16_t le_reserved3[20];
57 } lun_entry_t;
58
59 /*
60 * le_flags values
61 */
62 #define LUN_TQAE 0x00000002 /* bit1 Tagged Queue Action Enable */
63 #define LUN_DSSM 0x01000000 /* bit24 Disable Sending SDP Message */
64 #define LUN_DISAD 0x02000000 /* bit25 Disable autodisconnect */
65 #define LUN_DM 0x40000000 /* bit30 Disconnects Mandatory */
66
67 /*
68 * le_ops values
69 */
70 #define LUN_CCINCR 0x01 /* increment command count */
71 #define LUN_CCDECR 0x02 /* decrement command count */
72 #define LUN_ININCR 0x40 /* increment immed. notify count */
73 #define LUN_INDECR 0x80 /* decrement immed. notify count */
74
75 /*
76 * le_status values
77 */
78 #define LUN_OK 0x01 /* we be rockin' */
79 #define LUN_ERR 0x04 /* request completed with error */
80 #define LUN_INVAL 0x06 /* invalid request */
81 #define LUN_NOCAP 0x16 /* can't provide requested capability */
82 #define LUN_ENABLED 0x3E /* LUN already enabled */
83
84 /*
85 * Immediate Notify Entry structure
86 */
87 #define IN_MSGLEN 8 /* 8 bytes */
88 #define IN_RSVDLEN 8 /* 8 words */
89 typedef struct {
90 isphdr_t in_header;
91 uint32_t in_reserved;
92 uint8_t in_lun; /* lun */
93 uint8_t in_iid; /* initiator */
94 uint8_t in_reserved2;
95 uint8_t in_tgt; /* target */
96 uint32_t in_flags;
97 uint8_t in_status;
98 uint8_t in_rsvd2;
99 uint8_t in_tag_val; /* tag value */
100 uint8_t in_tag_type; /* tag type */
101 uint16_t in_seqid; /* sequence id */
102 uint8_t in_msg[IN_MSGLEN]; /* SCSI message bytes */
103 uint16_t in_reserved3[IN_RSVDLEN];
104 uint8_t in_sense[QLTM_SENSELEN];/* suggested sense data */
105 } in_entry_t;
106
107 typedef struct {
108 isphdr_t in_header;
109 uint32_t in_reserved;
110 uint8_t in_lun; /* lun */
111 uint8_t in_iid; /* initiator */
112 uint16_t in_scclun;
113 uint32_t in_reserved2;
114 uint16_t in_status;
115 uint16_t in_task_flags;
116 uint16_t in_seqid; /* sequence id */
117 } in_fcentry_t;
118
119 typedef struct {
120 isphdr_t in_header;
121 uint32_t in_reserved;
122 uint16_t in_iid; /* initiator */
123 uint16_t in_scclun;
124 uint32_t in_reserved2;
125 uint16_t in_status;
126 uint16_t in_task_flags;
127 uint16_t in_seqid; /* sequence id */
128 } in_fcentry_e_t;
129
130 /*
131 * Values for the in_status field
132 */
133 #define IN_REJECT 0x0D /* Message Reject message received */
134 #define IN_RESET 0x0E /* Bus Reset occurred */
135 #define IN_NO_RCAP 0x16 /* requested capability not available */
136 #define IN_IDE_RECEIVED 0x33 /* Initiator Detected Error msg received */
137 #define IN_RSRC_UNAVAIL 0x34 /* resource unavailable */
138 #define IN_MSG_RECEIVED 0x36 /* SCSI message received */
139 #define IN_ABORT_TASK 0x20 /* task named in RX_ID is being aborted (FC) */
140 #define IN_PORT_LOGOUT 0x29 /* port has logged out (FC) */
141 #define IN_PORT_CHANGED 0x2A /* port changed */
142 #define IN_GLOBAL_LOGO 0x2E /* all ports logged out */
143 #define IN_NO_NEXUS 0x3B /* Nexus not established */
144
145 /*
146 * Values for the in_task_flags field- should only get one at a time!
147 */
148 #define TASK_FLAGS_RESERVED_MASK (0xe700)
149 #define TASK_FLAGS_CLEAR_ACA (1<<14)
150 #define TASK_FLAGS_TARGET_RESET (1<<13)
151 #define TASK_FLAGS_LUN_RESET (1<<12)
152 #define TASK_FLAGS_CLEAR_TASK_SET (1<<10)
153 #define TASK_FLAGS_ABORT_TASK_SET (1<<9)
154
155 /*
156 * ISP24XX Immediate Notify
157 */
158 typedef struct {
159 isphdr_t in_header;
160 uint32_t in_reserved;
161 uint16_t in_nphdl;
162 uint16_t in_reserved1;
163 uint16_t in_flags;
164 uint16_t in_srr_rxid;
165 uint16_t in_status;
166 uint8_t in_status_subcode;
167 uint8_t in_reserved2;
168 uint32_t in_rxid;
169 uint16_t in_srr_reloff_lo;
170 uint16_t in_srr_reloff_hi;
171 uint16_t in_srr_iu;
172 uint16_t in_srr_oxid;
173 /*
174 * If bit 2 is set in in_flags, the following
175 * two tags are valid. If the received ELS is
176 * a LOGO, then these tags contain the N Port ID
177 * from the LOGO payload. If the received ELS
178 * request is TPRLO, these tags contain the
179 * Third Party Originator N Port ID.
180 */
181 uint16_t in_nport_id_hi;
182 uint8_t in_nport_id_lo;
183 uint8_t in_reserved3;
184 /*
185 * If bit 2 is set in in_flags, the following
186 * tag is valid. If the received ELS is a LOGO,
187 * then this tag contains the n-port handle
188 * from the LOGO payload. If the received ELS
189 * request is TPRLO, this tag contain the
190 * n-port handle for the Third Party Originator.
191 */
192 uint16_t in_np_handle;
193 uint8_t in_reserved4[12];
194 uint8_t in_reserved5;
195 uint8_t in_vpindex;
196 uint32_t in_reserved6;
197 uint16_t in_portid_lo;
198 uint8_t in_portid_hi;
199 uint8_t in_reserved7;
200 uint16_t in_reserved8;
201 uint16_t in_oxid;
202 } in_fcentry_24xx_t;
203
204 #define IN24XX_FLAG_PUREX_IOCB 0x1
205 #define IN24XX_FLAG_GLOBAL_LOGOUT 0x2
206 #define IN24XX_FLAG_NPHDL_VALID 0x4
207
208 #define IN24XX_LIP_RESET 0x0E
209 #define IN24XX_LINK_RESET 0x0F
210 #define IN24XX_PORT_LOGOUT 0x29
211 #define IN24XX_PORT_CHANGED 0x2A
212 #define IN24XX_LINK_FAILED 0x2E
213 #define IN24XX_SRR_RCVD 0x45
214 #define IN24XX_ELS_RCVD 0x46 /*
215 * login-affectin ELS received- check
216 * subcode for specific opcode
217 */
218
219 /*
220 * For f/w > 4.0.25, these offsets in the Immediate Notify contain
221 * the WWNN/WWPN if the ELS is PLOGI, PDISC or ADISC. The WWN is in
222 * Big Endian format.
223 */
224 #define IN24XX_PLOGI_WWNN_OFF 0x20
225 #define IN24XX_PLOGI_WWPN_OFF 0x28
226
227 /*
228 * For f/w > 4.0.25, this offset in the Immediate Notify contain
229 * the WWPN if the ELS is LOGO. The WWN is in Big Endian format.
230 */
231 #define IN24XX_LOGO_WWPN_OFF 0x28
232
233 /*
234 * Notify Acknowledge Entry structure
235 */
236 #define NA_RSVDLEN 22
237 typedef struct {
238 isphdr_t na_header;
239 uint32_t na_reserved;
240 uint8_t na_lun; /* lun */
241 uint8_t na_iid; /* initiator */
242 uint8_t na_reserved2;
243 uint8_t na_tgt; /* target */
244 uint32_t na_flags;
245 uint8_t na_status;
246 uint8_t na_event;
247 uint16_t na_seqid; /* sequence id */
248 uint16_t na_reserved3[NA_RSVDLEN];
249 } na_entry_t;
250
251 /*
252 * Value for the na_event field
253 */
254 #define NA_RST_CLRD 0x80 /* Clear an async event notification */
255 #define NA_OK 0x01 /* Notify Acknowledge Succeeded */
256 #define NA_INVALID 0x06 /* Invalid Notify Acknowledge */
257
258 #define NA2_RSVDLEN 21
259 typedef struct {
260 isphdr_t na_header;
261 uint32_t na_reserved;
262 uint8_t na_reserved1;
263 uint8_t na_iid; /* initiator loop id */
264 uint16_t na_response;
265 uint16_t na_flags;
266 uint16_t na_reserved2;
267 uint16_t na_status;
268 uint16_t na_task_flags;
269 uint16_t na_seqid; /* sequence id */
270 uint16_t na_reserved3[NA2_RSVDLEN];
271 } na_fcentry_t;
272
273 typedef struct {
274 isphdr_t na_header;
275 uint32_t na_reserved;
276 uint16_t na_iid; /* initiator loop id */
277 uint16_t na_response; /* response code */
278 uint16_t na_flags;
279 uint16_t na_reserved2;
280 uint16_t na_status;
281 uint16_t na_task_flags;
282 uint16_t na_seqid; /* sequence id */
283 uint16_t na_reserved3[NA2_RSVDLEN];
284 } na_fcentry_e_t;
285
286 #define NAFC_RCOUNT 0x80 /* increment resource count */
287 #define NAFC_RST_CLRD 0x20 /* Clear LIP Reset */
288 #define NAFC_TVALID 0x10 /* task mangement response code is valid */
289
290 /*
291 * ISP24XX Notify Acknowledge
292 */
293
294 typedef struct {
295 isphdr_t na_header;
296 uint32_t na_handle;
297 uint16_t na_nphdl;
298 uint16_t na_reserved1;
299 uint16_t na_flags;
300 uint16_t na_srr_rxid;
301 uint16_t na_status;
302 uint8_t na_status_subcode;
303 uint8_t na_reserved2;
304 uint32_t na_rxid;
305 uint16_t na_srr_reloff_lo;
306 uint16_t na_srr_reloff_hi;
307 uint16_t na_srr_iu;
308 uint16_t na_srr_flags;
309 uint8_t na_reserved3[18];
310 uint8_t na_reserved4;
311 uint8_t na_vpindex;
312 uint8_t na_srr_reject_vunique;
313 uint8_t na_srr_reject_explanation;
314 uint8_t na_srr_reject_code;
315 uint8_t na_reserved5;
316 uint8_t na_reserved6[6];
317 uint16_t na_oxid;
318 } na_fcentry_24xx_t;
319
320 /*
321 * Accept Target I/O Entry structure
322 */
323 #define ATIO_CDBLEN 26
324
325 typedef struct {
326 isphdr_t at_header;
327 uint16_t at_reserved;
328 uint16_t at_handle;
329 uint8_t at_lun; /* lun */
330 uint8_t at_iid; /* initiator */
331 uint8_t at_cdblen; /* cdb length */
332 uint8_t at_tgt; /* target */
333 uint32_t at_flags;
334 uint8_t at_status; /* firmware status */
335 uint8_t at_scsi_status; /* scsi status */
336 uint8_t at_tag_val; /* tag value */
337 uint8_t at_tag_type; /* tag type */
338 uint8_t at_cdb[ATIO_CDBLEN]; /* received CDB */
339 uint8_t at_sense[QLTM_SENSELEN];/* suggested sense data */
340 } at_entry_t;
341
342 /*
343 * at_flags values
344 */
345 #define AT_NODISC 0x00008000 /* disconnect disabled */
346 #define AT_TQAE 0x00000002 /* Tagged Queue Action enabled */
347
348 /*
349 * at_status values
350 */
351 #define AT_PATH_INVALID 0x07 /* ATIO sent to firmware for disabled lun */
352 #define AT_RESET 0x0E /* SCSI Bus Reset Occurred */
353 #define AT_PHASE_ERROR 0x14 /* Bus phase sequence error */
354 #define AT_NOCAP 0x16 /* Requested capability not available */
355 #define AT_BDR_MSG 0x17 /* Bus Device Reset msg received */
356 #define AT_CDB 0x3D /* CDB received */
357 /*
358 * Macros to create and fetch and test concatenated handle and tag value macros
359 */
360
361 #define AT_MAKE_TAGID(tid, bus, inst, aep) \
362 tid = aep->at_handle; \
363 if (aep->at_flags & AT_TQAE) { \
364 tid |= (aep->at_tag_val << 16); \
365 tid |= (1 << 24); \
366 } \
367 tid |= (bus << 25); \
368 tid |= (inst << 26)
369
370 #define CT_MAKE_TAGID(tid, bus, inst, ct) \
371 tid = ct->ct_fwhandle; \
372 if (ct->ct_flags & CT_TQAE) { \
373 tid |= (ct->ct_tag_val << 16); \
374 tid |= (1 << 24); \
375 } \
376 tid |= ((bus & 0x1) << 25); \
377 tid |= (inst << 26)
378
379 #define AT_HAS_TAG(val) ((val) & (1 << 24))
380 #define AT_GET_TAG(val) (((val) >> 16) & 0xff)
381 #define AT_GET_INST(val) (((val) >> 26) & 0x3f)
382 #define AT_GET_BUS(val) (((val) >> 25) & 0x1)
383 #define AT_GET_HANDLE(val) ((val) & 0xffff)
384
385 #define IN_MAKE_TAGID(tid, bus, inst, inp) \
386 tid = inp->in_seqid; \
387 tid |= (inp->in_tag_val << 16); \
388 tid |= (1 << 24); \
389 tid |= (bus << 25); \
390 tid |= (inst << 26)
391
392 #define TAG_INSERT_INST(tid, inst) \
393 tid &= ~(0x3ffffff); \
394 tid |= (inst << 26)
395
396 #define TAG_INSERT_BUS(tid, bus) \
397 tid &= ~(1 << 25); \
398 tid |= (bus << 25)
399
400 /*
401 * Accept Target I/O Entry structure, Type 2
402 */
403 #define ATIO2_CDBLEN 16
404
405 typedef struct {
406 isphdr_t at_header;
407 uint32_t at_reserved;
408 uint8_t at_lun; /* lun or reserved */
409 uint8_t at_iid; /* initiator */
410 uint16_t at_rxid; /* response ID */
411 uint16_t at_flags;
412 uint16_t at_status; /* firmware status */
413 uint8_t at_crn; /* command reference number */
414 uint8_t at_taskcodes;
415 uint8_t at_taskflags;
416 uint8_t at_execodes;
417 uint8_t at_cdb[ATIO2_CDBLEN]; /* received CDB */
418 uint32_t at_datalen; /* allocated data len */
419 uint16_t at_scclun; /* SCC Lun or reserved */
420 uint16_t at_wwpn[4]; /* WWPN of initiator */
421 uint16_t at_reserved2[6];
422 uint16_t at_oxid;
423 } at2_entry_t;
424
425 typedef struct {
426 isphdr_t at_header;
427 uint32_t at_reserved;
428 uint16_t at_iid; /* initiator */
429 uint16_t at_rxid; /* response ID */
430 uint16_t at_flags;
431 uint16_t at_status; /* firmware status */
432 uint8_t at_crn; /* command reference number */
433 uint8_t at_taskcodes;
434 uint8_t at_taskflags;
435 uint8_t at_execodes;
436 uint8_t at_cdb[ATIO2_CDBLEN]; /* received CDB */
437 uint32_t at_datalen; /* allocated data len */
438 uint16_t at_scclun; /* SCC Lun or reserved */
439 uint16_t at_wwpn[4]; /* WWPN of initiator */
440 uint16_t at_reserved2[6];
441 uint16_t at_oxid;
442 } at2e_entry_t;
443
444 #define ATIO2_WWPN_OFFSET 0x2A
445 #define ATIO2_OXID_OFFSET 0x3E
446
447 #define ATIO2_TC_ATTR_MASK 0x7
448 #define ATIO2_TC_ATTR_SIMPLEQ 0
449 #define ATIO2_TC_ATTR_HEADOFQ 1
450 #define ATIO2_TC_ATTR_ORDERED 2
451 #define ATIO2_TC_ATTR_ACAQ 4
452 #define ATIO2_TC_ATTR_UNTAGGED 5
453
454 #define ATIO2_EX_WRITE 0x1
455 #define ATIO2_EX_READ 0x2
456 /*
457 * Macros to create and fetch and test concatenated handle and tag value macros
458 */
459 #define AT2_MAKE_TAGID(tid, bus, inst, aep) \
460 tid = aep->at_rxid; \
461 tid |= (((uint64_t)inst) << 32); \
462 tid |= (((uint64_t)bus) << 48)
463
464 #define CT2_MAKE_TAGID(tid, bus, inst, ct) \
465 tid = ct->ct_rxid; \
466 tid |= (((uint64_t)inst) << 32); \
467 tid |= (((uint64_t)(bus & 0xff)) << 48)
468
469 #define AT2_HAS_TAG(val) 1
470 #define AT2_GET_TAG(val) ((val) & 0xffffffff)
471 #define AT2_GET_INST(val) (((val) >> 32) & 0xffff)
472 #define AT2_GET_HANDLE AT2_GET_TAG
473 #define AT2_GET_BUS(val) (((val) >> 48) & 0xff)
474
475 #define FC_HAS_TAG AT2_HAS_TAG
476 #define FC_GET_TAG AT2_GET_TAG
477 #define FC_GET_INST AT2_GET_INST
478 #define FC_GET_HANDLE AT2_GET_HANDLE
479
480 #define IN_FC_MAKE_TAGID(tid, bus, inst, seqid) \
481 tid = seqid; \
482 tid |= (((uint64_t)inst) << 32); \
483 tid |= (((uint64_t)(bus & 0xff)) << 48)
484
485 #define FC_TAG_INSERT_INST(tid, inst) \
486 tid &= ~0x0000ffff00000000ull; \
487 tid |= (((uint64_t)inst) << 32)
488
489 /*
490 * 24XX ATIO Definition
491 *
492 * This is *quite* different from other entry types.
493 * First of all, it has its own queue it comes in on.
494 *
495 * Secondly, it doesn't have a normal header.
496 *
497 * Thirdly, it's just a passthru of the FCP CMND IU
498 * which is recorded in big endian mode.
499 */
500 typedef struct {
501 uint8_t at_type;
502 uint8_t at_count;
503 /*
504 * Task attribute in high four bits,
505 * the rest is the FCP CMND IU Length.
506 * NB: the command can extend past the
507 * length for a single queue entry.
508 */
509 uint16_t at_ta_len;
510 uint32_t at_rxid;
511 fc_hdr_t at_hdr;
512 fcp_cmnd_iu_t at_cmnd;
513 } at7_entry_t;
514 #define AT7_NORESRC_RXID 0xffffffff
515
516
517 /*
518 * Continue Target I/O Entry structure
519 * Request from driver. The response from the
520 * ISP firmware is the same except that the last 18
521 * bytes are overwritten by suggested sense data if
522 * the 'autosense valid' bit is set in the status byte.
523 */
524 typedef struct {
525 isphdr_t ct_header;
526 uint16_t ct_syshandle;
527 uint16_t ct_fwhandle; /* required by f/w */
528 uint8_t ct_lun; /* lun */
529 uint8_t ct_iid; /* initiator id */
530 uint8_t ct_reserved2;
531 uint8_t ct_tgt; /* our target id */
532 uint32_t ct_flags;
533 uint8_t ct_status; /* isp status */
534 uint8_t ct_scsi_status; /* scsi status */
535 uint8_t ct_tag_val; /* tag value */
536 uint8_t ct_tag_type; /* tag type */
537 uint32_t ct_xfrlen; /* transfer length */
538 uint32_t ct_resid; /* residual length */
539 uint16_t ct_timeout;
540 uint16_t ct_seg_count;
541 ispds_t ct_dataseg[ISP_RQDSEG];
542 } ct_entry_t;
543
544 /*
545 * For some of the dual port SCSI adapters, port (bus #) is reported
546 * in the MSbit of ct_iid. Bit fields are a bit too awkward here.
547 *
548 * Note that this does not apply to FC adapters at all which can and
549 * do report IIDs between 0x81 && 0xfe (or 0x7ff) which represent devices
550 * that have logged in across a SCSI fabric.
551 */
552 #define GET_IID_VAL(x) (x & 0x3f)
553 #define GET_BUS_VAL(x) ((x >> 7) & 0x1)
554 #define SET_IID_VAL(y, x) y = ((y & ~0x3f) | (x & 0x3f))
555 #define SET_BUS_VAL(y, x) y = ((y & 0x3f) | ((x & 0x1) << 7))
556
557 /*
558 * ct_flags values
559 */
560 #define CT_TQAE 0x00000002 /* bit 1, Tagged Queue Action enable */
561 #define CT_DATA_IN 0x00000040 /* bits 6&7, Data direction */
562 #define CT_DATA_OUT 0x00000080 /* bits 6&7, Data direction */
563 #define CT_NO_DATA 0x000000C0 /* bits 6&7, Data direction */
564 #define CT_CCINCR 0x00000100 /* bit 8, autoincrement atio count */
565 #define CT_DATAMASK 0x000000C0 /* bits 6&7, Data direction */
566 #define CT_INISYNCWIDE 0x00004000 /* bit 14, Do Sync/Wide Negotiation */
567 #define CT_NODISC 0x00008000 /* bit 15, Disconnects disabled */
568 #define CT_DSDP 0x01000000 /* bit 24, Disable Save Data Pointers */
569 #define CT_SENDRDP 0x04000000 /* bit 26, Send Restore Pointers msg */
570 #define CT_SENDSTATUS 0x80000000 /* bit 31, Send SCSI status byte */
571
572 /*
573 * ct_status values
574 * - set by the firmware when it returns the CTIO
575 */
576 #define CT_OK 0x01 /* completed without error */
577 #define CT_ABORTED 0x02 /* aborted by host */
578 #define CT_ERR 0x04 /* see sense data for error */
579 #define CT_INVAL 0x06 /* request for disabled lun */
580 #define CT_NOPATH 0x07 /* invalid ITL nexus */
581 #define CT_INVRXID 0x08 /* (FC only) Invalid RX_ID */
582 #define CT_DATA_OVER 0x09 /* (FC only) Data Overrun */
583 #define CT_RSELTMO 0x0A /* reselection timeout after 2 tries */
584 #define CT_TIMEOUT 0x0B /* timed out */
585 #define CT_RESET 0x0E /* SCSI Bus Reset occurred */
586 #define CT_PARITY 0x0F /* Uncorrectable Parity Error */
587 #define CT_BUS_ERROR 0x10 /* (FC Only) DMA PCI Error */
588 #define CT_PANIC 0x13 /* Unrecoverable Error */
589 #define CT_PHASE_ERROR 0x14 /* Bus phase sequence error */
590 #define CT_DATA_UNDER 0x15 /* (FC only) Data Underrun */
591 #define CT_BDR_MSG 0x17 /* Bus Device Reset msg received */
592 #define CT_TERMINATED 0x19 /* due to Terminate Transfer mbox cmd */
593 #define CT_PORTUNAVAIL 0x28 /* port not available */
594 #define CT_LOGOUT 0x29 /* port logout */
595 #define CT_PORTCHANGED 0x2A /* port changed */
596 #define CT_IDE 0x33 /* Initiator Detected Error */
597 #define CT_NOACK 0x35 /* Outstanding Immed. Notify. entry */
598 #define CT_SRR 0x45 /* SRR Received */
599 #define CT_LUN_RESET 0x48 /* Lun Reset Received */
600
601 /*
602 * When the firmware returns a CTIO entry, it may overwrite the last
603 * part of the structure with sense data. This starts at offset 0x2E
604 * into the entry, which is in the middle of ct_dataseg[1]. Rather
605 * than define a new struct for this, I'm just using the sense data
606 * offset.
607 */
608 #define CTIO_SENSE_OFFSET 0x2E
609
610 /*
611 * Entry length in u_longs. All entries are the same size so
612 * any one will do as the numerator.
613 */
614 #define UINT32_ENTRY_SIZE (sizeof(at_entry_t)/sizeof(uint32_t))
615
616 /*
617 * QLA2100 CTIO (type 2) entry
618 */
619 #define MAXRESPLEN 26
620 typedef struct {
621 isphdr_t ct_header;
622 uint32_t ct_syshandle;
623 uint8_t ct_lun; /* lun */
624 uint8_t ct_iid; /* initiator id */
625 uint16_t ct_rxid; /* response ID */
626 uint16_t ct_flags;
627 uint16_t ct_status; /* isp status */
628 uint16_t ct_timeout;
629 uint16_t ct_seg_count;
630 uint32_t ct_reloff; /* relative offset */
631 int32_t ct_resid; /* residual length */
632 union {
633 /*
634 * The three different modes that the target driver
635 * can set the CTIO{2,3,4} up as.
636 *
637 * The first is for sending FCP_DATA_IUs as well as
638 * (optionally) sending a terminal SCSI status FCP_RSP_IU.
639 *
640 * The second is for sending SCSI sense data in an FCP_RSP_IU.
641 * Note that no FCP_DATA_IUs will be sent.
642 *
643 * The third is for sending FCP_RSP_IUs as built specifically
644 * in system memory as located by the isp_dataseg.
645 */
646 struct {
647 uint32_t _reserved;
648 uint16_t _reserved2;
649 uint16_t ct_scsi_status;
650 uint32_t ct_xfrlen;
651 union {
652 ispds_t ct_dataseg[ISP_RQDSEG_T2];
653 ispds64_t ct_dataseg64[ISP_RQDSEG_T3];
654 ispdslist_t ct_dslist;
655 } u;
656 } m0;
657 struct {
658 uint16_t _reserved;
659 uint16_t _reserved2;
660 uint16_t ct_senselen;
661 uint16_t ct_scsi_status;
662 uint16_t ct_resplen;
663 uint8_t ct_resp[MAXRESPLEN];
664 } m1;
665 struct {
666 uint32_t _reserved;
667 uint16_t _reserved2;
668 uint16_t _reserved3;
669 uint32_t ct_datalen;
670 ispds_t ct_fcp_rsp_iudata;
671 } m2;
672 } rsp;
673 } ct2_entry_t;
674
675 typedef struct {
676 isphdr_t ct_header;
677 uint32_t ct_syshandle;
678 uint16_t ct_iid; /* initiator id */
679 uint16_t ct_rxid; /* response ID */
680 uint16_t ct_flags;
681 uint16_t ct_status; /* isp status */
682 uint16_t ct_timeout;
683 uint16_t ct_seg_count;
684 uint32_t ct_reloff; /* relative offset */
685 int32_t ct_resid; /* residual length */
686 union {
687 struct {
688 uint32_t _reserved;
689 uint16_t _reserved2;
690 uint16_t ct_scsi_status;
691 uint32_t ct_xfrlen;
692 union {
693 ispds_t ct_dataseg[ISP_RQDSEG_T2];
694 ispds64_t ct_dataseg64[ISP_RQDSEG_T3];
695 ispdslist_t ct_dslist;
696 } u;
697 } m0;
698 struct {
699 uint16_t _reserved;
700 uint16_t _reserved2;
701 uint16_t ct_senselen;
702 uint16_t ct_scsi_status;
703 uint16_t ct_resplen;
704 uint8_t ct_resp[MAXRESPLEN];
705 } m1;
706 struct {
707 uint32_t _reserved;
708 uint16_t _reserved2;
709 uint16_t _reserved3;
710 uint32_t ct_datalen;
711 ispds_t ct_fcp_rsp_iudata;
712 } m2;
713 } rsp;
714 } ct2e_entry_t;
715
716 /*
717 * ct_flags values for CTIO2
718 */
719 #define CT2_FLAG_MODE0 0x0000
720 #define CT2_FLAG_MODE1 0x0001
721 #define CT2_FLAG_MODE2 0x0002
722 #define CT2_FLAG_MMASK 0x0003
723 #define CT2_DATA_IN 0x0040
724 #define CT2_DATA_OUT 0x0080
725 #define CT2_NO_DATA 0x00C0
726 #define CT2_DATAMASK 0x00C0
727 #define CT2_CCINCR 0x0100
728 #define CT2_FASTPOST 0x0200
729 #define CT2_CONFIRM 0x2000
730 #define CT2_TERMINATE 0x4000
731 #define CT2_SENDSTATUS 0x8000
732
733 /*
734 * ct_status values are (mostly) the same as that for ct_entry.
735 */
736
737 /*
738 * ct_scsi_status values- the low 8 bits are the normal SCSI status
739 * we know and love. The upper 8 bits are validity markers for FCP_RSP_IU
740 * fields.
741 */
742 #define CT2_RSPLEN_VALID 0x0100
743 #define CT2_SNSLEN_VALID 0x0200
744 #define CT2_DATA_OVER 0x0400
745 #define CT2_DATA_UNDER 0x0800
746
747 /*
748 * ISP24XX CTIO
749 */
750 #define MAXRESPLEN_24XX 24
751 typedef struct {
752 isphdr_t ct_header;
753 uint32_t ct_syshandle;
754 uint16_t ct_nphdl; /* status on returned CTIOs */
755 uint16_t ct_timeout;
756 uint16_t ct_seg_count;
757 uint8_t ct_vpindex;
758 uint8_t ct_xflags;
759 uint16_t ct_iid_lo; /* low 16 bits of portid */
760 uint8_t ct_iid_hi; /* hi 8 bits of portid */
761 uint8_t ct_reserved;
762 uint32_t ct_rxid;
763 uint16_t ct_senselen; /* mode 1 only */
764 uint16_t ct_flags;
765 int32_t ct_resid; /* residual length */
766 uint16_t ct_oxid;
767 uint16_t ct_scsi_status; /* modes 0 && 1 only */
768 union {
769 struct {
770 uint32_t reloff;
771 uint32_t reserved0;
772 uint32_t ct_xfrlen;
773 uint32_t reserved1;
774 ispds64_t ds;
775 } m0;
776 struct {
777 uint16_t ct_resplen;
778 uint16_t reserved;
779 uint8_t ct_resp[MAXRESPLEN_24XX];
780 } m1;
781 struct {
782 uint32_t reserved0;
783 uint32_t ct_datalen;
784 uint32_t reserved1;
785 ispds64_t ct_fcp_rsp_iudata;
786 } m2;
787 } rsp;
788 } ct7_entry_t;
789
790 /*
791 * ct_flags values for CTIO7
792 */
793 #define CT7_DATA_IN 0x0002
794 #define CT7_DATA_OUT 0x0001
795 #define CT7_NO_DATA 0x0000
796 #define CT7_DATAMASK 0x003
797 #define CT7_DSD_ENABLE 0x0004
798 #define CT7_CONF_STSFD 0x0010
799 #define CT7_EXPLCT_CONF 0x0020
800 #define CT7_FLAG_MODE0 0x0000
801 #define CT7_FLAG_MODE1 0x0040
802 #define CT7_FLAG_MODE2 0x0080
803 #define CT7_FLAG_MMASK 0x00C0
804 #define CT7_NOACK 0x0100
805 #define CT7_TASK_ATTR_SHIFT 9
806 #define CT7_CONFIRM 0x2000
807 #define CT7_TERMINATE 0x4000
808 #define CT7_SENDSTATUS 0x8000
809
810 /*
811 * Type 7 CTIO status codes
812 */
813 #define CT7_OK 0x01 /* completed without error */
814 #define CT7_ABORTED 0x02 /* aborted by host */
815 #define CT7_ERR 0x04 /* see sense data for error */
816 #define CT7_INVAL 0x06 /* request for disabled lun */
817 #define CT7_INVRXID 0x08 /* (FC only) Invalid RX_ID */
818 #define CT7_DATA_OVER 0x09 /* (FC only) Data Overrun */
819 #define CT7_TIMEOUT 0x0B /* timed out */
820 #define CT7_RESET 0x0E /* LIP Rset Received */
821 #define CT7_BUS_ERROR 0x10 /* DMA PCI Error */
822 #define CT7_REASSY_ERR 0x11 /* DMA reassembly error */
823 #define CT7_DATA_UNDER 0x15 /* (FC only) Data Underrun */
824 #define CT7_PORTUNAVAIL 0x28 /* port not available */
825 #define CT7_LOGOUT 0x29 /* port logout */
826 #define CT7_PORTCHANGED 0x2A /* port changed */
827 #define CT7_SRR 0x45 /* SRR Received */
828
829 /*
830 * Other 24XX related target IOCBs
831 */
832
833 /*
834 * ABTS Received
835 */
836 typedef struct {
837 isphdr_t abts_header;
838 uint8_t abts_reserved0[6];
839 uint16_t abts_nphdl;
840 uint16_t abts_reserved1;
841 uint16_t abts_sof;
842 uint32_t abts_rxid_abts;
843 uint16_t abts_did_lo;
844 uint8_t abts_did_hi;
845 uint8_t abts_r_ctl;
846 uint16_t abts_sid_lo;
847 uint8_t abts_sid_hi;
848 uint8_t abts_cs_ctl;
849 uint16_t abts_fs_ctl;
850 uint8_t abts_f_ctl;
851 uint8_t abts_type;
852 uint16_t abts_seq_cnt;
853 uint8_t abts_df_ctl;
854 uint8_t abts_seq_id;
855 uint16_t abts_rx_id;
856 uint16_t abts_ox_id;
857 uint32_t abts_param;
858 uint8_t abts_reserved2[16];
859 uint32_t abts_rxid_task;
860 } abts_t;
861
862 typedef struct {
863 isphdr_t abts_rsp_header;
864 uint32_t abts_rsp_handle;
865 uint16_t abts_rsp_status;
866 uint16_t abts_rsp_nphdl;
867 uint16_t abts_rsp_ctl_flags;
868 uint16_t abts_rsp_sof;
869 uint32_t abts_rsp_rxid_abts;
870 uint16_t abts_rsp_did_lo;
871 uint8_t abts_rsp_did_hi;
872 uint8_t abts_rsp_r_ctl;
873 uint16_t abts_rsp_sid_lo;
874 uint8_t abts_rsp_sid_hi;
875 uint8_t abts_rsp_cs_ctl;
876 uint16_t abts_rsp_f_ctl_lo;
877 uint8_t abts_rsp_f_ctl_hi;
878 uint8_t abts_rsp_type;
879 uint16_t abts_rsp_seq_cnt;
880 uint8_t abts_rsp_df_ctl;
881 uint8_t abts_rsp_seq_id;
882 uint16_t abts_rsp_rx_id;
883 uint16_t abts_rsp_ox_id;
884 uint32_t abts_rsp_param;
885 union {
886 struct {
887 uint16_t reserved;
888 uint8_t last_seq_id;
889 uint8_t seq_id_valid;
890 uint16_t aborted_rx_id;
891 uint16_t aborted_ox_id;
892 uint16_t high_seq_cnt;
893 uint16_t low_seq_cnt;
894 uint8_t reserved2[4];
895 } ba_acc;
896 struct {
897 uint8_t vendor_unique;
898 uint8_t explanation;
899 uint8_t reason;
900 uint8_t reserved;
901 uint8_t reserved2[12];
902 } ba_rjt;
903 struct {
904 uint8_t reserved[8];
905 uint32_t subcode1;
906 uint32_t subcode2;
907 } rsp;
908 uint8_t reserved[16];
909 } abts_rsp_payload;
910 uint32_t abts_rsp_rxid_task;
911 } abts_rsp_t;
912
913 /* terminate this ABTS exchange */
914 #define ISP24XX_ABTS_RSP_TERMINATE 0x01
915
916 #define ISP24XX_ABTS_RSP_COMPLETE 0x00
917 #define ISP24XX_ABTS_RSP_RESET 0x04
918 #define ISP24XX_ABTS_RSP_ABORTED 0x05
919 #define ISP24XX_ABTS_RSP_TIMEOUT 0x06
920 #define ISP24XX_ABTS_RSP_INVXID 0x08
921 #define ISP24XX_ABTS_RSP_LOGOUT 0x29
922 #define ISP24XX_ABTS_RSP_SUBCODE 0x31
923
924 #define ISP24XX_NO_TASK 0xffffffff
925
926 /*
927 * Debug macros
928 */
929
930 #define ISP_TDQE(isp, msg, idx, arg) \
931 if (isp->isp_dblev & ISP_LOGTDEBUG2) isp_print_qentry(isp, msg, idx, arg)
932
933 #ifndef ISP_TOOLS
934 /*
935 * The functions below are for the publicly available
936 * target mode functions that are internal to the Qlogic driver.
937 */
938
939 /*
940 * This function handles new response queue entry appropriate for target mode.
941 */
942 int isp_target_notify(ispsoftc_t *, void *, uint32_t *);
943
944 /*
945 * This function externalizes the ability to acknowledge an Immediate Notify
946 * request.
947 */
948 void isp_notify_ack(ispsoftc_t *, void *);
949
950 /*
951 * Enable/Disable/Modify a logical unit.
952 * (softc, cmd, bus, tgt, lun, cmd_cnt, inotify_cnt)
953 */
954 #define DFLT_CMND_CNT 0xfe /* unmonitored */
955 #define DFLT_INOT_CNT 0xfe /* unmonitored */
956 int isp_lun_cmd(ispsoftc_t *, int, int, int, int, int);
957
958 /*
959 * General request queue 'put' routine for target mode entries.
960 */
961 int isp_target_put_entry(ispsoftc_t *isp, void *);
962
963 /*
964 * General routine to put back an ATIO entry-
965 * used for replenishing f/w resource counts.
966 * The argument is a pointer to a source ATIO
967 * or ATIO2.
968 */
969 int isp_target_put_atio(ispsoftc_t *, void *);
970
971 /*
972 * General routine to send a final CTIO for a command- used mostly for
973 * local responses.
974 */
975 int isp_endcmd(ispsoftc_t *, ...);
976 #define ECMD_SVALID 0x100
977
978 /*
979 * Handle an asynchronous event
980 *
981 * Return nonzero if the interrupt that generated this event has been dismissed.
982 */
983 int isp_target_async(ispsoftc_t *, int, int);
984 #endif
985 #endif /* _ISP_TARGET_H */
Cache object: b1017a2ae85eab30a1a50339fdc1d103
|