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
49 /* Round a 32-bit unsigned constant down to the nearest power of two. */
60 * power of two (so we can mask with (size-1) to loop around).
63 (__RD32(((_sz) - offsetof(struct _s##_sring, ring)) / \
64 sizeof(((struct _s##_sring *)0)->ring[0])))
69 (__RD32(((_sz) - (long)(_s)->ring + (long)(_s)) / sizeof((_s)->ring[0])))
84 * mytag_sring_t - The shared ring.
85 * mytag_front_ring_t - The 'front' half of the ring.
86 * mytag_back_ring_t - The 'back' half of the ring.
90 * the front half:
96 * Initializing the back follows similarly (note that only the front
116 union __name##_sring_entry ring[1]; /* variable-length */ \
119 /* "Front" end's private variables */ \
127 /* "Back" end's private variables */ \
138 * FRONT_RING_whatever works on the "front end" of a ring: here
141 * BACK_RING_whatever works on the "back end" of a ring: here
145 * This is OK in 1-for-1 request-response situations where the
146 * requestor (front end) never has more than RING_SIZE()-1
152 (_s)->req_prod = (_s)->rsp_prod = 0; \
153 (_s)->req_event = (_s)->rsp_event = 1; \
154 (void)memset((_s)->__pad, 0, sizeof((_s)->__pad)); \
158 (_r)->req_prod_pvt = (_i); \
159 (_r)->rsp_cons = (_i); \
160 (_r)->nr_ents = __RING_SIZE(_s, __size); \
161 (_r)->sring = (_s); \
167 (_r)->rsp_prod_pvt = (_i); \
168 (_r)->req_cons = (_i); \
169 (_r)->nr_ents = __RING_SIZE(_s, __size); \
170 (_r)->sring = (_s); \
177 ((_r)->nr_ents)
179 /* Number of free requests (for use on front side only). */
181 (RING_SIZE(_r) - ((_r)->req_prod_pvt - (_r)->rsp_cons))
183 /* Test if there is an empty slot available on the front ring.
184 * (This is only meaningful from the front. )
191 ((_r)->sring->rsp_prod - (_r)->rsp_cons)
194 unsigned int req = (_r)->sring->req_prod - (_r)->req_cons; \
195 unsigned int rsp = RING_SIZE(_r) - \
196 ((_r)->req_cons - (_r)->rsp_prod_pvt); \
202 (&((_r)->sring->ring[((_idx) & (RING_SIZE(_r) - 1))].req))
205 (&((_r)->sring->ring[((_idx) & (RING_SIZE(_r) - 1))].rsp))
211 * done on a local copy that cannot be modified by the other end.
226 (((_cons) - (_r)->rsp_prod_pvt) >= RING_SIZE(_r))
228 /* Ill-behaved frontend determination: Can there be this many requests? */
230 (((_prod) - (_r)->rsp_prod_pvt) > RING_SIZE(_r))
232 /* Ill-behaved backend determination: Can there be this many responses? */
234 (((_prod) - (_r)->rsp_cons) > RING_SIZE(_r))
238 (_r)->sring->req_prod = (_r)->req_prod_pvt; \
242 virt_wmb(); /* front sees resps /before/ updated producer index */ \
243 (_r)->sring->rsp_prod = (_r)->rsp_prod_pvt; \
247 * Notification hold-off (req_event and rsp_event):
250 * necessary to notify the remote end. For example, if requests are in flight
251 * in a backend, the front may be able to queue further requests without
277 RING_IDX __old = (_r)->sring->req_prod; \
278 RING_IDX __new = (_r)->req_prod_pvt; \
280 (_r)->sring->req_prod = __new; \
282 (_notify) = ((RING_IDX)(__new - (_r)->sring->req_event) < \
283 (RING_IDX)(__new - __old)); \
287 RING_IDX __old = (_r)->sring->rsp_prod; \
288 RING_IDX __new = (_r)->rsp_prod_pvt; \
289 virt_wmb(); /* front sees resps /before/ updated producer index */ \
290 (_r)->sring->rsp_prod = __new; \
291 virt_mb(); /* front sees new resps /before/ we check rsp_event */ \
292 (_notify) = ((RING_IDX)(__new - (_r)->sring->rsp_event) < \
293 (RING_IDX)(__new - __old)); \
299 (_r)->sring->req_event = (_r)->req_cons + 1; \
307 (_r)->sring->rsp_event = (_r)->rsp_cons + 1; \
329 * within the range [0-size].
350 * space is currently on the ring (XEN_FLEX_RING_SIZE() -
362 (1UL << ((order) + XEN_PAGE_SHIFT - 1))
367 return idx & (ring_size - 1); \
385 size <= ring_size - *masked_cons) { \
388 memcpy(opaque, buf + *masked_cons, ring_size - *masked_cons); \
389 memcpy((unsigned char *)opaque + ring_size - *masked_cons, buf, \
390 size - (ring_size - *masked_cons)); \
403 size <= ring_size - *masked_prod) { \
406 memcpy(buf + *masked_prod, opaque, ring_size - *masked_prod); \
407 memcpy(buf, (unsigned char *)opaque + (ring_size - *masked_prod), \
408 size - (ring_size - *masked_prod)); \
429 size = prod - cons; \
431 size = ring_size - (cons - prod); \