Merge branch 'core/xen' into x86/xen
[safe/jmp/linux-2.6] / drivers / net / myri10ge / myri10ge.c
index 806081b..d6524db 100644 (file)
@@ -1,7 +1,7 @@
 /*************************************************************************
  * myri10ge.c: Myricom Myri-10G Ethernet driver.
  *
- * Copyright (C) 2005, 2006 Myricom, Inc.
+ * Copyright (C) 2005 - 2007 Myricom, Inc.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.
  *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
  *
  *
  * If the eeprom on your board is not recent enough, you will need to get a
 #include <linux/etherdevice.h>
 #include <linux/if_ether.h>
 #include <linux/if_vlan.h>
+#include <linux/inet_lro.h>
+#include <linux/dca.h>
 #include <linux/ip.h>
 #include <linux/inet.h>
 #include <linux/in.h>
 #include <linux/ethtool.h>
 #include <linux/firmware.h>
 #include <linux/delay.h>
-#include <linux/version.h>
 #include <linux/timer.h>
 #include <linux/vmalloc.h>
 #include <linux/crc32.h>
 #include <linux/moduleparam.h>
 #include <linux/io.h>
+#include <linux/log2.h>
 #include <net/checksum.h>
+#include <net/ip.h>
+#include <net/tcp.h>
 #include <asm/byteorder.h>
 #include <asm/io.h>
 #include <asm/processor.h>
@@ -71,7 +75,7 @@
 #include "myri10ge_mcp.h"
 #include "myri10ge_mcp_gen_header.h"
 
-#define MYRI10GE_VERSION_STR "1.0.0"
+#define MYRI10GE_VERSION_STR "1.4.3-1.358"
 
 MODULE_DESCRIPTION("Myricom 10G driver (10GbE)");
 MODULE_AUTHOR("Maintainer: help@myri.com");
@@ -88,12 +92,19 @@ MODULE_LICENSE("Dual BSD/GPL");
 
 #define MYRI10GE_EEPROM_STRINGS_SIZE 256
 #define MYRI10GE_MAX_SEND_DESC_TSO ((65536 / 2048) * 2)
+#define MYRI10GE_MAX_LRO_DESCRIPTORS 8
+#define MYRI10GE_LRO_MAX_PKTS 64
 
-#define MYRI10GE_NO_CONFIRM_DATA 0xffffffff
+#define MYRI10GE_NO_CONFIRM_DATA htonl(0xffffffff)
 #define MYRI10GE_NO_RESPONSE_RESULT 0xffffffff
 
+#define MYRI10GE_ALLOC_ORDER 0
+#define MYRI10GE_ALLOC_SIZE ((1 << MYRI10GE_ALLOC_ORDER) * PAGE_SIZE)
+#define MYRI10GE_MAX_FRAGS_PER_FRAME (MYRI10GE_MAX_ETHER_MTU/MYRI10GE_ALLOC_SIZE + 1)
+
 struct myri10ge_rx_buffer_state {
-       struct sk_buff *skb;
+       struct page *page;
+       int page_offset;
         DECLARE_PCI_UNMAP_ADDR(bus)
         DECLARE_PCI_UNMAP_LEN(len)
 };
@@ -113,26 +124,31 @@ struct myri10ge_cmd {
 
 struct myri10ge_rx_buf {
        struct mcp_kreq_ether_recv __iomem *lanai;      /* lanai ptr for recv ring */
-       u8 __iomem *wc_fifo;    /* w/c rx dma addr fifo address */
        struct mcp_kreq_ether_recv *shadow;     /* host shadow of recv ring */
        struct myri10ge_rx_buffer_state *info;
+       struct page *page;
+       dma_addr_t bus;
+       int page_offset;
        int cnt;
+       int fill_cnt;
        int alloc_fail;
        int mask;               /* number of rx slots -1 */
