scsi: qla2xxx: Fix remoteport disconnect for FC-NVMe
authorhimanshu.madhani@cavium.com <himanshu.madhani@cavium.com>
Fri, 21 Jul 2017 16:32:27 +0000 (09:32 -0700)
committerMartin K. Petersen <martin.petersen@oracle.com>
Mon, 7 Aug 2017 18:04:02 +0000 (14:04 -0400)
Signed-off-by: Duane Grigsby <duane.grigsby@cavium.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/qla2xxx/qla_isr.c
drivers/scsi/qla2xxx/qla_nvme.c

index 317fe602685629c91e18002205f4d9289923850e..c14fab35fc36a07269733906d1a5dc77b0893e68 100644 (file)
@@ -1856,17 +1856,42 @@ qla24xx_nvme_iocb_entry(scsi_qla_host_t *vha, struct req_que *req, void *tsk)
        fd->transferred_length = fd->payload_length -
            le32_to_cpu(sts->residual_len);
 
+       /*
+        * If transport error then Failure (HBA rejects request)
+        * otherwise transport will handle.
+        */
        if (sts->entry_status) {
                ql_log(ql_log_warn, fcport->vha, 0x5038,
                    "NVME-%s error - hdl=%x entry-status(%x).\n",
                    sp->name, sp->handle, sts->entry_status);
                ret = QLA_FUNCTION_FAILED;
-       } else if (sts->comp_status != cpu_to_le16(CS_COMPLETE)) {
-               ql_log(ql_log_warn, fcport->vha, 0x5039,
-                   "NVME-%s error - hdl=%x completion status(%x) resid=%x  ox_id=%x\n",
-                   sp->name, sp->handle, sts->comp_status,
-                   le32_to_cpu(sts->residual_len), sts->ox_id);
-               ret = QLA_FUNCTION_FAILED;
+       } else  {
+               switch (le16_to_cpu(sts->comp_status)) {
+                       case CS_COMPLETE:
+                               ret = 0;
+                       break;
+
+                       case CS_ABORTED:
+                       case CS_RESET:
+                       case CS_PORT_UNAVAILABLE:
+                       case CS_PORT_LOGGED_OUT:
+                       case CS_PORT_BUSY:
+                               ql_log(ql_log_warn, fcport->vha, 0x5060,
+                               "NVME-%s ERR Handling - hdl=%x completion status(%x) resid=%x  ox_id=%x\n",
+                               sp->name, sp->handle, sts->comp_status,
+                               le32_to_cpu(sts->residual_len), sts->ox_id);
+                               fd->transferred_length = fd->payload_length;
+                               ret = QLA_ABORTED;
+                       break;
+
+                       default:
+                               ql_log(ql_log_warn, fcport->vha, 0x5060,
+                               "NVME-%s error - hdl=%x completion status(%x) resid=%x  ox_id=%x\n",
+                               sp->name, sp->handle, sts->comp_status,
+                               le32_to_cpu(sts->residual_len), sts->ox_id);
+                               ret = QLA_FUNCTION_FAILED;
+                               break;
+               }
        }
        sp->done(sp, ret);
 }
index 6c5eebbbda4c3330c92013049a4a8fa4c9f27b71..97a7b222b5495443ee1a5f675aa2840e814df767 100644 (file)
@@ -169,8 +169,8 @@ static void qla_nvme_sp_done(void *ptr, int res)
        if (!(sp->fcport->nvme_flag & NVME_FLAG_REGISTERED))
                goto rel;
 
-       if (unlikely(nvme->u.nvme.comp_status || res))
-               fd->status = -EINVAL;
+       if (unlikely(res == QLA_FUNCTION_FAILED))
+               fd->status = NVME_SC_FC_TRANSPORT_ERROR;
        else
                fd->status = 0;
 
@@ -635,13 +635,18 @@ static void qla_nvme_unregister_remote_port(struct work_struct *work)
        if (!IS_ENABLED(CONFIG_NVME_FC))
                return;
 
+       ql_log(ql_log_warn, NULL, 0x2112,
+           "%s: unregister remoteport on %p\n",__func__, fcport);
+
        list_for_each_entry_safe(rport, trport,
            &fcport->vha->nvme_rport_list, list) {
                if (rport->fcport == fcport) {
                        ql_log(ql_log_info, fcport->vha, 0x2113,
                            "%s: fcport=%p\n", __func__, fcport);
+                       init_completion(&fcport->nvme_del_done);
                        nvme_fc_unregister_remoteport(
                            fcport->nvme_remote_port);
+                       qla_nvme_wait_on_rport_del(fcport);
                }
        }
 }