From: James Smart <jsmart2021@gmail.com>
To: linux-scsi@vger.kernel.org
Cc: James Smart <jsmart2021@gmail.com>,
Dick Kennedy <dick.kennedy@broadcom.com>
Subject: [PATCH 10/12] lpfc: Change lpfc_lun_queue_depth attribute to writable
Date: Mon, 27 Jan 2020 16:23:10 -0800 [thread overview]
Message-ID: <20200128002312.16346-11-jsmart2021@gmail.com> (raw)
In-Reply-To: <20200128002312.16346-1-jsmart2021@gmail.com>
Change the lpfc_lun_queue_depth attribute to be writable. When written,
will change the driver's value and calls the new scsi service routine
shost_change_max_queue_depths() to set the maximum and queue depth of
the luns on the shost to the new value.
Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
---
This patch is dependent upon this series, which adds the new
scsi service routine shost_change_max_queue_depths():
https://www.spinics.net/lists/linux-scsi/msg137981.html
---
drivers/scsi/lpfc/lpfc.h | 3 +++
drivers/scsi/lpfc/lpfc_attr.c | 59 +++++++++++++++++++++++++++++++++++++++++--
2 files changed, 60 insertions(+), 2 deletions(-)
diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
index cebbad1b3e55..d26ae94e6f1e 100644
--- a/drivers/scsi/lpfc/lpfc.h
+++ b/drivers/scsi/lpfc/lpfc.h
@@ -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. */
diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c
index 48b6c98ec922..127484061f18 100644
--- a/drivers/scsi/lpfc/lpfc_attr.c
+++ b/drivers/scsi/lpfc/lpfc_attr.c
@@ -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
--
2.13.7
next prev parent reply other threads:[~2020-01-28 0:23 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-28 0:23 [PATCH 00/12] lpfc: Update lpfc to revision 12.6.0.4 James Smart
2020-01-28 0:23 ` [PATCH 01/12] lpfc: Fix RQ buffer leakage when no IOCBs available James Smart
2020-01-28 0:23 ` [PATCH 02/12] lpfc: Fix lpfc_io_buf resource leak in lpfc_get_scsi_buf_s4 error path James Smart
2020-01-28 0:23 ` [PATCH 03/12] lpfc: Fix broken Credit Recovery after driver load James Smart
2020-05-12 21:28 ` Chris Hofstaedtler
2020-05-12 23:59 ` James Smart
2020-05-13 7:47 ` Chris Hofstaedtler | Deduktiva
2020-05-13 10:25 ` Chris Hofstaedtler | Deduktiva
2020-01-28 0:23 ` [PATCH 04/12] lpfc: Fix registration of ELS type support in fdmi James Smart
2020-01-28 0:23 ` [PATCH 05/12] lpfc: Fix release of hwq to clear the eq relationship James Smart
2020-01-28 0:23 ` [PATCH 06/12] lpfc: Fix compiler warning on frame size James Smart
2020-01-28 0:23 ` [PATCH 07/12] lpfc: Fix coverity errors in fmdi attribute handling James Smart
2020-01-28 0:23 ` [PATCH 08/12] lpfc: Remove handler for obsolete ELS - Read Port Status (RPS) James Smart
2020-01-28 0:23 ` [PATCH 09/12] lpfc: Clean up hba max_lun_queue_depth checks James Smart
2020-01-28 0:23 ` James Smart [this message]
2020-01-28 0:23 ` [PATCH 11/12] lpfc: Update lpfc version to 12.6.0.4 James Smart
2020-01-28 0:23 ` [PATCH 12/12] lpfc: Copyright updates for 12.6.0.4 patches James Smart
2020-02-05 3:00 ` [PATCH 00/12] lpfc: Update lpfc to revision 12.6.0.4 Martin K. Petersen
2020-02-05 19:01 ` James Smart
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200128002312.16346-11-jsmart2021@gmail.com \
--to=jsmart2021@gmail.com \
--cc=dick.kennedy@broadcom.com \
--cc=linux-scsi@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox