diff options
author | Stephen Hemminger <shemminger@linux-foundation.org> | 2007-06-16 19:06:49 -0400 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2007-07-08 22:16:43 -0400 |
commit | b449655ff52ff8a29c66c5fc3fc03617e61182ee (patch) | |
tree | 460175b0a8b5bd84c7a6a76df297a5f0d9309c48 /drivers | |
parent | 278667ba186a23770b0dd23ccd26de56a8cc4ec2 (diff) |
r8169: Rx path update
- pci_dma_sync_single_for_cpu is not needed for a single large packet
- remove the function pointer to help gcc optimizing the inline
pci_dma functions.
Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
Signed-off-by: Francois Romieu <romieu@fr.zoreil.com>
Cc: Edward Hsu <edward_hsu@realtek.com.tw>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/r8169.c | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c index e4827a414689..4d0cdbaf527e 100644 --- a/drivers/net/r8169.c +++ b/drivers/net/r8169.c | |||
@@ -2483,25 +2483,27 @@ static inline void rtl8169_rx_csum(struct sk_buff *skb, struct RxDesc *desc) | |||
2483 | skb->ip_summed = CHECKSUM_NONE; | 2483 | skb->ip_summed = CHECKSUM_NONE; |
2484 | } | 2484 | } |
2485 | 2485 | ||
2486 | static inline int rtl8169_try_rx_copy(struct sk_buff **sk_buff, int pkt_size, | 2486 | static inline bool rtl8169_try_rx_copy(struct sk_buff **sk_buff, int pkt_size, |
2487 | struct RxDesc *desc, int rx_buf_sz, | 2487 | struct pci_dev *pdev, dma_addr_t addr, |
2488 | unsigned int align) | 2488 | unsigned int align) |
2489 | { | 2489 | { |
2490 | int ret = -1; | 2490 | struct sk_buff *skb; |
2491 | bool done = false; | ||
2491 | 2492 | ||
2492 | if (pkt_size < rx_copybreak) { | 2493 | if (pkt_size >= rx_copybreak) |
2493 | struct sk_buff *skb; | 2494 | goto out; |
2494 | 2495 | ||
2495 | skb = dev_alloc_skb(pkt_size + align); | 2496 | skb = dev_alloc_skb(pkt_size + align); |
2496 | if (skb) { | 2497 | if (!skb) |
2497 | skb_reserve(skb, (align - 1) & (unsigned long)skb->data); | 2498 | goto out; |
2498 | skb_copy_from_linear_data(*sk_buff, skb->data, pkt_size); | 2499 | |
2499 | *sk_buff = skb; | 2500 | pci_dma_sync_single_for_cpu(pdev, addr, pkt_size, PCI_DMA_FROMDEVICE); |
2500 | rtl8169_mark_to_asic(desc, rx_buf_sz); | 2501 | skb_reserve(skb, (align - 1) & (unsigned long)skb->data); |
2501 | ret = 0; | 2502 | skb_copy_from_linear_data(*sk_buff, skb->data, pkt_size); |
2502 | } | 2503 | *sk_buff = skb; |
2503 | } | 2504 | done = true; |
2504 | return ret; | 2505 | out: |
2506 | return done; | ||
2505 | } | 2507 | } |
2506 | 2508 | ||
2507 | static int | 2509 | static int |
@@ -2547,9 +2549,9 @@ rtl8169_rx_interrupt(struct net_device *dev, struct rtl8169_private *tp, | |||
2547 | rtl8169_mark_to_asic(desc, tp->rx_buf_sz); | 2549 | rtl8169_mark_to_asic(desc, tp->rx_buf_sz); |
2548 | } else { | 2550 | } else { |
2549 | struct sk_buff *skb = tp->Rx_skbuff[entry]; | 2551 | struct sk_buff *skb = tp->Rx_skbuff[entry]; |
2552 | dma_addr_t addr = le64_to_cpu(desc->addr); | ||
2550 | int pkt_size = (status & 0x00001FFF) - 4; | 2553 | int pkt_size = (status & 0x00001FFF) - 4; |
2551 | void (*pci_action)(struct pci_dev *, dma_addr_t, | 2554 | struct pci_dev *pdev = tp->pci_dev; |
2552 | size_t, int) = pci_dma_sync_single_for_device; | ||
2553 | 2555 | ||
2554 | /* | 2556 | /* |
2555 | * The driver does not support incoming fragmented | 2557 | * The driver does not support incoming fragmented |
@@ -2565,19 +2567,17 @@ rtl8169_rx_interrupt(struct net_device *dev, struct rtl8169_private *tp, | |||
2565 | 2567 | ||
2566 | rtl8169_rx_csum(skb, desc); | 2568 | rtl8169_rx_csum(skb, desc); |
2567 | 2569 | ||
2568 | pci_dma_sync_single_for_cpu(tp->pci_dev, | 2570 | if (rtl8169_try_rx_copy(&skb, pkt_size, pdev, addr, |
2569 | le64_to_cpu(desc->addr), tp->rx_buf_sz, | 2571 | tp->align)) { |
2570 | PCI_DMA_FROMDEVICE); | 2572 | pci_dma_sync_single_for_device(pdev, addr, |
2571 | 2573 | pkt_size, PCI_DMA_FROMDEVICE); | |
2572 | if (rtl8169_try_rx_copy(&skb, pkt_size, desc, | 2574 | rtl8169_mark_to_asic(desc, tp->rx_buf_sz); |
2573 | tp->rx_buf_sz, tp->align)) { | 2575 | } else { |
2574 | pci_action = pci_unmap_single; | 2576 | pci_unmap_single(pdev, addr, pkt_size, |
2577 | PCI_DMA_FROMDEVICE); | ||
2575 | tp->Rx_skbuff[entry] = NULL; | 2578 | tp->Rx_skbuff[entry] = NULL; |
2576 | } | 2579 | } |
2577 | 2580 | ||
2578 | pci_action(tp->pci_dev, le64_to_cpu(desc->addr), | ||
2579 | tp->rx_buf_sz, PCI_DMA_FROMDEVICE); | ||
2580 | |||
2581 | skb_put(skb, pkt_size); | 2581 | skb_put(skb, pkt_size); |
2582 | skb->protocol = eth_type_trans(skb, dev); | 2582 | skb->protocol = eth_type_trans(skb, dev); |
2583 | 2583 | ||