]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/s390/scsi/zfcp_fsf.c
[SCSI] zfcp: Cleanup debug trace view functions.
[linux-2.6-omap-h63xx.git] / drivers / s390 / scsi / zfcp_fsf.c
index 99299976e89195288a32768147325b4958e99aea..b7aa9696ba60f73e4e063689a5024f6c1b8c0652 100644 (file)
@@ -46,7 +46,7 @@ static int zfcp_fsf_req_send(struct zfcp_fsf_req *);
 static int zfcp_fsf_protstatus_eval(struct zfcp_fsf_req *);
 static int zfcp_fsf_fsfstatus_eval(struct zfcp_fsf_req *);
 static int zfcp_fsf_fsfstatus_qual_eval(struct zfcp_fsf_req *);
-static void zfcp_fsf_link_down_info_eval(struct zfcp_adapter *,
+static void zfcp_fsf_link_down_info_eval(struct zfcp_fsf_req *, u8,
        struct fsf_link_down_info *);
 static int zfcp_fsf_req_dispatch(struct zfcp_fsf_req *);
 
@@ -80,10 +80,10 @@ static const char zfcp_act_subtable_type[5][8] = {
 /*
  * function:   zfcp_fsf_req_alloc
  *
- * purpose:     Obtains an fsf_req and potentially a qtcb (for all but 
+ * purpose:     Obtains an fsf_req and potentially a qtcb (for all but
  *              unsolicited requests) via helper functions
  *              Does some initial fsf request set-up.
- *              
+ *
  * returns:    pointer to allocated fsf_req if successfull
  *              NULL otherwise
  *
@@ -192,7 +192,7 @@ void zfcp_fsf_req_dismiss_all(struct zfcp_adapter *adapter)
  * returns:    0 - success
  *             !0 - failure
  *
- * context:    
+ * context:
  */
 int
 zfcp_fsf_req_complete(struct zfcp_fsf_req *fsf_req)
@@ -214,8 +214,8 @@ zfcp_fsf_req_complete(struct zfcp_fsf_req *fsf_req)
        }
 
        /*
-        * fsf_req may be deleted due to waking up functions, so 
-        * cleanup is saved here and used later 
+        * fsf_req may be deleted due to waking up functions, so
+        * cleanup is saved here and used later
         */
        if (likely(fsf_req->status & ZFCP_STATUS_FSFREQ_CLEANUP))
                cleanup = 1;
@@ -259,9 +259,9 @@ zfcp_fsf_req_complete(struct zfcp_fsf_req *fsf_req)
  *             and initiates appropriate actions
  *             (usually calling FSF command specific handlers)
  *
- * returns:    
+ * returns:
  *
- * context:    
+ * context:
  *
  * locks:
  */
@@ -284,37 +284,6 @@ zfcp_fsf_protstatus_eval(struct zfcp_fsf_req *fsf_req)
                goto skip_protstatus;
        }
 
-       /* log additional information provided by FSF (if any) */
-       if (likely(qtcb->header.log_length)) {
-               /* do not trust them ;-) */
-               if (unlikely(qtcb->header.log_start >
-                            sizeof(struct fsf_qtcb))) {
-                       ZFCP_LOG_NORMAL
-                           ("bug: ULP (FSF logging) log data starts "
-                            "beyond end of packet header. Ignored. "
-                            "(start=%i, size=%li)\n",
-                            qtcb->header.log_start,
-                            sizeof(struct fsf_qtcb));
-                       goto forget_log;
-               }
-               if (unlikely((size_t) (qtcb->header.log_start +
-                                      qtcb->header.log_length) >
-                            sizeof(struct fsf_qtcb))) {
-                       ZFCP_LOG_NORMAL("bug: ULP (FSF logging) log data ends "
-                                       "beyond end of packet header. Ignored. "
-                                       "(start=%i, length=%i, size=%li)\n",
-                                       qtcb->header.log_start,
-                                       qtcb->header.log_length,
-                                       sizeof(struct fsf_qtcb));
-                       goto forget_log;
-               }
-               ZFCP_LOG_TRACE("ULP log data: \n");
-               ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_TRACE,
-                             (char *) qtcb + qtcb->header.log_start,
-                             qtcb->header.log_length);
-       }
- forget_log:
-
        /* evaluate FSF Protocol Status */
        switch (qtcb->prefix.prot_status) {
 
@@ -329,7 +298,7 @@ zfcp_fsf_protstatus_eval(struct zfcp_fsf_req *fsf_req)
                                zfcp_get_busid_by_adapter(adapter),
                                prot_status_qual->version_error.fsf_version,
                                ZFCP_QTCB_VERSION);
-               zfcp_erp_adapter_shutdown(adapter, 0);
+               zfcp_erp_adapter_shutdown(adapter, 0, 117, (u64)fsf_req);
                fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
                break;
 
@@ -340,7 +309,7 @@ zfcp_fsf_protstatus_eval(struct zfcp_fsf_req *fsf_req)
                                qtcb->prefix.req_seq_no,
                                zfcp_get_busid_by_adapter(adapter),
                                prot_status_qual->sequence_error.exp_req_seq_no);
-               zfcp_erp_adapter_reopen(adapter, 0);
+               zfcp_erp_adapter_reopen(adapter, 0, 98, (u64)fsf_req);
                fsf_req->status |= ZFCP_STATUS_FSFREQ_RETRY;
                fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
                break;
@@ -351,7 +320,7 @@ zfcp_fsf_protstatus_eval(struct zfcp_fsf_req *fsf_req)
                                "that used on adapter %s. "
                                "Stopping all operations on this adapter.\n",
                                zfcp_get_busid_by_adapter(adapter));
-               zfcp_erp_adapter_shutdown(adapter, 0);
+               zfcp_erp_adapter_shutdown(adapter, 0, 118, (u64)fsf_req);
                fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
                break;
 
@@ -368,14 +337,15 @@ zfcp_fsf_protstatus_eval(struct zfcp_fsf_req *fsf_req)
                                *(unsigned long long*)
                                (&qtcb->bottom.support.req_handle),
                                        zfcp_get_busid_by_adapter(adapter));
-               zfcp_erp_adapter_shutdown(adapter, 0);
+               zfcp_erp_adapter_shutdown(adapter, 0, 78, (u64)fsf_req);
                fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
                break;
 
        case FSF_PROT_LINK_DOWN:
-               zfcp_fsf_link_down_info_eval(adapter,
+               zfcp_fsf_link_down_info_eval(fsf_req, 37,
                                             &prot_status_qual->link_down_info);
-               zfcp_erp_adapter_reopen(adapter, 0);
+               /* FIXME: reopening adapter now? better wait for link up */
+               zfcp_erp_adapter_reopen(adapter, 0, 79, (u64)fsf_req);
                fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
                break;
 
@@ -385,12 +355,13 @@ zfcp_fsf_protstatus_eval(struct zfcp_fsf_req *fsf_req)
                              "Re-starting operations on this adapter.\n",
                              zfcp_get_busid_by_adapter(adapter));
                /* All ports should be marked as ready to run again */
-               zfcp_erp_modify_adapter_status(adapter,
-                                              ZFCP_STATUS_COMMON_RUNNING,
+               zfcp_erp_modify_adapter_status(adapter, 28,
+                                              0, ZFCP_STATUS_COMMON_RUNNING,
                                               ZFCP_SET);
                zfcp_erp_adapter_reopen(adapter,
                                        ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED
-                                       | ZFCP_STATUS_COMMON_ERP_FAILED);
+                                       | ZFCP_STATUS_COMMON_ERP_FAILED,
+                                       99, (u64)fsf_req);
                fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
                break;
 
@@ -400,7 +371,7 @@ zfcp_fsf_protstatus_eval(struct zfcp_fsf_req *fsf_req)
                                "Restarting all operations on this "
                                "adapter.\n",
                                zfcp_get_busid_by_adapter(adapter));
-               zfcp_erp_adapter_reopen(adapter, 0);
+               zfcp_erp_adapter_reopen(adapter, 0, 100, (u64)fsf_req);
                fsf_req->status |= ZFCP_STATUS_FSFREQ_RETRY;
                fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
                break;
@@ -413,7 +384,7 @@ zfcp_fsf_protstatus_eval(struct zfcp_fsf_req *fsf_req)
                                "(debug info 0x%x).\n",
                                zfcp_get_busid_by_adapter(adapter),
                                qtcb->prefix.prot_status);
-               zfcp_erp_adapter_shutdown(adapter, 0);
+               zfcp_erp_adapter_shutdown(adapter, 0, 119, (u64)fsf_req);
                fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
        }
 
@@ -452,7 +423,8 @@ zfcp_fsf_fsfstatus_eval(struct zfcp_fsf_req *fsf_req)
                                "(debug info 0x%x).\n",
                                zfcp_get_busid_by_adapter(fsf_req->adapter),
                                fsf_req->qtcb->header.fsf_command);
-               zfcp_erp_adapter_shutdown(fsf_req->adapter, 0);
+               zfcp_erp_adapter_shutdown(fsf_req->adapter, 0, 120,
+                                         (u64)fsf_req);
                fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
                break;
 
@@ -502,11 +474,12 @@ zfcp_fsf_fsfstatus_qual_eval(struct zfcp_fsf_req *fsf_req)
                fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
                break;
        case FSF_SQ_NO_RECOM:
