Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2589647rwd; Mon, 22 May 2023 00:52:06 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6KKGBBw0SoTwfKF0NOkkPczlUaKdAFDItHwHvOUoMAi4kFAmT4lJxJH6mSIcZ+mRXurlDv X-Received: by 2002:a17:90b:3847:b0:250:ca46:dfe1 with SMTP id nl7-20020a17090b384700b00250ca46dfe1mr8533245pjb.48.1684741926199; Mon, 22 May 2023 00:52:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684741926; cv=none; d=google.com; s=arc-20160816; b=SKDXOn8Qdk753U6YwXn/6OHGKhB2ycRfEHWRtcC7QVoSKQw/nvEG4D+7DMy3cDpbQP JoemjGIBOTQMj+4OaHlNvZI1A07XVhe1mBg39X66Nc4fkZBraxNwYKq0JgIewTCxlgk0 J1ehHs271ZyLMKBvei+A6sn6T4hlVuqlif/aPfNEokhgdKOBUHeCWGqZrsUEnC/clI1c HCDpHZU0VrVzqhSrUsZE8hOSDumRn2SRzG3CRU9KjR+D5XPUxisavnrHlCpOzyaFhJGz mCh9ejU0chX/t2dEON51NepZvx4Wv1NctJN9Y97wdQBLhjuiMtULBpBeTKHvsPvM/Il9 BnDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=B6LHD0ddTDQ3vaHpouYR+VjbT71Q46Di1RjaF1nYxV8=; b=JCydYUQMmgmXXCQSzEw6rASivoXTtcmvLAHlsRQE/3kO0XhS45HYvPCBo6B9AfKmQH +eZjVx7bycerQP1qHIZOPWuilJQBKXYFSwbUiCyaiqJwe0V3QymRKMNWzEib7LDjObcu MSyKmcpHw38D1SwFeD9YZ77RKdiKTX2INYEnru6OIKhWAAxCBg92zjQRlZg+AX41LSzC iA7rqksBFrKyh9vbzg+2HS8x9QIbY3GfsuFkgAHaI5LVmmGYD4UEX4UpWxg9l0rPla7M WCrDwGHF9b+QDMV+nIkD1JOI3Gt9LKBdcd9yE/0IKRnsc7+HijSi3Qw0YJjNrdBvRWpb MkkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sberdevices.ru header.s=mail header.b=rRGUQqM7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=sberdevices.ru Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nn2-20020a17090b38c200b002532e1993basi2881586pjb.154.2023.05.22.00.51.51; Mon, 22 May 2023 00:52:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@sberdevices.ru header.s=mail header.b=rRGUQqM7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=sberdevices.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232714AbjEVHpL (ORCPT + 99 others); Mon, 22 May 2023 03:45:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232654AbjEVHot (ORCPT ); Mon, 22 May 2023 03:44:49 -0400 Received: from mx.sberdevices.ru (mx.sberdevices.ru [45.89.227.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3E05B9; Mon, 22 May 2023 00:44:48 -0700 (PDT) Received: from s-lin-edge02.sberdevices.ru (localhost [127.0.0.1]) by mx.sberdevices.ru (Postfix) with ESMTP id 4D8595FD4D; Mon, 22 May 2023 10:44:46 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sberdevices.ru; s=mail; t=1684741486; bh=B6LHD0ddTDQ3vaHpouYR+VjbT71Q46Di1RjaF1nYxV8=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; b=rRGUQqM7bsJ+EbfVI4Cc5kzsJ2p6k17C79Los+1oSyECT9wCX+bST/78ejRacLDx0 pB60qo4KoeiUF7JdDj1FRh9PmIbQfP+cFIygIa02qXopUdqZ7eczxJ1oKHWXbrN+yu jgW1SyjArAcePR1C4ZsUYWeRq7ZSxLpAhRS5S5Wadf5dqyk3hN2f+WX5U1RwumtVlV puKm1bNRSKxDgM6iBvBAbrMFSgZg9hcwYCu12o5k89ygnd/tEtw6ujJShYl4jR2Inl hA7T8pxvn/JSLzwFeUdPZHfD9l3JUXb5XifsBnhDk/cDV1DDesrsHrbyC14Jozgw9L IY1bfu1HPPlRw== Received: from S-MS-EXCH01.sberdevices.ru (S-MS-EXCH01.sberdevices.ru [172.16.1.4]) by mx.sberdevices.ru (Postfix) with ESMTP; Mon, 22 May 2023 10:44:46 +0300 (MSK) From: Arseniy Krasnov To: Stefan Hajnoczi , Stefano Garzarella , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , "Michael S. Tsirkin" , Jason Wang , Bobby Eshleman CC: , , , , , , , Arseniy Krasnov Subject: [RFC PATCH v3 03/17] vsock/virtio: support to send non-linear skb Date: Mon, 22 May 2023 10:39:36 +0300 Message-ID: <20230522073950.3574171-4-AVKrasnov@sberdevices.ru> X-Mailer: git-send-email 2.35.0 In-Reply-To: <20230522073950.3574171-1-AVKrasnov@sberdevices.ru> References: <20230522073950.3574171-1-AVKrasnov@sberdevices.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.16.1.6] X-ClientProxiedBy: S-MS-EXCH02.sberdevices.ru (172.16.1.5) To S-MS-EXCH01.sberdevices.ru (172.16.1.4) X-KSMG-Rule-ID: 4 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Status: not scanned, disabled by settings X-KSMG-AntiSpam-Interceptor-Info: not scanned X-KSMG-AntiPhishing: not scanned, disabled by settings X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 1.1.2.30, bases: 2023/05/22 04:49:00 #21364689 X-KSMG-AntiVirus-Status: Clean, skipped X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use pages of non-linear skb as buffers in virtio tx queue. Signed-off-by: Arseniy Krasnov --- net/vmw_vsock/virtio_transport.c | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/net/vmw_vsock/virtio_transport.c b/net/vmw_vsock/virtio_transport.c index e95df847176b..1c269c3f010d 100644 --- a/net/vmw_vsock/virtio_transport.c +++ b/net/vmw_vsock/virtio_transport.c @@ -100,7 +100,9 @@ virtio_transport_send_pkt_work(struct work_struct *work) vq = vsock->vqs[VSOCK_VQ_TX]; for (;;) { - struct scatterlist hdr, buf, *sgs[2]; + /* +1 is for packet header. */ + struct scatterlist *sgs[MAX_SKB_FRAGS + 1]; + struct scatterlist bufs[MAX_SKB_FRAGS + 1]; int ret, in_sg = 0, out_sg = 0; struct sk_buff *skb; bool reply; @@ -111,12 +113,30 @@ virtio_transport_send_pkt_work(struct work_struct *work) virtio_transport_deliver_tap_pkt(skb); reply = virtio_vsock_skb_reply(skb); + sg_init_one(&bufs[0], virtio_vsock_hdr(skb), sizeof(*virtio_vsock_hdr(skb))); + sgs[out_sg++] = &bufs[0]; + + if (skb_is_nonlinear(skb)) { + int i; + + for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { + struct page *data_page = skb_shinfo(skb)->frags[i].bv_page; + + /* We will use 'page_to_virt()' for userspace page here, + * because virtio layer will call 'virt_to_phys()' later + * to fill buffer descriptor. We don't touch memory at + * "virtual" address of this page. + */ + sg_init_one(&bufs[i + 1], + page_to_virt(data_page), PAGE_SIZE); + sgs[out_sg++] = &bufs[i + 1]; + } + } else { + if (skb->len > 0) { + sg_init_one(&bufs[1], skb->data, skb->len); + sgs[out_sg++] = &bufs[1]; + } - sg_init_one(&hdr, virtio_vsock_hdr(skb), sizeof(*virtio_vsock_hdr(skb))); - sgs[out_sg++] = &hdr; - if (skb->len > 0) { - sg_init_one(&buf, skb->data, skb->len); - sgs[out_sg++] = &buf; } ret = virtqueue_add_sgs(vq, sgs, out_sg, in_sg, skb, GFP_KERNEL); -- 2.25.1