[SCSI] qla2xxx: Add loopback IDC-TIME-EXTEND aen handling support.
authorSantosh Vernekar <santosh.vernekar@qlogic.com>
Tue, 27 Aug 2013 05:37:48 +0000 (01:37 -0400)
committerJames Bottomley <JBottomley@Parallels.com>
Tue, 3 Sep 2013 14:28:06 +0000 (07:28 -0700)
Earlier IDC-TIME-EXTEND aen was a nop and ignored by driver.
We now have to handle the aen so that other protocol drivers can use time
extension during some loopback operations.

Signed-off-by: Santosh Vernekar <santosh.vernekar@qlogic.com>
Signed-off-by: Saurav Kashyap <saurav.kashyap@qlogic.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
drivers/scsi/qla2xxx/qla_bsg.c
drivers/scsi/qla2xxx/qla_dbg.c
drivers/scsi/qla2xxx/qla_def.h
drivers/scsi/qla2xxx/qla_isr.c

index fb5bd6e17e8a620d631eefb7f2a2b7cec15c77ae..b989add77ec3977f6c379f28ddb3d89be757bcc9 100644 (file)
@@ -627,6 +627,7 @@ qla81xx_set_loopback_mode(scsi_qla_host_t *vha, uint16_t *config,
 {
        int ret = 0;
        int rval = 0;
+       unsigned long rem_tmo = 0, current_tmo = 0;
        struct qla_hw_data *ha = vha->hw;
 
        if (!IS_QLA81XX(ha) && !IS_QLA8031(ha) && !IS_QLA8044(ha))
@@ -652,8 +653,19 @@ qla81xx_set_loopback_mode(scsi_qla_host_t *vha, uint16_t *config,
        }
 
        /* Wait for DCBX complete event */
-       if (!wait_for_completion_timeout(&ha->dcbx_comp,
-           (DCBX_COMP_TIMEOUT * HZ))) {
+       current_tmo = DCBX_COMP_TIMEOUT * HZ;
+       while (1) {
+               rem_tmo = wait_for_completion_timeout(&ha->dcbx_comp,
+                   current_tmo);
+               if (!ha->idc_extend_tmo || rem_tmo) {
+                       ha->idc_extend_tmo = 0;
+                       break;
+               }
+               current_tmo = ha->idc_extend_tmo * HZ;
+               ha->idc_extend_tmo = 0;
+       }
+
+       if (!rem_tmo) {
                ql_dbg(ql_dbg_user, vha, 0x7022,
                    "DCBX completion not received.\n");
                ret = qla81xx_reset_loopback_mode(vha, new_config, 0, 0);
@@ -678,6 +690,7 @@ qla81xx_set_loopback_mode(scsi_qla_host_t *vha, uint16_t *config,
        }
 
        ha->notify_dcbx_comp = 0;
+       ha->idc_extend_tmo = 0;
 
 done_set_internal:
        return rval;
index ca6bcf6e721dd3088b6a219c476e552de8f22bcd..f192c52a82a9c377de984f5788baaa691c1b6f59 100644 (file)
@@ -26,7 +26,7 @@
  * |                              |                    | 0x3036,0x3038  |
  * |                              |                    | 0x303a                |
  * | DPC Thread                   |       0x4022       | 0x4002,0x4013  |
- * | Async Events                 |       0x5086       | 0x502b-0x502f  |
+ * | Async Events                 |       0x5087       | 0x502b-0x502f  |
  * |                              |                    | 0x5047,0x5052  |
  * |                              |                    | 0x5040,0x5075  |
  * |                              |                    | 0x503d,0x5044  |
index d6eefb872bf69660f4b045ed4eca4c3357069090..93db74ef346117a1fc419b3f836948cfa8056150 100644 (file)
@@ -3292,6 +3292,7 @@ struct qla_hw_data {
 
        /* QLA83XX IDC specific fields */
        uint32_t        idc_audit_ts;
+       uint32_t        idc_extend_tmo;
 
        /* DPC low-priority workqueue */
        struct workqueue_struct *dpc_lp_wq;
index bbc24d3afc5baa208491de0c363a126535361f42..df1b30ba938cc0578d409880711d2afa5b2a8898 100644 (file)
@@ -282,25 +282,38 @@ qla81xx_idc_event(scsi_qla_host_t *vha, uint16_t aen, uint16_t descr)
            "%04x %04x %04x %04x %04x %04x %04x.\n",
            event[aen & 0xff], mb[0], mb[1], mb[2], mb[3],
            mb[4], mb[5], mb[6]);
-       if ((aen == MBA_IDC_COMPLETE && mb[1] >> 15)) {
-               vha->hw->flags.idc_compl_status = 1;
-               if (vha->hw->notify_dcbx_comp)
-                       complete(&vha->hw->dcbx_comp);
-       }
-
-       /* Acknowledgement needed? [Notify && non-zero timeout]. */
-       timeout = (descr >> 8) & 0xf;
-       if (aen != MBA_IDC_NOTIFY || !timeout)
-               return;
+       switch (aen) {
+       /* Handle IDC Error completion case. */
+       case MBA_IDC_COMPLETE:
+               if (mb[1] >> 15) {
+                       vha->hw->flags.idc_compl_status = 1;
+                       if (vha->hw->notify_dcbx_comp)
+                               complete(&vha->hw->dcbx_comp);
+               }
+               break;
 
-       ql_dbg(ql_dbg_async, vha, 0x5022,
-           "%lu Inter-Driver Communication %s -- ACK timeout=%d.\n",
-           vha->host_no, event[aen & 0xff], timeout);
+       case MBA_IDC_NOTIFY:
+               /* Acknowledgement needed? [Notify && non-zero timeout]. */
+               timeout = (descr >> 8) & 0xf;
+               ql_dbg(ql_dbg_async, vha, 0x5022,
+                   "%lu Inter-Driver Communication %s -- ACK timeout=%d.\n",
+                   vha->host_no, event[aen & 0xff], timeout);
 
-       rval = qla2x00_post_idc_ack_work(vha, mb);
-       if (rval != QLA_SUCCESS)
-               ql_log(ql_log_warn, vha, 0x5023,
-                   "IDC failed to post ACK.\n");
+               if (!timeout)
+                       return;
+               rval = qla2x00_post_idc_ack_work(vha, mb);
+               if (rval != QLA_SUCCESS)
+                       ql_log(ql_log_warn, vha, 0x5023,
+                           "IDC failed to post ACK.\n");
+               break;
+       case MBA_IDC_TIME_EXT:
+               vha->hw->idc_extend_tmo = descr;
+               ql_dbg(ql_dbg_async, vha, 0x5087,
+                   "%lu Inter-Driver Communication %s -- "
+                   "Extend timeout by=%d.\n",
+                   vha->host_no, event[aen & 0xff], vha->hw->idc_extend_tmo);
+               break;
+       }
 }
 
 #define LS_UNKNOWN     2