2 * This file is part of the zfcp device driver for
3 * FCP adapters for IBM System z9 and zSeries.
5 * (C) Copyright IBM Corp. 2002, 2006
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 static int zfcp_fsf_exchange_config_data_handler(struct zfcp_fsf_req
*);
25 static void zfcp_fsf_exchange_port_data_handler(struct zfcp_fsf_req
*);
26 static int zfcp_fsf_open_port_handler(struct zfcp_fsf_req
*);
27 static int zfcp_fsf_close_port_handler(struct zfcp_fsf_req
*);
28 static int zfcp_fsf_close_physical_port_handler(struct zfcp_fsf_req
*);
29 static int zfcp_fsf_open_unit_handler(struct zfcp_fsf_req
*);
30 static int zfcp_fsf_close_unit_handler(struct zfcp_fsf_req
*);
31 static int zfcp_fsf_send_fcp_command_handler(struct zfcp_fsf_req
*);
32 static int zfcp_fsf_send_fcp_command_task_handler(struct zfcp_fsf_req
*);
33 static int zfcp_fsf_send_fcp_command_task_management_handler(
34 struct zfcp_fsf_req
*);
35 static int zfcp_fsf_abort_fcp_command_handler(struct zfcp_fsf_req
*);
36 static int zfcp_fsf_status_read_handler(struct zfcp_fsf_req
*);
37 static int zfcp_fsf_send_ct_handler(struct zfcp_fsf_req
*);
38 static int zfcp_fsf_send_els_handler(struct zfcp_fsf_req
*);
39 static int zfcp_fsf_control_file_handler(struct zfcp_fsf_req
*);
40 static inline int zfcp_fsf_req_sbal_check(
41 unsigned long *, struct zfcp_qdio_queue
*, int);
42 static inline int zfcp_use_one_sbal(
43 struct scatterlist
*, int, struct scatterlist
*, int);
44 static struct zfcp_fsf_req
*zfcp_fsf_req_alloc(mempool_t
*, int);
45 static int zfcp_fsf_req_send(struct zfcp_fsf_req
*, struct timer_list
*);
46 static int zfcp_fsf_protstatus_eval(struct zfcp_fsf_req
*);
47 static int zfcp_fsf_fsfstatus_eval(struct zfcp_fsf_req
*);
48 static int zfcp_fsf_fsfstatus_qual_eval(struct zfcp_fsf_req
*);
49 static void zfcp_fsf_link_down_info_eval(struct zfcp_adapter
*,
50 struct fsf_link_down_info
*);
51 static int zfcp_fsf_req_dispatch(struct zfcp_fsf_req
*);
52 static void zfcp_fsf_req_dismiss(struct zfcp_fsf_req
*);
54 /* association between FSF command and FSF QTCB type */
55 static u32 fsf_qtcb_type
[] = {
56 [FSF_QTCB_FCP_CMND
] = FSF_IO_COMMAND
,
57 [FSF_QTCB_ABORT_FCP_CMND
] = FSF_SUPPORT_COMMAND
,
58 [FSF_QTCB_OPEN_PORT_WITH_DID
] = FSF_SUPPORT_COMMAND
,
59 [FSF_QTCB_OPEN_LUN
] = FSF_SUPPORT_COMMAND
,
60 [FSF_QTCB_CLOSE_LUN
] = FSF_SUPPORT_COMMAND
,
61 [FSF_QTCB_CLOSE_PORT
] = FSF_SUPPORT_COMMAND
,
62 [FSF_QTCB_CLOSE_PHYSICAL_PORT
] = FSF_SUPPORT_COMMAND
,
63 [FSF_QTCB_SEND_ELS
] = FSF_SUPPORT_COMMAND
,
64 [FSF_QTCB_SEND_GENERIC
] = FSF_SUPPORT_COMMAND
,
65 [FSF_QTCB_EXCHANGE_CONFIG_DATA
] = FSF_CONFIG_COMMAND
,
66 [FSF_QTCB_EXCHANGE_PORT_DATA
] = FSF_PORT_COMMAND
,
67 [FSF_QTCB_DOWNLOAD_CONTROL_FILE
] = FSF_SUPPORT_COMMAND
,
68 [FSF_QTCB_UPLOAD_CONTROL_FILE
] = FSF_SUPPORT_COMMAND
71 static const char zfcp_act_subtable_type
[5][8] = {
72 "unknown", "OS", "WWPN", "DID", "LUN"
75 /****************************************************************/
76 /*************** FSF related Functions *************************/
77 /****************************************************************/
79 #define ZFCP_LOG_AREA ZFCP_LOG_AREA_FSF
82 * function: zfcp_fsf_req_alloc
84 * purpose: Obtains an fsf_req and potentially a qtcb (for all but
85 * unsolicited requests) via helper functions
86 * Does some initial fsf request set-up.
88 * returns: pointer to allocated fsf_req if successfull
94 static struct zfcp_fsf_req
*
95 zfcp_fsf_req_alloc(mempool_t
*pool
, int req_flags
)
99 struct zfcp_fsf_req
*fsf_req
= NULL
;
101 if (req_flags
& ZFCP_REQ_NO_QTCB
)
102 size
= sizeof(struct zfcp_fsf_req
);
104 size
= sizeof(struct zfcp_fsf_req_pool_element
);
106 if (likely(pool
!= NULL
))
107 ptr
= mempool_alloc(pool
, GFP_ATOMIC
);
109 ptr
= kmalloc(size
, GFP_ATOMIC
);
111 if (unlikely(NULL
== ptr
))
114 memset(ptr
, 0, size
);
116 if (req_flags
& ZFCP_REQ_NO_QTCB
) {
117 fsf_req
= (struct zfcp_fsf_req
*) ptr
;
119 fsf_req
= &((struct zfcp_fsf_req_pool_element
*) ptr
)->fsf_req
;
121 &((struct zfcp_fsf_req_pool_element
*) ptr
)->qtcb
;
124 fsf_req
->pool
= pool
;
131 * function: zfcp_fsf_req_free
133 * purpose: Frees the memory of an fsf_req (and potentially a qtcb) or
134 * returns it into the pool via helper functions.
141 zfcp_fsf_req_free(struct zfcp_fsf_req
*fsf_req
)
143 if (likely(fsf_req
->pool
!= NULL
))
144 mempool_free(fsf_req
, fsf_req
->pool
);
156 * note: qdio queues shall be down (no ongoing inbound processing)
159 zfcp_fsf_req_dismiss_all(struct zfcp_adapter
*adapter
)
161 struct zfcp_fsf_req
*fsf_req
, *tmp
;
163 LIST_HEAD(remove_queue
);
165 spin_lock_irqsave(&adapter
->fsf_req_list_lock
, flags
);
166 list_splice_init(&adapter
->fsf_req_list_head
, &remove_queue
);
167 atomic_set(&adapter
->fsf_reqs_active
, 0);
168 spin_unlock_irqrestore(&adapter
->fsf_req_list_lock
, flags
);
170 list_for_each_entry_safe(fsf_req
, tmp
, &remove_queue
, list
) {
171 list_del(&fsf_req
->list
);
172 zfcp_fsf_req_dismiss(fsf_req
);
186 zfcp_fsf_req_dismiss(struct zfcp_fsf_req
*fsf_req
)
188 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_DISMISSED
;
189 zfcp_fsf_req_complete(fsf_req
);
193 * function: zfcp_fsf_req_complete
195 * purpose: Updates active counts and timers for openfcp-reqs
196 * May cleanup request after req_eval returns
198 * returns: 0 - success
204 zfcp_fsf_req_complete(struct zfcp_fsf_req
*fsf_req
)
209 if (unlikely(fsf_req
->fsf_command
== FSF_QTCB_UNSOLICITED_STATUS
)) {
210 ZFCP_LOG_DEBUG("Status read response received\n");
212 * Note: all cleanup handling is done in the callchain of
213 * the function call-chain below.
215 zfcp_fsf_status_read_handler(fsf_req
);
218 zfcp_fsf_protstatus_eval(fsf_req
);
221 * fsf_req may be deleted due to waking up functions, so
222 * cleanup is saved here and used later
224 if (likely(fsf_req
->status
& ZFCP_STATUS_FSFREQ_CLEANUP
))
229 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_COMPLETED
;
231 /* cleanup request if requested by initiator */
232 if (likely(cleanup
)) {
233 ZFCP_LOG_TRACE("removing FSF request %p\n", fsf_req
);
235 * lock must not be held here since it will be
236 * grabed by the called routine, too
238 zfcp_fsf_req_free(fsf_req
);
240 /* notify initiator waiting for the requests completion */
241 ZFCP_LOG_TRACE("waking initiator of FSF request %p\n",fsf_req
);
243 * FIXME: Race! We must not access fsf_req here as it might have been
244 * cleaned up already due to the set ZFCP_STATUS_FSFREQ_COMPLETED
245 * flag. It's an improbable case. But, we have the same paranoia for
246 * the cleanup flag already.
247 * Might better be handled using complete()?
248 * (setting the flag and doing wakeup ought to be atomic
249 * with regard to checking the flag as long as waitqueue is
250 * part of the to be released structure)
252 wake_up(&fsf_req
->completion_wq
);
260 * function: zfcp_fsf_protstatus_eval
262 * purpose: evaluates the QTCB of the finished FSF request
263 * and initiates appropriate actions
264 * (usually calling FSF command specific handlers)
273 zfcp_fsf_protstatus_eval(struct zfcp_fsf_req
*fsf_req
)
276 struct zfcp_adapter
*adapter
= fsf_req
->adapter
;
277 struct fsf_qtcb
*qtcb
= fsf_req
->qtcb
;
278 union fsf_prot_status_qual
*prot_status_qual
=
279 &qtcb
->prefix
.prot_status_qual
;
281 zfcp_hba_dbf_event_fsf_response(fsf_req
);
283 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_DISMISSED
) {
284 ZFCP_LOG_DEBUG("fsf_req 0x%lx has been dismissed\n",
285 (unsigned long) fsf_req
);
286 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
|
287 ZFCP_STATUS_FSFREQ_RETRY
; /* only for SCSI cmnds. */
288 goto skip_protstatus
;
291 /* log additional information provided by FSF (if any) */
292 if (unlikely(qtcb
->header
.log_length
)) {
293 /* do not trust them ;-) */
294 if (qtcb
->header
.log_start
> sizeof(struct fsf_qtcb
)) {
296 ("bug: ULP (FSF logging) log data starts "
297 "beyond end of packet header. Ignored. "
298 "(start=%i, size=%li)\n",
299 qtcb
->header
.log_start
,
300 sizeof(struct fsf_qtcb
));
303 if ((size_t) (qtcb
->header
.log_start
+ qtcb
->header
.log_length
)
304 > sizeof(struct fsf_qtcb
)) {
305 ZFCP_LOG_NORMAL("bug: ULP (FSF logging) log data ends "
306 "beyond end of packet header. Ignored. "
307 "(start=%i, length=%i, size=%li)\n",
308 qtcb
->header
.log_start
,
309 qtcb
->header
.log_length
,
310 sizeof(struct fsf_qtcb
));
313 ZFCP_LOG_TRACE("ULP log data: \n");
314 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_TRACE
,
315 (char *) qtcb
+ qtcb
->header
.log_start
,
316 qtcb
->header
.log_length
);
320 /* evaluate FSF Protocol Status */
321 switch (qtcb
->prefix
.prot_status
) {
324 case FSF_PROT_FSF_STATUS_PRESENTED
:
327 case FSF_PROT_QTCB_VERSION_ERROR
:
328 ZFCP_LOG_NORMAL("error: The adapter %s contains "
329 "microcode of version 0x%x, the device driver "
330 "only supports 0x%x. Aborting.\n",
331 zfcp_get_busid_by_adapter(adapter
),
332 prot_status_qual
->version_error
.fsf_version
,
334 zfcp_erp_adapter_shutdown(adapter
, 0);
335 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
338 case FSF_PROT_SEQ_NUMB_ERROR
:
339 ZFCP_LOG_NORMAL("bug: Sequence number mismatch between "
340 "driver (0x%x) and adapter %s (0x%x). "
341 "Restarting all operations on this adapter.\n",
342 qtcb
->prefix
.req_seq_no
,
343 zfcp_get_busid_by_adapter(adapter
),
344 prot_status_qual
->sequence_error
.exp_req_seq_no
);
345 zfcp_erp_adapter_reopen(adapter
, 0);
346 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_RETRY
;
347 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
350 case FSF_PROT_UNSUPP_QTCB_TYPE
:
351 ZFCP_LOG_NORMAL("error: Packet header type used by the "
352 "device driver is incompatible with "
353 "that used on adapter %s. "
354 "Stopping all operations on this adapter.\n",
355 zfcp_get_busid_by_adapter(adapter
));
356 zfcp_erp_adapter_shutdown(adapter
, 0);
357 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
360 case FSF_PROT_HOST_CONNECTION_INITIALIZING
:
361 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
362 atomic_set_mask(ZFCP_STATUS_ADAPTER_HOST_CON_INIT
,
366 case FSF_PROT_DUPLICATE_REQUEST_ID
:
367 ZFCP_LOG_NORMAL("bug: The request identifier 0x%Lx "
368 "to the adapter %s is ambiguous. "
369 "Stopping all operations on this adapter.\n",
370 *(unsigned long long*)
371 (&qtcb
->bottom
.support
.req_handle
),
372 zfcp_get_busid_by_adapter(adapter
));
373 zfcp_erp_adapter_shutdown(adapter
, 0);
374 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
377 case FSF_PROT_LINK_DOWN
:
378 zfcp_fsf_link_down_info_eval(adapter
,
379 &prot_status_qual
->link_down_info
);
380 zfcp_erp_adapter_reopen(adapter
, 0);
381 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
384 case FSF_PROT_REEST_QUEUE
:
385 ZFCP_LOG_NORMAL("The local link to adapter with "
386 "%s was re-plugged. "
387 "Re-starting operations on this adapter.\n",
388 zfcp_get_busid_by_adapter(adapter
));
389 /* All ports should be marked as ready to run again */
390 zfcp_erp_modify_adapter_status(adapter
,
391 ZFCP_STATUS_COMMON_RUNNING
,
393 zfcp_erp_adapter_reopen(adapter
,
394 ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED
395 | ZFCP_STATUS_COMMON_ERP_FAILED
);
396 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
399 case FSF_PROT_ERROR_STATE
:
400 ZFCP_LOG_NORMAL("error: The adapter %s "
401 "has entered the error state. "
402 "Restarting all operations on this "
404 zfcp_get_busid_by_adapter(adapter
));
405 zfcp_erp_adapter_reopen(adapter
, 0);
406 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_RETRY
;
407 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
411 ZFCP_LOG_NORMAL("bug: Transfer protocol status information "
412 "provided by the adapter %s "
413 "is not compatible with the device driver. "
414 "Stopping all operations on this adapter. "
415 "(debug info 0x%x).\n",
416 zfcp_get_busid_by_adapter(adapter
),
417 qtcb
->prefix
.prot_status
);
418 zfcp_erp_adapter_shutdown(adapter
, 0);
419 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
424 * always call specific handlers to give them a chance to do
425 * something meaningful even in error cases
427 zfcp_fsf_fsfstatus_eval(fsf_req
);
432 * function: zfcp_fsf_fsfstatus_eval
434 * purpose: evaluates FSF status of completed FSF request
435 * and acts accordingly
440 zfcp_fsf_fsfstatus_eval(struct zfcp_fsf_req
*fsf_req
)
444 if (unlikely(fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
)) {
448 /* evaluate FSF Status */
449 switch (fsf_req
->qtcb
->header
.fsf_status
) {
450 case FSF_UNKNOWN_COMMAND
:
451 ZFCP_LOG_NORMAL("bug: Command issued by the device driver is "
452 "not known by the adapter %s "
453 "Stopping all operations on this adapter. "
454 "(debug info 0x%x).\n",
455 zfcp_get_busid_by_adapter(fsf_req
->adapter
),
456 fsf_req
->qtcb
->header
.fsf_command
);
457 zfcp_erp_adapter_shutdown(fsf_req
->adapter
, 0);
458 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
461 case FSF_FCP_RSP_AVAILABLE
:
462 ZFCP_LOG_DEBUG("FCP Sense data will be presented to the "
466 case FSF_ADAPTER_STATUS_AVAILABLE
:
467 zfcp_fsf_fsfstatus_qual_eval(fsf_req
);
473 * always call specific handlers to give them a chance to do
474 * something meaningful even in error cases
476 zfcp_fsf_req_dispatch(fsf_req
);
482 * function: zfcp_fsf_fsfstatus_qual_eval
484 * purpose: evaluates FSF status-qualifier of completed FSF request
485 * and acts accordingly
490 zfcp_fsf_fsfstatus_qual_eval(struct zfcp_fsf_req
*fsf_req
)
494 switch (fsf_req
->qtcb
->header
.fsf_status_qual
.word
[0]) {
495 case FSF_SQ_FCP_RSP_AVAILABLE
:
497 case FSF_SQ_RETRY_IF_POSSIBLE
:
498 /* The SCSI-stack may now issue retries or escalate */
499 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
501 case FSF_SQ_COMMAND_ABORTED
:
502 /* Carry the aborted state on to upper layer */
503 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ABORTED
;
504 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
506 case FSF_SQ_NO_RECOM
:
507 ZFCP_LOG_NORMAL("bug: No recommendation could be given for a"
508 "problem on the adapter %s "
509 "Stopping all operations on this adapter. ",
510 zfcp_get_busid_by_adapter(fsf_req
->adapter
));
511 zfcp_erp_adapter_shutdown(fsf_req
->adapter
, 0);
512 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
514 case FSF_SQ_ULP_PROGRAMMING_ERROR
:
515 ZFCP_LOG_NORMAL("error: not enough SBALs for data transfer "
517 zfcp_get_busid_by_adapter(fsf_req
->adapter
));
518 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
520 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE
:
521 case FSF_SQ_NO_RETRY_POSSIBLE
:
522 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED
:
523 /* dealt with in the respective functions */
526 ZFCP_LOG_NORMAL("bug: Additional status info could "
527 "not be interpreted properly.\n");
528 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_NORMAL
,
529 (char *) &fsf_req
->qtcb
->header
.fsf_status_qual
,
530 sizeof (union fsf_status_qual
));
531 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
539 * zfcp_fsf_link_down_info_eval - evaluate link down information block
542 zfcp_fsf_link_down_info_eval(struct zfcp_adapter
*adapter
,
543 struct fsf_link_down_info
*link_down
)
545 if (atomic_test_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED
,
549 atomic_set_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED
, &adapter
->status
);
551 if (link_down
== NULL
)
554 switch (link_down
->error_code
) {
555 case FSF_PSQ_LINK_NO_LIGHT
:
556 ZFCP_LOG_NORMAL("The local link to adapter %s is down "
557 "(no light detected)\n",
558 zfcp_get_busid_by_adapter(adapter
));
560 case FSF_PSQ_LINK_WRAP_PLUG
:
561 ZFCP_LOG_NORMAL("The local link to adapter %s is down "
562 "(wrap plug detected)\n",
563 zfcp_get_busid_by_adapter(adapter
));
565 case FSF_PSQ_LINK_NO_FCP
:
566 ZFCP_LOG_NORMAL("The local link to adapter %s is down "
567 "(adjacent node on link does not support FCP)\n",
568 zfcp_get_busid_by_adapter(adapter
));
570 case FSF_PSQ_LINK_FIRMWARE_UPDATE
:
571 ZFCP_LOG_NORMAL("The local link to adapter %s is down "
572 "(firmware update in progress)\n",
573 zfcp_get_busid_by_adapter(adapter
));
575 case FSF_PSQ_LINK_INVALID_WWPN
:
576 ZFCP_LOG_NORMAL("The local link to adapter %s is down "
577 "(duplicate or invalid WWPN detected)\n",
578 zfcp_get_busid_by_adapter(adapter
));
580 case FSF_PSQ_LINK_NO_NPIV_SUPPORT
:
581 ZFCP_LOG_NORMAL("The local link to adapter %s is down "
582 "(no support for NPIV by Fabric)\n",
583 zfcp_get_busid_by_adapter(adapter
));
585 case FSF_PSQ_LINK_NO_FCP_RESOURCES
:
586 ZFCP_LOG_NORMAL("The local link to adapter %s is down "
587 "(out of resource in FCP daughtercard)\n",
588 zfcp_get_busid_by_adapter(adapter
));
590 case FSF_PSQ_LINK_NO_FABRIC_RESOURCES
:
591 ZFCP_LOG_NORMAL("The local link to adapter %s is down "
592 "(out of resource in Fabric)\n",
593 zfcp_get_busid_by_adapter(adapter
));
595 case FSF_PSQ_LINK_FABRIC_LOGIN_UNABLE
:
596 ZFCP_LOG_NORMAL("The local link to adapter %s is down "
597 "(unable to Fabric login)\n",
598 zfcp_get_busid_by_adapter(adapter
));
600 case FSF_PSQ_LINK_WWPN_ASSIGNMENT_CORRUPTED
:
601 ZFCP_LOG_NORMAL("WWPN assignment file corrupted on adapter %s\n",
602 zfcp_get_busid_by_adapter(adapter
));
604 case FSF_PSQ_LINK_MODE_TABLE_CURRUPTED
:
605 ZFCP_LOG_NORMAL("Mode table corrupted on adapter %s\n",
606 zfcp_get_busid_by_adapter(adapter
));
608 case FSF_PSQ_LINK_NO_WWPN_ASSIGNMENT
:
609 ZFCP_LOG_NORMAL("No WWPN for assignment table on adapter %s\n",
610 zfcp_get_busid_by_adapter(adapter
));
613 ZFCP_LOG_NORMAL("The local link to adapter %s is down "
614 "(warning: unknown reason code %d)\n",
615 zfcp_get_busid_by_adapter(adapter
),
616 link_down
->error_code
);
619 if (adapter
->connection_features
& FSF_FEATURE_NPIV_MODE
)
620 ZFCP_LOG_DEBUG("Debug information to link down: "
621 "primary_status=0x%02x "
623 "action_code=0x%02x "
624 "reason_code=0x%02x "
625 "explanation_code=0x%02x "
626 "vendor_specific_code=0x%02x\n",
627 link_down
->primary_status
,
628 link_down
->ioerr_code
,
629 link_down
->action_code
,
630 link_down
->reason_code
,
631 link_down
->explanation_code
,
632 link_down
->vendor_specific_code
);
635 zfcp_erp_adapter_failed(adapter
);
639 * function: zfcp_fsf_req_dispatch
641 * purpose: calls the appropriate command specific handler
646 zfcp_fsf_req_dispatch(struct zfcp_fsf_req
*fsf_req
)
648 struct zfcp_erp_action
*erp_action
= fsf_req
->erp_action
;
649 struct zfcp_adapter
*adapter
= fsf_req
->adapter
;
653 switch (fsf_req
->fsf_command
) {
655 case FSF_QTCB_FCP_CMND
:
656 zfcp_fsf_send_fcp_command_handler(fsf_req
);
659 case FSF_QTCB_ABORT_FCP_CMND
:
660 zfcp_fsf_abort_fcp_command_handler(fsf_req
);
663 case FSF_QTCB_SEND_GENERIC
:
664 zfcp_fsf_send_ct_handler(fsf_req
);
667 case FSF_QTCB_OPEN_PORT_WITH_DID
:
668 zfcp_fsf_open_port_handler(fsf_req
);
671 case FSF_QTCB_OPEN_LUN
:
672 zfcp_fsf_open_unit_handler(fsf_req
);
675 case FSF_QTCB_CLOSE_LUN
:
676 zfcp_fsf_close_unit_handler(fsf_req
);
679 case FSF_QTCB_CLOSE_PORT
:
680 zfcp_fsf_close_port_handler(fsf_req
);
683 case FSF_QTCB_CLOSE_PHYSICAL_PORT
:
684 zfcp_fsf_close_physical_port_handler(fsf_req
);
687 case FSF_QTCB_EXCHANGE_CONFIG_DATA
:
688 zfcp_fsf_exchange_config_data_handler(fsf_req
);
691 case FSF_QTCB_EXCHANGE_PORT_DATA
:
692 zfcp_fsf_exchange_port_data_handler(fsf_req
);
695 case FSF_QTCB_SEND_ELS
:
696 zfcp_fsf_send_els_handler(fsf_req
);
699 case FSF_QTCB_DOWNLOAD_CONTROL_FILE
:
700 zfcp_fsf_control_file_handler(fsf_req
);
703 case FSF_QTCB_UPLOAD_CONTROL_FILE
:
704 zfcp_fsf_control_file_handler(fsf_req
);
708 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
709 ZFCP_LOG_NORMAL("bug: Command issued by the device driver is "
710 "not supported by the adapter %s\n",
711 zfcp_get_busid_by_adapter(adapter
));
712 if (fsf_req
->fsf_command
!= fsf_req
->qtcb
->header
.fsf_command
)
714 ("bug: Command issued by the device driver differs "
715 "from the command returned by the adapter %s "
716 "(debug info 0x%x, 0x%x).\n",
717 zfcp_get_busid_by_adapter(adapter
),
718 fsf_req
->fsf_command
,
719 fsf_req
->qtcb
->header
.fsf_command
);
725 zfcp_erp_async_handler(erp_action
, 0);
731 * function: zfcp_fsf_status_read
733 * purpose: initiates a Status Read command at the specified adapter
738 zfcp_fsf_status_read(struct zfcp_adapter
*adapter
, int req_flags
)
740 struct zfcp_fsf_req
*fsf_req
;
741 struct fsf_status_read_buffer
*status_buffer
;
742 unsigned long lock_flags
;
743 volatile struct qdio_buffer_element
*sbale
;
746 /* setup new FSF request */
747 retval
= zfcp_fsf_req_create(adapter
, FSF_QTCB_UNSOLICITED_STATUS
,
748 req_flags
| ZFCP_REQ_NO_QTCB
,
749 adapter
->pool
.fsf_req_status_read
,
750 &lock_flags
, &fsf_req
);
752 ZFCP_LOG_INFO("error: Could not create unsolicited status "
753 "buffer for adapter %s.\n",
754 zfcp_get_busid_by_adapter(adapter
));
755 goto failed_req_create
;
758 sbale
= zfcp_qdio_sbale_req(fsf_req
, fsf_req
->sbal_curr
, 0);
759 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_STATUS
;
760 sbale
[2].flags
|= SBAL_FLAGS_LAST_ENTRY
;
761 fsf_req
->sbale_curr
= 2;
764 mempool_alloc(adapter
->pool
.data_status_read
, GFP_ATOMIC
);
765 if (!status_buffer
) {
766 ZFCP_LOG_NORMAL("bug: could not get some buffer\n");
769 memset(status_buffer
, 0, sizeof (struct fsf_status_read_buffer
));
770 fsf_req
->data
= (unsigned long) status_buffer
;
772 /* insert pointer to respective buffer */
773 sbale
= zfcp_qdio_sbale_curr(fsf_req
);
774 sbale
->addr
= (void *) status_buffer
;
775 sbale
->length
= sizeof(struct fsf_status_read_buffer
);
777 /* start QDIO request for this FSF request */
778 retval
= zfcp_fsf_req_send(fsf_req
, NULL
);
780 ZFCP_LOG_DEBUG("error: Could not set-up unsolicited status "
782 goto failed_req_send
;
785 ZFCP_LOG_TRACE("Status Read request initiated (adapter%s)\n",
786 zfcp_get_busid_by_adapter(adapter
));
790 mempool_free(status_buffer
, adapter
->pool
.data_status_read
);
793 zfcp_fsf_req_free(fsf_req
);
795 zfcp_hba_dbf_event_fsf_unsol("fail", adapter
, NULL
);
797 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
, lock_flags
);
802 zfcp_fsf_status_read_port_closed(struct zfcp_fsf_req
*fsf_req
)
804 struct fsf_status_read_buffer
*status_buffer
;
805 struct zfcp_adapter
*adapter
;
806 struct zfcp_port
*port
;
809 status_buffer
= (struct fsf_status_read_buffer
*) fsf_req
->data
;
810 adapter
= fsf_req
->adapter
;
812 read_lock_irqsave(&zfcp_data
.config_lock
, flags
);
813 list_for_each_entry(port
, &adapter
->port_list_head
, list
)
814 if (port
->d_id
== (status_buffer
->d_id
& ZFCP_DID_MASK
))
816 read_unlock_irqrestore(&zfcp_data
.config_lock
, flags
);
818 if (!port
|| (port
->d_id
!= (status_buffer
->d_id
& ZFCP_DID_MASK
))) {
819 ZFCP_LOG_NORMAL("bug: Reopen port indication received for"
820 "nonexisting port with d_id 0x%08x on "
821 "adapter %s. Ignored.\n",
822 status_buffer
->d_id
& ZFCP_DID_MASK
,
823 zfcp_get_busid_by_adapter(adapter
));
827 switch (status_buffer
->status_subtype
) {
829 case FSF_STATUS_READ_SUB_CLOSE_PHYS_PORT
:
830 debug_text_event(adapter
->erp_dbf
, 3, "unsol_pc_phys:");
831 zfcp_erp_port_reopen(port
, 0);
834 case FSF_STATUS_READ_SUB_ERROR_PORT
:
835 debug_text_event(adapter
->erp_dbf
, 1, "unsol_pc_err:");
836 zfcp_erp_port_shutdown(port
, 0);
840 debug_text_event(adapter
->erp_dbf
, 0, "unsol_unk_sub:");
841 debug_exception(adapter
->erp_dbf
, 0,
842 &status_buffer
->status_subtype
, sizeof (u32
));
843 ZFCP_LOG_NORMAL("bug: Undefined status subtype received "
844 "for a reopen indication on port with "
845 "d_id 0x%08x on the adapter %s. "
846 "Ignored. (debug info 0x%x)\n",
848 zfcp_get_busid_by_adapter(adapter
),
849 status_buffer
->status_subtype
);
856 * function: zfcp_fsf_status_read_handler
858 * purpose: is called for finished Open Port command
863 zfcp_fsf_status_read_handler(struct zfcp_fsf_req
*fsf_req
)
866 struct zfcp_adapter
*adapter
= fsf_req
->adapter
;
867 struct fsf_status_read_buffer
*status_buffer
=
868 (struct fsf_status_read_buffer
*) fsf_req
->data
;
869 struct fsf_bit_error_payload
*fsf_bit_error
;
871 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_DISMISSED
) {
872 zfcp_hba_dbf_event_fsf_unsol("dism", adapter
, status_buffer
);
873 mempool_free(status_buffer
, adapter
->pool
.data_status_read
);
874 zfcp_fsf_req_free(fsf_req
);
878 zfcp_hba_dbf_event_fsf_unsol("read", adapter
, status_buffer
);
880 switch (status_buffer
->status_type
) {
882 case FSF_STATUS_READ_PORT_CLOSED
:
883 zfcp_fsf_status_read_port_closed(fsf_req
);
886 case FSF_STATUS_READ_INCOMING_ELS
:
887 zfcp_fsf_incoming_els(fsf_req
);
890 case FSF_STATUS_READ_SENSE_DATA_AVAIL
:
891 ZFCP_LOG_INFO("unsolicited sense data received (adapter %s)\n",
892 zfcp_get_busid_by_adapter(adapter
));
895 case FSF_STATUS_READ_BIT_ERROR_THRESHOLD
:
896 fsf_bit_error
= (struct fsf_bit_error_payload
*)
897 status_buffer
->payload
;
898 ZFCP_LOG_NORMAL("Warning: bit error threshold data "
899 "received (adapter %s, "
900 "link failures = %i, loss of sync errors = %i, "
901 "loss of signal errors = %i, "
902 "primitive sequence errors = %i, "
903 "invalid transmission word errors = %i, "
904 "CRC errors = %i)\n",
905 zfcp_get_busid_by_adapter(adapter
),
906 fsf_bit_error
->link_failure_error_count
,
907 fsf_bit_error
->loss_of_sync_error_count
,
908 fsf_bit_error
->loss_of_signal_error_count
,
909 fsf_bit_error
->primitive_sequence_error_count
,
910 fsf_bit_error
->invalid_transmission_word_error_count
,
911 fsf_bit_error
->crc_error_count
);
912 ZFCP_LOG_INFO("Additional bit error threshold data "
914 "primitive sequence event time-outs = %i, "
915 "elastic buffer overrun errors = %i, "
916 "advertised receive buffer-to-buffer credit = %i, "
917 "current receice buffer-to-buffer credit = %i, "
918 "advertised transmit buffer-to-buffer credit = %i, "
919 "current transmit buffer-to-buffer credit = %i)\n",
920 zfcp_get_busid_by_adapter(adapter
),
921 fsf_bit_error
->primitive_sequence_event_timeout_count
,
922 fsf_bit_error
->elastic_buffer_overrun_error_count
,
923 fsf_bit_error
->advertised_receive_b2b_credit
,
924 fsf_bit_error
->current_receive_b2b_credit
,
925 fsf_bit_error
->advertised_transmit_b2b_credit
,
926 fsf_bit_error
->current_transmit_b2b_credit
);
929 case FSF_STATUS_READ_LINK_DOWN
:
930 switch (status_buffer
->status_subtype
) {
931 case FSF_STATUS_READ_SUB_NO_PHYSICAL_LINK
:
932 ZFCP_LOG_INFO("Physical link to adapter %s is down\n",
933 zfcp_get_busid_by_adapter(adapter
));
934 zfcp_fsf_link_down_info_eval(adapter
,
935 (struct fsf_link_down_info
*)
936 &status_buffer
->payload
);
938 case FSF_STATUS_READ_SUB_FDISC_FAILED
:
939 ZFCP_LOG_INFO("Local link to adapter %s is down "
940 "due to failed FDISC login\n",
941 zfcp_get_busid_by_adapter(adapter
));
942 zfcp_fsf_link_down_info_eval(adapter
,
943 (struct fsf_link_down_info
*)
944 &status_buffer
->payload
);
946 case FSF_STATUS_READ_SUB_FIRMWARE_UPDATE
:
947 ZFCP_LOG_INFO("Local link to adapter %s is down "
948 "due to firmware update on adapter\n",
949 zfcp_get_busid_by_adapter(adapter
));
950 zfcp_fsf_link_down_info_eval(adapter
, NULL
);
953 ZFCP_LOG_INFO("Local link to adapter %s is down "
954 "due to unknown reason\n",
955 zfcp_get_busid_by_adapter(adapter
));
956 zfcp_fsf_link_down_info_eval(adapter
, NULL
);
960 case FSF_STATUS_READ_LINK_UP
:
961 ZFCP_LOG_NORMAL("Local link to adapter %s was replugged. "
962 "Restarting operations on this adapter\n",
963 zfcp_get_busid_by_adapter(adapter
));
964 /* All ports should be marked as ready to run again */
965 zfcp_erp_modify_adapter_status(adapter
,
966 ZFCP_STATUS_COMMON_RUNNING
,
968 zfcp_erp_adapter_reopen(adapter
,
969 ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED
970 | ZFCP_STATUS_COMMON_ERP_FAILED
);
973 case FSF_STATUS_READ_NOTIFICATION_LOST
:
974 ZFCP_LOG_NORMAL("Unsolicited status notification(s) lost: "
975 "adapter %s%s%s%s%s%s%s%s%s\n",
976 zfcp_get_busid_by_adapter(adapter
),
977 (status_buffer
->status_subtype
&
978 FSF_STATUS_READ_SUB_INCOMING_ELS
) ?
979 ", incoming ELS" : "",
980 (status_buffer
->status_subtype
&
981 FSF_STATUS_READ_SUB_SENSE_DATA
) ?
983 (status_buffer
->status_subtype
&
984 FSF_STATUS_READ_SUB_LINK_STATUS
) ?
985 ", link status change" : "",
986 (status_buffer
->status_subtype
&
987 FSF_STATUS_READ_SUB_PORT_CLOSED
) ?
989 (status_buffer
->status_subtype
&
990 FSF_STATUS_READ_SUB_BIT_ERROR_THRESHOLD
) ?
991 ", bit error exception" : "",
992 (status_buffer
->status_subtype
&
993 FSF_STATUS_READ_SUB_ACT_UPDATED
) ?
995 (status_buffer
->status_subtype
&
996 FSF_STATUS_READ_SUB_ACT_HARDENED
) ?
997 ", ACT hardening" : "",
998 (status_buffer
->status_subtype
&
999 FSF_STATUS_READ_SUB_FEATURE_UPDATE_ALERT
) ?
1000 ", adapter feature change" : "");
1002 if (status_buffer
->status_subtype
&
1003 FSF_STATUS_READ_SUB_ACT_UPDATED
)
1004 zfcp_erp_adapter_access_changed(adapter
);
1007 case FSF_STATUS_READ_CFDC_UPDATED
:
1008 ZFCP_LOG_NORMAL("CFDC has been updated on the adapter %s\n",
1009 zfcp_get_busid_by_adapter(adapter
));
1010 zfcp_erp_adapter_access_changed(adapter
);
1013 case FSF_STATUS_READ_CFDC_HARDENED
:
1014 switch (status_buffer
->status_subtype
) {
1015 case FSF_STATUS_READ_SUB_CFDC_HARDENED_ON_SE
:
1016 ZFCP_LOG_NORMAL("CFDC of adapter %s saved on SE\n",
1017 zfcp_get_busid_by_adapter(adapter
));
1019 case FSF_STATUS_READ_SUB_CFDC_HARDENED_ON_SE2
:
1020 ZFCP_LOG_NORMAL("CFDC of adapter %s has been copied "
1021 "to the secondary SE\n",
1022 zfcp_get_busid_by_adapter(adapter
));
1025 ZFCP_LOG_NORMAL("CFDC of adapter %s has been hardened\n",
1026 zfcp_get_busid_by_adapter(adapter
));
1030 case FSF_STATUS_READ_FEATURE_UPDATE_ALERT
:
1031 debug_text_event(adapter
->erp_dbf
, 2, "unsol_features:");
1032 ZFCP_LOG_INFO("List of supported features on adapter %s has "
1033 "been changed from 0x%08X to 0x%08X\n",
1034 zfcp_get_busid_by_adapter(adapter
),
1035 *(u32
*) (status_buffer
->payload
+ 4),
1036 *(u32
*) (status_buffer
->payload
));
1037 adapter
->adapter_features
= *(u32
*) status_buffer
->payload
;
1041 ZFCP_LOG_NORMAL("warning: An unsolicited status packet of unknown "
1042 "type was received (debug info 0x%x)\n",
1043 status_buffer
->status_type
);
1044 ZFCP_LOG_DEBUG("Dump of status_read_buffer %p:\n",
1046 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
1047 (char *) status_buffer
,
1048 sizeof (struct fsf_status_read_buffer
));
1051 mempool_free(status_buffer
, adapter
->pool
.data_status_read
);
1052 zfcp_fsf_req_free(fsf_req
);
1054 * recycle buffer and start new request repeat until outbound
1055 * queue is empty or adapter shutdown is requested
1059 * we may wait in the req_create for 5s during shutdown, so
1060 * qdio_cleanup will have to wait at least that long before returning
1061 * with failure to allow us a proper cleanup under all circumstances
1065 * allocation failure possible? (Is this code needed?)
1067 retval
= zfcp_fsf_status_read(adapter
, 0);
1069 ZFCP_LOG_INFO("Failed to create unsolicited status read "
1070 "request for the adapter %s.\n",
1071 zfcp_get_busid_by_adapter(adapter
));
1072 /* temporary fix to avoid status read buffer shortage */
1073 adapter
->status_read_failed
++;
1074 if ((ZFCP_STATUS_READS_RECOM
- adapter
->status_read_failed
)
1075 < ZFCP_STATUS_READ_FAILED_THRESHOLD
) {
1076 ZFCP_LOG_INFO("restart adapter %s due to status read "
1077 "buffer shortage\n",
1078 zfcp_get_busid_by_adapter(adapter
));
1079 zfcp_erp_adapter_reopen(adapter
, 0);
1087 * function: zfcp_fsf_abort_fcp_command
1089 * purpose: tells FSF to abort a running SCSI command
1091 * returns: address of initiated FSF request
1092 * NULL - request could not be initiated
1094 * FIXME(design): should be watched by a timeout !!!
1095 * FIXME(design) shouldn't this be modified to return an int
1096 * also...don't know how though
1098 struct zfcp_fsf_req
*
1099 zfcp_fsf_abort_fcp_command(unsigned long old_req_id
,
1100 struct zfcp_adapter
*adapter
,
1101 struct zfcp_unit
*unit
, int req_flags
)
1103 volatile struct qdio_buffer_element
*sbale
;
1104 unsigned long lock_flags
;
1105 struct zfcp_fsf_req
*fsf_req
= NULL
;
1108 /* setup new FSF request */
1109 retval
= zfcp_fsf_req_create(adapter
, FSF_QTCB_ABORT_FCP_CMND
,
1110 req_flags
, adapter
->pool
.fsf_req_abort
,
1111 &lock_flags
, &fsf_req
);
1113 ZFCP_LOG_INFO("error: Failed to create an abort command "
1114 "request for lun 0x%016Lx on port 0x%016Lx "
1118 zfcp_get_busid_by_adapter(adapter
));
1122 sbale
= zfcp_qdio_sbale_req(fsf_req
, fsf_req
->sbal_curr
, 0);
1123 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_READ
;
1124 sbale
[1].flags
|= SBAL_FLAGS_LAST_ENTRY
;
1126 fsf_req
->data
= (unsigned long) unit
;
1128 /* set handles of unit and its parent port in QTCB */
1129 fsf_req
->qtcb
->header
.lun_handle
= unit
->handle
;
1130 fsf_req
->qtcb
->header
.port_handle
= unit
->port
->handle
;
1132 /* set handle of request which should be aborted */
1133 fsf_req
->qtcb
->bottom
.support
.req_handle
= (u64
) old_req_id
;
1135 /* start QDIO request for this FSF request */
1137 zfcp_fsf_start_scsi_er_timer(adapter
);
1138 retval
= zfcp_fsf_req_send(fsf_req
, NULL
);
1140 del_timer(&adapter
->scsi_er_timer
);
1141 ZFCP_LOG_INFO("error: Failed to send abort command request "
1142 "on adapter %s, port 0x%016Lx, unit 0x%016Lx\n",
1143 zfcp_get_busid_by_adapter(adapter
),
1144 unit
->port
->wwpn
, unit
->fcp_lun
);
1145 zfcp_fsf_req_free(fsf_req
);
1150 ZFCP_LOG_DEBUG("Abort FCP Command request initiated "
1151 "(adapter%s, port d_id=0x%08x, "
1152 "unit x%016Lx, old_req_id=0x%lx)\n",
1153 zfcp_get_busid_by_adapter(adapter
),
1155 unit
->fcp_lun
, old_req_id
);
1157 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
, lock_flags
);
1162 * function: zfcp_fsf_abort_fcp_command_handler
1164 * purpose: is called for finished Abort FCP Command request
1169 zfcp_fsf_abort_fcp_command_handler(struct zfcp_fsf_req
*new_fsf_req
)
1171 int retval
= -EINVAL
;
1172 struct zfcp_unit
*unit
;
1173 unsigned char status_qual
=
1174 new_fsf_req
->qtcb
->header
.fsf_status_qual
.word
[0];
1176 del_timer(&new_fsf_req
->adapter
->scsi_er_timer
);
1178 if (new_fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
) {
1179 /* do not set ZFCP_STATUS_FSFREQ_ABORTSUCCEEDED */
1180 goto skip_fsfstatus
;
1183 unit
= (struct zfcp_unit
*) new_fsf_req
->data
;
1185 /* evaluate FSF status in QTCB */
1186 switch (new_fsf_req
->qtcb
->header
.fsf_status
) {
1188 case FSF_PORT_HANDLE_NOT_VALID
:
1189 if (status_qual
>> 4 != status_qual
% 0xf) {
1190 debug_text_event(new_fsf_req
->adapter
->erp_dbf
, 3,
1193 * In this case a command that was sent prior to a port
1194 * reopen was aborted (handles are different). This is
1198 ZFCP_LOG_INFO("Temporary port identifier 0x%x for "
1199 "port 0x%016Lx on adapter %s invalid. "
1200 "This may happen occasionally.\n",
1203 zfcp_get_busid_by_unit(unit
));
1204 ZFCP_LOG_INFO("status qualifier:\n");
1205 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_INFO
,
1206 (char *) &new_fsf_req
->qtcb
->header
.
1208 sizeof (union fsf_status_qual
));
1209 /* Let's hope this sorts out the mess */
1210 debug_text_event(new_fsf_req
->adapter
->erp_dbf
, 1,
1212 zfcp_erp_adapter_reopen(unit
->port
->adapter
, 0);
1213 new_fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1217 case FSF_LUN_HANDLE_NOT_VALID
:
1218 if (status_qual
>> 4 != status_qual
% 0xf) {
1220 debug_text_event(new_fsf_req
->adapter
->erp_dbf
, 3,
1223 * In this case a command that was sent prior to a unit
1224 * reopen was aborted (handles are different).
1229 ("Warning: Temporary LUN identifier 0x%x of LUN "
1230 "0x%016Lx on port 0x%016Lx on adapter %s is "
1231 "invalid. This may happen in rare cases. "
1232 "Trying to re-establish link.\n",
1236 zfcp_get_busid_by_unit(unit
));
1237 ZFCP_LOG_DEBUG("Status qualifier data:\n");
1238 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
1239 (char *) &new_fsf_req
->qtcb
->header
.
1241 sizeof (union fsf_status_qual
));
1242 /* Let's hope this sorts out the mess */
1243 debug_text_event(new_fsf_req
->adapter
->erp_dbf
, 1,
1245 zfcp_erp_port_reopen(unit
->port
, 0);
1246 new_fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1250 case FSF_FCP_COMMAND_DOES_NOT_EXIST
:
1252 debug_text_event(new_fsf_req
->adapter
->erp_dbf
, 3,
1254 new_fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ABORTNOTNEEDED
;
1257 case FSF_PORT_BOXED
:
1258 ZFCP_LOG_INFO("Remote port 0x%016Lx on adapter %s needs to "
1259 "be reopened\n", unit
->port
->wwpn
,
1260 zfcp_get_busid_by_unit(unit
));
1261 debug_text_event(new_fsf_req
->adapter
->erp_dbf
, 2,
1263 zfcp_erp_port_boxed(unit
->port
);
1264 new_fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
1265 | ZFCP_STATUS_FSFREQ_RETRY
;
1270 "unit 0x%016Lx on port 0x%016Lx on adapter %s needs "
1272 unit
->fcp_lun
, unit
->port
->wwpn
,
1273 zfcp_get_busid_by_unit(unit
));
1274 debug_text_event(new_fsf_req
->adapter
->erp_dbf
, 1, "fsf_s_lboxed");
1275 zfcp_erp_unit_boxed(unit
);
1276 new_fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
1277 | ZFCP_STATUS_FSFREQ_RETRY
;
1280 case FSF_ADAPTER_STATUS_AVAILABLE
:
1281 switch (new_fsf_req
->qtcb
->header
.fsf_status_qual
.word
[0]) {
1282 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE
:
1283 debug_text_event(new_fsf_req
->adapter
->erp_dbf
, 1,
1285 zfcp_test_link(unit
->port
);
1286 new_fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1288 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED
:
1289 /* SCSI stack will escalate */
1290 debug_text_event(new_fsf_req
->adapter
->erp_dbf
, 1,
1292 new_fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1296 ("bug: Wrong status qualifier 0x%x arrived.\n",
1297 new_fsf_req
->qtcb
->header
.fsf_status_qual
.word
[0]);
1298 debug_text_event(new_fsf_req
->adapter
->erp_dbf
, 0,
1300 debug_exception(new_fsf_req
->adapter
->erp_dbf
, 0,
1301 &new_fsf_req
->qtcb
->header
.
1302 fsf_status_qual
.word
[0], sizeof (u32
));
1309 new_fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ABORTSUCCEEDED
;
1313 ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
1314 "(debug info 0x%x)\n",
1315 new_fsf_req
->qtcb
->header
.fsf_status
);
1316 debug_text_event(new_fsf_req
->adapter
->erp_dbf
, 0,
1318 debug_exception(new_fsf_req
->adapter
->erp_dbf
, 0,
1319 &new_fsf_req
->qtcb
->header
.fsf_status
,
1328 * zfcp_use_one_sbal - checks whether req buffer and resp bother each fit into
1330 * Two scatter-gather lists are passed, one for the reqeust and one for the
1334 zfcp_use_one_sbal(struct scatterlist
*req
, int req_count
,
1335 struct scatterlist
*resp
, int resp_count
)
1337 return ((req_count
== 1) &&
1338 (resp_count
== 1) &&
1339 (((unsigned long) zfcp_sg_to_address(&req
[0]) &
1341 ((unsigned long) (zfcp_sg_to_address(&req
[0]) +
1342 req
[0].length
- 1) & PAGE_MASK
)) &&
1343 (((unsigned long) zfcp_sg_to_address(&resp
[0]) &
1345 ((unsigned long) (zfcp_sg_to_address(&resp
[0]) +
1346 resp
[0].length
- 1) & PAGE_MASK
)));
1350 * zfcp_fsf_send_ct - initiate a Generic Service request (FC-GS)
1351 * @ct: pointer to struct zfcp_send_ct which conatins all needed data for
1353 * @pool: pointer to memory pool, if non-null this pool is used to allocate
1354 * a struct zfcp_fsf_req
1355 * @erp_action: pointer to erp_action, if non-null the Generic Service request
1356 * is sent within error recovery
1359 zfcp_fsf_send_ct(struct zfcp_send_ct
*ct
, mempool_t
*pool
,
1360 struct zfcp_erp_action
*erp_action
)
1362 volatile struct qdio_buffer_element
*sbale
;
1363 struct zfcp_port
*port
;
1364 struct zfcp_adapter
*adapter
;
1365 struct zfcp_fsf_req
*fsf_req
;
1366 unsigned long lock_flags
;
1371 adapter
= port
->adapter
;
1373 ret
= zfcp_fsf_req_create(adapter
, FSF_QTCB_SEND_GENERIC
,
1374 ZFCP_WAIT_FOR_SBAL
| ZFCP_REQ_AUTO_CLEANUP
,
1375 pool
, &lock_flags
, &fsf_req
);
1377 ZFCP_LOG_INFO("error: Could not create CT request (FC-GS) for "
1379 zfcp_get_busid_by_adapter(adapter
));
1383 if (erp_action
!= NULL
) {
1384 erp_action
->fsf_req
= fsf_req
;
1385 fsf_req
->erp_action
= erp_action
;
1388 sbale
= zfcp_qdio_sbale_req(fsf_req
, fsf_req
->sbal_curr
, 0);
1389 if (zfcp_use_one_sbal(ct
->req
, ct
->req_count
,
1390 ct
->resp
, ct
->resp_count
)){
1391 /* both request buffer and response buffer
1392 fit into one sbale each */
1393 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_WRITE_READ
;
1394 sbale
[2].addr
= zfcp_sg_to_address(&ct
->req
[0]);
1395 sbale
[2].length
= ct
->req
[0].length
;
1396 sbale
[3].addr
= zfcp_sg_to_address(&ct
->resp
[0]);
1397 sbale
[3].length
= ct
->resp
[0].length
;
1398 sbale
[3].flags
|= SBAL_FLAGS_LAST_ENTRY
;
1399 } else if (adapter
->adapter_features
&
1400 FSF_FEATURE_ELS_CT_CHAINED_SBALS
) {
1401 /* try to use chained SBALs */
1402 bytes
= zfcp_qdio_sbals_from_sg(fsf_req
,
1403 SBAL_FLAGS0_TYPE_WRITE_READ
,
1404 ct
->req
, ct
->req_count
,
1405 ZFCP_MAX_SBALS_PER_CT_REQ
);
1407 ZFCP_LOG_INFO("error: creation of CT request failed "
1409 zfcp_get_busid_by_adapter(adapter
));
1417 fsf_req
->qtcb
->bottom
.support
.req_buf_length
= bytes
;
1418 fsf_req
->sbale_curr
= ZFCP_LAST_SBALE_PER_SBAL
;
1419 bytes
= zfcp_qdio_sbals_from_sg(fsf_req
,
1420 SBAL_FLAGS0_TYPE_WRITE_READ
,
1421 ct
->resp
, ct
->resp_count
,
1422 ZFCP_MAX_SBALS_PER_CT_REQ
);
1424 ZFCP_LOG_INFO("error: creation of CT request failed "
1426 zfcp_get_busid_by_adapter(adapter
));
1434 fsf_req
->qtcb
->bottom
.support
.resp_buf_length
= bytes
;
1436 /* reject send generic request */
1438 "error: microcode does not support chained SBALs,"
1439 "CT request too big (adapter %s)\n",
1440 zfcp_get_busid_by_adapter(adapter
));
1445 /* settings in QTCB */
1446 fsf_req
->qtcb
->header
.port_handle
= port
->handle
;
1447 fsf_req
->qtcb
->bottom
.support
.service_class
=
1448 ZFCP_FC_SERVICE_CLASS_DEFAULT
;
1449 fsf_req
->qtcb
->bottom
.support
.timeout
= ct
->timeout
;
1450 fsf_req
->data
= (unsigned long) ct
;
1452 zfcp_san_dbf_event_ct_request(fsf_req
);
1454 /* start QDIO request for this FSF request */
1455 ret
= zfcp_fsf_req_send(fsf_req
, ct
->timer
);
1457 ZFCP_LOG_DEBUG("error: initiation of CT request failed "
1458 "(adapter %s, port 0x%016Lx)\n",
1459 zfcp_get_busid_by_adapter(adapter
), port
->wwpn
);
1463 ZFCP_LOG_DEBUG("CT request initiated (adapter %s, port 0x%016Lx)\n",
1464 zfcp_get_busid_by_adapter(adapter
), port
->wwpn
);
1468 zfcp_fsf_req_free(fsf_req
);
1469 if (erp_action
!= NULL
) {
1470 erp_action
->fsf_req
= NULL
;
1474 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
,
1480 * zfcp_fsf_send_ct_handler - handler for Generic Service requests
1481 * @fsf_req: pointer to struct zfcp_fsf_req
1483 * Data specific for the Generic Service request is passed using
1484 * fsf_req->data. There we find the pointer to struct zfcp_send_ct.
1485 * Usually a specific handler for the CT request is called which is
1486 * found in this structure.
1489 zfcp_fsf_send_ct_handler(struct zfcp_fsf_req
*fsf_req
)
1491 struct zfcp_port
*port
;
1492 struct zfcp_adapter
*adapter
;
1493 struct zfcp_send_ct
*send_ct
;
1494 struct fsf_qtcb_header
*header
;
1495 struct fsf_qtcb_bottom_support
*bottom
;
1496 int retval
= -EINVAL
;
1497 u16 subtable
, rule
, counter
;
1499 adapter
= fsf_req
->adapter
;
1500 send_ct
= (struct zfcp_send_ct
*) fsf_req
->data
;
1501 port
= send_ct
->port
;
1502 header
= &fsf_req
->qtcb
->header
;
1503 bottom
= &fsf_req
->qtcb
->bottom
.support
;
1505 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
)
1506 goto skip_fsfstatus
;
1508 /* evaluate FSF status in QTCB */
1509 switch (header
->fsf_status
) {
1512 zfcp_san_dbf_event_ct_response(fsf_req
);
1516 case FSF_SERVICE_CLASS_NOT_SUPPORTED
:
1517 ZFCP_LOG_INFO("error: adapter %s does not support fc "
1519 zfcp_get_busid_by_port(port
),
1520 ZFCP_FC_SERVICE_CLASS_DEFAULT
);
1521 /* stop operation for this adapter */
1522 debug_text_exception(adapter
->erp_dbf
, 0, "fsf_s_class_nsup");
1523 zfcp_erp_adapter_shutdown(adapter
, 0);
1524 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1527 case FSF_ADAPTER_STATUS_AVAILABLE
:
1528 switch (header
->fsf_status_qual
.word
[0]){
1529 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE
:
1530 /* reopening link to port */
1531 debug_text_event(adapter
->erp_dbf
, 1, "fsf_sq_ltest");
1532 zfcp_test_link(port
);
1533 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1535 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED
:
1536 /* ERP strategy will escalate */
1537 debug_text_event(adapter
->erp_dbf
, 1, "fsf_sq_ulp");
1538 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1541 ZFCP_LOG_INFO("bug: Wrong status qualifier 0x%x "
1543 header
->fsf_status_qual
.word
[0]);
1548 case FSF_ACCESS_DENIED
:
1549 ZFCP_LOG_NORMAL("access denied, cannot send generic service "
1550 "command (adapter %s, port d_id=0x%08x)\n",
1551 zfcp_get_busid_by_port(port
), port
->d_id
);
1552 for (counter
= 0; counter
< 2; counter
++) {
1553 subtable
= header
->fsf_status_qual
.halfword
[counter
* 2];
1554 rule
= header
->fsf_status_qual
.halfword
[counter
* 2 + 1];
1556 case FSF_SQ_CFDC_SUBTABLE_OS
:
1557 case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN
:
1558 case FSF_SQ_CFDC_SUBTABLE_PORT_DID
:
1559 case FSF_SQ_CFDC_SUBTABLE_LUN
:
1560 ZFCP_LOG_INFO("Access denied (%s rule %d)\n",
1561 zfcp_act_subtable_type
[subtable
], rule
);
1565 debug_text_event(adapter
->erp_dbf
, 1, "fsf_s_access");
1566 zfcp_erp_port_access_denied(port
);
1567 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1570 case FSF_GENERIC_COMMAND_REJECTED
:
1571 ZFCP_LOG_INFO("generic service command rejected "
1572 "(adapter %s, port d_id=0x%08x)\n",
1573 zfcp_get_busid_by_port(port
), port
->d_id
);
1574 ZFCP_LOG_INFO("status qualifier:\n");
1575 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_INFO
,
1576 (char *) &header
->fsf_status_qual
,
1577 sizeof (union fsf_status_qual
));
1578 debug_text_event(adapter
->erp_dbf
, 1, "fsf_s_gcom_rej");
1579 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1582 case FSF_PORT_HANDLE_NOT_VALID
:
1583 ZFCP_LOG_DEBUG("Temporary port identifier 0x%x for port "
1584 "0x%016Lx on adapter %s invalid. This may "
1585 "happen occasionally.\n", port
->handle
,
1586 port
->wwpn
, zfcp_get_busid_by_port(port
));
1587 ZFCP_LOG_INFO("status qualifier:\n");
1588 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_INFO
,
1589 (char *) &header
->fsf_status_qual
,
1590 sizeof (union fsf_status_qual
));
1591 debug_text_event(adapter
->erp_dbf
, 1, "fsf_s_phandle_nv");
1592 zfcp_erp_adapter_reopen(adapter
, 0);
1593 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1596 case FSF_PORT_BOXED
:
1597 ZFCP_LOG_INFO("port needs to be reopened "
1598 "(adapter %s, port d_id=0x%08x)\n",
1599 zfcp_get_busid_by_port(port
), port
->d_id
);
1600 debug_text_event(adapter
->erp_dbf
, 2, "fsf_s_pboxed");
1601 zfcp_erp_port_boxed(port
);
1602 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
1603 | ZFCP_STATUS_FSFREQ_RETRY
;
1606 /* following states should never occure, all cases avoided
1607 in zfcp_fsf_send_ct - but who knows ... */
1608 case FSF_PAYLOAD_SIZE_MISMATCH
:
1609 ZFCP_LOG_INFO("payload size mismatch (adapter: %s, "
1610 "req_buf_length=%d, resp_buf_length=%d)\n",
1611 zfcp_get_busid_by_adapter(adapter
),
1612 bottom
->req_buf_length
, bottom
->resp_buf_length
);
1613 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1615 case FSF_REQUEST_SIZE_TOO_LARGE
:
1616 ZFCP_LOG_INFO("request size too large (adapter: %s, "
1617 "req_buf_length=%d)\n",
1618 zfcp_get_busid_by_adapter(adapter
),
1619 bottom
->req_buf_length
);
1620 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1622 case FSF_RESPONSE_SIZE_TOO_LARGE
:
1623 ZFCP_LOG_INFO("response size too large (adapter: %s, "
1624 "resp_buf_length=%d)\n",
1625 zfcp_get_busid_by_adapter(adapter
),
1626 bottom
->resp_buf_length
);
1627 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1629 case FSF_SBAL_MISMATCH
:
1630 ZFCP_LOG_INFO("SBAL mismatch (adapter: %s, req_buf_length=%d, "
1631 "resp_buf_length=%d)\n",
1632 zfcp_get_busid_by_adapter(adapter
),
1633 bottom
->req_buf_length
, bottom
->resp_buf_length
);
1634 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1638 ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
1639 "(debug info 0x%x)\n", header
->fsf_status
);
1640 debug_text_event(adapter
->erp_dbf
, 0, "fsf_sq_inval:");
1641 debug_exception(adapter
->erp_dbf
, 0,
1642 &header
->fsf_status_qual
.word
[0], sizeof (u32
));
1647 send_ct
->status
= retval
;
1649 if (send_ct
->handler
!= NULL
)
1650 send_ct
->handler(send_ct
->handler_data
);
1656 * zfcp_fsf_send_els - initiate an ELS command (FC-FS)
1657 * @els: pointer to struct zfcp_send_els which contains all needed data for
1661 zfcp_fsf_send_els(struct zfcp_send_els
*els
)
1663 volatile struct qdio_buffer_element
*sbale
;
1664 struct zfcp_fsf_req
*fsf_req
;
1666 struct zfcp_adapter
*adapter
;
1667 unsigned long lock_flags
;
1672 adapter
= els
->adapter
;
1674 ret
= zfcp_fsf_req_create(adapter
, FSF_QTCB_SEND_ELS
,
1675 ZFCP_REQ_AUTO_CLEANUP
,
1676 NULL
, &lock_flags
, &fsf_req
);
1678 ZFCP_LOG_INFO("error: creation of ELS request failed "
1679 "(adapter %s, port d_id: 0x%08x)\n",
1680 zfcp_get_busid_by_adapter(adapter
), d_id
);
1684 sbale
= zfcp_qdio_sbale_req(fsf_req
, fsf_req
->sbal_curr
, 0);
1685 if (zfcp_use_one_sbal(els
->req
, els
->req_count
,
1686 els
->resp
, els
->resp_count
)){
1687 /* both request buffer and response buffer
1688 fit into one sbale each */
1689 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_WRITE_READ
;
1690 sbale
[2].addr
= zfcp_sg_to_address(&els
->req
[0]);
1691 sbale
[2].length
= els
->req
[0].length
;
1692 sbale
[3].addr
= zfcp_sg_to_address(&els
->resp
[0]);
1693 sbale
[3].length
= els
->resp
[0].length
;
1694 sbale
[3].flags
|= SBAL_FLAGS_LAST_ENTRY
;
1695 } else if (adapter
->adapter_features
&
1696 FSF_FEATURE_ELS_CT_CHAINED_SBALS
) {
1697 /* try to use chained SBALs */
1698 bytes
= zfcp_qdio_sbals_from_sg(fsf_req
,
1699 SBAL_FLAGS0_TYPE_WRITE_READ
,
1700 els
->req
, els
->req_count
,
1701 ZFCP_MAX_SBALS_PER_ELS_REQ
);
1703 ZFCP_LOG_INFO("error: creation of ELS request failed "
1704 "(adapter %s, port d_id: 0x%08x)\n",
1705 zfcp_get_busid_by_adapter(adapter
), d_id
);
1713 fsf_req
->qtcb
->bottom
.support
.req_buf_length
= bytes
;
1714 fsf_req
->sbale_curr
= ZFCP_LAST_SBALE_PER_SBAL
;
1715 bytes
= zfcp_qdio_sbals_from_sg(fsf_req
,
1716 SBAL_FLAGS0_TYPE_WRITE_READ
,
1717 els
->resp
, els
->resp_count
,
1718 ZFCP_MAX_SBALS_PER_ELS_REQ
);
1720 ZFCP_LOG_INFO("error: creation of ELS request failed "
1721 "(adapter %s, port d_id: 0x%08x)\n",
1722 zfcp_get_busid_by_adapter(adapter
), d_id
);
1730 fsf_req
->qtcb
->bottom
.support
.resp_buf_length
= bytes
;
1732 /* reject request */
1733 ZFCP_LOG_INFO("error: microcode does not support chained SBALs"
1734 ", ELS request too big (adapter %s, "
1735 "port d_id: 0x%08x)\n",
1736 zfcp_get_busid_by_adapter(adapter
), d_id
);
1741 /* settings in QTCB */
1742 fsf_req
->qtcb
->bottom
.support
.d_id
= d_id
;
1743 fsf_req
->qtcb
->bottom
.support
.service_class
=
1744 ZFCP_FC_SERVICE_CLASS_DEFAULT
;
1745 fsf_req
->qtcb
->bottom
.support
.timeout
= ZFCP_ELS_TIMEOUT
;
1746 fsf_req
->data
= (unsigned long) els
;
1748 sbale
= zfcp_qdio_sbale_req(fsf_req
, fsf_req
->sbal_curr
, 0);
1750 zfcp_san_dbf_event_els_request(fsf_req
);
1752 /* start QDIO request for this FSF request */
1753 ret
= zfcp_fsf_req_send(fsf_req
, els
->timer
);
1755 ZFCP_LOG_DEBUG("error: initiation of ELS request failed "
1756 "(adapter %s, port d_id: 0x%08x)\n",
1757 zfcp_get_busid_by_adapter(adapter
), d_id
);
1761 ZFCP_LOG_DEBUG("ELS request initiated (adapter %s, port d_id: "
1762 "0x%08x)\n", zfcp_get_busid_by_adapter(adapter
), d_id
);
1766 zfcp_fsf_req_free(fsf_req
);
1770 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
,
1777 * zfcp_fsf_send_els_handler - handler for ELS commands
1778 * @fsf_req: pointer to struct zfcp_fsf_req
1780 * Data specific for the ELS command is passed using
1781 * fsf_req->data. There we find the pointer to struct zfcp_send_els.
1782 * Usually a specific handler for the ELS command is called which is
1783 * found in this structure.
1785 static int zfcp_fsf_send_els_handler(struct zfcp_fsf_req
*fsf_req
)
1787 struct zfcp_adapter
*adapter
;
1788 struct zfcp_port
*port
;
1790 struct fsf_qtcb_header
*header
;
1791 struct fsf_qtcb_bottom_support
*bottom
;
1792 struct zfcp_send_els
*send_els
;
1793 int retval
= -EINVAL
;
1794 u16 subtable
, rule
, counter
;
1796 send_els
= (struct zfcp_send_els
*) fsf_req
->data
;
1797 adapter
= send_els
->adapter
;
1798 port
= send_els
->port
;
1799 d_id
= send_els
->d_id
;
1800 header
= &fsf_req
->qtcb
->header
;
1801 bottom
= &fsf_req
->qtcb
->bottom
.support
;
1803 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
)
1804 goto skip_fsfstatus
;
1806 switch (header
->fsf_status
) {
1809 zfcp_san_dbf_event_els_response(fsf_req
);
1813 case FSF_SERVICE_CLASS_NOT_SUPPORTED
:
1814 ZFCP_LOG_INFO("error: adapter %s does not support fc "
1816 zfcp_get_busid_by_adapter(adapter
),
1817 ZFCP_FC_SERVICE_CLASS_DEFAULT
);
1818 /* stop operation for this adapter */
1819 debug_text_exception(adapter
->erp_dbf
, 0, "fsf_s_class_nsup");
1820 zfcp_erp_adapter_shutdown(adapter
, 0);
1821 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1824 case FSF_ADAPTER_STATUS_AVAILABLE
:
1825 switch (header
->fsf_status_qual
.word
[0]){
1826 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE
:
1827 debug_text_event(adapter
->erp_dbf
, 1, "fsf_sq_ltest");
1828 if (port
&& (send_els
->ls_code
!= ZFCP_LS_ADISC
))
1829 zfcp_test_link(port
);
1830 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1832 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED
:
1833 debug_text_event(adapter
->erp_dbf
, 1, "fsf_sq_ulp");
1834 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1836 zfcp_handle_els_rjt(header
->fsf_status_qual
.word
[1],
1837 (struct zfcp_ls_rjt_par
*)
1838 &header
->fsf_status_qual
.word
[2]);
1840 case FSF_SQ_RETRY_IF_POSSIBLE
:
1841 debug_text_event(adapter
->erp_dbf
, 1, "fsf_sq_retry");
1842 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1845 ZFCP_LOG_INFO("bug: Wrong status qualifier 0x%x\n",
1846 header
->fsf_status_qual
.word
[0]);
1847 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_INFO
,
1848 (char*)header
->fsf_status_qual
.word
, 16);
1852 case FSF_ELS_COMMAND_REJECTED
:
1853 ZFCP_LOG_INFO("ELS has been rejected because command filter "
1854 "prohibited sending "
1855 "(adapter: %s, port d_id: 0x%08x)\n",
1856 zfcp_get_busid_by_adapter(adapter
), d_id
);
1860 case FSF_PAYLOAD_SIZE_MISMATCH
:
1862 "ELS request size and ELS response size must be either "
1863 "both 0, or both greater than 0 "
1864 "(adapter: %s, req_buf_length=%d resp_buf_length=%d)\n",
1865 zfcp_get_busid_by_adapter(adapter
),
1866 bottom
->req_buf_length
,
1867 bottom
->resp_buf_length
);
1870 case FSF_REQUEST_SIZE_TOO_LARGE
:
1872 "Length of the ELS request buffer, "
1873 "specified in QTCB bottom, "
1874 "exceeds the size of the buffers "
1875 "that have been allocated for ELS request data "
1876 "(adapter: %s, req_buf_length=%d)\n",
1877 zfcp_get_busid_by_adapter(adapter
),
1878 bottom
->req_buf_length
);
1881 case FSF_RESPONSE_SIZE_TOO_LARGE
:
1883 "Length of the ELS response buffer, "
1884 "specified in QTCB bottom, "
1885 "exceeds the size of the buffers "
1886 "that have been allocated for ELS response data "
1887 "(adapter: %s, resp_buf_length=%d)\n",
1888 zfcp_get_busid_by_adapter(adapter
),
1889 bottom
->resp_buf_length
);
1892 case FSF_SBAL_MISMATCH
:
1893 /* should never occure, avoided in zfcp_fsf_send_els */
1894 ZFCP_LOG_INFO("SBAL mismatch (adapter: %s, req_buf_length=%d, "
1895 "resp_buf_length=%d)\n",
1896 zfcp_get_busid_by_adapter(adapter
),
1897 bottom
->req_buf_length
, bottom
->resp_buf_length
);
1898 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1901 case FSF_ACCESS_DENIED
:
1902 ZFCP_LOG_NORMAL("access denied, cannot send ELS command "
1903 "(adapter %s, port d_id=0x%08x)\n",
1904 zfcp_get_busid_by_adapter(adapter
), d_id
);
1905 for (counter
= 0; counter
< 2; counter
++) {
1906 subtable
= header
->fsf_status_qual
.halfword
[counter
* 2];
1907 rule
= header
->fsf_status_qual
.halfword
[counter
* 2 + 1];
1909 case FSF_SQ_CFDC_SUBTABLE_OS
:
1910 case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN
:
1911 case FSF_SQ_CFDC_SUBTABLE_PORT_DID
:
1912 case FSF_SQ_CFDC_SUBTABLE_LUN
:
1913 ZFCP_LOG_INFO("Access denied (%s rule %d)\n",
1914 zfcp_act_subtable_type
[subtable
], rule
);
1918 debug_text_event(adapter
->erp_dbf
, 1, "fsf_s_access");
1920 zfcp_erp_port_access_denied(port
);
1921 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1926 "bug: An unknown FSF Status was presented "
1927 "(adapter: %s, fsf_status=0x%08x)\n",
1928 zfcp_get_busid_by_adapter(adapter
),
1929 header
->fsf_status
);
1930 debug_text_event(adapter
->erp_dbf
, 0, "fsf_sq_inval");
1931 debug_exception(adapter
->erp_dbf
, 0,
1932 &header
->fsf_status_qual
.word
[0], sizeof(u32
));
1933 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1938 send_els
->status
= retval
;
1940 if (send_els
->handler
!= 0)
1941 send_els
->handler(send_els
->handler_data
);
1947 zfcp_fsf_exchange_config_data(struct zfcp_erp_action
*erp_action
)
1949 volatile struct qdio_buffer_element
*sbale
;
1950 unsigned long lock_flags
;
1953 /* setup new FSF request */
1954 retval
= zfcp_fsf_req_create(erp_action
->adapter
,
1955 FSF_QTCB_EXCHANGE_CONFIG_DATA
,
1956 ZFCP_REQ_AUTO_CLEANUP
,
1957 erp_action
->adapter
->pool
.fsf_req_erp
,
1958 &lock_flags
, &(erp_action
->fsf_req
));
1960 ZFCP_LOG_INFO("error: Could not create exchange configuration "
1961 "data request for adapter %s.\n",
1962 zfcp_get_busid_by_adapter(erp_action
->adapter
));
1966 sbale
= zfcp_qdio_sbale_req(erp_action
->fsf_req
,
1967 erp_action
->fsf_req
->sbal_curr
, 0);
1968 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_READ
;
1969 sbale
[1].flags
|= SBAL_FLAGS_LAST_ENTRY
;
1971 erp_action
->fsf_req
->erp_action
= erp_action
;
1972 erp_action
->fsf_req
->qtcb
->bottom
.config
.feature_selection
=
1974 FSF_FEATURE_LUN_SHARING
|
1975 FSF_FEATURE_NOTIFICATION_LOST
|
1976 FSF_FEATURE_UPDATE_ALERT
;
1978 /* start QDIO request for this FSF request */
1979 retval
= zfcp_fsf_req_send(erp_action
->fsf_req
, &erp_action
->timer
);
1982 ("error: Could not send exchange configuration data "
1983 "command on the adapter %s\n",
1984 zfcp_get_busid_by_adapter(erp_action
->adapter
));
1985 zfcp_fsf_req_free(erp_action
->fsf_req
);
1986 erp_action
->fsf_req
= NULL
;
1990 ZFCP_LOG_DEBUG("exchange configuration data request initiated "
1992 zfcp_get_busid_by_adapter(erp_action
->adapter
));
1995 write_unlock_irqrestore(&erp_action
->adapter
->request_queue
.queue_lock
,
2001 * zfcp_fsf_exchange_config_evaluate
2002 * @fsf_req: fsf_req which belongs to xchg config data request
2003 * @xchg_ok: specifies if xchg config data was incomplete or complete (0/1)
2005 * returns: -EIO on error, 0 otherwise
2008 zfcp_fsf_exchange_config_evaluate(struct zfcp_fsf_req
*fsf_req
, int xchg_ok
)
2010 struct fsf_qtcb_bottom_config
*bottom
;
2011 struct zfcp_adapter
*adapter
= fsf_req
->adapter
;
2012 struct Scsi_Host
*shost
= adapter
->scsi_host
;
2014 bottom
= &fsf_req
->qtcb
->bottom
.config
;
2015 ZFCP_LOG_DEBUG("low/high QTCB version 0x%x/0x%x of FSF\n",
2016 bottom
->low_qtcb_version
, bottom
->high_qtcb_version
);
2017 adapter
->fsf_lic_version
= bottom
->lic_version
;
2018 adapter
->adapter_features
= bottom
->adapter_features
;
2019 adapter
->connection_features
= bottom
->connection_features
;
2020 adapter
->peer_wwpn
= 0;
2021 adapter
->peer_wwnn
= 0;
2022 adapter
->peer_d_id
= 0;
2025 fc_host_node_name(shost
) = bottom
->nport_serv_param
.wwnn
;
2026 fc_host_port_name(shost
) = bottom
->nport_serv_param
.wwpn
;
2027 fc_host_port_id(shost
) = bottom
->s_id
& ZFCP_DID_MASK
;
2028 fc_host_speed(shost
) = bottom
->fc_link_speed
;
2029 fc_host_supported_classes(shost
) = FC_COS_CLASS2
| FC_COS_CLASS3
;
2030 adapter
->hydra_version
= bottom
->adapter_type
;
2031 if (fc_host_permanent_port_name(shost
) == -1)
2032 fc_host_permanent_port_name(shost
) =
2033 fc_host_port_name(shost
);
2034 if (bottom
->fc_topology
== FSF_TOPO_P2P
) {
2035 adapter
->peer_d_id
= bottom
->peer_d_id
& ZFCP_DID_MASK
;
2036 adapter
->peer_wwpn
= bottom
->plogi_payload
.wwpn
;
2037 adapter
->peer_wwnn
= bottom
->plogi_payload
.wwnn
;
2038 fc_host_port_type(shost
) = FC_PORTTYPE_PTP
;
2039 } else if (bottom
->fc_topology
== FSF_TOPO_FABRIC
)
2040 fc_host_port_type(shost
) = FC_PORTTYPE_NPORT
;
2041 else if (bottom
->fc_topology
== FSF_TOPO_AL
)
2042 fc_host_port_type(shost
) = FC_PORTTYPE_NLPORT
;
2044 fc_host_port_type(shost
) = FC_PORTTYPE_UNKNOWN
;
2046 fc_host_node_name(shost
) = 0;
2047 fc_host_port_name(shost
) = 0;
2048 fc_host_port_id(shost
) = 0;
2049 fc_host_speed(shost
) = FC_PORTSPEED_UNKNOWN
;
2050 fc_host_port_type(shost
) = FC_PORTTYPE_UNKNOWN
;
2051 adapter
->hydra_version
= 0;
2054 if (adapter
->adapter_features
& FSF_FEATURE_HBAAPI_MANAGEMENT
) {
2055 adapter
->hardware_version
= bottom
->hardware_version
;
2056 memcpy(fc_host_serial_number(shost
), bottom
->serial_number
,
2057 min(FC_SERIAL_NUMBER_SIZE
, 17));
2058 EBCASC(fc_host_serial_number(shost
),
2059 min(FC_SERIAL_NUMBER_SIZE
, 17));
2062 ZFCP_LOG_NORMAL("The adapter %s reported the following characteristics:\n"
2066 "adapter version 0x%x, "
2067 "LIC version 0x%x, "
2068 "FC link speed %d Gb/s\n",
2069 zfcp_get_busid_by_adapter(adapter
),
2070 (wwn_t
) fc_host_node_name(shost
),
2071 (wwn_t
) fc_host_port_name(shost
),
2072 fc_host_port_id(shost
),
2073 adapter
->hydra_version
,
2074 adapter
->fsf_lic_version
,
2075 fc_host_speed(shost
));
2076 if (ZFCP_QTCB_VERSION
< bottom
->low_qtcb_version
) {
2077 ZFCP_LOG_NORMAL("error: the adapter %s "
2078 "only supports newer control block "
2079 "versions in comparison to this device "
2080 "driver (try updated device driver)\n",
2081 zfcp_get_busid_by_adapter(adapter
));
2082 debug_text_event(adapter
->erp_dbf
, 0, "low_qtcb_ver");
2083 zfcp_erp_adapter_shutdown(adapter
, 0);
2086 if (ZFCP_QTCB_VERSION
> bottom
->high_qtcb_version
) {
2087 ZFCP_LOG_NORMAL("error: the adapter %s "
2088 "only supports older control block "
2089 "versions than this device driver uses"
2090 "(consider a microcode upgrade)\n",
2091 zfcp_get_busid_by_adapter(adapter
));
2092 debug_text_event(adapter
->erp_dbf
, 0, "high_qtcb_ver");
2093 zfcp_erp_adapter_shutdown(adapter
, 0);
2100 * function: zfcp_fsf_exchange_config_data_handler
2102 * purpose: is called for finished Exchange Configuration Data command
2107 zfcp_fsf_exchange_config_data_handler(struct zfcp_fsf_req
*fsf_req
)
2109 struct fsf_qtcb_bottom_config
*bottom
;
2110 struct zfcp_adapter
*adapter
= fsf_req
->adapter
;
2111 struct fsf_qtcb
*qtcb
= fsf_req
->qtcb
;
2113 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
)
2116 switch (qtcb
->header
.fsf_status
) {
2119 if (zfcp_fsf_exchange_config_evaluate(fsf_req
, 1))
2122 switch (fc_host_port_type(adapter
->scsi_host
)) {
2123 case FC_PORTTYPE_PTP
:
2124 ZFCP_LOG_NORMAL("Point-to-Point fibrechannel "
2125 "configuration detected at adapter %s\n"
2126 "Peer WWNN 0x%016llx, "
2127 "peer WWPN 0x%016llx, "
2128 "peer d_id 0x%06x\n",
2129 zfcp_get_busid_by_adapter(adapter
),
2132 adapter
->peer_d_id
);
2133 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0,
2136 case FC_PORTTYPE_NLPORT
:
2137 ZFCP_LOG_NORMAL("error: Arbitrated loop fibrechannel "
2138 "topology detected at adapter %s "
2139 "unsupported, shutting down adapter\n",
2140 zfcp_get_busid_by_adapter(adapter
));
2141 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0,
2143 zfcp_erp_adapter_shutdown(adapter
, 0);
2145 case FC_PORTTYPE_NPORT
:
2146 ZFCP_LOG_NORMAL("Switched fabric fibrechannel "
2147 "network detected at adapter %s.\n",
2148 zfcp_get_busid_by_adapter(adapter
));
2151 ZFCP_LOG_NORMAL("bug: The fibrechannel topology "
2152 "reported by the exchange "
2153 "configuration command for "
2154 "the adapter %s is not "
2155 "of a type known to the zfcp "
2156 "driver, shutting down adapter\n",
2157 zfcp_get_busid_by_adapter(adapter
));
2158 debug_text_exception(fsf_req
->adapter
->erp_dbf
, 0,
2160 zfcp_erp_adapter_shutdown(adapter
, 0);
2163 bottom
= &qtcb
->bottom
.config
;
2164 if (bottom
->max_qtcb_size
< sizeof(struct fsf_qtcb
)) {
2165 ZFCP_LOG_NORMAL("bug: Maximum QTCB size (%d bytes) "
2166 "allowed by the adapter %s "
2167 "is lower than the minimum "
2168 "required by the driver (%ld bytes).\n",
2169 bottom
->max_qtcb_size
,
2170 zfcp_get_busid_by_adapter(adapter
),
2171 sizeof(struct fsf_qtcb
));
2172 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0,
2174 debug_event(fsf_req
->adapter
->erp_dbf
, 0,
2175 &bottom
->max_qtcb_size
, sizeof (u32
));
2176 zfcp_erp_adapter_shutdown(adapter
, 0);
2179 atomic_set_mask(ZFCP_STATUS_ADAPTER_XCONFIG_OK
,
2182 case FSF_EXCHANGE_CONFIG_DATA_INCOMPLETE
:
2183 debug_text_event(adapter
->erp_dbf
, 0, "xchg-inco");
2185 if (zfcp_fsf_exchange_config_evaluate(fsf_req
, 0))
2188 atomic_set_mask(ZFCP_STATUS_ADAPTER_XCONFIG_OK
, &adapter
->status
);
2190 zfcp_fsf_link_down_info_eval(adapter
,
2191 &qtcb
->header
.fsf_status_qual
.link_down_info
);
2194 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0, "fsf-stat-ng");
2195 debug_event(fsf_req
->adapter
->erp_dbf
, 0,
2196 &fsf_req
->qtcb
->header
.fsf_status
, sizeof (u32
));
2197 zfcp_erp_adapter_shutdown(adapter
, 0);
2204 * zfcp_fsf_exchange_port_data - request information about local port
2205 * @erp_action: ERP action for the adapter for which port data is requested
2206 * @adapter: for which port data is requested
2207 * @data: response to exchange port data request
2210 zfcp_fsf_exchange_port_data(struct zfcp_erp_action
*erp_action
,
2211 struct zfcp_adapter
*adapter
,
2212 struct fsf_qtcb_bottom_port
*data
)
2214 volatile struct qdio_buffer_element
*sbale
;
2216 unsigned long lock_flags
;
2217 struct zfcp_fsf_req
*fsf_req
;
2218 struct timer_list
*timer
;
2220 if (!(adapter
->adapter_features
& FSF_FEATURE_HBAAPI_MANAGEMENT
)) {
2221 ZFCP_LOG_INFO("error: exchange port data "
2222 "command not supported by adapter %s\n",
2223 zfcp_get_busid_by_adapter(adapter
));
2227 /* setup new FSF request */
2228 retval
= zfcp_fsf_req_create(adapter
, FSF_QTCB_EXCHANGE_PORT_DATA
,
2229 erp_action
? ZFCP_REQ_AUTO_CLEANUP
: 0,
2230 0, &lock_flags
, &fsf_req
);
2232 ZFCP_LOG_INFO("error: Out of resources. Could not create an "
2233 "exchange port data request for"
2234 "the adapter %s.\n",
2235 zfcp_get_busid_by_adapter(adapter
));
2236 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
,
2242 fsf_req
->data
= (unsigned long) data
;
2244 sbale
= zfcp_qdio_sbale_req(fsf_req
, fsf_req
->sbal_curr
, 0);
2245 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_READ
;
2246 sbale
[1].flags
|= SBAL_FLAGS_LAST_ENTRY
;
2249 erp_action
->fsf_req
= fsf_req
;
2250 fsf_req
->erp_action
= erp_action
;
2251 timer
= &erp_action
->timer
;
2253 timer
= kmalloc(sizeof(struct timer_list
), GFP_ATOMIC
);
2255 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
,
2257 zfcp_fsf_req_free(fsf_req
);
2261 timer
->function
= zfcp_fsf_request_timeout_handler
;
2262 timer
->data
= (unsigned long) adapter
;
2263 timer
->expires
= ZFCP_FSF_REQUEST_TIMEOUT
;
2266 retval
= zfcp_fsf_req_send(fsf_req
, timer
);
2268 ZFCP_LOG_INFO("error: Could not send an exchange port data "
2269 "command on the adapter %s\n",
2270 zfcp_get_busid_by_adapter(adapter
));
2271 zfcp_fsf_req_free(fsf_req
);
2273 erp_action
->fsf_req
= NULL
;
2276 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
,
2281 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
, lock_flags
);
2284 wait_event(fsf_req
->completion_wq
,
2285 fsf_req
->status
& ZFCP_STATUS_FSFREQ_COMPLETED
);
2286 del_timer_sync(timer
);
2287 zfcp_fsf_req_free(fsf_req
);
2294 * zfcp_fsf_exchange_port_evaluate
2295 * @fsf_req: fsf_req which belongs to xchg port data request
2296 * @xchg_ok: specifies if xchg port data was incomplete or complete (0/1)
2299 zfcp_fsf_exchange_port_evaluate(struct zfcp_fsf_req
*fsf_req
, int xchg_ok
)
2301 struct zfcp_adapter
*adapter
;
2302 struct fsf_qtcb
*qtcb
;
2303 struct fsf_qtcb_bottom_port
*bottom
, *data
;
2304 struct Scsi_Host
*shost
;
2306 adapter
= fsf_req
->adapter
;
2307 qtcb
= fsf_req
->qtcb
;
2308 bottom
= &qtcb
->bottom
.port
;
2309 shost
= adapter
->scsi_host
;
2311 data
= (struct fsf_qtcb_bottom_port
*) fsf_req
->data
;
2313 memcpy(data
, bottom
, sizeof(struct fsf_qtcb_bottom_port
));
2315 if (adapter
->connection_features
& FSF_FEATURE_NPIV_MODE
)
2316 fc_host_permanent_port_name(shost
) = bottom
->wwpn
;
2318 fc_host_permanent_port_name(shost
) = fc_host_port_name(shost
);
2319 fc_host_maxframe_size(shost
) = bottom
->maximum_frame_size
;
2320 fc_host_supported_speeds(shost
) = bottom
->supported_speed
;
2324 * zfcp_fsf_exchange_port_data_handler - handler for exchange_port_data request
2325 * @fsf_req: pointer to struct zfcp_fsf_req
2328 zfcp_fsf_exchange_port_data_handler(struct zfcp_fsf_req
*fsf_req
)
2330 struct zfcp_adapter
*adapter
;
2331 struct fsf_qtcb
*qtcb
;
2333 adapter
= fsf_req
->adapter
;
2334 qtcb
= fsf_req
->qtcb
;
2336 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
)
2339 switch (qtcb
->header
.fsf_status
) {
2341 zfcp_fsf_exchange_port_evaluate(fsf_req
, 1);
2342 atomic_set_mask(ZFCP_STATUS_ADAPTER_XPORT_OK
, &adapter
->status
);
2344 case FSF_EXCHANGE_CONFIG_DATA_INCOMPLETE
:
2345 zfcp_fsf_exchange_port_evaluate(fsf_req
, 0);
2346 atomic_set_mask(ZFCP_STATUS_ADAPTER_XPORT_OK
, &adapter
->status
);
2347 zfcp_fsf_link_down_info_eval(adapter
,
2348 &qtcb
->header
.fsf_status_qual
.link_down_info
);
2351 debug_text_event(adapter
->erp_dbf
, 0, "xchg-port-ng");
2352 debug_event(adapter
->erp_dbf
, 0,
2353 &fsf_req
->qtcb
->header
.fsf_status
, sizeof(u32
));
2359 * function: zfcp_fsf_open_port
2363 * returns: address of initiated FSF request
2364 * NULL - request could not be initiated
2367 zfcp_fsf_open_port(struct zfcp_erp_action
*erp_action
)
2369 volatile struct qdio_buffer_element
*sbale
;
2370 unsigned long lock_flags
;
2373 /* setup new FSF request */
2374 retval
= zfcp_fsf_req_create(erp_action
->adapter
,
2375 FSF_QTCB_OPEN_PORT_WITH_DID
,
2376 ZFCP_WAIT_FOR_SBAL
| ZFCP_REQ_AUTO_CLEANUP
,
2377 erp_action
->adapter
->pool
.fsf_req_erp
,
2378 &lock_flags
, &(erp_action
->fsf_req
));
2380 ZFCP_LOG_INFO("error: Could not create open port request "
2381 "for port 0x%016Lx on adapter %s.\n",
2382 erp_action
->port
->wwpn
,
2383 zfcp_get_busid_by_adapter(erp_action
->adapter
));
2387 sbale
= zfcp_qdio_sbale_req(erp_action
->fsf_req
,
2388 erp_action
->fsf_req
->sbal_curr
, 0);
2389 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_READ
;
2390 sbale
[1].flags
|= SBAL_FLAGS_LAST_ENTRY
;
2392 erp_action
->fsf_req
->qtcb
->bottom
.support
.d_id
= erp_action
->port
->d_id
;
2393 atomic_set_mask(ZFCP_STATUS_COMMON_OPENING
, &erp_action
->port
->status
);
2394 erp_action
->fsf_req
->data
= (unsigned long) erp_action
->port
;
2395 erp_action
->fsf_req
->erp_action
= erp_action
;
2397 /* start QDIO request for this FSF request */
2398 retval
= zfcp_fsf_req_send(erp_action
->fsf_req
, &erp_action
->timer
);
2400 ZFCP_LOG_INFO("error: Could not send open port request for "
2401 "port 0x%016Lx on adapter %s.\n",
2402 erp_action
->port
->wwpn
,
2403 zfcp_get_busid_by_adapter(erp_action
->adapter
));
2404 zfcp_fsf_req_free(erp_action
->fsf_req
);
2405 erp_action
->fsf_req
= NULL
;
2409 ZFCP_LOG_DEBUG("open port request initiated "
2410 "(adapter %s, port 0x%016Lx)\n",
2411 zfcp_get_busid_by_adapter(erp_action
->adapter
),
2412 erp_action
->port
->wwpn
);
2414 write_unlock_irqrestore(&erp_action
->adapter
->request_queue
.queue_lock
,
2420 * function: zfcp_fsf_open_port_handler
2422 * purpose: is called for finished Open Port command
2427 zfcp_fsf_open_port_handler(struct zfcp_fsf_req
*fsf_req
)
2429 int retval
= -EINVAL
;
2430 struct zfcp_port
*port
;
2431 struct fsf_plogi
*plogi
;
2432 struct fsf_qtcb_header
*header
;
2433 u16 subtable
, rule
, counter
;
2435 port
= (struct zfcp_port
*) fsf_req
->data
;
2436 header
= &fsf_req
->qtcb
->header
;
2438 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
) {
2439 /* don't change port status in our bookkeeping */
2440 goto skip_fsfstatus
;
2443 /* evaluate FSF status in QTCB */
2444 switch (header
->fsf_status
) {
2446 case FSF_PORT_ALREADY_OPEN
:
2447 ZFCP_LOG_NORMAL("bug: remote port 0x%016Lx on adapter %s "
2448 "is already open.\n",
2449 port
->wwpn
, zfcp_get_busid_by_port(port
));
2450 debug_text_exception(fsf_req
->adapter
->erp_dbf
, 0,
2453 * This is a bug, however operation should continue normally
2454 * if it is simply ignored
2458 case FSF_ACCESS_DENIED
:
2459 ZFCP_LOG_NORMAL("Access denied, cannot open port 0x%016Lx "
2461 port
->wwpn
, zfcp_get_busid_by_port(port
));
2462 for (counter
= 0; counter
< 2; counter
++) {
2463 subtable
= header
->fsf_status_qual
.halfword
[counter
* 2];
2464 rule
= header
->fsf_status_qual
.halfword
[counter
* 2 + 1];
2466 case FSF_SQ_CFDC_SUBTABLE_OS
:
2467 case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN
:
2468 case FSF_SQ_CFDC_SUBTABLE_PORT_DID
:
2469 case FSF_SQ_CFDC_SUBTABLE_LUN
:
2470 ZFCP_LOG_INFO("Access denied (%s rule %d)\n",
2471 zfcp_act_subtable_type
[subtable
], rule
);
2475 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1, "fsf_s_access");
2476 zfcp_erp_port_access_denied(port
);
2477 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
2480 case FSF_MAXIMUM_NUMBER_OF_PORTS_EXCEEDED
:
2481 ZFCP_LOG_INFO("error: The FSF adapter is out of resources. "
2482 "The remote port 0x%016Lx on adapter %s "
2483 "could not be opened. Disabling it.\n",
2484 port
->wwpn
, zfcp_get_busid_by_port(port
));
2485 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
2487 zfcp_erp_port_failed(port
);
2488 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
2491 case FSF_ADAPTER_STATUS_AVAILABLE
:
2492 switch (header
->fsf_status_qual
.word
[0]) {
2493 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE
:
2494 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
2496 /* ERP strategy will escalate */
2497 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
2499 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED
:
2500 /* ERP strategy will escalate */
2501 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
2503 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
2505 case FSF_SQ_NO_RETRY_POSSIBLE
:
2506 ZFCP_LOG_NORMAL("The remote port 0x%016Lx on "
2507 "adapter %s could not be opened. "
2510 zfcp_get_busid_by_port(port
));
2511 debug_text_exception(fsf_req
->adapter
->erp_dbf
, 0,
2513 zfcp_erp_port_failed(port
);
2514 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
2518 ("bug: Wrong status qualifier 0x%x arrived.\n",
2519 header
->fsf_status_qual
.word
[0]);
2520 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0,
2523 fsf_req
->adapter
->erp_dbf
, 0,
2524 &header
->fsf_status_qual
.word
[0],
2531 /* save port handle assigned by FSF */
2532 port
->handle
= header
->port_handle
;
2533 ZFCP_LOG_INFO("The remote port 0x%016Lx via adapter %s "
2534 "was opened, it's port handle is 0x%x\n",
2535 port
->wwpn
, zfcp_get_busid_by_port(port
),
2537 /* mark port as open */
2538 atomic_set_mask(ZFCP_STATUS_COMMON_OPEN
|
2539 ZFCP_STATUS_PORT_PHYS_OPEN
, &port
->status
);
2540 atomic_clear_mask(ZFCP_STATUS_COMMON_ACCESS_DENIED
|
2541 ZFCP_STATUS_COMMON_ACCESS_BOXED
,
2544 /* check whether D_ID has changed during open */
2546 * FIXME: This check is not airtight, as the FCP channel does
2547 * not monitor closures of target port connections caused on
2548 * the remote side. Thus, they might miss out on invalidating
2549 * locally cached WWPNs (and other N_Port parameters) of gone
2550 * target ports. So, our heroic attempt to make things safe
2551 * could be undermined by 'open port' response data tagged with
2552 * obsolete WWPNs. Another reason to monitor potential
2553 * connection closures ourself at least (by interpreting
2554 * incoming ELS' and unsolicited status). It just crosses my
2555 * mind that one should be able to cross-check by means of
2556 * another GID_PN straight after a port has been opened.
2557 * Alternately, an ADISC/PDISC ELS should suffice, as well.
2559 plogi
= (struct fsf_plogi
*) fsf_req
->qtcb
->bottom
.support
.els
;
2560 if (!atomic_test_mask(ZFCP_STATUS_PORT_NO_WWPN
, &port
->status
))
2562 if (fsf_req
->qtcb
->bottom
.support
.els1_length
<
2563 sizeof (struct fsf_plogi
)) {
2565 "warning: insufficient length of "
2566 "PLOGI payload (%i)\n",
2567 fsf_req
->qtcb
->bottom
.support
.els1_length
);
2568 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0,
2569 "fsf_s_short_plogi:");
2570 /* skip sanity check and assume wwpn is ok */
2572 if (plogi
->serv_param
.wwpn
!= port
->wwpn
) {
2573 ZFCP_LOG_INFO("warning: d_id of port "
2574 "0x%016Lx changed during "
2575 "open\n", port
->wwpn
);
2577 fsf_req
->adapter
->erp_dbf
, 0,
2578 "fsf_s_did_change:");
2580 ZFCP_STATUS_PORT_DID_DID
,
2583 port
->wwnn
= plogi
->serv_param
.wwnn
;
2584 zfcp_plogi_evaluate(port
, plogi
);
2590 case FSF_UNKNOWN_OP_SUBTYPE
:
2591 /* should never occure, subtype not set in zfcp_fsf_open_port */
2592 ZFCP_LOG_INFO("unknown operation subtype (adapter: %s, "
2593 "op_subtype=0x%x)\n",
2594 zfcp_get_busid_by_port(port
),
2595 fsf_req
->qtcb
->bottom
.support
.operation_subtype
);
2596 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
2600 ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
2601 "(debug info 0x%x)\n",
2602 header
->fsf_status
);
2603 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0, "fsf_s_inval:");
2604 debug_exception(fsf_req
->adapter
->erp_dbf
, 0,
2605 &header
->fsf_status
, sizeof (u32
));
2610 atomic_clear_mask(ZFCP_STATUS_COMMON_OPENING
, &port
->status
);
2615 * function: zfcp_fsf_close_port
2617 * purpose: submit FSF command "close port"
2619 * returns: address of initiated FSF request
2620 * NULL - request could not be initiated
2623 zfcp_fsf_close_port(struct zfcp_erp_action
*erp_action
)
2625 volatile struct qdio_buffer_element
*sbale
;
2626 unsigned long lock_flags
;
2629 /* setup new FSF request */
2630 retval
= zfcp_fsf_req_create(erp_action
->adapter
,
2631 FSF_QTCB_CLOSE_PORT
,
2632 ZFCP_WAIT_FOR_SBAL
| ZFCP_REQ_AUTO_CLEANUP
,
2633 erp_action
->adapter
->pool
.fsf_req_erp
,
2634 &lock_flags
, &(erp_action
->fsf_req
));
2636 ZFCP_LOG_INFO("error: Could not create a close port request "
2637 "for port 0x%016Lx on adapter %s.\n",
2638 erp_action
->port
->wwpn
,
2639 zfcp_get_busid_by_adapter(erp_action
->adapter
));
2643 sbale
= zfcp_qdio_sbale_req(erp_action
->fsf_req
,
2644 erp_action
->fsf_req
->sbal_curr
, 0);
2645 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_READ
;
2646 sbale
[1].flags
|= SBAL_FLAGS_LAST_ENTRY
;
2648 atomic_set_mask(ZFCP_STATUS_COMMON_CLOSING
, &erp_action
->port
->status
);
2649 erp_action
->fsf_req
->data
= (unsigned long) erp_action
->port
;
2650 erp_action
->fsf_req
->erp_action
= erp_action
;
2651 erp_action
->fsf_req
->qtcb
->header
.port_handle
=
2652 erp_action
->port
->handle
;
2654 /* start QDIO request for this FSF request */
2655 retval
= zfcp_fsf_req_send(erp_action
->fsf_req
, &erp_action
->timer
);
2657 ZFCP_LOG_INFO("error: Could not send a close port request for "
2658 "port 0x%016Lx on adapter %s.\n",
2659 erp_action
->port
->wwpn
,
2660 zfcp_get_busid_by_adapter(erp_action
->adapter
));
2661 zfcp_fsf_req_free(erp_action
->fsf_req
);
2662 erp_action
->fsf_req
= NULL
;
2666 ZFCP_LOG_TRACE("close port request initiated "
2667 "(adapter %s, port 0x%016Lx)\n",
2668 zfcp_get_busid_by_adapter(erp_action
->adapter
),
2669 erp_action
->port
->wwpn
);
2671 write_unlock_irqrestore(&erp_action
->adapter
->request_queue
.queue_lock
,
2677 * function: zfcp_fsf_close_port_handler
2679 * purpose: is called for finished Close Port FSF command
2684 zfcp_fsf_close_port_handler(struct zfcp_fsf_req
*fsf_req
)
2686 int retval
= -EINVAL
;
2687 struct zfcp_port
*port
;
2689 port
= (struct zfcp_port
*) fsf_req
->data
;
2691 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
) {
2692 /* don't change port status in our bookkeeping */
2693 goto skip_fsfstatus
;
2696 /* evaluate FSF status in QTCB */
2697 switch (fsf_req
->qtcb
->header
.fsf_status
) {
2699 case FSF_PORT_HANDLE_NOT_VALID
:
2700 ZFCP_LOG_INFO("Temporary port identifier 0x%x for port "
2701 "0x%016Lx on adapter %s invalid. This may happen "
2702 "occasionally.\n", port
->handle
,
2703 port
->wwpn
, zfcp_get_busid_by_port(port
));
2704 ZFCP_LOG_DEBUG("status qualifier:\n");
2705 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
2706 (char *) &fsf_req
->qtcb
->header
.fsf_status_qual
,
2707 sizeof (union fsf_status_qual
));
2708 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
2710 zfcp_erp_adapter_reopen(port
->adapter
, 0);
2711 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
2714 case FSF_ADAPTER_STATUS_AVAILABLE
:
2715 /* Note: FSF has actually closed the port in this case.
2716 * The status code is just daft. Fingers crossed for a change
2722 ZFCP_LOG_TRACE("remote port 0x016%Lx on adapter %s closed, "
2723 "port handle 0x%x\n", port
->wwpn
,
2724 zfcp_get_busid_by_port(port
), port
->handle
);
2725 zfcp_erp_modify_port_status(port
,
2726 ZFCP_STATUS_COMMON_OPEN
,
2732 ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
2733 "(debug info 0x%x)\n",
2734 fsf_req
->qtcb
->header
.fsf_status
);
2735 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0, "fsf_s_inval:");
2736 debug_exception(fsf_req
->adapter
->erp_dbf
, 0,
2737 &fsf_req
->qtcb
->header
.fsf_status
,
2743 atomic_clear_mask(ZFCP_STATUS_COMMON_CLOSING
, &port
->status
);
2748 * function: zfcp_fsf_close_physical_port
2750 * purpose: submit FSF command "close physical port"
2752 * returns: address of initiated FSF request
2753 * NULL - request could not be initiated
2756 zfcp_fsf_close_physical_port(struct zfcp_erp_action
*erp_action
)
2759 unsigned long lock_flags
;
2760 volatile struct qdio_buffer_element
*sbale
;
2762 /* setup new FSF request */
2763 retval
= zfcp_fsf_req_create(erp_action
->adapter
,
2764 FSF_QTCB_CLOSE_PHYSICAL_PORT
,
2765 ZFCP_WAIT_FOR_SBAL
| ZFCP_REQ_AUTO_CLEANUP
,
2766 erp_action
->adapter
->pool
.fsf_req_erp
,
2767 &lock_flags
, &erp_action
->fsf_req
);
2769 ZFCP_LOG_INFO("error: Could not create close physical port "
2770 "request (adapter %s, port 0x%016Lx)\n",
2771 zfcp_get_busid_by_adapter(erp_action
->adapter
),
2772 erp_action
->port
->wwpn
);
2777 sbale
= zfcp_qdio_sbale_req(erp_action
->fsf_req
,
2778 erp_action
->fsf_req
->sbal_curr
, 0);
2779 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_READ
;
2780 sbale
[1].flags
|= SBAL_FLAGS_LAST_ENTRY
;
2782 /* mark port as being closed */
2783 atomic_set_mask(ZFCP_STATUS_PORT_PHYS_CLOSING
,
2784 &erp_action
->port
->status
);
2785 /* save a pointer to this port */
2786 erp_action
->fsf_req
->data
= (unsigned long) erp_action
->port
;
2787 /* port to be closed */
2788 erp_action
->fsf_req
->qtcb
->header
.port_handle
=
2789 erp_action
->port
->handle
;
2790 erp_action
->fsf_req
->erp_action
= erp_action
;
2792 /* start QDIO request for this FSF request */
2793 retval
= zfcp_fsf_req_send(erp_action
->fsf_req
, &erp_action
->timer
);
2795 ZFCP_LOG_INFO("error: Could not send close physical port "
2796 "request (adapter %s, port 0x%016Lx)\n",
2797 zfcp_get_busid_by_adapter(erp_action
->adapter
),
2798 erp_action
->port
->wwpn
);
2799 zfcp_fsf_req_free(erp_action
->fsf_req
);
2800 erp_action
->fsf_req
= NULL
;
2804 ZFCP_LOG_TRACE("close physical port request initiated "
2805 "(adapter %s, port 0x%016Lx)\n",
2806 zfcp_get_busid_by_adapter(erp_action
->adapter
),
2807 erp_action
->port
->wwpn
);
2809 write_unlock_irqrestore(&erp_action
->adapter
->request_queue
.queue_lock
,
2815 * function: zfcp_fsf_close_physical_port_handler
2817 * purpose: is called for finished Close Physical Port FSF command
2822 zfcp_fsf_close_physical_port_handler(struct zfcp_fsf_req
*fsf_req
)
2824 int retval
= -EINVAL
;
2825 struct zfcp_port
*port
;
2826 struct zfcp_unit
*unit
;
2827 struct fsf_qtcb_header
*header
;
2828 u16 subtable
, rule
, counter
;
2830 port
= (struct zfcp_port
*) fsf_req
->data
;
2831 header
= &fsf_req
->qtcb
->header
;
2833 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
) {
2834 /* don't change port status in our bookkeeping */
2835 goto skip_fsfstatus
;
2838 /* evaluate FSF status in QTCB */
2839 switch (header
->fsf_status
) {
2841 case FSF_PORT_HANDLE_NOT_VALID
:
2842 ZFCP_LOG_INFO("Temporary port identifier 0x%x invalid"
2843 "(adapter %s, port 0x%016Lx). "
2844 "This may happen occasionally.\n",
2846 zfcp_get_busid_by_port(port
),
2848 ZFCP_LOG_DEBUG("status qualifier:\n");
2849 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
2850 (char *) &header
->fsf_status_qual
,
2851 sizeof (union fsf_status_qual
));
2852 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
2854 zfcp_erp_adapter_reopen(port
->adapter
, 0);
2855 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
2858 case FSF_ACCESS_DENIED
:
2859 ZFCP_LOG_NORMAL("Access denied, cannot close "
2860 "physical port 0x%016Lx on adapter %s\n",
2861 port
->wwpn
, zfcp_get_busid_by_port(port
));
2862 for (counter
= 0; counter
< 2; counter
++) {
2863 subtable
= header
->fsf_status_qual
.halfword
[counter
* 2];
2864 rule
= header
->fsf_status_qual
.halfword
[counter
* 2 + 1];
2866 case FSF_SQ_CFDC_SUBTABLE_OS
:
2867 case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN
:
2868 case FSF_SQ_CFDC_SUBTABLE_PORT_DID
:
2869 case FSF_SQ_CFDC_SUBTABLE_LUN
:
2870 ZFCP_LOG_INFO("Access denied (%s rule %d)\n",
2871 zfcp_act_subtable_type
[subtable
], rule
);
2875 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1, "fsf_s_access");
2876 zfcp_erp_port_access_denied(port
);
2877 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
2880 case FSF_PORT_BOXED
:
2881 ZFCP_LOG_DEBUG("The remote port 0x%016Lx on adapter "
2882 "%s needs to be reopened but it was attempted "
2883 "to close it physically.\n",
2885 zfcp_get_busid_by_port(port
));
2886 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1, "fsf_s_pboxed");
2887 zfcp_erp_port_boxed(port
);
2888 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
|
2889 ZFCP_STATUS_FSFREQ_RETRY
;
2892 case FSF_ADAPTER_STATUS_AVAILABLE
:
2893 switch (header
->fsf_status_qual
.word
[0]) {
2894 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE
:
2895 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
2897 /* This will now be escalated by ERP */
2898 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
2900 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED
:
2901 /* ERP strategy will escalate */
2902 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
2904 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
2908 ("bug: Wrong status qualifier 0x%x arrived.\n",
2909 header
->fsf_status_qual
.word
[0]);
2910 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0,
2913 fsf_req
->adapter
->erp_dbf
, 0,
2914 &header
->fsf_status_qual
.word
[0], sizeof (u32
));
2920 ZFCP_LOG_DEBUG("Remote port 0x%016Lx via adapter %s "
2921 "physically closed, port handle 0x%x\n",
2923 zfcp_get_busid_by_port(port
), port
->handle
);
2924 /* can't use generic zfcp_erp_modify_port_status because
2925 * ZFCP_STATUS_COMMON_OPEN must not be reset for the port
2927 atomic_clear_mask(ZFCP_STATUS_PORT_PHYS_OPEN
, &port
->status
);
2928 list_for_each_entry(unit
, &port
->unit_list_head
, list
)
2929 atomic_clear_mask(ZFCP_STATUS_COMMON_OPEN
, &unit
->status
);
2934 ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
2935 "(debug info 0x%x)\n",
2936 header
->fsf_status
);
2937 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0, "fsf_s_inval:");
2938 debug_exception(fsf_req
->adapter
->erp_dbf
, 0,
2939 &header
->fsf_status
, sizeof (u32
));
2944 atomic_clear_mask(ZFCP_STATUS_PORT_PHYS_CLOSING
, &port
->status
);
2949 * function: zfcp_fsf_open_unit
2955 * assumptions: This routine does not check whether the associated
2956 * remote port has already been opened. This should be
2957 * done by calling routines. Otherwise some status
2958 * may be presented by FSF
2961 zfcp_fsf_open_unit(struct zfcp_erp_action
*erp_action
)
2963 volatile struct qdio_buffer_element
*sbale
;
2964 unsigned long lock_flags
;
2967 /* setup new FSF request */
2968 retval
= zfcp_fsf_req_create(erp_action
->adapter
,
2970 ZFCP_WAIT_FOR_SBAL
| ZFCP_REQ_AUTO_CLEANUP
,
2971 erp_action
->adapter
->pool
.fsf_req_erp
,
2972 &lock_flags
, &(erp_action
->fsf_req
));
2974 ZFCP_LOG_INFO("error: Could not create open unit request for "
2975 "unit 0x%016Lx on port 0x%016Lx on adapter %s.\n",
2976 erp_action
->unit
->fcp_lun
,
2977 erp_action
->unit
->port
->wwpn
,
2978 zfcp_get_busid_by_adapter(erp_action
->adapter
));
2982 sbale
= zfcp_qdio_sbale_req(erp_action
->fsf_req
,
2983 erp_action
->fsf_req
->sbal_curr
, 0);
2984 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_READ
;
2985 sbale
[1].flags
|= SBAL_FLAGS_LAST_ENTRY
;
2987 erp_action
->fsf_req
->qtcb
->header
.port_handle
=
2988 erp_action
->port
->handle
;
2989 erp_action
->fsf_req
->qtcb
->bottom
.support
.fcp_lun
=
2990 erp_action
->unit
->fcp_lun
;
2991 if (!(erp_action
->adapter
->connection_features
& FSF_FEATURE_NPIV_MODE
))
2992 erp_action
->fsf_req
->qtcb
->bottom
.support
.option
=
2993 FSF_OPEN_LUN_SUPPRESS_BOXING
;
2994 atomic_set_mask(ZFCP_STATUS_COMMON_OPENING
, &erp_action
->unit
->status
);
2995 erp_action
->fsf_req
->data
= (unsigned long) erp_action
->unit
;
2996 erp_action
->fsf_req
->erp_action
= erp_action
;
2998 /* start QDIO request for this FSF request */
2999 retval
= zfcp_fsf_req_send(erp_action
->fsf_req
, &erp_action
->timer
);
3001 ZFCP_LOG_INFO("error: Could not send an open unit request "
3002 "on the adapter %s, port 0x%016Lx for "
3004 zfcp_get_busid_by_adapter(erp_action
->adapter
),
3005 erp_action
->port
->wwpn
,
3006 erp_action
->unit
->fcp_lun
);
3007 zfcp_fsf_req_free(erp_action
->fsf_req
);
3008 erp_action
->fsf_req
= NULL
;
3012 ZFCP_LOG_TRACE("Open LUN request initiated (adapter %s, "
3013 "port 0x%016Lx, unit 0x%016Lx)\n",
3014 zfcp_get_busid_by_adapter(erp_action
->adapter
),
3015 erp_action
->port
->wwpn
, erp_action
->unit
->fcp_lun
);
3017 write_unlock_irqrestore(&erp_action
->adapter
->request_queue
.queue_lock
,
3023 * function: zfcp_fsf_open_unit_handler
3025 * purpose: is called for finished Open LUN command
3030 zfcp_fsf_open_unit_handler(struct zfcp_fsf_req
*fsf_req
)
3032 int retval
= -EINVAL
;
3033 struct zfcp_adapter
*adapter
;
3034 struct zfcp_unit
*unit
;
3035 struct fsf_qtcb_header
*header
;
3036 struct fsf_qtcb_bottom_support
*bottom
;
3037 struct fsf_queue_designator
*queue_designator
;
3038 u16 subtable
, rule
, counter
;
3039 int exclusive
, readwrite
;
3041 unit
= (struct zfcp_unit
*) fsf_req
->data
;
3043 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
) {
3044 /* don't change unit status in our bookkeeping */
3045 goto skip_fsfstatus
;
3048 adapter
= fsf_req
->adapter
;
3049 header
= &fsf_req
->qtcb
->header
;
3050 bottom
= &fsf_req
->qtcb
->bottom
.support
;
3051 queue_designator
= &header
->fsf_status_qual
.fsf_queue_designator
;
3053 atomic_clear_mask(ZFCP_STATUS_COMMON_ACCESS_DENIED
|
3054 ZFCP_STATUS_UNIT_SHARED
|
3055 ZFCP_STATUS_UNIT_READONLY
,
3058 /* evaluate FSF status in QTCB */
3059 switch (header
->fsf_status
) {
3061 case FSF_PORT_HANDLE_NOT_VALID
:
3062 ZFCP_LOG_INFO("Temporary port identifier 0x%x "
3063 "for port 0x%016Lx on adapter %s invalid "
3064 "This may happen occasionally\n",
3066 unit
->port
->wwpn
, zfcp_get_busid_by_unit(unit
));
3067 ZFCP_LOG_DEBUG("status qualifier:\n");
3068 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
3069 (char *) &header
->fsf_status_qual
,
3070 sizeof (union fsf_status_qual
));
3071 debug_text_event(adapter
->erp_dbf
, 1, "fsf_s_ph_nv");
3072 zfcp_erp_adapter_reopen(unit
->port
->adapter
, 0);
3073 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3076 case FSF_LUN_ALREADY_OPEN
:
3077 ZFCP_LOG_NORMAL("bug: Attempted to open unit 0x%016Lx on "
3078 "remote port 0x%016Lx on adapter %s twice.\n",
3080 unit
->port
->wwpn
, zfcp_get_busid_by_unit(unit
));
3081 debug_text_exception(adapter
->erp_dbf
, 0,
3083 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3086 case FSF_ACCESS_DENIED
:
3087 ZFCP_LOG_NORMAL("Access denied, cannot open unit 0x%016Lx on "
3088 "remote port 0x%016Lx on adapter %s\n",
3089 unit
->fcp_lun
, unit
->port
->wwpn
,
3090 zfcp_get_busid_by_unit(unit
));
3091 for (counter
= 0; counter
< 2; counter
++) {
3092 subtable
= header
->fsf_status_qual
.halfword
[counter
* 2];
3093 rule
= header
->fsf_status_qual
.halfword
[counter
* 2 + 1];
3095 case FSF_SQ_CFDC_SUBTABLE_OS
:
3096 case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN
:
3097 case FSF_SQ_CFDC_SUBTABLE_PORT_DID
:
3098 case FSF_SQ_CFDC_SUBTABLE_LUN
:
3099 ZFCP_LOG_INFO("Access denied (%s rule %d)\n",
3100 zfcp_act_subtable_type
[subtable
], rule
);
3104 debug_text_event(adapter
->erp_dbf
, 1, "fsf_s_access");
3105 zfcp_erp_unit_access_denied(unit
);
3106 atomic_clear_mask(ZFCP_STATUS_UNIT_SHARED
, &unit
->status
);
3107 atomic_clear_mask(ZFCP_STATUS_UNIT_READONLY
, &unit
->status
);
3108 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3111 case FSF_PORT_BOXED
:
3112 ZFCP_LOG_DEBUG("The remote port 0x%016Lx on adapter %s "
3113 "needs to be reopened\n",
3114 unit
->port
->wwpn
, zfcp_get_busid_by_unit(unit
));
3115 debug_text_event(adapter
->erp_dbf
, 2, "fsf_s_pboxed");
3116 zfcp_erp_port_boxed(unit
->port
);
3117 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
|
3118 ZFCP_STATUS_FSFREQ_RETRY
;
3121 case FSF_LUN_SHARING_VIOLATION
:
3122 if (header
->fsf_status_qual
.word
[0] != 0) {
3123 ZFCP_LOG_NORMAL("FCP-LUN 0x%Lx at the remote port "
3125 "connected to the adapter %s "
3126 "is already in use in LPAR%d, CSS%d\n",
3129 zfcp_get_busid_by_unit(unit
),
3130 queue_designator
->hla
,
3131 queue_designator
->cssid
);
3133 subtable
= header
->fsf_status_qual
.halfword
[4];
3134 rule
= header
->fsf_status_qual
.halfword
[5];
3136 case FSF_SQ_CFDC_SUBTABLE_OS
:
3137 case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN
:
3138 case FSF_SQ_CFDC_SUBTABLE_PORT_DID
:
3139 case FSF_SQ_CFDC_SUBTABLE_LUN
:
3140 ZFCP_LOG_NORMAL("Access to FCP-LUN 0x%Lx at the "
3141 "remote port with WWPN 0x%Lx "
3142 "connected to the adapter %s "
3143 "is denied (%s rule %d)\n",
3146 zfcp_get_busid_by_unit(unit
),
3147 zfcp_act_subtable_type
[subtable
],
3152 ZFCP_LOG_DEBUG("status qualifier:\n");
3153 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
3154 (char *) &header
->fsf_status_qual
,
3155 sizeof (union fsf_status_qual
));
3156 debug_text_event(adapter
->erp_dbf
, 2,
3158 zfcp_erp_unit_access_denied(unit
);
3159 atomic_clear_mask(ZFCP_STATUS_UNIT_SHARED
, &unit
->status
);
3160 atomic_clear_mask(ZFCP_STATUS_UNIT_READONLY
, &unit
->status
);
3161 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3164 case FSF_MAXIMUM_NUMBER_OF_LUNS_EXCEEDED
:
3165 ZFCP_LOG_INFO("error: The adapter ran out of resources. "
3166 "There is no handle (temporary port identifier) "
3167 "available for unit 0x%016Lx on port 0x%016Lx "
3171 zfcp_get_busid_by_unit(unit
));
3172 debug_text_event(adapter
->erp_dbf
, 1,
3174 zfcp_erp_unit_failed(unit
);
3175 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3178 case FSF_ADAPTER_STATUS_AVAILABLE
:
3179 switch (header
->fsf_status_qual
.word
[0]) {
3180 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE
:
3181 /* Re-establish link to port */
3182 debug_text_event(adapter
->erp_dbf
, 1,
3184 zfcp_test_link(unit
->port
);
3185 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3187 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED
:
3188 /* ERP strategy will escalate */
3189 debug_text_event(adapter
->erp_dbf
, 1,
3191 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3195 ("bug: Wrong status qualifier 0x%x arrived.\n",
3196 header
->fsf_status_qual
.word
[0]);
3197 debug_text_event(adapter
->erp_dbf
, 0,
3199 debug_exception(adapter
->erp_dbf
, 0,
3200 &header
->fsf_status_qual
.word
[0],
3205 case FSF_INVALID_COMMAND_OPTION
:
3207 "Invalid option 0x%x has been specified "
3208 "in QTCB bottom sent to the adapter %s\n",
3210 zfcp_get_busid_by_adapter(adapter
));
3211 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3216 /* save LUN handle assigned by FSF */
3217 unit
->handle
= header
->lun_handle
;
3218 ZFCP_LOG_TRACE("unit 0x%016Lx on remote port 0x%016Lx on "
3219 "adapter %s opened, port handle 0x%x\n",
3222 zfcp_get_busid_by_unit(unit
),
3224 /* mark unit as open */
3225 atomic_set_mask(ZFCP_STATUS_COMMON_OPEN
, &unit
->status
);
3227 if (!(adapter
->connection_features
& FSF_FEATURE_NPIV_MODE
) &&
3228 (adapter
->adapter_features
& FSF_FEATURE_LUN_SHARING
) &&
3229 (adapter
->ccw_device
->id
.dev_model
!= ZFCP_DEVICE_MODEL_PRIV
)) {
3230 exclusive
= (bottom
->lun_access_info
&
3231 FSF_UNIT_ACCESS_EXCLUSIVE
);
3232 readwrite
= (bottom
->lun_access_info
&
3233 FSF_UNIT_ACCESS_OUTBOUND_TRANSFER
);
3236 atomic_set_mask(ZFCP_STATUS_UNIT_SHARED
,
3240 atomic_set_mask(ZFCP_STATUS_UNIT_READONLY
,
3242 ZFCP_LOG_NORMAL("read-only access for unit "
3243 "(adapter %s, wwpn=0x%016Lx, "
3244 "fcp_lun=0x%016Lx)\n",
3245 zfcp_get_busid_by_unit(unit
),
3250 if (exclusive
&& !readwrite
) {
3251 ZFCP_LOG_NORMAL("exclusive access of read-only "
3252 "unit not supported\n");
3253 zfcp_erp_unit_failed(unit
);
3254 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3255 zfcp_erp_unit_shutdown(unit
, 0);
3256 } else if (!exclusive
&& readwrite
) {
3257 ZFCP_LOG_NORMAL("shared access of read-write "
3258 "unit not supported\n");
3259 zfcp_erp_unit_failed(unit
);
3260 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3261 zfcp_erp_unit_shutdown(unit
, 0);
3269 ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
3270 "(debug info 0x%x)\n",
3271 header
->fsf_status
);
3272 debug_text_event(adapter
->erp_dbf
, 0, "fsf_s_inval:");
3273 debug_exception(adapter
->erp_dbf
, 0,
3274 &header
->fsf_status
, sizeof (u32
));
3279 atomic_clear_mask(ZFCP_STATUS_COMMON_OPENING
, &unit
->status
);
3284 * function: zfcp_fsf_close_unit
3288 * returns: address of fsf_req - request successfully initiated
3291 * assumptions: This routine does not check whether the associated
3292 * remote port/lun has already been opened. This should be
3293 * done by calling routines. Otherwise some status
3294 * may be presented by FSF
3297 zfcp_fsf_close_unit(struct zfcp_erp_action
*erp_action
)
3299 volatile struct qdio_buffer_element
*sbale
;
3300 unsigned long lock_flags
;
3303 /* setup new FSF request */
3304 retval
= zfcp_fsf_req_create(erp_action
->adapter
,
3306 ZFCP_WAIT_FOR_SBAL
| ZFCP_REQ_AUTO_CLEANUP
,
3307 erp_action
->adapter
->pool
.fsf_req_erp
,
3308 &lock_flags
, &(erp_action
->fsf_req
));
3310 ZFCP_LOG_INFO("error: Could not create close unit request for "
3311 "unit 0x%016Lx on port 0x%016Lx on adapter %s.\n",
3312 erp_action
->unit
->fcp_lun
,
3313 erp_action
->port
->wwpn
,
3314 zfcp_get_busid_by_adapter(erp_action
->adapter
));
3318 sbale
= zfcp_qdio_sbale_req(erp_action
->fsf_req
,
3319 erp_action
->fsf_req
->sbal_curr
, 0);
3320 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_READ
;
3321 sbale
[1].flags
|= SBAL_FLAGS_LAST_ENTRY
;
3323 erp_action
->fsf_req
->qtcb
->header
.port_handle
=
3324 erp_action
->port
->handle
;
3325 erp_action
->fsf_req
->qtcb
->header
.lun_handle
= erp_action
->unit
->handle
;
3326 atomic_set_mask(ZFCP_STATUS_COMMON_CLOSING
, &erp_action
->unit
->status
);
3327 erp_action
->fsf_req
->data
= (unsigned long) erp_action
->unit
;
3328 erp_action
->fsf_req
->erp_action
= erp_action
;
3330 /* start QDIO request for this FSF request */
3331 retval
= zfcp_fsf_req_send(erp_action
->fsf_req
, &erp_action
->timer
);
3333 ZFCP_LOG_INFO("error: Could not send a close unit request for "
3334 "unit 0x%016Lx on port 0x%016Lx onadapter %s.\n",
3335 erp_action
->unit
->fcp_lun
,
3336 erp_action
->port
->wwpn
,
3337 zfcp_get_busid_by_adapter(erp_action
->adapter
));
3338 zfcp_fsf_req_free(erp_action
->fsf_req
);
3339 erp_action
->fsf_req
= NULL
;
3343 ZFCP_LOG_TRACE("Close LUN request initiated (adapter %s, "
3344 "port 0x%016Lx, unit 0x%016Lx)\n",
3345 zfcp_get_busid_by_adapter(erp_action
->adapter
),
3346 erp_action
->port
->wwpn
, erp_action
->unit
->fcp_lun
);
3348 write_unlock_irqrestore(&erp_action
->adapter
->request_queue
.queue_lock
,
3354 * function: zfcp_fsf_close_unit_handler
3356 * purpose: is called for finished Close LUN FSF command
3361 zfcp_fsf_close_unit_handler(struct zfcp_fsf_req
*fsf_req
)
3363 int retval
= -EINVAL
;
3364 struct zfcp_unit
*unit
;
3366 unit
= (struct zfcp_unit
*) fsf_req
->data
;
3368 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
) {
3369 /* don't change unit status in our bookkeeping */
3370 goto skip_fsfstatus
;
3373 /* evaluate FSF status in QTCB */
3374 switch (fsf_req
->qtcb
->header
.fsf_status
) {
3376 case FSF_PORT_HANDLE_NOT_VALID
:
3377 ZFCP_LOG_INFO("Temporary port identifier 0x%x for port "
3378 "0x%016Lx on adapter %s invalid. This may "
3379 "happen in rare circumstances\n",
3382 zfcp_get_busid_by_unit(unit
));
3383 ZFCP_LOG_DEBUG("status qualifier:\n");
3384 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
3385 (char *) &fsf_req
->qtcb
->header
.fsf_status_qual
,
3386 sizeof (union fsf_status_qual
));
3387 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
3389 zfcp_erp_adapter_reopen(unit
->port
->adapter
, 0);
3390 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3393 case FSF_LUN_HANDLE_NOT_VALID
:
3394 ZFCP_LOG_INFO("Temporary LUN identifier 0x%x of unit "
3395 "0x%016Lx on port 0x%016Lx on adapter %s is "
3396 "invalid. This may happen occasionally.\n",
3400 zfcp_get_busid_by_unit(unit
));
3401 ZFCP_LOG_DEBUG("Status qualifier data:\n");
3402 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
3403 (char *) &fsf_req
->qtcb
->header
.fsf_status_qual
,
3404 sizeof (union fsf_status_qual
));
3405 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
3407 zfcp_erp_port_reopen(unit
->port
, 0);
3408 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3411 case FSF_PORT_BOXED
:
3412 ZFCP_LOG_DEBUG("The remote port 0x%016Lx on adapter %s "
3413 "needs to be reopened\n",
3415 zfcp_get_busid_by_unit(unit
));
3416 debug_text_event(fsf_req
->adapter
->erp_dbf
, 2, "fsf_s_pboxed");
3417 zfcp_erp_port_boxed(unit
->port
);
3418 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
|
3419 ZFCP_STATUS_FSFREQ_RETRY
;
3422 case FSF_ADAPTER_STATUS_AVAILABLE
:
3423 switch (fsf_req
->qtcb
->header
.fsf_status_qual
.word
[0]) {
3424 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE
:
3425 /* re-establish link to port */
3426 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
3428 zfcp_test_link(unit
->port
);
3429 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3431 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED
:
3432 /* ERP strategy will escalate */
3433 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
3435 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3439 ("bug: Wrong status qualifier 0x%x arrived.\n",
3440 fsf_req
->qtcb
->header
.fsf_status_qual
.word
[0]);
3441 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0,
3444 fsf_req
->adapter
->erp_dbf
, 0,
3445 &fsf_req
->qtcb
->header
.fsf_status_qual
.word
[0],
3452 ZFCP_LOG_TRACE("unit 0x%016Lx on port 0x%016Lx on adapter %s "
3453 "closed, port handle 0x%x\n",
3456 zfcp_get_busid_by_unit(unit
),
3458 /* mark unit as closed */
3459 atomic_clear_mask(ZFCP_STATUS_COMMON_OPEN
, &unit
->status
);
3464 ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
3465 "(debug info 0x%x)\n",
3466 fsf_req
->qtcb
->header
.fsf_status
);
3467 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0, "fsf_s_inval:");
3468 debug_exception(fsf_req
->adapter
->erp_dbf
, 0,
3469 &fsf_req
->qtcb
->header
.fsf_status
,
3475 atomic_clear_mask(ZFCP_STATUS_COMMON_CLOSING
, &unit
->status
);
3480 * zfcp_fsf_send_fcp_command_task - initiate an FCP command (for a SCSI command)
3481 * @adapter: adapter where scsi command is issued
3482 * @unit: unit where command is sent to
3483 * @scsi_cmnd: scsi command to be sent
3484 * @timer: timer to be started when request is initiated
3485 * @req_flags: flags for fsf_request
3488 zfcp_fsf_send_fcp_command_task(struct zfcp_adapter
*adapter
,
3489 struct zfcp_unit
*unit
,
3490 struct scsi_cmnd
* scsi_cmnd
,
3491 struct timer_list
*timer
, int req_flags
)
3493 struct zfcp_fsf_req
*fsf_req
= NULL
;
3494 struct fcp_cmnd_iu
*fcp_cmnd_iu
;
3495 unsigned int sbtype
;
3496 unsigned long lock_flags
;
3501 /* setup new FSF request */
3502 retval
= zfcp_fsf_req_create(adapter
, FSF_QTCB_FCP_CMND
, req_flags
,
3503 adapter
->pool
.fsf_req_scsi
,
3504 &lock_flags
, &fsf_req
);
3505 if (unlikely(retval
< 0)) {
3506 ZFCP_LOG_DEBUG("error: Could not create FCP command request "
3507 "for unit 0x%016Lx on port 0x%016Lx on "
3511 zfcp_get_busid_by_adapter(adapter
));
3512 goto failed_req_create
;
3515 zfcp_unit_get(unit
);
3516 fsf_req
->unit
= unit
;
3518 /* associate FSF request with SCSI request (for look up on abort) */
3519 scsi_cmnd
->host_scribble
= (char *) fsf_req
;
3521 /* associate SCSI command with FSF request */
3522 fsf_req
->data
= (unsigned long) scsi_cmnd
;
3524 /* set handles of unit and its parent port in QTCB */
3525 fsf_req
->qtcb
->header
.lun_handle
= unit
->handle
;
3526 fsf_req
->qtcb
->header
.port_handle
= unit
->port
->handle
;
3528 /* FSF does not define the structure of the FCP_CMND IU */
3529 fcp_cmnd_iu
= (struct fcp_cmnd_iu
*)
3530 &(fsf_req
->qtcb
->bottom
.io
.fcp_cmnd
);
3533 * set depending on data direction:
3534 * data direction bits in SBALE (SB Type)
3535 * data direction bits in QTCB
3536 * data direction bits in FCP_CMND IU
3538 switch (scsi_cmnd
->sc_data_direction
) {
3540 fsf_req
->qtcb
->bottom
.io
.data_direction
= FSF_DATADIR_CMND
;
3543 * what is the correct type for commands
3544 * without 'real' data buffers?
3546 sbtype
= SBAL_FLAGS0_TYPE_READ
;
3548 case DMA_FROM_DEVICE
:
3549 fsf_req
->qtcb
->bottom
.io
.data_direction
= FSF_DATADIR_READ
;
3550 sbtype
= SBAL_FLAGS0_TYPE_READ
;
3551 fcp_cmnd_iu
->rddata
= 1;
3554 fsf_req
->qtcb
->bottom
.io
.data_direction
= FSF_DATADIR_WRITE
;
3555 sbtype
= SBAL_FLAGS0_TYPE_WRITE
;
3556 fcp_cmnd_iu
->wddata
= 1;
3558 case DMA_BIDIRECTIONAL
:
3561 * dummy, catch this condition earlier
3562 * in zfcp_scsi_queuecommand
3564 goto failed_scsi_cmnd
;
3567 /* set FC service class in QTCB (3 per default) */
3568 fsf_req
->qtcb
->bottom
.io
.service_class
= ZFCP_FC_SERVICE_CLASS_DEFAULT
;
3570 /* set FCP_LUN in FCP_CMND IU in QTCB */
3571 fcp_cmnd_iu
->fcp_lun
= unit
->fcp_lun
;
3573 mask
= ZFCP_STATUS_UNIT_READONLY
| ZFCP_STATUS_UNIT_SHARED
;
3575 /* set task attributes in FCP_CMND IU in QTCB */
3576 if (likely((scsi_cmnd
->device
->simple_tags
) ||
3577 (atomic_test_mask(mask
, &unit
->status
))))
3578 fcp_cmnd_iu
->task_attribute
= SIMPLE_Q
;
3580 fcp_cmnd_iu
->task_attribute
= UNTAGGED
;
3582 /* set additional length of FCP_CDB in FCP_CMND IU in QTCB, if needed */
3583 if (unlikely(scsi_cmnd
->cmd_len
> FCP_CDB_LENGTH
)) {
3584 fcp_cmnd_iu
->add_fcp_cdb_length
3585 = (scsi_cmnd
->cmd_len
- FCP_CDB_LENGTH
) >> 2;
3586 ZFCP_LOG_TRACE("SCSI CDB length is 0x%x, "
3587 "additional FCP_CDB length is 0x%x "
3588 "(shifted right 2 bits)\n",
3590 fcp_cmnd_iu
->add_fcp_cdb_length
);
3593 * copy SCSI CDB (including additional length, if any) to
3594 * FCP_CDB in FCP_CMND IU in QTCB
3596 memcpy(fcp_cmnd_iu
->fcp_cdb
, scsi_cmnd
->cmnd
, scsi_cmnd
->cmd_len
);
3598 /* FCP CMND IU length in QTCB */
3599 fsf_req
->qtcb
->bottom
.io
.fcp_cmnd_length
=
3600 sizeof (struct fcp_cmnd_iu
) +
3601 fcp_cmnd_iu
->add_fcp_cdb_length
+ sizeof (fcp_dl_t
);
3603 /* generate SBALEs from data buffer */
3604 real_bytes
= zfcp_qdio_sbals_from_scsicmnd(fsf_req
, sbtype
, scsi_cmnd
);
3605 if (unlikely(real_bytes
< 0)) {
3606 if (fsf_req
->sbal_number
< ZFCP_MAX_SBALS_PER_REQ
) {
3608 "Data did not fit into available buffer(s), "
3609 "waiting for more...\n");
3612 ZFCP_LOG_NORMAL("error: No truncation implemented but "
3613 "required. Shutting down unit "
3614 "(adapter %s, port 0x%016Lx, "
3616 zfcp_get_busid_by_unit(unit
),
3619 zfcp_erp_unit_shutdown(unit
, 0);
3625 /* set length of FCP data length in FCP_CMND IU in QTCB */
3626 zfcp_set_fcp_dl(fcp_cmnd_iu
, real_bytes
);
3628 ZFCP_LOG_DEBUG("Sending SCSI command:\n");
3629 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
3630 (char *) scsi_cmnd
->cmnd
, scsi_cmnd
->cmd_len
);
3633 * start QDIO request for this FSF request
3634 * covered by an SBALE)
3636 retval
= zfcp_fsf_req_send(fsf_req
, timer
);
3637 if (unlikely(retval
< 0)) {
3638 ZFCP_LOG_INFO("error: Could not send FCP command request "
3639 "on adapter %s, port 0x%016Lx, unit 0x%016Lx\n",
3640 zfcp_get_busid_by_adapter(adapter
),
3646 ZFCP_LOG_TRACE("Send FCP Command initiated (adapter %s, "
3647 "port 0x%016Lx, unit 0x%016Lx)\n",
3648 zfcp_get_busid_by_adapter(adapter
),
3656 zfcp_unit_put(unit
);
3657 zfcp_fsf_req_free(fsf_req
);
3659 scsi_cmnd
->host_scribble
= NULL
;
3662 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
, lock_flags
);
3666 struct zfcp_fsf_req
*
3667 zfcp_fsf_send_fcp_command_task_management(struct zfcp_adapter
*adapter
,
3668 struct zfcp_unit
*unit
,
3669 u8 tm_flags
, int req_flags
)
3671 struct zfcp_fsf_req
*fsf_req
= NULL
;
3673 struct fcp_cmnd_iu
*fcp_cmnd_iu
;
3674 unsigned long lock_flags
;
3675 volatile struct qdio_buffer_element
*sbale
;
3677 /* setup new FSF request */
3678 retval
= zfcp_fsf_req_create(adapter
, FSF_QTCB_FCP_CMND
, req_flags
,
3679 adapter
->pool
.fsf_req_scsi
,
3680 &lock_flags
, &fsf_req
);
3682 ZFCP_LOG_INFO("error: Could not create FCP command (task "
3683 "management) request for adapter %s, port "
3684 " 0x%016Lx, unit 0x%016Lx.\n",
3685 zfcp_get_busid_by_adapter(adapter
),
3686 unit
->port
->wwpn
, unit
->fcp_lun
);
3691 * Used to decide on proper handler in the return path,
3692 * could be either zfcp_fsf_send_fcp_command_task_handler or
3693 * zfcp_fsf_send_fcp_command_task_management_handler */
3695 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT
;
3698 * hold a pointer to the unit being target of this
3699 * task management request
3701 fsf_req
->data
= (unsigned long) unit
;
3703 /* set FSF related fields in QTCB */
3704 fsf_req
->qtcb
->header
.lun_handle
= unit
->handle
;
3705 fsf_req
->qtcb
->header
.port_handle
= unit
->port
->handle
;
3706 fsf_req
->qtcb
->bottom
.io
.data_direction
= FSF_DATADIR_CMND
;
3707 fsf_req
->qtcb
->bottom
.io
.service_class
= ZFCP_FC_SERVICE_CLASS_DEFAULT
;
3708 fsf_req
->qtcb
->bottom
.io
.fcp_cmnd_length
=
3709 sizeof (struct fcp_cmnd_iu
) + sizeof (fcp_dl_t
);
3711 sbale
= zfcp_qdio_sbale_req(fsf_req
, fsf_req
->sbal_curr
, 0);
3712 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_WRITE
;
3713 sbale
[1].flags
|= SBAL_FLAGS_LAST_ENTRY
;
3715 /* set FCP related fields in FCP_CMND IU in QTCB */
3716 fcp_cmnd_iu
= (struct fcp_cmnd_iu
*)
3717 &(fsf_req
->qtcb
->bottom
.io
.fcp_cmnd
);
3718 fcp_cmnd_iu
->fcp_lun
= unit
->fcp_lun
;
3719 fcp_cmnd_iu
->task_management_flags
= tm_flags
;
3721 /* start QDIO request for this FSF request */
3722 zfcp_fsf_start_scsi_er_timer(adapter
);
3723 retval
= zfcp_fsf_req_send(fsf_req
, NULL
);
3725 del_timer(&adapter
->scsi_er_timer
);
3726 ZFCP_LOG_INFO("error: Could not send an FCP-command (task "
3727 "management) on adapter %s, port 0x%016Lx for "
3728 "unit LUN 0x%016Lx\n",
3729 zfcp_get_busid_by_adapter(adapter
),
3732 zfcp_fsf_req_free(fsf_req
);
3737 ZFCP_LOG_TRACE("Send FCP Command (task management function) initiated "
3738 "(adapter %s, port 0x%016Lx, unit 0x%016Lx, "
3740 zfcp_get_busid_by_adapter(adapter
),
3745 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
, lock_flags
);
3750 * function: zfcp_fsf_send_fcp_command_handler
3752 * purpose: is called for finished Send FCP Command
3757 zfcp_fsf_send_fcp_command_handler(struct zfcp_fsf_req
*fsf_req
)
3759 int retval
= -EINVAL
;
3760 struct zfcp_unit
*unit
;
3761 struct fsf_qtcb_header
*header
;
3762 u16 subtable
, rule
, counter
;
3764 header
= &fsf_req
->qtcb
->header
;
3766 if (unlikely(fsf_req
->status
& ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT
))
3767 unit
= (struct zfcp_unit
*) fsf_req
->data
;
3769 unit
= fsf_req
->unit
;
3771 if (unlikely(fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
)) {
3772 /* go directly to calls of special handlers */
3773 goto skip_fsfstatus
;
3776 /* evaluate FSF status in QTCB */
3777 switch (header
->fsf_status
) {
3779 case FSF_PORT_HANDLE_NOT_VALID
:
3780 ZFCP_LOG_INFO("Temporary port identifier 0x%x for port "
3781 "0x%016Lx on adapter %s invalid\n",
3783 unit
->port
->wwpn
, zfcp_get_busid_by_unit(unit
));
3784 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
3785 (char *) &header
->fsf_status_qual
,
3786 sizeof (union fsf_status_qual
));
3787 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
3789 zfcp_erp_adapter_reopen(unit
->port
->adapter
, 0);
3790 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3793 case FSF_LUN_HANDLE_NOT_VALID
:
3794 ZFCP_LOG_INFO("Temporary LUN identifier 0x%x for unit "
3795 "0x%016Lx on port 0x%016Lx on adapter %s is "
3796 "invalid. This may happen occasionally.\n",
3800 zfcp_get_busid_by_unit(unit
));
3801 ZFCP_LOG_NORMAL("Status qualifier data:\n");
3802 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_NORMAL
,
3803 (char *) &header
->fsf_status_qual
,
3804 sizeof (union fsf_status_qual
));
3805 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
3807 zfcp_erp_port_reopen(unit
->port
, 0);
3808 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3811 case FSF_HANDLE_MISMATCH
:
3812 ZFCP_LOG_NORMAL("bug: The port handle 0x%x has changed "
3813 "unexpectedly. (adapter %s, port 0x%016Lx, "
3816 zfcp_get_busid_by_unit(unit
),
3819 ZFCP_LOG_NORMAL("status qualifier:\n");
3820 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_NORMAL
,
3821 (char *) &header
->fsf_status_qual
,
3822 sizeof (union fsf_status_qual
));
3823 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
3825 zfcp_erp_adapter_reopen(unit
->port
->adapter
, 0);
3826 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3829 case FSF_SERVICE_CLASS_NOT_SUPPORTED
:
3830 ZFCP_LOG_INFO("error: adapter %s does not support fc "
3832 zfcp_get_busid_by_unit(unit
),
3833 ZFCP_FC_SERVICE_CLASS_DEFAULT
);
3834 /* stop operation for this adapter */
3835 debug_text_exception(fsf_req
->adapter
->erp_dbf
, 0,
3836 "fsf_s_class_nsup");
3837 zfcp_erp_adapter_shutdown(unit
->port
->adapter
, 0);
3838 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3841 case FSF_FCPLUN_NOT_VALID
:
3842 ZFCP_LOG_NORMAL("bug: unit 0x%016Lx on port 0x%016Lx on "
3843 "adapter %s does not have correct unit "
3847 zfcp_get_busid_by_unit(unit
),
3849 ZFCP_LOG_DEBUG("status qualifier:\n");
3850 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
3851 (char *) &header
->fsf_status_qual
,
3852 sizeof (union fsf_status_qual
));
3853 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
3854 "fsf_s_fcp_lun_nv");
3855 zfcp_erp_port_reopen(unit
->port
, 0);
3856 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3859 case FSF_ACCESS_DENIED
:
3860 ZFCP_LOG_NORMAL("Access denied, cannot send FCP command to "
3861 "unit 0x%016Lx on port 0x%016Lx on "
3862 "adapter %s\n", unit
->fcp_lun
, unit
->port
->wwpn
,
3863 zfcp_get_busid_by_unit(unit
));
3864 for (counter
= 0; counter
< 2; counter
++) {
3865 subtable
= header
->fsf_status_qual
.halfword
[counter
* 2];
3866 rule
= header
->fsf_status_qual
.halfword
[counter
* 2 + 1];
3868 case FSF_SQ_CFDC_SUBTABLE_OS
:
3869 case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN
:
3870 case FSF_SQ_CFDC_SUBTABLE_PORT_DID
:
3871 case FSF_SQ_CFDC_SUBTABLE_LUN
:
3872 ZFCP_LOG_INFO("Access denied (%s rule %d)\n",
3873 zfcp_act_subtable_type
[subtable
], rule
);
3877 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1, "fsf_s_access");
3878 zfcp_erp_unit_access_denied(unit
);
3879 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3882 case FSF_DIRECTION_INDICATOR_NOT_VALID
:
3883 ZFCP_LOG_INFO("bug: Invalid data direction given for unit "
3884 "0x%016Lx on port 0x%016Lx on adapter %s "
3885 "(debug info %d)\n",
3888 zfcp_get_busid_by_unit(unit
),
3889 fsf_req
->qtcb
->bottom
.io
.data_direction
);
3890 /* stop operation for this adapter */
3891 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0,
3892 "fsf_s_dir_ind_nv");
3893 zfcp_erp_adapter_shutdown(unit
->port
->adapter
, 0);
3894 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3897 case FSF_CMND_LENGTH_NOT_VALID
:
3899 ("bug: An invalid control-data-block length field "
3900 "was found in a command for unit 0x%016Lx on port "
3901 "0x%016Lx on adapter %s " "(debug info %d)\n",
3902 unit
->fcp_lun
, unit
->port
->wwpn
,
3903 zfcp_get_busid_by_unit(unit
),
3904 fsf_req
->qtcb
->bottom
.io
.fcp_cmnd_length
);
3905 /* stop operation for this adapter */
3906 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0,
3907 "fsf_s_cmd_len_nv");
3908 zfcp_erp_adapter_shutdown(unit
->port
->adapter
, 0);
3909 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3912 case FSF_PORT_BOXED
:
3913 ZFCP_LOG_DEBUG("The remote port 0x%016Lx on adapter %s "
3914 "needs to be reopened\n",
3915 unit
->port
->wwpn
, zfcp_get_busid_by_unit(unit
));
3916 debug_text_event(fsf_req
->adapter
->erp_dbf
, 2, "fsf_s_pboxed");
3917 zfcp_erp_port_boxed(unit
->port
);
3918 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
|
3919 ZFCP_STATUS_FSFREQ_RETRY
;
3923 ZFCP_LOG_NORMAL("unit needs to be reopened (adapter %s, "
3924 "wwpn=0x%016Lx, fcp_lun=0x%016Lx)\n",
3925 zfcp_get_busid_by_unit(unit
),
3926 unit
->port
->wwpn
, unit
->fcp_lun
);
3927 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1, "fsf_s_lboxed");
3928 zfcp_erp_unit_boxed(unit
);
3929 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
3930 | ZFCP_STATUS_FSFREQ_RETRY
;
3933 case FSF_ADAPTER_STATUS_AVAILABLE
:
3934 switch (header
->fsf_status_qual
.word
[0]) {
3935 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE
:
3936 /* re-establish link to port */
3937 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
3939 zfcp_test_link(unit
->port
);
3941 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED
:
3942 /* FIXME(hw) need proper specs for proper action */
3943 /* let scsi stack deal with retries and escalation */
3944 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
3949 ("Unknown status qualifier 0x%x arrived.\n",
3950 header
->fsf_status_qual
.word
[0]);
3951 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0,
3953 debug_exception(fsf_req
->adapter
->erp_dbf
, 0,
3954 &header
->fsf_status_qual
.word
[0],
3958 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3964 case FSF_FCP_RSP_AVAILABLE
:
3968 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0, "fsf_s_inval:");
3969 debug_exception(fsf_req
->adapter
->erp_dbf
, 0,
3970 &header
->fsf_status
, sizeof(u32
));
3975 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT
) {
3977 zfcp_fsf_send_fcp_command_task_management_handler(fsf_req
);
3979 retval
= zfcp_fsf_send_fcp_command_task_handler(fsf_req
);
3980 fsf_req
->unit
= NULL
;
3981 zfcp_unit_put(unit
);
3987 * function: zfcp_fsf_send_fcp_command_task_handler
3989 * purpose: evaluates FCP_RSP IU
3994 zfcp_fsf_send_fcp_command_task_handler(struct zfcp_fsf_req
*fsf_req
)
3997 struct scsi_cmnd
*scpnt
;
3998 struct fcp_rsp_iu
*fcp_rsp_iu
= (struct fcp_rsp_iu
*)
3999 &(fsf_req
->qtcb
->bottom
.io
.fcp_rsp
);
4000 struct fcp_cmnd_iu
*fcp_cmnd_iu
= (struct fcp_cmnd_iu
*)
4001 &(fsf_req
->qtcb
->bottom
.io
.fcp_cmnd
);
4003 char *fcp_rsp_info
= zfcp_get_fcp_rsp_info_ptr(fcp_rsp_iu
);
4004 unsigned long flags
;
4005 struct zfcp_unit
*unit
= fsf_req
->unit
;
4007 read_lock_irqsave(&fsf_req
->adapter
->abort_lock
, flags
);
4008 scpnt
= (struct scsi_cmnd
*) fsf_req
->data
;
4009 if (unlikely(!scpnt
)) {
4011 ("Command with fsf_req %p is not associated to "
4012 "a scsi command anymore. Aborted?\n", fsf_req
);
4015 if (unlikely(fsf_req
->status
& ZFCP_STATUS_FSFREQ_ABORTED
)) {
4016 /* FIXME: (design) mid-layer should handle DID_ABORT like
4017 * DID_SOFT_ERROR by retrying the request for devices
4018 * that allow retries.
4020 ZFCP_LOG_DEBUG("Setting DID_SOFT_ERROR and SUGGEST_RETRY\n");
4021 set_host_byte(&scpnt
->result
, DID_SOFT_ERROR
);
4022 set_driver_byte(&scpnt
->result
, SUGGEST_RETRY
);
4023 goto skip_fsfstatus
;
4026 if (unlikely(fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
)) {
4027 ZFCP_LOG_DEBUG("Setting DID_ERROR\n");
4028 set_host_byte(&scpnt
->result
, DID_ERROR
);
4029 goto skip_fsfstatus
;
4032 /* set message byte of result in SCSI command */
4033 scpnt
->result
|= COMMAND_COMPLETE
<< 8;
4036 * copy SCSI status code of FCP_STATUS of FCP_RSP IU to status byte
4037 * of result in SCSI command
4039 scpnt
->result
|= fcp_rsp_iu
->scsi_status
;
4040 if (unlikely(fcp_rsp_iu
->scsi_status
)) {
4042 ZFCP_LOG_DEBUG("status for SCSI Command:\n");
4043 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
4044 scpnt
->cmnd
, scpnt
->cmd_len
);
4045 ZFCP_LOG_DEBUG("SCSI status code 0x%x\n",
4046 fcp_rsp_iu
->scsi_status
);
4047 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
4048 (void *) fcp_rsp_iu
, sizeof (struct fcp_rsp_iu
));
4049 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
4050 zfcp_get_fcp_sns_info_ptr(fcp_rsp_iu
),
4051 fcp_rsp_iu
->fcp_sns_len
);
4054 /* check FCP_RSP_INFO */
4055 if (unlikely(fcp_rsp_iu
->validity
.bits
.fcp_rsp_len_valid
)) {
4056 ZFCP_LOG_DEBUG("rsp_len is valid\n");
4057 switch (fcp_rsp_info
[3]) {
4060 ZFCP_LOG_TRACE("no failure or Task Management "
4061 "Function complete\n");
4062 set_host_byte(&scpnt
->result
, DID_OK
);
4064 case RSP_CODE_LENGTH_MISMATCH
:
4066 ZFCP_LOG_NORMAL("bug: FCP response code indictates "
4067 "that the fibrechannel protocol data "
4068 "length differs from the burst length. "
4069 "The problem occured on unit 0x%016Lx "
4070 "on port 0x%016Lx on adapter %s",
4073 zfcp_get_busid_by_unit(unit
));
4074 /* dump SCSI CDB as prepared by zfcp */
4075 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
4076 (char *) &fsf_req
->qtcb
->
4077 bottom
.io
.fcp_cmnd
, FSF_FCP_CMND_SIZE
);
4078 set_host_byte(&scpnt
->result
, DID_ERROR
);
4079 goto skip_fsfstatus
;
4080 case RSP_CODE_FIELD_INVALID
:
4081 /* driver or hardware bug */
4082 ZFCP_LOG_NORMAL("bug: FCP response code indictates "
4083 "that the fibrechannel protocol data "
4084 "fields were incorrectly set up. "
4085 "The problem occured on the unit "
4086 "0x%016Lx on port 0x%016Lx on "
4090 zfcp_get_busid_by_unit(unit
));
4091 /* dump SCSI CDB as prepared by zfcp */
4092 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
4093 (char *) &fsf_req
->qtcb
->
4094 bottom
.io
.fcp_cmnd
, FSF_FCP_CMND_SIZE
);
4095 set_host_byte(&scpnt
->result
, DID_ERROR
);
4096 goto skip_fsfstatus
;
4097 case RSP_CODE_RO_MISMATCH
:
4099 ZFCP_LOG_NORMAL("bug: The FCP response code indicates "
4100 "that conflicting values for the "
4101 "fibrechannel payload offset from the "
4102 "header were found. "
4103 "The problem occured on unit 0x%016Lx "
4104 "on port 0x%016Lx on adapter %s.\n",
4107 zfcp_get_busid_by_unit(unit
));
4108 /* dump SCSI CDB as prepared by zfcp */
4109 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
4110 (char *) &fsf_req
->qtcb
->
4111 bottom
.io
.fcp_cmnd
, FSF_FCP_CMND_SIZE
);
4112 set_host_byte(&scpnt
->result
, DID_ERROR
);
4113 goto skip_fsfstatus
;
4115 ZFCP_LOG_NORMAL("bug: An invalid FCP response "
4116 "code was detected for a command. "
4117 "The problem occured on the unit "
4118 "0x%016Lx on port 0x%016Lx on "
4119 "adapter %s (debug info 0x%x)\n",
4122 zfcp_get_busid_by_unit(unit
),
4124 /* dump SCSI CDB as prepared by zfcp */
4125 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
4126 (char *) &fsf_req
->qtcb
->
4127 bottom
.io
.fcp_cmnd
, FSF_FCP_CMND_SIZE
);
4128 set_host_byte(&scpnt
->result
, DID_ERROR
);
4129 goto skip_fsfstatus
;
4133 /* check for sense data */
4134 if (unlikely(fcp_rsp_iu
->validity
.bits
.fcp_sns_len_valid
)) {
4135 sns_len
= FSF_FCP_RSP_SIZE
-
4136 sizeof (struct fcp_rsp_iu
) + fcp_rsp_iu
->fcp_rsp_len
;
4137 ZFCP_LOG_TRACE("room for %i bytes sense data in QTCB\n",
4139 sns_len
= min(sns_len
, (u32
) SCSI_SENSE_BUFFERSIZE
);
4140 ZFCP_LOG_TRACE("room for %i bytes sense data in SCSI command\n",
4141 SCSI_SENSE_BUFFERSIZE
);
4142 sns_len
= min(sns_len
, fcp_rsp_iu
->fcp_sns_len
);
4143 ZFCP_LOG_TRACE("scpnt->result =0x%x, command was:\n",
4145 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_TRACE
,
4146 (void *) &scpnt
->cmnd
, scpnt
->cmd_len
);
4148 ZFCP_LOG_TRACE("%i bytes sense data provided by FCP\n",
4149 fcp_rsp_iu
->fcp_sns_len
);
4150 memcpy(&scpnt
->sense_buffer
,
4151 zfcp_get_fcp_sns_info_ptr(fcp_rsp_iu
), sns_len
);
4152 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_TRACE
,
4153 (void *) &scpnt
->sense_buffer
, sns_len
);
4156 /* check for overrun */
4157 if (unlikely(fcp_rsp_iu
->validity
.bits
.fcp_resid_over
)) {
4158 ZFCP_LOG_INFO("A data overrun was detected for a command. "
4159 "unit 0x%016Lx, port 0x%016Lx, adapter %s. "
4160 "The response data length is "
4161 "%d, the original length was %d.\n",
4164 zfcp_get_busid_by_unit(unit
),
4165 fcp_rsp_iu
->fcp_resid
,
4166 (int) zfcp_get_fcp_dl(fcp_cmnd_iu
));
4169 /* check for underrun */
4170 if (unlikely(fcp_rsp_iu
->validity
.bits
.fcp_resid_under
)) {
4171 ZFCP_LOG_INFO("A data underrun was detected for a command. "
4172 "unit 0x%016Lx, port 0x%016Lx, adapter %s. "
4173 "The response data length is "
4174 "%d, the original length was %d.\n",
4177 zfcp_get_busid_by_unit(unit
),
4178 fcp_rsp_iu
->fcp_resid
,
4179 (int) zfcp_get_fcp_dl(fcp_cmnd_iu
));
4181 scpnt
->resid
= fcp_rsp_iu
->fcp_resid
;
4182 if (scpnt
->request_bufflen
- scpnt
->resid
< scpnt
->underflow
)
4183 set_host_byte(&scpnt
->result
, DID_ERROR
);
4187 ZFCP_LOG_DEBUG("scpnt->result =0x%x\n", scpnt
->result
);
4189 if (scpnt
->result
!= 0)
4190 zfcp_scsi_dbf_event_result("erro", 3, fsf_req
->adapter
, scpnt
, fsf_req
);
4191 else if (scpnt
->retries
> 0)
4192 zfcp_scsi_dbf_event_result("retr", 4, fsf_req
->adapter
, scpnt
, fsf_req
);
4194 zfcp_scsi_dbf_event_result("norm", 6, fsf_req
->adapter
, scpnt
, fsf_req
);
4196 /* cleanup pointer (need this especially for abort) */
4197 scpnt
->host_scribble
= NULL
;
4199 /* always call back */
4200 (scpnt
->scsi_done
) (scpnt
);
4203 * We must hold this lock until scsi_done has been called.
4204 * Otherwise we may call scsi_done after abort regarding this
4205 * command has completed.
4206 * Note: scsi_done must not block!
4209 read_unlock_irqrestore(&fsf_req
->adapter
->abort_lock
, flags
);
4214 * function: zfcp_fsf_send_fcp_command_task_management_handler
4216 * purpose: evaluates FCP_RSP IU
4221 zfcp_fsf_send_fcp_command_task_management_handler(struct zfcp_fsf_req
*fsf_req
)
4224 struct fcp_rsp_iu
*fcp_rsp_iu
= (struct fcp_rsp_iu
*)
4225 &(fsf_req
->qtcb
->bottom
.io
.fcp_rsp
);
4226 char *fcp_rsp_info
= zfcp_get_fcp_rsp_info_ptr(fcp_rsp_iu
);
4227 struct zfcp_unit
*unit
= (struct zfcp_unit
*) fsf_req
->data
;
4229 del_timer(&fsf_req
->adapter
->scsi_er_timer
);
4230 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
) {
4231 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_TMFUNCFAILED
;
4232 goto skip_fsfstatus
;
4235 /* check FCP_RSP_INFO */
4236 switch (fcp_rsp_info
[3]) {
4239 ZFCP_LOG_DEBUG("no failure or Task Management "
4240 "Function complete\n");
4242 case RSP_CODE_TASKMAN_UNSUPP
:
4243 ZFCP_LOG_NORMAL("bug: A reuested task management function "
4244 "is not supported on the target device "
4245 "unit 0x%016Lx, port 0x%016Lx, adapter %s\n ",
4248 zfcp_get_busid_by_unit(unit
));
4249 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_TMFUNCNOTSUPP
;
4251 case RSP_CODE_TASKMAN_FAILED
:
4252 ZFCP_LOG_NORMAL("bug: A reuested task management function "
4253 "failed to complete successfully. "
4254 "unit 0x%016Lx, port 0x%016Lx, adapter %s.\n",
4257 zfcp_get_busid_by_unit(unit
));
4258 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_TMFUNCFAILED
;
4261 ZFCP_LOG_NORMAL("bug: An invalid FCP response "
4262 "code was detected for a command. "
4263 "unit 0x%016Lx, port 0x%016Lx, adapter %s "
4264 "(debug info 0x%x)\n",
4267 zfcp_get_busid_by_unit(unit
),
4269 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_TMFUNCFAILED
;
4278 * function: zfcp_fsf_control_file
4280 * purpose: Initiator of the control file upload/download FSF requests
4282 * returns: 0 - FSF request is successfuly created and queued
4283 * -EOPNOTSUPP - The FCP adapter does not have Control File support
4284 * -EINVAL - Invalid direction specified
4285 * -ENOMEM - Insufficient memory
4286 * -EPERM - Cannot create FSF request or place it in QDIO queue
4289 zfcp_fsf_control_file(struct zfcp_adapter
*adapter
,
4290 struct zfcp_fsf_req
**fsf_req_ptr
,
4293 struct zfcp_sg_list
*sg_list
)
4295 struct zfcp_fsf_req
*fsf_req
;
4296 struct fsf_qtcb_bottom_support
*bottom
;
4297 volatile struct qdio_buffer_element
*sbale
;
4298 struct timer_list
*timer
;
4299 unsigned long lock_flags
;
4304 if (!(adapter
->adapter_features
& FSF_FEATURE_CFDC
)) {
4305 ZFCP_LOG_INFO("cfdc not supported (adapter %s)\n",
4306 zfcp_get_busid_by_adapter(adapter
));
4307 retval
= -EOPNOTSUPP
;
4311 switch (fsf_command
) {
4313 case FSF_QTCB_DOWNLOAD_CONTROL_FILE
:
4314 direction
= SBAL_FLAGS0_TYPE_WRITE
;
4315 if ((option
!= FSF_CFDC_OPTION_FULL_ACCESS
) &&
4316 (option
!= FSF_CFDC_OPTION_RESTRICTED_ACCESS
))
4317 req_flags
= ZFCP_WAIT_FOR_SBAL
;
4320 case FSF_QTCB_UPLOAD_CONTROL_FILE
:
4321 direction
= SBAL_FLAGS0_TYPE_READ
;
4325 ZFCP_LOG_INFO("Invalid FSF command code 0x%08x\n", fsf_command
);
4330 timer
= kmalloc(sizeof(struct timer_list
), GFP_KERNEL
);
4336 retval
= zfcp_fsf_req_create(adapter
, fsf_command
, req_flags
,
4337 NULL
, &lock_flags
, &fsf_req
);
4339 ZFCP_LOG_INFO("error: Could not create FSF request for the "
4341 zfcp_get_busid_by_adapter(adapter
));
4343 goto unlock_queue_lock
;
4346 sbale
= zfcp_qdio_sbale_req(fsf_req
, fsf_req
->sbal_curr
, 0);
4347 sbale
[0].flags
|= direction
;
4349 bottom
= &fsf_req
->qtcb
->bottom
.support
;
4350 bottom
->operation_subtype
= FSF_CFDC_OPERATION_SUBTYPE
;
4351 bottom
->option
= option
;
4353 if (sg_list
->count
> 0) {
4356 bytes
= zfcp_qdio_sbals_from_sg(fsf_req
, direction
,
4357 sg_list
->sg
, sg_list
->count
,
4358 ZFCP_MAX_SBALS_PER_REQ
);
4359 if (bytes
!= ZFCP_CFDC_MAX_CONTROL_FILE_SIZE
) {
4361 "error: Could not create sufficient number of "
4362 "SBALS for an FSF request to the adapter %s\n",
4363 zfcp_get_busid_by_adapter(adapter
));
4368 sbale
[1].flags
|= SBAL_FLAGS_LAST_ENTRY
;
4371 timer
->function
= zfcp_fsf_request_timeout_handler
;
4372 timer
->data
= (unsigned long) adapter
;
4373 timer
->expires
= ZFCP_FSF_REQUEST_TIMEOUT
;
4375 retval
= zfcp_fsf_req_send(fsf_req
, timer
);
4377 ZFCP_LOG_INFO("initiation of cfdc up/download failed"
4379 zfcp_get_busid_by_adapter(adapter
));
4383 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
, lock_flags
);
4385 ZFCP_LOG_NORMAL("Control file %s FSF request has been sent to the "
4387 fsf_command
== FSF_QTCB_DOWNLOAD_CONTROL_FILE
?
4388 "download" : "upload",
4389 zfcp_get_busid_by_adapter(adapter
));
4391 wait_event(fsf_req
->completion_wq
,
4392 fsf_req
->status
& ZFCP_STATUS_FSFREQ_COMPLETED
);
4394 *fsf_req_ptr
= fsf_req
;
4395 del_timer_sync(timer
);
4399 zfcp_fsf_req_free(fsf_req
);
4401 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
, lock_flags
);
4410 * function: zfcp_fsf_control_file_handler
4412 * purpose: Handler of the control file upload/download FSF requests
4414 * returns: 0 - FSF request successfuly processed
4415 * -EAGAIN - Operation has to be repeated because of a temporary problem
4416 * -EACCES - There is no permission to execute an operation
4417 * -EPERM - The control file is not in a right format
4418 * -EIO - There is a problem with the FCP adapter
4419 * -EINVAL - Invalid operation
4420 * -EFAULT - User space memory I/O operation fault
4423 zfcp_fsf_control_file_handler(struct zfcp_fsf_req
*fsf_req
)
4425 struct zfcp_adapter
*adapter
= fsf_req
->adapter
;
4426 struct fsf_qtcb_header
*header
= &fsf_req
->qtcb
->header
;
4427 struct fsf_qtcb_bottom_support
*bottom
= &fsf_req
->qtcb
->bottom
.support
;
4430 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
) {
4432 goto skip_fsfstatus
;
4435 switch (header
->fsf_status
) {
4439 "The FSF request has been successfully completed "
4440 "on the adapter %s\n",
4441 zfcp_get_busid_by_adapter(adapter
));
4444 case FSF_OPERATION_PARTIALLY_SUCCESSFUL
:
4445 if (bottom
->operation_subtype
== FSF_CFDC_OPERATION_SUBTYPE
) {
4446 switch (header
->fsf_status_qual
.word
[0]) {
4448 case FSF_SQ_CFDC_HARDENED_ON_SE
:
4450 "CFDC on the adapter %s has being "
4451 "hardened on primary and secondary SE\n",
4452 zfcp_get_busid_by_adapter(adapter
));
4455 case FSF_SQ_CFDC_COULD_NOT_HARDEN_ON_SE
:
4457 "CFDC of the adapter %s could not "
4458 "be saved on the SE\n",
4459 zfcp_get_busid_by_adapter(adapter
));
4462 case FSF_SQ_CFDC_COULD_NOT_HARDEN_ON_SE2
:
4464 "CFDC of the adapter %s could not "
4465 "be copied to the secondary SE\n",
4466 zfcp_get_busid_by_adapter(adapter
));
4471 "CFDC could not be hardened "
4472 "on the adapter %s\n",
4473 zfcp_get_busid_by_adapter(adapter
));
4476 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4480 case FSF_AUTHORIZATION_FAILURE
:
4482 "Adapter %s does not accept privileged commands\n",
4483 zfcp_get_busid_by_adapter(adapter
));
4484 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4488 case FSF_CFDC_ERROR_DETECTED
:
4490 "Error at position %d in the CFDC, "
4491 "CFDC is discarded by the adapter %s\n",
4492 header
->fsf_status_qual
.word
[0],
4493 zfcp_get_busid_by_adapter(adapter
));
4494 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4498 case FSF_CONTROL_FILE_UPDATE_ERROR
:
4500 "Adapter %s cannot harden the control file, "
4501 "file is discarded\n",
4502 zfcp_get_busid_by_adapter(adapter
));
4503 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4507 case FSF_CONTROL_FILE_TOO_LARGE
:
4509 "Control file is too large, file is discarded "
4510 "by the adapter %s\n",
4511 zfcp_get_busid_by_adapter(adapter
));
4512 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4516 case FSF_ACCESS_CONFLICT_DETECTED
:
4517 if (bottom
->operation_subtype
== FSF_CFDC_OPERATION_SUBTYPE
)
4519 "CFDC has been discarded by the adapter %s, "
4520 "because activation would impact "
4521 "%d active connection(s)\n",
4522 zfcp_get_busid_by_adapter(adapter
),
4523 header
->fsf_status_qual
.word
[0]);
4524 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4528 case FSF_CONFLICTS_OVERRULED
:
4529 if (bottom
->operation_subtype
== FSF_CFDC_OPERATION_SUBTYPE
)
4531 "CFDC has been activated on the adapter %s, "
4532 "but activation has impacted "
4533 "%d active connection(s)\n",
4534 zfcp_get_busid_by_adapter(adapter
),
4535 header
->fsf_status_qual
.word
[0]);
4536 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4540 case FSF_UNKNOWN_OP_SUBTYPE
:
4541 ZFCP_LOG_NORMAL("unknown operation subtype (adapter: %s, "
4542 "op_subtype=0x%x)\n",
4543 zfcp_get_busid_by_adapter(adapter
),
4544 bottom
->operation_subtype
);
4545 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4549 case FSF_INVALID_COMMAND_OPTION
:
4551 "Invalid option 0x%x has been specified "
4552 "in QTCB bottom sent to the adapter %s\n",
4554 zfcp_get_busid_by_adapter(adapter
));
4555 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4561 "bug: An unknown/unexpected FSF status 0x%08x "
4562 "was presented on the adapter %s\n",
4564 zfcp_get_busid_by_adapter(adapter
));
4565 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0, "fsf_sq_inval");
4566 debug_exception(fsf_req
->adapter
->erp_dbf
, 0,
4567 &header
->fsf_status_qual
.word
[0], sizeof(u32
));
4568 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4578 zfcp_fsf_req_sbal_check(unsigned long *flags
,
4579 struct zfcp_qdio_queue
*queue
, int needed
)
4581 write_lock_irqsave(&queue
->queue_lock
, *flags
);
4582 if (likely(atomic_read(&queue
->free_count
) >= needed
))
4584 write_unlock_irqrestore(&queue
->queue_lock
, *flags
);
4589 * set qtcb pointer in fsf_req and initialize QTCB
4592 zfcp_fsf_req_qtcb_init(struct zfcp_fsf_req
*fsf_req
)
4594 if (likely(fsf_req
->qtcb
!= NULL
)) {
4595 fsf_req
->qtcb
->prefix
.req_seq_no
= fsf_req
->adapter
->fsf_req_seq_no
;
4596 fsf_req
->qtcb
->prefix
.req_id
= (unsigned long)fsf_req
;
4597 fsf_req
->qtcb
->prefix
.ulp_info
= ZFCP_ULP_INFO_VERSION
;
4598 fsf_req
->qtcb
->prefix
.qtcb_type
= fsf_qtcb_type
[fsf_req
->fsf_command
];
4599 fsf_req
->qtcb
->prefix
.qtcb_version
= ZFCP_QTCB_VERSION
;
4600 fsf_req
->qtcb
->header
.req_handle
= (unsigned long)fsf_req
;
4601 fsf_req
->qtcb
->header
.fsf_command
= fsf_req
->fsf_command
;
4606 * zfcp_fsf_req_sbal_get - try to get one SBAL in the request queue
4607 * @adapter: adapter for which request queue is examined
4608 * @req_flags: flags indicating whether to wait for needed SBAL or not
4609 * @lock_flags: lock_flags if queue_lock is taken
4610 * Return: 0 on success, otherwise -EIO, or -ERESTARTSYS
4611 * Locks: lock adapter->request_queue->queue_lock on success
4614 zfcp_fsf_req_sbal_get(struct zfcp_adapter
*adapter
, int req_flags
,
4615 unsigned long *lock_flags
)
4618 struct zfcp_qdio_queue
*req_queue
= &adapter
->request_queue
;
4620 if (unlikely(req_flags
& ZFCP_WAIT_FOR_SBAL
)) {
4621 ret
= wait_event_interruptible_timeout(adapter
->request_wq
,
4622 zfcp_fsf_req_sbal_check(lock_flags
, req_queue
, 1),
4628 } else if (!zfcp_fsf_req_sbal_check(lock_flags
, req_queue
, 1))
4635 * function: zfcp_fsf_req_create
4637 * purpose: create an FSF request at the specified adapter and
4638 * setup common fields
4640 * returns: -ENOMEM if there was insufficient memory for a request
4641 * -EIO if no qdio buffers could be allocate to the request
4642 * -EINVAL/-EPERM on bug conditions in req_dequeue
4645 * note: The created request is returned by reference.
4647 * locks: lock of concerned request queue must not be held,
4648 * but is held on completion (write, irqsave)
4651 zfcp_fsf_req_create(struct zfcp_adapter
*adapter
, u32 fsf_cmd
, int req_flags
,
4652 mempool_t
*pool
, unsigned long *lock_flags
,
4653 struct zfcp_fsf_req
**fsf_req_p
)
4655 volatile struct qdio_buffer_element
*sbale
;
4656 struct zfcp_fsf_req
*fsf_req
= NULL
;
4658 struct zfcp_qdio_queue
*req_queue
= &adapter
->request_queue
;
4660 /* allocate new FSF request */
4661 fsf_req
= zfcp_fsf_req_alloc(pool
, req_flags
);
4662 if (unlikely(NULL
== fsf_req
)) {
4663 ZFCP_LOG_DEBUG("error: Could not put an FSF request into"
4664 "the outbound (send) queue.\n");
4666 goto failed_fsf_req
;
4669 fsf_req
->adapter
= adapter
;
4670 fsf_req
->fsf_command
= fsf_cmd
;
4672 zfcp_fsf_req_qtcb_init(fsf_req
);
4674 /* initialize waitqueue which may be used to wait on
4675 this request completion */
4676 init_waitqueue_head(&fsf_req
->completion_wq
);
4678 ret
= zfcp_fsf_req_sbal_get(adapter
, req_flags
, lock_flags
);
4684 * We hold queue_lock here. Check if QDIOUP is set and let request fail
4685 * if it is not set (see also *_open_qdio and *_close_qdio).
4688 if (!atomic_test_mask(ZFCP_STATUS_ADAPTER_QDIOUP
, &adapter
->status
)) {
4689 write_unlock_irqrestore(&req_queue
->queue_lock
, *lock_flags
);
4694 if (fsf_req
->qtcb
) {
4695 fsf_req
->seq_no
= adapter
->fsf_req_seq_no
;
4696 fsf_req
->qtcb
->prefix
.req_seq_no
= adapter
->fsf_req_seq_no
;
4698 fsf_req
->sbal_number
= 1;
4699 fsf_req
->sbal_first
= req_queue
->free_index
;
4700 fsf_req
->sbal_curr
= req_queue
->free_index
;
4701 fsf_req
->sbale_curr
= 1;
4703 if (likely(req_flags
& ZFCP_REQ_AUTO_CLEANUP
)) {
4704 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_CLEANUP
;
4707 sbale
= zfcp_qdio_sbale_req(fsf_req
, fsf_req
->sbal_curr
, 0);
4709 /* setup common SBALE fields */
4710 sbale
[0].addr
= fsf_req
;
4711 sbale
[0].flags
|= SBAL_FLAGS0_COMMAND
;
4712 if (likely(fsf_req
->qtcb
!= NULL
)) {
4713 sbale
[1].addr
= (void *) fsf_req
->qtcb
;
4714 sbale
[1].length
= sizeof(struct fsf_qtcb
);
4717 ZFCP_LOG_TRACE("got %i free BUFFERs starting at index %i\n",
4718 fsf_req
->sbal_number
, fsf_req
->sbal_first
);
4723 /* dequeue new FSF request previously enqueued */
4724 zfcp_fsf_req_free(fsf_req
);
4728 write_lock_irqsave(&req_queue
->queue_lock
, *lock_flags
);
4730 *fsf_req_p
= fsf_req
;
4735 * function: zfcp_fsf_req_send
4737 * purpose: start transfer of FSF request via QDIO
4739 * returns: 0 - request transfer succesfully started
4740 * !0 - start of request transfer failed
4743 zfcp_fsf_req_send(struct zfcp_fsf_req
*fsf_req
, struct timer_list
*timer
)
4745 struct zfcp_adapter
*adapter
;
4746 struct zfcp_qdio_queue
*req_queue
;
4747 volatile struct qdio_buffer_element
*sbale
;
4749 int new_distance_from_int
;
4750 unsigned long flags
;
4753 adapter
= fsf_req
->adapter
;
4754 req_queue
= &adapter
->request_queue
,
4757 /* FIXME(debug): remove it later */
4758 sbale
= zfcp_qdio_sbale_req(fsf_req
, fsf_req
->sbal_first
, 0);
4759 ZFCP_LOG_DEBUG("SBALE0 flags=0x%x\n", sbale
[0].flags
);
4760 ZFCP_LOG_TRACE("HEX DUMP OF SBALE1 PAYLOAD:\n");
4761 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_TRACE
, (char *) sbale
[1].addr
,
4764 /* put allocated FSF request at list tail */
4765 spin_lock_irqsave(&adapter
->fsf_req_list_lock
, flags
);
4766 list_add_tail(&fsf_req
->list
, &adapter
->fsf_req_list_head
);
4767 spin_unlock_irqrestore(&adapter
->fsf_req_list_lock
, flags
);
4769 inc_seq_no
= (fsf_req
->qtcb
!= NULL
);
4771 /* figure out expiration time of timeout and start timeout */
4772 if (unlikely(timer
)) {
4773 timer
->expires
+= jiffies
;
4777 ZFCP_LOG_TRACE("request queue of adapter %s: "
4778 "next free SBAL is %i, %i free SBALs\n",
4779 zfcp_get_busid_by_adapter(adapter
),
4780 req_queue
->free_index
,
4781 atomic_read(&req_queue
->free_count
));
4783 ZFCP_LOG_DEBUG("calling do_QDIO adapter %s, flags=0x%x, queue_no=%i, "
4784 "index_in_queue=%i, count=%i, buffers=%p\n",
4785 zfcp_get_busid_by_adapter(adapter
),
4786 QDIO_FLAG_SYNC_OUTPUT
,
4787 0, fsf_req
->sbal_first
, fsf_req
->sbal_number
,
4788 &req_queue
->buffer
[fsf_req
->sbal_first
]);
4791 * adjust the number of free SBALs in request queue as well as
4792 * position of first one
4794 atomic_sub(fsf_req
->sbal_number
, &req_queue
->free_count
);
4795 ZFCP_LOG_TRACE("free_count=%d\n", atomic_read(&req_queue
->free_count
));
4796 req_queue
->free_index
+= fsf_req
->sbal_number
; /* increase */
4797 req_queue
->free_index
%= QDIO_MAX_BUFFERS_PER_Q
; /* wrap if needed */
4798 new_distance_from_int
= zfcp_qdio_determine_pci(req_queue
, fsf_req
);
4800 fsf_req
->issued
= get_clock();
4802 retval
= do_QDIO(adapter
->ccw_device
,
4803 QDIO_FLAG_SYNC_OUTPUT
,
4804 0, fsf_req
->sbal_first
, fsf_req
->sbal_number
, NULL
);
4806 if (unlikely(retval
)) {
4807 /* Queues are down..... */
4810 * FIXME(potential race):
4811 * timer might be expired (absolutely unlikely)
4815 spin_lock_irqsave(&adapter
->fsf_req_list_lock
, flags
);
4816 list_del(&fsf_req
->list
);
4817 spin_unlock_irqrestore(&adapter
->fsf_req_list_lock
, flags
);
4819 * adjust the number of free SBALs in request queue as well as
4820 * position of first one
4822 zfcp_qdio_zero_sbals(req_queue
->buffer
,
4823 fsf_req
->sbal_first
, fsf_req
->sbal_number
);
4824 atomic_add(fsf_req
->sbal_number
, &req_queue
->free_count
);
4825 req_queue
->free_index
-= fsf_req
->sbal_number
; /* increase */
4826 req_queue
->free_index
+= QDIO_MAX_BUFFERS_PER_Q
;
4827 req_queue
->free_index
%= QDIO_MAX_BUFFERS_PER_Q
; /* wrap */
4829 ("error: do_QDIO failed. Buffers could not be enqueued "
4830 "to request queue.\n");
4832 req_queue
->distance_from_int
= new_distance_from_int
;
4834 * increase FSF sequence counter -
4835 * this must only be done for request successfully enqueued to
4836 * QDIO this rejected requests may be cleaned up by calling
4837 * routines resulting in missing sequence counter values
4841 /* Don't increase for unsolicited status */
4843 adapter
->fsf_req_seq_no
++;
4845 /* count FSF requests pending */
4846 atomic_inc(&adapter
->fsf_reqs_active
);
4851 #undef ZFCP_LOG_AREA