vhost: add packed ring indexes increasing function
When enqueuing or dequeuing, the virtqueue's local available and used indexes are increased. Signed-off-by: Marvin Liu <yong.liu@intel.com> Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
This commit is contained in:
parent
0e4949639b
commit
86202aae94
@ -367,6 +367,26 @@ desc_is_avail(struct vring_packed_desc *desc, bool wrap_counter)
|
||||
wrap_counter != !!(flags & VRING_DESC_F_USED);
|
||||
}
|
||||
|
||||
static inline void
|
||||
vq_inc_last_used_packed(struct vhost_virtqueue *vq, uint16_t num)
|
||||
{
|
||||
vq->last_used_idx += num;
|
||||
if (vq->last_used_idx >= vq->size) {
|
||||
vq->used_wrap_counter ^= 1;
|
||||
vq->last_used_idx -= vq->size;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
vq_inc_last_avail_packed(struct vhost_virtqueue *vq, uint16_t num)
|
||||
{
|
||||
vq->last_avail_idx += num;
|
||||
if (vq->last_avail_idx >= vq->size) {
|
||||
vq->avail_wrap_counter ^= 1;
|
||||
vq->last_avail_idx -= vq->size;
|
||||
}
|
||||
}
|
||||
|
||||
void __vhost_log_cache_write(struct virtio_net *dev,
|
||||
struct vhost_virtqueue *vq,
|
||||
uint64_t addr, uint64_t len);
|
||||
|
@ -138,11 +138,7 @@ flush_shadow_used_ring_packed(struct virtio_net *dev,
|
||||
head_flags = flags;
|
||||
}
|
||||
|
||||
vq->last_used_idx += vq->shadow_used_packed[i].count;
|
||||
if (vq->last_used_idx >= vq->size) {
|
||||
vq->used_wrap_counter ^= 1;
|
||||
vq->last_used_idx -= vq->size;
|
||||
}
|
||||
vq_inc_last_used_packed(vq, vq->shadow_used_packed[i].count);
|
||||
}
|
||||
|
||||
__atomic_store_n(&vq->desc_packed[head_idx].flags, head_flags,
|
||||
@ -865,11 +861,7 @@ virtio_dev_rx_packed(struct virtio_net *dev, struct vhost_virtqueue *vq,
|
||||
break;
|
||||
}
|
||||
|
||||
vq->last_avail_idx += nr_descs;
|
||||
if (vq->last_avail_idx >= vq->size) {
|
||||
vq->last_avail_idx -= vq->size;
|
||||
vq->avail_wrap_counter ^= 1;
|
||||
}
|
||||
vq_inc_last_avail_packed(vq, nr_descs);
|
||||
}
|
||||
|
||||
do_data_copy_enqueue(dev, vq);
|
||||
@ -1585,11 +1577,7 @@ virtio_dev_tx_packed(struct virtio_net *dev, struct vhost_virtqueue *vq,
|
||||
TAILQ_INSERT_TAIL(&vq->zmbuf_list, zmbuf, next);
|
||||
}
|
||||
|
||||
vq->last_avail_idx += desc_count;
|
||||
if (vq->last_avail_idx >= vq->size) {
|
||||
vq->last_avail_idx -= vq->size;
|
||||
vq->avail_wrap_counter ^= 1;
|
||||
}
|
||||
vq_inc_last_avail_packed(vq, desc_count);
|
||||
}
|
||||
|
||||
if (likely(dev->dequeue_zero_copy == 0)) {
|
||||
|
Loading…
Reference in New Issue
Block a user