-               ZFCP_LOG_NORMAL("bug: No recommendation could be given for a"
+               ZFCP_LOG_NORMAL("bug: No recommendation could be given for a "
                                "problem on the adapter %s "
                                "Stopping all operations on this adapter. ",
                                zfcp_get_busid_by_adapter(fsf_req->adapter));
-               zfcp_erp_adapter_shutdown(fsf_req->adapter, 0);
+               zfcp_erp_adapter_shutdown(fsf_req->adapter, 0, 121,
+                                         (u64)fsf_req);
                fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
                break;
        case FSF_SQ_ULP_PROGRAMMING_ERROR:
@@ -537,9 +510,11 @@ zfcp_fsf_fsfstatus_qual_eval(struct zfcp_fsf_req *fsf_req)
  * zfcp_fsf_link_down_info_eval - evaluate link down information block
  */
 static void
-zfcp_fsf_link_down_info_eval(struct zfcp_adapter *adapter,
+zfcp_fsf_link_down_info_eval(struct zfcp_fsf_req *fsf_req, u8 id,
                             struct fsf_link_down_info *link_down)
 {
+       struct zfcp_adapter *adapter = fsf_req->adapter;
+
        if (atomic_test_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED,
                             &adapter->status))
                return;
@@ -630,7 +605,7 @@ zfcp_fsf_link_down_info_eval(struct zfcp_adapter *adapter,
                                link_down->vendor_specific_code);
 
  out:
-       zfcp_erp_adapter_failed(adapter);
+       zfcp_erp_adapter_failed(adapter, id, (u64)fsf_req);
 }
 
 /*
@@ -638,7 +613,7 @@ zfcp_fsf_link_down_info_eval(struct zfcp_adapter *adapter,
  *
  * purpose:    calls the appropriate command specific handler
  *
- * returns:    
+ * returns:
  */
 static int
 zfcp_fsf_req_dispatch(struct zfcp_fsf_req *fsf_req)
@@ -813,7 +788,7 @@ zfcp_fsf_status_read_port_closed(struct zfcp_fsf_req *fsf_req)
        read_unlock_irqrestore(&zfcp_data.config_lock, flags);
 
        if (!port || (port->d_id != (status_buffer->d_id & ZFCP_DID_MASK))) {
-               ZFCP_LOG_NORMAL("bug: Reopen port indication received for"
+               ZFCP_LOG_NORMAL("bug: Reopen port indication received for "
                                "nonexisting port with d_id 0x%06x on "
                                "adapter %s. Ignored.\n",
                                status_buffer->d_id & ZFCP_DID_MASK,
@@ -824,19 +799,14 @@ zfcp_fsf_status_read_port_closed(struct zfcp_fsf_req *fsf_req)
        switch (status_buffer->status_subtype) {
 
        case FSF_STATUS_READ_SUB_CLOSE_PHYS_PORT:
-               debug_text_event(adapter->erp_dbf, 3, "unsol_pc_phys:");
-               zfcp_erp_port_reopen(port, 0);
+               zfcp_erp_port_reopen(port, 0, 101, (u64)fsf_req);
                break;
 
        case FSF_STATUS_READ_SUB_ERROR_PORT:
-               debug_text_event(adapter->erp_dbf, 1, "unsol_pc_err:");
-               zfcp_erp_port_shutdown(port, 0);
+               zfcp_erp_port_shutdown(port, 0, 122, (u64)fsf_req);
                break;
 
        default:
-               debug_text_event(adapter->erp_dbf, 0, "unsol_unk_sub:");
-               debug_exception(adapter->erp_dbf, 0,
-                               &status_buffer->status_subtype, sizeof (u32));
                ZFCP_LOG_NORMAL("bug: Undefined status subtype received "
                                "for a reopen indication on port with "
                                "d_id 0x%06x on the adapter %s. "
@@ -854,7 +824,7 @@ zfcp_fsf_status_read_port_closed(struct zfcp_fsf_req *fsf_req)
  *
  * purpose:    is called for finished Open Port command
  *
- * returns:    
+ * returns:
  */
 static int
 zfcp_fsf_status_read_handler(struct zfcp_fsf_req *fsf_req)
@@ -928,7 +898,7 @@ zfcp_fsf_status_read_handler(struct zfcp_fsf_req *fsf_req)
                case FSF_STATUS_READ_SUB_NO_PHYSICAL_LINK:
                        ZFCP_LOG_INFO("Physical link to adapter %s is down\n",
                                      zfcp_get_busid_by_adapter(adapter));
-                       zfcp_fsf_link_down_info_eval(adapter,
+                       zfcp_fsf_link_down_info_eval(fsf_req, 38,
                                (struct fsf_link_down_info *)
                                &status_buffer->payload);
                        break;
@@ -936,7 +906,7 @@ zfcp_fsf_status_read_handler(struct zfcp_fsf_req *fsf_req)
                        ZFCP_LOG_INFO("Local link to adapter %s is down "
                                      "due to failed FDISC login\n",
                                      zfcp_get_busid_by_adapter(adapter));
-                       zfcp_fsf_link_down_info_eval(adapter,
+                       zfcp_fsf_link_down_info_eval(fsf_req, 39,
                                (struct fsf_link_down_info *)
                                &status_buffer->payload);
                        break;
@@ -944,13 +914,13 @@ zfcp_fsf_status_read_handler(struct zfcp_fsf_req *fsf_req)
                        ZFCP_LOG_INFO("Local link to adapter %s is down "
                                      "due to firmware update on adapter\n",
                                      zfcp_get_busid_by_adapter(adapter));
-                       zfcp_fsf_link_down_info_eval(adapter, NULL);
+                       zfcp_fsf_link_down_info_eval(fsf_req, 40, NULL);
                        break;
                default:
                        ZFCP_LOG_INFO("Local link to adapter %s is down "
                                      "due to unknown reason\n",
                                      zfcp_get_busid_by_adapter(adapter));
-                       zfcp_fsf_link_down_info_eval(adapter, NULL);
+                       zfcp_fsf_link_down_info_eval(fsf_req, 41, NULL);
                };
                break;
 
@@ -959,12 +929,13 @@ zfcp_fsf_status_read_handler(struct zfcp_fsf_req *fsf_req)
                                "Restarting operations on this adapter\n",
                                zfcp_get_busid_by_adapter(adapter));
                /* All ports should be marked as ready to run again */
-               zfcp_erp_modify_adapter_status(adapter,
+               zfcp_erp_modify_adapter_status(adapter, 30, 0,
                                               ZFCP_STATUS_COMMON_RUNNING,
                                               ZFCP_SET);
                zfcp_erp_adapter_reopen(adapter,
                                        ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED
-                                       | ZFCP_STATUS_COMMON_ERP_FAILED);
+                                       | ZFCP_STATUS_COMMON_ERP_FAILED,
+                                       102, (u64)fsf_req);
                break;
 
        case FSF_STATUS_READ_NOTIFICATION_LOST:
@@ -998,13 +969,14 @@ zfcp_fsf_status_read_handler(struct zfcp_fsf_req *fsf_req)
 
                if (status_buffer->status_subtype &
                    FSF_STATUS_READ_SUB_ACT_UPDATED)
-                       zfcp_erp_adapter_access_changed(adapter);
+                       zfcp_erp_adapter_access_changed(adapter, 135,
+                                                       (u64)fsf_req);
                break;
 
        case FSF_STATUS_READ_CFDC_UPDATED:
                ZFCP_LOG_NORMAL("CFDC has been updated on the adapter %s\n",
                              zfcp_get_busid_by_adapter(adapter));
-               zfcp_erp_adapter_access_changed(adapter);
+               zfcp_erp_adapter_access_changed(adapter, 136, (u64)fsf_req);
                break;
 
        case FSF_STATUS_READ_CFDC_HARDENED:
@@ -1025,7 +997,6 @@ zfcp_fsf_status_read_handler(struct zfcp_fsf_req *fsf_req)
                break;
 
        case FSF_STATUS_READ_FEATURE_UPDATE_ALERT:
-               debug_text_event(adapter->erp_dbf, 2, "unsol_features:");
                ZFCP_LOG_INFO("List of supported features on adapter %s has "
                              "been changed from 0x%08X to 0x%08X\n",
                              zfcp_get_busid_by_adapter(adapter),
@@ -1073,7 +1044,7 @@ zfcp_fsf_status_read_handler(struct zfcp_fsf_req *fsf_req)
                        ZFCP_LOG_INFO("restart adapter %s due to status read "
                                      "buffer shortage\n",
                                      zfcp_get_busid_by_adapter(adapter));
-                       zfcp_erp_adapter_reopen(adapter, 0);
+                       zfcp_erp_adapter_reopen(adapter, 0, 103, (u64)fsf_req);
                }
        }
  out:
@@ -1088,7 +1059,7 @@ zfcp_fsf_status_read_handler(struct zfcp_fsf_req *fsf_req)
  * returns:    address of initiated FSF request
  *             NULL - request could not be initiated
  *
- * FIXME(design): should be watched by a timeout !!! 
+ * FIXME(design): should be watched by a timeout !!!
  * FIXME(design) shouldn't this be modified to return an int
  *               also...don't know how though
  */
@@ -1116,6 +1087,10 @@ zfcp_fsf_abort_fcp_command(unsigned long old_req_id,
                goto out;
        }
 
+       if (unlikely(!atomic_test_mask(ZFCP_STATUS_COMMON_UNBLOCKED,
+                       &unit->status)))
+               goto unit_blocked;
+
        sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0);
         sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
         sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
@@ -1131,22 +1106,13 @@ zfcp_fsf_abort_fcp_command(unsigned long old_req_id,
 
        zfcp_fsf_start_timer(fsf_req, ZFCP_SCSI_ER_TIMEOUT);
        retval = zfcp_fsf_req_send(fsf_req);
-       if (retval) {
-               ZFCP_LOG_INFO("error: Failed to send abort command request "
-                             "on adapter %s, port 0x%016Lx, unit 0x%016Lx\n",
-                             zfcp_get_busid_by_adapter(adapter),
-                             unit->port->wwpn, unit->fcp_lun);
+       if (!retval)
+               goto out;
+
+ unit_blocked:
                zfcp_fsf_req_free(fsf_req);
                fsf_req = NULL;
-               goto out;
-       }
 
-       ZFCP_LOG_DEBUG("Abort FCP Command request initiated "
-                      "(adapter%s, port d_id=0x%06x, "
-                      "unit x%016Lx, old_req_id=0x%lx)\n",
-                      zfcp_get_busid_by_adapter(adapter),
-                      unit->port->d_id,
-                      unit->fcp_lun, old_req_id);
  out:
        write_unlock_irqrestore(&adapter->request_queue.queue_lock, lock_flags);
        return fsf_req;
@@ -1157,15 +1123,15 @@ zfcp_fsf_abort_fcp_command(unsigned long old_req_id,
  *
  * purpose:    is called for finished Abort FCP Command request
  *
- * returns:    
+ * returns:
  */
 static int
 zfcp_fsf_abort_fcp_command_handler(struct zfcp_fsf_req *new_fsf_req)
 {
        int retval = -EINVAL;
        struct zfcp_unit *unit;
-       unsigned char status_qual =
-           new_fsf_req->qtcb->header.fsf_status_qual.word[0];
+       union fsf_status_qual *fsf_stat_qual =
+               &new_fsf_req->qtcb->header.fsf_status_qual;
 
        if (new_fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) {
                /* do not set ZFCP_STATUS_FSFREQ_ABORTSUCCEEDED */
@@ -1178,9 +1144,7 @@ zfcp_fsf_abort_fcp_command_handler(struct zfcp_fsf_req *new_fsf_req)
        switch (new_fsf_req->qtcb->header.fsf_status) {
 
        case FSF_PORT_HANDLE_NOT_VALID:
-               if (status_qual >> 4 != status_qual % 0xf) {
-                       debug_text_event(new_fsf_req->adapter->erp_dbf, 3,
-                                        "fsf_s_phand_nv0");
+               if (fsf_stat_qual->word[0] != fsf_stat_qual->word[1]) {
                        /*
                         * In this case a command that was sent prior to a port
                         * reopen was aborted (handles are different). This is
@@ -1199,18 +1163,14 @@ zfcp_fsf_abort_fcp_command_handler(struct zfcp_fsf_req *new_fsf_req)
                                      fsf_status_qual,
                                      sizeof (union fsf_status_qual));
                        /* Let's hope this sorts out the mess */
-                       debug_text_event(new_fsf_req->adapter->erp_dbf, 1,
-                                        "fsf_s_phand_nv1");
-                       zfcp_erp_adapter_reopen(unit->port->adapter, 0);
+                       zfcp_erp_adapter_reopen(unit->port->adapter, 0, 104,
+                                               (u64)new_fsf_req);
                        new_fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
                }
                break;
 
        case FSF_LUN_HANDLE_NOT_VALID:
-               if (status_qual >> 4 != status_qual % 0xf) {
-                       /* 2 */
-                       debug_text_event(new_fsf_req->adapter->erp_dbf, 3,
-                                        "fsf_s_lhand_nv0");
+               if (fsf_stat_qual->word[0] != fsf_stat_qual->word[1]) {
                        /*
                         * In this case a command that was sent prior to a unit
                         * reopen was aborted (handles are different).
@@ -1232,17 +1192,14 @@ zfcp_fsf_abort_fcp_command_handler(struct zfcp_fsf_req *new_fsf_req)
                                      fsf_status_qual,
                                      sizeof (union fsf_status_qual));
                        /* Let's hope this sorts out the mess */
-                       debug_text_event(new_fsf_req->adapter->erp_dbf, 1,
-                                        "fsf_s_lhand_nv1");
-                       zfcp_erp_port_reopen(unit->port, 0);
+                       zfcp_erp_port_reopen(unit->port, 0, 105,
+                                            (u64)new_fsf_req);
                        new_fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
                }
                break;
 
        case FSF_FCP_COMMAND_DOES_NOT_EXIST:
                retval = 0;
-               debug_text_event(new_fsf_req->adapter->erp_dbf, 3,
-                                "fsf_s_no_exist");
                new_fsf_req->status |= ZFCP_STATUS_FSFREQ_ABORTNOTNEEDED;
                break;
 
@@ -1250,9 +1207,7 @@ zfcp_fsf_abort_fcp_command_handler(struct zfcp_fsf_req *new_fsf_req)
                ZFCP_LOG_INFO("Remote port 0x%016Lx on adapter %s needs to "
                              "be reopened\n", unit->port->wwpn,
                              zfcp_get_busid_by_unit(unit));
-               debug_text_event(new_fsf_req->adapter->erp_dbf, 2,
-                                "fsf_s_pboxed");
-               zfcp_erp_port_boxed(unit->port);
+               zfcp_erp_port_boxed(unit->port, 47, (u64)new_fsf_req);
                new_fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR
                    | ZFCP_STATUS_FSFREQ_RETRY;
                break;
@@ -1263,8 +1218,7 @@ zfcp_fsf_abort_fcp_command_handler(struct zfcp_fsf_req *new_fsf_req)
                         "to be reopened\n",
                         unit->fcp_lun, unit->port->wwpn,
                         zfcp_get_busid_by_unit(unit));
-                debug_text_event(new_fsf_req->adapter->erp_dbf, 1, "fsf_s_lboxed");
-               zfcp_erp_unit_boxed(unit);
+               zfcp_erp_unit_boxed(unit, 48, (u64)new_fsf_req);
                 new_fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR
                         | ZFCP_STATUS_FSFREQ_RETRY;
                 break;
@@ -1272,26 +1226,17 @@ zfcp_fsf_abort_fcp_command_handler(struct zfcp_fsf_req *new_fsf_req)
        case FSF_ADAPTER_STATUS_AVAILABLE:
                switch (new_fsf_req->qtcb->header.fsf_status_qual.word[0]) {
                case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
-                       debug_text_event(new_fsf_req->adapter->erp_dbf, 1,
-                                        "fsf_sq_ltest");
                        zfcp_test_link(unit->port);
                        new_fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
                        break;
                case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
                        /* SCSI stack will escalate */
-                       debug_text_event(new_fsf_req->adapter->erp_dbf, 1,
-                                        "fsf_sq_ulp");
                        new_fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
                        break;
                default:
                        ZFCP_LOG_NORMAL
                            ("bug: Wrong status qualifier 0x%x arrived.\n",
                             new_fsf_req->qtcb->header.fsf_status_qual.word[0]);
-                       debug_text_event(new_fsf_req->adapter->erp_dbf, 0,
-                                        "fsf_sq_inval:");
-                       debug_exception(new_fsf_req->adapter->erp_dbf, 0,
-                                       &new_fsf_req->qtcb->header.
-                                       fsf_status_qual.word[0], sizeof (u32));
                        break;
                }
                break;
@@ -1305,11 +1250,6 @@ zfcp_fsf_abort_fcp_command_handler(struct zfcp_fsf_req *new_fsf_req)
                ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
                                "(debug info 0x%x)\n",
                                new_fsf_req->qtcb->header.fsf_status);
-               debug_text_event(new_fsf_req->adapter->erp_dbf, 0,
-                                "fsf_s_inval:");
-               debug_exception(new_fsf_req->adapter->erp_dbf, 0,
-                               &new_fsf_req->qtcb->header.fsf_status,
-                               sizeof (u32));
                break;
        }
  skip_fsfstatus:
@@ -1512,8 +1452,7 @@ zfcp_fsf_send_ct_handler(struct zfcp_fsf_req *fsf_req)
                              zfcp_get_busid_by_port(port),
                              ZFCP_FC_SERVICE_CLASS_DEFAULT);
                /* stop operation for this adapter */
-               debug_text_exception(adapter->erp_dbf, 0, "fsf_s_class_nsup");
-               zfcp_erp_adapter_shutdown(adapter, 0);
+               zfcp_erp_adapter_shutdown(adapter, 0, 123, (u64)fsf_req);
                fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
                break;
 
@@ -1521,13 +1460,11 @@ zfcp_fsf_send_ct_handler(struct zfcp_fsf_req *fsf_req)
                 switch (header->fsf_status_qual.word[0]){
                 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
                        /* reopening link to port */
-                       debug_text_event(adapter->erp_dbf, 1, "fsf_sq_ltest");
                        zfcp_test_link(port);
                        fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
                        break;
                 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
                        /* ERP strategy will escalate */
-                       debug_text_event(adapter->erp_dbf, 1, "fsf_sq_ulp");
                        fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
                        break;
                 default:
@@ -1555,8 +1492,7 @@ zfcp_fsf_send_ct_handler(struct zfcp_fsf_req *fsf_req)
                                break;
                        }
                }
-               debug_text_event(adapter->erp_dbf, 1, "fsf_s_access");
-               zfcp_erp_port_access_denied(port);
+               zfcp_erp_port_access_denied(port, 55, (u64)fsf_req);
                fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
                break;
 
@@ -1568,7 +1504,6 @@ zfcp_fsf_send_ct_handler(struct zfcp_fsf_req *fsf_req)
                ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_INFO,
                              (char *) &header->fsf_status_qual,
                              sizeof (union fsf_status_qual));
-               debug_text_event(adapter->erp_dbf, 1, "fsf_s_gcom_rej");
                fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
                break;
 
@@ -1581,8 +1516,7 @@ zfcp_fsf_send_ct_handler(struct zfcp_fsf_req *fsf_req)
                ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_INFO,
                              (char *) &header->fsf_status_qual,
                              sizeof (union fsf_status_qual));
-               debug_text_event(adapter->erp_dbf, 1, "fsf_s_phandle_nv");
-               zfcp_erp_adapter_reopen(adapter, 0);
+               zfcp_erp_adapter_reopen(adapter, 0, 106, (u64)fsf_req);
                fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
                break;
 
@@ -1590,8 +1524,7 @@ zfcp_fsf_send_ct_handler(struct zfcp_fsf_req *fsf_req)
                ZFCP_LOG_INFO("port needs to be reopened "
                              "(adapter %s, port d_id=0x%06x)\n",
                              zfcp_get_busid_by_port(port), port->d_id);
-               debug_text_event(adapter->erp_dbf, 2, "fsf_s_pboxed");
-               zfcp_erp_port_boxed(port);
+               zfcp_erp_port_boxed(port, 49, (u64)fsf_req);
                fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR
                    | ZFCP_STATUS_FSFREQ_RETRY;
                break;
@@ -1630,9 +1563,6 @@ zfcp_fsf_send_ct_handler(struct zfcp_fsf_req *fsf_req)
        default:
                ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
                                "(debug info 0x%x)\n", header->fsf_status);
-               debug_text_event(adapter->erp_dbf, 0, "fsf_sq_inval:");
-               debug_exception(adapter->erp_dbf, 0,
-                               &header->fsf_status_qual.word[0], sizeof (u32));
                break;
        }
 
@@ -1674,6 +1604,12 @@ zfcp_fsf_send_els(struct zfcp_send_els *els)
                 goto failed_req;
        }
 
+       if (unlikely(!atomic_test_mask(ZFCP_STATUS_COMMON_UNBLOCKED,
+                       &els->port->status))) {
+               ret = -EBUSY;
+               goto port_blocked;
+       }
+
        sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0);
         if (zfcp_use_one_sbal(els->req, els->req_count,
                               els->resp, els->resp_count)){
@@ -1755,6 +1691,7 @@ zfcp_fsf_send_els(struct zfcp_send_els *els)
                       "0x%06x)\n", zfcp_get_busid_by_adapter(adapter), d_id);
        goto out;
 
