From patchwork Wed Jan 31 17:05:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Barker X-Patchwork-Id: 194881 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp2050520dyb; Wed, 31 Jan 2024 09:39:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IFalW5PCJl55gWCDRjakIF4HRSbG0ziMGZteoYsO04A2fbnyn2VS/ccxwQ/fxFCFqVTSNcc X-Received: by 2002:aa7:9851:0:b0:6db:afd4:f54c with SMTP id n17-20020aa79851000000b006dbafd4f54cmr2530266pfq.0.1706722777272; Wed, 31 Jan 2024 09:39:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706722777; cv=pass; d=google.com; s=arc-20160816; b=WnfCUTdx8QkGU9PGDKeFerMZfvvLWHw2RqC//We5n5wfUqYtqHimxEBhQTjqvxaLB/ 7leTz4TfrsJbAe4JESzfG5QVPKYOkQZorC2aU93YKD8Vevqm4myaBX6DiKhVGf6xUHud vIdCQXOvKaTVg/4Re7zt3Vjrcj5x9mfBzbZFMbCaT3oU9u4C1NlGsbKT+sHVlBssmHYV jLcfeKClZdJ5HjP5aotnXNSmWr8kIdV5aFMcnyL8yb5bhVZDSBrLR77QJqtwqN6N+mfR 4O04cJidQB55nAre2eYj1dKEn/+UeaCgKyZtP1T04BGxDRweBnn2ngCQciCtPDCv0LmN PBNQ== 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=U9xIfP68l1vhQsfAETMkRUwX65ZfvcXPsH7Y7a0qEg8=; fh=/YieQlk81Dk8f06LbLApraeOLw/JAA6qzajpNW9j73E=; b=th41fg7pjpPtvaJqmsCQq7pfriysj1KhNIbzN/UgnPShawQZfFFb+3vrZ5GwZByIrI Vd2F8AlzPWd6+1W2q5BkwULB73jhdomrPswzqOIpPiYPfYPA8gkoE1jB8EvF0RKTo+O3 LSylScJh8PcX8qG9FqeKFKqkk8VyMts6UXLjPdwkglCbky8Zhgeh+/cievOw+p3GyplR Ek/OhAISQts4BO/0f9At6P4Cbm1j02JEHD2AIcFqxE5R8IunLTQ1m2TAPq7FjlzJtF4I RVTycwnkPXsLn1lbEUB0Sy57RKwtWyOUlUowt3SAaA86b6tEQyDoF8RuiKa1H2AHaPhB HYMg==; 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-46863-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46863-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=renesas.com X-Forwarded-Encrypted: i=1; AJvYcCWyV5ks0EaSFO9+7M5Sp2cvB33L1XG0J9pbOuK6cRrERtiT2lGVtA8mEy3yXqomOIFow+VMWqpjJ4q80GRm8F0TrDy0bg== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id m26-20020aa78a1a000000b006de04df03e3si9348420pfa.114.2024.01.31.09.39.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 09:39:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-46863-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-46863-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46863-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 DF1A6B315B1 for ; Wed, 31 Jan 2024 17:06:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9723112DDA9; Wed, 31 Jan 2024 17:06:00 +0000 (UTC) Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CF1A412C54B; Wed, 31 Jan 2024 17:05:55 +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=1706720758; cv=none; b=Ad1q3MpM4XBptrUPj2FzQZLaOXndOozMIKULN4oI0Z+SJ3FTJm8tE2pD9CvHvs4/HufjO8ksV0uoCipk9XGM0ksv6voY3PwP7cEnW/IuXBRKubBeZP0bP3zUL6aj3EEWrX+U86Ck7vQ77COtHzSVIZ1sshVEUVKSpRrxPL3H7oc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706720758; c=relaxed/simple; bh=O3JgQWQjXJLciyc2HaqxwHx7NmFu6s1KXH6/DXjbg0U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=qURtoawAvZAw4fKgMA+2hbR/wWjIjp/pR195HNvaiAEJPSdmVYgiIUE7vHzFDCv4M5iJoLIhdzgOtuWR6KUXZKHYPUZCKer+okS41/fWbPHAYg8SWBGTSvTb/FyH6NIX6daT9sE7d2IVcfakH5oToUYsnYfSPjxSGLC8m4g/RgE= 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,231,1701097200"; d="scan'208";a="196315518" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 01 Feb 2024 02:05:50 +0900 Received: from GBR-5CG2373LKG.adwin.renesas.com (unknown [10.226.92.158]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id EA4CB40344F5; Thu, 1 Feb 2024 02:05:46 +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: [PATCH net-next 1/8] net: ravb: Split R-Car & GbEth poll functions Date: Wed, 31 Jan 2024 17:05:15 +0000 Message-Id: <20240131170523.30048-2-paul.barker.ct@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240131170523.30048-1-paul.barker.ct@bp.renesas.com> References: <20240131170523.30048-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: 1789628543137686117 X-GMAIL-MSGID: 1789628543137686117 This allows us to optimise polling and receive processing for the GbEth IP used in the RZ/G2L Soc family, without affecting the wider family of R-Car based devices. Signed-off-by: Paul Barker --- drivers/net/ethernet/renesas/ravb.h | 2 +- drivers/net/ethernet/renesas/ravb_main.c | 74 ++++++++++++++++++------ 2 files changed, 58 insertions(+), 18 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h index 3cf869fb9a68..9e9cf0d36d72 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 (*poll)(struct napi_struct *napi, int budget); 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..c9464c1731b4 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -1069,15 +1069,6 @@ static bool ravb_rx_rcar(struct net_device *ndev, int *quota, int q) return boguscnt <= 0; } -/* Packet receive function for Ethernet AVB */ -static bool ravb_rx(struct net_device *ndev, int *quota, int q) -{ - struct ravb_private *priv = netdev_priv(ndev); - const struct ravb_hw_info *info = priv->info; - - return info->receive(ndev, quota, q); -} - static void ravb_rcv_snd_disable(struct net_device *ndev) { /* Disable TX and RX */ @@ -1345,7 +1336,56 @@ static irqreturn_t ravb_nc_interrupt(int irq, void *dev_id) return ravb_dma_interrupt(irq, dev_id, RAVB_NC); } -static int ravb_poll(struct napi_struct *napi, int budget) +static int ravb_poll_gbeth(struct napi_struct *napi, int budget) +{ + struct net_device *ndev = napi->dev; + struct ravb_private *priv = netdev_priv(ndev); + const struct ravb_hw_info *info = priv->info; + unsigned long flags; + int q = napi - priv->napi; + int mask = BIT(q); + int quota = budget; + + /* Processing RX Descriptor Ring */ + /* Clear RX interrupt */ + ravb_write(ndev, ~(mask | RIS0_RESERVED), RIS0); + if (ravb_rx_gbeth(ndev, "a, q)) + goto out; + + /* Processing TX Descriptor Ring */ + spin_lock_irqsave(&priv->lock, flags); + /* Clear TX interrupt */ + ravb_write(ndev, ~(mask | TIS_RESERVED), TIS); + ravb_tx_free(ndev, q, true); + netif_wake_subqueue(ndev, q); + spin_unlock_irqrestore(&priv->lock, flags); + + 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); + } + 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 budget - quota; +} + +static int ravb_poll_rcar(struct napi_struct *napi, int budget) { struct net_device *ndev = napi->dev; struct ravb_private *priv = netdev_priv(ndev); @@ -1358,7 +1398,7 @@ static int ravb_poll(struct napi_struct *napi, int budget) /* Processing RX Descriptor Ring */ /* Clear RX interrupt */ ravb_write(ndev, ~(mask | RIS0_RESERVED), RIS0); - if (ravb_rx(ndev, "a, q)) + if (ravb_rx_rcar(ndev, "a, q)) goto out; /* Processing TX Descriptor Ring */ @@ -2559,7 +2599,7 @@ static const struct ravb_hw_info ravb_gen3_hw_info = { .rx_ring_free = ravb_rx_ring_free_rcar, .rx_ring_format = ravb_rx_ring_format_rcar, .alloc_rx_desc = ravb_alloc_rx_desc_rcar, - .receive = ravb_rx_rcar, + .poll = ravb_poll_rcar, .set_rate = ravb_set_rate_rcar, .set_feature = ravb_set_features_rcar, .dmac_init = ravb_dmac_init_rcar, @@ -2585,7 +2625,7 @@ static const struct ravb_hw_info ravb_gen2_hw_info = { .rx_ring_free = ravb_rx_ring_free_rcar, .rx_ring_format = ravb_rx_ring_format_rcar, .alloc_rx_desc = ravb_alloc_rx_desc_rcar, - .receive = ravb_rx_rcar, + .poll = ravb_poll_rcar, .set_rate = ravb_set_rate_rcar, .set_feature = ravb_set_features_rcar, .dmac_init = ravb_dmac_init_rcar, @@ -2608,7 +2648,7 @@ static const struct ravb_hw_info ravb_rzv2m_hw_info = { .rx_ring_free = ravb_rx_ring_free_rcar, .rx_ring_format = ravb_rx_ring_format_rcar, .alloc_rx_desc = ravb_alloc_rx_desc_rcar, - .receive = ravb_rx_rcar, + .poll = ravb_poll_rcar, .set_rate = ravb_set_rate_rcar, .set_feature = ravb_set_features_rcar, .dmac_init = ravb_dmac_init_rcar, @@ -2633,7 +2673,7 @@ static const struct ravb_hw_info gbeth_hw_info = { .rx_ring_free = ravb_rx_ring_free_gbeth, .rx_ring_format = ravb_rx_ring_format_gbeth, .alloc_rx_desc = ravb_alloc_rx_desc_gbeth, - .receive = ravb_rx_gbeth, + .poll = ravb_poll_gbeth, .set_rate = ravb_set_rate_gbeth, .set_feature = ravb_set_features_gbeth, .dmac_init = ravb_dmac_init_gbeth, @@ -2990,9 +3030,9 @@ static int ravb_probe(struct platform_device *pdev) goto out_dma_free; } - netif_napi_add(ndev, &priv->napi[RAVB_BE], ravb_poll); + netif_napi_add(ndev, &priv->napi[RAVB_BE], info->poll); if (info->nc_queues) - netif_napi_add(ndev, &priv->napi[RAVB_NC], ravb_poll); + netif_napi_add(ndev, &priv->napi[RAVB_NC], info->poll); /* Network device register */ error = register_netdev(ndev);