Skip to content

Commit

Permalink
virtqueue: Add helper to get the buffer address from descriptor index
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
arnopo committed Jun 24, 2022
1 parent b6d639d commit cd6042b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/include/openamp/virtqueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
6 changes: 6 additions & 0 deletions lib/virtio/virtqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -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].len);
return virtqueue_phys_to_virt(vq, vq->vq_ring.desc[idx].addr);
}

/**
* virtqueue_free - Frees VirtIO queue resources
*
Expand Down

0 comments on commit cd6042b

Please sign in to comment.