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 3B514C433FE for ; Thu, 20 Oct 2022 04:27:13 +0000 (UTC) Received: from localhost ([::1]:34346 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olN9E-0002Oy-93 for qemu-devel@archiver.kernel.org; Thu, 20 Oct 2022 00:27:12 -0400 Received: from [::1] (port=44162 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olN9E-00016u-4c for qemu-devel@archiver.kernel.org; Thu, 20 Oct 2022 00:27:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35630) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1olN5L-0006Wo-Uk for qemu-devel@nongnu.org; Thu, 20 Oct 2022 00:23:19 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:20989) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1olN5J-0002s9-Vy for qemu-devel@nongnu.org; Thu, 20 Oct 2022 00:23:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666239788; 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=ZHTdFhBVfTM5koLYUdvW3kXx9RGJ288B8/L4MH9FyYs=; b=OY6mKef1KPdRjfQGbtA8SDJZTGICSCMzQEiAbA7oIS/Zkz8bcDXs7lsBSHXL0mYWYayRts fIKSL+DthQoNlGBDpAWaOJNoilOMbB7BxFYqGtOUbgHIEsTWHBzcmfn1f3pQ+asHxlhOay 0fmovvxZBR/IhgNAo0o2zMAIs8Hg/AE= Received: from mail-oa1-f69.google.com (mail-oa1-f69.google.com [209.85.160.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-606-VkqyYmCdOt6oPl62xYBd1g-1; Thu, 20 Oct 2022 00:23:07 -0400 X-MC-Unique: VkqyYmCdOt6oPl62xYBd1g-1 Received: by mail-oa1-f69.google.com with SMTP id 586e51a60fabf-13237320c16so9104155fac.16 for ; Wed, 19 Oct 2022 21:23:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=ZHTdFhBVfTM5koLYUdvW3kXx9RGJ288B8/L4MH9FyYs=; b=FNozI4ViUwr6kEc1J5HrzAqNMQs48XJyS+Evle2mnMb4nOf0zu8G2a8ITPnhC4i5wX W4PcPIPBmx05DrZrghbJK+KWc3Pn3+QZxCLJRY0QXcO95JkrTVBLU8PhTS1J20zo1X0w x2pWmIWDfRTUL1KgM5mt8on9emxFsOQTHDu1al+HqyLNkYrEbzEKbxCaXiQ6COCTSELj PD/X6XQi7GXBWp4f8HrByWEAmLFmtUWW8byF6XpWNLR4bgEuUKEoBDo5IJNOgEuznzm6 ZhGcFRtQCeRoUmbchJk/4p+looZAf4UBwzXcYaWTpeAKWwnAj8qf+ktsfZqxI0Qm9GNn Lajw== X-Gm-Message-State: ACrzQf26NimMF1RjRPJnf5vQlL8yZQD9zs0XejSLKMKihN+OY9x0ZBSS p3sAas/g69Ct2R5uxcC+wvd4raWLPkPkHU3PIEUYBloKuLfM+hjyt3Erjnvhp7uf559PUtMrb6A QFSKgZECZZ0OQsif25e14rSrEa1aXiPY= X-Received: by 2002:a05:6808:1483:b0:354:a36e:5b with SMTP id e3-20020a056808148300b00354a36e005bmr20059239oiw.35.1666239781833; Wed, 19 Oct 2022 21:23:01 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5GAeLz3wMjZtY94Zrp01tB+AKjmmXh2gd2s0lHokjkqx4s14IGVcRHIEtth8NaHUs8JOUsWFNhj0N3Ij2d1Mo= X-Received: by 2002:a05:6808:1483:b0:354:a36e:5b with SMTP id e3-20020a056808148300b00354a36e005bmr20059220oiw.35.1666239781638; Wed, 19 Oct 2022 21:23:01 -0700 (PDT) MIME-Version: 1.0 References: <20221019125210.226291-1-eperezma@redhat.com> <20221019125210.226291-3-eperezma@redhat.com> In-Reply-To: <20221019125210.226291-3-eperezma@redhat.com> From: Jason Wang Date: Thu, 20 Oct 2022 12:22:50 +0800 Message-ID: Subject: Re: [RFC PATCH v2 2/8] vdpa: Save emulated features list in vhost_vdpa To: =?UTF-8?Q?Eugenio_P=C3=A9rez?= Cc: qemu-devel@nongnu.org, Zhu Lingshan , Harpreet Singh Anand , Stefano Garzarella , Si-Wei Liu , "Michael S. Tsirkin" , Cindy Lu , Laurent Vivier , Eli Cohen , Liuxiangdong , Parav Pandit , Gautam Dawar 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.256, 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_H2=-0.001, 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" On Wed, Oct 19, 2022 at 8:52 PM Eugenio P=C3=A9rez wr= ote: > > At this moment only _F_LOG is added there. > > However future patches add features that depend on the kind of device. > In particular, only net devices can add VIRTIO_F_GUEST_ANNOUNCE. So > let's allow vhost_vdpa creator to set custom emulated device features. > > Signed-off-by: Eugenio P=C3=A9rez > --- > include/hw/virtio/vhost-vdpa.h | 2 ++ > hw/virtio/vhost-vdpa.c | 8 ++++---- > net/vhost-vdpa.c | 4 ++++ > 3 files changed, 10 insertions(+), 4 deletions(-) > > diff --git a/include/hw/virtio/vhost-vdpa.h b/include/hw/virtio/vhost-vdp= a.h > index 1111d85643..50083e1e3b 100644 > --- a/include/hw/virtio/vhost-vdpa.h > +++ b/include/hw/virtio/vhost-vdpa.h > @@ -31,6 +31,8 @@ typedef struct vhost_vdpa { > bool iotlb_batch_begin_sent; > MemoryListener listener; > struct vhost_vdpa_iova_range iova_range; > + /* VirtIO device features that can be emulated by qemu */ > + uint64_t added_features; Any reason we need a per vhost_vdpa storage for this? Or is there a chance that this field could be different among the devices? Thanks > uint64_t acked_features; > bool shadow_vqs_enabled; > /* IOVA mapping used by the Shadow Virtqueue */ > diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c > index 7468e44b87..ddb5e29288 100644 > --- a/hw/virtio/vhost-vdpa.c > +++ b/hw/virtio/vhost-vdpa.c > @@ -660,8 +660,8 @@ static int vhost_vdpa_set_features(struct vhost_dev *= dev, > > v->acked_features =3D features; > > - /* We must not ack _F_LOG if SVQ is enabled */ > - features &=3D ~BIT_ULL(VHOST_F_LOG_ALL); > + /* Do not ack features emulated by qemu */ > + features &=3D ~v->added_features; > } > > trace_vhost_vdpa_set_features(dev, features); > @@ -1244,8 +1244,8 @@ static int vhost_vdpa_get_features(struct vhost_dev= *dev, > int ret =3D vhost_vdpa_get_dev_features(dev, features); > > if (ret =3D=3D 0 && v->shadow_vqs_enabled) { > - /* Add SVQ logging capabilities */ > - *features |=3D BIT_ULL(VHOST_F_LOG_ALL); > + /* Add emulated capabilities */ > + *features |=3D v->added_features; > } > > return ret; > diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c > index eebf29f5c1..3803452800 100644 > --- a/net/vhost-vdpa.c > +++ b/net/vhost-vdpa.c > @@ -599,6 +599,10 @@ static NetClientState *net_vhost_vdpa_init(NetClient= State *peer, > s->vhost_vdpa.index =3D queue_pair_index; > s->vhost_vdpa.shadow_vqs_enabled =3D svq; > s->vhost_vdpa.iova_tree =3D iova_tree; > + if (svq) { > + /* Add SVQ logging capabilities */ > + s->vhost_vdpa.added_features |=3D BIT_ULL(VHOST_F_LOG_ALL); > + } > if (!is_datapath) { > s->cvq_cmd_out_buffer =3D qemu_memalign(qemu_real_host_page_size= (), > vhost_vdpa_net_cvq_cmd_page_= len()); > -- > 2.31.1 >