netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paulius Zaleckas <paulius.zaleckas@teltonika.lt>
To: netdev@vger.kernel.org
Subject: [PATCH] amd8111e: use netstats in net_device structure
Date: Tue, 06 May 2008 00:46:43 +0300	[thread overview]
Message-ID: <fvnv83$lke$1@ger.gmane.org> (raw)

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

Use net_device_stats from net_device structure instead of local.

Signed-off-by: Paulius Zaleckas <paulius.zaleckas@teltonika.lt>

[-- Attachment #2: amd8111e_netstats.patch --]
[-- Type: text/x-patch, Size: 4969 bytes --]

diff --git a/drivers/net/amd8111e.c b/drivers/net/amd8111e.c
index 85f7276..b61d059 100644
--- a/drivers/net/amd8111e.c
+++ b/drivers/net/amd8111e.c
@@ -1022,30 +1022,28 @@ static struct net_device_stats *amd8111e_get_stats(struct net_device * dev)
 	struct amd8111e_priv *lp = netdev_priv(dev);
 	void __iomem *mmio = lp->mmio;
 	unsigned long flags;
-	/* struct net_device_stats *prev_stats = &lp->prev_stats; */
-	struct net_device_stats* new_stats = &lp->stats;
 
 	if(!lp->opened)
-		return &lp->stats;
+		return &dev->stats;
 	spin_lock_irqsave (&lp->lock, flags);
 
 	/* stats.rx_packets */
-	new_stats->rx_packets = amd8111e_read_mib(mmio, rcv_broadcast_pkts)+
+	dev->stats.rx_packets = amd8111e_read_mib(mmio, rcv_broadcast_pkts)+
 				amd8111e_read_mib(mmio, rcv_multicast_pkts)+
 				amd8111e_read_mib(mmio, rcv_unicast_pkts);
 
 	/* stats.tx_packets */
-	new_stats->tx_packets = amd8111e_read_mib(mmio, xmt_packets);
+	dev->stats.tx_packets = amd8111e_read_mib(mmio, xmt_packets);
 
 	/*stats.rx_bytes */
-	new_stats->rx_bytes = amd8111e_read_mib(mmio, rcv_octets);
+	dev->stats.rx_bytes = amd8111e_read_mib(mmio, rcv_octets);
 
 	/* stats.tx_bytes */
-	new_stats->tx_bytes = amd8111e_read_mib(mmio, xmt_octets);
+	dev->stats.tx_bytes = amd8111e_read_mib(mmio, xmt_octets);
 
 	/* stats.rx_errors */
 	/* hw errors + errors driver reported */
-	new_stats->rx_errors = amd8111e_read_mib(mmio, rcv_undersize_pkts)+
+	dev->stats.rx_errors = amd8111e_read_mib(mmio, rcv_undersize_pkts)+
 				amd8111e_read_mib(mmio, rcv_fragments)+
 				amd8111e_read_mib(mmio, rcv_jabbers)+
 				amd8111e_read_mib(mmio, rcv_alignment_errors)+
@@ -1054,54 +1052,54 @@ static struct net_device_stats *amd8111e_get_stats(struct net_device * dev)
 				lp->drv_rx_errors;
 
 	/* stats.tx_errors */
-	new_stats->tx_errors = amd8111e_read_mib(mmio, xmt_underrun_pkts);
+	dev->stats.tx_errors = amd8111e_read_mib(mmio, xmt_underrun_pkts);
 
 	/* stats.rx_dropped*/
-	new_stats->rx_dropped = amd8111e_read_mib(mmio, rcv_miss_pkts);
+	dev->stats.rx_dropped = amd8111e_read_mib(mmio, rcv_miss_pkts);
 
 	/* stats.tx_dropped*/
-	new_stats->tx_dropped = amd8111e_read_mib(mmio,  xmt_underrun_pkts);
+	dev->stats.tx_dropped = amd8111e_read_mib(mmio,  xmt_underrun_pkts);
 
 	/* stats.multicast*/
-	new_stats->multicast = amd8111e_read_mib(mmio, rcv_multicast_pkts);
+	dev->stats.multicast = amd8111e_read_mib(mmio, rcv_multicast_pkts);
 
 	/* stats.collisions*/
-	new_stats->collisions = amd8111e_read_mib(mmio, xmt_collisions);
+	dev->stats.collisions = amd8111e_read_mib(mmio, xmt_collisions);
 
 	/* stats.rx_length_errors*/
-	new_stats->rx_length_errors =
+	dev->stats.rx_length_errors =
 		amd8111e_read_mib(mmio, rcv_undersize_pkts)+
 		amd8111e_read_mib(mmio, rcv_oversize_pkts);
 
 	/* stats.rx_over_errors*/
-	new_stats->rx_over_errors = amd8111e_read_mib(mmio, rcv_miss_pkts);
+	dev->stats.rx_over_errors = amd8111e_read_mib(mmio, rcv_miss_pkts);
 
 	/* stats.rx_crc_errors*/
-	new_stats->rx_crc_errors = amd8111e_read_mib(mmio, rcv_fcs_errors);
+	dev->stats.rx_crc_errors = amd8111e_read_mib(mmio, rcv_fcs_errors);
 
 	/* stats.rx_frame_errors*/
-	new_stats->rx_frame_errors =
+	dev->stats.rx_frame_errors =
 		amd8111e_read_mib(mmio, rcv_alignment_errors);
 
 	/* stats.rx_fifo_errors */
-	new_stats->rx_fifo_errors = amd8111e_read_mib(mmio, rcv_miss_pkts);
+	dev->stats.rx_fifo_errors = amd8111e_read_mib(mmio, rcv_miss_pkts);
 
 	/* stats.rx_missed_errors */
-	new_stats->rx_missed_errors = amd8111e_read_mib(mmio, rcv_miss_pkts);
+	dev->stats.rx_missed_errors = amd8111e_read_mib(mmio, rcv_miss_pkts);
 
 	/* stats.tx_aborted_errors*/
-	new_stats->tx_aborted_errors =
+	dev->stats.tx_aborted_errors =
 		amd8111e_read_mib(mmio, xmt_excessive_collision);
 
 	/* stats.tx_carrier_errors*/
-	new_stats->tx_carrier_errors =
+	dev->stats.tx_carrier_errors =
 		amd8111e_read_mib(mmio, xmt_loss_carrier);
 
 	/* stats.tx_fifo_errors*/
-	new_stats->tx_fifo_errors = amd8111e_read_mib(mmio, xmt_underrun_pkts);
+	dev->stats.tx_fifo_errors = amd8111e_read_mib(mmio, xmt_underrun_pkts);
 
 	/* stats.tx_window_errors*/
-	new_stats->tx_window_errors =
+	dev->stats.tx_window_errors =
 		amd8111e_read_mib(mmio, xmt_late_collision);
 
 	/* Reset the mibs for collecting new statistics */
@@ -1109,7 +1107,7 @@ static struct net_device_stats *amd8111e_get_stats(struct net_device * dev)
 
 	spin_unlock_irqrestore (&lp->lock, flags);
 
-	return new_stats;
+	return &dev->stats;
 }
 /* This function recalculate the interrupt coalescing  mode on every interrupt
 according to the datarate and the packet rate.
diff --git a/drivers/net/amd8111e.h b/drivers/net/amd8111e.h
index 28c60a7..5027759 100644
--- a/drivers/net/amd8111e.h
+++ b/drivers/net/amd8111e.h
@@ -787,7 +787,6 @@ struct amd8111e_priv{
 	struct vlan_group		*vlgrp;
 #endif
 	char opened;
-	struct net_device_stats stats;
 	unsigned int drv_rx_errors;
 	struct dev_mc_list* mc_list;
 	struct amd8111e_coalesce_conf coal_conf;

                 reply	other threads:[~2008-05-05 21:46 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='fvnv83$lke$1@ger.gmane.org' \
    --to=paulius.zaleckas@teltonika.lt \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).