virtqueue: Add helper to get the buffer address from descriptor index

As it possible to get the buffer length we need also to retrieve
the address associated to the descriptor index.
This is need by rpmsg virtio to implement the buffer recycler.

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
This commit is contained in:
Arnaud Pouliquen
2022-10-18 10:31:19 +02:00
committed by Arnaud Pouliquen
parent 753a20368b
commit 2e0015af74
2 changed files with 7 additions and 0 deletions
+1
View File
@@ -222,6 +222,7 @@ void virtqueue_notification(struct virtqueue *vq);
uint32_t virtqueue_get_desc_size(struct virtqueue *vq);
uint32_t virtqueue_get_buffer_length(struct virtqueue *vq, uint16_t idx);
void *virtqueue_get_buffer_addr(struct virtqueue *vq, uint16_t idx);
#if defined __cplusplus
}
+6
View File
@@ -226,6 +226,12 @@ uint32_t virtqueue_get_buffer_length(struct virtqueue *vq, uint16_t idx)
return vq->vq_ring.desc[idx].len;
}
void *virtqueue_get_buffer_addr(struct virtqueue *vq, uint16_t idx)
{
VRING_INVALIDATE(vq->vq_ring.desc[idx].addr);
return virtqueue_phys_to_virt(vq, vq->vq_ring.desc[idx].addr);
}
/**
* virtqueue_free - Frees VirtIO queue resources
*