+       int watchdog_needed;
 };
 
 struct myri10ge_tx_buf {
        struct mcp_kreq_ether_send __iomem *lanai;      /* lanai ptr for sendq */
-       u8 __iomem *wc_fifo;    /* w/c send fifo address */
        struct mcp_kreq_ether_send *req_list;   /* host shadow of sendq */
        char *req_bytes;
        struct myri10ge_tx_buffer_state *info;
        int mask;               /* number of transmit slots -1  */
-       int boundary;           /* boundary transmits cannot cross */
        int req ____cacheline_aligned;  /* transmit slots submitted     */
        int pkt_start;          /* packets started */
+       int stop_queue;
+       int linearized;
        int done ____cacheline_aligned; /* transmit slots completed     */
        int pkt_done;           /* packets completed */
+       int wake_queue;
 };
 
 struct myri10ge_rx_done {
@@ -140,56 +156,95 @@ struct myri10ge_rx_done {
        dma_addr_t bus;
        int cnt;
        int idx;
+       struct net_lro_mgr lro_mgr;
+       struct net_lro_desc lro_desc[MYRI10GE_MAX_LRO_DESCRIPTORS];
 };
 
-struct myri10ge_priv {
-       int running;            /* running?             */
-       int csum_flag;          /* rx_csums?            */
+struct myri10ge_slice_netstats {
+       unsigned long rx_packets;
+       unsigned long tx_packets;
+       unsigned long rx_bytes;
+       unsigned long tx_bytes;
+       unsigned long rx_dropped;
+       unsigned long tx_dropped;
+};
+
+struct myri10ge_slice_state {
        struct myri10ge_tx_buf tx;      /* transmit ring        */
        struct myri10ge_rx_buf rx_small;
        struct myri10ge_rx_buf rx_big;
        struct myri10ge_rx_done rx_done;
+       struct net_device *dev;
+       struct napi_struct napi;
+       struct myri10ge_priv *mgp;
+       struct myri10ge_slice_netstats stats;
+       __be32 __iomem *irq_claim;
+       struct mcp_irq_data *fw_stats;
+       dma_addr_t fw_stats_bus;
+       int watchdog_tx_done;
+       int watchdog_tx_req;
+#ifdef CONFIG_DCA
+       int cached_dca_tag;
+       int cpu;
+       __be32 __iomem *dca_tag;
+#endif
+       char irq_desc[32];
+};
+
+struct myri10ge_priv {
+       struct myri10ge_slice_state *ss;
+       int tx_boundary;        /* boundary transmits cannot cross */
+       int num_slices;
+       int running;            /* running?             */
+       int csum_flag;          /* rx_csums?            */
        int small_bytes;
+       int big_bytes;
+       int max_intr_slots;
        struct net_device *dev;
        struct net_device_stats stats;
+       spinlock_t stats_lock;
        u8 __iomem *sram;
        int sram_size;
        unsigned long board_span;
        unsigned long iomem_base;
-       u32 __iomem *irq_claim;
-       u32 __iomem *irq_deassert;
+       __be32 __iomem *irq_deassert;
        char *mac_addr_string;
        struct mcp_cmd_response *cmd;
        dma_addr_t cmd_bus;
-       struct mcp_irq_data *fw_stats;
-       dma_addr_t fw_stats_bus;
        struct pci_dev *pdev;
        int msi_enabled;
-       unsigned int link_state;
+       int msix_enabled;
+       struct msix_entry *msix_vectors;
+#ifdef CONFIG_DCA
+       int dca_enabled;
+#endif
+       u32 link_state;
        unsigned int rdma_tags_available;
        int intr_coal_delay;
-       u32 __iomem *intr_coal_delay_ptr;
+       __be32 __iomem *intr_coal_delay_ptr;
        int mtrr;
-       int wake_queue;
-       int stop_queue;
+       int wc_enabled;
        int down_cnt;
        wait_queue_head_t down_wq;
        struct work_struct watchdog_work;
        struct timer_list watchdog_timer;
-       int watchdog_tx_done;
-       int watchdog_tx_req;
        int watchdog_resets;
-       int tx_linearized;
+       int watchdog_pause;
        int pause;
        char *fw_name;
        char eeprom_strings[MYRI10GE_EEPROM_STRINGS_SIZE];
+       char *product_code_string;
        char fw_version[128];
+       int fw_ver_major;
+       int fw_ver_minor;
+       int fw_ver_tiny;
+       int adopted_rx_filter_bug;
        u8 mac_addr[6];         /* eeprom mac address */
        unsigned long serial_number;
        int vendor_specific_offset;
        int fw_multicast_support;
-       u32 devctl;
-       u16 msi_flags;
+       unsigned long features;
+       u32 max_tso6;
        u32 read_dma;
        u32 write_dma;
        u32 read_write_dma;
@@ -199,66 +254,59 @@ struct myri10ge_priv {
 
 static char *myri10ge_fw_unaligned = "myri10ge_ethp_z8e.dat";
 static char *myri10ge_fw_aligned = "myri10ge_eth_z8e.dat";
+static char *myri10ge_fw_rss_unaligned = "myri10ge_rss_ethp_z8e.dat";
+static char *myri10ge_fw_rss_aligned = "myri10ge_rss_eth_z8e.dat";
 
 static char *myri10ge_fw_name = NULL;
 module_param(myri10ge_fw_name, charp, S_IRUGO | S_IWUSR);
-MODULE_PARM_DESC(myri10ge_fw_name, "Firmware image name\n");
+MODULE_PARM_DESC(myri10ge_fw_name, "Firmware image name");
 
 static int myri10ge_ecrc_enable = 1;
 module_param(myri10ge_ecrc_enable, int, S_IRUGO);
-MODULE_PARM_DESC(myri10ge_ecrc_enable, "Enable Extended CRC on PCI-E\n");
-
-static int myri10ge_max_intr_slots = 1024;
-module_param(myri10ge_max_intr_slots, int, S_IRUGO);
-MODULE_PARM_DESC(myri10ge_max_intr_slots, "Interrupt queue slots\n");
+MODULE_PARM_DESC(myri10ge_ecrc_enable, "Enable Extended CRC on PCI-E");
 
 static int myri10ge_small_bytes = -1;  /* -1 == auto */
 module_param(myri10ge_small_bytes, int, S_IRUGO | S_IWUSR);
-MODULE_PARM_DESC(myri10ge_small_bytes, "Threshold of small packets\n");
+MODULE_PARM_DESC(myri10ge_small_bytes, "Threshold of small packets");
 
 static int myri10ge_msi = 1;   /* enable msi by default */
-module_param(myri10ge_msi, int, S_IRUGO);
-MODULE_PARM_DESC(myri10ge_msi, "Enable Message Signalled Interrupts\n");
+module_param(myri10ge_msi, int, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(myri10ge_msi, "Enable Message Signalled Interrupts");
 
-static int myri10ge_intr_coal_delay = 25;
+static int myri10ge_intr_coal_delay = 75;
 module_param(myri10ge_intr_coal_delay, int, S_IRUGO);
-MODULE_PARM_DESC(myri10ge_intr_coal_delay, "Interrupt coalescing delay\n");
+MODULE_PARM_DESC(myri10ge_intr_coal_delay, "Interrupt coalescing delay");
 
 static int myri10ge_flow_control = 1;
 module_param(myri10ge_flow_control, int, S_IRUGO);
-MODULE_PARM_DESC(myri10ge_flow_control, "Pause parameter\n");
+MODULE_PARM_DESC(myri10ge_flow_control, "Pause parameter");
 
 static int myri10ge_deassert_wait = 1;
 module_param(myri10ge_deassert_wait, int, S_IRUGO | S_IWUSR);
 MODULE_PARM_DESC(myri10ge_deassert_wait,
-                "Wait when deasserting legacy interrupts\n");
+                "Wait when deasserting legacy interrupts");
 
 static int myri10ge_force_firmware = 0;
 module_param(myri10ge_force_firmware, int, S_IRUGO);
 MODULE_PARM_DESC(myri10ge_force_firmware,
-                "Force firmware to assume aligned completions\n");
-
-static int myri10ge_skb_cross_4k = 0;
-module_param(myri10ge_skb_cross_4k, int, S_IRUGO | S_IWUSR);
-MODULE_PARM_DESC(myri10ge_skb_cross_4k,
-                "Can a small skb cross a 4KB boundary?\n");
+                "Force firmware to assume aligned completions");
 
 static int myri10ge_initial_mtu = MYRI10GE_MAX_ETHER_MTU - ETH_HLEN;
 module_param(myri10ge_initial_mtu, int, S_IRUGO);
-MODULE_PARM_DESC(myri10ge_initial_mtu, "Initial MTU\n");
+MODULE_PARM_DESC(myri10ge_initial_mtu, "Initial MTU");
 
 static int myri10ge_napi_weight = 64;
 module_param(myri10ge_napi_weight, int, S_IRUGO);
-MODULE_PARM_DESC(myri10ge_napi_weight, "Set NAPI weight\n");
+MODULE_PARM_DESC(myri10ge_napi_weight, "Set NAPI weight");
 
 static int myri10ge_watchdog_timeout = 1;
 module_param(myri10ge_watchdog_timeout, int, S_IRUGO);
-MODULE_PARM_DESC(myri10ge_watchdog_timeout, "Set watchdog timeout\n");
+MODULE_PARM_DESC(myri10ge_watchdog_timeout, "Set watchdog timeout");
 
 static int myri10ge_max_irq_loops = 1048576;
 module_param(myri10ge_max_irq_loops, int, S_IRUGO);
 MODULE_PARM_DESC(myri10ge_max_irq_loops,
-                "Set stuck legacy IRQ detection threshold\n");
+                "Set stuck legacy IRQ detection threshold");
 
 #define MYRI10GE_MSG_DEFAULT NETIF_MSG_LINK
 
@@ -266,6 +314,33 @@ static int myri10ge_debug = -1;    /* defaults above */
 module_param(myri10ge_debug, int, 0);
 MODULE_PARM_DESC(myri10ge_debug, "Debug level (0=none,...,16=all)");
 
+static int myri10ge_lro = 1;
+module_param(myri10ge_lro, int, S_IRUGO);
+MODULE_PARM_DESC(myri10ge_lro, "Enable large receive offload");
+
+static int myri10ge_lro_max_pkts = MYRI10GE_LRO_MAX_PKTS;
+module_param(myri10ge_lro_max_pkts, int, S_IRUGO);
+MODULE_PARM_DESC(myri10ge_lro_max_pkts,
+                "Number of LRO packets to be aggregated");
+
+static int myri10ge_fill_thresh = 256;
+module_param(myri10ge_fill_thresh, int, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(myri10ge_fill_thresh, "Number of empty rx slots allowed");
+
+static int myri10ge_reset_recover = 1;
+
+static int myri10ge_max_slices = 1;
+module_param(myri10ge_max_slices, int, S_IRUGO);
+MODULE_PARM_DESC(myri10ge_max_slices, "Max tx/rx queues");
+
+static int myri10ge_rss_hash = MXGEFW_RSS_HASH_TYPE_SRC_PORT;
+module_param(myri10ge_rss_hash, int, S_IRUGO);
+MODULE_PARM_DESC(myri10ge_rss_hash, "Type of RSS hashing to do");
+
+static int myri10ge_dca = 1;
+module_param(myri10ge_dca, int, S_IRUGO);
+MODULE_PARM_DESC(myri10ge_dca, "Enable DCA if possible");
+
 #define MYRI10GE_FW_OFFSET 1024*1024
 #define MYRI10GE_HIGHPART_TO_U32(X) \
 (sizeof (X) == 8) ? ((u32)((u64)(X) >> 32)) : (0)
@@ -273,6 +348,14 @@ MODULE_PARM_DESC(myri10ge_debug, "Debug level (0=none,...,16=all)");
 
 #define myri10ge_pio_copy(to,from,size) __iowrite64_copy(to,from,size/8)
 
+static void myri10ge_set_multicast_list(struct net_device *dev);
+static int myri10ge_sw_tso(struct sk_buff *skb, struct net_device *dev);
+
+static inline void put_be32(__be32 val, __be32 __iomem * p)
+{
+       __raw_writel((__force __u32) val, (__force void __iomem *)p);
+}
+
 static int
 myri10ge_send_cmd(struct myri10ge_priv *mgp, u32 cmd,
                  struct myri10ge_cmd *data, int atomic)
@@ -296,7 +379,7 @@ myri10ge_send_cmd(struct myri10ge_priv *mgp, u32 cmd,
 
        buf->response_addr.low = htonl(dma_low);
        buf->response_addr.high = htonl(dma_high);
-       response->result = MYRI10GE_NO_RESPONSE_RESULT;
+       response->result = htonl(MYRI10GE_NO_RESPONSE_RESULT);
        mb();
        myri10ge_pio_copy(cmd_addr, buf, sizeof(*buf));
 
@@ -311,14 +394,16 @@ myri10ge_send_cmd(struct myri10ge_priv *mgp, u32 cmd,
                 * (1ms will be enough for those commands) */
                for (sleep_total = 0;
                     sleep_total < 1000
-                    && response->result == MYRI10GE_NO_RESPONSE_RESULT;
-                    sleep_total += 10)
+                    && response->result == htonl(MYRI10GE_NO_RESPONSE_RESULT);
+                    sleep_total += 10) {
                        udelay(10);
+                       mb();
+               }
        } else {
                /* use msleep for most command */
                for (sleep_total = 0;
                     sleep_total < 15
-                    && response->result == MYRI10GE_NO_RESPONSE_RESULT;
+                    && response->result == htonl(MYRI10GE_NO_RESPONSE_RESULT);
                     sleep_total++)
                        msleep(1);
        }
@@ -331,6 +416,8 @@ myri10ge_send_cmd(struct myri10ge_priv *mgp, u32 cmd,
                        return 0;
                } else if (result == MXGEFW_CMD_UNKNOWN) {
                        return -ENOSYS;
+               } else if (result == MXGEFW_CMD_ERROR_UNALIGNED) {
+                       return -E2BIG;
                } else {
                        dev_err(&mgp->pdev->dev,
                                "command %d failed, result = %d\n",
@@ -371,6 +458,10 @@ static int myri10ge_read_mac_addr(struct myri10ge_priv *mgp)
                                ptr += 1;
                        }
                }
+               if (memcmp(ptr, "PC=", 3) == 0) {
+                       ptr += 3;
+                       mgp->product_code_string = ptr;
+               }
                if (memcmp((const void *)ptr, "SN=", 3) == 0) {
                        ptr += 3;
                        mgp->serial_number = simple_strtoul(ptr, &ptr, 10);
@@ -393,7 +484,7 @@ abort:
 static void myri10ge_dummy_rdma(struct myri10ge_priv *mgp, int enable)
 {
        char __iomem *submit;
-       u32 buf[16];
+       __be32 buf[16] __attribute__ ((__aligned__(8)));
        u32 dma_low, dma_high;
        int i;
 
@@ -410,7 +501,7 @@ static void myri10ge_dummy_rdma(struct myri10ge_priv *mgp, int enable)
 
        buf[0] = htonl(dma_high);       /* confirm addr MSW */
        buf[1] = htonl(dma_low);        /* confirm addr LSW */
-       buf[2] = htonl(MYRI10GE_NO_CONFIRM_DATA);       /* confirm data */
+       buf[2] = MYRI10GE_NO_CONFIRM_DATA;      /* confirm data */
        buf[3] = htonl(dma_high);       /* dummy addr MSW */
        buf[4] = htonl(dma_low);        /* dummy addr LSW */
        buf[5] = htonl(enable); /* enable? */
@@ -430,7 +521,6 @@ myri10ge_validate_firmware(struct myri10ge_priv *mgp,
                           struct mcp_gen_header *hdr)
 {
        struct device *dev = &mgp->pdev->dev;
-       int major, minor;
 
        /* check firmware type */
        if (ntohl(hdr->mcp_type) != MCP_TYPE_ETH) {
@@ -441,9 +531,11 @@ myri10ge_validate_firmware(struct myri10ge_priv *mgp,
        /* save firmware version for ethtool */
        strncpy(mgp->fw_version, hdr->version, sizeof(mgp->fw_version));
 
-       sscanf(mgp->fw_version, "%d.%d", &major, &minor);
+       sscanf(mgp->fw_version, "%d.%d.%d", &mgp->fw_ver_major,
+              &mgp->fw_ver_minor, &mgp->fw_ver_tiny);
 
-       if (!(major == MXGEFW_VERSION_MAJOR && minor == MXGEFW_VERSION_MINOR)) {
+       if (!(mgp->fw_ver_major == MXGEFW_VERSION_MAJOR
+             && mgp->fw_ver_minor == MXGEFW_VERSION_MINOR)) {
                dev_err(dev, "Found firmware version %s\n", mgp->fw_version);
                dev_err(dev, "Driver needs %d.%d\n", MXGEFW_VERSION_MAJOR,
                        MXGEFW_VERSION_MINOR);
@@ -457,6 +549,7 @@ static int myri10ge_load_hotplug_firmware(struct myri10ge_priv *mgp, u32 * size)
        unsigned crc, reread_crc;
        const struct firmware *fw;
        struct device *dev = &mgp->pdev->dev;
+       unsigned char *fw_readback;
        struct mcp_gen_header *hdr;
        size_t hdr_offset;
        int status;
@@ -479,7 +572,7 @@ static int myri10ge_load_hotplug_firmware(struct myri10ge_priv *mgp, u32 * size)
        }
 
        /* check id */
-       hdr_offset = ntohl(*(u32 *) (fw->data + MCP_HEADER_PTR_OFFSET));
+       hdr_offset = ntohl(*(__be32 *) (fw->data + MCP_HEADER_PTR_OFFSET));
        if ((hdr_offset & 3) || hdr_offset + sizeof(*hdr) > fw->size) {
                dev_err(dev, "Bad firmware file\n");
                status = -EINVAL;
@@ -499,9 +592,15 @@ static int myri10ge_load_hotplug_firmware(struct myri10ge_priv *mgp, u32 * size)
                mb();
                readb(mgp->sram);
        }
+       fw_readback = vmalloc(fw->size);
+       if (!fw_readback) {
+               status = -ENOMEM;
+               goto abort_with_fw;
+       }
        /* corruption checking is good for parity recovery and buggy chipset */
-       memcpy_fromio(fw->data, mgp->sram + MYRI10GE_FW_OFFSET, fw->size);
-       reread_crc = crc32(~0, fw->data, fw->size);
+       memcpy_fromio(fw_readback, mgp->sram + MYRI10GE_FW_OFFSET, fw->size);
+       reread_crc = crc32(~0, fw_readback, fw->size);
+       vfree(fw_readback);
        if (crc != reread_crc) {
                dev_err(dev, "CRC failed(fw-len=%u), got 0x%x (expect 0x%x)\n",
                        (unsigned)fw->size, reread_crc, crc);
@@ -526,7 +625,7 @@ static int myri10ge_adopt_running_firmware(struct myri10ge_priv *mgp)
        int status;
 
        /* find running firmware header */
-       hdr_offset = ntohl(__raw_readl(mgp->sram + MCP_HEADER_PTR_OFFSET));
+       hdr_offset = swab32(readl(mgp->sram + MCP_HEADER_PTR_OFFSET));
 
        if ((hdr_offset & 3) || hdr_offset + sizeof(*hdr) > mgp->sram_size) {
                dev_err(dev, "Running firmware has bad header offset (%d)\n",
@@ -544,19 +643,59 @@ static int myri10ge_adopt_running_firmware(struct myri10ge_priv *mgp)
        memcpy_fromio(hdr, mgp->sram + hdr_offset, bytes);
        status = myri10ge_validate_firmware(mgp, hdr);
        kfree(hdr);
+
+       /* check to see if adopted firmware has bug where adopting
+        * it will cause broadcasts to be filtered unless the NIC
+        * is kept in ALLMULTI mode */
+       if (mgp->fw_ver_major == 1 && mgp->fw_ver_minor == 4 &&
+           mgp->fw_ver_tiny >= 4 && mgp->fw_ver_tiny <= 11) {
+               mgp->adopted_rx_filter_bug = 1;
+               dev_warn(dev, "Adopting fw %d.%d.%d: "
+                        "working around rx filter bug\n",
+                        mgp->fw_ver_major, mgp->fw_ver_minor,
+                        mgp->fw_ver_tiny);
+       }
        return status;
 }
 
-static int myri10ge_load_firmware(struct myri10ge_priv *mgp)
+static int myri10ge_get_firmware_capabilities(struct myri10ge_priv *mgp)
+{
+       struct myri10ge_cmd cmd;
+       int status;
+
+       /* probe for IPv6 TSO support */
+       mgp->features = NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_TSO;
+       status = myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_MAX_TSO6_HDR_SIZE,
+                                  &cmd, 0);
+       if (status == 0) {
+               mgp->max_tso6 = cmd.data0;
+               mgp->features |= NETIF_F_TSO6;
+       }
+
+       status = myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_RX_RING_SIZE, &cmd, 0);
+       if (status != 0) {
+               dev_err(&mgp->pdev->dev,
+                       "failed MXGEFW_CMD_GET_RX_RING_SIZE\n");
+               return -ENXIO;
+       }
+
+       mgp->max_intr_slots = 2 * (cmd.data0 / sizeof(struct mcp_dma_addr));
+
+       return 0;
+}
+
+static int myri10ge_load_firmware(struct myri10ge_priv *mgp, int adopt)
 {
        char __iomem *submit;
-       u32 buf[16];
+       __be32 buf[16] __attribute__ ((__aligned__(8)));
        u32 dma_low, dma_high, size;
        int status, i;
 
        size = 0;
        status = myri10ge_load_hotplug_firmware(mgp, &size);
        if (status) {
+               if (!adopt)
+                       return status;
                dev_warn(&mgp->pdev->dev, "hotplug firmware loading failed\n");
 
                /* Do not attempt to adopt firmware if there
@@ -572,7 +711,7 @@ static int myri10ge_load_firmware(struct myri10ge_priv *mgp)
                }
                dev_info(&mgp->pdev->dev,
                         "Successfully adopted running firmware\n");
-               if (mgp->tx.boundary == 4096) {
+               if (mgp->tx_boundary == 4096) {
                        dev_warn(&mgp->pdev->dev,
                                 "Using firmware currently running on NIC"
                                 ".  For optimal\n");
@@ -583,7 +722,9 @@ static int myri10ge_load_firmware(struct myri10ge_priv *mgp)
                }
 
                mgp->fw_name = "adopted";
-               mgp->tx.boundary = 2048;
+               mgp->tx_boundary = 2048;
+               myri10ge_dummy_rdma(mgp, 1);
+               status = myri10ge_get_firmware_capabilities(mgp);
                return status;
        }
 
@@ -600,7 +741,7 @@ static int myri10ge_load_firmware(struct myri10ge_priv *mgp)
 
        buf[0] = htonl(dma_high);       /* confirm addr MSW */
        buf[1] = htonl(dma_low);        /* confirm addr LSW */
-       buf[2] = htonl(MYRI10GE_NO_CONFIRM_DATA);       /* confirm data */
+       buf[2] = MYRI10GE_NO_CONFIRM_DATA;      /* confirm data */
 
        /* FIX: All newest firmware should un-protect the bottom of
         * the sram before handoff. However, the very first interfaces
@@ -618,18 +759,18 @@ static int myri10ge_load_firmware(struct myri10ge_priv *mgp)
        msleep(1);
        mb();
        i = 0;
-       while (mgp->cmd->data != MYRI10GE_NO_CONFIRM_DATA && i < 20) {
-               msleep(1);
+       while (mgp->cmd->data != MYRI10GE_NO_CONFIRM_DATA && i < 9) {
+               msleep(1 << i);
                i++;
        }
        if (mgp->cmd->data != MYRI10GE_NO_CONFIRM_DATA) {
                dev_err(&mgp->pdev->dev, "handoff failed\n");
                return -ENXIO;
        }
-       dev_info(&mgp->pdev->dev, "handoff confirmed\n");
        myri10ge_dummy_rdma(mgp, 1);
+       status = myri10ge_get_firmware_capabilities(mgp);
 
-       return 0;
+       return status;
 }
 
 static int myri10ge_update_mac_address(struct myri10ge_priv *mgp, u8 * addr)
@@ -677,12 +818,82 @@ myri10ge_change_promisc(struct myri10ge_priv *mgp, int promisc, int atomic)
                       mgp->dev->name);
 }
 
-static int myri10ge_reset(struct myri10ge_priv *mgp)
+static int myri10ge_dma_test(struct myri10ge_priv *mgp, int test_type)
 {
        struct myri10ge_cmd cmd;
        int status;
-       size_t bytes;
        u32 len;
+       struct page *dmatest_page;
+       dma_addr_t dmatest_bus;
+       char *test = " ";
+
+       dmatest_page = alloc_page(GFP_KERNEL);
+       if (!dmatest_page)
+               return -ENOMEM;
+       dmatest_bus = pci_map_page(mgp->pdev, dmatest_page, 0, PAGE_SIZE,
+                                  DMA_BIDIRECTIONAL);
+
+       /* Run a small DMA test.
+        * The magic multipliers to the length tell the firmware
+        * to do DMA read, write, or read+write tests.  The
+        * results are returned in cmd.data0.  The upper 16
+        * bits or the return is the number of transfers completed.
+        * The lower 16 bits is the time in 0.5us ticks that the
+        * transfers took to complete.
+        */
+
+       len = mgp->tx_boundary;
+
+       cmd.data0 = MYRI10GE_LOWPART_TO_U32(dmatest_bus);
+       cmd.data1 = MYRI10GE_HIGHPART_TO_U32(dmatest_bus);
+       cmd.data2 = len * 0x10000;
+       status = myri10ge_send_cmd(mgp, test_type, &cmd, 0);
+       if (status != 0) {
+               test = "read";
+               goto abort;
+       }
+       mgp->read_dma = ((cmd.data0 >> 16) * len * 2) / (cmd.data0 & 0xffff);
+       cmd.data0 = MYRI10GE_LOWPART_TO_U32(dmatest_bus);
+       cmd.data1 = MYRI10GE_HIGHPART_TO_U32(dmatest_bus);
+       cmd.data2 = len * 0x1;
+       status = myri10ge_send_cmd(mgp, test_type, &cmd, 0);
+       if (status != 0) {
+               test = "write";
+               goto abort;
+       }
+       mgp->write_dma = ((cmd.data0 >> 16) * len * 2) / (cmd.data0 & 0xffff);
+
+       cmd.data0 = MYRI10GE_LOWPART_TO_U32(dmatest_bus);
+       cmd.data1 = MYRI10GE_HIGHPART_TO_U32(dmatest_bus);
+       cmd.data2 = len * 0x10001;
+       status = myri10ge_send_cmd(mgp, test_type, &cmd, 0);
+       if (status != 0) {
+               test = "read/write";
+               goto abort;
+       }
+       mgp->read_write_dma = ((cmd.data0 >> 16) * len * 2 * 2) /
+           (cmd.data0 & 0xffff);
+
+abort:
+       pci_unmap_page(mgp->pdev, dmatest_bus, PAGE_SIZE, DMA_BIDIRECTIONAL);
+       put_page(dmatest_page);
+
+       if (status != 0 && test_type != MXGEFW_CMD_UNALIGNED_TEST)
+               dev_warn(&mgp->pdev->dev, "DMA %s benchmark failed: %d\n",
+                        test, status);
+
+       return status;
+}
+
+static int myri10ge_reset(struct myri10ge_priv *mgp)
+{
+       struct myri10ge_cmd cmd;
+       struct myri10ge_slice_state *ss;
+       int i, status;
+       size_t bytes;
+#ifdef CONFIG_DCA
+       unsigned long dca_tag_off;
+#endif
 
        /* try to send a reset command to the card to see if it
         * is alive */
@@ -693,319 +904,420 @@ static int myri10ge_reset(struct myri10ge_priv *mgp)
                return -ENXIO;
        }
 
+       (void)myri10ge_dma_test(mgp, MXGEFW_DMA_TEST);
+       /*
+        * Use non-ndis mcp_slot (eg, 4 bytes total,
+        * no toeplitz hash value returned.  Older firmware will
+        * not understand this command, but will use the correct
+        * sized mcp_slot, so we ignore error returns
+        */
+       cmd.data0 = MXGEFW_RSS_MCP_SLOT_TYPE_MIN;
+       (void)myri10ge_send_cmd(mgp, MXGEFW_CMD_SET_RSS_MCP_SLOT_TYPE, &cmd, 0);
+
        /* Now exchange information about interrupts  */
 
-       bytes = myri10ge_max_intr_slots * sizeof(*mgp->rx_done.entry);
-       memset(mgp->rx_done.entry, 0, bytes);
+       bytes = mgp->max_intr_slots * sizeof(*mgp->ss[0].rx_done.entry);
        cmd.data0 = (u32) bytes;
        status = myri10ge_send_cmd(mgp, MXGEFW_CMD_SET_INTRQ_SIZE, &cmd, 0);
-       cmd.data0 = MYRI10GE_LOWPART_TO_U32(mgp->rx_done.bus);
-       cmd.data1 = MYRI10GE_HIGHPART_TO_U32(mgp->rx_done.bus);
-       status |= myri10ge_send_cmd(mgp, MXGEFW_CMD_SET_INTRQ_DMA, &cmd, 0);
+
+       /*
+        * Even though we already know how many slices are supported
+        * via myri10ge_probe_slices() MXGEFW_CMD_GET_MAX_RSS_QUEUES
+        * has magic side effects, and must be called after a reset.
+        * It must be called prior to calling any RSS related cmds,
+        * including assigning an interrupt queue for anything but
+        * slice 0.  It must also be called *after*
+        * MXGEFW_CMD_SET_INTRQ_SIZE, since the intrq size is used by
+        * the firmware to compute offsets.
+        */
+
+       if (mgp->num_slices > 1) {
+
+               /* ask the maximum number of slices it supports */
+               status = myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_MAX_RSS_QUEUES,
+                                          &cmd, 0);
+               if (status != 0) {
+                       dev_err(&mgp->pdev->dev,
+                               "failed to get number of slices\n");
+               }
+
+               /*
+                * MXGEFW_CMD_ENABLE_RSS_QUEUES must be called prior
+                * to setting up the interrupt queue DMA
+                */
+
+               cmd.data0 = mgp->num_slices;
+               cmd.data1 = 1;  /* use MSI-X */
+               status = myri10ge_send_cmd(mgp, MXGEFW_CMD_ENABLE_RSS_QUEUES,
+                                          &cmd, 0);
+               if (status != 0) {
+                       dev_err(&mgp->pdev->dev,
+                               "failed to set number of slices\n");
+
+                       return status;
+               }
+       }
+       for (i = 0; i < mgp->num_slices; i++) {
+               ss = &mgp->ss[i];
+               cmd.data0 = MYRI10GE_LOWPART_TO_U32(ss->rx_done.bus);
+               cmd.data1 = MYRI10GE_HIGHPART_TO_U32(ss->rx_done.bus);
+               cmd.data2 = i;
+               status |= myri10ge_send_cmd(mgp, MXGEFW_CMD_SET_INTRQ_DMA,
+                                           &cmd, 0);
+       };
 
        status |=
            myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_IRQ_ACK_OFFSET, &cmd, 0);
-       mgp->irq_claim = (__iomem u32 *) (mgp->sram + cmd.data0);
-       if (!mgp->msi_enabled) {
-               status |= myri10ge_send_cmd
-                   (mgp, MXGEFW_CMD_GET_IRQ_DEASSERT_OFFSET, &cmd, 0);
-               mgp->irq_deassert = (__iomem u32 *) (mgp->sram + cmd.data0);
-
+       for (i = 0; i < mgp->num_slices; i++) {
+               ss = &mgp->ss[i];
+               ss->irq_claim =
+                   (__iomem __be32 *) (mgp->sram + cmd.data0 + 8 * i);
        }
+       status |= myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_IRQ_DEASSERT_OFFSET,
+                                   &cmd, 0);
+       mgp->irq_deassert = (__iomem __be32 *) (mgp->sram + cmd.data0);
+
        status |= myri10ge_send_cmd
            (mgp, MXGEFW_CMD_GET_INTR_COAL_DELAY_OFFSET, &cmd, 0);
-       mgp->intr_coal_delay_ptr = (__iomem u32 *) (mgp->sram + cmd.data0);
+       mgp->intr_coal_delay_ptr = (__iomem __be32 *) (mgp->sram + cmd.data0);
        if (status != 0) {
                dev_err(&mgp->pdev->dev, "failed set interrupt parameters\n");
                return status;
        }
-       __raw_writel(htonl(mgp->intr_coal_delay), mgp->intr_coal_delay_ptr);
+       put_be32(htonl(mgp->intr_coal_delay), mgp->intr_coal_delay_ptr);
 
-       /* Run a small DMA test.
-        * The magic multipliers to the length tell the firmware
-        * to do DMA read, write, or read+write tests.  The
-        * results are returned in cmd.data0.  The upper 16
-        * bits or the return is the number of transfers completed.
-        * The lower 16 bits is the time in 0.5us ticks that the
-        * transfers took to complete.
-        */
-
-       len = mgp->tx.boundary;
-
-       cmd.data0 = MYRI10GE_LOWPART_TO_U32(mgp->rx_done.bus);
-       cmd.data1 = MYRI10GE_HIGHPART_TO_U32(mgp->rx_done.bus);
-       cmd.data2 = len * 0x10000;
-       status = myri10ge_send_cmd(mgp, MXGEFW_DMA_TEST, &cmd, 0);
-       if (status == 0)
-               mgp->read_dma = ((cmd.data0 >> 16) * len * 2) /
-                   (cmd.data0 & 0xffff);
-       else
-               dev_warn(&mgp->pdev->dev, "DMA read benchmark failed: %d\n",
-                        status);
-       cmd.data0 = MYRI10GE_LOWPART_TO_U32(mgp->rx_done.bus);
-       cmd.data1 = MYRI10GE_HIGHPART_TO_U32(mgp->rx_done.bus);
-       cmd.data2 = len * 0x1;
-       status = myri10ge_send_cmd(mgp, MXGEFW_DMA_TEST, &cmd, 0);
-       if (status == 0)
-               mgp->write_dma = ((cmd.data0 >> 16) * len * 2) /
-                   (cmd.data0 & 0xffff);
-       else
-               dev_warn(&mgp->pdev->dev, "DMA write benchmark failed: %d\n",
-                        status);
-
-       cmd.data0 = MYRI10GE_LOWPART_TO_U32(mgp->rx_done.bus);
-       cmd.data1 = MYRI10GE_HIGHPART_TO_U32(mgp->rx_done.bus);
-       cmd.data2 = len * 0x10001;
-       status = myri10ge_send_cmd(mgp, MXGEFW_DMA_TEST, &cmd, 0);
-       if (status == 0)
-               mgp->read_write_dma = ((cmd.data0 >> 16) * len * 2 * 2) /
-                   (cmd.data0 & 0xffff);
-       else
-               dev_warn(&mgp->pdev->dev,
-                        "DMA read/write benchmark failed: %d\n", status);
-
-       memset(mgp->rx_done.entry, 0, bytes);
+#ifdef CONFIG_DCA
+       status = myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_DCA_OFFSET, &cmd, 0);
+       dca_tag_off = cmd.data0;
+       for (i = 0; i < mgp->num_slices; i++) {
+               ss = &mgp->ss[i];
+               if (status == 0) {
+                       ss->dca_tag = (__iomem __be32 *)
+                           (mgp->sram + dca_tag_off + 4 * i);
+               } else {
+                       ss->dca_tag = NULL;
+               }
+       }
+#endif                         /* CONFIG_DCA */
 
        /* reset mcp/driver shared state back to 0 */
-       mgp->tx.req = 0;
-       mgp->tx.done = 0;
-       mgp->tx.pkt_start = 0;
-       mgp->tx.pkt_done = 0;
-       mgp->rx_big.cnt = 0;
-       mgp->rx_small.cnt = 0;
-       mgp->rx_done.idx = 0;
-       mgp->rx_done.cnt = 0;
+
        mgp->link_changes = 0;
+       for (i = 0; i < mgp->num_slices; i++) {
+               ss = &mgp->ss[i];
+
+               memset(ss->rx_done.entry, 0, bytes);
+               ss->tx.req = 0;
+               ss->tx.done = 0;
+               ss->tx.pkt_start = 0;
+               ss->tx.pkt_done = 0;
+               ss->rx_big.cnt = 0;
+               ss->rx_small.cnt = 0;
+               ss->rx_done.idx = 0;
+               ss->rx_done.cnt = 0;
+               ss->tx.wake_queue = 0;
+               ss->tx.stop_queue = 0;
+       }
+
        status = myri10ge_update_mac_address(mgp, mgp->dev->dev_addr);
-       myri10ge_change_promisc(mgp, 0, 0);
        myri10ge_change_pause(mgp, mgp->pause);
+       myri10ge_set_multicast_list(mgp->dev);
        return status;
 }
 
-static inline void
-myri10ge_submit_8rx(struct mcp_kreq_ether_recv __iomem * dst,
-                   struct mcp_kreq_ether_recv *src)
+#ifdef CONFIG_DCA
+static void
+myri10ge_write_dca(struct myri10ge_slice_state *ss, int cpu, int tag)
 {
-       u32 low;
-
-       low = src->addr_low;
-       src->addr_low = DMA_32BIT_MASK;
-       myri10ge_pio_copy(dst, src, 8 * sizeof(*src));
-       mb();
-       src->addr_low = low;
-       __raw_writel(low, &dst->addr_low);
-       mb();
+       ss->cpu = cpu;
+       ss->cached_dca_tag = tag;
+       put_be32(htonl(tag), ss->dca_tag);
 }
 
-/*
- * Set of routines to get a new receive buffer.  Any buffer which
- * crosses a 4KB boundary must start on a 4KB boundary due to PCIe
- * wdma restrictions. We also try to align any smaller allocation to
- * at least a 16 byte boundary for efficiency.  We assume the linux
- * memory allocator works by powers of 2, and will not return memory
- * smaller than 2KB which crosses a 4KB boundary.  If it does, we fall
- * back to allocating 2x as much space as required.
- *
- * We intend to replace large (>4KB) skb allocations by using
- * pages directly and building a fraglist in the near future.
- */
-
-static inline struct sk_buff *myri10ge_alloc_big(struct net_device *dev,
-                                                int bytes)
+static inline void myri10ge_update_dca(struct myri10ge_slice_state *ss)
 {
-       struct sk_buff *skb;
-       unsigned long data, roundup;
+       int cpu = get_cpu();
+       int tag;
 
-       skb = netdev_alloc_skb(dev, bytes + 4096 + MXGEFW_PAD);
-       if (skb == NULL)
-               return NULL;
+       if (cpu != ss->cpu) {
+               tag = dca_get_tag(cpu);
+               if (ss->cached_dca_tag != tag)
+                       myri10ge_write_dca(ss, cpu, tag);
+       }
+       put_cpu();
+}
 
-       /* Correct skb->truesize so that socket buffer
-        * accounting is not confused the rounding we must
-        * do to satisfy alignment constraints.
-        */
-       skb->truesize -= 4096;
+static void myri10ge_setup_dca(struct myri10ge_priv *mgp)
+{
+       int err, i;
+       struct pci_dev *pdev = mgp->pdev;
 
-       data = (unsigned long)(skb->data);
-       roundup = (-data) & (4095);
-       skb_reserve(skb, roundup);
-       return skb;
+       if (mgp->ss[0].dca_tag == NULL || mgp->dca_enabled)
+               return;
+       if (!myri10ge_dca) {
+               dev_err(&pdev->dev, "dca disabled by administrator\n");
+               return;
+       }
+       err = dca_add_requester(&pdev->dev);
+       if (err) {
+               dev_err(&pdev->dev,
+                       "dca_add_requester() failed, err=%d\n", err);
+               return;
+       }
+       mgp->dca_enabled = 1;
+       for (i = 0; i < mgp->num_slices; i++)
+               myri10ge_write_dca(&mgp->ss[i], -1, 0);
 }
 
-/* Allocate 2x as much space as required and use whichever portion
- * does not cross a 4KB boundary */
-static inline struct sk_buff *myri10ge_alloc_small_safe(struct net_device *dev,
-                                                       unsigned int bytes)
+static void myri10ge_teardown_dca(struct myri10ge_priv *mgp)
 {
-       struct sk_buff *skb;
-       unsigned long data, boundary;
+       struct pci_dev *pdev = mgp->pdev;
+       int err;
 
-       skb = netdev_alloc_skb(dev, 2 * (bytes + MXGEFW_PAD) - 1);
-       if (unlikely(skb == NULL))
-               return NULL;
+       if (!mgp->dca_enabled)
+               return;
+       mgp->dca_enabled = 0;
+       err = dca_remove_requester(&pdev->dev);
+}
 
-       /* Correct skb->truesize so that socket buffer
-        * accounting is not confused the rounding we must
-        * do to satisfy alignment constraints.
-        */
-       skb->truesize -= bytes + MXGEFW_PAD;
+static int myri10ge_notify_dca_device(struct device *dev, void *data)
+{
+       struct myri10ge_priv *mgp;
+       unsigned long event;
 
-       data = (unsigned long)(skb->data);
-       boundary = (data + 4095UL) & ~4095UL;
-       if ((boundary - data) >= (bytes + MXGEFW_PAD))
-               return skb;
+       mgp = dev_get_drvdata(dev);
+       event = *(unsigned long *)data;
 
-       skb_reserve(skb, boundary - data);
-       return skb;
+       if (event == DCA_PROVIDER_ADD)
+               myri10ge_setup_dca(mgp);
+       else if (event == DCA_PROVIDER_REMOVE)
+               myri10ge_teardown_dca(mgp);
+       return 0;
 }
+#endif                         /* CONFIG_DCA */
 
-/* Allocate just enough space, and verify that the allocated
- * space does not cross a 4KB boundary */
-static inline struct sk_buff *myri10ge_alloc_small(struct net_device *dev,
-                                                  int bytes)
+static inline void
+myri10ge_submit_8rx(struct mcp_kreq_ether_recv __iomem * dst,
+                   struct mcp_kreq_ether_recv *src)
 {
-       struct sk_buff *skb;
-       unsigned long roundup, data, end;
+       __be32 low;
 
-       skb = netdev_alloc_skb(dev, bytes + 16 + MXGEFW_PAD);
-       if (unlikely(skb == NULL))
-               return NULL;
+       low = src->addr_low;
+       src->addr_low = htonl(DMA_32BIT_MASK);
+       myri10ge_pio_copy(dst, src, 4 * sizeof(*src));
+       mb();
+       myri10ge_pio_copy(dst + 4, src + 4, 4 * sizeof(*src));
+       mb();
+       src->addr_low = low;
+       put_be32(low, &dst->addr_low);
+       mb();
+}
+
+static inline void myri10ge_vlan_ip_csum(struct sk_buff *skb, __wsum hw_csum)
+{
+       struct vlan_hdr *vh = (struct vlan_hdr *)(skb->data);
 
-       /* Round allocated buffer to 16 byte boundary */
-       data = (unsigned long)(skb->data);
-       roundup = (-data) & 15UL;
-       skb_reserve(skb, roundup);
-       /* Verify that the data buffer does not cross a page boundary */
-       data = (unsigned long)(skb->data);
-       end = data + bytes + MXGEFW_PAD - 1;
-       if (unlikely(((end >> 12) != (data >> 12)) && (data & 4095UL))) {
-               printk(KERN_NOTICE
-                      "myri10ge_alloc_small: small skb crossed 4KB boundary\n");
-               myri10ge_skb_cross_4k = 1;
-               dev_kfree_skb_any(skb);
-               skb = myri10ge_alloc_small_safe(dev, bytes);
+       if ((skb->protocol == htons(ETH_P_8021Q)) &&
+           (vh->h_vlan_encapsulated_proto == htons(ETH_P_IP) ||
+            vh->h_vlan_encapsulated_proto == htons(ETH_P_IPV6))) {
+               skb->csum = hw_csum;
+               skb->ip_summed = CHECKSUM_COMPLETE;
        }
-       return skb;
 }
 
-static inline int
-myri10ge_getbuf(struct myri10ge_rx_buf *rx, struct myri10ge_priv *mgp,
-               int bytes, int idx)
+static inline void
+myri10ge_rx_skb_build(struct sk_buff *skb, u8 * va,
+                     struct skb_frag_struct *rx_frags, int len, int hlen)
 {
-       struct net_device *dev = mgp->dev;
-       struct pci_dev *pdev = mgp->pdev;
-       struct sk_buff *skb;
-       dma_addr_t bus;
-       int len, retval = 0;
+       struct skb_frag_struct *skb_frags;
+
+       skb->len = skb->data_len = len;
+       skb->truesize = len + sizeof(struct sk_buff);
+       /* attach the page(s) */
+
+       skb_frags = skb_shinfo(skb)->frags;
+       while (len > 0) {
+               memcpy(skb_frags, rx_frags, sizeof(*skb_frags));
+               len -= rx_frags->size;
+               skb_frags++;
+               rx_frags++;
+               skb_shinfo(skb)->nr_frags++;
+       }
+
+       /* pskb_may_pull is not available in irq context, but
+        * skb_pull() (for ether_pad and eth_type_trans()) requires
+        * the beginning of the packet in skb_headlen(), move it
+        * manually */
+       skb_copy_to_linear_data(skb, va, hlen);
+       skb_shinfo(skb)->frags[0].page_offset += hlen;
+       skb_shinfo(skb)->frags[0].size -= hlen;
+       skb->data_len -= hlen;
+       skb->tail += hlen;
+       skb_pull(skb, MXGEFW_PAD);
+}
 
-       bytes += VLAN_HLEN;     /* account for 802.1q vlan tag */
+static void
+myri10ge_alloc_rx_pages(struct myri10ge_priv *mgp, struct myri10ge_rx_buf *rx,
+                       int bytes, int watchdog)
+{
+       struct page *page;
+       int idx;
 
-       if ((bytes + MXGEFW_PAD) > (4096 - 16) /* linux overhead */ )
-               skb = myri10ge_alloc_big(dev, bytes);
-       else if (myri10ge_skb_cross_4k)
-               skb = myri10ge_alloc_small_safe(dev, bytes);
-       else
-               skb = myri10ge_alloc_small(dev, bytes);
+       if (unlikely(rx->watchdog_needed && !watchdog))
+               return;
 
-       if (unlikely(skb == NULL)) {
-               rx->alloc_fail++;
-               retval = -ENOBUFS;
-               goto done;
-       }
-
-       /* set len so that it only covers the area we
-        * need mapped for DMA */
-       len = bytes + MXGEFW_PAD;
-
-       bus = pci_map_single(pdev, skb->data, len, PCI_DMA_FROMDEVICE);
-       rx->info[idx].skb = skb;
-       pci_unmap_addr_set(&rx->info[idx], bus, bus);
-       pci_unmap_len_set(&rx->info[idx], len, len);
-       rx->shadow[idx].addr_low = htonl(MYRI10GE_LOWPART_TO_U32(bus));
-       rx->shadow[idx].addr_high = htonl(MYRI10GE_HIGHPART_TO_U32(bus));
-
-done:
-       /* copy 8 descriptors (64-bytes) to the mcp at a time */
-       if ((idx & 7) == 7) {
-               if (rx->wc_fifo == NULL)
+       /* try to refill entire ring */
+       while (rx->fill_cnt != (rx->cnt + rx->mask + 1)) {
+               idx = rx->fill_cnt & rx->mask;
+               if (rx->page_offset + bytes <= MYRI10GE_ALLOC_SIZE) {
+                       /* we can use part of previous page */
+                       get_page(rx->page);
+               } else {
+                       /* we need a new page */
+                       page =
+                           alloc_pages(GFP_ATOMIC | __GFP_COMP,
+                                       MYRI10GE_ALLOC_ORDER);
+                       if (unlikely(page == NULL)) {
+                               if (rx->fill_cnt - rx->cnt < 16)
+                                       rx->watchdog_needed = 1;
+                               return;
+                       }
+                       rx->page = page;
+                       rx->page_offset = 0;
+                       rx->bus = pci_map_page(mgp->pdev, page, 0,
+                                              MYRI10GE_ALLOC_SIZE,
+                                              PCI_DMA_FROMDEVICE);
+               }
+               rx->info[idx].page = rx->page;
+               rx->info[idx].page_offset = rx->page_offset;
+               /* note that this is the address of the start of the
+                * page */
+               pci_unmap_addr_set(&rx->info[idx], bus, rx->bus);
+               rx->shadow[idx].addr_low =
+                   htonl(MYRI10GE_LOWPART_TO_U32(rx->bus) + rx->page_offset);
+               rx->shadow[idx].addr_high =
+                   htonl(MYRI10GE_HIGHPART_TO_U32(rx->bus));
+
+               /* start next packet on a cacheline boundary */
+               rx->page_offset += SKB_DATA_ALIGN(bytes);
+
+#if MYRI10GE_ALLOC_SIZE > 4096
+               /* don't cross a 4KB boundary */
+               if ((rx->page_offset >> 12) !=
+                   ((rx->page_offset + bytes - 1) >> 12))
+                       rx->page_offset = (rx->page_offset + 4096) & ~4095;
+#endif
+               rx->fill_cnt++;
+
+               /* copy 8 descriptors to the firmware at a time */
+               if ((idx & 7) == 7) {
                        myri10ge_submit_8rx(&rx->lanai[idx - 7],
                                            &rx->shadow[idx - 7]);
-               else {
-                       mb();
-                       myri10ge_pio_copy(rx->wc_fifo,
-                                         &rx->shadow[idx - 7], 64);
                }
        }
-       return retval;
 }
 
-static inline void myri10ge_vlan_ip_csum(struct sk_buff *skb, u16 hw_csum)
+static inline void
+myri10ge_unmap_rx_page(struct pci_dev *pdev,
+                      struct myri10ge_rx_buffer_state *info, int bytes)
 {
-       struct vlan_hdr *vh = (struct vlan_hdr *)(skb->data);
-
-       if ((skb->protocol == ntohs(ETH_P_8021Q)) &&
-           (vh->h_vlan_encapsulated_proto == htons(ETH_P_IP) ||
-            vh->h_vlan_encapsulated_proto == htons(ETH_P_IPV6))) {
-               skb->csum = hw_csum;
-               skb->ip_summed = CHECKSUM_COMPLETE;
+       /* unmap the recvd page if we're the only or last user of it */
+       if (bytes >= MYRI10GE_ALLOC_SIZE / 2 ||
+           (info->page_offset + 2 * bytes) > MYRI10GE_ALLOC_SIZE) {
+               pci_unmap_page(pdev, (pci_unmap_addr(info, bus)
+                                     & ~(MYRI10GE_ALLOC_SIZE - 1)),
+                              MYRI10GE_ALLOC_SIZE, PCI_DMA_FROMDEVICE);
        }
 }
 
-static inline unsigned long
-myri10ge_rx_done(struct myri10ge_priv *mgp, struct myri10ge_rx_buf *rx,
-                int bytes, int len, int csum)
+#define MYRI10GE_HLEN 64       /* The number of bytes to copy from a
+                                * page into an skb */
+
+static inline int
+myri10ge_rx_done(struct myri10ge_slice_state *ss, struct myri10ge_rx_buf *rx,
+                int bytes, int len, __wsum csum)
 {
-       dma_addr_t bus;
+       struct myri10ge_priv *mgp = ss->mgp;
        struct sk_buff *skb;
-       int idx, unmap_len;
+       struct skb_frag_struct rx_frags[MYRI10GE_MAX_FRAGS_PER_FRAME];
+       int i, idx, hlen, remainder;
+       struct pci_dev *pdev = mgp->pdev;
+       struct net_device *dev = mgp->dev;
+       u8 *va;
 
+       len += MXGEFW_PAD;
        idx = rx->cnt & rx->mask;
-       rx->cnt++;
+       va = page_address(rx->info[idx].page) + rx->info[idx].page_offset;
+       prefetch(va);
+       /* Fill skb_frag_struct(s) with data from our receive */
+       for (i = 0, remainder = len; remainder > 0; i++) {
+               myri10ge_unmap_rx_page(pdev, &rx->info[idx], bytes);
+               rx_frags[i].page = rx->info[idx].page;
+               rx_frags[i].page_offset = rx->info[idx].page_offset;
+               if (remainder < MYRI10GE_ALLOC_SIZE)
+                       rx_frags[i].size = remainder;
+               else
+                       rx_frags[i].size = MYRI10GE_ALLOC_SIZE;
+               rx->cnt++;
+               idx = rx->cnt & rx->mask;
+               remainder -= MYRI10GE_ALLOC_SIZE;
+       }
 
-       /* save a pointer to the received skb */
-       skb = rx->info[idx].skb;
-       bus = pci_unmap_addr(&rx->info[idx], bus);
-       unmap_len = pci_unmap_len(&rx->info[idx], len);
+       if (mgp->csum_flag && myri10ge_lro) {
+               rx_frags[0].page_offset += MXGEFW_PAD;
+               rx_frags[0].size -= MXGEFW_PAD;
+               len -= MXGEFW_PAD;
+               lro_receive_frags(&ss->rx_done.lro_mgr, rx_frags,
+                                 /* opaque, will come back in get_frag_header */
+                                 len, len,
+                                 (void *)(__force unsigned long)csum, csum);
 
-       /* try to replace the received skb */
-       if (myri10ge_getbuf(rx, mgp, bytes, idx)) {
-               /* drop the frame -- the old skbuf is re-cycled */
-               mgp->stats.rx_dropped += 1;
-               return 0;
+               return 1;
        }
 
-       /* unmap the recvd skb */
-       pci_unmap_single(mgp->pdev, bus, unmap_len, PCI_DMA_FROMDEVICE);
+       hlen = MYRI10GE_HLEN > len ? len : MYRI10GE_HLEN;
 
-       /* mcp implicitly skips 1st bytes so that packet is properly
-        * aligned */
-       skb_reserve(skb, MXGEFW_PAD);
+       /* allocate an skb to attach the page(s) to. This is done
+        * after trying LRO, so as to avoid skb allocation overheads */
 
-       /* set the length of the frame */
-       skb_put(skb, len);
+       skb = netdev_alloc_skb(dev, MYRI10GE_HLEN + 16);
+       if (unlikely(skb == NULL)) {
+               mgp->stats.rx_dropped++;
+               do {
+                       i--;
+                       put_page(rx_frags[i].page);
+               } while (i != 0);
+               return 0;
+       }
+
+       /* Attach the pages to the skb, and trim off any padding */
+       myri10ge_rx_skb_build(skb, va, rx_frags, len, hlen);
+       if (skb_shinfo(skb)->frags[0].size <= 0) {
+               put_page(skb_shinfo(skb)->frags[0].page);
+               skb_shinfo(skb)->nr_frags = 0;
+       }
+       skb->protocol = eth_type_trans(skb, dev);
 
-       skb->protocol = eth_type_trans(skb, mgp->dev);
        if (mgp->csum_flag) {
-               if ((skb->protocol == ntohs(ETH_P_IP)) ||
-                   (skb->protocol == ntohs(ETH_P_IPV6))) {
-                       skb->csum = ntohs((u16) csum);
+               if ((skb->protocol == htons(ETH_P_IP)) ||
+                   (skb->protocol == htons(ETH_P_IPV6))) {
+                       skb->csum = csum;
                        skb->ip_summed = CHECKSUM_COMPLETE;
                } else
-                       myri10ge_vlan_ip_csum(skb, ntohs((u16) csum));
+                       myri10ge_vlan_ip_csum(skb, csum);
        }
-
        netif_receive_skb(skb);
-       mgp->dev->last_rx = jiffies;
+       dev->last_rx = jiffies;
        return 1;
 }
 
-static inline void myri10ge_tx_done(struct myri10ge_priv *mgp, int mcp_index)
+static inline void
+myri10ge_tx_done(struct myri10ge_slice_state *ss, int mcp_index)
 {
-       struct pci_dev *pdev = mgp->pdev;
-       struct myri10ge_tx_buf *tx = &mgp->tx;
+       struct pci_dev *pdev = ss->mgp->pdev;
+       struct myri10ge_tx_buf *tx = &ss->tx;
        struct sk_buff *skb;
        int idx, len;
-       int limit = 0;
 
        while (tx->pkt_done != mcp_index) {
                idx = tx->done & tx->mask;
@@ -1021,8 +1333,8 @@ static inline void myri10ge_tx_done(struct myri10ge_priv *mgp, int mcp_index)
                len = pci_unmap_len(&tx->info[idx], len);
                pci_unmap_len_set(&tx->info[idx], len, 0);
                if (skb) {
-                       mgp->stats.tx_bytes += skb->len;
-                       mgp->stats.tx_packets++;
+                       ss->stats.tx_bytes += skb->len;
+                       ss->stats.tx_packets++;
                        dev_kfree_skb_irq(skb);
                        if (len)
                                pci_unmap_single(pdev,
@@ -1036,67 +1348,76 @@ static inline void myri10ge_tx_done(struct myri10ge_priv *mgp, int mcp_index)
                                                              bus), len,
                                               PCI_DMA_TODEVICE);
                }
-
-               /* limit potential for livelock by only handling
-                * 2 full tx rings per call */
-               if (unlikely(++limit > 2 * tx->mask))
-                       break;
        }
        /* start the queue if we've stopped it */
-       if (netif_queue_stopped(mgp->dev)
+       if (netif_queue_stopped(ss->dev)
            && tx->req - tx->done < (tx->mask >> 1)) {
-               mgp->wake_queue++;
-               netif_wake_queue(mgp->dev);
+               tx->wake_queue++;
+               netif_wake_queue(ss->dev);
        }
 }
 
-static inline void myri10ge_clean_rx_done(struct myri10ge_priv *mgp, int *limit)
+static inline int
+myri10ge_clean_rx_done(struct myri10ge_slice_state *ss, int budget)
 {
-       struct myri10ge_rx_done *rx_done = &mgp->rx_done;
+       struct myri10ge_rx_done *rx_done = &ss->rx_done;
+       struct myri10ge_priv *mgp = ss->mgp;
        unsigned long rx_bytes = 0;
        unsigned long rx_packets = 0;
        unsigned long rx_ok;
 
        int idx = rx_done->idx;
        int cnt = rx_done->cnt;
+       int work_done = 0;
        u16 length;
-       u16 checksum;
+       __wsum checksum;
 
-       while (rx_done->entry[idx].length != 0 && *limit != 0) {
+       while (rx_done->entry[idx].length != 0 && work_done < budget) {
                length = ntohs(rx_done->entry[idx].length);
                rx_done->entry[idx].length = 0;
-               checksum = ntohs(rx_done->entry[idx].checksum);
+               checksum = csum_unfold(rx_done->entry[idx].checksum);
                if (length <= mgp->small_bytes)
-                       rx_ok = myri10ge_rx_done(mgp, &mgp->rx_small,
+                       rx_ok = myri10ge_rx_done(ss, &ss->rx_small,
                                                 mgp->small_bytes,
                                                 length, checksum);
                else
-                       rx_ok = myri10ge_rx_done(mgp, &mgp->rx_big,
-                                                mgp->dev->mtu + ETH_HLEN,
+                       rx_ok = myri10ge_rx_done(ss, &ss->rx_big,
+                                                mgp->big_bytes,
                                                 length, checksum);
                rx_packets += rx_ok;
                rx_bytes += rx_ok * (unsigned long)length;
                cnt++;
-               idx = cnt & (myri10ge_max_intr_slots - 1);
-
-               /* limit potential for livelock by only handling a
-                * limited number of frames. */
-               (*limit)--;
+               idx = cnt & (mgp->max_intr_slots - 1);
+               work_done++;
        }
        rx_done->idx = idx;
        rx_done->cnt = cnt;
-       mgp->stats.rx_packets += rx_packets;
-       mgp->stats.rx_bytes += rx_bytes;
+       ss->stats.rx_packets += rx_packets;
+       ss->stats.rx_bytes += rx_bytes;
+
+       if (myri10ge_lro)
+               lro_flush_all(&rx_done->lro_mgr);
+
+       /* restock receive rings if needed */
+       if (ss->rx_small.fill_cnt - ss->rx_small.cnt < myri10ge_fill_thresh)
+               myri10ge_alloc_rx_pages(mgp, &ss->rx_small,
+                                       mgp->small_bytes + MXGEFW_PAD, 0);
+       if (ss->rx_big.fill_cnt - ss->rx_big.cnt < myri10ge_fill_thresh)
+               myri10ge_alloc_rx_pages(mgp, &ss->rx_big, mgp->big_bytes, 0);
+
+       return work_done;
 }
 
 static inline void myri10ge_check_statblock(struct myri10ge_priv *mgp)
 {
-       struct mcp_irq_data *stats = mgp->fw_stats;
+       struct mcp_irq_data *stats = mgp->ss[0].fw_stats;
 
        if (unlikely(stats->stats_updated)) {
-               if (mgp->link_state != stats->link_up) {
-                       mgp->link_state = stats->link_up;
-                       if (mgp->link_state) {
+               unsigned link_up = ntohl(stats->link_up);
+               if (mgp->link_state != link_up) {
+                       mgp->link_state = link_up;
+
+                       if (mgp->link_state == MXGEFW_LINK_UP) {
                                if (netif_msg_link(mgp))
                                        printk(KERN_INFO
                                               "myri10ge: %s: link up\n",
@@ -1106,16 +1427,19 @@ static inline void myri10ge_check_statblock(struct myri10ge_priv *mgp)
                        } else {
                                if (netif_msg_link(mgp))
                                        printk(KERN_INFO
-                                              "myri10ge: %s: link down\n",
-                                              mgp->dev->name);
+                                              "myri10ge: %s: link %s\n",
+                                              mgp->dev->name,
+                                              (link_up == MXGEFW_LINK_MYRINET ?
+                                               "mismatch (Myrinet detected)" :
+                                               "down"));
                                netif_carrier_off(mgp->dev);
                                mgp->link_changes++;
                        }
                }
                if (mgp->rdma_tags_available !=
-                   ntohl(mgp->fw_stats->rdma_tags_available)) {
+                   ntohl(stats->rdma_tags_available)) {
                        mgp->rdma_tags_available =
-                           ntohl(mgp->fw_stats->rdma_tags_available);
+                           ntohl(stats->rdma_tags_available);
                        printk(KERN_WARNING "myri10ge: %s: RDMA timed out! "
                               "%d tags left\n", mgp->dev->name,
                               mgp->rdma_tags_available);
@@ -1126,36 +1450,44 @@ static inline void myri10ge_check_statblock(struct myri10ge_priv *mgp)
        }
 }
 
-static int myri10ge_poll(struct net_device *netdev, int *budget)
+static int myri10ge_poll(struct napi_struct *napi, int budget)
 {
-       struct myri10ge_priv *mgp = netdev_priv(netdev);
-       struct myri10ge_rx_done *rx_done = &mgp->rx_done;
-       int limit, orig_limit, work_done;
+       struct myri10ge_slice_state *ss =
+           container_of(napi, struct myri10ge_slice_state, napi);
+       struct net_device *netdev = ss->mgp->dev;
+       int work_done;
+
+#ifdef CONFIG_DCA
+       if (ss->mgp->dca_enabled)
+               myri10ge_update_dca(ss);
+#endif
 
        /* process as many rx events as NAPI will allow */
-       limit = min(*budget, netdev->quota);
-       orig_limit = limit;
-       myri10ge_clean_rx_done(mgp, &limit);
-       work_done = orig_limit - limit;
-       *budget -= work_done;
-       netdev->quota -= work_done;
-
-       if (rx_done->entry[rx_done->idx].length == 0 || !netif_running(netdev)) {
-               netif_rx_complete(netdev);
-               __raw_writel(htonl(3), mgp->irq_claim);
-               return 0;
+       work_done = myri10ge_clean_rx_done(ss, budget);
+
+       if (work_done < budget) {
+               netif_rx_complete(netdev, napi);
+               put_be32(htonl(3), ss->irq_claim);
        }
-       return 1;
+       return work_done;
 }
 
 static irqreturn_t myri10ge_intr(int irq, void *arg)
 {
-       struct myri10ge_priv *mgp = arg;
-       struct mcp_irq_data *stats = mgp->fw_stats;
-       struct myri10ge_tx_buf *tx = &mgp->tx;
+       struct myri10ge_slice_state *ss = arg;
+       struct myri10ge_priv *mgp = ss->mgp;
+       struct mcp_irq_data *stats = ss->fw_stats;
+       struct myri10ge_tx_buf *tx = &ss->tx;
        u32 send_done_count;
        int i;
 
+       /* an interrupt on a non-zero slice is implicitly valid
+        * since MSI-X irqs are not shared */
+       if (ss != mgp->ss) {
+               netif_rx_schedule(ss->dev, &ss->napi);
+               return (IRQ_HANDLED);
+       }
+
        /* make sure it is our IRQ, and that the DMA has finished */
        if (unlikely(!stats->valid))
                return (IRQ_NONE);
@@ -1163,10 +1495,10 @@ static irqreturn_t myri10ge_intr(int irq, void *arg)
        /* low bit indicates receives are present, so schedule
         * napi poll handler */
        if (stats->valid & 1)
-               netif_rx_schedule(mgp->dev);
+               netif_rx_schedule(ss->dev, &ss->napi);
 
-       if (!mgp->msi_enabled) {
-               __raw_writel(0, mgp->irq_deassert);
+       if (!mgp->msi_enabled && !mgp->msix_enabled) {
+               put_be32(0, mgp->irq_deassert);
                if (!myri10ge_deassert_wait)
                        stats->valid = 0;
                mb();
@@ -1180,7 +1512,7 @@ static irqreturn_t myri10ge_intr(int irq, void *arg)
                /* check for transmit completes and receives */
                send_done_count = ntohl(stats->send_done_count);
                if (send_done_count != tx->pkt_done)
-                       myri10ge_tx_done(mgp, (int)send_done_count);
+                       myri10ge_tx_done(ss, (int)send_done_count);
                if (unlikely(i > myri10ge_max_irq_loops)) {
                        printk(KERN_WARNING "myri10ge: %s: irq stuck?\n",
                               mgp->dev->name);
@@ -1195,16 +1527,46 @@ static irqreturn_t myri10ge_intr(int irq, void *arg)
 
        myri10ge_check_statblock(mgp);
 
-       __raw_writel(htonl(3), mgp->irq_claim + 1);
+       put_be32(htonl(3), ss->irq_claim + 1);
        return (IRQ_HANDLED);
 }
 
 static int
 myri10ge_get_settings(struct net_device *netdev, struct ethtool_cmd *cmd)
 {
+       struct myri10ge_priv *mgp = netdev_priv(netdev);
+       char *ptr;
+       int i;
+
        cmd->autoneg = AUTONEG_DISABLE;
        cmd->speed = SPEED_10000;
        cmd->duplex = DUPLEX_FULL;
+
+       /*
+        * parse the product code to deterimine the interface type
+        * (CX4, XFP, Quad Ribbon Fiber) by looking at the character
+        * after the 3rd dash in the driver's cached copy of the
+        * EEPROM's product code string.
+        */
+       ptr = mgp->product_code_string;
+       if (ptr == NULL) {
+               printk(KERN_ERR "myri10ge: %s: Missing product code\n",
+                      netdev->name);
+               return 0;
+       }
+       for (i = 0; i < 3; i++, ptr++) {
+               ptr = strchr(ptr, '-');
+               if (ptr == NULL) {
+                       printk(KERN_ERR "myri10ge: %s: Invalid product "
+                              "code %s\n", netdev->name,
+                              mgp->product_code_string);
+                       return 0;
+               }
+       }
+       if (*ptr == 'R' || *ptr == 'Q') {
+               /* We've found either an XFP or quad ribbon fiber */
+               cmd->port = PORT_FIBRE;
+       }
        return 0;
 }
 
@@ -1223,6 +1585,7 @@ static int
 myri10ge_get_coalesce(struct net_device *netdev, struct ethtool_coalesce *coal)
 {
        struct myri10ge_priv *mgp = netdev_priv(netdev);
+
        coal->rx_coalesce_usecs = mgp->intr_coal_delay;
        return 0;
 }
@@ -1233,7 +1596,7 @@ myri10ge_set_coalesce(struct net_device *netdev, struct ethtool_coalesce *coal)
        struct myri10ge_priv *mgp = netdev_priv(netdev);
 
        mgp->intr_coal_delay = coal->rx_coalesce_usecs;
-       __raw_writel(htonl(mgp->intr_coal_delay), mgp->intr_coal_delay_ptr);
+       put_be32(htonl(mgp->intr_coal_delay), mgp->intr_coal_delay_ptr);
        return 0;
 }
 
@@ -1269,10 +1632,10 @@ myri10ge_get_ringparam(struct net_device *netdev,
 {
        struct myri10ge_priv *mgp = netdev_priv(netdev);
 
-       ring->rx_mini_max_pending = mgp->rx_small.mask + 1;
-       ring->rx_max_pending = mgp->rx_big.mask + 1;
+       ring->rx_mini_max_pending = mgp->ss[0].rx_small.mask + 1;
+       ring->rx_max_pending = mgp->ss[0].rx_big.mask + 1;
        ring->rx_jumbo_max_pending = 0;
-       ring->tx_max_pending = mgp->rx_small.mask + 1;
+       ring->tx_max_pending = mgp->ss[0].rx_small.mask + 1;
        ring->rx_mini_pending = ring->rx_mini_max_pending;
        ring->rx_pending = ring->rx_max_pending;
        ring->rx_jumbo_pending = ring->rx_jumbo_max_pending;
@@ -1282,6 +1645,7 @@ myri10ge_get_ringparam(struct net_device *netdev,
 static u32 myri10ge_get_rx_csum(struct net_device *netdev)
 {
        struct myri10ge_priv *mgp = netdev_priv(netdev);
+
        if (mgp->csum_flag)
                return 1;
        else
@@ -1291,6 +1655,7 @@ static u32 myri10ge_get_rx_csum(struct net_device *netdev)
 static int myri10ge_set_rx_csum(struct net_device *netdev, u32 csum_enabled)
 {
        struct myri10ge_priv *mgp = netdev_priv(netdev);
+
        if (csum_enabled)
                mgp->csum_flag = MXGEFW_FLAGS_CKSUM;
        else
@@ -1298,7 +1663,19 @@ static int myri10ge_set_rx_csum(struct net_device *netdev, u32 csum_enabled)
        return 0;
 }
 
-static const char myri10ge_gstrings_stats[][ETH_GSTRING_LEN] = {
+static int myri10ge_set_tso(struct net_device *netdev, u32 tso_enabled)
+{
+       struct myri10ge_priv *mgp = netdev_priv(netdev);
+       unsigned long flags = mgp->features & (NETIF_F_TSO6 | NETIF_F_TSO);
+
+       if (tso_enabled)
+               netdev->features |= flags;
+       else
+               netdev->features &= ~flags;
+       return 0;
+}
+
+static const char myri10ge_gstrings_main_stats[][ETH_GSTRING_LEN] = {
        "rx_packets", "tx_packets", "rx_bytes", "tx_bytes", "rx_errors",
        "tx_errors", "rx_dropped", "tx_dropped", "multicast", "collisions",
        "rx_length_errors", "rx_over_errors", "rx_crc_errors",
@@ -1306,34 +1683,64 @@ 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",
+       "tx_boundary", "WC", "irq", "MSI", "MSIX",
        "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",
-       "wake_queue", "stop_queue", "watchdog_resets", "tx_linearized",
+       "serial_number", "watchdog_resets",
+#ifdef CONFIG_DCA
+       "dca_capable", "dca_enabled",
+#endif
        "link_changes", "link_up", "dropped_link_overflow",
-       "dropped_link_error_or_filtered", "dropped_multicast_filtered",
+       "dropped_link_error_or_filtered",
+       "dropped_pause", "dropped_bad_phy", "dropped_bad_crc32",
+       "dropped_unicast_filtered", "dropped_multicast_filtered",
        "dropped_runt", "dropped_overrun", "dropped_no_small_buffer",
        "dropped_no_big_buffer"
 };
 
+static const char myri10ge_gstrings_slice_stats[][ETH_GSTRING_LEN] = {
+       "----------- slice ---------",
+       "tx_pkt_start", "tx_pkt_done", "tx_req", "tx_done",
+       "rx_small_cnt", "rx_big_cnt",
+       "wake_queue", "stop_queue", "tx_linearized", "LRO aggregated",
+           "LRO flushed",
+       "LRO avg aggr", "LRO no_desc"
+};
+
 #define MYRI10GE_NET_STATS_LEN      21
-#define MYRI10GE_STATS_LEN  sizeof(myri10ge_gstrings_stats) / ETH_GSTRING_LEN
+#define MYRI10GE_MAIN_STATS_LEN  ARRAY_SIZE(myri10ge_gstrings_main_stats)
+#define MYRI10GE_SLICE_STATS_LEN  ARRAY_SIZE(myri10ge_gstrings_slice_stats)
 
 static void
 myri10ge_get_strings(struct net_device *netdev, u32 stringset, u8 * data)
 {
+       struct myri10ge_priv *mgp = netdev_priv(netdev);
+       int i;
+
        switch (stringset) {
        case ETH_SS_STATS:
-               memcpy(data, *myri10ge_gstrings_stats,
-                      sizeof(myri10ge_gstrings_stats));
+               memcpy(data, *myri10ge_gstrings_main_stats,
+                      sizeof(myri10ge_gstrings_main_stats));
+               data += sizeof(myri10ge_gstrings_main_stats);
+               for (i = 0; i < mgp->num_slices; i++) {
+                       memcpy(data, *myri10ge_gstrings_slice_stats,
+                              sizeof(myri10ge_gstrings_slice_stats));
+                       data += sizeof(myri10ge_gstrings_slice_stats);
+               }
                break;
        }
 }
 
-static int myri10ge_get_stats_count(struct net_device *netdev)
+static int myri10ge_get_sset_count(struct net_device *netdev, int sset)
 {
-       return MYRI10GE_STATS_LEN;
+       struct myri10ge_priv *mgp = netdev_priv(netdev);
+
+       switch (sset) {
+       case ETH_SS_STATS:
+               return MYRI10GE_MAIN_STATS_LEN +
+                   mgp->num_slices * MYRI10GE_SLICE_STATS_LEN;
+       default:
+               return -EOPNOTSUPP;
+       }
 }
 
 static void
@@ -1341,40 +1748,67 @@ myri10ge_get_ethtool_stats(struct net_device *netdev,
                           struct ethtool_stats *stats, u64 * data)
 {
        struct myri10ge_priv *mgp = netdev_priv(netdev);
+       struct myri10ge_slice_state *ss;
+       int slice;
        int i;
 
        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->tx_boundary;
+       data[i++] = (unsigned int)mgp->wc_enabled;
        data[i++] = (unsigned int)mgp->pdev->irq;
        data[i++] = (unsigned int)mgp->msi_enabled;
+       data[i++] = (unsigned int)mgp->msix_enabled;
        data[i++] = (unsigned int)mgp->read_dma;
        data[i++] = (unsigned int)mgp->write_dma;
        data[i++] = (unsigned int)mgp->read_write_dma;
        data[i++] = (unsigned int)mgp->serial_number;
-       data[i++] = (unsigned int)mgp->tx.pkt_start;
-       data[i++] = (unsigned int)mgp->tx.pkt_done;
-       data[i++] = (unsigned int)mgp->tx.req;
-       data[i++] = (unsigned int)mgp->tx.done;
-       data[i++] = (unsigned int)mgp->rx_small.cnt;
-       data[i++] = (unsigned int)mgp->rx_big.cnt;
-       data[i++] = (unsigned int)mgp->wake_queue;
-       data[i++] = (unsigned int)mgp->stop_queue;
        data[i++] = (unsigned int)mgp->watchdog_resets;
-       data[i++] = (unsigned int)mgp->tx_linearized;
+#ifdef CONFIG_DCA
+       data[i++] = (unsigned int)(mgp->ss[0].dca_tag != NULL);
+       data[i++] = (unsigned int)(mgp->dca_enabled);
+#endif
        data[i++] = (unsigned int)mgp->link_changes;
-       data[i++] = (unsigned int)ntohl(mgp->fw_stats->link_up);
-       data[i++] = (unsigned int)ntohl(mgp->fw_stats->dropped_link_overflow);
+
+       /* firmware stats are useful only in the first slice */
+       ss = &mgp->ss[0];
+       data[i++] = (unsigned int)ntohl(ss->fw_stats->link_up);
+       data[i++] = (unsigned int)ntohl(ss->fw_stats->dropped_link_overflow);
        data[i++] =
-           (unsigned int)ntohl(mgp->fw_stats->dropped_link_error_or_filtered);
+           (unsigned int)ntohl(ss->fw_stats->dropped_link_error_or_filtered);
+       data[i++] = (unsigned int)ntohl(ss->fw_stats->dropped_pause);
+       data[i++] = (unsigned int)ntohl(ss->fw_stats->dropped_bad_phy);
+       data[i++] = (unsigned int)ntohl(ss->fw_stats->dropped_bad_crc32);
+       data[i++] = (unsigned int)ntohl(ss->fw_stats->dropped_unicast_filtered);
        data[i++] =
-           (unsigned int)ntohl(mgp->fw_stats->dropped_multicast_filtered);
-       data[i++] = (unsigned int)ntohl(mgp->fw_stats->dropped_runt);
-       data[i++] = (unsigned int)ntohl(mgp->fw_stats->dropped_overrun);
-       data[i++] = (unsigned int)ntohl(mgp->fw_stats->dropped_no_small_buffer);
-       data[i++] = (unsigned int)ntohl(mgp->fw_stats->dropped_no_big_buffer);
+           (unsigned int)ntohl(ss->fw_stats->dropped_multicast_filtered);
+       data[i++] = (unsigned int)ntohl(ss->fw_stats->dropped_runt);
+       data[i++] = (unsigned int)ntohl(ss->fw_stats->dropped_overrun);
+       data[i++] = (unsigned int)ntohl(ss->fw_stats->dropped_no_small_buffer);
+       data[i++] = (unsigned int)ntohl(ss->fw_stats->dropped_no_big_buffer);
+
+       for (slice = 0; slice < mgp->num_slices; slice++) {
+               ss = &mgp->ss[slice];
+               data[i++] = slice;
+               data[i++] = (unsigned int)ss->tx.pkt_start;
+               data[i++] = (unsigned int)ss->tx.pkt_done;
+               data[i++] = (unsigned int)ss->tx.req;
+               data[i++] = (unsigned int)ss->tx.done;
+               data[i++] = (unsigned int)ss->rx_small.cnt;
+               data[i++] = (unsigned int)ss->rx_big.cnt;
+               data[i++] = (unsigned int)ss->tx.wake_queue;
+               data[i++] = (unsigned int)ss->tx.stop_queue;
+               data[i++] = (unsigned int)ss->tx.linearized;
+               data[i++] = ss->rx_done.lro_mgr.stats.aggregated;
+               data[i++] = ss->rx_done.lro_mgr.stats.flushed;
+               if (ss->rx_done.lro_mgr.stats.flushed)
+                       data[i++] = ss->rx_done.lro_mgr.stats.aggregated /
+                           ss->rx_done.lro_mgr.stats.flushed;
+               else
+                       data[i++] = 0;
+               data[i++] = ss->rx_done.lro_mgr.stats.no_desc;
+       }
 }
 
 static void myri10ge_set_msglevel(struct net_device *netdev, u32 value)
@@ -1399,191 +1833,182 @@ static const struct ethtool_ops myri10ge_ethtool_ops = {
        .get_ringparam = myri10ge_get_ringparam,
        .get_rx_csum = myri10ge_get_rx_csum,
        .set_rx_csum = myri10ge_set_rx_csum,
-       .get_tx_csum = ethtool_op_get_tx_csum,
        .set_tx_csum = ethtool_op_set_tx_hw_csum,
-       .get_sg = ethtool_op_get_sg,
        .set_sg = ethtool_op_set_sg,
-#ifdef NETIF_F_TSO
-       .get_tso = ethtool_op_get_tso,
-       .set_tso = ethtool_op_set_tso,
-#endif
+       .set_tso = myri10ge_set_tso,
+       .get_link = ethtool_op_get_link,
        .get_strings = myri10ge_get_strings,
-       .get_stats_count = myri10ge_get_stats_count,
+       .get_sset_count = myri10ge_get_sset_count,
        .get_ethtool_stats = myri10ge_get_ethtool_stats,
        .set_msglevel = myri10ge_set_msglevel,
        .get_msglevel = myri10ge_get_msglevel
 };
 
-static int myri10ge_allocate_rings(struct net_device *dev)
+static int myri10ge_allocate_rings(struct myri10ge_slice_state *ss)
 {
-       struct myri10ge_priv *mgp;
+       struct myri10ge_priv *mgp = ss->mgp;
        struct myri10ge_cmd cmd;
+       struct net_device *dev = mgp->dev;
        int tx_ring_size, rx_ring_size;
        int tx_ring_entries, rx_ring_entries;
-       int i, status;
+       int i, slice, status;
        size_t bytes;
 
-       mgp = netdev_priv(dev);
-
        /* get ring sizes */
-
+       slice = ss - mgp->ss;
+       cmd.data0 = slice;
        status = myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_SEND_RING_SIZE, &cmd, 0);
        tx_ring_size = cmd.data0;
+       cmd.data0 = slice;
        status |= myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_RX_RING_SIZE, &cmd, 0);
+       if (status != 0)
+               return status;
        rx_ring_size = cmd.data0;
 
        tx_ring_entries = tx_ring_size / sizeof(struct mcp_kreq_ether_send);
        rx_ring_entries = rx_ring_size / sizeof(struct mcp_dma_addr);
-       mgp->tx.mask = tx_ring_entries - 1;
-       mgp->rx_small.mask = mgp->rx_big.mask = rx_ring_entries - 1;
+       ss->tx.mask = tx_ring_entries - 1;
+       ss->rx_small.mask = ss->rx_big.mask = rx_ring_entries - 1;
+
+       status = -ENOMEM;
 
        /* allocate the host shadow rings */
 
        bytes = 8 + (MYRI10GE_MAX_SEND_DESC_TSO + 4)
-           * sizeof(*mgp->tx.req_list);
-       mgp->tx.req_bytes = kzalloc(bytes, GFP_KERNEL);
-       if (mgp->tx.req_bytes == NULL)
+           * sizeof(*ss->tx.req_list);
+       ss->tx.req_bytes = kzalloc(bytes, GFP_KERNEL);
+       if (ss->tx.req_bytes == NULL)
                goto abort_with_nothing;
 
        /* ensure req_list entries are aligned to 8 bytes */
-       mgp->tx.req_list = (struct mcp_kreq_ether_send *)
-           ALIGN((unsigned long)mgp->tx.req_bytes, 8);
+       ss->tx.req_list = (struct mcp_kreq_ether_send *)
+           ALIGN((unsigned long)ss->tx.req_bytes, 8);
 
-       bytes = rx_ring_entries * sizeof(*mgp->rx_small.shadow);
-       mgp->rx_small.shadow = kzalloc(bytes, GFP_KERNEL);
-       if (mgp->rx_small.shadow == NULL)
+       bytes = rx_ring_entries * sizeof(*ss->rx_small.shadow);
+       ss->rx_small.shadow = kzalloc(bytes, GFP_KERNEL);
+       if (ss->rx_small.shadow == NULL)
                goto abort_with_tx_req_bytes;
 
-       bytes = rx_ring_entries * sizeof(*mgp->rx_big.shadow);
-       mgp->rx_big.shadow = kzalloc(bytes, GFP_KERNEL);
-       if (mgp->rx_big.shadow == NULL)
+       bytes = rx_ring_entries * sizeof(*ss->rx_big.shadow);
+       ss->rx_big.shadow = kzalloc(bytes, GFP_KERNEL);
+       if (ss->rx_big.shadow == NULL)
                goto abort_with_rx_small_shadow;
 
        /* allocate the host info rings */
 
-       bytes = tx_ring_entries * sizeof(*mgp->tx.info);
-       mgp->tx.info = kzalloc(bytes, GFP_KERNEL);
-       if (mgp->tx.info == NULL)
+       bytes = tx_ring_entries * sizeof(*ss->tx.info);
+       ss->tx.info = kzalloc(bytes, GFP_KERNEL);
+       if (ss->tx.info == NULL)
                goto abort_with_rx_big_shadow;
 
-       bytes = rx_ring_entries * sizeof(*mgp->rx_small.info);
-       mgp->rx_small.info = kzalloc(bytes, GFP_KERNEL);
-       if (mgp->rx_small.info == NULL)
+       bytes = rx_ring_entries * sizeof(*ss->rx_small.info);
+       ss->rx_small.info = kzalloc(bytes, GFP_KERNEL);
+       if (ss->rx_small.info == NULL)
                goto abort_with_tx_info;
 
-       bytes = rx_ring_entries * sizeof(*mgp->rx_big.info);
-       mgp->rx_big.info = kzalloc(bytes, GFP_KERNEL);
-       if (mgp->rx_big.info == NULL)
+       bytes = rx_ring_entries * sizeof(*ss->rx_big.info);
+       ss->rx_big.info = kzalloc(bytes, GFP_KERNEL);
+       if (ss->rx_big.info == NULL)
                goto abort_with_rx_small_info;
 
        /* Fill the receive rings */
-
-       for (i = 0; i <= mgp->rx_small.mask; i++) {
-               status = myri10ge_getbuf(&mgp->rx_small, mgp,
-                                        mgp->small_bytes, i);
-               if (status) {
-                       printk(KERN_ERR
-                              "myri10ge: %s: alloced only %d small bufs\n",
-                              dev->name, i);
-                       goto abort_with_rx_small_ring;
-               }
+       ss->rx_big.cnt = 0;
+       ss->rx_small.cnt = 0;
+       ss->rx_big.fill_cnt = 0;
+       ss->rx_small.fill_cnt = 0;
+       ss->rx_small.page_offset = MYRI10GE_ALLOC_SIZE;
+       ss->rx_big.page_offset = MYRI10GE_ALLOC_SIZE;
+       ss->rx_small.watchdog_needed = 0;
+       ss->rx_big.watchdog_needed = 0;
+       myri10ge_alloc_rx_pages(mgp, &ss->rx_small,
+                               mgp->small_bytes + MXGEFW_PAD, 0);
+
+       if (ss->rx_small.fill_cnt < ss->rx_small.mask + 1) {
+               printk(KERN_ERR
+                      "myri10ge: %s:slice-%d: alloced only %d small bufs\n",
+                      dev->name, slice, ss->rx_small.fill_cnt);
+               goto abort_with_rx_small_ring;
        }
 
-       for (i = 0; i <= mgp->rx_big.mask; i++) {
-               status =
-                   myri10ge_getbuf(&mgp->rx_big, mgp, dev->mtu + ETH_HLEN, i);
-               if (status) {
-                       printk(KERN_ERR
-                              "myri10ge: %s: alloced only %d big bufs\n",
-                              dev->name, i);
-                       goto abort_with_rx_big_ring;
-               }
+       myri10ge_alloc_rx_pages(mgp, &ss->rx_big, mgp->big_bytes, 0);
+       if (ss->rx_big.fill_cnt < ss->rx_big.mask + 1) {
+               printk(KERN_ERR
+                      "myri10ge: %s:slice-%d: alloced only %d big bufs\n",
+                      dev->name, slice, ss->rx_big.fill_cnt);
+               goto abort_with_rx_big_ring;
        }
 
        return 0;
 
 abort_with_rx_big_ring:
-       for (i = 0; i <= mgp->rx_big.mask; i++) {
-               if (mgp->rx_big.info[i].skb != NULL)
-                       dev_kfree_skb_any(mgp->rx_big.info[i].skb);
-               if (pci_unmap_len(&mgp->rx_big.info[i], len))
-                       pci_unmap_single(mgp->pdev,
-                                        pci_unmap_addr(&mgp->rx_big.info[i],
-                                                       bus),
-                                        pci_unmap_len(&mgp->rx_big.info[i],
-                                                      len),
-                                        PCI_DMA_FROMDEVICE);
+       for (i = ss->rx_big.cnt; i < ss->rx_big.fill_cnt; i++) {
+               int idx = i & ss->rx_big.mask;
+               myri10ge_unmap_rx_page(mgp->pdev, &ss->rx_big.info[idx],
+                                      mgp->big_bytes);
+               put_page(ss->rx_big.info[idx].page);
        }
 
 abort_with_rx_small_ring:
-       for (i = 0; i <= mgp->rx_small.mask; i++) {
-               if (mgp->rx_small.info[i].skb != NULL)
-                       dev_kfree_skb_any(mgp->rx_small.info[i].skb);
-               if (pci_unmap_len(&mgp->rx_small.info[i], len))
-                       pci_unmap_single(mgp->pdev,
-                                        pci_unmap_addr(&mgp->rx_small.info[i],
-                                                       bus),
-                                        pci_unmap_len(&mgp->rx_small.info[i],
-                                                      len),
-                                        PCI_DMA_FROMDEVICE);
-       }
-       kfree(mgp->rx_big.info);
+       for (i = ss->rx_small.cnt; i < ss->rx_small.fill_cnt; i++) {
+               int idx = i & ss->rx_small.mask;
+               myri10ge_unmap_rx_page(mgp->pdev, &ss->rx_small.info[idx],
+                                      mgp->small_bytes + MXGEFW_PAD);
+               put_page(ss->rx_small.info[idx].page);
+       }
+
+       kfree(ss->rx_big.info);
 
 abort_with_rx_small_info:
-       kfree(mgp->rx_small.info);
+       kfree(ss->rx_small.info);
 
 abort_with_tx_info:
-       kfree(mgp->tx.info);
+       kfree(ss->tx.info);
 
 abort_with_rx_big_shadow:
-       kfree(mgp->rx_big.shadow);
+       kfree(ss->rx_big.shadow);
 
 abort_with_rx_small_shadow:
-       kfree(mgp->rx_small.shadow);
+       kfree(ss->rx_small.shadow);
 
 abort_with_tx_req_bytes:
-       kfree(mgp->tx.req_bytes);
-       mgp->tx.req_bytes = NULL;
-       mgp->tx.req_list = NULL;
+       kfree(ss->tx.req_bytes);
+       ss->tx.req_bytes = NULL;
+       ss->tx.req_list = NULL;
 
 abort_with_nothing:
        return status;
 }
 
-static void myri10ge_free_rings(struct net_device *dev)
+static void myri10ge_free_rings(struct myri10ge_slice_state *ss)
 {
-       struct myri10ge_priv *mgp;
+       struct myri10ge_priv *mgp = ss->mgp;
        struct sk_buff *skb;
        struct myri10ge_tx_buf *tx;
        int i, len, idx;
 
-       mgp = netdev_priv(dev);
-
-       for (i = 0; i <= mgp->rx_big.mask; i++) {
-               if (mgp->rx_big.info[i].skb != NULL)
-                       dev_kfree_skb_any(mgp->rx_big.info[i].skb);
-               if (pci_unmap_len(&mgp->rx_big.info[i], len))
-                       pci_unmap_single(mgp->pdev,
-                                        pci_unmap_addr(&mgp->rx_big.info[i],
-                                                       bus),
-                                        pci_unmap_len(&mgp->rx_big.info[i],
-                                                      len),
-                                        PCI_DMA_FROMDEVICE);
-       }
-
-       for (i = 0; i <= mgp->rx_small.mask; i++) {
-               if (mgp->rx_small.info[i].skb != NULL)
-                       dev_kfree_skb_any(mgp->rx_small.info[i].skb);
-               if (pci_unmap_len(&mgp->rx_small.info[i], len))
-                       pci_unmap_single(mgp->pdev,
-                                        pci_unmap_addr(&mgp->rx_small.info[i],
-                                                       bus),
-                                        pci_unmap_len(&mgp->rx_small.info[i],
-                                                      len),
-                                        PCI_DMA_FROMDEVICE);
-       }
-
-       tx = &mgp->tx;
+       /* If not allocated, skip it */
+       if (ss->tx.req_list == NULL)
+               return;
+
+       for (i = ss->rx_big.cnt; i < ss->rx_big.fill_cnt; i++) {
+               idx = i & ss->rx_big.mask;
+               if (i == ss->rx_big.fill_cnt - 1)
+                       ss->rx_big.info[idx].page_offset = MYRI10GE_ALLOC_SIZE;
+               myri10ge_unmap_rx_page(mgp->pdev, &ss->rx_big.info[idx],
+                                      mgp->big_bytes);
+               put_page(ss->rx_big.info[idx].page);
+       }
+
+       for (i = ss->rx_small.cnt; i < ss->rx_small.fill_cnt; i++) {
+               idx = i & ss->rx_small.mask;
+               if (i == ss->rx_small.fill_cnt - 1)
+                       ss->rx_small.info[idx].page_offset =
+                           MYRI10GE_ALLOC_SIZE;
+               myri10ge_unmap_rx_page(mgp->pdev, &ss->rx_small.info[idx],
+                                      mgp->small_bytes + MXGEFW_PAD);
+               put_page(ss->rx_small.info[idx].page);
+       }
+       tx = &ss->tx;
        while (tx->done != tx->req) {
                idx = tx->done & tx->mask;
                skb = tx->info[idx].skb;
@@ -1594,7 +2019,7 @@ static void myri10ge_free_rings(struct net_device *dev)
                len = pci_unmap_len(&tx->info[idx], len);
                pci_unmap_len_set(&tx->info[idx], len, 0);
                if (skb) {
-                       mgp->stats.tx_dropped++;
+                       ss->stats.tx_dropped++;
                        dev_kfree_skb_any(skb);
                        if (len)
                                pci_unmap_single(mgp->pdev,
@@ -1609,28 +2034,229 @@ static void myri10ge_free_rings(struct net_device *dev)
                                               PCI_DMA_TODEVICE);
                }
        }
-       kfree(mgp->rx_big.info);
+       kfree(ss->rx_big.info);
 
-       kfree(mgp->rx_small.info);
+       kfree(ss->rx_small.info);
 
-       kfree(mgp->tx.info);
+       kfree(ss->tx.info);
 
-       kfree(mgp->rx_big.shadow);
+       kfree(ss->rx_big.shadow);
 
-       kfree(mgp->rx_small.shadow);
+       kfree(ss->rx_small.shadow);
 
-       kfree(mgp->tx.req_bytes);
-       mgp->tx.req_bytes = NULL;
-       mgp->tx.req_list = NULL;
+       kfree(ss->tx.req_bytes);
+       ss->tx.req_bytes = NULL;
+       ss->tx.req_list = NULL;
 }
 
-static int myri10ge_open(struct net_device *dev)
+static int myri10ge_request_irq(struct myri10ge_priv *mgp)
+{
+       struct pci_dev *pdev = mgp->pdev;
+       struct myri10ge_slice_state *ss;
+       struct net_device *netdev = mgp->dev;
+       int i;
+       int status;
+
+       mgp->msi_enabled = 0;
+       mgp->msix_enabled = 0;
+       status = 0;
+       if (myri10ge_msi) {
+               if (mgp->num_slices > 1) {
+                       status =
+                           pci_enable_msix(pdev, mgp->msix_vectors,
+                                           mgp->num_slices);
+                       if (status == 0) {
+                               mgp->msix_enabled = 1;
+                       } else {
+                               dev_err(&pdev->dev,
+                                       "Error %d setting up MSI-X\n", status);
+                               return status;
+                       }
+               }
+               if (mgp->msix_enabled == 0) {
+                       status = pci_enable_msi(pdev);
+                       if (status != 0) {
+                               dev_err(&pdev->dev,
+                                       "Error %d setting up MSI; falling back to xPIC\n",
+                                       status);
+                       } else {
+                               mgp->msi_enabled = 1;
+                       }
+               }
+       }
+       if (mgp->msix_enabled) {
+               for (i = 0; i < mgp->num_slices; i++) {
+                       ss = &mgp->ss[i];
+                       snprintf(ss->irq_desc, sizeof(ss->irq_desc),
+                                "%s:slice-%d", netdev->name, i);
+                       status = request_irq(mgp->msix_vectors[i].vector,
+                                            myri10ge_intr, 0, ss->irq_desc,
+                                            ss);
+                       if (status != 0) {
+                               dev_err(&pdev->dev,
+                                       "slice %d failed to allocate IRQ\n", i);
+                               i--;
+                               while (i >= 0) {
+                                       free_irq(mgp->msix_vectors[i].vector,
+                                                &mgp->ss[i]);
+                                       i--;
+                               }
+                               pci_disable_msix(pdev);
+                               return status;
+                       }
+               }
+       } else {
+               status = request_irq(pdev->irq, myri10ge_intr, IRQF_SHARED,
+                                    mgp->dev->name, &mgp->ss[0]);
+               if (status != 0) {
+                       dev_err(&pdev->dev, "failed to allocate IRQ\n");
+                       if (mgp->msi_enabled)
+                               pci_disable_msi(pdev);
+               }
+       }
+       return status;
+}
+
+static void myri10ge_free_irq(struct myri10ge_priv *mgp)
+{
+       struct pci_dev *pdev = mgp->pdev;
+       int i;
+
+       if (mgp->msix_enabled) {
+               for (i = 0; i < mgp->num_slices; i++)
+                       free_irq(mgp->msix_vectors[i].vector, &mgp->ss[i]);
+       } else {
+               free_irq(pdev->irq, &mgp->ss[0]);
+       }
+       if (mgp->msi_enabled)
+               pci_disable_msi(pdev);
+       if (mgp->msix_enabled)
+               pci_disable_msix(pdev);
+}
+
+static int
+myri10ge_get_frag_header(struct skb_frag_struct *frag, void **mac_hdr,
+                        void **ip_hdr, void **tcpudp_hdr,
+                        u64 * hdr_flags, void *priv)
+{
+       struct ethhdr *eh;
+       struct vlan_ethhdr *veh;
+       struct iphdr *iph;
+       u8 *va = page_address(frag->page) + frag->page_offset;
+       unsigned long ll_hlen;
+       /* passed opaque through lro_receive_frags() */
+       __wsum csum = (__force __wsum) (unsigned long)priv;
+
+       /* find the mac header, aborting if not IPv4 */
+
+       eh = (struct ethhdr *)va;
+       *mac_hdr = eh;
+       ll_hlen = ETH_HLEN;
+       if (eh->h_proto != htons(ETH_P_IP)) {
+               if (eh->h_proto == htons(ETH_P_8021Q)) {
+                       veh = (struct vlan_ethhdr *)va;
+                       if (veh->h_vlan_encapsulated_proto != htons(ETH_P_IP))
+                               return -1;
+
+                       ll_hlen += VLAN_HLEN;
+
+                       /*
+                        *  HW checksum starts ETH_HLEN bytes into
+                        *  frame, so we must subtract off the VLAN
+                        *  header's checksum before csum can be used
+                        */
+                       csum = csum_sub(csum, csum_partial(va + ETH_HLEN,
+                                                          VLAN_HLEN, 0));
+               } else {
+                       return -1;
+               }
+       }
+       *hdr_flags = LRO_IPV4;
+
+       iph = (struct iphdr *)(va + ll_hlen);
+       *ip_hdr = iph;
+       if (iph->protocol != IPPROTO_TCP)
+               return -1;
+       *hdr_flags |= LRO_TCP;
+       *tcpudp_hdr = (u8 *) (*ip_hdr) + (iph->ihl << 2);
+
+       /* verify the IP checksum */
+       if (unlikely(ip_fast_csum((u8 *) iph, iph->ihl)))
+               return -1;
+
+       /* verify the  checksum */
+       if (unlikely(csum_tcpudp_magic(iph->saddr, iph->daddr,
+                                      ntohs(iph->tot_len) - (iph->ihl << 2),
+                                      IPPROTO_TCP, csum)))
+               return -1;
+
+       return 0;
+}
+
+static int myri10ge_get_txrx(struct myri10ge_priv *mgp, int slice)
 {
-       struct myri10ge_priv *mgp;
        struct myri10ge_cmd cmd;
-       int status, big_pow2;
+       struct myri10ge_slice_state *ss;
+       int status;
+
+       ss = &mgp->ss[slice];
+       cmd.data0 = 0;          /* single slice for now */
+       status = myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_SEND_OFFSET, &cmd, 0);
+       ss->tx.lanai = (struct mcp_kreq_ether_send __iomem *)
+           (mgp->sram + cmd.data0);
+
+       cmd.data0 = slice;
+       status |= myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_SMALL_RX_OFFSET,
+                                   &cmd, 0);
+       ss->rx_small.lanai = (struct mcp_kreq_ether_recv __iomem *)
+           (mgp->sram + cmd.data0);
+
+       cmd.data0 = slice;
+       status |= myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_BIG_RX_OFFSET, &cmd, 0);
+       ss->rx_big.lanai = (struct mcp_kreq_ether_recv __iomem *)
+           (mgp->sram + cmd.data0);
+
+       return status;
+
+}
+
+static int myri10ge_set_stats(struct myri10ge_priv *mgp, int slice)
+{
+       struct myri10ge_cmd cmd;
+       struct myri10ge_slice_state *ss;
+       int status;
+
+       ss = &mgp->ss[slice];
+       cmd.data0 = MYRI10GE_LOWPART_TO_U32(ss->fw_stats_bus);
+       cmd.data1 = MYRI10GE_HIGHPART_TO_U32(ss->fw_stats_bus);
+       cmd.data2 = sizeof(struct mcp_irq_data);
+       status = myri10ge_send_cmd(mgp, MXGEFW_CMD_SET_STATS_DMA_V2, &cmd, 0);
+       if (status == -ENOSYS) {
+               dma_addr_t bus = ss->fw_stats_bus;
+               if (slice != 0)
+                       return -EINVAL;
+               bus += offsetof(struct mcp_irq_data, send_done_count);
+               cmd.data0 = MYRI10GE_LOWPART_TO_U32(bus);
+               cmd.data1 = MYRI10GE_HIGHPART_TO_U32(bus);
+               status = myri10ge_send_cmd(mgp,
+                                          MXGEFW_CMD_SET_STATS_DMA_OBSOLETE,
+                                          &cmd, 0);
+               /* Firmware cannot support multicast without STATS_DMA_V2 */
+               mgp->fw_multicast_support = 0;
+       } else {
+               mgp->fw_multicast_support = 1;
+       }
+       return 0;
+}
 
-       mgp = netdev_priv(dev);
+static int myri10ge_open(struct net_device *dev)
+{
+       struct myri10ge_slice_state *ss;
+       struct myri10ge_priv *mgp = netdev_priv(dev);
+       struct myri10ge_cmd cmd;
+       int i, status, big_pow2, slice;
+       u8 *itable;
+       struct net_lro_mgr *lro_mgr;
 
        if (mgp->running != MYRI10GE_ETH_STOPPED)
                return -EBUSY;
@@ -1639,10 +2265,55 @@ static int myri10ge_open(struct net_device *dev)
        status = myri10ge_reset(mgp);
        if (status != 0) {
                printk(KERN_ERR "myri10ge: %s: failed reset\n", dev->name);
-               mgp->running = MYRI10GE_ETH_STOPPED;
-               return -ENXIO;
+               goto abort_with_nothing;
        }
 
+       if (mgp->num_slices > 1) {
+               cmd.data0 = mgp->num_slices;
+               cmd.data1 = 1;  /* use MSI-X */
+               status = myri10ge_send_cmd(mgp, MXGEFW_CMD_ENABLE_RSS_QUEUES,
+                                          &cmd, 0);
+               if (status != 0) {
+                       printk(KERN_ERR
+                              "myri10ge: %s: failed to set number of slices\n",
+                              dev->name);
+                       goto abort_with_nothing;
+               }
+               /* setup the indirection table */
+               cmd.data0 = mgp->num_slices;
+               status = myri10ge_send_cmd(mgp, MXGEFW_CMD_SET_RSS_TABLE_SIZE,
+                                          &cmd, 0);
+
+               status |= myri10ge_send_cmd(mgp,
+                                           MXGEFW_CMD_GET_RSS_TABLE_OFFSET,
+                                           &cmd, 0);
+               if (status != 0) {
+                       printk(KERN_ERR
+                              "myri10ge: %s: failed to setup rss tables\n",
+                              dev->name);
+               }
+
+               /* just enable an identity mapping */
+               itable = mgp->sram + cmd.data0;
+               for (i = 0; i < mgp->num_slices; i++)
+                       __raw_writeb(i, &itable[i]);
+
+               cmd.data0 = 1;
+               cmd.data1 = myri10ge_rss_hash;
+               status = myri10ge_send_cmd(mgp, MXGEFW_CMD_SET_RSS_ENABLE,
+                                          &cmd, 0);
+               if (status != 0) {
+                       printk(KERN_ERR
+                              "myri10ge: %s: failed to enable slices\n",
+                              dev->name);
+                       goto abort_with_nothing;
+               }
+       }
+
+       status = myri10ge_request_irq(mgp);
+       if (status != 0)
+               goto abort_with_nothing;
+
        /* decide what small buffer size to use.  For good TCP rx
         * performance, it is important to not receive 1514 byte
         * frames into jumbo buffers, as it confuses the socket buffer
@@ -1650,66 +2321,71 @@ static int myri10ge_open(struct net_device *dev)
         */
 
        if (dev->mtu <= ETH_DATA_LEN)
-               mgp->small_bytes = 128; /* enough for a TCP header */
+               /* enough for a TCP header */
+               mgp->small_bytes = (128 > SMP_CACHE_BYTES)
+                   ? (128 - MXGEFW_PAD)
+                   : (SMP_CACHE_BYTES - MXGEFW_PAD);
        else
-               mgp->small_bytes = ETH_FRAME_LEN;       /* enough for an ETH_DATA_LEN frame */
+               /* enough for a vlan encapsulated ETH_DATA_LEN frame */
+               mgp->small_bytes = VLAN_ETH_FRAME_LEN;
 
        /* Override the small buffer size? */
        if (myri10ge_small_bytes > 0)
                mgp->small_bytes = myri10ge_small_bytes;
 
-       /* If the user sets an obscenely small MTU, adjust the small
-        * bytes down to nearly nothing */
-       if (mgp->small_bytes >= (dev->mtu + ETH_HLEN))
-               mgp->small_bytes = 64;
-
-       /* get the lanai pointers to the send and receive rings */
-
-       status |= myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_SEND_OFFSET, &cmd, 0);
-       mgp->tx.lanai =
-           (struct mcp_kreq_ether_send __iomem *)(mgp->sram + cmd.data0);
+       /* Firmware needs the big buff size as a power of 2.  Lie and
+        * tell him the buffer is larger, because we only use 1
+        * buffer/pkt, and the mtu will prevent overruns.
+        */
+       big_pow2 = dev->mtu + ETH_HLEN + VLAN_HLEN + MXGEFW_PAD;
+       if (big_pow2 < MYRI10GE_ALLOC_SIZE / 2) {
+               while (!is_power_of_2(big_pow2))
+                       big_pow2++;
+               mgp->big_bytes = dev->mtu + ETH_HLEN + VLAN_HLEN + MXGEFW_PAD;
+       } else {
+               big_pow2 = MYRI10GE_ALLOC_SIZE;
+               mgp->big_bytes = big_pow2;
+       }
 
-       status |=
-           myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_SMALL_RX_OFFSET, &cmd, 0);
-       mgp->rx_small.lanai =
-           (struct mcp_kreq_ether_recv __iomem *)(mgp->sram + cmd.data0);
+       /* setup the per-slice data structures */
+       for (slice = 0; slice < mgp->num_slices; slice++) {
+               ss = &mgp->ss[slice];
 
-       status |= myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_BIG_RX_OFFSET, &cmd, 0);
-       mgp->rx_big.lanai =
-           (struct mcp_kreq_ether_recv __iomem *)(mgp->sram + cmd.data0);
+               status = myri10ge_get_txrx(mgp, slice);
+               if (status != 0) {
+                       printk(KERN_ERR
+                              "myri10ge: %s: failed to get ring sizes or locations\n",
+                              dev->name);
+                       goto abort_with_rings;
+               }
+               status = myri10ge_allocate_rings(ss);
+               if (status != 0)
+                       goto abort_with_rings;
+               if (slice == 0)
+                       status = myri10ge_set_stats(mgp, slice);
+               if (status) {
+                       printk(KERN_ERR
+                              "myri10ge: %s: Couldn't set stats DMA\n",
+                              dev->name);
+                       goto abort_with_rings;
+               }
 
-       if (status != 0) {
-               printk(KERN_ERR
-                      "myri10ge: %s: failed to get ring sizes or locations\n",
-                      dev->name);
-               mgp->running = MYRI10GE_ETH_STOPPED;
-               return -ENXIO;
-       }
+               lro_mgr = &ss->rx_done.lro_mgr;
+               lro_mgr->dev = dev;
+               lro_mgr->features = LRO_F_NAPI;
+               lro_mgr->ip_summed = CHECKSUM_COMPLETE;
+               lro_mgr->ip_summed_aggr = CHECKSUM_UNNECESSARY;
+               lro_mgr->max_desc = MYRI10GE_MAX_LRO_DESCRIPTORS;
+               lro_mgr->lro_arr = ss->rx_done.lro_desc;
+               lro_mgr->get_frag_header = myri10ge_get_frag_header;
+               lro_mgr->max_aggr = myri10ge_lro_max_pkts;
+               if (lro_mgr->max_aggr > MAX_SKB_FRAGS)
+                       lro_mgr->max_aggr = MAX_SKB_FRAGS;
 
-       if (mgp->mtrr >= 0) {
-               mgp->tx.wc_fifo = (u8 __iomem *) mgp->sram + MXGEFW_ETH_SEND_4;
-               mgp->rx_small.wc_fifo =
-                   (u8 __iomem *) mgp->sram + MXGEFW_ETH_RECV_SMALL;
-               mgp->rx_big.wc_fifo =
-                   (u8 __iomem *) mgp->sram + MXGEFW_ETH_RECV_BIG;
-       } else {
-               mgp->tx.wc_fifo = NULL;
-               mgp->rx_small.wc_fifo = NULL;
-               mgp->rx_big.wc_fifo = NULL;
+               /* must happen prior to any irq */
+               napi_enable(&(ss)->napi);
        }
 
-       status = myri10ge_allocate_rings(dev);
-       if (status != 0)
-               goto abort_with_nothing;
-
-       /* Firmware needs the big buff size as a power of 2.  Lie and
-        * tell him the buffer is larger, because we only use 1
-        * buffer/pkt, and the mtu will prevent overruns.
-        */
-       big_pow2 = dev->mtu + ETH_HLEN + MXGEFW_PAD;
-       while ((big_pow2 & (big_pow2 - 1)) != 0)
-               big_pow2++;
-
        /* now give firmware buffers sizes, and MTU */
        cmd.data0 = dev->mtu + ETH_HLEN + VLAN_HLEN;
        status = myri10ge_send_cmd(mgp, MXGEFW_CMD_SET_MTU, &cmd, 0);
@@ -1725,34 +2401,22 @@ static int myri10ge_open(struct net_device *dev)
                goto abort_with_rings;
        }
 
-       cmd.data0 = MYRI10GE_LOWPART_TO_U32(mgp->fw_stats_bus);
-       cmd.data1 = MYRI10GE_HIGHPART_TO_U32(mgp->fw_stats_bus);
-       cmd.data2 = sizeof(struct mcp_irq_data);
-       status = myri10ge_send_cmd(mgp, MXGEFW_CMD_SET_STATS_DMA_V2, &cmd, 0);
-       if (status == -ENOSYS) {
-               dma_addr_t bus = mgp->fw_stats_bus;
-               bus += offsetof(struct mcp_irq_data, send_done_count);
-               cmd.data0 = MYRI10GE_LOWPART_TO_U32(bus);
-               cmd.data1 = MYRI10GE_HIGHPART_TO_U32(bus);
-               status = myri10ge_send_cmd(mgp,
-                                          MXGEFW_CMD_SET_STATS_DMA_OBSOLETE,
-                                          &cmd, 0);
-               /* Firmware cannot support multicast without STATS_DMA_V2 */
-               mgp->fw_multicast_support = 0;
-       } else {
-               mgp->fw_multicast_support = 1;
-       }
-       if (status) {
-               printk(KERN_ERR "myri10ge: %s: Couldn't set stats DMA\n",
+       /*
+        * Set Linux style TSO mode; this is needed only on newer
+        *  firmware versions.  Older versions default to Linux
+        *  style TSO
+        */
+       cmd.data0 = 0;
+       status = myri10ge_send_cmd(mgp, MXGEFW_CMD_SET_TSO_MODE, &cmd, 0);
+       if (status && status != -ENOSYS) {
+               printk(KERN_ERR "myri10ge: %s: Couldn't set TSO mode\n",
                       dev->name);
                goto abort_with_rings;
        }
 
-       mgp->link_state = -1;
+       mgp->link_state = ~0U;
        mgp->rdma_tags_available = 15;
 
-       netif_poll_enable(mgp->dev);    /* must happen prior to any irq */
-
        status = myri10ge_send_cmd(mgp, MXGEFW_CMD_ETHERNET_UP, &cmd, 0);
        if (status) {
                printk(KERN_ERR "myri10ge: %s: Couldn't bring up link\n",
@@ -1760,8 +2424,6 @@ static int myri10ge_open(struct net_device *dev)
                goto abort_with_rings;
        }
 
-       mgp->wake_queue = 0;
-       mgp->stop_queue = 0;
        mgp->running = MYRI10GE_ETH_RUNNING;
        mgp->watchdog_timer.expires = jiffies + myri10ge_watchdog_timeout * HZ;
        add_timer(&mgp->watchdog_timer);
@@ -1769,7 +2431,10 @@ static int myri10ge_open(struct net_device *dev)
        return 0;
 
 abort_with_rings:
-       myri10ge_free_rings(dev);
+       for (i = 0; i < mgp->num_slices; i++)
+               myri10ge_free_rings(&mgp->ss[i]);
+
+       myri10ge_free_irq(mgp);
 
 abort_with_nothing:
        mgp->running = MYRI10GE_ETH_STOPPED;
@@ -1778,21 +2443,22 @@ abort_with_nothing:
 
 static int myri10ge_close(struct net_device *dev)
 {
-       struct myri10ge_priv *mgp;
+       struct myri10ge_priv *mgp = netdev_priv(dev);
        struct myri10ge_cmd cmd;
        int status, old_down_cnt;
-
-       mgp = netdev_priv(dev);
+       int i;
 
        if (mgp->running != MYRI10GE_ETH_RUNNING)
                return 0;
 
-       if (mgp->tx.req_bytes == NULL)
+       if (mgp->ss[0].tx.req_bytes == NULL)
                return 0;
 
        del_timer_sync(&mgp->watchdog_timer);
        mgp->running = MYRI10GE_ETH_STOPPING;
-       netif_poll_disable(mgp->dev);
+       for (i = 0; i < mgp->num_slices; i++) {
+               napi_disable(&mgp->ss[i].napi);
+       }
        netif_carrier_off(dev);
        netif_stop_queue(dev);
        old_down_cnt = mgp->down_cnt;
@@ -1807,8 +2473,9 @@ static int myri10ge_close(struct net_device *dev)
                printk(KERN_ERR "myri10ge: %s never got down irq\n", dev->name);
 
        netif_tx_disable(dev);
-
-       myri10ge_free_rings(dev);
+       myri10ge_free_irq(mgp);
+       for (i = 0; i < mgp->num_slices; i++)
+               myri10ge_free_rings(&mgp->ss[i]);
 
        mgp->running = MYRI10GE_ETH_STOPPED;
        return 0;
@@ -1876,35 +2543,14 @@ myri10ge_submit_req(struct myri10ge_tx_buf *tx, struct mcp_kreq_ether_send *src,
 
        /* re-write the last 32-bits with the valid flags */
        src->flags = last_flags;
-       __raw_writel(*((u32 *) src + 3), (u32 __iomem *) dst + 3);
-       tx->req += cnt;
-       mb();
-}
-
-static inline void
-myri10ge_submit_req_wc(struct myri10ge_tx_buf *tx,
-                      struct mcp_kreq_ether_send *src, int cnt)
-{
+       put_be32(*((__be32 *) src + 3), (__be32 __iomem *) dst + 3);
        tx->req += cnt;
        mb();
-       while (cnt >= 4) {
-               myri10ge_pio_copy(tx->wc_fifo, src, 64);
-               mb();
-               src += 4;
-               cnt -= 4;
-       }
-       if (cnt > 0) {
-               /* pad it to 64 bytes.  The src is 64 bytes bigger than it
-                * needs to be so that we don't overrun it */
-               myri10ge_pio_copy(tx->wc_fifo + MXGEFW_ETH_SEND_OFFSET(cnt),
-                                 src, 64);
-               mb();
-       }
 }
 
 /*
  * Transmit a packet.  We need to split the packet so that a single
- * segment does not cross myri10ge->tx.boundary, so this makes segment
+ * segment does not cross myri10ge->tx_boundary, so this makes segment
  * counting tricky.  So rather than try to count segments up front, we
  * just give up if there are too few segments to hold a reasonably
  * fragmented packet currently available.  If we run
@@ -1915,17 +2561,22 @@ myri10ge_submit_req_wc(struct myri10ge_tx_buf *tx,
 static int myri10ge_xmit(struct sk_buff *skb, struct net_device *dev)
 {
        struct myri10ge_priv *mgp = netdev_priv(dev);
+       struct myri10ge_slice_state *ss;
        struct mcp_kreq_ether_send *req;
-       struct myri10ge_tx_buf *tx = &mgp->tx;
+       struct myri10ge_tx_buf *tx;
        struct skb_frag_struct *frag;
        dma_addr_t bus;
-       u32 low, high_swapped;
+       u32 low;
+       __be32 high_swapped;
        unsigned int len;
        int idx, last_idx, avail, frag_cnt, frag_idx, count, mss, max_segments;
        u16 pseudo_hdr_offset, cksum_offset;
        int cum_len, seglen, boundary, rdma_count;
        u8 flags, odd_flag;
 
+       /* always transmit through slot 0 */
+       ss = mgp->ss;
+       tx = &ss->tx;
 again:
        req = tx->req_list;
        avail = tx->mask - 1 - (tx->req - tx->done);
@@ -1933,17 +2584,14 @@ again:
        mss = 0;
        max_segments = MXGEFW_MAX_SEND_DESC;
 
-#ifdef NETIF_F_TSO
-       if (skb->len > (dev->mtu + ETH_HLEN)) {
+       if (skb_is_gso(skb)) {
                mss = skb_shinfo(skb)->gso_size;
-               if (mss != 0)
-                       max_segments = MYRI10GE_MAX_SEND_DESC_TSO;
+               max_segments = MYRI10GE_MAX_SEND_DESC_TSO;
        }
-#endif                         /*NETIF_F_TSO */
 
        if ((unlikely(avail < max_segments))) {
                /* we are out of transmit resources */
-               mgp->stop_queue++;
+               tx->stop_queue++;
                netif_stop_queue(dev);
                return 1;
        }
@@ -1954,17 +2602,17 @@ again:
        odd_flag = 0;
        flags = (MXGEFW_FLAGS_NO_TSO | MXGEFW_FLAGS_FIRST);
        if (likely(skb->ip_summed == CHECKSUM_PARTIAL)) {
-               cksum_offset = (skb->h.raw - skb->data);
-               pseudo_hdr_offset = (skb->h.raw + skb->csum) - skb->data;
+               cksum_offset = skb_transport_offset(skb);
+               pseudo_hdr_offset = cksum_offset + skb->csum_offset;
                /* If the headers are excessively large, then we must
                 * fall back to a software checksum */
-               if (unlikely(cksum_offset > 255 || pseudo_hdr_offset > 127)) {
+               if (unlikely(!mss && (cksum_offset > 255 ||
+                                     pseudo_hdr_offset > 127))) {
                        if (skb_checksum_help(skb))
                                goto drop;
                        cksum_offset = 0;
                        pseudo_hdr_offset = 0;
                } else {
-                       pseudo_hdr_offset = htons(pseudo_hdr_offset);
                        odd_flag = MXGEFW_FLAGS_ALIGN_ODD;
                        flags |= MXGEFW_FLAGS_CKSUM;
                }
@@ -1972,7 +2620,6 @@ again:
 
        cum_len = 0;
 
-#ifdef NETIF_F_TSO
        if (mss) {              /* TSO */
                /* this removes any CKSUM flag from before */
                flags = (MXGEFW_FLAGS_TSO_HDR | MXGEFW_FLAGS_FIRST);
@@ -1980,15 +2627,23 @@ again:
                /* negative cum_len signifies to the
                 * send loop that we are still in the
                 * header portion of the TSO packet.
-                * TSO header must be at most 134 bytes long */
-               cum_len = -((skb->h.raw - skb->data) + (skb->h.th->doff << 2));
-
+                * TSO header can be at most 1KB long */
+               cum_len = -(skb_transport_offset(skb) + tcp_hdrlen(skb));
+
+               /* for IPv6 TSO, the checksum offset stores the
+                * TCP header length, to save the firmware from
+                * the need to parse the headers */
+               if (skb_is_gso_v6(skb)) {
+                       cksum_offset = tcp_hdrlen(skb);
+                       /* Can only handle headers <= max_tso6 long */
+                       if (unlikely(-cum_len > mgp->max_tso6))
+                               return myri10ge_sw_tso(skb, dev);
+               }
                /* for TSO, pseudo_hdr_offset holds mss.
                 * The firmware figures out where to put
                 * the checksum by parsing the header. */
-               pseudo_hdr_offset = htons(mss);
+               pseudo_hdr_offset = mss;
        } else
-#endif                         /*NETIF_F_TSO */
                /* Mark small packets, and pad out tiny packets */
        if (skb->len <= MXGEFW_SEND_SMALL_SIZE) {
                flags |= MXGEFW_FLAGS_SMALL;
@@ -1998,7 +2653,7 @@ again:
                        if (skb_padto(skb, ETH_ZLEN)) {
                                /* The packet is gone, so we must
                                 * return 0 */
-                               mgp->stats.tx_dropped += 1;
+                               ss->stats.tx_dropped += 1;
                                return 0;
                        }
                        /* adjust the len to account for the zero pad
@@ -2040,7 +2695,7 @@ again:
 
        while (1) {
                /* Break the SKB or Fragment up into pieces which
-                * do not cross mgp->tx.boundary */
+                * do not cross mgp->tx_boundary */
                low = MYRI10GE_LOWPART_TO_U32(bus);
                high_swapped = htonl(MYRI10GE_HIGHPART_TO_U32(bus));
                while (len) {
@@ -2050,13 +2705,13 @@ again:
                        if (unlikely(count == max_segments))
                                goto abort_linearize;
 
-                       boundary = (low + tx->boundary) & ~(tx->boundary - 1);
+                       boundary =
+                           (low + mgp->tx_boundary) & ~(mgp->tx_boundary - 1);
                        seglen = boundary - low;
                        if (seglen > len)
                                seglen = len;
                        flags_next = flags & ~MXGEFW_FLAGS_FIRST;
                        cum_len_next = cum_len + seglen;
-#ifdef NETIF_F_TSO
                        if (mss) {      /* TSO */
                                (req - rdma_count)->rdma_count = rdma_count + 1;
 
@@ -2083,10 +2738,9 @@ again:
                                            (small * MXGEFW_FLAGS_SMALL);
                                }
                        }
-#endif                         /* NETIF_F_TSO */
                        req->addr_high = high_swapped;
                        req->addr_low = htonl(low);
-                       req->pseudo_hdr_offset = pseudo_hdr_offset;
+                       req->pseudo_hdr_offset = htons(pseudo_hdr_offset);
                        req->pad = 0;   /* complete solid 16-byte block; does this matter? */
                        req->rdma_count = 1;
                        req->length = htons(seglen);
@@ -2100,10 +2754,12 @@ again:
                        req++;
                        count++;
                        rdma_count++;
-                       if (unlikely(cksum_offset > seglen))
-                               cksum_offset -= seglen;
-                       else
-                               cksum_offset = 0;
+                       if (cksum_offset != 0 && !(mss && skb_is_gso_v6(skb))) {
+                               if (unlikely(cksum_offset > seglen))
+                                       cksum_offset -= seglen;
+                               else
+                                       cksum_offset = 0;
+                       }
                }
                if (frag_idx == frag_cnt)
                        break;
@@ -2120,23 +2776,18 @@ again:
        }
 
        (req - rdma_count)->rdma_count = rdma_count;
-#ifdef NETIF_F_TSO
        if (mss)
                do {
                        req--;
                        req->flags |= MXGEFW_FLAGS_TSO_LAST;
                } while (!(req->flags & (MXGEFW_FLAGS_TSO_CHOP |
                                         MXGEFW_FLAGS_FIRST)));
-#endif
        idx = ((count - 1) + tx->req) & tx->mask;
        tx->info[idx].last = 1;
-       if (tx->wc_fifo == NULL)
-               myri10ge_submit_req(tx, tx->req_list, count);
-       else
-               myri10ge_submit_req_wc(tx, tx->req_list, count);
+       myri10ge_submit_req(tx, tx->req_list, count);
        tx->pkt_start++;
        if ((avail - count) < MXGEFW_MAX_SEND_DESC) {
-               mgp->stop_queue++;
+               tx->stop_queue++;
                netif_stop_queue(dev);
        }
        dev->trans_start = jiffies;
@@ -2178,30 +2829,80 @@ abort_linearize:
        if (skb_linearize(skb))
                goto drop;
 
-       mgp->tx_linearized++;
+       tx->linearized++;
        goto again;
 
 drop:
        dev_kfree_skb_any(skb);
-       mgp->stats.tx_dropped += 1;
+       ss->stats.tx_dropped += 1;
+       return 0;
+
+}
+
+static int myri10ge_sw_tso(struct sk_buff *skb, struct net_device *dev)
+{
+       struct sk_buff *segs, *curr;
+       struct myri10ge_priv *mgp = netdev_priv(dev);
+       int status;
+
+       segs = skb_gso_segment(skb, dev->features & ~NETIF_F_TSO6);
+       if (IS_ERR(segs))
+               goto drop;
+
+       while (segs) {
+               curr = segs;
+               segs = segs->next;
+               curr->next = NULL;
+               status = myri10ge_xmit(curr, dev);
+               if (status != 0) {
+                       dev_kfree_skb_any(curr);
+                       if (segs != NULL) {
+                               curr = segs;
+                               segs = segs->next;
+                               curr->next = NULL;
+                               dev_kfree_skb_any(segs);
+                       }
+                       goto drop;
+               }
+       }
+       dev_kfree_skb_any(skb);
        return 0;
 
+drop:
+       dev_kfree_skb_any(skb);
+       mgp->stats.tx_dropped += 1;
+       return 0;
 }
 
 static struct net_device_stats *myri10ge_get_stats(struct net_device *dev)
 {
        struct myri10ge_priv *mgp = netdev_priv(dev);
-       return &mgp->stats;
+       struct myri10ge_slice_netstats *slice_stats;
+       struct net_device_stats *stats = &mgp->stats;
+       int i;
+
+       memset(stats, 0, sizeof(*stats));
+       for (i = 0; i < mgp->num_slices; i++) {
+               slice_stats = &mgp->ss[i].stats;
+               stats->rx_packets += slice_stats->rx_packets;
+               stats->tx_packets += slice_stats->tx_packets;
+               stats->rx_bytes += slice_stats->rx_bytes;
+               stats->tx_bytes += slice_stats->tx_bytes;
+               stats->rx_dropped += slice_stats->rx_dropped;
+               stats->tx_dropped += slice_stats->tx_dropped;
+       }
+       return stats;
 }
 
 static void myri10ge_set_multicast_list(struct net_device *dev)
 {
+       struct myri10ge_priv *mgp = netdev_priv(dev);
        struct myri10ge_cmd cmd;
-       struct myri10ge_priv *mgp;
        struct dev_mc_list *mc_list;
+       __be32 data[2] = { 0, 0 };
        int err;
+       DECLARE_MAC_BUF(mac);
 
-       mgp = netdev_priv(dev);
        /* can be called from atomic contexts,
         * pass 1 to force atomicity in myri10ge_send_cmd() */
        myri10ge_change_promisc(mgp, dev->flags & IFF_PROMISC, 1);
@@ -2219,7 +2920,7 @@ static void myri10ge_set_multicast_list(struct net_device *dev)
                goto abort;
        }
 
-       if (dev->flags & IFF_ALLMULTI) {
+       if ((dev->flags & IFF_ALLMULTI) || mgp->adopted_rx_filter_bug) {
                /* request to disable multicast filtering, so quit here */
                return;
        }
@@ -2237,10 +2938,9 @@ static void myri10ge_set_multicast_list(struct net_device *dev)
 
        /* Walk the multicast list, and add each address */
        for (mc_list = dev->mc_list; mc_list != NULL; mc_list = mc_list->next) {
-               memcpy(&cmd.data0, &mc_list->dmi_addr, 4);
-               memcpy(&cmd.data1, ((char *)&mc_list->dmi_addr) + 4, 2);
-               cmd.data0 = htonl(cmd.data0);
-               cmd.data1 = htonl(cmd.data1);
+               memcpy(data, &mc_list->dmi_addr, 6);
+               cmd.data0 = ntohl(data[0]);
+               cmd.data1 = ntohl(data[1]);
                err = myri10ge_send_cmd(mgp, MXGEFW_JOIN_MULTICAST_GROUP,
                                        &cmd, 1);
 
@@ -2248,14 +2948,8 @@ static void myri10ge_set_multicast_list(struct net_device *dev)
                        printk(KERN_ERR "myri10ge: %s: Failed "
                               "MXGEFW_JOIN_MULTICAST_GROUP, error status:"
                               "%d\t", dev->name, err);
-                       printk(KERN_ERR "MAC %02x:%02x:%02x:%02x:%02x:%02x\n",
-                              ((unsigned char *)&mc_list->dmi_addr)[0],
-                              ((unsigned char *)&mc_list->dmi_addr)[1],
-                              ((unsigned char *)&mc_list->dmi_addr)[2],
-                              ((unsigned char *)&mc_list->dmi_addr)[3],
-                              ((unsigned char *)&mc_list->dmi_addr)[4],
-                              ((unsigned char *)&mc_list->dmi_addr)[5]
-                           );
+                       printk(KERN_ERR "MAC %s\n",
+                              print_mac(mac, mc_list->dmi_addr));
                        goto abort;
                }
        }
@@ -2344,13 +3038,14 @@ static void myri10ge_enable_ecrc(struct myri10ge_priv *mgp)
        ext_type = (val & PCI_EXP_FLAGS_TYPE) >> 4;
        if (ext_type != PCI_EXP_TYPE_ROOT_PORT) {
                if (myri10ge_ecrc_enable > 1) {
-                       struct pci_dev *old_bridge = bridge;
+                       struct pci_dev *prev_bridge, *old_bridge = bridge;
 
                        /* Walk the hierarchy up to the root port
                         * where ECRC has to be enabled */
                        do {
+                               prev_bridge = bridge;
                                bridge = bridge->bus->self;
-                               if (!bridge) {
+                               if (!bridge || prev_bridge == bridge) {
                                        dev_err(dev,
                                                "Failed to find root port"
                                                " to force ECRC\n");
@@ -2393,8 +3088,6 @@ static void myri10ge_enable_ecrc(struct myri10ge_priv *mgp)
        err_cap |= PCI_ERR_CAP_ECRC_GENE;
        pci_write_config_dword(bridge, cap + PCI_ERR_CAP, err_cap);
        dev_info(dev, "Enabled ECRC on upstream bridge %s\n", pci_name(bridge));
-       mgp->tx.boundary = 4096;
-       mgp->fw_name = myri10ge_fw_aligned;
 }
 
 /*
@@ -2409,23 +3102,71 @@ static void myri10ge_enable_ecrc(struct myri10ge_priv *mgp)
  *
  * If the driver can neither enable ECRC nor verify that it has
  * already been enabled, then it must use a firmware image which works
- * around unaligned completion packets (myri10ge_ethp_z8e.dat), and it
+ * around unaligned completion packets (myri10ge_rss_ethp_z8e.dat), and it
  * should also ensure that it never gives the device a Read-DMA which is
- * larger than 2KB by setting the tx.boundary to 2KB.  If ECRC is
- * enabled, then the driver should use the aligned (myri10ge_eth_z8e.dat)
- * firmware image, and set tx.boundary to 4KB.
+ * larger than 2KB by setting the tx_boundary to 2KB.  If ECRC is
+ * enabled, then the driver should use the aligned (myri10ge_rss_eth_z8e.dat)
+ * firmware image, and set tx_boundary to 4KB.
  */
 
-#define PCI_DEVICE_ID_INTEL_E5000_PCIE23 0x25f7
-#define PCI_DEVICE_ID_INTEL_E5000_PCIE47 0x25fa
-
-static void myri10ge_select_firmware(struct myri10ge_priv *mgp)
+static void myri10ge_firmware_probe(struct myri10ge_priv *mgp)
 {
-       struct pci_dev *bridge = mgp->pdev->bus->self;
+       struct pci_dev *pdev = mgp->pdev;
+       struct device *dev = &pdev->dev;
+       int status;
+
+       mgp->tx_boundary = 4096;
+       /*
+        * Verify the max read request size was set to 4KB
+        * before trying the test with 4KB.
+        */
+       status = pcie_get_readrq(pdev);
+       if (status < 0) {
+               dev_err(dev, "Couldn't read max read req size: %d\n", status);
+               goto abort;
+       }
+       if (status != 4096) {
+               dev_warn(dev, "Max Read Request size != 4096 (%d)\n", status);
+               mgp->tx_boundary = 2048;
+       }
+       /*
+        * load the optimized firmware (which assumes aligned PCIe
+        * completions) in order to see if it works on this host.
+        */
+       mgp->fw_name = myri10ge_fw_aligned;
+       status = myri10ge_load_firmware(mgp, 1);
+       if (status != 0) {
+               goto abort;
+       }
+
+       /*
+        * Enable ECRC if possible
+        */
+       myri10ge_enable_ecrc(mgp);
 
-       mgp->tx.boundary = 2048;
+       /*
+        * Run a DMA test which watches for unaligned completions and
+        * aborts on the first one seen.
+        */
+
+       status = myri10ge_dma_test(mgp, MXGEFW_CMD_UNALIGNED_TEST);
+       if (status == 0)
+               return;         /* keep the aligned firmware */
+
+       if (status != -E2BIG)
+               dev_warn(dev, "DMA test failed: %d\n", status);
+       if (status == -ENOSYS)
+               dev_warn(dev, "Falling back to ethp! "
+                        "Please install up to date fw\n");
+abort:
+       /* fall back to using the unaligned firmware */
+       mgp->tx_boundary = 2048;
        mgp->fw_name = myri10ge_fw_unaligned;
 
+}
+
+static void myri10ge_select_firmware(struct myri10ge_priv *mgp)
+{
        if (myri10ge_force_firmware == 0) {
                int link_width, exp_cap;
                u16 lnk;
@@ -2434,43 +3175,27 @@ static void myri10ge_select_firmware(struct myri10ge_priv *mgp)
                pci_read_config_word(mgp->pdev, exp_cap + PCI_EXP_LNKSTA, &lnk);
                link_width = (lnk >> 4) & 0x3f;
 
-               myri10ge_enable_ecrc(mgp);
-
                /* Check to see if Link is less than 8 or if the
                 * upstream bridge is known to provide aligned
                 * completions */
                if (link_width < 8) {
                        dev_info(&mgp->pdev->dev, "PCIE x%d Link\n",
                                 link_width);
-                       mgp->tx.boundary = 4096;
-                       mgp->fw_name = myri10ge_fw_aligned;
-               } else if (bridge &&
-                          /* ServerWorks HT2000/HT1000 */
-                          ((bridge->vendor == PCI_VENDOR_ID_SERVERWORKS
-                            && bridge->device ==
-                            PCI_DEVICE_ID_SERVERWORKS_HT2000_PCIE)
-                           /* All Intel E5000 PCIE ports */
-                           || (bridge->vendor == PCI_VENDOR_ID_INTEL
-                               && bridge->device >=
-                               PCI_DEVICE_ID_INTEL_E5000_PCIE23
-                               && bridge->device <=
-                               PCI_DEVICE_ID_INTEL_E5000_PCIE47))) {
-                       dev_info(&mgp->pdev->dev,
-                                "Assuming aligned completions (0x%x:0x%x)\n",
-                                bridge->vendor, bridge->device);
-                       mgp->tx.boundary = 4096;
+                       mgp->tx_boundary = 4096;
                        mgp->fw_name = myri10ge_fw_aligned;
+               } else {
+                       myri10ge_firmware_probe(mgp);
                }
        } else {
                if (myri10ge_force_firmware == 1) {
                        dev_info(&mgp->pdev->dev,
                                 "Assuming aligned completions (forced)\n");
-                       mgp->tx.boundary = 4096;
+                       mgp->tx_boundary = 4096;
                        mgp->fw_name = myri10ge_fw_aligned;
                } else {
                        dev_info(&mgp->pdev->dev,
                                 "Assuming unaligned completions (forced)\n");
-                       mgp->tx.boundary = 2048;
+                       mgp->tx_boundary = 2048;
                        mgp->fw_name = myri10ge_fw_unaligned;
                }
        }
@@ -2481,36 +3206,7 @@ static void myri10ge_select_firmware(struct myri10ge_priv *mgp)
        }
 }
 
-static void myri10ge_save_state(struct myri10ge_priv *mgp)
-{
-       struct pci_dev *pdev = mgp->pdev;
-       int cap;
-
-       pci_save_state(pdev);
-       /* now save PCIe and MSI state that Linux will not
-        * save for us */
-       cap = pci_find_capability(pdev, PCI_CAP_ID_EXP);
-       pci_read_config_dword(pdev, cap + PCI_EXP_DEVCTL, &mgp->devctl);
-       cap = pci_find_capability(pdev, PCI_CAP_ID_MSI);
-       pci_read_config_word(pdev, cap + PCI_MSI_FLAGS, &mgp->msi_flags);
-}
-
-static void myri10ge_restore_state(struct myri10ge_priv *mgp)
-{
-       struct pci_dev *pdev = mgp->pdev;
-       int cap;
-
-       /* restore PCIe and MSI state that linux will not */
-       cap = pci_find_capability(pdev, PCI_CAP_ID_EXP);
-       pci_write_config_dword(pdev, cap + PCI_CAP_ID_EXP, mgp->devctl);
-       cap = pci_find_capability(pdev, PCI_CAP_ID_MSI);
-       pci_write_config_word(pdev, cap + PCI_MSI_FLAGS, mgp->msi_flags);
-
-       pci_restore_state(pdev);
-}
-
 #ifdef CONFIG_PM
-
 static int myri10ge_suspend(struct pci_dev *pdev, pm_message_t state)
 {
        struct myri10ge_priv *mgp;
@@ -2529,11 +3225,10 @@ static int myri10ge_suspend(struct pci_dev *pdev, pm_message_t state)
                rtnl_unlock();
        }
        myri10ge_dummy_rdma(mgp, 0);
-       free_irq(pdev->irq, mgp);
-       myri10ge_save_state(mgp);
+       pci_save_state(pdev);
        pci_disable_device(pdev);
-       pci_set_power_state(pdev, pci_choose_state(pdev, state));
-       return 0;
+
+       return pci_set_power_state(pdev, pci_choose_state(pdev, state));
 }
 
 static int myri10ge_resume(struct pci_dev *pdev)
@@ -2555,34 +3250,33 @@ static int myri10ge_resume(struct pci_dev *pdev)
                       mgp->dev->name);
                return -EIO;
        }
-       myri10ge_restore_state(mgp);
+
+       status = pci_restore_state(pdev);
+       if (status)
+               return status;
 
        status = pci_enable_device(pdev);
-       if (status < 0) {
+       if (status) {
                dev_err(&pdev->dev, "failed to enable device\n");
-               return -EIO;
+               return status;
        }
 
        pci_set_master(pdev);
 
-       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_enabled;
-       }
-
        myri10ge_reset(mgp);
        myri10ge_dummy_rdma(mgp, 1);
 
        /* Save configuration space to be restored if the
         * nic resets due to a parity error */
-       myri10ge_save_state(mgp);
+       pci_save_state(pdev);
 
        if (netif_running(netdev)) {
                rtnl_lock();
-               myri10ge_open(netdev);
+               status = myri10ge_open(netdev);
                rtnl_unlock();
+               if (status != 0)
+                       goto abort_with_enabled;
+
        }
        netif_device_attach(netdev);
 
@@ -2593,7 +3287,6 @@ abort_with_enabled:
        return -EIO;
 
 }
-
 #endif                         /* CONFIG_PM */
 
 static u32 myri10ge_read_reboot(struct myri10ge_priv *mgp)
@@ -2615,11 +3308,14 @@ static u32 myri10ge_read_reboot(struct myri10ge_priv *mgp)
  * This watchdog is used to check whether the board has suffered
  * from a parity error and needs to be recovered.
  */
-static void myri10ge_watchdog(void *arg)
+static void myri10ge_watchdog(struct work_struct *work)
 {
-       struct myri10ge_priv *mgp = arg;
+       struct myri10ge_priv *mgp =
+           container_of(work, struct myri10ge_priv, watchdog_work);
+       struct myri10ge_tx_buf *tx;
        u32 reboot;
        int status;
+       int i;
        u16 cmd, vendor;
 
        mgp->watchdog_resets++;
@@ -2630,8 +3326,14 @@ static void myri10ge_watchdog(void *arg)
                 * For now, just report it */
                reboot = myri10ge_read_reboot(mgp);
                printk(KERN_ERR
-                      "myri10ge: %s: NIC rebooted (0x%x), resetting\n",
-                      mgp->dev->name, reboot);
+                      "myri10ge: %s: NIC rebooted (0x%x),%s resetting\n",
+                      mgp->dev->name, reboot,
+                      myri10ge_reset_recover ? " " : " not");
+               if (myri10ge_reset_recover == 0)
+                       return;
+
+               myri10ge_reset_recover--;
+
                /*
                 * A rebooted nic will come back with config space as
                 * it was after power was applied to PCIe bus.
@@ -2639,7 +3341,11 @@ static void myri10ge_watchdog(void *arg)
                 * when the driver was loaded, or the last time the
                 * nic was resumed from power saving mode.
                 */
-               myri10ge_restore_state(mgp);
+               pci_restore_state(mgp->pdev);
+
+               /* save state again for accounting reasons */
+               pci_save_state(mgp->pdev);
+
        } else {
                /* if we get back -1's from our slot, perhaps somebody
                 * powered off our card.  Don't try to reset it in
@@ -2657,19 +3363,26 @@ static void myri10ge_watchdog(void *arg)
 
                printk(KERN_ERR "myri10ge: %s: device timeout, resetting\n",
                       mgp->dev->name);
-               printk(KERN_INFO "myri10ge: %s: %d %d %d %d %d\n",
-                      mgp->dev->name, mgp->tx.req, mgp->tx.done,
-                      mgp->tx.pkt_start, mgp->tx.pkt_done,
-                      (int)ntohl(mgp->fw_stats->send_done_count));
-               msleep(2000);
-               printk(KERN_INFO "myri10ge: %s: %d %d %d %d %d\n",
-                      mgp->dev->name, mgp->tx.req, mgp->tx.done,
-                      mgp->tx.pkt_start, mgp->tx.pkt_done,
-                      (int)ntohl(mgp->fw_stats->send_done_count));
+               for (i = 0; i < mgp->num_slices; i++) {
+                       tx = &mgp->ss[i].tx;
+                       printk(KERN_INFO
+                              "myri10ge: %s: (%d): %d %d %d %d %d\n",
+                              mgp->dev->name, i, tx->req, tx->done,
+                              tx->pkt_start, tx->pkt_done,
+                              (int)ntohl(mgp->ss[i].fw_stats->
+                                         send_done_count));
+                       msleep(2000);
+                       printk(KERN_INFO
+                              "myri10ge: %s: (%d): %d %d %d %d %d\n",
+                              mgp->dev->name, i, tx->req, tx->done,
+                              tx->pkt_start, tx->pkt_done,
+                              (int)ntohl(mgp->ss[i].fw_stats->
+                                         send_done_count));
+               }
        }
        rtnl_lock();
        myri10ge_close(mgp->dev);
-       status = myri10ge_load_firmware(mgp);
+       status = myri10ge_load_firmware(mgp, 1);
        if (status != 0)
                printk(KERN_ERR "myri10ge: %s: failed to load firmware\n",
                       mgp->dev->name);
@@ -2688,20 +3401,246 @@ static void myri10ge_watchdog(void *arg)
 static void myri10ge_watchdog_timer(unsigned long arg)
 {
        struct myri10ge_priv *mgp;
+       struct myri10ge_slice_state *ss;
+       int i, reset_needed;
+       u32 rx_pause_cnt;
 
        mgp = (struct myri10ge_priv *)arg;
-       if (mgp->tx.req != mgp->tx.done &&
-           mgp->tx.done == mgp->watchdog_tx_done &&
-           mgp->watchdog_tx_req != mgp->watchdog_tx_done)
-               /* nic seems like it might be stuck.. */
+
+       rx_pause_cnt = ntohl(mgp->ss[0].fw_stats->dropped_pause);
+       for (i = 0, reset_needed = 0;
+            i < mgp->num_slices && reset_needed == 0; ++i) {
+
+               ss = &mgp->ss[i];
+               if (ss->rx_small.watchdog_needed) {
+                       myri10ge_alloc_rx_pages(mgp, &ss->rx_small,
+                                               mgp->small_bytes + MXGEFW_PAD,
+                                               1);
+                       if (ss->rx_small.fill_cnt - ss->rx_small.cnt >=
+                           myri10ge_fill_thresh)
+                               ss->rx_small.watchdog_needed = 0;
+               }
+               if (ss->rx_big.watchdog_needed) {
+                       myri10ge_alloc_rx_pages(mgp, &ss->rx_big,
+                                               mgp->big_bytes, 1);
+                       if (ss->rx_big.fill_cnt - ss->rx_big.cnt >=
+                           myri10ge_fill_thresh)
+                               ss->rx_big.watchdog_needed = 0;
+               }
+
+               if (ss->tx.req != ss->tx.done &&
+                   ss->tx.done == ss->watchdog_tx_done &&
+                   ss->watchdog_tx_req != ss->watchdog_tx_done) {
+                       /* nic seems like it might be stuck.. */
+                       if (rx_pause_cnt != mgp->watchdog_pause) {
+                               if (net_ratelimit())
+                                       printk(KERN_WARNING "myri10ge %s:"
+                                              "TX paused, check link partner\n",
+                                              mgp->dev->name);
+                       } else {
+                               reset_needed = 1;
+                       }
+               }
+               ss->watchdog_tx_done = ss->tx.done;
+               ss->watchdog_tx_req = ss->tx.req;
+       }
+       mgp->watchdog_pause = rx_pause_cnt;
+
+       if (reset_needed) {
                schedule_work(&mgp->watchdog_work);
-       else
+       } else {
                /* rearm timer */
                mod_timer(&mgp->watchdog_timer,
                          jiffies + myri10ge_watchdog_timeout * HZ);
+       }
+}
+
+static void myri10ge_free_slices(struct myri10ge_priv *mgp)
+{
+       struct myri10ge_slice_state *ss;
+       struct pci_dev *pdev = mgp->pdev;
+       size_t bytes;
+       int i;
+
+       if (mgp->ss == NULL)
+               return;
+
+       for (i = 0; i < mgp->num_slices; i++) {
+               ss = &mgp->ss[i];
+               if (ss->rx_done.entry != NULL) {
+                       bytes = mgp->max_intr_slots *
+                           sizeof(*ss->rx_done.entry);
+                       dma_free_coherent(&pdev->dev, bytes,
+                                         ss->rx_done.entry, ss->rx_done.bus);
+                       ss->rx_done.entry = NULL;
+               }
+               if (ss->fw_stats != NULL) {
+                       bytes = sizeof(*ss->fw_stats);
+                       dma_free_coherent(&pdev->dev, bytes,
+                                         ss->fw_stats, ss->fw_stats_bus);
+                       ss->fw_stats = NULL;
+               }
+       }
+       kfree(mgp->ss);
+       mgp->ss = NULL;
+}
+
+static int myri10ge_alloc_slices(struct myri10ge_priv *mgp)
+{
+       struct myri10ge_slice_state *ss;
+       struct pci_dev *pdev = mgp->pdev;
+       size_t bytes;
+       int i;
+
+       bytes = sizeof(*mgp->ss) * mgp->num_slices;
+       mgp->ss = kzalloc(bytes, GFP_KERNEL);
+       if (mgp->ss == NULL) {
+               return -ENOMEM;
+       }
+
+       for (i = 0; i < mgp->num_slices; i++) {
+               ss = &mgp->ss[i];
+               bytes = mgp->max_intr_slots * sizeof(*ss->rx_done.entry);
+               ss->rx_done.entry = dma_alloc_coherent(&pdev->dev, bytes,
+                                                      &ss->rx_done.bus,
+                                                      GFP_KERNEL);
+               if (ss->rx_done.entry == NULL)
+                       goto abort;
+               memset(ss->rx_done.entry, 0, bytes);
+               bytes = sizeof(*ss->fw_stats);
+               ss->fw_stats = dma_alloc_coherent(&pdev->dev, bytes,
+                                                 &ss->fw_stats_bus,
+                                                 GFP_KERNEL);
+               if (ss->fw_stats == NULL)
+                       goto abort;
+               ss->mgp = mgp;
+               ss->dev = mgp->dev;
+               netif_napi_add(ss->dev, &ss->napi, myri10ge_poll,
+                              myri10ge_napi_weight);
+       }
+       return 0;
+abort:
+       myri10ge_free_slices(mgp);
+       return -ENOMEM;
+}
+
+/*
+ * This function determines the number of slices supported.
+ * The number slices is the minumum of the number of CPUS,
+ * the number of MSI-X irqs supported, the number of slices
+ * supported by the firmware
+ */
+static void myri10ge_probe_slices(struct myri10ge_priv *mgp)
+{
+       struct myri10ge_cmd cmd;
+       struct pci_dev *pdev = mgp->pdev;
+       char *old_fw;
+       int i, status, ncpus, msix_cap;
+
+       mgp->num_slices = 1;
+       msix_cap = pci_find_capability(pdev, PCI_CAP_ID_MSIX);
+       ncpus = num_online_cpus();
+
+       if (myri10ge_max_slices == 1 || msix_cap == 0 ||
+           (myri10ge_max_slices == -1 && ncpus < 2))
+               return;
+
+       /* try to load the slice aware rss firmware */
+       old_fw = mgp->fw_name;
+       if (myri10ge_fw_name != NULL) {
+               dev_info(&mgp->pdev->dev, "overriding rss firmware to %s\n",
+                        myri10ge_fw_name);
+               mgp->fw_name = myri10ge_fw_name;
+       } else if (old_fw == myri10ge_fw_aligned)
+               mgp->fw_name = myri10ge_fw_rss_aligned;
+       else
+               mgp->fw_name = myri10ge_fw_rss_unaligned;
+       status = myri10ge_load_firmware(mgp, 0);
+       if (status != 0) {
+               dev_info(&pdev->dev, "Rss firmware not found\n");
+               return;
+       }
+
+       /* hit the board with a reset to ensure it is alive */
+       memset(&cmd, 0, sizeof(cmd));
+       status = myri10ge_send_cmd(mgp, MXGEFW_CMD_RESET, &cmd, 0);
+       if (status != 0) {
+               dev_err(&mgp->pdev->dev, "failed reset\n");
+               goto abort_with_fw;
+               return;
+       }
+
+       mgp->max_intr_slots = cmd.data0 / sizeof(struct mcp_slot);
+
+       /* tell it the size of the interrupt queues */
+       cmd.data0 = mgp->max_intr_slots * sizeof(struct mcp_slot);
+       status = myri10ge_send_cmd(mgp, MXGEFW_CMD_SET_INTRQ_SIZE, &cmd, 0);
+       if (status != 0) {
+               dev_err(&mgp->pdev->dev, "failed MXGEFW_CMD_SET_INTRQ_SIZE\n");
+               goto abort_with_fw;
+       }
+
+       /* ask the maximum number of slices it supports */
+       status = myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_MAX_RSS_QUEUES, &cmd, 0);
+       if (status != 0)
+               goto abort_with_fw;
+       else
+               mgp->num_slices = cmd.data0;
+
+       /* Only allow multiple slices if MSI-X is usable */
+       if (!myri10ge_msi) {
+               goto abort_with_fw;
+       }
+
+       /* if the admin did not specify a limit to how many
+        * slices we should use, cap it automatically to the
+        * number of CPUs currently online */
+       if (myri10ge_max_slices == -1)
+               myri10ge_max_slices = ncpus;
+
+       if (mgp->num_slices > myri10ge_max_slices)
+               mgp->num_slices = myri10ge_max_slices;
+
+       /* Now try to allocate as many MSI-X vectors as we have
+        * slices. We give up on MSI-X if we can only get a single
+        * vector. */
+
+       mgp->msix_vectors = kzalloc(mgp->num_slices *
+                                   sizeof(*mgp->msix_vectors), GFP_KERNEL);
+       if (mgp->msix_vectors == NULL)
+               goto disable_msix;
+       for (i = 0; i < mgp->num_slices; i++) {
+               mgp->msix_vectors[i].entry = i;
+       }
+
+       while (mgp->num_slices > 1) {
+               /* make sure it is a power of two */
+               while (!is_power_of_2(mgp->num_slices))
+                       mgp->num_slices--;
+               if (mgp->num_slices == 1)
+                       goto disable_msix;
+               status = pci_enable_msix(pdev, mgp->msix_vectors,
+                                        mgp->num_slices);
+               if (status == 0) {
+                       pci_disable_msix(pdev);
+                       return;
+               }
+               if (status > 0)
+                       mgp->num_slices = status;
+               else
+                       goto disable_msix;
+       }
+
+disable_msix:
+       if (mgp->msix_vectors != NULL) {
+               kfree(mgp->msix_vectors);
+               mgp->msix_vectors = NULL;
+       }
 
-       mgp->watchdog_tx_done = mgp->tx.done;
-       mgp->watchdog_tx_req = mgp->tx.req;
+abort_with_fw:
+       mgp->num_slices = 1;
+       mgp->fw_name = old_fw;
+       myri10ge_load_firmware(mgp, 0);
 }
 
 static int myri10ge_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
@@ -2709,12 +3648,9 @@ static int myri10ge_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        struct net_device *netdev;
        struct myri10ge_priv *mgp;
        struct device *dev = &pdev->dev;
-       size_t bytes;
        int i;
        int status = -ENXIO;
-       int cap;
        int dac_enabled;
-       u16 val;
 
        netdev = alloc_etherdev(sizeof(*mgp));
        if (netdev == NULL) {
@@ -2722,8 +3658,9 @@ static int myri10ge_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
                return -ENOMEM;
        }
 
+       SET_NETDEV_DEV(netdev, &pdev->dev);
+
        mgp = netdev_priv(netdev);
-       memset(mgp, 0, sizeof(*mgp));
        mgp->dev = netdev;
        mgp->pdev = pdev;
        mgp->csum_flag = MXGEFW_FLAGS_CKSUM;
@@ -2737,7 +3674,6 @@ static int myri10ge_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
                status = -ENODEV;
                goto abort_with_netdev;
        }
-       myri10ge_select_firmware(mgp);
 
        /* Find the vendor-specific cap so we can check
         * the reboot register later on */
@@ -2745,19 +3681,7 @@ static int myri10ge_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
            = pci_find_capability(pdev, PCI_CAP_ID_VNDR);
 
        /* Set our max read request to 4KB */
-       cap = pci_find_capability(pdev, PCI_CAP_ID_EXP);
-       if (cap < 64) {
-               dev_err(&pdev->dev, "Bad PCI_CAP_ID_EXP location %d\n", cap);
-               goto abort_with_netdev;
-       }
-       status = pci_read_config_word(pdev, cap + PCI_EXP_DEVCTL, &val);
-       if (status != 0) {
-               dev_err(&pdev->dev, "Error %d reading PCI_EXP_DEVCTL\n",
-                       status);
-               goto abort_with_netdev;
-       }
-       val = (val & ~PCI_EXP_DEVCTL_READRQ) | (5 << 12);
-       status = pci_write_config_word(pdev, cap + PCI_EXP_DEVCTL, val);
+       status = pcie_set_readrq(pdev, 4096);
        if (status != 0) {
                dev_err(&pdev->dev, "Error %d writing PCI_EXP_DEVCTL\n",
                        status);
@@ -2770,29 +3694,29 @@ static int myri10ge_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        if (status != 0) {
                dac_enabled = 0;
                dev_err(&pdev->dev,
-                       "64-bit pci address mask was refused, trying 32-bit");
+                       "64-bit pci address mask was refused, "
+                       "trying 32-bit\n");
                status = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
        }
        if (status != 0) {
                dev_err(&pdev->dev, "Error %d setting DMA mask\n", status);
                goto abort_with_netdev;
        }
+       (void)pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK);
        mgp->cmd = dma_alloc_coherent(&pdev->dev, sizeof(*mgp->cmd),
                                      &mgp->cmd_bus, GFP_KERNEL);
        if (mgp->cmd == NULL)
                goto abort_with_netdev;
 
-       mgp->fw_stats = dma_alloc_coherent(&pdev->dev, sizeof(*mgp->fw_stats),
-                                          &mgp->fw_stats_bus, GFP_KERNEL);
-       if (mgp->fw_stats == NULL)
-               goto abort_with_cmd;
-
        mgp->board_span = pci_resource_len(pdev, 0);
        mgp->iomem_base = pci_resource_start(pdev, 0);
        mgp->mtrr = -1;
+       mgp->wc_enabled = 0;
 #ifdef CONFIG_MTRR
        mgp->mtrr = mtrr_add(mgp->iomem_base, mgp->board_span,
                             MTRR_TYPE_WRCOMB, 1);
+       if (mgp->mtrr >= 0)
+               mgp->wc_enabled = 1;
 #endif
        /* Hack.  need to get rid of these magic numbers */
        mgp->sram_size =
@@ -2800,14 +3724,14 @@ static int myri10ge_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        if (mgp->sram_size > mgp->board_span) {
                dev_err(&pdev->dev, "board span %ld bytes too small\n",
                        mgp->board_span);
-               goto abort_with_wc;
+               goto abort_with_mtrr;
        }
-       mgp->sram = ioremap(mgp->iomem_base, mgp->board_span);
+       mgp->sram = ioremap_wc(mgp->iomem_base, mgp->board_span);
        if (mgp->sram == NULL) {
                dev_err(&pdev->dev, "ioremap failed for %ld bytes at 0x%lx\n",
                        mgp->board_span, mgp->iomem_base);
                status = -ENXIO;
-               goto abort_with_wc;
+               goto abort_with_mtrr;
        }
        memcpy_fromio(mgp->eeprom_strings,
                      mgp->sram + mgp->sram_size - MYRI10GE_EEPROM_STRINGS_SIZE,
@@ -2820,43 +3744,28 @@ static int myri10ge_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        for (i = 0; i < ETH_ALEN; i++)
                netdev->dev_addr[i] = mgp->mac_addr[i];
 
-       /* allocate rx done ring */
-       bytes = myri10ge_max_intr_slots * sizeof(*mgp->rx_done.entry);
-       mgp->rx_done.entry = dma_alloc_coherent(&pdev->dev, bytes,
-                                               &mgp->rx_done.bus, GFP_KERNEL);
-       if (mgp->rx_done.entry == NULL)
-               goto abort_with_ioremap;
-       memset(mgp->rx_done.entry, 0, bytes);
+       myri10ge_select_firmware(mgp);
 
-       status = myri10ge_load_firmware(mgp);
+       status = myri10ge_load_firmware(mgp, 1);
        if (status != 0) {
                dev_err(&pdev->dev, "failed to load firmware\n");
-               goto abort_with_rx_done;
+               goto abort_with_ioremap;
        }
-
-       status = myri10ge_reset(mgp);
+       myri10ge_probe_slices(mgp);
+       status = myri10ge_alloc_slices(mgp);
        if (status != 0) {
-               dev_err(&pdev->dev, "failed reset\n");
+               dev_err(&pdev->dev, "failed to alloc slice state\n");
                goto abort_with_firmware;
        }
 
-       if (myri10ge_msi) {
-               status = pci_enable_msi(pdev);
-               if (status != 0)
-                       dev_err(&pdev->dev,
-                               "Error %d setting up MSI; falling back to xPIC\n",
-                               status);
-               else
-                       mgp->msi_enabled = 1;
-       }
-
-       status = request_irq(pdev->irq, myri10ge_intr, IRQF_SHARED,
-                            netdev->name, mgp);
+       status = myri10ge_reset(mgp);
        if (status != 0) {
-               dev_err(&pdev->dev, "failed to allocate IRQ\n");
-               goto abort_with_firmware;
+               dev_err(&pdev->dev, "failed reset\n");
+               goto abort_with_slices;
        }
-
+#ifdef CONFIG_DCA
+       myri10ge_setup_dca(mgp);
+#endif
        pci_set_drvdata(pdev, mgp);
        if ((myri10ge_initial_mtu + ETH_HLEN) > MYRI10GE_MAX_ETHER_MTU)
                myri10ge_initial_mtu = MYRI10GE_MAX_ETHER_MTU - ETH_HLEN;
@@ -2868,63 +3777,66 @@ static int myri10ge_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        netdev->hard_start_xmit = myri10ge_xmit;
        netdev->get_stats = myri10ge_get_stats;
        netdev->base_addr = mgp->iomem_base;
-       netdev->irq = pdev->irq;
        netdev->change_mtu = myri10ge_change_mtu;
        netdev->set_multicast_list = myri10ge_set_multicast_list;
        netdev->set_mac_address = myri10ge_set_mac_address;
-       netdev->features = NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_TSO;
+       netdev->features = mgp->features;
        if (dac_enabled)
                netdev->features |= NETIF_F_HIGHDMA;
-       netdev->poll = myri10ge_poll;
-       netdev->weight = myri10ge_napi_weight;
+
+       /* make sure we can get an irq, and that MSI can be
+        * setup (if available).  Also ensure netdev->irq
+        * is set to correct value if MSI is enabled */
+       status = myri10ge_request_irq(mgp);
+       if (status != 0)
+               goto abort_with_firmware;
+       netdev->irq = pdev->irq;
+       myri10ge_free_irq(mgp);
 
        /* Save configuration space to be restored if the
         * nic resets due to a parity error */
-       myri10ge_save_state(mgp);
+       pci_save_state(pdev);
 
        /* Setup the watchdog timer */
        setup_timer(&mgp->watchdog_timer, myri10ge_watchdog_timer,
                    (unsigned long)mgp);
 
        SET_ETHTOOL_OPS(netdev, &myri10ge_ethtool_ops);
-       INIT_WORK(&mgp->watchdog_work, myri10ge_watchdog, mgp);
+       INIT_WORK(&mgp->watchdog_work, myri10ge_watchdog);
        status = register_netdev(netdev);
        if (status != 0) {
                dev_err(&pdev->dev, "register_netdev failed: %d\n", status);
-               goto abort_with_irq;
+               goto abort_with_state;
        }
-       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"));
+       if (mgp->msix_enabled)
+               dev_info(dev, "%d MSI-X IRQs, tx bndry %d, fw %s, WC %s\n",
+                        mgp->num_slices, mgp->tx_boundary, mgp->fw_name,
+                        (mgp->wc_enabled ? "Enabled" : "Disabled"));
+       else
+               dev_info(dev, "%s IRQ %d, tx bndry %d, fw %s, WC %s\n",
+                        mgp->msi_enabled ? "MSI" : "xPIC",
+                        netdev->irq, mgp->tx_boundary, mgp->fw_name,
+                        (mgp->wc_enabled ? "Enabled" : "Disabled"));
 
        return 0;
 
-abort_with_irq:
-       free_irq(pdev->irq, mgp);
-       if (mgp->msi_enabled)
-               pci_disable_msi(pdev);
+abort_with_state:
+       pci_restore_state(pdev);
+
+abort_with_slices:
+       myri10ge_free_slices(mgp);
 
 abort_with_firmware:
        myri10ge_dummy_rdma(mgp, 0);
 
-abort_with_rx_done:
-       bytes = myri10ge_max_intr_slots * sizeof(*mgp->rx_done.entry);
-       dma_free_coherent(&pdev->dev, bytes,
-                         mgp->rx_done.entry, mgp->rx_done.bus);
-
 abort_with_ioremap:
        iounmap(mgp->sram);
 
-abort_with_wc:
+abort_with_mtrr:
 #ifdef CONFIG_MTRR
        if (mgp->mtrr >= 0)
                mtrr_del(mgp->mtrr, mgp->iomem_base, mgp->board_span);
 #endif
-       dma_free_coherent(&pdev->dev, sizeof(*mgp->fw_stats),
-                         mgp->fw_stats, mgp->fw_stats_bus);
-
-abort_with_cmd:
        dma_free_coherent(&pdev->dev, sizeof(*mgp->cmd),
                          mgp->cmd, mgp->cmd_bus);
 
@@ -2945,7 +3857,6 @@ static void myri10ge_remove(struct pci_dev *pdev)
 {
        struct myri10ge_priv *mgp;
        struct net_device *netdev;
-       size_t bytes;
 
        mgp = pci_get_drvdata(pdev);
        if (mgp == NULL)
@@ -2954,15 +3865,14 @@ static void myri10ge_remove(struct pci_dev *pdev)
        flush_scheduled_work();
        netdev = mgp->dev;
        unregister_netdev(netdev);
-       free_irq(pdev->irq, mgp);
-       if (mgp->msi_enabled)
-               pci_disable_msi(pdev);
 
+#ifdef CONFIG_DCA
+       myri10ge_teardown_dca(mgp);
+#endif
        myri10ge_dummy_rdma(mgp, 0);
 
-       bytes = myri10ge_max_intr_slots * sizeof(*mgp->rx_done.entry);
-       dma_free_coherent(&pdev->dev, bytes,
-                         mgp->rx_done.entry, mgp->rx_done.bus);
+       /* avoid a memory leak */
+       pci_restore_state(pdev);
 
        iounmap(mgp->sram);
 
@@ -2970,9 +3880,9 @@ static void myri10ge_remove(struct pci_dev *pdev)
        if (mgp->mtrr >= 0)
                mtrr_del(mgp->mtrr, mgp->iomem_base, mgp->board_span);
 #endif
-       dma_free_coherent(&pdev->dev, sizeof(*mgp->fw_stats),
-                         mgp->fw_stats, mgp->fw_stats_bus);
-
+       myri10ge_free_slices(mgp);
+       if (mgp->msix_vectors != NULL)
+               kfree(mgp->msix_vectors);
        dma_free_coherent(&pdev->dev, sizeof(*mgp->cmd),
                          mgp->cmd, mgp->cmd_bus);
 
@@ -2981,9 +3891,12 @@ static void myri10ge_remove(struct pci_dev *pdev)
 }
 
 #define PCI_DEVICE_ID_MYRICOM_MYRI10GE_Z8E     0x0008
+#define PCI_DEVICE_ID_MYRICOM_MYRI10GE_Z8E_9   0x0009
 
 static struct pci_device_id myri10ge_pci_tbl[] = {
        {PCI_DEVICE(PCI_VENDOR_ID_MYRICOM, PCI_DEVICE_ID_MYRICOM_MYRI10GE_Z8E)},
+       {PCI_DEVICE
+        (PCI_VENDOR_ID_MYRICOM, PCI_DEVICE_ID_MYRICOM_MYRI10GE_Z8E_9)},
        {0},
 };
 
@@ -2998,10 +3911,42 @@ static struct pci_driver myri10ge_driver = {
 #endif
 };
 
+#ifdef CONFIG_DCA
+static int
+myri10ge_notify_dca(struct notifier_block *nb, unsigned long event, void *p)
+{
+       int err = driver_for_each_device(&myri10ge_driver.driver,
+                                        NULL, &event,
+                                        myri10ge_notify_dca_device);
+
+       if (err)
+               return NOTIFY_BAD;
+       return NOTIFY_DONE;
+}
+
+static struct notifier_block myri10ge_dca_notifier = {
+       .notifier_call = myri10ge_notify_dca,
+       .next = NULL,
+       .priority = 0,
+};
+#endif                         /* CONFIG_DCA */
+
 static __init int myri10ge_init_module(void)
 {
        printk(KERN_INFO "%s: Version %s\n", myri10ge_driver.name,
               MYRI10GE_VERSION_STR);
+
+       if (myri10ge_rss_hash > MXGEFW_RSS_HASH_TYPE_SRC_PORT ||
+           myri10ge_rss_hash < MXGEFW_RSS_HASH_TYPE_IPV4) {
+               printk(KERN_ERR
+                      "%s: Illegal rssh hash type %d, defaulting to source port\n",
+                      myri10ge_driver.name, myri10ge_rss_hash);
+               myri10ge_rss_hash = MXGEFW_RSS_HASH_TYPE_SRC_PORT;
+       }
+#ifdef CONFIG_DCA
+       dca_register_notify(&myri10ge_dca_notifier);
+#endif
+
        return pci_register_driver(&myri10ge_driver);
 }
 
@@ -3009,6 +3954,9 @@ module_init(myri10ge_init_module);
 
 static __exit void myri10ge_cleanup_module(void)
 {
+#ifdef CONFIG_DCA
+       dca_unregister_notify(&myri10ge_dca_notifier);
+#endif
        pci_unregister_driver(&myri10ge_driver);
 }