]> git.proxmox.com Git - ovs.git/blob - Documentation/howto/dpdk.rst
a67f3a1facffc745529e761c96d0bde9d065f5c9
[ovs.git] / Documentation / howto / dpdk.rst
1 ..
2 Licensed under the Apache License, Version 2.0 (the "License"); you may
3 not use this file except in compliance with the License. You may obtain
4 a copy of the License at
5
6 http://www.apache.org/licenses/LICENSE-2.0
7
8 Unless required by applicable law or agreed to in writing, software
9 distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
10 WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
11 License for the specific language governing permissions and limitations
12 under the License.
13
14 Convention for heading levels in Open vSwitch documentation:
15
16 ======= Heading 0 (reserved for the title in a document)
17 ------- Heading 1
18 ~~~~~~~ Heading 2
19 +++++++ Heading 3
20 ''''''' Heading 4
21
22 Avoid deeper levels because they do not render well.
23
24 ============================
25 Using Open vSwitch with DPDK
26 ============================
27
28 This document describes how to use Open vSwitch with DPDK datapath.
29
30 .. important::
31
32 Using the DPDK datapath requires building OVS with DPDK support. Refer to
33 :doc:`/intro/install/dpdk` for more information.
34
35 Ports and Bridges
36 -----------------
37
38 ovs-vsctl can be used to set up bridges and other Open vSwitch features.
39 Bridges should be created with a ``datapath_type=netdev``::
40
41 $ ovs-vsctl add-br br0 -- set bridge br0 datapath_type=netdev
42
43 ovs-vsctl can also be used to add DPDK devices. ovs-vswitchd should print the
44 number of dpdk devices found in the log file::
45
46 $ ovs-vsctl add-port br0 dpdk-p0 -- set Interface dpdk-p0 type=dpdk \
47 options:dpdk-devargs=0000:01:00.0
48 $ ovs-vsctl add-port br0 dpdk-p1 -- set Interface dpdk-p1 type=dpdk \
49 options:dpdk-devargs=0000:01:00.1
50
51 After the DPDK ports get added to switch, a polling thread continuously polls
52 DPDK devices and consumes 100% of the core, as can be checked from ``top`` and
53 ``ps`` commands::
54
55 $ top -H
56 $ ps -eLo pid,psr,comm | grep pmd
57
58 Creating bonds of DPDK interfaces is slightly different to creating bonds of
59 system interfaces. For DPDK, the interface type and devargs must be explicitly
60 set. For example::
61
62 $ ovs-vsctl add-bond br0 dpdkbond p0 p1 \
63 -- set Interface p0 type=dpdk options:dpdk-devargs=0000:01:00.0 \
64 -- set Interface p1 type=dpdk options:dpdk-devargs=0000:01:00.1
65
66 To stop ovs-vswitchd & delete bridge, run::
67
68 $ ovs-appctl -t ovs-vswitchd exit
69 $ ovs-appctl -t ovsdb-server exit
70 $ ovs-vsctl del-br br0
71
72 PMD Thread Statistics
73 ---------------------
74
75 To show current stats::
76
77 $ ovs-appctl dpif-netdev/pmd-stats-show
78
79 To clear previous stats::
80
81 $ ovs-appctl dpif-netdev/pmd-stats-clear
82
83 Port/RXQ Assigment to PMD Threads
84 ---------------------------------
85
86 To show port/rxq assignment::
87
88 $ ovs-appctl dpif-netdev/pmd-rxq-show
89
90 To change default rxq assignment to pmd threads, rxqs may be manually pinned to
91 desired cores using::
92
93 $ ovs-vsctl set Interface <iface> \
94 other_config:pmd-rxq-affinity=<rxq-affinity-list>
95
96 where:
97
98 - ``<rxq-affinity-list>`` is a CSV list of ``<queue-id>:<core-id>`` values
99
100 For example::
101
102 $ ovs-vsctl set interface dpdk-p0 options:n_rxq=4 \
103 other_config:pmd-rxq-affinity="0:3,1:7,3:8"
104
105 This will ensure:
106
107 - Queue #0 pinned to core 3
108 - Queue #1 pinned to core 7
109 - Queue #2 not pinned
110 - Queue #3 pinned to core 8
111
112 After that PMD threads on cores where RX queues was pinned will become
113 ``isolated``. This means that this thread will poll only pinned RX queues.
114
115 .. warning::
116 If there are no ``non-isolated`` PMD threads, ``non-pinned`` RX queues will
117 not be polled. Also, if provided ``core_id`` is not available (ex. this
118 ``core_id`` not in ``pmd-cpu-mask``), RX queue will not be polled by any PMD
119 thread.
120
121 If pmd-rxq-affinity is not set for rxqs, they will be assigned to pmds (cores)
122 automatically. The processing cycles that have been stored for each rxq
123 will be used where known to assign rxqs to pmd based on a round robin of the
124 sorted rxqs.
125
126 Rxq to pmds assignment takes place whenever there are configuration changes.
127
128 QoS
129 ---
130
131 Assuming you have a vhost-user port transmitting traffic consisting of packets
132 of size 64 bytes, the following command would limit the egress transmission
133 rate of the port to ~1,000,000 packets per second::
134
135 $ ovs-vsctl set port vhost-user0 qos=@newqos -- \
136 --id=@newqos create qos type=egress-policer other-config:cir=46000000 \
137 other-config:cbs=2048`
138
139 To examine the QoS configuration of the port, run::
140
141 $ ovs-appctl -t ovs-vswitchd qos/show vhost-user0
142
143 To clear the QoS configuration from the port and ovsdb, run::
144
145 $ ovs-vsctl destroy QoS vhost-user0 -- clear Port vhost-user0 qos
146
147 Refer to vswitch.xml for more details on egress-policer.
148
149 Rate Limiting
150 --------------
151
152 Here is an example on Ingress Policing usage. Assuming you have a vhost-user
153 port receiving traffic consisting of packets of size 64 bytes, the following
154 command would limit the reception rate of the port to ~1,000,000 packets per
155 second::
156
157 $ ovs-vsctl set interface vhost-user0 ingress_policing_rate=368000 \
158 ingress_policing_burst=1000`
159
160 To examine the ingress policer configuration of the port::
161
162 $ ovs-vsctl list interface vhost-user0
163
164 To clear the ingress policer configuration from the port::
165
166 $ ovs-vsctl set interface vhost-user0 ingress_policing_rate=0
167
168 Refer to vswitch.xml for more details on ingress-policer.
169
170 Flow Control
171 ------------
172
173 Flow control can be enabled only on DPDK physical ports. To enable flow control
174 support at tx side while adding a port, run::
175
176 $ ovs-vsctl add-port br0 dpdk-p0 -- set Interface dpdk-p0 type=dpdk \
177 options:dpdk-devargs=0000:01:00.0 options:tx-flow-ctrl=true
178
179 Similarly, to enable rx flow control, run::
180
181 $ ovs-vsctl add-port br0 dpdk-p0 -- set Interface dpdk-p0 type=dpdk \
182 options:dpdk-devargs=0000:01:00.0 options:rx-flow-ctrl=true
183
184 To enable flow control auto-negotiation, run::
185
186 $ ovs-vsctl add-port br0 dpdk-p0 -- set Interface dpdk-p0 type=dpdk \
187 options:dpdk-devargs=0000:01:00.0 options:flow-ctrl-autoneg=true
188
189 To turn ON the tx flow control at run time for an existing port, run::
190
191 $ ovs-vsctl set Interface dpdk-p0 options:tx-flow-ctrl=true
192
193 The flow control parameters can be turned off by setting ``false`` to the
194 respective parameter. To disable the flow control at tx side, run::
195
196 $ ovs-vsctl set Interface dpdk-p0 options:tx-flow-ctrl=false
197
198 pdump
199 -----
200
201 pdump allows you to listen on DPDK ports and view the traffic that is passing
202 on them. To use this utility, one must have libpcap installed on the system.
203 Furthermore, DPDK must be built with ``CONFIG_RTE_LIBRTE_PDUMP=y`` and
204 ``CONFIG_RTE_LIBRTE_PMD_PCAP=y``.
205
206 .. warning::
207 A performance decrease is expected when using a monitoring application like
208 the DPDK pdump app.
209
210 To use pdump, simply launch OVS as usual, then navigate to the ``app/pdump``
211 directory in DPDK, ``make`` the application and run like so::
212
213 $ sudo ./build/app/dpdk-pdump -- \
214 --pdump port=0,queue=0,rx-dev=/tmp/pkts.pcap \
215 --server-socket-path=/usr/local/var/run/openvswitch
216
217 The above command captures traffic received on queue 0 of port 0 and stores it
218 in ``/tmp/pkts.pcap``. Other combinations of port numbers, queues numbers and
219 pcap locations are of course also available to use. For example, to capture all
220 packets that traverse port 0 in a single pcap file::
221
222 $ sudo ./build/app/dpdk-pdump -- \
223 --pdump 'port=0,queue=*,rx-dev=/tmp/pkts.pcap,tx-dev=/tmp/pkts.pcap' \
224 --server-socket-path=/usr/local/var/run/openvswitch
225
226 ``server-socket-path`` must be set to the value of ``ovs_rundir()`` which
227 typically resolves to ``/usr/local/var/run/openvswitch``.
228
229 Many tools are available to view the contents of the pcap file. Once example is
230 tcpdump. Issue the following command to view the contents of ``pkts.pcap``::
231
232 $ tcpdump -r pkts.pcap
233
234 More information on the pdump app and its usage can be found in the `DPDK docs
235 <http://dpdk.org/doc/guides/tools/pdump.html>`__.
236
237 Jumbo Frames
238 ------------
239
240 By default, DPDK ports are configured with standard Ethernet MTU (1500B). To
241 enable Jumbo Frames support for a DPDK port, change the Interface's
242 ``mtu_request`` attribute to a sufficiently large value. For example, to add a
243 DPDK Phy port with MTU of 9000::
244
245 $ ovs-vsctl add-port br0 dpdk-p0 -- set Interface dpdk-p0 type=dpdk \
246 options:dpdk-devargs=0000:01:00.0 mtu_request=9000
247
248 Similarly, to change the MTU of an existing port to 6200::
249
250 $ ovs-vsctl set Interface dpdk-p0 mtu_request=6200
251
252 Some additional configuration is needed to take advantage of jumbo frames with
253 vHost ports:
254
255 1. *mergeable buffers* must be enabled for vHost ports, as demonstrated in the
256 QEMU command line snippet below::
257
258 -netdev type=vhost-user,id=mynet1,chardev=char0,vhostforce \
259 -device virtio-net-pci,mac=00:00:00:00:00:01,netdev=mynet1,mrg_rxbuf=on
260
261 2. Where virtio devices are bound to the Linux kernel driver in a guest
262 environment (i.e. interfaces are not bound to an in-guest DPDK driver), the
263 MTU of those logical network interfaces must also be increased to a
264 sufficiently large value. This avoids segmentation of Jumbo Frames received
265 in the guest. Note that 'MTU' refers to the length of the IP packet only,
266 and not that of the entire frame.
267
268 To calculate the exact MTU of a standard IPv4 frame, subtract the L2 header
269 and CRC lengths (i.e. 18B) from the max supported frame size. So, to set
270 the MTU for a 9018B Jumbo Frame::
271
272 $ ip link set eth1 mtu 9000
273
274 When Jumbo Frames are enabled, the size of a DPDK port's mbuf segments are
275 increased, such that a full Jumbo Frame of a specific size may be accommodated
276 within a single mbuf segment.
277
278 Jumbo frame support has been validated against 9728B frames, which is the
279 largest frame size supported by Fortville NIC using the DPDK i40e driver, but
280 larger frames and other DPDK NIC drivers may be supported. These cases are
281 common for use cases involving East-West traffic only.
282
283 Rx Checksum Offload
284 -------------------
285
286 By default, DPDK physical ports are enabled with Rx checksum offload.
287
288 Rx checksum offload can offer performance improvement only for tunneling
289 traffic in OVS-DPDK because the checksum validation of tunnel packets is
290 offloaded to the NIC. Also enabling Rx checksum may slightly reduce the
291 performance of non-tunnel traffic, specifically for smaller size packet.
292
293 .. _extended-statistics:
294
295 Extended Statistics
296 -------------------
297
298 DPDK Extended Statistics API allows PMD to expose unique set of statistics.
299 The Extended statistics are implemented and supported only for DPDK physical
300 and vHost ports.
301
302 To enable statistics, you have to enable OpenFlow 1.4 support for OVS.
303 Configure bridge br0 to support OpenFlow version 1.4::
304
305 $ ovs-vsctl set bridge br0 datapath_type=netdev \
306 protocols=OpenFlow10,OpenFlow11,OpenFlow12,OpenFlow13,OpenFlow14
307
308 Check the OVSDB protocols column in the bridge table if OpenFlow 1.4 support
309 is enabled for OVS::
310
311 $ ovsdb-client dump Bridge protocols
312
313 Query the port statistics by explicitly specifying -O OpenFlow14 option::
314
315 $ ovs-ofctl -O OpenFlow14 dump-ports br0
316
317 Note: vHost ports supports only partial statistics. RX packet size based
318 counter are only supported and doesn't include TX packet size counters.
319
320 .. _port-hotplug:
321
322 Port Hotplug
323 ------------
324
325 OVS supports port hotplugging, allowing the use of ports that were not bound
326 to DPDK when vswitchd was started.
327 In order to attach a port, it has to be bound to DPDK using the
328 ``dpdk_nic_bind.py`` script::
329
330 $ $DPDK_DIR/tools/dpdk_nic_bind.py --bind=igb_uio 0000:01:00.0
331
332 Then it can be attached to OVS::
333
334 $ ovs-vsctl add-port br0 dpdkx -- set Interface dpdkx type=dpdk \
335 options:dpdk-devargs=0000:01:00.0
336
337 Detaching will be performed while processing del-port command::
338
339 $ ovs-vsctl del-port dpdkx
340
341 Sometimes, the del-port command may not detach the device.
342 Detaching can be confirmed by the appearance of an INFO log.
343 For example::
344
345 INFO|Device '0000:04:00.1' has been detached
346
347 If the log is not seen, then the port can be detached using::
348
349 $ ovs-appctl netdev-dpdk/detach 0000:01:00.0
350
351 Detaching can be confirmed by console output::
352
353 Device '0000:04:00.1' has been detached
354
355 .. warning::
356 Detaching should not be done if a device is known to be non-detachable, as
357 this may cause the device to behave improperly when added back with
358 add-port. The Chelsio Terminator adapters which use the cxgbe driver seem
359 to be an example of this behavior; check the driver documentation if this
360 is suspected.
361
362 This feature does not work with some NICs.
363 For more information please refer to the `DPDK Port Hotplug Framework
364 <http://dpdk.org/doc/guides/prog_guide/port_hotplug_framework.html#hotplug>`__.
365
366 .. _vdev-support:
367
368 Vdev Support
369 ------------
370
371 DPDK provides drivers for both physical and virtual devices. Physical DPDK
372 devices are added to OVS by specifying a valid PCI address in 'dpdk-devargs'.
373 Virtual DPDK devices which do not have PCI addresses can be added using a
374 different format for 'dpdk-devargs'.
375
376 Typically, the format expected is 'eth_<driver_name><x>' where 'x' is a
377 unique identifier of your choice for the given port.
378
379 For example to add a dpdk port that uses the 'null' DPDK PMD driver::
380
381 $ ovs-vsctl add-port br0 null0 -- set Interface null0 type=dpdk \
382 options:dpdk-devargs=eth_null0
383
384 Similarly, to add a dpdk port that uses the 'af_packet' DPDK PMD driver::
385
386 $ ovs-vsctl add-port br0 myeth0 -- set Interface myeth0 type=dpdk \
387 options:dpdk-devargs=eth_af_packet0,iface=eth0
388
389 More information on the different types of virtual DPDK PMDs can be found in
390 the `DPDK documentation
391 <http://dpdk.org/doc/guides/nics/overview.html>`__.
392
393 Note: Not all DPDK virtual PMD drivers have been tested and verified to work.
394
395 EMC Insertion Probability
396 -------------------------
397 By default 1 in every 100 flows are inserted into the Exact Match Cache (EMC).
398 It is possible to change this insertion probability by setting the
399 ``emc-insert-inv-prob`` option::
400
401 $ ovs-vsctl --no-wait set Open_vSwitch . other_config:emc-insert-inv-prob=N
402
403 where:
404
405 ``N``
406 is a positive integer representing the inverse probability of insertion ie.
407 on average 1 in every N packets with a unique flow will generate an EMC
408 insertion.
409
410 If ``N`` is set to 1, an insertion will be performed for every flow. If set to
411 0, no insertions will be performed and the EMC will effectively be disabled.
412
413 With default ``N`` set to 100, higher megaflow hits will occur initially
414 as observed with pmd stats::
415
416 $ ovs-appctl dpif-netdev/pmd-stats-show
417
418 For certain traffic profiles with many parallel flows, it's recommended to set
419 ``N`` to '0' to achieve higher forwarding performance.
420
421 For more information on the EMC refer to :doc:`/intro/install/dpdk` .
422
423 .. _dpdk-ovs-in-guest:
424
425 OVS with DPDK Inside VMs
426 ------------------------
427
428 Additional configuration is required if you want to run ovs-vswitchd with DPDK
429 backend inside a QEMU virtual machine. ovs-vswitchd creates separate DPDK TX
430 queues for each CPU core available. This operation fails inside QEMU virtual
431 machine because, by default, VirtIO NIC provided to the guest is configured to
432 support only single TX queue and single RX queue. To change this behavior, you
433 need to turn on ``mq`` (multiqueue) property of all ``virtio-net-pci`` devices
434 emulated by QEMU and used by DPDK. You may do it manually (by changing QEMU
435 command line) or, if you use Libvirt, by adding the following string to
436 ``<interface>`` sections of all network devices used by DPDK::
437
438 <driver name='vhost' queues='N'/>
439
440 where:
441
442 ``N``
443 determines how many queues can be used by the guest.
444
445 This requires QEMU >= 2.2.
446
447 .. _dpdk-phy-phy:
448
449 PHY-PHY
450 -------
451
452 Add a userspace bridge and two ``dpdk`` (PHY) ports::
453
454 # Add userspace bridge
455 $ ovs-vsctl add-br br0 -- set bridge br0 datapath_type=netdev
456
457 # Add two dpdk ports
458 $ ovs-vsctl add-port br0 phy0 -- set Interface phy0 type=dpdk \
459 options:dpdk-devargs=0000:01:00.0 ofport_request=1
460
461 $ ovs-vsctl add-port br0 phy1 -- set Interface phy1 type=dpdk
462 options:dpdk-devargs=0000:01:00.1 ofport_request=2
463
464 Add test flows to forward packets betwen DPDK port 0 and port 1::
465
466 # Clear current flows
467 $ ovs-ofctl del-flows br0
468
469 # Add flows between port 1 (phy0) to port 2 (phy1)
470 $ ovs-ofctl add-flow br0 in_port=1,action=output:2
471 $ ovs-ofctl add-flow br0 in_port=2,action=output:1
472
473 Transmit traffic into either port. You should see it returned via the other.
474
475 .. _dpdk-vhost-loopback:
476
477 PHY-VM-PHY (vHost Loopback)
478 ---------------------------
479
480 Add a userspace bridge, two ``dpdk`` (PHY) ports, and two ``dpdkvhostuser``
481 ports::
482
483 # Add userspace bridge
484 $ ovs-vsctl add-br br0 -- set bridge br0 datapath_type=netdev
485
486 # Add two dpdk ports
487 $ ovs-vsctl add-port br0 phy0 -- set Interface phy0 type=dpdk \
488 options:dpdk-devargs=0000:01:00.0 ofport_request=1
489
490 $ ovs-vsctl add-port br0 phy1 -- set Interface phy1 type=dpdk
491 options:dpdk-devargs=0000:01:00.1 ofport_request=2
492
493 # Add two dpdkvhostuser ports
494 $ ovs-vsctl add-port br0 dpdkvhostuser0 \
495 -- set Interface dpdkvhostuser0 type=dpdkvhostuser ofport_request=3
496 $ ovs-vsctl add-port br0 dpdkvhostuser1 \
497 -- set Interface dpdkvhostuser1 type=dpdkvhostuser ofport_request=4
498
499 Add test flows to forward packets betwen DPDK devices and VM ports::
500
501 # Clear current flows
502 $ ovs-ofctl del-flows br0
503
504 # Add flows
505 $ ovs-ofctl add-flow br0 in_port=1,action=output:3
506 $ ovs-ofctl add-flow br0 in_port=3,action=output:1
507 $ ovs-ofctl add-flow br0 in_port=4,action=output:2
508 $ ovs-ofctl add-flow br0 in_port=2,action=output:4
509
510 # Dump flows
511 $ ovs-ofctl dump-flows br0
512
513 Create a VM using the following configuration:
514
515 +----------------------+--------+-----------------+
516 | configuration | values | comments |
517 +----------------------+--------+-----------------+
518 | qemu version | 2.2.0 | n/a |
519 | qemu thread affinity | core 5 | taskset 0x20 |
520 | memory | 4GB | n/a |
521 | cores | 2 | n/a |
522 | Qcow2 image | CentOS7| n/a |
523 | mrg_rxbuf | off | n/a |
524 +----------------------+--------+-----------------+
525
526 You can do this directly with QEMU via the ``qemu-system-x86_64`` application::
527
528 $ export VM_NAME=vhost-vm
529 $ export GUEST_MEM=3072M
530 $ export QCOW2_IMAGE=/root/CentOS7_x86_64.qcow2
531 $ export VHOST_SOCK_DIR=/usr/local/var/run/openvswitch
532
533 $ taskset 0x20 qemu-system-x86_64 -name $VM_NAME -cpu host -enable-kvm \
534 -m $GUEST_MEM -drive file=$QCOW2_IMAGE --nographic -snapshot \
535 -numa node,memdev=mem -mem-prealloc -smp sockets=1,cores=2 \
536 -object memory-backend-file,id=mem,size=$GUEST_MEM,mem-path=/dev/hugepages,share=on \
537 -chardev socket,id=char0,path=$VHOST_SOCK_DIR/dpdkvhostuser0 \
538 -netdev type=vhost-user,id=mynet1,chardev=char0,vhostforce \
539 -device virtio-net-pci,mac=00:00:00:00:00:01,netdev=mynet1,mrg_rxbuf=off \
540 -chardev socket,id=char1,path=$VHOST_SOCK_DIR/dpdkvhostuser1 \
541 -netdev type=vhost-user,id=mynet2,chardev=char1,vhostforce \
542 -device virtio-net-pci,mac=00:00:00:00:00:02,netdev=mynet2,mrg_rxbuf=off
543
544 For a explanation of this command, along with alternative approaches such as
545 booting the VM via libvirt, refer to :doc:`/topics/dpdk/vhost-user`.
546
547 Once the guest is configured and booted, configure DPDK packet forwarding
548 within the guest. To accomplish this, build the ``testpmd`` application as
549 described in :ref:`dpdk-testpmd`. Once compiled, run the application::
550
551 $ cd $DPDK_DIR/app/test-pmd;
552 $ ./testpmd -c 0x3 -n 4 --socket-mem 1024 -- \
553 --burst=64 -i --txqflags=0xf00 --disable-hw-vlan
554 $ set fwd mac retry
555 $ start
556
557 When you finish testing, bind the vNICs back to kernel::
558
559 $ $DPDK_DIR/usertools/dpdk-devbind.py --bind=virtio-pci 0000:00:03.0
560 $ $DPDK_DIR/usertools/dpdk-devbind.py --bind=virtio-pci 0000:00:04.0
561
562 .. note::
563
564 Valid PCI IDs must be passed in above example. The PCI IDs can be retrieved
565 like so::
566
567 $ $DPDK_DIR/usertools/dpdk-devbind.py --status
568
569 More information on the dpdkvhostuser ports can be found in
570 :doc:`/topics/dpdk/vhost-user`.
571
572 PHY-VM-PHY (vHost Loopback) (Kernel Forwarding)
573 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
574
575 :ref:`dpdk-vhost-loopback` details steps for PHY-VM-PHY loopback
576 testcase and packet forwarding using DPDK testpmd application in the Guest VM.
577 For users wishing to do packet forwarding using kernel stack below, you need to
578 run the below commands on the guest::
579
580 $ ip addr add 1.1.1.2/24 dev eth1
581 $ ip addr add 1.1.2.2/24 dev eth2
582 $ ip link set eth1 up
583 $ ip link set eth2 up
584 $ systemctl stop firewalld.service
585 $ systemctl stop iptables.service
586 $ sysctl -w net.ipv4.ip_forward=1
587 $ sysctl -w net.ipv4.conf.all.rp_filter=0
588 $ sysctl -w net.ipv4.conf.eth1.rp_filter=0
589 $ sysctl -w net.ipv4.conf.eth2.rp_filter=0
590 $ route add -net 1.1.2.0/24 eth2
591 $ route add -net 1.1.1.0/24 eth1
592 $ arp -s 1.1.2.99 DE:AD:BE:EF:CA:FE
593 $ arp -s 1.1.1.99 DE:AD:BE:EF:CA:EE
594
595 PHY-VM-PHY (vHost Multiqueue)
596 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
597
598 vHost Multiqueue functionality can also be validated using the PHY-VM-PHY
599 configuration. To begin, follow the steps described in :ref:`dpdk-phy-phy` to
600 create and initialize the database, start ovs-vswitchd and add ``dpdk``-type
601 devices to bridge ``br0``. Once complete, follow the below steps:
602
603 1. Configure PMD and RXQs.
604
605 For example, set the number of dpdk port rx queues to at least 2 The number
606 of rx queues at vhost-user interface gets automatically configured after
607 virtio device connection and doesn't need manual configuration::
608
609 $ ovs-vsctl set Open_vSwitch . other_config:pmd-cpu-mask=0xc
610 $ ovs-vsctl set Interface phy0 options:n_rxq=2
611 $ ovs-vsctl set Interface phy1 options:n_rxq=2
612
613 2. Instantiate Guest VM using QEMU cmdline
614
615 We must configure with appropriate software versions to ensure this feature
616 is supported.
617
618 .. list-table:: Recommended BIOS Settings
619 :header-rows: 1
620
621 * - Setting
622 - Value
623 * - QEMU version
624 - 2.5.0
625 * - QEMU thread affinity
626 - 2 cores (taskset 0x30)
627 * - Memory
628 - 4 GB
629 * - Cores
630 - 2
631 * - Distro
632 - Fedora 22
633 * - Multiqueue
634 - Enabled
635
636 To do this, instantiate the guest as follows::
637
638 $ export VM_NAME=vhost-vm
639 $ export GUEST_MEM=4096M
640 $ export QCOW2_IMAGE=/root/Fedora22_x86_64.qcow2
641 $ export VHOST_SOCK_DIR=/usr/local/var/run/openvswitch
642 $ taskset 0x30 qemu-system-x86_64 -cpu host -smp 2,cores=2 -m 4096M \
643 -drive file=$QCOW2_IMAGE --enable-kvm -name $VM_NAME \
644 -nographic -numa node,memdev=mem -mem-prealloc \
645 -object memory-backend-file,id=mem,size=$GUEST_MEM,mem-path=/dev/hugepages,share=on \
646 -chardev socket,id=char1,path=$VHOST_SOCK_DIR/dpdkvhostuser0 \
647 -netdev type=vhost-user,id=mynet1,chardev=char1,vhostforce,queues=2 \
648 -device virtio-net-pci,mac=00:00:00:00:00:01,netdev=mynet1,mq=on,vectors=6 \
649 -chardev socket,id=char2,path=$VHOST_SOCK_DIR/dpdkvhostuser1 \
650 -netdev type=vhost-user,id=mynet2,chardev=char2,vhostforce,queues=2 \
651 -device virtio-net-pci,mac=00:00:00:00:00:02,netdev=mynet2,mq=on,vectors=6
652
653 .. note::
654 Queue value above should match the queues configured in OVS, The vector
655 value should be set to "number of queues x 2 + 2"
656
657 3. Configure the guest interface
658
659 Assuming there are 2 interfaces in the guest named eth0, eth1 check the
660 channel configuration and set the number of combined channels to 2 for
661 virtio devices::
662
663 $ ethtool -l eth0
664 $ ethtool -L eth0 combined 2
665 $ ethtool -L eth1 combined 2
666
667 More information can be found in vHost walkthrough section.
668
669 4. Configure kernel packet forwarding
670
671 Configure IP and enable interfaces::
672
673 $ ip addr add 5.5.5.1/24 dev eth0
674 $ ip addr add 90.90.90.1/24 dev eth1
675 $ ip link set eth0 up
676 $ ip link set eth1 up
677
678 Configure IP forwarding and add route entries::
679
680 $ sysctl -w net.ipv4.ip_forward=1
681 $ sysctl -w net.ipv4.conf.all.rp_filter=0
682 $ sysctl -w net.ipv4.conf.eth0.rp_filter=0
683 $ sysctl -w net.ipv4.conf.eth1.rp_filter=0
684 $ ip route add 2.1.1.0/24 dev eth1
685 $ route add default gw 2.1.1.2 eth1
686 $ route add default gw 90.90.90.90 eth1
687 $ arp -s 90.90.90.90 DE:AD:BE:EF:CA:FE
688 $ arp -s 2.1.1.2 DE:AD:BE:EF:CA:FA
689
690 Check traffic on multiple queues::
691
692 $ cat /proc/interrupts | grep virtio