All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] via-rhine: add 64bit statistics.
@ 2013-01-23 14:31 Jamie Gloudon
  2013-01-23 14:38 ` Eric Dumazet
  0 siblings, 1 reply; 10+ messages in thread
From: Jamie Gloudon @ 2013-01-23 14:31 UTC (permalink / raw)
  To: netdev; +Cc: davem

Switch to use ndo_get_stats64 to get 64bit statistics.

Signed-off-by: Jamie Gloudon <jamie.gloudon@gmail.com>
---
 drivers/net/ethernet/via/via-rhine.c | 64 +++++++++++++++++++++++++++++++-----
 1 file changed, 56 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/via/via-rhine.c b/drivers/net/ethernet/via/via-rhine.c
index eab63e1..aabc904 100644
--- a/drivers/net/ethernet/via/via-rhine.c
+++ b/drivers/net/ethernet/via/via-rhine.c
@@ -417,6 +417,12 @@ enum chip_cmd_bits {
 	Cmd1NoTxPoll=0x08, Cmd1Reset=0x80,
 };
 
+struct rhine_stats {
+	u64		packets;
+	u64		bytes;
+	struct u64_stats_sync syncp;
+};
+
 struct rhine_private {
 	/* Bit mask for configured VLAN ids */
 	unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
@@ -458,6 +464,8 @@ struct rhine_private {
 	unsigned int cur_rx, dirty_rx;	/* Producer/consumer ring indices */
 	unsigned int cur_tx, dirty_tx;
 	unsigned int rx_buf_sz;		/* Based on MTU+slack. */
+	struct rhine_stats rx_stats;
+	struct rhine_stats tx_stats;
 	u8 wolopts;
 
 	u8 tx_thresh, rx_thresh;
@@ -495,7 +503,8 @@ static irqreturn_t rhine_interrupt(int irq, void *dev_instance);
 static void rhine_tx(struct net_device *dev);
 static int rhine_rx(struct net_device *dev, int limit);
 static void rhine_set_rx_mode(struct net_device *dev);
-static struct net_device_stats *rhine_get_stats(struct net_device *dev);
+static struct rtnl_link_stats64 *rhine_get_stats64(struct net_device *dev,
+	       struct rtnl_link_stats64 *stats);
 static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
 static const struct ethtool_ops netdev_ethtool_ops;
 static int  rhine_close(struct net_device *dev);
@@ -842,7 +851,7 @@ static const struct net_device_ops rhine_netdev_ops = {
 	.ndo_open		 = rhine_open,
 	.ndo_stop		 = rhine_close,
 	.ndo_start_xmit		 = rhine_start_tx,
-	.ndo_get_stats		 = rhine_get_stats,
+	.ndo_get_stats64	 = rhine_get_stats64,
 	.ndo_set_rx_mode	 = rhine_set_rx_mode,
 	.ndo_change_mtu		 = eth_change_mtu,
 	.ndo_validate_addr	 = eth_validate_addr,
@@ -1790,8 +1799,11 @@ static void rhine_tx(struct net_device *dev)
 				dev->stats.collisions += txstatus & 0x0F;
 			netif_dbg(rp, tx_done, dev, "collisions: %1.1x:%1.1x\n",
 				  (txstatus >> 3) & 0xF, txstatus & 0xF);
-			dev->stats.tx_bytes += rp->tx_skbuff[entry]->len;
-			dev->stats.tx_packets++;
+
+			u64_stats_update_begin(&rp->tx_stats.syncp);
+			rp->tx_stats.bytes += rp->tx_skbuff[entry]->len;
+			rp->tx_stats.packets++;
+			u64_stats_update_end(&rp->tx_stats.syncp);
 		}
 		/* Free the original skb. */
 		if (rp->tx_skbuff_dma[entry]) {
@@ -1857,6 +1869,7 @@ static int rhine_rx(struct net_device *dev, int limit)
 					    "Oversized Ethernet frame %p vs %p\n",
 					    rp->rx_head_desc,
 					    &rp->rx_ring[entry]);
+				dev->stats.rx_dropped++;
 				dev->stats.rx_length_errors++;
 			} else if (desc_status & RxErr) {
 				/* There was a error. */
@@ -1923,8 +1936,11 @@ static int rhine_rx(struct net_device *dev, int limit)
 			if (unlikely(desc_length & DescTag))
 				__vlan_hwaccel_put_tag(skb, vlan_tci);
 			netif_receive_skb(skb);
-			dev->stats.rx_bytes += pkt_len;
-			dev->stats.rx_packets++;
+
+			u64_stats_update_begin(&rp->rx_stats.syncp);
+			rp->rx_stats.bytes += pkt_len;
+			rp->rx_stats.packets++;
+			u64_stats_update_end(&rp->rx_stats.syncp);
 		}
 		entry = (++rp->cur_rx) % RX_RING_SIZE;
 		rp->rx_head_desc = &rp->rx_ring[entry];
@@ -2019,15 +2035,47 @@ out_unlock:
 	mutex_unlock(&rp->task_lock);
 }
 
-static struct net_device_stats *rhine_get_stats(struct net_device *dev)
+static struct rtnl_link_stats64 *
+rhine_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats)
 {
 	struct rhine_private *rp = netdev_priv(dev);
+	unsigned int start;
 
 	spin_lock_bh(&rp->lock);
 	rhine_update_rx_crc_and_missed_errord(rp);
 	spin_unlock_bh(&rp->lock);
 
-	return &dev->stats;
+	do {
+		start = u64_stats_fetch_begin_bh(&rp->rx_stats.syncp);
+		stats->rx_packets = rp->rx_stats.packets;
+		stats->rx_bytes = rp->rx_stats.bytes;
+	} while (u64_stats_fetch_retry_bh(&rp->rx_stats.syncp, start));
+
+	do {
+		start = u64_stats_fetch_begin_bh(&rp->tx_stats.syncp);
+		stats->tx_packets = rp->tx_stats.packets;
+		stats->tx_bytes = rp->tx_stats.bytes;
+	} while (u64_stats_fetch_retry_bh(&rp->tx_stats.syncp, start));
+
+	stats->rx_errors = dev->stats.rx_errors;
+	stats->tx_errors = dev->stats.tx_errors;
+	stats->rx_dropped = dev->stats.rx_dropped;
+	stats->tx_dropped = dev->stats.tx_dropped;
+	stats->collisions = dev->stats.collisions;
+
+	stats->rx_length_errors = dev->stats.rx_length_errors;
+	stats->rx_crc_errors = dev->stats.rx_crc_errors;
+	stats->rx_frame_errors = dev->stats.rx_frame_errors;
+	stats->rx_fifo_errors = dev->stats.rx_fifo_errors;
+	stats->rx_missed_errors = dev->stats.rx_missed_errors;
+
+	stats->tx_aborted_errors = dev->stats.tx_aborted_errors;
+	stats->tx_carrier_errors = dev->stats.tx_carrier_errors;
+	stats->tx_fifo_errors = dev->stats.tx_fifo_errors;
+	stats->tx_heartbeat_errors = dev->stats.tx_heartbeat_errors;
+	stats->tx_window_errors = dev->stats.tx_window_errors;
+
+	return stats;
 }
 
 static void rhine_set_rx_mode(struct net_device *dev)
-- 
1.7.12

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

* Re: [PATCH net-next] via-rhine: add 64bit statistics.
  2013-01-23 14:31 [PATCH net-next] via-rhine: add 64bit statistics Jamie Gloudon
@ 2013-01-23 14:38 ` Eric Dumazet
  2013-01-23 15:41   ` Jamie Gloudon
  0 siblings, 1 reply; 10+ messages in thread
From: Eric Dumazet @ 2013-01-23 14:38 UTC (permalink / raw)
  To: Jamie Gloudon; +Cc: netdev, davem

On Wed, 2013-01-23 at 10:31 -0400, Jamie Gloudon wrote:
> Switch to use ndo_get_stats64 to get 64bit statistics.
> 
> Signed-off-by: Jamie Gloudon <jamie.gloudon@gmail.com>
> ---

> +
> +	stats->rx_errors = dev->stats.rx_errors;
> +	stats->tx_errors = dev->stats.tx_errors;
> +	stats->rx_dropped = dev->stats.rx_dropped;
> +	stats->tx_dropped = dev->stats.tx_dropped;
> +	stats->collisions = dev->stats.collisions;
> +
> +	stats->rx_length_errors = dev->stats.rx_length_errors;
> +	stats->rx_crc_errors = dev->stats.rx_crc_errors;
> +	stats->rx_frame_errors = dev->stats.rx_frame_errors;
> +	stats->rx_fifo_errors = dev->stats.rx_fifo_errors;
> +	stats->rx_missed_errors = dev->stats.rx_missed_errors;
> +
> +	stats->tx_aborted_errors = dev->stats.tx_aborted_errors;
> +	stats->tx_carrier_errors = dev->stats.tx_carrier_errors;
> +	stats->tx_fifo_errors = dev->stats.tx_fifo_errors;
> +	stats->tx_heartbeat_errors = dev->stats.tx_heartbeat_errors;
> +	stats->tx_window_errors = dev->stats.tx_window_errors;
> +
> +	return stats;
>  }
>  

Hi Jamie

Please use netdev_stats_to_stats64() for this block

commit 77a1abf54f4b003ad6e59c535045b2ad89fedfeb
Author: Eric Dumazet <eric.dumazet@gmail.com>
Date:   Mon Mar 5 04:50:09 2012 +0000

    net: export netdev_stats_to_stats64
    
    Some drivers use internal netdev stats member to store part of their
    stats, yet advertize ndo_get_stats64() to implement some 64bit fields.
    
    Allow them to use netdev_stats_to_stats64() helper to make the copy of
    netdev stats before they compute their 64bit counters.

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

* Re: [PATCH net-next] via-rhine: add 64bit statistics.
  2013-01-23 14:38 ` Eric Dumazet
