linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Improved net device stats for hdlcdrv
@ 2004-11-21 22:37 Micah Dowty
  0 siblings, 0 replies; only message in thread
From: Micah Dowty @ 2004-11-21 22:37 UTC (permalink / raw)
  To: sailer; +Cc: linux-kernel, trivial

This is a tiny patch for hdlcdrv (a ham radio driver) that adds accounting
for transmitted/received bytes and receiver CRC errors. It's useful to have
these show up in ifconfig, and I need these stats in other kernel modules
cooperating with hdlcdrv.

If you apply this, please also apply my earlier patch that fixes the transmit
CRC problem- without that, hdlcdrv is completely useless.

Signed-off-by: Micah Dowty <micah@navi.cx>

--- linux-2.6.10-rc2-bk6/drivers/net/hamradio/hdlcdrv.c	2004-11-21 14:59:55.969119632 -0700
+++ linux-hdlcdrv-stats/drivers/net/hamradio/hdlcdrv.c	2004-11-21 15:15:05.955780632 -0700
@@ -166,8 +166,10 @@ static void hdlc_rx_flag(struct net_devi
 
 	if (s->hdlcrx.len < 4) 
 		return;
-	if (!check_crc_ccitt(s->hdlcrx.buffer, s->hdlcrx.len)) 
+	if (!check_crc_ccitt(s->hdlcrx.buffer, s->hdlcrx.len)) {
+		s->stats.rx_errors++;
 		return;
+	}
 	pkt_len = s->hdlcrx.len - 2 + 1; /* KISS kludge */
 	if (!(skb = dev_alloc_skb(pkt_len))) {
 		printk("%s: memory squeeze, dropping packet\n", dev->name);
@@ -183,6 +185,7 @@ static void hdlc_rx_flag(struct net_devi
 	netif_rx(skb);
 	dev->last_rx = jiffies;
 	s->stats.rx_packets++;
+	s->stats.rx_bytes += s->hdlcrx.len;
 }
 
 void hdlcdrv_receiver(struct net_device *dev, struct hdlcdrv_state *s)
@@ -345,6 +348,7 @@ void hdlcdrv_transmitter(struct net_devi
 			s->hdlctx.tx_state = 2;
 			s->hdlctx.bitstream = 0;
 			s->stats.tx_packets++;
+			s->stats.tx_bytes += s->hdlctx.len;
 			break;
 		case 2:
 			if (!s->hdlctx.len) {

-- 
Only you can prevent creeping featurism!

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2004-11-21 22:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-11-21 22:37 [PATCH] Improved net device stats for hdlcdrv Micah Dowty

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