Merge "Create API to get SUT information"
[yardstick.git] / yardstick / benchmark / scenarios / networking / testpmd_fwd.bash
1 #!/bin/bash
2 ##############################################################################
3 # Copyright (c) 2017 ZTE corporation and others.
4 #
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
10 #!/bin/sh
11
12 set -e
13
14 # Commandline arguments
15 DST_MAC=$1         # MAC address of the peer port
16
17 load_modules()
18 {
19     if lsmod | grep "uio" &> /dev/null ; then
20     echo "uio module is loaded"
21     else
22     modprobe uio
23     fi
24
25     if lsmod | grep "igb_uio" &> /dev/null ; then
26     echo "igb_uio module is loaded"
27     else
28     insmod /dpdk/x86_64-native-linuxapp-gcc/kmod/igb_uio.ko
29     fi
30
31     if lsmod | grep "rte_kni" &> /dev/null ; then
32     echo "rte_kni module is loaded"
33     else
34     insmod /dpdk/x86_64-native-linuxapp-gcc/kmod/rte_kni.ko
35     fi
36 }
37
38 change_permissions()
39 {
40     chmod 777 /sys/bus/pci/drivers/virtio-pci/*
41     chmod 777 /sys/bus/pci/drivers/igb_uio/*
42 }
43
44 add_interface_to_dpdk(){
45     interfaces=$(lspci |grep Eth |tail -n +2 |awk '{print $1}')
46     /dpdk/tools/dpdk-devbind.py --bind=igb_uio $interfaces
47 }
48
49 run_testpmd()
50 {
51     blacklist=$(lspci |grep Eth |awk '{print $1}'|head -1)
52     cd /dpdk
53     sudo ./destdir/bin/testpmd -c 0x07 -n 4 -b $blacklist -- -a --eth-peer=1,$DST_MAC --forward-mode=mac
54 }
55
56 main()
57 {
58     load_modules
59     change_permissions
60     add_interface_to_dpdk
61     run_testpmd
62 }
63
64 main