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>,
"Eric Dumazet" <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Jacob Keller <jacob.e.keller@intel.com>,
Eric Joyner <eric.joyner@amd.com>
Subject: [PATCH net-next v4 3/5] ionic: Report "rx_bits_phy" stat to ethtool
Date: Tue, 9 Jun 2026 23:18:28 -0700 [thread overview]
Message-ID: <20260610061830.51037-4-eric.joyner@amd.com> (raw)
In-Reply-To: <20260610061830.51037-1-eric.joyner@amd.com>
This stat contains the number of total bits that the PHY has received;
it's useful for BER calculations. Add it to the ethtool stats output.
However, since this is one of the new "extra port stats", it's reported
in a different manner than the existing port stats and only
conditionally added to the ethtool stats output list: both the
DEV_CAP_EXTRA_STATS capability must be supported by the firmware, and
the firmware must set the value of the statistic to something other than
IONIC_STAT_INVALID.
To help support this scheme, the extra port stats region is initialized to
0xff's/IONIC_STAT_INVALID by the driver, to ensure the statistics that
the driver knows about but the firmware does not are still invalid
to the driver.
Signed-off-by: Eric Joyner <eric.joyner@amd.com>
---
.../net/ethernet/pensando/ionic/ionic_dev.h | 1 +
.../net/ethernet/pensando/ionic/ionic_main.c | 6 ++
.../net/ethernet/pensando/ionic/ionic_stats.c | 58 ++++++++++++++++++-
3 files changed, 64 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/pensando/ionic/ionic_dev.h b/drivers/net/ethernet/pensando/ionic/ionic_dev.h
index 35566f97eaea..5f677bcbaf02 100644
--- a/drivers/net/ethernet/pensando/ionic/ionic_dev.h
+++ b/drivers/net/ethernet/pensando/ionic/ionic_dev.h
@@ -184,6 +184,7 @@ struct ionic_dev {
u32 port_info_sz;
struct ionic_port_info *port_info;
dma_addr_t port_info_pa;
+ struct ionic_port_extra_stats port_extra_stats_cache;
struct ionic_devinfo dev_info;
};
diff --git a/drivers/net/ethernet/pensando/ionic/ionic_main.c b/drivers/net/ethernet/pensando/ionic/ionic_main.c
index 3c5200e2fdb7..306d9d160e17 100644
--- a/drivers/net/ethernet/pensando/ionic/ionic_main.c
+++ b/drivers/net/ethernet/pensando/ionic/ionic_main.c
@@ -731,6 +731,12 @@ int ionic_port_init(struct ionic *ionic)
return -ENOMEM;
}
+ /* 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));
+
sz = min(sizeof(ident->port.config), sizeof(idev->dev_cmd_regs->data));
mutex_lock(&ionic->dev_cmd_lock);
diff --git a/drivers/net/ethernet/pensando/ionic/ionic_stats.c b/drivers/net/ethernet/pensando/ionic/ionic_stats.c
index 0107599a9dd4..e81190cc9d2f 100644
--- a/drivers/net/ethernet/pensando/ionic/ionic_stats.c
+++ b/drivers/net/ethernet/pensando/ionic/ionic_stats.c
@@ -167,6 +167,7 @@ static const struct ionic_stat_desc ionic_rx_stats_desc[] = {
#define IONIC_NUM_PORT_STATS ARRAY_SIZE(ionic_port_stats_desc)
#define IONIC_NUM_TX_STATS ARRAY_SIZE(ionic_tx_stats_desc)
#define IONIC_NUM_RX_STATS ARRAY_SIZE(ionic_rx_stats_desc)
+#define IONIC_NUM_EXTRA_PORT_STATS 1
#define MAX_Q(lif) ((lif)->netdev->real_num_tx_queues)
@@ -232,6 +233,26 @@ static void ionic_get_lif_stats(struct ionic_lif *lif,
stats->hw_tx_aborted_errors = ns.tx_aborted_errors;
}
+static u32 ionic_extra_port_stats_get_count(struct ionic_lif *lif)
+{
+ struct ionic_dev *idev = &lif->ionic->idev;
+ struct ionic_port_extra_stats *pes_cache;
+ u32 count = 0;
+
+ if (!(lif->ionic->ident.dev.capabilities &
+ cpu_to_le64(IONIC_DEV_CAP_EXTRA_STATS)))
+ return count;
+
+ /* Cache copy for subsequent ethtool calls */
+ pes_cache = &idev->port_extra_stats_cache;
+ *pes_cache = idev->port_info->extra_stats;
+
+ if (pes_cache->rx_bits_phy != IONIC_STAT_INVALID)
+ count++;
+
+ return count;
+}
+
static u64 ionic_sw_stats_get_count(struct ionic_lif *lif)
{
u64 total = 0, tx_queues = MAX_Q(lif), rx_queues = MAX_Q(lif);
@@ -243,7 +264,7 @@ static u64 ionic_sw_stats_get_count(struct ionic_lif *lif)
rx_queues += 1;
total += IONIC_NUM_LIF_STATS;
- total += IONIC_NUM_PORT_STATS;
+ total += IONIC_NUM_PORT_STATS + ionic_extra_port_stats_get_count(lif);
total += tx_queues * IONIC_NUM_TX_STATS;
total += rx_queues * IONIC_NUM_RX_STATS;
@@ -271,6 +292,20 @@ static void ionic_sw_stats_get_rx_strings(struct ionic_lif *lif, u8 **buf,
ionic_rx_stats_desc[i].name);
}
+static void ionic_extra_port_stats_get_strings(struct ionic_lif *lif, u8 **buf)
+{
+ struct ionic_port_extra_stats *pes_cache;
+
+ if (!(lif->ionic->ident.dev.capabilities &
+ cpu_to_le64(IONIC_DEV_CAP_EXTRA_STATS)))
+ return;
+
+ pes_cache = &lif->ionic->idev.port_extra_stats_cache;
+
+ if (pes_cache->rx_bits_phy != IONIC_STAT_INVALID)
+ ethtool_puts(buf, "rx_bits_phy");
+}
+
static void ionic_sw_stats_get_strings(struct ionic_lif *lif, u8 **buf)
{
int i, q_num;
@@ -280,6 +315,7 @@ static void ionic_sw_stats_get_strings(struct ionic_lif *lif, u8 **buf)
for (i = 0; i < IONIC_NUM_PORT_STATS; i++)
ethtool_puts(buf, ionic_port_stats_desc[i].name);
+ ionic_extra_port_stats_get_strings(lif, buf);
for (q_num = 0; q_num < MAX_Q(lif); q_num++)
ionic_sw_stats_get_tx_strings(lif, buf, q_num);
@@ -322,6 +358,25 @@ static void ionic_sw_stats_get_rxq_values(struct ionic_lif *lif, u64 **buf,
}
}
+static void ionic_extra_port_stats_get_values(struct ionic_lif *lif, u64 **buf)
+{
+ struct ionic_port_extra_stats *pes_cache;
+
+ if (!(lif->ionic->ident.dev.capabilities &
+ cpu_to_le64(IONIC_DEV_CAP_EXTRA_STATS)))
+ return;
+
+ /* The number of statistics added to @buf here must equal
+ * ionic_extra_port_stats_get_count().
+ */
+ pes_cache = &lif->ionic->idev.port_extra_stats_cache;
+
+ if (pes_cache->rx_bits_phy != IONIC_STAT_INVALID) {
+ **buf = le64_to_cpu(pes_cache->rx_bits_phy);
+ (*buf)++;
+ }
+}
+
static void ionic_sw_stats_get_values(struct ionic_lif *lif, u64 **buf)
{
struct ionic_port_stats *port_stats;
@@ -341,6 +396,7 @@ static void ionic_sw_stats_get_values(struct ionic_lif *lif, u64 **buf)
&ionic_port_stats_desc[i]);
(*buf)++;
}
+ ionic_extra_port_stats_get_values(lif, buf);
for (q_num = 0; q_num < MAX_Q(lif); q_num++)
ionic_sw_stats_get_txq_values(lif, buf, q_num);
--
2.17.1
next prev parent reply other threads:[~2026-06-10 6:19 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-10 6:18 [PATCH net-next v4 0/5] ionic: Expose more port stats to ethtool Eric Joyner
2026-06-10 6:18 ` [PATCH net-next v4 1/5] ionic: Fix check in ionic_get_link_ext_stats Eric Joyner
2026-06-10 6:18 ` [PATCH net-next v4 2/5] ionic: Update ionic_if.h with new extra port stats Eric Joyner
2026-06-10 6:18 ` Eric Joyner [this message]
2026-06-10 6:18 ` [PATCH net-next v4 4/5] ionic: Report "link_down_events_phy" in ethtool statistics Eric Joyner
2026-06-10 6:18 ` [PATCH net-next v4 5/5] ionic: Add .get_fec_stats ethtool 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=20260610061830.51037-4-eric.joyner@amd.com \
--to=eric.joyner@amd.com \
--cc=andrew+netdev@lunn.ch \
--cc=brett.creeley@amd.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=jacob.e.keller@intel.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.