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