From: Jason Wang <jasowang@redhat.com>
To: Paolo Abeni <pabeni@redhat.com>
Cc: qemu-devel@nongnu.org, Paolo Bonzini <pbonzini@redhat.com>,
Dmitry Fleytman <dmitry.fleytman@gmail.com>,
Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>,
Sriram Yagnaraman <sriram.yagnaraman@ericsson.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
Stefano Garzarella <sgarzare@redhat.com>,
Cornelia Huck <cohuck@redhat.com>,
Luigi Rizzo <lrizzo@google.com>,
Giuseppe Lettieri <g.lettieri@iet.unipi.it>,
Vincenzo Maffione <v.maffione@gmail.com>,
Eric Blake <eblake@redhat.com>,
Markus Armbruster <armbru@redhat.com>
Subject: Re: [PATCH RFC v3 07/13] vhost: add support for negotiating extended features
Date: Tue, 22 Jul 2025 11:32:39 +0800 [thread overview]
Message-ID: <CACGkMEtWOk2o1xRK9XtaXPuWBnd8Yrfk4DVNJZB4kRCZzxWwRQ@mail.gmail.com> (raw)
In-Reply-To: <d3d36eaf7a68813d5f1208ffe6f85b86b654cc24.1752828082.git.pabeni@redhat.com>
On Fri, Jul 18, 2025 at 4:53 PM Paolo Abeni <pabeni@redhat.com> wrote:
>
> Similar to virtio infra, vhost core maintains the features status
> in the full extended format and allows the devices to implement
> extended version of the getter/setter.
>
> Note that 'protocol_features' are not extended: they are only
> used by vhost-user, and the latter device is not going to implement
> extended features soon.
>
> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
> ---
> v2 -> v3:
> - fix compile warning
> - _array -> _ex
>
> v1 -> v2:
> - uint128_t -> uint64_t[]
> - add _ex() variant of features manipulation helpers
> ---
> hw/virtio/vhost.c | 73 +++++++++++++++++++++++++++----
> include/hw/virtio/vhost-backend.h | 6 +++
> include/hw/virtio/vhost.h | 33 ++++++++++++--
> 3 files changed, 100 insertions(+), 12 deletions(-)
>
> diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
> index c30ea1156e..85ae1e4d4c 100644
> --- a/hw/virtio/vhost.c
> +++ b/hw/virtio/vhost.c
> @@ -972,20 +972,34 @@ static int vhost_virtqueue_set_addr(struct vhost_dev *dev,
> static int vhost_dev_set_features(struct vhost_dev *dev,
> bool enable_log)
> {
> - uint64_t features = dev->acked_features;
> + uint64_t features[VIRTIO_FEATURES_DWORDS];
> int r;
> +
> + virtio_features_copy(features, dev->acked_features_ex);
> if (enable_log) {
> - features |= 0x1ULL << VHOST_F_LOG_ALL;
> + virtio_add_feature_ex(features, VHOST_F_LOG_ALL);
> }
> if (!vhost_dev_has_iommu(dev)) {
> - features &= ~(0x1ULL << VIRTIO_F_IOMMU_PLATFORM);
> + virtio_clear_feature_ex(features, VIRTIO_F_IOMMU_PLATFORM);
> }
> if (dev->vhost_ops->vhost_force_iommu) {
> if (dev->vhost_ops->vhost_force_iommu(dev) == true) {
> - features |= 0x1ULL << VIRTIO_F_IOMMU_PLATFORM;
> + virtio_add_feature_ex(features, VIRTIO_F_IOMMU_PLATFORM);
> }
> }
> - r = dev->vhost_ops->vhost_set_features(dev, features);
> +
> + if (virtio_features_use_extended(features) &&
> + !dev->vhost_ops->vhost_set_features_ex) {
> + VHOST_OPS_DEBUG(r, "extended features without device support");
> + r = -EINVAL;
> + goto out;
> + }
> +
> + if (dev->vhost_ops->vhost_set_features_ex) {
> + r = dev->vhost_ops->vhost_set_features_ex(dev, features);
> + } else {
> + r = dev->vhost_ops->vhost_set_features(dev, features[0]);
> + }
> if (r < 0) {
> VHOST_OPS_DEBUG(r, "vhost_set_features failed");
> goto out;
> @@ -1506,12 +1520,27 @@ static void vhost_virtqueue_cleanup(struct vhost_virtqueue *vq)
> }
> }
>
> +static int vhost_dev_get_features(struct vhost_dev *hdev,
> + uint64_t *features)
> +{
> + uint64_t features64;
> + int r;
> +
> + if (hdev->vhost_ops->vhost_get_features_ex) {
> + return hdev->vhost_ops->vhost_get_features_ex(hdev, features);
> + }
> +
> + r = hdev->vhost_ops->vhost_get_features(hdev, &features64);
> + virtio_features_from_u64(features, features64);
> + return r;
> +}
Nit: let's have a vhost_dev_set_features() as well?
Thanks
next prev parent reply other threads:[~2025-07-22 3:33 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-18 8:52 [PATCH RFC v3 00/13] virtio: introduce support for GSO over UDP tunnel Paolo Abeni
2025-07-18 8:52 ` [PATCH RFC v3 01/13] net: bundle all offloads in a single struct Paolo Abeni
2025-07-20 10:31 ` Akihiko Odaki
2025-07-18 8:52 ` [PATCH RFC v3 02/13] linux-headers: Update to Linux ~v6.16-rc5 net-next Paolo Abeni
2025-07-18 8:52 ` [PATCH RFC v3 03/13] virtio: introduce extended features type Paolo Abeni
2025-07-20 10:41 ` Akihiko Odaki
2025-07-21 7:33 ` Paolo Abeni
2025-07-21 7:49 ` Akihiko Odaki
2025-07-21 8:45 ` Paolo Abeni
2025-07-18 8:52 ` [PATCH RFC v3 04/13] virtio: serialize extended features state Paolo Abeni
2025-07-18 15:06 ` Stefano Garzarella
2025-07-20 10:44 ` Akihiko Odaki
2025-07-21 7:51 ` Paolo Abeni
2025-07-21 7:55 ` Akihiko Odaki
2025-07-18 8:52 ` [PATCH RFC v3 05/13] virtio: add support for negotiating extended features Paolo Abeni
2025-07-18 8:52 ` [PATCH RFC v3 06/13] virtio-pci: implement support for " Paolo Abeni
2025-07-22 3:28 ` Jason Wang
2025-07-22 7:37 ` Paolo Abeni
2025-07-23 5:47 ` Jason Wang
2025-07-23 11:21 ` Paolo Abeni
2025-07-18 8:52 ` [PATCH RFC v3 07/13] vhost: add support for negotiating " Paolo Abeni
2025-07-18 14:36 ` Stefano Garzarella
2025-07-21 2:53 ` Lei Yang
2025-07-21 8:21 ` Paolo Abeni
2025-07-21 7:00 ` Paolo Abeni
2025-07-22 3:32 ` Jason Wang [this message]
2025-07-22 16:55 ` Paolo Abeni
2025-07-23 5:56 ` Jason Wang
2025-07-18 8:52 ` [PATCH RFC v3 08/13] qmp: update virtio features map to support " Paolo Abeni
2025-07-18 10:18 ` Stefano Garzarella
2025-07-18 10:23 ` Paolo Abeni
2025-07-18 10:28 ` Stefano Garzarella
2025-07-19 6:57 ` Markus Armbruster
2025-07-21 7:07 ` Paolo Abeni
2025-07-21 7:23 ` Akihiko Odaki
2025-07-21 7:45 ` Stefano Garzarella
2025-07-21 8:04 ` Paolo Abeni
2025-07-18 8:52 ` [PATCH RFC v3 09/13] vhost-backend: implement extended features support Paolo Abeni
2025-07-18 8:52 ` [PATCH RFC v3 10/13] vhost-net: " Paolo Abeni
2025-07-18 13:01 ` Stefano Garzarella
2025-07-18 14:33 ` Paolo Abeni
2025-07-18 8:52 ` [PATCH RFC v3 11/13] virtio-net: " Paolo Abeni
2025-07-18 8:52 ` [PATCH RFC v3 12/13] net: implement tunnel probing Paolo Abeni
2025-07-18 11:17 ` Stefano Garzarella
2025-07-21 8:48 ` Paolo Abeni
2025-07-22 3:50 ` Jason Wang
2025-07-22 7:33 ` Paolo Abeni
2025-07-23 5:47 ` Jason Wang
2025-07-22 4:15 ` Akihiko Odaki
2025-07-18 8:52 ` [PATCH RFC v3 13/13] net: implement UDP tunnel features offloading Paolo Abeni
2025-07-18 13:22 ` Stefano Garzarella
2025-07-18 13:44 ` Paolo Abeni
2025-07-18 13:48 ` Stefano Garzarella
2025-07-18 15:21 ` Stefano Garzarella
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CACGkMEtWOk2o1xRK9XtaXPuWBnd8Yrfk4DVNJZB4kRCZzxWwRQ@mail.gmail.com \
--to=jasowang@redhat.com \
--cc=armbru@redhat.com \
--cc=cohuck@redhat.com \
--cc=dmitry.fleytman@gmail.com \
--cc=eblake@redhat.com \
--cc=g.lettieri@iet.unipi.it \
--cc=lrizzo@google.com \
--cc=mst@redhat.com \
--cc=odaki@rsg.ci.i.u-tokyo.ac.jp \
--cc=pabeni@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=sgarzare@redhat.com \
--cc=sriram.yagnaraman@ericsson.com \
--cc=v.maffione@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).