/* vq->avail->flags */
qvirtio_writew(vq->vdev, qts, vq->avail, 0);
- /* vq->avail->idx */
- qvirtio_writew(vq->vdev, qts, vq->avail + 2, 0);
+
+ qvirtqueue_set_avail_idx(qts, vq->vdev, vq, 0);
+
/* vq->avail->used_event */
qvirtio_writew(vq->vdev, qts, vq->avail + 4 + (2 * vq->size), 0);
return vq->free_head++; /* Return and increase, in this order */
}
+void qvirtqueue_set_avail_idx(QTestState *qts, QVirtioDevice *d,
+ QVirtQueue *vq, uint16_t idx)
+{
+ /* vq->avail->idx */
+ qvirtio_writew(d, qts, vq->avail + 2, idx);
+}
+
void qvirtqueue_kick(QTestState *qts, QVirtioDevice *d, QVirtQueue *vq,
uint32_t free_head)
{
/* vq->avail->ring[idx % vq->size] */
qvirtio_writew(d, qts, vq->avail + 4 + (2 * (idx % vq->size)), free_head);
- /* vq->avail->idx */
- qvirtio_writew(d, qts, vq->avail + 2, idx + 1);
+
+ qvirtqueue_set_avail_idx(qts, d, vq, idx + 1);
/* Must read after idx is updated */
flags = qvirtio_readw(d, qts, vq->used);
uint32_t len, bool write, bool next);
uint32_t qvirtqueue_add_indirect(QTestState *qts, QVirtQueue *vq,
QVRingIndirectDesc *indirect);
+void qvirtqueue_set_avail_idx(QTestState *qts, QVirtioDevice *d,
+ QVirtQueue *vq, uint16_t idx);
void qvirtqueue_kick(QTestState *qts, QVirtioDevice *d, QVirtQueue *vq,
uint32_t free_head);
bool qvirtqueue_get_buf(QTestState *qts, QVirtQueue *vq, uint32_t *desc_idx,