1a9263e3cSJerin Jacob.. SPDX-License-Identifier: BSD-3-Clause 2a9263e3cSJerin Jacob Copyright(c) 2017 Cavium, Inc 3e682cb5dSShijith Thotton 4e682cb5dSShijith Thotton.. _pmd_build_and_test: 5e682cb5dSShijith Thotton 6e682cb5dSShijith ThottonCompiling and testing a PMD for a NIC 7e682cb5dSShijith Thotton===================================== 8e682cb5dSShijith Thotton 9e682cb5dSShijith ThottonThis section demonstrates how to compile and run a Poll Mode Driver (PMD) for 10e682cb5dSShijith Thottonthe available Network Interface Cards in DPDK using TestPMD. 11e682cb5dSShijith Thotton 12e682cb5dSShijith ThottonTestPMD is one of the reference applications distributed with the DPDK. Its main 13e682cb5dSShijith Thottonpurpose is to forward packets between Ethernet ports on a network interface and 14e682cb5dSShijith Thottonas such is the best way to test a PMD. 15e682cb5dSShijith Thotton 16e682cb5dSShijith ThottonRefer to the :ref:`testpmd application user guide <testpmd_ug>` for detailed 17e682cb5dSShijith Thottoninformation on how to build and run testpmd. 18e682cb5dSShijith Thotton 19e682cb5dSShijith ThottonDriver Compilation 20e682cb5dSShijith Thotton------------------ 21e682cb5dSShijith Thotton 22582e9d77SThomas MonjalonTo compile a PMD for a platform, build DPDK 23582e9d77SThomas Monjalonas described in the "Getting Started Guide" for your platform. 24582e9d77SThomas MonjalonThis will also build testpmd. 25e682cb5dSShijith Thotton 26582e9d77SThomas MonjalonDetailed instructions are available 27582e9d77SThomas Monjalonin the :doc:`meson build guide <../prog_guide/build-sdk-meson>`. 28e682cb5dSShijith Thotton 29bb6270daSQi ZhangThe ethdev layer supports below build options for debug purpose: 30bb6270daSQi Zhang 31bb6270daSQi Zhang- ``RTE_ETHDEV_DEBUG_RX`` (default **disabled**) 32bb6270daSQi Zhang 33bb6270daSQi Zhang Build with debug code on Rx path. 34bb6270daSQi Zhang 35bb6270daSQi Zhang- ``RTE_ETHDEV_DEBUG_TX`` (default **disabled**) 36bb6270daSQi Zhang 37bb6270daSQi Zhang Build with debug code on Tx path. 38bb6270daSQi Zhang 39*537bfddaSDariusz Sosnowski- ``RTE_FLOW_DEBUG`` (default **disabled**; enabled automatically on debug builds) 40*537bfddaSDariusz Sosnowski 41*537bfddaSDariusz Sosnowski Build with debug code in asynchronous flow API. 42*537bfddaSDariusz Sosnowski 43bb6270daSQi Zhang.. Note:: 44bb6270daSQi Zhang 45*537bfddaSDariusz Sosnowski The ethdev library uses above options to wrap debug code to trace invalid parameters 46bb6270daSQi Zhang on data path APIs, so performance downgrade is expected when enabling those options. 47*537bfddaSDariusz Sosnowski Each PMD can decide to reuse them to wrap their own debug code in the Rx/Tx path 48*537bfddaSDariusz Sosnowski and in asynchronous flow API implementation. 49bb6270daSQi Zhang 50e682cb5dSShijith ThottonRunning testpmd in Linux 51e682cb5dSShijith Thotton------------------------ 52e682cb5dSShijith Thotton 53e682cb5dSShijith ThottonThis section demonstrates how to setup and run ``testpmd`` in Linux. 54e682cb5dSShijith Thotton 55e682cb5dSShijith Thotton#. Mount huge pages: 56e682cb5dSShijith Thotton 57e682cb5dSShijith Thotton .. code-block:: console 58e682cb5dSShijith Thotton 59e682cb5dSShijith Thotton mkdir /mnt/huge 60e682cb5dSShijith Thotton mount -t hugetlbfs nodev /mnt/huge 61e682cb5dSShijith Thotton 62e682cb5dSShijith Thotton#. Request huge pages: 63e682cb5dSShijith Thotton 64e682cb5dSShijith Thotton Hugepage memory should be reserved as per application requirement. Check 65e682cb5dSShijith Thotton hugepage size configured in the system and calculate the number of pages 66e682cb5dSShijith Thotton required. 67e682cb5dSShijith Thotton 68e682cb5dSShijith Thotton To reserve 1024 pages of 2MB: 69e682cb5dSShijith Thotton 70e682cb5dSShijith Thotton .. code-block:: console 71e682cb5dSShijith Thotton 72e682cb5dSShijith Thotton echo 1024 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages 73e682cb5dSShijith Thotton 74e682cb5dSShijith Thotton .. note:: 75e682cb5dSShijith Thotton 76e682cb5dSShijith Thotton Check ``/proc/meminfo`` to find system hugepage size: 77e682cb5dSShijith Thotton 78e682cb5dSShijith Thotton .. code-block:: console 79e682cb5dSShijith Thotton 80e682cb5dSShijith Thotton grep "Hugepagesize:" /proc/meminfo 81e682cb5dSShijith Thotton 82e682cb5dSShijith Thotton Example output: 83e682cb5dSShijith Thotton 84e682cb5dSShijith Thotton .. code-block:: console 85e682cb5dSShijith Thotton 86e682cb5dSShijith Thotton Hugepagesize: 2048 kB 87e682cb5dSShijith Thotton 88de34aaa9SThomas Monjalon Mount and request above can be achieved simply with this tool: 89de34aaa9SThomas Monjalon 90de34aaa9SThomas Monjalon .. code-block:: console 91de34aaa9SThomas Monjalon 92de34aaa9SThomas Monjalon dpdk-hugepages.py --setup 2G 93de34aaa9SThomas Monjalon 94e682cb5dSShijith Thotton#. Load ``igb_uio`` or ``vfio-pci`` driver: 95e682cb5dSShijith Thotton 96e682cb5dSShijith Thotton .. code-block:: console 97e682cb5dSShijith Thotton 98e682cb5dSShijith Thotton modprobe uio 9956bb5841SThomas Monjalon insmod igb_uio.ko 100e682cb5dSShijith Thotton 101e682cb5dSShijith Thotton or 102e682cb5dSShijith Thotton 103e682cb5dSShijith Thotton .. code-block:: console 104e682cb5dSShijith Thotton 105e682cb5dSShijith Thotton modprobe vfio-pci 106e682cb5dSShijith Thotton 107e682cb5dSShijith Thotton#. Setup VFIO permissions for regular users before binding to ``vfio-pci``: 108e682cb5dSShijith Thotton 109e682cb5dSShijith Thotton .. code-block:: console 110e682cb5dSShijith Thotton 111e682cb5dSShijith Thotton sudo chmod a+x /dev/vfio 112e682cb5dSShijith Thotton 113e682cb5dSShijith Thotton sudo chmod 0666 /dev/vfio/* 114e682cb5dSShijith Thotton 115e682cb5dSShijith Thotton#. Bind the adapters to ``igb_uio`` or ``vfio-pci`` loaded in the previous step: 116e682cb5dSShijith Thotton 117e682cb5dSShijith Thotton .. code-block:: console 118e682cb5dSShijith Thotton 119e682cb5dSShijith Thotton ./usertools/dpdk-devbind.py --bind igb_uio DEVICE1 DEVICE2 ... 120e682cb5dSShijith Thotton 121e682cb5dSShijith Thotton Or setup VFIO permissions for regular users and then bind to ``vfio-pci``: 122e682cb5dSShijith Thotton 123e682cb5dSShijith Thotton .. code-block:: console 124e682cb5dSShijith Thotton 125e682cb5dSShijith Thotton ./usertools/dpdk-devbind.py --bind vfio-pci DEVICE1 DEVICE2 ... 126e682cb5dSShijith Thotton 127e682cb5dSShijith Thotton .. note:: 128e682cb5dSShijith Thotton 129e682cb5dSShijith Thotton DEVICE1, DEVICE2 are specified via PCI "domain:bus:slot.func" syntax or 130e682cb5dSShijith Thotton "bus:slot.func" syntax. 131e682cb5dSShijith Thotton 132e682cb5dSShijith Thotton#. Start ``testpmd`` with basic parameters: 133e682cb5dSShijith Thotton 134e682cb5dSShijith Thotton .. code-block:: console 135e682cb5dSShijith Thotton 13668d99d00SCiara Power ./<build_dir>/app/dpdk-testpmd -l 0-3 -n 4 -- -i 137e682cb5dSShijith Thotton 138e682cb5dSShijith Thotton Successful execution will show initialization messages from EAL, PMD and 139e682cb5dSShijith Thotton testpmd application. A prompt will be displayed at the end for user commands 140e682cb5dSShijith Thotton as interactive mode (``-i``) is on. 141e682cb5dSShijith Thotton 142e682cb5dSShijith Thotton .. code-block:: console 143e682cb5dSShijith Thotton 144e682cb5dSShijith Thotton testpmd> 145e682cb5dSShijith Thotton 146e682cb5dSShijith Thotton Refer to the :ref:`testpmd runtime functions <testpmd_runtime>` for a list 147e682cb5dSShijith Thotton of available commands. 14816126326SVipin Varghese 14916126326SVipin Varghese .. note:: 15016126326SVipin Varghese When ``testpmd`` is built with shared library, use option ``-d`` to load 15116126326SVipin Varghese the dynamic PMD for ``rte_eal_init``. 152