Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * |
| 3 | * linux/drivers/s390/scsi/zfcp_fsf.c |
| 4 | * |
| 5 | * FCP adapter driver for IBM eServer zSeries |
| 6 | * |
| 7 | * (C) Copyright IBM Corp. 2002, 2004 |
| 8 | * |
| 9 | * Author(s): Martin Peschke <mpeschke@de.ibm.com> |
| 10 | * Raimund Schroeder <raimund.schroeder@de.ibm.com> |
| 11 | * Aron Zeh |
| 12 | * Wolfgang Taphorn |
| 13 | * Stefan Bader <stefan.bader@de.ibm.com> |
| 14 | * Heiko Carstens <heiko.carstens@de.ibm.com> |
| 15 | * Andreas Herrmann <aherrman@de.ibm.com> |
| 16 | * Volker Sameske <sameske@de.ibm.com> |
| 17 | * |
| 18 | * This program is free software; you can redistribute it and/or modify |
| 19 | * it under the terms of the GNU General Public License as published by |
| 20 | * the Free Software Foundation; either version 2, or (at your option) |
| 21 | * any later version. |
| 22 | * |
| 23 | * This program is distributed in the hope that it will be useful, |
| 24 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 26 | * GNU General Public License for more details. |
| 27 | * |
| 28 | * You should have received a copy of the GNU General Public License |
| 29 | * along with this program; if not, write to the Free Software |
| 30 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 31 | */ |
| 32 | |
| 33 | #define ZFCP_FSF_C_REVISION "$Revision: 1.92 $" |
| 34 | |
| 35 | #include "zfcp_ext.h" |
| 36 | |
| 37 | static int zfcp_fsf_exchange_config_data_handler(struct zfcp_fsf_req *); |
| 38 | static void zfcp_fsf_exchange_port_data_handler(struct zfcp_fsf_req *); |
| 39 | static int zfcp_fsf_open_port_handler(struct zfcp_fsf_req *); |
| 40 | static int zfcp_fsf_close_port_handler(struct zfcp_fsf_req *); |
| 41 | static int zfcp_fsf_close_physical_port_handler(struct zfcp_fsf_req *); |
| 42 | static int zfcp_fsf_open_unit_handler(struct zfcp_fsf_req *); |
| 43 | static int zfcp_fsf_close_unit_handler(struct zfcp_fsf_req *); |
| 44 | static int zfcp_fsf_send_fcp_command_handler(struct zfcp_fsf_req *); |
| 45 | static int zfcp_fsf_send_fcp_command_task_handler(struct zfcp_fsf_req *); |
| 46 | static int zfcp_fsf_send_fcp_command_task_management_handler( |
| 47 | struct zfcp_fsf_req *); |
| 48 | static int zfcp_fsf_abort_fcp_command_handler(struct zfcp_fsf_req *); |
| 49 | static int zfcp_fsf_status_read_handler(struct zfcp_fsf_req *); |
| 50 | static int zfcp_fsf_send_ct_handler(struct zfcp_fsf_req *); |
| 51 | static int zfcp_fsf_send_els_handler(struct zfcp_fsf_req *); |
| 52 | static int zfcp_fsf_control_file_handler(struct zfcp_fsf_req *); |
| 53 | static inline int zfcp_fsf_req_sbal_check( |
| 54 | unsigned long *, struct zfcp_qdio_queue *, int); |
| 55 | static inline int zfcp_use_one_sbal( |
| 56 | struct scatterlist *, int, struct scatterlist *, int); |
| 57 | static struct zfcp_fsf_req *zfcp_fsf_req_alloc(mempool_t *, int); |
| 58 | static int zfcp_fsf_req_send(struct zfcp_fsf_req *, struct timer_list *); |
| 59 | static int zfcp_fsf_protstatus_eval(struct zfcp_fsf_req *); |
| 60 | static int zfcp_fsf_fsfstatus_eval(struct zfcp_fsf_req *); |
| 61 | static int zfcp_fsf_fsfstatus_qual_eval(struct zfcp_fsf_req *); |
| 62 | static int zfcp_fsf_req_dispatch(struct zfcp_fsf_req *); |
| 63 | static void zfcp_fsf_req_dismiss(struct zfcp_fsf_req *); |
| 64 | static void zfcp_fsf_req_free(struct zfcp_fsf_req *); |
| 65 | |
| 66 | /* association between FSF command and FSF QTCB type */ |
| 67 | static u32 fsf_qtcb_type[] = { |
| 68 | [FSF_QTCB_FCP_CMND] = FSF_IO_COMMAND, |
| 69 | [FSF_QTCB_ABORT_FCP_CMND] = FSF_SUPPORT_COMMAND, |
| 70 | [FSF_QTCB_OPEN_PORT_WITH_DID] = FSF_SUPPORT_COMMAND, |
| 71 | [FSF_QTCB_OPEN_LUN] = FSF_SUPPORT_COMMAND, |
| 72 | [FSF_QTCB_CLOSE_LUN] = FSF_SUPPORT_COMMAND, |
| 73 | [FSF_QTCB_CLOSE_PORT] = FSF_SUPPORT_COMMAND, |
| 74 | [FSF_QTCB_CLOSE_PHYSICAL_PORT] = FSF_SUPPORT_COMMAND, |
| 75 | [FSF_QTCB_SEND_ELS] = FSF_SUPPORT_COMMAND, |
| 76 | [FSF_QTCB_SEND_GENERIC] = FSF_SUPPORT_COMMAND, |
| 77 | [FSF_QTCB_EXCHANGE_CONFIG_DATA] = FSF_CONFIG_COMMAND, |
| 78 | [FSF_QTCB_EXCHANGE_PORT_DATA] = FSF_PORT_COMMAND, |
| 79 | [FSF_QTCB_DOWNLOAD_CONTROL_FILE] = FSF_SUPPORT_COMMAND, |
| 80 | [FSF_QTCB_UPLOAD_CONTROL_FILE] = FSF_SUPPORT_COMMAND |
| 81 | }; |
| 82 | |
| 83 | static const char zfcp_act_subtable_type[5][8] = { |
| 84 | "unknown", "OS", "WWPN", "DID", "LUN" |
| 85 | }; |
| 86 | |
| 87 | /****************************************************************/ |
| 88 | /*************** FSF related Functions *************************/ |
| 89 | /****************************************************************/ |
| 90 | |
| 91 | #define ZFCP_LOG_AREA ZFCP_LOG_AREA_FSF |
| 92 | |
| 93 | /* |
| 94 | * function: zfcp_fsf_req_alloc |
| 95 | * |
| 96 | * purpose: Obtains an fsf_req and potentially a qtcb (for all but |
| 97 | * unsolicited requests) via helper functions |
| 98 | * Does some initial fsf request set-up. |
| 99 | * |
| 100 | * returns: pointer to allocated fsf_req if successfull |
| 101 | * NULL otherwise |
| 102 | * |
| 103 | * locks: none |
| 104 | * |
| 105 | */ |
| 106 | static struct zfcp_fsf_req * |
| 107 | zfcp_fsf_req_alloc(mempool_t *pool, int req_flags) |
| 108 | { |
| 109 | size_t size; |
| 110 | void *ptr; |
| 111 | struct zfcp_fsf_req *fsf_req = NULL; |
| 112 | |
| 113 | if (req_flags & ZFCP_REQ_NO_QTCB) |
| 114 | size = sizeof(struct zfcp_fsf_req); |
| 115 | else |
| 116 | size = sizeof(struct zfcp_fsf_req_pool_element); |
| 117 | |
| 118 | if (likely(pool != NULL)) |
| 119 | ptr = mempool_alloc(pool, GFP_ATOMIC); |
| 120 | else |
| 121 | ptr = kmalloc(size, GFP_ATOMIC); |
| 122 | |
| 123 | if (unlikely(NULL == ptr)) |
| 124 | goto out; |
| 125 | |
| 126 | memset(ptr, 0, size); |
| 127 | |
| 128 | if (req_flags & ZFCP_REQ_NO_QTCB) { |
| 129 | fsf_req = (struct zfcp_fsf_req *) ptr; |
| 130 | } else { |
| 131 | fsf_req = &((struct zfcp_fsf_req_pool_element *) ptr)->fsf_req; |
| 132 | fsf_req->qtcb = |
| 133 | &((struct zfcp_fsf_req_pool_element *) ptr)->qtcb; |
| 134 | } |
| 135 | |
| 136 | fsf_req->pool = pool; |
| 137 | |
| 138 | out: |
| 139 | return fsf_req; |
| 140 | } |
| 141 | |
| 142 | /* |
| 143 | * function: zfcp_fsf_req_free |
| 144 | * |
| 145 | * purpose: Frees the memory of an fsf_req (and potentially a qtcb) or |
| 146 | * returns it into the pool via helper functions. |
| 147 | * |
| 148 | * returns: sod all |
| 149 | * |
| 150 | * locks: none |
| 151 | */ |
| 152 | static void |
| 153 | zfcp_fsf_req_free(struct zfcp_fsf_req *fsf_req) |
| 154 | { |
| 155 | if (likely(fsf_req->pool != NULL)) |
| 156 | mempool_free(fsf_req, fsf_req->pool); |
| 157 | else |
| 158 | kfree(fsf_req); |
| 159 | } |
| 160 | |
| 161 | /* |
| 162 | * function: |
| 163 | * |
| 164 | * purpose: |
| 165 | * |
| 166 | * returns: |
| 167 | * |
| 168 | * note: qdio queues shall be down (no ongoing inbound processing) |
| 169 | */ |
| 170 | int |
| 171 | zfcp_fsf_req_dismiss_all(struct zfcp_adapter *adapter) |
| 172 | { |
| 173 | int retval = 0; |
| 174 | struct zfcp_fsf_req *fsf_req, *tmp; |
| 175 | |
| 176 | list_for_each_entry_safe(fsf_req, tmp, &adapter->fsf_req_list_head, |
| 177 | list) |
| 178 | zfcp_fsf_req_dismiss(fsf_req); |
| 179 | /* wait_event_timeout? */ |
| 180 | while (!list_empty(&adapter->fsf_req_list_head)) { |
| 181 | ZFCP_LOG_DEBUG("fsf req list of adapter %s not yet empty\n", |
| 182 | zfcp_get_busid_by_adapter(adapter)); |
| 183 | /* wait for woken intiators to clean up their requests */ |
| 184 | msleep(jiffies_to_msecs(ZFCP_FSFREQ_CLEANUP_TIMEOUT)); |
| 185 | } |
| 186 | |
| 187 | /* consistency check */ |
| 188 | if (atomic_read(&adapter->fsf_reqs_active)) { |
| 189 | ZFCP_LOG_NORMAL("bug: There are still %d FSF requests pending " |
| 190 | "on adapter %s after cleanup.\n", |
| 191 | atomic_read(&adapter->fsf_reqs_active), |
| 192 | zfcp_get_busid_by_adapter(adapter)); |
| 193 | atomic_set(&adapter->fsf_reqs_active, 0); |
| 194 | } |
| 195 | |
| 196 | return retval; |
| 197 | } |
| 198 | |
| 199 | /* |
| 200 | * function: |
| 201 | * |
| 202 | * purpose: |
| 203 | * |
| 204 | * returns: |
| 205 | */ |
| 206 | static void |
| 207 | zfcp_fsf_req_dismiss(struct zfcp_fsf_req *fsf_req) |
| 208 | { |
| 209 | fsf_req->status |= ZFCP_STATUS_FSFREQ_DISMISSED; |
| 210 | zfcp_fsf_req_complete(fsf_req); |
| 211 | } |
| 212 | |
| 213 | /* |
| 214 | * function: zfcp_fsf_req_complete |
| 215 | * |
| 216 | * purpose: Updates active counts and timers for openfcp-reqs |
| 217 | * May cleanup request after req_eval returns |
| 218 | * |
| 219 | * returns: 0 - success |
| 220 | * !0 - failure |
| 221 | * |
| 222 | * context: |
| 223 | */ |
| 224 | int |
| 225 | zfcp_fsf_req_complete(struct zfcp_fsf_req *fsf_req) |
| 226 | { |
| 227 | int retval = 0; |
| 228 | int cleanup; |
| 229 | struct zfcp_adapter *adapter = fsf_req->adapter; |
| 230 | |
| 231 | /* do some statistics */ |
| 232 | atomic_dec(&adapter->fsf_reqs_active); |
| 233 | |
| 234 | if (unlikely(fsf_req->fsf_command == FSF_QTCB_UNSOLICITED_STATUS)) { |
| 235 | ZFCP_LOG_DEBUG("Status read response received\n"); |
| 236 | /* |
| 237 | * Note: all cleanup handling is done in the callchain of |
| 238 | * the function call-chain below. |
| 239 | */ |
| 240 | zfcp_fsf_status_read_handler(fsf_req); |
| 241 | goto out; |
| 242 | } else |
| 243 | zfcp_fsf_protstatus_eval(fsf_req); |
| 244 | |
| 245 | /* |
| 246 | * fsf_req may be deleted due to waking up functions, so |
| 247 | * cleanup is saved here and used later |
| 248 | */ |
| 249 | if (likely(fsf_req->status & ZFCP_STATUS_FSFREQ_CLEANUP)) |
| 250 | cleanup = 1; |
| 251 | else |
| 252 | cleanup = 0; |
| 253 | |
| 254 | fsf_req->status |= ZFCP_STATUS_FSFREQ_COMPLETED; |
| 255 | |
| 256 | /* cleanup request if requested by initiator */ |
| 257 | if (likely(cleanup)) { |
| 258 | ZFCP_LOG_TRACE("removing FSF request %p\n", fsf_req); |
| 259 | /* |
| 260 | * lock must not be held here since it will be |
| 261 | * grabed by the called routine, too |
| 262 | */ |
| 263 | zfcp_fsf_req_cleanup(fsf_req); |
| 264 | } else { |
| 265 | /* notify initiator waiting for the requests completion */ |
| 266 | ZFCP_LOG_TRACE("waking initiator of FSF request %p\n",fsf_req); |
| 267 | /* |
| 268 | * FIXME: Race! We must not access fsf_req here as it might have been |
| 269 | * cleaned up already due to the set ZFCP_STATUS_FSFREQ_COMPLETED |
| 270 | * flag. It's an improbable case. But, we have the same paranoia for |
| 271 | * the cleanup flag already. |
| 272 | * Might better be handled using complete()? |
| 273 | * (setting the flag and doing wakeup ought to be atomic |
| 274 | * with regard to checking the flag as long as waitqueue is |
| 275 | * part of the to be released structure) |
| 276 | */ |
| 277 | wake_up(&fsf_req->completion_wq); |
| 278 | } |
| 279 | |
| 280 | out: |
| 281 | return retval; |
| 282 | } |
| 283 | |
| 284 | /* |
| 285 | * function: zfcp_fsf_protstatus_eval |
| 286 | * |
| 287 | * purpose: evaluates the QTCB of the finished FSF request |
| 288 | * and initiates appropriate actions |
| 289 | * (usually calling FSF command specific handlers) |
| 290 | * |
| 291 | * returns: |
| 292 | * |
| 293 | * context: |
| 294 | * |
| 295 | * locks: |
| 296 | */ |
| 297 | static int |
| 298 | zfcp_fsf_protstatus_eval(struct zfcp_fsf_req *fsf_req) |
| 299 | { |
| 300 | int retval = 0; |
| 301 | struct zfcp_adapter *adapter = fsf_req->adapter; |
| 302 | |
| 303 | ZFCP_LOG_DEBUG("QTCB is at %p\n", fsf_req->qtcb); |
| 304 | |
| 305 | if (fsf_req->status & ZFCP_STATUS_FSFREQ_DISMISSED) { |
| 306 | ZFCP_LOG_DEBUG("fsf_req 0x%lx has been dismissed\n", |
| 307 | (unsigned long) fsf_req); |
| 308 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR | |
| 309 | ZFCP_STATUS_FSFREQ_RETRY; /* only for SCSI cmnds. */ |
| 310 | zfcp_cmd_dbf_event_fsf("dismiss", fsf_req, NULL, 0); |
| 311 | goto skip_protstatus; |
| 312 | } |
| 313 | |
| 314 | /* log additional information provided by FSF (if any) */ |
| 315 | if (unlikely(fsf_req->qtcb->header.log_length)) { |
| 316 | /* do not trust them ;-) */ |
| 317 | if (fsf_req->qtcb->header.log_start > sizeof(struct fsf_qtcb)) { |
| 318 | ZFCP_LOG_NORMAL |
| 319 | ("bug: ULP (FSF logging) log data starts " |
| 320 | "beyond end of packet header. Ignored. " |
| 321 | "(start=%i, size=%li)\n", |
| 322 | fsf_req->qtcb->header.log_start, |
| 323 | sizeof(struct fsf_qtcb)); |
| 324 | goto forget_log; |
| 325 | } |
| 326 | if ((size_t) (fsf_req->qtcb->header.log_start + |
| 327 | fsf_req->qtcb->header.log_length) |
| 328 | > sizeof(struct fsf_qtcb)) { |
| 329 | ZFCP_LOG_NORMAL("bug: ULP (FSF logging) log data ends " |
| 330 | "beyond end of packet header. Ignored. " |
| 331 | "(start=%i, length=%i, size=%li)\n", |
| 332 | fsf_req->qtcb->header.log_start, |
| 333 | fsf_req->qtcb->header.log_length, |
| 334 | sizeof(struct fsf_qtcb)); |
| 335 | goto forget_log; |
| 336 | } |
| 337 | ZFCP_LOG_TRACE("ULP log data: \n"); |
| 338 | ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_TRACE, |
| 339 | (char *) fsf_req->qtcb + |
| 340 | fsf_req->qtcb->header.log_start, |
| 341 | fsf_req->qtcb->header.log_length); |
| 342 | } |
| 343 | forget_log: |
| 344 | |
| 345 | /* evaluate FSF Protocol Status */ |
| 346 | switch (fsf_req->qtcb->prefix.prot_status) { |
| 347 | |
| 348 | case FSF_PROT_GOOD: |
| 349 | ZFCP_LOG_TRACE("FSF_PROT_GOOD\n"); |
| 350 | break; |
| 351 | |
| 352 | case FSF_PROT_FSF_STATUS_PRESENTED: |
| 353 | ZFCP_LOG_TRACE("FSF_PROT_FSF_STATUS_PRESENTED\n"); |
| 354 | break; |
| 355 | |
| 356 | case FSF_PROT_QTCB_VERSION_ERROR: |
| 357 | ZFCP_LOG_FLAGS(0, "FSF_PROT_QTCB_VERSION_ERROR\n"); |
| 358 | ZFCP_LOG_NORMAL("error: The adapter %s contains " |
| 359 | "microcode of version 0x%x, the device driver " |
| 360 | "only supports 0x%x. Aborting.\n", |
| 361 | zfcp_get_busid_by_adapter(adapter), |
| 362 | fsf_req->qtcb->prefix.prot_status_qual. |
| 363 | version_error.fsf_version, ZFCP_QTCB_VERSION); |
| 364 | /* stop operation for this adapter */ |
| 365 | debug_text_exception(adapter->erp_dbf, 0, "prot_ver_err"); |
| 366 | zfcp_erp_adapter_shutdown(adapter, 0); |
| 367 | zfcp_cmd_dbf_event_fsf("qverserr", fsf_req, |
| 368 | &fsf_req->qtcb->prefix.prot_status_qual, |
| 369 | sizeof (union fsf_prot_status_qual)); |
| 370 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 371 | break; |
| 372 | |
| 373 | case FSF_PROT_SEQ_NUMB_ERROR: |
| 374 | ZFCP_LOG_FLAGS(0, "FSF_PROT_SEQ_NUMB_ERROR\n"); |
| 375 | ZFCP_LOG_NORMAL("bug: Sequence number mismatch between " |
| 376 | "driver (0x%x) and adapter %s (0x%x). " |
| 377 | "Restarting all operations on this adapter.\n", |
| 378 | fsf_req->qtcb->prefix.req_seq_no, |
| 379 | zfcp_get_busid_by_adapter(adapter), |
| 380 | fsf_req->qtcb->prefix.prot_status_qual. |
| 381 | sequence_error.exp_req_seq_no); |
| 382 | debug_text_exception(adapter->erp_dbf, 0, "prot_seq_err"); |
| 383 | /* restart operation on this adapter */ |
| 384 | zfcp_erp_adapter_reopen(adapter, 0); |
| 385 | zfcp_cmd_dbf_event_fsf("seqnoerr", fsf_req, |
| 386 | &fsf_req->qtcb->prefix.prot_status_qual, |
| 387 | sizeof (union fsf_prot_status_qual)); |
| 388 | fsf_req->status |= ZFCP_STATUS_FSFREQ_RETRY; |
| 389 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 390 | break; |
| 391 | |
| 392 | case FSF_PROT_UNSUPP_QTCB_TYPE: |
| 393 | ZFCP_LOG_FLAGS(0, "FSF_PROT_UNSUP_QTCB_TYPE\n"); |
| 394 | ZFCP_LOG_NORMAL("error: Packet header type used by the " |
| 395 | "device driver is incompatible with " |
| 396 | "that used on adapter %s. " |
| 397 | "Stopping all operations on this adapter.\n", |
| 398 | zfcp_get_busid_by_adapter(adapter)); |
| 399 | debug_text_exception(adapter->erp_dbf, 0, "prot_unsup_qtcb"); |
| 400 | zfcp_erp_adapter_shutdown(adapter, 0); |
| 401 | zfcp_cmd_dbf_event_fsf("unsqtcbt", fsf_req, |
| 402 | &fsf_req->qtcb->prefix.prot_status_qual, |
| 403 | sizeof (union fsf_prot_status_qual)); |
| 404 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 405 | break; |
| 406 | |
| 407 | case FSF_PROT_HOST_CONNECTION_INITIALIZING: |
| 408 | ZFCP_LOG_FLAGS(1, "FSF_PROT_HOST_CONNECTION_INITIALIZING\n"); |
| 409 | zfcp_cmd_dbf_event_fsf("hconinit", fsf_req, |
| 410 | &fsf_req->qtcb->prefix.prot_status_qual, |
| 411 | sizeof (union fsf_prot_status_qual)); |
| 412 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 413 | atomic_set_mask(ZFCP_STATUS_ADAPTER_HOST_CON_INIT, |
| 414 | &(adapter->status)); |
| 415 | debug_text_event(adapter->erp_dbf, 3, "prot_con_init"); |
| 416 | break; |
| 417 | |
| 418 | case FSF_PROT_DUPLICATE_REQUEST_ID: |
| 419 | ZFCP_LOG_FLAGS(0, "FSF_PROT_DUPLICATE_REQUEST_IDS\n"); |
| 420 | if (fsf_req->qtcb) { |
| 421 | ZFCP_LOG_NORMAL("bug: The request identifier 0x%Lx " |
| 422 | "to the adapter %s is ambiguous. " |
| 423 | "Stopping all operations on this " |
| 424 | "adapter.\n", |
| 425 | *(unsigned long long *) |
| 426 | (&fsf_req->qtcb->bottom.support. |
| 427 | req_handle), |
| 428 | zfcp_get_busid_by_adapter(adapter)); |
| 429 | } else { |
| 430 | ZFCP_LOG_NORMAL("bug: The request identifier %p " |
| 431 | "to the adapter %s is ambiguous. " |
| 432 | "Stopping all operations on this " |
| 433 | "adapter. " |
| 434 | "(bug: got this for an unsolicited " |
| 435 | "status read request)\n", |
| 436 | fsf_req, |
| 437 | zfcp_get_busid_by_adapter(adapter)); |
| 438 | } |
| 439 | debug_text_exception(adapter->erp_dbf, 0, "prot_dup_id"); |
| 440 | zfcp_erp_adapter_shutdown(adapter, 0); |
| 441 | zfcp_cmd_dbf_event_fsf("dupreqid", fsf_req, |
| 442 | &fsf_req->qtcb->prefix.prot_status_qual, |
| 443 | sizeof (union fsf_prot_status_qual)); |
| 444 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 445 | break; |
| 446 | |
| 447 | case FSF_PROT_LINK_DOWN: |
| 448 | ZFCP_LOG_FLAGS(1, "FSF_PROT_LINK_DOWN\n"); |
| 449 | /* |
| 450 | * 'test and set' is not atomic here - |
| 451 | * it's ok as long as calls to our response queue handler |
| 452 | * (and thus execution of this code here) are serialized |
| 453 | * by the qdio module |
| 454 | */ |
| 455 | if (!atomic_test_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED, |
| 456 | &adapter->status)) { |
| 457 | switch (fsf_req->qtcb->prefix.prot_status_qual. |
| 458 | locallink_error.code) { |
| 459 | case FSF_PSQ_LINK_NOLIGHT: |
| 460 | ZFCP_LOG_INFO("The local link to adapter %s " |
| 461 | "is down (no light detected).\n", |
| 462 | zfcp_get_busid_by_adapter( |
| 463 | adapter)); |
| 464 | break; |
| 465 | case FSF_PSQ_LINK_WRAPPLUG: |
| 466 | ZFCP_LOG_INFO("The local link to adapter %s " |
| 467 | "is down (wrap plug detected).\n", |
| 468 | zfcp_get_busid_by_adapter( |
| 469 | adapter)); |
| 470 | break; |
| 471 | case FSF_PSQ_LINK_NOFCP: |
| 472 | ZFCP_LOG_INFO("The local link to adapter %s " |
| 473 | "is down (adjacent node on " |
| 474 | "link does not support FCP).\n", |
| 475 | zfcp_get_busid_by_adapter( |
| 476 | adapter)); |
| 477 | break; |
| 478 | default: |
| 479 | ZFCP_LOG_INFO("The local link to adapter %s " |
| 480 | "is down " |
| 481 | "(warning: unknown reason " |
| 482 | "code).\n", |
| 483 | zfcp_get_busid_by_adapter( |
| 484 | adapter)); |
| 485 | break; |
| 486 | |
| 487 | } |
| 488 | /* |
| 489 | * Due to the 'erp failed' flag the adapter won't |
| 490 | * be recovered but will be just set to 'blocked' |
| 491 | * state. All subordinary devices will have state |
| 492 | * 'blocked' and 'erp failed', too. |
| 493 | * Thus the adapter is still able to provide |
| 494 | * 'link up' status without being flooded with |
| 495 | * requests. |
| 496 | * (note: even 'close port' is not permitted) |
| 497 | */ |
| 498 | ZFCP_LOG_INFO("Stopping all operations for adapter " |
| 499 | "%s.\n", |
| 500 | zfcp_get_busid_by_adapter(adapter)); |
| 501 | atomic_set_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED | |
| 502 | ZFCP_STATUS_COMMON_ERP_FAILED, |
| 503 | &adapter->status); |
| 504 | zfcp_erp_adapter_reopen(adapter, 0); |
| 505 | debug_text_event(adapter->erp_dbf, 1, "prot_link_down"); |
| 506 | } |
| 507 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 508 | break; |
| 509 | |
| 510 | case FSF_PROT_REEST_QUEUE: |
| 511 | ZFCP_LOG_FLAGS(1, "FSF_PROT_REEST_QUEUE\n"); |
| 512 | debug_text_event(adapter->erp_dbf, 1, "prot_reest_queue"); |
| 513 | ZFCP_LOG_INFO("The local link to adapter with " |
| 514 | "%s was re-plugged. " |
| 515 | "Re-starting operations on this adapter.\n", |
| 516 | zfcp_get_busid_by_adapter(adapter)); |
| 517 | /* All ports should be marked as ready to run again */ |
| 518 | zfcp_erp_modify_adapter_status(adapter, |
| 519 | ZFCP_STATUS_COMMON_RUNNING, |
| 520 | ZFCP_SET); |
| 521 | zfcp_erp_adapter_reopen(adapter, |
| 522 | ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED |
| 523 | | ZFCP_STATUS_COMMON_ERP_FAILED); |
| 524 | zfcp_cmd_dbf_event_fsf("reestque", fsf_req, |
| 525 | &fsf_req->qtcb->prefix.prot_status_qual, |
| 526 | sizeof (union fsf_prot_status_qual)); |
| 527 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 528 | break; |
| 529 | |
| 530 | case FSF_PROT_ERROR_STATE: |
| 531 | ZFCP_LOG_FLAGS(0, "FSF_PROT_ERROR_STATE\n"); |
| 532 | ZFCP_LOG_NORMAL("error: The adapter %s " |
| 533 | "has entered the error state. " |
| 534 | "Restarting all operations on this " |
| 535 | "adapter.\n", |
| 536 | zfcp_get_busid_by_adapter(adapter)); |
| 537 | debug_text_event(adapter->erp_dbf, 0, "prot_err_sta"); |
| 538 | /* restart operation on this adapter */ |
| 539 | zfcp_erp_adapter_reopen(adapter, 0); |
| 540 | zfcp_cmd_dbf_event_fsf("proterrs", fsf_req, |
| 541 | &fsf_req->qtcb->prefix.prot_status_qual, |
| 542 | sizeof (union fsf_prot_status_qual)); |
| 543 | fsf_req->status |= ZFCP_STATUS_FSFREQ_RETRY; |
| 544 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 545 | break; |
| 546 | |
| 547 | default: |
| 548 | ZFCP_LOG_NORMAL("bug: Transfer protocol status information " |
| 549 | "provided by the adapter %s " |
| 550 | "is not compatible with the device driver. " |
| 551 | "Stopping all operations on this adapter. " |
| 552 | "(debug info 0x%x).\n", |
| 553 | zfcp_get_busid_by_adapter(adapter), |
| 554 | fsf_req->qtcb->prefix.prot_status); |
| 555 | debug_text_event(adapter->erp_dbf, 0, "prot_inval:"); |
| 556 | debug_exception(adapter->erp_dbf, 0, |
| 557 | &fsf_req->qtcb->prefix.prot_status, |
| 558 | sizeof (u32)); |
| 559 | zfcp_erp_adapter_shutdown(adapter, 0); |
| 560 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 561 | } |
| 562 | |
| 563 | skip_protstatus: |
| 564 | /* |
| 565 | * always call specific handlers to give them a chance to do |
| 566 | * something meaningful even in error cases |
| 567 | */ |
| 568 | zfcp_fsf_fsfstatus_eval(fsf_req); |
| 569 | return retval; |
| 570 | } |
| 571 | |
| 572 | /* |
| 573 | * function: zfcp_fsf_fsfstatus_eval |
| 574 | * |
| 575 | * purpose: evaluates FSF status of completed FSF request |
| 576 | * and acts accordingly |
| 577 | * |
| 578 | * returns: |
| 579 | */ |
| 580 | static int |
| 581 | zfcp_fsf_fsfstatus_eval(struct zfcp_fsf_req *fsf_req) |
| 582 | { |
| 583 | int retval = 0; |
| 584 | |
| 585 | if (unlikely(fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR)) { |
| 586 | goto skip_fsfstatus; |
| 587 | } |
| 588 | |
| 589 | /* evaluate FSF Status */ |
| 590 | switch (fsf_req->qtcb->header.fsf_status) { |
| 591 | case FSF_UNKNOWN_COMMAND: |
| 592 | ZFCP_LOG_FLAGS(0, "FSF_UNKNOWN_COMMAND\n"); |
| 593 | ZFCP_LOG_NORMAL("bug: Command issued by the device driver is " |
| 594 | "not known by the adapter %s " |
| 595 | "Stopping all operations on this adapter. " |
| 596 | "(debug info 0x%x).\n", |
| 597 | zfcp_get_busid_by_adapter(fsf_req->adapter), |
| 598 | fsf_req->qtcb->header.fsf_command); |
| 599 | debug_text_exception(fsf_req->adapter->erp_dbf, 0, |
| 600 | "fsf_s_unknown"); |
| 601 | zfcp_erp_adapter_shutdown(fsf_req->adapter, 0); |
| 602 | zfcp_cmd_dbf_event_fsf("unknownc", fsf_req, |
| 603 | &fsf_req->qtcb->header.fsf_status_qual, |
| 604 | sizeof (union fsf_status_qual)); |
| 605 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 606 | break; |
| 607 | |
| 608 | case FSF_FCP_RSP_AVAILABLE: |
| 609 | ZFCP_LOG_FLAGS(2, "FSF_FCP_RSP_AVAILABLE\n"); |
| 610 | ZFCP_LOG_DEBUG("FCP Sense data will be presented to the " |
| 611 | "SCSI stack.\n"); |
| 612 | debug_text_event(fsf_req->adapter->erp_dbf, 3, "fsf_s_rsp"); |
| 613 | break; |
| 614 | |
| 615 | case FSF_ADAPTER_STATUS_AVAILABLE: |
| 616 | ZFCP_LOG_FLAGS(2, "FSF_ADAPTER_STATUS_AVAILABLE\n"); |
| 617 | debug_text_event(fsf_req->adapter->erp_dbf, 2, "fsf_s_astatus"); |
| 618 | zfcp_fsf_fsfstatus_qual_eval(fsf_req); |
| 619 | break; |
| 620 | |
| 621 | default: |
| 622 | break; |
| 623 | } |
| 624 | |
| 625 | skip_fsfstatus: |
| 626 | /* |
| 627 | * always call specific handlers to give them a chance to do |
| 628 | * something meaningful even in error cases |
| 629 | */ |
| 630 | zfcp_fsf_req_dispatch(fsf_req); |
| 631 | |
| 632 | return retval; |
| 633 | } |
| 634 | |
| 635 | /* |
| 636 | * function: zfcp_fsf_fsfstatus_qual_eval |
| 637 | * |
| 638 | * purpose: evaluates FSF status-qualifier of completed FSF request |
| 639 | * and acts accordingly |
| 640 | * |
| 641 | * returns: |
| 642 | */ |
| 643 | static int |
| 644 | zfcp_fsf_fsfstatus_qual_eval(struct zfcp_fsf_req *fsf_req) |
| 645 | { |
| 646 | int retval = 0; |
| 647 | |
| 648 | switch (fsf_req->qtcb->header.fsf_status_qual.word[0]) { |
| 649 | case FSF_SQ_FCP_RSP_AVAILABLE: |
| 650 | ZFCP_LOG_FLAGS(2, "FSF_SQ_FCP_RSP_AVAILABLE\n"); |
| 651 | debug_text_event(fsf_req->adapter->erp_dbf, 4, "fsf_sq_rsp"); |
| 652 | break; |
| 653 | case FSF_SQ_RETRY_IF_POSSIBLE: |
| 654 | ZFCP_LOG_FLAGS(2, "FSF_SQ_RETRY_IF_POSSIBLE\n"); |
| 655 | /* The SCSI-stack may now issue retries or escalate */ |
| 656 | debug_text_event(fsf_req->adapter->erp_dbf, 2, "fsf_sq_retry"); |
| 657 | zfcp_cmd_dbf_event_fsf("sqretry", fsf_req, |
| 658 | &fsf_req->qtcb->header.fsf_status_qual, |
| 659 | sizeof (union fsf_status_qual)); |
| 660 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 661 | break; |
| 662 | case FSF_SQ_COMMAND_ABORTED: |
| 663 | ZFCP_LOG_FLAGS(2, "FSF_SQ_COMMAND_ABORTED\n"); |
| 664 | /* Carry the aborted state on to upper layer */ |
| 665 | debug_text_event(fsf_req->adapter->erp_dbf, 2, "fsf_sq_abort"); |
| 666 | zfcp_cmd_dbf_event_fsf("sqabort", fsf_req, |
| 667 | &fsf_req->qtcb->header.fsf_status_qual, |
| 668 | sizeof (union fsf_status_qual)); |
| 669 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ABORTED; |
| 670 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 671 | break; |
| 672 | case FSF_SQ_NO_RECOM: |
| 673 | ZFCP_LOG_FLAGS(0, "FSF_SQ_NO_RECOM\n"); |
| 674 | debug_text_exception(fsf_req->adapter->erp_dbf, 0, |
| 675 | "fsf_sq_no_rec"); |
| 676 | ZFCP_LOG_NORMAL("bug: No recommendation could be given for a" |
| 677 | "problem on the adapter %s " |
| 678 | "Stopping all operations on this adapter. ", |
| 679 | zfcp_get_busid_by_adapter(fsf_req->adapter)); |
| 680 | zfcp_erp_adapter_shutdown(fsf_req->adapter, 0); |
| 681 | zfcp_cmd_dbf_event_fsf("sqnrecom", fsf_req, |
| 682 | &fsf_req->qtcb->header.fsf_status_qual, |
| 683 | sizeof (union fsf_status_qual)); |
| 684 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 685 | break; |
| 686 | case FSF_SQ_ULP_PROGRAMMING_ERROR: |
| 687 | ZFCP_LOG_FLAGS(0, "FSF_SQ_ULP_PROGRAMMING_ERROR\n"); |
| 688 | ZFCP_LOG_NORMAL("error: not enough SBALs for data transfer " |
| 689 | "(adapter %s)\n", |
| 690 | zfcp_get_busid_by_adapter(fsf_req->adapter)); |
| 691 | debug_text_exception(fsf_req->adapter->erp_dbf, 0, |
| 692 | "fsf_sq_ulp_err"); |
| 693 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 694 | break; |
| 695 | case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE: |
| 696 | case FSF_SQ_NO_RETRY_POSSIBLE: |
| 697 | case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED: |
| 698 | /* dealt with in the respective functions */ |
| 699 | break; |
| 700 | default: |
| 701 | ZFCP_LOG_NORMAL("bug: Additional status info could " |
| 702 | "not be interpreted properly.\n"); |
| 703 | ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_NORMAL, |
| 704 | (char *) &fsf_req->qtcb->header.fsf_status_qual, |
| 705 | sizeof (union fsf_status_qual)); |
| 706 | debug_text_event(fsf_req->adapter->erp_dbf, 0, "fsf_sq_inval:"); |
| 707 | debug_exception(fsf_req->adapter->erp_dbf, 0, |
| 708 | &fsf_req->qtcb->header.fsf_status_qual.word[0], |
| 709 | sizeof (u32)); |
| 710 | zfcp_cmd_dbf_event_fsf("squndef", fsf_req, |
| 711 | &fsf_req->qtcb->header.fsf_status_qual, |
| 712 | sizeof (union fsf_status_qual)); |
| 713 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 714 | break; |
| 715 | } |
| 716 | |
| 717 | return retval; |
| 718 | } |
| 719 | |
| 720 | /* |
| 721 | * function: zfcp_fsf_req_dispatch |
| 722 | * |
| 723 | * purpose: calls the appropriate command specific handler |
| 724 | * |
| 725 | * returns: |
| 726 | */ |
| 727 | static int |
| 728 | zfcp_fsf_req_dispatch(struct zfcp_fsf_req *fsf_req) |
| 729 | { |
| 730 | struct zfcp_erp_action *erp_action = fsf_req->erp_action; |
| 731 | struct zfcp_adapter *adapter = fsf_req->adapter; |
| 732 | int retval = 0; |
| 733 | |
| 734 | if (unlikely(fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR)) { |
| 735 | ZFCP_LOG_TRACE("fsf_req=%p, QTCB=%p\n", fsf_req, fsf_req->qtcb); |
| 736 | ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_TRACE, |
| 737 | (char *) fsf_req->qtcb, sizeof(struct fsf_qtcb)); |
| 738 | } |
| 739 | |
| 740 | switch (fsf_req->fsf_command) { |
| 741 | |
| 742 | case FSF_QTCB_FCP_CMND: |
| 743 | ZFCP_LOG_FLAGS(3, "FSF_QTCB_FCP_CMND\n"); |
| 744 | zfcp_fsf_send_fcp_command_handler(fsf_req); |
| 745 | break; |
| 746 | |
| 747 | case FSF_QTCB_ABORT_FCP_CMND: |
| 748 | ZFCP_LOG_FLAGS(2, "FSF_QTCB_ABORT_FCP_CMND\n"); |
| 749 | zfcp_fsf_abort_fcp_command_handler(fsf_req); |
| 750 | break; |
| 751 | |
| 752 | case FSF_QTCB_SEND_GENERIC: |
| 753 | ZFCP_LOG_FLAGS(2, "FSF_QTCB_SEND_GENERIC\n"); |
| 754 | zfcp_fsf_send_ct_handler(fsf_req); |
| 755 | break; |
| 756 | |
| 757 | case FSF_QTCB_OPEN_PORT_WITH_DID: |
| 758 | ZFCP_LOG_FLAGS(2, "FSF_QTCB_OPEN_PORT_WITH_DID\n"); |
| 759 | zfcp_fsf_open_port_handler(fsf_req); |
| 760 | break; |
| 761 | |
| 762 | case FSF_QTCB_OPEN_LUN: |
| 763 | ZFCP_LOG_FLAGS(2, "FSF_QTCB_OPEN_LUN\n"); |
| 764 | zfcp_fsf_open_unit_handler(fsf_req); |
| 765 | break; |
| 766 | |
| 767 | case FSF_QTCB_CLOSE_LUN: |
| 768 | ZFCP_LOG_FLAGS(2, "FSF_QTCB_CLOSE_LUN\n"); |
| 769 | zfcp_fsf_close_unit_handler(fsf_req); |
| 770 | break; |
| 771 | |
| 772 | case FSF_QTCB_CLOSE_PORT: |
| 773 | ZFCP_LOG_FLAGS(2, "FSF_QTCB_CLOSE_PORT\n"); |
| 774 | zfcp_fsf_close_port_handler(fsf_req); |
| 775 | break; |
| 776 | |
| 777 | case FSF_QTCB_CLOSE_PHYSICAL_PORT: |
| 778 | ZFCP_LOG_FLAGS(2, "FSF_QTCB_CLOSE_PHYSICAL_PORT\n"); |
| 779 | zfcp_fsf_close_physical_port_handler(fsf_req); |
| 780 | break; |
| 781 | |
| 782 | case FSF_QTCB_EXCHANGE_CONFIG_DATA: |
| 783 | ZFCP_LOG_FLAGS(2, "FSF_QTCB_EXCHANGE_CONFIG_DATA\n"); |
| 784 | zfcp_fsf_exchange_config_data_handler(fsf_req); |
| 785 | break; |
| 786 | |
| 787 | case FSF_QTCB_EXCHANGE_PORT_DATA: |
| 788 | ZFCP_LOG_FLAGS(2, "FSF_QTCB_EXCHANGE_PORT_DATA\n"); |
| 789 | zfcp_fsf_exchange_port_data_handler(fsf_req); |
| 790 | break; |
| 791 | |
| 792 | case FSF_QTCB_SEND_ELS: |
| 793 | ZFCP_LOG_FLAGS(2, "FSF_QTCB_SEND_ELS\n"); |
| 794 | zfcp_fsf_send_els_handler(fsf_req); |
| 795 | break; |
| 796 | |
| 797 | case FSF_QTCB_DOWNLOAD_CONTROL_FILE: |
| 798 | ZFCP_LOG_FLAGS(2, "FSF_QTCB_DOWNLOAD_CONTROL_FILE\n"); |
| 799 | zfcp_fsf_control_file_handler(fsf_req); |
| 800 | break; |
| 801 | |
| 802 | case FSF_QTCB_UPLOAD_CONTROL_FILE: |
| 803 | ZFCP_LOG_FLAGS(2, "FSF_QTCB_UPLOAD_CONTROL_FILE\n"); |
| 804 | zfcp_fsf_control_file_handler(fsf_req); |
| 805 | break; |
| 806 | |
| 807 | default: |
| 808 | ZFCP_LOG_FLAGS(2, "FSF_QTCB_UNKNOWN\n"); |
| 809 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 810 | ZFCP_LOG_NORMAL("bug: Command issued by the device driver is " |
| 811 | "not supported by the adapter %s\n", |
| 812 | zfcp_get_busid_by_adapter(fsf_req->adapter)); |
| 813 | if (fsf_req->fsf_command != fsf_req->qtcb->header.fsf_command) |
| 814 | ZFCP_LOG_NORMAL |
| 815 | ("bug: Command issued by the device driver differs " |
| 816 | "from the command returned by the adapter %s " |
| 817 | "(debug info 0x%x, 0x%x).\n", |
| 818 | zfcp_get_busid_by_adapter(fsf_req->adapter), |
| 819 | fsf_req->fsf_command, |
| 820 | fsf_req->qtcb->header.fsf_command); |
| 821 | } |
| 822 | |
| 823 | if (!erp_action) |
| 824 | return retval; |
| 825 | |
| 826 | debug_text_event(adapter->erp_dbf, 3, "a_frh"); |
| 827 | debug_event(adapter->erp_dbf, 3, &erp_action->action, sizeof (int)); |
| 828 | zfcp_erp_async_handler(erp_action, 0); |
| 829 | |
| 830 | return retval; |
| 831 | } |
| 832 | |
| 833 | /* |
| 834 | * function: zfcp_fsf_status_read |
| 835 | * |
| 836 | * purpose: initiates a Status Read command at the specified adapter |
| 837 | * |
| 838 | * returns: |
| 839 | */ |
| 840 | int |
| 841 | zfcp_fsf_status_read(struct zfcp_adapter *adapter, int req_flags) |
| 842 | { |
| 843 | struct zfcp_fsf_req *fsf_req; |
| 844 | struct fsf_status_read_buffer *status_buffer; |
| 845 | unsigned long lock_flags; |
| 846 | volatile struct qdio_buffer_element *sbale; |
| 847 | int retval = 0; |
| 848 | |
| 849 | /* setup new FSF request */ |
| 850 | retval = zfcp_fsf_req_create(adapter, FSF_QTCB_UNSOLICITED_STATUS, |
| 851 | req_flags | ZFCP_REQ_NO_QTCB, |
| 852 | adapter->pool.fsf_req_status_read, |
| 853 | &lock_flags, &fsf_req); |
| 854 | if (retval < 0) { |
| 855 | ZFCP_LOG_INFO("error: Could not create unsolicited status " |
| 856 | "buffer for adapter %s.\n", |
| 857 | zfcp_get_busid_by_adapter(adapter)); |
| 858 | goto failed_req_create; |
| 859 | } |
| 860 | |
| 861 | sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0); |
| 862 | sbale[0].flags |= SBAL_FLAGS0_TYPE_STATUS; |
| 863 | sbale[2].flags |= SBAL_FLAGS_LAST_ENTRY; |
| 864 | fsf_req->sbale_curr = 2; |
| 865 | |
| 866 | status_buffer = |
| 867 | mempool_alloc(adapter->pool.data_status_read, GFP_ATOMIC); |
| 868 | if (!status_buffer) { |
| 869 | ZFCP_LOG_NORMAL("bug: could not get some buffer\n"); |
| 870 | goto failed_buf; |
| 871 | } |
| 872 | memset(status_buffer, 0, sizeof (struct fsf_status_read_buffer)); |
| 873 | fsf_req->data.status_read.buffer = status_buffer; |
| 874 | |
| 875 | /* insert pointer to respective buffer */ |
| 876 | sbale = zfcp_qdio_sbale_curr(fsf_req); |
| 877 | sbale->addr = (void *) status_buffer; |
| 878 | sbale->length = sizeof(struct fsf_status_read_buffer); |
| 879 | |
| 880 | /* start QDIO request for this FSF request */ |
| 881 | retval = zfcp_fsf_req_send(fsf_req, NULL); |
| 882 | if (retval) { |
| 883 | ZFCP_LOG_DEBUG("error: Could not set-up unsolicited status " |
| 884 | "environment.\n"); |
| 885 | goto failed_req_send; |
| 886 | } |
| 887 | |
| 888 | ZFCP_LOG_TRACE("Status Read request initiated (adapter%s)\n", |
| 889 | zfcp_get_busid_by_adapter(adapter)); |
| 890 | goto out; |
| 891 | |
| 892 | failed_req_send: |
| 893 | mempool_free(status_buffer, adapter->pool.data_status_read); |
| 894 | |
| 895 | failed_buf: |
| 896 | zfcp_fsf_req_free(fsf_req); |
| 897 | failed_req_create: |
| 898 | out: |
| 899 | write_unlock_irqrestore(&adapter->request_queue.queue_lock, lock_flags); |
| 900 | return retval; |
| 901 | } |
| 902 | |
| 903 | static int |
| 904 | zfcp_fsf_status_read_port_closed(struct zfcp_fsf_req *fsf_req) |
| 905 | { |
| 906 | struct fsf_status_read_buffer *status_buffer; |
| 907 | struct zfcp_adapter *adapter; |
| 908 | struct zfcp_port *port; |
| 909 | unsigned long flags; |
| 910 | |
| 911 | status_buffer = fsf_req->data.status_read.buffer; |
| 912 | adapter = fsf_req->adapter; |
| 913 | |
| 914 | read_lock_irqsave(&zfcp_data.config_lock, flags); |
| 915 | list_for_each_entry(port, &adapter->port_list_head, list) |
| 916 | if (port->d_id == (status_buffer->d_id & ZFCP_DID_MASK)) |
| 917 | break; |
| 918 | read_unlock_irqrestore(&zfcp_data.config_lock, flags); |
| 919 | |
| 920 | if (!port || (port->d_id != (status_buffer->d_id & ZFCP_DID_MASK))) { |
| 921 | ZFCP_LOG_NORMAL("bug: Reopen port indication received for" |
| 922 | "nonexisting port with d_id 0x%08x on " |
| 923 | "adapter %s. Ignored.\n", |
| 924 | status_buffer->d_id & ZFCP_DID_MASK, |
| 925 | zfcp_get_busid_by_adapter(adapter)); |
| 926 | goto out; |
| 927 | } |
| 928 | |
| 929 | switch (status_buffer->status_subtype) { |
| 930 | |
| 931 | case FSF_STATUS_READ_SUB_CLOSE_PHYS_PORT: |
| 932 | ZFCP_LOG_FLAGS(2, "FSF_STATUS_READ_SUB_CLOSE_PHYS_PORT\n"); |
| 933 | debug_text_event(adapter->erp_dbf, 3, "unsol_pc_phys:"); |
| 934 | zfcp_erp_port_reopen(port, 0); |
| 935 | break; |
| 936 | |
| 937 | case FSF_STATUS_READ_SUB_ERROR_PORT: |
| 938 | ZFCP_LOG_FLAGS(1, "FSF_STATUS_READ_SUB_ERROR_PORT\n"); |
| 939 | debug_text_event(adapter->erp_dbf, 1, "unsol_pc_err:"); |
| 940 | zfcp_erp_port_shutdown(port, 0); |
| 941 | break; |
| 942 | |
| 943 | default: |
| 944 | debug_text_event(adapter->erp_dbf, 0, "unsol_unk_sub:"); |
| 945 | debug_exception(adapter->erp_dbf, 0, |
| 946 | &status_buffer->status_subtype, sizeof (u32)); |
| 947 | ZFCP_LOG_NORMAL("bug: Undefined status subtype received " |
| 948 | "for a reopen indication on port with " |
| 949 | "d_id 0x%08x on the adapter %s. " |
| 950 | "Ignored. (debug info 0x%x)\n", |
| 951 | status_buffer->d_id, |
| 952 | zfcp_get_busid_by_adapter(adapter), |
| 953 | status_buffer->status_subtype); |
| 954 | } |
| 955 | out: |
| 956 | return 0; |
| 957 | } |
| 958 | |
| 959 | /* |
| 960 | * function: zfcp_fsf_status_read_handler |
| 961 | * |
| 962 | * purpose: is called for finished Open Port command |
| 963 | * |
| 964 | * returns: |
| 965 | */ |
| 966 | static int |
| 967 | zfcp_fsf_status_read_handler(struct zfcp_fsf_req *fsf_req) |
| 968 | { |
| 969 | int retval = 0; |
| 970 | struct zfcp_adapter *adapter = fsf_req->adapter; |
| 971 | struct fsf_status_read_buffer *status_buffer = |
| 972 | fsf_req->data.status_read.buffer; |
| 973 | |
| 974 | if (fsf_req->status & ZFCP_STATUS_FSFREQ_DISMISSED) { |
| 975 | mempool_free(status_buffer, adapter->pool.data_status_read); |
| 976 | zfcp_fsf_req_cleanup(fsf_req); |
| 977 | goto out; |
| 978 | } |
| 979 | |
| 980 | switch (status_buffer->status_type) { |
| 981 | |
| 982 | case FSF_STATUS_READ_PORT_CLOSED: |
| 983 | ZFCP_LOG_FLAGS(1, "FSF_STATUS_READ_PORT_CLOSED\n"); |
| 984 | debug_text_event(adapter->erp_dbf, 3, "unsol_pclosed:"); |
| 985 | debug_event(adapter->erp_dbf, 3, |
| 986 | &status_buffer->d_id, sizeof (u32)); |
| 987 | zfcp_fsf_status_read_port_closed(fsf_req); |
| 988 | break; |
| 989 | |
| 990 | case FSF_STATUS_READ_INCOMING_ELS: |
| 991 | ZFCP_LOG_FLAGS(1, "FSF_STATUS_READ_INCOMING_ELS\n"); |
| 992 | debug_text_event(adapter->erp_dbf, 3, "unsol_els:"); |
| 993 | zfcp_fsf_incoming_els(fsf_req); |
| 994 | break; |
| 995 | |
| 996 | case FSF_STATUS_READ_SENSE_DATA_AVAIL: |
| 997 | ZFCP_LOG_FLAGS(1, "FSF_STATUS_READ_SENSE_DATA_AVAIL\n"); |
| 998 | debug_text_event(adapter->erp_dbf, 3, "unsol_sense:"); |
| 999 | ZFCP_LOG_INFO("unsolicited sense data received (adapter %s)\n", |
| 1000 | zfcp_get_busid_by_adapter(adapter)); |
| 1001 | ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_NORMAL, (char *) status_buffer, |
| 1002 | sizeof(struct fsf_status_read_buffer)); |
| 1003 | break; |
| 1004 | |
| 1005 | case FSF_STATUS_READ_BIT_ERROR_THRESHOLD: |
| 1006 | ZFCP_LOG_FLAGS(1, "FSF_STATUS_READ_BIT_ERROR_THRESHOLD\n"); |
| 1007 | debug_text_event(adapter->erp_dbf, 3, "unsol_bit_err:"); |
| 1008 | ZFCP_LOG_NORMAL("Bit error threshold data received:\n"); |
| 1009 | ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_NORMAL, |
| 1010 | (char *) status_buffer, |
| 1011 | sizeof (struct fsf_status_read_buffer)); |
| 1012 | break; |
| 1013 | |
| 1014 | case FSF_STATUS_READ_LINK_DOWN: |
| 1015 | ZFCP_LOG_FLAGS(1, "FSF_STATUS_READ_LINK_DOWN\n"); |
| 1016 | debug_text_event(adapter->erp_dbf, 0, "unsol_link_down:"); |
| 1017 | ZFCP_LOG_INFO("Local link to adapter %s is down\n", |
| 1018 | zfcp_get_busid_by_adapter(adapter)); |
| 1019 | atomic_set_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED, |
| 1020 | &adapter->status); |
| 1021 | zfcp_erp_adapter_failed(adapter); |
| 1022 | break; |
| 1023 | |
| 1024 | case FSF_STATUS_READ_LINK_UP: |
| 1025 | ZFCP_LOG_FLAGS(1, "FSF_STATUS_READ_LINK_UP\n"); |
| 1026 | debug_text_event(adapter->erp_dbf, 2, "unsol_link_up:"); |
| 1027 | ZFCP_LOG_INFO("Local link to adapter %s was replugged. " |
| 1028 | "Restarting operations on this adapter\n", |
| 1029 | zfcp_get_busid_by_adapter(adapter)); |
| 1030 | /* All ports should be marked as ready to run again */ |
| 1031 | zfcp_erp_modify_adapter_status(adapter, |
| 1032 | ZFCP_STATUS_COMMON_RUNNING, |
| 1033 | ZFCP_SET); |
| 1034 | zfcp_erp_adapter_reopen(adapter, |
| 1035 | ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED |
| 1036 | | ZFCP_STATUS_COMMON_ERP_FAILED); |
| 1037 | break; |
| 1038 | |
| 1039 | case FSF_STATUS_READ_CFDC_UPDATED: |
| 1040 | ZFCP_LOG_FLAGS(1, "FSF_STATUS_READ_CFDC_UPDATED\n"); |
| 1041 | debug_text_event(adapter->erp_dbf, 2, "unsol_cfdc_update:"); |
| 1042 | ZFCP_LOG_INFO("CFDC has been updated on the adapter %s\n", |
| 1043 | zfcp_get_busid_by_adapter(adapter)); |
| 1044 | zfcp_erp_adapter_access_changed(adapter); |
| 1045 | break; |
| 1046 | |
| 1047 | case FSF_STATUS_READ_CFDC_HARDENED: |
| 1048 | ZFCP_LOG_FLAGS(1, "FSF_STATUS_READ_CFDC_HARDENED\n"); |
| 1049 | debug_text_event(adapter->erp_dbf, 2, "unsol_cfdc_harden:"); |
| 1050 | switch (status_buffer->status_subtype) { |
| 1051 | case FSF_STATUS_READ_SUB_CFDC_HARDENED_ON_SE: |
| 1052 | ZFCP_LOG_INFO("CFDC of adapter %s saved on SE\n", |
| 1053 | zfcp_get_busid_by_adapter(adapter)); |
| 1054 | break; |
| 1055 | case FSF_STATUS_READ_SUB_CFDC_HARDENED_ON_SE2: |
| 1056 | ZFCP_LOG_INFO("CFDC of adapter %s has been copied " |
| 1057 | "to the secondary SE\n", |
| 1058 | zfcp_get_busid_by_adapter(adapter)); |
| 1059 | break; |
| 1060 | default: |
| 1061 | ZFCP_LOG_INFO("CFDC of adapter %s has been hardened\n", |
| 1062 | zfcp_get_busid_by_adapter(adapter)); |
| 1063 | } |
| 1064 | break; |
| 1065 | |
| 1066 | default: |
| 1067 | debug_text_event(adapter->erp_dbf, 0, "unsol_unknown:"); |
| 1068 | debug_exception(adapter->erp_dbf, 0, |
| 1069 | &status_buffer->status_type, sizeof (u32)); |
| 1070 | ZFCP_LOG_NORMAL("bug: An unsolicited status packet of unknown " |
| 1071 | "type was received (debug info 0x%x)\n", |
| 1072 | status_buffer->status_type); |
| 1073 | ZFCP_LOG_DEBUG("Dump of status_read_buffer %p:\n", |
| 1074 | status_buffer); |
| 1075 | ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG, |
| 1076 | (char *) status_buffer, |
| 1077 | sizeof (struct fsf_status_read_buffer)); |
| 1078 | break; |
| 1079 | } |
| 1080 | mempool_free(status_buffer, adapter->pool.data_status_read); |
| 1081 | zfcp_fsf_req_cleanup(fsf_req); |
| 1082 | /* |
| 1083 | * recycle buffer and start new request repeat until outbound |
| 1084 | * queue is empty or adapter shutdown is requested |
| 1085 | */ |
| 1086 | /* |
| 1087 | * FIXME(qdio): |
| 1088 | * we may wait in the req_create for 5s during shutdown, so |
| 1089 | * qdio_cleanup will have to wait at least that long before returning |
| 1090 | * with failure to allow us a proper cleanup under all circumstances |
| 1091 | */ |
| 1092 | /* |
| 1093 | * FIXME: |
| 1094 | * allocation failure possible? (Is this code needed?) |
| 1095 | */ |
| 1096 | retval = zfcp_fsf_status_read(adapter, 0); |
| 1097 | if (retval < 0) { |
| 1098 | ZFCP_LOG_INFO("Failed to create unsolicited status read " |
| 1099 | "request for the adapter %s.\n", |
| 1100 | zfcp_get_busid_by_adapter(adapter)); |
| 1101 | /* temporary fix to avoid status read buffer shortage */ |
| 1102 | adapter->status_read_failed++; |
| 1103 | if ((ZFCP_STATUS_READS_RECOM - adapter->status_read_failed) |
| 1104 | < ZFCP_STATUS_READ_FAILED_THRESHOLD) { |
| 1105 | ZFCP_LOG_INFO("restart adapter %s due to status read " |
| 1106 | "buffer shortage\n", |
| 1107 | zfcp_get_busid_by_adapter(adapter)); |
| 1108 | zfcp_erp_adapter_reopen(adapter, 0); |
| 1109 | } |
| 1110 | } |
| 1111 | out: |
| 1112 | return retval; |
| 1113 | } |
| 1114 | |
| 1115 | /* |
| 1116 | * function: zfcp_fsf_abort_fcp_command |
| 1117 | * |
| 1118 | * purpose: tells FSF to abort a running SCSI command |
| 1119 | * |
| 1120 | * returns: address of initiated FSF request |
| 1121 | * NULL - request could not be initiated |
| 1122 | * |
| 1123 | * FIXME(design): should be watched by a timeout !!! |
| 1124 | * FIXME(design) shouldn't this be modified to return an int |
| 1125 | * also...don't know how though |
| 1126 | */ |
| 1127 | struct zfcp_fsf_req * |
| 1128 | zfcp_fsf_abort_fcp_command(unsigned long old_req_id, |
| 1129 | struct zfcp_adapter *adapter, |
| 1130 | struct zfcp_unit *unit, int req_flags) |
| 1131 | { |
| 1132 | volatile struct qdio_buffer_element *sbale; |
| 1133 | unsigned long lock_flags; |
| 1134 | struct zfcp_fsf_req *fsf_req = NULL; |
| 1135 | int retval = 0; |
| 1136 | |
| 1137 | /* setup new FSF request */ |
| 1138 | retval = zfcp_fsf_req_create(adapter, FSF_QTCB_ABORT_FCP_CMND, |
| 1139 | req_flags, adapter->pool.fsf_req_abort, |
| 1140 | &lock_flags, &fsf_req); |
| 1141 | if (retval < 0) { |
| 1142 | ZFCP_LOG_INFO("error: Failed to create an abort command " |
| 1143 | "request for lun 0x%016Lx on port 0x%016Lx " |
| 1144 | "on adapter %s.\n", |
| 1145 | unit->fcp_lun, |
| 1146 | unit->port->wwpn, |
| 1147 | zfcp_get_busid_by_adapter(adapter)); |
| 1148 | goto out; |
| 1149 | } |
| 1150 | |
| 1151 | sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0); |
| 1152 | sbale[0].flags |= SBAL_FLAGS0_TYPE_READ; |
| 1153 | sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY; |
| 1154 | |
| 1155 | fsf_req->data.abort_fcp_command.unit = unit; |
| 1156 | |
| 1157 | /* set handles of unit and its parent port in QTCB */ |
| 1158 | fsf_req->qtcb->header.lun_handle = unit->handle; |
| 1159 | fsf_req->qtcb->header.port_handle = unit->port->handle; |
| 1160 | |
| 1161 | /* set handle of request which should be aborted */ |
| 1162 | fsf_req->qtcb->bottom.support.req_handle = (u64) old_req_id; |
| 1163 | |
| 1164 | /* start QDIO request for this FSF request */ |
| 1165 | |
| 1166 | zfcp_fsf_start_scsi_er_timer(adapter); |
| 1167 | retval = zfcp_fsf_req_send(fsf_req, NULL); |
| 1168 | if (retval) { |
| 1169 | del_timer(&adapter->scsi_er_timer); |
| 1170 | ZFCP_LOG_INFO("error: Failed to send abort command request " |
| 1171 | "on adapter %s, port 0x%016Lx, unit 0x%016Lx\n", |
| 1172 | zfcp_get_busid_by_adapter(adapter), |
| 1173 | unit->port->wwpn, unit->fcp_lun); |
| 1174 | zfcp_fsf_req_free(fsf_req); |
| 1175 | fsf_req = NULL; |
| 1176 | goto out; |
| 1177 | } |
| 1178 | |
| 1179 | ZFCP_LOG_DEBUG("Abort FCP Command request initiated " |
| 1180 | "(adapter%s, port d_id=0x%08x, " |
| 1181 | "unit x%016Lx, old_req_id=0x%lx)\n", |
| 1182 | zfcp_get_busid_by_adapter(adapter), |
| 1183 | unit->port->d_id, |
| 1184 | unit->fcp_lun, old_req_id); |
| 1185 | out: |
| 1186 | write_unlock_irqrestore(&adapter->request_queue.queue_lock, lock_flags); |
| 1187 | return fsf_req; |
| 1188 | } |
| 1189 | |
| 1190 | /* |
| 1191 | * function: zfcp_fsf_abort_fcp_command_handler |
| 1192 | * |
| 1193 | * purpose: is called for finished Abort FCP Command request |
| 1194 | * |
| 1195 | * returns: |
| 1196 | */ |
| 1197 | static int |
| 1198 | zfcp_fsf_abort_fcp_command_handler(struct zfcp_fsf_req *new_fsf_req) |
| 1199 | { |
| 1200 | int retval = -EINVAL; |
| 1201 | struct zfcp_unit *unit = new_fsf_req->data.abort_fcp_command.unit; |
| 1202 | unsigned char status_qual = |
| 1203 | new_fsf_req->qtcb->header.fsf_status_qual.word[0]; |
| 1204 | |
| 1205 | del_timer(&new_fsf_req->adapter->scsi_er_timer); |
| 1206 | |
| 1207 | if (new_fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) { |
| 1208 | /* do not set ZFCP_STATUS_FSFREQ_ABORTSUCCEEDED */ |
| 1209 | goto skip_fsfstatus; |
| 1210 | } |
| 1211 | |
| 1212 | /* evaluate FSF status in QTCB */ |
| 1213 | switch (new_fsf_req->qtcb->header.fsf_status) { |
| 1214 | |
| 1215 | case FSF_PORT_HANDLE_NOT_VALID: |
| 1216 | if (status_qual >> 4 != status_qual % 0xf) { |
| 1217 | ZFCP_LOG_FLAGS(2, "FSF_PORT_HANDLE_NOT_VALID\n"); |
| 1218 | debug_text_event(new_fsf_req->adapter->erp_dbf, 3, |
| 1219 | "fsf_s_phand_nv0"); |
| 1220 | /* |
| 1221 | * In this case a command that was sent prior to a port |
| 1222 | * reopen was aborted (handles are different). This is |
| 1223 | * fine. |
| 1224 | */ |
| 1225 | } else { |
| 1226 | ZFCP_LOG_FLAGS(1, "FSF_PORT_HANDLE_NOT_VALID\n"); |
| 1227 | ZFCP_LOG_INFO("Temporary port identifier 0x%x for " |
| 1228 | "port 0x%016Lx on adapter %s invalid. " |
| 1229 | "This may happen occasionally.\n", |
| 1230 | unit->port->handle, |
| 1231 | unit->port->wwpn, |
| 1232 | zfcp_get_busid_by_unit(unit)); |
| 1233 | ZFCP_LOG_INFO("status qualifier:\n"); |
| 1234 | ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_INFO, |
| 1235 | (char *) &new_fsf_req->qtcb->header. |
| 1236 | fsf_status_qual, |
| 1237 | sizeof (union fsf_status_qual)); |
| 1238 | /* Let's hope this sorts out the mess */ |
| 1239 | debug_text_event(new_fsf_req->adapter->erp_dbf, 1, |
| 1240 | "fsf_s_phand_nv1"); |
| 1241 | zfcp_erp_adapter_reopen(unit->port->adapter, 0); |
| 1242 | new_fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 1243 | } |
| 1244 | break; |
| 1245 | |
| 1246 | case FSF_LUN_HANDLE_NOT_VALID: |
| 1247 | if (status_qual >> 4 != status_qual % 0xf) { |
| 1248 | /* 2 */ |
| 1249 | ZFCP_LOG_FLAGS(0, "FSF_LUN_HANDLE_NOT_VALID\n"); |
| 1250 | debug_text_event(new_fsf_req->adapter->erp_dbf, 3, |
| 1251 | "fsf_s_lhand_nv0"); |
| 1252 | /* |
| 1253 | * In this case a command that was sent prior to a unit |
| 1254 | * reopen was aborted (handles are different). |
| 1255 | * This is fine. |
| 1256 | */ |
| 1257 | } else { |
| 1258 | ZFCP_LOG_FLAGS(1, "FSF_LUN_HANDLE_NOT_VALID\n"); |
| 1259 | ZFCP_LOG_INFO |
| 1260 | ("Warning: Temporary LUN identifier 0x%x of LUN " |
| 1261 | "0x%016Lx on port 0x%016Lx on adapter %s is " |
| 1262 | "invalid. This may happen in rare cases. " |
| 1263 | "Trying to re-establish link.\n", |
| 1264 | unit->handle, |
| 1265 | unit->fcp_lun, |
| 1266 | unit->port->wwpn, |
| 1267 | zfcp_get_busid_by_unit(unit)); |
| 1268 | ZFCP_LOG_DEBUG("Status qualifier data:\n"); |
| 1269 | ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG, |
| 1270 | (char *) &new_fsf_req->qtcb->header. |
| 1271 | fsf_status_qual, |
| 1272 | sizeof (union fsf_status_qual)); |
| 1273 | /* Let's hope this sorts out the mess */ |
| 1274 | debug_text_event(new_fsf_req->adapter->erp_dbf, 1, |
| 1275 | "fsf_s_lhand_nv1"); |
| 1276 | zfcp_erp_port_reopen(unit->port, 0); |
| 1277 | new_fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 1278 | } |
| 1279 | break; |
| 1280 | |
| 1281 | case FSF_FCP_COMMAND_DOES_NOT_EXIST: |
| 1282 | ZFCP_LOG_FLAGS(2, "FSF_FCP_COMMAND_DOES_NOT_EXIST\n"); |
| 1283 | retval = 0; |
| 1284 | debug_text_event(new_fsf_req->adapter->erp_dbf, 3, |
| 1285 | "fsf_s_no_exist"); |
| 1286 | new_fsf_req->status |= ZFCP_STATUS_FSFREQ_ABORTNOTNEEDED; |
| 1287 | break; |
| 1288 | |
| 1289 | case FSF_PORT_BOXED: |
| 1290 | /* 2 */ |
| 1291 | ZFCP_LOG_FLAGS(0, "FSF_PORT_BOXED\n"); |
| 1292 | ZFCP_LOG_INFO("Remote port 0x%016Lx on adapter %s needs to " |
| 1293 | "be reopened\n", unit->port->wwpn, |
| 1294 | zfcp_get_busid_by_unit(unit)); |
| 1295 | debug_text_event(new_fsf_req->adapter->erp_dbf, 2, |
| 1296 | "fsf_s_pboxed"); |
| 1297 | zfcp_erp_port_reopen(unit->port, 0); |
| 1298 | new_fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR |
| 1299 | | ZFCP_STATUS_FSFREQ_RETRY; |
| 1300 | break; |
| 1301 | |
| 1302 | case FSF_LUN_BOXED: |
| 1303 | ZFCP_LOG_FLAGS(0, "FSF_LUN_BOXED\n"); |
| 1304 | ZFCP_LOG_INFO( |
| 1305 | "unit 0x%016Lx on port 0x%016Lx on adapter %s needs " |
| 1306 | "to be reopened\n", |
| 1307 | unit->fcp_lun, unit->port->wwpn, |
| 1308 | zfcp_get_busid_by_unit(unit)); |
| 1309 | debug_text_event(new_fsf_req->adapter->erp_dbf, 1, "fsf_s_lboxed"); |
| 1310 | zfcp_erp_unit_reopen(unit, 0); |
| 1311 | zfcp_cmd_dbf_event_fsf("unitbox", new_fsf_req, |
| 1312 | &new_fsf_req->qtcb->header.fsf_status_qual, |
| 1313 | sizeof(union fsf_status_qual)); |
| 1314 | new_fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR |
| 1315 | | ZFCP_STATUS_FSFREQ_RETRY; |
| 1316 | break; |
| 1317 | |
| 1318 | case FSF_ADAPTER_STATUS_AVAILABLE: |
| 1319 | /* 2 */ |
| 1320 | ZFCP_LOG_FLAGS(0, "FSF_ADAPTER_STATUS_AVAILABLE\n"); |
| 1321 | switch (new_fsf_req->qtcb->header.fsf_status_qual.word[0]) { |
| 1322 | case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE: |
| 1323 | ZFCP_LOG_FLAGS(2, |
| 1324 | "FSF_SQ_INVOKE_LINK_TEST_PROCEDURE\n"); |
| 1325 | debug_text_event(new_fsf_req->adapter->erp_dbf, 1, |
| 1326 | "fsf_sq_ltest"); |
| 1327 | /* reopening link to port */ |
| 1328 | zfcp_erp_port_reopen(unit->port, 0); |
| 1329 | new_fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 1330 | break; |
| 1331 | case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED: |
| 1332 | ZFCP_LOG_FLAGS(2, |
| 1333 | "FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED\n"); |
| 1334 | /* SCSI stack will escalate */ |
| 1335 | debug_text_event(new_fsf_req->adapter->erp_dbf, 1, |
| 1336 | "fsf_sq_ulp"); |
| 1337 | new_fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 1338 | break; |
| 1339 | default: |
| 1340 | ZFCP_LOG_NORMAL |
| 1341 | ("bug: Wrong status qualifier 0x%x arrived.\n", |
| 1342 | new_fsf_req->qtcb->header.fsf_status_qual.word[0]); |
| 1343 | debug_text_event(new_fsf_req->adapter->erp_dbf, 0, |
| 1344 | "fsf_sq_inval:"); |
| 1345 | debug_exception(new_fsf_req->adapter->erp_dbf, 0, |
| 1346 | &new_fsf_req->qtcb->header. |
| 1347 | fsf_status_qual.word[0], sizeof (u32)); |
| 1348 | break; |
| 1349 | } |
| 1350 | break; |
| 1351 | |
| 1352 | case FSF_GOOD: |
| 1353 | /* 3 */ |
| 1354 | ZFCP_LOG_FLAGS(0, "FSF_GOOD\n"); |
| 1355 | retval = 0; |
| 1356 | new_fsf_req->status |= ZFCP_STATUS_FSFREQ_ABORTSUCCEEDED; |
| 1357 | break; |
| 1358 | |
| 1359 | default: |
| 1360 | ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented " |
| 1361 | "(debug info 0x%x)\n", |
| 1362 | new_fsf_req->qtcb->header.fsf_status); |
| 1363 | debug_text_event(new_fsf_req->adapter->erp_dbf, 0, |
| 1364 | "fsf_s_inval:"); |
| 1365 | debug_exception(new_fsf_req->adapter->erp_dbf, 0, |
| 1366 | &new_fsf_req->qtcb->header.fsf_status, |
| 1367 | sizeof (u32)); |
| 1368 | break; |
| 1369 | } |
| 1370 | skip_fsfstatus: |
| 1371 | return retval; |
| 1372 | } |
| 1373 | |
| 1374 | /** |
| 1375 | * zfcp_use_one_sbal - checks whether req buffer and resp bother each fit into |
| 1376 | * one SBALE |
| 1377 | * Two scatter-gather lists are passed, one for the reqeust and one for the |
| 1378 | * response. |
| 1379 | */ |
| 1380 | static inline int |
| 1381 | zfcp_use_one_sbal(struct scatterlist *req, int req_count, |
| 1382 | struct scatterlist *resp, int resp_count) |
| 1383 | { |
| 1384 | return ((req_count == 1) && |
| 1385 | (resp_count == 1) && |
| 1386 | (((unsigned long) zfcp_sg_to_address(&req[0]) & |
| 1387 | PAGE_MASK) == |
| 1388 | ((unsigned long) (zfcp_sg_to_address(&req[0]) + |
| 1389 | req[0].length - 1) & PAGE_MASK)) && |
| 1390 | (((unsigned long) zfcp_sg_to_address(&resp[0]) & |
| 1391 | PAGE_MASK) == |
| 1392 | ((unsigned long) (zfcp_sg_to_address(&resp[0]) + |
| 1393 | resp[0].length - 1) & PAGE_MASK))); |
| 1394 | } |
| 1395 | |
| 1396 | /** |
| 1397 | * zfcp_fsf_send_ct - initiate a Generic Service request (FC-GS) |
| 1398 | * @ct: pointer to struct zfcp_send_ct which conatins all needed data for |
| 1399 | * the request |
| 1400 | * @pool: pointer to memory pool, if non-null this pool is used to allocate |
| 1401 | * a struct zfcp_fsf_req |
| 1402 | * @erp_action: pointer to erp_action, if non-null the Generic Service request |
| 1403 | * is sent within error recovery |
| 1404 | */ |
| 1405 | int |
| 1406 | zfcp_fsf_send_ct(struct zfcp_send_ct *ct, mempool_t *pool, |
| 1407 | struct zfcp_erp_action *erp_action) |
| 1408 | { |
| 1409 | volatile struct qdio_buffer_element *sbale; |
| 1410 | struct zfcp_port *port; |
| 1411 | struct zfcp_adapter *adapter; |
| 1412 | struct zfcp_fsf_req *fsf_req; |
| 1413 | unsigned long lock_flags; |
| 1414 | int bytes; |
| 1415 | int ret = 0; |
| 1416 | |
| 1417 | port = ct->port; |
| 1418 | adapter = port->adapter; |
| 1419 | |
| 1420 | ret = zfcp_fsf_req_create(adapter, FSF_QTCB_SEND_GENERIC, |
| 1421 | ZFCP_WAIT_FOR_SBAL | ZFCP_REQ_AUTO_CLEANUP, |
| 1422 | pool, &lock_flags, &fsf_req); |
| 1423 | if (ret < 0) { |
| 1424 | ZFCP_LOG_INFO("error: Could not create CT request (FC-GS) for " |
| 1425 | "adapter: %s\n", |
| 1426 | zfcp_get_busid_by_adapter(adapter)); |
| 1427 | goto failed_req; |
| 1428 | } |
| 1429 | |
| 1430 | if (erp_action != NULL) { |
| 1431 | erp_action->fsf_req = fsf_req; |
| 1432 | fsf_req->erp_action = erp_action; |
| 1433 | } |
| 1434 | |
| 1435 | sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0); |
| 1436 | if (zfcp_use_one_sbal(ct->req, ct->req_count, |
| 1437 | ct->resp, ct->resp_count)){ |
| 1438 | /* both request buffer and response buffer |
| 1439 | fit into one sbale each */ |
| 1440 | sbale[0].flags |= SBAL_FLAGS0_TYPE_WRITE_READ; |
| 1441 | sbale[2].addr = zfcp_sg_to_address(&ct->req[0]); |
| 1442 | sbale[2].length = ct->req[0].length; |
| 1443 | sbale[3].addr = zfcp_sg_to_address(&ct->resp[0]); |
| 1444 | sbale[3].length = ct->resp[0].length; |
| 1445 | sbale[3].flags |= SBAL_FLAGS_LAST_ENTRY; |
| 1446 | } else if (adapter->supported_features & |
| 1447 | FSF_FEATURE_ELS_CT_CHAINED_SBALS) { |
| 1448 | /* try to use chained SBALs */ |
| 1449 | bytes = zfcp_qdio_sbals_from_sg(fsf_req, |
| 1450 | SBAL_FLAGS0_TYPE_WRITE_READ, |
| 1451 | ct->req, ct->req_count, |
| 1452 | ZFCP_MAX_SBALS_PER_CT_REQ); |
| 1453 | if (bytes <= 0) { |
| 1454 | ZFCP_LOG_INFO("error: creation of CT request failed " |
| 1455 | "on adapter %s\n", |
| 1456 | zfcp_get_busid_by_adapter(adapter)); |
| 1457 | if (bytes == 0) |
| 1458 | ret = -ENOMEM; |
| 1459 | else |
| 1460 | ret = bytes; |
| 1461 | |
| 1462 | goto failed_send; |
| 1463 | } |
| 1464 | fsf_req->qtcb->bottom.support.req_buf_length = bytes; |
| 1465 | fsf_req->sbale_curr = ZFCP_LAST_SBALE_PER_SBAL; |
| 1466 | bytes = zfcp_qdio_sbals_from_sg(fsf_req, |
| 1467 | SBAL_FLAGS0_TYPE_WRITE_READ, |
| 1468 | ct->resp, ct->resp_count, |
| 1469 | ZFCP_MAX_SBALS_PER_CT_REQ); |
| 1470 | if (bytes <= 0) { |
| 1471 | ZFCP_LOG_INFO("error: creation of CT request failed " |
| 1472 | "on adapter %s\n", |
| 1473 | zfcp_get_busid_by_adapter(adapter)); |
| 1474 | if (bytes == 0) |
| 1475 | ret = -ENOMEM; |
| 1476 | else |
| 1477 | ret = bytes; |
| 1478 | |
| 1479 | goto failed_send; |
| 1480 | } |
| 1481 | fsf_req->qtcb->bottom.support.resp_buf_length = bytes; |
| 1482 | } else { |
| 1483 | /* reject send generic request */ |
| 1484 | ZFCP_LOG_INFO( |
| 1485 | "error: microcode does not support chained SBALs," |
| 1486 | "CT request too big (adapter %s)\n", |
| 1487 | zfcp_get_busid_by_adapter(adapter)); |
| 1488 | ret = -EOPNOTSUPP; |
| 1489 | goto failed_send; |
| 1490 | } |
| 1491 | |
| 1492 | /* settings in QTCB */ |
| 1493 | fsf_req->qtcb->header.port_handle = port->handle; |
| 1494 | fsf_req->qtcb->bottom.support.service_class = adapter->fc_service_class; |
| 1495 | fsf_req->qtcb->bottom.support.timeout = ct->timeout; |
| 1496 | fsf_req->data.send_ct = ct; |
| 1497 | |
| 1498 | /* start QDIO request for this FSF request */ |
| 1499 | ret = zfcp_fsf_req_send(fsf_req, ct->timer); |
| 1500 | if (ret) { |
| 1501 | ZFCP_LOG_DEBUG("error: initiation of CT request failed " |
| 1502 | "(adapter %s, port 0x%016Lx)\n", |
| 1503 | zfcp_get_busid_by_adapter(adapter), port->wwpn); |
| 1504 | goto failed_send; |
| 1505 | } |
| 1506 | |
| 1507 | ZFCP_LOG_DEBUG("CT request initiated (adapter %s, port 0x%016Lx)\n", |
| 1508 | zfcp_get_busid_by_adapter(adapter), port->wwpn); |
| 1509 | goto out; |
| 1510 | |
| 1511 | failed_send: |
| 1512 | zfcp_fsf_req_free(fsf_req); |
| 1513 | if (erp_action != NULL) { |
| 1514 | erp_action->fsf_req = NULL; |
| 1515 | } |
| 1516 | failed_req: |
| 1517 | out: |
| 1518 | write_unlock_irqrestore(&adapter->request_queue.queue_lock, |
| 1519 | lock_flags); |
| 1520 | return ret; |
| 1521 | } |
| 1522 | |
| 1523 | /** |
| 1524 | * zfcp_fsf_send_ct_handler - handler for Generic Service requests |
| 1525 | * @fsf_req: pointer to struct zfcp_fsf_req |
| 1526 | * |
| 1527 | * Data specific for the Generic Service request is passed by |
| 1528 | * fsf_req->data.send_ct |
| 1529 | * Usually a specific handler for the request is called via |
| 1530 | * fsf_req->data.send_ct->handler at end of this function. |
| 1531 | */ |
| 1532 | static int |
| 1533 | zfcp_fsf_send_ct_handler(struct zfcp_fsf_req *fsf_req) |
| 1534 | { |
| 1535 | struct zfcp_port *port; |
| 1536 | struct zfcp_adapter *adapter; |
| 1537 | struct zfcp_send_ct *send_ct; |
| 1538 | struct fsf_qtcb_header *header; |
| 1539 | struct fsf_qtcb_bottom_support *bottom; |
| 1540 | int retval = -EINVAL; |
| 1541 | u16 subtable, rule, counter; |
| 1542 | |
| 1543 | adapter = fsf_req->adapter; |
| 1544 | send_ct = fsf_req->data.send_ct; |
| 1545 | port = send_ct->port; |
| 1546 | header = &fsf_req->qtcb->header; |
| 1547 | bottom = &fsf_req->qtcb->bottom.support; |
| 1548 | |
| 1549 | if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) |
| 1550 | goto skip_fsfstatus; |
| 1551 | |
| 1552 | /* evaluate FSF status in QTCB */ |
| 1553 | switch (header->fsf_status) { |
| 1554 | |
| 1555 | case FSF_GOOD: |
| 1556 | ZFCP_LOG_FLAGS(2,"FSF_GOOD\n"); |
| 1557 | retval = 0; |
| 1558 | break; |
| 1559 | |
| 1560 | case FSF_SERVICE_CLASS_NOT_SUPPORTED: |
| 1561 | ZFCP_LOG_FLAGS(2, "FSF_SERVICE_CLASS_NOT_SUPPORTED\n"); |
| 1562 | if (adapter->fc_service_class <= 3) { |
| 1563 | ZFCP_LOG_INFO("error: adapter %s does not support fc " |
| 1564 | "class %d.\n", |
| 1565 | zfcp_get_busid_by_port(port), |
| 1566 | adapter->fc_service_class); |
| 1567 | } else { |
| 1568 | ZFCP_LOG_INFO("bug: The fibre channel class at the " |
| 1569 | "adapter %s is invalid. " |
| 1570 | "(debug info %d)\n", |
| 1571 | zfcp_get_busid_by_port(port), |
| 1572 | adapter->fc_service_class); |
| 1573 | } |
| 1574 | /* stop operation for this adapter */ |
| 1575 | debug_text_exception(adapter->erp_dbf, 0, "fsf_s_class_nsup"); |
| 1576 | zfcp_erp_adapter_shutdown(adapter, 0); |
| 1577 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 1578 | break; |
| 1579 | |
| 1580 | case FSF_ADAPTER_STATUS_AVAILABLE: |
| 1581 | ZFCP_LOG_FLAGS(2, "FSF_ADAPTER_STATUS_AVAILABLE\n"); |
| 1582 | switch (header->fsf_status_qual.word[0]){ |
| 1583 | case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE: |
| 1584 | ZFCP_LOG_FLAGS(2,"FSF_SQ_INVOKE_LINK_TEST_PROCEDURE\n"); |
| 1585 | /* reopening link to port */ |
| 1586 | debug_text_event(adapter->erp_dbf, 1, "fsf_sq_ltest"); |
| 1587 | zfcp_test_link(port); |
| 1588 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 1589 | break; |
| 1590 | case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED: |
| 1591 | ZFCP_LOG_FLAGS(2,"FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED\n"); |
| 1592 | /* ERP strategy will escalate */ |
| 1593 | debug_text_event(adapter->erp_dbf, 1, "fsf_sq_ulp"); |
| 1594 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 1595 | break; |
| 1596 | default: |
| 1597 | ZFCP_LOG_INFO("bug: Wrong status qualifier 0x%x " |
| 1598 | "arrived.\n", |
| 1599 | header->fsf_status_qual.word[0]); |
| 1600 | break; |
| 1601 | } |
| 1602 | break; |
| 1603 | |
| 1604 | case FSF_ACCESS_DENIED: |
| 1605 | ZFCP_LOG_FLAGS(2, "FSF_ACCESS_DENIED\n"); |
| 1606 | ZFCP_LOG_NORMAL("access denied, cannot send generic service " |
| 1607 | "command (adapter %s, port d_id=0x%08x)\n", |
| 1608 | zfcp_get_busid_by_port(port), port->d_id); |
| 1609 | for (counter = 0; counter < 2; counter++) { |
| 1610 | subtable = header->fsf_status_qual.halfword[counter * 2]; |
| 1611 | rule = header->fsf_status_qual.halfword[counter * 2 + 1]; |
| 1612 | switch (subtable) { |
| 1613 | case FSF_SQ_CFDC_SUBTABLE_OS: |
| 1614 | case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN: |
| 1615 | case FSF_SQ_CFDC_SUBTABLE_PORT_DID: |
| 1616 | case FSF_SQ_CFDC_SUBTABLE_LUN: |
| 1617 | ZFCP_LOG_INFO("Access denied (%s rule %d)\n", |
| 1618 | zfcp_act_subtable_type[subtable], rule); |
| 1619 | break; |
| 1620 | } |
| 1621 | } |
| 1622 | debug_text_event(adapter->erp_dbf, 1, "fsf_s_access"); |
| 1623 | zfcp_erp_port_access_denied(port); |
| 1624 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 1625 | break; |
| 1626 | |
| 1627 | case FSF_GENERIC_COMMAND_REJECTED: |
| 1628 | ZFCP_LOG_FLAGS(2, "FSF_GENERIC_COMMAND_REJECTED\n"); |
| 1629 | ZFCP_LOG_INFO("generic service command rejected " |
| 1630 | "(adapter %s, port d_id=0x%08x)\n", |
| 1631 | zfcp_get_busid_by_port(port), port->d_id); |
| 1632 | ZFCP_LOG_INFO("status qualifier:\n"); |
| 1633 | ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_INFO, |
| 1634 | (char *) &header->fsf_status_qual, |
| 1635 | sizeof (union fsf_status_qual)); |
| 1636 | debug_text_event(adapter->erp_dbf, 1, "fsf_s_gcom_rej"); |
| 1637 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 1638 | break; |
| 1639 | |
| 1640 | case FSF_PORT_HANDLE_NOT_VALID: |
| 1641 | ZFCP_LOG_FLAGS(2, "FSF_PORT_HANDLE_NOT_VALID\n"); |
| 1642 | ZFCP_LOG_DEBUG("Temporary port identifier 0x%x for port " |
| 1643 | "0x%016Lx on adapter %s invalid. This may " |
| 1644 | "happen occasionally.\n", port->handle, |
| 1645 | port->wwpn, zfcp_get_busid_by_port(port)); |
| 1646 | ZFCP_LOG_INFO("status qualifier:\n"); |
| 1647 | ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_INFO, |
| 1648 | (char *) &header->fsf_status_qual, |
| 1649 | sizeof (union fsf_status_qual)); |
| 1650 | debug_text_event(adapter->erp_dbf, 1, "fsf_s_phandle_nv"); |
| 1651 | zfcp_erp_adapter_reopen(adapter, 0); |
| 1652 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 1653 | break; |
| 1654 | |
| 1655 | case FSF_PORT_BOXED: |
| 1656 | ZFCP_LOG_FLAGS(2, "FSF_PORT_BOXED\n"); |
| 1657 | ZFCP_LOG_INFO("port needs to be reopened " |
| 1658 | "(adapter %s, port d_id=0x%08x)\n", |
| 1659 | zfcp_get_busid_by_port(port), port->d_id); |
| 1660 | debug_text_event(adapter->erp_dbf, 2, "fsf_s_pboxed"); |
| 1661 | zfcp_erp_port_reopen(port, 0); |
| 1662 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR |
| 1663 | | ZFCP_STATUS_FSFREQ_RETRY; |
| 1664 | break; |
| 1665 | |
| 1666 | /* following states should never occure, all cases avoided |
| 1667 | in zfcp_fsf_send_ct - but who knows ... */ |
| 1668 | case FSF_PAYLOAD_SIZE_MISMATCH: |
| 1669 | ZFCP_LOG_FLAGS(2, "FSF_PAYLOAD_SIZE_MISMATCH\n"); |
| 1670 | ZFCP_LOG_INFO("payload size mismatch (adapter: %s, " |
| 1671 | "req_buf_length=%d, resp_buf_length=%d)\n", |
| 1672 | zfcp_get_busid_by_adapter(adapter), |
| 1673 | bottom->req_buf_length, bottom->resp_buf_length); |
| 1674 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 1675 | break; |
| 1676 | case FSF_REQUEST_SIZE_TOO_LARGE: |
| 1677 | ZFCP_LOG_FLAGS(2, "FSF_REQUEST_SIZE_TOO_LARGE\n"); |
| 1678 | ZFCP_LOG_INFO("request size too large (adapter: %s, " |
| 1679 | "req_buf_length=%d)\n", |
| 1680 | zfcp_get_busid_by_adapter(adapter), |
| 1681 | bottom->req_buf_length); |
| 1682 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 1683 | break; |
| 1684 | case FSF_RESPONSE_SIZE_TOO_LARGE: |
| 1685 | ZFCP_LOG_FLAGS(2, "FSF_RESPONSE_SIZE_TOO_LARGE\n"); |
| 1686 | ZFCP_LOG_INFO("response size too large (adapter: %s, " |
| 1687 | "resp_buf_length=%d)\n", |
| 1688 | zfcp_get_busid_by_adapter(adapter), |
| 1689 | bottom->resp_buf_length); |
| 1690 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 1691 | break; |
| 1692 | case FSF_SBAL_MISMATCH: |
| 1693 | ZFCP_LOG_FLAGS(2, "FSF_SBAL_MISMATCH\n"); |
| 1694 | ZFCP_LOG_INFO("SBAL mismatch (adapter: %s, req_buf_length=%d, " |
| 1695 | "resp_buf_length=%d)\n", |
| 1696 | zfcp_get_busid_by_adapter(adapter), |
| 1697 | bottom->req_buf_length, bottom->resp_buf_length); |
| 1698 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 1699 | break; |
| 1700 | |
| 1701 | default: |
| 1702 | ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented " |
| 1703 | "(debug info 0x%x)\n", header->fsf_status); |
| 1704 | debug_text_event(adapter->erp_dbf, 0, "fsf_sq_inval:"); |
| 1705 | debug_exception(adapter->erp_dbf, 0, |
| 1706 | &header->fsf_status_qual.word[0], sizeof (u32)); |
| 1707 | break; |
| 1708 | } |
| 1709 | |
| 1710 | skip_fsfstatus: |
| 1711 | send_ct->status = retval; |
| 1712 | |
| 1713 | if (send_ct->handler != NULL) |
| 1714 | send_ct->handler(send_ct->handler_data); |
| 1715 | |
| 1716 | return retval; |
| 1717 | } |
| 1718 | |
| 1719 | /** |
| 1720 | * zfcp_fsf_send_els - initiate an ELS command (FC-FS) |
| 1721 | * @els: pointer to struct zfcp_send_els which contains all needed data for |
| 1722 | * the command. |
| 1723 | */ |
| 1724 | int |
| 1725 | zfcp_fsf_send_els(struct zfcp_send_els *els) |
| 1726 | { |
| 1727 | volatile struct qdio_buffer_element *sbale; |
| 1728 | struct zfcp_fsf_req *fsf_req; |
| 1729 | fc_id_t d_id; |
| 1730 | struct zfcp_adapter *adapter; |
| 1731 | unsigned long lock_flags; |
| 1732 | int bytes; |
| 1733 | int ret = 0; |
| 1734 | |
| 1735 | d_id = els->d_id; |
| 1736 | adapter = els->adapter; |
| 1737 | |
| 1738 | ret = zfcp_fsf_req_create(adapter, FSF_QTCB_SEND_ELS, |
| 1739 | ZFCP_REQ_AUTO_CLEANUP, |
| 1740 | NULL, &lock_flags, &fsf_req); |
| 1741 | if (ret < 0) { |
| 1742 | ZFCP_LOG_INFO("error: creation of ELS request failed " |
| 1743 | "(adapter %s, port d_id: 0x%08x)\n", |
| 1744 | zfcp_get_busid_by_adapter(adapter), d_id); |
| 1745 | goto failed_req; |
| 1746 | } |
| 1747 | |
| 1748 | sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0); |
| 1749 | if (zfcp_use_one_sbal(els->req, els->req_count, |
| 1750 | els->resp, els->resp_count)){ |
| 1751 | /* both request buffer and response buffer |
| 1752 | fit into one sbale each */ |
| 1753 | sbale[0].flags |= SBAL_FLAGS0_TYPE_WRITE_READ; |
| 1754 | sbale[2].addr = zfcp_sg_to_address(&els->req[0]); |
| 1755 | sbale[2].length = els->req[0].length; |
| 1756 | sbale[3].addr = zfcp_sg_to_address(&els->resp[0]); |
| 1757 | sbale[3].length = els->resp[0].length; |
| 1758 | sbale[3].flags |= SBAL_FLAGS_LAST_ENTRY; |
| 1759 | } else if (adapter->supported_features & |
| 1760 | FSF_FEATURE_ELS_CT_CHAINED_SBALS) { |
| 1761 | /* try to use chained SBALs */ |
| 1762 | bytes = zfcp_qdio_sbals_from_sg(fsf_req, |
| 1763 | SBAL_FLAGS0_TYPE_WRITE_READ, |
| 1764 | els->req, els->req_count, |
| 1765 | ZFCP_MAX_SBALS_PER_ELS_REQ); |
| 1766 | if (bytes <= 0) { |
| 1767 | ZFCP_LOG_INFO("error: creation of ELS request failed " |
| 1768 | "(adapter %s, port d_id: 0x%08x)\n", |
| 1769 | zfcp_get_busid_by_adapter(adapter), d_id); |
| 1770 | if (bytes == 0) { |
| 1771 | ret = -ENOMEM; |
| 1772 | } else { |
| 1773 | ret = bytes; |
| 1774 | } |
| 1775 | goto failed_send; |
| 1776 | } |
| 1777 | fsf_req->qtcb->bottom.support.req_buf_length = bytes; |
| 1778 | fsf_req->sbale_curr = ZFCP_LAST_SBALE_PER_SBAL; |
| 1779 | bytes = zfcp_qdio_sbals_from_sg(fsf_req, |
| 1780 | SBAL_FLAGS0_TYPE_WRITE_READ, |
| 1781 | els->resp, els->resp_count, |
| 1782 | ZFCP_MAX_SBALS_PER_ELS_REQ); |
| 1783 | if (bytes <= 0) { |
| 1784 | ZFCP_LOG_INFO("error: creation of ELS request failed " |
| 1785 | "(adapter %s, port d_id: 0x%08x)\n", |
| 1786 | zfcp_get_busid_by_adapter(adapter), d_id); |
| 1787 | if (bytes == 0) { |
| 1788 | ret = -ENOMEM; |
| 1789 | } else { |
| 1790 | ret = bytes; |
| 1791 | } |
| 1792 | goto failed_send; |
| 1793 | } |
| 1794 | fsf_req->qtcb->bottom.support.resp_buf_length = bytes; |
| 1795 | } else { |
| 1796 | /* reject request */ |
| 1797 | ZFCP_LOG_INFO("error: microcode does not support chained SBALs" |
| 1798 | ", ELS request too big (adapter %s, " |
| 1799 | "port d_id: 0x%08x)\n", |
| 1800 | zfcp_get_busid_by_adapter(adapter), d_id); |
| 1801 | ret = -EOPNOTSUPP; |
| 1802 | goto failed_send; |
| 1803 | } |
| 1804 | |
| 1805 | /* settings in QTCB */ |
| 1806 | fsf_req->qtcb->bottom.support.d_id = d_id; |
| 1807 | fsf_req->qtcb->bottom.support.service_class = adapter->fc_service_class; |
| 1808 | fsf_req->qtcb->bottom.support.timeout = ZFCP_ELS_TIMEOUT; |
| 1809 | fsf_req->data.send_els = els; |
| 1810 | |
| 1811 | sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0); |
| 1812 | |
| 1813 | /* start QDIO request for this FSF request */ |
| 1814 | ret = zfcp_fsf_req_send(fsf_req, els->timer); |
| 1815 | if (ret) { |
| 1816 | ZFCP_LOG_DEBUG("error: initiation of ELS request failed " |
| 1817 | "(adapter %s, port d_id: 0x%08x)\n", |
| 1818 | zfcp_get_busid_by_adapter(adapter), d_id); |
| 1819 | goto failed_send; |
| 1820 | } |
| 1821 | |
| 1822 | ZFCP_LOG_DEBUG("ELS request initiated (adapter %s, port d_id: " |
| 1823 | "0x%08x)\n", zfcp_get_busid_by_adapter(adapter), d_id); |
| 1824 | goto out; |
| 1825 | |
| 1826 | failed_send: |
| 1827 | zfcp_fsf_req_free(fsf_req); |
| 1828 | |
| 1829 | failed_req: |
| 1830 | out: |
| 1831 | write_unlock_irqrestore(&adapter->request_queue.queue_lock, |
| 1832 | lock_flags); |
| 1833 | |
| 1834 | return ret; |
| 1835 | } |
| 1836 | |
| 1837 | /** |
| 1838 | * zfcp_fsf_send_els_handler - handler for ELS commands |
| 1839 | * @fsf_req: pointer to struct zfcp_fsf_req |
| 1840 | * |
| 1841 | * Data specific for the ELS command is passed by |
| 1842 | * fsf_req->data.send_els |
| 1843 | * Usually a specific handler for the command is called via |
| 1844 | * fsf_req->data.send_els->handler at end of this function. |
| 1845 | */ |
| 1846 | static int zfcp_fsf_send_els_handler(struct zfcp_fsf_req *fsf_req) |
| 1847 | { |
| 1848 | struct zfcp_adapter *adapter; |
| 1849 | fc_id_t d_id; |
| 1850 | struct zfcp_port *port; |
| 1851 | struct fsf_qtcb_header *header; |
| 1852 | struct fsf_qtcb_bottom_support *bottom; |
| 1853 | struct zfcp_send_els *send_els; |
| 1854 | int retval = -EINVAL; |
| 1855 | u16 subtable, rule, counter; |
| 1856 | |
| 1857 | send_els = fsf_req->data.send_els; |
| 1858 | adapter = send_els->adapter; |
| 1859 | d_id = send_els->d_id; |
| 1860 | header = &fsf_req->qtcb->header; |
| 1861 | bottom = &fsf_req->qtcb->bottom.support; |
| 1862 | |
| 1863 | if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) |
| 1864 | goto skip_fsfstatus; |
| 1865 | |
| 1866 | switch (header->fsf_status) { |
| 1867 | |
| 1868 | case FSF_GOOD: |
| 1869 | ZFCP_LOG_FLAGS(2, "FSF_GOOD\n"); |
| 1870 | retval = 0; |
| 1871 | break; |
| 1872 | |
| 1873 | case FSF_SERVICE_CLASS_NOT_SUPPORTED: |
| 1874 | ZFCP_LOG_FLAGS(2, "FSF_SERVICE_CLASS_NOT_SUPPORTED\n"); |
| 1875 | if (adapter->fc_service_class <= 3) { |
| 1876 | ZFCP_LOG_INFO("error: adapter %s does " |
| 1877 | "not support fibrechannel class %d.\n", |
| 1878 | zfcp_get_busid_by_adapter(adapter), |
| 1879 | adapter->fc_service_class); |
| 1880 | } else { |
| 1881 | ZFCP_LOG_INFO("bug: The fibrechannel class at " |
| 1882 | "adapter %s is invalid. " |
| 1883 | "(debug info %d)\n", |
| 1884 | zfcp_get_busid_by_adapter(adapter), |
| 1885 | adapter->fc_service_class); |
| 1886 | } |
| 1887 | /* stop operation for this adapter */ |
| 1888 | debug_text_exception(adapter->erp_dbf, 0, "fsf_s_class_nsup"); |
| 1889 | zfcp_erp_adapter_shutdown(adapter, 0); |
| 1890 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 1891 | break; |
| 1892 | |
| 1893 | case FSF_ADAPTER_STATUS_AVAILABLE: |
| 1894 | ZFCP_LOG_FLAGS(2, "FSF_ADAPTER_STATUS_AVAILABLE\n"); |
| 1895 | switch (header->fsf_status_qual.word[0]){ |
| 1896 | case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE: |
| 1897 | ZFCP_LOG_FLAGS(2,"FSF_SQ_INVOKE_LINK_TEST_PROCEDURE\n"); |
| 1898 | debug_text_event(adapter->erp_dbf, 1, "fsf_sq_ltest"); |
| 1899 | if (send_els->ls_code != ZFCP_LS_ADISC) { |
| 1900 | read_lock(&zfcp_data.config_lock); |
| 1901 | port = zfcp_get_port_by_did(adapter, d_id); |
| 1902 | if (port) |
| 1903 | zfcp_test_link(port); |
| 1904 | read_unlock(&zfcp_data.config_lock); |
| 1905 | } |
| 1906 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 1907 | break; |
| 1908 | case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED: |
| 1909 | ZFCP_LOG_FLAGS(2,"FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED\n"); |
| 1910 | debug_text_event(adapter->erp_dbf, 1, "fsf_sq_ulp"); |
| 1911 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 1912 | retval = |
| 1913 | zfcp_handle_els_rjt(header->fsf_status_qual.word[1], |
| 1914 | (struct zfcp_ls_rjt_par *) |
| 1915 | &header->fsf_status_qual.word[2]); |
| 1916 | break; |
| 1917 | case FSF_SQ_RETRY_IF_POSSIBLE: |
| 1918 | ZFCP_LOG_FLAGS(2, "FSF_SQ_RETRY_IF_POSSIBLE\n"); |
| 1919 | debug_text_event(adapter->erp_dbf, 1, "fsf_sq_retry"); |
| 1920 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 1921 | break; |
| 1922 | default: |
| 1923 | ZFCP_LOG_INFO("bug: Wrong status qualifier 0x%x\n", |
| 1924 | header->fsf_status_qual.word[0]); |
| 1925 | ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_INFO, |
| 1926 | (char*)header->fsf_status_qual.word, 16); |
| 1927 | } |
| 1928 | break; |
| 1929 | |
| 1930 | case FSF_ELS_COMMAND_REJECTED: |
| 1931 | ZFCP_LOG_FLAGS(2, "FSF_ELS_COMMAND_REJECTED\n"); |
| 1932 | ZFCP_LOG_INFO("ELS has been rejected because command filter " |
| 1933 | "prohibited sending " |
| 1934 | "(adapter: %s, port d_id: 0x%08x)\n", |
| 1935 | zfcp_get_busid_by_adapter(adapter), d_id); |
| 1936 | |
| 1937 | break; |
| 1938 | |
| 1939 | case FSF_PAYLOAD_SIZE_MISMATCH: |
| 1940 | ZFCP_LOG_FLAGS(2, "FSF_PAYLOAD_SIZE_MISMATCH\n"); |
| 1941 | ZFCP_LOG_INFO( |
| 1942 | "ELS request size and ELS response size must be either " |
| 1943 | "both 0, or both greater than 0 " |
| 1944 | "(adapter: %s, req_buf_length=%d resp_buf_length=%d)\n", |
| 1945 | zfcp_get_busid_by_adapter(adapter), |
| 1946 | bottom->req_buf_length, |
| 1947 | bottom->resp_buf_length); |
| 1948 | break; |
| 1949 | |
| 1950 | case FSF_REQUEST_SIZE_TOO_LARGE: |
| 1951 | ZFCP_LOG_FLAGS(2, "FSF_REQUEST_SIZE_TOO_LARGE\n"); |
| 1952 | ZFCP_LOG_INFO( |
| 1953 | "Length of the ELS request buffer, " |
| 1954 | "specified in QTCB bottom, " |
| 1955 | "exceeds the size of the buffers " |
| 1956 | "that have been allocated for ELS request data " |
| 1957 | "(adapter: %s, req_buf_length=%d)\n", |
| 1958 | zfcp_get_busid_by_adapter(adapter), |
| 1959 | bottom->req_buf_length); |
| 1960 | break; |
| 1961 | |
| 1962 | case FSF_RESPONSE_SIZE_TOO_LARGE: |
| 1963 | ZFCP_LOG_FLAGS(2, "FSF_RESPONSE_SIZE_TOO_LARGE\n"); |
| 1964 | ZFCP_LOG_INFO( |
| 1965 | "Length of the ELS response buffer, " |
| 1966 | "specified in QTCB bottom, " |
| 1967 | "exceeds the size of the buffers " |
| 1968 | "that have been allocated for ELS response data " |
| 1969 | "(adapter: %s, resp_buf_length=%d)\n", |
| 1970 | zfcp_get_busid_by_adapter(adapter), |
| 1971 | bottom->resp_buf_length); |
| 1972 | break; |
| 1973 | |
| 1974 | case FSF_SBAL_MISMATCH: |
| 1975 | /* should never occure, avoided in zfcp_fsf_send_els */ |
| 1976 | ZFCP_LOG_FLAGS(2, "FSF_SBAL_MISMATCH\n"); |
| 1977 | ZFCP_LOG_INFO("SBAL mismatch (adapter: %s, req_buf_length=%d, " |
| 1978 | "resp_buf_length=%d)\n", |
| 1979 | zfcp_get_busid_by_adapter(adapter), |
| 1980 | bottom->req_buf_length, bottom->resp_buf_length); |
| 1981 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 1982 | break; |
| 1983 | |
| 1984 | case FSF_ACCESS_DENIED: |
| 1985 | ZFCP_LOG_FLAGS(2, "FSF_ACCESS_DENIED\n"); |
| 1986 | ZFCP_LOG_NORMAL("access denied, cannot send ELS command " |
| 1987 | "(adapter %s, port d_id=0x%08x)\n", |
| 1988 | zfcp_get_busid_by_adapter(adapter), d_id); |
| 1989 | for (counter = 0; counter < 2; counter++) { |
| 1990 | subtable = header->fsf_status_qual.halfword[counter * 2]; |
| 1991 | rule = header->fsf_status_qual.halfword[counter * 2 + 1]; |
| 1992 | switch (subtable) { |
| 1993 | case FSF_SQ_CFDC_SUBTABLE_OS: |
| 1994 | case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN: |
| 1995 | case FSF_SQ_CFDC_SUBTABLE_PORT_DID: |
| 1996 | case FSF_SQ_CFDC_SUBTABLE_LUN: |
| 1997 | ZFCP_LOG_INFO("Access denied (%s rule %d)\n", |
| 1998 | zfcp_act_subtable_type[subtable], rule); |
| 1999 | break; |
| 2000 | } |
| 2001 | } |
| 2002 | debug_text_event(adapter->erp_dbf, 1, "fsf_s_access"); |
| 2003 | read_lock(&zfcp_data.config_lock); |
| 2004 | port = zfcp_get_port_by_did(adapter, d_id); |
| 2005 | if (port != NULL) |
| 2006 | zfcp_erp_port_access_denied(port); |
| 2007 | read_unlock(&zfcp_data.config_lock); |
| 2008 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 2009 | break; |
| 2010 | |
| 2011 | default: |
| 2012 | ZFCP_LOG_NORMAL( |
| 2013 | "bug: An unknown FSF Status was presented " |
| 2014 | "(adapter: %s, fsf_status=0x%08x)\n", |
| 2015 | zfcp_get_busid_by_adapter(adapter), |
| 2016 | header->fsf_status); |
| 2017 | debug_text_event(adapter->erp_dbf, 0, "fsf_sq_inval"); |
| 2018 | debug_exception(adapter->erp_dbf, 0, |
| 2019 | &header->fsf_status_qual.word[0], sizeof(u32)); |
| 2020 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 2021 | break; |
| 2022 | } |
| 2023 | |
| 2024 | skip_fsfstatus: |
| 2025 | send_els->status = retval; |
| 2026 | |
| 2027 | if (send_els->handler != 0) |
| 2028 | send_els->handler(send_els->handler_data); |
| 2029 | |
| 2030 | return retval; |
| 2031 | } |
| 2032 | |
| 2033 | /* |
| 2034 | * function: |
| 2035 | * |
| 2036 | * purpose: |
| 2037 | * |
| 2038 | * returns: address of initiated FSF request |
| 2039 | * NULL - request could not be initiated |
| 2040 | */ |
| 2041 | int |
| 2042 | zfcp_fsf_exchange_config_data(struct zfcp_erp_action *erp_action) |
| 2043 | { |
| 2044 | volatile struct qdio_buffer_element *sbale; |
| 2045 | unsigned long lock_flags; |
| 2046 | int retval = 0; |
| 2047 | |
| 2048 | /* setup new FSF request */ |
| 2049 | retval = zfcp_fsf_req_create(erp_action->adapter, |
| 2050 | FSF_QTCB_EXCHANGE_CONFIG_DATA, |
| 2051 | ZFCP_REQ_AUTO_CLEANUP, |
| 2052 | erp_action->adapter->pool.fsf_req_erp, |
| 2053 | &lock_flags, &(erp_action->fsf_req)); |
| 2054 | if (retval < 0) { |
| 2055 | ZFCP_LOG_INFO("error: Could not create exchange configuration " |
| 2056 | "data request for adapter %s.\n", |
| 2057 | zfcp_get_busid_by_adapter(erp_action->adapter)); |
| 2058 | goto out; |
| 2059 | } |
| 2060 | |
| 2061 | sbale = zfcp_qdio_sbale_req(erp_action->fsf_req, |
| 2062 | erp_action->fsf_req->sbal_curr, 0); |
| 2063 | sbale[0].flags |= SBAL_FLAGS0_TYPE_READ; |
| 2064 | sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY; |
| 2065 | |
| 2066 | erp_action->fsf_req->erp_action = erp_action; |
| 2067 | erp_action->fsf_req->qtcb->bottom.config.feature_selection = |
| 2068 | (FSF_FEATURE_CFDC | FSF_FEATURE_LUN_SHARING); |
| 2069 | |
| 2070 | /* start QDIO request for this FSF request */ |
| 2071 | retval = zfcp_fsf_req_send(erp_action->fsf_req, &erp_action->timer); |
| 2072 | if (retval) { |
| 2073 | ZFCP_LOG_INFO |
| 2074 | ("error: Could not send exchange configuration data " |
| 2075 | "command on the adapter %s\n", |
| 2076 | zfcp_get_busid_by_adapter(erp_action->adapter)); |
| 2077 | zfcp_fsf_req_free(erp_action->fsf_req); |
| 2078 | erp_action->fsf_req = NULL; |
| 2079 | goto out; |
| 2080 | } |
| 2081 | |
| 2082 | ZFCP_LOG_DEBUG("exchange configuration data request initiated " |
| 2083 | "(adapter %s)\n", |
| 2084 | zfcp_get_busid_by_adapter(erp_action->adapter)); |
| 2085 | |
| 2086 | out: |
| 2087 | write_unlock_irqrestore(&erp_action->adapter->request_queue.queue_lock, |
| 2088 | lock_flags); |
| 2089 | return retval; |
| 2090 | } |
| 2091 | |
| 2092 | /** |
| 2093 | * zfcp_fsf_exchange_config_evaluate |
| 2094 | * @fsf_req: fsf_req which belongs to xchg config data request |
| 2095 | * @xchg_ok: specifies if xchg config data was incomplete or complete (0/1) |
| 2096 | * |
| 2097 | * returns: -EIO on error, 0 otherwise |
| 2098 | */ |
| 2099 | static int |
| 2100 | zfcp_fsf_exchange_config_evaluate(struct zfcp_fsf_req *fsf_req, int xchg_ok) |
| 2101 | { |
| 2102 | struct fsf_qtcb_bottom_config *bottom; |
| 2103 | struct zfcp_adapter *adapter = fsf_req->adapter; |
| 2104 | |
| 2105 | bottom = &fsf_req->qtcb->bottom.config; |
| 2106 | ZFCP_LOG_DEBUG("low/high QTCB version 0x%x/0x%x of FSF\n", |
| 2107 | bottom->low_qtcb_version, bottom->high_qtcb_version); |
| 2108 | adapter->fsf_lic_version = bottom->lic_version; |
| 2109 | adapter->supported_features = bottom->supported_features; |
| 6f71d9b | 2005-04-10 23:04:28 -0500 | [diff] [blame] | 2110 | adapter->peer_wwpn = 0; |
| 2111 | adapter->peer_wwnn = 0; |
| 2112 | adapter->peer_d_id = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2113 | |
| 2114 | if (xchg_ok) { |
| 2115 | adapter->wwnn = bottom->nport_serv_param.wwnn; |
| 2116 | adapter->wwpn = bottom->nport_serv_param.wwpn; |
| 2117 | adapter->s_id = bottom->s_id & ZFCP_DID_MASK; |
| 2118 | adapter->fc_topology = bottom->fc_topology; |
| 2119 | adapter->fc_link_speed = bottom->fc_link_speed; |
| 2120 | adapter->hydra_version = bottom->adapter_type; |
| 2121 | } else { |
| 2122 | adapter->wwnn = 0; |
| 2123 | adapter->wwpn = 0; |
| 2124 | adapter->s_id = 0; |
| 2125 | adapter->fc_topology = 0; |
| 2126 | adapter->fc_link_speed = 0; |
| 2127 | adapter->hydra_version = 0; |
| 2128 | } |
| 2129 | |
| 6f71d9b | 2005-04-10 23:04:28 -0500 | [diff] [blame] | 2130 | if (adapter->fc_topology == FSF_TOPO_P2P) { |
| 2131 | adapter->peer_d_id = bottom->peer_d_id & ZFCP_DID_MASK; |
| 2132 | adapter->peer_wwpn = bottom->plogi_payload.wwpn; |
| 2133 | adapter->peer_wwnn = bottom->plogi_payload.wwnn; |
| 2134 | } |
| 2135 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2136 | if(adapter->supported_features & FSF_FEATURE_HBAAPI_MANAGEMENT){ |
| 2137 | adapter->hardware_version = bottom->hardware_version; |
| 2138 | memcpy(adapter->serial_number, bottom->serial_number, 17); |
| 2139 | EBCASC(adapter->serial_number, sizeof(adapter->serial_number)); |
| 2140 | } |
| 2141 | |
| 6f71d9b | 2005-04-10 23:04:28 -0500 | [diff] [blame] | 2142 | ZFCP_LOG_NORMAL("The adapter %s reported the following characteristics:\n" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2143 | "WWNN 0x%016Lx, " |
| 2144 | "WWPN 0x%016Lx, " |
| 2145 | "S_ID 0x%08x,\n" |
| 2146 | "adapter version 0x%x, " |
| 2147 | "LIC version 0x%x, " |
| 2148 | "FC link speed %d Gb/s\n", |
| 2149 | zfcp_get_busid_by_adapter(adapter), |
| 2150 | adapter->wwnn, |
| 2151 | adapter->wwpn, |
| 2152 | (unsigned int) adapter->s_id, |
| 2153 | adapter->hydra_version, |
| 2154 | adapter->fsf_lic_version, |
| 2155 | adapter->fc_link_speed); |
| 2156 | if (ZFCP_QTCB_VERSION < bottom->low_qtcb_version) { |
| 2157 | ZFCP_LOG_NORMAL("error: the adapter %s " |
| 2158 | "only supports newer control block " |
| 2159 | "versions in comparison to this device " |
| 2160 | "driver (try updated device driver)\n", |
| 2161 | zfcp_get_busid_by_adapter(adapter)); |
| 2162 | debug_text_event(adapter->erp_dbf, 0, "low_qtcb_ver"); |
| 2163 | zfcp_erp_adapter_shutdown(adapter, 0); |
| 2164 | return -EIO; |
| 2165 | } |
| 2166 | if (ZFCP_QTCB_VERSION > bottom->high_qtcb_version) { |
| 2167 | ZFCP_LOG_NORMAL("error: the adapter %s " |
| 2168 | "only supports older control block " |
| 2169 | "versions than this device driver uses" |
| 2170 | "(consider a microcode upgrade)\n", |
| 2171 | zfcp_get_busid_by_adapter(adapter)); |
| 2172 | debug_text_event(adapter->erp_dbf, 0, "high_qtcb_ver"); |
| 2173 | zfcp_erp_adapter_shutdown(adapter, 0); |
| 2174 | return -EIO; |
| 2175 | } |
| 2176 | return 0; |
| 2177 | } |
| 2178 | |
| 2179 | /* |
| 2180 | * function: zfcp_fsf_exchange_config_data_handler |
| 2181 | * |
| 2182 | * purpose: is called for finished Exchange Configuration Data command |
| 2183 | * |
| 2184 | * returns: |
| 2185 | */ |
| 2186 | static int |
| 2187 | zfcp_fsf_exchange_config_data_handler(struct zfcp_fsf_req *fsf_req) |
| 2188 | { |
| 2189 | struct fsf_qtcb_bottom_config *bottom; |
| 2190 | struct zfcp_adapter *adapter = fsf_req->adapter; |
| 2191 | |
| 2192 | if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) |
| 2193 | return -EIO; |
| 2194 | |
| 2195 | switch (fsf_req->qtcb->header.fsf_status) { |
| 2196 | |
| 2197 | case FSF_GOOD: |
| 2198 | ZFCP_LOG_FLAGS(2, "FSF_GOOD\n"); |
| 2199 | |
| 2200 | if (zfcp_fsf_exchange_config_evaluate(fsf_req, 1)) |
| 2201 | return -EIO; |
| 2202 | |
| 2203 | switch (adapter->fc_topology) { |
| 2204 | case FSF_TOPO_P2P: |
| 2205 | ZFCP_LOG_FLAGS(1, "FSF_TOPO_P2P\n"); |
| 6f71d9b | 2005-04-10 23:04:28 -0500 | [diff] [blame] | 2206 | ZFCP_LOG_NORMAL("Point-to-Point fibrechannel " |
| 2207 | "configuration detected at adapter %s\n" |
| 2208 | "Peer WWNN 0x%016llx, " |
| 2209 | "peer WWPN 0x%016llx, " |
| 2210 | "peer d_id 0x%06x\n", |
| 2211 | zfcp_get_busid_by_adapter(adapter), |
| 2212 | adapter->peer_wwnn, |
| 2213 | adapter->peer_wwpn, |
| 2214 | adapter->peer_d_id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2215 | debug_text_event(fsf_req->adapter->erp_dbf, 0, |
| 2216 | "top-p-to-p"); |
| 6f71d9b | 2005-04-10 23:04:28 -0500 | [diff] [blame] | 2217 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2218 | case FSF_TOPO_AL: |
| 2219 | ZFCP_LOG_FLAGS(1, "FSF_TOPO_AL\n"); |
| 2220 | ZFCP_LOG_NORMAL("error: Arbitrated loop fibrechannel " |
| 2221 | "topology detected at adapter %s " |
| 2222 | "unsupported, shutting down adapter\n", |
| 2223 | zfcp_get_busid_by_adapter(adapter)); |
| 2224 | debug_text_event(fsf_req->adapter->erp_dbf, 0, |
| 2225 | "top-al"); |
| 2226 | zfcp_erp_adapter_shutdown(adapter, 0); |
| 2227 | return -EIO; |
| 2228 | case FSF_TOPO_FABRIC: |
| 2229 | ZFCP_LOG_FLAGS(1, "FSF_TOPO_FABRIC\n"); |
| 2230 | ZFCP_LOG_INFO("Switched fabric fibrechannel " |
| 2231 | "network detected at adapter %s.\n", |
| 2232 | zfcp_get_busid_by_adapter(adapter)); |
| 2233 | break; |
| 2234 | default: |
| 2235 | ZFCP_LOG_NORMAL("bug: The fibrechannel topology " |
| 2236 | "reported by the exchange " |
| 2237 | "configuration command for " |
| 2238 | "the adapter %s is not " |
| 2239 | "of a type known to the zfcp " |
| 2240 | "driver, shutting down adapter\n", |
| 2241 | zfcp_get_busid_by_adapter(adapter)); |
| 6f71d9b | 2005-04-10 23:04:28 -0500 | [diff] [blame] | 2242 | adapter->fc_topology = FSF_TOPO_ERROR; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2243 | debug_text_exception(fsf_req->adapter->erp_dbf, 0, |
| 2244 | "unknown-topo"); |
| 2245 | zfcp_erp_adapter_shutdown(adapter, 0); |
| 2246 | return -EIO; |
| 2247 | } |
| 2248 | bottom = &fsf_req->qtcb->bottom.config; |
| 2249 | if (bottom->max_qtcb_size < sizeof(struct fsf_qtcb)) { |
| 2250 | ZFCP_LOG_NORMAL("bug: Maximum QTCB size (%d bytes) " |
| 2251 | "allowed by the adapter %s " |
| 2252 | "is lower than the minimum " |
| 2253 | "required by the driver (%ld bytes).\n", |
| 2254 | bottom->max_qtcb_size, |
| 2255 | zfcp_get_busid_by_adapter(adapter), |
| 2256 | sizeof(struct fsf_qtcb)); |
| 2257 | debug_text_event(fsf_req->adapter->erp_dbf, 0, |
| 2258 | "qtcb-size"); |
| 2259 | debug_event(fsf_req->adapter->erp_dbf, 0, |
| 2260 | &bottom->max_qtcb_size, sizeof (u32)); |
| 2261 | zfcp_erp_adapter_shutdown(adapter, 0); |
| 2262 | return -EIO; |
| 2263 | } |
| 2264 | atomic_set_mask(ZFCP_STATUS_ADAPTER_XCONFIG_OK, |
| 2265 | &adapter->status); |
| 2266 | break; |
| 2267 | case FSF_EXCHANGE_CONFIG_DATA_INCOMPLETE: |
| 2268 | debug_text_event(adapter->erp_dbf, 0, "xchg-inco"); |
| 2269 | |
| 2270 | if (zfcp_fsf_exchange_config_evaluate(fsf_req, 0)) |
| 2271 | return -EIO; |
| 2272 | |
| 2273 | ZFCP_LOG_INFO("Local link to adapter %s is down\n", |
| 2274 | zfcp_get_busid_by_adapter(adapter)); |
| 2275 | atomic_set_mask(ZFCP_STATUS_ADAPTER_XCONFIG_OK | |
| 2276 | ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED, |
| 2277 | &adapter->status); |
| 2278 | zfcp_erp_adapter_failed(adapter); |
| 2279 | break; |
| 2280 | default: |
| 2281 | debug_text_event(fsf_req->adapter->erp_dbf, 0, "fsf-stat-ng"); |
| 2282 | debug_event(fsf_req->adapter->erp_dbf, 0, |
| 2283 | &fsf_req->qtcb->header.fsf_status, sizeof (u32)); |
| 2284 | zfcp_erp_adapter_shutdown(adapter, 0); |
| 2285 | return -EIO; |
| 2286 | } |
| 2287 | return 0; |
| 2288 | } |
| 2289 | |
| 2290 | /** |
| 2291 | * zfcp_fsf_exchange_port_data - request information about local port |
| 2292 | * @adapter: for which port data is requested |
| 2293 | * @data: response to exchange port data request |
| 2294 | */ |
| 2295 | int |
| 2296 | zfcp_fsf_exchange_port_data(struct zfcp_adapter *adapter, |
| 2297 | struct fsf_qtcb_bottom_port *data) |
| 2298 | { |
| 2299 | volatile struct qdio_buffer_element *sbale; |
| 2300 | int retval = 0; |
| 2301 | unsigned long lock_flags; |
| 2302 | struct zfcp_fsf_req *fsf_req; |
| 2303 | struct timer_list *timer; |
| 2304 | |
| 2305 | if(!(adapter->supported_features & FSF_FEATURE_HBAAPI_MANAGEMENT)){ |
| 2306 | ZFCP_LOG_INFO("error: exchange port data " |
| 2307 | "command not supported by adapter %s\n", |
| 2308 | zfcp_get_busid_by_adapter(adapter)); |
| 2309 | return -EOPNOTSUPP; |
| 2310 | } |
| 2311 | |
| 2312 | timer = kmalloc(sizeof(struct timer_list), GFP_KERNEL); |
| 2313 | if (!timer) |
| 2314 | return -ENOMEM; |
| 2315 | |
| 2316 | /* setup new FSF request */ |
| 2317 | retval = zfcp_fsf_req_create(adapter, FSF_QTCB_EXCHANGE_PORT_DATA, |
| 2318 | 0, 0, &lock_flags, &fsf_req); |
| 2319 | if (retval < 0) { |
| 2320 | ZFCP_LOG_INFO("error: Out of resources. Could not create an " |
| 2321 | "exchange port data request for" |
| 2322 | "the adapter %s.\n", |
| 2323 | zfcp_get_busid_by_adapter(adapter)); |
| 2324 | write_unlock_irqrestore(&adapter->request_queue.queue_lock, |
| 2325 | lock_flags); |
| 2326 | goto out; |
| 2327 | } |
| 2328 | |
| 2329 | sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0); |
| 2330 | sbale[0].flags |= SBAL_FLAGS0_TYPE_READ; |
| 2331 | sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY; |
| 2332 | |
| 2333 | fsf_req->data.port_data = data; |
| 2334 | |
| 2335 | init_timer(timer); |
| 2336 | timer->function = zfcp_fsf_request_timeout_handler; |
| 2337 | timer->data = (unsigned long) adapter; |
| 2338 | timer->expires = ZFCP_FSF_REQUEST_TIMEOUT; |
| 2339 | |
| 2340 | retval = zfcp_fsf_req_send(fsf_req, timer); |
| 2341 | if (retval) { |
| 2342 | ZFCP_LOG_INFO("error: Could not send an exchange port data " |
| 2343 | "command on the adapter %s\n", |
| 2344 | zfcp_get_busid_by_adapter(adapter)); |
| 2345 | zfcp_fsf_req_free(fsf_req); |
| 2346 | write_unlock_irqrestore(&adapter->request_queue.queue_lock, |
| 2347 | lock_flags); |
| 2348 | goto out; |
| 2349 | } |
| 2350 | |
| 2351 | ZFCP_LOG_DEBUG("Exchange Port Data request initiated (adapter %s)\n", |
| 2352 | zfcp_get_busid_by_adapter(adapter)); |
| 2353 | |
| 2354 | write_unlock_irqrestore(&adapter->request_queue.queue_lock, |
| 2355 | lock_flags); |
| 2356 | |
| 2357 | wait_event(fsf_req->completion_wq, |
| 2358 | fsf_req->status & ZFCP_STATUS_FSFREQ_COMPLETED); |
| 2359 | del_timer_sync(timer); |
| 2360 | zfcp_fsf_req_cleanup(fsf_req); |
| 2361 | out: |
| 2362 | kfree(timer); |
| 2363 | return retval; |
| 2364 | } |
| 2365 | |
| 2366 | |
| 2367 | /** |
| 2368 | * zfcp_fsf_exchange_port_data_handler - handler for exchange_port_data request |
| 2369 | * @fsf_req: pointer to struct zfcp_fsf_req |
| 2370 | */ |
| 2371 | static void |
| 2372 | zfcp_fsf_exchange_port_data_handler(struct zfcp_fsf_req *fsf_req) |
| 2373 | { |
| 2374 | struct fsf_qtcb_bottom_port *bottom; |
| 2375 | struct fsf_qtcb_bottom_port *data = fsf_req->data.port_data; |
| 2376 | |
| 2377 | if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) |
| 2378 | return; |
| 2379 | |
| 2380 | switch (fsf_req->qtcb->header.fsf_status) { |
| 2381 | case FSF_GOOD: |
| 2382 | ZFCP_LOG_FLAGS(2,"FSF_GOOD\n"); |
| 2383 | bottom = &fsf_req->qtcb->bottom.port; |
| 2384 | memcpy(data, bottom, sizeof(*data)); |
| 2385 | break; |
| 2386 | |
| 2387 | default: |
| 2388 | debug_text_event(fsf_req->adapter->erp_dbf, 0, "xchg-port-ng"); |
| 2389 | debug_event(fsf_req->adapter->erp_dbf, 0, |
| 2390 | &fsf_req->qtcb->header.fsf_status, sizeof(u32)); |
| 2391 | } |
| 2392 | } |
| 2393 | |
| 2394 | |
| 2395 | /* |
| 2396 | * function: zfcp_fsf_open_port |
| 2397 | * |
| 2398 | * purpose: |
| 2399 | * |
| 2400 | * returns: address of initiated FSF request |
| 2401 | * NULL - request could not be initiated |
| 2402 | */ |
| 2403 | int |
| 2404 | zfcp_fsf_open_port(struct zfcp_erp_action *erp_action) |
| 2405 | { |
| 2406 | volatile struct qdio_buffer_element *sbale; |
| 2407 | unsigned long lock_flags; |
| 2408 | int retval = 0; |
| 2409 | |
| 2410 | /* setup new FSF request */ |
| 2411 | retval = zfcp_fsf_req_create(erp_action->adapter, |
| 2412 | FSF_QTCB_OPEN_PORT_WITH_DID, |
| 2413 | ZFCP_WAIT_FOR_SBAL | ZFCP_REQ_AUTO_CLEANUP, |
| 2414 | erp_action->adapter->pool.fsf_req_erp, |
| 2415 | &lock_flags, &(erp_action->fsf_req)); |
| 2416 | if (retval < 0) { |
| 2417 | ZFCP_LOG_INFO("error: Could not create open port request " |
| 2418 | "for port 0x%016Lx on adapter %s.\n", |
| 2419 | erp_action->port->wwpn, |
| 2420 | zfcp_get_busid_by_adapter(erp_action->adapter)); |
| 2421 | goto out; |
| 2422 | } |
| 2423 | |
| 2424 | sbale = zfcp_qdio_sbale_req(erp_action->fsf_req, |
| 2425 | erp_action->fsf_req->sbal_curr, 0); |
| 2426 | sbale[0].flags |= SBAL_FLAGS0_TYPE_READ; |
| 2427 | sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY; |
| 2428 | |
| 2429 | erp_action->fsf_req->qtcb->bottom.support.d_id = erp_action->port->d_id; |
| 2430 | atomic_set_mask(ZFCP_STATUS_COMMON_OPENING, &erp_action->port->status); |
| 2431 | erp_action->fsf_req->data.open_port.port = erp_action->port; |
| 2432 | erp_action->fsf_req->erp_action = erp_action; |
| 2433 | |
| 2434 | /* start QDIO request for this FSF request */ |
| 2435 | retval = zfcp_fsf_req_send(erp_action->fsf_req, &erp_action->timer); |
| 2436 | if (retval) { |
| 2437 | ZFCP_LOG_INFO("error: Could not send open port request for " |
| 2438 | "port 0x%016Lx on adapter %s.\n", |
| 2439 | erp_action->port->wwpn, |
| 2440 | zfcp_get_busid_by_adapter(erp_action->adapter)); |
| 2441 | zfcp_fsf_req_free(erp_action->fsf_req); |
| 2442 | erp_action->fsf_req = NULL; |
| 2443 | goto out; |
| 2444 | } |
| 2445 | |
| 2446 | ZFCP_LOG_DEBUG("open port request initiated " |
| 2447 | "(adapter %s, port 0x%016Lx)\n", |
| 2448 | zfcp_get_busid_by_adapter(erp_action->adapter), |
| 2449 | erp_action->port->wwpn); |
| 2450 | out: |
| 2451 | write_unlock_irqrestore(&erp_action->adapter->request_queue.queue_lock, |
| 2452 | lock_flags); |
| 2453 | return retval; |
| 2454 | } |
| 2455 | |
| 2456 | /* |
| 2457 | * function: zfcp_fsf_open_port_handler |
| 2458 | * |
| 2459 | * purpose: is called for finished Open Port command |
| 2460 | * |
| 2461 | * returns: |
| 2462 | */ |
| 2463 | static int |
| 2464 | zfcp_fsf_open_port_handler(struct zfcp_fsf_req *fsf_req) |
| 2465 | { |
| 2466 | int retval = -EINVAL; |
| 2467 | struct zfcp_port *port; |
| 2468 | struct fsf_plogi *plogi; |
| 2469 | struct fsf_qtcb_header *header; |
| 2470 | u16 subtable, rule, counter; |
| 2471 | |
| 2472 | port = fsf_req->data.open_port.port; |
| 2473 | header = &fsf_req->qtcb->header; |
| 2474 | |
| 2475 | if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) { |
| 2476 | /* don't change port status in our bookkeeping */ |
| 2477 | goto skip_fsfstatus; |
| 2478 | } |
| 2479 | |
| 2480 | /* evaluate FSF status in QTCB */ |
| 2481 | switch (header->fsf_status) { |
| 2482 | |
| 2483 | case FSF_PORT_ALREADY_OPEN: |
| 2484 | ZFCP_LOG_FLAGS(0, "FSF_PORT_ALREADY_OPEN\n"); |
| 2485 | ZFCP_LOG_NORMAL("bug: remote port 0x%016Lx on adapter %s " |
| 2486 | "is already open.\n", |
| 2487 | port->wwpn, zfcp_get_busid_by_port(port)); |
| 2488 | debug_text_exception(fsf_req->adapter->erp_dbf, 0, |
| 2489 | "fsf_s_popen"); |
| 2490 | /* |
| 2491 | * This is a bug, however operation should continue normally |
| 2492 | * if it is simply ignored |
| 2493 | */ |
| 2494 | break; |
| 2495 | |
| 2496 | case FSF_ACCESS_DENIED: |
| 2497 | ZFCP_LOG_FLAGS(2, "FSF_ACCESS_DENIED\n"); |
| 2498 | ZFCP_LOG_NORMAL("Access denied, cannot open port 0x%016Lx " |
| 2499 | "on adapter %s\n", |
| 2500 | port->wwpn, zfcp_get_busid_by_port(port)); |
| 2501 | for (counter = 0; counter < 2; counter++) { |
| 2502 | subtable = header->fsf_status_qual.halfword[counter * 2]; |
| 2503 | rule = header->fsf_status_qual.halfword[counter * 2 + 1]; |
| 2504 | switch (subtable) { |
| 2505 | case FSF_SQ_CFDC_SUBTABLE_OS: |
| 2506 | case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN: |
| 2507 | case FSF_SQ_CFDC_SUBTABLE_PORT_DID: |
| 2508 | case FSF_SQ_CFDC_SUBTABLE_LUN: |
| 2509 | ZFCP_LOG_INFO("Access denied (%s rule %d)\n", |
| 2510 | zfcp_act_subtable_type[subtable], rule); |
| 2511 | break; |
| 2512 | } |
| 2513 | } |
| 2514 | debug_text_event(fsf_req->adapter->erp_dbf, 1, "fsf_s_access"); |
| 2515 | zfcp_erp_port_access_denied(port); |
| 2516 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 2517 | break; |
| 2518 | |
| 2519 | case FSF_MAXIMUM_NUMBER_OF_PORTS_EXCEEDED: |
| 2520 | ZFCP_LOG_FLAGS(1, "FSF_MAXIMUM_NUMBER_OF_PORTS_EXCEEDED\n"); |
| 2521 | ZFCP_LOG_INFO("error: The FSF adapter is out of resources. " |
| 2522 | "The remote port 0x%016Lx on adapter %s " |
| 2523 | "could not be opened. Disabling it.\n", |
| 2524 | port->wwpn, zfcp_get_busid_by_port(port)); |
| 2525 | debug_text_event(fsf_req->adapter->erp_dbf, 1, |
| 2526 | "fsf_s_max_ports"); |
| 2527 | zfcp_erp_port_failed(port); |
| 2528 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 2529 | break; |
| 2530 | |
| 2531 | case FSF_ADAPTER_STATUS_AVAILABLE: |
| 2532 | ZFCP_LOG_FLAGS(2, "FSF_ADAPTER_STATUS_AVAILABLE\n"); |
| 2533 | switch (header->fsf_status_qual.word[0]) { |
| 2534 | case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE: |
| 2535 | ZFCP_LOG_FLAGS(2, |
| 2536 | "FSF_SQ_INVOKE_LINK_TEST_PROCEDURE\n"); |
| 2537 | debug_text_event(fsf_req->adapter->erp_dbf, 1, |
| 2538 | "fsf_sq_ltest"); |
| 2539 | /* ERP strategy will escalate */ |
| 2540 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 2541 | break; |
| 2542 | case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED: |
| 2543 | /* ERP strategy will escalate */ |
| 2544 | debug_text_event(fsf_req->adapter->erp_dbf, 1, |
| 2545 | "fsf_sq_ulp"); |
| 2546 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 2547 | break; |
| 2548 | case FSF_SQ_NO_RETRY_POSSIBLE: |
| 2549 | ZFCP_LOG_FLAGS(0, "FSF_SQ_NO_RETRY_POSSIBLE\n"); |
| 2550 | ZFCP_LOG_NORMAL("The remote port 0x%016Lx on " |
| 2551 | "adapter %s could not be opened. " |
| 2552 | "Disabling it.\n", |
| 2553 | port->wwpn, |
| 2554 | zfcp_get_busid_by_port(port)); |
| 2555 | debug_text_exception(fsf_req->adapter->erp_dbf, 0, |
| 2556 | "fsf_sq_no_retry"); |
| 2557 | zfcp_erp_port_failed(port); |
| 2558 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 2559 | break; |
| 2560 | default: |
| 2561 | ZFCP_LOG_NORMAL |
| 2562 | ("bug: Wrong status qualifier 0x%x arrived.\n", |
| 2563 | header->fsf_status_qual.word[0]); |
| 2564 | debug_text_event(fsf_req->adapter->erp_dbf, 0, |
| 2565 | "fsf_sq_inval:"); |
| 2566 | debug_exception( |
| 2567 | fsf_req->adapter->erp_dbf, 0, |
| 2568 | &header->fsf_status_qual.word[0], |
| 2569 | sizeof (u32)); |
| 2570 | break; |
| 2571 | } |
| 2572 | break; |
| 2573 | |
| 2574 | case FSF_GOOD: |
| 2575 | ZFCP_LOG_FLAGS(3, "FSF_GOOD\n"); |
| 2576 | /* save port handle assigned by FSF */ |
| 2577 | port->handle = header->port_handle; |
| 2578 | ZFCP_LOG_INFO("The remote port 0x%016Lx via adapter %s " |
| 2579 | "was opened, it's port handle is 0x%x\n", |
| 2580 | port->wwpn, zfcp_get_busid_by_port(port), |
| 2581 | port->handle); |
| 2582 | /* mark port as open */ |
| 2583 | atomic_set_mask(ZFCP_STATUS_COMMON_OPEN | |
| 2584 | ZFCP_STATUS_PORT_PHYS_OPEN, &port->status); |
| 2585 | retval = 0; |
| 2586 | /* check whether D_ID has changed during open */ |
| 2587 | /* |
| 2588 | * FIXME: This check is not airtight, as the FCP channel does |
| 2589 | * not monitor closures of target port connections caused on |
| 2590 | * the remote side. Thus, they might miss out on invalidating |
| 2591 | * locally cached WWPNs (and other N_Port parameters) of gone |
| 2592 | * target ports. So, our heroic attempt to make things safe |
| 2593 | * could be undermined by 'open port' response data tagged with |
| 2594 | * obsolete WWPNs. Another reason to monitor potential |
| 2595 | * connection closures ourself at least (by interpreting |
| 2596 | * incoming ELS' and unsolicited status). It just crosses my |
| 2597 | * mind that one should be able to cross-check by means of |
| 2598 | * another GID_PN straight after a port has been opened. |
| 2599 | * Alternately, an ADISC/PDISC ELS should suffice, as well. |
| 2600 | */ |
| 2601 | plogi = (struct fsf_plogi *) fsf_req->qtcb->bottom.support.els; |
| 2602 | if (!atomic_test_mask(ZFCP_STATUS_PORT_NO_WWPN, &port->status)) |
| 2603 | { |
| 2604 | if (fsf_req->qtcb->bottom.support.els1_length < |
| 2605 | ((((unsigned long) &plogi->serv_param.wwpn) - |
| 2606 | ((unsigned long) plogi)) + sizeof (u64))) { |
| 2607 | ZFCP_LOG_INFO( |
| 2608 | "warning: insufficient length of " |
| 2609 | "PLOGI payload (%i)\n", |
| 2610 | fsf_req->qtcb->bottom.support.els1_length); |
| 2611 | debug_text_event(fsf_req->adapter->erp_dbf, 0, |
| 2612 | "fsf_s_short_plogi:"); |
| 2613 | /* skip sanity check and assume wwpn is ok */ |
| 2614 | } else { |
| 2615 | if (plogi->serv_param.wwpn != port->wwpn) { |
| 2616 | ZFCP_LOG_INFO("warning: d_id of port " |
| 2617 | "0x%016Lx changed during " |
| 2618 | "open\n", port->wwpn); |
| 2619 | debug_text_event( |
| 2620 | fsf_req->adapter->erp_dbf, 0, |
| 2621 | "fsf_s_did_change:"); |
| 2622 | atomic_clear_mask( |
| 2623 | ZFCP_STATUS_PORT_DID_DID, |
| 2624 | &port->status); |
| 2625 | } else |
| 2626 | port->wwnn = plogi->serv_param.wwnn; |
| 2627 | } |
| 2628 | } |
| 2629 | break; |
| 2630 | |
| 2631 | case FSF_UNKNOWN_OP_SUBTYPE: |
| 2632 | /* should never occure, subtype not set in zfcp_fsf_open_port */ |
| 2633 | ZFCP_LOG_FLAGS(2, "FSF_UNKNOWN_OP_SUBTYPE\n"); |
| 2634 | ZFCP_LOG_INFO("unknown operation subtype (adapter: %s, " |
| 2635 | "op_subtype=0x%x)\n", |
| 2636 | zfcp_get_busid_by_port(port), |
| 2637 | fsf_req->qtcb->bottom.support.operation_subtype); |
| 2638 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 2639 | break; |
| 2640 | |
| 2641 | default: |
| 2642 | ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented " |
| 2643 | "(debug info 0x%x)\n", |
| 2644 | header->fsf_status); |
| 2645 | debug_text_event(fsf_req->adapter->erp_dbf, 0, "fsf_s_inval:"); |
| 2646 | debug_exception(fsf_req->adapter->erp_dbf, 0, |
| 2647 | &header->fsf_status, sizeof (u32)); |
| 2648 | break; |
| 2649 | } |
| 2650 | |
| 2651 | skip_fsfstatus: |
| 2652 | atomic_clear_mask(ZFCP_STATUS_COMMON_OPENING, &port->status); |
| 2653 | return retval; |
| 2654 | } |
| 2655 | |
| 2656 | /* |
| 2657 | * function: zfcp_fsf_close_port |
| 2658 | * |
| 2659 | * purpose: submit FSF command "close port" |
| 2660 | * |
| 2661 | * returns: address of initiated FSF request |
| 2662 | * NULL - request could not be initiated |
| 2663 | */ |
| 2664 | int |
| 2665 | zfcp_fsf_close_port(struct zfcp_erp_action *erp_action) |
| 2666 | { |
| 2667 | volatile struct qdio_buffer_element *sbale; |
| 2668 | unsigned long lock_flags; |
| 2669 | int retval = 0; |
| 2670 | |
| 2671 | /* setup new FSF request */ |
| 2672 | retval = zfcp_fsf_req_create(erp_action->adapter, |
| 2673 | FSF_QTCB_CLOSE_PORT, |
| 2674 | ZFCP_WAIT_FOR_SBAL | ZFCP_REQ_AUTO_CLEANUP, |
| 2675 | erp_action->adapter->pool.fsf_req_erp, |
| 2676 | &lock_flags, &(erp_action->fsf_req)); |
| 2677 | if (retval < 0) { |
| 2678 | ZFCP_LOG_INFO("error: Could not create a close port request " |
| 2679 | "for port 0x%016Lx on adapter %s.\n", |
| 2680 | erp_action->port->wwpn, |
| 2681 | zfcp_get_busid_by_adapter(erp_action->adapter)); |
| 2682 | goto out; |
| 2683 | } |
| 2684 | |
| 2685 | sbale = zfcp_qdio_sbale_req(erp_action->fsf_req, |
| 2686 | erp_action->fsf_req->sbal_curr, 0); |
| 2687 | sbale[0].flags |= SBAL_FLAGS0_TYPE_READ; |
| 2688 | sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY; |
| 2689 | |
| 2690 | atomic_set_mask(ZFCP_STATUS_COMMON_CLOSING, &erp_action->port->status); |
| 2691 | erp_action->fsf_req->data.close_port.port = erp_action->port; |
| 2692 | erp_action->fsf_req->erp_action = erp_action; |
| 2693 | erp_action->fsf_req->qtcb->header.port_handle = |
| 2694 | erp_action->port->handle; |
| 2695 | |
| 2696 | /* start QDIO request for this FSF request */ |
| 2697 | retval = zfcp_fsf_req_send(erp_action->fsf_req, &erp_action->timer); |
| 2698 | if (retval) { |
| 2699 | ZFCP_LOG_INFO("error: Could not send a close port request for " |
| 2700 | "port 0x%016Lx on adapter %s.\n", |
| 2701 | erp_action->port->wwpn, |
| 2702 | zfcp_get_busid_by_adapter(erp_action->adapter)); |
| 2703 | zfcp_fsf_req_free(erp_action->fsf_req); |
| 2704 | erp_action->fsf_req = NULL; |
| 2705 | goto out; |
| 2706 | } |
| 2707 | |
| 2708 | ZFCP_LOG_TRACE("close port request initiated " |
| 2709 | "(adapter %s, port 0x%016Lx)\n", |
| 2710 | zfcp_get_busid_by_adapter(erp_action->adapter), |
| 2711 | erp_action->port->wwpn); |
| 2712 | out: |
| 2713 | write_unlock_irqrestore(&erp_action->adapter->request_queue.queue_lock, |
| 2714 | lock_flags); |
| 2715 | return retval; |
| 2716 | } |
| 2717 | |
| 2718 | /* |
| 2719 | * function: zfcp_fsf_close_port_handler |
| 2720 | * |
| 2721 | * purpose: is called for finished Close Port FSF command |
| 2722 | * |
| 2723 | * returns: |
| 2724 | */ |
| 2725 | static int |
| 2726 | zfcp_fsf_close_port_handler(struct zfcp_fsf_req *fsf_req) |
| 2727 | { |
| 2728 | int retval = -EINVAL; |
| 2729 | struct zfcp_port *port; |
| 2730 | |
| 2731 | port = fsf_req->data.close_port.port; |
| 2732 | |
| 2733 | if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) { |
| 2734 | /* don't change port status in our bookkeeping */ |
| 2735 | goto skip_fsfstatus; |
| 2736 | } |
| 2737 | |
| 2738 | /* evaluate FSF status in QTCB */ |
| 2739 | switch (fsf_req->qtcb->header.fsf_status) { |
| 2740 | |
| 2741 | case FSF_PORT_HANDLE_NOT_VALID: |
| 2742 | ZFCP_LOG_FLAGS(1, "FSF_PORT_HANDLE_NOT_VALID\n"); |
| 2743 | ZFCP_LOG_INFO("Temporary port identifier 0x%x for port " |
| 2744 | "0x%016Lx on adapter %s invalid. This may happen " |
| 2745 | "occasionally.\n", port->handle, |
| 2746 | port->wwpn, zfcp_get_busid_by_port(port)); |
| 2747 | ZFCP_LOG_DEBUG("status qualifier:\n"); |
| 2748 | ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG, |
| 2749 | (char *) &fsf_req->qtcb->header.fsf_status_qual, |
| 2750 | sizeof (union fsf_status_qual)); |
| 2751 | debug_text_event(fsf_req->adapter->erp_dbf, 1, |
| 2752 | "fsf_s_phand_nv"); |
| 2753 | zfcp_erp_adapter_reopen(port->adapter, 0); |
| 2754 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 2755 | break; |
| 2756 | |
| 2757 | case FSF_ADAPTER_STATUS_AVAILABLE: |
| 2758 | ZFCP_LOG_FLAGS(2, "FSF_ADAPTER_STATUS_AVAILABLE\n"); |
| 2759 | /* Note: FSF has actually closed the port in this case. |
| 2760 | * The status code is just daft. Fingers crossed for a change |
| 2761 | */ |
| 2762 | retval = 0; |
| 2763 | break; |
| 2764 | |
| 2765 | case FSF_GOOD: |
| 2766 | ZFCP_LOG_FLAGS(3, "FSF_GOOD\n"); |
| 2767 | ZFCP_LOG_TRACE("remote port 0x016%Lx on adapter %s closed, " |
| 2768 | "port handle 0x%x\n", port->wwpn, |
| 2769 | zfcp_get_busid_by_port(port), port->handle); |
| 2770 | zfcp_erp_modify_port_status(port, |
| 2771 | ZFCP_STATUS_COMMON_OPEN, |
| 2772 | ZFCP_CLEAR); |
| 2773 | retval = 0; |
| 2774 | break; |
| 2775 | |
| 2776 | default: |
| 2777 | ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented " |
| 2778 | "(debug info 0x%x)\n", |
| 2779 | fsf_req->qtcb->header.fsf_status); |
| 2780 | debug_text_event(fsf_req->adapter->erp_dbf, 0, "fsf_s_inval:"); |
| 2781 | debug_exception(fsf_req->adapter->erp_dbf, 0, |
| 2782 | &fsf_req->qtcb->header.fsf_status, |
| 2783 | sizeof (u32)); |
| 2784 | break; |
| 2785 | } |
| 2786 | |
| 2787 | skip_fsfstatus: |
| 2788 | atomic_clear_mask(ZFCP_STATUS_COMMON_CLOSING, &port->status); |
| 2789 | return retval; |
| 2790 | } |
| 2791 | |
| 2792 | /* |
| 2793 | * function: zfcp_fsf_close_physical_port |
| 2794 | * |
| 2795 | * purpose: submit FSF command "close physical port" |
| 2796 | * |
| 2797 | * returns: address of initiated FSF request |
| 2798 | * NULL - request could not be initiated |
| 2799 | */ |
| 2800 | int |
| 2801 | zfcp_fsf_close_physical_port(struct zfcp_erp_action *erp_action) |
| 2802 | { |
| 2803 | int retval = 0; |
| 2804 | unsigned long lock_flags; |
| 2805 | volatile struct qdio_buffer_element *sbale; |
| 2806 | |
| 2807 | /* setup new FSF request */ |
| 2808 | retval = zfcp_fsf_req_create(erp_action->adapter, |
| 2809 | FSF_QTCB_CLOSE_PHYSICAL_PORT, |
| 2810 | ZFCP_WAIT_FOR_SBAL | ZFCP_REQ_AUTO_CLEANUP, |
| 2811 | erp_action->adapter->pool.fsf_req_erp, |
| 2812 | &lock_flags, &erp_action->fsf_req); |
| 2813 | if (retval < 0) { |
| 2814 | ZFCP_LOG_INFO("error: Could not create close physical port " |
| 2815 | "request (adapter %s, port 0x%016Lx)\n", |
| 2816 | zfcp_get_busid_by_adapter(erp_action->adapter), |
| 2817 | erp_action->port->wwpn); |
| 2818 | |
| 2819 | goto out; |
| 2820 | } |
| 2821 | |
| 2822 | sbale = zfcp_qdio_sbale_req(erp_action->fsf_req, |
| 2823 | erp_action->fsf_req->sbal_curr, 0); |
| 2824 | sbale[0].flags |= SBAL_FLAGS0_TYPE_READ; |
| 2825 | sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY; |
| 2826 | |
| 2827 | /* mark port as being closed */ |
| 2828 | atomic_set_mask(ZFCP_STATUS_PORT_PHYS_CLOSING, |
| 2829 | &erp_action->port->status); |
| 2830 | /* save a pointer to this port */ |
| 2831 | erp_action->fsf_req->data.close_physical_port.port = erp_action->port; |
| 2832 | /* port to be closeed */ |
| 2833 | erp_action->fsf_req->qtcb->header.port_handle = |
| 2834 | erp_action->port->handle; |
| 2835 | erp_action->fsf_req->erp_action = erp_action; |
| 2836 | |
| 2837 | /* start QDIO request for this FSF request */ |
| 2838 | retval = zfcp_fsf_req_send(erp_action->fsf_req, &erp_action->timer); |
| 2839 | if (retval) { |
| 2840 | ZFCP_LOG_INFO("error: Could not send close physical port " |
| 2841 | "request (adapter %s, port 0x%016Lx)\n", |
| 2842 | zfcp_get_busid_by_adapter(erp_action->adapter), |
| 2843 | erp_action->port->wwpn); |
| 2844 | zfcp_fsf_req_free(erp_action->fsf_req); |
| 2845 | erp_action->fsf_req = NULL; |
| 2846 | goto out; |
| 2847 | } |
| 2848 | |
| 2849 | ZFCP_LOG_TRACE("close physical port request initiated " |
| 2850 | "(adapter %s, port 0x%016Lx)\n", |
| 2851 | zfcp_get_busid_by_adapter(erp_action->adapter), |
| 2852 | erp_action->port->wwpn); |
| 2853 | out: |
| 2854 | write_unlock_irqrestore(&erp_action->adapter->request_queue.queue_lock, |
| 2855 | lock_flags); |
| 2856 | return retval; |
| 2857 | } |
| 2858 | |
| 2859 | /* |
| 2860 | * function: zfcp_fsf_close_physical_port_handler |
| 2861 | * |
| 2862 | * purpose: is called for finished Close Physical Port FSF command |
| 2863 | * |
| 2864 | * returns: |
| 2865 | */ |
| 2866 | static int |
| 2867 | zfcp_fsf_close_physical_port_handler(struct zfcp_fsf_req *fsf_req) |
| 2868 | { |
| 2869 | int retval = -EINVAL; |
| 2870 | struct zfcp_port *port; |
| 2871 | struct zfcp_unit *unit; |
| 2872 | struct fsf_qtcb_header *header; |
| 2873 | u16 subtable, rule, counter; |
| 2874 | |
| 2875 | port = fsf_req->data.close_physical_port.port; |
| 2876 | header = &fsf_req->qtcb->header; |
| 2877 | |
| 2878 | if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) { |
| 2879 | /* don't change port status in our bookkeeping */ |
| 2880 | goto skip_fsfstatus; |
| 2881 | } |
| 2882 | |
| 2883 | /* evaluate FSF status in QTCB */ |
| 2884 | switch (header->fsf_status) { |
| 2885 | |
| 2886 | case FSF_PORT_HANDLE_NOT_VALID: |
| 2887 | ZFCP_LOG_FLAGS(1, "FSF_PORT_HANDLE_NOT_VALID\n"); |
| 2888 | ZFCP_LOG_INFO("Temporary port identifier 0x%x invalid" |
| 2889 | "(adapter %s, port 0x%016Lx). " |
| 2890 | "This may happen occasionally.\n", |
| 2891 | port->handle, |
| 2892 | zfcp_get_busid_by_port(port), |
| 2893 | port->wwpn); |
| 2894 | ZFCP_LOG_DEBUG("status qualifier:\n"); |
| 2895 | ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG, |
| 2896 | (char *) &header->fsf_status_qual, |
| 2897 | sizeof (union fsf_status_qual)); |
| 2898 | debug_text_event(fsf_req->adapter->erp_dbf, 1, |
| 2899 | "fsf_s_phand_nv"); |
| 2900 | zfcp_erp_adapter_reopen(port->adapter, 0); |
| 2901 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 2902 | break; |
| 2903 | |
| 2904 | case FSF_ACCESS_DENIED: |
| 2905 | ZFCP_LOG_FLAGS(2, "FSF_ACCESS_DENIED\n"); |
| 2906 | ZFCP_LOG_NORMAL("Access denied, cannot close " |
| 2907 | "physical port 0x%016Lx on adapter %s\n", |
| 2908 | port->wwpn, zfcp_get_busid_by_port(port)); |
| 2909 | for (counter = 0; counter < 2; counter++) { |
| 2910 | subtable = header->fsf_status_qual.halfword[counter * 2]; |
| 2911 | rule = header->fsf_status_qual.halfword[counter * 2 + 1]; |
| 2912 | switch (subtable) { |
| 2913 | case FSF_SQ_CFDC_SUBTABLE_OS: |
| 2914 | case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN: |
| 2915 | case FSF_SQ_CFDC_SUBTABLE_PORT_DID: |
| 2916 | case FSF_SQ_CFDC_SUBTABLE_LUN: |
| 2917 | ZFCP_LOG_INFO("Access denied (%s rule %d)\n", |
| 2918 | zfcp_act_subtable_type[subtable], rule); |
| 2919 | break; |
| 2920 | } |
| 2921 | } |
| 2922 | debug_text_event(fsf_req->adapter->erp_dbf, 1, "fsf_s_access"); |
| 2923 | zfcp_erp_port_access_denied(port); |
| 2924 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 2925 | break; |
| 2926 | |
| 2927 | case FSF_PORT_BOXED: |
| 2928 | ZFCP_LOG_FLAGS(2, "FSF_PORT_BOXED\n"); |
| 2929 | ZFCP_LOG_DEBUG("The remote port 0x%016Lx on adapter " |
| 2930 | "%s needs to be reopened but it was attempted " |
| 2931 | "to close it physically.\n", |
| 2932 | port->wwpn, |
| 2933 | zfcp_get_busid_by_port(port)); |
| 2934 | debug_text_event(fsf_req->adapter->erp_dbf, 1, "fsf_s_pboxed"); |
| 2935 | zfcp_erp_port_reopen(port, 0); |
| 2936 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR | |
| 2937 | ZFCP_STATUS_FSFREQ_RETRY; |
| 2938 | break; |
| 2939 | |
| 2940 | case FSF_ADAPTER_STATUS_AVAILABLE: |
| 2941 | ZFCP_LOG_FLAGS(2, "FSF_ADAPTER_STATUS_AVAILABLE\n"); |
| 2942 | switch (header->fsf_status_qual.word[0]) { |
| 2943 | case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE: |
| 2944 | ZFCP_LOG_FLAGS(2, |
| 2945 | "FSF_SQ_INVOKE_LINK_TEST_PROCEDURE\n"); |
| 2946 | debug_text_event(fsf_req->adapter->erp_dbf, 1, |
| 2947 | "fsf_sq_ltest"); |
| 2948 | /* This will now be escalated by ERP */ |
| 2949 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 2950 | break; |
| 2951 | case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED: |
| 2952 | ZFCP_LOG_FLAGS(2, |
| 2953 | "FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED\n"); |
| 2954 | /* ERP strategy will escalate */ |
| 2955 | debug_text_event(fsf_req->adapter->erp_dbf, 1, |
| 2956 | "fsf_sq_ulp"); |
| 2957 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 2958 | break; |
| 2959 | default: |
| 2960 | ZFCP_LOG_NORMAL |
| 2961 | ("bug: Wrong status qualifier 0x%x arrived.\n", |
| 2962 | header->fsf_status_qual.word[0]); |
| 2963 | debug_text_event(fsf_req->adapter->erp_dbf, 0, |
| 2964 | "fsf_sq_inval:"); |
| 2965 | debug_exception( |
| 2966 | fsf_req->adapter->erp_dbf, 0, |
| 2967 | &header->fsf_status_qual.word[0], sizeof (u32)); |
| 2968 | break; |
| 2969 | } |
| 2970 | break; |
| 2971 | |
| 2972 | case FSF_GOOD: |
| 2973 | ZFCP_LOG_FLAGS(3, "FSF_GOOD\n"); |
| 2974 | ZFCP_LOG_DEBUG("Remote port 0x%016Lx via adapter %s " |
| 2975 | "physically closed, port handle 0x%x\n", |
| 2976 | port->wwpn, |
| 2977 | zfcp_get_busid_by_port(port), port->handle); |
| 2978 | /* can't use generic zfcp_erp_modify_port_status because |
| 2979 | * ZFCP_STATUS_COMMON_OPEN must not be reset for the port |
| 2980 | */ |
| 2981 | atomic_clear_mask(ZFCP_STATUS_PORT_PHYS_OPEN, &port->status); |
| 2982 | list_for_each_entry(unit, &port->unit_list_head, list) |
| 2983 | atomic_clear_mask(ZFCP_STATUS_COMMON_OPEN, &unit->status); |
| 2984 | retval = 0; |
| 2985 | break; |
| 2986 | |
| 2987 | default: |
| 2988 | ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented " |
| 2989 | "(debug info 0x%x)\n", |
| 2990 | header->fsf_status); |
| 2991 | debug_text_event(fsf_req->adapter->erp_dbf, 0, "fsf_s_inval:"); |
| 2992 | debug_exception(fsf_req->adapter->erp_dbf, 0, |
| 2993 | &header->fsf_status, sizeof (u32)); |
| 2994 | break; |
| 2995 | } |
| 2996 | |
| 2997 | skip_fsfstatus: |
| 2998 | atomic_clear_mask(ZFCP_STATUS_PORT_PHYS_CLOSING, &port->status); |
| 2999 | return retval; |
| 3000 | } |
| 3001 | |
| 3002 | /* |
| 3003 | * function: zfcp_fsf_open_unit |
| 3004 | * |
| 3005 | * purpose: |
| 3006 | * |
| 3007 | * returns: |
| 3008 | * |
| 3009 | * assumptions: This routine does not check whether the associated |
| 3010 | * remote port has already been opened. This should be |
| 3011 | * done by calling routines. Otherwise some status |
| 3012 | * may be presented by FSF |
| 3013 | */ |
| 3014 | int |
| 3015 | zfcp_fsf_open_unit(struct zfcp_erp_action *erp_action) |
| 3016 | { |
| 3017 | volatile struct qdio_buffer_element *sbale; |
| 3018 | unsigned long lock_flags; |
| 3019 | int retval = 0; |
| 3020 | |
| 3021 | /* setup new FSF request */ |
| 3022 | retval = zfcp_fsf_req_create(erp_action->adapter, |
| 3023 | FSF_QTCB_OPEN_LUN, |
| 3024 | ZFCP_WAIT_FOR_SBAL | ZFCP_REQ_AUTO_CLEANUP, |
| 3025 | erp_action->adapter->pool.fsf_req_erp, |
| 3026 | &lock_flags, &(erp_action->fsf_req)); |
| 3027 | if (retval < 0) { |
| 3028 | ZFCP_LOG_INFO("error: Could not create open unit request for " |
| 3029 | "unit 0x%016Lx on port 0x%016Lx on adapter %s.\n", |
| 3030 | erp_action->unit->fcp_lun, |
| 3031 | erp_action->unit->port->wwpn, |
| 3032 | zfcp_get_busid_by_adapter(erp_action->adapter)); |
| 3033 | goto out; |
| 3034 | } |
| 3035 | |
| 3036 | sbale = zfcp_qdio_sbale_req(erp_action->fsf_req, |
| 3037 | erp_action->fsf_req->sbal_curr, 0); |
| 3038 | sbale[0].flags |= SBAL_FLAGS0_TYPE_READ; |
| 3039 | sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY; |
| 3040 | |
| 3041 | erp_action->fsf_req->qtcb->header.port_handle = |
| 3042 | erp_action->port->handle; |
| 3043 | erp_action->fsf_req->qtcb->bottom.support.fcp_lun = |
| 3044 | erp_action->unit->fcp_lun; |
| 3045 | erp_action->fsf_req->qtcb->bottom.support.option = |
| 3046 | FSF_OPEN_LUN_SUPPRESS_BOXING; |
| 3047 | atomic_set_mask(ZFCP_STATUS_COMMON_OPENING, &erp_action->unit->status); |
| 3048 | erp_action->fsf_req->data.open_unit.unit = erp_action->unit; |
| 3049 | erp_action->fsf_req->erp_action = erp_action; |
| 3050 | |
| 3051 | /* start QDIO request for this FSF request */ |
| 3052 | retval = zfcp_fsf_req_send(erp_action->fsf_req, &erp_action->timer); |
| 3053 | if (retval) { |
| 3054 | ZFCP_LOG_INFO("error: Could not send an open unit request " |
| 3055 | "on the adapter %s, port 0x%016Lx for " |
| 3056 | "unit 0x%016Lx\n", |
| 3057 | zfcp_get_busid_by_adapter(erp_action->adapter), |
| 3058 | erp_action->port->wwpn, |
| 3059 | erp_action->unit->fcp_lun); |
| 3060 | zfcp_fsf_req_free(erp_action->fsf_req); |
| 3061 | erp_action->fsf_req = NULL; |
| 3062 | goto out; |
| 3063 | } |
| 3064 | |
| 3065 | ZFCP_LOG_TRACE("Open LUN request initiated (adapter %s, " |
| 3066 | "port 0x%016Lx, unit 0x%016Lx)\n", |
| 3067 | zfcp_get_busid_by_adapter(erp_action->adapter), |
| 3068 | erp_action->port->wwpn, erp_action->unit->fcp_lun); |
| 3069 | out: |
| 3070 | write_unlock_irqrestore(&erp_action->adapter->request_queue.queue_lock, |
| 3071 | lock_flags); |
| 3072 | return retval; |
| 3073 | } |
| 3074 | |
| 3075 | /* |
| 3076 | * function: zfcp_fsf_open_unit_handler |
| 3077 | * |
| 3078 | * purpose: is called for finished Open LUN command |
| 3079 | * |
| 3080 | * returns: |
| 3081 | */ |
| 3082 | static int |
| 3083 | zfcp_fsf_open_unit_handler(struct zfcp_fsf_req *fsf_req) |
| 3084 | { |
| 3085 | int retval = -EINVAL; |
| 3086 | struct zfcp_adapter *adapter; |
| 3087 | struct zfcp_unit *unit; |
| 3088 | struct fsf_qtcb_header *header; |
| 3089 | struct fsf_qtcb_bottom_support *bottom; |
| 3090 | struct fsf_queue_designator *queue_designator; |
| 3091 | u16 subtable, rule, counter; |
| 3092 | u32 allowed, exclusive, readwrite; |
| 3093 | |
| 3094 | unit = fsf_req->data.open_unit.unit; |
| 3095 | |
| 3096 | if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) { |
| 3097 | /* don't change unit status in our bookkeeping */ |
| 3098 | goto skip_fsfstatus; |
| 3099 | } |
| 3100 | |
| 3101 | adapter = fsf_req->adapter; |
| 3102 | header = &fsf_req->qtcb->header; |
| 3103 | bottom = &fsf_req->qtcb->bottom.support; |
| 3104 | queue_designator = &header->fsf_status_qual.fsf_queue_designator; |
| 3105 | |
| 3106 | allowed = bottom->lun_access_info & FSF_UNIT_ACCESS_OPEN_LUN_ALLOWED; |
| 3107 | exclusive = bottom->lun_access_info & FSF_UNIT_ACCESS_EXCLUSIVE; |
| 3108 | readwrite = bottom->lun_access_info & FSF_UNIT_ACCESS_OUTBOUND_TRANSFER; |
| 3109 | |
| 3110 | atomic_clear_mask(ZFCP_STATUS_COMMON_ACCESS_DENIED | |
| 3111 | ZFCP_STATUS_UNIT_SHARED | |
| 3112 | ZFCP_STATUS_UNIT_READONLY, |
| 3113 | &unit->status); |
| 3114 | |
| 3115 | /* evaluate FSF status in QTCB */ |
| 3116 | switch (header->fsf_status) { |
| 3117 | |
| 3118 | case FSF_PORT_HANDLE_NOT_VALID: |
| 3119 | ZFCP_LOG_FLAGS(1, "FSF_PORT_HANDLE_NOT_VALID\n"); |
| 3120 | ZFCP_LOG_INFO("Temporary port identifier 0x%x " |
| 3121 | "for port 0x%016Lx on adapter %s invalid " |
| 3122 | "This may happen occasionally\n", |
| 3123 | unit->port->handle, |
| 3124 | unit->port->wwpn, zfcp_get_busid_by_unit(unit)); |
| 3125 | ZFCP_LOG_DEBUG("status qualifier:\n"); |
| 3126 | ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG, |
| 3127 | (char *) &header->fsf_status_qual, |
| 3128 | sizeof (union fsf_status_qual)); |
| 3129 | debug_text_event(adapter->erp_dbf, 1, "fsf_s_ph_nv"); |
| 3130 | zfcp_erp_adapter_reopen(unit->port->adapter, 0); |
| 3131 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 3132 | break; |
| 3133 | |
| 3134 | case FSF_LUN_ALREADY_OPEN: |
| 3135 | ZFCP_LOG_FLAGS(0, "FSF_LUN_ALREADY_OPEN\n"); |
| 3136 | ZFCP_LOG_NORMAL("bug: Attempted to open unit 0x%016Lx on " |
| 3137 | "remote port 0x%016Lx on adapter %s twice.\n", |
| 3138 | unit->fcp_lun, |
| 3139 | unit->port->wwpn, zfcp_get_busid_by_unit(unit)); |
| 3140 | debug_text_exception(adapter->erp_dbf, 0, |
| 3141 | "fsf_s_uopen"); |
| 3142 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 3143 | break; |
| 3144 | |
| 3145 | case FSF_ACCESS_DENIED: |
| 3146 | ZFCP_LOG_FLAGS(2, "FSF_ACCESS_DENIED\n"); |
| 3147 | ZFCP_LOG_NORMAL("Access denied, cannot open unit 0x%016Lx on " |
| 3148 | "remote port 0x%016Lx on adapter %s\n", |
| 3149 | unit->fcp_lun, unit->port->wwpn, |
| 3150 | zfcp_get_busid_by_unit(unit)); |
| 3151 | for (counter = 0; counter < 2; counter++) { |
| 3152 | subtable = header->fsf_status_qual.halfword[counter * 2]; |
| 3153 | rule = header->fsf_status_qual.halfword[counter * 2 + 1]; |
| 3154 | switch (subtable) { |
| 3155 | case FSF_SQ_CFDC_SUBTABLE_OS: |
| 3156 | case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN: |
| 3157 | case FSF_SQ_CFDC_SUBTABLE_PORT_DID: |
| 3158 | case FSF_SQ_CFDC_SUBTABLE_LUN: |
| 3159 | ZFCP_LOG_INFO("Access denied (%s rule %d)\n", |
| 3160 | zfcp_act_subtable_type[subtable], rule); |
| 3161 | break; |
| 3162 | } |
| 3163 | } |
| 3164 | debug_text_event(adapter->erp_dbf, 1, "fsf_s_access"); |
| 3165 | zfcp_erp_unit_access_denied(unit); |
| 3166 | atomic_clear_mask(ZFCP_STATUS_UNIT_SHARED, &unit->status); |
| 3167 | atomic_clear_mask(ZFCP_STATUS_UNIT_READONLY, &unit->status); |
| 3168 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 3169 | break; |
| 3170 | |
| 3171 | case FSF_PORT_BOXED: |
| 3172 | ZFCP_LOG_FLAGS(2, "FSF_PORT_BOXED\n"); |
| 3173 | ZFCP_LOG_DEBUG("The remote port 0x%016Lx on adapter %s " |
| 3174 | "needs to be reopened\n", |
| 3175 | unit->port->wwpn, zfcp_get_busid_by_unit(unit)); |
| 3176 | debug_text_event(adapter->erp_dbf, 2, "fsf_s_pboxed"); |
| 3177 | zfcp_erp_port_reopen(unit->port, 0); |
| 3178 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR | |
| 3179 | ZFCP_STATUS_FSFREQ_RETRY; |
| 3180 | break; |
| 3181 | |
| 3182 | case FSF_LUN_SHARING_VIOLATION: |
| 3183 | ZFCP_LOG_FLAGS(2, "FSF_LUN_SHARING_VIOLATION\n"); |
| 3184 | if (header->fsf_status_qual.word[0] != 0) { |
| 3185 | ZFCP_LOG_NORMAL("FCP-LUN 0x%Lx at the remote port " |
| 3186 | "with WWPN 0x%Lx " |
| 3187 | "connected to the adapter %s " |
| 3188 | "is already in use in LPAR%d, CSS%d\n", |
| 3189 | unit->fcp_lun, |
| 3190 | unit->port->wwpn, |
| 3191 | zfcp_get_busid_by_unit(unit), |
| 3192 | queue_designator->hla, |
| 3193 | queue_designator->cssid); |
| 3194 | } else { |
| 3195 | subtable = header->fsf_status_qual.halfword[4]; |
| 3196 | rule = header->fsf_status_qual.halfword[5]; |
| 3197 | switch (subtable) { |
| 3198 | case FSF_SQ_CFDC_SUBTABLE_OS: |
| 3199 | case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN: |
| 3200 | case FSF_SQ_CFDC_SUBTABLE_PORT_DID: |
| 3201 | case FSF_SQ_CFDC_SUBTABLE_LUN: |
| 3202 | ZFCP_LOG_NORMAL("Access to FCP-LUN 0x%Lx at the " |
| 3203 | "remote port with WWPN 0x%Lx " |
| 3204 | "connected to the adapter %s " |
| 3205 | "is denied (%s rule %d)\n", |
| 3206 | unit->fcp_lun, |
| 3207 | unit->port->wwpn, |
| 3208 | zfcp_get_busid_by_unit(unit), |
| 3209 | zfcp_act_subtable_type[subtable], |
| 3210 | rule); |
| 3211 | break; |
| 3212 | } |
| 3213 | } |
| 3214 | ZFCP_LOG_DEBUG("status qualifier:\n"); |
| 3215 | ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG, |
| 3216 | (char *) &header->fsf_status_qual, |
| 3217 | sizeof (union fsf_status_qual)); |
| 3218 | debug_text_event(adapter->erp_dbf, 2, |
| 3219 | "fsf_s_l_sh_vio"); |
| 3220 | zfcp_erp_unit_access_denied(unit); |
| 3221 | atomic_clear_mask(ZFCP_STATUS_UNIT_SHARED, &unit->status); |
| 3222 | atomic_clear_mask(ZFCP_STATUS_UNIT_READONLY, &unit->status); |
| 3223 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 3224 | break; |
| 3225 | |
| 3226 | case FSF_MAXIMUM_NUMBER_OF_LUNS_EXCEEDED: |
| 3227 | ZFCP_LOG_FLAGS(1, "FSF_MAXIMUM_NUMBER_OF_LUNS_EXCEEDED\n"); |
| 3228 | ZFCP_LOG_INFO("error: The adapter ran out of resources. " |
| 3229 | "There is no handle (temporary port identifier) " |
| 3230 | "available for unit 0x%016Lx on port 0x%016Lx " |
| 3231 | "on adapter %s\n", |
| 3232 | unit->fcp_lun, |
| 3233 | unit->port->wwpn, |
| 3234 | zfcp_get_busid_by_unit(unit)); |
| 3235 | debug_text_event(adapter->erp_dbf, 1, |
| 3236 | "fsf_s_max_units"); |
| 3237 | zfcp_erp_unit_failed(unit); |
| 3238 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 3239 | break; |
| 3240 | |
| 3241 | case FSF_ADAPTER_STATUS_AVAILABLE: |
| 3242 | ZFCP_LOG_FLAGS(2, "FSF_ADAPTER_STATUS_AVAILABLE\n"); |
| 3243 | switch (header->fsf_status_qual.word[0]) { |
| 3244 | case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE: |
| 3245 | ZFCP_LOG_FLAGS(2, |
| 3246 | "FSF_SQ_INVOKE_LINK_TEST_PROCEDURE\n"); |
| 3247 | /* Re-establish link to port */ |
| 3248 | debug_text_event(adapter->erp_dbf, 1, |
| 3249 | "fsf_sq_ltest"); |
| 3250 | zfcp_erp_port_reopen(unit->port, 0); |
| 3251 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 3252 | break; |
| 3253 | case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED: |
| 3254 | ZFCP_LOG_FLAGS(2, |
| 3255 | "FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED\n"); |
| 3256 | /* ERP strategy will escalate */ |
| 3257 | debug_text_event(adapter->erp_dbf, 1, |
| 3258 | "fsf_sq_ulp"); |
| 3259 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 3260 | break; |
| 3261 | default: |
| 3262 | ZFCP_LOG_NORMAL |
| 3263 | ("bug: Wrong status qualifier 0x%x arrived.\n", |
| 3264 | header->fsf_status_qual.word[0]); |
| 3265 | debug_text_event(adapter->erp_dbf, 0, |
| 3266 | "fsf_sq_inval:"); |
| 3267 | debug_exception(adapter->erp_dbf, 0, |
| 3268 | &header->fsf_status_qual.word[0], |
| 3269 | sizeof (u32)); |
| 3270 | } |
| 3271 | break; |
| 3272 | |
| 3273 | case FSF_INVALID_COMMAND_OPTION: |
| 3274 | ZFCP_LOG_FLAGS(2, "FSF_INVALID_COMMAND_OPTION\n"); |
| 3275 | ZFCP_LOG_NORMAL( |
| 3276 | "Invalid option 0x%x has been specified " |
| 3277 | "in QTCB bottom sent to the adapter %s\n", |
| 3278 | bottom->option, |
| 3279 | zfcp_get_busid_by_adapter(adapter)); |
| 3280 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 3281 | retval = -EINVAL; |
| 3282 | break; |
| 3283 | |
| 3284 | case FSF_GOOD: |
| 3285 | ZFCP_LOG_FLAGS(3, "FSF_GOOD\n"); |
| 3286 | /* save LUN handle assigned by FSF */ |
| 3287 | unit->handle = header->lun_handle; |
| 3288 | ZFCP_LOG_TRACE("unit 0x%016Lx on remote port 0x%016Lx on " |
| 3289 | "adapter %s opened, port handle 0x%x\n", |
| 3290 | unit->fcp_lun, |
| 3291 | unit->port->wwpn, |
| 3292 | zfcp_get_busid_by_unit(unit), |
| 3293 | unit->handle); |
| 3294 | /* mark unit as open */ |
| 3295 | atomic_set_mask(ZFCP_STATUS_COMMON_OPEN, &unit->status); |
| 3296 | |
| 3297 | if (adapter->supported_features & FSF_FEATURE_LUN_SHARING){ |
| 3298 | if (!exclusive) |
| 3299 | atomic_set_mask(ZFCP_STATUS_UNIT_SHARED, |
| 3300 | &unit->status); |
| 3301 | |
| 3302 | if (!readwrite) { |
| 3303 | atomic_set_mask(ZFCP_STATUS_UNIT_READONLY, |
| 3304 | &unit->status); |
| 3305 | ZFCP_LOG_NORMAL("read-only access for unit " |
| 3306 | "(adapter %s, wwpn=0x%016Lx, " |
| 3307 | "fcp_lun=0x%016Lx)\n", |
| 3308 | zfcp_get_busid_by_unit(unit), |
| 3309 | unit->port->wwpn, |
| 3310 | unit->fcp_lun); |
| 3311 | } |
| 3312 | |
| 3313 | if (exclusive && !readwrite) { |
| 3314 | ZFCP_LOG_NORMAL("exclusive access of read-only " |
| 3315 | "unit not supported\n"); |
| 3316 | zfcp_erp_unit_failed(unit); |
| 3317 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 3318 | zfcp_erp_unit_shutdown(unit, 0); |
| 3319 | } else if (!exclusive && readwrite) { |
| 3320 | ZFCP_LOG_NORMAL("shared access of read-write " |
| 3321 | "unit not supported\n"); |
| 3322 | zfcp_erp_unit_failed(unit); |
| 3323 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 3324 | zfcp_erp_unit_shutdown(unit, 0); |
| 3325 | } |
| 3326 | } |
| 3327 | |
| 3328 | retval = 0; |
| 3329 | break; |
| 3330 | |
| 3331 | default: |
| 3332 | ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented " |
| 3333 | "(debug info 0x%x)\n", |
| 3334 | header->fsf_status); |
| 3335 | debug_text_event(adapter->erp_dbf, 0, "fsf_s_inval:"); |
| 3336 | debug_exception(adapter->erp_dbf, 0, |
| 3337 | &header->fsf_status, sizeof (u32)); |
| 3338 | break; |
| 3339 | } |
| 3340 | |
| 3341 | skip_fsfstatus: |
| 3342 | atomic_clear_mask(ZFCP_STATUS_COMMON_OPENING, &unit->status); |
| 3343 | return retval; |
| 3344 | } |
| 3345 | |
| 3346 | /* |
| 3347 | * function: zfcp_fsf_close_unit |
| 3348 | * |
| 3349 | * purpose: |
| 3350 | * |
| 3351 | * returns: address of fsf_req - request successfully initiated |
| 3352 | * NULL - |
| 3353 | * |
| 3354 | * assumptions: This routine does not check whether the associated |
| 3355 | * remote port/lun has already been opened. This should be |
| 3356 | * done by calling routines. Otherwise some status |
| 3357 | * may be presented by FSF |
| 3358 | */ |
| 3359 | int |
| 3360 | zfcp_fsf_close_unit(struct zfcp_erp_action *erp_action) |
| 3361 | { |
| 3362 | volatile struct qdio_buffer_element *sbale; |
| 3363 | unsigned long lock_flags; |
| 3364 | int retval = 0; |
| 3365 | |
| 3366 | /* setup new FSF request */ |
| 3367 | retval = zfcp_fsf_req_create(erp_action->adapter, |
| 3368 | FSF_QTCB_CLOSE_LUN, |
| 3369 | ZFCP_WAIT_FOR_SBAL | ZFCP_REQ_AUTO_CLEANUP, |
| 3370 | erp_action->adapter->pool.fsf_req_erp, |
| 3371 | &lock_flags, &(erp_action->fsf_req)); |
| 3372 | if (retval < 0) { |
| 3373 | ZFCP_LOG_INFO("error: Could not create close unit request for " |
| 3374 | "unit 0x%016Lx on port 0x%016Lx on adapter %s.\n", |
| 3375 | erp_action->unit->fcp_lun, |
| 3376 | erp_action->port->wwpn, |
| 3377 | zfcp_get_busid_by_adapter(erp_action->adapter)); |
| 3378 | goto out; |
| 3379 | } |
| 3380 | |
| 3381 | sbale = zfcp_qdio_sbale_req(erp_action->fsf_req, |
| 3382 | erp_action->fsf_req->sbal_curr, 0); |
| 3383 | sbale[0].flags |= SBAL_FLAGS0_TYPE_READ; |
| 3384 | sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY; |
| 3385 | |
| 3386 | erp_action->fsf_req->qtcb->header.port_handle = |
| 3387 | erp_action->port->handle; |
| 3388 | erp_action->fsf_req->qtcb->header.lun_handle = erp_action->unit->handle; |
| 3389 | atomic_set_mask(ZFCP_STATUS_COMMON_CLOSING, &erp_action->unit->status); |
| 3390 | erp_action->fsf_req->data.close_unit.unit = erp_action->unit; |
| 3391 | erp_action->fsf_req->erp_action = erp_action; |
| 3392 | |
| 3393 | /* start QDIO request for this FSF request */ |
| 3394 | retval = zfcp_fsf_req_send(erp_action->fsf_req, &erp_action->timer); |
| 3395 | if (retval) { |
| 3396 | ZFCP_LOG_INFO("error: Could not send a close unit request for " |
| 3397 | "unit 0x%016Lx on port 0x%016Lx onadapter %s.\n", |
| 3398 | erp_action->unit->fcp_lun, |
| 3399 | erp_action->port->wwpn, |
| 3400 | zfcp_get_busid_by_adapter(erp_action->adapter)); |
| 3401 | zfcp_fsf_req_free(erp_action->fsf_req); |
| 3402 | erp_action->fsf_req = NULL; |
| 3403 | goto out; |
| 3404 | } |
| 3405 | |
| 3406 | ZFCP_LOG_TRACE("Close LUN request initiated (adapter %s, " |
| 3407 | "port 0x%016Lx, unit 0x%016Lx)\n", |
| 3408 | zfcp_get_busid_by_adapter(erp_action->adapter), |
| 3409 | erp_action->port->wwpn, erp_action->unit->fcp_lun); |
| 3410 | out: |
| 3411 | write_unlock_irqrestore(&erp_action->adapter->request_queue.queue_lock, |
| 3412 | lock_flags); |
| 3413 | return retval; |
| 3414 | } |
| 3415 | |
| 3416 | /* |
| 3417 | * function: zfcp_fsf_close_unit_handler |
| 3418 | * |
| 3419 | * purpose: is called for finished Close LUN FSF command |
| 3420 | * |
| 3421 | * returns: |
| 3422 | */ |
| 3423 | static int |
| 3424 | zfcp_fsf_close_unit_handler(struct zfcp_fsf_req *fsf_req) |
| 3425 | { |
| 3426 | int retval = -EINVAL; |
| 3427 | struct zfcp_unit *unit; |
| 3428 | |
| 3429 | unit = fsf_req->data.close_unit.unit; /* restore unit */ |
| 3430 | |
| 3431 | if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) { |
| 3432 | /* don't change unit status in our bookkeeping */ |
| 3433 | goto skip_fsfstatus; |
| 3434 | } |
| 3435 | |
| 3436 | /* evaluate FSF status in QTCB */ |
| 3437 | switch (fsf_req->qtcb->header.fsf_status) { |
| 3438 | |
| 3439 | case FSF_PORT_HANDLE_NOT_VALID: |
| 3440 | ZFCP_LOG_FLAGS(1, "FSF_PORT_HANDLE_NOT_VALID\n"); |
| 3441 | ZFCP_LOG_INFO("Temporary port identifier 0x%x for port " |
| 3442 | "0x%016Lx on adapter %s invalid. This may " |
| 3443 | "happen in rare circumstances\n", |
| 3444 | unit->port->handle, |
| 3445 | unit->port->wwpn, |
| 3446 | zfcp_get_busid_by_unit(unit)); |
| 3447 | ZFCP_LOG_DEBUG("status qualifier:\n"); |
| 3448 | ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG, |
| 3449 | (char *) &fsf_req->qtcb->header.fsf_status_qual, |
| 3450 | sizeof (union fsf_status_qual)); |
| 3451 | debug_text_event(fsf_req->adapter->erp_dbf, 1, |
| 3452 | "fsf_s_phand_nv"); |
| 3453 | zfcp_erp_adapter_reopen(unit->port->adapter, 0); |
| 3454 | zfcp_cmd_dbf_event_fsf("porthinv", fsf_req, |
| 3455 | &fsf_req->qtcb->header.fsf_status_qual, |
| 3456 | sizeof (union fsf_status_qual)); |
| 3457 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 3458 | break; |
| 3459 | |
| 3460 | case FSF_LUN_HANDLE_NOT_VALID: |
| 3461 | ZFCP_LOG_FLAGS(1, "FSF_LUN_HANDLE_NOT_VALID\n"); |
| 3462 | ZFCP_LOG_INFO("Temporary LUN identifier 0x%x of unit " |
| 3463 | "0x%016Lx on port 0x%016Lx on adapter %s is " |
| 3464 | "invalid. This may happen occasionally.\n", |
| 3465 | unit->handle, |
| 3466 | unit->fcp_lun, |
| 3467 | unit->port->wwpn, |
| 3468 | zfcp_get_busid_by_unit(unit)); |
| 3469 | ZFCP_LOG_DEBUG("Status qualifier data:\n"); |
| 3470 | ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG, |
| 3471 | (char *) &fsf_req->qtcb->header.fsf_status_qual, |
| 3472 | sizeof (union fsf_status_qual)); |
| 3473 | debug_text_event(fsf_req->adapter->erp_dbf, 1, |
| 3474 | "fsf_s_lhand_nv"); |
| 3475 | zfcp_erp_port_reopen(unit->port, 0); |
| 3476 | zfcp_cmd_dbf_event_fsf("lunhinv", fsf_req, |
| 3477 | &fsf_req->qtcb->header.fsf_status_qual, |
| 3478 | sizeof (union fsf_status_qual)); |
| 3479 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 3480 | break; |
| 3481 | |
| 3482 | case FSF_PORT_BOXED: |
| 3483 | ZFCP_LOG_FLAGS(2, "FSF_PORT_BOXED\n"); |
| 3484 | ZFCP_LOG_DEBUG("The remote port 0x%016Lx on adapter %s " |
| 3485 | "needs to be reopened\n", |
| 3486 | unit->port->wwpn, |
| 3487 | zfcp_get_busid_by_unit(unit)); |
| 3488 | debug_text_event(fsf_req->adapter->erp_dbf, 2, "fsf_s_pboxed"); |
| 3489 | zfcp_erp_port_reopen(unit->port, 0); |
| 3490 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR | |
| 3491 | ZFCP_STATUS_FSFREQ_RETRY; |
| 3492 | break; |
| 3493 | |
| 3494 | case FSF_ADAPTER_STATUS_AVAILABLE: |
| 3495 | ZFCP_LOG_FLAGS(2, "FSF_ADAPTER_STATUS_AVAILABLE\n"); |
| 3496 | switch (fsf_req->qtcb->header.fsf_status_qual.word[0]) { |
| 3497 | case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE: |
| 3498 | ZFCP_LOG_FLAGS(2, |
| 3499 | "FSF_SQ_INVOKE_LINK_TEST_PROCEDURE\n"); |
| 3500 | /* re-establish link to port */ |
| 3501 | debug_text_event(fsf_req->adapter->erp_dbf, 1, |
| 3502 | "fsf_sq_ltest"); |
| 3503 | zfcp_erp_port_reopen(unit->port, 0); |
| 3504 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 3505 | break; |
| 3506 | case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED: |
| 3507 | ZFCP_LOG_FLAGS(2, |
| 3508 | "FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED\n"); |
| 3509 | /* ERP strategy will escalate */ |
| 3510 | debug_text_event(fsf_req->adapter->erp_dbf, 1, |
| 3511 | "fsf_sq_ulp"); |
| 3512 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 3513 | break; |
| 3514 | default: |
| 3515 | ZFCP_LOG_NORMAL |
| 3516 | ("bug: Wrong status qualifier 0x%x arrived.\n", |
| 3517 | fsf_req->qtcb->header.fsf_status_qual.word[0]); |
| 3518 | debug_text_event(fsf_req->adapter->erp_dbf, 0, |
| 3519 | "fsf_sq_inval:"); |
| 3520 | debug_exception( |
| 3521 | fsf_req->adapter->erp_dbf, 0, |
| 3522 | &fsf_req->qtcb->header.fsf_status_qual.word[0], |
| 3523 | sizeof (u32)); |
| 3524 | break; |
| 3525 | } |
| 3526 | break; |
| 3527 | |
| 3528 | case FSF_GOOD: |
| 3529 | ZFCP_LOG_FLAGS(3, "FSF_GOOD\n"); |
| 3530 | ZFCP_LOG_TRACE("unit 0x%016Lx on port 0x%016Lx on adapter %s " |
| 3531 | "closed, port handle 0x%x\n", |
| 3532 | unit->fcp_lun, |
| 3533 | unit->port->wwpn, |
| 3534 | zfcp_get_busid_by_unit(unit), |
| 3535 | unit->handle); |
| 3536 | /* mark unit as closed */ |
| 3537 | atomic_clear_mask(ZFCP_STATUS_COMMON_OPEN, &unit->status); |
| 3538 | retval = 0; |
| 3539 | break; |
| 3540 | |
| 3541 | default: |
| 3542 | ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented " |
| 3543 | "(debug info 0x%x)\n", |
| 3544 | fsf_req->qtcb->header.fsf_status); |
| 3545 | debug_text_event(fsf_req->adapter->erp_dbf, 0, "fsf_s_inval:"); |
| 3546 | debug_exception(fsf_req->adapter->erp_dbf, 0, |
| 3547 | &fsf_req->qtcb->header.fsf_status, |
| 3548 | sizeof (u32)); |
| 3549 | break; |
| 3550 | } |
| 3551 | |
| 3552 | skip_fsfstatus: |
| 3553 | atomic_clear_mask(ZFCP_STATUS_COMMON_CLOSING, &unit->status); |
| 3554 | return retval; |
| 3555 | } |
| 3556 | |
| 3557 | /** |
| 3558 | * zfcp_fsf_send_fcp_command_task - initiate an FCP command (for a SCSI command) |
| 3559 | * @adapter: adapter where scsi command is issued |
| 3560 | * @unit: unit where command is sent to |
| 3561 | * @scsi_cmnd: scsi command to be sent |
| 3562 | * @timer: timer to be started when request is initiated |
| 3563 | * @req_flags: flags for fsf_request |
| 3564 | */ |
| 3565 | int |
| 3566 | zfcp_fsf_send_fcp_command_task(struct zfcp_adapter *adapter, |
| 3567 | struct zfcp_unit *unit, |
| 3568 | struct scsi_cmnd * scsi_cmnd, |
| 3569 | struct timer_list *timer, int req_flags) |
| 3570 | { |
| 3571 | struct zfcp_fsf_req *fsf_req = NULL; |
| 3572 | struct fcp_cmnd_iu *fcp_cmnd_iu; |
| 3573 | unsigned int sbtype; |
| 3574 | unsigned long lock_flags; |
| 3575 | int real_bytes = 0; |
| 3576 | int retval = 0; |
| 3577 | int mask; |
| 3578 | |
| 3579 | /* setup new FSF request */ |
| 3580 | retval = zfcp_fsf_req_create(adapter, FSF_QTCB_FCP_CMND, req_flags, |
| 3581 | adapter->pool.fsf_req_scsi, |
| 3582 | &lock_flags, &fsf_req); |
| 3583 | if (unlikely(retval < 0)) { |
| 3584 | ZFCP_LOG_DEBUG("error: Could not create FCP command request " |
| 3585 | "for unit 0x%016Lx on port 0x%016Lx on " |
| 3586 | "adapter %s\n", |
| 3587 | unit->fcp_lun, |
| 3588 | unit->port->wwpn, |
| 3589 | zfcp_get_busid_by_adapter(adapter)); |
| 3590 | goto failed_req_create; |
| 3591 | } |
| 3592 | |
| 3593 | /* |
| 3594 | * associate FSF request with SCSI request |
| 3595 | * (need this for look up on abort) |
| 3596 | */ |
| 3597 | fsf_req->data.send_fcp_command_task.fsf_req = fsf_req; |
| 3598 | scsi_cmnd->host_scribble = (char *) &(fsf_req->data); |
| 3599 | |
| 3600 | /* |
| 3601 | * associate SCSI command with FSF request |
| 3602 | * (need this for look up on normal command completion) |
| 3603 | */ |
| 3604 | fsf_req->data.send_fcp_command_task.scsi_cmnd = scsi_cmnd; |
| 3605 | fsf_req->data.send_fcp_command_task.start_jiffies = jiffies; |
| 3606 | fsf_req->data.send_fcp_command_task.unit = unit; |
| 3607 | ZFCP_LOG_DEBUG("unit=%p, fcp_lun=0x%016Lx\n", unit, unit->fcp_lun); |
| 3608 | |
| 3609 | /* set handles of unit and its parent port in QTCB */ |
| 3610 | fsf_req->qtcb->header.lun_handle = unit->handle; |
| 3611 | fsf_req->qtcb->header.port_handle = unit->port->handle; |
| 3612 | |
| 3613 | /* FSF does not define the structure of the FCP_CMND IU */ |
| 3614 | fcp_cmnd_iu = (struct fcp_cmnd_iu *) |
| 3615 | &(fsf_req->qtcb->bottom.io.fcp_cmnd); |
| 3616 | |
| 3617 | /* |
| 3618 | * set depending on data direction: |
| 3619 | * data direction bits in SBALE (SB Type) |
| 3620 | * data direction bits in QTCB |
| 3621 | * data direction bits in FCP_CMND IU |
| 3622 | */ |
| 3623 | switch (scsi_cmnd->sc_data_direction) { |
| 3624 | case DMA_NONE: |
| 3625 | ZFCP_LOG_FLAGS(3, "DMA_NONE\n"); |
| 3626 | fsf_req->qtcb->bottom.io.data_direction = FSF_DATADIR_CMND; |
| 3627 | /* |
| 3628 | * FIXME(qdio): |
| 3629 | * what is the correct type for commands |
| 3630 | * without 'real' data buffers? |
| 3631 | */ |
| 3632 | sbtype = SBAL_FLAGS0_TYPE_READ; |
| 3633 | break; |
| 3634 | case DMA_FROM_DEVICE: |
| 3635 | ZFCP_LOG_FLAGS(3, "DMA_FROM_DEVICE\n"); |
| 3636 | fsf_req->qtcb->bottom.io.data_direction = FSF_DATADIR_READ; |
| 3637 | sbtype = SBAL_FLAGS0_TYPE_READ; |
| 3638 | fcp_cmnd_iu->rddata = 1; |
| 3639 | break; |
| 3640 | case DMA_TO_DEVICE: |
| 3641 | ZFCP_LOG_FLAGS(3, "DMA_TO_DEVICE\n"); |
| 3642 | fsf_req->qtcb->bottom.io.data_direction = FSF_DATADIR_WRITE; |
| 3643 | sbtype = SBAL_FLAGS0_TYPE_WRITE; |
| 3644 | fcp_cmnd_iu->wddata = 1; |
| 3645 | break; |
| 3646 | case DMA_BIDIRECTIONAL: |
| 3647 | ZFCP_LOG_FLAGS(0, "DMA_BIDIRECTIONAL not supported\n"); |
| 3648 | default: |
| 3649 | /* |
| 3650 | * dummy, catch this condition earlier |
| 3651 | * in zfcp_scsi_queuecommand |
| 3652 | */ |
| 3653 | goto failed_scsi_cmnd; |
| 3654 | } |
| 3655 | |
| 3656 | /* set FC service class in QTCB (3 per default) */ |
| 3657 | fsf_req->qtcb->bottom.io.service_class = adapter->fc_service_class; |
| 3658 | |
| 3659 | /* set FCP_LUN in FCP_CMND IU in QTCB */ |
| 3660 | fcp_cmnd_iu->fcp_lun = unit->fcp_lun; |
| 3661 | |
| 3662 | mask = ZFCP_STATUS_UNIT_READONLY | ZFCP_STATUS_UNIT_SHARED; |
| 3663 | |
| 3664 | /* set task attributes in FCP_CMND IU in QTCB */ |
| 3665 | if (likely((scsi_cmnd->device->simple_tags) || |
| 3666 | (atomic_test_mask(mask, &unit->status)))) |
| 3667 | fcp_cmnd_iu->task_attribute = SIMPLE_Q; |
| 3668 | else |
| 3669 | fcp_cmnd_iu->task_attribute = UNTAGGED; |
| 3670 | |
| 3671 | /* set additional length of FCP_CDB in FCP_CMND IU in QTCB, if needed */ |
| 3672 | if (unlikely(scsi_cmnd->cmd_len > FCP_CDB_LENGTH)) { |
| 3673 | fcp_cmnd_iu->add_fcp_cdb_length |
| 3674 | = (scsi_cmnd->cmd_len - FCP_CDB_LENGTH) >> 2; |
| 3675 | ZFCP_LOG_TRACE("SCSI CDB length is 0x%x, " |
| 3676 | "additional FCP_CDB length is 0x%x " |
| 3677 | "(shifted right 2 bits)\n", |
| 3678 | scsi_cmnd->cmd_len, |
| 3679 | fcp_cmnd_iu->add_fcp_cdb_length); |
| 3680 | } |
| 3681 | /* |
| 3682 | * copy SCSI CDB (including additional length, if any) to |
| 3683 | * FCP_CDB in FCP_CMND IU in QTCB |
| 3684 | */ |
| 3685 | memcpy(fcp_cmnd_iu->fcp_cdb, scsi_cmnd->cmnd, scsi_cmnd->cmd_len); |
| 3686 | |
| 3687 | /* FCP CMND IU length in QTCB */ |
| 3688 | fsf_req->qtcb->bottom.io.fcp_cmnd_length = |
| 3689 | sizeof (struct fcp_cmnd_iu) + |
| 3690 | fcp_cmnd_iu->add_fcp_cdb_length + sizeof (fcp_dl_t); |
| 3691 | |
| 3692 | /* generate SBALEs from data buffer */ |
| 3693 | real_bytes = zfcp_qdio_sbals_from_scsicmnd(fsf_req, sbtype, scsi_cmnd); |
| 3694 | if (unlikely(real_bytes < 0)) { |
| 3695 | if (fsf_req->sbal_number < ZFCP_MAX_SBALS_PER_REQ) { |
| 3696 | ZFCP_LOG_DEBUG( |
| 3697 | "Data did not fit into available buffer(s), " |
| 3698 | "waiting for more...\n"); |
| 3699 | retval = -EIO; |
| 3700 | } else { |
| 3701 | ZFCP_LOG_NORMAL("error: No truncation implemented but " |
| 3702 | "required. Shutting down unit " |
| 3703 | "(adapter %s, port 0x%016Lx, " |
| 3704 | "unit 0x%016Lx)\n", |
| 3705 | zfcp_get_busid_by_unit(unit), |
| 3706 | unit->port->wwpn, |
| 3707 | unit->fcp_lun); |
| 3708 | zfcp_erp_unit_shutdown(unit, 0); |
| 3709 | retval = -EINVAL; |
| 3710 | } |
| 3711 | goto no_fit; |
| 3712 | } |
| 3713 | |
| 3714 | /* set length of FCP data length in FCP_CMND IU in QTCB */ |
| 3715 | zfcp_set_fcp_dl(fcp_cmnd_iu, real_bytes); |
| 3716 | |
| 3717 | ZFCP_LOG_DEBUG("Sending SCSI command:\n"); |
| 3718 | ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG, |
| 3719 | (char *) scsi_cmnd->cmnd, scsi_cmnd->cmd_len); |
| 3720 | |
| 3721 | /* |
| 3722 | * start QDIO request for this FSF request |
| 3723 | * covered by an SBALE) |
| 3724 | */ |
| 3725 | retval = zfcp_fsf_req_send(fsf_req, timer); |
| 3726 | if (unlikely(retval < 0)) { |
| 3727 | ZFCP_LOG_INFO("error: Could not send FCP command request " |
| 3728 | "on adapter %s, port 0x%016Lx, unit 0x%016Lx\n", |
| 3729 | zfcp_get_busid_by_adapter(adapter), |
| 3730 | unit->port->wwpn, |
| 3731 | unit->fcp_lun); |
| 3732 | goto send_failed; |
| 3733 | } |
| 3734 | |
| 3735 | ZFCP_LOG_TRACE("Send FCP Command initiated (adapter %s, " |
| 3736 | "port 0x%016Lx, unit 0x%016Lx)\n", |
| 3737 | zfcp_get_busid_by_adapter(adapter), |
| 3738 | unit->port->wwpn, |
| 3739 | unit->fcp_lun); |
| 3740 | goto success; |
| 3741 | |
| 3742 | send_failed: |
| 3743 | no_fit: |
| 3744 | failed_scsi_cmnd: |
| 3745 | zfcp_fsf_req_free(fsf_req); |
| 3746 | fsf_req = NULL; |
| 3747 | scsi_cmnd->host_scribble = NULL; |
| 3748 | success: |
| 3749 | failed_req_create: |
| 3750 | write_unlock_irqrestore(&adapter->request_queue.queue_lock, lock_flags); |
| 3751 | return retval; |
| 3752 | } |
| 3753 | |
| 3754 | /* |
| 3755 | * function: zfcp_fsf_send_fcp_command_task_management |
| 3756 | * |
| 3757 | * purpose: |
| 3758 | * |
| 3759 | * returns: |
| 3760 | * |
| 3761 | * FIXME(design): should be watched by a timeout!!! |
| 3762 | * FIXME(design) shouldn't this be modified to return an int |
| 3763 | * also...don't know how though |
| 3764 | * |
| 3765 | */ |
| 3766 | struct zfcp_fsf_req * |
| 3767 | zfcp_fsf_send_fcp_command_task_management(struct zfcp_adapter *adapter, |
| 3768 | struct zfcp_unit *unit, |
| 3769 | u8 tm_flags, int req_flags) |
| 3770 | { |
| 3771 | struct zfcp_fsf_req *fsf_req = NULL; |
| 3772 | int retval = 0; |
| 3773 | struct fcp_cmnd_iu *fcp_cmnd_iu; |
| 3774 | unsigned long lock_flags; |
| 3775 | volatile struct qdio_buffer_element *sbale; |
| 3776 | |
| 3777 | /* setup new FSF request */ |
| 3778 | retval = zfcp_fsf_req_create(adapter, FSF_QTCB_FCP_CMND, req_flags, |
| 3779 | adapter->pool.fsf_req_scsi, |
| 3780 | &lock_flags, &fsf_req); |
| 3781 | if (retval < 0) { |
| 3782 | ZFCP_LOG_INFO("error: Could not create FCP command (task " |
| 3783 | "management) request for adapter %s, port " |
| 3784 | " 0x%016Lx, unit 0x%016Lx.\n", |
| 3785 | zfcp_get_busid_by_adapter(adapter), |
| 3786 | unit->port->wwpn, unit->fcp_lun); |
| 3787 | goto out; |
| 3788 | } |
| 3789 | |
| 3790 | /* |
| 3791 | * Used to decide on proper handler in the return path, |
| 3792 | * could be either zfcp_fsf_send_fcp_command_task_handler or |
| 3793 | * zfcp_fsf_send_fcp_command_task_management_handler */ |
| 3794 | |
| 3795 | fsf_req->status |= ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT; |
| 3796 | |
| 3797 | /* |
| 3798 | * hold a pointer to the unit being target of this |
| 3799 | * task management request |
| 3800 | */ |
| 3801 | fsf_req->data.send_fcp_command_task_management.unit = unit; |
| 3802 | |
| 3803 | /* set FSF related fields in QTCB */ |
| 3804 | fsf_req->qtcb->header.lun_handle = unit->handle; |
| 3805 | fsf_req->qtcb->header.port_handle = unit->port->handle; |
| 3806 | fsf_req->qtcb->bottom.io.data_direction = FSF_DATADIR_CMND; |
| 3807 | fsf_req->qtcb->bottom.io.service_class = adapter->fc_service_class; |
| 3808 | fsf_req->qtcb->bottom.io.fcp_cmnd_length = |
| 3809 | sizeof (struct fcp_cmnd_iu) + sizeof (fcp_dl_t); |
| 3810 | |
| 3811 | sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0); |
| 3812 | sbale[0].flags |= SBAL_FLAGS0_TYPE_WRITE; |
| 3813 | sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY; |
| 3814 | |
| 3815 | /* set FCP related fields in FCP_CMND IU in QTCB */ |
| 3816 | fcp_cmnd_iu = (struct fcp_cmnd_iu *) |
| 3817 | &(fsf_req->qtcb->bottom.io.fcp_cmnd); |
| 3818 | fcp_cmnd_iu->fcp_lun = unit->fcp_lun; |
| 3819 | fcp_cmnd_iu->task_management_flags = tm_flags; |
| 3820 | |
| 3821 | /* start QDIO request for this FSF request */ |
| 3822 | zfcp_fsf_start_scsi_er_timer(adapter); |
| 3823 | retval = zfcp_fsf_req_send(fsf_req, NULL); |
| 3824 | if (retval) { |
| 3825 | del_timer(&adapter->scsi_er_timer); |
| 3826 | ZFCP_LOG_INFO("error: Could not send an FCP-command (task " |
| 3827 | "management) on adapter %s, port 0x%016Lx for " |
| 3828 | "unit LUN 0x%016Lx\n", |
| 3829 | zfcp_get_busid_by_adapter(adapter), |
| 3830 | unit->port->wwpn, |
| 3831 | unit->fcp_lun); |
| 3832 | zfcp_fsf_req_free(fsf_req); |
| 3833 | fsf_req = NULL; |
| 3834 | goto out; |
| 3835 | } |
| 3836 | |
| 3837 | ZFCP_LOG_TRACE("Send FCP Command (task management function) initiated " |
| 3838 | "(adapter %s, port 0x%016Lx, unit 0x%016Lx, " |
| 3839 | "tm_flags=0x%x)\n", |
| 3840 | zfcp_get_busid_by_adapter(adapter), |
| 3841 | unit->port->wwpn, |
| 3842 | unit->fcp_lun, |
| 3843 | tm_flags); |
| 3844 | out: |
| 3845 | write_unlock_irqrestore(&adapter->request_queue.queue_lock, lock_flags); |
| 3846 | return fsf_req; |
| 3847 | } |
| 3848 | |
| 3849 | /* |
| 3850 | * function: zfcp_fsf_send_fcp_command_handler |
| 3851 | * |
| 3852 | * purpose: is called for finished Send FCP Command |
| 3853 | * |
| 3854 | * returns: |
| 3855 | */ |
| 3856 | static int |
| 3857 | zfcp_fsf_send_fcp_command_handler(struct zfcp_fsf_req *fsf_req) |
| 3858 | { |
| 3859 | int retval = -EINVAL; |
| 3860 | struct zfcp_unit *unit; |
| 3861 | struct fsf_qtcb_header *header; |
| 3862 | u16 subtable, rule, counter; |
| 3863 | |
| 3864 | header = &fsf_req->qtcb->header; |
| 3865 | |
| 3866 | if (unlikely(fsf_req->status & ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT)) |
| 3867 | unit = fsf_req->data.send_fcp_command_task_management.unit; |
| 3868 | else |
| 3869 | unit = fsf_req->data.send_fcp_command_task.unit; |
| 3870 | |
| 3871 | if (unlikely(fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR)) { |
| 3872 | /* go directly to calls of special handlers */ |
| 3873 | goto skip_fsfstatus; |
| 3874 | } |
| 3875 | |
| 3876 | /* evaluate FSF status in QTCB */ |
| 3877 | switch (header->fsf_status) { |
| 3878 | |
| 3879 | case FSF_PORT_HANDLE_NOT_VALID: |
| 3880 | ZFCP_LOG_FLAGS(1, "FSF_PORT_HANDLE_NOT_VALID\n"); |
| 3881 | ZFCP_LOG_INFO("Temporary port identifier 0x%x for port " |
| 3882 | "0x%016Lx on adapter %s invalid\n", |
| 3883 | unit->port->handle, |
| 3884 | unit->port->wwpn, zfcp_get_busid_by_unit(unit)); |
| 3885 | ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG, |
| 3886 | (char *) &header->fsf_status_qual, |
| 3887 | sizeof (union fsf_status_qual)); |
| 3888 | debug_text_event(fsf_req->adapter->erp_dbf, 1, |
| 3889 | "fsf_s_phand_nv"); |
| 3890 | zfcp_erp_adapter_reopen(unit->port->adapter, 0); |
| 3891 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 3892 | break; |
| 3893 | |
| 3894 | case FSF_LUN_HANDLE_NOT_VALID: |
| 3895 | ZFCP_LOG_FLAGS(1, "FSF_LUN_HANDLE_NOT_VALID\n"); |
| 3896 | ZFCP_LOG_INFO("Temporary LUN identifier 0x%x for unit " |
| 3897 | "0x%016Lx on port 0x%016Lx on adapter %s is " |
| 3898 | "invalid. This may happen occasionally.\n", |
| 3899 | unit->handle, |
| 3900 | unit->fcp_lun, |
| 3901 | unit->port->wwpn, |
| 3902 | zfcp_get_busid_by_unit(unit)); |
| 3903 | ZFCP_LOG_NORMAL("Status qualifier data:\n"); |
| 3904 | ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_NORMAL, |
| 3905 | (char *) &header->fsf_status_qual, |
| 3906 | sizeof (union fsf_status_qual)); |
| 3907 | debug_text_event(fsf_req->adapter->erp_dbf, 1, |
| 3908 | "fsf_s_uhand_nv"); |
| 3909 | zfcp_erp_port_reopen(unit->port, 0); |
| 3910 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 3911 | break; |
| 3912 | |
| 3913 | case FSF_HANDLE_MISMATCH: |
| 3914 | ZFCP_LOG_FLAGS(0, "FSF_HANDLE_MISMATCH\n"); |
| 3915 | ZFCP_LOG_NORMAL("bug: The port handle 0x%x has changed " |
| 3916 | "unexpectedly. (adapter %s, port 0x%016Lx, " |
| 3917 | "unit 0x%016Lx)\n", |
| 3918 | unit->port->handle, |
| 3919 | zfcp_get_busid_by_unit(unit), |
| 3920 | unit->port->wwpn, |
| 3921 | unit->fcp_lun); |
| 3922 | ZFCP_LOG_NORMAL("status qualifier:\n"); |
| 3923 | ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_NORMAL, |
| 3924 | (char *) &header->fsf_status_qual, |
| 3925 | sizeof (union fsf_status_qual)); |
| 3926 | debug_text_event(fsf_req->adapter->erp_dbf, 1, |
| 3927 | "fsf_s_hand_mis"); |
| 3928 | zfcp_erp_adapter_reopen(unit->port->adapter, 0); |
| 3929 | zfcp_cmd_dbf_event_fsf("handmism", |
| 3930 | fsf_req, |
| 3931 | &header->fsf_status_qual, |
| 3932 | sizeof (union fsf_status_qual)); |
| 3933 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 3934 | break; |
| 3935 | |
| 3936 | case FSF_SERVICE_CLASS_NOT_SUPPORTED: |
| 3937 | ZFCP_LOG_FLAGS(0, "FSF_SERVICE_CLASS_NOT_SUPPORTED\n"); |
| 3938 | if (fsf_req->adapter->fc_service_class <= 3) { |
| 3939 | ZFCP_LOG_NORMAL("error: The adapter %s does " |
| 3940 | "not support fibrechannel class %d.\n", |
| 3941 | zfcp_get_busid_by_unit(unit), |
| 3942 | fsf_req->adapter->fc_service_class); |
| 3943 | } else { |
| 3944 | ZFCP_LOG_NORMAL("bug: The fibrechannel class at " |
| 3945 | "adapter %s is invalid. " |
| 3946 | "(debug info %d)\n", |
| 3947 | zfcp_get_busid_by_unit(unit), |
| 3948 | fsf_req->adapter->fc_service_class); |
| 3949 | } |
| 3950 | /* stop operation for this adapter */ |
| 3951 | debug_text_exception(fsf_req->adapter->erp_dbf, 0, |
| 3952 | "fsf_s_class_nsup"); |
| 3953 | zfcp_erp_adapter_shutdown(unit->port->adapter, 0); |
| 3954 | zfcp_cmd_dbf_event_fsf("unsclass", |
| 3955 | fsf_req, |
| 3956 | &header->fsf_status_qual, |
| 3957 | sizeof (union fsf_status_qual)); |
| 3958 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 3959 | break; |
| 3960 | |
| 3961 | case FSF_FCPLUN_NOT_VALID: |
| 3962 | ZFCP_LOG_FLAGS(0, "FSF_FCPLUN_NOT_VALID\n"); |
| 3963 | ZFCP_LOG_NORMAL("bug: unit 0x%016Lx on port 0x%016Lx on " |
| 3964 | "adapter %s does not have correct unit " |
| 3965 | "handle 0x%x\n", |
| 3966 | unit->fcp_lun, |
| 3967 | unit->port->wwpn, |
| 3968 | zfcp_get_busid_by_unit(unit), |
| 3969 | unit->handle); |
| 3970 | ZFCP_LOG_DEBUG("status qualifier:\n"); |
| 3971 | ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG, |
| 3972 | (char *) &header->fsf_status_qual, |
| 3973 | sizeof (union fsf_status_qual)); |
| 3974 | debug_text_event(fsf_req->adapter->erp_dbf, 1, |
| 3975 | "fsf_s_fcp_lun_nv"); |
| 3976 | zfcp_erp_port_reopen(unit->port, 0); |
| 3977 | zfcp_cmd_dbf_event_fsf("fluninv", |
| 3978 | fsf_req, |
| 3979 | &header->fsf_status_qual, |
| 3980 | sizeof (union fsf_status_qual)); |
| 3981 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 3982 | break; |
| 3983 | |
| 3984 | case FSF_ACCESS_DENIED: |
| 3985 | ZFCP_LOG_FLAGS(2, "FSF_ACCESS_DENIED\n"); |
| 3986 | ZFCP_LOG_NORMAL("Access denied, cannot send FCP command to " |
| 3987 | "unit 0x%016Lx on port 0x%016Lx on " |
| 3988 | "adapter %s\n", unit->fcp_lun, unit->port->wwpn, |
| 3989 | zfcp_get_busid_by_unit(unit)); |
| 3990 | for (counter = 0; counter < 2; counter++) { |
| 3991 | subtable = header->fsf_status_qual.halfword[counter * 2]; |
| 3992 | rule = header->fsf_status_qual.halfword[counter * 2 + 1]; |
| 3993 | switch (subtable) { |
| 3994 | case FSF_SQ_CFDC_SUBTABLE_OS: |
| 3995 | case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN: |
| 3996 | case FSF_SQ_CFDC_SUBTABLE_PORT_DID: |
| 3997 | case FSF_SQ_CFDC_SUBTABLE_LUN: |
| 3998 | ZFCP_LOG_INFO("Access denied (%s rule %d)\n", |
| 3999 | zfcp_act_subtable_type[subtable], rule); |
| 4000 | break; |
| 4001 | } |
| 4002 | } |
| 4003 | debug_text_event(fsf_req->adapter->erp_dbf, 1, "fsf_s_access"); |
| 4004 | zfcp_erp_unit_access_denied(unit); |
| 4005 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 4006 | break; |
| 4007 | |
| 4008 | case FSF_DIRECTION_INDICATOR_NOT_VALID: |
| 4009 | ZFCP_LOG_FLAGS(0, "FSF_DIRECTION_INDICATOR_NOT_VALID\n"); |
| 4010 | ZFCP_LOG_INFO("bug: Invalid data direction given for unit " |
| 4011 | "0x%016Lx on port 0x%016Lx on adapter %s " |
| 4012 | "(debug info %d)\n", |
| 4013 | unit->fcp_lun, |
| 4014 | unit->port->wwpn, |
| 4015 | zfcp_get_busid_by_unit(unit), |
| 4016 | fsf_req->qtcb->bottom.io.data_direction); |
| 4017 | /* stop operation for this adapter */ |
| 4018 | debug_text_event(fsf_req->adapter->erp_dbf, 0, |
| 4019 | "fsf_s_dir_ind_nv"); |
| 4020 | zfcp_erp_adapter_shutdown(unit->port->adapter, 0); |
| 4021 | zfcp_cmd_dbf_event_fsf("dirinv", |
| 4022 | fsf_req, |
| 4023 | &header->fsf_status_qual, |
| 4024 | sizeof (union fsf_status_qual)); |
| 4025 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 4026 | break; |
| 4027 | |
| 4028 | case FSF_CMND_LENGTH_NOT_VALID: |
| 4029 | ZFCP_LOG_FLAGS(0, "FSF_CMND_LENGTH_NOT_VALID\n"); |
| 4030 | ZFCP_LOG_NORMAL |
| 4031 | ("bug: An invalid control-data-block length field " |
| 4032 | "was found in a command for unit 0x%016Lx on port " |
| 4033 | "0x%016Lx on adapter %s " "(debug info %d)\n", |
| 4034 | unit->fcp_lun, unit->port->wwpn, |
| 4035 | zfcp_get_busid_by_unit(unit), |
| 4036 | fsf_req->qtcb->bottom.io.fcp_cmnd_length); |
| 4037 | /* stop operation for this adapter */ |
| 4038 | debug_text_event(fsf_req->adapter->erp_dbf, 0, |
| 4039 | "fsf_s_cmd_len_nv"); |
| 4040 | zfcp_erp_adapter_shutdown(unit->port->adapter, 0); |
| 4041 | zfcp_cmd_dbf_event_fsf("cleninv", |
| 4042 | fsf_req, |
| 4043 | &header->fsf_status_qual, |
| 4044 | sizeof (union fsf_status_qual)); |
| 4045 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 4046 | break; |
| 4047 | |
| 4048 | case FSF_PORT_BOXED: |
| 4049 | ZFCP_LOG_FLAGS(2, "FSF_PORT_BOXED\n"); |
| 4050 | ZFCP_LOG_DEBUG("The remote port 0x%016Lx on adapter %s " |
| 4051 | "needs to be reopened\n", |
| 4052 | unit->port->wwpn, zfcp_get_busid_by_unit(unit)); |
| 4053 | debug_text_event(fsf_req->adapter->erp_dbf, 2, "fsf_s_pboxed"); |
| 4054 | zfcp_erp_port_reopen(unit->port, 0); |
| 4055 | zfcp_cmd_dbf_event_fsf("portbox", fsf_req, |
| 4056 | &header->fsf_status_qual, |
| 4057 | sizeof (union fsf_status_qual)); |
| 4058 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR | |
| 4059 | ZFCP_STATUS_FSFREQ_RETRY; |
| 4060 | break; |
| 4061 | |
| 4062 | case FSF_LUN_BOXED: |
| 4063 | ZFCP_LOG_FLAGS(0, "FSF_LUN_BOXED\n"); |
| 4064 | ZFCP_LOG_NORMAL("unit needs to be reopened (adapter %s, " |
| 4065 | "wwpn=0x%016Lx, fcp_lun=0x%016Lx)\n", |
| 4066 | zfcp_get_busid_by_unit(unit), |
| 4067 | unit->port->wwpn, unit->fcp_lun); |
| 4068 | debug_text_event(fsf_req->adapter->erp_dbf, 1, "fsf_s_lboxed"); |
| 4069 | zfcp_erp_unit_reopen(unit, 0); |
| 4070 | zfcp_cmd_dbf_event_fsf("unitbox", fsf_req, |
| 4071 | &header->fsf_status_qual, |
| 4072 | sizeof(union fsf_status_qual)); |
| 4073 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR |
| 4074 | | ZFCP_STATUS_FSFREQ_RETRY; |
| 4075 | break; |
| 4076 | |
| 4077 | case FSF_ADAPTER_STATUS_AVAILABLE: |
| 4078 | ZFCP_LOG_FLAGS(2, "FSF_ADAPTER_STATUS_AVAILABLE\n"); |
| 4079 | switch (header->fsf_status_qual.word[0]) { |
| 4080 | case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE: |
| 4081 | ZFCP_LOG_FLAGS(2, |
| 4082 | "FSF_SQ_INVOKE_LINK_TEST_PROCEDURE\n"); |
| 4083 | /* re-establish link to port */ |
| 4084 | debug_text_event(fsf_req->adapter->erp_dbf, 1, |
| 4085 | "fsf_sq_ltest"); |
| 4086 | zfcp_erp_port_reopen(unit->port, 0); |
| 4087 | zfcp_cmd_dbf_event_fsf( |
| 4088 | "sqltest", |
| 4089 | fsf_req, |
| 4090 | &header->fsf_status_qual, |
| 4091 | sizeof (union fsf_status_qual)); |
| 4092 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 4093 | break; |
| 4094 | case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED: |
| 4095 | ZFCP_LOG_FLAGS(3, |
| 4096 | "FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED\n"); |
| 4097 | /* FIXME(hw) need proper specs for proper action */ |
| 4098 | /* let scsi stack deal with retries and escalation */ |
| 4099 | debug_text_event(fsf_req->adapter->erp_dbf, 1, |
| 4100 | "fsf_sq_ulp"); |
| 4101 | zfcp_cmd_dbf_event_fsf( |
| 4102 | "sqdeperp", |
| 4103 | fsf_req, |
| 4104 | &header->fsf_status_qual, |
| 4105 | sizeof (union fsf_status_qual)); |
| 4106 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 4107 | break; |
| 4108 | default: |
| 4109 | /* FIXME: shall we consider this a successful transfer? */ |
| 4110 | ZFCP_LOG_NORMAL |
| 4111 | ("bug: Wrong status qualifier 0x%x arrived.\n", |
| 4112 | header->fsf_status_qual.word[0]); |
| 4113 | debug_text_event(fsf_req->adapter->erp_dbf, 0, |
| 4114 | "fsf_sq_inval:"); |
| 4115 | debug_exception(fsf_req->adapter->erp_dbf, 0, |
| 4116 | &header->fsf_status_qual.word[0], |
| 4117 | sizeof(u32)); |
| 4118 | break; |
| 4119 | } |
| 4120 | break; |
| 4121 | |
| 4122 | case FSF_GOOD: |
| 4123 | ZFCP_LOG_FLAGS(3, "FSF_GOOD\n"); |
| 4124 | break; |
| 4125 | |
| 4126 | case FSF_FCP_RSP_AVAILABLE: |
| 4127 | ZFCP_LOG_FLAGS(2, "FSF_FCP_RSP_AVAILABLE\n"); |
| 4128 | break; |
| 4129 | |
| 4130 | default: |
| 4131 | debug_text_event(fsf_req->adapter->erp_dbf, 0, "fsf_s_inval:"); |
| 4132 | debug_exception(fsf_req->adapter->erp_dbf, 0, |
| 4133 | &header->fsf_status, sizeof(u32)); |
| 4134 | break; |
| 4135 | } |
| 4136 | |
| 4137 | skip_fsfstatus: |
| 4138 | if (fsf_req->status & ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT) { |
| 4139 | retval = |
| 4140 | zfcp_fsf_send_fcp_command_task_management_handler(fsf_req); |
| 4141 | } else { |
| 4142 | retval = zfcp_fsf_send_fcp_command_task_handler(fsf_req); |
| 4143 | } |
| 4144 | return retval; |
| 4145 | } |
| 4146 | |
| 4147 | /* |
| 4148 | * function: zfcp_fsf_send_fcp_command_task_handler |
| 4149 | * |
| 4150 | * purpose: evaluates FCP_RSP IU |
| 4151 | * |
| 4152 | * returns: |
| 4153 | */ |
| 4154 | static int |
| 4155 | zfcp_fsf_send_fcp_command_task_handler(struct zfcp_fsf_req *fsf_req) |
| 4156 | { |
| 4157 | int retval = 0; |
| 4158 | struct scsi_cmnd *scpnt; |
| 4159 | struct fcp_rsp_iu *fcp_rsp_iu = (struct fcp_rsp_iu *) |
| 4160 | &(fsf_req->qtcb->bottom.io.fcp_rsp); |
| 4161 | struct fcp_cmnd_iu *fcp_cmnd_iu = (struct fcp_cmnd_iu *) |
| 4162 | &(fsf_req->qtcb->bottom.io.fcp_cmnd); |
| 4163 | u32 sns_len; |
| 4164 | char *fcp_rsp_info = zfcp_get_fcp_rsp_info_ptr(fcp_rsp_iu); |
| 4165 | unsigned long flags; |
| 4166 | struct zfcp_unit *unit = fsf_req->data.send_fcp_command_task.unit; |
| 4167 | |
| 4168 | read_lock_irqsave(&fsf_req->adapter->abort_lock, flags); |
| 4169 | scpnt = fsf_req->data.send_fcp_command_task.scsi_cmnd; |
| 4170 | if (unlikely(!scpnt)) { |
| 4171 | ZFCP_LOG_DEBUG |
| 4172 | ("Command with fsf_req %p is not associated to " |
| 4173 | "a scsi command anymore. Aborted?\n", fsf_req); |
| 4174 | goto out; |
| 4175 | } |
| 4176 | if (unlikely(fsf_req->status & ZFCP_STATUS_FSFREQ_ABORTED)) { |
| 4177 | /* FIXME: (design) mid-layer should handle DID_ABORT like |
| 4178 | * DID_SOFT_ERROR by retrying the request for devices |
| 4179 | * that allow retries. |
| 4180 | */ |
| 4181 | ZFCP_LOG_DEBUG("Setting DID_SOFT_ERROR and SUGGEST_RETRY\n"); |
| 4182 | set_host_byte(&scpnt->result, DID_SOFT_ERROR); |
| 4183 | set_driver_byte(&scpnt->result, SUGGEST_RETRY); |
| 4184 | goto skip_fsfstatus; |
| 4185 | } |
| 4186 | |
| 4187 | if (unlikely(fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR)) { |
| 4188 | ZFCP_LOG_DEBUG("Setting DID_ERROR\n"); |
| 4189 | set_host_byte(&scpnt->result, DID_ERROR); |
| 4190 | goto skip_fsfstatus; |
| 4191 | } |
| 4192 | |
| 4193 | /* set message byte of result in SCSI command */ |
| 4194 | scpnt->result |= COMMAND_COMPLETE << 8; |
| 4195 | |
| 4196 | /* |
| 4197 | * copy SCSI status code of FCP_STATUS of FCP_RSP IU to status byte |
| 4198 | * of result in SCSI command |
| 4199 | */ |
| 4200 | scpnt->result |= fcp_rsp_iu->scsi_status; |
| 4201 | if (unlikely(fcp_rsp_iu->scsi_status)) { |
| 4202 | /* DEBUG */ |
| 4203 | ZFCP_LOG_DEBUG("status for SCSI Command:\n"); |
| 4204 | ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG, |
| 4205 | scpnt->cmnd, scpnt->cmd_len); |
| 4206 | ZFCP_LOG_DEBUG("SCSI status code 0x%x\n", |
| 4207 | fcp_rsp_iu->scsi_status); |
| 4208 | ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG, |
| 4209 | (void *) fcp_rsp_iu, sizeof (struct fcp_rsp_iu)); |
| 4210 | ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG, |
| 4211 | zfcp_get_fcp_sns_info_ptr(fcp_rsp_iu), |
| 4212 | fcp_rsp_iu->fcp_sns_len); |
| 4213 | } |
| 4214 | |
| 4215 | /* check FCP_RSP_INFO */ |
| 4216 | if (unlikely(fcp_rsp_iu->validity.bits.fcp_rsp_len_valid)) { |
| 4217 | ZFCP_LOG_DEBUG("rsp_len is valid\n"); |
| 4218 | switch (fcp_rsp_info[3]) { |
| 4219 | case RSP_CODE_GOOD: |
| 4220 | ZFCP_LOG_FLAGS(3, "RSP_CODE_GOOD\n"); |
| 4221 | /* ok, continue */ |
| 4222 | ZFCP_LOG_TRACE("no failure or Task Management " |
| 4223 | "Function complete\n"); |
| 4224 | set_host_byte(&scpnt->result, DID_OK); |
| 4225 | break; |
| 4226 | case RSP_CODE_LENGTH_MISMATCH: |
| 4227 | ZFCP_LOG_FLAGS(0, "RSP_CODE_LENGTH_MISMATCH\n"); |
| 4228 | /* hardware bug */ |
| 4229 | ZFCP_LOG_NORMAL("bug: FCP response code indictates " |
| 4230 | "that the fibrechannel protocol data " |
| 4231 | "length differs from the burst length. " |
| 4232 | "The problem occured on unit 0x%016Lx " |
| 4233 | "on port 0x%016Lx on adapter %s", |
| 4234 | unit->fcp_lun, |
| 4235 | unit->port->wwpn, |
| 4236 | zfcp_get_busid_by_unit(unit)); |
| 4237 | /* dump SCSI CDB as prepared by zfcp */ |
| 4238 | ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG, |
| 4239 | (char *) &fsf_req->qtcb-> |
| 4240 | bottom.io.fcp_cmnd, FSF_FCP_CMND_SIZE); |
| 4241 | zfcp_cmd_dbf_event_fsf("clenmis", fsf_req, NULL, 0); |
| 4242 | set_host_byte(&scpnt->result, DID_ERROR); |
| 4243 | goto skip_fsfstatus; |
| 4244 | case RSP_CODE_FIELD_INVALID: |
| 4245 | ZFCP_LOG_FLAGS(0, "RSP_CODE_FIELD_INVALID\n"); |
| 4246 | /* driver or hardware bug */ |
| 4247 | ZFCP_LOG_NORMAL("bug: FCP response code indictates " |
| 4248 | "that the fibrechannel protocol data " |
| 4249 | "fields were incorrectly set up. " |
| 4250 | "The problem occured on the unit " |
| 4251 | "0x%016Lx on port 0x%016Lx on " |
| 4252 | "adapter %s", |
| 4253 | unit->fcp_lun, |
| 4254 | unit->port->wwpn, |
| 4255 | zfcp_get_busid_by_unit(unit)); |
| 4256 | /* dump SCSI CDB as prepared by zfcp */ |
| 4257 | ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG, |
| 4258 | (char *) &fsf_req->qtcb-> |
| 4259 | bottom.io.fcp_cmnd, FSF_FCP_CMND_SIZE); |
| 4260 | set_host_byte(&scpnt->result, DID_ERROR); |
| 4261 | zfcp_cmd_dbf_event_fsf("codeinv", fsf_req, NULL, 0); |
| 4262 | goto skip_fsfstatus; |
| 4263 | case RSP_CODE_RO_MISMATCH: |
| 4264 | ZFCP_LOG_FLAGS(0, "RSP_CODE_RO_MISMATCH\n"); |
| 4265 | /* hardware bug */ |
| 4266 | ZFCP_LOG_NORMAL("bug: The FCP response code indicates " |
| 4267 | "that conflicting values for the " |
| 4268 | "fibrechannel payload offset from the " |
| 4269 | "header were found. " |
| 4270 | "The problem occured on unit 0x%016Lx " |
| 4271 | "on port 0x%016Lx on adapter %s.\n", |
| 4272 | unit->fcp_lun, |
| 4273 | unit->port->wwpn, |
| 4274 | zfcp_get_busid_by_unit(unit)); |
| 4275 | /* dump SCSI CDB as prepared by zfcp */ |
| 4276 | ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG, |
| 4277 | (char *) &fsf_req->qtcb-> |
| 4278 | bottom.io.fcp_cmnd, FSF_FCP_CMND_SIZE); |
| 4279 | zfcp_cmd_dbf_event_fsf("codemism", fsf_req, NULL, 0); |
| 4280 | set_host_byte(&scpnt->result, DID_ERROR); |
| 4281 | goto skip_fsfstatus; |
| 4282 | default: |
| 4283 | ZFCP_LOG_NORMAL("bug: An invalid FCP response " |
| 4284 | "code was detected for a command. " |
| 4285 | "The problem occured on the unit " |
| 4286 | "0x%016Lx on port 0x%016Lx on " |
| 4287 | "adapter %s (debug info 0x%x)\n", |
| 4288 | unit->fcp_lun, |
| 4289 | unit->port->wwpn, |
| 4290 | zfcp_get_busid_by_unit(unit), |
| 4291 | fcp_rsp_info[3]); |
| 4292 | /* dump SCSI CDB as prepared by zfcp */ |
| 4293 | ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG, |
| 4294 | (char *) &fsf_req->qtcb-> |
| 4295 | bottom.io.fcp_cmnd, FSF_FCP_CMND_SIZE); |
| 4296 | zfcp_cmd_dbf_event_fsf("undeffcp", fsf_req, NULL, 0); |
| 4297 | set_host_byte(&scpnt->result, DID_ERROR); |
| 6f71d9b | 2005-04-10 23:04:28 -0500 | [diff] [blame] | 4298 | goto skip_fsfstatus; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4299 | } |
| 4300 | } |
| 4301 | |
| 4302 | /* check for sense data */ |
| 4303 | if (unlikely(fcp_rsp_iu->validity.bits.fcp_sns_len_valid)) { |
| 4304 | sns_len = FSF_FCP_RSP_SIZE - |
| 4305 | sizeof (struct fcp_rsp_iu) + fcp_rsp_iu->fcp_rsp_len; |
| 4306 | ZFCP_LOG_TRACE("room for %i bytes sense data in QTCB\n", |
| 4307 | sns_len); |
| 4308 | sns_len = min(sns_len, (u32) SCSI_SENSE_BUFFERSIZE); |
| 4309 | ZFCP_LOG_TRACE("room for %i bytes sense data in SCSI command\n", |
| 4310 | SCSI_SENSE_BUFFERSIZE); |
| 4311 | sns_len = min(sns_len, fcp_rsp_iu->fcp_sns_len); |
| 4312 | ZFCP_LOG_TRACE("scpnt->result =0x%x, command was:\n", |
| 4313 | scpnt->result); |
| 4314 | ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_TRACE, |
| 4315 | (void *) &scpnt->cmnd, scpnt->cmd_len); |
| 4316 | |
| 4317 | ZFCP_LOG_TRACE("%i bytes sense data provided by FCP\n", |
| 4318 | fcp_rsp_iu->fcp_sns_len); |
| 4319 | memcpy(&scpnt->sense_buffer, |
| 4320 | zfcp_get_fcp_sns_info_ptr(fcp_rsp_iu), sns_len); |
| 4321 | ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_TRACE, |
| 4322 | (void *) &scpnt->sense_buffer, sns_len); |
| 4323 | } |
| 4324 | |
| 4325 | /* check for overrun */ |
| 4326 | if (unlikely(fcp_rsp_iu->validity.bits.fcp_resid_over)) { |
| 4327 | ZFCP_LOG_INFO("A data overrun was detected for a command. " |
| 4328 | "unit 0x%016Lx, port 0x%016Lx, adapter %s. " |
| 4329 | "The response data length is " |
| 4330 | "%d, the original length was %d.\n", |
| 4331 | unit->fcp_lun, |
| 4332 | unit->port->wwpn, |
| 4333 | zfcp_get_busid_by_unit(unit), |
| 4334 | fcp_rsp_iu->fcp_resid, |
| 4335 | (int) zfcp_get_fcp_dl(fcp_cmnd_iu)); |
| 4336 | } |
| 4337 | |
| 4338 | /* check for underrun */ |
| 4339 | if (unlikely(fcp_rsp_iu->validity.bits.fcp_resid_under)) { |
| 4340 | ZFCP_LOG_INFO("A data underrun was detected for a command. " |
| 4341 | "unit 0x%016Lx, port 0x%016Lx, adapter %s. " |
| 4342 | "The response data length is " |
| 4343 | "%d, the original length was %d.\n", |
| 4344 | unit->fcp_lun, |
| 4345 | unit->port->wwpn, |
| 4346 | zfcp_get_busid_by_unit(unit), |
| 4347 | fcp_rsp_iu->fcp_resid, |
| 4348 | (int) zfcp_get_fcp_dl(fcp_cmnd_iu)); |
| 4349 | |
| 4350 | scpnt->resid = fcp_rsp_iu->fcp_resid; |
| 4351 | if (scpnt->request_bufflen - scpnt->resid < scpnt->underflow) |
| 6f71d9b | 2005-04-10 23:04:28 -0500 | [diff] [blame] | 4352 | set_host_byte(&scpnt->result, DID_ERROR); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4353 | } |
| 4354 | |
| 4355 | skip_fsfstatus: |
| 4356 | ZFCP_LOG_DEBUG("scpnt->result =0x%x\n", scpnt->result); |
| 4357 | |
| 4358 | zfcp_cmd_dbf_event_scsi("response", scpnt); |
| 4359 | |
| 4360 | /* cleanup pointer (need this especially for abort) */ |
| 4361 | scpnt->host_scribble = NULL; |
| 4362 | |
| 4363 | /* |
| 4364 | * NOTE: |
| 4365 | * according to the outcome of a discussion on linux-scsi we |
| 4366 | * don't need to grab the io_request_lock here since we use |
| 4367 | * the new eh |
| 4368 | */ |
| 4369 | /* always call back */ |
| 4370 | |
| 4371 | (scpnt->scsi_done) (scpnt); |
| 4372 | |
| 4373 | /* |
| 4374 | * We must hold this lock until scsi_done has been called. |
| 4375 | * Otherwise we may call scsi_done after abort regarding this |
| 4376 | * command has completed. |
| 4377 | * Note: scsi_done must not block! |
| 4378 | */ |
| 4379 | out: |
| 4380 | read_unlock_irqrestore(&fsf_req->adapter->abort_lock, flags); |
| 4381 | return retval; |
| 4382 | } |
| 4383 | |
| 4384 | /* |
| 4385 | * function: zfcp_fsf_send_fcp_command_task_management_handler |
| 4386 | * |
| 4387 | * purpose: evaluates FCP_RSP IU |
| 4388 | * |
| 4389 | * returns: |
| 4390 | */ |
| 4391 | static int |
| 4392 | zfcp_fsf_send_fcp_command_task_management_handler(struct zfcp_fsf_req *fsf_req) |
| 4393 | { |
| 4394 | int retval = 0; |
| 4395 | struct fcp_rsp_iu *fcp_rsp_iu = (struct fcp_rsp_iu *) |
| 4396 | &(fsf_req->qtcb->bottom.io.fcp_rsp); |
| 4397 | char *fcp_rsp_info = zfcp_get_fcp_rsp_info_ptr(fcp_rsp_iu); |
| 4398 | struct zfcp_unit *unit = |
| 4399 | fsf_req->data.send_fcp_command_task_management.unit; |
| 4400 | |
| 4401 | del_timer(&fsf_req->adapter->scsi_er_timer); |
| 4402 | if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) { |
| 4403 | fsf_req->status |= ZFCP_STATUS_FSFREQ_TMFUNCFAILED; |
| 4404 | goto skip_fsfstatus; |
| 4405 | } |
| 4406 | |
| 4407 | /* check FCP_RSP_INFO */ |
| 4408 | switch (fcp_rsp_info[3]) { |
| 4409 | case RSP_CODE_GOOD: |
| 4410 | ZFCP_LOG_FLAGS(3, "RSP_CODE_GOOD\n"); |
| 4411 | /* ok, continue */ |
| 4412 | ZFCP_LOG_DEBUG("no failure or Task Management " |
| 4413 | "Function complete\n"); |
| 4414 | break; |
| 4415 | case RSP_CODE_TASKMAN_UNSUPP: |
| 4416 | ZFCP_LOG_FLAGS(0, "RSP_CODE_TASKMAN_UNSUPP\n"); |
| 4417 | ZFCP_LOG_NORMAL("bug: A reuested task management function " |
| 4418 | "is not supported on the target device " |
| 4419 | "unit 0x%016Lx, port 0x%016Lx, adapter %s\n ", |
| 4420 | unit->fcp_lun, |
| 4421 | unit->port->wwpn, |
| 4422 | zfcp_get_busid_by_unit(unit)); |
| 4423 | fsf_req->status |= ZFCP_STATUS_FSFREQ_TMFUNCNOTSUPP; |
| 4424 | break; |
| 4425 | case RSP_CODE_TASKMAN_FAILED: |
| 4426 | ZFCP_LOG_FLAGS(0, "RSP_CODE_TASKMAN_FAILED\n"); |
| 4427 | ZFCP_LOG_NORMAL("bug: A reuested task management function " |
| 4428 | "failed to complete successfully. " |
| 4429 | "unit 0x%016Lx, port 0x%016Lx, adapter %s.\n", |
| 4430 | unit->fcp_lun, |
| 4431 | unit->port->wwpn, |
| 4432 | zfcp_get_busid_by_unit(unit)); |
| 4433 | fsf_req->status |= ZFCP_STATUS_FSFREQ_TMFUNCFAILED; |
| 4434 | break; |
| 4435 | default: |
| 4436 | ZFCP_LOG_NORMAL("bug: An invalid FCP response " |
| 4437 | "code was detected for a command. " |
| 4438 | "unit 0x%016Lx, port 0x%016Lx, adapter %s " |
| 4439 | "(debug info 0x%x)\n", |
| 4440 | unit->fcp_lun, |
| 4441 | unit->port->wwpn, |
| 4442 | zfcp_get_busid_by_unit(unit), |
| 4443 | fcp_rsp_info[3]); |
| 4444 | fsf_req->status |= ZFCP_STATUS_FSFREQ_TMFUNCFAILED; |
| 4445 | } |
| 4446 | |
| 4447 | skip_fsfstatus: |
| 4448 | return retval; |
| 4449 | } |
| 4450 | |
| 4451 | |
| 4452 | /* |
| 4453 | * function: zfcp_fsf_control_file |
| 4454 | * |
| 4455 | * purpose: Initiator of the control file upload/download FSF requests |
| 4456 | * |
| 4457 | * returns: 0 - FSF request is successfuly created and queued |
| 4458 | * -EOPNOTSUPP - The FCP adapter does not have Control File support |
| 4459 | * -EINVAL - Invalid direction specified |
| 4460 | * -ENOMEM - Insufficient memory |
| 4461 | * -EPERM - Cannot create FSF request or place it in QDIO queue |
| 4462 | */ |
| 4463 | int |
| 4464 | zfcp_fsf_control_file(struct zfcp_adapter *adapter, |
| 4465 | struct zfcp_fsf_req **fsf_req_ptr, |
| 4466 | u32 fsf_command, |
| 4467 | u32 option, |
| 4468 | struct zfcp_sg_list *sg_list) |
| 4469 | { |
| 4470 | struct zfcp_fsf_req *fsf_req; |
| 4471 | struct fsf_qtcb_bottom_support *bottom; |
| 4472 | volatile struct qdio_buffer_element *sbale; |
| 4473 | struct timer_list *timer; |
| 4474 | unsigned long lock_flags; |
| 4475 | int req_flags = 0; |
| 4476 | int direction; |
| 4477 | int retval = 0; |
| 4478 | |
| 4479 | if (!(adapter->supported_features & FSF_FEATURE_CFDC)) { |
| 4480 | ZFCP_LOG_INFO("cfdc not supported (adapter %s)\n", |
| 4481 | zfcp_get_busid_by_adapter(adapter)); |
| 4482 | retval = -EOPNOTSUPP; |
| 4483 | goto out; |
| 4484 | } |
| 4485 | |
| 4486 | switch (fsf_command) { |
| 4487 | |
| 4488 | case FSF_QTCB_DOWNLOAD_CONTROL_FILE: |
| 4489 | direction = SBAL_FLAGS0_TYPE_WRITE; |
| 4490 | if ((option != FSF_CFDC_OPTION_FULL_ACCESS) && |
| 4491 | (option != FSF_CFDC_OPTION_RESTRICTED_ACCESS)) |
| 4492 | req_flags = ZFCP_WAIT_FOR_SBAL; |
| 4493 | break; |
| 4494 | |
| 4495 | case FSF_QTCB_UPLOAD_CONTROL_FILE: |
| 4496 | direction = SBAL_FLAGS0_TYPE_READ; |
| 4497 | break; |
| 4498 | |
| 4499 | default: |
| 4500 | ZFCP_LOG_INFO("Invalid FSF command code 0x%08x\n", fsf_command); |
| 4501 | retval = -EINVAL; |
| 4502 | goto out; |
| 4503 | } |
| 4504 | |
| 4505 | timer = kmalloc(sizeof(struct timer_list), GFP_KERNEL); |
| 4506 | if (!timer) { |
| 4507 | retval = -ENOMEM; |
| 4508 | goto out; |
| 4509 | } |
| 4510 | |
| 4511 | retval = zfcp_fsf_req_create(adapter, fsf_command, req_flags, |
| 4512 | NULL, &lock_flags, &fsf_req); |
| 4513 | if (retval < 0) { |
| 4514 | ZFCP_LOG_INFO("error: Could not create FSF request for the " |
| 4515 | "adapter %s\n", |
| 4516 | zfcp_get_busid_by_adapter(adapter)); |
| 4517 | retval = -EPERM; |
| 4518 | goto unlock_queue_lock; |
| 4519 | } |
| 4520 | |
| 4521 | sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0); |
| 4522 | sbale[0].flags |= direction; |
| 4523 | |
| 4524 | bottom = &fsf_req->qtcb->bottom.support; |
| 4525 | bottom->operation_subtype = FSF_CFDC_OPERATION_SUBTYPE; |
| 4526 | bottom->option = option; |
| 4527 | |
| 4528 | if (sg_list->count > 0) { |
| 4529 | int bytes; |
| 4530 | |
| 4531 | bytes = zfcp_qdio_sbals_from_sg(fsf_req, direction, |
| 4532 | sg_list->sg, sg_list->count, |
| 4533 | ZFCP_MAX_SBALS_PER_REQ); |
| 4534 | if (bytes != ZFCP_CFDC_MAX_CONTROL_FILE_SIZE) { |
| 4535 | ZFCP_LOG_INFO( |
| 4536 | "error: Could not create sufficient number of " |
| 4537 | "SBALS for an FSF request to the adapter %s\n", |
| 4538 | zfcp_get_busid_by_adapter(adapter)); |
| 4539 | retval = -ENOMEM; |
| 4540 | goto free_fsf_req; |
| 4541 | } |
| 4542 | } else |
| 4543 | sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY; |
| 4544 | |
| 4545 | init_timer(timer); |
| 4546 | timer->function = zfcp_fsf_request_timeout_handler; |
| 4547 | timer->data = (unsigned long) adapter; |
| 4548 | timer->expires = ZFCP_FSF_REQUEST_TIMEOUT; |
| 4549 | |
| 4550 | retval = zfcp_fsf_req_send(fsf_req, timer); |
| 4551 | if (retval < 0) { |
| 4552 | ZFCP_LOG_INFO("initiation of cfdc up/download failed" |
| 4553 | "(adapter %s)\n", |
| 4554 | zfcp_get_busid_by_adapter(adapter)); |
| 4555 | retval = -EPERM; |
| 4556 | goto free_fsf_req; |
| 4557 | } |
| 4558 | write_unlock_irqrestore(&adapter->request_queue.queue_lock, lock_flags); |
| 4559 | |
| 4560 | ZFCP_LOG_NORMAL("Control file %s FSF request has been sent to the " |
| 4561 | "adapter %s\n", |
| 4562 | fsf_command == FSF_QTCB_DOWNLOAD_CONTROL_FILE ? |
| 4563 | "download" : "upload", |
| 4564 | zfcp_get_busid_by_adapter(adapter)); |
| 4565 | |
| 4566 | wait_event(fsf_req->completion_wq, |
| 4567 | fsf_req->status & ZFCP_STATUS_FSFREQ_COMPLETED); |
| 4568 | |
| 4569 | *fsf_req_ptr = fsf_req; |
| 4570 | del_timer_sync(timer); |
| 4571 | goto free_timer; |
| 4572 | |
| 4573 | free_fsf_req: |
| 4574 | zfcp_fsf_req_free(fsf_req); |
| 4575 | unlock_queue_lock: |
| 4576 | write_unlock_irqrestore(&adapter->request_queue.queue_lock, lock_flags); |
| 4577 | free_timer: |
| 4578 | kfree(timer); |
| 4579 | out: |
| 4580 | return retval; |
| 4581 | } |
| 4582 | |
| 4583 | |
| 4584 | /* |
| 4585 | * function: zfcp_fsf_control_file_handler |
| 4586 | * |
| 4587 | * purpose: Handler of the control file upload/download FSF requests |
| 4588 | * |
| 4589 | * returns: 0 - FSF request successfuly processed |
| 4590 | * -EAGAIN - Operation has to be repeated because of a temporary problem |
| 4591 | * -EACCES - There is no permission to execute an operation |
| 4592 | * -EPERM - The control file is not in a right format |
| 4593 | * -EIO - There is a problem with the FCP adapter |
| 4594 | * -EINVAL - Invalid operation |
| 4595 | * -EFAULT - User space memory I/O operation fault |
| 4596 | */ |
| 4597 | static int |
| 4598 | zfcp_fsf_control_file_handler(struct zfcp_fsf_req *fsf_req) |
| 4599 | { |
| 4600 | struct zfcp_adapter *adapter = fsf_req->adapter; |
| 4601 | struct fsf_qtcb_header *header = &fsf_req->qtcb->header; |
| 4602 | struct fsf_qtcb_bottom_support *bottom = &fsf_req->qtcb->bottom.support; |
| 4603 | int retval = 0; |
| 4604 | |
| 4605 | if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) { |
| 4606 | retval = -EINVAL; |
| 4607 | goto skip_fsfstatus; |
| 4608 | } |
| 4609 | |
| 4610 | switch (header->fsf_status) { |
| 4611 | |
| 4612 | case FSF_GOOD: |
| 4613 | ZFCP_LOG_FLAGS(2, "FSF_GOOD\n"); |
| 4614 | ZFCP_LOG_NORMAL( |
| 4615 | "The FSF request has been successfully completed " |
| 4616 | "on the adapter %s\n", |
| 4617 | zfcp_get_busid_by_adapter(adapter)); |
| 4618 | break; |
| 4619 | |
| 4620 | case FSF_OPERATION_PARTIALLY_SUCCESSFUL: |
| 4621 | ZFCP_LOG_FLAGS(2, "FSF_OPERATION_PARTIALLY_SUCCESSFUL\n"); |
| 4622 | if (bottom->operation_subtype == FSF_CFDC_OPERATION_SUBTYPE) { |
| 4623 | switch (header->fsf_status_qual.word[0]) { |
| 4624 | |
| 6f71d9b | 2005-04-10 23:04:28 -0500 | [diff] [blame] | 4625 | case FSF_SQ_CFDC_HARDENED_ON_SE: |
| 4626 | ZFCP_LOG_NORMAL( |
| 4627 | "CFDC on the adapter %s has being " |
| 4628 | "hardened on primary and secondary SE\n", |
| 4629 | zfcp_get_busid_by_adapter(adapter)); |
| 4630 | break; |
| 4631 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4632 | case FSF_SQ_CFDC_COULD_NOT_HARDEN_ON_SE: |
| 4633 | ZFCP_LOG_NORMAL( |
| 4634 | "CFDC of the adapter %s could not " |
| 4635 | "be saved on the SE\n", |
| 4636 | zfcp_get_busid_by_adapter(adapter)); |
| 4637 | break; |
| 4638 | |
| 4639 | case FSF_SQ_CFDC_COULD_NOT_HARDEN_ON_SE2: |
| 4640 | ZFCP_LOG_NORMAL( |
| 4641 | "CFDC of the adapter %s could not " |
| 4642 | "be copied to the secondary SE\n", |
| 4643 | zfcp_get_busid_by_adapter(adapter)); |
| 4644 | break; |
| 4645 | |
| 4646 | default: |
| 4647 | ZFCP_LOG_NORMAL( |
| 4648 | "CFDC could not be hardened " |
| 4649 | "on the adapter %s\n", |
| 4650 | zfcp_get_busid_by_adapter(adapter)); |
| 4651 | } |
| 4652 | } |
| 4653 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 4654 | retval = -EAGAIN; |
| 4655 | break; |
| 4656 | |
| 4657 | case FSF_AUTHORIZATION_FAILURE: |
| 4658 | ZFCP_LOG_FLAGS(2, "FSF_AUTHORIZATION_FAILURE\n"); |
| 4659 | ZFCP_LOG_NORMAL( |
| 4660 | "Adapter %s does not accept privileged commands\n", |
| 4661 | zfcp_get_busid_by_adapter(adapter)); |
| 4662 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 4663 | retval = -EACCES; |
| 4664 | break; |
| 4665 | |
| 4666 | case FSF_CFDC_ERROR_DETECTED: |
| 4667 | ZFCP_LOG_FLAGS(2, "FSF_CFDC_ERROR_DETECTED\n"); |
| 4668 | ZFCP_LOG_NORMAL( |
| 4669 | "Error at position %d in the CFDC, " |
| 4670 | "CFDC is discarded by the adapter %s\n", |
| 4671 | header->fsf_status_qual.word[0], |
| 4672 | zfcp_get_busid_by_adapter(adapter)); |
| 4673 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 4674 | retval = -EPERM; |
| 4675 | break; |
| 4676 | |
| 4677 | case FSF_CONTROL_FILE_UPDATE_ERROR: |
| 4678 | ZFCP_LOG_FLAGS(2, "FSF_CONTROL_FILE_UPDATE_ERROR\n"); |
| 4679 | ZFCP_LOG_NORMAL( |
| 4680 | "Adapter %s cannot harden the control file, " |
| 4681 | "file is discarded\n", |
| 4682 | zfcp_get_busid_by_adapter(adapter)); |
| 4683 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 4684 | retval = -EIO; |
| 4685 | break; |
| 4686 | |
| 4687 | case FSF_CONTROL_FILE_TOO_LARGE: |
| 4688 | ZFCP_LOG_FLAGS(2, "FSF_CONTROL_FILE_TOO_LARGE\n"); |
| 4689 | ZFCP_LOG_NORMAL( |
| 4690 | "Control file is too large, file is discarded " |
| 4691 | "by the adapter %s\n", |
| 4692 | zfcp_get_busid_by_adapter(adapter)); |
| 4693 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 4694 | retval = -EIO; |
| 4695 | break; |
| 4696 | |
| 4697 | case FSF_ACCESS_CONFLICT_DETECTED: |
| 4698 | ZFCP_LOG_FLAGS(2, "FSF_ACCESS_CONFLICT_DETECTED\n"); |
| 4699 | if (bottom->operation_subtype == FSF_CFDC_OPERATION_SUBTYPE) |
| 4700 | ZFCP_LOG_NORMAL( |
| 4701 | "CFDC has been discarded by the adapter %s, " |
| 4702 | "because activation would impact " |
| 4703 | "%d active connection(s)\n", |
| 4704 | zfcp_get_busid_by_adapter(adapter), |
| 4705 | header->fsf_status_qual.word[0]); |
| 4706 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 4707 | retval = -EIO; |
| 4708 | break; |
| 4709 | |
| 4710 | case FSF_CONFLICTS_OVERRULED: |
| 4711 | ZFCP_LOG_FLAGS(2, "FSF_CONFLICTS_OVERRULED\n"); |
| 4712 | if (bottom->operation_subtype == FSF_CFDC_OPERATION_SUBTYPE) |
| 4713 | ZFCP_LOG_NORMAL( |
| 4714 | "CFDC has been activated on the adapter %s, " |
| 4715 | "but activation has impacted " |
| 4716 | "%d active connection(s)\n", |
| 4717 | zfcp_get_busid_by_adapter(adapter), |
| 4718 | header->fsf_status_qual.word[0]); |
| 4719 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 4720 | retval = -EIO; |
| 4721 | break; |
| 4722 | |
| 4723 | case FSF_UNKNOWN_OP_SUBTYPE: |
| 4724 | ZFCP_LOG_FLAGS(2, "FSF_UNKNOWN_OP_SUBTYPE\n"); |
| 4725 | ZFCP_LOG_NORMAL("unknown operation subtype (adapter: %s, " |
| 4726 | "op_subtype=0x%x)\n", |
| 4727 | zfcp_get_busid_by_adapter(adapter), |
| 4728 | bottom->operation_subtype); |
| 4729 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 4730 | retval = -EINVAL; |
| 4731 | break; |
| 4732 | |
| 4733 | case FSF_INVALID_COMMAND_OPTION: |
| 4734 | ZFCP_LOG_FLAGS(2, "FSF_INVALID_COMMAND_OPTION\n"); |
| 4735 | ZFCP_LOG_NORMAL( |
| 4736 | "Invalid option 0x%x has been specified " |
| 4737 | "in QTCB bottom sent to the adapter %s\n", |
| 4738 | bottom->option, |
| 4739 | zfcp_get_busid_by_adapter(adapter)); |
| 4740 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 4741 | retval = -EINVAL; |
| 4742 | break; |
| 4743 | |
| 4744 | default: |
| 4745 | ZFCP_LOG_NORMAL( |
| 4746 | "bug: An unknown/unexpected FSF status 0x%08x " |
| 4747 | "was presented on the adapter %s\n", |
| 4748 | header->fsf_status, |
| 4749 | zfcp_get_busid_by_adapter(adapter)); |
| 4750 | debug_text_event(fsf_req->adapter->erp_dbf, 0, "fsf_sq_inval"); |
| 4751 | debug_exception(fsf_req->adapter->erp_dbf, 0, |
| 4752 | &header->fsf_status_qual.word[0], sizeof(u32)); |
| 4753 | fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 4754 | retval = -EINVAL; |
| 4755 | break; |
| 4756 | } |
| 4757 | |
| 4758 | skip_fsfstatus: |
| 4759 | return retval; |
| 4760 | } |
| 4761 | |
| 4762 | |
| 4763 | /* |
| 4764 | * function: zfcp_fsf_req_wait_and_cleanup |
| 4765 | * |
| 4766 | * purpose: |
| 4767 | * |
| 4768 | * FIXME(design): signal seems to be <0 !!! |
| 4769 | * returns: 0 - request completed (*status is valid), cleanup succ. |
| 4770 | * <0 - request completed (*status is valid), cleanup failed |
| 4771 | * >0 - signal which interrupted waiting (*status invalid), |
| 4772 | * request not completed, no cleanup |
| 4773 | * |
| 4774 | * *status is a copy of status of completed fsf_req |
| 4775 | */ |
| 4776 | int |
| 4777 | zfcp_fsf_req_wait_and_cleanup(struct zfcp_fsf_req *fsf_req, |
| 4778 | int interruptible, u32 * status) |
| 4779 | { |
| 4780 | int retval = 0; |
| 4781 | int signal = 0; |
| 4782 | |
| 4783 | if (interruptible) { |
| 4784 | __wait_event_interruptible(fsf_req->completion_wq, |
| 4785 | fsf_req->status & |
| 4786 | ZFCP_STATUS_FSFREQ_COMPLETED, |
| 4787 | signal); |
| 4788 | if (signal) { |
| 4789 | ZFCP_LOG_DEBUG("Caught signal %i while waiting for the " |
| 4790 | "completion of the request at %p\n", |
| 4791 | signal, fsf_req); |
| 4792 | retval = signal; |
| 4793 | goto out; |
| 4794 | } |
| 4795 | } else { |
| 4796 | __wait_event(fsf_req->completion_wq, |
| 4797 | fsf_req->status & ZFCP_STATUS_FSFREQ_COMPLETED); |
| 4798 | } |
| 4799 | |
| 4800 | *status = fsf_req->status; |
| 4801 | |
| 4802 | /* cleanup request */ |
| 4803 | zfcp_fsf_req_cleanup(fsf_req); |
| 4804 | out: |
| 4805 | return retval; |
| 4806 | } |
| 4807 | |
| 4808 | static inline int |
| 4809 | zfcp_fsf_req_sbal_check(unsigned long *flags, |
| 4810 | struct zfcp_qdio_queue *queue, int needed) |
| 4811 | { |
| 4812 | write_lock_irqsave(&queue->queue_lock, *flags); |
| 4813 | if (likely(atomic_read(&queue->free_count) >= needed)) |
| 4814 | return 1; |
| 4815 | write_unlock_irqrestore(&queue->queue_lock, *flags); |
| 4816 | return 0; |
| 4817 | } |
| 4818 | |
| 4819 | /* |
| 4820 | * set qtcb pointer in fsf_req and initialize QTCB |
| 4821 | */ |
| 4822 | static inline void |
| 4823 | zfcp_fsf_req_qtcb_init(struct zfcp_fsf_req *fsf_req, u32 fsf_cmd) |
| 4824 | { |
| 4825 | if (likely(fsf_req->qtcb != NULL)) { |
| 4826 | fsf_req->qtcb->prefix.req_id = (unsigned long)fsf_req; |
| 4827 | fsf_req->qtcb->prefix.ulp_info = ZFCP_ULP_INFO_VERSION; |
| 4828 | fsf_req->qtcb->prefix.qtcb_type = fsf_qtcb_type[fsf_cmd]; |
| 4829 | fsf_req->qtcb->prefix.qtcb_version = ZFCP_QTCB_VERSION; |
| 4830 | fsf_req->qtcb->header.req_handle = (unsigned long)fsf_req; |
| 4831 | fsf_req->qtcb->header.fsf_command = fsf_cmd; |
| 4832 | } |
| 4833 | } |
| 4834 | |
| 4835 | /** |
| 4836 | * zfcp_fsf_req_sbal_get - try to get one SBAL in the request queue |
| 4837 | * @adapter: adapter for which request queue is examined |
| 4838 | * @req_flags: flags indicating whether to wait for needed SBAL or not |
| 4839 | * @lock_flags: lock_flags if queue_lock is taken |
| 4840 | * Return: 0 on success, otherwise -EIO, or -ERESTARTSYS |
| 4841 | * Locks: lock adapter->request_queue->queue_lock on success |
| 4842 | */ |
| 4843 | static int |
| 4844 | zfcp_fsf_req_sbal_get(struct zfcp_adapter *adapter, int req_flags, |
| 4845 | unsigned long *lock_flags) |
| 4846 | { |
| 4847 | long ret; |
| 4848 | struct zfcp_qdio_queue *req_queue = &adapter->request_queue; |
| 4849 | |
| 4850 | if (unlikely(req_flags & ZFCP_WAIT_FOR_SBAL)) { |
| 4851 | ret = wait_event_interruptible_timeout(adapter->request_wq, |
| 4852 | zfcp_fsf_req_sbal_check(lock_flags, req_queue, 1), |
| 4853 | ZFCP_SBAL_TIMEOUT); |
| 4854 | if (ret < 0) |
| 4855 | return ret; |
| 4856 | if (!ret) |
| 4857 | return -EIO; |
| 4858 | } else if (!zfcp_fsf_req_sbal_check(lock_flags, req_queue, 1)) |
| 4859 | return -EIO; |
| 4860 | |
| 4861 | return 0; |
| 4862 | } |
| 4863 | |
| 4864 | /* |
| 4865 | * function: zfcp_fsf_req_create |
| 4866 | * |
| 4867 | * purpose: create an FSF request at the specified adapter and |
| 4868 | * setup common fields |
| 4869 | * |
| 4870 | * returns: -ENOMEM if there was insufficient memory for a request |
| 4871 | * -EIO if no qdio buffers could be allocate to the request |
| 4872 | * -EINVAL/-EPERM on bug conditions in req_dequeue |
| 4873 | * 0 in success |
| 4874 | * |
| 4875 | * note: The created request is returned by reference. |
| 4876 | * |
| 4877 | * locks: lock of concerned request queue must not be held, |
| 4878 | * but is held on completion (write, irqsave) |
| 4879 | */ |
| 4880 | int |
| 4881 | zfcp_fsf_req_create(struct zfcp_adapter *adapter, u32 fsf_cmd, int req_flags, |
| 4882 | mempool_t *pool, unsigned long *lock_flags, |
| 4883 | struct zfcp_fsf_req **fsf_req_p) |
| 4884 | { |
| 4885 | volatile struct qdio_buffer_element *sbale; |
| 4886 | struct zfcp_fsf_req *fsf_req = NULL; |
| 4887 | int ret = 0; |
| 4888 | struct zfcp_qdio_queue *req_queue = &adapter->request_queue; |
| 4889 | |
| 4890 | /* allocate new FSF request */ |
| 4891 | fsf_req = zfcp_fsf_req_alloc(pool, req_flags); |
| 4892 | if (unlikely(NULL == fsf_req)) { |
| 4893 | ZFCP_LOG_DEBUG("error: Could not put an FSF request into" |
| 4894 | "the outbound (send) queue.\n"); |
| 4895 | ret = -ENOMEM; |
| 4896 | goto failed_fsf_req; |
| 4897 | } |
| 4898 | |
| 4899 | zfcp_fsf_req_qtcb_init(fsf_req, fsf_cmd); |
| 4900 | |
| 4901 | /* initialize waitqueue which may be used to wait on |
| 4902 | this request completion */ |
| 4903 | init_waitqueue_head(&fsf_req->completion_wq); |
| 4904 | |
| 4905 | ret = zfcp_fsf_req_sbal_get(adapter, req_flags, lock_flags); |
| 4906 | if(ret < 0) { |
| 4907 | goto failed_sbals; |
| 4908 | } |
| 4909 | |
| 4910 | /* |
| 4911 | * We hold queue_lock here. Check if QDIOUP is set and let request fail |
| 4912 | * if it is not set (see also *_open_qdio and *_close_qdio). |
| 4913 | */ |
| 4914 | |
| 4915 | if (!atomic_test_mask(ZFCP_STATUS_ADAPTER_QDIOUP, &adapter->status)) { |
| 4916 | write_unlock_irqrestore(&req_queue->queue_lock, *lock_flags); |
| 4917 | ret = -EIO; |
| 4918 | goto failed_sbals; |
| 4919 | } |
| 4920 | |
| 4921 | fsf_req->adapter = adapter; /* pointer to "parent" adapter */ |
| 4922 | fsf_req->fsf_command = fsf_cmd; |
| 4923 | fsf_req->sbal_number = 1; |
| 4924 | fsf_req->sbal_first = req_queue->free_index; |
| 4925 | fsf_req->sbal_curr = req_queue->free_index; |
| 4926 | fsf_req->sbale_curr = 1; |
| 4927 | |
| 4928 | if (likely(req_flags & ZFCP_REQ_AUTO_CLEANUP)) { |
| 4929 | fsf_req->status |= ZFCP_STATUS_FSFREQ_CLEANUP; |
| 4930 | } |
| 4931 | |
| 4932 | sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0); |
| 4933 | |
| 4934 | /* setup common SBALE fields */ |
| 4935 | sbale[0].addr = fsf_req; |
| 4936 | sbale[0].flags |= SBAL_FLAGS0_COMMAND; |
| 4937 | if (likely(fsf_req->qtcb != NULL)) { |
| 4938 | sbale[1].addr = (void *) fsf_req->qtcb; |
| 4939 | sbale[1].length = sizeof(struct fsf_qtcb); |
| 4940 | } |
| 4941 | |
| 4942 | ZFCP_LOG_TRACE("got %i free BUFFERs starting at index %i\n", |
| 4943 | fsf_req->sbal_number, fsf_req->sbal_first); |
| 4944 | |
| 4945 | goto success; |
| 4946 | |
| 4947 | failed_sbals: |
| 4948 | /* dequeue new FSF request previously enqueued */ |
| 4949 | zfcp_fsf_req_free(fsf_req); |
| 4950 | fsf_req = NULL; |
| 4951 | |
| 4952 | failed_fsf_req: |
| 4953 | write_lock_irqsave(&req_queue->queue_lock, *lock_flags); |
| 4954 | success: |
| 4955 | *fsf_req_p = fsf_req; |
| 4956 | return ret; |
| 4957 | } |
| 4958 | |
| 4959 | /* |
| 4960 | * function: zfcp_fsf_req_send |
| 4961 | * |
| 4962 | * purpose: start transfer of FSF request via QDIO |
| 4963 | * |
| 4964 | * returns: 0 - request transfer succesfully started |
| 4965 | * !0 - start of request transfer failed |
| 4966 | */ |
| 4967 | static int |
| 4968 | zfcp_fsf_req_send(struct zfcp_fsf_req *fsf_req, struct timer_list *timer) |
| 4969 | { |
| 4970 | struct zfcp_adapter *adapter; |
| 4971 | struct zfcp_qdio_queue *req_queue; |
| 4972 | volatile struct qdio_buffer_element *sbale; |
| 4973 | int new_distance_from_int; |
| 4974 | unsigned long flags; |
| 4975 | int inc_seq_no = 1; |
| 4976 | int retval = 0; |
| 4977 | |
| 4978 | adapter = fsf_req->adapter; |
| 4979 | req_queue = &adapter->request_queue, |
| 4980 | |
| 4981 | |
| 4982 | /* FIXME(debug): remove it later */ |
| 4983 | sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_first, 0); |
| 4984 | ZFCP_LOG_DEBUG("SBALE0 flags=0x%x\n", sbale[0].flags); |
| 4985 | ZFCP_LOG_TRACE("HEX DUMP OF SBALE1 PAYLOAD:\n"); |
| 4986 | ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_TRACE, (char *) sbale[1].addr, |
| 4987 | sbale[1].length); |
| 4988 | |
| 4989 | /* set sequence counter in QTCB */ |
| 4990 | if (likely(fsf_req->qtcb)) { |
| 4991 | fsf_req->qtcb->prefix.req_seq_no = adapter->fsf_req_seq_no; |
| 4992 | fsf_req->seq_no = adapter->fsf_req_seq_no; |
| 4993 | ZFCP_LOG_TRACE("FSF request %p of adapter %s gets " |
| 4994 | "FSF sequence counter value of %i\n", |
| 4995 | fsf_req, |
| 4996 | zfcp_get_busid_by_adapter(adapter), |
| 4997 | fsf_req->qtcb->prefix.req_seq_no); |
| 4998 | } else |
| 4999 | inc_seq_no = 0; |
| 5000 | |
| 5001 | /* put allocated FSF request at list tail */ |
| 5002 | write_lock_irqsave(&adapter->fsf_req_list_lock, flags); |
| 5003 | list_add_tail(&fsf_req->list, &adapter->fsf_req_list_head); |
| 5004 | write_unlock_irqrestore(&adapter->fsf_req_list_lock, flags); |
| 5005 | |
| 5006 | /* figure out expiration time of timeout and start timeout */ |
| 5007 | if (unlikely(timer)) { |
| 5008 | timer->expires += jiffies; |
| 5009 | add_timer(timer); |
| 5010 | } |
| 5011 | |
| 5012 | ZFCP_LOG_TRACE("request queue of adapter %s: " |
| 5013 | "next free SBAL is %i, %i free SBALs\n", |
| 5014 | zfcp_get_busid_by_adapter(adapter), |
| 5015 | req_queue->free_index, |
| 5016 | atomic_read(&req_queue->free_count)); |
| 5017 | |
| 5018 | ZFCP_LOG_DEBUG("calling do_QDIO adapter %s, flags=0x%x, queue_no=%i, " |
| 5019 | "index_in_queue=%i, count=%i, buffers=%p\n", |
| 5020 | zfcp_get_busid_by_adapter(adapter), |
| 5021 | QDIO_FLAG_SYNC_OUTPUT, |
| 5022 | 0, fsf_req->sbal_first, fsf_req->sbal_number, |
| 5023 | &req_queue->buffer[fsf_req->sbal_first]); |
| 5024 | |
| 5025 | /* |
| 5026 | * adjust the number of free SBALs in request queue as well as |
| 5027 | * position of first one |
| 5028 | */ |
| 5029 | atomic_sub(fsf_req->sbal_number, &req_queue->free_count); |
| 5030 | ZFCP_LOG_TRACE("free_count=%d\n", atomic_read(&req_queue->free_count)); |
| 5031 | req_queue->free_index += fsf_req->sbal_number; /* increase */ |
| 5032 | req_queue->free_index %= QDIO_MAX_BUFFERS_PER_Q; /* wrap if needed */ |
| 5033 | new_distance_from_int = zfcp_qdio_determine_pci(req_queue, fsf_req); |
| 5034 | |
| 5035 | retval = do_QDIO(adapter->ccw_device, |
| 5036 | QDIO_FLAG_SYNC_OUTPUT, |
| 5037 | 0, fsf_req->sbal_first, fsf_req->sbal_number, NULL); |
| 5038 | |
| 5039 | if (unlikely(retval)) { |
| 5040 | /* Queues are down..... */ |
| 5041 | retval = -EIO; |
| 5042 | /* |
| 5043 | * FIXME(potential race): |
| 5044 | * timer might be expired (absolutely unlikely) |
| 5045 | */ |
| 5046 | if (timer) |
| 5047 | del_timer(timer); |
| 5048 | write_lock_irqsave(&adapter->fsf_req_list_lock, flags); |
| 5049 | list_del(&fsf_req->list); |
| 5050 | write_unlock_irqrestore(&adapter->fsf_req_list_lock, flags); |
| 5051 | /* |
| 5052 | * adjust the number of free SBALs in request queue as well as |
| 5053 | * position of first one |
| 5054 | */ |
| 5055 | zfcp_qdio_zero_sbals(req_queue->buffer, |
| 5056 | fsf_req->sbal_first, fsf_req->sbal_number); |
| 5057 | atomic_add(fsf_req->sbal_number, &req_queue->free_count); |
| 5058 | req_queue->free_index -= fsf_req->sbal_number; /* increase */ |
| 5059 | req_queue->free_index += QDIO_MAX_BUFFERS_PER_Q; |
| 5060 | req_queue->free_index %= QDIO_MAX_BUFFERS_PER_Q; /* wrap */ |
| 5061 | ZFCP_LOG_DEBUG |
| 5062 | ("error: do_QDIO failed. Buffers could not be enqueued " |
| 5063 | "to request queue.\n"); |
| 5064 | } else { |
| 5065 | req_queue->distance_from_int = new_distance_from_int; |
| 5066 | /* |
| 5067 | * increase FSF sequence counter - |
| 5068 | * this must only be done for request successfully enqueued to |
| 5069 | * QDIO this rejected requests may be cleaned up by calling |
| 5070 | * routines resulting in missing sequence counter values |
| 5071 | * otherwise, |
| 5072 | */ |
| 5073 | /* Don't increase for unsolicited status */ |
| 5074 | if (likely(inc_seq_no)) { |
| 5075 | adapter->fsf_req_seq_no++; |
| 5076 | ZFCP_LOG_TRACE |
| 5077 | ("FSF sequence counter value of adapter %s " |
| 5078 | "increased to %i\n", |
| 5079 | zfcp_get_busid_by_adapter(adapter), |
| 5080 | adapter->fsf_req_seq_no); |
| 5081 | } |
| 5082 | /* count FSF requests pending */ |
| 5083 | atomic_inc(&adapter->fsf_reqs_active); |
| 5084 | } |
| 5085 | return retval; |
| 5086 | } |
| 5087 | |
| 5088 | /* |
| 5089 | * function: zfcp_fsf_req_cleanup |
| 5090 | * |
| 5091 | * purpose: cleans up an FSF request and removes it from the specified list |
| 5092 | * |
| 5093 | * returns: |
| 5094 | * |
| 5095 | * assumption: no pending SB in SBALEs other than QTCB |
| 5096 | */ |
| 5097 | void |
| 5098 | zfcp_fsf_req_cleanup(struct zfcp_fsf_req *fsf_req) |
| 5099 | { |
| 5100 | struct zfcp_adapter *adapter = fsf_req->adapter; |
| 5101 | unsigned long flags; |
| 5102 | |
| 5103 | write_lock_irqsave(&adapter->fsf_req_list_lock, flags); |
| 5104 | list_del(&fsf_req->list); |
| 5105 | write_unlock_irqrestore(&adapter->fsf_req_list_lock, flags); |
| 5106 | zfcp_fsf_req_free(fsf_req); |
| 5107 | } |
| 5108 | |
| 5109 | #undef ZFCP_LOG_AREA |