aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/broadcom/tg3.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/ethernet/broadcom/tg3.c')
-rw-r--r--drivers/net/ethernet/broadcom/tg3.c43
1 files changed, 22 insertions, 21 deletions
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index 97dcccdb9eb2..76f33d5c7272 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -8001,10 +8001,8 @@ static int tg3_chip_reset(struct tg3 *tp)
8001 return 0; 8001 return 0;
8002} 8002}
8003 8003
8004static struct rtnl_link_stats64 *tg3_get_stats64(struct net_device *, 8004static void tg3_get_nstats(struct tg3 *, struct rtnl_link_stats64 *);
8005 struct rtnl_link_stats64 *); 8005static void tg3_get_estats(struct tg3 *, struct tg3_ethtool_stats *);
8006static struct tg3_ethtool_stats *tg3_get_estats(struct tg3 *,
8007 struct tg3_ethtool_stats *);
8008 8006
8009/* tp->lock is held. */ 8007/* tp->lock is held. */
8010static int tg3_halt(struct tg3 *tp, int kind, int silent) 8008static int tg3_halt(struct tg3 *tp, int kind, int silent)
@@ -8025,7 +8023,7 @@ static int tg3_halt(struct tg3 *tp, int kind, int silent)
8025 8023
8026 if (tp->hw_stats) { 8024 if (tp->hw_stats) {
8027 /* Save the stats across chip resets... */ 8025 /* Save the stats across chip resets... */
8028 tg3_get_stats64(tp->dev, &tp->net_stats_prev), 8026 tg3_get_nstats(tp, &tp->net_stats_prev);
8029 tg3_get_estats(tp, &tp->estats_prev); 8027 tg3_get_estats(tp, &tp->estats_prev);
8030 8028
8031 /* And make sure the next sample is new data */ 8029 /* And make sure the next sample is new data */
@@ -10125,7 +10123,7 @@ static inline u64 get_stat64(tg3_stat64_t *val)
10125 return ((u64)val->high << 32) | ((u64)val->low); 10123 return ((u64)val->high << 32) | ((u64)val->low);
10126} 10124}
10127 10125
10128static u64 calc_crc_errors(struct tg3 *tp) 10126static u64 tg3_calc_crc_errors(struct tg3 *tp)
10129{ 10127{
10130 struct tg3_hw_stats *hw_stats = tp->hw_stats; 10128 struct tg3_hw_stats *hw_stats = tp->hw_stats;
10131 10129
@@ -10134,14 +10132,12 @@ static u64 calc_crc_errors(struct tg3 *tp)
10134 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701)) { 10132 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701)) {
10135 u32 val; 10133 u32 val;
10136 10134
10137 spin_lock_bh(&tp->lock);
10138 if (!tg3_readphy(tp, MII_TG3_TEST1, &val)) { 10135 if (!tg3_readphy(tp, MII_TG3_TEST1, &val)) {
10139 tg3_writephy(tp, MII_TG3_TEST1, 10136 tg3_writephy(tp, MII_TG3_TEST1,
10140 val | MII_TG3_TEST1_CRC_EN); 10137 val | MII_TG3_TEST1_CRC_EN);
10141 tg3_readphy(tp, MII_TG3_RXR_COUNTERS, &val); 10138 tg3_readphy(tp, MII_TG3_RXR_COUNTERS, &val);
10142 } else 10139 } else
10143 val = 0; 10140 val = 0;
10144 spin_unlock_bh(&tp->lock);
10145 10141
10146 tp->phy_crc_errors += val; 10142 tp->phy_crc_errors += val;
10147 10143
@@ -10155,8 +10151,7 @@ static u64 calc_crc_errors(struct tg3 *tp)
10155 estats->member = old_estats->member + \ 10151 estats->member = old_estats->member + \
10156 get_stat64(&hw_stats->member) 10152 get_stat64(&hw_stats->member)
10157 10153
10158static struct tg3_ethtool_stats *tg3_get_estats(struct tg3 *tp, 10154static void tg3_get_estats(struct tg3 *tp, struct tg3_ethtool_stats *estats)
10159 struct tg3_ethtool_stats *estats)
10160{ 10155{
10161 struct tg3_ethtool_stats *old_estats = &tp->estats_prev; 10156 struct tg3_ethtool_stats *old_estats = &tp->estats_prev;
10162 struct tg3_hw_stats *hw_stats = tp->hw_stats; 10157 struct tg3_hw_stats *hw_stats = tp->hw_stats;
@@ -10238,20 +10233,13 @@ static struct tg3_ethtool_stats *tg3_get_estats(struct tg3 *tp,
10238 ESTAT_ADD(nic_tx_threshold_hit); 10233 ESTAT_ADD(nic_tx_threshold_hit);
10239 10234
10240 ESTAT_ADD(mbuf_lwm_thresh_hit); 10235 ESTAT_ADD(mbuf_lwm_thresh_hit);
10241
10242 return estats;
10243} 10236}
10244 10237
10245static struct rtnl_link_stats64 *tg3_get_stats64(struct net_device *dev, 10238static void tg3_get_nstats(struct tg3 *tp, struct rtnl_link_stats64 *stats)
10246 struct rtnl_link_stats64 *stats)
10247{ 10239{
10248 struct tg3 *tp = netdev_priv(dev);
10249 struct rtnl_link_stats64 *old_stats = &tp->net_stats_prev; 10240 struct rtnl_link_stats64 *old_stats = &tp->net_stats_prev;
10250 struct tg3_hw_stats *hw_stats = tp->hw_stats; 10241 struct tg3_hw_stats *hw_stats = tp->hw_stats;
10251 10242
10252 if (!hw_stats)
10253 return old_stats;
10254
10255 stats->rx_packets = old_stats->rx_packets + 10243 stats->rx_packets = old_stats->rx_packets +
10256 get_stat64(&hw_stats->rx_ucast_packets) + 10244 get_stat64(&hw_stats->rx_ucast_packets) +
10257 get_stat64(&hw_stats->rx_mcast_packets) + 10245 get_stat64(&hw_stats->rx_mcast_packets) +
@@ -10294,15 +10282,13 @@ static struct rtnl_link_stats64 *tg3_get_stats64(struct net_device *dev,
10294 get_stat64(&hw_stats->tx_carrier_sense_errors); 10282 get_stat64(&hw_stats->tx_carrier_sense_errors);
10295 10283
10296 stats->rx_crc_errors = old_stats->rx_crc_errors + 10284 stats->rx_crc_errors = old_stats->rx_crc_errors +
10297 calc_crc_errors(tp); 10285 tg3_calc_crc_errors(tp);
10298 10286
10299 stats->rx_missed_errors = old_stats->rx_missed_errors + 10287 stats->rx_missed_errors = old_stats->rx_missed_errors +
10300 get_stat64(&hw_stats->rx_discards); 10288 get_stat64(&hw_stats->rx_discards);
10301 10289
10302 stats->rx_dropped = tp->rx_dropped; 10290 stats->rx_dropped = tp->rx_dropped;
10303 stats->tx_dropped = tp->tx_dropped; 10291 stats->tx_dropped = tp->tx_dropped;
10304
10305 return stats;
10306} 10292}
10307 10293
10308static int tg3_get_regs_len(struct net_device *dev) 10294static int tg3_get_regs_len(struct net_device *dev)
@@ -12213,6 +12199,21 @@ static const struct ethtool_ops tg3_ethtool_ops = {
12213 .set_rxfh_indir = tg3_set_rxfh_indir, 12199 .set_rxfh_indir = tg3_set_rxfh_indir,
12214}; 12200};
12215 12201
12202static struct rtnl_link_stats64 *tg3_get_stats64(struct net_device *dev,
12203 struct rtnl_link_stats64 *stats)
12204{
12205 struct tg3 *tp = netdev_priv(dev);
12206
12207 if (!tp->hw_stats)
12208 return &tp->net_stats_prev;
12209
12210 spin_lock_bh(&tp->lock);
12211 tg3_get_nstats(tp, stats);
12212 spin_unlock_bh(&tp->lock);
12213
12214 return stats;
12215}
12216
12216static void tg3_set_rx_mode(struct net_device *dev) 12217static void tg3_set_rx_mode(struct net_device *dev)
12217{ 12218{
12218 struct tg3 *tp = netdev_priv(dev); 12219 struct tg3 *tp = netdev_priv(dev);