diff options
Diffstat (limited to 'drivers/scsi/qla2xxx/qla_target.h')
-rw-r--r-- | drivers/scsi/qla2xxx/qla_target.h | 1005 |
1 files changed, 1005 insertions, 0 deletions
diff --git a/drivers/scsi/qla2xxx/qla_target.h b/drivers/scsi/qla2xxx/qla_target.h new file mode 100644 index 000000000000..9ec19bc2f0fe --- /dev/null +++ b/drivers/scsi/qla2xxx/qla_target.h | |||
@@ -0,0 +1,1005 @@ | |||
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" | ||
48 | |||
49 | #define QLA2XXX_INI_MODE_EXCLUSIVE 0 | ||
50 | #define QLA2XXX_INI_MODE_DISABLED 1 | ||
51 | #define QLA2XXX_INI_MODE_ENABLED 2 | ||
52 | |||
53 | #define QLA2XXX_COMMAND_COUNT_INIT 250 | ||
54 | #define QLA2XXX_IMMED_NOTIFY_COUNT_INIT 250 | ||
55 | |||
56 | /* | ||
57 | * Used to mark which completion handles (for RIO Status's) are for CTIO's | ||
58 | * vs. regular (non-target) info. This is checked for in | ||
59 | * qla2x00_process_response_queue() to see if a handle coming back in a | ||
60 | * multi-complete should come to the tgt driver or be handled there by qla2xxx | ||
61 | */ | ||
62 | #define CTIO_COMPLETION_HANDLE_MARK BIT_29 | ||
63 | #if (CTIO_COMPLETION_HANDLE_MARK <= MAX_OUTSTANDING_COMMANDS) | ||
64 | #error "CTIO_COMPLETION_HANDLE_MARK not larger than MAX_OUTSTANDING_COMMANDS" | ||
65 | #endif | ||
66 | #define HANDLE_IS_CTIO_COMP(h) (h & CTIO_COMPLETION_HANDLE_MARK) | ||
67 | |||
68 | /* Used to mark CTIO as intermediate */ | ||
69 | #define CTIO_INTERMEDIATE_HANDLE_MARK BIT_30 | ||
70 | |||
71 | #ifndef OF_SS_MODE_0 | ||
72 | /* | ||
73 | * ISP target entries - Flags bit definitions. | ||
74 | */ | ||
75 | #define OF_SS_MODE_0 0 | ||
76 | #define OF_SS_MODE_1 1 | ||
77 | #define OF_SS_MODE_2 2 | ||
78 | #define OF_SS_MODE_3 3 | ||
79 | |||
80 | #define OF_EXPL_CONF BIT_5 /* Explicit Confirmation Requested */ | ||
81 | #define OF_DATA_IN BIT_6 /* Data in to initiator */ | ||
82 | /* (data from target to initiator) */ | ||
83 | #define OF_DATA_OUT BIT_7 /* Data out from initiator */ | ||
84 | /* (data from initiator to target) */ | ||
85 | #define OF_NO_DATA (BIT_7 | BIT_6) | ||
86 | #define OF_INC_RC BIT_8 /* Increment command resource count */ | ||
87 | #define OF_FAST_POST BIT_9 /* Enable mailbox fast posting. */ | ||
88 | #define OF_CONF_REQ BIT_13 /* Confirmation Requested */ | ||
89 | #define OF_TERM_EXCH BIT_14 /* Terminate exchange */ | ||
90 | #define OF_SSTS BIT_15 /* Send SCSI status */ | ||
91 | #endif | ||
92 | |||
93 | #ifndef QLA_TGT_DATASEGS_PER_CMD32 | ||
94 | #define QLA_TGT_DATASEGS_PER_CMD32 3 | ||
95 | #define QLA_TGT_DATASEGS_PER_CONT32 7 | ||
96 | #define QLA_TGT_MAX_SG32(ql) \ | ||
97 | (((ql) > 0) ? (QLA_TGT_DATASEGS_PER_CMD32 + \ | ||
98 | QLA_TGT_DATASEGS_PER_CONT32*((ql) - 1)) : 0) | ||
99 | |||
100 | #define QLA_TGT_DATASEGS_PER_CMD64 2 | ||
101 | #define QLA_TGT_DATASEGS_PER_CONT64 5 | ||
102 | #define QLA_TGT_MAX_SG64(ql) \ | ||
103 | (((ql) > 0) ? (QLA_TGT_DATASEGS_PER_CMD64 + \ | ||
104 | QLA_TGT_DATASEGS_PER_CONT64*((ql) - 1)) : 0) | ||
105 | #endif | ||
106 | |||
107 | #ifndef QLA_TGT_DATASEGS_PER_CMD_24XX | ||
108 | #define QLA_TGT_DATASEGS_PER_CMD_24XX 1 | ||
109 | #define QLA_TGT_DATASEGS_PER_CONT_24XX 5 | ||
110 | #define QLA_TGT_MAX_SG_24XX(ql) \ | ||
111 | (min(1270, ((ql) > 0) ? (QLA_TGT_DATASEGS_PER_CMD_24XX + \ | ||
112 | QLA_TGT_DATASEGS_PER_CONT_24XX*((ql) - 1)) : 0)) | ||
113 | #endif | ||
114 | #endif | ||
115 | |||
116 | #define GET_TARGET_ID(ha, iocb) ((HAS_EXTENDED_IDS(ha)) \ | ||
117 | ? le16_to_cpu((iocb)->u.isp2x.target.extended) \ | ||
118 | : (uint16_t)(iocb)->u.isp2x.target.id.standard) | ||
119 | |||
120 | #ifndef IMMED_NOTIFY_TYPE | ||
121 | #define IMMED_NOTIFY_TYPE 0x0D /* Immediate notify entry. */ | ||
122 | /* | ||
123 | * ISP queue - immediate notify entry structure definition. | ||
124 | * This is sent by the ISP to the Target driver. | ||
125 | * This IOCB would have report of events sent by the | ||
126 | * initiator, that needs to be handled by the target | ||
127 | * driver immediately. | ||
128 | */ | ||
129 | struct imm_ntfy_from_isp { | ||
130 | uint8_t entry_type; /* Entry type. */ | ||
131 | uint8_t entry_count; /* Entry count. */ | ||
132 | uint8_t sys_define; /* System defined. */ | ||
133 | uint8_t entry_status; /* Entry Status. */ | ||
134 | union { | ||
135 | struct { | ||
136 | uint32_t sys_define_2; /* System defined. */ | ||
137 | target_id_t target; | ||
138 | uint16_t lun; | ||
139 | uint8_t target_id; | ||
140 | uint8_t reserved_1; | ||
141 | uint16_t status_modifier; | ||
142 | uint16_t status; | ||
143 | uint16_t task_flags; | ||
144 | uint16_t seq_id; | ||
145 | uint16_t srr_rx_id; | ||
146 | uint32_t srr_rel_offs; | ||
147 | uint16_t srr_ui; | ||
148 | #define SRR_IU_DATA_IN 0x1 | ||
149 | #define SRR_IU_DATA_OUT 0x5 | ||
150 | #define SRR_IU_STATUS 0x7 | ||
151 | uint16_t srr_ox_id; | ||
152 | uint8_t reserved_2[28]; | ||
153 | } isp2x; | ||
154 | struct { | ||
155 | uint32_t reserved; | ||
156 | uint16_t nport_handle; | ||
157 | uint16_t reserved_2; | ||
158 | uint16_t flags; | ||
159 | #define NOTIFY24XX_FLAGS_GLOBAL_TPRLO BIT_1 | ||
160 | #define NOTIFY24XX_FLAGS_PUREX_IOCB BIT_0 | ||
161 | uint16_t srr_rx_id; | ||
162 | uint16_t status; | ||
163 | uint8_t status_subcode; | ||
164 | uint8_t reserved_3; | ||
165 | uint32_t exchange_address; | ||
166 | uint32_t srr_rel_offs; | ||
167 | uint16_t srr_ui; | ||
168 | uint16_t srr_ox_id; | ||
169 | uint8_t reserved_4[19]; | ||
170 | uint8_t vp_index; | ||
171 | uint32_t reserved_5; | ||
172 | uint8_t port_id[3]; | ||
173 | uint8_t reserved_6; | ||
174 | } isp24; | ||
175 | } u; | ||
176 | uint16_t reserved_7; | ||
177 | uint16_t ox_id; | ||
178 | } __packed; | ||
179 | #endif | ||
180 | |||
181 | #ifndef NOTIFY_ACK_TYPE | ||
182 | #define NOTIFY_ACK_TYPE 0x0E /* Notify acknowledge entry. */ | ||
183 | /* | ||
184 | * ISP queue - notify acknowledge entry structure definition. | ||
185 | * This is sent to the ISP from the target driver. | ||
186 | */ | ||
187 | struct nack_to_isp { | ||
188 | uint8_t entry_type; /* Entry type. */ | ||
189 | uint8_t entry_count; /* Entry count. */ | ||
190 | uint8_t sys_define; /* System defined. */ | ||
191 | uint8_t entry_status; /* Entry Status. */ | ||
192 | union { | ||
193 | struct { | ||
194 | uint32_t sys_define_2; /* System defined. */ | ||
195 | target_id_t target; | ||
196 | uint8_t target_id; | ||
197 | uint8_t reserved_1; | ||
198 | uint16_t flags; | ||
199 | uint16_t resp_code; | ||
200 | uint16_t status; | ||
201 | uint16_t task_flags; | ||
202 | uint16_t seq_id; | ||
203 | uint16_t srr_rx_id; | ||
204 | uint32_t srr_rel_offs; | ||
205 | uint16_t srr_ui; | ||
206 | uint16_t srr_flags; | ||
207 | uint16_t srr_reject_code; | ||
208 | uint8_t srr_reject_vendor_uniq; | ||
209 | uint8_t srr_reject_code_expl; | ||
210 | uint8_t reserved_2[24]; | ||
211 | } isp2x; | ||
212 | struct { | ||
213 | uint32_t handle; | ||
214 | uint16_t nport_handle; | ||
215 | uint16_t reserved_1; | ||
216 | uint16_t flags; | ||
217 | uint16_t srr_rx_id; | ||
218 | uint16_t status; | ||
219 | uint8_t status_subcode; | ||
220 | uint8_t reserved_3; | ||
221 | uint32_t exchange_address; | ||
222 | uint32_t srr_rel_offs; | ||
223 | uint16_t srr_ui; | ||
224 | uint16_t srr_flags; | ||
225 | uint8_t reserved_4[19]; | ||
226 | uint8_t vp_index; | ||
227 | uint8_t srr_reject_vendor_uniq; | ||
228 | uint8_t srr_reject_code_expl; | ||
229 | uint8_t srr_reject_code; | ||
230 | uint8_t reserved_5[5]; | ||
231 | } isp24; | ||
232 | } u; | ||
233 | uint8_t reserved[2]; | ||
234 | uint16_t ox_id; | ||
235 | } __packed; | ||
236 | #define NOTIFY_ACK_SRR_FLAGS_ACCEPT 0 | ||
237 | #define NOTIFY_ACK_SRR_FLAGS_REJECT 1 | ||
238 | |||
239 | #define NOTIFY_ACK_SRR_REJECT_REASON_UNABLE_TO_PERFORM 0x9 | ||
240 | |||
241 | #define NOTIFY_ACK_SRR_FLAGS_REJECT_EXPL_NO_EXPL 0 | ||
242 | #define NOTIFY_ACK_SRR_FLAGS_REJECT_EXPL_UNABLE_TO_SUPPLY_DATA 0x2a | ||
243 | |||
244 | #define NOTIFY_ACK_SUCCESS 0x01 | ||
245 | #endif | ||
246 | |||
247 | #ifndef ACCEPT_TGT_IO_TYPE | ||
248 | #define ACCEPT_TGT_IO_TYPE 0x16 /* Accept target I/O entry. */ | ||
249 | #endif | ||
250 | |||
251 | #ifndef CONTINUE_TGT_IO_TYPE | ||
252 | #define CONTINUE_TGT_IO_TYPE 0x17 | ||
253 | /* | ||
254 | * ISP queue - Continue Target I/O (CTIO) entry for status mode 0 structure. | ||
255 | * This structure is sent to the ISP 2xxx from target driver. | ||
256 | */ | ||
257 | struct ctio_to_2xxx { | ||
258 | uint8_t entry_type; /* Entry type. */ | ||
259 | uint8_t entry_count; /* Entry count. */ | ||
260 | uint8_t sys_define; /* System defined. */ | ||
261 | uint8_t entry_status; /* Entry Status. */ | ||
262 | uint32_t handle; /* System defined handle */ | ||
263 | target_id_t target; | ||
264 | uint16_t rx_id; | ||
265 | uint16_t flags; | ||
266 | uint16_t status; | ||
267 | uint16_t timeout; /* 0 = 30 seconds, 0xFFFF = disable */ | ||
268 | uint16_t dseg_count; /* Data segment count. */ | ||
269 | uint32_t relative_offset; | ||
270 | uint32_t residual; | ||
271 | uint16_t reserved_1[3]; | ||
272 | uint16_t scsi_status; | ||
273 | uint32_t transfer_length; | ||
274 | uint32_t dseg_0_address; /* Data segment 0 address. */ | ||
275 | uint32_t dseg_0_length; /* Data segment 0 length. */ | ||
276 | uint32_t dseg_1_address; /* Data segment 1 address. */ | ||
277 | uint32_t dseg_1_length; /* Data segment 1 length. */ | ||
278 | uint32_t dseg_2_address; /* Data segment 2 address. */ | ||
279 | uint32_t dseg_2_length; /* Data segment 2 length. */ | ||
280 | } __packed; | ||
281 | #define ATIO_PATH_INVALID 0x07 | ||
282 | #define ATIO_CANT_PROV_CAP 0x16 | ||
283 | #define ATIO_CDB_VALID 0x3D | ||
284 | |||
285 | #define ATIO_EXEC_READ BIT_1 | ||
286 | #define ATIO_EXEC_WRITE BIT_0 | ||
287 | #endif | ||
288 | |||
289 | #ifndef CTIO_A64_TYPE | ||
290 | #define CTIO_A64_TYPE 0x1F | ||
291 | #define CTIO_SUCCESS 0x01 | ||
292 | #define CTIO_ABORTED 0x02 | ||
293 | #define CTIO_INVALID_RX_ID 0x08 | ||
294 | #define CTIO_TIMEOUT 0x0B | ||
295 | #define CTIO_LIP_RESET 0x0E | ||
296 | #define CTIO_TARGET_RESET 0x17 | ||
297 | #define CTIO_PORT_UNAVAILABLE 0x28 | ||
298 | #define CTIO_PORT_LOGGED_OUT 0x29 | ||
299 | #define CTIO_PORT_CONF_CHANGED 0x2A | ||
300 | #define CTIO_SRR_RECEIVED 0x45 | ||
301 | #endif | ||
302 | |||
303 | #ifndef CTIO_RET_TYPE | ||
304 | #define CTIO_RET_TYPE 0x17 /* CTIO return entry */ | ||
305 | #define ATIO_TYPE7 0x06 /* Accept target I/O entry for 24xx */ | ||
306 | |||
307 | struct fcp_hdr { | ||
308 | uint8_t r_ctl; | ||
309 | uint8_t d_id[3]; | ||
310 | uint8_t cs_ctl; | ||
311 | uint8_t s_id[3]; | ||
312 | uint8_t type; | ||
313 | uint8_t f_ctl[3]; | ||
314 | uint8_t seq_id; | ||
315 | uint8_t df_ctl; | ||
316 | uint16_t seq_cnt; | ||
317 | uint16_t ox_id; | ||
318 | uint16_t rx_id; | ||
319 | uint32_t parameter; | ||
320 | } __packed; | ||
321 | |||
322 | struct fcp_hdr_le { | ||
323 | uint8_t d_id[3]; | ||
324 | uint8_t r_ctl; | ||
325 | uint8_t s_id[3]; | ||
326 | uint8_t cs_ctl; | ||
327 | uint8_t f_ctl[3]; | ||
328 | uint8_t type; | ||
329 | uint16_t seq_cnt; | ||
330 | uint8_t df_ctl; | ||
331 | uint8_t seq_id; | ||
332 | uint16_t rx_id; | ||
333 | uint16_t ox_id; | ||
334 | uint32_t parameter; | ||
335 | } __packed; | ||
336 | |||
337 | #define F_CTL_EXCH_CONTEXT_RESP BIT_23 | ||
338 | #define F_CTL_SEQ_CONTEXT_RESIP BIT_22 | ||
339 | #define F_CTL_LAST_SEQ BIT_20 | ||
340 | #define F_CTL_END_SEQ BIT_19 | ||
341 | #define F_CTL_SEQ_INITIATIVE BIT_16 | ||
342 | |||
343 | #define R_CTL_BASIC_LINK_SERV 0x80 | ||
344 | #define R_CTL_B_ACC 0x4 | ||
345 | #define R_CTL_B_RJT 0x5 | ||
346 | |||
347 | struct atio7_fcp_cmnd { | ||
348 | uint64_t lun; | ||
349 | uint8_t cmnd_ref; | ||
350 | uint8_t task_attr:3; | ||
351 | uint8_t reserved:5; | ||
352 | uint8_t task_mgmt_flags; | ||
353 | #define FCP_CMND_TASK_MGMT_CLEAR_ACA 6 | ||
354 | #define FCP_CMND_TASK_MGMT_TARGET_RESET 5 | ||
355 | #define FCP_CMND_TASK_MGMT_LU_RESET 4 | ||
356 | #define FCP_CMND_TASK_MGMT_CLEAR_TASK_SET 2 | ||
357 | #define FCP_CMND_TASK_MGMT_ABORT_TASK_SET 1 | ||
358 | uint8_t wrdata:1; | ||
359 | uint8_t rddata:1; | ||
360 | uint8_t add_cdb_len:6; | ||
361 | uint8_t cdb[16]; | ||
362 | /* | ||
363 | * add_cdb is optional and can absent from struct atio7_fcp_cmnd. Size 4 | ||
364 | * only to make sizeof(struct atio7_fcp_cmnd) be as expected by | ||
365 | * BUILD_BUG_ON in qlt_init(). | ||
366 | */ | ||
367 | uint8_t add_cdb[4]; | ||
368 | /* uint32_t data_length; */ | ||
369 | } __packed; | ||
370 | |||
371 | /* | ||
372 | * ISP queue - Accept Target I/O (ATIO) type entry IOCB structure. | ||
373 | * This is sent from the ISP to the target driver. | ||
374 | */ | ||
375 | struct atio_from_isp { | ||
376 | union { | ||
377 | struct { | ||
378 | uint16_t entry_hdr; | ||
379 | uint8_t sys_define; /* System defined. */ | ||
380 | uint8_t entry_status; /* Entry Status. */ | ||
381 | uint32_t sys_define_2; /* System defined. */ | ||
382 | target_id_t target; | ||
383 | uint16_t rx_id; | ||
384 | uint16_t flags; | ||
385 | uint16_t status; | ||
386 | uint8_t command_ref; | ||
387 | uint8_t task_codes; | ||
388 | uint8_t task_flags; | ||
389 | uint8_t execution_codes; | ||
390 | uint8_t cdb[MAX_CMDSZ]; | ||
391 | uint32_t data_length; | ||
392 | uint16_t lun; | ||
393 | uint8_t initiator_port_name[WWN_SIZE]; /* on qla23xx */ | ||
394 | uint16_t reserved_32[6]; | ||
395 | uint16_t ox_id; | ||
396 | } isp2x; | ||
397 | struct { | ||
398 | uint16_t entry_hdr; | ||
399 | uint8_t fcp_cmnd_len_low; | ||
400 | uint8_t fcp_cmnd_len_high:4; | ||
401 | uint8_t attr:4; | ||
402 | uint32_t exchange_addr; | ||
403 | #define ATIO_EXCHANGE_ADDRESS_UNKNOWN 0xFFFFFFFF | ||
404 | struct fcp_hdr fcp_hdr; | ||
405 | struct atio7_fcp_cmnd fcp_cmnd; | ||
406 | } isp24; | ||
407 | struct { | ||
408 | uint8_t entry_type; /* Entry type. */ | ||
409 | uint8_t entry_count; /* Entry count. */ | ||
410 | uint8_t data[58]; | ||
411 | uint32_t signature; | ||
412 | #define ATIO_PROCESSED 0xDEADDEAD /* Signature */ | ||
413 | } raw; | ||
414 | } u; | ||
415 | } __packed; | ||
416 | |||
417 | #define CTIO_TYPE7 0x12 /* Continue target I/O entry (for 24xx) */ | ||
418 | |||
419 | /* | ||
420 | * ISP queue - Continue Target I/O (ATIO) type 7 entry (for 24xx) structure. | ||
421 | * This structure is sent to the ISP 24xx from the target driver. | ||
422 | */ | ||
423 | |||
424 | struct ctio7_to_24xx { | ||
425 | uint8_t entry_type; /* Entry type. */ | ||
426 | uint8_t entry_count; /* Entry count. */ | ||
427 | uint8_t sys_define; /* System defined. */ | ||
428 | uint8_t entry_status; /* Entry Status. */ | ||
429 | uint32_t handle; /* System defined handle */ | ||
430 | uint16_t nport_handle; | ||
431 | #define CTIO7_NHANDLE_UNRECOGNIZED 0xFFFF | ||
432 | uint16_t timeout; | ||
433 | uint16_t dseg_count; /* Data segment count. */ | ||
434 | uint8_t vp_index; | ||
435 | uint8_t add_flags; | ||
436 | uint8_t initiator_id[3]; | ||
437 | uint8_t reserved; | ||
438 | uint32_t exchange_addr; | ||
439 | union { | ||
440 | struct { | ||
441 | uint16_t reserved1; | ||
442 | uint16_t flags; | ||
443 | uint32_t residual; | ||
444 | uint16_t ox_id; | ||
445 | uint16_t scsi_status; | ||
446 | uint32_t relative_offset; | ||
447 | uint32_t reserved2; | ||
448 | uint32_t transfer_length; | ||
449 | uint32_t reserved3; | ||
450 | /* Data segment 0 address. */ | ||
451 | uint32_t dseg_0_address[2]; | ||
452 | /* Data segment 0 length. */ | ||
453 | uint32_t dseg_0_length; | ||
454 | } status0; | ||
455 | struct { | ||
456 | uint16_t sense_length; | ||
457 | uint16_t flags; | ||
458 | uint32_t residual; | ||
459 | uint16_t ox_id; | ||
460 | uint16_t scsi_status; | ||
461 | uint16_t response_len; | ||
462 | uint16_t reserved; | ||
463 | uint8_t sense_data[24]; | ||
464 | } status1; | ||
465 | } u; | ||
466 | } __packed; | ||
467 | |||
468 | /* | ||
469 | * ISP queue - CTIO type 7 from ISP 24xx to target driver | ||
470 | * returned entry structure. | ||
471 | */ | ||
472 | struct ctio7_from_24xx { | ||
473 | uint8_t entry_type; /* Entry type. */ | ||
474 | uint8_t entry_count; /* Entry count. */ | ||
475 | uint8_t sys_define; /* System defined. */ | ||
476 | uint8_t entry_status; /* Entry Status. */ | ||
477 | uint32_t handle; /* System defined handle */ | ||
478 | uint16_t status; | ||
479 | uint16_t timeout; | ||
480 | uint16_t dseg_count; /* Data segment count. */ | ||
481 | uint8_t vp_index; | ||
482 | uint8_t reserved1[5]; | ||
483 | uint32_t exchange_address; | ||
484 | uint16_t reserved2; | ||
485 | uint16_t flags; | ||
486 | uint32_t residual; | ||
487 | uint16_t ox_id; | ||
488 | uint16_t reserved3; | ||
489 | uint32_t relative_offset; | ||
490 | uint8_t reserved4[24]; | ||
491 | } __packed; | ||
492 | |||
493 | /* CTIO7 flags values */ | ||
494 | #define CTIO7_FLAGS_SEND_STATUS BIT_15 | ||
495 | #define CTIO7_FLAGS_TERMINATE BIT_14 | ||
496 | #define CTIO7_FLAGS_CONFORM_REQ BIT_13 | ||
497 | #define CTIO7_FLAGS_DONT_RET_CTIO BIT_8 | ||
498 | #define CTIO7_FLAGS_STATUS_MODE_0 0 | ||
499 | #define CTIO7_FLAGS_STATUS_MODE_1 BIT_6 | ||
500 | #define CTIO7_FLAGS_EXPLICIT_CONFORM BIT_5 | ||
501 | #define CTIO7_FLAGS_CONFIRM_SATISF BIT_4 | ||
502 | #define CTIO7_FLAGS_DSD_PTR BIT_2 | ||
503 | #define CTIO7_FLAGS_DATA_IN BIT_1 | ||
504 | #define CTIO7_FLAGS_DATA_OUT BIT_0 | ||
505 | |||
506 | #define ELS_PLOGI 0x3 | ||
507 | #define ELS_FLOGI 0x4 | ||
508 | #define ELS_LOGO 0x5 | ||
509 | #define ELS_PRLI 0x20 | ||
510 | #define ELS_PRLO 0x21 | ||
511 | #define ELS_TPRLO 0x24 | ||
512 | #define ELS_PDISC 0x50 | ||
513 | #define ELS_ADISC 0x52 | ||
514 | |||
515 | /* | ||
516 | * ISP queue - ABTS received/response entries structure definition for 24xx. | ||
517 | */ | ||
518 | #define ABTS_RECV_24XX 0x54 /* ABTS received (for 24xx) */ | ||
519 | #define ABTS_RESP_24XX 0x55 /* ABTS responce (for 24xx) */ | ||
520 | |||
521 | /* | ||
522 | * ISP queue - ABTS received IOCB entry structure definition for 24xx. | ||
523 | * The ABTS BLS received from the wire is sent to the | ||
524 | * target driver by the ISP 24xx. | ||
525 | * The IOCB is placed on the response queue. | ||
526 | */ | ||
527 | struct abts_recv_from_24xx { | ||
528 | uint8_t entry_type; /* Entry type. */ | ||
529 | uint8_t entry_count; /* Entry count. */ | ||
530 | uint8_t sys_define; /* System defined. */ | ||
531 | uint8_t entry_status; /* Entry Status. */ | ||
532 | uint8_t reserved_1[6]; | ||
533 | uint16_t nport_handle; | ||
534 | uint8_t reserved_2[2]; | ||
535 | uint8_t vp_index; | ||
536 | uint8_t reserved_3:4; | ||
537 | uint8_t sof_type:4; | ||
538 | uint32_t exchange_address; | ||
539 | struct fcp_hdr_le fcp_hdr_le; | ||
540 | uint8_t reserved_4[16]; | ||
541 | uint32_t exchange_addr_to_abort; | ||
542 | } __packed; | ||
543 | |||
544 | #define ABTS_PARAM_ABORT_SEQ BIT_0 | ||
545 | |||
546 | struct ba_acc_le { | ||
547 | uint16_t reserved; | ||
548 | uint8_t seq_id_last; | ||
549 | uint8_t seq_id_valid; | ||
550 | #define SEQ_ID_VALID 0x80 | ||
551 | #define SEQ_ID_INVALID 0x00 | ||
552 | uint16_t rx_id; | ||
553 | uint16_t ox_id; | ||
554 | uint16_t high_seq_cnt; | ||
555 | uint16_t low_seq_cnt; | ||
556 | } __packed; | ||
557 | |||
558 | struct ba_rjt_le { | ||
559 | uint8_t vendor_uniq; | ||
560 | uint8_t reason_expl; | ||
561 | uint8_t reason_code; | ||
562 | #define BA_RJT_REASON_CODE_INVALID_COMMAND 0x1 | ||
563 | #define BA_RJT_REASON_CODE_UNABLE_TO_PERFORM 0x9 | ||
564 | uint8_t reserved; | ||
565 | } __packed; | ||
566 | |||
567 | /* | ||
568 | * ISP queue - ABTS Response IOCB entry structure definition for 24xx. | ||
569 | * The ABTS response to the ABTS received is sent by the | ||
570 | * target driver to the ISP 24xx. | ||
571 | * The IOCB is placed on the request queue. | ||
572 | */ | ||
573 | struct abts_resp_to_24xx { | ||
574 | uint8_t entry_type; /* Entry type. */ | ||
575 | uint8_t entry_count; /* Entry count. */ | ||
576 | uint8_t sys_define; /* System defined. */ | ||
577 | uint8_t entry_status; /* Entry Status. */ | ||
578 | uint32_t handle; | ||
579 | uint16_t reserved_1; | ||
580 | uint16_t nport_handle; | ||
581 | uint16_t control_flags; | ||
582 | #define ABTS_CONTR_FLG_TERM_EXCHG BIT_0 | ||
583 | uint8_t vp_index; | ||
584 | uint8_t reserved_3:4; | ||
585 | uint8_t sof_type:4; | ||
586 | uint32_t exchange_address; | ||
587 | struct fcp_hdr_le fcp_hdr_le; | ||
588 | union { | ||
589 | struct ba_acc_le ba_acct; | ||
590 | struct ba_rjt_le ba_rjt; | ||
591 | } __packed payload; | ||
592 | uint32_t reserved_4; | ||
593 | uint32_t exchange_addr_to_abort; | ||
594 | } __packed; | ||
595 | |||
596 | /* | ||
597 | * ISP queue - ABTS Response IOCB from ISP24xx Firmware entry structure. | ||
598 | * The ABTS response with completion status to the ABTS response | ||
599 | * (sent by the target driver to the ISP 24xx) is sent by the | ||
600 | * ISP24xx firmware to the target driver. | ||
601 | * The IOCB is placed on the response queue. | ||
602 | */ | ||
603 | struct abts_resp_from_24xx_fw { | ||
604 | uint8_t entry_type; /* Entry type. */ | ||
605 | uint8_t entry_count; /* Entry count. */ | ||
606 | uint8_t sys_define; /* System defined. */ | ||
607 | uint8_t entry_status; /* Entry Status. */ | ||
608 | uint32_t handle; | ||
609 | uint16_t compl_status; | ||
610 | #define ABTS_RESP_COMPL_SUCCESS 0 | ||
611 | #define ABTS_RESP_COMPL_SUBCODE_ERROR 0x31 | ||
612 | uint16_t nport_handle; | ||
613 | uint16_t reserved_1; | ||
614 | uint8_t reserved_2; | ||
615 | uint8_t reserved_3:4; | ||
616 | uint8_t sof_type:4; | ||
617 | uint32_t exchange_address; | ||
618 | struct fcp_hdr_le fcp_hdr_le; | ||
619 | uint8_t reserved_4[8]; | ||
620 | uint32_t error_subcode1; | ||
621 | #define ABTS_RESP_SUBCODE_ERR_ABORTED_EXCH_NOT_TERM 0x1E | ||
622 | uint32_t error_subcode2; | ||
623 | uint32_t exchange_addr_to_abort; | ||
624 | } __packed; | ||
625 | |||
626 | /********************************************************************\ | ||
627 | * Type Definitions used by initiator & target halves | ||
628 | \********************************************************************/ | ||
629 | |||
630 | struct qla_tgt_mgmt_cmd; | ||
631 | struct qla_tgt_sess; | ||
632 | |||
633 | /* | ||
634 | * This structure provides a template of function calls that the | ||
635 | * target driver (from within qla_target.c) can issue to the | ||
636 | * target module (tcm_qla2xxx). | ||
637 | */ | ||
638 | struct qla_tgt_func_tmpl { | ||
639 | |||
640 | int (*handle_cmd)(struct scsi_qla_host *, struct qla_tgt_cmd *, | ||
641 | unsigned char *, uint32_t, int, int, int); | ||
642 | int (*handle_data)(struct qla_tgt_cmd *); | ||
643 | int (*handle_tmr)(struct qla_tgt_mgmt_cmd *, uint32_t, uint8_t, | ||
644 | uint32_t); | ||
645 | void (*free_cmd)(struct qla_tgt_cmd *); | ||
646 | void (*free_mcmd)(struct qla_tgt_mgmt_cmd *); | ||
647 | void (*free_session)(struct qla_tgt_sess *); | ||
648 | |||
649 | int (*check_initiator_node_acl)(struct scsi_qla_host *, unsigned char *, | ||
650 | void *, uint8_t *, uint16_t); | ||
651 | struct qla_tgt_sess *(*find_sess_by_loop_id)(struct scsi_qla_host *, | ||
652 | const uint16_t); | ||
653 | struct qla_tgt_sess *(*find_sess_by_s_id)(struct scsi_qla_host *, | ||
654 | const uint8_t *); | ||
655 | void (*clear_nacl_from_fcport_map)(struct qla_tgt_sess *); | ||
656 | void (*put_sess)(struct qla_tgt_sess *); | ||
657 | void (*shutdown_sess)(struct qla_tgt_sess *); | ||
658 | }; | ||
659 | |||
660 | int qla2x00_wait_for_hba_online(struct scsi_qla_host *); | ||
661 | |||
662 | #include <target/target_core_base.h> | ||
663 | |||
664 | #define QLA_TGT_TIMEOUT 10 /* in seconds */ | ||
665 | |||
666 | #define QLA_TGT_MAX_HW_PENDING_TIME 60 /* in seconds */ | ||
667 | |||
668 | /* Immediate notify status constants */ | ||
669 | #define IMM_NTFY_LIP_RESET 0x000E | ||
670 | #define IMM_NTFY_LIP_LINK_REINIT 0x000F | ||
671 | #define IMM_NTFY_IOCB_OVERFLOW 0x0016 | ||
672 | #define IMM_NTFY_ABORT_TASK 0x0020 | ||
673 | #define IMM_NTFY_PORT_LOGOUT 0x0029 | ||
674 | #define IMM_NTFY_PORT_CONFIG 0x002A | ||
675 | #define IMM_NTFY_GLBL_TPRLO 0x002D | ||
676 | #define IMM_NTFY_GLBL_LOGO 0x002E | ||
677 | #define IMM_NTFY_RESOURCE 0x0034 | ||
678 | #define IMM_NTFY_MSG_RX 0x0036 | ||
679 | #define IMM_NTFY_SRR 0x0045 | ||
680 | #define IMM_NTFY_ELS 0x0046 | ||
681 | |||
682 | /* Immediate notify task flags */ | ||
683 | #define IMM_NTFY_TASK_MGMT_SHIFT 8 | ||
684 | |||
685 | #define QLA_TGT_CLEAR_ACA 0x40 | ||
686 | #define QLA_TGT_TARGET_RESET 0x20 | ||
687 | #define QLA_TGT_LUN_RESET 0x10 | ||
688 | #define QLA_TGT_CLEAR_TS 0x04 | ||
689 | #define QLA_TGT_ABORT_TS 0x02 | ||
690 | #define QLA_TGT_ABORT_ALL_SESS 0xFFFF | ||
691 | #define QLA_TGT_ABORT_ALL 0xFFFE | ||
692 | #define QLA_TGT_NEXUS_LOSS_SESS 0xFFFD | ||
693 | #define QLA_TGT_NEXUS_LOSS 0xFFFC | ||
694 | |||
695 | /* Notify Acknowledge flags */ | ||
696 | #define NOTIFY_ACK_RES_COUNT BIT_8 | ||
697 | #define NOTIFY_ACK_CLEAR_LIP_RESET BIT_5 | ||
698 | #define NOTIFY_ACK_TM_RESP_CODE_VALID BIT_4 | ||
699 | |||
700 | /* Command's states */ | ||
701 | #define QLA_TGT_STATE_NEW 0 /* New command + target processing */ | ||
702 | #define QLA_TGT_STATE_NEED_DATA 1 /* target needs data to continue */ | ||
703 | #define QLA_TGT_STATE_DATA_IN 2 /* Data arrived + target processing */ | ||
704 | #define QLA_TGT_STATE_PROCESSED 3 /* target done processing */ | ||
705 | #define QLA_TGT_STATE_ABORTED 4 /* Command aborted */ | ||
706 | |||
707 | /* Special handles */ | ||
708 | #define QLA_TGT_NULL_HANDLE 0 | ||
709 | #define QLA_TGT_SKIP_HANDLE (0xFFFFFFFF & ~CTIO_COMPLETION_HANDLE_MARK) | ||
710 | |||
711 | /* ATIO task_codes field */ | ||
712 | #define ATIO_SIMPLE_QUEUE 0 | ||
713 | #define ATIO_HEAD_OF_QUEUE 1 | ||
714 | #define ATIO_ORDERED_QUEUE 2 | ||
715 | #define ATIO_ACA_QUEUE 4 | ||
716 | #define ATIO_UNTAGGED 5 | ||
717 | |||
718 | /* TM failed response codes, see FCP (9.4.11 FCP_RSP_INFO) */ | ||
719 | #define FC_TM_SUCCESS 0 | ||
720 | #define FC_TM_BAD_FCP_DATA 1 | ||
721 | #define FC_TM_BAD_CMD 2 | ||
722 | #define FC_TM_FCP_DATA_MISMATCH 3 | ||
723 | #define FC_TM_REJECT 4 | ||
724 | #define FC_TM_FAILED 5 | ||
725 | |||
726 | /* | ||
727 | * Error code of qlt_pre_xmit_response() meaning that cmd's exchange was | ||
728 | * terminated, so no more actions is needed and success should be returned | ||
729 | * to target. | ||
730 | */ | ||
731 | #define QLA_TGT_PRE_XMIT_RESP_CMD_ABORTED 0x1717 | ||
732 | |||
733 | #if (BITS_PER_LONG > 32) || defined(CONFIG_HIGHMEM64G) | ||
734 | #define pci_dma_lo32(a) (a & 0xffffffff) | ||
735 | #define pci_dma_hi32(a) ((((a) >> 16)>>16) & 0xffffffff) | ||
736 | #else | ||
737 | #define pci_dma_lo32(a) (a & 0xffffffff) | ||
738 | #define pci_dma_hi32(a) 0 | ||
739 | #endif | ||
740 | |||
741 | #define QLA_TGT_SENSE_VALID(sense) ((sense != NULL) && \ | ||
742 | (((const uint8_t *)(sense))[0] & 0x70) == 0x70) | ||
743 | |||
744 | struct qla_port_24xx_data { | ||
745 | uint8_t port_name[WWN_SIZE]; | ||
746 | uint16_t loop_id; | ||
747 | uint16_t reserved; | ||
748 | }; | ||
749 | |||
750 | struct qla_tgt { | ||
751 | struct scsi_qla_host *vha; | ||
752 | struct qla_hw_data *ha; | ||
753 | |||
754 | /* | ||
755 | * To sync between IRQ handlers and qlt_target_release(). Needed, | ||
756 | * because req_pkt() can drop/reaquire HW lock inside. Protected by | ||
757 | * HW lock. | ||
758 | */ | ||
759 | int irq_cmd_count; | ||
760 | |||
761 | int datasegs_per_cmd, datasegs_per_cont, sg_tablesize; | ||
762 | |||
763 | /* Target's flags, serialized by pha->hardware_lock */ | ||
764 | unsigned int tgt_enable_64bit_addr:1; /* 64-bits PCI addr enabled */ | ||
765 | unsigned int link_reinit_iocb_pending:1; | ||
766 | |||
767 | /* | ||
768 | * Protected by tgt_mutex AND hardware_lock for writing and tgt_mutex | ||
769 | * OR hardware_lock for reading. | ||
770 | */ | ||
771 | int tgt_stop; /* the target mode driver is being stopped */ | ||
772 | int tgt_stopped; /* the target mode driver has been stopped */ | ||
773 | |||
774 | /* Count of sessions refering qla_tgt. Protected by hardware_lock. */ | ||
775 | int sess_count; | ||
776 | |||
777 | /* Protected by hardware_lock. Addition also protected by tgt_mutex. */ | ||
778 | struct list_head sess_list; | ||
779 | |||
780 | /* Protected by hardware_lock */ | ||
781 | struct list_head del_sess_list; | ||
782 | struct delayed_work sess_del_work; | ||
783 | |||
784 | spinlock_t sess_work_lock; | ||
785 | struct list_head sess_works_list; | ||
786 | struct work_struct sess_work; | ||
787 | |||
788 | struct imm_ntfy_from_isp link_reinit_iocb; | ||
789 | wait_queue_head_t waitQ; | ||
790 | int notify_ack_expected; | ||
791 | int abts_resp_expected; | ||
792 | int modify_lun_expected; | ||
793 | |||
794 | int ctio_srr_id; | ||
795 | int imm_srr_id; | ||
796 | spinlock_t srr_lock; | ||
797 | struct list_head srr_ctio_list; | ||
798 | struct list_head srr_imm_list; | ||
799 | struct work_struct srr_work; | ||
800 | |||
801 | atomic_t tgt_global_resets_count; | ||
802 | |||
803 | struct list_head tgt_list_entry; | ||
804 | }; | ||
805 | |||
806 | /* | ||
807 | * Equivilant to IT Nexus (Initiator-Target) | ||
808 | */ | ||
809 | struct qla_tgt_sess { | ||
810 | uint16_t loop_id; | ||
811 | port_id_t s_id; | ||
812 | |||
813 | unsigned int conf_compl_supported:1; | ||
814 | unsigned int deleted:1; | ||
815 | unsigned int local:1; | ||
816 | unsigned int tearing_down:1; | ||
817 | |||
818 | struct se_session *se_sess; | ||
819 | struct scsi_qla_host *vha; | ||
820 | struct qla_tgt *tgt; | ||
821 | |||
822 | struct list_head sess_list_entry; | ||
823 | unsigned long expires; | ||
824 | struct list_head del_list_entry; | ||
825 | |||
826 | uint8_t port_name[WWN_SIZE]; | ||
827 | struct work_struct free_work; | ||
828 | }; | ||
829 | |||
830 | struct qla_tgt_cmd { | ||
831 | struct qla_tgt_sess *sess; | ||
832 | int state; | ||
833 | struct se_cmd se_cmd; | ||
834 | struct work_struct free_work; | ||
835 | struct work_struct work; | ||
836 | /* Sense buffer that will be mapped into outgoing status */ | ||
837 | unsigned char sense_buffer[TRANSPORT_SENSE_BUFFER]; | ||
838 | |||
839 | /* to save extra sess dereferences */ | ||
840 | unsigned int conf_compl_supported:1; | ||
841 | unsigned int sg_mapped:1; | ||
842 | unsigned int free_sg:1; | ||
843 | unsigned int aborted:1; /* Needed in case of SRR */ | ||
844 | unsigned int write_data_transferred:1; | ||
845 | |||
846 | struct scatterlist *sg; /* cmd data buffer SG vector */ | ||
847 | int sg_cnt; /* SG segments count */ | ||
848 | int bufflen; /* cmd buffer length */ | ||
849 | int offset; | ||
850 | uint32_t tag; | ||
851 | uint32_t unpacked_lun; | ||
852 | enum dma_data_direction dma_data_direction; | ||
853 | |||
854 | uint16_t loop_id; /* to save extra sess dereferences */ | ||
855 | struct qla_tgt *tgt; /* to save extra sess dereferences */ | ||
856 | struct scsi_qla_host *vha; | ||
857 | struct list_head cmd_list; | ||
858 | |||
859 | struct atio_from_isp atio; | ||
860 | }; | ||
861 | |||
862 | struct qla_tgt_sess_work_param { | ||
863 | struct list_head sess_works_list_entry; | ||
864 | |||
865 | #define QLA_TGT_SESS_WORK_ABORT 1 | ||
866 | #define QLA_TGT_SESS_WORK_TM 2 | ||
867 | int type; | ||
868 | |||
869 | union { | ||
870 | struct abts_recv_from_24xx abts; | ||
871 | struct imm_ntfy_from_isp tm_iocb; | ||
872 | struct atio_from_isp tm_iocb2; | ||
873 | }; | ||
874 | }; | ||
875 | |||
876 | struct qla_tgt_mgmt_cmd { | ||
877 | uint8_t tmr_func; | ||
878 | uint8_t fc_tm_rsp; | ||
879 | struct qla_tgt_sess *sess; | ||
880 | struct se_cmd se_cmd; | ||
881 | struct work_struct free_work; | ||
882 | unsigned int flags; | ||
883 | #define QLA24XX_MGMT_SEND_NACK 1 | ||
884 | union { | ||
885 | struct atio_from_isp atio; | ||
886 | struct imm_ntfy_from_isp imm_ntfy; | ||
887 | struct abts_recv_from_24xx abts; | ||
888 | } __packed orig_iocb; | ||
889 | }; | ||
890 | |||
891 | struct qla_tgt_prm { | ||
892 | struct qla_tgt_cmd *cmd; | ||
893 | struct qla_tgt *tgt; | ||
894 | void *pkt; | ||
895 | struct scatterlist *sg; /* cmd data buffer SG vector */ | ||
896 | int seg_cnt; | ||
897 | int req_cnt; | ||
898 | uint16_t rq_result; | ||
899 | uint16_t scsi_status; | ||
900 | unsigned char *sense_buffer; | ||
901 | int sense_buffer_len; | ||
902 | int residual; | ||
903 | int add_status_pkt; | ||
904 | }; | ||
905 | |||
906 | struct qla_tgt_srr_imm { | ||
907 | struct list_head srr_list_entry; | ||
908 | int srr_id; | ||
909 | struct imm_ntfy_from_isp imm_ntfy; | ||
910 | }; | ||
911 | |||
912 | struct qla_tgt_srr_ctio { | ||
913 | struct list_head srr_list_entry; | ||
914 | int srr_id; | ||
915 | struct qla_tgt_cmd *cmd; | ||
916 | }; | ||
917 | |||
918 | #define QLA_TGT_XMIT_DATA 1 | ||
919 | #define QLA_TGT_XMIT_STATUS 2 | ||
920 | #define QLA_TGT_XMIT_ALL (QLA_TGT_XMIT_STATUS|QLA_TGT_XMIT_DATA) | ||
921 | |||
922 | #include <linux/version.h> | ||
923 | |||
924 | extern struct qla_tgt_data qla_target; | ||
925 | /* | ||
926 | * Internal function prototypes | ||
927 | */ | ||
928 | void qlt_disable_vha(struct scsi_qla_host *); | ||
929 | |||
930 | /* | ||
931 | * Function prototypes for qla_target.c logic used by qla2xxx LLD code. | ||
932 | */ | ||
933 | extern int qlt_add_target(struct qla_hw_data *, struct scsi_qla_host *); | ||
934 | extern int qlt_remove_target(struct qla_hw_data *, struct scsi_qla_host *); | ||
935 | extern int qlt_lport_register(struct qla_tgt_func_tmpl *, u64, | ||
936 | int (*callback)(struct scsi_qla_host *), void *); | ||
937 | extern void qlt_lport_deregister(struct scsi_qla_host *); | ||
938 | extern void qlt_unreg_sess(struct qla_tgt_sess *); | ||
939 | extern void qlt_fc_port_added(struct scsi_qla_host *, fc_port_t *); | ||
940 | extern void qlt_fc_port_deleted(struct scsi_qla_host *, fc_port_t *); | ||
941 | extern void qlt_set_mode(struct scsi_qla_host *ha); | ||
942 | extern void qlt_clear_mode(struct scsi_qla_host *ha); | ||
943 | extern int __init qlt_init(void); | ||
944 | extern void qlt_exit(void); | ||
945 | extern void qlt_update_vp_map(struct scsi_qla_host *, int); | ||
946 | |||
947 | /* | ||
948 | * This macro is used during early initializations when host->active_mode | ||
949 | * is not set. Right now, ha value is ignored. | ||
950 | */ | ||
951 | #define QLA_TGT_MODE_ENABLED() (ql2x_ini_mode != QLA2XXX_INI_MODE_ENABLED) | ||
952 | |||
953 | static inline bool qla_tgt_mode_enabled(struct scsi_qla_host *ha) | ||
954 | { | ||
955 | return ha->host->active_mode & MODE_TARGET; | ||
956 | } | ||
957 | |||
958 | static inline bool qla_ini_mode_enabled(struct scsi_qla_host *ha) | ||
959 | { | ||
960 | return ha->host->active_mode & MODE_INITIATOR; | ||
961 | } | ||
962 | |||
963 | static inline void qla_reverse_ini_mode(struct scsi_qla_host *ha) | ||
964 | { | ||
965 | if (ha->host->active_mode & MODE_INITIATOR) | ||
966 | ha->host->active_mode &= ~MODE_INITIATOR; | ||
967 | else | ||
968 | ha->host->active_mode |= MODE_INITIATOR; | ||
969 | } | ||
970 | |||
971 | /* | ||
972 | * Exported symbols from qla_target.c LLD logic used by qla2xxx code.. | ||
973 | */ | ||
974 | extern void qlt_24xx_atio_pkt_all_vps(struct scsi_qla_host *, | ||
975 | struct atio_from_isp *); | ||
976 | extern void qlt_response_pkt_all_vps(struct scsi_qla_host *, response_t *); | ||
977 | extern int qlt_rdy_to_xfer(struct qla_tgt_cmd *); | ||
978 | extern int qlt_xmit_response(struct qla_tgt_cmd *, int, uint8_t); | ||
979 | extern void qlt_xmit_tm_rsp(struct qla_tgt_mgmt_cmd *); | ||
980 | extern void qlt_free_mcmd(struct qla_tgt_mgmt_cmd *); | ||
981 | extern void qlt_free_cmd(struct qla_tgt_cmd *cmd); | ||
982 | extern void qlt_ctio_completion(struct scsi_qla_host *, uint32_t); | ||
983 | extern void qlt_async_event(uint16_t, struct scsi_qla_host *, uint16_t *); | ||
984 | extern void qlt_enable_vha(struct scsi_qla_host *); | ||
985 | extern void qlt_vport_create(struct scsi_qla_host *, struct qla_hw_data *); | ||
986 | extern void qlt_rff_id(struct scsi_qla_host *, struct ct_sns_req *); | ||
987 | extern void qlt_init_atio_q_entries(struct scsi_qla_host *); | ||
988 | extern void qlt_24xx_process_atio_queue(struct scsi_qla_host *); | ||
989 | extern void qlt_24xx_config_rings(struct scsi_qla_host *, | ||
990 | device_reg_t __iomem *); | ||
991 | extern void qlt_24xx_config_nvram_stage1(struct scsi_qla_host *, | ||
992 | struct nvram_24xx *); | ||
993 | extern void qlt_24xx_config_nvram_stage2(struct scsi_qla_host *, | ||
994 | struct init_cb_24xx *); | ||
995 | extern int qlt_24xx_process_response_error(struct scsi_qla_host *, | ||
996 | struct sts_entry_24xx *); | ||
997 | extern void qlt_modify_vp_config(struct scsi_qla_host *, | ||
998 | struct vp_config_entry_24xx *); | ||
999 | extern void qlt_probe_one_stage1(struct scsi_qla_host *, struct qla_hw_data *); | ||
1000 | extern int qlt_mem_alloc(struct qla_hw_data *); | ||
1001 | extern void qlt_mem_free(struct qla_hw_data *); | ||
1002 | extern void qlt_stop_phase1(struct qla_tgt *); | ||
1003 | extern void qlt_stop_phase2(struct qla_tgt *); | ||
1004 | |||
1005 | #endif /* __QLA_TARGET_H */ | ||