Thread (39 messages) 39 messages, 4 authors, 2018-04-04

Re: [PATCH 11/17] vhost: add helpers for packed virtqueues

From: Jens Freimann <hidden>
Date: 2018-03-21 09:17:54

On Mon, Mar 19, 2018 at 06:39:56PM +0800, Tiwei Bie wrote:
On Fri, Mar 16, 2018 at 04:21:14PM +0100, Jens Freimann wrote:
quoted
Add some helper functions to set/check descriptor flags
and toggle the used wrap counter.

Signed-off-by: Jens Freimann <redacted>
[...]
quoted
+static inline void
+toggle_wrap_counter(struct vhost_virtqueue *vq)
+{
+	vq->used_wrap_counter ^= 1;
+}
+
+static inline int
+desc_is_avail(struct vhost_virtqueue *vq, struct vring_desc_packed *desc)
+{
+	if (unlikely(!vq))
+		return -1;
Maybe it's better to let the caller make sure the vq
won't be NULL.
quoted
+
+	if (vq->used_wrap_counter == 1)
+		if ((desc->flags & DESC_AVAIL) && !(desc->flags & DESC_USED))
+			return 1;
+	if (vq->used_wrap_counter == 0)
Maybe it's better to use '} else {' here.
Agree with both, thanks for the review!

regards,
Jens 
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help