From a72505824cd9006454e4000ddac7f455242ff50d Mon Sep 17 00:00:00 2001 From: Luigi Rizzo Date: Sun, 11 Mar 2012 17:35:12 +0000 Subject: [PATCH] - remove an extra parenthesis in a closing brace; - add the macro NETMAP_RING_FIRST_RESERVED() which returns the index of the first non-released buffer in the ring (this is useful for code that retains buffers for some time instead of processing them immediately) --- sys/net/netmap_user.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sys/net/netmap_user.h b/sys/net/netmap_user.h index be66e7a14bee..4efdec34c4f5 100644 --- a/sys/net/netmap_user.h +++ b/sys/net/netmap_user.h @@ -77,11 +77,16 @@ #define NETMAP_BUF_IDX(ring, buf) \ ( ((char *)(buf) - ((char *)(ring) + (ring)->buf_ofs) ) / \ - (ring)->nr_buf_size) ) + (ring)->nr_buf_size ) #define NETMAP_RING_NEXT(r, i) \ ((i)+1 == (r)->num_slots ? 0 : (i) + 1 ) +#define NETMAP_RING_FIRST_RESERVED(r) \ + ( (r)->cur < (r)->reserved ? \ + (r)->cur + (r)->num_slots - (r)->reserved : \ + (r)->cur - (r)->reserved ) + /* * Return 1 if the given tx ring is empty. */