Merge master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6
[powerpc.git] / drivers / s390 / scsi / zfcp_fsf.c
index 5958795..662ec57 100644 (file)
@@ -30,8 +30,6 @@
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
-#define ZFCP_FSF_C_REVISION "$Revision: 1.92 $"
-
 #include "zfcp_ext.h"
 
 static int zfcp_fsf_exchange_config_data_handler(struct zfcp_fsf_req *);
@@ -390,6 +388,7 @@ zfcp_fsf_protstatus_eval(struct zfcp_fsf_req *fsf_req)
        case FSF_PROT_LINK_DOWN:
                zfcp_fsf_link_down_info_eval(adapter,
                                             &prot_status_qual->link_down_info);
+               zfcp_erp_adapter_reopen(adapter, 0);
                fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
                break;
 
@@ -560,10 +559,8 @@ zfcp_fsf_link_down_info_eval(struct zfcp_adapter *adapter,
 
        atomic_set_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED, &adapter->status);
 
-       if (link_down == NULL) {
-               zfcp_erp_adapter_reopen(adapter, 0);
-               return;
-       }
+       if (link_down == NULL)
+               goto out;
 
        switch (link_down->error_code) {
        case FSF_PSQ_LINK_NO_LIGHT:
@@ -645,16 +642,8 @@ zfcp_fsf_link_down_info_eval(struct zfcp_adapter *adapter,
                                link_down->explanation_code,
                                link_down->vendor_specific_code);
 
-       switch (link_down->error_code) {
-       case FSF_PSQ_LINK_NO_LIGHT:
-       case FSF_PSQ_LINK_WRAP_PLUG:
-       case FSF_PSQ_LINK_NO_FCP:
-       case FSF_PSQ_LINK_FIRMWARE_UPDATE:
-               zfcp_erp_adapter_reopen(adapter, 0);
-               break;
-       default:
-               zfcp_erp_adapter_failed(adapter);
-       }
+ out:
+       zfcp_erp_adapter_failed(adapter);
 }
 
 /*
@@ -964,6 +953,40 @@ zfcp_fsf_status_read_handler(struct zfcp_fsf_req *fsf_req)
                                        | ZFCP_STATUS_COMMON_ERP_FAILED);
                break;
 
+       case FSF_STATUS_READ_NOTIFICATION_LOST:
+               ZFCP_LOG_NORMAL("Unsolicited status notification(s) lost: "
+                               "adapter %s%s%s%s%s%s%s%s%s\n",
+                               zfcp_get_busid_by_adapter(adapter),
+                               (status_buffer->status_subtype &
+                                       FSF_STATUS_READ_SUB_INCOMING_ELS) ?
+                                       ", incoming ELS" : "",
+                               (status_buffer->status_subtype &
+                                       FSF_STATUS_READ_SUB_SENSE_DATA) ?
+                                       ", sense data" : "",
+                               (status_buffer->status_subtype &
+                                       FSF_STATUS_READ_SUB_LINK_STATUS) ?
+                                       ", link status change" : "",
+                               (status_buffer->status_subtype &
+                                       FSF_STATUS_READ_SUB_PORT_CLOSED) ?
+                                       ", port close" : "",
+                               (status_buffer->status_subtype &
+                                       FSF_STATUS_READ_SUB_BIT_ERROR_THRESHOLD) ?
+                                       ", bit error exception" : "",
+                               (status_buffer->status_subtype &
+                                       FSF_STATUS_READ_SUB_ACT_UPDATED) ?
+                                       ", ACT update" : "",
+                               (status_buffer->status_subtype &
+                                       FSF_STATUS_READ_SUB_ACT_HARDENED) ?
+                                       ", ACT hardening" : "",
+                               (status_buffer->status_subtype &
+                                       FSF_STATUS_READ_SUB_FEATURE_UPDATE_ALERT) ?
+                                       ", adapter feature change" : "");
+
+               if (status_buffer->status_subtype &
+                   FSF_STATUS_READ_SUB_ACT_UPDATED)
+                       zfcp_erp_adapter_access_changed(adapter);
+               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));
@@ -1954,6 +1977,7 @@ zfcp_fsf_exchange_config_data(struct zfcp_erp_action *erp_action)
        erp_action->fsf_req->qtcb->bottom.config.feature_selection =
                        FSF_FEATURE_CFDC |
                        FSF_FEATURE_LUN_SHARING |
+                       FSF_FEATURE_NOTIFICATION_LOST |
                        FSF_FEATURE_UPDATE_ALERT;
 
        /* start QDIO request for this FSF request */
