[PATCH] Improved net device stats for hdlcdrv

From: Micah Dowty
Date: Sun Nov 21 2004 - 17:27:54 EST


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@xxxxxxx>

--- 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!
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/