Lines Matching +full:front +full:- +full:end
4 * Shared producer-consumer ring macros.
33 * - standard integers types (uint8_t, uint16_t, etc)
38 * - size_t
39 * - memcpy
40 * - grant_ref_t
45 #include "../xen-compat.h"
55 /* Round a 32-bit unsigned constant down to the nearest power of two. */
66 * power of two (so we can mask with (size-1) to loop around).
69 (__RD32(((_sz) - offsetof(struct _s##_sring, ring)) / \
70 sizeof(((struct _s##_sring *)0)->ring[0])))
75 (__RD32(((_sz) - (long)(_s)->ring + (long)(_s)) / sizeof((_s)->ring[0])))
90 * mytag_sring_t - The shared ring.
91 * mytag_front_ring_t - The 'front' half of the ring.
92 * mytag_back_ring_t - The 'back' half of the ring.
96 * the front half:
102 * Initializing the back follows similarly (note that only the front
131 union __name##_sring_entry ring[1]; /* variable-length */ \
134 /* "Front" end's private variables */ \
142 /* "Back" end's private variables */ \
158 * FRONT_RING_whatever works on the "front end" of a ring: here
161 * BACK_RING_whatever works on the "back end" of a ring: here
165 * This is OK in 1-for-1 request-response situations where the
166 * requestor (front end) never has more than RING_SIZE()-1
172 (_s)->req_prod = (_s)->rsp_prod = 0; \
173 (_s)->req_event = (_s)->rsp_event = 1; \
174 (void)memset((_s)->pvt.pvt_pad, 0, sizeof((_s)->pvt.pvt_pad)); \
175 (void)memset((_s)->__pad, 0, sizeof((_s)->__pad)); \
179 (_r)->req_prod_pvt = (_i); \
180 (_r)->rsp_cons = (_i); \
181 (_r)->nr_ents = __RING_SIZE(_s, __size); \
182 (_r)->sring = (_s); \
188 (_r)->rsp_prod_pvt = (_i); \
189 (_r)->req_cons = (_i); \
190 (_r)->nr_ents = __RING_SIZE(_s, __size); \
191 (_r)->sring = (_s); \
198 ((_r)->nr_ents)
200 /* Number of free requests (for use on front side only). */
202 (RING_SIZE(_r) - ((_r)->req_prod_pvt - (_r)->rsp_cons))
204 /* Test if there is an empty slot available on the front ring.
205 * (This is only meaningful from the front. )
212 ((_r)->sring->rsp_prod - (_r)->rsp_cons)
216 unsigned int req = (_r)->sring->req_prod - (_r)->req_cons; \
217 unsigned int rsp = RING_SIZE(_r) - \
218 ((_r)->req_cons - (_r)->rsp_prod_pvt); \
224 ((((_r)->sring->req_prod - (_r)->req_cons) < \
225 (RING_SIZE(_r) - ((_r)->req_cons - (_r)->rsp_prod_pvt))) ? \
226 ((_r)->sring->req_prod - (_r)->req_cons) : \
227 (RING_SIZE(_r) - ((_r)->req_cons - (_r)->rsp_prod_pvt)))
232 (&((_r)->sring->ring[((_idx) & (RING_SIZE(_r) - 1))].req))
235 (&((_r)->sring->ring[((_idx) & (RING_SIZE(_r) - 1))].rsp))
241 * done on a local copy that cannot be modified by the other end.
256 (((_cons) - (_r)->rsp_prod_pvt) >= RING_SIZE(_r))
258 /* Ill-behaved frontend determination: Can there be this many requests? */
260 (((_prod) - (_r)->rsp_prod_pvt) > RING_SIZE(_r))
262 /* Ill-behaved backend determination: Can there be this many responses? */
264 (((_prod) - (_r)->rsp_cons) > RING_SIZE(_r))
268 (_r)->sring->req_prod = (_r)->req_prod_pvt; \
272 xen_wmb(); /* front sees resps /before/ updated producer index */ \
273 (_r)->sring->rsp_prod = (_r)->rsp_prod_pvt; \
277 * Notification hold-off (req_event and rsp_event):
280 * necessary to notify the remote end. For example, if requests are in flight
281 * in a backend, the front may be able to queue further requests without
307 RING_IDX __old = (_r)->sring->req_prod; \
308 RING_IDX __new = (_r)->req_prod_pvt; \
310 (_r)->sring->req_prod = __new; \
312 (_notify) = ((RING_IDX)(__new - (_r)->sring->req_event) < \
313 (RING_IDX)(__new - __old)); \
317 RING_IDX __old = (_r)->sring->rsp_prod; \
318 RING_IDX __new = (_r)->rsp_prod_pvt; \
319 xen_wmb(); /* front sees resps /before/ updated producer index */ \
320 (_r)->sring->rsp_prod = __new; \
321 xen_mb(); /* front sees new resps /before/ we check rsp_event */ \
322 (_notify) = ((RING_IDX)(__new - (_r)->sring->rsp_event) < \
323 (RING_IDX)(__new - __old)); \
329 (_r)->sring->req_event = (_r)->req_cons + 1; \
337 (_r)->sring->rsp_event = (_r)->rsp_cons + 1; \
359 * within the range [0-size].
380 * space is currently on the ring (XEN_FLEX_RING_SIZE() -
392 (1UL << ((order) + XEN_PAGE_SHIFT - 1))
397 return idx & (ring_size - 1); \
415 size <= ring_size - *masked_cons) { \
418 memcpy(opaque, buf + *masked_cons, ring_size - *masked_cons); \
419 memcpy((unsigned char *)opaque + ring_size - *masked_cons, buf, \
420 size - (ring_size - *masked_cons)); \
433 size <= ring_size - *masked_prod) { \
436 memcpy(buf + *masked_prod, opaque, ring_size - *masked_prod); \
437 memcpy(buf, (unsigned char *)opaque + (ring_size - *masked_prod), \
438 size - (ring_size - *masked_prod)); \
459 size = prod - cons; \
461 size = ring_size - (cons - prod); \
490 * c-file-style: "BSD"
491 * c-basic-offset: 4
492 * tab-width: 4
493 * indent-tabs-mode: nil
494 * End: