mpi3mr: Add shost & device sysfs attributes
Subsystems (2)
Sreekanth Reddy
maintainercover mpi3mr: Add shost & device sysfs attributes
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(+)
Signature · 1 line
2.27.0
Sreekanth Reddy
maintainerPATCH 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.
--- drivers/scsi/mpi3mr/mpi3mr_app.c | 139 +++++++++++++++++++++++++++++++ 1 file changed, 139 insertions(+)
drivers/scsi/mpi3mr/mpi3mr_app.c +139 -0
@@ -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 , };
Signature · 1 line
2.27.0
Re: [PATCH 1/2] mpi3mr: Add shost related sysfs attributes
Quoted 174 lines · Sreekanth Reddy
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 thelogging_level.Signed-off-by Sreekanth Reddy <[email protected]>---
drivers/scsi/mpi3mr/mpi3mr_app.c| 139 +++++++++++++++++++++++++++++++1 file changed, 139 insertions(+)drivers/scsi/mpi3mr/mpi3mr_app.c +139
-0@@ -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 , };Signature · 1 line
2.27.0
--
Himanshu Madhani Oracle Linux Engineering
Re: [PATCH 1/2] mpi3mr: Add shost related sysfs attributes
In reply to Sreekanth ReddySreekanth,
drivers/scsi/mpi3mr/mpi3mr_app.c err_device_add: · line 1580
Quoted 12 lines
drivers/scsi/mpi3mr/mpi3mr_app.c +12
-0+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.
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
Sreekanth Reddy
maintainerPATCH 2/2 mpi3mr: Add target device related sysfs attributes
In reply to Sreekanth ReddyAdded 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.
--- 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
@@ -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
@@ -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
Re: [PATCH 2/2] mpi3mr: Add target device related sysfs attributes
Quoted 168 lines · 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.
Signed-off-by Sreekanth Reddy <[email protected]>---
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@@ -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@@ -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 , +};drivers/scsi/mpi3mr/mpi3mr_os.c +1
-0@@ -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
--
Himanshu Madhani Oracle Linux Engineering