]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
domain_conf: Add configs for virtio net RSS and Hash report.
authorAndrew Melnychenko <andrew@daynix.com>
Sun, 9 Jan 2022 21:07:35 +0000 (23:07 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 5 Apr 2022 13:36:27 +0000 (15:36 +0200)
Added "rss" and "rss_hash_report" configuration that should be
used with qemu virtio RSS. Both options are triswitches. Used as
"driver" options and affects only NIC with model type "virtio".
In other patches - options should turn on virtio-net RSS and hash
properties.

Signed-off-by: Andrew Melnychenko <andrew@daynix.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
docs/formatdomain.rst
src/conf/domain_conf.c
src/conf/domain_conf.h
src/conf/schemas/domaincommon.rng
tests/qemuxml2argvdata/net-virtio-rss.xml [new file with mode: 0644]
tests/qemuxml2argvdata/virtio-options.xml
tests/qemuxml2xmloutdata/net-virtio-rss.x86_64-latest.xml [new symlink]
tests/qemuxml2xmltest.c

index c67dcfb4bf193adb3005025189029b4b6986228d..0ac88b2dfb5f35380c8bce09705934a25d4dbb11 100644 (file)
@@ -5338,6 +5338,24 @@ following attributes are available for the ``"virtio"`` NIC driver:
    only for ``vhostuser`` type. :since:`Since 3.7.0 (QEMU and KVM only)`
    **In general you should leave this option alone, unless you are very certain
    you know what you are doing.**
+``rss``
+   The ``rss`` option enables in-qemu/ebpf RSS for virtio NIC. RSS works with
+   virtio and tap backends only. Virtio NIC will be launched with "rss"
+   property. For now "in-qemu" RSS is supported by libvirt.
+   QEMU may load eBPF RSS if it has CAP_SYS_ADMIN permissions, which is
+   not supported by default in libvirt.
+   **In general you should leave this option alone, unless you are very certain
+   you know what you are doing. Proper RSS configuration depends from vcpu,
+   tap, and vhost settings.**
+``rss_hash_report``
+   The ``rss_hash_report`` option enables in-qemu RSS hash report for virtio
+   NIC. Virtio NIC will be launched with a "hash" property. Network packets provided
+   to VM will contain a hash of the packet in the virt header. Usually enabled
+   alongside with ``rss``. Without ``rss`` option, the hash report doesn't affect
+   steering itself but provides vnet header with a calculated hash.
+   **In general you should leave this option alone, unless you are very certain
+   you know what you are doing. Proper RSS configuration depends from vcpu,
+   tap, and vhost settings.**
 virtio options
    For virtio interfaces, `Virtio-specific options <#elementsVirtio>`__ can also
    be set. ( :since:`Since 3.5.0` )
index 98df54e78cb079edad715f846eaa45719e6566a9..33eace04dcca97a93fc33504bc48e1dce726e8fb 100644 (file)
@@ -10777,6 +10777,16 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt,
                            &def->driver.virtio.tx_queue_size) < 0)
             goto error;
 
