summaryrefslogtreecommitdiff
path: root/drivers/net/ethernet/netronome/nfp/nfp_net.h
diff options
context:
space:
mode:
authorJakub Kicinski <jakub.kicinski@netronome.com>2017-05-15 17:55:22 -0700
committerDavid S. Miller <davem@davemloft.net>2017-05-16 12:59:04 -0400
commit4aa3b7660aa79bb030aaa887dc16a60e02fa4348 (patch)
tree1a96f186c151530f5c6b24bdb071934b34566418 /drivers/net/ethernet/netronome/nfp/nfp_net.h
parentabeeec4adf6a6fe71a6a4d8199ff0a533d73a57f (diff)
downloadlwn-4aa3b7660aa79bb030aaa887dc16a60e02fa4348.tar.gz
lwn-4aa3b7660aa79bb030aaa887dc16a60e02fa4348.zip
nfp: add a helper for wrapping descriptor index
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.kicinski@netronome.com> Reviewed-by: Simon Horman <simon.horman@netronome.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/netronome/nfp/nfp_net.h')
-rw-r--r--drivers/net/ethernet/netronome/nfp/nfp_net.h3
1 files changed, 3 insertions, 0 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))
+
/* Convenience macro for writing dma address into RX/TX descriptors */
#define nfp_desc_set_dma_addr(desc, dma_addr) \
do { \