From patchwork Mon Nov 13 11:07:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 164408 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b909:0:b0:403:3b70:6f57 with SMTP id t9csp1127122vqg; Mon, 13 Nov 2023 03:07:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IGeGmxVBZDY6Ohvyd/xsWC+fu4suAU+9vEFuaNqp22+knLKf58CHxRkYra7u6TVb39JSxVJ X-Received: by 2002:a17:903:d3:b0:1cc:6ec2:d24e with SMTP id x19-20020a17090300d300b001cc6ec2d24emr5006579plc.53.1699873649595; Mon, 13 Nov 2023 03:07:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699873649; cv=none; d=google.com; s=arc-20160816; b=V0RxktZerRs7ltiMXt/bNilzJ58jQpbiCV6iY3HpJYTWGut6lQKS9XDC0dvbQnxrGD JUt00IRtO13gF4fJYBWdGnz+BhGpg1H7RZA/Mo3OpyxW2YhxVAsmHv1tIu+JCT2XnWLx uI4IR7z9GtP8Yioi5XOpPqQnpk1txHZGYUOGfsmBUbzGi8sueeIybzZy3LfYMBkxYoQt apD8Z6wnQWsqnZZvhRmHQAof5CeiDF85zXn315PtOSsDd1usH8w66/d6xFqHnh85iOfh LMid0bnnh2YeZ/A7j9nWoPNCzMW0s8id4NJQfzgaorVP7LOmA665GVepfpvKFOKwobIq Us9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=vOJ2zl8i5yGORXWu7mjzwse4nu+xURX9QZ0b4Dd0YTI=; fh=5XVN7hYDrjkwKFw4bFXRK8oy6VkSo1QEqyD70rM4SXo=; b=G20rMtP9WzmgYu6FkDiIvdxdUreGOs+yfPU8ticYnaF12krwSVLrDNEioX194ZVajQ gCh4+XE+xwIqFpFFk95tbPwmSyUrZXeA78k8HmrNN/5unt7d3PFC7xzjGs/0fahFCUc2 RyVcOqhlBE0UGog3ApqLHPgdg1o9k07UQKv1YFAvi/jY4F3Xt605e2JDDwsAxiw7nfut euiAA5kYvUcOpSQx7u3Qqfy+m96d3pC8yMP+O0PPTAyv8jrXV2DwTbVHUM7562mKW9zJ C7UZIeqsH7Wu1SRWu9cmVLf6lXc9ad7J386vXKYWrcrbt+0293kriSG/BGGy/nG1qxqy Dhww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PdvLOAOa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id jc5-20020a17090325c500b001c7342b46e4si5056055plb.23.2023.11.13.03.07.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Nov 2023 03:07:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PdvLOAOa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 87F81804746C; Mon, 13 Nov 2023 03:07:28 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229870AbjKMLHZ (ORCPT + 29 others); Mon, 13 Nov 2023 06:07:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229470AbjKMLHX (ORCPT ); Mon, 13 Nov 2023 06:07:23 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33EE310D0 for ; Mon, 13 Nov 2023 03:07:20 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 370A5C433CB; Mon, 13 Nov 2023 11:07:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1699873639; bh=bN8FSN+y+03IPg4F931v2Jh6hFvo4bxNhLJa8WipQWM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PdvLOAOaU/wKIWKM1KxY60RwmGDSq1UXZlrBO3HC4IGqOiJrf7pMfcljXSe+AuLJc w9GU6NHQ2GFP50pewNlBiUM5VAnN6978gVSWzMQJpwUDqdNkS8i2FqbfajpFL+Bv1e 6W/2gJ2RpEjSoOt0M4uRgkToGDdE1wR4qGqhUWDI7GupWKNnSsN7aH/OincREAtWsx nycnYtSH7HNGIa4Ad00Ic6jM8irxC8lN3hq13l0OBDlfrzuYhLSM4pJ7VgTUpyJfG8 GimYD5hj6wXP6UoNDnpUhyMXrKJFQtL7swsCy+VrIfU7ufZaFSoiyHj8GYHBgzo7Fv 29q1iwDuN68jA== From: Roger Quadros To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: vladimir.oltean@nxp.com, s-vadapalli@ti.com, r-gunasekaran@ti.com, srk@ti.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Roger Quadros Subject: [PATCH net-next 1/3] net: ethernet: am65-cpsw: Add standard Ethernet MAC stats to ethtool Date: Mon, 13 Nov 2023 13:07:06 +0200 Message-Id: <20231113110708.137379-2-rogerq@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231113110708.137379-1-rogerq@kernel.org> References: <20231113110708.137379-1-rogerq@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 13 Nov 2023 03:07:28 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782446711799866741 X-GMAIL-MSGID: 1782446711799866741 Gets 'ethtool -S eth0 --groups eth-mac' command to work. Signed-off-by: Roger Quadros Reviewed-by: Andrew Lunn --- drivers/net/ethernet/ti/am65-cpsw-ethtool.c | 26 +++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/net/ethernet/ti/am65-cpsw-ethtool.c b/drivers/net/ethernet/ti/am65-cpsw-ethtool.c index c51e2af91f69..ac7276f0f77a 100644 --- a/drivers/net/ethernet/ti/am65-cpsw-ethtool.c +++ b/drivers/net/ethernet/ti/am65-cpsw-ethtool.c @@ -662,6 +662,31 @@ static void am65_cpsw_get_ethtool_stats(struct net_device *ndev, hw_stats[i].offset); } +static void am65_cpsw_get_eth_mac_stats(struct net_device *ndev, + struct ethtool_eth_mac_stats *s) +{ + struct am65_cpsw_port *port = am65_ndev_to_port(ndev); + struct am65_cpsw_stats_regs *stats; + + stats = port->stat_base; + + s->FramesTransmittedOK = readl_relaxed(&stats->tx_good_frames); + s->SingleCollisionFrames = readl_relaxed(&stats->tx_single_coll_frames); + s->MultipleCollisionFrames = readl_relaxed(&stats->tx_mult_coll_frames); + s->FramesReceivedOK = readl_relaxed(&stats->rx_good_frames); + s->FrameCheckSequenceErrors = readl_relaxed(&stats->rx_crc_errors); + s->AlignmentErrors = readl_relaxed(&stats->rx_align_code_errors); + s->OctetsTransmittedOK = readl_relaxed(&stats->tx_octets); + s->FramesWithDeferredXmissions = readl_relaxed(&stats->tx_deferred_frames); + s->LateCollisions = readl_relaxed(&stats->tx_late_collisions); + s->CarrierSenseErrors = readl_relaxed(&stats->tx_carrier_sense_errors); + s->OctetsReceivedOK = readl_relaxed(&stats->rx_octets); + s->MulticastFramesXmittedOK = readl_relaxed(&stats->tx_multicast_frames); + s->BroadcastFramesXmittedOK = readl_relaxed(&stats->tx_broadcast_frames); + s->MulticastFramesReceivedOK = readl_relaxed(&stats->rx_multicast_frames); + s->BroadcastFramesReceivedOK = readl_relaxed(&stats->rx_broadcast_frames); +}; + static int am65_cpsw_get_ethtool_ts_info(struct net_device *ndev, struct ethtool_ts_info *info) { @@ -729,6 +754,7 @@ const struct ethtool_ops am65_cpsw_ethtool_ops_slave = { .get_sset_count = am65_cpsw_get_sset_count, .get_strings = am65_cpsw_get_strings, .get_ethtool_stats = am65_cpsw_get_ethtool_stats, + .get_eth_mac_stats = am65_cpsw_get_eth_mac_stats, .get_ts_info = am65_cpsw_get_ethtool_ts_info, .get_priv_flags = am65_cpsw_get_ethtool_priv_flags, .set_priv_flags = am65_cpsw_set_ethtool_priv_flags,