bnx2: Apply BROKEN_STATS workaround to 5706 and 5708.
[pandora-kernel.git] / drivers / net / bnx2.c
index 38f1c33..085c2dd 100644 (file)
@@ -619,6 +619,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);
@@ -4858,6 +4861,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;
 
@@ -4896,7 +4900,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);
@@ -6021,7 +6025,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);
 
@@ -6253,9 +6257,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);
@@ -6825,6 +6834,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)
 {
@@ -6924,7 +6941,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;
        }
@@ -6975,9 +6992,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;
@@ -7392,7 +7414,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,
@@ -7700,6 +7722,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) {
@@ -8015,6 +8038,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)
 {
@@ -8056,16 +8086,20 @@ bnx2_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
        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");
                goto error;
@@ -8180,6 +8214,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);