Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp3678411ybg; Sun, 7 Jun 2020 07:16:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwdR55ESSlmgijc60jfn7HQBkzqAztOHR4sD8+PaCAncKeu2rsOzOGqTSFge5v+dKxV/pKO X-Received: by 2002:a05:6402:2207:: with SMTP id cq7mr15208497edb.186.1591539360034; Sun, 07 Jun 2020 07:16:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591539360; cv=none; d=google.com; s=arc-20160816; b=GHvukzlAd6ZAYZ00S53Q7JfroAM4quigrKHw2l9GsaVi+pPUd82aSmaj8SGbg/JX9p 3tJ+YfsDquu2c5jYLT2XA1z1qg7ZqpLSt2rxEmn4/XAmnIM04vPfvyVSe/BOnBwI2/P3 bYw1v+DK5CxXdSRF44q+MpsdipVgJBOJt4WP8ApWAQsRoo745nb7ylfs5GvUoL3faxKx OC0lSyw5XDXuTb3Dh0rlL9okR7tO4elBc2tXynn56eRn9dRFNrg/wELFrpgrLkmKMVa9 5xMKx//IlTNQsBde/gsx1r6ibq+VNgl8nYsd27D0p2iOGx8Zgpq3HoI4cQlMIofW9qvm 37Sw== 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=VWXM+ipVrzQXYONFpt3zkOQmQtQZ231iT3DOSd7IMMo=; b=O4BP+13fceIit0SRAoV5N0O1sby7/iX6IDaZrFQrDnZi1pLs3Lt5bEuovIxYnkWqs4 PJ+tXAdOjM9UVnpCj2Hw+fmOD6gNmDexbyvAbpuF2S6dYM9/W4VLGePwZQ7gdEWJKpcv zzofybNreHaUtITeZ2Z0YxqAKhMxqs9GS3yxJxTaUtIDJ3msnXQotEVmicbLsF0IHh4G QpJKMOJjGa0OzeqjTuP3NO8bfIt+8GUPxqYoKd8Kb4fM+cmwwsPqtwz64lq3eqeuq0oy /vkjpayhk2RtjXbcnA/eEnIG83uqFpdwKThjstvl7O7UXp88KWPsUbLI7Rxw0gvb3SKA LkwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=H3pdxkqa; 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 y14si7410043edu.550.2020.06.07.07.15.37; Sun, 07 Jun 2020 07:16:00 -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=H3pdxkqa; 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 S1727961AbgFGONF (ORCPT + 99 others); Sun, 7 Jun 2020 10:13:05 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:20049 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726742AbgFGOLl (ORCPT ); Sun, 7 Jun 2020 10:11:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591539100; 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=VWXM+ipVrzQXYONFpt3zkOQmQtQZ231iT3DOSd7IMMo=; b=H3pdxkqa44l0b8TxXpY64UbNfMagHP21i9p33NKHoZbDsyN9h4480ULfO9JS1P7+jxgSap 7KlhZnv+p3YinuEau9cCYari5gFC49/5u96FkI8jBsdTKs0wrw262Q5AegRCqAshgbrls9 lBMN7S4nVlW5N0r+4zRwqX5MTbEjraU= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-321-31YA3-kUO1uUbQugldyHGA-1; Sun, 07 Jun 2020 10:11:37 -0400 X-MC-Unique: 31YA3-kUO1uUbQugldyHGA-1 Received: by mail-wr1-f70.google.com with SMTP id s17so6018687wrt.7 for ; Sun, 07 Jun 2020 07:11:37 -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=VWXM+ipVrzQXYONFpt3zkOQmQtQZ231iT3DOSd7IMMo=; b=JDZCOgr6UPxid64Po7hEdXki3n+YpVRPMySUoTeB9qs1PXyzEVz1TqwaGABJa1EL8m u0vXWb9Sxt4futveYhFyT2gZvLeHIsHC7pok4qJ46rxWc/tt9eKh1z5liTW55Rpr0s8u iQBURY34CEVRehjKODLv1AW0keLcMaYsjvGkU08FdBSWOL0gotHe9/6oIz97JuVYNH2h iz8E1F1peSkK3Q42iRlgTOBzGWEBllR2Zn8N83iEcPY7Od0rcalTTZ2Y+XuSmf6WpMMa D/GCJa2LWcW59OGcsww0u/Dilq214TnYneQJIY+DtITLc4sXvc1AbtLVOpUwosPY4cdH u+1Q== X-Gm-Message-State: AOAM531/iSoOhlDkMpEcg0l97Rxf0xjsGx2YN46Rz8LkQ9til5NBcWkx U3y2JwG8rXJnisW9+OVBnQ8eLlnacb+Q9wfbKhEkP0pP868iFD+Um8AmYI5Pf0HgstsB16B6aDR CSBbIVQeOyzrlSx9xcaBD8ckD X-Received: by 2002:a05:6000:4c:: with SMTP id k12mr18631308wrx.215.1591539096211; Sun, 07 Jun 2020 07:11:36 -0700 (PDT) X-Received: by 2002:a05:6000:4c:: with SMTP id k12mr18631293wrx.215.1591539096029; Sun, 07 Jun 2020 07:11:36 -0700 (PDT) Received: from redhat.com (bzq-82-81-31-23.red.bezeqint.net. [82.81.31.23]) by smtp.gmail.com with ESMTPSA id d2sm20296210wrs.95.2020.06.07.07.11.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Jun 2020 07:11:35 -0700 (PDT) Date: Sun, 7 Jun 2020 10:11:34 -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 Subject: [PATCH RFC v5 05/13] vhost/net: pass net specific struct pointer Message-ID: <20200607141057.704085-6-mst@redhat.com> References: <20200607141057.704085-1-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200607141057.704085-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 In preparation for further cleanup, pass net specific pointer to ubuf callbacks so we can move net specific fields out to net structures. Signed-off-by: Michael S. Tsirkin --- drivers/vhost/net.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c index bf5e1d81ae25..ff594eec8ae3 100644 --- a/drivers/vhost/net.c +++ b/drivers/vhost/net.c @@ -94,7 +94,7 @@ struct vhost_net_ubuf_ref { */ atomic_t refcount; wait_queue_head_t wait; - struct vhost_virtqueue *vq; + struct vhost_net_virtqueue *nvq; }; #define VHOST_NET_BATCH 64 @@ -231,7 +231,7 @@ static void vhost_net_enable_zcopy(int vq) } static struct vhost_net_ubuf_ref * -vhost_net_ubuf_alloc(struct vhost_virtqueue *vq, bool zcopy) +vhost_net_ubuf_alloc(struct vhost_net_virtqueue *nvq, bool zcopy) { struct vhost_net_ubuf_ref *ubufs; /* No zero copy backend? Nothing to count. */ @@ -242,7 +242,7 @@ vhost_net_ubuf_alloc(struct vhost_virtqueue *vq, bool zcopy) return ERR_PTR(-ENOMEM); atomic_set(&ubufs->refcount, 1); init_waitqueue_head(&ubufs->wait); - ubufs->vq = vq; + ubufs->nvq = nvq; return ubufs; } @@ -384,13 +384,13 @@ static void vhost_zerocopy_signal_used(struct vhost_net *net, static void vhost_zerocopy_callback(struct ubuf_info *ubuf, bool success) { struct vhost_net_ubuf_ref *ubufs = ubuf->ctx; - struct vhost_virtqueue *vq = ubufs->vq; + struct vhost_net_virtqueue *nvq = ubufs->nvq; int cnt; rcu_read_lock_bh(); /* set len to mark this desc buffers done DMA */ - vq->heads[ubuf->desc].len = success ? + nvq->vq.heads[ubuf->desc].in_len = success ? VHOST_DMA_DONE_LEN : VHOST_DMA_FAILED_LEN; cnt = vhost_net_ubuf_put(ubufs); @@ -402,7 +402,7 @@ static void vhost_zerocopy_callback(struct ubuf_info *ubuf, bool success) * less than 10% of times). */ if (cnt <= 1 || !(cnt % 16)) - vhost_poll_queue(&vq->poll); + vhost_poll_queue(&nvq->vq.poll); rcu_read_unlock_bh(); } @@ -1525,7 +1525,7 @@ static long vhost_net_set_backend(struct vhost_net *n, unsigned index, int fd) /* start polling new socket */ oldsock = vhost_vq_get_backend(vq); if (sock != oldsock) { - ubufs = vhost_net_ubuf_alloc(vq, + ubufs = vhost_net_ubuf_alloc(nvq, sock && vhost_sock_zcopy(sock)); if (IS_ERR(ubufs)) { r = PTR_ERR(ubufs); -- MST