]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/net/myri10ge/myri10ge.c
[PATCH] myri10ge - Write the firmware in 256-bytes chunks
[linux-2.6-omap-h63xx.git] / drivers / net / myri10ge / myri10ge.c
index e1feb58bd6615675cbf89d23355efd63228be94f..198c6f0e0105d2f877158654ccf163e66cce9bd4 100644 (file)
@@ -188,7 +188,6 @@ struct myri10ge_priv {
        int vendor_specific_offset;
        u32 devctl;
        u16 msi_flags;
-       u32 pm_state[16];
        u32 read_dma;
        u32 write_dma;
        u32 read_write_dma;
@@ -449,6 +448,7 @@ static int myri10ge_load_hotplug_firmware(struct myri10ge_priv *mgp, u32 * size)
        struct mcp_gen_header *hdr;
        size_t hdr_offset;
        int status;
+       unsigned i;
 
        if ((status = request_firmware(&fw, mgp->fw_name, dev)) < 0) {
                dev_err(dev, "Unable to load %s firmware image via hotplug\n",
@@ -480,18 +480,12 @@ static int myri10ge_load_hotplug_firmware(struct myri10ge_priv *mgp, u32 * size)
                goto abort_with_fw;
 
        crc = crc32(~0, fw->data, fw->size);
-       if (mgp->tx.boundary == 2048) {
-               /* Avoid PCI burst on chipset with unaligned completions. */
-               int i;
-               __iomem u32 *ptr = (__iomem u32 *) (mgp->sram +
-                                                   MYRI10GE_FW_OFFSET);
-               for (i = 0; i < fw->size / 4; i++) {
-                       __raw_writel(((u32 *) fw->data)[i], ptr + i);
-                       wmb();
-               }
-       } else {
-               myri10ge_pio_copy(mgp->sram + MYRI10GE_FW_OFFSET, fw->data,
-                                 fw->size);
+       for (i = 0; i < fw->size; i += 256) {
+               myri10ge_pio_copy(mgp->sram + MYRI10GE_FW_OFFSET + i,
+                                 fw->data + i,
+                                 min(256U, (unsigned)(fw->size - i)));
+               mb();
+               readb(mgp->sram);
        }
        /* corruption checking is good for parity recovery and buggy chipset */
        memcpy_fromio(fw->data, mgp->sram + MYRI10GE_FW_OFFSET, fw->size);
@@ -621,7 +615,7 @@ static int myri10ge_load_firmware(struct myri10ge_priv *mgp)
                return -ENXIO;
        }
        dev_info(&mgp->pdev->dev, "handoff confirmed\n");
-       myri10ge_dummy_rdma(mgp, mgp->tx.boundary != 4096);
+       myri10ge_dummy_rdma(mgp, 1);
 
        return 0;
 }
@@ -1289,6 +1283,7 @@ static const char myri10ge_gstrings_stats[][ETH_GSTRING_LEN] = {
        "tx_aborted_errors", "tx_carrier_errors", "tx_fifo_errors",
        "tx_heartbeat_errors", "tx_window_errors",
        /* device-specific stats */
+       "tx_boundary", "WC", "irq", "MSI",
        "read_dma_bw_MBs", "write_dma_bw_MBs", "read_write_dma_bw_MBs",
        "serial_number", "tx_pkt_start", "tx_pkt_done",
        "tx_req", "tx_done", "rx_small_cnt", "rx_big_cnt",
@@ -1327,6 +1322,10 @@ myri10ge_get_ethtool_stats(struct net_device *netdev,
        for (i = 0; i < MYRI10GE_NET_STATS_LEN; i++)
                data[i] = ((unsigned long *)&mgp->stats)[i];
 
+       data[i++] = (unsigned int)mgp->tx.boundary;
+       data[i++] = (unsigned int)(mgp->mtrr >= 0);
+       data[i++] = (unsigned int)mgp->pdev->irq;
+       data[i++] = (unsigned int)mgp->msi_enabled;
        data[i++] = (unsigned int)mgp->read_dma;
        data[i++] = (unsigned int)mgp->write_dma;
        data[i++] = (unsigned int)mgp->read_write_dma;
@@ -1879,7 +1878,7 @@ again:
 
 #ifdef NETIF_F_TSO
        if (skb->len > (dev->mtu + ETH_HLEN)) {
-               mss = skb_shinfo(skb)->tso_size;
+               mss = skb_shinfo(skb)->gso_size;
                if (mss != 0)
                        max_segments = MYRI10GE_MAX_SEND_DESC_TSO;
        }
@@ -1939,8 +1938,7 @@ again:
 
                /* pad frames to at least ETH_ZLEN bytes */
                if (unlikely(skb->len < ETH_ZLEN)) {
-                       skb = skb_padto(skb, ETH_ZLEN);
-                       if (skb == NULL) {
+                       if (skb_padto(skb, ETH_ZLEN)) {
                                /* The packet is gone, so we must
                                 * return 0 */
                                mgp->stats.tx_dropped += 1;
@@ -2113,14 +2111,14 @@ abort_linearize:
                }
                idx = (idx + 1) & tx->mask;
        } while (idx != last_idx);
-       if (skb_shinfo(skb)->tso_size) {
+       if (skb_is_gso(skb)) {
                printk(KERN_ERR
                       "myri10ge: %s: TSO but wanted to linearize?!?!?\n",
                       mgp->dev->name);
                goto drop;
        }
 
-       if (skb_linearize(skb, GFP_ATOMIC))
+       if (skb_linearize(skb))
                goto drop;
 
        mgp->tx_linearized++;
@@ -2198,8 +2196,6 @@ static int myri10ge_change_mtu(struct net_device *dev, int new_mtu)
  * any other device, except if forced with myri10ge_ecrc_enable > 1.
  */
 
-#define PCI_DEVICE_ID_NVIDIA_NFORCE_CK804_PCIE 0x005d
-
 static void myri10ge_enable_ecrc(struct myri10ge_priv *mgp)
 {
        struct pci_dev *bridge = mgp->pdev->bus->self;
@@ -2251,12 +2247,6 @@ static void myri10ge_enable_ecrc(struct myri10ge_priv *mgp)
        }
 
        cap = pci_find_ext_capability(bridge, PCI_EXT_CAP_ID_ERR);
-       /* nvidia ext cap is not always linked in ext cap chain */
-       if (!cap
-           && bridge->vendor == PCI_VENDOR_ID_NVIDIA
-           && bridge->device == PCI_DEVICE_ID_NVIDIA_NFORCE_CK804_PCIE)
-               cap = 0x160;
-
        if (!cap)
                return;
 
@@ -2417,14 +2407,20 @@ static int myri10ge_resume(struct pci_dev *pdev)
                return -EIO;
        }
        myri10ge_restore_state(mgp);
-       pci_enable_device(pdev);
+
+       status = pci_enable_device(pdev);
+       if (status < 0) {
+               dev_err(&pdev->dev, "failed to enable device\n");
+               return -EIO;
+       }
+
        pci_set_master(pdev);
 
-       status = request_irq(pdev->irq, myri10ge_intr, SA_SHIRQ,
+       status = request_irq(pdev->irq, myri10ge_intr, IRQF_SHARED,
                             netdev->name, mgp);
        if (status != 0) {
                dev_err(&pdev->dev, "failed to allocate IRQ\n");
-               goto abort_with_msi;
+               goto abort_with_enabled;
        }
 
        myri10ge_reset(mgp);
@@ -2443,7 +2439,8 @@ static int myri10ge_resume(struct pci_dev *pdev)
 
        return 0;
 
-abort_with_msi:
+abort_with_enabled:
+       pci_disable_device(pdev);
        return -EIO;
 
 }
@@ -2701,7 +2698,7 @@ static int myri10ge_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
                        mgp->msi_enabled = 1;
        }
 
-       status = request_irq(pdev->irq, myri10ge_intr, SA_SHIRQ,
+       status = request_irq(pdev->irq, myri10ge_intr, IRQF_SHARED,
                             netdev->name, mgp);
        if (status != 0) {
                dev_err(&pdev->dev, "failed to allocate IRQ\n");
@@ -2732,8 +2729,6 @@ static int myri10ge_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        /* Save configuration space to be restored if the
         * nic resets due to a parity error */
        myri10ge_save_state(mgp);
-       /* Restore state immediately since pci_save_msi_state disables MSI */
-       myri10ge_restore_state(mgp);
 
        /* Setup the watchdog timer */
        setup_timer(&mgp->watchdog_timer, myri10ge_watchdog_timer,
@@ -2746,11 +2741,10 @@ static int myri10ge_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
                dev_err(&pdev->dev, "register_netdev failed: %d\n", status);
                goto abort_with_irq;
        }
-
-       printk(KERN_INFO "myri10ge: %s: %s IRQ %d, tx bndry %d, fw %s, WC %s\n",
-              netdev->name, (mgp->msi_enabled ? "MSI" : "xPIC"),
-              pdev->irq, mgp->tx.boundary, mgp->fw_name,
-              (mgp->mtrr >= 0 ? "Enabled" : "Disabled"));
+       dev_info(dev, "%s IRQ %d, tx bndry %d, fw %s, WC %s\n",
+                (mgp->msi_enabled ? "MSI" : "xPIC"),
+                pdev->irq, mgp->tx.boundary, mgp->fw_name,
+                (mgp->mtrr >= 0 ? "Enabled" : "Disabled"));
 
        return 0;