diff options
Diffstat (limited to 'include/xen/interface/io/ring.h')
| -rw-r--r-- | include/xen/interface/io/ring.h | 16 | 
1 files changed, 14 insertions, 2 deletions
diff --git a/include/xen/interface/io/ring.h b/include/xen/interface/io/ring.h index e8cbf431c8c..7d28aff605c 100644 --- a/include/xen/interface/io/ring.h +++ b/include/xen/interface/io/ring.h @@ -24,8 +24,15 @@ typedef unsigned int RING_IDX;   * A ring contains as many entries as will fit, rounded down to the nearest   * power of two (so we can mask with (size-1) to loop around).   */ -#define __RING_SIZE(_s, _sz) \ -    (__RD32(((_sz) - (long)&(_s)->ring + (long)(_s)) / sizeof((_s)->ring[0]))) +#define __CONST_RING_SIZE(_s, _sz)				\ +	(__RD32(((_sz) - offsetof(struct _s##_sring, ring)) /	\ +		sizeof(((struct _s##_sring *)0)->ring[0]))) + +/* + * The same for passing in an actual pointer instead of a name tag. + */ +#define __RING_SIZE(_s, _sz)						\ +	(__RD32(((_sz) - (long)&(_s)->ring + (long)(_s)) / sizeof((_s)->ring[0])))  /*   * Macros to make the correct C datatypes for a new kind of ring. @@ -181,6 +188,11 @@ struct __name##_back_ring {						\  #define RING_REQUEST_CONS_OVERFLOW(_r, _cons)				\      (((_cons) - (_r)->rsp_prod_pvt) >= RING_SIZE(_r)) +/* Ill-behaved frontend determination: Can there be this many requests? */ +#define RING_REQUEST_PROD_OVERFLOW(_r, _prod)               \ +    (((_prod) - (_r)->rsp_prod_pvt) > RING_SIZE(_r)) + +  #define RING_PUSH_REQUESTS(_r) do {					\      wmb(); /* back sees requests /before/ updated producer index */	\      (_r)->sring->req_prod = (_r)->req_prod_pvt;				\  | 
