# grep '>> 6' -C5 catc.c
catc->stats.rx_bytes += pkt_len;
/* F5U011 only does one packet per RX */
if (catc->is_f5u011)
break;
pkt_start += (((pkt_len + 1) >> 6) + 1) << 6;
} while (pkt_start - (u8 *) urb->transfer_buffer < urb->actual_length);
catc->netdev->last_rx = jiffies;
--
unsigned long flags;
char *tx_buf;
spin_lock_irqsave(&catc->tx_lock, flags);
catc->tx_ptr = (((catc->tx_ptr - 1) >> 6) + 1) << 6;
tx_buf = catc->tx_buf[catc->tx_idx] + catc->tx_ptr;
*((u16*)tx_buf) = (catc->is_f5u011) ? cpu_to_be16((u16)skb->len) : cpu_to_le16((u16)skb->len);
memcpy(tx_buf + 2, skb->data, skb->len);
catc->tx_ptr += skb->len + 2;
I case I do not miss something, second one rounds tx_ptr up to 64 byte
boundary. It can be done in 2 operations instead of 4.
First one may be the same, but do you really meant pkt_len + 1, not pkt_len - 1?
Patch is below, and also attached (KMail may mangle inline patches).
--
vda
--- linux-2.6.13.org/drivers/usb/net/catc.c.org Mon Aug 29 02:41:01 2005
+++ linux-2.6.13.org/drivers/usb/net/catc.c Sat Sep 24 13:35:42 2005
@@ -268,7 +268,7 @@ static void catc_rx_done(struct urb *urb
/* F5U011 only does one packet per RX */
if (catc->is_f5u011)
break;
- pkt_start += (((pkt_len + 1) >> 6) + 1) << 6;
+ pkt_start += ((pkt_len + 2) + 63) & ~63;
} while (pkt_start - (u8 *) urb->transfer_buffer < urb->actual_length);
@@ -417,7 +417,7 @@ static int catc_hard_start_xmit(struct s
spin_lock_irqsave(&catc->tx_lock, flags);
- catc->tx_ptr = (((catc->tx_ptr - 1) >> 6) + 1) << 6;
+ catc->tx_ptr = (catc->tx_ptr + 63) & ~63;
tx_buf = catc->tx_buf[catc->tx_idx] + catc->tx_ptr;
*((u16*)tx_buf) = (catc->is_f5u011) ? cpu_to_be16((u16)skb->len) : cpu_to_le16((u16)skb->len);
memcpy(tx_buf + 2, skb->data, skb->len);
On Sat, 24 Sep 2005 13:43:42 +0300, Denis Vlasenko <[email protected]> wrote:
> /* F5U011 only does one packet per RX */
> if (catc->is_f5u011)
> break;
>- pkt_start += (((pkt_len + 1) >> 6) + 1) << 6;
>+ pkt_start += ((pkt_len + 2) + 63) & ~63;
pkt_start += ((pkt_len + 1) + 64) & ~63;
Seems more clear to me.
Grant.
On Saturday 24 September 2005 21:46, Grant Coady wrote:
> On Sat, 24 Sep 2005 13:43:42 +0300, Denis Vlasenko <[email protected]> wrote:
> > /* F5U011 only does one packet per RX */
> > if (catc->is_f5u011)
> > break;
> >- pkt_start += (((pkt_len + 1) >> 6) + 1) << 6;
> >+ pkt_start += ((pkt_len + 2) + 63) & ~63;
>
> pkt_start += ((pkt_len + 1) + 64) & ~63;
>
> Seems more clear to me.
Why?
((pkt_len + 2) + 63) & ~63 is "add 2 and round up to next 64".
((pkt_len + 1) + 64) & ~63 is "???!"
It's strange code anyway, I hope maintainer can clarify what's going on.
(I suspect it was intended to be pkt_len - 1, not +, in the first place)
--
vda
On Sun, Sep 25, 2005 at 01:43:47PM +0300, Denis Vlasenko wrote:
> On Saturday 24 September 2005 21:46, Grant Coady wrote:
> > On Sat, 24 Sep 2005 13:43:42 +0300, Denis Vlasenko <[email protected]> wrote:
> > > /* F5U011 only does one packet per RX */
> > > if (catc->is_f5u011)
> > > break;
> > >- pkt_start += (((pkt_len + 1) >> 6) + 1) << 6;
> > >+ pkt_start += ((pkt_len + 2) + 63) & ~63;
> >
> > pkt_start += ((pkt_len + 1) + 64) & ~63;
> >
> > Seems more clear to me.
>
> Why?
>
> ((pkt_len + 2) + 63) & ~63 is "add 2 and round up to next 64".
> ((pkt_len + 1) + 64) & ~63 is "???!"
>
> It's strange code anyway, I hope maintainer can clarify what's going on.
> (I suspect it was intended to be pkt_len - 1, not +, in the first place)
Honestly, I don't remember at all. I'll try to find the (very old) docs
I have for the chip.
--
Vojtech Pavlik
SuSE Labs, SuSE CR