Skip to contentSkip to conversation

mpt fusion: add sysfs attributes to display IOC parameters

PATCH In review Prakash, Sathya 3 participants 3 messages Jul 3, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mpt fusion: add sysfs attributes to display IOC parameters

New sysfs scsi_host attributes are added to provide information about, Firmware version, BIOS version, Driver version, MPI version and other product related information.

---

drivers/message/fusion/mptbase.c +45 -0
diff -Naurp b/drivers/message/fusion/mptbase.c a/drivers/message/fusion/mptbase.c
@@ -161,6 +161,7 @@ static int	mpt_readScsiDevicePageHeaders
 static void 	mpt_read_ioc_pg_1(MPT_ADAPTER *ioc);
 static void 	mpt_read_ioc_pg_4(MPT_ADAPTER *ioc);
 static void	mpt_timer_expired(unsigned long data);
+static void	mpt_get_manufacturing_pg_0(MPT_ADAPTER *ioc);
 static int	SendEventNotification(MPT_ADAPTER *ioc, u8 EvSwitch);
 static int	SendEventAck(MPT_ADAPTER *ioc, EventNotificationReply_t *evnp);
 static int	mpt_host_page_access_control(MPT_ADAPTER *ioc, u8 access_control_value, int sleepFlag);
@@ -1880,6 +1881,7 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u3
 		}
 
 		GetIoUnitPage2(ioc);
+		mpt_get_manufacturing_pg_0(ioc);
 	}
 
 	/*
@@ -5190,6 +5192,49 @@ mpt_read_ioc_pg_1(MPT_ADAPTER *ioc)
 	return;
 }
 
+static void
+mpt_get_manufacturing_pg_0(MPT_ADAPTER *ioc)
+{
+	CONFIGPARMS		cfg;
+	ConfigPageHeader_t	hdr;
+	dma_addr_t		buf_dma;
+	ManufacturingPage0_t	*pbuf = NULL;
+
+	memset(&cfg, 0 , sizeof(CONFIGPARMS));
+	memset(&hdr, 0 , sizeof(ConfigPageHeader_t));
+
+	hdr.PageType = MPI_CONFIG_PAGETYPE_MANUFACTURING;
+	cfg.cfghdr.hdr = &hdr;
+	cfg.physAddr = -1;
+	cfg.action = MPI_CONFIG_ACTION_PAGE_HEADER;
+	cfg.timeout = 10;
+
+	if (mpt_config(ioc, &cfg) != 0)
+		goto out;
+
+	if (!cfg.cfghdr.hdr->PageLength)
+		goto out;
+
+	cfg.action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT;
+	pbuf = pci_alloc_consistent(ioc->pcidev, hdr.PageLength * 4, &buf_dma);
+	if (!pbuf)
+		goto out;
+
+	cfg.physAddr = buf_dma;
+
+	if (mpt_config(ioc, &cfg) != 0)
+		goto out;
+
+	memcpy(ioc->board_name, pbuf->BoardName, 16);
+	memcpy(ioc->board_assembly, pbuf->BoardAssembly, 16);
+	memcpy(ioc->board_tracer, pbuf->BoardTracerNumber, 16);
+
+	out:
+
+	if (pbuf)
+		pci_free_consistent(ioc->pcidev, hdr.PageLength * 4, pbuf, buf_dma);
+}
+
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
 /**
  *	SendEventNotification - Send EventNotification (on or off) request to adapter
drivers/message/fusion/mptbase.h +11 -0
diff -Naurp b/drivers/message/fusion/mptbase.h a/drivers/message/fusion/mptbase.h
@@ -78,6 +78,10 @@
 #define MPT_LINUX_VERSION_COMMON	"3.04.05"
 #define MPT_LINUX_PACKAGE_NAME		"@(#)mptlinux-3.04.05"
 #define WHAT_MAGIC_STRING		"@" "(" "#" ")"
+#define MPT_LINUX_MAJOR_VERSION		3
+#define MPT_LINUX_MINOR_VERSION		04
+#define MPT_LINUX_BUILD_VERSION		05
+#define MPT_LINUX_RELEASE_VERSION	00
 
 #define show_mptmod_ver(s,ver)  \
 	printk(KERN_INFO "%s %s\n", s, ver);
@@ -538,6 +542,13 @@ typedef struct _MPT_ADAPTER
 	int			 pci_irq;	/* This irq           */
 	char			 name[MPT_NAME_LENGTH];	/* "iocN"             */
 	char			*prod_name;	/* "LSIFC9x9"         */
+	char			 board_name[16];
+	char			 board_assembly[16];
+	char			 board_tracer[16];
+	u16			 nvdata_version_persistent;
+	u16			 nvdata_version_default;
+	u8			 io_missing_delay;
+	u8			 device_missing_delay;
 	SYSIF_REGS __iomem	*chip;		/* == c8817000 (mmap) */
 	SYSIF_REGS __iomem	*pio_chip;	/* Programmed IO (downloadboot) */
 	u8			 bus_type;
drivers/message/fusion/mptfc.c +1 -0
diff -Naurp b/drivers/message/fusion/mptfc.c a/drivers/message/fusion/mptfc.c
@@ -130,6 +130,7 @@ static struct scsi_host_template mptfc_d
 	.max_sectors			= 8192,
 	.cmd_per_lun			= 7,
 	.use_clustering			= ENABLE_CLUSTERING,
