vdpa_sim: add device id field in vdpasim_dev_attr
authorStefano Garzarella <sgarzare@redhat.com>
Tue, 15 Dec 2020 14:42:45 +0000 (15:42 +0100)
committerMichael S. Tsirkin <mst@redhat.com>
Fri, 18 Dec 2020 21:14:29 +0000 (16:14 -0500)
Remove VDPASIM_DEVICE_ID macro and add 'id' field in vdpasim_dev_attr,
that will be returned by vdpasim_get_device_id().

Use VIRTIO_ID_NET for vDPA-net simulator device id.

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-8-sgarzare@redhat.com
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
drivers/vdpa/vdpa_sim/vdpa_sim.c

index ae295dc57d7db49d11c655c4f924d9705ab40fd8..3a8e57ac7762a4cb394bb455f6b09a8472df5327 100644 (file)
@@ -55,7 +55,6 @@ struct vdpasim_virtqueue {
 
 #define VDPASIM_QUEUE_ALIGN PAGE_SIZE
 #define VDPASIM_QUEUE_MAX 256
-#define VDPASIM_DEVICE_ID 0x1
 #define VDPASIM_VENDOR_ID 0
 #define VDPASIM_VQ_NUM 0x2
 #define VDPASIM_NAME "vdpasim-netdev"
@@ -67,6 +66,7 @@ static u64 vdpasim_features = (1ULL << VIRTIO_F_ANY_LAYOUT) |
 
 struct vdpasim_dev_attr {
        int nvqs;
+       u32 id;
 };
 
 /* State of each vdpasim device */
@@ -546,7 +546,9 @@ static u16 vdpasim_get_vq_num_max(struct vdpa_device *vdpa)
 
 static u32 vdpasim_get_device_id(struct vdpa_device *vdpa)
 {
-       return VDPASIM_DEVICE_ID;
+       struct vdpasim *vdpasim = vdpa_to_sim(vdpa);
+
+       return vdpasim->dev_attr.id;
 }
 
 static u32 vdpasim_get_vendor_id(struct vdpa_device *vdpa)
@@ -729,6 +731,7 @@ static int __init vdpasim_dev_init(void)
 {
        struct vdpasim_dev_attr dev_attr = {};
 
+       dev_attr.id = VIRTIO_ID_NET;
        dev_attr.nvqs = VDPASIM_VQ_NUM;
 
        vdpasim_dev = vdpasim_create(&dev_attr);