-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrestart_environment.sh
More file actions
executable file
·138 lines (105 loc) · 3.07 KB
/
restart_environment.sh
File metadata and controls
executable file
·138 lines (105 loc) · 3.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/bin/bash
build_hairpin_code() {
echo "Building hairpin code..."
# Build hairpin code
export PKG_CONFIG_PATH=:/opt/mellanox/doca/lib/aarch64-linux-gnu/pkgconfig:/opt/mellanox/dpdk/lib/aarch64-linux-gnu/pkgconfig:/opt/mellanox
CURRENT_PATH=$(pwd)
cd $CURRENT_PATH/hairpin
meson build
cd build
ninja
cd ../..
echo "Hairpin code built successfully."
}
compile_hairpin_code() {
CURRENT_PATH=$(pwd)
cd $CURRENT_PATH/hairpin/build
ninja
cd ../..
echo "Hairpin code compiled."
}
build_rss_code() {
echo "Building hairpin code..."
# Build hairpin code
export PKG_CONFIG_PATH=:/opt/mellanox/doca/lib/aarch64-linux-gnu/pkgconfig:/opt/mellanox/dpdk/lib/aarch64-linux-gnu/pkgconfig:/opt/mellanox
CURRENT_PATH=$(pwd)
cd $CURRENT_PATH/rss
meson build
cd build
ninja
cd ../..
echo "Hairpin code built successfully."
}
compile_rss_code() {
CURRENT_PATH=$(pwd)
cd $CURRENT_PATH/rss/build
ninja
cd ../..
echo "RSS code compiled."
}
# Function to clean up OVS bridges
cleanup_bridges() {
echo "Cleaning up all OVS bridges..."
# Get all bridges and delete them
for bridge in $(ovs-vsctl list-br); do
echo "Deleting bridge: $bridge"
ovs-vsctl del-br $bridge
done
echo "All bridges deleted."
}
# Function to clean up Scalable Functions
cleanup_sfs() {
echo "Cleaning up all Scalable Functions..."
# Delete all SFs
for sf in $(mlnx-sf -a show | grep pci/ | awk '{print $3}'); do
echo "Deleting SF: $sf"
/opt/mellanox/iproute2/sbin/mlxdevm port del $sf
done
echo "All Scalable Functions deleted."
}
# Function to set up hugepages
setup_hugepages() {
echo "Setting up hugepages..."
# Unmount if already mounted
umount /dev/hugepages 2>/dev/null || true
# Create mount point and mount
mkdir -p /mnt/huge
mount -t hugetlbfs nodev /mnt/huge
# Allocate hugepages
echo 4096 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
echo "Hugepages set up successfully."
}
# Function to enable hardware offload
enable_hw_offload() {
echo "Enabling hardware offload..."
ovs-vsctl set Open_vSwitch . Other_config:hw-offload=true
systemctl restart openvswitch-switch
echo "Hardware offload enabled."
}
# Main execution
echo "Starting environment setup..."
#kill any prev app
killall doca_flow_hairpin_vnf
killall doca_flow_rss_meta
# Step 1: Clean existing environment
cleanup_bridges
sleep 1
cleanup_sfs
sleep 2
# Step 2: Set up hugepages
setup_hugepages
# Step 3: Enable hardware offload
enable_hw_offload
# Step 4: Check if hairpin code needs to be built
if [ ! -f "hairpin/build/doca_flow_hairpin_vnf" ]; then
build_hairpin_code
else
echo "Hairpin code already built. Skipping build step."
fi
# Step 5: Check if rss code needs to be built
if [ ! -f "rss/build/doca_flow_rss_meta" ]; then
build_rss_code
else
echo "RSS code already built. Skipping built step."
fi
echo "Environment setup complete. Ready for topology creation."