Commit b449655f authored by Stephen Hemminger's avatar Stephen Hemminger Committed by Jeff Garzik

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: default avatarStephen Hemminger <shemminger@linux-foundation.org>
Signed-off-by: default avatarFrancois Romieu <romieu@fr.zoreil.com>
Cc: Edward Hsu <edward_hsu@realtek.com.tw>
parent 278667ba
...@@ -2483,25 +2483,27 @@ static inline void rtl8169_rx_csum(struct sk_buff *skb, struct RxDesc *desc) ...@@ -2483,25 +2483,27 @@ static inline void rtl8169_rx_csum(struct sk_buff *skb, struct RxDesc *desc)
skb->ip_summed = CHECKSUM_NONE; skb->ip_summed = CHECKSUM_NONE;
} }
static inline int rtl8169_try_rx_copy(struct sk_buff **sk_buff, int pkt_size, static inline bool rtl8169_try_rx_copy(struct sk_buff **sk_buff, int pkt_size,
struct RxDesc *desc, int rx_buf_sz, struct pci_dev *pdev, dma_addr_t addr,
unsigned int align) unsigned int align)
{ {
int ret = -1; struct sk_buff *skb;
bool done = false;
if (pkt_size < rx_copybreak) { if (pkt_size >= rx_copybreak)
struct sk_buff *skb; goto out;
skb = dev_alloc_skb(pkt_size + align); skb = dev_alloc_skb(pkt_size + align);
if (skb) { if (!skb)
skb_reserve(skb, (align - 1) & (unsigned long)skb->data); goto out;
skb_copy_from_linear_data(*sk_buff, skb->data, pkt_size);
*sk_buff = skb; pci_dma_sync_single_for_cpu(pdev, addr, pkt_size, PCI_DMA_FROMDEVICE);
rtl8169_mark_to_asic(desc, rx_buf_sz); skb_reserve(skb, (align - 1) & (unsigned long)skb->data);
ret = 0; skb_copy_from_linear_data(*sk_buff, skb->data, pkt_size);
} *sk_buff = skb;
} done = true;
return ret; out:
return done;
} }
static int static int
...@@ -2547,9 +2549,9 @@ rtl8169_rx_interrupt(struct net_device *dev, struct rtl8169_private *tp, ...@@ -2547,9 +2549,9 @@ rtl8169_rx_interrupt(struct net_device *dev, struct rtl8169_private *tp,
rtl8169_mark_to_asic(desc, tp->rx_buf_sz); rtl8169_mark_to_asic(desc, tp->rx_buf_sz);
} else { } else {
struct sk_buff *skb = tp->Rx_skbuff[entry]; struct sk_buff *skb = tp->Rx_skbuff[entry];
dma_addr_t addr = le64_to_cpu(desc->addr);
int pkt_size = (status & 0x00001FFF) - 4; int pkt_size = (status & 0x00001FFF) - 4;
void (*pci_action)(struct pci_dev *, dma_addr_t, struct pci_dev *pdev = tp->pci_dev;
size_t, int) = pci_dma_sync_single_for_device;
/* /*
* The driver does not support incoming fragmented * The driver does not support incoming fragmented
...@@ -2565,19 +2567,17 @@ rtl8169_rx_interrupt(struct net_device *dev, struct rtl8169_private *tp, ...@@ -2565,19 +2567,17 @@ rtl8169_rx_interrupt(struct net_device *dev, struct rtl8169_private *tp,
rtl8169_rx_csum(skb, desc); rtl8169_rx_csum(skb, desc);
pci_dma_sync_single_for_cpu(tp->pci_dev, if (rtl8169_try_rx_copy(&skb, pkt_size, pdev, addr,
le64_to_cpu(desc->addr), tp->rx_buf_sz, tp->align)) {
PCI_DMA_FROMDEVICE); pci_dma_sync_single_for_device(pdev, addr,
pkt_size, PCI_DMA_FROMDEVICE);
if (rtl8169_try_rx_copy(&skb, pkt_size, desc, rtl8169_mark_to_asic(desc, tp->rx_buf_sz);
tp->rx_buf_sz, tp->align)) { } else {
pci_action = pci_unmap_single; pci_unmap_single(pdev, addr, pkt_size,
PCI_DMA_FROMDEVICE);
tp->Rx_skbuff[entry] = NULL; 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_put(skb, pkt_size);
skb->protocol = eth_type_trans(skb, dev); skb->protocol = eth_type_trans(skb, dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment