Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor VRING macros for AMP VIRTIO #505

Merged
merged 1 commit into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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