@ 2013-01-23 15:41   ` Jamie Gloudon
  2013-01-23 16:17     ` Eric Dumazet
  2013-01-23 18:25     ` David Miller
  0 siblings, 2 replies; 10+ messages in thread
From: Jamie Gloudon @ 2013-01-23 15:41 UTC (permalink / raw)
  To: netdev; +Cc: Eric Dumazet, davem

[-- Attachment #1: Type: text/plain, Size: 1761 bytes --]

On Wed, Jan 23, 2013 at 06:38:04AM -0800, Eric Dumazet wrote:
> On Wed, 2013-01-23 at 10:31 -0400, Jamie Gloudon wrote:
> > Switch to use ndo_get_stats64 to get 64bit statistics.
> > 
> > Signed-off-by: Jamie Gloudon <jamie.gloudon@gmail.com>
> > ---
> 
> > +
> > +	stats->rx_errors = dev->stats.rx_errors;
> > +	stats->tx_errors = dev->stats.tx_errors;
> > +	stats->rx_dropped = dev->stats.rx_dropped;
> > +	stats->tx_dropped = dev->stats.tx_dropped;
> > +	stats->collisions = dev->stats.collisions;
> > +
> > +	stats->rx_length_errors = dev->stats.rx_length_errors;
> > +	stats->rx_crc_errors = dev->stats.rx_crc_errors;
> > +	stats->rx_frame_errors = dev->stats.rx_frame_errors;
> > +	stats->rx_fifo_errors = dev->stats.rx_fifo_errors;
> > +	stats->rx_missed_errors = dev->stats.rx_missed_errors;
> > +
> > +	stats->tx_aborted_errors = dev->stats.tx_aborted_errors;
> > +	stats->tx_carrier_errors = dev->stats.tx_carrier_errors;
> > +	stats->tx_fifo_errors = dev->stats.tx_fifo_errors;
> > +	stats->tx_heartbeat_errors = dev->stats.tx_heartbeat_errors;
> > +	stats->tx_window_errors = dev->stats.tx_window_errors;
> > +
> > +	return stats;
> >  }
> >  
> 
> Hi Jamie
> 
> Please use netdev_stats_to_stats64() for this block
> 
> commit 77a1abf54f4b003ad6e59c535045b2ad89fedfeb
> Author: Eric Dumazet <eric.dumazet@gmail.com>
> Date:   Mon Mar 5 04:50:09 2012 +0000
> 
>     net: export netdev_stats_to_stats64
>     
>     Some drivers use internal netdev stats member to store part of their
>     stats, yet advertize ndo_get_stats64() to implement some 64bit fields.
>     
>     Allow them to use netdev_stats_to_stats64() helper to make the copy of
>     netdev stats before they compute their 64bit counters.
> 
>

Definitely looks cleaner now. Thanks!

[-- Attachment #2: 0001-via-rhine-add-64bit-statistics-v2.patch --]
[-- Type: text/plain, Size: 4400 bytes --]

Signed-off-by: Jamie Gloudon <jamie.gloudon@gmail.com>
---
 drivers/net/ethernet/via/via-rhine.c | 48 ++++++++++++++++++++++++++++++------
 1 file changed, 40 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/via/via-rhine.c b/drivers/net/ethernet/via/via-rhine.c
index eab63e1..82813ed 100644
--- a/drivers/net/ethernet/via/via-rhine.c
+++ b/drivers/net/ethernet/via/via-rhine.c
@@ -417,6 +417,12 @@ enum chip_cmd_bits {
 	Cmd1NoTxPoll=0x08, Cmd1Reset=0x80,
 };
 
+struct rhine_stats {
+	u64		packets;
+	u64		bytes;
+	struct u64_stats_sync syncp;
+};
+
 struct rhine_private {
 	/* Bit mask for configured VLAN ids */
 	unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
@@ -458,6 +464,8 @@ struct rhine_private {
 	unsigned int cur_rx, dirty_rx;	/* Producer/consumer ring indices */
 	unsigned int cur_tx, dirty_tx;
 	unsigned int rx_buf_sz;		/* Based on MTU+slack. */
+	struct rhine_stats rx_stats;
+	struct rhine_stats tx_stats;
 	u8 wolopts;
 
 	u8 tx_thresh, rx_thresh;
@@ -495,7 +503,8 @@ static irqreturn_t rhine_interrupt(int irq, void *dev_instance);
 static void rhine_tx(struct net_device *dev);
 static int rhine_rx(struct net_device *dev, int limit);
 static void rhine_set_rx_mode(struct net_device *dev);
-static struct net_device_stats *rhine_get_stats(struct net_device *dev);
+static struct rtnl_link_stats64 *rhine_get_stats64(struct net_device *dev,
+	       struct rtnl_link_stats64 *stats);
 static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
 static const struct ethtool_ops netdev_ethtool_ops;
 static int  rhine_close(struct net_device *dev);
@@ -842,7 +851,7 @@ static const struct net_device_ops rhine_netdev_ops = {
 	.ndo_open		 = rhine_open,
 	.ndo_stop		 = rhine_close,
 	.ndo_start_xmit		 = rhine_start_tx,
-	.ndo_get_stats		 = rhine_get_stats,
+	.ndo_get_stats64	 = rhine_get_stats64,
 	.ndo_set_rx_mode	 = rhine_set_rx_mode,
 	.ndo_change_mtu		 = eth_change_mtu,
 	.ndo_validate_addr	 = eth_validate_addr,
@@ -1790,8 +1799,11 @@ static void rhine_tx(struct net_device *dev)
 				dev->stats.collisions += txstatus & 0x0F;
 			netif_dbg(rp, tx_done, dev, "collisions: %1.1x:%1.1x\n",
 				  (txstatus >> 3) & 0xF, txstatus & 0xF);
-			dev->stats.tx_bytes += rp->tx_skbuff[entry]->len;
-			dev->stats.tx_packets++;
+
+			u64_stats_update_begin(&rp->tx_stats.syncp);
+			rp->tx_stats.bytes += rp->tx_skbuff[entry]->len;
+			rp->tx_stats.packets++;
+			u64_stats_update_end(&rp->tx_stats.syncp);
 		}
 		/* Free the original skb. */
 		if (rp->tx_skbuff_dma[entry]) {
@@ -1857,6 +1869,7 @@ static int rhine_rx(struct net_device *dev, int limit)
 					    "Oversized Ethernet frame %p vs %p\n",
 					    rp->rx_head_desc,
 					    &rp->rx_ring[entry]);
+				dev->stats.rx_dropped++;
 				dev->stats.rx_length_errors++;
 			} else if (desc_status & RxErr) {
 				/* There was a error. */
@@ -1923,8 +1936,11 @@ static int rhine_rx(struct net_device *dev, int limit)
 			if (unlikely(desc_length & DescTag))
 				__vlan_hwaccel_put_tag(skb, vlan_tci);
 			netif_receive_skb(skb);
-			dev->stats.rx_bytes += pkt_len;
-			dev->stats.rx_packets++;
+
+			u64_stats_update_begin(&rp->rx_stats.syncp);
+			rp->rx_stats.bytes += pkt_len;
+			rp->rx_stats.packets++;
+			u64_stats_update_end(&rp->rx_stats.syncp);
 		}
 		entry = (++rp->cur_rx) % RX_RING_SIZE;
 		rp->rx_head_desc = &rp->rx_ring[entry];
@@ -2019,15 +2035,31 @@ out_unlock:
 	mutex_unlock(&rp->task_lock);
 }
 
-static struct net_device_stats *rhine_get_stats(struct net_device *dev)
+static struct rtnl_link_stats64 *
+rhine_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats)
 {
 	struct rhine_private *rp = netdev_priv(dev);
+	unsigned int start;
 
 	spin_lock_bh(&rp->lock);
 	rhine_update_rx_crc_and_missed_errord(rp);
 	spin_unlock_bh(&rp->lock);
 
-	return &dev->stats;
+	do {
+		start = u64_stats_fetch_begin_bh(&rp->rx_stats.syncp);
+		stats->rx_packets = rp->rx_stats.packets;
+		stats->rx_bytes = rp->rx_stats.bytes;
+	} while (u64_stats_fetch_retry_bh(&rp->rx_stats.syncp, start));
+
+	do {
+		start = u64_stats_fetch_begin_bh(&rp->tx_stats.syncp);
+		stats->tx_packets = rp->tx_stats.packets;
+		stats->tx_bytes = rp->tx_stats.bytes;
+	} while (u64_stats_fetch_retry_bh(&rp->tx_stats.syncp, start));
+
+	netdev_stats_to_stats64(stats, &dev->stats);
+
+	return stats;
 }
 
 static void rhine_set_rx_mode(struct net_device *dev)
-- 
1.7.12


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

* Re: [PATCH net-next] via-rhine: add 64bit statistics.
  2013-01-23 15:41   ` Jamie Gloudon