+ port_blocked:
  failed_send:
        zfcp_fsf_req_free(fsf_req);
 
@@ -1809,21 +1746,18 @@ static int zfcp_fsf_send_els_handler(struct zfcp_fsf_req *fsf_req)
                              zfcp_get_busid_by_adapter(adapter),
                              ZFCP_FC_SERVICE_CLASS_DEFAULT);
                /* stop operation for this adapter */
-               debug_text_exception(adapter->erp_dbf, 0, "fsf_s_class_nsup");
-               zfcp_erp_adapter_shutdown(adapter, 0);
+               zfcp_erp_adapter_shutdown(adapter, 0, 124, (u64)fsf_req);
                fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
                break;
 
        case FSF_ADAPTER_STATUS_AVAILABLE:
                switch (header->fsf_status_qual.word[0]){
                case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
-                       debug_text_event(adapter->erp_dbf, 1, "fsf_sq_ltest");
                        if (port && (send_els->ls_code != ZFCP_LS_ADISC))
                                zfcp_test_link(port);
                        fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
                        break;
                case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
-                       debug_text_event(adapter->erp_dbf, 1, "fsf_sq_ulp");
                        fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
                        retval =
                          zfcp_handle_els_rjt(header->fsf_status_qual.word[1],
@@ -1831,7 +1765,6 @@ static int zfcp_fsf_send_els_handler(struct zfcp_fsf_req *fsf_req)
                                              &header->fsf_status_qual.word[2]);
                        break;
                case FSF_SQ_RETRY_IF_POSSIBLE:
-                       debug_text_event(adapter->erp_dbf, 1, "fsf_sq_retry");
                        fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
                        break;
                default:
@@ -1908,9 +1841,8 @@ static int zfcp_fsf_send_els_handler(struct zfcp_fsf_req *fsf_req)
                                break;
                        }
                }
-               debug_text_event(adapter->erp_dbf, 1, "fsf_s_access");
                if (port != NULL)
-                       zfcp_erp_port_access_denied(port);
+                       zfcp_erp_port_access_denied(port, 56, (u64)fsf_req);
                fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
                break;
 
@@ -1920,9 +1852,6 @@ static int zfcp_fsf_send_els_handler(struct zfcp_fsf_req *fsf_req)
                        "(adapter: %s, fsf_status=0x%08x)\n",
                        zfcp_get_busid_by_adapter(adapter),
                        header->fsf_status);
-               debug_text_event(adapter->erp_dbf, 0, "fsf_sq_inval");
-               debug_exception(adapter->erp_dbf, 0,
-                       &header->fsf_status_qual.word[0], sizeof(u32));
                fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
                break;
        }
