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 void zfcp_fsf_link_down_info_eval(struct zfcp_adapter
*,
63 struct fsf_link_down_info
*);
64 static int zfcp_fsf_req_dispatch(struct zfcp_fsf_req
*);
65 static void zfcp_fsf_req_dismiss(struct zfcp_fsf_req
*);
67 /* association between FSF command and FSF QTCB type */
68 static u32 fsf_qtcb_type
[] = {
69 [FSF_QTCB_FCP_CMND
] = FSF_IO_COMMAND
,
70 [FSF_QTCB_ABORT_FCP_CMND
] = FSF_SUPPORT_COMMAND
,
71 [FSF_QTCB_OPEN_PORT_WITH_DID
] = FSF_SUPPORT_COMMAND
,
72 [FSF_QTCB_OPEN_LUN
] = FSF_SUPPORT_COMMAND
,
73 [FSF_QTCB_CLOSE_LUN
] = FSF_SUPPORT_COMMAND
,
74 [FSF_QTCB_CLOSE_PORT
] = FSF_SUPPORT_COMMAND
,
75 [FSF_QTCB_CLOSE_PHYSICAL_PORT
] = FSF_SUPPORT_COMMAND
,
76 [FSF_QTCB_SEND_ELS
] = FSF_SUPPORT_COMMAND
,
77 [FSF_QTCB_SEND_GENERIC
] = FSF_SUPPORT_COMMAND
,
78 [FSF_QTCB_EXCHANGE_CONFIG_DATA
] = FSF_CONFIG_COMMAND
,
79 [FSF_QTCB_EXCHANGE_PORT_DATA
] = FSF_PORT_COMMAND
,
80 [FSF_QTCB_DOWNLOAD_CONTROL_FILE
] = FSF_SUPPORT_COMMAND
,
81 [FSF_QTCB_UPLOAD_CONTROL_FILE
] = FSF_SUPPORT_COMMAND
84 static const char zfcp_act_subtable_type
[5][8] = {
85 "unknown", "OS", "WWPN", "DID", "LUN"
88 /****************************************************************/
89 /*************** FSF related Functions *************************/
90 /****************************************************************/
92 #define ZFCP_LOG_AREA ZFCP_LOG_AREA_FSF
95 * function: zfcp_fsf_req_alloc
97 * purpose: Obtains an fsf_req and potentially a qtcb (for all but
98 * unsolicited requests) via helper functions
99 * Does some initial fsf request set-up.
101 * returns: pointer to allocated fsf_req if successfull
107 static struct zfcp_fsf_req
*
108 zfcp_fsf_req_alloc(mempool_t
*pool
, int req_flags
)
112 struct zfcp_fsf_req
*fsf_req
= NULL
;
114 if (req_flags
& ZFCP_REQ_NO_QTCB
)
115 size
= sizeof(struct zfcp_fsf_req
);
117 size
= sizeof(struct zfcp_fsf_req_pool_element
);
119 if (likely(pool
!= NULL
))
120 ptr
= mempool_alloc(pool
, GFP_ATOMIC
);
122 ptr
= kmalloc(size
, GFP_ATOMIC
);
124 if (unlikely(NULL
== ptr
))
127 memset(ptr
, 0, size
);
129 if (req_flags
& ZFCP_REQ_NO_QTCB
) {
130 fsf_req
= (struct zfcp_fsf_req
*) ptr
;
132 fsf_req
= &((struct zfcp_fsf_req_pool_element
*) ptr
)->fsf_req
;
134 &((struct zfcp_fsf_req_pool_element
*) ptr
)->qtcb
;
137 fsf_req
->pool
= pool
;
144 * function: zfcp_fsf_req_free
146 * purpose: Frees the memory of an fsf_req (and potentially a qtcb) or
147 * returns it into the pool via helper functions.
154 zfcp_fsf_req_free(struct zfcp_fsf_req
*fsf_req
)
156 if (likely(fsf_req
->pool
!= NULL
))
157 mempool_free(fsf_req
, fsf_req
->pool
);
169 * note: qdio queues shall be down (no ongoing inbound processing)
172 zfcp_fsf_req_dismiss_all(struct zfcp_adapter
*adapter
)
174 struct zfcp_fsf_req
*fsf_req
, *tmp
;
176 LIST_HEAD(remove_queue
);
178 spin_lock_irqsave(&adapter
->fsf_req_list_lock
, flags
);
179 list_splice_init(&adapter
->fsf_req_list_head
, &remove_queue
);
180 atomic_set(&adapter
->fsf_reqs_active
, 0);
181 spin_unlock_irqrestore(&adapter
->fsf_req_list_lock
, flags
);
183 list_for_each_entry_safe(fsf_req
, tmp
, &remove_queue
, list
) {
184 list_del(&fsf_req
->list
);
185 zfcp_fsf_req_dismiss(fsf_req
);
199 zfcp_fsf_req_dismiss(struct zfcp_fsf_req
*fsf_req
)
201 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_DISMISSED
;
202 zfcp_fsf_req_complete(fsf_req
);
206 * function: zfcp_fsf_req_complete
208 * purpose: Updates active counts and timers for openfcp-reqs
209 * May cleanup request after req_eval returns
211 * returns: 0 - success
217 zfcp_fsf_req_complete(struct zfcp_fsf_req
*fsf_req
)
222 if (unlikely(fsf_req
->fsf_command
== FSF_QTCB_UNSOLICITED_STATUS
)) {
223 ZFCP_LOG_DEBUG("Status read response received\n");
225 * Note: all cleanup handling is done in the callchain of
226 * the function call-chain below.
228 zfcp_fsf_status_read_handler(fsf_req
);
231 zfcp_fsf_protstatus_eval(fsf_req
);
234 * fsf_req may be deleted due to waking up functions, so
235 * cleanup is saved here and used later
237 if (likely(fsf_req
->status
& ZFCP_STATUS_FSFREQ_CLEANUP
))
242 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_COMPLETED
;
244 /* cleanup request if requested by initiator */
245 if (likely(cleanup
)) {
246 ZFCP_LOG_TRACE("removing FSF request %p\n", fsf_req
);
248 * lock must not be held here since it will be
249 * grabed by the called routine, too
251 zfcp_fsf_req_free(fsf_req
);
253 /* notify initiator waiting for the requests completion */
254 ZFCP_LOG_TRACE("waking initiator of FSF request %p\n",fsf_req
);
256 * FIXME: Race! We must not access fsf_req here as it might have been
257 * cleaned up already due to the set ZFCP_STATUS_FSFREQ_COMPLETED
258 * flag. It's an improbable case. But, we have the same paranoia for
259 * the cleanup flag already.
260 * Might better be handled using complete()?
261 * (setting the flag and doing wakeup ought to be atomic
262 * with regard to checking the flag as long as waitqueue is
263 * part of the to be released structure)
265 wake_up(&fsf_req
->completion_wq
);
273 * function: zfcp_fsf_protstatus_eval
275 * purpose: evaluates the QTCB of the finished FSF request
276 * and initiates appropriate actions
277 * (usually calling FSF command specific handlers)
286 zfcp_fsf_protstatus_eval(struct zfcp_fsf_req
*fsf_req
)
289 struct zfcp_adapter
*adapter
= fsf_req
->adapter
;
290 struct fsf_qtcb
*qtcb
= fsf_req
->qtcb
;
291 union fsf_prot_status_qual
*prot_status_qual
=
292 &qtcb
->prefix
.prot_status_qual
;
294 zfcp_hba_dbf_event_fsf_response(fsf_req
);
296 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_DISMISSED
) {
297 ZFCP_LOG_DEBUG("fsf_req 0x%lx has been dismissed\n",
298 (unsigned long) fsf_req
);
299 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
|
300 ZFCP_STATUS_FSFREQ_RETRY
; /* only for SCSI cmnds. */
301 goto skip_protstatus
;
304 /* log additional information provided by FSF (if any) */
305 if (unlikely(qtcb
->header
.log_length
)) {
306 /* do not trust them ;-) */
307 if (qtcb
->header
.log_start
> sizeof(struct fsf_qtcb
)) {
309 ("bug: ULP (FSF logging) log data starts "
310 "beyond end of packet header. Ignored. "
311 "(start=%i, size=%li)\n",
312 qtcb
->header
.log_start
,
313 sizeof(struct fsf_qtcb
));
316 if ((size_t) (qtcb
->header
.log_start
+ qtcb
->header
.log_length
)
317 > sizeof(struct fsf_qtcb
)) {
318 ZFCP_LOG_NORMAL("bug: ULP (FSF logging) log data ends "
319 "beyond end of packet header. Ignored. "
320 "(start=%i, length=%i, size=%li)\n",
321 qtcb
->header
.log_start
,
322 qtcb
->header
.log_length
,
323 sizeof(struct fsf_qtcb
));
326 ZFCP_LOG_TRACE("ULP log data: \n");
327 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_TRACE
,
328 (char *) qtcb
+ qtcb
->header
.log_start
,
329 qtcb
->header
.log_length
);
333 /* evaluate FSF Protocol Status */
334 switch (qtcb
->prefix
.prot_status
) {
337 case FSF_PROT_FSF_STATUS_PRESENTED
:
340 case FSF_PROT_QTCB_VERSION_ERROR
:
341 ZFCP_LOG_NORMAL("error: The adapter %s contains "
342 "microcode of version 0x%x, the device driver "
343 "only supports 0x%x. Aborting.\n",
344 zfcp_get_busid_by_adapter(adapter
),
345 prot_status_qual
->version_error
.fsf_version
,
347 zfcp_erp_adapter_shutdown(adapter
, 0);
348 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
351 case FSF_PROT_SEQ_NUMB_ERROR
:
352 ZFCP_LOG_NORMAL("bug: Sequence number mismatch between "
353 "driver (0x%x) and adapter %s (0x%x). "
354 "Restarting all operations on this adapter.\n",
355 qtcb
->prefix
.req_seq_no
,
356 zfcp_get_busid_by_adapter(adapter
),
357 prot_status_qual
->sequence_error
.exp_req_seq_no
);
358 zfcp_erp_adapter_reopen(adapter
, 0);
359 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_RETRY
;
360 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
363 case FSF_PROT_UNSUPP_QTCB_TYPE
:
364 ZFCP_LOG_NORMAL("error: Packet header type used by the "
365 "device driver is incompatible with "
366 "that used on adapter %s. "
367 "Stopping all operations on this adapter.\n",
368 zfcp_get_busid_by_adapter(adapter
));
369 zfcp_erp_adapter_shutdown(adapter
, 0);
370 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
373 case FSF_PROT_HOST_CONNECTION_INITIALIZING
:
374 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
375 atomic_set_mask(ZFCP_STATUS_ADAPTER_HOST_CON_INIT
,
379 case FSF_PROT_DUPLICATE_REQUEST_ID
:
380 ZFCP_LOG_NORMAL("bug: The request identifier 0x%Lx "
381 "to the adapter %s is ambiguous. "
382 "Stopping all operations on this adapter.\n",
383 *(unsigned long long*)
384 (&qtcb
->bottom
.support
.req_handle
),
385 zfcp_get_busid_by_adapter(adapter
));
386 zfcp_erp_adapter_shutdown(adapter
, 0);
387 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
390 case FSF_PROT_LINK_DOWN
:
391 zfcp_fsf_link_down_info_eval(adapter
,
392 &prot_status_qual
->link_down_info
);
393 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
396 case FSF_PROT_REEST_QUEUE
:
397 ZFCP_LOG_NORMAL("The local link to adapter with "
398 "%s was re-plugged. "
399 "Re-starting operations on this adapter.\n",
400 zfcp_get_busid_by_adapter(adapter
));
401 /* All ports should be marked as ready to run again */
402 zfcp_erp_modify_adapter_status(adapter
,
403 ZFCP_STATUS_COMMON_RUNNING
,
405 zfcp_erp_adapter_reopen(adapter
,
406 ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED
407 | ZFCP_STATUS_COMMON_ERP_FAILED
);
408 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
411 case FSF_PROT_ERROR_STATE
:
412 ZFCP_LOG_NORMAL("error: The adapter %s "
413 "has entered the error state. "
414 "Restarting all operations on this "
416 zfcp_get_busid_by_adapter(adapter
));
417 zfcp_erp_adapter_reopen(adapter
, 0);
418 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_RETRY
;
419 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
423 ZFCP_LOG_NORMAL("bug: Transfer protocol status information "
424 "provided by the adapter %s "
425 "is not compatible with the device driver. "
426 "Stopping all operations on this adapter. "
427 "(debug info 0x%x).\n",
428 zfcp_get_busid_by_adapter(adapter
),
429 qtcb
->prefix
.prot_status
);
430 zfcp_erp_adapter_shutdown(adapter
, 0);
431 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
436 * always call specific handlers to give them a chance to do
437 * something meaningful even in error cases
439 zfcp_fsf_fsfstatus_eval(fsf_req
);
444 * function: zfcp_fsf_fsfstatus_eval
446 * purpose: evaluates FSF status of completed FSF request
447 * and acts accordingly
452 zfcp_fsf_fsfstatus_eval(struct zfcp_fsf_req
*fsf_req
)
456 if (unlikely(fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
)) {
460 /* evaluate FSF Status */
461 switch (fsf_req
->qtcb
->header
.fsf_status
) {
462 case FSF_UNKNOWN_COMMAND
:
463 ZFCP_LOG_NORMAL("bug: Command issued by the device driver is "
464 "not known by the adapter %s "
465 "Stopping all operations on this adapter. "
466 "(debug info 0x%x).\n",
467 zfcp_get_busid_by_adapter(fsf_req
->adapter
),
468 fsf_req
->qtcb
->header
.fsf_command
);
469 zfcp_erp_adapter_shutdown(fsf_req
->adapter
, 0);
470 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
473 case FSF_FCP_RSP_AVAILABLE
:
474 ZFCP_LOG_DEBUG("FCP Sense data will be presented to the "
478 case FSF_ADAPTER_STATUS_AVAILABLE
:
479 zfcp_fsf_fsfstatus_qual_eval(fsf_req
);
485 * always call specific handlers to give them a chance to do
486 * something meaningful even in error cases
488 zfcp_fsf_req_dispatch(fsf_req
);
494 * function: zfcp_fsf_fsfstatus_qual_eval
496 * purpose: evaluates FSF status-qualifier of completed FSF request
497 * and acts accordingly
502 zfcp_fsf_fsfstatus_qual_eval(struct zfcp_fsf_req
*fsf_req
)
506 switch (fsf_req
->qtcb
->header
.fsf_status_qual
.word
[0]) {
507 case FSF_SQ_FCP_RSP_AVAILABLE
:
509 case FSF_SQ_RETRY_IF_POSSIBLE
:
510 /* The SCSI-stack may now issue retries or escalate */
511 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
513 case FSF_SQ_COMMAND_ABORTED
:
514 /* Carry the aborted state on to upper layer */
515 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ABORTED
;
516 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
518 case FSF_SQ_NO_RECOM
:
519 ZFCP_LOG_NORMAL("bug: No recommendation could be given for a"
520 "problem on the adapter %s "
521 "Stopping all operations on this adapter. ",
522 zfcp_get_busid_by_adapter(fsf_req
->adapter
));
523 zfcp_erp_adapter_shutdown(fsf_req
->adapter
, 0);
524 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
526 case FSF_SQ_ULP_PROGRAMMING_ERROR
:
527 ZFCP_LOG_NORMAL("error: not enough SBALs for data transfer "
529 zfcp_get_busid_by_adapter(fsf_req
->adapter
));
530 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
532 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE
:
533 case FSF_SQ_NO_RETRY_POSSIBLE
:
534 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED
:
535 /* dealt with in the respective functions */
538 ZFCP_LOG_NORMAL("bug: Additional status info could "
539 "not be interpreted properly.\n");
540 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_NORMAL
,
541 (char *) &fsf_req
->qtcb
->header
.fsf_status_qual
,
542 sizeof (union fsf_status_qual
));
543 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
551 * zfcp_fsf_link_down_info_eval - evaluate link down information block
554 zfcp_fsf_link_down_info_eval(struct zfcp_adapter
*adapter
,
555 struct fsf_link_down_info
*link_down
)
557 if (atomic_test_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED
,
561 atomic_set_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED
, &adapter
->status
);
563 if (link_down
== NULL
) {
564 zfcp_erp_adapter_reopen(adapter
, 0);
568 switch (link_down
->error_code
) {
569 case FSF_PSQ_LINK_NO_LIGHT
:
570 ZFCP_LOG_NORMAL("The local link to adapter %s is down "
571 "(no light detected)\n",
572 zfcp_get_busid_by_adapter(adapter
));
574 case FSF_PSQ_LINK_WRAP_PLUG
:
575 ZFCP_LOG_NORMAL("The local link to adapter %s is down "
576 "(wrap plug detected)\n",
577 zfcp_get_busid_by_adapter(adapter
));
579 case FSF_PSQ_LINK_NO_FCP
:
580 ZFCP_LOG_NORMAL("The local link to adapter %s is down "
581 "(adjacent node on link does not support FCP)\n",
582 zfcp_get_busid_by_adapter(adapter
));
584 case FSF_PSQ_LINK_FIRMWARE_UPDATE
:
585 ZFCP_LOG_NORMAL("The local link to adapter %s is down "
586 "(firmware update in progress)\n",
587 zfcp_get_busid_by_adapter(adapter
));
589 case FSF_PSQ_LINK_INVALID_WWPN
:
590 ZFCP_LOG_NORMAL("The local link to adapter %s is down "
591 "(duplicate or invalid WWPN detected)\n",
592 zfcp_get_busid_by_adapter(adapter
));
594 case FSF_PSQ_LINK_NO_NPIV_SUPPORT
:
595 ZFCP_LOG_NORMAL("The local link to adapter %s is down "
596 "(no support for NPIV by Fabric)\n",
597 zfcp_get_busid_by_adapter(adapter
));
599 case FSF_PSQ_LINK_NO_FCP_RESOURCES
:
600 ZFCP_LOG_NORMAL("The local link to adapter %s is down "
601 "(out of resource in FCP daughtercard)\n",
602 zfcp_get_busid_by_adapter(adapter
));
604 case FSF_PSQ_LINK_NO_FABRIC_RESOURCES
:
605 ZFCP_LOG_NORMAL("The local link to adapter %s is down "
606 "(out of resource in Fabric)\n",
607 zfcp_get_busid_by_adapter(adapter
));
609 case FSF_PSQ_LINK_FABRIC_LOGIN_UNABLE
:
610 ZFCP_LOG_NORMAL("The local link to adapter %s is down "
611 "(unable to Fabric login)\n",
612 zfcp_get_busid_by_adapter(adapter
));
614 case FSF_PSQ_LINK_WWPN_ASSIGNMENT_CORRUPTED
:
615 ZFCP_LOG_NORMAL("WWPN assignment file corrupted on adapter %s\n",
616 zfcp_get_busid_by_adapter(adapter
));
618 case FSF_PSQ_LINK_MODE_TABLE_CURRUPTED
:
619 ZFCP_LOG_NORMAL("Mode table corrupted on adapter %s\n",
620 zfcp_get_busid_by_adapter(adapter
));
622 case FSF_PSQ_LINK_NO_WWPN_ASSIGNMENT
:
623 ZFCP_LOG_NORMAL("No WWPN for assignment table on adapter %s\n",
624 zfcp_get_busid_by_adapter(adapter
));
627 ZFCP_LOG_NORMAL("The local link to adapter %s is down "
628 "(warning: unknown reason code %d)\n",
629 zfcp_get_busid_by_adapter(adapter
),
630 link_down
->error_code
);
633 if (adapter
->connection_features
& FSF_FEATURE_NPIV_MODE
)
634 ZFCP_LOG_DEBUG("Debug information to link down: "
635 "primary_status=0x%02x "
637 "action_code=0x%02x "
638 "reason_code=0x%02x "
639 "explanation_code=0x%02x "
640 "vendor_specific_code=0x%02x\n",
641 link_down
->primary_status
,
642 link_down
->ioerr_code
,
643 link_down
->action_code
,
644 link_down
->reason_code
,
645 link_down
->explanation_code
,
646 link_down
->vendor_specific_code
);
648 switch (link_down
->error_code
) {
649 case FSF_PSQ_LINK_NO_LIGHT
:
650 case FSF_PSQ_LINK_WRAP_PLUG
:
651 case FSF_PSQ_LINK_NO_FCP
:
652 case FSF_PSQ_LINK_FIRMWARE_UPDATE
:
653 zfcp_erp_adapter_reopen(adapter
, 0);
656 zfcp_erp_adapter_failed(adapter
);
661 * function: zfcp_fsf_req_dispatch
663 * purpose: calls the appropriate command specific handler
668 zfcp_fsf_req_dispatch(struct zfcp_fsf_req
*fsf_req
)
670 struct zfcp_erp_action
*erp_action
= fsf_req
->erp_action
;
671 struct zfcp_adapter
*adapter
= fsf_req
->adapter
;
675 switch (fsf_req
->fsf_command
) {
677 case FSF_QTCB_FCP_CMND
:
678 zfcp_fsf_send_fcp_command_handler(fsf_req
);
681 case FSF_QTCB_ABORT_FCP_CMND
:
682 zfcp_fsf_abort_fcp_command_handler(fsf_req
);
685 case FSF_QTCB_SEND_GENERIC
:
686 zfcp_fsf_send_ct_handler(fsf_req
);
689 case FSF_QTCB_OPEN_PORT_WITH_DID
:
690 zfcp_fsf_open_port_handler(fsf_req
);
693 case FSF_QTCB_OPEN_LUN
:
694 zfcp_fsf_open_unit_handler(fsf_req
);
697 case FSF_QTCB_CLOSE_LUN
:
698 zfcp_fsf_close_unit_handler(fsf_req
);
701 case FSF_QTCB_CLOSE_PORT
:
702 zfcp_fsf_close_port_handler(fsf_req
);
705 case FSF_QTCB_CLOSE_PHYSICAL_PORT
:
706 zfcp_fsf_close_physical_port_handler(fsf_req
);
709 case FSF_QTCB_EXCHANGE_CONFIG_DATA
:
710 zfcp_fsf_exchange_config_data_handler(fsf_req
);
713 case FSF_QTCB_EXCHANGE_PORT_DATA
:
714 zfcp_fsf_exchange_port_data_handler(fsf_req
);
717 case FSF_QTCB_SEND_ELS
:
718 zfcp_fsf_send_els_handler(fsf_req
);
721 case FSF_QTCB_DOWNLOAD_CONTROL_FILE
:
722 zfcp_fsf_control_file_handler(fsf_req
);
725 case FSF_QTCB_UPLOAD_CONTROL_FILE
:
726 zfcp_fsf_control_file_handler(fsf_req
);
730 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
731 ZFCP_LOG_NORMAL("bug: Command issued by the device driver is "
732 "not supported by the adapter %s\n",
733 zfcp_get_busid_by_adapter(adapter
));
734 if (fsf_req
->fsf_command
!= fsf_req
->qtcb
->header
.fsf_command
)
736 ("bug: Command issued by the device driver differs "
737 "from the command returned by the adapter %s "
738 "(debug info 0x%x, 0x%x).\n",
739 zfcp_get_busid_by_adapter(adapter
),
740 fsf_req
->fsf_command
,
741 fsf_req
->qtcb
->header
.fsf_command
);
747 zfcp_erp_async_handler(erp_action
, 0);
753 * function: zfcp_fsf_status_read
755 * purpose: initiates a Status Read command at the specified adapter
760 zfcp_fsf_status_read(struct zfcp_adapter
*adapter
, int req_flags
)
762 struct zfcp_fsf_req
*fsf_req
;
763 struct fsf_status_read_buffer
*status_buffer
;
764 unsigned long lock_flags
;
765 volatile struct qdio_buffer_element
*sbale
;
768 /* setup new FSF request */
769 retval
= zfcp_fsf_req_create(adapter
, FSF_QTCB_UNSOLICITED_STATUS
,
770 req_flags
| ZFCP_REQ_NO_QTCB
,
771 adapter
->pool
.fsf_req_status_read
,
772 &lock_flags
, &fsf_req
);
774 ZFCP_LOG_INFO("error: Could not create unsolicited status "
775 "buffer for adapter %s.\n",
776 zfcp_get_busid_by_adapter(adapter
));
777 goto failed_req_create
;
780 sbale
= zfcp_qdio_sbale_req(fsf_req
, fsf_req
->sbal_curr
, 0);
781 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_STATUS
;
782 sbale
[2].flags
|= SBAL_FLAGS_LAST_ENTRY
;
783 fsf_req
->sbale_curr
= 2;
786 mempool_alloc(adapter
->pool
.data_status_read
, GFP_ATOMIC
);
787 if (!status_buffer
) {
788 ZFCP_LOG_NORMAL("bug: could not get some buffer\n");
791 memset(status_buffer
, 0, sizeof (struct fsf_status_read_buffer
));
792 fsf_req
->data
= (unsigned long) status_buffer
;
794 /* insert pointer to respective buffer */
795 sbale
= zfcp_qdio_sbale_curr(fsf_req
);
796 sbale
->addr
= (void *) status_buffer
;
797 sbale
->length
= sizeof(struct fsf_status_read_buffer
);
799 /* start QDIO request for this FSF request */
800 retval
= zfcp_fsf_req_send(fsf_req
, NULL
);
802 ZFCP_LOG_DEBUG("error: Could not set-up unsolicited status "
804 goto failed_req_send
;
807 ZFCP_LOG_TRACE("Status Read request initiated (adapter%s)\n",
808 zfcp_get_busid_by_adapter(adapter
));
812 mempool_free(status_buffer
, adapter
->pool
.data_status_read
);
815 zfcp_fsf_req_free(fsf_req
);
817 zfcp_hba_dbf_event_fsf_unsol("fail", adapter
, NULL
);
819 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
, lock_flags
);
824 zfcp_fsf_status_read_port_closed(struct zfcp_fsf_req
*fsf_req
)
826 struct fsf_status_read_buffer
*status_buffer
;
827 struct zfcp_adapter
*adapter
;
828 struct zfcp_port
*port
;
831 status_buffer
= (struct fsf_status_read_buffer
*) fsf_req
->data
;
832 adapter
= fsf_req
->adapter
;
834 read_lock_irqsave(&zfcp_data
.config_lock
, flags
);
835 list_for_each_entry(port
, &adapter
->port_list_head
, list
)
836 if (port
->d_id
== (status_buffer
->d_id
& ZFCP_DID_MASK
))
838 read_unlock_irqrestore(&zfcp_data
.config_lock
, flags
);
840 if (!port
|| (port
->d_id
!= (status_buffer
->d_id
& ZFCP_DID_MASK
))) {
841 ZFCP_LOG_NORMAL("bug: Reopen port indication received for"
842 "nonexisting port with d_id 0x%08x on "
843 "adapter %s. Ignored.\n",
844 status_buffer
->d_id
& ZFCP_DID_MASK
,
845 zfcp_get_busid_by_adapter(adapter
));
849 switch (status_buffer
->status_subtype
) {
851 case FSF_STATUS_READ_SUB_CLOSE_PHYS_PORT
:
852 debug_text_event(adapter
->erp_dbf
, 3, "unsol_pc_phys:");
853 zfcp_erp_port_reopen(port
, 0);
856 case FSF_STATUS_READ_SUB_ERROR_PORT
:
857 debug_text_event(adapter
->erp_dbf
, 1, "unsol_pc_err:");
858 zfcp_erp_port_shutdown(port
, 0);
862 debug_text_event(adapter
->erp_dbf
, 0, "unsol_unk_sub:");
863 debug_exception(adapter
->erp_dbf
, 0,
864 &status_buffer
->status_subtype
, sizeof (u32
));
865 ZFCP_LOG_NORMAL("bug: Undefined status subtype received "
866 "for a reopen indication on port with "
867 "d_id 0x%08x on the adapter %s. "
868 "Ignored. (debug info 0x%x)\n",
870 zfcp_get_busid_by_adapter(adapter
),
871 status_buffer
->status_subtype
);
878 * function: zfcp_fsf_status_read_handler
880 * purpose: is called for finished Open Port command
885 zfcp_fsf_status_read_handler(struct zfcp_fsf_req
*fsf_req
)
888 struct zfcp_adapter
*adapter
= fsf_req
->adapter
;
889 struct fsf_status_read_buffer
*status_buffer
=
890 (struct fsf_status_read_buffer
*) fsf_req
->data
;
892 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_DISMISSED
) {
893 zfcp_hba_dbf_event_fsf_unsol("dism", adapter
, status_buffer
);
894 mempool_free(status_buffer
, adapter
->pool
.data_status_read
);
895 zfcp_fsf_req_free(fsf_req
);
899 zfcp_hba_dbf_event_fsf_unsol("read", adapter
, status_buffer
);
901 switch (status_buffer
->status_type
) {
903 case FSF_STATUS_READ_PORT_CLOSED
:
904 zfcp_fsf_status_read_port_closed(fsf_req
);
907 case FSF_STATUS_READ_INCOMING_ELS
:
908 zfcp_fsf_incoming_els(fsf_req
);
911 case FSF_STATUS_READ_SENSE_DATA_AVAIL
:
912 ZFCP_LOG_INFO("unsolicited sense data received (adapter %s)\n",
913 zfcp_get_busid_by_adapter(adapter
));
916 case FSF_STATUS_READ_BIT_ERROR_THRESHOLD
:
917 ZFCP_LOG_NORMAL("Bit error threshold data received:\n");
918 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_NORMAL
,
919 (char *) status_buffer
,
920 sizeof (struct fsf_status_read_buffer
));
923 case FSF_STATUS_READ_LINK_DOWN
:
924 switch (status_buffer
->status_subtype
) {
925 case FSF_STATUS_READ_SUB_NO_PHYSICAL_LINK
:
926 ZFCP_LOG_INFO("Physical link to adapter %s is down\n",
927 zfcp_get_busid_by_adapter(adapter
));
928 zfcp_fsf_link_down_info_eval(adapter
,
929 (struct fsf_link_down_info
*)
930 &status_buffer
->payload
);
932 case FSF_STATUS_READ_SUB_FDISC_FAILED
:
933 ZFCP_LOG_INFO("Local link to adapter %s is down "
934 "due to failed FDISC login\n",
935 zfcp_get_busid_by_adapter(adapter
));
936 zfcp_fsf_link_down_info_eval(adapter
,
937 (struct fsf_link_down_info
*)
938 &status_buffer
->payload
);
940 case FSF_STATUS_READ_SUB_FIRMWARE_UPDATE
:
941 ZFCP_LOG_INFO("Local link to adapter %s is down "
942 "due to firmware update on adapter\n",
943 zfcp_get_busid_by_adapter(adapter
));
944 zfcp_fsf_link_down_info_eval(adapter
, NULL
);
947 ZFCP_LOG_INFO("Local link to adapter %s is down "
948 "due to unknown reason\n",
949 zfcp_get_busid_by_adapter(adapter
));
950 zfcp_fsf_link_down_info_eval(adapter
, NULL
);
954 case FSF_STATUS_READ_LINK_UP
:
955 ZFCP_LOG_NORMAL("Local link to adapter %s was replugged. "
956 "Restarting operations on this adapter\n",
957 zfcp_get_busid_by_adapter(adapter
));
958 /* All ports should be marked as ready to run again */
959 zfcp_erp_modify_adapter_status(adapter
,
960 ZFCP_STATUS_COMMON_RUNNING
,
962 zfcp_erp_adapter_reopen(adapter
,
963 ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED
964 | ZFCP_STATUS_COMMON_ERP_FAILED
);
967 case FSF_STATUS_READ_CFDC_UPDATED
:
968 ZFCP_LOG_NORMAL("CFDC has been updated on the adapter %s\n",
969 zfcp_get_busid_by_adapter(adapter
));
970 zfcp_erp_adapter_access_changed(adapter
);
973 case FSF_STATUS_READ_CFDC_HARDENED
:
974 switch (status_buffer
->status_subtype
) {
975 case FSF_STATUS_READ_SUB_CFDC_HARDENED_ON_SE
:
976 ZFCP_LOG_NORMAL("CFDC of adapter %s saved on SE\n",
977 zfcp_get_busid_by_adapter(adapter
));
979 case FSF_STATUS_READ_SUB_CFDC_HARDENED_ON_SE2
:
980 ZFCP_LOG_NORMAL("CFDC of adapter %s has been copied "
981 "to the secondary SE\n",
982 zfcp_get_busid_by_adapter(adapter
));
985 ZFCP_LOG_NORMAL("CFDC of adapter %s has been hardened\n",
986 zfcp_get_busid_by_adapter(adapter
));
990 case FSF_STATUS_READ_FEATURE_UPDATE_ALERT
:
991 debug_text_event(adapter
->erp_dbf
, 2, "unsol_features:");
992 ZFCP_LOG_INFO("List of supported features on adapter %s has "
993 "been changed from 0x%08X to 0x%08X\n",
994 zfcp_get_busid_by_adapter(adapter
),
995 *(u32
*) (status_buffer
->payload
+ 4),
996 *(u32
*) (status_buffer
->payload
));
997 adapter
->adapter_features
= *(u32
*) status_buffer
->payload
;
1001 ZFCP_LOG_NORMAL("warning: An unsolicited status packet of unknown "
1002 "type was received (debug info 0x%x)\n",
1003 status_buffer
->status_type
);
1004 ZFCP_LOG_DEBUG("Dump of status_read_buffer %p:\n",
1006 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
1007 (char *) status_buffer
,
1008 sizeof (struct fsf_status_read_buffer
));
1011 mempool_free(status_buffer
, adapter
->pool
.data_status_read
);
1012 zfcp_fsf_req_free(fsf_req
);
1014 * recycle buffer and start new request repeat until outbound
1015 * queue is empty or adapter shutdown is requested
1019 * we may wait in the req_create for 5s during shutdown, so
1020 * qdio_cleanup will have to wait at least that long before returning
1021 * with failure to allow us a proper cleanup under all circumstances
1025 * allocation failure possible? (Is this code needed?)
1027 retval
= zfcp_fsf_status_read(adapter
, 0);
1029 ZFCP_LOG_INFO("Failed to create unsolicited status read "
1030 "request for the adapter %s.\n",
1031 zfcp_get_busid_by_adapter(adapter
));
1032 /* temporary fix to avoid status read buffer shortage */
1033 adapter
->status_read_failed
++;
1034 if ((ZFCP_STATUS_READS_RECOM
- adapter
->status_read_failed
)
1035 < ZFCP_STATUS_READ_FAILED_THRESHOLD
) {
1036 ZFCP_LOG_INFO("restart adapter %s due to status read "
1037 "buffer shortage\n",
1038 zfcp_get_busid_by_adapter(adapter
));
1039 zfcp_erp_adapter_reopen(adapter
, 0);
1047 * function: zfcp_fsf_abort_fcp_command
1049 * purpose: tells FSF to abort a running SCSI command
1051 * returns: address of initiated FSF request
1052 * NULL - request could not be initiated
1054 * FIXME(design): should be watched by a timeout !!!
1055 * FIXME(design) shouldn't this be modified to return an int
1056 * also...don't know how though
1058 struct zfcp_fsf_req
*
1059 zfcp_fsf_abort_fcp_command(unsigned long old_req_id
,
1060 struct zfcp_adapter
*adapter
,
1061 struct zfcp_unit
*unit
, int req_flags
)
1063 volatile struct qdio_buffer_element
*sbale
;
1064 unsigned long lock_flags
;
1065 struct zfcp_fsf_req
*fsf_req
= NULL
;
1068 /* setup new FSF request */
1069 retval
= zfcp_fsf_req_create(adapter
, FSF_QTCB_ABORT_FCP_CMND
,
1070 req_flags
, adapter
->pool
.fsf_req_abort
,
1071 &lock_flags
, &fsf_req
);
1073 ZFCP_LOG_INFO("error: Failed to create an abort command "
1074 "request for lun 0x%016Lx on port 0x%016Lx "
1078 zfcp_get_busid_by_adapter(adapter
));
1082 sbale
= zfcp_qdio_sbale_req(fsf_req
, fsf_req
->sbal_curr
, 0);
1083 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_READ
;
1084 sbale
[1].flags
|= SBAL_FLAGS_LAST_ENTRY
;
1086 fsf_req
->data
= (unsigned long) unit
;
1088 /* set handles of unit and its parent port in QTCB */
1089 fsf_req
->qtcb
->header
.lun_handle
= unit
->handle
;
1090 fsf_req
->qtcb
->header
.port_handle
= unit
->port
->handle
;
1092 /* set handle of request which should be aborted */
1093 fsf_req
->qtcb
->bottom
.support
.req_handle
= (u64
) old_req_id
;
1095 /* start QDIO request for this FSF request */
1097 zfcp_fsf_start_scsi_er_timer(adapter
);
1098 retval
= zfcp_fsf_req_send(fsf_req
, NULL
);
1100 del_timer(&adapter
->scsi_er_timer
);
1101 ZFCP_LOG_INFO("error: Failed to send abort command request "
1102 "on adapter %s, port 0x%016Lx, unit 0x%016Lx\n",
1103 zfcp_get_busid_by_adapter(adapter
),
1104 unit
->port
->wwpn
, unit
->fcp_lun
);
1105 zfcp_fsf_req_free(fsf_req
);
1110 ZFCP_LOG_DEBUG("Abort FCP Command request initiated "
1111 "(adapter%s, port d_id=0x%08x, "
1112 "unit x%016Lx, old_req_id=0x%lx)\n",
1113 zfcp_get_busid_by_adapter(adapter
),
1115 unit
->fcp_lun
, old_req_id
);
1117 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
, lock_flags
);
1122 * function: zfcp_fsf_abort_fcp_command_handler
1124 * purpose: is called for finished Abort FCP Command request
1129 zfcp_fsf_abort_fcp_command_handler(struct zfcp_fsf_req
*new_fsf_req
)
1131 int retval
= -EINVAL
;
1132 struct zfcp_unit
*unit
;
1133 unsigned char status_qual
=
1134 new_fsf_req
->qtcb
->header
.fsf_status_qual
.word
[0];
1136 del_timer(&new_fsf_req
->adapter
->scsi_er_timer
);
1138 if (new_fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
) {
1139 /* do not set ZFCP_STATUS_FSFREQ_ABORTSUCCEEDED */
1140 goto skip_fsfstatus
;
1143 unit
= (struct zfcp_unit
*) new_fsf_req
->data
;
1145 /* evaluate FSF status in QTCB */
1146 switch (new_fsf_req
->qtcb
->header
.fsf_status
) {
1148 case FSF_PORT_HANDLE_NOT_VALID
:
1149 if (status_qual
>> 4 != status_qual
% 0xf) {
1150 debug_text_event(new_fsf_req
->adapter
->erp_dbf
, 3,
1153 * In this case a command that was sent prior to a port
1154 * reopen was aborted (handles are different). This is
1158 ZFCP_LOG_INFO("Temporary port identifier 0x%x for "
1159 "port 0x%016Lx on adapter %s invalid. "
1160 "This may happen occasionally.\n",
1163 zfcp_get_busid_by_unit(unit
));
1164 ZFCP_LOG_INFO("status qualifier:\n");
1165 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_INFO
,
1166 (char *) &new_fsf_req
->qtcb
->header
.
1168 sizeof (union fsf_status_qual
));
1169 /* Let's hope this sorts out the mess */
1170 debug_text_event(new_fsf_req
->adapter
->erp_dbf
, 1,
1172 zfcp_erp_adapter_reopen(unit
->port
->adapter
, 0);
1173 new_fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1177 case FSF_LUN_HANDLE_NOT_VALID
:
1178 if (status_qual
>> 4 != status_qual
% 0xf) {
1180 debug_text_event(new_fsf_req
->adapter
->erp_dbf
, 3,
1183 * In this case a command that was sent prior to a unit
1184 * reopen was aborted (handles are different).
1189 ("Warning: Temporary LUN identifier 0x%x of LUN "
1190 "0x%016Lx on port 0x%016Lx on adapter %s is "
1191 "invalid. This may happen in rare cases. "
1192 "Trying to re-establish link.\n",
1196 zfcp_get_busid_by_unit(unit
));
1197 ZFCP_LOG_DEBUG("Status qualifier data:\n");
1198 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
1199 (char *) &new_fsf_req
->qtcb
->header
.
1201 sizeof (union fsf_status_qual
));
1202 /* Let's hope this sorts out the mess */
1203 debug_text_event(new_fsf_req
->adapter
->erp_dbf
, 1,
1205 zfcp_erp_port_reopen(unit
->port
, 0);
1206 new_fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1210 case FSF_FCP_COMMAND_DOES_NOT_EXIST
:
1212 debug_text_event(new_fsf_req
->adapter
->erp_dbf
, 3,
1214 new_fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ABORTNOTNEEDED
;
1217 case FSF_PORT_BOXED
:
1218 ZFCP_LOG_INFO("Remote port 0x%016Lx on adapter %s needs to "
1219 "be reopened\n", unit
->port
->wwpn
,
1220 zfcp_get_busid_by_unit(unit
));
1221 debug_text_event(new_fsf_req
->adapter
->erp_dbf
, 2,
1223 zfcp_erp_port_boxed(unit
->port
);
1224 new_fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
1225 | ZFCP_STATUS_FSFREQ_RETRY
;
1230 "unit 0x%016Lx on port 0x%016Lx on adapter %s needs "
1232 unit
->fcp_lun
, unit
->port
->wwpn
,
1233 zfcp_get_busid_by_unit(unit
));
1234 debug_text_event(new_fsf_req
->adapter
->erp_dbf
, 1, "fsf_s_lboxed");
1235 zfcp_erp_unit_boxed(unit
);
1236 new_fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
1237 | ZFCP_STATUS_FSFREQ_RETRY
;
1240 case FSF_ADAPTER_STATUS_AVAILABLE
:
1241 switch (new_fsf_req
->qtcb
->header
.fsf_status_qual
.word
[0]) {
1242 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE
:
1243 debug_text_event(new_fsf_req
->adapter
->erp_dbf
, 1,
1245 zfcp_test_link(unit
->port
);
1246 new_fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1248 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED
:
1249 /* SCSI stack will escalate */
1250 debug_text_event(new_fsf_req
->adapter
->erp_dbf
, 1,
1252 new_fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1256 ("bug: Wrong status qualifier 0x%x arrived.\n",
1257 new_fsf_req
->qtcb
->header
.fsf_status_qual
.word
[0]);
1258 debug_text_event(new_fsf_req
->adapter
->erp_dbf
, 0,
1260 debug_exception(new_fsf_req
->adapter
->erp_dbf
, 0,
1261 &new_fsf_req
->qtcb
->header
.
1262 fsf_status_qual
.word
[0], sizeof (u32
));
1269 new_fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ABORTSUCCEEDED
;
1273 ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
1274 "(debug info 0x%x)\n",
1275 new_fsf_req
->qtcb
->header
.fsf_status
);
1276 debug_text_event(new_fsf_req
->adapter
->erp_dbf
, 0,
1278 debug_exception(new_fsf_req
->adapter
->erp_dbf
, 0,
1279 &new_fsf_req
->qtcb
->header
.fsf_status
,
1288 * zfcp_use_one_sbal - checks whether req buffer and resp bother each fit into
1290 * Two scatter-gather lists are passed, one for the reqeust and one for the
1294 zfcp_use_one_sbal(struct scatterlist
*req
, int req_count
,
1295 struct scatterlist
*resp
, int resp_count
)
1297 return ((req_count
== 1) &&
1298 (resp_count
== 1) &&
1299 (((unsigned long) zfcp_sg_to_address(&req
[0]) &
1301 ((unsigned long) (zfcp_sg_to_address(&req
[0]) +
1302 req
[0].length
- 1) & PAGE_MASK
)) &&
1303 (((unsigned long) zfcp_sg_to_address(&resp
[0]) &
1305 ((unsigned long) (zfcp_sg_to_address(&resp
[0]) +
1306 resp
[0].length
- 1) & PAGE_MASK
)));
1310 * zfcp_fsf_send_ct - initiate a Generic Service request (FC-GS)
1311 * @ct: pointer to struct zfcp_send_ct which conatins all needed data for
1313 * @pool: pointer to memory pool, if non-null this pool is used to allocate
1314 * a struct zfcp_fsf_req
1315 * @erp_action: pointer to erp_action, if non-null the Generic Service request
1316 * is sent within error recovery
1319 zfcp_fsf_send_ct(struct zfcp_send_ct
*ct
, mempool_t
*pool
,
1320 struct zfcp_erp_action
*erp_action
)
1322 volatile struct qdio_buffer_element
*sbale
;
1323 struct zfcp_port
*port
;
1324 struct zfcp_adapter
*adapter
;
1325 struct zfcp_fsf_req
*fsf_req
;
1326 unsigned long lock_flags
;
1331 adapter
= port
->adapter
;
1333 ret
= zfcp_fsf_req_create(adapter
, FSF_QTCB_SEND_GENERIC
,
1334 ZFCP_WAIT_FOR_SBAL
| ZFCP_REQ_AUTO_CLEANUP
,
1335 pool
, &lock_flags
, &fsf_req
);
1337 ZFCP_LOG_INFO("error: Could not create CT request (FC-GS) for "
1339 zfcp_get_busid_by_adapter(adapter
));
1343 if (erp_action
!= NULL
) {
1344 erp_action
->fsf_req
= fsf_req
;
1345 fsf_req
->erp_action
= erp_action
;
1348 sbale
= zfcp_qdio_sbale_req(fsf_req
, fsf_req
->sbal_curr
, 0);
1349 if (zfcp_use_one_sbal(ct
->req
, ct
->req_count
,
1350 ct
->resp
, ct
->resp_count
)){
1351 /* both request buffer and response buffer
1352 fit into one sbale each */
1353 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_WRITE_READ
;
1354 sbale
[2].addr
= zfcp_sg_to_address(&ct
->req
[0]);
1355 sbale
[2].length
= ct
->req
[0].length
;
1356 sbale
[3].addr
= zfcp_sg_to_address(&ct
->resp
[0]);
1357 sbale
[3].length
= ct
->resp
[0].length
;
1358 sbale
[3].flags
|= SBAL_FLAGS_LAST_ENTRY
;
1359 } else if (adapter
->adapter_features
&
1360 FSF_FEATURE_ELS_CT_CHAINED_SBALS
) {
1361 /* try to use chained SBALs */
1362 bytes
= zfcp_qdio_sbals_from_sg(fsf_req
,
1363 SBAL_FLAGS0_TYPE_WRITE_READ
,
1364 ct
->req
, ct
->req_count
,
1365 ZFCP_MAX_SBALS_PER_CT_REQ
);
1367 ZFCP_LOG_INFO("error: creation of CT request failed "
1369 zfcp_get_busid_by_adapter(adapter
));
1377 fsf_req
->qtcb
->bottom
.support
.req_buf_length
= bytes
;
1378 fsf_req
->sbale_curr
= ZFCP_LAST_SBALE_PER_SBAL
;
1379 bytes
= zfcp_qdio_sbals_from_sg(fsf_req
,
1380 SBAL_FLAGS0_TYPE_WRITE_READ
,
1381 ct
->resp
, ct
->resp_count
,
1382 ZFCP_MAX_SBALS_PER_CT_REQ
);
1384 ZFCP_LOG_INFO("error: creation of CT request failed "
1386 zfcp_get_busid_by_adapter(adapter
));
1394 fsf_req
->qtcb
->bottom
.support
.resp_buf_length
= bytes
;
1396 /* reject send generic request */
1398 "error: microcode does not support chained SBALs,"
1399 "CT request too big (adapter %s)\n",
1400 zfcp_get_busid_by_adapter(adapter
));
1405 /* settings in QTCB */
1406 fsf_req
->qtcb
->header
.port_handle
= port
->handle
;
1407 fsf_req
->qtcb
->bottom
.support
.service_class
= adapter
->fc_service_class
;
1408 fsf_req
->qtcb
->bottom
.support
.timeout
= ct
->timeout
;
1409 fsf_req
->data
= (unsigned long) ct
;
1411 zfcp_san_dbf_event_ct_request(fsf_req
);
1413 /* start QDIO request for this FSF request */
1414 ret
= zfcp_fsf_req_send(fsf_req
, ct
->timer
);
1416 ZFCP_LOG_DEBUG("error: initiation of CT request failed "
1417 "(adapter %s, port 0x%016Lx)\n",
1418 zfcp_get_busid_by_adapter(adapter
), port
->wwpn
);
1422 ZFCP_LOG_DEBUG("CT request initiated (adapter %s, port 0x%016Lx)\n",
1423 zfcp_get_busid_by_adapter(adapter
), port
->wwpn
);
1427 zfcp_fsf_req_free(fsf_req
);
1428 if (erp_action
!= NULL
) {
1429 erp_action
->fsf_req
= NULL
;
1433 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
,
1439 * zfcp_fsf_send_ct_handler - handler for Generic Service requests
1440 * @fsf_req: pointer to struct zfcp_fsf_req
1442 * Data specific for the Generic Service request is passed using
1443 * fsf_req->data. There we find the pointer to struct zfcp_send_ct.
1444 * Usually a specific handler for the CT request is called which is
1445 * found in this structure.
1448 zfcp_fsf_send_ct_handler(struct zfcp_fsf_req
*fsf_req
)
1450 struct zfcp_port
*port
;
1451 struct zfcp_adapter
*adapter
;
1452 struct zfcp_send_ct
*send_ct
;
1453 struct fsf_qtcb_header
*header
;
1454 struct fsf_qtcb_bottom_support
*bottom
;
1455 int retval
= -EINVAL
;
1456 u16 subtable
, rule
, counter
;
1458 adapter
= fsf_req
->adapter
;
1459 send_ct
= (struct zfcp_send_ct
*) fsf_req
->data
;
1460 port
= send_ct
->port
;
1461 header
= &fsf_req
->qtcb
->header
;
1462 bottom
= &fsf_req
->qtcb
->bottom
.support
;
1464 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
)
1465 goto skip_fsfstatus
;
1467 /* evaluate FSF status in QTCB */
1468 switch (header
->fsf_status
) {
1471 zfcp_san_dbf_event_ct_response(fsf_req
);
1475 case FSF_SERVICE_CLASS_NOT_SUPPORTED
:
1476 if (adapter
->fc_service_class
<= 3) {
1477 ZFCP_LOG_INFO("error: adapter %s does not support fc "
1479 zfcp_get_busid_by_port(port
),
1480 adapter
->fc_service_class
);
1482 ZFCP_LOG_INFO("bug: The fibre channel class at the "
1483 "adapter %s is invalid. "
1484 "(debug info %d)\n",
1485 zfcp_get_busid_by_port(port
),
1486 adapter
->fc_service_class
);
1488 /* stop operation for this adapter */
1489 debug_text_exception(adapter
->erp_dbf
, 0, "fsf_s_class_nsup");
1490 zfcp_erp_adapter_shutdown(adapter
, 0);
1491 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1494 case FSF_ADAPTER_STATUS_AVAILABLE
:
1495 switch (header
->fsf_status_qual
.word
[0]){
1496 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE
:
1497 /* reopening link to port */
1498 debug_text_event(adapter
->erp_dbf
, 1, "fsf_sq_ltest");
1499 zfcp_test_link(port
);
1500 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1502 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED
:
1503 /* ERP strategy will escalate */
1504 debug_text_event(adapter
->erp_dbf
, 1, "fsf_sq_ulp");
1505 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1508 ZFCP_LOG_INFO("bug: Wrong status qualifier 0x%x "
1510 header
->fsf_status_qual
.word
[0]);
1515 case FSF_ACCESS_DENIED
:
1516 ZFCP_LOG_NORMAL("access denied, cannot send generic service "
1517 "command (adapter %s, port d_id=0x%08x)\n",
1518 zfcp_get_busid_by_port(port
), port
->d_id
);
1519 for (counter
= 0; counter
< 2; counter
++) {
1520 subtable
= header
->fsf_status_qual
.halfword
[counter
* 2];
1521 rule
= header
->fsf_status_qual
.halfword
[counter
* 2 + 1];
1523 case FSF_SQ_CFDC_SUBTABLE_OS
:
1524 case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN
:
1525 case FSF_SQ_CFDC_SUBTABLE_PORT_DID
:
1526 case FSF_SQ_CFDC_SUBTABLE_LUN
:
1527 ZFCP_LOG_INFO("Access denied (%s rule %d)\n",
1528 zfcp_act_subtable_type
[subtable
], rule
);
1532 debug_text_event(adapter
->erp_dbf
, 1, "fsf_s_access");
1533 zfcp_erp_port_access_denied(port
);
1534 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1537 case FSF_GENERIC_COMMAND_REJECTED
:
1538 ZFCP_LOG_INFO("generic service command rejected "
1539 "(adapter %s, port d_id=0x%08x)\n",
1540 zfcp_get_busid_by_port(port
), port
->d_id
);
1541 ZFCP_LOG_INFO("status qualifier:\n");
1542 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_INFO
,
1543 (char *) &header
->fsf_status_qual
,
1544 sizeof (union fsf_status_qual
));
1545 debug_text_event(adapter
->erp_dbf
, 1, "fsf_s_gcom_rej");
1546 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1549 case FSF_PORT_HANDLE_NOT_VALID
:
1550 ZFCP_LOG_DEBUG("Temporary port identifier 0x%x for port "
1551 "0x%016Lx on adapter %s invalid. This may "
1552 "happen occasionally.\n", port
->handle
,
1553 port
->wwpn
, zfcp_get_busid_by_port(port
));
1554 ZFCP_LOG_INFO("status qualifier:\n");
1555 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_INFO
,
1556 (char *) &header
->fsf_status_qual
,
1557 sizeof (union fsf_status_qual
));
1558 debug_text_event(adapter
->erp_dbf
, 1, "fsf_s_phandle_nv");
1559 zfcp_erp_adapter_reopen(adapter
, 0);
1560 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1563 case FSF_PORT_BOXED
:
1564 ZFCP_LOG_INFO("port needs to be reopened "
1565 "(adapter %s, port d_id=0x%08x)\n",
1566 zfcp_get_busid_by_port(port
), port
->d_id
);
1567 debug_text_event(adapter
->erp_dbf
, 2, "fsf_s_pboxed");
1568 zfcp_erp_port_boxed(port
);
1569 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
1570 | ZFCP_STATUS_FSFREQ_RETRY
;
1573 /* following states should never occure, all cases avoided
1574 in zfcp_fsf_send_ct - but who knows ... */
1575 case FSF_PAYLOAD_SIZE_MISMATCH
:
1576 ZFCP_LOG_INFO("payload size mismatch (adapter: %s, "
1577 "req_buf_length=%d, resp_buf_length=%d)\n",
1578 zfcp_get_busid_by_adapter(adapter
),
1579 bottom
->req_buf_length
, bottom
->resp_buf_length
);
1580 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1582 case FSF_REQUEST_SIZE_TOO_LARGE
:
1583 ZFCP_LOG_INFO("request size too large (adapter: %s, "
1584 "req_buf_length=%d)\n",
1585 zfcp_get_busid_by_adapter(adapter
),
1586 bottom
->req_buf_length
);
1587 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1589 case FSF_RESPONSE_SIZE_TOO_LARGE
:
1590 ZFCP_LOG_INFO("response size too large (adapter: %s, "
1591 "resp_buf_length=%d)\n",
1592 zfcp_get_busid_by_adapter(adapter
),
1593 bottom
->resp_buf_length
);
1594 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1596 case FSF_SBAL_MISMATCH
:
1597 ZFCP_LOG_INFO("SBAL mismatch (adapter: %s, req_buf_length=%d, "
1598 "resp_buf_length=%d)\n",
1599 zfcp_get_busid_by_adapter(adapter
),
1600 bottom
->req_buf_length
, bottom
->resp_buf_length
);
1601 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1605 ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
1606 "(debug info 0x%x)\n", header
->fsf_status
);
1607 debug_text_event(adapter
->erp_dbf
, 0, "fsf_sq_inval:");
1608 debug_exception(adapter
->erp_dbf
, 0,
1609 &header
->fsf_status_qual
.word
[0], sizeof (u32
));
1614 send_ct
->status
= retval
;
1616 if (send_ct
->handler
!= NULL
)
1617 send_ct
->handler(send_ct
->handler_data
);
1623 * zfcp_fsf_send_els - initiate an ELS command (FC-FS)
1624 * @els: pointer to struct zfcp_send_els which contains all needed data for
1628 zfcp_fsf_send_els(struct zfcp_send_els
*els
)
1630 volatile struct qdio_buffer_element
*sbale
;
1631 struct zfcp_fsf_req
*fsf_req
;
1633 struct zfcp_adapter
*adapter
;
1634 unsigned long lock_flags
;
1639 adapter
= els
->adapter
;
1641 ret
= zfcp_fsf_req_create(adapter
, FSF_QTCB_SEND_ELS
,
1642 ZFCP_REQ_AUTO_CLEANUP
,
1643 NULL
, &lock_flags
, &fsf_req
);
1645 ZFCP_LOG_INFO("error: creation of ELS request failed "
1646 "(adapter %s, port d_id: 0x%08x)\n",
1647 zfcp_get_busid_by_adapter(adapter
), d_id
);
1651 sbale
= zfcp_qdio_sbale_req(fsf_req
, fsf_req
->sbal_curr
, 0);
1652 if (zfcp_use_one_sbal(els
->req
, els
->req_count
,
1653 els
->resp
, els
->resp_count
)){
1654 /* both request buffer and response buffer
1655 fit into one sbale each */
1656 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_WRITE_READ
;
1657 sbale
[2].addr
= zfcp_sg_to_address(&els
->req
[0]);
1658 sbale
[2].length
= els
->req
[0].length
;
1659 sbale
[3].addr
= zfcp_sg_to_address(&els
->resp
[0]);
1660 sbale
[3].length
= els
->resp
[0].length
;
1661 sbale
[3].flags
|= SBAL_FLAGS_LAST_ENTRY
;
1662 } else if (adapter
->adapter_features
&
1663 FSF_FEATURE_ELS_CT_CHAINED_SBALS
) {
1664 /* try to use chained SBALs */
1665 bytes
= zfcp_qdio_sbals_from_sg(fsf_req
,
1666 SBAL_FLAGS0_TYPE_WRITE_READ
,
1667 els
->req
, els
->req_count
,
1668 ZFCP_MAX_SBALS_PER_ELS_REQ
);
1670 ZFCP_LOG_INFO("error: creation of ELS request failed "
1671 "(adapter %s, port d_id: 0x%08x)\n",
1672 zfcp_get_busid_by_adapter(adapter
), d_id
);
1680 fsf_req
->qtcb
->bottom
.support
.req_buf_length
= bytes
;
1681 fsf_req
->sbale_curr
= ZFCP_LAST_SBALE_PER_SBAL
;
1682 bytes
= zfcp_qdio_sbals_from_sg(fsf_req
,
1683 SBAL_FLAGS0_TYPE_WRITE_READ
,
1684 els
->resp
, els
->resp_count
,
1685 ZFCP_MAX_SBALS_PER_ELS_REQ
);
1687 ZFCP_LOG_INFO("error: creation of ELS request failed "
1688 "(adapter %s, port d_id: 0x%08x)\n",
1689 zfcp_get_busid_by_adapter(adapter
), d_id
);
1697 fsf_req
->qtcb
->bottom
.support
.resp_buf_length
= bytes
;
1699 /* reject request */
1700 ZFCP_LOG_INFO("error: microcode does not support chained SBALs"
1701 ", ELS request too big (adapter %s, "
1702 "port d_id: 0x%08x)\n",
1703 zfcp_get_busid_by_adapter(adapter
), d_id
);
1708 /* settings in QTCB */
1709 fsf_req
->qtcb
->bottom
.support
.d_id
= d_id
;
1710 fsf_req
->qtcb
->bottom
.support
.service_class
= adapter
->fc_service_class
;
1711 fsf_req
->qtcb
->bottom
.support
.timeout
= ZFCP_ELS_TIMEOUT
;
1712 fsf_req
->data
= (unsigned long) els
;
1714 sbale
= zfcp_qdio_sbale_req(fsf_req
, fsf_req
->sbal_curr
, 0);
1716 zfcp_san_dbf_event_els_request(fsf_req
);
1718 /* start QDIO request for this FSF request */
1719 ret
= zfcp_fsf_req_send(fsf_req
, els
->timer
);
1721 ZFCP_LOG_DEBUG("error: initiation of ELS request failed "
1722 "(adapter %s, port d_id: 0x%08x)\n",
1723 zfcp_get_busid_by_adapter(adapter
), d_id
);
1727 ZFCP_LOG_DEBUG("ELS request initiated (adapter %s, port d_id: "
1728 "0x%08x)\n", zfcp_get_busid_by_adapter(adapter
), d_id
);
1732 zfcp_fsf_req_free(fsf_req
);
1736 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
,
1743 * zfcp_fsf_send_els_handler - handler for ELS commands
1744 * @fsf_req: pointer to struct zfcp_fsf_req
1746 * Data specific for the ELS command is passed using
1747 * fsf_req->data. There we find the pointer to struct zfcp_send_els.
1748 * Usually a specific handler for the ELS command is called which is
1749 * found in this structure.
1751 static int zfcp_fsf_send_els_handler(struct zfcp_fsf_req
*fsf_req
)
1753 struct zfcp_adapter
*adapter
;
1754 struct zfcp_port
*port
;
1756 struct fsf_qtcb_header
*header
;
1757 struct fsf_qtcb_bottom_support
*bottom
;
1758 struct zfcp_send_els
*send_els
;
1759 int retval
= -EINVAL
;
1760 u16 subtable
, rule
, counter
;
1762 send_els
= (struct zfcp_send_els
*) fsf_req
->data
;
1763 adapter
= send_els
->adapter
;
1764 port
= send_els
->port
;
1765 d_id
= send_els
->d_id
;
1766 header
= &fsf_req
->qtcb
->header
;
1767 bottom
= &fsf_req
->qtcb
->bottom
.support
;
1769 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
)
1770 goto skip_fsfstatus
;
1772 switch (header
->fsf_status
) {
1775 zfcp_san_dbf_event_els_response(fsf_req
);
1779 case FSF_SERVICE_CLASS_NOT_SUPPORTED
:
1780 if (adapter
->fc_service_class
<= 3) {
1781 ZFCP_LOG_INFO("error: adapter %s does "
1782 "not support fibrechannel class %d.\n",
1783 zfcp_get_busid_by_adapter(adapter
),
1784 adapter
->fc_service_class
);
1786 ZFCP_LOG_INFO("bug: The fibrechannel class at "
1787 "adapter %s is invalid. "
1788 "(debug info %d)\n",
1789 zfcp_get_busid_by_adapter(adapter
),
1790 adapter
->fc_service_class
);
1792 /* stop operation for this adapter */
1793 debug_text_exception(adapter
->erp_dbf
, 0, "fsf_s_class_nsup");
1794 zfcp_erp_adapter_shutdown(adapter
, 0);
1795 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1798 case FSF_ADAPTER_STATUS_AVAILABLE
:
1799 switch (header
->fsf_status_qual
.word
[0]){
1800 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE
:
1801 debug_text_event(adapter
->erp_dbf
, 1, "fsf_sq_ltest");
1802 if (port
&& (send_els
->ls_code
!= ZFCP_LS_ADISC
))
1803 zfcp_test_link(port
);
1804 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1806 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED
:
1807 debug_text_event(adapter
->erp_dbf
, 1, "fsf_sq_ulp");
1808 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1810 zfcp_handle_els_rjt(header
->fsf_status_qual
.word
[1],
1811 (struct zfcp_ls_rjt_par
*)
1812 &header
->fsf_status_qual
.word
[2]);
1814 case FSF_SQ_RETRY_IF_POSSIBLE
:
1815 debug_text_event(adapter
->erp_dbf
, 1, "fsf_sq_retry");
1816 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1819 ZFCP_LOG_INFO("bug: Wrong status qualifier 0x%x\n",
1820 header
->fsf_status_qual
.word
[0]);
1821 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_INFO
,
1822 (char*)header
->fsf_status_qual
.word
, 16);
1826 case FSF_ELS_COMMAND_REJECTED
:
1827 ZFCP_LOG_INFO("ELS has been rejected because command filter "
1828 "prohibited sending "
1829 "(adapter: %s, port d_id: 0x%08x)\n",
1830 zfcp_get_busid_by_adapter(adapter
), d_id
);
1834 case FSF_PAYLOAD_SIZE_MISMATCH
:
1836 "ELS request size and ELS response size must be either "
1837 "both 0, or both greater than 0 "
1838 "(adapter: %s, req_buf_length=%d resp_buf_length=%d)\n",
1839 zfcp_get_busid_by_adapter(adapter
),
1840 bottom
->req_buf_length
,
1841 bottom
->resp_buf_length
);
1844 case FSF_REQUEST_SIZE_TOO_LARGE
:
1846 "Length of the ELS request buffer, "
1847 "specified in QTCB bottom, "
1848 "exceeds the size of the buffers "
1849 "that have been allocated for ELS request data "
1850 "(adapter: %s, req_buf_length=%d)\n",
1851 zfcp_get_busid_by_adapter(adapter
),
1852 bottom
->req_buf_length
);
1855 case FSF_RESPONSE_SIZE_TOO_LARGE
:
1857 "Length of the ELS response buffer, "
1858 "specified in QTCB bottom, "
1859 "exceeds the size of the buffers "
1860 "that have been allocated for ELS response data "
1861 "(adapter: %s, resp_buf_length=%d)\n",
1862 zfcp_get_busid_by_adapter(adapter
),
1863 bottom
->resp_buf_length
);
1866 case FSF_SBAL_MISMATCH
:
1867 /* should never occure, avoided in zfcp_fsf_send_els */
1868 ZFCP_LOG_INFO("SBAL mismatch (adapter: %s, req_buf_length=%d, "
1869 "resp_buf_length=%d)\n",
1870 zfcp_get_busid_by_adapter(adapter
),
1871 bottom
->req_buf_length
, bottom
->resp_buf_length
);
1872 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1875 case FSF_ACCESS_DENIED
:
1876 ZFCP_LOG_NORMAL("access denied, cannot send ELS command "
1877 "(adapter %s, port d_id=0x%08x)\n",
1878 zfcp_get_busid_by_adapter(adapter
), d_id
);
1879 for (counter
= 0; counter
< 2; counter
++) {
1880 subtable
= header
->fsf_status_qual
.halfword
[counter
* 2];
1881 rule
= header
->fsf_status_qual
.halfword
[counter
* 2 + 1];
1883 case FSF_SQ_CFDC_SUBTABLE_OS
:
1884 case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN
:
1885 case FSF_SQ_CFDC_SUBTABLE_PORT_DID
:
1886 case FSF_SQ_CFDC_SUBTABLE_LUN
:
1887 ZFCP_LOG_INFO("Access denied (%s rule %d)\n",
1888 zfcp_act_subtable_type
[subtable
], rule
);
1892 debug_text_event(adapter
->erp_dbf
, 1, "fsf_s_access");
1894 zfcp_erp_port_access_denied(port
);
1895 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1900 "bug: An unknown FSF Status was presented "
1901 "(adapter: %s, fsf_status=0x%08x)\n",
1902 zfcp_get_busid_by_adapter(adapter
),
1903 header
->fsf_status
);
1904 debug_text_event(adapter
->erp_dbf
, 0, "fsf_sq_inval");
1905 debug_exception(adapter
->erp_dbf
, 0,
1906 &header
->fsf_status_qual
.word
[0], sizeof(u32
));
1907 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1912 send_els
->status
= retval
;
1914 if (send_els
->handler
!= 0)
1915 send_els
->handler(send_els
->handler_data
);
1925 * returns: address of initiated FSF request
1926 * NULL - request could not be initiated
1929 zfcp_fsf_exchange_config_data(struct zfcp_erp_action
*erp_action
)
1931 volatile struct qdio_buffer_element
*sbale
;
1932 unsigned long lock_flags
;
1935 /* setup new FSF request */
1936 retval
= zfcp_fsf_req_create(erp_action
->adapter
,
1937 FSF_QTCB_EXCHANGE_CONFIG_DATA
,
1938 ZFCP_REQ_AUTO_CLEANUP
,
1939 erp_action
->adapter
->pool
.fsf_req_erp
,
1940 &lock_flags
, &(erp_action
->fsf_req
));
1942 ZFCP_LOG_INFO("error: Could not create exchange configuration "
1943 "data request for adapter %s.\n",
1944 zfcp_get_busid_by_adapter(erp_action
->adapter
));
1948 sbale
= zfcp_qdio_sbale_req(erp_action
->fsf_req
,
1949 erp_action
->fsf_req
->sbal_curr
, 0);
1950 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_READ
;
1951 sbale
[1].flags
|= SBAL_FLAGS_LAST_ENTRY
;
1953 erp_action
->fsf_req
->erp_action
= erp_action
;
1954 erp_action
->fsf_req
->qtcb
->bottom
.config
.feature_selection
=
1956 FSF_FEATURE_LUN_SHARING
|
1957 FSF_FEATURE_UPDATE_ALERT
;
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
;
1993 struct Scsi_Host
*shost
= adapter
->scsi_host
;
1995 bottom
= &fsf_req
->qtcb
->bottom
.config
;
1996 ZFCP_LOG_DEBUG("low/high QTCB version 0x%x/0x%x of FSF\n",
1997 bottom
->low_qtcb_version
, bottom
->high_qtcb_version
);
1998 adapter
->fsf_lic_version
= bottom
->lic_version
;
1999 adapter
->adapter_features
= bottom
->adapter_features
;
2000 adapter
->connection_features
= bottom
->connection_features
;
2001 adapter
->peer_wwpn
= 0;
2002 adapter
->peer_wwnn
= 0;
2003 adapter
->peer_d_id
= 0;
2006 fc_host_node_name(shost
) = bottom
->nport_serv_param
.wwnn
;
2007 fc_host_port_name(shost
) = bottom
->nport_serv_param
.wwpn
;
2008 fc_host_port_id(shost
) = bottom
->s_id
& ZFCP_DID_MASK
;
2009 fc_host_speed(shost
) = bottom
->fc_link_speed
;
2010 fc_host_supported_classes(shost
) = FC_COS_CLASS2
| FC_COS_CLASS3
;
2011 adapter
->fc_topology
= bottom
->fc_topology
;
2012 adapter
->hydra_version
= bottom
->adapter_type
;
2013 if (adapter
->physical_wwpn
== 0)
2014 adapter
->physical_wwpn
= fc_host_port_name(shost
);
2015 if (adapter
->physical_s_id
== 0)
2016 adapter
->physical_s_id
= fc_host_port_id(shost
);
2018 fc_host_node_name(shost
) = 0;
2019 fc_host_port_name(shost
) = 0;
2020 fc_host_port_id(shost
) = 0;
2021 fc_host_speed(shost
) = FC_PORTSPEED_UNKNOWN
;
2022 adapter
->fc_topology
= 0;
2023 adapter
->hydra_version
= 0;
2026 if (adapter
->fc_topology
== FSF_TOPO_P2P
) {
2027 adapter
->peer_d_id
= bottom
->peer_d_id
& ZFCP_DID_MASK
;
2028 adapter
->peer_wwpn
= bottom
->plogi_payload
.wwpn
;
2029 adapter
->peer_wwnn
= bottom
->plogi_payload
.wwnn
;
2032 if (adapter
->adapter_features
& FSF_FEATURE_HBAAPI_MANAGEMENT
) {
2033 adapter
->hardware_version
= bottom
->hardware_version
;
2034 memcpy(fc_host_serial_number(shost
), bottom
->serial_number
,
2035 min(FC_SERIAL_NUMBER_SIZE
, 17));
2036 EBCASC(fc_host_serial_number(shost
),
2037 min(FC_SERIAL_NUMBER_SIZE
, 17));
2040 ZFCP_LOG_NORMAL("The adapter %s reported the following characteristics:\n"
2044 "adapter version 0x%x, "
2045 "LIC version 0x%x, "
2046 "FC link speed %d Gb/s\n",
2047 zfcp_get_busid_by_adapter(adapter
),
2048 (wwn_t
) fc_host_node_name(shost
),
2049 (wwn_t
) fc_host_port_name(shost
),
2050 fc_host_port_id(shost
),
2051 adapter
->hydra_version
,
2052 adapter
->fsf_lic_version
,
2053 fc_host_speed(shost
));
2054 if (ZFCP_QTCB_VERSION
< bottom
->low_qtcb_version
) {
2055 ZFCP_LOG_NORMAL("error: the adapter %s "
2056 "only supports newer control block "
2057 "versions in comparison to this device "
2058 "driver (try updated device driver)\n",
2059 zfcp_get_busid_by_adapter(adapter
));
2060 debug_text_event(adapter
->erp_dbf
, 0, "low_qtcb_ver");
2061 zfcp_erp_adapter_shutdown(adapter
, 0);
2064 if (ZFCP_QTCB_VERSION
> bottom
->high_qtcb_version
) {
2065 ZFCP_LOG_NORMAL("error: the adapter %s "
2066 "only supports older control block "
2067 "versions than this device driver uses"
2068 "(consider a microcode upgrade)\n",
2069 zfcp_get_busid_by_adapter(adapter
));
2070 debug_text_event(adapter
->erp_dbf
, 0, "high_qtcb_ver");
2071 zfcp_erp_adapter_shutdown(adapter
, 0);
2078 * function: zfcp_fsf_exchange_config_data_handler
2080 * purpose: is called for finished Exchange Configuration Data command
2085 zfcp_fsf_exchange_config_data_handler(struct zfcp_fsf_req
*fsf_req
)
2087 struct fsf_qtcb_bottom_config
*bottom
;
2088 struct zfcp_adapter
*adapter
= fsf_req
->adapter
;
2089 struct fsf_qtcb
*qtcb
= fsf_req
->qtcb
;
2091 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
)
2094 switch (qtcb
->header
.fsf_status
) {
2097 if (zfcp_fsf_exchange_config_evaluate(fsf_req
, 1))
2100 switch (adapter
->fc_topology
) {
2102 ZFCP_LOG_NORMAL("Point-to-Point fibrechannel "
2103 "configuration detected at adapter %s\n"
2104 "Peer WWNN 0x%016llx, "
2105 "peer WWPN 0x%016llx, "
2106 "peer d_id 0x%06x\n",
2107 zfcp_get_busid_by_adapter(adapter
),
2110 adapter
->peer_d_id
);
2111 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0,
2115 ZFCP_LOG_NORMAL("error: Arbitrated loop fibrechannel "
2116 "topology detected at adapter %s "
2117 "unsupported, shutting down adapter\n",
2118 zfcp_get_busid_by_adapter(adapter
));
2119 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0,
2121 zfcp_erp_adapter_shutdown(adapter
, 0);
2123 case FSF_TOPO_FABRIC
:
2124 ZFCP_LOG_NORMAL("Switched fabric fibrechannel "
2125 "network detected at adapter %s.\n",
2126 zfcp_get_busid_by_adapter(adapter
));
2129 ZFCP_LOG_NORMAL("bug: The fibrechannel topology "
2130 "reported by the exchange "
2131 "configuration command for "
2132 "the adapter %s is not "
2133 "of a type known to the zfcp "
2134 "driver, shutting down adapter\n",
2135 zfcp_get_busid_by_adapter(adapter
));
2136 adapter
->fc_topology
= FSF_TOPO_ERROR
;
2137 debug_text_exception(fsf_req
->adapter
->erp_dbf
, 0,
2139 zfcp_erp_adapter_shutdown(adapter
, 0);
2142 bottom
= &qtcb
->bottom
.config
;
2143 if (bottom
->max_qtcb_size
< sizeof(struct fsf_qtcb
)) {
2144 ZFCP_LOG_NORMAL("bug: Maximum QTCB size (%d bytes) "
2145 "allowed by the adapter %s "
2146 "is lower than the minimum "
2147 "required by the driver (%ld bytes).\n",
2148 bottom
->max_qtcb_size
,
2149 zfcp_get_busid_by_adapter(adapter
),
2150 sizeof(struct fsf_qtcb
));
2151 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0,
2153 debug_event(fsf_req
->adapter
->erp_dbf
, 0,
2154 &bottom
->max_qtcb_size
, sizeof (u32
));
2155 zfcp_erp_adapter_shutdown(adapter
, 0);
2158 atomic_set_mask(ZFCP_STATUS_ADAPTER_XCONFIG_OK
,
2161 case FSF_EXCHANGE_CONFIG_DATA_INCOMPLETE
:
2162 debug_text_event(adapter
->erp_dbf
, 0, "xchg-inco");
2164 if (zfcp_fsf_exchange_config_evaluate(fsf_req
, 0))
2167 atomic_set_mask(ZFCP_STATUS_ADAPTER_XCONFIG_OK
, &adapter
->status
);
2169 zfcp_fsf_link_down_info_eval(adapter
,
2170 &qtcb
->header
.fsf_status_qual
.link_down_info
);
2173 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0, "fsf-stat-ng");
2174 debug_event(fsf_req
->adapter
->erp_dbf
, 0,
2175 &fsf_req
->qtcb
->header
.fsf_status
, sizeof (u32
));
2176 zfcp_erp_adapter_shutdown(adapter
, 0);
2183 * zfcp_fsf_exchange_port_data - request information about local port
2184 * @erp_action: ERP action for the adapter for which port data is requested
2185 * @adapter: for which port data is requested
2186 * @data: response to exchange port data request
2189 zfcp_fsf_exchange_port_data(struct zfcp_erp_action
*erp_action
,
2190 struct zfcp_adapter
*adapter
,
2191 struct fsf_qtcb_bottom_port
*data
)
2193 volatile struct qdio_buffer_element
*sbale
;
2195 unsigned long lock_flags
;
2196 struct zfcp_fsf_req
*fsf_req
;
2197 struct timer_list
*timer
;
2199 if (!(adapter
->adapter_features
& FSF_FEATURE_HBAAPI_MANAGEMENT
)) {
2200 ZFCP_LOG_INFO("error: exchange port data "
2201 "command not supported by adapter %s\n",
2202 zfcp_get_busid_by_adapter(adapter
));
2206 /* setup new FSF request */
2207 retval
= zfcp_fsf_req_create(adapter
, FSF_QTCB_EXCHANGE_PORT_DATA
,
2208 erp_action
? ZFCP_REQ_AUTO_CLEANUP
: 0,
2209 0, &lock_flags
, &fsf_req
);
2211 ZFCP_LOG_INFO("error: Out of resources. Could not create an "
2212 "exchange port data request for"
2213 "the adapter %s.\n",
2214 zfcp_get_busid_by_adapter(adapter
));
2215 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
,
2221 fsf_req
->data
= (unsigned long) data
;
2223 sbale
= zfcp_qdio_sbale_req(fsf_req
, fsf_req
->sbal_curr
, 0);
2224 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_READ
;
2225 sbale
[1].flags
|= SBAL_FLAGS_LAST_ENTRY
;
2228 erp_action
->fsf_req
= fsf_req
;
2229 fsf_req
->erp_action
= erp_action
;
2230 timer
= &erp_action
->timer
;
2232 timer
= kmalloc(sizeof(struct timer_list
), GFP_ATOMIC
);
2234 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
,
2236 zfcp_fsf_req_free(fsf_req
);
2240 timer
->function
= zfcp_fsf_request_timeout_handler
;
2241 timer
->data
= (unsigned long) adapter
;
2242 timer
->expires
= ZFCP_FSF_REQUEST_TIMEOUT
;
2245 retval
= zfcp_fsf_req_send(fsf_req
, timer
);
2247 ZFCP_LOG_INFO("error: Could not send an exchange port data "
2248 "command on the adapter %s\n",
2249 zfcp_get_busid_by_adapter(adapter
));
2250 zfcp_fsf_req_free(fsf_req
);
2252 erp_action
->fsf_req
= NULL
;
2255 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
,
2260 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
, lock_flags
);
2263 wait_event(fsf_req
->completion_wq
,
2264 fsf_req
->status
& ZFCP_STATUS_FSFREQ_COMPLETED
);
2265 del_timer_sync(timer
);
2266 zfcp_fsf_req_free(fsf_req
);
2274 * zfcp_fsf_exchange_port_data_handler - handler for exchange_port_data request
2275 * @fsf_req: pointer to struct zfcp_fsf_req
2278 zfcp_fsf_exchange_port_data_handler(struct zfcp_fsf_req
*fsf_req
)
2280 struct zfcp_adapter
*adapter
= fsf_req
->adapter
;
2281 struct Scsi_Host
*shost
= adapter
->scsi_host
;
2282 struct fsf_qtcb
*qtcb
= fsf_req
->qtcb
;
2283 struct fsf_qtcb_bottom_port
*bottom
, *data
;
2285 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
)
2288 switch (qtcb
->header
.fsf_status
) {
2290 atomic_set_mask(ZFCP_STATUS_ADAPTER_XPORT_OK
, &adapter
->status
);
2292 bottom
= &qtcb
->bottom
.port
;
2293 data
= (struct fsf_qtcb_bottom_port
*) fsf_req
->data
;
2295 memcpy(data
, bottom
, sizeof(struct fsf_qtcb_bottom_port
));
2296 if (adapter
->connection_features
& FSF_FEATURE_NPIV_MODE
) {
2297 adapter
->physical_wwpn
= bottom
->wwpn
;
2298 adapter
->physical_s_id
= bottom
->fc_port_id
;
2300 adapter
->physical_wwpn
= fc_host_port_name(shost
);
2301 adapter
->physical_s_id
= fc_host_port_id(shost
);
2303 fc_host_maxframe_size(shost
) = bottom
->maximum_frame_size
;
2306 case FSF_EXCHANGE_CONFIG_DATA_INCOMPLETE
:
2307 atomic_set_mask(ZFCP_STATUS_ADAPTER_XPORT_OK
, &adapter
->status
);
2309 zfcp_fsf_link_down_info_eval(adapter
,
2310 &qtcb
->header
.fsf_status_qual
.link_down_info
);
2314 debug_text_event(adapter
->erp_dbf
, 0, "xchg-port-ng");
2315 debug_event(adapter
->erp_dbf
, 0,
2316 &fsf_req
->qtcb
->header
.fsf_status
, sizeof(u32
));
2322 * function: zfcp_fsf_open_port
2326 * returns: address of initiated FSF request
2327 * NULL - request could not be initiated
2330 zfcp_fsf_open_port(struct zfcp_erp_action
*erp_action
)
2332 volatile struct qdio_buffer_element
*sbale
;
2333 unsigned long lock_flags
;
2336 /* setup new FSF request */
2337 retval
= zfcp_fsf_req_create(erp_action
->adapter
,
2338 FSF_QTCB_OPEN_PORT_WITH_DID
,
2339 ZFCP_WAIT_FOR_SBAL
| ZFCP_REQ_AUTO_CLEANUP
,
2340 erp_action
->adapter
->pool
.fsf_req_erp
,
2341 &lock_flags
, &(erp_action
->fsf_req
));
2343 ZFCP_LOG_INFO("error: Could not create open port request "
2344 "for port 0x%016Lx on adapter %s.\n",
2345 erp_action
->port
->wwpn
,
2346 zfcp_get_busid_by_adapter(erp_action
->adapter
));
2350 sbale
= zfcp_qdio_sbale_req(erp_action
->fsf_req
,
2351 erp_action
->fsf_req
->sbal_curr
, 0);
2352 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_READ
;
2353 sbale
[1].flags
|= SBAL_FLAGS_LAST_ENTRY
;
2355 erp_action
->fsf_req
->qtcb
->bottom
.support
.d_id
= erp_action
->port
->d_id
;
2356 atomic_set_mask(ZFCP_STATUS_COMMON_OPENING
, &erp_action
->port
->status
);
2357 erp_action
->fsf_req
->data
= (unsigned long) erp_action
->port
;
2358 erp_action
->fsf_req
->erp_action
= erp_action
;
2360 /* start QDIO request for this FSF request */
2361 retval
= zfcp_fsf_req_send(erp_action
->fsf_req
, &erp_action
->timer
);
2363 ZFCP_LOG_INFO("error: Could not send open port request for "
2364 "port 0x%016Lx on adapter %s.\n",
2365 erp_action
->port
->wwpn
,
2366 zfcp_get_busid_by_adapter(erp_action
->adapter
));
2367 zfcp_fsf_req_free(erp_action
->fsf_req
);
2368 erp_action
->fsf_req
= NULL
;
2372 ZFCP_LOG_DEBUG("open port request initiated "
2373 "(adapter %s, port 0x%016Lx)\n",
2374 zfcp_get_busid_by_adapter(erp_action
->adapter
),
2375 erp_action
->port
->wwpn
);
2377 write_unlock_irqrestore(&erp_action
->adapter
->request_queue
.queue_lock
,
2383 * function: zfcp_fsf_open_port_handler
2385 * purpose: is called for finished Open Port command
2390 zfcp_fsf_open_port_handler(struct zfcp_fsf_req
*fsf_req
)
2392 int retval
= -EINVAL
;
2393 struct zfcp_port
*port
;
2394 struct fsf_plogi
*plogi
;
2395 struct fsf_qtcb_header
*header
;
2396 u16 subtable
, rule
, counter
;
2398 port
= (struct zfcp_port
*) fsf_req
->data
;
2399 header
= &fsf_req
->qtcb
->header
;
2401 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
) {
2402 /* don't change port status in our bookkeeping */
2403 goto skip_fsfstatus
;
2406 /* evaluate FSF status in QTCB */
2407 switch (header
->fsf_status
) {
2409 case FSF_PORT_ALREADY_OPEN
:
2410 ZFCP_LOG_NORMAL("bug: remote port 0x%016Lx on adapter %s "
2411 "is already open.\n",
2412 port
->wwpn
, zfcp_get_busid_by_port(port
));
2413 debug_text_exception(fsf_req
->adapter
->erp_dbf
, 0,
2416 * This is a bug, however operation should continue normally
2417 * if it is simply ignored
2421 case FSF_ACCESS_DENIED
:
2422 ZFCP_LOG_NORMAL("Access denied, cannot open port 0x%016Lx "
2424 port
->wwpn
, zfcp_get_busid_by_port(port
));
2425 for (counter
= 0; counter
< 2; counter
++) {
2426 subtable
= header
->fsf_status_qual
.halfword
[counter
* 2];
2427 rule
= header
->fsf_status_qual
.halfword
[counter
* 2 + 1];
2429 case FSF_SQ_CFDC_SUBTABLE_OS
:
2430 case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN
:
2431 case FSF_SQ_CFDC_SUBTABLE_PORT_DID
:
2432 case FSF_SQ_CFDC_SUBTABLE_LUN
:
2433 ZFCP_LOG_INFO("Access denied (%s rule %d)\n",
2434 zfcp_act_subtable_type
[subtable
], rule
);
2438 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1, "fsf_s_access");
2439 zfcp_erp_port_access_denied(port
);
2440 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
2443 case FSF_MAXIMUM_NUMBER_OF_PORTS_EXCEEDED
:
2444 ZFCP_LOG_INFO("error: The FSF adapter is out of resources. "
2445 "The remote port 0x%016Lx on adapter %s "
2446 "could not be opened. Disabling it.\n",
2447 port
->wwpn
, zfcp_get_busid_by_port(port
));
2448 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
2450 zfcp_erp_port_failed(port
);
2451 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
2454 case FSF_ADAPTER_STATUS_AVAILABLE
:
2455 switch (header
->fsf_status_qual
.word
[0]) {
2456 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE
:
2457 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
2459 /* ERP strategy will escalate */
2460 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
2462 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED
:
2463 /* ERP strategy will escalate */
2464 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
2466 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
2468 case FSF_SQ_NO_RETRY_POSSIBLE
:
2469 ZFCP_LOG_NORMAL("The remote port 0x%016Lx on "
2470 "adapter %s could not be opened. "
2473 zfcp_get_busid_by_port(port
));
2474 debug_text_exception(fsf_req
->adapter
->erp_dbf
, 0,
2476 zfcp_erp_port_failed(port
);
2477 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
2481 ("bug: Wrong status qualifier 0x%x arrived.\n",
2482 header
->fsf_status_qual
.word
[0]);
2483 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0,
2486 fsf_req
->adapter
->erp_dbf
, 0,
2487 &header
->fsf_status_qual
.word
[0],
2494 /* save port handle assigned by FSF */
2495 port
->handle
= header
->port_handle
;
2496 ZFCP_LOG_INFO("The remote port 0x%016Lx via adapter %s "
2497 "was opened, it's port handle is 0x%x\n",
2498 port
->wwpn
, zfcp_get_busid_by_port(port
),
2500 /* mark port as open */
2501 atomic_set_mask(ZFCP_STATUS_COMMON_OPEN
|
2502 ZFCP_STATUS_PORT_PHYS_OPEN
, &port
->status
);
2503 atomic_clear_mask(ZFCP_STATUS_COMMON_ACCESS_DENIED
|
2504 ZFCP_STATUS_COMMON_ACCESS_BOXED
,
2507 /* check whether D_ID has changed during open */
2509 * FIXME: This check is not airtight, as the FCP channel does
2510 * not monitor closures of target port connections caused on
2511 * the remote side. Thus, they might miss out on invalidating
2512 * locally cached WWPNs (and other N_Port parameters) of gone
2513 * target ports. So, our heroic attempt to make things safe
2514 * could be undermined by 'open port' response data tagged with
2515 * obsolete WWPNs. Another reason to monitor potential
2516 * connection closures ourself at least (by interpreting
2517 * incoming ELS' and unsolicited status). It just crosses my
2518 * mind that one should be able to cross-check by means of
2519 * another GID_PN straight after a port has been opened.
2520 * Alternately, an ADISC/PDISC ELS should suffice, as well.
2522 plogi
= (struct fsf_plogi
*) fsf_req
->qtcb
->bottom
.support
.els
;
2523 if (!atomic_test_mask(ZFCP_STATUS_PORT_NO_WWPN
, &port
->status
))
2525 if (fsf_req
->qtcb
->bottom
.support
.els1_length
<
2526 ((((unsigned long) &plogi
->serv_param
.wwpn
) -
2527 ((unsigned long) plogi
)) + sizeof (u64
))) {
2529 "warning: insufficient length of "
2530 "PLOGI payload (%i)\n",
2531 fsf_req
->qtcb
->bottom
.support
.els1_length
);
2532 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0,
2533 "fsf_s_short_plogi:");
2534 /* skip sanity check and assume wwpn is ok */
2536 if (plogi
->serv_param
.wwpn
!= port
->wwpn
) {
2537 ZFCP_LOG_INFO("warning: d_id of port "
2538 "0x%016Lx changed during "
2539 "open\n", port
->wwpn
);
2541 fsf_req
->adapter
->erp_dbf
, 0,
2542 "fsf_s_did_change:");
2544 ZFCP_STATUS_PORT_DID_DID
,
2547 port
->wwnn
= plogi
->serv_param
.wwnn
;
2552 case FSF_UNKNOWN_OP_SUBTYPE
:
2553 /* should never occure, subtype not set in zfcp_fsf_open_port */
2554 ZFCP_LOG_INFO("unknown operation subtype (adapter: %s, "
2555 "op_subtype=0x%x)\n",
2556 zfcp_get_busid_by_port(port
),
2557 fsf_req
->qtcb
->bottom
.support
.operation_subtype
);
2558 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
2562 ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
2563 "(debug info 0x%x)\n",
2564 header
->fsf_status
);
2565 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0, "fsf_s_inval:");
2566 debug_exception(fsf_req
->adapter
->erp_dbf
, 0,
2567 &header
->fsf_status
, sizeof (u32
));
2572 atomic_clear_mask(ZFCP_STATUS_COMMON_OPENING
, &port
->status
);
2577 * function: zfcp_fsf_close_port
2579 * purpose: submit FSF command "close port"
2581 * returns: address of initiated FSF request
2582 * NULL - request could not be initiated
2585 zfcp_fsf_close_port(struct zfcp_erp_action
*erp_action
)
2587 volatile struct qdio_buffer_element
*sbale
;
2588 unsigned long lock_flags
;
2591 /* setup new FSF request */
2592 retval
= zfcp_fsf_req_create(erp_action
->adapter
,
2593 FSF_QTCB_CLOSE_PORT
,
2594 ZFCP_WAIT_FOR_SBAL
| ZFCP_REQ_AUTO_CLEANUP
,
2595 erp_action
->adapter
->pool
.fsf_req_erp
,
2596 &lock_flags
, &(erp_action
->fsf_req
));
2598 ZFCP_LOG_INFO("error: Could not create a close port request "
2599 "for port 0x%016Lx on adapter %s.\n",
2600 erp_action
->port
->wwpn
,
2601 zfcp_get_busid_by_adapter(erp_action
->adapter
));
2605 sbale
= zfcp_qdio_sbale_req(erp_action
->fsf_req
,
2606 erp_action
->fsf_req
->sbal_curr
, 0);
2607 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_READ
;
2608 sbale
[1].flags
|= SBAL_FLAGS_LAST_ENTRY
;
2610 atomic_set_mask(ZFCP_STATUS_COMMON_CLOSING
, &erp_action
->port
->status
);
2611 erp_action
->fsf_req
->data
= (unsigned long) erp_action
->port
;
2612 erp_action
->fsf_req
->erp_action
= erp_action
;
2613 erp_action
->fsf_req
->qtcb
->header
.port_handle
=
2614 erp_action
->port
->handle
;
2616 /* start QDIO request for this FSF request */
2617 retval
= zfcp_fsf_req_send(erp_action
->fsf_req
, &erp_action
->timer
);
2619 ZFCP_LOG_INFO("error: Could not send a close port request for "
2620 "port 0x%016Lx on adapter %s.\n",
2621 erp_action
->port
->wwpn
,
2622 zfcp_get_busid_by_adapter(erp_action
->adapter
));
2623 zfcp_fsf_req_free(erp_action
->fsf_req
);
2624 erp_action
->fsf_req
= NULL
;
2628 ZFCP_LOG_TRACE("close port request initiated "
2629 "(adapter %s, port 0x%016Lx)\n",
2630 zfcp_get_busid_by_adapter(erp_action
->adapter
),
2631 erp_action
->port
->wwpn
);
2633 write_unlock_irqrestore(&erp_action
->adapter
->request_queue
.queue_lock
,
2639 * function: zfcp_fsf_close_port_handler
2641 * purpose: is called for finished Close Port FSF command
2646 zfcp_fsf_close_port_handler(struct zfcp_fsf_req
*fsf_req
)
2648 int retval
= -EINVAL
;
2649 struct zfcp_port
*port
;
2651 port
= (struct zfcp_port
*) fsf_req
->data
;
2653 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
) {
2654 /* don't change port status in our bookkeeping */
2655 goto skip_fsfstatus
;
2658 /* evaluate FSF status in QTCB */
2659 switch (fsf_req
->qtcb
->header
.fsf_status
) {
2661 case FSF_PORT_HANDLE_NOT_VALID
:
2662 ZFCP_LOG_INFO("Temporary port identifier 0x%x for port "
2663 "0x%016Lx on adapter %s invalid. This may happen "
2664 "occasionally.\n", port
->handle
,
2665 port
->wwpn
, zfcp_get_busid_by_port(port
));
2666 ZFCP_LOG_DEBUG("status qualifier:\n");
2667 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
2668 (char *) &fsf_req
->qtcb
->header
.fsf_status_qual
,
2669 sizeof (union fsf_status_qual
));
2670 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
2672 zfcp_erp_adapter_reopen(port
->adapter
, 0);
2673 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
2676 case FSF_ADAPTER_STATUS_AVAILABLE
:
2677 /* Note: FSF has actually closed the port in this case.
2678 * The status code is just daft. Fingers crossed for a change
2684 ZFCP_LOG_TRACE("remote port 0x016%Lx on adapter %s closed, "
2685 "port handle 0x%x\n", port
->wwpn
,
2686 zfcp_get_busid_by_port(port
), port
->handle
);
2687 zfcp_erp_modify_port_status(port
,
2688 ZFCP_STATUS_COMMON_OPEN
,
2694 ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
2695 "(debug info 0x%x)\n",
2696 fsf_req
->qtcb
->header
.fsf_status
);
2697 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0, "fsf_s_inval:");
2698 debug_exception(fsf_req
->adapter
->erp_dbf
, 0,
2699 &fsf_req
->qtcb
->header
.fsf_status
,
2705 atomic_clear_mask(ZFCP_STATUS_COMMON_CLOSING
, &port
->status
);
2710 * function: zfcp_fsf_close_physical_port
2712 * purpose: submit FSF command "close physical port"
2714 * returns: address of initiated FSF request
2715 * NULL - request could not be initiated
2718 zfcp_fsf_close_physical_port(struct zfcp_erp_action
*erp_action
)
2721 unsigned long lock_flags
;
2722 volatile struct qdio_buffer_element
*sbale
;
2724 /* setup new FSF request */
2725 retval
= zfcp_fsf_req_create(erp_action
->adapter
,
2726 FSF_QTCB_CLOSE_PHYSICAL_PORT
,
2727 ZFCP_WAIT_FOR_SBAL
| ZFCP_REQ_AUTO_CLEANUP
,
2728 erp_action
->adapter
->pool
.fsf_req_erp
,
2729 &lock_flags
, &erp_action
->fsf_req
);
2731 ZFCP_LOG_INFO("error: Could not create close physical port "
2732 "request (adapter %s, port 0x%016Lx)\n",
2733 zfcp_get_busid_by_adapter(erp_action
->adapter
),
2734 erp_action
->port
->wwpn
);
2739 sbale
= zfcp_qdio_sbale_req(erp_action
->fsf_req
,
2740 erp_action
->fsf_req
->sbal_curr
, 0);
2741 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_READ
;
2742 sbale
[1].flags
|= SBAL_FLAGS_LAST_ENTRY
;
2744 /* mark port as being closed */
2745 atomic_set_mask(ZFCP_STATUS_PORT_PHYS_CLOSING
,
2746 &erp_action
->port
->status
);
2747 /* save a pointer to this port */
2748 erp_action
->fsf_req
->data
= (unsigned long) erp_action
->port
;
2749 /* port to be closed */
2750 erp_action
->fsf_req
->qtcb
->header
.port_handle
=
2751 erp_action
->port
->handle
;
2752 erp_action
->fsf_req
->erp_action
= erp_action
;
2754 /* start QDIO request for this FSF request */
2755 retval
= zfcp_fsf_req_send(erp_action
->fsf_req
, &erp_action
->timer
);
2757 ZFCP_LOG_INFO("error: Could not send close physical port "
2758 "request (adapter %s, port 0x%016Lx)\n",
2759 zfcp_get_busid_by_adapter(erp_action
->adapter
),
2760 erp_action
->port
->wwpn
);
2761 zfcp_fsf_req_free(erp_action
->fsf_req
);
2762 erp_action
->fsf_req
= NULL
;
2766 ZFCP_LOG_TRACE("close physical port request initiated "
2767 "(adapter %s, port 0x%016Lx)\n",
2768 zfcp_get_busid_by_adapter(erp_action
->adapter
),
2769 erp_action
->port
->wwpn
);
2771 write_unlock_irqrestore(&erp_action
->adapter
->request_queue
.queue_lock
,
2777 * function: zfcp_fsf_close_physical_port_handler
2779 * purpose: is called for finished Close Physical Port FSF command
2784 zfcp_fsf_close_physical_port_handler(struct zfcp_fsf_req
*fsf_req
)
2786 int retval
= -EINVAL
;
2787 struct zfcp_port
*port
;
2788 struct zfcp_unit
*unit
;
2789 struct fsf_qtcb_header
*header
;
2790 u16 subtable
, rule
, counter
;
2792 port
= (struct zfcp_port
*) fsf_req
->data
;
2793 header
= &fsf_req
->qtcb
->header
;
2795 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
) {
2796 /* don't change port status in our bookkeeping */
2797 goto skip_fsfstatus
;
2800 /* evaluate FSF status in QTCB */
2801 switch (header
->fsf_status
) {
2803 case FSF_PORT_HANDLE_NOT_VALID
:
2804 ZFCP_LOG_INFO("Temporary port identifier 0x%x invalid"
2805 "(adapter %s, port 0x%016Lx). "
2806 "This may happen occasionally.\n",
2808 zfcp_get_busid_by_port(port
),
2810 ZFCP_LOG_DEBUG("status qualifier:\n");
2811 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
2812 (char *) &header
->fsf_status_qual
,
2813 sizeof (union fsf_status_qual
));
2814 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
2816 zfcp_erp_adapter_reopen(port
->adapter
, 0);
2817 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
2820 case FSF_ACCESS_DENIED
:
2821 ZFCP_LOG_NORMAL("Access denied, cannot close "
2822 "physical port 0x%016Lx on adapter %s\n",
2823 port
->wwpn
, zfcp_get_busid_by_port(port
));
2824 for (counter
= 0; counter
< 2; counter
++) {
2825 subtable
= header
->fsf_status_qual
.halfword
[counter
* 2];
2826 rule
= header
->fsf_status_qual
.halfword
[counter
* 2 + 1];
2828 case FSF_SQ_CFDC_SUBTABLE_OS
:
2829 case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN
:
2830 case FSF_SQ_CFDC_SUBTABLE_PORT_DID
:
2831 case FSF_SQ_CFDC_SUBTABLE_LUN
:
2832 ZFCP_LOG_INFO("Access denied (%s rule %d)\n",
2833 zfcp_act_subtable_type
[subtable
], rule
);
2837 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1, "fsf_s_access");
2838 zfcp_erp_port_access_denied(port
);
2839 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
2842 case FSF_PORT_BOXED
:
2843 ZFCP_LOG_DEBUG("The remote port 0x%016Lx on adapter "
2844 "%s needs to be reopened but it was attempted "
2845 "to close it physically.\n",
2847 zfcp_get_busid_by_port(port
));
2848 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1, "fsf_s_pboxed");
2849 zfcp_erp_port_boxed(port
);
2850 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
|
2851 ZFCP_STATUS_FSFREQ_RETRY
;
2854 case FSF_ADAPTER_STATUS_AVAILABLE
:
2855 switch (header
->fsf_status_qual
.word
[0]) {
2856 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE
:
2857 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
2859 /* This will now be escalated by ERP */
2860 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
2862 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED
:
2863 /* ERP strategy will escalate */
2864 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
2866 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
2870 ("bug: Wrong status qualifier 0x%x arrived.\n",
2871 header
->fsf_status_qual
.word
[0]);
2872 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0,
2875 fsf_req
->adapter
->erp_dbf
, 0,
2876 &header
->fsf_status_qual
.word
[0], sizeof (u32
));
2882 ZFCP_LOG_DEBUG("Remote port 0x%016Lx via adapter %s "
2883 "physically closed, port handle 0x%x\n",
2885 zfcp_get_busid_by_port(port
), port
->handle
);
2886 /* can't use generic zfcp_erp_modify_port_status because
2887 * ZFCP_STATUS_COMMON_OPEN must not be reset for the port
2889 atomic_clear_mask(ZFCP_STATUS_PORT_PHYS_OPEN
, &port
->status
);
2890 list_for_each_entry(unit
, &port
->unit_list_head
, list
)
2891 atomic_clear_mask(ZFCP_STATUS_COMMON_OPEN
, &unit
->status
);
2896 ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
2897 "(debug info 0x%x)\n",
2898 header
->fsf_status
);
2899 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0, "fsf_s_inval:");
2900 debug_exception(fsf_req
->adapter
->erp_dbf
, 0,
2901 &header
->fsf_status
, sizeof (u32
));
2906 atomic_clear_mask(ZFCP_STATUS_PORT_PHYS_CLOSING
, &port
->status
);
2911 * function: zfcp_fsf_open_unit
2917 * assumptions: This routine does not check whether the associated
2918 * remote port has already been opened. This should be
2919 * done by calling routines. Otherwise some status
2920 * may be presented by FSF
2923 zfcp_fsf_open_unit(struct zfcp_erp_action
*erp_action
)
2925 volatile struct qdio_buffer_element
*sbale
;
2926 unsigned long lock_flags
;
2929 /* setup new FSF request */
2930 retval
= zfcp_fsf_req_create(erp_action
->adapter
,
2932 ZFCP_WAIT_FOR_SBAL
| ZFCP_REQ_AUTO_CLEANUP
,
2933 erp_action
->adapter
->pool
.fsf_req_erp
,
2934 &lock_flags
, &(erp_action
->fsf_req
));
2936 ZFCP_LOG_INFO("error: Could not create open unit request for "
2937 "unit 0x%016Lx on port 0x%016Lx on adapter %s.\n",
2938 erp_action
->unit
->fcp_lun
,
2939 erp_action
->unit
->port
->wwpn
,
2940 zfcp_get_busid_by_adapter(erp_action
->adapter
));
2944 sbale
= zfcp_qdio_sbale_req(erp_action
->fsf_req
,
2945 erp_action
->fsf_req
->sbal_curr
, 0);
2946 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_READ
;
2947 sbale
[1].flags
|= SBAL_FLAGS_LAST_ENTRY
;
2949 erp_action
->fsf_req
->qtcb
->header
.port_handle
=
2950 erp_action
->port
->handle
;
2951 erp_action
->fsf_req
->qtcb
->bottom
.support
.fcp_lun
=
2952 erp_action
->unit
->fcp_lun
;
2953 if (!(erp_action
->adapter
->connection_features
& FSF_FEATURE_NPIV_MODE
))
2954 erp_action
->fsf_req
->qtcb
->bottom
.support
.option
=
2955 FSF_OPEN_LUN_SUPPRESS_BOXING
;
2956 atomic_set_mask(ZFCP_STATUS_COMMON_OPENING
, &erp_action
->unit
->status
);
2957 erp_action
->fsf_req
->data
= (unsigned long) erp_action
->unit
;
2958 erp_action
->fsf_req
->erp_action
= erp_action
;
2960 /* start QDIO request for this FSF request */
2961 retval
= zfcp_fsf_req_send(erp_action
->fsf_req
, &erp_action
->timer
);
2963 ZFCP_LOG_INFO("error: Could not send an open unit request "
2964 "on the adapter %s, port 0x%016Lx for "
2966 zfcp_get_busid_by_adapter(erp_action
->adapter
),
2967 erp_action
->port
->wwpn
,
2968 erp_action
->unit
->fcp_lun
);
2969 zfcp_fsf_req_free(erp_action
->fsf_req
);
2970 erp_action
->fsf_req
= NULL
;
2974 ZFCP_LOG_TRACE("Open LUN request initiated (adapter %s, "
2975 "port 0x%016Lx, unit 0x%016Lx)\n",
2976 zfcp_get_busid_by_adapter(erp_action
->adapter
),
2977 erp_action
->port
->wwpn
, erp_action
->unit
->fcp_lun
);
2979 write_unlock_irqrestore(&erp_action
->adapter
->request_queue
.queue_lock
,
2985 * function: zfcp_fsf_open_unit_handler
2987 * purpose: is called for finished Open LUN command
2992 zfcp_fsf_open_unit_handler(struct zfcp_fsf_req
*fsf_req
)
2994 int retval
= -EINVAL
;
2995 struct zfcp_adapter
*adapter
;
2996 struct zfcp_unit
*unit
;
2997 struct fsf_qtcb_header
*header
;
2998 struct fsf_qtcb_bottom_support
*bottom
;
2999 struct fsf_queue_designator
*queue_designator
;
3000 u16 subtable
, rule
, counter
;
3001 int exclusive
, readwrite
;
3003 unit
= (struct zfcp_unit
*) fsf_req
->data
;
3005 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
) {
3006 /* don't change unit status in our bookkeeping */
3007 goto skip_fsfstatus
;
3010 adapter
= fsf_req
->adapter
;
3011 header
= &fsf_req
->qtcb
->header
;
3012 bottom
= &fsf_req
->qtcb
->bottom
.support
;
3013 queue_designator
= &header
->fsf_status_qual
.fsf_queue_designator
;
3015 atomic_clear_mask(ZFCP_STATUS_COMMON_ACCESS_DENIED
|
3016 ZFCP_STATUS_UNIT_SHARED
|
3017 ZFCP_STATUS_UNIT_READONLY
,
3020 /* evaluate FSF status in QTCB */
3021 switch (header
->fsf_status
) {
3023 case FSF_PORT_HANDLE_NOT_VALID
:
3024 ZFCP_LOG_INFO("Temporary port identifier 0x%x "
3025 "for port 0x%016Lx on adapter %s invalid "
3026 "This may happen occasionally\n",
3028 unit
->port
->wwpn
, zfcp_get_busid_by_unit(unit
));
3029 ZFCP_LOG_DEBUG("status qualifier:\n");
3030 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
3031 (char *) &header
->fsf_status_qual
,
3032 sizeof (union fsf_status_qual
));
3033 debug_text_event(adapter
->erp_dbf
, 1, "fsf_s_ph_nv");
3034 zfcp_erp_adapter_reopen(unit
->port
->adapter
, 0);
3035 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3038 case FSF_LUN_ALREADY_OPEN
:
3039 ZFCP_LOG_NORMAL("bug: Attempted to open unit 0x%016Lx on "
3040 "remote port 0x%016Lx on adapter %s twice.\n",
3042 unit
->port
->wwpn
, zfcp_get_busid_by_unit(unit
));
3043 debug_text_exception(adapter
->erp_dbf
, 0,
3045 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3048 case FSF_ACCESS_DENIED
:
3049 ZFCP_LOG_NORMAL("Access denied, cannot open unit 0x%016Lx on "
3050 "remote port 0x%016Lx on adapter %s\n",
3051 unit
->fcp_lun
, unit
->port
->wwpn
,
3052 zfcp_get_busid_by_unit(unit
));
3053 for (counter
= 0; counter
< 2; counter
++) {
3054 subtable
= header
->fsf_status_qual
.halfword
[counter
* 2];
3055 rule
= header
->fsf_status_qual
.halfword
[counter
* 2 + 1];
3057 case FSF_SQ_CFDC_SUBTABLE_OS
:
3058 case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN
:
3059 case FSF_SQ_CFDC_SUBTABLE_PORT_DID
:
3060 case FSF_SQ_CFDC_SUBTABLE_LUN
:
3061 ZFCP_LOG_INFO("Access denied (%s rule %d)\n",
3062 zfcp_act_subtable_type
[subtable
], rule
);
3066 debug_text_event(adapter
->erp_dbf
, 1, "fsf_s_access");
3067 zfcp_erp_unit_access_denied(unit
);
3068 atomic_clear_mask(ZFCP_STATUS_UNIT_SHARED
, &unit
->status
);
3069 atomic_clear_mask(ZFCP_STATUS_UNIT_READONLY
, &unit
->status
);
3070 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3073 case FSF_PORT_BOXED
:
3074 ZFCP_LOG_DEBUG("The remote port 0x%016Lx on adapter %s "
3075 "needs to be reopened\n",
3076 unit
->port
->wwpn
, zfcp_get_busid_by_unit(unit
));
3077 debug_text_event(adapter
->erp_dbf
, 2, "fsf_s_pboxed");
3078 zfcp_erp_port_boxed(unit
->port
);
3079 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
|
3080 ZFCP_STATUS_FSFREQ_RETRY
;
3083 case FSF_LUN_SHARING_VIOLATION
:
3084 if (header
->fsf_status_qual
.word
[0] != 0) {
3085 ZFCP_LOG_NORMAL("FCP-LUN 0x%Lx at the remote port "
3087 "connected to the adapter %s "
3088 "is already in use in LPAR%d, CSS%d\n",
3091 zfcp_get_busid_by_unit(unit
),
3092 queue_designator
->hla
,
3093 queue_designator
->cssid
);
3095 subtable
= header
->fsf_status_qual
.halfword
[4];
3096 rule
= header
->fsf_status_qual
.halfword
[5];
3098 case FSF_SQ_CFDC_SUBTABLE_OS
:
3099 case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN
:
3100 case FSF_SQ_CFDC_SUBTABLE_PORT_DID
:
3101 case FSF_SQ_CFDC_SUBTABLE_LUN
:
3102 ZFCP_LOG_NORMAL("Access to FCP-LUN 0x%Lx at the "
3103 "remote port with WWPN 0x%Lx "
3104 "connected to the adapter %s "
3105 "is denied (%s rule %d)\n",
3108 zfcp_get_busid_by_unit(unit
),
3109 zfcp_act_subtable_type
[subtable
],
3114 ZFCP_LOG_DEBUG("status qualifier:\n");
3115 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
3116 (char *) &header
->fsf_status_qual
,
3117 sizeof (union fsf_status_qual
));
3118 debug_text_event(adapter
->erp_dbf
, 2,
3120 zfcp_erp_unit_access_denied(unit
);
3121 atomic_clear_mask(ZFCP_STATUS_UNIT_SHARED
, &unit
->status
);
3122 atomic_clear_mask(ZFCP_STATUS_UNIT_READONLY
, &unit
->status
);
3123 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3126 case FSF_MAXIMUM_NUMBER_OF_LUNS_EXCEEDED
:
3127 ZFCP_LOG_INFO("error: The adapter ran out of resources. "
3128 "There is no handle (temporary port identifier) "
3129 "available for unit 0x%016Lx on port 0x%016Lx "
3133 zfcp_get_busid_by_unit(unit
));
3134 debug_text_event(adapter
->erp_dbf
, 1,
3136 zfcp_erp_unit_failed(unit
);
3137 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3140 case FSF_ADAPTER_STATUS_AVAILABLE
:
3141 switch (header
->fsf_status_qual
.word
[0]) {
3142 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE
:
3143 /* Re-establish link to port */
3144 debug_text_event(adapter
->erp_dbf
, 1,
3146 zfcp_test_link(unit
->port
);
3147 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3149 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED
:
3150 /* ERP strategy will escalate */
3151 debug_text_event(adapter
->erp_dbf
, 1,
3153 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3157 ("bug: Wrong status qualifier 0x%x arrived.\n",
3158 header
->fsf_status_qual
.word
[0]);
3159 debug_text_event(adapter
->erp_dbf
, 0,
3161 debug_exception(adapter
->erp_dbf
, 0,
3162 &header
->fsf_status_qual
.word
[0],
3167 case FSF_INVALID_COMMAND_OPTION
:
3169 "Invalid option 0x%x has been specified "
3170 "in QTCB bottom sent to the adapter %s\n",
3172 zfcp_get_busid_by_adapter(adapter
));
3173 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3178 /* save LUN handle assigned by FSF */
3179 unit
->handle
= header
->lun_handle
;
3180 ZFCP_LOG_TRACE("unit 0x%016Lx on remote port 0x%016Lx on "
3181 "adapter %s opened, port handle 0x%x\n",
3184 zfcp_get_busid_by_unit(unit
),
3186 /* mark unit as open */
3187 atomic_set_mask(ZFCP_STATUS_COMMON_OPEN
, &unit
->status
);
3189 if (!(adapter
->connection_features
& FSF_FEATURE_NPIV_MODE
) &&
3190 (adapter
->adapter_features
& FSF_FEATURE_LUN_SHARING
) &&
3191 (adapter
->ccw_device
->id
.dev_model
!= ZFCP_DEVICE_MODEL_PRIV
)) {
3192 exclusive
= (bottom
->lun_access_info
&
3193 FSF_UNIT_ACCESS_EXCLUSIVE
);
3194 readwrite
= (bottom
->lun_access_info
&
3195 FSF_UNIT_ACCESS_OUTBOUND_TRANSFER
);
3198 atomic_set_mask(ZFCP_STATUS_UNIT_SHARED
,
3202 atomic_set_mask(ZFCP_STATUS_UNIT_READONLY
,
3204 ZFCP_LOG_NORMAL("read-only access for unit "
3205 "(adapter %s, wwpn=0x%016Lx, "
3206 "fcp_lun=0x%016Lx)\n",
3207 zfcp_get_busid_by_unit(unit
),
3212 if (exclusive
&& !readwrite
) {
3213 ZFCP_LOG_NORMAL("exclusive access of read-only "
3214 "unit not supported\n");
3215 zfcp_erp_unit_failed(unit
);
3216 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3217 zfcp_erp_unit_shutdown(unit
, 0);
3218 } else if (!exclusive
&& readwrite
) {
3219 ZFCP_LOG_NORMAL("shared access of read-write "
3220 "unit not supported\n");
3221 zfcp_erp_unit_failed(unit
);
3222 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3223 zfcp_erp_unit_shutdown(unit
, 0);
3231 ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
3232 "(debug info 0x%x)\n",
3233 header
->fsf_status
);
3234 debug_text_event(adapter
->erp_dbf
, 0, "fsf_s_inval:");
3235 debug_exception(adapter
->erp_dbf
, 0,
3236 &header
->fsf_status
, sizeof (u32
));
3241 atomic_clear_mask(ZFCP_STATUS_COMMON_OPENING
, &unit
->status
);
3246 * function: zfcp_fsf_close_unit
3250 * returns: address of fsf_req - request successfully initiated
3253 * assumptions: This routine does not check whether the associated
3254 * remote port/lun has already been opened. This should be
3255 * done by calling routines. Otherwise some status
3256 * may be presented by FSF
3259 zfcp_fsf_close_unit(struct zfcp_erp_action
*erp_action
)
3261 volatile struct qdio_buffer_element
*sbale
;
3262 unsigned long lock_flags
;
3265 /* setup new FSF request */
3266 retval
= zfcp_fsf_req_create(erp_action
->adapter
,
3268 ZFCP_WAIT_FOR_SBAL
| ZFCP_REQ_AUTO_CLEANUP
,
3269 erp_action
->adapter
->pool
.fsf_req_erp
,
3270 &lock_flags
, &(erp_action
->fsf_req
));
3272 ZFCP_LOG_INFO("error: Could not create close unit request for "
3273 "unit 0x%016Lx on port 0x%016Lx on adapter %s.\n",
3274 erp_action
->unit
->fcp_lun
,
3275 erp_action
->port
->wwpn
,
3276 zfcp_get_busid_by_adapter(erp_action
->adapter
));
3280 sbale
= zfcp_qdio_sbale_req(erp_action
->fsf_req
,
3281 erp_action
->fsf_req
->sbal_curr
, 0);
3282 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_READ
;
3283 sbale
[1].flags
|= SBAL_FLAGS_LAST_ENTRY
;
3285 erp_action
->fsf_req
->qtcb
->header
.port_handle
=
3286 erp_action
->port
->handle
;
3287 erp_action
->fsf_req
->qtcb
->header
.lun_handle
= erp_action
->unit
->handle
;
3288 atomic_set_mask(ZFCP_STATUS_COMMON_CLOSING
, &erp_action
->unit
->status
);
3289 erp_action
->fsf_req
->data
= (unsigned long) erp_action
->unit
;
3290 erp_action
->fsf_req
->erp_action
= erp_action
;
3292 /* start QDIO request for this FSF request */
3293 retval
= zfcp_fsf_req_send(erp_action
->fsf_req
, &erp_action
->timer
);
3295 ZFCP_LOG_INFO("error: Could not send a close unit request for "
3296 "unit 0x%016Lx on port 0x%016Lx onadapter %s.\n",
3297 erp_action
->unit
->fcp_lun
,
3298 erp_action
->port
->wwpn
,
3299 zfcp_get_busid_by_adapter(erp_action
->adapter
));
3300 zfcp_fsf_req_free(erp_action
->fsf_req
);
3301 erp_action
->fsf_req
= NULL
;
3305 ZFCP_LOG_TRACE("Close LUN request initiated (adapter %s, "
3306 "port 0x%016Lx, unit 0x%016Lx)\n",
3307 zfcp_get_busid_by_adapter(erp_action
->adapter
),
3308 erp_action
->port
->wwpn
, erp_action
->unit
->fcp_lun
);
3310 write_unlock_irqrestore(&erp_action
->adapter
->request_queue
.queue_lock
,
3316 * function: zfcp_fsf_close_unit_handler
3318 * purpose: is called for finished Close LUN FSF command
3323 zfcp_fsf_close_unit_handler(struct zfcp_fsf_req
*fsf_req
)
3325 int retval
= -EINVAL
;
3326 struct zfcp_unit
*unit
;
3328 unit
= (struct zfcp_unit
*) fsf_req
->data
;
3330 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
) {
3331 /* don't change unit status in our bookkeeping */
3332 goto skip_fsfstatus
;
3335 /* evaluate FSF status in QTCB */
3336 switch (fsf_req
->qtcb
->header
.fsf_status
) {
3338 case FSF_PORT_HANDLE_NOT_VALID
:
3339 ZFCP_LOG_INFO("Temporary port identifier 0x%x for port "
3340 "0x%016Lx on adapter %s invalid. This may "
3341 "happen in rare circumstances\n",
3344 zfcp_get_busid_by_unit(unit
));
3345 ZFCP_LOG_DEBUG("status qualifier:\n");
3346 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
3347 (char *) &fsf_req
->qtcb
->header
.fsf_status_qual
,
3348 sizeof (union fsf_status_qual
));
3349 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
3351 zfcp_erp_adapter_reopen(unit
->port
->adapter
, 0);
3352 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3355 case FSF_LUN_HANDLE_NOT_VALID
:
3356 ZFCP_LOG_INFO("Temporary LUN identifier 0x%x of unit "
3357 "0x%016Lx on port 0x%016Lx on adapter %s is "
3358 "invalid. This may happen occasionally.\n",
3362 zfcp_get_busid_by_unit(unit
));
3363 ZFCP_LOG_DEBUG("Status qualifier data:\n");
3364 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
3365 (char *) &fsf_req
->qtcb
->header
.fsf_status_qual
,
3366 sizeof (union fsf_status_qual
));
3367 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
3369 zfcp_erp_port_reopen(unit
->port
, 0);
3370 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3373 case FSF_PORT_BOXED
:
3374 ZFCP_LOG_DEBUG("The remote port 0x%016Lx on adapter %s "
3375 "needs to be reopened\n",
3377 zfcp_get_busid_by_unit(unit
));
3378 debug_text_event(fsf_req
->adapter
->erp_dbf
, 2, "fsf_s_pboxed");
3379 zfcp_erp_port_boxed(unit
->port
);
3380 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
|
3381 ZFCP_STATUS_FSFREQ_RETRY
;
3384 case FSF_ADAPTER_STATUS_AVAILABLE
:
3385 switch (fsf_req
->qtcb
->header
.fsf_status_qual
.word
[0]) {
3386 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE
:
3387 /* re-establish link to port */
3388 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
3390 zfcp_test_link(unit
->port
);
3391 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3393 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED
:
3394 /* ERP strategy will escalate */
3395 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
3397 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3401 ("bug: Wrong status qualifier 0x%x arrived.\n",
3402 fsf_req
->qtcb
->header
.fsf_status_qual
.word
[0]);
3403 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0,
3406 fsf_req
->adapter
->erp_dbf
, 0,
3407 &fsf_req
->qtcb
->header
.fsf_status_qual
.word
[0],
3414 ZFCP_LOG_TRACE("unit 0x%016Lx on port 0x%016Lx on adapter %s "
3415 "closed, port handle 0x%x\n",
3418 zfcp_get_busid_by_unit(unit
),
3420 /* mark unit as closed */
3421 atomic_clear_mask(ZFCP_STATUS_COMMON_OPEN
, &unit
->status
);
3426 ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
3427 "(debug info 0x%x)\n",
3428 fsf_req
->qtcb
->header
.fsf_status
);
3429 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0, "fsf_s_inval:");
3430 debug_exception(fsf_req
->adapter
->erp_dbf
, 0,
3431 &fsf_req
->qtcb
->header
.fsf_status
,
3437 atomic_clear_mask(ZFCP_STATUS_COMMON_CLOSING
, &unit
->status
);
3442 * zfcp_fsf_send_fcp_command_task - initiate an FCP command (for a SCSI command)
3443 * @adapter: adapter where scsi command is issued
3444 * @unit: unit where command is sent to
3445 * @scsi_cmnd: scsi command to be sent
3446 * @timer: timer to be started when request is initiated
3447 * @req_flags: flags for fsf_request
3450 zfcp_fsf_send_fcp_command_task(struct zfcp_adapter
*adapter
,
3451 struct zfcp_unit
*unit
,
3452 struct scsi_cmnd
* scsi_cmnd
,
3453 struct timer_list
*timer
, int req_flags
)
3455 struct zfcp_fsf_req
*fsf_req
= NULL
;
3456 struct fcp_cmnd_iu
*fcp_cmnd_iu
;
3457 unsigned int sbtype
;
3458 unsigned long lock_flags
;
3463 /* setup new FSF request */
3464 retval
= zfcp_fsf_req_create(adapter
, FSF_QTCB_FCP_CMND
, req_flags
,
3465 adapter
->pool
.fsf_req_scsi
,
3466 &lock_flags
, &fsf_req
);
3467 if (unlikely(retval
< 0)) {
3468 ZFCP_LOG_DEBUG("error: Could not create FCP command request "
3469 "for unit 0x%016Lx on port 0x%016Lx on "
3473 zfcp_get_busid_by_adapter(adapter
));
3474 goto failed_req_create
;
3477 zfcp_unit_get(unit
);
3478 fsf_req
->unit
= unit
;
3480 /* associate FSF request with SCSI request (for look up on abort) */
3481 scsi_cmnd
->host_scribble
= (char *) fsf_req
;
3483 /* associate SCSI command with FSF request */
3484 fsf_req
->data
= (unsigned long) scsi_cmnd
;
3486 /* set handles of unit and its parent port in QTCB */
3487 fsf_req
->qtcb
->header
.lun_handle
= unit
->handle
;
3488 fsf_req
->qtcb
->header
.port_handle
= unit
->port
->handle
;
3490 /* FSF does not define the structure of the FCP_CMND IU */
3491 fcp_cmnd_iu
= (struct fcp_cmnd_iu
*)
3492 &(fsf_req
->qtcb
->bottom
.io
.fcp_cmnd
);
3495 * set depending on data direction:
3496 * data direction bits in SBALE (SB Type)
3497 * data direction bits in QTCB
3498 * data direction bits in FCP_CMND IU
3500 switch (scsi_cmnd
->sc_data_direction
) {
3502 fsf_req
->qtcb
->bottom
.io
.data_direction
= FSF_DATADIR_CMND
;
3505 * what is the correct type for commands
3506 * without 'real' data buffers?
3508 sbtype
= SBAL_FLAGS0_TYPE_READ
;
3510 case DMA_FROM_DEVICE
:
3511 fsf_req
->qtcb
->bottom
.io
.data_direction
= FSF_DATADIR_READ
;
3512 sbtype
= SBAL_FLAGS0_TYPE_READ
;
3513 fcp_cmnd_iu
->rddata
= 1;
3516 fsf_req
->qtcb
->bottom
.io
.data_direction
= FSF_DATADIR_WRITE
;
3517 sbtype
= SBAL_FLAGS0_TYPE_WRITE
;
3518 fcp_cmnd_iu
->wddata
= 1;
3520 case DMA_BIDIRECTIONAL
:
3523 * dummy, catch this condition earlier
3524 * in zfcp_scsi_queuecommand
3526 goto failed_scsi_cmnd
;
3529 /* set FC service class in QTCB (3 per default) */
3530 fsf_req
->qtcb
->bottom
.io
.service_class
= adapter
->fc_service_class
;
3532 /* set FCP_LUN in FCP_CMND IU in QTCB */
3533 fcp_cmnd_iu
->fcp_lun
= unit
->fcp_lun
;
3535 mask
= ZFCP_STATUS_UNIT_READONLY
| ZFCP_STATUS_UNIT_SHARED
;
3537 /* set task attributes in FCP_CMND IU in QTCB */
3538 if (likely((scsi_cmnd
->device
->simple_tags
) ||
3539 (atomic_test_mask(mask
, &unit
->status
))))
3540 fcp_cmnd_iu
->task_attribute
= SIMPLE_Q
;
3542 fcp_cmnd_iu
->task_attribute
= UNTAGGED
;
3544 /* set additional length of FCP_CDB in FCP_CMND IU in QTCB, if needed */
3545 if (unlikely(scsi_cmnd
->cmd_len
> FCP_CDB_LENGTH
)) {
3546 fcp_cmnd_iu
->add_fcp_cdb_length
3547 = (scsi_cmnd
->cmd_len
- FCP_CDB_LENGTH
) >> 2;
3548 ZFCP_LOG_TRACE("SCSI CDB length is 0x%x, "
3549 "additional FCP_CDB length is 0x%x "
3550 "(shifted right 2 bits)\n",
3552 fcp_cmnd_iu
->add_fcp_cdb_length
);
3555 * copy SCSI CDB (including additional length, if any) to
3556 * FCP_CDB in FCP_CMND IU in QTCB
3558 memcpy(fcp_cmnd_iu
->fcp_cdb
, scsi_cmnd
->cmnd
, scsi_cmnd
->cmd_len
);
3560 /* FCP CMND IU length in QTCB */
3561 fsf_req
->qtcb
->bottom
.io
.fcp_cmnd_length
=
3562 sizeof (struct fcp_cmnd_iu
) +
3563 fcp_cmnd_iu
->add_fcp_cdb_length
+ sizeof (fcp_dl_t
);
3565 /* generate SBALEs from data buffer */
3566 real_bytes
= zfcp_qdio_sbals_from_scsicmnd(fsf_req
, sbtype
, scsi_cmnd
);
3567 if (unlikely(real_bytes
< 0)) {
3568 if (fsf_req
->sbal_number
< ZFCP_MAX_SBALS_PER_REQ
) {
3570 "Data did not fit into available buffer(s), "
3571 "waiting for more...\n");
3574 ZFCP_LOG_NORMAL("error: No truncation implemented but "
3575 "required. Shutting down unit "
3576 "(adapter %s, port 0x%016Lx, "
3578 zfcp_get_busid_by_unit(unit
),
3581 zfcp_erp_unit_shutdown(unit
, 0);
3587 /* set length of FCP data length in FCP_CMND IU in QTCB */
3588 zfcp_set_fcp_dl(fcp_cmnd_iu
, real_bytes
);
3590 ZFCP_LOG_DEBUG("Sending SCSI command:\n");
3591 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
3592 (char *) scsi_cmnd
->cmnd
, scsi_cmnd
->cmd_len
);
3595 * start QDIO request for this FSF request
3596 * covered by an SBALE)
3598 retval
= zfcp_fsf_req_send(fsf_req
, timer
);
3599 if (unlikely(retval
< 0)) {
3600 ZFCP_LOG_INFO("error: Could not send FCP command request "
3601 "on adapter %s, port 0x%016Lx, unit 0x%016Lx\n",
3602 zfcp_get_busid_by_adapter(adapter
),
3608 ZFCP_LOG_TRACE("Send FCP Command initiated (adapter %s, "
3609 "port 0x%016Lx, unit 0x%016Lx)\n",
3610 zfcp_get_busid_by_adapter(adapter
),
3618 zfcp_unit_put(unit
);
3619 zfcp_fsf_req_free(fsf_req
);
3621 scsi_cmnd
->host_scribble
= NULL
;
3624 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
, lock_flags
);
3629 * function: zfcp_fsf_send_fcp_command_task_management
3635 * FIXME(design): should be watched by a timeout!!!
3636 * FIXME(design) shouldn't this be modified to return an int
3637 * also...don't know how though
3640 struct zfcp_fsf_req
*
3641 zfcp_fsf_send_fcp_command_task_management(struct zfcp_adapter
*adapter
,
3642 struct zfcp_unit
*unit
,
3643 u8 tm_flags
, int req_flags
)
3645 struct zfcp_fsf_req
*fsf_req
= NULL
;
3647 struct fcp_cmnd_iu
*fcp_cmnd_iu
;
3648 unsigned long lock_flags
;
3649 volatile struct qdio_buffer_element
*sbale
;
3651 /* setup new FSF request */
3652 retval
= zfcp_fsf_req_create(adapter
, FSF_QTCB_FCP_CMND
, req_flags
,
3653 adapter
->pool
.fsf_req_scsi
,
3654 &lock_flags
, &fsf_req
);
3656 ZFCP_LOG_INFO("error: Could not create FCP command (task "
3657 "management) request for adapter %s, port "
3658 " 0x%016Lx, unit 0x%016Lx.\n",
3659 zfcp_get_busid_by_adapter(adapter
),
3660 unit
->port
->wwpn
, unit
->fcp_lun
);
3665 * Used to decide on proper handler in the return path,
3666 * could be either zfcp_fsf_send_fcp_command_task_handler or
3667 * zfcp_fsf_send_fcp_command_task_management_handler */
3669 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT
;
3672 * hold a pointer to the unit being target of this
3673 * task management request
3675 fsf_req
->data
= (unsigned long) unit
;
3677 /* set FSF related fields in QTCB */
3678 fsf_req
->qtcb
->header
.lun_handle
= unit
->handle
;
3679 fsf_req
->qtcb
->header
.port_handle
= unit
->port
->handle
;
3680 fsf_req
->qtcb
->bottom
.io
.data_direction
= FSF_DATADIR_CMND
;
3681 fsf_req
->qtcb
->bottom
.io
.service_class
= adapter
->fc_service_class
;
3682 fsf_req
->qtcb
->bottom
.io
.fcp_cmnd_length
=
3683 sizeof (struct fcp_cmnd_iu
) + sizeof (fcp_dl_t
);
3685 sbale
= zfcp_qdio_sbale_req(fsf_req
, fsf_req
->sbal_curr
, 0);
3686 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_WRITE
;
3687 sbale
[1].flags
|= SBAL_FLAGS_LAST_ENTRY
;
3689 /* set FCP related fields in FCP_CMND IU in QTCB */
3690 fcp_cmnd_iu
= (struct fcp_cmnd_iu
*)
3691 &(fsf_req
->qtcb
->bottom
.io
.fcp_cmnd
);
3692 fcp_cmnd_iu
->fcp_lun
= unit
->fcp_lun
;
3693 fcp_cmnd_iu
->task_management_flags
= tm_flags
;
3695 /* start QDIO request for this FSF request */
3696 zfcp_fsf_start_scsi_er_timer(adapter
);
3697 retval
= zfcp_fsf_req_send(fsf_req
, NULL
);
3699 del_timer(&adapter
->scsi_er_timer
);
3700 ZFCP_LOG_INFO("error: Could not send an FCP-command (task "
3701 "management) on adapter %s, port 0x%016Lx for "
3702 "unit LUN 0x%016Lx\n",
3703 zfcp_get_busid_by_adapter(adapter
),
3706 zfcp_fsf_req_free(fsf_req
);
3711 ZFCP_LOG_TRACE("Send FCP Command (task management function) initiated "
3712 "(adapter %s, port 0x%016Lx, unit 0x%016Lx, "
3714 zfcp_get_busid_by_adapter(adapter
),
3719 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
, lock_flags
);
3724 * function: zfcp_fsf_send_fcp_command_handler
3726 * purpose: is called for finished Send FCP Command
3731 zfcp_fsf_send_fcp_command_handler(struct zfcp_fsf_req
*fsf_req
)
3733 int retval
= -EINVAL
;
3734 struct zfcp_unit
*unit
;
3735 struct fsf_qtcb_header
*header
;
3736 u16 subtable
, rule
, counter
;
3738 header
= &fsf_req
->qtcb
->header
;
3740 if (unlikely(fsf_req
->status
& ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT
))
3741 unit
= (struct zfcp_unit
*) fsf_req
->data
;
3743 unit
= fsf_req
->unit
;
3745 if (unlikely(fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
)) {
3746 /* go directly to calls of special handlers */
3747 goto skip_fsfstatus
;
3750 /* evaluate FSF status in QTCB */
3751 switch (header
->fsf_status
) {
3753 case FSF_PORT_HANDLE_NOT_VALID
:
3754 ZFCP_LOG_INFO("Temporary port identifier 0x%x for port "
3755 "0x%016Lx on adapter %s invalid\n",
3757 unit
->port
->wwpn
, zfcp_get_busid_by_unit(unit
));
3758 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
3759 (char *) &header
->fsf_status_qual
,
3760 sizeof (union fsf_status_qual
));
3761 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
3763 zfcp_erp_adapter_reopen(unit
->port
->adapter
, 0);
3764 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3767 case FSF_LUN_HANDLE_NOT_VALID
:
3768 ZFCP_LOG_INFO("Temporary LUN identifier 0x%x for unit "
3769 "0x%016Lx on port 0x%016Lx on adapter %s is "
3770 "invalid. This may happen occasionally.\n",
3774 zfcp_get_busid_by_unit(unit
));
3775 ZFCP_LOG_NORMAL("Status qualifier data:\n");
3776 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_NORMAL
,
3777 (char *) &header
->fsf_status_qual
,
3778 sizeof (union fsf_status_qual
));
3779 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
3781 zfcp_erp_port_reopen(unit
->port
, 0);
3782 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3785 case FSF_HANDLE_MISMATCH
:
3786 ZFCP_LOG_NORMAL("bug: The port handle 0x%x has changed "
3787 "unexpectedly. (adapter %s, port 0x%016Lx, "
3790 zfcp_get_busid_by_unit(unit
),
3793 ZFCP_LOG_NORMAL("status qualifier:\n");
3794 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_NORMAL
,
3795 (char *) &header
->fsf_status_qual
,
3796 sizeof (union fsf_status_qual
));
3797 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
3799 zfcp_erp_adapter_reopen(unit
->port
->adapter
, 0);
3800 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3803 case FSF_SERVICE_CLASS_NOT_SUPPORTED
:
3804 if (fsf_req
->adapter
->fc_service_class
<= 3) {
3805 ZFCP_LOG_NORMAL("error: The adapter %s does "
3806 "not support fibrechannel class %d.\n",
3807 zfcp_get_busid_by_unit(unit
),
3808 fsf_req
->adapter
->fc_service_class
);
3810 ZFCP_LOG_NORMAL("bug: The fibrechannel class at "
3811 "adapter %s is invalid. "
3812 "(debug info %d)\n",
3813 zfcp_get_busid_by_unit(unit
),
3814 fsf_req
->adapter
->fc_service_class
);
3816 /* stop operation for this adapter */
3817 debug_text_exception(fsf_req
->adapter
->erp_dbf
, 0,
3818 "fsf_s_class_nsup");
3819 zfcp_erp_adapter_shutdown(unit
->port
->adapter
, 0);
3820 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3823 case FSF_FCPLUN_NOT_VALID
:
3824 ZFCP_LOG_NORMAL("bug: unit 0x%016Lx on port 0x%016Lx on "
3825 "adapter %s does not have correct unit "
3829 zfcp_get_busid_by_unit(unit
),
3831 ZFCP_LOG_DEBUG("status qualifier:\n");
3832 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
3833 (char *) &header
->fsf_status_qual
,
3834 sizeof (union fsf_status_qual
));
3835 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
3836 "fsf_s_fcp_lun_nv");
3837 zfcp_erp_port_reopen(unit
->port
, 0);
3838 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3841 case FSF_ACCESS_DENIED
:
3842 ZFCP_LOG_NORMAL("Access denied, cannot send FCP command to "
3843 "unit 0x%016Lx on port 0x%016Lx on "
3844 "adapter %s\n", unit
->fcp_lun
, unit
->port
->wwpn
,
3845 zfcp_get_busid_by_unit(unit
));
3846 for (counter
= 0; counter
< 2; counter
++) {
3847 subtable
= header
->fsf_status_qual
.halfword
[counter
* 2];
3848 rule
= header
->fsf_status_qual
.halfword
[counter
* 2 + 1];
3850 case FSF_SQ_CFDC_SUBTABLE_OS
:
3851 case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN
:
3852 case FSF_SQ_CFDC_SUBTABLE_PORT_DID
:
3853 case FSF_SQ_CFDC_SUBTABLE_LUN
:
3854 ZFCP_LOG_INFO("Access denied (%s rule %d)\n",
3855 zfcp_act_subtable_type
[subtable
], rule
);
3859 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1, "fsf_s_access");
3860 zfcp_erp_unit_access_denied(unit
);
3861 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3864 case FSF_DIRECTION_INDICATOR_NOT_VALID
:
3865 ZFCP_LOG_INFO("bug: Invalid data direction given for unit "
3866 "0x%016Lx on port 0x%016Lx on adapter %s "
3867 "(debug info %d)\n",
3870 zfcp_get_busid_by_unit(unit
),
3871 fsf_req
->qtcb
->bottom
.io
.data_direction
);
3872 /* stop operation for this adapter */
3873 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0,
3874 "fsf_s_dir_ind_nv");
3875 zfcp_erp_adapter_shutdown(unit
->port
->adapter
, 0);
3876 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3879 case FSF_CMND_LENGTH_NOT_VALID
:
3881 ("bug: An invalid control-data-block length field "
3882 "was found in a command for unit 0x%016Lx on port "
3883 "0x%016Lx on adapter %s " "(debug info %d)\n",
3884 unit
->fcp_lun
, unit
->port
->wwpn
,
3885 zfcp_get_busid_by_unit(unit
),
3886 fsf_req
->qtcb
->bottom
.io
.fcp_cmnd_length
);
3887 /* stop operation for this adapter */
3888 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0,
3889 "fsf_s_cmd_len_nv");
3890 zfcp_erp_adapter_shutdown(unit
->port
->adapter
, 0);
3891 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3894 case FSF_PORT_BOXED
:
3895 ZFCP_LOG_DEBUG("The remote port 0x%016Lx on adapter %s "
3896 "needs to be reopened\n",
3897 unit
->port
->wwpn
, zfcp_get_busid_by_unit(unit
));
3898 debug_text_event(fsf_req
->adapter
->erp_dbf
, 2, "fsf_s_pboxed");
3899 zfcp_erp_port_boxed(unit
->port
);
3900 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
|
3901 ZFCP_STATUS_FSFREQ_RETRY
;
3905 ZFCP_LOG_NORMAL("unit needs to be reopened (adapter %s, "
3906 "wwpn=0x%016Lx, fcp_lun=0x%016Lx)\n",
3907 zfcp_get_busid_by_unit(unit
),
3908 unit
->port
->wwpn
, unit
->fcp_lun
);
3909 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1, "fsf_s_lboxed");
3910 zfcp_erp_unit_boxed(unit
);
3911 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
3912 | ZFCP_STATUS_FSFREQ_RETRY
;
3915 case FSF_ADAPTER_STATUS_AVAILABLE
:
3916 switch (header
->fsf_status_qual
.word
[0]) {
3917 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE
:
3918 /* re-establish link to port */
3919 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
3921 zfcp_test_link(unit
->port
);
3923 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED
:
3924 /* FIXME(hw) need proper specs for proper action */
3925 /* let scsi stack deal with retries and escalation */
3926 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
3931 ("Unknown status qualifier 0x%x arrived.\n",
3932 header
->fsf_status_qual
.word
[0]);
3933 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0,
3935 debug_exception(fsf_req
->adapter
->erp_dbf
, 0,
3936 &header
->fsf_status_qual
.word
[0],
3940 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3946 case FSF_FCP_RSP_AVAILABLE
:
3950 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0, "fsf_s_inval:");
3951 debug_exception(fsf_req
->adapter
->erp_dbf
, 0,
3952 &header
->fsf_status
, sizeof(u32
));
3957 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT
) {
3959 zfcp_fsf_send_fcp_command_task_management_handler(fsf_req
);
3961 retval
= zfcp_fsf_send_fcp_command_task_handler(fsf_req
);
3962 fsf_req
->unit
= NULL
;
3963 zfcp_unit_put(unit
);
3969 * function: zfcp_fsf_send_fcp_command_task_handler
3971 * purpose: evaluates FCP_RSP IU
3976 zfcp_fsf_send_fcp_command_task_handler(struct zfcp_fsf_req
*fsf_req
)
3979 struct scsi_cmnd
*scpnt
;
3980 struct fcp_rsp_iu
*fcp_rsp_iu
= (struct fcp_rsp_iu
*)
3981 &(fsf_req
->qtcb
->bottom
.io
.fcp_rsp
);
3982 struct fcp_cmnd_iu
*fcp_cmnd_iu
= (struct fcp_cmnd_iu
*)
3983 &(fsf_req
->qtcb
->bottom
.io
.fcp_cmnd
);
3985 char *fcp_rsp_info
= zfcp_get_fcp_rsp_info_ptr(fcp_rsp_iu
);
3986 unsigned long flags
;
3987 struct zfcp_unit
*unit
= fsf_req
->unit
;
3989 read_lock_irqsave(&fsf_req
->adapter
->abort_lock
, flags
);
3990 scpnt
= (struct scsi_cmnd
*) fsf_req
->data
;
3991 if (unlikely(!scpnt
)) {
3993 ("Command with fsf_req %p is not associated to "
3994 "a scsi command anymore. Aborted?\n", fsf_req
);
3997 if (unlikely(fsf_req
->status
& ZFCP_STATUS_FSFREQ_ABORTED
)) {
3998 /* FIXME: (design) mid-layer should handle DID_ABORT like
3999 * DID_SOFT_ERROR by retrying the request for devices
4000 * that allow retries.
4002 ZFCP_LOG_DEBUG("Setting DID_SOFT_ERROR and SUGGEST_RETRY\n");
4003 set_host_byte(&scpnt
->result
, DID_SOFT_ERROR
);
4004 set_driver_byte(&scpnt
->result
, SUGGEST_RETRY
);
4005 goto skip_fsfstatus
;
4008 if (unlikely(fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
)) {
4009 ZFCP_LOG_DEBUG("Setting DID_ERROR\n");
4010 set_host_byte(&scpnt
->result
, DID_ERROR
);
4011 goto skip_fsfstatus
;
4014 /* set message byte of result in SCSI command */
4015 scpnt
->result
|= COMMAND_COMPLETE
<< 8;
4018 * copy SCSI status code of FCP_STATUS of FCP_RSP IU to status byte
4019 * of result in SCSI command
4021 scpnt
->result
|= fcp_rsp_iu
->scsi_status
;
4022 if (unlikely(fcp_rsp_iu
->scsi_status
)) {
4024 ZFCP_LOG_DEBUG("status for SCSI Command:\n");
4025 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
4026 scpnt
->cmnd
, scpnt
->cmd_len
);
4027 ZFCP_LOG_DEBUG("SCSI status code 0x%x\n",
4028 fcp_rsp_iu
->scsi_status
);
4029 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
4030 (void *) fcp_rsp_iu
, sizeof (struct fcp_rsp_iu
));
4031 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
4032 zfcp_get_fcp_sns_info_ptr(fcp_rsp_iu
),
4033 fcp_rsp_iu
->fcp_sns_len
);
4036 /* check FCP_RSP_INFO */
4037 if (unlikely(fcp_rsp_iu
->validity
.bits
.fcp_rsp_len_valid
)) {
4038 ZFCP_LOG_DEBUG("rsp_len is valid\n");
4039 switch (fcp_rsp_info
[3]) {
4042 ZFCP_LOG_TRACE("no failure or Task Management "
4043 "Function complete\n");
4044 set_host_byte(&scpnt
->result
, DID_OK
);
4046 case RSP_CODE_LENGTH_MISMATCH
:
4048 ZFCP_LOG_NORMAL("bug: FCP response code indictates "
4049 "that the fibrechannel protocol data "
4050 "length differs from the burst length. "
4051 "The problem occured on unit 0x%016Lx "
4052 "on port 0x%016Lx on adapter %s",
4055 zfcp_get_busid_by_unit(unit
));
4056 /* dump SCSI CDB as prepared by zfcp */
4057 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
4058 (char *) &fsf_req
->qtcb
->
4059 bottom
.io
.fcp_cmnd
, FSF_FCP_CMND_SIZE
);
4060 set_host_byte(&scpnt
->result
, DID_ERROR
);
4061 goto skip_fsfstatus
;
4062 case RSP_CODE_FIELD_INVALID
:
4063 /* driver or hardware bug */
4064 ZFCP_LOG_NORMAL("bug: FCP response code indictates "
4065 "that the fibrechannel protocol data "
4066 "fields were incorrectly set up. "
4067 "The problem occured on the unit "
4068 "0x%016Lx on port 0x%016Lx on "
4072 zfcp_get_busid_by_unit(unit
));
4073 /* dump SCSI CDB as prepared by zfcp */
4074 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
4075 (char *) &fsf_req
->qtcb
->
4076 bottom
.io
.fcp_cmnd
, FSF_FCP_CMND_SIZE
);
4077 set_host_byte(&scpnt
->result
, DID_ERROR
);
4078 goto skip_fsfstatus
;
4079 case RSP_CODE_RO_MISMATCH
:
4081 ZFCP_LOG_NORMAL("bug: The FCP response code indicates "
4082 "that conflicting values for the "
4083 "fibrechannel payload offset from the "
4084 "header were found. "
4085 "The problem occured on unit 0x%016Lx "
4086 "on port 0x%016Lx on adapter %s.\n",
4089 zfcp_get_busid_by_unit(unit
));
4090 /* dump SCSI CDB as prepared by zfcp */
4091 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
4092 (char *) &fsf_req
->qtcb
->
4093 bottom
.io
.fcp_cmnd
, FSF_FCP_CMND_SIZE
);
4094 set_host_byte(&scpnt
->result
, DID_ERROR
);
4095 goto skip_fsfstatus
;
4097 ZFCP_LOG_NORMAL("bug: An invalid FCP response "
4098 "code was detected for a command. "
4099 "The problem occured on the unit "
4100 "0x%016Lx on port 0x%016Lx on "
4101 "adapter %s (debug info 0x%x)\n",
4104 zfcp_get_busid_by_unit(unit
),
4106 /* dump SCSI CDB as prepared by zfcp */
4107 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
4108 (char *) &fsf_req
->qtcb
->
4109 bottom
.io
.fcp_cmnd
, FSF_FCP_CMND_SIZE
);
4110 set_host_byte(&scpnt
->result
, DID_ERROR
);
4111 goto skip_fsfstatus
;
4115 /* check for sense data */
4116 if (unlikely(fcp_rsp_iu
->validity
.bits
.fcp_sns_len_valid
)) {
4117 sns_len
= FSF_FCP_RSP_SIZE
-
4118 sizeof (struct fcp_rsp_iu
) + fcp_rsp_iu
->fcp_rsp_len
;
4119 ZFCP_LOG_TRACE("room for %i bytes sense data in QTCB\n",
4121 sns_len
= min(sns_len
, (u32
) SCSI_SENSE_BUFFERSIZE
);
4122 ZFCP_LOG_TRACE("room for %i bytes sense data in SCSI command\n",
4123 SCSI_SENSE_BUFFERSIZE
);
4124 sns_len
= min(sns_len
, fcp_rsp_iu
->fcp_sns_len
);
4125 ZFCP_LOG_TRACE("scpnt->result =0x%x, command was:\n",
4127 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_TRACE
,
4128 (void *) &scpnt
->cmnd
, scpnt
->cmd_len
);
4130 ZFCP_LOG_TRACE("%i bytes sense data provided by FCP\n",
4131 fcp_rsp_iu
->fcp_sns_len
);
4132 memcpy(&scpnt
->sense_buffer
,
4133 zfcp_get_fcp_sns_info_ptr(fcp_rsp_iu
), sns_len
);
4134 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_TRACE
,
4135 (void *) &scpnt
->sense_buffer
, sns_len
);
4138 /* check for overrun */
4139 if (unlikely(fcp_rsp_iu
->validity
.bits
.fcp_resid_over
)) {
4140 ZFCP_LOG_INFO("A data overrun was detected for a command. "
4141 "unit 0x%016Lx, port 0x%016Lx, adapter %s. "
4142 "The response data length is "
4143 "%d, the original length was %d.\n",
4146 zfcp_get_busid_by_unit(unit
),
4147 fcp_rsp_iu
->fcp_resid
,
4148 (int) zfcp_get_fcp_dl(fcp_cmnd_iu
));
4151 /* check for underrun */
4152 if (unlikely(fcp_rsp_iu
->validity
.bits
.fcp_resid_under
)) {
4153 ZFCP_LOG_INFO("A data underrun was detected for a command. "
4154 "unit 0x%016Lx, port 0x%016Lx, adapter %s. "
4155 "The response data length is "
4156 "%d, the original length was %d.\n",
4159 zfcp_get_busid_by_unit(unit
),
4160 fcp_rsp_iu
->fcp_resid
,
4161 (int) zfcp_get_fcp_dl(fcp_cmnd_iu
));
4163 scpnt
->resid
= fcp_rsp_iu
->fcp_resid
;
4164 if (scpnt
->request_bufflen
- scpnt
->resid
< scpnt
->underflow
)
4165 set_host_byte(&scpnt
->result
, DID_ERROR
);
4169 ZFCP_LOG_DEBUG("scpnt->result =0x%x\n", scpnt
->result
);
4171 if (scpnt
->result
!= 0)
4172 zfcp_scsi_dbf_event_result("erro", 3, fsf_req
->adapter
, scpnt
);
4173 else if (scpnt
->retries
> 0)
4174 zfcp_scsi_dbf_event_result("retr", 4, fsf_req
->adapter
, scpnt
);
4176 zfcp_scsi_dbf_event_result("norm", 6, fsf_req
->adapter
, scpnt
);
4178 /* cleanup pointer (need this especially for abort) */
4179 scpnt
->host_scribble
= NULL
;
4181 /* always call back */
4182 (scpnt
->scsi_done
) (scpnt
);
4185 * We must hold this lock until scsi_done has been called.
4186 * Otherwise we may call scsi_done after abort regarding this
4187 * command has completed.
4188 * Note: scsi_done must not block!
4191 read_unlock_irqrestore(&fsf_req
->adapter
->abort_lock
, flags
);
4196 * function: zfcp_fsf_send_fcp_command_task_management_handler
4198 * purpose: evaluates FCP_RSP IU
4203 zfcp_fsf_send_fcp_command_task_management_handler(struct zfcp_fsf_req
*fsf_req
)
4206 struct fcp_rsp_iu
*fcp_rsp_iu
= (struct fcp_rsp_iu
*)
4207 &(fsf_req
->qtcb
->bottom
.io
.fcp_rsp
);
4208 char *fcp_rsp_info
= zfcp_get_fcp_rsp_info_ptr(fcp_rsp_iu
);
4209 struct zfcp_unit
*unit
= (struct zfcp_unit
*) fsf_req
->data
;
4211 del_timer(&fsf_req
->adapter
->scsi_er_timer
);
4212 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
) {
4213 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_TMFUNCFAILED
;
4214 goto skip_fsfstatus
;
4217 /* check FCP_RSP_INFO */
4218 switch (fcp_rsp_info
[3]) {
4221 ZFCP_LOG_DEBUG("no failure or Task Management "
4222 "Function complete\n");
4224 case RSP_CODE_TASKMAN_UNSUPP
:
4225 ZFCP_LOG_NORMAL("bug: A reuested task management function "
4226 "is not supported on the target device "
4227 "unit 0x%016Lx, port 0x%016Lx, adapter %s\n ",
4230 zfcp_get_busid_by_unit(unit
));
4231 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_TMFUNCNOTSUPP
;
4233 case RSP_CODE_TASKMAN_FAILED
:
4234 ZFCP_LOG_NORMAL("bug: A reuested task management function "
4235 "failed to complete successfully. "
4236 "unit 0x%016Lx, port 0x%016Lx, adapter %s.\n",
4239 zfcp_get_busid_by_unit(unit
));
4240 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_TMFUNCFAILED
;
4243 ZFCP_LOG_NORMAL("bug: An invalid FCP response "
4244 "code was detected for a command. "
4245 "unit 0x%016Lx, port 0x%016Lx, adapter %s "
4246 "(debug info 0x%x)\n",
4249 zfcp_get_busid_by_unit(unit
),
4251 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_TMFUNCFAILED
;
4260 * function: zfcp_fsf_control_file
4262 * purpose: Initiator of the control file upload/download FSF requests
4264 * returns: 0 - FSF request is successfuly created and queued
4265 * -EOPNOTSUPP - The FCP adapter does not have Control File support
4266 * -EINVAL - Invalid direction specified
4267 * -ENOMEM - Insufficient memory
4268 * -EPERM - Cannot create FSF request or place it in QDIO queue
4271 zfcp_fsf_control_file(struct zfcp_adapter
*adapter
,
4272 struct zfcp_fsf_req
**fsf_req_ptr
,
4275 struct zfcp_sg_list
*sg_list
)
4277 struct zfcp_fsf_req
*fsf_req
;
4278 struct fsf_qtcb_bottom_support
*bottom
;
4279 volatile struct qdio_buffer_element
*sbale
;
4280 struct timer_list
*timer
;
4281 unsigned long lock_flags
;
4286 if (!(adapter
->adapter_features
& FSF_FEATURE_CFDC
)) {
4287 ZFCP_LOG_INFO("cfdc not supported (adapter %s)\n",
4288 zfcp_get_busid_by_adapter(adapter
));
4289 retval
= -EOPNOTSUPP
;
4293 switch (fsf_command
) {
4295 case FSF_QTCB_DOWNLOAD_CONTROL_FILE
:
4296 direction
= SBAL_FLAGS0_TYPE_WRITE
;
4297 if ((option
!= FSF_CFDC_OPTION_FULL_ACCESS
) &&
4298 (option
!= FSF_CFDC_OPTION_RESTRICTED_ACCESS
))
4299 req_flags
= ZFCP_WAIT_FOR_SBAL
;
4302 case FSF_QTCB_UPLOAD_CONTROL_FILE
:
4303 direction
= SBAL_FLAGS0_TYPE_READ
;
4307 ZFCP_LOG_INFO("Invalid FSF command code 0x%08x\n", fsf_command
);
4312 timer
= kmalloc(sizeof(struct timer_list
), GFP_KERNEL
);
4318 retval
= zfcp_fsf_req_create(adapter
, fsf_command
, req_flags
,
4319 NULL
, &lock_flags
, &fsf_req
);
4321 ZFCP_LOG_INFO("error: Could not create FSF request for the "
4323 zfcp_get_busid_by_adapter(adapter
));
4325 goto unlock_queue_lock
;
4328 sbale
= zfcp_qdio_sbale_req(fsf_req
, fsf_req
->sbal_curr
, 0);
4329 sbale
[0].flags
|= direction
;
4331 bottom
= &fsf_req
->qtcb
->bottom
.support
;
4332 bottom
->operation_subtype
= FSF_CFDC_OPERATION_SUBTYPE
;
4333 bottom
->option
= option
;
4335 if (sg_list
->count
> 0) {
4338 bytes
= zfcp_qdio_sbals_from_sg(fsf_req
, direction
,
4339 sg_list
->sg
, sg_list
->count
,
4340 ZFCP_MAX_SBALS_PER_REQ
);
4341 if (bytes
!= ZFCP_CFDC_MAX_CONTROL_FILE_SIZE
) {
4343 "error: Could not create sufficient number of "
4344 "SBALS for an FSF request to the adapter %s\n",
4345 zfcp_get_busid_by_adapter(adapter
));
4350 sbale
[1].flags
|= SBAL_FLAGS_LAST_ENTRY
;
4353 timer
->function
= zfcp_fsf_request_timeout_handler
;
4354 timer
->data
= (unsigned long) adapter
;
4355 timer
->expires
= ZFCP_FSF_REQUEST_TIMEOUT
;
4357 retval
= zfcp_fsf_req_send(fsf_req
, timer
);
4359 ZFCP_LOG_INFO("initiation of cfdc up/download failed"
4361 zfcp_get_busid_by_adapter(adapter
));
4365 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
, lock_flags
);
4367 ZFCP_LOG_NORMAL("Control file %s FSF request has been sent to the "
4369 fsf_command
== FSF_QTCB_DOWNLOAD_CONTROL_FILE
?
4370 "download" : "upload",
4371 zfcp_get_busid_by_adapter(adapter
));
4373 wait_event(fsf_req
->completion_wq
,
4374 fsf_req
->status
& ZFCP_STATUS_FSFREQ_COMPLETED
);
4376 *fsf_req_ptr
= fsf_req
;
4377 del_timer_sync(timer
);
4381 zfcp_fsf_req_free(fsf_req
);
4383 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
, lock_flags
);
4392 * function: zfcp_fsf_control_file_handler
4394 * purpose: Handler of the control file upload/download FSF requests
4396 * returns: 0 - FSF request successfuly processed
4397 * -EAGAIN - Operation has to be repeated because of a temporary problem
4398 * -EACCES - There is no permission to execute an operation
4399 * -EPERM - The control file is not in a right format
4400 * -EIO - There is a problem with the FCP adapter
4401 * -EINVAL - Invalid operation
4402 * -EFAULT - User space memory I/O operation fault
4405 zfcp_fsf_control_file_handler(struct zfcp_fsf_req
*fsf_req
)
4407 struct zfcp_adapter
*adapter
= fsf_req
->adapter
;
4408 struct fsf_qtcb_header
*header
= &fsf_req
->qtcb
->header
;
4409 struct fsf_qtcb_bottom_support
*bottom
= &fsf_req
->qtcb
->bottom
.support
;
4412 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
) {
4414 goto skip_fsfstatus
;
4417 switch (header
->fsf_status
) {
4421 "The FSF request has been successfully completed "
4422 "on the adapter %s\n",
4423 zfcp_get_busid_by_adapter(adapter
));
4426 case FSF_OPERATION_PARTIALLY_SUCCESSFUL
:
4427 if (bottom
->operation_subtype
== FSF_CFDC_OPERATION_SUBTYPE
) {
4428 switch (header
->fsf_status_qual
.word
[0]) {
4430 case FSF_SQ_CFDC_HARDENED_ON_SE
:
4432 "CFDC on the adapter %s has being "
4433 "hardened on primary and secondary SE\n",
4434 zfcp_get_busid_by_adapter(adapter
));
4437 case FSF_SQ_CFDC_COULD_NOT_HARDEN_ON_SE
:
4439 "CFDC of the adapter %s could not "
4440 "be saved on the SE\n",
4441 zfcp_get_busid_by_adapter(adapter
));
4444 case FSF_SQ_CFDC_COULD_NOT_HARDEN_ON_SE2
:
4446 "CFDC of the adapter %s could not "
4447 "be copied to the secondary SE\n",
4448 zfcp_get_busid_by_adapter(adapter
));
4453 "CFDC could not be hardened "
4454 "on the adapter %s\n",
4455 zfcp_get_busid_by_adapter(adapter
));
4458 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4462 case FSF_AUTHORIZATION_FAILURE
:
4464 "Adapter %s does not accept privileged commands\n",
4465 zfcp_get_busid_by_adapter(adapter
));
4466 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4470 case FSF_CFDC_ERROR_DETECTED
:
4472 "Error at position %d in the CFDC, "
4473 "CFDC is discarded by the adapter %s\n",
4474 header
->fsf_status_qual
.word
[0],
4475 zfcp_get_busid_by_adapter(adapter
));
4476 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4480 case FSF_CONTROL_FILE_UPDATE_ERROR
:
4482 "Adapter %s cannot harden the control file, "
4483 "file is discarded\n",
4484 zfcp_get_busid_by_adapter(adapter
));
4485 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4489 case FSF_CONTROL_FILE_TOO_LARGE
:
4491 "Control file is too large, file is discarded "
4492 "by the adapter %s\n",
4493 zfcp_get_busid_by_adapter(adapter
));
4494 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4498 case FSF_ACCESS_CONFLICT_DETECTED
:
4499 if (bottom
->operation_subtype
== FSF_CFDC_OPERATION_SUBTYPE
)
4501 "CFDC has been discarded by the adapter %s, "
4502 "because activation would impact "
4503 "%d active connection(s)\n",
4504 zfcp_get_busid_by_adapter(adapter
),
4505 header
->fsf_status_qual
.word
[0]);
4506 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4510 case FSF_CONFLICTS_OVERRULED
:
4511 if (bottom
->operation_subtype
== FSF_CFDC_OPERATION_SUBTYPE
)
4513 "CFDC has been activated on the adapter %s, "
4514 "but activation has impacted "
4515 "%d active connection(s)\n",
4516 zfcp_get_busid_by_adapter(adapter
),
4517 header
->fsf_status_qual
.word
[0]);
4518 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4522 case FSF_UNKNOWN_OP_SUBTYPE
:
4523 ZFCP_LOG_NORMAL("unknown operation subtype (adapter: %s, "
4524 "op_subtype=0x%x)\n",
4525 zfcp_get_busid_by_adapter(adapter
),
4526 bottom
->operation_subtype
);
4527 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4531 case FSF_INVALID_COMMAND_OPTION
:
4533 "Invalid option 0x%x has been specified "
4534 "in QTCB bottom sent to the adapter %s\n",
4536 zfcp_get_busid_by_adapter(adapter
));
4537 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4543 "bug: An unknown/unexpected FSF status 0x%08x "
4544 "was presented on the adapter %s\n",
4546 zfcp_get_busid_by_adapter(adapter
));
4547 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0, "fsf_sq_inval");
4548 debug_exception(fsf_req
->adapter
->erp_dbf
, 0,
4549 &header
->fsf_status_qual
.word
[0], sizeof(u32
));
4550 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4560 zfcp_fsf_req_sbal_check(unsigned long *flags
,
4561 struct zfcp_qdio_queue
*queue
, int needed
)
4563 write_lock_irqsave(&queue
->queue_lock
, *flags
);
4564 if (likely(atomic_read(&queue
->free_count
) >= needed
))
4566 write_unlock_irqrestore(&queue
->queue_lock
, *flags
);
4571 * set qtcb pointer in fsf_req and initialize QTCB
4574 zfcp_fsf_req_qtcb_init(struct zfcp_fsf_req
*fsf_req
)
4576 if (likely(fsf_req
->qtcb
!= NULL
)) {
4577 fsf_req
->qtcb
->prefix
.req_seq_no
= fsf_req
->adapter
->fsf_req_seq_no
;
4578 fsf_req
->qtcb
->prefix
.req_id
= (unsigned long)fsf_req
;
4579 fsf_req
->qtcb
->prefix
.ulp_info
= ZFCP_ULP_INFO_VERSION
;
4580 fsf_req
->qtcb
->prefix
.qtcb_type
= fsf_qtcb_type
[fsf_req
->fsf_command
];
4581 fsf_req
->qtcb
->prefix
.qtcb_version
= ZFCP_QTCB_VERSION
;
4582 fsf_req
->qtcb
->header
.req_handle
= (unsigned long)fsf_req
;
4583 fsf_req
->qtcb
->header
.fsf_command
= fsf_req
->fsf_command
;
4588 * zfcp_fsf_req_sbal_get - try to get one SBAL in the request queue
4589 * @adapter: adapter for which request queue is examined
4590 * @req_flags: flags indicating whether to wait for needed SBAL or not
4591 * @lock_flags: lock_flags if queue_lock is taken
4592 * Return: 0 on success, otherwise -EIO, or -ERESTARTSYS
4593 * Locks: lock adapter->request_queue->queue_lock on success
4596 zfcp_fsf_req_sbal_get(struct zfcp_adapter
*adapter
, int req_flags
,
4597 unsigned long *lock_flags
)
4600 struct zfcp_qdio_queue
*req_queue
= &adapter
->request_queue
;
4602 if (unlikely(req_flags
& ZFCP_WAIT_FOR_SBAL
)) {
4603 ret
= wait_event_interruptible_timeout(adapter
->request_wq
,
4604 zfcp_fsf_req_sbal_check(lock_flags
, req_queue
, 1),
4610 } else if (!zfcp_fsf_req_sbal_check(lock_flags
, req_queue
, 1))
4617 * function: zfcp_fsf_req_create
4619 * purpose: create an FSF request at the specified adapter and
4620 * setup common fields
4622 * returns: -ENOMEM if there was insufficient memory for a request
4623 * -EIO if no qdio buffers could be allocate to the request
4624 * -EINVAL/-EPERM on bug conditions in req_dequeue
4627 * note: The created request is returned by reference.
4629 * locks: lock of concerned request queue must not be held,
4630 * but is held on completion (write, irqsave)
4633 zfcp_fsf_req_create(struct zfcp_adapter
*adapter
, u32 fsf_cmd
, int req_flags
,
4634 mempool_t
*pool
, unsigned long *lock_flags
,
4635 struct zfcp_fsf_req
**fsf_req_p
)
4637 volatile struct qdio_buffer_element
*sbale
;
4638 struct zfcp_fsf_req
*fsf_req
= NULL
;
4640 struct zfcp_qdio_queue
*req_queue
= &adapter
->request_queue
;
4642 /* allocate new FSF request */
4643 fsf_req
= zfcp_fsf_req_alloc(pool
, req_flags
);
4644 if (unlikely(NULL
== fsf_req
)) {
4645 ZFCP_LOG_DEBUG("error: Could not put an FSF request into"
4646 "the outbound (send) queue.\n");
4648 goto failed_fsf_req
;
4651 fsf_req
->adapter
= adapter
;
4652 fsf_req
->fsf_command
= fsf_cmd
;
4654 zfcp_fsf_req_qtcb_init(fsf_req
);
4656 /* initialize waitqueue which may be used to wait on
4657 this request completion */
4658 init_waitqueue_head(&fsf_req
->completion_wq
);
4660 ret
= zfcp_fsf_req_sbal_get(adapter
, req_flags
, lock_flags
);
4666 * We hold queue_lock here. Check if QDIOUP is set and let request fail
4667 * if it is not set (see also *_open_qdio and *_close_qdio).
4670 if (!atomic_test_mask(ZFCP_STATUS_ADAPTER_QDIOUP
, &adapter
->status
)) {
4671 write_unlock_irqrestore(&req_queue
->queue_lock
, *lock_flags
);
4676 if (fsf_req
->qtcb
) {
4677 fsf_req
->seq_no
= adapter
->fsf_req_seq_no
;
4678 fsf_req
->qtcb
->prefix
.req_seq_no
= adapter
->fsf_req_seq_no
;
4680 fsf_req
->sbal_number
= 1;
4681 fsf_req
->sbal_first
= req_queue
->free_index
;
4682 fsf_req
->sbal_curr
= req_queue
->free_index
;
4683 fsf_req
->sbale_curr
= 1;
4685 if (likely(req_flags
& ZFCP_REQ_AUTO_CLEANUP
)) {
4686 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_CLEANUP
;
4689 sbale
= zfcp_qdio_sbale_req(fsf_req
, fsf_req
->sbal_curr
, 0);
4691 /* setup common SBALE fields */
4692 sbale
[0].addr
= fsf_req
;
4693 sbale
[0].flags
|= SBAL_FLAGS0_COMMAND
;
4694 if (likely(fsf_req
->qtcb
!= NULL
)) {
4695 sbale
[1].addr
= (void *) fsf_req
->qtcb
;
4696 sbale
[1].length
= sizeof(struct fsf_qtcb
);
4699 ZFCP_LOG_TRACE("got %i free BUFFERs starting at index %i\n",
4700 fsf_req
->sbal_number
, fsf_req
->sbal_first
);
4705 /* dequeue new FSF request previously enqueued */
4706 zfcp_fsf_req_free(fsf_req
);
4710 write_lock_irqsave(&req_queue
->queue_lock
, *lock_flags
);
4712 *fsf_req_p
= fsf_req
;
4717 * function: zfcp_fsf_req_send
4719 * purpose: start transfer of FSF request via QDIO
4721 * returns: 0 - request transfer succesfully started
4722 * !0 - start of request transfer failed
4725 zfcp_fsf_req_send(struct zfcp_fsf_req
*fsf_req
, struct timer_list
*timer
)
4727 struct zfcp_adapter
*adapter
;
4728 struct zfcp_qdio_queue
*req_queue
;
4729 volatile struct qdio_buffer_element
*sbale
;
4731 int new_distance_from_int
;
4732 unsigned long flags
;
4735 adapter
= fsf_req
->adapter
;
4736 req_queue
= &adapter
->request_queue
,
4739 /* FIXME(debug): remove it later */
4740 sbale
= zfcp_qdio_sbale_req(fsf_req
, fsf_req
->sbal_first
, 0);
4741 ZFCP_LOG_DEBUG("SBALE0 flags=0x%x\n", sbale
[0].flags
);
4742 ZFCP_LOG_TRACE("HEX DUMP OF SBALE1 PAYLOAD:\n");
4743 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_TRACE
, (char *) sbale
[1].addr
,
4746 /* put allocated FSF request at list tail */
4747 spin_lock_irqsave(&adapter
->fsf_req_list_lock
, flags
);
4748 list_add_tail(&fsf_req
->list
, &adapter
->fsf_req_list_head
);
4749 spin_unlock_irqrestore(&adapter
->fsf_req_list_lock
, flags
);
4751 inc_seq_no
= (fsf_req
->qtcb
!= NULL
);
4753 /* figure out expiration time of timeout and start timeout */
4754 if (unlikely(timer
)) {
4755 timer
->expires
+= jiffies
;
4759 ZFCP_LOG_TRACE("request queue of adapter %s: "
4760 "next free SBAL is %i, %i free SBALs\n",
4761 zfcp_get_busid_by_adapter(adapter
),
4762 req_queue
->free_index
,
4763 atomic_read(&req_queue
->free_count
));
4765 ZFCP_LOG_DEBUG("calling do_QDIO adapter %s, flags=0x%x, queue_no=%i, "
4766 "index_in_queue=%i, count=%i, buffers=%p\n",
4767 zfcp_get_busid_by_adapter(adapter
),
4768 QDIO_FLAG_SYNC_OUTPUT
,
4769 0, fsf_req
->sbal_first
, fsf_req
->sbal_number
,
4770 &req_queue
->buffer
[fsf_req
->sbal_first
]);
4773 * adjust the number of free SBALs in request queue as well as
4774 * position of first one
4776 atomic_sub(fsf_req
->sbal_number
, &req_queue
->free_count
);
4777 ZFCP_LOG_TRACE("free_count=%d\n", atomic_read(&req_queue
->free_count
));
4778 req_queue
->free_index
+= fsf_req
->sbal_number
; /* increase */
4779 req_queue
->free_index
%= QDIO_MAX_BUFFERS_PER_Q
; /* wrap if needed */
4780 new_distance_from_int
= zfcp_qdio_determine_pci(req_queue
, fsf_req
);
4782 fsf_req
->issued
= get_clock();
4784 retval
= do_QDIO(adapter
->ccw_device
,
4785 QDIO_FLAG_SYNC_OUTPUT
,
4786 0, fsf_req
->sbal_first
, fsf_req
->sbal_number
, NULL
);
4788 if (unlikely(retval
)) {
4789 /* Queues are down..... */
4792 * FIXME(potential race):
4793 * timer might be expired (absolutely unlikely)
4797 spin_lock_irqsave(&adapter
->fsf_req_list_lock
, flags
);
4798 list_del(&fsf_req
->list
);
4799 spin_unlock_irqrestore(&adapter
->fsf_req_list_lock
, flags
);
4801 * adjust the number of free SBALs in request queue as well as
4802 * position of first one
4804 zfcp_qdio_zero_sbals(req_queue
->buffer
,
4805 fsf_req
->sbal_first
, fsf_req
->sbal_number
);
4806 atomic_add(fsf_req
->sbal_number
, &req_queue
->free_count
);
4807 req_queue
->free_index
-= fsf_req
->sbal_number
; /* increase */
4808 req_queue
->free_index
+= QDIO_MAX_BUFFERS_PER_Q
;
4809 req_queue
->free_index
%= QDIO_MAX_BUFFERS_PER_Q
; /* wrap */
4811 ("error: do_QDIO failed. Buffers could not be enqueued "
4812 "to request queue.\n");
4814 req_queue
->distance_from_int
= new_distance_from_int
;
4816 * increase FSF sequence counter -
4817 * this must only be done for request successfully enqueued to
4818 * QDIO this rejected requests may be cleaned up by calling
4819 * routines resulting in missing sequence counter values
4823 /* Don't increase for unsolicited status */
4825 adapter
->fsf_req_seq_no
++;
4827 /* count FSF requests pending */
4828 atomic_inc(&adapter
->fsf_reqs_active
);
4833 #undef ZFCP_LOG_AREA