Commit | Line | Data |
---|---|---|
f032c2f7 RL |
1 | /* |
2 | * Copyright(c) 2007 Intel Corporation. All rights reserved. | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or modify it | |
5 | * under the terms and conditions of the GNU General Public License, | |
6 | * version 2, as published by the Free Software Foundation. | |
7 | * | |
8 | * This program is distributed in the hope it will be useful, but WITHOUT | |
9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
11 | * more details. | |
12 | * | |
13 | * You should have received a copy of the GNU General Public License along with | |
14 | * this program; if not, write to the Free Software Foundation, Inc., | |
15 | * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. | |
16 | * | |
17 | * Maintained at www.Open-FCoE.org | |
18 | */ | |
19 | ||
20 | #ifndef _FC_FCP_H_ | |
21 | #define _FC_FCP_H_ | |
22 | ||
e35fa8c2 AG |
23 | #include <scsi/scsi.h> |
24 | ||
f032c2f7 RL |
25 | /* |
26 | * Fibre Channel Protocol for SCSI. | |
27 | * From T10 FCP-3, T10 project 1560-D Rev 4, Sept. 13, 2005. | |
28 | */ | |
29 | ||
30 | /* | |
31 | * fc/fs.h defines FC_TYPE_FCP. | |
32 | */ | |
33 | ||
34 | /* | |
35 | * Service parameter page parameters (word 3 bits) for Process Login. | |
36 | */ | |
37 | #define FCP_SPPF_TASK_RETRY_ID 0x0200 /* task retry ID requested */ | |
38 | #define FCP_SPPF_RETRY 0x0100 /* retry supported */ | |
39 | #define FCP_SPPF_CONF_COMPL 0x0080 /* confirmed completion allowed */ | |
40 | #define FCP_SPPF_OVLY_ALLOW 0x0040 /* data overlay allowed */ | |
41 | #define FCP_SPPF_INIT_FCN 0x0020 /* initiator function */ | |
42 | #define FCP_SPPF_TARG_FCN 0x0010 /* target function */ | |
43 | #define FCP_SPPF_RD_XRDY_DIS 0x0002 /* disable XFER_RDY for reads */ | |
44 | #define FCP_SPPF_WR_XRDY_DIS 0x0001 /* disable XFER_RDY for writes */ | |
45 | ||
46 | /* | |
47 | * FCP_CMND IU Payload. | |
48 | */ | |
49 | struct fcp_cmnd { | |
e35fa8c2 | 50 | struct scsi_lun fc_lun; /* logical unit number */ |
b595076a | 51 | __u8 fc_cmdref; /* command reference number */ |
f032c2f7 RL |
52 | __u8 fc_pri_ta; /* priority and task attribute */ |
53 | __u8 fc_tm_flags; /* task management flags */ | |
54 | __u8 fc_flags; /* additional len & flags */ | |
55 | __u8 fc_cdb[16]; /* base CDB */ | |
56 | __be32 fc_dl; /* data length (must follow fc_cdb) */ | |
57 | }; | |
58 | ||
59 | #define FCP_CMND_LEN 32 /* expected length of structure */ | |
60 | ||
61 | struct fcp_cmnd32 { | |
e35fa8c2 | 62 | struct scsi_lun fc_lun; /* logical unit number */ |
b595076a | 63 | __u8 fc_cmdref; /* command reference number */ |
f032c2f7 RL |
64 | __u8 fc_pri_ta; /* priority and task attribute */ |
65 | __u8 fc_tm_flags; /* task management flags */ | |
66 | __u8 fc_flags; /* additional len & flags */ | |
67 | __u8 fc_cdb[32]; /* base CDB */ | |
68 | __be32 fc_dl; /* data length (must follow fc_cdb) */ | |
69 | }; | |
70 | ||
71 | #define FCP_CMND32_LEN 48 /* expected length of structure */ | |
72 | #define FCP_CMND32_ADD_LEN (16 / 4) /* Additional cdb length */ | |
73 | ||
74 | /* | |
75 | * fc_pri_ta. | |
76 | */ | |
77 | #define FCP_PTA_SIMPLE 0 /* simple task attribute */ | |
78 | #define FCP_PTA_HEADQ 1 /* head of queue task attribute */ | |
79 | #define FCP_PTA_ORDERED 2 /* ordered task attribute */ | |
25985edc | 80 | #define FCP_PTA_ACA 4 /* auto. contingent allegiance */ |
4dc7ccf7 | 81 | #define FCP_PTA_MASK 7 /* mask for task attribute field */ |
f032c2f7 RL |
82 | #define FCP_PRI_SHIFT 3 /* priority field starts in bit 3 */ |
83 | #define FCP_PRI_RESVD_MASK 0x80 /* reserved bits in priority field */ | |
84 | ||
85 | /* | |
86 | * fc_tm_flags - task management flags field. | |
87 | */ | |
88 | #define FCP_TMF_CLR_ACA 0x40 /* clear ACA condition */ | |
0a55256d CS |
89 | #define FCP_TMF_TGT_RESET 0x20 /* target reset task management, |
90 | deprecated as of FCP-3 */ | |
f032c2f7 RL |
91 | #define FCP_TMF_LUN_RESET 0x10 /* logical unit reset task management */ |
92 | #define FCP_TMF_CLR_TASK_SET 0x04 /* clear task set */ | |
93 | #define FCP_TMF_ABT_TASK_SET 0x02 /* abort task set */ | |
94 | ||
95 | /* | |
96 | * fc_flags. | |
97 | * Bits 7:2 are the additional FCP_CDB length / 4. | |
98 | */ | |
99 | #define FCP_CFL_LEN_MASK 0xfc /* mask for additional length */ | |
100 | #define FCP_CFL_LEN_SHIFT 2 /* shift bits for additional length */ | |
101 | #define FCP_CFL_RDDATA 0x02 /* read data */ | |
102 | #define FCP_CFL_WRDATA 0x01 /* write data */ | |
103 | ||
104 | /* | |
105 | * FCP_TXRDY IU - transfer ready payload. | |
106 | */ | |
107 | struct fcp_txrdy { | |
108 | __be32 ft_data_ro; /* data relative offset */ | |
109 | __be32 ft_burst_len; /* burst length */ | |
110 | __u8 _ft_resvd[4]; /* reserved */ | |
111 | }; | |
112 | ||
113 | #define FCP_TXRDY_LEN 12 /* expected length of structure */ | |
114 | ||
115 | /* | |
116 | * FCP_RESP IU - response payload. | |
117 | * | |
118 | * The response payload comes in three parts: the flags/status, the | |
119 | * sense/response lengths and the sense data/response info section. | |
120 | * | |
121 | * From FCP3r04, note 6 of section 9.5.13: | |
122 | * | |
123 | * Some early implementations presented the FCP_RSP IU without the FCP_RESID, | |
124 | * FCP_SNS_LEN, and FCP_RSP_LEN fields if the FCP_RESID_UNDER, FCP_RESID_OVER, | |
125 | * FCP_SNS_LEN_VALID, and FCP_RSP_LEN_VALID bits were all set to zero. This | |
126 | * non-standard behavior should be tolerated. | |
127 | * | |
128 | * All response frames will always contain the fcp_resp template. Some | |
129 | * will also include the fcp_resp_len template. | |
3b64b188 YZ |
130 | * |
131 | * From Table 23, the FCP_RSP_INFO can either be 4 bytes or 8 bytes, both | |
132 | * are valid length. | |
f032c2f7 RL |
133 | */ |
134 | struct fcp_resp { | |
135 | __u8 _fr_resvd[8]; /* reserved */ | |
136 | __be16 fr_retry_delay; /* retry delay timer */ | |
137 | __u8 fr_flags; /* flags */ | |
138 | __u8 fr_status; /* SCSI status code */ | |
139 | }; | |
140 | ||
141 | #define FCP_RESP_LEN 12 /* expected length of structure */ | |
142 | ||
143 | struct fcp_resp_ext { | |
144 | __be32 fr_resid; /* Residual value */ | |
145 | __be32 fr_sns_len; /* SCSI Sense length */ | |
146 | __be32 fr_rsp_len; /* Response Info length */ | |
147 | ||
148 | /* | |
149 | * Optionally followed by RSP info and/or SNS info and/or | |
150 | * bidirectional read residual length, if any. | |
151 | */ | |
152 | }; | |
153 | ||
154 | #define FCP_RESP_EXT_LEN 12 /* expected length of the structure */ | |
155 | ||
156 | struct fcp_resp_rsp_info { | |
157 | __u8 _fr_resvd[3]; /* reserved */ | |
158 | __u8 rsp_code; /* Response Info Code */ | |
159 | __u8 _fr_resvd2[4]; /* reserved */ | |
160 | }; | |
161 | ||
3b64b188 YZ |
162 | #define FCP_RESP_RSP_INFO_LEN4 4 /* without reserved field */ |
163 | #define FCP_RESP_RSP_INFO_LEN8 8 /* with reserved field */ | |
164 | ||
f032c2f7 RL |
165 | struct fcp_resp_with_ext { |
166 | struct fcp_resp resp; | |
167 | struct fcp_resp_ext ext; | |
168 | }; | |
169 | ||
170 | #define FCP_RESP_WITH_EXT (FCP_RESP_LEN + FCP_RESP_EXT_LEN) | |
171 | ||
172 | /* | |
173 | * fr_flags. | |
174 | */ | |
175 | #define FCP_BIDI_RSP 0x80 /* bidirectional read response */ | |
176 | #define FCP_BIDI_READ_UNDER 0x40 /* bidir. read less than requested */ | |
177 | #define FCP_BIDI_READ_OVER 0x20 /* DL insufficient for full transfer */ | |
178 | #define FCP_CONF_REQ 0x10 /* confirmation requested */ | |
179 | #define FCP_RESID_UNDER 0x08 /* transfer shorter than expected */ | |
180 | #define FCP_RESID_OVER 0x04 /* DL insufficient for full transfer */ | |
181 | #define FCP_SNS_LEN_VAL 0x02 /* SNS_LEN field is valid */ | |
182 | #define FCP_RSP_LEN_VAL 0x01 /* RSP_LEN field is valid */ | |
183 | ||
184 | /* | |
185 | * rsp_codes | |
186 | */ | |
187 | enum fcp_resp_rsp_codes { | |
188 | FCP_TMF_CMPL = 0, | |
189 | FCP_DATA_LEN_INVALID = 1, | |
190 | FCP_CMND_FIELDS_INVALID = 2, | |
191 | FCP_DATA_PARAM_MISMATCH = 3, | |
192 | FCP_TMF_REJECTED = 4, | |
193 | FCP_TMF_FAILED = 5, | |
194 | FCP_TMF_INVALID_LUN = 9, | |
195 | }; | |
196 | ||
197 | /* | |
198 | * FCP SRR Link Service request - Sequence Retransmission Request. | |
199 | */ | |
200 | struct fcp_srr { | |
201 | __u8 srr_op; /* opcode ELS_SRR */ | |
202 | __u8 srr_resvd[3]; /* opcode / reserved - must be zero */ | |
203 | __be16 srr_ox_id; /* OX_ID of failed command */ | |
204 | __be16 srr_rx_id; /* RX_ID of failed command */ | |
205 | __be32 srr_rel_off; /* relative offset */ | |
206 | __u8 srr_r_ctl; /* r_ctl for the information unit */ | |
207 | __u8 srr_resvd2[3]; /* reserved */ | |
208 | }; | |
209 | ||
ab593b18 JE |
210 | /* |
211 | * Feature bits in name server FC-4 Features object. | |
212 | */ | |
213 | #define FCP_FEAT_TARG (1 << 0) /* target function supported */ | |
214 | #define FCP_FEAT_INIT (1 << 1) /* initiator function supported */ | |
215 | ||
f032c2f7 | 216 | #endif /* _FC_FCP_H_ */ |