@@ -2008,27 +2032,30 @@ zfcp_fsf_exchange_config_evaluate(struct zfcp_fsf_req *fsf_req, int xchg_ok)
                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;
-               adapter->fc_topology = bottom->fc_topology;
                adapter->hydra_version = bottom->adapter_type;
-               if (adapter->physical_wwpn == 0)
-                       adapter->physical_wwpn = fc_host_port_name(shost);
-               if (adapter->physical_s_id == 0)
-                       adapter->physical_s_id = fc_host_port_id(shost);
+               if (fc_host_permanent_port_name(shost) == -1)
+                       fc_host_permanent_port_name(shost) =
+                               fc_host_port_name(shost);
+               if (bottom->fc_topology == FSF_TOPO_P2P) {
+                       adapter->peer_d_id = bottom->peer_d_id & ZFCP_DID_MASK;
+                       adapter->peer_wwpn = bottom->plogi_payload.wwpn;
+                       adapter->peer_wwnn = bottom->plogi_payload.wwnn;
+                       fc_host_port_type(shost) = FC_PORTTYPE_PTP;
+               } else if (bottom->fc_topology == FSF_TOPO_FABRIC)
+                       fc_host_port_type(shost) = FC_PORTTYPE_NPORT;
+               else if (bottom->fc_topology == FSF_TOPO_AL)
+                       fc_host_port_type(shost) = FC_PORTTYPE_NLPORT;
+               else
+                       fc_host_port_type(shost) = FC_PORTTYPE_UNKNOWN;
        } else {
                fc_host_node_name(shost) = 0;
                fc_host_port_name(shost) = 0;
                fc_host_port_id(shost) = 0;
                fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN;
-               adapter->fc_topology = 0;
+               fc_host_port_type(shost) = FC_PORTTYPE_UNKNOWN;
                adapter->hydra_version = 0;
        }
 
