From: Eric Joyner <eric.joyner@amd.com>
To: <netdev@vger.kernel.org>
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>,
Vadim Fedorenko <vadim.fedorenko@linux.dev>,
"Nikhil P. Rao" <nikhil.rao@amd.com>,
Eric Joyner <eric.joyner@amd.com>,
Eric Dumazet <edumazet@kernel.org>
Subject: [PATCH net-next v3 1/5] ionic: write the extra_stats invalid markers one counter at a time
Date: Wed, 4 Nov 2026 13:19:42 -0800 [thread overview]
Message-ID: <20261104-ionic-get-fec-stats-v3-1-b261fd53d0a7@amd.com> (raw)
In-Reply-To: <20261104-ionic-get-fec-stats-v3-0-b261fd53d0a7@amd.com>
From: "Nikhil P. Rao" <nikhil.rao@amd.com>
ionic_port_init() marks every counter in the device-written extra_stats
block invalid before asking firmware to refresh it, so that a statistic
this driver knows about but the firmware does not is reported as absent
rather than as zero. It does that with a memset() of the whole block.
The .get_fec_stats handler added later in this series reads those
counters one at a time and tests each against IONIC_STAT_INVALID to
decide whether to report it. memset() gives no guarantee about the
width of its stores, so such a reader can observe a counter that is
neither its old value nor the marker.
The block is entirely __le64, each member naturally aligned, so walk it
as an array and write the markers one counter at a time instead. A
counter read on its own is then either a complete value or the marker.
Signed-off-by: Nikhil P. Rao <nikhil.rao@amd.com>
Signed-off-by: Eric Joyner <eric.joyner@amd.com>
---
drivers/net/ethernet/pensando/ionic/ionic_main.c | 8 ++++++--
drivers/net/ethernet/pensando/ionic/ionic_stats.h | 2 ++
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/pensando/ionic/ionic_main.c b/drivers/net/ethernet/pensando/ionic/ionic_main.c
index 38b47b959a11..8197df5532f5 100644
--- a/drivers/net/ethernet/pensando/ionic/ionic_main.c
+++ b/drivers/net/ethernet/pensando/ionic/ionic_main.c
@@ -12,6 +12,7 @@
#include "ionic.h"
#include "ionic_bus.h"
#include "ionic_lif.h"
+#include "ionic_stats.h"
#include "ionic_debugfs.h"
MODULE_DESCRIPTION(IONIC_DRV_DESCRIPTION);
@@ -723,7 +724,9 @@ int ionic_port_init(struct ionic *ionic)
struct ionic_identity *ident = &ionic->ident;
struct ionic_dev *idev = &ionic->idev;
bool allocated = false;
+ __le64 *stat;
size_t sz;
+ size_t i;
int err;
if (!idev->port_info) {
@@ -741,8 +744,9 @@ int ionic_port_init(struct ionic *ionic)
/* If the driver knows about more "extra stats" than the firmware,
* make sure these stats are marked as invalid.
*/
- memset(&idev->port_info->extra_stats, 0xff,
- sizeof(idev->port_info->extra_stats));
+ stat = (__le64 *)&idev->port_info->extra_stats;
+ for (i = 0; i < sizeof(idev->port_info->extra_stats) / sizeof(*stat); i++)
+ WRITE_ONCE(stat[i], IONIC_STAT_INVALID);
WRITE_ONCE(idev->link_down_count_init, false);
diff --git a/drivers/net/ethernet/pensando/ionic/ionic_stats.h b/drivers/net/ethernet/pensando/ionic/ionic_stats.h
index 7ed935868e84..8a0edcc86fb8 100644
--- a/drivers/net/ethernet/pensando/ionic/ionic_stats.h
+++ b/drivers/net/ethernet/pensando/ionic/ionic_stats.h
@@ -4,6 +4,8 @@
#ifndef _IONIC_STATS_H_
#define _IONIC_STATS_H_
+#include <linux/ethtool.h>
+
#define IONIC_STAT_INVALID (cpu_to_le64(~0ULL))
#define IONIC_STAT_TO_OFFSET(type, stat_name) (offsetof(type, stat_name))
--
2.53.0
next prev parent reply other threads:[~2026-11-04 21:20 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-04 21:19 [PATCH net-next v3 0/5] ionic: FEC reporting fixes and .get_fec_stats handler Eric Joyner
2026-11-04 21:19 ` Eric Joyner [this message]
2026-11-04 21:19 ` [PATCH net-next v3 2/5] ionic: report the configured FEC mode in ethtool_fecparam.fec Eric Joyner
2026-11-10 21:26 ` Jakub Kicinski
2026-11-04 21:19 ` [PATCH net-next v3 3/5] ionic: map the FEC type through a helper in ionic_get_fecparam() Eric Joyner
2026-11-04 21:19 ` [PATCH net-next v3 4/5] ionic: report the operational FEC mode from ethtool --show-fec Eric Joyner
2026-11-10 21:26 ` Jakub Kicinski
2026-11-04 21:19 ` [PATCH net-next v3 5/5] ionic: Add .get_fec_stats ethtool handler Eric Joyner
2026-11-09 19:35 ` [PATCH net-next v3 0/5] ionic: FEC reporting fixes and .get_fec_stats handler Eric Joyner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261104-ionic-get-fec-stats-v3-1-b261fd53d0a7@amd.com \
--to=eric.joyner@amd.com \
--cc=andrew+netdev@lunn.ch \
--cc=brett.creeley@amd.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nikhil.rao@amd.com \
--cc=pabeni@redhat.com \
--cc=vadim.fedorenko@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox