summaryrefslogtreecommitdiffstats
path: root/drivers/net/r8169.c
diff options
context:
space:
mode:
authorStephen Hemminger <shemminger@linux-foundation.org>2007-06-17 01:06:49 +0200
committerJeff Garzik <jeff@garzik.org>2007-07-08 22:16:43 -0400
commitb449655ff52ff8a29c66c5fc3fc03617e61182ee (patch)
tree460175b0a8b5bd84c7a6a76df297a5f0d9309c48 /drivers/net/r8169.c
parent278667ba186a23770b0dd23ccd26de56a8cc4ec2 (diff)
downloadop-kernel-dev-b449655ff52ff8a29c66c5fc3fc03617e61182ee.zip
op-kernel-dev-b449655ff52ff8a29c66c5fc3fc03617e61182ee.tar.gz
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/net/r8169.c')
-rw-r--r--drivers/net/r8169.c56
1 files changed, 28 insertions, 28 deletions
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index e4827a4..4d0cdba 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)
skb->ip_summed = CHECKSUM_NONE;
}
-static inline int rtl8169_try_rx_copy(struct sk_buff **sk_buff, int pkt_size,
- struct RxDesc *desc, int rx_buf_sz,
- unsigned int align)
+static inline bool rtl8169_try_rx_copy(struct sk_buff **sk_buff, int pkt_size,
+ struct pci_dev *pdev, dma_addr_t addr,
+ unsigned int align)
{
- int ret = -1;
+ struct sk_buff *skb;
+ bool done = false;
- if (pkt_size < rx_copybreak) {
- struct sk_buff *skb;
+ if (pkt_size >= rx_copybreak)
+ goto out;
- skb = dev_alloc_skb(pkt_size + align);
- if (skb) {
- skb_reserve(skb, (align - 1) & (unsigned long)skb->data);
- skb_copy_from_linear_data(*sk_buff, skb->data, pkt_size);
- *sk_buff = skb;
- rtl8169_mark_to_asic(desc, rx_buf_sz);
- ret = 0;
- }
- }
- return ret;
+ skb = dev_alloc_skb(pkt_size + align);
+ if (!skb)
+ goto out;
+
+ pci_dma_sync_single_for_cpu(pdev, addr, pkt_size, PCI_DMA_FROMDEVICE);
+ skb_reserve(skb, (align - 1) & (unsigned long)skb->data);
+ skb_copy_from_linear_data(*sk_buff, skb->data, pkt_size);
+ *sk_buff = skb;
+ done = true;
+out:
+ return done;
}
static int
@@ -2547,9 +2549,9 @@ rtl8169_rx_interrupt(struct net_device *dev, struct rtl8169_private *tp,
rtl8169_mark_to_asic(desc, tp->rx_buf_sz);
} else {
struct sk_buff *skb = tp->Rx_skbuff[entry];
+ dma_addr_t addr = le64_to_cpu(desc->addr);
int pkt_size = (status & 0x00001FFF) - 4;
- void (*pci_action)(struct pci_dev *, dma_addr_t,
- size_t, int) = pci_dma_sync_single_for_device;
+ struct pci_dev *pdev = tp->pci_dev;
/*
* The driver does not support incoming fragmented
@@ -2565,19 +2567,17 @@ rtl8169_rx_interrupt(struct net_device *dev, struct rtl8169_private *tp,
rtl8169_rx_csum(skb, desc);
- pci_dma_sync_single_for_cpu(tp->pci_dev,
- le64_to_cpu(desc->addr), tp->rx_buf_sz,
- PCI_DMA_FROMDEVICE);
-
- if (rtl8169_try_rx_copy(&skb, pkt_size, desc,
- tp->rx_buf_sz, tp->align)) {
- pci_action = pci_unmap_single;
+ if (rtl8169_try_rx_copy(&skb, pkt_size, pdev, addr,
+ tp->align)) {
+ pci_dma_sync_single_for_device(pdev, addr,
+ pkt_size, PCI_DMA_FROMDEVICE);
+ rtl8169_mark_to_asic(desc, tp->rx_buf_sz);
+ } else {
+ pci_unmap_single(pdev, addr, pkt_size,
+ PCI_DMA_FROMDEVICE);
tp->Rx_skbuff[entry] = NULL;
}
- pci_action(tp->pci_dev, le64_to_cpu(desc->addr),
- tp->rx_buf_sz, PCI_DMA_FROMDEVICE);
-
skb_put(skb, pkt_size);
skb->protocol = eth_type_trans(skb, dev);
OpenPOWER on IntegriCloud