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