@@ -69,6 +69,9 @@ struct lpfc_sli2_slim;
#define LPFC_TGTQ_RAMPUP_PCENT 5 /* Target queue rampup in percentage */
#define LPFC_MIN_TGT_QDEPTH 10
#define LPFC_MAX_TGT_QDEPTH 0xFFFF
+#define LPFC_MIN_LUN_QDEPTH 1
+#define LPFC_DEF_LUN_QDEPTH 30
+#define LPFC_MAX_LUN_QDEPTH 512
#define LPFC_MAX_BUCKET_COUNT 20 /* Maximum no. of buckets for stat data
collection. */
@@ -3870,8 +3870,63 @@ LPFC_VPORT_ATTR_R(enable_da_id, 1, 0, 1,
# lun_queue_depth: This parameter is used to limit the number of outstanding
# commands per FCP LUN. Value range is [1,512]. Default value is 30.
*/
-LPFC_VPORT_ATTR_R(lun_queue_depth, 30, 1, 512,
- "Max number of FCP commands we can queue to a specific LUN");
+static u16 lpfc_lun_queue_depth = LPFC_DEF_LUN_QDEPTH;
+module_param(lpfc_lun_queue_depth, ushort, 0644);
+MODULE_PARM_DESC(lpfc_lun_queue_depth,
+ "Max number of FCP commands we can queue to a specific LUN");
+lpfc_vport_param_show(lun_queue_depth);
+lpfc_vport_param_init(lun_queue_depth, LPFC_DEF_LUN_QDEPTH, LPFC_MIN_LUN_QDEPTH,
+ LPFC_MAX_LUN_QDEPTH);
+
+static ssize_t
+lpfc_lun_queue_depth_store(struct device *dev, struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct Scsi_Host *shost = class_to_shost(dev);
+ struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata;
+ struct lpfc_hba *phba = vport->phba;
+ u16 new_queue_depth;
+ int rc;
+
+ rc = kstrtou16(buf, 0, &new_queue_depth);
+ if (rc) {
+ lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
+ "4385 lpfc_lun_queue_depth: failed to convert "
+ "\"%s\" to u16 (%d)\n",
+ buf, rc);
+ return -EINVAL;
+ }
+
+ /* Check allowed range */
+ if (new_queue_depth < LPFC_MIN_LUN_QDEPTH ||
+ new_queue_depth > LPFC_MAX_LUN_QDEPTH) {
+ lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
+ "4386 lpfc_lun_queue_depth: %d outside of "
+ "allowed range [%u, %u]\n",
+ new_queue_depth, LPFC_MIN_LUN_QDEPTH,
+ LPFC_MAX_LUN_QDEPTH);
+ return -EINVAL;
+ }
+
+ /* Check if previously set same value */
+ if (new_queue_depth == vport->cfg_lun_queue_depth)
+ goto buffer_done;
+
+ /* Store for future calls to slave_configure */
+ vport->cfg_lun_queue_depth = new_queue_depth;
+
+ /* Change all the current LUNs' queue depths */
+ rc = shost_change_max_queue_depths(shost, new_queue_depth);
+ if (rc)
+ lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
+ "4387 lpfc_lun_queue_depth: error setting lun "
+ "max queue depths (%d)\n",
+ rc);
+
+buffer_done:
+ return strlen(buf);
+}
+static DEVICE_ATTR_RW(lpfc_lun_queue_depth);
/*
# tgt_queue_depth: This parameter is used to limit the number of outstanding