Skip to content

Commit

Permalink
Refactor VRING macros for AMP VIRTIO
Browse files Browse the repository at this point in the history
Renamed AMP VIRTIO macros to avoid conflicts.

Signed-off-by: Dan Milea <[email protected]>
  • Loading branch information
Dan Milea authored and arnopo committed Oct 10, 2023
1 parent 937ba1d commit bdf5f91
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 24 deletions.
24 changes: 1 addition & 23 deletions lib/include/openamp/virtio.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,29 +136,7 @@ struct virtio_device_id {
#define VIRTIO_ASSERT(_exp, _msg) metal_assert(_exp)
#endif /* VIRTIO_DEBUG */

#define VRING_ALIGNMENT 4096

#define VIRTIO_RING_SIZE(n, align) \
(( \
( \
sizeof(struct vring_desc) * n + \
sizeof(struct vring_avail) + \
sizeof(uint16_t) * (n + 1) + \
align - 1 \
) \
& ~(align - 1) \
) + \
sizeof(struct vring_used) + \
sizeof(struct vring_used_elem) * n + sizeof(uint16_t))

#define VRING_DECLARE(name, n, align) \
static char __vrbuf_##name[VIRTIO_RING_SIZE(n, align)] __aligned(VRING_ALIGNMENT); \
static struct vring __vring_##name = { \
.desc = (void *)__vrbuf_##name, \
.avail = (void *)((unsigned long)__vrbuf_##name + n * sizeof(struct vring_desc)), \
.used = (void *)((unsigned long)__vrbuf_##name + ((n * sizeof(struct vring_desc) + \
(n + 1) * sizeof(uint16_t) + align - 1) & ~(align - 1))), \
}
#define VIRTIO_MMIO_VRING_ALIGNMENT 4096

typedef void (*virtio_dev_reset_cb)(struct virtio_device *vdev);

Expand Down
2 changes: 1 addition & 1 deletion lib/virtio_mmio/virtio_mmio_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ struct virtqueue *virtio_mmio_setup_virtqueue(struct virtio_device *vdev,

vring_info->io = vmdev->shm_io;
vring_info->info.num_descs = virtio_mmio_get_max_elem(vdev, idx);
vring_info->info.align = VRING_ALIGNMENT;
vring_info->info.align = VIRTIO_MMIO_VRING_ALIGNMENT;

/* Check if vrings are already configured */
if (vq->vq_nentries != 0 && vq->vq_nentries == vq->vq_free_cnt &&
Expand Down

0 comments on commit bdf5f91

Please sign in to comment.