1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * ibmvfc.h -- driver for IBM Power Virtual Fibre Channel Adapter
5 * Written By: Brian King <brking@linux.vnet.ibm.com>, IBM Corporation
7 * Copyright (C) IBM Corporation, 2008
13 #include <linux/list.h>
14 #include <linux/types.h>
15 #include <scsi/viosrp.h>
17 #define IBMVFC_NAME "ibmvfc"
18 #define IBMVFC_DRIVER_VERSION "1.0.11"
19 #define IBMVFC_DRIVER_DATE "(April 12, 2013)"
21 #define IBMVFC_DEFAULT_TIMEOUT 60
22 #define IBMVFC_ADISC_CANCEL_TIMEOUT 45
23 #define IBMVFC_ADISC_TIMEOUT 15
24 #define IBMVFC_ADISC_PLUS_CANCEL_TIMEOUT \
25 (IBMVFC_ADISC_TIMEOUT + IBMVFC_ADISC_CANCEL_TIMEOUT)
26 #define IBMVFC_INIT_TIMEOUT 120
27 #define IBMVFC_ABORT_TIMEOUT 8
28 #define IBMVFC_ABORT_WAIT_TIMEOUT 40
29 #define IBMVFC_MAX_REQUESTS_DEFAULT 100
30 #define IBMVFC_SCSI_QDEPTH 128
32 #define IBMVFC_DEBUG 0
33 #define IBMVFC_MAX_TARGETS 1024
34 #define IBMVFC_MAX_LUN 0xffffffff
35 #define IBMVFC_MAX_SECTORS 0xffffu
36 #define IBMVFC_MAX_DISC_THREADS 4
37 #define IBMVFC_TGT_MEMPOOL_SZ 64
38 #define IBMVFC_MAX_CMDS_PER_LUN 64
39 #define IBMVFC_MAX_HOST_INIT_RETRIES 6
40 #define IBMVFC_MAX_TGT_INIT_RETRIES 3
41 #define IBMVFC_DEV_LOSS_TMO (5 * 60)
42 #define IBMVFC_DEFAULT_LOG_LEVEL 2
43 #define IBMVFC_MAX_CDB_LEN 16
44 #define IBMVFC_CLS3_ERROR 0
46 #define IBMVFC_SCSI_CHANNELS 8
47 #define IBMVFC_MAX_SCSI_QUEUES 16
48 #define IBMVFC_SCSI_HW_QUEUES 8
49 #define IBMVFC_MIG_NO_SUB_TO_CRQ 0
50 #define IBMVFC_MIG_NO_N_TO_M 0
53 * Ensure we have resources for ERP and initialization:
55 * 1 for initialization
58 * 2 for each discovery thread
60 #define IBMVFC_NUM_INTERNAL_REQ (1 + 1 + 1 + 2 + (disc_threads * 2))
61 /* Reserved suset of events for cancelling channelized IO commands */
62 #define IBMVFC_NUM_INTERNAL_SUBQ_REQ 4
64 #define IBMVFC_MAD_SUCCESS 0x00
65 #define IBMVFC_MAD_NOT_SUPPORTED 0xF1
66 #define IBMVFC_MAD_VERSION_NOT_SUPP 0xF2
67 #define IBMVFC_MAD_FAILED 0xF7
68 #define IBMVFC_MAD_DRIVER_FAILED 0xEE
69 #define IBMVFC_MAD_CRQ_ERROR 0xEF
71 enum ibmvfc_crq_valid {
72 IBMVFC_CRQ_CMD_RSP = 0x80,
73 IBMVFC_CRQ_INIT_RSP = 0xC0,
74 IBMVFC_CRQ_XPORT_EVENT = 0xFF,
77 enum ibmvfc_crq_init_msg {
78 IBMVFC_CRQ_INIT = 0x01,
79 IBMVFC_CRQ_INIT_COMPLETE = 0x02,
82 enum ibmvfc_crq_xport_evts {
83 IBMVFC_PARTNER_FAILED = 0x01,
84 IBMVFC_PARTNER_DEREGISTER = 0x02,
85 IBMVFC_PARTITION_MIGRATED = 0x06,
88 enum ibmvfc_cmd_status_flags {
89 IBMVFC_FABRIC_MAPPED = 0x0001,
90 IBMVFC_VIOS_FAILURE = 0x0002,
91 IBMVFC_FC_FAILURE = 0x0004,
92 IBMVFC_FC_SCSI_ERROR = 0x0008,
93 IBMVFC_HW_EVENT_LOGGED = 0x0010,
94 IBMVFC_VIOS_LOGGED = 0x0020,
97 enum ibmvfc_fabric_mapped_errors {
98 IBMVFC_UNABLE_TO_ESTABLISH = 0x0001,
99 IBMVFC_XPORT_FAULT = 0x0002,
100 IBMVFC_CMD_TIMEOUT = 0x0003,
101 IBMVFC_ENETDOWN = 0x0004,
102 IBMVFC_HW_FAILURE = 0x0005,
103 IBMVFC_LINK_DOWN_ERR = 0x0006,
104 IBMVFC_LINK_DEAD_ERR = 0x0007,
105 IBMVFC_UNABLE_TO_REGISTER = 0x0008,
106 IBMVFC_XPORT_BUSY = 0x000A,
107 IBMVFC_XPORT_DEAD = 0x000B,
108 IBMVFC_CONFIG_ERROR = 0x000C,
109 IBMVFC_NAME_SERVER_FAIL = 0x000D,
110 IBMVFC_LINK_HALTED = 0x000E,
111 IBMVFC_XPORT_GENERAL = 0x8000,
114 enum ibmvfc_vios_errors {
115 IBMVFC_CRQ_FAILURE = 0x0001,
116 IBMVFC_SW_FAILURE = 0x0002,
117 IBMVFC_INVALID_PARAMETER = 0x0003,
118 IBMVFC_MISSING_PARAMETER = 0x0004,
119 IBMVFC_HOST_IO_BUS = 0x0005,
120 IBMVFC_TRANS_CANCELLED = 0x0006,
121 IBMVFC_TRANS_CANCELLED_IMPLICIT = 0x0007,
122 IBMVFC_INSUFFICIENT_RESOURCE = 0x0008,
123 IBMVFC_PLOGI_REQUIRED = 0x0010,
124 IBMVFC_COMMAND_FAILED = 0x8000,
127 enum ibmvfc_mad_types {
128 IBMVFC_NPIV_LOGIN = 0x0001,
129 IBMVFC_DISC_TARGETS = 0x0002,
130 IBMVFC_PORT_LOGIN = 0x0004,
131 IBMVFC_PROCESS_LOGIN = 0x0008,
132 IBMVFC_QUERY_TARGET = 0x0010,
133 IBMVFC_MOVE_LOGIN = 0x0020,
134 IBMVFC_IMPLICIT_LOGOUT = 0x0040,
135 IBMVFC_PASSTHRU = 0x0200,
136 IBMVFC_TMF_MAD = 0x0100,
137 IBMVFC_NPIV_LOGOUT = 0x0800,
138 IBMVFC_CHANNEL_ENQUIRY = 0x1000,
139 IBMVFC_CHANNEL_SETUP = 0x2000,
140 IBMVFC_CONNECTION_INFO = 0x4000,
143 struct ibmvfc_mad_common {
150 } __packed __aligned(8);
152 struct ibmvfc_npiv_login_mad {
153 struct ibmvfc_mad_common common;
154 struct srp_direct_buf buffer;
155 } __packed __aligned(8);
157 struct ibmvfc_npiv_logout_mad {
158 struct ibmvfc_mad_common common;
159 } __packed __aligned(8);
161 #define IBMVFC_MAX_NAME 256
163 struct ibmvfc_npiv_login {
165 #define IBMVFC_OS_LINUX 0x02
170 __be32 partition_num;
171 __be32 vfc_frame_version;
174 #define IBMVFC_CLIENT_MIGRATED 0x01
175 #define IBMVFC_FLUSH_ON_HALT 0x02
178 #define IBMVFC_CAN_MIGRATE 0x01
179 #define IBMVFC_CAN_USE_CHANNELS 0x02
180 #define IBMVFC_CAN_HANDLE_FPIN 0x04
181 #define IBMVFC_CAN_USE_MAD_VERSION 0x08
182 #define IBMVFC_CAN_SEND_VF_WWPN 0x10
184 struct srp_direct_buf async;
185 u8 partition_name[IBMVFC_MAX_NAME];
186 u8 device_name[IBMVFC_MAX_NAME];
187 u8 drc_name[IBMVFC_MAX_NAME];
189 } __packed __aligned(8);
191 struct ibmvfc_common_svc_parms {
195 __be16 bb_rcv_sz; /* upper nibble is BB_SC_N */
198 } __packed __aligned(4);
200 struct ibmvfc_service_parms {
201 struct ibmvfc_common_svc_parms common;
204 __be32 class1_parms[4];
205 __be32 class2_parms[4];
206 __be32 class3_parms[4];
208 __be32 vendor_version[4];
209 __be32 services_avail[2];
212 __be32 clk_sync_qos[2];
214 } __packed __aligned(4);
216 struct ibmvfc_npiv_login_resp {
221 #define IBMVFC_NATIVE_FC 0x01
224 #define IBMVFC_CAN_FLUSH_ON_HALT 0x08
225 #define IBMVFC_CAN_SUPPRESS_ABTS 0x10
226 #define IBMVFC_MAD_VERSION_CAP 0x20
227 #define IBMVFC_HANDLE_VF_WWPN 0x40
228 #define IBMVFC_CAN_SUPPORT_CHANNELS 0x80
236 u8 partition_name[IBMVFC_MAX_NAME];
237 u8 device_name[IBMVFC_MAX_NAME];
238 u8 port_loc_code[IBMVFC_MAX_NAME];
239 u8 drc_name[IBMVFC_MAX_NAME];
240 struct ibmvfc_service_parms service_parms;
242 } __packed __aligned(8);
244 union ibmvfc_npiv_login_data {
245 struct ibmvfc_npiv_login login;
246 struct ibmvfc_npiv_login_resp resp;
247 } __packed __aligned(8);
249 struct ibmvfc_discover_targets_entry {
253 #define IBMVFC_DISC_TGT_SCSI_ID_MASK 0x00ffffff
254 } __packed __aligned(8);
256 struct ibmvfc_discover_targets {
257 struct ibmvfc_mad_common common;
258 struct srp_direct_buf buffer;
260 #define IBMVFC_DISC_TGT_PORT_ID_WWPN_LIST 0x02
267 } __packed __aligned(8);
269 enum ibmvfc_fc_reason {
270 IBMVFC_INVALID_ELS_CMD_CODE = 0x01,
271 IBMVFC_INVALID_VERSION = 0x02,
272 IBMVFC_LOGICAL_ERROR = 0x03,
273 IBMVFC_INVALID_CT_IU_SIZE = 0x04,
274 IBMVFC_LOGICAL_BUSY = 0x05,
275 IBMVFC_PROTOCOL_ERROR = 0x07,
276 IBMVFC_UNABLE_TO_PERFORM_REQ = 0x09,
277 IBMVFC_CMD_NOT_SUPPORTED = 0x0B,
278 IBMVFC_SERVER_NOT_AVAIL = 0x0D,
279 IBMVFC_CMD_IN_PROGRESS = 0x0E,
280 IBMVFC_VENDOR_SPECIFIC = 0xFF,
283 enum ibmvfc_fc_type {
284 IBMVFC_FABRIC_REJECT = 0x01,
285 IBMVFC_PORT_REJECT = 0x02,
286 IBMVFC_LS_REJECT = 0x03,
287 IBMVFC_FABRIC_BUSY = 0x04,
288 IBMVFC_PORT_BUSY = 0x05,
289 IBMVFC_BASIC_REJECT = 0x06,
292 enum ibmvfc_gs_explain {
293 IBMVFC_PORT_NAME_NOT_REG = 0x02,
296 struct ibmvfc_port_login {
297 struct ibmvfc_mad_common common;
300 __be16 fc_service_class;
304 __be16 error; /* also fc_reason */
308 struct ibmvfc_service_parms service_parms;
309 struct ibmvfc_service_parms service_parms_change;
312 } __packed __aligned(8);
314 struct ibmvfc_move_login {
315 struct ibmvfc_mad_common common;
321 #define IBMVFC_MOVE_LOGIN_IMPLICIT_OLD_FAILED 0x01
322 #define IBMVFC_MOVE_LOGIN_IMPLICIT_NEW_FAILED 0x02
323 #define IBMVFC_MOVE_LOGIN_PORT_LOGIN_FAILED 0x04
325 struct ibmvfc_service_parms service_parms;
326 struct ibmvfc_service_parms service_parms_change;
328 __be16 service_class;
330 #define IBMVFC_MOVE_LOGIN_VF_NOT_SENT_ADAPTER 0x01
332 } __packed __aligned(8);
334 struct ibmvfc_prli_svc_parms {
336 #define IBMVFC_SCSI_FCP_TYPE 0x08
339 #define IBMVFC_PRLI_ORIG_PA_VALID 0x8000
340 #define IBMVFC_PRLI_RESP_PA_VALID 0x4000
341 #define IBMVFC_PRLI_EST_IMG_PAIR 0x2000
344 __be32 service_parms;
345 #define IBMVFC_PRLI_TASK_RETRY 0x00000200
346 #define IBMVFC_PRLI_RETRY 0x00000100
347 #define IBMVFC_PRLI_DATA_OVERLAY 0x00000040
348 #define IBMVFC_PRLI_INITIATOR_FUNC 0x00000020
349 #define IBMVFC_PRLI_TARGET_FUNC 0x00000010
350 #define IBMVFC_PRLI_READ_FCP_XFER_RDY_DISABLED 0x00000002
351 #define IBMVFC_PRLI_WR_FCP_XFER_RDY_DISABLED 0x00000001
352 } __packed __aligned(4);
354 struct ibmvfc_process_login {
355 struct ibmvfc_mad_common common;
357 struct ibmvfc_prli_svc_parms parms;
360 __be16 error; /* also fc_reason */
364 } __packed __aligned(8);
366 struct ibmvfc_query_tgt {
367 struct ibmvfc_mad_common common;
375 } __packed __aligned(8);
377 struct ibmvfc_implicit_logout {
378 struct ibmvfc_mad_common common;
381 } __packed __aligned(8);
384 struct ibmvfc_mad_common common;
388 #define IBMVFC_TMF_ABORT_TASK 0x02
389 #define IBMVFC_TMF_ABORT_TASK_SET 0x04
390 #define IBMVFC_TMF_LUN_RESET 0x10
391 #define IBMVFC_TMF_TGT_RESET 0x20
392 #define IBMVFC_TMF_LUA_VALID 0x40
393 #define IBMVFC_TMF_SUPPRESS_ABTS 0x80
395 __be32 my_cancel_key;
400 } __packed __aligned(8);
402 enum ibmvfc_fcp_rsp_info_codes {
403 RSP_NO_FAILURE = 0x00,
404 RSP_TMF_REJECTED = 0x04,
405 RSP_TMF_FAILED = 0x05,
406 RSP_TMF_INVALID_LUN = 0x09,
409 struct ibmvfc_fcp_rsp_info {
413 } __packed __aligned(2);
415 enum ibmvfc_fcp_rsp_flags {
417 FCP_BIDI_READ_RESID_UNDER = 0x40,
418 FCP_BIDI_READ_RESID_OVER = 0x20,
420 FCP_RESID_UNDER = 0x08,
421 FCP_RESID_OVER = 0x04,
422 FCP_SNS_LEN_VALID = 0x02,
423 FCP_RSP_LEN_VALID = 0x01,
426 union ibmvfc_fcp_rsp_data {
427 struct ibmvfc_fcp_rsp_info info;
428 u8 sense[SCSI_SENSE_BUFFERSIZE + sizeof(struct ibmvfc_fcp_rsp_info)];
429 } __packed __aligned(8);
431 struct ibmvfc_fcp_rsp {
433 __be16 retry_delay_timer;
437 __be32 fcp_sense_len;
439 union ibmvfc_fcp_rsp_data data;
440 } __packed __aligned(8);
442 enum ibmvfc_cmd_flags {
443 IBMVFC_SCATTERLIST = 0x0001,
444 IBMVFC_NO_MEM_DESC = 0x0002,
445 IBMVFC_READ = 0x0004,
446 IBMVFC_WRITE = 0x0008,
448 IBMVFC_CLASS_3_ERR = 0x0100,
451 enum ibmvfc_fc_task_attr {
452 IBMVFC_SIMPLE_TASK = 0x00,
453 IBMVFC_HEAD_OF_QUEUE = 0x01,
454 IBMVFC_ORDERED_TASK = 0x02,
455 IBMVFC_ACA_TASK = 0x04,
458 enum ibmvfc_fc_tmf_flags {
459 IBMVFC_ABORT_TASK_SET = 0x02,
460 IBMVFC_LUN_RESET = 0x10,
461 IBMVFC_TARGET_RESET = 0x20,
464 struct ibmvfc_fcp_cmd_iu {
470 #define IBMVFC_RDDATA 0x02
471 #define IBMVFC_WRDATA 0x01
472 u8 cdb[IBMVFC_MAX_CDB_LEN];
474 } __packed __aligned(4);
481 __be32 adapter_resid;
485 __be16 response_flags;
486 #define IBMVFC_ADAPTER_RESID_VALID 0x01
489 struct srp_direct_buf ext_func;
490 struct srp_direct_buf ioba;
491 struct srp_direct_buf resp;
499 struct ibmvfc_fcp_cmd_iu iu;
500 struct ibmvfc_fcp_rsp rsp;
504 struct ibmvfc_fcp_cmd_iu iu;
505 struct ibmvfc_fcp_rsp rsp;
508 } __packed __aligned(8);
510 struct ibmvfc_passthru_fc_iu {
512 #define IBMVFC_ADISC 0x52000000
516 struct ibmvfc_passthru_iu {
523 #define IBMVFC_FC_ELS 0x01
524 #define IBMVFC_FC_CT_IU 0x02
526 #define IBMVFC_PASSTHRU_CANCEL_KEY 0x80000000
527 #define IBMVFC_INTERNAL_CANCEL_KEY 0x80000001
529 struct srp_direct_buf cmd;
530 struct srp_direct_buf rsp;
536 } __packed __aligned(8);
538 struct ibmvfc_passthru_mad {
539 struct ibmvfc_mad_common common;
540 struct srp_direct_buf cmd_ioba;
541 struct ibmvfc_passthru_iu iu;
542 struct ibmvfc_passthru_fc_iu fc_iu;
543 } __packed __aligned(8);
545 struct ibmvfc_channel_enquiry {
546 struct ibmvfc_mad_common common;
548 #define IBMVFC_NO_CHANNELS_TO_CRQ_SUPPORT 0x01
549 #define IBMVFC_SUPPORT_VARIABLE_SUBQ_MSG 0x02
550 #define IBMVFC_NO_N_TO_M_CHANNELS_SUPPORT 0x04
551 __be32 num_scsi_subq_channels;
552 __be32 num_nvmeof_subq_channels;
553 __be32 num_scsi_vas_channels;
554 __be32 num_nvmeof_vas_channels;
555 } __packed __aligned(8);
557 struct ibmvfc_channel_setup_mad {
558 struct ibmvfc_mad_common common;
559 struct srp_direct_buf buffer;
560 } __packed __aligned(8);
562 #define IBMVFC_MAX_CHANNELS 502
564 struct ibmvfc_channel_setup {
566 #define IBMVFC_CANCEL_CHANNELS 0x01
567 #define IBMVFC_USE_BUFFER 0x02
568 #define IBMVFC_CHANNELS_CANCELED 0x04
570 __be32 num_scsi_subq_channels;
571 __be32 num_nvmeof_subq_channels;
572 __be32 num_scsi_vas_channels;
573 __be32 num_nvmeof_vas_channels;
574 struct srp_direct_buf buffer;
576 __be64 channel_handles[IBMVFC_MAX_CHANNELS];
577 } __packed __aligned(8);
579 struct ibmvfc_connection_info {
580 struct ibmvfc_mad_common common;
581 __be64 information_bits;
582 #define IBMVFC_NO_FC_IO_CHANNEL 0x01
583 #define IBMVFC_NO_PHYP_VAS 0x02
584 #define IBMVFC_NO_PHYP_SUBQ 0x04
585 #define IBMVFC_PHYP_DEPRECATED_SUBQ 0x08
586 #define IBMVFC_PHYP_PRESERVED_SUBQ 0x10
587 #define IBMVFC_PHYP_FULL_SUBQ 0x20
589 } __packed __aligned(8);
591 struct ibmvfc_trace_start_entry {
595 struct ibmvfc_trace_end_entry {
604 struct ibmvfc_trace_entry {
605 struct ibmvfc_event *evt;
613 #define IBMVFC_TRC_START 0x00
614 #define IBMVFC_TRC_END 0xff
616 struct ibmvfc_trace_start_entry start;
617 struct ibmvfc_trace_end_entry end;
619 } __packed __aligned(8);
621 enum ibmvfc_crq_formats {
622 IBMVFC_CMD_FORMAT = 0x01,
623 IBMVFC_ASYNC_EVENT = 0x02,
624 IBMVFC_MAD_FORMAT = 0x04,
627 enum ibmvfc_async_event {
628 IBMVFC_AE_ELS_PLOGI = 0x0001,
629 IBMVFC_AE_ELS_LOGO = 0x0002,
630 IBMVFC_AE_ELS_PRLO = 0x0004,
631 IBMVFC_AE_SCN_NPORT = 0x0008,
632 IBMVFC_AE_SCN_GROUP = 0x0010,
633 IBMVFC_AE_SCN_DOMAIN = 0x0020,
634 IBMVFC_AE_SCN_FABRIC = 0x0040,
635 IBMVFC_AE_LINK_UP = 0x0080,
636 IBMVFC_AE_LINK_DOWN = 0x0100,
637 IBMVFC_AE_LINK_DEAD = 0x0200,
638 IBMVFC_AE_HALT = 0x0400,
639 IBMVFC_AE_RESUME = 0x0800,
640 IBMVFC_AE_ADAPTER_FAILED = 0x1000,
641 IBMVFC_AE_FPIN = 0x2000,
644 struct ibmvfc_async_desc {
646 enum ibmvfc_async_event ae;
654 volatile __be64 ioba;
655 } __packed __aligned(8);
657 struct ibmvfc_sub_crq {
658 struct ibmvfc_crq crq;
660 } __packed __aligned(8);
662 enum ibmvfc_ae_link_state {
663 IBMVFC_AE_LS_LINK_UP = 0x01,
664 IBMVFC_AE_LS_LINK_BOUNCED = 0x02,
665 IBMVFC_AE_LS_LINK_DOWN = 0x04,
666 IBMVFC_AE_LS_LINK_DEAD = 0x08,
669 enum ibmvfc_ae_fpin_status {
670 IBMVFC_AE_FPIN_LINK_CONGESTED = 0x1,
671 IBMVFC_AE_FPIN_PORT_CONGESTED = 0x2,
672 IBMVFC_AE_FPIN_PORT_CLEARED = 0x3,
673 IBMVFC_AE_FPIN_PORT_DEGRADED = 0x4,
676 struct ibmvfc_async_crq {
682 volatile __be64 event;
683 volatile __be64 scsi_id;
684 volatile __be64 wwpn;
685 volatile __be64 node_name;
687 } __packed __aligned(8);
690 struct ibmvfc_mad_common mad_common;
691 struct ibmvfc_npiv_login_mad npiv_login;
692 struct ibmvfc_npiv_logout_mad npiv_logout;
693 struct ibmvfc_discover_targets discover_targets;
694 struct ibmvfc_port_login plogi;
695 struct ibmvfc_process_login prli;
696 struct ibmvfc_move_login move_login;
697 struct ibmvfc_query_tgt query_tgt;
698 struct ibmvfc_implicit_logout implicit_logout;
699 struct ibmvfc_tmf tmf;
700 struct ibmvfc_cmd cmd;
701 struct ibmvfc_passthru_mad passthru;
702 struct ibmvfc_channel_enquiry channel_enquiry;
703 struct ibmvfc_channel_setup_mad channel_setup;
704 struct ibmvfc_connection_info connection_info;
705 } __packed __aligned(8);
707 enum ibmvfc_target_action {
708 IBMVFC_TGT_ACTION_NONE = 0,
709 IBMVFC_TGT_ACTION_INIT,
710 IBMVFC_TGT_ACTION_INIT_WAIT,
711 IBMVFC_TGT_ACTION_LOGOUT_RPORT,
712 IBMVFC_TGT_ACTION_LOGOUT_RPORT_WAIT,
713 IBMVFC_TGT_ACTION_DEL_RPORT,
714 IBMVFC_TGT_ACTION_DELETED_RPORT,
715 IBMVFC_TGT_ACTION_DEL_AND_LOGOUT_RPORT,
716 IBMVFC_TGT_ACTION_LOGOUT_DELETED_RPORT,
719 struct ibmvfc_target {
720 struct list_head queue;
721 struct ibmvfc_host *vhost;
725 struct fc_rport *rport;
727 enum ibmvfc_target_action action;
734 struct ibmvfc_service_parms service_parms;
735 struct ibmvfc_service_parms service_parms_change;
736 struct fc_rport_identifiers ids;
737 void (*job_step) (struct ibmvfc_target *);
738 struct timer_list timer;
742 /* a unit of work for the hosting partition */
743 struct ibmvfc_event {
744 struct list_head queue_list;
745 struct list_head cancel;
746 struct ibmvfc_host *vhost;
747 struct ibmvfc_queue *queue;
748 struct ibmvfc_target *tgt;
749 struct scsi_cmnd *cmnd;
752 union ibmvfc_iu *xfer_iu;
753 void (*done)(struct ibmvfc_event *evt);
754 void (*_done)(struct ibmvfc_event *evt);
755 struct ibmvfc_crq crq;
757 union ibmvfc_iu *sync_iu;
758 struct srp_direct_buf *ext_list;
759 dma_addr_t ext_list_token;
760 struct completion comp;
761 struct completion *eh_comp;
762 struct timer_list timer;
767 /* a pool of event structs for use */
768 struct ibmvfc_event_pool {
769 struct ibmvfc_event *events;
771 union ibmvfc_iu *iu_storage;
775 enum ibmvfc_msg_fmt {
783 struct ibmvfc_crq *crq;
784 struct ibmvfc_async_crq *async;
785 struct ibmvfc_sub_crq *scrq;
788 struct ibmvfc_queue {
789 union ibmvfc_msgs msgs;
790 dma_addr_t msg_token;
791 enum ibmvfc_msg_fmt fmt;
796 struct ibmvfc_host *vhost;
797 struct ibmvfc_event_pool evt_pool;
798 struct list_head sent;
799 struct list_head free;
807 union ibmvfc_iu cancel_rsp;
810 unsigned long cookie;
811 unsigned long vios_cookie;
812 unsigned long hw_irq;
814 unsigned long hwq_id;
818 struct ibmvfc_scsi_channels {
819 struct ibmvfc_queue *scrqs;
820 unsigned int active_queues;
823 enum ibmvfc_host_action {
824 IBMVFC_HOST_ACTION_NONE = 0,
825 IBMVFC_HOST_ACTION_RESET,
826 IBMVFC_HOST_ACTION_REENABLE,
827 IBMVFC_HOST_ACTION_LOGO,
828 IBMVFC_HOST_ACTION_LOGO_WAIT,
829 IBMVFC_HOST_ACTION_INIT,
830 IBMVFC_HOST_ACTION_INIT_WAIT,
831 IBMVFC_HOST_ACTION_QUERY,
832 IBMVFC_HOST_ACTION_QUERY_TGTS,
833 IBMVFC_HOST_ACTION_TGT_DEL,
834 IBMVFC_HOST_ACTION_ALLOC_TGTS,
835 IBMVFC_HOST_ACTION_TGT_INIT,
836 IBMVFC_HOST_ACTION_TGT_DEL_FAILED,
839 enum ibmvfc_host_state {
851 struct list_head queue;
852 struct Scsi_Host *host;
853 enum ibmvfc_host_state state;
854 enum ibmvfc_host_action action;
855 #define IBMVFC_NUM_TRACE_INDEX_BITS 8
856 #define IBMVFC_NUM_TRACE_ENTRIES (1 << IBMVFC_NUM_TRACE_INDEX_BITS)
857 #define IBMVFC_TRACE_INDEX_MASK (IBMVFC_NUM_TRACE_ENTRIES - 1)
858 #define IBMVFC_TRACE_SIZE (sizeof(struct ibmvfc_trace_entry) * IBMVFC_NUM_TRACE_ENTRIES)
859 struct ibmvfc_trace_entry *trace;
860 atomic_t trace_index;
862 struct list_head targets;
863 struct list_head purge;
865 struct dma_pool *sg_pool;
867 struct ibmvfc_queue crq;
868 struct ibmvfc_queue async_crq;
869 struct ibmvfc_scsi_channels scsi_scrqs;
870 struct ibmvfc_npiv_login login_info;
871 union ibmvfc_npiv_login_data *login_buf;
872 dma_addr_t login_buf_dma;
873 struct ibmvfc_channel_setup *channel_setup_buf;
874 dma_addr_t channel_setup_dma;
877 struct ibmvfc_discover_targets_entry *disc_buf;
878 struct mutex passthru_mutex;
879 int max_vios_scsi_channels;
882 int discovery_threads;
893 int client_scsi_channels;
894 int aborting_passthru;
896 #define IBMVFC_AE_LINKUP 0x0001
897 #define IBMVFC_AE_LINKDOWN 0x0002
898 #define IBMVFC_AE_RSCN 0x0004
899 dma_addr_t disc_buf_dma;
900 unsigned int partition_number;
901 char partition_name[97];
902 void (*job_step) (struct ibmvfc_host *);
903 struct task_struct *work_thread;
904 struct tasklet_struct tasklet;
905 struct work_struct rport_add_work_q;
906 wait_queue_head_t init_wait_q;
907 wait_queue_head_t work_wait_q;
910 #define DBG_CMD(CMD) do { if (ibmvfc_debug) CMD; } while (0)
912 #define tgt_dbg(t, fmt, ...) \
913 DBG_CMD(dev_info((t)->vhost->dev, "%llX: " fmt, (t)->scsi_id, ##__VA_ARGS__))
915 #define tgt_info(t, fmt, ...) \
916 dev_info((t)->vhost->dev, "%llX: " fmt, (t)->scsi_id, ##__VA_ARGS__)
918 #define tgt_err(t, fmt, ...) \
919 dev_err((t)->vhost->dev, "%llX: " fmt, (t)->scsi_id, ##__VA_ARGS__)
921 #define tgt_log(t, level, fmt, ...) \
923 if ((t)->vhost->log_level >= level) \
924 tgt_err(t, fmt, ##__VA_ARGS__); \
927 #define ibmvfc_dbg(vhost, ...) \
928 DBG_CMD(dev_info((vhost)->dev, ##__VA_ARGS__))
930 #define ibmvfc_log(vhost, level, ...) \
932 if ((vhost)->log_level >= level) \
933 dev_err((vhost)->dev, ##__VA_ARGS__); \
936 #define ENTER DBG_CMD(printk(KERN_INFO IBMVFC_NAME": Entering %s\n", __func__))
937 #define LEAVE DBG_CMD(printk(KERN_INFO IBMVFC_NAME": Leaving %s\n", __func__))
939 #ifdef CONFIG_SCSI_IBMVFC_TRACE
940 #define ibmvfc_create_trace_file(kobj, attr) sysfs_create_bin_file(kobj, attr)
941 #define ibmvfc_remove_trace_file(kobj, attr) sysfs_remove_bin_file(kobj, attr)
943 #define ibmvfc_create_trace_file(kobj, attr) 0
944 #define ibmvfc_remove_trace_file(kobj, attr) do { } while (0)