Skip to content

Commit 6fac592

Browse files
committed
xen: update ring.h
Update include/xen/interface/io/ring.h to its newest version. Switch the two improper use cases of RING_HAS_UNCONSUMED_RESPONSES() to XEN_RING_NR_UNCONSUMED_RESPONSES() in order to avoid the nasty XEN_RING_HAS_UNCONSUMED_IS_BOOL #define. Signed-off-by: Juergen Gross <[email protected]> Reviewed-by: Boris Ostrovsky <[email protected]> Signed-off-by: Juergen Gross <[email protected]>
1 parent 888fd78 commit 6fac592

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

drivers/net/xen-netfront.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,7 @@ static void xennet_set_rx_rsp_cons(struct netfront_queue *queue, RING_IDX val)
866866

867867
spin_lock_irqsave(&queue->rx_cons_lock, flags);
868868
queue->rx.rsp_cons = val;
869-
queue->rx_rsp_unconsumed = RING_HAS_UNCONSUMED_RESPONSES(&queue->rx);
869+
queue->rx_rsp_unconsumed = XEN_RING_NR_UNCONSUMED_RESPONSES(&queue->rx);
870870
spin_unlock_irqrestore(&queue->rx_cons_lock, flags);
871871
}
872872

@@ -1498,7 +1498,7 @@ static bool xennet_handle_rx(struct netfront_queue *queue, unsigned int *eoi)
14981498
return false;
14991499

15001500
spin_lock_irqsave(&queue->rx_cons_lock, flags);
1501-
work_queued = RING_HAS_UNCONSUMED_RESPONSES(&queue->rx);
1501+
work_queued = XEN_RING_NR_UNCONSUMED_RESPONSES(&queue->rx);
15021502
if (work_queued > queue->rx_rsp_unconsumed) {
15031503
queue->rx_rsp_unconsumed = work_queued;
15041504
*eoi = 0;

include/xen/interface/io/ring.h

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,8 @@ typedef unsigned int RING_IDX;
7272
* of the shared memory area (PAGE_SIZE, for instance). To initialise
7373
* the front half:
7474
*
75-
* mytag_front_ring_t front_ring;
76-
* SHARED_RING_INIT((mytag_sring_t *)shared_page);
77-
* FRONT_RING_INIT(&front_ring, (mytag_sring_t *)shared_page, PAGE_SIZE);
75+
* mytag_front_ring_t ring;
76+
* XEN_FRONT_RING_INIT(&ring, (mytag_sring_t *)shared_page, PAGE_SIZE);
7877
*
7978
* Initializing the back follows similarly (note that only the front
8079
* initializes the shared ring):
@@ -146,6 +145,11 @@ struct __name##_back_ring { \
146145

147146
#define FRONT_RING_INIT(_r, _s, __size) FRONT_RING_ATTACH(_r, _s, 0, __size)
148147

148+
#define XEN_FRONT_RING_INIT(r, s, size) do { \
149+
SHARED_RING_INIT(s); \
150+
FRONT_RING_INIT(r, s, size); \
151+
} while (0)
152+
149153
#define BACK_RING_ATTACH(_r, _s, _i, __size) do { \
150154
(_r)->rsp_prod_pvt = (_i); \
151155
(_r)->req_cons = (_i); \
@@ -170,16 +174,21 @@ struct __name##_back_ring { \
170174
(RING_FREE_REQUESTS(_r) == 0)
171175

172176
/* Test if there are outstanding messages to be processed on a ring. */
173-
#define RING_HAS_UNCONSUMED_RESPONSES(_r) \
177+
#define XEN_RING_NR_UNCONSUMED_RESPONSES(_r) \
174178
((_r)->sring->rsp_prod - (_r)->rsp_cons)
175179

176-
#define RING_HAS_UNCONSUMED_REQUESTS(_r) ({ \
180+
#define XEN_RING_NR_UNCONSUMED_REQUESTS(_r) ({ \
177181
unsigned int req = (_r)->sring->req_prod - (_r)->req_cons; \
178182
unsigned int rsp = RING_SIZE(_r) - \
179183
((_r)->req_cons - (_r)->rsp_prod_pvt); \
180184
req < rsp ? req : rsp; \
181185
})
182186

187+
#define RING_HAS_UNCONSUMED_RESPONSES(_r) \
188+
(!!XEN_RING_NR_UNCONSUMED_RESPONSES(_r))
189+
#define RING_HAS_UNCONSUMED_REQUESTS(_r) \
190+
(!!XEN_RING_NR_UNCONSUMED_REQUESTS(_r))
191+
183192
/* Direct access to individual ring elements, by index. */
184193
#define RING_GET_REQUEST(_r, _idx) \
185194
(&((_r)->sring->ring[((_idx) & (RING_SIZE(_r) - 1))].req))

0 commit comments

Comments
 (0)