netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [Patch 1/1 net-next] S2io: fix statistics flush after a MTU change
@ 2008-07-22 19:27 Breno Leitao
  2008-07-24 17:45 ` Ramkrishna Vepa
  2008-07-29 22:25 ` Jeff Garzik
  0 siblings, 2 replies; 3+ messages in thread
From: Breno Leitao @ 2008-07-22 19:27 UTC (permalink / raw)
  To: netdev
  Cc: jeff, ram.vepa, santosh.rastapur, sivakumar.subramani,
	sreenivasa.honnur, Jay Vosburgh

On s2io driver, when you change the interface MTU, it invokes a card
reset, which flush some statistics.  This patch solves this problem, and
also set the net_device->stats as the default statistics structure,
instead of s2io_nic->stats.

To do that, s2io_nic->stats turned into a staging area, where is saved
statistics of the last hardware statistics query. So, the difference
between the current hardware statistics and s2io_nic->stats, is the
value that should be summed up, in order to get the correct statistics
value, even after a reset.

Signed-off-by: Breno Leitao <leitao@linux.vnet.ibm.com>
Signed-off-by: Jay Vosburgh <fubar@us.ibm.com>

----

diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c
index 9dae40c..f92108e 100644
--- a/drivers/net/s2io.c
+++ b/drivers/net/s2io.c
@@ -3139,7 +3139,7 @@ static void tx_intr_handler(struct fifo_info *fifo_data)
 		pkt_cnt++;
 
 		/* Updating the statistics block */
-		nic->stats.tx_bytes += skb->len;
+		nic->dev->stats.tx_bytes += skb->len;
 		nic->mac_control.stats_info->sw_stat.mem_freed += skb->truesize;
 		dev_kfree_skb_irq(skb);
 
@@ -4892,25 +4892,42 @@ static struct net_device_stats *s2io_get_stats(struct net_device *dev)
 	/* Configure Stats for immediate updt */
 	s2io_updt_stats(sp);
 
+	/* Using sp->stats as a staging area, because reset (due to mtu
+	   change, for example) will clear some hardware counters */
+	dev->stats.tx_packets +=
+		le32_to_cpu(mac_control->stats_info->tmac_frms) - 
+		sp->stats.tx_packets;
 	sp->stats.tx_packets =
 		le32_to_cpu(mac_control->stats_info->tmac_frms);
+	dev->stats.tx_errors +=
+		le32_to_cpu(mac_control->stats_info->tmac_any_err_frms) -
+		sp->stats.tx_errors;
 	sp->stats.tx_errors =
 		le32_to_cpu(mac_control->stats_info->tmac_any_err_frms);
+	dev->stats.rx_errors +=
+		le64_to_cpu(mac_control->stats_info->rmac_drop_frms) -
+		sp->stats.rx_errors;
 	sp->stats.rx_errors =
 		le64_to_cpu(mac_control->stats_info->rmac_drop_frms);
+	dev->stats.multicast =
+		le32_to_cpu(mac_control->stats_info->rmac_vld_mcst_frms) - 
+		sp->stats.multicast;
 	sp->stats.multicast =
 		le32_to_cpu(mac_control->stats_info->rmac_vld_mcst_frms);
+	dev->stats.rx_length_errors =
+		le64_to_cpu(mac_control->stats_info->rmac_long_frms) - 
+		sp->stats.rx_length_errors;
 	sp->stats.rx_length_errors =
 		le64_to_cpu(mac_control->stats_info->rmac_long_frms);
 
 	/* collect per-ring rx_packets and rx_bytes */
-	sp->stats.rx_packets = sp->stats.rx_bytes = 0;
+	dev->stats.rx_packets = dev->stats.rx_bytes = 0;
 	for (i = 0; i < config->rx_ring_num; i++) {
-		sp->stats.rx_packets += mac_control->rings[i].rx_packets;
-		sp->stats.rx_bytes += mac_control->rings[i].rx_bytes;
+		dev->stats.rx_packets += mac_control->rings[i].rx_packets;
+		dev->stats.rx_bytes += mac_control->rings[i].rx_bytes;
 	}
 
