diff options
| author | root <[email protected]> | 2015-11-04 10:53:28 +0800 |
|---|---|---|
| committer | root <[email protected]> | 2015-11-04 10:53:28 +0800 |
| commit | 39095200a81101acb5e43a16758f4700ea9114f7 (patch) | |
| tree | 46ea70609af5136f108a04d2c3ff31e6d3ffb235 | |
| parent | d86014c0fda6d3dfda8a883db8b7c9a03ee94d9a (diff) | |
| parent | 10ca5e55bfa62338e795aca60591d139694bdea8 (diff) | |
Merge branch 'master' into develop20151103.108.05
| -rw-r--r-- | conf/ixgbe.conf | 14 | ||||
| -rwxr-xr-x | tools/dpdk_intel | 259 |
2 files changed, 273 insertions, 0 deletions
diff --git a/conf/ixgbe.conf b/conf/ixgbe.conf new file mode 100644 index 0000000..281f5a8 --- /dev/null +++ b/conf/ixgbe.conf @@ -0,0 +1,14 @@ +# Configure File in Shell Format +# To configure mlx4 uio network drivers and dpdk env +# +# DPDK Envourment PATH + +export RTE_SDK=/home/driver/dpdk-2.0.0/ +export RTE_TARGET=x86_64-native-linuxapp-gcc + +# HUGEPAGES Count +HUGEPAGE_MEM=8000 + +# PCI Resource Address using IXGBE_UIO drivers +IXGBE_UIO=0000:07:00.0 + diff --git a/tools/dpdk_intel b/tools/dpdk_intel new file mode 100755 index 0000000..0dcb79f --- /dev/null +++ b/tools/dpdk_intel @@ -0,0 +1,259 @@ +#! /bin/bash + +prog=dpdk_intel +config=/etc/ixgbe.conf + +quit() +{ + QUIT=$1 +} + +# +# Creates hugepage filesystem. +# +create_mnt_huge() +{ + echo "Creating /mnt/huge and mounting as hugetlbfs" + mkdir -p /mnt/huge + + grep -s '/mnt/huge' /proc/mounts > /dev/null + if [ $? -ne 0 ] ; then + mount -t hugetlbfs nodev /mnt/huge + fi +} + +# +# Removes hugepage filesystem. +# +remove_mnt_huge() +{ + echo "Unmounting /mnt/huge and removing directory" + grep -s '/mnt/huge' /proc/mounts > /dev/null + if [ $? -eq 0 ] ; then + umount /mnt/huge + fi + + if [ -d /mnt/huge ] ; then + rm -R /mnt/huge + fi +} + +# +# Unloads igb_uio.ko. +# +remove_igb_uio_module() +{ + echo "Unloading any existing DPDK UIO module" + /sbin/lsmod | grep -s igb_uio > /dev/null + if [ $? -eq 0 ] ; then + /sbin/rmmod igb_uio + fi +} + +# +# Loads new igb_uio.ko (and uio module if needed). +# +load_igb_uio_module() +{ + if [ ! -f $RTE_SDK/$RTE_TARGET/kmod/igb_uio.ko ];then + echo "## ERROR: Target does not have the DPDK UIO Kernel Module." + echo " To fix, please try to rebuild target." + return + fi + + remove_igb_uio_module + + /sbin/lsmod | grep -s uio > /dev/null + if [ $? -ne 0 ] ; then + modinfo uio > /dev/null + if [ $? -eq 0 ]; then + echo "Loading uio module" + /sbin/modprobe uio + fi + fi + + # UIO may be compiled into kernel, so it may not be an error if it can't + # be loaded. + + echo "Loading DPDK UIO module" + /sbin/insmod $RTE_SDK/$RTE_TARGET/kmod/igb_uio.ko + if [ $? -ne 0 ] ; then + echo "## ERROR: Could not load kmod/igb_uio.ko." + quit + fi +} + +# +# Unloads the rte_kni.ko module. +# +remove_kni_module() +{ + echo "Unloading any existing DPDK KNI module" + /sbin/lsmod | grep -s rte_kni > /dev/null + if [ $? -eq 0 ] ; then + /sbin/rmmod rte_kni + fi +} + +# +# Loads the rte_kni.ko module. +# +load_kni_module() +{ + # Check that the KNI module is already built. + if [ ! -f $RTE_SDK/$RTE_TARGET/kmod/rte_kni.ko ];then + echo "## ERROR: Target does not have the DPDK KNI Module." + echo " To fix, please try to rebuild target." + return + fi + + # Unload existing version if present. + remove_kni_module + + # Now try load the KNI module. + echo "Loading DPDK KNI module" + /sbin/insmod $RTE_SDK/$RTE_TARGET/kmod/rte_kni.ko + if [ $? -ne 0 ] ; then + echo "## ERROR: Could not load kmod/rte_kni.ko." + quit + fi +} + +# +# Removes all reserved hugepages. +# +clear_huge_pages() +{ + echo > .echo_tmp + for d in /sys/devices/system/node/node? ; do + echo "echo 0 > $d/hugepages/hugepages-2048kB/nr_hugepages" >> .echo_tmp + done + echo "Removing currently reserved hugepages" + sh .echo_tmp + rm -f .echo_tmp + + remove_mnt_huge +} + +# +# Creates hugepages. +# +set_non_numa_pages() +{ + clear_huge_pages + + echo "echo $HUGEPAGE_MEM > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages" > .echo_tmp + echo "Reserving hugepages" + + sh .echo_tmp + rm -f .echo_tmp + + create_mnt_huge +} + +# +# Creates hugepages on specific NUMA nodes. +# +set_numa_pages() +{ + clear_huge_pages + + echo "" + echo " Input the number of 2MB pages for each node" + echo " Example: to have 128MB of hugepages available per node," + echo " enter '64' to reserve 64 * 2MB pages on each node" + + echo > .echo_tmp + for d in /sys/devices/system/node/node? ; do + node=$(basename $d) + echo -n "Number of pages for $node: " + read Pages + echo "echo $Pages > $d/hugepages/hugepages-2048kB/nr_hugepages" >> .echo_tmp + done + echo "Reserving hugepages" + sh .echo_tmp + rm -f .echo_tmp + + create_mnt_huge +} + +# +# Uses dpdk_nic_bind.py to move devices to work with igb_uio +# +bind_nics_to_igb_uio() +{ + oldIFS=$IFS + IFS=, + for PCI_PATH in $IXGBE_UIO; do + ${RTE_SDK}/tools/dpdk_nic_bind.py -b igb_uio $PCI_PATH + done + IFS=$oldIFS +} + +# +# Uses dpdk_nic_bind.py to move devices to work with kernel drivers again +# +unbind_nics() +{ + oldIFS=$IFS + IFS=, + + for PCI_PATH in $IXGBE_UIO; do + sudo ${RTE_SDK}/tools/dpdk_nic_bind.py -b ixgbe $PCI_PATH + done + IFS=$oldIFS +} + + +load_config_file() +{ + if [ ! -f $config ] ; then + echo "Loading Configure file $config error" + exit 3 + fi + source $config +} + +start() +{ + echo -n $"Starting $prog: " + + load_config_file + load_igb_uio_module + bind_nics_to_igb_uio + set_non_numa_pages + + return 0 +} + +stop() +{ + echo -n $"Stopping $prog: " + load_config_file + clear_huge_pages + unbind_nics + remove_igb_uio_module + + return 0 +} + +restart() { + stop + start +} + +case "$1" in + start) + start + ;; + stop) + stop + ;; + restart) + restart + ;; + *) + echo $"Usage: $0 {start|stop|restart}" + RETVAL=2 +esac +exit $RETVAL |
