[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250402102015.GL214849@horms.kernel.org>
Date: Wed, 2 Apr 2025 11:20:15 +0100
From: Simon Horman <horms@...nel.org>
To: Michal Swiatkowski <michal.swiatkowski@...ux.intel.com>
Cc: Harshitha Ramamurthy <hramamurthy@...gle.com>, netdev@...r.kernel.org,
jeroendb@...gle.com, andrew+netdev@...n.ch, davem@...emloft.net,
edumazet@...gle.com, kuba@...nel.org, pabeni@...hat.com,
pkaligineedi@...gle.com, willemb@...gle.com, joshwash@...gle.com,
shailend@...gle.com, jrkim@...gle.com, linux-kernel@...r.kernel.org,
stable@...r.kernel.org
Subject: Re: [PATCH net] gve: handle overflow when reporting TX consumed
descriptors
On Wed, Apr 02, 2025 at 07:10:18AM +0200, Michal Swiatkowski wrote:
> On Wed, Apr 02, 2025 at 12:10:37AM +0000, Harshitha Ramamurthy wrote:
> > From: Joshua Washington <joshwash@...gle.com>
> >
> > When the tx tail is less than the head (in cases of wraparound), the TX
> > consumed descriptor statistic in DQ will be reported as
> > UINT32_MAX - head + tail, which is incorrect. Mask the difference of
> > head and tail according to the ring size when reporting the statistic.
> >
> > Cc: stable@...r.kernel.org
> > Fixes: 2c9198356d56 ("gve: Add consumed counts to ethtool stats")
> > Signed-off-by: Joshua Washington <joshwash@...gle.com>
> > Signed-off-by: Harshitha Ramamurthy <hramamurthy@...gle.com>
> > ---
> > drivers/net/ethernet/google/gve/gve_ethtool.c | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/net/ethernet/google/gve/gve_ethtool.c b/drivers/net/ethernet/google/gve/gve_ethtool.c
> > index 31a21ccf4863..4dea1fdce748 100644
> > --- a/drivers/net/ethernet/google/gve/gve_ethtool.c
> > +++ b/drivers/net/ethernet/google/gve/gve_ethtool.c
> > @@ -392,7 +392,9 @@ gve_get_ethtool_stats(struct net_device *netdev,
> > */
> > data[i++] = 0;
> > data[i++] = 0;
> > - data[i++] = tx->dqo_tx.tail - tx->dqo_tx.head;
> > + data[i++] =
> > + (tx->dqo_tx.tail - tx->dqo_tx.head) &
> > + tx->mask;
>
> Reviewed-by: Michal Swiatkowski <michal.swiatkowski@...ux.intel.com>
>
> I will add it in gve_tx_dqo.c as num_used_tx_slots() and simplify
> num_avail_tx_slots()
> {
> return tx->mask - num_used_tx_slots();
> }
> but it isn't needed, even maybe unwanted as this is just fix.
I think that would be a nice cleanup, but should be as a follow-up
to this minimal fix.
Reviewed-by: Simon Horman <horms@...nel.org>
Powered by blists - more mailing lists