Skip to contentSkip to conversation

virtio-net: add support for SR-IOV emulation

RFC In review Yui Washizu 3 participants 11 messages Jul 19, 2023 – Sep 15, 2023

lore
Share & tools
lore
#0 lore raw

cover virtio-net: add support for SR-IOV emulation

This patch series is the first step towards enabling
hardware offloading of the L2 packet switching feature on virtio-net device to host machine. We are considering that this hardware offloading enables
the use of high-performance networks in virtual infrastructures,
such as container infrastructures on VMs.

To enable L2 packet switching by SR-IOV VFs, we are considering the following:
- making the guest recognize virtio-net devices as SR-IOV PF devices (archived with this patch series)
- allowing virtio-net devices to connect SR-IOV VFs to the backend networks, leaving the L2 packet switching feature to the management layer like libvirt
- This makes hardware offloading of L2 packet switching possible. For example, when using vDPA devices, it allows the guest
to utilize SR-IOV NIC embedded switch of hosts.

This patch series aims to enable SR-IOV emulation on virtio-net devices. With this series, the guest can identify the virtio-net device as an SR-IOV PF device. The newly added property 'sriov_max_vfs' allows us to enable the SR-IOV feature on the virtio-net device.
Currently, we are unable to specify the properties of a VF created from the guest. The properties are set to their default values.
In the future, we plan to allow users to set the properties.

qemu-system-x86_64 --device virtio-net,sriov_max_vfs=<num>

# when 'sriov_max_vfs' is present, the SR-IOV feature will be automatically enabled
# <num> means the max number of VF on guest

Example commands to create VFs in virtio-net device from the guest:

guest% readlink -f /sys/class/net/eth1/device
/sys/devices/pci0000:00/0000:00:02.0/0000:01:00.0/virtio1
guest% echo "2" > /sys/devices/pci0000:00/0000:00:02.0/0000:01:00.0/sriov_numvfs guest% ip link show
eth0: ....
eth1: ....
eth2: .... #virtual VF created
eth3: .... #virtual VF created

Please note that communication between VF and PF/VF is not possible by this patch series itself.

Yui Washizu (1):
virtio-pci: add SR-IOV capability

 hw/pci/msix.c                  |  8 +++--
 hw/pci/pci.c                   |  4 +++
 hw/virtio/virtio-pci.c         | 62 ++++++++++++++++++++++++++++++----
 include/hw/virtio/virtio-pci.h |  1 +
 4 files changed, 66 insertions(+), 9 deletions(-)
Signature · 1 line
2.39.3
#1 lore raw

RFC 1/1 virtio-pci: add SR-IOV capability

This enables SR-IOV emulation on virtio-pci devices by adding SR-IOV capability It also introduces a newly added property 'sriov_max_vfs'
to enable or disable the SR-IOV feature on the virtio-pci device in guest, as well as to specify the maximum number of VFs that can be created in the guest. Currently only virtio-net is supported.
Also, the vendor ID and device ID remain the same for both the PF and VF, enabling existing guest PF drivers to be used in the VF without any modifications.

---
 hw/pci/msix.c                  |  8 +++--
 hw/pci/pci.c                   |  4 +++
 hw/virtio/virtio-pci.c         | 62 ++++++++++++++++++++++++++++++----
 include/hw/virtio/virtio-pci.h |  1 +
 4 files changed, 66 insertions(+), 9 deletions(-)
hw/pci/msix.c +6 -2
index ab8869d9d0..3b94ce389f 100644
@@ -421,8 +421,12 @@ int msix_init_exclusive_bar(PCIDevice *dev, unsigned short nentries,
         return ret;
     }
 
-    pci_register_bar(dev, bar_nr, PCI_BASE_ADDRESS_SPACE_MEMORY,
-                     &dev->msix_exclusive_bar);
+    if (pci_is_vf(dev)) {
+        pcie_sriov_vf_register_bar(dev, bar_nr, &dev->msix_exclusive_bar);
+    } else {
+        pci_register_bar(dev, bar_nr, PCI_BASE_ADDRESS_SPACE_MEMORY,
+                         &dev->msix_exclusive_bar);
+    }
 
     return 0;
 }
hw/pci/pci.c +4 -0
index e2eb4c3b4a..cbd50b38ea 100644
@@ -2325,6 +2325,10 @@ static void pci_add_option_rom(PCIDevice *pdev, bool is_default_rom,
         return;
     }
 
+    if (pci_is_vf(pdev)) {
+        return;
+    }
+
     if (!pdev->rom_bar) {
         /*
          * Load rom via fw_cfg instead of creating a rom bar,
hw/virtio/virtio-pci.c +55 -7

95 lines not on this page · raw message

include/hw/virtio/virtio-pci.h +1 -0
index ab2051b64b..05ab6ddc3f 100644
@@ -150,6 +150,7 @@ struct VirtIOPCIProxy {
     uint32_t flags;
     bool disable_modern;
     bool ignore_backend_features;
+    uint16_t sriov_max_vfs;
     OnOffAuto disable_legacy;
     /* Transitional device id */
     uint16_t trans_devid;
Signature · 1 line
2.39.3
#2 lore raw

Re: [RFC 1/1] virtio-pci: add SR-IOV capability

Quoted 64 lines · Yui Washizu

This enables SR-IOV emulation on virtio-pci devices by adding SR-IOV capability It also introduces a newly added property 'sriov_max_vfs'
to enable or disable the SR-IOV feature on the virtio-pci device in guest, as well as to specify the maximum number of VFs that can be created in the guest. Currently only virtio-net is supported.
Also, the vendor ID and device ID remain the same for both the PF and VF, enabling existing guest PF drivers to be used in the VF without any modifications.

---
  hw/pci/msix.c                  |  8 +++--
  hw/pci/pci.c                   |  4 +++
  hw/virtio/virtio-pci.c         | 62 ++++++++++++++++++++++++++++++----
  include/hw/virtio/virtio-pci.h |  1 +
  4 files changed, 66 insertions(+), 9 deletions(-)
hw/pci/msix.c +6 -2
index ab8869d9d0..3b94ce389f 100644
@@ -421,8 +421,12 @@ int msix_init_exclusive_bar(PCIDevice *dev, unsigned short nentries,
          return ret;
      }
 
-    pci_register_bar(dev, bar_nr, PCI_BASE_ADDRESS_SPACE_MEMORY,
-                     &dev->msix_exclusive_bar);
+    if (pci_is_vf(dev)) {
+        pcie_sriov_vf_register_bar(dev, bar_nr, &dev->msix_exclusive_bar);
+    } else {
+        pci_register_bar(dev, bar_nr, PCI_BASE_ADDRESS_SPACE_MEMORY,
+                         &dev->msix_exclusive_bar);
+    }
 
      return 0;
  }
hw/pci/pci.c +4 -0
index e2eb4c3b4a..cbd50b38ea 100644
@@ -2325,6 +2325,10 @@ static void pci_add_option_rom(PCIDevice *pdev, bool is_default_rom,
          return;
      }
 
+    if (pci_is_vf(pdev)) {
+        return;
+    }
+
      if (!pdev->rom_bar) {
          /*
           * Load rom via fw_cfg instead of creating a rom bar,
hw/virtio/virtio-pci.c +2 -0
index edbc0daa18..2315c2647a 100644
@@ -49,6 +49,8 @@
   * configuration space */
  #define VIRTIO_PCI_CONFIG_SIZE(dev)     VIRTIO_PCI_CONFIG_OFF(msix_enabled(dev))
 
+#define VIRTIO_MAX_VFS 127
+
  static void virtio_pci_bus_new(VirtioBusState *bus, size_t bus_size,
                                 VirtIOPCIProxy *dev);
  static void virtio_pci_reset(DeviceState *qdev);

hw/virtio/virtio-pci.c static void virtio_pci_pre_plugged(DeviceState *d, Error **errp) · line 1916

Quoted 8 lines
hw/virtio/virtio-pci.c +5 -0
@@ -1907,6 +1909,11 @@ static void virtio_pci_pre_plugged(DeviceState *d, Error **errp)
 
      if (virtio_pci_modern(proxy)) {
          virtio_add_feature(&vdev->host_features, VIRTIO_F_VERSION_1);
+        if (proxy->sriov_max_vfs) {
+            virtio_add_feature(&vdev->host_features, VIRTIO_F_SR_IOV);
+        }
+    } else if (proxy->sriov_max_vfs) {
+        error_setg(errp, "VirtIO PCI modern is required for the use of SR-IOV");

Missing: return;

Quoted 93 lines
hw/virtio/virtio-pci.c +48 -7
      }
 
      virtio_add_feature(&vdev->host_features, VIRTIO_F_BAD_FEATURE);
@@ -2015,22 +2022,62 @@ static void virtio_pci_device_plugged(DeviceState *d, Error **errp)
          virtio_pci_modern_mem_region_map(proxy, &proxy->device, &cap);
          virtio_pci_modern_mem_region_map(proxy, &proxy->notify, &notify.cap);
 
+        if (!pci_is_vf(&proxy->pci_dev) && proxy->sriov_max_vfs) {
+            if (virtio_bus_get_vdev_id(bus) != VIRTIO_ID_NET) {
+                error_setg(errp, "sriov_max_vfs prop is not supported by %s",
+                           proxy->pci_dev.name);
+                return;
+            }
+            if (proxy->sriov_max_vfs > VIRTIO_MAX_VFS) {
+                error_setg(errp, "sriov_max_vfs must be between 0 and %d",
+                           VIRTIO_MAX_VFS);
+                return;
+            }
+
+            pcie_sriov_pf_init(&proxy->pci_dev, PCI_CONFIG_SPACE_SIZE,
+                               proxy->pci_dev.name,
+                               PCI_DEVICE_ID_VIRTIO_10_BASE
+                               + virtio_bus_get_vdev_id(bus),
+                               proxy->sriov_max_vfs, proxy->sriov_max_vfs, 1, 1);
+            if (proxy->flags & VIRTIO_PCI_FLAG_MODERN_PIO_NOTIFY) {
+                pcie_sriov_pf_init_vf_bar(&proxy->pci_dev, proxy->modern_io_bar_idx,
+                                          PCI_BASE_ADDRESS_SPACE_IO, 4);
+            }
+            if (proxy->nvectors) {
+                pcie_sriov_pf_init_vf_bar(&proxy->pci_dev, proxy->msix_bar_idx,
+                                          PCI_BASE_ADDRESS_SPACE_MEMORY, 4 * 1024);
+            }
+            pcie_sriov_pf_init_vf_bar(&proxy->pci_dev, proxy->modern_mem_bar_idx,
+                                      PCI_BASE_ADDRESS_SPACE_MEMORY |
+                                      PCI_BASE_ADDRESS_MEM_PREFETCH |
+                                      PCI_BASE_ADDRESS_MEM_TYPE_64,
+                                      16 * 1024);
+        }
+
          if (modern_pio) {
              memory_region_init(&proxy->io_bar, OBJECT(proxy),
                                 "virtio-pci-io", 0x4);
 
-            pci_register_bar(&proxy->pci_dev, proxy->modern_io_bar_idx,
-                             PCI_BASE_ADDRESS_SPACE_IO, &proxy->io_bar);
+            if (pci_is_vf(&proxy->pci_dev))
+                pcie_sriov_vf_register_bar(&proxy->pci_dev, proxy->modern_io_bar_idx,
+                                           &proxy->io_bar);
+            else
+                pci_register_bar(&proxy->pci_dev, proxy->modern_io_bar_idx,
+                                 PCI_BASE_ADDRESS_SPACE_IO, &proxy->io_bar);
 
              virtio_pci_modern_io_region_map(proxy, &proxy->notify_pio,
                                              &notify_pio.cap);
          }
 
-        pci_register_bar(&proxy->pci_dev, proxy->modern_mem_bar_idx,
-                         PCI_BASE_ADDRESS_SPACE_MEMORY |
-                         PCI_BASE_ADDRESS_MEM_PREFETCH |
-                         PCI_BASE_ADDRESS_MEM_TYPE_64,
-                         &proxy->modern_bar);
+        if (pci_is_vf(&proxy->pci_dev))
+            pcie_sriov_vf_register_bar(&proxy->pci_dev, proxy->modern_mem_bar_idx,
+                                       &proxy->modern_bar);
+        else
+            pci_register_bar(&proxy->pci_dev, proxy->modern_mem_bar_idx,
+                             PCI_BASE_ADDRESS_SPACE_MEMORY |
+                             PCI_BASE_ADDRESS_MEM_PREFETCH |
+                             PCI_BASE_ADDRESS_MEM_TYPE_64,
+                             &proxy->modern_bar);
 
          proxy->config_cap = virtio_pci_add_mem_cap(proxy, &cfg.cap);
          cfg_mask = (void *)(proxy->pci_dev.wmask + proxy->config_cap);
@@ -2298,6 +2345,7 @@ static Property virtio_pci_properties[] = {
                      VIRTIO_PCI_FLAG_INIT_FLR_BIT, true),
      DEFINE_PROP_BIT("aer", VirtIOPCIProxy, flags,
                      VIRTIO_PCI_FLAG_AER_BIT, false),
+    DEFINE_PROP_UINT16("sriov_max_vfs", VirtIOPCIProxy, sriov_max_vfs, 0),
      DEFINE_PROP_END_OF_LIST(),
  };
 
include/hw/virtio/virtio-pci.h +1 -0
index ab2051b64b..05ab6ddc3f 100644
@@ -150,6 +150,7 @@ struct VirtIOPCIProxy {
      uint32_t flags;
      bool disable_modern;
      bool ignore_backend_features;
+    uint16_t sriov_max_vfs;
      OnOffAuto disable_legacy;
      /* Transitional device id */
      uint16_t trans_devid;
#3 lore raw

Re: [RFC 1/1] virtio-pci: add SR-IOV capability

In reply to Yui Washizu
Quoted 111 lines · Yui Washizu

This enables SR-IOV emulation on virtio-pci devices by adding SR-IOV capability It also introduces a newly added property 'sriov_max_vfs'
to enable or disable the SR-IOV feature on the virtio-pci device in guest, as well as to specify the maximum number of VFs that can be created in the guest. Currently only virtio-net is supported.
Also, the vendor ID and device ID remain the same for both the PF and VF, enabling existing guest PF drivers to be used in the VF without any modifications.

---
 hw/pci/msix.c                  |  8 +++--
 hw/pci/pci.c                   |  4 +++
 hw/virtio/virtio-pci.c         | 62 ++++++++++++++++++++++++++++++----
 include/hw/virtio/virtio-pci.h |  1 +
 4 files changed, 66 insertions(+), 9 deletions(-)
hw/pci/msix.c +6 -2
index ab8869d9d0..3b94ce389f 100644
@@ -421,8 +421,12 @@ int msix_init_exclusive_bar(PCIDevice *dev, unsigned short nentries,
         return ret;
     }
 
-    pci_register_bar(dev, bar_nr, PCI_BASE_ADDRESS_SPACE_MEMORY,
-                     &dev->msix_exclusive_bar);
+    if (pci_is_vf(dev)) {
+        pcie_sriov_vf_register_bar(dev, bar_nr, &dev->msix_exclusive_bar);
+    } else {
+        pci_register_bar(dev, bar_nr, PCI_BASE_ADDRESS_SPACE_MEMORY,
+                         &dev->msix_exclusive_bar);
+    }
 
     return 0;
 }
hw/pci/pci.c +4 -0
index e2eb4c3b4a..cbd50b38ea 100644
@@ -2325,6 +2325,10 @@ static void pci_add_option_rom(PCIDevice *pdev, bool is_default_rom,
         return;
     }
 
+    if (pci_is_vf(pdev)) {
+        return;
+    }
+
     if (!pdev->rom_bar) {
         /*
          * Load rom via fw_cfg instead of creating a rom bar,
hw/virtio/virtio-pci.c +38 -0
index edbc0daa18..2315c2647a 100644
@@ -49,6 +49,8 @@
  * configuration space */
 #define VIRTIO_PCI_CONFIG_SIZE(dev)     VIRTIO_PCI_CONFIG_OFF(msix_enabled(dev))
 
+#define VIRTIO_MAX_VFS 127
+
 static void virtio_pci_bus_new(VirtioBusState *bus, size_t bus_size,
                                VirtIOPCIProxy *dev);
 static void virtio_pci_reset(DeviceState *qdev);
@@ -1907,6 +1909,11 @@ static void virtio_pci_pre_plugged(DeviceState *d, Error **errp)
 
     if (virtio_pci_modern(proxy)) {
         virtio_add_feature(&vdev->host_features, VIRTIO_F_VERSION_1);
+        if (proxy->sriov_max_vfs) {
+            virtio_add_feature(&vdev->host_features, VIRTIO_F_SR_IOV);
+        }
+    } else if (proxy->sriov_max_vfs) {
+        error_setg(errp, "VirtIO PCI modern is required for the use of SR-IOV");
     }
 
     virtio_add_feature(&vdev->host_features, VIRTIO_F_BAD_FEATURE);
@@ -2015,22 +2022,62 @@ static void virtio_pci_device_plugged(DeviceState *d, Error **errp)
         virtio_pci_modern_mem_region_map(proxy, &proxy->device, &cap);
         virtio_pci_modern_mem_region_map(proxy, &proxy->notify, &notify.cap);
 
+        if (!pci_is_vf(&proxy->pci_dev) && proxy->sriov_max_vfs) {
+            if (virtio_bus_get_vdev_id(bus) != VIRTIO_ID_NET) {
+                error_setg(errp, "sriov_max_vfs prop is not supported by %s",
+                           proxy->pci_dev.name);
+                return;
+            }
+            if (proxy->sriov_max_vfs > VIRTIO_MAX_VFS) {
+                error_setg(errp, "sriov_max_vfs must be between 0 and %d",
+                           VIRTIO_MAX_VFS);
+                return;
+            }
+
+            pcie_sriov_pf_init(&proxy->pci_dev, PCI_CONFIG_SPACE_SIZE,
+                               proxy->pci_dev.name,
+                               PCI_DEVICE_ID_VIRTIO_10_BASE
+                               + virtio_bus_get_vdev_id(bus),
+                               proxy->sriov_max_vfs, proxy->sriov_max_vfs, 1, 1);
+            if (proxy->flags & VIRTIO_PCI_FLAG_MODERN_PIO_NOTIFY) {
+                pcie_sriov_pf_init_vf_bar(&proxy->pci_dev, proxy->modern_io_bar_idx,
+                                          PCI_BASE_ADDRESS_SPACE_IO, 4);
+            }
+            if (proxy->nvectors) {
+                pcie_sriov_pf_init_vf_bar(&proxy->pci_dev, proxy->msix_bar_idx,
+                                          PCI_BASE_ADDRESS_SPACE_MEMORY, 4 * 1024);
+            }
+            pcie_sriov_pf_init_vf_bar(&proxy->pci_dev, proxy->modern_mem_bar_idx,
+                                      PCI_BASE_ADDRESS_SPACE_MEMORY |
+                                      PCI_BASE_ADDRESS_MEM_PREFETCH |
+                                      PCI_BASE_ADDRESS_MEM_TYPE_64,
+                                      16 * 1024);
+        }

hw/virtio/virtio-pci.c static void virtio_pci_device_plugged(DeviceState *d, Error **errp) · line 2063

Quoted 10 lines
hw/virtio/virtio-pci.c +4 -2
+
         if (modern_pio) {
             memory_region_init(&proxy->io_bar, OBJECT(proxy),
                                "virtio-pci-io", 0x4);
 
-            pci_register_bar(&proxy->pci_dev, proxy->modern_io_bar_idx,
-                             PCI_BASE_ADDRESS_SPACE_IO, &proxy->io_bar);
+            if (pci_is_vf(&proxy->pci_dev))
+                pcie_sriov_vf_register_bar(&proxy->pci_dev, proxy->modern_io_bar_idx,
+                                           &proxy->io_bar);

We probably don't need another memory bar for notification.

Thanks

Quoted 48 lines
hw/virtio/virtio-pci.c +13 -5
+            else
+                pci_register_bar(&proxy->pci_dev, proxy->modern_io_bar_idx,
+                                 PCI_BASE_ADDRESS_SPACE_IO, &proxy->io_bar);
 
             virtio_pci_modern_io_region_map(proxy, &proxy->notify_pio,
                                             &notify_pio.cap);
         }
 
-        pci_register_bar(&proxy->pci_dev, proxy->modern_mem_bar_idx,
-                         PCI_BASE_ADDRESS_SPACE_MEMORY |
-                         PCI_BASE_ADDRESS_MEM_PREFETCH |
-                         PCI_BASE_ADDRESS_MEM_TYPE_64,
-                         &proxy->modern_bar);
+        if (pci_is_vf(&proxy->pci_dev))
+            pcie_sriov_vf_register_bar(&proxy->pci_dev, proxy->modern_mem_bar_idx,
+                                       &proxy->modern_bar);
+        else
+            pci_register_bar(&proxy->pci_dev, proxy->modern_mem_bar_idx,
+                             PCI_BASE_ADDRESS_SPACE_MEMORY |
+                             PCI_BASE_ADDRESS_MEM_PREFETCH |
+                             PCI_BASE_ADDRESS_MEM_TYPE_64,
+                             &proxy->modern_bar);
 
         proxy->config_cap = virtio_pci_add_mem_cap(proxy, &cfg.cap);
         cfg_mask = (void *)(proxy->pci_dev.wmask + proxy->config_cap);
@@ -2298,6 +2345,7 @@ static Property virtio_pci_properties[] = {
                     VIRTIO_PCI_FLAG_INIT_FLR_BIT, true),
     DEFINE_PROP_BIT("aer", VirtIOPCIProxy, flags,
                     VIRTIO_PCI_FLAG_AER_BIT, false),
+    DEFINE_PROP_UINT16("sriov_max_vfs", VirtIOPCIProxy, sriov_max_vfs, 0),
     DEFINE_PROP_END_OF_LIST(),
 };
 
