IB/ipath: Provide I/O bus speeds for diagnostic purposes
authorArthur Jones <arthur.jones@qlogic.com>
Thu, 17 Apr 2008 04:01:12 +0000 (21:01 -0700)
committerRoland Dreier <rolandd@cisco.com>
Thu, 17 Apr 2008 04:01:12 +0000 (21:01 -0700)
Modern I/O buses like PCIe and HT can be configured for multiple speeds
and widths.  When an ipath HCA seems to have lower than expected
performance, it is very useful to be able to display what the driver
thinks the bus speed is.

Signed-off-by: Dave Olson <dave.olson@qlogic.com>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
drivers/infiniband/hw/ipath/ipath_iba6110.c
drivers/infiniband/hw/ipath/ipath_iba6120.c
drivers/infiniband/hw/ipath/ipath_kernel.h
drivers/infiniband/hw/ipath/ipath_sysfs.c

index 684c27e4240622599c313688085d9e4c172d3e04..19e3955304c0a79ad5531fa9cbfae5fe17c73891 100644 (file)
@@ -742,11 +742,10 @@ static int ipath_ht_boardname(struct ipath_devdata *dd, char *name,
         */
        dd->ipath_flags |= IPATH_32BITCOUNTERS;
        dd->ipath_flags |= IPATH_GPIO_INTR;
-       if (dd->ipath_htspeed != 800)
+       if (dd->ipath_lbus_speed != 800)
                ipath_dev_err(dd,
                              "Incorrectly configured for HT @ %uMHz\n",
-                             dd->ipath_htspeed);
-       ret = 0;
+                             dd->ipath_lbus_speed);
 
        /*
         * set here, not in ipath_init_*_funcs because we have to do
@@ -911,7 +910,7 @@ static void slave_or_pri_blk(struct ipath_devdata *dd, struct pci_dev *pdev,
                        break;
                }
 
-               dd->ipath_htwidth = width;
+               dd->ipath_lbus_width = width;
 
                if (linkwidth != 0x11) {
                        ipath_dev_err(dd, "Not configured for 16 bit HT "
@@ -959,8 +958,13 @@ static void slave_or_pri_blk(struct ipath_devdata *dd, struct pci_dev *pdev,
                        speed = 200;
                        break;
                }
-               dd->ipath_htspeed = speed;
+               dd->ipath_lbus_speed = speed;
        }
+
+       snprintf(dd->ipath_lbus_info, sizeof(dd->ipath_lbus_info),
+               "HyperTransport,%uMHz,x%u\n",
+               dd->ipath_lbus_speed,
+               dd->ipath_lbus_width);
 }
 
 static int ipath_ht_intconfig(struct ipath_devdata *dd)
index 8423fee6344b5e868e1faab7f6d53b4d531c6f66..828066e20ad77231296b0075c6126b34c8d3ec09 100644 (file)
@@ -626,7 +626,6 @@ static int ipath_pe_boardname(struct ipath_devdata *dd, char *name,
                        dd->ipath_f_put_tid = ipath_pe_put_tid_2;
        }
 
-
        /*
         * set here, not in ipath_init_*_funcs because we have to do
         * it after we can read chip registers.
@@ -879,6 +878,62 @@ static void ipath_setup_pe_cleanup(struct ipath_devdata *dd)
        pci_disable_msi(dd->pcidev);
 }
 
+static void ipath_6120_pcie_params(struct ipath_devdata *dd)
+{
+       u16 linkstat, speed;
+       int pos;
+
+       pos = pci_find_capability(dd->pcidev, PCI_CAP_ID_EXP);
+       if (!pos) {
+               ipath_dev_err(dd, "Can't find PCI Express capability!\n");
+               goto bail;
+       }
+
+       pci_read_config_word(dd->pcidev, pos + PCI_EXP_LNKSTA,
+                            &linkstat);
+       /*
+        * speed is bits 0-4, linkwidth is bits 4-8
+        * no defines for them in headers
+        */
+       speed = linkstat & 0xf;
+       linkstat >>= 4;
+       linkstat &= 0x1f;
+       dd->ipath_lbus_width = linkstat;
+
+       switch (speed) {
+       case 1:
+               dd->ipath_lbus_speed = 2500; /* Gen1, 2.5GHz */
+               break;
+       case 2:
+               dd->ipath_lbus_speed = 5000; /* Gen1, 5GHz */
+               break;
+       default: /* not defined, assume gen1 */
+               dd->ipath_lbus_speed = 2500;
+               break;
+       }
+
+       if (linkstat < 8)
+               ipath_dev_err(dd,
+                       "PCIe width %u (x8 HCA), performance reduced\n",
+                       linkstat);
+       else
+               ipath_cdbg(VERBOSE, "PCIe speed %u width %u (x8 HCA)\n",
+                       dd->ipath_lbus_speed, linkstat);
+
+       if (speed != 1)
+               ipath_dev_err(dd,
+                       "PCIe linkspeed %u is incorrect; "
+                       "should be 1 (2500)!\n", speed);
+bail:
+       /* fill in string, even on errors */
+       snprintf(dd->ipath_lbus_info, sizeof(dd->ipath_lbus_info),
+               "PCIe,%uMHz,x%u\n",
+               dd->ipath_lbus_speed,
+               dd->ipath_lbus_width);
+
+       return;
+}
+
 /**
  * ipath_setup_pe_config - setup PCIe config related stuff
  * @dd: the infinipath device
@@ -936,19 +991,8 @@ static int ipath_setup_pe_config(struct ipath_devdata *dd,
        } else
                ipath_dev_err(dd, "Can't find MSI capability, "
                              "can't save MSI settings for reset\n");
-       if ((pos = pci_find_capability(dd->pcidev, PCI_CAP_ID_EXP))) {
-               u16 linkstat;
-               pci_read_config_word(dd->pcidev, pos + PCI_EXP_LNKSTA,
-                                    &linkstat);
-               linkstat >>= 4;
-               linkstat &= 0x1f;
-               if (linkstat != 8)
-                       ipath_dev_err(dd, "PCIe width %u, "
-                                     "performance reduced\n", linkstat);
-       }
-       else
-               ipath_dev_err(dd, "Can't find PCI Express "
-                             "capability!\n");
+
+       ipath_6120_pcie_params(dd);
 
        dd->ipath_link_width_supported = IB_WIDTH_1X | IB_WIDTH_4X;
        dd->ipath_link_speed_supported = IPATH_IB_SDR;
@@ -1206,6 +1250,8 @@ static int ipath_setup_pe_reset(struct ipath_devdata *dd)
        ret = 0; /* failed */
 
 bail:
