Convert from GET/SET_FLATPTR() to GET/SET_LOWFLAT() - the latter produces better code.
Signed-off-by: Kevin O'Connor kevin@koconnor.net --- src/virtio-ring.c | 66 ++++++++++++++++++++++++++-------------------------- 1 files changed, 33 insertions(+), 33 deletions(-)
diff --git a/src/virtio-ring.c b/src/virtio-ring.c index 97a3ffe..0883330 100644 --- a/src/virtio-ring.c +++ b/src/virtio-ring.c @@ -37,8 +37,8 @@
int vring_more_used(struct vring_virtqueue *vq) { - struct vring_used *used = GET_FLATPTR(vq->vring.used); - int more = GET_FLATPTR(vq->last_used_idx) != GET_FLATPTR(used->idx); + struct vring_used *used = GET_LOWFLAT(vq->vring.used); + int more = GET_LOWFLAT(vq->last_used_idx) != GET_LOWFLAT(used->idx); /* Make sure ring reads are done after idx read above. */ smp_rmb(); return more; @@ -53,19 +53,19 @@ int vring_more_used(struct vring_virtqueue *vq) void vring_detach(struct vring_virtqueue *vq, unsigned int head) { struct vring *vr = &vq->vring; - struct vring_desc *desc = GET_FLATPTR(vr->desc); + struct vring_desc *desc = GET_LOWFLAT(vr->desc); unsigned int i;
/* find end of given descriptor */
i = head; - while (GET_FLATPTR(desc[i].flags) & VRING_DESC_F_NEXT) - i = GET_FLATPTR(desc[i].next); + while (GET_LOWFLAT(desc[i].flags) & VRING_DESC_F_NEXT) + i = GET_LOWFLAT(desc[i].next);
/* link it with free list and point to it */
- SET_FLATPTR(desc[i].next, GET_FLATPTR(vq->free_head)); - SET_FLATPTR(vq->free_head, head); + SET_LOWFLAT(desc[i].next, GET_LOWFLAT(vq->free_head)); + SET_LOWFLAT(vq->free_head, head); }
/* @@ -79,22 +79,22 @@ int vring_get_buf(struct vring_virtqueue *vq, unsigned int *len) { struct vring *vr = &vq->vring; struct vring_used_elem *elem; - struct vring_used *used = GET_FLATPTR(vq->vring.used); + struct vring_used *used = GET_LOWFLAT(vq->vring.used); u32 id; int ret;
// BUG_ON(!vring_more_used(vq));
- elem = &used->ring[GET_FLATPTR(vq->last_used_idx) % GET_FLATPTR(vr->num)]; - id = GET_FLATPTR(elem->id); + elem = &used->ring[GET_LOWFLAT(vq->last_used_idx) % GET_LOWFLAT(vr->num)]; + id = GET_LOWFLAT(elem->id); if (len != NULL) - *len = GET_FLATPTR(elem->len); + *len = GET_LOWFLAT(elem->len);
- ret = GET_FLATPTR(vq->vdata[id]); + ret = GET_LOWFLAT(vq->vdata[id]);
vring_detach(vq, id);
- SET_FLATPTR(vq->last_used_idx, GET_FLATPTR(vq->last_used_idx) + 1); + SET_LOWFLAT(vq->last_used_idx, GET_LOWFLAT(vq->last_used_idx) + 1);
return ret; } @@ -106,46 +106,46 @@ void vring_add_buf(struct vring_virtqueue *vq, { struct vring *vr = &vq->vring; int i, av, head, prev; - struct vring_desc *desc = GET_FLATPTR(vr->desc); - struct vring_avail *avail = GET_FLATPTR(vr->avail); + struct vring_desc *desc = GET_LOWFLAT(vr->desc); + struct vring_avail *avail = GET_LOWFLAT(vr->avail);
BUG_ON(out + in == 0);
prev = 0; - head = GET_FLATPTR(vq->free_head); - for (i = head; out; i = GET_FLATPTR(desc[i].next), out--) { - SET_FLATPTR(desc[i].flags, VRING_DESC_F_NEXT); - SET_FLATPTR(desc[i].addr, (u64)virt_to_phys(list->addr)); - SET_FLATPTR(desc[i].len, list->length); + head = GET_LOWFLAT(vq->free_head); + for (i = head; out; i = GET_LOWFLAT(desc[i].next), out--) { + SET_LOWFLAT(desc[i].flags, VRING_DESC_F_NEXT); + SET_LOWFLAT(desc[i].addr, (u64)virt_to_phys(list->addr)); + SET_LOWFLAT(desc[i].len, list->length); prev = i; list++; } - for ( ; in; i = GET_FLATPTR(desc[i].next), in--) { - SET_FLATPTR(desc[i].flags, VRING_DESC_F_NEXT|VRING_DESC_F_WRITE); - SET_FLATPTR(desc[i].addr, (u64)virt_to_phys(list->addr)); - SET_FLATPTR(desc[i].len, list->length); + for ( ; in; i = GET_LOWFLAT(desc[i].next), in--) { + SET_LOWFLAT(desc[i].flags, VRING_DESC_F_NEXT|VRING_DESC_F_WRITE); + SET_LOWFLAT(desc[i].addr, (u64)virt_to_phys(list->addr)); + SET_LOWFLAT(desc[i].len, list->length); prev = i; list++; } - SET_FLATPTR(desc[prev].flags, - GET_FLATPTR(desc[prev].flags) & ~VRING_DESC_F_NEXT); + SET_LOWFLAT(desc[prev].flags, + GET_LOWFLAT(desc[prev].flags) & ~VRING_DESC_F_NEXT);
- SET_FLATPTR(vq->free_head, i); + SET_LOWFLAT(vq->free_head, i);
- SET_FLATPTR(vq->vdata[head], index); + SET_LOWFLAT(vq->vdata[head], index);
- av = (GET_FLATPTR(avail->idx) + num_added) % GET_FLATPTR(vr->num); - SET_FLATPTR(avail->ring[av], head); + av = (GET_LOWFLAT(avail->idx) + num_added) % GET_LOWFLAT(vr->num); + SET_LOWFLAT(avail->ring[av], head); }
void vring_kick(unsigned int ioaddr, struct vring_virtqueue *vq, int num_added) { struct vring *vr = &vq->vring; - struct vring_avail *avail = GET_FLATPTR(vr->avail); + struct vring_avail *avail = GET_LOWFLAT(vr->avail);
/* Make sure idx update is done after ring write. */ smp_wmb(); - SET_FLATPTR(avail->idx, GET_FLATPTR(avail->idx) + num_added); + SET_LOWFLAT(avail->idx, GET_LOWFLAT(avail->idx) + num_added);
- vp_notify(ioaddr, GET_FLATPTR(vq->queue_index)); + vp_notify(ioaddr, GET_LOWFLAT(vq->queue_index)); }