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, run make with appropriate target as shown below.
23 Use "make" command in Linux and "gmake" in FreeBSD. This will also build testpmd.
25 To check available targets:
27 .. code-block:: console
29 cd <DPDK-source-directory>
34 .. code-block:: console
36 arm-armv7a-linuxapp-gcc
37 arm64-armv8a-linuxapp-gcc
38 arm64-dpaa2-linuxapp-gcc
39 arm64-thunderx-linuxapp-gcc
40 arm64-xgene1-linuxapp-gcc
41 i686-native-linuxapp-gcc
42 i686-native-linuxapp-icc
43 ppc_64-power8-linuxapp-gcc
44 x86_64-native-bsdapp-clang
45 x86_64-native-bsdapp-gcc
46 x86_64-native-linuxapp-clang
47 x86_64-native-linuxapp-gcc
48 x86_64-native-linuxapp-icc
49 x86_x32-native-linuxapp-gcc
51 To compile a PMD for Linux x86_64 gcc target, run the following "make" command:
53 .. code-block:: console
55 make install T=x86_64-native-linuxapp-gcc
57 Use ARM (ThunderX, DPAA, X-Gene) or PowerPC target for respective platform.
59 For more information, refer to the :ref:`Getting Started Guide for Linux <linux_gsg>`
60 or :ref:`Getting Started Guide for FreeBSD <freebsd_gsg>` depending on your platform.
62 Running testpmd in Linux
63 ------------------------
65 This section demonstrates how to setup and run ``testpmd`` in Linux.
69 .. code-block:: console
72 mount -t hugetlbfs nodev /mnt/huge
74 #. Request huge pages:
76 Hugepage memory should be reserved as per application requirement. Check
77 hugepage size configured in the system and calculate the number of pages
80 To reserve 1024 pages of 2MB:
82 .. code-block:: console
84 echo 1024 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
88 Check ``/proc/meminfo`` to find system hugepage size:
90 .. code-block:: console
92 grep "Hugepagesize:" /proc/meminfo
96 .. code-block:: console
100 #. Load ``igb_uio`` or ``vfio-pci`` driver:
102 .. code-block:: console
105 insmod ./x86_64-native-linuxapp-gcc/kmod/igb_uio.ko
109 .. code-block:: console
113 #. Setup VFIO permissions for regular users before binding to ``vfio-pci``:
115 .. code-block:: console
117 sudo chmod a+x /dev/vfio
119 sudo chmod 0666 /dev/vfio/*
121 #. Bind the adapters to ``igb_uio`` or ``vfio-pci`` loaded in the previous step:
123 .. code-block:: console
125 ./usertools/dpdk-devbind.py --bind igb_uio DEVICE1 DEVICE2 ...
127 Or setup VFIO permissions for regular users and then bind to ``vfio-pci``:
129 .. code-block:: console
131 ./usertools/dpdk-devbind.py --bind vfio-pci DEVICE1 DEVICE2 ...
135 DEVICE1, DEVICE2 are specified via PCI "domain:bus:slot.func" syntax or
136 "bus:slot.func" syntax.
138 #. Start ``testpmd`` with basic parameters:
140 .. code-block:: console
142 ./x86_64-native-linuxapp-gcc/app/testpmd -l 0-3 -n 4 -- -i
144 Successful execution will show initialization messages from EAL, PMD and
145 testpmd application. A prompt will be displayed at the end for user commands
146 as interactive mode (``-i``) is on.
148 .. code-block:: console
152 Refer to the :ref:`testpmd runtime functions <testpmd_runtime>` for a list
153 of available commands.
156 When ``testpmd`` is built with shared library, use option ``-d`` to load
157 the dynamic PMD for ``rte_eal_init``.