From patchwork Tue Feb 6 09:19: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: 197279 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1417656dyb; Tue, 6 Feb 2024 01:21:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IGzbEANjkKG1ym4Y248Kz74rwiGazZ+f8qAzryMtZxYSzvG6yz8rIG508i+YvZrgOgrQHxF X-Received: by 2002:a17:902:7444:b0:1d9:a601:798b with SMTP id e4-20020a170902744400b001d9a601798bmr1027722plt.54.1707211276068; Tue, 06 Feb 2024 01:21:16 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707211276; cv=pass; d=google.com; s=arc-20160816; b=UULVIyYz3v337GrTeF45dApXirdqXeenx9ZhccbFj2wSazv+/GpWKNcCw0O5gndQqQ TDnkB6/iDy+Vfhna4WQe+VdgzgdBlMA5SoYwTMwPBJ3bLyfwQ5boqFBMxkK1e/JGbUfE Ei67zhnSKHawuczhMqdxYwcli2NylpEOsChpImoJrpGSW8QITZ1uLjx86JbORhZjEsrj lexzYHNfZDojdTQQkXhtpzbQQR9RYCt/PE4OAVsGSApyW/YLwteXa6VOr+iwqzNjRLnW khRyG3je7cMTUvRGmqEMIZb9aNmsuXjdByhfGHxaCFpVaF+ffmt0mE4GcHYvZWLzL3Q1 T3Aw== 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:references:in-reply-to:message-id :date:subject:cc:to:from; bh=S3zxoYGpz2NrENNychu5/9bu+zGlZsdD+LmZxeunRLY=; fh=639wv5ok+E1YIh8SSPvoTsm6LO+1lNV0uELLPTa+LtI=; b=nzsrruWzgA/hIwKIU9g1UuVauuEckQllxtXeO/jFwLh4lwZMxl78NP3DlaAcuftzP0 Nh3C9FpbUUdjz/at3fK9M5LXaqJfA2JGSf5DludHHCnQxgT7w+v2g1/9HC0lOHI0DHdK GDHDsRWHS+qjPx7e+Kn6ctEnPQUc6S4ZZ10Uyk36qt2lHXOZtF1orNeFsOC6N8uvx06C Jh5/5WDWp7D1K5YMfDQlJWUs3zrlt7wpnaUta2ODwOeuUFZkZFoLczteRpuBacjQSDh1 yRNm4/9kJqynmvCzVIXWwqiTH011E7kRZO/IAkVDLJWOfBIyhfowGitUuGop0v8aSfMN SMUg==; 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-54572-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-54572-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=renesas.com X-Forwarded-Encrypted: i=1; AJvYcCWt92N84J6HpXuMwXeGyW9dxHmHuetc0F/6uQqew7GO4M3K4HKAWLwpmzApfp7X5vHE2zy6F/aRjVWAq0p2X1dn/hhnVg== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id p14-20020a170902e74e00b001d098bf0df8si1360882plf.612.2024.02.06.01.21.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 01:21:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-54572-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::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-54572-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-54572-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id DD976B23EAD for ; Tue, 6 Feb 2024 09:20:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6D89312E1ED; Tue, 6 Feb 2024 09:19:37 +0000 (UTC) Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E83CC12D164; Tue, 6 Feb 2024 09:19:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.160.252.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707211175; cv=none; b=u88ylkjkO6w6UgaivNg7UH3RD89la/KLN94+cKcFJwedtm0iGqR1jxwv/hhOqkNlAayEDRQYyLuFmyNygskSId9kAmyw+jpmSb3bEHN30yt1qdJ9Zds7gETipyBuAIx4HFghQyKEFrVYAVY7CvCnYAk5BMfWPGDJeW4Y28SixnM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707211175; c=relaxed/simple; bh=+nLdJAeGVZo7YdSrELcAYK8JRq4WJ5ippaKl609J+3I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OZmXMA8pl9cTt8B1mpsrMYib1hC7LVw9VzQHegCXBkhB6GlVf/peBEY/uvdI6RExPeWsNA+Vfphh/lTUkU68OfU/DjjnSr6+wQ34+ZyMZasSnhIdcbnocFOYXEYHihl+EseSQnIsQZbVSXhejzEYzq49tuemylTJg9wIDoBsDnY= 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.172 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.05,246,1701097200"; d="scan'208";a="196934627" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 06 Feb 2024 18:19:26 +0900 Received: from GBR-5CG2373LKG.adwin.renesas.com (unknown [10.226.93.63]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id BA8EE41B8EF7; Tue, 6 Feb 2024 18:19:22 +0900 (JST) From: Paul Barker To: Sergey Shtylyov , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Paul Barker , Yoshihiro Shimoda , Wolfram Sang , netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH net-next v2 2/7] net: ravb: Count packets instead of descriptors in RX path Date: Tue, 6 Feb 2024 09:19:04 +0000 Message-Id: <20240206091909.3191-3-paul.barker.ct@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240206091909.3191-1-paul.barker.ct@bp.renesas.com> References: <20240206091909.3191-1-paul.barker.ct@bp.renesas.com> 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: 1790140770808531010 X-GMAIL-MSGID: 1790140770808531010 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 --- drivers/net/ethernet/renesas/ravb_main.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) 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 */