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
31 #define IBMVFC_DEBUG 0
32 #define IBMVFC_MAX_TARGETS 1024
33 #define IBMVFC_MAX_LUN 0xffffffff
34 #define IBMVFC_MAX_SECTORS 0xffffu
35 #define IBMVFC_MAX_DISC_THREADS 4
36 #define IBMVFC_TGT_MEMPOOL_SZ 64
37 #define IBMVFC_MAX_CMDS_PER_LUN 64
38 #define IBMVFC_MAX_HOST_INIT_RETRIES 6
39 #define IBMVFC_MAX_TGT_INIT_RETRIES 3
40 #define IBMVFC_DEV_LOSS_TMO (5 * 60)
41 #define IBMVFC_DEFAULT_LOG_LEVEL 2
42 #define IBMVFC_MAX_CDB_LEN 16
43 #define IBMVFC_CLS3_ERROR 0
45 #define IBMVFC_SCSI_CHANNELS 8
46 #define IBMVFC_MAX_SCSI_QUEUES 16
47 #define IBMVFC_SCSI_HW_QUEUES 8
48 #define IBMVFC_MIG_NO_SUB_TO_CRQ 0
49 #define IBMVFC_MIG_NO_N_TO_M 0
52 * Ensure we have resources for ERP and initialization:
54 * 1 for initialization
57 * 2 for each discovery thread
59 #define IBMVFC_NUM_INTERNAL_REQ (1 + 1 + 1 + 2 + (disc_threads * 2))
61 #define IBMVFC_MAD_SUCCESS 0x00
62 #define IBMVFC_MAD_NOT_SUPPORTED 0xF1
63 #define IBMVFC_MAD_VERSION_NOT_SUPP 0xF2
64 #define IBMVFC_MAD_FAILED 0xF7
65 #define IBMVFC_MAD_DRIVER_FAILED 0xEE
66 #define IBMVFC_MAD_CRQ_ERROR 0xEF
68 enum ibmvfc_crq_valid {
69 IBMVFC_CRQ_CMD_RSP = 0x80,
70 IBMVFC_CRQ_INIT_RSP = 0xC0,
71 IBMVFC_CRQ_XPORT_EVENT = 0xFF,
74 enum ibmvfc_crq_init_msg {
75 IBMVFC_CRQ_INIT = 0x01,
76 IBMVFC_CRQ_INIT_COMPLETE = 0x02,
79 enum ibmvfc_crq_xport_evts {
80 IBMVFC_PARTNER_FAILED = 0x01,
81 IBMVFC_PARTNER_DEREGISTER = 0x02,
82 IBMVFC_PARTITION_MIGRATED = 0x06,
85 enum ibmvfc_cmd_status_flags {
86 IBMVFC_FABRIC_MAPPED = 0x0001,
87 IBMVFC_VIOS_FAILURE = 0x0002,
88 IBMVFC_FC_FAILURE = 0x0004,
89 IBMVFC_FC_SCSI_ERROR = 0x0008,
90 IBMVFC_HW_EVENT_LOGGED = 0x0010,
91 IBMVFC_VIOS_LOGGED = 0x0020,
94 enum ibmvfc_fabric_mapped_errors {
95 IBMVFC_UNABLE_TO_ESTABLISH = 0x0001,
96 IBMVFC_XPORT_FAULT = 0x0002,
97 IBMVFC_CMD_TIMEOUT = 0x0003,
98 IBMVFC_ENETDOWN = 0x0004,
99 IBMVFC_HW_FAILURE = 0x0005,
100 IBMVFC_LINK_DOWN_ERR = 0x0006,
101 IBMVFC_LINK_DEAD_ERR = 0x0007,
102 IBMVFC_UNABLE_TO_REGISTER = 0x0008,
103 IBMVFC_XPORT_BUSY = 0x000A,
104 IBMVFC_XPORT_DEAD = 0x000B,
105 IBMVFC_CONFIG_ERROR = 0x000C,
106 IBMVFC_NAME_SERVER_FAIL = 0x000D,
107 IBMVFC_LINK_HALTED = 0x000E,
108 IBMVFC_XPORT_GENERAL = 0x8000,
111 enum ibmvfc_vios_errors {
112 IBMVFC_CRQ_FAILURE = 0x0001,
113 IBMVFC_SW_FAILURE = 0x0002,
114 IBMVFC_INVALID_PARAMETER = 0x0003,
115 IBMVFC_MISSING_PARAMETER = 0x0004,
116 IBMVFC_HOST_IO_BUS = 0x0005,
117 IBMVFC_TRANS_CANCELLED = 0x0006,
118 IBMVFC_TRANS_CANCELLED_IMPLICIT = 0x0007,
119 IBMVFC_INSUFFICIENT_RESOURCE = 0x0008,
120 IBMVFC_PLOGI_REQUIRED = 0x0010,
121 IBMVFC_COMMAND_FAILED = 0x8000,
124 enum ibmvfc_mad_types {
125 IBMVFC_NPIV_LOGIN = 0x0001,
126 IBMVFC_DISC_TARGETS = 0x0002,
127 IBMVFC_PORT_LOGIN = 0x0004,
128 IBMVFC_PROCESS_LOGIN = 0x0008,
129 IBMVFC_QUERY_TARGET = 0x0010,
130 IBMVFC_MOVE_LOGIN = 0x0020,
131 IBMVFC_IMPLICIT_LOGOUT = 0x0040,
132 IBMVFC_PASSTHRU = 0x0200,
133 IBMVFC_TMF_MAD = 0x0100,
134 IBMVFC_NPIV_LOGOUT = 0x0800,
135 IBMVFC_CHANNEL_ENQUIRY = 0x1000,
136 IBMVFC_CHANNEL_SETUP = 0x2000,
137 IBMVFC_CONNECTION_INFO = 0x4000,
140 struct ibmvfc_mad_common {
147 } __packed __aligned(8);
149 struct ibmvfc_npiv_login_mad {
150 struct ibmvfc_mad_common common;
151 struct srp_direct_buf buffer;
152 } __packed __aligned(8);
154 struct ibmvfc_npiv_logout_mad {
155 struct ibmvfc_mad_common common;
156 } __packed __aligned(8);
158 #define IBMVFC_MAX_NAME 256
160 struct ibmvfc_npiv_login {
162 #define IBMVFC_OS_LINUX 0x02
167 __be32 partition_num;
168 __be32 vfc_frame_version;
171 #define IBMVFC_CLIENT_MIGRATED 0x01
172 #define IBMVFC_FLUSH_ON_HALT 0x02
175 #define IBMVFC_CAN_MIGRATE 0x01
176 #define IBMVFC_CAN_USE_CHANNELS 0x02
177 #define IBMVFC_CAN_HANDLE_FPIN 0x04
178 #define IBMVFC_CAN_USE_MAD_VERSION 0x08
179 #define IBMVFC_CAN_SEND_VF_WWPN 0x10
181 struct srp_direct_buf async;
182 u8 partition_name[IBMVFC_MAX_NAME];
183 u8 device_name[IBMVFC_MAX_NAME];
184 u8 drc_name[IBMVFC_MAX_NAME];
186 } __packed __aligned(8);
188 struct ibmvfc_common_svc_parms {
192 __be16 bb_rcv_sz; /* upper nibble is BB_SC_N */
195 } __packed __aligned(4);
197 struct ibmvfc_service_parms {
198 struct ibmvfc_common_svc_parms common;
201 __be32 class1_parms[4];
202 __be32 class2_parms[4];
203 __be32 class3_parms[4];
205 __be32 vendor_version[4];
206 __be32 services_avail[2];
209 __be32 clk_sync_qos[2];
211 } __packed __aligned(4);
213 struct ibmvfc_npiv_login_resp {
218 #define IBMVFC_NATIVE_FC 0x01
221 #define IBMVFC_CAN_FLUSH_ON_HALT 0x08
222 #define IBMVFC_CAN_SUPPRESS_ABTS 0x10
223 #define IBMVFC_MAD_VERSION_CAP 0x20
224 #define IBMVFC_HANDLE_VF_WWPN 0x40
225 #define IBMVFC_CAN_SUPPORT_CHANNELS 0x80
233 u8 partition_name[IBMVFC_MAX_NAME];
234 u8 device_name[IBMVFC_MAX_NAME];
235 u8 port_loc_code[IBMVFC_MAX_NAME];
236 u8 drc_name[IBMVFC_MAX_NAME];
237 struct ibmvfc_service_parms service_parms;
239 } __packed __aligned(8);
241 union ibmvfc_npiv_login_data {
242 struct ibmvfc_npiv_login login;
243 struct ibmvfc_npiv_login_resp resp;
244 } __packed __aligned(8);
246 struct ibmvfc_discover_targets_entry {
250 #define IBMVFC_DISC_TGT_SCSI_ID_MASK 0x00ffffff
251 } __packed __aligned(8);
253 struct ibmvfc_discover_targets {
254 struct ibmvfc_mad_common common;
255 struct srp_direct_buf buffer;
257 #define IBMVFC_DISC_TGT_PORT_ID_WWPN_LIST 0x02
264 } __packed __aligned(8);
266 enum ibmvfc_fc_reason {
267 IBMVFC_INVALID_ELS_CMD_CODE = 0x01,
268 IBMVFC_INVALID_VERSION = 0x02,
269 IBMVFC_LOGICAL_ERROR = 0x03,
270 IBMVFC_INVALID_CT_IU_SIZE = 0x04,
271 IBMVFC_LOGICAL_BUSY = 0x05,
272 IBMVFC_PROTOCOL_ERROR = 0x07,
273 IBMVFC_UNABLE_TO_PERFORM_REQ = 0x09,
274 IBMVFC_CMD_NOT_SUPPORTED = 0x0B,
275 IBMVFC_SERVER_NOT_AVAIL = 0x0D,
276 IBMVFC_CMD_IN_PROGRESS = 0x0E,
277 IBMVFC_VENDOR_SPECIFIC = 0xFF,
280 enum ibmvfc_fc_type {
281 IBMVFC_FABRIC_REJECT = 0x01,
282 IBMVFC_PORT_REJECT = 0x02,
283 IBMVFC_LS_REJECT = 0x03,
284 IBMVFC_FABRIC_BUSY = 0x04,
285 IBMVFC_PORT_BUSY = 0x05,
286 IBMVFC_BASIC_REJECT = 0x06,
289 enum ibmvfc_gs_explain {
290 IBMVFC_PORT_NAME_NOT_REG = 0x02,
293 struct ibmvfc_port_login {
294 struct ibmvfc_mad_common common;
297 __be16 fc_service_class;
301 __be16 error; /* also fc_reason */
305 struct ibmvfc_service_parms service_parms;
306 struct ibmvfc_service_parms service_parms_change;
309 } __packed __aligned(8);
311 struct ibmvfc_move_login {
312 struct ibmvfc_mad_common common;
318 #define IBMVFC_MOVE_LOGIN_IMPLICIT_OLD_FAILED 0x01
319 #define IBMVFC_MOVE_LOGIN_IMPLICIT_NEW_FAILED 0x02
320 #define IBMVFC_MOVE_LOGIN_PORT_LOGIN_FAILED 0x04
322 struct ibmvfc_service_parms service_parms;
323 struct ibmvfc_service_parms service_parms_change;
325 __be16 service_class;
327 #define IBMVFC_MOVE_LOGIN_VF_NOT_SENT_ADAPTER 0x01
329 } __packed __aligned(8);
331 struct ibmvfc_prli_svc_parms {
333 #define IBMVFC_SCSI_FCP_TYPE 0x08
336 #define IBMVFC_PRLI_ORIG_PA_VALID 0x8000
337 #define IBMVFC_PRLI_RESP_PA_VALID 0x4000
338 #define IBMVFC_PRLI_EST_IMG_PAIR 0x2000
341 __be32 service_parms;
342 #define IBMVFC_PRLI_TASK_RETRY 0x00000200
343 #define IBMVFC_PRLI_RETRY 0x00000100
344 #define IBMVFC_PRLI_DATA_OVERLAY 0x00000040
345 #define IBMVFC_PRLI_INITIATOR_FUNC 0x00000020
346 #define IBMVFC_PRLI_TARGET_FUNC 0x00000010
347 #define IBMVFC_PRLI_READ_FCP_XFER_RDY_DISABLED 0x00000002
348 #define IBMVFC_PRLI_WR_FCP_XFER_RDY_DISABLED 0x00000001
349 } __packed __aligned(4);
351 struct ibmvfc_process_login {
352 struct ibmvfc_mad_common common;
354 struct ibmvfc_prli_svc_parms parms;
357 __be16 error; /* also fc_reason */
361 } __packed __aligned(8);
363 struct ibmvfc_query_tgt {
364 struct ibmvfc_mad_common common;
372 } __packed __aligned(8);
374 struct ibmvfc_implicit_logout {
375 struct ibmvfc_mad_common common;
378 } __packed __aligned(8);
381 struct ibmvfc_mad_common common;
385 #define IBMVFC_TMF_ABORT_TASK 0x02
386 #define IBMVFC_TMF_ABORT_TASK_SET 0x04
387 #define IBMVFC_TMF_LUN_RESET 0x10
388 #define IBMVFC_TMF_TGT_RESET 0x20
389 #define IBMVFC_TMF_LUA_VALID 0x40
390 #define IBMVFC_TMF_SUPPRESS_ABTS 0x80
392 __be32 my_cancel_key;
397 } __packed __aligned(8);
399 enum ibmvfc_fcp_rsp_info_codes {
400 RSP_NO_FAILURE = 0x00,
401 RSP_TMF_REJECTED = 0x04,
402 RSP_TMF_FAILED = 0x05,
403 RSP_TMF_INVALID_LUN = 0x09,
406 struct ibmvfc_fcp_rsp_info {
410 } __packed __aligned(2);
412 enum ibmvfc_fcp_rsp_flags {
414 FCP_BIDI_READ_RESID_UNDER = 0x40,
415 FCP_BIDI_READ_RESID_OVER = 0x20,
417 FCP_RESID_UNDER = 0x08,
418 FCP_RESID_OVER = 0x04,
419 FCP_SNS_LEN_VALID = 0x02,
420 FCP_RSP_LEN_VALID = 0x01,
423 union ibmvfc_fcp_rsp_data {
424 struct ibmvfc_fcp_rsp_info info;
425 u8 sense[SCSI_SENSE_BUFFERSIZE + sizeof(struct ibmvfc_fcp_rsp_info)];
426 } __packed __aligned(8);
428 struct ibmvfc_fcp_rsp {
430 __be16 retry_delay_timer;
434 __be32 fcp_sense_len;
436 union ibmvfc_fcp_rsp_data data;
437 } __packed __aligned(8);
439 enum ibmvfc_cmd_flags {
440 IBMVFC_SCATTERLIST = 0x0001,
441 IBMVFC_NO_MEM_DESC = 0x0002,
442 IBMVFC_READ = 0x0004,
443 IBMVFC_WRITE = 0x0008,
445 IBMVFC_CLASS_3_ERR = 0x0100,
448 enum ibmvfc_fc_task_attr {
449 IBMVFC_SIMPLE_TASK = 0x00,
450 IBMVFC_HEAD_OF_QUEUE = 0x01,
451 IBMVFC_ORDERED_TASK = 0x02,
452 IBMVFC_ACA_TASK = 0x04,
455 enum ibmvfc_fc_tmf_flags {
456 IBMVFC_ABORT_TASK_SET = 0x02,
457 IBMVFC_LUN_RESET = 0x10,
458 IBMVFC_TARGET_RESET = 0x20,
461 struct ibmvfc_fcp_cmd_iu {
467 #define IBMVFC_RDDATA 0x02
468 #define IBMVFC_WRDATA 0x01
469 u8 cdb[IBMVFC_MAX_CDB_LEN];
471 } __packed __aligned(4);
478 __be32 adapter_resid;
482 __be16 response_flags;
483 #define IBMVFC_ADAPTER_RESID_VALID 0x01
486 struct srp_direct_buf ext_func;
487 struct srp_direct_buf ioba;
488 struct srp_direct_buf resp;
496 struct ibmvfc_fcp_cmd_iu iu;
497 struct ibmvfc_fcp_rsp rsp;
501 struct ibmvfc_fcp_cmd_iu iu;
502 struct ibmvfc_fcp_rsp rsp;
505 } __packed __aligned(8);
507 struct ibmvfc_passthru_fc_iu {
509 #define IBMVFC_ADISC 0x52000000
513 struct ibmvfc_passthru_iu {
520 #define IBMVFC_FC_ELS 0x01
521 #define IBMVFC_FC_CT_IU 0x02
523 #define IBMVFC_PASSTHRU_CANCEL_KEY 0x80000000
524 #define IBMVFC_INTERNAL_CANCEL_KEY 0x80000001
526 struct srp_direct_buf cmd;
527 struct srp_direct_buf rsp;
533 } __packed __aligned(8);
535 struct ibmvfc_passthru_mad {
536 struct ibmvfc_mad_common common;
537 struct srp_direct_buf cmd_ioba;
538 struct ibmvfc_passthru_iu iu;
539 struct ibmvfc_passthru_fc_iu fc_iu;
540 } __packed __aligned(8);
542 struct ibmvfc_channel_enquiry {
543 struct ibmvfc_mad_common common;
545 #define IBMVFC_NO_CHANNELS_TO_CRQ_SUPPORT 0x01
546 #define IBMVFC_SUPPORT_VARIABLE_SUBQ_MSG 0x02
547 #define IBMVFC_NO_N_TO_M_CHANNELS_SUPPORT 0x04
548 __be32 num_scsi_subq_channels;
549 __be32 num_nvmeof_subq_channels;
550 __be32 num_scsi_vas_channels;
551 __be32 num_nvmeof_vas_channels;
552 } __packed __aligned(8);
554 struct ibmvfc_channel_setup_mad {
555 struct ibmvfc_mad_common common;
556 struct srp_direct_buf buffer;
557 } __packed __aligned(8);
559 #define IBMVFC_MAX_CHANNELS 502
561 struct ibmvfc_channel_setup {
563 #define IBMVFC_CANCEL_CHANNELS 0x01
564 #define IBMVFC_USE_BUFFER 0x02
565 #define IBMVFC_CHANNELS_CANCELED 0x04
567 __be32 num_scsi_subq_channels;
568 __be32 num_nvmeof_subq_channels;
569 __be32 num_scsi_vas_channels;
570 __be32 num_nvmeof_vas_channels;
571 struct srp_direct_buf buffer;
573 __be64 channel_handles[IBMVFC_MAX_CHANNELS];
574 } __packed __aligned(8);
576 struct ibmvfc_connection_info {
577 struct ibmvfc_mad_common common;
578 __be64 information_bits;
579 #define IBMVFC_NO_FC_IO_CHANNEL 0x01
580 #define IBMVFC_NO_PHYP_VAS 0x02
581 #define IBMVFC_NO_PHYP_SUBQ 0x04
582 #define IBMVFC_PHYP_DEPRECATED_SUBQ 0x08
583 #define IBMVFC_PHYP_PRESERVED_SUBQ 0x10
584 #define IBMVFC_PHYP_FULL_SUBQ 0x20
586 } __packed __aligned(8);
588 struct ibmvfc_trace_start_entry {
592 struct ibmvfc_trace_end_entry {
601 struct ibmvfc_trace_entry {
602 struct ibmvfc_event *evt;
610 #define IBMVFC_TRC_START 0x00
611 #define IBMVFC_TRC_END 0xff
613 struct ibmvfc_trace_start_entry start;
614 struct ibmvfc_trace_end_entry end;
616 } __packed __aligned(8);
618 enum ibmvfc_crq_formats {
619 IBMVFC_CMD_FORMAT = 0x01,
620 IBMVFC_ASYNC_EVENT = 0x02,
621 IBMVFC_MAD_FORMAT = 0x04,
624 enum ibmvfc_async_event {
625 IBMVFC_AE_ELS_PLOGI = 0x0001,
626 IBMVFC_AE_ELS_LOGO = 0x0002,
627 IBMVFC_AE_ELS_PRLO = 0x0004,
628 IBMVFC_AE_SCN_NPORT = 0x0008,
629 IBMVFC_AE_SCN_GROUP = 0x0010,
630 IBMVFC_AE_SCN_DOMAIN = 0x0020,
631 IBMVFC_AE_SCN_FABRIC = 0x0040,
632 IBMVFC_AE_LINK_UP = 0x0080,
633 IBMVFC_AE_LINK_DOWN = 0x0100,
634 IBMVFC_AE_LINK_DEAD = 0x0200,
635 IBMVFC_AE_HALT = 0x0400,
636 IBMVFC_AE_RESUME = 0x0800,
637 IBMVFC_AE_ADAPTER_FAILED = 0x1000,
638 IBMVFC_AE_FPIN = 0x2000,
641 struct ibmvfc_async_desc {
643 enum ibmvfc_async_event ae;
651 volatile __be64 ioba;
652 } __packed __aligned(8);
654 struct ibmvfc_sub_crq {
655 struct ibmvfc_crq crq;
657 } __packed __aligned(8);
659 enum ibmvfc_ae_link_state {
660 IBMVFC_AE_LS_LINK_UP = 0x01,
661 IBMVFC_AE_LS_LINK_BOUNCED = 0x02,
662 IBMVFC_AE_LS_LINK_DOWN = 0x04,
663 IBMVFC_AE_LS_LINK_DEAD = 0x08,
666 enum ibmvfc_ae_fpin_status {
667 IBMVFC_AE_FPIN_LINK_CONGESTED = 0x1,
668 IBMVFC_AE_FPIN_PORT_CONGESTED = 0x2,
669 IBMVFC_AE_FPIN_PORT_CLEARED = 0x3,
670 IBMVFC_AE_FPIN_PORT_DEGRADED = 0x4,
673 struct ibmvfc_async_crq {
679 volatile __be64 event;
680 volatile __be64 scsi_id;
681 volatile __be64 wwpn;
682 volatile __be64 node_name;
684 } __packed __aligned(8);
687 struct ibmvfc_mad_common mad_common;
688 struct ibmvfc_npiv_login_mad npiv_login;
689 struct ibmvfc_npiv_logout_mad npiv_logout;
690 struct ibmvfc_discover_targets discover_targets;
691 struct ibmvfc_port_login plogi;
692 struct ibmvfc_process_login prli;
693 struct ibmvfc_move_login move_login;
694 struct ibmvfc_query_tgt query_tgt;
695 struct ibmvfc_implicit_logout implicit_logout;
696 struct ibmvfc_tmf tmf;
697 struct ibmvfc_cmd cmd;
698 struct ibmvfc_passthru_mad passthru;
699 struct ibmvfc_channel_enquiry channel_enquiry;
700 struct ibmvfc_channel_setup_mad channel_setup;
701 struct ibmvfc_connection_info connection_info;
702 } __packed __aligned(8);
704 enum ibmvfc_target_action {
705 IBMVFC_TGT_ACTION_NONE = 0,
706 IBMVFC_TGT_ACTION_INIT,
707 IBMVFC_TGT_ACTION_INIT_WAIT,
708 IBMVFC_TGT_ACTION_LOGOUT_RPORT,
709 IBMVFC_TGT_ACTION_LOGOUT_RPORT_WAIT,
710 IBMVFC_TGT_ACTION_DEL_RPORT,
711 IBMVFC_TGT_ACTION_DELETED_RPORT,
712 IBMVFC_TGT_ACTION_DEL_AND_LOGOUT_RPORT,
713 IBMVFC_TGT_ACTION_LOGOUT_DELETED_RPORT,
716 struct ibmvfc_target {
717 struct list_head queue;
718 struct ibmvfc_host *vhost;
722 struct fc_rport *rport;
724 enum ibmvfc_target_action action;
731 struct ibmvfc_service_parms service_parms;
732 struct ibmvfc_service_parms service_parms_change;
733 struct fc_rport_identifiers ids;
734 void (*job_step) (struct ibmvfc_target *);
735 struct timer_list timer;
739 /* a unit of work for the hosting partition */
740 struct ibmvfc_event {
741 struct list_head queue_list;
742 struct list_head cancel;
743 struct ibmvfc_host *vhost;
744 struct ibmvfc_queue *queue;
745 struct ibmvfc_target *tgt;
746 struct scsi_cmnd *cmnd;
749 union ibmvfc_iu *xfer_iu;
750 void (*done)(struct ibmvfc_event *evt);
751 void (*_done)(struct ibmvfc_event *evt);
752 struct ibmvfc_crq crq;
754 union ibmvfc_iu *sync_iu;
755 struct srp_direct_buf *ext_list;
756 dma_addr_t ext_list_token;
757 struct completion comp;
758 struct completion *eh_comp;
759 struct timer_list timer;
763 /* a pool of event structs for use */
764 struct ibmvfc_event_pool {
765 struct ibmvfc_event *events;
767 union ibmvfc_iu *iu_storage;
771 enum ibmvfc_msg_fmt {
779 struct ibmvfc_crq *crq;
780 struct ibmvfc_async_crq *async;
781 struct ibmvfc_sub_crq *scrq;
784 struct ibmvfc_queue {
785 union ibmvfc_msgs msgs;
786 dma_addr_t msg_token;
787 enum ibmvfc_msg_fmt fmt;
792 struct ibmvfc_host *vhost;
793 struct ibmvfc_event_pool evt_pool;
794 struct list_head sent;
795 struct list_head free;
798 union ibmvfc_iu cancel_rsp;
801 unsigned long cookie;
802 unsigned long vios_cookie;
803 unsigned long hw_irq;
805 unsigned long hwq_id;
809 struct ibmvfc_scsi_channels {
810 struct ibmvfc_queue *scrqs;
811 unsigned int active_queues;
814 enum ibmvfc_host_action {
815 IBMVFC_HOST_ACTION_NONE = 0,
816 IBMVFC_HOST_ACTION_RESET,
817 IBMVFC_HOST_ACTION_REENABLE,
818 IBMVFC_HOST_ACTION_LOGO,
819 IBMVFC_HOST_ACTION_LOGO_WAIT,
820 IBMVFC_HOST_ACTION_INIT,
821 IBMVFC_HOST_ACTION_INIT_WAIT,
822 IBMVFC_HOST_ACTION_QUERY,
823 IBMVFC_HOST_ACTION_QUERY_TGTS,
824 IBMVFC_HOST_ACTION_TGT_DEL,
825 IBMVFC_HOST_ACTION_ALLOC_TGTS,
826 IBMVFC_HOST_ACTION_TGT_INIT,
827 IBMVFC_HOST_ACTION_TGT_DEL_FAILED,
830 enum ibmvfc_host_state {
842 struct list_head queue;
843 struct Scsi_Host *host;
844 enum ibmvfc_host_state state;
845 enum ibmvfc_host_action action;
846 #define IBMVFC_NUM_TRACE_INDEX_BITS 8
847 #define IBMVFC_NUM_TRACE_ENTRIES (1 << IBMVFC_NUM_TRACE_INDEX_BITS)
848 #define IBMVFC_TRACE_INDEX_MASK (IBMVFC_NUM_TRACE_ENTRIES - 1)
849 #define IBMVFC_TRACE_SIZE (sizeof(struct ibmvfc_trace_entry) * IBMVFC_NUM_TRACE_ENTRIES)
850 struct ibmvfc_trace_entry *trace;
851 atomic_t trace_index;
853 struct list_head targets;
854 struct list_head purge;
856 struct dma_pool *sg_pool;
858 struct ibmvfc_queue crq;
859 struct ibmvfc_queue async_crq;
860 struct ibmvfc_scsi_channels scsi_scrqs;
861 struct ibmvfc_npiv_login login_info;
862 union ibmvfc_npiv_login_data *login_buf;
863 dma_addr_t login_buf_dma;
864 struct ibmvfc_channel_setup *channel_setup_buf;
865 dma_addr_t channel_setup_dma;
868 struct ibmvfc_discover_targets_entry *disc_buf;
869 struct mutex passthru_mutex;
870 int max_vios_scsi_channels;
873 int discovery_threads;
884 int client_scsi_channels;
885 int aborting_passthru;
887 #define IBMVFC_AE_LINKUP 0x0001
888 #define IBMVFC_AE_LINKDOWN 0x0002
889 #define IBMVFC_AE_RSCN 0x0004
890 dma_addr_t disc_buf_dma;
891 unsigned int partition_number;
892 char partition_name[97];
893 void (*job_step) (struct ibmvfc_host *);
894 struct task_struct *work_thread;
895 struct tasklet_struct tasklet;
896 struct work_struct rport_add_work_q;
897 wait_queue_head_t init_wait_q;
898 wait_queue_head_t work_wait_q;
901 #define DBG_CMD(CMD) do { if (ibmvfc_debug) CMD; } while (0)
903 #define tgt_dbg(t, fmt, ...) \
904 DBG_CMD(dev_info((t)->vhost->dev, "%llX: " fmt, (t)->scsi_id, ##__VA_ARGS__))
906 #define tgt_info(t, fmt, ...) \
907 dev_info((t)->vhost->dev, "%llX: " fmt, (t)->scsi_id, ##__VA_ARGS__)
909 #define tgt_err(t, fmt, ...) \
910 dev_err((t)->vhost->dev, "%llX: " fmt, (t)->scsi_id, ##__VA_ARGS__)
912 #define tgt_log(t, level, fmt, ...) \
914 if ((t)->vhost->log_level >= level) \
915 tgt_err(t, fmt, ##__VA_ARGS__); \
918 #define ibmvfc_dbg(vhost, ...) \
919 DBG_CMD(dev_info((vhost)->dev, ##__VA_ARGS__))
921 #define ibmvfc_log(vhost, level, ...) \
923 if ((vhost)->log_level >= level) \
924 dev_err((vhost)->dev, ##__VA_ARGS__); \
927 #define ENTER DBG_CMD(printk(KERN_INFO IBMVFC_NAME": Entering %s\n", __func__))
928 #define LEAVE DBG_CMD(printk(KERN_INFO IBMVFC_NAME": Leaving %s\n", __func__))
930 #ifdef CONFIG_SCSI_IBMVFC_TRACE
931 #define ibmvfc_create_trace_file(kobj, attr) sysfs_create_bin_file(kobj, attr)
932 #define ibmvfc_remove_trace_file(kobj, attr) sysfs_remove_bin_file(kobj, attr)
934 #define ibmvfc_create_trace_file(kobj, attr) 0
935 #define ibmvfc_remove_trace_file(kobj, attr) do { } while (0)