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
*);
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
*);
53 /* association between FSF command and FSF QTCB type */
54 static u32 fsf_qtcb_type
[] = {
55 [FSF_QTCB_FCP_CMND
] = FSF_IO_COMMAND
,
56 [FSF_QTCB_ABORT_FCP_CMND
] = FSF_SUPPORT_COMMAND
,
57 [FSF_QTCB_OPEN_PORT_WITH_DID
] = FSF_SUPPORT_COMMAND
,
58 [FSF_QTCB_OPEN_LUN
] = FSF_SUPPORT_COMMAND
,
59 [FSF_QTCB_CLOSE_LUN
] = FSF_SUPPORT_COMMAND
,
60 [FSF_QTCB_CLOSE_PORT
] = FSF_SUPPORT_COMMAND
,
61 [FSF_QTCB_CLOSE_PHYSICAL_PORT
] = FSF_SUPPORT_COMMAND
,
62 [FSF_QTCB_SEND_ELS
] = FSF_SUPPORT_COMMAND
,
63 [FSF_QTCB_SEND_GENERIC
] = FSF_SUPPORT_COMMAND
,
64 [FSF_QTCB_EXCHANGE_CONFIG_DATA
] = FSF_CONFIG_COMMAND
,
65 [FSF_QTCB_EXCHANGE_PORT_DATA
] = FSF_PORT_COMMAND
,
66 [FSF_QTCB_DOWNLOAD_CONTROL_FILE
] = FSF_SUPPORT_COMMAND
,
67 [FSF_QTCB_UPLOAD_CONTROL_FILE
] = FSF_SUPPORT_COMMAND
70 static const char zfcp_act_subtable_type
[5][8] = {
71 "unknown", "OS", "WWPN", "DID", "LUN"
74 /****************************************************************/
75 /*************** FSF related Functions *************************/
76 /****************************************************************/
78 #define ZFCP_LOG_AREA ZFCP_LOG_AREA_FSF
81 * function: zfcp_fsf_req_alloc
83 * purpose: Obtains an fsf_req and potentially a qtcb (for all but
84 * unsolicited requests) via helper functions
85 * Does some initial fsf request set-up.
87 * returns: pointer to allocated fsf_req if successfull
93 static struct zfcp_fsf_req
*
94 zfcp_fsf_req_alloc(mempool_t
*pool
, int req_flags
)
98 struct zfcp_fsf_req
*fsf_req
= NULL
;
100 if (req_flags
& ZFCP_REQ_NO_QTCB
)
101 size
= sizeof(struct zfcp_fsf_req
);
103 size
= sizeof(struct zfcp_fsf_req_qtcb
);
106 ptr
= mempool_alloc(pool
, GFP_ATOMIC
);
108 if (req_flags
& ZFCP_REQ_NO_QTCB
)
109 ptr
= kmalloc(size
, GFP_ATOMIC
);
111 ptr
= kmem_cache_alloc(zfcp_data
.fsf_req_qtcb_cache
,
118 memset(ptr
, 0, size
);
120 if (req_flags
& ZFCP_REQ_NO_QTCB
) {
121 fsf_req
= (struct zfcp_fsf_req
*) ptr
;
123 fsf_req
= &((struct zfcp_fsf_req_qtcb
*) ptr
)->fsf_req
;
124 fsf_req
->qtcb
= &((struct zfcp_fsf_req_qtcb
*) ptr
)->qtcb
;
127 fsf_req
->pool
= pool
;
134 * function: zfcp_fsf_req_free
136 * purpose: Frees the memory of an fsf_req (and potentially a qtcb) or
137 * returns it into the pool via helper functions.
144 zfcp_fsf_req_free(struct zfcp_fsf_req
*fsf_req
)
146 if (likely(fsf_req
->pool
)) {
147 mempool_free(fsf_req
, fsf_req
->pool
);
152 kmem_cache_free(zfcp_data
.fsf_req_qtcb_cache
, fsf_req
);
160 * Never ever call this without shutting down the adapter first.
161 * Otherwise the adapter would continue using and corrupting s390 storage.
162 * Included BUG_ON() call to ensure this is done.
163 * ERP is supposed to be the only user of this function.
165 void zfcp_fsf_req_dismiss_all(struct zfcp_adapter
*adapter
)
167 struct zfcp_fsf_req
*fsf_req
, *tmp
;
169 LIST_HEAD(remove_queue
);
172 BUG_ON(atomic_test_mask(ZFCP_STATUS_ADAPTER_QDIOUP
, &adapter
->status
));
173 spin_lock_irqsave(&adapter
->req_list_lock
, flags
);
174 atomic_set(&adapter
->reqs_active
, 0);
175 for (i
= 0; i
< REQUEST_LIST_SIZE
; i
++)
176 list_splice_init(&adapter
->req_list
[i
], &remove_queue
);
177 spin_unlock_irqrestore(&adapter
->req_list_lock
, flags
);
179 list_for_each_entry_safe(fsf_req
, tmp
, &remove_queue
, list
) {
180 list_del(&fsf_req
->list
);
181 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_DISMISSED
;
182 zfcp_fsf_req_complete(fsf_req
);
187 * function: zfcp_fsf_req_complete
189 * purpose: Updates active counts and timers for openfcp-reqs
190 * May cleanup request after req_eval returns
192 * returns: 0 - success
198 zfcp_fsf_req_complete(struct zfcp_fsf_req
*fsf_req
)
203 if (unlikely(fsf_req
->fsf_command
== FSF_QTCB_UNSOLICITED_STATUS
)) {
204 ZFCP_LOG_DEBUG("Status read response received\n");
206 * Note: all cleanup handling is done in the callchain of
207 * the function call-chain below.
209 zfcp_fsf_status_read_handler(fsf_req
);
212 del_timer(&fsf_req
->timer
);
213 zfcp_fsf_protstatus_eval(fsf_req
);
217 * fsf_req may be deleted due to waking up functions, so
218 * cleanup is saved here and used later
220 if (likely(fsf_req
->status
& ZFCP_STATUS_FSFREQ_CLEANUP
))
225 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_COMPLETED
;
227 /* cleanup request if requested by initiator */
228 if (likely(cleanup
)) {
229 ZFCP_LOG_TRACE("removing FSF request %p\n", fsf_req
);
231 * lock must not be held here since it will be
232 * grabed by the called routine, too
234 zfcp_fsf_req_free(fsf_req
);
236 /* notify initiator waiting for the requests completion */
237 ZFCP_LOG_TRACE("waking initiator of FSF request %p\n",fsf_req
);
239 * FIXME: Race! We must not access fsf_req here as it might have been
240 * cleaned up already due to the set ZFCP_STATUS_FSFREQ_COMPLETED
241 * flag. It's an improbable case. But, we have the same paranoia for
242 * the cleanup flag already.
243 * Might better be handled using complete()?
244 * (setting the flag and doing wakeup ought to be atomic
245 * with regard to checking the flag as long as waitqueue is
246 * part of the to be released structure)
248 wake_up(&fsf_req
->completion_wq
);
256 * function: zfcp_fsf_protstatus_eval
258 * purpose: evaluates the QTCB of the finished FSF request
259 * and initiates appropriate actions
260 * (usually calling FSF command specific handlers)
269 zfcp_fsf_protstatus_eval(struct zfcp_fsf_req
*fsf_req
)
272 struct zfcp_adapter
*adapter
= fsf_req
->adapter
;
273 struct fsf_qtcb
*qtcb
= fsf_req
->qtcb
;
274 union fsf_prot_status_qual
*prot_status_qual
=
275 &qtcb
->prefix
.prot_status_qual
;
277 zfcp_hba_dbf_event_fsf_response(fsf_req
);
279 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_DISMISSED
) {
280 ZFCP_LOG_DEBUG("fsf_req 0x%lx has been dismissed\n",
281 (unsigned long) fsf_req
);
282 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
|
283 ZFCP_STATUS_FSFREQ_RETRY
; /* only for SCSI cmnds. */
284 goto skip_protstatus
;
287 /* evaluate FSF Protocol Status */
288 switch (qtcb
->prefix
.prot_status
) {
291 case FSF_PROT_FSF_STATUS_PRESENTED
:
294 case FSF_PROT_QTCB_VERSION_ERROR
:
295 ZFCP_LOG_NORMAL("error: The adapter %s contains "
296 "microcode of version 0x%x, the device driver "
297 "only supports 0x%x. Aborting.\n",
298 zfcp_get_busid_by_adapter(adapter
),
299 prot_status_qual
->version_error
.fsf_version
,
301 zfcp_erp_adapter_shutdown(adapter
, 0);
302 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
305 case FSF_PROT_SEQ_NUMB_ERROR
:
306 ZFCP_LOG_NORMAL("bug: Sequence number mismatch between "
307 "driver (0x%x) and adapter %s (0x%x). "
308 "Restarting all operations on this adapter.\n",
309 qtcb
->prefix
.req_seq_no
,
310 zfcp_get_busid_by_adapter(adapter
),
311 prot_status_qual
->sequence_error
.exp_req_seq_no
);
312 zfcp_erp_adapter_reopen(adapter
, 0);
313 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_RETRY
;
314 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
317 case FSF_PROT_UNSUPP_QTCB_TYPE
:
318 ZFCP_LOG_NORMAL("error: Packet header type used by the "
319 "device driver is incompatible with "
320 "that used on adapter %s. "
321 "Stopping all operations on this adapter.\n",
322 zfcp_get_busid_by_adapter(adapter
));
323 zfcp_erp_adapter_shutdown(adapter
, 0);
324 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
327 case FSF_PROT_HOST_CONNECTION_INITIALIZING
:
328 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
329 atomic_set_mask(ZFCP_STATUS_ADAPTER_HOST_CON_INIT
,
333 case FSF_PROT_DUPLICATE_REQUEST_ID
:
334 ZFCP_LOG_NORMAL("bug: The request identifier 0x%Lx "
335 "to the adapter %s is ambiguous. "
336 "Stopping all operations on this adapter.\n",
337 *(unsigned long long*)
338 (&qtcb
->bottom
.support
.req_handle
),
339 zfcp_get_busid_by_adapter(adapter
));
340 zfcp_erp_adapter_shutdown(adapter
, 0);
341 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
344 case FSF_PROT_LINK_DOWN
:
345 zfcp_fsf_link_down_info_eval(adapter
,
346 &prot_status_qual
->link_down_info
);
347 zfcp_erp_adapter_reopen(adapter
, 0);
348 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
351 case FSF_PROT_REEST_QUEUE
:
352 ZFCP_LOG_NORMAL("The local link to adapter with "
353 "%s was re-plugged. "
354 "Re-starting operations on this adapter.\n",
355 zfcp_get_busid_by_adapter(adapter
));
356 /* All ports should be marked as ready to run again */
357 zfcp_erp_modify_adapter_status(adapter
,
358 ZFCP_STATUS_COMMON_RUNNING
,
360 zfcp_erp_adapter_reopen(adapter
,
361 ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED
362 | ZFCP_STATUS_COMMON_ERP_FAILED
);
363 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
366 case FSF_PROT_ERROR_STATE
:
367 ZFCP_LOG_NORMAL("error: The adapter %s "
368 "has entered the error state. "
369 "Restarting all operations on this "
371 zfcp_get_busid_by_adapter(adapter
));
372 zfcp_erp_adapter_reopen(adapter
, 0);
373 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_RETRY
;
374 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
378 ZFCP_LOG_NORMAL("bug: Transfer protocol status information "
379 "provided by the adapter %s "
380 "is not compatible with the device driver. "
381 "Stopping all operations on this adapter. "
382 "(debug info 0x%x).\n",
383 zfcp_get_busid_by_adapter(adapter
),
384 qtcb
->prefix
.prot_status
);
385 zfcp_erp_adapter_shutdown(adapter
, 0);
386 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
391 * always call specific handlers to give them a chance to do
392 * something meaningful even in error cases
394 zfcp_fsf_fsfstatus_eval(fsf_req
);
399 * function: zfcp_fsf_fsfstatus_eval
401 * purpose: evaluates FSF status of completed FSF request
402 * and acts accordingly
407 zfcp_fsf_fsfstatus_eval(struct zfcp_fsf_req
*fsf_req
)
411 if (unlikely(fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
)) {
415 /* evaluate FSF Status */
416 switch (fsf_req
->qtcb
->header
.fsf_status
) {
417 case FSF_UNKNOWN_COMMAND
:
418 ZFCP_LOG_NORMAL("bug: Command issued by the device driver is "
419 "not known by the adapter %s "
420 "Stopping all operations on this adapter. "
421 "(debug info 0x%x).\n",
422 zfcp_get_busid_by_adapter(fsf_req
->adapter
),
423 fsf_req
->qtcb
->header
.fsf_command
);
424 zfcp_erp_adapter_shutdown(fsf_req
->adapter
, 0);
425 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
428 case FSF_FCP_RSP_AVAILABLE
:
429 ZFCP_LOG_DEBUG("FCP Sense data will be presented to the "
433 case FSF_ADAPTER_STATUS_AVAILABLE
:
434 zfcp_fsf_fsfstatus_qual_eval(fsf_req
);
440 * always call specific handlers to give them a chance to do
441 * something meaningful even in error cases
443 zfcp_fsf_req_dispatch(fsf_req
);
449 * function: zfcp_fsf_fsfstatus_qual_eval
451 * purpose: evaluates FSF status-qualifier of completed FSF request
452 * and acts accordingly
457 zfcp_fsf_fsfstatus_qual_eval(struct zfcp_fsf_req
*fsf_req
)
461 switch (fsf_req
->qtcb
->header
.fsf_status_qual
.word
[0]) {
462 case FSF_SQ_FCP_RSP_AVAILABLE
:
464 case FSF_SQ_RETRY_IF_POSSIBLE
:
465 /* The SCSI-stack may now issue retries or escalate */
466 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
468 case FSF_SQ_COMMAND_ABORTED
:
469 /* Carry the aborted state on to upper layer */
470 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ABORTED
;
471 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
473 case FSF_SQ_NO_RECOM
:
474 ZFCP_LOG_NORMAL("bug: No recommendation could be given for a "
475 "problem on the adapter %s "
476 "Stopping all operations on this adapter. ",
477 zfcp_get_busid_by_adapter(fsf_req
->adapter
));
478 zfcp_erp_adapter_shutdown(fsf_req
->adapter
, 0);
479 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
481 case FSF_SQ_ULP_PROGRAMMING_ERROR
:
482 ZFCP_LOG_NORMAL("error: not enough SBALs for data transfer "
484 zfcp_get_busid_by_adapter(fsf_req
->adapter
));
485 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
487 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE
:
488 case FSF_SQ_NO_RETRY_POSSIBLE
:
489 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED
:
490 /* dealt with in the respective functions */
493 ZFCP_LOG_NORMAL("bug: Additional status info could "
494 "not be interpreted properly.\n");
495 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_NORMAL
,
496 (char *) &fsf_req
->qtcb
->header
.fsf_status_qual
,
497 sizeof (union fsf_status_qual
));
498 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
506 * zfcp_fsf_link_down_info_eval - evaluate link down information block
509 zfcp_fsf_link_down_info_eval(struct zfcp_adapter
*adapter
,
510 struct fsf_link_down_info
*link_down
)
512 if (atomic_test_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED
,
516 atomic_set_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED
, &adapter
->status
);
518 if (link_down
== NULL
)
521 switch (link_down
->error_code
) {
522 case FSF_PSQ_LINK_NO_LIGHT
:
523 ZFCP_LOG_NORMAL("The local link to adapter %s is down "
524 "(no light detected)\n",
525 zfcp_get_busid_by_adapter(adapter
));
527 case FSF_PSQ_LINK_WRAP_PLUG
:
528 ZFCP_LOG_NORMAL("The local link to adapter %s is down "
529 "(wrap plug detected)\n",
530 zfcp_get_busid_by_adapter(adapter
));
532 case FSF_PSQ_LINK_NO_FCP
:
533 ZFCP_LOG_NORMAL("The local link to adapter %s is down "
534 "(adjacent node on link does not support FCP)\n",
535 zfcp_get_busid_by_adapter(adapter
));
537 case FSF_PSQ_LINK_FIRMWARE_UPDATE
:
538 ZFCP_LOG_NORMAL("The local link to adapter %s is down "
539 "(firmware update in progress)\n",
540 zfcp_get_busid_by_adapter(adapter
));
542 case FSF_PSQ_LINK_INVALID_WWPN
:
543 ZFCP_LOG_NORMAL("The local link to adapter %s is down "
544 "(duplicate or invalid WWPN detected)\n",
545 zfcp_get_busid_by_adapter(adapter
));
547 case FSF_PSQ_LINK_NO_NPIV_SUPPORT
:
548 ZFCP_LOG_NORMAL("The local link to adapter %s is down "
549 "(no support for NPIV by Fabric)\n",
550 zfcp_get_busid_by_adapter(adapter
));
552 case FSF_PSQ_LINK_NO_FCP_RESOURCES
:
553 ZFCP_LOG_NORMAL("The local link to adapter %s is down "
554 "(out of resource in FCP daughtercard)\n",
555 zfcp_get_busid_by_adapter(adapter
));
557 case FSF_PSQ_LINK_NO_FABRIC_RESOURCES
:
558 ZFCP_LOG_NORMAL("The local link to adapter %s is down "
559 "(out of resource in Fabric)\n",
560 zfcp_get_busid_by_adapter(adapter
));
562 case FSF_PSQ_LINK_FABRIC_LOGIN_UNABLE
:
563 ZFCP_LOG_NORMAL("The local link to adapter %s is down "
564 "(unable to Fabric login)\n",
565 zfcp_get_busid_by_adapter(adapter
));
567 case FSF_PSQ_LINK_WWPN_ASSIGNMENT_CORRUPTED
:
568 ZFCP_LOG_NORMAL("WWPN assignment file corrupted on adapter %s\n",
569 zfcp_get_busid_by_adapter(adapter
));
571 case FSF_PSQ_LINK_MODE_TABLE_CURRUPTED
:
572 ZFCP_LOG_NORMAL("Mode table corrupted on adapter %s\n",
573 zfcp_get_busid_by_adapter(adapter
));
575 case FSF_PSQ_LINK_NO_WWPN_ASSIGNMENT
:
576 ZFCP_LOG_NORMAL("No WWPN for assignment table on adapter %s\n",
577 zfcp_get_busid_by_adapter(adapter
));
580 ZFCP_LOG_NORMAL("The local link to adapter %s is down "
581 "(warning: unknown reason code %d)\n",
582 zfcp_get_busid_by_adapter(adapter
),
583 link_down
->error_code
);
586 if (adapter
->connection_features
& FSF_FEATURE_NPIV_MODE
)
587 ZFCP_LOG_DEBUG("Debug information to link down: "
588 "primary_status=0x%02x "
590 "action_code=0x%02x "
591 "reason_code=0x%02x "
592 "explanation_code=0x%02x "
593 "vendor_specific_code=0x%02x\n",
594 link_down
->primary_status
,
595 link_down
->ioerr_code
,
596 link_down
->action_code
,
597 link_down
->reason_code
,
598 link_down
->explanation_code
,
599 link_down
->vendor_specific_code
);
602 zfcp_erp_adapter_failed(adapter
);
606 * function: zfcp_fsf_req_dispatch
608 * purpose: calls the appropriate command specific handler
613 zfcp_fsf_req_dispatch(struct zfcp_fsf_req
*fsf_req
)
615 struct zfcp_erp_action
*erp_action
= fsf_req
->erp_action
;
616 struct zfcp_adapter
*adapter
= fsf_req
->adapter
;
620 switch (fsf_req
->fsf_command
) {
622 case FSF_QTCB_FCP_CMND
:
623 zfcp_fsf_send_fcp_command_handler(fsf_req
);
626 case FSF_QTCB_ABORT_FCP_CMND
:
627 zfcp_fsf_abort_fcp_command_handler(fsf_req
);
630 case FSF_QTCB_SEND_GENERIC
:
631 zfcp_fsf_send_ct_handler(fsf_req
);
634 case FSF_QTCB_OPEN_PORT_WITH_DID
:
635 zfcp_fsf_open_port_handler(fsf_req
);
638 case FSF_QTCB_OPEN_LUN
:
639 zfcp_fsf_open_unit_handler(fsf_req
);
642 case FSF_QTCB_CLOSE_LUN
:
643 zfcp_fsf_close_unit_handler(fsf_req
);
646 case FSF_QTCB_CLOSE_PORT
:
647 zfcp_fsf_close_port_handler(fsf_req
);
650 case FSF_QTCB_CLOSE_PHYSICAL_PORT
:
651 zfcp_fsf_close_physical_port_handler(fsf_req
);
654 case FSF_QTCB_EXCHANGE_CONFIG_DATA
:
655 zfcp_fsf_exchange_config_data_handler(fsf_req
);
658 case FSF_QTCB_EXCHANGE_PORT_DATA
:
659 zfcp_fsf_exchange_port_data_handler(fsf_req
);
662 case FSF_QTCB_SEND_ELS
:
663 zfcp_fsf_send_els_handler(fsf_req
);
666 case FSF_QTCB_DOWNLOAD_CONTROL_FILE
:
667 zfcp_fsf_control_file_handler(fsf_req
);
670 case FSF_QTCB_UPLOAD_CONTROL_FILE
:
671 zfcp_fsf_control_file_handler(fsf_req
);
675 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
676 ZFCP_LOG_NORMAL("bug: Command issued by the device driver is "
677 "not supported by the adapter %s\n",
678 zfcp_get_busid_by_adapter(adapter
));
679 if (fsf_req
->fsf_command
!= fsf_req
->qtcb
->header
.fsf_command
)
681 ("bug: Command issued by the device driver differs "
682 "from the command returned by the adapter %s "
683 "(debug info 0x%x, 0x%x).\n",
684 zfcp_get_busid_by_adapter(adapter
),
685 fsf_req
->fsf_command
,
686 fsf_req
->qtcb
->header
.fsf_command
);
692 zfcp_erp_async_handler(erp_action
, 0);
698 * function: zfcp_fsf_status_read
700 * purpose: initiates a Status Read command at the specified adapter
705 zfcp_fsf_status_read(struct zfcp_adapter
*adapter
, int req_flags
)
707 struct zfcp_fsf_req
*fsf_req
;
708 struct fsf_status_read_buffer
*status_buffer
;
709 unsigned long lock_flags
;
710 volatile struct qdio_buffer_element
*sbale
;
713 /* setup new FSF request */
714 retval
= zfcp_fsf_req_create(adapter
, FSF_QTCB_UNSOLICITED_STATUS
,
715 req_flags
| ZFCP_REQ_NO_QTCB
,
716 adapter
->pool
.fsf_req_status_read
,
717 &lock_flags
, &fsf_req
);
719 ZFCP_LOG_INFO("error: Could not create unsolicited status "
720 "buffer for adapter %s.\n",
721 zfcp_get_busid_by_adapter(adapter
));
722 goto failed_req_create
;
725 sbale
= zfcp_qdio_sbale_req(fsf_req
, fsf_req
->sbal_curr
, 0);
726 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_STATUS
;
727 sbale
[2].flags
|= SBAL_FLAGS_LAST_ENTRY
;
728 fsf_req
->sbale_curr
= 2;
731 mempool_alloc(adapter
->pool
.data_status_read
, GFP_ATOMIC
);
732 if (!status_buffer
) {
733 ZFCP_LOG_NORMAL("bug: could not get some buffer\n");
736 memset(status_buffer
, 0, sizeof (struct fsf_status_read_buffer
));
737 fsf_req
->data
= (unsigned long) status_buffer
;
739 /* insert pointer to respective buffer */
740 sbale
= zfcp_qdio_sbale_curr(fsf_req
);
741 sbale
->addr
= (void *) status_buffer
;
742 sbale
->length
= sizeof(struct fsf_status_read_buffer
);
744 retval
= zfcp_fsf_req_send(fsf_req
);
746 ZFCP_LOG_DEBUG("error: Could not set-up unsolicited status "
748 goto failed_req_send
;
751 ZFCP_LOG_TRACE("Status Read request initiated (adapter%s)\n",
752 zfcp_get_busid_by_adapter(adapter
));
756 mempool_free(status_buffer
, adapter
->pool
.data_status_read
);
759 zfcp_fsf_req_free(fsf_req
);
761 zfcp_hba_dbf_event_fsf_unsol("fail", adapter
, NULL
);
763 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
, lock_flags
);
768 zfcp_fsf_status_read_port_closed(struct zfcp_fsf_req
*fsf_req
)
770 struct fsf_status_read_buffer
*status_buffer
;
771 struct zfcp_adapter
*adapter
;
772 struct zfcp_port
*port
;
775 status_buffer
= (struct fsf_status_read_buffer
*) fsf_req
->data
;
776 adapter
= fsf_req
->adapter
;
778 read_lock_irqsave(&zfcp_data
.config_lock
, flags
);
779 list_for_each_entry(port
, &adapter
->port_list_head
, list
)
780 if (port
->d_id
== (status_buffer
->d_id
& ZFCP_DID_MASK
))
782 read_unlock_irqrestore(&zfcp_data
.config_lock
, flags
);
784 if (!port
|| (port
->d_id
!= (status_buffer
->d_id
& ZFCP_DID_MASK
))) {
785 ZFCP_LOG_NORMAL("bug: Reopen port indication received for "
786 "nonexisting port with d_id 0x%06x on "
787 "adapter %s. Ignored.\n",
788 status_buffer
->d_id
& ZFCP_DID_MASK
,
789 zfcp_get_busid_by_adapter(adapter
));
793 switch (status_buffer
->status_subtype
) {
795 case FSF_STATUS_READ_SUB_CLOSE_PHYS_PORT
:
796 debug_text_event(adapter
->erp_dbf
, 3, "unsol_pc_phys:");
797 zfcp_erp_port_reopen(port
, 0);
800 case FSF_STATUS_READ_SUB_ERROR_PORT
:
801 debug_text_event(adapter
->erp_dbf
, 1, "unsol_pc_err:");
802 zfcp_erp_port_shutdown(port
, 0);
806 debug_text_event(adapter
->erp_dbf
, 0, "unsol_unk_sub:");
807 debug_exception(adapter
->erp_dbf
, 0,
808 &status_buffer
->status_subtype
, sizeof (u32
));
809 ZFCP_LOG_NORMAL("bug: Undefined status subtype received "
810 "for a reopen indication on port with "
811 "d_id 0x%06x on the adapter %s. "
812 "Ignored. (debug info 0x%x)\n",
814 zfcp_get_busid_by_adapter(adapter
),
815 status_buffer
->status_subtype
);
822 * function: zfcp_fsf_status_read_handler
824 * purpose: is called for finished Open Port command
829 zfcp_fsf_status_read_handler(struct zfcp_fsf_req
*fsf_req
)
832 struct zfcp_adapter
*adapter
= fsf_req
->adapter
;
833 struct fsf_status_read_buffer
*status_buffer
=
834 (struct fsf_status_read_buffer
*) fsf_req
->data
;
835 struct fsf_bit_error_payload
*fsf_bit_error
;
837 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_DISMISSED
) {
838 zfcp_hba_dbf_event_fsf_unsol("dism", adapter
, status_buffer
);
839 mempool_free(status_buffer
, adapter
->pool
.data_status_read
);
840 zfcp_fsf_req_free(fsf_req
);
844 zfcp_hba_dbf_event_fsf_unsol("read", adapter
, status_buffer
);
846 switch (status_buffer
->status_type
) {
848 case FSF_STATUS_READ_PORT_CLOSED
:
849 zfcp_fsf_status_read_port_closed(fsf_req
);
852 case FSF_STATUS_READ_INCOMING_ELS
:
853 zfcp_fsf_incoming_els(fsf_req
);
856 case FSF_STATUS_READ_SENSE_DATA_AVAIL
:
857 ZFCP_LOG_INFO("unsolicited sense data received (adapter %s)\n",
858 zfcp_get_busid_by_adapter(adapter
));
861 case FSF_STATUS_READ_BIT_ERROR_THRESHOLD
:
862 fsf_bit_error
= (struct fsf_bit_error_payload
*)
863 status_buffer
->payload
;
864 ZFCP_LOG_NORMAL("Warning: bit error threshold data "
865 "received (adapter %s, "
866 "link failures = %i, loss of sync errors = %i, "
867 "loss of signal errors = %i, "
868 "primitive sequence errors = %i, "
869 "invalid transmission word errors = %i, "
870 "CRC errors = %i)\n",
871 zfcp_get_busid_by_adapter(adapter
),
872 fsf_bit_error
->link_failure_error_count
,
873 fsf_bit_error
->loss_of_sync_error_count
,
874 fsf_bit_error
->loss_of_signal_error_count
,
875 fsf_bit_error
->primitive_sequence_error_count
,
876 fsf_bit_error
->invalid_transmission_word_error_count
,
877 fsf_bit_error
->crc_error_count
);
878 ZFCP_LOG_INFO("Additional bit error threshold data "
880 "primitive sequence event time-outs = %i, "
881 "elastic buffer overrun errors = %i, "
882 "advertised receive buffer-to-buffer credit = %i, "
883 "current receice buffer-to-buffer credit = %i, "
884 "advertised transmit buffer-to-buffer credit = %i, "
885 "current transmit buffer-to-buffer credit = %i)\n",
886 zfcp_get_busid_by_adapter(adapter
),
887 fsf_bit_error
->primitive_sequence_event_timeout_count
,
888 fsf_bit_error
->elastic_buffer_overrun_error_count
,
889 fsf_bit_error
->advertised_receive_b2b_credit
,
890 fsf_bit_error
->current_receive_b2b_credit
,
891 fsf_bit_error
->advertised_transmit_b2b_credit
,
892 fsf_bit_error
->current_transmit_b2b_credit
);
895 case FSF_STATUS_READ_LINK_DOWN
:
896 switch (status_buffer
->status_subtype
) {
897 case FSF_STATUS_READ_SUB_NO_PHYSICAL_LINK
:
898 ZFCP_LOG_INFO("Physical link to adapter %s is down\n",
899 zfcp_get_busid_by_adapter(adapter
));
900 zfcp_fsf_link_down_info_eval(adapter
,
901 (struct fsf_link_down_info
*)
902 &status_buffer
->payload
);
904 case FSF_STATUS_READ_SUB_FDISC_FAILED
:
905 ZFCP_LOG_INFO("Local link to adapter %s is down "
906 "due to failed FDISC login\n",
907 zfcp_get_busid_by_adapter(adapter
));
908 zfcp_fsf_link_down_info_eval(adapter
,
909 (struct fsf_link_down_info
*)
910 &status_buffer
->payload
);
912 case FSF_STATUS_READ_SUB_FIRMWARE_UPDATE
:
913 ZFCP_LOG_INFO("Local link to adapter %s is down "
914 "due to firmware update on adapter\n",
915 zfcp_get_busid_by_adapter(adapter
));
916 zfcp_fsf_link_down_info_eval(adapter
, NULL
);
919 ZFCP_LOG_INFO("Local link to adapter %s is down "
920 "due to unknown reason\n",
921 zfcp_get_busid_by_adapter(adapter
));
922 zfcp_fsf_link_down_info_eval(adapter
, NULL
);
926 case FSF_STATUS_READ_LINK_UP
:
927 ZFCP_LOG_NORMAL("Local link to adapter %s was replugged. "
928 "Restarting operations on this adapter\n",
929 zfcp_get_busid_by_adapter(adapter
));
930 /* All ports should be marked as ready to run again */
931 zfcp_erp_modify_adapter_status(adapter
,
932 ZFCP_STATUS_COMMON_RUNNING
,
934 zfcp_erp_adapter_reopen(adapter
,
935 ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED
936 | ZFCP_STATUS_COMMON_ERP_FAILED
);
939 case FSF_STATUS_READ_NOTIFICATION_LOST
:
940 ZFCP_LOG_NORMAL("Unsolicited status notification(s) lost: "
941 "adapter %s%s%s%s%s%s%s%s%s\n",
942 zfcp_get_busid_by_adapter(adapter
),
943 (status_buffer
->status_subtype
&
944 FSF_STATUS_READ_SUB_INCOMING_ELS
) ?
945 ", incoming ELS" : "",
946 (status_buffer
->status_subtype
&
947 FSF_STATUS_READ_SUB_SENSE_DATA
) ?
949 (status_buffer
->status_subtype
&
950 FSF_STATUS_READ_SUB_LINK_STATUS
) ?
951 ", link status change" : "",
952 (status_buffer
->status_subtype
&
953 FSF_STATUS_READ_SUB_PORT_CLOSED
) ?
955 (status_buffer
->status_subtype
&
956 FSF_STATUS_READ_SUB_BIT_ERROR_THRESHOLD
) ?
957 ", bit error exception" : "",
958 (status_buffer
->status_subtype
&
959 FSF_STATUS_READ_SUB_ACT_UPDATED
) ?
961 (status_buffer
->status_subtype
&
962 FSF_STATUS_READ_SUB_ACT_HARDENED
) ?
963 ", ACT hardening" : "",
964 (status_buffer
->status_subtype
&
965 FSF_STATUS_READ_SUB_FEATURE_UPDATE_ALERT
) ?
966 ", adapter feature change" : "");
968 if (status_buffer
->status_subtype
&
969 FSF_STATUS_READ_SUB_ACT_UPDATED
)
970 zfcp_erp_adapter_access_changed(adapter
);
973 case FSF_STATUS_READ_CFDC_UPDATED
:
974 ZFCP_LOG_NORMAL("CFDC has been updated on the adapter %s\n",
975 zfcp_get_busid_by_adapter(adapter
));
976 zfcp_erp_adapter_access_changed(adapter
);
979 case FSF_STATUS_READ_CFDC_HARDENED
:
980 switch (status_buffer
->status_subtype
) {
981 case FSF_STATUS_READ_SUB_CFDC_HARDENED_ON_SE
:
982 ZFCP_LOG_NORMAL("CFDC of adapter %s saved on SE\n",
983 zfcp_get_busid_by_adapter(adapter
));
985 case FSF_STATUS_READ_SUB_CFDC_HARDENED_ON_SE2
:
986 ZFCP_LOG_NORMAL("CFDC of adapter %s has been copied "
987 "to the secondary SE\n",
988 zfcp_get_busid_by_adapter(adapter
));
991 ZFCP_LOG_NORMAL("CFDC of adapter %s has been hardened\n",
992 zfcp_get_busid_by_adapter(adapter
));
996 case FSF_STATUS_READ_FEATURE_UPDATE_ALERT
:
997 debug_text_event(adapter
->erp_dbf
, 2, "unsol_features:");
998 ZFCP_LOG_INFO("List of supported features on adapter %s has "
999 "been changed from 0x%08X to 0x%08X\n",
1000 zfcp_get_busid_by_adapter(adapter
),
1001 *(u32
*) (status_buffer
->payload
+ 4),
1002 *(u32
*) (status_buffer
->payload
));
1003 adapter
->adapter_features
= *(u32
*) status_buffer
->payload
;
1007 ZFCP_LOG_NORMAL("warning: An unsolicited status packet of unknown "
1008 "type was received (debug info 0x%x)\n",
1009 status_buffer
->status_type
);
1010 ZFCP_LOG_DEBUG("Dump of status_read_buffer %p:\n",
1012 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
1013 (char *) status_buffer
,
1014 sizeof (struct fsf_status_read_buffer
));
1017 mempool_free(status_buffer
, adapter
->pool
.data_status_read
);
1018 zfcp_fsf_req_free(fsf_req
);
1020 * recycle buffer and start new request repeat until outbound
1021 * queue is empty or adapter shutdown is requested
1025 * we may wait in the req_create for 5s during shutdown, so
1026 * qdio_cleanup will have to wait at least that long before returning
1027 * with failure to allow us a proper cleanup under all circumstances
1031 * allocation failure possible? (Is this code needed?)
1033 retval
= zfcp_fsf_status_read(adapter
, 0);
1035 ZFCP_LOG_INFO("Failed to create unsolicited status read "
1036 "request for the adapter %s.\n",
1037 zfcp_get_busid_by_adapter(adapter
));
1038 /* temporary fix to avoid status read buffer shortage */
1039 adapter
->status_read_failed
++;
1040 if ((ZFCP_STATUS_READS_RECOM
- adapter
->status_read_failed
)
1041 < ZFCP_STATUS_READ_FAILED_THRESHOLD
) {
1042 ZFCP_LOG_INFO("restart adapter %s due to status read "
1043 "buffer shortage\n",
1044 zfcp_get_busid_by_adapter(adapter
));
1045 zfcp_erp_adapter_reopen(adapter
, 0);
1053 * function: zfcp_fsf_abort_fcp_command
1055 * purpose: tells FSF to abort a running SCSI command
1057 * returns: address of initiated FSF request
1058 * NULL - request could not be initiated
1060 * FIXME(design): should be watched by a timeout !!!
1061 * FIXME(design) shouldn't this be modified to return an int
1062 * also...don't know how though
1064 struct zfcp_fsf_req
*
1065 zfcp_fsf_abort_fcp_command(unsigned long old_req_id
,
1066 struct zfcp_adapter
*adapter
,
1067 struct zfcp_unit
*unit
, int req_flags
)
1069 volatile struct qdio_buffer_element
*sbale
;
1070 struct zfcp_fsf_req
*fsf_req
= NULL
;
1071 unsigned long lock_flags
;
1074 /* setup new FSF request */
1075 retval
= zfcp_fsf_req_create(adapter
, FSF_QTCB_ABORT_FCP_CMND
,
1076 req_flags
, adapter
->pool
.fsf_req_abort
,
1077 &lock_flags
, &fsf_req
);
1079 ZFCP_LOG_INFO("error: Failed to create an abort command "
1080 "request for lun 0x%016Lx on port 0x%016Lx "
1084 zfcp_get_busid_by_adapter(adapter
));
1088 if (unlikely(!atomic_test_mask(ZFCP_STATUS_COMMON_UNBLOCKED
,
1092 sbale
= zfcp_qdio_sbale_req(fsf_req
, fsf_req
->sbal_curr
, 0);
1093 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_READ
;
1094 sbale
[1].flags
|= SBAL_FLAGS_LAST_ENTRY
;
1096 fsf_req
->data
= (unsigned long) unit
;
1098 /* set handles of unit and its parent port in QTCB */
1099 fsf_req
->qtcb
->header
.lun_handle
= unit
->handle
;
1100 fsf_req
->qtcb
->header
.port_handle
= unit
->port
->handle
;
1102 /* set handle of request which should be aborted */
1103 fsf_req
->qtcb
->bottom
.support
.req_handle
= (u64
) old_req_id
;
1105 zfcp_fsf_start_timer(fsf_req
, ZFCP_SCSI_ER_TIMEOUT
);
1106 retval
= zfcp_fsf_req_send(fsf_req
);
1111 zfcp_fsf_req_free(fsf_req
);
1115 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
, lock_flags
);
1120 * function: zfcp_fsf_abort_fcp_command_handler
1122 * purpose: is called for finished Abort FCP Command request
1127 zfcp_fsf_abort_fcp_command_handler(struct zfcp_fsf_req
*new_fsf_req
)
1129 int retval
= -EINVAL
;
1130 struct zfcp_unit
*unit
;
1131 union fsf_status_qual
*fsf_stat_qual
=
1132 &new_fsf_req
->qtcb
->header
.fsf_status_qual
;
1134 if (new_fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
) {
1135 /* do not set ZFCP_STATUS_FSFREQ_ABORTSUCCEEDED */
1136 goto skip_fsfstatus
;
1139 unit
= (struct zfcp_unit
*) new_fsf_req
->data
;
1141 /* evaluate FSF status in QTCB */
1142 switch (new_fsf_req
->qtcb
->header
.fsf_status
) {
1144 case FSF_PORT_HANDLE_NOT_VALID
:
1145 if (fsf_stat_qual
->word
[0] != fsf_stat_qual
->word
[1]) {
1146 debug_text_event(new_fsf_req
->adapter
->erp_dbf
, 3,
1149 * In this case a command that was sent prior to a port
1150 * reopen was aborted (handles are different). This is
1154 ZFCP_LOG_INFO("Temporary port identifier 0x%x for "
1155 "port 0x%016Lx on adapter %s invalid. "
1156 "This may happen occasionally.\n",
1159 zfcp_get_busid_by_unit(unit
));
1160 ZFCP_LOG_INFO("status qualifier:\n");
1161 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_INFO
,
1162 (char *) &new_fsf_req
->qtcb
->header
.
1164 sizeof (union fsf_status_qual
));
1165 /* Let's hope this sorts out the mess */
1166 debug_text_event(new_fsf_req
->adapter
->erp_dbf
, 1,
1168 zfcp_erp_adapter_reopen(unit
->port
->adapter
, 0);
1169 new_fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1173 case FSF_LUN_HANDLE_NOT_VALID
:
1174 if (fsf_stat_qual
->word
[0] != fsf_stat_qual
->word
[1]) {
1175 debug_text_event(new_fsf_req
->adapter
->erp_dbf
, 3,
1178 * In this case a command that was sent prior to a unit
1179 * reopen was aborted (handles are different).
1184 ("Warning: Temporary LUN identifier 0x%x of LUN "
1185 "0x%016Lx on port 0x%016Lx on adapter %s is "
1186 "invalid. This may happen in rare cases. "
1187 "Trying to re-establish link.\n",
1191 zfcp_get_busid_by_unit(unit
));
1192 ZFCP_LOG_DEBUG("Status qualifier data:\n");
1193 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
1194 (char *) &new_fsf_req
->qtcb
->header
.
1196 sizeof (union fsf_status_qual
));
1197 /* Let's hope this sorts out the mess */
1198 debug_text_event(new_fsf_req
->adapter
->erp_dbf
, 1,
1200 zfcp_erp_port_reopen(unit
->port
, 0);
1201 new_fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1205 case FSF_FCP_COMMAND_DOES_NOT_EXIST
:
1207 debug_text_event(new_fsf_req
->adapter
->erp_dbf
, 3,
1209 new_fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ABORTNOTNEEDED
;
1212 case FSF_PORT_BOXED
:
1213 ZFCP_LOG_INFO("Remote port 0x%016Lx on adapter %s needs to "
1214 "be reopened\n", unit
->port
->wwpn
,
1215 zfcp_get_busid_by_unit(unit
));
1216 debug_text_event(new_fsf_req
->adapter
->erp_dbf
, 2,
1218 zfcp_erp_port_boxed(unit
->port
);
1219 new_fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
1220 | ZFCP_STATUS_FSFREQ_RETRY
;
1225 "unit 0x%016Lx on port 0x%016Lx on adapter %s needs "
1227 unit
->fcp_lun
, unit
->port
->wwpn
,
1228 zfcp_get_busid_by_unit(unit
));
1229 debug_text_event(new_fsf_req
->adapter
->erp_dbf
, 1, "fsf_s_lboxed");
1230 zfcp_erp_unit_boxed(unit
);
1231 new_fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
1232 | ZFCP_STATUS_FSFREQ_RETRY
;
1235 case FSF_ADAPTER_STATUS_AVAILABLE
:
1236 switch (new_fsf_req
->qtcb
->header
.fsf_status_qual
.word
[0]) {
1237 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE
:
1238 debug_text_event(new_fsf_req
->adapter
->erp_dbf
, 1,
1240 zfcp_test_link(unit
->port
);
1241 new_fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1243 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED
:
1244 /* SCSI stack will escalate */
1245 debug_text_event(new_fsf_req
->adapter
->erp_dbf
, 1,
1247 new_fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1251 ("bug: Wrong status qualifier 0x%x arrived.\n",
1252 new_fsf_req
->qtcb
->header
.fsf_status_qual
.word
[0]);
1253 debug_text_event(new_fsf_req
->adapter
->erp_dbf
, 0,
1255 debug_exception(new_fsf_req
->adapter
->erp_dbf
, 0,
1256 &new_fsf_req
->qtcb
->header
.
1257 fsf_status_qual
.word
[0], sizeof (u32
));
1264 new_fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ABORTSUCCEEDED
;
1268 ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
1269 "(debug info 0x%x)\n",
1270 new_fsf_req
->qtcb
->header
.fsf_status
);
1271 debug_text_event(new_fsf_req
->adapter
->erp_dbf
, 0,
1273 debug_exception(new_fsf_req
->adapter
->erp_dbf
, 0,
1274 &new_fsf_req
->qtcb
->header
.fsf_status
,
1283 * zfcp_use_one_sbal - checks whether req buffer and resp bother each fit into
1285 * Two scatter-gather lists are passed, one for the reqeust and one for the
1289 zfcp_use_one_sbal(struct scatterlist
*req
, int req_count
,
1290 struct scatterlist
*resp
, int resp_count
)
1292 return ((req_count
== 1) &&
1293 (resp_count
== 1) &&
1294 (((unsigned long) zfcp_sg_to_address(&req
[0]) &
1296 ((unsigned long) (zfcp_sg_to_address(&req
[0]) +
1297 req
[0].length
- 1) & PAGE_MASK
)) &&
1298 (((unsigned long) zfcp_sg_to_address(&resp
[0]) &
1300 ((unsigned long) (zfcp_sg_to_address(&resp
[0]) +
1301 resp
[0].length
- 1) & PAGE_MASK
)));
1305 * zfcp_fsf_send_ct - initiate a Generic Service request (FC-GS)
1306 * @ct: pointer to struct zfcp_send_ct which conatins all needed data for
1308 * @pool: pointer to memory pool, if non-null this pool is used to allocate
1309 * a struct zfcp_fsf_req
1310 * @erp_action: pointer to erp_action, if non-null the Generic Service request
1311 * is sent within error recovery
1314 zfcp_fsf_send_ct(struct zfcp_send_ct
*ct
, mempool_t
*pool
,
1315 struct zfcp_erp_action
*erp_action
)
1317 volatile struct qdio_buffer_element
*sbale
;
1318 struct zfcp_port
*port
;
1319 struct zfcp_adapter
*adapter
;
1320 struct zfcp_fsf_req
*fsf_req
;
1321 unsigned long lock_flags
;
1326 adapter
= port
->adapter
;
1328 ret
= zfcp_fsf_req_create(adapter
, FSF_QTCB_SEND_GENERIC
,
1329 ZFCP_WAIT_FOR_SBAL
| ZFCP_REQ_AUTO_CLEANUP
,
1330 pool
, &lock_flags
, &fsf_req
);
1332 ZFCP_LOG_INFO("error: Could not create CT request (FC-GS) for "
1334 zfcp_get_busid_by_adapter(adapter
));
1338 sbale
= zfcp_qdio_sbale_req(fsf_req
, fsf_req
->sbal_curr
, 0);
1339 if (zfcp_use_one_sbal(ct
->req
, ct
->req_count
,
1340 ct
->resp
, ct
->resp_count
)){
1341 /* both request buffer and response buffer
1342 fit into one sbale each */
1343 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_WRITE_READ
;
1344 sbale
[2].addr
= zfcp_sg_to_address(&ct
->req
[0]);
1345 sbale
[2].length
= ct
->req
[0].length
;
1346 sbale
[3].addr
= zfcp_sg_to_address(&ct
->resp
[0]);
1347 sbale
[3].length
= ct
->resp
[0].length
;
1348 sbale
[3].flags
|= SBAL_FLAGS_LAST_ENTRY
;
1349 } else if (adapter
->adapter_features
&
1350 FSF_FEATURE_ELS_CT_CHAINED_SBALS
) {
1351 /* try to use chained SBALs */
1352 bytes
= zfcp_qdio_sbals_from_sg(fsf_req
,
1353 SBAL_FLAGS0_TYPE_WRITE_READ
,
1354 ct
->req
, ct
->req_count
,
1355 ZFCP_MAX_SBALS_PER_CT_REQ
);
1357 ZFCP_LOG_INFO("error: creation of CT request failed "
1359 zfcp_get_busid_by_adapter(adapter
));
1367 fsf_req
->qtcb
->bottom
.support
.req_buf_length
= bytes
;
1368 fsf_req
->sbale_curr
= ZFCP_LAST_SBALE_PER_SBAL
;
1369 bytes
= zfcp_qdio_sbals_from_sg(fsf_req
,
1370 SBAL_FLAGS0_TYPE_WRITE_READ
,
1371 ct
->resp
, ct
->resp_count
,
1372 ZFCP_MAX_SBALS_PER_CT_REQ
);
1374 ZFCP_LOG_INFO("error: creation of CT request failed "
1376 zfcp_get_busid_by_adapter(adapter
));
1384 fsf_req
->qtcb
->bottom
.support
.resp_buf_length
= bytes
;
1386 /* reject send generic request */
1388 "error: microcode does not support chained SBALs,"
1389 "CT request too big (adapter %s)\n",
1390 zfcp_get_busid_by_adapter(adapter
));
1395 /* settings in QTCB */
1396 fsf_req
->qtcb
->header
.port_handle
= port
->handle
;
1397 fsf_req
->qtcb
->bottom
.support
.service_class
=
1398 ZFCP_FC_SERVICE_CLASS_DEFAULT
;
1399 fsf_req
->qtcb
->bottom
.support
.timeout
= ct
->timeout
;
1400 fsf_req
->data
= (unsigned long) ct
;
1402 zfcp_san_dbf_event_ct_request(fsf_req
);
1405 erp_action
->fsf_req
= fsf_req
;
1406 fsf_req
->erp_action
= erp_action
;
1407 zfcp_erp_start_timer(fsf_req
);
1409 zfcp_fsf_start_timer(fsf_req
, ZFCP_FSF_REQUEST_TIMEOUT
);
1411 ret
= zfcp_fsf_req_send(fsf_req
);
1413 ZFCP_LOG_DEBUG("error: initiation of CT request failed "
1414 "(adapter %s, port 0x%016Lx)\n",
1415 zfcp_get_busid_by_adapter(adapter
), port
->wwpn
);
1419 ZFCP_LOG_DEBUG("CT request initiated (adapter %s, port 0x%016Lx)\n",
1420 zfcp_get_busid_by_adapter(adapter
), port
->wwpn
);
1424 zfcp_fsf_req_free(fsf_req
);
1425 if (erp_action
!= NULL
) {
1426 erp_action
->fsf_req
= NULL
;
1430 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
,
1436 * zfcp_fsf_send_ct_handler - handler for Generic Service requests
1437 * @fsf_req: pointer to struct zfcp_fsf_req
1439 * Data specific for the Generic Service request is passed using
1440 * fsf_req->data. There we find the pointer to struct zfcp_send_ct.
1441 * Usually a specific handler for the CT request is called which is
1442 * found in this structure.
1445 zfcp_fsf_send_ct_handler(struct zfcp_fsf_req
*fsf_req
)
1447 struct zfcp_port
*port
;
1448 struct zfcp_adapter
*adapter
;
1449 struct zfcp_send_ct
*send_ct
;
1450 struct fsf_qtcb_header
*header
;
1451 struct fsf_qtcb_bottom_support
*bottom
;
1452 int retval
= -EINVAL
;
1453 u16 subtable
, rule
, counter
;
1455 adapter
= fsf_req
->adapter
;
1456 send_ct
= (struct zfcp_send_ct
*) fsf_req
->data
;
1457 port
= send_ct
->port
;
1458 header
= &fsf_req
->qtcb
->header
;
1459 bottom
= &fsf_req
->qtcb
->bottom
.support
;
1461 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
)
1462 goto skip_fsfstatus
;
1464 /* evaluate FSF status in QTCB */
1465 switch (header
->fsf_status
) {
1468 zfcp_san_dbf_event_ct_response(fsf_req
);
1472 case FSF_SERVICE_CLASS_NOT_SUPPORTED
:
1473 ZFCP_LOG_INFO("error: adapter %s does not support fc "
1475 zfcp_get_busid_by_port(port
),
1476 ZFCP_FC_SERVICE_CLASS_DEFAULT
);
1477 /* stop operation for this adapter */
1478 debug_text_exception(adapter
->erp_dbf
, 0, "fsf_s_class_nsup");
1479 zfcp_erp_adapter_shutdown(adapter
, 0);
1480 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1483 case FSF_ADAPTER_STATUS_AVAILABLE
:
1484 switch (header
->fsf_status_qual
.word
[0]){
1485 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE
:
1486 /* reopening link to port */
1487 debug_text_event(adapter
->erp_dbf
, 1, "fsf_sq_ltest");
1488 zfcp_test_link(port
);
1489 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1491 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED
:
1492 /* ERP strategy will escalate */
1493 debug_text_event(adapter
->erp_dbf
, 1, "fsf_sq_ulp");
1494 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1497 ZFCP_LOG_INFO("bug: Wrong status qualifier 0x%x "
1499 header
->fsf_status_qual
.word
[0]);
1504 case FSF_ACCESS_DENIED
:
1505 ZFCP_LOG_NORMAL("access denied, cannot send generic service "
1506 "command (adapter %s, port d_id=0x%06x)\n",
1507 zfcp_get_busid_by_port(port
), port
->d_id
);
1508 for (counter
= 0; counter
< 2; counter
++) {
1509 subtable
= header
->fsf_status_qual
.halfword
[counter
* 2];
1510 rule
= header
->fsf_status_qual
.halfword
[counter
* 2 + 1];
1512 case FSF_SQ_CFDC_SUBTABLE_OS
:
1513 case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN
:
1514 case FSF_SQ_CFDC_SUBTABLE_PORT_DID
:
1515 case FSF_SQ_CFDC_SUBTABLE_LUN
:
1516 ZFCP_LOG_INFO("Access denied (%s rule %d)\n",
1517 zfcp_act_subtable_type
[subtable
], rule
);
1521 debug_text_event(adapter
->erp_dbf
, 1, "fsf_s_access");
1522 zfcp_erp_port_access_denied(port
);
1523 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1526 case FSF_GENERIC_COMMAND_REJECTED
:
1527 ZFCP_LOG_INFO("generic service command rejected "
1528 "(adapter %s, port d_id=0x%06x)\n",
1529 zfcp_get_busid_by_port(port
), port
->d_id
);
1530 ZFCP_LOG_INFO("status qualifier:\n");
1531 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_INFO
,
1532 (char *) &header
->fsf_status_qual
,
1533 sizeof (union fsf_status_qual
));
1534 debug_text_event(adapter
->erp_dbf
, 1, "fsf_s_gcom_rej");
1535 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1538 case FSF_PORT_HANDLE_NOT_VALID
:
1539 ZFCP_LOG_DEBUG("Temporary port identifier 0x%x for port "
1540 "0x%016Lx on adapter %s invalid. This may "
1541 "happen occasionally.\n", port
->handle
,
1542 port
->wwpn
, zfcp_get_busid_by_port(port
));
1543 ZFCP_LOG_INFO("status qualifier:\n");
1544 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_INFO
,
1545 (char *) &header
->fsf_status_qual
,
1546 sizeof (union fsf_status_qual
));
1547 debug_text_event(adapter
->erp_dbf
, 1, "fsf_s_phandle_nv");
1548 zfcp_erp_adapter_reopen(adapter
, 0);
1549 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1552 case FSF_PORT_BOXED
:
1553 ZFCP_LOG_INFO("port needs to be reopened "
1554 "(adapter %s, port d_id=0x%06x)\n",
1555 zfcp_get_busid_by_port(port
), port
->d_id
);
1556 debug_text_event(adapter
->erp_dbf
, 2, "fsf_s_pboxed");
1557 zfcp_erp_port_boxed(port
);
1558 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
1559 | ZFCP_STATUS_FSFREQ_RETRY
;
1562 /* following states should never occure, all cases avoided
1563 in zfcp_fsf_send_ct - but who knows ... */
1564 case FSF_PAYLOAD_SIZE_MISMATCH
:
1565 ZFCP_LOG_INFO("payload size mismatch (adapter: %s, "
1566 "req_buf_length=%d, resp_buf_length=%d)\n",
1567 zfcp_get_busid_by_adapter(adapter
),
1568 bottom
->req_buf_length
, bottom
->resp_buf_length
);
1569 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1571 case FSF_REQUEST_SIZE_TOO_LARGE
:
1572 ZFCP_LOG_INFO("request size too large (adapter: %s, "
1573 "req_buf_length=%d)\n",
1574 zfcp_get_busid_by_adapter(adapter
),
1575 bottom
->req_buf_length
);
1576 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1578 case FSF_RESPONSE_SIZE_TOO_LARGE
:
1579 ZFCP_LOG_INFO("response size too large (adapter: %s, "
1580 "resp_buf_length=%d)\n",
1581 zfcp_get_busid_by_adapter(adapter
),
1582 bottom
->resp_buf_length
);
1583 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1585 case FSF_SBAL_MISMATCH
:
1586 ZFCP_LOG_INFO("SBAL mismatch (adapter: %s, req_buf_length=%d, "
1587 "resp_buf_length=%d)\n",
1588 zfcp_get_busid_by_adapter(adapter
),
1589 bottom
->req_buf_length
, bottom
->resp_buf_length
);
1590 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1594 ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
1595 "(debug info 0x%x)\n", header
->fsf_status
);
1596 debug_text_event(adapter
->erp_dbf
, 0, "fsf_sq_inval:");
1597 debug_exception(adapter
->erp_dbf
, 0,
1598 &header
->fsf_status_qual
.word
[0], sizeof (u32
));
1603 send_ct
->status
= retval
;
1605 if (send_ct
->handler
!= NULL
)
1606 send_ct
->handler(send_ct
->handler_data
);
1612 * zfcp_fsf_send_els - initiate an ELS command (FC-FS)
1613 * @els: pointer to struct zfcp_send_els which contains all needed data for
1617 zfcp_fsf_send_els(struct zfcp_send_els
*els
)
1619 volatile struct qdio_buffer_element
*sbale
;
1620 struct zfcp_fsf_req
*fsf_req
;
1622 struct zfcp_adapter
*adapter
;
1623 unsigned long lock_flags
;
1628 adapter
= els
->adapter
;
1630 ret
= zfcp_fsf_req_create(adapter
, FSF_QTCB_SEND_ELS
,
1631 ZFCP_REQ_AUTO_CLEANUP
,
1632 NULL
, &lock_flags
, &fsf_req
);
1634 ZFCP_LOG_INFO("error: creation of ELS request failed "
1635 "(adapter %s, port d_id: 0x%06x)\n",
1636 zfcp_get_busid_by_adapter(adapter
), d_id
);
1640 if (unlikely(!atomic_test_mask(ZFCP_STATUS_COMMON_UNBLOCKED
,
1641 &els
->port
->status
))) {
1646 sbale
= zfcp_qdio_sbale_req(fsf_req
, fsf_req
->sbal_curr
, 0);
1647 if (zfcp_use_one_sbal(els
->req
, els
->req_count
,
1648 els
->resp
, els
->resp_count
)){
1649 /* both request buffer and response buffer
1650 fit into one sbale each */
1651 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_WRITE_READ
;
1652 sbale
[2].addr
= zfcp_sg_to_address(&els
->req
[0]);
1653 sbale
[2].length
= els
->req
[0].length
;
1654 sbale
[3].addr
= zfcp_sg_to_address(&els
->resp
[0]);
1655 sbale
[3].length
= els
->resp
[0].length
;
1656 sbale
[3].flags
|= SBAL_FLAGS_LAST_ENTRY
;
1657 } else if (adapter
->adapter_features
&
1658 FSF_FEATURE_ELS_CT_CHAINED_SBALS
) {
1659 /* try to use chained SBALs */
1660 bytes
= zfcp_qdio_sbals_from_sg(fsf_req
,
1661 SBAL_FLAGS0_TYPE_WRITE_READ
,
1662 els
->req
, els
->req_count
,
1663 ZFCP_MAX_SBALS_PER_ELS_REQ
);
1665 ZFCP_LOG_INFO("error: creation of ELS request failed "
1666 "(adapter %s, port d_id: 0x%06x)\n",
1667 zfcp_get_busid_by_adapter(adapter
), d_id
);
1675 fsf_req
->qtcb
->bottom
.support
.req_buf_length
= bytes
;
1676 fsf_req
->sbale_curr
= ZFCP_LAST_SBALE_PER_SBAL
;
1677 bytes
= zfcp_qdio_sbals_from_sg(fsf_req
,
1678 SBAL_FLAGS0_TYPE_WRITE_READ
,
1679 els
->resp
, els
->resp_count
,
1680 ZFCP_MAX_SBALS_PER_ELS_REQ
);
1682 ZFCP_LOG_INFO("error: creation of ELS request failed "
1683 "(adapter %s, port d_id: 0x%06x)\n",
1684 zfcp_get_busid_by_adapter(adapter
), d_id
);
1692 fsf_req
->qtcb
->bottom
.support
.resp_buf_length
= bytes
;
1694 /* reject request */
1695 ZFCP_LOG_INFO("error: microcode does not support chained SBALs"
1696 ", ELS request too big (adapter %s, "
1697 "port d_id: 0x%06x)\n",
1698 zfcp_get_busid_by_adapter(adapter
), d_id
);
1703 /* settings in QTCB */
1704 fsf_req
->qtcb
->bottom
.support
.d_id
= d_id
;
1705 fsf_req
->qtcb
->bottom
.support
.service_class
=
1706 ZFCP_FC_SERVICE_CLASS_DEFAULT
;
1707 fsf_req
->qtcb
->bottom
.support
.timeout
= ZFCP_ELS_TIMEOUT
;
1708 fsf_req
->data
= (unsigned long) els
;
1710 sbale
= zfcp_qdio_sbale_req(fsf_req
, fsf_req
->sbal_curr
, 0);
1712 zfcp_san_dbf_event_els_request(fsf_req
);
1714 zfcp_fsf_start_timer(fsf_req
, ZFCP_FSF_REQUEST_TIMEOUT
);
1715 ret
= zfcp_fsf_req_send(fsf_req
);
1717 ZFCP_LOG_DEBUG("error: initiation of ELS request failed "
1718 "(adapter %s, port d_id: 0x%06x)\n",
1719 zfcp_get_busid_by_adapter(adapter
), d_id
);
1723 ZFCP_LOG_DEBUG("ELS request initiated (adapter %s, port d_id: "
1724 "0x%06x)\n", zfcp_get_busid_by_adapter(adapter
), d_id
);
1729 zfcp_fsf_req_free(fsf_req
);
1733 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
,
1740 * zfcp_fsf_send_els_handler - handler for ELS commands
1741 * @fsf_req: pointer to struct zfcp_fsf_req
1743 * Data specific for the ELS command is passed using
1744 * fsf_req->data. There we find the pointer to struct zfcp_send_els.
1745 * Usually a specific handler for the ELS command is called which is
1746 * found in this structure.
1748 static int zfcp_fsf_send_els_handler(struct zfcp_fsf_req
*fsf_req
)
1750 struct zfcp_adapter
*adapter
;
1751 struct zfcp_port
*port
;
1753 struct fsf_qtcb_header
*header
;
1754 struct fsf_qtcb_bottom_support
*bottom
;
1755 struct zfcp_send_els
*send_els
;
1756 int retval
= -EINVAL
;
1757 u16 subtable
, rule
, counter
;
1759 send_els
= (struct zfcp_send_els
*) fsf_req
->data
;
1760 adapter
= send_els
->adapter
;
1761 port
= send_els
->port
;
1762 d_id
= send_els
->d_id
;
1763 header
= &fsf_req
->qtcb
->header
;
1764 bottom
= &fsf_req
->qtcb
->bottom
.support
;
1766 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
)
1767 goto skip_fsfstatus
;
1769 switch (header
->fsf_status
) {
1772 zfcp_san_dbf_event_els_response(fsf_req
);
1776 case FSF_SERVICE_CLASS_NOT_SUPPORTED
:
1777 ZFCP_LOG_INFO("error: adapter %s does not support fc "
1779 zfcp_get_busid_by_adapter(adapter
),
1780 ZFCP_FC_SERVICE_CLASS_DEFAULT
);
1781 /* stop operation for this adapter */
1782 debug_text_exception(adapter
->erp_dbf
, 0, "fsf_s_class_nsup");
1783 zfcp_erp_adapter_shutdown(adapter
, 0);
1784 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1787 case FSF_ADAPTER_STATUS_AVAILABLE
:
1788 switch (header
->fsf_status_qual
.word
[0]){
1789 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE
:
1790 debug_text_event(adapter
->erp_dbf
, 1, "fsf_sq_ltest");
1791 if (port
&& (send_els
->ls_code
!= ZFCP_LS_ADISC
))
1792 zfcp_test_link(port
);
1793 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1795 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED
:
1796 debug_text_event(adapter
->erp_dbf
, 1, "fsf_sq_ulp");
1797 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1799 zfcp_handle_els_rjt(header
->fsf_status_qual
.word
[1],
1800 (struct zfcp_ls_rjt_par
*)
1801 &header
->fsf_status_qual
.word
[2]);
1803 case FSF_SQ_RETRY_IF_POSSIBLE
:
1804 debug_text_event(adapter
->erp_dbf
, 1, "fsf_sq_retry");
1805 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1808 ZFCP_LOG_INFO("bug: Wrong status qualifier 0x%x\n",
1809 header
->fsf_status_qual
.word
[0]);
1810 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_INFO
,
1811 (char*)header
->fsf_status_qual
.word
, 16);
1815 case FSF_ELS_COMMAND_REJECTED
:
1816 ZFCP_LOG_INFO("ELS has been rejected because command filter "
1817 "prohibited sending "
1818 "(adapter: %s, port d_id: 0x%06x)\n",
1819 zfcp_get_busid_by_adapter(adapter
), d_id
);
1823 case FSF_PAYLOAD_SIZE_MISMATCH
:
1825 "ELS request size and ELS response size must be either "
1826 "both 0, or both greater than 0 "
1827 "(adapter: %s, req_buf_length=%d resp_buf_length=%d)\n",
1828 zfcp_get_busid_by_adapter(adapter
),
1829 bottom
->req_buf_length
,
1830 bottom
->resp_buf_length
);
1833 case FSF_REQUEST_SIZE_TOO_LARGE
:
1835 "Length of the ELS request buffer, "
1836 "specified in QTCB bottom, "
1837 "exceeds the size of the buffers "
1838 "that have been allocated for ELS request data "
1839 "(adapter: %s, req_buf_length=%d)\n",
1840 zfcp_get_busid_by_adapter(adapter
),
1841 bottom
->req_buf_length
);
1844 case FSF_RESPONSE_SIZE_TOO_LARGE
:
1846 "Length of the ELS response buffer, "
1847 "specified in QTCB bottom, "
1848 "exceeds the size of the buffers "
1849 "that have been allocated for ELS response data "
1850 "(adapter: %s, resp_buf_length=%d)\n",
1851 zfcp_get_busid_by_adapter(adapter
),
1852 bottom
->resp_buf_length
);
1855 case FSF_SBAL_MISMATCH
:
1856 /* should never occure, avoided in zfcp_fsf_send_els */
1857 ZFCP_LOG_INFO("SBAL mismatch (adapter: %s, req_buf_length=%d, "
1858 "resp_buf_length=%d)\n",
1859 zfcp_get_busid_by_adapter(adapter
),
1860 bottom
->req_buf_length
, bottom
->resp_buf_length
);
1861 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1864 case FSF_ACCESS_DENIED
:
1865 ZFCP_LOG_NORMAL("access denied, cannot send ELS command "
1866 "(adapter %s, port d_id=0x%06x)\n",
1867 zfcp_get_busid_by_adapter(adapter
), d_id
);
1868 for (counter
= 0; counter
< 2; counter
++) {
1869 subtable
= header
->fsf_status_qual
.halfword
[counter
* 2];
1870 rule
= header
->fsf_status_qual
.halfword
[counter
* 2 + 1];
1872 case FSF_SQ_CFDC_SUBTABLE_OS
:
1873 case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN
:
1874 case FSF_SQ_CFDC_SUBTABLE_PORT_DID
:
1875 case FSF_SQ_CFDC_SUBTABLE_LUN
:
1876 ZFCP_LOG_INFO("Access denied (%s rule %d)\n",
1877 zfcp_act_subtable_type
[subtable
], rule
);
1881 debug_text_event(adapter
->erp_dbf
, 1, "fsf_s_access");
1883 zfcp_erp_port_access_denied(port
);
1884 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1889 "bug: An unknown FSF Status was presented "
1890 "(adapter: %s, fsf_status=0x%08x)\n",
1891 zfcp_get_busid_by_adapter(adapter
),
1892 header
->fsf_status
);
1893 debug_text_event(adapter
->erp_dbf
, 0, "fsf_sq_inval");
1894 debug_exception(adapter
->erp_dbf
, 0,
1895 &header
->fsf_status_qual
.word
[0], sizeof(u32
));
1896 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1901 send_els
->status
= retval
;
1903 if (send_els
->handler
)
1904 send_els
->handler(send_els
->handler_data
);
1910 zfcp_fsf_exchange_config_data(struct zfcp_erp_action
*erp_action
)
1912 volatile struct qdio_buffer_element
*sbale
;
1913 struct zfcp_fsf_req
*fsf_req
;
1914 struct zfcp_adapter
*adapter
= erp_action
->adapter
;
1915 unsigned long lock_flags
;
1918 /* setup new FSF request */
1919 retval
= zfcp_fsf_req_create(adapter
,
1920 FSF_QTCB_EXCHANGE_CONFIG_DATA
,
1921 ZFCP_REQ_AUTO_CLEANUP
,
1922 adapter
->pool
.fsf_req_erp
,
1923 &lock_flags
, &fsf_req
);
1925 ZFCP_LOG_INFO("error: Could not create exchange configuration "
1926 "data request for adapter %s.\n",
1927 zfcp_get_busid_by_adapter(adapter
));
1928 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
,
1933 sbale
= zfcp_qdio_sbale_req(fsf_req
, fsf_req
->sbal_curr
, 0);
1934 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_READ
;
1935 sbale
[1].flags
|= SBAL_FLAGS_LAST_ENTRY
;
1937 fsf_req
->qtcb
->bottom
.config
.feature_selection
=
1939 FSF_FEATURE_LUN_SHARING
|
1940 FSF_FEATURE_NOTIFICATION_LOST
|
1941 FSF_FEATURE_UPDATE_ALERT
;
1942 fsf_req
->erp_action
= erp_action
;
1943 erp_action
->fsf_req
= fsf_req
;
1945 zfcp_erp_start_timer(fsf_req
);
1946 retval
= zfcp_fsf_req_send(fsf_req
);
1947 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
,
1950 ZFCP_LOG_INFO("error: Could not send exchange configuration "
1951 "data command on the adapter %s\n",
1952 zfcp_get_busid_by_adapter(adapter
));
1953 zfcp_fsf_req_free(fsf_req
);
1954 erp_action
->fsf_req
= NULL
;
1957 ZFCP_LOG_DEBUG("exchange configuration data request initiated "
1959 zfcp_get_busid_by_adapter(adapter
));
1965 zfcp_fsf_exchange_config_data_sync(struct zfcp_adapter
*adapter
,
1966 struct fsf_qtcb_bottom_config
*data
)
1968 volatile struct qdio_buffer_element
*sbale
;
1969 struct zfcp_fsf_req
*fsf_req
;
1970 unsigned long lock_flags
;
1973 /* setup new FSF request */
1974 retval
= zfcp_fsf_req_create(adapter
, FSF_QTCB_EXCHANGE_CONFIG_DATA
,
1975 0, NULL
, &lock_flags
, &fsf_req
);
1977 ZFCP_LOG_INFO("error: Could not create exchange configuration "
1978 "data request for adapter %s.\n",
1979 zfcp_get_busid_by_adapter(adapter
));
1980 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
,
1985 sbale
= zfcp_qdio_sbale_req(fsf_req
, fsf_req
->sbal_curr
, 0);
1986 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_READ
;
1987 sbale
[1].flags
|= SBAL_FLAGS_LAST_ENTRY
;
1989 fsf_req
->qtcb
->bottom
.config
.feature_selection
=
1991 FSF_FEATURE_LUN_SHARING
|
1992 FSF_FEATURE_NOTIFICATION_LOST
|
1993 FSF_FEATURE_UPDATE_ALERT
;
1996 fsf_req
->data
= (unsigned long) data
;
1998 zfcp_fsf_start_timer(fsf_req
, ZFCP_FSF_REQUEST_TIMEOUT
);
1999 retval
= zfcp_fsf_req_send(fsf_req
);
2000 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
,
2003 ZFCP_LOG_INFO("error: Could not send exchange configuration "
2004 "data command on the adapter %s\n",
2005 zfcp_get_busid_by_adapter(adapter
));
2007 wait_event(fsf_req
->completion_wq
,
2008 fsf_req
->status
& ZFCP_STATUS_FSFREQ_COMPLETED
);
2010 zfcp_fsf_req_free(fsf_req
);
2016 * zfcp_fsf_exchange_config_evaluate
2017 * @fsf_req: fsf_req which belongs to xchg config data request
2018 * @xchg_ok: specifies if xchg config data was incomplete or complete (0/1)
2020 * returns: -EIO on error, 0 otherwise
2023 zfcp_fsf_exchange_config_evaluate(struct zfcp_fsf_req
*fsf_req
, int xchg_ok
)
2025 struct fsf_qtcb_bottom_config
*bottom
;
2026 struct zfcp_adapter
*adapter
= fsf_req
->adapter
;
2027 struct Scsi_Host
*shost
= adapter
->scsi_host
;
2029 bottom
= &fsf_req
->qtcb
->bottom
.config
;
2030 ZFCP_LOG_DEBUG("low/high QTCB version 0x%x/0x%x of FSF\n",
2031 bottom
->low_qtcb_version
, bottom
->high_qtcb_version
);
2032 adapter
->fsf_lic_version
= bottom
->lic_version
;
2033 adapter
->adapter_features
= bottom
->adapter_features
;
2034 adapter
->connection_features
= bottom
->connection_features
;
2035 adapter
->peer_wwpn
= 0;
2036 adapter
->peer_wwnn
= 0;
2037 adapter
->peer_d_id
= 0;
2042 memcpy((struct fsf_qtcb_bottom_config
*) fsf_req
->data
,
2043 bottom
, sizeof (struct fsf_qtcb_bottom_config
));
2045 fc_host_node_name(shost
) = bottom
->nport_serv_param
.wwnn
;
2046 fc_host_port_name(shost
) = bottom
->nport_serv_param
.wwpn
;
2047 fc_host_port_id(shost
) = bottom
->s_id
& ZFCP_DID_MASK
;
2048 fc_host_speed(shost
) = bottom
->fc_link_speed
;
2049 fc_host_supported_classes(shost
) =
2050 FC_COS_CLASS2
| FC_COS_CLASS3
;
2051 adapter
->hydra_version
= bottom
->adapter_type
;
2052 if (fc_host_permanent_port_name(shost
) == -1)
2053 fc_host_permanent_port_name(shost
) =
2054 fc_host_port_name(shost
);
2055 if (bottom
->fc_topology
== FSF_TOPO_P2P
) {
2056 adapter
->peer_d_id
= bottom
->peer_d_id
& ZFCP_DID_MASK
;
2057 adapter
->peer_wwpn
= bottom
->plogi_payload
.wwpn
;
2058 adapter
->peer_wwnn
= bottom
->plogi_payload
.wwnn
;
2059 fc_host_port_type(shost
) = FC_PORTTYPE_PTP
;
2060 } else if (bottom
->fc_topology
== FSF_TOPO_FABRIC
)
2061 fc_host_port_type(shost
) = FC_PORTTYPE_NPORT
;
2062 else if (bottom
->fc_topology
== FSF_TOPO_AL
)
2063 fc_host_port_type(shost
) = FC_PORTTYPE_NLPORT
;
2065 fc_host_port_type(shost
) = FC_PORTTYPE_UNKNOWN
;
2067 fc_host_node_name(shost
) = 0;
2068 fc_host_port_name(shost
) = 0;
2069 fc_host_port_id(shost
) = 0;
2070 fc_host_speed(shost
) = FC_PORTSPEED_UNKNOWN
;
2071 fc_host_port_type(shost
) = FC_PORTTYPE_UNKNOWN
;
2072 adapter
->hydra_version
= 0;
2075 if (adapter
->adapter_features
& FSF_FEATURE_HBAAPI_MANAGEMENT
) {
2076 adapter
->hardware_version
= bottom
->hardware_version
;
2077 memcpy(fc_host_serial_number(shost
), bottom
->serial_number
,
2078 min(FC_SERIAL_NUMBER_SIZE
, 17));
2079 EBCASC(fc_host_serial_number(shost
),
2080 min(FC_SERIAL_NUMBER_SIZE
, 17));
2083 ZFCP_LOG_NORMAL("The adapter %s reported the following "
2084 "characteristics:\n"
2088 "adapter version 0x%x, "
2089 "LIC version 0x%x, "
2090 "FC link speed %d Gb/s\n",
2091 zfcp_get_busid_by_adapter(adapter
),
2092 (wwn_t
) fc_host_node_name(shost
),
2093 (wwn_t
) fc_host_port_name(shost
),
2094 fc_host_port_id(shost
),
2095 adapter
->hydra_version
,
2096 adapter
->fsf_lic_version
,
2097 fc_host_speed(shost
));
2098 if (ZFCP_QTCB_VERSION
< bottom
->low_qtcb_version
) {
2099 ZFCP_LOG_NORMAL("error: the adapter %s "
2100 "only supports newer control block "
2101 "versions in comparison to this device "
2102 "driver (try updated device driver)\n",
2103 zfcp_get_busid_by_adapter(adapter
));
2104 debug_text_event(adapter
->erp_dbf
, 0, "low_qtcb_ver");
2105 zfcp_erp_adapter_shutdown(adapter
, 0);
2108 if (ZFCP_QTCB_VERSION
> bottom
->high_qtcb_version
) {
2109 ZFCP_LOG_NORMAL("error: the adapter %s "
2110 "only supports older control block "
2111 "versions than this device driver uses"
2112 "(consider a microcode upgrade)\n",
2113 zfcp_get_busid_by_adapter(adapter
));
2114 debug_text_event(adapter
->erp_dbf
, 0, "high_qtcb_ver");
2115 zfcp_erp_adapter_shutdown(adapter
, 0);
2122 * function: zfcp_fsf_exchange_config_data_handler
2124 * purpose: is called for finished Exchange Configuration Data command
2129 zfcp_fsf_exchange_config_data_handler(struct zfcp_fsf_req
*fsf_req
)
2131 struct fsf_qtcb_bottom_config
*bottom
;
2132 struct zfcp_adapter
*adapter
= fsf_req
->adapter
;
2133 struct fsf_qtcb
*qtcb
= fsf_req
->qtcb
;
2135 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
)
2138 switch (qtcb
->header
.fsf_status
) {
2141 if (zfcp_fsf_exchange_config_evaluate(fsf_req
, 1))
2144 switch (fc_host_port_type(adapter
->scsi_host
)) {
2145 case FC_PORTTYPE_PTP
:
2146 ZFCP_LOG_NORMAL("Point-to-Point fibrechannel "
2147 "configuration detected at adapter %s\n"
2148 "Peer WWNN 0x%016llx, "
2149 "peer WWPN 0x%016llx, "
2150 "peer d_id 0x%06x\n",
2151 zfcp_get_busid_by_adapter(adapter
),
2154 adapter
->peer_d_id
);
2155 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0,
2158 case FC_PORTTYPE_NLPORT
:
2159 ZFCP_LOG_NORMAL("error: Arbitrated loop fibrechannel "
2160 "topology detected at adapter %s "
2161 "unsupported, shutting down adapter\n",
2162 zfcp_get_busid_by_adapter(adapter
));
2163 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0,
2165 zfcp_erp_adapter_shutdown(adapter
, 0);
2167 case FC_PORTTYPE_NPORT
:
2168 ZFCP_LOG_NORMAL("Switched fabric fibrechannel "
2169 "network detected at adapter %s.\n",
2170 zfcp_get_busid_by_adapter(adapter
));
2173 ZFCP_LOG_NORMAL("bug: The fibrechannel topology "
2174 "reported by the exchange "
2175 "configuration command for "
2176 "the adapter %s is not "
2177 "of a type known to the zfcp "
2178 "driver, shutting down adapter\n",
2179 zfcp_get_busid_by_adapter(adapter
));
2180 debug_text_exception(fsf_req
->adapter
->erp_dbf
, 0,
2182 zfcp_erp_adapter_shutdown(adapter
, 0);
2185 bottom
= &qtcb
->bottom
.config
;
2186 if (bottom
->max_qtcb_size
< sizeof(struct fsf_qtcb
)) {
2187 ZFCP_LOG_NORMAL("bug: Maximum QTCB size (%d bytes) "
2188 "allowed by the adapter %s "
2189 "is lower than the minimum "
2190 "required by the driver (%ld bytes).\n",
2191 bottom
->max_qtcb_size
,
2192 zfcp_get_busid_by_adapter(adapter
),
2193 sizeof(struct fsf_qtcb
));
2194 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0,
2196 debug_event(fsf_req
->adapter
->erp_dbf
, 0,
2197 &bottom
->max_qtcb_size
, sizeof (u32
));
2198 zfcp_erp_adapter_shutdown(adapter
, 0);
2201 atomic_set_mask(ZFCP_STATUS_ADAPTER_XCONFIG_OK
,
2204 case FSF_EXCHANGE_CONFIG_DATA_INCOMPLETE
:
2205 debug_text_event(adapter
->erp_dbf
, 0, "xchg-inco");
2207 if (zfcp_fsf_exchange_config_evaluate(fsf_req
, 0))
2210 atomic_set_mask(ZFCP_STATUS_ADAPTER_XCONFIG_OK
,
2213 zfcp_fsf_link_down_info_eval(adapter
,
2214 &qtcb
->header
.fsf_status_qual
.link_down_info
);
2217 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0, "fsf-stat-ng");
2218 debug_event(fsf_req
->adapter
->erp_dbf
, 0,
2219 &fsf_req
->qtcb
->header
.fsf_status
, sizeof(u32
));
2220 zfcp_erp_adapter_shutdown(adapter
, 0);
2227 * zfcp_fsf_exchange_port_data - request information about local port
2228 * @erp_action: ERP action for the adapter for which port data is requested
2231 zfcp_fsf_exchange_port_data(struct zfcp_erp_action
*erp_action
)
2233 volatile struct qdio_buffer_element
*sbale
;
2234 struct zfcp_fsf_req
*fsf_req
;
2235 struct zfcp_adapter
*adapter
= erp_action
->adapter
;
2236 unsigned long lock_flags
;
2239 if (!(adapter
->adapter_features
& FSF_FEATURE_HBAAPI_MANAGEMENT
)) {
2240 ZFCP_LOG_INFO("error: exchange port data "
2241 "command not supported by adapter %s\n",
2242 zfcp_get_busid_by_adapter(adapter
));
2246 /* setup new FSF request */
2247 retval
= zfcp_fsf_req_create(adapter
, FSF_QTCB_EXCHANGE_PORT_DATA
,
2248 ZFCP_REQ_AUTO_CLEANUP
,
2249 adapter
->pool
.fsf_req_erp
,
2250 &lock_flags
, &fsf_req
);
2252 ZFCP_LOG_INFO("error: Out of resources. Could not create an "
2253 "exchange port data request for "
2254 "the adapter %s.\n",
2255 zfcp_get_busid_by_adapter(adapter
));
2256 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
,
2261 sbale
= zfcp_qdio_sbale_req(fsf_req
, fsf_req
->sbal_curr
, 0);
2262 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_READ
;
2263 sbale
[1].flags
|= SBAL_FLAGS_LAST_ENTRY
;
2265 erp_action
->fsf_req
= fsf_req
;
2266 fsf_req
->erp_action
= erp_action
;
2267 zfcp_erp_start_timer(fsf_req
);
2269 retval
= zfcp_fsf_req_send(fsf_req
);
2270 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
, lock_flags
);
2273 ZFCP_LOG_INFO("error: Could not send an exchange port data "
2274 "command on the adapter %s\n",
2275 zfcp_get_busid_by_adapter(adapter
));
2276 zfcp_fsf_req_free(fsf_req
);
2277 erp_action
->fsf_req
= NULL
;
2280 ZFCP_LOG_DEBUG("exchange port data request initiated "
2282 zfcp_get_busid_by_adapter(adapter
));
2288 * zfcp_fsf_exchange_port_data_sync - request information about local port
2289 * and wait until information is ready
2292 zfcp_fsf_exchange_port_data_sync(struct zfcp_adapter
*adapter
,
2293 struct fsf_qtcb_bottom_port
*data
)
2295 volatile struct qdio_buffer_element
*sbale
;
2296 struct zfcp_fsf_req
*fsf_req
;
2297 unsigned long lock_flags
;
2300 if (!(adapter
->adapter_features
& FSF_FEATURE_HBAAPI_MANAGEMENT
)) {
2301 ZFCP_LOG_INFO("error: exchange port data "
2302 "command not supported by adapter %s\n",
2303 zfcp_get_busid_by_adapter(adapter
));
2307 /* setup new FSF request */
2308 retval
= zfcp_fsf_req_create(adapter
, FSF_QTCB_EXCHANGE_PORT_DATA
,
2309 0, NULL
, &lock_flags
, &fsf_req
);
2311 ZFCP_LOG_INFO("error: Out of resources. Could not create an "
2312 "exchange port data request for "
2313 "the adapter %s.\n",
2314 zfcp_get_busid_by_adapter(adapter
));
2315 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
,
2321 fsf_req
->data
= (unsigned long) data
;
2323 sbale
= zfcp_qdio_sbale_req(fsf_req
, fsf_req
->sbal_curr
, 0);
2324 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_READ
;
2325 sbale
[1].flags
|= SBAL_FLAGS_LAST_ENTRY
;
2327 zfcp_fsf_start_timer(fsf_req
, ZFCP_FSF_REQUEST_TIMEOUT
);
2328 retval
= zfcp_fsf_req_send(fsf_req
);
2329 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
, lock_flags
);
2332 ZFCP_LOG_INFO("error: Could not send an exchange port data "
2333 "command on the adapter %s\n",
2334 zfcp_get_busid_by_adapter(adapter
));
2336 wait_event(fsf_req
->completion_wq
,
2337 fsf_req
->status
& ZFCP_STATUS_FSFREQ_COMPLETED
);
2339 zfcp_fsf_req_free(fsf_req
);
2345 * zfcp_fsf_exchange_port_evaluate
2346 * @fsf_req: fsf_req which belongs to xchg port data request
2347 * @xchg_ok: specifies if xchg port data was incomplete or complete (0/1)
2350 zfcp_fsf_exchange_port_evaluate(struct zfcp_fsf_req
*fsf_req
, int xchg_ok
)
2352 struct zfcp_adapter
*adapter
;
2353 struct fsf_qtcb_bottom_port
*bottom
;
2354 struct Scsi_Host
*shost
;
2356 adapter
= fsf_req
->adapter
;
2357 bottom
= &fsf_req
->qtcb
->bottom
.port
;
2358 shost
= adapter
->scsi_host
;
2361 memcpy((struct fsf_qtcb_bottom_port
*) fsf_req
->data
, bottom
,
2362 sizeof(struct fsf_qtcb_bottom_port
));
2364 if (adapter
->connection_features
& FSF_FEATURE_NPIV_MODE
)
2365 fc_host_permanent_port_name(shost
) = bottom
->wwpn
;
2367 fc_host_permanent_port_name(shost
) = fc_host_port_name(shost
);
2368 fc_host_maxframe_size(shost
) = bottom
->maximum_frame_size
;
2369 fc_host_supported_speeds(shost
) = bottom
->supported_speed
;
2373 * zfcp_fsf_exchange_port_data_handler - handler for exchange_port_data request
2374 * @fsf_req: pointer to struct zfcp_fsf_req
2377 zfcp_fsf_exchange_port_data_handler(struct zfcp_fsf_req
*fsf_req
)
2379 struct zfcp_adapter
*adapter
;
2380 struct fsf_qtcb
*qtcb
;
2382 adapter
= fsf_req
->adapter
;
2383 qtcb
= fsf_req
->qtcb
;
2385 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
)
2388 switch (qtcb
->header
.fsf_status
) {
2390 zfcp_fsf_exchange_port_evaluate(fsf_req
, 1);
2391 atomic_set_mask(ZFCP_STATUS_ADAPTER_XPORT_OK
, &adapter
->status
);
2393 case FSF_EXCHANGE_CONFIG_DATA_INCOMPLETE
:
2394 zfcp_fsf_exchange_port_evaluate(fsf_req
, 0);
2395 atomic_set_mask(ZFCP_STATUS_ADAPTER_XPORT_OK
, &adapter
->status
);
2396 zfcp_fsf_link_down_info_eval(adapter
,
2397 &qtcb
->header
.fsf_status_qual
.link_down_info
);
2400 debug_text_event(adapter
->erp_dbf
, 0, "xchg-port-ng");
2401 debug_event(adapter
->erp_dbf
, 0,
2402 &fsf_req
->qtcb
->header
.fsf_status
, sizeof(u32
));
2408 * function: zfcp_fsf_open_port
2412 * returns: address of initiated FSF request
2413 * NULL - request could not be initiated
2416 zfcp_fsf_open_port(struct zfcp_erp_action
*erp_action
)
2418 volatile struct qdio_buffer_element
*sbale
;
2419 struct zfcp_fsf_req
*fsf_req
;
2420 unsigned long lock_flags
;
2423 /* setup new FSF request */
2424 retval
= zfcp_fsf_req_create(erp_action
->adapter
,
2425 FSF_QTCB_OPEN_PORT_WITH_DID
,
2426 ZFCP_WAIT_FOR_SBAL
| ZFCP_REQ_AUTO_CLEANUP
,
2427 erp_action
->adapter
->pool
.fsf_req_erp
,
2428 &lock_flags
, &fsf_req
);
2430 ZFCP_LOG_INFO("error: Could not create open port request "
2431 "for port 0x%016Lx on adapter %s.\n",
2432 erp_action
->port
->wwpn
,
2433 zfcp_get_busid_by_adapter(erp_action
->adapter
));
2437 sbale
= zfcp_qdio_sbale_req(fsf_req
, fsf_req
->sbal_curr
, 0);
2438 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_READ
;
2439 sbale
[1].flags
|= SBAL_FLAGS_LAST_ENTRY
;
2441 fsf_req
->qtcb
->bottom
.support
.d_id
= erp_action
->port
->d_id
;
2442 atomic_set_mask(ZFCP_STATUS_COMMON_OPENING
, &erp_action
->port
->status
);
2443 fsf_req
->data
= (unsigned long) erp_action
->port
;
2444 fsf_req
->erp_action
= erp_action
;
2445 erp_action
->fsf_req
= fsf_req
;
2447 zfcp_erp_start_timer(fsf_req
);
2448 retval
= zfcp_fsf_req_send(fsf_req
);
2450 ZFCP_LOG_INFO("error: Could not send open port request for "
2451 "port 0x%016Lx on adapter %s.\n",
2452 erp_action
->port
->wwpn
,
2453 zfcp_get_busid_by_adapter(erp_action
->adapter
));
2454 zfcp_fsf_req_free(fsf_req
);
2455 erp_action
->fsf_req
= NULL
;
2459 ZFCP_LOG_DEBUG("open port request initiated "
2460 "(adapter %s, port 0x%016Lx)\n",
2461 zfcp_get_busid_by_adapter(erp_action
->adapter
),
2462 erp_action
->port
->wwpn
);
2464 write_unlock_irqrestore(&erp_action
->adapter
->request_queue
.queue_lock
,
2470 * function: zfcp_fsf_open_port_handler
2472 * purpose: is called for finished Open Port command
2477 zfcp_fsf_open_port_handler(struct zfcp_fsf_req
*fsf_req
)
2479 int retval
= -EINVAL
;
2480 struct zfcp_port
*port
;
2481 struct fsf_plogi
*plogi
;
2482 struct fsf_qtcb_header
*header
;
2483 u16 subtable
, rule
, counter
;
2485 port
= (struct zfcp_port
*) fsf_req
->data
;
2486 header
= &fsf_req
->qtcb
->header
;
2488 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
) {
2489 /* don't change port status in our bookkeeping */
2490 goto skip_fsfstatus
;
2493 /* evaluate FSF status in QTCB */
2494 switch (header
->fsf_status
) {
2496 case FSF_PORT_ALREADY_OPEN
:
2497 ZFCP_LOG_NORMAL("bug: remote port 0x%016Lx on adapter %s "
2498 "is already open.\n",
2499 port
->wwpn
, zfcp_get_busid_by_port(port
));
2500 debug_text_exception(fsf_req
->adapter
->erp_dbf
, 0,
2503 * This is a bug, however operation should continue normally
2504 * if it is simply ignored
2508 case FSF_ACCESS_DENIED
:
2509 ZFCP_LOG_NORMAL("Access denied, cannot open port 0x%016Lx "
2511 port
->wwpn
, zfcp_get_busid_by_port(port
));
2512 for (counter
= 0; counter
< 2; counter
++) {
2513 subtable
= header
->fsf_status_qual
.halfword
[counter
* 2];
2514 rule
= header
->fsf_status_qual
.halfword
[counter
* 2 + 1];
2516 case FSF_SQ_CFDC_SUBTABLE_OS
:
2517 case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN
:
2518 case FSF_SQ_CFDC_SUBTABLE_PORT_DID
:
2519 case FSF_SQ_CFDC_SUBTABLE_LUN
:
2520 ZFCP_LOG_INFO("Access denied (%s rule %d)\n",
2521 zfcp_act_subtable_type
[subtable
], rule
);
2525 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1, "fsf_s_access");
2526 zfcp_erp_port_access_denied(port
);
2527 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
2530 case FSF_MAXIMUM_NUMBER_OF_PORTS_EXCEEDED
:
2531 ZFCP_LOG_INFO("error: The FSF adapter is out of resources. "
2532 "The remote port 0x%016Lx on adapter %s "
2533 "could not be opened. Disabling it.\n",
2534 port
->wwpn
, zfcp_get_busid_by_port(port
));
2535 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
2537 zfcp_erp_port_failed(port
);
2538 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
2541 case FSF_ADAPTER_STATUS_AVAILABLE
:
2542 switch (header
->fsf_status_qual
.word
[0]) {
2543 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE
:
2544 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
2546 /* ERP strategy will escalate */
2547 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
2549 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED
:
2550 /* ERP strategy will escalate */
2551 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
2553 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
2555 case FSF_SQ_NO_RETRY_POSSIBLE
:
2556 ZFCP_LOG_NORMAL("The remote port 0x%016Lx on "
2557 "adapter %s could not be opened. "
2560 zfcp_get_busid_by_port(port
));
2561 debug_text_exception(fsf_req
->adapter
->erp_dbf
, 0,
2563 zfcp_erp_port_failed(port
);
2564 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
2568 ("bug: Wrong status qualifier 0x%x arrived.\n",
2569 header
->fsf_status_qual
.word
[0]);
2570 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0,
2573 fsf_req
->adapter
->erp_dbf
, 0,
2574 &header
->fsf_status_qual
.word
[0],
2581 /* save port handle assigned by FSF */
2582 port
->handle
= header
->port_handle
;
2583 ZFCP_LOG_INFO("The remote port 0x%016Lx via adapter %s "
2584 "was opened, it's port handle is 0x%x\n",
2585 port
->wwpn
, zfcp_get_busid_by_port(port
),
2587 /* mark port as open */
2588 atomic_set_mask(ZFCP_STATUS_COMMON_OPEN
|
2589 ZFCP_STATUS_PORT_PHYS_OPEN
, &port
->status
);
2590 atomic_clear_mask(ZFCP_STATUS_COMMON_ACCESS_DENIED
|
2591 ZFCP_STATUS_COMMON_ACCESS_BOXED
,
2594 /* check whether D_ID has changed during open */
2596 * FIXME: This check is not airtight, as the FCP channel does
2597 * not monitor closures of target port connections caused on
2598 * the remote side. Thus, they might miss out on invalidating
2599 * locally cached WWPNs (and other N_Port parameters) of gone
2600 * target ports. So, our heroic attempt to make things safe
2601 * could be undermined by 'open port' response data tagged with
2602 * obsolete WWPNs. Another reason to monitor potential
2603 * connection closures ourself at least (by interpreting
2604 * incoming ELS' and unsolicited status). It just crosses my
2605 * mind that one should be able to cross-check by means of
2606 * another GID_PN straight after a port has been opened.
2607 * Alternately, an ADISC/PDISC ELS should suffice, as well.
2609 plogi
= (struct fsf_plogi
*) fsf_req
->qtcb
->bottom
.support
.els
;
2610 if (!atomic_test_mask(ZFCP_STATUS_PORT_NO_WWPN
, &port
->status
))
2612 if (fsf_req
->qtcb
->bottom
.support
.els1_length
<
2613 sizeof (struct fsf_plogi
)) {
2615 "warning: insufficient length of "
2616 "PLOGI payload (%i)\n",
2617 fsf_req
->qtcb
->bottom
.support
.els1_length
);
2618 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0,
2619 "fsf_s_short_plogi:");
2620 /* skip sanity check and assume wwpn is ok */
2622 if (plogi
->serv_param
.wwpn
!= port
->wwpn
) {
2623 ZFCP_LOG_INFO("warning: d_id of port "
2624 "0x%016Lx changed during "
2625 "open\n", port
->wwpn
);
2627 fsf_req
->adapter
->erp_dbf
, 0,
2628 "fsf_s_did_change:");
2630 ZFCP_STATUS_PORT_DID_DID
,
2633 port
->wwnn
= plogi
->serv_param
.wwnn
;
2634 zfcp_plogi_evaluate(port
, plogi
);
2640 case FSF_UNKNOWN_OP_SUBTYPE
:
2641 /* should never occure, subtype not set in zfcp_fsf_open_port */
2642 ZFCP_LOG_INFO("unknown operation subtype (adapter: %s, "
2643 "op_subtype=0x%x)\n",
2644 zfcp_get_busid_by_port(port
),
2645 fsf_req
->qtcb
->bottom
.support
.operation_subtype
);
2646 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
2650 ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
2651 "(debug info 0x%x)\n",
2652 header
->fsf_status
);
2653 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0, "fsf_s_inval:");
2654 debug_exception(fsf_req
->adapter
->erp_dbf
, 0,
2655 &header
->fsf_status
, sizeof (u32
));
2660 atomic_clear_mask(ZFCP_STATUS_COMMON_OPENING
, &port
->status
);
2665 * function: zfcp_fsf_close_port
2667 * purpose: submit FSF command "close port"
2669 * returns: address of initiated FSF request
2670 * NULL - request could not be initiated
2673 zfcp_fsf_close_port(struct zfcp_erp_action
*erp_action
)
2675 volatile struct qdio_buffer_element
*sbale
;
2676 struct zfcp_fsf_req
*fsf_req
;
2677 unsigned long lock_flags
;
2680 /* setup new FSF request */
2681 retval
= zfcp_fsf_req_create(erp_action
->adapter
,
2682 FSF_QTCB_CLOSE_PORT
,
2683 ZFCP_WAIT_FOR_SBAL
| ZFCP_REQ_AUTO_CLEANUP
,
2684 erp_action
->adapter
->pool
.fsf_req_erp
,
2685 &lock_flags
, &fsf_req
);
2687 ZFCP_LOG_INFO("error: Could not create a close port request "
2688 "for port 0x%016Lx on adapter %s.\n",
2689 erp_action
->port
->wwpn
,
2690 zfcp_get_busid_by_adapter(erp_action
->adapter
));
2694 sbale
= zfcp_qdio_sbale_req(fsf_req
, fsf_req
->sbal_curr
, 0);
2695 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_READ
;
2696 sbale
[1].flags
|= SBAL_FLAGS_LAST_ENTRY
;
2698 atomic_set_mask(ZFCP_STATUS_COMMON_CLOSING
, &erp_action
->port
->status
);
2699 fsf_req
->data
= (unsigned long) erp_action
->port
;
2700 fsf_req
->erp_action
= erp_action
;
2701 fsf_req
->qtcb
->header
.port_handle
= erp_action
->port
->handle
;
2702 fsf_req
->erp_action
= erp_action
;
2703 erp_action
->fsf_req
= fsf_req
;
2705 zfcp_erp_start_timer(fsf_req
);
2706 retval
= zfcp_fsf_req_send(fsf_req
);
2708 ZFCP_LOG_INFO("error: Could not send a close port request for "
2709 "port 0x%016Lx on adapter %s.\n",
2710 erp_action
->port
->wwpn
,
2711 zfcp_get_busid_by_adapter(erp_action
->adapter
));
2712 zfcp_fsf_req_free(fsf_req
);
2713 erp_action
->fsf_req
= NULL
;
2717 ZFCP_LOG_TRACE("close port request initiated "
2718 "(adapter %s, port 0x%016Lx)\n",
2719 zfcp_get_busid_by_adapter(erp_action
->adapter
),
2720 erp_action
->port
->wwpn
);
2722 write_unlock_irqrestore(&erp_action
->adapter
->request_queue
.queue_lock
,
2728 * function: zfcp_fsf_close_port_handler
2730 * purpose: is called for finished Close Port FSF command
2735 zfcp_fsf_close_port_handler(struct zfcp_fsf_req
*fsf_req
)
2737 int retval
= -EINVAL
;
2738 struct zfcp_port
*port
;
2740 port
= (struct zfcp_port
*) fsf_req
->data
;
2742 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
) {
2743 /* don't change port status in our bookkeeping */
2744 goto skip_fsfstatus
;
2747 /* evaluate FSF status in QTCB */
2748 switch (fsf_req
->qtcb
->header
.fsf_status
) {
2750 case FSF_PORT_HANDLE_NOT_VALID
:
2751 ZFCP_LOG_INFO("Temporary port identifier 0x%x for port "
2752 "0x%016Lx on adapter %s invalid. This may happen "
2753 "occasionally.\n", port
->handle
,
2754 port
->wwpn
, zfcp_get_busid_by_port(port
));
2755 ZFCP_LOG_DEBUG("status qualifier:\n");
2756 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
2757 (char *) &fsf_req
->qtcb
->header
.fsf_status_qual
,
2758 sizeof (union fsf_status_qual
));
2759 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
2761 zfcp_erp_adapter_reopen(port
->adapter
, 0);
2762 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
2765 case FSF_ADAPTER_STATUS_AVAILABLE
:
2766 /* Note: FSF has actually closed the port in this case.
2767 * The status code is just daft. Fingers crossed for a change
2773 ZFCP_LOG_TRACE("remote port 0x016%Lx on adapter %s closed, "
2774 "port handle 0x%x\n", port
->wwpn
,
2775 zfcp_get_busid_by_port(port
), port
->handle
);
2776 zfcp_erp_modify_port_status(port
,
2777 ZFCP_STATUS_COMMON_OPEN
,
2783 ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
2784 "(debug info 0x%x)\n",
2785 fsf_req
->qtcb
->header
.fsf_status
);
2786 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0, "fsf_s_inval:");
2787 debug_exception(fsf_req
->adapter
->erp_dbf
, 0,
2788 &fsf_req
->qtcb
->header
.fsf_status
,
2794 atomic_clear_mask(ZFCP_STATUS_COMMON_CLOSING
, &port
->status
);
2799 * function: zfcp_fsf_close_physical_port
2801 * purpose: submit FSF command "close physical port"
2803 * returns: address of initiated FSF request
2804 * NULL - request could not be initiated
2807 zfcp_fsf_close_physical_port(struct zfcp_erp_action
*erp_action
)
2809 volatile struct qdio_buffer_element
*sbale
;
2810 struct zfcp_fsf_req
*fsf_req
;
2811 unsigned long lock_flags
;
2814 /* setup new FSF request */
2815 retval
= zfcp_fsf_req_create(erp_action
->adapter
,
2816 FSF_QTCB_CLOSE_PHYSICAL_PORT
,
2817 ZFCP_WAIT_FOR_SBAL
| ZFCP_REQ_AUTO_CLEANUP
,
2818 erp_action
->adapter
->pool
.fsf_req_erp
,
2819 &lock_flags
, &fsf_req
);
2821 ZFCP_LOG_INFO("error: Could not create close physical port "
2822 "request (adapter %s, port 0x%016Lx)\n",
2823 zfcp_get_busid_by_adapter(erp_action
->adapter
),
2824 erp_action
->port
->wwpn
);
2829 sbale
= zfcp_qdio_sbale_req(fsf_req
, fsf_req
->sbal_curr
, 0);
2830 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_READ
;
2831 sbale
[1].flags
|= SBAL_FLAGS_LAST_ENTRY
;
2833 /* mark port as being closed */
2834 atomic_set_mask(ZFCP_STATUS_PORT_PHYS_CLOSING
,
2835 &erp_action
->port
->status
);
2836 /* save a pointer to this port */
2837 fsf_req
->data
= (unsigned long) erp_action
->port
;
2838 fsf_req
->qtcb
->header
.port_handle
= erp_action
->port
->handle
;
2839 fsf_req
->erp_action
= erp_action
;
2840 erp_action
->fsf_req
= fsf_req
;
2842 zfcp_erp_start_timer(fsf_req
);
2843 retval
= zfcp_fsf_req_send(fsf_req
);
2845 ZFCP_LOG_INFO("error: Could not send close physical port "
2846 "request (adapter %s, port 0x%016Lx)\n",
2847 zfcp_get_busid_by_adapter(erp_action
->adapter
),
2848 erp_action
->port
->wwpn
);
2849 zfcp_fsf_req_free(fsf_req
);
2850 erp_action
->fsf_req
= NULL
;
2854 ZFCP_LOG_TRACE("close physical port request initiated "
2855 "(adapter %s, port 0x%016Lx)\n",
2856 zfcp_get_busid_by_adapter(erp_action
->adapter
),
2857 erp_action
->port
->wwpn
);
2859 write_unlock_irqrestore(&erp_action
->adapter
->request_queue
.queue_lock
,
2865 * function: zfcp_fsf_close_physical_port_handler
2867 * purpose: is called for finished Close Physical Port FSF command
2872 zfcp_fsf_close_physical_port_handler(struct zfcp_fsf_req
*fsf_req
)
2874 int retval
= -EINVAL
;
2875 struct zfcp_port
*port
;
2876 struct zfcp_unit
*unit
;
2877 struct fsf_qtcb_header
*header
;
2878 u16 subtable
, rule
, counter
;
2880 port
= (struct zfcp_port
*) fsf_req
->data
;
2881 header
= &fsf_req
->qtcb
->header
;
2883 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
) {
2884 /* don't change port status in our bookkeeping */
2885 goto skip_fsfstatus
;
2888 /* evaluate FSF status in QTCB */
2889 switch (header
->fsf_status
) {
2891 case FSF_PORT_HANDLE_NOT_VALID
:
2892 ZFCP_LOG_INFO("Temporary port identifier 0x%x invalid"
2893 "(adapter %s, port 0x%016Lx). "
2894 "This may happen occasionally.\n",
2896 zfcp_get_busid_by_port(port
),
2898 ZFCP_LOG_DEBUG("status qualifier:\n");
2899 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
2900 (char *) &header
->fsf_status_qual
,
2901 sizeof (union fsf_status_qual
));
2902 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
2904 zfcp_erp_adapter_reopen(port
->adapter
, 0);
2905 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
2908 case FSF_ACCESS_DENIED
:
2909 ZFCP_LOG_NORMAL("Access denied, cannot close "
2910 "physical port 0x%016Lx on adapter %s\n",
2911 port
->wwpn
, zfcp_get_busid_by_port(port
));
2912 for (counter
= 0; counter
< 2; counter
++) {
2913 subtable
= header
->fsf_status_qual
.halfword
[counter
* 2];
2914 rule
= header
->fsf_status_qual
.halfword
[counter
* 2 + 1];
2916 case FSF_SQ_CFDC_SUBTABLE_OS
:
2917 case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN
:
2918 case FSF_SQ_CFDC_SUBTABLE_PORT_DID
:
2919 case FSF_SQ_CFDC_SUBTABLE_LUN
:
2920 ZFCP_LOG_INFO("Access denied (%s rule %d)\n",
2921 zfcp_act_subtable_type
[subtable
], rule
);
2925 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1, "fsf_s_access");
2926 zfcp_erp_port_access_denied(port
);
2927 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
2930 case FSF_PORT_BOXED
:
2931 ZFCP_LOG_DEBUG("The remote port 0x%016Lx on adapter "
2932 "%s needs to be reopened but it was attempted "
2933 "to close it physically.\n",
2935 zfcp_get_busid_by_port(port
));
2936 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1, "fsf_s_pboxed");
2937 zfcp_erp_port_boxed(port
);
2938 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
|
2939 ZFCP_STATUS_FSFREQ_RETRY
;
2941 /* can't use generic zfcp_erp_modify_port_status because
2942 * ZFCP_STATUS_COMMON_OPEN must not be reset for the port */
2943 atomic_clear_mask(ZFCP_STATUS_PORT_PHYS_OPEN
, &port
->status
);
2944 list_for_each_entry(unit
, &port
->unit_list_head
, list
)
2945 atomic_clear_mask(ZFCP_STATUS_COMMON_OPEN
,
2949 case FSF_ADAPTER_STATUS_AVAILABLE
:
2950 switch (header
->fsf_status_qual
.word
[0]) {
2951 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE
:
2952 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
2954 /* This will now be escalated by ERP */
2955 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
2957 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED
:
2958 /* ERP strategy will escalate */
2959 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
2961 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
2965 ("bug: Wrong status qualifier 0x%x arrived.\n",
2966 header
->fsf_status_qual
.word
[0]);
2967 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0,
2970 fsf_req
->adapter
->erp_dbf
, 0,
2971 &header
->fsf_status_qual
.word
[0], sizeof (u32
));
2977 ZFCP_LOG_DEBUG("Remote port 0x%016Lx via adapter %s "
2978 "physically closed, port handle 0x%x\n",
2980 zfcp_get_busid_by_port(port
), port
->handle
);
2981 /* can't use generic zfcp_erp_modify_port_status because
2982 * ZFCP_STATUS_COMMON_OPEN must not be reset for the port
2984 atomic_clear_mask(ZFCP_STATUS_PORT_PHYS_OPEN
, &port
->status
);
2985 list_for_each_entry(unit
, &port
->unit_list_head
, list
)
2986 atomic_clear_mask(ZFCP_STATUS_COMMON_OPEN
, &unit
->status
);
2991 ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
2992 "(debug info 0x%x)\n",
2993 header
->fsf_status
);
2994 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0, "fsf_s_inval:");
2995 debug_exception(fsf_req
->adapter
->erp_dbf
, 0,
2996 &header
->fsf_status
, sizeof (u32
));
3001 atomic_clear_mask(ZFCP_STATUS_PORT_PHYS_CLOSING
, &port
->status
);
3006 * function: zfcp_fsf_open_unit
3012 * assumptions: This routine does not check whether the associated
3013 * remote port has already been opened. This should be
3014 * done by calling routines. Otherwise some status
3015 * may be presented by FSF
3018 zfcp_fsf_open_unit(struct zfcp_erp_action
*erp_action
)
3020 volatile struct qdio_buffer_element
*sbale
;
3021 struct zfcp_fsf_req
*fsf_req
;
3022 unsigned long lock_flags
;
3025 /* setup new FSF request */
3026 retval
= zfcp_fsf_req_create(erp_action
->adapter
,
3028 ZFCP_WAIT_FOR_SBAL
| ZFCP_REQ_AUTO_CLEANUP
,
3029 erp_action
->adapter
->pool
.fsf_req_erp
,
3030 &lock_flags
, &fsf_req
);
3032 ZFCP_LOG_INFO("error: Could not create open unit request for "
3033 "unit 0x%016Lx on port 0x%016Lx on adapter %s.\n",
3034 erp_action
->unit
->fcp_lun
,
3035 erp_action
->unit
->port
->wwpn
,
3036 zfcp_get_busid_by_adapter(erp_action
->adapter
));
3040 sbale
= zfcp_qdio_sbale_req(fsf_req
, fsf_req
->sbal_curr
, 0);
3041 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_READ
;
3042 sbale
[1].flags
|= SBAL_FLAGS_LAST_ENTRY
;
3044 fsf_req
->qtcb
->header
.port_handle
= erp_action
->port
->handle
;
3045 fsf_req
->qtcb
->bottom
.support
.fcp_lun
= erp_action
->unit
->fcp_lun
;
3046 if (!(erp_action
->adapter
->connection_features
& FSF_FEATURE_NPIV_MODE
))
3047 fsf_req
->qtcb
->bottom
.support
.option
=
3048 FSF_OPEN_LUN_SUPPRESS_BOXING
;
3049 atomic_set_mask(ZFCP_STATUS_COMMON_OPENING
, &erp_action
->unit
->status
);
3050 fsf_req
->data
= (unsigned long) erp_action
->unit
;
3051 fsf_req
->erp_action
= erp_action
;
3052 erp_action
->fsf_req
= fsf_req
;
3054 zfcp_erp_start_timer(fsf_req
);
3055 retval
= zfcp_fsf_req_send(erp_action
->fsf_req
);
3057 ZFCP_LOG_INFO("error: Could not send an open unit request "
3058 "on the adapter %s, port 0x%016Lx for "
3060 zfcp_get_busid_by_adapter(erp_action
->adapter
),
3061 erp_action
->port
->wwpn
,
3062 erp_action
->unit
->fcp_lun
);
3063 zfcp_fsf_req_free(fsf_req
);
3064 erp_action
->fsf_req
= NULL
;
3068 ZFCP_LOG_TRACE("Open LUN request initiated (adapter %s, "
3069 "port 0x%016Lx, unit 0x%016Lx)\n",
3070 zfcp_get_busid_by_adapter(erp_action
->adapter
),
3071 erp_action
->port
->wwpn
, erp_action
->unit
->fcp_lun
);
3073 write_unlock_irqrestore(&erp_action
->adapter
->request_queue
.queue_lock
,
3079 * function: zfcp_fsf_open_unit_handler
3081 * purpose: is called for finished Open LUN command
3086 zfcp_fsf_open_unit_handler(struct zfcp_fsf_req
*fsf_req
)
3088 int retval
= -EINVAL
;
3089 struct zfcp_adapter
*adapter
;
3090 struct zfcp_unit
*unit
;
3091 struct fsf_qtcb_header
*header
;
3092 struct fsf_qtcb_bottom_support
*bottom
;
3093 struct fsf_queue_designator
*queue_designator
;
3094 u16 subtable
, rule
, counter
;
3095 int exclusive
, readwrite
;
3097 unit
= (struct zfcp_unit
*) fsf_req
->data
;
3099 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
) {
3100 /* don't change unit status in our bookkeeping */
3101 goto skip_fsfstatus
;
3104 adapter
= fsf_req
->adapter
;
3105 header
= &fsf_req
->qtcb
->header
;
3106 bottom
= &fsf_req
->qtcb
->bottom
.support
;
3107 queue_designator
= &header
->fsf_status_qual
.fsf_queue_designator
;
3109 atomic_clear_mask(ZFCP_STATUS_COMMON_ACCESS_DENIED
|
3110 ZFCP_STATUS_COMMON_ACCESS_BOXED
|
3111 ZFCP_STATUS_UNIT_SHARED
|
3112 ZFCP_STATUS_UNIT_READONLY
,
3115 /* evaluate FSF status in QTCB */
3116 switch (header
->fsf_status
) {
3118 case FSF_PORT_HANDLE_NOT_VALID
:
3119 ZFCP_LOG_INFO("Temporary port identifier 0x%x "
3120 "for port 0x%016Lx on adapter %s invalid "
3121 "This may happen occasionally\n",
3123 unit
->port
->wwpn
, zfcp_get_busid_by_unit(unit
));
3124 ZFCP_LOG_DEBUG("status qualifier:\n");
3125 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
3126 (char *) &header
->fsf_status_qual
,
3127 sizeof (union fsf_status_qual
));
3128 debug_text_event(adapter
->erp_dbf
, 1, "fsf_s_ph_nv");
3129 zfcp_erp_adapter_reopen(unit
->port
->adapter
, 0);
3130 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3133 case FSF_LUN_ALREADY_OPEN
:
3134 ZFCP_LOG_NORMAL("bug: Attempted to open unit 0x%016Lx on "
3135 "remote port 0x%016Lx on adapter %s twice.\n",
3137 unit
->port
->wwpn
, zfcp_get_busid_by_unit(unit
));
3138 debug_text_exception(adapter
->erp_dbf
, 0,
3140 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3143 case FSF_ACCESS_DENIED
:
3144 ZFCP_LOG_NORMAL("Access denied, cannot open unit 0x%016Lx on "
3145 "remote port 0x%016Lx on adapter %s\n",
3146 unit
->fcp_lun
, unit
->port
->wwpn
,
3147 zfcp_get_busid_by_unit(unit
));
3148 for (counter
= 0; counter
< 2; counter
++) {
3149 subtable
= header
->fsf_status_qual
.halfword
[counter
* 2];
3150 rule
= header
->fsf_status_qual
.halfword
[counter
* 2 + 1];
3152 case FSF_SQ_CFDC_SUBTABLE_OS
:
3153 case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN
:
3154 case FSF_SQ_CFDC_SUBTABLE_PORT_DID
:
3155 case FSF_SQ_CFDC_SUBTABLE_LUN
:
3156 ZFCP_LOG_INFO("Access denied (%s rule %d)\n",
3157 zfcp_act_subtable_type
[subtable
], rule
);
3161 debug_text_event(adapter
->erp_dbf
, 1, "fsf_s_access");
3162 zfcp_erp_unit_access_denied(unit
);
3163 atomic_clear_mask(ZFCP_STATUS_UNIT_SHARED
, &unit
->status
);
3164 atomic_clear_mask(ZFCP_STATUS_UNIT_READONLY
, &unit
->status
);
3165 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3168 case FSF_PORT_BOXED
:
3169 ZFCP_LOG_DEBUG("The remote port 0x%016Lx on adapter %s "
3170 "needs to be reopened\n",
3171 unit
->port
->wwpn
, zfcp_get_busid_by_unit(unit
));
3172 debug_text_event(adapter
->erp_dbf
, 2, "fsf_s_pboxed");
3173 zfcp_erp_port_boxed(unit
->port
);
3174 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
|
3175 ZFCP_STATUS_FSFREQ_RETRY
;
3178 case FSF_LUN_SHARING_VIOLATION
:
3179 if (header
->fsf_status_qual
.word
[0] != 0) {
3180 ZFCP_LOG_NORMAL("FCP-LUN 0x%Lx at the remote port "
3182 "connected to the adapter %s "
3183 "is already in use in LPAR%d, CSS%d\n",
3186 zfcp_get_busid_by_unit(unit
),
3187 queue_designator
->hla
,
3188 queue_designator
->cssid
);
3190 subtable
= header
->fsf_status_qual
.halfword
[4];
3191 rule
= header
->fsf_status_qual
.halfword
[5];
3193 case FSF_SQ_CFDC_SUBTABLE_OS
:
3194 case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN
:
3195 case FSF_SQ_CFDC_SUBTABLE_PORT_DID
:
3196 case FSF_SQ_CFDC_SUBTABLE_LUN
:
3197 ZFCP_LOG_NORMAL("Access to FCP-LUN 0x%Lx at the "
3198 "remote port with WWPN 0x%Lx "
3199 "connected to the adapter %s "
3200 "is denied (%s rule %d)\n",
3203 zfcp_get_busid_by_unit(unit
),
3204 zfcp_act_subtable_type
[subtable
],
3209 ZFCP_LOG_DEBUG("status qualifier:\n");
3210 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
3211 (char *) &header
->fsf_status_qual
,
3212 sizeof (union fsf_status_qual
));
3213 debug_text_event(adapter
->erp_dbf
, 2,
3215 zfcp_erp_unit_access_denied(unit
);
3216 atomic_clear_mask(ZFCP_STATUS_UNIT_SHARED
, &unit
->status
);
3217 atomic_clear_mask(ZFCP_STATUS_UNIT_READONLY
, &unit
->status
);
3218 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3221 case FSF_MAXIMUM_NUMBER_OF_LUNS_EXCEEDED
:
3222 ZFCP_LOG_INFO("error: The adapter ran out of resources. "
3223 "There is no handle (temporary port identifier) "
3224 "available for unit 0x%016Lx on port 0x%016Lx "
3228 zfcp_get_busid_by_unit(unit
));
3229 debug_text_event(adapter
->erp_dbf
, 1,
3231 zfcp_erp_unit_failed(unit
);
3232 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3235 case FSF_ADAPTER_STATUS_AVAILABLE
:
3236 switch (header
->fsf_status_qual
.word
[0]) {
3237 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE
:
3238 /* Re-establish link to port */
3239 debug_text_event(adapter
->erp_dbf
, 1,
3241 zfcp_test_link(unit
->port
);
3242 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3244 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED
:
3245 /* ERP strategy will escalate */
3246 debug_text_event(adapter
->erp_dbf
, 1,
3248 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3252 ("bug: Wrong status qualifier 0x%x arrived.\n",
3253 header
->fsf_status_qual
.word
[0]);
3254 debug_text_event(adapter
->erp_dbf
, 0,
3256 debug_exception(adapter
->erp_dbf
, 0,
3257 &header
->fsf_status_qual
.word
[0],
3262 case FSF_INVALID_COMMAND_OPTION
:
3264 "Invalid option 0x%x has been specified "
3265 "in QTCB bottom sent to the adapter %s\n",
3267 zfcp_get_busid_by_adapter(adapter
));
3268 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3273 /* save LUN handle assigned by FSF */
3274 unit
->handle
= header
->lun_handle
;
3275 ZFCP_LOG_TRACE("unit 0x%016Lx on remote port 0x%016Lx on "
3276 "adapter %s opened, port handle 0x%x\n",
3279 zfcp_get_busid_by_unit(unit
),
3281 /* mark unit as open */
3282 atomic_set_mask(ZFCP_STATUS_COMMON_OPEN
, &unit
->status
);
3284 if (!(adapter
->connection_features
& FSF_FEATURE_NPIV_MODE
) &&
3285 (adapter
->adapter_features
& FSF_FEATURE_LUN_SHARING
) &&
3286 (adapter
->ccw_device
->id
.dev_model
!= ZFCP_DEVICE_MODEL_PRIV
)) {
3287 exclusive
= (bottom
->lun_access_info
&
3288 FSF_UNIT_ACCESS_EXCLUSIVE
);
3289 readwrite
= (bottom
->lun_access_info
&
3290 FSF_UNIT_ACCESS_OUTBOUND_TRANSFER
);
3293 atomic_set_mask(ZFCP_STATUS_UNIT_SHARED
,
3297 atomic_set_mask(ZFCP_STATUS_UNIT_READONLY
,
3299 ZFCP_LOG_NORMAL("read-only access for unit "
3300 "(adapter %s, wwpn=0x%016Lx, "
3301 "fcp_lun=0x%016Lx)\n",
3302 zfcp_get_busid_by_unit(unit
),
3307 if (exclusive
&& !readwrite
) {
3308 ZFCP_LOG_NORMAL("exclusive access of read-only "
3309 "unit not supported\n");
3310 zfcp_erp_unit_failed(unit
);
3311 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3312 zfcp_erp_unit_shutdown(unit
, 0);
3313 } else if (!exclusive
&& readwrite
) {
3314 ZFCP_LOG_NORMAL("shared access of read-write "
3315 "unit not supported\n");
3316 zfcp_erp_unit_failed(unit
);
3317 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3318 zfcp_erp_unit_shutdown(unit
, 0);
3326 ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
3327 "(debug info 0x%x)\n",
3328 header
->fsf_status
);
3329 debug_text_event(adapter
->erp_dbf
, 0, "fsf_s_inval:");
3330 debug_exception(adapter
->erp_dbf
, 0,
3331 &header
->fsf_status
, sizeof (u32
));
3336 atomic_clear_mask(ZFCP_STATUS_COMMON_OPENING
, &unit
->status
);
3341 * function: zfcp_fsf_close_unit
3345 * returns: address of fsf_req - request successfully initiated
3348 * assumptions: This routine does not check whether the associated
3349 * remote port/lun has already been opened. This should be
3350 * done by calling routines. Otherwise some status
3351 * may be presented by FSF
3354 zfcp_fsf_close_unit(struct zfcp_erp_action
*erp_action
)
3356 volatile struct qdio_buffer_element
*sbale
;
3357 struct zfcp_fsf_req
*fsf_req
;
3358 unsigned long lock_flags
;
3361 /* setup new FSF request */
3362 retval
= zfcp_fsf_req_create(erp_action
->adapter
,
3364 ZFCP_WAIT_FOR_SBAL
| ZFCP_REQ_AUTO_CLEANUP
,
3365 erp_action
->adapter
->pool
.fsf_req_erp
,
3366 &lock_flags
, &fsf_req
);
3368 ZFCP_LOG_INFO("error: Could not create close unit request for "
3369 "unit 0x%016Lx on port 0x%016Lx on adapter %s.\n",
3370 erp_action
->unit
->fcp_lun
,
3371 erp_action
->port
->wwpn
,
3372 zfcp_get_busid_by_adapter(erp_action
->adapter
));
3376 sbale
= zfcp_qdio_sbale_req(fsf_req
, fsf_req
->sbal_curr
, 0);
3377 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_READ
;
3378 sbale
[1].flags
|= SBAL_FLAGS_LAST_ENTRY
;
3380 fsf_req
->qtcb
->header
.port_handle
= erp_action
->port
->handle
;
3381 fsf_req
->qtcb
->header
.lun_handle
= erp_action
->unit
->handle
;
3382 atomic_set_mask(ZFCP_STATUS_COMMON_CLOSING
, &erp_action
->unit
->status
);
3383 fsf_req
->data
= (unsigned long) erp_action
->unit
;
3384 fsf_req
->erp_action
= erp_action
;
3385 erp_action
->fsf_req
= fsf_req
;
3387 zfcp_erp_start_timer(fsf_req
);
3388 retval
= zfcp_fsf_req_send(erp_action
->fsf_req
);
3390 ZFCP_LOG_INFO("error: Could not send a close unit request for "
3391 "unit 0x%016Lx on port 0x%016Lx onadapter %s.\n",
3392 erp_action
->unit
->fcp_lun
,
3393 erp_action
->port
->wwpn
,
3394 zfcp_get_busid_by_adapter(erp_action
->adapter
));
3395 zfcp_fsf_req_free(fsf_req
);
3396 erp_action
->fsf_req
= NULL
;
3400 ZFCP_LOG_TRACE("Close LUN request initiated (adapter %s, "
3401 "port 0x%016Lx, unit 0x%016Lx)\n",
3402 zfcp_get_busid_by_adapter(erp_action
->adapter
),
3403 erp_action
->port
->wwpn
, erp_action
->unit
->fcp_lun
);
3405 write_unlock_irqrestore(&erp_action
->adapter
->request_queue
.queue_lock
,
3411 * function: zfcp_fsf_close_unit_handler
3413 * purpose: is called for finished Close LUN FSF command
3418 zfcp_fsf_close_unit_handler(struct zfcp_fsf_req
*fsf_req
)
3420 int retval
= -EINVAL
;
3421 struct zfcp_unit
*unit
;
3423 unit
= (struct zfcp_unit
*) fsf_req
->data
;
3425 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
) {
3426 /* don't change unit status in our bookkeeping */
3427 goto skip_fsfstatus
;
3430 /* evaluate FSF status in QTCB */
3431 switch (fsf_req
->qtcb
->header
.fsf_status
) {
3433 case FSF_PORT_HANDLE_NOT_VALID
:
3434 ZFCP_LOG_INFO("Temporary port identifier 0x%x for port "
3435 "0x%016Lx on adapter %s invalid. This may "
3436 "happen in rare circumstances\n",
3439 zfcp_get_busid_by_unit(unit
));
3440 ZFCP_LOG_DEBUG("status qualifier:\n");
3441 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
3442 (char *) &fsf_req
->qtcb
->header
.fsf_status_qual
,
3443 sizeof (union fsf_status_qual
));
3444 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
3446 zfcp_erp_adapter_reopen(unit
->port
->adapter
, 0);
3447 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3450 case FSF_LUN_HANDLE_NOT_VALID
:
3451 ZFCP_LOG_INFO("Temporary LUN identifier 0x%x of unit "
3452 "0x%016Lx on port 0x%016Lx on adapter %s is "
3453 "invalid. This may happen occasionally.\n",
3457 zfcp_get_busid_by_unit(unit
));
3458 ZFCP_LOG_DEBUG("Status qualifier data:\n");
3459 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
3460 (char *) &fsf_req
->qtcb
->header
.fsf_status_qual
,
3461 sizeof (union fsf_status_qual
));
3462 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
3464 zfcp_erp_port_reopen(unit
->port
, 0);
3465 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3468 case FSF_PORT_BOXED
:
3469 ZFCP_LOG_DEBUG("The remote port 0x%016Lx on adapter %s "
3470 "needs to be reopened\n",
3472 zfcp_get_busid_by_unit(unit
));
3473 debug_text_event(fsf_req
->adapter
->erp_dbf
, 2, "fsf_s_pboxed");
3474 zfcp_erp_port_boxed(unit
->port
);
3475 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
|
3476 ZFCP_STATUS_FSFREQ_RETRY
;
3479 case FSF_ADAPTER_STATUS_AVAILABLE
:
3480 switch (fsf_req
->qtcb
->header
.fsf_status_qual
.word
[0]) {
3481 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE
:
3482 /* re-establish link to port */
3483 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
3485 zfcp_test_link(unit
->port
);
3486 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3488 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED
:
3489 /* ERP strategy will escalate */
3490 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
3492 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3496 ("bug: Wrong status qualifier 0x%x arrived.\n",
3497 fsf_req
->qtcb
->header
.fsf_status_qual
.word
[0]);
3498 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0,
3501 fsf_req
->adapter
->erp_dbf
, 0,
3502 &fsf_req
->qtcb
->header
.fsf_status_qual
.word
[0],
3509 ZFCP_LOG_TRACE("unit 0x%016Lx on port 0x%016Lx on adapter %s "
3510 "closed, port handle 0x%x\n",
3513 zfcp_get_busid_by_unit(unit
),
3515 /* mark unit as closed */
3516 atomic_clear_mask(ZFCP_STATUS_COMMON_OPEN
, &unit
->status
);
3521 ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
3522 "(debug info 0x%x)\n",
3523 fsf_req
->qtcb
->header
.fsf_status
);
3524 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0, "fsf_s_inval:");
3525 debug_exception(fsf_req
->adapter
->erp_dbf
, 0,
3526 &fsf_req
->qtcb
->header
.fsf_status
,
3532 atomic_clear_mask(ZFCP_STATUS_COMMON_CLOSING
, &unit
->status
);
3537 * zfcp_fsf_send_fcp_command_task - initiate an FCP command (for a SCSI command)
3538 * @adapter: adapter where scsi command is issued
3539 * @unit: unit where command is sent to
3540 * @scsi_cmnd: scsi command to be sent
3541 * @timer: timer to be started when request is initiated
3542 * @req_flags: flags for fsf_request
3545 zfcp_fsf_send_fcp_command_task(struct zfcp_adapter
*adapter
,
3546 struct zfcp_unit
*unit
,
3547 struct scsi_cmnd
* scsi_cmnd
,
3548 int use_timer
, int req_flags
)
3550 struct zfcp_fsf_req
*fsf_req
= NULL
;
3551 struct fcp_cmnd_iu
*fcp_cmnd_iu
;
3552 unsigned int sbtype
;
3553 unsigned long lock_flags
;
3558 /* setup new FSF request */
3559 retval
= zfcp_fsf_req_create(adapter
, FSF_QTCB_FCP_CMND
, req_flags
,
3560 adapter
->pool
.fsf_req_scsi
,
3561 &lock_flags
, &fsf_req
);
3562 if (unlikely(retval
< 0)) {
3563 ZFCP_LOG_DEBUG("error: Could not create FCP command request "
3564 "for unit 0x%016Lx on port 0x%016Lx on "
3568 zfcp_get_busid_by_adapter(adapter
));
3569 goto failed_req_create
;
3572 if (unlikely(!atomic_test_mask(ZFCP_STATUS_COMMON_UNBLOCKED
,
3578 zfcp_unit_get(unit
);
3579 fsf_req
->unit
= unit
;
3581 /* associate FSF request with SCSI request (for look up on abort) */
3582 scsi_cmnd
->host_scribble
= (unsigned char *) fsf_req
->req_id
;
3584 /* associate SCSI command with FSF request */
3585 fsf_req
->data
= (unsigned long) scsi_cmnd
;
3587 /* set handles of unit and its parent port in QTCB */
3588 fsf_req
->qtcb
->header
.lun_handle
= unit
->handle
;
3589 fsf_req
->qtcb
->header
.port_handle
= unit
->port
->handle
;
3591 /* FSF does not define the structure of the FCP_CMND IU */
3592 fcp_cmnd_iu
= (struct fcp_cmnd_iu
*)
3593 &(fsf_req
->qtcb
->bottom
.io
.fcp_cmnd
);
3596 * set depending on data direction:
3597 * data direction bits in SBALE (SB Type)
3598 * data direction bits in QTCB
3599 * data direction bits in FCP_CMND IU
3601 switch (scsi_cmnd
->sc_data_direction
) {
3603 fsf_req
->qtcb
->bottom
.io
.data_direction
= FSF_DATADIR_CMND
;
3606 * what is the correct type for commands
3607 * without 'real' data buffers?
3609 sbtype
= SBAL_FLAGS0_TYPE_READ
;
3611 case DMA_FROM_DEVICE
:
3612 fsf_req
->qtcb
->bottom
.io
.data_direction
= FSF_DATADIR_READ
;
3613 sbtype
= SBAL_FLAGS0_TYPE_READ
;
3614 fcp_cmnd_iu
->rddata
= 1;
3617 fsf_req
->qtcb
->bottom
.io
.data_direction
= FSF_DATADIR_WRITE
;
3618 sbtype
= SBAL_FLAGS0_TYPE_WRITE
;
3619 fcp_cmnd_iu
->wddata
= 1;
3621 case DMA_BIDIRECTIONAL
:
3624 * dummy, catch this condition earlier
3625 * in zfcp_scsi_queuecommand
3627 goto failed_scsi_cmnd
;
3630 /* set FC service class in QTCB (3 per default) */
3631 fsf_req
->qtcb
->bottom
.io
.service_class
= ZFCP_FC_SERVICE_CLASS_DEFAULT
;
3633 /* set FCP_LUN in FCP_CMND IU in QTCB */
3634 fcp_cmnd_iu
->fcp_lun
= unit
->fcp_lun
;
3636 mask
= ZFCP_STATUS_UNIT_READONLY
| ZFCP_STATUS_UNIT_SHARED
;
3638 /* set task attributes in FCP_CMND IU in QTCB */
3639 if (likely((scsi_cmnd
->device
->simple_tags
) ||
3640 (atomic_test_mask(mask
, &unit
->status
))))
3641 fcp_cmnd_iu
->task_attribute
= SIMPLE_Q
;
3643 fcp_cmnd_iu
->task_attribute
= UNTAGGED
;
3645 /* set additional length of FCP_CDB in FCP_CMND IU in QTCB, if needed */
3646 if (unlikely(scsi_cmnd
->cmd_len
> FCP_CDB_LENGTH
)) {
3647 fcp_cmnd_iu
->add_fcp_cdb_length
3648 = (scsi_cmnd
->cmd_len
- FCP_CDB_LENGTH
) >> 2;
3649 ZFCP_LOG_TRACE("SCSI CDB length is 0x%x, "
3650 "additional FCP_CDB length is 0x%x "
3651 "(shifted right 2 bits)\n",
3653 fcp_cmnd_iu
->add_fcp_cdb_length
);
3656 * copy SCSI CDB (including additional length, if any) to
3657 * FCP_CDB in FCP_CMND IU in QTCB
3659 memcpy(fcp_cmnd_iu
->fcp_cdb
, scsi_cmnd
->cmnd
, scsi_cmnd
->cmd_len
);
3661 /* FCP CMND IU length in QTCB */
3662 fsf_req
->qtcb
->bottom
.io
.fcp_cmnd_length
=
3663 sizeof (struct fcp_cmnd_iu
) +
3664 fcp_cmnd_iu
->add_fcp_cdb_length
+ sizeof (fcp_dl_t
);
3666 /* generate SBALEs from data buffer */
3667 real_bytes
= zfcp_qdio_sbals_from_scsicmnd(fsf_req
, sbtype
, scsi_cmnd
);
3668 if (unlikely(real_bytes
< 0)) {
3669 if (fsf_req
->sbal_number
< ZFCP_MAX_SBALS_PER_REQ
) {
3671 "Data did not fit into available buffer(s), "
3672 "waiting for more...\n");
3675 ZFCP_LOG_NORMAL("error: No truncation implemented but "
3676 "required. Shutting down unit "
3677 "(adapter %s, port 0x%016Lx, "
3679 zfcp_get_busid_by_unit(unit
),
3682 zfcp_erp_unit_shutdown(unit
, 0);
3688 /* set length of FCP data length in FCP_CMND IU in QTCB */
3689 zfcp_set_fcp_dl(fcp_cmnd_iu
, real_bytes
);
3691 ZFCP_LOG_DEBUG("Sending SCSI command:\n");
3692 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
3693 (char *) scsi_cmnd
->cmnd
, scsi_cmnd
->cmd_len
);
3696 zfcp_fsf_start_timer(fsf_req
, ZFCP_FSF_REQUEST_TIMEOUT
);
3698 retval
= zfcp_fsf_req_send(fsf_req
);
3699 if (unlikely(retval
< 0)) {
3700 ZFCP_LOG_INFO("error: Could not send FCP command request "
3701 "on adapter %s, port 0x%016Lx, unit 0x%016Lx\n",
3702 zfcp_get_busid_by_adapter(adapter
),
3708 ZFCP_LOG_TRACE("Send FCP Command initiated (adapter %s, "
3709 "port 0x%016Lx, unit 0x%016Lx)\n",
3710 zfcp_get_busid_by_adapter(adapter
),
3719 zfcp_unit_put(unit
);
3720 zfcp_fsf_req_free(fsf_req
);
3722 scsi_cmnd
->host_scribble
= NULL
;
3725 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
, lock_flags
);
3729 struct zfcp_fsf_req
*
3730 zfcp_fsf_send_fcp_command_task_management(struct zfcp_adapter
*adapter
,
3731 struct zfcp_unit
*unit
,
3732 u8 tm_flags
, int req_flags
)
3734 struct zfcp_fsf_req
*fsf_req
= NULL
;
3736 struct fcp_cmnd_iu
*fcp_cmnd_iu
;
3737 unsigned long lock_flags
;
3738 volatile struct qdio_buffer_element
*sbale
;
3740 /* setup new FSF request */
3741 retval
= zfcp_fsf_req_create(adapter
, FSF_QTCB_FCP_CMND
, req_flags
,
3742 adapter
->pool
.fsf_req_scsi
,
3743 &lock_flags
, &fsf_req
);
3745 ZFCP_LOG_INFO("error: Could not create FCP command (task "
3746 "management) request for adapter %s, port "
3747 " 0x%016Lx, unit 0x%016Lx.\n",
3748 zfcp_get_busid_by_adapter(adapter
),
3749 unit
->port
->wwpn
, unit
->fcp_lun
);
3753 if (unlikely(!atomic_test_mask(ZFCP_STATUS_COMMON_UNBLOCKED
,
3758 * Used to decide on proper handler in the return path,
3759 * could be either zfcp_fsf_send_fcp_command_task_handler or
3760 * zfcp_fsf_send_fcp_command_task_management_handler */
3762 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT
;
3765 * hold a pointer to the unit being target of this
3766 * task management request
3768 fsf_req
->data
= (unsigned long) unit
;
3770 /* set FSF related fields in QTCB */
3771 fsf_req
->qtcb
->header
.lun_handle
= unit
->handle
;
3772 fsf_req
->qtcb
->header
.port_handle
= unit
->port
->handle
;
3773 fsf_req
->qtcb
->bottom
.io
.data_direction
= FSF_DATADIR_CMND
;
3774 fsf_req
->qtcb
->bottom
.io
.service_class
= ZFCP_FC_SERVICE_CLASS_DEFAULT
;
3775 fsf_req
->qtcb
->bottom
.io
.fcp_cmnd_length
=
3776 sizeof (struct fcp_cmnd_iu
) + sizeof (fcp_dl_t
);
3778 sbale
= zfcp_qdio_sbale_req(fsf_req
, fsf_req
->sbal_curr
, 0);
3779 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_WRITE
;
3780 sbale
[1].flags
|= SBAL_FLAGS_LAST_ENTRY
;
3782 /* set FCP related fields in FCP_CMND IU in QTCB */
3783 fcp_cmnd_iu
= (struct fcp_cmnd_iu
*)
3784 &(fsf_req
->qtcb
->bottom
.io
.fcp_cmnd
);
3785 fcp_cmnd_iu
->fcp_lun
= unit
->fcp_lun
;
3786 fcp_cmnd_iu
->task_management_flags
= tm_flags
;
3788 zfcp_fsf_start_timer(fsf_req
, ZFCP_SCSI_ER_TIMEOUT
);
3789 retval
= zfcp_fsf_req_send(fsf_req
);
3794 zfcp_fsf_req_free(fsf_req
);
3798 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
, lock_flags
);
3803 * function: zfcp_fsf_send_fcp_command_handler
3805 * purpose: is called for finished Send FCP Command
3810 zfcp_fsf_send_fcp_command_handler(struct zfcp_fsf_req
*fsf_req
)
3812 int retval
= -EINVAL
;
3813 struct zfcp_unit
*unit
;
3814 struct fsf_qtcb_header
*header
;
3815 u16 subtable
, rule
, counter
;
3817 header
= &fsf_req
->qtcb
->header
;
3819 if (unlikely(fsf_req
->status
& ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT
))
3820 unit
= (struct zfcp_unit
*) fsf_req
->data
;
3822 unit
= fsf_req
->unit
;
3824 if (unlikely(fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
)) {
3825 /* go directly to calls of special handlers */
3826 goto skip_fsfstatus
;
3829 /* evaluate FSF status in QTCB */
3830 switch (header
->fsf_status
) {
3832 case FSF_PORT_HANDLE_NOT_VALID
:
3833 ZFCP_LOG_INFO("Temporary port identifier 0x%x for port "
3834 "0x%016Lx on adapter %s invalid\n",
3836 unit
->port
->wwpn
, zfcp_get_busid_by_unit(unit
));
3837 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
3838 (char *) &header
->fsf_status_qual
,
3839 sizeof (union fsf_status_qual
));
3840 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
3842 zfcp_erp_adapter_reopen(unit
->port
->adapter
, 0);
3843 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3846 case FSF_LUN_HANDLE_NOT_VALID
:
3847 ZFCP_LOG_INFO("Temporary LUN identifier 0x%x for unit "
3848 "0x%016Lx on port 0x%016Lx on adapter %s is "
3849 "invalid. This may happen occasionally.\n",
3853 zfcp_get_busid_by_unit(unit
));
3854 ZFCP_LOG_NORMAL("Status qualifier data:\n");
3855 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_NORMAL
,
3856 (char *) &header
->fsf_status_qual
,
3857 sizeof (union fsf_status_qual
));
3858 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
3860 zfcp_erp_port_reopen(unit
->port
, 0);
3861 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3864 case FSF_HANDLE_MISMATCH
:
3865 ZFCP_LOG_NORMAL("bug: The port handle 0x%x has changed "
3866 "unexpectedly. (adapter %s, port 0x%016Lx, "
3869 zfcp_get_busid_by_unit(unit
),
3872 ZFCP_LOG_NORMAL("status qualifier:\n");
3873 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_NORMAL
,
3874 (char *) &header
->fsf_status_qual
,
3875 sizeof (union fsf_status_qual
));
3876 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
3878 zfcp_erp_adapter_reopen(unit
->port
->adapter
, 0);
3879 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3882 case FSF_SERVICE_CLASS_NOT_SUPPORTED
:
3883 ZFCP_LOG_INFO("error: adapter %s does not support fc "
3885 zfcp_get_busid_by_unit(unit
),
3886 ZFCP_FC_SERVICE_CLASS_DEFAULT
);
3887 /* stop operation for this adapter */
3888 debug_text_exception(fsf_req
->adapter
->erp_dbf
, 0,
3889 "fsf_s_class_nsup");
3890 zfcp_erp_adapter_shutdown(unit
->port
->adapter
, 0);
3891 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3894 case FSF_FCPLUN_NOT_VALID
:
3895 ZFCP_LOG_NORMAL("bug: unit 0x%016Lx on port 0x%016Lx on "
3896 "adapter %s does not have correct unit "
3900 zfcp_get_busid_by_unit(unit
),
3902 ZFCP_LOG_DEBUG("status qualifier:\n");
3903 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
3904 (char *) &header
->fsf_status_qual
,
3905 sizeof (union fsf_status_qual
));
3906 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
3907 "fsf_s_fcp_lun_nv");
3908 zfcp_erp_port_reopen(unit
->port
, 0);
3909 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3912 case FSF_ACCESS_DENIED
:
3913 ZFCP_LOG_NORMAL("Access denied, cannot send FCP command to "
3914 "unit 0x%016Lx on port 0x%016Lx on "
3915 "adapter %s\n", unit
->fcp_lun
, unit
->port
->wwpn
,
3916 zfcp_get_busid_by_unit(unit
));
3917 for (counter
= 0; counter
< 2; counter
++) {
3918 subtable
= header
->fsf_status_qual
.halfword
[counter
* 2];
3919 rule
= header
->fsf_status_qual
.halfword
[counter
* 2 + 1];
3921 case FSF_SQ_CFDC_SUBTABLE_OS
:
3922 case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN
:
3923 case FSF_SQ_CFDC_SUBTABLE_PORT_DID
:
3924 case FSF_SQ_CFDC_SUBTABLE_LUN
:
3925 ZFCP_LOG_INFO("Access denied (%s rule %d)\n",
3926 zfcp_act_subtable_type
[subtable
], rule
);
3930 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1, "fsf_s_access");
3931 zfcp_erp_unit_access_denied(unit
);
3932 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3935 case FSF_DIRECTION_INDICATOR_NOT_VALID
:
3936 ZFCP_LOG_INFO("bug: Invalid data direction given for unit "
3937 "0x%016Lx on port 0x%016Lx on adapter %s "
3938 "(debug info %d)\n",
3941 zfcp_get_busid_by_unit(unit
),
3942 fsf_req
->qtcb
->bottom
.io
.data_direction
);
3943 /* stop operation for this adapter */
3944 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0,
3945 "fsf_s_dir_ind_nv");
3946 zfcp_erp_adapter_shutdown(unit
->port
->adapter
, 0);
3947 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3950 case FSF_CMND_LENGTH_NOT_VALID
:
3952 ("bug: An invalid control-data-block length field "
3953 "was found in a command for unit 0x%016Lx on port "
3954 "0x%016Lx on adapter %s " "(debug info %d)\n",
3955 unit
->fcp_lun
, unit
->port
->wwpn
,
3956 zfcp_get_busid_by_unit(unit
),
3957 fsf_req
->qtcb
->bottom
.io
.fcp_cmnd_length
);
3958 /* stop operation for this adapter */
3959 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0,
3960 "fsf_s_cmd_len_nv");
3961 zfcp_erp_adapter_shutdown(unit
->port
->adapter
, 0);
3962 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3965 case FSF_PORT_BOXED
:
3966 ZFCP_LOG_DEBUG("The remote port 0x%016Lx on adapter %s "
3967 "needs to be reopened\n",
3968 unit
->port
->wwpn
, zfcp_get_busid_by_unit(unit
));
3969 debug_text_event(fsf_req
->adapter
->erp_dbf
, 2, "fsf_s_pboxed");
3970 zfcp_erp_port_boxed(unit
->port
);
3971 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
|
3972 ZFCP_STATUS_FSFREQ_RETRY
;
3976 ZFCP_LOG_NORMAL("unit needs to be reopened (adapter %s, "
3977 "wwpn=0x%016Lx, fcp_lun=0x%016Lx)\n",
3978 zfcp_get_busid_by_unit(unit
),
3979 unit
->port
->wwpn
, unit
->fcp_lun
);
3980 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1, "fsf_s_lboxed");
3981 zfcp_erp_unit_boxed(unit
);
3982 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
3983 | ZFCP_STATUS_FSFREQ_RETRY
;
3986 case FSF_ADAPTER_STATUS_AVAILABLE
:
3987 switch (header
->fsf_status_qual
.word
[0]) {
3988 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE
:
3989 /* re-establish link to port */
3990 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
3992 zfcp_test_link(unit
->port
);
3994 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED
:
3995 /* FIXME(hw) need proper specs for proper action */
3996 /* let scsi stack deal with retries and escalation */
3997 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
4002 ("Unknown status qualifier 0x%x arrived.\n",
4003 header
->fsf_status_qual
.word
[0]);
4004 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0,
4006 debug_exception(fsf_req
->adapter
->erp_dbf
, 0,
4007 &header
->fsf_status_qual
.word
[0],
4011 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4017 case FSF_FCP_RSP_AVAILABLE
:
4021 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0, "fsf_s_inval:");
4022 debug_exception(fsf_req
->adapter
->erp_dbf
, 0,
4023 &header
->fsf_status
, sizeof(u32
));
4028 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT
) {
4030 zfcp_fsf_send_fcp_command_task_management_handler(fsf_req
);
4032 retval
= zfcp_fsf_send_fcp_command_task_handler(fsf_req
);
4033 fsf_req
->unit
= NULL
;
4034 zfcp_unit_put(unit
);
4040 * function: zfcp_fsf_send_fcp_command_task_handler
4042 * purpose: evaluates FCP_RSP IU
4047 zfcp_fsf_send_fcp_command_task_handler(struct zfcp_fsf_req
*fsf_req
)
4050 struct scsi_cmnd
*scpnt
;
4051 struct fcp_rsp_iu
*fcp_rsp_iu
= (struct fcp_rsp_iu
*)
4052 &(fsf_req
->qtcb
->bottom
.io
.fcp_rsp
);
4053 struct fcp_cmnd_iu
*fcp_cmnd_iu
= (struct fcp_cmnd_iu
*)
4054 &(fsf_req
->qtcb
->bottom
.io
.fcp_cmnd
);
4056 char *fcp_rsp_info
= zfcp_get_fcp_rsp_info_ptr(fcp_rsp_iu
);
4057 unsigned long flags
;
4058 struct zfcp_unit
*unit
= fsf_req
->unit
;
4060 read_lock_irqsave(&fsf_req
->adapter
->abort_lock
, flags
);
4061 scpnt
= (struct scsi_cmnd
*) fsf_req
->data
;
4062 if (unlikely(!scpnt
)) {
4064 ("Command with fsf_req %p is not associated to "
4065 "a scsi command anymore. Aborted?\n", fsf_req
);
4068 if (unlikely(fsf_req
->status
& ZFCP_STATUS_FSFREQ_ABORTED
)) {
4069 /* FIXME: (design) mid-layer should handle DID_ABORT like
4070 * DID_SOFT_ERROR by retrying the request for devices
4071 * that allow retries.
4073 ZFCP_LOG_DEBUG("Setting DID_SOFT_ERROR and SUGGEST_RETRY\n");
4074 set_host_byte(&scpnt
->result
, DID_SOFT_ERROR
);
4075 set_driver_byte(&scpnt
->result
, SUGGEST_RETRY
);
4076 goto skip_fsfstatus
;
4079 if (unlikely(fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
)) {
4080 ZFCP_LOG_DEBUG("Setting DID_ERROR\n");
4081 set_host_byte(&scpnt
->result
, DID_ERROR
);
4082 goto skip_fsfstatus
;
4085 /* set message byte of result in SCSI command */
4086 scpnt
->result
|= COMMAND_COMPLETE
<< 8;
4089 * copy SCSI status code of FCP_STATUS of FCP_RSP IU to status byte
4090 * of result in SCSI command
4092 scpnt
->result
|= fcp_rsp_iu
->scsi_status
;
4093 if (unlikely(fcp_rsp_iu
->scsi_status
)) {
4095 ZFCP_LOG_DEBUG("status for SCSI Command:\n");
4096 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
4097 scpnt
->cmnd
, scpnt
->cmd_len
);
4098 ZFCP_LOG_DEBUG("SCSI status code 0x%x\n",
4099 fcp_rsp_iu
->scsi_status
);
4100 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
4101 (void *) fcp_rsp_iu
, sizeof (struct fcp_rsp_iu
));
4102 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
4103 zfcp_get_fcp_sns_info_ptr(fcp_rsp_iu
),
4104 fcp_rsp_iu
->fcp_sns_len
);
4107 /* check FCP_RSP_INFO */
4108 if (unlikely(fcp_rsp_iu
->validity
.bits
.fcp_rsp_len_valid
)) {
4109 ZFCP_LOG_DEBUG("rsp_len is valid\n");
4110 switch (fcp_rsp_info
[3]) {
4113 ZFCP_LOG_TRACE("no failure or Task Management "
4114 "Function complete\n");
4115 set_host_byte(&scpnt
->result
, DID_OK
);
4117 case RSP_CODE_LENGTH_MISMATCH
:
4119 ZFCP_LOG_NORMAL("bug: FCP response code indictates "
4120 "that the fibrechannel protocol data "
4121 "length differs from the burst length. "
4122 "The problem occured on unit 0x%016Lx "
4123 "on port 0x%016Lx on adapter %s",
4126 zfcp_get_busid_by_unit(unit
));
4127 /* dump SCSI CDB as prepared by zfcp */
4128 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
4129 (char *) &fsf_req
->qtcb
->
4130 bottom
.io
.fcp_cmnd
, FSF_FCP_CMND_SIZE
);
4131 set_host_byte(&scpnt
->result
, DID_ERROR
);
4132 goto skip_fsfstatus
;
4133 case RSP_CODE_FIELD_INVALID
:
4134 /* driver or hardware bug */
4135 ZFCP_LOG_NORMAL("bug: FCP response code indictates "
4136 "that the fibrechannel protocol data "
4137 "fields were incorrectly set up. "
4138 "The problem occured on the unit "
4139 "0x%016Lx on port 0x%016Lx on "
4143 zfcp_get_busid_by_unit(unit
));
4144 /* dump SCSI CDB as prepared by zfcp */
4145 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
4146 (char *) &fsf_req
->qtcb
->
4147 bottom
.io
.fcp_cmnd
, FSF_FCP_CMND_SIZE
);
4148 set_host_byte(&scpnt
->result
, DID_ERROR
);
4149 goto skip_fsfstatus
;
4150 case RSP_CODE_RO_MISMATCH
:
4152 ZFCP_LOG_NORMAL("bug: The FCP response code indicates "
4153 "that conflicting values for the "
4154 "fibrechannel payload offset from the "
4155 "header were found. "
4156 "The problem occured on unit 0x%016Lx "
4157 "on port 0x%016Lx on adapter %s.\n",
4160 zfcp_get_busid_by_unit(unit
));
4161 /* dump SCSI CDB as prepared by zfcp */
4162 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
4163 (char *) &fsf_req
->qtcb
->
4164 bottom
.io
.fcp_cmnd
, FSF_FCP_CMND_SIZE
);
4165 set_host_byte(&scpnt
->result
, DID_ERROR
);
4166 goto skip_fsfstatus
;
4168 ZFCP_LOG_NORMAL("bug: An invalid FCP response "
4169 "code was detected for a command. "
4170 "The problem occured on the unit "
4171 "0x%016Lx on port 0x%016Lx on "
4172 "adapter %s (debug info 0x%x)\n",
4175 zfcp_get_busid_by_unit(unit
),
4177 /* dump SCSI CDB as prepared by zfcp */
4178 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
4179 (char *) &fsf_req
->qtcb
->
4180 bottom
.io
.fcp_cmnd
, FSF_FCP_CMND_SIZE
);
4181 set_host_byte(&scpnt
->result
, DID_ERROR
);
4182 goto skip_fsfstatus
;
4186 /* check for sense data */
4187 if (unlikely(fcp_rsp_iu
->validity
.bits
.fcp_sns_len_valid
)) {
4188 sns_len
= FSF_FCP_RSP_SIZE
-
4189 sizeof (struct fcp_rsp_iu
) + fcp_rsp_iu
->fcp_rsp_len
;
4190 ZFCP_LOG_TRACE("room for %i bytes sense data in QTCB\n",
4192 sns_len
= min(sns_len
, (u32
) SCSI_SENSE_BUFFERSIZE
);
4193 ZFCP_LOG_TRACE("room for %i bytes sense data in SCSI command\n",
4194 SCSI_SENSE_BUFFERSIZE
);
4195 sns_len
= min(sns_len
, fcp_rsp_iu
->fcp_sns_len
);
4196 ZFCP_LOG_TRACE("scpnt->result =0x%x, command was:\n",
4198 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_TRACE
,
4199 (void *) &scpnt
->cmnd
, scpnt
->cmd_len
);
4201 ZFCP_LOG_TRACE("%i bytes sense data provided by FCP\n",
4202 fcp_rsp_iu
->fcp_sns_len
);
4203 memcpy(scpnt
->sense_buffer
,
4204 zfcp_get_fcp_sns_info_ptr(fcp_rsp_iu
), sns_len
);
4205 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_TRACE
,
4206 (void *)scpnt
->sense_buffer
, sns_len
);
4209 /* check for overrun */
4210 if (unlikely(fcp_rsp_iu
->validity
.bits
.fcp_resid_over
)) {
4211 ZFCP_LOG_INFO("A data overrun was detected for a command. "
4212 "unit 0x%016Lx, port 0x%016Lx, adapter %s. "
4213 "The response data length is "
4214 "%d, the original length was %d.\n",
4217 zfcp_get_busid_by_unit(unit
),
4218 fcp_rsp_iu
->fcp_resid
,
4219 (int) zfcp_get_fcp_dl(fcp_cmnd_iu
));
4222 /* check for underrun */
4223 if (unlikely(fcp_rsp_iu
->validity
.bits
.fcp_resid_under
)) {
4224 ZFCP_LOG_INFO("A data underrun was detected for a command. "
4225 "unit 0x%016Lx, port 0x%016Lx, adapter %s. "
4226 "The response data length is "
4227 "%d, the original length was %d.\n",
4230 zfcp_get_busid_by_unit(unit
),
4231 fcp_rsp_iu
->fcp_resid
,
4232 (int) zfcp_get_fcp_dl(fcp_cmnd_iu
));
4234 scsi_set_resid(scpnt
, fcp_rsp_iu
->fcp_resid
);
4235 if (scsi_bufflen(scpnt
) - scsi_get_resid(scpnt
) <
4237 set_host_byte(&scpnt
->result
, DID_ERROR
);
4241 ZFCP_LOG_DEBUG("scpnt->result =0x%x\n", scpnt
->result
);
4243 if (scpnt
->result
!= 0)
4244 zfcp_scsi_dbf_event_result("erro", 3, fsf_req
->adapter
, scpnt
, fsf_req
);
4245 else if (scpnt
->retries
> 0)
4246 zfcp_scsi_dbf_event_result("retr", 4, fsf_req
->adapter
, scpnt
, fsf_req
);
4248 zfcp_scsi_dbf_event_result("norm", 6, fsf_req
->adapter
, scpnt
, fsf_req
);
4250 /* cleanup pointer (need this especially for abort) */
4251 scpnt
->host_scribble
= NULL
;
4253 /* always call back */
4254 (scpnt
->scsi_done
) (scpnt
);
4257 * We must hold this lock until scsi_done has been called.
4258 * Otherwise we may call scsi_done after abort regarding this
4259 * command has completed.
4260 * Note: scsi_done must not block!
4263 read_unlock_irqrestore(&fsf_req
->adapter
->abort_lock
, flags
);
4268 * function: zfcp_fsf_send_fcp_command_task_management_handler
4270 * purpose: evaluates FCP_RSP IU
4275 zfcp_fsf_send_fcp_command_task_management_handler(struct zfcp_fsf_req
*fsf_req
)
4278 struct fcp_rsp_iu
*fcp_rsp_iu
= (struct fcp_rsp_iu
*)
4279 &(fsf_req
->qtcb
->bottom
.io
.fcp_rsp
);
4280 char *fcp_rsp_info
= zfcp_get_fcp_rsp_info_ptr(fcp_rsp_iu
);
4281 struct zfcp_unit
*unit
= (struct zfcp_unit
*) fsf_req
->data
;
4283 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
) {
4284 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_TMFUNCFAILED
;
4285 goto skip_fsfstatus
;
4288 /* check FCP_RSP_INFO */
4289 switch (fcp_rsp_info
[3]) {
4292 ZFCP_LOG_DEBUG("no failure or Task Management "
4293 "Function complete\n");
4295 case RSP_CODE_TASKMAN_UNSUPP
:
4296 ZFCP_LOG_NORMAL("bug: A reuested task management function "
4297 "is not supported on the target device "
4298 "unit 0x%016Lx, port 0x%016Lx, adapter %s\n ",
4301 zfcp_get_busid_by_unit(unit
));
4302 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_TMFUNCNOTSUPP
;
4304 case RSP_CODE_TASKMAN_FAILED
:
4305 ZFCP_LOG_NORMAL("bug: A reuested task management function "
4306 "failed to complete successfully. "
4307 "unit 0x%016Lx, port 0x%016Lx, adapter %s.\n",
4310 zfcp_get_busid_by_unit(unit
));
4311 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_TMFUNCFAILED
;
4314 ZFCP_LOG_NORMAL("bug: An invalid FCP response "
4315 "code was detected for a command. "
4316 "unit 0x%016Lx, port 0x%016Lx, adapter %s "
4317 "(debug info 0x%x)\n",
4320 zfcp_get_busid_by_unit(unit
),
4322 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_TMFUNCFAILED
;
4331 * function: zfcp_fsf_control_file
4333 * purpose: Initiator of the control file upload/download FSF requests
4335 * returns: 0 - FSF request is successfuly created and queued
4336 * -EOPNOTSUPP - The FCP adapter does not have Control File support
4337 * -EINVAL - Invalid direction specified
4338 * -ENOMEM - Insufficient memory
4339 * -EPERM - Cannot create FSF request or place it in QDIO queue
4342 zfcp_fsf_control_file(struct zfcp_adapter
*adapter
,
4343 struct zfcp_fsf_req
**fsf_req_ptr
,
4346 struct zfcp_sg_list
*sg_list
)
4348 struct zfcp_fsf_req
*fsf_req
;
4349 struct fsf_qtcb_bottom_support
*bottom
;
4350 volatile struct qdio_buffer_element
*sbale
;
4351 unsigned long lock_flags
;
4356 if (!(adapter
->adapter_features
& FSF_FEATURE_CFDC
)) {
4357 ZFCP_LOG_INFO("cfdc not supported (adapter %s)\n",
4358 zfcp_get_busid_by_adapter(adapter
));
4359 retval
= -EOPNOTSUPP
;
4363 switch (fsf_command
) {
4365 case FSF_QTCB_DOWNLOAD_CONTROL_FILE
:
4366 direction
= SBAL_FLAGS0_TYPE_WRITE
;
4367 if ((option
!= FSF_CFDC_OPTION_FULL_ACCESS
) &&
4368 (option
!= FSF_CFDC_OPTION_RESTRICTED_ACCESS
))
4369 req_flags
= ZFCP_WAIT_FOR_SBAL
;
4372 case FSF_QTCB_UPLOAD_CONTROL_FILE
:
4373 direction
= SBAL_FLAGS0_TYPE_READ
;
4377 ZFCP_LOG_INFO("Invalid FSF command code 0x%08x\n", fsf_command
);
4382 retval
= zfcp_fsf_req_create(adapter
, fsf_command
, req_flags
,
4383 NULL
, &lock_flags
, &fsf_req
);
4385 ZFCP_LOG_INFO("error: Could not create FSF request for the "
4387 zfcp_get_busid_by_adapter(adapter
));
4389 goto unlock_queue_lock
;
4392 sbale
= zfcp_qdio_sbale_req(fsf_req
, fsf_req
->sbal_curr
, 0);
4393 sbale
[0].flags
|= direction
;
4395 bottom
= &fsf_req
->qtcb
->bottom
.support
;
4396 bottom
->operation_subtype
= FSF_CFDC_OPERATION_SUBTYPE
;
4397 bottom
->option
= option
;
4399 if (sg_list
->count
> 0) {
4402 bytes
= zfcp_qdio_sbals_from_sg(fsf_req
, direction
,
4403 sg_list
->sg
, sg_list
->count
,
4404 ZFCP_MAX_SBALS_PER_REQ
);
4405 if (bytes
!= ZFCP_CFDC_MAX_CONTROL_FILE_SIZE
) {
4407 "error: Could not create sufficient number of "
4408 "SBALS for an FSF request to the adapter %s\n",
4409 zfcp_get_busid_by_adapter(adapter
));
4414 sbale
[1].flags
|= SBAL_FLAGS_LAST_ENTRY
;
4416 zfcp_fsf_start_timer(fsf_req
, ZFCP_FSF_REQUEST_TIMEOUT
);
4417 retval
= zfcp_fsf_req_send(fsf_req
);
4419 ZFCP_LOG_INFO("initiation of cfdc up/download failed"
4421 zfcp_get_busid_by_adapter(adapter
));
4425 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
, lock_flags
);
4427 ZFCP_LOG_NORMAL("Control file %s FSF request has been sent to the "
4429 fsf_command
== FSF_QTCB_DOWNLOAD_CONTROL_FILE
?
4430 "download" : "upload",
4431 zfcp_get_busid_by_adapter(adapter
));
4433 wait_event(fsf_req
->completion_wq
,
4434 fsf_req
->status
& ZFCP_STATUS_FSFREQ_COMPLETED
);
4436 *fsf_req_ptr
= fsf_req
;
4440 zfcp_fsf_req_free(fsf_req
);
4442 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
, lock_flags
);
4449 * function: zfcp_fsf_control_file_handler
4451 * purpose: Handler of the control file upload/download FSF requests
4453 * returns: 0 - FSF request successfuly processed
4454 * -EAGAIN - Operation has to be repeated because of a temporary problem
4455 * -EACCES - There is no permission to execute an operation
4456 * -EPERM - The control file is not in a right format
4457 * -EIO - There is a problem with the FCP adapter
4458 * -EINVAL - Invalid operation
4459 * -EFAULT - User space memory I/O operation fault
4462 zfcp_fsf_control_file_handler(struct zfcp_fsf_req
*fsf_req
)
4464 struct zfcp_adapter
*adapter
= fsf_req
->adapter
;
4465 struct fsf_qtcb_header
*header
= &fsf_req
->qtcb
->header
;
4466 struct fsf_qtcb_bottom_support
*bottom
= &fsf_req
->qtcb
->bottom
.support
;
4469 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
) {
4471 goto skip_fsfstatus
;
4474 switch (header
->fsf_status
) {
4478 "The FSF request has been successfully completed "
4479 "on the adapter %s\n",
4480 zfcp_get_busid_by_adapter(adapter
));
4483 case FSF_OPERATION_PARTIALLY_SUCCESSFUL
:
4484 if (bottom
->operation_subtype
== FSF_CFDC_OPERATION_SUBTYPE
) {
4485 switch (header
->fsf_status_qual
.word
[0]) {
4487 case FSF_SQ_CFDC_HARDENED_ON_SE
:
4489 "CFDC on the adapter %s has being "
4490 "hardened on primary and secondary SE\n",
4491 zfcp_get_busid_by_adapter(adapter
));
4494 case FSF_SQ_CFDC_COULD_NOT_HARDEN_ON_SE
:
4496 "CFDC of the adapter %s could not "
4497 "be saved on the SE\n",
4498 zfcp_get_busid_by_adapter(adapter
));
4501 case FSF_SQ_CFDC_COULD_NOT_HARDEN_ON_SE2
:
4503 "CFDC of the adapter %s could not "
4504 "be copied to the secondary SE\n",
4505 zfcp_get_busid_by_adapter(adapter
));
4510 "CFDC could not be hardened "
4511 "on the adapter %s\n",
4512 zfcp_get_busid_by_adapter(adapter
));
4515 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4519 case FSF_AUTHORIZATION_FAILURE
:
4521 "Adapter %s does not accept privileged commands\n",
4522 zfcp_get_busid_by_adapter(adapter
));
4523 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4527 case FSF_CFDC_ERROR_DETECTED
:
4529 "Error at position %d in the CFDC, "
4530 "CFDC is discarded by the adapter %s\n",
4531 header
->fsf_status_qual
.word
[0],
4532 zfcp_get_busid_by_adapter(adapter
));
4533 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4537 case FSF_CONTROL_FILE_UPDATE_ERROR
:
4539 "Adapter %s cannot harden the control file, "
4540 "file is discarded\n",
4541 zfcp_get_busid_by_adapter(adapter
));
4542 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4546 case FSF_CONTROL_FILE_TOO_LARGE
:
4548 "Control file is too large, file is discarded "
4549 "by the adapter %s\n",
4550 zfcp_get_busid_by_adapter(adapter
));
4551 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4555 case FSF_ACCESS_CONFLICT_DETECTED
:
4556 if (bottom
->operation_subtype
== FSF_CFDC_OPERATION_SUBTYPE
)
4558 "CFDC has been discarded by the adapter %s, "
4559 "because activation would impact "
4560 "%d active connection(s)\n",
4561 zfcp_get_busid_by_adapter(adapter
),
4562 header
->fsf_status_qual
.word
[0]);
4563 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4567 case FSF_CONFLICTS_OVERRULED
:
4568 if (bottom
->operation_subtype
== FSF_CFDC_OPERATION_SUBTYPE
)
4570 "CFDC has been activated on the adapter %s, "
4571 "but activation has impacted "
4572 "%d active connection(s)\n",
4573 zfcp_get_busid_by_adapter(adapter
),
4574 header
->fsf_status_qual
.word
[0]);
4575 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4579 case FSF_UNKNOWN_OP_SUBTYPE
:
4580 ZFCP_LOG_NORMAL("unknown operation subtype (adapter: %s, "
4581 "op_subtype=0x%x)\n",
4582 zfcp_get_busid_by_adapter(adapter
),
4583 bottom
->operation_subtype
);
4584 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4588 case FSF_INVALID_COMMAND_OPTION
:
4590 "Invalid option 0x%x has been specified "
4591 "in QTCB bottom sent to the adapter %s\n",
4593 zfcp_get_busid_by_adapter(adapter
));
4594 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4600 "bug: An unknown/unexpected FSF status 0x%08x "
4601 "was presented on the adapter %s\n",
4603 zfcp_get_busid_by_adapter(adapter
));
4604 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0, "fsf_sq_inval");
4605 debug_exception(fsf_req
->adapter
->erp_dbf
, 0,
4606 &header
->fsf_status_qual
.word
[0], sizeof(u32
));
4607 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4617 zfcp_fsf_req_sbal_check(unsigned long *flags
,
4618 struct zfcp_qdio_queue
*queue
, int needed
)
4620 write_lock_irqsave(&queue
->queue_lock
, *flags
);
4621 if (likely(atomic_read(&queue
->free_count
) >= needed
))
4623 write_unlock_irqrestore(&queue
->queue_lock
, *flags
);
4628 * set qtcb pointer in fsf_req and initialize QTCB
4631 zfcp_fsf_req_qtcb_init(struct zfcp_fsf_req
*fsf_req
)
4633 if (likely(fsf_req
->qtcb
!= NULL
)) {
4634 fsf_req
->qtcb
->prefix
.req_seq_no
=
4635 fsf_req
->adapter
->fsf_req_seq_no
;
4636 fsf_req
->qtcb
->prefix
.req_id
= fsf_req
->req_id
;
4637 fsf_req
->qtcb
->prefix
.ulp_info
= ZFCP_ULP_INFO_VERSION
;
4638 fsf_req
->qtcb
->prefix
.qtcb_type
=
4639 fsf_qtcb_type
[fsf_req
->fsf_command
];
4640 fsf_req
->qtcb
->prefix
.qtcb_version
= ZFCP_QTCB_VERSION
;
4641 fsf_req
->qtcb
->header
.req_handle
= fsf_req
->req_id
;
4642 fsf_req
->qtcb
->header
.fsf_command
= fsf_req
->fsf_command
;
4647 * zfcp_fsf_req_sbal_get - try to get one SBAL in the request queue
4648 * @adapter: adapter for which request queue is examined
4649 * @req_flags: flags indicating whether to wait for needed SBAL or not
4650 * @lock_flags: lock_flags if queue_lock is taken
4651 * Return: 0 on success, otherwise -EIO, or -ERESTARTSYS
4652 * Locks: lock adapter->request_queue->queue_lock on success
4655 zfcp_fsf_req_sbal_get(struct zfcp_adapter
*adapter
, int req_flags
,
4656 unsigned long *lock_flags
)
4659 struct zfcp_qdio_queue
*req_queue
= &adapter
->request_queue
;
4661 if (unlikely(req_flags
& ZFCP_WAIT_FOR_SBAL
)) {
4662 ret
= wait_event_interruptible_timeout(adapter
->request_wq
,
4663 zfcp_fsf_req_sbal_check(lock_flags
, req_queue
, 1),
4669 } else if (!zfcp_fsf_req_sbal_check(lock_flags
, req_queue
, 1))
4676 * function: zfcp_fsf_req_create
4678 * purpose: create an FSF request at the specified adapter and
4679 * setup common fields
4681 * returns: -ENOMEM if there was insufficient memory for a request
4682 * -EIO if no qdio buffers could be allocate to the request
4683 * -EINVAL/-EPERM on bug conditions in req_dequeue
4686 * note: The created request is returned by reference.
4688 * locks: lock of concerned request queue must not be held,
4689 * but is held on completion (write, irqsave)
4692 zfcp_fsf_req_create(struct zfcp_adapter
*adapter
, u32 fsf_cmd
, int req_flags
,
4693 mempool_t
*pool
, unsigned long *lock_flags
,
4694 struct zfcp_fsf_req
**fsf_req_p
)
4696 volatile struct qdio_buffer_element
*sbale
;
4697 struct zfcp_fsf_req
*fsf_req
= NULL
;
4699 struct zfcp_qdio_queue
*req_queue
= &adapter
->request_queue
;
4701 /* allocate new FSF request */
4702 fsf_req
= zfcp_fsf_req_alloc(pool
, req_flags
);
4703 if (unlikely(NULL
== fsf_req
)) {
4704 ZFCP_LOG_DEBUG("error: Could not put an FSF request into "
4705 "the outbound (send) queue.\n");
4707 goto failed_fsf_req
;
4710 fsf_req
->adapter
= adapter
;
4711 fsf_req
->fsf_command
= fsf_cmd
;
4712 INIT_LIST_HEAD(&fsf_req
->list
);
4713 init_timer(&fsf_req
->timer
);
4715 /* initialize waitqueue which may be used to wait on
4716 this request completion */
4717 init_waitqueue_head(&fsf_req
->completion_wq
);
4719 ret
= zfcp_fsf_req_sbal_get(adapter
, req_flags
, lock_flags
);
4723 /* this is serialized (we are holding req_queue-lock of adapter) */
4724 if (adapter
->req_no
== 0)
4726 fsf_req
->req_id
= adapter
->req_no
++;
4728 zfcp_fsf_req_qtcb_init(fsf_req
);
4731 * We hold queue_lock here. Check if QDIOUP is set and let request fail
4732 * if it is not set (see also *_open_qdio and *_close_qdio).
4735 if (!atomic_test_mask(ZFCP_STATUS_ADAPTER_QDIOUP
, &adapter
->status
)) {
4736 write_unlock_irqrestore(&req_queue
->queue_lock
, *lock_flags
);
4741 if (fsf_req
->qtcb
) {
4742 fsf_req
->seq_no
= adapter
->fsf_req_seq_no
;
4743 fsf_req
->qtcb
->prefix
.req_seq_no
= adapter
->fsf_req_seq_no
;
4745 fsf_req
->sbal_number
= 1;
4746 fsf_req
->sbal_first
= req_queue
->free_index
;
4747 fsf_req
->sbal_curr
= req_queue
->free_index
;
4748 fsf_req
->sbale_curr
= 1;
4750 if (likely(req_flags
& ZFCP_REQ_AUTO_CLEANUP
)) {
4751 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_CLEANUP
;
4754 sbale
= zfcp_qdio_sbale_req(fsf_req
, fsf_req
->sbal_curr
, 0);
4756 /* setup common SBALE fields */
4757 sbale
[0].addr
= (void *) fsf_req
->req_id
;
4758 sbale
[0].flags
|= SBAL_FLAGS0_COMMAND
;
4759 if (likely(fsf_req
->qtcb
!= NULL
)) {
4760 sbale
[1].addr
= (void *) fsf_req
->qtcb
;
4761 sbale
[1].length
= sizeof(struct fsf_qtcb
);
4764 ZFCP_LOG_TRACE("got %i free BUFFERs starting at index %i\n",
4765 fsf_req
->sbal_number
, fsf_req
->sbal_first
);
4770 /* dequeue new FSF request previously enqueued */
4771 zfcp_fsf_req_free(fsf_req
);
4775 write_lock_irqsave(&req_queue
->queue_lock
, *lock_flags
);
4777 *fsf_req_p
= fsf_req
;
4782 * function: zfcp_fsf_req_send
4784 * purpose: start transfer of FSF request via QDIO
4786 * returns: 0 - request transfer succesfully started
4787 * !0 - start of request transfer failed
4789 static int zfcp_fsf_req_send(struct zfcp_fsf_req
*fsf_req
)
4791 struct zfcp_adapter
*adapter
;
4792 struct zfcp_qdio_queue
*req_queue
;
4793 volatile struct qdio_buffer_element
*sbale
;
4795 int new_distance_from_int
;
4799 adapter
= fsf_req
->adapter
;
4800 req_queue
= &adapter
->request_queue
,
4803 /* FIXME(debug): remove it later */
4804 sbale
= zfcp_qdio_sbale_req(fsf_req
, fsf_req
->sbal_first
, 0);
4805 ZFCP_LOG_DEBUG("SBALE0 flags=0x%x\n", sbale
[0].flags
);
4806 ZFCP_LOG_TRACE("HEX DUMP OF SBALE1 PAYLOAD:\n");
4807 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_TRACE
, (char *) sbale
[1].addr
,
4810 /* put allocated FSF request into hash table */
4811 spin_lock(&adapter
->req_list_lock
);
4812 zfcp_reqlist_add(adapter
, fsf_req
);
4813 spin_unlock(&adapter
->req_list_lock
);
4815 inc_seq_no
= (fsf_req
->qtcb
!= NULL
);
4817 ZFCP_LOG_TRACE("request queue of adapter %s: "
4818 "next free SBAL is %i, %i free SBALs\n",
4819 zfcp_get_busid_by_adapter(adapter
),
4820 req_queue
->free_index
,
4821 atomic_read(&req_queue
->free_count
));
4823 ZFCP_LOG_DEBUG("calling do_QDIO adapter %s, flags=0x%x, queue_no=%i, "
4824 "index_in_queue=%i, count=%i, buffers=%p\n",
4825 zfcp_get_busid_by_adapter(adapter
),
4826 QDIO_FLAG_SYNC_OUTPUT
,
4827 0, fsf_req
->sbal_first
, fsf_req
->sbal_number
,
4828 &req_queue
->buffer
[fsf_req
->sbal_first
]);
4831 * adjust the number of free SBALs in request queue as well as
4832 * position of first one
4834 atomic_sub(fsf_req
->sbal_number
, &req_queue
->free_count
);
4835 ZFCP_LOG_TRACE("free_count=%d\n", atomic_read(&req_queue
->free_count
));
4836 req_queue
->free_index
+= fsf_req
->sbal_number
; /* increase */
4837 req_queue
->free_index
%= QDIO_MAX_BUFFERS_PER_Q
; /* wrap if needed */
4838 new_distance_from_int
= zfcp_qdio_determine_pci(req_queue
, fsf_req
);
4840 fsf_req
->issued
= get_clock();
4842 retval
= do_QDIO(adapter
->ccw_device
,
4843 QDIO_FLAG_SYNC_OUTPUT
,
4844 0, fsf_req
->sbal_first
, fsf_req
->sbal_number
, NULL
);
4846 dbg_tmp
[0] = (unsigned long) sbale
[0].addr
;
4847 dbg_tmp
[1] = (u64
) retval
;
4848 debug_event(adapter
->erp_dbf
, 4, (void *) dbg_tmp
, 16);
4850 if (unlikely(retval
)) {
4851 /* Queues are down..... */
4853 del_timer(&fsf_req
->timer
);
4854 spin_lock(&adapter
->req_list_lock
);
4855 zfcp_reqlist_remove(adapter
, fsf_req
);
4856 spin_unlock(&adapter
->req_list_lock
);
4857 /* undo changes in request queue made for this request */
4858 zfcp_qdio_zero_sbals(req_queue
->buffer
,
4859 fsf_req
->sbal_first
, fsf_req
->sbal_number
);
4860 atomic_add(fsf_req
->sbal_number
, &req_queue
->free_count
);
4861 req_queue
->free_index
-= fsf_req
->sbal_number
;
4862 req_queue
->free_index
+= QDIO_MAX_BUFFERS_PER_Q
;
4863 req_queue
->free_index
%= QDIO_MAX_BUFFERS_PER_Q
; /* wrap */
4864 zfcp_erp_adapter_reopen(adapter
, 0);
4866 req_queue
->distance_from_int
= new_distance_from_int
;
4868 * increase FSF sequence counter -
4869 * this must only be done for request successfully enqueued to
4870 * QDIO this rejected requests may be cleaned up by calling
4871 * routines resulting in missing sequence counter values
4875 /* Don't increase for unsolicited status */
4877 adapter
->fsf_req_seq_no
++;
4879 /* count FSF requests pending */
4880 atomic_inc(&adapter
->reqs_active
);
4885 #undef ZFCP_LOG_AREA