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>
15 * Andreas Herrmann <aherrman@de.ibm.com>
16 * Volker Sameske <sameske@de.ibm.com>
18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation; either version 2, or (at your option)
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
28 * You should have received a copy of the GNU General Public License
29 * along with this program; if not, write to the Free Software
30 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
33 #define ZFCP_FSF_C_REVISION "$Revision: 1.92 $"
37 static int zfcp_fsf_exchange_config_data_handler(struct zfcp_fsf_req
*);
38 static void zfcp_fsf_exchange_port_data_handler(struct zfcp_fsf_req
*);
39 static int zfcp_fsf_open_port_handler(struct zfcp_fsf_req
*);
40 static int zfcp_fsf_close_port_handler(struct zfcp_fsf_req
*);
41 static int zfcp_fsf_close_physical_port_handler(struct zfcp_fsf_req
*);
42 static int zfcp_fsf_open_unit_handler(struct zfcp_fsf_req
*);
43 static int zfcp_fsf_close_unit_handler(struct zfcp_fsf_req
*);
44 static int zfcp_fsf_send_fcp_command_handler(struct zfcp_fsf_req
*);
45 static int zfcp_fsf_send_fcp_command_task_handler(struct zfcp_fsf_req
*);
46 static int zfcp_fsf_send_fcp_command_task_management_handler(
47 struct zfcp_fsf_req
*);
48 static int zfcp_fsf_abort_fcp_command_handler(struct zfcp_fsf_req
*);
49 static int zfcp_fsf_status_read_handler(struct zfcp_fsf_req
*);
50 static int zfcp_fsf_send_ct_handler(struct zfcp_fsf_req
*);
51 static int zfcp_fsf_send_els_handler(struct zfcp_fsf_req
*);
52 static int zfcp_fsf_control_file_handler(struct zfcp_fsf_req
*);
53 static inline int zfcp_fsf_req_sbal_check(
54 unsigned long *, struct zfcp_qdio_queue
*, int);
55 static inline int zfcp_use_one_sbal(
56 struct scatterlist
*, int, struct scatterlist
*, int);
57 static struct zfcp_fsf_req
*zfcp_fsf_req_alloc(mempool_t
*, int);
58 static int zfcp_fsf_req_send(struct zfcp_fsf_req
*, struct timer_list
*);
59 static int zfcp_fsf_protstatus_eval(struct zfcp_fsf_req
*);
60 static int zfcp_fsf_fsfstatus_eval(struct zfcp_fsf_req
*);
61 static int zfcp_fsf_fsfstatus_qual_eval(struct zfcp_fsf_req
*);
62 static int zfcp_fsf_req_dispatch(struct zfcp_fsf_req
*);
63 static void zfcp_fsf_req_dismiss(struct zfcp_fsf_req
*);
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
)
172 struct zfcp_fsf_req
*fsf_req
, *tmp
;
174 LIST_HEAD(remove_queue
);
176 spin_lock_irqsave(&adapter
->fsf_req_list_lock
, flags
);
177 list_splice_init(&adapter
->fsf_req_list_head
, &remove_queue
);
178 atomic_set(&adapter
->fsf_reqs_active
, 0);
179 spin_unlock_irqrestore(&adapter
->fsf_req_list_lock
, flags
);
181 list_for_each_entry_safe(fsf_req
, tmp
, &remove_queue
, list
) {
182 list_del(&fsf_req
->list
);
183 zfcp_fsf_req_dismiss(fsf_req
);
197 zfcp_fsf_req_dismiss(struct zfcp_fsf_req
*fsf_req
)
199 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_DISMISSED
;
200 zfcp_fsf_req_complete(fsf_req
);
204 * function: zfcp_fsf_req_complete
206 * purpose: Updates active counts and timers for openfcp-reqs
207 * May cleanup request after req_eval returns
209 * returns: 0 - success
215 zfcp_fsf_req_complete(struct zfcp_fsf_req
*fsf_req
)
220 if (unlikely(fsf_req
->fsf_command
== FSF_QTCB_UNSOLICITED_STATUS
)) {
221 ZFCP_LOG_DEBUG("Status read response received\n");
223 * Note: all cleanup handling is done in the callchain of
224 * the function call-chain below.
226 zfcp_fsf_status_read_handler(fsf_req
);
229 zfcp_fsf_protstatus_eval(fsf_req
);
232 * fsf_req may be deleted due to waking up functions, so
233 * cleanup is saved here and used later
235 if (likely(fsf_req
->status
& ZFCP_STATUS_FSFREQ_CLEANUP
))
240 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_COMPLETED
;
242 /* cleanup request if requested by initiator */
243 if (likely(cleanup
)) {
244 ZFCP_LOG_TRACE("removing FSF request %p\n", fsf_req
);
246 * lock must not be held here since it will be
247 * grabed by the called routine, too
249 zfcp_fsf_req_free(fsf_req
);
251 /* notify initiator waiting for the requests completion */
252 ZFCP_LOG_TRACE("waking initiator of FSF request %p\n",fsf_req
);
254 * FIXME: Race! We must not access fsf_req here as it might have been
255 * cleaned up already due to the set ZFCP_STATUS_FSFREQ_COMPLETED
256 * flag. It's an improbable case. But, we have the same paranoia for
257 * the cleanup flag already.
258 * Might better be handled using complete()?
259 * (setting the flag and doing wakeup ought to be atomic
260 * with regard to checking the flag as long as waitqueue is
261 * part of the to be released structure)
263 wake_up(&fsf_req
->completion_wq
);
271 * function: zfcp_fsf_protstatus_eval
273 * purpose: evaluates the QTCB of the finished FSF request
274 * and initiates appropriate actions
275 * (usually calling FSF command specific handlers)
284 zfcp_fsf_protstatus_eval(struct zfcp_fsf_req
*fsf_req
)
287 struct zfcp_adapter
*adapter
= fsf_req
->adapter
;
289 ZFCP_LOG_DEBUG("QTCB is at %p\n", fsf_req
->qtcb
);
291 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_DISMISSED
) {
292 ZFCP_LOG_DEBUG("fsf_req 0x%lx has been dismissed\n",
293 (unsigned long) fsf_req
);
294 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
|
295 ZFCP_STATUS_FSFREQ_RETRY
; /* only for SCSI cmnds. */
296 zfcp_cmd_dbf_event_fsf("dismiss", fsf_req
, NULL
, 0);
297 goto skip_protstatus
;
300 /* log additional information provided by FSF (if any) */
301 if (unlikely(fsf_req
->qtcb
->header
.log_length
)) {
302 /* do not trust them ;-) */
303 if (fsf_req
->qtcb
->header
.log_start
> sizeof(struct fsf_qtcb
)) {
305 ("bug: ULP (FSF logging) log data starts "
306 "beyond end of packet header. Ignored. "
307 "(start=%i, size=%li)\n",
308 fsf_req
->qtcb
->header
.log_start
,
309 sizeof(struct fsf_qtcb
));
312 if ((size_t) (fsf_req
->qtcb
->header
.log_start
+
313 fsf_req
->qtcb
->header
.log_length
)
314 > sizeof(struct fsf_qtcb
)) {
315 ZFCP_LOG_NORMAL("bug: ULP (FSF logging) log data ends "
316 "beyond end of packet header. Ignored. "
317 "(start=%i, length=%i, size=%li)\n",
318 fsf_req
->qtcb
->header
.log_start
,
319 fsf_req
->qtcb
->header
.log_length
,
320 sizeof(struct fsf_qtcb
));
323 ZFCP_LOG_TRACE("ULP log data: \n");
324 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_TRACE
,
325 (char *) fsf_req
->qtcb
+
326 fsf_req
->qtcb
->header
.log_start
,
327 fsf_req
->qtcb
->header
.log_length
);
331 /* evaluate FSF Protocol Status */
332 switch (fsf_req
->qtcb
->prefix
.prot_status
) {
335 case FSF_PROT_FSF_STATUS_PRESENTED
:
338 case FSF_PROT_QTCB_VERSION_ERROR
:
339 ZFCP_LOG_NORMAL("error: The adapter %s contains "
340 "microcode of version 0x%x, the device driver "
341 "only supports 0x%x. Aborting.\n",
342 zfcp_get_busid_by_adapter(adapter
),
343 fsf_req
->qtcb
->prefix
.prot_status_qual
.
344 version_error
.fsf_version
, ZFCP_QTCB_VERSION
);
345 /* stop operation for this adapter */
346 debug_text_exception(adapter
->erp_dbf
, 0, "prot_ver_err");
347 zfcp_erp_adapter_shutdown(adapter
, 0);
348 zfcp_cmd_dbf_event_fsf("qverserr", fsf_req
,
349 &fsf_req
->qtcb
->prefix
.prot_status_qual
,
350 sizeof (union fsf_prot_status_qual
));
351 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
354 case FSF_PROT_SEQ_NUMB_ERROR
:
355 ZFCP_LOG_NORMAL("bug: Sequence number mismatch between "
356 "driver (0x%x) and adapter %s (0x%x). "
357 "Restarting all operations on this adapter.\n",
358 fsf_req
->qtcb
->prefix
.req_seq_no
,
359 zfcp_get_busid_by_adapter(adapter
),
360 fsf_req
->qtcb
->prefix
.prot_status_qual
.
361 sequence_error
.exp_req_seq_no
);
362 debug_text_exception(adapter
->erp_dbf
, 0, "prot_seq_err");
363 /* restart operation on this adapter */
364 zfcp_erp_adapter_reopen(adapter
, 0);
365 zfcp_cmd_dbf_event_fsf("seqnoerr", fsf_req
,
366 &fsf_req
->qtcb
->prefix
.prot_status_qual
,
367 sizeof (union fsf_prot_status_qual
));
368 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_RETRY
;
369 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
372 case FSF_PROT_UNSUPP_QTCB_TYPE
:
373 ZFCP_LOG_NORMAL("error: Packet header type used by the "
374 "device driver is incompatible with "
375 "that used on adapter %s. "
376 "Stopping all operations on this adapter.\n",
377 zfcp_get_busid_by_adapter(adapter
));
378 debug_text_exception(adapter
->erp_dbf
, 0, "prot_unsup_qtcb");
379 zfcp_erp_adapter_shutdown(adapter
, 0);
380 zfcp_cmd_dbf_event_fsf("unsqtcbt", fsf_req
,
381 &fsf_req
->qtcb
->prefix
.prot_status_qual
,
382 sizeof (union fsf_prot_status_qual
));
383 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
386 case FSF_PROT_HOST_CONNECTION_INITIALIZING
:
387 zfcp_cmd_dbf_event_fsf("hconinit", fsf_req
,
388 &fsf_req
->qtcb
->prefix
.prot_status_qual
,
389 sizeof (union fsf_prot_status_qual
));
390 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
391 atomic_set_mask(ZFCP_STATUS_ADAPTER_HOST_CON_INIT
,
393 debug_text_event(adapter
->erp_dbf
, 3, "prot_con_init");
396 case FSF_PROT_DUPLICATE_REQUEST_ID
:
398 ZFCP_LOG_NORMAL("bug: The request identifier 0x%Lx "
399 "to the adapter %s is ambiguous. "
400 "Stopping all operations on this "
402 *(unsigned long long *)
403 (&fsf_req
->qtcb
->bottom
.support
.
405 zfcp_get_busid_by_adapter(adapter
));
407 ZFCP_LOG_NORMAL("bug: The request identifier %p "
408 "to the adapter %s is ambiguous. "
409 "Stopping all operations on this "
411 "(bug: got this for an unsolicited "
412 "status read request)\n",
414 zfcp_get_busid_by_adapter(adapter
));
416 debug_text_exception(adapter
->erp_dbf
, 0, "prot_dup_id");
417 zfcp_erp_adapter_shutdown(adapter
, 0);
418 zfcp_cmd_dbf_event_fsf("dupreqid", fsf_req
,
419 &fsf_req
->qtcb
->prefix
.prot_status_qual
,
420 sizeof (union fsf_prot_status_qual
));
421 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
424 case FSF_PROT_LINK_DOWN
:
426 * 'test and set' is not atomic here -
427 * it's ok as long as calls to our response queue handler
428 * (and thus execution of this code here) are serialized
431 if (!atomic_test_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED
,
433 switch (fsf_req
->qtcb
->prefix
.prot_status_qual
.
434 locallink_error
.code
) {
435 case FSF_PSQ_LINK_NOLIGHT
:
436 ZFCP_LOG_INFO("The local link to adapter %s "
437 "is down (no light detected).\n",
438 zfcp_get_busid_by_adapter(
441 case FSF_PSQ_LINK_WRAPPLUG
:
442 ZFCP_LOG_INFO("The local link to adapter %s "
443 "is down (wrap plug detected).\n",
444 zfcp_get_busid_by_adapter(
447 case FSF_PSQ_LINK_NOFCP
:
448 ZFCP_LOG_INFO("The local link to adapter %s "
449 "is down (adjacent node on "
450 "link does not support FCP).\n",
451 zfcp_get_busid_by_adapter(
455 ZFCP_LOG_INFO("The local link to adapter %s "
457 "(warning: unknown reason "
459 zfcp_get_busid_by_adapter(
465 * Due to the 'erp failed' flag the adapter won't
466 * be recovered but will be just set to 'blocked'
467 * state. All subordinary devices will have state
468 * 'blocked' and 'erp failed', too.
469 * Thus the adapter is still able to provide
470 * 'link up' status without being flooded with
472 * (note: even 'close port' is not permitted)
474 ZFCP_LOG_INFO("Stopping all operations for adapter "
476 zfcp_get_busid_by_adapter(adapter
));
477 atomic_set_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED
|
478 ZFCP_STATUS_COMMON_ERP_FAILED
,
480 zfcp_erp_adapter_reopen(adapter
, 0);
482 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
485 case FSF_PROT_REEST_QUEUE
:
486 debug_text_event(adapter
->erp_dbf
, 1, "prot_reest_queue");
487 ZFCP_LOG_INFO("The local link to adapter with "
488 "%s was re-plugged. "
489 "Re-starting operations on this adapter.\n",
490 zfcp_get_busid_by_adapter(adapter
));
491 /* All ports should be marked as ready to run again */
492 zfcp_erp_modify_adapter_status(adapter
,
493 ZFCP_STATUS_COMMON_RUNNING
,
495 zfcp_erp_adapter_reopen(adapter
,
496 ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED
497 | ZFCP_STATUS_COMMON_ERP_FAILED
);
498 zfcp_cmd_dbf_event_fsf("reestque", fsf_req
,
499 &fsf_req
->qtcb
->prefix
.prot_status_qual
,
500 sizeof (union fsf_prot_status_qual
));
501 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
504 case FSF_PROT_ERROR_STATE
:
505 ZFCP_LOG_NORMAL("error: The adapter %s "
506 "has entered the error state. "
507 "Restarting all operations on this "
509 zfcp_get_busid_by_adapter(adapter
));
510 debug_text_event(adapter
->erp_dbf
, 0, "prot_err_sta");
511 /* restart operation on this adapter */
512 zfcp_erp_adapter_reopen(adapter
, 0);
513 zfcp_cmd_dbf_event_fsf("proterrs", fsf_req
,
514 &fsf_req
->qtcb
->prefix
.prot_status_qual
,
515 sizeof (union fsf_prot_status_qual
));
516 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_RETRY
;
517 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
521 ZFCP_LOG_NORMAL("bug: Transfer protocol status information "
522 "provided by the adapter %s "
523 "is not compatible with the device driver. "
524 "Stopping all operations on this adapter. "
525 "(debug info 0x%x).\n",
526 zfcp_get_busid_by_adapter(adapter
),
527 fsf_req
->qtcb
->prefix
.prot_status
);
528 debug_text_event(adapter
->erp_dbf
, 0, "prot_inval:");
529 debug_exception(adapter
->erp_dbf
, 0,
530 &fsf_req
->qtcb
->prefix
.prot_status
,
532 zfcp_erp_adapter_shutdown(adapter
, 0);
533 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
538 * always call specific handlers to give them a chance to do
539 * something meaningful even in error cases
541 zfcp_fsf_fsfstatus_eval(fsf_req
);
546 * function: zfcp_fsf_fsfstatus_eval
548 * purpose: evaluates FSF status of completed FSF request
549 * and acts accordingly
554 zfcp_fsf_fsfstatus_eval(struct zfcp_fsf_req
*fsf_req
)
558 if (unlikely(fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
)) {
562 /* evaluate FSF Status */
563 switch (fsf_req
->qtcb
->header
.fsf_status
) {
564 case FSF_UNKNOWN_COMMAND
:
565 ZFCP_LOG_NORMAL("bug: Command issued by the device driver is "
566 "not known by the adapter %s "
567 "Stopping all operations on this adapter. "
568 "(debug info 0x%x).\n",
569 zfcp_get_busid_by_adapter(fsf_req
->adapter
),
570 fsf_req
->qtcb
->header
.fsf_command
);
571 debug_text_exception(fsf_req
->adapter
->erp_dbf
, 0,
573 zfcp_erp_adapter_shutdown(fsf_req
->adapter
, 0);
574 zfcp_cmd_dbf_event_fsf("unknownc", fsf_req
,
575 &fsf_req
->qtcb
->header
.fsf_status_qual
,
576 sizeof (union fsf_status_qual
));
577 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
580 case FSF_FCP_RSP_AVAILABLE
:
581 ZFCP_LOG_DEBUG("FCP Sense data will be presented to the "
583 debug_text_event(fsf_req
->adapter
->erp_dbf
, 3, "fsf_s_rsp");
586 case FSF_ADAPTER_STATUS_AVAILABLE
:
587 debug_text_event(fsf_req
->adapter
->erp_dbf
, 2, "fsf_s_astatus");
588 zfcp_fsf_fsfstatus_qual_eval(fsf_req
);
597 * always call specific handlers to give them a chance to do
598 * something meaningful even in error cases
600 zfcp_fsf_req_dispatch(fsf_req
);
606 * function: zfcp_fsf_fsfstatus_qual_eval
608 * purpose: evaluates FSF status-qualifier of completed FSF request
609 * and acts accordingly
614 zfcp_fsf_fsfstatus_qual_eval(struct zfcp_fsf_req
*fsf_req
)
618 switch (fsf_req
->qtcb
->header
.fsf_status_qual
.word
[0]) {
619 case FSF_SQ_FCP_RSP_AVAILABLE
:
620 debug_text_event(fsf_req
->adapter
->erp_dbf
, 4, "fsf_sq_rsp");
622 case FSF_SQ_RETRY_IF_POSSIBLE
:
623 /* The SCSI-stack may now issue retries or escalate */
624 debug_text_event(fsf_req
->adapter
->erp_dbf
, 2, "fsf_sq_retry");
625 zfcp_cmd_dbf_event_fsf("sqretry", fsf_req
,
626 &fsf_req
->qtcb
->header
.fsf_status_qual
,
627 sizeof (union fsf_status_qual
));
628 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
630 case FSF_SQ_COMMAND_ABORTED
:
631 /* Carry the aborted state on to upper layer */
632 debug_text_event(fsf_req
->adapter
->erp_dbf
, 2, "fsf_sq_abort");
633 zfcp_cmd_dbf_event_fsf("sqabort", fsf_req
,
634 &fsf_req
->qtcb
->header
.fsf_status_qual
,
635 sizeof (union fsf_status_qual
));
636 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ABORTED
;
637 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
639 case FSF_SQ_NO_RECOM
:
640 debug_text_exception(fsf_req
->adapter
->erp_dbf
, 0,
642 ZFCP_LOG_NORMAL("bug: No recommendation could be given for a"
643 "problem on the adapter %s "
644 "Stopping all operations on this adapter. ",
645 zfcp_get_busid_by_adapter(fsf_req
->adapter
));
646 zfcp_erp_adapter_shutdown(fsf_req
->adapter
, 0);
647 zfcp_cmd_dbf_event_fsf("sqnrecom", fsf_req
,
648 &fsf_req
->qtcb
->header
.fsf_status_qual
,
649 sizeof (union fsf_status_qual
));
650 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
652 case FSF_SQ_ULP_PROGRAMMING_ERROR
:
653 ZFCP_LOG_NORMAL("error: not enough SBALs for data transfer "
655 zfcp_get_busid_by_adapter(fsf_req
->adapter
));
656 debug_text_exception(fsf_req
->adapter
->erp_dbf
, 0,
658 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
660 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE
:
661 case FSF_SQ_NO_RETRY_POSSIBLE
:
662 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED
:
663 /* dealt with in the respective functions */
666 ZFCP_LOG_NORMAL("bug: Additional status info could "
667 "not be interpreted properly.\n");
668 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_NORMAL
,
669 (char *) &fsf_req
->qtcb
->header
.fsf_status_qual
,
670 sizeof (union fsf_status_qual
));
671 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0, "fsf_sq_inval:");
672 debug_exception(fsf_req
->adapter
->erp_dbf
, 0,
673 &fsf_req
->qtcb
->header
.fsf_status_qual
.word
[0],
675 zfcp_cmd_dbf_event_fsf("squndef", fsf_req
,
676 &fsf_req
->qtcb
->header
.fsf_status_qual
,
677 sizeof (union fsf_status_qual
));
678 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
686 * function: zfcp_fsf_req_dispatch
688 * purpose: calls the appropriate command specific handler
693 zfcp_fsf_req_dispatch(struct zfcp_fsf_req
*fsf_req
)
695 struct zfcp_erp_action
*erp_action
= fsf_req
->erp_action
;
696 struct zfcp_adapter
*adapter
= fsf_req
->adapter
;
699 if (unlikely(fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
)) {
700 ZFCP_LOG_TRACE("fsf_req=%p, QTCB=%p\n", fsf_req
, fsf_req
->qtcb
);
701 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_TRACE
,
702 (char *) fsf_req
->qtcb
, sizeof(struct fsf_qtcb
));
705 switch (fsf_req
->fsf_command
) {
707 case FSF_QTCB_FCP_CMND
:
708 zfcp_fsf_send_fcp_command_handler(fsf_req
);
711 case FSF_QTCB_ABORT_FCP_CMND
:
712 zfcp_fsf_abort_fcp_command_handler(fsf_req
);
715 case FSF_QTCB_SEND_GENERIC
:
716 zfcp_fsf_send_ct_handler(fsf_req
);
719 case FSF_QTCB_OPEN_PORT_WITH_DID
:
720 zfcp_fsf_open_port_handler(fsf_req
);
723 case FSF_QTCB_OPEN_LUN
:
724 zfcp_fsf_open_unit_handler(fsf_req
);
727 case FSF_QTCB_CLOSE_LUN
:
728 zfcp_fsf_close_unit_handler(fsf_req
);
731 case FSF_QTCB_CLOSE_PORT
:
732 zfcp_fsf_close_port_handler(fsf_req
);
735 case FSF_QTCB_CLOSE_PHYSICAL_PORT
:
736 zfcp_fsf_close_physical_port_handler(fsf_req
);
739 case FSF_QTCB_EXCHANGE_CONFIG_DATA
:
740 zfcp_fsf_exchange_config_data_handler(fsf_req
);
743 case FSF_QTCB_EXCHANGE_PORT_DATA
:
744 zfcp_fsf_exchange_port_data_handler(fsf_req
);
747 case FSF_QTCB_SEND_ELS
:
748 zfcp_fsf_send_els_handler(fsf_req
);
751 case FSF_QTCB_DOWNLOAD_CONTROL_FILE
:
752 zfcp_fsf_control_file_handler(fsf_req
);
755 case FSF_QTCB_UPLOAD_CONTROL_FILE
:
756 zfcp_fsf_control_file_handler(fsf_req
);
760 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
761 ZFCP_LOG_NORMAL("bug: Command issued by the device driver is "
762 "not supported by the adapter %s\n",
763 zfcp_get_busid_by_adapter(fsf_req
->adapter
));
764 if (fsf_req
->fsf_command
!= fsf_req
->qtcb
->header
.fsf_command
)
766 ("bug: Command issued by the device driver differs "
767 "from the command returned by the adapter %s "
768 "(debug info 0x%x, 0x%x).\n",
769 zfcp_get_busid_by_adapter(fsf_req
->adapter
),
770 fsf_req
->fsf_command
,
771 fsf_req
->qtcb
->header
.fsf_command
);
777 debug_text_event(adapter
->erp_dbf
, 3, "a_frh");
778 debug_event(adapter
->erp_dbf
, 3, &erp_action
->action
, sizeof (int));
779 zfcp_erp_async_handler(erp_action
, 0);
785 * function: zfcp_fsf_status_read
787 * purpose: initiates a Status Read command at the specified adapter
792 zfcp_fsf_status_read(struct zfcp_adapter
*adapter
, int req_flags
)
794 struct zfcp_fsf_req
*fsf_req
;
795 struct fsf_status_read_buffer
*status_buffer
;
796 unsigned long lock_flags
;
797 volatile struct qdio_buffer_element
*sbale
;
800 /* setup new FSF request */
801 retval
= zfcp_fsf_req_create(adapter
, FSF_QTCB_UNSOLICITED_STATUS
,
802 req_flags
| ZFCP_REQ_NO_QTCB
,
803 adapter
->pool
.fsf_req_status_read
,
804 &lock_flags
, &fsf_req
);
806 ZFCP_LOG_INFO("error: Could not create unsolicited status "
807 "buffer for adapter %s.\n",
808 zfcp_get_busid_by_adapter(adapter
));
809 goto failed_req_create
;
812 sbale
= zfcp_qdio_sbale_req(fsf_req
, fsf_req
->sbal_curr
, 0);
813 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_STATUS
;
814 sbale
[2].flags
|= SBAL_FLAGS_LAST_ENTRY
;
815 fsf_req
->sbale_curr
= 2;
818 mempool_alloc(adapter
->pool
.data_status_read
, GFP_ATOMIC
);
819 if (!status_buffer
) {
820 ZFCP_LOG_NORMAL("bug: could not get some buffer\n");
823 memset(status_buffer
, 0, sizeof (struct fsf_status_read_buffer
));
824 fsf_req
->data
.status_read
.buffer
= status_buffer
;
826 /* insert pointer to respective buffer */
827 sbale
= zfcp_qdio_sbale_curr(fsf_req
);
828 sbale
->addr
= (void *) status_buffer
;
829 sbale
->length
= sizeof(struct fsf_status_read_buffer
);
831 /* start QDIO request for this FSF request */
832 retval
= zfcp_fsf_req_send(fsf_req
, NULL
);
834 ZFCP_LOG_DEBUG("error: Could not set-up unsolicited status "
836 goto failed_req_send
;
839 ZFCP_LOG_TRACE("Status Read request initiated (adapter%s)\n",
840 zfcp_get_busid_by_adapter(adapter
));
844 mempool_free(status_buffer
, adapter
->pool
.data_status_read
);
847 zfcp_fsf_req_free(fsf_req
);
850 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
, lock_flags
);
855 zfcp_fsf_status_read_port_closed(struct zfcp_fsf_req
*fsf_req
)
857 struct fsf_status_read_buffer
*status_buffer
;
858 struct zfcp_adapter
*adapter
;
859 struct zfcp_port
*port
;
862 status_buffer
= fsf_req
->data
.status_read
.buffer
;
863 adapter
= fsf_req
->adapter
;
865 read_lock_irqsave(&zfcp_data
.config_lock
, flags
);
866 list_for_each_entry(port
, &adapter
->port_list_head
, list
)
867 if (port
->d_id
== (status_buffer
->d_id
& ZFCP_DID_MASK
))
869 read_unlock_irqrestore(&zfcp_data
.config_lock
, flags
);
871 if (!port
|| (port
->d_id
!= (status_buffer
->d_id
& ZFCP_DID_MASK
))) {
872 ZFCP_LOG_NORMAL("bug: Reopen port indication received for"
873 "nonexisting port with d_id 0x%08x on "
874 "adapter %s. Ignored.\n",
875 status_buffer
->d_id
& ZFCP_DID_MASK
,
876 zfcp_get_busid_by_adapter(adapter
));
880 switch (status_buffer
->status_subtype
) {
882 case FSF_STATUS_READ_SUB_CLOSE_PHYS_PORT
:
883 debug_text_event(adapter
->erp_dbf
, 3, "unsol_pc_phys:");
884 zfcp_erp_port_reopen(port
, 0);
887 case FSF_STATUS_READ_SUB_ERROR_PORT
:
888 debug_text_event(adapter
->erp_dbf
, 1, "unsol_pc_err:");
889 zfcp_erp_port_shutdown(port
, 0);
893 debug_text_event(adapter
->erp_dbf
, 0, "unsol_unk_sub:");
894 debug_exception(adapter
->erp_dbf
, 0,
895 &status_buffer
->status_subtype
, sizeof (u32
));
896 ZFCP_LOG_NORMAL("bug: Undefined status subtype received "
897 "for a reopen indication on port with "
898 "d_id 0x%08x on the adapter %s. "
899 "Ignored. (debug info 0x%x)\n",
901 zfcp_get_busid_by_adapter(adapter
),
902 status_buffer
->status_subtype
);
909 * function: zfcp_fsf_status_read_handler
911 * purpose: is called for finished Open Port command
916 zfcp_fsf_status_read_handler(struct zfcp_fsf_req
*fsf_req
)
919 struct zfcp_adapter
*adapter
= fsf_req
->adapter
;
920 struct fsf_status_read_buffer
*status_buffer
=
921 fsf_req
->data
.status_read
.buffer
;
923 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_DISMISSED
) {
924 mempool_free(status_buffer
, adapter
->pool
.data_status_read
);
925 zfcp_fsf_req_free(fsf_req
);
929 switch (status_buffer
->status_type
) {
931 case FSF_STATUS_READ_PORT_CLOSED
:
932 debug_text_event(adapter
->erp_dbf
, 3, "unsol_pclosed:");
933 debug_event(adapter
->erp_dbf
, 3,
934 &status_buffer
->d_id
, sizeof (u32
));
935 zfcp_fsf_status_read_port_closed(fsf_req
);
938 case FSF_STATUS_READ_INCOMING_ELS
:
939 debug_text_event(adapter
->erp_dbf
, 3, "unsol_els:");
940 zfcp_fsf_incoming_els(fsf_req
);
943 case FSF_STATUS_READ_SENSE_DATA_AVAIL
:
944 debug_text_event(adapter
->erp_dbf
, 3, "unsol_sense:");
945 ZFCP_LOG_INFO("unsolicited sense data received (adapter %s)\n",
946 zfcp_get_busid_by_adapter(adapter
));
947 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_NORMAL
, (char *) status_buffer
,
948 sizeof(struct fsf_status_read_buffer
));
951 case FSF_STATUS_READ_BIT_ERROR_THRESHOLD
:
952 debug_text_event(adapter
->erp_dbf
, 3, "unsol_bit_err:");
953 ZFCP_LOG_NORMAL("Bit error threshold data received:\n");
954 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_NORMAL
,
955 (char *) status_buffer
,
956 sizeof (struct fsf_status_read_buffer
));
959 case FSF_STATUS_READ_LINK_DOWN
:
960 debug_text_event(adapter
->erp_dbf
, 0, "unsol_link_down:");
961 ZFCP_LOG_INFO("Local link to adapter %s is down\n",
962 zfcp_get_busid_by_adapter(adapter
));
963 atomic_set_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED
,
965 zfcp_erp_adapter_failed(adapter
);
968 case FSF_STATUS_READ_LINK_UP
:
969 debug_text_event(adapter
->erp_dbf
, 2, "unsol_link_up:");
970 ZFCP_LOG_INFO("Local link to adapter %s was replugged. "
971 "Restarting operations on this adapter\n",
972 zfcp_get_busid_by_adapter(adapter
));
973 /* All ports should be marked as ready to run again */
974 zfcp_erp_modify_adapter_status(adapter
,
975 ZFCP_STATUS_COMMON_RUNNING
,
977 zfcp_erp_adapter_reopen(adapter
,
978 ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED
979 | ZFCP_STATUS_COMMON_ERP_FAILED
);
982 case FSF_STATUS_READ_CFDC_UPDATED
:
983 debug_text_event(adapter
->erp_dbf
, 2, "unsol_cfdc_update:");
984 ZFCP_LOG_INFO("CFDC has been updated on the adapter %s\n",
985 zfcp_get_busid_by_adapter(adapter
));
986 zfcp_erp_adapter_access_changed(adapter
);
989 case FSF_STATUS_READ_CFDC_HARDENED
:
990 debug_text_event(adapter
->erp_dbf
, 2, "unsol_cfdc_harden:");
991 switch (status_buffer
->status_subtype
) {
992 case FSF_STATUS_READ_SUB_CFDC_HARDENED_ON_SE
:
993 ZFCP_LOG_INFO("CFDC of adapter %s saved on SE\n",
994 zfcp_get_busid_by_adapter(adapter
));
996 case FSF_STATUS_READ_SUB_CFDC_HARDENED_ON_SE2
:
997 ZFCP_LOG_INFO("CFDC of adapter %s has been copied "
998 "to the secondary SE\n",
999 zfcp_get_busid_by_adapter(adapter
));
1002 ZFCP_LOG_INFO("CFDC of adapter %s has been hardened\n",
1003 zfcp_get_busid_by_adapter(adapter
));
1008 debug_text_event(adapter
->erp_dbf
, 0, "unsol_unknown:");
1009 debug_exception(adapter
->erp_dbf
, 0,
1010 &status_buffer
->status_type
, sizeof (u32
));
1011 ZFCP_LOG_NORMAL("bug: An unsolicited status packet of unknown "
1012 "type was received (debug info 0x%x)\n",
1013 status_buffer
->status_type
);
1014 ZFCP_LOG_DEBUG("Dump of status_read_buffer %p:\n",
1016 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
1017 (char *) status_buffer
,
1018 sizeof (struct fsf_status_read_buffer
));
1021 mempool_free(status_buffer
, adapter
->pool
.data_status_read
);
1022 zfcp_fsf_req_free(fsf_req
);
1024 * recycle buffer and start new request repeat until outbound
1025 * queue is empty or adapter shutdown is requested
1029 * we may wait in the req_create for 5s during shutdown, so
1030 * qdio_cleanup will have to wait at least that long before returning
1031 * with failure to allow us a proper cleanup under all circumstances
1035 * allocation failure possible? (Is this code needed?)
1037 retval
= zfcp_fsf_status_read(adapter
, 0);
1039 ZFCP_LOG_INFO("Failed to create unsolicited status read "
1040 "request for the adapter %s.\n",
1041 zfcp_get_busid_by_adapter(adapter
));
1042 /* temporary fix to avoid status read buffer shortage */
1043 adapter
->status_read_failed
++;
1044 if ((ZFCP_STATUS_READS_RECOM
- adapter
->status_read_failed
)
1045 < ZFCP_STATUS_READ_FAILED_THRESHOLD
) {
1046 ZFCP_LOG_INFO("restart adapter %s due to status read "
1047 "buffer shortage\n",
1048 zfcp_get_busid_by_adapter(adapter
));
1049 zfcp_erp_adapter_reopen(adapter
, 0);
1057 * function: zfcp_fsf_abort_fcp_command
1059 * purpose: tells FSF to abort a running SCSI command
1061 * returns: address of initiated FSF request
1062 * NULL - request could not be initiated
1064 * FIXME(design): should be watched by a timeout !!!
1065 * FIXME(design) shouldn't this be modified to return an int
1066 * also...don't know how though
1068 struct zfcp_fsf_req
*
1069 zfcp_fsf_abort_fcp_command(unsigned long old_req_id
,
1070 struct zfcp_adapter
*adapter
,
1071 struct zfcp_unit
*unit
, int req_flags
)
1073 volatile struct qdio_buffer_element
*sbale
;
1074 unsigned long lock_flags
;
1075 struct zfcp_fsf_req
*fsf_req
= NULL
;
1078 /* setup new FSF request */
1079 retval
= zfcp_fsf_req_create(adapter
, FSF_QTCB_ABORT_FCP_CMND
,
1080 req_flags
, adapter
->pool
.fsf_req_abort
,
1081 &lock_flags
, &fsf_req
);
1083 ZFCP_LOG_INFO("error: Failed to create an abort command "
1084 "request for lun 0x%016Lx on port 0x%016Lx "
1088 zfcp_get_busid_by_adapter(adapter
));
1092 sbale
= zfcp_qdio_sbale_req(fsf_req
, fsf_req
->sbal_curr
, 0);
1093 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_READ
;
1094 sbale
[1].flags
|= SBAL_FLAGS_LAST_ENTRY
;
1096 fsf_req
->data
.abort_fcp_command
.unit
= unit
;
1098 /* set handles of unit and its parent port in QTCB */
1099 fsf_req
->qtcb
->header
.lun_handle
= unit
->handle
;
1100 fsf_req
->qtcb
->header
.port_handle
= unit
->port
->handle
;
1102 /* set handle of request which should be aborted */
1103 fsf_req
->qtcb
->bottom
.support
.req_handle
= (u64
) old_req_id
;
1105 /* start QDIO request for this FSF request */
1107 zfcp_fsf_start_scsi_er_timer(adapter
);
1108 retval
= zfcp_fsf_req_send(fsf_req
, NULL
);
1110 del_timer(&adapter
->scsi_er_timer
);
1111 ZFCP_LOG_INFO("error: Failed to send abort command request "
1112 "on adapter %s, port 0x%016Lx, unit 0x%016Lx\n",
1113 zfcp_get_busid_by_adapter(adapter
),
1114 unit
->port
->wwpn
, unit
->fcp_lun
);
1115 zfcp_fsf_req_free(fsf_req
);
1120 ZFCP_LOG_DEBUG("Abort FCP Command request initiated "
1121 "(adapter%s, port d_id=0x%08x, "
1122 "unit x%016Lx, old_req_id=0x%lx)\n",
1123 zfcp_get_busid_by_adapter(adapter
),
1125 unit
->fcp_lun
, old_req_id
);
1127 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
, lock_flags
);
1132 * function: zfcp_fsf_abort_fcp_command_handler
1134 * purpose: is called for finished Abort FCP Command request
1139 zfcp_fsf_abort_fcp_command_handler(struct zfcp_fsf_req
*new_fsf_req
)
1141 int retval
= -EINVAL
;
1142 struct zfcp_unit
*unit
= new_fsf_req
->data
.abort_fcp_command
.unit
;
1143 unsigned char status_qual
=
1144 new_fsf_req
->qtcb
->header
.fsf_status_qual
.word
[0];
1146 del_timer(&new_fsf_req
->adapter
->scsi_er_timer
);
1148 if (new_fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
) {
1149 /* do not set ZFCP_STATUS_FSFREQ_ABORTSUCCEEDED */
1150 goto skip_fsfstatus
;
1153 /* evaluate FSF status in QTCB */
1154 switch (new_fsf_req
->qtcb
->header
.fsf_status
) {
1156 case FSF_PORT_HANDLE_NOT_VALID
:
1157 if (status_qual
>> 4 != status_qual
% 0xf) {
1158 debug_text_event(new_fsf_req
->adapter
->erp_dbf
, 3,
1161 * In this case a command that was sent prior to a port
1162 * reopen was aborted (handles are different). This is
1166 ZFCP_LOG_INFO("Temporary port identifier 0x%x for "
1167 "port 0x%016Lx on adapter %s invalid. "
1168 "This may happen occasionally.\n",
1171 zfcp_get_busid_by_unit(unit
));
1172 ZFCP_LOG_INFO("status qualifier:\n");
1173 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_INFO
,
1174 (char *) &new_fsf_req
->qtcb
->header
.
1176 sizeof (union fsf_status_qual
));
1177 /* Let's hope this sorts out the mess */
1178 debug_text_event(new_fsf_req
->adapter
->erp_dbf
, 1,
1180 zfcp_erp_adapter_reopen(unit
->port
->adapter
, 0);
1181 new_fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1185 case FSF_LUN_HANDLE_NOT_VALID
:
1186 if (status_qual
>> 4 != status_qual
% 0xf) {
1188 debug_text_event(new_fsf_req
->adapter
->erp_dbf
, 3,
1191 * In this case a command that was sent prior to a unit
1192 * reopen was aborted (handles are different).
1197 ("Warning: Temporary LUN identifier 0x%x of LUN "
1198 "0x%016Lx on port 0x%016Lx on adapter %s is "
1199 "invalid. This may happen in rare cases. "
1200 "Trying to re-establish link.\n",
1204 zfcp_get_busid_by_unit(unit
));
1205 ZFCP_LOG_DEBUG("Status qualifier data:\n");
1206 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
1207 (char *) &new_fsf_req
->qtcb
->header
.
1209 sizeof (union fsf_status_qual
));
1210 /* Let's hope this sorts out the mess */
1211 debug_text_event(new_fsf_req
->adapter
->erp_dbf
, 1,
1213 zfcp_erp_port_reopen(unit
->port
, 0);
1214 new_fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1218 case FSF_FCP_COMMAND_DOES_NOT_EXIST
:
1220 debug_text_event(new_fsf_req
->adapter
->erp_dbf
, 3,
1222 new_fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ABORTNOTNEEDED
;
1225 case FSF_PORT_BOXED
:
1226 ZFCP_LOG_INFO("Remote port 0x%016Lx on adapter %s needs to "
1227 "be reopened\n", unit
->port
->wwpn
,
1228 zfcp_get_busid_by_unit(unit
));
1229 debug_text_event(new_fsf_req
->adapter
->erp_dbf
, 2,
1231 zfcp_erp_port_boxed(unit
->port
);
1232 new_fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
1233 | ZFCP_STATUS_FSFREQ_RETRY
;
1238 "unit 0x%016Lx on port 0x%016Lx on adapter %s needs "
1240 unit
->fcp_lun
, unit
->port
->wwpn
,
1241 zfcp_get_busid_by_unit(unit
));
1242 debug_text_event(new_fsf_req
->adapter
->erp_dbf
, 1, "fsf_s_lboxed");
1243 zfcp_erp_unit_boxed(unit
);
1244 new_fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
1245 | ZFCP_STATUS_FSFREQ_RETRY
;
1248 case FSF_ADAPTER_STATUS_AVAILABLE
:
1249 switch (new_fsf_req
->qtcb
->header
.fsf_status_qual
.word
[0]) {
1250 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE
:
1251 debug_text_event(new_fsf_req
->adapter
->erp_dbf
, 1,
1253 zfcp_test_link(unit
->port
);
1254 new_fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1256 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED
:
1257 /* SCSI stack will escalate */
1258 debug_text_event(new_fsf_req
->adapter
->erp_dbf
, 1,
1260 new_fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1264 ("bug: Wrong status qualifier 0x%x arrived.\n",
1265 new_fsf_req
->qtcb
->header
.fsf_status_qual
.word
[0]);
1266 debug_text_event(new_fsf_req
->adapter
->erp_dbf
, 0,
1268 debug_exception(new_fsf_req
->adapter
->erp_dbf
, 0,
1269 &new_fsf_req
->qtcb
->header
.
1270 fsf_status_qual
.word
[0], sizeof (u32
));
1277 new_fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ABORTSUCCEEDED
;
1281 ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
1282 "(debug info 0x%x)\n",
1283 new_fsf_req
->qtcb
->header
.fsf_status
);
1284 debug_text_event(new_fsf_req
->adapter
->erp_dbf
, 0,
1286 debug_exception(new_fsf_req
->adapter
->erp_dbf
, 0,
1287 &new_fsf_req
->qtcb
->header
.fsf_status
,
1296 * zfcp_use_one_sbal - checks whether req buffer and resp bother each fit into
1298 * Two scatter-gather lists are passed, one for the reqeust and one for the
1302 zfcp_use_one_sbal(struct scatterlist
*req
, int req_count
,
1303 struct scatterlist
*resp
, int resp_count
)
1305 return ((req_count
== 1) &&
1306 (resp_count
== 1) &&
1307 (((unsigned long) zfcp_sg_to_address(&req
[0]) &
1309 ((unsigned long) (zfcp_sg_to_address(&req
[0]) +
1310 req
[0].length
- 1) & PAGE_MASK
)) &&
1311 (((unsigned long) zfcp_sg_to_address(&resp
[0]) &
1313 ((unsigned long) (zfcp_sg_to_address(&resp
[0]) +
1314 resp
[0].length
- 1) & PAGE_MASK
)));
1318 * zfcp_fsf_send_ct - initiate a Generic Service request (FC-GS)
1319 * @ct: pointer to struct zfcp_send_ct which conatins all needed data for
1321 * @pool: pointer to memory pool, if non-null this pool is used to allocate
1322 * a struct zfcp_fsf_req
1323 * @erp_action: pointer to erp_action, if non-null the Generic Service request
1324 * is sent within error recovery
1327 zfcp_fsf_send_ct(struct zfcp_send_ct
*ct
, mempool_t
*pool
,
1328 struct zfcp_erp_action
*erp_action
)
1330 volatile struct qdio_buffer_element
*sbale
;
1331 struct zfcp_port
*port
;
1332 struct zfcp_adapter
*adapter
;
1333 struct zfcp_fsf_req
*fsf_req
;
1334 unsigned long lock_flags
;
1339 adapter
= port
->adapter
;
1341 ret
= zfcp_fsf_req_create(adapter
, FSF_QTCB_SEND_GENERIC
,
1342 ZFCP_WAIT_FOR_SBAL
| ZFCP_REQ_AUTO_CLEANUP
,
1343 pool
, &lock_flags
, &fsf_req
);
1345 ZFCP_LOG_INFO("error: Could not create CT request (FC-GS) for "
1347 zfcp_get_busid_by_adapter(adapter
));
1351 if (erp_action
!= NULL
) {
1352 erp_action
->fsf_req
= fsf_req
;
1353 fsf_req
->erp_action
= erp_action
;
1356 sbale
= zfcp_qdio_sbale_req(fsf_req
, fsf_req
->sbal_curr
, 0);
1357 if (zfcp_use_one_sbal(ct
->req
, ct
->req_count
,
1358 ct
->resp
, ct
->resp_count
)){
1359 /* both request buffer and response buffer
1360 fit into one sbale each */
1361 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_WRITE_READ
;
1362 sbale
[2].addr
= zfcp_sg_to_address(&ct
->req
[0]);
1363 sbale
[2].length
= ct
->req
[0].length
;
1364 sbale
[3].addr
= zfcp_sg_to_address(&ct
->resp
[0]);
1365 sbale
[3].length
= ct
->resp
[0].length
;
1366 sbale
[3].flags
|= SBAL_FLAGS_LAST_ENTRY
;
1367 } else if (adapter
->supported_features
&
1368 FSF_FEATURE_ELS_CT_CHAINED_SBALS
) {
1369 /* try to use chained SBALs */
1370 bytes
= zfcp_qdio_sbals_from_sg(fsf_req
,
1371 SBAL_FLAGS0_TYPE_WRITE_READ
,
1372 ct
->req
, ct
->req_count
,
1373 ZFCP_MAX_SBALS_PER_CT_REQ
);
1375 ZFCP_LOG_INFO("error: creation of CT request failed "
1377 zfcp_get_busid_by_adapter(adapter
));
1385 fsf_req
->qtcb
->bottom
.support
.req_buf_length
= bytes
;
1386 fsf_req
->sbale_curr
= ZFCP_LAST_SBALE_PER_SBAL
;
1387 bytes
= zfcp_qdio_sbals_from_sg(fsf_req
,
1388 SBAL_FLAGS0_TYPE_WRITE_READ
,
1389 ct
->resp
, ct
->resp_count
,
1390 ZFCP_MAX_SBALS_PER_CT_REQ
);
1392 ZFCP_LOG_INFO("error: creation of CT request failed "
1394 zfcp_get_busid_by_adapter(adapter
));
1402 fsf_req
->qtcb
->bottom
.support
.resp_buf_length
= bytes
;
1404 /* reject send generic request */
1406 "error: microcode does not support chained SBALs,"
1407 "CT request too big (adapter %s)\n",
1408 zfcp_get_busid_by_adapter(adapter
));
1413 /* settings in QTCB */
1414 fsf_req
->qtcb
->header
.port_handle
= port
->handle
;
1415 fsf_req
->qtcb
->bottom
.support
.service_class
= adapter
->fc_service_class
;
1416 fsf_req
->qtcb
->bottom
.support
.timeout
= ct
->timeout
;
1417 fsf_req
->data
.send_ct
= ct
;
1419 /* start QDIO request for this FSF request */
1420 ret
= zfcp_fsf_req_send(fsf_req
, ct
->timer
);
1422 ZFCP_LOG_DEBUG("error: initiation of CT request failed "
1423 "(adapter %s, port 0x%016Lx)\n",
1424 zfcp_get_busid_by_adapter(adapter
), port
->wwpn
);
1428 ZFCP_LOG_DEBUG("CT request initiated (adapter %s, port 0x%016Lx)\n",
1429 zfcp_get_busid_by_adapter(adapter
), port
->wwpn
);
1433 zfcp_fsf_req_free(fsf_req
);
1434 if (erp_action
!= NULL
) {
1435 erp_action
->fsf_req
= NULL
;
1439 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
,
1445 * zfcp_fsf_send_ct_handler - handler for Generic Service requests
1446 * @fsf_req: pointer to struct zfcp_fsf_req
1448 * Data specific for the Generic Service request is passed by
1449 * fsf_req->data.send_ct
1450 * Usually a specific handler for the request is called via
1451 * fsf_req->data.send_ct->handler at end of this function.
1454 zfcp_fsf_send_ct_handler(struct zfcp_fsf_req
*fsf_req
)
1456 struct zfcp_port
*port
;
1457 struct zfcp_adapter
*adapter
;
1458 struct zfcp_send_ct
*send_ct
;
1459 struct fsf_qtcb_header
*header
;
1460 struct fsf_qtcb_bottom_support
*bottom
;
1461 int retval
= -EINVAL
;
1462 u16 subtable
, rule
, counter
;
1464 adapter
= fsf_req
->adapter
;
1465 send_ct
= fsf_req
->data
.send_ct
;
1466 port
= send_ct
->port
;
1467 header
= &fsf_req
->qtcb
->header
;
1468 bottom
= &fsf_req
->qtcb
->bottom
.support
;
1470 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
)
1471 goto skip_fsfstatus
;
1473 /* evaluate FSF status in QTCB */
1474 switch (header
->fsf_status
) {
1480 case FSF_SERVICE_CLASS_NOT_SUPPORTED
:
1481 if (adapter
->fc_service_class
<= 3) {
1482 ZFCP_LOG_INFO("error: adapter %s does not support fc "
1484 zfcp_get_busid_by_port(port
),
1485 adapter
->fc_service_class
);
1487 ZFCP_LOG_INFO("bug: The fibre channel class at the "
1488 "adapter %s is invalid. "
1489 "(debug info %d)\n",
1490 zfcp_get_busid_by_port(port
),
1491 adapter
->fc_service_class
);
1493 /* stop operation for this adapter */
1494 debug_text_exception(adapter
->erp_dbf
, 0, "fsf_s_class_nsup");
1495 zfcp_erp_adapter_shutdown(adapter
, 0);
1496 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1499 case FSF_ADAPTER_STATUS_AVAILABLE
:
1500 switch (header
->fsf_status_qual
.word
[0]){
1501 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE
:
1502 /* reopening link to port */
1503 debug_text_event(adapter
->erp_dbf
, 1, "fsf_sq_ltest");
1504 zfcp_test_link(port
);
1505 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1507 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED
:
1508 /* ERP strategy will escalate */
1509 debug_text_event(adapter
->erp_dbf
, 1, "fsf_sq_ulp");
1510 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1513 ZFCP_LOG_INFO("bug: Wrong status qualifier 0x%x "
1515 header
->fsf_status_qual
.word
[0]);
1520 case FSF_ACCESS_DENIED
:
1521 ZFCP_LOG_NORMAL("access denied, cannot send generic service "
1522 "command (adapter %s, port d_id=0x%08x)\n",
1523 zfcp_get_busid_by_port(port
), port
->d_id
);
1524 for (counter
= 0; counter
< 2; counter
++) {
1525 subtable
= header
->fsf_status_qual
.halfword
[counter
* 2];
1526 rule
= header
->fsf_status_qual
.halfword
[counter
* 2 + 1];
1528 case FSF_SQ_CFDC_SUBTABLE_OS
:
1529 case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN
:
1530 case FSF_SQ_CFDC_SUBTABLE_PORT_DID
:
1531 case FSF_SQ_CFDC_SUBTABLE_LUN
:
1532 ZFCP_LOG_INFO("Access denied (%s rule %d)\n",
1533 zfcp_act_subtable_type
[subtable
], rule
);
1537 debug_text_event(adapter
->erp_dbf
, 1, "fsf_s_access");
1538 zfcp_erp_port_access_denied(port
);
1539 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1542 case FSF_GENERIC_COMMAND_REJECTED
:
1543 ZFCP_LOG_INFO("generic service command rejected "
1544 "(adapter %s, port d_id=0x%08x)\n",
1545 zfcp_get_busid_by_port(port
), port
->d_id
);
1546 ZFCP_LOG_INFO("status qualifier:\n");
1547 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_INFO
,
1548 (char *) &header
->fsf_status_qual
,
1549 sizeof (union fsf_status_qual
));
1550 debug_text_event(adapter
->erp_dbf
, 1, "fsf_s_gcom_rej");
1551 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1554 case FSF_PORT_HANDLE_NOT_VALID
:
1555 ZFCP_LOG_DEBUG("Temporary port identifier 0x%x for port "
1556 "0x%016Lx on adapter %s invalid. This may "
1557 "happen occasionally.\n", port
->handle
,
1558 port
->wwpn
, zfcp_get_busid_by_port(port
));
1559 ZFCP_LOG_INFO("status qualifier:\n");
1560 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_INFO
,
1561 (char *) &header
->fsf_status_qual
,
1562 sizeof (union fsf_status_qual
));
1563 debug_text_event(adapter
->erp_dbf
, 1, "fsf_s_phandle_nv");
1564 zfcp_erp_adapter_reopen(adapter
, 0);
1565 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1568 case FSF_PORT_BOXED
:
1569 ZFCP_LOG_INFO("port needs to be reopened "
1570 "(adapter %s, port d_id=0x%08x)\n",
1571 zfcp_get_busid_by_port(port
), port
->d_id
);
1572 debug_text_event(adapter
->erp_dbf
, 2, "fsf_s_pboxed");
1573 zfcp_erp_port_boxed(port
);
1574 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
1575 | ZFCP_STATUS_FSFREQ_RETRY
;
1578 /* following states should never occure, all cases avoided
1579 in zfcp_fsf_send_ct - but who knows ... */
1580 case FSF_PAYLOAD_SIZE_MISMATCH
:
1581 ZFCP_LOG_INFO("payload size mismatch (adapter: %s, "
1582 "req_buf_length=%d, resp_buf_length=%d)\n",
1583 zfcp_get_busid_by_adapter(adapter
),
1584 bottom
->req_buf_length
, bottom
->resp_buf_length
);
1585 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1587 case FSF_REQUEST_SIZE_TOO_LARGE
:
1588 ZFCP_LOG_INFO("request size too large (adapter: %s, "
1589 "req_buf_length=%d)\n",
1590 zfcp_get_busid_by_adapter(adapter
),
1591 bottom
->req_buf_length
);
1592 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1594 case FSF_RESPONSE_SIZE_TOO_LARGE
:
1595 ZFCP_LOG_INFO("response size too large (adapter: %s, "
1596 "resp_buf_length=%d)\n",
1597 zfcp_get_busid_by_adapter(adapter
),
1598 bottom
->resp_buf_length
);
1599 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1601 case FSF_SBAL_MISMATCH
:
1602 ZFCP_LOG_INFO("SBAL mismatch (adapter: %s, req_buf_length=%d, "
1603 "resp_buf_length=%d)\n",
1604 zfcp_get_busid_by_adapter(adapter
),
1605 bottom
->req_buf_length
, bottom
->resp_buf_length
);
1606 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1610 ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
1611 "(debug info 0x%x)\n", header
->fsf_status
);
1612 debug_text_event(adapter
->erp_dbf
, 0, "fsf_sq_inval:");
1613 debug_exception(adapter
->erp_dbf
, 0,
1614 &header
->fsf_status_qual
.word
[0], sizeof (u32
));
1619 send_ct
->status
= retval
;
1621 if (send_ct
->handler
!= NULL
)
1622 send_ct
->handler(send_ct
->handler_data
);
1628 * zfcp_fsf_send_els - initiate an ELS command (FC-FS)
1629 * @els: pointer to struct zfcp_send_els which contains all needed data for
1633 zfcp_fsf_send_els(struct zfcp_send_els
*els
)
1635 volatile struct qdio_buffer_element
*sbale
;
1636 struct zfcp_fsf_req
*fsf_req
;
1638 struct zfcp_adapter
*adapter
;
1639 unsigned long lock_flags
;
1644 adapter
= els
->adapter
;
1646 ret
= zfcp_fsf_req_create(adapter
, FSF_QTCB_SEND_ELS
,
1647 ZFCP_REQ_AUTO_CLEANUP
,
1648 NULL
, &lock_flags
, &fsf_req
);
1650 ZFCP_LOG_INFO("error: creation of ELS request failed "
1651 "(adapter %s, port d_id: 0x%08x)\n",
1652 zfcp_get_busid_by_adapter(adapter
), d_id
);
1656 sbale
= zfcp_qdio_sbale_req(fsf_req
, fsf_req
->sbal_curr
, 0);
1657 if (zfcp_use_one_sbal(els
->req
, els
->req_count
,
1658 els
->resp
, els
->resp_count
)){
1659 /* both request buffer and response buffer
1660 fit into one sbale each */
1661 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_WRITE_READ
;
1662 sbale
[2].addr
= zfcp_sg_to_address(&els
->req
[0]);
1663 sbale
[2].length
= els
->req
[0].length
;
1664 sbale
[3].addr
= zfcp_sg_to_address(&els
->resp
[0]);
1665 sbale
[3].length
= els
->resp
[0].length
;
1666 sbale
[3].flags
|= SBAL_FLAGS_LAST_ENTRY
;
1667 } else if (adapter
->supported_features
&
1668 FSF_FEATURE_ELS_CT_CHAINED_SBALS
) {
1669 /* try to use chained SBALs */
1670 bytes
= zfcp_qdio_sbals_from_sg(fsf_req
,
1671 SBAL_FLAGS0_TYPE_WRITE_READ
,
1672 els
->req
, els
->req_count
,
1673 ZFCP_MAX_SBALS_PER_ELS_REQ
);
1675 ZFCP_LOG_INFO("error: creation of ELS request failed "
1676 "(adapter %s, port d_id: 0x%08x)\n",
1677 zfcp_get_busid_by_adapter(adapter
), d_id
);
1685 fsf_req
->qtcb
->bottom
.support
.req_buf_length
= bytes
;
1686 fsf_req
->sbale_curr
= ZFCP_LAST_SBALE_PER_SBAL
;
1687 bytes
= zfcp_qdio_sbals_from_sg(fsf_req
,
1688 SBAL_FLAGS0_TYPE_WRITE_READ
,
1689 els
->resp
, els
->resp_count
,
1690 ZFCP_MAX_SBALS_PER_ELS_REQ
);
1692 ZFCP_LOG_INFO("error: creation of ELS request failed "
1693 "(adapter %s, port d_id: 0x%08x)\n",
1694 zfcp_get_busid_by_adapter(adapter
), d_id
);
1702 fsf_req
->qtcb
->bottom
.support
.resp_buf_length
= bytes
;
1704 /* reject request */
1705 ZFCP_LOG_INFO("error: microcode does not support chained SBALs"
1706 ", ELS request too big (adapter %s, "
1707 "port d_id: 0x%08x)\n",
1708 zfcp_get_busid_by_adapter(adapter
), d_id
);
1713 /* settings in QTCB */
1714 fsf_req
->qtcb
->bottom
.support
.d_id
= d_id
;
1715 fsf_req
->qtcb
->bottom
.support
.service_class
= adapter
->fc_service_class
;
1716 fsf_req
->qtcb
->bottom
.support
.timeout
= ZFCP_ELS_TIMEOUT
;
1717 fsf_req
->data
.send_els
= els
;
1719 sbale
= zfcp_qdio_sbale_req(fsf_req
, fsf_req
->sbal_curr
, 0);
1721 /* start QDIO request for this FSF request */
1722 ret
= zfcp_fsf_req_send(fsf_req
, els
->timer
);
1724 ZFCP_LOG_DEBUG("error: initiation of ELS request failed "
1725 "(adapter %s, port d_id: 0x%08x)\n",
1726 zfcp_get_busid_by_adapter(adapter
), d_id
);
1730 ZFCP_LOG_DEBUG("ELS request initiated (adapter %s, port d_id: "
1731 "0x%08x)\n", zfcp_get_busid_by_adapter(adapter
), d_id
);
1735 zfcp_fsf_req_free(fsf_req
);
1739 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
,
1746 * zfcp_fsf_send_els_handler - handler for ELS commands
1747 * @fsf_req: pointer to struct zfcp_fsf_req
1749 * Data specific for the ELS command is passed by
1750 * fsf_req->data.send_els
1751 * Usually a specific handler for the command is called via
1752 * fsf_req->data.send_els->handler at end of this function.
1754 static int zfcp_fsf_send_els_handler(struct zfcp_fsf_req
*fsf_req
)
1756 struct zfcp_adapter
*adapter
;
1757 struct zfcp_port
*port
;
1759 struct fsf_qtcb_header
*header
;
1760 struct fsf_qtcb_bottom_support
*bottom
;
1761 struct zfcp_send_els
*send_els
;
1762 int retval
= -EINVAL
;
1763 u16 subtable
, rule
, counter
;
1765 send_els
= fsf_req
->data
.send_els
;
1766 adapter
= send_els
->adapter
;
1767 port
= send_els
->port
;
1768 d_id
= send_els
->d_id
;
1769 header
= &fsf_req
->qtcb
->header
;
1770 bottom
= &fsf_req
->qtcb
->bottom
.support
;
1772 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
)
1773 goto skip_fsfstatus
;
1775 switch (header
->fsf_status
) {
1781 case FSF_SERVICE_CLASS_NOT_SUPPORTED
:
1782 if (adapter
->fc_service_class
<= 3) {
1783 ZFCP_LOG_INFO("error: adapter %s does "
1784 "not support fibrechannel class %d.\n",
1785 zfcp_get_busid_by_adapter(adapter
),
1786 adapter
->fc_service_class
);
1788 ZFCP_LOG_INFO("bug: The fibrechannel class at "
1789 "adapter %s is invalid. "
1790 "(debug info %d)\n",
1791 zfcp_get_busid_by_adapter(adapter
),
1792 adapter
->fc_service_class
);
1794 /* stop operation for this adapter */
1795 debug_text_exception(adapter
->erp_dbf
, 0, "fsf_s_class_nsup");
1796 zfcp_erp_adapter_shutdown(adapter
, 0);
1797 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1800 case FSF_ADAPTER_STATUS_AVAILABLE
:
1801 switch (header
->fsf_status_qual
.word
[0]){
1802 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE
:
1803 debug_text_event(adapter
->erp_dbf
, 1, "fsf_sq_ltest");
1804 if (port
&& (send_els
->ls_code
!= ZFCP_LS_ADISC
))
1805 zfcp_test_link(port
);
1806 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1808 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED
:
1809 debug_text_event(adapter
->erp_dbf
, 1, "fsf_sq_ulp");
1810 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1812 zfcp_handle_els_rjt(header
->fsf_status_qual
.word
[1],
1813 (struct zfcp_ls_rjt_par
*)
1814 &header
->fsf_status_qual
.word
[2]);
1816 case FSF_SQ_RETRY_IF_POSSIBLE
:
1817 debug_text_event(adapter
->erp_dbf
, 1, "fsf_sq_retry");
1818 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1821 ZFCP_LOG_INFO("bug: Wrong status qualifier 0x%x\n",
1822 header
->fsf_status_qual
.word
[0]);
1823 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_INFO
,
1824 (char*)header
->fsf_status_qual
.word
, 16);
1828 case FSF_ELS_COMMAND_REJECTED
:
1829 ZFCP_LOG_INFO("ELS has been rejected because command filter "
1830 "prohibited sending "
1831 "(adapter: %s, port d_id: 0x%08x)\n",
1832 zfcp_get_busid_by_adapter(adapter
), d_id
);
1836 case FSF_PAYLOAD_SIZE_MISMATCH
:
1838 "ELS request size and ELS response size must be either "
1839 "both 0, or both greater than 0 "
1840 "(adapter: %s, req_buf_length=%d resp_buf_length=%d)\n",
1841 zfcp_get_busid_by_adapter(adapter
),
1842 bottom
->req_buf_length
,
1843 bottom
->resp_buf_length
);
1846 case FSF_REQUEST_SIZE_TOO_LARGE
:
1848 "Length of the ELS request buffer, "
1849 "specified in QTCB bottom, "
1850 "exceeds the size of the buffers "
1851 "that have been allocated for ELS request data "
1852 "(adapter: %s, req_buf_length=%d)\n",
1853 zfcp_get_busid_by_adapter(adapter
),
1854 bottom
->req_buf_length
);
1857 case FSF_RESPONSE_SIZE_TOO_LARGE
:
1859 "Length of the ELS response buffer, "
1860 "specified in QTCB bottom, "
1861 "exceeds the size of the buffers "
1862 "that have been allocated for ELS response data "
1863 "(adapter: %s, resp_buf_length=%d)\n",
1864 zfcp_get_busid_by_adapter(adapter
),
1865 bottom
->resp_buf_length
);
1868 case FSF_SBAL_MISMATCH
:
1869 /* should never occure, avoided in zfcp_fsf_send_els */
1870 ZFCP_LOG_INFO("SBAL mismatch (adapter: %s, req_buf_length=%d, "
1871 "resp_buf_length=%d)\n",
1872 zfcp_get_busid_by_adapter(adapter
),
1873 bottom
->req_buf_length
, bottom
->resp_buf_length
);
1874 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1877 case FSF_ACCESS_DENIED
:
1878 ZFCP_LOG_NORMAL("access denied, cannot send ELS command "
1879 "(adapter %s, port d_id=0x%08x)\n",
1880 zfcp_get_busid_by_adapter(adapter
), d_id
);
1881 for (counter
= 0; counter
< 2; counter
++) {
1882 subtable
= header
->fsf_status_qual
.halfword
[counter
* 2];
1883 rule
= header
->fsf_status_qual
.halfword
[counter
* 2 + 1];
1885 case FSF_SQ_CFDC_SUBTABLE_OS
:
1886 case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN
:
1887 case FSF_SQ_CFDC_SUBTABLE_PORT_DID
:
1888 case FSF_SQ_CFDC_SUBTABLE_LUN
:
1889 ZFCP_LOG_INFO("Access denied (%s rule %d)\n",
1890 zfcp_act_subtable_type
[subtable
], rule
);
1894 debug_text_event(adapter
->erp_dbf
, 1, "fsf_s_access");
1896 zfcp_erp_port_access_denied(port
);
1897 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1902 "bug: An unknown FSF Status was presented "
1903 "(adapter: %s, fsf_status=0x%08x)\n",
1904 zfcp_get_busid_by_adapter(adapter
),
1905 header
->fsf_status
);
1906 debug_text_event(adapter
->erp_dbf
, 0, "fsf_sq_inval");
1907 debug_exception(adapter
->erp_dbf
, 0,
1908 &header
->fsf_status_qual
.word
[0], sizeof(u32
));
1909 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1914 send_els
->status
= retval
;
1916 if (send_els
->handler
!= 0)
1917 send_els
->handler(send_els
->handler_data
);
1927 * returns: address of initiated FSF request
1928 * NULL - request could not be initiated
1931 zfcp_fsf_exchange_config_data(struct zfcp_erp_action
*erp_action
)
1933 volatile struct qdio_buffer_element
*sbale
;
1934 unsigned long lock_flags
;
1937 /* setup new FSF request */
1938 retval
= zfcp_fsf_req_create(erp_action
->adapter
,
1939 FSF_QTCB_EXCHANGE_CONFIG_DATA
,
1940 ZFCP_REQ_AUTO_CLEANUP
,
1941 erp_action
->adapter
->pool
.fsf_req_erp
,
1942 &lock_flags
, &(erp_action
->fsf_req
));
1944 ZFCP_LOG_INFO("error: Could not create exchange configuration "
1945 "data request for adapter %s.\n",
1946 zfcp_get_busid_by_adapter(erp_action
->adapter
));
1950 sbale
= zfcp_qdio_sbale_req(erp_action
->fsf_req
,
1951 erp_action
->fsf_req
->sbal_curr
, 0);
1952 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_READ
;
1953 sbale
[1].flags
|= SBAL_FLAGS_LAST_ENTRY
;
1955 erp_action
->fsf_req
->erp_action
= erp_action
;
1956 erp_action
->fsf_req
->qtcb
->bottom
.config
.feature_selection
=
1957 (FSF_FEATURE_CFDC
| FSF_FEATURE_LUN_SHARING
);
1959 /* start QDIO request for this FSF request */
1960 retval
= zfcp_fsf_req_send(erp_action
->fsf_req
, &erp_action
->timer
);
1963 ("error: Could not send exchange configuration data "
1964 "command on the adapter %s\n",
1965 zfcp_get_busid_by_adapter(erp_action
->adapter
));
1966 zfcp_fsf_req_free(erp_action
->fsf_req
);
1967 erp_action
->fsf_req
= NULL
;
1971 ZFCP_LOG_DEBUG("exchange configuration data request initiated "
1973 zfcp_get_busid_by_adapter(erp_action
->adapter
));
1976 write_unlock_irqrestore(&erp_action
->adapter
->request_queue
.queue_lock
,
1982 * zfcp_fsf_exchange_config_evaluate
1983 * @fsf_req: fsf_req which belongs to xchg config data request
1984 * @xchg_ok: specifies if xchg config data was incomplete or complete (0/1)
1986 * returns: -EIO on error, 0 otherwise
1989 zfcp_fsf_exchange_config_evaluate(struct zfcp_fsf_req
*fsf_req
, int xchg_ok
)
1991 struct fsf_qtcb_bottom_config
*bottom
;
1992 struct zfcp_adapter
*adapter
= fsf_req
->adapter
;
1994 bottom
= &fsf_req
->qtcb
->bottom
.config
;
1995 ZFCP_LOG_DEBUG("low/high QTCB version 0x%x/0x%x of FSF\n",
1996 bottom
->low_qtcb_version
, bottom
->high_qtcb_version
);
1997 adapter
->fsf_lic_version
= bottom
->lic_version
;
1998 adapter
->supported_features
= bottom
->supported_features
;
1999 adapter
->peer_wwpn
= 0;
2000 adapter
->peer_wwnn
= 0;
2001 adapter
->peer_d_id
= 0;
2004 adapter
->wwnn
= bottom
->nport_serv_param
.wwnn
;
2005 adapter
->wwpn
= bottom
->nport_serv_param
.wwpn
;
2006 adapter
->s_id
= bottom
->s_id
& ZFCP_DID_MASK
;
2007 adapter
->fc_topology
= bottom
->fc_topology
;
2008 adapter
->fc_link_speed
= bottom
->fc_link_speed
;
2009 adapter
->hydra_version
= bottom
->adapter_type
;
2014 adapter
->fc_topology
= 0;
2015 adapter
->fc_link_speed
= 0;
2016 adapter
->hydra_version
= 0;
2019 if (adapter
->fc_topology
== FSF_TOPO_P2P
) {
2020 adapter
->peer_d_id
= bottom
->peer_d_id
& ZFCP_DID_MASK
;
2021 adapter
->peer_wwpn
= bottom
->plogi_payload
.wwpn
;
2022 adapter
->peer_wwnn
= bottom
->plogi_payload
.wwnn
;
2025 if(adapter
->supported_features
& FSF_FEATURE_HBAAPI_MANAGEMENT
){
2026 adapter
->hardware_version
= bottom
->hardware_version
;
2027 memcpy(adapter
->serial_number
, bottom
->serial_number
, 17);
2028 EBCASC(adapter
->serial_number
, sizeof(adapter
->serial_number
));
2031 ZFCP_LOG_NORMAL("The adapter %s reported the following characteristics:\n"
2035 "adapter version 0x%x, "
2036 "LIC version 0x%x, "
2037 "FC link speed %d Gb/s\n",
2038 zfcp_get_busid_by_adapter(adapter
),
2041 (unsigned int) adapter
->s_id
,
2042 adapter
->hydra_version
,
2043 adapter
->fsf_lic_version
,
2044 adapter
->fc_link_speed
);
2045 if (ZFCP_QTCB_VERSION
< bottom
->low_qtcb_version
) {
2046 ZFCP_LOG_NORMAL("error: the adapter %s "
2047 "only supports newer control block "
2048 "versions in comparison to this device "
2049 "driver (try updated device driver)\n",
2050 zfcp_get_busid_by_adapter(adapter
));
2051 debug_text_event(adapter
->erp_dbf
, 0, "low_qtcb_ver");
2052 zfcp_erp_adapter_shutdown(adapter
, 0);
2055 if (ZFCP_QTCB_VERSION
> bottom
->high_qtcb_version
) {
2056 ZFCP_LOG_NORMAL("error: the adapter %s "
2057 "only supports older control block "
2058 "versions than this device driver uses"
2059 "(consider a microcode upgrade)\n",
2060 zfcp_get_busid_by_adapter(adapter
));
2061 debug_text_event(adapter
->erp_dbf
, 0, "high_qtcb_ver");
2062 zfcp_erp_adapter_shutdown(adapter
, 0);
2069 * function: zfcp_fsf_exchange_config_data_handler
2071 * purpose: is called for finished Exchange Configuration Data command
2076 zfcp_fsf_exchange_config_data_handler(struct zfcp_fsf_req
*fsf_req
)
2078 struct fsf_qtcb_bottom_config
*bottom
;
2079 struct zfcp_adapter
*adapter
= fsf_req
->adapter
;
2081 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
)
2084 switch (fsf_req
->qtcb
->header
.fsf_status
) {
2087 if (zfcp_fsf_exchange_config_evaluate(fsf_req
, 1))
2090 switch (adapter
->fc_topology
) {
2092 ZFCP_LOG_NORMAL("Point-to-Point fibrechannel "
2093 "configuration detected at adapter %s\n"
2094 "Peer WWNN 0x%016llx, "
2095 "peer WWPN 0x%016llx, "
2096 "peer d_id 0x%06x\n",
2097 zfcp_get_busid_by_adapter(adapter
),
2100 adapter
->peer_d_id
);
2101 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0,
2105 ZFCP_LOG_NORMAL("error: Arbitrated loop fibrechannel "
2106 "topology detected at adapter %s "
2107 "unsupported, shutting down adapter\n",
2108 zfcp_get_busid_by_adapter(adapter
));
2109 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0,
2111 zfcp_erp_adapter_shutdown(adapter
, 0);
2113 case FSF_TOPO_FABRIC
:
2114 ZFCP_LOG_INFO("Switched fabric fibrechannel "
2115 "network detected at adapter %s.\n",
2116 zfcp_get_busid_by_adapter(adapter
));
2119 ZFCP_LOG_NORMAL("bug: The fibrechannel topology "
2120 "reported by the exchange "
2121 "configuration command for "
2122 "the adapter %s is not "
2123 "of a type known to the zfcp "
2124 "driver, shutting down adapter\n",
2125 zfcp_get_busid_by_adapter(adapter
));
2126 adapter
->fc_topology
= FSF_TOPO_ERROR
;
2127 debug_text_exception(fsf_req
->adapter
->erp_dbf
, 0,
2129 zfcp_erp_adapter_shutdown(adapter
, 0);
2132 bottom
= &fsf_req
->qtcb
->bottom
.config
;
2133 if (bottom
->max_qtcb_size
< sizeof(struct fsf_qtcb
)) {
2134 ZFCP_LOG_NORMAL("bug: Maximum QTCB size (%d bytes) "
2135 "allowed by the adapter %s "
2136 "is lower than the minimum "
2137 "required by the driver (%ld bytes).\n",
2138 bottom
->max_qtcb_size
,
2139 zfcp_get_busid_by_adapter(adapter
),
2140 sizeof(struct fsf_qtcb
));
2141 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0,
2143 debug_event(fsf_req
->adapter
->erp_dbf
, 0,
2144 &bottom
->max_qtcb_size
, sizeof (u32
));
2145 zfcp_erp_adapter_shutdown(adapter
, 0);
2148 atomic_set_mask(ZFCP_STATUS_ADAPTER_XCONFIG_OK
,
2151 case FSF_EXCHANGE_CONFIG_DATA_INCOMPLETE
:
2152 debug_text_event(adapter
->erp_dbf
, 0, "xchg-inco");
2154 if (zfcp_fsf_exchange_config_evaluate(fsf_req
, 0))
2157 ZFCP_LOG_INFO("Local link to adapter %s is down\n",
2158 zfcp_get_busid_by_adapter(adapter
));
2159 atomic_set_mask(ZFCP_STATUS_ADAPTER_XCONFIG_OK
|
2160 ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED
,
2162 zfcp_erp_adapter_failed(adapter
);
2165 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0, "fsf-stat-ng");
2166 debug_event(fsf_req
->adapter
->erp_dbf
, 0,
2167 &fsf_req
->qtcb
->header
.fsf_status
, sizeof (u32
));
2168 zfcp_erp_adapter_shutdown(adapter
, 0);
2175 * zfcp_fsf_exchange_port_data - request information about local port
2176 * @adapter: for which port data is requested
2177 * @data: response to exchange port data request
2180 zfcp_fsf_exchange_port_data(struct zfcp_adapter
*adapter
,
2181 struct fsf_qtcb_bottom_port
*data
)
2183 volatile struct qdio_buffer_element
*sbale
;
2185 unsigned long lock_flags
;
2186 struct zfcp_fsf_req
*fsf_req
;
2187 struct timer_list
*timer
;
2189 if(!(adapter
->supported_features
& FSF_FEATURE_HBAAPI_MANAGEMENT
)){
2190 ZFCP_LOG_INFO("error: exchange port data "
2191 "command not supported by adapter %s\n",
2192 zfcp_get_busid_by_adapter(adapter
));
2196 timer
= kmalloc(sizeof(struct timer_list
), GFP_KERNEL
);
2200 /* setup new FSF request */
2201 retval
= zfcp_fsf_req_create(adapter
, FSF_QTCB_EXCHANGE_PORT_DATA
,
2202 0, 0, &lock_flags
, &fsf_req
);
2204 ZFCP_LOG_INFO("error: Out of resources. Could not create an "
2205 "exchange port data request for"
2206 "the adapter %s.\n",
2207 zfcp_get_busid_by_adapter(adapter
));
2208 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
,
2213 sbale
= zfcp_qdio_sbale_req(fsf_req
, fsf_req
->sbal_curr
, 0);
2214 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_READ
;
2215 sbale
[1].flags
|= SBAL_FLAGS_LAST_ENTRY
;
2217 fsf_req
->data
.port_data
= data
;
2220 timer
->function
= zfcp_fsf_request_timeout_handler
;
2221 timer
->data
= (unsigned long) adapter
;
2222 timer
->expires
= ZFCP_FSF_REQUEST_TIMEOUT
;
2224 retval
= zfcp_fsf_req_send(fsf_req
, timer
);
2226 ZFCP_LOG_INFO("error: Could not send an exchange port data "
2227 "command on the adapter %s\n",
2228 zfcp_get_busid_by_adapter(adapter
));
2229 zfcp_fsf_req_free(fsf_req
);
2230 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
,
2235 ZFCP_LOG_DEBUG("Exchange Port Data request initiated (adapter %s)\n",
2236 zfcp_get_busid_by_adapter(adapter
));
2238 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
,
2241 wait_event(fsf_req
->completion_wq
,
2242 fsf_req
->status
& ZFCP_STATUS_FSFREQ_COMPLETED
);
2243 del_timer_sync(timer
);
2244 zfcp_fsf_req_free(fsf_req
);
2252 * zfcp_fsf_exchange_port_data_handler - handler for exchange_port_data request
2253 * @fsf_req: pointer to struct zfcp_fsf_req
2256 zfcp_fsf_exchange_port_data_handler(struct zfcp_fsf_req
*fsf_req
)
2258 struct fsf_qtcb_bottom_port
*bottom
;
2259 struct fsf_qtcb_bottom_port
*data
= fsf_req
->data
.port_data
;
2261 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
)
2264 switch (fsf_req
->qtcb
->header
.fsf_status
) {
2266 bottom
= &fsf_req
->qtcb
->bottom
.port
;
2267 memcpy(data
, bottom
, sizeof(*data
));
2271 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0, "xchg-port-ng");
2272 debug_event(fsf_req
->adapter
->erp_dbf
, 0,
2273 &fsf_req
->qtcb
->header
.fsf_status
, sizeof(u32
));
2279 * function: zfcp_fsf_open_port
2283 * returns: address of initiated FSF request
2284 * NULL - request could not be initiated
2287 zfcp_fsf_open_port(struct zfcp_erp_action
*erp_action
)
2289 volatile struct qdio_buffer_element
*sbale
;
2290 unsigned long lock_flags
;
2293 /* setup new FSF request */
2294 retval
= zfcp_fsf_req_create(erp_action
->adapter
,
2295 FSF_QTCB_OPEN_PORT_WITH_DID
,
2296 ZFCP_WAIT_FOR_SBAL
| ZFCP_REQ_AUTO_CLEANUP
,
2297 erp_action
->adapter
->pool
.fsf_req_erp
,
2298 &lock_flags
, &(erp_action
->fsf_req
));
2300 ZFCP_LOG_INFO("error: Could not create open port request "
2301 "for port 0x%016Lx on adapter %s.\n",
2302 erp_action
->port
->wwpn
,
2303 zfcp_get_busid_by_adapter(erp_action
->adapter
));
2307 sbale
= zfcp_qdio_sbale_req(erp_action
->fsf_req
,
2308 erp_action
->fsf_req
->sbal_curr
, 0);
2309 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_READ
;
2310 sbale
[1].flags
|= SBAL_FLAGS_LAST_ENTRY
;
2312 erp_action
->fsf_req
->qtcb
->bottom
.support
.d_id
= erp_action
->port
->d_id
;
2313 atomic_set_mask(ZFCP_STATUS_COMMON_OPENING
, &erp_action
->port
->status
);
2314 erp_action
->fsf_req
->data
.open_port
.port
= erp_action
->port
;
2315 erp_action
->fsf_req
->erp_action
= erp_action
;
2317 /* start QDIO request for this FSF request */
2318 retval
= zfcp_fsf_req_send(erp_action
->fsf_req
, &erp_action
->timer
);
2320 ZFCP_LOG_INFO("error: Could not send open port request for "
2321 "port 0x%016Lx on adapter %s.\n",
2322 erp_action
->port
->wwpn
,
2323 zfcp_get_busid_by_adapter(erp_action
->adapter
));
2324 zfcp_fsf_req_free(erp_action
->fsf_req
);
2325 erp_action
->fsf_req
= NULL
;
2329 ZFCP_LOG_DEBUG("open port request initiated "
2330 "(adapter %s, port 0x%016Lx)\n",
2331 zfcp_get_busid_by_adapter(erp_action
->adapter
),
2332 erp_action
->port
->wwpn
);
2334 write_unlock_irqrestore(&erp_action
->adapter
->request_queue
.queue_lock
,
2340 * function: zfcp_fsf_open_port_handler
2342 * purpose: is called for finished Open Port command
2347 zfcp_fsf_open_port_handler(struct zfcp_fsf_req
*fsf_req
)
2349 int retval
= -EINVAL
;
2350 struct zfcp_port
*port
;
2351 struct fsf_plogi
*plogi
;
2352 struct fsf_qtcb_header
*header
;
2353 u16 subtable
, rule
, counter
;
2355 port
= fsf_req
->data
.open_port
.port
;
2356 header
= &fsf_req
->qtcb
->header
;
2358 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
) {
2359 /* don't change port status in our bookkeeping */
2360 goto skip_fsfstatus
;
2363 /* evaluate FSF status in QTCB */
2364 switch (header
->fsf_status
) {
2366 case FSF_PORT_ALREADY_OPEN
:
2367 ZFCP_LOG_NORMAL("bug: remote port 0x%016Lx on adapter %s "
2368 "is already open.\n",
2369 port
->wwpn
, zfcp_get_busid_by_port(port
));
2370 debug_text_exception(fsf_req
->adapter
->erp_dbf
, 0,
2373 * This is a bug, however operation should continue normally
2374 * if it is simply ignored
2378 case FSF_ACCESS_DENIED
:
2379 ZFCP_LOG_NORMAL("Access denied, cannot open port 0x%016Lx "
2381 port
->wwpn
, zfcp_get_busid_by_port(port
));
2382 for (counter
= 0; counter
< 2; counter
++) {
2383 subtable
= header
->fsf_status_qual
.halfword
[counter
* 2];
2384 rule
= header
->fsf_status_qual
.halfword
[counter
* 2 + 1];
2386 case FSF_SQ_CFDC_SUBTABLE_OS
:
2387 case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN
:
2388 case FSF_SQ_CFDC_SUBTABLE_PORT_DID
:
2389 case FSF_SQ_CFDC_SUBTABLE_LUN
:
2390 ZFCP_LOG_INFO("Access denied (%s rule %d)\n",
2391 zfcp_act_subtable_type
[subtable
], rule
);
2395 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1, "fsf_s_access");
2396 zfcp_erp_port_access_denied(port
);
2397 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
2400 case FSF_MAXIMUM_NUMBER_OF_PORTS_EXCEEDED
:
2401 ZFCP_LOG_INFO("error: The FSF adapter is out of resources. "
2402 "The remote port 0x%016Lx on adapter %s "
2403 "could not be opened. Disabling it.\n",
2404 port
->wwpn
, zfcp_get_busid_by_port(port
));
2405 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
2407 zfcp_erp_port_failed(port
);
2408 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
2411 case FSF_ADAPTER_STATUS_AVAILABLE
:
2412 switch (header
->fsf_status_qual
.word
[0]) {
2413 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE
:
2414 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
2416 /* ERP strategy will escalate */
2417 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
2419 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED
:
2420 /* ERP strategy will escalate */
2421 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
2423 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
2425 case FSF_SQ_NO_RETRY_POSSIBLE
:
2426 ZFCP_LOG_NORMAL("The remote port 0x%016Lx on "
2427 "adapter %s could not be opened. "
2430 zfcp_get_busid_by_port(port
));
2431 debug_text_exception(fsf_req
->adapter
->erp_dbf
, 0,
2433 zfcp_erp_port_failed(port
);
2434 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
2438 ("bug: Wrong status qualifier 0x%x arrived.\n",
2439 header
->fsf_status_qual
.word
[0]);
2440 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0,
2443 fsf_req
->adapter
->erp_dbf
, 0,
2444 &header
->fsf_status_qual
.word
[0],
2451 /* save port handle assigned by FSF */
2452 port
->handle
= header
->port_handle
;
2453 ZFCP_LOG_INFO("The remote port 0x%016Lx via adapter %s "
2454 "was opened, it's port handle is 0x%x\n",
2455 port
->wwpn
, zfcp_get_busid_by_port(port
),
2457 /* mark port as open */
2458 atomic_set_mask(ZFCP_STATUS_COMMON_OPEN
|
2459 ZFCP_STATUS_PORT_PHYS_OPEN
, &port
->status
);
2460 atomic_clear_mask(ZFCP_STATUS_COMMON_ACCESS_DENIED
|
2461 ZFCP_STATUS_COMMON_ACCESS_BOXED
,
2464 /* check whether D_ID has changed during open */
2466 * FIXME: This check is not airtight, as the FCP channel does
2467 * not monitor closures of target port connections caused on
2468 * the remote side. Thus, they might miss out on invalidating
2469 * locally cached WWPNs (and other N_Port parameters) of gone
2470 * target ports. So, our heroic attempt to make things safe
2471 * could be undermined by 'open port' response data tagged with
2472 * obsolete WWPNs. Another reason to monitor potential
2473 * connection closures ourself at least (by interpreting
2474 * incoming ELS' and unsolicited status). It just crosses my
2475 * mind that one should be able to cross-check by means of
2476 * another GID_PN straight after a port has been opened.
2477 * Alternately, an ADISC/PDISC ELS should suffice, as well.
2479 plogi
= (struct fsf_plogi
*) fsf_req
->qtcb
->bottom
.support
.els
;
2480 if (!atomic_test_mask(ZFCP_STATUS_PORT_NO_WWPN
, &port
->status
))
2482 if (fsf_req
->qtcb
->bottom
.support
.els1_length
<
2483 ((((unsigned long) &plogi
->serv_param
.wwpn
) -
2484 ((unsigned long) plogi
)) + sizeof (u64
))) {
2486 "warning: insufficient length of "
2487 "PLOGI payload (%i)\n",
2488 fsf_req
->qtcb
->bottom
.support
.els1_length
);
2489 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0,
2490 "fsf_s_short_plogi:");
2491 /* skip sanity check and assume wwpn is ok */
2493 if (plogi
->serv_param
.wwpn
!= port
->wwpn
) {
2494 ZFCP_LOG_INFO("warning: d_id of port "
2495 "0x%016Lx changed during "
2496 "open\n", port
->wwpn
);
2498 fsf_req
->adapter
->erp_dbf
, 0,
2499 "fsf_s_did_change:");
2501 ZFCP_STATUS_PORT_DID_DID
,
2504 port
->wwnn
= plogi
->serv_param
.wwnn
;
2509 case FSF_UNKNOWN_OP_SUBTYPE
:
2510 /* should never occure, subtype not set in zfcp_fsf_open_port */
2511 ZFCP_LOG_INFO("unknown operation subtype (adapter: %s, "
2512 "op_subtype=0x%x)\n",
2513 zfcp_get_busid_by_port(port
),
2514 fsf_req
->qtcb
->bottom
.support
.operation_subtype
);
2515 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
2519 ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
2520 "(debug info 0x%x)\n",
2521 header
->fsf_status
);
2522 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0, "fsf_s_inval:");
2523 debug_exception(fsf_req
->adapter
->erp_dbf
, 0,
2524 &header
->fsf_status
, sizeof (u32
));
2529 atomic_clear_mask(ZFCP_STATUS_COMMON_OPENING
, &port
->status
);
2534 * function: zfcp_fsf_close_port
2536 * purpose: submit FSF command "close port"
2538 * returns: address of initiated FSF request
2539 * NULL - request could not be initiated
2542 zfcp_fsf_close_port(struct zfcp_erp_action
*erp_action
)
2544 volatile struct qdio_buffer_element
*sbale
;
2545 unsigned long lock_flags
;
2548 /* setup new FSF request */
2549 retval
= zfcp_fsf_req_create(erp_action
->adapter
,
2550 FSF_QTCB_CLOSE_PORT
,
2551 ZFCP_WAIT_FOR_SBAL
| ZFCP_REQ_AUTO_CLEANUP
,
2552 erp_action
->adapter
->pool
.fsf_req_erp
,
2553 &lock_flags
, &(erp_action
->fsf_req
));
2555 ZFCP_LOG_INFO("error: Could not create a close port request "
2556 "for port 0x%016Lx on adapter %s.\n",
2557 erp_action
->port
->wwpn
,
2558 zfcp_get_busid_by_adapter(erp_action
->adapter
));
2562 sbale
= zfcp_qdio_sbale_req(erp_action
->fsf_req
,
2563 erp_action
->fsf_req
->sbal_curr
, 0);
2564 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_READ
;
2565 sbale
[1].flags
|= SBAL_FLAGS_LAST_ENTRY
;
2567 atomic_set_mask(ZFCP_STATUS_COMMON_CLOSING
, &erp_action
->port
->status
);
2568 erp_action
->fsf_req
->data
.close_port
.port
= erp_action
->port
;
2569 erp_action
->fsf_req
->erp_action
= erp_action
;
2570 erp_action
->fsf_req
->qtcb
->header
.port_handle
=
2571 erp_action
->port
->handle
;
2573 /* start QDIO request for this FSF request */
2574 retval
= zfcp_fsf_req_send(erp_action
->fsf_req
, &erp_action
->timer
);
2576 ZFCP_LOG_INFO("error: Could not send a close port request for "
2577 "port 0x%016Lx on adapter %s.\n",
2578 erp_action
->port
->wwpn
,
2579 zfcp_get_busid_by_adapter(erp_action
->adapter
));
2580 zfcp_fsf_req_free(erp_action
->fsf_req
);
2581 erp_action
->fsf_req
= NULL
;
2585 ZFCP_LOG_TRACE("close port request initiated "
2586 "(adapter %s, port 0x%016Lx)\n",
2587 zfcp_get_busid_by_adapter(erp_action
->adapter
),
2588 erp_action
->port
->wwpn
);
2590 write_unlock_irqrestore(&erp_action
->adapter
->request_queue
.queue_lock
,
2596 * function: zfcp_fsf_close_port_handler
2598 * purpose: is called for finished Close Port FSF command
2603 zfcp_fsf_close_port_handler(struct zfcp_fsf_req
*fsf_req
)
2605 int retval
= -EINVAL
;
2606 struct zfcp_port
*port
;
2608 port
= fsf_req
->data
.close_port
.port
;
2610 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
) {
2611 /* don't change port status in our bookkeeping */
2612 goto skip_fsfstatus
;
2615 /* evaluate FSF status in QTCB */
2616 switch (fsf_req
->qtcb
->header
.fsf_status
) {
2618 case FSF_PORT_HANDLE_NOT_VALID
:
2619 ZFCP_LOG_INFO("Temporary port identifier 0x%x for port "
2620 "0x%016Lx on adapter %s invalid. This may happen "
2621 "occasionally.\n", port
->handle
,
2622 port
->wwpn
, zfcp_get_busid_by_port(port
));
2623 ZFCP_LOG_DEBUG("status qualifier:\n");
2624 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
2625 (char *) &fsf_req
->qtcb
->header
.fsf_status_qual
,
2626 sizeof (union fsf_status_qual
));
2627 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
2629 zfcp_erp_adapter_reopen(port
->adapter
, 0);
2630 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
2633 case FSF_ADAPTER_STATUS_AVAILABLE
:
2634 /* Note: FSF has actually closed the port in this case.
2635 * The status code is just daft. Fingers crossed for a change
2641 ZFCP_LOG_TRACE("remote port 0x016%Lx on adapter %s closed, "
2642 "port handle 0x%x\n", port
->wwpn
,
2643 zfcp_get_busid_by_port(port
), port
->handle
);
2644 zfcp_erp_modify_port_status(port
,
2645 ZFCP_STATUS_COMMON_OPEN
,
2651 ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
2652 "(debug info 0x%x)\n",
2653 fsf_req
->qtcb
->header
.fsf_status
);
2654 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0, "fsf_s_inval:");
2655 debug_exception(fsf_req
->adapter
->erp_dbf
, 0,
2656 &fsf_req
->qtcb
->header
.fsf_status
,
2662 atomic_clear_mask(ZFCP_STATUS_COMMON_CLOSING
, &port
->status
);
2667 * function: zfcp_fsf_close_physical_port
2669 * purpose: submit FSF command "close physical port"
2671 * returns: address of initiated FSF request
2672 * NULL - request could not be initiated
2675 zfcp_fsf_close_physical_port(struct zfcp_erp_action
*erp_action
)
2678 unsigned long lock_flags
;
2679 volatile struct qdio_buffer_element
*sbale
;
2681 /* setup new FSF request */
2682 retval
= zfcp_fsf_req_create(erp_action
->adapter
,
2683 FSF_QTCB_CLOSE_PHYSICAL_PORT
,
2684 ZFCP_WAIT_FOR_SBAL
| ZFCP_REQ_AUTO_CLEANUP
,
2685 erp_action
->adapter
->pool
.fsf_req_erp
,
2686 &lock_flags
, &erp_action
->fsf_req
);
2688 ZFCP_LOG_INFO("error: Could not create close physical port "
2689 "request (adapter %s, port 0x%016Lx)\n",
2690 zfcp_get_busid_by_adapter(erp_action
->adapter
),
2691 erp_action
->port
->wwpn
);
2696 sbale
= zfcp_qdio_sbale_req(erp_action
->fsf_req
,
2697 erp_action
->fsf_req
->sbal_curr
, 0);
2698 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_READ
;
2699 sbale
[1].flags
|= SBAL_FLAGS_LAST_ENTRY
;
2701 /* mark port as being closed */
2702 atomic_set_mask(ZFCP_STATUS_PORT_PHYS_CLOSING
,
2703 &erp_action
->port
->status
);
2704 /* save a pointer to this port */
2705 erp_action
->fsf_req
->data
.close_physical_port
.port
= erp_action
->port
;
2706 /* port to be closeed */
2707 erp_action
->fsf_req
->qtcb
->header
.port_handle
=
2708 erp_action
->port
->handle
;
2709 erp_action
->fsf_req
->erp_action
= erp_action
;
2711 /* start QDIO request for this FSF request */
2712 retval
= zfcp_fsf_req_send(erp_action
->fsf_req
, &erp_action
->timer
);
2714 ZFCP_LOG_INFO("error: Could not send close physical port "
2715 "request (adapter %s, port 0x%016Lx)\n",
2716 zfcp_get_busid_by_adapter(erp_action
->adapter
),
2717 erp_action
->port
->wwpn
);
2718 zfcp_fsf_req_free(erp_action
->fsf_req
);
2719 erp_action
->fsf_req
= NULL
;
2723 ZFCP_LOG_TRACE("close physical port request initiated "
2724 "(adapter %s, port 0x%016Lx)\n",
2725 zfcp_get_busid_by_adapter(erp_action
->adapter
),
2726 erp_action
->port
->wwpn
);
2728 write_unlock_irqrestore(&erp_action
->adapter
->request_queue
.queue_lock
,
2734 * function: zfcp_fsf_close_physical_port_handler
2736 * purpose: is called for finished Close Physical Port FSF command
2741 zfcp_fsf_close_physical_port_handler(struct zfcp_fsf_req
*fsf_req
)
2743 int retval
= -EINVAL
;
2744 struct zfcp_port
*port
;
2745 struct zfcp_unit
*unit
;
2746 struct fsf_qtcb_header
*header
;
2747 u16 subtable
, rule
, counter
;
2749 port
= fsf_req
->data
.close_physical_port
.port
;
2750 header
= &fsf_req
->qtcb
->header
;
2752 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
) {
2753 /* don't change port status in our bookkeeping */
2754 goto skip_fsfstatus
;
2757 /* evaluate FSF status in QTCB */
2758 switch (header
->fsf_status
) {
2760 case FSF_PORT_HANDLE_NOT_VALID
:
2761 ZFCP_LOG_INFO("Temporary port identifier 0x%x invalid"
2762 "(adapter %s, port 0x%016Lx). "
2763 "This may happen occasionally.\n",
2765 zfcp_get_busid_by_port(port
),
2767 ZFCP_LOG_DEBUG("status qualifier:\n");
2768 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
2769 (char *) &header
->fsf_status_qual
,
2770 sizeof (union fsf_status_qual
));
2771 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
2773 zfcp_erp_adapter_reopen(port
->adapter
, 0);
2774 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
2777 case FSF_ACCESS_DENIED
:
2778 ZFCP_LOG_NORMAL("Access denied, cannot close "
2779 "physical port 0x%016Lx on adapter %s\n",
2780 port
->wwpn
, zfcp_get_busid_by_port(port
));
2781 for (counter
= 0; counter
< 2; counter
++) {
2782 subtable
= header
->fsf_status_qual
.halfword
[counter
* 2];
2783 rule
= header
->fsf_status_qual
.halfword
[counter
* 2 + 1];
2785 case FSF_SQ_CFDC_SUBTABLE_OS
:
2786 case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN
:
2787 case FSF_SQ_CFDC_SUBTABLE_PORT_DID
:
2788 case FSF_SQ_CFDC_SUBTABLE_LUN
:
2789 ZFCP_LOG_INFO("Access denied (%s rule %d)\n",
2790 zfcp_act_subtable_type
[subtable
], rule
);
2794 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1, "fsf_s_access");
2795 zfcp_erp_port_access_denied(port
);
2796 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
2799 case FSF_PORT_BOXED
:
2800 ZFCP_LOG_DEBUG("The remote port 0x%016Lx on adapter "
2801 "%s needs to be reopened but it was attempted "
2802 "to close it physically.\n",
2804 zfcp_get_busid_by_port(port
));
2805 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1, "fsf_s_pboxed");
2806 zfcp_erp_port_boxed(port
);
2807 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
|
2808 ZFCP_STATUS_FSFREQ_RETRY
;
2811 case FSF_ADAPTER_STATUS_AVAILABLE
:
2812 switch (header
->fsf_status_qual
.word
[0]) {
2813 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE
:
2814 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
2816 /* This will now be escalated by ERP */
2817 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
2819 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED
:
2820 /* ERP strategy will escalate */
2821 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
2823 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
2827 ("bug: Wrong status qualifier 0x%x arrived.\n",
2828 header
->fsf_status_qual
.word
[0]);
2829 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0,
2832 fsf_req
->adapter
->erp_dbf
, 0,
2833 &header
->fsf_status_qual
.word
[0], sizeof (u32
));
2839 ZFCP_LOG_DEBUG("Remote port 0x%016Lx via adapter %s "
2840 "physically closed, port handle 0x%x\n",
2842 zfcp_get_busid_by_port(port
), port
->handle
);
2843 /* can't use generic zfcp_erp_modify_port_status because
2844 * ZFCP_STATUS_COMMON_OPEN must not be reset for the port
2846 atomic_clear_mask(ZFCP_STATUS_PORT_PHYS_OPEN
, &port
->status
);
2847 list_for_each_entry(unit
, &port
->unit_list_head
, list
)
2848 atomic_clear_mask(ZFCP_STATUS_COMMON_OPEN
, &unit
->status
);
2853 ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
2854 "(debug info 0x%x)\n",
2855 header
->fsf_status
);
2856 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0, "fsf_s_inval:");
2857 debug_exception(fsf_req
->adapter
->erp_dbf
, 0,
2858 &header
->fsf_status
, sizeof (u32
));
2863 atomic_clear_mask(ZFCP_STATUS_PORT_PHYS_CLOSING
, &port
->status
);
2868 * function: zfcp_fsf_open_unit
2874 * assumptions: This routine does not check whether the associated
2875 * remote port has already been opened. This should be
2876 * done by calling routines. Otherwise some status
2877 * may be presented by FSF
2880 zfcp_fsf_open_unit(struct zfcp_erp_action
*erp_action
)
2882 volatile struct qdio_buffer_element
*sbale
;
2883 unsigned long lock_flags
;
2886 /* setup new FSF request */
2887 retval
= zfcp_fsf_req_create(erp_action
->adapter
,
2889 ZFCP_WAIT_FOR_SBAL
| ZFCP_REQ_AUTO_CLEANUP
,
2890 erp_action
->adapter
->pool
.fsf_req_erp
,
2891 &lock_flags
, &(erp_action
->fsf_req
));
2893 ZFCP_LOG_INFO("error: Could not create open unit request for "
2894 "unit 0x%016Lx on port 0x%016Lx on adapter %s.\n",
2895 erp_action
->unit
->fcp_lun
,
2896 erp_action
->unit
->port
->wwpn
,
2897 zfcp_get_busid_by_adapter(erp_action
->adapter
));
2901 sbale
= zfcp_qdio_sbale_req(erp_action
->fsf_req
,
2902 erp_action
->fsf_req
->sbal_curr
, 0);
2903 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_READ
;
2904 sbale
[1].flags
|= SBAL_FLAGS_LAST_ENTRY
;
2906 erp_action
->fsf_req
->qtcb
->header
.port_handle
=
2907 erp_action
->port
->handle
;
2908 erp_action
->fsf_req
->qtcb
->bottom
.support
.fcp_lun
=
2909 erp_action
->unit
->fcp_lun
;
2910 erp_action
->fsf_req
->qtcb
->bottom
.support
.option
=
2911 FSF_OPEN_LUN_SUPPRESS_BOXING
;
2912 atomic_set_mask(ZFCP_STATUS_COMMON_OPENING
, &erp_action
->unit
->status
);
2913 erp_action
->fsf_req
->data
.open_unit
.unit
= erp_action
->unit
;
2914 erp_action
->fsf_req
->erp_action
= erp_action
;
2916 /* start QDIO request for this FSF request */
2917 retval
= zfcp_fsf_req_send(erp_action
->fsf_req
, &erp_action
->timer
);
2919 ZFCP_LOG_INFO("error: Could not send an open unit request "
2920 "on the adapter %s, port 0x%016Lx for "
2922 zfcp_get_busid_by_adapter(erp_action
->adapter
),
2923 erp_action
->port
->wwpn
,
2924 erp_action
->unit
->fcp_lun
);
2925 zfcp_fsf_req_free(erp_action
->fsf_req
);
2926 erp_action
->fsf_req
= NULL
;
2930 ZFCP_LOG_TRACE("Open LUN request initiated (adapter %s, "
2931 "port 0x%016Lx, unit 0x%016Lx)\n",
2932 zfcp_get_busid_by_adapter(erp_action
->adapter
),
2933 erp_action
->port
->wwpn
, erp_action
->unit
->fcp_lun
);
2935 write_unlock_irqrestore(&erp_action
->adapter
->request_queue
.queue_lock
,
2941 * function: zfcp_fsf_open_unit_handler
2943 * purpose: is called for finished Open LUN command
2948 zfcp_fsf_open_unit_handler(struct zfcp_fsf_req
*fsf_req
)
2950 int retval
= -EINVAL
;
2951 struct zfcp_adapter
*adapter
;
2952 struct zfcp_unit
*unit
;
2953 struct fsf_qtcb_header
*header
;
2954 struct fsf_qtcb_bottom_support
*bottom
;
2955 struct fsf_queue_designator
*queue_designator
;
2956 u16 subtable
, rule
, counter
;
2957 u32 allowed
, exclusive
, readwrite
;
2959 unit
= fsf_req
->data
.open_unit
.unit
;
2961 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
) {
2962 /* don't change unit status in our bookkeeping */
2963 goto skip_fsfstatus
;
2966 adapter
= fsf_req
->adapter
;
2967 header
= &fsf_req
->qtcb
->header
;
2968 bottom
= &fsf_req
->qtcb
->bottom
.support
;
2969 queue_designator
= &header
->fsf_status_qual
.fsf_queue_designator
;
2971 allowed
= bottom
->lun_access_info
& FSF_UNIT_ACCESS_OPEN_LUN_ALLOWED
;
2972 exclusive
= bottom
->lun_access_info
& FSF_UNIT_ACCESS_EXCLUSIVE
;
2973 readwrite
= bottom
->lun_access_info
& FSF_UNIT_ACCESS_OUTBOUND_TRANSFER
;
2975 atomic_clear_mask(ZFCP_STATUS_COMMON_ACCESS_DENIED
|
2976 ZFCP_STATUS_UNIT_SHARED
|
2977 ZFCP_STATUS_UNIT_READONLY
,
2980 /* evaluate FSF status in QTCB */
2981 switch (header
->fsf_status
) {
2983 case FSF_PORT_HANDLE_NOT_VALID
:
2984 ZFCP_LOG_INFO("Temporary port identifier 0x%x "
2985 "for port 0x%016Lx on adapter %s invalid "
2986 "This may happen occasionally\n",
2988 unit
->port
->wwpn
, zfcp_get_busid_by_unit(unit
));
2989 ZFCP_LOG_DEBUG("status qualifier:\n");
2990 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
2991 (char *) &header
->fsf_status_qual
,
2992 sizeof (union fsf_status_qual
));
2993 debug_text_event(adapter
->erp_dbf
, 1, "fsf_s_ph_nv");
2994 zfcp_erp_adapter_reopen(unit
->port
->adapter
, 0);
2995 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
2998 case FSF_LUN_ALREADY_OPEN
:
2999 ZFCP_LOG_NORMAL("bug: Attempted to open unit 0x%016Lx on "
3000 "remote port 0x%016Lx on adapter %s twice.\n",
3002 unit
->port
->wwpn
, zfcp_get_busid_by_unit(unit
));
3003 debug_text_exception(adapter
->erp_dbf
, 0,
3005 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3008 case FSF_ACCESS_DENIED
:
3009 ZFCP_LOG_NORMAL("Access denied, cannot open unit 0x%016Lx on "
3010 "remote port 0x%016Lx on adapter %s\n",
3011 unit
->fcp_lun
, unit
->port
->wwpn
,
3012 zfcp_get_busid_by_unit(unit
));
3013 for (counter
= 0; counter
< 2; counter
++) {
3014 subtable
= header
->fsf_status_qual
.halfword
[counter
* 2];
3015 rule
= header
->fsf_status_qual
.halfword
[counter
* 2 + 1];
3017 case FSF_SQ_CFDC_SUBTABLE_OS
:
3018 case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN
:
3019 case FSF_SQ_CFDC_SUBTABLE_PORT_DID
:
3020 case FSF_SQ_CFDC_SUBTABLE_LUN
:
3021 ZFCP_LOG_INFO("Access denied (%s rule %d)\n",
3022 zfcp_act_subtable_type
[subtable
], rule
);
3026 debug_text_event(adapter
->erp_dbf
, 1, "fsf_s_access");
3027 zfcp_erp_unit_access_denied(unit
);
3028 atomic_clear_mask(ZFCP_STATUS_UNIT_SHARED
, &unit
->status
);
3029 atomic_clear_mask(ZFCP_STATUS_UNIT_READONLY
, &unit
->status
);
3030 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3033 case FSF_PORT_BOXED
:
3034 ZFCP_LOG_DEBUG("The remote port 0x%016Lx on adapter %s "
3035 "needs to be reopened\n",
3036 unit
->port
->wwpn
, zfcp_get_busid_by_unit(unit
));
3037 debug_text_event(adapter
->erp_dbf
, 2, "fsf_s_pboxed");
3038 zfcp_erp_port_boxed(unit
->port
);
3039 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
|
3040 ZFCP_STATUS_FSFREQ_RETRY
;
3043 case FSF_LUN_SHARING_VIOLATION
:
3044 if (header
->fsf_status_qual
.word
[0] != 0) {
3045 ZFCP_LOG_NORMAL("FCP-LUN 0x%Lx at the remote port "
3047 "connected to the adapter %s "
3048 "is already in use in LPAR%d, CSS%d\n",
3051 zfcp_get_busid_by_unit(unit
),
3052 queue_designator
->hla
,
3053 queue_designator
->cssid
);
3055 subtable
= header
->fsf_status_qual
.halfword
[4];
3056 rule
= header
->fsf_status_qual
.halfword
[5];
3058 case FSF_SQ_CFDC_SUBTABLE_OS
:
3059 case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN
:
3060 case FSF_SQ_CFDC_SUBTABLE_PORT_DID
:
3061 case FSF_SQ_CFDC_SUBTABLE_LUN
:
3062 ZFCP_LOG_NORMAL("Access to FCP-LUN 0x%Lx at the "
3063 "remote port with WWPN 0x%Lx "
3064 "connected to the adapter %s "
3065 "is denied (%s rule %d)\n",
3068 zfcp_get_busid_by_unit(unit
),
3069 zfcp_act_subtable_type
[subtable
],
3074 ZFCP_LOG_DEBUG("status qualifier:\n");
3075 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
3076 (char *) &header
->fsf_status_qual
,
3077 sizeof (union fsf_status_qual
));
3078 debug_text_event(adapter
->erp_dbf
, 2,
3080 zfcp_erp_unit_access_denied(unit
);
3081 atomic_clear_mask(ZFCP_STATUS_UNIT_SHARED
, &unit
->status
);
3082 atomic_clear_mask(ZFCP_STATUS_UNIT_READONLY
, &unit
->status
);
3083 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3086 case FSF_MAXIMUM_NUMBER_OF_LUNS_EXCEEDED
:
3087 ZFCP_LOG_INFO("error: The adapter ran out of resources. "
3088 "There is no handle (temporary port identifier) "
3089 "available for unit 0x%016Lx on port 0x%016Lx "
3093 zfcp_get_busid_by_unit(unit
));
3094 debug_text_event(adapter
->erp_dbf
, 1,
3096 zfcp_erp_unit_failed(unit
);
3097 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3100 case FSF_ADAPTER_STATUS_AVAILABLE
:
3101 switch (header
->fsf_status_qual
.word
[0]) {
3102 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE
:
3103 /* Re-establish link to port */
3104 debug_text_event(adapter
->erp_dbf
, 1,
3106 zfcp_test_link(unit
->port
);
3107 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3109 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED
:
3110 /* ERP strategy will escalate */
3111 debug_text_event(adapter
->erp_dbf
, 1,
3113 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3117 ("bug: Wrong status qualifier 0x%x arrived.\n",
3118 header
->fsf_status_qual
.word
[0]);
3119 debug_text_event(adapter
->erp_dbf
, 0,
3121 debug_exception(adapter
->erp_dbf
, 0,
3122 &header
->fsf_status_qual
.word
[0],
3127 case FSF_INVALID_COMMAND_OPTION
:
3129 "Invalid option 0x%x has been specified "
3130 "in QTCB bottom sent to the adapter %s\n",
3132 zfcp_get_busid_by_adapter(adapter
));
3133 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3138 /* save LUN handle assigned by FSF */
3139 unit
->handle
= header
->lun_handle
;
3140 ZFCP_LOG_TRACE("unit 0x%016Lx on remote port 0x%016Lx on "
3141 "adapter %s opened, port handle 0x%x\n",
3144 zfcp_get_busid_by_unit(unit
),
3146 /* mark unit as open */
3147 atomic_set_mask(ZFCP_STATUS_COMMON_OPEN
, &unit
->status
);
3148 atomic_clear_mask(ZFCP_STATUS_COMMON_ACCESS_DENIED
|
3149 ZFCP_STATUS_COMMON_ACCESS_BOXED
,
3151 if (adapter
->supported_features
& FSF_FEATURE_LUN_SHARING
){
3153 atomic_set_mask(ZFCP_STATUS_UNIT_SHARED
,
3157 atomic_set_mask(ZFCP_STATUS_UNIT_READONLY
,
3159 ZFCP_LOG_NORMAL("read-only access for unit "
3160 "(adapter %s, wwpn=0x%016Lx, "
3161 "fcp_lun=0x%016Lx)\n",
3162 zfcp_get_busid_by_unit(unit
),
3167 if (exclusive
&& !readwrite
) {
3168 ZFCP_LOG_NORMAL("exclusive access of read-only "
3169 "unit not supported\n");
3170 zfcp_erp_unit_failed(unit
);
3171 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3172 zfcp_erp_unit_shutdown(unit
, 0);
3173 } else if (!exclusive
&& readwrite
) {
3174 ZFCP_LOG_NORMAL("shared access of read-write "
3175 "unit not supported\n");
3176 zfcp_erp_unit_failed(unit
);
3177 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3178 zfcp_erp_unit_shutdown(unit
, 0);
3186 ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
3187 "(debug info 0x%x)\n",
3188 header
->fsf_status
);
3189 debug_text_event(adapter
->erp_dbf
, 0, "fsf_s_inval:");
3190 debug_exception(adapter
->erp_dbf
, 0,
3191 &header
->fsf_status
, sizeof (u32
));
3196 atomic_clear_mask(ZFCP_STATUS_COMMON_OPENING
, &unit
->status
);
3201 * function: zfcp_fsf_close_unit
3205 * returns: address of fsf_req - request successfully initiated
3208 * assumptions: This routine does not check whether the associated
3209 * remote port/lun has already been opened. This should be
3210 * done by calling routines. Otherwise some status
3211 * may be presented by FSF
3214 zfcp_fsf_close_unit(struct zfcp_erp_action
*erp_action
)
3216 volatile struct qdio_buffer_element
*sbale
;
3217 unsigned long lock_flags
;
3220 /* setup new FSF request */
3221 retval
= zfcp_fsf_req_create(erp_action
->adapter
,
3223 ZFCP_WAIT_FOR_SBAL
| ZFCP_REQ_AUTO_CLEANUP
,
3224 erp_action
->adapter
->pool
.fsf_req_erp
,
3225 &lock_flags
, &(erp_action
->fsf_req
));
3227 ZFCP_LOG_INFO("error: Could not create close unit request for "
3228 "unit 0x%016Lx on port 0x%016Lx on adapter %s.\n",
3229 erp_action
->unit
->fcp_lun
,
3230 erp_action
->port
->wwpn
,
3231 zfcp_get_busid_by_adapter(erp_action
->adapter
));
3235 sbale
= zfcp_qdio_sbale_req(erp_action
->fsf_req
,
3236 erp_action
->fsf_req
->sbal_curr
, 0);
3237 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_READ
;
3238 sbale
[1].flags
|= SBAL_FLAGS_LAST_ENTRY
;
3240 erp_action
->fsf_req
->qtcb
->header
.port_handle
=
3241 erp_action
->port
->handle
;
3242 erp_action
->fsf_req
->qtcb
->header
.lun_handle
= erp_action
->unit
->handle
;
3243 atomic_set_mask(ZFCP_STATUS_COMMON_CLOSING
, &erp_action
->unit
->status
);
3244 erp_action
->fsf_req
->data
.close_unit
.unit
= erp_action
->unit
;
3245 erp_action
->fsf_req
->erp_action
= erp_action
;
3247 /* start QDIO request for this FSF request */
3248 retval
= zfcp_fsf_req_send(erp_action
->fsf_req
, &erp_action
->timer
);
3250 ZFCP_LOG_INFO("error: Could not send a close unit request for "
3251 "unit 0x%016Lx on port 0x%016Lx onadapter %s.\n",
3252 erp_action
->unit
->fcp_lun
,
3253 erp_action
->port
->wwpn
,
3254 zfcp_get_busid_by_adapter(erp_action
->adapter
));
3255 zfcp_fsf_req_free(erp_action
->fsf_req
);
3256 erp_action
->fsf_req
= NULL
;
3260 ZFCP_LOG_TRACE("Close LUN request initiated (adapter %s, "
3261 "port 0x%016Lx, unit 0x%016Lx)\n",
3262 zfcp_get_busid_by_adapter(erp_action
->adapter
),
3263 erp_action
->port
->wwpn
, erp_action
->unit
->fcp_lun
);
3265 write_unlock_irqrestore(&erp_action
->adapter
->request_queue
.queue_lock
,
3271 * function: zfcp_fsf_close_unit_handler
3273 * purpose: is called for finished Close LUN FSF command
3278 zfcp_fsf_close_unit_handler(struct zfcp_fsf_req
*fsf_req
)
3280 int retval
= -EINVAL
;
3281 struct zfcp_unit
*unit
;
3283 unit
= fsf_req
->data
.close_unit
.unit
; /* restore unit */
3285 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
) {
3286 /* don't change unit status in our bookkeeping */
3287 goto skip_fsfstatus
;
3290 /* evaluate FSF status in QTCB */
3291 switch (fsf_req
->qtcb
->header
.fsf_status
) {
3293 case FSF_PORT_HANDLE_NOT_VALID
:
3294 ZFCP_LOG_INFO("Temporary port identifier 0x%x for port "
3295 "0x%016Lx on adapter %s invalid. This may "
3296 "happen in rare circumstances\n",
3299 zfcp_get_busid_by_unit(unit
));
3300 ZFCP_LOG_DEBUG("status qualifier:\n");
3301 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
3302 (char *) &fsf_req
->qtcb
->header
.fsf_status_qual
,
3303 sizeof (union fsf_status_qual
));
3304 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
3306 zfcp_erp_adapter_reopen(unit
->port
->adapter
, 0);
3307 zfcp_cmd_dbf_event_fsf("porthinv", fsf_req
,
3308 &fsf_req
->qtcb
->header
.fsf_status_qual
,
3309 sizeof (union fsf_status_qual
));
3310 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3313 case FSF_LUN_HANDLE_NOT_VALID
:
3314 ZFCP_LOG_INFO("Temporary LUN identifier 0x%x of unit "
3315 "0x%016Lx on port 0x%016Lx on adapter %s is "
3316 "invalid. This may happen occasionally.\n",
3320 zfcp_get_busid_by_unit(unit
));
3321 ZFCP_LOG_DEBUG("Status qualifier data:\n");
3322 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
3323 (char *) &fsf_req
->qtcb
->header
.fsf_status_qual
,
3324 sizeof (union fsf_status_qual
));
3325 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
3327 zfcp_erp_port_reopen(unit
->port
, 0);
3328 zfcp_cmd_dbf_event_fsf("lunhinv", fsf_req
,
3329 &fsf_req
->qtcb
->header
.fsf_status_qual
,
3330 sizeof (union fsf_status_qual
));
3331 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3334 case FSF_PORT_BOXED
:
3335 ZFCP_LOG_DEBUG("The remote port 0x%016Lx on adapter %s "
3336 "needs to be reopened\n",
3338 zfcp_get_busid_by_unit(unit
));
3339 debug_text_event(fsf_req
->adapter
->erp_dbf
, 2, "fsf_s_pboxed");
3340 zfcp_erp_port_boxed(unit
->port
);
3341 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
|
3342 ZFCP_STATUS_FSFREQ_RETRY
;
3345 case FSF_ADAPTER_STATUS_AVAILABLE
:
3346 switch (fsf_req
->qtcb
->header
.fsf_status_qual
.word
[0]) {
3347 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE
:
3348 /* re-establish link to port */
3349 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
3351 zfcp_test_link(unit
->port
);
3352 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3354 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED
:
3355 /* ERP strategy will escalate */
3356 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
3358 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3362 ("bug: Wrong status qualifier 0x%x arrived.\n",
3363 fsf_req
->qtcb
->header
.fsf_status_qual
.word
[0]);
3364 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0,
3367 fsf_req
->adapter
->erp_dbf
, 0,
3368 &fsf_req
->qtcb
->header
.fsf_status_qual
.word
[0],
3375 ZFCP_LOG_TRACE("unit 0x%016Lx on port 0x%016Lx on adapter %s "
3376 "closed, port handle 0x%x\n",
3379 zfcp_get_busid_by_unit(unit
),
3381 /* mark unit as closed */
3382 atomic_clear_mask(ZFCP_STATUS_COMMON_OPEN
, &unit
->status
);
3387 ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
3388 "(debug info 0x%x)\n",
3389 fsf_req
->qtcb
->header
.fsf_status
);
3390 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0, "fsf_s_inval:");
3391 debug_exception(fsf_req
->adapter
->erp_dbf
, 0,
3392 &fsf_req
->qtcb
->header
.fsf_status
,
3398 atomic_clear_mask(ZFCP_STATUS_COMMON_CLOSING
, &unit
->status
);
3403 * zfcp_fsf_send_fcp_command_task - initiate an FCP command (for a SCSI command)
3404 * @adapter: adapter where scsi command is issued
3405 * @unit: unit where command is sent to
3406 * @scsi_cmnd: scsi command to be sent
3407 * @timer: timer to be started when request is initiated
3408 * @req_flags: flags for fsf_request
3411 zfcp_fsf_send_fcp_command_task(struct zfcp_adapter
*adapter
,
3412 struct zfcp_unit
*unit
,
3413 struct scsi_cmnd
* scsi_cmnd
,
3414 struct timer_list
*timer
, int req_flags
)
3416 struct zfcp_fsf_req
*fsf_req
= NULL
;
3417 struct fcp_cmnd_iu
*fcp_cmnd_iu
;
3418 unsigned int sbtype
;
3419 unsigned long lock_flags
;
3424 /* setup new FSF request */
3425 retval
= zfcp_fsf_req_create(adapter
, FSF_QTCB_FCP_CMND
, req_flags
,
3426 adapter
->pool
.fsf_req_scsi
,
3427 &lock_flags
, &fsf_req
);
3428 if (unlikely(retval
< 0)) {
3429 ZFCP_LOG_DEBUG("error: Could not create FCP command request "
3430 "for unit 0x%016Lx on port 0x%016Lx on "
3434 zfcp_get_busid_by_adapter(adapter
));
3435 goto failed_req_create
;
3439 * associate FSF request with SCSI request
3440 * (need this for look up on abort)
3442 fsf_req
->data
.send_fcp_command_task
.fsf_req
= fsf_req
;
3443 scsi_cmnd
->host_scribble
= (char *) &(fsf_req
->data
);
3446 * associate SCSI command with FSF request
3447 * (need this for look up on normal command completion)
3449 fsf_req
->data
.send_fcp_command_task
.scsi_cmnd
= scsi_cmnd
;
3450 fsf_req
->data
.send_fcp_command_task
.start_jiffies
= jiffies
;
3451 fsf_req
->data
.send_fcp_command_task
.unit
= unit
;
3452 ZFCP_LOG_DEBUG("unit=%p, fcp_lun=0x%016Lx\n", unit
, unit
->fcp_lun
);
3454 /* set handles of unit and its parent port in QTCB */
3455 fsf_req
->qtcb
->header
.lun_handle
= unit
->handle
;
3456 fsf_req
->qtcb
->header
.port_handle
= unit
->port
->handle
;
3458 /* FSF does not define the structure of the FCP_CMND IU */
3459 fcp_cmnd_iu
= (struct fcp_cmnd_iu
*)
3460 &(fsf_req
->qtcb
->bottom
.io
.fcp_cmnd
);
3463 * set depending on data direction:
3464 * data direction bits in SBALE (SB Type)
3465 * data direction bits in QTCB
3466 * data direction bits in FCP_CMND IU
3468 switch (scsi_cmnd
->sc_data_direction
) {
3470 fsf_req
->qtcb
->bottom
.io
.data_direction
= FSF_DATADIR_CMND
;
3473 * what is the correct type for commands
3474 * without 'real' data buffers?
3476 sbtype
= SBAL_FLAGS0_TYPE_READ
;
3478 case DMA_FROM_DEVICE
:
3479 fsf_req
->qtcb
->bottom
.io
.data_direction
= FSF_DATADIR_READ
;
3480 sbtype
= SBAL_FLAGS0_TYPE_READ
;
3481 fcp_cmnd_iu
->rddata
= 1;
3484 fsf_req
->qtcb
->bottom
.io
.data_direction
= FSF_DATADIR_WRITE
;
3485 sbtype
= SBAL_FLAGS0_TYPE_WRITE
;
3486 fcp_cmnd_iu
->wddata
= 1;
3488 case DMA_BIDIRECTIONAL
:
3491 * dummy, catch this condition earlier
3492 * in zfcp_scsi_queuecommand
3494 goto failed_scsi_cmnd
;
3497 /* set FC service class in QTCB (3 per default) */
3498 fsf_req
->qtcb
->bottom
.io
.service_class
= adapter
->fc_service_class
;
3500 /* set FCP_LUN in FCP_CMND IU in QTCB */
3501 fcp_cmnd_iu
->fcp_lun
= unit
->fcp_lun
;
3503 mask
= ZFCP_STATUS_UNIT_READONLY
| ZFCP_STATUS_UNIT_SHARED
;
3505 /* set task attributes in FCP_CMND IU in QTCB */
3506 if (likely((scsi_cmnd
->device
->simple_tags
) ||
3507 (atomic_test_mask(mask
, &unit
->status
))))
3508 fcp_cmnd_iu
->task_attribute
= SIMPLE_Q
;
3510 fcp_cmnd_iu
->task_attribute
= UNTAGGED
;
3512 /* set additional length of FCP_CDB in FCP_CMND IU in QTCB, if needed */
3513 if (unlikely(scsi_cmnd
->cmd_len
> FCP_CDB_LENGTH
)) {
3514 fcp_cmnd_iu
->add_fcp_cdb_length
3515 = (scsi_cmnd
->cmd_len
- FCP_CDB_LENGTH
) >> 2;
3516 ZFCP_LOG_TRACE("SCSI CDB length is 0x%x, "
3517 "additional FCP_CDB length is 0x%x "
3518 "(shifted right 2 bits)\n",
3520 fcp_cmnd_iu
->add_fcp_cdb_length
);
3523 * copy SCSI CDB (including additional length, if any) to
3524 * FCP_CDB in FCP_CMND IU in QTCB
3526 memcpy(fcp_cmnd_iu
->fcp_cdb
, scsi_cmnd
->cmnd
, scsi_cmnd
->cmd_len
);
3528 /* FCP CMND IU length in QTCB */
3529 fsf_req
->qtcb
->bottom
.io
.fcp_cmnd_length
=
3530 sizeof (struct fcp_cmnd_iu
) +
3531 fcp_cmnd_iu
->add_fcp_cdb_length
+ sizeof (fcp_dl_t
);
3533 /* generate SBALEs from data buffer */
3534 real_bytes
= zfcp_qdio_sbals_from_scsicmnd(fsf_req
, sbtype
, scsi_cmnd
);
3535 if (unlikely(real_bytes
< 0)) {
3536 if (fsf_req
->sbal_number
< ZFCP_MAX_SBALS_PER_REQ
) {
3538 "Data did not fit into available buffer(s), "
3539 "waiting for more...\n");
3542 ZFCP_LOG_NORMAL("error: No truncation implemented but "
3543 "required. Shutting down unit "
3544 "(adapter %s, port 0x%016Lx, "
3546 zfcp_get_busid_by_unit(unit
),
3549 zfcp_erp_unit_shutdown(unit
, 0);
3555 /* set length of FCP data length in FCP_CMND IU in QTCB */
3556 zfcp_set_fcp_dl(fcp_cmnd_iu
, real_bytes
);
3558 ZFCP_LOG_DEBUG("Sending SCSI command:\n");
3559 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
3560 (char *) scsi_cmnd
->cmnd
, scsi_cmnd
->cmd_len
);
3563 * start QDIO request for this FSF request
3564 * covered by an SBALE)
3566 retval
= zfcp_fsf_req_send(fsf_req
, timer
);
3567 if (unlikely(retval
< 0)) {
3568 ZFCP_LOG_INFO("error: Could not send FCP command request "
3569 "on adapter %s, port 0x%016Lx, unit 0x%016Lx\n",
3570 zfcp_get_busid_by_adapter(adapter
),
3576 ZFCP_LOG_TRACE("Send FCP Command initiated (adapter %s, "
3577 "port 0x%016Lx, unit 0x%016Lx)\n",
3578 zfcp_get_busid_by_adapter(adapter
),
3586 zfcp_fsf_req_free(fsf_req
);
3588 scsi_cmnd
->host_scribble
= NULL
;
3591 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
, lock_flags
);
3596 * function: zfcp_fsf_send_fcp_command_task_management
3602 * FIXME(design): should be watched by a timeout!!!
3603 * FIXME(design) shouldn't this be modified to return an int
3604 * also...don't know how though
3607 struct zfcp_fsf_req
*
3608 zfcp_fsf_send_fcp_command_task_management(struct zfcp_adapter
*adapter
,
3609 struct zfcp_unit
*unit
,
3610 u8 tm_flags
, int req_flags
)
3612 struct zfcp_fsf_req
*fsf_req
= NULL
;
3614 struct fcp_cmnd_iu
*fcp_cmnd_iu
;
3615 unsigned long lock_flags
;
3616 volatile struct qdio_buffer_element
*sbale
;
3618 /* setup new FSF request */
3619 retval
= zfcp_fsf_req_create(adapter
, FSF_QTCB_FCP_CMND
, req_flags
,
3620 adapter
->pool
.fsf_req_scsi
,
3621 &lock_flags
, &fsf_req
);
3623 ZFCP_LOG_INFO("error: Could not create FCP command (task "
3624 "management) request for adapter %s, port "
3625 " 0x%016Lx, unit 0x%016Lx.\n",
3626 zfcp_get_busid_by_adapter(adapter
),
3627 unit
->port
->wwpn
, unit
->fcp_lun
);
3632 * Used to decide on proper handler in the return path,
3633 * could be either zfcp_fsf_send_fcp_command_task_handler or
3634 * zfcp_fsf_send_fcp_command_task_management_handler */
3636 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT
;
3639 * hold a pointer to the unit being target of this
3640 * task management request
3642 fsf_req
->data
.send_fcp_command_task_management
.unit
= unit
;
3644 /* set FSF related fields in QTCB */
3645 fsf_req
->qtcb
->header
.lun_handle
= unit
->handle
;
3646 fsf_req
->qtcb
->header
.port_handle
= unit
->port
->handle
;
3647 fsf_req
->qtcb
->bottom
.io
.data_direction
= FSF_DATADIR_CMND
;
3648 fsf_req
->qtcb
->bottom
.io
.service_class
= adapter
->fc_service_class
;
3649 fsf_req
->qtcb
->bottom
.io
.fcp_cmnd_length
=
3650 sizeof (struct fcp_cmnd_iu
) + sizeof (fcp_dl_t
);
3652 sbale
= zfcp_qdio_sbale_req(fsf_req
, fsf_req
->sbal_curr
, 0);
3653 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_WRITE
;
3654 sbale
[1].flags
|= SBAL_FLAGS_LAST_ENTRY
;
3656 /* set FCP related fields in FCP_CMND IU in QTCB */
3657 fcp_cmnd_iu
= (struct fcp_cmnd_iu
*)
3658 &(fsf_req
->qtcb
->bottom
.io
.fcp_cmnd
);
3659 fcp_cmnd_iu
->fcp_lun
= unit
->fcp_lun
;
3660 fcp_cmnd_iu
->task_management_flags
= tm_flags
;
3662 /* start QDIO request for this FSF request */
3663 zfcp_fsf_start_scsi_er_timer(adapter
);
3664 retval
= zfcp_fsf_req_send(fsf_req
, NULL
);
3666 del_timer(&adapter
->scsi_er_timer
);
3667 ZFCP_LOG_INFO("error: Could not send an FCP-command (task "
3668 "management) on adapter %s, port 0x%016Lx for "
3669 "unit LUN 0x%016Lx\n",
3670 zfcp_get_busid_by_adapter(adapter
),
3673 zfcp_fsf_req_free(fsf_req
);
3678 ZFCP_LOG_TRACE("Send FCP Command (task management function) initiated "
3679 "(adapter %s, port 0x%016Lx, unit 0x%016Lx, "
3681 zfcp_get_busid_by_adapter(adapter
),
3686 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
, lock_flags
);
3691 * function: zfcp_fsf_send_fcp_command_handler
3693 * purpose: is called for finished Send FCP Command
3698 zfcp_fsf_send_fcp_command_handler(struct zfcp_fsf_req
*fsf_req
)
3700 int retval
= -EINVAL
;
3701 struct zfcp_unit
*unit
;
3702 struct fsf_qtcb_header
*header
;
3703 u16 subtable
, rule
, counter
;
3705 header
= &fsf_req
->qtcb
->header
;
3707 if (unlikely(fsf_req
->status
& ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT
))
3708 unit
= fsf_req
->data
.send_fcp_command_task_management
.unit
;
3710 unit
= fsf_req
->data
.send_fcp_command_task
.unit
;
3712 if (unlikely(fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
)) {
3713 /* go directly to calls of special handlers */
3714 goto skip_fsfstatus
;
3717 /* evaluate FSF status in QTCB */
3718 switch (header
->fsf_status
) {
3720 case FSF_PORT_HANDLE_NOT_VALID
:
3721 ZFCP_LOG_INFO("Temporary port identifier 0x%x for port "
3722 "0x%016Lx on adapter %s invalid\n",
3724 unit
->port
->wwpn
, zfcp_get_busid_by_unit(unit
));
3725 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
3726 (char *) &header
->fsf_status_qual
,
3727 sizeof (union fsf_status_qual
));
3728 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
3730 zfcp_erp_adapter_reopen(unit
->port
->adapter
, 0);
3731 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3734 case FSF_LUN_HANDLE_NOT_VALID
:
3735 ZFCP_LOG_INFO("Temporary LUN identifier 0x%x for unit "
3736 "0x%016Lx on port 0x%016Lx on adapter %s is "
3737 "invalid. This may happen occasionally.\n",
3741 zfcp_get_busid_by_unit(unit
));
3742 ZFCP_LOG_NORMAL("Status qualifier data:\n");
3743 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_NORMAL
,
3744 (char *) &header
->fsf_status_qual
,
3745 sizeof (union fsf_status_qual
));
3746 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
3748 zfcp_erp_port_reopen(unit
->port
, 0);
3749 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3752 case FSF_HANDLE_MISMATCH
:
3753 ZFCP_LOG_NORMAL("bug: The port handle 0x%x has changed "
3754 "unexpectedly. (adapter %s, port 0x%016Lx, "
3757 zfcp_get_busid_by_unit(unit
),
3760 ZFCP_LOG_NORMAL("status qualifier:\n");
3761 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_NORMAL
,
3762 (char *) &header
->fsf_status_qual
,
3763 sizeof (union fsf_status_qual
));
3764 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
3766 zfcp_erp_adapter_reopen(unit
->port
->adapter
, 0);
3767 zfcp_cmd_dbf_event_fsf("handmism",
3769 &header
->fsf_status_qual
,
3770 sizeof (union fsf_status_qual
));
3771 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3774 case FSF_SERVICE_CLASS_NOT_SUPPORTED
:
3775 if (fsf_req
->adapter
->fc_service_class
<= 3) {
3776 ZFCP_LOG_NORMAL("error: The adapter %s does "
3777 "not support fibrechannel class %d.\n",
3778 zfcp_get_busid_by_unit(unit
),
3779 fsf_req
->adapter
->fc_service_class
);
3781 ZFCP_LOG_NORMAL("bug: The fibrechannel class at "
3782 "adapter %s is invalid. "
3783 "(debug info %d)\n",
3784 zfcp_get_busid_by_unit(unit
),
3785 fsf_req
->adapter
->fc_service_class
);
3787 /* stop operation for this adapter */
3788 debug_text_exception(fsf_req
->adapter
->erp_dbf
, 0,
3789 "fsf_s_class_nsup");
3790 zfcp_erp_adapter_shutdown(unit
->port
->adapter
, 0);
3791 zfcp_cmd_dbf_event_fsf("unsclass",
3793 &header
->fsf_status_qual
,
3794 sizeof (union fsf_status_qual
));
3795 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3798 case FSF_FCPLUN_NOT_VALID
:
3799 ZFCP_LOG_NORMAL("bug: unit 0x%016Lx on port 0x%016Lx on "
3800 "adapter %s does not have correct unit "
3804 zfcp_get_busid_by_unit(unit
),
3806 ZFCP_LOG_DEBUG("status qualifier:\n");
3807 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
3808 (char *) &header
->fsf_status_qual
,
3809 sizeof (union fsf_status_qual
));
3810 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
3811 "fsf_s_fcp_lun_nv");
3812 zfcp_erp_port_reopen(unit
->port
, 0);
3813 zfcp_cmd_dbf_event_fsf("fluninv",
3815 &header
->fsf_status_qual
,
3816 sizeof (union fsf_status_qual
));
3817 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3820 case FSF_ACCESS_DENIED
:
3821 ZFCP_LOG_NORMAL("Access denied, cannot send FCP command to "
3822 "unit 0x%016Lx on port 0x%016Lx on "
3823 "adapter %s\n", unit
->fcp_lun
, unit
->port
->wwpn
,
3824 zfcp_get_busid_by_unit(unit
));
3825 for (counter
= 0; counter
< 2; counter
++) {
3826 subtable
= header
->fsf_status_qual
.halfword
[counter
* 2];
3827 rule
= header
->fsf_status_qual
.halfword
[counter
* 2 + 1];
3829 case FSF_SQ_CFDC_SUBTABLE_OS
:
3830 case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN
:
3831 case FSF_SQ_CFDC_SUBTABLE_PORT_DID
:
3832 case FSF_SQ_CFDC_SUBTABLE_LUN
:
3833 ZFCP_LOG_INFO("Access denied (%s rule %d)\n",
3834 zfcp_act_subtable_type
[subtable
], rule
);
3838 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1, "fsf_s_access");
3839 zfcp_erp_unit_access_denied(unit
);
3840 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3843 case FSF_DIRECTION_INDICATOR_NOT_VALID
:
3844 ZFCP_LOG_INFO("bug: Invalid data direction given for unit "
3845 "0x%016Lx on port 0x%016Lx on adapter %s "
3846 "(debug info %d)\n",
3849 zfcp_get_busid_by_unit(unit
),
3850 fsf_req
->qtcb
->bottom
.io
.data_direction
);
3851 /* stop operation for this adapter */
3852 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0,
3853 "fsf_s_dir_ind_nv");
3854 zfcp_erp_adapter_shutdown(unit
->port
->adapter
, 0);
3855 zfcp_cmd_dbf_event_fsf("dirinv",
3857 &header
->fsf_status_qual
,
3858 sizeof (union fsf_status_qual
));
3859 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3862 case FSF_CMND_LENGTH_NOT_VALID
:
3864 ("bug: An invalid control-data-block length field "
3865 "was found in a command for unit 0x%016Lx on port "
3866 "0x%016Lx on adapter %s " "(debug info %d)\n",
3867 unit
->fcp_lun
, unit
->port
->wwpn
,
3868 zfcp_get_busid_by_unit(unit
),
3869 fsf_req
->qtcb
->bottom
.io
.fcp_cmnd_length
);
3870 /* stop operation for this adapter */
3871 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0,
3872 "fsf_s_cmd_len_nv");
3873 zfcp_erp_adapter_shutdown(unit
->port
->adapter
, 0);
3874 zfcp_cmd_dbf_event_fsf("cleninv",
3876 &header
->fsf_status_qual
,
3877 sizeof (union fsf_status_qual
));
3878 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3881 case FSF_PORT_BOXED
:
3882 ZFCP_LOG_DEBUG("The remote port 0x%016Lx on adapter %s "
3883 "needs to be reopened\n",
3884 unit
->port
->wwpn
, zfcp_get_busid_by_unit(unit
));
3885 debug_text_event(fsf_req
->adapter
->erp_dbf
, 2, "fsf_s_pboxed");
3886 zfcp_erp_port_boxed(unit
->port
);
3887 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
|
3888 ZFCP_STATUS_FSFREQ_RETRY
;
3892 ZFCP_LOG_NORMAL("unit needs to be reopened (adapter %s, "
3893 "wwpn=0x%016Lx, fcp_lun=0x%016Lx)\n",
3894 zfcp_get_busid_by_unit(unit
),
3895 unit
->port
->wwpn
, unit
->fcp_lun
);
3896 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1, "fsf_s_lboxed");
3897 zfcp_erp_unit_boxed(unit
);
3898 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
3899 | ZFCP_STATUS_FSFREQ_RETRY
;
3902 case FSF_ADAPTER_STATUS_AVAILABLE
:
3903 switch (header
->fsf_status_qual
.word
[0]) {
3904 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE
:
3905 /* re-establish link to port */
3906 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
3908 zfcp_test_link(unit
->port
);
3910 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED
:
3911 /* FIXME(hw) need proper specs for proper action */
3912 /* let scsi stack deal with retries and escalation */
3913 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
3918 ("Unknown status qualifier 0x%x arrived.\n",
3919 header
->fsf_status_qual
.word
[0]);
3920 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0,
3922 debug_exception(fsf_req
->adapter
->erp_dbf
, 0,
3923 &header
->fsf_status_qual
.word
[0],
3927 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3933 case FSF_FCP_RSP_AVAILABLE
:
3937 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0, "fsf_s_inval:");
3938 debug_exception(fsf_req
->adapter
->erp_dbf
, 0,
3939 &header
->fsf_status
, sizeof(u32
));
3944 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT
) {
3946 zfcp_fsf_send_fcp_command_task_management_handler(fsf_req
);
3948 retval
= zfcp_fsf_send_fcp_command_task_handler(fsf_req
);
3954 * function: zfcp_fsf_send_fcp_command_task_handler
3956 * purpose: evaluates FCP_RSP IU
3961 zfcp_fsf_send_fcp_command_task_handler(struct zfcp_fsf_req
*fsf_req
)
3964 struct scsi_cmnd
*scpnt
;
3965 struct fcp_rsp_iu
*fcp_rsp_iu
= (struct fcp_rsp_iu
*)
3966 &(fsf_req
->qtcb
->bottom
.io
.fcp_rsp
);
3967 struct fcp_cmnd_iu
*fcp_cmnd_iu
= (struct fcp_cmnd_iu
*)
3968 &(fsf_req
->qtcb
->bottom
.io
.fcp_cmnd
);
3970 char *fcp_rsp_info
= zfcp_get_fcp_rsp_info_ptr(fcp_rsp_iu
);
3971 unsigned long flags
;
3972 struct zfcp_unit
*unit
= fsf_req
->data
.send_fcp_command_task
.unit
;
3974 read_lock_irqsave(&fsf_req
->adapter
->abort_lock
, flags
);
3975 scpnt
= fsf_req
->data
.send_fcp_command_task
.scsi_cmnd
;
3976 if (unlikely(!scpnt
)) {
3978 ("Command with fsf_req %p is not associated to "
3979 "a scsi command anymore. Aborted?\n", fsf_req
);
3982 if (unlikely(fsf_req
->status
& ZFCP_STATUS_FSFREQ_ABORTED
)) {
3983 /* FIXME: (design) mid-layer should handle DID_ABORT like
3984 * DID_SOFT_ERROR by retrying the request for devices
3985 * that allow retries.
3987 ZFCP_LOG_DEBUG("Setting DID_SOFT_ERROR and SUGGEST_RETRY\n");
3988 set_host_byte(&scpnt
->result
, DID_SOFT_ERROR
);
3989 set_driver_byte(&scpnt
->result
, SUGGEST_RETRY
);
3990 goto skip_fsfstatus
;
3993 if (unlikely(fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
)) {
3994 ZFCP_LOG_DEBUG("Setting DID_ERROR\n");
3995 set_host_byte(&scpnt
->result
, DID_ERROR
);
3996 goto skip_fsfstatus
;
3999 /* set message byte of result in SCSI command */
4000 scpnt
->result
|= COMMAND_COMPLETE
<< 8;
4003 * copy SCSI status code of FCP_STATUS of FCP_RSP IU to status byte
4004 * of result in SCSI command
4006 scpnt
->result
|= fcp_rsp_iu
->scsi_status
;
4007 if (unlikely(fcp_rsp_iu
->scsi_status
)) {
4009 ZFCP_LOG_DEBUG("status for SCSI Command:\n");
4010 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
4011 scpnt
->cmnd
, scpnt
->cmd_len
);
4012 ZFCP_LOG_DEBUG("SCSI status code 0x%x\n",
4013 fcp_rsp_iu
->scsi_status
);
4014 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
4015 (void *) fcp_rsp_iu
, sizeof (struct fcp_rsp_iu
));
4016 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
4017 zfcp_get_fcp_sns_info_ptr(fcp_rsp_iu
),
4018 fcp_rsp_iu
->fcp_sns_len
);
4021 /* check FCP_RSP_INFO */
4022 if (unlikely(fcp_rsp_iu
->validity
.bits
.fcp_rsp_len_valid
)) {
4023 ZFCP_LOG_DEBUG("rsp_len is valid\n");
4024 switch (fcp_rsp_info
[3]) {
4027 ZFCP_LOG_TRACE("no failure or Task Management "
4028 "Function complete\n");
4029 set_host_byte(&scpnt
->result
, DID_OK
);
4031 case RSP_CODE_LENGTH_MISMATCH
:
4033 ZFCP_LOG_NORMAL("bug: FCP response code indictates "
4034 "that the fibrechannel protocol data "
4035 "length differs from the burst length. "
4036 "The problem occured on unit 0x%016Lx "
4037 "on port 0x%016Lx on adapter %s",
4040 zfcp_get_busid_by_unit(unit
));
4041 /* dump SCSI CDB as prepared by zfcp */
4042 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
4043 (char *) &fsf_req
->qtcb
->
4044 bottom
.io
.fcp_cmnd
, FSF_FCP_CMND_SIZE
);
4045 zfcp_cmd_dbf_event_fsf("clenmis", fsf_req
, NULL
, 0);
4046 set_host_byte(&scpnt
->result
, DID_ERROR
);
4047 goto skip_fsfstatus
;
4048 case RSP_CODE_FIELD_INVALID
:
4049 /* driver or hardware bug */
4050 ZFCP_LOG_NORMAL("bug: FCP response code indictates "
4051 "that the fibrechannel protocol data "
4052 "fields were incorrectly set up. "
4053 "The problem occured on the unit "
4054 "0x%016Lx on port 0x%016Lx on "
4058 zfcp_get_busid_by_unit(unit
));
4059 /* dump SCSI CDB as prepared by zfcp */
4060 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
4061 (char *) &fsf_req
->qtcb
->
4062 bottom
.io
.fcp_cmnd
, FSF_FCP_CMND_SIZE
);
4063 set_host_byte(&scpnt
->result
, DID_ERROR
);
4064 zfcp_cmd_dbf_event_fsf("codeinv", fsf_req
, NULL
, 0);
4065 goto skip_fsfstatus
;
4066 case RSP_CODE_RO_MISMATCH
:
4068 ZFCP_LOG_NORMAL("bug: The FCP response code indicates "
4069 "that conflicting values for the "
4070 "fibrechannel payload offset from the "
4071 "header were found. "
4072 "The problem occured on unit 0x%016Lx "
4073 "on port 0x%016Lx on adapter %s.\n",
4076 zfcp_get_busid_by_unit(unit
));
4077 /* dump SCSI CDB as prepared by zfcp */
4078 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
4079 (char *) &fsf_req
->qtcb
->
4080 bottom
.io
.fcp_cmnd
, FSF_FCP_CMND_SIZE
);
4081 zfcp_cmd_dbf_event_fsf("codemism", fsf_req
, NULL
, 0);
4082 set_host_byte(&scpnt
->result
, DID_ERROR
);
4083 goto skip_fsfstatus
;
4085 ZFCP_LOG_NORMAL("bug: An invalid FCP response "
4086 "code was detected for a command. "
4087 "The problem occured on the unit "
4088 "0x%016Lx on port 0x%016Lx on "
4089 "adapter %s (debug info 0x%x)\n",
4092 zfcp_get_busid_by_unit(unit
),
4094 /* dump SCSI CDB as prepared by zfcp */
4095 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
4096 (char *) &fsf_req
->qtcb
->
4097 bottom
.io
.fcp_cmnd
, FSF_FCP_CMND_SIZE
);
4098 zfcp_cmd_dbf_event_fsf("undeffcp", fsf_req
, NULL
, 0);
4099 set_host_byte(&scpnt
->result
, DID_ERROR
);
4100 goto skip_fsfstatus
;
4104 /* check for sense data */
4105 if (unlikely(fcp_rsp_iu
->validity
.bits
.fcp_sns_len_valid
)) {
4106 sns_len
= FSF_FCP_RSP_SIZE
-
4107 sizeof (struct fcp_rsp_iu
) + fcp_rsp_iu
->fcp_rsp_len
;
4108 ZFCP_LOG_TRACE("room for %i bytes sense data in QTCB\n",
4110 sns_len
= min(sns_len
, (u32
) SCSI_SENSE_BUFFERSIZE
);
4111 ZFCP_LOG_TRACE("room for %i bytes sense data in SCSI command\n",
4112 SCSI_SENSE_BUFFERSIZE
);
4113 sns_len
= min(sns_len
, fcp_rsp_iu
->fcp_sns_len
);
4114 ZFCP_LOG_TRACE("scpnt->result =0x%x, command was:\n",
4116 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_TRACE
,
4117 (void *) &scpnt
->cmnd
, scpnt
->cmd_len
);
4119 ZFCP_LOG_TRACE("%i bytes sense data provided by FCP\n",
4120 fcp_rsp_iu
->fcp_sns_len
);
4121 memcpy(&scpnt
->sense_buffer
,
4122 zfcp_get_fcp_sns_info_ptr(fcp_rsp_iu
), sns_len
);
4123 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_TRACE
,
4124 (void *) &scpnt
->sense_buffer
, sns_len
);
4127 /* check for overrun */
4128 if (unlikely(fcp_rsp_iu
->validity
.bits
.fcp_resid_over
)) {
4129 ZFCP_LOG_INFO("A data overrun was detected for a command. "
4130 "unit 0x%016Lx, port 0x%016Lx, adapter %s. "
4131 "The response data length is "
4132 "%d, the original length was %d.\n",
4135 zfcp_get_busid_by_unit(unit
),
4136 fcp_rsp_iu
->fcp_resid
,
4137 (int) zfcp_get_fcp_dl(fcp_cmnd_iu
));
4140 /* check for underrun */
4141 if (unlikely(fcp_rsp_iu
->validity
.bits
.fcp_resid_under
)) {
4142 ZFCP_LOG_INFO("A data underrun was detected for a command. "
4143 "unit 0x%016Lx, port 0x%016Lx, adapter %s. "
4144 "The response data length is "
4145 "%d, the original length was %d.\n",
4148 zfcp_get_busid_by_unit(unit
),
4149 fcp_rsp_iu
->fcp_resid
,
4150 (int) zfcp_get_fcp_dl(fcp_cmnd_iu
));
4152 scpnt
->resid
= fcp_rsp_iu
->fcp_resid
;
4153 if (scpnt
->request_bufflen
- scpnt
->resid
< scpnt
->underflow
)
4154 set_host_byte(&scpnt
->result
, DID_ERROR
);
4158 ZFCP_LOG_DEBUG("scpnt->result =0x%x\n", scpnt
->result
);
4160 zfcp_cmd_dbf_event_scsi("response", scpnt
);
4162 /* cleanup pointer (need this especially for abort) */
4163 scpnt
->host_scribble
= NULL
;
4167 * according to the outcome of a discussion on linux-scsi we
4168 * don't need to grab the io_request_lock here since we use
4171 /* always call back */
4173 (scpnt
->scsi_done
) (scpnt
);
4176 * We must hold this lock until scsi_done has been called.
4177 * Otherwise we may call scsi_done after abort regarding this
4178 * command has completed.
4179 * Note: scsi_done must not block!
4182 read_unlock_irqrestore(&fsf_req
->adapter
->abort_lock
, flags
);
4187 * function: zfcp_fsf_send_fcp_command_task_management_handler
4189 * purpose: evaluates FCP_RSP IU
4194 zfcp_fsf_send_fcp_command_task_management_handler(struct zfcp_fsf_req
*fsf_req
)
4197 struct fcp_rsp_iu
*fcp_rsp_iu
= (struct fcp_rsp_iu
*)
4198 &(fsf_req
->qtcb
->bottom
.io
.fcp_rsp
);
4199 char *fcp_rsp_info
= zfcp_get_fcp_rsp_info_ptr(fcp_rsp_iu
);
4200 struct zfcp_unit
*unit
=
4201 fsf_req
->data
.send_fcp_command_task_management
.unit
;
4203 del_timer(&fsf_req
->adapter
->scsi_er_timer
);
4204 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
) {
4205 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_TMFUNCFAILED
;
4206 goto skip_fsfstatus
;
4209 /* check FCP_RSP_INFO */
4210 switch (fcp_rsp_info
[3]) {
4213 ZFCP_LOG_DEBUG("no failure or Task Management "
4214 "Function complete\n");
4216 case RSP_CODE_TASKMAN_UNSUPP
:
4217 ZFCP_LOG_NORMAL("bug: A reuested task management function "
4218 "is not supported on the target device "
4219 "unit 0x%016Lx, port 0x%016Lx, adapter %s\n ",
4222 zfcp_get_busid_by_unit(unit
));
4223 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_TMFUNCNOTSUPP
;
4225 case RSP_CODE_TASKMAN_FAILED
:
4226 ZFCP_LOG_NORMAL("bug: A reuested task management function "
4227 "failed to complete successfully. "
4228 "unit 0x%016Lx, port 0x%016Lx, adapter %s.\n",
4231 zfcp_get_busid_by_unit(unit
));
4232 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_TMFUNCFAILED
;
4235 ZFCP_LOG_NORMAL("bug: An invalid FCP response "
4236 "code was detected for a command. "
4237 "unit 0x%016Lx, port 0x%016Lx, adapter %s "
4238 "(debug info 0x%x)\n",
4241 zfcp_get_busid_by_unit(unit
),
4243 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_TMFUNCFAILED
;
4252 * function: zfcp_fsf_control_file
4254 * purpose: Initiator of the control file upload/download FSF requests
4256 * returns: 0 - FSF request is successfuly created and queued
4257 * -EOPNOTSUPP - The FCP adapter does not have Control File support
4258 * -EINVAL - Invalid direction specified
4259 * -ENOMEM - Insufficient memory
4260 * -EPERM - Cannot create FSF request or place it in QDIO queue
4263 zfcp_fsf_control_file(struct zfcp_adapter
*adapter
,
4264 struct zfcp_fsf_req
**fsf_req_ptr
,
4267 struct zfcp_sg_list
*sg_list
)
4269 struct zfcp_fsf_req
*fsf_req
;
4270 struct fsf_qtcb_bottom_support
*bottom
;
4271 volatile struct qdio_buffer_element
*sbale
;
4272 struct timer_list
*timer
;
4273 unsigned long lock_flags
;
4278 if (!(adapter
->supported_features
& FSF_FEATURE_CFDC
)) {
4279 ZFCP_LOG_INFO("cfdc not supported (adapter %s)\n",
4280 zfcp_get_busid_by_adapter(adapter
));
4281 retval
= -EOPNOTSUPP
;
4285 switch (fsf_command
) {
4287 case FSF_QTCB_DOWNLOAD_CONTROL_FILE
:
4288 direction
= SBAL_FLAGS0_TYPE_WRITE
;
4289 if ((option
!= FSF_CFDC_OPTION_FULL_ACCESS
) &&
4290 (option
!= FSF_CFDC_OPTION_RESTRICTED_ACCESS
))
4291 req_flags
= ZFCP_WAIT_FOR_SBAL
;
4294 case FSF_QTCB_UPLOAD_CONTROL_FILE
:
4295 direction
= SBAL_FLAGS0_TYPE_READ
;
4299 ZFCP_LOG_INFO("Invalid FSF command code 0x%08x\n", fsf_command
);
4304 timer
= kmalloc(sizeof(struct timer_list
), GFP_KERNEL
);
4310 retval
= zfcp_fsf_req_create(adapter
, fsf_command
, req_flags
,
4311 NULL
, &lock_flags
, &fsf_req
);
4313 ZFCP_LOG_INFO("error: Could not create FSF request for the "
4315 zfcp_get_busid_by_adapter(adapter
));
4317 goto unlock_queue_lock
;
4320 sbale
= zfcp_qdio_sbale_req(fsf_req
, fsf_req
->sbal_curr
, 0);
4321 sbale
[0].flags
|= direction
;
4323 bottom
= &fsf_req
->qtcb
->bottom
.support
;
4324 bottom
->operation_subtype
= FSF_CFDC_OPERATION_SUBTYPE
;
4325 bottom
->option
= option
;
4327 if (sg_list
->count
> 0) {
4330 bytes
= zfcp_qdio_sbals_from_sg(fsf_req
, direction
,
4331 sg_list
->sg
, sg_list
->count
,
4332 ZFCP_MAX_SBALS_PER_REQ
);
4333 if (bytes
!= ZFCP_CFDC_MAX_CONTROL_FILE_SIZE
) {
4335 "error: Could not create sufficient number of "
4336 "SBALS for an FSF request to the adapter %s\n",
4337 zfcp_get_busid_by_adapter(adapter
));
4342 sbale
[1].flags
|= SBAL_FLAGS_LAST_ENTRY
;
4345 timer
->function
= zfcp_fsf_request_timeout_handler
;
4346 timer
->data
= (unsigned long) adapter
;
4347 timer
->expires
= ZFCP_FSF_REQUEST_TIMEOUT
;
4349 retval
= zfcp_fsf_req_send(fsf_req
, timer
);
4351 ZFCP_LOG_INFO("initiation of cfdc up/download failed"
4353 zfcp_get_busid_by_adapter(adapter
));
4357 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
, lock_flags
);
4359 ZFCP_LOG_NORMAL("Control file %s FSF request has been sent to the "
4361 fsf_command
== FSF_QTCB_DOWNLOAD_CONTROL_FILE
?
4362 "download" : "upload",
4363 zfcp_get_busid_by_adapter(adapter
));
4365 wait_event(fsf_req
->completion_wq
,
4366 fsf_req
->status
& ZFCP_STATUS_FSFREQ_COMPLETED
);
4368 *fsf_req_ptr
= fsf_req
;
4369 del_timer_sync(timer
);
4373 zfcp_fsf_req_free(fsf_req
);
4375 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
, lock_flags
);
4384 * function: zfcp_fsf_control_file_handler
4386 * purpose: Handler of the control file upload/download FSF requests
4388 * returns: 0 - FSF request successfuly processed
4389 * -EAGAIN - Operation has to be repeated because of a temporary problem
4390 * -EACCES - There is no permission to execute an operation
4391 * -EPERM - The control file is not in a right format
4392 * -EIO - There is a problem with the FCP adapter
4393 * -EINVAL - Invalid operation
4394 * -EFAULT - User space memory I/O operation fault
4397 zfcp_fsf_control_file_handler(struct zfcp_fsf_req
*fsf_req
)
4399 struct zfcp_adapter
*adapter
= fsf_req
->adapter
;
4400 struct fsf_qtcb_header
*header
= &fsf_req
->qtcb
->header
;
4401 struct fsf_qtcb_bottom_support
*bottom
= &fsf_req
->qtcb
->bottom
.support
;
4404 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
) {
4406 goto skip_fsfstatus
;
4409 switch (header
->fsf_status
) {
4413 "The FSF request has been successfully completed "
4414 "on the adapter %s\n",
4415 zfcp_get_busid_by_adapter(adapter
));
4418 case FSF_OPERATION_PARTIALLY_SUCCESSFUL
:
4419 if (bottom
->operation_subtype
== FSF_CFDC_OPERATION_SUBTYPE
) {
4420 switch (header
->fsf_status_qual
.word
[0]) {
4422 case FSF_SQ_CFDC_HARDENED_ON_SE
:
4424 "CFDC on the adapter %s has being "
4425 "hardened on primary and secondary SE\n",
4426 zfcp_get_busid_by_adapter(adapter
));
4429 case FSF_SQ_CFDC_COULD_NOT_HARDEN_ON_SE
:
4431 "CFDC of the adapter %s could not "
4432 "be saved on the SE\n",
4433 zfcp_get_busid_by_adapter(adapter
));
4436 case FSF_SQ_CFDC_COULD_NOT_HARDEN_ON_SE2
:
4438 "CFDC of the adapter %s could not "
4439 "be copied to the secondary SE\n",
4440 zfcp_get_busid_by_adapter(adapter
));
4445 "CFDC could not be hardened "
4446 "on the adapter %s\n",
4447 zfcp_get_busid_by_adapter(adapter
));
4450 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4454 case FSF_AUTHORIZATION_FAILURE
:
4456 "Adapter %s does not accept privileged commands\n",
4457 zfcp_get_busid_by_adapter(adapter
));
4458 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4462 case FSF_CFDC_ERROR_DETECTED
:
4464 "Error at position %d in the CFDC, "
4465 "CFDC is discarded by the adapter %s\n",
4466 header
->fsf_status_qual
.word
[0],
4467 zfcp_get_busid_by_adapter(adapter
));
4468 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4472 case FSF_CONTROL_FILE_UPDATE_ERROR
:
4474 "Adapter %s cannot harden the control file, "
4475 "file is discarded\n",
4476 zfcp_get_busid_by_adapter(adapter
));
4477 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4481 case FSF_CONTROL_FILE_TOO_LARGE
:
4483 "Control file is too large, file is discarded "
4484 "by the adapter %s\n",
4485 zfcp_get_busid_by_adapter(adapter
));
4486 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4490 case FSF_ACCESS_CONFLICT_DETECTED
:
4491 if (bottom
->operation_subtype
== FSF_CFDC_OPERATION_SUBTYPE
)
4493 "CFDC has been discarded by the adapter %s, "
4494 "because activation would impact "
4495 "%d active connection(s)\n",
4496 zfcp_get_busid_by_adapter(adapter
),
4497 header
->fsf_status_qual
.word
[0]);
4498 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4502 case FSF_CONFLICTS_OVERRULED
:
4503 if (bottom
->operation_subtype
== FSF_CFDC_OPERATION_SUBTYPE
)
4505 "CFDC has been activated on the adapter %s, "
4506 "but activation has impacted "
4507 "%d active connection(s)\n",
4508 zfcp_get_busid_by_adapter(adapter
),
4509 header
->fsf_status_qual
.word
[0]);
4510 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4514 case FSF_UNKNOWN_OP_SUBTYPE
:
4515 ZFCP_LOG_NORMAL("unknown operation subtype (adapter: %s, "
4516 "op_subtype=0x%x)\n",
4517 zfcp_get_busid_by_adapter(adapter
),
4518 bottom
->operation_subtype
);
4519 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4523 case FSF_INVALID_COMMAND_OPTION
:
4525 "Invalid option 0x%x has been specified "
4526 "in QTCB bottom sent to the adapter %s\n",
4528 zfcp_get_busid_by_adapter(adapter
));
4529 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4535 "bug: An unknown/unexpected FSF status 0x%08x "
4536 "was presented on the adapter %s\n",
4538 zfcp_get_busid_by_adapter(adapter
));
4539 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0, "fsf_sq_inval");
4540 debug_exception(fsf_req
->adapter
->erp_dbf
, 0,
4541 &header
->fsf_status_qual
.word
[0], sizeof(u32
));
4542 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4553 * function: zfcp_fsf_req_wait_and_cleanup
4557 * FIXME(design): signal seems to be <0 !!!
4558 * returns: 0 - request completed (*status is valid), cleanup succ.
4559 * <0 - request completed (*status is valid), cleanup failed
4560 * >0 - signal which interrupted waiting (*status invalid),
4561 * request not completed, no cleanup
4563 * *status is a copy of status of completed fsf_req
4566 zfcp_fsf_req_wait_and_cleanup(struct zfcp_fsf_req
*fsf_req
,
4567 int interruptible
, u32
* status
)
4572 if (interruptible
) {
4573 __wait_event_interruptible(fsf_req
->completion_wq
,
4575 ZFCP_STATUS_FSFREQ_COMPLETED
,
4578 ZFCP_LOG_DEBUG("Caught signal %i while waiting for the "
4579 "completion of the request at %p\n",
4585 __wait_event(fsf_req
->completion_wq
,
4586 fsf_req
->status
& ZFCP_STATUS_FSFREQ_COMPLETED
);
4589 *status
= fsf_req
->status
;
4591 /* cleanup request */
4592 zfcp_fsf_req_free(fsf_req
);
4598 zfcp_fsf_req_sbal_check(unsigned long *flags
,
4599 struct zfcp_qdio_queue
*queue
, int needed
)
4601 write_lock_irqsave(&queue
->queue_lock
, *flags
);
4602 if (likely(atomic_read(&queue
->free_count
) >= needed
))
4604 write_unlock_irqrestore(&queue
->queue_lock
, *flags
);
4609 * set qtcb pointer in fsf_req and initialize QTCB
4612 zfcp_fsf_req_qtcb_init(struct zfcp_fsf_req
*fsf_req
, u32 fsf_cmd
)
4614 if (likely(fsf_req
->qtcb
!= NULL
)) {
4615 fsf_req
->qtcb
->prefix
.req_id
= (unsigned long)fsf_req
;
4616 fsf_req
->qtcb
->prefix
.ulp_info
= ZFCP_ULP_INFO_VERSION
;
4617 fsf_req
->qtcb
->prefix
.qtcb_type
= fsf_qtcb_type
[fsf_cmd
];
4618 fsf_req
->qtcb
->prefix
.qtcb_version
= ZFCP_QTCB_VERSION
;
4619 fsf_req
->qtcb
->header
.req_handle
= (unsigned long)fsf_req
;
4620 fsf_req
->qtcb
->header
.fsf_command
= fsf_cmd
;
4625 * zfcp_fsf_req_sbal_get - try to get one SBAL in the request queue
4626 * @adapter: adapter for which request queue is examined
4627 * @req_flags: flags indicating whether to wait for needed SBAL or not
4628 * @lock_flags: lock_flags if queue_lock is taken
4629 * Return: 0 on success, otherwise -EIO, or -ERESTARTSYS
4630 * Locks: lock adapter->request_queue->queue_lock on success
4633 zfcp_fsf_req_sbal_get(struct zfcp_adapter
*adapter
, int req_flags
,
4634 unsigned long *lock_flags
)
4637 struct zfcp_qdio_queue
*req_queue
= &adapter
->request_queue
;
4639 if (unlikely(req_flags
& ZFCP_WAIT_FOR_SBAL
)) {
4640 ret
= wait_event_interruptible_timeout(adapter
->request_wq
,
4641 zfcp_fsf_req_sbal_check(lock_flags
, req_queue
, 1),
4647 } else if (!zfcp_fsf_req_sbal_check(lock_flags
, req_queue
, 1))
4654 * function: zfcp_fsf_req_create
4656 * purpose: create an FSF request at the specified adapter and
4657 * setup common fields
4659 * returns: -ENOMEM if there was insufficient memory for a request
4660 * -EIO if no qdio buffers could be allocate to the request
4661 * -EINVAL/-EPERM on bug conditions in req_dequeue
4664 * note: The created request is returned by reference.
4666 * locks: lock of concerned request queue must not be held,
4667 * but is held on completion (write, irqsave)
4670 zfcp_fsf_req_create(struct zfcp_adapter
*adapter
, u32 fsf_cmd
, int req_flags
,
4671 mempool_t
*pool
, unsigned long *lock_flags
,
4672 struct zfcp_fsf_req
**fsf_req_p
)
4674 volatile struct qdio_buffer_element
*sbale
;
4675 struct zfcp_fsf_req
*fsf_req
= NULL
;
4677 struct zfcp_qdio_queue
*req_queue
= &adapter
->request_queue
;
4679 /* allocate new FSF request */
4680 fsf_req
= zfcp_fsf_req_alloc(pool
, req_flags
);
4681 if (unlikely(NULL
== fsf_req
)) {
4682 ZFCP_LOG_DEBUG("error: Could not put an FSF request into"
4683 "the outbound (send) queue.\n");
4685 goto failed_fsf_req
;
4688 zfcp_fsf_req_qtcb_init(fsf_req
, fsf_cmd
);
4690 /* initialize waitqueue which may be used to wait on
4691 this request completion */
4692 init_waitqueue_head(&fsf_req
->completion_wq
);
4694 ret
= zfcp_fsf_req_sbal_get(adapter
, req_flags
, lock_flags
);
4700 * We hold queue_lock here. Check if QDIOUP is set and let request fail
4701 * if it is not set (see also *_open_qdio and *_close_qdio).
4704 if (!atomic_test_mask(ZFCP_STATUS_ADAPTER_QDIOUP
, &adapter
->status
)) {
4705 write_unlock_irqrestore(&req_queue
->queue_lock
, *lock_flags
);
4710 fsf_req
->adapter
= adapter
; /* pointer to "parent" adapter */
4711 fsf_req
->fsf_command
= fsf_cmd
;
4712 fsf_req
->sbal_number
= 1;
4713 fsf_req
->sbal_first
= req_queue
->free_index
;
4714 fsf_req
->sbal_curr
= req_queue
->free_index
;
4715 fsf_req
->sbale_curr
= 1;
4717 if (likely(req_flags
& ZFCP_REQ_AUTO_CLEANUP
)) {
4718 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_CLEANUP
;
4721 sbale
= zfcp_qdio_sbale_req(fsf_req
, fsf_req
->sbal_curr
, 0);
4723 /* setup common SBALE fields */
4724 sbale
[0].addr
= fsf_req
;
4725 sbale
[0].flags
|= SBAL_FLAGS0_COMMAND
;
4726 if (likely(fsf_req
->qtcb
!= NULL
)) {
4727 sbale
[1].addr
= (void *) fsf_req
->qtcb
;
4728 sbale
[1].length
= sizeof(struct fsf_qtcb
);
4731 ZFCP_LOG_TRACE("got %i free BUFFERs starting at index %i\n",
4732 fsf_req
->sbal_number
, fsf_req
->sbal_first
);
4737 /* dequeue new FSF request previously enqueued */
4738 zfcp_fsf_req_free(fsf_req
);
4742 write_lock_irqsave(&req_queue
->queue_lock
, *lock_flags
);
4744 *fsf_req_p
= fsf_req
;
4749 * function: zfcp_fsf_req_send
4751 * purpose: start transfer of FSF request via QDIO
4753 * returns: 0 - request transfer succesfully started
4754 * !0 - start of request transfer failed
4757 zfcp_fsf_req_send(struct zfcp_fsf_req
*fsf_req
, struct timer_list
*timer
)
4759 struct zfcp_adapter
*adapter
;
4760 struct zfcp_qdio_queue
*req_queue
;
4761 volatile struct qdio_buffer_element
*sbale
;
4762 int new_distance_from_int
;
4763 unsigned long flags
;
4767 adapter
= fsf_req
->adapter
;
4768 req_queue
= &adapter
->request_queue
,
4771 /* FIXME(debug): remove it later */
4772 sbale
= zfcp_qdio_sbale_req(fsf_req
, fsf_req
->sbal_first
, 0);
4773 ZFCP_LOG_DEBUG("SBALE0 flags=0x%x\n", sbale
[0].flags
);
4774 ZFCP_LOG_TRACE("HEX DUMP OF SBALE1 PAYLOAD:\n");
4775 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_TRACE
, (char *) sbale
[1].addr
,
4778 /* set sequence counter in QTCB */
4779 if (likely(fsf_req
->qtcb
)) {
4780 fsf_req
->qtcb
->prefix
.req_seq_no
= adapter
->fsf_req_seq_no
;
4781 fsf_req
->seq_no
= adapter
->fsf_req_seq_no
;
4782 ZFCP_LOG_TRACE("FSF request %p of adapter %s gets "
4783 "FSF sequence counter value of %i\n",
4785 zfcp_get_busid_by_adapter(adapter
),
4786 fsf_req
->qtcb
->prefix
.req_seq_no
);
4790 /* put allocated FSF request at list tail */
4791 spin_lock_irqsave(&adapter
->fsf_req_list_lock
, flags
);
4792 list_add_tail(&fsf_req
->list
, &adapter
->fsf_req_list_head
);
4793 spin_unlock_irqrestore(&adapter
->fsf_req_list_lock
, flags
);
4795 /* figure out expiration time of timeout and start timeout */
4796 if (unlikely(timer
)) {
4797 timer
->expires
+= jiffies
;
4801 ZFCP_LOG_TRACE("request queue of adapter %s: "
4802 "next free SBAL is %i, %i free SBALs\n",
4803 zfcp_get_busid_by_adapter(adapter
),
4804 req_queue
->free_index
,
4805 atomic_read(&req_queue
->free_count
));
4807 ZFCP_LOG_DEBUG("calling do_QDIO adapter %s, flags=0x%x, queue_no=%i, "
4808 "index_in_queue=%i, count=%i, buffers=%p\n",
4809 zfcp_get_busid_by_adapter(adapter
),
4810 QDIO_FLAG_SYNC_OUTPUT
,
4811 0, fsf_req
->sbal_first
, fsf_req
->sbal_number
,
4812 &req_queue
->buffer
[fsf_req
->sbal_first
]);
4815 * adjust the number of free SBALs in request queue as well as
4816 * position of first one
4818 atomic_sub(fsf_req
->sbal_number
, &req_queue
->free_count
);
4819 ZFCP_LOG_TRACE("free_count=%d\n", atomic_read(&req_queue
->free_count
));
4820 req_queue
->free_index
+= fsf_req
->sbal_number
; /* increase */
4821 req_queue
->free_index
%= QDIO_MAX_BUFFERS_PER_Q
; /* wrap if needed */
4822 new_distance_from_int
= zfcp_qdio_determine_pci(req_queue
, fsf_req
);
4824 retval
= do_QDIO(adapter
->ccw_device
,
4825 QDIO_FLAG_SYNC_OUTPUT
,
4826 0, fsf_req
->sbal_first
, fsf_req
->sbal_number
, NULL
);
4828 if (unlikely(retval
)) {
4829 /* Queues are down..... */
4832 * FIXME(potential race):
4833 * timer might be expired (absolutely unlikely)
4837 spin_lock_irqsave(&adapter
->fsf_req_list_lock
, flags
);
4838 list_del(&fsf_req
->list
);
4839 spin_unlock_irqrestore(&adapter
->fsf_req_list_lock
, flags
);
4841 * adjust the number of free SBALs in request queue as well as
4842 * position of first one
4844 zfcp_qdio_zero_sbals(req_queue
->buffer
,
4845 fsf_req
->sbal_first
, fsf_req
->sbal_number
);
4846 atomic_add(fsf_req
->sbal_number
, &req_queue
->free_count
);
4847 req_queue
->free_index
-= fsf_req
->sbal_number
; /* increase */
4848 req_queue
->free_index
+= QDIO_MAX_BUFFERS_PER_Q
;
4849 req_queue
->free_index
%= QDIO_MAX_BUFFERS_PER_Q
; /* wrap */
4851 ("error: do_QDIO failed. Buffers could not be enqueued "
4852 "to request queue.\n");
4854 req_queue
->distance_from_int
= new_distance_from_int
;
4856 * increase FSF sequence counter -
4857 * this must only be done for request successfully enqueued to
4858 * QDIO this rejected requests may be cleaned up by calling
4859 * routines resulting in missing sequence counter values
4862 /* Don't increase for unsolicited status */
4863 if (likely(inc_seq_no
)) {
4864 adapter
->fsf_req_seq_no
++;
4866 ("FSF sequence counter value of adapter %s "
4867 "increased to %i\n",
4868 zfcp_get_busid_by_adapter(adapter
),
4869 adapter
->fsf_req_seq_no
);
4871 /* count FSF requests pending */
4872 atomic_inc(&adapter
->fsf_reqs_active
);
4877 #undef ZFCP_LOG_AREA