@ 2013-01-23 16:17     ` Eric Dumazet
  2013-01-23 23:55       ` Jamie Gloudon
  2013-01-23 18:25     ` David Miller
  1 sibling, 1 reply; 10+ messages in thread
From: Eric Dumazet @ 2013-01-23 16:17 UTC (permalink / raw)
  To: Jamie Gloudon; +Cc: netdev, davem

On Wed, 2013-01-23 at 11:41 -0400, Jamie Gloudon wrote:
> On Wed, Jan 23, 2013 at 06:38:04AM -0800, Eric Dumazet wrote:
> > On Wed, 2013-01-23 at 10:31 -0400, Jamie Gloudon wrote:
> > > Switch to use ndo_get_stats64 to get 64bit statistics.
> > > 
> > > Signed-off-by: Jamie Gloudon <jamie.gloudon@gmail.com>
> > > ---
> > 
> > > +
> > > +	stats->rx_errors = dev->stats.rx_errors;
> > > +	stats->tx_errors = dev->stats.tx_errors;
> > > +	stats->rx_dropped = dev->stats.rx_dropped;
> > > +	stats->tx_dropped = dev->stats.tx_dropped;
> > > +	stats->collisions = dev->stats.collisions;
> > > +
> > > +	stats->rx_length_errors = dev->stats.rx_length_errors;
> > > +	stats->rx_crc_errors = dev->stats.rx_crc_errors;
> > > +	stats->rx_frame_errors = dev->stats.rx_frame_errors;
> > > +	stats->rx_fifo_errors = dev->stats.rx_fifo_errors;
> > > +	stats->rx_missed_errors = dev->stats.rx_missed_errors;
> > > +
> > > +	stats->tx_aborted_errors = dev->stats.tx_aborted_errors;
> > > +	stats->tx_carrier_errors = dev->stats.tx_carrier_errors;
> > > +	stats->tx_fifo_errors = dev->stats.tx_fifo_errors;
> > > +	stats->tx_heartbeat_errors = dev->stats.tx_heartbeat_errors;
> > > +	stats->tx_window_errors = dev->stats.tx_window_errors;
> > > +
> > > +	return stats;
> > >  }
> > >  
> > 
> > Hi Jamie
> > 
> > Please use netdev_stats_to_stats64() for this block
> > 
> > commit 77a1abf54f4b003ad6e59c535045b2ad89fedfeb
> > Author: Eric Dumazet <eric.dumazet@gmail.com>
> > Date:   Mon Mar 5 04:50:09 2012 +0000
> > 
> >     net: export netdev_stats_to_stats64
> >     
> >     Some drivers use internal netdev stats member to store part of their
> >     stats, yet advertize ndo_get_stats64() to implement some 64bit fields.
> >     
> >     Allow them to use netdev_stats_to_stats64() helper to make the copy of
> >     netdev stats before they compute their 64bit counters.
> > 
> >
> 
> Definitely looks cleaner now. Thanks!

Well, no ;)

Please read again the changelog I copied, and highlight the word
_before_

If you cant test the patch, please ask someone to do so.

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

* Re: [PATCH net-next] via-rhine: add 64bit statistics.
  2013-01-23 15:41   ` Jamie Gloudon
  2013-01-23 16:17     ` Eric Dumazet
@ 2013-01-23 18:25     ` David Miller
  1 sibling, 0 replies; 10+ messages in thread
