netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] am79c961a: use netstats in net_device structure
@ 2008-05-05 21:28 Paulius Zaleckas
  2008-05-07 21:30 ` Russell King - ARM Linux
  0 siblings, 1 reply; 2+ messages in thread
From: Paulius Zaleckas @ 2008-05-05 21:28 UTC (permalink / raw)
  To: netdev; +Cc: linux-arm-kernel, netdev

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

Use net_device_stats from net_device structure instead of local.
Kill am79c961_getstats function, because by default it is used
identical internal_stats function from net/core/dev.c
Don't clear statistics when opening device.

Haven't tried to compile it. Need ack from ARM people!

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

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

diff --git a/drivers/net/arm/am79c961a.c b/drivers/net/arm/am79c961a.c
index a637910..d5ec2fc 100644
--- a/drivers/net/arm/am79c961a.c
+++ b/drivers/net/arm/am79c961a.c
@@ -300,8 +300,6 @@ am79c961_open(struct net_device *dev)
 	struct dev_priv *priv = netdev_priv(dev);
 	int ret;
 
-	memset (&priv->stats, 0, sizeof (priv->stats));
-
 	ret = request_irq(dev->irq, am79c961_interrupt, 0, dev->name, dev);
 	if (ret)
 		return ret;
@@ -342,15 +340,6 @@ am79c961_close(struct net_device *dev)
 	return 0;
 }
 
-/*
- * Get the current statistics.
- */
-static struct net_device_stats *am79c961_getstats (struct net_device *dev)
-{
-	struct dev_priv *priv = netdev_priv(dev);
-	return &priv->stats;
-}
-
 static void am79c961_mc_hash(struct dev_mc_list *dmi, unsigned short *hash)
 {
 	if (dmi->dmi_addrlen == ETH_ALEN && dmi->dmi_addr[0] & 0x01) {
@@ -511,14 +500,14 @@ am79c961_rx(struct net_device *dev, struct dev_priv *priv)
 
 		if ((status & (RMD_ERR|RMD_STP|RMD_ENP)) != (RMD_STP|RMD_ENP)) {
 			am_writeword (dev, hdraddr + 2, RMD_OWN);
-			priv->stats.rx_errors ++;
+			dev->stats.rx_errors ++;
 			if (status & RMD_ERR) {
 				if (status & RMD_FRAM)
-					priv->stats.rx_frame_errors ++;
+					dev->stats.rx_frame_errors ++;
 				if (status & RMD_CRC)
-					priv->stats.rx_crc_errors ++;
+					dev->stats.rx_crc_errors ++;
 			} else if (status & RMD_STP)
-				priv->stats.rx_length_errors ++;
+				dev->stats.rx_length_errors ++;
 			continue;
 		}
 
@@ -533,12 +522,12 @@ am79c961_rx(struct net_device *dev, struct dev_priv *priv)
 			skb->protocol = eth_type_trans(skb, dev);
 			netif_rx(skb);
 			dev->last_rx = jiffies;
-			priv->stats.rx_bytes += len;
-			priv->stats.rx_packets ++;
+			dev->stats.rx_bytes += len;
+			dev->stats.rx_packets ++;
 		} else {
 			am_writeword (dev, hdraddr + 2, RMD_OWN);
 			printk (KERN_WARNING "%s: memory squeeze, dropping packet.\n", dev->name);
-			priv->stats.rx_dropped ++;
+			dev->stats.rx_dropped ++;
 			break;
 		}
 	} while (1);
@@ -567,7 +556,7 @@ am79c961_tx(struct net_device *dev, struct dev_priv *priv)
 		if (status & TMD_ERR) {
 			u_int status2;
 
-			priv->stats.tx_errors ++;
+			dev->stats.tx_errors ++;
 
 			status2 = am_readword (dev, hdraddr + 6);
 
@@ -577,18 +566,18 @@ am79c961_tx(struct net_device *dev, struct dev_priv *priv)
 			am_writeword (dev, hdraddr + 6, 0);
 
 			if (status2 & TST_RTRY)
-				priv->stats.collisions += 16;
+				dev->stats.collisions += 16;
 			if (status2 & TST_LCOL)
-				priv->stats.tx_window_errors ++;
+				dev->stats.tx_window_errors ++;
 			if (status2 & TST_LCAR)
-				priv->stats.tx_carrier_errors ++;
+				dev->stats.tx_carrier_errors ++;
 			if (status2 & TST_UFLO)
-				priv->stats.tx_fifo_errors ++;
+				dev->stats.tx_fifo_errors ++;
 			continue;
 		}
-		priv->stats.tx_packets ++;
+		dev->stats.tx_packets ++;
 		len = am_readword (dev, hdraddr + 4);
-		priv->stats.tx_bytes += -len;
+		dev->stats.tx_bytes += -len;
 	} while (priv->txtail != priv->txhead);
 
 	netif_wake_queue(dev);
@@ -618,7 +607,7 @@ am79c961_interrupt(int irq, void *dev_id)
 		}
 		if (status & CSR0_MISS) {
 			handled = 1;
-			priv->stats.rx_dropped ++;
+			dev->stats.rx_dropped ++;
 		}
 		if (status & CSR0_CERR) {
 			handled = 1;
@@ -736,7 +725,6 @@ static int __init am79c961_probe(struct platform_device *pdev)
 	dev->open		= am79c961_open;
 	dev->stop		= am79c961_close;
 	dev->hard_start_xmit	= am79c961_sendpacket;
-	dev->get_stats		= am79c961_getstats;
 	dev->set_multicast_list	= am79c961_setmulticastlist;
 	dev->tx_timeout		= am79c961_timeout;
 #ifdef CONFIG_NET_POLL_CONTROLLER
diff --git a/drivers/net/arm/am79c961a.h b/drivers/net/arm/am79c961a.h
index 483009f..fd634d3 100644
--- a/drivers/net/arm/am79c961a.h
+++ b/drivers/net/arm/am79c961a.h
@@ -130,7 +130,6 @@
 #define ISALED0_LNKST	0x8000
 
 struct dev_priv {
-    struct net_device_stats stats;
     unsigned long	rxbuffer[RX_BUFFERS];
     unsigned long	txbuffer[TX_BUFFERS];
     unsigned char	txhead;

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

* Re: [PATCH] am79c961a: use netstats in net_device structure
  2008-05-05 21:28 [PATCH] am79c961a: use netstats in net_device structure Paulius Zaleckas
@ 2008-05-07 21:30 ` Russell King - ARM Linux
  0 siblings, 0 replies; 2+ messages in thread
From: Russell King - ARM Linux @ 2008-05-07 21:30 UTC (permalink / raw)
  To: Paulius Zaleckas; +Cc: linux-arm-kernel, netdev

On Tue, May 06, 2008 at 12:28:52AM +0300, Paulius Zaleckas wrote:
> Use net_device_stats from net_device structure instead of local.
> Kill am79c961_getstats function, because by default it is used
> identical internal_stats function from net/core/dev.c
> Don't clear statistics when opening device.
> 
> Haven't tried to compile it. Need ack from ARM people!
> 
> Signed-off-by: Paulius Zaleckas <paulius.zaleckas@teltonika.lt>

Acked-by: Russell King <rmk+kernel@arm.linux.org.uk>

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

end of thread, other threads:[~2008-05-07 21:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-05 21:28 [PATCH] am79c961a: use netstats in net_device structure Paulius Zaleckas
2008-05-07 21:30 ` Russell King - ARM Linux

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