* [PATCH 0/2] mpi3mr: Add shost & device sysfs attributes
@ 2022-05-12 14:00 Sreekanth Reddy
2022-05-12 14:00 ` [PATCH 1/2] mpi3mr: Add shost related " Sreekanth Reddy
2022-05-12 14:00 ` [PATCH 2/2] mpi3mr: Add target device " Sreekanth Reddy
0 siblings, 2 replies; 6+ messages in thread
From: Sreekanth Reddy @ 2022-05-12 14:00 UTC (permalink / raw)
To: linux-scsi; +Cc: martin.petersen, Sreekanth Reddy
[-- Attachment #1: Type: text/plain, Size: 372 bytes --]
Added shost & device related sysfs attributes
Sreekanth Reddy (2):
mpi3mr: Add shost related sysfs attributes
mpi3mr: Add target device related sysfs attributes
drivers/scsi/mpi3mr/mpi3mr.h | 1 +
drivers/scsi/mpi3mr/mpi3mr_app.c | 259 +++++++++++++++++++++++++++++++
drivers/scsi/mpi3mr/mpi3mr_os.c | 1 +
3 files changed, 261 insertions(+)
--
2.27.0
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4218 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] mpi3mr: Add shost related sysfs attributes
2022-05-12 14:00 [PATCH 0/2] mpi3mr: Add shost & device sysfs attributes Sreekanth Reddy
@ 2022-05-12 14:00 ` Sreekanth Reddy
2022-05-12 23:36 ` Himanshu Madhani
2022-05-17 1:55 ` Martin K. Petersen
2022-05-12 14:00 ` [PATCH 2/2] mpi3mr: Add target device " Sreekanth Reddy
1 sibling, 2 replies; 6+ messages in thread
From: Sreekanth Reddy @ 2022-05-12 14:00 UTC (permalink / raw)
To: linux-scsi; +Cc: martin.petersen, Sreekanth Reddy
[-- Attachment #1: Type: text/plain, Size: 4810 bytes --]
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
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4218 bytes --]
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] mpi3mr: Add target device related sysfs attributes
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 14:00 ` Sreekanth Reddy
2022-05-12 23:36 ` Himanshu Madhani
1 sibling, 1 reply; 6+ messages in thread
From: Sreekanth Reddy @ 2022-05-12 14:00 UTC (permalink / raw)
To: linux-scsi; +Cc: martin.petersen, Sreekanth Reddy
[-- Attachment #1: Type: text/plain, Size: 4787 bytes --]
Added sysfs attributes for exposing target device details
such as SAS address, firmware device handle and persistent ID
for the controller attached devices and RAID volumes.
Signed-off-by: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
---
drivers/scsi/mpi3mr/mpi3mr.h | 1 +
drivers/scsi/mpi3mr/mpi3mr_app.c | 120 +++++++++++++++++++++++++++++++
drivers/scsi/mpi3mr/mpi3mr_os.c | 1 +
3 files changed, 122 insertions(+)
diff --git a/drivers/scsi/mpi3mr/mpi3mr.h b/drivers/scsi/mpi3mr/mpi3mr.h
index 584659e..01cd017 100644
--- a/drivers/scsi/mpi3mr/mpi3mr.h
+++ b/drivers/scsi/mpi3mr/mpi3mr.h
@@ -1085,4 +1085,5 @@ int mpi3mr_pel_get_seqnum_post(struct mpi3mr_ioc *mrioc,
void mpi3mr_app_save_logdata(struct mpi3mr_ioc *mrioc, char *event_data,
u16 event_data_size);
extern const struct attribute_group *mpi3mr_host_groups[];
+extern const struct attribute_group *mpi3mr_dev_groups[];
#endif /*MPI3MR_H_INCLUDED*/
diff --git a/drivers/scsi/mpi3mr/mpi3mr_app.c b/drivers/scsi/mpi3mr/mpi3mr_app.c
index c9b153c..69054a8 100644
--- a/drivers/scsi/mpi3mr/mpi3mr_app.c
+++ b/drivers/scsi/mpi3mr/mpi3mr_app.c
@@ -1742,3 +1742,123 @@ const struct attribute_group *mpi3mr_host_groups[] = {
&mpi3mr_host_attr_group,
NULL,
};
+
+
+/*
+ * SCSI Device attributes under sysfs
+ */
+
+/**
+ * sas_address_show - SysFS callback for dev SASaddress display
+ * @dev: class device
+ * @attr: Device attributes
+ * @buf: Buffer to copy
+ *
+ * Return: snprintf() return after copying SAS address of the
+ * specific SAS/SATA end device.
+ */
+static ssize_t
+sas_address_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
+{
+ struct scsi_device *sdev = to_scsi_device(dev);
+ struct mpi3mr_sdev_priv_data *sdev_priv_data;
+ struct mpi3mr_stgt_priv_data *tgt_priv_data;
+ struct mpi3mr_tgt_dev *tgtdev;
+
+ sdev_priv_data = sdev->hostdata;
+ if (!sdev_priv_data)
+ return 0;
+
+ tgt_priv_data = sdev_priv_data->tgt_priv_data;
+ if (!tgt_priv_data)
+ return 0;
+ tgtdev = tgt_priv_data->tgt_dev;
+ if (!tgtdev || tgtdev->dev_type != MPI3_DEVICE_DEVFORM_SAS_SATA)
+ return 0;
+ return snprintf(buf, PAGE_SIZE, "0x%016llx\n",
+ (unsigned long long)tgtdev->dev_spec.sas_sata_inf.sas_address);
+}
+
+static DEVICE_ATTR_RO(sas_address);
+
+/**
+ * device_handle_show - SysFS callback for device handle display
+ * @dev: class device
+ * @attr: Device attributes
+ * @buf: Buffer to copy
+ *
+ * Return: snprintf() return after copying firmware internal
+ * device handle of the specific device.
+ */
+static ssize_t
+device_handle_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
+{
+ struct scsi_device *sdev = to_scsi_device(dev);
+ struct mpi3mr_sdev_priv_data *sdev_priv_data;
+ struct mpi3mr_stgt_priv_data *tgt_priv_data;
+ struct mpi3mr_tgt_dev *tgtdev;
+
+ sdev_priv_data = sdev->hostdata;
+ if (!sdev_priv_data)
+ return 0;
+
+ tgt_priv_data = sdev_priv_data->tgt_priv_data;
+ if (!tgt_priv_data)
+ return 0;
+ tgtdev = tgt_priv_data->tgt_dev;
+ if (!tgtdev)
+ return 0;
+ return snprintf(buf, PAGE_SIZE, "0x%04x\n", tgtdev->dev_handle);
+}
+
+static DEVICE_ATTR_RO(device_handle);
+
+/**
+ * persistent_id_show - SysFS callback for persisten ID display
+ * @dev: class device
+ * @attr: Device attributes
+ * @buf: Buffer to copy
+ *
+ * Return: snprintf() return after copying persistent ID of the
+ * of the specific device.
+ */
+static ssize_t
+persistent_id_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
+{
+ struct scsi_device *sdev = to_scsi_device(dev);
+ struct mpi3mr_sdev_priv_data *sdev_priv_data;
+ struct mpi3mr_stgt_priv_data *tgt_priv_data;
+ struct mpi3mr_tgt_dev *tgtdev;
+
+ sdev_priv_data = sdev->hostdata;
+ if (!sdev_priv_data)
+ return 0;
+
+ tgt_priv_data = sdev_priv_data->tgt_priv_data;
+ if (!tgt_priv_data)
+ return 0;
+ tgtdev = tgt_priv_data->tgt_dev;
+ if (!tgtdev)
+ return 0;
+ return snprintf(buf, PAGE_SIZE, "%d\n", tgtdev->perst_id);
+}
+static DEVICE_ATTR_RO(persistent_id);
+
+static struct attribute *mpi3mr_dev_attrs[] = {
+ &dev_attr_sas_address.attr,
+ &dev_attr_device_handle.attr,
+ &dev_attr_persistent_id.attr,
+ NULL,
+};
+
+static const struct attribute_group mpi3mr_dev_attr_group = {
+ .attrs = mpi3mr_dev_attrs
+};
+
+const struct attribute_group *mpi3mr_dev_groups[] = {
+ &mpi3mr_dev_attr_group,
+ NULL,
+};
diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c
index f5c345d..d8c195b 100644
--- a/drivers/scsi/mpi3mr/mpi3mr_os.c
+++ b/drivers/scsi/mpi3mr/mpi3mr_os.c
@@ -4147,6 +4147,7 @@ static struct scsi_host_template mpi3mr_driver_template = {
.track_queue_depth = 1,
.cmd_size = sizeof(struct scmd_priv),
.shost_groups = mpi3mr_host_groups,
+ .sdev_groups = mpi3mr_dev_groups,
};
/**
--
2.27.0
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4218 bytes --]
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] mpi3mr: Add target device related sysfs attributes
2022-05-12 14:00 ` [PATCH 2/2] mpi3mr: Add target device " Sreekanth Reddy
@ 2022-05-12 23:36 ` Himanshu Madhani
0 siblings, 0 replies; 6+ messages in thread
From: Himanshu Madhani @ 2022-05-12 23:36 UTC (permalink / raw)
To: Sreekanth Reddy; +Cc: linux-scsi, Martin Petersen
> On May 12, 2022, at 7:00 AM, Sreekanth Reddy <sreekanth.reddy@broadcom.com> wrote:
>
> Added sysfs attributes for exposing target device details
> such as SAS address, firmware device handle and persistent ID
> for the controller attached devices and RAID volumes.
>
> Signed-off-by: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
> ---
> drivers/scsi/mpi3mr/mpi3mr.h | 1 +
> drivers/scsi/mpi3mr/mpi3mr_app.c | 120 +++++++++++++++++++++++++++++++
> drivers/scsi/mpi3mr/mpi3mr_os.c | 1 +
> 3 files changed, 122 insertions(+)
>
> diff --git a/drivers/scsi/mpi3mr/mpi3mr.h b/drivers/scsi/mpi3mr/mpi3mr.h
> index 584659e..01cd017 100644
> --- a/drivers/scsi/mpi3mr/mpi3mr.h
> +++ b/drivers/scsi/mpi3mr/mpi3mr.h
> @@ -1085,4 +1085,5 @@ int mpi3mr_pel_get_seqnum_post(struct mpi3mr_ioc *mrioc,
> void mpi3mr_app_save_logdata(struct mpi3mr_ioc *mrioc, char *event_data,
> u16 event_data_size);
> extern const struct attribute_group *mpi3mr_host_groups[];
> +extern const struct attribute_group *mpi3mr_dev_groups[];
> #endif /*MPI3MR_H_INCLUDED*/
> diff --git a/drivers/scsi/mpi3mr/mpi3mr_app.c b/drivers/scsi/mpi3mr/mpi3mr_app.c
> index c9b153c..69054a8 100644
> --- a/drivers/scsi/mpi3mr/mpi3mr_app.c
> +++ b/drivers/scsi/mpi3mr/mpi3mr_app.c
> @@ -1742,3 +1742,123 @@ const struct attribute_group *mpi3mr_host_groups[] = {
> &mpi3mr_host_attr_group,
> NULL,
> };
> +
> +
> +/*
> + * SCSI Device attributes under sysfs
> + */
> +
> +/**
> + * sas_address_show - SysFS callback for dev SASaddress display
> + * @dev: class device
> + * @attr: Device attributes
> + * @buf: Buffer to copy
> + *
> + * Return: snprintf() return after copying SAS address of the
> + * specific SAS/SATA end device.
> + */
> +static ssize_t
> +sas_address_show(struct device *dev, struct device_attribute *attr,
> + char *buf)
> +{
> + struct scsi_device *sdev = to_scsi_device(dev);
> + struct mpi3mr_sdev_priv_data *sdev_priv_data;
> + struct mpi3mr_stgt_priv_data *tgt_priv_data;
> + struct mpi3mr_tgt_dev *tgtdev;
> +
> + sdev_priv_data = sdev->hostdata;
> + if (!sdev_priv_data)
> + return 0;
> +
> + tgt_priv_data = sdev_priv_data->tgt_priv_data;
> + if (!tgt_priv_data)
> + return 0;
> + tgtdev = tgt_priv_data->tgt_dev;
> + if (!tgtdev || tgtdev->dev_type != MPI3_DEVICE_DEVFORM_SAS_SATA)
> + return 0;
> + return snprintf(buf, PAGE_SIZE, "0x%016llx\n",
> + (unsigned long long)tgtdev->dev_spec.sas_sata_inf.sas_address);
> +}
> +
> +static DEVICE_ATTR_RO(sas_address);
> +
> +/**
> + * device_handle_show - SysFS callback for device handle display
> + * @dev: class device
> + * @attr: Device attributes
> + * @buf: Buffer to copy
> + *
> + * Return: snprintf() return after copying firmware internal
> + * device handle of the specific device.
> + */
> +static ssize_t
> +device_handle_show(struct device *dev, struct device_attribute *attr,
> + char *buf)
> +{
> + struct scsi_device *sdev = to_scsi_device(dev);
> + struct mpi3mr_sdev_priv_data *sdev_priv_data;
> + struct mpi3mr_stgt_priv_data *tgt_priv_data;
> + struct mpi3mr_tgt_dev *tgtdev;
> +
> + sdev_priv_data = sdev->hostdata;
> + if (!sdev_priv_data)
> + return 0;
> +
> + tgt_priv_data = sdev_priv_data->tgt_priv_data;
> + if (!tgt_priv_data)
> + return 0;
> + tgtdev = tgt_priv_data->tgt_dev;
> + if (!tgtdev)
> + return 0;
> + return snprintf(buf, PAGE_SIZE, "0x%04x\n", tgtdev->dev_handle);
> +}
> +
> +static DEVICE_ATTR_RO(device_handle);
> +
> +/**
> + * persistent_id_show - SysFS callback for persisten ID display
> + * @dev: class device
> + * @attr: Device attributes
> + * @buf: Buffer to copy
> + *
> + * Return: snprintf() return after copying persistent ID of the
> + * of the specific device.
> + */
> +static ssize_t
> +persistent_id_show(struct device *dev, struct device_attribute *attr,
> + char *buf)
> +{
> + struct scsi_device *sdev = to_scsi_device(dev);
> + struct mpi3mr_sdev_priv_data *sdev_priv_data;
> + struct mpi3mr_stgt_priv_data *tgt_priv_data;
> + struct mpi3mr_tgt_dev *tgtdev;
> +
> + sdev_priv_data = sdev->hostdata;
> + if (!sdev_priv_data)
> + return 0;
> +
> + tgt_priv_data = sdev_priv_data->tgt_priv_data;
> + if (!tgt_priv_data)
> + return 0;
> + tgtdev = tgt_priv_data->tgt_dev;
> + if (!tgtdev)
> + return 0;
> + return snprintf(buf, PAGE_SIZE, "%d\n", tgtdev->perst_id);
> +}
> +static DEVICE_ATTR_RO(persistent_id);
> +
> +static struct attribute *mpi3mr_dev_attrs[] = {
> + &dev_attr_sas_address.attr,
> + &dev_attr_device_handle.attr,
> + &dev_attr_persistent_id.attr,
> + NULL,
> +};
> +
> +static const struct attribute_group mpi3mr_dev_attr_group = {
> + .attrs = mpi3mr_dev_attrs
> +};
> +
> +const struct attribute_group *mpi3mr_dev_groups[] = {
> + &mpi3mr_dev_attr_group,
> + NULL,
> +};
> diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c
> index f5c345d..d8c195b 100644
> --- a/drivers/scsi/mpi3mr/mpi3mr_os.c
> +++ b/drivers/scsi/mpi3mr/mpi3mr_os.c
> @@ -4147,6 +4147,7 @@ static struct scsi_host_template mpi3mr_driver_template = {
> .track_queue_depth = 1,
> .cmd_size = sizeof(struct scmd_priv),
> .shost_groups = mpi3mr_host_groups,
> + .sdev_groups = mpi3mr_dev_groups,
> };
>
> /**
> --
> 2.27.0
>
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
--
Himanshu Madhani Oracle Linux Engineering
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] mpi3mr: Add shost related sysfs attributes
2022-05-12 14:00 ` [PATCH 1/2] mpi3mr: Add shost related " Sreekanth Reddy
@ 2022-05-12 23:36 ` Himanshu Madhani
2022-05-17 1:55 ` Martin K. Petersen
1 sibling, 0 replies; 6+ messages in thread
From: Himanshu Madhani @ 2022-05-12 23:36 UTC (permalink / raw)
To: Sreekanth Reddy; +Cc: linux-scsi, Martin Petersen
> 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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] mpi3mr: Add shost related sysfs attributes
2022-05-12 14:00 ` [PATCH 1/2] mpi3mr: Add shost related " Sreekanth Reddy
2022-05-12 23:36 ` Himanshu Madhani
@ 2022-05-17 1:55 ` Martin K. Petersen
1 sibling, 0 replies; 6+ messages in thread
From: Martin K. Petersen @ 2022-05-17 1:55 UTC (permalink / raw)
To: Sreekanth Reddy; +Cc: linux-scsi, martin.petersen
Sreekanth,
> +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);
> +}
Please use sysfs_emit() for new code.
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-05-17 1:55 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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
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.