[dpdk-dev,1/2] net/virtio: support modern device id

Message ID 1472798220-7121-1-git-send-email-jasowang@redhat.com (mailing list archive)
State Superseded, archived
Delegated to: Yuanhan Liu
Headers

Commit Message

Jason Wang Sept. 2, 2016, 6:36 a.m. UTC
  Spec said "The PCI Device ID is calculated by adding 0x1040 to the
Virtio Device ID". So this patch makes pmd can recognize modern virtio
net id.

Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 drivers/net/virtio/virtio_ethdev.c | 1 +
 drivers/net/virtio/virtio_pci.h    | 1 +
 2 files changed, 2 insertions(+)
  

Comments

Thomas Monjalon Sept. 2, 2016, 12:57 p.m. UTC | #1
2016-09-02 14:36, Jason Wang:
> Spec said "The PCI Device ID is calculated by adding 0x1040 to the
> Virtio Device ID". So this patch makes pmd can recognize modern virtio
> net id.

Please could you describe what is a modern virtio-net?

>  #define VIRTIO_PCI_DEVICEID_MIN 0x1000
>  #define VIRTIO_PCI_DEVICEID_MAX 0x103F
> +#define VIRTIO_PCI_MODERN_DEVICEID_NET 0x1041

It doesn't match the sentence above: 1000 + 1040 = 2040

By the way, VIRTIO_PCI_DEVICEID_MAX is not used in the code.
  
Jason Wang Sept. 5, 2016, 6:36 a.m. UTC | #2
On 2016年09月02日 20:57, Thomas Monjalon wrote:
> 2016-09-02 14:36, Jason Wang:
>> Spec said "The PCI Device ID is calculated by adding 0x1040 to the
>> Virtio Device ID". So this patch makes pmd can recognize modern virtio
>> net id.
> Please could you describe what is a modern virtio-net?

I think it means the device that only support virtio 1.0.

>
>>   #define VIRTIO_PCI_DEVICEID_MIN 0x1000
>>   #define VIRTIO_PCI_DEVICEID_MAX 0x103F
>> +#define VIRTIO_PCI_MODERN_DEVICEID_NET 0x1041
> It doesn't match the sentence above: 1000 + 1040 = 2040

According to the spec (5.1.1), Virtio Device id (not pci device id) is 1.

>
> By the way, VIRTIO_PCI_DEVICEID_MAX is not used in the code.
>

Yes, we can remove this.

Thanks
  

Patch

diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index 07d6449..f48e037 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -104,6 +104,7 @@  static int virtio_dev_queue_stats_mapping_set(
  */
 static const struct rte_pci_id pci_id_virtio_map[] = {
 	{ RTE_PCI_DEVICE(VIRTIO_PCI_VENDORID, VIRTIO_PCI_DEVICEID_MIN) },
+	{ RTE_PCI_DEVICE(VIRTIO_PCI_VENDORID, VIRTIO_PCI_MODERN_DEVICEID_NET) },
 	{ .vendor_id = 0, /* sentinel */ },
 };
 
diff --git a/drivers/net/virtio/virtio_pci.h b/drivers/net/virtio/virtio_pci.h
index dd7693f..d3bdfa0 100644
--- a/drivers/net/virtio/virtio_pci.h
+++ b/drivers/net/virtio/virtio_pci.h
@@ -46,6 +46,7 @@  struct virtnet_ctl;
 #define VIRTIO_PCI_VENDORID     0x1AF4
 #define VIRTIO_PCI_DEVICEID_MIN 0x1000
 #define VIRTIO_PCI_DEVICEID_MAX 0x103F
+#define VIRTIO_PCI_MODERN_DEVICEID_NET 0x1041
 
 /* VirtIO ABI version, this must match exactly. */
 #define VIRTIO_PCI_ABI_VERSION 0