New upstream version 16.11.9
[deb_dpdk.git] / doc / guides / freebsd_gsg / install_from_ports.rst
1 ..  BSD LICENSE
2     Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
3     All rights reserved.
4
5     Redistribution and use in source and binary forms, with or without
6     modification, are permitted provided that the following conditions
7     are met:
8
9     * Redistributions of source code must retain the above copyright
10     notice, this list of conditions and the following disclaimer.
11     * Redistributions in binary form must reproduce the above copyright
12     notice, this list of conditions and the following disclaimer in
13     the documentation and/or other materials provided with the
14     distribution.
15     * Neither the name of Intel Corporation nor the names of its
16     contributors may be used to endorse or promote products derived
17     from this software without specific prior written permission.
18
19     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20     "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21     LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22     A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23     OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24     SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25     LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26     DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27     THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29     OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
31 .. _install_from_ports:
32
33 Installing DPDK from the Ports Collection
34 =========================================
35
36 The easiest way to get up and running with the DPDK on FreeBSD is to
37 install it from the ports collection. Details of getting and using the ports
38 collection are documented in the
39 `FreeBSD Handbook <http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/index.html>`_.
40
41 .. note::
42
43     Testing has been performed using FreeBSD 10.0-RELEASE (x86_64) and requires the
44     installation of the kernel sources, which should be included during the
45     installation of FreeBSD.
46
47 Installing the DPDK FreeBSD Port
48 --------------------------------
49
50 On a system with the ports collection installed in ``/usr/ports``, the DPDK
51 can be installed using the commands:
52
53 .. code-block:: console
54
55     cd /usr/ports/net/dpdk
56
57     make install
58
59 After the installation of the DPDK port, instructions will be printed on
60 how to install the kernel modules required to use the DPDK. A more
61 complete version of these instructions can be found in the sections
62 :ref:`loading_contigmem` and :ref:`loading_nic_uio`. Normally, lines like
63 those below would be added to the file ``/boot/loader.conf``.
64
65 .. code-block:: console
66
67     # Reserve 2 x 1G blocks of contiguous memory using contigmem driver:
68     hw.contigmem.num_buffers=2
69     hw.contigmem.buffer_size=1073741824
70     contigmem_load="YES"
71
72     # Identify NIC devices for DPDK apps to use and load nic_uio driver:
73     hw.nic_uio.bdfs="2:0:0,2:0:1"
74     nic_uio_load="YES"
75
76 Compiling and Running the Example Applications
77 ----------------------------------------------
78
79 When the DPDK has been installed from the ports collection it installs
80 its example applications in ``/usr/local/share/dpdk/examples`` - also accessible via
81 symlink as ``/usr/local/share/examples/dpdk``. These examples can be compiled and
82 run as described in :ref:`compiling_sample_apps`. In this case, the required
83 environmental variables should be set as below:
84
85 * ``RTE_SDK=/usr/local/share/dpdk``
86
87 * ``RTE_TARGET=x86_64-native-bsdapp-clang``
88
89 .. note::
90
91    To install a copy of the DPDK compiled using gcc, please download the
92    official DPDK package from http://core.dpdk.org/download/ and install manually using
93    the instructions given in the next chapter, :ref:`building_from_source`
94
95 An example application can therefore be copied to a user's home directory and
96 compiled and run as below:
97
98 .. code-block:: console
99
100     export RTE_SDK=/usr/local/share/dpdk
101
102     export RTE_TARGET=x86_64-native-bsdapp-clang
103
104     cp -r /usr/local/share/dpdk/examples/helloworld .
105
106     cd helloworld/
107
108     gmake
109       CC main.o
110       LD helloworld
111       INSTALL-APP helloworld
112       INSTALL-MAP helloworld.map
113
114     sudo ./build/helloworld -c F -n 2
115
116     EAL: Contigmem driver has 2 buffers, each of size 1GB
117     EAL: Sysctl reports 8 cpus
118     EAL: Detected lcore 0
119     EAL: Detected lcore 1
120     EAL: Detected lcore 2
121     EAL: Detected lcore 3
122     EAL: Support maximum 64 logical core(s) by configuration.
123     EAL: Detected 4 lcore(s)
124     EAL: Setting up physically contiguous memory...
125     EAL: Mapped memory segment 1 @ 0x802400000: len 1073741824
126     EAL: Mapped memory segment 2 @ 0x842400000: len 1073741824
127     EAL: WARNING: clock_gettime cannot use CLOCK_MONOTONIC_RAW and HPET
128          is not available - clock timings may be less accurate.
129     EAL: TSC frequency is ~3569023 KHz
130     EAL: PCI scan found 24 devices
131     EAL: Master core 0 is ready (tid=0x802006400)
132     EAL: Core 1 is ready (tid=0x802006800)
133     EAL: Core 3 is ready (tid=0x802007000)
134     EAL: Core 2 is ready (tid=0x802006c00)
135     EAL: PCI device 0000:01:00.0 on NUMA socket 0
136     EAL:   probe driver: 8086:10fb rte_ixgbe_pmd
137     EAL:   PCI memory mapped at 0x80074a000
138     EAL:   PCI memory mapped at 0x8007ca000
139     EAL: PCI device 0000:01:00.1 on NUMA socket 0
140     EAL:   probe driver: 8086:10fb rte_ixgbe_pmd
141     EAL:   PCI memory mapped at 0x8007ce000
142     EAL:   PCI memory mapped at 0x80084e000
143     EAL: PCI device 0000:02:00.0 on NUMA socket 0
144     EAL:   probe driver: 8086:10fb rte_ixgbe_pmd
145     EAL:   PCI memory mapped at 0x800852000
146     EAL:   PCI memory mapped at 0x8008d2000
147     EAL: PCI device 0000:02:00.1 on NUMA socket 0
148     EAL:   probe driver: 8086:10fb rte_ixgbe_pmd
149     EAL:   PCI memory mapped at 0x801b3f000
150     EAL:   PCI memory mapped at 0x8008d6000
151     hello from core 1
152     hello from core 2
153     hello from core 3
154     hello from core 0
155
156 .. note::
157
158    To run a DPDK process as a non-root user, adjust the permissions on
159    the ``/dev/contigmem`` and ``/dev/uio device`` nodes as described in section
160    :ref:`running_non_root`
161
162 .. note::
163
164    For an explanation of the command-line parameters that can be passed to an
165    DPDK application, see section :ref:`running_sample_app`.