* [PATCH v2 0/2] mpi3mr: Add shost & device sysfs attributes
@ 2022-05-17 11:53 Sreekanth Reddy
2022-05-17 11:53 ` [PATCH v2 1/2] mpi3mr: Add shost related " Sreekanth Reddy
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Sreekanth Reddy @ 2022-05-17 11:53 UTC (permalink / raw)
To: linux-scsi; +Cc: martin.petersen, Sreekanth Reddy
[-- Attachment #1: Type: text/plain, Size: 451 bytes --]
Added shost & device related sysfs attributes
Changes from v1:
Used sysfs_emit() instead of snprintf() api.
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 | 263 ++++++++++++++++++++++++++++++-
drivers/scsi/mpi3mr/mpi3mr_os.c | 1 +
3 files changed, 263 insertions(+), 2 deletions(-)
--
2.27.0
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4218 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 1/2] mpi3mr: Add shost related sysfs attributes
2022-05-17 11:53 [PATCH v2 0/2] mpi3mr: Add shost & device sysfs attributes Sreekanth Reddy
@ 2022-05-17 11:53 ` Sreekanth Reddy
2022-05-17 11:53 ` [PATCH v2 2/2] mpi3mr: Add target device " Sreekanth Reddy
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Sreekanth Reddy @ 2022-05-17 11:53 UTC (permalink / raw)
To: linux-scsi; +Cc: martin.petersen, Sreekanth Reddy, Himanshu Madhani
[-- Attachment #1: Type: text/plain, Size: 5343 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.
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
---
Changes from v1:
Used sysfs_emit() instead of snprintf() api.
drivers/scsi/mpi3mr/mpi3mr_app.c | 143 ++++++++++++++++++++++++++++++-
1 file changed, 141 insertions(+), 2 deletions(-)
diff --git a/drivers/scsi/mpi3mr/mpi3mr_app.c b/drivers/scsi/mpi3mr/mpi3mr_app.c
index 8138a72..33bad2f 100644
--- a/drivers/scsi/mpi3mr/mpi3mr_app.c
+++ b/drivers/scsi/mpi3mr/mpi3mr_app.c
@@ -1558,13 +1558,147 @@ 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: sysfs_emit() 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 sysfs_emit(buf, "%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: sysfs_emit() 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 sysfs_emit(buf, "%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: sysfs_emit() 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 sysfs_emit(buf, "%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: sysfs_emit() 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 sysfs_emit(buf, "%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: sysfs_emit() 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 sysfs_emit(buf, "%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
* @attr: Device attributes
* @buf: Buffer to copy
*
- * Return: snprintf() return after copying adapter state
+ * Return: sysfs_emit() return after copying adapter state
*/
static ssize_t
adp_state_show(struct device *dev, struct device_attribute *attr,
@@ -1585,12 +1719,17 @@ adp_state_show(struct device *dev, struct device_attribute *attr,
else
adp_state = MPI3MR_BSG_ADPSTATE_OPERATIONAL;
- return snprintf(buf, PAGE_SIZE, "%u\n", adp_state);
+ return sysfs_emit(buf, "%u\n", adp_state);
}
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] 5+ messages in thread
* [PATCH v2 2/2] mpi3mr: Add target device related sysfs attributes
2022-05-17 11:53 [PATCH v2 0/2] mpi3mr: Add shost & device sysfs attributes Sreekanth Reddy
2022-05-17 11:53 ` [PATCH v2 1/2] mpi3mr: Add shost related " Sreekanth Reddy
@ 2022-05-17 11:53 ` Sreekanth Reddy
2022-05-18 1:11 ` [PATCH v2 0/2] mpi3mr: Add shost & device " Martin K. Petersen
2022-05-20 1:09 ` Martin K. Petersen
3 siblings, 0 replies; 5+ messages in thread
From: Sreekanth Reddy @ 2022-05-17 11:53 UTC (permalink / raw)
To: linux-scsi; +Cc: martin.petersen, Sreekanth Reddy, Himanshu Madhani
[-- Attachment #1: Type: text/plain, Size: 4891 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.
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
---
Changes from v1:
Used sysfs_emit() instead of snprintf() api.
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 33bad2f..9ab1762 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: sysfs_emit() 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 sysfs_emit(buf, "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: sysfs_emit() 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 sysfs_emit(buf, "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: sysfs_emit() 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 sysfs_emit(buf, "%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] 5+ messages in thread
* Re: [PATCH v2 0/2] mpi3mr: Add shost & device sysfs attributes
2022-05-17 11:53 [PATCH v2 0/2] mpi3mr: Add shost & device sysfs attributes Sreekanth Reddy
2022-05-17 11:53 ` [PATCH v2 1/2] mpi3mr: Add shost related " Sreekanth Reddy
2022-05-17 11:53 ` [PATCH v2 2/2] mpi3mr: Add target device " Sreekanth Reddy
@ 2022-05-18 1:11 ` Martin K. Petersen
2022-05-20 1:09 ` Martin K. Petersen
3 siblings, 0 replies; 5+ messages in thread
From: Martin K. Petersen @ 2022-05-18 1:11 UTC (permalink / raw)
To: Sreekanth Reddy; +Cc: linux-scsi, martin.petersen
Sreekanth,
> Added shost & device related sysfs attributes
Applied to 5.19/scsi-staging, thanks!
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 0/2] mpi3mr: Add shost & device sysfs attributes
2022-05-17 11:53 [PATCH v2 0/2] mpi3mr: Add shost & device sysfs attributes Sreekanth Reddy
` (2 preceding siblings ...)
2022-05-18 1:11 ` [PATCH v2 0/2] mpi3mr: Add shost & device " Martin K. Petersen
@ 2022-05-20 1:09 ` Martin K. Petersen
3 siblings, 0 replies; 5+ messages in thread
From: Martin K. Petersen @ 2022-05-20 1:09 UTC (permalink / raw)
To: linux-scsi, Sreekanth Reddy; +Cc: Martin K . Petersen
On Tue, 17 May 2022 17:23:08 +0530, Sreekanth Reddy wrote:
> Added shost & device related sysfs attributes
>
> Changes from v1:
> Used sysfs_emit() instead of snprintf() api.
>
> Sreekanth Reddy (2):
> mpi3mr: Add shost related sysfs attributes
> mpi3mr: Add target device related sysfs attributes
>
> [...]
Applied to 5.19/scsi-queue, thanks!
[1/2] mpi3mr: Add shost related sysfs attributes
https://git.kernel.org/mkp/scsi/c/e51e76edddb1
[2/2] mpi3mr: Add target device related sysfs attributes
https://git.kernel.org/mkp/scsi/c/9feb5c4c3f95
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-05-20 1:10 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-17 11:53 [PATCH v2 0/2] mpi3mr: Add shost & device sysfs attributes Sreekanth Reddy
2022-05-17 11:53 ` [PATCH v2 1/2] mpi3mr: Add shost related " Sreekanth Reddy
2022-05-17 11:53 ` [PATCH v2 2/2] mpi3mr: Add target device " Sreekanth Reddy
2022-05-18 1:11 ` [PATCH v2 0/2] mpi3mr: Add shost & device " Martin K. Petersen
2022-05-20 1:09 ` Martin K. Petersen
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.