Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp2979084rwo; Mon, 24 Jul 2023 04:36:43 -0700 (PDT) X-Google-Smtp-Source: APBJJlGbqBg1SiWNRd8hqIvu+WTl9PwqSgv36E9f+eHyXXljy3hEeKtIytZ2vkfYZuZRIGMcgSNI X-Received: by 2002:a05:6a20:748b:b0:138:60e:9ba with SMTP id p11-20020a056a20748b00b00138060e09bamr12842324pzd.29.1690198602752; Mon, 24 Jul 2023 04:36:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690198602; cv=none; d=google.com; s=arc-20160816; b=BdTTkPKdN+n/jeNHdqGQr6b7PLAMcncZviGfy3Fo9QXsGCTZFvjnqOk5hJhe8dSyj4 AMYQ2F7FOky+80sDc3rniTGJuTc4vcQeN2n5ZMwy/qmdIRAKwtpf0CscG03pFh6GAlF/ fXAjRQqMK6ZBtsRwmHFQLSs0NAZEW/OIkXXpBbERu5oEvDtOGupkcCUTW39+YHcfYG14 JX7aZc8eeul/d47L2q8ew7p1zgo/M5+tpfqKP3kkhDM5V8VOoEGE5XVdKHg7MvzfYrXQ hZRw+j+MKoqKXf8iq8uvMJHq4zyXnCwVbBgFmBQdRdzZ4QJwjV1cYSahmzSvuQyNeG+O bUDA== 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=4VlwOUd0+FkSANQ+QF8KHv0L0Q9NfaBIxt05nQpl3bM=; fh=TO4fkcEI9b5r/wMetIII7RIVPqbK0XaoWpj6Tf2aW8M=; b=EQH/jEWL4klnIM/haFvLx+gn3Pet7GhW6/RMG7ft3ar4zJkBNBT+9AZz3ehgd/olPg KfUieQJVCHU/Y5ymZWbLvEPyS6b68bmvOYlqKRDibJdmOeq1fEGJEugs9vvjpTwYGnBc wxYiAxWKBYbrkyca49T0rrH+SL+Rz6WI7MpzLCtehrKLF/3F7lq43hlshSYmMLGhdmy0 BI5IkmBcWqI7n/6WlUMVBVSbPa7gBi2VhHpka0hlqE7gcXmlAFUN05JRUV/vSjS0jIOv sgAkPAGMfUjnw/fawmJFJ5mT2XiBu12SNzGyZ8Clg1tr0c7Wf1ttSd6PHasslTMjABnO bvYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="uqj/ICk6"; 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=NONE dis=NONE) header.from=ti.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g13-20020a056a000b8d00b006535a72d26csi9238670pfj.152.2023.07.24.04.36.30; Mon, 24 Jul 2023 04:36:42 -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=@ti.com header.s=ti-com-17Q1 header.b="uqj/ICk6"; 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=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229504AbjGXLcD (ORCPT + 99 others); Mon, 24 Jul 2023 07:32:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229848AbjGXLbn (ORCPT ); Mon, 24 Jul 2023 07:31:43 -0400 Received: from fllv0016.ext.ti.com (fllv0016.ext.ti.com [198.47.19.142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A46B919AB; Mon, 24 Jul 2023 04:31:09 -0700 (PDT) Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 36OBUb9Q072080; Mon, 24 Jul 2023 06:30:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1690198237; bh=4VlwOUd0+FkSANQ+QF8KHv0L0Q9NfaBIxt05nQpl3bM=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=uqj/ICk6AyIaVTsW+dBnb/OmawBoliwatmjhEoICNBl9XyXBa6GHl+XBnoh+xt506 tmF9YayDJ4j5uRbBW4+Nie1hZ+k+/slE6hwDpycVyw1p59ZnW4TrZhjDpYIcwEmUDC vFmkdnxDsxMsarqsFHIq1HrOzVtRsg63nLAjTlPs= Received: from DFLE104.ent.ti.com (dfle104.ent.ti.com [10.64.6.25]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 36OBUbuv023352 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 24 Jul 2023 06:30:37 -0500 Received: from DFLE111.ent.ti.com (10.64.6.32) by DFLE104.ent.ti.com (10.64.6.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Mon, 24 Jul 2023 06:30:37 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DFLE111.ent.ti.com (10.64.6.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Mon, 24 Jul 2023 06:30:37 -0500 Received: from fllv0122.itg.ti.com (fllv0122.itg.ti.com [10.247.120.72]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id 36OBUbkc018935; Mon, 24 Jul 2023 06:30:37 -0500 Received: from localhost (uda0501179.dhcp.ti.com [172.24.227.217]) by fllv0122.itg.ti.com (8.14.7/8.14.7) with ESMTP id 36OBUaKc007675; Mon, 24 Jul 2023 06:30:36 -0500 From: MD Danish Anwar To: Randy Dunlap , Roger Quadros , Simon Horman , Vignesh Raghavendra , Andrew Lunn , Richard Cochran , Conor Dooley , Krzysztof Kozlowski , Rob Herring , Paolo Abeni , Jakub Kicinski , Eric Dumazet , "David S. Miller" , MD Danish Anwar CC: , , , , , , Subject: [PATCH v11 08/10] net: ti: icssg-prueth: Add Standard network staticstics Date: Mon, 24 Jul 2023 16:59:32 +0530 Message-ID: <20230724112934.2637802-9-danishanwar@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230724112934.2637802-1-danishanwar@ti.com> References: <20230724112934.2637802-1-danishanwar@ti.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,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 Implement .ndo_get_stats64 to dump standard network interface statistics for ICSSG ethernet driver. Signed-off-by: MD Danish Anwar --- drivers/net/ethernet/ti/icssg_prueth.c | 21 +++++++++++++++++++++ drivers/net/ethernet/ti/icssg_prueth.h | 2 ++ drivers/net/ethernet/ti/icssg_stats.c | 13 +++++++++++++ 3 files changed, 36 insertions(+) diff --git a/drivers/net/ethernet/ti/icssg_prueth.c b/drivers/net/ethernet/ti/icssg_prueth.c index a60e0f98f425..45fa271dd014 100644 --- a/drivers/net/ethernet/ti/icssg_prueth.c +++ b/drivers/net/ethernet/ti/icssg_prueth.c @@ -1260,6 +1260,26 @@ static int emac_ndo_ioctl(struct net_device *ndev, struct ifreq *ifr, int cmd) return phy_do_ioctl(ndev, ifr, cmd); } +static void emac_ndo_get_stats64(struct net_device *ndev, + struct rtnl_link_stats64 *stats) +{ + struct prueth_emac *emac = netdev_priv(ndev); + + emac_update_hardware_stats(emac); + + stats->rx_packets = emac_get_stat_by_name(emac, "rx_packets"); + stats->rx_bytes = emac_get_stat_by_name(emac, "rx_bytes"); + stats->tx_packets = emac_get_stat_by_name(emac, "tx_packets"); + stats->tx_bytes = emac_get_stat_by_name(emac, "tx_bytes"); + stats->rx_crc_errors = emac_get_stat_by_name(emac, "rx_crc_errors"); + stats->rx_over_errors = emac_get_stat_by_name(emac, "rx_over_errors"); + + stats->rx_errors = ndev->stats.rx_errors; + stats->rx_dropped = ndev->stats.rx_dropped; + stats->tx_errors = ndev->stats.tx_errors; + stats->tx_dropped = ndev->stats.tx_dropped; +} + static const struct net_device_ops emac_netdev_ops = { .ndo_open = emac_ndo_open, .ndo_stop = emac_ndo_stop, @@ -1269,6 +1289,7 @@ static const struct net_device_ops emac_netdev_ops = { .ndo_tx_timeout = emac_ndo_tx_timeout, .ndo_set_rx_mode = emac_ndo_set_rx_mode, .ndo_eth_ioctl = emac_ndo_ioctl, + .ndo_get_stats64 = emac_ndo_get_stats64, }; /* get emac_port corresponding to eth_node name */ diff --git a/drivers/net/ethernet/ti/icssg_prueth.h b/drivers/net/ethernet/ti/icssg_prueth.h index 355bbbbd6888..b3c7b4e0b2b7 100644 --- a/drivers/net/ethernet/ti/icssg_prueth.h +++ b/drivers/net/ethernet/ti/icssg_prueth.h @@ -47,6 +47,7 @@ /* Number of ICSSG related stats */ #define ICSSG_NUM_STATS 60 +#define ICSSG_NUM_STANDARD_STATS 6 /* Firmware status codes */ #define ICSS_HS_FW_READY 0x55555555 @@ -251,4 +252,5 @@ void icssg_config_set_speed(struct prueth_emac *emac); void emac_stats_work_handler(struct work_struct *work); void emac_update_hardware_stats(struct prueth_emac *emac); +int emac_get_stat_by_name(struct prueth_emac *emac, char *stat_name); #endif /* __NET_TI_ICSSG_PRUETH_H */ diff --git a/drivers/net/ethernet/ti/icssg_stats.c b/drivers/net/ethernet/ti/icssg_stats.c index 25deb368a3f0..bb0b33927e3b 100644 --- a/drivers/net/ethernet/ti/icssg_stats.c +++ b/drivers/net/ethernet/ti/icssg_stats.c @@ -42,3 +42,16 @@ void emac_stats_work_handler(struct work_struct *work) queue_delayed_work(system_long_wq, &emac->stats_work, msecs_to_jiffies((STATS_TIME_LIMIT_1G_MS * 1000) / emac->speed)); } + +int emac_get_stat_by_name(struct prueth_emac *emac, char *stat_name) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(icssg_all_stats); i++) { + if (!strcmp(icssg_all_stats[i].name, stat_name)) + return emac->stats[icssg_all_stats[i].offset / sizeof(u32)]; + } + + netdev_err(emac->ndev, "Invalid stats %s\n", stat_name); + return -EINVAL; +} -- 2.34.1