From patchwork Thu Jun 17 09:49:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Esben Haabendal X-Patchwork-Id: 12327195 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8EF8CC2B9F4 for ; Thu, 17 Jun 2021 09:49:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 78FDB613D5 for ; Thu, 17 Jun 2021 09:49:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231881AbhFQJv0 (ORCPT ); Thu, 17 Jun 2021 05:51:26 -0400 Received: from first.geanix.com ([116.203.34.67]:41892 "EHLO first.geanix.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231845AbhFQJvZ (ORCPT ); Thu, 17 Jun 2021 05:51:25 -0400 Received: from localhost (unknown [185.17.218.86]) by first.geanix.com (Postfix) with ESMTPSA id A788A4C325D; Thu, 17 Jun 2021 09:49:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=geanix.com; s=first; t=1623923355; bh=IoCXtXJsUbap8V+xD8LLq4yWJQOOPHd9bY+uNZyTmtI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=h92R3X3MIoTX+PyZqVzLxvBcdkD9GKH6GJ7/sHPVE04LX2p90vqLAiUUgbpMqI2Yl YrdTQVDr25wqG+xiaAVpB6tD28va4qsT2RQF3XKq1uAau3JOuCcem60SynoZc/dLse mxXn2PDauo1QI30FVclAO7RkLgNuUBpKuY2Phr9M66a2/M/xRJjDy3eINUD6x1WuLi znjGB5DCELW7KQNvDX/P0Fi1tWubgX/wXVpGYaZg/z8S6KJURSvE29/HAHQ2i1D9h1 qp7djyr0eawQLGYXQguaVs/iwuTd9OjkZE5P+Htj1GmJSJQuC4XR3Z7ZhbTy0r4eSi JV0S4PNlBR2Wg== From: Esben Haabendal To: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Rasmus Villemoes , Claudiu Manoil , "David S. Miller" , Jakub Kicinski Subject: [PATCH 1/6] net: gianfar: Convert to ndo_get_stats64 interface Date: Thu, 17 Jun 2021 11:49:15 +0200 Message-Id: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org No reason to produce the legacy net_device_stats struct, only to have it converted to rtnl_link_stats64. And as a bonus, this allows for improving counter size to 64 bit. Signed-off-by: Esben Haabendal --- drivers/net/ethernet/freescale/gianfar.c | 25 +++++++----------------- 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c index f2945abdb041..a0277fe8cc60 100644 --- a/drivers/net/ethernet/freescale/gianfar.c +++ b/drivers/net/ethernet/freescale/gianfar.c @@ -274,32 +274,21 @@ static void gfar_configure_coalescing_all(struct gfar_private *priv) gfar_configure_coalescing(priv, 0xFF, 0xFF); } -static struct net_device_stats *gfar_get_stats(struct net_device *dev) +static void gfar_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats) { struct gfar_private *priv = netdev_priv(dev); - unsigned long rx_packets = 0, rx_bytes = 0, rx_dropped = 0; - unsigned long tx_packets = 0, tx_bytes = 0; int i; for (i = 0; i < priv->num_rx_queues; i++) { - rx_packets += priv->rx_queue[i]->stats.rx_packets; - rx_bytes += priv->rx_queue[i]->stats.rx_bytes; - rx_dropped += priv->rx_queue[i]->stats.rx_dropped; + stats->rx_packets += priv->rx_queue[i]->stats.rx_packets; + stats->rx_bytes += priv->rx_queue[i]->stats.rx_bytes; + stats->rx_dropped += priv->rx_queue[i]->stats.rx_dropped; } - dev->stats.rx_packets = rx_packets; - dev->stats.rx_bytes = rx_bytes; - dev->stats.rx_dropped = rx_dropped; - for (i = 0; i < priv->num_tx_queues; i++) { - tx_bytes += priv->tx_queue[i]->stats.tx_bytes; - tx_packets += priv->tx_queue[i]->stats.tx_packets; + stats->tx_bytes += priv->tx_queue[i]->stats.tx_bytes; + stats->tx_packets += priv->tx_queue[i]->stats.tx_packets; } - - dev->stats.tx_bytes = tx_bytes; - dev->stats.tx_packets = tx_packets; - - return &dev->stats; } /* Set the appropriate hash bit for the given addr */ @@ -3157,7 +3146,7 @@ static const struct net_device_ops gfar_netdev_ops = { .ndo_set_rx_mode = gfar_set_multi, .ndo_tx_timeout = gfar_timeout, .ndo_do_ioctl = gfar_ioctl, - .ndo_get_stats = gfar_get_stats, + .ndo_get_stats64 = gfar_get_stats64, .ndo_change_carrier = fixed_phy_change_carrier, .ndo_set_mac_address = gfar_set_mac_addr, .ndo_validate_addr = eth_validate_addr, From patchwork Thu Jun 17 09:49:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Esben Haabendal X-Patchwork-Id: 12327197 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F1F6C2B9F4 for ; Thu, 17 Jun 2021 09:49:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 66B32613CE for ; Thu, 17 Jun 2021 09:49:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231895AbhFQJvb (ORCPT ); Thu, 17 Jun 2021 05:51:31 -0400 Received: from first.geanix.com ([116.203.34.67]:41912 "EHLO first.geanix.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231847AbhFQJv1 (ORCPT ); Thu, 17 Jun 2021 05:51:27 -0400 Received: from localhost (unknown [185.17.218.86]) by first.geanix.com (Postfix) with ESMTPSA id 648C64C3292; Thu, 17 Jun 2021 09:49:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=geanix.com; s=first; t=1623923358; bh=aDM42wVtbFCJQul8ZRo2dGnWDMYAECSz7+N9SXJwEfM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=lPIb+TbAyDUb9X+kTt6qJiqah6OFv1RQPCh2F5hIfntOwc47MbXRhhCAUoT5vVdyB tiW2uMcB8lK544FeQpw1P+gLlQhlYMDoOO7sVCWwdaBL2zUqAnbdhFxoyhQHTrwwEp pZLEiVDhYmPQMtOqbyI1XU1wDHEJ7f+RY0/KFic5OK4BvNjhfjKMXg4NfCKGPvXYLx UfYcca/AfLRc/pm9cHjgn2c2rK+Byo5/G4bEI9hiEdgXtXCkVqWQnA7XqS/4eWTICn dByDs3dH8bUWo6ocK8MrF2Imj92TIYy+6vOzxaOnNEqbZLVAUFqCnxc9ujjbCiOORQ yj5hG63N7j73A== From: Esben Haabendal To: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Rasmus Villemoes , Claudiu Manoil , "David S. Miller" , Jakub Kicinski Subject: [PATCH 2/6] net: gianfar: Extend statistics counters to 64-bit Date: Thu, 17 Jun 2021 11:49:17 +0200 Message-Id: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org No reason to wrap counter values at 2^32. Especially the bytes counters can wrap pretty fast on Gbit networks. Signed-off-by: Esben Haabendal --- drivers/net/ethernet/freescale/gianfar.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/freescale/gianfar.h b/drivers/net/ethernet/freescale/gianfar.h index 5ea47df93e5e..d8ae5353e881 100644 --- a/drivers/net/ethernet/freescale/gianfar.h +++ b/drivers/net/ethernet/freescale/gianfar.h @@ -913,8 +913,8 @@ enum { * Per TX queue stats */ struct tx_q_stats { - unsigned long tx_packets; - unsigned long tx_bytes; + u64 tx_packets; + u64 tx_bytes; }; /** @@ -963,9 +963,9 @@ struct gfar_priv_tx_q { * Per RX queue stats */ struct rx_q_stats { - unsigned long rx_packets; - unsigned long rx_bytes; - unsigned long rx_dropped; + u64 rx_packets; + u64 rx_bytes; + u64 rx_dropped; }; struct gfar_rx_buff { From patchwork Thu Jun 17 09:49:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Esben Haabendal X-Patchwork-Id: 12327199 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F41BDC2B9F4 for ; Thu, 17 Jun 2021 09:49:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DBD59613D5 for ; Thu, 17 Jun 2021 09:49:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231908AbhFQJvd (ORCPT ); Thu, 17 Jun 2021 05:51:33 -0400 Received: from first.geanix.com ([116.203.34.67]:41918 "EHLO first.geanix.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231873AbhFQJva (ORCPT ); Thu, 17 Jun 2021 05:51:30 -0400 Received: from localhost (unknown [185.17.218.86]) by first.geanix.com (Postfix) with ESMTPSA id 106774C325D; Thu, 17 Jun 2021 09:49:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=geanix.com; s=first; t=1623923361; bh=Uk5FCCq/1hvryiYQiavefB+WTK09cJgC9AtSy84qEt0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=GnnqdQ5V/UeL4MATP7d7kuaHLuKjFWGWmCX7OvdCB+Ed2c88XZ02kn9IIEDwEq4Jj dItGk5y35TPEhcibTjc85UQ2nG1bImQ96nikqRAcUn4iBEcQrx79IK5HgfDvgRMKm/ XIpCFGFRl9rQE7B4paV1KKTidbeIVA4uOSBTOe7kBO7CF+ZGXXZTAPgZ1sU7EQzo/j K9HdgolAGZZ8ulFj8pmxZXR0cvNVWwwe8xrrBM+2m4LF2uJdkJa53Icp9xpZ9WtNYr +w4vyJSNOQ25set5m5akPFMsB0F9/A2L/ssvf5d3RoTPQt1JK0G2/+KfoZYoLkn5XF 0oKYPjd63/SJQ== From: Esben Haabendal To: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Rasmus Villemoes , Claudiu Manoil , "David S. Miller" , Jakub Kicinski Subject: [PATCH 3/6] net: gianfar: Clear CAR registers Date: Thu, 17 Jun 2021 11:49:20 +0200 Message-Id: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The CAR1 and CAR2 registers are W1C style registers, to the memset does not actually clear them. Signed-off-by: Esben Haabendal --- drivers/net/ethernet/freescale/gianfar.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c index a0277fe8cc60..ebd1065f39fa 100644 --- a/drivers/net/ethernet/freescale/gianfar.c +++ b/drivers/net/ethernet/freescale/gianfar.c @@ -3103,6 +3103,9 @@ static void gfar_hw_init(struct gfar_private *priv) /* Mask off the CAM interrupts */ gfar_write(®s->rmon.cam1, 0xffffffff); gfar_write(®s->rmon.cam2, 0xffffffff); + /* Clear the CAR registers (w1c style) */ + gfar_write(®s->rmon.car1, 0xffffffff); + gfar_write(®s->rmon.car2, 0xffffffff); } /* Initialize ECNTRL */ From patchwork Thu Jun 17 09:49:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Esben Haabendal X-Patchwork-Id: 12327201 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E027BC2B9F4 for ; Thu, 17 Jun 2021 09:49:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C2D63613BF for ; Thu, 17 Jun 2021 09:49:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231847AbhFQJvk (ORCPT ); Thu, 17 Jun 2021 05:51:40 -0400 Received: from first.geanix.com ([116.203.34.67]:41936 "EHLO first.geanix.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231845AbhFQJvd (ORCPT ); Thu, 17 Jun 2021 05:51:33 -0400 Received: from localhost (unknown [185.17.218.86]) by first.geanix.com (Postfix) with ESMTPSA id B2E3D4C329C; Thu, 17 Jun 2021 09:49:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=geanix.com; s=first; t=1623923363; bh=DU/8XgCmqOcU1c6ia7VRITPn2rmzotPkskeH7i2WLuE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=RgrmVPT09wm4owgY4qqyp8/Cci0ulXlxBLzQH/V6PWyzfV0B+YZZoqHaAAYmrtzhw fKIbQ+trbTrGvtF7YQJZTlJTLuHNFGtMDdeLOgEV1FiowJSmaJ3HVdNA6QQmcpmJrs /CkWA61DVbjlYzWX+EA8sljVcnjTUx3nw/MvOsylX9fDerHOnBs5kpQv3eaRS/O4KN H5qhRnMrIHBtlHZZswU+VcoPKc5jdnlVtSiVVqQHaLLin5Tu03eqOcSOfTGj0LQHgl EiCbGbZ2j8/Yt7DjTBrdbiCdfeX7rk5D0268u3aNIXBXE8SU5iAX6OzsrDUqwpX+A3 eF3O0kvBnpE0A== From: Esben Haabendal To: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Rasmus Villemoes , Claudiu Manoil , "David S. Miller" , Jakub Kicinski Subject: [PATCH 4/6] net: gianfar: Avoid 16 bytes of memset Date: Thu, 17 Jun 2021 11:49:23 +0200 Message-Id: <3550366c0e6eda798a36a6695e6b4736e41e40ab.1623922686.git.esben@geanix.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The memset on CAMx is wrong, as it actually unmasks all carry irq's, which we clearly are not interested in. The memset on CARx registers is just pointless, as they are W1C. So let's just stop the memset before CAR1. Signed-off-by: Esben Haabendal --- drivers/net/ethernet/freescale/gianfar.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c index ebd1065f39fa..4608c0c337bc 100644 --- a/drivers/net/ethernet/freescale/gianfar.c +++ b/drivers/net/ethernet/freescale/gianfar.c @@ -3098,7 +3098,7 @@ static void gfar_hw_init(struct gfar_private *priv) /* Zero out the rmon mib registers if it has them */ if (priv->device_flags & FSL_GIANFAR_DEV_HAS_RMON) { - memset_io(&(regs->rmon), 0, sizeof(struct rmon_mib)); + memset_io(®s->rmon, 0, offsetof(struct rmon_mib, car1)); /* Mask off the CAM interrupts */ gfar_write(®s->rmon.cam1, 0xffffffff); From patchwork Thu Jun 17 09:49:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Esben Haabendal X-Patchwork-Id: 12327203 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, UNWANTED_LANGUAGE_BODY,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 862EAC2B9F4 for ; Thu, 17 Jun 2021 09:49:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6DE0D613BF for ; Thu, 17 Jun 2021 09:49:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231983AbhFQJvn (ORCPT ); Thu, 17 Jun 2021 05:51:43 -0400 Received: from first.geanix.com ([116.203.34.67]:41950 "EHLO first.geanix.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231926AbhFQJvf (ORCPT ); Thu, 17 Jun 2021 05:51:35 -0400 Received: from localhost (unknown [185.17.218.86]) by first.geanix.com (Postfix) with ESMTPSA id A0E214C329E; Thu, 17 Jun 2021 09:49:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=geanix.com; s=first; t=1623923366; bh=TsS7BAMz2l0iG7vhnR5TeopRChL28In0UoMCZn1qkw0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=QGwXIf1uXAkOYFZlTSJnJFCQGKXNOfQYSVeyrAxePSlzmknUftDpJd0V1TrOBtzmp tuqfXyCrfkFgULgOyBfP3i0vUN0HT6y4hzld+lZBpNbybCwNfkyUEzvnUcvhKLwBTJ Wobi9zywUN3bgPJkNzIYP8p3O6cO4hyLSE9sbXqvVVL5EPH8vjeH7vIEvFKZlpzC8K mdEZZlUV/POqI1GSP4IUA3DGJmKZLMSClU4tIspNP5u1/E4Ff/YscAkak1dX/KqUxA vQ+34eKsixFELWPlzT2wywNRyODSvLICpFFfgZsm+Sp4jJcMK0kQp4LJDpv5O+JhNr 8T3q3Pd7EeDpw== From: Esben Haabendal To: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Rasmus Villemoes , Claudiu Manoil , "David S. Miller" , Jakub Kicinski Subject: [PATCH 5/6] net: gianfar: Add definitions for CAR1 and CAM1 register bits Date: Thu, 17 Jun 2021 11:49:26 +0200 Message-Id: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org These are for carry status and interrupt mask bits of statistics registers. Signed-off-by: Esben Haabendal --- drivers/net/ethernet/freescale/gianfar.h | 54 ++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/drivers/net/ethernet/freescale/gianfar.h b/drivers/net/ethernet/freescale/gianfar.h index d8ae5353e881..c8aa140a910f 100644 --- a/drivers/net/ethernet/freescale/gianfar.h +++ b/drivers/net/ethernet/freescale/gianfar.h @@ -445,6 +445,60 @@ struct ethtool_rx_list { #define RQFPR_PER 0x00000002 #define RQFPR_EER 0x00000001 +/* CAR1 bits */ +#define CAR1_C164 0x80000000 +#define CAR1_C1127 0x40000000 +#define CAR1_C1255 0x20000000 +#define CAR1_C1511 0x10000000 +#define CAR1_C11K 0x08000000 +#define CAR1_C1MAX 0x04000000 +#define CAR1_C1MGV 0x02000000 +#define CAR1_C1REJ 0x00020000 +#define CAR1_C1RBY 0x00010000 +#define CAR1_C1RPK 0x00008000 +#define CAR1_C1RFC 0x00004000 +#define CAR1_C1RMC 0x00002000 +#define CAR1_C1RBC 0x00001000 +#define CAR1_C1RXC 0x00000800 +#define CAR1_C1RXP 0x00000400 +#define CAR1_C1RXU 0x00000200 +#define CAR1_C1RAL 0x00000100 +#define CAR1_C1RFL 0x00000080 +#define CAR1_C1RCD 0x00000040 +#define CAR1_C1RCS 0x00000020 +#define CAR1_C1RUN 0x00000010 +#define CAR1_C1ROV 0x00000008 +#define CAR1_C1RFR 0x00000004 +#define CAR1_C1RJB 0x00000002 +#define CAR1_C1RDR 0x00000001 + +/* CAM1 bits */ +#define CAM1_M164 0x80000000 +#define CAM1_M1127 0x40000000 +#define CAM1_M1255 0x20000000 +#define CAM1_M1511 0x10000000 +#define CAM1_M11K 0x08000000 +#define CAM1_M1MAX 0x04000000 +#define CAM1_M1MGV 0x02000000 +#define CAM1_M1REJ 0x00020000 +#define CAM1_M1RBY 0x00010000 +#define CAM1_M1RPK 0x00008000 +#define CAM1_M1RFC 0x00004000 +#define CAM1_M1RMC 0x00002000 +#define CAM1_M1RBC 0x00001000 +#define CAM1_M1RXC 0x00000800 +#define CAM1_M1RXP 0x00000400 +#define CAM1_M1RXU 0x00000200 +#define CAM1_M1RAL 0x00000100 +#define CAM1_M1RFL 0x00000080 +#define CAM1_M1RCD 0x00000040 +#define CAM1_M1RCS 0x00000020 +#define CAM1_M1RUN 0x00000010 +#define CAM1_M1ROV 0x00000008 +#define CAM1_M1RFR 0x00000004 +#define CAM1_M1RJB 0x00000002 +#define CAM1_M1RDR 0x00000001 + /* TxBD status field bits */ #define TXBD_READY 0x8000 #define TXBD_PADCRC 0x4000 From patchwork Thu Jun 17 09:49:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Esben Haabendal X-Patchwork-Id: 12327205 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 506FBC2B9F4 for ; Thu, 17 Jun 2021 09:49:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 38F0F613DB for ; Thu, 17 Jun 2021 09:49:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232009AbhFQJvt (ORCPT ); Thu, 17 Jun 2021 05:51:49 -0400 Received: from first.geanix.com ([116.203.34.67]:41964 "EHLO first.geanix.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231945AbhFQJvj (ORCPT ); Thu, 17 Jun 2021 05:51:39 -0400 Received: from localhost (unknown [185.17.218.86]) by first.geanix.com (Postfix) with ESMTPSA id 7C79F4C329F; Thu, 17 Jun 2021 09:49:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=geanix.com; s=first; t=1623923369; bh=feNRlUYMtFeRKEObT62vVB8ErOgRqSori+/2ECKwuUU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=F4gY/oqMXIkpltdc8EckPCqLjHXZdafUjLweVqy2phE2PidsqCBeqaeZj5KBn7Qdl vRZL48V+IlkLUWz4TIL9tPzhlupmNWa4yqG00ji0baSUdfqOYw1n7i28YkrmH3w9hU cdj3+UkeMvOSOhJTz8aRGR/ndoDn5iLZfjocLMC7RB6OVksFXhf3+oddVArgLpM0Rs PeBflBvD8MBW6SngntdM6unsSE+ZS6vY8AJA7/oj0cncAqaj1FcEn61Eg7IDoVJto7 86fFK2gfFMeq2z9xIWhv1207Cf5tiQIDJrMi8ZXqQZKzSnntAG8Rkk4s5tsFE7C2ps vYGxcsZYCPRTQ== From: Esben Haabendal To: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Rasmus Villemoes , Claudiu Manoil , "David S. Miller" , Jakub Kicinski Subject: [PATCH 6/6] net: gianfar: Implement rx_missed_errors counter Date: Thu, 17 Jun 2021 11:49:28 +0200 Message-Id: <6786b85ee59f57f64cfe60683fc7be498ad8cf47.1623922686.git.esben@geanix.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Devices with RMON support has a 16-bit RDRP counter. It provides: "Receive dropped packets counter. Increments for frames received which are streamed to system but are later dropped due to lack of system resources." To handle more than 2^16 dropped packets, a carry bit in CAR1 register is set on overflow, so we enable irq when this is set, extending the counter to 2^64 for handling situations where lots of packets are missed (e.g. during heavy network storms). Signed-off-by: Esben Haabendal --- drivers/net/ethernet/freescale/gianfar.c | 50 ++++++++++++++++++++++-- drivers/net/ethernet/freescale/gianfar.h | 10 +++++ 2 files changed, 57 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c index 4608c0c337bc..9646483137c4 100644 --- a/drivers/net/ethernet/freescale/gianfar.c +++ b/drivers/net/ethernet/freescale/gianfar.c @@ -289,6 +289,29 @@ static void gfar_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *s stats->tx_bytes += priv->tx_queue[i]->stats.tx_bytes; stats->tx_packets += priv->tx_queue[i]->stats.tx_packets; } + + if (priv->device_flags & FSL_GIANFAR_DEV_HAS_RMON) { + struct rmon_mib __iomem *rmon = &priv->gfargrp[0].regs->rmon; + unsigned long flags; + u32 rdrp, car, car_before; + u64 rdrp_offset; + + spin_lock_irqsave(&priv->rmon_overflow.lock, flags); + car = gfar_read(&rmon->car1) & CAR1_C1RDR; + do { + car_before = car; + rdrp = gfar_read(&rmon->rdrp); + car = gfar_read(&rmon->car1) & CAR1_C1RDR; + } while (car != car_before); + if (car) { + priv->rmon_overflow.rdrp++; + gfar_write(&rmon->car1, car); + } + rdrp_offset = priv->rmon_overflow.rdrp; + spin_unlock_irqrestore(&priv->rmon_overflow.lock, flags); + + stats->rx_missed_errors = rdrp + (rdrp_offset << 16); + } } /* Set the appropriate hash bit for the given addr */ @@ -379,7 +402,8 @@ static void gfar_ints_enable(struct gfar_private *priv) for (i = 0; i < priv->num_grps; i++) { struct gfar __iomem *regs = priv->gfargrp[i].regs; /* Unmask the interrupts we look for */ - gfar_write(®s->imask, IMASK_DEFAULT); + gfar_write(®s->imask, + IMASK_DEFAULT | priv->rmon_overflow.imask); } } @@ -2287,7 +2311,7 @@ static irqreturn_t gfar_receive(int irq, void *grp_id) if (likely(napi_schedule_prep(&grp->napi_rx))) { spin_lock_irqsave(&grp->grplock, flags); imask = gfar_read(&grp->regs->imask); - imask &= IMASK_RX_DISABLED; + imask &= IMASK_RX_DISABLED | grp->priv->rmon_overflow.imask; gfar_write(&grp->regs->imask, imask); spin_unlock_irqrestore(&grp->grplock, flags); __napi_schedule(&grp->napi_rx); @@ -2311,7 +2335,7 @@ static irqreturn_t gfar_transmit(int irq, void *grp_id) if (likely(napi_schedule_prep(&grp->napi_tx))) { spin_lock_irqsave(&grp->grplock, flags); imask = gfar_read(&grp->regs->imask); - imask &= IMASK_TX_DISABLED; + imask &= IMASK_TX_DISABLED | grp->priv->rmon_overflow.imask; gfar_write(&grp->regs->imask, imask); spin_unlock_irqrestore(&grp->grplock, flags); __napi_schedule(&grp->napi_tx); @@ -2682,6 +2706,18 @@ static irqreturn_t gfar_error(int irq, void *grp_id) } netif_dbg(priv, tx_err, dev, "Transmit Error\n"); } + if (events & IEVENT_MSRO) { + struct rmon_mib __iomem *rmon = ®s->rmon; + u32 car; + + spin_lock(&priv->rmon_overflow.lock); + car = gfar_read(&rmon->car1) & CAR1_C1RDR; + if (car) { + priv->rmon_overflow.rdrp++; + gfar_write(&rmon->car1, car); + } + spin_unlock(&priv->rmon_overflow.lock); + } if (events & IEVENT_BSY) { dev->stats.rx_over_errors++; atomic64_inc(&priv->extra_stats.rx_bsy); @@ -3259,6 +3295,14 @@ static int gfar_probe(struct platform_device *ofdev) gfar_hw_init(priv); + if (priv->device_flags & FSL_GIANFAR_DEV_HAS_RMON) { + struct rmon_mib __iomem *rmon = &priv->gfargrp[0].regs->rmon; + + spin_lock_init(&priv->rmon_overflow.lock); + priv->rmon_overflow.imask = IMASK_MSRO; + gfar_write(&rmon->cam1, gfar_read(&rmon->cam1) & ~CAM1_M1RDR); + } + /* Carrier starts down, phylib will bring it up */ netif_carrier_off(dev); diff --git a/drivers/net/ethernet/freescale/gianfar.h b/drivers/net/ethernet/freescale/gianfar.h index c8aa140a910f..ca5e14f908fe 100644 --- a/drivers/net/ethernet/freescale/gianfar.h +++ b/drivers/net/ethernet/freescale/gianfar.h @@ -663,6 +663,15 @@ struct rmon_mib u32 cam2; /* 0x.73c - Carry Mask Register Two */ }; +struct rmon_overflow { + /* lock for synchronization of the rdrp field of this struct, and + * CAR1/CAR2 registers + */ + spinlock_t lock; + u32 imask; + u64 rdrp; +}; + struct gfar_extra_stats { atomic64_t rx_alloc_err; atomic64_t rx_large; @@ -1150,6 +1159,7 @@ struct gfar_private { /* Network Statistics */ struct gfar_extra_stats extra_stats; + struct rmon_overflow rmon_overflow; /* PHY stuff */ phy_interface_t interface;