Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 58389
b: refs/heads/master
c: b449655
h: refs/heads/master
i:
  58387: eeac776
v: v3
  • Loading branch information
Stephen Hemminger authored and Jeff Garzik committed Jul 9, 2007
1 parent 9befa85 commit 07e9daa
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 278667ba186a23770b0dd23ccd26de56a8cc4ec2
refs/heads/master: b449655ff52ff8a29c66c5fc3fc03617e61182ee
56 changes: 28 additions & 28 deletions trunk/drivers/net/r8169.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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);

Expand Down

0 comments on commit 07e9daa

Please sign in to comment.