include/hw/virtio/virtio-pci.h +1 -1
index ab2051b64b..05ab6ddc3f 100644
@@ -150,6 +150,7 @@ struct VirtIOPCIProxy {
     uint32_t flags;
     bool disable_modern;
     bool ignore_backend_features;
+    uint16_t sriov_max_vfs;
     OnOffAuto disable_legacy;
     /* Transitional device id */
     uint16_t trans_devid;
--

2.39.3

#4 lore raw
In reply to Yui Washizu
Quoted 7 lines · Yui Washizu

This patch series is the first step towards enabling
hardware offloading of the L2 packet switching feature on virtio-net device to host machine. We are considering that this hardware offloading enables
the use of high-performance networks in virtual infrastructures,
such as container infrastructures on VMs.

Quoted 5 lines

To enable L2 packet switching by SR-IOV VFs, we are considering the following:
- making the guest recognize virtio-net devices as SR-IOV PF devices (archived with this patch series)
- allowing virtio-net devices to connect SR-IOV VFs to the backend networks, leaving the L2 packet switching feature to the management layer like libvirt

Could you please show the qemu command line you want to propose here?

Quoted 3 lines

- This makes hardware offloading of L2 packet switching possible. For example, when using vDPA devices, it allows the guest to utilize SR-IOV NIC embedded switch of hosts.

This would be interesting.

Thanks

Quoted 38 lines

This patch series aims to enable SR-IOV emulation on virtio-net devices. With this series, the guest can identify the virtio-net device as an SR-IOV PF device. The newly added property 'sriov_max_vfs' allows us to enable the SR-IOV feature on the virtio-net device.
Currently, we are unable to specify the properties of a VF created from the guest. The properties are set to their default values.
In the future, we plan to allow users to set the properties.

qemu-system-x86_64 --device virtio-net,sriov_max_vfs=<num>

# when 'sriov_max_vfs' is present, the SR-IOV feature will be automatically enabled
# <num> means the max number of VF on guest

Example commands to create VFs in virtio-net device from the guest:

guest% readlink -f /sys/class/net/eth1/device
/sys/devices/pci0000:00/0000:00:02.0/0000:01:00.0/virtio1
guest% echo "2" > /sys/devices/pci0000:00/0000:00:02.0/0000:01:00.0/sriov_numvfs guest% ip link show
eth0: ....
eth1: ....
eth2: .... #virtual VF created
eth3: .... #virtual VF created

Please note that communication between VF and PF/VF is not possible by this patch series itself.

Yui Washizu (1):
virtio-pci: add SR-IOV capability

 hw/pci/msix.c                  |  8 +++--
 hw/pci/pci.c                   |  4 +++
 hw/virtio/virtio-pci.c         | 62 ++++++++++++++++++++++++++++++----
 include/hw/virtio/virtio-pci.h |  1 +
 4 files changed, 66 insertions(+), 9 deletions(-)

--
2.39.3

#5 lore raw
Quoted 7 lines · Jason Wang
Quoted 6 lines · Yui Washizu

This patch series is the first step towards enabling
hardware offloading of the L2 packet switching feature on virtio-net device to host machine. We are considering that this hardware offloading enables
the use of high-performance networks in virtual infrastructures,
such as container infrastructures on VMs.

Quoted 6 lines
Quoted 5 lines

To enable L2 packet switching by SR-IOV VFs, we are considering the following:
- making the guest recognize virtio-net devices as SR-IOV PF devices (archived with this patch series)
- allowing virtio-net devices to connect SR-IOV VFs to the backend networks, leaving the L2 packet switching feature to the management layer like libvirt

Could you please show the qemu command line you want to propose here?

I am considering how to specify the properties of VFs to connect SR-IOV VFs to the backend networks.

For example:

qemu-system-x86_64 -device pcie-root-port,port=8,chassis=8,id=pci.8,bus=pcie.0,multifunction=on -netdev tap,id=hostnet0,vhost=on
                   -netdev tap,id=vfnet1,vhost=on # backend network for SR-IOV VF 1 -netdev tap,id=vfnet2,vhost=on # backend network for SR-IOV VF 2 -device virtio-net-pci,netdev=hostnet0,sriov_max_vfs=2,sriov_netdev=vfnet1:vfnet2,...

In this example, we can specify multiple backend networks to the VFs
by adding "sriov_netdev" and separating them with ":".
Additionally, when passing properties like "rx_queue_size" to VFs, we can utilize new properties, such as "sriov_rx_queue_size_per_vfs," to ensure that the same value is passed to all VFs.

I'm still considering about how to specify it, so please give me any comments if you have any.

Quoted 44 lines
Quoted 3 lines

- This makes hardware offloading of L2 packet switching possible. For example, when using vDPA devices, it allows the guest to utilize SR-IOV NIC embedded switch of hosts.

This would be interesting.

Thanks

Quoted 37 lines

This patch series aims to enable SR-IOV emulation on virtio-net devices. With this series, the guest can identify the virtio-net device as an SR-IOV PF device. The newly added property 'sriov_max_vfs' allows us to enable the SR-IOV feature on the virtio-net device.
Currently, we are unable to specify the properties of a VF created from the guest. The properties are set to their default values.
In the future, we plan to allow users to set the properties.

qemu-system-x86_64 --device virtio-net,sriov_max_vfs=<num>

# when 'sriov_max_vfs' is present, the SR-IOV feature will be automatically enabled
# <num> means the max number of VF on guest

Example commands to create VFs in virtio-net device from the guest:

guest% readlink -f /sys/class/net/eth1/device
/sys/devices/pci0000:00/0000:00:02.0/0000:01:00.0/virtio1
guest% echo "2" > /sys/devices/pci0000:00/0000:00:02.0/0000:01:00.0/sriov_numvfs guest% ip link show
eth0: ....
eth1: ....
eth2: .... #virtual VF created
eth3: .... #virtual VF created

Please note that communication between VF and PF/VF is not possible by this patch series itself.

Yui Washizu (1):
virtio-pci: add SR-IOV capability

  hw/pci/msix.c                  |  8 +++--
  hw/pci/pci.c                   |  4 +++
  hw/virtio/virtio-pci.c         | 62 ++++++++++++++++++++++++++++++----
  include/hw/virtio/virtio-pci.h |  1 +
  4 files changed, 66 insertions(+), 9 deletions(-)

--
2.39.3

#6 lore raw
Quoted 36 lines · Yui Washizu
Quoted 7 lines · Jason Wang
Quoted 6 lines · Yui Washizu

This patch series is the first step towards enabling
hardware offloading of the L2 packet switching feature on virtio-net device to host machine. We are considering that this hardware offloading enables
the use of high-performance networks in virtual infrastructures,
such as container infrastructures on VMs.

Quoted 6 lines
Quoted 5 lines

To enable L2 packet switching by SR-IOV VFs, we are considering the following:
- making the guest recognize virtio-net devices as SR-IOV PF devices (archived with this patch series)
- allowing virtio-net devices to connect SR-IOV VFs to the backend networks, leaving the L2 packet switching feature to the management layer like libvirt

Could you please show the qemu command line you want to propose here?

I am considering how to specify the properties of VFs to connect SR-IOV VFs to the backend networks.

For example:

qemu-system-x86_64 -device pcie-root-port,port=8,chassis=8,id=pci.8,bus=pcie.0,multifunction=on
-netdev tap,id=hostnet0,vhost=on
-netdev tap,id=vfnet1,vhost=on # backend network for
SR-IOV VF 1
-netdev tap,id=vfnet2,vhost=on # backend network for
SR-IOV VF 2
-device
virtio-net-pci,netdev=hostnet0,sriov_max_vfs=2,sriov_netdev=vfnet1:vfnet2,...

Quoted 2 lines

In this example, we can specify multiple backend networks to the VFs by adding "sriov_netdev" and separating them with ":".

This seems what is in my mind as well, more below

Quoted 4 lines

Additionally, when passing properties like "rx_queue_size" to VFs, we can utilize new properties,
such as "sriov_rx_queue_size_per_vfs," to ensure that the same value is passed to all VFs.

Or we can introduce new device like:

-netdev tap,id=hn0 \
-device virtio-net-pci,netdev=hn0,id=vnet_pf \
-netdev tap,netdev=hn1 \
-device virtio-net-pci-vf,netdev=hn1,id=vf0,pf=vnet_pf,rx_queue_size=XYZ ... \

This allows us to reuse the codes for configuring vf parameters. But note that rx_queue_size doesn't make too much sense to vhost-vDPA, as qemu can perform nothing more than a simple sanity test.

Thanks

Quoted 50 lines

I'm still considering about how to specify it, so please give me any comments if you have any.

Quoted 44 lines
Quoted 3 lines

- This makes hardware offloading of L2 packet switching possible. For example, when using vDPA devices, it allows the guest to utilize SR-IOV NIC embedded switch of hosts.

This would be interesting.

Thanks

Quoted 37 lines

This patch series aims to enable SR-IOV emulation on virtio-net devices. With this series, the guest can identify the virtio-net device as an SR-IOV PF device. The newly added property 'sriov_max_vfs' allows us to enable the SR-IOV feature on the virtio-net device.
Currently, we are unable to specify the properties of a VF created from the guest. The properties are set to their default values.
In the future, we plan to allow users to set the properties.

qemu-system-x86_64 --device virtio-net,sriov_max_vfs=<num>

# when 'sriov_max_vfs' is present, the SR-IOV feature will be automatically enabled
# <num> means the max number of VF on guest

Example commands to create VFs in virtio-net device from the guest:

guest% readlink -f /sys/class/net/eth1/device
/sys/devices/pci0000:00/0000:00:02.0/0000:01:00.0/virtio1
guest% echo "2" > /sys/devices/pci0000:00/0000:00:02.0/0000:01:00.0/sriov_numvfs guest% ip link show
eth0: ....
eth1: ....
eth2: .... #virtual VF created
eth3: .... #virtual VF created

Please note that communication between VF and PF/VF is not possible by this patch series itself.

Yui Washizu (1):
virtio-pci: add SR-IOV capability

  hw/pci/msix.c                  |  8 +++--
  hw/pci/pci.c                   |  4 +++
  hw/virtio/virtio-pci.c         | 62 ++++++++++++++++++++++++++++++----
  include/hw/virtio/virtio-pci.h |  1 +
  4 files changed, 66 insertions(+), 9 deletions(-)

--
2.39.3

#7 lore raw
Quoted 50 lines · Jason Wang
Quoted 34 lines · Yui Washizu
Quoted 7 lines · Jason Wang
Quoted 6 lines · Yui Washizu

This patch series is the first step towards enabling
hardware offloading of the L2 packet switching feature on virtio-net device to host machine. We are considering that this hardware offloading enables
the use of high-performance networks in virtual infrastructures,
such as container infrastructures on VMs.

Quoted 6 lines
Quoted 5 lines

To enable L2 packet switching by SR-IOV VFs, we are considering the following:
- making the guest recognize virtio-net devices as SR-IOV PF devices (archived with this patch series)
- allowing virtio-net devices to connect SR-IOV VFs to the backend networks, leaving the L2 packet switching feature to the management layer like libvirt

Could you please show the qemu command line you want to propose here?

I am considering how to specify the properties of VFs to connect SR-IOV VFs to the backend networks.

For example:

qemu-system-x86_64 -device pcie-root-port,port=8,chassis=8,id=pci.8,bus=pcie.0,multifunction=on
-netdev tap,id=hostnet0,vhost=on
-netdev tap,id=vfnet1,vhost=on # backend network for
SR-IOV VF 1
-netdev tap,id=vfnet2,vhost=on # backend network for
SR-IOV VF 2
-device
virtio-net-pci,netdev=hostnet0,sriov_max_vfs=2,sriov_netdev=vfnet1:vfnet2,...

Quoted 2 lines

In this example, we can specify multiple backend networks to the VFs by adding "sriov_netdev" and separating them with ":".

This seems what is in my mind as well, more below

Quoted 4 lines

Additionally, when passing properties like "rx_queue_size" to VFs, we can utilize new properties,
such as "sriov_rx_queue_size_per_vfs," to ensure that the same value is passed to all VFs.

Or we can introduce new device like:

(quoted diff) +0 -4
-netdev tap,id=hn0 \
-device virtio-net-pci,netdev=hn0,id=vnet_pf \
-netdev tap,netdev=hn1 \
-device virtio-net-pci-vf,netdev=hn1,id=vf0,pf=vnet_pf,rx_queue_size=XYZ ... \
Quoted 1 line

This allows us to reuse the codes for configuring vf parameters.

Yes, I was also considering this method was one of the option.

I was concerned that the implementation
for it might be different from other devices specified by the "-device" option because VF devices are created when the guest creates VFs from PFs, not when the guest starts,
and the implementation may be complicated.
So I dropped the idea then.

However, I think it is a cleaner way for specifying VFs than my suggested one.

I will further consider whether the implementation will be really difficult or not.

Thank you.

Quoted 54 lines

But
note that rx_queue_size doesn't make too much sense to vhost-vDPA, as qemu can perform nothing more than a simple sanity test.

Thanks

Quoted 48 lines

I'm still considering about how to specify it, so please give me any comments if you have any.

Quoted 44 lines
Quoted 3 lines

- This makes hardware offloading of L2 packet switching possible. For example, when using vDPA devices, it allows the guest to utilize SR-IOV NIC embedded switch of hosts.

This would be interesting.

Thanks

Quoted 37 lines

This patch series aims to enable SR-IOV emulation on virtio-net devices. With this series, the guest can identify the virtio-net device as an SR-IOV PF device. The newly added property 'sriov_max_vfs' allows us to enable the SR-IOV feature on the virtio-net device.
Currently, we are unable to specify the properties of a VF created from the guest. The properties are set to their default values.
In the future, we plan to allow users to set the properties.

qemu-system-x86_64 --device virtio-net,sriov_max_vfs=<num>

# when 'sriov_max_vfs' is present, the SR-IOV feature will be automatically enabled
# <num> means the max number of VF on guest

Example commands to create VFs in virtio-net device from the guest:

guest% readlink -f /sys/class/net/eth1/device
/sys/devices/pci0000:00/0000:00:02.0/0000:01:00.0/virtio1
guest% echo "2" > /sys/devices/pci0000:00/0000:00:02.0/0000:01:00.0/sriov_numvfs guest% ip link show
eth0: ....
eth1: ....
eth2: .... #virtual VF created
eth3: .... #virtual VF created

Please note that communication between VF and PF/VF is not possible by this patch series itself.

Yui Washizu (1):
virtio-pci: add SR-IOV capability

   hw/pci/msix.c                  |  8 +++--
   hw/pci/pci.c                   |  4 +++
   hw/virtio/virtio-pci.c         | 62 ++++++++++++++++++++++++++++++----
   include/hw/virtio/virtio-pci.h |  1 +
   4 files changed, 66 insertions(+), 9 deletions(-)

--
2.39.3

#8 lore raw
In reply to Jason Wang
Quoted 50 lines · Jason Wang
Quoted 34 lines · Yui Washizu
Quoted 7 lines · Jason Wang
Quoted 6 lines · Yui Washizu

This patch series is the first step towards enabling
hardware offloading of the L2 packet switching feature on virtio-net device to host machine. We are considering that this hardware offloading enables
the use of high-performance networks in virtual infrastructures,
such as container infrastructures on VMs.

Quoted 6 lines
Quoted 5 lines

To enable L2 packet switching by SR-IOV VFs, we are considering the following:
- making the guest recognize virtio-net devices as SR-IOV PF devices (archived with this patch series)
- allowing virtio-net devices to connect SR-IOV VFs to the backend networks, leaving the L2 packet switching feature to the management layer like libvirt

Could you please show the qemu command line you want to propose here?

I am considering how to specify the properties of VFs to connect SR-IOV VFs to the backend networks.

For example:

qemu-system-x86_64 -device pcie-root-port,port=8,chassis=8,id=pci.8,bus=pcie.0,multifunction=on
-netdev tap,id=hostnet0,vhost=on
-netdev tap,id=vfnet1,vhost=on # backend network for
SR-IOV VF 1
-netdev tap,id=vfnet2,vhost=on # backend network for
SR-IOV VF 2
-device
virtio-net-pci,netdev=hostnet0,sriov_max_vfs=2,sriov_netdev=vfnet1:vfnet2,...

Quoted 2 lines

In this example, we can specify multiple backend networks to the VFs by adding "sriov_netdev" and separating them with ":".

This seems what is in my mind as well, more below

Quoted 4 lines

Additionally, when passing properties like "rx_queue_size" to VFs, we can utilize new properties,
such as "sriov_rx_queue_size_per_vfs," to ensure that the same value is passed to all VFs.

Or we can introduce new device like:

(quoted diff) +0 -4
-netdev tap,id=hn0 \
-device virtio-net-pci,netdev=hn0,id=vnet_pf \
-netdev tap,netdev=hn1 \
-device virtio-net-pci-vf,netdev=hn1,id=vf0,pf=vnet_pf,rx_queue_size=XYZ ... \
Quoted 5 lines

This allows us to reuse the codes for configuring vf parameters. But note that rx_queue_size doesn't make too much sense to vhost-vDPA, as qemu can perform nothing more than a simple sanity test.

Thanks

Thanks for proposing this new way.

I have considered how to implement this.

As virtio-net-pci-vf device should show up

on the guest only when the guest OS creates a VF,

the guest must not be able to see the VF device on PCI bus when qemu starts.

However, it's hard to realize this without overcomplicating

relevant code due to current qemu implementation.

It's because qdev_device_add_from_qdict,

a function which is called when devices are specified

with "-device" option of qemu startup command,

always create devices by qdev_new and qdev_realize.

It might be possible that we fix it

so that qdev_new/qdev_realize aren't triggered for virtio-net-pci-vf devices,

but It seems that we need to special case the device in very generic code

like qdev_device_add_from_qdict(), qdev_device_add(),

device_init_func() or their caller function.

Given my current ideas,

it seems like this PATCH could become complex.

Woule you have any suggestions

for achieving this in more simple way possible ?

Quoted 48 lines
Quoted 48 lines

I'm still considering about how to specify it, so please give me any comments if you have any.

Quoted 44 lines
Quoted 3 lines

- This makes hardware offloading of L2 packet switching possible. For example, when using vDPA devices, it allows the guest to utilize SR-IOV NIC embedded switch of hosts.

This would be interesting.

Thanks

Quoted 37 lines

This patch series aims to enable SR-IOV emulation on virtio-net devices. With this series, the guest can identify the virtio-net device as an SR-IOV PF device. The newly added property 'sriov_max_vfs' allows us to enable the SR-IOV feature on the virtio-net device.
Currently, we are unable to specify the properties of a VF created from the guest. The properties are set to their default values.
In the future, we plan to allow users to set the properties.

qemu-system-x86_64 --device virtio-net,sriov_max_vfs=<num>

# when 'sriov_max_vfs' is present, the SR-IOV feature will be automatically enabled
# <num> means the max number of VF on guest

Example commands to create VFs in virtio-net device from the guest:

guest% readlink -f /sys/class/net/eth1/device
/sys/devices/pci0000:00/0000:00:02.0/0000:01:00.0/virtio1
guest% echo "2" > /sys/devices/pci0000:00/0000:00:02.0/0000:01:00.0/sriov_numvfs guest% ip link show
eth0: ....
eth1: ....
eth2: .... #virtual VF created
eth3: .... #virtual VF created

Please note that communication between VF and PF/VF is not possible by this patch series itself.

Yui Washizu (1):
virtio-pci: add SR-IOV capability

   hw/pci/msix.c                  |  8 +++--
   hw/pci/pci.c                   |  4 +++
   hw/virtio/virtio-pci.c         | 62 ++++++++++++++++++++++++++++++----
   include/hw/virtio/virtio-pci.h |  1 +
   4 files changed, 66 insertions(+), 9 deletions(-)

--
2.39.3

#9 lore raw

Hi Jason,

Quoted 96 lines · Yui Washizu
Quoted 53 lines · Jason Wang
Quoted 36 lines · Yui Washizu
Quoted 7 lines · Jason Wang
Quoted 6 lines · Yui Washizu

This patch series is the first step towards enabling
hardware offloading of the L2 packet switching feature on virtio-net device to host machine. We are considering that this hardware offloading enables
the use of high-performance networks in virtual infrastructures,
such as container infrastructures on VMs.

Quoted 7 lines
Quoted 6 lines

To enable L2 packet switching by SR-IOV VFs, we are considering the following:
- making the guest recognize virtio-net devices as SR-IOV PF devices (archived with this patch series)
- allowing virtio-net devices to connect SR-IOV VFs to the backend networks,
    leaving the L2 packet switching feature to the management layer like libvirt

Could you please show the qemu command line you want to propose here?

I am considering how to specify the properties of VFs to connect SR-IOV VFs to the backend networks.

For example:

qemu-system-x86_64 -device pcie-root-port,port=8,chassis=8,id=pci.8,bus=pcie.0,multifunction=on -netdev tap,id=hostnet0,vhost=on
                     -netdev tap,id=vfnet1,vhost=on # backend network for SR-IOV VF 1
                     -netdev tap,id=vfnet2,vhost=on # backend network for SR-IOV VF 2
                     -device virtio-net-pci,netdev=hostnet0,sriov_max_vfs=2,sriov_netdev=vfnet1:vfnet2,...

Quoted 2 lines

In this example, we can specify multiple backend networks to the VFs by adding "sriov_netdev" and separating them with ":".

This seems what is in my mind as well, more below

Quoted 4 lines

Additionally, when passing properties like "rx_queue_size" to VFs, we can utilize new properties,
such as "sriov_rx_queue_size_per_vfs," to ensure that the same value is passed to all VFs.

Or we can introduce new device like:

(quoted diff) +0 -4
-netdev tap,id=hn0 \
-device virtio-net-pci,netdev=hn0,id=vnet_pf \
-netdev tap,netdev=hn1 \
-device 

virtio-net-pci-vf,netdev=hn1,id=vf0,pf=vnet_pf,rx_queue_size=XYZ ... \

Quoted 5 lines

This allows us to reuse the codes for configuring vf parameters. But note that rx_queue_size doesn't make too much sense to vhost-vDPA, as qemu can perform nothing more than a simple sanity test.

Thanks

Thanks for proposing this new way.

I have considered how to implement this.

As virtio-net-pci-vf device should show up

on the guest only when the guest OS creates a VF,

the guest must not be able to see the VF device on PCI bus when qemu starts.

However, it's hard to realize this without overcomplicating

relevant code due to current qemu implementation.

It's because qdev_device_add_from_qdict,

a function which is called when devices are specified

with "-device" option of qemu startup command,

always create devices by qdev_new and qdev_realize.

It might be possible that we fix it

so that qdev_new/qdev_realize aren't triggered for virtio-net-pci-vf devices,

but It seems that we need to special case the device in very generic code

like qdev_device_add_from_qdict(), qdev_device_add(),

device_init_func() or their caller function.

Quoted 9 lines

Given my current ideas,

it seems like this PATCH could become complex.

Woule you have any suggestions

for achieving this in more simple way possible ?

I was wondering if you could give me some feedback. Best regard.

Quoted 50 lines
Quoted 50 lines
Quoted 50 lines

I'm still considering about how to specify it, so please give me any comments if you have any.

Quoted 45 lines
Quoted 3 lines

    - This makes hardware offloading of L2 packet switching possible. For example, when using vDPA devices, it allows the guest to utilize SR-IOV NIC embedded switch of hosts.

This would be interesting.

Thanks

Quoted 38 lines

This patch series aims to enable SR-IOV emulation on virtio-net devices. With this series, the guest can identify the virtio-net device as an SR-IOV PF device. The newly added property 'sriov_max_vfs' allows us to enable the SR-IOV feature on the virtio-net device.
Currently, we are unable to specify the properties of a VF created from the guest. The properties are set to their default values.
In the future, we plan to allow users to set the properties.

qemu-system-x86_64 --device virtio-net,sriov_max_vfs=<num>

# when 'sriov_max_vfs' is present, the SR-IOV feature will be automatically enabled
# <num> means the max number of VF on guest

Example commands to create VFs in virtio-net device from the guest:

guest% readlink -f /sys/class/net/eth1/device /sys/devices/pci0000:00/0000:00:02.0/0000:01:00.0/virtio1
guest% echo "2" > /sys/devices/pci0000:00/0000:00:02.0/0000:01:00.0/sriov_numvfs guest% ip link show
   eth0: ....
   eth1: ....
   eth2: .... #virtual VF created
   eth3: .... #virtual VF created

Please note that communication between VF and PF/VF is not possible by this patch series itself.

Yui Washizu (1):
    virtio-pci: add SR-IOV capability

   hw/pci/msix.c                  |  8 +++--
   hw/pci/pci.c                   |  4 +++
   hw/virtio/virtio-pci.c         | 62
++++++++++++++++++++++++++++++----
   include/hw/virtio/virtio-pci.h |  1 +

   4 files changed, 66 insertions(+), 9 deletions(-)
Signature · 1 line
2.39.3
#10 lore raw
Quoted 115 lines · Yui Washizu

Hi Jason,

Quoted 109 lines · Yui Washizu
Quoted 60 lines · Jason Wang
Quoted 42 lines · Yui Washizu
Quoted 17 lines · Jason Wang
Quoted 7 lines · Yui Washizu

This patch series is the first step towards enabling hardware offloading of the L2 packet switching feature on virtio-net device to host machine.
We are considering that this hardware offloading enables the use of high-performance networks in virtual infrastructures, such as container infrastructures on VMs.

Quoted 8 lines

To enable L2 packet switching by SR-IOV VFs, we are considering the following:
- making the guest recognize virtio-net devices as SR-IOV PF devices (archived with this patch series)
- allowing virtio-net devices to connect SR-IOV VFs to the backend networks,
leaving the L2 packet switching feature to the management
layer like libvirt

Quoted 1 line

Could you please show the qemu command line you want to propose here?

I am considering how to specify the properties of VFs to connect SR-IOV VFs to the backend networks.

For example:

qemu-system-x86_64 -device pcie-root-port,port=8,chassis=8,id=pci.8,bus=pcie.0,multifunction=on
-netdev tap,id=hostnet0,vhost=on
-netdev tap,id=vfnet1,vhost=on # backend
network for
SR-IOV VF 1
-netdev tap,id=vfnet2,vhost=on # backend
network for
SR-IOV VF 2
-device
virtio-net-pci,netdev=hostnet0,sriov_max_vfs=2,sriov_netdev=vfnet1:vfnet2,...

Quoted 2 lines

In this example, we can specify multiple backend networks to the VFs by adding "sriov_netdev" and separating them with ":".

This seems what is in my mind as well, more below

Quoted 4 lines

Additionally, when passing properties like "rx_queue_size" to VFs, we can utilize new properties,
such as "sriov_rx_queue_size_per_vfs," to ensure that the same value is passed to all VFs.

Or we can introduce new device like:

(quoted diff) +0 -4
-netdev tap,id=hn0 \
-device virtio-net-pci,netdev=hn0,id=vnet_pf \
-netdev tap,netdev=hn1 \
-device

virtio-net-pci-vf,netdev=hn1,id=vf0,pf=vnet_pf,rx_queue_size=XYZ ... \

Quoted 5 lines

This allows us to reuse the codes for configuring vf parameters. But note that rx_queue_size doesn't make too much sense to vhost-vDPA, as qemu can perform nothing more than a simple sanity test.

Thanks

Thanks for proposing this new way.

I have considered how to implement this.

As virtio-net-pci-vf device should show up

on the guest only when the guest OS creates a VF,

the guest must not be able to see the VF device on PCI bus when qemu starts.

However, it's hard to realize this without overcomplicating

relevant code due to current qemu implementation.

It's because qdev_device_add_from_qdict,

a function which is called when devices are specified

with "-device" option of qemu startup command,

always create devices by qdev_new and qdev_realize.

It might be possible that we fix it

so that qdev_new/qdev_realize aren't triggered for virtio-net-pci-vf devices,

but It seems that we need to special case the device in very generic code

like qdev_device_add_from_qdict(), qdev_device_add(),

device_init_func() or their caller function.

Given my current ideas,

it seems like this PATCH could become complex.

Quoted 8 lines
Quoted 5 lines

Woule you have any suggestions

for achieving this in more simple way possible ?

I was wondering if you could give me some feedback. Best regard.

Sorry for the late reply, I think we can start from the easy way from your point and see.

Thanks

Quoted 60 lines
Quoted 59 lines
Quoted 59 lines
Quoted 59 lines

I'm still considering about how to specify it, so please give me any comments if you have any.

Quoted 52 lines
Quoted 3 lines

- This makes hardware offloading of L2 packet switching possible. For example, when using vDPA devices, it allows the guest to utilize SR-IOV NIC embedded switch of hosts.

This would be interesting.

Thanks

Quoted 45 lines

This patch series aims to enable SR-IOV emulation on virtio-net devices.
With this series, the guest can identify the virtio-net device as an SR-IOV PF device.
The newly added property 'sriov_max_vfs' allows us to enable the SR-IOV feature
on the virtio-net device.
Currently, we are unable to specify the properties of a VF created from the guest.
The properties are set to their default values.
In the future, we plan to allow users to set the properties.

qemu-system-x86_64 --device virtio-net,sriov_max_vfs=<num>

# when 'sriov_max_vfs' is present, the SR-IOV feature will be
automatically enabled
# <num> means the max number of VF on guest

Example commands to create VFs in virtio-net device from the guest:

guest% readlink -f /sys/class/net/eth1/device /sys/devices/pci0000:00/0000:00:02.0/0000:01:00.0/virtio1 guest% echo "2" > /sys/devices/pci0000:00/0000:00:02.0/0000:01:00.0/sriov_numvfs guest% ip link show
eth0: ....
eth1: ....
eth2: .... #virtual VF created
eth3: .... #virtual VF created

Please note that communication between VF and PF/VF is not possible by this patch series itself.

Yui Washizu (1):
virtio-pci: add SR-IOV capability

   hw/pci/msix.c                  |  8 +++--
   hw/pci/pci.c                   |  4 +++
   hw/virtio/virtio-pci.c         | 62
++++++++++++++++++++++++++++++----
   include/hw/virtio/virtio-pci.h |  1 +
   4 files changed, 66 insertions(+), 9 deletions(-)

--
2.39.3