From patchwork Tue Feb 6 09:19:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Barker X-Patchwork-Id: 197277 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1417395dyb; Tue, 6 Feb 2024 01:20:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IGbu68KLa5XI3Q7QlYPBJHCqeDoDVAlBTBldPpeuCRpkvB5qQzB7EswZmo2s3ftkBZYM4Ft X-Received: by 2002:a17:903:18a:b0:1d9:8789:4b96 with SMTP id z10-20020a170903018a00b001d987894b96mr1012273plg.14.1707211237085; Tue, 06 Feb 2024 01:20:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707211237; cv=pass; d=google.com; s=arc-20160816; b=Qh8Ehc4BeUutITWAVK/5I1Ydklp+OZwV/Cz2Qmszatun+kmnbVuFWE7JPsoAjd6Ozh JEKQnJ6BrXxmZvgBDKIhgVdfZCb2Kuei7FC15rd8RvtscjYopN0SuC8Jeo8YYxMsEajN 0CbMr0BRwsGEbl3X90/j/Ngwm5GXafgl5bDG6lSlq2An9BoSpbxrmYmST6oMR1WQg7c7 ZDMKW6ErlH8Uwer1TE9B5uGhPpafgPY2UDPvt66mtzsvaaINBLgvK3ZqlgHny4gI+UXe Euptclww61s042+GqNHYL3ozkWAwDCV2wz6fgTy19yCK96sScZMw5bll4B03WwBgDdLR 0P/g== 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=H82yGo+pFTzvdiWiiAh27ZB+k3TfVwo6mWiq1iOTe5I=; fh=DUk2oVVxVaXB1LjdSo2c4C4MZYLBtVrCg8/r1ej1SNw=; b=zVySA+Y4kN8rVKJ2DFS6mihk7OBK+4rzHjLPONFzVqH94AMPEbWiSyg+yPxvdnq5Q1 wZ4Xo9Gz9AqLAd5bqdWeQo6CzgnIIGxTX+/cSR1OECccR0RbwSYAfmzQjnXdwAddiOCj LDeMJgQeivuDdFNUPbqDgbrykrmNQaRk+hzUoBZrEegBquUIe+WOwHUGWGbp/4x3D3hK mFpXaeaD6owtqBe7tjrrf9RISQnsQNCUXecUcT7rboFaBWSbvV688uUCcFZl2NKmxILl pGsiOJN2A2iOm3z7veIcHfSfuaRR2O9fPeDFDgakY4WWTMxdYb9iDQ+zQ0tUITLuGAld QVGw==; 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-54570-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-54570-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=renesas.com X-Forwarded-Encrypted: i=1; AJvYcCVpKFlC+DHp9OItkOHHFwwvohcnme5i85d94/C0zsqw+DADqM57z+EgZCKKVAR79buQb4QuL1ewzz/4mMCpMHVSNtsbjw== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id s21-20020a170902a51500b001d71c8871e4si1317606plq.165.2024.02.06.01.20.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 01:20:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-54570-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; 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-54570-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-54570-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 079E8B227B0 for ; Tue, 6 Feb 2024 09:20:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CE24112D777; Tue, 6 Feb 2024 09:19:33 +0000 (UTC) Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3CE8512D173; Tue, 6 Feb 2024 09:19:28 +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=1707211171; cv=none; b=qtziCZTA3Z9+2pk8YbWNiO2JqmOy37g0s6n8SWp7LiScx1tXP5IRR+tQnFYX9uvH8lgpYcmaa0AR3/L25d6sFv9r1C+jF9GwQ3Y7xQnAzOZoOqgCABDWezBs5seShLJL4v9JN1houzTRUqJz80/cGqGAHkpydlyr5+8v6OJzvJQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707211171; c=relaxed/simple; bh=C1SY0L5Dc5UjHfx9zo6gwJom7EBMAwYl8y/Lr3H2wDs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=SZpCxpbsj1rDDKTFMPU11AmDJ/7bOojRsBOE1rNCw7HnPnfLq2/irG9qw2/aC47DOKAcSt+MAiQtsfwv0wJ858HVBTSqTehQafMAOc35fgNHhFj/yz0LbQRh7NmKU05EEgRRrZ3Eb78UkHOu9pWvQpkKqrP2drelrZW37PhbHo8= 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="196934614" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 06 Feb 2024 18:19:22 +0900 Received: from GBR-5CG2373LKG.adwin.renesas.com (unknown [10.226.93.63]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 8206B41B86C7; Tue, 6 Feb 2024 18:19:18 +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 1/7] net: ravb: Simplify poll & receive functions Date: Tue, 6 Feb 2024 09:19:03 +0000 Message-Id: <20240206091909.3191-2-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: 1790140730349598315 X-GMAIL-MSGID: 1790140730349598315 We don't need to pass the work budget to ravb_rx() by reference, it's cleaner to pass this by value and return the amount of work done. This allows us to simplify the ravb_poll() function and use the common `work_done` variable name seen in other network drivers for consistency and ease of understanding. In ravb_rx_gbeth() & ravb_rx_rcar(), we can also drop the confusingly named `boguscnt` variable and use a for loop to iterate through descriptors. This is a pure refactor and should not affect behaviour. Signed-off-by: Paul Barker Reviewed-by: Sergey Shtylyov --- drivers/net/ethernet/renesas/ravb.h | 2 +- drivers/net/ethernet/renesas/ravb_main.c | 47 +++++++++--------------- 2 files changed, 19 insertions(+), 30 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h index 3cf869fb9a68..55a7a08aabef 100644 --- a/drivers/net/ethernet/renesas/ravb.h +++ b/drivers/net/ethernet/renesas/ravb.h @@ -1050,7 +1050,7 @@ struct ravb_hw_info { void (*rx_ring_free)(struct net_device *ndev, int q); void (*rx_ring_format)(struct net_device *ndev, int q); void *(*alloc_rx_desc)(struct net_device *ndev, int q); - bool (*receive)(struct net_device *ndev, int *quota, int q); + int (*receive)(struct net_device *ndev, int budget, int q); void (*set_rate)(struct net_device *ndev); int (*set_feature)(struct net_device *ndev, netdev_features_t features); int (*dmac_init)(struct net_device *ndev); diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 4976ecc91cde..b18026575a2d 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -822,7 +822,7 @@ static struct sk_buff *ravb_get_skb_gbeth(struct net_device *ndev, int entry, } /* Packet receive function for Gigabit Ethernet */ -static bool ravb_rx_gbeth(struct net_device *ndev, int *quota, int q) +static int ravb_rx_gbeth(struct net_device *ndev, int budget, int q) { struct ravb_private *priv = netdev_priv(ndev); const struct ravb_hw_info *info = priv->info; @@ -831,28 +831,24 @@ static bool ravb_rx_gbeth(struct net_device *ndev, int *quota, int q) struct sk_buff *skb; dma_addr_t dma_addr; 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; + limit = min(limit, budget); desc = &priv->gbeth_rx_ring[entry]; - while (desc->die_dt != DT_FEMPTY) { + for (i = 0; i < limit && 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; @@ -949,19 +945,16 @@ static bool ravb_rx_gbeth(struct net_device *ndev, int *quota, int q) desc->die_dt = DT_FEMPTY; } - *quota -= limit - (++boguscnt); - - return boguscnt <= 0; + return i; } /* Packet receive function for Ethernet AVB */ -static bool ravb_rx_rcar(struct net_device *ndev, int *quota, int q) +static int ravb_rx_rcar(struct net_device *ndev, int budget, int q) { struct ravb_private *priv = netdev_priv(ndev); const struct ravb_hw_info *info = priv->info; int entry = priv->cur_rx[q] % priv->num_rx_ring[q]; - int boguscnt = (priv->dirty_rx[q] + priv->num_rx_ring[q]) - - priv->cur_rx[q]; + int limit = priv->dirty_rx[q] + priv->num_rx_ring[q] - priv->cur_rx[q]; struct net_device_stats *stats = &priv->stats[q]; struct ravb_ex_rx_desc *desc; struct sk_buff *skb; @@ -970,19 +963,16 @@ static bool ravb_rx_rcar(struct net_device *ndev, int *quota, int q) u8 desc_status; u16 pkt_len; int limit; + int i; - boguscnt = min(boguscnt, *quota); - limit = boguscnt; + limit = min(limit, budget); desc = &priv->rx_ring[q][entry]; - while (desc->die_dt != DT_FEMPTY) { + for (i = 0; i < limit && 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; @@ -1064,18 +1054,16 @@ static bool ravb_rx_rcar(struct net_device *ndev, int *quota, int q) desc->die_dt = DT_FEMPTY; } - *quota -= limit - (++boguscnt); - - return boguscnt <= 0; + return i; } /* Packet receive function for Ethernet AVB */ -static bool ravb_rx(struct net_device *ndev, int *quota, int q) +static int ravb_rx(struct net_device *ndev, int budget, int q) { struct ravb_private *priv = netdev_priv(ndev); const struct ravb_hw_info *info = priv->info; - return info->receive(ndev, quota, q); + return info->receive(ndev, budget, q); } static void ravb_rcv_snd_disable(struct net_device *ndev) @@ -1353,12 +1341,13 @@ static int ravb_poll(struct napi_struct *napi, int budget) unsigned long flags; int q = napi - priv->napi; int mask = BIT(q); - int quota = budget; + int work_done; /* Processing RX Descriptor Ring */ /* Clear RX interrupt */ ravb_write(ndev, ~(mask | RIS0_RESERVED), RIS0); - if (ravb_rx(ndev, "a, q)) + work_done = ravb_rx(ndev, budget, q); + if (work_done == budget) goto out; /* Processing TX Descriptor Ring */ @@ -1391,7 +1380,7 @@ static int ravb_poll(struct napi_struct *napi, int budget) if (priv->rx_fifo_errors != ndev->stats.rx_fifo_errors) ndev->stats.rx_fifo_errors = priv->rx_fifo_errors; out: - return budget - quota; + return work_done; } static void ravb_set_duplex_gbeth(struct net_device *ndev) 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 */ From patchwork Tue Feb 6 09:19:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Barker X-Patchwork-Id: 197276 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1417343dyb; Tue, 6 Feb 2024 01:20:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IHMS0gaWcMl3lrROMuD6I9ltYnDbs8V65kp53a/gXJuUIRdWXwJRvQuJrATDJsxRlPPrEUc X-Received: by 2002:a37:c24c:0:b0:785:8f96:7beb with SMTP id j12-20020a37c24c000000b007858f967bebmr1036492qkm.33.1707211226889; Tue, 06 Feb 2024 01:20:26 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707211226; cv=pass; d=google.com; s=arc-20160816; b=bEP2y6UIr7hnYV2RRvz522CJJqO2C00Ssz+ZKuiB/JQoS9cqsxOJ3ilcXzHKu6Vc22 MZp24FeUaHx4S/HgabLE9KloGQvp0dML2E4faEQ/eUEBKPgCrsoxHf2xCzvEW7Mh/k9h k4lfBqQxKrXNcw+V/4Dm0KRQHyTHj4bLPXTMyGpWEEI4WYkdZlVi2JcLkxbThIJnAkN5 aOGCDlhJ3uFJn2Vpy9C+F0yk97j3ZuO4GO9pM5jzOwsCZKafnq5Psgt5mNLCp0rtULrU y3fe0I+eWkGs9JJDWwhkQb5IaWVoxCFwOOlnrmOY4wZUrynv9xYyeBFlRsTrZv3eYVwO Jc+Q== 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=bnQIUEZaFRaaHLkozmOLTfBDaYHORu0QaABBrOvq5bU=; fh=HfZGM2GfBilWsBSahFfz73odcrYAjaGDE/ngPd1lUC0=; b=OIMso+BHov5Pkdt/JbgeMdN7Km9JvNMBNalymL7f6SH+c7VdGs5PptRCx5cxO1sEVb 5VqPKQrDqdL6Qjuk/R/UsJuECNTH3UDLH+G6otZXJt2KgnWtWmBzQUwwFJJUe8dJcsUs 7B8LYHtX6DX/S/n0DERlCrJOtPoIT3r/mfTML9BbfCctAZ/AW5AVGmL2tFpphLNSb4bd eU3ImH1xAYCOUb/iizUHmRn6CyajtP3VD17JyUMB2Z5nFa1vfFWAXLGhGMtiYaaM5gEq YixyqvCC0+k+b13zRV+rvC1lEP07aF+Wj9a5AygKbKNBfc77fEO+sE+BDW5vCfOIctrO dIIw==; 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-54571-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-54571-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=renesas.com X-Forwarded-Encrypted: i=1; AJvYcCX/anPk+6/+hTujxGCBaQOFeGGxBif+fr9TPwYnj5hnzFMsGswEY+B6QMoaJA2nBvf0ZPixfsUn1NT9D/YRlPoOB/gW8w== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id n5-20020a05620a222500b007858c916862si1248628qkh.612.2024.02.06.01.20.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 01:20:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-54571-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; 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-54571-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-54571-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 A05F21C22184 for ; Tue, 6 Feb 2024 09:20:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0163D12D151; Tue, 6 Feb 2024 09:19:36 +0000 (UTC) Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2573612D74A; Tue, 6 Feb 2024 09:19:32 +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=1707211174; cv=none; b=ca8Kv5RNPKPIJA3qTdXxbPok9wu4zfzAXhuMOnOw0cGnbnnsuGqmQ5ed64SmNA4OD+O4jaLpD4bmJijeBvzicXqRDuD3BVM3+2HrT2MPV41OgfzBtrUJ6rxayr6EmKJmKIuUDIGa9ArA/cnf/oO/SNP8Y/USddeWoe0lfrjnlQE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707211174; c=relaxed/simple; bh=wMCMA52G6QYbcIfsCp50vOc4fUzt5+fBqBVJp0vQUgU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=pyMfN1P0xk0HEeFOwGONIvRbUhpDco+esn955C5iOsVI3XdoiqlNBVRJ8ROOAaUty9SvMDyVca1ApJilmj0IQ2RdAYQbvkycJzkr90ItJm3tj2MNGlWzcGkDphyl3vPvxi/C2wgI8Ixp3VTQSGLZZ1Riya5JPTLfLHfsPtuA6Io= 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="196934634" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 06 Feb 2024 18:19:30 +0900 Received: from GBR-5CG2373LKG.adwin.renesas.com (unknown [10.226.93.63]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 0011241B9447; Tue, 6 Feb 2024 18:19:26 +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 3/7] net: ravb: Always process TX descriptor ring Date: Tue, 6 Feb 2024 09:19:05 +0000 Message-Id: <20240206091909.3191-4-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: 1790140719620359182 X-GMAIL-MSGID: 1790140719620359182 The TX queue should be serviced each time the poll function is called, even if the full RX work budget has been consumed. This prevents starvation of the TX queue when RX bandwidth usage is high. Signed-off-by: Paul Barker --- drivers/net/ethernet/renesas/ravb_main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 20193944c143..10f11141569f 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -1349,8 +1349,6 @@ static int ravb_poll(struct napi_struct *napi, int budget) /* Clear RX interrupt */ ravb_write(ndev, ~(mask | RIS0_RESERVED), RIS0); work_done = ravb_rx(ndev, budget, q); - if (work_done == budget) - goto out; /* Processing TX Descriptor Ring */ spin_lock_irqsave(&priv->lock, flags); @@ -1360,6 +1358,9 @@ static int ravb_poll(struct napi_struct *napi, int budget) netif_wake_subqueue(ndev, q); spin_unlock_irqrestore(&priv->lock, flags); + if (work_done == budget) + goto out; + napi_complete(napi); /* Re-enable RX/TX interrupts */ From patchwork Tue Feb 6 09:19:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Barker X-Patchwork-Id: 197278 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1417549dyb; Tue, 6 Feb 2024 01:21:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IFhfgS2/oPK4nv6hnKIVOUYrD/unpyDVp5T9zfdZGsS4y1EFJ/l4SdE4iHOI6YUcOWx580Z X-Received: by 2002:a05:6102:54a0:b0:46d:395f:6b98 with SMTP id bk32-20020a05610254a000b0046d395f6b98mr3016723vsb.0.1707211262877; Tue, 06 Feb 2024 01:21:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707211262; cv=pass; d=google.com; s=arc-20160816; b=GViDRajxQXpTWZYzYNluKet2VX6Cm3S/bk4YG7hMxtUX4SOKoPr8EfVagonxUYBme1 Mc1yQGqVMPbPM4iSK/glyQ7SsjoydQdQcDWcjjV2DA4xI3Kg8MF6Mkw48Q99HwCRpYVA XJPy0elDRe2jbHjDBtVlAiPgfSQLDIFbU0y1ojg/MvmZP9iOpHAOFEz6E8QumXjim9n2 3n6xV1nKPijMLZU2wP3HS4XfvKdkawvadmUotSwJOFdG9q2/WyA2iHqpG3CUQZrQ0y0i +FkBo8xLFGWgNlCPMdK/xKG2Z2C+rOa+dvdapF6XNCp9q6gn14y0vAoYvhkQNU3bPKXA vAbw== 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=78VAFIsDFzWqE6vEPfSqMFOOKvHZMv2JRytuksoYfEk=; fh=Gs1PG8X+JZYt+xXf9T0OzhddmSSTyo7/fBly7HM0fHs=; b=AUxgk90RMoGxVfUQ+vuktUX6ovhdScRusdzjmuzcKTeedzaeY2Qej2o9LRUdpCT0fo fAJk7RVtoUzezlztvzk62xYJB/0va8CUCw1/B4wNjgLakFVIZixUr/N4Wqo/3b47a+P3 s5g2aeJC5dCXthN+TqOEshx6Eqp9Htl3EBd8qcgQ0BUBPW8l/vxieuhIhTIMO/MSI3dl zkruyb4FhmoEY03dw/Ok8+c1zsTF52RmxvkXdEGYs+209YtfXDROEl6RDyFrUa8jUM5S 7+mGN47gGA1zX+qHga5FeOUTRy6caRBbrjVq23YmlhJKYbzy3bojZ7moKlv4Q+bErr2G JqPQ==; 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-54573-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-54573-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=renesas.com X-Forwarded-Encrypted: i=1; AJvYcCUYZG9UPdGd4YafmpcdJclaCULjAD9NNS6yv/y7UsrSfv+znUB/0ndFdQsiJArZyLurGV8qbRv3R+YVnU3L/ORm6dUXLg== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id e8-20020a0562141d0800b0068c469e8e89si2268623qvd.262.2024.02.06.01.21.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 01:21:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-54573-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; 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-54573-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-54573-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 A78D41C213C5 for ; Tue, 6 Feb 2024 09:21:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0AEB712EBD0; Tue, 6 Feb 2024 09:19:39 +0000 (UTC) Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 36D5612D74F; Tue, 6 Feb 2024 09:19:35 +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=1707211177; cv=none; b=QK2ztsMcEznqP32UswGmd0KpDd9QLulY9ZYhhLOUJt4s59YZyl+6bYTAt5qlCydITHtGQI3a52mciV9XpaeyKbkMh2zHMIcgkXZhyNPBebuA4cXpLQztI93MgRyjMNCfCXpFiQu0jabfDtJ5lb+nMT7Menawpo78N04igl3YrRg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707211177; c=relaxed/simple; bh=VWwAkeNIRheV+jEp3hBBLEU6AH3N4DBzBzaCBZMZS6M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=O0ZprxTQ/ctNV5v817EFeOVpEQQN+TViw4X4CS8xxIzfybh/U6jaMmab2xh6zhNHlegOf6gzY/Y6VQWRoX5E17O84JMixJQUM1JNVTfe6NkQoN3e3E/1aEyGpytWieGKboXKkCzqlm3ZR8ll6PsEcEKFifAJY8YZ9tC4p43xRiM= 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="196934640" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 06 Feb 2024 18:19:34 +0900 Received: from GBR-5CG2373LKG.adwin.renesas.com (unknown [10.226.93.63]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 46C3D41B8EF7; Tue, 6 Feb 2024 18:19:31 +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 4/7] net: ravb: Always update error counters Date: Tue, 6 Feb 2024 09:19:06 +0000 Message-Id: <20240206091909.3191-5-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: 1790140757137999867 X-GMAIL-MSGID: 1790140757137999867 The error statistics should be updated each time the poll function is called, even if the full RX work budget has been consumed. This prevents the counts from becoming stuck when RX bandwidth usage is high. This also ensures that error counters are not updated after we've re-enabled interrupts as that could result in a race condition. Also drop an unnecessary space. Signed-off-by: Paul Barker --- drivers/net/ethernet/renesas/ravb_main.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 10f11141569f..2136600d60dd 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -1358,6 +1358,15 @@ static int ravb_poll(struct napi_struct *napi, int budget) netif_wake_subqueue(ndev, q); spin_unlock_irqrestore(&priv->lock, flags); + /* Receive error message handling */ + priv->rx_over_errors = priv->stats[RAVB_BE].rx_over_errors; + if (info->nc_queues) + priv->rx_over_errors += priv->stats[RAVB_NC].rx_over_errors; + if (priv->rx_over_errors != ndev->stats.rx_over_errors) + ndev->stats.rx_over_errors = priv->rx_over_errors; + if (priv->rx_fifo_errors != ndev->stats.rx_fifo_errors) + ndev->stats.rx_fifo_errors = priv->rx_fifo_errors; + if (work_done == budget) goto out; @@ -1374,14 +1383,6 @@ static int ravb_poll(struct napi_struct *napi, int budget) } spin_unlock_irqrestore(&priv->lock, flags); - /* Receive error message handling */ - priv->rx_over_errors = priv->stats[RAVB_BE].rx_over_errors; - if (info->nc_queues) - priv->rx_over_errors += priv->stats[RAVB_NC].rx_over_errors; - if (priv->rx_over_errors != ndev->stats.rx_over_errors) - ndev->stats.rx_over_errors = priv->rx_over_errors; - if (priv->rx_fifo_errors != ndev->stats.rx_fifo_errors) - ndev->stats.rx_fifo_errors = priv->rx_fifo_errors; out: return work_done; } From patchwork Tue Feb 6 09:19:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Barker X-Patchwork-Id: 197282 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1417888dyb; Tue, 6 Feb 2024 01:21:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IEDY/3IpnRF1aWKcojVVIiIIJG/EEwXJUfSGCfx9BnC3b1FWZsGXewjS2LGlvGskgFidCH6 X-Received: by 2002:a05:6a20:9591:b0:19e:487e:39e7 with SMTP id iu17-20020a056a20959100b0019e487e39e7mr1951003pzb.16.1707211319371; Tue, 06 Feb 2024 01:21:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707211319; cv=pass; d=google.com; s=arc-20160816; b=eHZT/x71A2z7xS+NL67Zy/aInop//06K/nfQV+V4U2xb09orwhvr5IItUF16tpt5cN vllyGML+AyTsr70Yq2w7WWzjghyU+u53LjVP8G/Su4IA1B2s7Y6sesPTd72uTaDydUbo FVCh/VmuwC78rOvGO4TROWmESIgP+u3sAuJz6ULyd6/Cu7fY3/XqeDV2UQJ3E1rc7XsW gMSCpsEvdQDIAJ+P0qLGkQw9B82/EZNT6nRQjqnEHTmMcVSw/cx+7+GdEisONNguLDFf vkjwq8n4DzNCXUkSgvD9oS7h7sWiEGXc5mxUmxsyA49xBUbLlNipaUBV7GOTgFbC2NNc 3ubg== 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=xyiOUdHK0bMQCWOdpMuWoJ1WCVfzek/iF/jrS9uOLrg=; fh=GHMPSKXn93pIHPfsxLw3pzxAavCO2ykuHdi2bsqSRUs=; b=so80apQUKMnkycijmpoDf6ljgqBOVyZtjv0nXKStNU2VSBuoLwTsUE4C+GUUJIW8Lu BL6QXOzPIzWuxqDAgPvuhvzKnlxUBkSp/diQRl6M+/uyh+ExSjZWzLjngdMtNttvrMlI BgzOTr2a3wu3j24Qz1TKx5YG8IfmkBG2OaLPgh9KCQ9KDBq4AA7a99fNR60tUl2pnZTx uTUqRMZEdNvPNdIiGi4kK2Q2/625XCofMqW+TBRfN/qdINOJv0ysFBYd8qz3hBuKA7k9 W4SEZ9rSSeQx3SAuZQxL9Ama2FTzNmDgPOqjKrK1NMJhItECE6SmPLl67Mj1yYEVtpLk aNNA==; 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-54574-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-54574-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=renesas.com X-Forwarded-Encrypted: i=1; AJvYcCUaZUPjDpDQ5TK1VCi+9QyYyeYM1Uc5Md6P7wyJx1rqxMiYhg+DhUhOLyVz+5pyGlr5HfQFO66EfUVVEJxg3Ynve3e7Mw== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id b17-20020aa78711000000b006e044ae6f2esi1266145pfo.313.2024.02.06.01.21.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 01:21:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-54574-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; 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-54574-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-54574-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 A1DF4B223B7 for ; Tue, 6 Feb 2024 09:21:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8258112EBF2; Tue, 6 Feb 2024 09:19:43 +0000 (UTC) Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3230512EBDD; Tue, 6 Feb 2024 09:19:39 +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=1707211182; cv=none; b=SvfVQc/resLy15z19jnw4nu9eULsiFC630c1vHwdUSGjUcUjOnmmC5Ha+XJ+P+nasgoJrC4zHICHQ2oSVJdRM/Wdz4hGYHHRNhMkvkvaCCh/TTBc8vH5J52pn6de1k4/lNHZjSAA/YwMDF77WOlHHbrG0mob4CfxfJz12ZqysKI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707211182; c=relaxed/simple; bh=87blQj+GxmDYGplMV4xdgn6LYv3+QSfpU7NtXCzDNME=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=UqL+34O8ClfAV16DhDFAt+Y31bNLdPIrX8Nz56QXvkTruZn1LX95lVTjW/JB/Q3yX3gnwcKg+YgvcLY0YR9ovWg+t8Deb/vTo2N0KUO7JSTGaxqtBlSToXUsMDuPSSK8Rg6LSKoWk0mEQBLCpX/NlyOOcazhYUWD9q4IZPF5Ax4= 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="196934650" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 06 Feb 2024 18:19:39 +0900 Received: from GBR-5CG2373LKG.adwin.renesas.com (unknown [10.226.93.63]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 834D941B86C7; Tue, 6 Feb 2024 18:19:35 +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 5/7] net: ravb: Align poll function with NAPI docs Date: Tue, 6 Feb 2024 09:19:07 +0000 Message-Id: <20240206091909.3191-6-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: 1790140816445229789 X-GMAIL-MSGID: 1790140816445229789 Call napi_complete_done() in accordance with the documentation in `Documentation/networking/napi.rst`. Signed-off-by: Paul Barker Reviewed-by: Sergey Shtylyov --- drivers/net/ethernet/renesas/ravb_main.c | 26 ++++++++++-------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 2136600d60dd..661fd86899ac 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -1367,23 +1367,19 @@ static int ravb_poll(struct napi_struct *napi, int budget) if (priv->rx_fifo_errors != ndev->stats.rx_fifo_errors) ndev->stats.rx_fifo_errors = priv->rx_fifo_errors; - if (work_done == budget) - goto out; - - napi_complete(napi); - - /* Re-enable RX/TX interrupts */ - spin_lock_irqsave(&priv->lock, flags); - if (!info->irq_en_dis) { - ravb_modify(ndev, RIC0, mask, mask); - ravb_modify(ndev, TIC, mask, mask); - } else { - ravb_write(ndev, mask, RIE0); - ravb_write(ndev, mask, TIE); + if (work_done < budget && napi_complete_done(napi, work_done)) { + /* Re-enable RX/TX interrupts */ + spin_lock_irqsave(&priv->lock, flags); + if (!info->irq_en_dis) { + ravb_modify(ndev, RIC0, mask, mask); + ravb_modify(ndev, TIC, mask, mask); + } else { + ravb_write(ndev, mask, RIE0); + ravb_write(ndev, mask, TIE); + } + spin_unlock_irqrestore(&priv->lock, flags); } - spin_unlock_irqrestore(&priv->lock, flags); -out: return work_done; } From patchwork Tue Feb 6 09:19:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Barker X-Patchwork-Id: 197280 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1417788dyb; Tue, 6 Feb 2024 01:21:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IFTrjYGxLjWSuiSzlSBAg7lYkhr4my8oK7Royoiq5UP5FVjY+RBCpL4dznv6DL3wB6DnjAC X-Received: by 2002:a05:620a:1124:b0:783:df10:a0e5 with SMTP id p4-20020a05620a112400b00783df10a0e5mr1671748qkk.73.1707211299356; Tue, 06 Feb 2024 01:21:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707211299; cv=pass; d=google.com; s=arc-20160816; b=KoLrIgFUp2//KBh2jKg4rujVdA4v68GiHtjh6PTIwZ3peNKscfeAOzcEbIHiVQG31s Pz9Lwle/E3JlN9Jg8NT7vlhp6cmNGViuK4VTUo3zic7ZujaatY+wFX8uuCEHvpIv17cX 2BnkaWmk0qMbdgLUxuC9Rr7NXcEP25jywoHaYO5IzFvFsgwAW9X+nJPV5+i3GhRkyvTR Ug0Hdd5LgPTykMUHHZLhws/sHhr4Ut+dCiiu5CxmJjQLcritLybboZcgs1Jaq+IudMeD sf2T3vtV+3xG4Ag21gqCIFvwwsShk4DGYT33HGERiopdzmKo4zuKGgbifQhlMTBoa5uj jf8g== 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=rfuTluO4LlL/ukcj2oNHny17ZywTMv0sKmbc4/mtTpo=; fh=HMHu5Ee56nNcNuXLtvd3B50DWjJs1vM9HF5Wx+iCjGk=; b=b+5XbTAyEOHaNhyTLDZoYr//ng7lqGv0OqbsSFCIzoIgnX3ZNV7kyWMziZ8yxABIjb qHp4nzJrLJgoa3/dGOU7Au4zdF5FmJfFVY/3vnZff42W3jUe7ld5KYMofXP/i8hvOmcZ y/8X+ceVjoXfP7JIlZZG3Z2Mv3UdpG8IxVnIZXERclQgz4bLx0a4O86KPL6Aehj5Ja7l mcwJtGc5zd+MWCYtxNRZl8R3lqVU4mL7lznDJOzau5vekLp38SgZX/P/txqU5n+SYwBN 87YuGLpSGkL9sDAxxKSUqIKqn7/sTdhBI/dLQfEFwp+algn8fYDGIjNvi+MC5P7XQPjO 3Fbg==; 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-54575-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-54575-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=renesas.com X-Forwarded-Encrypted: i=1; AJvYcCVDDs9gewe3WwY9o9Wf1MaK3l4G+5fPU7KZ9+O+w19YxZCDIjQeJCU0oJQ4k9D+elmxUYbjiY1qjySXfgxj19wyF+Iz9w== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id vw2-20020a05620a564200b00783e2eb9b2fsi1831178qkn.491.2024.02.06.01.21.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 01:21:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-54575-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; 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-54575-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-54575-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 292111C22157 for ; Tue, 6 Feb 2024 09:21:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 53DCC12D176; Tue, 6 Feb 2024 09:19:48 +0000 (UTC) Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A184012EBFA; Tue, 6 Feb 2024 09:19:44 +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=1707211186; cv=none; b=kmvL59kKGPatmadeToN4eKyREwEyTpTL3Gw/YYHzw3rtykaqtuVqt7/E7RnokBriQsRCKOFXgU09fZtSEhLRfiHSwIW54y8ajXqMKypGm6dFNYgWL7sRP24L+bDBo5lk1XZMur8CN3U1t91YxNBS4TUceLmV40gmHydy92oH6n0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707211186; c=relaxed/simple; bh=K2OpG4YqvGtxSFVnu+Kxv9nWWw/e4YY7sJiQxe5ZN2I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=B20oA7PMcW72MRe7U27IsbNX3y944XoMiIJzESer4yQR7pPkLgnyIqvykqYTNtZ3X2r0irhtLxZNGUVpbM2WB/5oHplXFeFVqZE9y1jeB4SYZzAbyz7vrnd0T2BI64z67OZcP9FhjHjMpNcybWjsrWysRhjR/fA5nfHMYMuCmCw= 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.05,246,1701097200"; d="scan'208";a="193022712" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 06 Feb 2024 18:19:43 +0900 Received: from GBR-5CG2373LKG.adwin.renesas.com (unknown [10.226.93.63]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id BFCCE41B86C7; Tue, 6 Feb 2024 18:19:39 +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 6/7] net: ravb: Enable SW IRQ Coalescing for GbEth Date: Tue, 6 Feb 2024 09:19:08 +0000 Message-Id: <20240206091909.3191-7-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: 1790140795921766933 X-GMAIL-MSGID: 1790140795921766933 Software IRQ Coalescing is required to improve network stack performance in the RZ/G2L SoC family and the RZ/G3S SoC, i.e. the SoCs which use the GbEth IP. For the RZ/G2L, network throughput is comparable before and after this change. CPU usage during TCP RX testing dropped by 6.5% and during UDP RX testing dropped by 10%. For the RZ/G2UL, network throughput is greatly increased by this change (results obtained with iperf3): * TCP TX: 2.9% more throughput * TCP RX: 1.1% more throughput * UDP TX: similar throughput * UDP RX: 41500% more throughput For the RZ/G3S we see improvements in network throughput similar to the RZ/G2UL. The improvement of UDP RX bandwidth for the single core SoCs (RZ/G2UL & RZ/G3S) is particularly critical. Signed-off-by: Paul Barker --- drivers/net/ethernet/renesas/ravb.h | 1 + drivers/net/ethernet/renesas/ravb_main.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h index 55a7a08aabef..ca7a66759e35 100644 --- a/drivers/net/ethernet/renesas/ravb.h +++ b/drivers/net/ethernet/renesas/ravb.h @@ -1078,6 +1078,7 @@ struct ravb_hw_info { unsigned nc_queues:1; /* AVB-DMAC has RX and TX NC queues */ unsigned magic_pkt:1; /* E-MAC supports magic packet detection */ unsigned half_duplex:1; /* E-MAC supports half duplex mode */ + unsigned needs_irq_coalesce:1; /* Requires SW IRQ Coalescing to achieve best performance */ }; struct ravb_private { diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 661fd86899ac..7bb80608f260 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2639,6 +2639,7 @@ static const struct ravb_hw_info gbeth_hw_info = { .tx_counters = 1, .carrier_counters = 1, .half_duplex = 1, + .needs_irq_coalesce = 1, }; static const struct of_device_id ravb_match_table[] = { @@ -2983,6 +2984,9 @@ static int ravb_probe(struct platform_device *pdev) if (info->nc_queues) netif_napi_add(ndev, &priv->napi[RAVB_NC], ravb_poll); + if (info->needs_irq_coalesce) + netdev_sw_irq_coalesce_default_on(ndev); + /* Network device register */ error = register_netdev(ndev); if (error) From patchwork Tue Feb 6 09:19:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Barker X-Patchwork-Id: 197281 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1417876dyb; Tue, 6 Feb 2024 01:21:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IF1pHrwpCK/d38X2R/tvomuVTf/koTctZ1GcNbrJ610sc/FXFW//UefSBOetDsli+hPKEG9 X-Received: by 2002:a17:90b:1e04:b0:296:8e43:3621 with SMTP id pg4-20020a17090b1e0400b002968e433621mr1982074pjb.38.1707211317243; Tue, 06 Feb 2024 01:21:57 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707211317; cv=pass; d=google.com; s=arc-20160816; b=ZawxlLeiInExHD27pHpTOpYpqC+3w11wNaawCe88d82anwAdBp4Fh8dJ6JEfvnQIRT iXbRXedWNSplypI0zKJnDy5dWBofP7ObCYyaE7g4FfIx+ygDK1R3c/HnvguP9xgu3Y43 NMrE3mmQSxAU4Y6dqdZP3wRJLDb+kR2Li1rPJD3nYzBP5oyGGc35Apg8jFl9MW3l0t/I 2ckRuIowIB43aTZVjgdhxBoDpssWhYM0QiwOm7ld6/z3POyP4nXzQoBXr3fnO5kqBAvX rTntuydjCj9nEIJKhCiQCMC42ZQLYn7582c9bLYHPqOxW05o0JGsWs9XKBbSToTkFaKG U49A== 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=oEcGMnyc23bpvOOUcWo6dTsqNJogDJWYfz1sHAv2iNY=; fh=Xb3qtrBZmn+pwAQLZysIFyhfA31t+OeKgMzq7JQVits=; b=t1ZRNu/bsmqH8x2254kcKu7MVHR4v6uvTW2v623LAuqedgK4eNFgaSh2sUrEWJCWBq VQtK8+5+wXlAQf1wRDJ9eMq0ooDKUjrfuClz2vkCKVYIO2aqTg1ZbRALQLajhKmMZTqq OEJ0Y7QUezGfay8lAPFLraLLOr3YPRvQ/wbCXDOHvaxMnTy+QOP7oq9iAMjXKYK6WBC3 My/ov2UW6UcAudddUnt8R6Fr4yC4UQ+aJA9A7zqpgIwyw7HxbSejvIvFsH++xcuGLTPR U4lBSa5PU5TI6uRVsstS7LJ6i9hjkPMpXoZ1OxkQu+mNbc4k5WMY34Tl3uDqutW/Mm3R nxyA==; 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-54576-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-54576-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=renesas.com X-Forwarded-Encrypted: i=1; AJvYcCX2rf7RKATGXqGb3kkCJvJDGmfAnlZ5ZyZxscBAa9C9y7S4zyjh206Pj9diFVQXcMJIMI4BWksimRiqpGVj++/5La2FjA== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id i18-20020a17090acf9200b002953a1e7e33si820907pju.164.2024.02.06.01.21.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 01:21:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-54576-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::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-54576-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-54576-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id F1BFC285D73 for ; Tue, 6 Feb 2024 09:21:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 23BE812F59D; Tue, 6 Feb 2024 09:19:52 +0000 (UTC) Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9B98712F386; Tue, 6 Feb 2024 09:19:48 +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=1707211190; cv=none; b=aPVtSolvTgHCUQCFBsoPWzBHkz7EV1SacPjyuv4SInB8HVm9nN3kP43j+T9k6yXe9LMvM7tR7EOiSZaO4wFvdZfQS9/l7F/a+Zw69+B4uchcYQw6ICnY6v9fAadu6KO3ed0/iyyxOUcYX2ioftbVTSsU6GBRwmnh7o46y/I+HRg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707211190; c=relaxed/simple; bh=v30FjsWUe3ZhLh+6uEKl3Kbs4m0Yb16dWTX3b3fdzp8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=GbynWw0Ew48m1AaJbTPC2Tyf7uRoVT4SAxPnDEQJvJRVIC5fOAKPbMwNP0xlVHTbKPeLKN+EYuT7TquEpfkPG6WDx6iLVLQQSNZ91H6IDBhYArvkGIpkoPMPgI9TnLOode2F6vdNoWBYTux81nMsDEX7jwK1fumhr915XpOl+mE= 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="196934676" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 06 Feb 2024 18:19:47 +0900 Received: from GBR-5CG2373LKG.adwin.renesas.com (unknown [10.226.93.63]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 0C8F041B8EF7; Tue, 6 Feb 2024 18:19:43 +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 7/7] net: ravb: Use NAPI threaded mode on 1-core CPUs with GbEth IP Date: Tue, 6 Feb 2024 09:19:09 +0000 Message-Id: <20240206091909.3191-8-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: 1790140814142968141 X-GMAIL-MSGID: 1790140814142968141 NAPI Threaded mode (along with the previously enabled SW IRQ Coalescing) is required to improve network stack performance for single core SoCs using the GbEth IP (currently the RZ/G2L SoC family and the RZ/G3S SoC). For the RZ/G2UL, network throughput is greatly increased by this change (results obtained with iperf3) for all test cases except UDP TX: * TCP TX: 30% more throughput * TCP RX: 9.8% more throughput * UDP TX: 9.7% less throughput * UDP RX: 89% more throughput For the RZ/G3S we see improvements in network throughput similar to the RZ/G2UL. The improvement of UDP RX bandwidth for the single core SoCs (RZ/G2UL & RZ/G3S) is particularly critical. NAPI Threaded mode can be disabled at runtime via sysfs for applications where UDP TX performance is a priority. Signed-off-by: Paul Barker Reviewed-by: Sergey Shtylyov --- drivers/net/ethernet/renesas/ravb_main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 7bb80608f260..522df82524ff 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2984,8 +2984,11 @@ static int ravb_probe(struct platform_device *pdev) if (info->nc_queues) netif_napi_add(ndev, &priv->napi[RAVB_NC], ravb_poll); - if (info->needs_irq_coalesce) + if (info->needs_irq_coalesce) { netdev_sw_irq_coalesce_default_on(ndev); + if (num_present_cpus() == 1) + dev_set_threaded(ndev, true); + } /* Network device register */ error = register_netdev(ndev);