vlan: Don't check for vlan group before vlan_tx_tag_present.
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / net / bnx2.c
index 4ff76e38e788b4e12b6b53c496d6968e5a7d973b..363ca8bcc974dd75ffcba3cce7b2aa7f08487ec4 100644 (file)
 #include "bnx2_fw.h"
 
 #define DRV_MODULE_NAME                "bnx2"
-#define DRV_MODULE_VERSION     "2.0.17"
-#define DRV_MODULE_RELDATE     "July 18, 2010"
-#define FW_MIPS_FILE_06                "bnx2/bnx2-mips-06-5.0.0.j6.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.j15.fw"
-#define FW_RV2P_FILE_09_Ax     "bnx2/bnx2-rv2p-09ax-5.0.0.j10.fw"
-#define FW_RV2P_FILE_09                "bnx2/bnx2-rv2p-09-5.0.0.j10.fw"
+#define DRV_MODULE_VERSION     "2.0.18"
+#define DRV_MODULE_RELDATE     "Oct 7, 2010"
+#define FW_MIPS_FILE_06                "bnx2/bnx2-mips-06-6.0.15.fw"
+#define FW_RV2P_FILE_06                "bnx2/bnx2-rv2p-06-6.0.15.fw"
+#define FW_MIPS_FILE_09                "bnx2/bnx2-mips-09-6.0.17.fw"
+#define FW_RV2P_FILE_09_Ax     "bnx2/bnx2-rv2p-09ax-6.0.17.fw"
+#define FW_RV2P_FILE_09                "bnx2/bnx2-rv2p-09-6.0.17.fw"
 
 #define RUN_AT(x) (jiffies + (x))
 
@@ -266,7 +266,7 @@ static inline u32 bnx2_tx_avail(struct bnx2 *bp, struct bnx2_tx_ring_info *txr)
                if (diff == TX_DESC_CNT)
                        diff = MAX_TX_DESC_CNT;
        }
-       return (bp->tx_ring_size - diff);
+       return bp->tx_ring_size - diff;
 }
 
 static u32
@@ -299,7 +299,7 @@ bnx2_shmem_wr(struct bnx2 *bp, u32 offset, u32 val)
 static u32
 bnx2_shmem_rd(struct bnx2 *bp, u32 offset)
 {
-       return (bnx2_reg_rd_ind(bp, bp->shmem_base + offset));
+       return bnx2_reg_rd_ind(bp, bp->shmem_base + offset);
 }
 
 static void
@@ -977,9 +977,9 @@ bnx2_report_fw_link(struct bnx2 *bp)
 static char *
 bnx2_xceiver_str(struct bnx2 *bp)
 {
-       return ((bp->phy_port == PORT_FIBRE) ? "SerDes" :
+       return (bp->phy_port == PORT_FIBRE) ? "SerDes" :
                ((bp->phy_flags & BNX2_PHY_FLAG_SERDES) ? "Remote Copper" :
-                "Copper"));
+                "Copper");
 }
 
 static void
@@ -1269,30 +1269,9 @@ bnx2_init_rx_context(struct bnx2 *bp, u32 cid)
        val |= BNX2_L2CTX_CTX_TYPE_SIZE_L2;
        val |= 0x02 << 8;
 
-       if (CHIP_NUM(bp) == CHIP_NUM_5709) {
-               u32 lo_water, hi_water;
-
-               if (bp->flow_ctrl & FLOW_CTRL_TX)
-                       lo_water = BNX2_L2CTX_LO_WATER_MARK_DEFAULT;
-               else
-                       lo_water = BNX2_L2CTX_LO_WATER_MARK_DIS;
-               if (lo_water >= bp->rx_ring_size)
-                       lo_water = 0;
-
-               hi_water = min_t(int, bp->rx_ring_size / 4, lo_water + 16);
-
-               if (hi_water <= lo_water)
-                       lo_water = 0;
-
-               hi_water /= BNX2_L2CTX_HI_WATER_MARK_SCALE;
-               lo_water /= BNX2_L2CTX_LO_WATER_MARK_SCALE;
+       if (bp->flow_ctrl & FLOW_CTRL_TX)
+               val |= BNX2_L2CTX_FLOW_CTRL_ENABLE;
 
-               if (hi_water > 0xf)
-                       hi_water = 0xf;
-               else if (hi_water == 0)
-                       lo_water = 0;
-               val |= lo_water | (hi_water << BNX2_L2CTX_HI_WATER_MARK_SHIFT);
-       }
        bnx2_ctx_wr(bp, rx_cid_addr, BNX2_L2CTX_CTX_TYPE, val);
 }
 
