🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #25823

Re: [PATCH net-next v7 6/6] ionic: Add .get_fec_stats ethtool handler

#25823
From: Vadim Fedorenko
Date: Wed, 02 Dec 2026 14:13
140 lines
13480 bytes
On 01/12/2026 06:48, Eric Joyner wrote:
> Reports FEC statistics totals and an 802.3ck FEC histogram. Per-lane
> counts currently aren't supported. Every counter reported here comes
> from the RS decoder, including fec_corrected_bits_total despite its
> name, and the only histogram format firmware produces is the 16-bin one
> from RS(544,514), so nothing is reported unless RS is the active FEC
> mode. The only devices whose firmware reports the histogram do not
> support RS(528,514), so RS on those devices is always RS(544,514).
> 
> These are physical port counters, so virtual functions are skipped the
> same way ionic_get_link_ext_stats() skips them, rather than reporting the
> port's counters as if they belonged to the VF.
> 
> The reporting of these statistics is gated by DEV_CAP_EXTRA_STATS and
> checks for IONIC_STAT_INVALID, since only the newest devices support
> reporting all of these stats. Older devices can only report some of the
> statistics or not at all, and so the output will properly exclude those
> unsupported statistics.
> 
> The firmware writes these counters by DMA while they are being read.
> Use READ_ONCE() to ensure that the IONIC_STAT_INVALID test and the store
> see the same value. Counters are still read one at a time, so the set
> reported can span more than one firmware update.
> 
> Co-developed-by: Nikhil P. Rao <nikhil.rao@amd.com>
> Signed-off-by: Nikhil P. Rao <nikhil.rao@amd.com>
> Signed-off-by: Eric Joyner <eric.joyner@amd.com>
> Signed-off-by: Brett Creeley <brett.creeley@amd.com>
> ---
>   .../net/ethernet/pensando/ionic/ionic_ethtool.c    | 86 ++++++++++++++++++++++
>   1 file changed, 86 insertions(+)
> 
> diff --git a/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c b/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c
> index c25483134b93..8f316d1ed9f2 100644
> --- a/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c
> +++ b/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c
> @@ -465,6 +465,91 @@ static int ionic_get_fecparam(struct net_device *netdev,
>   	return 0;
>   }
>   
> +#define IONIC_FEC_STAT(dst, src)			\
> +	do {						\
> +		__le64 __val = READ_ONCE(src);		\
> +							\
> +		if (__val != IONIC_STAT_INVALID)	\
> +			(dst) = le64_to_cpu(__val);	\
> +	} while (0)
> +
> +static const struct ethtool_fec_hist_range ionic_fec_hist_ranges[] = {
> +	{ 0, 0},
> +	{ 1, 1},
> +	{ 2, 2},
> +	{ 3, 3},
> +	{ 4, 4},
> +	{ 5, 5},
> +	{ 6, 6},
> +	{ 7, 7},
> +	{ 8, 8},
> +	{ 9, 9},
> +	{ 10, 10},
> +	{ 11, 11},
> +	{ 12, 12},
> +	{ 13, 13},
> +	{ 14, 14},
> +	{ 15, 15},
> +	{ 0, 0},
> +};
> +
> +static void
> +ionic_fill_fec_hist(const struct ionic_port_extra_stats *extra_stats,
> +		    struct ethtool_fec_hist *hist)
> +{
> +	int i;
> +
> +	for (i = 0; i < ARRAY_SIZE(extra_stats->fec_codeword_error_bin); i++) {
> +		__le64 val = READ_ONCE(extra_stats->fec_codeword_error_bin[i]);
> +
> +		if (val == IONIC_STAT_INVALID)
> +			return;
> +
> +		hist->values[i].sum = le64_to_cpu(val);
> +	}
> +
> +	hist->ranges = ionic_fec_hist_ranges;
> +}
> +
> +static void ionic_get_fec_stats(struct net_device *netdev,
> +				struct ethtool_fec_stats *fec_stats,
> +				struct ethtool_fec_hist *hist)
> +{
> +	struct ionic_lif *lif = netdev_priv(netdev);
> +	struct ionic_port_info *port_info;
> +	u32 active_fec;
> +	u32 fec;
> +
> +	if (lif->ionic->pdev->is_virtfn)
> +		return;
> +
> +	if (test_bit(IONIC_LIF_F_FW_RESET, lif->state))
> +		return;
> +
> +	if (!(lif->ionic->ident.dev.capabilities &
> +	      cpu_to_le64(IONIC_DEV_CAP_EXTRA_STATS)))
> +		return;
> +
> +	port_info = lif->ionic->idev.port_info;
> +	if (!port_info) {
> +		netdev_err_once(netdev, "port_info not initialized\n");
> +		return;
> +	}
> +
> +	ionic_get_fec_modes(port_info, &fec, &active_fec);
> +	if (active_fec != ETHTOOL_FEC_RS)
> +		return;
> +
> +	IONIC_FEC_STAT(fec_stats->corrected_blocks.total,
> +		       port_info->extra_stats.rsfec_correctable_blocks);
> +	IONIC_FEC_STAT(fec_stats->uncorrectable_blocks.total,
> +		       port_info->extra_stats.rsfec_uncorrectable_blocks);
> +	IONIC_FEC_STAT(fec_stats->corrected_bits.total,
> +		       port_info->extra_stats.fec_corrected_bits_total);
> +
> +	ionic_fill_fec_hist(&port_info->extra_stats, hist);
> +}
> +
>   static int ionic_set_fecparam(struct net_device *netdev,
>   			      struct ethtool_fecparam *fec)
>   {
> @@ -1206,6 +1291,7 @@ static const struct ethtool_ops ionic_ethtool_ops = {
>   	.get_module_eeprom_by_page	= ionic_get_module_eeprom_by_page,
>   	.get_pauseparam		= ionic_get_pauseparam,
>   	.set_pauseparam		= ionic_set_pauseparam,
> +	.get_fec_stats		= ionic_get_fec_stats,
>   	.get_fecparam		= ionic_get_fecparam,
>   	.set_fecparam		= ionic_set_fecparam,
>   	.get_ts_info		= ionic_get_ts_info,
> 

Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
Technical Details
Message-ID: <810544e0-8dcc-47f0-8ec3-c59f253da95a@linux.dev>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375840-linux-kernel-netdev=dewy.ru
References: <20261130-ionic-get-fec-stats-v7-0-730c1672f561@amd.com> <20261130-ionic-get-fec-stats-v7-6-730c1672f561@amd.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375840-linux-kernel-netdev=dewy.ru
From: vadim.fedorenko@linux.dev (Vadim Fedorenko)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v7 6/6] ionic: Add .get_fec_stats ethtool handler
Date: Wed, 2 Dec 2026 14:13:14 +0000
Organization: Usenet Network
Message-ID: <810544e0-8dcc-47f0-8ec3-c59f253da95a@linux.dev>
References: <20261130-ionic-get-fec-stats-v7-0-730c1672f561@amd.com>
 <20261130-ionic-get-fec-stats-v7-6-730c1672f561@amd.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
	logging-data="1986877"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:VzItU2thwWqSWRfRKx6HjBUXDpM= sha256:KxHFgYe+J8CnjkzNPcxdE51IX0j0TNWcs14muB1ADpA=
	sha1:hkqizTg3x3nYzSbW2uFWvtOQXWg= sha256:Ex62Bzop2mzR8NudL3UDf/U6qCdE9N3AuYGFEhV1dII=
Content-Language: en-US
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id D7F9C117620; Wed,  2 Dec 2026 17:13:53 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.15
X-Spam-Status: No, score=-3.15 tagged_above=-9999 required=6.31
	tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
	HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
	URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key)
	header.d=linux.dev
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id rRIxhvJ1fUZG;
	Wed,  2 Dec 2026 17:13:51 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-375840-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=linux.dev
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id DFF40117660; Wed,  2 Dec 2026 17:13:41 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id D43812BE7E; Wed,  2 Dec 2026 14:13:19 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796220799;
	b=BOLrex2UU5nVmw0HkeUeMqtR5J8gjCR2B1iL9cFavxsjSOAinJ+WH5OQxIwZp4iyn9MD
	 29s2onT6eukxM0e9wU05iorM3z/ul09VNkTwdHDw8k7vNwTTdm72S4TueHgNtkldxgyVG
	 r3NAzeQ9zCXYDQLIp1ek0kj7oVCvVU6MkJ/6ObpZRiXiks7K7+6PsGxtrWEZijZmMIIzV
	 7JpBFoTAKObP9H1uDHn9T1P7/gHcICIwbJNeTRK6V8MUBncoUnnDy/cxASJ9ESie3G/YK
	 NbDOky74cdvk189F7LjfO3bfh5yNKzf7xwd4elpDQTtGI3V36FHre7SavlUbFj/OzUg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796220799;
	h=X-Original-To:Received:DMARC-Filter:X-Envelope-To:DKIM-Signature:
	 X-Envelope-To:Received:X-Mizu-Trace-ID:X-Migadu-Flow:Message-ID:Date:
	 X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:User-Agent:
	 Subject:To:Cc:References:Content-Language:From:In-Reply-To:
	 Content-Type:Content-Transfer-Encoding;
	bh=atNMNhm/oLV2gE8eR8JUKQv6kspMKGy9NkTwDjj+41o=;
	b=bGbTbONcXWv+cUVrFTw7C0ZDqnBswbaQLC7EP1eHXdP8hpcbTh2rVVjbn+fTmJtTHKWx
	 vSL1bLv7eynkzsjV/f1/VllYEtevPzlUD/nrj6UBgKtA1j7/zddC4PSHANl861mqEernS
	 VJezOHanZjn+jiZaAXZmvSw/rXQhYS9zciXgF4kil1Y5zc4rjck28MxpxAwNiEWj1/ABr
	 9NlY6CKAxKXHUfTVPXJie4lNe7TsoBeqKLDNsrhSo3YzQrF0PSQChdgHb9FCSt8/eLaUA
	 wStjlHBiTvpV7vFr+bLKohf1w9jYGlEgiWCyYGJijNABtx4SEho5KkogoSe0EcALE7w==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=I9lQD4UX;
	dmarc=pass header.from=linux.dev;
	spf=pass smtp.mailfrom=linux.dev;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 5C83D606A332;
	Wed,  2 Dec 2026 14:13:19 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=I9lQD4UX
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.26
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796220798;
	b=Y9wxn20ocepx77jMK90AR4IUupLFvOBjn6ehqqrVakY0nIJBHJwITqN4z/oR+ok1FbUq
	 AxWgNR+nDONHfe+6d3eRis1qmwrkopXVwIZ4K0gaDlV/kfJ5XYy4N14SCiX1f6jCJJWG/
	 5ThRXkJm4Bh1AQALoWJssMxhikHSaxqNw8NzaokbAz/57oFrH98DLrO60X36jDieBYxbn
	 eDH0FHiC7NYt09+Irycv32d0GA5xS0KchuYKmJZGugeIbwAcZKQwJrVWvJNtmGR/+ieCK
	 QkdMaJ2g6/LbHC5nqO6LkjpQAzfIXF1xF16FiEbkGKOSMuXispAeNujD0Ro1X+fDLhg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796220798;
	h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received:
	 X-Mizu-Trace-ID:X-Migadu-Flow:Message-ID:Date:MIME-Version:User-Agent:
	 Subject:To:Cc:References:Content-Language:From:In-Reply-To:
	 Content-Type:Content-Transfer-Encoding;
	bh=atNMNhm/oLV2gE8eR8JUKQv6kspMKGy9NkTwDjj+41o=;
	b=MCpEXXQyOS/DotPDDBFC892bIrKvWK9m0c3C1mVsrPvLKiIHMQzr7UGjHmpXp1Mff4V0
	 HZj0edRqtzM3uSu5aOvn11YhXXgEGC/tLi83+ZxB75sCIM5Ru/zRorqqU0h8CJidJ0fBP
	 JLP9kpAlfDmQsPh1dGSpdvrSAW9F4HeEGWThuff+TayKoALbpNq0A9pLcCFo6ZF7tOU/g
	 CFVOsgzlN4G588ZE3vcwa1xq9oeM9qqw8nqRxaYE+XyvCp/aPn01375orKY6v6EN8v07b
	 tUpK2kOVoTpXG2GUseZRm/NUpqkoBK1kpGaL2h68MI/NFbKiFwdvl3QocsF6NRMFdxg==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=linux.dev;
	spf=pass smtp.mailfrom=linux.dev;
	dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=I9lQD4UX;
	arc=none smtp.remote-ip=91.218.175.26
