-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathsetup_dpdk_env.sh
More file actions
executable file
·90 lines (72 loc) · 1.83 KB
/
setup_dpdk_env.sh
File metadata and controls
executable file
·90 lines (72 loc) · 1.83 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
#!/bin/bash
# This script performs the following steps:
# 1. Setup hugepages.
# 2. Load the necessary kernel modules to access the NIC using DPDK library.
# 3. Bind the ethernet device(s) to the specified kernel module.
load_kernel_module () {
if [ $# != 1 ]; then
echo "Invalid number of arguments passed.";
return 1;
fi
echo "Loading kernel module: $1";
if [ $1 == "vfio-pci" ];then
sudo lsmod | grep "\bvfio_pci\b" > /dev/null 2>&1
else
sudo lsmod | grep "\b$1\b" > /dev/null 2>&1
fi
if [ $? != 0 ]; then
sudo modprobe $1
if [ $? != 0 ]; then
echo "Unable to load kernel module: $1"
return 1;
fi
else
echo "Kernel module: $1 already loaded."
fi
return 0
}
DPDK_HOME=$HOME/dpdk-stable
DPDK_USER_TOOLS_DIR=$DPDK_HOME/usertools
if [ ! -d "$DPDK_USER_TOOLS_DIR" ]; then
echo "Directory '$DPDK_USER_TOOLS_DIR' doesn't exists. Exiting ..."
exit 1
fi
cd $DPDK_USER_TOOLS_DIR
echo "Mounting huge pages ... "
sudo ./dpdk-hugepages.py --pagesize 1G --setup 2G --node 0
if [ $? != 0 ]; then
echo "Unable to mount hugepages. Exiting ..."
exit 2
fi
echo "Done."
echo ""
echo "Loading kernel modules ..."
load_kernel_module uio
if [ $? != 0 ]; then
exit 3
fi
load_kernel_module uio_pci_generic
if [ $? != 0 ]; then
exit 3
fi
load_kernel_module vfio-pci
if [ $? != 0 ]; then
exit 3
fi
echo "Done. "
echo ""
bind_device_to_dpdk_driver () {
if [ $# != 1 ]; then
echo "Invalid number of arguments passed to bind_device function. ";
return 4;
fi
echo "Binding ethernet device(s) "$1" to DPDK driver ..."
sudo ./dpdk-devbind.py -b vfio-pci "$1" --force
if [ $? != 0 ]; then
echo "Unable to bind ethernet device "$1" to DPDK driver. Exiting ..."
exit 4
fi
echo "Done."
}
bind_device_to_dpdk_driver "0000:04:00.0"
bind_device_to_dpdk_driver "0000:04:00.1"