Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Eugenio Pérez and committed by
Michael S. Tsirkin
b63e5c70 9f09fd61

+16
+12
drivers/vhost/vdpa.c
··· 403 403 return 0; 404 404 } 405 405 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 + 406 417 static long vhost_vdpa_set_features(struct vhost_vdpa *v, u64 __user *featurep) 407 418 { 408 419 struct vdpa_device *vdpa = v->vdpa; ··· 753 742 features |= BIT_ULL(VHOST_BACKEND_F_SUSPEND); 754 743 if (vhost_vdpa_can_resume(v)) 755 744 features |= BIT_ULL(VHOST_BACKEND_F_RESUME); 745 + features |= vhost_vdpa_get_backend_features(v); 756 746 if (copy_to_user(featurep, &features, sizeof(features))) 757 747 r = -EFAULT; 758 748 break;
+4
include/linux/vdpa.h
··· 208 208 * @vdev: vdpa device 209 209 * Returns the virtio features support by the 210 210 * device 211 + * @get_backend_features: Get parent-specific backend features (optional) 212 + * Returns the vdpa features supported by the 213 + * device. 211 214 * @set_driver_features: Set virtio features supported by the driver 212 215 * @vdev: vdpa device 213 216 * @features: feature support by the driver ··· 361 358 u32 (*get_vq_align)(struct vdpa_device *vdev); 362 359 u32 (*get_vq_group)(struct vdpa_device *vdev, u16 idx); 363 360 u64 (*get_device_features)(struct vdpa_device *vdev); 361 + u64 (*get_backend_features)(const struct vdpa_device *vdev); 364 362 int (*set_driver_features)(struct vdpa_device *vdev, u64 features); 365 363 u64 (*get_driver_features)(struct vdpa_device *vdev); 366 364 void (*set_config_cb)(struct vdpa_device *vdev,