@@ -1941,25 +1870,28 @@ zfcp_fsf_exchange_config_data(struct zfcp_erp_action *erp_action)
 {
        volatile struct qdio_buffer_element *sbale;
        struct zfcp_fsf_req *fsf_req;
+       struct zfcp_adapter *adapter = erp_action->adapter;
        unsigned long lock_flags;
-       int retval = 0;
+       int retval;
 
        /* setup new FSF request */
-       retval = zfcp_fsf_req_create(erp_action->adapter,
+       retval = zfcp_fsf_req_create(adapter,
                                     FSF_QTCB_EXCHANGE_CONFIG_DATA,
                                     ZFCP_REQ_AUTO_CLEANUP,
-                                    erp_action->adapter->pool.fsf_req_erp,
+                                    adapter->pool.fsf_req_erp,
                                     &lock_flags, &fsf_req);
-       if (retval < 0) {
+       if (retval) {
                ZFCP_LOG_INFO("error: Could not create exchange configuration "
                              "data request for adapter %s.\n",
-                             zfcp_get_busid_by_adapter(erp_action->adapter));
-               goto out;
+                             zfcp_get_busid_by_adapter(adapter));
+               write_unlock_irqrestore(&adapter->request_queue.queue_lock,
+                                       lock_flags);
+               return retval;
        }
 
        sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0);
-        sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
-        sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
+       sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
+       sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
 
        fsf_req->qtcb->bottom.config.feature_selection =
                        FSF_FEATURE_CFDC |
@@ -1971,23 +1903,71 @@ zfcp_fsf_exchange_config_data(struct zfcp_erp_action *erp_action)
 
        zfcp_erp_start_timer(fsf_req);
        retval = zfcp_fsf_req_send(fsf_req);
+       write_unlock_irqrestore(&adapter->request_queue.queue_lock,
+                               lock_flags);
        if (retval) {
-               ZFCP_LOG_INFO
-                   ("error: Could not send exchange configuration data "
-                    "command on the adapter %s\n",
-                    zfcp_get_busid_by_adapter(erp_action->adapter));
+               ZFCP_LOG_INFO("error: Could not send exchange configuration "
+                             "data command on the adapter %s\n",
+                             zfcp_get_busid_by_adapter(adapter));
                zfcp_fsf_req_free(fsf_req);
                erp_action->fsf_req = NULL;
-               goto out;
        }
+       else
+               ZFCP_LOG_DEBUG("exchange configuration data request initiated "
+                              "(adapter %s)\n",
+                              zfcp_get_busid_by_adapter(adapter));
 
-       ZFCP_LOG_DEBUG("exchange configuration data request initiated "
-                      "(adapter %s)\n",
-                      zfcp_get_busid_by_adapter(erp_action->adapter));
+       return retval;
+}
 
- out:
-       write_unlock_irqrestore(&erp_action->adapter->request_queue.queue_lock,
+int
+zfcp_fsf_exchange_config_data_sync(struct zfcp_adapter *adapter,
+                               struct fsf_qtcb_bottom_config *data)
+{
+       volatile struct qdio_buffer_element *sbale;
+       struct zfcp_fsf_req *fsf_req;
+       unsigned long lock_flags;
+       int retval;
+
+       /* setup new FSF request */
+       retval = zfcp_fsf_req_create(adapter, FSF_QTCB_EXCHANGE_CONFIG_DATA,
+                                    0, NULL, &lock_flags, &fsf_req);
+       if (retval) {
+               ZFCP_LOG_INFO("error: Could not create exchange configuration "
+                             "data request for adapter %s.\n",
+                             zfcp_get_busid_by_adapter(adapter));
+               write_unlock_irqrestore(&adapter->request_queue.queue_lock,
+                                       lock_flags);
+               return retval;
+       }
+
+       sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0);
+       sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
+       sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
+
+       fsf_req->qtcb->bottom.config.feature_selection =
+                       FSF_FEATURE_CFDC |
+                       FSF_FEATURE_LUN_SHARING |
+                       FSF_FEATURE_NOTIFICATION_LOST |
+                       FSF_FEATURE_UPDATE_ALERT;
+
+       if (data)
+               fsf_req->data = (unsigned long) data;
+
+       zfcp_fsf_start_timer(fsf_req, ZFCP_FSF_REQUEST_TIMEOUT);
+       retval = zfcp_fsf_req_send(fsf_req);
+       write_unlock_irqrestore(&adapter->request_queue.queue_lock,
                                lock_flags);
+       if (retval)
+               ZFCP_LOG_INFO("error: Could not send exchange configuration "
+                             "data command on the adapter %s\n",
+                             zfcp_get_busid_by_adapter(adapter));
+       else
+               wait_event(fsf_req->completion_wq,
+                          fsf_req->status & ZFCP_STATUS_FSFREQ_COMPLETED);
+
+       zfcp_fsf_req_free(fsf_req);
+
        return retval;
 }
 
@@ -2016,11 +1996,17 @@ zfcp_fsf_exchange_config_evaluate(struct zfcp_fsf_req *fsf_req, int xchg_ok)
        adapter->peer_d_id = 0;
 
        if (xchg_ok) {
+
+               if (fsf_req->data)
+                       memcpy((struct fsf_qtcb_bottom_config *) fsf_req->data,
+                               bottom, sizeof (struct fsf_qtcb_bottom_config));
+
                fc_host_node_name(shost) = bottom->nport_serv_param.wwnn;
                fc_host_port_name(shost) = bottom->nport_serv_param.wwpn;
                fc_host_port_id(shost) = bottom->s_id & ZFCP_DID_MASK;
                fc_host_speed(shost) = bottom->fc_link_speed;
-               fc_host_supported_classes(shost) = FC_COS_CLASS2 | FC_COS_CLASS3;
+               fc_host_supported_classes(shost) =
+                               FC_COS_CLASS2 | FC_COS_CLASS3;
                adapter->hydra_version = bottom->adapter_type;
                if (fc_host_permanent_port_name(shost) == -1)
                        fc_host_permanent_port_name(shost) =
@@ -2053,7 +2039,8 @@ zfcp_fsf_exchange_config_evaluate(struct zfcp_fsf_req *fsf_req, int xchg_ok)
                       min(FC_SERIAL_NUMBER_SIZE, 17));
        }
 
-       ZFCP_LOG_NORMAL("The adapter %s reported the following characteristics:\n"
+       ZFCP_LOG_NORMAL("The adapter %s reported the following "
+                       "characteristics:\n"
                        "WWNN 0x%016Lx, "
                        "WWPN 0x%016Lx, "
                        "S_ID 0x%06x,\n"
@@ -2073,8 +2060,7 @@ zfcp_fsf_exchange_config_evaluate(struct zfcp_fsf_req *fsf_req, int xchg_ok)
                                "versions in comparison to this device "
                                "driver (try updated device driver)\n",
                                zfcp_get_busid_by_adapter(adapter));
-               debug_text_event(adapter->erp_dbf, 0, "low_qtcb_ver");
-               zfcp_erp_adapter_shutdown(adapter, 0);
+               zfcp_erp_adapter_shutdown(adapter, 0, 125, (u64)fsf_req);
                return -EIO;
        }
        if (ZFCP_QTCB_VERSION > bottom->high_qtcb_version) {
@@ -2083,14 +2069,13 @@ zfcp_fsf_exchange_config_evaluate(struct zfcp_fsf_req *fsf_req, int xchg_ok)
                                "versions than this device driver uses"
                                "(consider a microcode upgrade)\n",
                                zfcp_get_busid_by_adapter(adapter));
-               debug_text_event(adapter->erp_dbf, 0, "high_qtcb_ver");
-               zfcp_erp_adapter_shutdown(adapter, 0);
+               zfcp_erp_adapter_shutdown(adapter, 0, 126, (u64)fsf_req);
                return -EIO;
        }
        return 0;
 }
 
-/*
+/**
  * function:    zfcp_fsf_exchange_config_data_handler
  *
  * purpose:     is called for finished Exchange Configuration Data command
@@ -2124,22 +2109,18 @@ zfcp_fsf_exchange_config_data_handler(struct zfcp_fsf_req *fsf_req)
                                        adapter->peer_wwnn,
                                        adapter->peer_wwpn,
                                        adapter->peer_d_id);
-                       debug_text_event(fsf_req->adapter->erp_dbf, 0,
-                                        "top-p-to-p");
                        break;
                case FC_PORTTYPE_NLPORT:
                        ZFCP_LOG_NORMAL("error: Arbitrated loop fibrechannel "
                                        "topology detected at adapter %s "
                                        "unsupported, shutting down adapter\n",
                                        zfcp_get_busid_by_adapter(adapter));
-                       debug_text_event(fsf_req->adapter->erp_dbf, 0,
-                                        "top-al");
-                       zfcp_erp_adapter_shutdown(adapter, 0);
+                       zfcp_erp_adapter_shutdown(adapter, 0, 127, (u64)fsf_req);
                        return -EIO;
                case FC_PORTTYPE_NPORT:
                        ZFCP_LOG_NORMAL("Switched fabric fibrechannel "
-                                     "network detected at adapter %s.\n",
-                                     zfcp_get_busid_by_adapter(adapter));
+                                       "network detected at adapter %s.\n",
+                                       zfcp_get_busid_by_adapter(adapter));
                        break;
                default:
                        ZFCP_LOG_NORMAL("bug: The fibrechannel topology "
@@ -2149,9 +2130,7 @@ zfcp_fsf_exchange_config_data_handler(struct zfcp_fsf_req *fsf_req)
                                        "of a type known to the zfcp "
                                        "driver, shutting down adapter\n",
                                        zfcp_get_busid_by_adapter(adapter));
-                       debug_text_exception(fsf_req->adapter->erp_dbf, 0,
-                                            "unknown-topo");
-                       zfcp_erp_adapter_shutdown(adapter, 0);
+                       zfcp_erp_adapter_shutdown(adapter, 0, 128, (u64)fsf_req);
                        return -EIO;
                }
                bottom = &qtcb->bottom.config;
@@ -2163,32 +2142,24 @@ zfcp_fsf_exchange_config_data_handler(struct zfcp_fsf_req *fsf_req)
                                        bottom->max_qtcb_size,
                                        zfcp_get_busid_by_adapter(adapter),
                                        sizeof(struct fsf_qtcb));
-                       debug_text_event(fsf_req->adapter->erp_dbf, 0,
-                                        "qtcb-size");
-                       debug_event(fsf_req->adapter->erp_dbf, 0,
-                                   &bottom->max_qtcb_size, sizeof (u32));
-                       zfcp_erp_adapter_shutdown(adapter, 0);
+                       zfcp_erp_adapter_shutdown(adapter, 0, 129, (u64)fsf_req);
                        return -EIO;
                }
                atomic_set_mask(ZFCP_STATUS_ADAPTER_XCONFIG_OK,
                                &adapter->status);
                break;
        case FSF_EXCHANGE_CONFIG_DATA_INCOMPLETE:
-               debug_text_event(adapter->erp_dbf, 0, "xchg-inco");
-
                if (zfcp_fsf_exchange_config_evaluate(fsf_req, 0))
                        return -EIO;
 
-               atomic_set_mask(ZFCP_STATUS_ADAPTER_XCONFIG_OK, &adapter->status);
+               atomic_set_mask(ZFCP_STATUS_ADAPTER_XCONFIG_OK,
+                               &adapter->status);
 
-               zfcp_fsf_link_down_info_eval(adapter,
+               zfcp_fsf_link_down_info_eval(fsf_req, 42,
                        &qtcb->header.fsf_status_qual.link_down_info);
                break;
        default:
-               debug_text_event(fsf_req->adapter->erp_dbf, 0, "fsf-stat-ng");
-               debug_event(fsf_req->adapter->erp_dbf, 0,
-                           &fsf_req->qtcb->header.fsf_status, sizeof (u32));
-               zfcp_erp_adapter_shutdown(adapter, 0);
+               zfcp_erp_adapter_shutdown(adapter, 0, 130, (u64)fsf_req);
                return -EIO;
        }
        return 0;
@@ -2197,74 +2168,118 @@ zfcp_fsf_exchange_config_data_handler(struct zfcp_fsf_req *fsf_req)
 /**
  * zfcp_fsf_exchange_port_data - request information about local port
  * @erp_action: ERP action for the adapter for which port data is requested
- * @adapter: for which port data is requested
- * @data: response to exchange port data request
  */
 int
