Re: /proc/net/dev

Russell Coker - mailing lists account (bofh@snoopy.virtual.net.au)
Wed, 18 Jun 97 11:30:00 +1100


>> /proc/net/dev? I would like to fix the ppp driver so it fills in the
>> number of bytes transmitted and received, and to put in received bytes
>> counting on the Tulip driver. I would like to know the following:
>>
>> Is the count the number of bytes transferred over the media or the size
>> of the IP packet? It appears to be the size of the IP packet.

>Its an approximation of the number of bytes sent to the media, not
>including preambles and training sequences.

If it's defined to be "an approximation" then that's OK and I won't
worry about it. Anyway it has already been suggested to me that other
drivers will be doing the same and it's the expected characteristics, so I
don't plan to change this.

>> On transmission the Tulip driver increases the byte counter before the
>> packet is sent and doesn't appear to decrease it on failure to send. Is
>> this a bug or is the byte count defined as the number of bytes that we
>> attempt to send?

>Is it worth the clock cycles to worry about tiny errors ?

IMHO the answer is yes. If the data provided is considered wrong then
we should fix the code. To make the driver perform otherwise I would only
have to add a "lp->stats.tx_bytes-=skb->len;" line at the appropriate
place. That's probably less than 10 clock cycles on a modern CPU which
only get used if an error occurs. IMHO if we get a significant amount of
errors occurring then the system won't be doing much anyway...

Russell Coker

Here's the patch for the Tulip and PPP devices for those who are
interested.

diff -ru linux/drivers/net/ppp.c linux-count/drivers/net/ppp.c ---
linux/drivers/net/ppp.c Tue May 13 03:35:41 1997
+++ linux-count/drivers/net/ppp.c Mon Jun 16 18:45:06 1997
@@ -6,7 +6,7 @@
* Dynamic PPP devices by Jim Freeman <jfree@caldera.com>.
* ppp_tty_receive ``noisy-raise-bug'' fixed by Ove Ewerlid
<ewerlid@syscon.uu.se>
*
- * ==FILEVERSION 970126==
+ * ==FILEVERSION 970616==
*
* NOTE TO MAINTAINERS:
* If you modify this file at all, please set the number above to the
@@ -3088,6 +3088,7 @@
struct ppp *ppp = dev2ppp (dev);
static struct net_device_stats ppp_stats;

+ ppp_stats.rx_bytes = ppp->stats.ppp_ibytes;
ppp_stats.rx_packets = ppp->stats.ppp_ipackets;
ppp_stats.rx_errors = ppp->stats.ppp_ierrors;
ppp_stats.rx_dropped = ppp->stats.ppp_ierrors;
@@ -3096,6 +3097,7 @@
ppp_stats.rx_over_errors = 0;
ppp_stats.rx_crc_errors = 0;
ppp_stats.rx_frame_errors = 0;
+ ppp_stats.tx_bytes = ppp->stats.ppp_obytes;
ppp_stats.tx_packets = ppp->stats.ppp_opackets;
ppp_stats.tx_errors = ppp->stats.ppp_oerrors;
ppp_stats.tx_dropped = 0;
diff -ru linux/drivers/net/tulip.c linux-count/drivers/net/tulip.c ---
linux/drivers/net/tulip.c Mon Jun 16 19:52:07 1997
+++ linux-count/drivers/net/tulip.c Mon Jun 16 20:05:15 1997
@@ -1078,6 +1078,7 @@
skb->protocol = eth_type_trans(skb,dev);
netif_rx(skb);
lp->stats.rx_packets++;
+ lp->stats.rx_bytes+=skb->len;
}

lp->rx_ring[entry].status = TRING_OWN;