+	.shost_attrs			= mptscsih_host_attrs,
 };
 
 /****************************************************************************
drivers/message/fusion/mptsas.c +64 -0

88 lines not on this page · raw message

drivers/message/fusion/mptscsih.c +176 -0

182 lines not on this page · raw message

drivers/message/fusion/mptscsih.h +1 -0
diff -Naurp b/drivers/message/fusion/mptscsih.h a/drivers/message/fusion/mptscsih.h
@@ -129,3 +129,4 @@ extern void mptscsih_timer_expired(unsig
 extern int mptscsih_TMHandler(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 id, int lun, int ctx2abort, ulong timeout);
 extern u8 mptscsih_raid_id_to_num(MPT_ADAPTER *ioc, u8 channel, u8 id);
 extern int mptscsih_is_phys_disk(MPT_ADAPTER *ioc, u8 channel, u8 id);
+extern struct class_device_attribute *mptscsih_host_attrs[];
drivers/message/fusion/mptspi.c +1 -0
diff -Naurp b/drivers/message/fusion/mptspi.c a/drivers/message/fusion/mptspi.c
@@ -819,6 +819,7 @@ static struct scsi_host_template mptspi_
 	.max_sectors			= 8192,
 	.cmd_per_lun			= 7,
 	.use_clustering			= ENABLE_CLUSTERING,
+	.shost_attrs			= mptscsih_host_attrs,
 };
 
 static int mptspi_write_spi_device_pg1(struct scsi_target *starget,
#1 lore raw

drivers/message/fusion/mptbase.c mpt_read_ioc_pg_1(MPT_ADAPTER *ioc) · line 5230

Quoted 8 lines · Sathya
drivers/message/fusion/mptbase.c +7 -0
+static void
+mpt_get_manufacturing_pg_0(MPT_ADAPTER *ioc)
+{
 
+
+	memcpy(ioc->board_name, pbuf->BoardName, 16);
+	memcpy(ioc->board_assembly, pbuf->BoardAssembly, 16);
+	memcpy(ioc->board_tracer, pbuf->BoardTracerNumber, 16);

Are these guaranteed to be NULL terminated? The code below appears to assume they are. Also you might want to use sizeof instead of hardcoding 16 here.

drivers/message/fusion/mptscsih.c mptscsih_synchronize_cache(MPT_SCSI_HOST · line 3231

Quoted 8 lines
drivers/message/fusion/mptscsih.c +8 -0
+static ssize_t
+mptscsih_version_driver_show(struct class_device *cdev, char *buf)
+{
+	return snprintf(buf, PAGE_SIZE, "%02d.%02d.%02d.%02d\n",
+	    MPT_LINUX_MAJOR_VERSION, MPT_LINUX_MINOR_VERSION,
+	    MPT_LINUX_BUILD_VERSION, MPT_LINUX_RELEASE_VERSION);
+}
+static CLASS_DEVICE_ATTR(version_driver, S_IRUGO, mptscsih_version_driver_show, NULL);

You should be using the MODULE_VERSION macro instead of this. This results in the version showing up in /sys/module/mpt_fusion/version

drivers/message/fusion/mptscsih.c mptscsih_synchronize_cache(MPT_SCSI_HOST · line 3331

Quoted 12 lines
drivers/message/fusion/mptscsih.c +12 -0
+
+static ssize_t
+mptscsih_io_delay_show(struct class_device *cdev, char *buf)
+{
+	struct Scsi_Host *host = class_to_shost(cdev);
+	MPT_SCSI_HOST	*hd = (MPT_SCSI_HOST *)host->hostdata;
+	MPT_ADAPTER *ioc = hd->ioc;
+	char delay_str[30];
+
+	sprintf(delay_str, "%02d", ioc->io_missing_delay);
+	return snprintf(buf, PAGE_SIZE, "%s\n", delay_str);
+}

Why not just do:

	return snprintf(buf, PAGE_SIZE, "%02d", ioc->io_missing_delay);

and get rid of the delay_str on the stack? In fact you have a lot of double sprintf's which seem like they could be just a single snprintf.

-Brian

Signature · 3 lines
Brian King
Linux on Power Virtualization
IBM Linux Technology Center
#2 lore raw
In reply to Prakash, Sathya
Quoted 1 line

diff -Naurp b/drivers/message/fusion/mptbase.h

a/drivers/message/fusion/mptbase.h

Quoted 1 line

--- b/drivers/message/fusion/mptbase.h 2007-07-02 16:20:46.000000000

+0530

Quoted 1 line

+++ a/drivers/message/fusion/mptbase.h 2007-07-03 18:13:28.000000000

+0530

drivers/message/fusion/mptbase.h line 84

Quoted 8 lines
drivers/message/fusion/mptbase.h +4 -0
@@ -78,6 +78,10 @@
 #define MPT_LINUX_VERSION_COMMON	"3.04.05"
 #define MPT_LINUX_PACKAGE_NAME		"@(#)mptlinux-3.04.05"
 #define WHAT_MAGIC_STRING		"@" "(" "#" ")"
+#define MPT_LINUX_MAJOR_VERSION		3
+#define MPT_LINUX_MINOR_VERSION		04
+#define MPT_LINUX_BUILD_VERSION		05
+#define MPT_LINUX_RELEASE_VERSION	00

You have the version information listed 3 times. Can't you just build MPT_LINUX_VERSION_COMMON and MPT_LINUX_PACKAGE_NAME?