[SCSI] libfc: add queue_depth ramp up
[firefly-linux-kernel-4.4.55.git] / drivers / scsi / libfc / fc_fcp.c
index a67f53a5026c9fe1eba9cd958c85b236d46370b3..479af9352a4279ba59380f62b9fb6b02eaa3e4a8 100644 (file)
@@ -1815,21 +1815,6 @@ static void fc_io_compl(struct fc_fcp_pkt *fsp)
                        sc_cmd->result = DID_OK << 16;
                        if (fsp->scsi_resid)
                                CMD_RESID_LEN(sc_cmd) = fsp->scsi_resid;
-               } else if (fsp->cdb_status == QUEUE_FULL) {
-                       struct scsi_device *tmp_sdev;
-                       struct scsi_device *sdev = sc_cmd->device;
-
-                       shost_for_each_device(tmp_sdev, sdev->host) {
-                               if (tmp_sdev->id != sdev->id)
-                                       continue;
-
-                               if (tmp_sdev->queue_depth > 1) {
-                                       scsi_track_queue_full(tmp_sdev,
-                                                             tmp_sdev->
-                                                             queue_depth - 1);
-                               }
-                       }
-                       sc_cmd->result = (DID_OK << 16) | fsp->cdb_status;
                } else {
                        /*
                         * transport level I/O was ok but scsi
@@ -2048,25 +2033,35 @@ EXPORT_SYMBOL(fc_eh_host_reset);
 int fc_slave_alloc(struct scsi_device *sdev)
 {
        struct fc_rport *rport = starget_to_rport(scsi_target(sdev));
-       int queue_depth;
 
        if (!rport || fc_remote_port_chkready(rport))
                return -ENXIO;
 
-       if (sdev->tagged_supported) {
-               if (sdev->host->hostt->cmd_per_lun)
-                       queue_depth = sdev->host->hostt->cmd_per_lun;
-               else
-                       queue_depth = FC_FCP_DFLT_QUEUE_DEPTH;
-               scsi_activate_tcq(sdev, queue_depth);
-       }
+       if (sdev->tagged_supported)
+               scsi_activate_tcq(sdev, FC_FCP_DFLT_QUEUE_DEPTH);
+       else
+               scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev),
+                                       FC_FCP_DFLT_QUEUE_DEPTH);
+
        return 0;
 }
 EXPORT_SYMBOL(fc_slave_alloc);
 
-int fc_change_queue_depth(struct scsi_device *sdev, int qdepth)
+int fc_change_queue_depth(struct scsi_device *sdev, int qdepth, int reason)
 {
-       scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), qdepth);
+       switch (reason) {
+       case SCSI_QDEPTH_DEFAULT:
+               scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), qdepth);
+               break;
+       case SCSI_QDEPTH_QFULL:
+               scsi_track_queue_full(sdev, qdepth);
+               break;
+       case SCSI_QDEPTH_RAMP_UP:
+               scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), qdepth);
+               break;
+       default:
+               return -EOPNOTSUPP;
+       }
        return sdev->queue_depth;
 }
 EXPORT_SYMBOL(fc_change_queue_depth);