550bd79595489425109250b1f6777468655f65e3
[dpdk.git] / doc / guides / nics / mrvl.rst
1 ..  BSD LICENSE
2     Copyright(c) 2017 Marvell International Ltd.
3     Copyright(c) 2017 Semihalf.
4     All rights reserved.
5
6     Redistribution and use in source and binary forms, with or without
7     modification, are permitted provided that the following conditions
8     are met:
9
10       * Redistributions of source code must retain the above copyright
11         notice, this list of conditions and the following disclaimer.
12       * Redistributions in binary form must reproduce the above copyright
13         notice, this list of conditions and the following disclaimer in
14         the documentation and/or other materials provided with the
15         distribution.
16       * Neither the name of the copyright holder nor the names of its
17         contributors may be used to endorse or promote products derived
18         from this software without specific prior written permission.
19
20     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21     "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22     LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23     A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24     OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25     SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26     LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27     DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28     THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30     OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
32 .. _mrvl_poll_mode_driver:
33
34 MRVL Poll Mode Driver
35 ======================
36
37 The MRVL PMD (librte_pmd_mrvl) provides poll mode driver support
38 for the Marvell PPv2 (Packet Processor v2) 1/10 Gbps adapter.
39
40 Detailed information about SoCs that use PPv2 can be obtained here:
41
42 * https://www.marvell.com/embedded-processors/armada-70xx/
43 * https://www.marvell.com/embedded-processors/armada-80xx/
44
45 .. Note::
46
47    Due to external dependencies, this driver is disabled by default. It must
48    be enabled manually by setting relevant configuration option manually.
49    Please refer to `Config File Options`_ section for further details.
50
51
52 Features
53 --------
54
55 Features of the MRVL PMD are:
56
57 - Speed capabilities
58 - Link status
59 - Queue start/stop
60 - MTU update
61 - Jumbo frame
62 - Promiscuous mode
63 - Allmulticast mode
64 - Unicast MAC filter
65 - Multicast MAC filter
66 - RSS hash
67 - VLAN filter
68 - CRC offload
69 - L3 checksum offload
70 - L4 checksum offload
71 - Packet type parsing
72 - Basic stats
73 - Extended stats
74 - QoS
75 - RX flow control
76
77
78 Limitations
79 -----------
80
81 - Number of lcores is limited to 9 by MUSDK internal design. If more lcores
82   need to be allocated, locking will have to be considered. Number of available
83   lcores can be changed via ``MRVL_MUSDK_HIFS_RESERVED`` define in
84   ``mrvl_ethdev.c`` source file.
85
86 - Flushing vlans added for filtering is not possible due to MUSDK missing
87   functionality. Current workaround is to reset board so that PPv2 has a
88   chance to start in a sane state.
89
90
91 Prerequisites
92 -------------
93
94 - Custom Linux Kernel sources
95
96   .. code-block:: console
97
98      git clone https://github.com/MarvellEmbeddedProcessors/linux-marvell.git -b linux-4.4.52-armada-17.10
99
100 - Out of tree `mvpp2x_sysfs` kernel module sources
101
102   .. code-block:: console
103
104      git clone https://github.com/MarvellEmbeddedProcessors/mvpp2x-marvell.git -b mvpp2x-armada-17.10
105
106 - MUSDK (Marvell User-Space SDK) sources
107
108   .. code-block:: console
109
110      git clone https://github.com/MarvellEmbeddedProcessors/musdk-marvell.git -b musdk-armada-17.10
111
112   MUSDK is a light-weight library that provides direct access to Marvell's
113   PPv2 (Packet Processor v2). Alternatively prebuilt MUSDK library can be
114   requested from `Marvell Extranet <https://extranet.marvell.com>`_. Once
115   approval has been granted, library can be found by typing ``musdk`` in
116   the search box.
117
118   To get better understanding of the library one can consult documentation
119   available in the ``doc`` top level directory of the MUSDK sources.
120
121   MUSDK must be configured with the following features:
122
123   .. code-block:: console
124
125      --enable-bpool-dma=64
126
127 - DPDK environment
128
129   Follow the DPDK :ref:`Getting Started Guide for Linux <linux_gsg>` to setup
130   DPDK environment.
131
132
133 Config File Options
134 -------------------
135
136 The following options can be modified in the ``config`` file.
137
138 - ``CONFIG_RTE_LIBRTE_MRVL_PMD`` (default ``n``)
139
140     Toggle compilation of the librte_pmd_mrvl driver.
141
142
143 QoS Configuration
144 -----------------
145
146 QoS configuration is done through external configuration file. Path to the
147 file must be given as `cfg` in driver's vdev parameter list.
148
149 Configuration syntax
150 ~~~~~~~~~~~~~~~~~~~~
151
152 .. code-block:: console
153
154    [port <portnum> default]
155    default_tc = <default_tc>
156    mapping_priority = <mapping_priority>
157    policer_enable = <policer_enable>
158    token_unit = <token_unit>
159    color = <color_mode>
160    cir = <cir>
161    ebs = <ebs>
162    cbs = <cbs>
163
164    rate_limit_enable = <rate_limit_enable>
165    rate_limit = <rate_limit>
166    burst_size = <burst_size>
167
168    [port <portnum> tc <traffic_class>]
169    rxq = <rx_queue_list>
170    pcp = <pcp_list>
171    dscp = <dscp_list>
172    default_color = <default_color>
173
174    [port <portnum> tc <traffic_class>]
175    rxq = <rx_queue_list>
176    pcp = <pcp_list>
177    dscp = <dscp_list>
178
179    [port <portnum> txq <txqnum>]
180    sched_mode = <sched_mode>
181    wrr_weight = <wrr_weight>
182
183    rate_limit_enable = <rate_limit_enable>
184    rate_limit = <rate_limit>
185    burst_size = <burst_size>
186
187 Where:
188
189 - ``<portnum>``: DPDK Port number (0..n).
190
191 - ``<default_tc>``: Default traffic class (e.g. 0)
192
193 - ``<mapping_priority>``: QoS priority for mapping (`ip`, `vlan`, `ip/vlan` or `vlan/ip`).
194
195 - ``<traffic_class>``: Traffic Class to be configured.
196
197 - ``<rx_queue_list>``: List of DPDK RX queues (e.g. 0 1 3-4)
198
199 - ``<pcp_list>``: List of PCP values to handle in particular TC (e.g. 0 1 3-4 7).
200
201 - ``<dscp_list>``: List of DSCP values to handle in particular TC (e.g. 0-12 32-48 63).
202
203 - ``<policer_enable>``: Enable ingress policer.
204
205 - ``<token_unit>``: Policer token unit (`bytes` or `packets`).
206
207 - ``<color_mode>``: Policer color mode (`aware` or `blind`).
208
209 - ``<cir>``: Committed information rate in unit of kilo bits per second (data rate) or packets per second.
210
211 - ``<cbs>``: Committed burst size in unit of kilo bytes or number of packets.
212
213 - ``<ebs>``: Excess burst size in unit of kilo bytes or number of packets.
214
215 - ``<default_color>``: Default color for specific tc.
216
217 - ``<rate_limit_enable>``: Enables per port or per txq rate limiting.
218
219 - ``<rate_limit>``: Committed information rate, in kilo bits per second.
220
221 - ``<burst_size>``: Committed burst size, in kilo bytes.
222
223 - ``<sched_mode>``: Egress scheduler mode (`wrr` or `sp`).
224
225 - ``<wrr_weight>``: Txq weight.
226
227 Setting PCP/DSCP values for the default TC is not required. All PCP/DSCP
228 values not assigned explicitly to particular TC will be handled by the
229 default TC.
230
231 Configuration file example
232 ^^^^^^^^^^^^^^^^^^^^^^^^^^
233
234 .. code-block:: console
235
236    [port 0 default]
237    default_tc = 0
238    mapping_priority = ip
239
240    rate_limit_enable = 1
241    rate_limit = 1000
242    burst_size = 2000
243
244    [port 0 tc 0]
245    rxq = 0 1
246
247    [port 0 txq 0]
248    sched_mode = wrr
249    wrr_weight = 10
250
251    [port 0 txq 1]
252    sched_mode = wrr
253    wrr_weight = 100
254
255    [port 0 txq 2]
256    sched_mode = sp
257
258    [port 0 tc 1]
259    rxq = 2
260    pcp = 5 6 7
261    dscp = 26-38
262
263    [port 1 default]
264    default_tc = 0
265    mapping_priority = vlan/ip
266
267    policer_enable = 1
268    token_unit = bytes
269    color = blind
270    cir = 100000
271    ebs = 64
272    cbs = 64
273
274    [port 1 tc 0]
275    rxq = 0
276    dscp = 10
277
278    [port 1 tc 1]
279    rxq = 1
280    dscp = 11-20
281
282    [port 1 tc 2]
283    rxq = 2
284    dscp = 30
285
286    [port 1 txq 0]
287    rate_limit_enable = 1
288    rate_limit = 10000
289    burst_size = 2000
290
291 Usage example
292 ^^^^^^^^^^^^^
293
294 .. code-block:: console
295
296    ./testpmd --vdev=eth_mrvl,iface=eth0,iface=eth2,cfg=/home/user/mrvl.conf \
297      -c 7 -- -i -a --disable-hw-vlan-strip --rxq=3 --txq=3
298
299
300 Building DPDK
301 -------------
302
303 Driver needs precompiled MUSDK library during compilation.
304
305 .. code-block:: console
306
307    export CROSS_COMPILE=<toolchain>/bin/aarch64-linux-gnu-
308    ./bootstrap
309    ./configure --host=aarch64-linux-gnu --enable-bpool-dma=64
310    make install
311
312 MUSDK will be installed to `usr/local` under current directory.
313 For the detailed build instructions please consult ``doc/musdk_get_started.txt``.
314
315 Before the DPDK build process the environmental variable ``LIBMUSDK_PATH`` with
316 the path to the MUSDK installation directory needs to be exported.
317
318 .. code-block:: console
319
320    export LIBMUSDK_PATH=<musdk>/usr/local
321    export CROSS=aarch64-linux-gnu-
322    make config T=arm64-armv8a-linuxapp-gcc
323    sed -ri 's,(MRVL_PMD=)n,\1y,' build/.config
324    make
325
326 Flow API
327 --------
328
329 PPv2 offers packet classification capabilities via classifier engine which
330 can be configured via generic flow API offered by DPDK.
331
332 Supported flow actions
333 ~~~~~~~~~~~~~~~~~~~~~~
334
335 Following flow action items are supported by the driver:
336
337 * DROP
338 * QUEUE
339
340 Supported flow items
341 ~~~~~~~~~~~~~~~~~~~~
342
343 Following flow items and their respective fields are supported by the driver:
344
345 * ETH
346
347   * source MAC
348   * destination MAC
349   * ethertype
350
351 * VLAN
352
353   * PCP
354   * VID
355
356 * IPV4
357
358   * DSCP
359   * protocol
360   * source address
361   * destination address
362
363 * IPV6
364
365   * flow label
366   * next header
367   * source address
368   * destination address
369
370 * UDP
371
372   * source port
373   * destination port
374
375 * TCP
376
377   * source port
378   * destination port
379
380 Classifier match engine
381 ~~~~~~~~~~~~~~~~~~~~~~~
382
383 Classifier has an internal match engine which can be configured to
384 operate in either exact or maskable mode.
385
386 Mode is selected upon creation of the first unique flow rule as follows:
387
388 * maskable, if key size is up to 8 bytes.
389 * exact, otherwise, i.e for keys bigger than 8 bytes.
390
391 Where the key size equals the number of bytes of all fields specified
392 in the flow items.
393
394 .. table:: Examples of key size calculation
395
396    +----------------------------------------------------------------------------+-------------------+-------------+
397    | Flow pattern                                                               | Key size in bytes | Used engine |
398    +============================================================================+===================+=============+
399    | ETH (destination MAC) / VLAN (VID)                                         | 6 + 2 = 8         | Maskable    |
400    +----------------------------------------------------------------------------+-------------------+-------------+
401    | VLAN (VID) / IPV4 (source address)                                         | 2 + 4 = 6         | Maskable    |
402    +----------------------------------------------------------------------------+-------------------+-------------+
403    | TCP (source port, destination port)                                        | 2 + 2 = 4         | Maskable    |
404    +----------------------------------------------------------------------------+-------------------+-------------+
405    | VLAN (priority) / IPV4 (source address)                                    | 1 + 4 = 5         | Maskable    |
406    +----------------------------------------------------------------------------+-------------------+-------------+
407    | IPV4 (destination address) / UDP (source port, destination port)           | 6 + 2 + 2 = 10    | Exact       |
408    +----------------------------------------------------------------------------+-------------------+-------------+
409    | VLAN (VID) / IPV6 (flow label, destination address)                        | 2 + 3 + 16 = 21   | Exact       |
410    +----------------------------------------------------------------------------+-------------------+-------------+
411    | IPV4 (DSCP, source address, destination address)                           | 1 + 4 + 4 = 9     | Exact       |
412    +----------------------------------------------------------------------------+-------------------+-------------+
413    | IPV6 (flow label, source address, destination address)                     | 3 + 16 + 16 = 35  | Exact       |
414    +----------------------------------------------------------------------------+-------------------+-------------+
415
416 From the user perspective maskable mode means that masks specified
417 via flow rules are respected. In case of exact match mode, masks
418 which do not provide exact matching (all bits masked) are ignored.
419
420 If the flow matches more than one classifier rule the first
421 (with the lowest index) matched takes precedence.
422
423 Flow rules usage example
424 ~~~~~~~~~~~~~~~~~~~~~~~~
425
426 Before proceeding run testpmd user application:
427
428 .. code-block:: console
429
430    ./testpmd --vdev=net_mrvl,iface=eth0,iface=eth2 -c 3 -- -i --p 3 -a --disable-hw-vlan-strip
431
432 Example #1
433 ^^^^^^^^^^
434
435 .. code-block:: console
436
437    testpmd> flow create 0 ingress pattern eth src is 10:11:12:13:14:15 / end actions drop / end
438
439 In this case key size is 6 bytes thus maskable type is selected. Testpmd
440 will set mask to ff:ff:ff:ff:ff:ff i.e traffic explicitly matching
441 above rule will be dropped.
442
443 Example #2
444 ^^^^^^^^^^
445
446 .. code-block:: console
447
448    testpmd> flow create 0 ingress pattern ipv4 src spec 10.10.10.0 src mask 255.255.255.0 / tcp src spec 0x10 src mask 0x10 / end action drop / end
449
450 In this case key size is 8 bytes thus maskable type is selected.
451 Flows which have IPv4 source addresses ranging from 10.10.10.0 to 10.10.10.255
452 and tcp source port set to 16 will be dropped.
453
454 Example #3
455 ^^^^^^^^^^
456
457 .. code-block:: console
458
459    testpmd> flow create 0 ingress pattern vlan vid spec 0x10 vid mask 0x10 / ipv4 src spec 10.10.1.1 src mask 255.255.0.0 dst spec 11.11.11.1 dst mask 255.255.255.0 / end actions drop / end
460
461 In this case key size is 10 bytes thus exact type is selected.
462 Even though each item has partial mask set, masks will be ignored.
463 As a result only flows with VID set to 16 and IPv4 source and destination
464 addresses set to 10.10.1.1 and 11.11.11.1 respectively will be dropped.
465
466 Limitations
467 ~~~~~~~~~~~
468
469 Following limitations need to be taken into account while creating flow rules:
470
471 * For IPv4 exact match type the key size must be up to 12 bytes.
472 * For IPv6 exact match type the key size must be up to 36 bytes.
473 * Following fields cannot be partially masked (all masks are treated as
474   if they were exact):
475
476   * ETH: ethertype
477   * VLAN: PCP, VID
478   * IPv4: protocol
479   * IPv6: next header
480   * TCP/UDP: source port, destination port
481
482 * Only one classifier table can be created thus all rules in the table
483   have to match table format. Table format is set during creation of
484   the first unique flow rule.
485 * Up to 5 fields can be specified per flow rule.
486 * Up to 20 flow rules can be added.
487
488 For additional information about classifier please consult
489 ``doc/musdk_cls_user_guide.txt``.
490
491 Usage Example
492 -------------
493
494 MRVL PMD requires extra out of tree kernel modules to function properly.
495 `musdk_uio` and `mv_pp_uio` sources are part of the MUSDK. Please consult
496 ``doc/musdk_get_started.txt`` for the detailed build instructions.
497 For `mvpp2x_sysfs` please consult ``Documentation/pp22_sysfs.txt`` for the
498 detailed build instructions.
499
500 .. code-block:: console
501
502    insmod musdk_uio.ko
503    insmod mv_pp_uio.ko
504    insmod mvpp2x_sysfs.ko
505
506 Additionally interfaces used by DPDK application need to be put up:
507
508 .. code-block:: console
509
510    ip link set eth0 up
511    ip link set eth2 up
512
513 In order to run testpmd example application following command can be used:
514
515 .. code-block:: console
516
517    ./testpmd --vdev=eth_mrvl,iface=eth0,iface=eth2 -c 7 -- \
518      --burst=128 --txd=2048 --rxd=1024 --rxq=2 --txq=2  --nb-cores=2 \
519      -i -a --rss-udp