Skip to content

Commit 26bfea1

Browse files
Zhu Lingshanmstsirkin
authored andcommitted
vDPA/ifcvf: deduce VIRTIO device ID when probe
This commit deduces VIRTIO device ID as device type when probe, then ifcvf_vdpa_get_device_id() can simply return the ID. ifcvf_vdpa_get_features() and ifcvf_vdpa_get_config_size() can work properly based on the device ID. Signed-off-by: Zhu Lingshan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Michael S. Tsirkin <[email protected]> Acked-by: Jason Wang <[email protected]>
1 parent 899c4d1 commit 26bfea1

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

drivers/vdpa/ifcvf/ifcvf_base.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ struct ifcvf_hw {
8484
u32 notify_off_multiplier;
8585
u64 req_features;
8686
u64 hw_features;
87+
u32 dev_type;
8788
struct virtio_pci_common_cfg __iomem *common_cfg;
8889
void __iomem *net_cfg;
8990
struct vring_info vring[IFCVF_MAX_QUEUE_PAIRS * 2];

drivers/vdpa/ifcvf/ifcvf_main.c

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -323,19 +323,9 @@ static u32 ifcvf_vdpa_get_generation(struct vdpa_device *vdpa_dev)
323323

324324
static u32 ifcvf_vdpa_get_device_id(struct vdpa_device *vdpa_dev)
325325
{
326-
struct ifcvf_adapter *adapter = vdpa_to_adapter(vdpa_dev);
327-
struct pci_dev *pdev = adapter->pdev;
328-
u32 ret = -ENODEV;
329-
330-
if (pdev->device < 0x1000 || pdev->device > 0x107f)
331-
return ret;
332-
333-
if (pdev->device < 0x1040)
334-
ret = pdev->subsystem_device;
335-
else
336-
ret = pdev->device - 0x1040;
326+
struct ifcvf_hw *vf = vdpa_to_vf(vdpa_dev);
337327

338-
return ret;
328+
return vf->dev_type;
339329
}
340330

341331
static u32 ifcvf_vdpa_get_vendor_id(struct vdpa_device *vdpa_dev)
@@ -466,6 +456,19 @@ static int ifcvf_probe(struct pci_dev *pdev, const struct pci_device_id *id)
466456
pci_set_drvdata(pdev, adapter);
467457

468458
vf = &adapter->vf;
459+
460+
/* This drirver drives both modern virtio devices and transitional
461+
* devices in modern mode.
462+
* vDPA requires feature bit VIRTIO_F_ACCESS_PLATFORM,
463+
* so legacy devices and transitional devices in legacy
464+
* mode will not work for vDPA, this driver will not
465+
* drive devices with legacy interface.
466+
*/
467+
if (pdev->device < 0x1040)
468+
vf->dev_type = pdev->subsystem_device;
469+
else
470+
vf->dev_type = pdev->device - 0x1040;
471+
469472
vf->base = pcim_iomap_table(pdev);
470473

471474
adapter->pdev = pdev;

0 commit comments

Comments
 (0)