Message ID | 20230323195404.1247326-4-eperezma@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Move ASID test to vhost-vdpa net initialization | expand |
On Fri, Mar 24, 2023 at 3:54 AM Eugenio Pérez <eperezma@redhat.com> wrote: > > This allows to set the features of a vhost-vdpa device from external > subsystems like vhost-net. It is used in subsequent patches to > negotiate features and probe for CVQ ASID isolation. > > Reviewed-by: Stefano Garzarella <sgarzare@redhat.com> > Signed-off-by: Eugenio Pérez <eperezma@redhat.com> Acked-by: Jason Wang <jasowang@redhat.com> Thanks > --- > include/hw/virtio/vhost-vdpa.h | 1 + > hw/virtio/vhost-vdpa.c | 20 +++++++++++++------- > 2 files changed, 14 insertions(+), 7 deletions(-) > > diff --git a/include/hw/virtio/vhost-vdpa.h b/include/hw/virtio/vhost-vdpa.h > index 28de7da91e..a9cb6f3a32 100644 > --- a/include/hw/virtio/vhost-vdpa.h > +++ b/include/hw/virtio/vhost-vdpa.h > @@ -55,6 +55,7 @@ typedef struct vhost_vdpa { > } VhostVDPA; > > void vhost_vdpa_reset_status_fd(int fd); > +int vhost_vdpa_set_dev_features_fd(int fd, uint64_t features); > int vhost_vdpa_get_iova_range(int fd, struct vhost_vdpa_iova_range *iova_range); > > int vhost_vdpa_dma_map(struct vhost_vdpa *v, uint32_t asid, hwaddr iova, > diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c > index 7a2053b8d9..acd5be46a9 100644 > --- a/hw/virtio/vhost-vdpa.c > +++ b/hw/virtio/vhost-vdpa.c > @@ -651,11 +651,22 @@ static int vhost_vdpa_set_mem_table(struct vhost_dev *dev, > return 0; > } > > +int vhost_vdpa_set_dev_features_fd(int fd, uint64_t features) > +{ > + int ret; > + > + ret = vhost_vdpa_call_fd(fd, VHOST_SET_FEATURES, &features); > + if (ret) { > + return ret; > + } > + > + return vhost_vdpa_add_status_fd(fd, VIRTIO_CONFIG_S_FEATURES_OK); > +} > + > static int vhost_vdpa_set_features(struct vhost_dev *dev, > uint64_t features) > { > struct vhost_vdpa *v = dev->opaque; > - int ret; > > if (!vhost_vdpa_first_dev(dev)) { > return 0; > @@ -678,12 +689,7 @@ static int vhost_vdpa_set_features(struct vhost_dev *dev, > } > > trace_vhost_vdpa_set_features(dev, features); > - ret = vhost_vdpa_call(dev, VHOST_SET_FEATURES, &features); > - if (ret) { > - return ret; > - } > - > - return vhost_vdpa_add_status(dev, VIRTIO_CONFIG_S_FEATURES_OK); > + return vhost_vdpa_set_dev_features_fd(vhost_vdpa_dev_fd(dev), features); > } > > static int vhost_vdpa_set_backend_cap(struct vhost_dev *dev) > -- > 2.31.1 >
diff --git a/include/hw/virtio/vhost-vdpa.h b/include/hw/virtio/vhost-vdpa.h index 28de7da91e..a9cb6f3a32 100644 --- a/include/hw/virtio/vhost-vdpa.h +++ b/include/hw/virtio/vhost-vdpa.h @@ -55,6 +55,7 @@ typedef struct vhost_vdpa { } VhostVDPA; void vhost_vdpa_reset_status_fd(int fd); +int vhost_vdpa_set_dev_features_fd(int fd, uint64_t features); int vhost_vdpa_get_iova_range(int fd, struct vhost_vdpa_iova_range *iova_range); int vhost_vdpa_dma_map(struct vhost_vdpa *v, uint32_t asid, hwaddr iova, diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 7a2053b8d9..acd5be46a9 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -651,11 +651,22 @@ static int vhost_vdpa_set_mem_table(struct vhost_dev *dev, return 0; } +int vhost_vdpa_set_dev_features_fd(int fd, uint64_t features) +{ + int ret; + + ret = vhost_vdpa_call_fd(fd, VHOST_SET_FEATURES, &features); + if (ret) { + return ret; + } + + return vhost_vdpa_add_status_fd(fd, VIRTIO_CONFIG_S_FEATURES_OK); +} + static int vhost_vdpa_set_features(struct vhost_dev *dev, uint64_t features) { struct vhost_vdpa *v = dev->opaque; - int ret; if (!vhost_vdpa_first_dev(dev)) { return 0; @@ -678,12 +689,7 @@ static int vhost_vdpa_set_features(struct vhost_dev *dev, } trace_vhost_vdpa_set_features(dev, features); - ret = vhost_vdpa_call(dev, VHOST_SET_FEATURES, &features); - if (ret) { - return ret; - } - - return vhost_vdpa_add_status(dev, VIRTIO_CONFIG_S_FEATURES_OK); + return vhost_vdpa_set_dev_features_fd(vhost_vdpa_dev_fd(dev), features); } static int vhost_vdpa_set_backend_cap(struct vhost_dev *dev)