3 * Copyright (c) 1997-2009 by Matthew Jacob
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
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.
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
30 * Structures that derive directly from public standards.
37 * Source: dpANS-X3.xxx-199x, section 18 (AKA FC-PH-2)
58 * Source: NICTS T10, Project 1144D, Revision 07a, Section 9 (AKA fcp2-r07a)
61 * When additional cdb length is defined in fcp_cmnd_alen_datadir,
62 * bits 2..7, the actual cdb length is 16 + ((fcp_cmnd_alen_datadir>>2)*4),
63 * with the datalength following in MSB format just after.
66 uint8_t fcp_cmnd_lun[8];
68 uint8_t fcp_cmnd_task_attribute;
69 uint8_t fcp_cmnd_task_management;
70 uint8_t fcp_cmnd_alen_datadir;
73 uint8_t fcp_cmnd_cdb[16];
77 uint8_t fcp_cmnd_cdb[1];
83 #define FCP_CMND_TASK_ATTR_SIMPLE 0x00
84 #define FCP_CMND_TASK_ATTR_HEAD 0x01
85 #define FCP_CMND_TASK_ATTR_ORDERED 0x02
86 #define FCP_CMND_TASK_ATTR_ACA 0x04
87 #define FCP_CMND_TASK_ATTR_UNTAGGED 0x05
88 #define FCP_CMND_TASK_ATTR_MASK 0x07
90 #define FCP_CMND_ADDTL_CDBLEN_SHIFT 2
92 #define FCP_CMND_DATA_WRITE 0x01
93 #define FCP_CMND_DATA_READ 0x02
95 #define FCP_CMND_DATA_DIR_MASK 0x03
97 #define FCP_CMND_TMF_CLEAR_ACA 0x40
98 #define FCP_CMND_TMF_TGT_RESET 0x20
99 #define FCP_CMND_TMF_LUN_RESET 0x10
100 #define FCP_CMND_TMF_CLEAR_TASK_SET 0x04
101 #define FCP_CMND_TMF_ABORT_TASK_SET 0x02
106 * Source: X3.288-199x Generic Services 2 Rev 5.3 (FC-GS-2) Section 4.3.1
113 uint8_t ct_fcs_subtype;
115 uint8_t ct_reserved0;
116 uint16_t ct_cmd_resp;
117 uint16_t ct_bcnt_resid;
118 uint8_t ct_reserved1;
120 uint8_t ct_explanation;
123 #define CT_REVISION 1
124 #define CT_FC_TYPE_FC 0xFC
125 #define CT_FC_SUBTYPE_NS 0x02
128 * RFT_ID Requet CT_IU
130 * Source: NCITS xxx-200x Generic Services- 5 Rev 8.5 Section 5.2.5.30
134 uint8_t rftid_reserved;
135 uint8_t rftid_portid[3];
136 uint32_t rftid_fc4types[8];
140 * FCP Response IU and bits of interest
141 * Source: NCITS T10, Project 1828D, Revision 02b (aka FCP4r02b)
144 uint8_t fcp_rsp_reserved[8];
145 uint16_t fcp_rsp_status_qualifier; /* SAM-5 Status Qualifier */
146 uint8_t fcp_rsp_bits;
147 uint8_t fcp_rsp_scsi_status; /* SAM-5 SCSI Status Byte */
148 uint32_t fcp_rsp_resid;
149 uint32_t fcp_rsp_snslen;
150 uint32_t fcp_rsp_rsplen;
152 * In the bytes that follow, it's going to be
153 * FCP RESPONSE INFO (max 8 bytes, possibly 0)
154 * FCP SENSE INFO (if any)
155 * FCP BIDIRECTIONAL READ RESID (if any)
157 uint8_t fcp_rsp_extra[0];
159 #define MIN_FCP_RESPONSE_SIZE 24
161 #define FCP_BIDIR_RSP 0x80 /* Bi-Directional response */
162 #define FCP_BIDIR_RESID_UNDERFLOW 0x40
163 #define FCP_BIDIR_RESID_OVERFLOW 0x20
164 #define FCP_CONF_REQ 0x10
165 #define FCP_RESID_UNDERFLOW 0x08
166 #define FCP_RESID_OVERFLOW 0x04
167 #define FCP_SNSLEN_VALID 0x02
168 #define FCP_RSPLEN_VALID 0x01
170 #define FCP_MAX_RSPLEN 0x08
172 * FCP Response Code Definitions
173 * Source: NCITS T10, Project 1144D, Revision 08 (aka FCP2r08)
175 #define FCP_RSPNS_CODE_OFFSET 3
177 #define FCP_RSPNS_TMF_DONE 0
178 #define FCP_RSPNS_DLBRSTX 1
179 #define FCP_RSPNS_BADCMND 2
180 #define FCP_RSPNS_EROFS 3
181 #define FCP_RSPNS_TMF_REJECT 4
182 #define FCP_RSPNS_TMF_FAILED 5
183 #define FCP_RSPNS_TMF_SUCCEEDED 8
184 #define FCP_RSPNS_TMF_INCORRECT_LUN 9
187 * R_CTL field definitions
189 * Bits 31-28 are ROUTING
190 * Bits 27-24 are INFORMATION
192 * These are nibble values, not bits
194 #define R_CTL_ROUTE_DATA 0x00
195 #define R_CTL_ROUTE_ELS 0x02
196 #define R_CTL_ROUTE_FC4_LINK 0x03
197 #define R_CTL_ROUTE_VDATA 0x04
198 #define R_CTL_ROUTE_EXENDED 0x05
199 #define R_CTL_ROUTE_BASIC 0x08
200 #define R_CTL_ROUTE_LINK 0x0c
201 #define R_CTL_ROUTE_EXT_ROUTING 0x0f
203 #define R_CTL_INFO_UNCATEGORIZED 0x00
204 #define R_CTL_INFO_SOLICITED_DATA 0x01
205 #define R_CTL_INFO_UNSOLICITED_CONTROL 0x02
206 #define R_CTL_INFO_SOLICITED_CONTROL 0x03
207 #define R_CTL_INFO_UNSOLICITED_DATA 0x04
208 #define R_CTL_INFO_DATA_DESCRIPTOR 0x05
209 #define R_CTL_INFO_UNSOLICITED_COMMAND 0x06
210 #define R_CTL_INFO_COMMAND_STATUS 0x07
212 #define MAKE_RCTL(a, b) (((a) << 4) | (b))
214 /* unconverted miscellany */
216 * Basic FC Link Service defines
218 /* #define ABTS MAKE_RCTL(R_CTL_ROUTE_BASIC, R_CTL_INFO_SOLICITED_DATA) */
219 #define BA_ACC MAKE_RCTL(R_CTL_ROUTE_BASIC, R_CTL_INFO_UNSOLICITED_DATA) /* of ABORT */
220 #define BA_RJT MAKE_RCTL(R_CTL_ROUTE_BASIC, R_CTL_INFO_DATA_DESCRIPTOR) /* of ABORT */
223 * Link Service Accept/Reject
225 #define LS_ACC 0x8002
226 #define LS_RJT 0x8001
229 * FC ELS Codes- bits 31-24 of the first payload word of an ELS frame.
244 * PRLI Word 3 definitions
245 * FPC4-r02b January, 2011
247 #define PRLI_WD3_ENHANCED_DISCOVERY (1 << 11)
248 #define PRLI_WD3_REC_SUPPORT (1 << 10)
249 #define PRLI_WD3_TASK_RETRY_IDENTIFICATION_REQUESTED (1 << 9)
250 #define PRLI_WD3_RETRY (1 << 8)
251 #define PRLI_WD3_CONFIRMED_COMPLETION_ALLOWED (1 << 7)
252 #define PRLI_WD3_DATA_OVERLAY_ALLOWED (1 << 6)
253 #define PRLI_WD3_INITIATOR_FUNCTION (1 << 5)
254 #define PRLI_WD3_TARGET_FUNCTION (1 << 4)
255 #define PRLI_WD3_READ_FCP_XFER_RDY_DISABLED (1 << 1) /* definitely supposed to be set */
256 #define PRLI_WD3_WRITE_FCP_XFER_RDY_DISABLED (1 << 0)
263 #define FC4_IP 5 /* ISO/EEC 8802-2 LLC/SNAP */
264 #define FC4_SCSI 8 /* SCSI-3 via Fibre Channel Protocol (FCP) */
265 #define FC4_FC_SVC 0x20 /* Fibre Channel Services */
268 #define MSG_ABORT 0x06
270 #ifndef MSG_BUS_DEV_RESET
271 #define MSG_BUS_DEV_RESET 0x0c
273 #ifndef MSG_ABORT_TAG
274 #define MSG_ABORT_TAG 0x0d
276 #ifndef MSG_CLEAR_QUEUE
277 #define MSG_CLEAR_QUEUE 0x0e
279 #ifndef MSG_REL_RECOVERY
280 #define MSG_REL_RECOVERY 0x10
282 #ifndef MSG_TERM_IO_PROC
283 #define MSG_TERM_IO_PROC 0x11
285 #ifndef MSG_LUN_RESET
286 #define MSG_LUN_RESET 0x17
289 #endif /* _ISP_STDS_H */