netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Roel Kluin <roel.kluin@gmail.com>
To: Krzysztof Halasa <khc@pm.waw.pl>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	David Miller <davem@davemloft.net>,
	romieu@fr.zoreil.com, netdev@vger.kernel.org
Subject: Re: [PATCH] WAN: bit and/or confusion
Date: Thu, 20 Aug 2009 16:04:40 +0200	[thread overview]
Message-ID: <4A8D57F8.1050106@gmail.com> (raw)
In-Reply-To: <m3iqgovrsv.fsf@intrepid.localdomain>

Fix the tests that check whether Frame* bits are not set

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---

>> -		else if (!(skb->data[pkt_len] | ~(FrameVfr | FrameRab)))
>> +		else if (!(skb->data[pkt_len] & (FrameVfr | FrameRab)))
>>  			dev->stats.rx_length_errors++;
> 
> This test requires both FrameVfr and FrameRab to be true (zero). Perhaps
> it should be:
> 
>> +		else if ((skb->data[pkt_len] & (FrameVfr | FrameRab)) != FrameVfr | FrameRab)

Ok, Francois Romieu, could you test this?

>>  		else
>>  			dev->stats.rx_errors++;
> 
> rx_errors is incremented only on remaining errors. I think most drivers
> increment rx_errors on all RX errors, and simultaneously rx_*_errors
> when needed.
> 
> 
> Perhaps something like the following should be better?
> 
> 		u8 status = ~skb->data[pkt_len];
> 
> 		if (status == 0)
> 			looks_good...;
> 		else {
> 			if (status & FrameRab)
> 				...
> 			if (status & FrameVfr)
> 				...
> 			etc.
> 			rx_errors++;
> 		}

I don't understand your suggestion - why status == 0? doesn't the patch
below do what you want instead?

Roel

diff --git a/drivers/net/wan/dscc4.c b/drivers/net/wan/dscc4.c
index 8face5d..88534b6 100644
--- a/drivers/net/wan/dscc4.c
+++ b/drivers/net/wan/dscc4.c
@@ -663,12 +663,12 @@ static inline void dscc4_rx_skb(struct dscc4_dev_priv *dpriv,
 	} else {
 		if (skb->data[pkt_len] & FrameRdo)
 			dev->stats.rx_fifo_errors++;
-		else if (!(skb->data[pkt_len] | ~FrameCrc))
+		else if (!(skb->data[pkt_len] & FrameCrc))
 			dev->stats.rx_crc_errors++;
-		else if (!(skb->data[pkt_len] | ~(FrameVfr | FrameRab)))
+		else if ((skb->data[pkt_len] & (FrameVfr | FrameRab)) !=
+				FrameVfr | FrameRab)
 			dev->stats.rx_length_errors++;
-		else
-			dev->stats.rx_errors++;
+		dev->stats.rx_errors++;
 		dev_kfree_skb_irq(skb);
 	}
 refill:

  reply	other threads:[~2009-08-20 14:00 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-14 12:51 [PATCH] WAN: bit and/or confusion Roel Kluin
2009-08-14 23:32 ` David Miller
2009-08-14 23:36 ` Andrew Morton
2009-08-14 23:41   ` David Miller
2009-08-14 23:58     ` Andrew Morton
2009-08-15 13:41       ` Roel Kluin
2009-08-15 14:13         ` Francois Romieu
2009-08-15 18:46         ` Krzysztof Halasa
2009-08-20 14:04           ` Roel Kluin [this message]
2009-08-20 14:25             ` Krzysztof Halasa
2009-08-31  5:02             ` David Miller

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=4A8D57F8.1050106@gmail.com \
    --to=roel.kluin@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=davem@davemloft.net \
    --cc=khc@pm.waw.pl \
    --cc=netdev@vger.kernel.org \
    --cc=romieu@fr.zoreil.com \
    /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).