From: David Miller @ 2013-01-23 18:25 UTC (permalink / raw)
  To: jamie.gloudon; +Cc: netdev, eric.dumazet


Please don't submit new versions of patchs using a reply like this,
that makes for a lot of work the subsystem maintainer has to do
to edit the reply to get the commit message to come out right.

Instead, make a fresh new patch posting on the list so that everything
comes out right and your intentions are %100 clear.

Thanks.

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

* Re: [PATCH net-next] via-rhine: add 64bit statistics.
  2013-01-23 16:17     ` Eric Dumazet
@ 2013-01-23 23:55       ` Jamie Gloudon
  2013-01-24  0:02         ` Eric Dumazet
  0 siblings, 1 reply; 10+ messages in thread
From: Jamie Gloudon @ 2013-01-23 23:55 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: netdev, davem

On Wed, Jan 23, 2013 at 08:17:18AM -0800, Eric Dumazet wrote:
> On Wed, 2013-01-23 at 11:41 -0400, Jamie Gloudon wrote:
> > On Wed, Jan 23, 2013 at 06:38:04AM -0800, Eric Dumazet wrote:
> > > On Wed, 2013-01-23 at 10:31 -0400, Jamie Gloudon wrote:
> > > > Switch to use ndo_get_stats64 to get 64bit statistics.
> > > > 
> > > > Signed-off-by: Jamie Gloudon <jamie.gloudon@gmail.com>
> > > > ---
> > > 
> > > > +
> > > > +	stats->rx_errors = dev->stats.rx_errors;
> > > > +	stats->tx_errors = dev->stats.tx_errors;
> > > > +	stats->rx_dropped = dev->stats.rx_dropped;
> > > > +	stats->tx_dropped = dev->stats.tx_dropped;
> > > > +	stats->collisions = dev->stats.collisions;
> > > > +
> > > > +	stats->rx_length_errors = dev->stats.rx_length_errors;
> > > > +	stats->rx_crc_errors = dev->stats.rx_crc_errors;
> > > > +	stats->rx_frame_errors = dev->stats.rx_frame_errors;
> > > > +	stats->rx_fifo_errors = dev->stats.rx_fifo_errors;
> > > > +	stats->rx_missed_errors = dev->stats.rx_missed_errors;
> > > > +
> > > > +	stats->tx_aborted_errors = dev->stats.tx_aborted_errors;
> > > > +	stats->tx_carrier_errors = dev->stats.tx_carrier_errors;
> > > > +	stats->tx_fifo_errors = dev->stats.tx_fifo_errors;
> > > > +	stats->tx_heartbeat_errors = dev->stats.tx_heartbeat_errors;
> > > > +	stats->tx_window_errors = dev->stats.tx_window_errors;
> > > > +
> > > > +	return stats;
> > > >  }
> > > >  
> > > 
> > > Hi Jamie
> > > 
> > > Please use netdev_stats_to_stats64() for this block
> > > 
> > > commit 77a1abf54f4b003ad6e59c535045b2ad89fedfeb
> > > Author: Eric Dumazet <eric.dumazet@gmail.com>
> > > Date:   Mon Mar 5 04:50:09 2012 +0000
> > > 
> > >     net: export netdev_stats_to_stats64
> > >     
> > >     Some drivers use internal netdev stats member to store part of their
> > >     stats, yet advertize ndo_get_stats64() to implement some 64bit fields.
> > >     
> > >     Allow them to use netdev_stats_to_stats64() helper to make the copy of
> > >     netdev stats before they compute their 64bit counters.
> > > 
> > >
> > 
> > Definitely looks cleaner now. Thanks!
> 
> Well, no ;)
> 
> Please read again the changelog I copied, and highlight the word
> _before_
> 
> If you cant test the patch, please ask someone to do so.
> 
> 
>

Eric, do you mean like this below? If not, please illustrate.

+       netdev_stats_to_stats64(stats, &dev->stats);
+
+       do {
+               start = u64_stats_fetch_begin_bh(&rp->rx_stats.syncp);
+               stats->rx_packets = rp->rx_stats.packets;
+               stats->rx_bytes = rp->rx_stats.bytes;
+       } while (u64_stats_fetch_retry_bh(&rp->rx_stats.syncp, start));
+
+       do {
+               start = u64_stats_fetch_begin_bh(&rp->tx_stats.syncp);
+               stats->tx_packets = rp->tx_stats.packets;
+               stats->tx_bytes = rp->tx_stats.bytes;
+       } while (u64_stats_fetch_retry_bh(&rp->tx_stats.syncp, start));
+
+       return stats;

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

* Re: [PATCH net-next] via-rhine: add 64bit statistics.
  2013-01-23 23:55       ` Jamie Gloudon
