Skip to content

Commit e51e76e

Browse files
sreekanthbrcmmartinkpetersen
authored andcommitted
scsi: mpi3mr: Add shost related sysfs attributes
Add shost related sysfs attributes to display the controller's firmware version, queue depth, number of requests, and number of reply queues. Also add an attribute to set & get the logging_level. Link: https://lore.kernel.org/r/20220517115310.13062-2-sreekanth.reddy@broadcom.com Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com> Signed-off-by: Sreekanth Reddy <sreekanth.reddy@broadcom.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent e79aaa9 commit e51e76e

File tree

1 file changed

+141
-2
lines changed

1 file changed

+141
-2
lines changed

drivers/scsi/mpi3mr/mpi3mr_app.c

Lines changed: 141 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1558,13 +1558,147 @@ void mpi3mr_bsg_init(struct mpi3mr_ioc *mrioc)
15581558
kfree(mrioc->bsg_dev);
15591559
}
15601560

1561+
/**
1562+
* version_fw_show - SysFS callback for firmware version read
1563+
* @dev: class device
1564+
* @attr: Device attributes
1565+
* @buf: Buffer to copy
1566+
*
1567+
* Return: sysfs_emit() return after copying firmware version
1568+
*/
1569+
static ssize_t
1570+
version_fw_show(struct device *dev, struct device_attribute *attr,
1571+
char *buf)
1572+
{
1573+
struct Scsi_Host *shost = class_to_shost(dev);
1574+
struct mpi3mr_ioc *mrioc = shost_priv(shost);
1575+
struct mpi3mr_compimg_ver *fwver = &mrioc->facts.fw_ver;
1576+
1577+
return sysfs_emit(buf, "%d.%d.%d.%d.%05d-%05d\n",
1578+
fwver->gen_major, fwver->gen_minor, fwver->ph_major,
1579+
fwver->ph_minor, fwver->cust_id, fwver->build_num);
1580+
}
1581+
static DEVICE_ATTR_RO(version_fw);
1582+
1583+
/**
1584+
* fw_queue_depth_show - SysFS callback for firmware max cmds
1585+
* @dev: class device
1586+
* @attr: Device attributes
1587+
* @buf: Buffer to copy
1588+
*
1589+
* Return: sysfs_emit() return after copying firmware max commands
1590+
*/
1591+
static ssize_t
1592+
fw_queue_depth_show(struct device *dev, struct device_attribute *attr,
1593+
char *buf)
1594+
{
1595+
struct Scsi_Host *shost = class_to_shost(dev);
1596+
struct mpi3mr_ioc *mrioc = shost_priv(shost);
1597+
1598+
return sysfs_emit(buf, "%d\n", mrioc->facts.max_reqs);
1599+
}
1600+
static DEVICE_ATTR_RO(fw_queue_depth);
1601+
1602+
/**
1603+
* op_req_q_count_show - SysFS callback for request queue count
1604+
* @dev: class device
1605+
* @attr: Device attributes
1606+
* @buf: Buffer to copy
1607+
*
1608+
* Return: sysfs_emit() return after copying request queue count
1609+
*/
1610+
static ssize_t
1611+
op_req_q_count_show(struct device *dev, struct device_attribute *attr,
1612+
char *buf)
1613+
{
1614+
struct Scsi_Host *shost = class_to_shost(dev);
1615+
struct mpi3mr_ioc *mrioc = shost_priv(shost);
1616+
1617+
return sysfs_emit(buf, "%d\n", mrioc->num_op_req_q);
1618+
}
1619+
static DEVICE_ATTR_RO(op_req_q_count);
1620+
1621+
/**
1622+
* reply_queue_count_show - SysFS callback for reply queue count
1623+
* @dev: class device
1624+
* @attr: Device attributes
1625+
* @buf: Buffer to copy
1626+
*
1627+
* Return: sysfs_emit() return after copying reply queue count
1628+
*/
1629+
static ssize_t
1630+
reply_queue_count_show(struct device *dev, struct device_attribute *attr,
1631+
char *buf)
1632+
{
1633+
struct Scsi_Host *shost = class_to_shost(dev);
1634+
struct mpi3mr_ioc *mrioc = shost_priv(shost);
1635+
1636+
return sysfs_emit(buf, "%d\n", mrioc->num_op_reply_q);
1637+
}
1638+
1639+
static DEVICE_ATTR_RO(reply_queue_count);
1640+
1641+
/**
1642+
* logging_level_show - Show controller debug level
1643+
* @dev: class device
1644+
* @attr: Device attributes
1645+
* @buf: Buffer to copy
1646+
*
1647+
* A sysfs 'read/write' shost attribute, to show the current
1648+
* debug log level used by the driver for the specific
1649+
* controller.
1650+
*
1651+
* Return: sysfs_emit() return
1652+
*/
1653+
static ssize_t
1654+
logging_level_show(struct device *dev,
1655+
struct device_attribute *attr, char *buf)
1656+
1657+
{
1658+
struct Scsi_Host *shost = class_to_shost(dev);
1659+
struct mpi3mr_ioc *mrioc = shost_priv(shost);
1660+
1661+
return sysfs_emit(buf, "%08xh\n", mrioc->logging_level);
1662+
}
1663+
1664+
/**
1665+
* logging_level_store- Change controller debug level
1666+
* @dev: class device
1667+
* @attr: Device attributes
1668+
* @buf: Buffer to copy
1669+
* @count: size of the buffer
1670+
*
1671+
* A sysfs 'read/write' shost attribute, to change the current
1672+
* debug log level used by the driver for the specific
1673+
* controller.
1674+
*
1675+
* Return: strlen() return
1676+
*/
1677+
static ssize_t
1678+
logging_level_store(struct device *dev,
1679+
struct device_attribute *attr,
1680+
const char *buf, size_t count)
1681+
{
1682+
struct Scsi_Host *shost = class_to_shost(dev);
1683+
struct mpi3mr_ioc *mrioc = shost_priv(shost);
1684+
int val = 0;
1685+
1686+
if (kstrtoint(buf, 0, &val) != 0)
1687+
return -EINVAL;
1688+
1689+
mrioc->logging_level = val;
1690+
ioc_info(mrioc, "logging_level=%08xh\n", mrioc->logging_level);
1691+
return strlen(buf);
1692+
}
1693+
static DEVICE_ATTR_RW(logging_level);
1694+
15611695
/**
15621696
* adapter_state_show - SysFS callback for adapter state show
15631697
* @dev: class device
15641698
* @attr: Device attributes
15651699
* @buf: Buffer to copy
15661700
*
1567-
* Return: snprintf() return after copying adapter state
1701+
* Return: sysfs_emit() return after copying adapter state
15681702
*/
15691703
static ssize_t
15701704
adp_state_show(struct device *dev, struct device_attribute *attr,
@@ -1585,12 +1719,17 @@ adp_state_show(struct device *dev, struct device_attribute *attr,
15851719
else
15861720
adp_state = MPI3MR_BSG_ADPSTATE_OPERATIONAL;
15871721

1588-
return snprintf(buf, PAGE_SIZE, "%u\n", adp_state);
1722+
return sysfs_emit(buf, "%u\n", adp_state);
15891723
}
15901724

15911725
static DEVICE_ATTR_RO(adp_state);
15921726

15931727
static struct attribute *mpi3mr_host_attrs[] = {
1728+
&dev_attr_version_fw.attr,
1729+
&dev_attr_fw_queue_depth.attr,
1730+
&dev_attr_op_req_q_count.attr,
1731+
&dev_attr_reply_queue_count.attr,
1732+
&dev_attr_logging_level.attr,
15941733
&dev_attr_adp_state.attr,
15951734
NULL,
15961735
};

0 commit comments

Comments
 (0)