pcnet_cs: add cis of PreMax PE-200 ethernet pcmcia card
[safe/jmp/linux-2.6] / drivers / net / bnx2.c
index e817802..08cddb6 100644 (file)
@@ -1,6 +1,6 @@
 /* bnx2.c: Broadcom NX2 network driver.
  *
- * Copyright (c) 2004-2008 Broadcom Corporation
+ * Copyright (c) 2004-2009 Broadcom Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
 #include <linux/crc32.h>
 #include <linux/prefetch.h>
 #include <linux/cache.h>
-#include <linux/zlib.h>
+#include <linux/firmware.h>
 #include <linux/log2.h>
+#include <linux/list.h>
 
+#if defined(CONFIG_CNIC) || defined(CONFIG_CNIC_MODULE)
+#define BCM_CNIC 1
+#include "cnic_if.h"
+#endif
 #include "bnx2.h"
 #include "bnx2_fw.h"
-#include "bnx2_fw2.h"
-
-#define FW_BUF_SIZE            0x10000
 
 #define DRV_MODULE_NAME                "bnx2"
 #define PFX DRV_MODULE_NAME    ": "
-#define DRV_MODULE_VERSION     "1.9.0"
-#define DRV_MODULE_RELDATE     "Dec 16, 2008"
+#define DRV_MODULE_VERSION     "2.0.2"
+#define DRV_MODULE_RELDATE     "Aug 21, 2009"
+#define FW_MIPS_FILE_06                "bnx2/bnx2-mips-06-5.0.0.j3.fw"
+#define FW_RV2P_FILE_06                "bnx2/bnx2-rv2p-06-5.0.0.j3.fw"
+#define FW_MIPS_FILE_09                "bnx2/bnx2-mips-09-5.0.0.j3.fw"
+#define FW_RV2P_FILE_09_Ax     "bnx2/bnx2-rv2p-09ax-5.0.0.j3.fw"
+#define FW_RV2P_FILE_09                "bnx2/bnx2-rv2p-09-5.0.0.j3.fw"
 
 #define RUN_AT(x) (jiffies + (x))
 
@@ -72,6 +79,11 @@ MODULE_AUTHOR("Michael Chan <mchan@broadcom.com>");
 MODULE_DESCRIPTION("Broadcom NetXtreme II BCM5706/5708/5709/5716 Driver");
 MODULE_LICENSE("GPL");
 MODULE_VERSION(DRV_MODULE_VERSION);
+MODULE_FIRMWARE(FW_MIPS_FILE_06);
+MODULE_FIRMWARE(FW_RV2P_FILE_06);
+MODULE_FIRMWARE(FW_MIPS_FILE_09);
+MODULE_FIRMWARE(FW_RV2P_FILE_09);
+MODULE_FIRMWARE(FW_RV2P_FILE_09_Ax);
 
 static int disable_msi = 0;
 
@@ -135,7 +147,7 @@ static DEFINE_PCI_DEVICE_TABLE(bnx2_pci_tbl) = {
        { 0, }
 };
 
-static struct flash_spec flash_table[] =
+static const struct flash_spec flash_table[] =
 {
 #define BUFFERED_FLAGS         (BNX2_NV_BUFFERED | BNX2_NV_TRANSLATE)
 #define NONBUFFERED_FLAGS      (BNX2_NV_WREN)
@@ -224,7 +236,7 @@ static struct flash_spec flash_table[] =
         "Buffered flash (256kB)"},
 };
 
-static struct flash_spec flash_5709 = {
+static const struct flash_spec flash_5709 = {
        .flags          = BNX2_NV_BUFFERED,
        .page_bits      = BCM5709_FLASH_PAGE_BITS,
        .page_size      = BCM5709_FLASH_PAGE_SIZE,
@@ -310,6 +322,160 @@ bnx2_ctx_wr(struct bnx2 *bp, u32 cid_addr, u32 offset, u32 val)
        spin_unlock_bh(&bp->indirect_lock);
 }
 
+#ifdef BCM_CNIC
+static int
+bnx2_drv_ctl(struct net_device *dev, struct drv_ctl_info *info)
+{
+       struct bnx2 *bp = netdev_priv(dev);
+       struct drv_ctl_io *io = &info->data.io;
+
+       switch (info->cmd) {
+       case DRV_CTL_IO_WR_CMD:
+               bnx2_reg_wr_ind(bp, io->offset, io->data);
+               break;
+       case DRV_CTL_IO_RD_CMD:
+               io->data = bnx2_reg_rd_ind(bp, io->offset);
+               break;
+       case DRV_CTL_CTX_WR_CMD:
+               bnx2_ctx_wr(bp, io->cid_addr, io->offset, io->data);
+               break;
+       default:
+               return -EINVAL;
+       }
+       return 0;
+}
+
+static void bnx2_setup_cnic_irq_info(struct bnx2 *bp)
+{
+       struct cnic_eth_dev *cp = &bp->cnic_eth_dev;
+       struct bnx2_napi *bnapi = &bp->bnx2_napi[0];
+       int sb_id;
+
+       if (bp->flags & BNX2_FLAG_USING_MSIX) {
+               cp->drv_state |= CNIC_DRV_STATE_USING_MSIX;
+               bnapi->cnic_present = 0;
+               sb_id = bp->irq_nvecs;
+               cp->irq_arr[0].irq_flags |= CNIC_IRQ_FL_MSIX;
+       } else {
+               cp->drv_state &= ~CNIC_DRV_STATE_USING_MSIX;
+               bnapi->cnic_tag = bnapi->last_status_idx;
+               bnapi->cnic_present = 1;
+               sb_id = 0;
+               cp->irq_arr[0].irq_flags &= ~CNIC_IRQ_FL_MSIX;
+       }
+
+       cp->irq_arr[0].vector = bp->irq_tbl[sb_id].vector;
+       cp->irq_arr[0].status_blk = (void *)
+               ((unsigned long) bnapi->status_blk.msi +
+               (BNX2_SBLK_MSIX_ALIGN_SIZE * sb_id));
+       cp->irq_arr[0].status_blk_num = sb_id;
+       cp->num_irq = 1;
+}
+
+static int bnx2_register_cnic(struct net_device *dev, struct cnic_ops *ops,
+                             void *data)
+{
+       struct bnx2 *bp = netdev_priv(dev);
+       struct cnic_eth_dev *cp = &bp->cnic_eth_dev;
+
+       if (ops == NULL)
+               return -EINVAL;
+
+       if (cp->drv_state & CNIC_DRV_STATE_REGD)
+               return -EBUSY;
+
+       bp->cnic_data = data;
+       rcu_assign_pointer(bp->cnic_ops, ops);
+
+       cp->num_irq = 0;
+       cp->drv_state = CNIC_DRV_STATE_REGD;
+
+       bnx2_setup_cnic_irq_info(bp);
+
+       return 0;
+}
+
+static int bnx2_unregister_cnic(struct net_device *dev)
+{
+       struct bnx2 *bp = netdev_priv(dev);
+       struct bnx2_napi *bnapi = &bp->bnx2_napi[0];
+       struct cnic_eth_dev *cp = &bp->cnic_eth_dev;
+
+       mutex_lock(&bp->cnic_lock);
+       cp->drv_state = 0;
+       bnapi->cnic_present = 0;
+       rcu_assign_pointer(bp->cnic_ops, NULL);
+       mutex_unlock(&bp->cnic_lock);
+       synchronize_rcu();
+       return 0;
+}
+
+struct cnic_eth_dev *bnx2_cnic_probe(struct net_device *dev)
+{
+       struct bnx2 *bp = netdev_priv(dev);
+       struct cnic_eth_dev *cp = &bp->cnic_eth_dev;
+
+       cp->drv_owner = THIS_MODULE;
+       cp->chip_id = bp->chip_id;
+       cp->pdev = bp->pdev;
+       cp->io_base = bp->regview;
+       cp->drv_ctl = bnx2_drv_ctl;
+       cp->drv_register_cnic = bnx2_register_cnic;
+       cp->drv_unregister_cnic = bnx2_unregister_cnic;
+
+       return cp;
+}
+EXPORT_SYMBOL(bnx2_cnic_probe);
+
+static void
+bnx2_cnic_stop(struct bnx2 *bp)
+{
+       struct cnic_ops *c_ops;
+       struct cnic_ctl_info info;
+
+       mutex_lock(&bp->cnic_lock);
+       c_ops = bp->cnic_ops;
+       if (c_ops) {
+               info.cmd = CNIC_CTL_STOP_CMD;
+               c_ops->cnic_ctl(bp->cnic_data, &info);
+       }
+       mutex_unlock(&bp->cnic_lock);
+}
+
+static void
+bnx2_cnic_start(struct bnx2 *bp)
+{
+       struct cnic_ops *c_ops;
+       struct cnic_ctl_info info;
+
+       mutex_lock(&bp->cnic_lock);
+       c_ops = bp->cnic_ops;
+       if (c_ops) {
+               if (!(bp->flags & BNX2_FLAG_USING_MSIX)) {
+                       struct bnx2_napi *bnapi = &bp->bnx2_napi[0];
+
+                       bnapi->cnic_tag = bnapi->last_status_idx;
+               }
+               info.cmd = CNIC_CTL_START_CMD;
+               c_ops->cnic_ctl(bp->cnic_data, &info);
+       }
+       mutex_unlock(&bp->cnic_lock);
+}
+
+#else
+
+static void
+bnx2_cnic_stop(struct bnx2 *bp)
+{
+}
+
+static void
+bnx2_cnic_start(struct bnx2 *bp)
+{
+}
+
+#endif
+
 static int
 bnx2_read_phy(struct bnx2 *bp, u32 reg, u32 *val)
 {
@@ -457,6 +623,9 @@ bnx2_disable_int_sync(struct bnx2 *bp)
        int i;
 
        atomic_inc(&bp->intr_sem);
+       if (!netif_running(bp->dev))
+               return;
+
        bnx2_disable_int(bp);
        for (i = 0; i < bp->irq_nvecs; i++)
                synchronize_irq(bp->irq_tbl[i].vector);
@@ -483,6 +652,7 @@ bnx2_napi_enable(struct bnx2 *bp)
 static void
 bnx2_netif_stop(struct bnx2 *bp)
 {
+       bnx2_cnic_stop(bp);
        bnx2_disable_int_sync(bp);
        if (netif_running(bp->dev)) {
                bnx2_napi_disable(bp);
@@ -499,6 +669,7 @@ bnx2_netif_start(struct bnx2 *bp)
                        netif_tx_wake_all_queues(bp->dev);
                        bnx2_napi_enable(bp);
                        bnx2_enable_int(bp);
+                       bnx2_cnic_start(bp);
                }
        }
 }
@@ -540,8 +711,7 @@ bnx2_free_rx_mem(struct bnx2 *bp)
                                                    rxr->rx_desc_mapping[j]);
                        rxr->rx_desc_ring[j] = NULL;
                }
-               if (rxr->rx_buf_ring)
-                       vfree(rxr->rx_buf_ring);
+               vfree(rxr->rx_buf_ring);
                rxr->rx_buf_ring = NULL;
 
                for (j = 0; j < bp->rx_max_pg_ring; j++) {
@@ -551,8 +721,7 @@ bnx2_free_rx_mem(struct bnx2 *bp)
                                                    rxr->rx_pg_desc_mapping[j]);
                        rxr->rx_pg_desc_ring[j] = NULL;
                }
-               if (rxr->rx_pg_ring)
-                       vfree(rxr->rx_pg_ring);
+               vfree(rxr->rx_pg_ring);
                rxr->rx_pg_ring = NULL;
        }
 }
@@ -1497,6 +1666,8 @@ static int bnx2_fw_sync(struct bnx2 *, u32, int, int);
 
 static int
 bnx2_setup_remote_phy(struct bnx2 *bp, u8 port)
+__releases(&bp->phy_lock)
+__acquires(&bp->phy_lock)
 {
        u32 speed_arg = 0, pause_adv;
 
@@ -1554,6 +1725,8 @@ bnx2_setup_remote_phy(struct bnx2 *bp, u8 port)
 
 static int
 bnx2_setup_serdes_phy(struct bnx2 *bp, u8 port)
+__releases(&bp->phy_lock)
+__acquires(&bp->phy_lock)
 {
        u32 adv, bmcr;
        u32 new_adv = 0;
@@ -1866,6 +2039,8 @@ bnx2_set_remote_link(struct bnx2 *bp)
 
 static int
 bnx2_setup_copper_phy(struct bnx2 *bp)
+__releases(&bp->phy_lock)
+__acquires(&bp->phy_lock)
 {
        u32 bmcr;
        u32 new_bmcr;
@@ -1963,6 +2138,8 @@ bnx2_setup_copper_phy(struct bnx2 *bp)
 
 static int
 bnx2_setup_phy(struct bnx2 *bp, u8 port)
+__releases(&bp->phy_lock)
+__acquires(&bp->phy_lock)
 {
        if (bp->loopback == MAC_LOOPBACK)
                return 0;
@@ -2176,6 +2353,8 @@ bnx2_init_copper_phy(struct bnx2 *bp, int reset_phy)
 
 static int
 bnx2_init_phy(struct bnx2 *bp, int reset_phy)
+__releases(&bp->phy_lock)
+__acquires(&bp->phy_lock)
 {
        u32 val;
        int rc = 0;
@@ -2585,6 +2764,7 @@ bnx2_get_hw_tx_cons(struct bnx2_napi *bnapi)
        /* Tell compiler that status block fields can change. */
        barrier();
        cons = *bnapi->hw_tx_cons_ptr;
