Commit | Line | Data |
---|---|---|
2d70c103 NB |
1 | /* |
2 | * Copyright (C) 2004 - 2010 Vladislav Bolkhovitin <vst@vlnb.net> | |
3 | * Copyright (C) 2004 - 2005 Leonid Stoljar | |
4 | * Copyright (C) 2006 Nathaniel Clark <nate@misrule.us> | |
5 | * Copyright (C) 2007 - 2010 ID7 Ltd. | |
6 | * | |
7 | * Forward port and refactoring to modern qla2xxx and target/configfs | |
8 | * | |
9 | * Copyright (C) 2010-2011 Nicholas A. Bellinger <nab@kernel.org> | |
10 | * | |
11 | * Additional file for the target driver support. | |
12 | * | |
13 | * This program is free software; you can redistribute it and/or | |
14 | * modify it under the terms of the GNU General Public License | |
15 | * as published by the Free Software Foundation; either version 2 | |
16 | * of the License, or (at your option) any later version. | |
17 | * | |
18 | * This program is distributed in the hope that it will be useful, | |
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
21 | * GNU General Public License for more details. | |
22 | */ | |
23 | /* | |
24 | * This is the global def file that is useful for including from the | |
25 | * target portion. | |
26 | */ | |
27 | ||
28 | #ifndef __QLA_TARGET_H | |
29 | #define __QLA_TARGET_H | |
30 | ||
31 | #include "qla_def.h" | |
32 | ||
33 | /* | |
34 | * Must be changed on any change in any initiator visible interfaces or | |
35 | * data in the target add-on | |
36 | */ | |
37 | #define QLA2XXX_TARGET_MAGIC 269 | |
38 | ||
39 | /* | |
40 | * Must be changed on any change in any target visible interfaces or | |
41 | * data in the initiator | |
42 | */ | |
43 | #define QLA2XXX_INITIATOR_MAGIC 57222 | |
44 | ||
45 | #define QLA2XXX_INI_MODE_STR_EXCLUSIVE "exclusive" | |
46 | #define QLA2XXX_INI_MODE_STR_DISABLED "disabled" | |
47 | #define QLA2XXX_INI_MODE_STR_ENABLED "enabled" | |
ead03855 | 48 | #define QLA2XXX_INI_MODE_STR_DUAL "dual" |
2d70c103 NB |
49 | |
50 | #define QLA2XXX_INI_MODE_EXCLUSIVE 0 | |
51 | #define QLA2XXX_INI_MODE_DISABLED 1 | |
52 | #define QLA2XXX_INI_MODE_ENABLED 2 | |
ead03855 | 53 | #define QLA2XXX_INI_MODE_DUAL 3 |
2d70c103 NB |
54 | |
55 | #define QLA2XXX_COMMAND_COUNT_INIT 250 | |
56 | #define QLA2XXX_IMMED_NOTIFY_COUNT_INIT 250 | |
57 | ||
58 | /* | |
59 | * Used to mark which completion handles (for RIO Status's) are for CTIO's | |
60 | * vs. regular (non-target) info. This is checked for in | |
61 | * qla2x00_process_response_queue() to see if a handle coming back in a | |
62 | * multi-complete should come to the tgt driver or be handled there by qla2xxx | |
63 | */ | |
64 | #define CTIO_COMPLETION_HANDLE_MARK BIT_29 | |
8d93f550 CD |
65 | #if (CTIO_COMPLETION_HANDLE_MARK <= DEFAULT_OUTSTANDING_COMMANDS) |
66 | #error "CTIO_COMPLETION_HANDLE_MARK not larger than " | |
67 | "DEFAULT_OUTSTANDING_COMMANDS" | |
2d70c103 NB |
68 | #endif |
69 | #define HANDLE_IS_CTIO_COMP(h) (h & CTIO_COMPLETION_HANDLE_MARK) | |
70 | ||
71 | /* Used to mark CTIO as intermediate */ | |
72 | #define CTIO_INTERMEDIATE_HANDLE_MARK BIT_30 | |
c5419e26 QT |
73 | #define QLA_TGT_NULL_HANDLE 0 |
74 | ||
75 | #define QLA_TGT_HANDLE_MASK 0xF0000000 | |
82de802a | 76 | #define QLA_QPID_HANDLE_MASK 0x00FF0000 /* qpair id mask */ |
c5419e26 QT |
77 | #define QLA_CMD_HANDLE_MASK 0x0000FFFF |
78 | #define QLA_TGT_SKIP_HANDLE (0xFFFFFFFF & ~QLA_TGT_HANDLE_MASK) | |
79 | ||
80 | #define QLA_QPID_HANDLE_SHIFT 16 | |
81 | #define GET_QID(_h) ((_h & QLA_QPID_HANDLE_MASK) >> QLA_QPID_HANDLE_SHIFT) | |
82 | ||
2d70c103 NB |
83 | |
84 | #ifndef OF_SS_MODE_0 | |
85 | /* | |
86 | * ISP target entries - Flags bit definitions. | |
87 | */ | |
88 | #define OF_SS_MODE_0 0 | |
89 | #define OF_SS_MODE_1 1 | |
90 | #define OF_SS_MODE_2 2 | |
91 | #define OF_SS_MODE_3 3 | |
92 | ||
93 | #define OF_EXPL_CONF BIT_5 /* Explicit Confirmation Requested */ | |
94 | #define OF_DATA_IN BIT_6 /* Data in to initiator */ | |
95 | /* (data from target to initiator) */ | |
96 | #define OF_DATA_OUT BIT_7 /* Data out from initiator */ | |
97 | /* (data from initiator to target) */ | |
98 | #define OF_NO_DATA (BIT_7 | BIT_6) | |
99 | #define OF_INC_RC BIT_8 /* Increment command resource count */ | |
100 | #define OF_FAST_POST BIT_9 /* Enable mailbox fast posting. */ | |
101 | #define OF_CONF_REQ BIT_13 /* Confirmation Requested */ | |
102 | #define OF_TERM_EXCH BIT_14 /* Terminate exchange */ | |
103 | #define OF_SSTS BIT_15 /* Send SCSI status */ | |
104 | #endif | |
105 | ||
106 | #ifndef QLA_TGT_DATASEGS_PER_CMD32 | |
107 | #define QLA_TGT_DATASEGS_PER_CMD32 3 | |
108 | #define QLA_TGT_DATASEGS_PER_CONT32 7 | |
109 | #define QLA_TGT_MAX_SG32(ql) \ | |
110 | (((ql) > 0) ? (QLA_TGT_DATASEGS_PER_CMD32 + \ | |
111 | QLA_TGT_DATASEGS_PER_CONT32*((ql) - 1)) : 0) | |
112 | ||
113 | #define QLA_TGT_DATASEGS_PER_CMD64 2 | |
114 | #define QLA_TGT_DATASEGS_PER_CONT64 5 | |
115 | #define QLA_TGT_MAX_SG64(ql) \ | |
116 | (((ql) > 0) ? (QLA_TGT_DATASEGS_PER_CMD64 + \ | |
117 | QLA_TGT_DATASEGS_PER_CONT64*((ql) - 1)) : 0) | |
118 | #endif | |
119 | ||
120 | #ifndef QLA_TGT_DATASEGS_PER_CMD_24XX | |
121 | #define QLA_TGT_DATASEGS_PER_CMD_24XX 1 | |
122 | #define QLA_TGT_DATASEGS_PER_CONT_24XX 5 | |
123 | #define QLA_TGT_MAX_SG_24XX(ql) \ | |
124 | (min(1270, ((ql) > 0) ? (QLA_TGT_DATASEGS_PER_CMD_24XX + \ | |
125 | QLA_TGT_DATASEGS_PER_CONT_24XX*((ql) - 1)) : 0)) | |
126 | #endif | |
127 | #endif | |
128 | ||
129 | #define GET_TARGET_ID(ha, iocb) ((HAS_EXTENDED_IDS(ha)) \ | |
130 | ? le16_to_cpu((iocb)->u.isp2x.target.extended) \ | |
131 | : (uint16_t)(iocb)->u.isp2x.target.id.standard) | |
132 | ||
2d70c103 NB |
133 | #ifndef NOTIFY_ACK_TYPE |
134 | #define NOTIFY_ACK_TYPE 0x0E /* Notify acknowledge entry. */ | |
135 | /* | |
136 | * ISP queue - notify acknowledge entry structure definition. | |
137 | * This is sent to the ISP from the target driver. | |
138 | */ | |
139 | struct nack_to_isp { | |
140 | uint8_t entry_type; /* Entry type. */ | |
141 | uint8_t entry_count; /* Entry count. */ | |
142 | uint8_t sys_define; /* System defined. */ | |
143 | uint8_t entry_status; /* Entry Status. */ | |
144 | union { | |
145 | struct { | |
146 | uint32_t sys_define_2; /* System defined. */ | |
147 | target_id_t target; | |
148 | uint8_t target_id; | |
149 | uint8_t reserved_1; | |
150 | uint16_t flags; | |
151 | uint16_t resp_code; | |
152 | uint16_t status; | |
153 | uint16_t task_flags; | |
154 | uint16_t seq_id; | |
155 | uint16_t srr_rx_id; | |
156 | uint32_t srr_rel_offs; | |
157 | uint16_t srr_ui; | |
158 | uint16_t srr_flags; | |
159 | uint16_t srr_reject_code; | |
160 | uint8_t srr_reject_vendor_uniq; | |
161 | uint8_t srr_reject_code_expl; | |
162 | uint8_t reserved_2[24]; | |
163 | } isp2x; | |
164 | struct { | |
165 | uint32_t handle; | |
166 | uint16_t nport_handle; | |
167 | uint16_t reserved_1; | |
168 | uint16_t flags; | |
169 | uint16_t srr_rx_id; | |
170 | uint16_t status; | |
171 | uint8_t status_subcode; | |
aa230bc5 | 172 | uint8_t fw_handle; |
2d70c103 NB |
173 | uint32_t exchange_address; |
174 | uint32_t srr_rel_offs; | |
175 | uint16_t srr_ui; | |
176 | uint16_t srr_flags; | |
177 | uint8_t reserved_4[19]; | |
178 | uint8_t vp_index; | |
179 | uint8_t srr_reject_vendor_uniq; | |
180 | uint8_t srr_reject_code_expl; | |
181 | uint8_t srr_reject_code; | |
182 | uint8_t reserved_5[5]; | |
183 | } isp24; | |
184 | } u; | |
185 | uint8_t reserved[2]; | |
186 | uint16_t ox_id; | |
187 | } __packed; | |
a6ca8878 | 188 | #define NOTIFY_ACK_FLAGS_TERMINATE BIT_3 |
2d70c103 NB |
189 | #define NOTIFY_ACK_SRR_FLAGS_ACCEPT 0 |
190 | #define NOTIFY_ACK_SRR_FLAGS_REJECT 1 | |
191 | ||
192 | #define NOTIFY_ACK_SRR_REJECT_REASON_UNABLE_TO_PERFORM 0x9 | |
193 | ||
194 | #define NOTIFY_ACK_SRR_FLAGS_REJECT_EXPL_NO_EXPL 0 | |
195 | #define NOTIFY_ACK_SRR_FLAGS_REJECT_EXPL_UNABLE_TO_SUPPLY_DATA 0x2a | |
196 | ||
197 | #define NOTIFY_ACK_SUCCESS 0x01 | |
198 | #endif | |
199 | ||
200 | #ifndef ACCEPT_TGT_IO_TYPE | |
201 | #define ACCEPT_TGT_IO_TYPE 0x16 /* Accept target I/O entry. */ | |
202 | #endif | |
203 | ||
204 | #ifndef CONTINUE_TGT_IO_TYPE | |
205 | #define CONTINUE_TGT_IO_TYPE 0x17 | |
206 | /* | |
207 | * ISP queue - Continue Target I/O (CTIO) entry for status mode 0 structure. | |
208 | * This structure is sent to the ISP 2xxx from target driver. | |
209 | */ | |
210 | struct ctio_to_2xxx { | |
211 | uint8_t entry_type; /* Entry type. */ | |
212 | uint8_t entry_count; /* Entry count. */ | |
213 | uint8_t sys_define; /* System defined. */ | |
214 | uint8_t entry_status; /* Entry Status. */ | |
215 | uint32_t handle; /* System defined handle */ | |
216 | target_id_t target; | |
217 | uint16_t rx_id; | |
218 | uint16_t flags; | |
219 | uint16_t status; | |
220 | uint16_t timeout; /* 0 = 30 seconds, 0xFFFF = disable */ | |
221 | uint16_t dseg_count; /* Data segment count. */ | |
222 | uint32_t relative_offset; | |
223 | uint32_t residual; | |
224 | uint16_t reserved_1[3]; | |
225 | uint16_t scsi_status; | |
226 | uint32_t transfer_length; | |
227 | uint32_t dseg_0_address; /* Data segment 0 address. */ | |
228 | uint32_t dseg_0_length; /* Data segment 0 length. */ | |
229 | uint32_t dseg_1_address; /* Data segment 1 address. */ | |
230 | uint32_t dseg_1_length; /* Data segment 1 length. */ | |
231 | uint32_t dseg_2_address; /* Data segment 2 address. */ | |
232 | uint32_t dseg_2_length; /* Data segment 2 length. */ | |
233 | } __packed; | |
234 | #define ATIO_PATH_INVALID 0x07 | |
235 | #define ATIO_CANT_PROV_CAP 0x16 | |
236 | #define ATIO_CDB_VALID 0x3D | |
237 | ||
238 | #define ATIO_EXEC_READ BIT_1 | |
239 | #define ATIO_EXEC_WRITE BIT_0 | |
240 | #endif | |
241 | ||
242 | #ifndef CTIO_A64_TYPE | |
243 | #define CTIO_A64_TYPE 0x1F | |
244 | #define CTIO_SUCCESS 0x01 | |
245 | #define CTIO_ABORTED 0x02 | |
246 | #define CTIO_INVALID_RX_ID 0x08 | |
247 | #define CTIO_TIMEOUT 0x0B | |
f83adb61 | 248 | #define CTIO_DIF_ERROR 0x0C /* DIF error detected */ |
2d70c103 NB |
249 | #define CTIO_LIP_RESET 0x0E |
250 | #define CTIO_TARGET_RESET 0x17 | |
251 | #define CTIO_PORT_UNAVAILABLE 0x28 | |
252 | #define CTIO_PORT_LOGGED_OUT 0x29 | |
253 | #define CTIO_PORT_CONF_CHANGED 0x2A | |
254 | #define CTIO_SRR_RECEIVED 0x45 | |
255 | #endif | |
256 | ||
257 | #ifndef CTIO_RET_TYPE | |
258 | #define CTIO_RET_TYPE 0x17 /* CTIO return entry */ | |
259 | #define ATIO_TYPE7 0x06 /* Accept target I/O entry for 24xx */ | |
260 | ||
261 | struct fcp_hdr { | |
262 | uint8_t r_ctl; | |
263 | uint8_t d_id[3]; | |
264 | uint8_t cs_ctl; | |
265 | uint8_t s_id[3]; | |
266 | uint8_t type; | |
267 | uint8_t f_ctl[3]; | |
268 | uint8_t seq_id; | |
269 | uint8_t df_ctl; | |
270 | uint16_t seq_cnt; | |
c7ee3bd4 | 271 | __be16 ox_id; |
2d70c103 NB |
272 | uint16_t rx_id; |
273 | uint32_t parameter; | |
274 | } __packed; | |
275 | ||
276 | struct fcp_hdr_le { | |
277 | uint8_t d_id[3]; | |
278 | uint8_t r_ctl; | |
279 | uint8_t s_id[3]; | |
280 | uint8_t cs_ctl; | |
281 | uint8_t f_ctl[3]; | |
282 | uint8_t type; | |
283 | uint16_t seq_cnt; | |
284 | uint8_t df_ctl; | |
285 | uint8_t seq_id; | |
286 | uint16_t rx_id; | |
287 | uint16_t ox_id; | |
288 | uint32_t parameter; | |
289 | } __packed; | |
290 | ||
291 | #define F_CTL_EXCH_CONTEXT_RESP BIT_23 | |
292 | #define F_CTL_SEQ_CONTEXT_RESIP BIT_22 | |
293 | #define F_CTL_LAST_SEQ BIT_20 | |
294 | #define F_CTL_END_SEQ BIT_19 | |
295 | #define F_CTL_SEQ_INITIATIVE BIT_16 | |
296 | ||
297 | #define R_CTL_BASIC_LINK_SERV 0x80 | |
298 | #define R_CTL_B_ACC 0x4 | |
299 | #define R_CTL_B_RJT 0x5 | |
300 | ||
301 | struct atio7_fcp_cmnd { | |
302 | uint64_t lun; | |
303 | uint8_t cmnd_ref; | |
304 | uint8_t task_attr:3; | |
305 | uint8_t reserved:5; | |
306 | uint8_t task_mgmt_flags; | |
307 | #define FCP_CMND_TASK_MGMT_CLEAR_ACA 6 | |
308 | #define FCP_CMND_TASK_MGMT_TARGET_RESET 5 | |
309 | #define FCP_CMND_TASK_MGMT_LU_RESET 4 | |
310 | #define FCP_CMND_TASK_MGMT_CLEAR_TASK_SET 2 | |
311 | #define FCP_CMND_TASK_MGMT_ABORT_TASK_SET 1 | |
312 | uint8_t wrdata:1; | |
313 | uint8_t rddata:1; | |
314 | uint8_t add_cdb_len:6; | |
315 | uint8_t cdb[16]; | |
316 | /* | |
317 | * add_cdb is optional and can absent from struct atio7_fcp_cmnd. Size 4 | |
318 | * only to make sizeof(struct atio7_fcp_cmnd) be as expected by | |
319 | * BUILD_BUG_ON in qlt_init(). | |
320 | */ | |
321 | uint8_t add_cdb[4]; | |
322 | /* uint32_t data_length; */ | |
323 | } __packed; | |
324 | ||
325 | /* | |
326 | * ISP queue - Accept Target I/O (ATIO) type entry IOCB structure. | |
327 | * This is sent from the ISP to the target driver. | |
328 | */ | |
329 | struct atio_from_isp { | |
330 | union { | |
331 | struct { | |
332 | uint16_t entry_hdr; | |
333 | uint8_t sys_define; /* System defined. */ | |
334 | uint8_t entry_status; /* Entry Status. */ | |
335 | uint32_t sys_define_2; /* System defined. */ | |
336 | target_id_t target; | |
337 | uint16_t rx_id; | |
338 | uint16_t flags; | |
339 | uint16_t status; | |
340 | uint8_t command_ref; | |
341 | uint8_t task_codes; | |
342 | uint8_t task_flags; | |
343 | uint8_t execution_codes; | |
344 | uint8_t cdb[MAX_CMDSZ]; | |
345 | uint32_t data_length; | |
346 | uint16_t lun; | |
347 | uint8_t initiator_port_name[WWN_SIZE]; /* on qla23xx */ | |
348 | uint16_t reserved_32[6]; | |
349 | uint16_t ox_id; | |
350 | } isp2x; | |
351 | struct { | |
352 | uint16_t entry_hdr; | |
353 | uint8_t fcp_cmnd_len_low; | |
354 | uint8_t fcp_cmnd_len_high:4; | |
355 | uint8_t attr:4; | |
356 | uint32_t exchange_addr; | |
357 | #define ATIO_EXCHANGE_ADDRESS_UNKNOWN 0xFFFFFFFF | |
358 | struct fcp_hdr fcp_hdr; | |
359 | struct atio7_fcp_cmnd fcp_cmnd; | |
360 | } isp24; | |
361 | struct { | |
362 | uint8_t entry_type; /* Entry type. */ | |
363 | uint8_t entry_count; /* Entry count. */ | |
5f35509d QT |
364 | __le16 attr_n_length; |
365 | #define FCP_CMD_LENGTH_MASK 0x0fff | |
366 | #define FCP_CMD_LENGTH_MIN 0x38 | |
367 | uint8_t data[56]; | |
2d70c103 NB |
368 | uint32_t signature; |
369 | #define ATIO_PROCESSED 0xDEADDEAD /* Signature */ | |
370 | } raw; | |
371 | } u; | |
372 | } __packed; | |
373 | ||
5f35509d QT |
374 | static inline int fcpcmd_is_corrupted(struct atio *atio) |
375 | { | |
376 | if (atio->entry_type == ATIO_TYPE7 && | |
377 | (le16_to_cpu(atio->attr_n_length & FCP_CMD_LENGTH_MASK) < | |
378 | FCP_CMD_LENGTH_MIN)) | |
379 | return 1; | |
380 | else | |
381 | return 0; | |
382 | } | |
383 | ||
384 | /* adjust corrupted atio so we won't trip over the same entry again. */ | |
385 | static inline void adjust_corrupted_atio(struct atio_from_isp *atio) | |
386 | { | |
387 | atio->u.raw.attr_n_length = cpu_to_le16(FCP_CMD_LENGTH_MIN); | |
388 | atio->u.isp24.fcp_cmnd.add_cdb_len = 0; | |
389 | } | |
390 | ||
be25152c QT |
391 | static inline int get_datalen_for_atio(struct atio_from_isp *atio) |
392 | { | |
393 | int len = atio->u.isp24.fcp_cmnd.add_cdb_len; | |
394 | ||
395 | return (be32_to_cpu(get_unaligned((uint32_t *) | |
396 | &atio->u.isp24.fcp_cmnd.add_cdb[len * 4]))); | |
397 | } | |
398 | ||
2d70c103 NB |
399 | #define CTIO_TYPE7 0x12 /* Continue target I/O entry (for 24xx) */ |
400 | ||
401 | /* | |
402 | * ISP queue - Continue Target I/O (ATIO) type 7 entry (for 24xx) structure. | |
403 | * This structure is sent to the ISP 24xx from the target driver. | |
404 | */ | |
405 | ||
406 | struct ctio7_to_24xx { | |
407 | uint8_t entry_type; /* Entry type. */ | |
408 | uint8_t entry_count; /* Entry count. */ | |
409 | uint8_t sys_define; /* System defined. */ | |
410 | uint8_t entry_status; /* Entry Status. */ | |
411 | uint32_t handle; /* System defined handle */ | |
412 | uint16_t nport_handle; | |
413 | #define CTIO7_NHANDLE_UNRECOGNIZED 0xFFFF | |
414 | uint16_t timeout; | |
415 | uint16_t dseg_count; /* Data segment count. */ | |
416 | uint8_t vp_index; | |
417 | uint8_t add_flags; | |
418 | uint8_t initiator_id[3]; | |
419 | uint8_t reserved; | |
420 | uint32_t exchange_addr; | |
421 | union { | |
422 | struct { | |
423 | uint16_t reserved1; | |
c7ee3bd4 | 424 | __le16 flags; |
2d70c103 | 425 | uint32_t residual; |
33a5fcee | 426 | __le16 ox_id; |
2d70c103 NB |
427 | uint16_t scsi_status; |
428 | uint32_t relative_offset; | |
429 | uint32_t reserved2; | |
430 | uint32_t transfer_length; | |
431 | uint32_t reserved3; | |
432 | /* Data segment 0 address. */ | |
433 | uint32_t dseg_0_address[2]; | |
434 | /* Data segment 0 length. */ | |
435 | uint32_t dseg_0_length; | |
436 | } status0; | |
437 | struct { | |
438 | uint16_t sense_length; | |
f7e761f5 | 439 | __le16 flags; |
2d70c103 | 440 | uint32_t residual; |
33a5fcee | 441 | __le16 ox_id; |
2d70c103 NB |
442 | uint16_t scsi_status; |
443 | uint16_t response_len; | |
444 | uint16_t reserved; | |
445 | uint8_t sense_data[24]; | |
446 | } status1; | |
447 | } u; | |
448 | } __packed; | |
449 | ||
450 | /* | |
451 | * ISP queue - CTIO type 7 from ISP 24xx to target driver | |
452 | * returned entry structure. | |
453 | */ | |
454 | struct ctio7_from_24xx { | |
455 | uint8_t entry_type; /* Entry type. */ | |
456 | uint8_t entry_count; /* Entry count. */ | |
457 | uint8_t sys_define; /* System defined. */ | |
458 | uint8_t entry_status; /* Entry Status. */ | |
459 | uint32_t handle; /* System defined handle */ | |
460 | uint16_t status; | |
461 | uint16_t timeout; | |
462 | uint16_t dseg_count; /* Data segment count. */ | |
463 | uint8_t vp_index; | |
464 | uint8_t reserved1[5]; | |
465 | uint32_t exchange_address; | |
466 | uint16_t reserved2; | |
467 | uint16_t flags; | |
468 | uint32_t residual; | |
469 | uint16_t ox_id; | |
470 | uint16_t reserved3; | |
471 | uint32_t relative_offset; | |
472 | uint8_t reserved4[24]; | |
473 | } __packed; | |
474 | ||
475 | /* CTIO7 flags values */ | |
476 | #define CTIO7_FLAGS_SEND_STATUS BIT_15 | |
477 | #define CTIO7_FLAGS_TERMINATE BIT_14 | |
478 | #define CTIO7_FLAGS_CONFORM_REQ BIT_13 | |
479 | #define CTIO7_FLAGS_DONT_RET_CTIO BIT_8 | |
480 | #define CTIO7_FLAGS_STATUS_MODE_0 0 | |
481 | #define CTIO7_FLAGS_STATUS_MODE_1 BIT_6 | |
f83adb61 | 482 | #define CTIO7_FLAGS_STATUS_MODE_2 BIT_7 |
2d70c103 NB |
483 | #define CTIO7_FLAGS_EXPLICIT_CONFORM BIT_5 |
484 | #define CTIO7_FLAGS_CONFIRM_SATISF BIT_4 | |
485 | #define CTIO7_FLAGS_DSD_PTR BIT_2 | |
f83adb61 QT |
486 | #define CTIO7_FLAGS_DATA_IN BIT_1 /* data to initiator */ |
487 | #define CTIO7_FLAGS_DATA_OUT BIT_0 /* data from initiator */ | |
2d70c103 NB |
488 | |
489 | #define ELS_PLOGI 0x3 | |
490 | #define ELS_FLOGI 0x4 | |
491 | #define ELS_LOGO 0x5 | |
492 | #define ELS_PRLI 0x20 | |
493 | #define ELS_PRLO 0x21 | |
494 | #define ELS_TPRLO 0x24 | |
495 | #define ELS_PDISC 0x50 | |
496 | #define ELS_ADISC 0x52 | |
497 | ||
f83adb61 QT |
498 | /* |
499 | *CTIO Type CRC_2 IOCB | |
500 | */ | |
501 | struct ctio_crc2_to_fw { | |
502 | uint8_t entry_type; /* Entry type. */ | |
503 | #define CTIO_CRC2 0x7A | |
504 | uint8_t entry_count; /* Entry count. */ | |
505 | uint8_t sys_define; /* System defined. */ | |
506 | uint8_t entry_status; /* Entry Status. */ | |
507 | ||
508 | uint32_t handle; /* System handle. */ | |
509 | uint16_t nport_handle; /* N_PORT handle. */ | |
c7ee3bd4 | 510 | __le16 timeout; /* Command timeout. */ |
f83adb61 QT |
511 | |
512 | uint16_t dseg_count; /* Data segment count. */ | |
513 | uint8_t vp_index; | |
514 | uint8_t add_flags; /* additional flags */ | |
515 | #define CTIO_CRC2_AF_DIF_DSD_ENA BIT_3 | |
516 | ||
517 | uint8_t initiator_id[3]; /* initiator ID */ | |
518 | uint8_t reserved1; | |
519 | uint32_t exchange_addr; /* rcv exchange address */ | |
520 | uint16_t reserved2; | |
c7ee3bd4 | 521 | __le16 flags; /* refer to CTIO7 flags values */ |
f83adb61 | 522 | uint32_t residual; |
c7ee3bd4 | 523 | __le16 ox_id; |
f83adb61 | 524 | uint16_t scsi_status; |
c7ee3bd4 | 525 | __le32 relative_offset; |
f83adb61 | 526 | uint32_t reserved5; |
c7ee3bd4 | 527 | __le32 transfer_length; /* total fc transfer length */ |
f83adb61 | 528 | uint32_t reserved6; |
c7ee3bd4 | 529 | __le32 crc_context_address[2];/* Data segment address. */ |
f83adb61 QT |
530 | uint16_t crc_context_len; /* Data segment length. */ |
531 | uint16_t reserved_1; /* MUST be set to 0. */ | |
532 | } __packed; | |
533 | ||
534 | /* CTIO Type CRC_x Status IOCB */ | |
535 | struct ctio_crc_from_fw { | |
536 | uint8_t entry_type; /* Entry type. */ | |
537 | uint8_t entry_count; /* Entry count. */ | |
538 | uint8_t sys_define; /* System defined. */ | |
539 | uint8_t entry_status; /* Entry Status. */ | |
540 | ||
541 | uint32_t handle; /* System handle. */ | |
542 | uint16_t status; | |
543 | uint16_t timeout; /* Command timeout. */ | |
544 | uint16_t dseg_count; /* Data segment count. */ | |
545 | uint32_t reserved1; | |
546 | uint16_t state_flags; | |
547 | #define CTIO_CRC_SF_DIF_CHOPPED BIT_4 | |
548 | ||
549 | uint32_t exchange_address; /* rcv exchange address */ | |
550 | uint16_t reserved2; | |
551 | uint16_t flags; | |
552 | uint32_t resid_xfer_length; | |
553 | uint16_t ox_id; | |
554 | uint8_t reserved3[12]; | |
555 | uint16_t runt_guard; /* reported runt blk guard */ | |
556 | uint8_t actual_dif[8]; | |
557 | uint8_t expected_dif[8]; | |
558 | } __packed; | |
559 | ||
2d70c103 NB |
560 | /* |
561 | * ISP queue - ABTS received/response entries structure definition for 24xx. | |
562 | */ | |
563 | #define ABTS_RECV_24XX 0x54 /* ABTS received (for 24xx) */ | |
564 | #define ABTS_RESP_24XX 0x55 /* ABTS responce (for 24xx) */ | |
565 | ||
566 | /* | |
567 | * ISP queue - ABTS received IOCB entry structure definition for 24xx. | |
568 | * The ABTS BLS received from the wire is sent to the | |
569 | * target driver by the ISP 24xx. | |
570 | * The IOCB is placed on the response queue. | |
571 | */ | |
572 | struct abts_recv_from_24xx { | |
573 | uint8_t entry_type; /* Entry type. */ | |
574 | uint8_t entry_count; /* Entry count. */ | |
575 | uint8_t sys_define; /* System defined. */ | |
576 | uint8_t entry_status; /* Entry Status. */ | |
577 | uint8_t reserved_1[6]; | |
578 | uint16_t nport_handle; | |
579 | uint8_t reserved_2[2]; | |
580 | uint8_t vp_index; | |
581 | uint8_t reserved_3:4; | |
582 | uint8_t sof_type:4; | |
583 | uint32_t exchange_address; | |
584 | struct fcp_hdr_le fcp_hdr_le; | |
585 | uint8_t reserved_4[16]; | |
586 | uint32_t exchange_addr_to_abort; | |
587 | } __packed; | |
588 | ||
589 | #define ABTS_PARAM_ABORT_SEQ BIT_0 | |
590 | ||
591 | struct ba_acc_le { | |
592 | uint16_t reserved; | |
593 | uint8_t seq_id_last; | |
594 | uint8_t seq_id_valid; | |
595 | #define SEQ_ID_VALID 0x80 | |
596 | #define SEQ_ID_INVALID 0x00 | |
597 | uint16_t rx_id; | |
598 | uint16_t ox_id; | |
599 | uint16_t high_seq_cnt; | |
600 | uint16_t low_seq_cnt; | |
601 | } __packed; | |
602 | ||
603 | struct ba_rjt_le { | |
604 | uint8_t vendor_uniq; | |
605 | uint8_t reason_expl; | |
606 | uint8_t reason_code; | |
607 | #define BA_RJT_REASON_CODE_INVALID_COMMAND 0x1 | |
608 | #define BA_RJT_REASON_CODE_UNABLE_TO_PERFORM 0x9 | |
609 | uint8_t reserved; | |
610 | } __packed; | |
611 | ||
612 | /* | |
613 | * ISP queue - ABTS Response IOCB entry structure definition for 24xx. | |
614 | * The ABTS response to the ABTS received is sent by the | |
615 | * target driver to the ISP 24xx. | |
616 | * The IOCB is placed on the request queue. | |
617 | */ | |
618 | struct abts_resp_to_24xx { | |
619 | uint8_t entry_type; /* Entry type. */ | |
620 | uint8_t entry_count; /* Entry count. */ | |
621 | uint8_t sys_define; /* System defined. */ | |
622 | uint8_t entry_status; /* Entry Status. */ | |
623 | uint32_t handle; | |
624 | uint16_t reserved_1; | |
625 | uint16_t nport_handle; | |
626 | uint16_t control_flags; | |
627 | #define ABTS_CONTR_FLG_TERM_EXCHG BIT_0 | |
628 | uint8_t vp_index; | |
629 | uint8_t reserved_3:4; | |
630 | uint8_t sof_type:4; | |
631 | uint32_t exchange_address; | |
632 | struct fcp_hdr_le fcp_hdr_le; | |
633 | union { | |
634 | struct ba_acc_le ba_acct; | |
635 | struct ba_rjt_le ba_rjt; | |
636 | } __packed payload; | |
637 | uint32_t reserved_4; | |
638 | uint32_t exchange_addr_to_abort; | |
639 | } __packed; | |
640 | ||
641 | /* | |
642 | * ISP queue - ABTS Response IOCB from ISP24xx Firmware entry structure. | |
643 | * The ABTS response with completion status to the ABTS response | |
644 | * (sent by the target driver to the ISP 24xx) is sent by the | |
645 | * ISP24xx firmware to the target driver. | |
646 | * The IOCB is placed on the response queue. | |
647 | */ | |
648 | struct abts_resp_from_24xx_fw { | |
649 | uint8_t entry_type; /* Entry type. */ | |
650 | uint8_t entry_count; /* Entry count. */ | |
651 | uint8_t sys_define; /* System defined. */ | |
652 | uint8_t entry_status; /* Entry Status. */ | |
653 | uint32_t handle; | |
654 | uint16_t compl_status; | |
655 | #define ABTS_RESP_COMPL_SUCCESS 0 | |
656 | #define ABTS_RESP_COMPL_SUBCODE_ERROR 0x31 | |
657 | uint16_t nport_handle; | |
658 | uint16_t reserved_1; | |
659 | uint8_t reserved_2; | |
660 | uint8_t reserved_3:4; | |
661 | uint8_t sof_type:4; | |
662 | uint32_t exchange_address; | |
663 | struct fcp_hdr_le fcp_hdr_le; | |
664 | uint8_t reserved_4[8]; | |
665 | uint32_t error_subcode1; | |
666 | #define ABTS_RESP_SUBCODE_ERR_ABORTED_EXCH_NOT_TERM 0x1E | |
667 | uint32_t error_subcode2; | |
668 | uint32_t exchange_addr_to_abort; | |
669 | } __packed; | |
670 | ||
671 | /********************************************************************\ | |
672 | * Type Definitions used by initiator & target halves | |
673 | \********************************************************************/ | |
674 | ||
675 | struct qla_tgt_mgmt_cmd; | |
5d964837 | 676 | struct fc_port; |
c5419e26 | 677 | struct qla_tgt_cmd; |
2d70c103 NB |
678 | |
679 | /* | |
680 | * This structure provides a template of function calls that the | |
681 | * target driver (from within qla_target.c) can issue to the | |
682 | * target module (tcm_qla2xxx). | |
683 | */ | |
684 | struct qla_tgt_func_tmpl { | |
685 | ||
686 | int (*handle_cmd)(struct scsi_qla_host *, struct qla_tgt_cmd *, | |
687 | unsigned char *, uint32_t, int, int, int); | |
43381ce8 | 688 | void (*handle_data)(struct qla_tgt_cmd *); |
f775bd14 | 689 | int (*handle_tmr)(struct qla_tgt_mgmt_cmd *, u64, uint16_t, |
2d70c103 NB |
690 | uint32_t); |
691 | void (*free_cmd)(struct qla_tgt_cmd *); | |
692 | void (*free_mcmd)(struct qla_tgt_mgmt_cmd *); | |
5d964837 | 693 | void (*free_session)(struct fc_port *); |
2d70c103 NB |
694 | |
695 | int (*check_initiator_node_acl)(struct scsi_qla_host *, unsigned char *, | |
5d964837 QT |
696 | struct fc_port *); |
697 | void (*update_sess)(struct fc_port *, port_id_t, uint16_t, bool); | |
698 | struct fc_port *(*find_sess_by_loop_id)(struct scsi_qla_host *, | |
2d70c103 | 699 | const uint16_t); |
5d964837 | 700 | struct fc_port *(*find_sess_by_s_id)(struct scsi_qla_host *, |
2d70c103 | 701 | const uint8_t *); |
5d964837 QT |
702 | void (*clear_nacl_from_fcport_map)(struct fc_port *); |
703 | void (*put_sess)(struct fc_port *); | |
704 | void (*shutdown_sess)(struct fc_port *); | |
be25152c QT |
705 | int (*get_dif_tags)(struct qla_tgt_cmd *cmd, uint16_t *pfw_prot_opts); |
706 | int (*chk_dif_tags)(uint32_t tag); | |
f1443eeb | 707 | void (*add_target)(struct scsi_qla_host *); |
2d70c103 NB |
708 | }; |
709 | ||
710 | int qla2x00_wait_for_hba_online(struct scsi_qla_host *); | |
711 | ||
712 | #include <target/target_core_base.h> | |
713 | ||
714 | #define QLA_TGT_TIMEOUT 10 /* in seconds */ | |
715 | ||
716 | #define QLA_TGT_MAX_HW_PENDING_TIME 60 /* in seconds */ | |
717 | ||
718 | /* Immediate notify status constants */ | |
719 | #define IMM_NTFY_LIP_RESET 0x000E | |
720 | #define IMM_NTFY_LIP_LINK_REINIT 0x000F | |
721 | #define IMM_NTFY_IOCB_OVERFLOW 0x0016 | |
722 | #define IMM_NTFY_ABORT_TASK 0x0020 | |
723 | #define IMM_NTFY_PORT_LOGOUT 0x0029 | |
724 | #define IMM_NTFY_PORT_CONFIG 0x002A | |
725 | #define IMM_NTFY_GLBL_TPRLO 0x002D | |
726 | #define IMM_NTFY_GLBL_LOGO 0x002E | |
727 | #define IMM_NTFY_RESOURCE 0x0034 | |
728 | #define IMM_NTFY_MSG_RX 0x0036 | |
729 | #define IMM_NTFY_SRR 0x0045 | |
730 | #define IMM_NTFY_ELS 0x0046 | |
731 | ||
732 | /* Immediate notify task flags */ | |
733 | #define IMM_NTFY_TASK_MGMT_SHIFT 8 | |
734 | ||
735 | #define QLA_TGT_CLEAR_ACA 0x40 | |
736 | #define QLA_TGT_TARGET_RESET 0x20 | |
737 | #define QLA_TGT_LUN_RESET 0x10 | |
738 | #define QLA_TGT_CLEAR_TS 0x04 | |
739 | #define QLA_TGT_ABORT_TS 0x02 | |
740 | #define QLA_TGT_ABORT_ALL_SESS 0xFFFF | |
741 | #define QLA_TGT_ABORT_ALL 0xFFFE | |
742 | #define QLA_TGT_NEXUS_LOSS_SESS 0xFFFD | |
743 | #define QLA_TGT_NEXUS_LOSS 0xFFFC | |
be25152c QT |
744 | #define QLA_TGT_ABTS 0xFFFB |
745 | #define QLA_TGT_2G_ABORT_TASK 0xFFFA | |
2d70c103 NB |
746 | |
747 | /* Notify Acknowledge flags */ | |
748 | #define NOTIFY_ACK_RES_COUNT BIT_8 | |
749 | #define NOTIFY_ACK_CLEAR_LIP_RESET BIT_5 | |
750 | #define NOTIFY_ACK_TM_RESP_CODE_VALID BIT_4 | |
751 | ||
752 | /* Command's states */ | |
753 | #define QLA_TGT_STATE_NEW 0 /* New command + target processing */ | |
754 | #define QLA_TGT_STATE_NEED_DATA 1 /* target needs data to continue */ | |
755 | #define QLA_TGT_STATE_DATA_IN 2 /* Data arrived + target processing */ | |
756 | #define QLA_TGT_STATE_PROCESSED 3 /* target done processing */ | |
193b50b9 | 757 | |
2d70c103 NB |
758 | /* ATIO task_codes field */ |
759 | #define ATIO_SIMPLE_QUEUE 0 | |
760 | #define ATIO_HEAD_OF_QUEUE 1 | |
761 | #define ATIO_ORDERED_QUEUE 2 | |
762 | #define ATIO_ACA_QUEUE 4 | |
763 | #define ATIO_UNTAGGED 5 | |
764 | ||
765 | /* TM failed response codes, see FCP (9.4.11 FCP_RSP_INFO) */ | |
766 | #define FC_TM_SUCCESS 0 | |
767 | #define FC_TM_BAD_FCP_DATA 1 | |
768 | #define FC_TM_BAD_CMD 2 | |
769 | #define FC_TM_FCP_DATA_MISMATCH 3 | |
770 | #define FC_TM_REJECT 4 | |
771 | #define FC_TM_FAILED 5 | |
772 | ||
2d70c103 NB |
773 | #if (BITS_PER_LONG > 32) || defined(CONFIG_HIGHMEM64G) |
774 | #define pci_dma_lo32(a) (a & 0xffffffff) | |
775 | #define pci_dma_hi32(a) ((((a) >> 16)>>16) & 0xffffffff) | |
776 | #else | |
777 | #define pci_dma_lo32(a) (a & 0xffffffff) | |
778 | #define pci_dma_hi32(a) 0 | |
779 | #endif | |
780 | ||
781 | #define QLA_TGT_SENSE_VALID(sense) ((sense != NULL) && \ | |
782 | (((const uint8_t *)(sense))[0] & 0x70) == 0x70) | |
783 | ||
784 | struct qla_port_24xx_data { | |
785 | uint8_t port_name[WWN_SIZE]; | |
786 | uint16_t loop_id; | |
787 | uint16_t reserved; | |
788 | }; | |
789 | ||
e326d22a QT |
790 | struct qla_qpair_hint { |
791 | struct list_head hint_elem; | |
792 | struct qla_qpair *qpair; | |
793 | u16 cpuid; | |
794 | uint8_t cmd_cnt; | |
795 | }; | |
796 | ||
2d70c103 NB |
797 | struct qla_tgt { |
798 | struct scsi_qla_host *vha; | |
799 | struct qla_hw_data *ha; | |
e326d22a QT |
800 | struct btree_head64 lun_qpair_map; |
801 | struct qla_qpair_hint *qphints; | |
2d70c103 NB |
802 | /* |
803 | * To sync between IRQ handlers and qlt_target_release(). Needed, | |
804 | * because req_pkt() can drop/reaquire HW lock inside. Protected by | |
805 | * HW lock. | |
806 | */ | |
2f424b9b | 807 | int atio_irq_cmd_count; |
2d70c103 NB |
808 | |
809 | int datasegs_per_cmd, datasegs_per_cont, sg_tablesize; | |
810 | ||
811 | /* Target's flags, serialized by pha->hardware_lock */ | |
812 | unsigned int tgt_enable_64bit_addr:1; /* 64-bits PCI addr enabled */ | |
813 | unsigned int link_reinit_iocb_pending:1; | |
814 | ||
815 | /* | |
816 | * Protected by tgt_mutex AND hardware_lock for writing and tgt_mutex | |
817 | * OR hardware_lock for reading. | |
818 | */ | |
819 | int tgt_stop; /* the target mode driver is being stopped */ | |
820 | int tgt_stopped; /* the target mode driver has been stopped */ | |
821 | ||
822 | /* Count of sessions refering qla_tgt. Protected by hardware_lock. */ | |
823 | int sess_count; | |
824 | ||
2d70c103 NB |
825 | /* Protected by hardware_lock */ |
826 | struct list_head del_sess_list; | |
2d70c103 NB |
827 | |
828 | spinlock_t sess_work_lock; | |
829 | struct list_head sess_works_list; | |
830 | struct work_struct sess_work; | |
831 | ||
832 | struct imm_ntfy_from_isp link_reinit_iocb; | |
833 | wait_queue_head_t waitQ; | |
834 | int notify_ack_expected; | |
835 | int abts_resp_expected; | |
836 | int modify_lun_expected; | |
2d70c103 | 837 | atomic_t tgt_global_resets_count; |
2d70c103 NB |
838 | struct list_head tgt_list_entry; |
839 | }; | |
840 | ||
51a07f84 NB |
841 | struct qla_tgt_sess_op { |
842 | struct scsi_qla_host *vha; | |
2f424b9b | 843 | uint32_t chip_reset; |
51a07f84 NB |
844 | struct atio_from_isp atio; |
845 | struct work_struct work; | |
8b2f5ff3 SN |
846 | struct list_head cmd_list; |
847 | bool aborted; | |
82de802a | 848 | struct rsp_que *rsp; |
51a07f84 NB |
849 | }; |
850 | ||
1eb42f96 QT |
851 | enum trace_flags { |
852 | TRC_NEW_CMD = BIT_0, | |
853 | TRC_DO_WORK = BIT_1, | |
854 | TRC_DO_WORK_ERR = BIT_2, | |
855 | TRC_XFR_RDY = BIT_3, | |
856 | TRC_XMIT_DATA = BIT_4, | |
857 | TRC_XMIT_STATUS = BIT_5, | |
858 | TRC_SRR_RSP = BIT_6, | |
859 | TRC_SRR_XRDY = BIT_7, | |
860 | TRC_SRR_TERM = BIT_8, | |
861 | TRC_SRR_CTIO = BIT_9, | |
862 | TRC_FLUSH = BIT_10, | |
863 | TRC_CTIO_ERR = BIT_11, | |
864 | TRC_CTIO_DONE = BIT_12, | |
865 | TRC_CTIO_ABORTED = BIT_13, | |
866 | TRC_CTIO_STRANGE= BIT_14, | |
867 | TRC_CMD_DONE = BIT_15, | |
868 | TRC_CMD_CHK_STOP = BIT_16, | |
869 | TRC_CMD_FREE = BIT_17, | |
870 | TRC_DATA_IN = BIT_18, | |
871 | TRC_ABORT = BIT_19, | |
be25152c | 872 | TRC_DIF_ERR = BIT_20, |
1eb42f96 | 873 | }; |
a07100e0 | 874 | |
2d70c103 | 875 | struct qla_tgt_cmd { |
c5419e26 QT |
876 | /* |
877 | * Do not move cmd_type field. it needs to line up with srb->cmd_type | |
878 | */ | |
879 | uint8_t cmd_type; | |
880 | uint8_t pad[7]; | |
f83adb61 | 881 | struct se_cmd se_cmd; |
5d964837 | 882 | struct fc_port *sess; |
82de802a | 883 | struct qla_qpair *qpair; |
2d70c103 | 884 | int state; |
2d70c103 NB |
885 | struct work_struct work; |
886 | /* Sense buffer that will be mapped into outgoing status */ | |
887 | unsigned char sense_buffer[TRANSPORT_SENSE_BUFFER]; | |
888 | ||
a07100e0 | 889 | spinlock_t cmd_lock; |
2d70c103 NB |
890 | /* to save extra sess dereferences */ |
891 | unsigned int conf_compl_supported:1; | |
892 | unsigned int sg_mapped:1; | |
893 | unsigned int free_sg:1; | |
2d70c103 | 894 | unsigned int write_data_transferred:1; |
33e79977 QT |
895 | unsigned int q_full:1; |
896 | unsigned int term_exchg:1; | |
d564a372 | 897 | unsigned int cmd_sent_to_fw:1; |
e07f8f65 | 898 | unsigned int cmd_in_wq:1; |
193b50b9 | 899 | unsigned int aborted:1; |
1eb42f96 QT |
900 | unsigned int data_work:1; |
901 | unsigned int data_work_free:1; | |
2d70c103 NB |
902 | |
903 | struct scatterlist *sg; /* cmd data buffer SG vector */ | |
904 | int sg_cnt; /* SG segments count */ | |
905 | int bufflen; /* cmd buffer length */ | |
906 | int offset; | |
f775bd14 | 907 | u64 unpacked_lun; |
2d70c103 | 908 | enum dma_data_direction dma_data_direction; |
b6a029e1 | 909 | uint32_t reset_count; |
2d70c103 NB |
910 | |
911 | uint16_t loop_id; /* to save extra sess dereferences */ | |
912 | struct qla_tgt *tgt; /* to save extra sess dereferences */ | |
913 | struct scsi_qla_host *vha; | |
33e79977 | 914 | struct list_head cmd_list; |
2d70c103 NB |
915 | |
916 | struct atio_from_isp atio; | |
be25152c QT |
917 | |
918 | uint8_t ctx_dsd_alloced; | |
919 | ||
920 | /* T10-DIF */ | |
921 | #define DIF_ERR_NONE 0 | |
922 | #define DIF_ERR_GRD 1 | |
923 | #define DIF_ERR_REF 2 | |
924 | #define DIF_ERR_APP 3 | |
925 | int8_t dif_err_code; | |
f83adb61 QT |
926 | struct scatterlist *prot_sg; |
927 | uint32_t prot_sg_cnt; | |
be25152c QT |
928 | uint32_t blk_sz, num_blks; |
929 | uint8_t scsi_status, sense_key, asc, ascq; | |
930 | ||
f83adb61 | 931 | struct crc_context *ctx; |
be25152c QT |
932 | uint8_t *cdb; |
933 | uint64_t lba; | |
934 | uint16_t a_guard, e_guard, a_app_tag, e_app_tag; | |
935 | uint32_t a_ref_tag, e_ref_tag; | |
f83adb61 | 936 | |
e07f8f65 SK |
937 | uint64_t jiffies_at_alloc; |
938 | uint64_t jiffies_at_free; | |
a07100e0 | 939 | |
1eb42f96 | 940 | enum trace_flags trc_flags; |
2d70c103 NB |
941 | }; |
942 | ||
943 | struct qla_tgt_sess_work_param { | |
944 | struct list_head sess_works_list_entry; | |
945 | ||
946 | #define QLA_TGT_SESS_WORK_ABORT 1 | |
947 | #define QLA_TGT_SESS_WORK_TM 2 | |
948 | int type; | |
949 | ||
950 | union { | |
951 | struct abts_recv_from_24xx abts; | |
952 | struct imm_ntfy_from_isp tm_iocb; | |
953 | struct atio_from_isp tm_iocb2; | |
954 | }; | |
955 | }; | |
956 | ||
957 | struct qla_tgt_mgmt_cmd { | |
be92fc3f | 958 | uint16_t tmr_func; |
2d70c103 | 959 | uint8_t fc_tm_rsp; |
5d964837 | 960 | struct fc_port *sess; |
82de802a | 961 | struct qla_qpair *qpair; |
2d70c103 NB |
962 | struct se_cmd se_cmd; |
963 | struct work_struct free_work; | |
964 | unsigned int flags; | |
b6a029e1 | 965 | uint32_t reset_count; |
2d70c103 NB |
966 | #define QLA24XX_MGMT_SEND_NACK 1 |
967 | union { | |
968 | struct atio_from_isp atio; | |
969 | struct imm_ntfy_from_isp imm_ntfy; | |
970 | struct abts_recv_from_24xx abts; | |
971 | } __packed orig_iocb; | |
972 | }; | |
973 | ||
974 | struct qla_tgt_prm { | |
975 | struct qla_tgt_cmd *cmd; | |
976 | struct qla_tgt *tgt; | |
977 | void *pkt; | |
978 | struct scatterlist *sg; /* cmd data buffer SG vector */ | |
db3a99b9 | 979 | unsigned char *sense_buffer; |
2d70c103 NB |
980 | int seg_cnt; |
981 | int req_cnt; | |
982 | uint16_t rq_result; | |
983 | uint16_t scsi_status; | |
2d70c103 NB |
984 | int sense_buffer_len; |
985 | int residual; | |
986 | int add_status_pkt; | |
f83adb61 QT |
987 | /* dif */ |
988 | struct scatterlist *prot_sg; | |
989 | uint16_t prot_seg_cnt; | |
990 | uint16_t tot_dsds; | |
2d70c103 NB |
991 | }; |
992 | ||
a6ca8878 AP |
993 | /* Check for Switch reserved address */ |
994 | #define IS_SW_RESV_ADDR(_s_id) \ | |
995 | ((_s_id.b.domain == 0xff) && (_s_id.b.area == 0xfc)) | |
996 | ||
2d70c103 NB |
997 | #define QLA_TGT_XMIT_DATA 1 |
998 | #define QLA_TGT_XMIT_STATUS 2 | |
999 | #define QLA_TGT_XMIT_ALL (QLA_TGT_XMIT_STATUS|QLA_TGT_XMIT_DATA) | |
1000 | ||
2d70c103 NB |
1001 | |
1002 | extern struct qla_tgt_data qla_target; | |
2d70c103 NB |
1003 | |
1004 | /* | |
1005 | * Function prototypes for qla_target.c logic used by qla2xxx LLD code. | |
1006 | */ | |
1007 | extern int qlt_add_target(struct qla_hw_data *, struct scsi_qla_host *); | |
1008 | extern int qlt_remove_target(struct qla_hw_data *, struct scsi_qla_host *); | |
49a47f2c NB |
1009 | extern int qlt_lport_register(void *, u64, u64, u64, |
1010 | int (*callback)(struct scsi_qla_host *, void *, u64, u64)); | |
2d70c103 | 1011 | extern void qlt_lport_deregister(struct scsi_qla_host *); |
5d964837 | 1012 | extern void qlt_unreg_sess(struct fc_port *); |
2d70c103 | 1013 | extern void qlt_fc_port_added(struct scsi_qla_host *, fc_port_t *); |
df673274 | 1014 | extern void qlt_fc_port_deleted(struct scsi_qla_host *, fc_port_t *, int); |
2d70c103 NB |
1015 | extern int __init qlt_init(void); |
1016 | extern void qlt_exit(void); | |
1017 | extern void qlt_update_vp_map(struct scsi_qla_host *, int); | |
1018 | ||
1019 | /* | |
1020 | * This macro is used during early initializations when host->active_mode | |
1021 | * is not set. Right now, ha value is ignored. | |
1022 | */ | |
1023 | #define QLA_TGT_MODE_ENABLED() (ql2x_ini_mode != QLA2XXX_INI_MODE_ENABLED) | |
ead03855 | 1024 | |
aa230bc5 | 1025 | extern int ql2x_ini_mode; |
2d70c103 NB |
1026 | |
1027 | static inline bool qla_tgt_mode_enabled(struct scsi_qla_host *ha) | |
1028 | { | |
726b8548 | 1029 | return ha->host->active_mode == MODE_TARGET; |
2d70c103 NB |
1030 | } |
1031 | ||
1032 | static inline bool qla_ini_mode_enabled(struct scsi_qla_host *ha) | |
1033 | { | |
726b8548 QT |
1034 | return ha->host->active_mode == MODE_INITIATOR; |
1035 | } | |
1036 | ||
1037 | static inline bool qla_dual_mode_enabled(struct scsi_qla_host *ha) | |
1038 | { | |
1039 | return (ha->host->active_mode == MODE_DUAL); | |
2d70c103 NB |
1040 | } |
1041 | ||
8b2f5ff3 SN |
1042 | static inline uint32_t sid_to_key(const uint8_t *s_id) |
1043 | { | |
1044 | uint32_t key; | |
1045 | ||
1046 | key = (((unsigned long)s_id[0] << 16) | | |
1047 | ((unsigned long)s_id[1] << 8) | | |
1048 | (unsigned long)s_id[2]); | |
1049 | return key; | |
1050 | } | |
1051 | ||
71cdc079 AP |
1052 | static inline void sid_to_portid(const uint8_t *s_id, port_id_t *p) |
1053 | { | |
1054 | memset(p, 0, sizeof(*p)); | |
1055 | p->b.domain = s_id[0]; | |
1056 | p->b.area = s_id[1]; | |
1057 | p->b.al_pa = s_id[2]; | |
1058 | } | |
1059 | ||
2d70c103 NB |
1060 | /* |
1061 | * Exported symbols from qla_target.c LLD logic used by qla2xxx code.. | |
1062 | */ | |
82de802a QT |
1063 | extern void qlt_response_pkt_all_vps(struct scsi_qla_host *, struct rsp_que *, |
1064 | response_t *); | |
2d70c103 NB |
1065 | extern int qlt_rdy_to_xfer(struct qla_tgt_cmd *); |
1066 | extern int qlt_xmit_response(struct qla_tgt_cmd *, int, uint8_t); | |
a07100e0 | 1067 | extern int qlt_abort_cmd(struct qla_tgt_cmd *); |
2d70c103 NB |
1068 | extern void qlt_xmit_tm_rsp(struct qla_tgt_mgmt_cmd *); |
1069 | extern void qlt_free_mcmd(struct qla_tgt_mgmt_cmd *); | |
1070 | extern void qlt_free_cmd(struct qla_tgt_cmd *cmd); | |
2d70c103 NB |
1071 | extern void qlt_async_event(uint16_t, struct scsi_qla_host *, uint16_t *); |
1072 | extern void qlt_enable_vha(struct scsi_qla_host *); | |
1073 | extern void qlt_vport_create(struct scsi_qla_host *, struct qla_hw_data *); | |
1074 | extern void qlt_rff_id(struct scsi_qla_host *, struct ct_sns_req *); | |
1075 | extern void qlt_init_atio_q_entries(struct scsi_qla_host *); | |
2f424b9b | 1076 | extern void qlt_24xx_process_atio_queue(struct scsi_qla_host *, uint8_t); |
aa230bc5 | 1077 | extern void qlt_24xx_config_rings(struct scsi_qla_host *); |
2d70c103 NB |
1078 | extern void qlt_24xx_config_nvram_stage1(struct scsi_qla_host *, |
1079 | struct nvram_24xx *); | |
1080 | extern void qlt_24xx_config_nvram_stage2(struct scsi_qla_host *, | |
1081 | struct init_cb_24xx *); | |
aa230bc5 AE |
1082 | extern void qlt_81xx_config_nvram_stage2(struct scsi_qla_host *, |
1083 | struct init_cb_81xx *); | |
1084 | extern void qlt_81xx_config_nvram_stage1(struct scsi_qla_host *, | |
1085 | struct nvram_81xx *); | |
2d70c103 NB |
1086 | extern int qlt_24xx_process_response_error(struct scsi_qla_host *, |
1087 | struct sts_entry_24xx *); | |
1088 | extern void qlt_modify_vp_config(struct scsi_qla_host *, | |
1089 | struct vp_config_entry_24xx *); | |
1090 | extern void qlt_probe_one_stage1(struct scsi_qla_host *, struct qla_hw_data *); | |
1091 | extern int qlt_mem_alloc(struct qla_hw_data *); | |
1092 | extern void qlt_mem_free(struct qla_hw_data *); | |
3c231bda | 1093 | extern int qlt_stop_phase1(struct qla_tgt *); |
2d70c103 | 1094 | extern void qlt_stop_phase2(struct qla_tgt *); |
aa230bc5 AE |
1095 | extern irqreturn_t qla83xx_msix_atio_q(int, void *); |
1096 | extern void qlt_83xx_iospace_config(struct qla_hw_data *); | |
82de802a | 1097 | extern int qlt_free_qfull_cmds(struct qla_qpair *); |
a6ca8878 | 1098 | extern void qlt_logo_completion_handler(fc_port_t *, int); |
df673274 | 1099 | extern void qlt_do_generation_tick(struct scsi_qla_host *, int *); |
2d70c103 | 1100 | |
be25152c QT |
1101 | void qlt_send_resp_ctio(scsi_qla_host_t *, struct qla_tgt_cmd *, uint8_t, |
1102 | uint8_t, uint8_t, uint8_t); | |
c5419e26 QT |
1103 | extern void qlt_abort_cmd_on_host_reset(struct scsi_qla_host *, |
1104 | struct qla_tgt_cmd *); | |
be25152c | 1105 | |
2d70c103 | 1106 | #endif /* __QLA_TARGET_H */ |