Skip to contentSkip to conversation

mpi3mr: Add shost & device sysfs attributes

PATCH Applied Sreekanth Reddy 2 participants 5 messages May 17, 2022 – May 20, 2022

Subsystems (2)
lore
Share & tools
lore

Sreekanth Reddy

author maintainer
#0 lore raw

v2 cover mpi3mr: Add shost & device sysfs attributes

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(-)
Signature · 1 line
2.27.0
author maintainer
#1 lore raw

PATCH v2 1/2 mpi3mr: Add shost related sysfs attributes

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.

---
Changes from v1:
Used sysfs_emit() instead of snprintf() api.

 drivers/scsi/mpi3mr/mpi3mr_app.c | 143 ++++++++++++++++++++++++++++++-
 1 file changed, 141 insertions(+), 2 deletions(-)
drivers/scsi/mpi3mr/mpi3mr_app.c +141 -2
index 8138a72..33bad2f 100644
@@ -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,
 };
Signature · 1 line
2.27.0
author maintainer
#2 lore raw

PATCH v2 2/2 mpi3mr: Add target device related sysfs attributes

In reply to Sreekanth Reddy

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.

---
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(+)
drivers/scsi/mpi3mr/mpi3mr.h +1 -0
index 584659e..01cd017 100644
@@ -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*/
drivers/scsi/mpi3mr/mpi3mr_app.c +120 -0

123 lines not on this page · raw message

drivers/scsi/mpi3mr/mpi3mr_os.c +1 -0
index f5c345d..d8c195b 100644
@@ -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,
 };
 
 /**
Signature · 1 line
2.27.0
#4 lore raw
In reply to Sreekanth Reddy
Quoted 10 lines · Sreekanth Reddy

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
Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering