Skip to contentSkip to conversation

drivers/net/pcmcia/3c574_cs: fixing stats.tx_bytes counter

PATCH Applied Alexander Kurz 3 participants 3 messages Mar 31, 2010 – Apr 21, 2010

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers/net/pcmcia/3c574_cs: fixing stats.tx_bytes counter

Hello folks,
while playing with an old "Megahertz 574B" card I noticed, that the netstat TX bytes where badly wrong. So I looked at drivers/net/pcmcia/3c574_cs and the method to update stats.tx_bytes. Since the 3c589_cs code is quite similar I checked if the method to update the counter from there (in dev->hard_start_xmit) produces correct results, and it did.
Unfortunately the differences between 3c589_cs and 3c574_cs concerning stats.tx_bytes are older than v2.6.11 and thus out of my git-focus. I would like to check this, but I don't know how, thanks,

Alexander Kurz

So, here is my patch:
From bbe9796e5f8835db3a3b0e80d4daadbb85b00802 Mon Sep 17 00:00:00 2001
From: Alexander Kurz <[email protected]>
Date: Wed, 31 Mar 2010 17:33:25 +0200
Subject: [PATCH] drivers/net/pcmcia/3c574_cs: fixing stats.tx_bytes counter
like done in 3c589_cs. The counter had incorrect contents
on tests using a "Megahertz 574B" card.

---
 drivers/net/pcmcia/3c574_cs.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
drivers/net/pcmcia/3c574_cs.c +5 -2
index 3d1d3a7..757f87b 100644
@@ -781,8 +781,13 @@ static netdev_tx_t el3_start_xmit(struct sk_buff *skb,
 		  inw(ioaddr + EL3_STATUS));
 
 	spin_lock_irqsave(&lp->window_lock, flags);
+
+	dev->stats.tx_bytes += skb->len;
+
+	/* Put out the doubleword header... */
 	outw(skb->len, ioaddr + TX_FIFO);
 	outw(0, ioaddr + TX_FIFO);
+	/* ... and the packet rounded to a doubleword. */
 	outsl(ioaddr + TX_FIFO, skb->data, (skb->len+3)>>2);
 
 	dev->trans_start = jiffies;
@@ -1021,8 +1026,6 @@ static void update_stats(struct net_device *dev)
 	/* BadSSD */				   inb(ioaddr + 12);
 	up					 = inb(ioaddr + 13);
 
-	dev->stats.tx_bytes 			+= tx + ((up & 0xf0) << 12);
-
 	EL3WINDOW(1);
 }
 
Signature · 1 line
1.7.0
#1 lore raw

David,

as this is more netdev-related than PCMCIA-related, could you pick it up? Else, I'm willing to take it upstream, but would prefer your ACK on this.

Thanks & best wishes,

Dominik

From: Alexander Kurz <[email protected]>
Date: Wed, 31 Mar 2010 20:21:29 +0400
Subject: [PATCH] net: 3c574_cs fix stats.tx_bytes counter

Update the stats counter calculation in 3c574_cs, similar to the method used in 3c589_cs. This corrects the contents of the counter on tests using a "Megahertz 574B" card.

drivers/net/pcmcia/3c574_cs.c +5 -2
index 727bb38..30b7cf7 100644
@@ -772,8 +772,13 @@ static netdev_tx_t el3_start_xmit(struct sk_buff *skb,
 		  inw(ioaddr + EL3_STATUS));
 
 	spin_lock_irqsave(&lp->window_lock, flags);
+
+	dev->stats.tx_bytes += skb->len;
+
+	/* Put out the doubleword header... */
 	outw(skb->len, ioaddr + TX_FIFO);
 	outw(0, ioaddr + TX_FIFO);
+	/* ... and the packet rounded to a doubleword. */
 	outsl(ioaddr + TX_FIFO, skb->data, (skb->len+3)>>2);
 
 	dev->trans_start = jiffies;
@@ -1012,8 +1017,6 @@ static void update_stats(struct net_device *dev)
 	/* BadSSD */				   inb(ioaddr + 12);
 	up					 = inb(ioaddr + 13);
 
-	dev->stats.tx_bytes 			+= tx + ((up & 0xf0) << 12);
-
 	EL3WINDOW(1);
 }
 
maintainer Applied
#2 lore raw

From: Dominik Brodowski <[email protected]>
Date: Fri, 16 Apr 2010 15:01:01 +0200

Quoted 4 lines

David,

as this is more netdev-related than PCMCIA-related, could you pick it up? Else, I'm willing to take it upstream, but would prefer your ACK on this.

Applied to net-2.6, thanks Dominik.