From: Denis Vlasenko <vda@ilport.com.ua>
To: Simon Evans <spse@secret.org.uk>, Vojtech Pavlik <vojtech@suse.cz>
Cc: linux-kernel@vger.kernel.org
Subject: New inventions in rounding up in catc.c?
Date: Sat, 24 Sep 2005 13:43:42 +0300 [thread overview]
Message-ID: <200509241343.42464.vda@ilport.com.ua> (raw)
[-- Attachment #1: Type: text/plain, Size: 1945 bytes --]
# 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);
[-- Attachment #2: catc.patch --]
[-- Type: text/x-diff, Size: 855 bytes --]
--- 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);
next reply other threads:[~2005-09-24 10:44 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-09-24 10:43 Denis Vlasenko [this message]
2005-09-24 18:46 ` New inventions in rounding up in catc.c? Grant Coady
2005-09-25 10:43 ` Denis Vlasenko
2005-09-25 20:54 ` Vojtech Pavlik
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=200509241343.42464.vda@ilport.com.ua \
--to=vda@ilport.com.ua \
--cc=linux-kernel@vger.kernel.org \
--cc=spse@secret.org.uk \
--cc=vojtech@suse.cz \
/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