-zfcp_fsf_exchange_port_data(struct zfcp_erp_action *erp_action,
-                           struct zfcp_adapter *adapter,
-                           struct fsf_qtcb_bottom_port *data)
+zfcp_fsf_exchange_port_data(struct zfcp_erp_action *erp_action)
 {
        volatile struct qdio_buffer_element *sbale;
-        struct zfcp_fsf_req *fsf_req;
+       struct zfcp_fsf_req *fsf_req;
+       struct zfcp_adapter *adapter = erp_action->adapter;
        unsigned long lock_flags;
-       int retval = 0;
+       int retval;
 
        if (!(adapter->adapter_features & FSF_FEATURE_HBAAPI_MANAGEMENT)) {
                ZFCP_LOG_INFO("error: exchange port data "
-                              "command not supported by adapter %s\n",
+                             "command not supported by adapter %s\n",
                              zfcp_get_busid_by_adapter(adapter));
-                return -EOPNOTSUPP;
-        }
+               return -EOPNOTSUPP;
+       }
 
        /* setup new FSF request */
        retval = zfcp_fsf_req_create(adapter, FSF_QTCB_EXCHANGE_PORT_DATA,
-                                    erp_action ? ZFCP_REQ_AUTO_CLEANUP : 0,
-                                    NULL, &lock_flags, &fsf_req);
-       if (retval < 0) {
+                                    ZFCP_REQ_AUTO_CLEANUP,
+                                    adapter->pool.fsf_req_erp,
+                                    &lock_flags, &fsf_req);
+       if (retval) {
                ZFCP_LOG_INFO("error: Out of resources. Could not create an "
-                              "exchange port data request for"
-                              "the adapter %s.\n",
+                             "exchange port data request for "
+                             "the adapter %s.\n",
                              zfcp_get_busid_by_adapter(adapter));
                write_unlock_irqrestore(&adapter->request_queue.queue_lock,
                                        lock_flags);
                return retval;
        }
 
-       if (data)
-               fsf_req->data = (unsigned long) data;
-
        sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0);
-        sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
-        sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
+       sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
+       sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
 
-       if (erp_action) {
-               erp_action->fsf_req = fsf_req;
-               fsf_req->erp_action = erp_action;
-               zfcp_erp_start_timer(fsf_req);
-       } else
-               zfcp_fsf_start_timer(fsf_req, ZFCP_FSF_REQUEST_TIMEOUT);
+       erp_action->fsf_req = fsf_req;
+       fsf_req->erp_action = erp_action;
+       zfcp_erp_start_timer(fsf_req);
 
        retval = zfcp_fsf_req_send(fsf_req);
+       write_unlock_irqrestore(&adapter->request_queue.queue_lock, lock_flags);
+
        if (retval) {
                ZFCP_LOG_INFO("error: Could not send an exchange port data "
-                              "command on the adapter %s\n",
+                             "command on the adapter %s\n",
                              zfcp_get_busid_by_adapter(adapter));
                zfcp_fsf_req_free(fsf_req);
-               if (erp_action)
-                       erp_action->fsf_req = NULL;
+               erp_action->fsf_req = NULL;
+       }
+       else
+               ZFCP_LOG_DEBUG("exchange port data request initiated "
+                              "(adapter %s)\n",
+                              zfcp_get_busid_by_adapter(adapter));
+       return retval;
+}
+
+
+/**
+ * zfcp_fsf_exchange_port_data_sync - request information about local port
+ * and wait until information is ready
+ */
+int
+zfcp_fsf_exchange_port_data_sync(struct zfcp_adapter *adapter,
+                               struct fsf_qtcb_bottom_port *data)
+{
+       volatile struct qdio_buffer_element *sbale;
+       struct zfcp_fsf_req *fsf_req;
+       unsigned long lock_flags;
+       int retval;
+
+       if (!(adapter->adapter_features & FSF_FEATURE_HBAAPI_MANAGEMENT)) {
+               ZFCP_LOG_INFO("error: exchange port data "
+                             "command not supported by adapter %s\n",
+                             zfcp_get_busid_by_adapter(adapter));
+               return -EOPNOTSUPP;
+       }
+
+       /* setup new FSF request */
+       retval = zfcp_fsf_req_create(adapter, FSF_QTCB_EXCHANGE_PORT_DATA,
+                               0, NULL, &lock_flags, &fsf_req);
+       if (retval) {
+               ZFCP_LOG_INFO("error: Out of resources. Could not create an "
+                             "exchange port data request for "
+                             "the adapter %s.\n",
+                             zfcp_get_busid_by_adapter(adapter));
                write_unlock_irqrestore(&adapter->request_queue.queue_lock,
                                        lock_flags);
                return retval;
        }
 
+       if (data)
+               fsf_req->data = (unsigned long) data;
+
+       sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0);
+       sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
+       sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
+
+       zfcp_fsf_start_timer(fsf_req, ZFCP_FSF_REQUEST_TIMEOUT);
+       retval = zfcp_fsf_req_send(fsf_req);
        write_unlock_irqrestore(&adapter->request_queue.queue_lock, lock_flags);
 
-       if (!erp_action) {
+       if (retval)
+               ZFCP_LOG_INFO("error: Could not send an exchange port data "
+                             "command on the adapter %s\n",
+                             zfcp_get_busid_by_adapter(adapter));
+       else
                wait_event(fsf_req->completion_wq,
                           fsf_req->status & ZFCP_STATUS_FSFREQ_COMPLETED);
-               zfcp_fsf_req_free(fsf_req);
-       }
+
+       zfcp_fsf_req_free(fsf_req);
+
        return retval;
 }
 
@@ -2277,18 +2292,16 @@ static void
 zfcp_fsf_exchange_port_evaluate(struct zfcp_fsf_req *fsf_req, int xchg_ok)
 {
        struct zfcp_adapter *adapter;
-       struct fsf_qtcb *qtcb;
-       struct fsf_qtcb_bottom_port *bottom, *data;
+       struct fsf_qtcb_bottom_port *bottom;
        struct Scsi_Host *shost;
 
        adapter = fsf_req->adapter;
-       qtcb = fsf_req->qtcb;
-       bottom = &qtcb->bottom.port;
+       bottom = &fsf_req->qtcb->bottom.port;
        shost = adapter->scsi_host;
 
-       data = (struct fsf_qtcb_bottom_port*) fsf_req->data;
-       if (data)
-               memcpy(data, bottom, sizeof(struct fsf_qtcb_bottom_port));
+       if (fsf_req->data)
+               memcpy((struct fsf_qtcb_bottom_port*) fsf_req->data, bottom,
+                       sizeof(struct fsf_qtcb_bottom_port));
 
        if (adapter->connection_features & FSF_FEATURE_NPIV_MODE)
                fc_host_permanent_port_name(shost) = bottom->wwpn;
@@ -2322,13 +2335,9 @@ zfcp_fsf_exchange_port_data_handler(struct zfcp_fsf_req *fsf_req)
        case FSF_EXCHANGE_CONFIG_DATA_INCOMPLETE:
                zfcp_fsf_exchange_port_evaluate(fsf_req, 0);
                atomic_set_mask(ZFCP_STATUS_ADAPTER_XPORT_OK, &adapter->status);
-               zfcp_fsf_link_down_info_eval(adapter,
+               zfcp_fsf_link_down_info_eval(fsf_req, 43,
                        &qtcb->header.fsf_status_qual.link_down_info);
                 break;
-        default:
-               debug_text_event(adapter->erp_dbf, 0, "xchg-port-ng");
-               debug_event(adapter->erp_dbf, 0,
-                           &fsf_req->qtcb->header.fsf_status, sizeof(u32));
        }
 }
 
@@ -2336,10 +2345,10 @@ zfcp_fsf_exchange_port_data_handler(struct zfcp_fsf_req *fsf_req)
 /*
  * function:    zfcp_fsf_open_port
  *
- * purpose:    
+ * purpose:
  *
  * returns:    address of initiated FSF request
- *             NULL - request could not be initiated 
+ *             NULL - request could not be initiated
  */
 int
 zfcp_fsf_open_port(struct zfcp_erp_action *erp_action)
@@ -2400,7 +2409,7 @@ zfcp_fsf_open_port(struct zfcp_erp_action *erp_action)
  *
  * purpose:    is called for finished Open Port command
  *
- * returns:    
+ * returns:
  */
 static int
 zfcp_fsf_open_port_handler(struct zfcp_fsf_req *fsf_req)
@@ -2426,8 +2435,6 @@ zfcp_fsf_open_port_handler(struct zfcp_fsf_req *fsf_req)
                ZFCP_LOG_NORMAL("bug: remote port 0x%016Lx on adapter %s "
                                "is already open.\n",
                                port->wwpn, zfcp_get_busid_by_port(port));
-               debug_text_exception(fsf_req->adapter->erp_dbf, 0,
-                                    "fsf_s_popen");
                /*
                 * This is a bug, however operation should continue normally
                 * if it is simply ignored
@@ -2451,8 +2458,7 @@ zfcp_fsf_open_port_handler(struct zfcp_fsf_req *fsf_req)
                                break;
                        }
                }
-               debug_text_event(fsf_req->adapter->erp_dbf, 1, "fsf_s_access");
-               zfcp_erp_port_access_denied(port);
+               zfcp_erp_port_access_denied(port, 57, (u64)fsf_req);
                fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
                break;
 
@@ -2461,24 +2467,18 @@ zfcp_fsf_open_port_handler(struct zfcp_fsf_req *fsf_req)
                              "The remote port 0x%016Lx on adapter %s "
                              "could not be opened. Disabling it.\n",
                              port->wwpn, zfcp_get_busid_by_port(port));
-               debug_text_event(fsf_req->adapter->erp_dbf, 1,
-                                "fsf_s_max_ports");
-               zfcp_erp_port_failed(port);
+               zfcp_erp_port_failed(port, 31, (u64)fsf_req);
                fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
                break;
 
        case FSF_ADAPTER_STATUS_AVAILABLE:
                switch (header->fsf_status_qual.word[0]) {
                case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
-                       debug_text_event(fsf_req->adapter->erp_dbf, 1,
-                                        "fsf_sq_ltest");
                        /* ERP strategy will escalate */
                        fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
                        break;
                case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
                        /* ERP strategy will escalate */
-                       debug_text_event(fsf_req->adapter->erp_dbf, 1,
-                                        "fsf_sq_ulp");
                        fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
                        break;
                case FSF_SQ_NO_RETRY_POSSIBLE:
@@ -2487,21 +2487,13 @@ zfcp_fsf_open_port_handler(struct zfcp_fsf_req *fsf_req)
                                        "Disabling it.\n",
                                        port->wwpn,
                                        zfcp_get_busid_by_port(port));
