Deleted Added
full compact
isp_target.h (167403) isp_target.h (196008)
1/* $FreeBSD: head/sys/dev/isp/isp_target.h 167403 2007-03-10 02:39:54Z mjacob $ */
1/* $FreeBSD: head/sys/dev/isp/isp_target.h 196008 2009-08-01 01:04:26Z mjacob $ */
2/*-
2/*-
3 * Copyright (c) 1997-2007 by Matthew Jacob
3 * Copyright (c) 1997-2009 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.

--- 7 unchanged lines hidden (view full) ---

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.
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.

--- 7 unchanged lines hidden (view full) ---

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