All of lore.kernel.org
 help / color / mirror / Atom feed
From: Himanshu Madhani <himanshu.madhani@oracle.com>
To: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
Cc: linux-scsi <linux-scsi@vger.kernel.org>,
	Martin Petersen <martin.petersen@oracle.com>
Subject: Re: [PATCH 1/2] mpi3mr: Add shost related sysfs attributes
Date: Thu, 12 May 2022 23:36:38 +0000	[thread overview]
Message-ID: <4348727B-BE3E-430B-B444-C845E2298C89@oracle.com> (raw)
In-Reply-To: <20220512140046.19046-2-sreekanth.reddy@broadcom.com>



> On May 12, 2022, at 7:00 AM, Sreekanth Reddy <sreekanth.reddy@broadcom.com> wrote:
> 
> Added shost related sysfs attributes to get the controller's
> firmware version, controlller's queue depth,
> number of request & reply queues.
> Also added an attribute to set & get the logging_level.
> 
> Signed-off-by: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
> ---
> drivers/scsi/mpi3mr/mpi3mr_app.c | 139 +++++++++++++++++++++++++++++++
> 1 file changed, 139 insertions(+)
> 
> diff --git a/drivers/scsi/mpi3mr/mpi3mr_app.c b/drivers/scsi/mpi3mr/mpi3mr_app.c
> index 73bb799..c9b153c 100644
> --- a/drivers/scsi/mpi3mr/mpi3mr_app.c
> +++ b/drivers/scsi/mpi3mr/mpi3mr_app.c
> @@ -1558,6 +1558,140 @@ err_device_add:
> 	kfree(mrioc->bsg_dev);
> }
> 
> +/**
> + * version_fw_show - SysFS callback for firmware version read
> + * @dev: class device
> + * @attr: Device attributes
> + * @buf: Buffer to copy
> + *
> + * Return: snprintf() return after copying firmware version
> + */
> +static ssize_t
> +version_fw_show(struct device *dev, struct device_attribute *attr,
> +	char *buf)
> +{
> +	struct Scsi_Host *shost = class_to_shost(dev);
> +	struct mpi3mr_ioc *mrioc = shost_priv(shost);
> +	struct mpi3mr_compimg_ver *fwver = &mrioc->facts.fw_ver;
> +
> +	return snprintf(buf, PAGE_SIZE, "%d.%d.%d.%d.%05d-%05d\n",
> +	    fwver->gen_major, fwver->gen_minor, fwver->ph_major,
> +	    fwver->ph_minor, fwver->cust_id, fwver->build_num);
> +}
> +static DEVICE_ATTR_RO(version_fw);
> +
> +/**
> + * fw_queue_depth_show - SysFS callback for firmware max cmds
> + * @dev: class device
> + * @attr: Device attributes
> + * @buf: Buffer to copy
> + *
> + * Return: snprintf() return after copying firmware max commands
> + */
> +static ssize_t
> +fw_queue_depth_show(struct device *dev, struct device_attribute *attr,
> +			char *buf)
> +{
> +	struct Scsi_Host *shost = class_to_shost(dev);
> +	struct mpi3mr_ioc *mrioc = shost_priv(shost);
> +
> +	return snprintf(buf, PAGE_SIZE, "%d\n", mrioc->facts.max_reqs);
> +}
> +static DEVICE_ATTR_RO(fw_queue_depth);
> +
> +/**
> + * op_req_q_count_show - SysFS callback for request queue count
> + * @dev: class device
> + * @attr: Device attributes
> + * @buf: Buffer to copy
> + *
> + * Return: snprintf() return after copying request queue count
> + */
> +static ssize_t
> +op_req_q_count_show(struct device *dev, struct device_attribute *attr,
> +			char *buf)
> +{
> +	struct Scsi_Host *shost = class_to_shost(dev);
> +	struct mpi3mr_ioc *mrioc = shost_priv(shost);
> +
> +	return snprintf(buf, PAGE_SIZE, "%d\n", mrioc->num_op_req_q);
> +}
> +static DEVICE_ATTR_RO(op_req_q_count);
> +
> +/**
> + * reply_queue_count_show - SysFS callback for reply queue count
> + * @dev: class device
> + * @attr: Device attributes
> + * @buf: Buffer to copy
> + *
> + * Return: snprintf() return after copying reply queue count
> + */
> +static ssize_t
> +reply_queue_count_show(struct device *dev, struct device_attribute *attr,
> +			char *buf)
> +{
> +	struct Scsi_Host *shost = class_to_shost(dev);
> +	struct mpi3mr_ioc *mrioc = shost_priv(shost);
> +
> +	return snprintf(buf, PAGE_SIZE, "%d\n", mrioc->num_op_reply_q);
> +}
> +
> +static DEVICE_ATTR_RO(reply_queue_count);
> +
> +/**
> + * logging_level_show - Show controller debug level
> + * @dev: class device
> + * @attr: Device attributes
> + * @buf: Buffer to copy
> + *
> + * A sysfs 'read/write' shost attribute, to show the current
> + * debug log level used by the driver for the specific
> + * controller.
> + *
> + * Return: snprintf() return
> + */
> +static ssize_t
> +logging_level_show(struct device *dev,
> +	struct device_attribute *attr, char *buf)
> +
> +{
> +	struct Scsi_Host *shost = class_to_shost(dev);
> +	struct mpi3mr_ioc *mrioc = shost_priv(shost);
> +
> +	return snprintf(buf, PAGE_SIZE, "%08xh\n", mrioc->logging_level);
> +}
> +
> +/**
> + * logging_level_store- Change controller debug level
> + * @dev: class device
> + * @attr: Device attributes
> + * @buf: Buffer to copy
> + * @count: size of the buffer
> + *
> + * A sysfs 'read/write' shost attribute, to change the current
> + * debug log level used by the driver for the specific
> + * controller.
> + *
> + * Return: strlen() return
> + */
> +static ssize_t
> +logging_level_store(struct device *dev,
> +	struct device_attribute *attr,
> +	const char *buf, size_t count)
> +{
> +	struct Scsi_Host *shost = class_to_shost(dev);
> +	struct mpi3mr_ioc *mrioc = shost_priv(shost);
> +	int val = 0;
> +
> +	if (kstrtoint(buf, 0, &val) != 0)
> +		return -EINVAL;
> +
> +	mrioc->logging_level = val;
> +	ioc_info(mrioc, "logging_level=%08xh\n", mrioc->logging_level);
> +	return strlen(buf);
> +}
> +static DEVICE_ATTR_RW(logging_level);
> +
> /**
>  * adapter_state_show - SysFS callback for adapter state show
>  * @dev: class device
> @@ -1591,6 +1725,11 @@ adp_state_show(struct device *dev, struct device_attribute *attr,
> static DEVICE_ATTR_RO(adp_state);
> 
> static struct attribute *mpi3mr_host_attrs[] = {
> +	&dev_attr_version_fw.attr,
> +	&dev_attr_fw_queue_depth.attr,
> +	&dev_attr_op_req_q_count.attr,
> +	&dev_attr_reply_queue_count.attr,
> +	&dev_attr_logging_level.attr,
> 	&dev_attr_adp_state.attr,
> 	NULL,
> };
> -- 
> 2.27.0
> 

Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>

--
Himanshu Madhani	Oracle Linux Engineering


  reply	other threads:[~2022-05-12 23:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-12 14:00 [PATCH 0/2] mpi3mr: Add shost & device sysfs attributes Sreekanth Reddy
2022-05-12 14:00 ` [PATCH 1/2] mpi3mr: Add shost related " Sreekanth Reddy
2022-05-12 23:36   ` Himanshu Madhani [this message]
2022-05-17  1:55   ` Martin K. Petersen
2022-05-12 14:00 ` [PATCH 2/2] mpi3mr: Add target device " Sreekanth Reddy
2022-05-12 23:36   ` Himanshu Madhani

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=4348727B-BE3E-430B-B444-C845E2298C89@oracle.com \
    --to=himanshu.madhani@oracle.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=sreekanth.reddy@broadcom.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.