-/* $OpenBSD: virtio.c,v 1.9 2017/05/30 19:28:09 sf Exp $ */
+/* $OpenBSD: virtio.c,v 1.10 2017/05/31 08:10:24 krw Exp $ */
/* $NetBSD: virtio.c,v 1.3 2011/11/02 23:05:52 njoly Exp $ */
/*
{
struct vq_entry *qe1 = &vq->vq_entries[slot];
struct vring_desc *vd = &vq->vq_desc[0];
- struct vq_entry *qe;
- int i, s;
+ int i;
if ((vd[slot].flags & VRING_DESC_F_INDIRECT) == 0) {
- qe1->qe_indirect = 0;
- qe1->qe_desc_base = vd;
qe1->qe_next = qe1->qe_index;
-
/*
* N.B.: the vq_entries are ASSUMED to be a contiguous
* block with slot being the index to the first one.
*/
- s = slot;
- for (i = 0; i < nsegs - 1; i++) {
- qe = &vq->vq_entries[s+1];
- vd[s].flags = VRING_DESC_F_NEXT;
- vd[s].next = qe->qe_index;
- s = qe->qe_index;
- }
- vd[s].flags = 0;
} else {
+ qe1->qe_next = 0;
vd = &vq->vq_desc[qe1->qe_index];
vd->len = sizeof(struct vring_desc) * nsegs;
vd = qe1->qe_desc_base;
- for (i = 0; i < nsegs; i++) {
- vd[i].flags = VRING_DESC_F_NEXT;
- if (i == (nsegs - 1))
- vd[i].flags = 0;
- }
- qe1->qe_next = 0;
+ slot = 0;
+ }
+
+ for (i = 0; i < nsegs -1 ; i++) {
+ vd[slot].flags = VRING_DESC_F_NEXT;
+ slot++;
}
+ vd[slot].flags = 0;
}
/*