1 .. SPDX-License-Identifier: BSD-3-Clause
2 Copyright(c) 2017 Cavium, Inc
4 .. _pmd_build_and_test:
6 Compiling and testing a PMD for a NIC
7 =====================================
9 This section demonstrates how to compile and run a Poll Mode Driver (PMD) for
10 the available Network Interface Cards in DPDK using TestPMD.
12 TestPMD is one of the reference applications distributed with the DPDK. Its main
13 purpose is to forward packets between Ethernet ports on a network interface and
14 as such is the best way to test a PMD.
16 Refer to the :ref:`testpmd application user guide <testpmd_ug>` for detailed
17 information on how to build and run testpmd.
22 To compile a PMD for a platform, build DPDK
23 as described in the "Getting Started Guide" for your platform.
24 This will also build testpmd.
26 Detailed instructions are available
27 in the :doc:`meson build guide <../prog_guide/build-sdk-meson>`.
29 Running testpmd in Linux
30 ------------------------
32 This section demonstrates how to setup and run ``testpmd`` in Linux.
36 .. code-block:: console
39 mount -t hugetlbfs nodev /mnt/huge
41 #. Request huge pages:
43 Hugepage memory should be reserved as per application requirement. Check
44 hugepage size configured in the system and calculate the number of pages
47 To reserve 1024 pages of 2MB:
49 .. code-block:: console
51 echo 1024 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
55 Check ``/proc/meminfo`` to find system hugepage size:
57 .. code-block:: console
59 grep "Hugepagesize:" /proc/meminfo
63 .. code-block:: console
67 #. Load ``igb_uio`` or ``vfio-pci`` driver:
69 .. code-block:: console
76 .. code-block:: console
80 #. Setup VFIO permissions for regular users before binding to ``vfio-pci``:
82 .. code-block:: console
84 sudo chmod a+x /dev/vfio
86 sudo chmod 0666 /dev/vfio/*
88 #. Bind the adapters to ``igb_uio`` or ``vfio-pci`` loaded in the previous step:
90 .. code-block:: console
92 ./usertools/dpdk-devbind.py --bind igb_uio DEVICE1 DEVICE2 ...
94 Or setup VFIO permissions for regular users and then bind to ``vfio-pci``:
96 .. code-block:: console
98 ./usertools/dpdk-devbind.py --bind vfio-pci DEVICE1 DEVICE2 ...
102 DEVICE1, DEVICE2 are specified via PCI "domain:bus:slot.func" syntax or
103 "bus:slot.func" syntax.
105 #. Start ``testpmd`` with basic parameters:
107 .. code-block:: console
109 ./<build_dir>/app/dpdk-testpmd -l 0-3 -n 4 -- -i
111 Successful execution will show initialization messages from EAL, PMD and
112 testpmd application. A prompt will be displayed at the end for user commands
113 as interactive mode (``-i``) is on.
115 .. code-block:: console
119 Refer to the :ref:`testpmd runtime functions <testpmd_runtime>` for a list
120 of available commands.
123 When ``testpmd`` is built with shared library, use option ``-d`` to load
124 the dynamic PMD for ``rte_eal_init``.