linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Micah Dowty <micah@navi.cx>
To: sailer@ife.ee.ethz.ch
Cc: linux-kernel@vger.kernel.org, trivial@rustcorp.com.au
Subject: [PATCH] Improved net device stats for hdlcdrv
Date: Sun, 21 Nov 2004 15:37:49 -0700	[thread overview]
Message-ID: <20041121223749.GA10208@navi.cx> (raw)

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!

                 reply	other threads:[~2004-11-21 22:26 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20041121223749.GA10208@navi.cx \
    --to=micah@navi.cx \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sailer@ife.ee.ethz.ch \
    --cc=trivial@rustcorp.com.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).