net/mlx5: support ESP SPI match and RSS hash
[dpdk.git] / doc / guides / nics / cnxk.rst
1 ..  SPDX-License-Identifier: BSD-3-Clause
2     Copyright(C) 2021 Marvell.
3
4 CNXK Poll Mode driver
5 =====================
6
7 The CNXK ETHDEV PMD (**librte_net_cnxk**) provides poll mode ethdev driver
8 support for the inbuilt network device found in **Marvell OCTEON CN9K/CN10K**
9 SoC family as well as for their virtual functions (VF) in SR-IOV context.
10
11 More information can be found at `Marvell Official Website
12 <https://www.marvell.com/embedded-processors/infrastructure-processors>`_.
13
14 Features
15 --------
16
17 Features of the CNXK Ethdev PMD are:
18
19 - Packet type information
20 - Promiscuous mode
21 - Jumbo frames
22 - SR-IOV VF
23 - Lock-free Tx queue
24 - Multiple queues for TX and RX
25 - Receiver Side Scaling (RSS)
26 - MAC filtering
27 - Generic flow API
28 - Inner and Outer Checksum offload
29 - Port hardware statistics
30 - Link state information
31 - Link flow control
32 - MTU update
33 - Scatter-Gather IO support
34 - Vector Poll mode driver
35 - Debug utilities - Context dump and error interrupt support
36 - Support Rx interrupt
37 - Inline IPsec processing support
38 - Ingress meter support
39 - Queue based priority flow control support
40
41 Prerequisites
42 -------------
43
44 See :doc:`../platform/cnxk` for setup information.
45
46
47 Driver compilation and testing
48 ------------------------------
49
50 Refer to the document :ref:`compiling and testing a PMD for a NIC <pmd_build_and_test>`
51 for details.
52
53 #. Running testpmd:
54
55    Follow instructions available in the document
56    :ref:`compiling and testing a PMD for a NIC <pmd_build_and_test>`
57    to run testpmd.
58
59    Example output:
60
61    .. code-block:: console
62
63       ./<build_dir>/app/dpdk-testpmd -c 0xc -a 0002:02:00.0 -- --portmask=0x1 --nb-cores=1 --port-topology=loop --rxq=1 --txq=1
64       EAL: Detected 4 lcore(s)
65       EAL: Detected 1 NUMA nodes
66       EAL: Multi-process socket /var/run/dpdk/rte/mp_socket
67       EAL: Selected IOVA mode 'VA'
68       EAL: No available hugepages reported in hugepages-16777216kB
69       EAL: No available hugepages reported in hugepages-2048kB
70       EAL: Probing VFIO support...
71       EAL: VFIO support initialized
72       EAL:   using IOMMU type 1 (Type 1)
73       [ 2003.202721] vfio-pci 0002:02:00.0: vfio_cap_init: hiding cap 0x14@0x98
74       EAL: Probe PCI driver: net_cn10k (177d:a063) device: 0002:02:00.0 (socket 0)
75       PMD: RoC Model: cn10k
76       EAL: No legacy callbacks, legacy socket not created
77       testpmd: create a new mbuf pool <mb_pool_0>: n=155456, size=2176, socket=0
78       testpmd: preferred mempool ops selected: cn10k_mempool_ops
79       Configuring Port 0 (socket 0)
80       PMD: Port 0: Link Up - speed 25000 Mbps - full-duplex
81
82       Port 0: link state change event
83       Port 0: 96:D4:99:72:A5:BF
84       Checking link statuses...
85       Done
86       No commandline core given, start packet forwarding
87       io packet forwarding - ports=1 - cores=1 - streams=1 - NUMA support enabled, MP allocation mode: native
88       Logical Core 3 (socket 0) forwards packets on 1 streams:
89         RX P=0/Q=0 (socket 0) -> TX P=0/Q=0 (socket 0) peer=02:00:00:00:00:00
90
91         io packet forwarding packets/burst=32
92         nb forwarding cores=1 - nb forwarding ports=1
93         port 0: RX queue number: 1 Tx queue number: 1
94           Rx offloads=0x0 Tx offloads=0x10000
95           RX queue: 0
96             RX desc=4096 - RX free threshold=0
97             RX threshold registers: pthresh=0 hthresh=0  wthresh=0
98             RX Offloads=0x0
99           TX queue: 0
100             TX desc=512 - TX free threshold=0
101             TX threshold registers: pthresh=0 hthresh=0  wthresh=0
102             TX offloads=0x0 - TX RS bit threshold=0
103       Press enter to exit
104
105 Runtime Config Options
106 ----------------------
107
108 - ``Rx&Tx scalar mode enable`` (default ``0``)
109
110    PMD supports both scalar and vector mode, it may be selected at runtime
111    using ``scalar_enable`` ``devargs`` parameter.
112
113 - ``RSS reta size`` (default ``64``)
114
115    RSS redirection table size may be configured during runtime using ``reta_size``
116    ``devargs`` parameter.
117
118    For example::
119
120       -a 0002:02:00.0,reta_size=256
121
122    With the above configuration, reta table of size 256 is populated.
123
124 - ``Flow priority levels`` (default ``3``)
125
126    RTE Flow priority levels can be configured during runtime using
127    ``flow_max_priority`` ``devargs`` parameter.
128
129    For example::
130
131       -a 0002:02:00.0,flow_max_priority=10
132
133    With the above configuration, priority level was set to 10 (0-9). Max
134    priority level supported is 32.
135
136 - ``Reserve Flow entries`` (default ``8``)
137
138    RTE flow entries can be pre allocated and the size of pre allocation can be
139    selected runtime using ``flow_prealloc_size`` ``devargs`` parameter.
140
141    For example::
142
143       -a 0002:02:00.0,flow_prealloc_size=4
144
145    With the above configuration, pre alloc size was set to 4. Max pre alloc
146    size supported is 32.
147
148 - ``Max SQB buffer count`` (default ``512``)
149
150    Send queue descriptor buffer count may be limited during runtime using
151    ``max_sqb_count`` ``devargs`` parameter.
152
153    For example::
154
155       -a 0002:02:00.0,max_sqb_count=64
156
157    With the above configuration, each send queue's descriptor buffer count is
158    limited to a maximum of 64 buffers.
159
160 - ``Switch header enable`` (default ``none``)
161
162    A port can be configured to a specific switch header type by using
163    ``switch_header`` ``devargs`` parameter.
164
165    For example::
166
167       -a 0002:02:00.0,switch_header="higig2"
168
169    With the above configuration, higig2 will be enabled on that port and the
170    traffic on this port should be higig2 traffic only. Supported switch header
171    types are "chlen24b", "chlen90b", "dsa", "exdsa", "higig2", "vlan_exdsa" and
172    "pre_l2".
173
174 - ``Flow pre_l2 info`` (default ``0x0/0x0/0x0``)
175
176    pre_l2 headers are custom headers placed before the ethernet header. For
177    parsing custom pre_l2 headers, an offset, mask within the offset and shift
178    direction has to be provided within the custom header that holds the size of
179    the custom header. This is valid only with switch header pre_l2. Maximum
180    supported offset range is 0 to 255 and mask range is 1 to 255 and
181    shift direction, 0: left shift, 1: right shift.
182    Info format will be "offset/mask/shift direction". All parameters has to be
183    in hexadecimal format and mask should be contiguous. Info can be configured
184    using ``flow_pre_l2_info`` ``devargs`` parameter.
185
186    For example::
187
188       -a 0002:02:00.0,switch_header="pre_l2",flow_pre_l2_info=0x2/0x7e/0x1
189
190    With the above configuration, custom pre_l2 header will be enabled on that
191    port and size of the header is placed at byte offset 0x2 in the packet with
192    mask 0x7e and right shift will be used to get the size. That is, size will be
193    (pkt[0x2] & 0x7e) >> shift count. Shift count will be calculated based on
194    mask and shift direction. For example, if mask is 0x7c and shift direction is
195    1 (i.e., right shift) then the shift count will be 2, that is, absolute
196    position of the rightmost set bit. If the mask is 0x7c and shift direction
197    is 0 (i.e., left shift) then the shift count will be 1, that is, (8 - n),
198    where n is the absolute position of leftmost set bit.
199
200 - ``RSS tag as XOR`` (default ``0``)
201
202    The HW gives two options to configure the RSS adder i.e
203
204    * ``rss_adder<7:0> = flow_tag<7:0> ^ flow_tag<15:8> ^ flow_tag<23:16> ^ flow_tag<31:24>``
205
206    * ``rss_adder<7:0> = flow_tag<7:0>``
207
208    Latter one aligns with standard NIC behavior vs former one is a legacy
209    RSS adder scheme used in OCTEON 9 products.
210
211    By default, the driver runs in the latter mode.
212    Setting this flag to 1 to select the legacy mode.
213
214    For example to select the legacy mode(RSS tag adder as XOR)::
215
216       -a 0002:02:00.0,tag_as_xor=1
217
218 - ``Min SPI for inbound inline IPsec`` (default ``0``)
219
220    Min SPI supported for inbound inline IPsec processing can be specified by
221    ``ipsec_in_min_spi`` ``devargs`` parameter.
222
223    For example::
224
225       -a 0002:02:00.0,ipsec_in_min_spi=6
226
227    With the above configuration, application can enable inline IPsec processing
228    for inbound SA with min SPI of 6.
229
230 - ``Max SPI for inbound inline IPsec`` (default ``255``)
231
232    Max SPI supported for inbound inline IPsec processing can be specified by
233    ``ipsec_in_max_spi`` ``devargs`` parameter.
234
235    For example::
236
237       -a 0002:02:00.0,ipsec_in_max_spi=128
238
239    With the above configuration, application can enable inline IPsec processing
240    with max SPI of 128.
241
242 - ``Max SA's for outbound inline IPsec`` (default ``4096``)
243
244    Max number of SA's supported for outbound inline IPsec processing can be
245    specified by ``ipsec_out_max_sa`` ``devargs`` parameter.
246
247    For example::
248
249       -a 0002:02:00.0,ipsec_out_max_sa=128
250
251    With the above configuration, application can enable inline IPsec processing
252    for 128 outbound SAs.
253
254 - ``Enable custom SA action`` (default ``0``)
255
256    Custom SA action can be enabled by specifying ``custom_sa_act`` ``devargs`` parameter.
257
258    For example::
259
260       -a 0002:02:00.0,custom_sa_act=1
261
262    With the above configuration, application can enable custom SA action. This
263    configuration allows the potential for a MCAM entry to match many SAs,
264    rather than only match a single SA.
265    For cnxk device sa_index will be calculated based on SPI value. So, it will
266    be 1 to 1 mapping. By enabling this devargs and setting a MCAM rule, will
267    allow application to configure the sa_index as part of session create. And
268    later original SPI value can be updated using session update.
269    For example, application can set sa_index as 0 using session create as SPI value
270    and later can update the original SPI value (for example 0x10000001) using
271    session update. And create a flow rule with security action and algorithm as
272    RTE_PMD_CNXK_SEC_ACTION_ALG0 and sa_hi as 0x1000 and sa_lo as 0x0001.
273
274 - ``Outbound CPT LF queue size`` (default ``8200``)
275
276    Size of Outbound CPT LF queue in number of descriptors can be specified by
277    ``outb_nb_desc`` ``devargs`` parameter.
278
279    For example::
280
281       -a 0002:02:00.0,outb_nb_desc=16384
282
283     With the above configuration, Outbound CPT LF will be created to accommodate
284     at max 16384 descriptors at any given time.
285
286 - ``Outbound CPT LF count`` (default ``1``)
287
288    Number of CPT LF's to attach for Outbound processing can be specified by
289    ``outb_nb_crypto_qs`` ``devargs`` parameter.
290
291    For example::
292
293       -a 0002:02:00.0,outb_nb_crypto_qs=2
294
295    With the above configuration, two CPT LF's are setup and distributed among
296    all the Tx queues for outbound processing.
297
298 - ``Disable using inline ipsec device for inbound`` (default ``0``)
299
300    In CN10K, in event mode, driver can work in two modes,
301
302    1. Inbound encrypted traffic received by probed ipsec inline device while
303       plain traffic post decryption is received by ethdev.
304
305    2. Both Inbound encrypted traffic and plain traffic post decryption are
306       received by ethdev.
307
308    By default event mode works using inline device i.e mode ``1``.
309    This behaviour can be changed to pick mode ``2`` by using
310    ``no_inl_dev`` ``devargs`` parameter.
311
312    For example::
313
314       -a 0002:02:00.0,no_inl_dev=1 -a 0002:03:00.0,no_inl_dev=1
315
316    With the above configuration, inbound encrypted traffic from both the ports
317    is received by ipsec inline device.
318
319 - ``Inline IPsec device channel and mask`` (default ``none``)
320
321    Set channel and channel mask configuration for the inline IPSec device. This
322    will be used when creating flow rules with RTE_FLOW_ACTION_TYPE_SECURITY
323    action.
324
325    By default, RTE Flow API sets the channel number of the port on which the
326    rule is created in the MCAM entry and matches it exactly. This behaviour can
327    be modified using the ``inl_cpt_channel`` ``devargs`` parameter.
328
329    For example::
330
331       -a 0002:1d:00.0,inl_cpt_channel=0x100/0xf00
332
333    With the above configuration, RTE Flow rules API will set the channel
334    and channel mask as 0x100 and 0xF00 in the MCAM entries of the  flow rules
335    created with RTE_FLOW_ACTION_TYPE_SECURITY action. Since channel number is
336    set with this custom mask, inbound encrypted traffic from all ports with
337    matching channel number pattern will be directed to the inline IPSec device.
338
339 - ``SDP device channel and mask`` (default ``none``)
340    Set channel and channel mask configuration for the SDP device. This
341    will be used when creating flow rules on the SDP device.
342
343    By default, for rules created on the SDP device, the RTE Flow API sets the
344    channel number and mask to cover the entire SDP channel range in the channel
345    field of the MCAM entry. This behaviour can be modified using the
346    ``sdp_channel_mask`` ``devargs`` parameter.
347
348    For example::
349
350       -a 0002:1d:00.0,sdp_channel_mask=0x700/0xf00
351
352    With the above configuration, RTE Flow rules API will set the channel
353    and channel mask as 0x700 and 0xF00 in the MCAM entries of the  flow rules
354    created on the SDP device. This option needs to be used when more than one
355    SDP interface is in use and RTE Flow rules created need to distinguish
356    between traffic from each SDP interface. The channel and mask combination
357    specified should match all the channels(or rings) configured on the SDP
358    interface.
359
360 .. note::
361
362    Above devarg parameters are configurable per device, user needs to pass the
363    parameters to all the PCIe devices if application requires to configure on
364    all the ethdev ports.
365
366 Limitations
367 -----------
368
369 ``mempool_cnxk`` external mempool handler dependency
370 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
371
372 The OCTEON CN9K/CN10K SoC family NIC has inbuilt HW assisted external mempool manager.
373 ``net_cnxk`` PMD only works with ``mempool_cnxk`` mempool handler
374 as it is performance wise most effective way for packet allocation and Tx buffer
375 recycling on OCTEON 9 SoC platform.
376
377 CRC stripping
378 ~~~~~~~~~~~~~
379
380 The OCTEON CN9K/CN10K SoC family NICs strip the CRC for every packet being received by
381 the host interface irrespective of the offload configuration.
382
383 RTE flow GRE support
384 ~~~~~~~~~~~~~~~~~~~~
385
386 - ``RTE_FLOW_ITEM_TYPE_GRE_KEY`` works only when checksum and routing
387   bits in the GRE header are equal to 0.
388
389 RTE flow action port_id support
390 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
391
392 - ``RTE_FLOW_ACTION_TYPE_PORT_ID`` is only supported between PF and its VFs.
393
394 Custom protocols supported in RTE Flow
395 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
396
397 The ``RTE_FLOW_ITEM_TYPE_RAW`` can be used to parse the below custom protocols.
398
399 * ``vlan_exdsa`` and ``exdsa`` can be parsed at L2 level.
400 * ``NGIO`` can be parsed at L3 level.
401
402 For ``vlan_exdsa`` and ``exdsa``, the port has to be configured with the
403 respective switch header.
404
405 For example::
406
407    -a 0002:02:00.0,switch_header="vlan_exdsa"
408
409 The below fields of ``struct rte_flow_item_raw`` shall be used to specify the
410 pattern.
411
412 - ``relative`` Selects the layer at which parsing is done.
413
414   - 0 for ``exdsa`` and ``vlan_exdsa``.
415
416   - 1 for  ``NGIO``.
417
418 - ``offset`` The offset in the header where the pattern should be matched.
419 - ``length`` Length of the pattern.
420 - ``pattern`` Pattern as a byte string.
421
422 Example usage in testpmd::
423
424    ./dpdk-testpmd -c 3 -w 0002:02:00.0,switch_header=exdsa -- -i \
425                   --rx-offloads=0x00080000 --rxq 8 --txq 8
426    testpmd> flow create 0 ingress pattern eth / raw relative is 0 pattern \
427           spec ab pattern mask ab offset is 4 / end actions queue index 1 / end
428
429 RTE Flow mark item support
430 ~~~~~~~~~~~~~~~~~~~~~~~~~~
431
432 - ``RTE_FLOW_ITEM_TYPE_MARK`` can be used to create ingress flow rules to match
433   packets from CPT(second pass packets). When mark item type is used, it should
434   be the first item in the patterns specification.
435
436 Inline device support for CN10K
437 -------------------------------
438
439 CN10K HW provides a misc device Inline device that supports ethernet devices in
440 providing following features.
441
442   - Aggregate all the inline IPsec inbound traffic from all the CN10K ethernet
443     devices to be processed by the single inline IPSec device. This allows
444     single rte security session to accept traffic from multiple ports.
445
446   - Support for event generation on outbound inline IPsec processing errors.
447
448   - Support CN106xx poll mode of operation for inline IPSec inbound processing.
449
450 Inline IPsec device is identified by PCI PF vendid:devid ``177D:A0F0`` or
451 VF ``177D:A0F1``.
452
453 Runtime Config Options for inline device
454 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
455
456 - ``Min SPI for inbound inline IPsec`` (default ``0``)
457
458    Min SPI supported for inbound inline IPsec processing can be specified by
459    ``ipsec_in_min_spi`` ``devargs`` parameter.
460
461    For example::
462
463       -a 0002:1d:00.0,ipsec_in_min_spi=6
464
465    With the above configuration, application can enable inline IPsec processing
466    for inbound SA with min SPI of 6 for traffic aggregated on inline device.
467
468 - ``Max SPI for inbound inline IPsec`` (default ``255``)
469
470    Max SPI supported for inbound inline IPsec processing can be specified by
471    ``ipsec_in_max_spi`` ``devargs`` parameter.
472
473    For example::
474
475       -a 0002:1d:00.0,ipsec_in_max_spi=128
476
477    With the above configuration, application can enable inline IPsec processing
478    for inbound SA with max SPI of 128 for traffic aggregated on inline device.
479
480
481 Debugging Options
482 -----------------
483
484 .. _table_cnxk_ethdev_debug_options:
485
486 .. table:: cnxk ethdev debug options
487
488    +---+------------+-------------------------------------------------------+
489    | # | Component  | EAL log command                                       |
490    +===+============+=======================================================+
491    | 1 | NIX        | --log-level='pmd\.net.cnxk,8'                         |
492    +---+------------+-------------------------------------------------------+
493    | 2 | NPC        | --log-level='pmd\.net.cnxk\.flow,8'                   |
494    +---+------------+-------------------------------------------------------+