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 3AAE5C27C6E for ; Fri, 14 Jun 2024 20:54:42 +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:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=c+Snf0whftzfpHgqudrfGK4VVlgcRO8EISXLh2sXflY=; b=DfPr8AQVSpWI1s7J1gLVmBA/vH uqQzcBMD2Kf+WpTAQuvZqvCMT2k6JbCebaC7A2nc+hSYe9WfrOCDtPoXrQeq6eFJc49JHgP04wYAf FPaHTsMx+rEm4Uqlo8xRKBqzdhx5Lu7jLLfMfmg+X+g2+pe+6w9+DlONzhRWyCRtUx3fzH9vt70aU 4CTJ6UQlYD7YEPnTKDtRq8C1PN7BqN5v36Dq/F4J3BTKKdJRmBm4hiPmoQGs7rSJteXOc2/xaD+XT iGdLYiW58Kduf38aSvouhxI8V7O5A/PEG15rHkb4bOwXnPmBJE9Kw2H/ZV9/WPR4uZapTBAIt1uj5 /VxcW3LQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sIDwG-000000041sx-3Y9E; Fri, 14 Jun 2024 20:54:24 +0000 Received: from out-189.mta1.migadu.com ([95.215.58.189]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sIDwE-000000041sO-0l88 for linux-arm-kernel@lists.infradead.org; Fri, 14 Jun 2024 20:54:23 +0000 X-Envelope-To: horms@kernel.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1718398457; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=c+Snf0whftzfpHgqudrfGK4VVlgcRO8EISXLh2sXflY=; b=Fq43c13WJaFpPaFsTzFOH0sjUUwEp7vNoWiYtvMmNX7gB8YQRYxqQjqH+ck51zL4x8uC4s cFPbkJcKNS/Cglkq+EJcwITZL9gZY4g0uKV8/DnFvSuqTWO7FjxrkB41kDE6pW1w554mSn TZlA3LKhvrg3FZneLZ//nIHMAPI5BC8= X-Envelope-To: radhey.shyam.pandey@amd.com X-Envelope-To: netdev@vger.kernel.org X-Envelope-To: linux-arm-kernel@lists.infradead.org X-Envelope-To: michal.simek@amd.com X-Envelope-To: kuba@kernel.org X-Envelope-To: linux@armlinux.org.uk X-Envelope-To: pabeni@redhat.com X-Envelope-To: edumazet@google.com X-Envelope-To: linux-kernel@vger.kernel.org X-Envelope-To: davem@davemloft.net Message-ID: Date: Fri, 14 Jun 2024 16:54:12 -0400 MIME-Version: 1.0 Subject: Re: [PATCH net-next 3/3] net: xilinx: axienet: Add statistics support To: Simon Horman Cc: Radhey Shyam Pandey , netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Michal Simek , Jakub Kicinski , Russell King , Paolo Abeni , Eric Dumazet , linux-kernel@vger.kernel.org, "David S . Miller" References: <20240610231022.2460953-1-sean.anderson@linux.dev> <20240610231022.2460953-4-sean.anderson@linux.dev> <20240614163050.GV8447@kernel.org> Content-Language: en-US X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Sean Anderson In-Reply-To: <20240614163050.GV8447@kernel.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240614_135422_478169_2DCBA3BE X-CRM114-Status: GOOD ( 22.00 ) 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 6/14/24 12:30, Simon Horman wrote: > On Mon, Jun 10, 2024 at 07:10:22PM -0400, Sean Anderson wrote: >> Add support for reading the statistics counters, if they are enabled. >> The counters may be 64-bit, but we can't detect this as there's no >> ability bit for it and the counters are read-only. Therefore, we assume >> the counters are 32-bits. To ensure we don't miss an overflow, we need >> to read all counters at regular intervals, configurable with >> stats-block-usecs. This should be often enough to ensure the bytes >> counters don't wrap at 2.5 Gbit/s. >> >> Another complication is that the counters may be reset when the device >> is reset (depending on configuration). To ensure the counters persist >> across link up/down (including suspend/resume), we maintain our own >> 64-bit versions along with the last counter value we saw. Because we >> might wait up to 100 ms for the reset to complete, we use a mutex to >> protect writing hw_stats. We can't sleep in ndo_get_stats64, so we use a >> u64_stats_sync to protect readers. >> >> We can't use the byte counters for either get_stats64 or >> get_eth_mac_stats. This is because the byte counters include everything >> in the frame (destination address to FCS, inclusive). But >> rtnl_link_stats64 wants bytes excluding the FCS, and >> ethtool_eth_mac_stats wants to exclude the L2 overhead (addresses and >> length/type). >> >> Signed-off-by: Sean Anderson >> --- >> >> drivers/net/ethernet/xilinx/xilinx_axienet.h | 81 ++++++ >> .../net/ethernet/xilinx/xilinx_axienet_main.c | 267 +++++++++++++++++- >> 2 files changed, 345 insertions(+), 3 deletions(-) >> >> diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet.h b/drivers/net/ethernet/xilinx/xilinx_axienet.h > > ... > >> @@ -434,6 +502,11 @@ struct skbuf_dma_descriptor { >> * @tx_packets: TX packet count for statistics >> * @tx_bytes: TX byte count for statistics >> * @tx_stat_sync: Synchronization object for TX stats >> + * @hw_last_counter: Last-seen value of each statistic >> + * @hw_stats: Interface statistics periodically updated from hardware counters >> + * @hw_stats_sync: Synchronization object for @hw_stats > > nit: s/hw_stats_sync/hw_stat_sync/ > > Flagged by kernel-doc -none I think I will rename the member instead. --Sean >> + * @stats_lock: Lock for writing @hw_stats and @hw_last_counter >> + * @stats_work: Work for reading the hardware statistics counters >> * @dma_err_task: Work structure to process Axi DMA errors >> * @tx_irq: Axidma TX IRQ number >> * @rx_irq: Axidma RX IRQ number >> @@ -452,6 +525,7 @@ struct skbuf_dma_descriptor { >> * @coalesce_usec_rx: IRQ coalesce delay for RX >> * @coalesce_count_tx: Store the irq coalesce on TX side. >> * @coalesce_usec_tx: IRQ coalesce delay for TX >> + * @coalesce_usec_stats: Delay between hardware statistics refreshes >> * @use_dmaengine: flag to check dmaengine framework usage. >> * @tx_chan: TX DMA channel. >> * @rx_chan: RX DMA channel. >> @@ -505,6 +579,12 @@ struct axienet_local { >> u64_stats_t tx_bytes; >> struct u64_stats_sync tx_stat_sync; >> >> + u32 hw_last_counter[STAT_COUNT]; >> + u64_stats_t hw_stats[STAT_COUNT]; >> + struct u64_stats_sync hw_stat_sync; >> + struct mutex stats_lock; >> + struct delayed_work stats_work; >> + >> struct work_struct dma_err_task; >> >> int tx_irq; > > ...