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