netdev: remove HAVE_ leftovers
[safe/jmp/linux-2.6] / drivers / net / bnx2.c
index b1c20e5..5917b94 100644 (file)
@@ -48,7 +48,6 @@
 #include <linux/cache.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
@@ -3579,14 +3578,14 @@ bnx2_set_rx_mode(struct net_device *dev)
                sort_mode |= BNX2_RPM_SORT_USER0_MC_HSH_EN;
        }
 
-       if (dev->uc.count > BNX2_MAX_UNICAST_ADDRESSES) {
+       if (netdev_uc_count(dev) > 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)) {
                /* Add all entries into to the match filter list */
                i = 0;
-               list_for_each_entry(ha, &dev->uc.list, list) {
+               netdev_for_each_uc_addr(ha, dev) {
                        bnx2_set_mac_addr(bp, ha->addr,
                                          i + BNX2_START_UNICAST_ADDRESS_INDEX);
                        sort_mode |= (1 <<
@@ -6231,6 +6230,8 @@ bnx2_open(struct net_device *dev)
 
        atomic_set(&bp->intr_sem, 0);
 
+       memset(bp->temp_stats_blk, 0, sizeof(struct statistics_block));
+
        bnx2_enable_int(bp);
 
        if (bp->flags & BNX2_FLAG_USING_MSI) {
@@ -6542,92 +6543,121 @@ bnx2_close(struct net_device *dev)
        return 0;
 }
 
-#define GET_NET_STATS64(ctr)                                   \
+static void
+bnx2_save_stats(struct bnx2 *bp)
+{
+       u32 *hw_stats = (u32 *) bp->stats_blk;
+       u32 *temp_stats = (u32 *) bp->temp_stats_blk;
+       int i;
+
+       /* The 1st 10 counters are 64-bit counters */
+       for (i = 0; i < 20; i += 2) {
+               u32 hi;
+               u64 lo;
+
+               hi = *(temp_stats + i) + *(hw_stats + i);
+               lo = *(temp_stats + i + 1) + *(hw_stats + i + 1);
+               if (lo > 0xffffffff)
+                       hi++;
+               *(temp_stats + i) = hi;
+               *(temp_stats + i + 1) = lo & 0xffffffff;
+       }
+
+       for ( ; i < sizeof(struct statistics_block) / 4; i++)
+               *(temp_stats + i) = *(temp_stats + i) + *(hw_stats + i);
+}
+
+#define GET_64BIT_NET_STATS64(ctr)                             \
        (unsigned long) ((unsigned long) (ctr##_hi) << 32) +    \
        (unsigned long) (ctr##_lo)
 
-#define GET_NET_STATS32(ctr)           \
+#define GET_64BIT_NET_STATS32(ctr)                             \
        (ctr##_lo)
 
 #if (BITS_PER_LONG == 64)
-#define GET_NET_STATS  GET_NET_STATS64
+#define GET_64BIT_NET_STATS(ctr)                               \
+       GET_64BIT_NET_STATS64(bp->stats_blk->ctr) +             \
+       GET_64BIT_NET_STATS64(bp->temp_stats_blk->ctr)
 #else
-#define GET_NET_STATS  GET_NET_STATS32
+#define GET_64BIT_NET_STATS(ctr)                               \
+       GET_64BIT_NET_STATS32(bp->stats_blk->ctr) +             \
+       GET_64BIT_NET_STATS32(bp->temp_stats_blk->ctr)
 #endif
 
+#define GET_32BIT_NET_STATS(ctr)                               \
+       (unsigned long) (bp->stats_blk->ctr +                   \
+                        bp->temp_stats_blk->ctr)
+
 static struct net_device_stats *
 bnx2_get_stats(struct net_device *dev)
 {
        struct bnx2 *bp = netdev_priv(dev);
-       struct statistics_block *stats_blk = bp->stats_blk;
        struct net_device_stats *net_stats = &dev->stats;
 
        if (bp->stats_blk == NULL) {
                return net_stats;
        }
        net_stats->rx_packets =
-               GET_NET_STATS(stats_blk->stat_IfHCInUcastPkts) +
-               GET_NET_STATS(stats_blk->stat_IfHCInMulticastPkts) +
-               GET_NET_STATS(stats_blk->stat_IfHCInBroadcastPkts);
+               GET_64BIT_NET_STATS(stat_IfHCInUcastPkts) +
+               GET_64BIT_NET_STATS(stat_IfHCInMulticastPkts) +
+               GET_64BIT_NET_STATS(stat_IfHCInBroadcastPkts);
 
        net_stats->tx_packets =
-               GET_NET_STATS(stats_blk->stat_IfHCOutUcastPkts) +
-               GET_NET_STATS(stats_blk->stat_IfHCOutMulticastPkts) +
-               GET_NET_STATS(stats_blk->stat_IfHCOutBroadcastPkts);
+               GET_64BIT_NET_STATS(stat_IfHCOutUcastPkts) +
+               GET_64BIT_NET_STATS(stat_IfHCOutMulticastPkts) +
+               GET_64BIT_NET_STATS(stat_IfHCOutBroadcastPkts);
 
        net_stats->rx_bytes =
-               GET_NET_STATS(stats_blk->stat_IfHCInOctets);
+               GET_64BIT_NET_STATS(stat_IfHCInOctets);
 
        net_stats->tx_bytes =
-               GET_NET_STATS(stats_blk->stat_IfHCOutOctets);
+               GET_64BIT_NET_STATS(stat_IfHCOutOctets);
 
        net_stats->multicast =
-               GET_NET_STATS(stats_blk->stat_IfHCOutMulticastPkts);
+               GET_64BIT_NET_STATS(stat_IfHCOutMulticastPkts);
 
        net_stats->collisions =
-               (unsigned long) stats_blk->stat_EtherStatsCollisions;
+               GET_32BIT_NET_STATS(stat_EtherStatsCollisions);
 
        net_stats->rx_length_errors =
-               (unsigned long) (stats_blk->stat_EtherStatsUndersizePkts +
-               stats_blk->stat_EtherStatsOverrsizePkts);
+               GET_32BIT_NET_STATS(stat_EtherStatsUndersizePkts) +
+               GET_32BIT_NET_STATS(stat_EtherStatsOverrsizePkts);
 
        net_stats->rx_over_errors =
-               (unsigned long) (stats_blk->stat_IfInFTQDiscards +
-               stats_blk->stat_IfInMBUFDiscards);
+               GET_32BIT_NET_STATS(stat_IfInFTQDiscards) +
+               GET_32BIT_NET_STATS(stat_IfInMBUFDiscards);
 
        net_stats->rx_frame_errors =
-               (unsigned long) stats_blk->stat_Dot3StatsAlignmentErrors;
+               GET_32BIT_NET_STATS(stat_Dot3StatsAlignmentErrors);
 
        net_stats->rx_crc_errors =
-               (unsigned long) stats_blk->stat_Dot3StatsFCSErrors;
+               GET_32BIT_NET_STATS(stat_Dot3StatsFCSErrors);
 
        net_stats->rx_errors = net_stats->rx_length_errors +
                net_stats->rx_over_errors + net_stats->rx_frame_errors +
                net_stats->rx_crc_errors;
 
        net_stats->tx_aborted_errors =
-               (unsigned long) (stats_blk->stat_Dot3StatsExcessiveCollisions +
-               stats_blk->stat_Dot3StatsLateCollisions);
+               GET_32BIT_NET_STATS(stat_Dot3StatsExcessiveCollisions) +
+               GET_32BIT_NET_STATS(stat_Dot3StatsLateCollisions);
 
        if ((CHIP_NUM(bp) == CHIP_NUM_5706) ||
            (CHIP_ID(bp) == CHIP_ID_5708_A0))
                net_stats->tx_carrier_errors = 0;
        else {
                net_stats->tx_carrier_errors =
-                       (unsigned long)
-                       stats_blk->stat_Dot3StatsCarrierSenseErrors;
+                       GET_32BIT_NET_STATS(stat_Dot3StatsCarrierSenseErrors);
        }
 
        net_stats->tx_errors =
-               (unsigned long)
-               stats_blk->stat_emac_tx_stat_dot3statsinternalmactransmiterrors
-               +
+               GET_32BIT_NET_STATS(stat_emac_tx_stat_dot3statsinternalmactransmiterrors) +
                net_stats->tx_aborted_errors +
                net_stats->tx_carrier_errors;
 
        net_stats->rx_missed_errors =
-               (unsigned long) (stats_blk->stat_IfInFTQDiscards +
-               stats_blk->stat_IfInMBUFDiscards + stats_blk->stat_FwRxDrop);
+               GET_32BIT_NET_STATS(stat_IfInFTQDiscards) +
+               GET_32BIT_NET_STATS(stat_IfInMBUFDiscards) +
+               GET_32BIT_NET_STATS(stat_FwRxDrop);
 
        return net_stats;
 }
@@ -7087,6 +7117,9 @@ static int
 bnx2_change_ring_size(struct bnx2 *bp, u32 rx, u32 tx)
 {
        if (netif_running(bp->dev)) {
+               /* Reset will erase chipset stats; save them */
+               bnx2_save_stats(bp);
+
                bnx2_netif_stop(bp);
                bnx2_reset_chip(bp, BNX2_DRV_MSG_CODE_RESET);
                bnx2_free_skbs(bp);
@@ -7431,6 +7464,7 @@ bnx2_get_ethtool_stats(struct net_device *dev,
        struct bnx2 *bp = netdev_priv(dev);
        int i;
        u32 *hw_stats = (u32 *) bp->stats_blk;
+       u32 *temp_stats = (u32 *) bp->temp_stats_blk;
        u8 *stats_len_arr = NULL;
 
        if (hw_stats == NULL) {
@@ -7447,21 +7481,26 @@ bnx2_get_ethtool_stats(struct net_device *dev,
                stats_len_arr = bnx2_5708_stats_len_arr;
 
        for (i = 0; i < BNX2_NUM_STATS; i++) {
+               unsigned long offset;
+
                if (stats_len_arr[i] == 0) {
                        /* skip this counter */
                        buf[i] = 0;
                        continue;
                }
+
+               offset = bnx2_stats_offset_arr[i];
                if (stats_len_arr[i] == 4) {
                        /* 4-byte counter */
-                       buf[i] = (u64)
-                               *(hw_stats + bnx2_stats_offset_arr[i]);
+                       buf[i] = (u64) *(hw_stats + offset) +
+                                *(temp_stats + offset);
                        continue;
                }
                /* 8-byte counter */
-               buf[i] = (((u64) *(hw_stats +
-                                       bnx2_stats_offset_arr[i])) << 32) +
-                               *(hw_stats + bnx2_stats_offset_arr[i] + 1);
+               buf[i] = (((u64) *(hw_stats + offset)) << 32) +
+                        *(hw_stats + offset + 1) +
+                        (((u64) *(temp_stats + offset)) << 32) +
+                        *(temp_stats + offset + 1);
        }
 }
 
@@ -7629,7 +7668,7 @@ bnx2_change_mtu(struct net_device *dev, int new_mtu)
        return (bnx2_change_ring_size(bp, bp->rx_ring_size, bp->tx_ring_size));
 }
 
-#if defined(HAVE_POLL_CONTROLLER) || defined(CONFIG_NET_POLL_CONTROLLER)
+#ifdef CONFIG_NET_POLL_CONTROLLER
 static void
 poll_bnx2(struct net_device *dev)
 {
@@ -7829,6 +7868,14 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
        bp->flags = 0;
        bp->phy_flags = 0;
 
+       bp->temp_stats_blk =
+               kzalloc(sizeof(struct statistics_block), GFP_KERNEL);
+
+       if (bp->temp_stats_blk == NULL) {
+               rc = -ENOMEM;
+               goto err_out;
+       }
+
        /* enable device (incl. PCI PM wakeup), and bus-mastering */
        rc = pci_enable_device(pdev);
        if (rc) {
@@ -8233,7 +8280,7 @@ static const struct net_device_ops bnx2_netdev_ops = {
 #ifdef BCM_VLAN
        .ndo_vlan_rx_register   = bnx2_vlan_rx_register,
 #endif
-#if defined(HAVE_POLL_CONTROLLER) || defined(CONFIG_NET_POLL_CONTROLLER)
+#ifdef CONFIG_NET_POLL_CONTROLLER
        .ndo_poll_controller    = poll_bnx2,
 #endif
 };
@@ -8350,6 +8397,8 @@ bnx2_remove_one(struct pci_dev *pdev)
        if (bp->regview)
                iounmap(bp->regview);
 
+       kfree(bp->temp_stats_blk);
+
        free_netdev(dev);
        pci_release_regions(pdev);
        pci_disable_device(pdev);