On Tue, Nov 17, 2026 at 1:25 AM Oleksij Rempel [off-list ref] wrote:
On Mon, Nov 16, 2026 at 02:20:50PM -0700, James Hilliard wrote:
quoted
On Mon, Nov 16, 2026 at 11:12 AM Oleksij Rempel [off-list ref] wrote:
quoted
On Mon, Nov 16, 2026 at 02:14:38PM +0100, Andrew Lunn wrote:
quoted
quoted
quoted
Think about it.
If you don't have a MAC, you don't have FCS.
There are existing mainline PHY drivers exposing this functionality.
The QCA807x/QCA808x drivers use qcom_phy_counter_config() to enable
CRC checking, and qcom_phy_get_stats() reports the RX CRC-error count
through ethtool_phy_stats.rx_errors [0]. The IP101G driver also exposes
a phy_crc_errors counter separately from phy_symbol_errors [1].
This demonstrates frame-aware diagnostic functionality within these
PHYs, rather than something every PHY necessarily implements.
The generic byte counter need not require that functionality. My
question was whether rx_bytes should count received bytes without
conditioning the count on FCS validity. ACx00 could then report its
hardware byte total through that field, including bytes from frames
which its separate CRC checker identifies as bad.
Read 802.3. What does an 802.3 defined PHY actually allow. That is
ideally what the kernel should support with these counters. Lowest
common denominator.
So i would say RX bytes does not differentiate between the frames the
MAC will later throw away because the FCS is wrong. I would say it is
also O.K. to include the preamble, and the FCS, any padding up to 64
byte frames, etc.
Since this counter is not actually defined by 802.3, i would also
allow some flexibility in its meaning. Different PHYs might have
slightly different meanings.
Look at it from the other direction. What is your use case? Does the
exact definition actually matter? Does it matter if a different
vendors PHY counts it differently? Does your use case require cross
device compatibility?
You have not actually said what your use case is. For new board
bringup, debugging broken networking, the exact definition generally
does not matter. The PHY RX counter is going up, the MAC is not,
something between the MAC and the PHY. Neither the MAC nor the PHY
counters are going up, something between the RJ45 and the PHY. The
absolute values don't matter, its that they change which matters. But
maybe your use case is different?
I agree that for bring-up the deltas are enough.
In the field the question is usually: is the board broken, or something
outside of it? The MAC counts FCS errors both when the line is noisy and
when the xMII corrupts frames. The PHY is the natural place to tell the
two apart, but only if we know whether its error counter checked the
FCS. Without that, the wrong part gets replaced.
For ACx00, rx_errors specifically reports Ethernet FCS failures, not
symbol errors. We verified that with PHY loopback and MAC FCS insertion
disabled: a software-generated valid FCS did not increment the PHY
CRC-error counter, while flipping an FCS bit did.
That establishes what this particular counter detects. It does not
distinguish corruption on the link from a peer transmitting an invalid
FCS, but comparing PHY and MAC observations could help locate where
the frame became invalid.
quoted
I have seen a board where MAC and PHY both provided the xMII clock.
Frames were lost only when the clocks drifted into a bad phase, so
production tests did not catch it. A PHY that checks the FCS would show
a clean PHY side, while the MAC counts FCS errors from time to time.
So the meaning has to be known, even if it differs between PHYs. I am
fine with that, as long as rx_packets and rx_bytes describe the same
frames and the driver says what they include, for example which errored
frames are counted and whether rx_errors counts CRC or symbol errors.
That is the metadata I suggested in the v6 thread. The ACx00 byte total
also counts frames with a bad CRC, while its rx_packets does not, so it
does not fit rx_bytes.
In the original v1/v2 implementation, rx_packets and rx_bytes both
reported the inclusive hardware totals, including CRC-bad frames [0].
They described the same traffic, with CRC errors reported separately.
The packet count was later changed to subtract CRC errors to match
the existing "Total successfully received frames" definition. That
introduced the mismatch: the hardware does not separately count bytes
in CRC-bad frames, so the equivalent subtraction is unavailable for
rx_bytes.
Should we revisit the original approach, with both rx_packets and
rx_bytes reporting inclusive totals and rx_errors reporting CRC
failures separately?
Before we decide that, I have one question about your test setup. In
your mail [0] you wrote that the MAC drops the 63-byte bad-FCS frames
without creating a descriptor, even with error and runt forwarding
enabled, and that MAC-internal loopback shows the same. Which MAC is
this, and does it count the frames it drops in hardware? If it does, I
would expect the numbers in the ethtool rmon group (etherStatsFragments
for bad-FCS runts, etherStatsUndersizePkts for valid-FCS runts, per RFC
2819) or in ethtool -S.
This is Allwinner H616 EMAC1, using dwmac-sun8i/stmmac, connected to an
AC200 PHY over RMII. The driver reports no MAC management counters.
The CRC and length-error statistics in ethtool -S are software counters
updated from RX descriptor status, not independent hardware counters.
I also checked the MAC register aperture before and after controlled
traffic, including CRC-error traffic, and sampled registers during
reception and descriptor starvation. I did not identify an additional
packet, byte or error counter. That does not rule out undocumented
counters, but we currently have no MAC counter that accounts for these
descriptor-less drops.
The answer tells us whether a PHY/MAC comparison can account for these
frames. As you noted, a difference between PHY and MAC counts alone does
not indicate a fault. But if the MAC does not count these drops, nothing
tells a user whether the difference is such a drop or real loss between
PHY and MAC. The same holds for your valid-FCS runts and length-error
frames. The PHY counts them without an error, and the MAC discards them
or reports a length error.
The exposed counters cannot make that distinction on this MAC. The
controlled tests identify the missing frames because their contents and
counts are known; a PHY/MAC counter difference in ordinary traffic does
not provide that information.
The tested length-field mismatches did produce descriptors and increment
rx_length_errors. The accounting gap is specifically for frames discarded
before an RX descriptor is returned, including those bad-FCS runts.
Could you hold off on v7 until we have this answer?
[0]
https://lore.kernel.org/r/CADvTj4qMgKrRZ_uq3K4t2+w_3eai4dwuCPod_vhEKEOsO85_Wg@mail.gmail.com/ (local)
Oleksij