-                       debug_text_exception(fsf_req->adapter->erp_dbf, 0,
-                                            "fsf_sq_no_retry");
-                       zfcp_erp_port_failed(port);
+                       zfcp_erp_port_failed(port, 32, (u64)fsf_req);
                        fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
                        break;
                default:
                        ZFCP_LOG_NORMAL
                            ("bug: Wrong status qualifier 0x%x arrived.\n",
                             header->fsf_status_qual.word[0]);
-                       debug_text_event(fsf_req->adapter->erp_dbf, 0,
-                                        "fsf_sq_inval:");
-                       debug_exception(
-                               fsf_req->adapter->erp_dbf, 0,
-                               &header->fsf_status_qual.word[0],
-                               sizeof (u32));
                        break;
                }
                break;
@@ -2544,17 +2536,12 @@ zfcp_fsf_open_port_handler(struct zfcp_fsf_req *fsf_req)
                                        "warning: insufficient length of "
                                        "PLOGI payload (%i)\n",
                                        fsf_req->qtcb->bottom.support.els1_length);
-                               debug_text_event(fsf_req->adapter->erp_dbf, 0,
-                                                "fsf_s_short_plogi:");
                                /* skip sanity check and assume wwpn is ok */
                        } else {
                                if (plogi->serv_param.wwpn != port->wwpn) {
                                        ZFCP_LOG_INFO("warning: d_id of port "
                                                      "0x%016Lx changed during "
                                                      "open\n", port->wwpn);
-                                       debug_text_event(
-                                               fsf_req->adapter->erp_dbf, 0,
-                                               "fsf_s_did_change:");
                                        atomic_clear_mask(
                                                ZFCP_STATUS_PORT_DID_DID,
                                                &port->status);
@@ -2579,9 +2566,6 @@ zfcp_fsf_open_port_handler(struct zfcp_fsf_req *fsf_req)
                ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
                                "(debug info 0x%x)\n",
                                header->fsf_status);
-               debug_text_event(fsf_req->adapter->erp_dbf, 0, "fsf_s_inval:");
-               debug_exception(fsf_req->adapter->erp_dbf, 0,
-                               &header->fsf_status, sizeof (u32));
                break;
        }
 
@@ -2685,9 +2669,7 @@ zfcp_fsf_close_port_handler(struct zfcp_fsf_req *fsf_req)
                ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
                              (char *) &fsf_req->qtcb->header.fsf_status_qual,
                              sizeof (union fsf_status_qual));
-               debug_text_event(fsf_req->adapter->erp_dbf, 1,
-                                "fsf_s_phand_nv");
-               zfcp_erp_adapter_reopen(port->adapter, 0);
+               zfcp_erp_adapter_reopen(port->adapter, 0, 107, (u64)fsf_req);
                fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
                break;
 
@@ -2702,7 +2684,7 @@ zfcp_fsf_close_port_handler(struct zfcp_fsf_req *fsf_req)
                ZFCP_LOG_TRACE("remote port 0x016%Lx on adapter %s closed, "
                               "port handle 0x%x\n", port->wwpn,
                               zfcp_get_busid_by_port(port), port->handle);
-               zfcp_erp_modify_port_status(port,
+               zfcp_erp_modify_port_status(port, 33, (u64)fsf_req,
                                            ZFCP_STATUS_COMMON_OPEN,
                                            ZFCP_CLEAR);
                retval = 0;
@@ -2712,10 +2694,6 @@ zfcp_fsf_close_port_handler(struct zfcp_fsf_req *fsf_req)
                ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
                                "(debug info 0x%x)\n",
                                fsf_req->qtcb->header.fsf_status);
-               debug_text_event(fsf_req->adapter->erp_dbf, 0, "fsf_s_inval:");
-               debug_exception(fsf_req->adapter->erp_dbf, 0,
-                               &fsf_req->qtcb->header.fsf_status,
-                               sizeof (u32));
                break;
        }
 
@@ -2828,9 +2806,7 @@ zfcp_fsf_close_physical_port_handler(struct zfcp_fsf_req *fsf_req)
                ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
                              (char *) &header->fsf_status_qual,
                              sizeof (union fsf_status_qual));
-               debug_text_event(fsf_req->adapter->erp_dbf, 1,
-                                "fsf_s_phand_nv");
-               zfcp_erp_adapter_reopen(port->adapter, 0);
+               zfcp_erp_adapter_reopen(port->adapter, 0, 108, (u64)fsf_req);
                fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
                break;
 
@@ -2851,8 +2827,7 @@ zfcp_fsf_close_physical_port_handler(struct zfcp_fsf_req *fsf_req)
                                break;
                        }
                }
-               debug_text_event(fsf_req->adapter->erp_dbf, 1, "fsf_s_access");
-               zfcp_erp_port_access_denied(port);
+               zfcp_erp_port_access_denied(port, 58, (u64)fsf_req);
                fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
                break;
 
@@ -2862,35 +2837,32 @@ zfcp_fsf_close_physical_port_handler(struct zfcp_fsf_req *fsf_req)
                               "to close it physically.\n",
                               port->wwpn,
                               zfcp_get_busid_by_port(port));
-               debug_text_event(fsf_req->adapter->erp_dbf, 1, "fsf_s_pboxed");
-               zfcp_erp_port_boxed(port);
+               zfcp_erp_port_boxed(port, 50, (u64)fsf_req);
                fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR |
                        ZFCP_STATUS_FSFREQ_RETRY;
+
+               /* can't use generic zfcp_erp_modify_port_status because
+                * ZFCP_STATUS_COMMON_OPEN must not be reset for the port */
+               atomic_clear_mask(ZFCP_STATUS_PORT_PHYS_OPEN, &port->status);
+               list_for_each_entry(unit, &port->unit_list_head, list)
+                       atomic_clear_mask(ZFCP_STATUS_COMMON_OPEN,
+                                         &unit->status);
                break;
 
        case FSF_ADAPTER_STATUS_AVAILABLE:
                switch (header->fsf_status_qual.word[0]) {
                case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
-                       debug_text_event(fsf_req->adapter->erp_dbf, 1,
-                                        "fsf_sq_ltest");
                        /* This will now be escalated by ERP */
                        fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
                        break;
                case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
                        /* ERP strategy will escalate */
-                       debug_text_event(fsf_req->adapter->erp_dbf, 1,
-                                        "fsf_sq_ulp");
                        fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
                        break;
                default:
                        ZFCP_LOG_NORMAL
                            ("bug: Wrong status qualifier 0x%x arrived.\n",
                             header->fsf_status_qual.word[0]);
-                       debug_text_event(fsf_req->adapter->erp_dbf, 0,
-                                        "fsf_sq_inval:");
-                       debug_exception(
-                               fsf_req->adapter->erp_dbf, 0,
-                               &header->fsf_status_qual.word[0], sizeof (u32));
                        break;
                }
                break;
@@ -2913,9 +2885,6 @@ zfcp_fsf_close_physical_port_handler(struct zfcp_fsf_req *fsf_req)
                ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
                                "(debug info 0x%x)\n",
                                header->fsf_status);
-               debug_text_event(fsf_req->adapter->erp_dbf, 0, "fsf_s_inval:");
-               debug_exception(fsf_req->adapter->erp_dbf, 0,
-                               &header->fsf_status, sizeof (u32));
                break;
        }
 
@@ -3002,7 +2971,7 @@ zfcp_fsf_open_unit(struct zfcp_erp_action *erp_action)
  *
  * purpose:    is called for finished Open LUN command
  *
- * returns:    
+ * returns:
  */
 static int
 zfcp_fsf_open_unit_handler(struct zfcp_fsf_req *fsf_req)
@@ -3047,8 +3016,8 @@ zfcp_fsf_open_unit_handler(struct zfcp_fsf_req *fsf_req)
                ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
                              (char *) &header->fsf_status_qual,
                              sizeof (union fsf_status_qual));
-               debug_text_event(adapter->erp_dbf, 1, "fsf_s_ph_nv");
-               zfcp_erp_adapter_reopen(unit->port->adapter, 0);
+               zfcp_erp_adapter_reopen(unit->port->adapter, 0, 109,
+                                       (u64)fsf_req);
                fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
                break;
 
@@ -3057,8 +3026,6 @@ zfcp_fsf_open_unit_handler(struct zfcp_fsf_req *fsf_req)
                                "remote port 0x%016Lx on adapter %s twice.\n",
                                unit->fcp_lun,
                                unit->port->wwpn, zfcp_get_busid_by_unit(unit));
-               debug_text_exception(adapter->erp_dbf, 0,
-                                    "fsf_s_uopen");
                fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
                break;
 
@@ -3080,8 +3047,7 @@ zfcp_fsf_open_unit_handler(struct zfcp_fsf_req *fsf_req)
                                break;
                        }
                }
-               debug_text_event(adapter->erp_dbf, 1, "fsf_s_access");
-               zfcp_erp_unit_access_denied(unit);
+               zfcp_erp_unit_access_denied(unit, 59, (u64)fsf_req);
                atomic_clear_mask(ZFCP_STATUS_UNIT_SHARED, &unit->status);
                 atomic_clear_mask(ZFCP_STATUS_UNIT_READONLY, &unit->status);
                fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
@@ -3091,8 +3057,7 @@ zfcp_fsf_open_unit_handler(struct zfcp_fsf_req *fsf_req)
                ZFCP_LOG_DEBUG("The remote port 0x%016Lx on adapter %s "
                               "needs to be reopened\n",
                               unit->port->wwpn, zfcp_get_busid_by_unit(unit));
-               debug_text_event(adapter->erp_dbf, 2, "fsf_s_pboxed");
-               zfcp_erp_port_boxed(unit->port);
+               zfcp_erp_port_boxed(unit->port, 51, (u64)fsf_req);
                fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR |
                        ZFCP_STATUS_FSFREQ_RETRY;
                break;
@@ -3132,9 +3097,7 @@ zfcp_fsf_open_unit_handler(struct zfcp_fsf_req *fsf_req)
                ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
                              (char *) &header->fsf_status_qual,
                              sizeof (union fsf_status_qual));
-               debug_text_event(adapter->erp_dbf, 2,
-                                "fsf_s_l_sh_vio");
-               zfcp_erp_unit_access_denied(unit);
+               zfcp_erp_unit_access_denied(unit, 60, (u64)fsf_req);
                atomic_clear_mask(ZFCP_STATUS_UNIT_SHARED, &unit->status);
                atomic_clear_mask(ZFCP_STATUS_UNIT_READONLY, &unit->status);
                fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
@@ -3148,9 +3111,7 @@ zfcp_fsf_open_unit_handler(struct zfcp_fsf_req *fsf_req)
                              unit->fcp_lun,
                              unit->port->wwpn,
                              zfcp_get_busid_by_unit(unit));
-               debug_text_event(adapter->erp_dbf, 1,
-                                "fsf_s_max_units");
-               zfcp_erp_unit_failed(unit);
+               zfcp_erp_unit_failed(unit, 34, (u64)fsf_req);
                fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
                break;
 