@ 2013-01-24  0:02         ` Eric Dumazet
  2013-01-24  0:20           ` Jamie Gloudon
  0 siblings, 1 reply; 10+ messages in thread
From: Eric Dumazet @ 2013-01-24  0:02 UTC (permalink / raw)
  To: Jamie Gloudon; +Cc: netdev, davem

On Wed, 2013-01-23 at 19:55 -0400, Jamie Gloudon wrote:

> Eric, do you mean like this below? If not, please illustrate.
> 
> +       netdev_stats_to_stats64(stats, &dev->stats);
> +
> +       do {
> +               start = u64_stats_fetch_begin_bh(&rp->rx_stats.syncp);
> +               stats->rx_packets = rp->rx_stats.packets;
> +               stats->rx_bytes = rp->rx_stats.bytes;
> +       } while (u64_stats_fetch_retry_bh(&rp->rx_stats.syncp, start));
> +
> +       do {
> +               start = u64_stats_fetch_begin_bh(&rp->tx_stats.syncp);
> +               stats->tx_packets = rp->tx_stats.packets;
> +               stats->tx_bytes = rp->tx_stats.bytes;
> +       } while (u64_stats_fetch_retry_bh(&rp->tx_stats.syncp, start));
> +
> +       return stats;
> 

Yes, this is exactly how you should do that, since
netdev_stats_to_stats64(stats, &dev->stats); would overwrite
{tr}x_packets, {tr}x_bytes anyway.

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

