Skip to content

Commit

Permalink
virtio: modify vring_init and vring_size to take account of the layou…
Browse files Browse the repository at this point in the history
…t containing *_event_idx

Based on the layout description in the comments, take account of
the *_event_idx in functions vring_init and vring_size.

Signed-off-by: Wang Sheng-Hui <shhuiw@gmail.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
  • Loading branch information
Wang Sheng-Hui authored and Rusty Russell committed Nov 2, 2011
1 parent 5f41f8b commit 00b894e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions include/linux/virtio_ring.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,13 @@ static inline void vring_init(struct vring *vr, unsigned int num, void *p,
vr->num = num;
vr->desc = p;
vr->avail = p + num*sizeof(struct vring_desc);
vr->used = (void *)(((unsigned long)&vr->avail->ring[num] + align-1)
& ~(align - 1));
vr->used = (void *)(((unsigned long)&vr->avail->ring[num] + sizeof(__u16)
+ align-1) & ~(align - 1));
}

static inline unsigned vring_size(unsigned int num, unsigned long align)
{
return ((sizeof(struct vring_desc) * num + sizeof(__u16) * (2 + num)
return ((sizeof(struct vring_desc) * num + sizeof(__u16) * (3 + num)
+ align - 1) & ~(align - 1))
+ sizeof(__u16) * 3 + sizeof(struct vring_used_elem) * num;
}
Expand Down

0 comments on commit 00b894e

Please sign in to comment.