* [PATCH net-next v6 0/3] net: phy: report ACx00 receive statistics
@ 2026-11-16 8:59 James Hilliard
2026-11-16 8:59 ` [PATCH net-next v6 1/3] docs: networking: correct the PHY statistics group name James Hilliard
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: James Hilliard @ 2026-11-16 8:59 UTC (permalink / raw)
To: Andrew Lunn, Heiner Kallweit, Russell King, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
Jonathan Corbet, Shuah Khan, Randy Dunlap
Cc: Oleksij Rempel, netdev, linux-kernel, linux-doc, James Hilliard
AC200 and AC300 count bytes in received frames including those with CRC
errors. Define the existing PHY rx_bytes statistic to include bytes in
frames with errors and use it to report this hardware total. The hardware
does not separately count damaged-frame lengths, so a successful-byte
count cannot be derived.
Report successful packets and CRC errors through the existing rx_packets
and rx_errors fields. Bracket the raw packet count with matching CRC
counts before subtracting; bytes and CRC errors can still advance when
sustained errors prevent a coherent packet sample.
Assisted-by: Codex:gpt-6-astra
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
---
Changes in v6:
- Define the existing rx_bytes field to include bytes in frames with
errors, and use it instead of adding rx_bytes_total.
- Collect Andrew's Reviewed-by for the PHY group-name correction.
- Rebase onto current net-next.
- Link to v5: https://patch.msgid.link/20261115-submit-acx00-phy-stats-v1-v5-0-ed81a7f54373@gmail.com
Changes in v5:
- Split the existing PHY statistics group-name documentation correction
into a separate patch, following Andrew's review.
- Narrow the generic statistics addition to the inclusive receive-byte
counter.
- Derive successful packets from a coherent packet/CRC pair and report
them through the existing rx_packets field.
- Keep collecting CRC errors and inclusive bytes when sustained errors
prevent a coherent pair, with separate baselines and sampling times.
- Skip invalid or unstable byte samples without discarding usable frame
samples, retaining the measured byte modulus and sampling-gap limit.
- Rebase onto current net-next.
- Link to v4: https://patch.msgid.link/20261113-submit-acx00-phy-stats-v1-v4-0-986b8a4a1871@gmail.com
Changes in v4:
- Invalidate the ACx00 baseline before accessing counters in soft_reset,
since phylib may already have reset the hardware before the callback.
- Start a new collection interval on resume and after gaps of at least
320 seconds, including system sleep, preserving collected totals without
interpreting unobserved traffic modulo the hardware counter width.
- Clarify that the byte modulus and frame-byte boundaries were measured
on both AC200 and AC300.
- Specify matching frame-byte boundaries for both PHY byte counters and
explain that phydev corrects the documented name of the existing group.
- Mark the DP83TG720 conversion as unsuitable for automatic stable
selection without the new receive-total API.
- Rebase onto current net-next.
- Link to v3: https://patch.msgid.link/20261109-submit-acx00-phy-stats-v1-v3-0-fbc6327c5be4@gmail.com
Changes in v3:
- Add generic PHY receive-total packet and byte counters in a preparatory
patch, retaining the existing successful-traffic counters and their IDs.
- Report ACx00 packet and byte totals through the new fields, leaving
successful-only counters unset.
- Convert DP83TG720's inclusive RX packet count to the new total field.
- Bound coherent-counter sampling to three attempts and skip unstable
snapshots without making phylib take the link down.
- Reject out-of-range byte samples before updating the hardware baseline
or accumulated totals, retaining MDIO and page-restoration errors.
- Rebase onto current net-next.
- Link to v2: https://patch.msgid.link/20261102-submit-acx00-phy-stats-v1-v2-1-3c8a664407c1@gmail.com
Changes in v2:
- Rebase onto current net-next and repost after the merge window.
- No functional changes.
- Link to v1: https://patch.msgid.link/20261025-submit-acx00-phy-stats-v1-v1-1-d3d461e46db0@gmail.com
To: Andrew Lunn <andrew@lunn.ch>
To: Heiner Kallweit <hkallweit1@gmail.com>
To: Russell King <linux@armlinux.org.uk>
To: "David S. Miller" <davem@davemloft.net>
To: Eric Dumazet <edumazet@kernel.org>
To: Jakub Kicinski <kuba@kernel.org>
To: Paolo Abeni <pabeni@redhat.com>
To: Simon Horman <horms@kernel.org>
To: Jonathan Corbet <corbet@lwn.net>
To: Shuah Khan <skhan@linuxfoundation.org>
To: Randy Dunlap <rdunlap@infradead.org>
Cc: netdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-doc@vger.kernel.org
---
James Hilliard (3):
docs: networking: correct the PHY statistics group name
ethtool: include errored frames in PHY receive byte counts
net: phy: acx00: report receive statistics
Documentation/networking/ethtool-netlink.rst | 2 +-
drivers/net/phy/xpowers/acx00.c | 223 ++++++++++++++++++++++++++-
include/linux/ethtool.h | 2 +-
3 files changed, 222 insertions(+), 5 deletions(-)
---
base-commit: 7ccc5e05043b1bb84326b19a2b05938d8f7a2ae6
base-tree: git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git main
change-id: 20261024-submit-acx00-phy-stats-v1-d838f77444e8
Best regards,
--
James Hilliard <james.hilliard1@gmail.com>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH net-next v6 1/3] docs: networking: correct the PHY statistics group name
2026-11-16 8:59 [PATCH net-next v6 0/3] net: phy: report ACx00 receive statistics James Hilliard
@ 2026-11-16 8:59 ` James Hilliard
2026-11-16 8:59 ` [PATCH net-next v6 2/3] ethtool: include errored frames in PHY receive byte counts James Hilliard
2026-11-16 8:59 ` [PATCH net-next v6 3/3] net: phy: acx00: report receive statistics James Hilliard
2 siblings, 0 replies; 9+ messages in thread
From: James Hilliard @ 2026-11-16 8:59 UTC (permalink / raw)
To: Andrew Lunn, Heiner Kallweit, Russell King, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
Jonathan Corbet, Shuah Khan, Randy Dunlap
Cc: Oleksij Rempel, netdev, linux-kernel, linux-doc, James Hilliard
The ETHTOOL_STATS_PHY group is exported as phydev by stats_std_names[],
but the ethtool netlink documentation lists it as phy. Use the exported
name so the documented group matches the statistics string set returned
to userspace.
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
---
Documentation/networking/ethtool-netlink.rst | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Documentation/networking/ethtool-netlink.rst b/Documentation/networking/ethtool-netlink.rst
index eba226c79ec3..8659761ebc69 100644
--- a/Documentation/networking/ethtool-netlink.rst
+++ b/Documentation/networking/ethtool-netlink.rst
@@ -1665,7 +1665,7 @@ the ``ETHTOOL_A_STATS_GROUPS`` bitset. Currently defined values are:
ETHTOOL_STATS_ETH_PHY eth-phy Basic IEEE 802.3 PHY statistics (30.3.2.1.*)
ETHTOOL_STATS_ETH_CTRL eth-ctrl Basic IEEE 802.3 MAC Ctrl statistics (30.3.3.*)
ETHTOOL_STATS_RMON rmon RMON (RFC 2819) statistics
- ETHTOOL_STATS_PHY phy Additional PHY statistics, not defined by IEEE
+ ETHTOOL_STATS_PHY phydev Additional PHY statistics, not defined by IEEE
====================== ======== ===============================================
Each group should have a corresponding ``ETHTOOL_A_STATS_GRP`` in the reply.
--
2.53.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH net-next v6 2/3] ethtool: include errored frames in PHY receive byte counts
2026-11-16 8:59 [PATCH net-next v6 0/3] net: phy: report ACx00 receive statistics James Hilliard
2026-11-16 8:59 ` [PATCH net-next v6 1/3] docs: networking: correct the PHY statistics group name James Hilliard
@ 2026-11-16 8:59 ` James Hilliard
2026-11-16 13:12 ` Oleksij Rempel
2026-11-19 12:00 ` netdev-bot+sashiko
2026-11-16 8:59 ` [PATCH net-next v6 3/3] net: phy: acx00: report receive statistics James Hilliard
2 siblings, 2 replies; 9+ messages in thread
From: James Hilliard @ 2026-11-16 8:59 UTC (permalink / raw)
To: Andrew Lunn, Heiner Kallweit, Russell King, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
Jonathan Corbet, Shuah Khan, Randy Dunlap
Cc: Oleksij Rempel, netdev, linux-kernel, linux-doc, James Hilliard
Some PHYs count bytes in all received frames, including frames with
errors. A successful-byte count cannot be derived by subtracting a frame
error count because the lengths of damaged frames are not available
separately.
No in-tree PHY driver currently reports rx_bytes. Define this existing
counter to include bytes in frames with errors so drivers can report
their hardware byte count through it. The counter describes reception at
the PHY, independently of MAC or host filtering.
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
---
include/linux/ethtool.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h
index c3a41fbd5426..9c3f079d9573 100644
--- a/include/linux/ethtool.h
+++ b/include/linux/ethtool.h
@@ -481,7 +481,7 @@ struct ethtool_eth_phy_stats {
/**
* struct ethtool_phy_stats - PHY-level statistics counters
* @rx_packets: Total successfully received frames
- * @rx_bytes: Total successfully received bytes
+ * @rx_bytes: Total received bytes
* @rx_errors: Total received frames with errors (e.g., CRC errors)
* @tx_packets: Total successfully transmitted frames
* @tx_bytes: Total successfully transmitted bytes
--
2.53.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH net-next v6 3/3] net: phy: acx00: report receive statistics
2026-11-16 8:59 [PATCH net-next v6 0/3] net: phy: report ACx00 receive statistics James Hilliard
2026-11-16 8:59 ` [PATCH net-next v6 1/3] docs: networking: correct the PHY statistics group name James Hilliard
2026-11-16 8:59 ` [PATCH net-next v6 2/3] ethtool: include errored frames in PHY receive byte counts James Hilliard
@ 2026-11-16 8:59 ` James Hilliard
2026-11-19 12:00 ` netdev-bot+sashiko
2 siblings, 1 reply; 9+ messages in thread
From: James Hilliard @ 2026-11-16 8:59 UTC (permalink / raw)
To: Andrew Lunn, Heiner Kallweit, Russell King, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
Jonathan Corbet, Shuah Khan, Randy Dunlap
Cc: Oleksij Rempel, netdev, linux-kernel, linux-doc, James Hilliard
AC200 and AC300 count received frames including those with CRC errors.
Subtract the CRC-error count to report successful frames through the
existing PHY rx_packets statistic, and report CRC errors through
rx_errors. Report the hardware byte total through rx_bytes, including
bytes in frames with CRC errors.
The free-running packet and CRC-error counters both wrap at 2^32.
Read each counter high/low/high to detect a carry, and bracket the packet
read with an unchanged CRC count before subtracting. Their difference
also wraps at 2^32. Accumulate its wrap-adjusted deltas in a 64-bit total.
Hardware measurements on AC200 and AC300 established a receive-byte
modulus of 4,000,000,000. The byte counts include Ethernet headers, padding
and FCS, but exclude preamble and SFD. Apply that modulus to byte deltas
and skip byte samples at or above it without changing their baseline.
Bound sampling retries to avoid retaining the PHY and MDIO locks
indefinitely. When CRC errors keep arriving, update rx_errors from the
latest stable error read without advancing the successful-frame baseline.
A later coherent pair accounts for the intervening successful frames.
Collect bytes independently of that pair. An unstable sample is not an
MDIO error: returning a synthetic error from update_stats would make
phylib take the link down. Real MDIO errors, including page-restoration
failures, still propagate.
Serialize sampling, reporting and power transitions with the package
mutex. Commit samples only after page restoration succeeds, and return
cached totals from get_phy_stats without further MDIO access.
Invalidate baselines before soft_reset or power-off, since phylib may
already have reset the counters. Take a best-effort snapshot before
suspend and start new intervals on resume, including when WoL retained
power while polling stopped. Keep a separate sampling time for each
counter and discard deltas after gaps of at least 320 seconds, including
system sleep and register-read time. At 100 Mb/s, that bounds the byte
counter and conservatively bounds the frame counters even at one frame
per received byte. Retain accumulated totals across these gaps and power
transitions, without inventing an unobservable number of counter cycles.
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
---
drivers/net/phy/xpowers/acx00.c | 223 +++++++++++++++++++++++++++++++++++++++-
1 file changed, 220 insertions(+), 3 deletions(-)
diff --git a/drivers/net/phy/xpowers/acx00.c b/drivers/net/phy/xpowers/acx00.c
index cee6c7ff0278..0015816fad07 100644
--- a/drivers/net/phy/xpowers/acx00.c
+++ b/drivers/net/phy/xpowers/acx00.c
@@ -8,12 +8,14 @@
#include <linux/bitfield.h>
#include <linux/device.h>
+#include <linux/ethtool.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/nvmem-consumer.h>
#include <linux/of.h>
#include <linux/phy.h>
#include <linux/slab.h>
+#include <linux/timekeeping.h>
#include "../phylib.h"
#include "acx00.h"
@@ -31,6 +33,7 @@
#define ACX00_PAGE_2 2
#define ACX00_PAGE_6 6
#define ACX00_PAGE_8 8
+#define ACX00_PAGE_9 9
#define ACX00_PAGE0_GLOBAL_CONFIG_REG 0x13
#define ACX00_PAGE0_XMII_RX_CLOCK_INVERT BIT(12)
@@ -76,6 +79,26 @@
(ACX00_PAGE8_AUTO_CAL_TX_LEVEL_ADJUST_BYPASS | \
ACX00_PAGE8_AUTO_CAL_LOW_CAL_OPAQUE_BITS)
+#define ACX00_PAGE9_RX_BYTES_HIGH_REG 0x19
+#define ACX00_PAGE9_RX_PACKETS_HIGH_REG 0x1b
+#define ACX00_PAGE9_RX_CRC_ERRORS_HIGH_REG 0x1d
+
+/*
+ * AC200 and AC300 hardware testing confirmed that the receive byte counter
+ * wraps at 4,000,000,000 rather than 2^32.
+ */
+#define ACX00_RX_BYTES_WRAP 4000000000ULL
+/* At 100 Mb/s, a full byte-counter cycle takes at least 320 seconds. */
+#define ACX00_STATS_MAX_INTERVAL_MS (ACX00_RX_BYTES_WRAP * 8 / (SPEED_100 * 1000))
+#define ACX00_COUNTER_READ_ATTEMPTS 3
+
+enum acx00_ephy_stat {
+ ACX00_STAT_RX_PACKETS,
+ ACX00_STAT_RX_CRC_ERRORS,
+ ACX00_STAT_RX_BYTES,
+ ACX00_NUM_STATS,
+};
+
/*
* Another integration of this exact-ID PHY documents its digital vendor
* register map, which also matches the observed ACx00 reset values. The ACx00
@@ -86,11 +109,16 @@
struct acx00_ephy_priv {
struct phy_device *phydev;
struct acx00_ephy_control *control;
- /* Serializes package state and multi-register power sequences. */
+ /* Serializes package state, power sequences and statistics. */
struct mutex state_lock;
bool is_ac300;
bool use_low_calibration_tuning;
bool xmii_rx_clock_inverted;
+ bool stats_active;
+ u8 stats_valid;
+ ktime_t stats_start[ACX00_NUM_STATS];
+ u32 stats_last[ACX00_NUM_STATS];
+ u64 stats[ACX00_NUM_STATS];
};
static int acx00_ephy_read_page(struct phy_device *phydev)
@@ -110,6 +138,169 @@ static int acx00_ephy_write_page(struct phy_device *phydev, int page)
FIELD_PREP(ACX00_PAGE_SELECT_MASK, page));
}
+/* Return 0 on success, 1 for an unstable sample, or a negative MDIO error. */
+static int acx00_ephy_read_counter(struct phy_device *phydev, u8 reg, u32 *count)
+{
+ int high, low, check;
+ int i;
+
+ /* The free-running counter can carry while its two halves are read. */
+ for (i = 0; i < ACX00_COUNTER_READ_ATTEMPTS; i++) {
+ high = __phy_read(phydev, reg);
+ if (high < 0)
+ return high;
+ low = __phy_read(phydev, reg + 1);
+ if (low < 0)
+ return low;
+ check = __phy_read(phydev, reg);
+ if (check < 0)
+ return check;
+ if (high != check)
+ continue;
+
+ *count = (u32)high << 16 | low;
+ return 0;
+ }
+
+ return 1;
+}
+
+/* Return a mask of usable counters, or a negative MDIO error. */
+static int acx00_ephy_read_counts(struct phy_device *phydev, u32 *counts)
+{
+ u32 packets, errors;
+ int ret;
+ int i;
+
+ ret = acx00_ephy_read_counter(phydev, ACX00_PAGE9_RX_CRC_ERRORS_HIGH_REG,
+ &counts[ACX00_STAT_RX_CRC_ERRORS]);
+ if (ret)
+ return ret < 0 ? ret : 0;
+
+ /* Bracket the packet counter with an unchanged CRC count. */
+ for (i = 0; i < ACX00_COUNTER_READ_ATTEMPTS; i++) {
+ ret = acx00_ephy_read_counter(phydev, ACX00_PAGE9_RX_PACKETS_HIGH_REG,
+ &packets);
+ if (ret < 0)
+ return ret;
+ if (ret)
+ break;
+ ret = acx00_ephy_read_counter(phydev, ACX00_PAGE9_RX_CRC_ERRORS_HIGH_REG,
+ &errors);
+ if (ret < 0)
+ return ret;
+ if (ret)
+ break;
+ if (errors == counts[ACX00_STAT_RX_CRC_ERRORS]) {
+ /* Both hardware counters and their difference wrap at 2^32. */
+ counts[ACX00_STAT_RX_PACKETS] = packets - errors;
+ return BIT(ACX00_STAT_RX_PACKETS) | BIT(ACX00_STAT_RX_CRC_ERRORS);
+ }
+ counts[ACX00_STAT_RX_CRC_ERRORS] = errors;
+ }
+
+ /* Keep reporting errors even when no coherent packet sample is possible. */
+ return BIT(ACX00_STAT_RX_CRC_ERRORS);
+}
+
+static int __acx00_ephy_update_stats(struct phy_device *phydev)
+{
+ struct acx00_ephy_priv *priv = phydev->priv;
+ u32 counts[ACX00_NUM_STATS];
+ ktime_t start;
+ int oldpage;
+ int valid;
+ int ret;
+ int i;
+
+ lockdep_assert_held(&priv->state_lock);
+
+ if (!priv->stats_active)
+ return 0;
+
+ start = ktime_get_boottime();
+ oldpage = phy_select_page(phydev, ACX00_PAGE_9);
+ if (oldpage < 0)
+ return phy_restore_page(phydev, oldpage, oldpage);
+
+ valid = acx00_ephy_read_counts(phydev, counts);
+ if (valid < 0) {
+ ret = valid;
+ goto out_restore_page;
+ }
+
+ ret = acx00_ephy_read_counter(phydev, ACX00_PAGE9_RX_BYTES_HIGH_REG,
+ &counts[ACX00_STAT_RX_BYTES]);
+ if (ret < 0)
+ goto out_restore_page;
+ if (!ret && counts[ACX00_STAT_RX_BYTES] < ACX00_RX_BYTES_WRAP)
+ valid |= BIT(ACX00_STAT_RX_BYTES);
+ ret = valid;
+
+out_restore_page:
+ ret = phy_restore_page(phydev, oldpage, ret);
+ if (ret < 0)
+ return ret;
+
+ for (i = 0; i < ACX00_NUM_STATS; i++) {
+ u64 count;
+
+ if (!(ret & BIT(i)))
+ continue;
+ count = counts[i];
+
+ /* Include sleep and read time; unseen cycles cannot be recovered. */
+ if ((priv->stats_valid & BIT(i)) &&
+ ktime_ms_delta(ktime_get_boottime(), priv->stats_start[i]) <
+ (s64)ACX00_STATS_MAX_INTERVAL_MS) {
+ if (count < priv->stats_last[i])
+ count += i == ACX00_STAT_RX_BYTES ?
+ ACX00_RX_BYTES_WRAP : BIT_ULL(32);
+ priv->stats[i] += count - priv->stats_last[i];
+ }
+ priv->stats_last[i] = counts[i];
+ priv->stats_start[i] = start;
+ priv->stats_valid |= BIT(i);
+ }
+
+ return 0;
+}
+
+static int acx00_ephy_update_stats(struct phy_device *phydev)
+{
+ struct acx00_ephy_priv *priv = phydev->priv;
+ int ret;
+
+ mutex_lock(&priv->state_lock);
+ ret = __acx00_ephy_update_stats(phydev);
+ mutex_unlock(&priv->state_lock);
+
+ return ret;
+}
+
+static void acx00_ephy_get_phy_stats(struct phy_device *phydev,
+ struct ethtool_eth_phy_stats *eth_stats,
+ struct ethtool_phy_stats *stats)
+{
+ struct acx00_ephy_priv *priv = phydev->priv;
+
+ mutex_lock(&priv->state_lock);
+ stats->rx_packets = priv->stats[ACX00_STAT_RX_PACKETS];
+ stats->rx_errors = priv->stats[ACX00_STAT_RX_CRC_ERRORS];
+ stats->rx_bytes = priv->stats[ACX00_STAT_RX_BYTES];
+ mutex_unlock(&priv->state_lock);
+}
+
+static void acx00_ephy_snapshot_stats(struct phy_device *phydev)
+{
+ int ret;
+
+ /* Statistics collection must not prevent reset or power management. */
+ ret = __acx00_ephy_update_stats(phydev);
+ if (ret)
+ phydev_dbg(phydev, "failed to snapshot statistics: %pe\n", ERR_PTR(ret));
+}
+
static int acx00_ephy_control_power_on(struct acx00_ephy_priv *priv)
{
lockdep_assert_held(&priv->state_lock);
@@ -122,6 +313,10 @@ static int acx00_ephy_control_power_off(struct acx00_ephy_priv *priv)
{
lockdep_assert_held(&priv->state_lock);
+ /* Even a failed power-off can have reset the hardware counter. */
+ priv->stats_active = false;
+ priv->stats_valid = 0;
+
return priv->control->power_off(priv->control);
}
@@ -350,6 +545,10 @@ static int acx00_ephy_soft_reset(struct phy_device *phydev)
mutex_lock(&priv->state_lock);
+ /* phylib may already have reset the counters before calling us. */
+ priv->stats_active = false;
+ priv->stats_valid = 0;
+
ret = acx00_ephy_set_interface(phydev);
if (ret)
goto out_power_off;
@@ -475,10 +674,21 @@ static int __acx00_ephy_config_init(struct phy_device *phydev)
/* Restore the standard EEE policy retained by phylib across resets. */
ret = genphy_c45_an_config_eee_aneg(phydev);
- if (ret <= 0)
+ if (ret < 0)
return ret;
+ if (ret > 0) {
+ ret = genphy_restart_aneg(phydev);
+ if (ret)
+ return ret;
+ }
+
+ if (!priv->stats_active) {
+ /* Establish a new baseline after reset, retaining the software total. */
+ priv->stats_active = true;
+ acx00_ephy_snapshot_stats(phydev);
+ }
- return genphy_restart_aneg(phydev);
+ return 0;
}
static int acx00_ephy_config_init(struct phy_device *phydev)
@@ -534,6 +744,9 @@ static int acx00_ephy_resume(struct phy_device *phydev)
int ret;
mutex_lock(&priv->state_lock);
+ /* WoL can keep the PHY counting while phylib polling is stopped. */
+ priv->stats_active = false;
+ priv->stats_valid = 0;
ret = __acx00_ephy_power_on_and_resume(phydev);
mutex_unlock(&priv->state_lock);
@@ -550,6 +763,8 @@ static int acx00_ephy_suspend(struct phy_device *phydev)
mutex_lock(&phydev->lock);
mutex_lock(&priv->state_lock);
+ acx00_ephy_snapshot_stats(phydev);
+
ret = genphy_suspend(phydev);
if (ret)
goto out_unlock;
@@ -616,6 +831,8 @@ static struct phy_driver acx00_ephy_driver[] = {
.soft_reset = acx00_ephy_soft_reset,
.config_init = acx00_ephy_config_init,
.disable_autonomous_eee = acx00_ephy_disable_autonomous_eee,
+ .get_phy_stats = acx00_ephy_get_phy_stats,
+ .update_stats = acx00_ephy_update_stats,
.suspend = acx00_ephy_suspend,
.resume = acx00_ephy_resume,
},
--
2.53.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH net-next v6 2/3] ethtool: include errored frames in PHY receive byte counts
2026-11-16 8:59 ` [PATCH net-next v6 2/3] ethtool: include errored frames in PHY receive byte counts James Hilliard
@ 2026-11-16 13:12 ` Oleksij Rempel
2026-11-16 13:23 ` Andrew Lunn
2026-11-17 2:35 ` James Hilliard
2026-11-19 12:00 ` netdev-bot+sashiko
1 sibling, 2 replies; 9+ messages in thread
From: Oleksij Rempel @ 2026-11-16 13:12 UTC (permalink / raw)
To: James Hilliard
Cc: Andrew Lunn, Heiner Kallweit, Russell King, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
Jonathan Corbet, Shuah Khan, Randy Dunlap, netdev, linux-kernel,
linux-doc
On Mon, Nov 16, 2026 at 01:59:58AM -0700, James Hilliard wrote:
> Some PHYs count bytes in all received frames, including frames with
> errors. A successful-byte count cannot be derived by subtracting a frame
> error count because the lengths of damaged frames are not available
> separately.
>
> No in-tree PHY driver currently reports rx_bytes. Define this existing
> counter to include bytes in frames with errors so drivers can report
> their hardware byte count through it.
I do not think we should change rx_bytes.
Comparing PHY and MAC counters, for example to find frames lost between
PHY and MAC, only works if both count the same kind of frames.
rx_packets counts good frames only ("Total successfully received
frames"), and so do the 802.3 MAC counters aFramesReceivedOK and
aOctetsReceivedOK (30.3.1.1.5, 30.3.1.1.14). With this patch, rx_bytes
would also count bad frames, so two counters in the same group describe
different frames. A PHY without a CRC checker cannot fill either of
them. A PHY that has one, like ACx00, should keep them consistent.
A separate counter for bad frames, as in v5, does not solve this either,
because "bad frame" is not one thing. 802.3 counts symbol errors at the
PHY (30.3.2.1.5) and FCS, alignment, length and frame-too-long errors at
the MAC (30.3.1.1.6, .7, .23 to .25). A symbol error points at this
link. A frame with a bad CRC can also come from the link partner.
rx_errors already means different things: mxl-gpy reports its RXERR
counter, qcom-phy-lib and dp83tg720 report CRC errors.
Strict definitions would need a counter for each combination, "include
everything" would make the counters useless for diagnosis, and moving a
counter between fields breaks existing users. Also, few people have the
hardware to confirm what a counter really counts.
I suggest metadata for the existing counters instead, similar to how
ETHTOOL_MSG_MSE_GET reports the scale of its values next to them. Old
user space can ignore it, new user space can use it, and it lists only
what is confirmed for a PHY. Andrew should agree to this direction
first.
For this series: keep rx_bytes as it is, report rx_packets and rx_errors
as you do, and keep the byte total driver-private for now.
@Andrew?
Oleksij
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH net-next v6 2/3] ethtool: include errored frames in PHY receive byte counts
2026-11-16 13:12 ` Oleksij Rempel
@ 2026-11-16 13:23 ` Andrew Lunn
2026-11-17 2:35 ` James Hilliard
1 sibling, 0 replies; 9+ messages in thread
From: Andrew Lunn @ 2026-11-16 13:23 UTC (permalink / raw)
To: Oleksij Rempel
Cc: James Hilliard, Heiner Kallweit, Russell King, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
Jonathan Corbet, Shuah Khan, Randy Dunlap, netdev, linux-kernel,
linux-doc
> For this series: keep rx_bytes as it is, report rx_packets and rx_errors
> as you do, and keep the byte total driver-private for now.
>
> @Andrew?
I replied to the previous thread, since discussion is still ongoing,
and so there should not of been a new version posted....
Andrew
---
pw-bot: cr
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH net-next v6 2/3] ethtool: include errored frames in PHY receive byte counts
2026-11-16 13:12 ` Oleksij Rempel
2026-11-16 13:23 ` Andrew Lunn
@ 2026-11-17 2:35 ` James Hilliard
1 sibling, 0 replies; 9+ messages in thread
From: James Hilliard @ 2026-11-17 2:35 UTC (permalink / raw)
To: Oleksij Rempel
Cc: Andrew Lunn, Heiner Kallweit, Russell King, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
Jonathan Corbet, Shuah Khan, Randy Dunlap, netdev, linux-kernel,
linux-doc
On Mon, Nov 16, 2026 at 6:12 AM Oleksij Rempel <o.rempel@pengutronix.de> wrote:
>
> On Mon, Nov 16, 2026 at 01:59:58AM -0700, James Hilliard wrote:
> > Some PHYs count bytes in all received frames, including frames with
> > errors. A successful-byte count cannot be derived by subtracting a frame
> > error count because the lengths of damaged frames are not available
> > separately.
> >
> > No in-tree PHY driver currently reports rx_bytes. Define this existing
> > counter to include bytes in frames with errors so drivers can report
> > their hardware byte count through it.
>
> I do not think we should change rx_bytes.
>
> Comparing PHY and MAC counters, for example to find frames lost between
> PHY and MAC, only works if both count the same kind of frames.
I did some additional tests to understand where the observed differences
come from. With MAC error and runt forwarding enabled, a bad-FCS
63-byte frame increments the PHY packet, byte and error counters, but
produces no MAC RX descriptor. At 64 bytes, it also produces a MAC
descriptor reporting a CRC error. These lengths include the FCS.
MAC-internal loopback reproduces exactly the same 63/64-byte boundary,
with PHY loopback disabled and all PHY counters unchanged. Good-FCS
frames pass at both sizes. This shows that the MAC alone can produce
the observed filtering; the earlier results do not establish a
CRC-dependent runt filter in the PHY.
It also explains how the PHY error counter can advance without a
corresponding MAC software error count: the MAC can discard the frame
before providing a descriptor. That difference alone does not indicate
a fault between the PHY and MAC.
> rx_packets counts good frames only ("Total successfully received
> frames"), and so do the 802.3 MAC counters aFramesReceivedOK and
> aOctetsReceivedOK (30.3.1.1.5, 30.3.1.1.14). With this patch, rx_bytes
> would also count bad frames, so two counters in the same group describe
> different frames. A PHY without a CRC checker cannot fill either of
> them. A PHY that has one, like ACx00, should keep them consistent.
The original implementation reported the inclusive hardware packet and
byte totals together. I changed rx_packets to subtract the error count
after review of the successful-frame definition. The hardware does not
provide a corresponding errored-byte count, which created this mismatch.
Subtracting the error count also does not necessarily produce the MAC's
successful-frame count. Valid-FCS runts and frames with an incorrect
802.3 length field were counted without PHY errors, even when the MAC
discarded them or reported a length error.
> A separate counter for bad frames, as in v5, does not solve this either,
> because "bad frame" is not one thing. 802.3 counts symbol errors at the
> PHY (30.3.2.1.5) and FCS, alignment, length and frame-too-long errors at
> the MAC (30.3.1.1.6, .7, .23 to .25). A symbol error points at this
> link. A frame with a bad CRC can also come from the link partner.
> rx_errors already means different things: mxl-gpy reports its RXERR
> counter, qcom-phy-lib and dp83tg720 report CRC errors.
The v5 addition was an inclusive byte total, rather than a separate
bad-frame counter. Its purpose was to expose the hardware byte count
without having to infer how many bytes belonged to errored frames.
The ACx00 tests confirm that deliberately transmitting bad FCS from the
link partner increments the PHY error counter. That does not imply a
physical-link fault. Tested valid-FCS runts and length-field mismatches
did not increment it, even when the MAC rejected those frames or
reported a length error.
I have not isolated symbol or non-octet alignment errors, so these
results do not establish that FCS errors are the only events counted.
The proposed metadata could express those distinctions without treating
every driver's rx_errors as the same error class.
> Strict definitions would need a counter for each combination, "include
> everything" would make the counters useless for diagnosis, and moving a
> counter between fields breaks existing users. Also, few people have the
> hardware to confirm what a counter really counts.
>
> I suggest metadata for the existing counters instead, similar to how
> ETHTOOL_MSG_MSE_GET reports the scale of its values next to them. Old
> user space can ignore it, new user space can use it, and it lists only
> what is confirmed for a PHY. Andrew should agree to this direction
> first.
The tests confirm that the PHY counts bad-FCS frames and their bytes,
including FCS, and increments its error counter for them. They do not
establish whether that error counter also includes symbol errors.
Should we return to reporting the inclusive packet and byte totals
together, with those confirmed semantics described through the proposed
metadata, rather than deriving a successful-packet count that still
does not match the MAC's acceptance criteria?
> For this series: keep rx_bytes as it is, report rx_packets and rx_errors
> as you do, and keep the byte total driver-private for now.
>
> @Andrew?
>
> Oleksij
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH net-next v6 2/3] ethtool: include errored frames in PHY receive byte counts
2026-11-16 8:59 ` [PATCH net-next v6 2/3] ethtool: include errored frames in PHY receive byte counts James Hilliard
2026-11-16 13:12 ` Oleksij Rempel
@ 2026-11-19 12:00 ` netdev-bot+sashiko
1 sibling, 0 replies; 9+ messages in thread
From: netdev-bot+sashiko @ 2026-11-19 12:00 UTC (permalink / raw)
To: james.hilliard1
Cc: andrew, hkallweit1, linux, davem, edumazet, kuba, pabeni, horms,
corbet, skhan, rdunlap, o.rempel, netdev, linux-kernel, linux-doc
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The commit message says the patch defines rx_bytes in two ways:
it includes bytes in frames with errors, and it counts reception at…
- [Low] After this patch, the counters in the ETHTOOL_STATS_PHY
("phydev") group no longer count the same set of frames, and nothing…
--
ethtool: include errored frames in PHY receive byte counts
This commit changes the kerneldoc for rx_bytes in struct ethtool_phy_stats
from "Total successfully received bytes" to "Total received bytes". The
commit message says the goal is to let PHY drivers report a hardware byte
count that includes frames with errors.
> diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h
> index c3a41fbd5426d..9c3f079d9573e 100644
> --- a/include/linux/ethtool.h
> +++ b/include/linux/ethtool.h
> @@ -481,7 +481,7 @@ struct ethtool_eth_phy_stats {
> /**
> * struct ethtool_phy_stats - PHY-level statistics counters
> * @rx_packets: Total successfully received frames
> - * @rx_bytes: Total successfully received bytes
> + * @rx_bytes: Total received bytes
[Severity: Low]
The commit message says:
Define this existing counter to include bytes in frames with errors so
drivers can report their hardware byte count through it. The counter
describes reception at the PHY, independently of MAC or host filtering.
Does the new kerneldoc line say either of these things? "Total received
bytes" does not say that errored frames are included. It also says nothing
about counting before MAC or host filtering.
Nothing else in the tree documents the new meaning either. The uAPI comment
covering ETHTOOL_A_STATS_PHY_RX_BYTES in include/uapi/linux/ethtool_netlink.h
only says:
/* Basic packet counters if PHY has separate counters from the MAC */
The group table in ethtool-netlink.rst only says "Additional PHY
statistics, not defined by IEEE".
Neither of these changes by the end of the series (after "net: phy: acx00:
report receive statistics"). The definition therefore exists only in this
commit message.
Could the line state it directly, for example "Total bytes in all frames
received by the PHY, including frames with errors"?
> * @rx_errors: Total received frames with errors (e.g., CRC errors)
> * @tx_packets: Total successfully transmitted frames
> * @tx_bytes: Total successfully transmitted bytes
[Severity: Low]
After this change, @rx_packets and @tx_bytes still say "successfully", but
@rx_bytes is meant to include errored frames. Should the doc say that the
two RX counters now cover different sets of frames?
stats_put_phydev_stats() in net/ethtool/stats.c sends them to userspace
together as the RxFrames/RxOctets pair:
if (stat_put(skb, ETHTOOL_A_STATS_PHY_RX_PKTS,
data->phydev_stats.rx_packets) ||
stat_put(skb, ETHTOOL_A_STATS_PHY_RX_BYTES,
data->phydev_stats.rx_bytes) ||
The first user is acx00_ephy_get_phy_stats(), added later in this series
by "net: phy: acx00: report receive statistics". It relies on this split.
It reports rx_packets without CRC-errored frames, and rx_bytes as the raw
hardware total that includes them:
stats->rx_packets = priv->stats[ACX00_STAT_RX_PACKETS];
stats->rx_errors = priv->stats[ACX00_STAT_RX_CRC_ERRORS];
stats->rx_bytes = priv->stats[ACX00_STAT_RX_BYTES];
Userspace that computes RxOctets / RxFrames (average frame size) would get
inflated numbers. So would userspace that compares the RX pair with the TX
pair. Nothing in the uAPI header, ethtool-netlink.rst or the kerneldoc
explains the difference.
The commit message explains why rx_bytes has to include errored frames. It
does not say why the difference between the two RX counters is left
undocumented.
Could the doc say something like "including frames with errors (unlike
@rx_packets)"? Alternatively, the pair could stay consistent, with a
separate attribute added for bytes in all frames.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261116-submit-acx00-phy-stats-v1-v6-0-8feef8e76cd5%40gmail.com
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH net-next v6 3/3] net: phy: acx00: report receive statistics
2026-11-16 8:59 ` [PATCH net-next v6 3/3] net: phy: acx00: report receive statistics James Hilliard
@ 2026-11-19 12:00 ` netdev-bot+sashiko
0 siblings, 0 replies; 9+ messages in thread
From: netdev-bot+sashiko @ 2026-11-19 12:00 UTC (permalink / raw)
To: james.hilliard1
Cc: andrew, hkallweit1, linux, davem, edumazet, kuba, pabeni, horms,
corbet, skhan, rdunlap, o.rempel, netdev, linux-kernel, linux-doc
Thank you for your contribution! Sashiko AI review found 4 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 3
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] Only the RX byte counter gets a plausibility check: samples >=
ACX00_RX_BYTES_WRAP are skipped without moving the baseline.
- [Low] In __acx00_ephy_config_init() (drivers/net/phy/xpowers/acx00.c),
the new statistics baseline snapshot goes through…
- [Low] In __acx00_ephy_update_stats(), stats_last[ACX00_STAT_RX_PACKETS]
and stats_start[ACX00_STAT_RX_PACKETS] only advance when…
- [Low] Counter baselines are only invalidated inside
acx00_ephy_soft_reset() (and power-off/resume), under priv->state_lock.
--
net: phy: acx00: report receive statistics
This commit adds receive statistics to the AC200/AC300 PHY driver. It
reports rx_packets, rx_errors and rx_bytes through get_phy_stats, using
counters that update_stats samples from vendor page 9 and adds into
64-bit totals with wrap handling. Baselines are invalidated across soft
reset, power-off and resume, and deltas are discarded after gaps of 320
seconds or more.
> diff --git a/drivers/net/phy/xpowers/acx00.c b/drivers/net/phy/xpowers/acx00.c
> index cee6c7ff0278e..0015816fad078 100644
> --- a/drivers/net/phy/xpowers/acx00.c
> +++ b/drivers/net/phy/xpowers/acx00.c
[ ... ]
> @@ -110,6 +138,169 @@ static int acx00_ephy_write_page(struct phy_device *phydev, int page)
[ ... ]
> +/* Return a mask of usable counters, or a negative MDIO error. */
> +static int acx00_ephy_read_counts(struct phy_device *phydev, u32 *counts)
> +{
[ ... ]
> + /* Bracket the packet counter with an unchanged CRC count. */
> + for (i = 0; i < ACX00_COUNTER_READ_ATTEMPTS; i++) {
> + ret = acx00_ephy_read_counter(phydev, ACX00_PAGE9_RX_PACKETS_HIGH_REG,
> + &packets);
> + if (ret < 0)
> + return ret;
> + if (ret)
> + break;
> + ret = acx00_ephy_read_counter(phydev, ACX00_PAGE9_RX_CRC_ERRORS_HIGH_REG,
> + &errors);
> + if (ret < 0)
> + return ret;
> + if (ret)
> + break;
> + if (errors == counts[ACX00_STAT_RX_CRC_ERRORS]) {
> + /* Both hardware counters and their difference wrap at 2^32. */
> + counts[ACX00_STAT_RX_PACKETS] = packets - errors;
> + return BIT(ACX00_STAT_RX_PACKETS) | BIT(ACX00_STAT_RX_CRC_ERRORS);
> + }
> + counts[ACX00_STAT_RX_CRC_ERRORS] = errors;
> + }
> +
> + /* Keep reporting errors even when no coherent packet sample is possible. */
> + return BIT(ACX00_STAT_RX_CRC_ERRORS);
[Severity: Low]
When the CRC count changes during all three bracket attempts, only the CRC
bit is returned. This leaves stats_last[ACX00_STAT_RX_PACKETS] and
stats_start[ACX00_STAT_RX_PACKETS] at their old values.
On a link with a sustained high CRC-error rate, this could happen on every
poll for 320 seconds or more:
_phy_state_machine()->phy_update_stats()->acx00_ephy_update_stats()
When a coherent pair finally arrives, __acx00_ephy_update_stats() checks
the interval against the stale timestamp:
if ((priv->stats_valid & BIT(i)) &&
ktime_ms_delta(ktime_get_boottime(), priv->stats_start[i]) <
(s64)ACX00_STATS_MAX_INTERVAL_MS) {
...
}
priv->stats_last[i] = counts[i];
priv->stats_start[i] = start;
The delta is dropped, but the baseline still moves forward. Wouldn't all
good frames received since the last coherent sample then be permanently
missing from rx_packets?
That seems to conflict with the commit message:
A later coherent pair accounts for the intervening successful frames.
The 320 second window comes from the 4e9 byte-counter modulus. At about
148,810 frames/s at 100 Mb/s, the 32-bit packets-minus-errors value would
take hours to wrap. Could the frame counters use a longer window?
> +}
[ ... ]
> + ret = acx00_ephy_read_counter(phydev, ACX00_PAGE9_RX_BYTES_HIGH_REG,
> + &counts[ACX00_STAT_RX_BYTES]);
> + if (ret < 0)
> + goto out_restore_page;
> + if (!ret && counts[ACX00_STAT_RX_BYTES] < ACX00_RX_BYTES_WRAP)
> + valid |= BIT(ACX00_STAT_RX_BYTES);
> + ret = valid;
> +
> +out_restore_page:
> + ret = phy_restore_page(phydev, oldpage, ret);
> + if (ret < 0)
> + return ret;
> +
> + for (i = 0; i < ACX00_NUM_STATS; i++) {
> + u64 count;
> +
> + if (!(ret & BIT(i)))
> + continue;
> + count = counts[i];
> +
> + /* Include sleep and read time; unseen cycles cannot be recovered. */
> + if ((priv->stats_valid & BIT(i)) &&
> + ktime_ms_delta(ktime_get_boottime(), priv->stats_start[i]) <
> + (s64)ACX00_STATS_MAX_INTERVAL_MS) {
> + if (count < priv->stats_last[i])
> + count += i == ACX00_STAT_RX_BYTES ?
> + ACX00_RX_BYTES_WRAP : BIT_ULL(32);
> + priv->stats[i] += count - priv->stats_last[i];
[Severity: Medium]
Can a single non-monotonic frame or CRC sample permanently add about 2^32
to rx_packets or rx_errors?
Only the byte counter has a plausibility check: samples at or above
ACX00_RX_BYTES_WRAP are skipped. For the CRC counter and the derived
packets-minus-errors value, any sample below stats_last[] counts as a
full 2^32 wrap, and the resulting delta has no upper bound.
An all-ones read is one way this can happen. Suppose the PHY stops
responding on an MDIO controller that returns 0xffff without an error.
acx00_ephy_read_counter() then sees high == check == 0xffff and returns
0xffffffff as a valid sample.
The CRC count reads 0xffffffff on both bracket reads, so packets - errors
is 0 and rx_packets gains 2^32 - N. The next good sample wraps again, and
both totals stay around 2^32 too high.
The other way is if the hardware updates the packet and CRC counters at
different times for the same bad frame. The bracket in
acx00_ephy_read_counts() could then see the frame in packets but not yet
in errors, or the reverse:
if (errors == counts[ACX00_STAT_RX_CRC_ERRORS]) {
/* Both hardware counters and their difference wrap at 2^32. */
counts[ACX00_STAT_RX_PACKETS] = packets - errors;
On the next sample, the -1 would become a jump of 2^32 - 1. Is it known
that the two counters update together?
The commit message bounds the rate at "one frame per received byte". Under
that bound, any real frame delta within the 320 second window is below
4e9. Could frame and CRC deltas in [4e9, 2^32) be rejected, the same way
out-of-range byte samples are?
> + }
> + priv->stats_last[i] = counts[i];
> + priv->stats_start[i] = start;
> + priv->stats_valid |= BIT(i);
> + }
[ ... ]
> @@ -350,6 +545,10 @@ static int acx00_ephy_soft_reset(struct phy_device *phydev)
>
> mutex_lock(&priv->state_lock);
>
> + /* phylib may already have reset the counters before calling us. */
> + priv->stats_active = false;
> + priv->stats_valid = 0;
> +
[Severity: Low]
Does this invalidation happen early enough when phy_mii_ioctl() triggers
the reset?
For SIOCSMIIREG on MII_BMCR with BMCR_RESET, drivers/net/phy/phy.c does:
phy_mii_ioctl()
mdiobus_write(phydev->mdio.bus, prtad, devad, val);
if (prtad == phydev->mdio.addr &&
devad == MII_BMCR &&
val & BMCR_RESET)
return phy_init_hw(phydev);
Neither call holds phydev->lock. _phy_state_machine() can therefore run
phy_update_stats()->acx00_ephy_update_stats() after the raw reset write
but before acx00_ephy_soft_reset() takes state_lock. stats_active and
stats_valid are still set at that point.
This comment assumes the reset clears the page 9 counters. If it does,
the new values are lower than stats_last[], and __acx00_ephy_update_stats()
treats them as a wrap:
if (count < priv->stats_last[i])
count += i == ACX00_STAT_RX_BYTES ?
ACX00_RX_BYTES_WRAP : BIT_ULL(32);
The totals are kept across resets. Would rx_packets, rx_errors and
rx_bytes then stay inflated by about 2^32 or 4e9?
The window is narrow and needs CAP_NET_ADMIN.
[ ... ]
> @@ -475,10 +674,21 @@ static int __acx00_ephy_config_init(struct phy_device *phydev)
[ ... ]
> + if (!priv->stats_active) {
> + /* Establish a new baseline after reset, retaining the software total. */
> + priv->stats_active = true;
> + acx00_ephy_snapshot_stats(phydev);
> + }
>
> - return genphy_restart_aneg(phydev);
> + return 0;
> }
[Severity: Low]
Should MDIO and page-restore errors from this snapshot be propagated?
acx00_ephy_snapshot_stats() drops every negative return from
__acx00_ephy_update_stats():
ret = __acx00_ephy_update_stats(phydev);
if (ret)
phydev_dbg(phydev, "failed to snapshot statistics: %pe\n", ERR_PTR(ret));
That includes a phy_restore_page() failure after
phy_select_page(phydev, ACX00_PAGE_9).
__acx00_ephy_config_init() then returns 0, so acx00_ephy_config_init()
skips its power-off path. phy_init_hw() and resume report success while
the page register may still be on page 9. Later phy_select_page() calls
would then save page 9 as oldpage and restore back to it.
Every other paged access in config_init propagates the phy_restore_page()
result. The commit message also says:
Real MDIO errors, including page-restoration failures, still propagate.
That holds for the .update_stats callback, but not for this snapshot.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261116-submit-acx00-phy-stats-v1-v6-0-8feef8e76cd5%40gmail.com
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2026-11-19 12:00 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-16 8:59 [PATCH net-next v6 0/3] net: phy: report ACx00 receive statistics James Hilliard
2026-11-16 8:59 ` [PATCH net-next v6 1/3] docs: networking: correct the PHY statistics group name James Hilliard
2026-11-16 8:59 ` [PATCH net-next v6 2/3] ethtool: include errored frames in PHY receive byte counts James Hilliard
2026-11-16 13:12 ` Oleksij Rempel
2026-11-16 13:23 ` Andrew Lunn
2026-11-17 2:35 ` James Hilliard
2026-11-19 12:00 ` netdev-bot+sashiko
2026-11-16 8:59 ` [PATCH net-next v6 3/3] net: phy: acx00: report receive statistics James Hilliard
2026-11-19 12:00 ` netdev-bot+sashiko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox