1. Update Dockerfile for CI build. But there is dependency on Intel System Studio...
[o-du/phy.git] / misc / update-config-run.sh
1 #!/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
26 cd $XRAN_DIR
27
28 #########Assigned PCIe VF for container
29 vf_num=$1
30 #########Test Case index
31 case_index=$2
32 ########du or ru?
33 mode_du_ru=$3
34 ########instance/wls ID
35 wls_id=$4
36 ########taskset core mask
37 taskset_str=$5
38
39 ###########Get SRIOV VF PCI addresses if K8S_SRIOV_DP enabled or not
40 array_pci_list=""
41 if [ $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
51 else
52    array_pci_list=$vf_number
53 fi
54
55 #####Specify which test case to run and the VF number
56 sed -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
59 sed -i "s/debugStop=.*/debugStop=0/" app/usecase/${case_index}/config_file_o_${mode_du_ru}.dat
60 sed -i "s/CPenable=.*/CPenable=1/" app/usecase/${case_index}/config_file_o_${mode_du_ru}.dat
61 sed -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
64 if [ $K8S_CPU_MANAGER ]; then
65     taskset_str=$(echo $(taskset -p 1) | sed 's/.*affinity mask: \(.*\)/\1/')
66 fi
67 let core_map="0x$taskset_str"
68 let core_mask=1
69 let first_core_mask=$((core_map & core_mask))
70 let first_core_num=0
71
72
73 #####Get first core ID for system thread
74 let max_cpu=64
75 while [ $first_core_mask -eq 0 ]
76 do
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))
87 done
88
89 system_core_num=$first_core_num
90
91 core_map=$(($core_map-$core_mask))
92 if [ $core_map -eq 0 ]
93 then
94     echo "ERROR: require at least two cores for O-DU/RU sample app"
95     exit
96 fi
97
98 #####Get the second core ID for timing thread
99 first_core_mask=0
100 while [ $first_core_mask -eq 0 ]
101 do
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))
113 done
114
115 timing_core_num=$first_core_num
116 ####Currently only use 2 cores to run O-DU/RU sample app
117 sed -i "s/ioCore.*/ioCore=${system_core_num}/" app/usecase/${case_index}/config_file_o_${mode_du_ru}.dat
118 sed -i "s/pktAuxCore.*/pktAuxCore=${system_core_num}/" app/usecase/${case_index}/config_file_o_${mode_du_ru}.dat
119 sed -i "s/pktProcCore.*/pktProcCore=${system_core_num}/" app/usecase/${case_index}/config_file_o_${mode_du_ru}.dat
120 sed -i "s/systemCore.*/systemCore=${system_core_num}/" app/usecase/${case_index}/config_file_o_${mode_du_ru}.dat
121 sed -i "s/timingCore.*/timingCore=${timing_core_num}/" app/usecase/${case_index}/config_file_o_${mode_du_ru}.dat
122
123 cd app
124 sh run_o_${mode_du_ru}.sh
125