From: Jakub Kicinski <kuba@kernel.org>
To: Sean Anderson <sean.anderson@linux.dev>
Cc: Andrew Lunn <andrew@lunn.ch>,
Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>,
netdev@vger.kernel.org, Simon Horman <horms@kernel.org>,
Michal Simek <michal.simek@amd.com>,
linux-kernel@vger.kernel.org,
"David S . Miller" <davem@davemloft.net>,
Russell King <linux@armlinux.org.uk>,
linux-arm-kernel@lists.infradead.org,
Eric Dumazet <edumazet@google.com>,
Paolo Abeni <pabeni@redhat.com>
Subject: Re: [PATCH net-next v3 2/2] net: xilinx: axienet: Add statistics support
Date: Fri, 16 Aug 2024 19:42:03 -0700 [thread overview]
Message-ID: <20240816194203.05753edf@kernel.org> (raw)
In-Reply-To: <20240815144031.4079048-3-sean.anderson@linux.dev>
On Thu, 15 Aug 2024 10:40:31 -0400 Sean Anderson wrote:
> + u64 hw_stat_base[STAT_COUNT];
> + u64 hw_last_counter[STAT_COUNT];
I think hw_last_counter has to be u32..
> + seqcount_mutex_t hw_stats_seqcount;
> + struct mutex stats_lock;
> + struct delayed_work stats_work;
> + bool reset_in_progress;
> +
> struct work_struct dma_err_task;
>
> int tx_irq;
> diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
> index b2d7c396e2e3..9353a4f0ab1b 100644
> --- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
> +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
> @@ -519,11 +519,55 @@ static void axienet_setoptions(struct net_device *ndev, u32 options)
> lp->options |= options;
> }
>
> +static u64 axienet_stat(struct axienet_local *lp, enum temac_stat stat)
> +{
> + u32 counter;
> +
> + if (lp->reset_in_progress)
> + return lp->hw_stat_base[stat];
> +
> + counter = axienet_ior(lp, XAE_STATS_OFFSET + stat * 8);
> + return lp->hw_stat_base[stat] + (counter - lp->hw_last_counter[stat]);
.. or you need to cast the (counter - lp->...) result to u32.
Otherwise counter's type is getting bumped to 64 and you're just doing
64b math here.
> +}
> +
> +static void axienet_stats_update(struct axienet_local *lp, bool reset)
> +{
> + enum temac_stat stat;
> +
> + write_seqcount_begin(&lp->hw_stats_seqcount);
> + lp->reset_in_progress = reset;
> + for (stat = 0; stat < STAT_COUNT; stat++) {
> + u32 counter = axienet_ior(lp, XAE_STATS_OFFSET + stat * 8);
> +
> + lp->hw_stat_base[stat] += counter - lp->hw_last_counter[stat];
> + lp->hw_last_counter[stat] = counter;
> + }
> + write_seqcount_end(&lp->hw_stats_seqcount);
next prev parent reply other threads:[~2024-08-17 2:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-15 14:40 [PATCH net-next v3 0/2] net: xilinx: axienet: Add statistics support Sean Anderson
2024-08-15 14:40 ` [PATCH net-next v3 1/2] net: xilinx: axienet: Report RxRject as rx_dropped Sean Anderson
2024-08-15 14:40 ` [PATCH net-next v3 2/2] net: xilinx: axienet: Add statistics support Sean Anderson
2024-08-17 2:42 ` Jakub Kicinski [this message]
2024-08-20 14:23 ` Sean Anderson
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=20240816194203.05753edf@kernel.org \
--to=kuba@kernel.org \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=michal.simek@amd.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=radhey.shyam.pandey@amd.com \
--cc=sean.anderson@linux.dev \
/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;
as well as URLs for NNTP newsgroup(s).