* Re: [PATCH net-next] via-rhine: add 64bit statistics.
  2013-01-24  0:02         ` Eric Dumazet
@ 2013-01-24  0:20           ` Jamie Gloudon
  2013-01-24  0:27             ` Eric Dumazet
  0 siblings, 1 reply; 10+ messages in thread
From: Jamie Gloudon @ 2013-01-24  0:20 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: netdev, davem

On Wed, Jan 23, 2013 at 04:02:52PM -0800, Eric Dumazet wrote:
> On Wed, 2013-01-23 at 19:55 -0400, Jamie Gloudon wrote:
> 
> > Eric, do you mean like this below? If not, please illustrate.
> > 
> > +       netdev_stats_to_stats64(stats, &dev->stats);
> > +
> > +       do {
> > +               start = u64_stats_fetch_begin_bh(&rp->rx_stats.syncp);
> > +               stats->rx_packets = rp->rx_stats.packets;
> > +               stats->rx_bytes = rp->rx_stats.bytes;
> > +       } while (u64_stats_fetch_retry_bh(&rp->rx_stats.syncp, start));
> > +
> > +       do {
> > +               start = u64_stats_fetch_begin_bh(&rp->tx_stats.syncp);
> > +               stats->tx_packets = rp->tx_stats.packets;
> > +               stats->tx_bytes = rp->tx_stats.bytes;
> > +       } while (u64_stats_fetch_retry_bh(&rp->tx_stats.syncp, start));
> > +
> > +       return stats;
> > 
> 
> Yes, this is exactly how you should do that, since
> netdev_stats_to_stats64(stats, &dev->stats); would overwrite
> {tr}x_packets, {tr}x_bytes anyway.
> 
>

Right. Also, I added rx_dropped to increment for oversize ethernet. Is
that valid?

@@ -1857,6 +1869,7 @@ static int rhine_rx(struct net_device *dev, int
limit)
	"Oversized Ethernet frame %p vs %p\n", rp->rx_head_desc,                        	&rp->rx_ring[entry]);
+	dev->stats.rx_dropped++;
	dev->stats.rx_length_errors++;

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

* Re: [PATCH net-next] via-rhine: add 64bit statistics.
  2013-01-24  0:20           ` Jamie Gloudon
