X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?p=o-du%2Fphy.git;a=blobdiff_plain;f=fhi_lib%2Fapp%2Fdpdk.sh;fp=fhi_lib%2Fapp%2Fdpdk.sh;h=96bb84f8661ee9bb3100deeb7459ca2c262c32a6;hp=0000000000000000000000000000000000000000;hb=4745e5c88ba931c6d71cb6d8c681f76cf364eac5;hpb=59f84608ec15c016958a6e0e0ddd813f376c0925 diff --git a/fhi_lib/app/dpdk.sh b/fhi_lib/app/dpdk.sh new file mode 100644 index 0000000..96bb84f --- /dev/null +++ b/fhi_lib/app/dpdk.sh @@ -0,0 +1,97 @@ +#! /bin/bash + +#/****************************************************************************** +#* +#* Copyright (c) 2019 Intel. +#* +#* Licensed under the Apache License, Version 2.0 (the "License"); +#* you may not use this file except in compliance with the License. +#* You may obtain a copy of the License at +#* +#* http://www.apache.org/licenses/LICENSE-2.0 +#* +#* Unless required by applicable law or agreed to in writing, software +#* distributed under the License is distributed on an "AS IS" BASIS, +#* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +#* See the License for the specific language governing permissions and +#* limitations under the License. +#* +#*******************************************************************************/ + +export RTE_SDK=/home/turner/dpdk +export RTE_TARGET=x86_64-native-linuxapp-icc + +# +# 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 + sudo /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 + if [ -f /lib/modules/$(uname -r)/kernel/drivers/uio/uio.ko ] ; then + echo "Loading uio module" + sudo /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" + sudo /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 +} + +load_igb_uio_module + +CPU_FEATURES_DETECT=`cat /proc/cpuinfo |grep hypervisor | wc -l` + +if [ "$CPU_FEATURES_DETECT" -eq "0" ] +then +VM_DETECT='HOST' +echo ${VM_DETECT} +else +VM_DETECT='VM' +echo ${VM_DETECT} +fi + +$RTE_SDK/usertools/dpdk-devbind.py --status +if [ ${VM_DETECT} == 'HOST' ]; then + #HOST + $RTE_SDK/usertools/dpdk-devbind.py --bind=igb_uio 0000:d8:02.0 + $RTE_SDK/usertools/dpdk-devbind.py --bind=igb_uio 0000:d8:02.1 + $RTE_SDK/usertools/dpdk-devbind.py --bind=igb_uio 0000:07:02.0 + $RTE_SDK/usertools/dpdk-devbind.py --bind=igb_uio 0000:07:02.1 +else + #VM + $RTE_SDK/usertools/dpdk-devbind.py --bind=igb_uio 0000:00:04.0 + $RTE_SDK/usertools/dpdk-devbind.py --bind=igb_uio 0000:00:05.0 + $RTE_SDK/usertools/dpdk-devbind.py --bind=igb_uio 0000:00:06.0 + $RTE_SDK/usertools/dpdk-devbind.py --bind=igb_uio 0000:00:07.0 +fi + +$RTE_SDK/usertools/dpdk-devbind.py --status +