[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 aa774752916549a9c41087f3d634a07bd1287648..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.
  */
@@ -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",