lib: Add and use VIRTIO_ENABLED() macro

Checks if this symbol is defined and set to equal 1. Used to make it
more clear that a preprocessor level check is intended.

Signed-off-by: Andrew Davis <afd@ti.com>
This commit is contained in:
Andrew Davis
2024-04-23 09:29:18 +02:00
committed by Arnaud Pouliquen
parent ca56246b19
commit 7a8c292754
6 changed files with 53 additions and 51 deletions
+2
View File
@@ -101,6 +101,8 @@ __deprecated static inline int deprecated_virtio_dev_slave(void)
#warning "VIRTIO_DEVICE_ONLY is deprecated, please use VIRTIO_DRIVER_SUPPORT=0"
#endif
#define VIRTIO_ENABLED(option) (option == 1)
/** @brief Virtio device identifier. */
struct virtio_device_id {
/** Virtio subsystem device ID. */
+2 -2
View File
@@ -939,12 +939,12 @@ remoteproc_create_virtio(struct remoteproc *rproc,
unsigned int num_vrings, i;
struct metal_list *node;
#if !VIRTIO_DRIVER_SUPPORT
#if !VIRTIO_ENABLED(VIRTIO_DRIVER_SUPPORT)
if (role == VIRTIO_DEV_DRIVER)
return NULL;
#endif
#if !VIRTIO_DEVICE_SUPPORT
#if !VIRTIO_ENABLED(VIRTIO_DEVICE_SUPPORT)
if (role == VIRTIO_DEV_DEVICE)
return NULL;
#endif
+7 -7
View File
@@ -55,7 +55,7 @@ static int rproc_virtio_create_virtqueue(struct virtio_device *vdev,
if (!vring_info->vq)
return ERROR_NO_MEM;
if (VIRTIO_DRIVER_SUPPORT && vdev->role == VIRTIO_DEV_DRIVER) {
if (VIRTIO_ENABLED(VIRTIO_DRIVER_SUPPORT) && vdev->role == VIRTIO_DEV_DRIVER) {
size_t offset = metal_io_virt_to_offset(vring_info->io, vring_alloc->vaddr);
size_t size = vring_size(vring_alloc->num_descs, vring_alloc->align);
@@ -128,7 +128,7 @@ static unsigned char rproc_virtio_get_status(struct virtio_device *vdev)
return status;
}
#if VIRTIO_DRIVER_SUPPORT
#if VIRTIO_ENABLED(VIRTIO_DRIVER_SUPPORT)
static void rproc_virtio_set_status(struct virtio_device *vdev,
unsigned char status)
{
@@ -183,7 +183,7 @@ static uint32_t rproc_virtio_get_features(struct virtio_device *vdev)
return dfeatures & gfeatures;
}
#if VIRTIO_DRIVER_SUPPORT
#if VIRTIO_ENABLED(VIRTIO_DRIVER_SUPPORT)
static void rproc_virtio_set_features(struct virtio_device *vdev,
uint32_t features)
{
@@ -233,7 +233,7 @@ static void rproc_virtio_read_config(struct virtio_device *vdev,
}
}
#if VIRTIO_DRIVER_SUPPORT
#if VIRTIO_ENABLED(VIRTIO_DRIVER_SUPPORT)
static void rproc_virtio_write_config(struct virtio_device *vdev,
uint32_t offset, void *src, int length)
{
@@ -271,7 +271,7 @@ static const struct virtio_dispatch remoteproc_virtio_dispatch_funcs = {
.get_features = rproc_virtio_get_features,
.read_config = rproc_virtio_read_config,
.notify = rproc_virtio_virtqueue_notify,
#if VIRTIO_DRIVER_SUPPORT
#if VIRTIO_ENABLED(VIRTIO_DRIVER_SUPPORT)
/*
* We suppose here that the vdev is in a shared memory so that can
* be access only by one core: the host. In this case salve core has
@@ -326,7 +326,7 @@ rproc_virtio_create_vdev(unsigned int role, unsigned int notifyid,
vdev->vrings_num = num_vrings;
vdev->func = &remoteproc_virtio_dispatch_funcs;
#if VIRTIO_DRIVER_SUPPORT
#if VIRTIO_ENABLED(VIRTIO_DRIVER_SUPPORT)
if (role == VIRTIO_DEV_DRIVER) {
uint32_t dfeatures = rproc_virtio_get_dfeatures(vdev);
/* Assume the virtio driver support all remote features */
@@ -405,7 +405,7 @@ void rproc_virtio_wait_remote_ready(struct virtio_device *vdev)
* remote action, we can return. Behavior should be updated
* in future if a remote status is added.
*/
if (VIRTIO_DRIVER_SUPPORT && vdev->role == VIRTIO_DEV_DRIVER)
if (VIRTIO_ENABLED(VIRTIO_DRIVER_SUPPORT) && vdev->role == VIRTIO_DEV_DRIVER)
return;
while (1) {
+26 -26
View File
@@ -58,7 +58,7 @@ struct vbuff_reclaimer_t {
};
/* Default configuration */
#if VIRTIO_DRIVER_SUPPORT
#if VIRTIO_ENABLED(VIRTIO_DRIVER_SUPPORT)
#define RPMSG_VIRTIO_DEFAULT_CONFIG \
(&(const struct rpmsg_virtio_config) { \
.h2r_buf_size = RPMSG_BUFFER_SIZE, \
@@ -69,7 +69,7 @@ struct vbuff_reclaimer_t {
#define RPMSG_VIRTIO_DEFAULT_CONFIG NULL
#endif
#if VIRTIO_DRIVER_SUPPORT
#if VIRTIO_ENABLED(VIRTIO_DRIVER_SUPPORT)
metal_weak void *
rpmsg_virtio_shm_pool_get_buffer(struct rpmsg_virtio_shm_pool *shpool,
size_t size)
@@ -83,7 +83,7 @@ rpmsg_virtio_shm_pool_get_buffer(struct rpmsg_virtio_shm_pool *shpool,
return buffer;
}
#endif /*VIRTIO_DRIVER_SUPPORT*/
#endif
void rpmsg_virtio_init_shm_pool(struct rpmsg_virtio_shm_pool *shpool,
void *shb, size_t size)
@@ -114,7 +114,7 @@ static void rpmsg_virtio_return_buffer(struct rpmsg_virtio_device *rvdev,
BUFFER_INVALIDATE(buffer, len);
if (VIRTIO_DRIVER_SUPPORT && role == RPMSG_HOST) {
if (VIRTIO_ENABLED(VIRTIO_DRIVER_SUPPORT) && role == RPMSG_HOST) {
struct virtqueue_buf vqbuf;
(void)idx;
@@ -125,7 +125,7 @@ static void rpmsg_virtio_return_buffer(struct rpmsg_virtio_device *rvdev,
RPMSG_ASSERT(ret == VQUEUE_SUCCESS, "add buffer failed\r\n");
}
if (VIRTIO_DEVICE_SUPPORT && role == RPMSG_REMOTE) {
if (VIRTIO_ENABLED(VIRTIO_DEVICE_SUPPORT) && role == RPMSG_REMOTE) {
(void)buffer;
ret = virtqueue_add_consumed_buffer(rvdev->rvq, idx, len);
RPMSG_ASSERT(ret == VQUEUE_SUCCESS, "add consumed buffer failed\r\n");
@@ -152,7 +152,7 @@ static int rpmsg_virtio_enqueue_buffer(struct rpmsg_virtio_device *rvdev,
BUFFER_FLUSH(buffer, len);
if (VIRTIO_DRIVER_SUPPORT && role == RPMSG_HOST) {
if (VIRTIO_ENABLED(VIRTIO_DRIVER_SUPPORT) && role == RPMSG_HOST) {
struct virtqueue_buf vqbuf;
(void)idx;
@@ -162,7 +162,7 @@ static int rpmsg_virtio_enqueue_buffer(struct rpmsg_virtio_device *rvdev,
return virtqueue_add_buffer(rvdev->svq, &vqbuf, 1, 0, buffer);
}
if (VIRTIO_DEVICE_SUPPORT && role == RPMSG_REMOTE) {
if (VIRTIO_ENABLED(VIRTIO_DEVICE_SUPPORT) && role == RPMSG_REMOTE) {
(void)buffer;
return virtqueue_add_consumed_buffer(rvdev->svq, idx, len);
}
@@ -197,11 +197,11 @@ static void *rpmsg_virtio_get_tx_buffer(struct rpmsg_virtio_device *rvdev,
data = r_desc;
*idx = r_desc->idx;
if (VIRTIO_DRIVER_SUPPORT && role == RPMSG_HOST)
if (VIRTIO_ENABLED(VIRTIO_DRIVER_SUPPORT) && role == RPMSG_HOST)
*len = rvdev->config.h2r_buf_size;
if (VIRTIO_DEVICE_SUPPORT && role == RPMSG_REMOTE)
if (VIRTIO_ENABLED(VIRTIO_DEVICE_SUPPORT) && role == RPMSG_REMOTE)
*len = virtqueue_get_buffer_length(rvdev->svq, *idx);
} else if (VIRTIO_DRIVER_SUPPORT && role == RPMSG_HOST) {
} else if (VIRTIO_ENABLED(VIRTIO_DRIVER_SUPPORT) && role == RPMSG_HOST) {
data = virtqueue_get_buffer(rvdev->svq, len, idx);
if (!data && rvdev->svq->vq_free_cnt) {
data = rpmsg_virtio_shm_pool_get_buffer(rvdev->shpool,
@@ -209,7 +209,7 @@ static void *rpmsg_virtio_get_tx_buffer(struct rpmsg_virtio_device *rvdev,
*len = rvdev->config.h2r_buf_size;
*idx = 0;
}
} else if (VIRTIO_DEVICE_SUPPORT && role == RPMSG_REMOTE) {
} else if (VIRTIO_ENABLED(VIRTIO_DEVICE_SUPPORT) && role == RPMSG_REMOTE) {
data = virtqueue_get_available_buffer(rvdev->svq, idx, len);
}
@@ -233,11 +233,11 @@ static void *rpmsg_virtio_get_rx_buffer(struct rpmsg_virtio_device *rvdev,
unsigned int role = rpmsg_virtio_get_role(rvdev);
void *data = NULL;
if (VIRTIO_DRIVER_SUPPORT && role == RPMSG_HOST) {
if (VIRTIO_ENABLED(VIRTIO_DRIVER_SUPPORT) && role == RPMSG_HOST) {
data = virtqueue_get_buffer(rvdev->rvq, len, idx);
}
if (VIRTIO_DEVICE_SUPPORT && role == RPMSG_REMOTE) {
if (VIRTIO_ENABLED(VIRTIO_DEVICE_SUPPORT) && role == RPMSG_REMOTE) {
data =
virtqueue_get_available_buffer(rvdev->rvq, idx, len);
}
@@ -452,7 +452,7 @@ static int rpmsg_virtio_send_offchannel_nocopy(struct rpmsg_device *rdev,
metal_mutex_acquire(&rdev->lock);
if (VIRTIO_DRIVER_SUPPORT && rpmsg_virtio_get_role(rvdev) == RPMSG_HOST)
if (VIRTIO_ENABLED(VIRTIO_DRIVER_SUPPORT) && rpmsg_virtio_get_role(rvdev) == RPMSG_HOST)
buff_len = rvdev->config.h2r_buf_size;
else
buff_len = virtqueue_get_buffer_length(rvdev->svq, idx);
@@ -714,7 +714,7 @@ int rpmsg_virtio_get_tx_buffer_size(struct rpmsg_device *rdev)
rvdev = (struct rpmsg_virtio_device *)rdev;
role = rpmsg_virtio_get_role(rvdev);
if (VIRTIO_DRIVER_SUPPORT && role == RPMSG_HOST) {
if (VIRTIO_ENABLED(VIRTIO_DRIVER_SUPPORT) && role == RPMSG_HOST) {
/*
* If device role is host then buffers are provided by us,
* so just provide the macro.
@@ -722,7 +722,7 @@ int rpmsg_virtio_get_tx_buffer_size(struct rpmsg_device *rdev)
size = rvdev->config.h2r_buf_size - sizeof(struct rpmsg_hdr);
}
if (VIRTIO_DEVICE_SUPPORT && role == RPMSG_REMOTE) {
if (VIRTIO_ENABLED(VIRTIO_DEVICE_SUPPORT) && role == RPMSG_REMOTE) {
/*
* If other core is host then buffers are provided by it,
* so get the buffer size from the virtqueue.
@@ -752,7 +752,7 @@ int rpmsg_virtio_get_rx_buffer_size(struct rpmsg_device *rdev)
rvdev = (struct rpmsg_virtio_device *)rdev;
role = rpmsg_virtio_get_role(rvdev);
if (VIRTIO_DRIVER_SUPPORT && role == RPMSG_HOST) {
if (VIRTIO_ENABLED(VIRTIO_DRIVER_SUPPORT) && role == RPMSG_HOST) {
/*
* If device role is host then buffers are provided by us,
* so just provide the macro.
@@ -760,7 +760,7 @@ int rpmsg_virtio_get_rx_buffer_size(struct rpmsg_device *rdev)
size = rvdev->config.r2h_buf_size - sizeof(struct rpmsg_hdr);
}
if (VIRTIO_DEVICE_SUPPORT && role == RPMSG_REMOTE) {
if (VIRTIO_ENABLED(VIRTIO_DEVICE_SUPPORT) && role == RPMSG_REMOTE) {
/*
* If other core is host then buffers are provided by it,
* so get the buffer size from the virtqueue.
@@ -821,7 +821,7 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev,
rdev->ops.get_tx_buffer_size = rpmsg_virtio_get_tx_buffer_size;
role = rpmsg_virtio_get_role(rvdev);
if (VIRTIO_DRIVER_SUPPORT && role == RPMSG_HOST) {
if (VIRTIO_ENABLED(VIRTIO_DRIVER_SUPPORT) && role == RPMSG_HOST) {
/*
* The virtio configuration contains only options applicable to
* a virtio driver, implying rpmsg host role.
@@ -832,7 +832,7 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev,
rvdev->config = *config;
}
if (VIRTIO_DEVICE_SUPPORT && role == RPMSG_REMOTE) {
if (VIRTIO_ENABLED(VIRTIO_DEVICE_SUPPORT) && role == RPMSG_REMOTE) {
/* wait synchro with the host */
status = rpmsg_virtio_wait_remote_ready(rvdev);
if (status)
@@ -844,7 +844,7 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev,
return status;
rdev->support_ns = !!(features & (1 << VIRTIO_RPMSG_F_NS));
if (VIRTIO_DRIVER_SUPPORT && role == RPMSG_HOST) {
if (VIRTIO_ENABLED(VIRTIO_DRIVER_SUPPORT) && role == RPMSG_HOST) {
/*
* Since device is RPMSG Remote so we need to manage the
* shared buffers. Create shared memory pool to handle buffers.
@@ -861,7 +861,7 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev,
callback[1] = rpmsg_virtio_tx_callback;
}
if (VIRTIO_DEVICE_SUPPORT && role == RPMSG_REMOTE) {
if (VIRTIO_ENABLED(VIRTIO_DEVICE_SUPPORT) && role == RPMSG_REMOTE) {
vq_names[0] = "tx_vq";
vq_names[1] = "rx_vq";
callback[0] = rpmsg_virtio_tx_callback;
@@ -878,12 +878,12 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev,
return status;
/* Create virtqueue success, assign back the virtqueue */
if (VIRTIO_DRIVER_SUPPORT && role == RPMSG_HOST) {
if (VIRTIO_ENABLED(VIRTIO_DRIVER_SUPPORT) && role == RPMSG_HOST) {
rvdev->rvq = vdev->vrings_info[0].vq;
rvdev->svq = vdev->vrings_info[1].vq;
}
if (VIRTIO_DEVICE_SUPPORT && role == RPMSG_REMOTE) {
if (VIRTIO_ENABLED(VIRTIO_DEVICE_SUPPORT) && role == RPMSG_REMOTE) {
rvdev->rvq = vdev->vrings_info[1].vq;
rvdev->svq = vdev->vrings_info[0].vq;
}
@@ -902,7 +902,7 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev,
vq->shm_io = shm_io;
}
if (VIRTIO_DRIVER_SUPPORT && role == RPMSG_HOST) {
if (VIRTIO_ENABLED(VIRTIO_DRIVER_SUPPORT) && role == RPMSG_HOST) {
struct virtqueue_buf vqbuf;
unsigned int idx;
void *buffer;
@@ -947,7 +947,7 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev,
rpmsg_virtio_ns_callback, NULL, rvdev);
}
if (VIRTIO_DRIVER_SUPPORT && role == RPMSG_HOST) {
if (VIRTIO_ENABLED(VIRTIO_DRIVER_SUPPORT) && role == RPMSG_HOST) {
status = virtio_set_status(rvdev->vdev, VIRTIO_CONFIG_STATUS_DRIVER_OK);
if (status)
goto err;
+1 -1
View File
@@ -120,7 +120,7 @@ int virtio_create_virtqueues(struct virtio_device *vdev, unsigned int flags,
vring_info = &vdev->vrings_info[i];
vring_alloc = &vring_info->info;
if (VIRTIO_DRIVER_SUPPORT && vdev->role == VIRTIO_DEV_DRIVER) {
if (VIRTIO_ENABLED(VIRTIO_DRIVER_SUPPORT) && vdev->role == VIRTIO_DEV_DRIVER) {
size_t offset;
struct metal_io_region *io = vring_info->io;
+15 -15
View File
@@ -278,25 +278,25 @@ void virtqueue_disable_cb(struct virtqueue *vq)
VQUEUE_BUSY(vq);
if (vq->vq_dev->features & VIRTIO_RING_F_EVENT_IDX) {
if (VIRTIO_DRIVER_SUPPORT && vq->vq_dev->role == VIRTIO_DEV_DRIVER) {
if (VIRTIO_ENABLED(VIRTIO_DRIVER_SUPPORT) && vq->vq_dev->role == VIRTIO_DEV_DRIVER) {
vring_used_event(&vq->vq_ring) =
vq->vq_used_cons_idx - vq->vq_nentries - 1;
VRING_FLUSH(&vring_used_event(&vq->vq_ring),
sizeof(vring_used_event(&vq->vq_ring)));
}
if (VIRTIO_DEVICE_SUPPORT && vq->vq_dev->role == VIRTIO_DEV_DEVICE) {
if (VIRTIO_ENABLED(VIRTIO_DEVICE_SUPPORT) && vq->vq_dev->role == VIRTIO_DEV_DEVICE) {
vring_avail_event(&vq->vq_ring) =
vq->vq_available_idx - vq->vq_nentries - 1;
VRING_FLUSH(&vring_avail_event(&vq->vq_ring),
sizeof(vring_avail_event(&vq->vq_ring)));
}
} else {
if (VIRTIO_DRIVER_SUPPORT && vq->vq_dev->role == VIRTIO_DEV_DRIVER) {
if (VIRTIO_ENABLED(VIRTIO_DRIVER_SUPPORT) && vq->vq_dev->role == VIRTIO_DEV_DRIVER) {
vq->vq_ring.avail->flags |= VRING_AVAIL_F_NO_INTERRUPT;
VRING_FLUSH(&vq->vq_ring.avail->flags,
sizeof(vq->vq_ring.avail->flags));
}
if (VIRTIO_DEVICE_SUPPORT && vq->vq_dev->role == VIRTIO_DEV_DEVICE) {
if (VIRTIO_ENABLED(VIRTIO_DEVICE_SUPPORT) && vq->vq_dev->role == VIRTIO_DEV_DEVICE) {
vq->vq_ring.used->flags |= VRING_USED_F_NO_NOTIFY;
VRING_FLUSH(&vq->vq_ring.used->flags,
sizeof(vq->vq_ring.used->flags));
@@ -485,7 +485,7 @@ static void vq_ring_init(struct virtqueue *vq, void *ring_mem, int alignment)
vring_init(vr, size, ring_mem, alignment);
if (VIRTIO_DRIVER_SUPPORT && vq->vq_dev->role == VIRTIO_DEV_DRIVER) {
if (VIRTIO_ENABLED(VIRTIO_DRIVER_SUPPORT) && vq->vq_dev->role == VIRTIO_DEV_DRIVER) {
int i;
for (i = 0; i < size - 1; i++)
@@ -542,25 +542,25 @@ static int vq_ring_enable_interrupt(struct virtqueue *vq, uint16_t ndesc)
* what's already been consumed.
*/
if (vq->vq_dev->features & VIRTIO_RING_F_EVENT_IDX) {
if (VIRTIO_DRIVER_SUPPORT && vq->vq_dev->role == VIRTIO_DEV_DRIVER) {
if (VIRTIO_ENABLED(VIRTIO_DRIVER_SUPPORT) && vq->vq_dev->role == VIRTIO_DEV_DRIVER) {
vring_used_event(&vq->vq_ring) =
vq->vq_used_cons_idx + ndesc;
VRING_FLUSH(&vring_used_event(&vq->vq_ring),
sizeof(vring_used_event(&vq->vq_ring)));
}
if (VIRTIO_DEVICE_SUPPORT && vq->vq_dev->role == VIRTIO_DEV_DEVICE) {
if (VIRTIO_ENABLED(VIRTIO_DEVICE_SUPPORT) && vq->vq_dev->role == VIRTIO_DEV_DEVICE) {
vring_avail_event(&vq->vq_ring) =
vq->vq_available_idx + ndesc;
VRING_FLUSH(&vring_avail_event(&vq->vq_ring),
sizeof(vring_avail_event(&vq->vq_ring)));
}
} else {
if (VIRTIO_DRIVER_SUPPORT && vq->vq_dev->role == VIRTIO_DEV_DRIVER) {
if (VIRTIO_ENABLED(VIRTIO_DRIVER_SUPPORT) && vq->vq_dev->role == VIRTIO_DEV_DRIVER) {
vq->vq_ring.avail->flags &= ~VRING_AVAIL_F_NO_INTERRUPT;
VRING_FLUSH(&vq->vq_ring.avail->flags,
sizeof(vq->vq_ring.avail->flags));
}
if (VIRTIO_DEVICE_SUPPORT && vq->vq_dev->role == VIRTIO_DEV_DEVICE) {
if (VIRTIO_ENABLED(VIRTIO_DEVICE_SUPPORT) && vq->vq_dev->role == VIRTIO_DEV_DEVICE) {
vq->vq_ring.used->flags &= ~VRING_USED_F_NO_NOTIFY;
VRING_FLUSH(&vq->vq_ring.used->flags,
sizeof(vq->vq_ring.used->flags));
@@ -574,12 +574,12 @@ static int vq_ring_enable_interrupt(struct virtqueue *vq, uint16_t ndesc)
* since we last checked. Let our caller know so it processes the new
* entries.
*/
if (VIRTIO_DRIVER_SUPPORT && vq->vq_dev->role == VIRTIO_DEV_DRIVER) {
if (VIRTIO_ENABLED(VIRTIO_DRIVER_SUPPORT) && vq->vq_dev->role == VIRTIO_DEV_DRIVER) {
if (virtqueue_nused(vq) > ndesc) {
return 1;
}
}
if (VIRTIO_DEVICE_SUPPORT && vq->vq_dev->role == VIRTIO_DEV_DEVICE) {
if (VIRTIO_ENABLED(VIRTIO_DEVICE_SUPPORT) && vq->vq_dev->role == VIRTIO_DEV_DEVICE) {
if (virtqueue_navail(vq) > ndesc) {
return 1;
}
@@ -610,7 +610,7 @@ static int vq_ring_must_notify(struct virtqueue *vq)
uint16_t new_idx, prev_idx, event_idx;
if (vq->vq_dev->features & VIRTIO_RING_F_EVENT_IDX) {
if (VIRTIO_DRIVER_SUPPORT && vq->vq_dev->role == VIRTIO_DEV_DRIVER) {
if (VIRTIO_ENABLED(VIRTIO_DRIVER_SUPPORT) && vq->vq_dev->role == VIRTIO_DEV_DRIVER) {
/* CACHE: no need to invalidate avail */
new_idx = vq->vq_ring.avail->idx;
prev_idx = new_idx - vq->vq_queued_cnt;
@@ -620,7 +620,7 @@ static int vq_ring_must_notify(struct virtqueue *vq)
return vring_need_event(event_idx, new_idx,
prev_idx) != 0;
}
if (VIRTIO_DEVICE_SUPPORT && vq->vq_dev->role == VIRTIO_DEV_DEVICE) {
if (VIRTIO_ENABLED(VIRTIO_DEVICE_SUPPORT) && vq->vq_dev->role == VIRTIO_DEV_DEVICE) {
/* CACHE: no need to invalidate used */
new_idx = vq->vq_ring.used->idx;
prev_idx = new_idx - vq->vq_queued_cnt;
@@ -631,13 +631,13 @@ static int vq_ring_must_notify(struct virtqueue *vq)
prev_idx) != 0;
}
} else {
if (VIRTIO_DRIVER_SUPPORT && vq->vq_dev->role == VIRTIO_DEV_DRIVER) {
if (VIRTIO_ENABLED(VIRTIO_DRIVER_SUPPORT) && vq->vq_dev->role == VIRTIO_DEV_DRIVER) {
VRING_INVALIDATE(&vq->vq_ring.used->flags,
sizeof(vq->vq_ring.used->flags));
return (vq->vq_ring.used->flags &
VRING_USED_F_NO_NOTIFY) == 0;
}
if (VIRTIO_DEVICE_SUPPORT && vq->vq_dev->role == VIRTIO_DEV_DEVICE) {
if (VIRTIO_ENABLED(VIRTIO_DEVICE_SUPPORT) && vq->vq_dev->role == VIRTIO_DEV_DEVICE) {
VRING_INVALIDATE(&vq->vq_ring.avail->flags,
sizeof(vq->vq_ring.avail->flags));
return (vq->vq_ring.avail->flags &