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
46 * Ensure we have resources for ERP and initialization:
48 * 1 for initialization
51 * 2 for each discovery thread
53 #define IBMVFC_NUM_INTERNAL_REQ (1 + 1 + 1 + 2 + (disc_threads * 2))
55 #define IBMVFC_MAD_SUCCESS 0x00
56 #define IBMVFC_MAD_NOT_SUPPORTED 0xF1
57 #define IBMVFC_MAD_VERSION_NOT_SUPP 0xF2
58 #define IBMVFC_MAD_FAILED 0xF7
59 #define IBMVFC_MAD_DRIVER_FAILED 0xEE
60 #define IBMVFC_MAD_CRQ_ERROR 0xEF
62 enum ibmvfc_crq_valid
{
63 IBMVFC_CRQ_CMD_RSP
= 0x80,
64 IBMVFC_CRQ_INIT_RSP
= 0xC0,
65 IBMVFC_CRQ_XPORT_EVENT
= 0xFF,
68 enum ibmvfc_crq_init_msg
{
69 IBMVFC_CRQ_INIT
= 0x01,
70 IBMVFC_CRQ_INIT_COMPLETE
= 0x02,
73 enum ibmvfc_crq_xport_evts
{
74 IBMVFC_PARTNER_FAILED
= 0x01,
75 IBMVFC_PARTNER_DEREGISTER
= 0x02,
76 IBMVFC_PARTITION_MIGRATED
= 0x06,
79 enum ibmvfc_cmd_status_flags
{
80 IBMVFC_FABRIC_MAPPED
= 0x0001,
81 IBMVFC_VIOS_FAILURE
= 0x0002,
82 IBMVFC_FC_FAILURE
= 0x0004,
83 IBMVFC_FC_SCSI_ERROR
= 0x0008,
84 IBMVFC_HW_EVENT_LOGGED
= 0x0010,
85 IBMVFC_VIOS_LOGGED
= 0x0020,
88 enum ibmvfc_fabric_mapped_errors
{
89 IBMVFC_UNABLE_TO_ESTABLISH
= 0x0001,
90 IBMVFC_XPORT_FAULT
= 0x0002,
91 IBMVFC_CMD_TIMEOUT
= 0x0003,
92 IBMVFC_ENETDOWN
= 0x0004,
93 IBMVFC_HW_FAILURE
= 0x0005,
94 IBMVFC_LINK_DOWN_ERR
= 0x0006,
95 IBMVFC_LINK_DEAD_ERR
= 0x0007,
96 IBMVFC_UNABLE_TO_REGISTER
= 0x0008,
97 IBMVFC_XPORT_BUSY
= 0x000A,
98 IBMVFC_XPORT_DEAD
= 0x000B,
99 IBMVFC_CONFIG_ERROR
= 0x000C,
100 IBMVFC_NAME_SERVER_FAIL
= 0x000D,
101 IBMVFC_LINK_HALTED
= 0x000E,
102 IBMVFC_XPORT_GENERAL
= 0x8000,
105 enum ibmvfc_vios_errors
{
106 IBMVFC_CRQ_FAILURE
= 0x0001,
107 IBMVFC_SW_FAILURE
= 0x0002,
108 IBMVFC_INVALID_PARAMETER
= 0x0003,
109 IBMVFC_MISSING_PARAMETER
= 0x0004,
110 IBMVFC_HOST_IO_BUS
= 0x0005,
111 IBMVFC_TRANS_CANCELLED
= 0x0006,
112 IBMVFC_TRANS_CANCELLED_IMPLICIT
= 0x0007,
113 IBMVFC_INSUFFICIENT_RESOURCE
= 0x0008,
114 IBMVFC_PLOGI_REQUIRED
= 0x0010,
115 IBMVFC_COMMAND_FAILED
= 0x8000,
118 enum ibmvfc_mad_types
{
119 IBMVFC_NPIV_LOGIN
= 0x0001,
120 IBMVFC_DISC_TARGETS
= 0x0002,
121 IBMVFC_PORT_LOGIN
= 0x0004,
122 IBMVFC_PROCESS_LOGIN
= 0x0008,
123 IBMVFC_QUERY_TARGET
= 0x0010,
124 IBMVFC_MOVE_LOGIN
= 0x0020,
125 IBMVFC_IMPLICIT_LOGOUT
= 0x0040,
126 IBMVFC_PASSTHRU
= 0x0200,
127 IBMVFC_TMF_MAD
= 0x0100,
128 IBMVFC_NPIV_LOGOUT
= 0x0800,
129 IBMVFC_CHANNEL_ENQUIRY
= 0x1000,
130 IBMVFC_CHANNEL_SETUP
= 0x2000,
131 IBMVFC_CONNECTION_INFO
= 0x4000,
134 struct ibmvfc_mad_common
{
141 } __packed
__aligned(8);
143 struct ibmvfc_npiv_login_mad
{
144 struct ibmvfc_mad_common common
;
145 struct srp_direct_buf buffer
;
146 } __packed
__aligned(8);
148 struct ibmvfc_npiv_logout_mad
{
149 struct ibmvfc_mad_common common
;
150 } __packed
__aligned(8);
152 #define IBMVFC_MAX_NAME 256
154 struct ibmvfc_npiv_login
{
156 #define IBMVFC_OS_LINUX 0x02
161 __be32 partition_num
;
162 __be32 vfc_frame_version
;
165 #define IBMVFC_CLIENT_MIGRATED 0x01
166 #define IBMVFC_FLUSH_ON_HALT 0x02
169 #define IBMVFC_CAN_MIGRATE 0x01
170 #define IBMVFC_CAN_USE_CHANNELS 0x02
171 #define IBMVFC_CAN_HANDLE_FPIN 0x04
172 #define IBMVFC_CAN_USE_MAD_VERSION 0x08
173 #define IBMVFC_CAN_SEND_VF_WWPN 0x10
175 struct srp_direct_buf async
;
176 u8 partition_name
[IBMVFC_MAX_NAME
];
177 u8 device_name
[IBMVFC_MAX_NAME
];
178 u8 drc_name
[IBMVFC_MAX_NAME
];
180 } __packed
__aligned(8);
182 struct ibmvfc_common_svc_parms
{
186 __be16 bb_rcv_sz
; /* upper nibble is BB_SC_N */
189 } __packed
__aligned(4);
191 struct ibmvfc_service_parms
{
192 struct ibmvfc_common_svc_parms common
;
195 __be32 class1_parms
[4];
196 __be32 class2_parms
[4];
197 __be32 class3_parms
[4];
199 __be32 vendor_version
[4];
200 __be32 services_avail
[2];
203 __be32 clk_sync_qos
[2];
205 } __packed
__aligned(4);
207 struct ibmvfc_npiv_login_resp
{
212 #define IBMVFC_NATIVE_FC 0x01
215 #define IBMVFC_CAN_FLUSH_ON_HALT 0x08
216 #define IBMVFC_CAN_SUPPRESS_ABTS 0x10
217 #define IBMVFC_MAD_VERSION_CAP 0x20
218 #define IBMVFC_HANDLE_VF_WWPN 0x40
219 #define IBMVFC_CAN_SUPPORT_CHANNELS 0x80
227 u8 partition_name
[IBMVFC_MAX_NAME
];
228 u8 device_name
[IBMVFC_MAX_NAME
];
229 u8 port_loc_code
[IBMVFC_MAX_NAME
];
230 u8 drc_name
[IBMVFC_MAX_NAME
];
231 struct ibmvfc_service_parms service_parms
;
233 } __packed
__aligned(8);
235 union ibmvfc_npiv_login_data
{
236 struct ibmvfc_npiv_login login
;
237 struct ibmvfc_npiv_login_resp resp
;
238 } __packed
__aligned(8);
240 struct ibmvfc_discover_targets_entry
{
244 #define IBMVFC_DISC_TGT_SCSI_ID_MASK 0x00ffffff
245 } __packed
__aligned(8);
247 struct ibmvfc_discover_targets
{
248 struct ibmvfc_mad_common common
;
249 struct srp_direct_buf buffer
;
251 #define IBMVFC_DISC_TGT_PORT_ID_WWPN_LIST 0x02
258 } __packed
__aligned(8);
260 enum ibmvfc_fc_reason
{
261 IBMVFC_INVALID_ELS_CMD_CODE
= 0x01,
262 IBMVFC_INVALID_VERSION
= 0x02,
263 IBMVFC_LOGICAL_ERROR
= 0x03,
264 IBMVFC_INVALID_CT_IU_SIZE
= 0x04,
265 IBMVFC_LOGICAL_BUSY
= 0x05,
266 IBMVFC_PROTOCOL_ERROR
= 0x07,
267 IBMVFC_UNABLE_TO_PERFORM_REQ
= 0x09,
268 IBMVFC_CMD_NOT_SUPPORTED
= 0x0B,
269 IBMVFC_SERVER_NOT_AVAIL
= 0x0D,
270 IBMVFC_CMD_IN_PROGRESS
= 0x0E,
271 IBMVFC_VENDOR_SPECIFIC
= 0xFF,
274 enum ibmvfc_fc_type
{
275 IBMVFC_FABRIC_REJECT
= 0x01,
276 IBMVFC_PORT_REJECT
= 0x02,
277 IBMVFC_LS_REJECT
= 0x03,
278 IBMVFC_FABRIC_BUSY
= 0x04,
279 IBMVFC_PORT_BUSY
= 0x05,
280 IBMVFC_BASIC_REJECT
= 0x06,
283 enum ibmvfc_gs_explain
{
284 IBMVFC_PORT_NAME_NOT_REG
= 0x02,
287 struct ibmvfc_port_login
{
288 struct ibmvfc_mad_common common
;
291 __be16 fc_service_class
;
295 __be16 error
; /* also fc_reason */
299 struct ibmvfc_service_parms service_parms
;
300 struct ibmvfc_service_parms service_parms_change
;
303 } __packed
__aligned(8);
305 struct ibmvfc_move_login
{
306 struct ibmvfc_mad_common common
;
312 #define IBMVFC_MOVE_LOGIN_IMPLICIT_OLD_FAILED 0x01
313 #define IBMVFC_MOVE_LOGIN_IMPLICIT_NEW_FAILED 0x02
314 #define IBMVFC_MOVE_LOGIN_PORT_LOGIN_FAILED 0x04
316 struct ibmvfc_service_parms service_parms
;
317 struct ibmvfc_service_parms service_parms_change
;
319 __be16 service_class
;
321 #define IBMVFC_MOVE_LOGIN_VF_NOT_SENT_ADAPTER 0x01
323 } __packed
__aligned(8);
325 struct ibmvfc_prli_svc_parms
{
327 #define IBMVFC_SCSI_FCP_TYPE 0x08
330 #define IBMVFC_PRLI_ORIG_PA_VALID 0x8000
331 #define IBMVFC_PRLI_RESP_PA_VALID 0x4000
332 #define IBMVFC_PRLI_EST_IMG_PAIR 0x2000
335 __be32 service_parms
;
336 #define IBMVFC_PRLI_TASK_RETRY 0x00000200
337 #define IBMVFC_PRLI_RETRY 0x00000100
338 #define IBMVFC_PRLI_DATA_OVERLAY 0x00000040
339 #define IBMVFC_PRLI_INITIATOR_FUNC 0x00000020
340 #define IBMVFC_PRLI_TARGET_FUNC 0x00000010
341 #define IBMVFC_PRLI_READ_FCP_XFER_RDY_DISABLED 0x00000002
342 #define IBMVFC_PRLI_WR_FCP_XFER_RDY_DISABLED 0x00000001
343 } __packed
__aligned(4);
345 struct ibmvfc_process_login
{
346 struct ibmvfc_mad_common common
;
348 struct ibmvfc_prli_svc_parms parms
;
351 __be16 error
; /* also fc_reason */
355 } __packed
__aligned(8);
357 struct ibmvfc_query_tgt
{
358 struct ibmvfc_mad_common common
;
366 } __packed
__aligned(8);
368 struct ibmvfc_implicit_logout
{
369 struct ibmvfc_mad_common common
;
372 } __packed
__aligned(8);
375 struct ibmvfc_mad_common common
;
379 #define IBMVFC_TMF_ABORT_TASK 0x02
380 #define IBMVFC_TMF_ABORT_TASK_SET 0x04
381 #define IBMVFC_TMF_LUN_RESET 0x10
382 #define IBMVFC_TMF_TGT_RESET 0x20
383 #define IBMVFC_TMF_LUA_VALID 0x40
384 #define IBMVFC_TMF_SUPPRESS_ABTS 0x80
386 __be32 my_cancel_key
;
391 } __packed
__aligned(8);
393 enum ibmvfc_fcp_rsp_info_codes
{
394 RSP_NO_FAILURE
= 0x00,
395 RSP_TMF_REJECTED
= 0x04,
396 RSP_TMF_FAILED
= 0x05,
397 RSP_TMF_INVALID_LUN
= 0x09,
400 struct ibmvfc_fcp_rsp_info
{
404 } __packed
__aligned(2);
406 enum ibmvfc_fcp_rsp_flags
{
408 FCP_BIDI_READ_RESID_UNDER
= 0x40,
409 FCP_BIDI_READ_RESID_OVER
= 0x20,
411 FCP_RESID_UNDER
= 0x08,
412 FCP_RESID_OVER
= 0x04,
413 FCP_SNS_LEN_VALID
= 0x02,
414 FCP_RSP_LEN_VALID
= 0x01,
417 union ibmvfc_fcp_rsp_data
{
418 struct ibmvfc_fcp_rsp_info info
;
419 u8 sense
[SCSI_SENSE_BUFFERSIZE
+ sizeof(struct ibmvfc_fcp_rsp_info
)];
420 } __packed
__aligned(8);
422 struct ibmvfc_fcp_rsp
{
424 __be16 retry_delay_timer
;
428 __be32 fcp_sense_len
;
430 union ibmvfc_fcp_rsp_data data
;
431 } __packed
__aligned(8);
433 enum ibmvfc_cmd_flags
{
434 IBMVFC_SCATTERLIST
= 0x0001,
435 IBMVFC_NO_MEM_DESC
= 0x0002,
436 IBMVFC_READ
= 0x0004,
437 IBMVFC_WRITE
= 0x0008,
439 IBMVFC_CLASS_3_ERR
= 0x0100,
442 enum ibmvfc_fc_task_attr
{
443 IBMVFC_SIMPLE_TASK
= 0x00,
444 IBMVFC_HEAD_OF_QUEUE
= 0x01,
445 IBMVFC_ORDERED_TASK
= 0x02,
446 IBMVFC_ACA_TASK
= 0x04,
449 enum ibmvfc_fc_tmf_flags
{
450 IBMVFC_ABORT_TASK_SET
= 0x02,
451 IBMVFC_LUN_RESET
= 0x10,
452 IBMVFC_TARGET_RESET
= 0x20,
455 struct ibmvfc_fcp_cmd_iu
{
461 #define IBMVFC_RDDATA 0x02
462 #define IBMVFC_WRDATA 0x01
463 u8 cdb
[IBMVFC_MAX_CDB_LEN
];
465 } __packed
__aligned(4);
472 __be32 adapter_resid
;
476 __be16 response_flags
;
477 #define IBMVFC_ADAPTER_RESID_VALID 0x01
480 struct srp_direct_buf ext_func
;
481 struct srp_direct_buf ioba
;
482 struct srp_direct_buf resp
;
490 struct ibmvfc_fcp_cmd_iu iu
;
491 struct ibmvfc_fcp_rsp rsp
;
495 struct ibmvfc_fcp_cmd_iu iu
;
496 struct ibmvfc_fcp_rsp rsp
;
499 } __packed
__aligned(8);
501 struct ibmvfc_passthru_fc_iu
{
503 #define IBMVFC_ADISC 0x52000000
507 struct ibmvfc_passthru_iu
{
514 #define IBMVFC_FC_ELS 0x01
515 #define IBMVFC_FC_CT_IU 0x02
517 #define IBMVFC_PASSTHRU_CANCEL_KEY 0x80000000
518 #define IBMVFC_INTERNAL_CANCEL_KEY 0x80000001
520 struct srp_direct_buf cmd
;
521 struct srp_direct_buf rsp
;
527 } __packed
__aligned(8);
529 struct ibmvfc_passthru_mad
{
530 struct ibmvfc_mad_common common
;
531 struct srp_direct_buf cmd_ioba
;
532 struct ibmvfc_passthru_iu iu
;
533 struct ibmvfc_passthru_fc_iu fc_iu
;
534 } __packed
__aligned(8);
536 struct ibmvfc_channel_enquiry
{
537 struct ibmvfc_mad_common common
;
539 #define IBMVFC_NO_CHANNELS_TO_CRQ_SUPPORT 0x01
540 #define IBMVFC_SUPPORT_VARIABLE_SUBQ_MSG 0x02
541 #define IBMVFC_NO_N_TO_M_CHANNELS_SUPPORT 0x04
542 __be32 num_scsi_subq_channels
;
543 __be32 num_nvmeof_subq_channels
;
544 __be32 num_scsi_vas_channels
;
545 __be32 num_nvmeof_vas_channels
;
546 } __packed
__aligned(8);
548 struct ibmvfc_channel_setup_mad
{
549 struct ibmvfc_mad_common common
;
550 struct srp_direct_buf buffer
;
551 } __packed
__aligned(8);
553 #define IBMVFC_MAX_CHANNELS 502
555 struct ibmvfc_channel_setup
{
557 #define IBMVFC_CANCEL_CHANNELS 0x01
558 #define IBMVFC_USE_BUFFER 0x02
559 #define IBMVFC_CHANNELS_CANCELED 0x04
561 __be32 num_scsi_subq_channels
;
562 __be32 num_nvmeof_subq_channels
;
563 __be32 num_scsi_vas_channels
;
564 __be32 num_nvmeof_vas_channels
;
565 struct srp_direct_buf buffer
;
567 __be64 channel_handles
[IBMVFC_MAX_CHANNELS
];
568 } __packed
__aligned(8);
570 struct ibmvfc_connection_info
{
571 struct ibmvfc_mad_common common
;
572 __be64 information_bits
;
573 #define IBMVFC_NO_FC_IO_CHANNEL 0x01
574 #define IBMVFC_NO_PHYP_VAS 0x02
575 #define IBMVFC_NO_PHYP_SUBQ 0x04
576 #define IBMVFC_PHYP_DEPRECATED_SUBQ 0x08
577 #define IBMVFC_PHYP_PRESERVED_SUBQ 0x10
578 #define IBMVFC_PHYP_FULL_SUBQ 0x20
580 } __packed
__aligned(8);
582 struct ibmvfc_trace_start_entry
{
586 struct ibmvfc_trace_end_entry
{
595 struct ibmvfc_trace_entry
{
596 struct ibmvfc_event
*evt
;
604 #define IBMVFC_TRC_START 0x00
605 #define IBMVFC_TRC_END 0xff
607 struct ibmvfc_trace_start_entry start
;
608 struct ibmvfc_trace_end_entry end
;
610 } __packed
__aligned(8);
612 enum ibmvfc_crq_formats
{
613 IBMVFC_CMD_FORMAT
= 0x01,
614 IBMVFC_ASYNC_EVENT
= 0x02,
615 IBMVFC_MAD_FORMAT
= 0x04,
618 enum ibmvfc_async_event
{
619 IBMVFC_AE_ELS_PLOGI
= 0x0001,
620 IBMVFC_AE_ELS_LOGO
= 0x0002,
621 IBMVFC_AE_ELS_PRLO
= 0x0004,
622 IBMVFC_AE_SCN_NPORT
= 0x0008,
623 IBMVFC_AE_SCN_GROUP
= 0x0010,
624 IBMVFC_AE_SCN_DOMAIN
= 0x0020,
625 IBMVFC_AE_SCN_FABRIC
= 0x0040,
626 IBMVFC_AE_LINK_UP
= 0x0080,
627 IBMVFC_AE_LINK_DOWN
= 0x0100,
628 IBMVFC_AE_LINK_DEAD
= 0x0200,
629 IBMVFC_AE_HALT
= 0x0400,
630 IBMVFC_AE_RESUME
= 0x0800,
631 IBMVFC_AE_ADAPTER_FAILED
= 0x1000,
632 IBMVFC_AE_FPIN
= 0x2000,
635 struct ibmvfc_async_desc
{
637 enum ibmvfc_async_event ae
;
645 volatile __be64 ioba
;
646 } __packed
__aligned(8);
648 struct ibmvfc_crq_queue
{
649 struct ibmvfc_crq
*msgs
;
651 dma_addr_t msg_token
;
654 enum ibmvfc_ae_link_state
{
655 IBMVFC_AE_LS_LINK_UP
= 0x01,
656 IBMVFC_AE_LS_LINK_BOUNCED
= 0x02,
657 IBMVFC_AE_LS_LINK_DOWN
= 0x04,
658 IBMVFC_AE_LS_LINK_DEAD
= 0x08,
661 enum ibmvfc_ae_fpin_status
{
662 IBMVFC_AE_FPIN_LINK_CONGESTED
= 0x1,
663 IBMVFC_AE_FPIN_PORT_CONGESTED
= 0x2,
664 IBMVFC_AE_FPIN_PORT_CLEARED
= 0x3,
665 IBMVFC_AE_FPIN_PORT_DEGRADED
= 0x4,
668 struct ibmvfc_async_crq
{
674 volatile __be64 event
;
675 volatile __be64 scsi_id
;
676 volatile __be64 wwpn
;
677 volatile __be64 node_name
;
679 } __packed
__aligned(8);
681 struct ibmvfc_async_crq_queue
{
682 struct ibmvfc_async_crq
*msgs
;
684 dma_addr_t msg_token
;
688 struct ibmvfc_mad_common mad_common
;
689 struct ibmvfc_npiv_login_mad npiv_login
;
690 struct ibmvfc_npiv_logout_mad npiv_logout
;
691 struct ibmvfc_discover_targets discover_targets
;
692 struct ibmvfc_port_login plogi
;
693 struct ibmvfc_process_login prli
;
694 struct ibmvfc_move_login move_login
;
695 struct ibmvfc_query_tgt query_tgt
;
696 struct ibmvfc_implicit_logout implicit_logout
;
697 struct ibmvfc_tmf tmf
;
698 struct ibmvfc_cmd cmd
;
699 struct ibmvfc_passthru_mad passthru
;
700 struct ibmvfc_channel_enquiry channel_enquiry
;
701 struct ibmvfc_channel_setup_mad channel_setup
;
702 struct ibmvfc_connection_info connection_info
;
703 } __packed
__aligned(8);
705 enum ibmvfc_target_action
{
706 IBMVFC_TGT_ACTION_NONE
= 0,
707 IBMVFC_TGT_ACTION_INIT
,
708 IBMVFC_TGT_ACTION_INIT_WAIT
,
709 IBMVFC_TGT_ACTION_LOGOUT_RPORT
,
710 IBMVFC_TGT_ACTION_LOGOUT_RPORT_WAIT
,
711 IBMVFC_TGT_ACTION_DEL_RPORT
,
712 IBMVFC_TGT_ACTION_DELETED_RPORT
,
713 IBMVFC_TGT_ACTION_DEL_AND_LOGOUT_RPORT
,
714 IBMVFC_TGT_ACTION_LOGOUT_DELETED_RPORT
,
717 struct ibmvfc_target
{
718 struct list_head queue
;
719 struct ibmvfc_host
*vhost
;
723 struct fc_rport
*rport
;
725 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
;
742 struct ibmvfc_host
*vhost
;
743 struct ibmvfc_target
*tgt
;
744 struct scsi_cmnd
*cmnd
;
746 union ibmvfc_iu
*xfer_iu
;
747 void (*done
) (struct ibmvfc_event
*);
748 struct ibmvfc_crq crq
;
750 union ibmvfc_iu
*sync_iu
;
751 struct srp_direct_buf
*ext_list
;
752 dma_addr_t ext_list_token
;
753 struct completion comp
;
754 struct completion
*eh_comp
;
755 struct timer_list timer
;
758 /* a pool of event structs for use */
759 struct ibmvfc_event_pool
{
760 struct ibmvfc_event
*events
;
762 union ibmvfc_iu
*iu_storage
;
766 enum ibmvfc_host_action
{
767 IBMVFC_HOST_ACTION_NONE
= 0,
768 IBMVFC_HOST_ACTION_RESET
,
769 IBMVFC_HOST_ACTION_REENABLE
,
770 IBMVFC_HOST_ACTION_LOGO
,
771 IBMVFC_HOST_ACTION_LOGO_WAIT
,
772 IBMVFC_HOST_ACTION_INIT
,
773 IBMVFC_HOST_ACTION_INIT_WAIT
,
774 IBMVFC_HOST_ACTION_QUERY
,
775 IBMVFC_HOST_ACTION_QUERY_TGTS
,
776 IBMVFC_HOST_ACTION_TGT_DEL
,
777 IBMVFC_HOST_ACTION_ALLOC_TGTS
,
778 IBMVFC_HOST_ACTION_TGT_INIT
,
779 IBMVFC_HOST_ACTION_TGT_DEL_FAILED
,
782 enum ibmvfc_host_state
{
794 struct list_head queue
;
795 struct Scsi_Host
*host
;
796 enum ibmvfc_host_state state
;
797 enum ibmvfc_host_action action
;
798 #define IBMVFC_NUM_TRACE_INDEX_BITS 8
799 #define IBMVFC_NUM_TRACE_ENTRIES (1 << IBMVFC_NUM_TRACE_INDEX_BITS)
800 #define IBMVFC_TRACE_SIZE (sizeof(struct ibmvfc_trace_entry) * IBMVFC_NUM_TRACE_ENTRIES)
801 struct ibmvfc_trace_entry
*trace
;
802 u32 trace_index
:IBMVFC_NUM_TRACE_INDEX_BITS
;
804 struct list_head targets
;
805 struct list_head sent
;
806 struct list_head free
;
808 struct ibmvfc_event_pool pool
;
809 struct dma_pool
*sg_pool
;
811 struct ibmvfc_crq_queue crq
;
812 struct ibmvfc_async_crq_queue async_crq
;
813 struct ibmvfc_npiv_login login_info
;
814 union ibmvfc_npiv_login_data
*login_buf
;
815 dma_addr_t login_buf_dma
;
818 struct ibmvfc_discover_targets_entry
*disc_buf
;
819 struct mutex passthru_mutex
;
822 int discovery_threads
;
829 int aborting_passthru
;
831 #define IBMVFC_AE_LINKUP 0x0001
832 #define IBMVFC_AE_LINKDOWN 0x0002
833 #define IBMVFC_AE_RSCN 0x0004
834 dma_addr_t disc_buf_dma
;
835 unsigned int partition_number
;
836 char partition_name
[97];
837 void (*job_step
) (struct ibmvfc_host
*);
838 struct task_struct
*work_thread
;
839 struct tasklet_struct tasklet
;
840 struct work_struct rport_add_work_q
;
841 wait_queue_head_t init_wait_q
;
842 wait_queue_head_t work_wait_q
;
845 #define DBG_CMD(CMD) do { if (ibmvfc_debug) CMD; } while (0)
847 #define tgt_dbg(t, fmt, ...) \
848 DBG_CMD(dev_info((t)->vhost->dev, "%llX: " fmt, (t)->scsi_id, ##__VA_ARGS__))
850 #define tgt_info(t, fmt, ...) \
851 dev_info((t)->vhost->dev, "%llX: " fmt, (t)->scsi_id, ##__VA_ARGS__)
853 #define tgt_err(t, fmt, ...) \
854 dev_err((t)->vhost->dev, "%llX: " fmt, (t)->scsi_id, ##__VA_ARGS__)
856 #define tgt_log(t, level, fmt, ...) \
858 if ((t)->vhost->log_level >= level) \
859 tgt_err(t, fmt, ##__VA_ARGS__); \
862 #define ibmvfc_dbg(vhost, ...) \
863 DBG_CMD(dev_info((vhost)->dev, ##__VA_ARGS__))
865 #define ibmvfc_log(vhost, level, ...) \
867 if ((vhost)->log_level >= level) \
868 dev_err((vhost)->dev, ##__VA_ARGS__); \
871 #define ENTER DBG_CMD(printk(KERN_INFO IBMVFC_NAME": Entering %s\n", __func__))
872 #define LEAVE DBG_CMD(printk(KERN_INFO IBMVFC_NAME": Leaving %s\n", __func__))
874 #ifdef CONFIG_SCSI_IBMVFC_TRACE
875 #define ibmvfc_create_trace_file(kobj, attr) sysfs_create_bin_file(kobj, attr)
876 #define ibmvfc_remove_trace_file(kobj, attr) sysfs_remove_bin_file(kobj, attr)
878 #define ibmvfc_create_trace_file(kobj, attr) 0
879 #define ibmvfc_remove_trace_file(kobj, attr) do { } while (0)