Re: [PATCH net-next v6 2/3] ethtool: include errored frames in PHY receive byte counts

From: James Hilliard

Date: Mon Nov 16 2026 - 21:36:16 EST


On Mon, Nov 16, 2026 at 6:12 AM Oleksij Rempel <o.rempel@xxxxxxxxxxxxxx> 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