X-Received: from mta0.migadu.com (out-26.mta0.migadu.com [91.218.175.26])
	(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id B2C32606A31A
	for <netdev@vger.kernel.org>; Wed,  2 Dec 2026 14:13:17 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B2C32606A31A
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev
X-Envelope-To: netdev@vger.kernel.org
X-DKIM-Signature: a=rsa-sha256; bh=YGieFcK32eELe9S5jDyzZh6f7dk81exvEpEnwEaSGy0=;
 c=simple/simple; d=linux.dev;
 h=from:to:subject:date:message-id:mime-version:content-type; s=key1;
 t=1796220795; v=1; x=1796825595;
 b=I9lQD4UXIG+INsdUphojrdgKX0mSlZWV5FrhQEyC5NXXGm06Cg96P0rHhdhuLblrLCIAaFKn
 AC8cFb4puMJBc2KNxKeExloWIZK48k4Ajq+/bmnoIAf8WpoVTW0l9V32BkbM01ZzN8DdsmLvO3V
 B46ErTdve8oLQlDmfwrhDRk0=
X-Envelope-To: netdev@vger.kernel.org
X-Received: by smtp.migadu.com with ESMTPS id 900fe808ef1d1d97;
	Wed, 02 Dec 2026 14:13:15 +0000
X-Mizu-Trace-ID: 900fe808ef1d1d97
X-Migadu-Flow: FLOW_OUT
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-User-Agent: Mozilla Thunderbird
X-Cc: Brett Creeley <brett.creeley@amd.com>, Andrew Lunn
 <andrew+netdev@lunn.ch>, "David S. Miller" <davem@davemloft.net>,
 Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
 Simon Horman <horms@kernel.org>, "Nikhil P. Rao" <nikhil.rao@amd.com>,
 Eric Dumazet <edumazet@kernel.org>
X-In-Reply-To: <20261130-ionic-get-fec-stats-v7-6-730c1672f561@amd.com>