From: "Alejandro.Lucero" <alejandro.luc...@netronome.com>

Signed-off-by: Alejandro.Lucero <alejandro.lucero at netronome.com>
Signed-off-by: Rolf.Neugebauer <rolf.neugebauer at netronome.com>
---
 tools/dpdk_nic_bind.py |    8 ++--
 tools/setup.sh         |  122 ++++++++++++++++++++++++++++++++++++++----------
 2 files changed, 101 insertions(+), 29 deletions(-)

diff --git a/tools/dpdk_nic_bind.py b/tools/dpdk_nic_bind.py
index b7bd877..f7f8a39 100755
--- a/tools/dpdk_nic_bind.py
+++ b/tools/dpdk_nic_bind.py
@@ -43,7 +43,7 @@ ETHERNET_CLASS = "0200"
 # Each device within this is itself a dictionary of device properties
 devices = {}
 # list of supported DPDK drivers
-dpdk_drivers = [ "igb_uio", "vfio-pci", "uio_pci_generic" ]
+dpdk_drivers = [ "igb_uio", "vfio-pci", "uio_pci_generic", "nfp_uio" ]

 # command-line arg flags
 b_flag = None
@@ -153,7 +153,7 @@ def find_module(mod):
                 return path

 def check_modules():
-    '''Checks that igb_uio is loaded'''
+    '''Checks that at least one dpdk module is loaded'''
     global dpdk_drivers

     fd = file("/proc/modules")
@@ -261,7 +261,7 @@ def get_nic_details():
                 devices[d]["Active"] = "*Active*"
                 break;

-        # add igb_uio to list of supporting modules if needed
+        # add module to list of supporting modules if needed
         if "Module_str" in devices[d]:
             for driver in dpdk_drivers:
                 if driver not in devices[d]["Module_str"]:
@@ -440,7 +440,7 @@ def display_devices(title, dev_list, extra_params = None):

 def show_status():
     '''Function called when the script is passed the "--status" option. 
Displays
-    to the user what devices are bound to the igb_uio driver, the kernel driver
+    to the user what devices are bound to a dpdk driver, the kernel driver
     or to no driver'''
     global dpdk_drivers
     kernel_drv = []
diff --git a/tools/setup.sh b/tools/setup.sh
index 5a8b2f3..e434ddb 100755
--- a/tools/setup.sh
+++ b/tools/setup.sh
@@ -236,6 +236,52 @@ load_vfio_module()
 }

 #
+# Unloads nfp_uio.ko.
+#
+remove_nfp_uio_module()
+{
+       echo "Unloading any existing DPDK UIO module"
+       /sbin/lsmod | grep -s nfp_uio > /dev/null
+       if [ $? -eq 0 ] ; then
+               sudo /sbin/rmmod nfp_uio
+       fi
+}
+
+#
+# Loads new nfp_uio.ko (and uio module if needed).
+#
+load_nfp_uio_module()
+{
+       echo "Using RTE_SDK=$RTE_SDK and RTE_TARGET=$RTE_TARGET"
+       if [ ! -f $RTE_SDK/$RTE_TARGET/kmod/nfp_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_nfp_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"
+                       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/nfp_uio.ko
+       if [ $? -ne 0 ] ; then
+               echo "## ERROR: Could not load kmod/nfp_uio.ko."
+               quit
+       fi
+}
+
+#
 # Unloads the rte_kni.ko module.
 #
 remove_kni_module()
@@ -427,10 +473,10 @@ grep_meminfo()
 #
 show_nics()
 {
-       if  /sbin/lsmod | grep -q -e igb_uio -e vfio_pci; then
+       if  /sbin/lsmod | grep -q -e igb_uio -e vfio_pci -e nfp_uio; then
                ${RTE_SDK}/tools/dpdk_nic_bind.py --status
        else
-               echo "# Please load the 'igb_uio' or 'vfio-pci' kernel module 
before "
+               echo "# Please load the 'igb_uio', 'vfio-pci' or 'nfp_uio' 
kernel module before "
                echo "# querying or adjusting NIC device bindings"
        fi
 }
@@ -471,6 +517,23 @@ bind_nics_to_igb_uio()
 }

 #
