{"id":280,"date":"2016-05-21T07:25:28","date_gmt":"2016-05-21T01:25:28","guid":{"rendered":"https:\/\/avalon.land\/blog\/?p=280"},"modified":"2016-05-21T07:35:24","modified_gmt":"2016-05-21T01:35:24","slug":"sr-iov-kvm-and-intel-x520-10gbps-cards-on-debianstable","status":"publish","type":"post","link":"https:\/\/avalon.land\/blog\/networking\/sr-iov-kvm-and-intel-x520-10gbps-cards-on-debianstable\/","title":{"rendered":"SR-IOV, KVM and Intel X520 10Gbps cards on Debian\/Stable"},"content":{"rendered":"<p>    1. SR-IOV and KVM virtual machines under GNU\/Linux Debian (Jessie) Intel X520 10Gbps cards Yoann Juet @ University of Nantes, France Information Technology Services Version 1.2 (12 Jun 2015)<br \/>\n<!--more--><\/p>\n<p>    2. 2\/19 Our goal \u2022 Virtualize high-performance servers, firewalls requiring: &#8211; Low network latency and jitter &#8211; Low processor impact (I\/O) &#8211; High throughput (10Gbps or more) \u2022 Solution: Single Root \u2013 IO Virtualization (SR-IOV) &#8211; A single PCI card is showed up as multiple virtual PCI cards &#8211; Exposes n virtual interfaces from a single physical interface > Shared bandwidth<br \/>\n    3. 3\/19 Prerequisites \u2022 Virtualization Technology for Directed I\/O: Intel VT-d or AMD-Vi &#8211; Must be supported by both the CPU and the chipset &#8211; Guest machines gain direct memory access (DMA) to PCI(e) devices, such as Ethernet cards \u2022 PCI-SIG Single Root I\/O Virtualization: SR-IOV &#8211; Must be supported by both the Ethernet cards and the BIOS &#8211; Guest machines are able to achieve ~ bare metal performance<br \/>\n    4. 4\/19 Technical environment \u2022 Dell PowerEdge R720xd &#8211; Intel Xeon CPU E5-2660 &#8211; Quad Broadcom BCM5720 1000Base-T interfaces > Logical names eth2 to eth5 &#8211; Dual Intel X520 SFP+ 10Gbps interfaces > SR-IOV compatible card > Logical names eth0 and eth1 &#8211; Operating System Debian 8 (code name &#8220;Jessie&#8221;) > Installed on both hosts and guests machines<br \/>\n    5. 5\/19 BIOS Host machine \u2022 Ensure Intel VT-d feature is enabled &#8211; System BIOS > Processor Settings > Virtualization Technology<br \/>\n    6. 6\/19 BIOS Host machine \u2022 Ensure SR-IOV BIOS option is enabled &#8211; Device Settings > [Select NIC] > Device Level Configuration > Virtualization mode = SR-IOV<br \/>\n    7. 7\/19 BIOS Host machine \u2022 Ensure SR-IOV BIOS option is enabled &#8211; Device Settings > [Select NIC] > NIC Configuration > PCI Virtual Functions Advertised = 64<br \/>\n    8. 8\/19 Debian: Starting with SR-IOV Host machine \u2022 Some Kernel requirements: CONFIG_PCI_IOV={y|m} CONFIG_PCI_STUB={y|m} CONFIG_VFIO_IOMMU_TYPE1={y|m} CONFIG_VFIO={y|m} CONFIG_VFIO_PCI={y|m} CONFIG_INTEL_IOMMU_DEFAULT_ON={y|m} \u2022 On Jessie default kernel, CONFIG_INTEL_IOMMU_DEFAULT_ON is not set require a grub special configuration\u2192<br \/>\n    9. 9\/19 Debian: Starting with SR-IOV Host machine \u2022 Edit file \/etc\/default\/grub and update the following parameter GRUB_CMDLINE_LINUX=&#8221;intel_iommu=on&#8221; \u2022 Execute the command update-grub and finaly reboot<br \/>\n    10. 10\/19 Debian: Starting with SR-IOV Host machine \u2022 Check for SR-IOV hardware support on NICs: # lspci -v \u2026 42:00.0 Ethernet controller: Intel Corporation Ethernet 10G 2P X520 Adapter (rev 01) Subsystem: Intel Corporation 10GbE 2P X520 Adapter &#8230; Capabilities: [160] Single Root I\/O Virtualization (SR-IOV) Kernel driver in use: ixgbe 42:00.1 Ethernet controller: Intel Corporation Ethernet 10G 2P X520 Adapter (rev 01) Subsystem: Intel Corporation 10GbE 2P X520 Adapter &#8230; Capabilities: [160] Single Root I\/O Virtualization (SR-IOV) Kernel driver in use: ixgbe eth0 eth1<br \/>\n    11. 11\/19 Debian: Starting with SR-IOV Host machine \u2022 Check for Intel&#8217;s VT-d IOMMU support: # dmesg | egrep -i \u201cDMA|IOMMU\u201d \u2026 Kernel command line: BOOT_IMAGE=\/vmlinuz-3.16.0-4-amd64 root=UUID=821747a0-fe42-473c-9273-391feb7f82cf ro intel_iommu=on quiet Intel-IOMMU: enabled &#8230; dmar: IOMMU 0: reg_base_addr d5000000 ver 1:0 cap d2078c106f0466 ecap f020de dmar: IOMMU 1: reg_base_addr df900000 ver 1:0 cap d2078c106f0466 ecap f020de &#8230; IOMMU: Setting identity map for device 0000:00:1f.0 [0x0 &#8211; 0xffffff] PCI-DMA: Intel(R) Virtualization Technology for Directed I\/O \u2026 https:\/\/www.kernel.org\/doc\/Documentation\/vfio.txt<br \/>\n    12. 12\/19 Debian: Starting with SR-IOV Host machine \u2022 Activate SR-IOV on both 10Gbps interfaces with 8 VFs (64 max. allowed) per PF # echo 8 > \/sys\/bus\/pci\/devices\/0000:42:00.0\/sriov_numvfs # echo 8 > \/sys\/bus\/pci\/devices\/0000:42:00.1\/sriov_numvfs USB IDs for eth0 and eth1<br \/>\n    13. 13\/19 Debian: Starting with SR-IOV Host machine \u2022 Check for new virtual PCIe devices (Virtual Functions): # lspci &#8230; 42:00.0 Ethernet controller: Intel Corporation Ethernet 10G 2P X520 Adapter (rev 01) 42:00.1 Ethernet controller: Intel Corporation Ethernet 10G 2P X520 Adapter (rev 01) 42:10.0 Ethernet controller: Intel Corporation 82599 Ethernet Controller Virtual Function (rev 01) 42:10.1 Ethernet controller: Intel Corporation 82599 Ethernet Controller Virtual Function (rev 01) 42:10.2 Ethernet controller: Intel Corporation 82599 Ethernet Controller Virtual Function (rev 01) 42:10.3 Ethernet controller: Intel Corporation 82599 Ethernet Controller Virtual Function (rev 01) 42:10.4 Ethernet controller: Intel Corporation 82599 Ethernet Controller Virtual Function (rev 01) 42:10.5 Ethernet controller: Intel Corporation 82599 Ethernet Controller Virtual Function (rev 01) 42:10.6 Ethernet controller: Intel Corporation 82599 Ethernet Controller Virtual Function (rev 01) 42:10.7 Ethernet controller: Intel Corporation 82599 Ethernet Controller Virtual Function (rev 01) 42:11.0 Ethernet controller: Intel Corporation 82599 Ethernet Controller Virtual Function (rev 01) 42:11.1 Ethernet controller: Intel Corporation 82599 Ethernet Controller Virtual Function (rev 01) 42:11.2 Ethernet controller: Intel Corporation 82599 Ethernet Controller Virtual Function (rev 01) 42:11.3 Ethernet controller: Intel Corporation 82599 Ethernet Controller Virtual Function (rev 01) 42:11.4 Ethernet controller: Intel Corporation 82599 Ethernet Controller Virtual Function (rev 01) 42:11.5 Ethernet controller: Intel Corporation 82599 Ethernet Controller Virtual Function (rev 01) 42:11.6 Ethernet controller: Intel Corporation 82599 Ethernet Controller Virtual Function (rev 01) 42:11.7 Ethernet controller: Intel Corporation 82599 Ethernet Controller Virtual Function (rev 01) 8 VFs on the second PF (eth1) 8 VFs on the first PF (eth0)<br \/>\n    14. 14\/19 Debian: Starting with SR-IOV Host machine \u2022 Each VF behaves like a traditional network interface &#8211; below, logical names eth6 eth21\u2192 # ip link show 6: eth0: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc mq master bond0 state UP mode DEFAULT group default qlen 1000 link\/ether a0:36:9f:51:cc:78 brd ff:ff:ff:ff:ff:ff vf 0 MAC 00:00:00:00:00:00, spoof checking on, link-state auto vf 1 MAC 32:b3:0d:59:31:42, spoof checking on, link-state auto vf 2 MAC 7e:9f:5c:09:c8:a6, spoof checking on, link-state auto vf 3 MAC e2:ba:d4:c2:67:3d, spoof checking on, link-state auto vf 4 MAC e6:fd:c3:16:c5:ce, spoof checking on, link-state auto vf 5 MAC f2:6b:58:67:c8:67, spoof checking on, link-state auto vf 6 MAC fe:4c:58:40:ff:59, spoof checking on, link-state auto vf 7 MAC 5e:ad:3a:0b:1e:3f, spoof checking on, link-state auto 7: eth1: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc mq master bond0 state UP mode DEFAULT group default qlen 1000 link\/ether a0:36:9f:51:cc:78 brd ff:ff:ff:ff:ff:ff vf 0 MAC 52:b3:83:97:5d:a6, spoof checking on, link-state auto vf 1 MAC d2:37:28:fb:f5:f8, spoof checking on, link-state auto vf 2 MAC 0e:74:de:f5:b8:2d, spoof checking on, link-state auto vf 3 MAC 32:54:71:e2:f4:da, spoof checking on, link-state auto vf 4 MAC ca:5b:02:0a:c9:b2, spoof checking on, link-state auto vf 5 MAC fa:ff:65:56:95:79, spoof checking on, link-state auto vf 6 MAC 8a:e5:a0:30:32:51, spoof checking on, link-state auto vf 7 MAC 00:00:00:00:00:00, spoof checking on, link-state auto 8 unused VFs on the first PF 8 unused VFs on the second PF<br \/>\n    15. 15\/19 Debian: Starting with SR-IOV Host machine 9: eth6: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000 10: eth7: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000 11: eth8: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000 12: eth9: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000 13: eth10: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000 14: eth11: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000 15: eth12: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000 16: eth13: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000 17: eth14: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000 18: eth15: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000 19: eth16: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000 20: eth17: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000 21: eth18: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000 22: eth19: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000 23: eth20: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000 24: eth21: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000 16virtual interfaces<br \/>\n    16. 16\/19 Debian: PCI passthrough with libvirt Host machine \u2022 Assign two pools of PCIe devices to passthrough ; no need to worry about VF PCI IDs&#8230; Allocation of ressources is dynamic. <\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n# vi \/etc\/libvirt\/qemu\/networks\/pf-eth0.xml \r\n<\/pre>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n&lt;network&gt; \r\n &lt;name&gt;pf-eth0&lt;\/name&gt; \r\n &lt;forward mode=&#039;hostdev&#039; managed=&#039;yes&#039;&gt; \r\n  &lt;driver name=&#039;vfio&#039;\/&gt; \r\n  &lt;pf dev=&#039;eth0&#039;\/&gt; \r\n &lt;\/forward&gt; \r\n&lt;\/network&gt; \r\n<\/pre>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n# virsh net-define \/etc\/libvirt\/qemu\/networks\/pf-eth0.xml \r\n# virsh net-start pf-eth0 \r\n# virsh net-autostart pf-eth0 \r\n# modprobe vfio \r\n# vi \/etc\/libvirt\/qemu\/networks\/pf-eth1.xml \r\n<\/pre>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n&lt;network&gt; \r\n &lt;name&gt;pf-eth1&lt;\/name&gt; \r\n &lt;forward mode=&#039;hostdev&#039; managed=&#039;yes&#039;&gt;\r\n  &lt;driver name=&#039;vfio&#039;\/&gt; \r\n  &lt;pf dev=&#039;eth1&#039;\/&gt; \r\n &lt;\/forward&gt; \r\n&lt;\/network&gt; \r\n<\/pre>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n# virsh net-define \/etc\/libvirt\/qemu\/networks\/pf-eth1.xml \r\n# virsh net-start pf-eth1 \r\n# virsh net-autostart pf-eth1 \r\n# virsh net-list\r\n<\/pre>\n<p>    17. 17\/19 Debian: PCI passthrough with libvirt Host machine \u2022 In each guest XML file, specify the source pool, vlan id as well as (if required) the interface mac address <\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\"># vi \/etc\/libvirt\/qemu\/myguest.xml<\/pre>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">&lt;interface type=&#039;network&#039;&gt; \r\n &lt;source network=&#039;pf-eth&lt;0|1&gt;&#039;\/&gt; \r\n &lt;vlan&gt; \r\n  &lt;tag id=&#039;&lt;vlan_id&gt;&#039;\/&gt; \r\n &lt;\/vlan&gt;\r\n&lt;\/interface&gt;<\/pre>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n# virsh define myguest.xml \r\n# virsh autostart myguest \r\n# virsh start myguest \r\n# vi \/etc\/libvirt\/qemu\/myguest.xml\r\n<\/pre>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n&lt;interface type=&#039;network&#039;&gt; \r\n &lt;mac address=&#039;&lt;mac-address&gt;&#039;\/&gt; \r\n &lt;source network=&#039;pf-eth&lt;0|1&gt;&#039;\/&gt; \r\n  &lt;vlan&gt; \r\n   &lt;tag id=&#039;&lt;vlan_id&gt;&#039;\/&gt; \r\n  &lt;\/vlan&gt; \r\n&lt;\/interface&gt; \r\n<\/pre>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n# virsh define myguest.xml \r\n# virsh autostart myguest \r\n# virsh start myguest\r\n<\/pre>\n<p>OR<br \/>\n    18. 18\/19 Debian: Starting Guest machine \u2022 No prerequisite, nor specific configuration on the guest linux machine \u2022 \u201ca pure\u201d Debian 8 (kernel 3.16.x) works perfectly \u2022 Virtual interfaces are using the driver ixgbevf<br \/>\n    19. 19\/19 University of Nantes \u2013 IT Services Questions Yoann (dot) Juet (at) univ\u2013nantes.fr<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. SR-IOV and KVM virtual machines under GNU\/Linux Debian (Jessie) Intel X520 10Gbps cards Yoann Juet @ University of Nantes, France Information Technology Services Version<\/p>\n<div class=\"more-link-wrapper\"><a class=\"more-link\" href=\"https:\/\/avalon.land\/blog\/networking\/sr-iov-kvm-and-intel-x520-10gbps-cards-on-debianstable\/\">Continue reading<span class=\"screen-reader-text\">SR-IOV, KVM and Intel X520 10Gbps cards on Debian\/Stable<\/span><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14,10],"tags":[],"class_list":["post-280","post","type-post","status-publish","format-standard","hentry","category-it","category-networking","entry"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/avalon.land\/blog\/wp-json\/wp\/v2\/posts\/280","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/avalon.land\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/avalon.land\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/avalon.land\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/avalon.land\/blog\/wp-json\/wp\/v2\/comments?post=280"}],"version-history":[{"count":5,"href":"https:\/\/avalon.land\/blog\/wp-json\/wp\/v2\/posts\/280\/revisions"}],"predecessor-version":[{"id":286,"href":"https:\/\/avalon.land\/blog\/wp-json\/wp\/v2\/posts\/280\/revisions\/286"}],"wp:attachment":[{"href":"https:\/\/avalon.land\/blog\/wp-json\/wp\/v2\/media?parent=280"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/avalon.land\/blog\/wp-json\/wp\/v2\/categories?post=280"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/avalon.land\/blog\/wp-json\/wp\/v2\/tags?post=280"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}