@@ -1373,8 +1352,7 @@ bnx2_set_mac_link(struct bnx2 *bp)
        /* Acknowledge the interrupt. */
        REG_WR(bp, BNX2_EMAC_STATUS, BNX2_EMAC_STATUS_LINK_CHANGE);
 
-       if (CHIP_NUM(bp) == CHIP_NUM_5709)
-               bnx2_init_all_rx_contexts(bp);
+       bnx2_init_all_rx_contexts(bp);
 }
 
 static void
@@ -1758,7 +1736,7 @@ __acquires(&bp->phy_lock)
        u32 new_adv = 0;
 
        if (bp->phy_flags & BNX2_PHY_FLAG_REMOTE_PHY_CAP)
-               return (bnx2_setup_remote_phy(bp, port));
+               return bnx2_setup_remote_phy(bp, port);
 
        if (!(bp->autoneg & AUTONEG_SPEED)) {
                u32 new_bmcr;
@@ -2171,10 +2149,10 @@ __acquires(&bp->phy_lock)
                return 0;
 
        if (bp->phy_flags & BNX2_PHY_FLAG_SERDES) {
-               return (bnx2_setup_serdes_phy(bp, port));
+               return bnx2_setup_serdes_phy(bp, port);
        }
        else {
-               return (bnx2_setup_copper_phy(bp));
+               return bnx2_setup_copper_phy(bp);
        }
 }
 
@@ -4974,6 +4952,11 @@ bnx2_init_chip(struct bnx2 *bp)
 
        REG_WR(bp, BNX2_HC_CONFIG, val);
 
+       if (bp->rx_ticks < 25)
+               bnx2_reg_wr_ind(bp, BNX2_FW_RX_LOW_LATENCY, 1);
+       else
+               bnx2_reg_wr_ind(bp, BNX2_FW_RX_LOW_LATENCY, 0);
+
        for (i = 1; i < bp->irq_nvecs; i++) {
                u32 base = ((i - 1) * BNX2_HC_SB_CONFIG_SIZE) +
                           BNX2_HC_SB_CONFIG_1;
@@ -5242,18 +5225,20 @@ bnx2_init_all_rings(struct bnx2 *bp)
                bnx2_init_rx_ring(bp, i);
 
        if (bp->num_rx_rings > 1) {
-               u32 tbl_32;
-               u8 *tbl = (u8 *) &tbl_32;
-
-               bnx2_reg_wr_ind(bp, BNX2_RXP_SCRATCH_RSS_TBL_SZ,
-                               BNX2_RXP_SCRATCH_RSS_TBL_MAX_ENTRIES);
+               u32 tbl_32 = 0;
 
                for (i = 0; i < BNX2_RXP_SCRATCH_RSS_TBL_MAX_ENTRIES; i++) {
-                       tbl[i % 4] = i % (bp->num_rx_rings - 1);
-                       if ((i % 4) == 3)
-                               bnx2_reg_wr_ind(bp,
-                                               BNX2_RXP_SCRATCH_RSS_TBL + i,
-                                               cpu_to_be32(tbl_32));
+                       int shift = (i % 8) << 2;
+
+                       tbl_32 |= (i % (bp->num_rx_rings - 1)) << shift;
+                       if ((i % 8) == 7) {
+                               REG_WR(bp, BNX2_RLUP_RSS_DATA, tbl_32);
+                               REG_WR(bp, BNX2_RLUP_RSS_COMMAND, (i >> 3) |
+                                       BNX2_RLUP_RSS_COMMAND_RSS_WRITE_MASK |
+                                       BNX2_RLUP_RSS_COMMAND_WRITE |
+                                       BNX2_RLUP_RSS_COMMAND_HASH_MASK);
+                               tbl_32 = 0;
+                       }
                }
 
                val = BNX2_RLUP_RSS_CONFIG_IPV4_RSS_TYPE_ALL_XI |
@@ -6202,7 +6187,7 @@ bnx2_enable_msix(struct bnx2 *bp, int msix_vecs)
        }
 }
 
-static void
+static int
 bnx2_setup_int_mode(struct bnx2 *bp, int dis_msi)
 {
        int cpus = num_online_cpus();
@@ -6231,9 +6216,10 @@ bnx2_setup_int_mode(struct bnx2 *bp, int dis_msi)
        }
 
        bp->num_tx_rings = rounddown_pow_of_two(bp->irq_nvecs);
-       bp->dev->real_num_tx_queues = bp->num_tx_rings;
+       netif_set_real_num_tx_queues(bp->dev, bp->num_tx_rings);
 
        bp->num_rx_rings = bp->irq_nvecs;
+       return netif_set_real_num_rx_queues(bp->dev, bp->num_rx_rings);
 }
 
 /* Called with rtnl_lock */