+# Uses dpdk_nic_bind.py to move devices to work with nfp_uio
+#
+bind_nics_to_nfp_uio()
+{
+       if  /sbin/lsmod  | grep -q nfp_uio ; then
+               ${RTE_SDK}/tools/dpdk_nic_bind.py --status
+               echo ""
+               echo -n "Enter PCI address of device to bind to NFP UIO driver: 
"
+               read PCI_PATH
+               sudo ${RTE_SDK}/tools/dpdk_nic_bind.py -b nfp_uio $PCI_PATH && 
echo "OK"
+       else
+               echo "# Please load the 'nfp_uio' kernel module before querying 
or "
+               echo "# adjusting NIC device bindings"
+       fi
+}
+
+#
 # Uses dpdk_nic_bind.py to move devices to work with kernel drivers again
 #
 unbind_nics()
@@ -513,29 +576,35 @@ step2_func()
        TEXT[1]="Insert IGB UIO module"
        FUNC[1]="load_igb_uio_module"

-       TEXT[2]="Insert VFIO module"
-       FUNC[2]="load_vfio_module"
+       TEXT[2]="Insert NFP UIO module"
+       FUNC[2]="load_nfp_uio_module"

-       TEXT[3]="Insert KNI module"
-       FUNC[3]="load_kni_module"
+       TEXT[3]="Insert VFIO module"
+       FUNC[3]="load_vfio_module"

-       TEXT[4]="Setup hugepage mappings for non-NUMA systems"
-       FUNC[4]="set_non_numa_pages"
+       TEXT[4]="Insert KNI module"
+       FUNC[4]="load_kni_module"

-       TEXT[5]="Setup hugepage mappings for NUMA systems"
-       FUNC[5]="set_numa_pages"
+       TEXT[5]="Setup hugepage mappings for non-NUMA systems"
+       FUNC[5]="set_non_numa_pages"

-       TEXT[6]="Display current Ethernet device settings"
-       FUNC[6]="show_nics"
+       TEXT[6]="Setup hugepage mappings for NUMA systems"
+       FUNC[6]="set_numa_pages"

-       TEXT[7]="Bind Ethernet device to IGB UIO module"
-       FUNC[7]="bind_nics_to_igb_uio"
+       TEXT[7]="Display current Ethernet device settings"
+       FUNC[7]="show_nics"

-       TEXT[8]="Bind Ethernet device to VFIO module"
-       FUNC[8]="bind_nics_to_vfio"
+       TEXT[8]="Bind Ethernet device to IGB UIO module"
+       FUNC[8]="bind_nics_to_igb_uio"

-       TEXT[9]="Setup VFIO permissions"
-       FUNC[9]="set_vfio_permissions"
+       TEXT[9]="Bind Ethernet device to NFP UIO module"
+       FUNC[9]="bind_nics_to_nfp_uio"
+
+       TEXT[10]="Bind Ethernet device to VFIO module"
+       FUNC[10]="bind_nics_to_vfio"
+
+       TEXT[11]="Setup VFIO permissions"
+       FUNC[11]="set_vfio_permissions"
 }

 #
@@ -574,20 +643,23 @@ step5_func()
        TEXT[1]="Uninstall all targets"
        FUNC[1]="uninstall_targets"

-       TEXT[2]="Unbind NICs from IGB UIO or VFIO driver"
+       TEXT[2]="Unbind NICs from IGB UIO, VFIO or NFP UIO driver"
        FUNC[2]="unbind_nics"

        TEXT[3]="Remove IGB UIO module"
        FUNC[3]="remove_igb_uio_module"

-       TEXT[4]="Remove VFIO module"
-       FUNC[4]="remove_vfio_module"
+       TEXT[4]="Remove NFP UIO module"
+       FUNC[4]="remove_nfp_uio_module"
+
+       TEXT[5]="Remove VFIO module"
+       FUNC[5]="remove_vfio_module"

-       TEXT[5]="Remove KNI module"
-       FUNC[5]="remove_kni_module"
+       TEXT[6]="Remove KNI module"
+       FUNC[6]="remove_kni_module"

-       TEXT[6]="Remove hugepage mappings"
-       FUNC[6]="clear_huge_pages"
+       TEXT[7]="Remove hugepage mappings"
+       FUNC[7]="clear_huge_pages"
 }

 STEPS[1]="step1_func"
-- 
1.7.9.5

Reply via email to