DPDK logo

Elixir Cross Referencer

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
## Table of Contents

- [Sample usage of the application](#sample-usage-of-the-application)
  - [Compilation](#compilation)
  - [Start Controller](#start-controller)
  - [Start spp_primary](#start-spp_primary)
  - [Start spp_nfv](#start-spp_nfv)
  - [Start spp_vm](#start-spp_vm)

- [Test Setups](#test-setups)
  - [Test Setup 1: Single NFV](#test-setup-1-single-nfv)
  - [Test Setup 2: Dual NFV](#test-setup-2-dual-nfv)
  - [Test Setup 3: Dual NFV with ring pmd](#test-setup-3-dual-nfv-with-ring-pmd)
  - [Test Setup 4: Single NFV with VM through vhost pmd](#test-setup-4-single-nfv-with-vm-through-vhost-pmd)
- [Optimizing qemu performance](#optimizing-qemu-performance)


## Sample usage of the application

### Compilation

Compile DPDK 
* Change to DPDK directory
* Set `RTE_SDK` variable to current folder
* Set `RTE_TARGET` variable to any valid target.
* Compile DPDK: "make T=x86_64-native-linuxapp-gcc install"

Compile SPP
* Change to SPP directory
* Compile SPP: "make"

### Start Controller

First, start spp.py with port numbers for spp_primary and secondary processes.

```sh
$ python spp.py -p 5555 -s 6666
primary port : 5555
secondary port : 6666
Welcome to the spp.   Type help or ? to list commands.

spp >
```

### Start spp_primary

Start spp_primary with SPP options.
* -p: port mask
* -n: number of ring
* -s: IP address of controller and port for primary

```sh
$ sudo ./src/primary/src/primary/x86_64-native-linuxapp-gcc/spp_primary \
	-c 0x02 -n 4 \
	--socket-mem 512,512 \
	--huge-dir=/dev/hugepages \
	--proc-type=primary \
	-- \
	-p 0x03 \
	-n 4 \
	-s 192.168.122.1:5555
```

### Start spp_nfv

There are two types fo secondary, spp_nfv and spp_vm.

Start two spp_nfv with SPP Options
* -n: seconary id (n > 0)
* -s: ipaddr of controller and port for secondary

```sh
$ sudo ./src/nfv/src/nfv/x86_64-native-linuxapp-gcc/spp_nfv \
	-c 0x06 -n 4 \
	--proc-type=secondary \
	-- \
	-n 1 \
	-s 192.168.122.1:6666

$ sudo ./src/nfv/src/nfv/x86_64-native-linuxapp-gcc/spp_nfv \
	-c 0x0A -n 4 \
	--proc-type=secondary \
	-- \
	-n 2 \
	-s 192.168.122.1:6666
```

### Start spp_vm

Start a VM for running spp_vm.
You need to add vhost interface while starting VM.
Vhost interface is supported to communicate between guest and host.

To start spp_vm, "qemu-ifup" script required.
Please copy "docs/qemu-ifup" to /etc/qemu-ifup of host.

SPP controller should do a "sec x;add vhost y" before starting the VM.
x is an id of spp_nfv and y is vhost port id (num of socket).
Vhost port is created as "/tmp/sock'y'".

To add vhost port 0 to sec 1,
```
spp > sec 1;add vhost 0
```
and confirm that "/tmp/sock0" is created.

Common qemu command line without vhost is here.

```sh
$ sudo ./x86_64-softmmu/qemu-system-x86_64 \
	-cpu host \
	-enable-kvm \
	-object memory-backend-file,id=mem,size=2048M,mem-path=/dev/hugepages,share=on \
	-numa node,memdev=mem \
	-mem-prealloc \
	-hda /home/dpdk/debian_wheezy_amd64_standard.qcow2 \
	-m 2048 \
	-smp cores=4,threads=1,sockets=1 \
	-device e1000,netdev=net0,mac=DE:AD:BE:EF:00:01 \
	-netdev tap,id=net0 \
	-nographic -vnc :2
```

Add chardev and another netdev,device options for vhost interface.

```sh
  sudo ./x86_64-softmmu/qemu-system-x86_64 \
  	-cpu host \
  	-enable-kvm \
  	-object memory-backend-file,id=mem,size=2048M,mem-path=/dev/hugepages,share=on \
  	-numa node,memdev=mem \
  	-mem-prealloc \
  	-hda /home/dpdk/debian_wheezy_amd64_standard.qcow2 \
  	-m 2048 \
  	-smp cores=4,threads=1,sockets=1 \
  	-device e1000,netdev=net0,mac=DE:AD:BE:EF:00:01 \
  	-netdev tap,id=net0 \
  	-chardev socket,id=chr0,path=/tmp/sock0 \              # vhost port
  	-netdev vhost-user,id=net1,chardev=chr0,vhostforce \   # netdev for vhost-user
  	-device virtio-net-pci,netdev=net1 \                   # device as virtio-net-pci
  	-nographic -vnc :2
```

Compile DPDK and SPP inside the VM and start spp_vm.

SPP options
* -p: port mask
* -n: secondary id
* -s: IP address of controller and port for secondary

```sh
$ sudo ./src/vm/src/vm/x86_64-native-linuxapp-gcc/spp_vm \
	-c 0x03 -n 4 \
	--proc-type=primary \
	-- \
	-p 0x01 \
	-n 1 \
	-s 192.168.122.1:6666
```


## Test Setups

### Test Setup 1: Single NFV

```
                                                                        __
                                    +--------------+                      |
                                    |    spp_nfv   |                      |
                                    |    (sec 1)   |                      |
                                    +--------------+                      |
                                         ^      :                         |
                                         |      |                         |
                                         :      v                         |
    +----+----------+-------------------------------------------------+   |
    |    | primary  |                    ^      :                     |   |
    |    +----------+                    :      :                     |   |
    |                                    :      :                     |   |
    |                         +----------+      +---------+           |   |  host
    |                         :                           v           |   |
    |                  +--------------+            +--------------+   |   |
    |                  |   phy port 0 |            |   phy port 1 |   |   |
    +------------------+--------------+------------+--------------+---+ __|
                              ^                           :
                              |                           |
                              :                           v

```

Check status of spp_nfv in spp controller.

```
spp > sec 1;status
recv:6:{Client ID 1 Idling
1
port id: 0,on,PHY,outport: -99
port id: 1,on,PHY,outport: -99
}
```

This message means that sec 1 has two physical ports refered as port 0, 1.
"outpport: -99" means the destionation is no assigned.

#### Configure spp_nfv as L2fwd

Assing the destination of ports by "patch" subcommand and start forwarding.
It is bi-directional.
```
spp > sec 1;patch 0 1
spp > sec 1;patch 1 0
spp > sec 1;forward
```

Check the status of sec 1 is updated.
```
spp > sec 1;status
recv:6:{Client ID 1 Running
1
port id: 0,on,PHY,outport: 1
port id: 1,on,PHY,outport: 0
}
```

Clear patch configuration.
```
spp > sec 1;stop
spp > sec 1;patch reset
```

#### Configure spp_nfv for loopback

Another example of patch configuration.
```
spp > sec 1;patch 0 0
spp > sec 1;patch 1 1
spp > sec 1;forward
```


### Test Setup 2: Dual NFV

```
                                                                        __
                         +--------------+          +--------------+       |
                         |    spp_nfv   |          |    spp_nfv   |       |
                         |    (sec 1)   |          |    (sec 2)   |       |
                         +--------------+          +--------------+       |
                            ^        :               :         :          |
                            |        |      +--------+         |          |
                            :        v      |                  v          |
    +----+----------+-----------------------+-------------------------+   |
    |    | primary  |       ^        :      |                  :      |   |
    |    +----------+       |        +------+--------+         :      |   |
    |                       :               |        :         :      |   |
    |                       :        +------+        :         |      |   |  host
    |                       :        v               v         v      |   |
    |                  +--------------+            +--------------+   |   |
    |                  |   phy port 0 |            |   phy port 1 |   |   |
    +------------------+--------------+------------+--------------+---+ __|
                              ^                           :
                              |                           |
                              :                           v

```

#### Configuration for two L2fwds

Assign patch configuration for sec 1 and 2.
It is uni-directional.
```
spp > sec 1;patch 0 1
spp > sec 2;patch 1 0
spp > sec 1;forward
spp > sec 2;forward
```

```

                                                                        __
                         +--------------+          +--------------+       |
                         |    spp_nfv   |          |    spp_nfv   |       |
                         |    (sec 1)   |          |    (sec 2)   |       |
                         +--------------+          +--------------+       |
                            ^        :               ^         :          |
                            |        |               |         |          |
                            :        v               :         v          |
    +----+----------+-------------------------------------------------+   |
    |    | primary  |       ^        :               ^         :      |   |
    |    +----------+       |        :               |         :      |   |
    |                       :        :               :         :      |   |
    |                       :        |               :         |      |   |  host
    |                       :        v               :         v      |   |
    |                  +--------------+            +--------------+   |   |
    |                  |   phy port 0 |            |   phy port 1 |   |   |
    +------------------+--------------+------------+--------------+---+ __|
                              ^                           ^
                              |                           |
                              v                           v

```

#### Configuration for loopback

```
spp > sec 1;patch 0 0
spp > sec 2;patch 1 1
spp > sec 1;forward
spp > sec 2;forward
```


### Test Setup 3: Dual NFV with ring pmd

```
                                                                        __
                       +----------+      ring 0      +----------+         |
                       |  spp_nfv |    +--------+    |  spp_nfv |         |
                       |  (sec 1) | -> |  |  |  |- > |  (sec 2) |         |
                       +----------+    +--------+    +----------+         |
                          ^                                   :           |
                          |                                   |           |
                          :                                   v           |
    +----+----------+-------------------------------------------------+   |
    |    | primary  |       ^                               :         |   |
    |    +----------+       |                               :         |   |
    |                       :                               :         |   |
    |                       :                               |         |   |  host
    |                       :                               v         |   |
    |                  +--------------+            +--------------+   |   |
    |                  |   phy port 0 |            |   phy port  1|   |   |
    +------------------+--------------+------------+--------------+---+ __|
                              ^                           :
                              |                           |
                              :                           v

```

#### Configuration for Uni directional L2fwd

Ring is an interface between spp_nfvs.
The maximum number of rings is defined as an option of spp_primary.
spp_nfv is able to find a ring by adding it.

Please notice that sec 1 has a new port id 2 after adding ring 0.
```
spp > sec 1;add ring 0
recv:6:{addring0}
spp > sec 1;status
recv:6:{Client ID 1 Idling
1
port id: 0,on,PHY,outport: -99
port id: 1,on,PHY,outport: -99
port id: 2,on,RING(0),outport: -99
}
```

To configure sec 1 and 2 forwarding thorugh ring 0,
add the ring both of them and patch.
```
spp > sec 1;add ring 0
spp > sec 2;add ring 0
spp > sec 1;patch 0 2
spp > sec 2;patch 2 1
spp > sec 1;forward
spp > sec 2;forward
```

#### Configuration for Bi directional L2fwd

```
                                                                        __
                                        ring 0                            |
                                      +--------+                          |
                    +------------+ <--|  |  |  |<-- +-----------+         |
                    |          p3|    +--------+    |p3         |         |
                    |  spp_nfv   |                  |  spp_nfv  |         |
                    |  (sec 1) p2|--> +--------+ -->|p2 (sec 2) |         |
                    +------------+    |  |  |  |    +-----------+         |
                            ^         +--------+          ^               |
                            |           ring 1            |               |
                            v                             v               |
    +---+----------+--------------------------------------------------+   |
    |   | primary  |        ^                             ^           |   |
    |   +----------+        |                             :           |   |
    |                       :                             :           |   |
    |                       :                             |           |   |  host
    |                       v                             v           |   |
    |                  +--------------+            +--------------+   |   |
    |                  |  phy port 0  |            |  phy port 1  |   |   |
    +------------------+--------------+------------+--------------+---+ __|
                              ^                           ^
                              |                           |
                              v                           v

```

Add ring 0 and 1 for sec 1.

```
spp > sec 1;add ring 0
spp > sec 1;add ring 1
spp > sec 1;status
recv:6:{Client ID 1 Idling
1
port id: 0,on,PHY,outport: -99
port id: 1,on,PHY,outport: -99
port id: 2,on,RING(0),outport: -99
port id: 3,on,RING(1),outport: -99
}
```

Then, add also for sec 2 and patch.
"p2" and "p3" inside of spp_nfv in the figure are port ids.
```
spp > sec 2;add ring 0
spp > sec 2;add ring 1
spp > sec 1;patch 0 2
spp > sec 1;patch 3 0
spp > sec 2;patch 1 3
spp > sec 2;patch 2 1
spp > sec 1;forward
spp > sec 2;forward
```

### Test Setup 4: Single NFV with VM through vhost pmd

```
                                                    __
                          +-----------------------+   |
                          | guest                 |   |
                          |                       |   |
                          |   +--------------+    |   |  guest 
                          |   |    spp_vm    |    |   |  192.168.122.51
                          |   |    (sec 2)   |    |   |
                          |   |      p0      |    |   |
                          +---+--------------+----+ __|
                               ^           :
                               |  virtio   |
                               |           V                          __
                           +--------------------+                       |
                           |      spp_nfv       |                       |
                           | p2   (sec 1)       |                       |
                           +--------------------+                       |
                               ^           :                            |
                               |           +---------- +                |
                               :                       v                |
    +----+----------+--------------------------------------------+      |
    |    | primary  |       ^                          :         |      |
    |    +----------+       |                          :         |      |
    |                       :                          |         |      | host 
    |                       :                          v         |      | 192.168.122.1
    |                  +--------------+       +--------------+   |      |
    |                  |   phy port 0 |       |  phy port  1 |   |      |
    +------------------+--------------+-------+--------------+---+    __|
                              ^                           :
                              |                           |
                              :                           v

```

#### Configuration for Uni directional L2fwd

Remove vhost port "/tmp/sock0" before starting VM if exists.

```sh
$ rm /tmp/sock0
```

Then, add sock0 from spp controller.
```
spp > sec 1;add vhost 0
```

Start VM and run spp_vm with sec id 2 inside VM.
You can find sec 2 from spp controller after spp_vm is launched.

Configure patch.
```
spp > sec 1;patch 0 2
spp > sec 1;patch 2 1
spp > sec 2;patch 0 0
spp > sec 1;forward
spp > sec 2;forward
```


### Optimizing qemu performance

First, find out the PID for qemu-system-x86 process.

```sh
$ ps ea
   PID TTY      STAT   TIME COMMAND
192606 pts/11   Sl+    4:42 ./x86_64-softmmu/qemu-system-x86_64 -cpu host -enable-kvm -object memory-backend-file,id=mem,siz
```

Using `pstree` to list out qemu-system-x86_64 threads.

```sh
$ pstree -p 192606
qemu-system-x86(192606)--+--{qemu-system-x8}(192607)
                         |--{qemu-system-x8}(192623)
                         |--{qemu-system-x8}(192624)
                         |--{qemu-system-x8}(192625)
                         |--{qemu-system-x8}(192626)
```

To Optimize, use `taskset` to pin each thread

```sh
$ sudo taskset -pc 4 192623
pid 192623's current affinity list: 0-31
pid 192623's new affinity list: 4
$ sudo taskset -pc 5 192624
pid 192624's current affinity list: 0-31
pid 192624's new affinity list: 5
$ sudo taskset -pc 6 192625
pid 192625's current affinity list: 0-31
pid 192625's new affinity list: 6
$ sudo taskset -pc 7 192626
pid 192626's current affinity list: 0-31
pid 192626's new affinity list: 7
```