[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <04c01c03-647c-49c2-bfa3-23fd995ce5bf@sberdevices.ru>
Date: Fri, 3 Jun 2022 05:39:23 +0000
From: Arseniy Krasnov <AVKrasnov@...rdevices.ru>
To: Stefano Garzarella <sgarzare@...hat.com>,
Stefan Hajnoczi <stefanha@...hat.com>,
"Michael S. Tsirkin" <mst@...hat.com>,
Jason Wang <jasowang@...hat.com>,
"David S. Miller" <davem@...emloft.net>,
"Jakub Kicinski" <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>
CC: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"kvm@...r.kernel.org" <kvm@...r.kernel.org>,
"virtualization@...ts.linux-foundation.org"
<virtualization@...ts.linux-foundation.org>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
kernel <kernel@...rdevices.ru>,
Krasnov Arseniy <oxffffaa@...il.com>,
Arseniy Krasnov <AVKrasnov@...rdevices.ru>
Subject: [RFC PATCH v2 5/8] vhost/vsock: enable zerocopy callback
This adds zerocopy callback to vhost transport.
Signed-off-by: Arseniy Krasnov <AVKrasnov@...rdevices.ru>
---
drivers/vhost/vsock.c | 40 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)
diff --git a/drivers/vhost/vsock.c b/drivers/vhost/vsock.c
index 0dc2229f18f7..dcb8182f5ac9 100644
--- a/drivers/vhost/vsock.c
+++ b/drivers/vhost/vsock.c
@@ -481,6 +481,43 @@ static bool vhost_vsock_more_replies(struct vhost_vsock *vsock)
return val < vq->num;
}
+static int vhost_transport_zerocopy_set(struct vsock_sock *vsk, bool enable)
+{
+ struct vhost_vsock *vsock;
+
+ rcu_read_lock();
+ vsock = vhost_vsock_get(vsk->remote_addr.svm_cid);
+
+ if (!vsock) {
+ rcu_read_unlock();
+ return -ENODEV;
+ }
+
+ vsock->zerocopy_rx_on = enable;
+ rcu_read_unlock();
+
+ return 0;
+}
+
+static int vhost_transport_zerocopy_get(struct vsock_sock *vsk)
+{
+ struct vhost_vsock *vsock;
+ bool res;
+
+ rcu_read_lock();
+ vsock = vhost_vsock_get(vsk->remote_addr.svm_cid);
+
+ if (!vsock) {
+ rcu_read_unlock();
+ return -ENODEV;
+ }
+
+ res = vsock->zerocopy_rx_on;
+ rcu_read_unlock();
+
+ return res;
+}
+
static bool vhost_transport_seqpacket_allow(u32 remote_cid);
static struct virtio_transport vhost_transport = {
@@ -508,6 +545,9 @@ static struct virtio_transport vhost_transport = {
.stream_rcvhiwat = virtio_transport_stream_rcvhiwat,
.stream_is_active = virtio_transport_stream_is_active,
.stream_allow = virtio_transport_stream_allow,
+ .zerocopy_dequeue = virtio_transport_zerocopy_dequeue,
+ .rx_zerocopy_set = vhost_transport_zerocopy_set,
+ .rx_zerocopy_get = vhost_transport_zerocopy_get,
.seqpacket_dequeue = virtio_transport_seqpacket_dequeue,
.seqpacket_enqueue = virtio_transport_seqpacket_enqueue,
--
2.25.1
Powered by blists - more mailing lists