+       if (ret)
+               ipath_6120_pcie_params(dd);
        return ret;
 }
 
index 3d4a254ffca03251bfdde8df91b813c49d51c3f5..59dc895162430979f9ea512de6bb3d367ec34d66 100644 (file)
@@ -546,10 +546,10 @@ struct ipath_devdata {
        u32 ipath_init_ibmaxlen;
        /* size of each rcvegrbuffer */
        u32 ipath_rcvegrbufsize;
-       /* width (2,4,8,16,32) from HT config reg */
-       u32 ipath_htwidth;
-       /* HT speed (200,400,800,1000) from HT config */
-       u32 ipath_htspeed;
+       /* localbus width (1, 2,4,8,16,32) from config space  */
+       u32 ipath_lbus_width;
+       /* localbus speed (HT: 200,400,800,1000; PCIe 2500) */
+       u32 ipath_lbus_speed;
        /*
         * number of sequential ibcstatus change for polling active/quiet
         * (i.e., link not coming up).
@@ -574,6 +574,7 @@ struct ipath_devdata {
        u8 ipath_serial[16];
        /* human readable board version */
        u8 ipath_boardversion[80];
+       u8 ipath_lbus_info[32]; /* human readable localbus info */
        /* chip major rev, from ipath_revision */
        u8 ipath_majrev;
        /* chip minor rev, from ipath_revision */
index 56dfc8a2344c31d7d3d7c18a8c7cb36b302b9a28..bb41c3f6aad38964c80adc0783bfaabfaf92bf02 100644 (file)
@@ -163,6 +163,15 @@ static ssize_t show_boardversion(struct device *dev,
        return scnprintf(buf, PAGE_SIZE, "%s", dd->ipath_boardversion);
 }
 
+static ssize_t show_localbus_info(struct device *dev,
+                              struct device_attribute *attr,
+                              char *buf)
+{
+       struct ipath_devdata *dd = dev_get_drvdata(dev);
+       /* The string printed here is already newline-terminated. */
+       return scnprintf(buf, PAGE_SIZE, "%s", dd->ipath_lbus_info);
+}
+
 static ssize_t show_lmc(struct device *dev,
                        struct device_attribute *attr,
                        char *buf)
@@ -1011,6 +1020,7 @@ 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 DEVICE_ATTR(localbus_info, S_IRUGO, show_localbus_info, NULL);
 static DEVICE_ATTR(jint_max_packets, S_IWUSR | S_IRUGO,
                   show_jint_max_packets, store_jint_max_packets);
 static DEVICE_ATTR(jint_idle_ticks, S_IWUSR | S_IRUGO,
@@ -1034,6 +1044,7 @@ static struct attribute *dev_attributes[] = {
        &dev_attr_rx_pol_inv.attr,
        &dev_attr_led_override.attr,
        &dev_attr_logged_errors.attr,
+       &dev_attr_localbus_info.attr,
        NULL
 };