Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp1281272ybg; Tue, 2 Jun 2020 06:09:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz6LBDyAGiA4uUAqGvPRJPy0MBtMjX9q35mYoGT8peRFrd4PLwIPqb9vkCQcqaEp9WbbNhX X-Received: by 2002:a17:906:6bc4:: with SMTP id t4mr15092284ejs.354.1591103364751; Tue, 02 Jun 2020 06:09:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591103364; cv=none; d=google.com; s=arc-20160816; b=sakFZtyELWl82AxRAssIFkQbd8Y8nGX91FDqWmRax7ShFS4lIOk9Fq9p7LzxEnRvEM IalDiNN55Ga8D7Wj5RusFTqDZPS0+owg0e5fck8svUifhA4Mqc7fmXdFr8WCZgHxlKM0 RCHERZyOxArNHa1bbgKMhn/FEiBePip84nG7wX9hukr/zlUfzldBWBlgNEN0IuDY7B7y yEzGBxhPtu6SffC/3qNTeVl3vt43NdW+DovL9A43JdGtioR2bfoeMw4MoI56i11Z14Gf e2Ou+bENUYO869V07/wSiUIG2m1vRTQRZtzdYr1d/XXywcUbTYqdfOFaE1UbHKCsLa/F cPzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=nZ+SseV/ZcYFSq4g3IfECGD3NtX/OI1iTKB8+Z0Evh0=; b=jFdw6kUaNZ3BVdo1q0F7kGKNmNNhLXbtyJ9YU88nXpUQ/Mf+fNBfBKmwDWHfHXMN7O nAUy2JwssUU7GiEh+hg8gBk+mQQfobYkIhN9XM+tGhmbDocZKdHTFDNXAsBpbKaFp5+U oAHzAqZh1CefTv12Q1vTKnhfOFl44MwNiPQjz/pT3P8F64WvinbXms/wBE8u1KTQFAp7 Q2yVj7W0xN3Y6I+WIR3qKYp2P5WybQnR3LfJFc+3xeTt4Que/JajGFOMgGiNkWDQ5Fif KWSwipCE8bBwWN8Yd9aRerJVofioEcAADBkGuNKrN5VvZx4GOAzhe/mGdKNlJ7xvuf90 5Yog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=biPIxTPu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jz17si1495332ejb.243.2020.06.02.06.09.01; Tue, 02 Jun 2020 06:09:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=biPIxTPu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728428AbgFBNGe (ORCPT + 99 others); Tue, 2 Jun 2020 09:06:34 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:52510 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728387AbgFBNGa (ORCPT ); Tue, 2 Jun 2020 09:06:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591103188; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=nZ+SseV/ZcYFSq4g3IfECGD3NtX/OI1iTKB8+Z0Evh0=; b=biPIxTPulj+Mwj/HS3qyX3WaGQozZmMwJ+aTzalvG7b7FRnXnmoOE/t48CNl05seFOBC2t anLaraSblUcfi5Dv25QW1C/2ia+q0DjTS6f/I3kjergYpWDm19cWzMGKq+4GAcE04eOZcs Diys2m3/L91ejDQcsjYmFTo+9T0+0ic= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-232-L93uzM88NwWGDXnQrPu0Ow-1; Tue, 02 Jun 2020 09:06:26 -0400 X-MC-Unique: L93uzM88NwWGDXnQrPu0Ow-1 Received: by mail-wr1-f69.google.com with SMTP id w4so1379343wrl.13 for ; Tue, 02 Jun 2020 06:06:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=nZ+SseV/ZcYFSq4g3IfECGD3NtX/OI1iTKB8+Z0Evh0=; b=hKct1GJI6mHxjVZXFkkeMte4Cq3tBnPbzhOupOx8Ud5Nksso8YlgxQwe570P3YgRWS fOQAN53uOTWekwuqveprwqAET17Ak3go+U0ACw4pKhoUI+lQeFJROaS56OMl1wjCr/kn DTOiGqQbiRzcPuZKxbQyrpDE59GjM+3hkkXTp52cbYDGRnyK0f09Vq7pqikktMtSkfQ8 YDkldKfp8HoWZbedBYbvsvkutcyFXgOZSflVaiAd8LpW2YKCopkRhi5txjfiXrrN5a22 gASKjXLpziyp8menCAZTQC1hPlWiYRQQx0dRq7DYXo/jSQEG406XrrR/S5rMzqnGO0Wz MeDQ== X-Gm-Message-State: AOAM53004fmxj5nNRhqg0VbJKX4TPgolyd4UKcEA4zuYP7LbNUCie1kF Zpvqgc+Sv8vzuXbBJ+5I47QIpBNx5y43QSfyOpv2TR5FwpylqLpvxE/4MTVUgZ2jCytcNZV/n9D gCIFuCpnkfpU/Bwbly813HAcM X-Received: by 2002:a5d:6289:: with SMTP id k9mr27798493wru.358.1591103184856; Tue, 02 Jun 2020 06:06:24 -0700 (PDT) X-Received: by 2002:a5d:6289:: with SMTP id k9mr27798483wru.358.1591103184639; Tue, 02 Jun 2020 06:06:24 -0700 (PDT) Received: from redhat.com (bzq-109-64-41-91.red.bezeqint.net. [109.64.41.91]) by smtp.gmail.com with ESMTPSA id o10sm3857545wrj.37.2020.06.02.06.06.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jun 2020 06:06:24 -0700 (PDT) Date: Tue, 2 Jun 2020 09:06:22 -0400 From: "Michael S. Tsirkin" To: linux-kernel@vger.kernel.org Cc: Eugenio =?utf-8?B?UMOpcmV6?= , Jason Wang , kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, Stefan Hajnoczi , Stefano Garzarella Subject: [PATCH RFC 12/13] vhost/vsock: switch to the buf API Message-ID: <20200602130543.578420-13-mst@redhat.com> References: <20200602130543.578420-1-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200602130543.578420-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org A straight-forward conversion. Signed-off-by: Michael S. Tsirkin --- drivers/vhost/vsock.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/drivers/vhost/vsock.c b/drivers/vhost/vsock.c index fb4e944c4d0d..07d1fb340fb4 100644 --- a/drivers/vhost/vsock.c +++ b/drivers/vhost/vsock.c @@ -103,7 +103,8 @@ vhost_transport_do_send_pkt(struct vhost_vsock *vsock, unsigned out, in; size_t nbytes; size_t iov_len, payload_len; - int head; + struct vhost_buf buf; + int ret; spin_lock_bh(&vsock->send_pkt_list_lock); if (list_empty(&vsock->send_pkt_list)) { @@ -117,16 +118,17 @@ vhost_transport_do_send_pkt(struct vhost_vsock *vsock, list_del_init(&pkt->list); spin_unlock_bh(&vsock->send_pkt_list_lock); - head = vhost_get_vq_desc(vq, vq->iov, ARRAY_SIZE(vq->iov), - &out, &in, NULL, NULL); - if (head < 0) { + ret = vhost_get_avail_buf(vq, &buf, + vq->iov, ARRAY_SIZE(vq->iov), + &out, &in, NULL, NULL); + if (ret < 0) { spin_lock_bh(&vsock->send_pkt_list_lock); list_add(&pkt->list, &vsock->send_pkt_list); spin_unlock_bh(&vsock->send_pkt_list_lock); break; } - if (head == vq->num) { + if (!ret) { spin_lock_bh(&vsock->send_pkt_list_lock); list_add(&pkt->list, &vsock->send_pkt_list); spin_unlock_bh(&vsock->send_pkt_list_lock); @@ -186,7 +188,8 @@ vhost_transport_do_send_pkt(struct vhost_vsock *vsock, */ virtio_transport_deliver_tap_pkt(pkt); - vhost_add_used(vq, head, sizeof(pkt->hdr) + payload_len); + buf.in_len = sizeof(pkt->hdr) + payload_len; + vhost_put_used_buf(vq, &buf); added = true; pkt->off += payload_len; @@ -440,7 +443,8 @@ static void vhost_vsock_handle_tx_kick(struct vhost_work *work) struct vhost_vsock *vsock = container_of(vq->dev, struct vhost_vsock, dev); struct virtio_vsock_pkt *pkt; - int head, pkts = 0, total_len = 0; + int ret, pkts = 0, total_len = 0; + struct vhost_buf buf; unsigned int out, in; bool added = false; @@ -461,12 +465,13 @@ static void vhost_vsock_handle_tx_kick(struct vhost_work *work) goto no_more_replies; } - head = vhost_get_vq_desc(vq, vq->iov, ARRAY_SIZE(vq->iov), - &out, &in, NULL, NULL); - if (head < 0) + ret = vhost_get_avail_buf(vq, &buf, + vq->iov, ARRAY_SIZE(vq->iov), + &out, &in, NULL, NULL); + if (ret < 0) break; - if (head == vq->num) { + if (!ret) { if (unlikely(vhost_enable_notify(&vsock->dev, vq))) { vhost_disable_notify(&vsock->dev, vq); continue; @@ -494,7 +499,8 @@ static void vhost_vsock_handle_tx_kick(struct vhost_work *work) virtio_transport_free_pkt(pkt); len += sizeof(pkt->hdr); - vhost_add_used(vq, head, len); + buf.in_len = len; + vhost_put_used_buf(vq, &buf); total_len += len; added = true; } while(likely(!vhost_exceeds_weight(vq, ++pkts, total_len))); -- MST