Changeset View
Changeset View
Standalone View
Standalone View
sys/xen/interface/io/ring.h
Show First 20 Lines • Show All 225 Lines • ▼ Show 20 Lines | #define RING_HAS_UNCONSUMED_REQUESTS(_r) \ | ||||
((_r)->sring->req_prod - (_r)->req_cons) : \ | ((_r)->sring->req_prod - (_r)->req_cons) : \ | ||||
(RING_SIZE(_r) - ((_r)->req_cons - (_r)->rsp_prod_pvt))) | (RING_SIZE(_r) - ((_r)->req_cons - (_r)->rsp_prod_pvt))) | ||||
#endif | #endif | ||||
/* Direct access to individual ring elements, by index. */ | /* Direct access to individual ring elements, by index. */ | ||||
#define RING_GET_REQUEST(_r, _idx) \ | #define RING_GET_REQUEST(_r, _idx) \ | ||||
(&((_r)->sring->ring[((_idx) & (RING_SIZE(_r) - 1))].req)) | (&((_r)->sring->ring[((_idx) & (RING_SIZE(_r) - 1))].req)) | ||||
#define RING_GET_RESPONSE(_r, _idx) \ | |||||
(&((_r)->sring->ring[((_idx) & (RING_SIZE(_r) - 1))].rsp)) | |||||
/* | /* | ||||
* Get a local copy of a request. | * Get a local copy of a request/response. | ||||
* | * | ||||
* Use this in preference to RING_GET_REQUEST() so all processing is | * Use this in preference to RING_GET_{REQUEST,RESPONSE}() so all processing is | ||||
* done on a local copy that cannot be modified by the other end. | * done on a local copy that cannot be modified by the other end. | ||||
* | * | ||||
* Note that https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58145 may cause this | * Note that https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58145 may cause this | ||||
* to be ineffective where _req is a struct which consists of only bitfields. | * to be ineffective where dest is a struct which consists of only bitfields. | ||||
*/ | */ | ||||
#define RING_COPY_REQUEST(_r, _idx, _req) do { \ | #define RING_COPY_(type, r, idx, dest) do { \ | ||||
/* Use volatile to force the copy into _req. */ \ | /* Use volatile to force the copy into dest. */ \ | ||||
*(_req) = *(volatile typeof(_req))RING_GET_REQUEST(_r, _idx); \ | *(dest) = *(volatile __typeof__(dest))RING_GET_##type(r, idx); \ | ||||
} while (0) | } while (0) | ||||
#define RING_GET_RESPONSE(_r, _idx) \ | #define RING_COPY_REQUEST(r, idx, req) RING_COPY_(REQUEST, r, idx, req) | ||||
(&((_r)->sring->ring[((_idx) & (RING_SIZE(_r) - 1))].rsp)) | #define RING_COPY_RESPONSE(r, idx, rsp) RING_COPY_(RESPONSE, r, idx, rsp) | ||||
/* Loop termination condition: Would the specified index overflow the ring? */ | /* Loop termination condition: Would the specified index overflow the ring? */ | ||||
#define RING_REQUEST_CONS_OVERFLOW(_r, _cons) \ | #define RING_REQUEST_CONS_OVERFLOW(_r, _cons) \ | ||||
(((_cons) - (_r)->rsp_prod_pvt) >= RING_SIZE(_r)) | (((_cons) - (_r)->rsp_prod_pvt) >= RING_SIZE(_r)) | ||||
/* Ill-behaved frontend determination: Can there be this many requests? */ | /* Ill-behaved frontend determination: Can there be this many requests? */ | ||||
#define RING_REQUEST_PROD_OVERFLOW(_r, _prod) \ | #define RING_REQUEST_PROD_OVERFLOW(_r, _prod) \ | ||||
(((_prod) - (_r)->rsp_prod_pvt) > RING_SIZE(_r)) | (((_prod) - (_r)->rsp_prod_pvt) > RING_SIZE(_r)) | ||||
/* Ill-behaved backend determination: Can there be this many responses? */ | |||||
#define RING_RESPONSE_PROD_OVERFLOW(_r, _prod) \ | |||||
(((_prod) - (_r)->rsp_cons) > RING_SIZE(_r)) | |||||
#define RING_PUSH_REQUESTS(_r) do { \ | #define RING_PUSH_REQUESTS(_r) do { \ | ||||
xen_wmb(); /* back sees requests /before/ updated producer index */ \ | xen_wmb(); /* back sees requests /before/ updated producer index */ \ | ||||
(_r)->sring->req_prod = (_r)->req_prod_pvt; \ | (_r)->sring->req_prod = (_r)->req_prod_pvt; \ | ||||
} while (0) | } while (0) | ||||
#define RING_PUSH_RESPONSES(_r) do { \ | #define RING_PUSH_RESPONSES(_r) do { \ | ||||
xen_wmb(); /* front sees resps /before/ updated producer index */ \ | xen_wmb(); /* front sees resps /before/ updated producer index */ \ | ||||
▲ Show 20 Lines • Show All 223 Lines • Show Last 20 Lines |