Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp1232189ybg; Thu, 11 Jun 2020 04:38:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxt3k0PBhuJf9bF4BCvDrdBZVlbnp9/iWQuDwBbwNvM1XaWl7PhDsSLsO59PLKqJ+1KM9VO X-Received: by 2002:a05:6402:8d1:: with SMTP id d17mr6310925edz.38.1591875503827; Thu, 11 Jun 2020 04:38:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591875503; cv=none; d=google.com; s=arc-20160816; b=fMlRTZigihzY8ZOZSggNAeEKIta6080sh0HXCerqmWocyt4XINDPGNNhIKC72jMd/D Sw71HORJdN+76ljRxfQoBxgXFJHSZXpsGmD9oBK2PGPnR9u8Y+x2/YuOmcrJvuwGsvbO 4qnOeSS1zr/35E8/UdT+Imp8mpfwv7XTx8lX1fB9TCtheD9ncx7RxUfruzUO+5wQIBnn NOIu5qn+guMXSz6GYwWXOOpFKjxIkw9WBV4BuGAzA2lzAGNkSjkGHlJjICVcrdRE6eIm nb7FlN+vxhG76H6c597KXfUOFt1ysPiI2cy3gdRjImCak9901f1jloG/iyFcSAMAgkx3 PO1g== 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=TEosg1cbEhe9hhKHYKqZg2N/D89Ri/A+CQJLw8Cq4Bg=; b=Rnjp3gtUOP483MSovjJoe5BgvKWaz+yh4WUXbD8X3lEz7mDs9YuPkYlBeCCoNbvTTS pIqj0iRNS1XOJLuJXTXuHjFy044+D87IWr93T59Se74GzlgDk0LPYRgmcFqrTMQKGced k8WjyYem6wxfmigEbXDUB2SrimlCQlNBI6/TodVvsSQUejZhI9ySgVlqa5ERas6aMrgO j+xpD2BElrny9bNWMrwAIGwUxuyGZObFXhe5n4we74PKHgABQNf1V2UPXaC0fhaAWN+U m63UBbH+I3OvaCn1DoVKSL+hUXfen4sqFtbKHkoDnS1prpLVw8FYDCE2XfuIVmBRt+ye z1JA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SqUOpLX+; 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 gg10si1945297ejb.413.2020.06.11.04.38.00; Thu, 11 Jun 2020 04:38:23 -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=SqUOpLX+; 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 S1728185AbgFKLfI (ORCPT + 99 others); Thu, 11 Jun 2020 07:35:08 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:34442 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728156AbgFKLeq (ORCPT ); Thu, 11 Jun 2020 07:34:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591875284; 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=TEosg1cbEhe9hhKHYKqZg2N/D89Ri/A+CQJLw8Cq4Bg=; b=SqUOpLX+JpIOzz/ldOFYkRyb2CbZe2+IK0b/z5LmwANBnWlEEvTfAyjFFEQigYAnYB6B/I kvMo+Cm6h3yKyZN0cvgfhcrPY7+58TuvN/i4iFADr5bVtq+yVn1Z0a56RrHla7ajZagmMZ 6FvqlCd6kqkat/OzLBeSSjBFY4F2Z7M= 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-38-s9baCZRWNNyNpbrYjA8iEA-1; Thu, 11 Jun 2020 07:34:43 -0400 X-MC-Unique: s9baCZRWNNyNpbrYjA8iEA-1 Received: by mail-wr1-f69.google.com with SMTP id e1so2463388wrm.3 for ; Thu, 11 Jun 2020 04:34:43 -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=TEosg1cbEhe9hhKHYKqZg2N/D89Ri/A+CQJLw8Cq4Bg=; b=l2CUftdp++fCSx9Su0Tm64sQAFcH6kHr515QlmwctdAQg6lxzH6pLWMdZB1V3QYND0 MiEoflBL0WFO7bABEwXGrswsrWwmHzucVt6ZKVrFR804IUkaVc3UQlecw3f4iK7vYSXQ OoKGzXu8KxnWoQda/l9rmVj3jWSDKIrAoQGJEdY6O0NLUwXDLauypuAVtXVS2nx0Sils qmQUInEVJKbSpUxNgCoHknMmbNYn7BVyCQ3BBrkPQIo64uljtVsp5kvq6qlbBqAoInPG uhuczaPhvzGnPOxK/N87Gt2tOuTQ1PTb11/Fj/3H/lK12rqPicEGjZYN/RTWB/3DzwXt ZCcQ== X-Gm-Message-State: AOAM531CXzrGH/4MiRpTO7jsLIWHsL3Re0Zgupb7am2ZRVZ04R3vMuHK yrI0GHP6h58XPOtERA2/63YkKfpitaKy3t7+790IAHRr+9fREt67VOHQLMtXL4bb63d/gtZoj4u EFVYsbaWbCaFAkuUFfjkgQ6XJ X-Received: by 2002:adf:f0d2:: with SMTP id x18mr9034935wro.250.1591875281758; Thu, 11 Jun 2020 04:34:41 -0700 (PDT) X-Received: by 2002:adf:f0d2:: with SMTP id x18mr9034914wro.250.1591875281527; Thu, 11 Jun 2020 04:34:41 -0700 (PDT) Received: from redhat.com (bzq-79-181-55-232.red.bezeqint.net. [79.181.55.232]) by smtp.gmail.com with ESMTPSA id v7sm4245400wre.93.2020.06.11.04.34.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jun 2020 04:34:41 -0700 (PDT) Date: Thu, 11 Jun 2020 07:34:39 -0400 From: "Michael S. Tsirkin" To: linux-kernel@vger.kernel.org Cc: kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, Jason Wang , eperezma@redhat.com, Stefan Hajnoczi , Stefano Garzarella Subject: [PATCH RFC v8 10/11] vhost/vsock: switch to the buf API Message-ID: <20200611113404.17810-11-mst@redhat.com> References: <20200611113404.17810-1-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200611113404.17810-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 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 a483cec31d5c..61c6d3dd2ae3 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