@ 2013-01-24  0:27             ` Eric Dumazet
  2013-01-24  0:34               ` Jamie Gloudon
  0 siblings, 1 reply; 10+ messages in thread
From: Eric Dumazet @ 2013-01-24  0:27 UTC (permalink / raw)
  To: Jamie Gloudon; +Cc: netdev, davem

On Wed, 2013-01-23 at 20:20 -0400, Jamie Gloudon wrote:

> Right. Also, I added rx_dropped to increment for oversize ethernet. Is
> that valid?
> 
> @@ -1857,6 +1869,7 @@ static int rhine_rx(struct net_device *dev, int
> limit)
> 	"Oversized Ethernet frame %p vs %p\n", rp->rx_head_desc,                        	&rp->rx_ring[entry]);
> +	dev->stats.rx_dropped++;
> 	dev->stats.rx_length_errors++;

Take other drivers as reference

git grep -n2 rx_length_errors -- drivers/net

Most of them dont do that (they are more likely increasing rx_errors)

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

* Re: [PATCH net-next] via-rhine: add 64bit statistics.
  2013-01-24  0:27             ` Eric Dumazet
@ 2013-01-24  0:34               ` Jamie Gloudon
  0 siblings, 0 replies; 10+ messages in thread
From: Jamie Gloudon @ 2013-01-24  0:34 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: netdev, davem

