diff mbox series

[RFC,net-next,v2,2/7] net: ravb: Count packets instead of descriptors in RX path

Message ID 20240206091909.3191-3-paul.barker.ct@bp.renesas.com (mailing list archive)
State RFC
Delegated to: Netdev Maintainers
Headers show
Series Improve GbEth performance on Renesas RZ/G2L and related SoCs | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/apply fail Patch does not apply to net-next

Commit Message

Paul Barker Feb. 6, 2024, 9:19 a.m. UTC
The units of "work done" in the RX path should be packets instead of
descriptors, as large packets can be spread over multiple descriptors.

Signed-off-by: Paul Barker <paul.barker.ct@bp.renesas.com>
---
 drivers/net/ethernet/renesas/ravb_main.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

Comments

Sergey Shtylyov Feb. 10, 2024, 4:32 p.m. UTC | #1
On 2/6/24 12:19 PM, Paul Barker wrote:

> The units of "work done" in the RX path should be packets instead of
> descriptors, as large packets can be spread over multiple descriptors.

   Only for GbEth, right?
   This does look like a bug fix...

> Signed-off-by: Paul Barker <paul.barker.ct@bp.renesas.com>

[...]

MBR, Sergey
diff mbox series

Patch

diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index b18026575a2d..20193944c143 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -830,6 +830,7 @@  static int ravb_rx_gbeth(struct net_device *ndev, int budget, int q)
 	struct ravb_rx_desc *desc;
 	struct sk_buff *skb;
 	dma_addr_t dma_addr;
+	int rx_packets = 0;
 	u8  desc_status;
 	u16 pkt_len;
 	u8  die_dt;
@@ -841,9 +842,8 @@  static int ravb_rx_gbeth(struct net_device *ndev, int budget, int q)
 	limit = priv->dirty_rx[q] + priv->num_rx_ring[q] - priv->cur_rx[q];
 	stats = &priv->stats[q];
 
-	limit = min(limit, budget);
 	desc = &priv->gbeth_rx_ring[entry];
-	for (i = 0; i < limit && desc->die_dt != DT_FEMPTY; i++) {
+	for (i = 0; i < limit && rx_packets < budget && desc->die_dt != DT_FEMPTY; i++) {
 		/* Descriptor type must be checked before all other reads */
 		dma_rmb();
 		desc_status = desc->msc;
@@ -876,7 +876,7 @@  static int ravb_rx_gbeth(struct net_device *ndev, int budget, int q)
 				if (ndev->features & NETIF_F_RXCSUM)
 					ravb_rx_csum_gbeth(skb);
 				napi_gro_receive(&priv->napi[q], skb);
-				stats->rx_packets++;
+				rx_packets++;
 				stats->rx_bytes += pkt_len;
 				break;
 			case DT_FSTART:
@@ -906,7 +906,7 @@  static int ravb_rx_gbeth(struct net_device *ndev, int budget, int q)
 					ravb_rx_csum_gbeth(skb);
 				napi_gro_receive(&priv->napi[q],
 						 priv->rx_1st_skb);
-				stats->rx_packets++;
+				rx_packets++;
 				stats->rx_bytes += pkt_len;
 				break;
 			}
@@ -945,7 +945,8 @@  static int ravb_rx_gbeth(struct net_device *ndev, int budget, int q)
 		desc->die_dt = DT_FEMPTY;
 	}
 
-	return i;
+	stats->rx_packets += rx_packets;
+	return rx_packets;
 }
 
 /* Packet receive function for Ethernet AVB */
@@ -960,14 +961,14 @@  static int ravb_rx_rcar(struct net_device *ndev, int budget, int q)
 	struct sk_buff *skb;
 	dma_addr_t dma_addr;
 	struct timespec64 ts;
+	int rx_packets = 0;
 	u8  desc_status;
 	u16 pkt_len;
 	int limit;
 	int i;
 
-	limit = min(limit, budget);
 	desc = &priv->rx_ring[q][entry];
-	for (i = 0; i < limit && desc->die_dt != DT_FEMPTY; i++) {
+	for (i = 0; i < limit && rx_packets < budget && desc->die_dt != DT_FEMPTY; i++) {
 		/* Descriptor type must be checked before all other reads */
 		dma_rmb();
 		desc_status = desc->msc;
@@ -1018,7 +1019,7 @@  static int ravb_rx_rcar(struct net_device *ndev, int budget, int q)
 			if (ndev->features & NETIF_F_RXCSUM)
 				ravb_rx_csum(skb);
 			napi_gro_receive(&priv->napi[q], skb);
-			stats->rx_packets++;
+			rx_packets++;
 			stats->rx_bytes += pkt_len;
 		}
 
@@ -1054,7 +1055,8 @@  static int ravb_rx_rcar(struct net_device *ndev, int budget, int q)
 		desc->die_dt = DT_FEMPTY;
 	}
 
-	return i;
+	stats->rx_packets += rx_packets;
+	return rx_packets;
 }
 
 /* Packet receive function for Ethernet AVB */