vhost: use vhost_desc instead of vhost_log
Now that everyone uses vhost_desc, we can drop vhost_log, simplifying
the code somewhat.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index 9c2e0cb..a5e46c4 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -1040,7 +1040,7 @@ static int get_rx_bufs(struct vhost_virtqueue *vq,
struct vring_used_elem *heads,
int datalen,
unsigned *iovcount,
- struct vhost_log *log,
+ struct vhost_desc *log,
unsigned *log_num,
unsigned int quota)
{
@@ -1115,7 +1115,7 @@ static void handle_rx(struct vhost_net *net)
struct vhost_net_virtqueue *nvq = &net->vqs[VHOST_NET_VQ_RX];
struct vhost_virtqueue *vq = &nvq->vq;
unsigned uninitialized_var(in), log;
- struct vhost_log *vq_log;
+ struct vhost_desc *vq_log;
struct msghdr msg = {
.msg_name = NULL,
.msg_namelen = 0,
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index b5a51b1..2be6319 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -1946,7 +1946,7 @@ static int log_used(struct vhost_virtqueue *vq, u64 used_offset, u64 len)
return 0;
}
-int vhost_log_write(struct vhost_virtqueue *vq, struct vhost_log *log,
+int vhost_log_write(struct vhost_virtqueue *vq, struct vhost_desc *log,
unsigned int log_num, u64 len, struct iovec *iov, int count)
{
int i, r;
@@ -1965,7 +1965,7 @@ int vhost_log_write(struct vhost_virtqueue *vq, struct vhost_log *log,
}
for (i = 0; i < log_num; ++i) {
- u64 l = min(log[i].len, len);
+ u64 l = min((u64)log[i].len, len);
r = log_write(vq->log_base, log[i].addr, l);
if (r < 0)
return r;
@@ -2350,7 +2350,7 @@ static int fetch_descs(struct vhost_virtqueue *vq)
int vhost_get_vq_desc(struct vhost_virtqueue *vq,
struct iovec iov[], unsigned int iov_size,
unsigned int *out_num, unsigned int *in_num,
- struct vhost_log *log, unsigned int *log_num)
+ struct vhost_desc *log, unsigned int *log_num)
{
int ret = fetch_descs(vq);
int i;
@@ -2392,11 +2392,8 @@ int vhost_get_vq_desc(struct vhost_virtqueue *vq,
/* If this is an input descriptor,
* increment that count. */
*in_num += ret;
- if (unlikely(log && ret)) {
- log[*log_num].addr = desc->addr;
- log[*log_num].len = desc->len;
- ++*log_num;
- }
+ if (unlikely(log && ret))
+ log[*log_num++] = *desc;
} else {
/* If it's an output descriptor, they're all supposed
* to come before any input descriptors. */
diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h
index 661088a..2e0f5c9f 100644
--- a/drivers/vhost/vhost.h
+++ b/drivers/vhost/vhost.h
@@ -47,11 +47,6 @@ void vhost_poll_queue(struct vhost_poll *poll);
void vhost_work_flush(struct vhost_dev *dev, struct vhost_work *work);
long vhost_vring_ioctl(struct vhost_dev *d, unsigned int ioctl, void __user *argp);
-struct vhost_log {
- u64 addr;
- u64 len;
-};
-
#define START(node) ((node)->start)
#define LAST(node) ((node)->last)
@@ -149,7 +144,7 @@ struct vhost_virtqueue {
u64 acked_backend_features;
/* Log write descriptors */
void __user *log_base;
- struct vhost_log *log;
+ struct vhost_desc *log;
/* Ring endianness. Defaults to legacy native endianness.
* Set to true when starting a modern virtio device. */
@@ -208,7 +203,7 @@ bool vhost_log_access_ok(struct vhost_dev *);
int vhost_get_vq_desc(struct vhost_virtqueue *,
struct iovec iov[], unsigned int iov_count,
unsigned int *out_num, unsigned int *in_num,
- struct vhost_log *log, unsigned int *log_num);
+ struct vhost_desc *log, unsigned int *log_num);
void vhost_discard_vq_desc(struct vhost_virtqueue *, int n);
int vhost_vq_init_access(struct vhost_virtqueue *);
@@ -224,7 +219,7 @@ void vhost_disable_notify(struct vhost_dev *, struct vhost_virtqueue *);
bool vhost_vq_avail_empty(struct vhost_dev *, struct vhost_virtqueue *);
bool vhost_enable_notify(struct vhost_dev *, struct vhost_virtqueue *);
-int vhost_log_write(struct vhost_virtqueue *vq, struct vhost_log *log,
+int vhost_log_write(struct vhost_virtqueue *vq, struct vhost_desc *log,
unsigned int log_num, u64 len,
struct iovec *iov, int count);
int vq_meta_prefetch(struct vhost_virtqueue *vq);