Skip to contentSkip to conversation

bnx2: Add GRO support.

PATCH Superseded Michael Chan 3 participants 5 messages May 5, 2010

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 bnx2: Add GRO support.

---
 drivers/net/bnx2.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/bnx2.c +2 -2
index ab26bbc..6ad3184 100644
@@ -3207,10 +3207,10 @@ bnx2_rx_int(struct bnx2 *bp, struct bnx2_napi *bnapi, int budget)
 
 #ifdef BCM_VLAN
 		if (hw_vlan)
-			vlan_hwaccel_receive_skb(skb, bp->vlgrp, vtag);
+			vlan_gro_receive(&bnapi->napi, bp->vlgrp, vtag, skb);
 		else
 #endif
-			netif_receive_skb(skb);
+			napi_gro_receive(&bnapi->napi, skb);
 
 		rx_pkt++;
 
Signature · 1 line
1.6.4.GIT
#1 lore raw

PATCH 2/3 bnx2: Add prefetches to rx path.

Add prefetches of the skb and the next rx descriptor to speed up rx path.

---
 drivers/net/bnx2.c |   12 +++++++++---
 drivers/net/bnx2.h |    1 +
 2 files changed, 10 insertions(+), 3 deletions(-)
drivers/net/bnx2.c +9 -3
index 6ad3184..cdee29b 100644
@@ -2719,6 +2719,7 @@ bnx2_alloc_rx_skb(struct bnx2 *bp, struct bnx2_rx_ring_info *rxr, u16 index)
 	}
 
 	rx_buf->skb = skb;
+	rx_buf->desc = (struct l2_fhdr *) skb->data;
 	dma_unmap_addr_set(rx_buf, mapping, mapping);
 
 	rxbd->rx_bd_haddr_hi = (u64) mapping >> 32;
