vio: create routines for inc,dec vio dring indexes

Both sunvdc and sunvnet implemented distinct functionality for incrementing
and decrementing dring indexes. Create common functions for use by both
from the sunvnet versions, which were chosen since they will still work
correctly in case a non power of two ring size is used.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Dwight Engen
2014-12-11 12:26:15 -05:00
committed by David S. Miller
parent 31f4888f51
commit fe47c3c262
3 changed files with 25 additions and 26 deletions

View File

@@ -300,6 +300,21 @@ static inline u32 vio_dring_avail(struct vio_dring_state *dr,
((dr->prod - dr->cons) & (ring_size - 1)) - 1);
}
static inline u32 vio_dring_next(struct vio_dring_state *dr, u32 index)
{
if (++index == dr->num_entries)
index = 0;
return index;
}
static inline u32 vio_dring_prev(struct vio_dring_state *dr, u32 index)
{
if (index == 0)
return dr->num_entries - 1;
else
return index - 1;
}
#define VIO_MAX_TYPE_LEN 32
#define VIO_MAX_COMPAT_LEN 64