doc: fix spellings and typos
[dpdk.git] / doc / guides / nics / mlx4.rst
1 ..  BSD LICENSE
2     Copyright 2012-2015 6WIND S.A.
3
4     Redistribution and use in source and binary forms, with or without
5     modification, are permitted provided that the following conditions
6     are met:
7
8     * Redistributions of source code must retain the above copyright
9     notice, this list of conditions and the following disclaimer.
10     * Redistributions in binary form must reproduce the above copyright
11     notice, this list of conditions and the following disclaimer in
12     the documentation and/or other materials provided with the
13     distribution.
14     * Neither the name of 6WIND S.A. nor the names of its
15     contributors may be used to endorse or promote products derived
16     from this software without specific prior written permission.
17
18     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19     "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20     LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21     A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22     OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23     SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24     LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25     DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26     THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28     OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
30 MLX4 poll mode driver library
31 =============================
32
33 The MLX4 poll mode driver library (**librte_pmd_mlx4**) implements support
34 for **Mellanox ConnectX-3 EN** 10/40 Gbps adapters as well as their virtual
35 functions (VF) in SR-IOV context.
36
37 Information and documentation about this family of adapters can be found on
38 the `Mellanox website <http://www.mellanox.com>`_. Help is also provided by
39 the `Mellanox community <http://community.mellanox.com/welcome>`_.
40
41 There is also a `section dedicated to this poll mode driver
42 <http://www.mellanox.com/page/products_dyn?product_family=209&mtag=pmd_for_dpdk>`_.
43
44 .. note::
45
46    Due to external dependencies, this driver is disabled by default. It must
47    be enabled manually by setting ``CONFIG_RTE_LIBRTE_MLX4_PMD=y`` and
48    recompiling DPDK.
49
50 Implementation details
51 ----------------------
52
53 Most Mellanox ConnectX-3 devices provide two ports but expose a single PCI
54 bus address, thus unlike most drivers, librte_pmd_mlx4 registers itself as a
55 PCI driver that allocates one Ethernet device per detected port.
56
57 For this reason, one cannot white/blacklist a single port without also
58 white/blacklisting the others on the same device.
59
60 Besides its dependency on libibverbs (that implies libmlx4 and associated
61 kernel support), librte_pmd_mlx4 relies heavily on system calls for control
62 operations such as querying/updating the MTU and flow control parameters.
63
64 For security reasons and robustness, this driver only deals with virtual
65 memory addresses. The way resources allocations are handled by the kernel
66 combined with hardware specifications that allow it to handle virtual memory
67 addresses directly ensure that DPDK applications cannot access random
68 physical memory (or memory that does not belong to the current process).
69
70 This capability allows the PMD to coexist with kernel network interfaces
71 which remain functional, although they stop receiving unicast packets as
72 long as they share the same MAC address.
73
74 Compiling librte_pmd_mlx4 causes DPDK to be linked against libibverbs.
75
76 Features and limitations
77 ------------------------
78
79 - RSS, also known as RCA, is supported. In this mode the number of
80   configured RX queues must be a power of two.
81 - VLAN filtering is supported.
82 - Link state information is provided.
83 - Promiscuous mode is supported.
84 - All multicast mode is supported.
85 - Multiple MAC addresses (unicast, multicast) can be configured.
86 - Scattered packets are supported for TX and RX.
87
88 .. break
89
90 - RSS hash key cannot be modified.
91 - Hardware counters are not implemented (they are software counters).
92 - Checksum offloads are not supported yet.
93
94 Configuration
95 -------------
96
97 Compilation options
98 ~~~~~~~~~~~~~~~~~~~
99
100 These options can be modified in the ``.config`` file.
101
102 - ``CONFIG_RTE_LIBRTE_MLX4_PMD`` (default **n**)
103
104   Toggle compilation of librte_pmd_mlx4 itself.
105
106 - ``CONFIG_RTE_LIBRTE_MLX4_DEBUG`` (default **n**)
107
108   Toggle debugging code and stricter compilation flags. Enabling this option
109   adds additional run-time checks and debugging messages at the cost of
110   lower performance.
111
112 - ``CONFIG_RTE_LIBRTE_MLX4_SGE_WR_N`` (default **4**)
113
114   Number of scatter/gather elements (SGEs) per work request (WR). Lowering
115   this number improves performance but also limits the ability to receive
116   scattered packets (packets that do not fit a single mbuf). The default
117   value is a safe tradeoff.
118
119 - ``CONFIG_RTE_LIBRTE_MLX4_MAX_INLINE`` (default **0**)
120
121   Amount of data to be inlined during TX operations. Improves latency but
122   lowers throughput.
123
124 - ``CONFIG_RTE_LIBRTE_MLX4_TX_MP_CACHE`` (default **8**)
125
126   Maximum number of cached memory pools (MPs) per TX queue. Each MP from
127   which buffers are to be transmitted must be associated to memory regions
128   (MRs). This is a slow operation that must be cached.
129
130   This value is always 1 for RX queues since they use a single MP.
131
132 - ``CONFIG_RTE_LIBRTE_MLX4_SOFT_COUNTERS`` (default **1**)
133
134   Toggle software counters. No counters are available if this option is
135   disabled since hardware counters are not supported.
136
137 Environment variables
138 ~~~~~~~~~~~~~~~~~~~~~
139
140 - ``MLX4_INLINE_RECV_SIZE``
141
142   A nonzero value enables inline receive for packets up to that size. May
143   significantly improve performance in some cases but lower it in
144   others. Requires careful testing.
145
146 Run-time configuration
147 ~~~~~~~~~~~~~~~~~~~~~~
148
149 - The only constraint when RSS mode is requested is to make sure the number
150   of RX queues is a power of two. This is a hardware requirement.
151
152 - librte_pmd_mlx4 brings kernel network interfaces up during initialization
153   because it is affected by their state. Forcing them down prevents packets
154   reception.
155
156 - **ethtool** operations on related kernel interfaces also affect the PMD.
157
158 Kernel module parameters
159 ~~~~~~~~~~~~~~~~~~~~~~~~
160
161 The **mlx4_core** kernel module has several parameters that affect the
162 behavior and/or the performance of librte_pmd_mlx4. Some of them are described
163 below.
164
165 - **num_vfs** (integer or triplet, optionally prefixed by device address
166   strings)
167
168   Create the given number of VFs on the specified devices.
169
170 - **log_num_mgm_entry_size** (integer)
171
172   Device-managed flow steering (DMFS) is required by DPDK applications. It is
173   enabled by using a negative value, the last four bits of which have a
174   special meaning.
175
176   - **-1**: force device-managed flow steering (DMFS).
177   - **-7**: configure optimized steering mode to improve performance with the
178     following limitation: Ethernet frames with the port MAC address as the
179     destination cannot be received, even in promiscuous mode. Additional MAC
180     addresses can still be set by ``rte_eth_dev_mac_addr_addr()``.
181
182 Prerequisites
183 -------------
184
185 This driver relies on external libraries and kernel drivers for resources
186 allocations and initialization. The following dependencies are not part of
187 DPDK and must be installed separately:
188
189 - **libibverbs**
190
191   User space verbs framework used by librte_pmd_mlx4. This library provides
192   a generic interface between the kernel and low-level user space drivers
193   such as libmlx4.
194
195   It allows slow and privileged operations (context initialization, hardware
196   resources allocations) to be managed by the kernel and fast operations to
197   never leave user space.
198
199 - **libmlx4**
200
201   Low-level user space driver library for Mellanox ConnectX-3 devices,
202   it is automatically loaded by libibverbs.
203
204   This library basically implements send/receive calls to the hardware
205   queues.
206
207 - **Kernel modules** (mlnx-ofed-kernel)
208
209   They provide the kernel-side verbs API and low level device drivers that
210   manage actual hardware initialization and resources sharing with user
211   space processes.
212
213   Unlike most other PMDs, these modules must remain loaded and bound to
214   their devices:
215
216   - mlx4_core: hardware driver managing Mellanox ConnectX-3 devices.
217   - mlx4_en: Ethernet device driver that provides kernel network interfaces.
218   - mlx4_ib: InifiniBand device driver.
219   - ib_uverbs: user space driver for verbs (entry point for libibverbs).
220
221 - **Firmware update**
222
223   Mellanox OFED releases include firmware updates for ConnectX-3 adapters.
224
225   Because each release provides new features, these updates must be applied to
226   match the kernel modules and libraries they come with.
227
228 .. note::
229
230    Both libraries are BSD and GPL licensed. Linux kernel modules are GPL
231    licensed.
232
233 Currently supported by DPDK:
234
235 - Mellanox OFED **2.4-1**.
236 - Firmware version **2.33.5000** and higher.
237
238 Getting Mellanox OFED
239 ~~~~~~~~~~~~~~~~~~~~~
240
241 While these libraries and kernel modules are available on OpenFabrics
242 Alliance's `website <https://www.openfabrics.org/>`_ and provided by package
243 managers on most distributions, this PMD requires Ethernet extensions that
244 may not be supported at the moment (this is a work in progress).
245
246 `Mellanox OFED
247 <http://www.mellanox.com/page/products_dyn?product_family=26&mtag=linux_sw_drivers>`_
248 includes the necessary support and should be used in the meantime. For DPDK,
249 only libibverbs, libmlx4, mlnx-ofed-kernel packages and firmware updates are
250 required from that distribution.
251
252 .. note::
253
254    Several versions of Mellanox OFED are available. Installing the version
255    this DPDK release was developed and tested against is strongly
256    recommended. Please check the `prerequisites`_.
257
258 Getting libibverbs and libmlx4 from DPDK.org
259 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
260
261 Based on Mellanox OFED, optimized libibverbs and libmlx4 versions can be
262 optionally downloaded from DPDK.org:
263
264 `<http://www.dpdk.org/download/mlx4>`_
265
266 Some enhancements are done for better performance with DPDK applications and
267 are not merged upstream yet.
268
269 Since it is partly achieved by tuning compilation options to disable features
270 not needed by DPDK, linking these libraries statically and avoid system-wide
271 installation is the preferred method.
272
273 Installation documentation is available from the above link.
274
275 Usage example
276 -------------
277
278 This section demonstrates how to launch **testpmd** with Mellanox ConnectX-3
279 devices managed by librte_pmd_mlx4.
280
281 #. Load the kernel modules:
282
283    .. code-block:: console
284
285       modprobe -a ib_uverbs mlx4_en mlx4_core mlx4_ib
286
287    .. note::
288
289       User space I/O kernel modules (uio and igb_uio) are not used and do
290       not have to be loaded.
291
292 #. Make sure Ethernet interfaces are in working order and linked to kernel
293    verbs. Related sysfs entries should be present:
294
295    .. code-block:: console
296
297       ls -d /sys/class/net/*/device/infiniband_verbs/uverbs* | cut -d / -f 5
298
299    Example output:
300
301    .. code-block:: console
302
303       eth2
304       eth3
305       eth4
306       eth5
307
308 #. Optionally, retrieve their PCI bus addresses for whitelisting:
309
310    .. code-block:: console
311
312       {
313           for intf in eth2 eth3 eth4 eth5;
314           do
315               (cd "/sys/class/net/${intf}/device/" && pwd -P);
316           done;
317       } |
318       sed -n 's,.*/\(.*\),-w \1,p'
319
320    Example output:
321
322    .. code-block:: console
323
324       -w 0000:83:00.0
325       -w 0000:83:00.0
326       -w 0000:84:00.0
327       -w 0000:84:00.0
328
329    .. note::
330
331       There are only two distinct PCI bus addresses because the Mellanox
332       ConnectX-3 adapters installed on this system are dual port.
333
334 #. Request huge pages:
335
336    .. code-block:: console
337
338       echo 1024 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages/nr_hugepages
339
340 #. Start testpmd with basic parameters:
341
342    .. code-block:: console
343
344       testpmd -c 0xff00 -n 4 -w 0000:83:00.0 -w 0000:84:00.0 -- --rxq=2 --txq=2 -i
345
346    Example output:
347
348    .. code-block:: console
349
350       [...]
351       EAL: PCI device 0000:83:00.0 on NUMA socket 1
352       EAL:   probe driver: 15b3:1007 librte_pmd_mlx4
353       PMD: librte_pmd_mlx4: PCI information matches, using device "mlx4_0" (VF: false)
354       PMD: librte_pmd_mlx4: 2 port(s) detected
355       PMD: librte_pmd_mlx4: port 1 MAC address is 00:02:c9:b5:b7:50
356       PMD: librte_pmd_mlx4: port 2 MAC address is 00:02:c9:b5:b7:51
357       EAL: PCI device 0000:84:00.0 on NUMA socket 1
358       EAL:   probe driver: 15b3:1007 librte_pmd_mlx4
359       PMD: librte_pmd_mlx4: PCI information matches, using device "mlx4_1" (VF: false)
360       PMD: librte_pmd_mlx4: 2 port(s) detected
361       PMD: librte_pmd_mlx4: port 1 MAC address is 00:02:c9:b5:ba:b0
362       PMD: librte_pmd_mlx4: port 2 MAC address is 00:02:c9:b5:ba:b1
363       Interactive-mode selected
364       Configuring Port 0 (socket 0)
365       PMD: librte_pmd_mlx4: 0x867d60: TX queues number update: 0 -> 2
366       PMD: librte_pmd_mlx4: 0x867d60: RX queues number update: 0 -> 2
367       Port 0: 00:02:C9:B5:B7:50
368       Configuring Port 1 (socket 0)
369       PMD: librte_pmd_mlx4: 0x867da0: TX queues number update: 0 -> 2
370       PMD: librte_pmd_mlx4: 0x867da0: RX queues number update: 0 -> 2
371       Port 1: 00:02:C9:B5:B7:51
372       Configuring Port 2 (socket 0)
373       PMD: librte_pmd_mlx4: 0x867de0: TX queues number update: 0 -> 2
374       PMD: librte_pmd_mlx4: 0x867de0: RX queues number update: 0 -> 2
375       Port 2: 00:02:C9:B5:BA:B0
376       Configuring Port 3 (socket 0)
377       PMD: librte_pmd_mlx4: 0x867e20: TX queues number update: 0 -> 2
378       PMD: librte_pmd_mlx4: 0x867e20: RX queues number update: 0 -> 2
379       Port 3: 00:02:C9:B5:BA:B1
380       Checking link statuses...
381       Port 0 Link Up - speed 10000 Mbps - full-duplex
382       Port 1 Link Up - speed 40000 Mbps - full-duplex
383       Port 2 Link Up - speed 10000 Mbps - full-duplex
384       Port 3 Link Up - speed 40000 Mbps - full-duplex
385       Done
386       testpmd>