From patchwork Thu Jul 13 22:19:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Chen X-Patchwork-Id: 120125 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp2123841vqm; Thu, 13 Jul 2023 15:21:44 -0700 (PDT) X-Google-Smtp-Source: APBJJlE5upy/yTRNrVzHEYHjfuaLzTQWljcyQFDJJiV6ql8mwgzlWgM1eHygt+FQtKEnEuY9cG4I X-Received: by 2002:a05:6358:4402:b0:134:c850:e8c5 with SMTP id z2-20020a056358440200b00134c850e8c5mr4615422rwc.19.1689286904233; Thu, 13 Jul 2023 15:21:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689286904; cv=none; d=google.com; s=arc-20160816; b=ja/ojiaL5mAQ5o30iHCvZJhByGIMYechc7SyHk8KqnqeixAhzXHO5DBYEa5TDXuFRT Eh31cdGCWqM4dbVfWaYKDr9O2o/zA6wEtk8JIySQUY2NvKK9nkvjaEo9934IDkK3fj/v 1fzZEWq7G8h+7bZY1IJ6rA3VH8R68mQxTWfkqT9Y6oAxRqpT5Irg6Xl6ExVF5GMZXHjg i4Cq2llqRYz8pyrw98MxNQaRI8GaP3Go42GpBlENpZgDollX4O3FwaE+BQYyXUVvIzmQ RzGmmX1BD6u7BpojECJUoTjrnAIigrjXInuEhw5hQorMj28lE+xQQ7qpph+saEewOrzg VZFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=/nC38yDv4AGEg0pB9FEwRHgyjA+fCmHly7MHhx15ouI=; fh=auIu3uj+2hbF0lD5w/46TjOR2iYLfsn3CHYsSny1RMQ=; b=O1wNb8VbS8FLDf0rdQyHW+u2U0yoMymSl6ifaePXYQKywln2cukWUbKC/ShhA+vs1q TpY7dI5LW9WETZlFUpxWjaJztBSrijODLRDIir9rtouT0L6p+G8tF5ymH+2d4HvqUtfA GN6dSkseI1Bc3wc18fZcYjh+zl/7S+N8iJqIsfoqD2uTZu62itjLkSShfZIdqG90Jn9D 92ATNk3chxf8rMny5YBaQflFF7g+hgAGSpMowTGJIZYds1/8fwU+zC2utAPDUEaI07G5 BYfFA/Yf5oQLnKKAjRclQaUlmgBV5WjtfOGfJ5TIikpIdIerhtvXY0Lg64S8zCIPZqhn cP8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b="GTP4Vt/w"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 63-20020a630242000000b0053439c1712esi5649678pgc.713.2023.07.13.15.21.30; Thu, 13 Jul 2023 15:21:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b="GTP4Vt/w"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233910AbjGMWUO (ORCPT + 99 others); Thu, 13 Jul 2023 18:20:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232990AbjGMWT5 (ORCPT ); Thu, 13 Jul 2023 18:19:57 -0400 Received: from mail-vs1-xe2a.google.com (mail-vs1-xe2a.google.com [IPv6:2607:f8b0:4864:20::e2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99ECE3590 for ; Thu, 13 Jul 2023 15:19:33 -0700 (PDT) Received: by mail-vs1-xe2a.google.com with SMTP id ada2fe7eead31-443628ee79dso537513137.1 for ; Thu, 13 Jul 2023 15:19:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1689286772; x=1691878772; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=/nC38yDv4AGEg0pB9FEwRHgyjA+fCmHly7MHhx15ouI=; b=GTP4Vt/w5Jot4+PmyDSDeDxCVkRfHxORhXpF1aUiuLCtqnQ6eRC1osmAzBnfPeIoNY O7oHXzAc8cuC9sU1V7KtIsCblOLapvIOpoSLP99Bx6AmwNViGW/9JlFZSl/u5PK5fSTS sZIM0mYqtYLC7F9ltb76jvkBAAp4xCop8TXxQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689286772; x=1691878772; h=references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=/nC38yDv4AGEg0pB9FEwRHgyjA+fCmHly7MHhx15ouI=; b=G09aTsAZuzWLqiQvZcRX7BY5C7CcYv3b8n7r4z+y9JmaBMc9gaG0BDyy1KJ0hkgDiQ LYe4MAlrGkMUrDMlUVCXms5j5XHaX6SSKNqFyXYlYJzdrmEP1f6WPnPeerUAPpluF6/z CkDPqResN+7shV6XP9zevpIj0JqzHjvjo1utXd2waG3Zmof++IQlXKk65NlcxvQndQ4H oMxL8jon/uk5tYJjLQL9mHKT28HNG4sXdwMJ1/Lujbe0+Zlyezg7hAlGffuL1Ex1g1Y7 EZ7LTnewDzF5XAJjMQi9snlBN47aierrfmzhRuTrtSIlLhtGrWjPWS5a7YvCOikSgC3P eJuA== X-Gm-Message-State: ABy/qLahXUnPkIodZxDPhvjf5qF/rLGgHNmIBpIt7SGvd/K83/w9vxJm gasZ6C7v/QhPEjaZw6CnyhBZ7Q== X-Received: by 2002:a67:f88e:0:b0:443:6352:4651 with SMTP id h14-20020a67f88e000000b0044363524651mr2098160vso.22.1689286771896; Thu, 13 Jul 2023 15:19:31 -0700 (PDT) Received: from stbirv-lnx-2.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id i14-20020a0cf38e000000b006262de12a8csm427623qvk.65.2023.07.13.15.19.29 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2023 15:19:31 -0700 (PDT) From: Justin Chen To: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, bcm-kernel-feedback-list@broadcom.com Cc: florian.fainelli@broadcom.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, opendmb@gmail.com, andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, richardcochran@gmail.com, sumit.semwal@linaro.org, simon.horman@corigine.com, christian.koenig@amd.com, Justin Chen Subject: [net-next v9 07/11] net: bcmasp: Add support for ethtool standard stats Date: Thu, 13 Jul 2023 15:19:02 -0700 Message-Id: <1689286746-43609-8-git-send-email-justin.chen@broadcom.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1689286746-43609-1-git-send-email-justin.chen@broadcom.com> References: <1689286746-43609-1-git-send-email-justin.chen@broadcom.com> X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, MIME_HEADER_CTYPE_ONLY,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,T_TVD_MIME_NO_HEADERS 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-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771345704906231086 X-GMAIL-MSGID: 1771345704906231086 Add support for eth_mac_stats, rmon_stats, and eth_ctrl_stats. Signed-off-by: Justin Chen --- .../net/ethernet/broadcom/asp2/bcmasp_ethtool.c | 77 ++++++++++++++++++++++ .../net/ethernet/broadcom/asp2/bcmasp_intf_defs.h | 63 +++++++++++++++++- 2 files changed, 139 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/broadcom/asp2/bcmasp_ethtool.c b/drivers/net/ethernet/broadcom/asp2/bcmasp_ethtool.c index 1e96a69043f3..59d853c2293c 100644 --- a/drivers/net/ethernet/broadcom/asp2/bcmasp_ethtool.c +++ b/drivers/net/ethernet/broadcom/asp2/bcmasp_ethtool.c @@ -250,6 +250,80 @@ static int bcmasp_set_eee(struct net_device *dev, struct ethtool_eee *e) return phy_ethtool_set_eee(dev->phydev, e); } +static void bcmasp_get_eth_mac_stats(struct net_device *dev, + struct ethtool_eth_mac_stats *mac_stats) +{ + struct bcmasp_intf *intf = netdev_priv(dev); + + mac_stats->FramesTransmittedOK = umac_rl(intf, UMC_GTPOK); + mac_stats->SingleCollisionFrames = umac_rl(intf, UMC_GTSCL); + mac_stats->MultipleCollisionFrames = umac_rl(intf, UMC_GTMCL); + mac_stats->FramesReceivedOK = umac_rl(intf, UMC_GRPOK); + mac_stats->FrameCheckSequenceErrors = umac_rl(intf, UMC_GRFCS); + mac_stats->AlignmentErrors = umac_rl(intf, UMC_GRALN); + mac_stats->OctetsTransmittedOK = umac_rl(intf, UMC_GTBYT); + mac_stats->FramesWithDeferredXmissions = umac_rl(intf, UMC_GTDRF); + mac_stats->LateCollisions = umac_rl(intf, UMC_GTLCL); + mac_stats->FramesAbortedDueToXSColls = umac_rl(intf, UMC_GTXCL); + mac_stats->OctetsReceivedOK = umac_rl(intf, UMC_GRBYT); + mac_stats->MulticastFramesXmittedOK = umac_rl(intf, UMC_GTMCA); + mac_stats->BroadcastFramesXmittedOK = umac_rl(intf, UMC_GTBCA); + mac_stats->FramesWithExcessiveDeferral = umac_rl(intf, UMC_GTEDF); + mac_stats->MulticastFramesReceivedOK = umac_rl(intf, UMC_GRMCA); + mac_stats->BroadcastFramesReceivedOK = umac_rl(intf, UMC_GRBCA); +} + +static const struct ethtool_rmon_hist_range bcmasp_rmon_ranges[] = { + { 0, 64}, + { 65, 127}, + { 128, 255}, + { 256, 511}, + { 512, 1023}, + { 1024, 1518}, + { 1519, 1522}, + {} +}; + +static void bcmasp_get_rmon_stats(struct net_device *dev, + struct ethtool_rmon_stats *rmon_stats, + const struct ethtool_rmon_hist_range **ranges) +{ + struct bcmasp_intf *intf = netdev_priv(dev); + + *ranges = bcmasp_rmon_ranges; + + rmon_stats->undersize_pkts = umac_rl(intf, UMC_RRUND); + rmon_stats->oversize_pkts = umac_rl(intf, UMC_GROVR); + rmon_stats->fragments = umac_rl(intf, UMC_RRFRG); + rmon_stats->jabbers = umac_rl(intf, UMC_GRJBR); + + rmon_stats->hist[0] = umac_rl(intf, UMC_GR64); + rmon_stats->hist[1] = umac_rl(intf, UMC_GR127); + rmon_stats->hist[2] = umac_rl(intf, UMC_GR255); + rmon_stats->hist[3] = umac_rl(intf, UMC_GR511); + rmon_stats->hist[4] = umac_rl(intf, UMC_GR1023); + rmon_stats->hist[5] = umac_rl(intf, UMC_GR1518); + rmon_stats->hist[6] = umac_rl(intf, UMC_GRMGV); + + rmon_stats->hist_tx[0] = umac_rl(intf, UMC_TR64); + rmon_stats->hist_tx[1] = umac_rl(intf, UMC_TR127); + rmon_stats->hist_tx[2] = umac_rl(intf, UMC_TR255); + rmon_stats->hist_tx[3] = umac_rl(intf, UMC_TR511); + rmon_stats->hist_tx[4] = umac_rl(intf, UMC_TR1023); + rmon_stats->hist_tx[5] = umac_rl(intf, UMC_TR1518); + rmon_stats->hist_tx[6] = umac_rl(intf, UMC_TRMGV); +} + +static void bcmasp_get_eth_ctrl_stats(struct net_device *dev, + struct ethtool_eth_ctrl_stats *ctrl_stats) +{ + struct bcmasp_intf *intf = netdev_priv(dev); + + ctrl_stats->MACControlFramesTransmitted = umac_rl(intf, UMC_GTXCF); + ctrl_stats->MACControlFramesReceived = umac_rl(intf, UMC_GRXCF); + ctrl_stats->UnsupportedOpcodesReceived = umac_rl(intf, UMC_GRXUO); +} + const struct ethtool_ops bcmasp_ethtool_ops = { .get_drvinfo = bcmasp_get_drvinfo, .get_link = ethtool_op_get_link, @@ -263,4 +337,7 @@ const struct ethtool_ops bcmasp_ethtool_ops = { .set_rxnfc = bcmasp_set_rxnfc, .set_eee = bcmasp_set_eee, .get_eee = bcmasp_get_eee, + .get_eth_mac_stats = bcmasp_get_eth_mac_stats, + .get_rmon_stats = bcmasp_get_rmon_stats, + .get_eth_ctrl_stats = bcmasp_get_eth_ctrl_stats, }; diff --git a/drivers/net/ethernet/broadcom/asp2/bcmasp_intf_defs.h b/drivers/net/ethernet/broadcom/asp2/bcmasp_intf_defs.h index b259a475207f..ad742612895f 100644 --- a/drivers/net/ethernet/broadcom/asp2/bcmasp_intf_defs.h +++ b/drivers/net/ethernet/broadcom/asp2/bcmasp_intf_defs.h @@ -45,7 +45,68 @@ #define UMC_EEE_LPI_TIMER 0x68 #define UMC_PAUSE_CNTRL 0x330 #define UMC_TX_FLUSH 0x334 -#define UMC_MIB_START 0x400 +#define UMC_GR64 0x400 +#define UMC_GR127 0x404 +#define UMC_GR255 0x408 +#define UMC_GR511 0x40c +#define UMC_GR1023 0x410 +#define UMC_GR1518 0x414 +#define UMC_GRMGV 0x418 +#define UMC_GR2047 0x41c +#define UMC_GR4095 0x420 +#define UMC_GR9216 0x424 +#define UMC_GRPKT 0x428 +#define UMC_GRBYT 0x42c +#define UMC_GRMCA 0x430 +#define UMC_GRBCA 0x434 +#define UMC_GRFCS 0x438 +#define UMC_GRXCF 0x43c +#define UMC_GRXPF 0x440 +#define UMC_GRXUO 0x444 +#define UMC_GRALN 0x448 +#define UMC_GRFLR 0x44c +#define UMC_GRCDE 0x450 +#define UMC_GRFCR 0x454 +#define UMC_GROVR 0x458 +#define UMC_GRJBR 0x45c +#define UMC_GRMTUE 0x460 +#define UMC_GRPOK 0x464 +#define UMC_GRUC 0x468 +#define UMC_GRPPP 0x46c +#define UMC_GRMCRC 0x470 +#define UMC_TR64 0x480 +#define UMC_TR127 0x484 +#define UMC_TR255 0x488 +#define UMC_TR511 0x48c +#define UMC_TR1023 0x490 +#define UMC_TR1518 0x494 +#define UMC_TRMGV 0x498 +#define UMC_TR2047 0x49c +#define UMC_TR4095 0x4a0 +#define UMC_TR9216 0x4a4 +#define UMC_GTPKT 0x4a8 +#define UMC_GTMCA 0x4ac +#define UMC_GTBCA 0x4b0 +#define UMC_GTXPF 0x4b4 +#define UMC_GTXCF 0x4b8 +#define UMC_GTFCS 0x4bc +#define UMC_GTOVR 0x4c0 +#define UMC_GTDRF 0x4c4 +#define UMC_GTEDF 0x4c8 +#define UMC_GTSCL 0x4cc +#define UMC_GTMCL 0x4d0 +#define UMC_GTLCL 0x4d4 +#define UMC_GTXCL 0x4d8 +#define UMC_GTFRG 0x4dc +#define UMC_GTNCL 0x4e0 +#define UMC_GTJBR 0x4e4 +#define UMC_GTBYT 0x4e8 +#define UMC_GTPOK 0x4ec +#define UMC_GTUC 0x4f0 +#define UMC_RRPKT 0x500 +#define UMC_RRUND 0x504 +#define UMC_RRFRG 0x508 +#define UMC_RRBYT 0x50c #define UMC_MIB_CNTRL 0x580 #define UMC_MIB_CNTRL_RX_CNT_RST BIT(0) #define UMC_MIB_CNTRL_RUNT_CNT_RST BIT(1)