Skip to content

Instantly share code, notes, and snippets.

@atoonk
Created March 30, 2021 00:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atoonk/04b65ce865135b16c6404a69778fda5c to your computer and use it in GitHub Desktop.
Save atoonk/04b65ce865135b16c6404a69778fda5c to your computer and use it in GitHub Desktop.
pktgen install
#!/bin/bash
if [ `whoami` != 'root' ]; then
echo "Please run this as root..., don't worry about it..."
exit 1
fi
echo "updating fstab"
r=`grep hugetlbfs /etc/fstab`
if [ $? -eq 1 ]; then
echo "huge /mnt/huge hugetlbfs defaults 0 0" >> /etc/fstab
fi
if [ ! -d /mnt/huge ]; then
mkdir /mnt/huge
chmod 777 /mnt/huge/
fi
echo "Updating sysctl"
r=`grep nr_hugepages /etc/sysctl.conf`
if [ $? -eq 1 ]; then
echo "vm.nr_hugepages=256" >> /etc/sysctl.conf
# also make sure it is live on this run, in case fstab has been already updated
sysctl -w vm.nr_hugepages=256
fi
echo "checking for iommu in GRUB"
r=`grep iommu=pt /etc/default/grub`
if [ $? -eq 1 ]; then
echo "iommu is missing from grub"
echo "please edit /etc/default/grub and make to append the below to GRUB_CMDLINE_LINUX"
echo "default_hugepagesz=1G hugepagesz=1G hugepages=8 iommu=pt intel_iommu=on pci=assign-busses"
echo 'example: GRUB_CMDLINE_LINUX="console=tty0 console=ttyS1,115200n8 biosdevname=0 net.ifnames=1 default_hugepagesz=1G hugepagesz=1G hugepages=8 iommu=pt intel_iommu=on pci=assign-busses"'
echo "after that run: update-grub && reboot"
echo "this will reboot your machine!"
echo "other things you may want to add are:"
echo "maxcpus=32"
echo "isolcpus=3-31"
exit 1
fi
r=`grep intel_iommu=on /etc/default/grub`
if [ $? -eq 1 ]; then
echo "iommu is missing from grub"
echo "please edit /etc/default/grub and make to append the below to GRUB_CMDLINE_LINUX"
echo "default_hugepagesz=1G hugepagesz=1G hugepages=8 iommu=pt intel_iommu=on pci=assign-busses"
echo 'example: GRUB_CMDLINE_LINUX="console=tty0 console=ttyS1,115200n8 biosdevname=0 net.ifnames=1 default_hugepagesz=1G hugepagesz=1G hugepages=8 iommu=pt intel_iommu=on pci=assign-busses"'
echo "after that run: update-grub && reboot"
echo "this will reboot your machine!"
exit 1
fi
echo "Going into /opt ..."
cd /opt
echo "Installing packages..."
apt-get -y update
apt-get -y upgrade
apt-get -y install python2.7
apt-get -y install build-essential
apt-get -y install libnuma-dev
apt-get -y install pciutils
apt-get -y install libpcap-dev
apt-get -y install liblua5.3-dev
apt -y install libelf-dev
apt-get -y install linux-headers-`uname -r` || apt -y install linux-headers-generic
apt -y install meson python3-pyelftools git
git clone https://dpdk.org/git/dpdk
sudo rm -fr /usr/local/lib/x86_64-linux-gnu # DPDK changed a number of lib names and need to clean up
cd dpdk
meson build
ninja -C build
sudo ninja -C build install
sudo ldconfig # make sure ld.so is pointing new DPDK libraries
export PKG_CONFIG_PATH=/usr/local/lib/x86_64-linux-gnu/pkgconfig
git clone http://dpdk.org/git/apps/pktgen-dpdk
cd pktgen-dpdk
make
export RTE_SDK=/usr/local
export RTE_TARGET=x86_64-native-linux-gcc
echo 1 > /sys/class/net/eno1/device/sriov_numvfs
modprobe uio
modprobe vfio-pci
modprobe uio_pci_generic
dpdk-devbind.py -b uio_pci_generic 0000:03:02.0
dpdk-devbind.py -s
./usr/local/bin/pktgen -- -T -P -m "2.[0]"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment