datapath-windows: Avoid BSOD when no event queue found.
[cascardo/ovs.git] / INSTALL.DPDK
1                    Using Open vSwitch with DPDK
2                    ============================
3
4 Open vSwitch can use Intel(R) DPDK lib to operate entirely in
5 userspace. This file explains how to install and use Open vSwitch in
6 such a mode.
7
8 The DPDK support of Open vSwitch is considered experimental.
9 It has not been thoroughly tested.
10
11 This version of Open vSwitch should be built manually with "configure"
12 and "make".
13
14 OVS needs a system with 1GB hugepages support.
15
16 Building and Installing:
17 ------------------------
18
19 Required DPDK 1.7
20
21 DPDK:
22 Set dir i.g.:   export DPDK_DIR=/usr/src/dpdk-1.7.1
23 cd $DPDK_DIR
24 update config/common_linuxapp so that dpdk generate single lib file.
25 (modification also required for IVSHMEM build)
26 CONFIG_RTE_BUILD_COMBINE_LIBS=y
27
28 For default install without IVSHMEM:
29 make install T=x86_64-native-linuxapp-gcc
30 To include IVSHMEM (shared memory):
31 make install T=x86_64-ivshmem-linuxapp-gcc
32 For details refer to  http://dpdk.org/
33
34 Linux kernel:
35 Refer to intel-dpdk-getting-started-guide.pdf for understanding
36 DPDK kernel requirement.
37
38 OVS:
39 Non IVSHMEM:
40 export DPDK_BUILD=$DPDK_DIR/x86_64-native-linuxapp-gcc/
41 IVSHMEM:
42 export DPDK_BUILD=$DPDK_DIR/x86_64-ivshmem-linuxapp-gcc/
43
44 cd $(OVS_DIR)/openvswitch
45 ./boot.sh
46 ./configure --with-dpdk=$DPDK_BUILD
47 make
48
49 To have better performance one can enable aggressive compiler optimizations and
50 use the special instructions(popcnt, crc32) that may not be available on all
51 machines. Instead of typing 'make', type:
52
53 make CFLAGS='-O3 -march=native'
54
55 Refer to INSTALL.userspace for general requirements of building
56 userspace OVS.
57
58 Using the DPDK with ovs-vswitchd:
59 ---------------------------------
60
61 Setup system boot:
62    kernel bootline, add: default_hugepagesz=1GB hugepagesz=1G hugepages=1
63
64 First setup DPDK devices:
65   - insert uio.ko
66     e.g. modprobe uio
67   - insert igb_uio.ko
68     e.g. insmod $DPDK_BUILD/kmod/igb_uio.ko
69   - Bind network device to igb_uio.
70     e.g. $DPDK_DIR/tools/dpdk_nic_bind.py --bind=igb_uio eth1
71
72 Prepare system:
73   - mount hugetlbfs
74     e.g. mount -t hugetlbfs -o pagesize=1G none /dev/hugepages
75
76 Ref to http://www.dpdk.org/doc/quick-start for verifying DPDK setup.
77
78 Start ovsdb-server as discussed in INSTALL doc:
79   Summary e.g.:
80     First time only db creation (or clearing):
81       mkdir -p /usr/local/etc/openvswitch
82       mkdir -p /usr/local/var/run/openvswitch
83       rm /usr/local/etc/openvswitch/conf.db
84       cd $OVS_DIR
85       ./ovsdb/ovsdb-tool create /usr/local/etc/openvswitch/conf.db \
86         ./vswitchd/vswitch.ovsschema
87     start ovsdb-server
88       cd $OVS_DIR
89       ./ovsdb/ovsdb-server --remote=punix:/usr/local/var/run/openvswitch/db.sock \
90           --remote=db:Open_vSwitch,Open_vSwitch,manager_options \
91           --private-key=db:Open_vSwitch,SSL,private_key \
92           --certificate=Open_vSwitch,SSL,certificate \
93           --bootstrap-ca-cert=db:Open_vSwitch,SSL,ca_cert --pidfile --detach
94     First time after db creation, initialize:
95       cd $OVS_DIR
96       ./utilities/ovs-vsctl --no-wait init
97
98 Start vswitchd:
99 DPDK configuration arguments can be passed to vswitchd via `--dpdk`
100 argument. This needs to be first argument passed to vswitchd process.
101 dpdk arg -c is ignored by ovs-dpdk, but it is a required parameter
102 for dpdk initialization.
103
104    e.g.
105    export DB_SOCK=/usr/local/var/run/openvswitch/db.sock
106    ./vswitchd/ovs-vswitchd --dpdk -c 0x1 -n 4 -- unix:$DB_SOCK --pidfile --detach
107
108 If allocated more than one GB hugepage (as for IVSHMEM), set amount and use NUMA
109 node 0 memory:
110
111    ./vswitchd/ovs-vswitchd --dpdk -c 0x1 -n 4 --socket-mem 1024,0 \
112       -- unix:$DB_SOCK --pidfile --detach
113
114 To use ovs-vswitchd with DPDK, create a bridge with datapath_type
115 "netdev" in the configuration database.  For example:
116
117     ovs-vsctl add-br br0 -- set bridge br0 datapath_type=netdev
118
119 Now you can add dpdk devices. OVS expect DPDK device name start with dpdk
120 and end with portid. vswitchd should print (in the log file) the number of dpdk
121 devices found.
122
123     ovs-vsctl add-port br0 dpdk0 -- set Interface dpdk0 type=dpdk
124     ovs-vsctl add-port br0 dpdk1 -- set Interface dpdk1 type=dpdk
125
126 Once first DPDK port is added to vswitchd, it creates a Polling thread and
127 polls dpdk device in continuous loop. Therefore CPU utilization
128 for that thread is always 100%.
129
130 Test flow script across NICs (assuming ovs in /usr/src/ovs):
131   Execute script:
132
133 ############################# Script:
134
135 #! /bin/sh
136 # Move to command directory
137 cd /usr/src/ovs/utilities/
138
139 # Clear current flows
140 ./ovs-ofctl del-flows br0
141
142 # Add flows between port 1 (dpdk0) to port 2 (dpdk1)
143 ./ovs-ofctl add-flow br0 in_port=1,action=output:2
144 ./ovs-ofctl add-flow br0 in_port=2,action=output:1
145
146 ######################################
147
148 With pmd multi-threading support, OVS creates one pmd thread for each
149 numa node as default.  The pmd thread handles the I/O of all DPDK
150 interfaces on the same numa node.  The following two commands can be used
151 to configure the multi-threading behavior.
152
153     ovs-vsctl set Open_vSwitch . other_config:pmd-cpu-mask=<hex string>
154
155 The command above asks for a CPU mask for setting the affinity of pmd threads.
156 A set bit in the mask means a pmd thread is created and pinned to the
157 corresponding CPU core.  For more information, please refer to
158 `man ovs-vswitchd.conf.db`
159
160     ovs-vsctl set Open_vSwitch . other_config:n-dpdk-rxqs=<integer>
161
162 The command above sets the number of rx queues of each DPDK interface.  The
163 rx queues are assigned to pmd threads on the same numa node in round-robin
164 fashion.  For more information, please refer to `man ovs-vswitchd.conf.db`
165
166 Ideally for maximum throughput, the pmd thread should not be scheduled out
167 which temporarily halts its execution. The following affinitization methods
168 can help.
169
170 Lets pick core 4,6,8,10 for pmd threads to run on.  Also assume a dual 8 core
171 sandy bridge system with hyperthreading enabled where CPU1 has cores 0,...,7
172 and 16,...,23 & CPU2 cores 8,...,15 & 24,...,31.  (A different cpu
173 configuration could have different core mask requirements).
174
175 To kernel bootline add core isolation list for cores and associated hype cores
176 (e.g.  isolcpus=4,20,6,22,8,24,10,26,).  Reboot system for isolation to take
177 effect, restart everything.
178
179 Configure pmd threads on core 4,6,8,10 using 'pmd-cpu-mask':
180
181     ovs-vsctl set Open_vSwitch . other_config:pmd-cpu-mask=00000550
182
183 You should be able to check that pmd threads are pinned to the correct cores
184 via:
185
186     top -p `pidof ovs-vswitchd` -H -d1
187
188 Note, the pmd threads on a numa node are only created if there is at least
189 one DPDK interface from the numa node that has been added to OVS.
190
191 Note, core 0 is always reserved from non-pmd threads and should never be set
192 in the cpu mask.
193
194 DPDK Rings :
195 ------------
196
197 Following the steps above to create a bridge, you can now add dpdk rings
198 as a port to the vswitch.  OVS will expect the DPDK ring device name to
199 start with dpdkr and end with a portid.
200
201     ovs-vsctl add-port br0 dpdkr0 -- set Interface dpdkr0 type=dpdkr
202
203 DPDK rings client test application
204
205 Included in the test directory is a sample DPDK application for testing
206 the rings.  This is from the base dpdk directory and modified to work
207 with the ring naming used within ovs.
208
209 location tests/ovs_client
210
211 To run the client :
212   cd /usr/src/ovs/tests/
213   ovsclient -c 1 -n 4 --proc-type=secondary -- -n "port id you gave dpdkr"
214
215 In the case of the dpdkr example above the "port id you gave dpdkr" is 0.
216
217 It is essential to have --proc-type=secondary
218
219 The application simply receives an mbuf on the receive queue of the
220 ethernet ring and then places that same mbuf on the transmit ring of
221 the ethernet ring.  It is a trivial loopback application.
222
223 DPDK rings in VM (IVSHMEM shared memory communications)
224 -------------------------------------------------------
225
226 In addition to executing the client in the host, you can execute it within
227 a guest VM. To do so you will need a patched qemu.  You can download the
228 patch and getting started guide at :
229
230 https://01.org/packet-processing/downloads
231
232 A general rule of thumb for better performance is that the client
233 application should not be assigned the same dpdk core mask "-c" as
234 the vswitchd.
235
236 Restrictions:
237 -------------
238
239   - This Support is for Physical NIC. I have tested with Intel NIC only.
240   - Work with 1500 MTU, needs few changes in DPDK lib to fix this issue.
241   - Currently DPDK port does not make use any offload functionality.
242
243   ivshmem:
244      - The shared memory is currently restricted to the use of a 1GB
245        huge pages.
246      - All huge pages are shared amongst the host, clients, virtual
247        machines etc.
248
249 Bug Reporting:
250 --------------
251
252 Please report problems to bugs@openvswitch.org.