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

Configure Feed

Select the types of activity you want to include in your feed.

vdpa_sim: add supported_features field in vdpasim_dev_attr

Introduce a new VDPASIM_FEATURES macro with the generic features
supported by the vDPA simulator, and VDPASIM_NET_FEATURES macro with
vDPA-net features.

Add 'supported_features' field in vdpasim_dev_attr, to allow devices
to specify their features.

Co-developed-by: Max Gurtovoy <mgurtovoy@nvidia.com>
Signed-off-by: Max Gurtovoy <mgurtovoy@nvidia.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Link: https://lore.kernel.org/r/20201215144256.155342-9-sgarzare@redhat.com
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

authored by

Stefano Garzarella and committed by
Michael S. Tsirkin
011c35ba 2f8f4618

+18 -11
+18 -11
drivers/vdpa/vdpa_sim/vdpa_sim.c
··· 59 59 #define VDPASIM_VQ_NUM 0x2 60 60 #define VDPASIM_NAME "vdpasim-netdev" 61 61 62 - static u64 vdpasim_features = (1ULL << VIRTIO_F_ANY_LAYOUT) | 63 - (1ULL << VIRTIO_F_VERSION_1) | 64 - (1ULL << VIRTIO_F_ACCESS_PLATFORM) | 65 - (1ULL << VIRTIO_NET_F_MAC); 62 + #define VDPASIM_FEATURES ((1ULL << VIRTIO_F_ANY_LAYOUT) | \ 63 + (1ULL << VIRTIO_F_VERSION_1) | \ 64 + (1ULL << VIRTIO_F_ACCESS_PLATFORM)) 65 + 66 + #define VDPASIM_NET_FEATURES (VDPASIM_FEATURES | \ 67 + (1ULL << VIRTIO_NET_F_MAC)) 66 68 67 69 struct vdpasim_dev_attr { 70 + u64 supported_features; 68 71 int nvqs; 69 72 u32 id; 70 73 }; ··· 125 122 { 126 123 struct vdpasim_virtqueue *vq = &vdpasim->vqs[idx]; 127 124 128 - vringh_init_iotlb(&vq->vring, vdpasim_features, 125 + vringh_init_iotlb(&vq->vring, vdpasim->dev_attr.supported_features, 129 126 VDPASIM_QUEUE_MAX, false, 130 127 (struct vring_desc *)(uintptr_t)vq->desc_addr, 131 128 (struct vring_avail *) ··· 134 131 (uintptr_t)vq->device_addr); 135 132 } 136 133 137 - static void vdpasim_vq_reset(struct vdpasim_virtqueue *vq) 134 + static void vdpasim_vq_reset(struct vdpasim *vdpasim, 135 + struct vdpasim_virtqueue *vq) 138 136 { 139 137 vq->ready = false; 140 138 vq->desc_addr = 0; ··· 143 139 vq->device_addr = 0; 144 140 vq->cb = NULL; 145 141 vq->private = NULL; 146 - vringh_init_iotlb(&vq->vring, vdpasim_features, VDPASIM_QUEUE_MAX, 147 - false, NULL, NULL, NULL); 142 + vringh_init_iotlb(&vq->vring, vdpasim->dev_attr.supported_features, 143 + VDPASIM_QUEUE_MAX, false, NULL, NULL, NULL); 148 144 } 149 145 150 146 static void vdpasim_reset(struct vdpasim *vdpasim) ··· 152 148 int i; 153 149 154 150 for (i = 0; i < vdpasim->dev_attr.nvqs; i++) 155 - vdpasim_vq_reset(&vdpasim->vqs[i]); 151 + vdpasim_vq_reset(vdpasim, &vdpasim->vqs[i]); 156 152 157 153 spin_lock(&vdpasim->iommu_lock); 158 154 vhost_iotlb_reset(vdpasim->iommu); ··· 512 508 513 509 static u64 vdpasim_get_features(struct vdpa_device *vdpa) 514 510 { 515 - return vdpasim_features; 511 + struct vdpasim *vdpasim = vdpa_to_sim(vdpa); 512 + 513 + return vdpasim->dev_attr.supported_features; 516 514 } 517 515 518 516 static int vdpasim_set_features(struct vdpa_device *vdpa, u64 features) ··· 526 520 if (!(features & (1ULL << VIRTIO_F_ACCESS_PLATFORM))) 527 521 return -EINVAL; 528 522 529 - vdpasim->features = features & vdpasim_features; 523 + vdpasim->features = features & vdpasim->dev_attr.supported_features; 530 524 531 525 /* We generally only know whether guest is using the legacy interface 532 526 * here, so generally that's the earliest we can set config fields. ··· 738 732 struct vdpasim_dev_attr dev_attr = {}; 739 733 740 734 dev_attr.id = VIRTIO_ID_NET; 735 + dev_attr.supported_features = VDPASIM_NET_FEATURES; 741 736 dev_attr.nvqs = VDPASIM_VQ_NUM; 742 737 743 738 vdpasim_dev = vdpasim_create(&dev_attr);