Skip to contentSkip to conversation

mvpp2 improvements in rx path

PATCH In review Matteo Croce 2 participants 5 messages Oct 24, 2019 – Oct 28, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v2 cover mvpp2 improvements in rx path

Refactor some code in the RX path to allow prefetching some data from the packet header. The first patch is only a refactor, the second one reduces the data synced, while the third one adds the prefetch.

The packet rate improvement with the second patch is very small (1606 => 1620 kpps), while the prefetch bumps it up by 14%: 1620 => 1853 kpps.

Matteo Croce (3):
mvpp2: refactor frame drop routine
mvpp2: sync only by the frame size
mvpp2: prefetch frame header

 .../net/ethernet/marvell/mvpp2/mvpp2_main.c   | 27 ++++++++++++-------
 1 file changed, 17 insertions(+), 10 deletions(-)
Signature · 1 line
2.21.0
#1 lore raw

PATCH v2 1/3 mvpp2: refactor frame drop routine

Move some code down to remove a backward goto.

---
 drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +9 -8
index 111b3b8239e1..33f327447b70 100644
@@ -2957,14 +2957,8 @@ static int mvpp2_rx(struct mvpp2_port *port, struct napi_struct *napi,
 		 * by the hardware, and the information about the buffer is
 		 * comprised by the RX descriptor.
 		 */
-		if (rx_status & MVPP2_RXD_ERR_SUMMARY) {
-err_drop_frame:
-			dev->stats.rx_errors++;
-			mvpp2_rx_error(port, rx_desc);
-			/* Return the buffer to the pool */
-			mvpp2_bm_pool_put(port, pool, dma_addr, phys_addr);
-			continue;
-		}
+		if (rx_status & MVPP2_RXD_ERR_SUMMARY)
+			goto err_drop_frame;
 
 		if (bm_pool->frag_size > PAGE_SIZE)
 			frag_size = 0;
@@ -2995,6 +2989,13 @@ static int mvpp2_rx(struct mvpp2_port *port, struct napi_struct *napi,
 		mvpp2_rx_csum(port, rx_status, skb);
 
 		napi_gro_receive(napi, skb);
+		continue;
+
+err_drop_frame:
+		dev->stats.rx_errors++;
+		mvpp2_rx_error(port, rx_desc);
+		/* Return the buffer to the pool */
+		mvpp2_bm_pool_put(port, pool, dma_addr, phys_addr);
 	}
 
 	if (rcvd_pkts) {
Signature · 1 line
2.21.0
#2 lore raw

PATCH v2 2/3 mvpp2: sync only the received frame

In reply to Matteo Croce

In the RX path we always sync against the maximum frame size for that pool. Do the DMA sync and the unmap separately, so we can only sync by the size of the received frame.

---
 drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +7 -2
index 33f327447b70..15818e1d6b04 100644
@@ -2960,6 +2960,10 @@ static int mvpp2_rx(struct mvpp2_port *port, struct napi_struct *napi,
 		if (rx_status & MVPP2_RXD_ERR_SUMMARY)
 			goto err_drop_frame;
 
+		dma_sync_single_for_cpu(dev->dev.parent, dma_addr,
+					rx_bytes + MVPP2_MH_SIZE,
+					DMA_FROM_DEVICE);
+
 		if (bm_pool->frag_size > PAGE_SIZE)
 			frag_size = 0;
 		else
@@ -2977,8 +2981,9 @@ static int mvpp2_rx(struct mvpp2_port *port, struct napi_struct *napi,
 			goto err_drop_frame;
 		}
 
-		dma_unmap_single(dev->dev.parent, dma_addr,
-				 bm_pool->buf_size, DMA_FROM_DEVICE);
+		dma_unmap_single_attrs(dev->dev.parent, dma_addr,
+				       bm_pool->buf_size, DMA_FROM_DEVICE,
+				       DMA_ATTR_SKIP_CPU_SYNC);
 
 		rcvd_pkts++;
 		rcvd_bytes += rx_bytes;
Signature · 1 line
2.21.0
#3 lore raw

PATCH v2 3/3 mvpp2: prefetch frame header

In reply to Matteo Croce

When receiving traffic, eth_type_trans() is high up on the perf top list, because it's the first function which access the packet data.

Move the DMA unmap a bit higher, and put a prefetch just after it, so we have more time to load the data into the cache.

The packet rate increase is about 14% with a tc drop test: 1620 => 1853 kpps

---
 drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +1 -0
index 15818e1d6b04..a55de943d5cb 100644
@@ -2963,6 +2963,7 @@ static int mvpp2_rx(struct mvpp2_port *port, struct napi_struct *napi,
 		dma_sync_single_for_cpu(dev->dev.parent, dma_addr,
 					rx_bytes + MVPP2_MH_SIZE,
 					DMA_FROM_DEVICE);
+		prefetch(data);
 
 		if (bm_pool->frag_size > PAGE_SIZE)
 			frag_size = 0;
Signature · 1 line
2.21.0
maintainer
#4 lore raw
In reply to Matteo Croce

From: Matteo Croce <[email protected]>
Date: Thu, 24 Oct 2019 19:24:55 +0200

Quoted 6 lines

Refactor some code in the RX path to allow prefetching some data from the packet header. The first patch is only a refactor, the second one reduces the data synced, while the third one adds the prefetch.

The packet rate improvement with the second patch is very small (1606 => 1620 kpps), while the prefetch bumps it up by 14%: 1620 => 1853 kpps.

Series applied to net-next, thanks Matteo.