mirror of
https://passt.top/passt
synced 2025-01-21 11:45:15 +00:00
vhost-user: Pass vu_dev to more virtio functions
vu_dev will be needed to log page update. Add the parameter to: vring_used_write() vu_queue_fill_by_index() vu_queue_fill() vring_used_idx_set() vu_queue_flush() The new parameter is unused for now. Signed-off-by: Laurent Vivier <lvivier@redhat.com> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
parent
b04195c60f
commit
538312af19
32
virtio.c
32
virtio.c
@ -580,28 +580,34 @@ bool vu_queue_rewind(struct vu_virtq *vq, unsigned int num)
|
||||
|
||||
/**
|
||||
* vring_used_write() - Write an entry in the used ring
|
||||
* @dev: Vhost-user device
|
||||
* @vq: Virtqueue
|
||||
* @uelem: Entry to write
|
||||
* @i: Index of the entry in the used ring
|
||||
*/
|
||||
static inline void vring_used_write(struct vu_virtq *vq,
|
||||
static inline void vring_used_write(const struct vu_dev *vdev,
|
||||
struct vu_virtq *vq,
|
||||
const struct vring_used_elem *uelem, int i)
|
||||
{
|
||||
struct vring_used *used = vq->vring.used;
|
||||
|
||||
used->ring[i] = *uelem;
|
||||
(void)vdev;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* vu_queue_fill_by_index() - Update information of a descriptor ring entry
|
||||
* in the used ring
|
||||
* @dev: Vhost-user device
|
||||
* @vq: Virtqueue
|
||||
* @index: Descriptor ring index
|
||||
* @len: Size of the element
|
||||
* @idx: Used ring entry index
|
||||
*/
|
||||
void vu_queue_fill_by_index(struct vu_virtq *vq, unsigned int index,
|
||||
unsigned int len, unsigned int idx)
|
||||
void vu_queue_fill_by_index(const struct vu_dev *vdev, struct vu_virtq *vq,
|
||||
unsigned int index, unsigned int len,
|
||||
unsigned int idx)
|
||||
{
|
||||
struct vring_used_elem uelem;
|
||||
|
||||
@ -612,7 +618,7 @@ void vu_queue_fill_by_index(struct vu_virtq *vq, unsigned int index,
|
||||
|
||||
uelem.id = htole32(index);
|
||||
uelem.len = htole32(len);
|
||||
vring_used_write(vq, &uelem, idx);
|
||||
vring_used_write(vdev, vq, &uelem, idx);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -623,30 +629,36 @@ void vu_queue_fill_by_index(struct vu_virtq *vq, unsigned int index,
|
||||
* @len: Size of the element
|
||||
* @idx: Used ring entry index
|
||||
*/
|
||||
void vu_queue_fill(struct vu_virtq *vq, const struct vu_virtq_element *elem,
|
||||
unsigned int len, unsigned int idx)
|
||||
void vu_queue_fill(const struct vu_dev *vdev, struct vu_virtq *vq,
|
||||
const struct vu_virtq_element *elem, unsigned int len,
|
||||
unsigned int idx)
|
||||
{
|
||||
vu_queue_fill_by_index(vq, elem->index, len, idx);
|
||||
vu_queue_fill_by_index(vdev, vq, elem->index, len, idx);
|
||||
}
|
||||
|
||||
/**
|
||||
* vring_used_idx_set() - Set the descriptor ring current index
|
||||
* @dev: Vhost-user device
|
||||
* @vq: Virtqueue
|
||||
* @val: Value to set in the index
|
||||
*/
|
||||
static inline void vring_used_idx_set(struct vu_virtq *vq, uint16_t val)
|
||||
static inline void vring_used_idx_set(const struct vu_dev *vdev,
|
||||
struct vu_virtq *vq, uint16_t val)
|
||||
{
|
||||
vq->vring.used->idx = htole16(val);
|
||||
(void)vdev;
|
||||
|
||||
vq->used_idx = val;
|
||||
}
|
||||
|
||||
/**
|
||||
* vu_queue_flush() - Flush the virtqueue
|
||||
* @dev: Vhost-user device
|
||||
* @vq: Virtqueue
|
||||
* @count: Number of entry to flush
|
||||
*/
|
||||
void vu_queue_flush(struct vu_virtq *vq, unsigned int count)
|
||||
void vu_queue_flush(const struct vu_dev *vdev, struct vu_virtq *vq,
|
||||
unsigned int count)
|
||||
{
|
||||
uint16_t old, new;
|
||||
|
||||
@ -658,7 +670,7 @@ void vu_queue_flush(struct vu_virtq *vq, unsigned int count)
|
||||
|
||||
old = vq->used_idx;
|
||||
new = old + count;
|
||||
vring_used_idx_set(vq, new);
|
||||
vring_used_idx_set(vdev, vq, new);
|
||||
vq->inuse -= count;
|
||||
if ((uint16_t)(new - vq->signalled_used) < (uint16_t)(new - old))
|
||||
vq->signalled_used_valid = false;
|
||||
|
10
virtio.h
10
virtio.h
@ -177,10 +177,12 @@ int vu_queue_pop(const struct vu_dev *dev, struct vu_virtq *vq,
|
||||
void vu_queue_detach_element(struct vu_virtq *vq);
|
||||
void vu_queue_unpop(struct vu_virtq *vq);
|
||||
bool vu_queue_rewind(struct vu_virtq *vq, unsigned int num);
|
||||
void vu_queue_fill_by_index(struct vu_virtq *vq, unsigned int index,
|
||||
unsigned int len, unsigned int idx);
|
||||
void vu_queue_fill(struct vu_virtq *vq,
|
||||
void vu_queue_fill_by_index(const struct vu_dev *vdev, struct vu_virtq *vq,
|
||||
unsigned int index, unsigned int len,
|
||||
unsigned int idx);
|
||||
void vu_queue_fill(const struct vu_dev *vdev, struct vu_virtq *vq,
|
||||
const struct vu_virtq_element *elem, unsigned int len,
|
||||
unsigned int idx);
|
||||
void vu_queue_flush(struct vu_virtq *vq, unsigned int count);
|
||||
void vu_queue_flush(const struct vu_dev *vdev, struct vu_virtq *vq,
|
||||
unsigned int count);
|
||||
#endif /* VIRTIO_H */
|
||||
|
@ -142,9 +142,9 @@ void vu_flush(const struct vu_dev *vdev, struct vu_virtq *vq,
|
||||
int i;
|
||||
|
||||
for (i = 0; i < elem_cnt; i++)
|
||||
vu_queue_fill(vq, &elem[i], elem[i].in_sg[0].iov_len, i);
|
||||
vu_queue_fill(vdev, vq, &elem[i], elem[i].in_sg[0].iov_len, i);
|
||||
|
||||
vu_queue_flush(vq, elem_cnt);
|
||||
vu_queue_flush(vdev, vq, elem_cnt);
|
||||
vu_queue_notify(vdev, vq);
|
||||
}
|
||||
|
||||
@ -210,8 +210,8 @@ static void vu_handle_tx(struct vu_dev *vdev, int index,
|
||||
int i;
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
vu_queue_fill(vq, &elem[i], 0, i);
|
||||
vu_queue_flush(vq, count);
|
||||
vu_queue_fill(vdev, vq, &elem[i], 0, i);
|
||||
vu_queue_flush(vdev, vq, count);
|
||||
vu_queue_notify(vdev, vq);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user