[168] in linux-net channel archive
proc/net/dev bug with 8390 cards + fix
daemon@ATHENA.MIT.EDU (Paul Gortmaker)
Wed Mar 29 18:34:37 1995
From: Paul Gortmaker <paul@rasty.anu.edu.au>
To: linux-net@vger.rutgers.edu
Date: Thu, 30 Mar 1995 01:32:00 +1000 (EST)
Cc: becker@cesdis1.gsfc.nasa.gov (Donald Becker)
Hi everybody,
It seems that proc/net/dev/ reports garbage on cards that are not
active (haven't been "ifconfig"ed). It adds to the garbage everytime the
_get_stats() routine is called. This is with 8390 based cards.
It may be a problem with non-8390 cards too, but I can't verify that.
Here is an example. eth1 has not been used yet, while eth0 is on line.
foobar:/tmp> cat /proc/net/dev
Inter-| Receive | Transmit
face |packets errs drop fifo frame|packets errs drop fifo colls carrier
lo: 0 0 0 0 0 12 0 0 0 0 0
eth0: 64359 0 0 0 0 9644 0 0 0 188 0
eth1: 0 0 127 0 254 0 0 0 0 0 0
foobar:/tmp> cat /proc/net/dev
Inter-| Receive | Transmit
face |packets errs drop fifo frame|packets errs drop fifo colls carrier
lo: 0 0 0 0 0 12 0 0 0 0 0
eth0: 64364 0 0 0 0 9644 0 0 0 188 0
eth1: 0 0 381 0 762 0 0 0 0 0 0
foobar:/tmp> cat /proc/net/dev
Inter-| Receive | Transmit
face |packets errs drop fifo frame|packets errs drop fifo colls carrier
lo: 0 0 0 0 0 12 0 0 0 0 0
eth0: 64384 0 0 0 0 9644 0 0 0 188 0
eth1: 0 0 635 0 1270 0 0 0 0 0 0
The problem is that we are reading the registers on a stopped card. I
don't know what the ns8390 databook says on this, but an obvious fix
would be the following:
--- /tmp/8390.c Thu Mar 30 00:34:31 1995
+++ linux/drivers/net/8390.c Thu Mar 30 00:37:43 1995
@@ -538,6 +538,9 @@
{
short ioaddr = dev->base_addr;
struct ei_device *ei_local = (struct ei_device *) dev->priv;
+
+ /* If the card is stopped, just return the present stats. */
+ if (dev->start == 0) return &ei_local->stat;
/* Read the counter registers, assuming we are in page 0. */
ei_local->stat.rx_frame_errors += inb_p(ioaddr + EN0_COUNTER0);
Regards,
Paul.