1 /* 2 * ibmvfc.h -- driver for IBM Power Virtual Fibre Channel Adapter 3 * 4 * Written By: Brian King <brking@linux.vnet.ibm.com>, IBM Corporation 5 * 6 * Copyright (C) IBM Corporation, 2008 7 * 8 * This program is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License as published by 10 * the Free Software Foundation; either version 2 of the License, or 11 * (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, write to the Free Software 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 * 22 */ 23 24 #ifndef _IBMVFC_H 25 #define _IBMVFC_H 26 27 #include <linux/list.h> 28 #include <linux/types.h> 29 #include "viosrp.h" 30 31 #define IBMVFC_NAME "ibmvfc" 32 #define IBMVFC_DRIVER_VERSION "1.0.5" 33 #define IBMVFC_DRIVER_DATE "(March 19, 2009)" 34 35 #define IBMVFC_DEFAULT_TIMEOUT 60 36 #define IBMVFC_ADISC_CANCEL_TIMEOUT 45 37 #define IBMVFC_ADISC_TIMEOUT 15 38 #define IBMVFC_ADISC_PLUS_CANCEL_TIMEOUT \ 39 (IBMVFC_ADISC_TIMEOUT + IBMVFC_ADISC_CANCEL_TIMEOUT) 40 #define IBMVFC_INIT_TIMEOUT 120 41 #define IBMVFC_MAX_REQUESTS_DEFAULT 100 42 43 #define IBMVFC_DEBUG 0 44 #define IBMVFC_MAX_TARGETS 1024 45 #define IBMVFC_MAX_LUN 0xffffffff 46 #define IBMVFC_MAX_SECTORS 0xffffu 47 #define IBMVFC_MAX_DISC_THREADS 4 48 #define IBMVFC_TGT_MEMPOOL_SZ 64 49 #define IBMVFC_MAX_CMDS_PER_LUN 64 50 #define IBMVFC_MAX_HOST_INIT_RETRIES 6 51 #define IBMVFC_MAX_TGT_INIT_RETRIES 3 52 #define IBMVFC_DEV_LOSS_TMO (5 * 60) 53 #define IBMVFC_DEFAULT_LOG_LEVEL 2 54 #define IBMVFC_MAX_CDB_LEN 16 55 56 /* 57 * Ensure we have resources for ERP and initialization: 58 * 1 for ERP 59 * 1 for initialization 60 * 2 for each discovery thread 61 */ 62 #define IBMVFC_NUM_INTERNAL_REQ (1 + 1 + (disc_threads * 2)) 63 64 #define IBMVFC_MAD_SUCCESS 0x00 65 #define IBMVFC_MAD_NOT_SUPPORTED 0xF1 66 #define IBMVFC_MAD_FAILED 0xF7 67 #define IBMVFC_MAD_DRIVER_FAILED 0xEE 68 #define IBMVFC_MAD_CRQ_ERROR 0xEF 69 70 enum ibmvfc_crq_valid { 71 IBMVFC_CRQ_CMD_RSP = 0x80, 72 IBMVFC_CRQ_INIT_RSP = 0xC0, 73 IBMVFC_CRQ_XPORT_EVENT = 0xFF, 74 }; 75 76 enum ibmvfc_crq_format { 77 IBMVFC_CRQ_INIT = 0x01, 78 IBMVFC_CRQ_INIT_COMPLETE = 0x02, 79 IBMVFC_PARTITION_MIGRATED = 0x06, 80 }; 81 82 enum ibmvfc_cmd_status_flags { 83 IBMVFC_FABRIC_MAPPED = 0x0001, 84 IBMVFC_VIOS_FAILURE = 0x0002, 85 IBMVFC_FC_FAILURE = 0x0004, 86 IBMVFC_FC_SCSI_ERROR = 0x0008, 87 IBMVFC_HW_EVENT_LOGGED = 0x0010, 88 IBMVFC_VIOS_LOGGED = 0x0020, 89 }; 90 91 enum ibmvfc_fabric_mapped_errors { 92 IBMVFC_UNABLE_TO_ESTABLISH = 0x0001, 93 IBMVFC_XPORT_FAULT = 0x0002, 94 IBMVFC_CMD_TIMEOUT = 0x0003, 95 IBMVFC_ENETDOWN = 0x0004, 96 IBMVFC_HW_FAILURE = 0x0005, 97 IBMVFC_LINK_DOWN_ERR = 0x0006, 98 IBMVFC_LINK_DEAD_ERR = 0x0007, 99 IBMVFC_UNABLE_TO_REGISTER = 0x0008, 100 IBMVFC_XPORT_BUSY = 0x000A, 101 IBMVFC_XPORT_DEAD = 0x000B, 102 IBMVFC_CONFIG_ERROR = 0x000C, 103 IBMVFC_NAME_SERVER_FAIL = 0x000D, 104 IBMVFC_LINK_HALTED = 0x000E, 105 IBMVFC_XPORT_GENERAL = 0x8000, 106 }; 107 108 enum ibmvfc_vios_errors { 109 IBMVFC_CRQ_FAILURE = 0x0001, 110 IBMVFC_SW_FAILURE = 0x0002, 111 IBMVFC_INVALID_PARAMETER = 0x0003, 112 IBMVFC_MISSING_PARAMETER = 0x0004, 113 IBMVFC_HOST_IO_BUS = 0x0005, 114 IBMVFC_TRANS_CANCELLED = 0x0006, 115 IBMVFC_TRANS_CANCELLED_IMPLICIT = 0x0007, 116 IBMVFC_INSUFFICIENT_RESOURCE = 0x0008, 117 IBMVFC_PLOGI_REQUIRED = 0x0010, 118 IBMVFC_COMMAND_FAILED = 0x8000, 119 }; 120 121 enum ibmvfc_mad_types { 122 IBMVFC_NPIV_LOGIN = 0x0001, 123 IBMVFC_DISC_TARGETS = 0x0002, 124 IBMVFC_PORT_LOGIN = 0x0004, 125 IBMVFC_PROCESS_LOGIN = 0x0008, 126 IBMVFC_QUERY_TARGET = 0x0010, 127 IBMVFC_IMPLICIT_LOGOUT = 0x0040, 128 IBMVFC_PASSTHRU = 0x0200, 129 IBMVFC_TMF_MAD = 0x0100, 130 }; 131 132 struct ibmvfc_mad_common { 133 u32 version; 134 u32 reserved; 135 u32 opcode; 136 u16 status; 137 u16 length; 138 u64 tag; 139 }__attribute__((packed, aligned (8))); 140 141 struct ibmvfc_npiv_login_mad { 142 struct ibmvfc_mad_common common; 143 struct srp_direct_buf buffer; 144 }__attribute__((packed, aligned (8))); 145 146 #define IBMVFC_MAX_NAME 256 147 148 struct ibmvfc_npiv_login { 149 u32 ostype; 150 #define IBMVFC_OS_LINUX 0x02 151 u32 pad; 152 u64 max_dma_len; 153 u32 max_payload; 154 u32 max_response; 155 u32 partition_num; 156 u32 vfc_frame_version; 157 u16 fcp_version; 158 u16 flags; 159 #define IBMVFC_CLIENT_MIGRATED 0x01 160 #define IBMVFC_FLUSH_ON_HALT 0x02 161 u32 max_cmds; 162 u64 capabilities; 163 #define IBMVFC_CAN_MIGRATE 0x01 164 u64 node_name; 165 struct srp_direct_buf async; 166 u8 partition_name[IBMVFC_MAX_NAME]; 167 u8 device_name[IBMVFC_MAX_NAME]; 168 u8 drc_name[IBMVFC_MAX_NAME]; 169 u64 reserved2[2]; 170 }__attribute__((packed, aligned (8))); 171 172 struct ibmvfc_common_svc_parms { 173 u16 fcph_version; 174 u16 b2b_credit; 175 u16 features; 176 u16 bb_rcv_sz; /* upper nibble is BB_SC_N */ 177 u32 ratov; 178 u32 edtov; 179 }__attribute__((packed, aligned (4))); 180 181 struct ibmvfc_service_parms { 182 struct ibmvfc_common_svc_parms common; 183 u8 port_name[8]; 184 u8 node_name[8]; 185 u32 class1_parms[4]; 186 u32 class2_parms[4]; 187 u32 class3_parms[4]; 188 u32 obsolete[4]; 189 u32 vendor_version[4]; 190 u32 services_avail[2]; 191 u32 ext_len; 192 u32 reserved[30]; 193 u32 clk_sync_qos[2]; 194 }__attribute__((packed, aligned (4))); 195 196 struct ibmvfc_npiv_login_resp { 197 u32 version; 198 u16 status; 199 u16 error; 200 u32 flags; 201 #define IBMVFC_NATIVE_FC 0x01 202 #define IBMVFC_CAN_FLUSH_ON_HALT 0x08 203 u32 reserved; 204 u64 capabilites; 205 u32 max_cmds; 206 u32 scsi_id_sz; 207 u64 max_dma_len; 208 u64 scsi_id; 209 u64 port_name; 210 u64 node_name; 211 u64 link_speed; 212 u8 partition_name[IBMVFC_MAX_NAME]; 213 u8 device_name[IBMVFC_MAX_NAME]; 214 u8 port_loc_code[IBMVFC_MAX_NAME]; 215 u8 drc_name[IBMVFC_MAX_NAME]; 216 struct ibmvfc_service_parms service_parms; 217 u64 reserved2; 218 }__attribute__((packed, aligned (8))); 219 220 union ibmvfc_npiv_login_data { 221 struct ibmvfc_npiv_login login; 222 struct ibmvfc_npiv_login_resp resp; 223 }__attribute__((packed, aligned (8))); 224 225 struct ibmvfc_discover_targets_buf { 226 u32 scsi_id[1]; 227 #define IBMVFC_DISC_TGT_SCSI_ID_MASK 0x00ffffff 228 }; 229 230 struct ibmvfc_discover_targets { 231 struct ibmvfc_mad_common common; 232 struct srp_direct_buf buffer; 233 u32 flags; 234 u16 status; 235 u16 error; 236 u32 bufflen; 237 u32 num_avail; 238 u32 num_written; 239 u64 reserved[2]; 240 }__attribute__((packed, aligned (8))); 241 242 enum ibmvfc_fc_reason { 243 IBMVFC_INVALID_ELS_CMD_CODE = 0x01, 244 IBMVFC_INVALID_VERSION = 0x02, 245 IBMVFC_LOGICAL_ERROR = 0x03, 246 IBMVFC_INVALID_CT_IU_SIZE = 0x04, 247 IBMVFC_LOGICAL_BUSY = 0x05, 248 IBMVFC_PROTOCOL_ERROR = 0x07, 249 IBMVFC_UNABLE_TO_PERFORM_REQ = 0x09, 250 IBMVFC_CMD_NOT_SUPPORTED = 0x0B, 251 IBMVFC_SERVER_NOT_AVAIL = 0x0D, 252 IBMVFC_CMD_IN_PROGRESS = 0x0E, 253 IBMVFC_VENDOR_SPECIFIC = 0xFF, 254 }; 255 256 enum ibmvfc_fc_type { 257 IBMVFC_FABRIC_REJECT = 0x01, 258 IBMVFC_PORT_REJECT = 0x02, 259 IBMVFC_LS_REJECT = 0x03, 260 IBMVFC_FABRIC_BUSY = 0x04, 261 IBMVFC_PORT_BUSY = 0x05, 262 IBMVFC_BASIC_REJECT = 0x06, 263 }; 264 265 enum ibmvfc_gs_explain { 266 IBMVFC_PORT_NAME_NOT_REG = 0x02, 267 }; 268 269 struct ibmvfc_port_login { 270 struct ibmvfc_mad_common common; 271 u64 scsi_id; 272 u16 reserved; 273 u16 fc_service_class; 274 u32 blksz; 275 u32 hdr_per_blk; 276 u16 status; 277 u16 error; /* also fc_reason */ 278 u16 fc_explain; 279 u16 fc_type; 280 u32 reserved2; 281 struct ibmvfc_service_parms service_parms; 282 struct ibmvfc_service_parms service_parms_change; 283 u64 reserved3[2]; 284 }__attribute__((packed, aligned (8))); 285 286 struct ibmvfc_prli_svc_parms { 287 u8 type; 288 #define IBMVFC_SCSI_FCP_TYPE 0x08 289 u8 type_ext; 290 u16 flags; 291 #define IBMVFC_PRLI_ORIG_PA_VALID 0x8000 292 #define IBMVFC_PRLI_RESP_PA_VALID 0x4000 293 #define IBMVFC_PRLI_EST_IMG_PAIR 0x2000 294 u32 orig_pa; 295 u32 resp_pa; 296 u32 service_parms; 297 #define IBMVFC_PRLI_TASK_RETRY 0x00000200 298 #define IBMVFC_PRLI_RETRY 0x00000100 299 #define IBMVFC_PRLI_DATA_OVERLAY 0x00000040 300 #define IBMVFC_PRLI_INITIATOR_FUNC 0x00000020 301 #define IBMVFC_PRLI_TARGET_FUNC 0x00000010 302 #define IBMVFC_PRLI_READ_FCP_XFER_RDY_DISABLED 0x00000002 303 #define IBMVFC_PRLI_WR_FCP_XFER_RDY_DISABLED 0x00000001 304 }__attribute__((packed, aligned (4))); 305 306 struct ibmvfc_process_login { 307 struct ibmvfc_mad_common common; 308 u64 scsi_id; 309 struct ibmvfc_prli_svc_parms parms; 310 u8 reserved[48]; 311 u16 status; 312 u16 error; /* also fc_reason */ 313 u32 reserved2; 314 u64 reserved3[2]; 315 }__attribute__((packed, aligned (8))); 316 317 struct ibmvfc_query_tgt { 318 struct ibmvfc_mad_common common; 319 u64 wwpn; 320 u64 scsi_id; 321 u16 status; 322 u16 error; 323 u16 fc_explain; 324 u16 fc_type; 325 u64 reserved[2]; 326 }__attribute__((packed, aligned (8))); 327 328 struct ibmvfc_implicit_logout { 329 struct ibmvfc_mad_common common; 330 u64 old_scsi_id; 331 u64 reserved[2]; 332 }__attribute__((packed, aligned (8))); 333 334 struct ibmvfc_tmf { 335 struct ibmvfc_mad_common common; 336 u64 scsi_id; 337 struct scsi_lun lun; 338 u32 flags; 339 #define IBMVFC_TMF_ABORT_TASK 0x02 340 #define IBMVFC_TMF_ABORT_TASK_SET 0x04 341 #define IBMVFC_TMF_LUN_RESET 0x10 342 #define IBMVFC_TMF_TGT_RESET 0x20 343 #define IBMVFC_TMF_LUA_VALID 0x40 344 u32 cancel_key; 345 u32 my_cancel_key; 346 u32 pad; 347 u64 reserved[2]; 348 }__attribute__((packed, aligned (8))); 349 350 enum ibmvfc_fcp_rsp_info_codes { 351 RSP_NO_FAILURE = 0x00, 352 RSP_TMF_REJECTED = 0x04, 353 RSP_TMF_FAILED = 0x05, 354 RSP_TMF_INVALID_LUN = 0x09, 355 }; 356 357 struct ibmvfc_fcp_rsp_info { 358 u16 reserved; 359 u8 rsp_code; 360 u8 reserved2[4]; 361 }__attribute__((packed, aligned (2))); 362 363 enum ibmvfc_fcp_rsp_flags { 364 FCP_BIDI_RSP = 0x80, 365 FCP_BIDI_READ_RESID_UNDER = 0x40, 366 FCP_BIDI_READ_RESID_OVER = 0x20, 367 FCP_CONF_REQ = 0x10, 368 FCP_RESID_UNDER = 0x08, 369 FCP_RESID_OVER = 0x04, 370 FCP_SNS_LEN_VALID = 0x02, 371 FCP_RSP_LEN_VALID = 0x01, 372 }; 373 374 union ibmvfc_fcp_rsp_data { 375 struct ibmvfc_fcp_rsp_info info; 376 u8 sense[SCSI_SENSE_BUFFERSIZE + sizeof(struct ibmvfc_fcp_rsp_info)]; 377 }__attribute__((packed, aligned (8))); 378 379 struct ibmvfc_fcp_rsp { 380 u64 reserved; 381 u16 retry_delay_timer; 382 u8 flags; 383 u8 scsi_status; 384 u32 fcp_resid; 385 u32 fcp_sense_len; 386 u32 fcp_rsp_len; 387 union ibmvfc_fcp_rsp_data data; 388 }__attribute__((packed, aligned (8))); 389 390 enum ibmvfc_cmd_flags { 391 IBMVFC_SCATTERLIST = 0x0001, 392 IBMVFC_NO_MEM_DESC = 0x0002, 393 IBMVFC_READ = 0x0004, 394 IBMVFC_WRITE = 0x0008, 395 IBMVFC_TMF = 0x0080, 396 IBMVFC_CLASS_3_ERR = 0x0100, 397 }; 398 399 enum ibmvfc_fc_task_attr { 400 IBMVFC_SIMPLE_TASK = 0x00, 401 IBMVFC_HEAD_OF_QUEUE = 0x01, 402 IBMVFC_ORDERED_TASK = 0x02, 403 IBMVFC_ACA_TASK = 0x04, 404 }; 405 406 enum ibmvfc_fc_tmf_flags { 407 IBMVFC_ABORT_TASK_SET = 0x02, 408 IBMVFC_LUN_RESET = 0x10, 409 IBMVFC_TARGET_RESET = 0x20, 410 }; 411 412 struct ibmvfc_fcp_cmd_iu { 413 struct scsi_lun lun; 414 u8 crn; 415 u8 pri_task_attr; 416 u8 tmf_flags; 417 u8 add_cdb_len; 418 #define IBMVFC_RDDATA 0x02 419 #define IBMVFC_WRDATA 0x01 420 u8 cdb[IBMVFC_MAX_CDB_LEN]; 421 u32 xfer_len; 422 }__attribute__((packed, aligned (4))); 423 424 struct ibmvfc_cmd { 425 u64 task_tag; 426 u32 frame_type; 427 u32 payload_len; 428 u32 resp_len; 429 u32 adapter_resid; 430 u16 status; 431 u16 error; 432 u16 flags; 433 u16 response_flags; 434 #define IBMVFC_ADAPTER_RESID_VALID 0x01 435 u32 cancel_key; 436 u32 exchange_id; 437 struct srp_direct_buf ext_func; 438 struct srp_direct_buf ioba; 439 struct srp_direct_buf resp; 440 u64 correlation; 441 u64 tgt_scsi_id; 442 u64 tag; 443 u64 reserved3[2]; 444 struct ibmvfc_fcp_cmd_iu iu; 445 struct ibmvfc_fcp_rsp rsp; 446 }__attribute__((packed, aligned (8))); 447 448 struct ibmvfc_passthru_fc_iu { 449 u32 payload[7]; 450 #define IBMVFC_ADISC 0x52000000 451 u32 response[7]; 452 }; 453 454 struct ibmvfc_passthru_iu { 455 u64 task_tag; 456 u32 cmd_len; 457 u32 rsp_len; 458 u16 status; 459 u16 error; 460 u32 flags; 461 #define IBMVFC_FC_ELS 0x01 462 u32 cancel_key; 463 u32 reserved; 464 struct srp_direct_buf cmd; 465 struct srp_direct_buf rsp; 466 u64 correlation; 467 u64 scsi_id; 468 u64 tag; 469 u64 reserved2[2]; 470 }__attribute__((packed, aligned (8))); 471 472 struct ibmvfc_passthru_mad { 473 struct ibmvfc_mad_common common; 474 struct srp_direct_buf cmd_ioba; 475 struct ibmvfc_passthru_iu iu; 476 struct ibmvfc_passthru_fc_iu fc_iu; 477 }__attribute__((packed, aligned (8))); 478 479 struct ibmvfc_trace_start_entry { 480 u32 xfer_len; 481 }__attribute__((packed)); 482 483 struct ibmvfc_trace_end_entry { 484 u16 status; 485 u16 error; 486 u8 fcp_rsp_flags; 487 u8 rsp_code; 488 u8 scsi_status; 489 u8 reserved; 490 }__attribute__((packed)); 491 492 struct ibmvfc_trace_entry { 493 struct ibmvfc_event *evt; 494 u32 time; 495 u32 scsi_id; 496 u32 lun; 497 u8 fmt; 498 u8 op_code; 499 u8 tmf_flags; 500 u8 type; 501 #define IBMVFC_TRC_START 0x00 502 #define IBMVFC_TRC_END 0xff 503 union { 504 struct ibmvfc_trace_start_entry start; 505 struct ibmvfc_trace_end_entry end; 506 } u; 507 }__attribute__((packed, aligned (8))); 508 509 enum ibmvfc_crq_formats { 510 IBMVFC_CMD_FORMAT = 0x01, 511 IBMVFC_ASYNC_EVENT = 0x02, 512 IBMVFC_MAD_FORMAT = 0x04, 513 }; 514 515 enum ibmvfc_async_event { 516 IBMVFC_AE_ELS_PLOGI = 0x0001, 517 IBMVFC_AE_ELS_LOGO = 0x0002, 518 IBMVFC_AE_ELS_PRLO = 0x0004, 519 IBMVFC_AE_SCN_NPORT = 0x0008, 520 IBMVFC_AE_SCN_GROUP = 0x0010, 521 IBMVFC_AE_SCN_DOMAIN = 0x0020, 522 IBMVFC_AE_SCN_FABRIC = 0x0040, 523 IBMVFC_AE_LINK_UP = 0x0080, 524 IBMVFC_AE_LINK_DOWN = 0x0100, 525 IBMVFC_AE_LINK_DEAD = 0x0200, 526 IBMVFC_AE_HALT = 0x0400, 527 IBMVFC_AE_RESUME = 0x0800, 528 IBMVFC_AE_ADAPTER_FAILED = 0x1000, 529 }; 530 531 struct ibmvfc_crq { 532 volatile u8 valid; 533 volatile u8 format; 534 u8 reserved[6]; 535 volatile u64 ioba; 536 }__attribute__((packed, aligned (8))); 537 538 struct ibmvfc_crq_queue { 539 struct ibmvfc_crq *msgs; 540 int size, cur; 541 dma_addr_t msg_token; 542 }; 543 544 struct ibmvfc_async_crq { 545 volatile u8 valid; 546 u8 pad[3]; 547 u32 pad2; 548 volatile u64 event; 549 volatile u64 scsi_id; 550 volatile u64 wwpn; 551 volatile u64 node_name; 552 u64 reserved; 553 }__attribute__((packed, aligned (8))); 554 555 struct ibmvfc_async_crq_queue { 556 struct ibmvfc_async_crq *msgs; 557 int size, cur; 558 dma_addr_t msg_token; 559 }; 560 561 union ibmvfc_iu { 562 struct ibmvfc_mad_common mad_common; 563 struct ibmvfc_npiv_login_mad npiv_login; 564 struct ibmvfc_discover_targets discover_targets; 565 struct ibmvfc_port_login plogi; 566 struct ibmvfc_process_login prli; 567 struct ibmvfc_query_tgt query_tgt; 568 struct ibmvfc_implicit_logout implicit_logout; 569 struct ibmvfc_tmf tmf; 570 struct ibmvfc_cmd cmd; 571 struct ibmvfc_passthru_mad passthru; 572 }__attribute__((packed, aligned (8))); 573 574 enum ibmvfc_target_action { 575 IBMVFC_TGT_ACTION_NONE = 0, 576 IBMVFC_TGT_ACTION_INIT, 577 IBMVFC_TGT_ACTION_INIT_WAIT, 578 IBMVFC_TGT_ACTION_ADD_RPORT, 579 IBMVFC_TGT_ACTION_DEL_RPORT, 580 }; 581 582 struct ibmvfc_target { 583 struct list_head queue; 584 struct ibmvfc_host *vhost; 585 u64 scsi_id; 586 u64 new_scsi_id; 587 struct fc_rport *rport; 588 int target_id; 589 enum ibmvfc_target_action action; 590 int need_login; 591 int init_retries; 592 u32 cancel_key; 593 struct ibmvfc_service_parms service_parms; 594 struct ibmvfc_service_parms service_parms_change; 595 struct fc_rport_identifiers ids; 596 void (*job_step) (struct ibmvfc_target *); 597 struct timer_list timer; 598 struct kref kref; 599 }; 600 601 /* a unit of work for the hosting partition */ 602 struct ibmvfc_event { 603 struct list_head queue; 604 struct ibmvfc_host *vhost; 605 struct ibmvfc_target *tgt; 606 struct scsi_cmnd *cmnd; 607 atomic_t free; 608 union ibmvfc_iu *xfer_iu; 609 void (*done) (struct ibmvfc_event *); 610 struct ibmvfc_crq crq; 611 union ibmvfc_iu iu; 612 union ibmvfc_iu *sync_iu; 613 struct srp_direct_buf *ext_list; 614 dma_addr_t ext_list_token; 615 struct completion comp; 616 struct completion *eh_comp; 617 struct timer_list timer; 618 }; 619 620 /* a pool of event structs for use */ 621 struct ibmvfc_event_pool { 622 struct ibmvfc_event *events; 623 u32 size; 624 union ibmvfc_iu *iu_storage; 625 dma_addr_t iu_token; 626 }; 627 628 enum ibmvfc_host_action { 629 IBMVFC_HOST_ACTION_NONE = 0, 630 IBMVFC_HOST_ACTION_INIT, 631 IBMVFC_HOST_ACTION_INIT_WAIT, 632 IBMVFC_HOST_ACTION_QUERY, 633 IBMVFC_HOST_ACTION_QUERY_TGTS, 634 IBMVFC_HOST_ACTION_TGT_DEL, 635 IBMVFC_HOST_ACTION_ALLOC_TGTS, 636 IBMVFC_HOST_ACTION_TGT_INIT, 637 IBMVFC_HOST_ACTION_TGT_DEL_FAILED, 638 IBMVFC_HOST_ACTION_TGT_ADD, 639 }; 640 641 enum ibmvfc_host_state { 642 IBMVFC_NO_CRQ = 0, 643 IBMVFC_INITIALIZING, 644 IBMVFC_ACTIVE, 645 IBMVFC_HALTED, 646 IBMVFC_LINK_DOWN, 647 IBMVFC_LINK_DEAD, 648 IBMVFC_HOST_OFFLINE, 649 }; 650 651 struct ibmvfc_host { 652 char name[8]; 653 struct list_head queue; 654 struct Scsi_Host *host; 655 enum ibmvfc_host_state state; 656 enum ibmvfc_host_action action; 657 #define IBMVFC_NUM_TRACE_INDEX_BITS 8 658 #define IBMVFC_NUM_TRACE_ENTRIES (1 << IBMVFC_NUM_TRACE_INDEX_BITS) 659 #define IBMVFC_TRACE_SIZE (sizeof(struct ibmvfc_trace_entry) * IBMVFC_NUM_TRACE_ENTRIES) 660 struct ibmvfc_trace_entry *trace; 661 u32 trace_index:IBMVFC_NUM_TRACE_INDEX_BITS; 662 int num_targets; 663 struct list_head targets; 664 struct list_head sent; 665 struct list_head free; 666 struct device *dev; 667 struct ibmvfc_event_pool pool; 668 struct dma_pool *sg_pool; 669 mempool_t *tgt_pool; 670 struct ibmvfc_crq_queue crq; 671 struct ibmvfc_async_crq_queue async_crq; 672 struct ibmvfc_npiv_login login_info; 673 union ibmvfc_npiv_login_data *login_buf; 674 dma_addr_t login_buf_dma; 675 int disc_buf_sz; 676 int log_level; 677 struct ibmvfc_discover_targets_buf *disc_buf; 678 int task_set; 679 int init_retries; 680 int discovery_threads; 681 int abort_threads; 682 int client_migrated; 683 int reinit; 684 int delay_init; 685 int events_to_log; 686 #define IBMVFC_AE_LINKUP 0x0001 687 #define IBMVFC_AE_LINKDOWN 0x0002 688 #define IBMVFC_AE_RSCN 0x0004 689 dma_addr_t disc_buf_dma; 690 unsigned int partition_number; 691 char partition_name[97]; 692 void (*job_step) (struct ibmvfc_host *); 693 struct task_struct *work_thread; 694 struct tasklet_struct tasklet; 695 wait_queue_head_t init_wait_q; 696 wait_queue_head_t work_wait_q; 697 }; 698 699 #define DBG_CMD(CMD) do { if (ibmvfc_debug) CMD; } while (0) 700 701 #define tgt_dbg(t, fmt, ...) \ 702 DBG_CMD(dev_info((t)->vhost->dev, "%llX: " fmt, (t)->scsi_id, ##__VA_ARGS__)) 703 704 #define tgt_info(t, fmt, ...) \ 705 dev_info((t)->vhost->dev, "%llX: " fmt, (t)->scsi_id, ##__VA_ARGS__) 706 707 #define tgt_err(t, fmt, ...) \ 708 dev_err((t)->vhost->dev, "%llX: " fmt, (t)->scsi_id, ##__VA_ARGS__) 709 710 #define ibmvfc_dbg(vhost, ...) \ 711 DBG_CMD(dev_info((vhost)->dev, ##__VA_ARGS__)) 712 713 #define ibmvfc_log(vhost, level, ...) \ 714 do { \ 715 if ((vhost)->log_level >= level) \ 716 dev_err((vhost)->dev, ##__VA_ARGS__); \ 717 } while (0) 718 719 #define ENTER DBG_CMD(printk(KERN_INFO IBMVFC_NAME": Entering %s\n", __func__)) 720 #define LEAVE DBG_CMD(printk(KERN_INFO IBMVFC_NAME": Leaving %s\n", __func__)) 721 722 #ifdef CONFIG_SCSI_IBMVFC_TRACE 723 #define ibmvfc_create_trace_file(kobj, attr) sysfs_create_bin_file(kobj, attr) 724 #define ibmvfc_remove_trace_file(kobj, attr) sysfs_remove_bin_file(kobj, attr) 725 #else 726 #define ibmvfc_create_trace_file(kobj, attr) 0 727 #define ibmvfc_remove_trace_file(kobj, attr) do { } while (0) 728 #endif 729 730 #endif 731