15129044dSC.J. Collier..  BSD LICENSE
25129044dSC.J. Collier    Copyright(c) 2015 Netronome Systems, Inc. All rights reserved.
35129044dSC.J. Collier    All rights reserved.
45129044dSC.J. Collier
55129044dSC.J. Collier    Redistribution and use in source and binary forms, with or without
65129044dSC.J. Collier    modification, are permitted provided that the following conditions
75129044dSC.J. Collier    are met:
85129044dSC.J. Collier
95129044dSC.J. Collier    * Redistributions of source code must retain the above copyright
105129044dSC.J. Collier    notice, this list of conditions and the following disclaimer.
115129044dSC.J. Collier    * Redistributions in binary form must reproduce the above copyright
125129044dSC.J. Collier    notice, this list of conditions and the following disclaimer in
135129044dSC.J. Collier    the documentation and/or other materials provided with the
145129044dSC.J. Collier    distribution.
155129044dSC.J. Collier    * Neither the name of Intel Corporation nor the names of its
165129044dSC.J. Collier    contributors may be used to endorse or promote products derived
175129044dSC.J. Collier    from this software without specific prior written permission.
185129044dSC.J. Collier
195129044dSC.J. Collier    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
205129044dSC.J. Collier    "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
215129044dSC.J. Collier    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
225129044dSC.J. Collier    A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
235129044dSC.J. Collier    OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
245129044dSC.J. Collier    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
255129044dSC.J. Collier    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
265129044dSC.J. Collier    DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
275129044dSC.J. Collier    THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
285129044dSC.J. Collier    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
295129044dSC.J. Collier    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
305129044dSC.J. Collier
315129044dSC.J. CollierNFP poll mode driver library
325129044dSC.J. Collier============================
335129044dSC.J. Collier
345129044dSC.J. CollierNetronome's sixth generation of flow processors pack 216 programmable
355129044dSC.J. Colliercores and over 100 hardware accelerators that uniquely combine packet,
365129044dSC.J. Collierflow, security and content processing in a single device that scales
375129044dSC.J. Collierup to 400 Gbps.
385129044dSC.J. Collier
395129044dSC.J. CollierThis document explains how to use DPDK with the Netronome Poll Mode
405129044dSC.J. CollierDriver (PMD) supporting Netronome's Network Flow Processor 6xxx
415129044dSC.J. Collier(NFP-6xxx).
425129044dSC.J. Collier
435129044dSC.J. CollierCurrently the driver supports virtual functions (VFs) only.
445129044dSC.J. Collier
455129044dSC.J. CollierDependencies
465129044dSC.J. Collier------------
475129044dSC.J. Collier
485129044dSC.J. CollierBefore using the Netronome's DPDK PMD some NFP-6xxx configuration,
495129044dSC.J. Collierwhich is not related to DPDK, is required. The system requires
505129044dSC.J. Collierinstallation of **Netronome's BSP (Board Support Package)** which includes
515129044dSC.J. CollierLinux drivers, programs and libraries.
525129044dSC.J. Collier
535129044dSC.J. CollierIf you have a NFP-6xxx device you should already have the code and
545129044dSC.J. Collierdocumentation for doing this configuration. Contact
555129044dSC.J. Collier**support@netronome.com** to obtain the latest available firmware.
565129044dSC.J. Collier
575129044dSC.J. CollierThe NFP Linux kernel drivers (including the required PF driver for the
585129044dSC.J. CollierNFP) are available on Github at
595129044dSC.J. Collier**https://github.com/Netronome/nfp-drv-kmods** along with build
605129044dSC.J. Collierinstructions.
615129044dSC.J. Collier
625129044dSC.J. CollierDPDK runs in userspace and PMDs uses the Linux kernel UIO interface to
635129044dSC.J. Collierallow access to physical devices from userspace. The NFP PMD requires
64809f0800SChristian Ehrhardtthe **igb_uio** UIO driver, available with DPDK, to perform correct
65809f0800SChristian Ehrhardtinitialization.
665129044dSC.J. Collier
675129044dSC.J. CollierBuilding the software
685129044dSC.J. Collier---------------------
695129044dSC.J. Collier
705129044dSC.J. CollierNetronome's PMD code is provided in the **drivers/net/nfp** directory.
715129044dSC.J. CollierBecause Netronome´s BSP dependencies the driver is disabled by default
725129044dSC.J. Collierin DPDK build using **common_linuxapp configuration** file. Enabling the
735129044dSC.J. Collierdriver or if you use another configuration file and want to have NFP
745129044dSC.J. Colliersupport, this variable is needed:
755129044dSC.J. Collier
765129044dSC.J. Collier- **CONFIG_RTE_LIBRTE_NFP_PMD=y**
775129044dSC.J. Collier
785129044dSC.J. CollierOnce DPDK is built all the DPDK apps and examples include support for
795129044dSC.J. Collierthe NFP PMD.
805129044dSC.J. Collier
815129044dSC.J. Collier
825129044dSC.J. CollierSystem configuration
835129044dSC.J. Collier--------------------
845129044dSC.J. Collier
855129044dSC.J. CollierUsing the NFP PMD is not different to using other PMDs. Usual steps are:
865129044dSC.J. Collier
875129044dSC.J. Collier#. **Configure hugepages:** All major Linux distributions have the hugepages
885129044dSC.J. Collier   functionality enabled by default. By default this allows the system uses for
895129044dSC.J. Collier   working with transparent hugepages. But in this case some hugepages need to
905129044dSC.J. Collier   be created/reserved for use with the DPDK through the hugetlbfs file system.
915129044dSC.J. Collier   First the virtual file system need to be mounted:
925129044dSC.J. Collier
935129044dSC.J. Collier   .. code-block:: console
945129044dSC.J. Collier
955129044dSC.J. Collier      mount -t hugetlbfs none /mnt/hugetlbfs
965129044dSC.J. Collier
975129044dSC.J. Collier   The command uses the common mount point for this file system and it needs to
985129044dSC.J. Collier   be created if necessary.
995129044dSC.J. Collier
1005129044dSC.J. Collier   Configuring hugepages is performed via sysfs:
1015129044dSC.J. Collier
1025129044dSC.J. Collier   .. code-block:: console
1035129044dSC.J. Collier
1045129044dSC.J. Collier      /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
1055129044dSC.J. Collier
1065129044dSC.J. Collier   This sysfs file is used to specify the number of hugepages to reserve.
1075129044dSC.J. Collier   For example:
1085129044dSC.J. Collier
1095129044dSC.J. Collier   .. code-block:: console
1105129044dSC.J. Collier
1115129044dSC.J. Collier      echo 1024 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
1125129044dSC.J. Collier
1135129044dSC.J. Collier   This will reserve 2GB of memory using 1024 2MB hugepages. The file may be
1145129044dSC.J. Collier   read to see if the operation was performed correctly:
1155129044dSC.J. Collier
1165129044dSC.J. Collier   .. code-block:: console
1175129044dSC.J. Collier
1185129044dSC.J. Collier      cat /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
1195129044dSC.J. Collier
1205129044dSC.J. Collier   The number of unused hugepages may also be inspected.
1215129044dSC.J. Collier
1225129044dSC.J. Collier   Before executing the DPDK app it should match the value of nr_hugepages.
1235129044dSC.J. Collier
1245129044dSC.J. Collier   .. code-block:: console
1255129044dSC.J. Collier
1265129044dSC.J. Collier      cat /sys/kernel/mm/hugepages/hugepages-2048kB/free_hugepages
1275129044dSC.J. Collier
1285129044dSC.J. Collier   The hugepages reservation should be performed at system initialization and
1295129044dSC.J. Collier   it is usual to use a kernel parameter for configuration. If the reservation
1305129044dSC.J. Collier   is attempted on a busy system it will likely fail. Reserving memory for
1315129044dSC.J. Collier   hugepages may be done adding the following to the grub kernel command line:
1325129044dSC.J. Collier
1335129044dSC.J. Collier   .. code-block:: console
1345129044dSC.J. Collier
1355129044dSC.J. Collier      default_hugepagesz=1M hugepagesz=2M hugepages=1024
1365129044dSC.J. Collier
1375129044dSC.J. Collier   This will reserve 2GBytes of memory using 2Mbytes huge pages.
1385129044dSC.J. Collier
1395129044dSC.J. Collier   Finally, for a NUMA system the allocation needs to be made on the correct
1405129044dSC.J. Collier   NUMA node. In a DPDK app there is a master core which will (usually) perform
1415129044dSC.J. Collier   memory allocation. It is important that some of the hugepages are reserved
1425129044dSC.J. Collier   on the NUMA memory node where the network device is attached. This is because
1435129044dSC.J. Collier   of a restriction in DPDK by which TX and RX descriptors rings must be created
1445129044dSC.J. Collier   on the master code.
1455129044dSC.J. Collier
1465129044dSC.J. Collier   Per-node allocation of hugepages may be inspected and controlled using sysfs.
1475129044dSC.J. Collier   For example:
1485129044dSC.J. Collier
1495129044dSC.J. Collier   .. code-block:: console
1505129044dSC.J. Collier
1515129044dSC.J. Collier      cat /sys/devices/system/node/node0/hugepages/hugepages-2048kB/nr_hugepages
1525129044dSC.J. Collier
1535129044dSC.J. Collier   For a NUMA system there will be a specific hugepage directory per node
1545129044dSC.J. Collier   allowing control of hugepage reservation. A common problem may occur when
1555129044dSC.J. Collier   hugepages reservation is performed after the system has been working for
1565129044dSC.J. Collier   some time. Configuration using the global sysfs hugepage interface will
1575129044dSC.J. Collier   succeed but the per-node allocations may be unsatisfactory.
1585129044dSC.J. Collier
1595129044dSC.J. Collier   The number of hugepages that need to be reserved depends on how the app uses
1605129044dSC.J. Collier   TX and RX descriptors, and packets mbufs.
1615129044dSC.J. Collier
1625129044dSC.J. Collier#. **Enable SR-IOV on the NFP-6xxx device:** The current NFP PMD works with
1635129044dSC.J. Collier   Virtual Functions (VFs) on a NFP device. Make sure that one of the Physical
1645129044dSC.J. Collier   Function (PF) drivers from the above Github repository is installed and
1655129044dSC.J. Collier   loaded.
1665129044dSC.J. Collier
1675129044dSC.J. Collier   Virtual Functions need to be enabled before they can be used with the PMD.
1685129044dSC.J. Collier   Before enabling the VFs it is useful to obtain information about the
1695129044dSC.J. Collier   current NFP PCI device detected by the system:
1705129044dSC.J. Collier
1715129044dSC.J. Collier   .. code-block:: console
1725129044dSC.J. Collier
1735129044dSC.J. Collier      lspci -d19ee:
1745129044dSC.J. Collier
1755129044dSC.J. Collier   Now, for example, configure two virtual functions on a NFP-6xxx device
1765129044dSC.J. Collier   whose PCI system identity is "0000:03:00.0":
1775129044dSC.J. Collier
1785129044dSC.J. Collier   .. code-block:: console
1795129044dSC.J. Collier
1805129044dSC.J. Collier      echo 2 > /sys/bus/pci/devices/0000:03:00.0/sriov_numvfs
1815129044dSC.J. Collier
1825129044dSC.J. Collier   The result of this command may be shown using lspci again:
1835129044dSC.J. Collier
1845129044dSC.J. Collier   .. code-block:: console
1855129044dSC.J. Collier
1865129044dSC.J. Collier      lspci -d19ee: -k
1875129044dSC.J. Collier
1885129044dSC.J. Collier   Two new PCI devices should appear in the output of the above command. The
1895129044dSC.J. Collier   -k option shows the device driver, if any, that devices are bound to.
1905129044dSC.J. Collier   Depending on the modules loaded at this point the new PCI devices may be
1915129044dSC.J. Collier   bound to nfp_netvf driver.
1925129044dSC.J. Collier
1935129044dSC.J. Collier#. **To install the uio kernel module (manually):** All major Linux
1945129044dSC.J. Collier   distributions have support for this kernel module so it is straightforward
1955129044dSC.J. Collier   to install it:
1965129044dSC.J. Collier
1975129044dSC.J. Collier   .. code-block:: console
1985129044dSC.J. Collier
1995129044dSC.J. Collier      modprobe uio
2005129044dSC.J. Collier
2015129044dSC.J. Collier   The module should now be listed by the lsmod command.
2025129044dSC.J. Collier
203809f0800SChristian Ehrhardt#. **To install the igb_uio kernel module (manually):** This module is part
204809f0800SChristian Ehrhardt   of DPDK sources and configured by default (CONFIG_RTE_EAL_IGB_UIO=y).
2055129044dSC.J. Collier
2065129044dSC.J. Collier   .. code-block:: console
2075129044dSC.J. Collier
208809f0800SChristian Ehrhardt      modprobe igb_uio.ko
2095129044dSC.J. Collier
2105129044dSC.J. Collier   The module should now be listed by the lsmod command.
2115129044dSC.J. Collier
212809f0800SChristian Ehrhardt   Depending on which NFP modules are loaded, it could be necessary to
213809f0800SChristian Ehrhardt   detach NFP devices from the nfp_netvf module. If this is the case the
214809f0800SChristian Ehrhardt   device needs to be unbound, for example:
2155129044dSC.J. Collier
2165129044dSC.J. Collier   .. code-block:: console
2175129044dSC.J. Collier
2185129044dSC.J. Collier      echo 0000:03:08.0 > /sys/bus/pci/devices/0000:03:08.0/driver/unbind
2195129044dSC.J. Collier
2205129044dSC.J. Collier      lspci -d19ee: -k
2215129044dSC.J. Collier
2225129044dSC.J. Collier   The output of lspci should now show that 0000:03:08.0 is not bound to
2235129044dSC.J. Collier   any driver.
2245129044dSC.J. Collier
225809f0800SChristian Ehrhardt   The next step is to add the NFP PCI ID to the IGB UIO driver:
2265129044dSC.J. Collier
2275129044dSC.J. Collier   .. code-block:: console
2285129044dSC.J. Collier
229809f0800SChristian Ehrhardt      echo 19ee 6003 > /sys/bus/pci/drivers/igb_uio/new_id
2305129044dSC.J. Collier
231809f0800SChristian Ehrhardt   And then to bind the device to the igb_uio driver:
2325129044dSC.J. Collier
2335129044dSC.J. Collier   .. code-block:: console
2345129044dSC.J. Collier
235809f0800SChristian Ehrhardt      echo 0000:03:08.0 > /sys/bus/pci/drivers/igb_uio/bind
2365129044dSC.J. Collier
2375129044dSC.J. Collier      lspci -d19ee: -k
2385129044dSC.J. Collier
239809f0800SChristian Ehrhardt   lspci should show that device bound to igb_uio driver.
2405129044dSC.J. Collier
241809f0800SChristian Ehrhardt#. **Using scripts to install and bind modules:** DPDK provides scripts which are
242809f0800SChristian Ehrhardt   useful for installing the UIO modules and for binding the right device to those
243809f0800SChristian Ehrhardt   modules avoiding doing so manually:
2445129044dSC.J. Collier
2455b1ff351SRicardo Salveti   * **dpdk-setup.sh**
2465b1ff351SRicardo Salveti   * **dpdk-devbind.py**
2475129044dSC.J. Collier
2485b1ff351SRicardo Salveti   Configuration may be performed by running dpdk-setup.sh which invokes
2495b1ff351SRicardo Salveti   dpdk-devbind.py as needed. Executing dpdk-setup.sh will display a menu of
2505129044dSC.J. Collier   configuration options.
251