From patchwork Wed Feb 14 15:12:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Barker X-Patchwork-Id: 200985 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp1281171dyb; Wed, 14 Feb 2024 07:14:05 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXLOCAncaoI0xQMkEykUPfbAMsM3iWztjKTR8Pa+a7kcI1JhpjqSUYX4N4v30hHDmNGgeXBbQ8Zw8JtSLPsmwXZCrZXYg== X-Google-Smtp-Source: AGHT+IGE8+Q0UvdvwwflYdB3tMObQyjb6mZ2fgbV2Pe9FEzMOVpH7spHysutrUUv9xOBBUDmbXhi X-Received: by 2002:a05:620a:208c:b0:787:2b1f:1c50 with SMTP id e12-20020a05620a208c00b007872b1f1c50mr1816618qka.52.1707923645601; Wed, 14 Feb 2024 07:14:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707923645; cv=pass; d=google.com; s=arc-20160816; b=PGyRrGRQJJ5miEQ9J6qPrFlvr9AMRi/J4P0faWx+FrC01VFagIMhsoQWxAiWNkK7tG AGmBkS2FmkZWVp5xUCjvfF5WalTTygE2BTZKsZ/hq+Q9971t8wZ9qP5oXPI9ZH+yKm/5 IV7/IrUkaleVqYQoEDxw2gXsM+aUndZbRWCyHPoE3Tk0oj5yKUtU6Ej0EM0nGg0QzMV5 HbFgC76K1PhTYU79D30wd/SNOw1qgkr+TirCE4k1dnQxuGO3z+uEtvKdHSV/PBN2oT7R z4RgwfOhs40dsSllbgtjW+14gPLqZx9lXiJaABKfp6fwOrG/9BDfvwZ1aQyGu3nzA6+1 0MHg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=dFTgvrIhJTbaB1TvUnh5BgEr7hTnv79wTwL1KxhUU9o=; fh=guzLatzNGqKpLWIpjFDXV5cr0m0FXG6OUsNeRWIiCfE=; b=r5HzkKtQ+0Jwf8l0M/X40v9GdRVeAuwWGh4zybpkdRFb57frnQJ39ZGQvht/1r2taR sMkJ+VUtkLyrxXCTIyMblBBIwAgfZwlEzVK86x2uIVd5BnebpZVAMm2RJH1f5Cbhdtao DWepxUjY0lA2OPzLgFMlKhp+spuyNLhxAL0zwjonQ7Z2HwmXxeT32rILXUZtqbWJ3O3I c1Wa6kW2z8VCB+RhkQAxt5M8I4CwEa30Nrh7ii8PEn3vjNnN38HiwpqUWkwHNlD61OnY xP48n8ruOazYw/5oKNV9dogf06+yyOlpaS9Eegk4ckqPeUutPpYLQ5jc42G7PuFa29Q/ Go+A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=bp.renesas.com dmarc=pass fromdomain=bp.renesas.com); spf=pass (google.com: domain of linux-kernel+bounces-65396-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65396-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=renesas.com X-Forwarded-Encrypted: i=2; AJvYcCXnXFg93kOisVdU1qwsRKv4+haAlEc8dDfromWm/NWDeClxrDTNvTBcHteb3uvVzGKQovYfhzz2VeOLU+WYIUWlKJNYJQ== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id o2-20020a05620a2a0200b0078727f14a18si2419302qkp.94.2024.02.14.07.14.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 07:14:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-65396-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=bp.renesas.com dmarc=pass fromdomain=bp.renesas.com); spf=pass (google.com: domain of linux-kernel+bounces-65396-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65396-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=renesas.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 65E051C222FB for ; Wed, 14 Feb 2024 15:14:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 62CEA5D8E7; Wed, 14 Feb 2024 15:12:58 +0000 (UTC) Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E30675D461; Wed, 14 Feb 2024 15:12:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.160.252.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707923576; cv=none; b=WMv0exIe3+qH2dx3vKXKnM4Qmwx0w7FhMef0zPSEo/AUO6IjS4Oy/87KazvTkBlrFBRU1kJe9nsfKg4FxOwH/XgdQFabdsjQDR0PbgFCEz/W8/U7+W8wRnPNt6EljeMMpBDy7jkhtYlmFpBgrfCnheBwMiZ7hD7GEF+g0fggHfY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707923576; c=relaxed/simple; bh=Fm4f8S9D3dClviZZAq026dnWtTRMEFW8SuKQ8DQrHI4=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=G9G7Zb590v3xxPYQq5rsa8eHP0GPnBp1mDEEIpoPKZnU5jwFG17yRhARuMqJ9WHq6VE7yf7WkRNL5czMV9udZTq7e+HrvTXTygAlUc92Zq2GfxNhGBZwk0q3BYas7zGPzExdkXQb/DY4WvSBFql4kZkEnuoaC8J+h6zhztMCat4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=bp.renesas.com; spf=pass smtp.mailfrom=bp.renesas.com; arc=none smtp.client-ip=210.160.252.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=bp.renesas.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bp.renesas.com X-IronPort-AV: E=Sophos;i="6.06,159,1705330800"; d="scan'208";a="193932772" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie5.idc.renesas.com with ESMTP; 15 Feb 2024 00:12:46 +0900 Received: from renesas-deb12.cephei.uk (unknown [10.226.93.104]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 4785B4005460; Thu, 15 Feb 2024 00:12:41 +0900 (JST) From: Paul Barker To: Sergey Shtylyov , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Paul Barker , Yoshihiro Shimoda , Wolfram Sang , Nikita Yushchenko , =?utf-8?q?Uwe_Kleine-K?= =?utf-8?q?=C3=B6nig?= , Claudiu Beznea , Lad Prabhakar , Biju Das , netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net v3] net: ravb: Count packets instead of descriptors in GbEth RX path Date: Wed, 14 Feb 2024 15:12:04 +0000 Message-Id: <20240214151204.2976-1-paul.barker.ct@bp.renesas.com> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790887744647026443 X-GMAIL-MSGID: 1790887744647026443 The units of "work done" in the RX path should be packets instead of descriptors, as large packets can be spread over multiple descriptors. Fixes: 1c59eb678cbd ("ravb: Fillup ravb_rx_gbeth() stub") Signed-off-by: Paul Barker Reviewed-by: Sergey Shtylyov --- This patch has been broken out from my previous series "Improve GbEth performance on Renesas RZ/G2L and related SoCs" and submitted as a bugfix as requested by Sergey. I've labeled it as 'v3' so the ordering is clear. Remaining patches from the series will follow once we've done gPTP testing. drivers/net/ethernet/renesas/ravb_main.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 0e3731f50fc2..f7566cfa45ca 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -772,29 +772,25 @@ static bool ravb_rx_gbeth(struct net_device *ndev, int *quota, int q) struct ravb_rx_desc *desc; struct sk_buff *skb; dma_addr_t dma_addr; + int rx_packets = 0; u8 desc_status; - int boguscnt; u16 pkt_len; u8 die_dt; int entry; int limit; + int i; entry = priv->cur_rx[q] % priv->num_rx_ring[q]; - boguscnt = priv->dirty_rx[q] + priv->num_rx_ring[q] - priv->cur_rx[q]; + limit = priv->dirty_rx[q] + priv->num_rx_ring[q] - priv->cur_rx[q]; stats = &priv->stats[q]; - boguscnt = min(boguscnt, *quota); - limit = boguscnt; desc = &priv->gbeth_rx_ring[entry]; - while (desc->die_dt != DT_FEMPTY) { + for (i = 0; i < limit && rx_packets < *quota && desc->die_dt != DT_FEMPTY; i++) { /* Descriptor type must be checked before all other reads */ dma_rmb(); desc_status = desc->msc; pkt_len = le16_to_cpu(desc->ds_cc) & RX_DS; - if (--boguscnt < 0) - break; - /* We use 0-byte descriptors to mark the DMA mapping errors */ if (!pkt_len) continue; @@ -820,7 +816,7 @@ static bool ravb_rx_gbeth(struct net_device *ndev, int *quota, int q) skb_put(skb, pkt_len); skb->protocol = eth_type_trans(skb, ndev); napi_gro_receive(&priv->napi[q], skb); - stats->rx_packets++; + rx_packets++; stats->rx_bytes += pkt_len; break; case DT_FSTART: @@ -848,7 +844,7 @@ static bool ravb_rx_gbeth(struct net_device *ndev, int *quota, int q) eth_type_trans(priv->rx_1st_skb, ndev); napi_gro_receive(&priv->napi[q], priv->rx_1st_skb); - stats->rx_packets++; + rx_packets++; stats->rx_bytes += pkt_len; break; } @@ -887,9 +883,9 @@ static bool ravb_rx_gbeth(struct net_device *ndev, int *quota, int q) desc->die_dt = DT_FEMPTY; } - *quota -= limit - (++boguscnt); - - return boguscnt <= 0; + stats->rx_packets += rx_packets; + *quota -= rx_packets; + return *quota == 0; } /* Packet receive function for Ethernet AVB */