@@ -6248,7 +6234,9 @@ bnx2_open(struct net_device *dev)
        bnx2_set_power_state(bp, PCI_D0);
        bnx2_disable_int(bp);
 
-       bnx2_setup_int_mode(bp, disable_msi);
+       rc = bnx2_setup_int_mode(bp, disable_msi);
+       if (rc)
+               goto open_err;
        bnx2_init_napi(bp);
        bnx2_napi_enable(bp);
        rc = bnx2_alloc_mem(bp);
@@ -6441,7 +6429,7 @@ bnx2_start_xmit(struct sk_buff *skb, struct net_device *dev)
        }
 
 #ifdef BCM_VLAN
-       if (bp->vlgrp && vlan_tx_tag_present(skb)) {
+       if (vlan_tx_tag_present(skb)) {
                vlan_tag_flags |=
                        (TX_BD_FLAGS_VLAN_TAG | (vlan_tx_tag_get(skb) << 16));
        }
@@ -7582,9 +7570,9 @@ bnx2_set_tx_csum(struct net_device *dev, u32 data)
        struct bnx2 *bp = netdev_priv(dev);
 
        if (CHIP_NUM(bp) == CHIP_NUM_5709)
-               return (ethtool_op_set_tx_ipv6_csum(dev, data));
+               return ethtool_op_set_tx_ipv6_csum(dev, data);
        else
-               return (ethtool_op_set_tx_csum(dev, data));
+               return ethtool_op_set_tx_csum(dev, data);
 }
 
 static int
@@ -7705,7 +7693,7 @@ bnx2_change_mtu(struct net_device *dev, int new_mtu)
                return -EINVAL;
 
        dev->mtu = new_mtu;
-       return (bnx2_change_ring_size(bp, bp->rx_ring_size, bp->tx_ring_size));
+       return bnx2_change_ring_size(bp, bp->rx_ring_size, bp->tx_ring_size);
 }
 
 #ifdef CONFIG_NET_POLL_CONTROLLER
@@ -7927,16 +7915,7 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
                goto err_out_disable;
        }
 
-       /* AER (Advanced Error Reporting) hooks */
-       err = pci_enable_pcie_error_reporting(pdev);
-       if (err) {
-               dev_err(&pdev->dev, "pci_enable_pcie_error_reporting failed "
-                                   "0x%x\n", err);
-               /* non-fatal, continue */
-       }
-
        pci_set_master(pdev);
-       pci_save_state(pdev);
 
        bp->pm_cap = pci_find_capability(pdev, PCI_CAP_ID_PM);
        if (bp->pm_cap == 0) {
@@ -7991,6 +7970,15 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
                bp->flags |= BNX2_FLAG_PCIE;
                if (CHIP_REV(bp) == CHIP_REV_Ax)
                        bp->flags |= BNX2_FLAG_JUMBO_BROKEN;
+
+               /* AER (Advanced Error Reporting) hooks */
+               err = pci_enable_pcie_error_reporting(pdev);
+               if (err) {
+                       dev_err(&pdev->dev, "pci_enable_pcie_error_reporting "
+                                           "failed 0x%x\n", err);
+                       /* non-fatal, continue */
+               }
+
        } else {
                bp->pcix_cap = pci_find_capability(pdev, PCI_CAP_ID_PCIX);
                if (bp->pcix_cap == 0) {
@@ -8247,16 +8235,20 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
        bp->timer.data = (unsigned long) bp;
        bp->timer.function = bnx2_timer;
 
+       pci_save_state(pdev);
+
        return 0;
 
 err_out_unmap:
+       if (bp->flags & BNX2_FLAG_PCIE)
+               pci_disable_pcie_error_reporting(pdev);
+
        if (bp->regview) {
                iounmap(bp->regview);
                bp->regview = NULL;
        }
 
 err_out_release:
-       pci_disable_pcie_error_reporting(pdev);
        pci_release_regions(pdev);
 
 err_out_disable:
@@ -8446,9 +8438,10 @@ bnx2_remove_one(struct pci_dev *pdev)
 
        kfree(bp->temp_stats_blk);
 
-       free_netdev(dev);
+       if (bp->flags & BNX2_FLAG_PCIE)
+               pci_disable_pcie_error_reporting(pdev);
 
-       pci_disable_pcie_error_reporting(pdev);
+       free_netdev(dev);
 
        pci_release_regions(pdev);
        pci_disable_device(pdev);
@@ -8562,6 +8555,9 @@ static pci_ers_result_t bnx2_io_slot_reset(struct pci_dev *pdev)
        }
        rtnl_unlock();
 
+       if (!(bp->flags & BNX2_FLAG_PCIE))
+               return result;
+
        err = pci_cleanup_aer_uncorrect_error_status(pdev);
        if (err) {
                dev_err(&pdev->dev,