提交 511d2224 编写于 作者: E Eric Dumazet 提交者: David S. Miller

tg3: 64 bit stats on all arches

Now core network is able to handle 64 bit netdevice stats on 32 bit
arches, we can provide them for tg3, since hardware maintains 64 bit
counters.
Signed-off-by: NEric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 5d07bf26
...@@ -9021,7 +9021,8 @@ static int tg3_open(struct net_device *dev) ...@@ -9021,7 +9021,8 @@ static int tg3_open(struct net_device *dev)
return err; return err;
} }
static struct net_device_stats *tg3_get_stats(struct net_device *); static struct rtnl_link_stats64 *tg3_get_stats64(struct net_device *,
struct rtnl_link_stats64 *);
static struct tg3_ethtool_stats *tg3_get_estats(struct tg3 *); static struct tg3_ethtool_stats *tg3_get_estats(struct tg3 *);
static int tg3_close(struct net_device *dev) static int tg3_close(struct net_device *dev)
...@@ -9055,8 +9056,8 @@ static int tg3_close(struct net_device *dev) ...@@ -9055,8 +9056,8 @@ static int tg3_close(struct net_device *dev)
tg3_ints_fini(tp); tg3_ints_fini(tp);
memcpy(&tp->net_stats_prev, tg3_get_stats(tp->dev), tg3_get_stats64(tp->dev, &tp->net_stats_prev);
sizeof(tp->net_stats_prev));
memcpy(&tp->estats_prev, tg3_get_estats(tp), memcpy(&tp->estats_prev, tg3_get_estats(tp),
sizeof(tp->estats_prev)); sizeof(tp->estats_prev));
...@@ -9069,24 +9070,12 @@ static int tg3_close(struct net_device *dev) ...@@ -9069,24 +9070,12 @@ static int tg3_close(struct net_device *dev)
return 0; return 0;
} }
static inline unsigned long get_stat64(tg3_stat64_t *val) static inline u64 get_stat64(tg3_stat64_t *val)
{
unsigned long ret;
#if (BITS_PER_LONG == 32)
ret = val->low;
#else
ret = ((u64)val->high << 32) | ((u64)val->low);
#endif
return ret;
}
static inline u64 get_estat64(tg3_stat64_t *val)
{ {
return ((u64)val->high << 32) | ((u64)val->low); return ((u64)val->high << 32) | ((u64)val->low);
} }
static unsigned long calc_crc_errors(struct tg3 *tp) static u64 calc_crc_errors(struct tg3 *tp)
{ {
struct tg3_hw_stats *hw_stats = tp->hw_stats; struct tg3_hw_stats *hw_stats = tp->hw_stats;
...@@ -9114,7 +9103,7 @@ static unsigned long calc_crc_errors(struct tg3 *tp) ...@@ -9114,7 +9103,7 @@ static unsigned long calc_crc_errors(struct tg3 *tp)
#define ESTAT_ADD(member) \ #define ESTAT_ADD(member) \
estats->member = old_estats->member + \ estats->member = old_estats->member + \
get_estat64(&hw_stats->member) get_stat64(&hw_stats->member)
static struct tg3_ethtool_stats *tg3_get_estats(struct tg3 *tp) static struct tg3_ethtool_stats *tg3_get_estats(struct tg3 *tp)
{ {
...@@ -9204,11 +9193,11 @@ static struct tg3_ethtool_stats *tg3_get_estats(struct tg3 *tp) ...@@ -9204,11 +9193,11 @@ static struct tg3_ethtool_stats *tg3_get_estats(struct tg3 *tp)
return estats; return estats;
} }
static struct net_device_stats *tg3_get_stats(struct net_device *dev) static struct rtnl_link_stats64 *tg3_get_stats64(struct net_device *dev,
struct rtnl_link_stats64 *stats)
{ {
struct tg3 *tp = netdev_priv(dev); struct tg3 *tp = netdev_priv(dev);
struct net_device_stats *stats = &tp->net_stats; struct rtnl_link_stats64 *old_stats = &tp->net_stats_prev;
struct net_device_stats *old_stats = &tp->net_stats_prev;
struct tg3_hw_stats *hw_stats = tp->hw_stats; struct tg3_hw_stats *hw_stats = tp->hw_stats;
if (!hw_stats) if (!hw_stats)
...@@ -14317,7 +14306,7 @@ static const struct net_device_ops tg3_netdev_ops = { ...@@ -14317,7 +14306,7 @@ static const struct net_device_ops tg3_netdev_ops = {
.ndo_open = tg3_open, .ndo_open = tg3_open,
.ndo_stop = tg3_close, .ndo_stop = tg3_close,
.ndo_start_xmit = tg3_start_xmit, .ndo_start_xmit = tg3_start_xmit,
.ndo_get_stats = tg3_get_stats, .ndo_get_stats64 = tg3_get_stats64,
.ndo_validate_addr = eth_validate_addr, .ndo_validate_addr = eth_validate_addr,
.ndo_set_multicast_list = tg3_set_rx_mode, .ndo_set_multicast_list = tg3_set_rx_mode,
.ndo_set_mac_address = tg3_set_mac_addr, .ndo_set_mac_address = tg3_set_mac_addr,
...@@ -14336,7 +14325,7 @@ static const struct net_device_ops tg3_netdev_ops_dma_bug = { ...@@ -14336,7 +14325,7 @@ static const struct net_device_ops tg3_netdev_ops_dma_bug = {
.ndo_open = tg3_open, .ndo_open = tg3_open,
.ndo_stop = tg3_close, .ndo_stop = tg3_close,
.ndo_start_xmit = tg3_start_xmit_dma_bug, .ndo_start_xmit = tg3_start_xmit_dma_bug,
.ndo_get_stats = tg3_get_stats, .ndo_get_stats64 = tg3_get_stats64,
.ndo_validate_addr = eth_validate_addr, .ndo_validate_addr = eth_validate_addr,
.ndo_set_multicast_list = tg3_set_rx_mode, .ndo_set_multicast_list = tg3_set_rx_mode,
.ndo_set_mac_address = tg3_set_mac_addr, .ndo_set_mac_address = tg3_set_mac_addr,
......
...@@ -2772,8 +2772,8 @@ struct tg3 { ...@@ -2772,8 +2772,8 @@ struct tg3 {
/* begin "everything else" cacheline(s) section */ /* begin "everything else" cacheline(s) section */
struct net_device_stats net_stats; struct rtnl_link_stats64 net_stats;
struct net_device_stats net_stats_prev; struct rtnl_link_stats64 net_stats_prev;
struct tg3_ethtool_stats estats; struct tg3_ethtool_stats estats;
struct tg3_ethtool_stats estats_prev; struct tg3_ethtool_stats estats_prev;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册