On Wed, Jan 23, 2013 at 04:27:42PM -0800, Eric Dumazet wrote:
> On Wed, 2013-01-23 at 20:20 -0400, Jamie Gloudon wrote:
> 
> > Right. Also, I added rx_dropped to increment for oversize ethernet. Is
> > that valid?
> > 
> > @@ -1857,6 +1869,7 @@ static int rhine_rx(struct net_device *dev, int
> > limit)
> > 	"Oversized Ethernet frame %p vs %p\n", rp->rx_head_desc,                        	&rp->rx_ring[entry]);
> > +	dev->stats.rx_dropped++;
> > 	dev->stats.rx_length_errors++;
> 
> Take other drivers as reference
> 
> git grep -n2 rx_length_errors -- drivers/net
> 
> Most of them dont do that (they are more likely increasing rx_errors)
> 
>

Alright then, I will remove that line and queue up another patch for submission.
Thanks for the feedback!

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

end of thread, other threads:[~2013-01-24  0:34 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-23 14:31 [PATCH net-next] via-rhine: add 64bit statistics Jamie Gloudon
2013-01-23 14:38 ` Eric Dumazet
2013-01-23 15:41   ` Jamie Gloudon
2013-01-23 16:17     ` Eric Dumazet
2013-01-23 23:55       ` Jamie Gloudon
2013-01-24  0:02         ` Eric Dumazet
2013-01-24  0:20           ` Jamie Gloudon
2013-01-24  0:27             ` Eric Dumazet
2013-01-24  0:34               ` Jamie Gloudon
2013-01-23 18:25     ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.