+       barrier();
        if (unlikely((cons & MAX_TX_DESC_CNT) == MAX_TX_DESC_CNT))
                cons++;
        return cons;
@@ -2614,14 +2794,15 @@ bnx2_tx_int(struct bnx2 *bp, struct bnx2_napi *bnapi, int budget)
                tx_buf = &txr->tx_buf_ring[sw_ring_cons];
                skb = tx_buf->skb;
 
+               /* prefetch skb_end_pointer() to speedup skb_shinfo(skb) */
+               prefetch(&skb->end);
+
                /* partial BD completions possible with TSO packets */
-               if (skb_is_gso(skb)) {
+               if (tx_buf->is_gso) {
                        u16 last_idx, last_ring_idx;
 
-                       last_idx = sw_cons +
-                               skb_shinfo(skb)->nr_frags + 1;
-                       last_ring_idx = sw_ring_cons +
-                               skb_shinfo(skb)->nr_frags + 1;
+                       last_idx = sw_cons + tx_buf->nr_frags + 1;
+                       last_ring_idx = sw_ring_cons + tx_buf->nr_frags + 1;
                        if (unlikely(last_ring_idx >= MAX_TX_DESC_CNT)) {
                                last_idx++;
                        }
@@ -2633,7 +2814,7 @@ bnx2_tx_int(struct bnx2 *bp, struct bnx2_napi *bnapi, int budget)
                skb_dma_unmap(&bp->pdev->dev, skb, DMA_TO_DEVICE);
 
                tx_buf->skb = NULL;
-               last = skb_shinfo(skb)->nr_frags;
+               last = tx_buf->nr_frags;
 
                for (i = 0; i < last; i++) {
                        sw_cons = NEXT_TX_BD(sw_cons);
@@ -2646,7 +2827,8 @@ bnx2_tx_int(struct bnx2 *bp, struct bnx2_napi *bnapi, int budget)
                if (tx_pkt == budget)
                        break;
 
-               hw_cons = bnx2_get_hw_tx_cons(bnapi);
+               if (hw_cons == sw_cons)
+                       hw_cons = bnx2_get_hw_tx_cons(bnapi);
        }
 
        txr->hw_tx_cons = hw_cons;
@@ -2864,6 +3046,7 @@ bnx2_get_hw_rx_cons(struct bnx2_napi *bnapi)
        /* Tell compiler that status block fields can change. */
        barrier();
        cons = *bnapi->hw_rx_cons_ptr;
+       barrier();
        if (unlikely((cons & MAX_RX_DESC_CNT) == MAX_RX_DESC_CNT))
                cons++;
        return cons;
@@ -2910,18 +3093,8 @@ bnx2_rx_int(struct bnx2 *bp, struct bnx2_napi *bnapi, int budget)
 
                rx_hdr = (struct l2_fhdr *) skb->data;
                len = rx_hdr->l2_fhdr_pkt_len;
+               status = rx_hdr->l2_fhdr_status;
 
-               if ((status = rx_hdr->l2_fhdr_status) &
-                       (L2_FHDR_ERRORS_BAD_CRC |
-                       L2_FHDR_ERRORS_PHY_DECODE |
-                       L2_FHDR_ERRORS_ALIGNMENT |
-                       L2_FHDR_ERRORS_TOO_SHORT |
-                       L2_FHDR_ERRORS_GIANT_FRAME)) {
-
-                       bnx2_reuse_rx_skb(bp, rxr, skb, sw_ring_cons,
-                                         sw_ring_prod);
-                       goto next_rx;
-               }
                hdr_len = 0;
                if (status & L2_FHDR_STATUS_SPLIT) {
                        hdr_len = rx_hdr->l2_fhdr_ip_xsum;
@@ -2931,6 +3104,24 @@ bnx2_rx_int(struct bnx2 *bp, struct bnx2_napi *bnapi, int budget)
                        pg_ring_used = 1;
                }
 
+               if (unlikely(status & (L2_FHDR_ERRORS_BAD_CRC |
+                                      L2_FHDR_ERRORS_PHY_DECODE |
+                                      L2_FHDR_ERRORS_ALIGNMENT |
+                                      L2_FHDR_ERRORS_TOO_SHORT |
+                                      L2_FHDR_ERRORS_GIANT_FRAME))) {
+
+                       bnx2_reuse_rx_skb(bp, rxr, skb, sw_ring_cons,
+                                         sw_ring_prod);
+                       if (pg_ring_used) {
+                               int pages;
+
+                               pages = PAGE_ALIGN(len - hdr_len) >> PAGE_SHIFT;
+
+                               bnx2_reuse_rx_skb_pages(bp, rxr, NULL, pages);
+                       }
+                       goto next_rx;
+               }
+
                len -= 4;
 
                if (len <= bp->rx_copy_thresh) {
@@ -2997,6 +3188,8 @@ bnx2_rx_int(struct bnx2 *bp, struct bnx2_napi *bnapi, int budget)
                                skb->ip_summed = CHECKSUM_UNNECESSARY;
                }
 
+               skb_record_rx_queue(skb, bnapi - &bp->bnx2_napi[0]);
+
 #ifdef BCM_VLAN
                if (hw_vlan)
                        vlan_hwaccel_receive_skb(skb, bp->vlgrp, vtag);
@@ -3137,6 +3330,11 @@ bnx2_has_work(struct bnx2_napi *bnapi)
        if (bnx2_has_fast_work(bnapi))
                return 1;
 
+#ifdef BCM_CNIC
+       if (bnapi->cnic_present && (bnapi->cnic_tag != sblk->status_idx))
+               return 1;
+#endif
+
        if ((sblk->status_attn_bits & STATUS_ATTN_EVENTS) !=
            (sblk->status_attn_bits_ack & STATUS_ATTN_EVENTS))
                return 1;
@@ -3166,6 +3364,23 @@ bnx2_chk_missed_msi(struct bnx2 *bp)
        bp->idle_chk_status_idx = bnapi->last_status_idx;
 }
 
+#ifdef BCM_CNIC
+static void bnx2_poll_cnic(struct bnx2 *bp, struct bnx2_napi *bnapi)
+{
+       struct cnic_ops *c_ops;
+
+       if (!bnapi->cnic_present)
+               return;
+
+       rcu_read_lock();
+       c_ops = rcu_dereference(bp->cnic_ops);
+       if (c_ops)
+               bnapi->cnic_tag = c_ops->cnic_handler(bp->cnic_data,
+                                                     bnapi->status_blk.msi);
+       rcu_read_unlock();
+}
+#endif
+
 static void bnx2_poll_link(struct bnx2 *bp, struct bnx2_napi *bnapi)
 {
        struct status_block *sblk = bnapi->status_blk.msi;
@@ -3240,6 +3455,10 @@ static int bnx2_poll(struct napi_struct *napi, int budget)
 
                work_done = bnx2_poll_work(bp, bnapi, work_done, budget);
 
+#ifdef BCM_CNIC
+               bnx2_poll_cnic(bp, bnapi);
+#endif
+
                /* bnapi->last_status_idx is used below to tell the hw how
                 * much work has been processed, so we must read it before
                 * checking for more work.
@@ -3281,7 +3500,7 @@ bnx2_set_rx_mode(struct net_device *dev)
 {
        struct bnx2 *bp = netdev_priv(dev);
        u32 rx_mode, sort_mode;
-       struct dev_addr_list *uc_ptr;
+       struct netdev_hw_addr *ha;
        int i;
 
        if (!netif_running(dev))
@@ -3340,21 +3559,19 @@ bnx2_set_rx_mode(struct net_device *dev)
                sort_mode |= BNX2_RPM_SORT_USER0_MC_HSH_EN;
        }
 
-       uc_ptr = NULL;
-       if (dev->uc_count > BNX2_MAX_UNICAST_ADDRESSES) {
+       if (dev->uc.count > BNX2_MAX_UNICAST_ADDRESSES) {
                rx_mode |= BNX2_EMAC_RX_MODE_PROMISCUOUS;
                sort_mode |= BNX2_RPM_SORT_USER0_PROM_EN |
                             BNX2_RPM_SORT_USER0_PROM_VLAN;
        } else if (!(dev->flags & IFF_PROMISC)) {
-               uc_ptr = dev->uc_list;
-
                /* Add all entries into to the match filter list */
-               for (i = 0; i < dev->uc_count; i++) {
-                       bnx2_set_mac_addr(bp, uc_ptr->da_addr,
+               i = 0;
+               list_for_each_entry(ha, &dev->uc.list, list) {
+                       bnx2_set_mac_addr(bp, ha->addr,
                                          i + BNX2_START_UNICAST_ADDRESS_INDEX);
                        sort_mode |= (1 <<
                                      (i + BNX2_START_UNICAST_ADDRESS_INDEX));
-                       uc_ptr = uc_ptr->next;
+                       i++;
                }
 
        }
@@ -3371,33 +3588,147 @@ bnx2_set_rx_mode(struct net_device *dev)
        spin_unlock_bh(&bp->phy_lock);
 }
 
-static void
-load_rv2p_fw(struct bnx2 *bp, __le32 *rv2p_code, u32 rv2p_code_len,
-       u32 rv2p_proc)
+static int __devinit
+check_fw_section(const struct firmware *fw,
+                const struct bnx2_fw_file_section *section,
+                u32 alignment, bool non_empty)
+{
+       u32 offset = be32_to_cpu(section->offset);
+       u32 len = be32_to_cpu(section->len);
+
+       if ((offset == 0 && len != 0) || offset >= fw->size || offset & 3)
+               return -EINVAL;
+       if ((non_empty && len == 0) || len > fw->size - offset ||
+           len & (alignment - 1))
+               return -EINVAL;
+       return 0;
+}
+
+static int __devinit
+check_mips_fw_entry(const struct firmware *fw,
+                   const struct bnx2_mips_fw_file_entry *entry)
 {
+       if (check_fw_section(fw, &entry->text, 4, true) ||
+           check_fw_section(fw, &entry->data, 4, false) ||
+           check_fw_section(fw, &entry->rodata, 4, false))
+               return -EINVAL;
+       return 0;
+}
+
+static int __devinit
+bnx2_request_firmware(struct bnx2 *bp)
+{
+       const char *mips_fw_file, *rv2p_fw_file;
+       const struct bnx2_mips_fw_file *mips_fw;
+       const struct bnx2_rv2p_fw_file *rv2p_fw;
+       int rc;
+
+       if (CHIP_NUM(bp) == CHIP_NUM_5709) {
+               mips_fw_file = FW_MIPS_FILE_09;
+               if ((CHIP_ID(bp) == CHIP_ID_5709_A0) ||
+                   (CHIP_ID(bp) == CHIP_ID_5709_A1))
+                       rv2p_fw_file = FW_RV2P_FILE_09_Ax;
+               else
+                       rv2p_fw_file = FW_RV2P_FILE_09;
+       } else {
+               mips_fw_file = FW_MIPS_FILE_06;
+               rv2p_fw_file = FW_RV2P_FILE_06;
+       }
+
+       rc = request_firmware(&bp->mips_firmware, mips_fw_file, &bp->pdev->dev);
+       if (rc) {
+               printk(KERN_ERR PFX "Can't load firmware file \"%s\"\n",
+                      mips_fw_file);
+               return rc;
+       }
+
+       rc = request_firmware(&bp->rv2p_firmware, rv2p_fw_file, &bp->pdev->dev);
+       if (rc) {
+               printk(KERN_ERR PFX "Can't load firmware file \"%s\"\n",
+                      rv2p_fw_file);
+               return rc;
+       }
+       mips_fw = (const struct bnx2_mips_fw_file *) bp->mips_firmware->data;
+       rv2p_fw = (const struct bnx2_rv2p_fw_file *) bp->rv2p_firmware->data;
+       if (bp->mips_firmware->size < sizeof(*mips_fw) ||
+           check_mips_fw_entry(bp->mips_firmware, &mips_fw->com) ||
+           check_mips_fw_entry(bp->mips_firmware, &mips_fw->cp) ||
+           check_mips_fw_entry(bp->mips_firmware, &mips_fw->rxp) ||
+           check_mips_fw_entry(bp->mips_firmware, &mips_fw->tpat) ||
+           check_mips_fw_entry(bp->mips_firmware, &mips_fw->txp)) {
+               printk(KERN_ERR PFX "Firmware file \"%s\" is invalid\n",
+                      mips_fw_file);
+               return -EINVAL;
+       }
+       if (bp->rv2p_firmware->size < sizeof(*rv2p_fw) ||
+           check_fw_section(bp->rv2p_firmware, &rv2p_fw->proc1.rv2p, 8, true) ||
+           check_fw_section(bp->rv2p_firmware, &rv2p_fw->proc2.rv2p, 8, true)) {
+               printk(KERN_ERR PFX "Firmware file \"%s\" is invalid\n",
+                      rv2p_fw_file);
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
+static u32
+rv2p_fw_fixup(u32 rv2p_proc, int idx, u32 loc, u32 rv2p_code)
+{
+       switch (idx) {
+       case RV2P_P1_FIXUP_PAGE_SIZE_IDX:
+               rv2p_code &= ~RV2P_BD_PAGE_SIZE_MSK;
+               rv2p_code |= RV2P_BD_PAGE_SIZE;
+               break;
+       }
+       return rv2p_code;
+}
+
+static int
+load_rv2p_fw(struct bnx2 *bp, u32 rv2p_proc,
+            const struct bnx2_rv2p_fw_file_entry *fw_entry)
+{
+       u32 rv2p_code_len, file_offset;
+       __be32 *rv2p_code;
        int i;
-       u32 val;
+       u32 val, cmd, addr;
+
+       rv2p_code_len = be32_to_cpu(fw_entry->rv2p.len);
+       file_offset = be32_to_cpu(fw_entry->rv2p.offset);
 
-       if (rv2p_proc == RV2P_PROC2 && CHIP_NUM(bp) == CHIP_NUM_5709) {
-               val = le32_to_cpu(rv2p_code[XI_RV2P_PROC2_MAX_BD_PAGE_LOC]);
-               val &= ~XI_RV2P_PROC2_BD_PAGE_SIZE_MSK;
-               val |= XI_RV2P_PROC2_BD_PAGE_SIZE;
-               rv2p_code[XI_RV2P_PROC2_MAX_BD_PAGE_LOC] = cpu_to_le32(val);
+       rv2p_code = (__be32 *)(bp->rv2p_firmware->data + file_offset);
+
+       if (rv2p_proc == RV2P_PROC1) {
+               cmd = BNX2_RV2P_PROC1_ADDR_CMD_RDWR;
+               addr = BNX2_RV2P_PROC1_ADDR_CMD;
+       } else {
+               cmd = BNX2_RV2P_PROC2_ADDR_CMD_RDWR;
+               addr = BNX2_RV2P_PROC2_ADDR_CMD;
        }
 
        for (i = 0; i < rv2p_code_len; i += 8) {
-               REG_WR(bp, BNX2_RV2P_INSTR_HIGH, le32_to_cpu(*rv2p_code));
+               REG_WR(bp, BNX2_RV2P_INSTR_HIGH, be32_to_cpu(*rv2p_code));
                rv2p_code++;
-               REG_WR(bp, BNX2_RV2P_INSTR_LOW, le32_to_cpu(*rv2p_code));
+               REG_WR(bp, BNX2_RV2P_INSTR_LOW, be32_to_cpu(*rv2p_code));
                rv2p_code++;
 
-               if (rv2p_proc == RV2P_PROC1) {
-                       val = (i / 8) | BNX2_RV2P_PROC1_ADDR_CMD_RDWR;
-                       REG_WR(bp, BNX2_RV2P_PROC1_ADDR_CMD, val);
-               }
-               else {
-                       val = (i / 8) | BNX2_RV2P_PROC2_ADDR_CMD_RDWR;
-                       REG_WR(bp, BNX2_RV2P_PROC2_ADDR_CMD, val);
+               val = (i / 8) | cmd;
+               REG_WR(bp, addr, val);
+       }
+
+       rv2p_code = (__be32 *)(bp->rv2p_firmware->data + file_offset);
+       for (i = 0; i < 8; i++) {
+               u32 loc, code;
+
+               loc = be32_to_cpu(fw_entry->fixup[i]);
+               if (loc && ((loc * 4) < rv2p_code_len)) {
+                       code = be32_to_cpu(*(rv2p_code + loc - 1));
+                       REG_WR(bp, BNX2_RV2P_INSTR_HIGH, code);
+                       code = be32_to_cpu(*(rv2p_code + loc));
+                       code = rv2p_fw_fixup(rv2p_proc, i, loc, code);
+                       REG_WR(bp, BNX2_RV2P_INSTR_LOW, code);
+
+                       val = (loc / 2) | cmd;
+                       REG_WR(bp, addr, val);
                }
        }
 
@@ -3408,14 +3739,18 @@ load_rv2p_fw(struct bnx2 *bp, __le32 *rv2p_code, u32 rv2p_code_len,
        else {
                REG_WR(bp, BNX2_RV2P_COMMAND, BNX2_RV2P_COMMAND_PROC2_RESET);
        }
+
+       return 0;
 }
 
 static int
-load_cpu_fw(struct bnx2 *bp, const struct cpu_reg *cpu_reg, struct fw_info *fw)
+load_cpu_fw(struct bnx2 *bp, const struct cpu_reg *cpu_reg,
+           const struct bnx2_mips_fw_file_entry *fw_entry)
 {
+       u32 addr, len, file_offset;
+       __be32 *data;
        u32 offset;
        u32 val;
-       int rc;
 
        /* Halt the CPU. */
        val = bnx2_reg_rd_ind(bp, cpu_reg->mode);
@@ -3424,64 +3759,52 @@ load_cpu_fw(struct bnx2 *bp, const struct cpu_reg *cpu_reg, struct fw_info *fw)
        bnx2_reg_wr_ind(bp, cpu_reg->state, cpu_reg->state_value_clear);
 
        /* Load the Text area. */
-       offset = cpu_reg->spad_base + (fw->text_addr - cpu_reg->mips_view_base);
-       if (fw->gz_text) {
-               int j;
-
-               rc = zlib_inflate_blob(fw->text, FW_BUF_SIZE, fw->gz_text,
-                                      fw->gz_text_len);
-               if (rc < 0)
-                       return rc;
+       addr = be32_to_cpu(fw_entry->text.addr);
+       len = be32_to_cpu(fw_entry->text.len);
+       file_offset = be32_to_cpu(fw_entry->text.offset);
+       data = (__be32 *)(bp->mips_firmware->data + file_offset);
 
-               for (j = 0; j < (fw->text_len / 4); j++, offset += 4) {
-                       bnx2_reg_wr_ind(bp, offset, le32_to_cpu(fw->text[j]));
-               }
-       }
-
-       /* Load the Data area. */
-       offset = cpu_reg->spad_base + (fw->data_addr - cpu_reg->mips_view_base);
-       if (fw->data) {
+       offset = cpu_reg->spad_base + (addr - cpu_reg->mips_view_base);
+       if (len) {
                int j;
 
-               for (j = 0; j < (fw->data_len / 4); j++, offset += 4) {
-                       bnx2_reg_wr_ind(bp, offset, fw->data[j]);
-               }
+               for (j = 0; j < (len / 4); j++, offset += 4)
+                       bnx2_reg_wr_ind(bp, offset, be32_to_cpu(data[j]));
        }
 
-       /* Load the SBSS area. */
-       offset = cpu_reg->spad_base + (fw->sbss_addr - cpu_reg->mips_view_base);
-       if (fw->sbss_len) {
-               int j;
-
-               for (j = 0; j < (fw->sbss_len / 4); j++, offset += 4) {
-                       bnx2_reg_wr_ind(bp, offset, 0);
-               }
-       }
+       /* Load the Data area. */
+       addr = be32_to_cpu(fw_entry->data.addr);
+       len = be32_to_cpu(fw_entry->data.len);
+       file_offset = be32_to_cpu(fw_entry->data.offset);
+       data = (__be32 *)(bp->mips_firmware->data + file_offset);
 
-       /* Load the BSS area. */
-       offset = cpu_reg->spad_base + (fw->bss_addr - cpu_reg->mips_view_base);
-       if (fw->bss_len) {
+       offset = cpu_reg->spad_base + (addr - cpu_reg->mips_view_base);
+       if (len) {
                int j;
 
-               for (j = 0; j < (fw->bss_len/4); j++, offset += 4) {
-                       bnx2_reg_wr_ind(bp, offset, 0);
-               }
+               for (j = 0; j < (len / 4); j++, offset += 4)
+                       bnx2_reg_wr_ind(bp, offset, be32_to_cpu(data[j]));
        }
 
        /* Load the Read-Only area. */
-       offset = cpu_reg->spad_base +
-               (fw->rodata_addr - cpu_reg->mips_view_base);
-       if (fw->rodata) {
+       addr = be32_to_cpu(fw_entry->rodata.addr);
+       len = be32_to_cpu(fw_entry->rodata.len);
+       file_offset = be32_to_cpu(fw_entry->rodata.offset);
+       data = (__be32 *)(bp->mips_firmware->data + file_offset);
+
+       offset = cpu_reg->spad_base + (addr - cpu_reg->mips_view_base);
+       if (len) {
                int j;
 
-               for (j = 0; j < (fw->rodata_len / 4); j++, offset += 4) {
-                       bnx2_reg_wr_ind(bp, offset, fw->rodata[j]);
-               }
+               for (j = 0; j < (len / 4); j++, offset += 4)
+                       bnx2_reg_wr_ind(bp, offset, be32_to_cpu(data[j]));
        }
 
        /* Clear the pre-fetch instruction. */
        bnx2_reg_wr_ind(bp, cpu_reg->inst, 0);
-       bnx2_reg_wr_ind(bp, cpu_reg->pc, fw->start_addr);
+
+       val = be32_to_cpu(fw_entry->start_addr);
+       bnx2_reg_wr_ind(bp, cpu_reg->pc, val);
 
        /* Start the CPU. */
        val = bnx2_reg_rd_ind(bp, cpu_reg->mode);
@@ -3495,95 +3818,40 @@ load_cpu_fw(struct bnx2 *bp, const struct cpu_reg *cpu_reg, struct fw_info *fw)
 static int
 bnx2_init_cpus(struct bnx2 *bp)
 {
-       struct fw_info *fw;
-       int rc, rv2p_len;
-       void *text, *rv2p;
+       const struct bnx2_mips_fw_file *mips_fw =
+               (const struct bnx2_mips_fw_file *) bp->mips_firmware->data;
+       const struct bnx2_rv2p_fw_file *rv2p_fw =
+               (const struct bnx2_rv2p_fw_file *) bp->rv2p_firmware->data;
+       int rc;
 
        /* Initialize the RV2P processor. */
-       text = vmalloc(FW_BUF_SIZE);
-       if (!text)
-               return -ENOMEM;
-       if (CHIP_NUM(bp) == CHIP_NUM_5709) {
-               rv2p = bnx2_xi_rv2p_proc1;
-               rv2p_len = sizeof(bnx2_xi_rv2p_proc1);
-       } else {
-               rv2p = bnx2_rv2p_proc1;
-               rv2p_len = sizeof(bnx2_rv2p_proc1);
-       }
-       rc = zlib_inflate_blob(text, FW_BUF_SIZE, rv2p, rv2p_len);
-       if (rc < 0)
-               goto init_cpu_err;
-
-       load_rv2p_fw(bp, text, rc /* == len */, RV2P_PROC1);
-
-       if (CHIP_NUM(bp) == CHIP_NUM_5709) {
-               rv2p = bnx2_xi_rv2p_proc2;
-               rv2p_len = sizeof(bnx2_xi_rv2p_proc2);
-       } else {
-               rv2p = bnx2_rv2p_proc2;
-               rv2p_len = sizeof(bnx2_rv2p_proc2);
-       }
-       rc = zlib_inflate_blob(text, FW_BUF_SIZE, rv2p, rv2p_len);
-       if (rc < 0)
-               goto init_cpu_err;
-
-       load_rv2p_fw(bp, text, rc /* == len */, RV2P_PROC2);
+       load_rv2p_fw(bp, RV2P_PROC1, &rv2p_fw->proc1);
+       load_rv2p_fw(bp, RV2P_PROC2, &rv2p_fw->proc2);
 
        /* Initialize the RX Processor. */
-       if (CHIP_NUM(bp) == CHIP_NUM_5709)
-               fw = &bnx2_rxp_fw_09;
-       else
-               fw = &bnx2_rxp_fw_06;
-
-       fw->text = text;
-       rc = load_cpu_fw(bp, &cpu_reg_rxp, fw);
+       rc = load_cpu_fw(bp, &cpu_reg_rxp, &mips_fw->rxp);
        if (rc)
                goto init_cpu_err;
 
        /* Initialize the TX Processor. */
-       if (CHIP_NUM(bp) == CHIP_NUM_5709)
-               fw = &bnx2_txp_fw_09;
-       else
-               fw = &bnx2_txp_fw_06;
-
-       fw->text = text;
-       rc = load_cpu_fw(bp, &cpu_reg_txp, fw);
+       rc = load_cpu_fw(bp, &cpu_reg_txp, &mips_fw->txp);
        if (rc)
                goto init_cpu_err;
 
        /* Initialize the TX Patch-up Processor. */
-       if (CHIP_NUM(bp) == CHIP_NUM_5709)
-               fw = &bnx2_tpat_fw_09;
-       else
-               fw = &bnx2_tpat_fw_06;
-
-       fw->text = text;
-       rc = load_cpu_fw(bp, &cpu_reg_tpat, fw);
+       rc = load_cpu_fw(bp, &cpu_reg_tpat, &mips_fw->tpat);
        if (rc)
                goto init_cpu_err;
 
        /* Initialize the Completion Processor. */
-       if (CHIP_NUM(bp) == CHIP_NUM_5709)
-               fw = &bnx2_com_fw_09;
-       else
-               fw = &bnx2_com_fw_06;
-
-       fw->text = text;
-       rc = load_cpu_fw(bp, &cpu_reg_com, fw);
+       rc = load_cpu_fw(bp, &cpu_reg_com, &mips_fw->com);
        if (rc)
                goto init_cpu_err;
 
        /* Initialize the Command Processor. */
-       if (CHIP_NUM(bp) == CHIP_NUM_5709)
-               fw = &bnx2_cp_fw_09;
-       else
-               fw = &bnx2_cp_fw_06;
-
-       fw->text = text;
-       rc = load_cpu_fw(bp, &cpu_reg_cp, fw);
+       rc = load_cpu_fw(bp, &cpu_reg_cp, &mips_fw->cp);
 
 init_cpu_err:
-       vfree(text);
        return rc;
 }
 
@@ -3967,7 +4235,7 @@ bnx2_init_nvram(struct bnx2 *bp)
 {
        u32 val;
        int j, entry_count, rc = 0;
-       struct flash_spec *flash;
+       const struct flash_spec *flash;
 
        if (CHIP_NUM(bp) == CHIP_NUM_5709) {
                bp->flash_info = &flash_5709;
@@ -4558,8 +4826,11 @@ bnx2_init_chip(struct bnx2 *bp)
        val = REG_RD(bp, BNX2_MQ_CONFIG);
        val &= ~BNX2_MQ_CONFIG_KNL_BYP_BLK_SIZE;
        val |= BNX2_MQ_CONFIG_KNL_BYP_BLK_SIZE_256;
-       if (CHIP_ID(bp) == CHIP_ID_5709_A0 || CHIP_ID(bp) == CHIP_ID_5709_A1)
-               val |= BNX2_MQ_CONFIG_HALT_DIS;
+       if (CHIP_NUM(bp) == CHIP_NUM_5709) {
+               val |= BNX2_MQ_CONFIG_BIN_MQ_MODE;
+               if (CHIP_REV(bp) == CHIP_REV_Ax)
+                       val |= BNX2_MQ_CONFIG_HALT_DIS;
+       }
 
        REG_WR(bp, BNX2_MQ_CONFIG, val);
 
@@ -4598,6 +4869,7 @@ bnx2_init_chip(struct bnx2 *bp)
        bnx2_reg_wr_ind(bp, BNX2_RBUF_CONFIG2, BNX2_RBUF_CONFIG2_VAL(mtu));
        bnx2_reg_wr_ind(bp, BNX2_RBUF_CONFIG3, BNX2_RBUF_CONFIG3_VAL(mtu));
 
+       memset(bp->bnx2_napi[0].status_blk.msi, 0, bp->status_stats_size);
        for (i = 0; i < BNX2_MAX_MSIX_VEC; i++)
                bp->bnx2_napi[i].last_status_idx = 0;
 
@@ -4636,7 +4908,7 @@ bnx2_init_chip(struct bnx2 *bp)
        REG_WR(bp, BNX2_HC_CMD_TICKS,
               (bp->cmd_ticks_int << 16) | bp->cmd_ticks);
 
-       if (CHIP_NUM(bp) == CHIP_NUM_5708)
+       if (bp->flags & BNX2_FLAG_BROKEN_STATS)
                REG_WR(bp, BNX2_HC_STATS_TICKS, 0);
        else
                REG_WR(bp, BNX2_HC_STATS_TICKS, bp->stats_ticks);
@@ -4657,7 +4929,7 @@ bnx2_init_chip(struct bnx2 *bp)
        }
 
        if (bp->flags & BNX2_FLAG_ONE_SHOT_MSI)
-               val |= BNX2_HC_CONFIG_ONE_SHOT;
+               val |= BNX2_HC_CONFIG_ONE_SHOT | BNX2_HC_CONFIG_USE_INT_PARAM;
 
        REG_WR(bp, BNX2_HC_CONFIG, val);
 
@@ -5412,7 +5684,7 @@ bnx2_run_loopback(struct bnx2 *bp, int loopback_mode)
                dev_kfree_skb(skb);
                return -EIO;
        }
-       map = skb_shinfo(skb)->dma_maps[0];
+       map = skb_shinfo(skb)->dma_head;
 
        REG_WR(bp, BNX2_HC_COMMAND,
               bp->hc_cmd | BNX2_HC_COMMAND_COAL_NOW_WO_INT);
@@ -5761,7 +6033,7 @@ bnx2_timer(unsigned long data)
                bnx2_reg_rd_ind(bp, BNX2_FW_RX_DROP_COUNT);
 
        /* workaround occasional corrupted counters */
-       if (CHIP_NUM(bp) == CHIP_NUM_5708 && bp->stats_ticks)
+       if ((bp->flags & BNX2_FLAG_BROKEN_STATS) && bp->stats_ticks)
                REG_WR(bp, BNX2_HC_COMMAND, bp->hc_cmd |
                                            BNX2_HC_COMMAND_STATS_NOW);
 
@@ -5835,9 +6107,6 @@ bnx2_enable_msix(struct bnx2 *bp, int msix_vecs)
        for (i = 0; i < BNX2_MAX_MSIX_VEC; i++) {
                msix_ent[i].entry = i;
                msix_ent[i].vector = 0;
-
-               snprintf(bp->irq_tbl[i].name, len, "%s-%d", dev->name, i);
-               bp->irq_tbl[i].handler = bnx2_msi_1shot;
        }
 
        rc = pci_enable_msix(bp->pdev, msix_ent, BNX2_MAX_MSIX_VEC);
@@ -5846,8 +6115,11 @@ bnx2_enable_msix(struct bnx2 *bp, int msix_vecs)
 
        bp->irq_nvecs = msix_vecs;
        bp->flags |= BNX2_FLAG_USING_MSIX | BNX2_FLAG_ONE_SHOT_MSI;
-       for (i = 0; i < BNX2_MAX_MSIX_VEC; i++)
+       for (i = 0; i < BNX2_MAX_MSIX_VEC; i++) {
                bp->irq_tbl[i].vector = msix_ent[i].vector;
+               snprintf(bp->irq_tbl[i].name, len, "%s-%d", dev->name, i);
+               bp->irq_tbl[i].handler = bnx2_msi_1shot;
+       }
 }
 
 static void
@@ -5993,9 +6265,14 @@ bnx2_vlan_rx_register(struct net_device *dev, struct vlan_group *vlgrp)
 {
        struct bnx2 *bp = netdev_priv(dev);
 
-       bnx2_netif_stop(bp);
+       if (netif_running(dev))
+               bnx2_netif_stop(bp);
 
        bp->vlgrp = vlgrp;
+
+       if (!netif_running(dev))
+               return;
+
        bnx2_set_rx_mode(dev);
        if (bp->flags & BNX2_FLAG_CAN_KEEP_VLAN)
                bnx2_fw_sync(bp, BNX2_DRV_MSG_CODE_KEEP_VLAN_UPDATE, 0, 1);
@@ -6008,7 +6285,7 @@ bnx2_vlan_rx_register(struct net_device *dev, struct vlan_group *vlgrp)
  * bnx2_tx_int() runs without netif_tx_lock unless it needs to call
  * netif_wake_queue().
  */
-static int
+static netdev_tx_t
 bnx2_start_xmit(struct sk_buff *skb, struct net_device *dev)
 {
        struct bnx2 *bp = netdev_priv(dev);
@@ -6092,7 +6369,7 @@ bnx2_start_xmit(struct sk_buff *skb, struct net_device *dev)
        }
 
        sp = skb_shinfo(skb);
-       mapping = sp->dma_maps[0];
+       mapping = sp->dma_head;
 
        tx_buf = &txr->tx_buf_ring[ring_prod];
        tx_buf->skb = skb;
@@ -6105,6 +6382,8 @@ bnx2_start_xmit(struct sk_buff *skb, struct net_device *dev)
        txbd->tx_bd_vlan_tag_flags = vlan_tag_flags | TX_BD_FLAGS_START;
 
        last_frag = skb_shinfo(skb)->nr_frags;
+       tx_buf->nr_frags = last_frag;
+       tx_buf->is_gso = skb_is_gso(skb);
 
        for (i = 0; i < last_frag; i++) {
                skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
@@ -6114,7 +6393,7 @@ bnx2_start_xmit(struct sk_buff *skb, struct net_device *dev)
                txbd = &txr->tx_desc_ring[ring_prod];
 
                len = frag->size;
-               mapping = sp->dma_maps[i + 1];
+               mapping = sp->dma_maps[i];
 
                txbd->tx_bd_haddr_hi = (u64) mapping >> 32;
                txbd->tx_bd_haddr_lo = (u64) mapping & 0xffffffff;
@@ -6133,7 +6412,6 @@ bnx2_start_xmit(struct sk_buff *skb, struct net_device *dev)
        mmiowb();
 
        txr->tx_prod = prod;
-       dev->trans_start = jiffies;
 
        if (unlikely(bnx2_tx_avail(bp, txr) <= MAX_SKB_FRAGS)) {
                netif_tx_stop_queue(txq);
@@ -6215,7 +6493,8 @@ bnx2_get_stats(struct net_device *dev)
                stats_blk->stat_EtherStatsOverrsizePkts);
 
        net_stats->rx_over_errors =
-               (unsigned long) stats_blk->stat_IfInMBUFDiscards;
+               (unsigned long) (stats_blk->stat_IfInFTQDiscards +
+               stats_blk->stat_IfInMBUFDiscards);
 
        net_stats->rx_frame_errors =
                (unsigned long) stats_blk->stat_Dot3StatsAlignmentErrors;
@@ -6248,8 +6527,8 @@ bnx2_get_stats(struct net_device *dev)
                net_stats->tx_carrier_errors;
 
        net_stats->rx_missed_errors =
-               (unsigned long) (stats_blk->stat_IfInMBUFDiscards +
-               stats_blk->stat_FwRxDrop);
+               (unsigned long) (stats_blk->stat_IfInFTQDiscards +
+               stats_blk->stat_IfInMBUFDiscards + stats_blk->stat_FwRxDrop);
 
        return net_stats;
 }
@@ -6564,6 +6843,14 @@ bnx2_nway_reset(struct net_device *dev)
        return 0;
 }
 
+static u32
+bnx2_get_link(struct net_device *dev)
+{
+       struct bnx2 *bp = netdev_priv(dev);
+
+       return bp->link_up;
+}
+
 static int
 bnx2_get_eeprom_len(struct net_device *dev)
 {
@@ -6663,7 +6950,7 @@ bnx2_set_coalesce(struct net_device *dev, struct ethtool_coalesce *coal)
                0xff;
 
        bp->stats_ticks = coal->stats_block_coalesce_usecs;
-       if (CHIP_NUM(bp) == CHIP_NUM_5708) {
+       if (bp->flags & BNX2_FLAG_BROKEN_STATS) {
                if (bp->stats_ticks != 0 && bp->stats_ticks != USEC_PER_SEC)
                        bp->stats_ticks = USEC_PER_SEC;
        }
@@ -6714,9 +7001,14 @@ bnx2_change_ring_size(struct bnx2 *bp, u32 rx, u32 tx)
                int rc;
 
                rc = bnx2_alloc_mem(bp);
-               if (rc)
+               if (!rc)
+                       rc = bnx2_init_nic(bp, 0);
+
+               if (rc) {
+                       bnx2_napi_enable(bp);
+                       dev_close(bp->dev);
                        return rc;
-               bnx2_init_nic(bp, 0);
+               }
                bnx2_netif_start(bp);
        }
        return 0;
@@ -6807,11 +7099,9 @@ bnx2_set_tso(struct net_device *dev, u32 data)
        return 0;
 }
 
-#define BNX2_NUM_STATS 46
-
 static struct {
        char string[ETH_GSTRING_LEN];
-} bnx2_stats_str_arr[BNX2_NUM_STATS] = {
+} bnx2_stats_str_arr[] = {
        { "rx_bytes" },
        { "rx_error_bytes" },
        { "tx_bytes" },
@@ -6856,10 +7146,14 @@ static struct {
        { "tx_xoff_frames" },
        { "rx_mac_ctrl_frames" },
        { "rx_filtered_packets" },
+       { "rx_ftq_discards" },
        { "rx_discards" },
        { "rx_fw_discards" },
 };
 
+#define BNX2_NUM_STATS (sizeof(bnx2_stats_str_arr)/\
+                       sizeof(bnx2_stats_str_arr[0]))
+
 #define STATS_OFFSET32(offset_name) (offsetof(struct statistics_block, offset_name) / 4)
 
 static const unsigned long bnx2_stats_offset_arr[BNX2_NUM_STATS] = {
@@ -6907,6 +7201,7 @@ static const unsigned long bnx2_stats_offset_arr[BNX2_NUM_STATS] = {
     STATS_OFFSET32(stat_OutXoffSent),
     STATS_OFFSET32(stat_MacControlFramesReceived),
     STATS_OFFSET32(stat_IfInFramesL2FilterDiscards),
+    STATS_OFFSET32(stat_IfInFTQDiscards),
     STATS_OFFSET32(stat_IfInMBUFDiscards),
     STATS_OFFSET32(stat_FwRxDrop),
 };
@@ -6919,7 +7214,7 @@ static u8 bnx2_5706_stats_len_arr[BNX2_NUM_STATS] = {
        4,0,4,4,4,4,4,4,4,4,
        4,4,4,4,4,4,4,4,4,4,
        4,4,4,4,4,4,4,4,4,4,
-       4,4,4,4,4,4,
+       4,4,4,4,4,4,4,
 };
 
 static u8 bnx2_5708_stats_len_arr[BNX2_NUM_STATS] = {
@@ -6927,7 +7222,7 @@ static u8 bnx2_5708_stats_len_arr[BNX2_NUM_STATS] = {
        4,4,4,4,4,4,4,4,4,4,
        4,4,4,4,4,4,4,4,4,4,
        4,4,4,4,4,4,4,4,4,4,
-       4,4,4,4,4,4,
+       4,4,4,4,4,4,4,
 };
 
 #define BNX2_NUM_TESTS 6
@@ -7131,7 +7426,7 @@ static const struct ethtool_ops bnx2_ethtool_ops = {
        .get_wol                = bnx2_get_wol,
        .set_wol                = bnx2_set_wol,
        .nway_reset             = bnx2_nway_reset,
-       .get_link               = ethtool_op_get_link,
+       .get_link               = bnx2_get_link,
        .get_eeprom_len         = bnx2_get_eeprom_len,
        .get_eeprom             = bnx2_get_eeprom,
        .set_eeprom             = bnx2_set_eeprom,
@@ -7185,9 +7480,6 @@ bnx2_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
        }
 
        case SIOCSMIIREG:
-               if (!capable(CAP_NET_ADMIN))
-                       return -EPERM;
-
                if (bp->phy_flags & BNX2_PHY_FLAG_REMOTE_PHY_CAP)
                        return -EOPNOTSUPP;
 
@@ -7394,10 +7686,13 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
 
        spin_lock_init(&bp->phy_lock);
        spin_lock_init(&bp->indirect_lock);
+#ifdef BCM_CNIC
+       mutex_init(&bp->cnic_lock);
+#endif
        INIT_WORK(&bp->reset_task, bnx2_reset_task);
 
        dev->base_addr = dev->mem_start = pci_resource_start(pdev, 0);
-       mem_len = MB_GET_CID_ADDR(TX_TSS_CID + TX_MAX_TSS_RINGS);
+       mem_len = MB_GET_CID_ADDR(TX_TSS_CID + TX_MAX_TSS_RINGS + 1);
        dev->mem_end = dev->mem_start + mem_len;
        dev->irq = pdev->irq;
 
@@ -7439,6 +7734,7 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
                        rc = -EIO;
                        goto err_out_unmap;
                }
+               bp->flags |= BNX2_FLAG_BROKEN_STATS;
        }
 
        if (CHIP_NUM(bp) == CHIP_NUM_5709 && CHIP_REV(bp) != CHIP_REV_Ax) {
@@ -7453,9 +7749,9 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
 
        /* 5708 cannot support DMA addresses > 40-bit.  */
        if (CHIP_NUM(bp) == CHIP_NUM_5708)
-               persist_dma_mask = dma_mask = DMA_40BIT_MASK;
+               persist_dma_mask = dma_mask = DMA_BIT_MASK(40);
        else
-               persist_dma_mask = dma_mask = DMA_64BIT_MASK;
+               persist_dma_mask = dma_mask = DMA_BIT_MASK(64);
 
        /* Configure DMA attributes. */
        if (pci_set_dma_mask(pdev, dma_mask) == 0) {
@@ -7466,7 +7762,7 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
                                "pci_set_consistent_dma_mask failed, aborting.\n");
                        goto err_out_unmap;
                }
-       } else if ((rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK)) != 0) {
+       } else if ((rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) != 0) {
                dev_err(&pdev->dev, "System does not support DMA, aborting.\n");
                goto err_out_unmap;
        }
@@ -7570,13 +7866,13 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
 
        bp->rx_csum = 1;
 
-       bp->tx_quick_cons_trip_int = 20;
+       bp->tx_quick_cons_trip_int = 2;
        bp->tx_quick_cons_trip = 20;
-       bp->tx_ticks_int = 80;
+       bp->tx_ticks_int = 18;
        bp->tx_ticks = 80;
 
-       bp->rx_quick_cons_trip_int = 6;
-       bp->rx_quick_cons_trip = 6;
+       bp->rx_quick_cons_trip_int = 2;
+       bp->rx_quick_cons_trip = 12;
        bp->rx_ticks_int = 18;
        bp->rx_ticks = 18;
 
@@ -7754,6 +8050,13 @@ static const struct net_device_ops bnx2_netdev_ops = {
 #endif
 };
 
+static void inline vlan_features_add(struct net_device *dev, unsigned long flags)
+{
+#ifdef BCM_VLAN
+       dev->vlan_features |= flags;
+#endif
+}
+
 static int __devinit
 bnx2_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
@@ -7787,29 +8090,31 @@ bnx2_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 
        pci_set_drvdata(pdev, dev);
 
+       rc = bnx2_request_firmware(bp);
+       if (rc)
+               goto error;
+
        memcpy(dev->dev_addr, bp->mac_addr, 6);
        memcpy(dev->perm_addr, bp->mac_addr, 6);
 
        dev->features |= NETIF_F_IP_CSUM | NETIF_F_SG;
-       if (CHIP_NUM(bp) == CHIP_NUM_5709)
+       vlan_features_add(dev, NETIF_F_IP_CSUM | NETIF_F_SG);
+       if (CHIP_NUM(bp) == CHIP_NUM_5709) {
                dev->features |= NETIF_F_IPV6_CSUM;
-
+               vlan_features_add(dev, NETIF_F_IPV6_CSUM);
+       }
 #ifdef BCM_VLAN
        dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
 #endif
        dev->features |= NETIF_F_TSO | NETIF_F_TSO_ECN;
-       if (CHIP_NUM(bp) == CHIP_NUM_5709)
+       vlan_features_add(dev, NETIF_F_TSO | NETIF_F_TSO_ECN);
+       if (CHIP_NUM(bp) == CHIP_NUM_5709) {
                dev->features |= NETIF_F_TSO6;
-
+               vlan_features_add(dev, NETIF_F_TSO6);
+       }
        if ((rc = register_netdev(dev))) {
                dev_err(&pdev->dev, "Cannot register net device\n");
-               if (bp->regview)
-                       iounmap(bp->regview);
-               pci_release_regions(pdev);
-               pci_disable_device(pdev);
-               pci_set_drvdata(pdev, NULL);
-               free_netdev(dev);
-               return rc;
+               goto error;
        }
 
        printk(KERN_INFO "%s: %s (%c%d) %s found at mem %lx, "
@@ -7823,6 +8128,20 @@ bnx2_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
                bp->pdev->irq, dev->dev_addr);
 
        return 0;
+
+error:
+       if (bp->mips_firmware)
+               release_firmware(bp->mips_firmware);
+       if (bp->rv2p_firmware)
+               release_firmware(bp->rv2p_firmware);
+
+       if (bp->regview)
+               iounmap(bp->regview);
+       pci_release_regions(pdev);
+       pci_disable_device(pdev);
+       pci_set_drvdata(pdev, NULL);
+       free_netdev(dev);
+       return rc;
 }
 
 static void __devexit
@@ -7835,6 +8154,11 @@ bnx2_remove_one(struct pci_dev *pdev)
 
        unregister_netdev(dev);
 
+       if (bp->mips_firmware)
+               release_firmware(bp->mips_firmware);
+       if (bp->rv2p_firmware)
+               release_firmware(bp->rv2p_firmware);
+
        if (bp->regview)
                iounmap(bp->regview);
 
@@ -7902,6 +8226,11 @@ static pci_ers_result_t bnx2_io_error_detected(struct pci_dev *pdev,
        rtnl_lock();
        netif_device_detach(dev);
 
+       if (state == pci_channel_io_perm_failure) {
+               rtnl_unlock();
+               return PCI_ERS_RESULT_DISCONNECT;
+       }
+
        if (netif_running(dev)) {
                bnx2_netif_stop(bp);
                del_timer_sync(&bp->timer);