@@ -2941,6 +2942,7 @@ bnx2_reuse_rx_skb(struct bnx2 *bp, struct bnx2_rx_ring_info *rxr,
 	rxr->rx_prod_bseq += bp->rx_buf_use_size;
 
 	prod_rx_buf->skb = skb;
+	prod_rx_buf->desc = (struct l2_fhdr *) skb->data;
 
 	if (cons == prod)
 		return;
@@ -3086,7 +3088,7 @@ bnx2_rx_int(struct bnx2 *bp, struct bnx2_napi *bnapi, int budget)
 	while (sw_cons != hw_cons) {
 		unsigned int len, hdr_len;
 		u32 status;
-		struct sw_bd *rx_buf;
+		struct sw_bd *rx_buf, *next_rx_buf;
 		struct sk_buff *skb;
 		dma_addr_t dma_addr;
 		u16 vtag = 0;
@@ -3097,7 +3099,11 @@ bnx2_rx_int(struct bnx2 *bp, struct bnx2_napi *bnapi, int budget)
 
 		rx_buf = &rxr->rx_buf_ring[sw_ring_cons];
 		skb = rx_buf->skb;
+		prefetch(skb);
 
+		next_rx_buf =
+			&rxr->rx_buf_ring[RX_RING_IDX(NEXT_RX_BD(sw_cons))];
+		prefetch(next_rx_buf->desc);
 		rx_buf->skb = NULL;
 
 		dma_addr = dma_unmap_addr(rx_buf, mapping);
@@ -3106,7 +3112,7 @@ bnx2_rx_int(struct bnx2 *bp, struct bnx2_napi *bnapi, int budget)
 			BNX2_RX_OFFSET + BNX2_RX_COPY_THRESH,
 			PCI_DMA_FROMDEVICE);
 
-		rx_hdr = (struct l2_fhdr *) skb->data;
+		rx_hdr = rx_buf->desc;
 		len = rx_hdr->l2_fhdr_pkt_len;
 		status = rx_hdr->l2_fhdr_status;
 
@@ -5764,7 +5770,7 @@ bnx2_run_loopback(struct bnx2 *bp, int loopback_mode)
 	rx_buf = &rxr->rx_buf_ring[rx_start_idx];
 	rx_skb = rx_buf->skb;
 
-	rx_hdr = (struct l2_fhdr *) rx_skb->data;
+	rx_hdr = rx_buf->desc;
 	skb_reserve(rx_skb, BNX2_RX_OFFSET);
 
 	pci_dma_sync_single_for_cpu(bp->pdev,
drivers/net/bnx2.h +1 -0
index ab34a5d..dd35bd0 100644
@@ -6551,6 +6551,7 @@ struct l2_fhdr {
 
 struct sw_bd {
 	struct sk_buff		*skb;
+	struct l2_fhdr		*desc;
 	DEFINE_DMA_UNMAP_ADDR(mapping);
 };
 
Signature · 1 line
1.6.4.GIT
#2 lore raw

Re: [PATCH -next 2/3] bnx2: Add prefetches to rx path.

Quoted 39 lines · Michael Chan

Add prefetches of the skb and the next rx descriptor to speed up rx path.

---
 drivers/net/bnx2.c |   12 +++++++++---
 drivers/net/bnx2.h |    1 +
 2 files changed, 10 insertions(+), 3 deletions(-)
drivers/net/bnx2.c +3 -1
index 6ad3184..cdee29b 100644
@@ -2719,6 +2719,7 @@ bnx2_alloc_rx_skb(struct bnx2 *bp, struct bnx2_rx_ring_info *rxr, u16 index)
 	}
 
 	rx_buf->skb = skb;
+	rx_buf->desc = (struct l2_fhdr *) skb->data;
 	dma_unmap_addr_set(rx_buf, mapping, mapping);
 
 	rxbd->rx_bd_haddr_hi = (u64) mapping >> 32;
@@ -2941,6 +2942,7 @@ bnx2_reuse_rx_skb(struct bnx2 *bp, struct bnx2_rx_ring_info *rxr,
 	rxr->rx_prod_bseq += bp->rx_buf_use_size;
 
 	prod_rx_buf->skb = skb;
+	prod_rx_buf->desc = (struct l2_fhdr *) skb->data;
 
 	if (cons == prod)
 		return;
@@ -3086,7 +3088,7 @@ bnx2_rx_int(struct bnx2 *bp, struct bnx2_napi *bnapi, int budget)
 	while (sw_cons != hw_cons) {
 		unsigned int len, hdr_len;
 		u32 status;
-		struct sw_bd *rx_buf;
+		struct sw_bd *rx_buf, *next_rx_buf;
 		struct sk_buff *skb;
 		dma_addr_t dma_addr;
 		u16 vtag = 0;

drivers/net/bnx2.c bnx2_rx_int(struct bnx2 *bp, struct bnx2_napi *bnapi, int budget) · line 3102

Quoted 4 lines
drivers/net/bnx2.c +1 -0
@@ -3097,7 +3099,11 @@ bnx2_rx_int(struct bnx2 *bp, struct bnx2_napi *bnapi, int budget)
 
 		rx_buf = &rxr->rx_buf_ring[sw_ring_cons];
 		skb = rx_buf->skb;
+		prefetch(skb);

why not a prefetchw() ?

drivers/net/bnx2.c bnx2_rx_int(struct bnx2 *bp, struct bnx2_napi *bnapi, int budget) · line 3106

Quoted 4 lines
drivers/net/bnx2.c +3 -0
+		next_rx_buf =
+			&rxr->rx_buf_ring[RX_RING_IDX(NEXT_RX_BD(sw_cons))];
+		prefetch(next_rx_buf->desc);

So cpu is allowed to start a memory transaction on next_skb->data, while not yes DMA unmapped ?

Quoted 26 lines
drivers/net/bnx2.c +2 -2
 		rx_buf->skb = NULL;
 
 		dma_addr = dma_unmap_addr(rx_buf, mapping);
@@ -3106,7 +3112,7 @@ bnx2_rx_int(struct bnx2 *bp, struct bnx2_napi *bnapi, int budget)
 			BNX2_RX_OFFSET + BNX2_RX_COPY_THRESH,
 			PCI_DMA_FROMDEVICE);
 
-		rx_hdr = (struct l2_fhdr *) skb->data;
+		rx_hdr = rx_buf->desc;
 		len = rx_hdr->l2_fhdr_pkt_len;
 		status = rx_hdr->l2_fhdr_status;
 
@@ -5764,7 +5770,7 @@ bnx2_run_loopback(struct bnx2 *bp, int loopback_mode)
 	rx_buf = &rxr->rx_buf_ring[rx_start_idx];
 	rx_skb = rx_buf->skb;
 
-	rx_hdr = (struct l2_fhdr *) rx_skb->data;
+	rx_hdr = rx_buf->desc;
 	skb_reserve(rx_skb, BNX2_RX_OFFSET);
 
 	pci_dma_sync_single_for_cpu(bp->pdev,
drivers/net/bnx2.h +0 -0
index ab34a5d..dd35bd0 100644

drivers/net/bnx2.h struct l2_fhdr { · line 6557

Quoted 7 lines
drivers/net/bnx2.h +1 -0
@@ -6551,6 +6551,7 @@ struct l2_fhdr {
 
 struct sw_bd {
 	struct sk_buff		*skb;
+	struct l2_fhdr		*desc;
 	DEFINE_DMA_UNMAP_ADDR(mapping);
 };
 

It seems there are two parts in this patch, one caching skb->data in sw_bd, and prefetches...

maintainer
#4 lore raw
In reply to Michael Chan

From: "Michael Chan" <[email protected]>
Date: Tue, 4 May 2010 22:21:44 -0700

Quoted 2 lines

Please turn it on by default by setting NETIF_F_GRO in your probe routine.

I don't want a precedent started where we have drivers that support GRO but don't enable it by default. If there are some performance degradations, we fix them instead of deferring the issue by not enabling it by default in some awkward selection of drivers.

#3 lore raw

Re: [PATCH -next 2/3] bnx2: Add prefetches to rx path.

In reply to Eric Dumazet
Quoted 8 lines · Eric Dumazet

Review bnx2_rx_int(struct bnx2 *bp, struct

Quoted 1 line
(quoted diff) +0 -0
@@ -3097,7 +3099,11 @@ bnx2_rx_int(struct bnx2 *bp, struct

bnx2_napi *bnapi, int budget)

drivers/net/bnx2.c bnx2_rx_int(struct bnx2 *bp, struct bnx2_napi *bnapi, int budget) · line 3102

Quoted 4 lines
drivers/net/bnx2.c +1 -0
            rx_buf = &rxr->rx_buf_ring[sw_ring_cons];
            skb = rx_buf->skb;
+           prefetch(skb);

why not a prefetchw() ?

Yes, didn't know there was a prefetchw() before you pointed it out.

Quoted 10 lines

Review bnx2_rx_int(struct bnx2 *bp, struct · line 3103

Quoted 4 lines
(quoted diff) +2 -0
+           next_rx_buf =
+

&rxr->rx_buf_ring[RX_RING_IDX(NEXT_RX_BD(sw_cons))];

drivers/net/bnx2.c bnx2_rx_int(struct bnx2 *bp, struct bnx2_napi *bnapi, int budget) · line 3106

Quoted 1 line
drivers/net/bnx2.c +1 -0
+           prefetch(next_rx_buf->desc);

So cpu is allowed to start a memory transaction on next_skb->data, while
not yes DMA unmapped ?

Very good point. The prefetch() will not work and will be wasted on systems that have pci_dma_sync_...() defined. I think we can skip the prefetch if pci_dma_sync_...() is defined. The logic to determine if the next descriptor is ready, dma_sync it, and prefetch it will be complicated and we may end up not gaining any performance in the end.

What do you think? Thanks.