[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <063D6719AE5E284EB5DD2968C1650D6DCFFFA91C@AcuExch.aculab.com>
Date: Fri, 19 May 2017 09:18:34 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Jakub Kicinski' <kubakici@...pl>
CC: "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
"oss-drivers@...ronome.com" <oss-drivers@...ronome.com>
Subject: RE: [PATCH net-next 9/9] nfp: eliminate an if statement in
calculation of completed frames
From: Jakub Kicinski
> Sent: 17 May 2017 18:37
..
> > > while (todo--) {
> > > idx = D_IDX(tx_ring, tx_ring->rd_p++);
> >
> > That '++' looks suspicious.
> > I think you need to decide whether you are incrementing pointers into the ring
> > or indexes into it.
> > Sometimes it is safer to use a non-wrapping index and mask when accessing the entry.
> > entry_ptr = &ring[idx & (RING_SIZE - 1)]
> > Ring full is then (read_idx == write_idx + RING_SIZE),
> > ring empty (read_idx == write_idx).
> > So the index just wrap at (probably)_2^32.
>
> I may be missing the point. I use a mix of the two, actually, the
> software pointers are free running (non-wrapping) but the HW QCP
> pointers wrap. Because HW pointers wrap I always keep one entry on
> the rings empty, see nfp_net_tx_full().
Ah, I'd assumed that rd_p was a pointer, not an index.
David
Powered by blists - more mailing lists