Skip to content

Commit

Permalink
[VirtIO] Define and use VQ_ADD_BUFFER_SUCCESS
Browse files Browse the repository at this point in the history
Define VQ_ADD_BUFFER_SUCCESS in VirtIO\virtio_ring.h
Update return code on success in virtqueue_add_buf() routines to use
VQ_ADD_BUFFER_SUCCESS. These are:
virtqueue_add_buf_split() in VirtIO\VirtIORing.c
virtqueue_add_buf_packed() in VirtIO\VirtIORing-Packed.c

Signed-off-by: benyamin-codez <115509179+benyamin-codez@users.noreply.github.com>
  • Loading branch information
benyamin-codez authored and vrozenfe committed Oct 14, 2024
1 parent c9ed8eb commit 51b3e5b
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion VirtIO/VirtIORing-Packed.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ static int virtqueue_add_buf_packed(
DPrintf(5, "Added buffer head @%i+%d to Q%d\n", head, descs_used, vq->vq.index);
}

return 0;
return VQ_ADD_BUFFER_SUCCESS;
}

static void detach_buf_packed(struct virtqueue_packed *vq, unsigned int id)
Expand Down
2 changes: 1 addition & 1 deletion VirtIO/VirtIORing.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ static int virtqueue_add_buf_split(
vring->avail->idx = ++vq->master_vring_avail.idx;
vq->num_added_since_kick++;

return 0;
return VQ_ADD_BUFFER_SUCCESS;
}

/* Gets the opaque pointer associated with a returned buffer, or NULL if no buffer is available */
Expand Down
2 changes: 2 additions & 0 deletions VirtIO/virtio_ring.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
* at the end of the used ring. Guest should ignore the used->flags field. */
#define VIRTIO_RING_F_EVENT_IDX 29

#define VQ_ADD_BUFFER_SUCCESS 0

void vring_transport_features(VirtIODevice *vdev, u64 *features);
unsigned long vring_size(unsigned int num, unsigned long align, bool packed);

Expand Down
3 changes: 1 addition & 2 deletions vioscsi/helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@

#include "osdep.h"
#include "virtio_pci.h"
#include "virtio_ring.h"
#include "vioscsi.h"

#define CHECKBIT(value, nbit) virtio_is_feature_enabled(value, nbit)
Expand All @@ -49,8 +50,6 @@
#define CACHE_LINE_SIZE 64
#define ROUND_TO_CACHE_LINES(Size) (((ULONG_PTR)(Size) + CACHE_LINE_SIZE - 1) & ~(CACHE_LINE_SIZE - 1))

#define VQ_ADD_BUFFER_SUCCESS 0

#include <srbhelper.h>

// Note: SrbGetCdbLength is defined in srbhelper.h
Expand Down

0 comments on commit 51b3e5b

Please sign in to comment.