Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

xen/interface: re-define FRONT/BACK_RING_ATTACH()

Currently these macros are defined to re-initialize a front/back ring
(respectively) to values read from the shared ring in such a way that any
requests/responses that are added to the shared ring whilst the front/back
is detached will be skipped over. This, in general, is not a desirable
semantic since most frontend implementations will eventually block waiting
for a response which would either never appear or never be processed.

Since the macros are currently unused, take this opportunity to re-define
them to re-initialize a front/back ring using specified values. This also
allows FRONT/BACK_RING_INIT() to be re-defined in terms of
FRONT/BACK_RING_ATTACH() using a specified value of 0.

NOTE: BACK_RING_ATTACH() will be used directly in a subsequent patch.

Signed-off-by: Paul Durrant <pdurrant@amazon.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
Signed-off-by: Juergen Gross <jgross@suse.com>

authored by

Paul Durrant and committed by
Juergen Gross
1ee54195 672b7763

+9 -20
+9 -20
include/xen/interface/io/ring.h
··· 125 125 memset((_s)->pad, 0, sizeof((_s)->pad)); \ 126 126 } while(0) 127 127 128 - #define FRONT_RING_INIT(_r, _s, __size) do { \ 129 - (_r)->req_prod_pvt = 0; \ 130 - (_r)->rsp_cons = 0; \ 128 + #define FRONT_RING_ATTACH(_r, _s, _i, __size) do { \ 129 + (_r)->req_prod_pvt = (_i); \ 130 + (_r)->rsp_cons = (_i); \ 131 131 (_r)->nr_ents = __RING_SIZE(_s, __size); \ 132 132 (_r)->sring = (_s); \ 133 133 } while (0) 134 134 135 - #define BACK_RING_INIT(_r, _s, __size) do { \ 136 - (_r)->rsp_prod_pvt = 0; \ 137 - (_r)->req_cons = 0; \ 135 + #define FRONT_RING_INIT(_r, _s, __size) FRONT_RING_ATTACH(_r, _s, 0, __size) 136 + 137 + #define BACK_RING_ATTACH(_r, _s, _i, __size) do { \ 138 + (_r)->rsp_prod_pvt = (_i); \ 139 + (_r)->req_cons = (_i); \ 138 140 (_r)->nr_ents = __RING_SIZE(_s, __size); \ 139 141 (_r)->sring = (_s); \ 140 142 } while (0) 141 143 142 - /* Initialize to existing shared indexes -- for recovery */ 143 - #define FRONT_RING_ATTACH(_r, _s, __size) do { \ 144 - (_r)->sring = (_s); \ 145 - (_r)->req_prod_pvt = (_s)->req_prod; \ 146 - (_r)->rsp_cons = (_s)->rsp_prod; \ 147 - (_r)->nr_ents = __RING_SIZE(_s, __size); \ 148 - } while (0) 149 - 150 - #define BACK_RING_ATTACH(_r, _s, __size) do { \ 151 - (_r)->sring = (_s); \ 152 - (_r)->rsp_prod_pvt = (_s)->rsp_prod; \ 153 - (_r)->req_cons = (_s)->req_prod; \ 154 - (_r)->nr_ents = __RING_SIZE(_s, __size); \ 155 - } while (0) 144 + #define BACK_RING_INIT(_r, _s, __size) BACK_RING_ATTACH(_r, _s, 0, __size) 156 145 157 146 /* How big is this ring? */ 158 147 #define RING_SIZE(_r) \