]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/infiniband/hw/ipath/ipath_sysfs.c
IB/ipath: Log "active" time and some errors to EEPROM
[linux-2.6-omap-h63xx.git] / drivers / infiniband / hw / ipath / ipath_sysfs.c
index e299148c4b68ec4ae793f0805a339d3c75bbb081..ab34d3e8b95595c912b3b4dbe974cf0232972233 100644 (file)
@@ -32,7 +32,6 @@
  */
 
 #include <linux/ctype.h>
-#include <linux/pci.h>
 
 #include "ipath_kernel.h"
 #include "ipath_common.h"
@@ -215,7 +214,6 @@ static ssize_t store_mlid(struct device *dev,
                          size_t count)
 {
        struct ipath_devdata *dd = dev_get_drvdata(dev);
-       int unit;
        u16 mlid;
        int ret;
 
@@ -223,8 +221,6 @@ static ssize_t store_mlid(struct device *dev,
        if (ret < 0 || mlid < IPATH_MULTICAST_LID_BASE)
                goto invalid;
 
-       unit = dd->ipath_unit;
-
        dd->ipath_mlid = mlid;
 
        goto bail;
@@ -257,7 +253,7 @@ static ssize_t store_guid(struct device *dev,
        struct ipath_devdata *dd = dev_get_drvdata(dev);
        ssize_t ret;
        unsigned short guid[8];
-       __be64 nguid;
+       __be64 new_guid;
        u8 *ng;
        int i;
 
@@ -266,7 +262,7 @@ static ssize_t store_guid(struct device *dev,
                   &guid[4], &guid[5], &guid[6], &guid[7]) != 8)
                goto invalid;
 
-       ng = (u8 *) &nguid;
+       ng = (u8 *) &new_guid;
 
        for (i = 0; i < 8; i++) {
                if (guid[i] > 0xff)
@@ -274,7 +270,10 @@ static ssize_t store_guid(struct device *dev,
                ng[i] = guid[i];
        }
 
-       dd->ipath_guid = nguid;
+       if (new_guid == 0)
+               goto invalid;
+
+       dd->ipath_guid = new_guid;
        dd->ipath_nguid = 1;
 
        ret = strlen(buf);
@@ -297,6 +296,16 @@ static ssize_t show_nguid(struct device *dev,
        return scnprintf(buf, PAGE_SIZE, "%u\n", dd->ipath_nguid);
 }
 
+static ssize_t show_nports(struct device *dev,
+                          struct device_attribute *attr,
+                          char *buf)
+{
+       struct ipath_devdata *dd = dev_get_drvdata(dev);
+
+       /* Return the number of user ports available. */
+       return scnprintf(buf, PAGE_SIZE, "%u\n", dd->ipath_cfgports - 1);
+}
+
 static ssize_t show_serial(struct device *dev,
                           struct device_attribute *attr,
                           char *buf)
@@ -587,6 +596,43 @@ bail:
        return ret;
 }
 
+static ssize_t store_led_override(struct device *dev,
+                         struct device_attribute *attr,
+                         const char *buf,
+                         size_t count)
+{
+       struct ipath_devdata *dd = dev_get_drvdata(dev);
+       int ret;
+       u16 val;
+
+       ret = ipath_parse_ushort(buf, &val);
+       if (ret > 0)
+               ipath_set_led_override(dd, val);
+       else
+               ipath_dev_err(dd, "attempt to set invalid LED override\n");
+       return ret;
+}
+
+static ssize_t show_logged_errs(struct device *dev,
+                               struct device_attribute *attr,
+                               char *buf)
+{
+       struct ipath_devdata *dd = dev_get_drvdata(dev);
+       int idx, count;
+
+       /* force consistency with actual EEPROM */
+       if (ipath_update_eeprom_log(dd) != 0)
+               return -ENXIO;
+
+       count = 0;
+       for (idx = 0; idx < IPATH_EEP_LOG_CNT; ++idx) {
+               count += scnprintf(buf + count, PAGE_SIZE - count, "%d%c",
+                       dd->ipath_eep_st_errs[idx],
+                       idx == (IPATH_EEP_LOG_CNT - 1) ? '\n' : ' ');
+       }
+
+       return count;
+}
 
 static DRIVER_ATTR(num_units, S_IRUGO, show_num_units, NULL);
 static DRIVER_ATTR(version, S_IRUGO, show_version, NULL);
@@ -608,6 +654,7 @@ static DEVICE_ATTR(mlid, S_IWUSR | S_IRUGO, show_mlid, store_mlid);
 static DEVICE_ATTR(mtu, S_IWUSR | S_IRUGO, show_mtu, store_mtu);
 static DEVICE_ATTR(enabled, S_IWUSR | S_IRUGO, show_enabled, store_enabled);
 static DEVICE_ATTR(nguid, S_IRUGO, show_nguid, NULL);
+static DEVICE_ATTR(nports, S_IRUGO, show_nports, NULL);
 static DEVICE_ATTR(reset, S_IWUSR, NULL, store_reset);
 static DEVICE_ATTR(serial, S_IRUGO, show_serial, NULL);
 static DEVICE_ATTR(status, S_IRUGO, show_status, NULL);
@@ -615,6 +662,8 @@ static DEVICE_ATTR(status_str, S_IRUGO, show_status_str, NULL);
 static DEVICE_ATTR(boardversion, S_IRUGO, show_boardversion, NULL);
 static DEVICE_ATTR(unit, S_IRUGO, show_unit, NULL);
 static DEVICE_ATTR(rx_pol_inv, S_IWUSR, NULL, store_rx_pol_inv);
+static DEVICE_ATTR(led_override, S_IWUSR, NULL, store_led_override);
+static DEVICE_ATTR(logged_errors, S_IRUGO, show_logged_errs, NULL);
 
 static struct attribute *dev_attributes[] = {
        &dev_attr_guid.attr,
@@ -623,6 +672,7 @@ static struct attribute *dev_attributes[] = {
        &dev_attr_mlid.attr,
        &dev_attr_mtu.attr,
        &dev_attr_nguid.attr,
+       &dev_attr_nports.attr,
        &dev_attr_serial.attr,
        &dev_attr_status.attr,
        &dev_attr_status_str.attr,
@@ -630,6 +680,8 @@ static struct attribute *dev_attributes[] = {
        &dev_attr_unit.attr,
        &dev_attr_enabled.attr,
        &dev_attr_rx_pol_inv.attr,
+       &dev_attr_led_override.attr,
+       &dev_attr_logged_errors.attr,
        NULL
 };