provide follow features implementation:
[o-du/phy.git] / fhi_lib / app / dpdk.sh
old mode 100644 (file)
new mode 100755 (executable)
index 1e4c8f4..2f5aa8a
-#! /bin/bash\r
-\r
-#/******************************************************************************\r
-#*\r
-#*   Copyright (c) 2019 Intel.\r
-#*\r
-#*   Licensed under the Apache License, Version 2.0 (the "License");\r
-#*   you may not use this file except in compliance with the License.\r
-#*   You may obtain a copy of the License at\r
-#*\r
-#*       http://www.apache.org/licenses/LICENSE-2.0\r
-#*\r
-#*   Unless required by applicable law or agreed to in writing, software\r
-#*   distributed under the License is distributed on an "AS IS" BASIS,\r
-#*   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-#*   See the License for the specific language governing permissions and\r
-#*   limitations under the License.\r
-#*\r
-#*******************************************************************************/\r
-\r
-\r
-export RTE_SDK=/home/turner/dpdk\r
-export RTE_TARGET=x86_64-native-linuxapp-icc\r
-\r
-#\r
-# Unloads igb_uio.ko.\r
-#\r
-remove_igb_uio_module()\r
-{\r
-    echo "Unloading any existing DPDK UIO module"\r
-    /sbin/lsmod | grep -s igb_uio > /dev/null\r
-    if [ $? -eq 0 ] ; then\r
-        sudo /sbin/rmmod igb_uio\r
-    fi\r
-}\r
-\r
-#\r
-# Loads new igb_uio.ko (and uio module if needed).\r
-#\r
-load_igb_uio_module()\r
-{\r
-    if [ ! -f $RTE_SDK/$RTE_TARGET/kmod/igb_uio.ko ];then\r
-        echo "## ERROR: Target does not have the DPDK UIO Kernel Module."\r
-        echo "       To fix, please try to rebuild target."\r
-        return\r
-    fi\r
-\r
-    remove_igb_uio_module\r
-\r
-    /sbin/lsmod | grep -s uio > /dev/null\r
-    if [ $? -ne 0 ] ; then\r
-        if [ -f /lib/modules/$(uname -r)/kernel/drivers/uio/uio.ko ] ; then\r
-            echo "Loading uio module"\r
-            sudo /sbin/modprobe uio\r
-        fi\r
-    fi\r
-\r
-    # UIO may be compiled into kernel, so it may not be an error if it can't\r
-    # be loaded.\r
-\r
-    echo "Loading DPDK UIO module"\r
-    sudo /sbin/insmod $RTE_SDK/$RTE_TARGET/kmod/igb_uio.ko\r
-    if [ $? -ne 0 ] ; then\r
-        echo "## ERROR: Could not load kmod/igb_uio.ko."\r
-        quit\r
-    fi\r
-}\r
-\r
-#\r
-# Unloads VFIO modules.\r
-#\r
-remove_vfio_module()\r
-{\r
-       echo "Unloading any existing VFIO module"\r
-       /sbin/lsmod | grep -s vfio > /dev/null\r
-       if [ $? -eq 0 ] ; then\r
-               sudo /sbin/rmmod vfio-pci\r
-               sudo /sbin/rmmod vfio_iommu_type1\r
-               sudo /sbin/rmmod vfio\r
-       fi\r
-}\r
-\r
-#\r
-# Loads new vfio-pci (and vfio module if needed).\r
-#\r
-load_vfio_module()\r
-{\r
-       remove_vfio_module\r
-\r
-       VFIO_PATH="kernel/drivers/vfio/pci/vfio-pci.ko"\r
-\r
-       echo "Loading VFIO module"\r
-       /sbin/lsmod | grep -s vfio_pci > /dev/null\r
-       if [ $? -ne 0 ] ; then\r
-               if [ -f /lib/modules/$(uname -r)/$VFIO_PATH ] ; then\r
-                       sudo /sbin/modprobe vfio-pci\r
-               fi\r
-       fi\r
-\r
-       # make sure regular users can read /dev/vfio\r
-       echo "chmod /dev/vfio"\r
-       sudo chmod a+x /dev/vfio\r
-       if [ $? -ne 0 ] ; then\r
-               echo "FAIL"\r
-               quit\r
-       fi\r
-       echo "OK"\r
-\r
-       # check if /dev/vfio/vfio exists - that way we\r
-       # know we either loaded the module, or it was\r
-       # compiled into the kernel\r
-       if [ ! -e /dev/vfio/vfio ] ; then\r
-               echo "## ERROR: VFIO not found!"\r
-       fi\r
-}\r
-\r
-\r
-load_igb_uio_module\r
-load_vfio_module\r
-\r
-CPU_FEATURES_DETECT=`cat /proc/cpuinfo |grep hypervisor | wc -l`\r
-\r
-if [ "$CPU_FEATURES_DETECT" -eq "0" ]\r
-then\r
-VM_DETECT='HOST'\r
-echo ${VM_DETECT}\r
-else\r
-VM_DETECT='VM'\r
-echo ${VM_DETECT}\r
-fi\r
-\r
-$RTE_SDK/usertools/dpdk-devbind.py --status\r
-if [ ${VM_DETECT} == 'HOST' ]; then\r
-    #HOST\r
-    $RTE_SDK/usertools/dpdk-devbind.py --bind=vfio-pci 0000:22:02.0\r
-    $RTE_SDK/usertools/dpdk-devbind.py --bind=vfio-pci 0000:22:02.1\r
-    $RTE_SDK/usertools/dpdk-devbind.py --bind=vfio-pci 0000:22:0a.0\r
-    $RTE_SDK/usertools/dpdk-devbind.py --bind=vfio-pci 0000:22:0a.1\r
-else\r
-    #VM\r
-    $RTE_SDK/usertools/dpdk-devbind.py --bind=igb_uio 0000:00:04.0\r
-    $RTE_SDK/usertools/dpdk-devbind.py --bind=igb_uio 0000:00:05.0\r
-    $RTE_SDK/usertools/dpdk-devbind.py --bind=igb_uio 0000:00:06.0\r
-    $RTE_SDK/usertools/dpdk-devbind.py --bind=igb_uio 0000:00:07.0\r
-fi\r
-\r
-$RTE_SDK/usertools/dpdk-devbind.py --status\r
-\r
+#! /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
+}
+
+#
+# Unloads VFIO modules.
+#
+remove_vfio_module()
+{
+       echo "Unloading any existing VFIO module"
+       /sbin/lsmod | grep -s vfio > /dev/null
+       if [ $? -eq 0 ] ; then
+               sudo /sbin/rmmod vfio-pci
+               sudo /sbin/rmmod vfio_iommu_type1
+               sudo /sbin/rmmod vfio
+       fi
+}
+
+#
+# Loads new vfio-pci (and vfio module if needed).
+#
+load_vfio_module()
+{
+       remove_vfio_module
+
+       VFIO_PATH="kernel/drivers/vfio/pci/vfio-pci.ko"
+
+       echo "Loading VFIO module"
+       /sbin/lsmod | grep -s vfio_pci > /dev/null
+       if [ $? -ne 0 ] ; then
+               if [ -f /lib/modules/$(uname -r)/$VFIO_PATH ] ; then
+                       sudo /sbin/modprobe vfio-pci
+               fi
+       fi
+
+       # make sure regular users can read /dev/vfio
+       echo "chmod /dev/vfio"
+       sudo chmod a+x /dev/vfio
+       if [ $? -ne 0 ] ; then
+               echo "FAIL"
+               quit
+       fi
+       echo "OK"
+
+       # check if /dev/vfio/vfio exists - that way we
+       # know we either loaded the module, or it was
+       # compiled into the kernel
+       if [ ! -e /dev/vfio/vfio ] ; then
+               echo "## ERROR: VFIO not found!"
+       fi
+}
+
+
+load_igb_uio_module
+load_vfio_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=vfio-pci 0000:22:02.0
+    $RTE_SDK/usertools/dpdk-devbind.py --bind=vfio-pci 0000:22:02.1
+    $RTE_SDK/usertools/dpdk-devbind.py --bind=vfio-pci 0000:22:0a.0
+    $RTE_SDK/usertools/dpdk-devbind.py --bind=vfio-pci 0000:22:0a.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
+