[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230423192643.1537470-3-AVKrasnov@sberdevices.ru>
Date: Sun, 23 Apr 2023 22:26:30 +0300
From: Arseniy Krasnov <AVKrasnov@...rdevices.ru>
To: Stefan Hajnoczi <stefanha@...hat.com>,
Stefano Garzarella <sgarzare@...hat.com>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
"Michael S. Tsirkin" <mst@...hat.com>,
Jason Wang <jasowang@...hat.com>,
Bobby Eshleman <bobby.eshleman@...edance.com>
CC: <kvm@...r.kernel.org>, <virtualization@...ts.linux-foundation.org>,
<netdev@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<kernel@...rdevices.ru>, <oxffffaa@...il.com>,
<avkrasnov@...rdevices.ru>,
Arseniy Krasnov <AVKrasnov@...rdevices.ru>
Subject: [RFC PATCH v2 02/15] vhost/vsock: non-linear skb handling support
This adds copying to guest's virtio buffers from non-linear skbs. Such
skbs are created by protocol layer when MSG_ZEROCOPY flags is used.
Signed-off-by: Arseniy Krasnov <AVKrasnov@...rdevices.ru>
---
drivers/vhost/vsock.c | 23 +++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/drivers/vhost/vsock.c b/drivers/vhost/vsock.c
index 6578db78f0ae..1e70aa390e44 100644
--- a/drivers/vhost/vsock.c
+++ b/drivers/vhost/vsock.c
@@ -197,11 +197,20 @@ vhost_transport_do_send_pkt(struct vhost_vsock *vsock,
break;
}
- nbytes = copy_to_iter(skb->data, payload_len, &iov_iter);
- if (nbytes != payload_len) {
- kfree_skb(skb);
- vq_err(vq, "Faulted on copying pkt buf\n");
- break;
+ if (skb_is_nonlinear(skb)) {
+ if (virtio_transport_nl_skb_to_iov(skb, &iov_iter,
+ payload_len,
+ false)) {
+ vq_err(vq, "Faulted on copying pkt buf from page\n");
+ break;
+ }
+ } else {
+ nbytes = copy_to_iter(skb->data, payload_len, &iov_iter);
+ if (nbytes != payload_len) {
+ kfree_skb(skb);
+ vq_err(vq, "Faulted on copying pkt buf\n");
+ break;
+ }
}
/* Deliver to monitoring devices all packets that we
@@ -212,7 +221,9 @@ vhost_transport_do_send_pkt(struct vhost_vsock *vsock,
vhost_add_used(vq, head, sizeof(*hdr) + payload_len);
added = true;
- skb_pull(skb, payload_len);
+ if (!skb_is_nonlinear(skb))
+ skb_pull(skb, payload_len);
+
total_len += payload_len;
/* If we didn't send all the payload we can requeue the packet
--
2.25.1
Powered by blists - more mailing lists