Skip to content

Commit b63e5c7

Browse files
eugpermarmstsirkin
authored andcommitted
vdpa: add get_backend_features vdpa operation
This operation allow vdpa parent to expose its own backend feature bits. Next patches introduce a feature not compatible with all parent drivers: the ability to enable vq after driver_ok. Each parent must declare if it allows it or not. Signed-off-by: Eugenio Pérez <eperezma@redhat.com> Acked-by: Shannon Nelson <shannon.nelson@amd.com> Message-Id: <20230609092127.170673-4-eperezma@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
1 parent 9f09fd6 commit b63e5c7

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

drivers/vhost/vdpa.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,17 @@ static long vhost_vdpa_get_features(struct vhost_vdpa *v, u64 __user *featurep)
403403
return 0;
404404
}
405405

406+
static u64 vhost_vdpa_get_backend_features(const struct vhost_vdpa *v)
407+
{
408+
struct vdpa_device *vdpa = v->vdpa;
409+
const struct vdpa_config_ops *ops = vdpa->config;
410+
411+
if (!ops->get_backend_features)
412+
return 0;
413+
else
414+
return ops->get_backend_features(vdpa);
415+
}
416+
406417
static long vhost_vdpa_set_features(struct vhost_vdpa *v, u64 __user *featurep)
407418
{
408419
struct vdpa_device *vdpa = v->vdpa;
@@ -742,6 +753,7 @@ static long vhost_vdpa_unlocked_ioctl(struct file *filep,
742753
features |= BIT_ULL(VHOST_BACKEND_F_SUSPEND);
743754
if (vhost_vdpa_can_resume(v))
744755
features |= BIT_ULL(VHOST_BACKEND_F_RESUME);
756+
features |= vhost_vdpa_get_backend_features(v);
745757
if (copy_to_user(featurep, &features, sizeof(features)))
746758
r = -EFAULT;
747759
break;

include/linux/vdpa.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,9 @@ struct vdpa_map_file {
208208
* @vdev: vdpa device
209209
* Returns the virtio features support by the
210210
* device
211+
* @get_backend_features: Get parent-specific backend features (optional)
212+
* Returns the vdpa features supported by the
213+
* device.
211214
* @set_driver_features: Set virtio features supported by the driver
212215
* @vdev: vdpa device
213216
* @features: feature support by the driver
@@ -358,6 +361,7 @@ struct vdpa_config_ops {
358361
u32 (*get_vq_align)(struct vdpa_device *vdev);
359362
u32 (*get_vq_group)(struct vdpa_device *vdev, u16 idx);
360363
u64 (*get_device_features)(struct vdpa_device *vdev);
364+
u64 (*get_backend_features)(const struct vdpa_device *vdev);
361365
int (*set_driver_features)(struct vdpa_device *vdev, u64 features);
362366
u64 (*get_driver_features)(struct vdpa_device *vdev);
363367
void (*set_config_cb)(struct vdpa_device *vdev,

0 commit comments

Comments
 (0)