]> git.baikalelectronics.ru Git - kernel.git/commitdiff
scsi: mpi3mr: Expose adapter state to sysfs
authorSumit Saxena <sumit.saxena@broadcom.com>
Fri, 29 Apr 2022 21:16:39 +0000 (17:16 -0400)
committerMartin K. Petersen <martin.petersen@oracle.com>
Mon, 2 May 2022 21:02:42 +0000 (17:02 -0400)
Link: https://lore.kernel.org/r/20220429211641.642010-7-sumit.saxena@broadcom.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Sumit Saxena <sumit.saxena@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/mpi3mr/mpi3mr.h
drivers/scsi/mpi3mr/mpi3mr_app.c
drivers/scsi/mpi3mr/mpi3mr_os.c

index ad1270cba2805a55e96e1afd3f430ec53f47700c..0c6efb0eb0631c1096ddfbed5831fc471f809071 100644 (file)
@@ -1056,5 +1056,5 @@ int mpi3mr_pel_get_seqnum_post(struct mpi3mr_ioc *mrioc,
        struct mpi3mr_drv_cmd *drv_cmd);
 void mpi3mr_app_save_logdata(struct mpi3mr_ioc *mrioc, char *event_data,
        u16 event_data_size);
-
+extern const struct attribute_group *mpi3mr_host_groups[];
 #endif /*MPI3MR_H_INCLUDED*/
index 06a1e950bec4a651e36ac6389df8d7218ea9ebbc..5221058e3d6b3ef2aa3d479899dedd829d742d8b 100644 (file)
@@ -1215,3 +1215,49 @@ err_setup_queue:
 err_device_add:
        kfree(mrioc->bsg_dev);
 }
+
+/**
+ * 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
+ */
+static ssize_t
+adp_state_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);
+       enum mpi3mr_iocstate ioc_state;
+       uint8_t adp_state;
+
+       ioc_state = mpi3mr_get_iocstate(mrioc);
+       if (ioc_state == MRIOC_STATE_UNRECOVERABLE)
+               adp_state = MPI3MR_BSG_ADPSTATE_UNRECOVERABLE;
+       else if ((mrioc->reset_in_progress) || (mrioc->stop_bsgs))
+               adp_state = MPI3MR_BSG_ADPSTATE_IN_RESET;
+       else if (ioc_state == MRIOC_STATE_FAULT)
+               adp_state = MPI3MR_BSG_ADPSTATE_FAULT;
+       else
+               adp_state = MPI3MR_BSG_ADPSTATE_OPERATIONAL;
+
+       return snprintf(buf, PAGE_SIZE, "%u\n", adp_state);
+}
+
+static DEVICE_ATTR_RO(adp_state);
+
+static struct attribute *mpi3mr_host_attrs[] = {
+       &dev_attr_adp_state.attr,
+       NULL,
+};
+
+static const struct attribute_group mpi3mr_host_attr_group = {
+       .attrs = mpi3mr_host_attrs
+};
+
+const struct attribute_group *mpi3mr_host_groups[] = {
+       &mpi3mr_host_attr_group,
+       NULL,
+};
index 19298136edb66d0825cf7f9aad04ce6b96975be0..89a4918c4a9eb01b6c5936e0b56cc74adf89cc69 100644 (file)
@@ -4134,6 +4134,7 @@ static struct scsi_host_template mpi3mr_driver_template = {
        .max_segment_size               = 0xffffffff,
        .track_queue_depth              = 1,
        .cmd_size                       = sizeof(struct scmd_priv),
+       .shost_groups                   = mpi3mr_host_groups,
 };
 
 /**