Patchwork [15/21] net: tulip/de2104x: use common rx_copybreak handling [strict refill!]

login
register
mail settings
Submitter Michał Mirosław
Date July 9, 2011, 5:17 p.m.
Message ID <29374e542d6211f31b9ed0571a60b795f4aed1bb.1310229312.git.mirq-linux@rere.qmqm.pl>
Download mbox | patch
Permalink /patch/104008/
State Superseded
Delegated to: David Miller
Headers show

Comments

Michał Mirosław - July 9, 2011, 5:17 p.m.
Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
 drivers/net/tulip/de2104x.c |   38 +++++++++-----------------------------
 1 files changed, 9 insertions(+), 29 deletions(-)
françois romieu - July 9, 2011, 10:31 p.m.
Michał Mirosław <mirq-linux@rere.qmqm.pl> :
[...]
> diff --git a/drivers/net/tulip/de2104x.c b/drivers/net/tulip/de2104x.c
> index ce90efc..80a34b6 100644
> --- a/drivers/net/tulip/de2104x.c
> +++ b/drivers/net/tulip/de2104x.c
> @@ -432,42 +431,22 @@ static void de_rx (struct de_private *de)
>  			goto rx_next;
>  		}
>  
> -		copying_skb = (len <= rx_copybreak);
> -
>  		netif_dbg(de, rx_status, de->dev,
>  			  "rx slot %d status 0x%x len %d copying? %d\n",
> -			  rx_tail, status, len, copying_skb);
> +			  rx_tail, status, len, len <= rx_copybreak);
>  
> -		buflen = copying_skb ? (len + RX_OFFSET) : de->rx_buf_sz;
> -		copy_skb = dev_alloc_skb (buflen);
> -		if (unlikely(!copy_skb)) {
> +		skb = dev_skb_finish_rx_dma_refill(&de->rx_skb[rx_tail].skb,
> +			len, rx_copybreak, 0, RX_OFFSET,
> +			&de->pdev->dev, &mapping, de->rx_buf_sz);
> +		de->rx_skb[rx_tail].mapping = mapping;
> +
> +		if (unlikely(!skb)) {

s/skb/de->rx_skb[rx_tail].skb/

Patch

diff --git a/drivers/net/tulip/de2104x.c b/drivers/net/tulip/de2104x.c
index ce90efc..80a34b6 100644
--- a/drivers/net/tulip/de2104x.c
+++ b/drivers/net/tulip/de2104x.c
@@ -409,8 +409,7 @@  static void de_rx (struct de_private *de)
 	while (--rx_work) {
 		u32 status, len;
 		dma_addr_t mapping;
-		struct sk_buff *skb, *copy_skb;
-		unsigned copying_skb, buflen;
+		struct sk_buff *skb;
 
 		skb = de->rx_skb[rx_tail].skb;
 		BUG_ON(!skb);
@@ -432,42 +431,22 @@  static void de_rx (struct de_private *de)
 			goto rx_next;
 		}
 
-		copying_skb = (len <= rx_copybreak);
-
 		netif_dbg(de, rx_status, de->dev,
 			  "rx slot %d status 0x%x len %d copying? %d\n",
-			  rx_tail, status, len, copying_skb);
+			  rx_tail, status, len, len <= rx_copybreak);
 
-		buflen = copying_skb ? (len + RX_OFFSET) : de->rx_buf_sz;
-		copy_skb = dev_alloc_skb (buflen);
-		if (unlikely(!copy_skb)) {
+		skb = dev_skb_finish_rx_dma_refill(&de->rx_skb[rx_tail].skb,
+			len, rx_copybreak, 0, RX_OFFSET,
+			&de->pdev->dev, &mapping, de->rx_buf_sz);
+		de->rx_skb[rx_tail].mapping = mapping;
+
+		if (unlikely(!skb)) {
 			de->net_stats.rx_dropped++;
 			drop = 1;
 			rx_work = 100;
 			goto rx_next;
 		}
 
-		if (!copying_skb) {
-			pci_unmap_single(de->pdev, mapping,
-					 buflen, PCI_DMA_FROMDEVICE);
-			skb_put(skb, len);
-
-			mapping =
-			de->rx_skb[rx_tail].mapping =
-				pci_map_single(de->pdev, copy_skb->data,
-					       buflen, PCI_DMA_FROMDEVICE);
-			de->rx_skb[rx_tail].skb = copy_skb;
-		} else {
-			pci_dma_sync_single_for_cpu(de->pdev, mapping, len, PCI_DMA_FROMDEVICE);
-			skb_reserve(copy_skb, RX_OFFSET);
-			skb_copy_from_linear_data(skb, skb_put(copy_skb, len),
-						  len);
-			pci_dma_sync_single_for_device(de->pdev, mapping, len, PCI_DMA_FROMDEVICE);
-
-			/* We'll reuse the original ring buffer. */
-			skb = copy_skb;
-		}
-
 		skb->protocol = eth_type_trans (skb, de->dev);
 
 		de->net_stats.rx_packets++;
@@ -1292,6 +1271,7 @@  static int de_refill_rx (struct de_private *de)
 		de->rx_skb[i].mapping = pci_map_single(de->pdev,
 			skb->data, de->rx_buf_sz, PCI_DMA_FROMDEVICE);
 		de->rx_skb[i].skb = skb;
+		skb_reserve(skb, RX_OFFSET);
 
 		de->rx_ring[i].opts1 = cpu_to_le32(DescOwn);
 		if (i == (DE_RX_RING_SIZE - 1))