From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5923EC531DC for ; Sat, 17 Aug 2024 02:43:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Subject:Cc:To: From:Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=YlN/2r25Mykr4Mx1GwsjAqr1v/J/XpHbNrT5zvjMprg=; b=Kva3+NWH9s6SmIRGdRaVMFIPru BqDqnahPxm7g1wdI5EqWok5tSLAxLKSvwvZERJc0JqUH3NjVVbe6Cx0q0Byde6+LekRccJZjlc6/6 pVKVQJn7VaGLX9eaCZwBstXgbiMgbxhDOH6qvKHqQlZ0Ai/jam2DiD6W2dNAj65EjyJgSoiv2ONuT SP0fDVXskTPjVpyWHUsZbFigriUQ1TjaTMxqjms5den3+FuGpOndz49lHwkLJQ8o+uke2GOJKA/wG lWAx2DY2x55k9PLaSrN+u6y8phyJu06k/g9MQmFiVZ0b2yyH/F/i37pquAvggIpGEgUdTKH5huRFJ bh+cNJIg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sf9Pe-0000000EWbT-3o9I; Sat, 17 Aug 2024 02:43:30 +0000 Received: from sin.source.kernel.org ([145.40.73.55]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sf9ON-0000000EWQD-3HHq for linux-arm-kernel@lists.infradead.org; Sat, 17 Aug 2024 02:42:13 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id CB2A6CE2104; Sat, 17 Aug 2024 02:42:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0EA13C32782; Sat, 17 Aug 2024 02:42:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1723862525; bh=l7c+tqqb/MEMAkjLmzruqEhMtkaDk2Uid0ORzOuA0pQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=JR7YHaDDV54RwgDhRgPYtrLdn9l/cl37v5X6Y/SlZK+vFMqYVEAOf54T/p+U36vOh wYFIrZQ9LuJ76TY1uCOop/pHo1JdqkBGMFWTLhbV1u2s4yZYAZXNBDSAcA2RKU6K3H 86CtTBcDJRVAaAIoFwTn38VZ0CTrB/E+ShlB3abihR3b0th0/R2VKebda/AAUSGgRe fRMzbVYrQN8+s2NFkuapeRTHw/YjOAyWHTTSWA5FaT3e5lk4CnQhrZeaujqz141wpI /4T6fjvECkecteMx9VtL5OifkNLvM3i11G7o4E3Y8NUQ7FpLiEPx0sXmcI6VGD6S/j ujgzu01UjaX7Q== Date: Fri, 16 Aug 2024 19:42:03 -0700 From: Jakub Kicinski To: Sean Anderson Cc: Andrew Lunn , Radhey Shyam Pandey , netdev@vger.kernel.org, Simon Horman , Michal Simek , linux-kernel@vger.kernel.org, "David S . Miller" , Russell King , linux-arm-kernel@lists.infradead.org, Eric Dumazet , Paolo Abeni Subject: Re: [PATCH net-next v3 2/2] net: xilinx: axienet: Add statistics support Message-ID: <20240816194203.05753edf@kernel.org> In-Reply-To: <20240815144031.4079048-3-sean.anderson@linux.dev> References: <20240815144031.4079048-1-sean.anderson@linux.dev> <20240815144031.4079048-3-sean.anderson@linux.dev> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240816_194212_035176_04C376D0 X-CRM114-Status: GOOD ( 13.72 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, 15 Aug 2024 10:40:31 -0400 Sean Anderson wrote: > + u64 hw_stat_base[STAT_COUNT]; > + u64 hw_last_counter[STAT_COUNT]; I think hw_last_counter has to be u32.. > + seqcount_mutex_t hw_stats_seqcount; > + struct mutex stats_lock; > + struct delayed_work stats_work; > + bool reset_in_progress; > + > struct work_struct dma_err_task; > > int tx_irq; > diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c > index b2d7c396e2e3..9353a4f0ab1b 100644 > --- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c > +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c > @@ -519,11 +519,55 @@ static void axienet_setoptions(struct net_device *ndev, u32 options) > lp->options |= options; > } > > +static u64 axienet_stat(struct axienet_local *lp, enum temac_stat stat) > +{ > + u32 counter; > + > + if (lp->reset_in_progress) > + return lp->hw_stat_base[stat]; > + > + counter = axienet_ior(lp, XAE_STATS_OFFSET + stat * 8); > + return lp->hw_stat_base[stat] + (counter - lp->hw_last_counter[stat]); .. or you need to cast the (counter - lp->...) result to u32. Otherwise counter's type is getting bumped to 64 and you're just doing 64b math here. > +} > + > +static void axienet_stats_update(struct axienet_local *lp, bool reset) > +{ > + enum temac_stat stat; > + > + write_seqcount_begin(&lp->hw_stats_seqcount); > + lp->reset_in_progress = reset; > + for (stat = 0; stat < STAT_COUNT; stat++) { > + u32 counter = axienet_ior(lp, XAE_STATS_OFFSET + stat * 8); > + > + lp->hw_stat_base[stat] += counter - lp->hw_last_counter[stat]; > + lp->hw_last_counter[stat] = counter; > + } > + write_seqcount_end(&lp->hw_stats_seqcount);