On Mon, May 15, 2017 at 05:55:22PM -0700, Jakub Kicinski wrote: > We have a number of places where we calculate the descriptor > index based on a value which may have overflown. Create a > macro for masking with the ring size. > > Signed-off-by: Jakub Kicinski <jakub.kicin...@netronome.com> > --- > drivers/net/ethernet/netronome/nfp/nfp_net.h | 3 +++ > drivers/net/ethernet/netronome/nfp/nfp_net_common.c | 21 > ++++++++++----------- > 2 files changed, 13 insertions(+), 11 deletions(-) > > diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net.h > b/drivers/net/ethernet/netronome/nfp/nfp_net.h > index 66319a1026bb..7b9518cbe965 100644 > --- a/drivers/net/ethernet/netronome/nfp/nfp_net.h > +++ b/drivers/net/ethernet/netronome/nfp/nfp_net.h > @@ -117,6 +117,9 @@ struct nfp_eth_table_port; > struct nfp_net; > struct nfp_net_r_vector; > > +/* Convenience macro for wrapping descriptor index on ring size */ > +#define D_IDX(ring, idx) ((idx) & ((ring)->cnt - 1))
Any reason not to make this a function? That notwithstanding: Reviewed-by: Simon Horman <simon.hor...@netronome.com>