Skip to content

Commit

Permalink
virtqueue: remove vq_ring_mem
Browse files Browse the repository at this point in the history
As we don't have indirect support, lets remove vq_ring_mem for now
since we don't really need vq_ring_mem for anything else.

Signed-off-by: Kumar Gala <[email protected]>
  • Loading branch information
galak committed Apr 12, 2018
1 parent 0a87280 commit 0525e3d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
1 change: 0 additions & 1 deletion lib/include/openamp/virtqueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ struct virtqueue {
uint16_t vq_queue_index;
uint16_t vq_nentries;
uint32_t vq_flags;
void *vq_ring_mem;
void (*callback) (struct virtqueue * vq);
void (*notify) (struct virtqueue * vq);
struct vring vq_ring;
Expand Down
16 changes: 5 additions & 11 deletions lib/virtio/virtqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include <metal/alloc.h>

/* Prototype for internal functions. */
static void vq_ring_init(struct virtqueue *, int);
static void vq_ring_init(struct virtqueue *, void *, int);
static void vq_ring_update_avail(struct virtqueue *, uint16_t);
static uint16_t vq_ring_add_buffer(struct virtqueue *, struct vring_desc *,
uint16_t, struct metal_sg *, int, int);
Expand Down Expand Up @@ -81,10 +81,9 @@ int virtqueue_create(struct virtio_device *virt_dev, unsigned short id,
vq->shm_io = shm_io;

//TODO : Whether we want to support indirect addition or not.
vq->vq_ring_mem = (void *)ring->vaddr;

/* Initialize vring control block in virtqueue. */
vq_ring_init(vq, ring->align);
vq_ring_init(vq, (void *)ring->vaddr, ring->align);

/* Disable callbacks - will be enabled by the application
* once initialization is completed.
Expand Down Expand Up @@ -303,11 +302,8 @@ void virtqueue_free(struct virtqueue *vq)
"%s: freeing non-empty virtqueue\r\n",
vq->vq_name);
}
//TODO : Need to free indirect buffers here

if (vq->vq_ring_mem != NULL) {
vq->vq_ring_mem = NULL;
}
//TODO : Need to free indirect buffers here

metal_free_memory(vq);
}
Expand Down Expand Up @@ -579,17 +575,15 @@ static void vq_ring_free_chain(struct virtqueue *vq, uint16_t desc_idx)
* vq_ring_init
*
*/
static void vq_ring_init(struct virtqueue *vq, int alignment)
static void vq_ring_init(struct virtqueue *vq, void *ring_mem, int alignment)
{
struct vring *vr;
unsigned char *ring_mem;
int i, size;

ring_mem = vq->vq_ring_mem;
size = vq->vq_nentries;
vr = &vq->vq_ring;

vring_init(vr, size, ring_mem, alignment);
vring_init(vr, size, (unsigned char *)ring_mem, alignment);

for (i = 0; i < size - 1; i++)
vr->desc[i].next = i + 1;
Expand Down

0 comments on commit 0525e3d

Please sign in to comment.