3 * linux/drivers/s390/scsi/zfcp_fsf.c
5 * FCP adapter driver for IBM eServer zSeries
7 * (C) Copyright IBM Corp. 2002, 2004
9 * Author(s): Martin Peschke <mpeschke@de.ibm.com>
10 * Raimund Schroeder <raimund.schroeder@de.ibm.com>
13 * Stefan Bader <stefan.bader@de.ibm.com>
14 * Heiko Carstens <heiko.carstens@de.ibm.com>
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2, or (at your option)
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
31 /* this drivers version (do not edit !!! generated and updated by cvs) */
32 #define ZFCP_FSF_C_REVISION "$Revision: 1.65 $"
36 static int zfcp_fsf_exchange_config_data_handler(struct zfcp_fsf_req *);
37 static void zfcp_fsf_exchange_port_data_handler(struct zfcp_fsf_req *);
38 static int zfcp_fsf_open_port_handler(struct zfcp_fsf_req *);
39 static int zfcp_fsf_close_port_handler(struct zfcp_fsf_req *);
40 static int zfcp_fsf_close_physical_port_handler(struct zfcp_fsf_req *);
41 static int zfcp_fsf_open_unit_handler(struct zfcp_fsf_req *);
42 static int zfcp_fsf_close_unit_handler(struct zfcp_fsf_req *);
43 static int zfcp_fsf_send_fcp_command_handler(struct zfcp_fsf_req *);
44 static int zfcp_fsf_send_fcp_command_task_handler(struct zfcp_fsf_req *);
45 static int zfcp_fsf_send_fcp_command_task_management_handler(
46 struct zfcp_fsf_req *);
47 static int zfcp_fsf_abort_fcp_command_handler(struct zfcp_fsf_req *);
48 static int zfcp_fsf_status_read_handler(struct zfcp_fsf_req *);
49 static int zfcp_fsf_send_ct_handler(struct zfcp_fsf_req *);
50 static int zfcp_fsf_send_els_handler(struct zfcp_fsf_req *);
51 static int zfcp_fsf_control_file_handler(struct zfcp_fsf_req *);
52 static inline int zfcp_fsf_req_sbal_check(
53 unsigned long *, struct zfcp_qdio_queue *, int);
54 static inline int zfcp_use_one_sbal(
55 struct scatterlist *, int, struct scatterlist *, int);
56 static struct zfcp_fsf_req *zfcp_fsf_req_alloc(mempool_t *, int);
57 static int zfcp_fsf_req_send(struct zfcp_fsf_req *, struct timer_list *);
58 static int zfcp_fsf_protstatus_eval(struct zfcp_fsf_req *);
59 static int zfcp_fsf_fsfstatus_eval(struct zfcp_fsf_req *);
60 static int zfcp_fsf_fsfstatus_qual_eval(struct zfcp_fsf_req *);
61 static int zfcp_fsf_req_dispatch(struct zfcp_fsf_req *);
62 static void zfcp_fsf_req_dismiss(struct zfcp_fsf_req *);
63 static void zfcp_fsf_req_free(struct zfcp_fsf_req *);
65 /* association between FSF command and FSF QTCB type */
66 static u32 fsf_qtcb_type[] = {
67 [FSF_QTCB_FCP_CMND] = FSF_IO_COMMAND,
68 [FSF_QTCB_ABORT_FCP_CMND] = FSF_SUPPORT_COMMAND,
69 [FSF_QTCB_OPEN_PORT_WITH_DID] = FSF_SUPPORT_COMMAND,
70 [FSF_QTCB_OPEN_LUN] = FSF_SUPPORT_COMMAND,
71 [FSF_QTCB_CLOSE_LUN] = FSF_SUPPORT_COMMAND,
72 [FSF_QTCB_CLOSE_PORT] = FSF_SUPPORT_COMMAND,
73 [FSF_QTCB_CLOSE_PHYSICAL_PORT] = FSF_SUPPORT_COMMAND,
74 [FSF_QTCB_SEND_ELS] = FSF_SUPPORT_COMMAND,
75 [FSF_QTCB_SEND_GENERIC] = FSF_SUPPORT_COMMAND,
76 [FSF_QTCB_EXCHANGE_CONFIG_DATA] = FSF_CONFIG_COMMAND,
77 [FSF_QTCB_EXCHANGE_PORT_DATA] = FSF_PORT_COMMAND,
78 [FSF_QTCB_DOWNLOAD_CONTROL_FILE] = FSF_SUPPORT_COMMAND,
79 [FSF_QTCB_UPLOAD_CONTROL_FILE] = FSF_SUPPORT_COMMAND
82 static const char zfcp_act_subtable_type[5][8] = {
83 "unknown", "OS", "WWPN", "DID", "LUN"
86 /****************************************************************/
87 /*************** FSF related Functions *************************/
88 /****************************************************************/
90 #define ZFCP_LOG_AREA ZFCP_LOG_AREA_FSF
93 * function: zfcp_fsf_req_alloc
95 * purpose: Obtains an fsf_req and potentially a qtcb (for all but
96 * unsolicited requests) via helper functions
97 * Does some initial fsf request set-up.
99 * returns: pointer to allocated fsf_req if successfull
105 static struct zfcp_fsf_req *
106 zfcp_fsf_req_alloc(mempool_t *pool, int req_flags)
110 struct zfcp_fsf_req *fsf_req = NULL;
112 if (req_flags & ZFCP_REQ_NO_QTCB)
113 size = sizeof(struct zfcp_fsf_req);
115 size = sizeof(struct zfcp_fsf_req_pool_element);
117 if (likely(pool != NULL))
118 ptr = mempool_alloc(pool, GFP_ATOMIC);
120 ptr = kmalloc(size, GFP_ATOMIC);
122 if (unlikely(NULL == ptr))
125 memset(ptr, 0, size);
127 if (req_flags & ZFCP_REQ_NO_QTCB) {
128 fsf_req = (struct zfcp_fsf_req *) ptr;
130 fsf_req = &((struct zfcp_fsf_req_pool_element *) ptr)->fsf_req;
132 &((struct zfcp_fsf_req_pool_element *) ptr)->qtcb;
135 fsf_req->pool = pool;
142 * function: zfcp_fsf_req_free
144 * purpose: Frees the memory of an fsf_req (and potentially a qtcb) or
145 * returns it into the pool via helper functions.
152 zfcp_fsf_req_free(struct zfcp_fsf_req *fsf_req)
154 if (likely(fsf_req->pool != NULL))
155 mempool_free(fsf_req, fsf_req->pool);
167 * note: qdio queues shall be down (no ongoing inbound processing)
170 zfcp_fsf_req_dismiss_all(struct zfcp_adapter *adapter)
173 struct zfcp_fsf_req *fsf_req, *tmp;
175 list_for_each_entry_safe(fsf_req, tmp, &adapter->fsf_req_list_head,
177 zfcp_fsf_req_dismiss(fsf_req);
178 /* wait_event_timeout? */
179 while (!list_empty(&adapter->fsf_req_list_head)) {
180 ZFCP_LOG_DEBUG("fsf req list of adapter %s not yet empty\n",
181 zfcp_get_busid_by_adapter(adapter));
182 /* wait for woken intiators to clean up their requests */
183 msleep(jiffies_to_msecs(ZFCP_FSFREQ_CLEANUP_TIMEOUT));
186 /* consistency check */
187 if (atomic_read(&adapter->fsf_reqs_active)) {
188 ZFCP_LOG_NORMAL("bug: There are still %d FSF requests pending "
189 "on adapter %s after cleanup.\n",
190 atomic_read(&adapter->fsf_reqs_active),
191 zfcp_get_busid_by_adapter(adapter));
192 atomic_set(&adapter->fsf_reqs_active, 0);
206 zfcp_fsf_req_dismiss(struct zfcp_fsf_req *fsf_req)
208 fsf_req->status |= ZFCP_STATUS_FSFREQ_DISMISSED;
209 zfcp_fsf_req_complete(fsf_req);
213 * function: zfcp_fsf_req_complete
215 * purpose: Updates active counts and timers for openfcp-reqs
216 * May cleanup request after req_eval returns
218 * returns: 0 - success
224 zfcp_fsf_req_complete(struct zfcp_fsf_req *fsf_req)
228 struct zfcp_adapter *adapter = fsf_req->adapter;
230 /* do some statistics */
231 atomic_dec(&adapter->fsf_reqs_active);
233 if (unlikely(fsf_req->fsf_command == FSF_QTCB_UNSOLICITED_STATUS)) {
234 ZFCP_LOG_DEBUG("Status read response received\n");
236 * Note: all cleanup handling is done in the callchain of
237 * the function call-chain below.
239 zfcp_fsf_status_read_handler(fsf_req);
242 zfcp_fsf_protstatus_eval(fsf_req);
245 * fsf_req may be deleted due to waking up functions, so
246 * cleanup is saved here and used later
248 if (likely(fsf_req->status & ZFCP_STATUS_FSFREQ_CLEANUP))
253 fsf_req->status |= ZFCP_STATUS_FSFREQ_COMPLETED;
255 /* cleanup request if requested by initiator */
256 if (likely(cleanup)) {
257 ZFCP_LOG_TRACE("removing FSF request %p\n", fsf_req);
259 * lock must not be held here since it will be
260 * grabed by the called routine, too
262 zfcp_fsf_req_cleanup(fsf_req);
264 /* notify initiator waiting for the requests completion */
265 ZFCP_LOG_TRACE("waking initiator of FSF request %p\n",fsf_req);
267 * FIXME: Race! We must not access fsf_req here as it might have been
268 * cleaned up already due to the set ZFCP_STATUS_FSFREQ_COMPLETED
269 * flag. It's an improbable case. But, we have the same paranoia for
270 * the cleanup flag already.
271 * Might better be handled using complete()?
272 * (setting the flag and doing wakeup ought to be atomic
273 * with regard to checking the flag as long as waitqueue is
274 * part of the to be released structure)
276 wake_up(&fsf_req->completion_wq);
284 * function: zfcp_fsf_protstatus_eval
286 * purpose: evaluates the QTCB of the finished FSF request
287 * and initiates appropriate actions
288 * (usually calling FSF command specific handlers)
297 zfcp_fsf_protstatus_eval(struct zfcp_fsf_req *fsf_req)
300 struct zfcp_adapter *adapter = fsf_req->adapter;
302 ZFCP_LOG_DEBUG("QTCB is at %p\n", fsf_req->qtcb);
304 if (fsf_req->status & ZFCP_STATUS_FSFREQ_DISMISSED) {
305 ZFCP_LOG_DEBUG("fsf_req 0x%lx has been dismissed\n",
306 (unsigned long) fsf_req);
307 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR |
308 ZFCP_STATUS_FSFREQ_RETRY; /* only for SCSI cmnds. */
309 zfcp_cmd_dbf_event_fsf("dismiss", fsf_req, NULL, 0);
310 goto skip_protstatus;
313 /* log additional information provided by FSF (if any) */
314 if (unlikely(fsf_req->qtcb->header.log_length)) {
315 /* do not trust them ;-) */
316 if (fsf_req->qtcb->header.log_start > sizeof(struct fsf_qtcb)) {
318 ("bug: ULP (FSF logging) log data starts "
319 "beyond end of packet header. Ignored. "
320 "(start=%i, size=%li)\n",
321 fsf_req->qtcb->header.log_start,
322 sizeof(struct fsf_qtcb));
325 if ((size_t) (fsf_req->qtcb->header.log_start +
326 fsf_req->qtcb->header.log_length)
327 > sizeof(struct fsf_qtcb)) {
328 ZFCP_LOG_NORMAL("bug: ULP (FSF logging) log data ends "
329 "beyond end of packet header. Ignored. "
330 "(start=%i, length=%i, size=%li)\n",
331 fsf_req->qtcb->header.log_start,
332 fsf_req->qtcb->header.log_length,
333 sizeof(struct fsf_qtcb));
336 ZFCP_LOG_TRACE("ULP log data: \n");
337 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_TRACE,
338 (char *) fsf_req->qtcb +
339 fsf_req->qtcb->header.log_start,
340 fsf_req->qtcb->header.log_length);
344 /* evaluate FSF Protocol Status */
345 switch (fsf_req->qtcb->prefix.prot_status) {
348 ZFCP_LOG_TRACE("FSF_PROT_GOOD\n");
351 case FSF_PROT_FSF_STATUS_PRESENTED:
352 ZFCP_LOG_TRACE("FSF_PROT_FSF_STATUS_PRESENTED\n");
355 case FSF_PROT_QTCB_VERSION_ERROR:
356 ZFCP_LOG_FLAGS(0, "FSF_PROT_QTCB_VERSION_ERROR\n");
357 ZFCP_LOG_NORMAL("error: The adapter %s contains "
358 "microcode of version 0x%x, the device driver "
359 "only supports 0x%x. Aborting.\n",
360 zfcp_get_busid_by_adapter(adapter),
361 fsf_req->qtcb->prefix.prot_status_qual.
362 version_error.fsf_version, ZFCP_QTCB_VERSION);
363 /* stop operation for this adapter */
364 debug_text_exception(adapter->erp_dbf, 0, "prot_ver_err");
365 zfcp_erp_adapter_shutdown(adapter, 0);
366 zfcp_cmd_dbf_event_fsf("qverserr", fsf_req,
367 &fsf_req->qtcb->prefix.prot_status_qual,
368 sizeof (union fsf_prot_status_qual));
369 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
372 case FSF_PROT_SEQ_NUMB_ERROR:
373 ZFCP_LOG_FLAGS(0, "FSF_PROT_SEQ_NUMB_ERROR\n");
374 ZFCP_LOG_NORMAL("bug: Sequence number mismatch between "
375 "driver (0x%x) and adapter %s (0x%x). "
376 "Restarting all operations on this adapter.\n",
377 fsf_req->qtcb->prefix.req_seq_no,
378 zfcp_get_busid_by_adapter(adapter),
379 fsf_req->qtcb->prefix.prot_status_qual.
380 sequence_error.exp_req_seq_no);
381 debug_text_exception(adapter->erp_dbf, 0, "prot_seq_err");
382 /* restart operation on this adapter */
383 zfcp_erp_adapter_reopen(adapter, 0);
384 zfcp_cmd_dbf_event_fsf("seqnoerr", fsf_req,
385 &fsf_req->qtcb->prefix.prot_status_qual,
386 sizeof (union fsf_prot_status_qual));
387 fsf_req->status |= ZFCP_STATUS_FSFREQ_RETRY;
388 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
391 case FSF_PROT_UNSUPP_QTCB_TYPE:
392 ZFCP_LOG_FLAGS(0, "FSF_PROT_UNSUP_QTCB_TYPE\n");
393 ZFCP_LOG_NORMAL("error: Packet header type used by the "
394 "device driver is incompatible with "
395 "that used on adapter %s. "
396 "Stopping all operations on this adapter.\n",
397 zfcp_get_busid_by_adapter(adapter));
398 debug_text_exception(adapter->erp_dbf, 0, "prot_unsup_qtcb");
399 zfcp_erp_adapter_shutdown(adapter, 0);
400 zfcp_cmd_dbf_event_fsf("unsqtcbt", fsf_req,
401 &fsf_req->qtcb->prefix.prot_status_qual,
402 sizeof (union fsf_prot_status_qual));
403 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
406 case FSF_PROT_HOST_CONNECTION_INITIALIZING:
407 ZFCP_LOG_FLAGS(1, "FSF_PROT_HOST_CONNECTION_INITIALIZING\n");
408 zfcp_cmd_dbf_event_fsf("hconinit", fsf_req,
409 &fsf_req->qtcb->prefix.prot_status_qual,
410 sizeof (union fsf_prot_status_qual));
411 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
412 atomic_set_mask(ZFCP_STATUS_ADAPTER_HOST_CON_INIT,
414 debug_text_event(adapter->erp_dbf, 3, "prot_con_init");
417 case FSF_PROT_DUPLICATE_REQUEST_ID:
418 ZFCP_LOG_FLAGS(0, "FSF_PROT_DUPLICATE_REQUEST_IDS\n");
420 ZFCP_LOG_NORMAL("bug: The request identifier 0x%Lx "
421 "to the adapter %s is ambiguous. "
422 "Stopping all operations on this "
424 *(unsigned long long *)
425 (&fsf_req->qtcb->bottom.support.
427 zfcp_get_busid_by_adapter(adapter));
429 ZFCP_LOG_NORMAL("bug: The request identifier %p "
430 "to the adapter %s is ambiguous. "
431 "Stopping all operations on this "
433 "(bug: got this for an unsolicited "
434 "status read request)\n",
436 zfcp_get_busid_by_adapter(adapter));
438 debug_text_exception(adapter->erp_dbf, 0, "prot_dup_id");
439 zfcp_erp_adapter_shutdown(adapter, 0);
440 zfcp_cmd_dbf_event_fsf("dupreqid", fsf_req,
441 &fsf_req->qtcb->prefix.prot_status_qual,
442 sizeof (union fsf_prot_status_qual));
443 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
446 case FSF_PROT_LINK_DOWN:
447 ZFCP_LOG_FLAGS(1, "FSF_PROT_LINK_DOWN\n");
449 * 'test and set' is not atomic here -
450 * it's ok as long as calls to our response queue handler
451 * (and thus execution of this code here) are serialized
454 if (!atomic_test_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED,
456 switch (fsf_req->qtcb->prefix.prot_status_qual.
457 locallink_error.code) {
458 case FSF_PSQ_LINK_NOLIGHT:
459 ZFCP_LOG_INFO("The local link to adapter %s "
460 "is down (no light detected).\n",
461 zfcp_get_busid_by_adapter(
464 case FSF_PSQ_LINK_WRAPPLUG:
465 ZFCP_LOG_INFO("The local link to adapter %s "
466 "is down (wrap plug detected).\n",
467 zfcp_get_busid_by_adapter(
470 case FSF_PSQ_LINK_NOFCP:
471 ZFCP_LOG_INFO("The local link to adapter %s "
472 "is down (adjacent node on "
473 "link does not support FCP).\n",
474 zfcp_get_busid_by_adapter(
478 ZFCP_LOG_INFO("The local link to adapter %s "
480 "(warning: unknown reason "
482 zfcp_get_busid_by_adapter(
488 * Due to the 'erp failed' flag the adapter won't
489 * be recovered but will be just set to 'blocked'
490 * state. All subordinary devices will have state
491 * 'blocked' and 'erp failed', too.
492 * Thus the adapter is still able to provide
493 * 'link up' status without being flooded with
495 * (note: even 'close port' is not permitted)
497 ZFCP_LOG_INFO("Stopping all operations for adapter "
499 zfcp_get_busid_by_adapter(adapter));
500 atomic_set_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED |
501 ZFCP_STATUS_COMMON_ERP_FAILED,
503 zfcp_erp_adapter_reopen(adapter, 0);
504 debug_text_event(adapter->erp_dbf, 1, "prot_link_down");
506 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
509 case FSF_PROT_REEST_QUEUE:
510 ZFCP_LOG_FLAGS(1, "FSF_PROT_REEST_QUEUE\n");
511 debug_text_event(adapter->erp_dbf, 1, "prot_reest_queue");
512 ZFCP_LOG_INFO("The local link to adapter with "
513 "%s was re-plugged. "
514 "Re-starting operations on this adapter.\n",
515 zfcp_get_busid_by_adapter(adapter));
516 /* All ports should be marked as ready to run again */
517 zfcp_erp_modify_adapter_status(adapter,
518 ZFCP_STATUS_COMMON_RUNNING,
520 zfcp_erp_adapter_reopen(adapter,
521 ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED
522 | ZFCP_STATUS_COMMON_ERP_FAILED);
523 zfcp_cmd_dbf_event_fsf("reestque", fsf_req,
524 &fsf_req->qtcb->prefix.prot_status_qual,
525 sizeof (union fsf_prot_status_qual));
526 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
529 case FSF_PROT_ERROR_STATE:
530 ZFCP_LOG_FLAGS(0, "FSF_PROT_ERROR_STATE\n");
531 ZFCP_LOG_NORMAL("error: The adapter %s "
532 "has entered the error state. "
533 "Restarting all operations on this "
535 zfcp_get_busid_by_adapter(adapter));
536 debug_text_event(adapter->erp_dbf, 0, "prot_err_sta");
537 /* restart operation on this adapter */
538 zfcp_erp_adapter_reopen(adapter, 0);
539 zfcp_cmd_dbf_event_fsf("proterrs", fsf_req,
540 &fsf_req->qtcb->prefix.prot_status_qual,
541 sizeof (union fsf_prot_status_qual));
542 fsf_req->status |= ZFCP_STATUS_FSFREQ_RETRY;
543 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
547 ZFCP_LOG_NORMAL("bug: Transfer protocol status information "
548 "provided by the adapter %s "
549 "is not compatible with the device driver. "
550 "Stopping all operations on this adapter. "
551 "(debug info 0x%x).\n",
552 zfcp_get_busid_by_adapter(adapter),
553 fsf_req->qtcb->prefix.prot_status);
554 debug_text_event(adapter->erp_dbf, 0, "prot_inval:");
555 debug_exception(adapter->erp_dbf, 0,
556 &fsf_req->qtcb->prefix.prot_status,
558 zfcp_erp_adapter_shutdown(adapter, 0);
559 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
564 * always call specific handlers to give them a chance to do
565 * something meaningful even in error cases
567 zfcp_fsf_fsfstatus_eval(fsf_req);
572 * function: zfcp_fsf_fsfstatus_eval
574 * purpose: evaluates FSF status of completed FSF request
575 * and acts accordingly
580 zfcp_fsf_fsfstatus_eval(struct zfcp_fsf_req *fsf_req)
584 if (unlikely(fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR)) {
588 /* evaluate FSF Status */
589 switch (fsf_req->qtcb->header.fsf_status) {
590 case FSF_UNKNOWN_COMMAND:
591 ZFCP_LOG_FLAGS(0, "FSF_UNKNOWN_COMMAND\n");
592 ZFCP_LOG_NORMAL("bug: Command issued by the device driver is "
593 "not known by the adapter %s "
594 "Stopping all operations on this adapter. "
595 "(debug info 0x%x).\n",
596 zfcp_get_busid_by_adapter(fsf_req->adapter),
597 fsf_req->qtcb->header.fsf_command);
598 debug_text_exception(fsf_req->adapter->erp_dbf, 0,
600 zfcp_erp_adapter_shutdown(fsf_req->adapter, 0);
601 zfcp_cmd_dbf_event_fsf("unknownc", fsf_req,
602 &fsf_req->qtcb->header.fsf_status_qual,
603 sizeof (union fsf_status_qual));
604 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
607 case FSF_FCP_RSP_AVAILABLE:
608 ZFCP_LOG_FLAGS(2, "FSF_FCP_RSP_AVAILABLE\n");
609 ZFCP_LOG_DEBUG("FCP Sense data will be presented to the "
611 debug_text_event(fsf_req->adapter->erp_dbf, 3, "fsf_s_rsp");
614 case FSF_ADAPTER_STATUS_AVAILABLE:
615 ZFCP_LOG_FLAGS(2, "FSF_ADAPTER_STATUS_AVAILABLE\n");
616 debug_text_event(fsf_req->adapter->erp_dbf, 2, "fsf_s_astatus");
617 zfcp_fsf_fsfstatus_qual_eval(fsf_req);
626 * always call specific handlers to give them a chance to do
627 * something meaningful even in error cases
629 zfcp_fsf_req_dispatch(fsf_req);
635 * function: zfcp_fsf_fsfstatus_qual_eval
637 * purpose: evaluates FSF status-qualifier of completed FSF request
638 * and acts accordingly
643 zfcp_fsf_fsfstatus_qual_eval(struct zfcp_fsf_req *fsf_req)
647 switch (fsf_req->qtcb->header.fsf_status_qual.word[0]) {
648 case FSF_SQ_FCP_RSP_AVAILABLE:
649 ZFCP_LOG_FLAGS(2, "FSF_SQ_FCP_RSP_AVAILABLE\n");
650 debug_text_event(fsf_req->adapter->erp_dbf, 4, "fsf_sq_rsp");
652 case FSF_SQ_RETRY_IF_POSSIBLE:
653 ZFCP_LOG_FLAGS(2, "FSF_SQ_RETRY_IF_POSSIBLE\n");
654 /* The SCSI-stack may now issue retries or escalate */
655 debug_text_event(fsf_req->adapter->erp_dbf, 2, "fsf_sq_retry");
656 zfcp_cmd_dbf_event_fsf("sqretry", fsf_req,
657 &fsf_req->qtcb->header.fsf_status_qual,
658 sizeof (union fsf_status_qual));
659 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
661 case FSF_SQ_COMMAND_ABORTED:
662 ZFCP_LOG_FLAGS(2, "FSF_SQ_COMMAND_ABORTED\n");
663 /* Carry the aborted state on to upper layer */
664 debug_text_event(fsf_req->adapter->erp_dbf, 2, "fsf_sq_abort");
665 zfcp_cmd_dbf_event_fsf("sqabort", fsf_req,
666 &fsf_req->qtcb->header.fsf_status_qual,
667 sizeof (union fsf_status_qual));
668 fsf_req->status |= ZFCP_STATUS_FSFREQ_ABORTED;
669 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
671 case FSF_SQ_NO_RECOM:
672 ZFCP_LOG_FLAGS(0, "FSF_SQ_NO_RECOM\n");
673 debug_text_exception(fsf_req->adapter->erp_dbf, 0,
675 ZFCP_LOG_NORMAL("bug: No recommendation could be given for a"
676 "problem on the adapter %s "
677 "Stopping all operations on this adapter. ",
678 zfcp_get_busid_by_adapter(fsf_req->adapter));
679 zfcp_erp_adapter_shutdown(fsf_req->adapter, 0);
680 zfcp_cmd_dbf_event_fsf("sqnrecom", fsf_req,
681 &fsf_req->qtcb->header.fsf_status_qual,
682 sizeof (union fsf_status_qual));
683 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
685 case FSF_SQ_ULP_PROGRAMMING_ERROR:
686 ZFCP_LOG_FLAGS(0, "FSF_SQ_ULP_PROGRAMMING_ERROR\n");
687 ZFCP_LOG_NORMAL("error: not enough SBALs for data transfer "
689 zfcp_get_busid_by_adapter(fsf_req->adapter));
690 debug_text_exception(fsf_req->adapter->erp_dbf, 0,
692 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
694 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
695 case FSF_SQ_NO_RETRY_POSSIBLE:
696 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
697 /* dealt with in the respective functions */
700 ZFCP_LOG_NORMAL("bug: Additional status info could "
701 "not be interpreted properly.\n");
702 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_NORMAL,
703 (char *) &fsf_req->qtcb->header.fsf_status_qual,
704 sizeof (union fsf_status_qual));
705 debug_text_event(fsf_req->adapter->erp_dbf, 0, "fsf_sq_inval:");
706 debug_exception(fsf_req->adapter->erp_dbf, 0,
707 &fsf_req->qtcb->header.fsf_status_qual.word[0],
709 zfcp_cmd_dbf_event_fsf("squndef", fsf_req,
710 &fsf_req->qtcb->header.fsf_status_qual,
711 sizeof (union fsf_status_qual));
712 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
720 * function: zfcp_fsf_req_dispatch
722 * purpose: calls the appropriate command specific handler
727 zfcp_fsf_req_dispatch(struct zfcp_fsf_req *fsf_req)
729 struct zfcp_erp_action *erp_action = fsf_req->erp_action;
730 struct zfcp_adapter *adapter = fsf_req->adapter;
733 if (unlikely(fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR)) {
734 ZFCP_LOG_TRACE("fsf_req=%p, QTCB=%p\n", fsf_req, fsf_req->qtcb);
735 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_TRACE,
736 (char *) fsf_req->qtcb, sizeof(struct fsf_qtcb));
739 switch (fsf_req->fsf_command) {
741 case FSF_QTCB_FCP_CMND:
742 ZFCP_LOG_FLAGS(3, "FSF_QTCB_FCP_CMND\n");
743 zfcp_fsf_send_fcp_command_handler(fsf_req);
746 case FSF_QTCB_ABORT_FCP_CMND:
747 ZFCP_LOG_FLAGS(2, "FSF_QTCB_ABORT_FCP_CMND\n");
748 zfcp_fsf_abort_fcp_command_handler(fsf_req);
751 case FSF_QTCB_SEND_GENERIC:
752 ZFCP_LOG_FLAGS(2, "FSF_QTCB_SEND_GENERIC\n");
753 zfcp_fsf_send_ct_handler(fsf_req);
756 case FSF_QTCB_OPEN_PORT_WITH_DID:
757 ZFCP_LOG_FLAGS(2, "FSF_QTCB_OPEN_PORT_WITH_DID\n");
758 zfcp_fsf_open_port_handler(fsf_req);
761 case FSF_QTCB_OPEN_LUN:
762 ZFCP_LOG_FLAGS(2, "FSF_QTCB_OPEN_LUN\n");
763 zfcp_fsf_open_unit_handler(fsf_req);
766 case FSF_QTCB_CLOSE_LUN:
767 ZFCP_LOG_FLAGS(2, "FSF_QTCB_CLOSE_LUN\n");
768 zfcp_fsf_close_unit_handler(fsf_req);
771 case FSF_QTCB_CLOSE_PORT:
772 ZFCP_LOG_FLAGS(2, "FSF_QTCB_CLOSE_PORT\n");
773 zfcp_fsf_close_port_handler(fsf_req);
776 case FSF_QTCB_CLOSE_PHYSICAL_PORT:
777 ZFCP_LOG_FLAGS(2, "FSF_QTCB_CLOSE_PHYSICAL_PORT\n");
778 zfcp_fsf_close_physical_port_handler(fsf_req);
781 case FSF_QTCB_EXCHANGE_CONFIG_DATA:
782 ZFCP_LOG_FLAGS(2, "FSF_QTCB_EXCHANGE_CONFIG_DATA\n");
783 zfcp_fsf_exchange_config_data_handler(fsf_req);
786 case FSF_QTCB_EXCHANGE_PORT_DATA :
787 ZFCP_LOG_FLAGS(2, "FSF_QTCB_EXCHANGE_PORT_DATA\n");
788 zfcp_fsf_exchange_port_data_handler(fsf_req);
791 case FSF_QTCB_SEND_ELS :
792 ZFCP_LOG_FLAGS(2, "FSF_QTCB_SEND_ELS\n");
793 zfcp_fsf_send_els_handler(fsf_req);
796 case FSF_QTCB_DOWNLOAD_CONTROL_FILE:
797 ZFCP_LOG_FLAGS(2, "FSF_QTCB_DOWNLOAD_CONTROL_FILE\n");
798 zfcp_fsf_control_file_handler(fsf_req);
801 case FSF_QTCB_UPLOAD_CONTROL_FILE:
802 ZFCP_LOG_FLAGS(2, "FSF_QTCB_UPLOAD_CONTROL_FILE\n");
803 zfcp_fsf_control_file_handler(fsf_req);
807 ZFCP_LOG_FLAGS(2, "FSF_QTCB_UNKNOWN\n");
808 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
809 ZFCP_LOG_NORMAL("bug: Command issued by the device driver is "
810 "not supported by the adapter %s\n",
811 zfcp_get_busid_by_adapter(fsf_req->adapter));
812 if (fsf_req->fsf_command != fsf_req->qtcb->header.fsf_command)
814 ("bug: Command issued by the device driver differs "
815 "from the command returned by the adapter %s "
816 "(debug info 0x%x, 0x%x).\n",
817 zfcp_get_busid_by_adapter(fsf_req->adapter),
818 fsf_req->fsf_command,
819 fsf_req->qtcb->header.fsf_command);
825 debug_text_event(adapter->erp_dbf, 3, "a_frh");
826 debug_event(adapter->erp_dbf, 3, &erp_action->action, sizeof (int));
827 zfcp_erp_async_handler(erp_action, 0);
833 * function: zfcp_fsf_status_read
835 * purpose: initiates a Status Read command at the specified adapter
840 zfcp_fsf_status_read(struct zfcp_adapter *adapter, int req_flags)
842 struct zfcp_fsf_req *fsf_req;
843 struct fsf_status_read_buffer *status_buffer;
844 unsigned long lock_flags;
845 volatile struct qdio_buffer_element *sbale;
848 /* setup new FSF request */
849 retval = zfcp_fsf_req_create(adapter, FSF_QTCB_UNSOLICITED_STATUS,
850 req_flags | ZFCP_REQ_NO_QTCB,
851 adapter->pool.fsf_req_status_read,
852 &lock_flags, &fsf_req);
854 ZFCP_LOG_INFO("error: Could not create unsolicited status "
855 "buffer for adapter %s.\n",
856 zfcp_get_busid_by_adapter(adapter));
857 goto failed_req_create;
860 sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0);
861 sbale[0].flags |= SBAL_FLAGS0_TYPE_STATUS;
862 sbale[2].flags |= SBAL_FLAGS_LAST_ENTRY;
863 fsf_req->sbale_curr = 2;
866 mempool_alloc(adapter->pool.data_status_read, GFP_ATOMIC);
867 if (!status_buffer) {
868 ZFCP_LOG_NORMAL("bug: could not get some buffer\n");
871 memset(status_buffer, 0, sizeof (struct fsf_status_read_buffer));
872 fsf_req->data.status_read.buffer = status_buffer;
874 /* insert pointer to respective buffer */
875 sbale = zfcp_qdio_sbale_curr(fsf_req);
876 sbale->addr = (void *) status_buffer;
877 sbale->length = sizeof(struct fsf_status_read_buffer);
879 /* start QDIO request for this FSF request */
880 retval = zfcp_fsf_req_send(fsf_req, NULL);
882 ZFCP_LOG_DEBUG("error: Could not set-up unsolicited status "
884 goto failed_req_send;
887 ZFCP_LOG_TRACE("Status Read request initiated (adapter%s)\n",
888 zfcp_get_busid_by_adapter(adapter));
892 mempool_free(status_buffer, adapter->pool.data_status_read);
895 zfcp_fsf_req_free(fsf_req);
898 write_unlock_irqrestore(&adapter->request_queue.queue_lock, lock_flags);
903 zfcp_fsf_status_read_port_closed(struct zfcp_fsf_req *fsf_req)
905 struct fsf_status_read_buffer *status_buffer;
906 struct zfcp_adapter *adapter;
907 struct zfcp_port *port;
910 status_buffer = fsf_req->data.status_read.buffer;
911 adapter = fsf_req->adapter;
913 read_lock_irqsave(&zfcp_data.config_lock, flags);
914 list_for_each_entry(port, &adapter->port_list_head, list)
915 if (port->d_id == (status_buffer->d_id & ZFCP_DID_MASK))
917 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
919 if (!port || (port->d_id != (status_buffer->d_id & ZFCP_DID_MASK))) {
920 ZFCP_LOG_NORMAL("bug: Reopen port indication received for"
921 "nonexisting port with d_id 0x%08x on "
922 "adapter %s. Ignored.\n",
923 status_buffer->d_id & ZFCP_DID_MASK,
924 zfcp_get_busid_by_adapter(adapter));
928 switch (status_buffer->status_subtype) {
930 case FSF_STATUS_READ_SUB_CLOSE_PHYS_PORT:
931 ZFCP_LOG_FLAGS(2, "FSF_STATUS_READ_SUB_CLOSE_PHYS_PORT\n");
932 debug_text_event(adapter->erp_dbf, 3, "unsol_pc_phys:");
933 zfcp_erp_port_reopen(port, 0);
936 case FSF_STATUS_READ_SUB_ERROR_PORT:
937 ZFCP_LOG_FLAGS(1, "FSF_STATUS_READ_SUB_ERROR_PORT\n");
938 debug_text_event(adapter->erp_dbf, 1, "unsol_pc_err:");
939 zfcp_erp_port_shutdown(port, 0);
943 debug_text_event(adapter->erp_dbf, 0, "unsol_unk_sub:");
944 debug_exception(adapter->erp_dbf, 0,
945 &status_buffer->status_subtype, sizeof (u32));
946 ZFCP_LOG_NORMAL("bug: Undefined status subtype received "
947 "for a reopen indication on port with "
948 "d_id 0x%08x on the adapter %s. "
949 "Ignored. (debug info 0x%x)\n",
951 zfcp_get_busid_by_adapter(adapter),
952 status_buffer->status_subtype);
959 * function: zfcp_fsf_status_read_handler
961 * purpose: is called for finished Open Port command
966 zfcp_fsf_status_read_handler(struct zfcp_fsf_req *fsf_req)
969 struct zfcp_adapter *adapter = fsf_req->adapter;
970 struct fsf_status_read_buffer *status_buffer =
971 fsf_req->data.status_read.buffer;
973 if (fsf_req->status & ZFCP_STATUS_FSFREQ_DISMISSED) {
974 mempool_free(status_buffer, adapter->pool.data_status_read);
975 zfcp_fsf_req_cleanup(fsf_req);
979 switch (status_buffer->status_type) {
981 case FSF_STATUS_READ_PORT_CLOSED:
982 ZFCP_LOG_FLAGS(1, "FSF_STATUS_READ_PORT_CLOSED\n");
983 debug_text_event(adapter->erp_dbf, 3, "unsol_pclosed:");
984 debug_event(adapter->erp_dbf, 3,
985 &status_buffer->d_id, sizeof (u32));
986 zfcp_fsf_status_read_port_closed(fsf_req);
989 case FSF_STATUS_READ_INCOMING_ELS:
990 ZFCP_LOG_FLAGS(1, "FSF_STATUS_READ_INCOMING_ELS\n");
991 debug_text_event(adapter->erp_dbf, 3, "unsol_els:");
992 zfcp_fsf_incoming_els(fsf_req);
995 case FSF_STATUS_READ_BIT_ERROR_THRESHOLD:
996 ZFCP_LOG_FLAGS(1, "FSF_STATUS_READ_BIT_ERROR_THRESHOLD\n");
997 debug_text_event(adapter->erp_dbf, 3, "unsol_bit_err:");
998 ZFCP_LOG_NORMAL("Bit error threshold data received:\n");
999 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_NORMAL,
1000 (char *) status_buffer,
1001 sizeof (struct fsf_status_read_buffer));
1004 case FSF_STATUS_READ_LINK_DOWN:
1005 ZFCP_LOG_FLAGS(1, "FSF_STATUS_READ_LINK_DOWN\n");
1006 debug_text_event(adapter->erp_dbf, 0, "unsol_link_down:");
1007 ZFCP_LOG_INFO("Local link to adapter %s is down\n",
1008 zfcp_get_busid_by_adapter(adapter));
1009 atomic_set_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED,
1011 zfcp_erp_adapter_failed(adapter);
1014 case FSF_STATUS_READ_LINK_UP:
1015 ZFCP_LOG_FLAGS(1, "FSF_STATUS_READ_LINK_UP\n");
1016 debug_text_event(adapter->erp_dbf, 2, "unsol_link_up:");
1017 ZFCP_LOG_INFO("Local link to adapter %s was replugged. "
1018 "Restarting operations on this adapter\n",
1019 zfcp_get_busid_by_adapter(adapter));
1020 /* All ports should be marked as ready to run again */
1021 zfcp_erp_modify_adapter_status(adapter,
1022 ZFCP_STATUS_COMMON_RUNNING,
1024 zfcp_erp_adapter_reopen(adapter,
1025 ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED
1026 | ZFCP_STATUS_COMMON_ERP_FAILED);
1030 case FSF_STATUS_READ_CFDC_UPDATED:
1031 ZFCP_LOG_FLAGS(1, "FSF_STATUS_READ_CFDC_UPDATED\n");
1032 debug_text_event(adapter->erp_dbf, 2, "unsol_cfdc_update:");
1033 ZFCP_LOG_INFO("CFDC has been updated on the adapter %s\n",
1034 zfcp_get_busid_by_adapter(adapter));
1037 case FSF_STATUS_READ_CFDC_HARDENED:
1038 ZFCP_LOG_FLAGS(1, "FSF_STATUS_READ_CFDC_HARDENED\n");
1039 debug_text_event(adapter->erp_dbf, 2, "unsol_cfdc_harden:");
1040 switch (status_buffer->status_subtype) {
1041 case FSF_STATUS_READ_SUB_CFDC_HARDENED_ON_SE:
1042 ZFCP_LOG_INFO("CFDC of adapter %s saved on SE\n",
1043 zfcp_get_busid_by_adapter(adapter));
1045 case FSF_STATUS_READ_SUB_CFDC_HARDENED_ON_SE2:
1046 ZFCP_LOG_INFO("CFDC of adapter %s has been copied "
1047 "to the secondary SE\n",
1048 zfcp_get_busid_by_adapter(adapter));
1051 ZFCP_LOG_INFO("CFDC of adapter %s has been hardened\n",
1052 zfcp_get_busid_by_adapter(adapter));
1057 debug_text_event(adapter->erp_dbf, 0, "unsol_unknown:");
1058 debug_exception(adapter->erp_dbf, 0,
1059 &status_buffer->status_type, sizeof (u32));
1060 ZFCP_LOG_NORMAL("bug: An unsolicited status packet of unknown "
1061 "type was received (debug info 0x%x)\n",
1062 status_buffer->status_type);
1063 ZFCP_LOG_DEBUG("Dump of status_read_buffer %p:\n",
1065 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
1066 (char *) status_buffer,
1067 sizeof (struct fsf_status_read_buffer));
1070 mempool_free(status_buffer, adapter->pool.data_status_read);
1071 zfcp_fsf_req_cleanup(fsf_req);
1073 * recycle buffer and start new request repeat until outbound
1074 * queue is empty or adapter shutdown is requested
1078 * we may wait in the req_create for 5s during shutdown, so
1079 * qdio_cleanup will have to wait at least that long before returning
1080 * with failure to allow us a proper cleanup under all circumstances
1084 * allocation failure possible? (Is this code needed?)
1086 retval = zfcp_fsf_status_read(adapter, 0);
1088 ZFCP_LOG_INFO("Failed to create unsolicited status read "
1089 "request for the adapter %s.\n",
1090 zfcp_get_busid_by_adapter(adapter));
1091 /* temporary fix to avoid status read buffer shortage */
1092 adapter->status_read_failed++;
1093 if ((ZFCP_STATUS_READS_RECOM - adapter->status_read_failed)
1094 < ZFCP_STATUS_READ_FAILED_THRESHOLD) {
1095 ZFCP_LOG_INFO("restart adapter %s due to status read "
1096 "buffer shortage\n",
1097 zfcp_get_busid_by_adapter(adapter));
1098 zfcp_erp_adapter_reopen(adapter, 0);
1106 * function: zfcp_fsf_abort_fcp_command
1108 * purpose: tells FSF to abort a running SCSI command
1110 * returns: address of initiated FSF request
1111 * NULL - request could not be initiated
1113 * FIXME(design): should be watched by a timeout !!!
1114 * FIXME(design) shouldn't this be modified to return an int
1115 * also...don't know how though
1117 struct zfcp_fsf_req *
1118 zfcp_fsf_abort_fcp_command(unsigned long old_req_id,
1119 struct zfcp_adapter *adapter,
1120 struct zfcp_unit *unit, int req_flags)
1122 volatile struct qdio_buffer_element *sbale;
1123 unsigned long lock_flags;
1124 struct zfcp_fsf_req *fsf_req = NULL;
1127 /* setup new FSF request */
1128 retval = zfcp_fsf_req_create(adapter, FSF_QTCB_ABORT_FCP_CMND,
1129 req_flags, adapter->pool.fsf_req_abort,
1130 &lock_flags, &fsf_req);
1132 ZFCP_LOG_INFO("error: Failed to create an abort command "
1133 "request for lun 0x%016Lx on port 0x%016Lx "
1137 zfcp_get_busid_by_adapter(adapter));
1141 sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0);
1142 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
1143 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
1145 fsf_req->data.abort_fcp_command.unit = unit;
1147 /* set handles of unit and its parent port in QTCB */
1148 fsf_req->qtcb->header.lun_handle = unit->handle;
1149 fsf_req->qtcb->header.port_handle = unit->port->handle;
1151 /* set handle of request which should be aborted */
1152 fsf_req->qtcb->bottom.support.req_handle = (u64) old_req_id;
1154 /* start QDIO request for this FSF request */
1156 zfcp_fsf_start_scsi_er_timer(adapter);
1157 retval = zfcp_fsf_req_send(fsf_req, NULL);
1159 del_timer(&adapter->scsi_er_timer);
1160 ZFCP_LOG_INFO("error: Failed to send abort command request "
1161 "on adapter %s, port 0x%016Lx, unit 0x%016Lx\n",
1162 zfcp_get_busid_by_adapter(adapter),
1163 unit->port->wwpn, unit->fcp_lun);
1164 zfcp_fsf_req_free(fsf_req);
1169 ZFCP_LOG_DEBUG("Abort FCP Command request initiated "
1170 "(adapter%s, port d_id=0x%08x, "
1171 "unit x%016Lx, old_req_id=0x%lx)\n",
1172 zfcp_get_busid_by_adapter(adapter),
1174 unit->fcp_lun, old_req_id);
1176 write_unlock_irqrestore(&adapter->request_queue.queue_lock, lock_flags);
1181 * function: zfcp_fsf_abort_fcp_command_handler
1183 * purpose: is called for finished Abort FCP Command request
1188 zfcp_fsf_abort_fcp_command_handler(struct zfcp_fsf_req *new_fsf_req)
1190 int retval = -EINVAL;
1191 struct zfcp_unit *unit = new_fsf_req->data.abort_fcp_command.unit;
1192 unsigned char status_qual =
1193 new_fsf_req->qtcb->header.fsf_status_qual.word[0];
1195 del_timer(&new_fsf_req->adapter->scsi_er_timer);
1197 if (new_fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) {
1198 /* do not set ZFCP_STATUS_FSFREQ_ABORTSUCCEEDED */
1199 goto skip_fsfstatus;
1202 /* evaluate FSF status in QTCB */
1203 switch (new_fsf_req->qtcb->header.fsf_status) {
1205 case FSF_PORT_HANDLE_NOT_VALID:
1206 if (status_qual >> 4 != status_qual % 0xf) {
1207 ZFCP_LOG_FLAGS(2, "FSF_PORT_HANDLE_NOT_VALID\n");
1208 debug_text_event(new_fsf_req->adapter->erp_dbf, 3,
1211 * In this case a command that was sent prior to a port
1212 * reopen was aborted (handles are different). This is
1216 ZFCP_LOG_FLAGS(1, "FSF_PORT_HANDLE_NOT_VALID\n");
1217 ZFCP_LOG_INFO("Temporary port identifier 0x%x for "
1218 "port 0x%016Lx on adapter %s invalid. "
1219 "This may happen occasionally.\n",
1222 zfcp_get_busid_by_unit(unit));
1223 ZFCP_LOG_INFO("status qualifier:\n");
1224 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_INFO,
1225 (char *) &new_fsf_req->qtcb->header.
1227 sizeof (union fsf_status_qual));
1228 /* Let's hope this sorts out the mess */
1229 debug_text_event(new_fsf_req->adapter->erp_dbf, 1,
1231 zfcp_erp_adapter_reopen(unit->port->adapter, 0);
1232 new_fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1236 case FSF_LUN_HANDLE_NOT_VALID:
1237 if (status_qual >> 4 != status_qual % 0xf) {
1239 ZFCP_LOG_FLAGS(0, "FSF_LUN_HANDLE_NOT_VALID\n");
1240 debug_text_event(new_fsf_req->adapter->erp_dbf, 3,
1243 * In this case a command that was sent prior to a unit
1244 * reopen was aborted (handles are different).
1248 ZFCP_LOG_FLAGS(1, "FSF_LUN_HANDLE_NOT_VALID\n");
1250 ("Warning: Temporary LUN identifier 0x%x of LUN "
1251 "0x%016Lx on port 0x%016Lx on adapter %s is "
1252 "invalid. This may happen in rare cases. "
1253 "Trying to re-establish link.\n",
1257 zfcp_get_busid_by_unit(unit));
1258 ZFCP_LOG_DEBUG("Status qualifier data:\n");
1259 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
1260 (char *) &new_fsf_req->qtcb->header.
1262 sizeof (union fsf_status_qual));
1263 /* Let's hope this sorts out the mess */
1264 debug_text_event(new_fsf_req->adapter->erp_dbf, 1,
1266 zfcp_erp_port_reopen(unit->port, 0);
1267 new_fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1271 case FSF_FCP_COMMAND_DOES_NOT_EXIST:
1272 ZFCP_LOG_FLAGS(2, "FSF_FCP_COMMAND_DOES_NOT_EXIST\n");
1274 debug_text_event(new_fsf_req->adapter->erp_dbf, 3,
1276 new_fsf_req->status |= ZFCP_STATUS_FSFREQ_ABORTNOTNEEDED;
1279 case FSF_PORT_BOXED:
1281 ZFCP_LOG_FLAGS(0, "FSF_PORT_BOXED\n");
1282 ZFCP_LOG_INFO("Remote port 0x%016Lx on adapter %s needs to "
1283 "be reopened\n", unit->port->wwpn,
1284 zfcp_get_busid_by_unit(unit));
1285 debug_text_event(new_fsf_req->adapter->erp_dbf, 2,
1287 zfcp_erp_port_reopen(unit->port, 0);
1288 new_fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR
1289 | ZFCP_STATUS_FSFREQ_RETRY;
1292 case FSF_ADAPTER_STATUS_AVAILABLE:
1294 ZFCP_LOG_FLAGS(0, "FSF_ADAPTER_STATUS_AVAILABLE\n");
1295 switch (new_fsf_req->qtcb->header.fsf_status_qual.word[0]) {
1296 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
1298 "FSF_SQ_INVOKE_LINK_TEST_PROCEDURE\n");
1299 debug_text_event(new_fsf_req->adapter->erp_dbf, 1,
1301 /* reopening link to port */
1302 zfcp_erp_port_reopen(unit->port, 0);
1303 new_fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1305 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
1307 "FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED\n");
1308 /* SCSI stack will escalate */
1309 debug_text_event(new_fsf_req->adapter->erp_dbf, 1,
1311 new_fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1315 ("bug: Wrong status qualifier 0x%x arrived.\n",
1316 new_fsf_req->qtcb->header.fsf_status_qual.word[0]);
1317 debug_text_event(new_fsf_req->adapter->erp_dbf, 0,
1319 debug_exception(new_fsf_req->adapter->erp_dbf, 0,
1320 &new_fsf_req->qtcb->header.
1321 fsf_status_qual.word[0], sizeof (u32));
1328 ZFCP_LOG_FLAGS(0, "FSF_GOOD\n");
1330 new_fsf_req->status |= ZFCP_STATUS_FSFREQ_ABORTSUCCEEDED;
1334 ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
1335 "(debug info 0x%x)\n",
1336 new_fsf_req->qtcb->header.fsf_status);
1337 debug_text_event(new_fsf_req->adapter->erp_dbf, 0,
1339 debug_exception(new_fsf_req->adapter->erp_dbf, 0,
1340 &new_fsf_req->qtcb->header.fsf_status,
1349 * zfcp_use_one_sbal - checks whether req buffer and resp bother each fit into
1351 * Two scatter-gather lists are passed, one for the reqeust and one for the
1355 zfcp_use_one_sbal(struct scatterlist *req, int req_count,
1356 struct scatterlist *resp, int resp_count)
1358 return ((req_count == 1) &&
1359 (resp_count == 1) &&
1360 (((unsigned long) zfcp_sg_to_address(&req[0]) &
1362 ((unsigned long) (zfcp_sg_to_address(&req[0]) +
1363 req[0].length - 1) & PAGE_MASK)) &&
1364 (((unsigned long) zfcp_sg_to_address(&resp[0]) &
1366 ((unsigned long) (zfcp_sg_to_address(&resp[0]) +
1367 resp[0].length - 1) & PAGE_MASK)));
1371 * zfcp_fsf_send_ct - initiate a Generic Service request (FC-GS)
1372 * @ct: pointer to struct zfcp_send_ct which conatins all needed data for
1374 * @pool: pointer to memory pool, if non-null this pool is used to allocate
1375 * a struct zfcp_fsf_req
1376 * @erp_action: pointer to erp_action, if non-null the Generic Service request
1377 * is sent within error recovery
1380 zfcp_fsf_send_ct(struct zfcp_send_ct *ct, mempool_t *pool,
1381 struct zfcp_erp_action *erp_action)
1383 volatile struct qdio_buffer_element *sbale;
1384 struct zfcp_port *port;
1385 struct zfcp_adapter *adapter;
1386 struct zfcp_fsf_req *fsf_req;
1387 unsigned long lock_flags;
1392 adapter = port->adapter;
1394 ret = zfcp_fsf_req_create(adapter, FSF_QTCB_SEND_GENERIC,
1395 ZFCP_WAIT_FOR_SBAL | ZFCP_REQ_AUTO_CLEANUP,
1396 pool, &lock_flags, &fsf_req);
1398 ZFCP_LOG_INFO("error: Could not create CT request (FC-GS) for "
1400 zfcp_get_busid_by_adapter(adapter));
1404 if (erp_action != NULL) {
1405 erp_action->fsf_req = fsf_req;
1406 fsf_req->erp_action = erp_action;
1409 sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0);
1410 if (zfcp_use_one_sbal(ct->req, ct->req_count,
1411 ct->resp, ct->resp_count)){
1412 /* both request buffer and response buffer
1413 fit into one sbale each */
1414 sbale[0].flags |= SBAL_FLAGS0_TYPE_WRITE_READ;
1415 sbale[2].addr = zfcp_sg_to_address(&ct->req[0]);
1416 sbale[2].length = ct->req[0].length;
1417 sbale[3].addr = zfcp_sg_to_address(&ct->resp[0]);
1418 sbale[3].length = ct->resp[0].length;
1419 sbale[3].flags |= SBAL_FLAGS_LAST_ENTRY;
1420 } else if (adapter->supported_features &
1421 FSF_FEATURE_ELS_CT_CHAINED_SBALS) {
1422 /* try to use chained SBALs */
1423 bytes = zfcp_qdio_sbals_from_sg(fsf_req,
1424 SBAL_FLAGS0_TYPE_WRITE_READ,
1425 ct->req, ct->req_count,
1426 ZFCP_MAX_SBALS_PER_CT_REQ);
1428 ZFCP_LOG_INFO("error: creation of CT request failed "
1430 zfcp_get_busid_by_adapter(adapter));
1438 fsf_req->qtcb->bottom.support.req_buf_length = bytes;
1439 fsf_req->sbale_curr = ZFCP_LAST_SBALE_PER_SBAL;
1440 bytes = zfcp_qdio_sbals_from_sg(fsf_req,
1441 SBAL_FLAGS0_TYPE_WRITE_READ,
1442 ct->resp, ct->resp_count,
1443 ZFCP_MAX_SBALS_PER_CT_REQ);
1445 ZFCP_LOG_INFO("error: creation of CT request failed "
1447 zfcp_get_busid_by_adapter(adapter));
1455 fsf_req->qtcb->bottom.support.resp_buf_length = bytes;
1457 /* reject send generic request */
1459 "error: microcode does not support chained SBALs,"
1460 "CT request too big (adapter %s)\n",
1461 zfcp_get_busid_by_adapter(adapter));
1466 /* settings in QTCB */
1467 fsf_req->qtcb->header.port_handle = port->handle;
1468 fsf_req->qtcb->bottom.support.service_class = adapter->fc_service_class;
1469 fsf_req->qtcb->bottom.support.timeout = ct->timeout;
1470 fsf_req->data.send_ct = ct;
1472 /* start QDIO request for this FSF request */
1473 ret = zfcp_fsf_req_send(fsf_req, ct->timer);
1475 ZFCP_LOG_DEBUG("error: initiation of CT request failed "
1476 "(adapter %s, port 0x%016Lx)\n",
1477 zfcp_get_busid_by_adapter(adapter), port->wwpn);
1481 ZFCP_LOG_DEBUG("CT request initiated (adapter %s, port 0x%016Lx)\n",
1482 zfcp_get_busid_by_adapter(adapter), port->wwpn);
1486 zfcp_fsf_req_free(fsf_req);
1487 if (erp_action != NULL) {
1488 erp_action->fsf_req = NULL;
1492 write_unlock_irqrestore(&adapter->request_queue.queue_lock,
1498 * zfcp_fsf_send_ct_handler - handler for Generic Service requests
1499 * @fsf_req: pointer to struct zfcp_fsf_req
1501 * Data specific for the Generic Service request is passed by
1502 * fsf_req->data.send_ct
1503 * Usually a specific handler for the request is called via
1504 * fsf_req->data.send_ct->handler at end of this function.
1507 zfcp_fsf_send_ct_handler(struct zfcp_fsf_req *fsf_req)
1509 struct zfcp_port *port;
1510 struct zfcp_adapter *adapter;
1511 struct zfcp_send_ct *send_ct;
1512 struct fsf_qtcb_header *header;
1513 struct fsf_qtcb_bottom_support *bottom;
1514 int retval = -EINVAL;
1515 u16 subtable, rule, counter;
1517 adapter = fsf_req->adapter;
1518 send_ct = fsf_req->data.send_ct;
1519 port = send_ct->port;
1520 header = &fsf_req->qtcb->header;
1521 bottom = &fsf_req->qtcb->bottom.support;
1523 if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) {
1524 /* do not set ZFCP_STATUS_FSFREQ_ABORTSUCCEEDED */
1525 goto skip_fsfstatus;
1528 /* evaluate FSF status in QTCB */
1529 switch (header->fsf_status) {
1532 ZFCP_LOG_FLAGS(2,"FSF_GOOD\n");
1536 case FSF_SERVICE_CLASS_NOT_SUPPORTED :
1537 ZFCP_LOG_FLAGS(2, "FSF_SERVICE_CLASS_NOT_SUPPORTED\n");
1538 if (adapter->fc_service_class <= 3) {
1539 ZFCP_LOG_INFO("error: adapter %s does not support fc "
1541 zfcp_get_busid_by_port(port),
1542 adapter->fc_service_class);
1544 ZFCP_LOG_INFO("bug: The fibre channel class at the "
1545 "adapter %s is invalid. "
1546 "(debug info %d)\n",
1547 zfcp_get_busid_by_port(port),
1548 adapter->fc_service_class);
1550 /* stop operation for this adapter */
1551 debug_text_exception(adapter->erp_dbf, 0, "fsf_s_class_nsup");
1552 zfcp_erp_adapter_shutdown(port->adapter, 0);
1553 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1556 case FSF_ADAPTER_STATUS_AVAILABLE :
1557 ZFCP_LOG_FLAGS(2, "FSF_ADAPTER_STATUS_AVAILABLE\n");
1558 switch (header->fsf_status_qual.word[0]){
1559 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE :
1560 ZFCP_LOG_FLAGS(2,"FSF_SQ_INVOKE_LINK_TEST_PROCEDURE\n");
1561 /* reopening link to port */
1562 debug_text_event(adapter->erp_dbf, 1, "fsf_sq_ltest");
1563 zfcp_test_link(port);
1564 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1566 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED :
1567 ZFCP_LOG_FLAGS(2,"FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED\n");
1568 /* ERP strategy will escalate */
1569 debug_text_event(adapter->erp_dbf, 1, "fsf_sq_ulp");
1570 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1573 ZFCP_LOG_INFO("bug: Wrong status qualifier 0x%x "
1575 header->fsf_status_qual.word[0]);
1580 case FSF_ACCESS_DENIED:
1581 ZFCP_LOG_FLAGS(2, "FSF_ACCESS_DENIED\n");
1582 ZFCP_LOG_NORMAL("Access denied, cannot send generic command "
1583 "to port 0x%016Lx on adapter %s\n", port->wwpn,
1584 zfcp_get_busid_by_port(port));
1585 for (counter = 0; counter < 2; counter++) {
1586 subtable = header->fsf_status_qual.halfword[counter * 2];
1587 rule = header->fsf_status_qual.halfword[counter * 2 + 1];
1589 case FSF_SQ_CFDC_SUBTABLE_OS:
1590 case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN:
1591 case FSF_SQ_CFDC_SUBTABLE_PORT_DID:
1592 case FSF_SQ_CFDC_SUBTABLE_LUN:
1593 ZFCP_LOG_INFO("Access denied (%s rule %d)\n",
1594 zfcp_act_subtable_type[subtable], rule);
1598 debug_text_event(fsf_req->adapter->erp_dbf, 1, "fsf_s_access");
1599 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1602 case FSF_GENERIC_COMMAND_REJECTED :
1603 ZFCP_LOG_FLAGS(2, "FSF_GENERIC_COMMAND_REJECTED\n");
1604 ZFCP_LOG_INFO("warning: The port 0x%016Lx on adapter %s has "
1605 "rejected a generic services command.\n",
1606 port->wwpn, zfcp_get_busid_by_port(port));
1607 ZFCP_LOG_INFO("status qualifier:\n");
1608 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_INFO,
1609 (char *) &header->fsf_status_qual,
1610 sizeof (union fsf_status_qual));
1611 debug_text_event(adapter->erp_dbf, 1, "fsf_s_gcom_rej");
1612 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1615 case FSF_PORT_HANDLE_NOT_VALID :
1616 ZFCP_LOG_FLAGS(2, "FSF_PORT_HANDLE_NOT_VALID\n");
1617 ZFCP_LOG_DEBUG("Temporary port identifier 0x%x for port "
1618 "0x%016Lx on adapter %s invalid. This may "
1619 "happen occasionally.\n", port->handle,
1620 port->wwpn, zfcp_get_busid_by_port(port));
1621 ZFCP_LOG_INFO("status qualifier:\n");
1622 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_INFO,
1623 (char *) &header->fsf_status_qual,
1624 sizeof (union fsf_status_qual));
1625 debug_text_event(adapter->erp_dbf, 1, "fsf_s_phandle_nv");
1626 zfcp_erp_adapter_reopen(port->adapter, 0);
1627 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1630 case FSF_PORT_BOXED :
1631 ZFCP_LOG_FLAGS(2, "FSF_PORT_BOXED\n");
1632 ZFCP_LOG_INFO("The remote port 0x%016Lx on adapter %s "
1633 "needs to be reopened\n",
1634 port->wwpn, zfcp_get_busid_by_port(port));
1635 debug_text_event(adapter->erp_dbf, 2, "fsf_s_pboxed");
1636 zfcp_erp_port_reopen(port, 0);
1637 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR
1638 | ZFCP_STATUS_FSFREQ_RETRY;
1642 ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
1643 "(debug info 0x%x)\n", header->fsf_status);
1644 debug_text_event(adapter->erp_dbf, 0, "fsf_sq_inval:");
1645 debug_exception(adapter->erp_dbf, 0,
1646 &header->fsf_status_qual.word[0], sizeof (u32));
1651 send_ct->status = retval;
1653 if (send_ct->handler != NULL)
1654 send_ct->handler(send_ct->handler_data);
1660 * zfcp_fsf_send_els - initiate an ELS command (FC-FS)
1661 * @els: pointer to struct zfcp_send_els which contains all needed data for
1665 zfcp_fsf_send_els(struct zfcp_send_els *els)
1667 volatile struct qdio_buffer_element *sbale;
1668 struct zfcp_fsf_req *fsf_req;
1669 struct zfcp_port *port;
1670 struct zfcp_adapter *adapter;
1671 unsigned long lock_flags;
1676 adapter = port->adapter;
1678 ret = zfcp_fsf_req_create(adapter, FSF_QTCB_SEND_ELS,
1679 ZFCP_WAIT_FOR_SBAL|ZFCP_REQ_AUTO_CLEANUP,
1680 NULL, &lock_flags, &fsf_req);
1682 ZFCP_LOG_INFO("error: creation of ELS request failed "
1683 "(adapter %s, port d_id: 0x%08x)\n",
1684 zfcp_get_busid_by_adapter(adapter), port->d_id);
1688 sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0);
1689 if (zfcp_use_one_sbal(els->req, els->req_count,
1690 els->resp, els->resp_count)){
1691 /* both request buffer and response buffer
1692 fit into one sbale each */
1693 sbale[0].flags |= SBAL_FLAGS0_TYPE_WRITE_READ;
1694 sbale[2].addr = zfcp_sg_to_address(&els->req[0]);
1695 sbale[2].length = els->req[0].length;
1696 sbale[3].addr = zfcp_sg_to_address(&els->resp[0]);
1697 sbale[3].length = els->resp[0].length;
1698 sbale[3].flags |= SBAL_FLAGS_LAST_ENTRY;
1699 } else if (adapter->supported_features &
1700 FSF_FEATURE_ELS_CT_CHAINED_SBALS) {
1701 /* try to use chained SBALs */
1702 bytes = zfcp_qdio_sbals_from_sg(fsf_req,
1703 SBAL_FLAGS0_TYPE_WRITE_READ,
1704 els->req, els->req_count,
1705 ZFCP_MAX_SBALS_PER_ELS_REQ);
1707 ZFCP_LOG_INFO("error: creation of ELS request failed "
1708 "(adapter %s, port d_id: 0x%08x)\n",
1709 zfcp_get_busid_by_adapter(adapter),
1718 fsf_req->qtcb->bottom.support.req_buf_length = bytes;
1719 fsf_req->sbale_curr = ZFCP_LAST_SBALE_PER_SBAL;
1720 bytes = zfcp_qdio_sbals_from_sg(fsf_req,
1721 SBAL_FLAGS0_TYPE_WRITE_READ,
1722 els->resp, els->resp_count,
1723 ZFCP_MAX_SBALS_PER_ELS_REQ);
1725 ZFCP_LOG_INFO("error: creation of ELS request failed "
1726 "(adapter %s, port d_id: 0x%08x)\n",
1727 zfcp_get_busid_by_adapter(adapter),
1736 fsf_req->qtcb->bottom.support.resp_buf_length = bytes;
1738 /* reject request */
1739 ZFCP_LOG_INFO("error: microcode does not support chained SBALs"
1740 ", ELS request too big (adapter %s, "
1741 "port d_id: 0x%08x)\n",
1742 zfcp_get_busid_by_adapter(adapter), port->d_id);
1747 /* settings in QTCB */
1748 fsf_req->qtcb->bottom.support.d_id = port->d_id;
1749 fsf_req->qtcb->bottom.support.service_class = adapter->fc_service_class;
1750 fsf_req->qtcb->bottom.support.timeout = ZFCP_ELS_TIMEOUT;
1751 fsf_req->data.send_els = els;
1753 sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0);
1755 /* start QDIO request for this FSF request */
1756 ret = zfcp_fsf_req_send(fsf_req, els->timer);
1758 ZFCP_LOG_DEBUG("error: initiation of ELS request failed "
1759 "(adapter %s, port 0x%016Lx)\n",
1760 zfcp_get_busid_by_adapter(adapter), port->wwpn);
1764 ZFCP_LOG_DEBUG("ELS request initiated (adapter %s, port 0x%016Lx)\n",
1765 zfcp_get_busid_by_adapter(adapter), port->wwpn);
1769 zfcp_fsf_req_free(fsf_req);
1773 write_unlock_irqrestore(&adapter->request_queue.queue_lock,
1780 * zfcp_fsf_send_els_handler - handler for ELS commands
1781 * @fsf_req: pointer to struct zfcp_fsf_req
1783 * Data specific for the ELS command is passed by
1784 * fsf_req->data.send_els
1785 * Usually a specific handler for the command is called via
1786 * fsf_req->data.send_els->handler at end of this function.
1788 static int zfcp_fsf_send_els_handler(struct zfcp_fsf_req *fsf_req)
1790 struct zfcp_adapter *adapter;
1791 struct zfcp_port *port;
1792 struct fsf_qtcb_header *header;
1793 struct fsf_qtcb_bottom_support *bottom;
1794 struct zfcp_send_els *send_els;
1795 int retval = -EINVAL;
1796 u16 subtable, rule, counter;
1798 adapter = fsf_req->adapter;
1799 send_els = fsf_req->data.send_els;
1800 port = send_els->port;
1801 header = &fsf_req->qtcb->header;
1802 bottom = &fsf_req->qtcb->bottom.support;
1804 if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR)
1805 goto skip_fsfstatus;
1807 switch (header->fsf_status) {
1810 ZFCP_LOG_FLAGS(2, "FSF_GOOD\n");
1814 case FSF_SERVICE_CLASS_NOT_SUPPORTED:
1815 ZFCP_LOG_FLAGS(2, "FSF_SERVICE_CLASS_NOT_SUPPORTED\n");
1816 if (adapter->fc_service_class <= 3) {
1817 ZFCP_LOG_INFO("error: adapter %s does "
1818 "not support fibrechannel class %d.\n",
1819 zfcp_get_busid_by_port(port),
1820 adapter->fc_service_class);
1822 ZFCP_LOG_INFO("bug: The fibrechannel class at "
1823 "adapter %s is invalid. "
1824 "(debug info %d)\n",
1825 zfcp_get_busid_by_port(port),
1826 adapter->fc_service_class);
1828 /* stop operation for this adapter */
1829 debug_text_exception(adapter->erp_dbf, 0, "fsf_s_class_nsup");
1830 zfcp_erp_adapter_shutdown(port->adapter, 0);
1831 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1834 case FSF_ADAPTER_STATUS_AVAILABLE:
1835 ZFCP_LOG_FLAGS(2, "FSF_ADAPTER_STATUS_AVAILABLE\n");
1836 switch (header->fsf_status_qual.word[0]){
1837 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE: {
1838 ZFCP_LOG_FLAGS(2,"FSF_SQ_INVOKE_LINK_TEST_PROCEDURE\n");
1839 debug_text_event(adapter->erp_dbf, 1, "fsf_sq_ltest");
1840 if (send_els->ls_code != ZFCP_LS_ADISC)
1841 zfcp_test_link(port);
1842 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1845 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
1846 ZFCP_LOG_FLAGS(2,"FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED\n");
1847 /* ERP strategy will escalate */
1848 debug_text_event(adapter->erp_dbf, 1, "fsf_sq_ulp");
1849 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1851 zfcp_handle_els_rjt(header->fsf_status_qual.word[1],
1852 (struct zfcp_ls_rjt_par *)
1853 &header->fsf_status_qual.word[2]);
1855 case FSF_SQ_RETRY_IF_POSSIBLE:
1856 ZFCP_LOG_FLAGS(2, "FSF_SQ_RETRY_IF_POSSIBLE\n");
1857 debug_text_event(adapter->erp_dbf, 1, "fsf_sq_retry");
1858 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1861 ZFCP_LOG_INFO("bug: Wrong status qualifier 0x%x\n",
1862 header->fsf_status_qual.word[0]);
1863 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_INFO,
1864 (char*)header->fsf_status_qual.word, 16);
1868 case FSF_ELS_COMMAND_REJECTED:
1869 ZFCP_LOG_FLAGS(2, "FSF_ELS_COMMAND_REJECTED\n");
1870 ZFCP_LOG_INFO("ELS has been rejected because command filter "
1871 "prohibited sending "
1872 "(adapter: %s, wwpn=0x%016Lx)\n",
1873 zfcp_get_busid_by_port(port), port->wwpn);
1877 case FSF_PAYLOAD_SIZE_MISMATCH:
1878 ZFCP_LOG_FLAGS(2, "FSF_PAYLOAD_SIZE_MISMATCH\n");
1880 "ELS request size and ELS response size must be either "
1881 "both 0, or both greater than 0 "
1882 "(adapter: %s, req_buf_length=%d resp_buf_length=%d)\n",
1883 zfcp_get_busid_by_port(port),
1884 bottom->req_buf_length,
1885 bottom->resp_buf_length);
1888 case FSF_REQUEST_SIZE_TOO_LARGE:
1889 ZFCP_LOG_FLAGS(2, "FSF_REQUEST_SIZE_TOO_LARGE\n");
1891 "Length of the ELS request buffer, "
1892 "specified in QTCB bottom, "
1893 "exceeds the size of the buffers "
1894 "that have been allocated for ELS request data "
1895 "(adapter: %s, req_buf_length=%d)\n",
1896 zfcp_get_busid_by_port(port),
1897 bottom->req_buf_length);
1900 case FSF_RESPONSE_SIZE_TOO_LARGE:
1901 ZFCP_LOG_FLAGS(2, "FSF_RESPONSE_SIZE_TOO_LARGE\n");
1903 "Length of the ELS response buffer, "
1904 "specified in QTCB bottom, "
1905 "exceeds the size of the buffers "
1906 "that have been allocated for ELS response data "
1907 "(adapter: %s, resp_buf_length=%d)\n",
1908 zfcp_get_busid_by_port(port),
1909 bottom->resp_buf_length);
1912 case FSF_ACCESS_DENIED:
1913 ZFCP_LOG_FLAGS(2, "FSF_ACCESS_DENIED\n");
1914 ZFCP_LOG_NORMAL("Access denied, cannot send ELS "
1915 "(adapter: %s, wwpn=0x%016Lx)\n",
1916 zfcp_get_busid_by_port(port), port->wwpn);
1917 for (counter = 0; counter < 2; counter++) {
1918 subtable = header->fsf_status_qual.halfword[counter * 2];
1919 rule = header->fsf_status_qual.halfword[counter * 2 + 1];
1921 case FSF_SQ_CFDC_SUBTABLE_OS:
1922 case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN:
1923 case FSF_SQ_CFDC_SUBTABLE_PORT_DID:
1924 case FSF_SQ_CFDC_SUBTABLE_LUN:
1925 ZFCP_LOG_INFO("Access denied (%s rule %d)\n",
1926 zfcp_act_subtable_type[subtable], rule);
1930 debug_text_event(adapter->erp_dbf, 1, "fsf_s_access");
1931 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1936 "bug: An unknown FSF Status was presented "
1937 "(adapter: %s, fsf_status=0x%08x)\n",
1938 zfcp_get_busid_by_port(port),
1939 header->fsf_status);
1940 debug_text_event(adapter->erp_dbf, 0, "fsf_sq_inval");
1941 debug_exception(adapter->erp_dbf, 0,
1942 &header->fsf_status_qual.word[0], sizeof(u32));
1943 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1948 send_els->status = retval;
1950 if (send_els->handler != 0)
1951 send_els->handler(send_els->handler_data);
1961 * returns: address of initiated FSF request
1962 * NULL - request could not be initiated
1965 zfcp_fsf_exchange_config_data(struct zfcp_erp_action *erp_action)
1967 volatile struct qdio_buffer_element *sbale;
1968 unsigned long lock_flags;
1971 /* setup new FSF request */
1972 retval = zfcp_fsf_req_create(erp_action->adapter,
1973 FSF_QTCB_EXCHANGE_CONFIG_DATA,
1974 ZFCP_REQ_AUTO_CLEANUP,
1975 erp_action->adapter->pool.fsf_req_erp,
1976 &lock_flags, &(erp_action->fsf_req));
1978 ZFCP_LOG_INFO("error: Could not create exchange configuration "
1979 "data request for adapter %s.\n",
1980 zfcp_get_busid_by_adapter(erp_action->adapter));
1984 sbale = zfcp_qdio_sbale_req(erp_action->fsf_req,
1985 erp_action->fsf_req->sbal_curr, 0);
1986 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
1987 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
1989 erp_action->fsf_req->erp_action = erp_action;
1990 erp_action->fsf_req->qtcb->bottom.config.feature_selection =
1993 /* start QDIO request for this FSF request */
1994 retval = zfcp_fsf_req_send(erp_action->fsf_req, &erp_action->timer);
1997 ("error: Could not send exchange configuration data "
1998 "command on the adapter %s\n",
1999 zfcp_get_busid_by_adapter(erp_action->adapter));
2000 zfcp_fsf_req_free(erp_action->fsf_req);
2001 erp_action->fsf_req = NULL;
2005 ZFCP_LOG_DEBUG("exchange configuration data request initiated "
2007 zfcp_get_busid_by_adapter(erp_action->adapter));
2010 write_unlock_irqrestore(&erp_action->adapter->request_queue.queue_lock,
2016 * zfcp_fsf_exchange_config_evaluate
2017 * @fsf_req: fsf_req which belongs to xchg config data request
2018 * @xchg_ok: specifies if xchg config data was incomplete or complete (0/1)
2020 * returns: -EIO on error, 0 otherwise
2023 zfcp_fsf_exchange_config_evaluate(struct zfcp_fsf_req *fsf_req, int xchg_ok)
2025 struct fsf_qtcb_bottom_config *bottom;
2026 struct zfcp_adapter *adapter = fsf_req->adapter;
2028 bottom = &fsf_req->qtcb->bottom.config;
2029 ZFCP_LOG_DEBUG("low/high QTCB version 0x%x/0x%x of FSF\n",
2030 bottom->low_qtcb_version, bottom->high_qtcb_version);
2031 adapter->fsf_lic_version = bottom->lic_version;
2032 adapter->supported_features = bottom->supported_features;
2035 adapter->wwnn = bottom->nport_serv_param.wwnn;
2036 adapter->wwpn = bottom->nport_serv_param.wwpn;
2037 adapter->s_id = bottom->s_id & ZFCP_DID_MASK;
2038 adapter->fc_topology = bottom->fc_topology;
2039 adapter->fc_link_speed = bottom->fc_link_speed;
2040 adapter->hydra_version = bottom->adapter_type;
2045 adapter->fc_topology = 0;
2046 adapter->fc_link_speed = 0;
2047 adapter->hydra_version = 0;
2050 if(adapter->supported_features & FSF_FEATURE_HBAAPI_MANAGEMENT){
2051 adapter->hardware_version = bottom->hardware_version;
2052 memcpy(adapter->serial_number, bottom->serial_number, 17);
2053 EBCASC(adapter->serial_number, sizeof(adapter->serial_number));
2056 ZFCP_LOG_INFO("The adapter %s reported the following characteristics:\n"
2060 "adapter version 0x%x, "
2061 "LIC version 0x%x, "
2062 "FC link speed %d Gb/s\n",
2063 zfcp_get_busid_by_adapter(adapter),
2066 (unsigned int) adapter->s_id,
2067 adapter->hydra_version,
2068 adapter->fsf_lic_version,
2069 adapter->fc_link_speed);
2070 if (ZFCP_QTCB_VERSION < bottom->low_qtcb_version) {
2071 ZFCP_LOG_NORMAL("error: the adapter %s "
2072 "only supports newer control block "
2073 "versions in comparison to this device "
2074 "driver (try updated device driver)\n",
2075 zfcp_get_busid_by_adapter(adapter));
2076 debug_text_event(adapter->erp_dbf, 0, "low_qtcb_ver");
2077 zfcp_erp_adapter_shutdown(adapter, 0);
2080 if (ZFCP_QTCB_VERSION > bottom->high_qtcb_version) {
2081 ZFCP_LOG_NORMAL("error: the adapter %s "
2082 "only supports older control block "
2083 "versions than this device driver uses"
2084 "(consider a microcode upgrade)\n",
2085 zfcp_get_busid_by_adapter(adapter));
2086 debug_text_event(adapter->erp_dbf, 0, "high_qtcb_ver");
2087 zfcp_erp_adapter_shutdown(adapter, 0);
2094 * function: zfcp_fsf_exchange_config_data_handler
2096 * purpose: is called for finished Exchange Configuration Data command
2101 zfcp_fsf_exchange_config_data_handler(struct zfcp_fsf_req *fsf_req)
2103 struct fsf_qtcb_bottom_config *bottom;
2104 struct zfcp_adapter *adapter = fsf_req->adapter;
2106 if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR)
2109 switch (fsf_req->qtcb->header.fsf_status) {
2112 ZFCP_LOG_FLAGS(2, "FSF_GOOD\n");
2114 if (zfcp_fsf_exchange_config_evaluate(fsf_req, 1))
2117 switch (adapter->fc_topology) {
2119 ZFCP_LOG_FLAGS(1, "FSF_TOPO_P2P\n");
2120 ZFCP_LOG_NORMAL("error: Point-to-point fibrechannel "
2121 "configuration detected at adapter %s "
2122 "unsupported, shutting down adapter\n",
2123 zfcp_get_busid_by_adapter(adapter));
2124 debug_text_event(fsf_req->adapter->erp_dbf, 0,
2126 zfcp_erp_adapter_shutdown(adapter, 0);
2129 ZFCP_LOG_FLAGS(1, "FSF_TOPO_AL\n");
2130 ZFCP_LOG_NORMAL("error: Arbitrated loop fibrechannel "
2131 "topology detected at adapter %s "
2132 "unsupported, shutting down adapter\n",
2133 zfcp_get_busid_by_adapter(adapter));
2134 debug_text_event(fsf_req->adapter->erp_dbf, 0,
2136 zfcp_erp_adapter_shutdown(adapter, 0);
2138 case FSF_TOPO_FABRIC:
2139 ZFCP_LOG_FLAGS(1, "FSF_TOPO_FABRIC\n");
2140 ZFCP_LOG_INFO("Switched fabric fibrechannel "
2141 "network detected at adapter %s.\n",
2142 zfcp_get_busid_by_adapter(adapter));
2145 ZFCP_LOG_NORMAL("bug: The fibrechannel topology "
2146 "reported by the exchange "
2147 "configuration command for "
2148 "the adapter %s is not "
2149 "of a type known to the zfcp "
2150 "driver, shutting down adapter\n",
2151 zfcp_get_busid_by_adapter(adapter));
2152 debug_text_exception(fsf_req->adapter->erp_dbf, 0,
2154 zfcp_erp_adapter_shutdown(adapter, 0);
2157 bottom = &fsf_req->qtcb->bottom.config;
2158 if (bottom->max_qtcb_size < sizeof(struct fsf_qtcb)) {
2159 ZFCP_LOG_NORMAL("bug: Maximum QTCB size (%d bytes) "
2160 "allowed by the adapter %s "
2161 "is lower than the minimum "
2162 "required by the driver (%ld bytes).\n",
2163 bottom->max_qtcb_size,
2164 zfcp_get_busid_by_adapter(adapter),
2165 sizeof(struct fsf_qtcb));
2166 debug_text_event(fsf_req->adapter->erp_dbf, 0,
2168 debug_event(fsf_req->adapter->erp_dbf, 0,
2169 &bottom->max_qtcb_size, sizeof (u32));
2170 zfcp_erp_adapter_shutdown(adapter, 0);
2173 atomic_set_mask(ZFCP_STATUS_ADAPTER_XCONFIG_OK,
2176 case FSF_EXCHANGE_CONFIG_DATA_INCOMPLETE:
2177 debug_text_event(adapter->erp_dbf, 0, "xchg-inco");
2179 if (zfcp_fsf_exchange_config_evaluate(fsf_req, 0))
2182 ZFCP_LOG_INFO("Local link to adapter %s is down\n",
2183 zfcp_get_busid_by_adapter(adapter));
2184 atomic_set_mask(ZFCP_STATUS_ADAPTER_XCONFIG_OK |
2185 ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED,
2187 zfcp_erp_adapter_failed(adapter);
2190 debug_text_event(fsf_req->adapter->erp_dbf, 0, "fsf-stat-ng");
2191 debug_event(fsf_req->adapter->erp_dbf, 0,
2192 &fsf_req->qtcb->header.fsf_status, sizeof (u32));
2193 zfcp_erp_adapter_shutdown(adapter, 0);
2200 * zfcp_fsf_exchange_port_data - request information about local port
2201 * @adapter: for which port data is requested
2202 * @data: response to exchange port data request
2205 zfcp_fsf_exchange_port_data(struct zfcp_adapter *adapter,
2206 struct fsf_qtcb_bottom_port *data)
2208 volatile struct qdio_buffer_element *sbale;
2210 unsigned long lock_flags;
2211 struct zfcp_fsf_req *fsf_req;
2212 struct timer_list *timer;
2214 if(!(adapter->supported_features & FSF_FEATURE_HBAAPI_MANAGEMENT)){
2215 ZFCP_LOG_INFO("error: exchange port data "
2216 "command not supported by adapter %s\n",
2217 zfcp_get_busid_by_adapter(adapter));
2221 timer = kmalloc(sizeof(struct timer_list), GFP_KERNEL);
2225 /* setup new FSF request */
2226 retval = zfcp_fsf_req_create(adapter, FSF_QTCB_EXCHANGE_PORT_DATA,
2227 0, 0, &lock_flags, &fsf_req);
2229 ZFCP_LOG_INFO("error: Out of resources. Could not create an "
2230 "exchange port data request for"
2231 "the adapter %s.\n",
2232 zfcp_get_busid_by_adapter(adapter));
2233 write_unlock_irqrestore(&adapter->request_queue.queue_lock,
2238 sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0);
2239 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
2240 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
2242 fsf_req->data.port_data = data;
2245 timer->function = zfcp_fsf_request_timeout_handler;
2246 timer->data = (unsigned long) adapter;
2247 timer->expires = ZFCP_FSF_REQUEST_TIMEOUT;
2249 retval = zfcp_fsf_req_send(fsf_req, timer);
2251 ZFCP_LOG_INFO("error: Could not send an exchange port data "
2252 "command on the adapter %s\n",
2253 zfcp_get_busid_by_adapter(adapter));
2254 zfcp_fsf_req_free(fsf_req);
2255 write_unlock_irqrestore(&adapter->request_queue.queue_lock,
2260 ZFCP_LOG_DEBUG("Exchange Port Data request initiated (adapter %s)\n",
2261 zfcp_get_busid_by_adapter(adapter));
2263 write_unlock_irqrestore(&adapter->request_queue.queue_lock,
2266 wait_event(fsf_req->completion_wq,
2267 fsf_req->status & ZFCP_STATUS_FSFREQ_COMPLETED);
2268 del_timer_sync(timer);
2269 zfcp_fsf_req_cleanup(fsf_req);
2277 * zfcp_fsf_exchange_port_data_handler - handler for exchange_port_data request
2278 * @fsf_req: pointer to struct zfcp_fsf_req
2281 zfcp_fsf_exchange_port_data_handler(struct zfcp_fsf_req *fsf_req)
2283 struct fsf_qtcb_bottom_port *bottom;
2284 struct fsf_qtcb_bottom_port *data = fsf_req->data.port_data;
2286 if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR)
2289 switch (fsf_req->qtcb->header.fsf_status) {
2291 ZFCP_LOG_FLAGS(2,"FSF_GOOD\n");
2292 bottom = &fsf_req->qtcb->bottom.port;
2293 memcpy(data, bottom, sizeof(*data));
2297 debug_text_event(fsf_req->adapter->erp_dbf, 0, "xchg-port-ng");
2298 debug_event(fsf_req->adapter->erp_dbf, 0,
2299 &fsf_req->qtcb->header.fsf_status, sizeof(u32));
2305 * function: zfcp_fsf_open_port
2309 * returns: address of initiated FSF request
2310 * NULL - request could not be initiated
2313 zfcp_fsf_open_port(struct zfcp_erp_action *erp_action)
2315 volatile struct qdio_buffer_element *sbale;
2316 unsigned long lock_flags;
2319 /* setup new FSF request */
2320 retval = zfcp_fsf_req_create(erp_action->adapter,
2321 FSF_QTCB_OPEN_PORT_WITH_DID,
2322 ZFCP_WAIT_FOR_SBAL | ZFCP_REQ_AUTO_CLEANUP,
2323 erp_action->adapter->pool.fsf_req_erp,
2324 &lock_flags, &(erp_action->fsf_req));
2326 ZFCP_LOG_INFO("error: Could not create open port request "
2327 "for port 0x%016Lx on adapter %s.\n",
2328 erp_action->port->wwpn,
2329 zfcp_get_busid_by_adapter(erp_action->adapter));
2333 sbale = zfcp_qdio_sbale_req(erp_action->fsf_req,
2334 erp_action->fsf_req->sbal_curr, 0);
2335 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
2336 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
2338 erp_action->fsf_req->qtcb->bottom.support.d_id = erp_action->port->d_id;
2339 atomic_set_mask(ZFCP_STATUS_COMMON_OPENING, &erp_action->port->status);
2340 erp_action->fsf_req->data.open_port.port = erp_action->port;
2341 erp_action->fsf_req->erp_action = erp_action;
2343 /* start QDIO request for this FSF request */
2344 retval = zfcp_fsf_req_send(erp_action->fsf_req, &erp_action->timer);
2346 ZFCP_LOG_INFO("error: Could not send open port request for "
2347 "port 0x%016Lx on adapter %s.\n",
2348 erp_action->port->wwpn,
2349 zfcp_get_busid_by_adapter(erp_action->adapter));
2350 zfcp_fsf_req_free(erp_action->fsf_req);
2351 erp_action->fsf_req = NULL;
2355 ZFCP_LOG_DEBUG("open port request initiated "
2356 "(adapter %s, port 0x%016Lx)\n",
2357 zfcp_get_busid_by_adapter(erp_action->adapter),
2358 erp_action->port->wwpn);
2360 write_unlock_irqrestore(&erp_action->adapter->request_queue.queue_lock,
2366 * function: zfcp_fsf_open_port_handler
2368 * purpose: is called for finished Open Port command
2373 zfcp_fsf_open_port_handler(struct zfcp_fsf_req *fsf_req)
2375 int retval = -EINVAL;
2376 struct zfcp_port *port;
2377 struct fsf_plogi *plogi;
2378 struct fsf_qtcb_header *header;
2379 u16 subtable, rule, counter;
2381 port = fsf_req->data.open_port.port;
2382 header = &fsf_req->qtcb->header;
2384 if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) {
2385 /* don't change port status in our bookkeeping */
2386 goto skip_fsfstatus;
2389 /* evaluate FSF status in QTCB */
2390 switch (header->fsf_status) {
2392 case FSF_PORT_ALREADY_OPEN:
2393 ZFCP_LOG_FLAGS(0, "FSF_PORT_ALREADY_OPEN\n");
2394 ZFCP_LOG_NORMAL("bug: remote port 0x%016Lx on adapter %s "
2395 "is already open.\n",
2396 port->wwpn, zfcp_get_busid_by_port(port));
2397 debug_text_exception(fsf_req->adapter->erp_dbf, 0,
2400 * This is a bug, however operation should continue normally
2401 * if it is simply ignored
2405 case FSF_ACCESS_DENIED:
2406 ZFCP_LOG_FLAGS(2, "FSF_ACCESS_DENIED\n");
2407 ZFCP_LOG_NORMAL("Access denied, cannot open port 0x%016Lx "
2409 port->wwpn, zfcp_get_busid_by_port(port));
2410 for (counter = 0; counter < 2; counter++) {
2411 subtable = header->fsf_status_qual.halfword[counter * 2];
2412 rule = header->fsf_status_qual.halfword[counter * 2 + 1];
2414 case FSF_SQ_CFDC_SUBTABLE_OS:
2415 case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN:
2416 case FSF_SQ_CFDC_SUBTABLE_PORT_DID:
2417 case FSF_SQ_CFDC_SUBTABLE_LUN:
2418 ZFCP_LOG_INFO("Access denied (%s rule %d)\n",
2419 zfcp_act_subtable_type[subtable], rule);
2423 debug_text_event(fsf_req->adapter->erp_dbf, 1, "fsf_s_access");
2424 zfcp_erp_port_failed(port);
2425 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
2428 case FSF_MAXIMUM_NUMBER_OF_PORTS_EXCEEDED:
2429 ZFCP_LOG_FLAGS(1, "FSF_MAXIMUM_NUMBER_OF_PORTS_EXCEEDED\n");
2430 ZFCP_LOG_INFO("error: The FSF adapter is out of resources. "
2431 "The remote port 0x%016Lx on adapter %s "
2432 "could not be opened. Disabling it.\n",
2433 port->wwpn, zfcp_get_busid_by_port(port));
2434 debug_text_event(fsf_req->adapter->erp_dbf, 1,
2436 zfcp_erp_port_failed(port);
2437 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
2440 case FSF_ADAPTER_STATUS_AVAILABLE:
2441 ZFCP_LOG_FLAGS(2, "FSF_ADAPTER_STATUS_AVAILABLE\n");
2442 switch (header->fsf_status_qual.word[0]) {
2443 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
2445 "FSF_SQ_INVOKE_LINK_TEST_PROCEDURE\n");
2446 debug_text_event(fsf_req->adapter->erp_dbf, 1,
2448 /* ERP strategy will escalate */
2449 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
2451 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
2452 /* ERP strategy will escalate */
2453 debug_text_event(fsf_req->adapter->erp_dbf, 1,
2455 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
2457 case FSF_SQ_NO_RETRY_POSSIBLE:
2458 ZFCP_LOG_FLAGS(0, "FSF_SQ_NO_RETRY_POSSIBLE\n");
2459 ZFCP_LOG_NORMAL("The remote port 0x%016Lx on "
2460 "adapter %s could not be opened. "
2463 zfcp_get_busid_by_port(port));
2464 debug_text_exception(fsf_req->adapter->erp_dbf, 0,
2466 zfcp_erp_port_failed(port);
2467 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
2471 ("bug: Wrong status qualifier 0x%x arrived.\n",
2472 header->fsf_status_qual.word[0]);
2473 debug_text_event(fsf_req->adapter->erp_dbf, 0,
2476 fsf_req->adapter->erp_dbf, 0,
2477 &header->fsf_status_qual.word[0],
2484 ZFCP_LOG_FLAGS(3, "FSF_GOOD\n");
2485 /* save port handle assigned by FSF */
2486 port->handle = header->port_handle;
2487 ZFCP_LOG_INFO("The remote port 0x%016Lx via adapter %s "
2488 "was opened, it's port handle is 0x%x\n",
2489 port->wwpn, zfcp_get_busid_by_port(port),
2491 /* mark port as open */
2492 atomic_set_mask(ZFCP_STATUS_COMMON_OPEN |
2493 ZFCP_STATUS_PORT_PHYS_OPEN, &port->status);
2495 /* check whether D_ID has changed during open */
2497 * FIXME: This check is not airtight, as the FCP channel does
2498 * not monitor closures of target port connections caused on
2499 * the remote side. Thus, they might miss out on invalidating
2500 * locally cached WWPNs (and other N_Port parameters) of gone
2501 * target ports. So, our heroic attempt to make things safe
2502 * could be undermined by 'open port' response data tagged with
2503 * obsolete WWPNs. Another reason to monitor potential
2504 * connection closures ourself at least (by interpreting
2505 * incoming ELS' and unsolicited status). It just crosses my
2506 * mind that one should be able to cross-check by means of
2507 * another GID_PN straight after a port has been opened.
2508 * Alternately, an ADISC/PDISC ELS should suffice, as well.
2510 plogi = (struct fsf_plogi *) fsf_req->qtcb->bottom.support.els;
2511 if (!atomic_test_mask(ZFCP_STATUS_PORT_NO_WWPN, &port->status))
2513 if (fsf_req->qtcb->bottom.support.els1_length <
2514 ((((unsigned long) &plogi->serv_param.wwpn) -
2515 ((unsigned long) plogi)) + sizeof (u64))) {
2517 "warning: insufficient length of "
2518 "PLOGI payload (%i)\n",
2519 fsf_req->qtcb->bottom.support.els1_length);
2520 debug_text_event(fsf_req->adapter->erp_dbf, 0,
2521 "fsf_s_short_plogi:");
2522 /* skip sanity check and assume wwpn is ok */
2524 if (plogi->serv_param.wwpn != port->wwpn) {
2525 ZFCP_LOG_INFO("warning: d_id of port "
2526 "0x%016Lx changed during "
2527 "open\n", port->wwpn);
2529 fsf_req->adapter->erp_dbf, 0,
2530 "fsf_s_did_change:");
2532 ZFCP_STATUS_PORT_DID_DID,
2535 port->wwnn = plogi->serv_param.wwnn;
2541 ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
2542 "(debug info 0x%x)\n",
2543 header->fsf_status);
2544 debug_text_event(fsf_req->adapter->erp_dbf, 0, "fsf_s_inval:");
2545 debug_exception(fsf_req->adapter->erp_dbf, 0,
2546 &header->fsf_status, sizeof (u32));
2551 atomic_clear_mask(ZFCP_STATUS_COMMON_OPENING, &port->status);
2556 * function: zfcp_fsf_close_port
2558 * purpose: submit FSF command "close port"
2560 * returns: address of initiated FSF request
2561 * NULL - request could not be initiated
2564 zfcp_fsf_close_port(struct zfcp_erp_action *erp_action)
2566 volatile struct qdio_buffer_element *sbale;
2567 unsigned long lock_flags;
2570 /* setup new FSF request */
2571 retval = zfcp_fsf_req_create(erp_action->adapter,
2572 FSF_QTCB_CLOSE_PORT,
2573 ZFCP_WAIT_FOR_SBAL | ZFCP_REQ_AUTO_CLEANUP,
2574 erp_action->adapter->pool.fsf_req_erp,
2575 &lock_flags, &(erp_action->fsf_req));
2577 ZFCP_LOG_INFO("error: Could not create a close port request "
2578 "for port 0x%016Lx on adapter %s.\n",
2579 erp_action->port->wwpn,
2580 zfcp_get_busid_by_adapter(erp_action->adapter));
2584 sbale = zfcp_qdio_sbale_req(erp_action->fsf_req,
2585 erp_action->fsf_req->sbal_curr, 0);
2586 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
2587 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
2589 atomic_set_mask(ZFCP_STATUS_COMMON_CLOSING, &erp_action->port->status);
2590 erp_action->fsf_req->data.close_port.port = erp_action->port;
2591 erp_action->fsf_req->erp_action = erp_action;
2592 erp_action->fsf_req->qtcb->header.port_handle =
2593 erp_action->port->handle;
2595 /* start QDIO request for this FSF request */
2596 retval = zfcp_fsf_req_send(erp_action->fsf_req, &erp_action->timer);
2598 ZFCP_LOG_INFO("error: Could not send a close port request for "
2599 "port 0x%016Lx on adapter %s.\n",
2600 erp_action->port->wwpn,
2601 zfcp_get_busid_by_adapter(erp_action->adapter));
2602 zfcp_fsf_req_free(erp_action->fsf_req);
2603 erp_action->fsf_req = NULL;
2607 ZFCP_LOG_TRACE("close port request initiated "
2608 "(adapter %s, port 0x%016Lx)\n",
2609 zfcp_get_busid_by_adapter(erp_action->adapter),
2610 erp_action->port->wwpn);
2612 write_unlock_irqrestore(&erp_action->adapter->request_queue.queue_lock,
2618 * function: zfcp_fsf_close_port_handler
2620 * purpose: is called for finished Close Port FSF command
2625 zfcp_fsf_close_port_handler(struct zfcp_fsf_req *fsf_req)
2627 int retval = -EINVAL;
2628 struct zfcp_port *port;
2630 port = fsf_req->data.close_port.port;
2632 if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) {
2633 /* don't change port status in our bookkeeping */
2634 goto skip_fsfstatus;
2637 /* evaluate FSF status in QTCB */
2638 switch (fsf_req->qtcb->header.fsf_status) {
2640 case FSF_PORT_HANDLE_NOT_VALID:
2641 ZFCP_LOG_FLAGS(1, "FSF_PORT_HANDLE_NOT_VALID\n");
2642 ZFCP_LOG_INFO("Temporary port identifier 0x%x for port "
2643 "0x%016Lx on adapter %s invalid. This may happen "
2644 "occasionally.\n", port->handle,
2645 port->wwpn, zfcp_get_busid_by_port(port));
2646 ZFCP_LOG_DEBUG("status qualifier:\n");
2647 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
2648 (char *) &fsf_req->qtcb->header.fsf_status_qual,
2649 sizeof (union fsf_status_qual));
2650 debug_text_event(fsf_req->adapter->erp_dbf, 1,
2652 zfcp_erp_adapter_reopen(port->adapter, 0);
2653 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
2656 case FSF_ADAPTER_STATUS_AVAILABLE:
2657 ZFCP_LOG_FLAGS(2, "FSF_ADAPTER_STATUS_AVAILABLE\n");
2658 /* Note: FSF has actually closed the port in this case.
2659 * The status code is just daft. Fingers crossed for a change
2665 ZFCP_LOG_FLAGS(3, "FSF_GOOD\n");
2666 ZFCP_LOG_TRACE("remote port 0x016%Lx on adapter %s closed, "
2667 "port handle 0x%x\n", port->wwpn,
2668 zfcp_get_busid_by_port(port), port->handle);
2669 zfcp_erp_modify_port_status(port,
2670 ZFCP_STATUS_COMMON_OPEN,
2676 ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
2677 "(debug info 0x%x)\n",
2678 fsf_req->qtcb->header.fsf_status);
2679 debug_text_event(fsf_req->adapter->erp_dbf, 0, "fsf_s_inval:");
2680 debug_exception(fsf_req->adapter->erp_dbf, 0,
2681 &fsf_req->qtcb->header.fsf_status,
2687 atomic_clear_mask(ZFCP_STATUS_COMMON_CLOSING, &port->status);
2692 * function: zfcp_fsf_close_physical_port
2694 * purpose: submit FSF command "close physical port"
2696 * returns: address of initiated FSF request
2697 * NULL - request could not be initiated
2700 zfcp_fsf_close_physical_port(struct zfcp_erp_action *erp_action)
2703 unsigned long lock_flags;
2704 volatile struct qdio_buffer_element *sbale;
2706 /* setup new FSF request */
2707 retval = zfcp_fsf_req_create(erp_action->adapter,
2708 FSF_QTCB_CLOSE_PHYSICAL_PORT,
2709 ZFCP_WAIT_FOR_SBAL | ZFCP_REQ_AUTO_CLEANUP,
2710 erp_action->adapter->pool.fsf_req_erp,
2711 &lock_flags, &erp_action->fsf_req);
2713 ZFCP_LOG_INFO("error: Could not create close physical port "
2714 "request (adapter %s, port 0x%016Lx)\n",
2715 zfcp_get_busid_by_adapter(erp_action->adapter),
2716 erp_action->port->wwpn);
2721 sbale = zfcp_qdio_sbale_req(erp_action->fsf_req,
2722 erp_action->fsf_req->sbal_curr, 0);
2723 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
2724 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
2726 /* mark port as being closed */
2727 atomic_set_mask(ZFCP_STATUS_PORT_PHYS_CLOSING,
2728 &erp_action->port->status);
2729 /* save a pointer to this port */
2730 erp_action->fsf_req->data.close_physical_port.port = erp_action->port;
2731 /* port to be closeed */
2732 erp_action->fsf_req->qtcb->header.port_handle =
2733 erp_action->port->handle;
2734 erp_action->fsf_req->erp_action = erp_action;
2736 /* start QDIO request for this FSF request */
2737 retval = zfcp_fsf_req_send(erp_action->fsf_req, &erp_action->timer);
2739 ZFCP_LOG_INFO("error: Could not send close physical port "
2740 "request (adapter %s, port 0x%016Lx)\n",
2741 zfcp_get_busid_by_adapter(erp_action->adapter),
2742 erp_action->port->wwpn);
2743 zfcp_fsf_req_free(erp_action->fsf_req);
2744 erp_action->fsf_req = NULL;
2748 ZFCP_LOG_TRACE("close physical port request initiated "
2749 "(adapter %s, port 0x%016Lx)\n",
2750 zfcp_get_busid_by_adapter(erp_action->adapter),
2751 erp_action->port->wwpn);
2753 write_unlock_irqrestore(&erp_action->adapter->request_queue.queue_lock,
2759 * function: zfcp_fsf_close_physical_port_handler
2761 * purpose: is called for finished Close Physical Port FSF command
2766 zfcp_fsf_close_physical_port_handler(struct zfcp_fsf_req *fsf_req)
2768 int retval = -EINVAL;
2769 struct zfcp_port *port;
2770 struct zfcp_unit *unit;
2771 struct fsf_qtcb_header *header;
2772 u16 subtable, rule, counter;
2774 port = fsf_req->data.close_physical_port.port;
2775 header = &fsf_req->qtcb->header;
2777 if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) {
2778 /* don't change port status in our bookkeeping */
2779 goto skip_fsfstatus;
2782 /* evaluate FSF status in QTCB */
2783 switch (header->fsf_status) {
2785 case FSF_PORT_HANDLE_NOT_VALID:
2786 ZFCP_LOG_FLAGS(1, "FSF_PORT_HANDLE_NOT_VALID\n");
2787 ZFCP_LOG_INFO("Temporary port identifier 0x%x invalid"
2788 "(adapter %s, port 0x%016Lx). "
2789 "This may happen occasionally.\n",
2791 zfcp_get_busid_by_port(port),
2793 ZFCP_LOG_DEBUG("status qualifier:\n");
2794 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
2795 (char *) &header->fsf_status_qual,
2796 sizeof (union fsf_status_qual));
2797 debug_text_event(fsf_req->adapter->erp_dbf, 1,
2799 zfcp_erp_adapter_reopen(port->adapter, 0);
2800 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
2803 case FSF_ACCESS_DENIED:
2804 ZFCP_LOG_FLAGS(2, "FSF_ACCESS_DENIED\n");
2805 ZFCP_LOG_NORMAL("Access denied, cannot close "
2806 "physical port 0x%016Lx on "
2807 "adapter %s\n", port->wwpn,
2808 zfcp_get_busid_by_port(port));
2809 for (counter = 0; counter < 2; counter++) {
2810 subtable = header->fsf_status_qual.halfword[counter * 2];
2811 rule = header->fsf_status_qual.halfword[counter * 2 + 1];
2813 case FSF_SQ_CFDC_SUBTABLE_OS:
2814 case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN:
2815 case FSF_SQ_CFDC_SUBTABLE_PORT_DID:
2816 case FSF_SQ_CFDC_SUBTABLE_LUN:
2817 ZFCP_LOG_INFO("Access denied (%s rule %d)\n",
2818 zfcp_act_subtable_type[subtable], rule);
2822 debug_text_event(fsf_req->adapter->erp_dbf, 1, "fsf_s_access");
2823 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
2826 case FSF_PORT_BOXED:
2827 ZFCP_LOG_FLAGS(2, "FSF_PORT_BOXED\n");
2828 ZFCP_LOG_DEBUG("The remote port 0x%016Lx on adapter "
2829 "%s needs to be reopened but it was attempted "
2830 "to close it physically.\n",
2832 zfcp_get_busid_by_port(port));
2833 debug_text_event(fsf_req->adapter->erp_dbf, 1, "fsf_s_pboxed");
2834 zfcp_erp_port_reopen(port, 0);
2835 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR |
2836 ZFCP_STATUS_FSFREQ_RETRY;
2839 case FSF_ADAPTER_STATUS_AVAILABLE:
2840 ZFCP_LOG_FLAGS(2, "FSF_ADAPTER_STATUS_AVAILABLE\n");
2841 switch (header->fsf_status_qual.word[0]) {
2842 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
2844 "FSF_SQ_INVOKE_LINK_TEST_PROCEDURE\n");
2845 debug_text_event(fsf_req->adapter->erp_dbf, 1,
2847 /* This will now be escalated by ERP */
2848 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
2850 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
2852 "FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED\n");
2853 /* ERP strategy will escalate */
2854 debug_text_event(fsf_req->adapter->erp_dbf, 1,
2856 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
2860 ("bug: Wrong status qualifier 0x%x arrived.\n",
2861 header->fsf_status_qual.word[0]);
2862 debug_text_event(fsf_req->adapter->erp_dbf, 0,
2865 fsf_req->adapter->erp_dbf, 0,
2866 &header->fsf_status_qual.word[0], sizeof (u32));
2872 ZFCP_LOG_FLAGS(3, "FSF_GOOD\n");
2873 ZFCP_LOG_DEBUG("Remote port 0x%016Lx via adapter %s "
2874 "physically closed, port handle 0x%x\n",
2876 zfcp_get_busid_by_port(port), port->handle);
2877 /* can't use generic zfcp_erp_modify_port_status because
2878 * ZFCP_STATUS_COMMON_OPEN must not be reset for the port
2880 atomic_clear_mask(ZFCP_STATUS_PORT_PHYS_OPEN, &port->status);
2881 list_for_each_entry(unit, &port->unit_list_head, list)
2882 atomic_clear_mask(ZFCP_STATUS_COMMON_OPEN, &unit->status);
2887 ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
2888 "(debug info 0x%x)\n",
2889 header->fsf_status);
2890 debug_text_event(fsf_req->adapter->erp_dbf, 0, "fsf_s_inval:");
2891 debug_exception(fsf_req->adapter->erp_dbf, 0,
2892 &header->fsf_status, sizeof (u32));
2897 atomic_clear_mask(ZFCP_STATUS_PORT_PHYS_CLOSING, &port->status);
2902 * function: zfcp_fsf_open_unit
2908 * assumptions: This routine does not check whether the associated
2909 * remote port has already been opened. This should be
2910 * done by calling routines. Otherwise some status
2911 * may be presented by FSF
2914 zfcp_fsf_open_unit(struct zfcp_erp_action *erp_action)
2916 volatile struct qdio_buffer_element *sbale;
2917 unsigned long lock_flags;
2920 /* setup new FSF request */
2921 retval = zfcp_fsf_req_create(erp_action->adapter,
2923 ZFCP_WAIT_FOR_SBAL | ZFCP_REQ_AUTO_CLEANUP,
2924 erp_action->adapter->pool.fsf_req_erp,
2925 &lock_flags, &(erp_action->fsf_req));
2927 ZFCP_LOG_INFO("error: Could not create open unit request for "
2928 "unit 0x%016Lx on port 0x%016Lx on adapter %s.\n",
2929 erp_action->unit->fcp_lun,
2930 erp_action->unit->port->wwpn,
2931 zfcp_get_busid_by_adapter(erp_action->adapter));
2935 sbale = zfcp_qdio_sbale_req(erp_action->fsf_req,
2936 erp_action->fsf_req->sbal_curr, 0);
2937 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
2938 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
2940 erp_action->fsf_req->qtcb->header.port_handle =
2941 erp_action->port->handle;
2942 erp_action->fsf_req->qtcb->bottom.support.fcp_lun =
2943 erp_action->unit->fcp_lun;
2944 atomic_set_mask(ZFCP_STATUS_COMMON_OPENING, &erp_action->unit->status);
2945 erp_action->fsf_req->data.open_unit.unit = erp_action->unit;
2946 erp_action->fsf_req->erp_action = erp_action;
2948 /* start QDIO request for this FSF request */
2949 retval = zfcp_fsf_req_send(erp_action->fsf_req, &erp_action->timer);
2951 ZFCP_LOG_INFO("error: Could not send an open unit request "
2952 "on the adapter %s, port 0x%016Lx for "
2954 zfcp_get_busid_by_adapter(erp_action->adapter),
2955 erp_action->port->wwpn,
2956 erp_action->unit->fcp_lun);
2957 zfcp_fsf_req_free(erp_action->fsf_req);
2958 erp_action->fsf_req = NULL;
2962 ZFCP_LOG_TRACE("Open LUN request initiated (adapter %s, "
2963 "port 0x%016Lx, unit 0x%016Lx)\n",
2964 zfcp_get_busid_by_adapter(erp_action->adapter),
2965 erp_action->port->wwpn, erp_action->unit->fcp_lun);
2967 write_unlock_irqrestore(&erp_action->adapter->request_queue.queue_lock,
2973 * function: zfcp_fsf_open_unit_handler
2975 * purpose: is called for finished Open LUN command
2980 zfcp_fsf_open_unit_handler(struct zfcp_fsf_req *fsf_req)
2982 int retval = -EINVAL;
2983 struct zfcp_adapter *adapter;
2984 struct zfcp_unit *unit;
2985 struct fsf_qtcb_header *header;
2986 struct fsf_qtcb_bottom_support *bottom;
2987 u16 subtable, rule, counter;
2989 adapter = fsf_req->adapter;
2990 unit = fsf_req->data.open_unit.unit;
2991 header = &fsf_req->qtcb->header;
2992 bottom = &fsf_req->qtcb->bottom.support;
2994 if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) {
2995 /* don't change unit status in our bookkeeping */
2996 goto skip_fsfstatus;
2999 /* evaluate FSF status in QTCB */
3000 switch (header->fsf_status) {
3002 case FSF_PORT_HANDLE_NOT_VALID:
3003 ZFCP_LOG_FLAGS(1, "FSF_PORT_HANDLE_NOT_VALID\n");
3004 ZFCP_LOG_INFO("Temporary port identifier 0x%x "
3005 "for port 0x%016Lx on adapter %s invalid "
3006 "This may happen occasionally\n",
3008 unit->port->wwpn, zfcp_get_busid_by_unit(unit));
3009 ZFCP_LOG_DEBUG("status qualifier:\n");
3010 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
3011 (char *) &header->fsf_status_qual,
3012 sizeof (union fsf_status_qual));
3013 debug_text_event(adapter->erp_dbf, 1, "fsf_s_ph_nv");
3014 zfcp_erp_adapter_reopen(unit->port->adapter, 0);
3015 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
3018 case FSF_LUN_ALREADY_OPEN:
3019 ZFCP_LOG_FLAGS(0, "FSF_LUN_ALREADY_OPEN\n");
3020 ZFCP_LOG_NORMAL("bug: Attempted to open unit 0x%016Lx on "
3021 "remote port 0x%016Lx on adapter %s twice.\n",
3023 unit->port->wwpn, zfcp_get_busid_by_unit(unit));
3024 debug_text_exception(adapter->erp_dbf, 0,
3026 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
3029 case FSF_ACCESS_DENIED:
3030 ZFCP_LOG_FLAGS(2, "FSF_ACCESS_DENIED\n");
3031 ZFCP_LOG_NORMAL("Access denied, cannot open unit 0x%016Lx on "
3032 "remote port 0x%016Lx on adapter %s\n",
3033 unit->fcp_lun, unit->port->wwpn,
3034 zfcp_get_busid_by_unit(unit));
3035 for (counter = 0; counter < 2; counter++) {
3036 subtable = header->fsf_status_qual.halfword[counter * 2];
3037 rule = header->fsf_status_qual.halfword[counter * 2 + 1];
3039 case FSF_SQ_CFDC_SUBTABLE_OS:
3040 case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN:
3041 case FSF_SQ_CFDC_SUBTABLE_PORT_DID:
3042 case FSF_SQ_CFDC_SUBTABLE_LUN:
3043 ZFCP_LOG_INFO("Access denied (%s rule %d)\n",
3044 zfcp_act_subtable_type[subtable], rule);
3048 debug_text_event(adapter->erp_dbf, 1, "fsf_s_access");
3049 zfcp_erp_unit_failed(unit);
3050 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
3053 case FSF_PORT_BOXED:
3054 ZFCP_LOG_FLAGS(2, "FSF_PORT_BOXED\n");
3055 ZFCP_LOG_DEBUG("The remote port 0x%016Lx on adapter %s "
3056 "needs to be reopened\n",
3057 unit->port->wwpn, zfcp_get_busid_by_unit(unit));
3058 debug_text_event(adapter->erp_dbf, 2, "fsf_s_pboxed");
3059 zfcp_erp_port_reopen(unit->port, 0);
3060 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR |
3061 ZFCP_STATUS_FSFREQ_RETRY;
3064 case FSF_LUN_SHARING_VIOLATION :
3065 ZFCP_LOG_FLAGS(2, "FSF_LUN_SHARING_VIOLATION\n");
3066 if (header->fsf_status_qual.word[0] != 0) {
3067 ZFCP_LOG_NORMAL("FCP-LUN 0x%Lx at the remote port "
3069 "connected to the adapter %s "
3070 "is already in use in LPAR%d\n",
3073 zfcp_get_busid_by_unit(unit),
3074 header->fsf_status_qual.fsf_queue_designator.hla);
3076 subtable = header->fsf_status_qual.halfword[4];
3077 rule = header->fsf_status_qual.halfword[5];
3079 case FSF_SQ_CFDC_SUBTABLE_OS:
3080 case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN:
3081 case FSF_SQ_CFDC_SUBTABLE_PORT_DID:
3082 case FSF_SQ_CFDC_SUBTABLE_LUN:
3083 ZFCP_LOG_NORMAL("Access to FCP-LUN 0x%Lx at the "
3084 "remote port with WWPN 0x%Lx "
3085 "connected to the adapter %s "
3086 "is denied (%s rule %d)\n",
3089 zfcp_get_busid_by_unit(unit),
3090 zfcp_act_subtable_type[subtable],
3095 ZFCP_LOG_DEBUG("status qualifier:\n");
3096 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
3097 (char *) &header->fsf_status_qual,
3098 sizeof (union fsf_status_qual));
3099 debug_text_event(adapter->erp_dbf, 2,
3101 zfcp_erp_unit_failed(unit);
3102 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
3105 case FSF_MAXIMUM_NUMBER_OF_LUNS_EXCEEDED:
3106 ZFCP_LOG_FLAGS(1, "FSF_MAXIMUM_NUMBER_OF_LUNS_EXCEEDED\n");
3107 ZFCP_LOG_INFO("error: The adapter ran out of resources. "
3108 "There is no handle (temporary port identifier) "
3109 "available for unit 0x%016Lx on port 0x%016Lx "
3113 zfcp_get_busid_by_unit(unit));
3114 debug_text_event(adapter->erp_dbf, 1,
3116 zfcp_erp_unit_failed(unit);
3117 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
3120 case FSF_ADAPTER_STATUS_AVAILABLE:
3121 ZFCP_LOG_FLAGS(2, "FSF_ADAPTER_STATUS_AVAILABLE\n");
3122 switch (header->fsf_status_qual.word[0]) {
3123 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
3125 "FSF_SQ_INVOKE_LINK_TEST_PROCEDURE\n");
3126 /* Re-establish link to port */
3127 debug_text_event(adapter->erp_dbf, 1,
3129 zfcp_erp_port_reopen(unit->port, 0);
3130 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
3132 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
3134 "FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED\n");
3135 /* ERP strategy will escalate */
3136 debug_text_event(adapter->erp_dbf, 1,
3138 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
3142 ("bug: Wrong status qualifier 0x%x arrived.\n",
3143 header->fsf_status_qual.word[0]);
3144 debug_text_event(adapter->erp_dbf, 0,
3146 debug_exception(adapter->erp_dbf, 0,
3147 &header->fsf_status_qual.word[0],
3152 case FSF_INVALID_COMMAND_OPTION:
3153 ZFCP_LOG_FLAGS(2, "FSF_INVALID_COMMAND_OPTION\n");
3155 "Invalid option 0x%x has been specified "
3156 "in QTCB bottom sent to the adapter %s\n",
3158 zfcp_get_busid_by_adapter(adapter));
3159 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
3164 ZFCP_LOG_FLAGS(3, "FSF_GOOD\n");
3165 /* save LUN handle assigned by FSF */
3166 unit->handle = header->lun_handle;
3167 ZFCP_LOG_TRACE("unit 0x%016Lx on remote port 0x%016Lx on "
3168 "adapter %s opened, port handle 0x%x\n",
3171 zfcp_get_busid_by_unit(unit),
3173 /* mark unit as open */
3174 atomic_set_mask(ZFCP_STATUS_COMMON_OPEN, &unit->status);
3179 ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
3180 "(debug info 0x%x)\n",
3181 header->fsf_status);
3182 debug_text_event(adapter->erp_dbf, 0, "fsf_s_inval:");
3183 debug_exception(adapter->erp_dbf, 0,
3184 &header->fsf_status, sizeof (u32));
3189 atomic_clear_mask(ZFCP_STATUS_COMMON_OPENING, &unit->status);
3194 * function: zfcp_fsf_close_unit
3198 * returns: address of fsf_req - request successfully initiated
3201 * assumptions: This routine does not check whether the associated
3202 * remote port/lun has already been opened. This should be
3203 * done by calling routines. Otherwise some status
3204 * may be presented by FSF
3207 zfcp_fsf_close_unit(struct zfcp_erp_action *erp_action)
3209 volatile struct qdio_buffer_element *sbale;
3210 unsigned long lock_flags;
3213 /* setup new FSF request */
3214 retval = zfcp_fsf_req_create(erp_action->adapter,
3216 ZFCP_WAIT_FOR_SBAL | ZFCP_REQ_AUTO_CLEANUP,
3217 erp_action->adapter->pool.fsf_req_erp,
3218 &lock_flags, &(erp_action->fsf_req));
3220 ZFCP_LOG_INFO("error: Could not create close unit request for "
3221 "unit 0x%016Lx on port 0x%016Lx on adapter %s.\n",
3222 erp_action->unit->fcp_lun,
3223 erp_action->port->wwpn,
3224 zfcp_get_busid_by_adapter(erp_action->adapter));
3228 sbale = zfcp_qdio_sbale_req(erp_action->fsf_req,
3229 erp_action->fsf_req->sbal_curr, 0);
3230 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
3231 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
3233 erp_action->fsf_req->qtcb->header.port_handle =
3234 erp_action->port->handle;
3235 erp_action->fsf_req->qtcb->header.lun_handle = erp_action->unit->handle;
3236 atomic_set_mask(ZFCP_STATUS_COMMON_CLOSING, &erp_action->unit->status);
3237 erp_action->fsf_req->data.close_unit.unit = erp_action->unit;
3238 erp_action->fsf_req->erp_action = erp_action;
3240 /* start QDIO request for this FSF request */
3241 retval = zfcp_fsf_req_send(erp_action->fsf_req, &erp_action->timer);
3243 ZFCP_LOG_INFO("error: Could not send a close unit request for "
3244 "unit 0x%016Lx on port 0x%016Lx onadapter %s.\n",
3245 erp_action->unit->fcp_lun,
3246 erp_action->port->wwpn,
3247 zfcp_get_busid_by_adapter(erp_action->adapter));
3248 zfcp_fsf_req_free(erp_action->fsf_req);
3249 erp_action->fsf_req = NULL;
3253 ZFCP_LOG_TRACE("Close LUN request initiated (adapter %s, "
3254 "port 0x%016Lx, unit 0x%016Lx)\n",
3255 zfcp_get_busid_by_adapter(erp_action->adapter),
3256 erp_action->port->wwpn, erp_action->unit->fcp_lun);
3258 write_unlock_irqrestore(&erp_action->adapter->request_queue.queue_lock,
3264 * function: zfcp_fsf_close_unit_handler
3266 * purpose: is called for finished Close LUN FSF command
3271 zfcp_fsf_close_unit_handler(struct zfcp_fsf_req *fsf_req)
3273 int retval = -EINVAL;
3274 struct zfcp_unit *unit;
3276 unit = fsf_req->data.close_unit.unit; /* restore unit */
3278 if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) {
3279 /* don't change unit status in our bookkeeping */
3280 goto skip_fsfstatus;
3283 /* evaluate FSF status in QTCB */
3284 switch (fsf_req->qtcb->header.fsf_status) {
3286 case FSF_PORT_HANDLE_NOT_VALID:
3287 ZFCP_LOG_FLAGS(1, "FSF_PORT_HANDLE_NOT_VALID\n");
3288 ZFCP_LOG_INFO("Temporary port identifier 0x%x for port "
3289 "0x%016Lx on adapter %s invalid. This may "
3290 "happen in rare circumstances\n",
3293 zfcp_get_busid_by_unit(unit));
3294 ZFCP_LOG_DEBUG("status qualifier:\n");
3295 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
3296 (char *) &fsf_req->qtcb->header.fsf_status_qual,
3297 sizeof (union fsf_status_qual));
3298 debug_text_event(fsf_req->adapter->erp_dbf, 1,
3300 zfcp_erp_adapter_reopen(unit->port->adapter, 0);
3301 zfcp_cmd_dbf_event_fsf("porthinv", fsf_req,
3302 &fsf_req->qtcb->header.fsf_status_qual,
3303 sizeof (union fsf_status_qual));
3304 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
3307 case FSF_LUN_HANDLE_NOT_VALID:
3308 ZFCP_LOG_FLAGS(1, "FSF_LUN_HANDLE_NOT_VALID\n");
3309 ZFCP_LOG_INFO("Temporary LUN identifier 0x%x of unit "
3310 "0x%016Lx on port 0x%016Lx on adapter %s is "
3311 "invalid. This may happen occasionally.\n",
3315 zfcp_get_busid_by_unit(unit));
3316 ZFCP_LOG_DEBUG("Status qualifier data:\n");
3317 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
3318 (char *) &fsf_req->qtcb->header.fsf_status_qual,
3319 sizeof (union fsf_status_qual));
3320 debug_text_event(fsf_req->adapter->erp_dbf, 1,
3322 zfcp_erp_port_reopen(unit->port, 0);
3323 zfcp_cmd_dbf_event_fsf("lunhinv", fsf_req,
3324 &fsf_req->qtcb->header.fsf_status_qual,
3325 sizeof (union fsf_status_qual));
3326 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
3329 case FSF_PORT_BOXED:
3330 ZFCP_LOG_FLAGS(2, "FSF_PORT_BOXED\n");
3331 ZFCP_LOG_DEBUG("The remote port 0x%016Lx on adapter %s "
3332 "needs to be reopened\n",
3334 zfcp_get_busid_by_unit(unit));
3335 debug_text_event(fsf_req->adapter->erp_dbf, 2, "fsf_s_pboxed");
3336 zfcp_erp_port_reopen(unit->port, 0);
3337 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR |
3338 ZFCP_STATUS_FSFREQ_RETRY;
3341 case FSF_ADAPTER_STATUS_AVAILABLE:
3342 ZFCP_LOG_FLAGS(2, "FSF_ADAPTER_STATUS_AVAILABLE\n");
3343 switch (fsf_req->qtcb->header.fsf_status_qual.word[0]) {
3344 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
3346 "FSF_SQ_INVOKE_LINK_TEST_PROCEDURE\n");
3347 /* re-establish link to port */
3348 debug_text_event(fsf_req->adapter->erp_dbf, 1,
3350 zfcp_erp_port_reopen(unit->port, 0);
3351 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
3353 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
3355 "FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED\n");
3356 /* ERP strategy will escalate */
3357 debug_text_event(fsf_req->adapter->erp_dbf, 1,
3359 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
3363 ("bug: Wrong status qualifier 0x%x arrived.\n",
3364 fsf_req->qtcb->header.fsf_status_qual.word[0]);
3365 debug_text_event(fsf_req->adapter->erp_dbf, 0,
3368 fsf_req->adapter->erp_dbf, 0,
3369 &fsf_req->qtcb->header.fsf_status_qual.word[0],
3376 ZFCP_LOG_FLAGS(3, "FSF_GOOD\n");
3377 ZFCP_LOG_TRACE("unit 0x%016Lx on port 0x%016Lx on adapter %s "
3378 "closed, port handle 0x%x\n",
3381 zfcp_get_busid_by_unit(unit),
3383 /* mark unit as closed */
3384 atomic_clear_mask(ZFCP_STATUS_COMMON_OPEN, &unit->status);
3389 ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
3390 "(debug info 0x%x)\n",
3391 fsf_req->qtcb->header.fsf_status);
3392 debug_text_event(fsf_req->adapter->erp_dbf, 0, "fsf_s_inval:");
3393 debug_exception(fsf_req->adapter->erp_dbf, 0,
3394 &fsf_req->qtcb->header.fsf_status,
3400 atomic_clear_mask(ZFCP_STATUS_COMMON_CLOSING, &unit->status);
3405 * zfcp_fsf_send_fcp_command_task - initiate an FCP command (for a SCSI command)
3406 * @adapter: adapter where scsi command is issued
3407 * @unit: unit where command is sent to
3408 * @scsi_cmnd: scsi command to be sent
3409 * @timer: timer to be started when request is initiated
3410 * @req_flags: flags for fsf_request
3413 zfcp_fsf_send_fcp_command_task(struct zfcp_adapter *adapter,
3414 struct zfcp_unit *unit,
3415 struct scsi_cmnd * scsi_cmnd,
3416 struct timer_list *timer, int req_flags)
3418 struct zfcp_fsf_req *fsf_req = NULL;
3419 struct fcp_cmnd_iu *fcp_cmnd_iu;
3420 unsigned int sbtype;
3421 unsigned long lock_flags;
3425 /* setup new FSF request */
3426 retval = zfcp_fsf_req_create(adapter, FSF_QTCB_FCP_CMND, req_flags,
3427 adapter->pool.fsf_req_scsi,
3428 &lock_flags, &fsf_req);
3429 if (unlikely(retval < 0)) {
3430 ZFCP_LOG_DEBUG("error: Could not create FCP command request "
3431 "for unit 0x%016Lx on port 0x%016Lx on "
3435 zfcp_get_busid_by_adapter(adapter));
3436 goto failed_req_create;
3440 * associate FSF request with SCSI request
3441 * (need this for look up on abort)
3443 fsf_req->data.send_fcp_command_task.fsf_req = fsf_req;
3444 scsi_cmnd->host_scribble = (char *) &(fsf_req->data);
3447 * associate SCSI command with FSF request
3448 * (need this for look up on normal command completion)
3450 fsf_req->data.send_fcp_command_task.scsi_cmnd = scsi_cmnd;
3451 fsf_req->data.send_fcp_command_task.start_jiffies = jiffies;
3452 fsf_req->data.send_fcp_command_task.unit = unit;
3453 ZFCP_LOG_DEBUG("unit=%p, fcp_lun=0x%016Lx\n", unit, unit->fcp_lun);
3455 /* set handles of unit and its parent port in QTCB */
3456 fsf_req->qtcb->header.lun_handle = unit->handle;
3457 fsf_req->qtcb->header.port_handle = unit->port->handle;
3459 /* FSF does not define the structure of the FCP_CMND IU */
3460 fcp_cmnd_iu = (struct fcp_cmnd_iu *)
3461 &(fsf_req->qtcb->bottom.io.fcp_cmnd);
3464 * set depending on data direction:
3465 * data direction bits in SBALE (SB Type)
3466 * data direction bits in QTCB
3467 * data direction bits in FCP_CMND IU
3469 switch (scsi_cmnd->sc_data_direction) {
3471 ZFCP_LOG_FLAGS(3, "DMA_NONE\n");
3472 fsf_req->qtcb->bottom.io.data_direction = FSF_DATADIR_CMND;
3475 * what is the correct type for commands
3476 * without 'real' data buffers?
3478 sbtype = SBAL_FLAGS0_TYPE_READ;
3480 case DMA_FROM_DEVICE:
3481 ZFCP_LOG_FLAGS(3, "DMA_FROM_DEVICE\n");
3482 fsf_req->qtcb->bottom.io.data_direction = FSF_DATADIR_READ;
3483 sbtype = SBAL_FLAGS0_TYPE_READ;
3484 fcp_cmnd_iu->rddata = 1;
3487 ZFCP_LOG_FLAGS(3, "DMA_TO_DEVICE\n");
3488 fsf_req->qtcb->bottom.io.data_direction = FSF_DATADIR_WRITE;
3489 sbtype = SBAL_FLAGS0_TYPE_WRITE;
3490 fcp_cmnd_iu->wddata = 1;
3492 case DMA_BIDIRECTIONAL:
3493 ZFCP_LOG_FLAGS(0, "DMA_BIDIRECTIONAL not supported\n");
3496 * dummy, catch this condition earlier
3497 * in zfcp_scsi_queuecommand
3499 goto failed_scsi_cmnd;
3502 /* set FC service class in QTCB (3 per default) */
3503 fsf_req->qtcb->bottom.io.service_class = adapter->fc_service_class;
3505 /* set FCP_LUN in FCP_CMND IU in QTCB */
3506 fcp_cmnd_iu->fcp_lun = unit->fcp_lun;
3508 /* set task attributes in FCP_CMND IU in QTCB */
3509 if (likely(scsi_cmnd->device->simple_tags)) {
3510 fcp_cmnd_iu->task_attribute = SIMPLE_Q;
3511 ZFCP_LOG_TRACE("setting SIMPLE_Q task attribute\n");
3513 fcp_cmnd_iu->task_attribute = UNTAGGED;
3514 ZFCP_LOG_TRACE("setting UNTAGGED task attribute\n");
3517 /* set additional length of FCP_CDB in FCP_CMND IU in QTCB, if needed */
3518 if (unlikely(scsi_cmnd->cmd_len > FCP_CDB_LENGTH)) {
3519 fcp_cmnd_iu->add_fcp_cdb_length
3520 = (scsi_cmnd->cmd_len - FCP_CDB_LENGTH) >> 2;
3521 ZFCP_LOG_TRACE("SCSI CDB length is 0x%x, "
3522 "additional FCP_CDB length is 0x%x "
3523 "(shifted right 2 bits)\n",
3525 fcp_cmnd_iu->add_fcp_cdb_length);
3528 * copy SCSI CDB (including additional length, if any) to
3529 * FCP_CDB in FCP_CMND IU in QTCB
3531 memcpy(fcp_cmnd_iu->fcp_cdb, scsi_cmnd->cmnd, scsi_cmnd->cmd_len);
3533 /* FCP CMND IU length in QTCB */
3534 fsf_req->qtcb->bottom.io.fcp_cmnd_length =
3535 sizeof (struct fcp_cmnd_iu) +
3536 fcp_cmnd_iu->add_fcp_cdb_length + sizeof (fcp_dl_t);
3538 /* generate SBALEs from data buffer */
3539 real_bytes = zfcp_qdio_sbals_from_scsicmnd(fsf_req, sbtype, scsi_cmnd);
3540 if (unlikely(real_bytes < 0)) {
3541 if (fsf_req->sbal_number < ZFCP_MAX_SBALS_PER_REQ) {
3543 "Data did not fit into available buffer(s), "
3544 "waiting for more...\n");
3547 ZFCP_LOG_NORMAL("error: No truncation implemented but "
3548 "required. Shutting down unit "
3549 "(adapter %s, port 0x%016Lx, "
3551 zfcp_get_busid_by_unit(unit),
3554 zfcp_erp_unit_shutdown(unit, 0);
3560 /* set length of FCP data length in FCP_CMND IU in QTCB */
3561 zfcp_set_fcp_dl(fcp_cmnd_iu, real_bytes);
3563 ZFCP_LOG_DEBUG("Sending SCSI command:\n");
3564 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
3565 (char *) scsi_cmnd->cmnd, scsi_cmnd->cmd_len);
3568 * start QDIO request for this FSF request
3569 * covered by an SBALE)
3571 retval = zfcp_fsf_req_send(fsf_req, timer);
3572 if (unlikely(retval < 0)) {
3573 ZFCP_LOG_INFO("error: Could not send FCP command request "
3574 "on adapter %s, port 0x%016Lx, unit 0x%016Lx\n",
3575 zfcp_get_busid_by_adapter(adapter),
3581 ZFCP_LOG_TRACE("Send FCP Command initiated (adapter %s, "
3582 "port 0x%016Lx, unit 0x%016Lx)\n",
3583 zfcp_get_busid_by_adapter(adapter),
3591 zfcp_fsf_req_free(fsf_req);
3593 scsi_cmnd->host_scribble = NULL;
3596 write_unlock_irqrestore(&adapter->request_queue.queue_lock, lock_flags);
3601 * function: zfcp_fsf_send_fcp_command_task_management
3607 * FIXME(design): should be watched by a timeout!!!
3608 * FIXME(design) shouldn't this be modified to return an int
3609 * also...don't know how though
3612 struct zfcp_fsf_req *
3613 zfcp_fsf_send_fcp_command_task_management(struct zfcp_adapter *adapter,
3614 struct zfcp_unit *unit,
3615 u8 tm_flags, int req_flags)
3617 struct zfcp_fsf_req *fsf_req = NULL;
3619 struct fcp_cmnd_iu *fcp_cmnd_iu;
3620 unsigned long lock_flags;
3621 volatile struct qdio_buffer_element *sbale;
3623 /* setup new FSF request */
3624 retval = zfcp_fsf_req_create(adapter, FSF_QTCB_FCP_CMND, req_flags,
3625 adapter->pool.fsf_req_scsi,
3626 &lock_flags, &fsf_req);
3628 ZFCP_LOG_INFO("error: Could not create FCP command (task "
3629 "management) request for adapter %s, port "
3630 " 0x%016Lx, unit 0x%016Lx.\n",
3631 zfcp_get_busid_by_adapter(adapter),
3632 unit->port->wwpn, unit->fcp_lun);
3637 * Used to decide on proper handler in the return path,
3638 * could be either zfcp_fsf_send_fcp_command_task_handler or
3639 * zfcp_fsf_send_fcp_command_task_management_handler */
3641 fsf_req->status |= ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT;
3644 * hold a pointer to the unit being target of this
3645 * task management request
3647 fsf_req->data.send_fcp_command_task_management.unit = unit;
3649 /* set FSF related fields in QTCB */
3650 fsf_req->qtcb->header.lun_handle = unit->handle;
3651 fsf_req->qtcb->header.port_handle = unit->port->handle;
3652 fsf_req->qtcb->bottom.io.data_direction = FSF_DATADIR_CMND;
3653 fsf_req->qtcb->bottom.io.service_class = adapter->fc_service_class;
3654 fsf_req->qtcb->bottom.io.fcp_cmnd_length =
3655 sizeof (struct fcp_cmnd_iu) + sizeof (fcp_dl_t);
3657 sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0);
3658 sbale[0].flags |= SBAL_FLAGS0_TYPE_WRITE;
3659 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
3661 /* set FCP related fields in FCP_CMND IU in QTCB */
3662 fcp_cmnd_iu = (struct fcp_cmnd_iu *)
3663 &(fsf_req->qtcb->bottom.io.fcp_cmnd);
3664 fcp_cmnd_iu->fcp_lun = unit->fcp_lun;
3665 fcp_cmnd_iu->task_management_flags = tm_flags;
3667 /* start QDIO request for this FSF request */
3668 zfcp_fsf_start_scsi_er_timer(adapter);
3669 retval = zfcp_fsf_req_send(fsf_req, NULL);
3671 del_timer(&adapter->scsi_er_timer);
3672 ZFCP_LOG_INFO("error: Could not send an FCP-command (task "
3673 "management) on adapter %s, port 0x%016Lx for "
3674 "unit LUN 0x%016Lx\n",
3675 zfcp_get_busid_by_adapter(adapter),
3678 zfcp_fsf_req_free(fsf_req);
3683 ZFCP_LOG_TRACE("Send FCP Command (task management function) initiated "
3684 "(adapter %s, port 0x%016Lx, unit 0x%016Lx, "
3686 zfcp_get_busid_by_adapter(adapter),
3691 write_unlock_irqrestore(&adapter->request_queue.queue_lock, lock_flags);
3696 * function: zfcp_fsf_send_fcp_command_handler
3698 * purpose: is called for finished Send FCP Command
3703 zfcp_fsf_send_fcp_command_handler(struct zfcp_fsf_req *fsf_req)
3705 int retval = -EINVAL;
3706 struct zfcp_unit *unit;
3707 struct fsf_qtcb_header *header;
3708 u16 subtable, rule, counter;
3710 header = &fsf_req->qtcb->header;
3712 if (unlikely(fsf_req->status & ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT))
3713 unit = fsf_req->data.send_fcp_command_task_management.unit;
3715 unit = fsf_req->data.send_fcp_command_task.unit;
3717 if (unlikely(fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR)) {
3718 /* go directly to calls of special handlers */
3719 goto skip_fsfstatus;
3722 /* evaluate FSF status in QTCB */
3723 switch (header->fsf_status) {
3725 case FSF_PORT_HANDLE_NOT_VALID:
3726 ZFCP_LOG_FLAGS(1, "FSF_PORT_HANDLE_NOT_VALID\n");
3727 ZFCP_LOG_INFO("Temporary port identifier 0x%x for port "
3728 "0x%016Lx on adapter %s invalid\n",
3730 unit->port->wwpn, zfcp_get_busid_by_unit(unit));
3731 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
3732 (char *) &header->fsf_status_qual,
3733 sizeof (union fsf_status_qual));
3734 debug_text_event(fsf_req->adapter->erp_dbf, 1,
3736 zfcp_erp_adapter_reopen(unit->port->adapter, 0);
3737 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
3740 case FSF_LUN_HANDLE_NOT_VALID:
3741 ZFCP_LOG_FLAGS(1, "FSF_LUN_HANDLE_NOT_VALID\n");
3742 ZFCP_LOG_INFO("Temporary LUN identifier 0x%x for unit "
3743 "0x%016Lx on port 0x%016Lx on adapter %s is "
3744 "invalid. This may happen occasionally.\n",
3748 zfcp_get_busid_by_unit(unit));
3749 ZFCP_LOG_NORMAL("Status qualifier data:\n");
3750 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_NORMAL,
3751 (char *) &header->fsf_status_qual,
3752 sizeof (union fsf_status_qual));
3753 debug_text_event(fsf_req->adapter->erp_dbf, 1,
3755 zfcp_erp_port_reopen(unit->port, 0);
3756 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
3759 case FSF_HANDLE_MISMATCH:
3760 ZFCP_LOG_FLAGS(0, "FSF_HANDLE_MISMATCH\n");
3761 ZFCP_LOG_NORMAL("bug: The port handle 0x%x has changed "
3762 "unexpectedly. (adapter %s, port 0x%016Lx, "
3765 zfcp_get_busid_by_unit(unit),
3768 ZFCP_LOG_NORMAL("status qualifier:\n");
3769 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_NORMAL,
3770 (char *) &header->fsf_status_qual,
3771 sizeof (union fsf_status_qual));
3772 debug_text_event(fsf_req->adapter->erp_dbf, 1,
3774 zfcp_erp_adapter_reopen(unit->port->adapter, 0);
3775 zfcp_cmd_dbf_event_fsf("handmism",
3777 &header->fsf_status_qual,
3778 sizeof (union fsf_status_qual));
3779 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
3782 case FSF_SERVICE_CLASS_NOT_SUPPORTED:
3783 ZFCP_LOG_FLAGS(0, "FSF_SERVICE_CLASS_NOT_SUPPORTED\n");
3784 if (fsf_req->adapter->fc_service_class <= 3) {
3785 ZFCP_LOG_NORMAL("error: The adapter %s does "
3786 "not support fibrechannel class %d.\n",
3787 zfcp_get_busid_by_unit(unit),
3788 fsf_req->adapter->fc_service_class);
3790 ZFCP_LOG_NORMAL("bug: The fibrechannel class at "
3791 "adapter %s is invalid. "
3792 "(debug info %d)\n",
3793 zfcp_get_busid_by_unit(unit),
3794 fsf_req->adapter->fc_service_class);
3796 /* stop operation for this adapter */
3797 debug_text_exception(fsf_req->adapter->erp_dbf, 0,
3798 "fsf_s_class_nsup");
3799 zfcp_erp_adapter_shutdown(unit->port->adapter, 0);
3800 zfcp_cmd_dbf_event_fsf("unsclass",
3802 &header->fsf_status_qual,
3803 sizeof (union fsf_status_qual));
3804 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
3807 case FSF_FCPLUN_NOT_VALID:
3808 ZFCP_LOG_FLAGS(0, "FSF_FCPLUN_NOT_VALID\n");
3809 ZFCP_LOG_NORMAL("bug: unit 0x%016Lx on port 0x%016Lx on "
3810 "adapter %s does not have correct unit "
3814 zfcp_get_busid_by_unit(unit),
3816 ZFCP_LOG_DEBUG("status qualifier:\n");
3817 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
3818 (char *) &header->fsf_status_qual,
3819 sizeof (union fsf_status_qual));
3820 debug_text_event(fsf_req->adapter->erp_dbf, 1,
3821 "fsf_s_fcp_lun_nv");
3822 zfcp_erp_port_reopen(unit->port, 0);
3823 zfcp_cmd_dbf_event_fsf("fluninv",
3825 &header->fsf_status_qual,
3826 sizeof (union fsf_status_qual));
3827 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
3830 case FSF_ACCESS_DENIED:
3831 ZFCP_LOG_FLAGS(2, "FSF_ACCESS_DENIED\n");
3832 ZFCP_LOG_NORMAL("Access denied, cannot send FCP command to "
3833 "unit 0x%016Lx on port 0x%016Lx on "
3834 "adapter %s\n", unit->fcp_lun, unit->port->wwpn,
3835 zfcp_get_busid_by_unit(unit));
3836 for (counter = 0; counter < 2; counter++) {
3837 subtable = header->fsf_status_qual.halfword[counter * 2];
3838 rule = header->fsf_status_qual.halfword[counter * 2 + 1];
3840 case FSF_SQ_CFDC_SUBTABLE_OS:
3841 case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN:
3842 case FSF_SQ_CFDC_SUBTABLE_PORT_DID:
3843 case FSF_SQ_CFDC_SUBTABLE_LUN:
3844 ZFCP_LOG_INFO("Access denied (%s rule %d)\n",
3845 zfcp_act_subtable_type[subtable], rule);
3849 debug_text_event(fsf_req->adapter->erp_dbf, 1, "fsf_s_access");
3850 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
3853 case FSF_DIRECTION_INDICATOR_NOT_VALID:
3854 ZFCP_LOG_FLAGS(0, "FSF_DIRECTION_INDICATOR_NOT_VALID\n");
3855 ZFCP_LOG_INFO("bug: Invalid data direction given for unit "
3856 "0x%016Lx on port 0x%016Lx on adapter %s "
3857 "(debug info %d)\n",
3860 zfcp_get_busid_by_unit(unit),
3861 fsf_req->qtcb->bottom.io.data_direction);
3862 /* stop operation for this adapter */
3863 debug_text_event(fsf_req->adapter->erp_dbf, 0,
3864 "fsf_s_dir_ind_nv");
3865 zfcp_erp_adapter_shutdown(unit->port->adapter, 0);
3866 zfcp_cmd_dbf_event_fsf("dirinv",
3868 &header->fsf_status_qual,
3869 sizeof (union fsf_status_qual));
3870 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
3873 case FSF_CMND_LENGTH_NOT_VALID:
3874 ZFCP_LOG_FLAGS(0, "FSF_CMND_LENGTH_NOT_VALID\n");
3876 ("bug: An invalid control-data-block length field "
3877 "was found in a command for unit 0x%016Lx on port "
3878 "0x%016Lx on adapter %s " "(debug info %d)\n",
3879 unit->fcp_lun, unit->port->wwpn,
3880 zfcp_get_busid_by_unit(unit),
3881 fsf_req->qtcb->bottom.io.fcp_cmnd_length);
3882 /* stop operation for this adapter */
3883 debug_text_event(fsf_req->adapter->erp_dbf, 0,
3884 "fsf_s_cmd_len_nv");
3885 zfcp_erp_adapter_shutdown(unit->port->adapter, 0);
3886 zfcp_cmd_dbf_event_fsf("cleninv",
3888 &header->fsf_status_qual,
3889 sizeof (union fsf_status_qual));
3890 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
3893 case FSF_PORT_BOXED:
3894 ZFCP_LOG_FLAGS(2, "FSF_PORT_BOXED\n");
3895 ZFCP_LOG_DEBUG("The remote port 0x%016Lx on adapter %s "
3896 "needs to be reopened\n",
3897 unit->port->wwpn, zfcp_get_busid_by_unit(unit));
3898 debug_text_event(fsf_req->adapter->erp_dbf, 2, "fsf_s_pboxed");
3899 zfcp_erp_port_reopen(unit->port, 0);
3900 zfcp_cmd_dbf_event_fsf("portbox", fsf_req,
3901 &header->fsf_status_qual,
3902 sizeof (union fsf_status_qual));
3903 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR |
3904 ZFCP_STATUS_FSFREQ_RETRY;
3908 ZFCP_LOG_FLAGS(0, "FSF_LUN_BOXED\n");
3910 "unit 0x%016Lx on port 0x%016Lx on adapter %s needs "
3912 unit->fcp_lun, unit->port->wwpn,
3913 zfcp_get_busid_by_unit(unit));
3914 debug_text_event(fsf_req->adapter->erp_dbf, 1, "fsf_s_lboxed");
3915 zfcp_erp_unit_reopen(unit, 0);
3916 zfcp_cmd_dbf_event_fsf("unitbox", fsf_req,
3917 &header->fsf_status_qual,
3918 sizeof(union fsf_status_qual));
3919 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR
3920 | ZFCP_STATUS_FSFREQ_RETRY;
3923 case FSF_ADAPTER_STATUS_AVAILABLE:
3924 ZFCP_LOG_FLAGS(2, "FSF_ADAPTER_STATUS_AVAILABLE\n");
3925 switch (header->fsf_status_qual.word[0]) {
3926 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
3928 "FSF_SQ_INVOKE_LINK_TEST_PROCEDURE\n");
3929 /* re-establish link to port */
3930 debug_text_event(fsf_req->adapter->erp_dbf, 1,
3932 zfcp_erp_port_reopen(unit->port, 0);
3933 zfcp_cmd_dbf_event_fsf(
3936 &header->fsf_status_qual,
3937 sizeof (union fsf_status_qual));
3938 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
3940 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
3942 "FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED\n");
3943 /* FIXME(hw) need proper specs for proper action */
3944 /* let scsi stack deal with retries and escalation */
3945 debug_text_event(fsf_req->adapter->erp_dbf, 1,
3947 zfcp_cmd_dbf_event_fsf(
3950 &header->fsf_status_qual,
3951 sizeof (union fsf_status_qual));
3952 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
3955 /* FIXME: shall we consider this a successful transfer? */
3957 ("bug: Wrong status qualifier 0x%x arrived.\n",
3958 header->fsf_status_qual.word[0]);
3959 debug_text_event(fsf_req->adapter->erp_dbf, 0,
3961 debug_exception(fsf_req->adapter->erp_dbf, 0,
3962 &header->fsf_status_qual.word[0],
3969 ZFCP_LOG_FLAGS(3, "FSF_GOOD\n");
3972 case FSF_FCP_RSP_AVAILABLE:
3973 ZFCP_LOG_FLAGS(2, "FSF_FCP_RSP_AVAILABLE\n");
3977 debug_text_event(fsf_req->adapter->erp_dbf, 0, "fsf_s_inval:");
3978 debug_exception(fsf_req->adapter->erp_dbf, 0,
3979 &header->fsf_status, sizeof(u32));
3984 if (fsf_req->status & ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT) {
3986 zfcp_fsf_send_fcp_command_task_management_handler(fsf_req);
3988 retval = zfcp_fsf_send_fcp_command_task_handler(fsf_req);
3994 * function: zfcp_fsf_send_fcp_command_task_handler
3996 * purpose: evaluates FCP_RSP IU
4001 zfcp_fsf_send_fcp_command_task_handler(struct zfcp_fsf_req *fsf_req)
4004 struct scsi_cmnd *scpnt;
4005 struct fcp_rsp_iu *fcp_rsp_iu = (struct fcp_rsp_iu *)
4006 &(fsf_req->qtcb->bottom.io.fcp_rsp);
4007 struct fcp_cmnd_iu *fcp_cmnd_iu = (struct fcp_cmnd_iu *)
4008 &(fsf_req->qtcb->bottom.io.fcp_cmnd);
4010 char *fcp_rsp_info = zfcp_get_fcp_rsp_info_ptr(fcp_rsp_iu);
4011 unsigned long flags;
4012 struct zfcp_unit *unit = fsf_req->data.send_fcp_command_task.unit;
4014 read_lock_irqsave(&fsf_req->adapter->abort_lock, flags);
4015 scpnt = fsf_req->data.send_fcp_command_task.scsi_cmnd;
4016 if (unlikely(!scpnt)) {
4018 ("Command with fsf_req %p is not associated to "
4019 "a scsi command anymore. Aborted?\n", fsf_req);
4022 if (unlikely(fsf_req->status & ZFCP_STATUS_FSFREQ_ABORTED)) {
4023 /* FIXME: (design) mid-layer should handle DID_ABORT like
4024 * DID_SOFT_ERROR by retrying the request for devices
4025 * that allow retries.
4027 ZFCP_LOG_DEBUG("Setting DID_SOFT_ERROR and SUGGEST_RETRY\n");
4028 set_host_byte(&scpnt->result, DID_SOFT_ERROR);
4029 set_driver_byte(&scpnt->result, SUGGEST_RETRY);
4030 goto skip_fsfstatus;
4033 if (unlikely(fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR)) {
4034 ZFCP_LOG_DEBUG("Setting DID_ERROR\n");
4035 set_host_byte(&scpnt->result, DID_ERROR);
4036 goto skip_fsfstatus;
4039 /* set message byte of result in SCSI command */
4040 scpnt->result |= COMMAND_COMPLETE << 8;
4043 * copy SCSI status code of FCP_STATUS of FCP_RSP IU to status byte
4044 * of result in SCSI command
4046 scpnt->result |= fcp_rsp_iu->scsi_status;
4047 if (unlikely(fcp_rsp_iu->scsi_status)) {
4049 ZFCP_LOG_DEBUG("status for SCSI Command:\n");
4050 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
4051 scpnt->cmnd, scpnt->cmd_len);
4052 ZFCP_LOG_DEBUG("SCSI status code 0x%x\n",
4053 fcp_rsp_iu->scsi_status);
4054 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
4055 (void *) fcp_rsp_iu, sizeof (struct fcp_rsp_iu));
4056 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
4057 zfcp_get_fcp_sns_info_ptr(fcp_rsp_iu),
4058 fcp_rsp_iu->fcp_sns_len);
4061 /* check FCP_RSP_INFO */
4062 if (unlikely(fcp_rsp_iu->validity.bits.fcp_rsp_len_valid)) {
4063 ZFCP_LOG_DEBUG("rsp_len is valid\n");
4064 switch (fcp_rsp_info[3]) {
4066 ZFCP_LOG_FLAGS(3, "RSP_CODE_GOOD\n");
4068 ZFCP_LOG_TRACE("no failure or Task Management "
4069 "Function complete\n");
4070 set_host_byte(&scpnt->result, DID_OK);
4072 case RSP_CODE_LENGTH_MISMATCH:
4073 ZFCP_LOG_FLAGS(0, "RSP_CODE_LENGTH_MISMATCH\n");
4075 ZFCP_LOG_NORMAL("bug: FCP response code indictates "
4076 "that the fibrechannel protocol data "
4077 "length differs from the burst length. "
4078 "The problem occured on unit 0x%016Lx "
4079 "on port 0x%016Lx on adapter %s",
4082 zfcp_get_busid_by_unit(unit));
4083 /* dump SCSI CDB as prepared by zfcp */
4084 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
4085 (char *) &fsf_req->qtcb->
4086 bottom.io.fcp_cmnd, FSF_FCP_CMND_SIZE);
4087 zfcp_cmd_dbf_event_fsf("clenmis", fsf_req, NULL, 0);
4088 set_host_byte(&scpnt->result, DID_ERROR);
4089 goto skip_fsfstatus;
4090 case RSP_CODE_FIELD_INVALID:
4091 ZFCP_LOG_FLAGS(0, "RSP_CODE_FIELD_INVALID\n");
4092 /* driver or hardware bug */
4093 ZFCP_LOG_NORMAL("bug: FCP response code indictates "
4094 "that the fibrechannel protocol data "
4095 "fields were incorrectly set up. "
4096 "The problem occured on the unit "
4097 "0x%016Lx on port 0x%016Lx on "
4101 zfcp_get_busid_by_unit(unit));
4102 /* dump SCSI CDB as prepared by zfcp */
4103 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
4104 (char *) &fsf_req->qtcb->
4105 bottom.io.fcp_cmnd, FSF_FCP_CMND_SIZE);
4106 set_host_byte(&scpnt->result, DID_ERROR);
4107 zfcp_cmd_dbf_event_fsf("codeinv", fsf_req, NULL, 0);
4108 goto skip_fsfstatus;
4109 case RSP_CODE_RO_MISMATCH:
4110 ZFCP_LOG_FLAGS(0, "RSP_CODE_RO_MISMATCH\n");
4112 ZFCP_LOG_NORMAL("bug: The FCP response code indicates "
4113 "that conflicting values for the "
4114 "fibrechannel payload offset from the "
4115 "header were found. "
4116 "The problem occured on unit 0x%016Lx "
4117 "on port 0x%016Lx on adapter %s.\n",
4120 zfcp_get_busid_by_unit(unit));
4121 /* dump SCSI CDB as prepared by zfcp */
4122 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
4123 (char *) &fsf_req->qtcb->
4124 bottom.io.fcp_cmnd, FSF_FCP_CMND_SIZE);
4125 zfcp_cmd_dbf_event_fsf("codemism", fsf_req, NULL, 0);
4126 set_host_byte(&scpnt->result, DID_ERROR);
4127 goto skip_fsfstatus;
4129 ZFCP_LOG_NORMAL("bug: An invalid FCP response "
4130 "code was detected for a command. "
4131 "The problem occured on the unit "
4132 "0x%016Lx on port 0x%016Lx on "
4133 "adapter %s (debug info 0x%x)\n",
4136 zfcp_get_busid_by_unit(unit),
4138 /* dump SCSI CDB as prepared by zfcp */
4139 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
4140 (char *) &fsf_req->qtcb->
4141 bottom.io.fcp_cmnd, FSF_FCP_CMND_SIZE);
4142 zfcp_cmd_dbf_event_fsf("undeffcp", fsf_req, NULL, 0);
4143 set_host_byte(&scpnt->result, DID_ERROR);
4147 /* check for sense data */
4148 if (unlikely(fcp_rsp_iu->validity.bits.fcp_sns_len_valid)) {
4149 sns_len = FSF_FCP_RSP_SIZE -
4150 sizeof (struct fcp_rsp_iu) + fcp_rsp_iu->fcp_rsp_len;
4151 ZFCP_LOG_TRACE("room for %i bytes sense data in QTCB\n",
4153 sns_len = min(sns_len, (u32) SCSI_SENSE_BUFFERSIZE);
4154 ZFCP_LOG_TRACE("room for %i bytes sense data in SCSI command\n",
4155 SCSI_SENSE_BUFFERSIZE);
4156 sns_len = min(sns_len, fcp_rsp_iu->fcp_sns_len);
4157 ZFCP_LOG_TRACE("scpnt->result =0x%x, command was:\n",
4159 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_TRACE,
4160 (void *) &scpnt->cmnd, scpnt->cmd_len);
4162 ZFCP_LOG_TRACE("%i bytes sense data provided by FCP\n",
4163 fcp_rsp_iu->fcp_sns_len);
4164 memcpy(&scpnt->sense_buffer,
4165 zfcp_get_fcp_sns_info_ptr(fcp_rsp_iu), sns_len);
4166 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_TRACE,
4167 (void *) &scpnt->sense_buffer, sns_len);
4170 /* check for overrun */
4171 if (unlikely(fcp_rsp_iu->validity.bits.fcp_resid_over)) {
4172 ZFCP_LOG_INFO("A data overrun was detected for a command. "
4173 "unit 0x%016Lx, port 0x%016Lx, adapter %s. "
4174 "The response data length is "
4175 "%d, the original length was %d.\n",
4178 zfcp_get_busid_by_unit(unit),
4179 fcp_rsp_iu->fcp_resid,
4180 (int) zfcp_get_fcp_dl(fcp_cmnd_iu));
4183 /* check for underrun */
4184 if (unlikely(fcp_rsp_iu->validity.bits.fcp_resid_under)) {
4185 ZFCP_LOG_DEBUG("A data underrun was detected for a command. "
4186 "unit 0x%016Lx, port 0x%016Lx, adapter %s. "
4187 "The response data length is "
4188 "%d, the original length was %d.\n",
4191 zfcp_get_busid_by_unit(unit),
4192 fcp_rsp_iu->fcp_resid,
4193 (int) zfcp_get_fcp_dl(fcp_cmnd_iu));
4195 * It may not have been possible to send all data and the
4196 * underrun on send may already be in scpnt->resid, so it's add
4197 * not equals in the below statement.
4199 scpnt->resid += fcp_rsp_iu->fcp_resid;
4200 ZFCP_LOG_TRACE("scpnt->resid=0x%x\n", scpnt->resid);
4204 ZFCP_LOG_DEBUG("scpnt->result =0x%x\n", scpnt->result);
4206 zfcp_cmd_dbf_event_scsi("response", scpnt);
4208 /* cleanup pointer (need this especially for abort) */
4209 scpnt->host_scribble = NULL;
4213 * according to the outcome of a discussion on linux-scsi we
4214 * don't need to grab the io_request_lock here since we use
4217 /* always call back */
4219 (scpnt->scsi_done) (scpnt);
4222 * We must hold this lock until scsi_done has been called.
4223 * Otherwise we may call scsi_done after abort regarding this
4224 * command has completed.
4225 * Note: scsi_done must not block!
4228 read_unlock_irqrestore(&fsf_req->adapter->abort_lock, flags);
4233 * function: zfcp_fsf_send_fcp_command_task_management_handler
4235 * purpose: evaluates FCP_RSP IU
4240 zfcp_fsf_send_fcp_command_task_management_handler(struct zfcp_fsf_req *fsf_req)
4243 struct fcp_rsp_iu *fcp_rsp_iu = (struct fcp_rsp_iu *)
4244 &(fsf_req->qtcb->bottom.io.fcp_rsp);
4245 char *fcp_rsp_info = zfcp_get_fcp_rsp_info_ptr(fcp_rsp_iu);
4246 struct zfcp_unit *unit =
4247 fsf_req->data.send_fcp_command_task_management.unit;
4249 del_timer(&fsf_req->adapter->scsi_er_timer);
4250 if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) {
4251 fsf_req->status |= ZFCP_STATUS_FSFREQ_TMFUNCFAILED;
4252 goto skip_fsfstatus;
4255 /* check FCP_RSP_INFO */
4256 switch (fcp_rsp_info[3]) {
4258 ZFCP_LOG_FLAGS(3, "RSP_CODE_GOOD\n");
4260 ZFCP_LOG_DEBUG("no failure or Task Management "
4261 "Function complete\n");
4263 case RSP_CODE_TASKMAN_UNSUPP:
4264 ZFCP_LOG_FLAGS(0, "RSP_CODE_TASKMAN_UNSUPP\n");
4265 ZFCP_LOG_NORMAL("bug: A reuested task management function "
4266 "is not supported on the target device "
4267 "unit 0x%016Lx, port 0x%016Lx, adapter %s\n ",
4270 zfcp_get_busid_by_unit(unit));
4271 fsf_req->status |= ZFCP_STATUS_FSFREQ_TMFUNCNOTSUPP;
4273 case RSP_CODE_TASKMAN_FAILED:
4274 ZFCP_LOG_FLAGS(0, "RSP_CODE_TASKMAN_FAILED\n");
4275 ZFCP_LOG_NORMAL("bug: A reuested task management function "
4276 "failed to complete successfully. "
4277 "unit 0x%016Lx, port 0x%016Lx, adapter %s.\n",
4280 zfcp_get_busid_by_unit(unit));
4281 fsf_req->status |= ZFCP_STATUS_FSFREQ_TMFUNCFAILED;
4284 ZFCP_LOG_NORMAL("bug: An invalid FCP response "
4285 "code was detected for a command. "
4286 "unit 0x%016Lx, port 0x%016Lx, adapter %s "
4287 "(debug info 0x%x)\n",
4290 zfcp_get_busid_by_unit(unit),
4292 fsf_req->status |= ZFCP_STATUS_FSFREQ_TMFUNCFAILED;
4301 * function: zfcp_fsf_control_file
4303 * purpose: Initiator of the control file upload/download FSF requests
4305 * returns: 0 - FSF request is successfuly created and queued
4306 * -EOPNOTSUPP - The FCP adapter does not have Control File support
4307 * -EINVAL - Invalid direction specified
4308 * -ENOMEM - Insufficient memory
4309 * -EPERM - Cannot create FSF request or or place it in QDIO queue
4312 zfcp_fsf_control_file(struct zfcp_adapter *adapter,
4313 struct zfcp_fsf_req **fsf_req_ptr,
4316 struct zfcp_sg_list *sg_list)
4318 struct zfcp_fsf_req *fsf_req;
4319 struct fsf_qtcb_bottom_support *bottom;
4320 volatile struct qdio_buffer_element *sbale;
4321 unsigned long lock_flags;
4326 if (!(adapter->supported_features & FSF_FEATURE_CFDC)) {
4328 "Adapter %s does not support control file\n",
4329 zfcp_get_busid_by_adapter(adapter));
4330 retval = -EOPNOTSUPP;
4331 goto no_cfdc_support;
4334 switch (fsf_command) {
4336 case FSF_QTCB_DOWNLOAD_CONTROL_FILE:
4337 direction = SBAL_FLAGS0_TYPE_WRITE;
4338 if ((option != FSF_CFDC_OPTION_FULL_ACCESS) &&
4339 (option != FSF_CFDC_OPTION_RESTRICTED_ACCESS))
4340 req_flags = ZFCP_WAIT_FOR_SBAL;
4343 case FSF_QTCB_UPLOAD_CONTROL_FILE:
4344 direction = SBAL_FLAGS0_TYPE_READ;
4348 ZFCP_LOG_INFO("Invalid FSF command code 0x%08x\n", fsf_command);
4349 goto invalid_command;
4352 retval = zfcp_fsf_req_create(adapter, fsf_command, req_flags,
4353 NULL, &lock_flags, &fsf_req);
4355 ZFCP_LOG_INFO("error: Could not create FSF request for the "
4357 zfcp_get_busid_by_adapter(adapter));
4362 sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0);
4363 sbale[0].flags |= direction;
4365 bottom = &fsf_req->qtcb->bottom.support;
4366 bottom->operation_subtype = FSF_CFDC_OPERATION_SUBTYPE;
4367 bottom->option = option;
4369 if (sg_list->count > 0) {
4372 bytes = zfcp_qdio_sbals_from_sg(fsf_req, direction,
4373 sg_list->sg, sg_list->count,
4374 ZFCP_MAX_SBALS_PER_REQ);
4375 if (bytes != ZFCP_CFDC_MAX_CONTROL_FILE_SIZE) {
4377 "error: Could not create sufficient number of "
4378 "SBALS for an FSF request to the adapter %s\n",
4379 zfcp_get_busid_by_adapter(adapter));
4384 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
4387 retval = zfcp_fsf_req_send(fsf_req, NULL);
4390 "error: Could not send FSF request to the adapter %s\n",
4391 zfcp_get_busid_by_adapter(adapter));
4397 "Control file %s FSF request has been sent to the adapter %s\n",
4398 fsf_command == FSF_QTCB_DOWNLOAD_CONTROL_FILE ?
4399 "download" : "upload",
4400 zfcp_get_busid_by_adapter(adapter));
4402 *fsf_req_ptr = fsf_req;
4408 zfcp_fsf_req_free(fsf_req);
4411 write_unlock_irqrestore(&adapter->request_queue.queue_lock, lock_flags);
4420 * function: zfcp_fsf_control_file_handler
4422 * purpose: Handler of the control file upload/download FSF requests
4424 * returns: 0 - FSF request successfuly processed
4425 * -EAGAIN - Operation has to be repeated because of a temporary problem
4426 * -EACCES - There is no permission to execute an operation
4427 * -EPERM - The control file is not in a right format
4428 * -EIO - There is a problem with the FCP adapter
4429 * -EINVAL - Invalid operation
4430 * -EFAULT - User space memory I/O operation fault
4433 zfcp_fsf_control_file_handler(struct zfcp_fsf_req *fsf_req)
4435 struct zfcp_adapter *adapter = fsf_req->adapter;
4436 struct fsf_qtcb_header *header = &fsf_req->qtcb->header;
4437 struct fsf_qtcb_bottom_support *bottom = &fsf_req->qtcb->bottom.support;
4440 if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) {
4442 goto skip_fsfstatus;
4445 switch (header->fsf_status) {
4448 ZFCP_LOG_FLAGS(2, "FSF_GOOD\n");
4450 "The FSF request has been successfully completed "
4451 "on the adapter %s\n",
4452 zfcp_get_busid_by_adapter(adapter));
4455 case FSF_OPERATION_PARTIALLY_SUCCESSFUL:
4456 ZFCP_LOG_FLAGS(2, "FSF_OPERATION_PARTIALLY_SUCCESSFUL\n");
4457 if (bottom->operation_subtype == FSF_CFDC_OPERATION_SUBTYPE) {
4458 switch (header->fsf_status_qual.word[0]) {
4460 case FSF_SQ_CFDC_COULD_NOT_HARDEN_ON_SE:
4462 "CFDC of the adapter %s could not "
4463 "be saved on the SE\n",
4464 zfcp_get_busid_by_adapter(adapter));
4467 case FSF_SQ_CFDC_COULD_NOT_HARDEN_ON_SE2:
4469 "CFDC of the adapter %s could not "
4470 "be copied to the secondary SE\n",
4471 zfcp_get_busid_by_adapter(adapter));
4476 "CFDC could not be hardened "
4477 "on the adapter %s\n",
4478 zfcp_get_busid_by_adapter(adapter));
4481 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
4485 case FSF_AUTHORIZATION_FAILURE:
4486 ZFCP_LOG_FLAGS(2, "FSF_AUTHORIZATION_FAILURE\n");
4488 "Adapter %s does not accept privileged commands\n",
4489 zfcp_get_busid_by_adapter(adapter));
4490 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
4494 case FSF_CFDC_ERROR_DETECTED:
4495 ZFCP_LOG_FLAGS(2, "FSF_CFDC_ERROR_DETECTED\n");
4497 "Error at position %d in the CFDC, "
4498 "CFDC is discarded by the adapter %s\n",
4499 header->fsf_status_qual.word[0],
4500 zfcp_get_busid_by_adapter(adapter));
4501 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
4505 case FSF_CONTROL_FILE_UPDATE_ERROR:
4506 ZFCP_LOG_FLAGS(2, "FSF_CONTROL_FILE_UPDATE_ERROR\n");
4508 "Adapter %s cannot harden the control file, "
4509 "file is discarded\n",
4510 zfcp_get_busid_by_adapter(adapter));
4511 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
4515 case FSF_CONTROL_FILE_TOO_LARGE:
4516 ZFCP_LOG_FLAGS(2, "FSF_CONTROL_FILE_TOO_LARGE\n");
4518 "Control file is too large, file is discarded "
4519 "by the adapter %s\n",
4520 zfcp_get_busid_by_adapter(adapter));
4521 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
4525 case FSF_ACCESS_CONFLICT_DETECTED:
4526 ZFCP_LOG_FLAGS(2, "FSF_ACCESS_CONFLICT_DETECTED\n");
4527 if (bottom->operation_subtype == FSF_CFDC_OPERATION_SUBTYPE)
4529 "CFDC has been discarded by the adapter %s, "
4530 "because activation would impact "
4531 "%d active connection(s)\n",
4532 zfcp_get_busid_by_adapter(adapter),
4533 header->fsf_status_qual.word[0]);
4534 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
4538 case FSF_CONFLICTS_OVERRULED:
4539 ZFCP_LOG_FLAGS(2, "FSF_CONFLICTS_OVERRULED\n");
4540 if (bottom->operation_subtype == FSF_CFDC_OPERATION_SUBTYPE)
4542 "CFDC has been activated on the adapter %s, "
4543 "but activation has impacted "
4544 "%d active connection(s)\n",
4545 zfcp_get_busid_by_adapter(adapter),
4546 header->fsf_status_qual.word[0]);
4547 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
4551 case FSF_UNKNOWN_OP_SUBTYPE:
4552 ZFCP_LOG_FLAGS(2, "FSF_UNKNOWN_OP_SUBTYPE\n");
4554 "Invalid operation subtype 0x%x has been specified "
4555 "in QTCB bottom sent to the adapter %s\n",
4556 bottom->operation_subtype,
4557 zfcp_get_busid_by_adapter(adapter));
4558 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
4562 case FSF_INVALID_COMMAND_OPTION:
4563 ZFCP_LOG_FLAGS(2, "FSF_INVALID_COMMAND_OPTION\n");
4565 "Invalid option 0x%x has been specified "
4566 "in QTCB bottom sent to the adapter %s\n",
4568 zfcp_get_busid_by_adapter(adapter));
4569 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
4575 "bug: An unknown/unexpected FSF status 0x%08x "
4576 "was presented on the adapter %s\n",
4578 zfcp_get_busid_by_adapter(adapter));
4579 debug_text_event(fsf_req->adapter->erp_dbf, 0, "fsf_sq_inval");
4580 debug_exception(fsf_req->adapter->erp_dbf, 0,
4581 &header->fsf_status_qual.word[0], sizeof(u32));
4582 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
4593 * function: zfcp_fsf_req_wait_and_cleanup
4597 * FIXME(design): signal seems to be <0 !!!
4598 * returns: 0 - request completed (*status is valid), cleanup succ.
4599 * <0 - request completed (*status is valid), cleanup failed
4600 * >0 - signal which interrupted waiting (*status invalid),
4601 * request not completed, no cleanup
4603 * *status is a copy of status of completed fsf_req
4606 zfcp_fsf_req_wait_and_cleanup(struct zfcp_fsf_req *fsf_req,
4607 int interruptible, u32 * status)
4612 if (interruptible) {
4613 __wait_event_interruptible(fsf_req->completion_wq,
4615 ZFCP_STATUS_FSFREQ_COMPLETED,
4618 ZFCP_LOG_DEBUG("Caught signal %i while waiting for the "
4619 "completion of the request at %p\n",
4625 __wait_event(fsf_req->completion_wq,
4626 fsf_req->status & ZFCP_STATUS_FSFREQ_COMPLETED);
4629 *status = fsf_req->status;
4631 /* cleanup request */
4632 zfcp_fsf_req_cleanup(fsf_req);
4638 zfcp_fsf_req_sbal_check(unsigned long *flags,
4639 struct zfcp_qdio_queue *queue, int needed)
4641 write_lock_irqsave(&queue->queue_lock, *flags);
4642 if (likely(atomic_read(&queue->free_count) >= needed))
4644 write_unlock_irqrestore(&queue->queue_lock, *flags);
4649 * set qtcb pointer in fsf_req and initialize QTCB
4652 zfcp_fsf_req_qtcb_init(struct zfcp_fsf_req *fsf_req, u32 fsf_cmd)
4654 if (likely(fsf_req->qtcb != NULL)) {
4655 fsf_req->qtcb->prefix.req_id = (unsigned long)fsf_req;
4656 fsf_req->qtcb->prefix.ulp_info = ZFCP_ULP_INFO_VERSION;
4657 fsf_req->qtcb->prefix.qtcb_type = fsf_qtcb_type[fsf_cmd];
4658 fsf_req->qtcb->prefix.qtcb_version = ZFCP_QTCB_VERSION;
4659 fsf_req->qtcb->header.req_handle = (unsigned long)fsf_req;
4660 fsf_req->qtcb->header.fsf_command = fsf_cmd;
4665 * zfcp_fsf_req_sbal_get - try to get one SBAL in the request queue
4666 * @adapter: adapter for which request queue is examined
4667 * @req_flags: flags indicating whether to wait for needed SBAL or not
4668 * @lock_flags: lock_flags if queue_lock is taken
4669 * Return: 0 on success, otherwise -EIO, or -ERESTARTSYS
4670 * Locks: lock adapter->request_queue->queue_lock on success
4673 zfcp_fsf_req_sbal_get(struct zfcp_adapter *adapter, int req_flags,
4674 unsigned long *lock_flags)
4677 struct zfcp_qdio_queue *req_queue = &adapter->request_queue;
4679 if (unlikely(req_flags & ZFCP_WAIT_FOR_SBAL)) {
4680 ret = wait_event_interruptible_timeout(adapter->request_wq,
4681 zfcp_fsf_req_sbal_check(lock_flags, req_queue, 1),
4685 } else if (!zfcp_fsf_req_sbal_check(lock_flags, req_queue, 1))
4692 * function: zfcp_fsf_req_create
4694 * purpose: create an FSF request at the specified adapter and
4695 * setup common fields
4697 * returns: -ENOMEM if there was insufficient memory for a request
4698 * -EIO if no qdio buffers could be allocate to the request
4699 * -EINVAL/-EPERM on bug conditions in req_dequeue
4702 * note: The created request is returned by reference.
4704 * locks: lock of concerned request queue must not be held,
4705 * but is held on completion (write, irqsave)
4708 zfcp_fsf_req_create(struct zfcp_adapter *adapter, u32 fsf_cmd, int req_flags,
4709 mempool_t *pool, unsigned long *lock_flags,
4710 struct zfcp_fsf_req **fsf_req_p)
4712 volatile struct qdio_buffer_element *sbale;
4713 struct zfcp_fsf_req *fsf_req = NULL;
4715 struct zfcp_qdio_queue *req_queue = &adapter->request_queue;
4717 /* allocate new FSF request */
4718 fsf_req = zfcp_fsf_req_alloc(pool, req_flags);
4719 if (unlikely(NULL == fsf_req)) {
4720 ZFCP_LOG_DEBUG("error: Could not put an FSF request into"
4721 "the outbound (send) queue.\n");
4723 goto failed_fsf_req;
4726 zfcp_fsf_req_qtcb_init(fsf_req, fsf_cmd);
4728 /* initialize waitqueue which may be used to wait on
4729 this request completion */
4730 init_waitqueue_head(&fsf_req->completion_wq);
4732 ret = zfcp_fsf_req_sbal_get(adapter, req_flags, lock_flags);
4738 * We hold queue_lock here. Check if QDIOUP is set and let request fail
4739 * if it is not set (see also *_open_qdio and *_close_qdio).
4742 if (!atomic_test_mask(ZFCP_STATUS_ADAPTER_QDIOUP, &adapter->status)) {
4743 write_unlock_irqrestore(&req_queue->queue_lock, *lock_flags);
4748 fsf_req->adapter = adapter; /* pointer to "parent" adapter */
4749 fsf_req->fsf_command = fsf_cmd;
4750 fsf_req->sbal_number = 1;
4751 fsf_req->sbal_first = req_queue->free_index;
4752 fsf_req->sbal_curr = req_queue->free_index;
4753 fsf_req->sbale_curr = 1;
4755 if (likely(req_flags & ZFCP_REQ_AUTO_CLEANUP)) {
4756 fsf_req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
4759 sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0);
4761 /* setup common SBALE fields */
4762 sbale[0].addr = fsf_req;
4763 sbale[0].flags |= SBAL_FLAGS0_COMMAND;
4764 if (likely(fsf_req->qtcb != NULL)) {
4765 sbale[1].addr = (void *) fsf_req->qtcb;
4766 sbale[1].length = sizeof(struct fsf_qtcb);
4769 ZFCP_LOG_TRACE("got %i free BUFFERs starting at index %i\n",
4770 fsf_req->sbal_number, fsf_req->sbal_first);
4775 /* dequeue new FSF request previously enqueued */
4776 zfcp_fsf_req_free(fsf_req);
4780 write_lock_irqsave(&req_queue->queue_lock, *lock_flags);
4782 *fsf_req_p = fsf_req;
4787 * function: zfcp_fsf_req_send
4789 * purpose: start transfer of FSF request via QDIO
4791 * returns: 0 - request transfer succesfully started
4792 * !0 - start of request transfer failed
4795 zfcp_fsf_req_send(struct zfcp_fsf_req *fsf_req, struct timer_list *timer)
4797 struct zfcp_adapter *adapter;
4798 struct zfcp_qdio_queue *req_queue;
4799 volatile struct qdio_buffer_element *sbale;
4800 int new_distance_from_int;
4801 unsigned long flags;
4805 adapter = fsf_req->adapter;
4806 req_queue = &adapter->request_queue,
4809 /* FIXME(debug): remove it later */
4810 sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_first, 0);
4811 ZFCP_LOG_DEBUG("SBALE0 flags=0x%x\n", sbale[0].flags);
4812 ZFCP_LOG_TRACE("HEX DUMP OF SBALE1 PAYLOAD:\n");
4813 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_TRACE, (char *) sbale[1].addr,
4816 /* set sequence counter in QTCB */
4817 if (likely(fsf_req->qtcb)) {
4818 fsf_req->qtcb->prefix.req_seq_no = adapter->fsf_req_seq_no;
4819 fsf_req->seq_no = adapter->fsf_req_seq_no;
4820 ZFCP_LOG_TRACE("FSF request %p of adapter %s gets "
4821 "FSF sequence counter value of %i\n",
4823 zfcp_get_busid_by_adapter(adapter),
4824 fsf_req->qtcb->prefix.req_seq_no);
4828 /* put allocated FSF request at list tail */
4829 write_lock_irqsave(&adapter->fsf_req_list_lock, flags);
4830 list_add_tail(&fsf_req->list, &adapter->fsf_req_list_head);
4831 write_unlock_irqrestore(&adapter->fsf_req_list_lock, flags);
4833 /* figure out expiration time of timeout and start timeout */
4834 if (unlikely(timer)) {
4835 timer->expires += jiffies;
4839 ZFCP_LOG_TRACE("request queue of adapter %s: "
4840 "next free SBAL is %i, %i free SBALs\n",
4841 zfcp_get_busid_by_adapter(adapter),
4842 req_queue->free_index,
4843 atomic_read(&req_queue->free_count));
4845 ZFCP_LOG_DEBUG("calling do_QDIO adapter %s, flags=0x%x, queue_no=%i, "
4846 "index_in_queue=%i, count=%i, buffers=%p\n",
4847 zfcp_get_busid_by_adapter(adapter),
4848 QDIO_FLAG_SYNC_OUTPUT,
4849 0, fsf_req->sbal_first, fsf_req->sbal_number,
4850 &req_queue->buffer[fsf_req->sbal_first]);
4853 * adjust the number of free SBALs in request queue as well as
4854 * position of first one
4856 atomic_sub(fsf_req->sbal_number, &req_queue->free_count);
4857 ZFCP_LOG_TRACE("free_count=%d\n", atomic_read(&req_queue->free_count));
4858 req_queue->free_index += fsf_req->sbal_number; /* increase */
4859 req_queue->free_index %= QDIO_MAX_BUFFERS_PER_Q; /* wrap if needed */
4860 new_distance_from_int = zfcp_qdio_determine_pci(req_queue, fsf_req);
4862 retval = do_QDIO(adapter->ccw_device,
4863 QDIO_FLAG_SYNC_OUTPUT,
4864 0, fsf_req->sbal_first, fsf_req->sbal_number, NULL);
4866 if (unlikely(retval)) {
4867 /* Queues are down..... */
4870 * FIXME(potential race):
4871 * timer might be expired (absolutely unlikely)
4874 del_timer_sync(timer);
4875 write_lock_irqsave(&adapter->fsf_req_list_lock, flags);
4876 list_del(&fsf_req->list);
4877 write_unlock_irqrestore(&adapter->fsf_req_list_lock, flags);
4879 * adjust the number of free SBALs in request queue as well as
4880 * position of first one
4882 zfcp_qdio_zero_sbals(req_queue->buffer,
4883 fsf_req->sbal_first, fsf_req->sbal_number);
4884 atomic_add(fsf_req->sbal_number, &req_queue->free_count);
4885 req_queue->free_index -= fsf_req->sbal_number; /* increase */
4886 req_queue->free_index += QDIO_MAX_BUFFERS_PER_Q;
4887 req_queue->free_index %= QDIO_MAX_BUFFERS_PER_Q; /* wrap */
4889 ("error: do_QDIO failed. Buffers could not be enqueued "
4890 "to request queue.\n");
4892 req_queue->distance_from_int = new_distance_from_int;
4894 * increase FSF sequence counter -
4895 * this must only be done for request successfully enqueued to
4896 * QDIO this rejected requests may be cleaned up by calling
4897 * routines resulting in missing sequence counter values
4900 /* Don't increase for unsolicited status */
4901 if (likely(inc_seq_no)) {
4902 adapter->fsf_req_seq_no++;
4904 ("FSF sequence counter value of adapter %s "
4905 "increased to %i\n",
4906 zfcp_get_busid_by_adapter(adapter),
4907 adapter->fsf_req_seq_no);
4909 /* count FSF requests pending */
4910 atomic_inc(&adapter->fsf_reqs_active);
4916 * function: zfcp_fsf_req_cleanup
4918 * purpose: cleans up an FSF request and removes it from the specified list
4922 * assumption: no pending SB in SBALEs other than QTCB
4925 zfcp_fsf_req_cleanup(struct zfcp_fsf_req *fsf_req)
4927 struct zfcp_adapter *adapter = fsf_req->adapter;
4928 unsigned long flags;
4930 write_lock_irqsave(&adapter->fsf_req_list_lock, flags);
4931 list_del(&fsf_req->list);
4932 write_unlock_irqrestore(&adapter->fsf_req_list_lock, flags);
4933 zfcp_fsf_req_free(fsf_req);
4936 #undef ZFCP_LOG_AREA