+        if (virXMLPropTristateSwitch(driver_node, "rss",
+                                     VIR_XML_PROP_NONE,
+                                     &def->driver.virtio.rss) < 0)
+            goto error;
+
+        if (virXMLPropTristateSwitch(driver_node, "rss_hash_report",
+                                     VIR_XML_PROP_NONE,
+                                     &def->driver.virtio.rss_hash_report) < 0)
+            goto error;
+
         if ((tmpNode = virXPathNode("./driver/host", ctxt))) {
             if (virXMLPropTristateSwitch(tmpNode, "csum", VIR_XML_PROP_NONE,
                                          &def->driver.virtio.host.csum) < 0)
@@ -24616,6 +24626,14 @@ virDomainVirtioNetDriverFormat(virBuffer *buf,
     if (def->driver.virtio.tx_queue_size)
         virBufferAsprintf(buf, " tx_queue_size='%u'",
                           def->driver.virtio.tx_queue_size);
+    if (def->driver.virtio.rss != VIR_TRISTATE_SWITCH_ABSENT) {
+        virBufferAsprintf(buf, " rss='%s'",
+                          virTristateSwitchTypeToString(def->driver.virtio.rss));
+    }
+    if (def->driver.virtio.rss_hash_report != VIR_TRISTATE_SWITCH_ABSENT) {
+        virBufferAsprintf(buf, " rss_hash_report='%s'",
+                          virTristateSwitchTypeToString(def->driver.virtio.rss_hash_report));
+    }
 
     virDomainVirtioOptionsFormat(buf, def->virtio);
 }
index 1ef3dc8a2b998638363a286f20e40595d4bd4ab6..694491cd63b1a8907385a5282c0accb802f568ce 100644 (file)
@@ -1069,6 +1069,8 @@ struct _virDomainNetDef {
                 virTristateSwitch ecn;
                 virTristateSwitch ufo;
             } guest;
+            virTristateSwitch rss;
+            virTristateSwitch rss_hash_report;
         } virtio;
     } driver;
     struct {
index 8345976e816e1108bea15060c1244916c3e21f5a..c0c14fe55843adc33ecbcc2e590ea24271e0d696 100644 (file)
                 </optional>
               </element>
             </optional>
+            <optional>
+              <attribute name="rss">
+                <ref name="virOnOff"/>
+              </attribute>
+            </optional>
+            <optional>
+              <attribute name="rss_hash_report">
+                <ref name="virOnOff"/>
+              </attribute>
+            </optional>
           </interleave>
         </element>
       </optional>
diff --git a/tests/qemuxml2argvdata/net-virtio-rss.xml b/tests/qemuxml2argvdata/net-virtio-rss.xml
new file mode 100644 (file)
index 0000000..5934e1c
--- /dev/null
@@ -0,0 +1,58 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>219100</memory>
+  <currentMemory unit='KiB'>219100</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='i686' machine='pc'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <cpu mode='custom' match='exact' check='none'>
+    <model fallback='forbid'>qemu64</model>
+  </cpu>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu-system-x86_64</emulator>
+    <disk type='block' device='disk'>
+      <driver name='qemu' type='raw'/>
+      <source dev='/dev/HostVG/QEMUGuest1'/>
+      <target dev='hda' bus='ide'/>
+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+    </disk>
+    <controller type='usb' index='0' model='piix3-uhci'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
+    </controller>
+    <controller type='pci' index='0' model='pci-root'/>
+    <controller type='ide' index='0'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
+    </controller>
+    <interface type='user'>
+      <mac address='00:11:22:33:44:55'/>
+      <model type='virtio'/>
+      <driver rss='on'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
+    </interface>
+    <interface type='user'>
+      <mac address='00:11:22:33:44:66'/>
+      <model type='virtio'/>
+      <driver rss_hash_report='on'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+    </interface>
+    <interface type='user'>
+      <mac address='00:11:22:33:44:77'/>
+      <model type='virtio'/>
+      <driver rss='off' rss_hash_report='on'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
+    </interface>
+    <input type='mouse' bus='ps2'/>
+    <input type='keyboard' bus='ps2'/>
+    <audio id='1' type='none'/>
+    <memballoon model='virtio'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
+    </memballoon>
+  </devices>
+</domain>
index 59e293d8e9caad826e164aa434ebbe19ef3df977..486bc453a1296bce0272ecad8503517b2f42c953 100644 (file)
@@ -53,7 +53,7 @@
     <interface type='user'>
       <mac address='52:54:56:58:5a:5c'/>
       <model type='virtio'/>
-      <driver iommu='on' ats='on' packed='on' page_per_vq='on'/>
+      <driver rss='on' rss_hash_report='on' iommu='on' ats='on' packed='on' page_per_vq='on'/>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
     </interface>
     <input type='mouse' bus='virtio'>
diff --git a/tests/qemuxml2xmloutdata/net-virtio-rss.x86_64-latest.xml b/tests/qemuxml2xmloutdata/net-virtio-rss.x86_64-latest.xml
new file mode 120000 (symlink)
index 0000000..90c32c9
--- /dev/null
@@ -0,0 +1 @@
+../qemuxml2argvdata/net-virtio-rss.xml
\ No newline at end of file
index 91777052543a4838d982436d1f211b0c3477250c..4d2b2ad784df4bead219fa7fa151936cdef4ac19 100644 (file)
@@ -487,6 +487,7 @@ mymain(void)
     DO_TEST_NOCAPS("net-many-models");
     DO_TEST("net-vdpa", QEMU_CAPS_NETDEV_VHOST_VDPA);
     DO_TEST("net-vdpa-multiqueue", QEMU_CAPS_NETDEV_VHOST_VDPA);
+    DO_TEST_CAPS_LATEST("net-virtio-rss");
 
     DO_TEST_NOCAPS("serial-tcp-tlsx509-chardev");
     DO_TEST_NOCAPS("serial-tcp-tlsx509-chardev-notls");