Re: [PATCH V4 7/7] vDPA/ifcvf: deduce VIRTIO device ID from pdev ids

From
Jason Wang <hidden>
Date
2021-03-17 04:09:02
Also in
kvm, lkml, virtualization
Reply to
Zhu Lingshan, 2021-03-15
在 2021/3/15 下午3:45, Zhu Lingshan 写道:
quoted hunk ↗ jump to hunk
  static u32 ifcvf_vdpa_get_device_id(struct vdpa_device *vdpa_dev)
  {
-	return VIRTIO_ID_NET;
+	struct ifcvf_hw *vf = vdpa_to_vf(vdpa_dev);
+	u32 ret = -EOPNOTSUPP;
+
+	if (ifcvf_probed_virtio_net(vf))
+		ret = VIRTIO_ID_NET;

So the point is to simplify the future extension.

How about simply?

if (device_id>0x1040)
    return devce_id - 0x1040;
else
    return device_id;

Since I don't think you plan to introduce device whose vendor id is not 1AF4 and the subsys vendor/device id is not interesting to vDPA bus.

Thanks

quoted hunk ↗ jump to hunk
+
+	return ret;
  }
  
Thread (15 messages) 15 messages, 2 authors, last reply 2021-03-17
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help