Messages in this thread Patches in this message | | | From | Denis Vlasenko <> | Subject | New inventions in rounding up in catc.c? | Date | Sat, 24 Sep 2005 13:43:42 +0300 |
| |
# 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);--- 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); | |