Skip to content

Commit 5619003

Browse files
Zhu Lingshanmstsirkin
authored andcommitted
vDPA/ifcvf: get_config_size should return dev specific config size
get_config_size() should return the size based on the decected device type. Signed-off-by: Zhu Lingshan <[email protected]> Reviewed-by: Stefano Garzarella <[email protected]> Acked-by: Jason Wang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Michael S. Tsirkin <[email protected]>
1 parent 6ad31d1 commit 5619003

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

drivers/vdpa/ifcvf/ifcvf_main.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,24 @@ static u32 ifcvf_vdpa_get_vq_align(struct vdpa_device *vdpa_dev)
356356

357357
static size_t ifcvf_vdpa_get_config_size(struct vdpa_device *vdpa_dev)
358358
{
359-
return sizeof(struct virtio_net_config);
359+
struct ifcvf_adapter *adapter = vdpa_to_adapter(vdpa_dev);
360+
struct ifcvf_hw *vf = vdpa_to_vf(vdpa_dev);
361+
struct pci_dev *pdev = adapter->pdev;
362+
size_t size;
363+
364+
switch (vf->dev_type) {
365+
case VIRTIO_ID_NET:
366+
size = sizeof(struct virtio_net_config);
367+
break;
368+
case VIRTIO_ID_BLOCK:
369+
size = sizeof(struct virtio_blk_config);
370+
break;
371+
default:
372+
size = 0;
373+
IFCVF_ERR(pdev, "VIRTIO ID %u not supported\n", vf->dev_type);
374+
}
375+
376+
return size;
360377
}
361378

362379
static void ifcvf_vdpa_get_config(struct vdpa_device *vdpa_dev,

0 commit comments

Comments
 (0)