Merge "Prohibit the importation of a list of libraries"
[yardstick.git] / yardstick / benchmark / scenarios / networking / testpmd_rev.bash
1 ##############################################################################
2 # Copyright (c) 2017 Nokia and others.
3 #
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
9 #!/bin/sh
10
11 set -e
12
13 # Commandline arguments
14 NUM_TRAFFIC_PORTS=${1:-1}
15
16 load_modules()
17 {
18     if ! lsmod | grep "uio" &> /dev/null; then
19         modprobe uio
20     fi
21
22     if ! lsmod | grep "igb_uio" &> /dev/null; then
23         insmod /dpdk/x86_64-native-linuxapp-gcc/kmod/igb_uio.ko
24     fi
25
26     if ! lsmod | grep "rte_kni" &> /dev/null; then
27         insmod /dpdk/x86_64-native-linuxapp-gcc/kmod/rte_kni.ko
28     fi
29 }
30
31 change_permissions()
32 {
33     chmod 777 /sys/bus/pci/drivers/virtio-pci/*
34     chmod 777 /sys/bus/pci/drivers/igb_uio/*
35 }
36
37 add_interface_to_dpdk(){
38     interfaces=$(lspci |grep Eth |tail -n +2 |awk '{print $1}')
39     /dpdk/usertools/dpdk-devbind.py --bind=igb_uio $interfaces &> /dev/null
40 }
41
42 run_testpmd()
43 {
44     blacklist=$(lspci |grep Eth |awk '{print $1}'|head -1)
45     cd /dpdk
46     if [ $NUM_TRAFFIC_PORTS -gt 1 ]; then
47         sudo ./destdir/bin/testpmd -c 0x3f -n 4 -b $blacklist -- -a --nb-cores=4 --coremask=0x3c --rxq=2 --rxd=4096 --rss-udp --txq=2 --forward-mode=rxonly
48     else
49         sudo ./destdir/bin/testpmd -c 0x0f -n 4 -b $blacklist -- -a --nb-cores=2 --coremask=0x0c --rxq=2 --rxd=4096 --rss-udp --txq=2 --forward-mode=rxonly
50     fi
51 }
52
53 main()
54 {
55     if ip a | grep eth2 >/dev/null 2>&1; then
56         ip link set eth2 down
57     fi
58
59     if ip a | grep eth1 >/dev/null 2>&1; then
60         ip link set eth1 down
61         load_modules
62         change_permissions
63         add_interface_to_dpdk
64     fi
65
66     run_testpmd
67 }
68
69 main