@@ -3158,26 +3119,17 @@ zfcp_fsf_open_unit_handler(struct zfcp_fsf_req *fsf_req)
                switch (header->fsf_status_qual.word[0]) {
                case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
                        /* Re-establish link to port */
-                       debug_text_event(adapter->erp_dbf, 1,
-                                        "fsf_sq_ltest");
                        zfcp_test_link(unit->port);
                        fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
                        break;
                case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
                        /* ERP strategy will escalate */
-                       debug_text_event(adapter->erp_dbf, 1,
-                                        "fsf_sq_ulp");
                        fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
                        break;
                default:
                        ZFCP_LOG_NORMAL
                            ("bug: Wrong status qualifier 0x%x arrived.\n",
                             header->fsf_status_qual.word[0]);
-                       debug_text_event(adapter->erp_dbf, 0,
-                                        "fsf_sq_inval:");
-                       debug_exception(adapter->erp_dbf, 0,
-                                       &header->fsf_status_qual.word[0],
-                               sizeof (u32));
                }
                break;
 
@@ -3229,15 +3181,17 @@ zfcp_fsf_open_unit_handler(struct zfcp_fsf_req *fsf_req)
                        if (exclusive && !readwrite) {
                                ZFCP_LOG_NORMAL("exclusive access of read-only "
                                                "unit not supported\n");
-                               zfcp_erp_unit_failed(unit);
+                               zfcp_erp_unit_failed(unit, 35, (u64)fsf_req);
                                fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
-                               zfcp_erp_unit_shutdown(unit, 0);
+                               zfcp_erp_unit_shutdown(unit, 0, 80,
+                                                      (u64)fsf_req);
                        } else if (!exclusive && readwrite) {
                                ZFCP_LOG_NORMAL("shared access of read-write "
                                                "unit not supported\n");
-                               zfcp_erp_unit_failed(unit);
+                               zfcp_erp_unit_failed(unit, 36, (u64)fsf_req);
                                fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
-                               zfcp_erp_unit_shutdown(unit, 0);
+                               zfcp_erp_unit_shutdown(unit, 0, 81,
+                                                      (u64)fsf_req);
                        }
                }
 
@@ -3248,9 +3202,6 @@ zfcp_fsf_open_unit_handler(struct zfcp_fsf_req *fsf_req)
                ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
                                "(debug info 0x%x)\n",
                                header->fsf_status);
-               debug_text_event(adapter->erp_dbf, 0, "fsf_s_inval:");
-               debug_exception(adapter->erp_dbf, 0,
-                               &header->fsf_status, sizeof (u32));
                break;
        }
 
@@ -3265,7 +3216,7 @@ zfcp_fsf_open_unit_handler(struct zfcp_fsf_req *fsf_req)
  * purpose:
  *
  * returns:    address of fsf_req - request successfully initiated
- *             NULL - 
+ *             NULL -
  *
  * assumptions: This routine does not check whether the associated
  *              remote port/lun has already been opened. This should be
@@ -3363,9 +3314,8 @@ zfcp_fsf_close_unit_handler(struct zfcp_fsf_req *fsf_req)
                ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
                              (char *) &fsf_req->qtcb->header.fsf_status_qual,
                              sizeof (union fsf_status_qual));
-               debug_text_event(fsf_req->adapter->erp_dbf, 1,
-                                "fsf_s_phand_nv");
-               zfcp_erp_adapter_reopen(unit->port->adapter, 0);
+               zfcp_erp_adapter_reopen(unit->port->adapter, 0, 110,
+                                       (u64)fsf_req);
                fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
                break;
 
@@ -3381,9 +3331,7 @@ zfcp_fsf_close_unit_handler(struct zfcp_fsf_req *fsf_req)
                ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
                              (char *) &fsf_req->qtcb->header.fsf_status_qual,
                              sizeof (union fsf_status_qual));
-               debug_text_event(fsf_req->adapter->erp_dbf, 1,
-                                "fsf_s_lhand_nv");
-               zfcp_erp_port_reopen(unit->port, 0);
+               zfcp_erp_port_reopen(unit->port, 0, 111, (u64)fsf_req);
                fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
                break;
 
@@ -3392,8 +3340,7 @@ zfcp_fsf_close_unit_handler(struct zfcp_fsf_req *fsf_req)
                               "needs to be reopened\n",
                               unit->port->wwpn,
                               zfcp_get_busid_by_unit(unit));
-               debug_text_event(fsf_req->adapter->erp_dbf, 2, "fsf_s_pboxed");
-               zfcp_erp_port_boxed(unit->port);
+               zfcp_erp_port_boxed(unit->port, 52, (u64)fsf_req);
                fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR |
                        ZFCP_STATUS_FSFREQ_RETRY;
                break;
@@ -3402,27 +3349,17 @@ zfcp_fsf_close_unit_handler(struct zfcp_fsf_req *fsf_req)
                switch (fsf_req->qtcb->header.fsf_status_qual.word[0]) {
                case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
                        /* re-establish link to port */
-                       debug_text_event(fsf_req->adapter->erp_dbf, 1,
-                                        "fsf_sq_ltest");
                        zfcp_test_link(unit->port);
                        fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
                        break;
                case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
                        /* ERP strategy will escalate */
-                       debug_text_event(fsf_req->adapter->erp_dbf, 1,
-                                        "fsf_sq_ulp");
                        fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
                        break;
                default:
                        ZFCP_LOG_NORMAL
                            ("bug: Wrong status qualifier 0x%x arrived.\n",
                             fsf_req->qtcb->header.fsf_status_qual.word[0]);
-                       debug_text_event(fsf_req->adapter->erp_dbf, 0,
-                                        "fsf_sq_inval:");
-                       debug_exception(
-                               fsf_req->adapter->erp_dbf, 0,
-                               &fsf_req->qtcb->header.fsf_status_qual.word[0],
-                               sizeof (u32));
                        break;
                }
                break;
@@ -3443,10 +3380,6 @@ zfcp_fsf_close_unit_handler(struct zfcp_fsf_req *fsf_req)
                ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
                                "(debug info 0x%x)\n",
                                fsf_req->qtcb->header.fsf_status);
-               debug_text_event(fsf_req->adapter->erp_dbf, 0, "fsf_s_inval:");
-               debug_exception(fsf_req->adapter->erp_dbf, 0,
-                               &fsf_req->qtcb->header.fsf_status,
-                               sizeof (u32));
                break;
        }
 
@@ -3491,6 +3424,12 @@ zfcp_fsf_send_fcp_command_task(struct zfcp_adapter *adapter,
                goto failed_req_create;
        }
 
+       if (unlikely(!atomic_test_mask(ZFCP_STATUS_COMMON_UNBLOCKED,
+                       &unit->status))) {
+               retval = -EBUSY;
+               goto unit_blocked;
+       }
+
        zfcp_unit_get(unit);
        fsf_req->unit = unit;
 
@@ -3586,17 +3525,17 @@ zfcp_fsf_send_fcp_command_task(struct zfcp_adapter *adapter,
                        ZFCP_LOG_DEBUG(
                                "Data did not fit into available buffer(s), "
                               "waiting for more...\n");
-               retval = -EIO;
-       } else {
-               ZFCP_LOG_NORMAL("error: No truncation implemented but "
-                               "required. Shutting down unit "
-                               "(adapter %s, port 0x%016Lx, "
-                               "unit 0x%016Lx)\n",
-                               zfcp_get_busid_by_unit(unit),
-                               unit->port->wwpn,
-                               unit->fcp_lun);
-               zfcp_erp_unit_shutdown(unit, 0);
-               retval = -EINVAL;
+                       retval = -EIO;
+               } else {
+                       ZFCP_LOG_NORMAL("error: No truncation implemented but "
+                                       "required. Shutting down unit "
+                                       "(adapter %s, port 0x%016Lx, "
+                                       "unit 0x%016Lx)\n",
+                                       zfcp_get_busid_by_unit(unit),
+                                       unit->port->wwpn,
+                                       unit->fcp_lun);
+                       zfcp_erp_unit_shutdown(unit, 0, 131, (u64)fsf_req);
+                       retval = -EINVAL;
                }
                goto no_fit;
        }
@@ -3631,6 +3570,7 @@ zfcp_fsf_send_fcp_command_task(struct zfcp_adapter *adapter,
  send_failed:
  no_fit:
  failed_scsi_cmnd:
+ unit_blocked:
        zfcp_unit_put(unit);
        zfcp_fsf_req_free(fsf_req);
        fsf_req = NULL;
@@ -3665,6 +3605,10 @@ zfcp_fsf_send_fcp_command_task_management(struct zfcp_adapter *adapter,
                goto out;
        }
 
+       if (unlikely(!atomic_test_mask(ZFCP_STATUS_COMMON_UNBLOCKED,
+                       &unit->status)))
+               goto unit_blocked;
+
        /*
         * Used to decide on proper handler in the return path,
         * could be either zfcp_fsf_send_fcp_command_task_handler or
@@ -3698,25 +3642,13 @@ zfcp_fsf_send_fcp_command_task_management(struct zfcp_adapter *adapter,
 
        zfcp_fsf_start_timer(fsf_req, ZFCP_SCSI_ER_TIMEOUT);
        retval = zfcp_fsf_req_send(fsf_req);
-       if (retval) {
-               ZFCP_LOG_INFO("error: Could not send an FCP-command (task "
-                             "management) on adapter %s, port 0x%016Lx for "
-                             "unit LUN 0x%016Lx\n",
-                             zfcp_get_busid_by_adapter(adapter),
-                             unit->port->wwpn,
-                             unit->fcp_lun);
-               zfcp_fsf_req_free(fsf_req);
-               fsf_req = NULL;
+       if (!retval)
                goto out;
-       }
 
-       ZFCP_LOG_TRACE("Send FCP Command (task management function) initiated "
-                      "(adapter %s, port 0x%016Lx, unit 0x%016Lx, "
-                      "tm_flags=0x%x)\n",
-                      zfcp_get_busid_by_adapter(adapter),
-                      unit->port->wwpn,
-                      unit->fcp_lun,
-                      tm_flags);
+ unit_blocked:
+       zfcp_fsf_req_free(fsf_req);
+       fsf_req = NULL;
+
  out:
        write_unlock_irqrestore(&adapter->request_queue.queue_lock, lock_flags);
        return fsf_req;
@@ -3727,7 +3659,7 @@ zfcp_fsf_send_fcp_command_task_management(struct zfcp_adapter *adapter,
  *
  * purpose:    is called for finished Send FCP Command
  *
- * returns:    
+ * returns:
  */
 static int
 zfcp_fsf_send_fcp_command_handler(struct zfcp_fsf_req *fsf_req)
@@ -3760,9 +3692,8 @@ zfcp_fsf_send_fcp_command_handler(struct zfcp_fsf_req *fsf_req)
                ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
                              (char *) &header->fsf_status_qual,
                              sizeof (union fsf_status_qual));
-               debug_text_event(fsf_req->adapter->erp_dbf, 1,
-                                "fsf_s_phand_nv");
-               zfcp_erp_adapter_reopen(unit->port->adapter, 0);
+               zfcp_erp_adapter_reopen(unit->port->adapter, 0, 112,
+                                       (u64)fsf_req);
                fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
                break;
 
@@ -3778,9 +3709,7 @@ zfcp_fsf_send_fcp_command_handler(struct zfcp_fsf_req *fsf_req)
                ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_NORMAL,
                              (char *) &header->fsf_status_qual,
                              sizeof (union fsf_status_qual));
