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