3 * linux/drivers/s390/scsi/zfcp_fsf.c
5 * FCP adapter driver for IBM eServer zSeries
7 * (C) Copyright IBM Corp. 2002, 2004
9 * Author(s): Martin Peschke <mpeschke@de.ibm.com>
10 * Raimund Schroeder <raimund.schroeder@de.ibm.com>
13 * Stefan Bader <stefan.bader@de.ibm.com>
14 * Heiko Carstens <heiko.carstens@de.ibm.com>
15 * Andreas Herrmann <aherrman@de.ibm.com>
16 * Volker Sameske <sameske@de.ibm.com>
18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation; either version 2, or (at your option)
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
28 * You should have received a copy of the GNU General Public License
29 * along with this program; if not, write to the Free Software
30 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
33 #define ZFCP_FSF_C_REVISION "$Revision: 1.92 $"
37 static int zfcp_fsf_exchange_config_data_handler(struct zfcp_fsf_req
*);
38 static void zfcp_fsf_exchange_port_data_handler(struct zfcp_fsf_req
*);
39 static int zfcp_fsf_open_port_handler(struct zfcp_fsf_req
*);
40 static int zfcp_fsf_close_port_handler(struct zfcp_fsf_req
*);
41 static int zfcp_fsf_close_physical_port_handler(struct zfcp_fsf_req
*);
42 static int zfcp_fsf_open_unit_handler(struct zfcp_fsf_req
*);
43 static int zfcp_fsf_close_unit_handler(struct zfcp_fsf_req
*);
44 static int zfcp_fsf_send_fcp_command_handler(struct zfcp_fsf_req
*);
45 static int zfcp_fsf_send_fcp_command_task_handler(struct zfcp_fsf_req
*);
46 static int zfcp_fsf_send_fcp_command_task_management_handler(
47 struct zfcp_fsf_req
*);
48 static int zfcp_fsf_abort_fcp_command_handler(struct zfcp_fsf_req
*);
49 static int zfcp_fsf_status_read_handler(struct zfcp_fsf_req
*);
50 static int zfcp_fsf_send_ct_handler(struct zfcp_fsf_req
*);
51 static int zfcp_fsf_send_els_handler(struct zfcp_fsf_req
*);
52 static int zfcp_fsf_control_file_handler(struct zfcp_fsf_req
*);
53 static inline int zfcp_fsf_req_sbal_check(
54 unsigned long *, struct zfcp_qdio_queue
*, int);
55 static inline int zfcp_use_one_sbal(
56 struct scatterlist
*, int, struct scatterlist
*, int);
57 static struct zfcp_fsf_req
*zfcp_fsf_req_alloc(mempool_t
*, int);
58 static int zfcp_fsf_req_send(struct zfcp_fsf_req
*, struct timer_list
*);
59 static int zfcp_fsf_protstatus_eval(struct zfcp_fsf_req
*);
60 static int zfcp_fsf_fsfstatus_eval(struct zfcp_fsf_req
*);
61 static int zfcp_fsf_fsfstatus_qual_eval(struct zfcp_fsf_req
*);
62 static int zfcp_fsf_req_dispatch(struct zfcp_fsf_req
*);
63 static void zfcp_fsf_req_dismiss(struct zfcp_fsf_req
*);
64 static void zfcp_fsf_req_free(struct zfcp_fsf_req
*);
66 /* association between FSF command and FSF QTCB type */
67 static u32 fsf_qtcb_type
[] = {
68 [FSF_QTCB_FCP_CMND
] = FSF_IO_COMMAND
,
69 [FSF_QTCB_ABORT_FCP_CMND
] = FSF_SUPPORT_COMMAND
,
70 [FSF_QTCB_OPEN_PORT_WITH_DID
] = FSF_SUPPORT_COMMAND
,
71 [FSF_QTCB_OPEN_LUN
] = FSF_SUPPORT_COMMAND
,
72 [FSF_QTCB_CLOSE_LUN
] = FSF_SUPPORT_COMMAND
,
73 [FSF_QTCB_CLOSE_PORT
] = FSF_SUPPORT_COMMAND
,
74 [FSF_QTCB_CLOSE_PHYSICAL_PORT
] = FSF_SUPPORT_COMMAND
,
75 [FSF_QTCB_SEND_ELS
] = FSF_SUPPORT_COMMAND
,
76 [FSF_QTCB_SEND_GENERIC
] = FSF_SUPPORT_COMMAND
,
77 [FSF_QTCB_EXCHANGE_CONFIG_DATA
] = FSF_CONFIG_COMMAND
,
78 [FSF_QTCB_EXCHANGE_PORT_DATA
] = FSF_PORT_COMMAND
,
79 [FSF_QTCB_DOWNLOAD_CONTROL_FILE
] = FSF_SUPPORT_COMMAND
,
80 [FSF_QTCB_UPLOAD_CONTROL_FILE
] = FSF_SUPPORT_COMMAND
83 static const char zfcp_act_subtable_type
[5][8] = {
84 "unknown", "OS", "WWPN", "DID", "LUN"
87 /****************************************************************/
88 /*************** FSF related Functions *************************/
89 /****************************************************************/
91 #define ZFCP_LOG_AREA ZFCP_LOG_AREA_FSF
94 * function: zfcp_fsf_req_alloc
96 * purpose: Obtains an fsf_req and potentially a qtcb (for all but
97 * unsolicited requests) via helper functions
98 * Does some initial fsf request set-up.
100 * returns: pointer to allocated fsf_req if successfull
106 static struct zfcp_fsf_req
*
107 zfcp_fsf_req_alloc(mempool_t
*pool
, int req_flags
)
111 struct zfcp_fsf_req
*fsf_req
= NULL
;
113 if (req_flags
& ZFCP_REQ_NO_QTCB
)
114 size
= sizeof(struct zfcp_fsf_req
);
116 size
= sizeof(struct zfcp_fsf_req_pool_element
);
118 if (likely(pool
!= NULL
))
119 ptr
= mempool_alloc(pool
, GFP_ATOMIC
);
121 ptr
= kmalloc(size
, GFP_ATOMIC
);
123 if (unlikely(NULL
== ptr
))
126 memset(ptr
, 0, size
);
128 if (req_flags
& ZFCP_REQ_NO_QTCB
) {
129 fsf_req
= (struct zfcp_fsf_req
*) ptr
;
131 fsf_req
= &((struct zfcp_fsf_req_pool_element
*) ptr
)->fsf_req
;
133 &((struct zfcp_fsf_req_pool_element
*) ptr
)->qtcb
;
136 fsf_req
->pool
= pool
;
143 * function: zfcp_fsf_req_free
145 * purpose: Frees the memory of an fsf_req (and potentially a qtcb) or
146 * returns it into the pool via helper functions.
153 zfcp_fsf_req_free(struct zfcp_fsf_req
*fsf_req
)
155 if (likely(fsf_req
->pool
!= NULL
))
156 mempool_free(fsf_req
, fsf_req
->pool
);
168 * note: qdio queues shall be down (no ongoing inbound processing)
171 zfcp_fsf_req_dismiss_all(struct zfcp_adapter
*adapter
)
174 struct zfcp_fsf_req
*fsf_req
, *tmp
;
176 list_for_each_entry_safe(fsf_req
, tmp
, &adapter
->fsf_req_list_head
,
178 zfcp_fsf_req_dismiss(fsf_req
);
179 /* wait_event_timeout? */
180 while (!list_empty(&adapter
->fsf_req_list_head
)) {
181 ZFCP_LOG_DEBUG("fsf req list of adapter %s not yet empty\n",
182 zfcp_get_busid_by_adapter(adapter
));
183 /* wait for woken intiators to clean up their requests */
184 msleep(jiffies_to_msecs(ZFCP_FSFREQ_CLEANUP_TIMEOUT
));
187 /* consistency check */
188 if (atomic_read(&adapter
->fsf_reqs_active
)) {
189 ZFCP_LOG_NORMAL("bug: There are still %d FSF requests pending "
190 "on adapter %s after cleanup.\n",
191 atomic_read(&adapter
->fsf_reqs_active
),
192 zfcp_get_busid_by_adapter(adapter
));
193 atomic_set(&adapter
->fsf_reqs_active
, 0);
207 zfcp_fsf_req_dismiss(struct zfcp_fsf_req
*fsf_req
)
209 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_DISMISSED
;
210 zfcp_fsf_req_complete(fsf_req
);
214 * function: zfcp_fsf_req_complete
216 * purpose: Updates active counts and timers for openfcp-reqs
217 * May cleanup request after req_eval returns
219 * returns: 0 - success
225 zfcp_fsf_req_complete(struct zfcp_fsf_req
*fsf_req
)
229 struct zfcp_adapter
*adapter
= fsf_req
->adapter
;
231 /* do some statistics */
232 atomic_dec(&adapter
->fsf_reqs_active
);
234 if (unlikely(fsf_req
->fsf_command
== FSF_QTCB_UNSOLICITED_STATUS
)) {
235 ZFCP_LOG_DEBUG("Status read response received\n");
237 * Note: all cleanup handling is done in the callchain of
238 * the function call-chain below.
240 zfcp_fsf_status_read_handler(fsf_req
);
243 zfcp_fsf_protstatus_eval(fsf_req
);
246 * fsf_req may be deleted due to waking up functions, so
247 * cleanup is saved here and used later
249 if (likely(fsf_req
->status
& ZFCP_STATUS_FSFREQ_CLEANUP
))
254 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_COMPLETED
;
256 /* cleanup request if requested by initiator */
257 if (likely(cleanup
)) {
258 ZFCP_LOG_TRACE("removing FSF request %p\n", fsf_req
);
260 * lock must not be held here since it will be
261 * grabed by the called routine, too
263 zfcp_fsf_req_cleanup(fsf_req
);
265 /* notify initiator waiting for the requests completion */
266 ZFCP_LOG_TRACE("waking initiator of FSF request %p\n",fsf_req
);
268 * FIXME: Race! We must not access fsf_req here as it might have been
269 * cleaned up already due to the set ZFCP_STATUS_FSFREQ_COMPLETED
270 * flag. It's an improbable case. But, we have the same paranoia for
271 * the cleanup flag already.
272 * Might better be handled using complete()?
273 * (setting the flag and doing wakeup ought to be atomic
274 * with regard to checking the flag as long as waitqueue is
275 * part of the to be released structure)
277 wake_up(&fsf_req
->completion_wq
);
285 * function: zfcp_fsf_protstatus_eval
287 * purpose: evaluates the QTCB of the finished FSF request
288 * and initiates appropriate actions
289 * (usually calling FSF command specific handlers)
298 zfcp_fsf_protstatus_eval(struct zfcp_fsf_req
*fsf_req
)
301 struct zfcp_adapter
*adapter
= fsf_req
->adapter
;
303 ZFCP_LOG_DEBUG("QTCB is at %p\n", fsf_req
->qtcb
);
305 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_DISMISSED
) {
306 ZFCP_LOG_DEBUG("fsf_req 0x%lx has been dismissed\n",
307 (unsigned long) fsf_req
);
308 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
|
309 ZFCP_STATUS_FSFREQ_RETRY
; /* only for SCSI cmnds. */
310 zfcp_cmd_dbf_event_fsf("dismiss", fsf_req
, NULL
, 0);
311 goto skip_protstatus
;
314 /* log additional information provided by FSF (if any) */
315 if (unlikely(fsf_req
->qtcb
->header
.log_length
)) {
316 /* do not trust them ;-) */
317 if (fsf_req
->qtcb
->header
.log_start
> sizeof(struct fsf_qtcb
)) {
319 ("bug: ULP (FSF logging) log data starts "
320 "beyond end of packet header. Ignored. "
321 "(start=%i, size=%li)\n",
322 fsf_req
->qtcb
->header
.log_start
,
323 sizeof(struct fsf_qtcb
));
326 if ((size_t) (fsf_req
->qtcb
->header
.log_start
+
327 fsf_req
->qtcb
->header
.log_length
)
328 > sizeof(struct fsf_qtcb
)) {
329 ZFCP_LOG_NORMAL("bug: ULP (FSF logging) log data ends "
330 "beyond end of packet header. Ignored. "
331 "(start=%i, length=%i, size=%li)\n",
332 fsf_req
->qtcb
->header
.log_start
,
333 fsf_req
->qtcb
->header
.log_length
,
334 sizeof(struct fsf_qtcb
));
337 ZFCP_LOG_TRACE("ULP log data: \n");
338 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_TRACE
,
339 (char *) fsf_req
->qtcb
+
340 fsf_req
->qtcb
->header
.log_start
,
341 fsf_req
->qtcb
->header
.log_length
);
345 /* evaluate FSF Protocol Status */
346 switch (fsf_req
->qtcb
->prefix
.prot_status
) {
349 ZFCP_LOG_TRACE("FSF_PROT_GOOD\n");
352 case FSF_PROT_FSF_STATUS_PRESENTED
:
353 ZFCP_LOG_TRACE("FSF_PROT_FSF_STATUS_PRESENTED\n");
356 case FSF_PROT_QTCB_VERSION_ERROR
:
357 ZFCP_LOG_FLAGS(0, "FSF_PROT_QTCB_VERSION_ERROR\n");
358 ZFCP_LOG_NORMAL("error: The adapter %s contains "
359 "microcode of version 0x%x, the device driver "
360 "only supports 0x%x. Aborting.\n",
361 zfcp_get_busid_by_adapter(adapter
),
362 fsf_req
->qtcb
->prefix
.prot_status_qual
.
363 version_error
.fsf_version
, ZFCP_QTCB_VERSION
);
364 /* stop operation for this adapter */
365 debug_text_exception(adapter
->erp_dbf
, 0, "prot_ver_err");
366 zfcp_erp_adapter_shutdown(adapter
, 0);
367 zfcp_cmd_dbf_event_fsf("qverserr", fsf_req
,
368 &fsf_req
->qtcb
->prefix
.prot_status_qual
,
369 sizeof (union fsf_prot_status_qual
));
370 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
373 case FSF_PROT_SEQ_NUMB_ERROR
:
374 ZFCP_LOG_FLAGS(0, "FSF_PROT_SEQ_NUMB_ERROR\n");
375 ZFCP_LOG_NORMAL("bug: Sequence number mismatch between "
376 "driver (0x%x) and adapter %s (0x%x). "
377 "Restarting all operations on this adapter.\n",
378 fsf_req
->qtcb
->prefix
.req_seq_no
,
379 zfcp_get_busid_by_adapter(adapter
),
380 fsf_req
->qtcb
->prefix
.prot_status_qual
.
381 sequence_error
.exp_req_seq_no
);
382 debug_text_exception(adapter
->erp_dbf
, 0, "prot_seq_err");
383 /* restart operation on this adapter */
384 zfcp_erp_adapter_reopen(adapter
, 0);
385 zfcp_cmd_dbf_event_fsf("seqnoerr", fsf_req
,
386 &fsf_req
->qtcb
->prefix
.prot_status_qual
,
387 sizeof (union fsf_prot_status_qual
));
388 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_RETRY
;
389 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
392 case FSF_PROT_UNSUPP_QTCB_TYPE
:
393 ZFCP_LOG_FLAGS(0, "FSF_PROT_UNSUP_QTCB_TYPE\n");
394 ZFCP_LOG_NORMAL("error: Packet header type used by the "
395 "device driver is incompatible with "
396 "that used on adapter %s. "
397 "Stopping all operations on this adapter.\n",
398 zfcp_get_busid_by_adapter(adapter
));
399 debug_text_exception(adapter
->erp_dbf
, 0, "prot_unsup_qtcb");
400 zfcp_erp_adapter_shutdown(adapter
, 0);
401 zfcp_cmd_dbf_event_fsf("unsqtcbt", fsf_req
,
402 &fsf_req
->qtcb
->prefix
.prot_status_qual
,
403 sizeof (union fsf_prot_status_qual
));
404 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
407 case FSF_PROT_HOST_CONNECTION_INITIALIZING
:
408 ZFCP_LOG_FLAGS(1, "FSF_PROT_HOST_CONNECTION_INITIALIZING\n");
409 zfcp_cmd_dbf_event_fsf("hconinit", fsf_req
,
410 &fsf_req
->qtcb
->prefix
.prot_status_qual
,
411 sizeof (union fsf_prot_status_qual
));
412 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
413 atomic_set_mask(ZFCP_STATUS_ADAPTER_HOST_CON_INIT
,
415 debug_text_event(adapter
->erp_dbf
, 3, "prot_con_init");
418 case FSF_PROT_DUPLICATE_REQUEST_ID
:
419 ZFCP_LOG_FLAGS(0, "FSF_PROT_DUPLICATE_REQUEST_IDS\n");
421 ZFCP_LOG_NORMAL("bug: The request identifier 0x%Lx "
422 "to the adapter %s is ambiguous. "
423 "Stopping all operations on this "
425 *(unsigned long long *)
426 (&fsf_req
->qtcb
->bottom
.support
.
428 zfcp_get_busid_by_adapter(adapter
));
430 ZFCP_LOG_NORMAL("bug: The request identifier %p "
431 "to the adapter %s is ambiguous. "
432 "Stopping all operations on this "
434 "(bug: got this for an unsolicited "
435 "status read request)\n",
437 zfcp_get_busid_by_adapter(adapter
));
439 debug_text_exception(adapter
->erp_dbf
, 0, "prot_dup_id");
440 zfcp_erp_adapter_shutdown(adapter
, 0);
441 zfcp_cmd_dbf_event_fsf("dupreqid", fsf_req
,
442 &fsf_req
->qtcb
->prefix
.prot_status_qual
,
443 sizeof (union fsf_prot_status_qual
));
444 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
447 case FSF_PROT_LINK_DOWN
:
448 ZFCP_LOG_FLAGS(1, "FSF_PROT_LINK_DOWN\n");
450 * 'test and set' is not atomic here -
451 * it's ok as long as calls to our response queue handler
452 * (and thus execution of this code here) are serialized
455 if (!atomic_test_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED
,
457 switch (fsf_req
->qtcb
->prefix
.prot_status_qual
.
458 locallink_error
.code
) {
459 case FSF_PSQ_LINK_NOLIGHT
:
460 ZFCP_LOG_INFO("The local link to adapter %s "
461 "is down (no light detected).\n",
462 zfcp_get_busid_by_adapter(
465 case FSF_PSQ_LINK_WRAPPLUG
:
466 ZFCP_LOG_INFO("The local link to adapter %s "
467 "is down (wrap plug detected).\n",
468 zfcp_get_busid_by_adapter(
471 case FSF_PSQ_LINK_NOFCP
:
472 ZFCP_LOG_INFO("The local link to adapter %s "
473 "is down (adjacent node on "
474 "link does not support FCP).\n",
475 zfcp_get_busid_by_adapter(
479 ZFCP_LOG_INFO("The local link to adapter %s "
481 "(warning: unknown reason "
483 zfcp_get_busid_by_adapter(
489 * Due to the 'erp failed' flag the adapter won't
490 * be recovered but will be just set to 'blocked'
491 * state. All subordinary devices will have state
492 * 'blocked' and 'erp failed', too.
493 * Thus the adapter is still able to provide
494 * 'link up' status without being flooded with
496 * (note: even 'close port' is not permitted)
498 ZFCP_LOG_INFO("Stopping all operations for adapter "
500 zfcp_get_busid_by_adapter(adapter
));
501 atomic_set_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED
|
502 ZFCP_STATUS_COMMON_ERP_FAILED
,
504 zfcp_erp_adapter_reopen(adapter
, 0);
505 debug_text_event(adapter
->erp_dbf
, 1, "prot_link_down");
507 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
510 case FSF_PROT_REEST_QUEUE
:
511 ZFCP_LOG_FLAGS(1, "FSF_PROT_REEST_QUEUE\n");
512 debug_text_event(adapter
->erp_dbf
, 1, "prot_reest_queue");
513 ZFCP_LOG_INFO("The local link to adapter with "
514 "%s was re-plugged. "
515 "Re-starting operations on this adapter.\n",
516 zfcp_get_busid_by_adapter(adapter
));
517 /* All ports should be marked as ready to run again */
518 zfcp_erp_modify_adapter_status(adapter
,
519 ZFCP_STATUS_COMMON_RUNNING
,
521 zfcp_erp_adapter_reopen(adapter
,
522 ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED
523 | ZFCP_STATUS_COMMON_ERP_FAILED
);
524 zfcp_cmd_dbf_event_fsf("reestque", fsf_req
,
525 &fsf_req
->qtcb
->prefix
.prot_status_qual
,
526 sizeof (union fsf_prot_status_qual
));
527 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
530 case FSF_PROT_ERROR_STATE
:
531 ZFCP_LOG_FLAGS(0, "FSF_PROT_ERROR_STATE\n");
532 ZFCP_LOG_NORMAL("error: The adapter %s "
533 "has entered the error state. "
534 "Restarting all operations on this "
536 zfcp_get_busid_by_adapter(adapter
));
537 debug_text_event(adapter
->erp_dbf
, 0, "prot_err_sta");
538 /* restart operation on this adapter */
539 zfcp_erp_adapter_reopen(adapter
, 0);
540 zfcp_cmd_dbf_event_fsf("proterrs", fsf_req
,
541 &fsf_req
->qtcb
->prefix
.prot_status_qual
,
542 sizeof (union fsf_prot_status_qual
));
543 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_RETRY
;
544 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
548 ZFCP_LOG_NORMAL("bug: Transfer protocol status information "
549 "provided by the adapter %s "
550 "is not compatible with the device driver. "
551 "Stopping all operations on this adapter. "
552 "(debug info 0x%x).\n",
553 zfcp_get_busid_by_adapter(adapter
),
554 fsf_req
->qtcb
->prefix
.prot_status
);
555 debug_text_event(adapter
->erp_dbf
, 0, "prot_inval:");
556 debug_exception(adapter
->erp_dbf
, 0,
557 &fsf_req
->qtcb
->prefix
.prot_status
,
559 zfcp_erp_adapter_shutdown(adapter
, 0);
560 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
565 * always call specific handlers to give them a chance to do
566 * something meaningful even in error cases
568 zfcp_fsf_fsfstatus_eval(fsf_req
);
573 * function: zfcp_fsf_fsfstatus_eval
575 * purpose: evaluates FSF status of completed FSF request
576 * and acts accordingly
581 zfcp_fsf_fsfstatus_eval(struct zfcp_fsf_req
*fsf_req
)
585 if (unlikely(fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
)) {
589 /* evaluate FSF Status */
590 switch (fsf_req
->qtcb
->header
.fsf_status
) {
591 case FSF_UNKNOWN_COMMAND
:
592 ZFCP_LOG_FLAGS(0, "FSF_UNKNOWN_COMMAND\n");
593 ZFCP_LOG_NORMAL("bug: Command issued by the device driver is "
594 "not known by the adapter %s "
595 "Stopping all operations on this adapter. "
596 "(debug info 0x%x).\n",
597 zfcp_get_busid_by_adapter(fsf_req
->adapter
),
598 fsf_req
->qtcb
->header
.fsf_command
);
599 debug_text_exception(fsf_req
->adapter
->erp_dbf
, 0,
601 zfcp_erp_adapter_shutdown(fsf_req
->adapter
, 0);
602 zfcp_cmd_dbf_event_fsf("unknownc", fsf_req
,
603 &fsf_req
->qtcb
->header
.fsf_status_qual
,
604 sizeof (union fsf_status_qual
));
605 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
608 case FSF_FCP_RSP_AVAILABLE
:
609 ZFCP_LOG_FLAGS(2, "FSF_FCP_RSP_AVAILABLE\n");
610 ZFCP_LOG_DEBUG("FCP Sense data will be presented to the "
612 debug_text_event(fsf_req
->adapter
->erp_dbf
, 3, "fsf_s_rsp");
615 case FSF_ADAPTER_STATUS_AVAILABLE
:
616 ZFCP_LOG_FLAGS(2, "FSF_ADAPTER_STATUS_AVAILABLE\n");
617 debug_text_event(fsf_req
->adapter
->erp_dbf
, 2, "fsf_s_astatus");
618 zfcp_fsf_fsfstatus_qual_eval(fsf_req
);
627 * always call specific handlers to give them a chance to do
628 * something meaningful even in error cases
630 zfcp_fsf_req_dispatch(fsf_req
);
636 * function: zfcp_fsf_fsfstatus_qual_eval
638 * purpose: evaluates FSF status-qualifier of completed FSF request
639 * and acts accordingly
644 zfcp_fsf_fsfstatus_qual_eval(struct zfcp_fsf_req
*fsf_req
)
648 switch (fsf_req
->qtcb
->header
.fsf_status_qual
.word
[0]) {
649 case FSF_SQ_FCP_RSP_AVAILABLE
:
650 ZFCP_LOG_FLAGS(2, "FSF_SQ_FCP_RSP_AVAILABLE\n");
651 debug_text_event(fsf_req
->adapter
->erp_dbf
, 4, "fsf_sq_rsp");
653 case FSF_SQ_RETRY_IF_POSSIBLE
:
654 ZFCP_LOG_FLAGS(2, "FSF_SQ_RETRY_IF_POSSIBLE\n");
655 /* The SCSI-stack may now issue retries or escalate */
656 debug_text_event(fsf_req
->adapter
->erp_dbf
, 2, "fsf_sq_retry");
657 zfcp_cmd_dbf_event_fsf("sqretry", fsf_req
,
658 &fsf_req
->qtcb
->header
.fsf_status_qual
,
659 sizeof (union fsf_status_qual
));
660 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
662 case FSF_SQ_COMMAND_ABORTED
:
663 ZFCP_LOG_FLAGS(2, "FSF_SQ_COMMAND_ABORTED\n");
664 /* Carry the aborted state on to upper layer */
665 debug_text_event(fsf_req
->adapter
->erp_dbf
, 2, "fsf_sq_abort");
666 zfcp_cmd_dbf_event_fsf("sqabort", fsf_req
,
667 &fsf_req
->qtcb
->header
.fsf_status_qual
,
668 sizeof (union fsf_status_qual
));
669 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ABORTED
;
670 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
672 case FSF_SQ_NO_RECOM
:
673 ZFCP_LOG_FLAGS(0, "FSF_SQ_NO_RECOM\n");
674 debug_text_exception(fsf_req
->adapter
->erp_dbf
, 0,
676 ZFCP_LOG_NORMAL("bug: No recommendation could be given for a"
677 "problem on the adapter %s "
678 "Stopping all operations on this adapter. ",
679 zfcp_get_busid_by_adapter(fsf_req
->adapter
));
680 zfcp_erp_adapter_shutdown(fsf_req
->adapter
, 0);
681 zfcp_cmd_dbf_event_fsf("sqnrecom", fsf_req
,
682 &fsf_req
->qtcb
->header
.fsf_status_qual
,
683 sizeof (union fsf_status_qual
));
684 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
686 case FSF_SQ_ULP_PROGRAMMING_ERROR
:
687 ZFCP_LOG_FLAGS(0, "FSF_SQ_ULP_PROGRAMMING_ERROR\n");
688 ZFCP_LOG_NORMAL("error: not enough SBALs for data transfer "
690 zfcp_get_busid_by_adapter(fsf_req
->adapter
));
691 debug_text_exception(fsf_req
->adapter
->erp_dbf
, 0,
693 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
695 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE
:
696 case FSF_SQ_NO_RETRY_POSSIBLE
:
697 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED
:
698 /* dealt with in the respective functions */
701 ZFCP_LOG_NORMAL("bug: Additional status info could "
702 "not be interpreted properly.\n");
703 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_NORMAL
,
704 (char *) &fsf_req
->qtcb
->header
.fsf_status_qual
,
705 sizeof (union fsf_status_qual
));
706 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0, "fsf_sq_inval:");
707 debug_exception(fsf_req
->adapter
->erp_dbf
, 0,
708 &fsf_req
->qtcb
->header
.fsf_status_qual
.word
[0],
710 zfcp_cmd_dbf_event_fsf("squndef", fsf_req
,
711 &fsf_req
->qtcb
->header
.fsf_status_qual
,
712 sizeof (union fsf_status_qual
));
713 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
721 * function: zfcp_fsf_req_dispatch
723 * purpose: calls the appropriate command specific handler
728 zfcp_fsf_req_dispatch(struct zfcp_fsf_req
*fsf_req
)
730 struct zfcp_erp_action
*erp_action
= fsf_req
->erp_action
;
731 struct zfcp_adapter
*adapter
= fsf_req
->adapter
;
734 if (unlikely(fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
)) {
735 ZFCP_LOG_TRACE("fsf_req=%p, QTCB=%p\n", fsf_req
, fsf_req
->qtcb
);
736 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_TRACE
,
737 (char *) fsf_req
->qtcb
, sizeof(struct fsf_qtcb
));
740 switch (fsf_req
->fsf_command
) {
742 case FSF_QTCB_FCP_CMND
:
743 ZFCP_LOG_FLAGS(3, "FSF_QTCB_FCP_CMND\n");
744 zfcp_fsf_send_fcp_command_handler(fsf_req
);
747 case FSF_QTCB_ABORT_FCP_CMND
:
748 ZFCP_LOG_FLAGS(2, "FSF_QTCB_ABORT_FCP_CMND\n");
749 zfcp_fsf_abort_fcp_command_handler(fsf_req
);
752 case FSF_QTCB_SEND_GENERIC
:
753 ZFCP_LOG_FLAGS(2, "FSF_QTCB_SEND_GENERIC\n");
754 zfcp_fsf_send_ct_handler(fsf_req
);
757 case FSF_QTCB_OPEN_PORT_WITH_DID
:
758 ZFCP_LOG_FLAGS(2, "FSF_QTCB_OPEN_PORT_WITH_DID\n");
759 zfcp_fsf_open_port_handler(fsf_req
);
762 case FSF_QTCB_OPEN_LUN
:
763 ZFCP_LOG_FLAGS(2, "FSF_QTCB_OPEN_LUN\n");
764 zfcp_fsf_open_unit_handler(fsf_req
);
767 case FSF_QTCB_CLOSE_LUN
:
768 ZFCP_LOG_FLAGS(2, "FSF_QTCB_CLOSE_LUN\n");
769 zfcp_fsf_close_unit_handler(fsf_req
);
772 case FSF_QTCB_CLOSE_PORT
:
773 ZFCP_LOG_FLAGS(2, "FSF_QTCB_CLOSE_PORT\n");
774 zfcp_fsf_close_port_handler(fsf_req
);
777 case FSF_QTCB_CLOSE_PHYSICAL_PORT
:
778 ZFCP_LOG_FLAGS(2, "FSF_QTCB_CLOSE_PHYSICAL_PORT\n");
779 zfcp_fsf_close_physical_port_handler(fsf_req
);
782 case FSF_QTCB_EXCHANGE_CONFIG_DATA
:
783 ZFCP_LOG_FLAGS(2, "FSF_QTCB_EXCHANGE_CONFIG_DATA\n");
784 zfcp_fsf_exchange_config_data_handler(fsf_req
);
787 case FSF_QTCB_EXCHANGE_PORT_DATA
:
788 ZFCP_LOG_FLAGS(2, "FSF_QTCB_EXCHANGE_PORT_DATA\n");
789 zfcp_fsf_exchange_port_data_handler(fsf_req
);
792 case FSF_QTCB_SEND_ELS
:
793 ZFCP_LOG_FLAGS(2, "FSF_QTCB_SEND_ELS\n");
794 zfcp_fsf_send_els_handler(fsf_req
);
797 case FSF_QTCB_DOWNLOAD_CONTROL_FILE
:
798 ZFCP_LOG_FLAGS(2, "FSF_QTCB_DOWNLOAD_CONTROL_FILE\n");
799 zfcp_fsf_control_file_handler(fsf_req
);
802 case FSF_QTCB_UPLOAD_CONTROL_FILE
:
803 ZFCP_LOG_FLAGS(2, "FSF_QTCB_UPLOAD_CONTROL_FILE\n");
804 zfcp_fsf_control_file_handler(fsf_req
);
808 ZFCP_LOG_FLAGS(2, "FSF_QTCB_UNKNOWN\n");
809 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
810 ZFCP_LOG_NORMAL("bug: Command issued by the device driver is "
811 "not supported by the adapter %s\n",
812 zfcp_get_busid_by_adapter(fsf_req
->adapter
));
813 if (fsf_req
->fsf_command
!= fsf_req
->qtcb
->header
.fsf_command
)
815 ("bug: Command issued by the device driver differs "
816 "from the command returned by the adapter %s "
817 "(debug info 0x%x, 0x%x).\n",
818 zfcp_get_busid_by_adapter(fsf_req
->adapter
),
819 fsf_req
->fsf_command
,
820 fsf_req
->qtcb
->header
.fsf_command
);
826 debug_text_event(adapter
->erp_dbf
, 3, "a_frh");
827 debug_event(adapter
->erp_dbf
, 3, &erp_action
->action
, sizeof (int));
828 zfcp_erp_async_handler(erp_action
, 0);
834 * function: zfcp_fsf_status_read
836 * purpose: initiates a Status Read command at the specified adapter
841 zfcp_fsf_status_read(struct zfcp_adapter
*adapter
, int req_flags
)
843 struct zfcp_fsf_req
*fsf_req
;
844 struct fsf_status_read_buffer
*status_buffer
;
845 unsigned long lock_flags
;
846 volatile struct qdio_buffer_element
*sbale
;
849 /* setup new FSF request */
850 retval
= zfcp_fsf_req_create(adapter
, FSF_QTCB_UNSOLICITED_STATUS
,
851 req_flags
| ZFCP_REQ_NO_QTCB
,
852 adapter
->pool
.fsf_req_status_read
,
853 &lock_flags
, &fsf_req
);
855 ZFCP_LOG_INFO("error: Could not create unsolicited status "
856 "buffer for adapter %s.\n",
857 zfcp_get_busid_by_adapter(adapter
));
858 goto failed_req_create
;
861 sbale
= zfcp_qdio_sbale_req(fsf_req
, fsf_req
->sbal_curr
, 0);
862 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_STATUS
;
863 sbale
[2].flags
|= SBAL_FLAGS_LAST_ENTRY
;
864 fsf_req
->sbale_curr
= 2;
867 mempool_alloc(adapter
->pool
.data_status_read
, GFP_ATOMIC
);
868 if (!status_buffer
) {
869 ZFCP_LOG_NORMAL("bug: could not get some buffer\n");
872 memset(status_buffer
, 0, sizeof (struct fsf_status_read_buffer
));
873 fsf_req
->data
.status_read
.buffer
= status_buffer
;
875 /* insert pointer to respective buffer */
876 sbale
= zfcp_qdio_sbale_curr(fsf_req
);
877 sbale
->addr
= (void *) status_buffer
;
878 sbale
->length
= sizeof(struct fsf_status_read_buffer
);
880 /* start QDIO request for this FSF request */
881 retval
= zfcp_fsf_req_send(fsf_req
, NULL
);
883 ZFCP_LOG_DEBUG("error: Could not set-up unsolicited status "
885 goto failed_req_send
;
888 ZFCP_LOG_TRACE("Status Read request initiated (adapter%s)\n",
889 zfcp_get_busid_by_adapter(adapter
));
893 mempool_free(status_buffer
, adapter
->pool
.data_status_read
);
896 zfcp_fsf_req_free(fsf_req
);
899 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
, lock_flags
);
904 zfcp_fsf_status_read_port_closed(struct zfcp_fsf_req
*fsf_req
)
906 struct fsf_status_read_buffer
*status_buffer
;
907 struct zfcp_adapter
*adapter
;
908 struct zfcp_port
*port
;
911 status_buffer
= fsf_req
->data
.status_read
.buffer
;
912 adapter
= fsf_req
->adapter
;
914 read_lock_irqsave(&zfcp_data
.config_lock
, flags
);
915 list_for_each_entry(port
, &adapter
->port_list_head
, list
)
916 if (port
->d_id
== (status_buffer
->d_id
& ZFCP_DID_MASK
))
918 read_unlock_irqrestore(&zfcp_data
.config_lock
, flags
);
920 if (!port
|| (port
->d_id
!= (status_buffer
->d_id
& ZFCP_DID_MASK
))) {
921 ZFCP_LOG_NORMAL("bug: Reopen port indication received for"
922 "nonexisting port with d_id 0x%08x on "
923 "adapter %s. Ignored.\n",
924 status_buffer
->d_id
& ZFCP_DID_MASK
,
925 zfcp_get_busid_by_adapter(adapter
));
929 switch (status_buffer
->status_subtype
) {
931 case FSF_STATUS_READ_SUB_CLOSE_PHYS_PORT
:
932 ZFCP_LOG_FLAGS(2, "FSF_STATUS_READ_SUB_CLOSE_PHYS_PORT\n");
933 debug_text_event(adapter
->erp_dbf
, 3, "unsol_pc_phys:");
934 zfcp_erp_port_reopen(port
, 0);
937 case FSF_STATUS_READ_SUB_ERROR_PORT
:
938 ZFCP_LOG_FLAGS(1, "FSF_STATUS_READ_SUB_ERROR_PORT\n");
939 debug_text_event(adapter
->erp_dbf
, 1, "unsol_pc_err:");
940 zfcp_erp_port_shutdown(port
, 0);
944 debug_text_event(adapter
->erp_dbf
, 0, "unsol_unk_sub:");
945 debug_exception(adapter
->erp_dbf
, 0,
946 &status_buffer
->status_subtype
, sizeof (u32
));
947 ZFCP_LOG_NORMAL("bug: Undefined status subtype received "
948 "for a reopen indication on port with "
949 "d_id 0x%08x on the adapter %s. "
950 "Ignored. (debug info 0x%x)\n",
952 zfcp_get_busid_by_adapter(adapter
),
953 status_buffer
->status_subtype
);
960 * function: zfcp_fsf_status_read_handler
962 * purpose: is called for finished Open Port command
967 zfcp_fsf_status_read_handler(struct zfcp_fsf_req
*fsf_req
)
970 struct zfcp_adapter
*adapter
= fsf_req
->adapter
;
971 struct fsf_status_read_buffer
*status_buffer
=
972 fsf_req
->data
.status_read
.buffer
;
974 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_DISMISSED
) {
975 mempool_free(status_buffer
, adapter
->pool
.data_status_read
);
976 zfcp_fsf_req_cleanup(fsf_req
);
980 switch (status_buffer
->status_type
) {
982 case FSF_STATUS_READ_PORT_CLOSED
:
983 ZFCP_LOG_FLAGS(1, "FSF_STATUS_READ_PORT_CLOSED\n");
984 debug_text_event(adapter
->erp_dbf
, 3, "unsol_pclosed:");
985 debug_event(adapter
->erp_dbf
, 3,
986 &status_buffer
->d_id
, sizeof (u32
));
987 zfcp_fsf_status_read_port_closed(fsf_req
);
990 case FSF_STATUS_READ_INCOMING_ELS
:
991 ZFCP_LOG_FLAGS(1, "FSF_STATUS_READ_INCOMING_ELS\n");
992 debug_text_event(adapter
->erp_dbf
, 3, "unsol_els:");
993 zfcp_fsf_incoming_els(fsf_req
);
996 case FSF_STATUS_READ_SENSE_DATA_AVAIL
:
997 ZFCP_LOG_FLAGS(1, "FSF_STATUS_READ_SENSE_DATA_AVAIL\n");
998 debug_text_event(adapter
->erp_dbf
, 3, "unsol_sense:");
999 ZFCP_LOG_INFO("unsolicited sense data received (adapter %s)\n",
1000 zfcp_get_busid_by_adapter(adapter
));
1001 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_NORMAL
, (char *) status_buffer
,
1002 sizeof(struct fsf_status_read_buffer
));
1005 case FSF_STATUS_READ_BIT_ERROR_THRESHOLD
:
1006 ZFCP_LOG_FLAGS(1, "FSF_STATUS_READ_BIT_ERROR_THRESHOLD\n");
1007 debug_text_event(adapter
->erp_dbf
, 3, "unsol_bit_err:");
1008 ZFCP_LOG_NORMAL("Bit error threshold data received:\n");
1009 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_NORMAL
,
1010 (char *) status_buffer
,
1011 sizeof (struct fsf_status_read_buffer
));
1014 case FSF_STATUS_READ_LINK_DOWN
:
1015 ZFCP_LOG_FLAGS(1, "FSF_STATUS_READ_LINK_DOWN\n");
1016 debug_text_event(adapter
->erp_dbf
, 0, "unsol_link_down:");
1017 ZFCP_LOG_INFO("Local link to adapter %s is down\n",
1018 zfcp_get_busid_by_adapter(adapter
));
1019 atomic_set_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED
,
1021 zfcp_erp_adapter_failed(adapter
);
1024 case FSF_STATUS_READ_LINK_UP
:
1025 ZFCP_LOG_FLAGS(1, "FSF_STATUS_READ_LINK_UP\n");
1026 debug_text_event(adapter
->erp_dbf
, 2, "unsol_link_up:");
1027 ZFCP_LOG_INFO("Local link to adapter %s was replugged. "
1028 "Restarting operations on this adapter\n",
1029 zfcp_get_busid_by_adapter(adapter
));
1030 /* All ports should be marked as ready to run again */
1031 zfcp_erp_modify_adapter_status(adapter
,
1032 ZFCP_STATUS_COMMON_RUNNING
,
1034 zfcp_erp_adapter_reopen(adapter
,
1035 ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED
1036 | ZFCP_STATUS_COMMON_ERP_FAILED
);
1039 case FSF_STATUS_READ_CFDC_UPDATED
:
1040 ZFCP_LOG_FLAGS(1, "FSF_STATUS_READ_CFDC_UPDATED\n");
1041 debug_text_event(adapter
->erp_dbf
, 2, "unsol_cfdc_update:");
1042 ZFCP_LOG_INFO("CFDC has been updated on the adapter %s\n",
1043 zfcp_get_busid_by_adapter(adapter
));
1044 zfcp_erp_adapter_access_changed(adapter
);
1047 case FSF_STATUS_READ_CFDC_HARDENED
:
1048 ZFCP_LOG_FLAGS(1, "FSF_STATUS_READ_CFDC_HARDENED\n");
1049 debug_text_event(adapter
->erp_dbf
, 2, "unsol_cfdc_harden:");
1050 switch (status_buffer
->status_subtype
) {
1051 case FSF_STATUS_READ_SUB_CFDC_HARDENED_ON_SE
:
1052 ZFCP_LOG_INFO("CFDC of adapter %s saved on SE\n",
1053 zfcp_get_busid_by_adapter(adapter
));
1055 case FSF_STATUS_READ_SUB_CFDC_HARDENED_ON_SE2
:
1056 ZFCP_LOG_INFO("CFDC of adapter %s has been copied "
1057 "to the secondary SE\n",
1058 zfcp_get_busid_by_adapter(adapter
));
1061 ZFCP_LOG_INFO("CFDC of adapter %s has been hardened\n",
1062 zfcp_get_busid_by_adapter(adapter
));
1067 debug_text_event(adapter
->erp_dbf
, 0, "unsol_unknown:");
1068 debug_exception(adapter
->erp_dbf
, 0,
1069 &status_buffer
->status_type
, sizeof (u32
));
1070 ZFCP_LOG_NORMAL("bug: An unsolicited status packet of unknown "
1071 "type was received (debug info 0x%x)\n",
1072 status_buffer
->status_type
);
1073 ZFCP_LOG_DEBUG("Dump of status_read_buffer %p:\n",
1075 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
1076 (char *) status_buffer
,
1077 sizeof (struct fsf_status_read_buffer
));
1080 mempool_free(status_buffer
, adapter
->pool
.data_status_read
);
1081 zfcp_fsf_req_cleanup(fsf_req
);
1083 * recycle buffer and start new request repeat until outbound
1084 * queue is empty or adapter shutdown is requested
1088 * we may wait in the req_create for 5s during shutdown, so
1089 * qdio_cleanup will have to wait at least that long before returning
1090 * with failure to allow us a proper cleanup under all circumstances
1094 * allocation failure possible? (Is this code needed?)
1096 retval
= zfcp_fsf_status_read(adapter
, 0);
1098 ZFCP_LOG_INFO("Failed to create unsolicited status read "
1099 "request for the adapter %s.\n",
1100 zfcp_get_busid_by_adapter(adapter
));
1101 /* temporary fix to avoid status read buffer shortage */
1102 adapter
->status_read_failed
++;
1103 if ((ZFCP_STATUS_READS_RECOM
- adapter
->status_read_failed
)
1104 < ZFCP_STATUS_READ_FAILED_THRESHOLD
) {
1105 ZFCP_LOG_INFO("restart adapter %s due to status read "
1106 "buffer shortage\n",
1107 zfcp_get_busid_by_adapter(adapter
));
1108 zfcp_erp_adapter_reopen(adapter
, 0);
1116 * function: zfcp_fsf_abort_fcp_command
1118 * purpose: tells FSF to abort a running SCSI command
1120 * returns: address of initiated FSF request
1121 * NULL - request could not be initiated
1123 * FIXME(design): should be watched by a timeout !!!
1124 * FIXME(design) shouldn't this be modified to return an int
1125 * also...don't know how though
1127 struct zfcp_fsf_req
*
1128 zfcp_fsf_abort_fcp_command(unsigned long old_req_id
,
1129 struct zfcp_adapter
*adapter
,
1130 struct zfcp_unit
*unit
, int req_flags
)
1132 volatile struct qdio_buffer_element
*sbale
;
1133 unsigned long lock_flags
;
1134 struct zfcp_fsf_req
*fsf_req
= NULL
;
1137 /* setup new FSF request */
1138 retval
= zfcp_fsf_req_create(adapter
, FSF_QTCB_ABORT_FCP_CMND
,
1139 req_flags
, adapter
->pool
.fsf_req_abort
,
1140 &lock_flags
, &fsf_req
);
1142 ZFCP_LOG_INFO("error: Failed to create an abort command "
1143 "request for lun 0x%016Lx on port 0x%016Lx "
1147 zfcp_get_busid_by_adapter(adapter
));
1151 sbale
= zfcp_qdio_sbale_req(fsf_req
, fsf_req
->sbal_curr
, 0);
1152 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_READ
;
1153 sbale
[1].flags
|= SBAL_FLAGS_LAST_ENTRY
;
1155 fsf_req
->data
.abort_fcp_command
.unit
= unit
;
1157 /* set handles of unit and its parent port in QTCB */
1158 fsf_req
->qtcb
->header
.lun_handle
= unit
->handle
;
1159 fsf_req
->qtcb
->header
.port_handle
= unit
->port
->handle
;
1161 /* set handle of request which should be aborted */
1162 fsf_req
->qtcb
->bottom
.support
.req_handle
= (u64
) old_req_id
;
1164 /* start QDIO request for this FSF request */
1166 zfcp_fsf_start_scsi_er_timer(adapter
);
1167 retval
= zfcp_fsf_req_send(fsf_req
, NULL
);
1169 del_timer(&adapter
->scsi_er_timer
);
1170 ZFCP_LOG_INFO("error: Failed to send abort command request "
1171 "on adapter %s, port 0x%016Lx, unit 0x%016Lx\n",
1172 zfcp_get_busid_by_adapter(adapter
),
1173 unit
->port
->wwpn
, unit
->fcp_lun
);
1174 zfcp_fsf_req_free(fsf_req
);
1179 ZFCP_LOG_DEBUG("Abort FCP Command request initiated "
1180 "(adapter%s, port d_id=0x%08x, "
1181 "unit x%016Lx, old_req_id=0x%lx)\n",
1182 zfcp_get_busid_by_adapter(adapter
),
1184 unit
->fcp_lun
, old_req_id
);
1186 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
, lock_flags
);
1191 * function: zfcp_fsf_abort_fcp_command_handler
1193 * purpose: is called for finished Abort FCP Command request
1198 zfcp_fsf_abort_fcp_command_handler(struct zfcp_fsf_req
*new_fsf_req
)
1200 int retval
= -EINVAL
;
1201 struct zfcp_unit
*unit
= new_fsf_req
->data
.abort_fcp_command
.unit
;
1202 unsigned char status_qual
=
1203 new_fsf_req
->qtcb
->header
.fsf_status_qual
.word
[0];
1205 del_timer(&new_fsf_req
->adapter
->scsi_er_timer
);
1207 if (new_fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
) {
1208 /* do not set ZFCP_STATUS_FSFREQ_ABORTSUCCEEDED */
1209 goto skip_fsfstatus
;
1212 /* evaluate FSF status in QTCB */
1213 switch (new_fsf_req
->qtcb
->header
.fsf_status
) {
1215 case FSF_PORT_HANDLE_NOT_VALID
:
1216 if (status_qual
>> 4 != status_qual
% 0xf) {
1217 ZFCP_LOG_FLAGS(2, "FSF_PORT_HANDLE_NOT_VALID\n");
1218 debug_text_event(new_fsf_req
->adapter
->erp_dbf
, 3,
1221 * In this case a command that was sent prior to a port
1222 * reopen was aborted (handles are different). This is
1226 ZFCP_LOG_FLAGS(1, "FSF_PORT_HANDLE_NOT_VALID\n");
1227 ZFCP_LOG_INFO("Temporary port identifier 0x%x for "
1228 "port 0x%016Lx on adapter %s invalid. "
1229 "This may happen occasionally.\n",
1232 zfcp_get_busid_by_unit(unit
));
1233 ZFCP_LOG_INFO("status qualifier:\n");
1234 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_INFO
,
1235 (char *) &new_fsf_req
->qtcb
->header
.
1237 sizeof (union fsf_status_qual
));
1238 /* Let's hope this sorts out the mess */
1239 debug_text_event(new_fsf_req
->adapter
->erp_dbf
, 1,
1241 zfcp_erp_adapter_reopen(unit
->port
->adapter
, 0);
1242 new_fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1246 case FSF_LUN_HANDLE_NOT_VALID
:
1247 if (status_qual
>> 4 != status_qual
% 0xf) {
1249 ZFCP_LOG_FLAGS(0, "FSF_LUN_HANDLE_NOT_VALID\n");
1250 debug_text_event(new_fsf_req
->adapter
->erp_dbf
, 3,
1253 * In this case a command that was sent prior to a unit
1254 * reopen was aborted (handles are different).
1258 ZFCP_LOG_FLAGS(1, "FSF_LUN_HANDLE_NOT_VALID\n");
1260 ("Warning: Temporary LUN identifier 0x%x of LUN "
1261 "0x%016Lx on port 0x%016Lx on adapter %s is "
1262 "invalid. This may happen in rare cases. "
1263 "Trying to re-establish link.\n",
1267 zfcp_get_busid_by_unit(unit
));
1268 ZFCP_LOG_DEBUG("Status qualifier data:\n");
1269 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
1270 (char *) &new_fsf_req
->qtcb
->header
.
1272 sizeof (union fsf_status_qual
));
1273 /* Let's hope this sorts out the mess */
1274 debug_text_event(new_fsf_req
->adapter
->erp_dbf
, 1,
1276 zfcp_erp_port_reopen(unit
->port
, 0);
1277 new_fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1281 case FSF_FCP_COMMAND_DOES_NOT_EXIST
:
1282 ZFCP_LOG_FLAGS(2, "FSF_FCP_COMMAND_DOES_NOT_EXIST\n");
1284 debug_text_event(new_fsf_req
->adapter
->erp_dbf
, 3,
1286 new_fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ABORTNOTNEEDED
;
1289 case FSF_PORT_BOXED
:
1291 ZFCP_LOG_FLAGS(0, "FSF_PORT_BOXED\n");
1292 ZFCP_LOG_INFO("Remote port 0x%016Lx on adapter %s needs to "
1293 "be reopened\n", unit
->port
->wwpn
,
1294 zfcp_get_busid_by_unit(unit
));
1295 debug_text_event(new_fsf_req
->adapter
->erp_dbf
, 2,
1297 zfcp_erp_port_reopen(unit
->port
, 0);
1298 new_fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
1299 | ZFCP_STATUS_FSFREQ_RETRY
;
1303 ZFCP_LOG_FLAGS(0, "FSF_LUN_BOXED\n");
1305 "unit 0x%016Lx on port 0x%016Lx on adapter %s needs "
1307 unit
->fcp_lun
, unit
->port
->wwpn
,
1308 zfcp_get_busid_by_unit(unit
));
1309 debug_text_event(new_fsf_req
->adapter
->erp_dbf
, 1, "fsf_s_lboxed");
1310 zfcp_erp_unit_reopen(unit
, 0);
1311 zfcp_cmd_dbf_event_fsf("unitbox", new_fsf_req
,
1312 &new_fsf_req
->qtcb
->header
.fsf_status_qual
,
1313 sizeof(union fsf_status_qual
));
1314 new_fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
1315 | ZFCP_STATUS_FSFREQ_RETRY
;
1318 case FSF_ADAPTER_STATUS_AVAILABLE
:
1320 ZFCP_LOG_FLAGS(0, "FSF_ADAPTER_STATUS_AVAILABLE\n");
1321 switch (new_fsf_req
->qtcb
->header
.fsf_status_qual
.word
[0]) {
1322 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE
:
1324 "FSF_SQ_INVOKE_LINK_TEST_PROCEDURE\n");
1325 debug_text_event(new_fsf_req
->adapter
->erp_dbf
, 1,
1327 /* reopening link to port */
1328 zfcp_erp_port_reopen(unit
->port
, 0);
1329 new_fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1331 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED
:
1333 "FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED\n");
1334 /* SCSI stack will escalate */
1335 debug_text_event(new_fsf_req
->adapter
->erp_dbf
, 1,
1337 new_fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1341 ("bug: Wrong status qualifier 0x%x arrived.\n",
1342 new_fsf_req
->qtcb
->header
.fsf_status_qual
.word
[0]);
1343 debug_text_event(new_fsf_req
->adapter
->erp_dbf
, 0,
1345 debug_exception(new_fsf_req
->adapter
->erp_dbf
, 0,
1346 &new_fsf_req
->qtcb
->header
.
1347 fsf_status_qual
.word
[0], sizeof (u32
));
1354 ZFCP_LOG_FLAGS(0, "FSF_GOOD\n");
1356 new_fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ABORTSUCCEEDED
;
1360 ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
1361 "(debug info 0x%x)\n",
1362 new_fsf_req
->qtcb
->header
.fsf_status
);
1363 debug_text_event(new_fsf_req
->adapter
->erp_dbf
, 0,
1365 debug_exception(new_fsf_req
->adapter
->erp_dbf
, 0,
1366 &new_fsf_req
->qtcb
->header
.fsf_status
,
1375 * zfcp_use_one_sbal - checks whether req buffer and resp bother each fit into
1377 * Two scatter-gather lists are passed, one for the reqeust and one for the
1381 zfcp_use_one_sbal(struct scatterlist
*req
, int req_count
,
1382 struct scatterlist
*resp
, int resp_count
)
1384 return ((req_count
== 1) &&
1385 (resp_count
== 1) &&
1386 (((unsigned long) zfcp_sg_to_address(&req
[0]) &
1388 ((unsigned long) (zfcp_sg_to_address(&req
[0]) +
1389 req
[0].length
- 1) & PAGE_MASK
)) &&
1390 (((unsigned long) zfcp_sg_to_address(&resp
[0]) &
1392 ((unsigned long) (zfcp_sg_to_address(&resp
[0]) +
1393 resp
[0].length
- 1) & PAGE_MASK
)));
1397 * zfcp_fsf_send_ct - initiate a Generic Service request (FC-GS)
1398 * @ct: pointer to struct zfcp_send_ct which conatins all needed data for
1400 * @pool: pointer to memory pool, if non-null this pool is used to allocate
1401 * a struct zfcp_fsf_req
1402 * @erp_action: pointer to erp_action, if non-null the Generic Service request
1403 * is sent within error recovery
1406 zfcp_fsf_send_ct(struct zfcp_send_ct
*ct
, mempool_t
*pool
,
1407 struct zfcp_erp_action
*erp_action
)
1409 volatile struct qdio_buffer_element
*sbale
;
1410 struct zfcp_port
*port
;
1411 struct zfcp_adapter
*adapter
;
1412 struct zfcp_fsf_req
*fsf_req
;
1413 unsigned long lock_flags
;
1418 adapter
= port
->adapter
;
1420 ret
= zfcp_fsf_req_create(adapter
, FSF_QTCB_SEND_GENERIC
,
1421 ZFCP_WAIT_FOR_SBAL
| ZFCP_REQ_AUTO_CLEANUP
,
1422 pool
, &lock_flags
, &fsf_req
);
1424 ZFCP_LOG_INFO("error: Could not create CT request (FC-GS) for "
1426 zfcp_get_busid_by_adapter(adapter
));
1430 if (erp_action
!= NULL
) {
1431 erp_action
->fsf_req
= fsf_req
;
1432 fsf_req
->erp_action
= erp_action
;
1435 sbale
= zfcp_qdio_sbale_req(fsf_req
, fsf_req
->sbal_curr
, 0);
1436 if (zfcp_use_one_sbal(ct
->req
, ct
->req_count
,
1437 ct
->resp
, ct
->resp_count
)){
1438 /* both request buffer and response buffer
1439 fit into one sbale each */
1440 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_WRITE_READ
;
1441 sbale
[2].addr
= zfcp_sg_to_address(&ct
->req
[0]);
1442 sbale
[2].length
= ct
->req
[0].length
;
1443 sbale
[3].addr
= zfcp_sg_to_address(&ct
->resp
[0]);
1444 sbale
[3].length
= ct
->resp
[0].length
;
1445 sbale
[3].flags
|= SBAL_FLAGS_LAST_ENTRY
;
1446 } else if (adapter
->supported_features
&
1447 FSF_FEATURE_ELS_CT_CHAINED_SBALS
) {
1448 /* try to use chained SBALs */
1449 bytes
= zfcp_qdio_sbals_from_sg(fsf_req
,
1450 SBAL_FLAGS0_TYPE_WRITE_READ
,
1451 ct
->req
, ct
->req_count
,
1452 ZFCP_MAX_SBALS_PER_CT_REQ
);
1454 ZFCP_LOG_INFO("error: creation of CT request failed "
1456 zfcp_get_busid_by_adapter(adapter
));
1464 fsf_req
->qtcb
->bottom
.support
.req_buf_length
= bytes
;
1465 fsf_req
->sbale_curr
= ZFCP_LAST_SBALE_PER_SBAL
;
1466 bytes
= zfcp_qdio_sbals_from_sg(fsf_req
,
1467 SBAL_FLAGS0_TYPE_WRITE_READ
,
1468 ct
->resp
, ct
->resp_count
,
1469 ZFCP_MAX_SBALS_PER_CT_REQ
);
1471 ZFCP_LOG_INFO("error: creation of CT request failed "
1473 zfcp_get_busid_by_adapter(adapter
));
1481 fsf_req
->qtcb
->bottom
.support
.resp_buf_length
= bytes
;
1483 /* reject send generic request */
1485 "error: microcode does not support chained SBALs,"
1486 "CT request too big (adapter %s)\n",
1487 zfcp_get_busid_by_adapter(adapter
));
1492 /* settings in QTCB */
1493 fsf_req
->qtcb
->header
.port_handle
= port
->handle
;
1494 fsf_req
->qtcb
->bottom
.support
.service_class
= adapter
->fc_service_class
;
1495 fsf_req
->qtcb
->bottom
.support
.timeout
= ct
->timeout
;
1496 fsf_req
->data
.send_ct
= ct
;
1498 /* start QDIO request for this FSF request */
1499 ret
= zfcp_fsf_req_send(fsf_req
, ct
->timer
);
1501 ZFCP_LOG_DEBUG("error: initiation of CT request failed "
1502 "(adapter %s, port 0x%016Lx)\n",
1503 zfcp_get_busid_by_adapter(adapter
), port
->wwpn
);
1507 ZFCP_LOG_DEBUG("CT request initiated (adapter %s, port 0x%016Lx)\n",
1508 zfcp_get_busid_by_adapter(adapter
), port
->wwpn
);
1512 zfcp_fsf_req_free(fsf_req
);
1513 if (erp_action
!= NULL
) {
1514 erp_action
->fsf_req
= NULL
;
1518 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
,
1524 * zfcp_fsf_send_ct_handler - handler for Generic Service requests
1525 * @fsf_req: pointer to struct zfcp_fsf_req
1527 * Data specific for the Generic Service request is passed by
1528 * fsf_req->data.send_ct
1529 * Usually a specific handler for the request is called via
1530 * fsf_req->data.send_ct->handler at end of this function.
1533 zfcp_fsf_send_ct_handler(struct zfcp_fsf_req
*fsf_req
)
1535 struct zfcp_port
*port
;
1536 struct zfcp_adapter
*adapter
;
1537 struct zfcp_send_ct
*send_ct
;
1538 struct fsf_qtcb_header
*header
;
1539 struct fsf_qtcb_bottom_support
*bottom
;
1540 int retval
= -EINVAL
;
1541 u16 subtable
, rule
, counter
;
1543 adapter
= fsf_req
->adapter
;
1544 send_ct
= fsf_req
->data
.send_ct
;
1545 port
= send_ct
->port
;
1546 header
= &fsf_req
->qtcb
->header
;
1547 bottom
= &fsf_req
->qtcb
->bottom
.support
;
1549 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
)
1550 goto skip_fsfstatus
;
1552 /* evaluate FSF status in QTCB */
1553 switch (header
->fsf_status
) {
1556 ZFCP_LOG_FLAGS(2,"FSF_GOOD\n");
1560 case FSF_SERVICE_CLASS_NOT_SUPPORTED
:
1561 ZFCP_LOG_FLAGS(2, "FSF_SERVICE_CLASS_NOT_SUPPORTED\n");
1562 if (adapter
->fc_service_class
<= 3) {
1563 ZFCP_LOG_INFO("error: adapter %s does not support fc "
1565 zfcp_get_busid_by_port(port
),
1566 adapter
->fc_service_class
);
1568 ZFCP_LOG_INFO("bug: The fibre channel class at the "
1569 "adapter %s is invalid. "
1570 "(debug info %d)\n",
1571 zfcp_get_busid_by_port(port
),
1572 adapter
->fc_service_class
);
1574 /* stop operation for this adapter */
1575 debug_text_exception(adapter
->erp_dbf
, 0, "fsf_s_class_nsup");
1576 zfcp_erp_adapter_shutdown(adapter
, 0);
1577 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1580 case FSF_ADAPTER_STATUS_AVAILABLE
:
1581 ZFCP_LOG_FLAGS(2, "FSF_ADAPTER_STATUS_AVAILABLE\n");
1582 switch (header
->fsf_status_qual
.word
[0]){
1583 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE
:
1584 ZFCP_LOG_FLAGS(2,"FSF_SQ_INVOKE_LINK_TEST_PROCEDURE\n");
1585 /* reopening link to port */
1586 debug_text_event(adapter
->erp_dbf
, 1, "fsf_sq_ltest");
1587 zfcp_test_link(port
);
1588 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1590 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED
:
1591 ZFCP_LOG_FLAGS(2,"FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED\n");
1592 /* ERP strategy will escalate */
1593 debug_text_event(adapter
->erp_dbf
, 1, "fsf_sq_ulp");
1594 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1597 ZFCP_LOG_INFO("bug: Wrong status qualifier 0x%x "
1599 header
->fsf_status_qual
.word
[0]);
1604 case FSF_ACCESS_DENIED
:
1605 ZFCP_LOG_FLAGS(2, "FSF_ACCESS_DENIED\n");
1606 ZFCP_LOG_NORMAL("access denied, cannot send generic service "
1607 "command (adapter %s, port d_id=0x%08x)\n",
1608 zfcp_get_busid_by_port(port
), port
->d_id
);
1609 for (counter
= 0; counter
< 2; counter
++) {
1610 subtable
= header
->fsf_status_qual
.halfword
[counter
* 2];
1611 rule
= header
->fsf_status_qual
.halfword
[counter
* 2 + 1];
1613 case FSF_SQ_CFDC_SUBTABLE_OS
:
1614 case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN
:
1615 case FSF_SQ_CFDC_SUBTABLE_PORT_DID
:
1616 case FSF_SQ_CFDC_SUBTABLE_LUN
:
1617 ZFCP_LOG_INFO("Access denied (%s rule %d)\n",
1618 zfcp_act_subtable_type
[subtable
], rule
);
1622 debug_text_event(adapter
->erp_dbf
, 1, "fsf_s_access");
1623 zfcp_erp_port_access_denied(port
);
1624 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1627 case FSF_GENERIC_COMMAND_REJECTED
:
1628 ZFCP_LOG_FLAGS(2, "FSF_GENERIC_COMMAND_REJECTED\n");
1629 ZFCP_LOG_INFO("generic service command rejected "
1630 "(adapter %s, port d_id=0x%08x)\n",
1631 zfcp_get_busid_by_port(port
), port
->d_id
);
1632 ZFCP_LOG_INFO("status qualifier:\n");
1633 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_INFO
,
1634 (char *) &header
->fsf_status_qual
,
1635 sizeof (union fsf_status_qual
));
1636 debug_text_event(adapter
->erp_dbf
, 1, "fsf_s_gcom_rej");
1637 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1640 case FSF_PORT_HANDLE_NOT_VALID
:
1641 ZFCP_LOG_FLAGS(2, "FSF_PORT_HANDLE_NOT_VALID\n");
1642 ZFCP_LOG_DEBUG("Temporary port identifier 0x%x for port "
1643 "0x%016Lx on adapter %s invalid. This may "
1644 "happen occasionally.\n", port
->handle
,
1645 port
->wwpn
, zfcp_get_busid_by_port(port
));
1646 ZFCP_LOG_INFO("status qualifier:\n");
1647 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_INFO
,
1648 (char *) &header
->fsf_status_qual
,
1649 sizeof (union fsf_status_qual
));
1650 debug_text_event(adapter
->erp_dbf
, 1, "fsf_s_phandle_nv");
1651 zfcp_erp_adapter_reopen(adapter
, 0);
1652 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1655 case FSF_PORT_BOXED
:
1656 ZFCP_LOG_FLAGS(2, "FSF_PORT_BOXED\n");
1657 ZFCP_LOG_INFO("port needs to be reopened "
1658 "(adapter %s, port d_id=0x%08x)\n",
1659 zfcp_get_busid_by_port(port
), port
->d_id
);
1660 debug_text_event(adapter
->erp_dbf
, 2, "fsf_s_pboxed");
1661 zfcp_erp_port_reopen(port
, 0);
1662 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
1663 | ZFCP_STATUS_FSFREQ_RETRY
;
1666 /* following states should never occure, all cases avoided
1667 in zfcp_fsf_send_ct - but who knows ... */
1668 case FSF_PAYLOAD_SIZE_MISMATCH
:
1669 ZFCP_LOG_FLAGS(2, "FSF_PAYLOAD_SIZE_MISMATCH\n");
1670 ZFCP_LOG_INFO("payload size mismatch (adapter: %s, "
1671 "req_buf_length=%d, resp_buf_length=%d)\n",
1672 zfcp_get_busid_by_adapter(adapter
),
1673 bottom
->req_buf_length
, bottom
->resp_buf_length
);
1674 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1676 case FSF_REQUEST_SIZE_TOO_LARGE
:
1677 ZFCP_LOG_FLAGS(2, "FSF_REQUEST_SIZE_TOO_LARGE\n");
1678 ZFCP_LOG_INFO("request size too large (adapter: %s, "
1679 "req_buf_length=%d)\n",
1680 zfcp_get_busid_by_adapter(adapter
),
1681 bottom
->req_buf_length
);
1682 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1684 case FSF_RESPONSE_SIZE_TOO_LARGE
:
1685 ZFCP_LOG_FLAGS(2, "FSF_RESPONSE_SIZE_TOO_LARGE\n");
1686 ZFCP_LOG_INFO("response size too large (adapter: %s, "
1687 "resp_buf_length=%d)\n",
1688 zfcp_get_busid_by_adapter(adapter
),
1689 bottom
->resp_buf_length
);
1690 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1692 case FSF_SBAL_MISMATCH
:
1693 ZFCP_LOG_FLAGS(2, "FSF_SBAL_MISMATCH\n");
1694 ZFCP_LOG_INFO("SBAL mismatch (adapter: %s, req_buf_length=%d, "
1695 "resp_buf_length=%d)\n",
1696 zfcp_get_busid_by_adapter(adapter
),
1697 bottom
->req_buf_length
, bottom
->resp_buf_length
);
1698 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1702 ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
1703 "(debug info 0x%x)\n", header
->fsf_status
);
1704 debug_text_event(adapter
->erp_dbf
, 0, "fsf_sq_inval:");
1705 debug_exception(adapter
->erp_dbf
, 0,
1706 &header
->fsf_status_qual
.word
[0], sizeof (u32
));
1711 send_ct
->status
= retval
;
1713 if (send_ct
->handler
!= NULL
)
1714 send_ct
->handler(send_ct
->handler_data
);
1720 * zfcp_fsf_send_els - initiate an ELS command (FC-FS)
1721 * @els: pointer to struct zfcp_send_els which contains all needed data for
1725 zfcp_fsf_send_els(struct zfcp_send_els
*els
)
1727 volatile struct qdio_buffer_element
*sbale
;
1728 struct zfcp_fsf_req
*fsf_req
;
1730 struct zfcp_adapter
*adapter
;
1731 unsigned long lock_flags
;
1736 adapter
= els
->adapter
;
1738 ret
= zfcp_fsf_req_create(adapter
, FSF_QTCB_SEND_ELS
,
1739 ZFCP_REQ_AUTO_CLEANUP
,
1740 NULL
, &lock_flags
, &fsf_req
);
1742 ZFCP_LOG_INFO("error: creation of ELS request failed "
1743 "(adapter %s, port d_id: 0x%08x)\n",
1744 zfcp_get_busid_by_adapter(adapter
), d_id
);
1748 sbale
= zfcp_qdio_sbale_req(fsf_req
, fsf_req
->sbal_curr
, 0);
1749 if (zfcp_use_one_sbal(els
->req
, els
->req_count
,
1750 els
->resp
, els
->resp_count
)){
1751 /* both request buffer and response buffer
1752 fit into one sbale each */
1753 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_WRITE_READ
;
1754 sbale
[2].addr
= zfcp_sg_to_address(&els
->req
[0]);
1755 sbale
[2].length
= els
->req
[0].length
;
1756 sbale
[3].addr
= zfcp_sg_to_address(&els
->resp
[0]);
1757 sbale
[3].length
= els
->resp
[0].length
;
1758 sbale
[3].flags
|= SBAL_FLAGS_LAST_ENTRY
;
1759 } else if (adapter
->supported_features
&
1760 FSF_FEATURE_ELS_CT_CHAINED_SBALS
) {
1761 /* try to use chained SBALs */
1762 bytes
= zfcp_qdio_sbals_from_sg(fsf_req
,
1763 SBAL_FLAGS0_TYPE_WRITE_READ
,
1764 els
->req
, els
->req_count
,
1765 ZFCP_MAX_SBALS_PER_ELS_REQ
);
1767 ZFCP_LOG_INFO("error: creation of ELS request failed "
1768 "(adapter %s, port d_id: 0x%08x)\n",
1769 zfcp_get_busid_by_adapter(adapter
), d_id
);
1777 fsf_req
->qtcb
->bottom
.support
.req_buf_length
= bytes
;
1778 fsf_req
->sbale_curr
= ZFCP_LAST_SBALE_PER_SBAL
;
1779 bytes
= zfcp_qdio_sbals_from_sg(fsf_req
,
1780 SBAL_FLAGS0_TYPE_WRITE_READ
,
1781 els
->resp
, els
->resp_count
,
1782 ZFCP_MAX_SBALS_PER_ELS_REQ
);
1784 ZFCP_LOG_INFO("error: creation of ELS request failed "
1785 "(adapter %s, port d_id: 0x%08x)\n",
1786 zfcp_get_busid_by_adapter(adapter
), d_id
);
1794 fsf_req
->qtcb
->bottom
.support
.resp_buf_length
= bytes
;
1796 /* reject request */
1797 ZFCP_LOG_INFO("error: microcode does not support chained SBALs"
1798 ", ELS request too big (adapter %s, "
1799 "port d_id: 0x%08x)\n",
1800 zfcp_get_busid_by_adapter(adapter
), d_id
);
1805 /* settings in QTCB */
1806 fsf_req
->qtcb
->bottom
.support
.d_id
= d_id
;
1807 fsf_req
->qtcb
->bottom
.support
.service_class
= adapter
->fc_service_class
;
1808 fsf_req
->qtcb
->bottom
.support
.timeout
= ZFCP_ELS_TIMEOUT
;
1809 fsf_req
->data
.send_els
= els
;
1811 sbale
= zfcp_qdio_sbale_req(fsf_req
, fsf_req
->sbal_curr
, 0);
1813 /* start QDIO request for this FSF request */
1814 ret
= zfcp_fsf_req_send(fsf_req
, els
->timer
);
1816 ZFCP_LOG_DEBUG("error: initiation of ELS request failed "
1817 "(adapter %s, port d_id: 0x%08x)\n",
1818 zfcp_get_busid_by_adapter(adapter
), d_id
);
1822 ZFCP_LOG_DEBUG("ELS request initiated (adapter %s, port d_id: "
1823 "0x%08x)\n", zfcp_get_busid_by_adapter(adapter
), d_id
);
1827 zfcp_fsf_req_free(fsf_req
);
1831 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
,
1838 * zfcp_fsf_send_els_handler - handler for ELS commands
1839 * @fsf_req: pointer to struct zfcp_fsf_req
1841 * Data specific for the ELS command is passed by
1842 * fsf_req->data.send_els
1843 * Usually a specific handler for the command is called via
1844 * fsf_req->data.send_els->handler at end of this function.
1846 static int zfcp_fsf_send_els_handler(struct zfcp_fsf_req
*fsf_req
)
1848 struct zfcp_adapter
*adapter
;
1850 struct zfcp_port
*port
;
1851 struct fsf_qtcb_header
*header
;
1852 struct fsf_qtcb_bottom_support
*bottom
;
1853 struct zfcp_send_els
*send_els
;
1854 int retval
= -EINVAL
;
1855 u16 subtable
, rule
, counter
;
1857 send_els
= fsf_req
->data
.send_els
;
1858 adapter
= send_els
->adapter
;
1859 d_id
= send_els
->d_id
;
1860 header
= &fsf_req
->qtcb
->header
;
1861 bottom
= &fsf_req
->qtcb
->bottom
.support
;
1863 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
)
1864 goto skip_fsfstatus
;
1866 switch (header
->fsf_status
) {
1869 ZFCP_LOG_FLAGS(2, "FSF_GOOD\n");
1873 case FSF_SERVICE_CLASS_NOT_SUPPORTED
:
1874 ZFCP_LOG_FLAGS(2, "FSF_SERVICE_CLASS_NOT_SUPPORTED\n");
1875 if (adapter
->fc_service_class
<= 3) {
1876 ZFCP_LOG_INFO("error: adapter %s does "
1877 "not support fibrechannel class %d.\n",
1878 zfcp_get_busid_by_adapter(adapter
),
1879 adapter
->fc_service_class
);
1881 ZFCP_LOG_INFO("bug: The fibrechannel class at "
1882 "adapter %s is invalid. "
1883 "(debug info %d)\n",
1884 zfcp_get_busid_by_adapter(adapter
),
1885 adapter
->fc_service_class
);
1887 /* stop operation for this adapter */
1888 debug_text_exception(adapter
->erp_dbf
, 0, "fsf_s_class_nsup");
1889 zfcp_erp_adapter_shutdown(adapter
, 0);
1890 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1893 case FSF_ADAPTER_STATUS_AVAILABLE
:
1894 ZFCP_LOG_FLAGS(2, "FSF_ADAPTER_STATUS_AVAILABLE\n");
1895 switch (header
->fsf_status_qual
.word
[0]){
1896 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE
:
1897 ZFCP_LOG_FLAGS(2,"FSF_SQ_INVOKE_LINK_TEST_PROCEDURE\n");
1898 debug_text_event(adapter
->erp_dbf
, 1, "fsf_sq_ltest");
1899 if (send_els
->ls_code
!= ZFCP_LS_ADISC
) {
1900 read_lock(&zfcp_data
.config_lock
);
1901 port
= zfcp_get_port_by_did(adapter
, d_id
);
1903 zfcp_test_link(port
);
1904 read_unlock(&zfcp_data
.config_lock
);
1906 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1908 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED
:
1909 ZFCP_LOG_FLAGS(2,"FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED\n");
1910 debug_text_event(adapter
->erp_dbf
, 1, "fsf_sq_ulp");
1911 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1913 zfcp_handle_els_rjt(header
->fsf_status_qual
.word
[1],
1914 (struct zfcp_ls_rjt_par
*)
1915 &header
->fsf_status_qual
.word
[2]);
1917 case FSF_SQ_RETRY_IF_POSSIBLE
:
1918 ZFCP_LOG_FLAGS(2, "FSF_SQ_RETRY_IF_POSSIBLE\n");
1919 debug_text_event(adapter
->erp_dbf
, 1, "fsf_sq_retry");
1920 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1923 ZFCP_LOG_INFO("bug: Wrong status qualifier 0x%x\n",
1924 header
->fsf_status_qual
.word
[0]);
1925 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_INFO
,
1926 (char*)header
->fsf_status_qual
.word
, 16);
1930 case FSF_ELS_COMMAND_REJECTED
:
1931 ZFCP_LOG_FLAGS(2, "FSF_ELS_COMMAND_REJECTED\n");
1932 ZFCP_LOG_INFO("ELS has been rejected because command filter "
1933 "prohibited sending "
1934 "(adapter: %s, port d_id: 0x%08x)\n",
1935 zfcp_get_busid_by_adapter(adapter
), d_id
);
1939 case FSF_PAYLOAD_SIZE_MISMATCH
:
1940 ZFCP_LOG_FLAGS(2, "FSF_PAYLOAD_SIZE_MISMATCH\n");
1942 "ELS request size and ELS response size must be either "
1943 "both 0, or both greater than 0 "
1944 "(adapter: %s, req_buf_length=%d resp_buf_length=%d)\n",
1945 zfcp_get_busid_by_adapter(adapter
),
1946 bottom
->req_buf_length
,
1947 bottom
->resp_buf_length
);
1950 case FSF_REQUEST_SIZE_TOO_LARGE
:
1951 ZFCP_LOG_FLAGS(2, "FSF_REQUEST_SIZE_TOO_LARGE\n");
1953 "Length of the ELS request buffer, "
1954 "specified in QTCB bottom, "
1955 "exceeds the size of the buffers "
1956 "that have been allocated for ELS request data "
1957 "(adapter: %s, req_buf_length=%d)\n",
1958 zfcp_get_busid_by_adapter(adapter
),
1959 bottom
->req_buf_length
);
1962 case FSF_RESPONSE_SIZE_TOO_LARGE
:
1963 ZFCP_LOG_FLAGS(2, "FSF_RESPONSE_SIZE_TOO_LARGE\n");
1965 "Length of the ELS response buffer, "
1966 "specified in QTCB bottom, "
1967 "exceeds the size of the buffers "
1968 "that have been allocated for ELS response data "
1969 "(adapter: %s, resp_buf_length=%d)\n",
1970 zfcp_get_busid_by_adapter(adapter
),
1971 bottom
->resp_buf_length
);
1974 case FSF_SBAL_MISMATCH
:
1975 /* should never occure, avoided in zfcp_fsf_send_els */
1976 ZFCP_LOG_FLAGS(2, "FSF_SBAL_MISMATCH\n");
1977 ZFCP_LOG_INFO("SBAL mismatch (adapter: %s, req_buf_length=%d, "
1978 "resp_buf_length=%d)\n",
1979 zfcp_get_busid_by_adapter(adapter
),
1980 bottom
->req_buf_length
, bottom
->resp_buf_length
);
1981 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
1984 case FSF_ACCESS_DENIED
:
1985 ZFCP_LOG_FLAGS(2, "FSF_ACCESS_DENIED\n");
1986 ZFCP_LOG_NORMAL("access denied, cannot send ELS command "
1987 "(adapter %s, port d_id=0x%08x)\n",
1988 zfcp_get_busid_by_adapter(adapter
), d_id
);
1989 for (counter
= 0; counter
< 2; counter
++) {
1990 subtable
= header
->fsf_status_qual
.halfword
[counter
* 2];
1991 rule
= header
->fsf_status_qual
.halfword
[counter
* 2 + 1];
1993 case FSF_SQ_CFDC_SUBTABLE_OS
:
1994 case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN
:
1995 case FSF_SQ_CFDC_SUBTABLE_PORT_DID
:
1996 case FSF_SQ_CFDC_SUBTABLE_LUN
:
1997 ZFCP_LOG_INFO("Access denied (%s rule %d)\n",
1998 zfcp_act_subtable_type
[subtable
], rule
);
2002 debug_text_event(adapter
->erp_dbf
, 1, "fsf_s_access");
2003 read_lock(&zfcp_data
.config_lock
);
2004 port
= zfcp_get_port_by_did(adapter
, d_id
);
2006 zfcp_erp_port_access_denied(port
);
2007 read_unlock(&zfcp_data
.config_lock
);
2008 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
2013 "bug: An unknown FSF Status was presented "
2014 "(adapter: %s, fsf_status=0x%08x)\n",
2015 zfcp_get_busid_by_adapter(adapter
),
2016 header
->fsf_status
);
2017 debug_text_event(adapter
->erp_dbf
, 0, "fsf_sq_inval");
2018 debug_exception(adapter
->erp_dbf
, 0,
2019 &header
->fsf_status_qual
.word
[0], sizeof(u32
));
2020 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
2025 send_els
->status
= retval
;
2027 if (send_els
->handler
!= 0)
2028 send_els
->handler(send_els
->handler_data
);
2038 * returns: address of initiated FSF request
2039 * NULL - request could not be initiated
2042 zfcp_fsf_exchange_config_data(struct zfcp_erp_action
*erp_action
)
2044 volatile struct qdio_buffer_element
*sbale
;
2045 unsigned long lock_flags
;
2048 /* setup new FSF request */
2049 retval
= zfcp_fsf_req_create(erp_action
->adapter
,
2050 FSF_QTCB_EXCHANGE_CONFIG_DATA
,
2051 ZFCP_REQ_AUTO_CLEANUP
,
2052 erp_action
->adapter
->pool
.fsf_req_erp
,
2053 &lock_flags
, &(erp_action
->fsf_req
));
2055 ZFCP_LOG_INFO("error: Could not create exchange configuration "
2056 "data request for adapter %s.\n",
2057 zfcp_get_busid_by_adapter(erp_action
->adapter
));
2061 sbale
= zfcp_qdio_sbale_req(erp_action
->fsf_req
,
2062 erp_action
->fsf_req
->sbal_curr
, 0);
2063 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_READ
;
2064 sbale
[1].flags
|= SBAL_FLAGS_LAST_ENTRY
;
2066 erp_action
->fsf_req
->erp_action
= erp_action
;
2067 erp_action
->fsf_req
->qtcb
->bottom
.config
.feature_selection
=
2068 (FSF_FEATURE_CFDC
| FSF_FEATURE_LUN_SHARING
);
2070 /* start QDIO request for this FSF request */
2071 retval
= zfcp_fsf_req_send(erp_action
->fsf_req
, &erp_action
->timer
);
2074 ("error: Could not send exchange configuration data "
2075 "command on the adapter %s\n",
2076 zfcp_get_busid_by_adapter(erp_action
->adapter
));
2077 zfcp_fsf_req_free(erp_action
->fsf_req
);
2078 erp_action
->fsf_req
= NULL
;
2082 ZFCP_LOG_DEBUG("exchange configuration data request initiated "
2084 zfcp_get_busid_by_adapter(erp_action
->adapter
));
2087 write_unlock_irqrestore(&erp_action
->adapter
->request_queue
.queue_lock
,
2093 * zfcp_fsf_exchange_config_evaluate
2094 * @fsf_req: fsf_req which belongs to xchg config data request
2095 * @xchg_ok: specifies if xchg config data was incomplete or complete (0/1)
2097 * returns: -EIO on error, 0 otherwise
2100 zfcp_fsf_exchange_config_evaluate(struct zfcp_fsf_req
*fsf_req
, int xchg_ok
)
2102 struct fsf_qtcb_bottom_config
*bottom
;
2103 struct zfcp_adapter
*adapter
= fsf_req
->adapter
;
2105 bottom
= &fsf_req
->qtcb
->bottom
.config
;
2106 ZFCP_LOG_DEBUG("low/high QTCB version 0x%x/0x%x of FSF\n",
2107 bottom
->low_qtcb_version
, bottom
->high_qtcb_version
);
2108 adapter
->fsf_lic_version
= bottom
->lic_version
;
2109 adapter
->supported_features
= bottom
->supported_features
;
2112 adapter
->wwnn
= bottom
->nport_serv_param
.wwnn
;
2113 adapter
->wwpn
= bottom
->nport_serv_param
.wwpn
;
2114 adapter
->s_id
= bottom
->s_id
& ZFCP_DID_MASK
;
2115 adapter
->fc_topology
= bottom
->fc_topology
;
2116 adapter
->fc_link_speed
= bottom
->fc_link_speed
;
2117 adapter
->hydra_version
= bottom
->adapter_type
;
2122 adapter
->fc_topology
= 0;
2123 adapter
->fc_link_speed
= 0;
2124 adapter
->hydra_version
= 0;
2127 if(adapter
->supported_features
& FSF_FEATURE_HBAAPI_MANAGEMENT
){
2128 adapter
->hardware_version
= bottom
->hardware_version
;
2129 memcpy(adapter
->serial_number
, bottom
->serial_number
, 17);
2130 EBCASC(adapter
->serial_number
, sizeof(adapter
->serial_number
));
2133 ZFCP_LOG_INFO("The adapter %s reported the following characteristics:\n"
2137 "adapter version 0x%x, "
2138 "LIC version 0x%x, "
2139 "FC link speed %d Gb/s\n",
2140 zfcp_get_busid_by_adapter(adapter
),
2143 (unsigned int) adapter
->s_id
,
2144 adapter
->hydra_version
,
2145 adapter
->fsf_lic_version
,
2146 adapter
->fc_link_speed
);
2147 if (ZFCP_QTCB_VERSION
< bottom
->low_qtcb_version
) {
2148 ZFCP_LOG_NORMAL("error: the adapter %s "
2149 "only supports newer control block "
2150 "versions in comparison to this device "
2151 "driver (try updated device driver)\n",
2152 zfcp_get_busid_by_adapter(adapter
));
2153 debug_text_event(adapter
->erp_dbf
, 0, "low_qtcb_ver");
2154 zfcp_erp_adapter_shutdown(adapter
, 0);
2157 if (ZFCP_QTCB_VERSION
> bottom
->high_qtcb_version
) {
2158 ZFCP_LOG_NORMAL("error: the adapter %s "
2159 "only supports older control block "
2160 "versions than this device driver uses"
2161 "(consider a microcode upgrade)\n",
2162 zfcp_get_busid_by_adapter(adapter
));
2163 debug_text_event(adapter
->erp_dbf
, 0, "high_qtcb_ver");
2164 zfcp_erp_adapter_shutdown(adapter
, 0);
2171 * function: zfcp_fsf_exchange_config_data_handler
2173 * purpose: is called for finished Exchange Configuration Data command
2178 zfcp_fsf_exchange_config_data_handler(struct zfcp_fsf_req
*fsf_req
)
2180 struct fsf_qtcb_bottom_config
*bottom
;
2181 struct zfcp_adapter
*adapter
= fsf_req
->adapter
;
2183 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
)
2186 switch (fsf_req
->qtcb
->header
.fsf_status
) {
2189 ZFCP_LOG_FLAGS(2, "FSF_GOOD\n");
2191 if (zfcp_fsf_exchange_config_evaluate(fsf_req
, 1))
2194 switch (adapter
->fc_topology
) {
2196 ZFCP_LOG_FLAGS(1, "FSF_TOPO_P2P\n");
2197 ZFCP_LOG_NORMAL("error: Point-to-point fibrechannel "
2198 "configuration detected at adapter %s "
2199 "unsupported, shutting down adapter\n",
2200 zfcp_get_busid_by_adapter(adapter
));
2201 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0,
2203 zfcp_erp_adapter_shutdown(adapter
, 0);
2206 ZFCP_LOG_FLAGS(1, "FSF_TOPO_AL\n");
2207 ZFCP_LOG_NORMAL("error: Arbitrated loop fibrechannel "
2208 "topology detected at adapter %s "
2209 "unsupported, shutting down adapter\n",
2210 zfcp_get_busid_by_adapter(adapter
));
2211 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0,
2213 zfcp_erp_adapter_shutdown(adapter
, 0);
2215 case FSF_TOPO_FABRIC
:
2216 ZFCP_LOG_FLAGS(1, "FSF_TOPO_FABRIC\n");
2217 ZFCP_LOG_INFO("Switched fabric fibrechannel "
2218 "network detected at adapter %s.\n",
2219 zfcp_get_busid_by_adapter(adapter
));
2222 ZFCP_LOG_NORMAL("bug: The fibrechannel topology "
2223 "reported by the exchange "
2224 "configuration command for "
2225 "the adapter %s is not "
2226 "of a type known to the zfcp "
2227 "driver, shutting down adapter\n",
2228 zfcp_get_busid_by_adapter(adapter
));
2229 debug_text_exception(fsf_req
->adapter
->erp_dbf
, 0,
2231 zfcp_erp_adapter_shutdown(adapter
, 0);
2234 bottom
= &fsf_req
->qtcb
->bottom
.config
;
2235 if (bottom
->max_qtcb_size
< sizeof(struct fsf_qtcb
)) {
2236 ZFCP_LOG_NORMAL("bug: Maximum QTCB size (%d bytes) "
2237 "allowed by the adapter %s "
2238 "is lower than the minimum "
2239 "required by the driver (%ld bytes).\n",
2240 bottom
->max_qtcb_size
,
2241 zfcp_get_busid_by_adapter(adapter
),
2242 sizeof(struct fsf_qtcb
));
2243 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0,
2245 debug_event(fsf_req
->adapter
->erp_dbf
, 0,
2246 &bottom
->max_qtcb_size
, sizeof (u32
));
2247 zfcp_erp_adapter_shutdown(adapter
, 0);
2250 atomic_set_mask(ZFCP_STATUS_ADAPTER_XCONFIG_OK
,
2253 case FSF_EXCHANGE_CONFIG_DATA_INCOMPLETE
:
2254 debug_text_event(adapter
->erp_dbf
, 0, "xchg-inco");
2256 if (zfcp_fsf_exchange_config_evaluate(fsf_req
, 0))
2259 ZFCP_LOG_INFO("Local link to adapter %s is down\n",
2260 zfcp_get_busid_by_adapter(adapter
));
2261 atomic_set_mask(ZFCP_STATUS_ADAPTER_XCONFIG_OK
|
2262 ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED
,
2264 zfcp_erp_adapter_failed(adapter
);
2267 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0, "fsf-stat-ng");
2268 debug_event(fsf_req
->adapter
->erp_dbf
, 0,
2269 &fsf_req
->qtcb
->header
.fsf_status
, sizeof (u32
));
2270 zfcp_erp_adapter_shutdown(adapter
, 0);
2277 * zfcp_fsf_exchange_port_data - request information about local port
2278 * @adapter: for which port data is requested
2279 * @data: response to exchange port data request
2282 zfcp_fsf_exchange_port_data(struct zfcp_adapter
*adapter
,
2283 struct fsf_qtcb_bottom_port
*data
)
2285 volatile struct qdio_buffer_element
*sbale
;
2287 unsigned long lock_flags
;
2288 struct zfcp_fsf_req
*fsf_req
;
2289 struct timer_list
*timer
;
2291 if(!(adapter
->supported_features
& FSF_FEATURE_HBAAPI_MANAGEMENT
)){
2292 ZFCP_LOG_INFO("error: exchange port data "
2293 "command not supported by adapter %s\n",
2294 zfcp_get_busid_by_adapter(adapter
));
2298 timer
= kmalloc(sizeof(struct timer_list
), GFP_KERNEL
);
2302 /* setup new FSF request */
2303 retval
= zfcp_fsf_req_create(adapter
, FSF_QTCB_EXCHANGE_PORT_DATA
,
2304 0, 0, &lock_flags
, &fsf_req
);
2306 ZFCP_LOG_INFO("error: Out of resources. Could not create an "
2307 "exchange port data request for"
2308 "the adapter %s.\n",
2309 zfcp_get_busid_by_adapter(adapter
));
2310 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
,
2315 sbale
= zfcp_qdio_sbale_req(fsf_req
, fsf_req
->sbal_curr
, 0);
2316 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_READ
;
2317 sbale
[1].flags
|= SBAL_FLAGS_LAST_ENTRY
;
2319 fsf_req
->data
.port_data
= data
;
2322 timer
->function
= zfcp_fsf_request_timeout_handler
;
2323 timer
->data
= (unsigned long) adapter
;
2324 timer
->expires
= ZFCP_FSF_REQUEST_TIMEOUT
;
2326 retval
= zfcp_fsf_req_send(fsf_req
, timer
);
2328 ZFCP_LOG_INFO("error: Could not send an exchange port data "
2329 "command on the adapter %s\n",
2330 zfcp_get_busid_by_adapter(adapter
));
2331 zfcp_fsf_req_free(fsf_req
);
2332 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
,
2337 ZFCP_LOG_DEBUG("Exchange Port Data request initiated (adapter %s)\n",
2338 zfcp_get_busid_by_adapter(adapter
));
2340 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
,
2343 wait_event(fsf_req
->completion_wq
,
2344 fsf_req
->status
& ZFCP_STATUS_FSFREQ_COMPLETED
);
2345 del_timer_sync(timer
);
2346 zfcp_fsf_req_cleanup(fsf_req
);
2354 * zfcp_fsf_exchange_port_data_handler - handler for exchange_port_data request
2355 * @fsf_req: pointer to struct zfcp_fsf_req
2358 zfcp_fsf_exchange_port_data_handler(struct zfcp_fsf_req
*fsf_req
)
2360 struct fsf_qtcb_bottom_port
*bottom
;
2361 struct fsf_qtcb_bottom_port
*data
= fsf_req
->data
.port_data
;
2363 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
)
2366 switch (fsf_req
->qtcb
->header
.fsf_status
) {
2368 ZFCP_LOG_FLAGS(2,"FSF_GOOD\n");
2369 bottom
= &fsf_req
->qtcb
->bottom
.port
;
2370 memcpy(data
, bottom
, sizeof(*data
));
2374 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0, "xchg-port-ng");
2375 debug_event(fsf_req
->adapter
->erp_dbf
, 0,
2376 &fsf_req
->qtcb
->header
.fsf_status
, sizeof(u32
));
2382 * function: zfcp_fsf_open_port
2386 * returns: address of initiated FSF request
2387 * NULL - request could not be initiated
2390 zfcp_fsf_open_port(struct zfcp_erp_action
*erp_action
)
2392 volatile struct qdio_buffer_element
*sbale
;
2393 unsigned long lock_flags
;
2396 /* setup new FSF request */
2397 retval
= zfcp_fsf_req_create(erp_action
->adapter
,
2398 FSF_QTCB_OPEN_PORT_WITH_DID
,
2399 ZFCP_WAIT_FOR_SBAL
| ZFCP_REQ_AUTO_CLEANUP
,
2400 erp_action
->adapter
->pool
.fsf_req_erp
,
2401 &lock_flags
, &(erp_action
->fsf_req
));
2403 ZFCP_LOG_INFO("error: Could not create open port request "
2404 "for port 0x%016Lx on adapter %s.\n",
2405 erp_action
->port
->wwpn
,
2406 zfcp_get_busid_by_adapter(erp_action
->adapter
));
2410 sbale
= zfcp_qdio_sbale_req(erp_action
->fsf_req
,
2411 erp_action
->fsf_req
->sbal_curr
, 0);
2412 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_READ
;
2413 sbale
[1].flags
|= SBAL_FLAGS_LAST_ENTRY
;
2415 erp_action
->fsf_req
->qtcb
->bottom
.support
.d_id
= erp_action
->port
->d_id
;
2416 atomic_set_mask(ZFCP_STATUS_COMMON_OPENING
, &erp_action
->port
->status
);
2417 erp_action
->fsf_req
->data
.open_port
.port
= erp_action
->port
;
2418 erp_action
->fsf_req
->erp_action
= erp_action
;
2420 /* start QDIO request for this FSF request */
2421 retval
= zfcp_fsf_req_send(erp_action
->fsf_req
, &erp_action
->timer
);
2423 ZFCP_LOG_INFO("error: Could not send open port request for "
2424 "port 0x%016Lx on adapter %s.\n",
2425 erp_action
->port
->wwpn
,
2426 zfcp_get_busid_by_adapter(erp_action
->adapter
));
2427 zfcp_fsf_req_free(erp_action
->fsf_req
);
2428 erp_action
->fsf_req
= NULL
;
2432 ZFCP_LOG_DEBUG("open port request initiated "
2433 "(adapter %s, port 0x%016Lx)\n",
2434 zfcp_get_busid_by_adapter(erp_action
->adapter
),
2435 erp_action
->port
->wwpn
);
2437 write_unlock_irqrestore(&erp_action
->adapter
->request_queue
.queue_lock
,
2443 * function: zfcp_fsf_open_port_handler
2445 * purpose: is called for finished Open Port command
2450 zfcp_fsf_open_port_handler(struct zfcp_fsf_req
*fsf_req
)
2452 int retval
= -EINVAL
;
2453 struct zfcp_port
*port
;
2454 struct fsf_plogi
*plogi
;
2455 struct fsf_qtcb_header
*header
;
2456 u16 subtable
, rule
, counter
;
2458 port
= fsf_req
->data
.open_port
.port
;
2459 header
= &fsf_req
->qtcb
->header
;
2461 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
) {
2462 /* don't change port status in our bookkeeping */
2463 goto skip_fsfstatus
;
2466 /* evaluate FSF status in QTCB */
2467 switch (header
->fsf_status
) {
2469 case FSF_PORT_ALREADY_OPEN
:
2470 ZFCP_LOG_FLAGS(0, "FSF_PORT_ALREADY_OPEN\n");
2471 ZFCP_LOG_NORMAL("bug: remote port 0x%016Lx on adapter %s "
2472 "is already open.\n",
2473 port
->wwpn
, zfcp_get_busid_by_port(port
));
2474 debug_text_exception(fsf_req
->adapter
->erp_dbf
, 0,
2477 * This is a bug, however operation should continue normally
2478 * if it is simply ignored
2482 case FSF_ACCESS_DENIED
:
2483 ZFCP_LOG_FLAGS(2, "FSF_ACCESS_DENIED\n");
2484 ZFCP_LOG_NORMAL("Access denied, cannot open port 0x%016Lx "
2486 port
->wwpn
, zfcp_get_busid_by_port(port
));
2487 for (counter
= 0; counter
< 2; counter
++) {
2488 subtable
= header
->fsf_status_qual
.halfword
[counter
* 2];
2489 rule
= header
->fsf_status_qual
.halfword
[counter
* 2 + 1];
2491 case FSF_SQ_CFDC_SUBTABLE_OS
:
2492 case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN
:
2493 case FSF_SQ_CFDC_SUBTABLE_PORT_DID
:
2494 case FSF_SQ_CFDC_SUBTABLE_LUN
:
2495 ZFCP_LOG_INFO("Access denied (%s rule %d)\n",
2496 zfcp_act_subtable_type
[subtable
], rule
);
2500 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1, "fsf_s_access");
2501 zfcp_erp_port_access_denied(port
);
2502 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
2505 case FSF_MAXIMUM_NUMBER_OF_PORTS_EXCEEDED
:
2506 ZFCP_LOG_FLAGS(1, "FSF_MAXIMUM_NUMBER_OF_PORTS_EXCEEDED\n");
2507 ZFCP_LOG_INFO("error: The FSF adapter is out of resources. "
2508 "The remote port 0x%016Lx on adapter %s "
2509 "could not be opened. Disabling it.\n",
2510 port
->wwpn
, zfcp_get_busid_by_port(port
));
2511 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
2513 zfcp_erp_port_failed(port
);
2514 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
2517 case FSF_ADAPTER_STATUS_AVAILABLE
:
2518 ZFCP_LOG_FLAGS(2, "FSF_ADAPTER_STATUS_AVAILABLE\n");
2519 switch (header
->fsf_status_qual
.word
[0]) {
2520 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE
:
2522 "FSF_SQ_INVOKE_LINK_TEST_PROCEDURE\n");
2523 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
2525 /* ERP strategy will escalate */
2526 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
2528 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED
:
2529 /* ERP strategy will escalate */
2530 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
2532 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
2534 case FSF_SQ_NO_RETRY_POSSIBLE
:
2535 ZFCP_LOG_FLAGS(0, "FSF_SQ_NO_RETRY_POSSIBLE\n");
2536 ZFCP_LOG_NORMAL("The remote port 0x%016Lx on "
2537 "adapter %s could not be opened. "
2540 zfcp_get_busid_by_port(port
));
2541 debug_text_exception(fsf_req
->adapter
->erp_dbf
, 0,
2543 zfcp_erp_port_failed(port
);
2544 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
2548 ("bug: Wrong status qualifier 0x%x arrived.\n",
2549 header
->fsf_status_qual
.word
[0]);
2550 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0,
2553 fsf_req
->adapter
->erp_dbf
, 0,
2554 &header
->fsf_status_qual
.word
[0],
2561 ZFCP_LOG_FLAGS(3, "FSF_GOOD\n");
2562 /* save port handle assigned by FSF */
2563 port
->handle
= header
->port_handle
;
2564 ZFCP_LOG_INFO("The remote port 0x%016Lx via adapter %s "
2565 "was opened, it's port handle is 0x%x\n",
2566 port
->wwpn
, zfcp_get_busid_by_port(port
),
2568 /* mark port as open */
2569 atomic_set_mask(ZFCP_STATUS_COMMON_OPEN
|
2570 ZFCP_STATUS_PORT_PHYS_OPEN
, &port
->status
);
2572 /* check whether D_ID has changed during open */
2574 * FIXME: This check is not airtight, as the FCP channel does
2575 * not monitor closures of target port connections caused on
2576 * the remote side. Thus, they might miss out on invalidating
2577 * locally cached WWPNs (and other N_Port parameters) of gone
2578 * target ports. So, our heroic attempt to make things safe
2579 * could be undermined by 'open port' response data tagged with
2580 * obsolete WWPNs. Another reason to monitor potential
2581 * connection closures ourself at least (by interpreting
2582 * incoming ELS' and unsolicited status). It just crosses my
2583 * mind that one should be able to cross-check by means of
2584 * another GID_PN straight after a port has been opened.
2585 * Alternately, an ADISC/PDISC ELS should suffice, as well.
2587 plogi
= (struct fsf_plogi
*) fsf_req
->qtcb
->bottom
.support
.els
;
2588 if (!atomic_test_mask(ZFCP_STATUS_PORT_NO_WWPN
, &port
->status
))
2590 if (fsf_req
->qtcb
->bottom
.support
.els1_length
<
2591 ((((unsigned long) &plogi
->serv_param
.wwpn
) -
2592 ((unsigned long) plogi
)) + sizeof (u64
))) {
2594 "warning: insufficient length of "
2595 "PLOGI payload (%i)\n",
2596 fsf_req
->qtcb
->bottom
.support
.els1_length
);
2597 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0,
2598 "fsf_s_short_plogi:");
2599 /* skip sanity check and assume wwpn is ok */
2601 if (plogi
->serv_param
.wwpn
!= port
->wwpn
) {
2602 ZFCP_LOG_INFO("warning: d_id of port "
2603 "0x%016Lx changed during "
2604 "open\n", port
->wwpn
);
2606 fsf_req
->adapter
->erp_dbf
, 0,
2607 "fsf_s_did_change:");
2609 ZFCP_STATUS_PORT_DID_DID
,
2612 port
->wwnn
= plogi
->serv_param
.wwnn
;
2617 case FSF_UNKNOWN_OP_SUBTYPE
:
2618 /* should never occure, subtype not set in zfcp_fsf_open_port */
2619 ZFCP_LOG_FLAGS(2, "FSF_UNKNOWN_OP_SUBTYPE\n");
2620 ZFCP_LOG_INFO("unknown operation subtype (adapter: %s, "
2621 "op_subtype=0x%x)\n",
2622 zfcp_get_busid_by_port(port
),
2623 fsf_req
->qtcb
->bottom
.support
.operation_subtype
);
2624 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
2628 ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
2629 "(debug info 0x%x)\n",
2630 header
->fsf_status
);
2631 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0, "fsf_s_inval:");
2632 debug_exception(fsf_req
->adapter
->erp_dbf
, 0,
2633 &header
->fsf_status
, sizeof (u32
));
2638 atomic_clear_mask(ZFCP_STATUS_COMMON_OPENING
, &port
->status
);
2643 * function: zfcp_fsf_close_port
2645 * purpose: submit FSF command "close port"
2647 * returns: address of initiated FSF request
2648 * NULL - request could not be initiated
2651 zfcp_fsf_close_port(struct zfcp_erp_action
*erp_action
)
2653 volatile struct qdio_buffer_element
*sbale
;
2654 unsigned long lock_flags
;
2657 /* setup new FSF request */
2658 retval
= zfcp_fsf_req_create(erp_action
->adapter
,
2659 FSF_QTCB_CLOSE_PORT
,
2660 ZFCP_WAIT_FOR_SBAL
| ZFCP_REQ_AUTO_CLEANUP
,
2661 erp_action
->adapter
->pool
.fsf_req_erp
,
2662 &lock_flags
, &(erp_action
->fsf_req
));
2664 ZFCP_LOG_INFO("error: Could not create a close port request "
2665 "for port 0x%016Lx on adapter %s.\n",
2666 erp_action
->port
->wwpn
,
2667 zfcp_get_busid_by_adapter(erp_action
->adapter
));
2671 sbale
= zfcp_qdio_sbale_req(erp_action
->fsf_req
,
2672 erp_action
->fsf_req
->sbal_curr
, 0);
2673 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_READ
;
2674 sbale
[1].flags
|= SBAL_FLAGS_LAST_ENTRY
;
2676 atomic_set_mask(ZFCP_STATUS_COMMON_CLOSING
, &erp_action
->port
->status
);
2677 erp_action
->fsf_req
->data
.close_port
.port
= erp_action
->port
;
2678 erp_action
->fsf_req
->erp_action
= erp_action
;
2679 erp_action
->fsf_req
->qtcb
->header
.port_handle
=
2680 erp_action
->port
->handle
;
2682 /* start QDIO request for this FSF request */
2683 retval
= zfcp_fsf_req_send(erp_action
->fsf_req
, &erp_action
->timer
);
2685 ZFCP_LOG_INFO("error: Could not send a close port request for "
2686 "port 0x%016Lx on adapter %s.\n",
2687 erp_action
->port
->wwpn
,
2688 zfcp_get_busid_by_adapter(erp_action
->adapter
));
2689 zfcp_fsf_req_free(erp_action
->fsf_req
);
2690 erp_action
->fsf_req
= NULL
;
2694 ZFCP_LOG_TRACE("close port request initiated "
2695 "(adapter %s, port 0x%016Lx)\n",
2696 zfcp_get_busid_by_adapter(erp_action
->adapter
),
2697 erp_action
->port
->wwpn
);
2699 write_unlock_irqrestore(&erp_action
->adapter
->request_queue
.queue_lock
,
2705 * function: zfcp_fsf_close_port_handler
2707 * purpose: is called for finished Close Port FSF command
2712 zfcp_fsf_close_port_handler(struct zfcp_fsf_req
*fsf_req
)
2714 int retval
= -EINVAL
;
2715 struct zfcp_port
*port
;
2717 port
= fsf_req
->data
.close_port
.port
;
2719 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
) {
2720 /* don't change port status in our bookkeeping */
2721 goto skip_fsfstatus
;
2724 /* evaluate FSF status in QTCB */
2725 switch (fsf_req
->qtcb
->header
.fsf_status
) {
2727 case FSF_PORT_HANDLE_NOT_VALID
:
2728 ZFCP_LOG_FLAGS(1, "FSF_PORT_HANDLE_NOT_VALID\n");
2729 ZFCP_LOG_INFO("Temporary port identifier 0x%x for port "
2730 "0x%016Lx on adapter %s invalid. This may happen "
2731 "occasionally.\n", port
->handle
,
2732 port
->wwpn
, zfcp_get_busid_by_port(port
));
2733 ZFCP_LOG_DEBUG("status qualifier:\n");
2734 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
2735 (char *) &fsf_req
->qtcb
->header
.fsf_status_qual
,
2736 sizeof (union fsf_status_qual
));
2737 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
2739 zfcp_erp_adapter_reopen(port
->adapter
, 0);
2740 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
2743 case FSF_ADAPTER_STATUS_AVAILABLE
:
2744 ZFCP_LOG_FLAGS(2, "FSF_ADAPTER_STATUS_AVAILABLE\n");
2745 /* Note: FSF has actually closed the port in this case.
2746 * The status code is just daft. Fingers crossed for a change
2752 ZFCP_LOG_FLAGS(3, "FSF_GOOD\n");
2753 ZFCP_LOG_TRACE("remote port 0x016%Lx on adapter %s closed, "
2754 "port handle 0x%x\n", port
->wwpn
,
2755 zfcp_get_busid_by_port(port
), port
->handle
);
2756 zfcp_erp_modify_port_status(port
,
2757 ZFCP_STATUS_COMMON_OPEN
,
2763 ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
2764 "(debug info 0x%x)\n",
2765 fsf_req
->qtcb
->header
.fsf_status
);
2766 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0, "fsf_s_inval:");
2767 debug_exception(fsf_req
->adapter
->erp_dbf
, 0,
2768 &fsf_req
->qtcb
->header
.fsf_status
,
2774 atomic_clear_mask(ZFCP_STATUS_COMMON_CLOSING
, &port
->status
);
2779 * function: zfcp_fsf_close_physical_port
2781 * purpose: submit FSF command "close physical port"
2783 * returns: address of initiated FSF request
2784 * NULL - request could not be initiated
2787 zfcp_fsf_close_physical_port(struct zfcp_erp_action
*erp_action
)
2790 unsigned long lock_flags
;
2791 volatile struct qdio_buffer_element
*sbale
;
2793 /* setup new FSF request */
2794 retval
= zfcp_fsf_req_create(erp_action
->adapter
,
2795 FSF_QTCB_CLOSE_PHYSICAL_PORT
,
2796 ZFCP_WAIT_FOR_SBAL
| ZFCP_REQ_AUTO_CLEANUP
,
2797 erp_action
->adapter
->pool
.fsf_req_erp
,
2798 &lock_flags
, &erp_action
->fsf_req
);
2800 ZFCP_LOG_INFO("error: Could not create close physical port "
2801 "request (adapter %s, port 0x%016Lx)\n",
2802 zfcp_get_busid_by_adapter(erp_action
->adapter
),
2803 erp_action
->port
->wwpn
);
2808 sbale
= zfcp_qdio_sbale_req(erp_action
->fsf_req
,
2809 erp_action
->fsf_req
->sbal_curr
, 0);
2810 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_READ
;
2811 sbale
[1].flags
|= SBAL_FLAGS_LAST_ENTRY
;
2813 /* mark port as being closed */
2814 atomic_set_mask(ZFCP_STATUS_PORT_PHYS_CLOSING
,
2815 &erp_action
->port
->status
);
2816 /* save a pointer to this port */
2817 erp_action
->fsf_req
->data
.close_physical_port
.port
= erp_action
->port
;
2818 /* port to be closeed */
2819 erp_action
->fsf_req
->qtcb
->header
.port_handle
=
2820 erp_action
->port
->handle
;
2821 erp_action
->fsf_req
->erp_action
= erp_action
;
2823 /* start QDIO request for this FSF request */
2824 retval
= zfcp_fsf_req_send(erp_action
->fsf_req
, &erp_action
->timer
);
2826 ZFCP_LOG_INFO("error: Could not send close physical port "
2827 "request (adapter %s, port 0x%016Lx)\n",
2828 zfcp_get_busid_by_adapter(erp_action
->adapter
),
2829 erp_action
->port
->wwpn
);
2830 zfcp_fsf_req_free(erp_action
->fsf_req
);
2831 erp_action
->fsf_req
= NULL
;
2835 ZFCP_LOG_TRACE("close physical port request initiated "
2836 "(adapter %s, port 0x%016Lx)\n",
2837 zfcp_get_busid_by_adapter(erp_action
->adapter
),
2838 erp_action
->port
->wwpn
);
2840 write_unlock_irqrestore(&erp_action
->adapter
->request_queue
.queue_lock
,
2846 * function: zfcp_fsf_close_physical_port_handler
2848 * purpose: is called for finished Close Physical Port FSF command
2853 zfcp_fsf_close_physical_port_handler(struct zfcp_fsf_req
*fsf_req
)
2855 int retval
= -EINVAL
;
2856 struct zfcp_port
*port
;
2857 struct zfcp_unit
*unit
;
2858 struct fsf_qtcb_header
*header
;
2859 u16 subtable
, rule
, counter
;
2861 port
= fsf_req
->data
.close_physical_port
.port
;
2862 header
= &fsf_req
->qtcb
->header
;
2864 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
) {
2865 /* don't change port status in our bookkeeping */
2866 goto skip_fsfstatus
;
2869 /* evaluate FSF status in QTCB */
2870 switch (header
->fsf_status
) {
2872 case FSF_PORT_HANDLE_NOT_VALID
:
2873 ZFCP_LOG_FLAGS(1, "FSF_PORT_HANDLE_NOT_VALID\n");
2874 ZFCP_LOG_INFO("Temporary port identifier 0x%x invalid"
2875 "(adapter %s, port 0x%016Lx). "
2876 "This may happen occasionally.\n",
2878 zfcp_get_busid_by_port(port
),
2880 ZFCP_LOG_DEBUG("status qualifier:\n");
2881 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
2882 (char *) &header
->fsf_status_qual
,
2883 sizeof (union fsf_status_qual
));
2884 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
2886 zfcp_erp_adapter_reopen(port
->adapter
, 0);
2887 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
2890 case FSF_ACCESS_DENIED
:
2891 ZFCP_LOG_FLAGS(2, "FSF_ACCESS_DENIED\n");
2892 ZFCP_LOG_NORMAL("Access denied, cannot close "
2893 "physical port 0x%016Lx on adapter %s\n",
2894 port
->wwpn
, zfcp_get_busid_by_port(port
));
2895 for (counter
= 0; counter
< 2; counter
++) {
2896 subtable
= header
->fsf_status_qual
.halfword
[counter
* 2];
2897 rule
= header
->fsf_status_qual
.halfword
[counter
* 2 + 1];
2899 case FSF_SQ_CFDC_SUBTABLE_OS
:
2900 case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN
:
2901 case FSF_SQ_CFDC_SUBTABLE_PORT_DID
:
2902 case FSF_SQ_CFDC_SUBTABLE_LUN
:
2903 ZFCP_LOG_INFO("Access denied (%s rule %d)\n",
2904 zfcp_act_subtable_type
[subtable
], rule
);
2908 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1, "fsf_s_access");
2909 zfcp_erp_port_access_denied(port
);
2910 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
2913 case FSF_PORT_BOXED
:
2914 ZFCP_LOG_FLAGS(2, "FSF_PORT_BOXED\n");
2915 ZFCP_LOG_DEBUG("The remote port 0x%016Lx on adapter "
2916 "%s needs to be reopened but it was attempted "
2917 "to close it physically.\n",
2919 zfcp_get_busid_by_port(port
));
2920 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1, "fsf_s_pboxed");
2921 zfcp_erp_port_reopen(port
, 0);
2922 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
|
2923 ZFCP_STATUS_FSFREQ_RETRY
;
2926 case FSF_ADAPTER_STATUS_AVAILABLE
:
2927 ZFCP_LOG_FLAGS(2, "FSF_ADAPTER_STATUS_AVAILABLE\n");
2928 switch (header
->fsf_status_qual
.word
[0]) {
2929 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE
:
2931 "FSF_SQ_INVOKE_LINK_TEST_PROCEDURE\n");
2932 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
2934 /* This will now be escalated by ERP */
2935 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
2937 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED
:
2939 "FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED\n");
2940 /* ERP strategy will escalate */
2941 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
2943 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
2947 ("bug: Wrong status qualifier 0x%x arrived.\n",
2948 header
->fsf_status_qual
.word
[0]);
2949 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0,
2952 fsf_req
->adapter
->erp_dbf
, 0,
2953 &header
->fsf_status_qual
.word
[0], sizeof (u32
));
2959 ZFCP_LOG_FLAGS(3, "FSF_GOOD\n");
2960 ZFCP_LOG_DEBUG("Remote port 0x%016Lx via adapter %s "
2961 "physically closed, port handle 0x%x\n",
2963 zfcp_get_busid_by_port(port
), port
->handle
);
2964 /* can't use generic zfcp_erp_modify_port_status because
2965 * ZFCP_STATUS_COMMON_OPEN must not be reset for the port
2967 atomic_clear_mask(ZFCP_STATUS_PORT_PHYS_OPEN
, &port
->status
);
2968 list_for_each_entry(unit
, &port
->unit_list_head
, list
)
2969 atomic_clear_mask(ZFCP_STATUS_COMMON_OPEN
, &unit
->status
);
2974 ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
2975 "(debug info 0x%x)\n",
2976 header
->fsf_status
);
2977 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0, "fsf_s_inval:");
2978 debug_exception(fsf_req
->adapter
->erp_dbf
, 0,
2979 &header
->fsf_status
, sizeof (u32
));
2984 atomic_clear_mask(ZFCP_STATUS_PORT_PHYS_CLOSING
, &port
->status
);
2989 * function: zfcp_fsf_open_unit
2995 * assumptions: This routine does not check whether the associated
2996 * remote port has already been opened. This should be
2997 * done by calling routines. Otherwise some status
2998 * may be presented by FSF
3001 zfcp_fsf_open_unit(struct zfcp_erp_action
*erp_action
)
3003 volatile struct qdio_buffer_element
*sbale
;
3004 unsigned long lock_flags
;
3007 /* setup new FSF request */
3008 retval
= zfcp_fsf_req_create(erp_action
->adapter
,
3010 ZFCP_WAIT_FOR_SBAL
| ZFCP_REQ_AUTO_CLEANUP
,
3011 erp_action
->adapter
->pool
.fsf_req_erp
,
3012 &lock_flags
, &(erp_action
->fsf_req
));
3014 ZFCP_LOG_INFO("error: Could not create open unit request for "
3015 "unit 0x%016Lx on port 0x%016Lx on adapter %s.\n",
3016 erp_action
->unit
->fcp_lun
,
3017 erp_action
->unit
->port
->wwpn
,
3018 zfcp_get_busid_by_adapter(erp_action
->adapter
));
3022 sbale
= zfcp_qdio_sbale_req(erp_action
->fsf_req
,
3023 erp_action
->fsf_req
->sbal_curr
, 0);
3024 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_READ
;
3025 sbale
[1].flags
|= SBAL_FLAGS_LAST_ENTRY
;
3027 erp_action
->fsf_req
->qtcb
->header
.port_handle
=
3028 erp_action
->port
->handle
;
3029 erp_action
->fsf_req
->qtcb
->bottom
.support
.fcp_lun
=
3030 erp_action
->unit
->fcp_lun
;
3031 erp_action
->fsf_req
->qtcb
->bottom
.support
.option
=
3032 FSF_OPEN_LUN_SUPPRESS_BOXING
;
3033 atomic_set_mask(ZFCP_STATUS_COMMON_OPENING
, &erp_action
->unit
->status
);
3034 erp_action
->fsf_req
->data
.open_unit
.unit
= erp_action
->unit
;
3035 erp_action
->fsf_req
->erp_action
= erp_action
;
3037 /* start QDIO request for this FSF request */
3038 retval
= zfcp_fsf_req_send(erp_action
->fsf_req
, &erp_action
->timer
);
3040 ZFCP_LOG_INFO("error: Could not send an open unit request "
3041 "on the adapter %s, port 0x%016Lx for "
3043 zfcp_get_busid_by_adapter(erp_action
->adapter
),
3044 erp_action
->port
->wwpn
,
3045 erp_action
->unit
->fcp_lun
);
3046 zfcp_fsf_req_free(erp_action
->fsf_req
);
3047 erp_action
->fsf_req
= NULL
;
3051 ZFCP_LOG_TRACE("Open LUN request initiated (adapter %s, "
3052 "port 0x%016Lx, unit 0x%016Lx)\n",
3053 zfcp_get_busid_by_adapter(erp_action
->adapter
),
3054 erp_action
->port
->wwpn
, erp_action
->unit
->fcp_lun
);
3056 write_unlock_irqrestore(&erp_action
->adapter
->request_queue
.queue_lock
,
3062 * function: zfcp_fsf_open_unit_handler
3064 * purpose: is called for finished Open LUN command
3069 zfcp_fsf_open_unit_handler(struct zfcp_fsf_req
*fsf_req
)
3071 int retval
= -EINVAL
;
3072 struct zfcp_adapter
*adapter
;
3073 struct zfcp_unit
*unit
;
3074 struct fsf_qtcb_header
*header
;
3075 struct fsf_qtcb_bottom_support
*bottom
;
3076 struct fsf_queue_designator
*queue_designator
;
3077 u16 subtable
, rule
, counter
;
3078 u32 allowed
, exclusive
, readwrite
;
3080 unit
= fsf_req
->data
.open_unit
.unit
;
3082 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
) {
3083 /* don't change unit status in our bookkeeping */
3084 goto skip_fsfstatus
;
3087 adapter
= fsf_req
->adapter
;
3088 header
= &fsf_req
->qtcb
->header
;
3089 bottom
= &fsf_req
->qtcb
->bottom
.support
;
3090 queue_designator
= &header
->fsf_status_qual
.fsf_queue_designator
;
3092 allowed
= bottom
->lun_access_info
& FSF_UNIT_ACCESS_OPEN_LUN_ALLOWED
;
3093 exclusive
= bottom
->lun_access_info
& FSF_UNIT_ACCESS_EXCLUSIVE
;
3094 readwrite
= bottom
->lun_access_info
& FSF_UNIT_ACCESS_OUTBOUND_TRANSFER
;
3096 atomic_clear_mask(ZFCP_STATUS_COMMON_ACCESS_DENIED
|
3097 ZFCP_STATUS_UNIT_SHARED
|
3098 ZFCP_STATUS_UNIT_READONLY
,
3101 /* evaluate FSF status in QTCB */
3102 switch (header
->fsf_status
) {
3104 case FSF_PORT_HANDLE_NOT_VALID
:
3105 ZFCP_LOG_FLAGS(1, "FSF_PORT_HANDLE_NOT_VALID\n");
3106 ZFCP_LOG_INFO("Temporary port identifier 0x%x "
3107 "for port 0x%016Lx on adapter %s invalid "
3108 "This may happen occasionally\n",
3110 unit
->port
->wwpn
, zfcp_get_busid_by_unit(unit
));
3111 ZFCP_LOG_DEBUG("status qualifier:\n");
3112 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
3113 (char *) &header
->fsf_status_qual
,
3114 sizeof (union fsf_status_qual
));
3115 debug_text_event(adapter
->erp_dbf
, 1, "fsf_s_ph_nv");
3116 zfcp_erp_adapter_reopen(unit
->port
->adapter
, 0);
3117 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3120 case FSF_LUN_ALREADY_OPEN
:
3121 ZFCP_LOG_FLAGS(0, "FSF_LUN_ALREADY_OPEN\n");
3122 ZFCP_LOG_NORMAL("bug: Attempted to open unit 0x%016Lx on "
3123 "remote port 0x%016Lx on adapter %s twice.\n",
3125 unit
->port
->wwpn
, zfcp_get_busid_by_unit(unit
));
3126 debug_text_exception(adapter
->erp_dbf
, 0,
3128 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3131 case FSF_ACCESS_DENIED
:
3132 ZFCP_LOG_FLAGS(2, "FSF_ACCESS_DENIED\n");
3133 ZFCP_LOG_NORMAL("Access denied, cannot open unit 0x%016Lx on "
3134 "remote port 0x%016Lx on adapter %s\n",
3135 unit
->fcp_lun
, unit
->port
->wwpn
,
3136 zfcp_get_busid_by_unit(unit
));
3137 for (counter
= 0; counter
< 2; counter
++) {
3138 subtable
= header
->fsf_status_qual
.halfword
[counter
* 2];
3139 rule
= header
->fsf_status_qual
.halfword
[counter
* 2 + 1];
3141 case FSF_SQ_CFDC_SUBTABLE_OS
:
3142 case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN
:
3143 case FSF_SQ_CFDC_SUBTABLE_PORT_DID
:
3144 case FSF_SQ_CFDC_SUBTABLE_LUN
:
3145 ZFCP_LOG_INFO("Access denied (%s rule %d)\n",
3146 zfcp_act_subtable_type
[subtable
], rule
);
3150 debug_text_event(adapter
->erp_dbf
, 1, "fsf_s_access");
3151 zfcp_erp_unit_access_denied(unit
);
3152 atomic_clear_mask(ZFCP_STATUS_UNIT_SHARED
, &unit
->status
);
3153 atomic_clear_mask(ZFCP_STATUS_UNIT_READONLY
, &unit
->status
);
3154 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3157 case FSF_PORT_BOXED
:
3158 ZFCP_LOG_FLAGS(2, "FSF_PORT_BOXED\n");
3159 ZFCP_LOG_DEBUG("The remote port 0x%016Lx on adapter %s "
3160 "needs to be reopened\n",
3161 unit
->port
->wwpn
, zfcp_get_busid_by_unit(unit
));
3162 debug_text_event(adapter
->erp_dbf
, 2, "fsf_s_pboxed");
3163 zfcp_erp_port_reopen(unit
->port
, 0);
3164 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
|
3165 ZFCP_STATUS_FSFREQ_RETRY
;
3168 case FSF_LUN_SHARING_VIOLATION
:
3169 ZFCP_LOG_FLAGS(2, "FSF_LUN_SHARING_VIOLATION\n");
3170 if (header
->fsf_status_qual
.word
[0] != 0) {
3171 ZFCP_LOG_NORMAL("FCP-LUN 0x%Lx at the remote port "
3173 "connected to the adapter %s "
3174 "is already in use in LPAR%d, CSS%d\n",
3177 zfcp_get_busid_by_unit(unit
),
3178 queue_designator
->hla
,
3179 queue_designator
->cssid
);
3181 subtable
= header
->fsf_status_qual
.halfword
[4];
3182 rule
= header
->fsf_status_qual
.halfword
[5];
3184 case FSF_SQ_CFDC_SUBTABLE_OS
:
3185 case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN
:
3186 case FSF_SQ_CFDC_SUBTABLE_PORT_DID
:
3187 case FSF_SQ_CFDC_SUBTABLE_LUN
:
3188 ZFCP_LOG_NORMAL("Access to FCP-LUN 0x%Lx at the "
3189 "remote port with WWPN 0x%Lx "
3190 "connected to the adapter %s "
3191 "is denied (%s rule %d)\n",
3194 zfcp_get_busid_by_unit(unit
),
3195 zfcp_act_subtable_type
[subtable
],
3200 ZFCP_LOG_DEBUG("status qualifier:\n");
3201 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
3202 (char *) &header
->fsf_status_qual
,
3203 sizeof (union fsf_status_qual
));
3204 debug_text_event(adapter
->erp_dbf
, 2,
3206 zfcp_erp_unit_access_denied(unit
);
3207 atomic_clear_mask(ZFCP_STATUS_UNIT_SHARED
, &unit
->status
);
3208 atomic_clear_mask(ZFCP_STATUS_UNIT_READONLY
, &unit
->status
);
3209 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3212 case FSF_MAXIMUM_NUMBER_OF_LUNS_EXCEEDED
:
3213 ZFCP_LOG_FLAGS(1, "FSF_MAXIMUM_NUMBER_OF_LUNS_EXCEEDED\n");
3214 ZFCP_LOG_INFO("error: The adapter ran out of resources. "
3215 "There is no handle (temporary port identifier) "
3216 "available for unit 0x%016Lx on port 0x%016Lx "
3220 zfcp_get_busid_by_unit(unit
));
3221 debug_text_event(adapter
->erp_dbf
, 1,
3223 zfcp_erp_unit_failed(unit
);
3224 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3227 case FSF_ADAPTER_STATUS_AVAILABLE
:
3228 ZFCP_LOG_FLAGS(2, "FSF_ADAPTER_STATUS_AVAILABLE\n");
3229 switch (header
->fsf_status_qual
.word
[0]) {
3230 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE
:
3232 "FSF_SQ_INVOKE_LINK_TEST_PROCEDURE\n");
3233 /* Re-establish link to port */
3234 debug_text_event(adapter
->erp_dbf
, 1,
3236 zfcp_erp_port_reopen(unit
->port
, 0);
3237 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3239 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED
:
3241 "FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED\n");
3242 /* ERP strategy will escalate */
3243 debug_text_event(adapter
->erp_dbf
, 1,
3245 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3249 ("bug: Wrong status qualifier 0x%x arrived.\n",
3250 header
->fsf_status_qual
.word
[0]);
3251 debug_text_event(adapter
->erp_dbf
, 0,
3253 debug_exception(adapter
->erp_dbf
, 0,
3254 &header
->fsf_status_qual
.word
[0],
3259 case FSF_INVALID_COMMAND_OPTION
:
3260 ZFCP_LOG_FLAGS(2, "FSF_INVALID_COMMAND_OPTION\n");
3262 "Invalid option 0x%x has been specified "
3263 "in QTCB bottom sent to the adapter %s\n",
3265 zfcp_get_busid_by_adapter(adapter
));
3266 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3271 ZFCP_LOG_FLAGS(3, "FSF_GOOD\n");
3272 /* save LUN handle assigned by FSF */
3273 unit
->handle
= header
->lun_handle
;
3274 ZFCP_LOG_TRACE("unit 0x%016Lx on remote port 0x%016Lx on "
3275 "adapter %s opened, port handle 0x%x\n",
3278 zfcp_get_busid_by_unit(unit
),
3280 /* mark unit as open */
3281 atomic_set_mask(ZFCP_STATUS_COMMON_OPEN
, &unit
->status
);
3283 if (adapter
->supported_features
& FSF_FEATURE_LUN_SHARING
){
3285 atomic_set_mask(ZFCP_STATUS_UNIT_SHARED
,
3289 atomic_set_mask(ZFCP_STATUS_UNIT_READONLY
,
3291 ZFCP_LOG_NORMAL("read-only access for unit "
3292 "(adapter %s, wwpn=0x%016Lx, "
3293 "fcp_lun=0x%016Lx)\n",
3294 zfcp_get_busid_by_unit(unit
),
3299 if (exclusive
&& !readwrite
) {
3300 ZFCP_LOG_NORMAL("exclusive access of read-only "
3301 "unit not supported\n");
3302 zfcp_erp_unit_failed(unit
);
3303 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3304 zfcp_erp_unit_shutdown(unit
, 0);
3305 } else if (!exclusive
&& readwrite
) {
3306 ZFCP_LOG_NORMAL("shared access of read-write "
3307 "unit not supported\n");
3308 zfcp_erp_unit_failed(unit
);
3309 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3310 zfcp_erp_unit_shutdown(unit
, 0);
3318 ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
3319 "(debug info 0x%x)\n",
3320 header
->fsf_status
);
3321 debug_text_event(adapter
->erp_dbf
, 0, "fsf_s_inval:");
3322 debug_exception(adapter
->erp_dbf
, 0,
3323 &header
->fsf_status
, sizeof (u32
));
3328 atomic_clear_mask(ZFCP_STATUS_COMMON_OPENING
, &unit
->status
);
3333 * function: zfcp_fsf_close_unit
3337 * returns: address of fsf_req - request successfully initiated
3340 * assumptions: This routine does not check whether the associated
3341 * remote port/lun has already been opened. This should be
3342 * done by calling routines. Otherwise some status
3343 * may be presented by FSF
3346 zfcp_fsf_close_unit(struct zfcp_erp_action
*erp_action
)
3348 volatile struct qdio_buffer_element
*sbale
;
3349 unsigned long lock_flags
;
3352 /* setup new FSF request */
3353 retval
= zfcp_fsf_req_create(erp_action
->adapter
,
3355 ZFCP_WAIT_FOR_SBAL
| ZFCP_REQ_AUTO_CLEANUP
,
3356 erp_action
->adapter
->pool
.fsf_req_erp
,
3357 &lock_flags
, &(erp_action
->fsf_req
));
3359 ZFCP_LOG_INFO("error: Could not create close unit request for "
3360 "unit 0x%016Lx on port 0x%016Lx on adapter %s.\n",
3361 erp_action
->unit
->fcp_lun
,
3362 erp_action
->port
->wwpn
,
3363 zfcp_get_busid_by_adapter(erp_action
->adapter
));
3367 sbale
= zfcp_qdio_sbale_req(erp_action
->fsf_req
,
3368 erp_action
->fsf_req
->sbal_curr
, 0);
3369 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_READ
;
3370 sbale
[1].flags
|= SBAL_FLAGS_LAST_ENTRY
;
3372 erp_action
->fsf_req
->qtcb
->header
.port_handle
=
3373 erp_action
->port
->handle
;
3374 erp_action
->fsf_req
->qtcb
->header
.lun_handle
= erp_action
->unit
->handle
;
3375 atomic_set_mask(ZFCP_STATUS_COMMON_CLOSING
, &erp_action
->unit
->status
);
3376 erp_action
->fsf_req
->data
.close_unit
.unit
= erp_action
->unit
;
3377 erp_action
->fsf_req
->erp_action
= erp_action
;
3379 /* start QDIO request for this FSF request */
3380 retval
= zfcp_fsf_req_send(erp_action
->fsf_req
, &erp_action
->timer
);
3382 ZFCP_LOG_INFO("error: Could not send a close unit request for "
3383 "unit 0x%016Lx on port 0x%016Lx onadapter %s.\n",
3384 erp_action
->unit
->fcp_lun
,
3385 erp_action
->port
->wwpn
,
3386 zfcp_get_busid_by_adapter(erp_action
->adapter
));
3387 zfcp_fsf_req_free(erp_action
->fsf_req
);
3388 erp_action
->fsf_req
= NULL
;
3392 ZFCP_LOG_TRACE("Close LUN request initiated (adapter %s, "
3393 "port 0x%016Lx, unit 0x%016Lx)\n",
3394 zfcp_get_busid_by_adapter(erp_action
->adapter
),
3395 erp_action
->port
->wwpn
, erp_action
->unit
->fcp_lun
);
3397 write_unlock_irqrestore(&erp_action
->adapter
->request_queue
.queue_lock
,
3403 * function: zfcp_fsf_close_unit_handler
3405 * purpose: is called for finished Close LUN FSF command
3410 zfcp_fsf_close_unit_handler(struct zfcp_fsf_req
*fsf_req
)
3412 int retval
= -EINVAL
;
3413 struct zfcp_unit
*unit
;
3415 unit
= fsf_req
->data
.close_unit
.unit
; /* restore unit */
3417 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
) {
3418 /* don't change unit status in our bookkeeping */
3419 goto skip_fsfstatus
;
3422 /* evaluate FSF status in QTCB */
3423 switch (fsf_req
->qtcb
->header
.fsf_status
) {
3425 case FSF_PORT_HANDLE_NOT_VALID
:
3426 ZFCP_LOG_FLAGS(1, "FSF_PORT_HANDLE_NOT_VALID\n");
3427 ZFCP_LOG_INFO("Temporary port identifier 0x%x for port "
3428 "0x%016Lx on adapter %s invalid. This may "
3429 "happen in rare circumstances\n",
3432 zfcp_get_busid_by_unit(unit
));
3433 ZFCP_LOG_DEBUG("status qualifier:\n");
3434 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
3435 (char *) &fsf_req
->qtcb
->header
.fsf_status_qual
,
3436 sizeof (union fsf_status_qual
));
3437 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
3439 zfcp_erp_adapter_reopen(unit
->port
->adapter
, 0);
3440 zfcp_cmd_dbf_event_fsf("porthinv", fsf_req
,
3441 &fsf_req
->qtcb
->header
.fsf_status_qual
,
3442 sizeof (union fsf_status_qual
));
3443 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3446 case FSF_LUN_HANDLE_NOT_VALID
:
3447 ZFCP_LOG_FLAGS(1, "FSF_LUN_HANDLE_NOT_VALID\n");
3448 ZFCP_LOG_INFO("Temporary LUN identifier 0x%x of unit "
3449 "0x%016Lx on port 0x%016Lx on adapter %s is "
3450 "invalid. This may happen occasionally.\n",
3454 zfcp_get_busid_by_unit(unit
));
3455 ZFCP_LOG_DEBUG("Status qualifier data:\n");
3456 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
3457 (char *) &fsf_req
->qtcb
->header
.fsf_status_qual
,
3458 sizeof (union fsf_status_qual
));
3459 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
3461 zfcp_erp_port_reopen(unit
->port
, 0);
3462 zfcp_cmd_dbf_event_fsf("lunhinv", fsf_req
,
3463 &fsf_req
->qtcb
->header
.fsf_status_qual
,
3464 sizeof (union fsf_status_qual
));
3465 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3468 case FSF_PORT_BOXED
:
3469 ZFCP_LOG_FLAGS(2, "FSF_PORT_BOXED\n");
3470 ZFCP_LOG_DEBUG("The remote port 0x%016Lx on adapter %s "
3471 "needs to be reopened\n",
3473 zfcp_get_busid_by_unit(unit
));
3474 debug_text_event(fsf_req
->adapter
->erp_dbf
, 2, "fsf_s_pboxed");
3475 zfcp_erp_port_reopen(unit
->port
, 0);
3476 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
|
3477 ZFCP_STATUS_FSFREQ_RETRY
;
3480 case FSF_ADAPTER_STATUS_AVAILABLE
:
3481 ZFCP_LOG_FLAGS(2, "FSF_ADAPTER_STATUS_AVAILABLE\n");
3482 switch (fsf_req
->qtcb
->header
.fsf_status_qual
.word
[0]) {
3483 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE
:
3485 "FSF_SQ_INVOKE_LINK_TEST_PROCEDURE\n");
3486 /* re-establish link to port */
3487 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
3489 zfcp_erp_port_reopen(unit
->port
, 0);
3490 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3492 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED
:
3494 "FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED\n");
3495 /* ERP strategy will escalate */
3496 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
3498 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3502 ("bug: Wrong status qualifier 0x%x arrived.\n",
3503 fsf_req
->qtcb
->header
.fsf_status_qual
.word
[0]);
3504 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0,
3507 fsf_req
->adapter
->erp_dbf
, 0,
3508 &fsf_req
->qtcb
->header
.fsf_status_qual
.word
[0],
3515 ZFCP_LOG_FLAGS(3, "FSF_GOOD\n");
3516 ZFCP_LOG_TRACE("unit 0x%016Lx on port 0x%016Lx on adapter %s "
3517 "closed, port handle 0x%x\n",
3520 zfcp_get_busid_by_unit(unit
),
3522 /* mark unit as closed */
3523 atomic_clear_mask(ZFCP_STATUS_COMMON_OPEN
, &unit
->status
);
3528 ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
3529 "(debug info 0x%x)\n",
3530 fsf_req
->qtcb
->header
.fsf_status
);
3531 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0, "fsf_s_inval:");
3532 debug_exception(fsf_req
->adapter
->erp_dbf
, 0,
3533 &fsf_req
->qtcb
->header
.fsf_status
,
3539 atomic_clear_mask(ZFCP_STATUS_COMMON_CLOSING
, &unit
->status
);
3544 * zfcp_fsf_send_fcp_command_task - initiate an FCP command (for a SCSI command)
3545 * @adapter: adapter where scsi command is issued
3546 * @unit: unit where command is sent to
3547 * @scsi_cmnd: scsi command to be sent
3548 * @timer: timer to be started when request is initiated
3549 * @req_flags: flags for fsf_request
3552 zfcp_fsf_send_fcp_command_task(struct zfcp_adapter
*adapter
,
3553 struct zfcp_unit
*unit
,
3554 struct scsi_cmnd
* scsi_cmnd
,
3555 struct timer_list
*timer
, int req_flags
)
3557 struct zfcp_fsf_req
*fsf_req
= NULL
;
3558 struct fcp_cmnd_iu
*fcp_cmnd_iu
;
3559 unsigned int sbtype
;
3560 unsigned long lock_flags
;
3565 /* setup new FSF request */
3566 retval
= zfcp_fsf_req_create(adapter
, FSF_QTCB_FCP_CMND
, req_flags
,
3567 adapter
->pool
.fsf_req_scsi
,
3568 &lock_flags
, &fsf_req
);
3569 if (unlikely(retval
< 0)) {
3570 ZFCP_LOG_DEBUG("error: Could not create FCP command request "
3571 "for unit 0x%016Lx on port 0x%016Lx on "
3575 zfcp_get_busid_by_adapter(adapter
));
3576 goto failed_req_create
;
3580 * associate FSF request with SCSI request
3581 * (need this for look up on abort)
3583 fsf_req
->data
.send_fcp_command_task
.fsf_req
= fsf_req
;
3584 scsi_cmnd
->host_scribble
= (char *) &(fsf_req
->data
);
3587 * associate SCSI command with FSF request
3588 * (need this for look up on normal command completion)
3590 fsf_req
->data
.send_fcp_command_task
.scsi_cmnd
= scsi_cmnd
;
3591 fsf_req
->data
.send_fcp_command_task
.start_jiffies
= jiffies
;
3592 fsf_req
->data
.send_fcp_command_task
.unit
= unit
;
3593 ZFCP_LOG_DEBUG("unit=%p, fcp_lun=0x%016Lx\n", unit
, unit
->fcp_lun
);
3595 /* set handles of unit and its parent port in QTCB */
3596 fsf_req
->qtcb
->header
.lun_handle
= unit
->handle
;
3597 fsf_req
->qtcb
->header
.port_handle
= unit
->port
->handle
;
3599 /* FSF does not define the structure of the FCP_CMND IU */
3600 fcp_cmnd_iu
= (struct fcp_cmnd_iu
*)
3601 &(fsf_req
->qtcb
->bottom
.io
.fcp_cmnd
);
3604 * set depending on data direction:
3605 * data direction bits in SBALE (SB Type)
3606 * data direction bits in QTCB
3607 * data direction bits in FCP_CMND IU
3609 switch (scsi_cmnd
->sc_data_direction
) {
3611 ZFCP_LOG_FLAGS(3, "DMA_NONE\n");
3612 fsf_req
->qtcb
->bottom
.io
.data_direction
= FSF_DATADIR_CMND
;
3615 * what is the correct type for commands
3616 * without 'real' data buffers?
3618 sbtype
= SBAL_FLAGS0_TYPE_READ
;
3620 case DMA_FROM_DEVICE
:
3621 ZFCP_LOG_FLAGS(3, "DMA_FROM_DEVICE\n");
3622 fsf_req
->qtcb
->bottom
.io
.data_direction
= FSF_DATADIR_READ
;
3623 sbtype
= SBAL_FLAGS0_TYPE_READ
;
3624 fcp_cmnd_iu
->rddata
= 1;
3627 ZFCP_LOG_FLAGS(3, "DMA_TO_DEVICE\n");
3628 fsf_req
->qtcb
->bottom
.io
.data_direction
= FSF_DATADIR_WRITE
;
3629 sbtype
= SBAL_FLAGS0_TYPE_WRITE
;
3630 fcp_cmnd_iu
->wddata
= 1;
3632 case DMA_BIDIRECTIONAL
:
3633 ZFCP_LOG_FLAGS(0, "DMA_BIDIRECTIONAL not supported\n");
3636 * dummy, catch this condition earlier
3637 * in zfcp_scsi_queuecommand
3639 goto failed_scsi_cmnd
;
3642 /* set FC service class in QTCB (3 per default) */
3643 fsf_req
->qtcb
->bottom
.io
.service_class
= adapter
->fc_service_class
;
3645 /* set FCP_LUN in FCP_CMND IU in QTCB */
3646 fcp_cmnd_iu
->fcp_lun
= unit
->fcp_lun
;
3648 mask
= ZFCP_STATUS_UNIT_READONLY
| ZFCP_STATUS_UNIT_SHARED
;
3650 /* set task attributes in FCP_CMND IU in QTCB */
3651 if (likely((scsi_cmnd
->device
->simple_tags
) ||
3652 (atomic_test_mask(mask
, &unit
->status
))))
3653 fcp_cmnd_iu
->task_attribute
= SIMPLE_Q
;
3655 fcp_cmnd_iu
->task_attribute
= UNTAGGED
;
3657 /* set additional length of FCP_CDB in FCP_CMND IU in QTCB, if needed */
3658 if (unlikely(scsi_cmnd
->cmd_len
> FCP_CDB_LENGTH
)) {
3659 fcp_cmnd_iu
->add_fcp_cdb_length
3660 = (scsi_cmnd
->cmd_len
- FCP_CDB_LENGTH
) >> 2;
3661 ZFCP_LOG_TRACE("SCSI CDB length is 0x%x, "
3662 "additional FCP_CDB length is 0x%x "
3663 "(shifted right 2 bits)\n",
3665 fcp_cmnd_iu
->add_fcp_cdb_length
);
3668 * copy SCSI CDB (including additional length, if any) to
3669 * FCP_CDB in FCP_CMND IU in QTCB
3671 memcpy(fcp_cmnd_iu
->fcp_cdb
, scsi_cmnd
->cmnd
, scsi_cmnd
->cmd_len
);
3673 /* FCP CMND IU length in QTCB */
3674 fsf_req
->qtcb
->bottom
.io
.fcp_cmnd_length
=
3675 sizeof (struct fcp_cmnd_iu
) +
3676 fcp_cmnd_iu
->add_fcp_cdb_length
+ sizeof (fcp_dl_t
);
3678 /* generate SBALEs from data buffer */
3679 real_bytes
= zfcp_qdio_sbals_from_scsicmnd(fsf_req
, sbtype
, scsi_cmnd
);
3680 if (unlikely(real_bytes
< 0)) {
3681 if (fsf_req
->sbal_number
< ZFCP_MAX_SBALS_PER_REQ
) {
3683 "Data did not fit into available buffer(s), "
3684 "waiting for more...\n");
3687 ZFCP_LOG_NORMAL("error: No truncation implemented but "
3688 "required. Shutting down unit "
3689 "(adapter %s, port 0x%016Lx, "
3691 zfcp_get_busid_by_unit(unit
),
3694 zfcp_erp_unit_shutdown(unit
, 0);
3700 /* set length of FCP data length in FCP_CMND IU in QTCB */
3701 zfcp_set_fcp_dl(fcp_cmnd_iu
, real_bytes
);
3703 ZFCP_LOG_DEBUG("Sending SCSI command:\n");
3704 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
3705 (char *) scsi_cmnd
->cmnd
, scsi_cmnd
->cmd_len
);
3708 * start QDIO request for this FSF request
3709 * covered by an SBALE)
3711 retval
= zfcp_fsf_req_send(fsf_req
, timer
);
3712 if (unlikely(retval
< 0)) {
3713 ZFCP_LOG_INFO("error: Could not send FCP command request "
3714 "on adapter %s, port 0x%016Lx, unit 0x%016Lx\n",
3715 zfcp_get_busid_by_adapter(adapter
),
3721 ZFCP_LOG_TRACE("Send FCP Command initiated (adapter %s, "
3722 "port 0x%016Lx, unit 0x%016Lx)\n",
3723 zfcp_get_busid_by_adapter(adapter
),
3731 zfcp_fsf_req_free(fsf_req
);
3733 scsi_cmnd
->host_scribble
= NULL
;
3736 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
, lock_flags
);
3741 * function: zfcp_fsf_send_fcp_command_task_management
3747 * FIXME(design): should be watched by a timeout!!!
3748 * FIXME(design) shouldn't this be modified to return an int
3749 * also...don't know how though
3752 struct zfcp_fsf_req
*
3753 zfcp_fsf_send_fcp_command_task_management(struct zfcp_adapter
*adapter
,
3754 struct zfcp_unit
*unit
,
3755 u8 tm_flags
, int req_flags
)
3757 struct zfcp_fsf_req
*fsf_req
= NULL
;
3759 struct fcp_cmnd_iu
*fcp_cmnd_iu
;
3760 unsigned long lock_flags
;
3761 volatile struct qdio_buffer_element
*sbale
;
3763 /* setup new FSF request */
3764 retval
= zfcp_fsf_req_create(adapter
, FSF_QTCB_FCP_CMND
, req_flags
,
3765 adapter
->pool
.fsf_req_scsi
,
3766 &lock_flags
, &fsf_req
);
3768 ZFCP_LOG_INFO("error: Could not create FCP command (task "
3769 "management) request for adapter %s, port "
3770 " 0x%016Lx, unit 0x%016Lx.\n",
3771 zfcp_get_busid_by_adapter(adapter
),
3772 unit
->port
->wwpn
, unit
->fcp_lun
);
3777 * Used to decide on proper handler in the return path,
3778 * could be either zfcp_fsf_send_fcp_command_task_handler or
3779 * zfcp_fsf_send_fcp_command_task_management_handler */
3781 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT
;
3784 * hold a pointer to the unit being target of this
3785 * task management request
3787 fsf_req
->data
.send_fcp_command_task_management
.unit
= unit
;
3789 /* set FSF related fields in QTCB */
3790 fsf_req
->qtcb
->header
.lun_handle
= unit
->handle
;
3791 fsf_req
->qtcb
->header
.port_handle
= unit
->port
->handle
;
3792 fsf_req
->qtcb
->bottom
.io
.data_direction
= FSF_DATADIR_CMND
;
3793 fsf_req
->qtcb
->bottom
.io
.service_class
= adapter
->fc_service_class
;
3794 fsf_req
->qtcb
->bottom
.io
.fcp_cmnd_length
=
3795 sizeof (struct fcp_cmnd_iu
) + sizeof (fcp_dl_t
);
3797 sbale
= zfcp_qdio_sbale_req(fsf_req
, fsf_req
->sbal_curr
, 0);
3798 sbale
[0].flags
|= SBAL_FLAGS0_TYPE_WRITE
;
3799 sbale
[1].flags
|= SBAL_FLAGS_LAST_ENTRY
;
3801 /* set FCP related fields in FCP_CMND IU in QTCB */
3802 fcp_cmnd_iu
= (struct fcp_cmnd_iu
*)
3803 &(fsf_req
->qtcb
->bottom
.io
.fcp_cmnd
);
3804 fcp_cmnd_iu
->fcp_lun
= unit
->fcp_lun
;
3805 fcp_cmnd_iu
->task_management_flags
= tm_flags
;
3807 /* start QDIO request for this FSF request */
3808 zfcp_fsf_start_scsi_er_timer(adapter
);
3809 retval
= zfcp_fsf_req_send(fsf_req
, NULL
);
3811 del_timer(&adapter
->scsi_er_timer
);
3812 ZFCP_LOG_INFO("error: Could not send an FCP-command (task "
3813 "management) on adapter %s, port 0x%016Lx for "
3814 "unit LUN 0x%016Lx\n",
3815 zfcp_get_busid_by_adapter(adapter
),
3818 zfcp_fsf_req_free(fsf_req
);
3823 ZFCP_LOG_TRACE("Send FCP Command (task management function) initiated "
3824 "(adapter %s, port 0x%016Lx, unit 0x%016Lx, "
3826 zfcp_get_busid_by_adapter(adapter
),
3831 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
, lock_flags
);
3836 * function: zfcp_fsf_send_fcp_command_handler
3838 * purpose: is called for finished Send FCP Command
3843 zfcp_fsf_send_fcp_command_handler(struct zfcp_fsf_req
*fsf_req
)
3845 int retval
= -EINVAL
;
3846 struct zfcp_unit
*unit
;
3847 struct fsf_qtcb_header
*header
;
3848 u16 subtable
, rule
, counter
;
3850 header
= &fsf_req
->qtcb
->header
;
3852 if (unlikely(fsf_req
->status
& ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT
))
3853 unit
= fsf_req
->data
.send_fcp_command_task_management
.unit
;
3855 unit
= fsf_req
->data
.send_fcp_command_task
.unit
;
3857 if (unlikely(fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
)) {
3858 /* go directly to calls of special handlers */
3859 goto skip_fsfstatus
;
3862 /* evaluate FSF status in QTCB */
3863 switch (header
->fsf_status
) {
3865 case FSF_PORT_HANDLE_NOT_VALID
:
3866 ZFCP_LOG_FLAGS(1, "FSF_PORT_HANDLE_NOT_VALID\n");
3867 ZFCP_LOG_INFO("Temporary port identifier 0x%x for port "
3868 "0x%016Lx on adapter %s invalid\n",
3870 unit
->port
->wwpn
, zfcp_get_busid_by_unit(unit
));
3871 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
3872 (char *) &header
->fsf_status_qual
,
3873 sizeof (union fsf_status_qual
));
3874 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
3876 zfcp_erp_adapter_reopen(unit
->port
->adapter
, 0);
3877 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3880 case FSF_LUN_HANDLE_NOT_VALID
:
3881 ZFCP_LOG_FLAGS(1, "FSF_LUN_HANDLE_NOT_VALID\n");
3882 ZFCP_LOG_INFO("Temporary LUN identifier 0x%x for unit "
3883 "0x%016Lx on port 0x%016Lx on adapter %s is "
3884 "invalid. This may happen occasionally.\n",
3888 zfcp_get_busid_by_unit(unit
));
3889 ZFCP_LOG_NORMAL("Status qualifier data:\n");
3890 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_NORMAL
,
3891 (char *) &header
->fsf_status_qual
,
3892 sizeof (union fsf_status_qual
));
3893 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
3895 zfcp_erp_port_reopen(unit
->port
, 0);
3896 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3899 case FSF_HANDLE_MISMATCH
:
3900 ZFCP_LOG_FLAGS(0, "FSF_HANDLE_MISMATCH\n");
3901 ZFCP_LOG_NORMAL("bug: The port handle 0x%x has changed "
3902 "unexpectedly. (adapter %s, port 0x%016Lx, "
3905 zfcp_get_busid_by_unit(unit
),
3908 ZFCP_LOG_NORMAL("status qualifier:\n");
3909 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_NORMAL
,
3910 (char *) &header
->fsf_status_qual
,
3911 sizeof (union fsf_status_qual
));
3912 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
3914 zfcp_erp_adapter_reopen(unit
->port
->adapter
, 0);
3915 zfcp_cmd_dbf_event_fsf("handmism",
3917 &header
->fsf_status_qual
,
3918 sizeof (union fsf_status_qual
));
3919 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3922 case FSF_SERVICE_CLASS_NOT_SUPPORTED
:
3923 ZFCP_LOG_FLAGS(0, "FSF_SERVICE_CLASS_NOT_SUPPORTED\n");
3924 if (fsf_req
->adapter
->fc_service_class
<= 3) {
3925 ZFCP_LOG_NORMAL("error: The adapter %s does "
3926 "not support fibrechannel class %d.\n",
3927 zfcp_get_busid_by_unit(unit
),
3928 fsf_req
->adapter
->fc_service_class
);
3930 ZFCP_LOG_NORMAL("bug: The fibrechannel class at "
3931 "adapter %s is invalid. "
3932 "(debug info %d)\n",
3933 zfcp_get_busid_by_unit(unit
),
3934 fsf_req
->adapter
->fc_service_class
);
3936 /* stop operation for this adapter */
3937 debug_text_exception(fsf_req
->adapter
->erp_dbf
, 0,
3938 "fsf_s_class_nsup");
3939 zfcp_erp_adapter_shutdown(unit
->port
->adapter
, 0);
3940 zfcp_cmd_dbf_event_fsf("unsclass",
3942 &header
->fsf_status_qual
,
3943 sizeof (union fsf_status_qual
));
3944 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3947 case FSF_FCPLUN_NOT_VALID
:
3948 ZFCP_LOG_FLAGS(0, "FSF_FCPLUN_NOT_VALID\n");
3949 ZFCP_LOG_NORMAL("bug: unit 0x%016Lx on port 0x%016Lx on "
3950 "adapter %s does not have correct unit "
3954 zfcp_get_busid_by_unit(unit
),
3956 ZFCP_LOG_DEBUG("status qualifier:\n");
3957 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
3958 (char *) &header
->fsf_status_qual
,
3959 sizeof (union fsf_status_qual
));
3960 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
3961 "fsf_s_fcp_lun_nv");
3962 zfcp_erp_port_reopen(unit
->port
, 0);
3963 zfcp_cmd_dbf_event_fsf("fluninv",
3965 &header
->fsf_status_qual
,
3966 sizeof (union fsf_status_qual
));
3967 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3970 case FSF_ACCESS_DENIED
:
3971 ZFCP_LOG_FLAGS(2, "FSF_ACCESS_DENIED\n");
3972 ZFCP_LOG_NORMAL("Access denied, cannot send FCP command to "
3973 "unit 0x%016Lx on port 0x%016Lx on "
3974 "adapter %s\n", unit
->fcp_lun
, unit
->port
->wwpn
,
3975 zfcp_get_busid_by_unit(unit
));
3976 for (counter
= 0; counter
< 2; counter
++) {
3977 subtable
= header
->fsf_status_qual
.halfword
[counter
* 2];
3978 rule
= header
->fsf_status_qual
.halfword
[counter
* 2 + 1];
3980 case FSF_SQ_CFDC_SUBTABLE_OS
:
3981 case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN
:
3982 case FSF_SQ_CFDC_SUBTABLE_PORT_DID
:
3983 case FSF_SQ_CFDC_SUBTABLE_LUN
:
3984 ZFCP_LOG_INFO("Access denied (%s rule %d)\n",
3985 zfcp_act_subtable_type
[subtable
], rule
);
3989 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1, "fsf_s_access");
3990 zfcp_erp_unit_access_denied(unit
);
3991 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
3994 case FSF_DIRECTION_INDICATOR_NOT_VALID
:
3995 ZFCP_LOG_FLAGS(0, "FSF_DIRECTION_INDICATOR_NOT_VALID\n");
3996 ZFCP_LOG_INFO("bug: Invalid data direction given for unit "
3997 "0x%016Lx on port 0x%016Lx on adapter %s "
3998 "(debug info %d)\n",
4001 zfcp_get_busid_by_unit(unit
),
4002 fsf_req
->qtcb
->bottom
.io
.data_direction
);
4003 /* stop operation for this adapter */
4004 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0,
4005 "fsf_s_dir_ind_nv");
4006 zfcp_erp_adapter_shutdown(unit
->port
->adapter
, 0);
4007 zfcp_cmd_dbf_event_fsf("dirinv",
4009 &header
->fsf_status_qual
,
4010 sizeof (union fsf_status_qual
));
4011 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4014 case FSF_CMND_LENGTH_NOT_VALID
:
4015 ZFCP_LOG_FLAGS(0, "FSF_CMND_LENGTH_NOT_VALID\n");
4017 ("bug: An invalid control-data-block length field "
4018 "was found in a command for unit 0x%016Lx on port "
4019 "0x%016Lx on adapter %s " "(debug info %d)\n",
4020 unit
->fcp_lun
, unit
->port
->wwpn
,
4021 zfcp_get_busid_by_unit(unit
),
4022 fsf_req
->qtcb
->bottom
.io
.fcp_cmnd_length
);
4023 /* stop operation for this adapter */
4024 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0,
4025 "fsf_s_cmd_len_nv");
4026 zfcp_erp_adapter_shutdown(unit
->port
->adapter
, 0);
4027 zfcp_cmd_dbf_event_fsf("cleninv",
4029 &header
->fsf_status_qual
,
4030 sizeof (union fsf_status_qual
));
4031 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4034 case FSF_PORT_BOXED
:
4035 ZFCP_LOG_FLAGS(2, "FSF_PORT_BOXED\n");
4036 ZFCP_LOG_DEBUG("The remote port 0x%016Lx on adapter %s "
4037 "needs to be reopened\n",
4038 unit
->port
->wwpn
, zfcp_get_busid_by_unit(unit
));
4039 debug_text_event(fsf_req
->adapter
->erp_dbf
, 2, "fsf_s_pboxed");
4040 zfcp_erp_port_reopen(unit
->port
, 0);
4041 zfcp_cmd_dbf_event_fsf("portbox", fsf_req
,
4042 &header
->fsf_status_qual
,
4043 sizeof (union fsf_status_qual
));
4044 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
|
4045 ZFCP_STATUS_FSFREQ_RETRY
;
4049 ZFCP_LOG_FLAGS(0, "FSF_LUN_BOXED\n");
4050 ZFCP_LOG_NORMAL("unit needs to be reopened (adapter %s, "
4051 "wwpn=0x%016Lx, fcp_lun=0x%016Lx)\n",
4052 zfcp_get_busid_by_unit(unit
),
4053 unit
->port
->wwpn
, unit
->fcp_lun
);
4054 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1, "fsf_s_lboxed");
4055 zfcp_erp_unit_reopen(unit
, 0);
4056 zfcp_cmd_dbf_event_fsf("unitbox", fsf_req
,
4057 &header
->fsf_status_qual
,
4058 sizeof(union fsf_status_qual
));
4059 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
4060 | ZFCP_STATUS_FSFREQ_RETRY
;
4063 case FSF_ADAPTER_STATUS_AVAILABLE
:
4064 ZFCP_LOG_FLAGS(2, "FSF_ADAPTER_STATUS_AVAILABLE\n");
4065 switch (header
->fsf_status_qual
.word
[0]) {
4066 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE
:
4068 "FSF_SQ_INVOKE_LINK_TEST_PROCEDURE\n");
4069 /* re-establish link to port */
4070 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
4072 zfcp_erp_port_reopen(unit
->port
, 0);
4073 zfcp_cmd_dbf_event_fsf(
4076 &header
->fsf_status_qual
,
4077 sizeof (union fsf_status_qual
));
4078 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4080 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED
:
4082 "FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED\n");
4083 /* FIXME(hw) need proper specs for proper action */
4084 /* let scsi stack deal with retries and escalation */
4085 debug_text_event(fsf_req
->adapter
->erp_dbf
, 1,
4087 zfcp_cmd_dbf_event_fsf(
4090 &header
->fsf_status_qual
,
4091 sizeof (union fsf_status_qual
));
4092 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4095 /* FIXME: shall we consider this a successful transfer? */
4097 ("bug: Wrong status qualifier 0x%x arrived.\n",
4098 header
->fsf_status_qual
.word
[0]);
4099 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0,
4101 debug_exception(fsf_req
->adapter
->erp_dbf
, 0,
4102 &header
->fsf_status_qual
.word
[0],
4109 ZFCP_LOG_FLAGS(3, "FSF_GOOD\n");
4112 case FSF_FCP_RSP_AVAILABLE
:
4113 ZFCP_LOG_FLAGS(2, "FSF_FCP_RSP_AVAILABLE\n");
4117 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0, "fsf_s_inval:");
4118 debug_exception(fsf_req
->adapter
->erp_dbf
, 0,
4119 &header
->fsf_status
, sizeof(u32
));
4124 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT
) {
4126 zfcp_fsf_send_fcp_command_task_management_handler(fsf_req
);
4128 retval
= zfcp_fsf_send_fcp_command_task_handler(fsf_req
);
4134 * function: zfcp_fsf_send_fcp_command_task_handler
4136 * purpose: evaluates FCP_RSP IU
4141 zfcp_fsf_send_fcp_command_task_handler(struct zfcp_fsf_req
*fsf_req
)
4144 struct scsi_cmnd
*scpnt
;
4145 struct fcp_rsp_iu
*fcp_rsp_iu
= (struct fcp_rsp_iu
*)
4146 &(fsf_req
->qtcb
->bottom
.io
.fcp_rsp
);
4147 struct fcp_cmnd_iu
*fcp_cmnd_iu
= (struct fcp_cmnd_iu
*)
4148 &(fsf_req
->qtcb
->bottom
.io
.fcp_cmnd
);
4150 char *fcp_rsp_info
= zfcp_get_fcp_rsp_info_ptr(fcp_rsp_iu
);
4151 unsigned long flags
;
4152 struct zfcp_unit
*unit
= fsf_req
->data
.send_fcp_command_task
.unit
;
4154 read_lock_irqsave(&fsf_req
->adapter
->abort_lock
, flags
);
4155 scpnt
= fsf_req
->data
.send_fcp_command_task
.scsi_cmnd
;
4156 if (unlikely(!scpnt
)) {
4158 ("Command with fsf_req %p is not associated to "
4159 "a scsi command anymore. Aborted?\n", fsf_req
);
4162 if (unlikely(fsf_req
->status
& ZFCP_STATUS_FSFREQ_ABORTED
)) {
4163 /* FIXME: (design) mid-layer should handle DID_ABORT like
4164 * DID_SOFT_ERROR by retrying the request for devices
4165 * that allow retries.
4167 ZFCP_LOG_DEBUG("Setting DID_SOFT_ERROR and SUGGEST_RETRY\n");
4168 set_host_byte(&scpnt
->result
, DID_SOFT_ERROR
);
4169 set_driver_byte(&scpnt
->result
, SUGGEST_RETRY
);
4170 goto skip_fsfstatus
;
4173 if (unlikely(fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
)) {
4174 ZFCP_LOG_DEBUG("Setting DID_ERROR\n");
4175 set_host_byte(&scpnt
->result
, DID_ERROR
);
4176 goto skip_fsfstatus
;
4179 /* set message byte of result in SCSI command */
4180 scpnt
->result
|= COMMAND_COMPLETE
<< 8;
4183 * copy SCSI status code of FCP_STATUS of FCP_RSP IU to status byte
4184 * of result in SCSI command
4186 scpnt
->result
|= fcp_rsp_iu
->scsi_status
;
4187 if (unlikely(fcp_rsp_iu
->scsi_status
)) {
4189 ZFCP_LOG_DEBUG("status for SCSI Command:\n");
4190 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
4191 scpnt
->cmnd
, scpnt
->cmd_len
);
4192 ZFCP_LOG_DEBUG("SCSI status code 0x%x\n",
4193 fcp_rsp_iu
->scsi_status
);
4194 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
4195 (void *) fcp_rsp_iu
, sizeof (struct fcp_rsp_iu
));
4196 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
4197 zfcp_get_fcp_sns_info_ptr(fcp_rsp_iu
),
4198 fcp_rsp_iu
->fcp_sns_len
);
4201 /* check FCP_RSP_INFO */
4202 if (unlikely(fcp_rsp_iu
->validity
.bits
.fcp_rsp_len_valid
)) {
4203 ZFCP_LOG_DEBUG("rsp_len is valid\n");
4204 switch (fcp_rsp_info
[3]) {
4206 ZFCP_LOG_FLAGS(3, "RSP_CODE_GOOD\n");
4208 ZFCP_LOG_TRACE("no failure or Task Management "
4209 "Function complete\n");
4210 set_host_byte(&scpnt
->result
, DID_OK
);
4212 case RSP_CODE_LENGTH_MISMATCH
:
4213 ZFCP_LOG_FLAGS(0, "RSP_CODE_LENGTH_MISMATCH\n");
4215 ZFCP_LOG_NORMAL("bug: FCP response code indictates "
4216 "that the fibrechannel protocol data "
4217 "length differs from the burst length. "
4218 "The problem occured on unit 0x%016Lx "
4219 "on port 0x%016Lx on adapter %s",
4222 zfcp_get_busid_by_unit(unit
));
4223 /* dump SCSI CDB as prepared by zfcp */
4224 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
4225 (char *) &fsf_req
->qtcb
->
4226 bottom
.io
.fcp_cmnd
, FSF_FCP_CMND_SIZE
);
4227 zfcp_cmd_dbf_event_fsf("clenmis", fsf_req
, NULL
, 0);
4228 set_host_byte(&scpnt
->result
, DID_ERROR
);
4229 goto skip_fsfstatus
;
4230 case RSP_CODE_FIELD_INVALID
:
4231 ZFCP_LOG_FLAGS(0, "RSP_CODE_FIELD_INVALID\n");
4232 /* driver or hardware bug */
4233 ZFCP_LOG_NORMAL("bug: FCP response code indictates "
4234 "that the fibrechannel protocol data "
4235 "fields were incorrectly set up. "
4236 "The problem occured on the unit "
4237 "0x%016Lx on port 0x%016Lx on "
4241 zfcp_get_busid_by_unit(unit
));
4242 /* dump SCSI CDB as prepared by zfcp */
4243 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
4244 (char *) &fsf_req
->qtcb
->
4245 bottom
.io
.fcp_cmnd
, FSF_FCP_CMND_SIZE
);
4246 set_host_byte(&scpnt
->result
, DID_ERROR
);
4247 zfcp_cmd_dbf_event_fsf("codeinv", fsf_req
, NULL
, 0);
4248 goto skip_fsfstatus
;
4249 case RSP_CODE_RO_MISMATCH
:
4250 ZFCP_LOG_FLAGS(0, "RSP_CODE_RO_MISMATCH\n");
4252 ZFCP_LOG_NORMAL("bug: The FCP response code indicates "
4253 "that conflicting values for the "
4254 "fibrechannel payload offset from the "
4255 "header were found. "
4256 "The problem occured on unit 0x%016Lx "
4257 "on port 0x%016Lx on adapter %s.\n",
4260 zfcp_get_busid_by_unit(unit
));
4261 /* dump SCSI CDB as prepared by zfcp */
4262 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
4263 (char *) &fsf_req
->qtcb
->
4264 bottom
.io
.fcp_cmnd
, FSF_FCP_CMND_SIZE
);
4265 zfcp_cmd_dbf_event_fsf("codemism", fsf_req
, NULL
, 0);
4266 set_host_byte(&scpnt
->result
, DID_ERROR
);
4267 goto skip_fsfstatus
;
4269 ZFCP_LOG_NORMAL("bug: An invalid FCP response "
4270 "code was detected for a command. "
4271 "The problem occured on the unit "
4272 "0x%016Lx on port 0x%016Lx on "
4273 "adapter %s (debug info 0x%x)\n",
4276 zfcp_get_busid_by_unit(unit
),
4278 /* dump SCSI CDB as prepared by zfcp */
4279 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG
,
4280 (char *) &fsf_req
->qtcb
->
4281 bottom
.io
.fcp_cmnd
, FSF_FCP_CMND_SIZE
);
4282 zfcp_cmd_dbf_event_fsf("undeffcp", fsf_req
, NULL
, 0);
4283 set_host_byte(&scpnt
->result
, DID_ERROR
);
4287 /* check for sense data */
4288 if (unlikely(fcp_rsp_iu
->validity
.bits
.fcp_sns_len_valid
)) {
4289 sns_len
= FSF_FCP_RSP_SIZE
-
4290 sizeof (struct fcp_rsp_iu
) + fcp_rsp_iu
->fcp_rsp_len
;
4291 ZFCP_LOG_TRACE("room for %i bytes sense data in QTCB\n",
4293 sns_len
= min(sns_len
, (u32
) SCSI_SENSE_BUFFERSIZE
);
4294 ZFCP_LOG_TRACE("room for %i bytes sense data in SCSI command\n",
4295 SCSI_SENSE_BUFFERSIZE
);
4296 sns_len
= min(sns_len
, fcp_rsp_iu
->fcp_sns_len
);
4297 ZFCP_LOG_TRACE("scpnt->result =0x%x, command was:\n",
4299 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_TRACE
,
4300 (void *) &scpnt
->cmnd
, scpnt
->cmd_len
);
4302 ZFCP_LOG_TRACE("%i bytes sense data provided by FCP\n",
4303 fcp_rsp_iu
->fcp_sns_len
);
4304 memcpy(&scpnt
->sense_buffer
,
4305 zfcp_get_fcp_sns_info_ptr(fcp_rsp_iu
), sns_len
);
4306 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_TRACE
,
4307 (void *) &scpnt
->sense_buffer
, sns_len
);
4310 /* check for overrun */
4311 if (unlikely(fcp_rsp_iu
->validity
.bits
.fcp_resid_over
)) {
4312 ZFCP_LOG_INFO("A data overrun was detected for a command. "
4313 "unit 0x%016Lx, port 0x%016Lx, adapter %s. "
4314 "The response data length is "
4315 "%d, the original length was %d.\n",
4318 zfcp_get_busid_by_unit(unit
),
4319 fcp_rsp_iu
->fcp_resid
,
4320 (int) zfcp_get_fcp_dl(fcp_cmnd_iu
));
4323 /* check for underrun */
4324 if (unlikely(fcp_rsp_iu
->validity
.bits
.fcp_resid_under
)) {
4325 ZFCP_LOG_INFO("A data underrun was detected for a command. "
4326 "unit 0x%016Lx, port 0x%016Lx, adapter %s. "
4327 "The response data length is "
4328 "%d, the original length was %d.\n",
4331 zfcp_get_busid_by_unit(unit
),
4332 fcp_rsp_iu
->fcp_resid
,
4333 (int) zfcp_get_fcp_dl(fcp_cmnd_iu
));
4335 scpnt
->resid
= fcp_rsp_iu
->fcp_resid
;
4336 if (scpnt
->request_bufflen
- scpnt
->resid
< scpnt
->underflow
)
4337 scpnt
->result
|= DID_ERROR
<< 16;
4341 ZFCP_LOG_DEBUG("scpnt->result =0x%x\n", scpnt
->result
);
4343 zfcp_cmd_dbf_event_scsi("response", scpnt
);
4345 /* cleanup pointer (need this especially for abort) */
4346 scpnt
->host_scribble
= NULL
;
4350 * according to the outcome of a discussion on linux-scsi we
4351 * don't need to grab the io_request_lock here since we use
4354 /* always call back */
4356 (scpnt
->scsi_done
) (scpnt
);
4359 * We must hold this lock until scsi_done has been called.
4360 * Otherwise we may call scsi_done after abort regarding this
4361 * command has completed.
4362 * Note: scsi_done must not block!
4365 read_unlock_irqrestore(&fsf_req
->adapter
->abort_lock
, flags
);
4370 * function: zfcp_fsf_send_fcp_command_task_management_handler
4372 * purpose: evaluates FCP_RSP IU
4377 zfcp_fsf_send_fcp_command_task_management_handler(struct zfcp_fsf_req
*fsf_req
)
4380 struct fcp_rsp_iu
*fcp_rsp_iu
= (struct fcp_rsp_iu
*)
4381 &(fsf_req
->qtcb
->bottom
.io
.fcp_rsp
);
4382 char *fcp_rsp_info
= zfcp_get_fcp_rsp_info_ptr(fcp_rsp_iu
);
4383 struct zfcp_unit
*unit
=
4384 fsf_req
->data
.send_fcp_command_task_management
.unit
;
4386 del_timer(&fsf_req
->adapter
->scsi_er_timer
);
4387 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
) {
4388 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_TMFUNCFAILED
;
4389 goto skip_fsfstatus
;
4392 /* check FCP_RSP_INFO */
4393 switch (fcp_rsp_info
[3]) {
4395 ZFCP_LOG_FLAGS(3, "RSP_CODE_GOOD\n");
4397 ZFCP_LOG_DEBUG("no failure or Task Management "
4398 "Function complete\n");
4400 case RSP_CODE_TASKMAN_UNSUPP
:
4401 ZFCP_LOG_FLAGS(0, "RSP_CODE_TASKMAN_UNSUPP\n");
4402 ZFCP_LOG_NORMAL("bug: A reuested task management function "
4403 "is not supported on the target device "
4404 "unit 0x%016Lx, port 0x%016Lx, adapter %s\n ",
4407 zfcp_get_busid_by_unit(unit
));
4408 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_TMFUNCNOTSUPP
;
4410 case RSP_CODE_TASKMAN_FAILED
:
4411 ZFCP_LOG_FLAGS(0, "RSP_CODE_TASKMAN_FAILED\n");
4412 ZFCP_LOG_NORMAL("bug: A reuested task management function "
4413 "failed to complete successfully. "
4414 "unit 0x%016Lx, port 0x%016Lx, adapter %s.\n",
4417 zfcp_get_busid_by_unit(unit
));
4418 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_TMFUNCFAILED
;
4421 ZFCP_LOG_NORMAL("bug: An invalid FCP response "
4422 "code was detected for a command. "
4423 "unit 0x%016Lx, port 0x%016Lx, adapter %s "
4424 "(debug info 0x%x)\n",
4427 zfcp_get_busid_by_unit(unit
),
4429 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_TMFUNCFAILED
;
4438 * function: zfcp_fsf_control_file
4440 * purpose: Initiator of the control file upload/download FSF requests
4442 * returns: 0 - FSF request is successfuly created and queued
4443 * -EOPNOTSUPP - The FCP adapter does not have Control File support
4444 * -EINVAL - Invalid direction specified
4445 * -ENOMEM - Insufficient memory
4446 * -EPERM - Cannot create FSF request or place it in QDIO queue
4449 zfcp_fsf_control_file(struct zfcp_adapter
*adapter
,
4450 struct zfcp_fsf_req
**fsf_req_ptr
,
4453 struct zfcp_sg_list
*sg_list
)
4455 struct zfcp_fsf_req
*fsf_req
;
4456 struct fsf_qtcb_bottom_support
*bottom
;
4457 volatile struct qdio_buffer_element
*sbale
;
4458 struct timer_list
*timer
;
4459 unsigned long lock_flags
;
4464 if (!(adapter
->supported_features
& FSF_FEATURE_CFDC
)) {
4465 ZFCP_LOG_INFO("cfdc not supported (adapter %s)\n",
4466 zfcp_get_busid_by_adapter(adapter
));
4467 retval
= -EOPNOTSUPP
;
4471 switch (fsf_command
) {
4473 case FSF_QTCB_DOWNLOAD_CONTROL_FILE
:
4474 direction
= SBAL_FLAGS0_TYPE_WRITE
;
4475 if ((option
!= FSF_CFDC_OPTION_FULL_ACCESS
) &&
4476 (option
!= FSF_CFDC_OPTION_RESTRICTED_ACCESS
))
4477 req_flags
= ZFCP_WAIT_FOR_SBAL
;
4480 case FSF_QTCB_UPLOAD_CONTROL_FILE
:
4481 direction
= SBAL_FLAGS0_TYPE_READ
;
4485 ZFCP_LOG_INFO("Invalid FSF command code 0x%08x\n", fsf_command
);
4490 timer
= kmalloc(sizeof(struct timer_list
), GFP_KERNEL
);
4496 retval
= zfcp_fsf_req_create(adapter
, fsf_command
, req_flags
,
4497 NULL
, &lock_flags
, &fsf_req
);
4499 ZFCP_LOG_INFO("error: Could not create FSF request for the "
4501 zfcp_get_busid_by_adapter(adapter
));
4503 goto unlock_queue_lock
;
4506 sbale
= zfcp_qdio_sbale_req(fsf_req
, fsf_req
->sbal_curr
, 0);
4507 sbale
[0].flags
|= direction
;
4509 bottom
= &fsf_req
->qtcb
->bottom
.support
;
4510 bottom
->operation_subtype
= FSF_CFDC_OPERATION_SUBTYPE
;
4511 bottom
->option
= option
;
4513 if (sg_list
->count
> 0) {
4516 bytes
= zfcp_qdio_sbals_from_sg(fsf_req
, direction
,
4517 sg_list
->sg
, sg_list
->count
,
4518 ZFCP_MAX_SBALS_PER_REQ
);
4519 if (bytes
!= ZFCP_CFDC_MAX_CONTROL_FILE_SIZE
) {
4521 "error: Could not create sufficient number of "
4522 "SBALS for an FSF request to the adapter %s\n",
4523 zfcp_get_busid_by_adapter(adapter
));
4528 sbale
[1].flags
|= SBAL_FLAGS_LAST_ENTRY
;
4531 timer
->function
= zfcp_fsf_request_timeout_handler
;
4532 timer
->data
= (unsigned long) adapter
;
4533 timer
->expires
= ZFCP_FSF_REQUEST_TIMEOUT
;
4535 retval
= zfcp_fsf_req_send(fsf_req
, timer
);
4537 ZFCP_LOG_INFO("initiation of cfdc up/download failed"
4539 zfcp_get_busid_by_adapter(adapter
));
4543 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
, lock_flags
);
4545 ZFCP_LOG_NORMAL("Control file %s FSF request has been sent to the "
4547 fsf_command
== FSF_QTCB_DOWNLOAD_CONTROL_FILE
?
4548 "download" : "upload",
4549 zfcp_get_busid_by_adapter(adapter
));
4551 wait_event(fsf_req
->completion_wq
,
4552 fsf_req
->status
& ZFCP_STATUS_FSFREQ_COMPLETED
);
4554 *fsf_req_ptr
= fsf_req
;
4555 del_timer_sync(timer
);
4559 zfcp_fsf_req_free(fsf_req
);
4561 write_unlock_irqrestore(&adapter
->request_queue
.queue_lock
, lock_flags
);
4570 * function: zfcp_fsf_control_file_handler
4572 * purpose: Handler of the control file upload/download FSF requests
4574 * returns: 0 - FSF request successfuly processed
4575 * -EAGAIN - Operation has to be repeated because of a temporary problem
4576 * -EACCES - There is no permission to execute an operation
4577 * -EPERM - The control file is not in a right format
4578 * -EIO - There is a problem with the FCP adapter
4579 * -EINVAL - Invalid operation
4580 * -EFAULT - User space memory I/O operation fault
4583 zfcp_fsf_control_file_handler(struct zfcp_fsf_req
*fsf_req
)
4585 struct zfcp_adapter
*adapter
= fsf_req
->adapter
;
4586 struct fsf_qtcb_header
*header
= &fsf_req
->qtcb
->header
;
4587 struct fsf_qtcb_bottom_support
*bottom
= &fsf_req
->qtcb
->bottom
.support
;
4590 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_ERROR
) {
4592 goto skip_fsfstatus
;
4595 switch (header
->fsf_status
) {
4598 ZFCP_LOG_FLAGS(2, "FSF_GOOD\n");
4600 "The FSF request has been successfully completed "
4601 "on the adapter %s\n",
4602 zfcp_get_busid_by_adapter(adapter
));
4605 case FSF_OPERATION_PARTIALLY_SUCCESSFUL
:
4606 ZFCP_LOG_FLAGS(2, "FSF_OPERATION_PARTIALLY_SUCCESSFUL\n");
4607 if (bottom
->operation_subtype
== FSF_CFDC_OPERATION_SUBTYPE
) {
4608 switch (header
->fsf_status_qual
.word
[0]) {
4610 case FSF_SQ_CFDC_COULD_NOT_HARDEN_ON_SE
:
4612 "CFDC of the adapter %s could not "
4613 "be saved on the SE\n",
4614 zfcp_get_busid_by_adapter(adapter
));
4617 case FSF_SQ_CFDC_COULD_NOT_HARDEN_ON_SE2
:
4619 "CFDC of the adapter %s could not "
4620 "be copied to the secondary SE\n",
4621 zfcp_get_busid_by_adapter(adapter
));
4626 "CFDC could not be hardened "
4627 "on the adapter %s\n",
4628 zfcp_get_busid_by_adapter(adapter
));
4631 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4635 case FSF_AUTHORIZATION_FAILURE
:
4636 ZFCP_LOG_FLAGS(2, "FSF_AUTHORIZATION_FAILURE\n");
4638 "Adapter %s does not accept privileged commands\n",
4639 zfcp_get_busid_by_adapter(adapter
));
4640 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4644 case FSF_CFDC_ERROR_DETECTED
:
4645 ZFCP_LOG_FLAGS(2, "FSF_CFDC_ERROR_DETECTED\n");
4647 "Error at position %d in the CFDC, "
4648 "CFDC is discarded by the adapter %s\n",
4649 header
->fsf_status_qual
.word
[0],
4650 zfcp_get_busid_by_adapter(adapter
));
4651 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4655 case FSF_CONTROL_FILE_UPDATE_ERROR
:
4656 ZFCP_LOG_FLAGS(2, "FSF_CONTROL_FILE_UPDATE_ERROR\n");
4658 "Adapter %s cannot harden the control file, "
4659 "file is discarded\n",
4660 zfcp_get_busid_by_adapter(adapter
));
4661 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4665 case FSF_CONTROL_FILE_TOO_LARGE
:
4666 ZFCP_LOG_FLAGS(2, "FSF_CONTROL_FILE_TOO_LARGE\n");
4668 "Control file is too large, file is discarded "
4669 "by the adapter %s\n",
4670 zfcp_get_busid_by_adapter(adapter
));
4671 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4675 case FSF_ACCESS_CONFLICT_DETECTED
:
4676 ZFCP_LOG_FLAGS(2, "FSF_ACCESS_CONFLICT_DETECTED\n");
4677 if (bottom
->operation_subtype
== FSF_CFDC_OPERATION_SUBTYPE
)
4679 "CFDC has been discarded by the adapter %s, "
4680 "because activation would impact "
4681 "%d active connection(s)\n",
4682 zfcp_get_busid_by_adapter(adapter
),
4683 header
->fsf_status_qual
.word
[0]);
4684 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4688 case FSF_CONFLICTS_OVERRULED
:
4689 ZFCP_LOG_FLAGS(2, "FSF_CONFLICTS_OVERRULED\n");
4690 if (bottom
->operation_subtype
== FSF_CFDC_OPERATION_SUBTYPE
)
4692 "CFDC has been activated on the adapter %s, "
4693 "but activation has impacted "
4694 "%d active connection(s)\n",
4695 zfcp_get_busid_by_adapter(adapter
),
4696 header
->fsf_status_qual
.word
[0]);
4697 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4701 case FSF_UNKNOWN_OP_SUBTYPE
:
4702 ZFCP_LOG_FLAGS(2, "FSF_UNKNOWN_OP_SUBTYPE\n");
4703 ZFCP_LOG_NORMAL("unknown operation subtype (adapter: %s, "
4704 "op_subtype=0x%x)\n",
4705 zfcp_get_busid_by_adapter(adapter
),
4706 bottom
->operation_subtype
);
4707 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4711 case FSF_INVALID_COMMAND_OPTION
:
4712 ZFCP_LOG_FLAGS(2, "FSF_INVALID_COMMAND_OPTION\n");
4714 "Invalid option 0x%x has been specified "
4715 "in QTCB bottom sent to the adapter %s\n",
4717 zfcp_get_busid_by_adapter(adapter
));
4718 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4724 "bug: An unknown/unexpected FSF status 0x%08x "
4725 "was presented on the adapter %s\n",
4727 zfcp_get_busid_by_adapter(adapter
));
4728 debug_text_event(fsf_req
->adapter
->erp_dbf
, 0, "fsf_sq_inval");
4729 debug_exception(fsf_req
->adapter
->erp_dbf
, 0,
4730 &header
->fsf_status_qual
.word
[0], sizeof(u32
));
4731 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_ERROR
;
4742 * function: zfcp_fsf_req_wait_and_cleanup
4746 * FIXME(design): signal seems to be <0 !!!
4747 * returns: 0 - request completed (*status is valid), cleanup succ.
4748 * <0 - request completed (*status is valid), cleanup failed
4749 * >0 - signal which interrupted waiting (*status invalid),
4750 * request not completed, no cleanup
4752 * *status is a copy of status of completed fsf_req
4755 zfcp_fsf_req_wait_and_cleanup(struct zfcp_fsf_req
*fsf_req
,
4756 int interruptible
, u32
* status
)
4761 if (interruptible
) {
4762 __wait_event_interruptible(fsf_req
->completion_wq
,
4764 ZFCP_STATUS_FSFREQ_COMPLETED
,
4767 ZFCP_LOG_DEBUG("Caught signal %i while waiting for the "
4768 "completion of the request at %p\n",
4774 __wait_event(fsf_req
->completion_wq
,
4775 fsf_req
->status
& ZFCP_STATUS_FSFREQ_COMPLETED
);
4778 *status
= fsf_req
->status
;
4780 /* cleanup request */
4781 zfcp_fsf_req_cleanup(fsf_req
);
4787 zfcp_fsf_req_sbal_check(unsigned long *flags
,
4788 struct zfcp_qdio_queue
*queue
, int needed
)
4790 write_lock_irqsave(&queue
->queue_lock
, *flags
);
4791 if (likely(atomic_read(&queue
->free_count
) >= needed
))
4793 write_unlock_irqrestore(&queue
->queue_lock
, *flags
);
4798 * set qtcb pointer in fsf_req and initialize QTCB
4801 zfcp_fsf_req_qtcb_init(struct zfcp_fsf_req
*fsf_req
, u32 fsf_cmd
)
4803 if (likely(fsf_req
->qtcb
!= NULL
)) {
4804 fsf_req
->qtcb
->prefix
.req_id
= (unsigned long)fsf_req
;
4805 fsf_req
->qtcb
->prefix
.ulp_info
= ZFCP_ULP_INFO_VERSION
;
4806 fsf_req
->qtcb
->prefix
.qtcb_type
= fsf_qtcb_type
[fsf_cmd
];
4807 fsf_req
->qtcb
->prefix
.qtcb_version
= ZFCP_QTCB_VERSION
;
4808 fsf_req
->qtcb
->header
.req_handle
= (unsigned long)fsf_req
;
4809 fsf_req
->qtcb
->header
.fsf_command
= fsf_cmd
;
4814 * zfcp_fsf_req_sbal_get - try to get one SBAL in the request queue
4815 * @adapter: adapter for which request queue is examined
4816 * @req_flags: flags indicating whether to wait for needed SBAL or not
4817 * @lock_flags: lock_flags if queue_lock is taken
4818 * Return: 0 on success, otherwise -EIO, or -ERESTARTSYS
4819 * Locks: lock adapter->request_queue->queue_lock on success
4822 zfcp_fsf_req_sbal_get(struct zfcp_adapter
*adapter
, int req_flags
,
4823 unsigned long *lock_flags
)
4826 struct zfcp_qdio_queue
*req_queue
= &adapter
->request_queue
;
4828 if (unlikely(req_flags
& ZFCP_WAIT_FOR_SBAL
)) {
4829 ret
= wait_event_interruptible_timeout(adapter
->request_wq
,
4830 zfcp_fsf_req_sbal_check(lock_flags
, req_queue
, 1),
4836 } else if (!zfcp_fsf_req_sbal_check(lock_flags
, req_queue
, 1))
4843 * function: zfcp_fsf_req_create
4845 * purpose: create an FSF request at the specified adapter and
4846 * setup common fields
4848 * returns: -ENOMEM if there was insufficient memory for a request
4849 * -EIO if no qdio buffers could be allocate to the request
4850 * -EINVAL/-EPERM on bug conditions in req_dequeue
4853 * note: The created request is returned by reference.
4855 * locks: lock of concerned request queue must not be held,
4856 * but is held on completion (write, irqsave)
4859 zfcp_fsf_req_create(struct zfcp_adapter
*adapter
, u32 fsf_cmd
, int req_flags
,
4860 mempool_t
*pool
, unsigned long *lock_flags
,
4861 struct zfcp_fsf_req
**fsf_req_p
)
4863 volatile struct qdio_buffer_element
*sbale
;
4864 struct zfcp_fsf_req
*fsf_req
= NULL
;
4866 struct zfcp_qdio_queue
*req_queue
= &adapter
->request_queue
;
4868 /* allocate new FSF request */
4869 fsf_req
= zfcp_fsf_req_alloc(pool
, req_flags
);
4870 if (unlikely(NULL
== fsf_req
)) {
4871 ZFCP_LOG_DEBUG("error: Could not put an FSF request into"
4872 "the outbound (send) queue.\n");
4874 goto failed_fsf_req
;
4877 zfcp_fsf_req_qtcb_init(fsf_req
, fsf_cmd
);
4879 /* initialize waitqueue which may be used to wait on
4880 this request completion */
4881 init_waitqueue_head(&fsf_req
->completion_wq
);
4883 ret
= zfcp_fsf_req_sbal_get(adapter
, req_flags
, lock_flags
);
4889 * We hold queue_lock here. Check if QDIOUP is set and let request fail
4890 * if it is not set (see also *_open_qdio and *_close_qdio).
4893 if (!atomic_test_mask(ZFCP_STATUS_ADAPTER_QDIOUP
, &adapter
->status
)) {
4894 write_unlock_irqrestore(&req_queue
->queue_lock
, *lock_flags
);
4899 fsf_req
->adapter
= adapter
; /* pointer to "parent" adapter */
4900 fsf_req
->fsf_command
= fsf_cmd
;
4901 fsf_req
->sbal_number
= 1;
4902 fsf_req
->sbal_first
= req_queue
->free_index
;
4903 fsf_req
->sbal_curr
= req_queue
->free_index
;
4904 fsf_req
->sbale_curr
= 1;
4906 if (likely(req_flags
& ZFCP_REQ_AUTO_CLEANUP
)) {
4907 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_CLEANUP
;
4910 sbale
= zfcp_qdio_sbale_req(fsf_req
, fsf_req
->sbal_curr
, 0);
4912 /* setup common SBALE fields */
4913 sbale
[0].addr
= fsf_req
;
4914 sbale
[0].flags
|= SBAL_FLAGS0_COMMAND
;
4915 if (likely(fsf_req
->qtcb
!= NULL
)) {
4916 sbale
[1].addr
= (void *) fsf_req
->qtcb
;
4917 sbale
[1].length
= sizeof(struct fsf_qtcb
);
4920 ZFCP_LOG_TRACE("got %i free BUFFERs starting at index %i\n",
4921 fsf_req
->sbal_number
, fsf_req
->sbal_first
);
4926 /* dequeue new FSF request previously enqueued */
4927 zfcp_fsf_req_free(fsf_req
);
4931 write_lock_irqsave(&req_queue
->queue_lock
, *lock_flags
);
4933 *fsf_req_p
= fsf_req
;
4938 * function: zfcp_fsf_req_send
4940 * purpose: start transfer of FSF request via QDIO
4942 * returns: 0 - request transfer succesfully started
4943 * !0 - start of request transfer failed
4946 zfcp_fsf_req_send(struct zfcp_fsf_req
*fsf_req
, struct timer_list
*timer
)
4948 struct zfcp_adapter
*adapter
;
4949 struct zfcp_qdio_queue
*req_queue
;
4950 volatile struct qdio_buffer_element
*sbale
;
4951 int new_distance_from_int
;
4952 unsigned long flags
;
4956 adapter
= fsf_req
->adapter
;
4957 req_queue
= &adapter
->request_queue
,
4960 /* FIXME(debug): remove it later */
4961 sbale
= zfcp_qdio_sbale_req(fsf_req
, fsf_req
->sbal_first
, 0);
4962 ZFCP_LOG_DEBUG("SBALE0 flags=0x%x\n", sbale
[0].flags
);
4963 ZFCP_LOG_TRACE("HEX DUMP OF SBALE1 PAYLOAD:\n");
4964 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_TRACE
, (char *) sbale
[1].addr
,
4967 /* set sequence counter in QTCB */
4968 if (likely(fsf_req
->qtcb
)) {
4969 fsf_req
->qtcb
->prefix
.req_seq_no
= adapter
->fsf_req_seq_no
;
4970 fsf_req
->seq_no
= adapter
->fsf_req_seq_no
;
4971 ZFCP_LOG_TRACE("FSF request %p of adapter %s gets "
4972 "FSF sequence counter value of %i\n",
4974 zfcp_get_busid_by_adapter(adapter
),
4975 fsf_req
->qtcb
->prefix
.req_seq_no
);
4979 /* put allocated FSF request at list tail */
4980 write_lock_irqsave(&adapter
->fsf_req_list_lock
, flags
);
4981 list_add_tail(&fsf_req
->list
, &adapter
->fsf_req_list_head
);
4982 write_unlock_irqrestore(&adapter
->fsf_req_list_lock
, flags
);
4984 /* figure out expiration time of timeout and start timeout */
4985 if (unlikely(timer
)) {
4986 timer
->expires
+= jiffies
;
4990 ZFCP_LOG_TRACE("request queue of adapter %s: "
4991 "next free SBAL is %i, %i free SBALs\n",
4992 zfcp_get_busid_by_adapter(adapter
),
4993 req_queue
->free_index
,
4994 atomic_read(&req_queue
->free_count
));
4996 ZFCP_LOG_DEBUG("calling do_QDIO adapter %s, flags=0x%x, queue_no=%i, "
4997 "index_in_queue=%i, count=%i, buffers=%p\n",
4998 zfcp_get_busid_by_adapter(adapter
),
4999 QDIO_FLAG_SYNC_OUTPUT
,
5000 0, fsf_req
->sbal_first
, fsf_req
->sbal_number
,
5001 &req_queue
->buffer
[fsf_req
->sbal_first
]);
5004 * adjust the number of free SBALs in request queue as well as
5005 * position of first one
5007 atomic_sub(fsf_req
->sbal_number
, &req_queue
->free_count
);
5008 ZFCP_LOG_TRACE("free_count=%d\n", atomic_read(&req_queue
->free_count
));
5009 req_queue
->free_index
+= fsf_req
->sbal_number
; /* increase */
5010 req_queue
->free_index
%= QDIO_MAX_BUFFERS_PER_Q
; /* wrap if needed */
5011 new_distance_from_int
= zfcp_qdio_determine_pci(req_queue
, fsf_req
);
5013 retval
= do_QDIO(adapter
->ccw_device
,
5014 QDIO_FLAG_SYNC_OUTPUT
,
5015 0, fsf_req
->sbal_first
, fsf_req
->sbal_number
, NULL
);
5017 if (unlikely(retval
)) {
5018 /* Queues are down..... */
5021 * FIXME(potential race):
5022 * timer might be expired (absolutely unlikely)
5026 write_lock_irqsave(&adapter
->fsf_req_list_lock
, flags
);
5027 list_del(&fsf_req
->list
);
5028 write_unlock_irqrestore(&adapter
->fsf_req_list_lock
, flags
);
5030 * adjust the number of free SBALs in request queue as well as
5031 * position of first one
5033 zfcp_qdio_zero_sbals(req_queue
->buffer
,
5034 fsf_req
->sbal_first
, fsf_req
->sbal_number
);
5035 atomic_add(fsf_req
->sbal_number
, &req_queue
->free_count
);
5036 req_queue
->free_index
-= fsf_req
->sbal_number
; /* increase */
5037 req_queue
->free_index
+= QDIO_MAX_BUFFERS_PER_Q
;
5038 req_queue
->free_index
%= QDIO_MAX_BUFFERS_PER_Q
; /* wrap */
5040 ("error: do_QDIO failed. Buffers could not be enqueued "
5041 "to request queue.\n");
5043 req_queue
->distance_from_int
= new_distance_from_int
;
5045 * increase FSF sequence counter -
5046 * this must only be done for request successfully enqueued to
5047 * QDIO this rejected requests may be cleaned up by calling
5048 * routines resulting in missing sequence counter values
5051 /* Don't increase for unsolicited status */
5052 if (likely(inc_seq_no
)) {
5053 adapter
->fsf_req_seq_no
++;
5055 ("FSF sequence counter value of adapter %s "
5056 "increased to %i\n",
5057 zfcp_get_busid_by_adapter(adapter
),
5058 adapter
->fsf_req_seq_no
);
5060 /* count FSF requests pending */
5061 atomic_inc(&adapter
->fsf_reqs_active
);
5067 * function: zfcp_fsf_req_cleanup
5069 * purpose: cleans up an FSF request and removes it from the specified list
5073 * assumption: no pending SB in SBALEs other than QTCB
5076 zfcp_fsf_req_cleanup(struct zfcp_fsf_req
*fsf_req
)
5078 struct zfcp_adapter
*adapter
= fsf_req
->adapter
;
5079 unsigned long flags
;
5081 write_lock_irqsave(&adapter
->fsf_req_list_lock
, flags
);
5082 list_del(&fsf_req
->list
);
5083 write_unlock_irqrestore(&adapter
->fsf_req_list_lock
, flags
);
5084 zfcp_fsf_req_free(fsf_req
);
5087 #undef ZFCP_LOG_AREA