netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next-2.6 V2] tg3: 64 bit stats on all arches
@ 2010-07-08  6:44 Eric Dumazet
  2010-07-08 10:05 ` [PATCH net-next-2.6] bnx2: " Eric Dumazet
  2010-07-09  6:14 ` [PATCH net-next-2.6 V2] tg3: " David Miller
  0 siblings, 2 replies; 6+ messages in thread
From: Eric Dumazet @ 2010-07-08  6:44 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, Matt Carlson, Michael Chan

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.

I'll provide bnx2 and bnx2x patches as well.

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
---
 drivers/net/tg3.c |   35 ++++++++++++-----------------------
 drivers/net/tg3.h |    4 ++--
 2 files changed, 14 insertions(+), 25 deletions(-)

diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index 289cdc5..7c75f1e 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -9021,7 +9021,8 @@ err_out1:
 	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 int tg3_close(struct net_device *dev)
@@ -9055,8 +9056,8 @@ static int tg3_close(struct net_device *dev)
 
 	tg3_ints_fini(tp);
 
-	memcpy(&tp->net_stats_prev, tg3_get_stats(tp->dev),
-	       sizeof(tp->net_stats_prev));
+	tg3_get_stats64(tp->dev, &tp->net_stats_prev);
+
 	memcpy(&tp->estats_prev, tg3_get_estats(tp),
 	       sizeof(tp->estats_prev));
 
@@ -9069,24 +9070,12 @@ static int tg3_close(struct net_device *dev)
 	return 0;
 }
 
