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