doc: add mlx4 driver
[dpdk.git] / doc / guides / prog_guide / mlx4_poll_mode_drv.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** 10/40 Gbps adapters (EN 40, EN 10, Pro EN 40) as
35 well as their virtual functions (VF) in SR-IOV context.
36
37 .. note::
38
39    Due to external dependencies, this driver is disabled by default. It must
40    be enabled manually by setting ``CONFIG_RTE_LIBRTE_MLX4_PMD=y`` and
41    recompiling DPDK.
42
43 Implementation details
44 ----------------------
45
46 Most Mellanox ConnectX-3 devices provide two ports but expose a single PCI
47 bus address, thus unlike most drivers, librte_pmd_mlx4 registers itself as a
48 PCI driver that allocates one Ethernet device per detected port.
49
50 For this reason, one cannot white/blacklist a single port without also
51 white/blacklisting the others on the same device.
52
53 Besides its dependency on libibverbs (that implies libmlx4 and associated
54 kernel support), librte_pmd_mlx4 relies heavily on system calls for control
55 operations such as querying/updating the MTU and flow control parameters.
56
57 For security reasons and robustness, this driver only deals with virtual
58 memory addresses. The way resources allocations are handled by the kernel
59 combined with hardware specifications that allow it to handle virtual memory
60 addresses directly ensure that DPDK applications cannot access random
61 physical memory (or memory that does not belong to the current process).
62
63 This capability allows the PMD to coexist with kernel network interfaces
64 which remain functional, although they stop receiving unicast packets as
65 long as they share the same MAC address.
66
67 Compiling librte_pmd_mlx4 causes DPDK to be linked against libibverbs.
68
69 Features and limitations
70 ------------------------
71
72 - RSS, also known as RCA, is supported. In this mode the number of
73   configured RX queues must be a power of two.
74 - VLAN filtering is supported.
75 - Link state information is provided.
76 - Promiscuous mode is supported.
77 - All multicast mode is supported.
78 - Multiple MAC addresses (unicast, multicast) can be configured.
79 - Scattered packets are supported for TX and RX.
80
81 ..
82
83 - RSS hash key cannot be modified.
84 - Hardware counters are not implemented (they are software counters).
85 - Checksum offloads are not supported yet.
86
87 Configuration
88 -------------
89
90 Compilation options
91 ~~~~~~~~~~~~~~~~~~~
92
93 - ``CONFIG_RTE_LIBRTE_MLX4_PMD`` (default **n**)
94
95   Toggle compilation of librte_pmd_mlx4 itself.
96
97 - ``CONFIG_RTE_LIBRTE_MLX4_DEBUG`` (default **n**)
98
99   Toggle debugging code and stricter compilation flags. Enabling this option
100   adds additional run-time checks and debugging messages at the cost of
101   lower performance.
102
103 - ``CONFIG_RTE_LIBRTE_MLX4_SGE_WR_N`` (default **4**)
104
105   Number of scatter/gather elements (SGEs) per work request (WR). Lowering
106   this number improves performance but also limits the ability to receive
107   scattered packets (packets that do not fit a single mbuf). The default
108   value is a safe tradeoff.
109
110 - ``CONFIG_RTE_LIBRTE_MLX4_MAX_INLINE`` (default **0**)
111
112   Amount of data to be inlined during TX operations. Improves latency but
113   lowers throughput.
114
115 - ``CONFIG_RTE_LIBRTE_MLX4_TX_MP_CACHE`` (default **8**)
116
117   Maximum number of cached memory pools (MPs) per TX queue. Each MP from
118   which buffers are to be transmitted must be associated to memory regions
119   (MRs). This is a slow operation that must be cached.
120
121   This value is always 1 for RX queues since they use a single MP.
122
123 - ``CONFIG_RTE_LIBRTE_MLX4_SOFT_COUNTERS`` (default **1**)
124
125   Toggle software counters. No counters are available if this option is
126   disabled since hardware counters are not supported.
127
128 - ``CONFIG_RTE_LIBRTE_MLX4_COMPAT_VMWARE`` (default **1**)
129
130   Toggle VMware compatibility code. It also requires the environment
131   variable ``MLX4_COMPAT_VMWARE`` set to a nonzero value at runtime.
132
133 Environment variables
134 ~~~~~~~~~~~~~~~~~~~~~
135
136 - ``MLX4_INLINE_RECV_SIZE``
137
138   A nonzero value enables inline receive for packets up to that size. May
139   significantly improve performance in some cases but lower it in
140   others. Requires careful testing.
141
142 - ``MLX4_COMPAT_VMWARE``
143
144   Only supported when compiled with
145   ``CONFIG_RTE_LIBRTE_MLX4_COMPAT_VMWARE=1``. Adds workarounds to run in
146   VMware systems that do not support the flows API properly.
147
148 Run-time configuration
149 ~~~~~~~~~~~~~~~~~~~~~~
150
151 - The only constraint when RSS mode is requested is to make sure the number
152   of RX queues is a power of two. This is a hardware requirement.
153
154 - librte_pmd_mlx4 brings kernel network interfaces up during initialization
155   because it is affected by their state. Forcing them down prevents packets
156   reception.
157
158 - **ethtool** operations on related kernel interfaces also affect the PMD.
159
160 Prerequisites
161 -------------
162
163 This driver relies on external libraries and kernel drivers for resources
164 allocations and initialization. The following dependencies are not part of
165 DPDK and must be installed separately:
166
167 - **libibverbs**
168
169   User space verbs framework used by librte_pmd_mlx4. This library provides
170   a generic interface between the kernel and low-level user space drivers
171   such as libmlx4.
172
173   It allows slow and privileged operations (context initialization, hardware
174   resources allocations) to be managed by the kernel and fast operations to
175   never leave user space.
176
177 - **libmlx4**
178
179   Low-level user space driver library for Mellanox ConnectX-3 devices,
180   it is automatically loaded by libibverbs.
181
182   This library basically implements send/receive calls to the hardware
183   queues.
184
185 - **Kernel modules** (mlnx-ofed-kernel)
186
187   They provide the kernel-side verbs API and low level device drivers that
188   manage actual hardware initialization and resources sharing with user
189   space processes.
190
191   Unlike most other PMDs, these modules must remain loaded and bound to
192   their devices:
193
194   - mlx4_core: hardware driver managing Mellanox ConnectX-3 devices.
195   - mlx4_en: Ethernet device driver that provides kernel network interfaces.
196   - mlx4_ib: InifiniBand device driver.
197   - ib_uverbs: user space driver for verbs (entry point for libibverbs).
198
199 While these libraries and kernel modules are available on OpenFabrics
200 Aliance's `website <https://www.openfabrics.org/>`_ and provided by package
201 managers on most distributions, this PMD requires Ethernet extensions that
202 may not be supported at the moment (this is a work in progress).
203
204 `Mellanox OFED
205 <http://www.mellanox.com/page/products_dyn?product_family=26&mtag=linux_sw_drivers>`_
206 includes the necessary support and should be used in the meantime. For DPDK,
207 only libibverbs, libmlx4 and mlnx-ofed-kernel packages are required from
208 that distribution.
209
210 .. note::
211
212    Both libraries are BSD and GPL licensed. Linux kernel modules are GPL
213    licensed.
214
215 Usage example
216 -------------
217
218 This section demonstrates how to launch **testpmd** with Mellanox ConnectX-3
219 devices managed by librte_pmd_mlx4.
220
221 #. Load the kernel modules:
222
223    .. code-block:: console
224
225       modprobe -a ib_uverbs mlx4_en mlx4_core mlx4_ib
226
227    .. note::
228
229       User space I/O kernel modules (uio and igb_uio) are not used and do
230       not have to be loaded.
231
232 #. Make sure Ethernet interfaces are in working order and linked to kernel
233    verbs. Related sysfs entries should be present:
234
235    .. code-block:: console
236
237       ls -d /sys/class/net/*/device/infiniband_verbs/uverbs* | cut -d / -f 5
238
239    Example output:
240
241    .. code-block:: console
242
243       eth2
244       eth3
245       eth4
246       eth5
247
248 #. Optionally, retrieve their PCI bus addresses for whitelisting:
249
250    .. code-block:: console
251
252       {
253           for intf in eth2 eth3 eth4 eth5;
254           do
255               (cd "/sys/class/net/${intf}/device/" && pwd -P);
256           done;
257       } |
258       sed -n 's,.*/\(.*\),-w \1,p'
259
260    Example output:
261
262    .. code-block:: console
263
264       -w 0000:83:00.0
265       -w 0000:83:00.0
266       -w 0000:84:00.0
267       -w 0000:84:00.0
268
269    .. note::
270
271       There are only two distinct PCI bus addresses because the Mellanox
272       ConnectX-3 adapters installed on this system are dual port.
273
274 #. Request huge pages:
275
276    .. code-block:: console
277
278       echo 1024 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages/nr_hugepages
279
280 #. Start testpmd with basic parameters:
281
282    .. code-block:: console
283
284       testpmd -c 0xff00 -n 4 -w 0000:83:00.0 -w 0000:84:00.0 -- --rxq=2 --txq=2 -i
285
286    Example output:
287
288    .. code-block:: console
289
290       [...]
291       EAL: PCI device 0000:83:00.0 on NUMA socket 1
292       EAL:   probe driver: 15b3:1007 librte_pmd_mlx4
293       PMD: librte_pmd_mlx4: PCI information matches, using device "mlx4_0" (VF: false)
294       PMD: librte_pmd_mlx4: 2 port(s) detected
295       PMD: librte_pmd_mlx4: port 1 MAC address is 00:02:c9:b5:b7:50
296       PMD: librte_pmd_mlx4: port 2 MAC address is 00:02:c9:b5:b7:51
297       EAL: PCI device 0000:84:00.0 on NUMA socket 1
298       EAL:   probe driver: 15b3:1007 librte_pmd_mlx4
299       PMD: librte_pmd_mlx4: PCI information matches, using device "mlx4_1" (VF: false)
300       PMD: librte_pmd_mlx4: 2 port(s) detected
301       PMD: librte_pmd_mlx4: port 1 MAC address is 00:02:c9:b5:ba:b0
302       PMD: librte_pmd_mlx4: port 2 MAC address is 00:02:c9:b5:ba:b1
303       Interactive-mode selected
304       Configuring Port 0 (socket 0)
305       PMD: librte_pmd_mlx4: 0x867d60: TX queues number update: 0 -> 2
306       PMD: librte_pmd_mlx4: 0x867d60: RX queues number update: 0 -> 2
307       Port 0: 00:02:C9:B5:B7:50
308       Configuring Port 1 (socket 0)
309       PMD: librte_pmd_mlx4: 0x867da0: TX queues number update: 0 -> 2
310       PMD: librte_pmd_mlx4: 0x867da0: RX queues number update: 0 -> 2
311       Port 1: 00:02:C9:B5:B7:51
312       Configuring Port 2 (socket 0)
313       PMD: librte_pmd_mlx4: 0x867de0: TX queues number update: 0 -> 2
314       PMD: librte_pmd_mlx4: 0x867de0: RX queues number update: 0 -> 2
315       Port 2: 00:02:C9:B5:BA:B0
316       Configuring Port 3 (socket 0)
317       PMD: librte_pmd_mlx4: 0x867e20: TX queues number update: 0 -> 2
318       PMD: librte_pmd_mlx4: 0x867e20: RX queues number update: 0 -> 2
319       Port 3: 00:02:C9:B5:BA:B1
320       Checking link statuses...
321       Port 0 Link Up - speed 10000 Mbps - full-duplex
322       Port 1 Link Up - speed 40000 Mbps - full-duplex
323       Port 2 Link Up - speed 10000 Mbps - full-duplex
324       Port 3 Link Up - speed 40000 Mbps - full-duplex
325       Done
326       testpmd>