blob: f6e38a686442306c66f24ccbc8186d2bddd6bc36 [file] [log] [blame]
Peng Cao3857f3f2020-04-29 22:08:22 +08001#!/bin/bash
2
3
4###Check environment K8S_SRIOV_DP (0 or 1, default 0), K8S_CPU_MANAGER (0 or 1, default 0), XRAN_DIR before running this script
5
6###Parameters:
7
8###$1 - used to specify sriov net devices to run XRAN sample app.
9###The input will be different depending on k8s sriov device plugin enabled or not.
10###If k8s sriov net device plugin is enabled, container will request integral sriov VF devices ($1) from k8s,
11###which is specified in the pod configuration file like - intel.com/intel_sriov_dpdk: "2".
12###Then the input of this parameter would be number like 2, or 4.
13###Else this parameter $1 will be sriov net devices PCIe address list like "18:02.0 18:02.1"
14
15###$2 - Test case index. Like "mu3_100mhz"
16
17###$3 - "du" or "ru"
18
19###$4 - Instance/wls ID. Like "1", "2", or "3".
20
21###$5 - Used to assign core affinity to different threads of XRAN sample app.
22###If this parameter input is "0", k8s CPU Manager is enabled, and this script will get core mapping from the container taskset affinity,
23###which is assigned by the CPU Manager.
24###Else this parameter input should be taskset core mask assigned by user (in Hex format, but removing 0x in the head), like "0000f0"
25
26cd $XRAN_DIR
27
28#########Assigned PCIe VF for container
29vf_num=$1
30#########Test Case index
31case_index=$2
32########du or ru?
33mode_du_ru=$3
34########instance/wls ID
35wls_id=$4
36########taskset core mask
37taskset_str=$5
38
39###########Get SRIOV VF PCI addresses if K8S_SRIOV_DP enabled or not
40array_pci_list=""
41if [ $K8S_SRIOV_DP ]; then
42 env_pci_list=$(env | grep -i PCIDEVICE | grep -i DPDK | awk -F= '{print $2}')
43
44 let i=1
45 while [ $i -le $vf_num ]
46 do
47 addr=$(echo $env_pci_list | awk -F, '{print $'$i'}')
48 array_pci_list="$array_pci_list $addr"
49 let i++
50 done
51else
52 array_pci_list=$vf_number
53fi
54
55#####Specify which test case to run and the VF number
56sed -i "s/\.\/build\/sample-app .*/\.\/build\/sample-app \.\/usecase\/$case_index\/config_file_o_${mode_du_ru}.dat $array_pci_list/" $XRAN_DIR/app/run_o_${mode_du_ru}.sh
57
58####Update some parameters for test case
59sed -i "s/debugStop=.*/debugStop=0/" app/usecase/${case_index}/config_file_o_${mode_du_ru}.dat
60sed -i "s/CPenable=.*/CPenable=1/" app/usecase/${case_index}/config_file_o_${mode_du_ru}.dat
61sed -i "s/instanceId=.*/instanceId=${wls_id}/" app/usecase/${case_index}/config_file_o_${mode_du_ru}.dat
62
63####Get core ID from core mask
64if [ $K8S_CPU_MANAGER ]; then
65 taskset_str=$(echo $(taskset -p 1) | sed 's/.*affinity mask: \(.*\)/\1/')
66fi
67let core_map="0x$taskset_str"
68let core_mask=1
69let first_core_mask=$((core_map & core_mask))
70let first_core_num=0
71
72
73#####Get first core ID for system thread
74let max_cpu=64
75while [ $first_core_mask -eq 0 ]
76do
77 if [ $max_cpu -eq 0 ]; then
78 echo "ERROR: provided core mask is wrong in your system. Please check."
79 fi
80 core_mask=$(($core_mask+$core_mask))
81 first_core_num=$(($first_core_num+1))
82 echo core_mask $core_mask
83 echo first_core_num $first_core_num
84 first_core_mask=$((core_map & core_mask))
85 echo first_core_mask=$first_core_mask
86 max_cpu=$(($max_cpu-1))
87done
88
89system_core_num=$first_core_num
90
91core_map=$(($core_map-$core_mask))
92if [ $core_map -eq 0 ]
93then
94 echo "ERROR: require at least two cores for O-DU/RU sample app"
95 exit
96fi
97
98#####Get the second core ID for timing thread
99first_core_mask=0
100while [ $first_core_mask -eq 0 ]
101do
102 if [ $max_cpu -eq 0 ]; then
103 echo "ERROR: provided core mask is wrong in your system. Please check."
104 fi
105
106 core_mask=$(($core_mask+$core_mask))
107 first_core_num=$(($first_core_num+1))
108 echo core_mask $core_mask
109 echo first_core_num $first_core_num
110 first_core_mask=$((core_map & core_mask))
111 echo first_core_mask=$first_core_mask
112 max_cpu=$(($max_cpu-1))
113done
114
115timing_core_num=$first_core_num
116####Currently only use 2 cores to run O-DU/RU sample app
117sed -i "s/ioCore.*/ioCore=${system_core_num}/" app/usecase/${case_index}/config_file_o_${mode_du_ru}.dat
118sed -i "s/pktAuxCore.*/pktAuxCore=${system_core_num}/" app/usecase/${case_index}/config_file_o_${mode_du_ru}.dat
119sed -i "s/pktProcCore.*/pktProcCore=${system_core_num}/" app/usecase/${case_index}/config_file_o_${mode_du_ru}.dat
120sed -i "s/systemCore.*/systemCore=${system_core_num}/" app/usecase/${case_index}/config_file_o_${mode_du_ru}.dat
121sed -i "s/timingCore.*/timingCore=${timing_core_num}/" app/usecase/${case_index}/config_file_o_${mode_du_ru}.dat
122
123cd app
124sh run_o_${mode_du_ru}.sh
125