-	return (&sp->stats);
+	return (&dev->stats);
 }
 
 /**
@@ -7413,7 +7430,7 @@ static int rx_osm_handler(struct ring_info *ring_data, struct RxD_t * rxdp)
 		if (err_mask != 0x5) {
 			DBG_PRINT(ERR_DBG, "%s: Rx error Value: 0x%x\n",
 				dev->name, err_mask);
-			sp->stats.rx_crc_errors++;
+			dev->stats.rx_crc_errors++;
 			sp->mac_control.stats_info->sw_stat.mem_freed
 				+= skb->truesize;
 			dev_kfree_skb(skb);

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

* RE: [Patch 1/1 net-next] S2io: fix statistics flush after a MTU change
  2008-07-22 19:27 [Patch 1/1 net-next] S2io: fix statistics flush after a MTU change Breno Leitao
@ 2008-07-24 17:45 ` Ramkrishna Vepa
  2008-07-29 22:25 ` Jeff Garzik
  1 sibling, 0 replies; 3+ messages in thread
From: Ramkrishna Vepa @ 2008-07-24 17:45 UTC (permalink / raw)
  To: jeff, Breno Leitao, netdev
  Cc: Rastapur Santosh, Sivakumar Subramani, Sreenivasa Honnur,
	Jay Vosburgh

Jeff,

The patch looks good. Please accept.

Thanks,
Ram

> -----Original Message-----
> From: Breno Leitao [mailto:leitao@linux.vnet.ibm.com]
> Sent: Tuesday, July 22, 2008 12:27 PM
> To: netdev@vger.kernel.org
> Cc: jeff@garzik.org; ram.vepa@neterion.com; Rastapur Santosh;
Sivakumar
> Subramani; Sreenivasa Honnur; Jay Vosburgh
> Subject: [Patch 1/1 net-next] S2io: fix statistics flush after a MTU
> change
> 
> On s2io driver, when you change the interface MTU, it invokes a card
> reset, which flush some statistics.  This patch solves this problem,
and
> also set the net_device->stats as the default statistics structure,
> instead of s2io_nic->stats.
> 
> To do that, s2io_nic->stats turned into a staging area, where is saved
> statistics of the last hardware statistics query. So, the difference
> between the current hardware statistics and s2io_nic->stats, is the
> value that should be summed up, in order to get the correct statistics
> value, even after a reset.
> 
> Signed-off-by: Breno Leitao <leitao@linux.vnet.ibm.com>
> Signed-off-by: Jay Vosburgh <fubar@us.ibm.com>
> 
> ----
> 
> diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c
> index 9dae40c..f92108e 100644
> --- a/drivers/net/s2io.c
> +++ b/drivers/net/s2io.c
> @@ -3139,7 +3139,7 @@ static void tx_intr_handler(struct fifo_info
> *fifo_data)
>  		pkt_cnt++;
> 
>  		/* Updating the statistics block */
> -		nic->stats.tx_bytes += skb->len;
> +		nic->dev->stats.tx_bytes += skb->len;
>  		nic->mac_control.stats_info->sw_stat.mem_freed += skb-
> >truesize;
>  		dev_kfree_skb_irq(skb);
> 
> @@ -4892,25 +4892,42 @@ static struct net_device_stats
> *s2io_get_stats(struct net_device *dev)
>  	/* Configure Stats for immediate updt */
>  	s2io_updt_stats(sp);
> 
> +	/* Using sp->stats as a staging area, because reset (due to mtu
> +	   change, for example) will clear some hardware counters */
> +	dev->stats.tx_packets +=
> +		le32_to_cpu(mac_control->stats_info->tmac_frms) -
> +		sp->stats.tx_packets;
>  	sp->stats.tx_packets =
>  		le32_to_cpu(mac_control->stats_info->tmac_frms);
> +	dev->stats.tx_errors +=
> +		le32_to_cpu(mac_control->stats_info->tmac_any_err_frms)
-
> +		sp->stats.tx_errors;
>  	sp->stats.tx_errors =
>  		le32_to_cpu(mac_control->stats_info->tmac_any_err_frms);
> +	dev->stats.rx_errors +=
> +		le64_to_cpu(mac_control->stats_info->rmac_drop_frms) -
> +		sp->stats.rx_errors;
>  	sp->stats.rx_errors =
>  		le64_to_cpu(mac_control->stats_info->rmac_drop_frms);
> +	dev->stats.multicast =
> +		le32_to_cpu(mac_control->stats_info->rmac_vld_mcst_frms)
-
> +		sp->stats.multicast;
>  	sp->stats.multicast =
>
le32_to_cpu(mac_control->stats_info->rmac_vld_mcst_frms);
> +	dev->stats.rx_length_errors =
> +		le64_to_cpu(mac_control->stats_info->rmac_long_frms) -
> +		sp->stats.rx_length_errors;
>  	sp->stats.rx_length_errors =
>  		le64_to_cpu(mac_control->stats_info->rmac_long_frms);
> 
>  	/* collect per-ring rx_packets and rx_bytes */
> -	sp->stats.rx_packets = sp->stats.rx_bytes = 0;
> +	dev->stats.rx_packets = dev->stats.rx_bytes = 0;
>  	for (i = 0; i < config->rx_ring_num; i++) {
> -		sp->stats.rx_packets +=
mac_control->rings[i].rx_packets;
> -		sp->stats.rx_bytes += mac_control->rings[i].rx_bytes;
> +		dev->stats.rx_packets +=
mac_control->rings[i].rx_packets;
> +		dev->stats.rx_bytes += mac_control->rings[i].rx_bytes;
>  	}
> 
> -	return (&sp->stats);
> +	return (&dev->stats);
>  }
> 
>  /**
> @@ -7413,7 +7430,7 @@ static int rx_osm_handler(struct ring_info
> *ring_data, struct RxD_t * rxdp)
>  		if (err_mask != 0x5) {
>  			DBG_PRINT(ERR_DBG, "%s: Rx error Value: 0x%x\n",
>  				dev->name, err_mask);
> -			sp->stats.rx_crc_errors++;
> +			dev->stats.rx_crc_errors++;
>  			sp->mac_control.stats_info->sw_stat.mem_freed
>  				+= skb->truesize;
>  			dev_kfree_skb(skb);

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

* Re: [Patch 1/1 net-next] S2io: fix statistics flush after a MTU change
  2008-07-22 19:27 [Patch 1/1 net-next] S2io: fix statistics flush after a MTU change Breno Leitao
  2008-07-24 17:45 ` Ramkrishna Vepa
@ 2008-07-29 22:25 ` Jeff Garzik
  1 sibling, 0 replies; 3+ messages in thread
From: Jeff Garzik @ 2008-07-29 22:25 UTC (permalink / raw)
  To: Breno Leitao
  Cc: netdev, ram.vepa, santosh.rastapur, sivakumar.subramani,
	sreenivasa.honnur, Jay Vosburgh

Breno Leitao wrote:
> On s2io driver, when you change the interface MTU, it invokes a card
> reset, which flush some statistics.  This patch solves this problem, and
> also set the net_device->stats as the default statistics structure,
> instead of s2io_nic->stats.
> 
> To do that, s2io_nic->stats turned into a staging area, where is saved
> statistics of the last hardware statistics query. So, the difference
> between the current hardware statistics and s2io_nic->stats, is the
> value that should be summed up, in order to get the correct statistics
> value, even after a reset.
> 
> Signed-off-by: Breno Leitao <leitao@linux.vnet.ibm.com>
> Signed-off-by: Jay Vosburgh <fubar@us.ibm.com>

applied



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

end of thread, other threads:[~2008-07-29 22:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-22 19:27 [Patch 1/1 net-next] S2io: fix statistics flush after a MTU change Breno Leitao
2008-07-24 17:45 ` Ramkrishna Vepa
2008-07-29 22:25 ` Jeff Garzik

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).