Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp1810705rdb; Wed, 31 Jan 2024 09:40:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IGgQXFoqU08eIYsz0cTldmKwta2Aa3FIsoogLKAKwyXP9jDD8m1PcrYFzxi5m1s16Jnosqw X-Received: by 2002:a17:902:ce83:b0:1d8:b51c:6b79 with SMTP id f3-20020a170902ce8300b001d8b51c6b79mr3068727plg.7.1706722801734; Wed, 31 Jan 2024 09:40:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706722801; cv=pass; d=google.com; s=arc-20160816; b=ZdI+BIXuZGXQArw+AacpaoJr0PtiE1pweLJ2cQTrTOjIrdSv2BQSWNcb9JdgvUsB+1 UZ8uNxtRrM4diPl1P0wPxtRgs1wlnA8n/vcQBG9Zv3qIWjvL3eErnKT7R7tMPpSOoR8X wKu0CwMw/AQCJ60l86IzoMZJjmna0OYias1HL5ColoOoAX6CT0qpMSiLKBxtgntgCcZl bWMRpXrPO8UVZjkocNqTTKcd8fxnecgBhlhDGKgpjXiEzEX5NHJpGAhE+u1gRhXIJrCZ 0cCrsWrNg4vWDvIjgUQcZpFGxiChmT9p/jpBCskdm9q50itIaROEL5pKvuNm1Db7QTWZ 9YAw== 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=iPR68BBy22PipOycnih0nZvKnqFAXCdpHzLdi9bBox8=; b=ntL9x+0bE8pinFWWw+Ond6xaxHg3hRoXEWWq1lj/ROr8lScIQcnZMUssS7W2e0NEsd 0V7EvOpj6jz2Ksv4PSbRgdvCQPhvvDrvz8HvR91qu0gOZ8B2OS1Tj8TAea5AtYGq9Ho5 8KmqbRN8N8y8ISIQBOobb5iVUW3l119BFp2glSdOI8BxuusUNLG76rQAYijyuZHVP1Pe vCoZ46TM6SiNv4qANMPfTzHR87QUGPnYSu/RDuFiXSzY1LqCYu/mlFBrokxC71QLmjz4 pYuzAugmimsBbnMI8oEOe6lL9dx5YfyR9VKQfAMn7006UfpIaUQnbP2wr4P0TlAlTIIw s/GA==; 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-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46863-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=renesas.com X-Forwarded-Encrypted: i=1; AJvYcCXvY1SuBsfwIRUS7RQTr7jVgoLIfX+kJj0QxPVZnnVvL3V515o0P6Y4jRK2OPP4X3WV+zcLdRAT2ABvh0eX+pBKrtiCjUG+30jTxX7avA== Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id v2-20020a170902d68200b001d910f0ac28si3271752ply.89.2024.01.31.09.40.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 09:40:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-46863-linux.lists.archive=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-46863-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46863-linux.lists.archive=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 B61E6B2CE89 for ; Wed, 31 Jan 2024 17:06:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 53FB912DD8A; Wed, 31 Jan 2024 17:05:59 +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 Content-Transfer-Encoding: 8bit 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); -- 2.39.2