-               debug_text_event(fsf_req->adapter->erp_dbf, 1,
-                                "fsf_s_uhand_nv");
-               zfcp_erp_port_reopen(unit->port, 0);
+               zfcp_erp_port_reopen(unit->port, 0, 113, (u64)fsf_req);
                fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
                break;
 
@@ -3796,9 +3725,8 @@ zfcp_fsf_send_fcp_command_handler(struct zfcp_fsf_req *fsf_req)
                ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_NORMAL,
                              (char *) &header->fsf_status_qual,
                              sizeof (union fsf_status_qual));
-               debug_text_event(fsf_req->adapter->erp_dbf, 1,
-                                "fsf_s_hand_mis");
-               zfcp_erp_adapter_reopen(unit->port->adapter, 0);
+               zfcp_erp_adapter_reopen(unit->port->adapter, 0, 114,
+                                       (u64)fsf_req);
                fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
                break;
 
@@ -3808,9 +3736,8 @@ zfcp_fsf_send_fcp_command_handler(struct zfcp_fsf_req *fsf_req)
                              zfcp_get_busid_by_unit(unit),
                              ZFCP_FC_SERVICE_CLASS_DEFAULT);
                /* stop operation for this adapter */
-               debug_text_exception(fsf_req->adapter->erp_dbf, 0,
-                                    "fsf_s_class_nsup");
-               zfcp_erp_adapter_shutdown(unit->port->adapter, 0);
+               zfcp_erp_adapter_shutdown(unit->port->adapter, 0, 132,
+                                         (u64)fsf_req);
                fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
                break;
 
@@ -3826,9 +3753,7 @@ zfcp_fsf_send_fcp_command_handler(struct zfcp_fsf_req *fsf_req)
                ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
                              (char *) &header->fsf_status_qual,
                              sizeof (union fsf_status_qual));
-               debug_text_event(fsf_req->adapter->erp_dbf, 1,
-                                "fsf_s_fcp_lun_nv");
-               zfcp_erp_port_reopen(unit->port, 0);
+               zfcp_erp_port_reopen(unit->port, 0, 115, (u64)fsf_req);
                fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
                break;
 
@@ -3850,8 +3775,7 @@ zfcp_fsf_send_fcp_command_handler(struct zfcp_fsf_req *fsf_req)
                                break;
                        }
                }
-               debug_text_event(fsf_req->adapter->erp_dbf, 1, "fsf_s_access");
-               zfcp_erp_unit_access_denied(unit);
+               zfcp_erp_unit_access_denied(unit, 61, (u64)fsf_req);
                fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
                break;
 
@@ -3864,9 +3788,8 @@ zfcp_fsf_send_fcp_command_handler(struct zfcp_fsf_req *fsf_req)
                              zfcp_get_busid_by_unit(unit),
                              fsf_req->qtcb->bottom.io.data_direction);
                /* stop operation for this adapter */
-               debug_text_event(fsf_req->adapter->erp_dbf, 0,
-                                "fsf_s_dir_ind_nv");
-               zfcp_erp_adapter_shutdown(unit->port->adapter, 0);
+               zfcp_erp_adapter_shutdown(unit->port->adapter, 0, 133,
+                                         (u64)fsf_req);
                fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
                break;
 
@@ -3879,9 +3802,8 @@ zfcp_fsf_send_fcp_command_handler(struct zfcp_fsf_req *fsf_req)
                     zfcp_get_busid_by_unit(unit),
                     fsf_req->qtcb->bottom.io.fcp_cmnd_length);
                /* stop operation for this adapter */
-               debug_text_event(fsf_req->adapter->erp_dbf, 0,
-                                "fsf_s_cmd_len_nv");
-               zfcp_erp_adapter_shutdown(unit->port->adapter, 0);
+               zfcp_erp_adapter_shutdown(unit->port->adapter, 0, 134,
+                                         (u64)fsf_req);
                fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
                break;
 
@@ -3889,8 +3811,7 @@ zfcp_fsf_send_fcp_command_handler(struct zfcp_fsf_req *fsf_req)
                ZFCP_LOG_DEBUG("The remote port 0x%016Lx on adapter %s "
                               "needs to be reopened\n",
                               unit->port->wwpn, zfcp_get_busid_by_unit(unit));
-               debug_text_event(fsf_req->adapter->erp_dbf, 2, "fsf_s_pboxed");
-               zfcp_erp_port_boxed(unit->port);
+               zfcp_erp_port_boxed(unit->port, 53, (u64)fsf_req);
                fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR |
                        ZFCP_STATUS_FSFREQ_RETRY;
                break;
@@ -3900,8 +3821,7 @@ zfcp_fsf_send_fcp_command_handler(struct zfcp_fsf_req *fsf_req)
                                "wwpn=0x%016Lx, fcp_lun=0x%016Lx)\n",
                                zfcp_get_busid_by_unit(unit),
                                unit->port->wwpn, unit->fcp_lun);
-               debug_text_event(fsf_req->adapter->erp_dbf, 1, "fsf_s_lboxed");
-               zfcp_erp_unit_boxed(unit);
+               zfcp_erp_unit_boxed(unit, 54, (u64)fsf_req);
                fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR
                        | ZFCP_STATUS_FSFREQ_RETRY;
                break;
@@ -3910,25 +3830,16 @@ zfcp_fsf_send_fcp_command_handler(struct zfcp_fsf_req *fsf_req)
                switch (header->fsf_status_qual.word[0]) {
                case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
                        /* re-establish link to port */
-                       debug_text_event(fsf_req->adapter->erp_dbf, 1,
-                                        "fsf_sq_ltest");
                        zfcp_test_link(unit->port);
                        break;
                case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
                        /* FIXME(hw) need proper specs for proper action */
                        /* let scsi stack deal with retries and escalation */
-                       debug_text_event(fsf_req->adapter->erp_dbf, 1,
-                                        "fsf_sq_ulp");
                        break;
                default:
                        ZFCP_LOG_NORMAL
                            ("Unknown status qualifier 0x%x arrived.\n",
                             header->fsf_status_qual.word[0]);
-                       debug_text_event(fsf_req->adapter->erp_dbf, 0,
-                                        "fsf_sq_inval:");
-                       debug_exception(fsf_req->adapter->erp_dbf, 0,
-                                       &header->fsf_status_qual.word[0],
-                                       sizeof(u32));
                        break;
                }
                fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
@@ -3939,12 +3850,6 @@ zfcp_fsf_send_fcp_command_handler(struct zfcp_fsf_req *fsf_req)
 
        case FSF_FCP_RSP_AVAILABLE:
                break;
-
-       default:
-               debug_text_event(fsf_req->adapter->erp_dbf, 0, "fsf_s_inval:");
-               debug_exception(fsf_req->adapter->erp_dbf, 0,
-                               &header->fsf_status, sizeof(u32));
-               break;
        }
 
  skip_fsfstatus:
@@ -3964,7 +3869,7 @@ zfcp_fsf_send_fcp_command_handler(struct zfcp_fsf_req *fsf_req)
  *
  * purpose:    evaluates FCP_RSP IU
  *
- * returns:    
+ * returns:
  */
 static int
 zfcp_fsf_send_fcp_command_task_handler(struct zfcp_fsf_req *fsf_req)
@@ -4123,10 +4028,10 @@ zfcp_fsf_send_fcp_command_task_handler(struct zfcp_fsf_req *fsf_req)
 
                ZFCP_LOG_TRACE("%i bytes sense data provided by FCP\n",
                               fcp_rsp_iu->fcp_sns_len);
-               memcpy(&scpnt->sense_buffer,
+               memcpy(scpnt->sense_buffer,
                       zfcp_get_fcp_sns_info_ptr(fcp_rsp_iu), sns_len);
                ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_TRACE,
-                             (void *) &scpnt->sense_buffer, sns_len);
+                             (void *)scpnt->sense_buffer, sns_len);
        }
 
        /* check for overrun */
@@ -4192,7 +4097,7 @@ zfcp_fsf_send_fcp_command_task_handler(struct zfcp_fsf_req *fsf_req)
  *
  * purpose:    evaluates FCP_RSP IU
  *
- * returns:    
+ * returns:
  */
 static int
 zfcp_fsf_send_fcp_command_task_management_handler(struct zfcp_fsf_req *fsf_req)
@@ -4524,9 +4429,6 @@ zfcp_fsf_control_file_handler(struct zfcp_fsf_req *fsf_req)
                        "was presented on the adapter %s\n",
                        header->fsf_status,
                        zfcp_get_busid_by_adapter(adapter));
-               debug_text_event(fsf_req->adapter->erp_dbf, 0, "fsf_sq_inval");
-               debug_exception(fsf_req->adapter->erp_dbf, 0,
-                       &header->fsf_status_qual.word[0], sizeof(u32));
                fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
                retval = -EINVAL;
                break;
@@ -4624,7 +4526,7 @@ zfcp_fsf_req_create(struct zfcp_adapter *adapter, u32 fsf_cmd, int req_flags,
        /* allocate new FSF request */
        fsf_req = zfcp_fsf_req_alloc(pool, req_flags);
        if (unlikely(NULL == fsf_req)) {
-               ZFCP_LOG_DEBUG("error: Could not put an FSF request into"
+               ZFCP_LOG_DEBUG("error: Could not put an FSF request into "
                               "the outbound (send) queue.\n");
                ret = -ENOMEM;
                goto failed_fsf_req;
@@ -4635,7 +4537,7 @@ zfcp_fsf_req_create(struct zfcp_adapter *adapter, u32 fsf_cmd, int req_flags,
        INIT_LIST_HEAD(&fsf_req->list);
        init_timer(&fsf_req->timer);
 
-       /* initialize waitqueue which may be used to wait on 
+       /* initialize waitqueue which may be used to wait on
           this request completion */
        init_waitqueue_head(&fsf_req->completion_wq);
 
@@ -4716,7 +4618,6 @@ static int zfcp_fsf_req_send(struct zfcp_fsf_req *fsf_req)
        volatile struct qdio_buffer_element *sbale;
        int inc_seq_no;
        int new_distance_from_int;
-       u64 dbg_tmp[2];
        int retval = 0;
 
        adapter = fsf_req->adapter;
@@ -4766,10 +4667,6 @@ static int zfcp_fsf_req_send(struct zfcp_fsf_req *fsf_req)
                         QDIO_FLAG_SYNC_OUTPUT,
                         0, fsf_req->sbal_first, fsf_req->sbal_number, NULL);
 
-       dbg_tmp[0] = (unsigned long) sbale[0].addr;
-       dbg_tmp[1] = (u64) retval;
-       debug_event(adapter->erp_dbf, 4, (void *) dbg_tmp, 16);
-
        if (unlikely(retval)) {
                /* Queues are down..... */
                retval = -EIO;
@@ -4784,7 +4681,7 @@ static int zfcp_fsf_req_send(struct zfcp_fsf_req *fsf_req)
                req_queue->free_index -= fsf_req->sbal_number;
                req_queue->free_index += QDIO_MAX_BUFFERS_PER_Q;
                req_queue->free_index %= QDIO_MAX_BUFFERS_PER_Q; /* wrap */
-               zfcp_erp_adapter_reopen(adapter, 0);
+               zfcp_erp_adapter_reopen(adapter, 0, 116, (u64)fsf_req);
        } else {
                req_queue->distance_from_int = new_distance_from_int;
                /*