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>
This commit is contained in:
Stephen Hemminger 2007-06-17 01:06:49 +02:00 committed by Jeff Garzik
parent 278667ba18
commit b449655ff5

View File

@ -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);