* [PATCH] WAN: bit and/or confusion
@ 2009-08-14 12:51 Roel Kluin
2009-08-14 23:32 ` David Miller
2009-08-14 23:36 ` Andrew Morton
0 siblings, 2 replies; 11+ messages in thread
From: Roel Kluin @ 2009-08-14 12:51 UTC (permalink / raw)
To: Francois Romieu, netdev, Andrew Morton, David S. Miller
Fix the tests that check whether Frame* bits are not set
Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
// vi drivers/net/wan/dscc4.c +307
#define FrameVfr 0x80
#define FrameRdo 0x40
#define FrameCrc 0x20
#define FrameRab 0x10
diff --git a/drivers/net/wan/dscc4.c b/drivers/net/wan/dscc4.c
index 8face5d..dd3c64a 100644
--- a/drivers/net/wan/dscc4.c
+++ b/drivers/net/wan/dscc4.c
@@ -663,9 +663,9 @@ 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)))
dev->stats.rx_length_errors++;
else
dev->stats.rx_errors++;
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH] WAN: bit and/or confusion
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
1 sibling, 0 replies; 11+ messages in thread
From: David Miller @ 2009-08-14 23:32 UTC (permalink / raw)
To: roel.kluin; +Cc: romieu, netdev, akpm
From: Roel Kluin <roel.kluin@gmail.com>
Date: Fri, 14 Aug 2009 14:51:46 +0200
> Fix the tests that check whether Frame* bits are not set
>
> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Applied.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] WAN: bit and/or confusion
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
1 sibling, 1 reply; 11+ messages in thread
From: Andrew Morton @ 2009-08-14 23:36 UTC (permalink / raw)
To: Roel Kluin; +Cc: romieu, netdev, davem
On Fri, 14 Aug 2009 14:51:46 +0200
Roel Kluin <roel.kluin@gmail.com> wrote:
> Fix the tests that check whether Frame* bits are not set
>
> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
> ---
> // vi drivers/net/wan/dscc4.c +307
> #define FrameVfr 0x80
> #define FrameRdo 0x40
> #define FrameCrc 0x20
> #define FrameRab 0x10
>
> diff --git a/drivers/net/wan/dscc4.c b/drivers/net/wan/dscc4.c
> index 8face5d..dd3c64a 100644
> --- a/drivers/net/wan/dscc4.c
> +++ b/drivers/net/wan/dscc4.c
> @@ -663,9 +663,9 @@ 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++;
that's
if (!(x & 0xffffffdf))
which seems peculiar. Should it have been
else if (skb->data[pkt_len] & FrameCrc)
or
else if (!(skb->data[pkt_len] & FrameCrc))
> - else if (!(skb->data[pkt_len] | ~(FrameVfr | FrameRab)))
> + else if (!(skb->data[pkt_len] & ~(FrameVfr | FrameRab)))
> dev->stats.rx_length_errors++;
> else
> dev->stats.rx_errors++;
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] WAN: bit and/or confusion
2009-08-14 23:36 ` Andrew Morton
@ 2009-08-14 23:41 ` David Miller
2009-08-14 23:58 ` Andrew Morton
0 siblings, 1 reply; 11+ messages in thread
From: David Miller @ 2009-08-14 23:41 UTC (permalink / raw)
To: akpm; +Cc: roel.kluin, romieu, netdev
From: Andrew Morton <akpm@linux-foundation.org>
Date: Fri, 14 Aug 2009 16:36:44 -0700
> On Fri, 14 Aug 2009 14:51:46 +0200
> Roel Kluin <roel.kluin@gmail.com> wrote:
>
>> @@ -663,9 +663,9 @@ 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++;
>
> that's
>
> if (!(x & 0xffffffdf))
>
> which seems peculiar. Should it have been
>
> else if (skb->data[pkt_len] & FrameCrc)
>
> or
>
> else if (!(skb->data[pkt_len] & FrameCrc))
Indeed, I can't tell which variant would be correct.
I'm reverting until someone with a datasheet for this chip speaks up
:-)
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] WAN: bit and/or confusion
2009-08-14 23:41 ` David Miller
@ 2009-08-14 23:58 ` Andrew Morton
2009-08-15 13:41 ` Roel Kluin
0 siblings, 1 reply; 11+ messages in thread
From: Andrew Morton @ 2009-08-14 23:58 UTC (permalink / raw)
To: David Miller; +Cc: roel.kluin, romieu, netdev
On Fri, 14 Aug 2009 16:41:23 -0700 (PDT)
David Miller <davem@davemloft.net> wrote:
> From: Andrew Morton <akpm@linux-foundation.org>
> Date: Fri, 14 Aug 2009 16:36:44 -0700
>
> > On Fri, 14 Aug 2009 14:51:46 +0200
> > Roel Kluin <roel.kluin@gmail.com> wrote:
> >
> >> @@ -663,9 +663,9 @@ 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++;
> >
> > that's
> >
> > if (!(x & 0xffffffdf))
> >
> > which seems peculiar. Should it have been
> >
> > else if (skb->data[pkt_len] & FrameCrc)
> >
> > or
> >
> > else if (!(skb->data[pkt_len] & FrameCrc))
>
> Indeed, I can't tell which variant would be correct.
>
> I'm reverting until someone with a datasheet for this chip speaks up
> :-)
http://www.datasheet.in/download.php?id=39415
Page 383 and 384 say that bit 5 (CRC) is zero if the rx frame contained
errors.
So we need
else if (!(skb->data[pkt_len] & FrameCrc))
> - else if (!(skb->data[pkt_len] | ~(FrameVfr | FrameRab)))
> + else if (!(skb->data[pkt_len] & ~(FrameVfr | FrameRab)))
vfr is "valid frame". 0 is invalid.
rab is "receive message aborted". The data sheet doesn't actually say
if the bit is active-high or active-low (grr).
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] WAN: bit and/or confusion
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
0 siblings, 2 replies; 11+ messages in thread
From: Roel Kluin @ 2009-08-15 13:41 UTC (permalink / raw)
To: Andrew Morton; +Cc: David Miller, romieu, netdev
Fix the tests that check whether Frame* bits are not set
Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
> we need
>
> else if (!(skb->data[pkt_len] & FrameCrc))
> vfr is "valid frame". 0 is invalid.
>
> rab is "receive message aborted". The data sheet doesn't actually say
> if the bit is active-high or active-low (grr).
Maybe someone could test this?
diff --git a/drivers/net/wan/dscc4.c b/drivers/net/wan/dscc4.c
index 8face5d..b686050 100644
--- a/drivers/net/wan/dscc4.c
+++ b/drivers/net/wan/dscc4.c
@@ -663,9 +663,9 @@ 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)))
dev->stats.rx_length_errors++;
else
dev->stats.rx_errors++;
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH] WAN: bit and/or confusion
2009-08-15 13:41 ` Roel Kluin
@ 2009-08-15 14:13 ` Francois Romieu
2009-08-15 18:46 ` Krzysztof Halasa
1 sibling, 0 replies; 11+ messages in thread
From: Francois Romieu @ 2009-08-15 14:13 UTC (permalink / raw)
To: Roel Kluin; +Cc: Andrew Morton, David Miller, netdev
Roel Kluin <roel.kluin@gmail.com> :
[...]
> Maybe someone could test this?
I may undust a pair of card and a split box but do not hold your breath.
--
Ueimor
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] WAN: bit and/or confusion
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
1 sibling, 1 reply; 11+ messages in thread
From: Krzysztof Halasa @ 2009-08-15 18:46 UTC (permalink / raw)
To: Roel Kluin; +Cc: Andrew Morton, David Miller, romieu, netdev
Roel Kluin <roel.kluin@gmail.com> writes:
> +++ b/drivers/net/wan/dscc4.c
> @@ -663,9 +663,9 @@ 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++;
This looks like a correct fix.
> - 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)
> 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 have the hardware and can't test (donations of such hw welcome).
--
Krzysztof Halasa
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] WAN: bit and/or confusion
2009-08-15 18:46 ` Krzysztof Halasa
@ 2009-08-20 14:04 ` Roel Kluin
2009-08-20 14:25 ` Krzysztof Halasa
2009-08-31 5:02 ` David Miller
0 siblings, 2 replies; 11+ messages in thread
From: Roel Kluin @ 2009-08-20 14:04 UTC (permalink / raw)
To: Krzysztof Halasa; +Cc: Andrew Morton, David Miller, romieu, netdev
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:
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH] WAN: bit and/or confusion
2009-08-20 14:04 ` Roel Kluin
@ 2009-08-20 14:25 ` Krzysztof Halasa
2009-08-31 5:02 ` David Miller
1 sibling, 0 replies; 11+ messages in thread
From: Krzysztof Halasa @ 2009-08-20 14:25 UTC (permalink / raw)
To: Roel Kluin; +Cc: Andrew Morton, David Miller, romieu, netdev
Roel Kluin <roel.kluin@gmail.com> writes:
>> 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?
Because I think (didn't read the manual) that these (inverted) bits
represent specific errors. So I suggested inverting them, then treating
as separate error bits, it should be easier to read.
That's only a suggestion of course (unless someone sends me the/a card -
non-returnable "donations" only please - and I can work on it
personally).
IOW all (inverted) bits = 1 => all bits zero after inversion => no
errors. This changes functionality a bit, and would need to be checked.
Otherwise, you could test: if ((status & FrameOk) == 0) then looks_good().
> 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:
Guess it would do.
--
Krzysztof Halasa
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] WAN: bit and/or confusion
2009-08-20 14:04 ` Roel Kluin
2009-08-20 14:25 ` Krzysztof Halasa
@ 2009-08-31 5:02 ` David Miller
1 sibling, 0 replies; 11+ messages in thread
From: David Miller @ 2009-08-31 5:02 UTC (permalink / raw)
To: roel.kluin; +Cc: khc, akpm, romieu, netdev
From: Roel Kluin <roel.kluin@gmail.com>
Date: Thu, 20 Aug 2009 16:04:40 +0200
> Fix the tests that check whether Frame* bits are not set
>
> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Applied to net-next-2.6, thanks.
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2009-08-31 5:02 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2009-08-20 14:25 ` Krzysztof Halasa
2009-08-31 5:02 ` David Miller
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).