Message ID | 20220512140046.19046-2-sreekanth.reddy@broadcom.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | mpi3mr: Add shost & device sysfs attributes | expand |
> 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
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.
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, };
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(+)