-static inline unsigned long 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)
+static inline u64 get_stat64(tg3_stat64_t *val)
 {
        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;
 
@@ -9114,7 +9103,7 @@ static unsigned long calc_crc_errors(struct tg3 *tp)
 
 #define ESTAT_ADD(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)
 {
@@ -9204,11 +9193,11 @@ static struct tg3_ethtool_stats *tg3_get_estats(struct tg3 *tp)
 	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 net_device_stats *stats = &tp->net_stats;
-	struct net_device_stats *old_stats = &tp->net_stats_prev;
+	struct rtnl_link_stats64 *old_stats = &tp->net_stats_prev;
 	struct tg3_hw_stats *hw_stats = tp->hw_stats;
 
 	if (!hw_stats)
@@ -14317,7 +14306,7 @@ static const struct net_device_ops tg3_netdev_ops = {
 	.ndo_open		= tg3_open,
 	.ndo_stop		= tg3_close,
 	.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_set_multicast_list	= tg3_set_rx_mode,
 	.ndo_set_mac_address	= tg3_set_mac_addr,
@@ -14336,7 +14325,7 @@ static const struct net_device_ops tg3_netdev_ops_dma_bug = {
 	.ndo_open		= tg3_open,
 	.ndo_stop		= tg3_close,
 	.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_set_multicast_list	= tg3_set_rx_mode,
 	.ndo_set_mac_address	= tg3_set_mac_addr,
diff --git a/drivers/net/tg3.h b/drivers/net/tg3.h
index 6b6af76..b72ac52 100644
--- a/drivers/net/tg3.h
+++ b/drivers/net/tg3.h
@@ -2772,8 +2772,8 @@ struct tg3 {
 
 
 	/* begin "everything else" cacheline(s) section */
-	struct net_device_stats		net_stats;
-	struct net_device_stats		net_stats_prev;
+	struct rtnl_link_stats64	net_stats;
+	struct rtnl_link_stats64	net_stats_prev;
 	struct tg3_ethtool_stats	estats;
 	struct tg3_ethtool_stats	estats_prev;
 



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH net-next-2.6] bnx2: 64 bit stats on all arches
  2010-07-08  6:44 [PATCH net-next-2.6 V2] tg3: 64 bit stats on all arches Eric Dumazet
@ 2010-07-08 10:05 ` Eric Dumazet
  2010-07-08 14:00   ` Michael Chan
  2010-07-09  6:14 ` [PATCH net-next-2.6 V2] tg3: " David Miller
  1 sibling, 1 reply; 6+ messages in thread
From: Eric Dumazet @ 2010-07-08 10:05 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, Matt Carlson, Michael Chan

Now core network is able to handle 64 bit netdevice stats on 32 bit
arches, we can provide them for bnx2, since hardware maintains some 64
bit counters.

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
---
 drivers/net/bnx2.c |   22 +++++++---------------
 1 file changed, 7 insertions(+), 15 deletions(-)

diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index 22fa1e9..2975bf9 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -6589,36 +6589,28 @@ bnx2_save_stats(struct bnx2 *bp)
 		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_64BIT_NET_STATS64(ctr)		\
+	(((u64) (ctr##_hi) << 32) + (u64) (ctr##_lo))
 
 #define GET_64BIT_NET_STATS32(ctr)				\
 	(ctr##_lo)
 
-#if (BITS_PER_LONG == 64)
 #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_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)
+static struct rtnl_link_stats64 *
+bnx2_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *net_stats)
 {
 	struct bnx2 *bp = netdev_priv(dev);
-	struct net_device_stats *net_stats = &dev->stats;
 
-	if (bp->stats_blk == NULL) {
+	if (bp->stats_blk == NULL)
 		return net_stats;
-	}
+
 	net_stats->rx_packets =
 		GET_64BIT_NET_STATS(stat_IfHCInUcastPkts) +
 		GET_64BIT_NET_STATS(stat_IfHCInMulticastPkts) +
@@ -8289,7 +8281,7 @@ static const struct net_device_ops bnx2_netdev_ops = {
 	.ndo_open		= bnx2_open,
 	.ndo_start_xmit		= bnx2_start_xmit,
 	.ndo_stop		= bnx2_close,
-	.ndo_get_stats		= bnx2_get_stats,
+	.ndo_get_stats64	= bnx2_get_stats64,
 	.ndo_set_rx_mode	= bnx2_set_rx_mode,
 	.ndo_do_ioctl		= bnx2_ioctl,
 	.ndo_validate_addr	= eth_validate_addr,



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next-2.6] bnx2: 64 bit stats on all arches
  2010-07-08 10:05 ` [PATCH net-next-2.6] bnx2: " Eric Dumazet
@ 2010-07-08 14:00   ` Michael Chan
  2010-07-08 14:08     ` Eric Dumazet
  0 siblings, 1 reply; 6+ messages in thread
From: Michael Chan @ 2010-07-08 14:00 UTC (permalink / raw)
  To: 'Eric Dumazet', David Miller; +Cc: netdev, Matthew Carlson

Eric Dumazet wrote:

> Now core network is able to handle 64 bit netdevice stats on 32 bit
> arches, we can provide them for bnx2, since hardware maintains some 64
> bit counters.
>
> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
> ---
>  drivers/net/bnx2.c |   22 +++++++---------------
>  1 file changed, 7 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
> index 22fa1e9..2975bf9 100644
> --- a/drivers/net/bnx2.c
> +++ b/drivers/net/bnx2.c
> @@ -6589,36 +6589,28 @@ bnx2_save_stats(struct bnx2 *bp)
>               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_64BIT_NET_STATS64(ctr)           \
> +     (((u64) (ctr##_hi) << 32) + (u64) (ctr##_lo))
>
>  #define GET_64BIT_NET_STATS32(ctr)                           \
>       (ctr##_lo)

It seems that GET_64BIT_NET_STATS32 is no longer needed.
Other than that,

Acked-by: Michael Chan <mchan@broadcom.com>

Thanks.

>
> -#if (BITS_PER_LONG == 64)
>  #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_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)
> +static struct rtnl_link_stats64 *
> +bnx2_get_stats64(struct net_device *dev, struct
> rtnl_link_stats64 *net_stats)
>  {
>       struct bnx2 *bp = netdev_priv(dev);
> -     struct net_device_stats *net_stats = &dev->stats;
>
> -     if (bp->stats_blk == NULL) {
> +     if (bp->stats_blk == NULL)
>               return net_stats;
> -     }
> +
>       net_stats->rx_packets =
>               GET_64BIT_NET_STATS(stat_IfHCInUcastPkts) +
>               GET_64BIT_NET_STATS(stat_IfHCInMulticastPkts) +
> @@ -8289,7 +8281,7 @@ static const struct net_device_ops
> bnx2_netdev_ops = {
>       .ndo_open               = bnx2_open,
>       .ndo_start_xmit         = bnx2_start_xmit,
>       .ndo_stop               = bnx2_close,
> -     .ndo_get_stats          = bnx2_get_stats,
> +     .ndo_get_stats64        = bnx2_get_stats64,
>       .ndo_set_rx_mode        = bnx2_set_rx_mode,
>       .ndo_do_ioctl           = bnx2_ioctl,
>       .ndo_validate_addr      = eth_validate_addr,
>
>
>
>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next-2.6] bnx2: 64 bit stats on all arches
  2010-07-08 14:00   ` Michael Chan
@ 2010-07-08 14:08     ` Eric Dumazet
  2010-07-09  6:13       ` David Miller
  0 siblings, 1 reply; 6+ messages in thread
From: Eric Dumazet @ 2010-07-08 14:08 UTC (permalink / raw)
  To: Michael Chan; +Cc: David Miller, netdev, Matthew Carlson

Le jeudi 08 juillet 2010 à 07:00 -0700, Michael Chan a écrit :

> It seems that GET_64BIT_NET_STATS32 is no longer needed.
> Other than that,
> 
> Acked-by: Michael Chan <mchan@broadcom.com>
> 
> Thanks.

Indeed, thanks for the tip !
Here is the updated version.

[PATCH net-next-2.6] bnx2: 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 bnx2, since hardware maintains some 64
bit counters.

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Acked-by: Michael Chan <mchan@broadcom.com>
---
 drivers/net/bnx2.c |   25 +++++++------------------
 1 file changed, 7 insertions(+), 18 deletions(-)

diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index 22fa1e9..a203f39 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -6589,36 +6589,25 @@ bnx2_save_stats(struct bnx2 *bp)
 		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_64BIT_NET_STATS64(ctr)		\
+	(((u64) (ctr##_hi) << 32) + (u64) (ctr##_lo))
 
-#define GET_64BIT_NET_STATS32(ctr)				\
-	(ctr##_lo)
-
-#if (BITS_PER_LONG == 64)
 #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_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)
+static struct rtnl_link_stats64 *
+bnx2_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *net_stats)
 {
 	struct bnx2 *bp = netdev_priv(dev);
-	struct net_device_stats *net_stats = &dev->stats;
 
-	if (bp->stats_blk == NULL) {
+	if (bp->stats_blk == NULL)
 		return net_stats;
-	}
+
 	net_stats->rx_packets =
 		GET_64BIT_NET_STATS(stat_IfHCInUcastPkts) +
 		GET_64BIT_NET_STATS(stat_IfHCInMulticastPkts) +
@@ -8289,7 +8278,7 @@ static const struct net_device_ops bnx2_netdev_ops = {
 	.ndo_open		= bnx2_open,
 	.ndo_start_xmit		= bnx2_start_xmit,
 	.ndo_stop		= bnx2_close,
-	.ndo_get_stats		= bnx2_get_stats,
+	.ndo_get_stats64	= bnx2_get_stats64,
 	.ndo_set_rx_mode	= bnx2_set_rx_mode,
 	.ndo_do_ioctl		= bnx2_ioctl,
 	.ndo_validate_addr	= eth_validate_addr,



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next-2.6] bnx2: 64 bit stats on all arches
  2010-07-08 14:08     ` Eric Dumazet
@ 2010-07-09  6:13       ` David Miller
  0 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2010-07-09  6:13 UTC (permalink / raw)
  To: eric.dumazet; +Cc: mchan, netdev, mcarlson

From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Thu, 08 Jul 2010 16:08:43 +0200

> [PATCH net-next-2.6] bnx2: 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 bnx2, since hardware maintains some 64
> bit counters.
> 
> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
> Acked-by: Michael Chan <mchan@broadcom.com>

Applied, thanks.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next-2.6 V2] tg3: 64 bit stats on all arches
  2010-07-08  6:44 [PATCH net-next-2.6 V2] tg3: 64 bit stats on all arches Eric Dumazet
  2010-07-08 10:05 ` [PATCH net-next-2.6] bnx2: " Eric Dumazet
@ 2010-07-09  6:14 ` David Miller
  1 sibling, 0 replies; 6+ messages in thread
From: David Miller @ 2010-07-09  6:14 UTC (permalink / raw)
  To: eric.dumazet; +Cc: netdev, mcarlson, mchan

From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Thu, 08 Jul 2010 08:44:24 +0200

> 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.
> 
> I'll provide bnx2 and bnx2x patches as well.
> 
> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>

Applied, thanks.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-07-09  6:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-08  6:44 [PATCH net-next-2.6 V2] tg3: 64 bit stats on all arches Eric Dumazet
2010-07-08 10:05 ` [PATCH net-next-2.6] bnx2: " Eric Dumazet
2010-07-08 14:00   ` Michael Chan
2010-07-08 14:08     ` Eric Dumazet
2010-07-09  6:13       ` David Miller
2010-07-09  6:14 ` [PATCH net-next-2.6 V2] tg3: " David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).