Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp1065726lqs; Fri, 14 Jun 2024 13:54:30 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVNABENUW6MrjEkV/P4jCI3WIYLlQ5Nbt0tEzvdOTnEUJC3XXIuP0ny7AJdRyCvYg52NfXRUgjrGL6PGaiJ9Av3UPvn778p99MXtyLWkg== X-Google-Smtp-Source: AGHT+IHlEe2GNXCXVropIy0ybmD0Rqy/+SeAwPyjKPZG0sDsPTkTLq6ONADfl1+BK/Y2OR8qe3Lo X-Received: by 2002:a05:6808:144e:b0:3d2:1816:65a2 with SMTP id 5614622812f47-3d24ea08f14mr4954700b6e.59.1718398469395; Fri, 14 Jun 2024 13:54:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718398469; cv=pass; d=google.com; s=arc-20160816; b=mneQ7a8EFB+4BiDEhzqNlJoxOb5dE0qd/JuDPasJeb1MbIUHRDFpXFQhXnuNj7RxL2 vtMYhc3pNetTjMCZsIDPBFLZ+/NE55/vfj2dKFKM3EQkg+i9hoPlaILMo8hzH5cQ8I20 Jedt40Hw3nkTc7+wUF9bL4+7oXn2exITzS5Wjk4PCmaDdF1LONpKja4B3/HayJ9wjCEz 7pfKfFGrZsiWgQi2/4TOS3snvwSLImJP8RnP74jcbDb5zkUkH7L7kHVUWEIKxNHQlwbE svDVURNC0L0H2TnnvREKjfv9X+u+wTIb8NY+aMzY/WJAcIelZpiZpxN8e46oeRmrX9o7 CCXg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=c+Snf0whftzfpHgqudrfGK4VVlgcRO8EISXLh2sXflY=; fh=vez8J9WHllJ0ULWqjyRc3OmY6sf11ZJbZJEEZCSEOis=; b=NuFYioeR7sbTLs7qHk//YYcROISZiIAasoYBxnDSynXsaSdzMltBOoJFkfKwWaFx0b 3nf5ySDuHE1zbSAd6K8X6QZx00dWPPqOLXRj8TBjsT/QLMWBKmToWreWC4QMU1Xv98xG YJYJSCoyu4guv9Zct17PrWlZYr4umW+NxlMZB4mAJO6M1JTbMNAMmidoWVjok5DVEZK1 rTcd9FF0VgWGqDFAQFux7ekpzdmZ5EqJ79iOGqpJEpy+4uKuZqbV6mkRRkDB3OGcLI+p jqJZT0ZdBeagIS9MYVS3ZNI2BkmqsGj22PaZarrk9V1ruhErX839qlqCZ4qbSYIvpabY IBkQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=Fq43c13W; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-215487-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-215487-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id af79cd13be357-798ab9fa015si423786885a.246.2024.06.14.13.54.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 13:54:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-215487-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=Fq43c13W; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-215487-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-215487-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 1B4EC1C21A26 for ; Fri, 14 Jun 2024 20:54:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 07131158872; Fri, 14 Jun 2024 20:54:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="Fq43c13W" Received: from out-173.mta1.migadu.com (out-173.mta1.migadu.com [95.215.58.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 26DBF144D12 for ; Fri, 14 Jun 2024 20:54:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718398461; cv=none; b=V68Zz9WJXQPT/n1ucxmZrCs1G0s6h5ocKHy8flLyQ5PylnoLzimTiaRh3ojaPGMzXlSwiSGLJ7vv7sbmd0bP375RKrx/mnNBq1iQ7dxuB8d1VHA/bm2H5r2WjIMuQgSt9JCpZtROnz8VLyOgwfU/xm+2mh0pKoand/MqRWMIyUs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718398461; c=relaxed/simple; bh=5tFnLSP33aYSES0MD32VcfyfckmdVgkIQ7KT4ZPO6QE=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=ifU4opdaVmQsweQxNqYjdBKvug20QBJBASYi7a+dJZ6RKdL81GBo1Q1Su43bJTdgKMepahv32H+cmoPtd+jK7DCwSIodSXShqwO7CuowUHFo6KJrQ5ULXf/MKfHf6TsB8dx8VTSyTF8jokCKLrPoYYJWdq44i3bBRIif3jNPhs0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=Fq43c13W; arc=none smtp.client-ip=95.215.58.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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; > > ...