From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 53167C001DB for ; Mon, 14 Aug 2023 06:58:22 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qVRWE-0003cg-IK; Mon, 14 Aug 2023 02:57:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qVRVv-0003Yj-9f for qemu-devel@nongnu.org; Mon, 14 Aug 2023 02:57:27 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qVRVq-0005IN-E2 for qemu-devel@nongnu.org; Mon, 14 Aug 2023 02:57:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1691996231; 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=ewHcWrWXeGmFF1T+/duJTsKCXyVL0uZnUQYra8Vz3QI=; b=VtAIXGT4Y55JGXwaTiqdwnPcfh++VqvySG9eXlYxTAXyv8oG1waWNd4qDhw9Fs67c68u6V YckkR24yLMW8Qe/Ea4l0l9BAL6f0FL3NxnCJxnMmpMGmPZGFaYddmT8Ta6pc6wPRY224YR 82yr8MfYP1hqSKWVj2cwuKmZsRDwYjE= Received: from mail-lj1-f197.google.com (mail-lj1-f197.google.com [209.85.208.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-694-LQUyTkmCM-evvrfkAtP6dg-1; Mon, 14 Aug 2023 02:57:09 -0400 X-MC-Unique: LQUyTkmCM-evvrfkAtP6dg-1 Received: by mail-lj1-f197.google.com with SMTP id 38308e7fff4ca-2b9ba719605so41056381fa.0 for ; Sun, 13 Aug 2023 23:57:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691996228; x=1692601028; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ewHcWrWXeGmFF1T+/duJTsKCXyVL0uZnUQYra8Vz3QI=; b=G6bPH0Iayax4oSH2lZ0FSPX1YAKN4b5TiTGutM3d+zVnrjRSZMUWglYpHW6/nAir2h vGvKOSUEyLovrEbW7rWMVwKFgpcrHeWez9CyGbV276JgMxMsBZXdTWdZ3omnovmSRce4 wnYSr6NDGMNfSKiBwLO9wG3OykPL3oYmQ1ybi56iv5SPjpyxtnvWVl4wjkHNIpkgtwpT sVAWm7MxOHND9qTw5qhs/Y+OxkT4W+/8SASuil0dgAuVrVOWxmQhL4syeG6Q9dbEwg57 SqlWjnOUB60qp0Tb+ENmMXlueYZl5zNv6atYLGoWQNWEZ1twxfA19KbMeb7OpvbIuImx CXiA== X-Gm-Message-State: AOJu0YwfruGAzC7SZCG93/lWh9tdDwi3RPom4sYaCeJ0VvKW7xq0gdAx kEpNZS3AKEO9VEr/AuBIhNr/7GW87X1ZYFxYlgEepnm3RVEYNVa6M6cjBLItdPJyyH3O9j2rIit tvtIxMi9tsGChCXZuY4PaSiY9MOHIIOM= X-Received: by 2002:a2e:320c:0:b0:2b9:b9c8:99 with SMTP id y12-20020a2e320c000000b002b9b9c80099mr6602515ljy.22.1691996228289; Sun, 13 Aug 2023 23:57:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE4kGSevbFQGtEhvzvfjNOo05wp5oRvyfxkp4slFp7Ig2IHYCBoHhT87/uREpDoT0F9vjvPTkWyoBIhvGztnck= X-Received: by 2002:a2e:320c:0:b0:2b9:b9c8:99 with SMTP id y12-20020a2e320c000000b002b9b9c80099mr6602498ljy.22.1691996227889; Sun, 13 Aug 2023 23:57:07 -0700 (PDT) MIME-Version: 1.0 References: <20230810153611.3410882-1-eperezma@redhat.com> <20230810153611.3410882-5-eperezma@redhat.com> In-Reply-To: <20230810153611.3410882-5-eperezma@redhat.com> From: Jason Wang Date: Mon, 14 Aug 2023 14:56:56 +0800 Message-ID: Subject: Re: [PATCH v2 4/5] vdpa: move vhost_vdpa_set_vrings_ready to the caller To: =?UTF-8?Q?Eugenio_P=C3=A9rez?= Cc: qemu-devel@nongnu.org, Laurent Vivier , Dragos Tatulea , si-wei.liu@oracle.com, Parav Pandit , Gautam Dawar , Zhu Lingshan , "Michael S. Tsirkin" , Cindy Lu , Harpreet Singh Anand , Stefano Garzarella , Hawkins Jiawei , Shannon Nelson , Lei Yang Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=170.10.133.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org On Thu, Aug 10, 2023 at 11:36=E2=80=AFPM Eugenio P=C3=A9rez wrote: > > Doing that way allows CVQ to be enabled before the dataplane vqs, > restoring the state as MQ or MAC addresses properly in the case of a > migration. > A typo in the subject, should be vhost_vdpa_set_vring_ready. > Signed-off-by: Eugenio P=C3=A9rez > --- > hw/virtio/vdpa-dev.c | 3 +++ > hw/virtio/vhost-vdpa.c | 3 --- > net/vhost-vdpa.c | 57 +++++++++++++++++++++++++++++------------- > 3 files changed, 42 insertions(+), 21 deletions(-) > > diff --git a/hw/virtio/vdpa-dev.c b/hw/virtio/vdpa-dev.c > index 363b625243..f22d5d5bc0 100644 > --- a/hw/virtio/vdpa-dev.c > +++ b/hw/virtio/vdpa-dev.c > @@ -255,6 +255,9 @@ static int vhost_vdpa_device_start(VirtIODevice *vdev= , Error **errp) > error_setg_errno(errp, -ret, "Error starting vhost"); > goto err_guest_notifiers; > } > + for (i =3D 0; i < s->dev.nvqs; ++i) { > + vhost_vdpa_set_vring_ready(&s->vdpa, i); > + } > s->started =3D true; > > /* > diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c > index 0d9975b5b5..8ca2e3800c 100644 > --- a/hw/virtio/vhost-vdpa.c > +++ b/hw/virtio/vhost-vdpa.c > @@ -1297,9 +1297,6 @@ static int vhost_vdpa_dev_start(struct vhost_dev *d= ev, bool started) > if (unlikely(!ok)) { > return -1; > } > - for (int i =3D 0; i < dev->nvqs; ++i) { > - vhost_vdpa_set_vring_ready(v, dev->vq_index + i); > - } > } else { > vhost_vdpa_suspend(dev); > vhost_vdpa_svqs_stop(dev); > diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c > index 9251351b4b..3bf60f9431 100644 > --- a/net/vhost-vdpa.c > +++ b/net/vhost-vdpa.c > @@ -371,6 +371,22 @@ static int vhost_vdpa_net_data_start(NetClientState = *nc) > return 0; > } > > +static int vhost_vdpa_net_data_load(NetClientState *nc) > +{ > + VhostVDPAState *s =3D DO_UPCAST(VhostVDPAState, nc, nc); > + struct vhost_vdpa *v =3D &s->vhost_vdpa; > + bool has_cvq =3D v->dev->vq_index_end % 2; > + > + if (has_cvq) { > + return 0; > + } > + > + for (int i =3D 0; i < v->dev->nvqs; ++i) { > + vhost_vdpa_set_vring_ready(v, i + v->dev->vq_index); > + } > + return 0; > +} > + > static void vhost_vdpa_net_client_stop(NetClientState *nc) > { > VhostVDPAState *s =3D DO_UPCAST(VhostVDPAState, nc, nc); > @@ -393,6 +409,7 @@ static NetClientInfo net_vhost_vdpa_info =3D { > .size =3D sizeof(VhostVDPAState), > .receive =3D vhost_vdpa_receive, > .start =3D vhost_vdpa_net_data_start, > + .load =3D vhost_vdpa_net_data_load, This deserve an independent patch? Thanks > .stop =3D vhost_vdpa_net_client_stop, > .cleanup =3D vhost_vdpa_cleanup, > .has_vnet_hdr =3D vhost_vdpa_has_vnet_hdr, > @@ -974,26 +991,30 @@ static int vhost_vdpa_net_cvq_load(NetClientState *= nc) > > assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_VHOST_VDPA); > > - if (!v->shadow_vqs_enabled) { > - return 0; > - } > + vhost_vdpa_set_vring_ready(v, v->dev->vq_index); > > - n =3D VIRTIO_NET(v->dev->vdev); > - r =3D vhost_vdpa_net_load_mac(s, n); > - if (unlikely(r < 0)) { > - return r; > - } > - r =3D vhost_vdpa_net_load_mq(s, n); > - if (unlikely(r)) { > - return r; > - } > - r =3D vhost_vdpa_net_load_offloads(s, n); > - if (unlikely(r)) { > - return r; > + if (v->shadow_vqs_enabled) { > + n =3D VIRTIO_NET(v->dev->vdev); > + r =3D vhost_vdpa_net_load_mac(s, n); > + if (unlikely(r < 0)) { > + return r; > + } > + r =3D vhost_vdpa_net_load_mq(s, n); > + if (unlikely(r)) { > + return r; > + } > + r =3D vhost_vdpa_net_load_offloads(s, n); > + if (unlikely(r)) { > + return r; > + } > + r =3D vhost_vdpa_net_load_rx(s, n); > + if (unlikely(r)) { > + return r; > + } > } > - r =3D vhost_vdpa_net_load_rx(s, n); > - if (unlikely(r)) { > - return r; > + > + for (int i =3D 0; i < v->dev->vq_index; ++i) { > + vhost_vdpa_set_vring_ready(v, i); > } > > return 0; > -- > 2.39.3 >