[SCSI] qla2xxx: Add test for valid loop id to qla2x00_relogin().
[firefly-linux-kernel-4.4.55.git] / drivers / scsi / qla2xxx / qla_os.c
index 75a966c94860e0cd0e05b903759645c7c460f739..d1b29dc9cba192c4ede3956d0f72f10d767fd84e 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * QLogic Fibre Channel HBA Driver
- * Copyright (c)  2003-2010 QLogic Corporation
+ * Copyright (c)  2003-2011 QLogic Corporation
  *
  * See LICENSE.qla2xxx for copyright and licensing details.
  */
@@ -1046,7 +1046,7 @@ qla2xxx_eh_bus_reset(struct scsi_cmnd *cmd)
 
 eh_bus_reset_done:
        qla_printk(KERN_INFO, vha->hw, "%s: reset %s\n", __func__,
-           (ret == FAILED) ? "failed" : "succeded");
+           (ret == FAILED) ? "failed" : "succeeded");
 
        return ret;
 }
@@ -1136,7 +1136,7 @@ qla2xxx_eh_host_reset(struct scsi_cmnd *cmd)
 
 eh_host_reset_lock:
        qla_printk(KERN_INFO, ha, "%s: reset %s\n", __func__,
-           (ret == FAILED) ? "failed" : "succeded");
+           (ret == FAILED) ? "failed" : "succeeded");
 
        return ret;
 }
@@ -3214,6 +3214,17 @@ void qla2x00_relogin(struct scsi_qla_host *vha)
                                                        fcport->d_id.b.area,
                                                        fcport->d_id.b.al_pa);
 
+                               if (fcport->loop_id == FC_NO_LOOP_ID) {
+                                       fcport->loop_id = next_loopid =
+                                           ha->min_external_loopid;
+                                       status = qla2x00_find_new_loop_id(
+                                           vha, fcport);
+                                       if (status != QLA_SUCCESS) {
+                                               /* Ran out of IDs to use */
+                                               break;
+                                       }
+                               }
+
                                if (IS_ALOGIO_CAPABLE(ha)) {
                                        fcport->flags |= FCF_ASYNC_SENT;
                                        data[0] = 0;
@@ -3612,7 +3623,8 @@ qla2x00_timer(scsi_qla_host_t *vha)
 
        /* Loop down handler. */
        if (atomic_read(&vha->loop_down_timer) > 0 &&
-           !(test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags))
+           !(test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags)) &&
+           !(test_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags))
                && vha->flags.online) {
 
                if (atomic_read(&vha->loop_down_timer) ==
@@ -3648,7 +3660,11 @@ qla2x00_timer(scsi_qla_host_t *vha)
                                        if (!(sfcp->flags & FCF_FCP2_DEVICE))
                                                continue;
 
-                                       set_bit(ISP_ABORT_NEEDED,
+                                       if (IS_QLA82XX(ha))
+                                               set_bit(FCOE_CTX_RESET_NEEDED,
+                                                       &vha->dpc_flags);
+                                       else
+                                               set_bit(ISP_ABORT_NEEDED,
                                                        &vha->dpc_flags);
                                        break;
                                }
@@ -3667,7 +3683,12 @@ qla2x00_timer(scsi_qla_host_t *vha)
                                qla_printk(KERN_WARNING, ha,
                                    "Loop down - aborting ISP.\n");
 
-                               set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags);
+                               if (IS_QLA82XX(ha))
+                                       set_bit(FCOE_CTX_RESET_NEEDED,
+                                               &vha->dpc_flags);
+                               else
+                                       set_bit(ISP_ABORT_NEEDED,
+                                               &vha->dpc_flags);
                        }
                }
                DEBUG3(printk("scsi(%ld): Loop Down - seconds remaining %d\n",
@@ -3902,7 +3923,7 @@ uint32_t qla82xx_error_recovery(scsi_qla_host_t *base_vha)
                        continue;
                if (atomic_read(&other_pdev->enable_cnt)) {
                        DEBUG17(qla_printk(KERN_INFO, ha,
-                           "Found PCI func availabe and enabled at 0x%x\n",
+                           "Found PCI func available and enabled at 0x%x\n",
                            fn));
                        pci_dev_put(other_pdev);
                        break;