Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=9f05cfe250498791cd24707aea3b728b52d886d5
Commit:     9f05cfe250498791cd24707aea3b728b52d886d5
Parent:     6dfa7522d8b08c887bf9f4cb2600b89232f132f5
Author:     Olof Johansson <[EMAIL PROTECTED]>
AuthorDate: Tue May 8 00:47:37 2007 -0500
Committer:  Jeff Garzik <[EMAIL PROTECTED]>
CommitDate: Tue May 8 01:47:53 2007 -0400

    pasemi_mac: Add SKB reuse / copy-break
    
    Add a copy-break and recycle the SKB in the driver for small packets.
    
    Signed-off-by: Olof Johansson <[EMAIL PROTECTED]>
    Signed-off-by: Jeff Garzik <[EMAIL PROTECTED]>
---
 drivers/net/pasemi_mac.c |   31 ++++++++++++++++++++++++-------
 1 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/drivers/net/pasemi_mac.c b/drivers/net/pasemi_mac.c
index 2bf13cf..216bb4a 100644
--- a/drivers/net/pasemi_mac.c
+++ b/drivers/net/pasemi_mac.c
@@ -279,8 +279,8 @@ static void pasemi_mac_free_rx_resources(struct net_device 
*dev)
        for (i = 0; i < RX_RING_SIZE; i++) {
                info = &RX_DESC_INFO(mac, i);
                dp = &RX_DESC(mac, i);
-               if (info->dma) {
-                       if (info->skb) {
+               if (info->skb) {
+                       if (info->dma) {
                                pci_unmap_single(mac->dma_pdev,
                                                 info->dma,
                                                 info->skb->len,
@@ -329,12 +329,14 @@ static void pasemi_mac_replenish_rx_ring(struct 
net_device *dev)
                struct sk_buff *skb;
                dma_addr_t dma;
 
-               skb = dev_alloc_skb(BUF_SIZE);
+               /* skb might still be in there for recycle on short receives */
+               if (info->skb)
+                       skb = info->skb;
+               else
+                       skb = dev_alloc_skb(BUF_SIZE);
 
-               if (!skb) {
-                       count = i - start;
+               if (unlikely(!skb))
                        break;
-               }
 
                dma = pci_map_single(mac->dma_pdev, skb->data, skb->len,
                                     PCI_DMA_FROMDEVICE);
@@ -442,13 +444,28 @@ static int pasemi_mac_clean_rx(struct pasemi_mac *mac, 
int limit)
 
                BUG_ON(!info);
                BUG_ON(info->dma != dma);
+               skb = info->skb;
 
                pci_unmap_single(mac->dma_pdev, info->dma, info->skb->len,
                                 PCI_DMA_FROMDEVICE);
+               info->dma = 0;
 
-               skb = info->skb;
 
                len = (dp->macrx & XCT_MACRX_LLEN_M) >> XCT_MACRX_LLEN_S;
+               if (len < 256) {
+                       struct sk_buff *new_skb =
+                           netdev_alloc_skb(mac->netdev, len + NET_IP_ALIGN);
+                       if (new_skb) {
+                               skb_reserve(new_skb, NET_IP_ALIGN);
+                               memcpy(new_skb->data - NET_IP_ALIGN,
+                                       skb->data - NET_IP_ALIGN,
+                                       len + NET_IP_ALIGN);
+                               /* save the skb in buffer_info as good */
+                               skb = new_skb;
+                       }
+                       /* else just continue with the old one */
+               } else
+                       info->skb = NULL;
 
                skb_put(skb, len);
 
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to