3 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
5 * Copyright (c) 1997-2009 by Matthew Jacob
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * Structures that derive directly from public standards.
39 * Source: dpANS-X3.xxx-199x, section 18 (AKA FC-PH-2)
60 * Source: NICTS T10, Project 1144D, Revision 07a, Section 9 (AKA fcp2-r07a)
63 * When additional cdb length is defined in fcp_cmnd_alen_datadir,
64 * bits 2..7, the actual cdb length is 16 + ((fcp_cmnd_alen_datadir>>2)*4),
65 * with the datalength following in MSB format just after.
68 uint8_t fcp_cmnd_lun[8];
70 uint8_t fcp_cmnd_task_attribute;
71 uint8_t fcp_cmnd_task_management;
72 uint8_t fcp_cmnd_alen_datadir;
75 uint8_t fcp_cmnd_cdb[16];
79 uint8_t fcp_cmnd_cdb[1];
85 #define FCP_CMND_TASK_ATTR_SIMPLE 0x00
86 #define FCP_CMND_TASK_ATTR_HEAD 0x01
87 #define FCP_CMND_TASK_ATTR_ORDERED 0x02
88 #define FCP_CMND_TASK_ATTR_ACA 0x04
89 #define FCP_CMND_TASK_ATTR_UNTAGGED 0x05
90 #define FCP_CMND_TASK_ATTR_MASK 0x07
92 #define FCP_CMND_ADDTL_CDBLEN_SHIFT 2
94 #define FCP_CMND_DATA_WRITE 0x01
95 #define FCP_CMND_DATA_READ 0x02
97 #define FCP_CMND_DATA_DIR_MASK 0x03
99 #define FCP_CMND_TMF_CLEAR_ACA 0x40
100 #define FCP_CMND_TMF_TGT_RESET 0x20
101 #define FCP_CMND_TMF_LUN_RESET 0x10
102 #define FCP_CMND_TMF_QUERY_ASYNC_EVENT 0x08
103 #define FCP_CMND_TMF_CLEAR_TASK_SET 0x04
104 #define FCP_CMND_TMF_ABORT_TASK_SET 0x02
105 #define FCP_CMND_TMF_QUERY_TASK_SET 0x01
110 * Source: X3.288-199x Generic Services 2 Rev 5.3 (FC-GS-2) Section 4.3.1
117 uint8_t ct_fcs_subtype;
119 uint8_t ct_reserved0;
120 uint16_t ct_cmd_resp;
121 uint16_t ct_bcnt_resid;
122 uint8_t ct_reserved1;
124 uint8_t ct_explanation;
127 #define CT_REVISION 1
128 #define CT_FC_TYPE_FC 0xFC
129 #define CT_FC_SUBTYPE_NS 0x02
132 * RFT_ID Requet CT_IU
134 * Source: NCITS xxx-200x Generic Services- 5 Rev 8.5 Section 5.2.5.30
138 uint8_t rftid_reserved;
139 uint8_t rftid_portid[3];
140 uint32_t rftid_fc4types[8];
144 * RSPN_ID Requet CT_IU
146 * Source: INCITS 463-2010 Generic Services 6 Section 5.2.5.32
150 uint8_t rspnid_reserved;
151 uint8_t rspnid_portid[3];
152 uint8_t rspnid_length;
153 uint8_t rspnid_name[0];
157 * RFF_ID Requet CT_IU
159 * Source: INCITS 463-2010 Generic Services 6 Section 5.2.5.34
163 uint8_t rffid_reserved;
164 uint8_t rffid_portid[3];
165 uint16_t rffid_reserved2;
166 uint8_t rffid_fc4features;
167 uint8_t rffid_fc4type;
171 * RSNN_NN Requet CT_IU
173 * Source: INCITS 463-2010 Generic Services 6 Section 5.2.5.35
177 uint8_t rsnnnn_nodename[8];
178 uint8_t rsnnnn_length;
179 uint8_t rsnnnn_name[0];
183 * FCP Response IU and bits of interest
184 * Source: NCITS T10, Project 1828D, Revision 02b (aka FCP4r02b)
187 uint8_t fcp_rsp_reserved[8];
188 uint16_t fcp_rsp_status_qualifier; /* SAM-5 Status Qualifier */
189 uint8_t fcp_rsp_bits;
190 uint8_t fcp_rsp_scsi_status; /* SAM-5 SCSI Status Byte */
191 uint32_t fcp_rsp_resid;
192 uint32_t fcp_rsp_snslen;
193 uint32_t fcp_rsp_rsplen;
195 * In the bytes that follow, it's going to be
196 * FCP RESPONSE INFO (max 8 bytes, possibly 0)
197 * FCP SENSE INFO (if any)
198 * FCP BIDIRECTIONAL READ RESID (if any)
200 uint8_t fcp_rsp_extra[0];
202 #define MIN_FCP_RESPONSE_SIZE 24
204 #define FCP_BIDIR_RSP 0x80 /* Bi-Directional response */
205 #define FCP_BIDIR_RESID_UNDERFLOW 0x40
206 #define FCP_BIDIR_RESID_OVERFLOW 0x20
207 #define FCP_CONF_REQ 0x10
208 #define FCP_RESID_UNDERFLOW 0x08
209 #define FCP_RESID_OVERFLOW 0x04
210 #define FCP_SNSLEN_VALID 0x02
211 #define FCP_RSPLEN_VALID 0x01
213 #define FCP_MAX_RSPLEN 0x08
215 * FCP Response Code Definitions
216 * Source: NCITS T10, Project 1144D, Revision 08 (aka FCP2r08)
218 #define FCP_RSPNS_CODE_OFFSET 3
220 #define FCP_RSPNS_TMF_DONE 0
221 #define FCP_RSPNS_DLBRSTX 1
222 #define FCP_RSPNS_BADCMND 2
223 #define FCP_RSPNS_EROFS 3
224 #define FCP_RSPNS_TMF_REJECT 4
225 #define FCP_RSPNS_TMF_FAILED 5
226 #define FCP_RSPNS_TMF_SUCCEEDED 8
227 #define FCP_RSPNS_TMF_INCORRECT_LUN 9
230 * R_CTL field definitions
232 * Bits 31-28 are ROUTING
233 * Bits 27-24 are INFORMATION
235 * These are nibble values, not bits
237 #define R_CTL_ROUTE_DATA 0x00
238 #define R_CTL_ROUTE_ELS 0x02
239 #define R_CTL_ROUTE_FC4_LINK 0x03
240 #define R_CTL_ROUTE_VDATA 0x04
241 #define R_CTL_ROUTE_EXENDED 0x05
242 #define R_CTL_ROUTE_BASIC 0x08
243 #define R_CTL_ROUTE_LINK 0x0c
244 #define R_CTL_ROUTE_EXT_ROUTING 0x0f
246 #define R_CTL_INFO_UNCATEGORIZED 0x00
247 #define R_CTL_INFO_SOLICITED_DATA 0x01
248 #define R_CTL_INFO_UNSOLICITED_CONTROL 0x02
249 #define R_CTL_INFO_SOLICITED_CONTROL 0x03
250 #define R_CTL_INFO_UNSOLICITED_DATA 0x04
251 #define R_CTL_INFO_DATA_DESCRIPTOR 0x05
252 #define R_CTL_INFO_UNSOLICITED_COMMAND 0x06
253 #define R_CTL_INFO_COMMAND_STATUS 0x07
255 #define MAKE_RCTL(a, b) (((a) << 4) | (b))
257 /* unconverted miscellany */
259 * Basic FC Link Service defines
261 /* #define ABTS MAKE_RCTL(R_CTL_ROUTE_BASIC, R_CTL_INFO_SOLICITED_DATA) */
262 #define BA_ACC MAKE_RCTL(R_CTL_ROUTE_BASIC, R_CTL_INFO_UNSOLICITED_DATA) /* of ABORT */
263 #define BA_RJT MAKE_RCTL(R_CTL_ROUTE_BASIC, R_CTL_INFO_DATA_DESCRIPTOR) /* of ABORT */
266 * Link Service Accept/Reject
268 #define LS_ACC 0x8002
269 #define LS_RJT 0x8001
272 * FC ELS Codes- bits 31-24 of the first payload word of an ELS frame.
287 * PRLI Word 0 definitions
288 * FPC4-r02b January, 2011
290 #define PRLI_WD0_TYPE_MASK 0xff000000
291 #define PRLI_WD0_TC_EXT_MASK 0x00ff0000
292 #define PRLI_WD0_EST_IMAGE_PAIR (1 << 13)
295 * PRLI Word 3 definitions
296 * FPC4-r02b January, 2011
298 #define PRLI_WD3_ENHANCED_DISCOVERY (1 << 11)
299 #define PRLI_WD3_REC_SUPPORT (1 << 10)
300 #define PRLI_WD3_TASK_RETRY_IDENTIFICATION_REQUESTED (1 << 9)
301 #define PRLI_WD3_RETRY (1 << 8)
302 #define PRLI_WD3_CONFIRMED_COMPLETION_ALLOWED (1 << 7)
303 #define PRLI_WD3_DATA_OVERLAY_ALLOWED (1 << 6)
304 #define PRLI_WD3_INITIATOR_FUNCTION (1 << 5)
305 #define PRLI_WD3_TARGET_FUNCTION (1 << 4)
306 #define PRLI_WD3_READ_FCP_XFER_RDY_DISABLED (1 << 1) /* definitely supposed to be set */
307 #define PRLI_WD3_WRITE_FCP_XFER_RDY_DISABLED (1 << 0)
314 #define FC4_IP 5 /* ISO/EEC 8802-2 LLC/SNAP */
315 #define FC4_SCSI 8 /* SCSI-3 via Fibre Channel Protocol (FCP) */
316 #define FC4_FC_SVC 0x20 /* Fibre Channel Services */
319 #define MSG_ABORT 0x06
321 #ifndef MSG_BUS_DEV_RESET
322 #define MSG_BUS_DEV_RESET 0x0c
324 #ifndef MSG_ABORT_TAG
325 #define MSG_ABORT_TAG 0x0d
327 #ifndef MSG_CLEAR_QUEUE
328 #define MSG_CLEAR_QUEUE 0x0e
330 #ifndef MSG_REL_RECOVERY
331 #define MSG_REL_RECOVERY 0x10
333 #ifndef MSG_TERM_IO_PROC
334 #define MSG_TERM_IO_PROC 0x11
336 #ifndef MSG_LUN_RESET
337 #define MSG_LUN_RESET 0x17
340 #endif /* _ISP_STDS_H */