From: Sean Anderson <sean.anderson@linux.dev>
To: Jakub Kicinski <kuba@kernel.org>
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: Tue, 20 Aug 2024 10:23:35 -0400 [thread overview]
Message-ID: <fcafcd35-3b31-4628-9035-cb7a90002436@linux.dev> (raw)
In-Reply-To: <20240816194203.05753edf@kernel.org>
On 8/16/24 22:42, Jakub Kicinski wrote:
> 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.
Yes, good catch. I think I changed the type while refactoring and forgot about it.
I think I'll expose the byte counters for the next revision to make it
easier to test rollover. I tried testing the packet counters overnight,
but I'm using a trial license for these devices at the moment and it
expired before the counters rolled over.
--Sean
>> +}
>> +
>> +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);
prev parent reply other threads:[~2024-08-20 14:24 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
2024-08-20 14:23 ` Sean Anderson [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=fcafcd35-3b31-4628-9035-cb7a90002436@linux.dev \
--to=sean.anderson@linux.dev \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@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 \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.