-       if (adapter->fc_topology == FSF_TOPO_P2P) {
-               adapter->peer_d_id = bottom->peer_d_id & ZFCP_DID_MASK;
-               adapter->peer_wwpn = bottom->plogi_payload.wwpn;
-               adapter->peer_wwnn = bottom->plogi_payload.wwnn;
-       }
-
        if (adapter->adapter_features & FSF_FEATURE_HBAAPI_MANAGEMENT) {
                adapter->hardware_version = bottom->hardware_version;
                memcpy(fc_host_serial_number(shost), bottom->serial_number,
@@ -2097,8 +2124,8 @@ zfcp_fsf_exchange_config_data_handler(struct zfcp_fsf_req *fsf_req)
                if (zfcp_fsf_exchange_config_evaluate(fsf_req, 1))
                        return -EIO;
 
-               switch (adapter->fc_topology) {
-               case FSF_TOPO_P2P:
+               switch (fc_host_port_type(adapter->scsi_host)) {
+               case FC_PORTTYPE_PTP:
                        ZFCP_LOG_NORMAL("Point-to-Point fibrechannel "
                                        "configuration detected at adapter %s\n"
                                        "Peer WWNN 0x%016llx, "
@@ -2111,7 +2138,7 @@ zfcp_fsf_exchange_config_data_handler(struct zfcp_fsf_req *fsf_req)
                        debug_text_event(fsf_req->adapter->erp_dbf, 0,
                                         "top-p-to-p");
                        break;
-               case FSF_TOPO_AL:
+               case FC_PORTTYPE_NLPORT:
                        ZFCP_LOG_NORMAL("error: Arbitrated loop fibrechannel "
                                        "topology detected at adapter %s "
                                        "unsupported, shutting down adapter\n",
@@ -2120,7 +2147,7 @@ zfcp_fsf_exchange_config_data_handler(struct zfcp_fsf_req *fsf_req)
                                         "top-al");
                        zfcp_erp_adapter_shutdown(adapter, 0);
                        return -EIO;
-               case FSF_TOPO_FABRIC:
+               case FC_PORTTYPE_NPORT:
                        ZFCP_LOG_NORMAL("Switched fabric fibrechannel "
                                      "network detected at adapter %s.\n",
                                      zfcp_get_busid_by_adapter(adapter));
@@ -2133,7 +2160,6 @@ 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));
-                       adapter->fc_topology = FSF_TOPO_ERROR;
                        debug_text_exception(fsf_req->adapter->erp_dbf, 0,
                                             "unknown-topo");
                        zfcp_erp_adapter_shutdown(adapter, 0);
@@ -2269,6 +2295,35 @@ zfcp_fsf_exchange_port_data(struct zfcp_erp_action *erp_action,
        return retval;
 }
 
+/**
+ * zfcp_fsf_exchange_port_evaluate
+ * @fsf_req: fsf_req which belongs to xchg port data request
+ * @xchg_ok: specifies if xchg port data was incomplete or complete (0/1)
+ */
+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 Scsi_Host *shost;
+
+       adapter = fsf_req->adapter;
+       qtcb = fsf_req->qtcb;
+       bottom = &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 (adapter->connection_features & FSF_FEATURE_NPIV_MODE)
+               fc_host_permanent_port_name(shost) = bottom->wwpn;
+       else
+               fc_host_permanent_port_name(shost) = fc_host_port_name(shost);
+       fc_host_maxframe_size(shost) = bottom->maximum_frame_size;
+       fc_host_supported_speeds(shost) = bottom->supported_speed;
+}
 
 /**
  * zfcp_fsf_exchange_port_data_handler - handler for exchange_port_data request
@@ -2277,39 +2332,26 @@ zfcp_fsf_exchange_port_data(struct zfcp_erp_action *erp_action,
 static void
 zfcp_fsf_exchange_port_data_handler(struct zfcp_fsf_req *fsf_req)
 {
-       struct zfcp_adapter *adapter = fsf_req->adapter;
-       struct Scsi_Host *shost = adapter->scsi_host;
-       struct fsf_qtcb *qtcb = fsf_req->qtcb;
-       struct fsf_qtcb_bottom_port *bottom, *data;
+       struct zfcp_adapter *adapter;
+       struct fsf_qtcb *qtcb;
+
+       adapter = fsf_req->adapter;
+       qtcb = fsf_req->qtcb;
 
        if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR)
                return;
 
        switch (qtcb->header.fsf_status) {
         case FSF_GOOD:
+               zfcp_fsf_exchange_port_evaluate(fsf_req, 1);
                atomic_set_mask(ZFCP_STATUS_ADAPTER_XPORT_OK, &adapter->status);
-
-               bottom = &qtcb->bottom.port;
-               data = (struct fsf_qtcb_bottom_port*) fsf_req->data;
-               if (data)
-                       memcpy(data, bottom, sizeof(struct fsf_qtcb_bottom_port));
-               if (adapter->connection_features & FSF_FEATURE_NPIV_MODE) {
-                       adapter->physical_wwpn = bottom->wwpn;
-                       adapter->physical_s_id = bottom->fc_port_id;
-               } else {
-                       adapter->physical_wwpn = fc_host_port_name(shost);
-                       adapter->physical_s_id = fc_host_port_id(shost);
-               }
-               fc_host_maxframe_size(shost) = bottom->maximum_frame_size;
                break;
-
        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,
                        &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,
@@ -4169,11 +4211,11 @@ zfcp_fsf_send_fcp_command_task_handler(struct zfcp_fsf_req *fsf_req)
        ZFCP_LOG_DEBUG("scpnt->result =0x%x\n", scpnt->result);
 
        if (scpnt->result != 0)
-               zfcp_scsi_dbf_event_result("erro", 3, fsf_req->adapter, scpnt);
+               zfcp_scsi_dbf_event_result("erro", 3, fsf_req->adapter, scpnt, fsf_req);
        else if (scpnt->retries > 0)
-               zfcp_scsi_dbf_event_result("retr", 4, fsf_req->adapter, scpnt);
+               zfcp_scsi_dbf_event_result("retr", 4, fsf_req->adapter, scpnt, fsf_req);
        else
-               zfcp_scsi_dbf_event_result("norm", 6, fsf_req->adapter, scpnt);
+               zfcp_scsi_dbf_event_result("norm", 6, fsf_req->adapter, scpnt, fsf_req);
 
        /* cleanup pointer (need this especially for abort) */
        scpnt->host_scribble = NULL;