xref: /dpdk/doc/guides/freebsd_gsg/install_from_ports.rst (revision 80a081384e23d26cc0db45bc1826b299e9780e8e)
15630257fSFerruh Yigit..  SPDX-License-Identifier: BSD-3-Clause
25630257fSFerruh Yigit    Copyright(c) 2010-2014 Intel Corporation.
33e7b87ddSBruce Richardson
43e7b87ddSBruce Richardson.. _install_from_ports:
53e7b87ddSBruce Richardson
69c587847SSiobhan ButlerInstalling DPDK from the Ports Collection
79c587847SSiobhan Butler=========================================
83e7b87ddSBruce Richardson
99c587847SSiobhan ButlerThe easiest way to get up and running with the DPDK on FreeBSD is to
1041985dcfSBruce Richardsoninstall it using the FreeBSD `pkg` utility or from the ports collection.
1141985dcfSBruce RichardsonDetails of installing applications from packages or the ports collection are documented in the
1241985dcfSBruce Richardson`FreeBSD Handbook <http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/index.html>`_,
1341985dcfSBruce Richardsonchapter `Installing Applications: Packages and Ports <https://www.freebsd.org/doc/handbook/ports.html>`_.
143e7b87ddSBruce Richardson
1541985dcfSBruce Richardson.. note::
163e7b87ddSBruce Richardson
1741985dcfSBruce Richardson   Please ensure that the latest patches are applied to third party libraries
1841985dcfSBruce Richardson   and software to avoid any known vulnerabilities.
193e7b87ddSBruce Richardson
203e7b87ddSBruce Richardson
2141985dcfSBruce RichardsonInstalling the DPDK Package for FreeBSD
2241985dcfSBruce Richardson---------------------------------------
233e7b87ddSBruce Richardson
2441985dcfSBruce RichardsonDPDK can be installed on FreeBSD using the command::
253e7b87ddSBruce Richardson
2641985dcfSBruce Richardson	pkg install dpdk
2741985dcfSBruce Richardson
2841985dcfSBruce RichardsonAfter the installation of the DPDK package, instructions will be printed on
299c587847SSiobhan Butlerhow to install the kernel modules required to use the DPDK. A more
303e7b87ddSBruce Richardsoncomplete version of these instructions can be found in the sections
313e7b87ddSBruce Richardson:ref:`loading_contigmem` and :ref:`loading_nic_uio`. Normally, lines like
32728c9e54SJohn McNamarathose below would be added to the file ``/boot/loader.conf``.
333e7b87ddSBruce Richardson
3441985dcfSBruce Richardson.. code-block:: shell
353e7b87ddSBruce Richardson
36728c9e54SJohn McNamara    # Reserve 2 x 1G blocks of contiguous memory using contigmem driver:
373e7b87ddSBruce Richardson    hw.contigmem.num_buffers=2
383e7b87ddSBruce Richardson    hw.contigmem.buffer_size=1073741824
393e7b87ddSBruce Richardson    contigmem_load="YES"
40728c9e54SJohn McNamara
41728c9e54SJohn McNamara    # Identify NIC devices for DPDK apps to use and load nic_uio driver:
423e7b87ddSBruce Richardson    hw.nic_uio.bdfs="2:0:0,2:0:1"
433e7b87ddSBruce Richardson    nic_uio_load="YES"
443e7b87ddSBruce Richardson
45e090fdb4SJohn McNamara
4641985dcfSBruce RichardsonInstalling the DPDK FreeBSD Port
4741985dcfSBruce Richardson--------------------------------
4841985dcfSBruce Richardson
4941985dcfSBruce RichardsonIf so desired, the user can install DPDK using the ports collection rather than from
5041985dcfSBruce Richardsona pre-compiled binary package.
5141985dcfSBruce RichardsonOn a system with the ports collection installed in ``/usr/ports``, the DPDK
5241985dcfSBruce Richardsoncan be installed using the commands::
5341985dcfSBruce Richardson
5441985dcfSBruce Richardson    cd /usr/ports/net/dpdk
5541985dcfSBruce Richardson
5641985dcfSBruce Richardson    make install
57e090fdb4SJohn McNamara
58e090fdb4SJohn McNamara
593e7b87ddSBruce RichardsonCompiling and Running the Example Applications
603e7b87ddSBruce Richardson----------------------------------------------
613e7b87ddSBruce Richardson
629c587847SSiobhan ButlerWhen the DPDK has been installed from the ports collection it installs
6341985dcfSBruce Richardsonits example applications in ``/usr/local/share/dpdk/examples``.
6441985dcfSBruce RichardsonThese examples can be compiled and run as described in :ref:`compiling_sample_apps`.
653e7b87ddSBruce Richardson
6641985dcfSBruce Richardson.. note::
673e7b87ddSBruce Richardson
6841985dcfSBruce Richardson   DPDK example applications must be complied using `gmake` rather than
6941985dcfSBruce Richardson   BSD `make`. To detect the installed DPDK libraries, `pkg-config` should
7041985dcfSBruce Richardson   also be installed on the system.
713e7b87ddSBruce Richardson
723e7b87ddSBruce Richardson.. note::
733e7b87ddSBruce Richardson
749c587847SSiobhan Butler   To install a copy of the DPDK compiled using gcc, please download the
753d4b2afbSDavid Marchand   official DPDK package from https://core.dpdk.org/download/ and install manually using
763e7b87ddSBruce Richardson   the instructions given in the next chapter, :ref:`building_from_source`
773e7b87ddSBruce Richardson
783e7b87ddSBruce RichardsonAn example application can therefore be copied to a user's home directory and
7941985dcfSBruce Richardsoncompiled and run as below, where we have 2 memory blocks of size 1G reserved
8041985dcfSBruce Richardsonvia the contigmem module, and 4 NIC ports bound to the nic_uio module::
813e7b87ddSBruce Richardson
82728c9e54SJohn McNamara    cp -r /usr/local/share/dpdk/examples/helloworld .
833e7b87ddSBruce Richardson
84728c9e54SJohn McNamara    cd helloworld/
853e7b87ddSBruce Richardson
86728c9e54SJohn McNamara    gmake
87*80a08138SStephen Hemminger    cc -O3 -I/usr/local/include -include rte_config.h -march=corei7 -D__BSD_VISIBLE  main.c -o build/helloworld-shared  -L/usr/local/lib -lrte_bpf -lrte_pipeline -lrte_table -lrte_port -lrte_fib -lrte_ipsec -lrte_stack -lrte_security -lrte_sched -lrte_reorder -lrte_rib -lrte_rcu -lrte_rawdev -lrte_pdump -lrte_member -lrte_lpm -lrte_latencystats -lrte_jobstats -lrte_ip_frag -lrte_gso -lrte_gro -lrte_eventdev -lrte_efd -lrte_distributor -lrte_cryptodev -lrte_compressdev -lrte_cfgfile -lrte_bitratestats -lrte_bbdev -lrte_acl -lrte_timer -lrte_hash -lrte_metrics -lrte_cmdline -lrte_pci -lrte_ethdev -lrte_meter -lrte_net -lrte_mbuf -lrte_mempool -lrte_ring -lrte_eal -lrte_kvargs
8841985dcfSBruce Richardson    ln -sf helloworld-shared build/helloworld
893e7b87ddSBruce Richardson
9041985dcfSBruce Richardson    sudo ./build/helloworld -l 0-3
913e7b87ddSBruce Richardson    EAL: Sysctl reports 8 cpus
92e21ee740SBruce Richardson    EAL: Detected 8 lcore(s)
93e21ee740SBruce Richardson    EAL: Detected 1 NUMA nodes
94e21ee740SBruce Richardson    EAL: Multi-process socket /var/run/dpdk/rte/mp_socket
95e21ee740SBruce Richardson    EAL: Selected IOVA mode 'PA'
96e21ee740SBruce Richardson    EAL: Contigmem driver has 2 buffers, each of size 1GB
97e21ee740SBruce Richardson    EAL: Mapped memory segment 0 @ 0x1040000000: physaddr:0x180000000, len 1073741824
98e21ee740SBruce Richardson    EAL: Mapped memory segment 1 @ 0x1080000000: physaddr:0x1c0000000, len 1073741824
99e21ee740SBruce Richardson    EAL: PCI device 0000:00:19.0 on NUMA socket 0
100e21ee740SBruce Richardson    EAL:   probe driver: 8086:153b net_e1000_em
101e21ee740SBruce Richardson    EAL:   0000:00:19.0 not managed by UIO driver, skipping
1023e7b87ddSBruce Richardson    EAL: PCI device 0000:01:00.0 on NUMA socket 0
103e21ee740SBruce Richardson    EAL:   probe driver: 8086:1572 net_i40e
1043e7b87ddSBruce Richardson    EAL: PCI device 0000:01:00.1 on NUMA socket 0
105e21ee740SBruce Richardson    EAL:   probe driver: 8086:1572 net_i40e
106e21ee740SBruce Richardson    EAL: PCI device 0000:01:00.2 on NUMA socket 0
107e21ee740SBruce Richardson    EAL:   probe driver: 8086:1572 net_i40e
108e21ee740SBruce Richardson    EAL: PCI device 0000:01:00.3 on NUMA socket 0
109e21ee740SBruce Richardson    EAL:   probe driver: 8086:1572 net_i40e
1103e7b87ddSBruce Richardson    hello from core 1
1113e7b87ddSBruce Richardson    hello from core 2
1123e7b87ddSBruce Richardson    hello from core 3
1133e7b87ddSBruce Richardson    hello from core 0
1143e7b87ddSBruce Richardson
115e21ee740SBruce Richardson
1163e7b87ddSBruce Richardson.. note::
1173e7b87ddSBruce Richardson
1189c587847SSiobhan Butler   To run a DPDK process as a non-root user, adjust the permissions on
119728c9e54SJohn McNamara   the ``/dev/contigmem`` and ``/dev/uio device`` nodes as described in section
1203e7b87ddSBruce Richardson   :ref:`running_non_root`
1213e7b87ddSBruce Richardson
1223e7b87ddSBruce Richardson.. note::
123728c9e54SJohn McNamara
1243e7b87ddSBruce Richardson   For an explanation of the command-line parameters that can be passed to an
1259c587847SSiobhan Butler   DPDK application, see section :ref:`running_sample_app`.
126