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 ((((unsigned long) &plogi
->serv_param
.wwpn
) -
2564 ((unsigned long) plogi
)) + sizeof (u64
))) {
2566 "warning: insufficient length of "
2567 "PLOGI payload (%i)\n",
2568 fsf_req
->qtcb
->bottom
.support
.els1_length
);
2569 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0,
2570 "fsf_s_short_plogi:");
2571 /* skip sanity check and assume wwpn is ok */
2573 if (plogi
->serv_param
.wwpn
!= port
->wwpn
) {
2574 ZFCP_LOG_INFO("warning: d_id of port "
2575 "0x%016Lx changed during "
2576 "open\n", port
->wwpn
);
2578 fsf_req
->adapter
->erp_dbf
, 0,
2579 "fsf_s_did_change:");
2581 ZFCP_STATUS_PORT_DID_DID
,
2584 port
->wwnn
= plogi
->serv_param
.wwnn
;
2589 case FSF_UNKNOWN_OP_SUBTYPE
:
2590 /* should never occure, subtype not set in zfcp_fsf_open_port */
2591 ZFCP_LOG_INFO("unknown operation subtype (adapter: %s, "
2592 "op_subtype=0x%x)\n",
2593 zfcp_get_busid_by_port(port
),
2594 fsf_req
->qtcb
->bottom
.support
.operation_subtype
);
2595 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
2599 ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
2600 "(debug info 0x%x)\n",
2601 header
->fsf_status
);
2602 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0, "fsf_s_inval:");
2603 debug_exception(fsf_req
->adapter
->erp_dbf
, 0,
2604 &header
->fsf_status
, sizeof (u32
));
2609 atomic_clear_mask(ZFCP_STATUS_COMMON_OPENING
, &port
->status
);
2614 * function: zfcp_fsf_close_port
2616 * purpose: submit FSF command "close port"
2618 * returns: address of initiated FSF request
2619 * NULL - request could not be initiated
2622 zfcp_fsf_close_port(struct zfcp_erp_action
*erp_action
)
2624 volatile struct qdio_buffer_element
*sbale
;
2625 unsigned long lock_flags
;
2628 /* setup new FSF request */
2629 retval
= zfcp_fsf_req_create(erp_action
->adapter
,
2630 FSF_QTCB_CLOSE_PORT
,
2631 ZFCP_WAIT_FOR_SBAL
| ZFCP_REQ_AUTO_CLEANUP
,
2632 erp_action
->adapter
->pool
.fsf_req_erp
,
2633 &lock_flags
, &(erp_action
->fsf_req
));
2635 ZFCP_LOG_INFO("error: Could not create a close port request "
2636 "for port 0x%016Lx on adapter %s.\n",
2637 erp_action
->port
->wwpn
,
2638 zfcp_get_busid_by_adapter(erp_action
->adapter
));
2642 sbale
= zfcp_qdio_sbale_req(erp_action
->fsf_req
,
2643 erp_action
->fsf_req
->sbal_curr
, 0);
2644 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_READ
;
2645 sbale
[1].flags
|= SBAL_FLAGS_LAST_ENTRY
;
2647 atomic_set_mask(ZFCP_STATUS_COMMON_CLOSING
, &erp_action
->port
->status
);
2648 erp_action
->fsf_req
->data
= (unsigned long) erp_action
->port
;
2649 erp_action
->fsf_req
->erp_action
= erp_action
;
2650 erp_action
->fsf_req
->qtcb
->header
.port_handle
=
2651 erp_action
->port
->handle
;
2653 /* start QDIO request for this FSF request */
2654 retval
= zfcp_fsf_req_send(erp_action
->fsf_req
, &erp_action
->timer
);
2656 ZFCP_LOG_INFO("error: Could not send a close port request for "
2657 "port 0x%016Lx on adapter %s.\n",
2658 erp_action
->port
->wwpn
,
2659 zfcp_get_busid_by_adapter(erp_action
->adapter
));
2660 zfcp_fsf_req_free(erp_action
->fsf_req
);
2661 erp_action
->fsf_req
= NULL
;
2665 ZFCP_LOG_TRACE("close port request initiated "
2666 "(adapter %s, port 0x%016Lx)\n",
2667 zfcp_get_busid_by_adapter(erp_action
->adapter
),
2668 erp_action
->port
->wwpn
);
2670 write_unlock_irqrestore(&erp_action
->adapter
->request_queue
.queue_lock
,
2676 * function: zfcp_fsf_close_port_handler
2678 * purpose: is called for finished Close Port FSF command
2683 zfcp_fsf_close_port_handler(struct zfcp_fsf_req
*fsf_req
)
2685 int retval
= -EINVAL
;
2686 struct zfcp_port
*port
;
2688 port
= (struct zfcp_port
*) fsf_req
->data
;
2690 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
) {
2691 /* don't change port status in our bookkeeping */
2692 goto skip_fsfstatus
;
2695 /* evaluate FSF status in QTCB */
2696 switch (fsf_req
->qtcb
->header
.fsf_status
) {
2698 case FSF_PORT_HANDLE_NOT_VALID
:
2699 ZFCP_LOG_INFO("Temporary port identifier 0x%x for port "
2700 "0x%016Lx on adapter %s invalid. This may happen "
2701 "occasionally.\n", port
->handle
,
2702 port
->wwpn
, zfcp_get_busid_by_port(port
));
2703 ZFCP_LOG_DEBUG("status qualifier:\n");
2704 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
2705 (char *) &fsf_req
->qtcb
->header
.fsf_status_qual
,
2706 sizeof (union fsf_status_qual
));
2707 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
2709 zfcp_erp_adapter_reopen(port
->adapter
, 0);
2710 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
2713 case FSF_ADAPTER_STATUS_AVAILABLE
:
2714 /* Note: FSF has actually closed the port in this case.
2715 * The status code is just daft. Fingers crossed for a change
2721 ZFCP_LOG_TRACE("remote port 0x016%Lx on adapter %s closed, "
2722 "port handle 0x%x\n", port
->wwpn
,
2723 zfcp_get_busid_by_port(port
), port
->handle
);
2724 zfcp_erp_modify_port_status(port
,
2725 ZFCP_STATUS_COMMON_OPEN
,
2731 ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
2732 "(debug info 0x%x)\n",
2733 fsf_req
->qtcb
->header
.fsf_status
);
2734 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0, "fsf_s_inval:");
2735 debug_exception(fsf_req
->adapter
->erp_dbf
, 0,
2736 &fsf_req
->qtcb
->header
.fsf_status
,
2742 atomic_clear_mask(ZFCP_STATUS_COMMON_CLOSING
, &port
->status
);
2747 * function: zfcp_fsf_close_physical_port
2749 * purpose: submit FSF command "close physical port"
2751 * returns: address of initiated FSF request
2752 * NULL - request could not be initiated
2755 zfcp_fsf_close_physical_port(struct zfcp_erp_action
*erp_action
)
2758 unsigned long lock_flags
;
2759 volatile struct qdio_buffer_element
*sbale
;
2761 /* setup new FSF request */
2762 retval
= zfcp_fsf_req_create(erp_action
->adapter
,
2763 FSF_QTCB_CLOSE_PHYSICAL_PORT
,
2764 ZFCP_WAIT_FOR_SBAL
| ZFCP_REQ_AUTO_CLEANUP
,
2765 erp_action
->adapter
->pool
.fsf_req_erp
,
2766 &lock_flags
, &erp_action
->fsf_req
);
2768 ZFCP_LOG_INFO("error: Could not create close physical port "
2769 "request (adapter %s, port 0x%016Lx)\n",
2770 zfcp_get_busid_by_adapter(erp_action
->adapter
),
2771 erp_action
->port
->wwpn
);
2776 sbale
= zfcp_qdio_sbale_req(erp_action
->fsf_req
,
2777 erp_action
->fsf_req
->sbal_curr
, 0);
2778 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_READ
;
2779 sbale
[1].flags
|= SBAL_FLAGS_LAST_ENTRY
;
2781 /* mark port as being closed */
2782 atomic_set_mask(ZFCP_STATUS_PORT_PHYS_CLOSING
,
2783 &erp_action
->port
->status
);
2784 /* save a pointer to this port */
2785 erp_action
->fsf_req
->data
= (unsigned long) erp_action
->port
;
2786 /* port to be closed */
2787 erp_action
->fsf_req
->qtcb
->header
.port_handle
=
2788 erp_action
->port
->handle
;
2789 erp_action
->fsf_req
->erp_action
= erp_action
;
2791 /* start QDIO request for this FSF request */
2792 retval
= zfcp_fsf_req_send(erp_action
->fsf_req
, &erp_action
->timer
);
2794 ZFCP_LOG_INFO("error: Could not send close physical port "
2795 "request (adapter %s, port 0x%016Lx)\n",
2796 zfcp_get_busid_by_adapter(erp_action
->adapter
),
2797 erp_action
->port
->wwpn
);
2798 zfcp_fsf_req_free(erp_action
->fsf_req
);
2799 erp_action
->fsf_req
= NULL
;
2803 ZFCP_LOG_TRACE("close physical port request initiated "
2804 "(adapter %s, port 0x%016Lx)\n",
2805 zfcp_get_busid_by_adapter(erp_action
->adapter
),
2806 erp_action
->port
->wwpn
);
2808 write_unlock_irqrestore(&erp_action
->adapter
->request_queue
.queue_lock
,
2814 * function: zfcp_fsf_close_physical_port_handler
2816 * purpose: is called for finished Close Physical Port FSF command
2821 zfcp_fsf_close_physical_port_handler(struct zfcp_fsf_req
*fsf_req
)
2823 int retval
= -EINVAL
;
2824 struct zfcp_port
*port
;
2825 struct zfcp_unit
*unit
;
2826 struct fsf_qtcb_header
*header
;
2827 u16 subtable
, rule
, counter
;
2829 port
= (struct zfcp_port
*) fsf_req
->data
;
2830 header
= &fsf_req
->qtcb
->header
;
2832 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
) {
2833 /* don't change port status in our bookkeeping */
2834 goto skip_fsfstatus
;
2837 /* evaluate FSF status in QTCB */
2838 switch (header
->fsf_status
) {
2840 case FSF_PORT_HANDLE_NOT_VALID
:
2841 ZFCP_LOG_INFO("Temporary port identifier 0x%x invalid"
2842 "(adapter %s, port 0x%016Lx). "
2843 "This may happen occasionally.\n",
2845 zfcp_get_busid_by_port(port
),
2847 ZFCP_LOG_DEBUG("status qualifier:\n");
2848 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
2849 (char *) &header
->fsf_status_qual
,
2850 sizeof (union fsf_status_qual
));
2851 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
2853 zfcp_erp_adapter_reopen(port
->adapter
, 0);
2854 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
2857 case FSF_ACCESS_DENIED
:
2858 ZFCP_LOG_NORMAL("Access denied, cannot close "
2859 "physical port 0x%016Lx on adapter %s\n",
2860 port
->wwpn
, zfcp_get_busid_by_port(port
));
2861 for (counter
= 0; counter
< 2; counter
++) {
2862 subtable
= header
->fsf_status_qual
.halfword
[counter
* 2];
2863 rule
= header
->fsf_status_qual
.halfword
[counter
* 2 + 1];
2865 case FSF_SQ_CFDC_SUBTABLE_OS
:
2866 case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN
:
2867 case FSF_SQ_CFDC_SUBTABLE_PORT_DID
:
2868 case FSF_SQ_CFDC_SUBTABLE_LUN
:
2869 ZFCP_LOG_INFO("Access denied (%s rule %d)\n",
2870 zfcp_act_subtable_type
[subtable
], rule
);
2874 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1, "fsf_s_access");
2875 zfcp_erp_port_access_denied(port
);
2876 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
2879 case FSF_PORT_BOXED
:
2880 ZFCP_LOG_DEBUG("The remote port 0x%016Lx on adapter "
2881 "%s needs to be reopened but it was attempted "
2882 "to close it physically.\n",
2884 zfcp_get_busid_by_port(port
));
2885 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1, "fsf_s_pboxed");
2886 zfcp_erp_port_boxed(port
);
2887 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
|
2888 ZFCP_STATUS_FSFREQ_RETRY
;
2891 case FSF_ADAPTER_STATUS_AVAILABLE
:
2892 switch (header
->fsf_status_qual
.word
[0]) {
2893 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE
:
2894 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
2896 /* This will now be escalated by ERP */
2897 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
2899 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED
:
2900 /* ERP strategy will escalate */
2901 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
2903 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
2907 ("bug: Wrong status qualifier 0x%x arrived.\n",
2908 header
->fsf_status_qual
.word
[0]);
2909 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0,
2912 fsf_req
->adapter
->erp_dbf
, 0,
2913 &header
->fsf_status_qual
.word
[0], sizeof (u32
));
2919 ZFCP_LOG_DEBUG("Remote port 0x%016Lx via adapter %s "
2920 "physically closed, port handle 0x%x\n",
2922 zfcp_get_busid_by_port(port
), port
->handle
);
2923 /* can't use generic zfcp_erp_modify_port_status because
2924 * ZFCP_STATUS_COMMON_OPEN must not be reset for the port
2926 atomic_clear_mask(ZFCP_STATUS_PORT_PHYS_OPEN
, &port
->status
);
2927 list_for_each_entry(unit
, &port
->unit_list_head
, list
)
2928 atomic_clear_mask(ZFCP_STATUS_COMMON_OPEN
, &unit
->status
);
2933 ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
2934 "(debug info 0x%x)\n",
2935 header
->fsf_status
);
2936 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0, "fsf_s_inval:");
2937 debug_exception(fsf_req
->adapter
->erp_dbf
, 0,
2938 &header
->fsf_status
, sizeof (u32
));
2943 atomic_clear_mask(ZFCP_STATUS_PORT_PHYS_CLOSING
, &port
->status
);
2948 * function: zfcp_fsf_open_unit
2954 * assumptions: This routine does not check whether the associated
2955 * remote port has already been opened. This should be
2956 * done by calling routines. Otherwise some status
2957 * may be presented by FSF
2960 zfcp_fsf_open_unit(struct zfcp_erp_action
*erp_action
)
2962 volatile struct qdio_buffer_element
*sbale
;
2963 unsigned long lock_flags
;
2966 /* setup new FSF request */
2967 retval
= zfcp_fsf_req_create(erp_action
->adapter
,
2969 ZFCP_WAIT_FOR_SBAL
| ZFCP_REQ_AUTO_CLEANUP
,
2970 erp_action
->adapter
->pool
.fsf_req_erp
,
2971 &lock_flags
, &(erp_action
->fsf_req
));
2973 ZFCP_LOG_INFO("error: Could not create open unit request for "
2974 "unit 0x%016Lx on port 0x%016Lx on adapter %s.\n",
2975 erp_action
->unit
->fcp_lun
,
2976 erp_action
->unit
->port
->wwpn
,
2977 zfcp_get_busid_by_adapter(erp_action
->adapter
));
2981 sbale
= zfcp_qdio_sbale_req(erp_action
->fsf_req
,
2982 erp_action
->fsf_req
->sbal_curr
, 0);
2983 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_READ
;
2984 sbale
[1].flags
|= SBAL_FLAGS_LAST_ENTRY
;
2986 erp_action
->fsf_req
->qtcb
->header
.port_handle
=
2987 erp_action
->port
->handle
;
2988 erp_action
->fsf_req
->qtcb
->bottom
.support
.fcp_lun
=
2989 erp_action
->unit
->fcp_lun
;
2990 if (!(erp_action
->adapter
->connection_features
& FSF_FEATURE_NPIV_MODE
))
2991 erp_action
->fsf_req
->qtcb
->bottom
.support
.option
=
2992 FSF_OPEN_LUN_SUPPRESS_BOXING
;
2993 atomic_set_mask(ZFCP_STATUS_COMMON_OPENING
, &erp_action
->unit
->status
);
2994 erp_action
->fsf_req
->data
= (unsigned long) erp_action
->unit
;
2995 erp_action
->fsf_req
->erp_action
= erp_action
;
2997 /* start QDIO request for this FSF request */
2998 retval
= zfcp_fsf_req_send(erp_action
->fsf_req
, &erp_action
->timer
);
3000 ZFCP_LOG_INFO("error: Could not send an open unit request "
3001 "on the adapter %s, port 0x%016Lx for "
3003 zfcp_get_busid_by_adapter(erp_action
->adapter
),
3004 erp_action
->port
->wwpn
,
3005 erp_action
->unit
->fcp_lun
);
3006 zfcp_fsf_req_free(erp_action
->fsf_req
);
3007 erp_action
->fsf_req
= NULL
;
3011 ZFCP_LOG_TRACE("Open LUN request initiated (adapter %s, "
3012 "port 0x%016Lx, unit 0x%016Lx)\n",
3013 zfcp_get_busid_by_adapter(erp_action
->adapter
),
3014 erp_action
->port
->wwpn
, erp_action
->unit
->fcp_lun
);
3016 write_unlock_irqrestore(&erp_action
->adapter
->request_queue
.queue_lock
,
3022 * function: zfcp_fsf_open_unit_handler
3024 * purpose: is called for finished Open LUN command
3029 zfcp_fsf_open_unit_handler(struct zfcp_fsf_req
*fsf_req
)
3031 int retval
= -EINVAL
;
3032 struct zfcp_adapter
*adapter
;
3033 struct zfcp_unit
*unit
;
3034 struct fsf_qtcb_header
*header
;
3035 struct fsf_qtcb_bottom_support
*bottom
;
3036 struct fsf_queue_designator
*queue_designator
;
3037 u16 subtable
, rule
, counter
;
3038 int exclusive
, readwrite
;
3040 unit
= (struct zfcp_unit
*) fsf_req
->data
;
3042 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
) {
3043 /* don't change unit status in our bookkeeping */
3044 goto skip_fsfstatus
;
3047 adapter
= fsf_req
->adapter
;
3048 header
= &fsf_req
->qtcb
->header
;
3049 bottom
= &fsf_req
->qtcb
->bottom
.support
;
3050 queue_designator
= &header
->fsf_status_qual
.fsf_queue_designator
;
3052 atomic_clear_mask(ZFCP_STATUS_COMMON_ACCESS_DENIED
|
3053 ZFCP_STATUS_UNIT_SHARED
|
3054 ZFCP_STATUS_UNIT_READONLY
,
3057 /* evaluate FSF status in QTCB */
3058 switch (header
->fsf_status
) {
3060 case FSF_PORT_HANDLE_NOT_VALID
:
3061 ZFCP_LOG_INFO("Temporary port identifier 0x%x "
3062 "for port 0x%016Lx on adapter %s invalid "
3063 "This may happen occasionally\n",
3065 unit
->port
->wwpn
, zfcp_get_busid_by_unit(unit
));
3066 ZFCP_LOG_DEBUG("status qualifier:\n");
3067 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
3068 (char *) &header
->fsf_status_qual
,
3069 sizeof (union fsf_status_qual
));
3070 debug_text_event(adapter
->erp_dbf
, 1, "fsf_s_ph_nv");
3071 zfcp_erp_adapter_reopen(unit
->port
->adapter
, 0);
3072 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3075 case FSF_LUN_ALREADY_OPEN
:
3076 ZFCP_LOG_NORMAL("bug: Attempted to open unit 0x%016Lx on "
3077 "remote port 0x%016Lx on adapter %s twice.\n",
3079 unit
->port
->wwpn
, zfcp_get_busid_by_unit(unit
));
3080 debug_text_exception(adapter
->erp_dbf
, 0,
3082 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3085 case FSF_ACCESS_DENIED
:
3086 ZFCP_LOG_NORMAL("Access denied, cannot open unit 0x%016Lx on "
3087 "remote port 0x%016Lx on adapter %s\n",
3088 unit
->fcp_lun
, unit
->port
->wwpn
,
3089 zfcp_get_busid_by_unit(unit
));
3090 for (counter
= 0; counter
< 2; counter
++) {
3091 subtable
= header
->fsf_status_qual
.halfword
[counter
* 2];
3092 rule
= header
->fsf_status_qual
.halfword
[counter
* 2 + 1];
3094 case FSF_SQ_CFDC_SUBTABLE_OS
:
3095 case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN
:
3096 case FSF_SQ_CFDC_SUBTABLE_PORT_DID
:
3097 case FSF_SQ_CFDC_SUBTABLE_LUN
:
3098 ZFCP_LOG_INFO("Access denied (%s rule %d)\n",
3099 zfcp_act_subtable_type
[subtable
], rule
);
3103 debug_text_event(adapter
->erp_dbf
, 1, "fsf_s_access");
3104 zfcp_erp_unit_access_denied(unit
);
3105 atomic_clear_mask(ZFCP_STATUS_UNIT_SHARED
, &unit
->status
);
3106 atomic_clear_mask(ZFCP_STATUS_UNIT_READONLY
, &unit
->status
);
3107 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3110 case FSF_PORT_BOXED
:
3111 ZFCP_LOG_DEBUG("The remote port 0x%016Lx on adapter %s "
3112 "needs to be reopened\n",
3113 unit
->port
->wwpn
, zfcp_get_busid_by_unit(unit
));
3114 debug_text_event(adapter
->erp_dbf
, 2, "fsf_s_pboxed");
3115 zfcp_erp_port_boxed(unit
->port
);
3116 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
|
3117 ZFCP_STATUS_FSFREQ_RETRY
;
3120 case FSF_LUN_SHARING_VIOLATION
:
3121 if (header
->fsf_status_qual
.word
[0] != 0) {
3122 ZFCP_LOG_NORMAL("FCP-LUN 0x%Lx at the remote port "
3124 "connected to the adapter %s "
3125 "is already in use in LPAR%d, CSS%d\n",
3128 zfcp_get_busid_by_unit(unit
),
3129 queue_designator
->hla
,
3130 queue_designator
->cssid
);
3132 subtable
= header
->fsf_status_qual
.halfword
[4];
3133 rule
= header
->fsf_status_qual
.halfword
[5];
3135 case FSF_SQ_CFDC_SUBTABLE_OS
:
3136 case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN
:
3137 case FSF_SQ_CFDC_SUBTABLE_PORT_DID
:
3138 case FSF_SQ_CFDC_SUBTABLE_LUN
:
3139 ZFCP_LOG_NORMAL("Access to FCP-LUN 0x%Lx at the "
3140 "remote port with WWPN 0x%Lx "
3141 "connected to the adapter %s "
3142 "is denied (%s rule %d)\n",
3145 zfcp_get_busid_by_unit(unit
),
3146 zfcp_act_subtable_type
[subtable
],
3151 ZFCP_LOG_DEBUG("status qualifier:\n");
3152 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
3153 (char *) &header
->fsf_status_qual
,
3154 sizeof (union fsf_status_qual
));
3155 debug_text_event(adapter
->erp_dbf
, 2,
3157 zfcp_erp_unit_access_denied(unit
);
3158 atomic_clear_mask(ZFCP_STATUS_UNIT_SHARED
, &unit
->status
);
3159 atomic_clear_mask(ZFCP_STATUS_UNIT_READONLY
, &unit
->status
);
3160 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3163 case FSF_MAXIMUM_NUMBER_OF_LUNS_EXCEEDED
:
3164 ZFCP_LOG_INFO("error: The adapter ran out of resources. "
3165 "There is no handle (temporary port identifier) "
3166 "available for unit 0x%016Lx on port 0x%016Lx "
3170 zfcp_get_busid_by_unit(unit
));
3171 debug_text_event(adapter
->erp_dbf
, 1,
3173 zfcp_erp_unit_failed(unit
);
3174 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3177 case FSF_ADAPTER_STATUS_AVAILABLE
:
3178 switch (header
->fsf_status_qual
.word
[0]) {
3179 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE
:
3180 /* Re-establish link to port */
3181 debug_text_event(adapter
->erp_dbf
, 1,
3183 zfcp_test_link(unit
->port
);
3184 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3186 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED
:
3187 /* ERP strategy will escalate */
3188 debug_text_event(adapter
->erp_dbf
, 1,
3190 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3194 ("bug: Wrong status qualifier 0x%x arrived.\n",
3195 header
->fsf_status_qual
.word
[0]);
3196 debug_text_event(adapter
->erp_dbf
, 0,
3198 debug_exception(adapter
->erp_dbf
, 0,
3199 &header
->fsf_status_qual
.word
[0],
3204 case FSF_INVALID_COMMAND_OPTION
:
3206 "Invalid option 0x%x has been specified "
3207 "in QTCB bottom sent to the adapter %s\n",
3209 zfcp_get_busid_by_adapter(adapter
));
3210 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3215 /* save LUN handle assigned by FSF */
3216 unit
->handle
= header
->lun_handle
;
3217 ZFCP_LOG_TRACE("unit 0x%016Lx on remote port 0x%016Lx on "
3218 "adapter %s opened, port handle 0x%x\n",
3221 zfcp_get_busid_by_unit(unit
),
3223 /* mark unit as open */
3224 atomic_set_mask(ZFCP_STATUS_COMMON_OPEN
, &unit
->status
);
3226 if (!(adapter
->connection_features
& FSF_FEATURE_NPIV_MODE
) &&
3227 (adapter
->adapter_features
& FSF_FEATURE_LUN_SHARING
) &&
3228 (adapter
->ccw_device
->id
.dev_model
!= ZFCP_DEVICE_MODEL_PRIV
)) {
3229 exclusive
= (bottom
->lun_access_info
&
3230 FSF_UNIT_ACCESS_EXCLUSIVE
);
3231 readwrite
= (bottom
->lun_access_info
&
3232 FSF_UNIT_ACCESS_OUTBOUND_TRANSFER
);
3235 atomic_set_mask(ZFCP_STATUS_UNIT_SHARED
,
3239 atomic_set_mask(ZFCP_STATUS_UNIT_READONLY
,
3241 ZFCP_LOG_NORMAL("read-only access for unit "
3242 "(adapter %s, wwpn=0x%016Lx, "
3243 "fcp_lun=0x%016Lx)\n",
3244 zfcp_get_busid_by_unit(unit
),
3249 if (exclusive
&& !readwrite
) {
3250 ZFCP_LOG_NORMAL("exclusive access of read-only "
3251 "unit not supported\n");
3252 zfcp_erp_unit_failed(unit
);
3253 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3254 zfcp_erp_unit_shutdown(unit
, 0);
3255 } else if (!exclusive
&& readwrite
) {
3256 ZFCP_LOG_NORMAL("shared access of read-write "
3257 "unit not supported\n");
3258 zfcp_erp_unit_failed(unit
);
3259 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3260 zfcp_erp_unit_shutdown(unit
, 0);
3268 ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
3269 "(debug info 0x%x)\n",
3270 header
->fsf_status
);
3271 debug_text_event(adapter
->erp_dbf
, 0, "fsf_s_inval:");
3272 debug_exception(adapter
->erp_dbf
, 0,
3273 &header
->fsf_status
, sizeof (u32
));
3278 atomic_clear_mask(ZFCP_STATUS_COMMON_OPENING
, &unit
->status
);
3283 * function: zfcp_fsf_close_unit
3287 * returns: address of fsf_req - request successfully initiated
3290 * assumptions: This routine does not check whether the associated
3291 * remote port/lun has already been opened. This should be
3292 * done by calling routines. Otherwise some status
3293 * may be presented by FSF
3296 zfcp_fsf_close_unit(struct zfcp_erp_action
*erp_action
)
3298 volatile struct qdio_buffer_element
*sbale
;
3299 unsigned long lock_flags
;
3302 /* setup new FSF request */
3303 retval
= zfcp_fsf_req_create(erp_action
->adapter
,
3305 ZFCP_WAIT_FOR_SBAL
| ZFCP_REQ_AUTO_CLEANUP
,
3306 erp_action
->adapter
->pool
.fsf_req_erp
,
3307 &lock_flags
, &(erp_action
->fsf_req
));
3309 ZFCP_LOG_INFO("error: Could not create close unit request for "
3310 "unit 0x%016Lx on port 0x%016Lx on adapter %s.\n",
3311 erp_action
->unit
->fcp_lun
,
3312 erp_action
->port
->wwpn
,
3313 zfcp_get_busid_by_adapter(erp_action
->adapter
));
3317 sbale
= zfcp_qdio_sbale_req(erp_action
->fsf_req
,
3318 erp_action
->fsf_req
->sbal_curr
, 0);
3319 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_READ
;
3320 sbale
[1].flags
|= SBAL_FLAGS_LAST_ENTRY
;
3322 erp_action
->fsf_req
->qtcb
->header
.port_handle
=
3323 erp_action
->port
->handle
;
3324 erp_action
->fsf_req
->qtcb
->header
.lun_handle
= erp_action
->unit
->handle
;
3325 atomic_set_mask(ZFCP_STATUS_COMMON_CLOSING
, &erp_action
->unit
->status
);
3326 erp_action
->fsf_req
->data
= (unsigned long) erp_action
->unit
;
3327 erp_action
->fsf_req
->erp_action
= erp_action
;
3329 /* start QDIO request for this FSF request */
3330 retval
= zfcp_fsf_req_send(erp_action
->fsf_req
, &erp_action
->timer
);
3332 ZFCP_LOG_INFO("error: Could not send a close unit request for "
3333 "unit 0x%016Lx on port 0x%016Lx onadapter %s.\n",
3334 erp_action
->unit
->fcp_lun
,
3335 erp_action
->port
->wwpn
,
3336 zfcp_get_busid_by_adapter(erp_action
->adapter
));
3337 zfcp_fsf_req_free(erp_action
->fsf_req
);
3338 erp_action
->fsf_req
= NULL
;
3342 ZFCP_LOG_TRACE("Close LUN request initiated (adapter %s, "
3343 "port 0x%016Lx, unit 0x%016Lx)\n",
3344 zfcp_get_busid_by_adapter(erp_action
->adapter
),
3345 erp_action
->port
->wwpn
, erp_action
->unit
->fcp_lun
);
3347 write_unlock_irqrestore(&erp_action
->adapter
->request_queue
.queue_lock
,
3353 * function: zfcp_fsf_close_unit_handler
3355 * purpose: is called for finished Close LUN FSF command
3360 zfcp_fsf_close_unit_handler(struct zfcp_fsf_req
*fsf_req
)
3362 int retval
= -EINVAL
;
3363 struct zfcp_unit
*unit
;
3365 unit
= (struct zfcp_unit
*) fsf_req
->data
;
3367 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
) {
3368 /* don't change unit status in our bookkeeping */
3369 goto skip_fsfstatus
;
3372 /* evaluate FSF status in QTCB */
3373 switch (fsf_req
->qtcb
->header
.fsf_status
) {
3375 case FSF_PORT_HANDLE_NOT_VALID
:
3376 ZFCP_LOG_INFO("Temporary port identifier 0x%x for port "
3377 "0x%016Lx on adapter %s invalid. This may "
3378 "happen in rare circumstances\n",
3381 zfcp_get_busid_by_unit(unit
));
3382 ZFCP_LOG_DEBUG("status qualifier:\n");
3383 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
3384 (char *) &fsf_req
->qtcb
->header
.fsf_status_qual
,
3385 sizeof (union fsf_status_qual
));
3386 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
3388 zfcp_erp_adapter_reopen(unit
->port
->adapter
, 0);
3389 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3392 case FSF_LUN_HANDLE_NOT_VALID
:
3393 ZFCP_LOG_INFO("Temporary LUN identifier 0x%x of unit "
3394 "0x%016Lx on port 0x%016Lx on adapter %s is "
3395 "invalid. This may happen occasionally.\n",
3399 zfcp_get_busid_by_unit(unit
));
3400 ZFCP_LOG_DEBUG("Status qualifier data:\n");
3401 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
3402 (char *) &fsf_req
->qtcb
->header
.fsf_status_qual
,
3403 sizeof (union fsf_status_qual
));
3404 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
3406 zfcp_erp_port_reopen(unit
->port
, 0);
3407 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3410 case FSF_PORT_BOXED
:
3411 ZFCP_LOG_DEBUG("The remote port 0x%016Lx on adapter %s "
3412 "needs to be reopened\n",
3414 zfcp_get_busid_by_unit(unit
));
3415 debug_text_event(fsf_req
->adapter
->erp_dbf
, 2, "fsf_s_pboxed");
3416 zfcp_erp_port_boxed(unit
->port
);
3417 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
|
3418 ZFCP_STATUS_FSFREQ_RETRY
;
3421 case FSF_ADAPTER_STATUS_AVAILABLE
:
3422 switch (fsf_req
->qtcb
->header
.fsf_status_qual
.word
[0]) {
3423 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE
:
3424 /* re-establish link to port */
3425 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
3427 zfcp_test_link(unit
->port
);
3428 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3430 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED
:
3431 /* ERP strategy will escalate */
3432 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
3434 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3438 ("bug: Wrong status qualifier 0x%x arrived.\n",
3439 fsf_req
->qtcb
->header
.fsf_status_qual
.word
[0]);
3440 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0,
3443 fsf_req
->adapter
->erp_dbf
, 0,
3444 &fsf_req
->qtcb
->header
.fsf_status_qual
.word
[0],
3451 ZFCP_LOG_TRACE("unit 0x%016Lx on port 0x%016Lx on adapter %s "
3452 "closed, port handle 0x%x\n",
3455 zfcp_get_busid_by_unit(unit
),
3457 /* mark unit as closed */
3458 atomic_clear_mask(ZFCP_STATUS_COMMON_OPEN
, &unit
->status
);
3463 ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
3464 "(debug info 0x%x)\n",
3465 fsf_req
->qtcb
->header
.fsf_status
);
3466 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0, "fsf_s_inval:");
3467 debug_exception(fsf_req
->adapter
->erp_dbf
, 0,
3468 &fsf_req
->qtcb
->header
.fsf_status
,
3474 atomic_clear_mask(ZFCP_STATUS_COMMON_CLOSING
, &unit
->status
);
3479 * zfcp_fsf_send_fcp_command_task - initiate an FCP command (for a SCSI command)
3480 * @adapter: adapter where scsi command is issued
3481 * @unit: unit where command is sent to
3482 * @scsi_cmnd: scsi command to be sent
3483 * @timer: timer to be started when request is initiated
3484 * @req_flags: flags for fsf_request
3487 zfcp_fsf_send_fcp_command_task(struct zfcp_adapter
*adapter
,
3488 struct zfcp_unit
*unit
,
3489 struct scsi_cmnd
* scsi_cmnd
,
3490 struct timer_list
*timer
, int req_flags
)
3492 struct zfcp_fsf_req
*fsf_req
= NULL
;
3493 struct fcp_cmnd_iu
*fcp_cmnd_iu
;
3494 unsigned int sbtype
;
3495 unsigned long lock_flags
;
3500 /* setup new FSF request */
3501 retval
= zfcp_fsf_req_create(adapter
, FSF_QTCB_FCP_CMND
, req_flags
,
3502 adapter
->pool
.fsf_req_scsi
,
3503 &lock_flags
, &fsf_req
);
3504 if (unlikely(retval
< 0)) {
3505 ZFCP_LOG_DEBUG("error: Could not create FCP command request "
3506 "for unit 0x%016Lx on port 0x%016Lx on "
3510 zfcp_get_busid_by_adapter(adapter
));
3511 goto failed_req_create
;
3514 zfcp_unit_get(unit
);
3515 fsf_req
->unit
= unit
;
3517 /* associate FSF request with SCSI request (for look up on abort) */
3518 scsi_cmnd
->host_scribble
= (char *) fsf_req
;
3520 /* associate SCSI command with FSF request */
3521 fsf_req
->data
= (unsigned long) scsi_cmnd
;
3523 /* set handles of unit and its parent port in QTCB */
3524 fsf_req
->qtcb
->header
.lun_handle
= unit
->handle
;
3525 fsf_req
->qtcb
->header
.port_handle
= unit
->port
->handle
;
3527 /* FSF does not define the structure of the FCP_CMND IU */
3528 fcp_cmnd_iu
= (struct fcp_cmnd_iu
*)
3529 &(fsf_req
->qtcb
->bottom
.io
.fcp_cmnd
);
3532 * set depending on data direction:
3533 * data direction bits in SBALE (SB Type)
3534 * data direction bits in QTCB
3535 * data direction bits in FCP_CMND IU
3537 switch (scsi_cmnd
->sc_data_direction
) {
3539 fsf_req
->qtcb
->bottom
.io
.data_direction
= FSF_DATADIR_CMND
;
3542 * what is the correct type for commands
3543 * without 'real' data buffers?
3545 sbtype
= SBAL_FLAGS0_TYPE_READ
;
3547 case DMA_FROM_DEVICE
:
3548 fsf_req
->qtcb
->bottom
.io
.data_direction
= FSF_DATADIR_READ
;
3549 sbtype
= SBAL_FLAGS0_TYPE_READ
;
3550 fcp_cmnd_iu
->rddata
= 1;
3553 fsf_req
->qtcb
->bottom
.io
.data_direction
= FSF_DATADIR_WRITE
;
3554 sbtype
= SBAL_FLAGS0_TYPE_WRITE
;
3555 fcp_cmnd_iu
->wddata
= 1;
3557 case DMA_BIDIRECTIONAL
:
3560 * dummy, catch this condition earlier
3561 * in zfcp_scsi_queuecommand
3563 goto failed_scsi_cmnd
;
3566 /* set FC service class in QTCB (3 per default) */
3567 fsf_req
->qtcb
->bottom
.io
.service_class
= ZFCP_FC_SERVICE_CLASS_DEFAULT
;
3569 /* set FCP_LUN in FCP_CMND IU in QTCB */
3570 fcp_cmnd_iu
->fcp_lun
= unit
->fcp_lun
;
3572 mask
= ZFCP_STATUS_UNIT_READONLY
| ZFCP_STATUS_UNIT_SHARED
;
3574 /* set task attributes in FCP_CMND IU in QTCB */
3575 if (likely((scsi_cmnd
->device
->simple_tags
) ||
3576 (atomic_test_mask(mask
, &unit
->status
))))
3577 fcp_cmnd_iu
->task_attribute
= SIMPLE_Q
;
3579 fcp_cmnd_iu
->task_attribute
= UNTAGGED
;
3581 /* set additional length of FCP_CDB in FCP_CMND IU in QTCB, if needed */
3582 if (unlikely(scsi_cmnd
->cmd_len
> FCP_CDB_LENGTH
)) {
3583 fcp_cmnd_iu
->add_fcp_cdb_length
3584 = (scsi_cmnd
->cmd_len
- FCP_CDB_LENGTH
) >> 2;
3585 ZFCP_LOG_TRACE("SCSI CDB length is 0x%x, "
3586 "additional FCP_CDB length is 0x%x "
3587 "(shifted right 2 bits)\n",
3589 fcp_cmnd_iu
->add_fcp_cdb_length
);
3592 * copy SCSI CDB (including additional length, if any) to
3593 * FCP_CDB in FCP_CMND IU in QTCB
3595 memcpy(fcp_cmnd_iu
->fcp_cdb
, scsi_cmnd
->cmnd
, scsi_cmnd
->cmd_len
);
3597 /* FCP CMND IU length in QTCB */
3598 fsf_req
->qtcb
->bottom
.io
.fcp_cmnd_length
=
3599 sizeof (struct fcp_cmnd_iu
) +
3600 fcp_cmnd_iu
->add_fcp_cdb_length
+ sizeof (fcp_dl_t
);
3602 /* generate SBALEs from data buffer */
3603 real_bytes
= zfcp_qdio_sbals_from_scsicmnd(fsf_req
, sbtype
, scsi_cmnd
);
3604 if (unlikely(real_bytes
< 0)) {
3605 if (fsf_req
->sbal_number
< ZFCP_MAX_SBALS_PER_REQ
) {
3607 "Data did not fit into available buffer(s), "
3608 "waiting for more...\n");
3611 ZFCP_LOG_NORMAL("error: No truncation implemented but "
3612 "required. Shutting down unit "
3613 "(adapter %s, port 0x%016Lx, "
3615 zfcp_get_busid_by_unit(unit
),
3618 zfcp_erp_unit_shutdown(unit
, 0);
3624 /* set length of FCP data length in FCP_CMND IU in QTCB */
3625 zfcp_set_fcp_dl(fcp_cmnd_iu
, real_bytes
);
3627 ZFCP_LOG_DEBUG("Sending SCSI command:\n");
3628 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
3629 (char *) scsi_cmnd
->cmnd
, scsi_cmnd
->cmd_len
);
3632 * start QDIO request for this FSF request
3633 * covered by an SBALE)
3635 retval
= zfcp_fsf_req_send(fsf_req
, timer
);
3636 if (unlikely(retval
< 0)) {
3637 ZFCP_LOG_INFO("error: Could not send FCP command request "
3638 "on adapter %s, port 0x%016Lx, unit 0x%016Lx\n",
3639 zfcp_get_busid_by_adapter(adapter
),
3645 ZFCP_LOG_TRACE("Send FCP Command initiated (adapter %s, "
3646 "port 0x%016Lx, unit 0x%016Lx)\n",
3647 zfcp_get_busid_by_adapter(adapter
),
3655 zfcp_unit_put(unit
);
3656 zfcp_fsf_req_free(fsf_req
);
3658 scsi_cmnd
->host_scribble
= NULL
;
3661 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
, lock_flags
);
3665 struct zfcp_fsf_req
*
3666 zfcp_fsf_send_fcp_command_task_management(struct zfcp_adapter
*adapter
,
3667 struct zfcp_unit
*unit
,
3668 u8 tm_flags
, int req_flags
)
3670 struct zfcp_fsf_req
*fsf_req
= NULL
;
3672 struct fcp_cmnd_iu
*fcp_cmnd_iu
;
3673 unsigned long lock_flags
;
3674 volatile struct qdio_buffer_element
*sbale
;
3676 /* setup new FSF request */
3677 retval
= zfcp_fsf_req_create(adapter
, FSF_QTCB_FCP_CMND
, req_flags
,
3678 adapter
->pool
.fsf_req_scsi
,
3679 &lock_flags
, &fsf_req
);
3681 ZFCP_LOG_INFO("error: Could not create FCP command (task "
3682 "management) request for adapter %s, port "
3683 " 0x%016Lx, unit 0x%016Lx.\n",
3684 zfcp_get_busid_by_adapter(adapter
),
3685 unit
->port
->wwpn
, unit
->fcp_lun
);
3690 * Used to decide on proper handler in the return path,
3691 * could be either zfcp_fsf_send_fcp_command_task_handler or
3692 * zfcp_fsf_send_fcp_command_task_management_handler */
3694 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT
;
3697 * hold a pointer to the unit being target of this
3698 * task management request
3700 fsf_req
->data
= (unsigned long) unit
;
3702 /* set FSF related fields in QTCB */
3703 fsf_req
->qtcb
->header
.lun_handle
= unit
->handle
;
3704 fsf_req
->qtcb
->header
.port_handle
= unit
->port
->handle
;
3705 fsf_req
->qtcb
->bottom
.io
.data_direction
= FSF_DATADIR_CMND
;
3706 fsf_req
->qtcb
->bottom
.io
.service_class
= ZFCP_FC_SERVICE_CLASS_DEFAULT
;
3707 fsf_req
->qtcb
->bottom
.io
.fcp_cmnd_length
=
3708 sizeof (struct fcp_cmnd_iu
) + sizeof (fcp_dl_t
);
3710 sbale
= zfcp_qdio_sbale_req(fsf_req
, fsf_req
->sbal_curr
, 0);
3711 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_WRITE
;
3712 sbale
[1].flags
|= SBAL_FLAGS_LAST_ENTRY
;
3714 /* set FCP related fields in FCP_CMND IU in QTCB */
3715 fcp_cmnd_iu
= (struct fcp_cmnd_iu
*)
3716 &(fsf_req
->qtcb
->bottom
.io
.fcp_cmnd
);
3717 fcp_cmnd_iu
->fcp_lun
= unit
->fcp_lun
;
3718 fcp_cmnd_iu
->task_management_flags
= tm_flags
;
3720 /* start QDIO request for this FSF request */
3721 zfcp_fsf_start_scsi_er_timer(adapter
);
3722 retval
= zfcp_fsf_req_send(fsf_req
, NULL
);
3724 del_timer(&adapter
->scsi_er_timer
);
3725 ZFCP_LOG_INFO("error: Could not send an FCP-command (task "
3726 "management) on adapter %s, port 0x%016Lx for "
3727 "unit LUN 0x%016Lx\n",
3728 zfcp_get_busid_by_adapter(adapter
),
3731 zfcp_fsf_req_free(fsf_req
);
3736 ZFCP_LOG_TRACE("Send FCP Command (task management function) initiated "
3737 "(adapter %s, port 0x%016Lx, unit 0x%016Lx, "
3739 zfcp_get_busid_by_adapter(adapter
),
3744 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
, lock_flags
);
3749 * function: zfcp_fsf_send_fcp_command_handler
3751 * purpose: is called for finished Send FCP Command
3756 zfcp_fsf_send_fcp_command_handler(struct zfcp_fsf_req
*fsf_req
)
3758 int retval
= -EINVAL
;
3759 struct zfcp_unit
*unit
;
3760 struct fsf_qtcb_header
*header
;
3761 u16 subtable
, rule
, counter
;
3763 header
= &fsf_req
->qtcb
->header
;
3765 if (unlikely(fsf_req
->status
& ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT
))
3766 unit
= (struct zfcp_unit
*) fsf_req
->data
;
3768 unit
= fsf_req
->unit
;
3770 if (unlikely(fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
)) {
3771 /* go directly to calls of special handlers */
3772 goto skip_fsfstatus
;
3775 /* evaluate FSF status in QTCB */
3776 switch (header
->fsf_status
) {
3778 case FSF_PORT_HANDLE_NOT_VALID
:
3779 ZFCP_LOG_INFO("Temporary port identifier 0x%x for port "
3780 "0x%016Lx on adapter %s invalid\n",
3782 unit
->port
->wwpn
, zfcp_get_busid_by_unit(unit
));
3783 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
3784 (char *) &header
->fsf_status_qual
,
3785 sizeof (union fsf_status_qual
));
3786 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
3788 zfcp_erp_adapter_reopen(unit
->port
->adapter
, 0);
3789 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3792 case FSF_LUN_HANDLE_NOT_VALID
:
3793 ZFCP_LOG_INFO("Temporary LUN identifier 0x%x for unit "
3794 "0x%016Lx on port 0x%016Lx on adapter %s is "
3795 "invalid. This may happen occasionally.\n",
3799 zfcp_get_busid_by_unit(unit
));
3800 ZFCP_LOG_NORMAL("Status qualifier data:\n");
3801 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_NORMAL
,
3802 (char *) &header
->fsf_status_qual
,
3803 sizeof (union fsf_status_qual
));
3804 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
3806 zfcp_erp_port_reopen(unit
->port
, 0);
3807 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3810 case FSF_HANDLE_MISMATCH
:
3811 ZFCP_LOG_NORMAL("bug: The port handle 0x%x has changed "
3812 "unexpectedly. (adapter %s, port 0x%016Lx, "
3815 zfcp_get_busid_by_unit(unit
),
3818 ZFCP_LOG_NORMAL("status qualifier:\n");
3819 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_NORMAL
,
3820 (char *) &header
->fsf_status_qual
,
3821 sizeof (union fsf_status_qual
));
3822 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
3824 zfcp_erp_adapter_reopen(unit
->port
->adapter
, 0);
3825 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3828 case FSF_SERVICE_CLASS_NOT_SUPPORTED
:
3829 ZFCP_LOG_INFO("error: adapter %s does not support fc "
3831 zfcp_get_busid_by_unit(unit
),
3832 ZFCP_FC_SERVICE_CLASS_DEFAULT
);
3833 /* stop operation for this adapter */
3834 debug_text_exception(fsf_req
->adapter
->erp_dbf
, 0,
3835 "fsf_s_class_nsup");
3836 zfcp_erp_adapter_shutdown(unit
->port
->adapter
, 0);
3837 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3840 case FSF_FCPLUN_NOT_VALID
:
3841 ZFCP_LOG_NORMAL("bug: unit 0x%016Lx on port 0x%016Lx on "
3842 "adapter %s does not have correct unit "
3846 zfcp_get_busid_by_unit(unit
),
3848 ZFCP_LOG_DEBUG("status qualifier:\n");
3849 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
3850 (char *) &header
->fsf_status_qual
,
3851 sizeof (union fsf_status_qual
));
3852 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
3853 "fsf_s_fcp_lun_nv");
3854 zfcp_erp_port_reopen(unit
->port
, 0);
3855 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3858 case FSF_ACCESS_DENIED
:
3859 ZFCP_LOG_NORMAL("Access denied, cannot send FCP command to "
3860 "unit 0x%016Lx on port 0x%016Lx on "
3861 "adapter %s\n", unit
->fcp_lun
, unit
->port
->wwpn
,
3862 zfcp_get_busid_by_unit(unit
));
3863 for (counter
= 0; counter
< 2; counter
++) {
3864 subtable
= header
->fsf_status_qual
.halfword
[counter
* 2];
3865 rule
= header
->fsf_status_qual
.halfword
[counter
* 2 + 1];
3867 case FSF_SQ_CFDC_SUBTABLE_OS
:
3868 case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN
:
3869 case FSF_SQ_CFDC_SUBTABLE_PORT_DID
:
3870 case FSF_SQ_CFDC_SUBTABLE_LUN
:
3871 ZFCP_LOG_INFO("Access denied (%s rule %d)\n",
3872 zfcp_act_subtable_type
[subtable
], rule
);
3876 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1, "fsf_s_access");
3877 zfcp_erp_unit_access_denied(unit
);
3878 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3881 case FSF_DIRECTION_INDICATOR_NOT_VALID
:
3882 ZFCP_LOG_INFO("bug: Invalid data direction given for unit "
3883 "0x%016Lx on port 0x%016Lx on adapter %s "
3884 "(debug info %d)\n",
3887 zfcp_get_busid_by_unit(unit
),
3888 fsf_req
->qtcb
->bottom
.io
.data_direction
);
3889 /* stop operation for this adapter */
3890 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0,
3891 "fsf_s_dir_ind_nv");
3892 zfcp_erp_adapter_shutdown(unit
->port
->adapter
, 0);
3893 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3896 case FSF_CMND_LENGTH_NOT_VALID
:
3898 ("bug: An invalid control-data-block length field "
3899 "was found in a command for unit 0x%016Lx on port "
3900 "0x%016Lx on adapter %s " "(debug info %d)\n",
3901 unit
->fcp_lun
, unit
->port
->wwpn
,
3902 zfcp_get_busid_by_unit(unit
),
3903 fsf_req
->qtcb
->bottom
.io
.fcp_cmnd_length
);
3904 /* stop operation for this adapter */
3905 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0,
3906 "fsf_s_cmd_len_nv");
3907 zfcp_erp_adapter_shutdown(unit
->port
->adapter
, 0);
3908 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3911 case FSF_PORT_BOXED
:
3912 ZFCP_LOG_DEBUG("The remote port 0x%016Lx on adapter %s "
3913 "needs to be reopened\n",
3914 unit
->port
->wwpn
, zfcp_get_busid_by_unit(unit
));
3915 debug_text_event(fsf_req
->adapter
->erp_dbf
, 2, "fsf_s_pboxed");
3916 zfcp_erp_port_boxed(unit
->port
);
3917 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
|
3918 ZFCP_STATUS_FSFREQ_RETRY
;
3922 ZFCP_LOG_NORMAL("unit needs to be reopened (adapter %s, "
3923 "wwpn=0x%016Lx, fcp_lun=0x%016Lx)\n",
3924 zfcp_get_busid_by_unit(unit
),
3925 unit
->port
->wwpn
, unit
->fcp_lun
);
3926 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1, "fsf_s_lboxed");
3927 zfcp_erp_unit_boxed(unit
);
3928 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
3929 | ZFCP_STATUS_FSFREQ_RETRY
;
3932 case FSF_ADAPTER_STATUS_AVAILABLE
:
3933 switch (header
->fsf_status_qual
.word
[0]) {
3934 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE
:
3935 /* re-establish link to port */
3936 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
3938 zfcp_test_link(unit
->port
);
3940 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED
:
3941 /* FIXME(hw) need proper specs for proper action */
3942 /* let scsi stack deal with retries and escalation */
3943 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
3948 ("Unknown status qualifier 0x%x arrived.\n",
3949 header
->fsf_status_qual
.word
[0]);
3950 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0,
3952 debug_exception(fsf_req
->adapter
->erp_dbf
, 0,
3953 &header
->fsf_status_qual
.word
[0],
3957 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3963 case FSF_FCP_RSP_AVAILABLE
:
3967 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0, "fsf_s_inval:");
3968 debug_exception(fsf_req
->adapter
->erp_dbf
, 0,
3969 &header
->fsf_status
, sizeof(u32
));
3974 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT
) {
3976 zfcp_fsf_send_fcp_command_task_management_handler(fsf_req
);
3978 retval
= zfcp_fsf_send_fcp_command_task_handler(fsf_req
);
3979 fsf_req
->unit
= NULL
;
3980 zfcp_unit_put(unit
);
3986 * function: zfcp_fsf_send_fcp_command_task_handler
3988 * purpose: evaluates FCP_RSP IU
3993 zfcp_fsf_send_fcp_command_task_handler(struct zfcp_fsf_req
*fsf_req
)
3996 struct scsi_cmnd
*scpnt
;
3997 struct fcp_rsp_iu
*fcp_rsp_iu
= (struct fcp_rsp_iu
*)
3998 &(fsf_req
->qtcb
->bottom
.io
.fcp_rsp
);
3999 struct fcp_cmnd_iu
*fcp_cmnd_iu
= (struct fcp_cmnd_iu
*)
4000 &(fsf_req
->qtcb
->bottom
.io
.fcp_cmnd
);
4002 char *fcp_rsp_info
= zfcp_get_fcp_rsp_info_ptr(fcp_rsp_iu
);
4003 unsigned long flags
;
4004 struct zfcp_unit
*unit
= fsf_req
->unit
;
4006 read_lock_irqsave(&fsf_req
->adapter
->abort_lock
, flags
);
4007 scpnt
= (struct scsi_cmnd
*) fsf_req
->data
;
4008 if (unlikely(!scpnt
)) {
4010 ("Command with fsf_req %p is not associated to "
4011 "a scsi command anymore. Aborted?\n", fsf_req
);
4014 if (unlikely(fsf_req
->status
& ZFCP_STATUS_FSFREQ_ABORTED
)) {
4015 /* FIXME: (design) mid-layer should handle DID_ABORT like
4016 * DID_SOFT_ERROR by retrying the request for devices
4017 * that allow retries.
4019 ZFCP_LOG_DEBUG("Setting DID_SOFT_ERROR and SUGGEST_RETRY\n");
4020 set_host_byte(&scpnt
->result
, DID_SOFT_ERROR
);
4021 set_driver_byte(&scpnt
->result
, SUGGEST_RETRY
);
4022 goto skip_fsfstatus
;
4025 if (unlikely(fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
)) {
4026 ZFCP_LOG_DEBUG("Setting DID_ERROR\n");
4027 set_host_byte(&scpnt
->result
, DID_ERROR
);
4028 goto skip_fsfstatus
;
4031 /* set message byte of result in SCSI command */
4032 scpnt
->result
|= COMMAND_COMPLETE
<< 8;
4035 * copy SCSI status code of FCP_STATUS of FCP_RSP IU to status byte
4036 * of result in SCSI command
4038 scpnt
->result
|= fcp_rsp_iu
->scsi_status
;
4039 if (unlikely(fcp_rsp_iu
->scsi_status
)) {
4041 ZFCP_LOG_DEBUG("status for SCSI Command:\n");
4042 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
4043 scpnt
->cmnd
, scpnt
->cmd_len
);
4044 ZFCP_LOG_DEBUG("SCSI status code 0x%x\n",
4045 fcp_rsp_iu
->scsi_status
);
4046 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
4047 (void *) fcp_rsp_iu
, sizeof (struct fcp_rsp_iu
));
4048 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
4049 zfcp_get_fcp_sns_info_ptr(fcp_rsp_iu
),
4050 fcp_rsp_iu
->fcp_sns_len
);
4053 /* check FCP_RSP_INFO */
4054 if (unlikely(fcp_rsp_iu
->validity
.bits
.fcp_rsp_len_valid
)) {
4055 ZFCP_LOG_DEBUG("rsp_len is valid\n");
4056 switch (fcp_rsp_info
[3]) {
4059 ZFCP_LOG_TRACE("no failure or Task Management "
4060 "Function complete\n");
4061 set_host_byte(&scpnt
->result
, DID_OK
);
4063 case RSP_CODE_LENGTH_MISMATCH
:
4065 ZFCP_LOG_NORMAL("bug: FCP response code indictates "
4066 "that the fibrechannel protocol data "
4067 "length differs from the burst length. "
4068 "The problem occured on unit 0x%016Lx "
4069 "on port 0x%016Lx on adapter %s",
4072 zfcp_get_busid_by_unit(unit
));
4073 /* dump SCSI CDB as prepared by zfcp */
4074 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
4075 (char *) &fsf_req
->qtcb
->
4076 bottom
.io
.fcp_cmnd
, FSF_FCP_CMND_SIZE
);
4077 set_host_byte(&scpnt
->result
, DID_ERROR
);
4078 goto skip_fsfstatus
;
4079 case RSP_CODE_FIELD_INVALID
:
4080 /* driver or hardware bug */
4081 ZFCP_LOG_NORMAL("bug: FCP response code indictates "
4082 "that the fibrechannel protocol data "
4083 "fields were incorrectly set up. "
4084 "The problem occured on the unit "
4085 "0x%016Lx on port 0x%016Lx on "
4089 zfcp_get_busid_by_unit(unit
));
4090 /* dump SCSI CDB as prepared by zfcp */
4091 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
4092 (char *) &fsf_req
->qtcb
->
4093 bottom
.io
.fcp_cmnd
, FSF_FCP_CMND_SIZE
);
4094 set_host_byte(&scpnt
->result
, DID_ERROR
);
4095 goto skip_fsfstatus
;
4096 case RSP_CODE_RO_MISMATCH
:
4098 ZFCP_LOG_NORMAL("bug: The FCP response code indicates "
4099 "that conflicting values for the "
4100 "fibrechannel payload offset from the "
4101 "header were found. "
4102 "The problem occured on unit 0x%016Lx "
4103 "on port 0x%016Lx on adapter %s.\n",
4106 zfcp_get_busid_by_unit(unit
));
4107 /* dump SCSI CDB as prepared by zfcp */
4108 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
4109 (char *) &fsf_req
->qtcb
->
4110 bottom
.io
.fcp_cmnd
, FSF_FCP_CMND_SIZE
);
4111 set_host_byte(&scpnt
->result
, DID_ERROR
);
4112 goto skip_fsfstatus
;
4114 ZFCP_LOG_NORMAL("bug: An invalid FCP response "
4115 "code was detected for a command. "
4116 "The problem occured on the unit "
4117 "0x%016Lx on port 0x%016Lx on "
4118 "adapter %s (debug info 0x%x)\n",
4121 zfcp_get_busid_by_unit(unit
),
4123 /* dump SCSI CDB as prepared by zfcp */
4124 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
4125 (char *) &fsf_req
->qtcb
->
4126 bottom
.io
.fcp_cmnd
, FSF_FCP_CMND_SIZE
);
4127 set_host_byte(&scpnt
->result
, DID_ERROR
);
4128 goto skip_fsfstatus
;
4132 /* check for sense data */
4133 if (unlikely(fcp_rsp_iu
->validity
.bits
.fcp_sns_len_valid
)) {
4134 sns_len
= FSF_FCP_RSP_SIZE
-
4135 sizeof (struct fcp_rsp_iu
) + fcp_rsp_iu
->fcp_rsp_len
;
4136 ZFCP_LOG_TRACE("room for %i bytes sense data in QTCB\n",
4138 sns_len
= min(sns_len
, (u32
) SCSI_SENSE_BUFFERSIZE
);
4139 ZFCP_LOG_TRACE("room for %i bytes sense data in SCSI command\n",
4140 SCSI_SENSE_BUFFERSIZE
);
4141 sns_len
= min(sns_len
, fcp_rsp_iu
->fcp_sns_len
);
4142 ZFCP_LOG_TRACE("scpnt->result =0x%x, command was:\n",
4144 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_TRACE
,
4145 (void *) &scpnt
->cmnd
, scpnt
->cmd_len
);
4147 ZFCP_LOG_TRACE("%i bytes sense data provided by FCP\n",
4148 fcp_rsp_iu
->fcp_sns_len
);
4149 memcpy(&scpnt
->sense_buffer
,
4150 zfcp_get_fcp_sns_info_ptr(fcp_rsp_iu
), sns_len
);
4151 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_TRACE
,
4152 (void *) &scpnt
->sense_buffer
, sns_len
);
4155 /* check for overrun */
4156 if (unlikely(fcp_rsp_iu
->validity
.bits
.fcp_resid_over
)) {
4157 ZFCP_LOG_INFO("A data overrun was detected for a command. "
4158 "unit 0x%016Lx, port 0x%016Lx, adapter %s. "
4159 "The response data length is "
4160 "%d, the original length was %d.\n",
4163 zfcp_get_busid_by_unit(unit
),
4164 fcp_rsp_iu
->fcp_resid
,
4165 (int) zfcp_get_fcp_dl(fcp_cmnd_iu
));
4168 /* check for underrun */
4169 if (unlikely(fcp_rsp_iu
->validity
.bits
.fcp_resid_under
)) {
4170 ZFCP_LOG_INFO("A data underrun was detected for a command. "
4171 "unit 0x%016Lx, port 0x%016Lx, adapter %s. "
4172 "The response data length is "
4173 "%d, the original length was %d.\n",
4176 zfcp_get_busid_by_unit(unit
),
4177 fcp_rsp_iu
->fcp_resid
,
4178 (int) zfcp_get_fcp_dl(fcp_cmnd_iu
));
4180 scpnt
->resid
= fcp_rsp_iu
->fcp_resid
;
4181 if (scpnt
->request_bufflen
- scpnt
->resid
< scpnt
->underflow
)
4182 set_host_byte(&scpnt
->result
, DID_ERROR
);
4186 ZFCP_LOG_DEBUG("scpnt->result =0x%x\n", scpnt
->result
);
4188 if (scpnt
->result
!= 0)
4189 zfcp_scsi_dbf_event_result("erro", 3, fsf_req
->adapter
, scpnt
, fsf_req
);
4190 else if (scpnt
->retries
> 0)
4191 zfcp_scsi_dbf_event_result("retr", 4, fsf_req
->adapter
, scpnt
, fsf_req
);
4193 zfcp_scsi_dbf_event_result("norm", 6, fsf_req
->adapter
, scpnt
, fsf_req
);
4195 /* cleanup pointer (need this especially for abort) */
4196 scpnt
->host_scribble
= NULL
;
4198 /* always call back */
4199 (scpnt
->scsi_done
) (scpnt
);
4202 * We must hold this lock until scsi_done has been called.
4203 * Otherwise we may call scsi_done after abort regarding this
4204 * command has completed.
4205 * Note: scsi_done must not block!
4208 read_unlock_irqrestore(&fsf_req
->adapter
->abort_lock
, flags
);
4213 * function: zfcp_fsf_send_fcp_command_task_management_handler
4215 * purpose: evaluates FCP_RSP IU
4220 zfcp_fsf_send_fcp_command_task_management_handler(struct zfcp_fsf_req
*fsf_req
)
4223 struct fcp_rsp_iu
*fcp_rsp_iu
= (struct fcp_rsp_iu
*)
4224 &(fsf_req
->qtcb
->bottom
.io
.fcp_rsp
);
4225 char *fcp_rsp_info
= zfcp_get_fcp_rsp_info_ptr(fcp_rsp_iu
);
4226 struct zfcp_unit
*unit
= (struct zfcp_unit
*) fsf_req
->data
;
4228 del_timer(&fsf_req
->adapter
->scsi_er_timer
);
4229 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
) {
4230 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_TMFUNCFAILED
;
4231 goto skip_fsfstatus
;
4234 /* check FCP_RSP_INFO */
4235 switch (fcp_rsp_info
[3]) {
4238 ZFCP_LOG_DEBUG("no failure or Task Management "
4239 "Function complete\n");
4241 case RSP_CODE_TASKMAN_UNSUPP
:
4242 ZFCP_LOG_NORMAL("bug: A reuested task management function "
4243 "is not supported on the target device "
4244 "unit 0x%016Lx, port 0x%016Lx, adapter %s\n ",
4247 zfcp_get_busid_by_unit(unit
));
4248 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_TMFUNCNOTSUPP
;
4250 case RSP_CODE_TASKMAN_FAILED
:
4251 ZFCP_LOG_NORMAL("bug: A reuested task management function "
4252 "failed to complete successfully. "
4253 "unit 0x%016Lx, port 0x%016Lx, adapter %s.\n",
4256 zfcp_get_busid_by_unit(unit
));
4257 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_TMFUNCFAILED
;
4260 ZFCP_LOG_NORMAL("bug: An invalid FCP response "
4261 "code was detected for a command. "
4262 "unit 0x%016Lx, port 0x%016Lx, adapter %s "
4263 "(debug info 0x%x)\n",
4266 zfcp_get_busid_by_unit(unit
),
4268 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_TMFUNCFAILED
;
4277 * function: zfcp_fsf_control_file
4279 * purpose: Initiator of the control file upload/download FSF requests
4281 * returns: 0 - FSF request is successfuly created and queued
4282 * -EOPNOTSUPP - The FCP adapter does not have Control File support
4283 * -EINVAL - Invalid direction specified
4284 * -ENOMEM - Insufficient memory
4285 * -EPERM - Cannot create FSF request or place it in QDIO queue
4288 zfcp_fsf_control_file(struct zfcp_adapter
*adapter
,
4289 struct zfcp_fsf_req
**fsf_req_ptr
,
4292 struct zfcp_sg_list
*sg_list
)
4294 struct zfcp_fsf_req
*fsf_req
;
4295 struct fsf_qtcb_bottom_support
*bottom
;
4296 volatile struct qdio_buffer_element
*sbale
;
4297 struct timer_list
*timer
;
4298 unsigned long lock_flags
;
4303 if (!(adapter
->adapter_features
& FSF_FEATURE_CFDC
)) {
4304 ZFCP_LOG_INFO("cfdc not supported (adapter %s)\n",
4305 zfcp_get_busid_by_adapter(adapter
));
4306 retval
= -EOPNOTSUPP
;
4310 switch (fsf_command
) {
4312 case FSF_QTCB_DOWNLOAD_CONTROL_FILE
:
4313 direction
= SBAL_FLAGS0_TYPE_WRITE
;
4314 if ((option
!= FSF_CFDC_OPTION_FULL_ACCESS
) &&
4315 (option
!= FSF_CFDC_OPTION_RESTRICTED_ACCESS
))
4316 req_flags
= ZFCP_WAIT_FOR_SBAL
;
4319 case FSF_QTCB_UPLOAD_CONTROL_FILE
:
4320 direction
= SBAL_FLAGS0_TYPE_READ
;
4324 ZFCP_LOG_INFO("Invalid FSF command code 0x%08x\n", fsf_command
);
4329 timer
= kmalloc(sizeof(struct timer_list
), GFP_KERNEL
);
4335 retval
= zfcp_fsf_req_create(adapter
, fsf_command
, req_flags
,
4336 NULL
, &lock_flags
, &fsf_req
);
4338 ZFCP_LOG_INFO("error: Could not create FSF request for the "
4340 zfcp_get_busid_by_adapter(adapter
));
4342 goto unlock_queue_lock
;
4345 sbale
= zfcp_qdio_sbale_req(fsf_req
, fsf_req
->sbal_curr
, 0);
4346 sbale
[0].flags
|= direction
;
4348 bottom
= &fsf_req
->qtcb
->bottom
.support
;
4349 bottom
->operation_subtype
= FSF_CFDC_OPERATION_SUBTYPE
;
4350 bottom
->option
= option
;
4352 if (sg_list
->count
> 0) {
4355 bytes
= zfcp_qdio_sbals_from_sg(fsf_req
, direction
,
4356 sg_list
->sg
, sg_list
->count
,
4357 ZFCP_MAX_SBALS_PER_REQ
);
4358 if (bytes
!= ZFCP_CFDC_MAX_CONTROL_FILE_SIZE
) {
4360 "error: Could not create sufficient number of "
4361 "SBALS for an FSF request to the adapter %s\n",
4362 zfcp_get_busid_by_adapter(adapter
));
4367 sbale
[1].flags
|= SBAL_FLAGS_LAST_ENTRY
;
4370 timer
->function
= zfcp_fsf_request_timeout_handler
;
4371 timer
->data
= (unsigned long) adapter
;
4372 timer
->expires
= ZFCP_FSF_REQUEST_TIMEOUT
;
4374 retval
= zfcp_fsf_req_send(fsf_req
, timer
);
4376 ZFCP_LOG_INFO("initiation of cfdc up/download failed"
4378 zfcp_get_busid_by_adapter(adapter
));
4382 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
, lock_flags
);
4384 ZFCP_LOG_NORMAL("Control file %s FSF request has been sent to the "
4386 fsf_command
== FSF_QTCB_DOWNLOAD_CONTROL_FILE
?
4387 "download" : "upload",
4388 zfcp_get_busid_by_adapter(adapter
));
4390 wait_event(fsf_req
->completion_wq
,
4391 fsf_req
->status
& ZFCP_STATUS_FSFREQ_COMPLETED
);
4393 *fsf_req_ptr
= fsf_req
;
4394 del_timer_sync(timer
);
4398 zfcp_fsf_req_free(fsf_req
);
4400 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
, lock_flags
);
4409 * function: zfcp_fsf_control_file_handler
4411 * purpose: Handler of the control file upload/download FSF requests
4413 * returns: 0 - FSF request successfuly processed
4414 * -EAGAIN - Operation has to be repeated because of a temporary problem
4415 * -EACCES - There is no permission to execute an operation
4416 * -EPERM - The control file is not in a right format
4417 * -EIO - There is a problem with the FCP adapter
4418 * -EINVAL - Invalid operation
4419 * -EFAULT - User space memory I/O operation fault
4422 zfcp_fsf_control_file_handler(struct zfcp_fsf_req
*fsf_req
)
4424 struct zfcp_adapter
*adapter
= fsf_req
->adapter
;
4425 struct fsf_qtcb_header
*header
= &fsf_req
->qtcb
->header
;
4426 struct fsf_qtcb_bottom_support
*bottom
= &fsf_req
->qtcb
->bottom
.support
;
4429 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
) {
4431 goto skip_fsfstatus
;
4434 switch (header
->fsf_status
) {
4438 "The FSF request has been successfully completed "
4439 "on the adapter %s\n",
4440 zfcp_get_busid_by_adapter(adapter
));
4443 case FSF_OPERATION_PARTIALLY_SUCCESSFUL
:
4444 if (bottom
->operation_subtype
== FSF_CFDC_OPERATION_SUBTYPE
) {
4445 switch (header
->fsf_status_qual
.word
[0]) {
4447 case FSF_SQ_CFDC_HARDENED_ON_SE
:
4449 "CFDC on the adapter %s has being "
4450 "hardened on primary and secondary SE\n",
4451 zfcp_get_busid_by_adapter(adapter
));
4454 case FSF_SQ_CFDC_COULD_NOT_HARDEN_ON_SE
:
4456 "CFDC of the adapter %s could not "
4457 "be saved on the SE\n",
4458 zfcp_get_busid_by_adapter(adapter
));
4461 case FSF_SQ_CFDC_COULD_NOT_HARDEN_ON_SE2
:
4463 "CFDC of the adapter %s could not "
4464 "be copied to the secondary SE\n",
4465 zfcp_get_busid_by_adapter(adapter
));
4470 "CFDC could not be hardened "
4471 "on the adapter %s\n",
4472 zfcp_get_busid_by_adapter(adapter
));
4475 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4479 case FSF_AUTHORIZATION_FAILURE
:
4481 "Adapter %s does not accept privileged commands\n",
4482 zfcp_get_busid_by_adapter(adapter
));
4483 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4487 case FSF_CFDC_ERROR_DETECTED
:
4489 "Error at position %d in the CFDC, "
4490 "CFDC is discarded by the adapter %s\n",
4491 header
->fsf_status_qual
.word
[0],
4492 zfcp_get_busid_by_adapter(adapter
));
4493 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4497 case FSF_CONTROL_FILE_UPDATE_ERROR
:
4499 "Adapter %s cannot harden the control file, "
4500 "file is discarded\n",
4501 zfcp_get_busid_by_adapter(adapter
));
4502 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4506 case FSF_CONTROL_FILE_TOO_LARGE
:
4508 "Control file is too large, file is discarded "
4509 "by the adapter %s\n",
4510 zfcp_get_busid_by_adapter(adapter
));
4511 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4515 case FSF_ACCESS_CONFLICT_DETECTED
:
4516 if (bottom
->operation_subtype
== FSF_CFDC_OPERATION_SUBTYPE
)
4518 "CFDC has been discarded by the adapter %s, "
4519 "because activation would impact "
4520 "%d active connection(s)\n",
4521 zfcp_get_busid_by_adapter(adapter
),
4522 header
->fsf_status_qual
.word
[0]);
4523 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4527 case FSF_CONFLICTS_OVERRULED
:
4528 if (bottom
->operation_subtype
== FSF_CFDC_OPERATION_SUBTYPE
)
4530 "CFDC has been activated on the adapter %s, "
4531 "but activation has impacted "
4532 "%d active connection(s)\n",
4533 zfcp_get_busid_by_adapter(adapter
),
4534 header
->fsf_status_qual
.word
[0]);
4535 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4539 case FSF_UNKNOWN_OP_SUBTYPE
:
4540 ZFCP_LOG_NORMAL("unknown operation subtype (adapter: %s, "
4541 "op_subtype=0x%x)\n",
4542 zfcp_get_busid_by_adapter(adapter
),
4543 bottom
->operation_subtype
);
4544 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4548 case FSF_INVALID_COMMAND_OPTION
:
4550 "Invalid option 0x%x has been specified "
4551 "in QTCB bottom sent to the adapter %s\n",
4553 zfcp_get_busid_by_adapter(adapter
));
4554 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4560 "bug: An unknown/unexpected FSF status 0x%08x "
4561 "was presented on the adapter %s\n",
4563 zfcp_get_busid_by_adapter(adapter
));
4564 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0, "fsf_sq_inval");
4565 debug_exception(fsf_req
->adapter
->erp_dbf
, 0,
4566 &header
->fsf_status_qual
.word
[0], sizeof(u32
));
4567 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4577 zfcp_fsf_req_sbal_check(unsigned long *flags
,
4578 struct zfcp_qdio_queue
*queue
, int needed
)
4580 write_lock_irqsave(&queue
->queue_lock
, *flags
);
4581 if (likely(atomic_read(&queue
->free_count
) >= needed
))
4583 write_unlock_irqrestore(&queue
->queue_lock
, *flags
);
4588 * set qtcb pointer in fsf_req and initialize QTCB
4591 zfcp_fsf_req_qtcb_init(struct zfcp_fsf_req
*fsf_req
)
4593 if (likely(fsf_req
->qtcb
!= NULL
)) {
4594 fsf_req
->qtcb
->prefix
.req_seq_no
= fsf_req
->adapter
->fsf_req_seq_no
;
4595 fsf_req
->qtcb
->prefix
.req_id
= (unsigned long)fsf_req
;
4596 fsf_req
->qtcb
->prefix
.ulp_info
= ZFCP_ULP_INFO_VERSION
;
4597 fsf_req
->qtcb
->prefix
.qtcb_type
= fsf_qtcb_type
[fsf_req
->fsf_command
];
4598 fsf_req
->qtcb
->prefix
.qtcb_version
= ZFCP_QTCB_VERSION
;
4599 fsf_req
->qtcb
->header
.req_handle
= (unsigned long)fsf_req
;
4600 fsf_req
->qtcb
->header
.fsf_command
= fsf_req
->fsf_command
;
4605 * zfcp_fsf_req_sbal_get - try to get one SBAL in the request queue
4606 * @adapter: adapter for which request queue is examined
4607 * @req_flags: flags indicating whether to wait for needed SBAL or not
4608 * @lock_flags: lock_flags if queue_lock is taken
4609 * Return: 0 on success, otherwise -EIO, or -ERESTARTSYS
4610 * Locks: lock adapter->request_queue->queue_lock on success
4613 zfcp_fsf_req_sbal_get(struct zfcp_adapter
*adapter
, int req_flags
,
4614 unsigned long *lock_flags
)
4617 struct zfcp_qdio_queue
*req_queue
= &adapter
->request_queue
;
4619 if (unlikely(req_flags
& ZFCP_WAIT_FOR_SBAL
)) {
4620 ret
= wait_event_interruptible_timeout(adapter
->request_wq
,
4621 zfcp_fsf_req_sbal_check(lock_flags
, req_queue
, 1),
4627 } else if (!zfcp_fsf_req_sbal_check(lock_flags
, req_queue
, 1))
4634 * function: zfcp_fsf_req_create
4636 * purpose: create an FSF request at the specified adapter and
4637 * setup common fields
4639 * returns: -ENOMEM if there was insufficient memory for a request
4640 * -EIO if no qdio buffers could be allocate to the request
4641 * -EINVAL/-EPERM on bug conditions in req_dequeue
4644 * note: The created request is returned by reference.
4646 * locks: lock of concerned request queue must not be held,
4647 * but is held on completion (write, irqsave)
4650 zfcp_fsf_req_create(struct zfcp_adapter
*adapter
, u32 fsf_cmd
, int req_flags
,
4651 mempool_t
*pool
, unsigned long *lock_flags
,
4652 struct zfcp_fsf_req
**fsf_req_p
)
4654 volatile struct qdio_buffer_element
*sbale
;
4655 struct zfcp_fsf_req
*fsf_req
= NULL
;
4657 struct zfcp_qdio_queue
*req_queue
= &adapter
->request_queue
;
4659 /* allocate new FSF request */
4660 fsf_req
= zfcp_fsf_req_alloc(pool
, req_flags
);
4661 if (unlikely(NULL
== fsf_req
)) {
4662 ZFCP_LOG_DEBUG("error: Could not put an FSF request into"
4663 "the outbound (send) queue.\n");
4665 goto failed_fsf_req
;
4668 fsf_req
->adapter
= adapter
;
4669 fsf_req
->fsf_command
= fsf_cmd
;
4671 zfcp_fsf_req_qtcb_init(fsf_req
);
4673 /* initialize waitqueue which may be used to wait on
4674 this request completion */
4675 init_waitqueue_head(&fsf_req
->completion_wq
);
4677 ret
= zfcp_fsf_req_sbal_get(adapter
, req_flags
, lock_flags
);
4683 * We hold queue_lock here. Check if QDIOUP is set and let request fail
4684 * if it is not set (see also *_open_qdio and *_close_qdio).
4687 if (!atomic_test_mask(ZFCP_STATUS_ADAPTER_QDIOUP
, &adapter
->status
)) {
4688 write_unlock_irqrestore(&req_queue
->queue_lock
, *lock_flags
);
4693 if (fsf_req
->qtcb
) {
4694 fsf_req
->seq_no
= adapter
->fsf_req_seq_no
;
4695 fsf_req
->qtcb
->prefix
.req_seq_no
= adapter
->fsf_req_seq_no
;
4697 fsf_req
->sbal_number
= 1;
4698 fsf_req
->sbal_first
= req_queue
->free_index
;
4699 fsf_req
->sbal_curr
= req_queue
->free_index
;
4700 fsf_req
->sbale_curr
= 1;
4702 if (likely(req_flags
& ZFCP_REQ_AUTO_CLEANUP
)) {
4703 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_CLEANUP
;
4706 sbale
= zfcp_qdio_sbale_req(fsf_req
, fsf_req
->sbal_curr
, 0);
4708 /* setup common SBALE fields */
4709 sbale
[0].addr
= fsf_req
;
4710 sbale
[0].flags
|= SBAL_FLAGS0_COMMAND
;
4711 if (likely(fsf_req
->qtcb
!= NULL
)) {
4712 sbale
[1].addr
= (void *) fsf_req
->qtcb
;
4713 sbale
[1].length
= sizeof(struct fsf_qtcb
);
4716 ZFCP_LOG_TRACE("got %i free BUFFERs starting at index %i\n",
4717 fsf_req
->sbal_number
, fsf_req
->sbal_first
);
4722 /* dequeue new FSF request previously enqueued */
4723 zfcp_fsf_req_free(fsf_req
);
4727 write_lock_irqsave(&req_queue
->queue_lock
, *lock_flags
);
4729 *fsf_req_p
= fsf_req
;
4734 * function: zfcp_fsf_req_send
4736 * purpose: start transfer of FSF request via QDIO
4738 * returns: 0 - request transfer succesfully started
4739 * !0 - start of request transfer failed
4742 zfcp_fsf_req_send(struct zfcp_fsf_req
*fsf_req
, struct timer_list
*timer
)
4744 struct zfcp_adapter
*adapter
;
4745 struct zfcp_qdio_queue
*req_queue
;
4746 volatile struct qdio_buffer_element
*sbale
;
4748 int new_distance_from_int
;
4749 unsigned long flags
;
4752 adapter
= fsf_req
->adapter
;
4753 req_queue
= &adapter
->request_queue
,
4756 /* FIXME(debug): remove it later */
4757 sbale
= zfcp_qdio_sbale_req(fsf_req
, fsf_req
->sbal_first
, 0);
4758 ZFCP_LOG_DEBUG("SBALE0 flags=0x%x\n", sbale
[0].flags
);
4759 ZFCP_LOG_TRACE("HEX DUMP OF SBALE1 PAYLOAD:\n");
4760 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_TRACE
, (char *) sbale
[1].addr
,
4763 /* put allocated FSF request at list tail */
4764 spin_lock_irqsave(&adapter
->fsf_req_list_lock
, flags
);
4765 list_add_tail(&fsf_req
->list
, &adapter
->fsf_req_list_head
);
4766 spin_unlock_irqrestore(&adapter
->fsf_req_list_lock
, flags
);
4768 inc_seq_no
= (fsf_req
->qtcb
!= NULL
);
4770 /* figure out expiration time of timeout and start timeout */
4771 if (unlikely(timer
)) {
4772 timer
->expires
+= jiffies
;
4776 ZFCP_LOG_TRACE("request queue of adapter %s: "
4777 "next free SBAL is %i, %i free SBALs\n",
4778 zfcp_get_busid_by_adapter(adapter
),
4779 req_queue
->free_index
,
4780 atomic_read(&req_queue
->free_count
));
4782 ZFCP_LOG_DEBUG("calling do_QDIO adapter %s, flags=0x%x, queue_no=%i, "
4783 "index_in_queue=%i, count=%i, buffers=%p\n",
4784 zfcp_get_busid_by_adapter(adapter
),
4785 QDIO_FLAG_SYNC_OUTPUT
,
4786 0, fsf_req
->sbal_first
, fsf_req
->sbal_number
,
4787 &req_queue
->buffer
[fsf_req
->sbal_first
]);
4790 * adjust the number of free SBALs in request queue as well as
4791 * position of first one
4793 atomic_sub(fsf_req
->sbal_number
, &req_queue
->free_count
);
4794 ZFCP_LOG_TRACE("free_count=%d\n", atomic_read(&req_queue
->free_count
));
4795 req_queue
->free_index
+= fsf_req
->sbal_number
; /* increase */
4796 req_queue
->free_index
%= QDIO_MAX_BUFFERS_PER_Q
; /* wrap if needed */
4797 new_distance_from_int
= zfcp_qdio_determine_pci(req_queue
, fsf_req
);
4799 fsf_req
->issued
= get_clock();
4801 retval
= do_QDIO(adapter
->ccw_device
,
4802 QDIO_FLAG_SYNC_OUTPUT
,
4803 0, fsf_req
->sbal_first
, fsf_req
->sbal_number
, NULL
);
4805 if (unlikely(retval
)) {
4806 /* Queues are down..... */
4809 * FIXME(potential race):
4810 * timer might be expired (absolutely unlikely)
4814 spin_lock_irqsave(&adapter
->fsf_req_list_lock
, flags
);
4815 list_del(&fsf_req
->list
);
4816 spin_unlock_irqrestore(&adapter
->fsf_req_list_lock
, flags
);
4818 * adjust the number of free SBALs in request queue as well as
4819 * position of first one
4821 zfcp_qdio_zero_sbals(req_queue
->buffer
,
4822 fsf_req
->sbal_first
, fsf_req
->sbal_number
);
4823 atomic_add(fsf_req
->sbal_number
, &req_queue
->free_count
);
4824 req_queue
->free_index
-= fsf_req
->sbal_number
; /* increase */
4825 req_queue
->free_index
+= QDIO_MAX_BUFFERS_PER_Q
;
4826 req_queue
->free_index
%= QDIO_MAX_BUFFERS_PER_Q
; /* wrap */
4828 ("error: do_QDIO failed. Buffers could not be enqueued "
4829 "to request queue.\n");
4831 req_queue
->distance_from_int
= new_distance_from_int
;
4833 * increase FSF sequence counter -
4834 * this must only be done for request successfully enqueued to
4835 * QDIO this rejected requests may be cleaned up by calling
4836 * routines resulting in missing sequence counter values
4840 /* Don't increase for unsolicited status */
4842 adapter
->fsf_req_seq_no
++;
4844 /* count FSF requests pending */
4845 atomic_inc(&adapter
->fsf_reqs_active
);
4850 #undef ZFCP_LOG_AREA