Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Suraj Gupta" <suraj.gupta2@amd.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH net-next v5 6/6] net: xilinx: axienet: Add statistics support for XXV ethernet
Date: Sun, 15 Nov 2026 18:31:37 +0000	[thread overview]
Message-ID: <sashiko-outbox-215725@kernel.org> (raw)
In-Reply-To: <20261114182947.2908628-7-suraj.gupta2@amd.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] net: xilinx: axienet: wrong RX bad-FCS offset in
  axienet_xxv_get_stats64()
--

commit 460172ab6de68521ff2c9e9d0c5b3adf14de408f
Author: Suraj Gupta <suraj.gupta2@amd.com>

net: xilinx: axienet: Add statistics support for XXV ethernet

This commit adds hardware statistics collection and reporting for the
Xilinx 10G/25G (XXV) Ethernet MAC via ndo_get_stats64() and ethtool
statistics callbacks, gated on the "xlnx,has-statistics-counters"
devicetree property.

> diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c b/drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c
> index 3c204dbbf6aec..83782bfbce4ce 100644
> --- a/drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c
> +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c
[ ... ]
> @@ -335,6 +411,204 @@ static int axienet_10g25g_clk_init(struct axienet_local *lp)
>  	return 0;
>  }
[ ... ]
> +static void axienet_xxv_get_stats64(struct axienet_local *lp,
> +				    struct rtnl_link_stats64 *stats)
> +{
> +	unsigned int start;
> +	u64 tx_hw_errors;
> +
> +	do {
> +		start = read_seqcount_begin(&lp->hw_stats_seqcount);
> +		stats->rx_crc_errors =
> +			lp->xxv_stat_base[XXV_STAT_RX_PACKET_BAD_FCS];
> +		/* Both in-range length errors and frame-too-long (oversize)
> +		 * frames are IEEE 802.3 length errors, so fold them together
> +		 * into rx_length_errors; rx_over_errors is reserved for receiver
> +		 * FIFO/ring overflow, which the XXV MAC does not expose.
> +		 */
> +		stats->rx_length_errors =
> +			lp->xxv_stat_base[XXV_STAT_RX_INRANGEERR] +
> +			lp->xxv_stat_base[XXV_STAT_RX_OVERSIZE];
> +		stats->rx_errors = lp->xxv_stat_base[XXV_STAT_RX_UNDERSIZE] +
> +				   lp->xxv_stat_base[XXV_STAT_RX_FRAGMENT] +
> +				   lp->xxv_stat_base[XXV_STAT_RX_JABBER] +
> +				   stats->rx_crc_errors +
> +				   stats->rx_length_errors;

[ ... ]

> +static void axienet_xxv_get_eth_mac_stats(struct axienet_local *lp,
> +					  struct ethtool_eth_mac_stats *mac_stats)
> +{
> +	unsigned int start;
> +
> +	do {
> +		start = read_seqcount_begin(&lp->hw_stats_seqcount);
> +		mac_stats->FramesTransmittedOK =
> +			lp->xxv_stat_base[XXV_STAT_TX_TOTAL_GOOD_PACKETS];
> +		mac_stats->FramesReceivedOK =
> +			lp->xxv_stat_base[XXV_STAT_RX_TOTAL_GOOD_PACKETS];
> +		mac_stats->OctetsTransmittedOK =
> +			lp->xxv_stat_base[XXV_STAT_TX_TOTAL_GOOD_BYTES];
> +		mac_stats->OctetsReceivedOK =
> +			lp->xxv_stat_base[XXV_STAT_RX_TOTAL_GOOD_BYTES];
> +		mac_stats->FrameCheckSequenceErrors =
> +			lp->xxv_stat_base[XXV_STAT_RX_PACKET_BAD_FCS];

[ ... ]

> diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_xxv.h b/drivers/net/ethernet/xilinx/xilinx_axienet_xxv.h
> index 6530344e40c7f..83682d1524ede 100644
> --- a/drivers/net/ethernet/xilinx/xilinx_axienet_xxv.h
> +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_xxv.h
> @@ -66,6 +66,36 @@ struct axienet_config;
[ ... ]
> +#define XXV_STAT_RX_UNDERSIZE_OFFSET		0x00000898
> +#define XXV_STAT_RX_FRAGMENT_OFFSET		0x000008A0
> +#define XXV_STAT_RX_OVERSIZE_OFFSET		0x000008A8
> +#define XXV_STAT_RX_JABBER_OFFSET		0x000008B8
> +#define XXV_STAT_RX_PACKET_BAD_FCS_OFFSET	0x000008C8

[Severity: Medium]
Should this read STAT_RX_BAD_FCS at offset 0x08C0 instead of
STAT_RX_PACKET_BAD_FCS at 0x08C8?

Per PG210, STAT_RX_PACKET_BAD_FCS (0x08C8) counts all received packets with
bad FCS regardless of length, which includes frames shorter than 64 bytes
with bad FCS (STAT_RX_FRAGMENT at 0x08A0) and frames longer than the configured
maximum length with bad FCS (STAT_RX_JABBER at 0x08B8).  Using 0x08C8
causes axienet_xxv_get_stats64() to double-count received fragments and
jabbers in stats->rx_errors, and includes undersize and oversize bad-FCS
frames in stats->rx_crc_errors and mac_stats->FrameCheckSequenceErrors,
whereas STAT_RX_BAD_FCS (0x08C0) counts only valid-length frames with bad
FCS.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261114182947.2908628-1-suraj.gupta2@amd.com?part=6

      reply	other threads:[~2026-11-15 18:31 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-14 18:29 [PATCH net-next v5 0/6] net: xilinx: axienet: Add 10G/25G (XXV) ethernet support Suraj Gupta
2026-11-14 18:29 ` [PATCH net-next v5 1/6] net: xilinx: axienet: Introduce axienet_config for MAC-specific ops Suraj Gupta
2026-11-15 18:31   ` sashiko-bot
2026-11-14 18:29 ` [PATCH net-next v5 2/6] dt-bindings: net: xlnx,xxv-ethernet: Add Xilinx XXV 10G/25G Ethernet Suraj Gupta
2026-11-14 18:29 ` [PATCH net-next v5 3/6] net: xilinx: axienet: Propagate device reset failure from ndo_open Suraj Gupta
2026-11-15 18:31   ` sashiko-bot
2026-11-14 18:29 ` [PATCH net-next v5 4/6] net: xilinx: axienet: Add 10G/25G (XXV) ethernet support Suraj Gupta
2026-11-15 18:31   ` sashiko-bot
2026-11-14 18:29 ` [PATCH net-next v5 5/6] net: xilinx: axienet: Dispatch statistics through axienet_config ops Suraj Gupta
2026-11-14 18:29 ` [PATCH net-next v5 6/6] net: xilinx: axienet: Add statistics support for XXV ethernet Suraj Gupta
2026-11-15 18:31   ` sashiko-bot [this message]

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=sashiko-outbox-215725@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=suraj.gupta2@amd.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox