[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f969f5e1-ac1a-dbef-5838-9b197934a04d@sberdevices.ru>
Date: Fri, 3 Jun 2022 05:41:07 +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>,
Paolo Abeni <pabeni@...hat.com>,
Jakub Kicinski <kuba@...nel.org>
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 6/8] virtio/vsock: enable zerocopy callback
This adds zerocopy callback for virtio transport.
Signed-off-by: Arseniy Krasnov <AVKrasnov@...rdevices.ru>
---
net/vmw_vsock/virtio_transport.c | 43 ++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
diff --git a/net/vmw_vsock/virtio_transport.c b/net/vmw_vsock/virtio_transport.c
index 19909c1e9ba3..2e05b01caa94 100644
--- a/net/vmw_vsock/virtio_transport.c
+++ b/net/vmw_vsock/virtio_transport.c
@@ -64,6 +64,7 @@ struct virtio_vsock {
u32 guest_cid;
bool seqpacket_allow;
+ bool zerocopy_rx_on;
};
static u32 virtio_transport_get_local_cid(void)
@@ -455,6 +456,45 @@ static void virtio_vsock_rx_done(struct virtqueue *vq)
static bool virtio_transport_seqpacket_allow(u32 remote_cid);
+static int
+virtio_transport_zerocopy_set(struct vsock_sock *vsk, bool enable)
+{
+ struct virtio_vsock *vsock;
+
+ rcu_read_lock();
+ vsock = rcu_dereference(the_virtio_vsock);
+
+ if (!vsock) {
+ rcu_read_unlock();
+ return -ENODEV;
+ }
+
+ vsock->zerocopy_rx_on = enable;
+ rcu_read_unlock();
+
+ return 0;
+}
+
+static int
+virtio_transport_zerocopy_get(struct vsock_sock *vsk)
+{
+ struct virtio_vsock *vsock;
+ bool res;
+
+ rcu_read_lock();
+ vsock = rcu_dereference(the_virtio_vsock);
+
+ if (!vsock) {
+ rcu_read_unlock();
+ return -ENODEV;
+ }
+
+ res = vsock->zerocopy_rx_on;
+ rcu_read_unlock();
+
+ return res;
+}
+
static struct virtio_transport virtio_transport = {
.transport = {
.module = THIS_MODULE,
@@ -480,6 +520,9 @@ static struct virtio_transport virtio_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 = virtio_transport_zerocopy_set,
+ .rx_zerocopy_get = virtio_transport_zerocopy_get,
.seqpacket_dequeue = virtio_transport_seqpacket_dequeue,
.seqpacket_enqueue = virtio_transport_seqpacket_enqueue,
--
2.25.1
Powered by blists - more mailing lists