summaryrefslogtreecommitdiff
path: root/containers/trex/files/generate-trex-conf.sh
diff options
context:
space:
mode:
Diffstat (limited to 'containers/trex/files/generate-trex-conf.sh')
-rw-r--r--containers/trex/files/generate-trex-conf.sh58
1 files changed, 58 insertions, 0 deletions
diff --git a/containers/trex/files/generate-trex-conf.sh b/containers/trex/files/generate-trex-conf.sh
new file mode 100644
index 00000000..c8c5b6f4
--- /dev/null
+++ b/containers/trex/files/generate-trex-conf.sh
@@ -0,0 +1,58 @@
+#!/bin/bash
+
+CPU_AFFINITY=(${CPU_AFFINITY//,/ })
+NIC_PCI=$(env | grep '_NIC_PCI' | cut -d'=' -f2 | sed 's/0000://')
+arr=($NIC_PCI)
+NIC_PCI=""
+for interface in "${arr[@]}"; do
+ if [ ! -z "$NIC_PCI" ]; then
+ NIC_PCI+=","
+ fi
+ NIC_PCI+="\"$interface\""
+done
+
+port_limit=${#arr[@]}
+
+declare -A NUMA
+for cpu in ${CPU_AFFINITY[@]}; do
+ numa_node=$(lscpu -p=CPU,NODE | grep "^$cpu," | cut -d',' -f2)
+ NUMA[$numa_node]+="$cpu,"
+done
+
+cat << EOF > /etc/trex_cfg.yaml
+- port_limit: $port_limit
+ version: 2
+ stack: legacy
+ interfaces: [${NIC_PCI}]
+ port_mtu: 2000
+ rx_desc: 4096
+ tx_desc: 4096
+ new_memory : true
+ port_info :
+ - ip : 17.17.0.1
+ default_gw : 17.18.0.1
+ dest_mac : "00:11:22:33:44:55"
+ src_mac : "aa:bb:cc:dd:ee:ff"
+ - ip : 17.18.0.1
+ default_gw : 17.17.0.1
+ dest_mac : "aa:bb:cc:dd:ee:ff"
+ src_mac : "00:11:22:33:44:55"
+ - ip : 17.19.0.1
+ default_gw : 17.20.0.1
+ dest_mac : "00:11:22:33:44:54"
+ src_mac : "aa:bb:cc:dd:ee:fe"
+ - ip : 17.20.0.1
+ default_gw : 17.19.0.1
+ dest_mac : "aa:bb:cc:dd:ee:fe"
+ src_mac : "00:11:22:33:44:54"
+ platform:
+ master_thread_id: ${MASTER_IOCORE}
+ latency_thread_id: ${LATENCY_IOCORE}
+ dual_if:
+EOF
+
+for numa_node in "${!NUMA[@]}"; do
+ threads=${NUMA[$numa_node]%,}
+ echo " - socket: $numa_node" >> /etc/trex_cfg.yaml
+ echo " threads: [${threads// /,}]" >> /etc/trex_cfg.yaml
+done