Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1007431ybt; Fri, 19 Jun 2020 21:24:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxdSdoPlhNyQ6U8g2apLoD0v+Ts2lZJtPoJuZlXrwxm+91unAo4FdVBD87jD+okNc98ge3p X-Received: by 2002:a17:906:16d3:: with SMTP id t19mr6284849ejd.297.1592627089127; Fri, 19 Jun 2020 21:24:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592627089; cv=none; d=google.com; s=arc-20160816; b=NxQzkQh2nusG5btzVGu5kuuqVkjKi0MCw8WeGkAF+ZLrl6ELOQGwW/hpRAIXSsMAhM ragLbkY54O6znb2bZucpMLWAtWi2yn/JtxwsMSuEy00lismo3cArp260tOClLGtIamN1 iuGk/bcHXBrSg7/ntDftt0WzGwXGHljmZHuASnp2o6ibEA65xqhk10yRsn5QxRrjM15n M+e1v8P66bsDAvJnUsP+ALmYNR+Yoib0dPtXGtLppmDlzlrszF01BUZr6Tniggi4ZVzN RfD8/6XCimVIwE8xkaJqdko4kJODTVOQuPkBQ3W77ebGIqK6nIgCFU43DtmQ58+5vbHh nTAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=jyGq6komk0fYvUmbv+TQR+iV83L9rQMuuJZlKEm5NNc=; b=GumplvUmXSUujiingca4x1tR+M+EdXMavEFdd1NxKzzk/Je/s6eRTeDwcIwcLP+MUf zk1Y4FrcSnOVRdC+JZkw6lvc2Qyis3MtHU2IfXZkB7uT1kPi5sgvl+rwruhTXfdSZrCj 5UQUovxPbdutJf/F7GEhYPAzfXKodGMIsgsuVEV7Gzqs1WtnEdwjsN1vPwZgd4jMjSox xPVQi/r/5Eqe9zV7l9r2bwcvpczn3y+4xE9USKnWy0OKoVqPz7y0ZE/7QeUshV363+Xf uu/iB+RldfvGqP1FAgZBBFJoFQVLHXfly0+u8RtD2VSHmpszcA+0dPDzfB44V/Oz+IU5 Q6rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=itC13VNr; 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 c18si5229657edt.202.2020.06.19.21.24.27; Fri, 19 Jun 2020 21:24:49 -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=itC13VNr; 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 S2395061AbgFSSZJ (ORCPT + 99 others); Fri, 19 Jun 2020 14:25:09 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:50957 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2392215AbgFSSXZ (ORCPT ); Fri, 19 Jun 2020 14:23:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592591003; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jyGq6komk0fYvUmbv+TQR+iV83L9rQMuuJZlKEm5NNc=; b=itC13VNrqgupDPOmR+U2+TE7VbTLyvpTRzM5V1F7frnzHzGYowub1tcdDVwDNdZEbvpjuj e1O+pZYJuZa9oz2I2HwNPMvalifi54gEQYQRMj/Y3rukFLfNZvZ7GObjidGL0jS6cjSHXR 5bleDTrF8DFr6hZwxDufFesqGMvgt1s= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-299-kXtmFMfGNluBxE8Al5UWBw-1; Fri, 19 Jun 2020 14:23:21 -0400 X-MC-Unique: kXtmFMfGNluBxE8Al5UWBw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0DE79835B8B; Fri, 19 Jun 2020 18:23:20 +0000 (UTC) Received: from eperezma.remote.csb (ovpn-113-14.ams2.redhat.com [10.36.113.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1C2107C1E2; Fri, 19 Jun 2020 18:23:17 +0000 (UTC) From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: mst@redhat.com Cc: kvm list , Stefano Garzarella , virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Stefan Hajnoczi , Jason Wang Subject: [RFC v9 03/11] vhost/net: pass net specific struct pointer Date: Fri, 19 Jun 2020 20:22:54 +0200 Message-Id: <20200619182302.850-4-eperezma@redhat.com> In-Reply-To: <20200619182302.850-1-eperezma@redhat.com> References: <20200619182302.850-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Michael S. Tsirkin" 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 Signed-off-by: Eugenio PĂ©rez --- 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 e992decfec53..81900ce673b4 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].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(); } @@ -1526,7 +1526,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); -- 2.18.1