Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp388906rdg; Thu, 12 Oct 2023 08:28:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHmJDgmwg+RVSUqQUACf26gIvNzx1Hbx1Ldl+NZA9JklSxrVqhu5Brn3oRKVxGIc2fUS681 X-Received: by 2002:a17:902:da84:b0:1c1:ed61:e058 with SMTP id j4-20020a170902da8400b001c1ed61e058mr29801073plx.16.1697124531538; Thu, 12 Oct 2023 08:28:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697124531; cv=none; d=google.com; s=arc-20160816; b=LXEC9lig1bU27slD+FsVGk+e0yBKOHTgdZ+h+wDYeNGN4sKI+A3+Rdv/Adtmp0lOCZ DVh8Mu5BxDXHeTM0Gg+8j+m+YELVrEbrLFQ0RZUoJg5ivw+WiJx9NfoHgNSyKYhxpzwi l1+277qR27KqtlT7td/GLp9f1hYjVHhDvZnVhGBvcUUjYQXPdROfy3Kb92u2rb4SL/Qm En1PNOKu1Ak9EOO6j9VDRg++Ji7hFhaMU2oI/Fvxew3j9vRVdLy6jl52oLUGt9GCIP6v io/WEUFIchr2DKudBA/H6Gs/vxrbViyFQBeUs/a9xuOr7/qafLkBQPqBZM0kpvM3YGwU QKHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=LtxAnAjUqRhHfJGOc405Qbe6cZQPQAf92M0E/m+mSns=; fh=RuYSrahU4DCWDaKaOnBQfVhPzSgZ94GSocxAc9RNlYE=; b=xsVRxBKUqQ0nOqzQJAzZ8IevWjHKZdb51kAeLzrKJ987o9YqTaIUuG63gkx8mPeGKL mK4ZVeLKRm3ST8Krn3sPI/GQSyC244XuflBZP3Xg9jbeWn785f9MpP7sW109mbmoe0JH a0DGB1tGe/j1mvZrovxq9DWRcWm0eV/DC5ZqETeMJCsb4kiM3fBMoJek+n7yB4HsD3CK jqs7ZmUDEgphX4xce6xbn8JocNCznwbRucanCTOjalCoBsjp8B4GR9uSY4UMljW6311N CI0lqo/28FoOzKcZDpIvsPfqU9YVrZnxwa+j4js940S8iOT58ogTAhlf1NYnGwSDmxe6 X18w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=QiGAjHtD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id f9-20020a17090274c900b001bc434b9d95si2221977plt.156.2023.10.12.08.28.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 08:28:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=QiGAjHtD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id F0EB7819D1E5; Thu, 12 Oct 2023 08:28:45 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379373AbjJLP2g (ORCPT + 99 others); Thu, 12 Oct 2023 11:28:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379229AbjJLP2f (ORCPT ); Thu, 12 Oct 2023 11:28:35 -0400 Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A4ECBE; Thu, 12 Oct 2023 08:28:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=LtxAnAjUqRhHfJGOc405Qbe6cZQPQAf92M0E/m+mSns=; b=QiGAjHtDTnv4+anA8SuXlkh7jk NIfxlHDjYt/UXj7RN33ePAKEzZtnZI0fJcB0srWzakaHsSNSIcL3sf5KPxe+kKWAK4xpc8c6eT4zc H1MI+GTILX9PxysGH6pHmH39RHzeXDS0qVWhByuo44rRXgcCj/2fvPwmcucM4/WQwtmA=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1qqxbv-001xOP-DJ; Thu, 12 Oct 2023 17:28:27 +0200 Date: Thu, 12 Oct 2023 17:28:27 +0200 From: Andrew Lunn To: MD Danish Anwar Cc: Paolo Abeni , Jakub Kicinski , Eric Dumazet , "David S. Miller" , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, srk@ti.com, Vignesh Raghavendra , r-gunasekaran@ti.com, Roger Quadros Subject: Re: [PATCH] net: ti: icssg-prueth: Fix tx_total_bytes count Message-ID: <524856b3-6876-48d1-aebf-09f7f6c71f7b@lunn.ch> References: <20231011063700.1824093-1-danishanwar@ti.com> <4d7c2ab9-e980-42a5-9452-79bc0d33e094@lunn.ch> <7b5f195f-c5c8-6847-9458-3d5563cf0112@ti.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7b5f195f-c5c8-6847-9458-3d5563cf0112@ti.com> X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email 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 (agentk.vger.email [0.0.0.0]); Thu, 12 Oct 2023 08:28:46 -0700 (PDT) On Thu, Oct 12, 2023 at 10:51:12AM +0530, MD Danish Anwar wrote: > Hi Andrew, > > On 11/10/23 18:11, Andrew Lunn wrote: > >> @@ -29,7 +30,12 @@ void emac_update_hardware_stats(struct prueth_emac *emac) > >> base + icssg_all_stats[i].offset, > >> val); > >> > >> + if (!strncmp(icssg_ethtool_stats[i].name, "tx_good_frames", ETH_GSTRING_LEN)) > >> + tx_pkt_cnt = val; > > > > Doing a strncmp seems very expensive. Could you make use of > > icssg_stats.offset? > > > > Sure. I can define the offset of these two stats and then use them in if > condition as below. > > #define ICSSG_TX_PACKET_OFFSET 0xA0 > #define ICSSG_TX_BYTE_OFFSET 0xEC > > if (icssg_ethtool_stats[i].offset == ICSSG_TX_PACKET_OFFSET) > tx_pkt_cnt = val; > > if (icssg_ethtool_stats[i].offset == ICSSG_TX_BYTE_OFFSET) > emac->stats[i] -= tx_pkt_cnt * 8; That is much better. Also consider adding something like: BUILD_BUG_ON(ICSSG_TX_PACKET_OFFSET < ICSSG_TX_BYTE_OFFSET) I've no idea if this is correct. Just something to prove at build time that ICSSG_TX_PACKET_OFFSET is read before ICSSG_TX_BYTE_OFFSET. Andrew