Skip to contentSkip to conversation

Improved net device stats for hdlcdrv

PATCH New Micah Dowty 1 participant 1 message Nov 21, 2004 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Improved net device stats for hdlcdrv

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.

drivers/net/hamradio/hdlcdrv.c +5 -1
@@ -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) {
Signature · 1 line
Only you can prevent creeping featurism!