Linux Kernel
3.7.1
Main Page
Related Pages
Modules
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
drivers
scsi
qla2xxx
qla_target.h
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2004 - 2010 Vladislav Bolkhovitin <
[email protected]
>
3
* Copyright (C) 2004 - 2005 Leonid Stoljar
4
* Copyright (C) 2006 Nathaniel Clark <
[email protected]
>
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 <
[email protected]
>
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
void
(*
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
void
(*
update_sess
)(
struct
qla_tgt_sess
*,
port_id_t
,
uint16_t
,
bool
);
652
struct
qla_tgt_sess
*(*find_sess_by_loop_id)(
struct
scsi_qla_host
*,
653
const
uint16_t
);
654
struct
qla_tgt_sess
*(*find_sess_by_s_id)(
struct
scsi_qla_host
*,
655
const
uint8_t
*);
656
void
(*
clear_nacl_from_fcport_map
)(
struct
qla_tgt_sess
*);
657
void
(*
put_sess
)(
struct
qla_tgt_sess
*);
658
void
(*
shutdown_sess
)(
struct
qla_tgt_sess
*);
659
};
660
661
int
qla2x00_wait_for_hba_online
(
struct
scsi_qla_host
*);
662
663
#include <
target/target_core_base.h
>
664
665
#define QLA_TGT_TIMEOUT 10
/* in seconds */
666
667
#define QLA_TGT_MAX_HW_PENDING_TIME 60
/* in seconds */
668
669
/* Immediate notify status constants */
670
#define IMM_NTFY_LIP_RESET 0x000E
671
#define IMM_NTFY_LIP_LINK_REINIT 0x000F
672
#define IMM_NTFY_IOCB_OVERFLOW 0x0016
673
#define IMM_NTFY_ABORT_TASK 0x0020
674
#define IMM_NTFY_PORT_LOGOUT 0x0029
675
#define IMM_NTFY_PORT_CONFIG 0x002A
676
#define IMM_NTFY_GLBL_TPRLO 0x002D
677
#define IMM_NTFY_GLBL_LOGO 0x002E
678
#define IMM_NTFY_RESOURCE 0x0034
679
#define IMM_NTFY_MSG_RX 0x0036
680
#define IMM_NTFY_SRR 0x0045
681
#define IMM_NTFY_ELS 0x0046
682
683
/* Immediate notify task flags */
684
#define IMM_NTFY_TASK_MGMT_SHIFT 8
685
686
#define QLA_TGT_CLEAR_ACA 0x40
687
#define QLA_TGT_TARGET_RESET 0x20
688
#define QLA_TGT_LUN_RESET 0x10
689
#define QLA_TGT_CLEAR_TS 0x04
690
#define QLA_TGT_ABORT_TS 0x02
691
#define QLA_TGT_ABORT_ALL_SESS 0xFFFF
692
#define QLA_TGT_ABORT_ALL 0xFFFE
693
#define QLA_TGT_NEXUS_LOSS_SESS 0xFFFD
694
#define QLA_TGT_NEXUS_LOSS 0xFFFC
695
696
/* Notify Acknowledge flags */
697
#define NOTIFY_ACK_RES_COUNT BIT_8
698
#define NOTIFY_ACK_CLEAR_LIP_RESET BIT_5
699
#define NOTIFY_ACK_TM_RESP_CODE_VALID BIT_4
700
701
/* Command's states */
702
#define QLA_TGT_STATE_NEW 0
/* New command + target processing */
703
#define QLA_TGT_STATE_NEED_DATA 1
/* target needs data to continue */
704
#define QLA_TGT_STATE_DATA_IN 2
/* Data arrived + target processing */
705
#define QLA_TGT_STATE_PROCESSED 3
/* target done processing */
706
#define QLA_TGT_STATE_ABORTED 4
/* Command aborted */
707
708
/* Special handles */
709
#define QLA_TGT_NULL_HANDLE 0
710
#define QLA_TGT_SKIP_HANDLE (0xFFFFFFFF & ~CTIO_COMPLETION_HANDLE_MARK)
711
712
/* ATIO task_codes field */
713
#define ATIO_SIMPLE_QUEUE 0
714
#define ATIO_HEAD_OF_QUEUE 1
715
#define ATIO_ORDERED_QUEUE 2
716
#define ATIO_ACA_QUEUE 4
717
#define ATIO_UNTAGGED 5
718
719
/* TM failed response codes, see FCP (9.4.11 FCP_RSP_INFO) */
720
#define FC_TM_SUCCESS 0
721
#define FC_TM_BAD_FCP_DATA 1
722
#define FC_TM_BAD_CMD 2
723
#define FC_TM_FCP_DATA_MISMATCH 3
724
#define FC_TM_REJECT 4
725
#define FC_TM_FAILED 5
726
727
/*
728
* Error code of qlt_pre_xmit_response() meaning that cmd's exchange was
729
* terminated, so no more actions is needed and success should be returned
730
* to target.
731
*/
732
#define QLA_TGT_PRE_XMIT_RESP_CMD_ABORTED 0x1717
733
734
#if (BITS_PER_LONG > 32) || defined(CONFIG_HIGHMEM64G)
735
#define pci_dma_lo32(a) (a & 0xffffffff)
736
#define pci_dma_hi32(a) ((((a) >> 16)>>16) & 0xffffffff)
737
#else
738
#define pci_dma_lo32(a) (a & 0xffffffff)
739
#define pci_dma_hi32(a) 0
740
#endif
741
742
#define QLA_TGT_SENSE_VALID(sense) ((sense != NULL) && \
743
(((const uint8_t *)(sense))[0] & 0x70) == 0x70)
744
745
struct
qla_port_24xx_data
{
746
uint8_t
port_name
[
WWN_SIZE
];
747
uint16_t
loop_id
;
748
uint16_t
reserved
;
749
};
750
751
struct
qla_tgt
{
752
struct
scsi_qla_host
*
vha
;
753
struct
qla_hw_data
*
ha
;
754
755
/*
756
* To sync between IRQ handlers and qlt_target_release(). Needed,
757
* because req_pkt() can drop/reaquire HW lock inside. Protected by
758
* HW lock.
759
*/
760
int
irq_cmd_count
;
761
762
int
datasegs_per_cmd
,
datasegs_per_cont
,
sg_tablesize
;
763
764
/* Target's flags, serialized by pha->hardware_lock */
765
unsigned
int
tgt_enable_64bit_addr
:1;
/* 64-bits PCI addr enabled */
766
unsigned
int
link_reinit_iocb_pending
:1;
767
768
/*
769
* Protected by tgt_mutex AND hardware_lock for writing and tgt_mutex
770
* OR hardware_lock for reading.
771
*/
772
int
tgt_stop
;
/* the target mode driver is being stopped */
773
int
tgt_stopped
;
/* the target mode driver has been stopped */
774
775
/* Count of sessions refering qla_tgt. Protected by hardware_lock. */
776
int
sess_count
;
777
778
/* Protected by hardware_lock. Addition also protected by tgt_mutex. */
779
struct
list_head
sess_list
;
780
781
/* Protected by hardware_lock */
782
struct
list_head
del_sess_list
;
783
struct
delayed_work
sess_del_work
;
784
785
spinlock_t
sess_work_lock
;
786
struct
list_head
sess_works_list
;
787
struct
work_struct
sess_work
;
788
789
struct
imm_ntfy_from_isp
link_reinit_iocb
;
790
wait_queue_head_t
waitQ
;
791
int
notify_ack_expected
;
792
int
abts_resp_expected
;
793
int
modify_lun_expected
;
794
795
int
ctio_srr_id
;
796
int
imm_srr_id
;
797
spinlock_t
srr_lock
;
798
struct
list_head
srr_ctio_list
;
799
struct
list_head
srr_imm_list
;
800
struct
work_struct
srr_work
;
801
802
atomic_t
tgt_global_resets_count
;
803
804
struct
list_head
tgt_list_entry
;
805
};
806
807
/*
808
* Equivilant to IT Nexus (Initiator-Target)
809
*/
810
struct
qla_tgt_sess
{
811
uint16_t
loop_id
;
812
port_id_t
s_id
;
813
814
unsigned
int
conf_compl_supported
:1;
815
unsigned
int
deleted
:1;
816
unsigned
int
local
: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
923
extern
struct
qla_tgt_data
qla_target
;
924
/*
925
* Internal function prototypes
926
*/
927
void
qlt_disable_vha
(
struct
scsi_qla_host
*);
928
929
/*
930
* Function prototypes for qla_target.c logic used by qla2xxx LLD code.
931
*/
932
extern
int
qlt_add_target
(
struct
qla_hw_data
*,
struct
scsi_qla_host
*);
933
extern
int
qlt_remove_target
(
struct
qla_hw_data
*,
struct
scsi_qla_host
*);
934
extern
int
qlt_lport_register
(
struct
qla_tgt_func_tmpl
*,
u64
,
935
int
(*
callback
)(
struct
scsi_qla_host
*),
void
*);
936
extern
void
qlt_lport_deregister
(
struct
scsi_qla_host
*);
937
extern
void
qlt_unreg_sess
(
struct
qla_tgt_sess
*);
938
extern
void
qlt_fc_port_added
(
struct
scsi_qla_host
*,
fc_port_t
*);
939
extern
void
qlt_fc_port_deleted
(
struct
scsi_qla_host
*,
fc_port_t
*);
940
extern
void
qlt_set_mode
(
struct
scsi_qla_host
*ha);
941
extern
void
qlt_clear_mode
(
struct
scsi_qla_host
*ha);
942
extern
int
__init
qlt_init
(
void
);
943
extern
void
qlt_exit
(
void
);
944
extern
void
qlt_update_vp_map
(
struct
scsi_qla_host
*,
int
);
945
946
/*
947
* This macro is used during early initializations when host->active_mode
948
* is not set. Right now, ha value is ignored.
949
*/
950
#define QLA_TGT_MODE_ENABLED() (ql2x_ini_mode != QLA2XXX_INI_MODE_ENABLED)
951
952
static
inline
bool
qla_tgt_mode_enabled(
struct
scsi_qla_host
*ha)
953
{
954
return
ha->
host
->active_mode &
MODE_TARGET
;
955
}
956
957
static
inline
bool
qla_ini_mode_enabled(
struct
scsi_qla_host
*ha)
958
{
959
return
ha->
host
->active_mode &
MODE_INITIATOR
;
960
}
961
962
static
inline
void
qla_reverse_ini_mode(
struct
scsi_qla_host
*ha)
963
{
964
if
(ha->
host
->active_mode &
MODE_INITIATOR
)
965
ha->
host
->active_mode &= ~
MODE_INITIATOR
;
966
else
967
ha->
host
->active_mode |=
MODE_INITIATOR
;
968
}
969
970
/*
971
* Exported symbols from qla_target.c LLD logic used by qla2xxx code..
972
*/
973
extern
void
qlt_24xx_atio_pkt_all_vps
(
struct
scsi_qla_host
*,
974
struct
atio_from_isp
*);
975
extern
void
qlt_response_pkt_all_vps
(
struct
scsi_qla_host
*,
response_t
*);
976
extern
int
qlt_rdy_to_xfer
(
struct
qla_tgt_cmd
*);
977
extern
int
qlt_xmit_response
(
struct
qla_tgt_cmd
*,
int
,
uint8_t
);
978
extern
void
qlt_xmit_tm_rsp
(
struct
qla_tgt_mgmt_cmd
*);
979
extern
void
qlt_free_mcmd
(
struct
qla_tgt_mgmt_cmd
*);
980
extern
void
qlt_free_cmd
(
struct
qla_tgt_cmd
*
cmd
);
981
extern
void
qlt_ctio_completion
(
struct
scsi_qla_host
*,
uint32_t
);
982
extern
void
qlt_async_event
(
uint16_t
,
struct
scsi_qla_host
*,
uint16_t
*);
983
extern
void
qlt_enable_vha
(
struct
scsi_qla_host
*);
984
extern
void
qlt_vport_create
(
struct
scsi_qla_host
*,
struct
qla_hw_data
*);
985
extern
void
qlt_rff_id
(
struct
scsi_qla_host
*,
struct
ct_sns_req
*);
986
extern
void
qlt_init_atio_q_entries
(
struct
scsi_qla_host
*);
987
extern
void
qlt_24xx_process_atio_queue
(
struct
scsi_qla_host
*);
988
extern
void
qlt_24xx_config_rings
(
struct
scsi_qla_host
*,
989
device_reg_t
__iomem
*);
990
extern
void
qlt_24xx_config_nvram_stage1
(
struct
scsi_qla_host
*,
991
struct
nvram_24xx
*);
992
extern
void
qlt_24xx_config_nvram_stage2
(
struct
scsi_qla_host
*,
993
struct
init_cb_24xx
*);
994
extern
int
qlt_24xx_process_response_error
(
struct
scsi_qla_host
*,
995
struct
sts_entry_24xx
*);
996
extern
void
qlt_modify_vp_config
(
struct
scsi_qla_host
*,
997
struct
vp_config_entry_24xx
*);
998
extern
void
qlt_probe_one_stage1
(
struct
scsi_qla_host
*,
struct
qla_hw_data
*);
999
extern
int
qlt_mem_alloc
(
struct
qla_hw_data
*);
1000
extern
void
qlt_mem_free
(
struct
qla_hw_data
*);
1001
extern
void
qlt_stop_phase1
(
struct
qla_tgt
*);
1002
extern
void
qlt_stop_phase2
(
struct
qla_tgt
*);
1003
1004
#endif
/* __QLA_TARGET_H */
Generated on Thu Jan 10 2013 14:23:53 for Linux Kernel by
1.8.2