xref: /dpdk/doc/guides/testpmd_app_ug/testpmd_funcs.rst (revision 045e35aa3fd6a9f82a6b30be81403a77fe4ee551)
1..  SPDX-License-Identifier: BSD-3-Clause
2    Copyright(c) 2010-2016 Intel Corporation.
3
4.. _testpmd_runtime:
5
6Testpmd Runtime Functions
7=========================
8
9Where the testpmd application is started in interactive mode, (``-i|--interactive``),
10it displays a prompt that can be used to start and stop forwarding,
11configure the application, display statistics (including the extended NIC
12statistics aka xstats) , set the Flow Director and other tasks::
13
14   testpmd>
15
16The testpmd prompt has some, limited, readline support.
17Common bash command-line functions such as ``Ctrl+a`` and ``Ctrl+e`` to go to the start and end of the prompt line are supported
18as well as access to the command history via the up-arrow.
19
20There is also support for tab completion.
21If you type a partial command and hit ``<TAB>`` you get a list of the available completions:
22
23.. code-block:: console
24
25   testpmd> show port <TAB>
26
27       info [Mul-choice STRING]: show|clear port info|stats|xstats|fdir|dcb_tc|cap X
28       info [Mul-choice STRING]: show|clear port info|stats|xstats|fdir|dcb_tc|cap all
29       stats [Mul-choice STRING]: show|clear port info|stats|xstats|fdir|dcb_tc|cap X
30       stats [Mul-choice STRING]: show|clear port info|stats|xstats|fdir|dcb_tc|cap all
31       ...
32
33
34.. note::
35
36   Some examples in this document are too long to fit on one line are shown wrapped at `"\\"` for display purposes::
37
38      testpmd> set flow_ctrl rx (on|off) tx (on|off) (high_water) (low_water) \
39               (pause_time) (send_xon) (port_id)
40
41In the real ``testpmd>`` prompt these commands should be on a single line.
42
43Help Functions
44--------------
45
46The testpmd has on-line help for the functions that are available at runtime.
47These are divided into sections and can be accessed using help, help section or help all:
48
49.. code-block:: console
50
51   testpmd> help
52       Help is available for the following sections:
53
54           help control                    : Start and stop forwarding.
55           help display                    : Displaying port, stats and config information.
56           help config                     : Configuration information.
57           help ports                      : Configuring ports.
58           help filters                    : Filters configuration help.
59           help traffic_management         : Traffic Management commands.
60           help devices                    : Device related commands.
61           help drivers                    : Driver specific commands.
62           help all                        : All of the above sections.
63
64Command File Functions
65----------------------
66
67To facilitate loading large number of commands or to avoid cutting and pasting where not
68practical or possible testpmd supports alternative methods for executing commands.
69
70* If started with the ``--cmdline-file=FILENAME`` command line argument testpmd
71  will execute all CLI commands contained within the file immediately before
72  starting packet forwarding or entering interactive mode.
73
74.. code-block:: console
75
76   ./dpdk-testpmd -n4 -r2 ... -- -i --cmdline-file=/home/ubuntu/flow-create-commands.txt
77   Interactive-mode selected
78   CLI commands to be read from /home/ubuntu/flow-create-commands.txt
79   Configuring Port 0 (socket 0)
80   Port 0: 7C:FE:90:CB:74:CE
81   Configuring Port 1 (socket 0)
82   Port 1: 7C:FE:90:CB:74:CA
83   Checking link statuses...
84   Port 0 Link Up - speed 10000 Mbps - full-duplex
85   Port 1 Link Up - speed 10000 Mbps - full-duplex
86   Done
87   Flow rule #0 created
88   Flow rule #1 created
89   ...
90   ...
91   Flow rule #498 created
92   Flow rule #499 created
93   Read all CLI commands from /home/ubuntu/flow-create-commands.txt
94   testpmd>
95
96
97* At run-time additional commands can be loaded in bulk by invoking the ``load FILENAME``
98  command.
99
100.. code-block:: console
101
102   testpmd> load /home/ubuntu/flow-create-commands.txt
103   Flow rule #0 created
104   Flow rule #1 created
105   ...
106   ...
107   Flow rule #498 created
108   Flow rule #499 created
109   Read all CLI commands from /home/ubuntu/flow-create-commands.txt
110   testpmd>
111
112
113In all cases output from any included command will be displayed as standard output.
114Execution will continue until the end of the file is reached regardless of
115whether any errors occur.  The end user must examine the output to determine if
116any failures occurred.
117
118
119Control Functions
120-----------------
121
122start
123~~~~~
124
125Start packet forwarding with current configuration::
126
127   testpmd> start
128
129start tx_first
130~~~~~~~~~~~~~~
131
132Start packet forwarding with current configuration after sending specified number of bursts of packets::
133
134   testpmd> start tx_first (""|burst_num)
135
136The default burst number is 1 when ``burst_num`` not presented.
137
138stop
139~~~~
140
141Stop packet forwarding, and display accumulated statistics::
142
143   testpmd> stop
144
145quit
146~~~~
147
148Quit to prompt::
149
150   testpmd> quit
151
152
153Display Functions
154-----------------
155
156The functions in the following sections are used to display information about the
157testpmd configuration or the NIC status.
158
159show port
160~~~~~~~~~
161
162Display information for a given port or all ports::
163
164   testpmd> show port (info|summary|stats|xstats|fdir|dcb_tc|cap) (port_id|all)
165
166The available information categories are:
167
168* ``info``: General port information such as MAC address.
169
170* ``summary``: Brief port summary such as Device Name, Driver Name etc.
171
172* ``stats``: RX/TX statistics.
173
174* ``xstats``: RX/TX extended NIC statistics.
175
176* ``fdir``: Flow Director information and statistics.
177
178* ``dcb_tc``: DCB information such as TC mapping.
179
180For example:
181
182.. code-block:: console
183
184   testpmd> show port info 0
185
186   ********************* Infos for port 0 *********************
187
188   MAC address: XX:XX:XX:XX:XX:XX
189   Connect to socket: 0
190   memory allocation on the socket: 0
191   Link status: up
192   Link speed: 40000 Mbps
193   Link duplex: full-duplex
194   Promiscuous mode: enabled
195   Allmulticast mode: disabled
196   Maximum number of MAC addresses: 64
197   Maximum number of MAC addresses of hash filtering: 0
198   VLAN offload:
199       strip on, filter on, extend off, qinq strip off
200   Redirection table size: 512
201   Supported flow types:
202     ipv4-frag
203     ipv4-tcp
204     ipv4-udp
205     ipv4-sctp
206     ipv4-other
207     ipv6-frag
208     ipv6-tcp
209     ipv6-udp
210     ipv6-sctp
211     ipv6-other
212     l2_payload
213     port
214     vxlan
215     geneve
216     nvgre
217     vxlan-gpe
218
219show port (module_eeprom|eeprom)
220~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
221
222Display the EEPROM information of a port::
223
224   testpmd> show port (port_id) (module_eeprom|eeprom)
225
226set eeprom
227~~~~~~~~~~
228
229Write a value to the device EEPROM of a port at a specific offset::
230
231   testpmd> set port (port_id) eeprom (accept_risk) magic (magic_num) value (value) \
232            offset (offset)
233
234Value should be given in the form of a hex-as-string, with no leading ``0x``.
235The offset field here is optional,
236if not specified then the offset will default to 0.
237
238.. note::
239
240   This is a high-risk command
241   and its misuse may result in unexpected behaviour from the NIC.
242   By inserting "accept_risk" into the command,
243   the user is acknowledging and taking responsibility for this risk.
244
245show port rss reta
246~~~~~~~~~~~~~~~~~~
247
248Display the rss redirection table entry indicated by masks on port X::
249
250   testpmd> show port (port_id) rss reta (size) (mask0, mask1...)
251
252size is used to indicate the hardware supported reta size
253
254show port rss-hash
255~~~~~~~~~~~~~~~~~~
256
257Display the RSS hash functions and RSS hash key or RSS hash algorithm of a port::
258
259   testpmd> show port (port_id) rss-hash [key | algorithm]
260
261clear port
262~~~~~~~~~~
263
264Clear the port statistics and forward engine statistics for a given port or for all ports::
265
266   testpmd> clear port (info|stats|xstats|fdir) (port_id|all)
267
268For example::
269
270   testpmd> clear port stats all
271
272show (rxq|txq)
273~~~~~~~~~~~~~~
274
275Display information for a given port's RX/TX queue::
276
277   testpmd> show (rxq|txq) info (port_id) (queue_id)
278
279show desc status(rxq|txq)
280~~~~~~~~~~~~~~~~~~~~~~~~~
281
282Display information for a given port's RX/TX descriptor status::
283
284   testpmd> show port (port_id) (rxq|txq) (queue_id) desc (desc_id) status
285
286show desc used count(rxq|txq)
287~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
288
289Display the number of packet descriptors currently used by hardware for a queue::
290
291   testpmd> show port (port_id) (rxq|txq) (queue_id) desc used count
292
293show config
294~~~~~~~~~~~
295
296Displays the configuration of the application.
297The configuration comes from the command-line, the runtime or the application defaults::
298
299   testpmd> show config (rxtx|cores|fwd|rxoffs|rxpkts|rxhdrs|txpkts|txtimes)
300
301The available information categories are:
302
303* ``rxtx``: RX/TX configuration items.
304
305* ``cores``: List of forwarding cores.
306
307* ``fwd``: Packet forwarding configuration.
308
309* ``rxoffs``: Packet offsets for RX split.
310
311* ``rxpkts``: Packets to RX length-based split configuration.
312
313* ``rxhdrs``: Packets to RX proto-based split configuration.
314
315* ``txpkts``: Packets to TX configuration.
316
317* ``txtimes``: Burst time pattern for Tx only mode.
318
319For example:
320
321.. code-block:: console
322
323   testpmd> show config rxtx
324
325   io packet forwarding - CRC stripping disabled - packets/burst=16
326   nb forwarding cores=2 - nb forwarding ports=1
327   RX queues=1 - RX desc=128 - RX free threshold=0
328   RX threshold registers: pthresh=8 hthresh=8 wthresh=4
329   TX queues=1 - TX desc=512 - TX free threshold=0
330   TX threshold registers: pthresh=36 hthresh=0 wthresh=0
331   TX RS bit threshold=0 - TXQ flags=0x0
332
333set fwd
334~~~~~~~
335
336Set the packet forwarding mode::
337
338   testpmd> set fwd (io|mac|macswap|flowgen| \
339                     rxonly|txonly|csum|icmpecho|noisy|5tswap|shared-rxq|recycle_mbufs) (""|retry)
340
341``retry`` can be specified for forwarding engines except ``rx_only``.
342
343The available information categories are:
344
345* ``io``: Forwards packets "as-is" in I/O mode.
346  This is the fastest possible forwarding operation as it does not access packets data.
347  This is the default mode.
348
349* ``mac``: Changes the source and the destination Ethernet addresses of packets before forwarding them.
350  Default application behavior is to set source Ethernet address to that of the transmitting interface, and destination
351  address to a dummy value (set during init). The user may specify a target destination Ethernet address via the 'eth-peer' or
352  'eth-peers-configfile' command-line options. It is not currently possible to specify a specific source Ethernet address.
353
354* ``macswap``: MAC swap forwarding mode.
355  Swaps the source and the destination Ethernet addresses of packets before forwarding them.
356
357* ``flowgen``: Multi-flow generation mode.
358  Originates a number of flows (with varying destination IP addresses), and terminate receive traffic.
359
360* ``rxonly``: Receives packets but doesn't transmit them.
361
362* ``txonly``: Generates and transmits packets without receiving any.
363
364* ``csum``: Changes the checksum field with hardware or software methods depending on the offload flags on the packet.
365
366* ``icmpecho``: Receives a burst of packets, lookup for ICMP echo requests and, if any, send back ICMP echo replies.
367
368* ``ieee1588``: Demonstrate L2 IEEE1588 V2 PTP timestamping for RX and TX.
369
370* ``noisy``: Noisy neighbor simulation.
371  Simulate more realistic behavior of a guest machine engaged in receiving
372  and sending packets performing Virtual Network Function (VNF).
373
374* ``5tswap``: Swap the source and destination of L2,L3,L4 if they exist.
375
376  L2 swaps the source address and destination address of Ethernet, as same as ``macswap``.
377
378  L3 swaps the source address and destination address of IP (v4 and v6).
379
380  L4 swaps the source port and destination port of transport layer (TCP and UDP).
381
382* ``shared-rxq``: Receive only for shared Rx queue.
383  Resolve packet source port from mbuf and update stream statistics accordingly.
384
385* ``recycle_mbufs``:  Recycle Tx queue used mbufs for Rx queue mbuf ring.
386  This mode uses fast path mbuf recycle feature and forwards packets in I/O mode.
387
388Example::
389
390   testpmd> set fwd rxonly
391
392   Set rxonly packet forwarding mode
393
394
395show fwd
396~~~~~~~~
397
398When running, forwarding engines maintain statistics from the time they have been started.
399Example for the io forwarding engine, with some packet drops on the tx side::
400
401   testpmd> show fwd stats all
402
403     ------- Forward Stats for RX Port= 0/Queue= 0 -> TX Port= 1/Queue= 0 -------
404     RX-packets: 274293770      TX-packets: 274293642      TX-dropped: 128
405
406     ------- Forward Stats for RX Port= 1/Queue= 0 -> TX Port= 0/Queue= 0 -------
407     RX-packets: 274301850      TX-packets: 274301850      TX-dropped: 0
408
409     ---------------------- Forward statistics for port 0  ----------------------
410     RX-packets: 274293802      RX-dropped: 0             RX-total: 274293802
411     TX-packets: 274301862      TX-dropped: 0             TX-total: 274301862
412     ----------------------------------------------------------------------------
413
414     ---------------------- Forward statistics for port 1  ----------------------
415     RX-packets: 274301894      RX-dropped: 0             RX-total: 274301894
416     TX-packets: 274293706      TX-dropped: 128           TX-total: 274293834
417     ----------------------------------------------------------------------------
418
419     +++++++++++++++ Accumulated forward statistics for all ports+++++++++++++++
420     RX-packets: 548595696      RX-dropped: 0             RX-total: 548595696
421     TX-packets: 548595568      TX-dropped: 128           TX-total: 548595696
422     ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
423
424
425clear fwd
426~~~~~~~~~
427
428Clear the forwarding engines statistics::
429
430   testpmd> clear fwd stats all
431
432read rxd
433~~~~~~~~
434
435Display an RX descriptor for a port RX queue::
436
437   testpmd> read rxd (port_id) (queue_id) (rxd_id)
438
439For example::
440
441   testpmd> read rxd 0 0 4
442        0x0000000B - 0x001D0180 / 0x0000000B - 0x001D0180
443
444read txd
445~~~~~~~~
446
447Display a TX descriptor for a port TX queue::
448
449   testpmd> read txd (port_id) (queue_id) (txd_id)
450
451For example::
452
453   testpmd> read txd 0 0 4
454        0x00000001 - 0x24C3C440 / 0x000F0000 - 0x2330003C
455
456show vf stats
457~~~~~~~~~~~~~
458
459Display VF statistics::
460
461   testpmd> show vf stats (port_id) (vf_id)
462
463clear vf stats
464~~~~~~~~~~~~~~
465
466Reset VF statistics::
467
468   testpmd> clear vf stats (port_id) (vf_id)
469
470show rx offloading capabilities
471~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
472
473List all per queue and per port Rx offloading capabilities of a port::
474
475   testpmd> show port (port_id) rx_offload capabilities
476
477show rx offloading configuration
478~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
479
480List port level and all queue level Rx offloading configuration::
481
482   testpmd> show port (port_id) rx_offload configuration
483
484show tx offloading capabilities
485~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
486
487List all per queue and per port Tx offloading capabilities of a port::
488
489   testpmd> show port (port_id) tx_offload capabilities
490
491show tx offloading configuration
492~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
493
494List port level and all queue level Tx offloading configuration::
495
496   testpmd> show port (port_id) tx_offload configuration
497
498show tx metadata setting
499~~~~~~~~~~~~~~~~~~~~~~~~
500
501Show Tx metadata value set for a specific port::
502
503   testpmd> show port (port_id) tx_metadata
504
505show port supported ptypes
506~~~~~~~~~~~~~~~~~~~~~~~~~~
507
508Show ptypes supported for a specific port::
509
510   testpmd> show port (port_id) ptypes
511
512set port supported ptypes
513~~~~~~~~~~~~~~~~~~~~~~~~~
514
515set packet types classification for a specific port::
516
517   testpmd> set port (port_id) ptypes_mask (mask)
518
519show port mac addresses info
520~~~~~~~~~~~~~~~~~~~~~~~~~~~~
521
522Show mac addresses added for a specific port::
523
524   testpmd> show port (port_id) macs
525
526
527show port multicast mac addresses info
528~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
529
530Show multicast mac addresses added for a specific port::
531
532   testpmd> show port (port_id) mcast_macs
533
534show flow transfer proxy port ID for the given port
535~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
536
537Show proxy port ID to use as the 1st argument in commands to
538manage ``transfer`` flows and their indirect components.
539::
540
541   testpmd> show port (port_id) flow transfer proxy
542
543show device info
544~~~~~~~~~~~~~~~~
545
546Show general information about devices probed::
547
548   testpmd> show device info (<identifier>|all)
549
550For example:
551
552.. code-block:: console
553
554    testpmd> show device info net_pcap0
555
556    ********************* Infos for device net_pcap0 *********************
557    Bus name: vdev
558    Driver name: net_pcap
559    Devargs: iface=enP2p6s0,phy_mac=1
560    Connect to socket: -1
561
562            Port id: 2
563            MAC address: 1E:37:93:28:04:B8
564            Device name: net_pcap0
565
566dump physmem
567~~~~~~~~~~~~
568
569Dumps all physical memory segment layouts::
570
571   testpmd> dump_physmem
572
573dump memzone
574~~~~~~~~~~~~
575
576Dumps the layout of all memory zones::
577
578   testpmd> dump_memzone
579
580dump socket memory
581~~~~~~~~~~~~~~~~~~
582
583Dumps the memory usage of all sockets::
584
585   testpmd> dump_socket_mem
586
587dump struct size
588~~~~~~~~~~~~~~~~
589
590Dumps the size of all memory structures::
591
592   testpmd> dump_struct_sizes
593
594dump ring
595~~~~~~~~~
596
597Dumps the status of all or specific element in DPDK rings::
598
599   testpmd> dump_ring [ring_name]
600
601dump mempool
602~~~~~~~~~~~~
603
604Dumps the statistics of all or specific memory pool::
605
606   testpmd> dump_mempool [mempool_name]
607
608dump devargs
609~~~~~~~~~~~~
610
611Dumps the user device list::
612
613   testpmd> dump_devargs
614
615dump lcores
616~~~~~~~~~~~
617
618Dumps the logical cores list::
619
620   testpmd> dump_lcores
621
622dump trace
623~~~~~~~~~~
624
625Dumps the tracing data to the folder according to the current EAL settings::
626
627   testpmd> dump_trace
628
629dump log types
630~~~~~~~~~~~~~~
631
632Dumps the log level for all the dpdk modules::
633
634   testpmd> dump_log_types
635
636show (raw_encap|raw_decap)
637~~~~~~~~~~~~~~~~~~~~~~~~~~
638
639Display content of raw_encap/raw_decap buffers in hex::
640
641  testpmd> show <raw_encap|raw_decap> <index>
642  testpmd> show <raw_encap|raw_decap> all
643
644For example::
645
646  testpmd> show raw_encap 6
647
648  index: 6 at [0x1c565b0], len=50
649  00000000: 00 00 00 00 00 00 16 26 36 46 56 66 08 00 45 00 | .......&6FVf..E.
650  00000010: 00 00 00 00 00 00 00 11 00 00 C0 A8 01 06 C0 A8 | ................
651  00000020: 03 06 00 00 00 FA 00 00 00 00 08 00 00 00 00 00 | ................
652  00000030: 06 00                                           | ..
653
654show fec capabilities
655~~~~~~~~~~~~~~~~~~~~~
656
657Show fec capabilities of a port::
658
659  testpmd> show port (port_id) fec capabilities
660
661show fec mode
662~~~~~~~~~~~~~
663
664Show fec mode of a port::
665
666  testpmd> show port (port_id) fec_mode
667
668
669Configuration Functions
670-----------------------
671
672The testpmd application can be configured from the runtime as well as from the command-line.
673
674This section details the available configuration functions that are available.
675
676.. note::
677
678   Configuration changes only become active when forwarding is started/restarted.
679
680set default
681~~~~~~~~~~~
682
683Reset forwarding to the default configuration::
684
685   testpmd> set default
686
687set verbose
688~~~~~~~~~~~
689
690Set the debug verbosity level::
691
692   testpmd> set verbose (level)
693
694Available levels are as following:
695
696* ``0`` silent except for error.
697* ``1`` fully verbose except for Tx packets.
698* ``2`` fully verbose except for Rx packets.
699* ``> 2`` fully verbose.
700
701set log
702~~~~~~~
703
704Set the log level for a log type::
705
706	testpmd> set log global|(type) (level)
707
708Where:
709
710* ``type`` is the log name.
711
712* ``level`` is the log level.
713
714For example, to change the global log level::
715
716	testpmd> set log global (level)
717
718Regexes can also be used for type. To change log level of user1, user2 and user3::
719
720	testpmd> set log user[1-3] (level)
721
722set nbport
723~~~~~~~~~~
724
725Set the number of ports used by the application:
726
727set nbport (num)
728
729This is equivalent to the ``--nb-ports`` command-line option.
730
731set nbcore
732~~~~~~~~~~
733
734Set the number of cores used by the application::
735
736   testpmd> set nbcore (num)
737
738This is equivalent to the ``--nb-cores`` command-line option.
739
740.. note::
741
742   The number of cores used must not be greater than number of ports used multiplied by the number of queues per port.
743
744set coremask
745~~~~~~~~~~~~
746
747Set the forwarding cores hexadecimal mask::
748
749   testpmd> set coremask (mask)
750
751This is equivalent to the ``--coremask`` command-line option.
752
753.. note::
754
755   The main lcore is reserved for command line parsing only and cannot be masked on for packet forwarding.
756
757set portmask
758~~~~~~~~~~~~
759
760Set the forwarding ports hexadecimal mask::
761
762   testpmd> set portmask (mask)
763
764This is equivalent to the ``--portmask`` command-line option.
765
766set record-core-cycles
767~~~~~~~~~~~~~~~~~~~~~~
768
769Set the recording of CPU cycles::
770
771   testpmd> set record-core-cycles (on|off)
772
773Where:
774
775* ``on`` enables measurement of CPU cycles per packet.
776
777* ``off`` disables measurement of CPU cycles per packet.
778
779This is equivalent to the ``--record-core-cycles command-line`` option.
780
781set record-burst-stats
782~~~~~~~~~~~~~~~~~~~~~~
783
784Set the displaying of RX and TX bursts::
785
786   testpmd> set record-burst-stats (on|off)
787
788Where:
789
790* ``on`` enables display of RX and TX bursts.
791
792* ``off`` disables display of RX and TX bursts.
793
794This is equivalent to the ``--record-burst-stats command-line`` option.
795
796set burst
797~~~~~~~~~
798
799Set number of packets per burst::
800
801   testpmd> set burst (num)
802
803This is equivalent to the ``--burst command-line`` option.
804
805When retry is enabled, the transmit delay time and number of retries can also be set::
806
807   testpmd> set burst tx delay (microseconds) retry (num)
808
809set rxoffs
810~~~~~~~~~~
811
812Set the offsets of segments relating to the data buffer beginning on receiving
813if split feature is engaged. Affects only the queues configured with split
814offloads (currently BUFFER_SPLIT is supported only).
815
816   testpmd> set rxoffs (x[,y]*)
817
818Where x[,y]* represents a CSV list of values, without white space. If the list
819of offsets is shorter than the list of segments the zero offsets will be used
820for the remaining segments.
821
822set rxpkts
823~~~~~~~~~~
824
825Set the length of segments to scatter packets on receiving if split
826feature is engaged. Affects only the queues configured with split offloads
827(currently BUFFER_SPLIT is supported only). Optionally the multiple memory
828pools can be specified with --mbuf-size command line parameter and the mbufs
829to receive will be allocated sequentially from these extra memory pools (the
830mbuf for the first segment is allocated from the first pool, the second one
831from the second pool, and so on, if segment number is greater then pool's the
832mbuf for remaining segments will be allocated from the last valid pool).
833
834   testpmd> set rxpkts (x[,y]*)
835
836Where x[,y]* represents a CSV list of values, without white space. Zero value
837means to use the corresponding memory pool data buffer size.
838
839set rxhdrs
840~~~~~~~~~~
841
842Set the protocol headers of segments to scatter packets on receiving
843if split feature is engaged.
844Affects only the queues configured with split offloads
845(currently BUFFER_SPLIT is supported only).
846
847   testpmd> set rxhdrs (eth[,ipv4]*)
848
849Where eth[,ipv4]* represents a CSV list of values, without white space.
850If the list of offsets is shorter than the list of segments,
851zero offsets will be used for the remaining segments.
852
853set txpkts
854~~~~~~~~~~
855
856Set the length of each segment of the TX-ONLY packets or length of packet for FLOWGEN mode::
857
858   testpmd> set txpkts (x[,y]*)
859
860Where x[,y]* represents a CSV list of values, without white space.
861
862set txtimes
863~~~~~~~~~~~
864
865Configure the timing burst pattern for Tx only mode. This command enables
866the packet send scheduling on dynamic timestamp mbuf field and configures
867timing pattern in Tx only mode. In this mode, if scheduling is enabled
868application provides timestamps in the packets being sent. It is possible
869to configure delay (in unspecified device clock units) between bursts
870and between the packets within the burst::
871
872   testpmd> set txtimes (inter),(intra)
873
874where:
875
876* ``inter``  is the delay between the bursts in the device clock units.
877  If ``intra`` is zero, this is the time between the beginnings of the
878  first packets in the neighbour bursts, if ``intra`` is not zero,
879  ``inter`` specifies the time between the beginning of the first packet
880  of the current burst and the beginning of the last packet of the
881  previous burst. If ``inter`` parameter is zero the send scheduling
882  on timestamps is disabled (default).
883
884* ``intra`` is the delay between the packets within the burst specified
885  in the device clock units. The number of packets in the burst is defined
886  by regular burst setting. If ``intra`` parameter is zero no timestamps
887  provided in the packets excepting the first one in the burst.
888
889As the result the bursts of packet will be transmitted with specific
890delays between the packets within the burst and specific delay between
891the bursts. The rte_eth_read_clock() must be supported by the device(s)
892and is supposed to be engaged to get the current device clock value
893and provide the reference for the timestamps. If there is no supported
894rte_eth_read_clock() there will be no send scheduling provided on the port.
895
896set txsplit
897~~~~~~~~~~~
898
899Set the split policy for the TX packets, applicable for TX-ONLY and CSUM forwarding modes::
900
901   testpmd> set txsplit (off|on|rand)
902
903Where:
904
905* ``off`` disable packet copy & split for CSUM mode.
906
907* ``on`` split outgoing packet into multiple segments. Size of each segment
908  and number of segments per packet is determined by ``set txpkts`` command
909  (see above).
910
911* ``rand`` same as 'on', but number of segments per each packet is a random value between 1 and total number of segments.
912
913set corelist
914~~~~~~~~~~~~
915
916Set the list of forwarding cores::
917
918   testpmd> set corelist (x[,y]*)
919
920For example, to change the forwarding cores:
921
922.. code-block:: console
923
924   testpmd> set corelist 3,1
925   testpmd> show config fwd
926
927   io packet forwarding - ports=2 - cores=2 - streams=2 - NUMA support disabled
928   Logical Core 3 (socket 0) forwards packets on 1 streams:
929   RX P=0/Q=0 (socket 0) -> TX P=1/Q=0 (socket 0) peer=02:00:00:00:00:01
930   Logical Core 1 (socket 0) forwards packets on 1 streams:
931   RX P=1/Q=0 (socket 0) -> TX P=0/Q=0 (socket 0) peer=02:00:00:00:00:00
932
933.. note::
934
935   The cores are used in the same order as specified on the command line.
936
937set portlist
938~~~~~~~~~~~~
939
940Set the list of forwarding ports::
941
942   testpmd> set portlist (x[,y]*)
943
944For example, to change the port forwarding:
945
946.. code-block:: console
947
948   testpmd> set portlist 0,2,1,3
949   testpmd> show config fwd
950
951   io packet forwarding - ports=4 - cores=1 - streams=4
952   Logical Core 3 (socket 0) forwards packets on 4 streams:
953   RX P=0/Q=0 (socket 0) -> TX P=2/Q=0 (socket 0) peer=02:00:00:00:00:01
954   RX P=2/Q=0 (socket 0) -> TX P=0/Q=0 (socket 0) peer=02:00:00:00:00:00
955   RX P=1/Q=0 (socket 0) -> TX P=3/Q=0 (socket 0) peer=02:00:00:00:00:03
956   RX P=3/Q=0 (socket 0) -> TX P=1/Q=0 (socket 0) peer=02:00:00:00:00:02
957
958set port setup on
959~~~~~~~~~~~~~~~~~
960
961Select how to retrieve new ports created after "port attach" command::
962
963   testpmd> set port setup on (iterator|event)
964
965For each new port, a setup is done.
966It will find the probed ports via RTE_ETH_FOREACH_MATCHING_DEV loop
967in iterator mode, or via RTE_ETH_EVENT_NEW in event mode.
968
969set tx loopback
970~~~~~~~~~~~~~~~
971
972Enable/disable tx loopback::
973
974   testpmd> set tx loopback (port_id) (on|off)
975
976set drop enable
977~~~~~~~~~~~~~~~
978
979set drop enable bit for all queues::
980
981   testpmd> set all queues drop (port_id) (on|off)
982
983set mac antispoof (for VF)
984~~~~~~~~~~~~~~~~~~~~~~~~~~
985
986Set mac antispoof for a VF from the PF::
987
988   testpmd> set vf mac antispoof  (port_id) (vf_id) (on|off)
989
990vlan set stripq
991~~~~~~~~~~~~~~~
992
993Set the VLAN strip for a queue on a port::
994
995   testpmd> vlan set stripq (on|off) (port_id,queue_id)
996
997vlan set stripq (for VF)
998~~~~~~~~~~~~~~~~~~~~~~~~
999
1000Set VLAN strip for all queues in a pool for a VF from the PF::
1001
1002   testpmd> set vf vlan stripq (port_id) (vf_id) (on|off)
1003
1004vlan set insert (for VF)
1005~~~~~~~~~~~~~~~~~~~~~~~~
1006
1007Set VLAN insert for a VF from the PF::
1008
1009   testpmd> set vf vlan insert (port_id) (vf_id) (vlan_id)
1010
1011vlan set antispoof (for VF)
1012~~~~~~~~~~~~~~~~~~~~~~~~~~~
1013
1014Set VLAN antispoof for a VF from the PF::
1015
1016   testpmd> set vf vlan antispoof (port_id) (vf_id) (on|off)
1017
1018vlan set (strip|filter|qinq_strip|extend)
1019~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1020Set the VLAN strip/filter/QinQ strip/extend on for a port::
1021
1022   testpmd> vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)
1023
1024vlan set tpid
1025~~~~~~~~~~~~~
1026
1027Set the inner or outer VLAN TPID for packet filtering on a port::
1028
1029   testpmd> vlan set (inner|outer) tpid (value) (port_id)
1030
1031.. note::
1032
1033   TPID value must be a 16-bit number (value <= 65536).
1034
1035rx_vlan add
1036~~~~~~~~~~~
1037
1038Add a VLAN ID, or all identifiers, to the set of VLAN identifiers filtered by port ID::
1039
1040   testpmd> rx_vlan add (vlan_id|all) (port_id)
1041
1042.. note::
1043
1044   VLAN filter must be set on that port. VLAN ID < 4096.
1045   Depending on the NIC used, number of vlan_ids may be limited to the maximum entries
1046   in VFTA table. This is important if enabling all vlan_ids.
1047
1048rx_vlan rm
1049~~~~~~~~~~
1050
1051Remove a VLAN ID, or all identifiers, from the set of VLAN identifiers filtered by port ID::
1052
1053   testpmd> rx_vlan rm (vlan_id|all) (port_id)
1054
1055rx_vlan add (for VF)
1056~~~~~~~~~~~~~~~~~~~~
1057
1058Add a VLAN ID, to the set of VLAN identifiers filtered for VF(s) for port ID::
1059
1060   testpmd> rx_vlan add (vlan_id) port (port_id) vf (vf_mask)
1061
1062rx_vlan rm (for VF)
1063~~~~~~~~~~~~~~~~~~~
1064
1065Remove a VLAN ID, from the set of VLAN identifiers filtered for VF(s) for port ID::
1066
1067   testpmd> rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)
1068
1069rx_vxlan_port add
1070~~~~~~~~~~~~~~~~~
1071
1072Add an UDP port for VXLAN packet filter on a port::
1073
1074   testpmd> rx_vxlan_port add (udp_port) (port_id)
1075
1076rx_vxlan_port remove
1077~~~~~~~~~~~~~~~~~~~~
1078
1079Remove an UDP port for VXLAN packet filter on a port::
1080
1081   testpmd> rx_vxlan_port rm (udp_port) (port_id)
1082
1083tx_vlan set
1084~~~~~~~~~~~
1085
1086Set hardware insertion of VLAN IDs in packets sent on a port::
1087
1088   testpmd> tx_vlan set (port_id) vlan_id[, vlan_id_outer]
1089
1090For example, set a single VLAN ID (5) insertion on port 0::
1091
1092   tx_vlan set 0 5
1093
1094Or, set double VLAN ID (inner: 2, outer: 3) insertion on port 1::
1095
1096   tx_vlan set 1 2 3
1097
1098
1099tx_vlan set pvid
1100~~~~~~~~~~~~~~~~
1101
1102Set port based hardware insertion of VLAN ID in packets sent on a port::
1103
1104   testpmd> tx_vlan set pvid (port_id) (vlan_id) (on|off)
1105
1106tx_vlan reset
1107~~~~~~~~~~~~~
1108
1109Disable hardware insertion of a VLAN header in packets sent on a port::
1110
1111   testpmd> tx_vlan reset (port_id)
1112
1113csum set
1114~~~~~~~~
1115
1116Select hardware or software calculation of the checksum when
1117transmitting a packet using the ``csum`` forwarding engine::
1118
1119   testpmd> csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)
1120
1121Where:
1122
1123* ``ip|udp|tcp|sctp`` always relate to  the inner layer.
1124
1125* ``outer-ip`` relates to the outer IP layer (only for IPv4) in the case where the packet is recognized
1126  as a tunnel packet by the forwarding engine (geneve, gre, gtp, ipip, vxlan and vxlan-gpe are
1127  supported). See also the ``csum parse-tunnel`` command.
1128
1129* ``outer-udp`` relates to the outer UDP layer in the case where the packet is recognized
1130  as a tunnel packet by the forwarding engine (geneve, gtp, vxlan and vxlan-gpe are
1131  supported). See also the ``csum parse-tunnel`` command.
1132
1133.. note::
1134
1135   Check the NIC Datasheet for hardware limits.
1136
1137csum parse-tunnel
1138~~~~~~~~~~~~~~~~~
1139
1140Define how tunneled packets should be handled by the csum forward
1141engine::
1142
1143   testpmd> csum parse-tunnel (on|off) (tx_port_id)
1144
1145If enabled, the csum forward engine will try to recognize supported
1146tunnel headers (geneve, gtp, gre, ipip, vxlan, vxlan-gpe).
1147
1148If disabled, treat tunnel packets as non-tunneled packets (a inner
1149header is handled as a packet payload).
1150
1151.. note::
1152
1153   The port argument is the TX port like in the ``csum set`` command.
1154
1155Example:
1156
1157Consider a packet in packet like the following::
1158
1159   eth_out/ipv4_out/udp_out/vxlan/eth_in/ipv4_in/tcp_in
1160
1161* If parse-tunnel is enabled, the ``ip|udp|tcp|sctp`` parameters of ``csum set``
1162  command relate to the inner headers (here ``ipv4_in`` and ``tcp_in``), and the
1163  ``outer-ip|outer-udp`` parameter relates to the outer headers (here ``ipv4_out`` and ``udp_out``).
1164
1165* If parse-tunnel is disabled, the ``ip|udp|tcp|sctp`` parameters of ``csum  set``
1166   command relate to the outer headers, here ``ipv4_out`` and ``udp_out``.
1167
1168csum show
1169~~~~~~~~~
1170
1171Display tx checksum offload configuration::
1172
1173   testpmd> csum show (port_id)
1174
1175tso set
1176~~~~~~~
1177
1178Enable TCP Segmentation Offload (TSO) in the ``csum`` forwarding engine::
1179
1180   testpmd> tso set (segsize) (port_id)
1181
1182.. note::
1183
1184   Check the NIC datasheet for hardware limits.
1185
1186tso show
1187~~~~~~~~
1188
1189Display the status of TCP Segmentation Offload::
1190
1191   testpmd> tso show (port_id)
1192
1193tunnel tso set
1194~~~~~~~~~~~~~~
1195
1196Set tso segment size of tunneled packets for a port in csum engine::
1197
1198   testpmd> tunnel_tso set (tso_segsz) (port_id)
1199
1200tunnel tso show
1201~~~~~~~~~~~~~~~
1202
1203Display the status of tunneled TCP Segmentation Offload for a port::
1204
1205   testpmd> tunnel_tso show (port_id)
1206
1207set port - gro
1208~~~~~~~~~~~~~~
1209
1210Enable or disable GRO in ``csum`` forwarding engine::
1211
1212   testpmd> set port <port_id> gro on|off
1213
1214If enabled, the csum forwarding engine will perform GRO on the TCP/IPv4
1215packets received from the given port.
1216
1217If disabled, packets received from the given port won't be performed
1218GRO. By default, GRO is disabled for all ports.
1219
1220.. note::
1221
1222   When enable GRO for a port, TCP/IPv4 packets received from the port
1223   will be performed GRO. After GRO, all merged packets have bad
1224   checksums, since the GRO library doesn't re-calculate checksums for
1225   the merged packets. Therefore, if users want the merged packets to
1226   have correct checksums, please select HW IP checksum calculation and
1227   HW TCP checksum calculation for the port which the merged packets are
1228   transmitted to.
1229
1230show port - gro
1231~~~~~~~~~~~~~~~
1232
1233Display GRO configuration for a given port::
1234
1235   testpmd> show port <port_id> gro
1236
1237set gro flush
1238~~~~~~~~~~~~~
1239
1240Set the cycle to flush the GROed packets from reassembly tables::
1241
1242   testpmd> set gro flush <cycles>
1243
1244When enable GRO, the csum forwarding engine performs GRO on received
1245packets, and the GROed packets are stored in reassembly tables. Users
1246can use this command to determine when the GROed packets are flushed
1247from the reassembly tables.
1248
1249The ``cycles`` is measured in GRO operation times. The csum forwarding
1250engine flushes the GROed packets from the tables every ``cycles`` GRO
1251operations.
1252
1253By default, the value of ``cycles`` is 1, which means flush GROed packets
1254from the reassembly tables as soon as one GRO operation finishes. The value
1255of ``cycles`` should be in the range of 1 to ``GRO_MAX_FLUSH_CYCLES``.
1256
1257Please note that the large value of ``cycles`` may cause the poor TCP/IP
1258stack performance. Because the GROed packets are delayed to arrive the
1259stack, thus causing more duplicated ACKs and TCP retransmissions.
1260
1261set port - gso
1262~~~~~~~~~~~~~~
1263
1264Toggle per-port GSO support in ``csum`` forwarding engine::
1265
1266   testpmd> set port <port_id> gso on|off
1267
1268If enabled, the csum forwarding engine will perform GSO on supported IPv4
1269packets, transmitted on the given port.
1270
1271If disabled, packets transmitted on the given port will not undergo GSO.
1272By default, GSO is disabled for all ports.
1273
1274.. note::
1275
1276   When GSO is enabled on a port, supported IPv4 packets transmitted on that
1277   port undergo GSO. Afterwards, the segmented packets are represented by
1278   multi-segment mbufs; however, the csum forwarding engine doesn't calculation
1279   of checksums for GSO'd segments in SW. As a result, if users want correct
1280   checksums in GSO segments, they should enable HW checksum calculation for
1281   GSO-enabled ports.
1282
1283   For example, HW checksum calculation for VxLAN GSO'd packets may be enabled
1284   by setting the following options in the csum forwarding engine:
1285
1286   testpmd> csum set outer_ip hw <port_id>
1287
1288   testpmd> csum set ip hw <port_id>
1289
1290   testpmd> csum set tcp hw <port_id>
1291
1292   UDP GSO is the same as IP fragmentation, which treats the UDP header
1293   as the payload and does not modify it during segmentation. That is,
1294   after UDP GSO, only the first output fragment has the original UDP
1295   header. Therefore, users need to enable HW IP checksum calculation
1296   and SW UDP checksum calculation for GSO-enabled ports, if they want
1297   correct checksums for UDP/IPv4 packets.
1298
1299set gso segsz
1300~~~~~~~~~~~~~
1301
1302Set the maximum GSO segment size (measured in bytes), which includes the
1303packet header and the packet payload for GSO-enabled ports (global)::
1304
1305   testpmd> set gso segsz <length>
1306
1307show port - gso
1308~~~~~~~~~~~~~~~
1309
1310Display the status of Generic Segmentation Offload for a given port::
1311
1312   testpmd> show port <port_id> gso
1313
1314mac_addr add
1315~~~~~~~~~~~~
1316
1317Add an alternative MAC address to a port::
1318
1319   testpmd> mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)
1320
1321mac_addr remove
1322~~~~~~~~~~~~~~~
1323
1324Remove a MAC address from a port::
1325
1326   testpmd> mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)
1327
1328mcast_addr add
1329~~~~~~~~~~~~~~
1330
1331To add the multicast MAC address to/from the set of multicast addresses
1332filtered by port::
1333
1334   testpmd> mcast_addr add (port_id) (mcast_addr)
1335
1336mcast_addr remove
1337~~~~~~~~~~~~~~~~~
1338
1339To remove the multicast MAC address to/from the set of multicast addresses
1340filtered by port::
1341
1342   testpmd> mcast_addr remove (port_id) (mcast_addr)
1343
1344mcast_addr flush
1345~~~~~~~~~~~~~~~~
1346
1347Flush all multicast MAC addresses on port_id::
1348
1349   testpmd> mcast_addr flush (port_id)
1350
1351mac_addr add (for VF)
1352~~~~~~~~~~~~~~~~~~~~~
1353
1354Add an alternative MAC address for a VF to a port::
1355
1356   testpmd> mac_add add port (port_id) vf (vf_id) (XX:XX:XX:XX:XX:XX)
1357
1358mac_addr set
1359~~~~~~~~~~~~
1360
1361Set the default MAC address for a port::
1362
1363   testpmd> mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)
1364
1365mac_addr set (for VF)
1366~~~~~~~~~~~~~~~~~~~~~
1367
1368Set the MAC address for a VF from the PF::
1369
1370   testpmd> set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)
1371
1372set eth-peer
1373~~~~~~~~~~~~
1374
1375Set the forwarding peer address for certain port::
1376
1377   testpmd> set eth-peer (port_id) (peer_addr)
1378
1379This is equivalent to the ``--eth-peer`` command-line option.
1380
1381set port-uta
1382~~~~~~~~~~~~
1383
1384Set the unicast hash filter(s) on/off for a port::
1385
1386   testpmd> set port (port_id) uta (XX:XX:XX:XX:XX:XX|all) (on|off)
1387
1388set promisc
1389~~~~~~~~~~~
1390
1391Set the promiscuous mode on for a port or for all ports.
1392In promiscuous mode packets are not dropped if they aren't for the specified MAC address::
1393
1394   testpmd> set promisc (port_id|all) (on|off)
1395
1396set allmulti
1397~~~~~~~~~~~~
1398
1399Set the allmulti mode for a port or for all ports::
1400
1401   testpmd> set allmulti (port_id|all) (on|off)
1402
1403Same as the ifconfig (8) option. Controls how multicast packets are handled.
1404
1405set flow_ctrl rx
1406~~~~~~~~~~~~~~~~
1407
1408Set the link flow control parameter on a port::
1409
1410   testpmd> set flow_ctrl rx (on|off) tx (on|off) (high_water) (low_water) \
1411            (pause_time) (send_xon) mac_ctrl_frame_fwd (on|off) \
1412	    autoneg (on|off) (port_id)
1413
1414Where:
1415
1416* ``high_water`` (integer): High threshold value to trigger XOFF.
1417
1418* ``low_water`` (integer): Low threshold value to trigger XON.
1419
1420* ``pause_time`` (integer): Pause quota in the Pause frame.
1421
1422* ``send_xon`` (0/1): Send XON frame.
1423
1424* ``mac_ctrl_frame_fwd``: Enable receiving MAC control frames.
1425
1426* ``autoneg``: Change the auto-negotiation parameter.
1427
1428show flow control
1429~~~~~~~~~~~~~~~~~
1430
1431show the link flow control parameter on a port::
1432
1433   testpmd> show port <port_id> flow_ctrl
1434
1435set pfc_ctrl rx
1436~~~~~~~~~~~~~~~
1437
1438Set the priority flow control parameter on a port::
1439
1440   testpmd> set pfc_ctrl rx (on|off) tx (on|off) (high_water) (low_water) \
1441            (pause_time) (priority) (port_id)
1442
1443Where:
1444
1445* ``high_water`` (integer): High threshold value.
1446
1447* ``low_water`` (integer): Low threshold value.
1448
1449* ``pause_time`` (integer): Pause quota in the Pause frame.
1450
1451* ``priority`` (0-7): VLAN User Priority.
1452
1453set pfc_queue_ctrl
1454~~~~~~~~~~~~~~~~~~
1455
1456Set the priority flow control parameter on a given Rx and Tx queue of a port::
1457
1458   testpmd> set pfc_queue_ctrl <port_id> rx (on|off) <tx_qid> <tx_tc> \
1459            tx (on|off) <rx_qid> <rx_tc> <pause_time>
1460
1461Where:
1462
1463* ``tx_qid`` (integer): Tx qid for which ``tx_tc`` will be applied and traffic
1464  will be paused when PFC frame is received with ``tx_tc`` enabled.
1465
1466* ``tx_tc`` (0-15): TC for which traffic is to be paused for xmit.
1467
1468* ``rx_qid`` (integer): Rx qid for which threshold will be applied and PFC
1469  frame will be generated with ``tx_tc`` when exceeds the threshold.
1470
1471* ``rx_tc`` (0-15): TC filled in PFC frame for which remote Tx is to be paused.
1472
1473* ``pause_time`` (integer): Pause quanta filled in the PFC frame for which
1474  interval, remote Tx will be paused. Valid only if Tx pause is on.
1475
1476Set Rx queue available descriptors threshold
1477~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1478
1479Set available descriptors threshold for a specific Rx queue of port::
1480
1481  testpmd> set port (port_id) rxq (queue_id) avail_thresh (0..99)
1482
1483Use 0 value to disable the threshold and corresponding event.
1484
1485set stat_qmap
1486~~~~~~~~~~~~~
1487
1488Set statistics mapping (qmapping 0..15) for RX/TX queue on port::
1489
1490   testpmd> set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)
1491
1492For example, to set rx queue 2 on port 0 to mapping 5::
1493
1494   testpmd>set stat_qmap rx 0 2 5
1495
1496set xstats-hide-zero
1497~~~~~~~~~~~~~~~~~~~~
1498
1499Set the option to hide zero values for xstats display::
1500
1501	testpmd> set xstats-hide-zero on|off
1502
1503.. note::
1504
1505	By default, the zero values are displayed for xstats.
1506
1507set port - rx/tx (for VF)
1508~~~~~~~~~~~~~~~~~~~~~~~~~
1509
1510Set VF receive/transmit from a port::
1511
1512   testpmd> set port (port_id) vf (vf_id) (rx|tx) (on|off)
1513
1514set port - rx mode(for VF)
1515~~~~~~~~~~~~~~~~~~~~~~~~~~
1516
1517Set the VF receive mode of a port::
1518
1519   testpmd> set port (port_id) vf (vf_id) \
1520            rxmode (AUPE|ROPE|BAM|MPE) (on|off)
1521
1522The available receive modes are:
1523
1524* ``AUPE``: Accepts untagged VLAN.
1525
1526* ``ROPE``: Accepts unicast hash.
1527
1528* ``BAM``: Accepts broadcast packets.
1529
1530* ``MPE``: Accepts all multicast packets.
1531
1532set port - tx_rate (for Queue)
1533~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1534
1535Set TX rate limitation for a queue on a port::
1536
1537   testpmd> set port (port_id) queue (queue_id) rate (rate_value)
1538
1539set port - tx_rate (for VF)
1540~~~~~~~~~~~~~~~~~~~~~~~~~~~
1541
1542Set TX rate limitation for queues in VF on a port::
1543
1544   testpmd> set port (port_id) vf (vf_id) rate (rate_value) queue_mask (queue_mask)
1545
1546set flush_rx
1547~~~~~~~~~~~~
1548
1549Set the flush on RX streams before forwarding.
1550The default is flush ``on``.
1551Mainly used with PCAP drivers to turn off the default behavior of flushing the first 512 packets on RX streams::
1552
1553   testpmd> set flush_rx off
1554
1555set link up
1556~~~~~~~~~~~
1557
1558Set link up for a port::
1559
1560   testpmd> set link-up port (port id)
1561
1562set link down
1563~~~~~~~~~~~~~
1564
1565Set link down for a port::
1566
1567   testpmd> set link-down port (port id)
1568
1569E-tag set
1570~~~~~~~~~
1571
1572Enable E-tag insertion for a VF on a port::
1573
1574   testpmd> E-tag set insertion on port-tag-id (value) port (port_id) vf (vf_id)
1575
1576Disable E-tag insertion for a VF on a port::
1577
1578   testpmd> E-tag set insertion off port (port_id) vf (vf_id)
1579
1580Enable/disable E-tag stripping on a port::
1581
1582   testpmd> E-tag set stripping (on|off) port (port_id)
1583
1584Enable/disable E-tag based forwarding on a port::
1585
1586   testpmd> E-tag set forwarding (on|off) port (port_id)
1587
1588config per port Rx offloading
1589~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1590
1591Enable or disable port Rx offloading on all Rx queues of a port::
1592
1593   testpmd> port config (port_id|all) rx_offload (offloading) on|off
1594
1595* ``offloading``: can be any of these offloading capability:
1596                  all, vlan_strip, ipv4_cksum, udp_cksum, tcp_cksum, tcp_lro,
1597                  qinq_strip, outer_ipv4_cksum, macsec_strip,
1598                  vlan_filter, vlan_extend, scatter, timestamp, security,
1599                  keep_crc, rss_hash
1600
1601This command should be run when the port is stopped, or else it will fail.
1602
1603config per queue Rx offloading
1604~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1605
1606Enable or disable a per queue Rx offloading only on a specific Rx queue::
1607
1608   testpmd> port (port_id) rxq (queue_id) rx_offload (offloading) on|off
1609
1610* ``offloading``: can be any of these offloading capability:
1611                  all, vlan_strip, ipv4_cksum, udp_cksum, tcp_cksum, tcp_lro,
1612                  qinq_strip, outer_ipv4_cksum, macsec_strip,
1613                  vlan_filter, vlan_extend, scatter, timestamp, security,
1614                  keep_crc
1615
1616This command should be run when the port is stopped, or else it will fail.
1617
1618config per port Tx offloading
1619~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1620
1621Enable or disable port Tx offloading on all Tx queues of a port::
1622
1623   testpmd> port config (port_id|all) tx_offload (offloading) on|off
1624
1625* ``offloading``: can be any of these offloading capability:
1626                  all, vlan_insert, ipv4_cksum, udp_cksum, tcp_cksum,
1627                  sctp_cksum, tcp_tso, udp_tso, outer_ipv4_cksum,
1628                  qinq_insert, vxlan_tnl_tso, gre_tnl_tso,
1629                  ipip_tnl_tso, geneve_tnl_tso, macsec_insert,
1630                  mt_lockfree, multi_segs, mbuf_fast_free, security
1631
1632This command should be run when the port is stopped, or else it will fail.
1633
1634config per queue Tx offloading
1635~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1636
1637Enable or disable a per queue Tx offloading only on a specific Tx queue::
1638
1639   testpmd> port (port_id) txq (queue_id) tx_offload (offloading) on|off
1640
1641* ``offloading``: can be any of these offloading capability:
1642                  all, vlan_insert, ipv4_cksum, udp_cksum, tcp_cksum,
1643                  sctp_cksum, tcp_tso, udp_tso, outer_ipv4_cksum,
1644                  qinq_insert, vxlan_tnl_tso, gre_tnl_tso,
1645                  ipip_tnl_tso, geneve_tnl_tso, macsec_insert,
1646                  mt_lockfree, multi_segs, mbuf_fast_free, security
1647
1648This command should be run when the port is stopped, or else it will fail.
1649
1650config per queue Tx affinity mapping
1651~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1652
1653Map a Tx queue with an aggregated port of the DPDK port (specified with port_id)::
1654
1655   testpmd> port (port_id) txq (queue_id) affinity (value)
1656
1657* ``affinity``: the number of the aggregated port.
1658                When multiple ports are aggregated into a single one,
1659                it allows to choose which port to use for Tx via a queue.
1660
1661This command should be run when the port is stopped, otherwise it fails.
1662
1663
1664Config VXLAN Encap outer layers
1665~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1666
1667Configure the outer layer to encapsulate a packet inside a VXLAN tunnel::
1668
1669 set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src (udp-src) \
1670 udp-dst (udp-dst) ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src) \
1671 eth-dst (eth-dst)
1672
1673 set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni) udp-src (udp-src) \
1674 udp-dst (udp-dst) ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci) \
1675 eth-src (eth-src) eth-dst (eth-dst)
1676
1677 set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src (udp-src) \
1678 udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl) ip-src (ip-src) \
1679 ip-dst (ip-dst) eth-src (eth-src) eth-dst (eth-dst)
1680
1681These commands will set an internal configuration inside testpmd, any following
1682flow rule using the action vxlan_encap will use the last configuration set.
1683To have a different encapsulation header, one of those commands must be called
1684before the flow rule creation.
1685
1686Config NVGRE Encap outer layers
1687~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1688
1689Configure the outer layer to encapsulate a packet inside a NVGRE tunnel::
1690
1691 set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src (ip-src) ip-dst (ip-dst) \
1692        eth-src (eth-src) eth-dst (eth-dst)
1693 set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni) ip-src (ip-src) \
1694        ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src) eth-dst (eth-dst)
1695
1696These commands will set an internal configuration inside testpmd, any following
1697flow rule using the action nvgre_encap will use the last configuration set.
1698To have a different encapsulation header, one of those commands must be called
1699before the flow rule creation.
1700
1701Config L2 Encap
1702~~~~~~~~~~~~~~~
1703
1704Configure the l2 to be used when encapsulating a packet with L2::
1705
1706 set l2_encap ip-version (ipv4|ipv6) eth-src (eth-src) eth-dst (eth-dst)
1707 set l2_encap-with-vlan ip-version (ipv4|ipv6) vlan-tci (vlan-tci) \
1708        eth-src (eth-src) eth-dst (eth-dst)
1709
1710Those commands will set an internal configuration inside testpmd, any following
1711flow rule using the action l2_encap will use the last configuration set.
1712To have a different encapsulation header, one of those commands must be called
1713before the flow rule creation.
1714
1715Config L2 Decap
1716~~~~~~~~~~~~~~~
1717
1718Configure the l2 to be removed when decapsulating a packet with L2::
1719
1720 set l2_decap ip-version (ipv4|ipv6)
1721 set l2_decap-with-vlan ip-version (ipv4|ipv6)
1722
1723Those commands will set an internal configuration inside testpmd, any following
1724flow rule using the action l2_decap will use the last configuration set.
1725To have a different encapsulation header, one of those commands must be called
1726before the flow rule creation.
1727
1728Config MPLSoGRE Encap outer layers
1729~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1730
1731Configure the outer layer to encapsulate a packet inside a MPLSoGRE tunnel::
1732
1733 set mplsogre_encap ip-version (ipv4|ipv6) label (label) \
1734        ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst (eth-dst)
1735 set mplsogre_encap-with-vlan ip-version (ipv4|ipv6) label (label) \
1736        ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci) \
1737        eth-src (eth-src) eth-dst (eth-dst)
1738
1739These commands will set an internal configuration inside testpmd, any following
1740flow rule using the action mplsogre_encap will use the last configuration set.
1741To have a different encapsulation header, one of those commands must be called
1742before the flow rule creation.
1743
1744Config MPLSoGRE Decap outer layers
1745~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1746
1747Configure the outer layer to decapsulate MPLSoGRE packet::
1748
1749 set mplsogre_decap ip-version (ipv4|ipv6)
1750 set mplsogre_decap-with-vlan ip-version (ipv4|ipv6)
1751
1752These commands will set an internal configuration inside testpmd, any following
1753flow rule using the action mplsogre_decap will use the last configuration set.
1754To have a different decapsulation header, one of those commands must be called
1755before the flow rule creation.
1756
1757Config MPLSoUDP Encap outer layers
1758~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1759
1760Configure the outer layer to encapsulate a packet inside a MPLSoUDP tunnel::
1761
1762 set mplsoudp_encap ip-version (ipv4|ipv6) label (label) udp-src (udp-src) \
1763        udp-dst (udp-dst) ip-src (ip-src) ip-dst (ip-dst) \
1764        eth-src (eth-src) eth-dst (eth-dst)
1765 set mplsoudp_encap-with-vlan ip-version (ipv4|ipv6) label (label) \
1766        udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst (ip-dst) \
1767        vlan-tci (vlan-tci) eth-src (eth-src) eth-dst (eth-dst)
1768
1769These commands will set an internal configuration inside testpmd, any following
1770flow rule using the action mplsoudp_encap will use the last configuration set.
1771To have a different encapsulation header, one of those commands must be called
1772before the flow rule creation.
1773
1774Config MPLSoUDP Decap outer layers
1775~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1776
1777Configure the outer layer to decapsulate MPLSoUDP packet::
1778
1779 set mplsoudp_decap ip-version (ipv4|ipv6)
1780 set mplsoudp_decap-with-vlan ip-version (ipv4|ipv6)
1781
1782These commands will set an internal configuration inside testpmd, any following
1783flow rule using the action mplsoudp_decap will use the last configuration set.
1784To have a different decapsulation header, one of those commands must be called
1785before the flow rule creation.
1786
1787Config Raw Encapsulation
1788~~~~~~~~~~~~~~~~~~~~~~~~~
1789
1790Configure the raw data to be used when encapsulating a packet by
1791rte_flow_action_raw_encap::
1792
1793 set raw_encap {index} {item} [/ {item} [...]] / end_set
1794
1795There are multiple global buffers for ``raw_encap``, this command will set one
1796internal buffer index by ``{index}``.
1797If there is no ``{index}`` specified::
1798
1799 set raw_encap {item} [/ {item} [...]] / end_set
1800
1801the default index ``0`` is used.
1802In order to use different encapsulating header, ``index`` must be specified
1803during the flow rule creation::
1804
1805 testpmd> flow create 0 egress pattern eth / ipv4 / end actions
1806        raw_encap index 2 / end
1807
1808Otherwise the default index ``0`` is used.
1809
1810Config Raw Decapsulation
1811~~~~~~~~~~~~~~~~~~~~~~~~
1812
1813Configure the raw data to be used when decapsulating a packet by
1814rte_flow_action_raw_decap::
1815
1816 set raw_decap {index} {item} [/ {item} [...]] / end_set
1817
1818There are multiple global buffers for ``raw_decap``, this command will set
1819one internal buffer index by ``{index}``.
1820If there is no ``{index}`` specified::
1821
1822 set raw_decap {item} [/ {item} [...]] / end_set
1823
1824the default index ``0`` is used.
1825In order to use different decapsulating header, ``index`` must be specified
1826during the flow rule creation::
1827
1828 testpmd> flow create 0 egress pattern eth / ipv4 / end actions
1829          raw_encap index 3 / end
1830
1831Otherwise the default index ``0`` is used.
1832
1833Set fec mode
1834~~~~~~~~~~~~
1835
1836Set fec mode for a specific port::
1837
1838  testpmd> set port (port_id) fec_mode auto|off|rs|baser|llrs
1839
1840Config Sample actions list
1841~~~~~~~~~~~~~~~~~~~~~~~~~~
1842
1843Configure the sample actions list to be used when sampling a packet by
1844rte_flow_action_sample::
1845
1846 set sample_actions {index} {action} [/ {action} [...]] / end
1847
1848There are multiple global buffers for ``sample_actions``, this command will set
1849one internal buffer index by ``{index}``.
1850
1851In order to use different sample actions list, ``index`` must be specified
1852during the flow rule creation::
1853
1854 testpmd> flow create 0 ingress pattern eth / ipv4 / end actions
1855        sample ratio 2 index 2 / end
1856
1857Otherwise the default index ``0`` is used.
1858
1859set port led
1860~~~~~~~~~~~~
1861
1862Set a controllable LED associated with a certain port on or off::
1863
1864   testpmd> set port (port_id) led (on|off)
1865
1866Port Functions
1867--------------
1868
1869The following sections show functions for configuring ports.
1870
1871.. note::
1872
1873   Port configuration changes only become active when forwarding is started/restarted.
1874
1875.. _port_attach:
1876
1877port attach
1878~~~~~~~~~~~
1879
1880Attach a port specified by pci address or virtual device args::
1881
1882   testpmd> port attach (identifier)
1883
1884To attach a new pci device, the device should be recognized by kernel first.
1885Then it should be moved under DPDK management.
1886Finally the port can be attached to testpmd.
1887
1888For example, to move a pci device using ixgbe under DPDK management:
1889
1890.. code-block:: console
1891
1892   # Check the status of the available devices.
1893   ./usertools/dpdk-devbind.py --status
1894
1895   Network devices using DPDK-compatible driver
1896   ============================================
1897   <none>
1898
1899   Network devices using kernel driver
1900   ===================================
1901   0000:0a:00.0 '82599ES 10-Gigabit' if=eth2 drv=ixgbe unused=
1902
1903
1904   # Bind the device to igb_uio.
1905   sudo ./usertools/dpdk-devbind.py -b igb_uio 0000:0a:00.0
1906
1907
1908   # Recheck the status of the devices.
1909   ./usertools/dpdk-devbind.py --status
1910   Network devices using DPDK-compatible driver
1911   ============================================
1912   0000:0a:00.0 '82599ES 10-Gigabit' drv=igb_uio unused=
1913
1914To attach a port created by virtual device, above steps are not needed.
1915
1916For example, to attach a port whose pci address is 0000:0a:00.0.
1917
1918.. code-block:: console
1919
1920   testpmd> port attach 0000:0a:00.0
1921   Attaching a new port...
1922   EAL: PCI device 0000:0a:00.0 on NUMA socket -1
1923   EAL:   probe driver: 8086:10fb rte_ixgbe_pmd
1924   EAL:   PCI memory mapped at 0x7f83bfa00000
1925   EAL:   PCI memory mapped at 0x7f83bfa80000
1926   PMD: eth_ixgbe_dev_init(): MAC: 2, PHY: 18, SFP+: 5
1927   PMD: eth_ixgbe_dev_init(): port 0 vendorID=0x8086 deviceID=0x10fb
1928   Port 0 is attached. Now total ports is 1
1929   Done
1930
1931For example, to attach a port created by pcap PMD.
1932
1933.. code-block:: console
1934
1935   testpmd> port attach net_pcap0
1936   Attaching a new port...
1937   PMD: Initializing pmd_pcap for net_pcap0
1938   PMD: Creating pcap-backed ethdev on numa socket 0
1939   Port 0 is attached. Now total ports is 1
1940   Done
1941
1942In this case, identifier is ``net_pcap0``.
1943This identifier format is the same as ``--vdev`` format of DPDK applications.
1944
1945For example, to re-attach a bonding port which has been previously detached,
1946the mode and slave parameters must be given.
1947
1948.. code-block:: console
1949
1950   testpmd> port attach net_bond_0,mode=0,slave=1
1951   Attaching a new port...
1952   EAL: Initializing pmd_bond for net_bond_0
1953   EAL: Create bonding device net_bond_0 on port 0 in mode 0 on socket 0.
1954   Port 0 is attached. Now total ports is 1
1955   Done
1956
1957
1958port detach
1959~~~~~~~~~~~
1960
1961Detach a specific port::
1962
1963   testpmd> port detach (port_id)
1964
1965Before detaching a port, the port should be stopped and closed.
1966
1967For example, to detach a pci device port 0.
1968
1969.. code-block:: console
1970
1971   testpmd> port stop 0
1972   Stopping ports...
1973   Done
1974   testpmd> port close 0
1975   Closing ports...
1976   Done
1977
1978   testpmd> port detach 0
1979   Detaching a port...
1980   EAL: PCI device 0000:0a:00.0 on NUMA socket -1
1981   EAL:   remove driver: 8086:10fb rte_ixgbe_pmd
1982   EAL:   PCI memory unmapped at 0x7f83bfa00000
1983   EAL:   PCI memory unmapped at 0x7f83bfa80000
1984   Done
1985
1986
1987For example, to detach a virtual device port 0.
1988
1989.. code-block:: console
1990
1991   testpmd> port stop 0
1992   Stopping ports...
1993   Done
1994   testpmd> port close 0
1995   Closing ports...
1996   Done
1997
1998   testpmd> port detach 0
1999   Detaching a port...
2000   PMD: Closing pcap ethdev on numa socket 0
2001   Port 'net_pcap0' is detached. Now total ports is 0
2002   Done
2003
2004To remove a pci device completely from the system, first detach the port from testpmd.
2005Then the device should be moved under kernel management.
2006Finally the device can be removed using kernel pci hotplug functionality.
2007
2008For example, to move a pci device under kernel management:
2009
2010.. code-block:: console
2011
2012   sudo ./usertools/dpdk-devbind.py -b ixgbe 0000:0a:00.0
2013
2014   ./usertools/dpdk-devbind.py --status
2015
2016   Network devices using DPDK-compatible driver
2017   ============================================
2018   <none>
2019
2020   Network devices using kernel driver
2021   ===================================
2022   0000:0a:00.0 '82599ES 10-Gigabit' if=eth2 drv=ixgbe unused=igb_uio
2023
2024To remove a port created by a virtual device, above steps are not needed.
2025
2026port start
2027~~~~~~~~~~
2028
2029Start all ports or a specific port::
2030
2031   testpmd> port start (port_id|all)
2032
2033port stop
2034~~~~~~~~~
2035
2036Stop all ports or a specific port::
2037
2038   testpmd> port stop (port_id|all)
2039
2040port close
2041~~~~~~~~~~
2042
2043Close all ports or a specific port::
2044
2045   testpmd> port close (port_id|all)
2046
2047port reset
2048~~~~~~~~~~
2049
2050Reset all ports or a specific port::
2051
2052   testpmd> port reset (port_id|all)
2053
2054User should stop port(s) before resetting and (re-)start after reset.
2055
2056port config - queue ring size
2057~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2058
2059Configure a rx/tx queue ring size::
2060
2061   testpmd> port config (port_id) (rxq|txq) (queue_id) ring_size (value)
2062
2063Only take effect after command that (re-)start the port or command that setup specific queue.
2064
2065port start/stop queue
2066~~~~~~~~~~~~~~~~~~~~~
2067
2068Start/stop a rx/tx queue on a specific port::
2069
2070   testpmd> port (port_id) (rxq|txq) (queue_id) (start|stop)
2071
2072port config - queue deferred start
2073~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2074
2075Switch on/off deferred start of a specific port queue::
2076
2077   testpmd> port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)
2078
2079port setup queue
2080~~~~~~~~~~~~~~~~~~~~~
2081
2082Setup a rx/tx queue on a specific port::
2083
2084   testpmd> port (port_id) (rxq|txq) (queue_id) setup
2085
2086Only take effect when port is started.
2087
2088port config - speed
2089~~~~~~~~~~~~~~~~~~~
2090
2091Set the speed and duplex mode for all ports or a specific port::
2092
2093   testpmd> port config (port_id|all) speed (10|100|1000|2500|5000|10000|25000|40000|50000|100000|200000|400000|auto) \
2094            duplex (half|full|auto)
2095
2096port config - queues/descriptors
2097~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2098
2099Set number of queues/descriptors for rxq, txq, rxd and txd::
2100
2101   testpmd> port config all (rxq|txq|rxd|txd) (value)
2102
2103This is equivalent to the ``--rxq``, ``--txq``, ``--rxd`` and ``--txd`` command-line options.
2104
2105port config - max-pkt-len
2106~~~~~~~~~~~~~~~~~~~~~~~~~
2107
2108Set the maximum packet length::
2109
2110   testpmd> port config all max-pkt-len (value)
2111
2112This is equivalent to the ``--max-pkt-len`` command-line option.
2113
2114port config - max-lro-pkt-size
2115~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2116
2117Set the maximum LRO aggregated packet size::
2118
2119   testpmd> port config all max-lro-pkt-size (value)
2120
2121This is equivalent to the ``--max-lro-pkt-size`` command-line option.
2122
2123port config - Drop Packets
2124~~~~~~~~~~~~~~~~~~~~~~~~~~
2125
2126Enable or disable packet drop on all RX queues of all ports when no receive buffers available::
2127
2128   testpmd> port config all drop-en (on|off)
2129
2130Packet dropping when no receive buffers available is off by default.
2131
2132The ``on`` option is equivalent to the ``--enable-drop-en`` command-line option.
2133
2134port config - RSS
2135~~~~~~~~~~~~~~~~~
2136
2137Set the RSS (Receive Side Scaling) mode on or off::
2138   testpmd> port config all rss (all|default|level-default|level-outer|level-inner| \
2139                                 ip|tcp|udp|sctp|tunnel|vlan|none| \
2140                                 ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other| \
2141                                 ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp| \
2142                                 ipv6-other|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|ipv6-flow-label| \
2143                                 l2-payload|port|vxlan|geneve|nvgre|gtpu|eth|s-vlan|c-vlan| \
2144                                 esp|ah|l2tpv3|pfcp|pppoe|ecpri|mpls|ipv4-chksum|l4-chksum| \
2145                                 l2tpv2|l3-pre96|l3-pre64|l3-pre56|l3-pre48|l3-pre40|l3-pre32| \
2146                                 l2-dst-only|l2-src-only|l4-dst-only|l4-src-only|l3-dst-only|l3-src-only|<rsstype_id>)
2147
2148RSS is on by default.
2149
2150The ``all`` option is equivalent to eth|vlan|ip|tcp|udp|sctp|ether|l2tpv3|esp|ah|pfcp|l2tpv2.
2151
2152The ``default`` option enables all supported RSS types reported by device info.
2153
2154The ``none`` option is equivalent to the ``--disable-rss`` command-line option.
2155
2156port config - RSS Reta
2157~~~~~~~~~~~~~~~~~~~~~~
2158
2159Set the RSS (Receive Side Scaling) redirection table::
2160
2161   testpmd> port config all rss reta (hash,queue)[,(hash,queue)]
2162
2163port config - DCB
2164~~~~~~~~~~~~~~~~~
2165
2166Set the DCB mode for an individual port::
2167
2168   testpmd> port config (port_id) dcb vt (on|off) (traffic_class) pfc (on|off)
2169
2170The traffic class should be 4 or 8.
2171
2172port config - Burst
2173~~~~~~~~~~~~~~~~~~~
2174
2175Set the number of packets per burst::
2176
2177   testpmd> port config all burst (value)
2178
2179This is equivalent to the ``--burst`` command-line option.
2180
2181port config - Threshold
2182~~~~~~~~~~~~~~~~~~~~~~~
2183
2184Set thresholds for TX/RX queues::
2185
2186   testpmd> port config all (threshold) (value)
2187
2188Where the threshold type can be:
2189
2190* ``txpt:`` Set the prefetch threshold register of the TX rings, 0 <= value <= 255.
2191
2192* ``txht:`` Set the host threshold register of the TX rings, 0 <= value <= 255.
2193
2194* ``txwt:`` Set the write-back threshold register of the TX rings, 0 <= value <= 255.
2195
2196* ``rxpt:`` Set the prefetch threshold register of the RX rings, 0 <= value <= 255.
2197
2198* ``rxht:`` Set the host threshold register of the RX rings, 0 <= value <= 255.
2199
2200* ``rxwt:`` Set the write-back threshold register of the RX rings, 0 <= value <= 255.
2201
2202* ``txfreet:`` Set the transmit free threshold of the TX rings, 0 <= value <= txd.
2203
2204* ``rxfreet:`` Set the transmit free threshold of the RX rings, 0 <= value <= rxd.
2205
2206* ``txrst:`` Set the transmit RS bit threshold of TX rings, 0 <= value <= txd.
2207
2208These threshold options are also available from the command-line.
2209
2210port config pctype mapping
2211~~~~~~~~~~~~~~~~~~~~~~~~~~
2212
2213Reset pctype mapping table::
2214
2215   testpmd> port config (port_id) pctype mapping reset
2216
2217Update hardware defined pctype to software defined flow type mapping table::
2218
2219   testpmd> port config (port_id) pctype mapping update (pctype_id_0[,pctype_id_1]*) (flow_type_id)
2220
2221where:
2222
2223* ``pctype_id_x``: hardware pctype id as index of bit in bitmask value of the pctype mapping table.
2224
2225* ``flow_type_id``: software flow type id as the index of the pctype mapping table.
2226
2227port config input set
2228~~~~~~~~~~~~~~~~~~~~~
2229
2230Config RSS/FDIR/FDIR flexible payload input set for some pctype::
2231
2232   testpmd> port config (port_id) pctype (pctype_id) \
2233            (hash_inset|fdir_inset|fdir_flx_inset) \
2234	    (get|set|clear) field (field_idx)
2235
2236Clear RSS/FDIR/FDIR flexible payload input set for some pctype::
2237
2238   testpmd> port config (port_id) pctype (pctype_id) \
2239            (hash_inset|fdir_inset|fdir_flx_inset) clear all
2240
2241where:
2242
2243* ``pctype_id``: hardware packet classification types.
2244* ``field_idx``: hardware field index.
2245
2246port config udp_tunnel_port
2247~~~~~~~~~~~~~~~~~~~~~~~~~~~
2248
2249Add/remove UDP tunnel port for VXLAN/GENEVE tunneling protocols::
2250
2251    testpmd> port config (port_id) udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe|ecpri (udp_port)
2252
2253port config tx_metadata
2254~~~~~~~~~~~~~~~~~~~~~~~
2255
2256Set Tx metadata value per port.
2257testpmd will add this value to any Tx packet sent from this port::
2258
2259   testpmd> port config (port_id) tx_metadata (value)
2260
2261port config dynf
2262~~~~~~~~~~~~~~~~
2263
2264Set/clear dynamic flag per port.
2265testpmd will register this flag in the mbuf (same registration
2266for both Tx and Rx). Then set/clear this flag for each Tx
2267packet sent from this port. The set bit only works for Tx packet::
2268
2269   testpmd> port config (port_id) dynf (name) (set|clear)
2270
2271port config mtu
2272~~~~~~~~~~~~~~~
2273
2274To configure MTU(Maximum Transmission Unit) on devices using testpmd::
2275
2276   testpmd> port config mtu (port_id) (value)
2277
2278port config rss hash key
2279~~~~~~~~~~~~~~~~~~~~~~~~
2280
2281To configure the RSS hash key used to compute the RSS
2282hash of input [IP] packets received on port::
2283
2284   testpmd> port config <port_id> rss-hash-key (ipv4|ipv4-frag|\
2285                     ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|\
2286                     ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|\
2287                     ipv6-other|l2-payload|ipv6-ex|ipv6-tcp-ex|\
2288                     ipv6-udp-ex <string of hex digits \
2289                     (variable length, NIC dependent)>)
2290
2291port config rss hash algorithm
2292~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2293
2294To configure the RSS hash algorithm used to compute the RSS
2295hash of input packets received on port::
2296
2297   testpmd> port config <port_id> rss-hash-algo (default|\
2298                     simple_xor|toeplitz|symmetric_toeplitz|\
2299                     symmetric_toeplitz_sort)
2300
2301port cleanup txq mbufs
2302~~~~~~~~~~~~~~~~~~~~~~
2303
2304To cleanup txq mbufs currently cached by driver::
2305
2306   testpmd> port cleanup (port_id) txq (queue_id) (free_cnt)
2307
2308If the value of ``free_cnt`` is 0, driver should free all cached mbufs.
2309
2310Device Functions
2311----------------
2312
2313The following sections show functions for device operations.
2314
2315device detach
2316~~~~~~~~~~~~~
2317
2318Detach a device specified by pci address or virtual device args::
2319
2320   testpmd> device detach (identifier)
2321
2322Before detaching a device associated with ports, the ports should be stopped and closed.
2323
2324For example, to detach a pci device whose address is 0002:03:00.0.
2325
2326.. code-block:: console
2327
2328    testpmd> device detach 0002:03:00.0
2329    Removing a device...
2330    Port 1 is now closed
2331    EAL: Releasing pci mapped resource for 0002:03:00.0
2332    EAL: Calling pci_unmap_resource for 0002:03:00.0 at 0x218a050000
2333    EAL: Calling pci_unmap_resource for 0002:03:00.0 at 0x218c050000
2334    Device 0002:03:00.0 is detached
2335    Now total ports is 1
2336
2337For example, to detach a port created by pcap PMD.
2338
2339.. code-block:: console
2340
2341    testpmd> device detach net_pcap0
2342    Removing a device...
2343    Port 0 is now closed
2344    Device net_pcap0 is detached
2345    Now total ports is 0
2346    Done
2347
2348In this case, identifier is ``net_pcap0``.
2349This identifier format is the same as ``--vdev`` format of DPDK applications.
2350
2351Link Bonding Functions
2352----------------------
2353
2354The Link Bonding functions make it possible to dynamically create and
2355manage link bonding devices from within testpmd interactive prompt.
2356
2357See :doc:`../prog_guide/link_bonding_poll_mode_drv_lib` for more information.
2358
2359Traffic Metering and Policing
2360-----------------------------
2361
2362The following section shows functions for configuring traffic metering and
2363policing on the ethernet device through the use of generic ethdev API.
2364
2365show port traffic management capability
2366~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2367
2368Show traffic metering and policing capability of the port::
2369
2370   testpmd> show port meter cap (port_id)
2371
2372add port meter profile (srTCM rfc2967)
2373~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2374
2375Add meter profile (srTCM rfc2697) to the ethernet device::
2376
2377   testpmd> add port meter profile srtcm_rfc2697 (port_id) (profile_id) \
2378   (cir) (cbs) (ebs) (packet_mode)
2379
2380where:
2381
2382* ``profile_id``: ID for the meter profile.
2383* ``cir``: Committed Information Rate (CIR) (bytes per second or packets per second).
2384* ``cbs``: Committed Burst Size (CBS) (bytes or packets).
2385* ``ebs``: Excess Burst Size (EBS) (bytes or packets).
2386* ``packet_mode``: Packets mode for meter profile.
2387
2388add port meter profile (trTCM rfc2968)
2389~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2390
2391Add meter profile (srTCM rfc2698) to the ethernet device::
2392
2393   testpmd> add port meter profile trtcm_rfc2698 (port_id) (profile_id) \
2394   (cir) (pir) (cbs) (pbs) (packet_mode)
2395
2396where:
2397
2398* ``profile_id``: ID for the meter profile.
2399* ``cir``: Committed information rate (bytes per second or packets per second).
2400* ``pir``: Peak information rate (bytes per second or packets per second).
2401* ``cbs``: Committed burst size (bytes or packets).
2402* ``pbs``: Peak burst size (bytes or packets).
2403* ``packet_mode``: Packets mode for meter profile.
2404
2405add port meter profile (trTCM rfc4115)
2406~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2407
2408Add meter profile (trTCM rfc4115) to the ethernet device::
2409
2410   testpmd> add port meter profile trtcm_rfc4115 (port_id) (profile_id) \
2411   (cir) (eir) (cbs) (ebs) (packet_mode)
2412
2413where:
2414
2415* ``profile_id``: ID for the meter profile.
2416* ``cir``: Committed information rate (bytes per second or packets per second).
2417* ``eir``: Excess information rate (bytes per second or packets per second).
2418* ``cbs``: Committed burst size (bytes or packets).
2419* ``ebs``: Excess burst size (bytes or packets).
2420* ``packet_mode``: Packets mode for meter profile.
2421
2422delete port meter profile
2423~~~~~~~~~~~~~~~~~~~~~~~~~
2424
2425Delete meter profile from the ethernet device::
2426
2427   testpmd> del port meter profile (port_id) (profile_id)
2428
2429create port policy
2430~~~~~~~~~~~~~~~~~~
2431
2432Create new policy object for the ethernet device::
2433
2434   testpmd> add port meter policy (port_id) (policy_id) g_actions \
2435   {action} y_actions {action} r_actions {action}
2436
2437where:
2438
2439* ``policy_id``: policy ID.
2440* ``action``: action lists for green/yellow/red colors.
2441
2442delete port policy
2443~~~~~~~~~~~~~~~~~~
2444
2445Delete policy object for the ethernet device::
2446
2447   testpmd> del port meter policy (port_id) (policy_id)
2448
2449where:
2450
2451* ``policy_id``: policy ID.
2452
2453create port meter
2454~~~~~~~~~~~~~~~~~
2455
2456Create new meter object for the ethernet device::
2457
2458   testpmd> create port meter (port_id) (mtr_id) (profile_id) \
2459   (policy_id) (meter_enable) (stats_mask) (shared) (default_input_color) \
2460   (use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\
2461   (dscp_tbl_entry63)] [(vlan_tbl_entry0) (vlan_tbl_entry1) ... \
2462   (vlan_tbl_entry15)]
2463
2464where:
2465
2466* ``mtr_id``: meter object ID.
2467* ``profile_id``: ID for the meter profile.
2468* ``policy_id``: ID for the policy.
2469* ``meter_enable``: When this parameter has a non-zero value, the meter object
2470  gets enabled at the time of creation, otherwise remains disabled.
2471* ``stats_mask``: Mask of statistics counter types to be enabled for the
2472  meter object.
2473* ``shared``:  When this parameter has a non-zero value, the meter object is
2474  shared by multiple flows. Otherwise, meter object is used by single flow.
2475* ``default_input_color``:  Default input color for incoming packets.
2476  If incoming packet misses DSCP or VLAN input color table then it will be used
2477  as input color.
2478* ``use_pre_meter_color``: When this parameter has a non-zero value, the
2479  input color for the current meter object is determined by the latest meter
2480  object in the same flow. Otherwise, the current meter object uses the
2481  *dscp_table* to determine the input color.
2482* ``dscp_tbl_entryx``: DSCP table entry x providing meter providing input
2483  color, 0 <= x <= 63.
2484* ``vlan_tbl_entryx``: VLAN table entry x providing meter input color,
2485  0 <= x <= 15.
2486
2487enable port meter
2488~~~~~~~~~~~~~~~~~
2489
2490Enable meter for the ethernet device::
2491
2492   testpmd> enable port meter (port_id) (mtr_id)
2493
2494disable port meter
2495~~~~~~~~~~~~~~~~~~
2496
2497Disable meter for the ethernet device::
2498
2499   testpmd> disable port meter (port_id) (mtr_id)
2500
2501delete port meter
2502~~~~~~~~~~~~~~~~~
2503
2504Delete meter for the ethernet device::
2505
2506   testpmd> del port meter (port_id) (mtr_id)
2507
2508Set port meter profile
2509~~~~~~~~~~~~~~~~~~~~~~
2510
2511Set meter profile for the ethernet device::
2512
2513   testpmd> set port meter profile (port_id) (mtr_id) (profile_id)
2514
2515set port meter dscp table
2516~~~~~~~~~~~~~~~~~~~~~~~~~
2517
2518Set meter dscp table for the ethernet device::
2519
2520   testpmd> set port meter dscp table (port_id) (mtr_id) (proto) \
2521   [(dscp_tbl_entry0) (dscp_tbl_entry1)...(dscp_tbl_entry63)]
2522
2523set port meter vlan table
2524~~~~~~~~~~~~~~~~~~~~~~~~~
2525Set meter VLAN table for the Ethernet device::
2526
2527   testpmd> set port meter vlan table (port_id) (mtr_id) (proto) \
2528   [(vlan_tbl_entry0) (vlan_tbl_entry1)...(vlan_tbl_entry15)]
2529
2530set port meter protocol
2531~~~~~~~~~~~~~~~~~~~~~~~
2532Set meter protocol and corresponding priority::
2533
2534   testpmd> set port meter proto (port_id) (mtr_id) (proto) (prio)
2535
2536get port meter protocol
2537~~~~~~~~~~~~~~~~~~~~~~~
2538Get meter protocol::
2539
2540   testpmd> get port meter proto (port_id) (mtr_id)
2541
2542get port meter protocol priority
2543~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2544Get priority associated to meter protocol::
2545
2546   testpmd> get port meter proto_prio (port_id) (mtr_id) (proto)
2547
2548set port meter stats mask
2549~~~~~~~~~~~~~~~~~~~~~~~~~
2550
2551Set meter stats mask for the ethernet device::
2552
2553   testpmd> set port meter stats mask (port_id) (mtr_id) (stats_mask)
2554
2555where:
2556
2557* ``stats_mask``: Bit mask indicating statistics counter types to be enabled.
2558
2559show port meter stats
2560~~~~~~~~~~~~~~~~~~~~~
2561
2562Show meter stats of the ethernet device::
2563
2564   testpmd> show port meter stats (port_id) (mtr_id) (clear)
2565
2566where:
2567
2568* ``clear``: Flag that indicates whether the statistics counters should
2569  be cleared (i.e. set to zero) immediately after they have been read or not.
2570
2571Traffic Management
2572------------------
2573
2574The following section shows functions for configuring traffic management on
2575the ethernet device through the use of generic TM API.
2576
2577show port traffic management capability
2578~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2579
2580Show traffic management capability of the port::
2581
2582   testpmd> show port tm cap (port_id)
2583
2584show port traffic management capability (hierarchy level)
2585~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2586
2587Show traffic management hierarchy level capability of the port::
2588
2589   testpmd> show port tm level cap (port_id) (level_id)
2590
2591show port traffic management capability (hierarchy node level)
2592~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2593
2594Show the traffic management hierarchy node capability of the port::
2595
2596   testpmd> show port tm node cap (port_id) (node_id)
2597
2598show port traffic management hierarchy node type
2599~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2600
2601Show the port traffic management hierarchy node type::
2602
2603   testpmd> show port tm node type (port_id) (node_id)
2604
2605show port traffic management hierarchy node stats
2606~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2607
2608Show the port traffic management hierarchy node statistics::
2609
2610   testpmd> show port tm node stats (port_id) (node_id) (clear)
2611
2612where:
2613
2614* ``clear``: When this parameter has a non-zero value, the statistics counters
2615  are cleared (i.e. set to zero) immediately after they have been read,
2616  otherwise the statistics counters are left untouched.
2617
2618Add port traffic management private shaper profile
2619~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2620
2621Add the port traffic management private shaper profile::
2622
2623   testpmd> add port tm node shaper profile (port_id) (shaper_profile_id) \
2624   (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size) \
2625   (packet_length_adjust) (packet_mode)
2626
2627where:
2628
2629* ``shaper_profile id``: Shaper profile ID for the new profile.
2630* ``cmit_tb_rate``: Committed token bucket rate (bytes per second or packets per second).
2631* ``cmit_tb_size``: Committed token bucket size (bytes or packets).
2632* ``peak_tb_rate``: Peak token bucket rate (bytes per second or packets per second).
2633* ``peak_tb_size``: Peak token bucket size (bytes or packets).
2634* ``packet_length_adjust``: The value (bytes) to be added to the length of
2635  each packet for the purpose of shaping. This parameter value can be used to
2636  correct the packet length with the framing overhead bytes that are consumed
2637  on the wire.
2638* ``packet_mode``: Shaper configured in packet mode. This parameter value if
2639  zero, configures shaper in byte mode and if non-zero configures it in packet
2640  mode.
2641
2642Delete port traffic management private shaper profile
2643~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2644
2645Delete the port traffic management private shaper::
2646
2647   testpmd> del port tm node shaper profile (port_id) (shaper_profile_id)
2648
2649where:
2650
2651* ``shaper_profile id``: Shaper profile ID that needs to be deleted.
2652
2653Add port traffic management shared shaper
2654~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2655
2656Create the port traffic management shared shaper::
2657
2658   testpmd> add port tm node shared shaper (port_id) (shared_shaper_id) \
2659   (shaper_profile_id)
2660
2661where:
2662
2663* ``shared_shaper_id``: Shared shaper ID to be created.
2664* ``shaper_profile id``: Shaper profile ID for shared shaper.
2665
2666Set port traffic management shared shaper
2667~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2668
2669Update the port traffic management shared shaper::
2670
2671   testpmd> set port tm node shared shaper (port_id) (shared_shaper_id) \
2672   (shaper_profile_id)
2673
2674where:
2675
2676* ``shared_shaper_id``: Shared shaper ID to be update.
2677* ``shaper_profile id``: Shaper profile ID for shared shaper.
2678
2679Delete port traffic management shared shaper
2680~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2681
2682Delete the port traffic management shared shaper::
2683
2684   testpmd> del port tm node shared shaper (port_id) (shared_shaper_id)
2685
2686where:
2687
2688* ``shared_shaper_id``: Shared shaper ID to be deleted.
2689
2690Set port traffic management hierarchy node private shaper
2691~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2692
2693set the port traffic management hierarchy node private shaper::
2694
2695   testpmd> set port tm node shaper profile (port_id) (node_id) \
2696   (shaper_profile_id)
2697
2698where:
2699
2700* ``shaper_profile id``: Private shaper profile ID to be enabled on the
2701  hierarchy node.
2702
2703Add port traffic management WRED profile
2704~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2705
2706Create a new WRED profile::
2707
2708   testpmd> add port tm node wred profile (port_id) (wred_profile_id) \
2709   (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g) \
2710   (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y) \
2711   (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)
2712
2713where:
2714
2715* ``wred_profile id``: Identifier for the newly create WRED profile
2716* ``color_g``: Packet color (green)
2717* ``min_th_g``: Minimum queue threshold for packet with green color
2718* ``max_th_g``: Minimum queue threshold for packet with green color
2719* ``maxp_inv_g``: Inverse of packet marking probability maximum value (maxp)
2720* ``wq_log2_g``: Negated log2 of queue weight (wq)
2721* ``color_y``: Packet color (yellow)
2722* ``min_th_y``: Minimum queue threshold for packet with yellow color
2723* ``max_th_y``: Minimum queue threshold for packet with yellow color
2724* ``maxp_inv_y``: Inverse of packet marking probability maximum value (maxp)
2725* ``wq_log2_y``: Negated log2 of queue weight (wq)
2726* ``color_r``: Packet color (red)
2727* ``min_th_r``: Minimum queue threshold for packet with yellow color
2728* ``max_th_r``: Minimum queue threshold for packet with yellow color
2729* ``maxp_inv_r``: Inverse of packet marking probability maximum value (maxp)
2730* ``wq_log2_r``: Negated log2 of queue weight (wq)
2731
2732Delete port traffic management WRED profile
2733~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2734
2735Delete the WRED profile::
2736
2737   testpmd> del port tm node wred profile (port_id) (wred_profile_id)
2738
2739Add port traffic management hierarchy nonleaf node
2740~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2741
2742Add nonleaf node to port traffic management hierarchy::
2743
2744   testpmd> add port tm nonleaf node (port_id) (node_id) (parent_node_id) \
2745   (priority) (weight) (level_id) (shaper_profile_id) \
2746   (n_sp_priorities) (stats_mask) (n_shared_shapers) \
2747   [(shared_shaper_0) (shared_shaper_1) ...] \
2748
2749where:
2750
2751* ``parent_node_id``: Node ID of the parent.
2752* ``priority``: Node priority (highest node priority is zero). This is used by
2753  the SP algorithm running on the parent node for scheduling this node.
2754* ``weight``: Node weight (lowest weight is one). The node weight is relative
2755  to the weight sum of all siblings that have the same priority. It is used by
2756  the WFQ algorithm running on the parent node for scheduling this node.
2757* ``level_id``: Hierarchy level of the node.
2758* ``shaper_profile_id``: Shaper profile ID of the private shaper to be used by
2759  the node.
2760* ``n_sp_priorities``: Number of strict priorities.
2761* ``stats_mask``: Mask of statistics counter types to be enabled for this node.
2762* ``n_shared_shapers``: Number of shared shapers.
2763* ``shared_shaper_id``: Shared shaper id.
2764
2765Add port traffic management hierarchy nonleaf node with packet mode
2766~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2767
2768Add nonleaf node with packet mode to port traffic management hierarchy::
2769
2770   testpmd> add port tm nonleaf node pktmode (port_id) (node_id) (parent_node_id) \
2771   (priority) (weight) (level_id) (shaper_profile_id) \
2772   (n_sp_priorities) (stats_mask) (n_shared_shapers) \
2773   [(shared_shaper_0) (shared_shaper_1) ...] \
2774
2775where:
2776
2777* ``parent_node_id``: Node ID of the parent.
2778* ``priority``: Node priority (highest node priority is zero). This is used by
2779  the SP algorithm running on the parent node for scheduling this node.
2780* ``weight``: Node weight (lowest weight is one). The node weight is relative
2781  to the weight sum of all siblings that have the same priority. It is used by
2782  the WFQ algorithm running on the parent node for scheduling this node.
2783* ``level_id``: Hierarchy level of the node.
2784* ``shaper_profile_id``: Shaper profile ID of the private shaper to be used by
2785  the node.
2786* ``n_sp_priorities``: Number of strict priorities. Packet mode is enabled on
2787  all of them.
2788* ``stats_mask``: Mask of statistics counter types to be enabled for this node.
2789* ``n_shared_shapers``: Number of shared shapers.
2790* ``shared_shaper_id``: Shared shaper id.
2791
2792Add port traffic management hierarchy leaf node
2793~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2794
2795Add leaf node to port traffic management hierarchy::
2796
2797   testpmd> add port tm leaf node (port_id) (node_id) (parent_node_id) \
2798   (priority) (weight) (level_id) (shaper_profile_id) \
2799   (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers) \
2800   [(shared_shaper_id) (shared_shaper_id) ...] \
2801
2802where:
2803
2804* ``parent_node_id``: Node ID of the parent.
2805* ``priority``: Node priority (highest node priority is zero). This is used by
2806  the SP algorithm running on the parent node for scheduling this node.
2807* ``weight``: Node weight (lowest weight is one). The node weight is relative
2808  to the weight sum of all siblings that have the same priority. It is used by
2809  the WFQ algorithm running on the parent node for scheduling this node.
2810* ``level_id``: Hierarchy level of the node.
2811* ``shaper_profile_id``: Shaper profile ID of the private shaper to be used by
2812  the node.
2813* ``cman_mode``: Congestion management mode to be enabled for this node.
2814* ``wred_profile_id``: WRED profile id to be enabled for this node.
2815* ``stats_mask``: Mask of statistics counter types to be enabled for this node.
2816* ``n_shared_shapers``: Number of shared shapers.
2817* ``shared_shaper_id``: Shared shaper id.
2818
2819Query port traffic management hierarchy node
2820~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2821
2822An added traffic management hierarchy node, whether leaf of non-leaf,
2823can be queried using::
2824
2825    testpmd> show port tm node (port_id) (node_id)
2826
2827where ``port_id`` and ``node_id`` are the numeric identifiers of the ethernet port
2828and the previously added traffic management node, respectively.
2829The output of this command are the parameters previously provided to the add call,
2830printed with appropriate labels.
2831For example::
2832
2833   testpmd> show port tm node 0 90
2834   Port 0 TM Node 90
2835     Parent Node ID: 100
2836     Level ID: 1
2837     Priority: 0
2838     Weight: 1
2839     Shaper Profile ID: <none>
2840     Shared Shaper IDs: <none>
2841     Stats Mask: 0
2842     Nonleaf Node Parameters
2843       Num Strict Priorities: 1
2844       WFQ Weights Mode: WFQ
2845
2846Delete port traffic management hierarchy node
2847~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2848
2849Delete node from port traffic management hierarchy::
2850
2851   testpmd> del port tm node (port_id) (node_id)
2852
2853Update port traffic management hierarchy parent node
2854~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2855
2856Update port traffic management hierarchy parent node::
2857
2858   testpmd> set port tm node parent (port_id) (node_id) (parent_node_id) \
2859   (priority) (weight)
2860
2861This function can only be called after the hierarchy commit invocation. Its
2862success depends on the port support for this operation, as advertised through
2863the port capability set. This function is valid for all nodes of the traffic
2864management hierarchy except root node.
2865
2866Suspend port traffic management hierarchy node
2867~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2868
2869   testpmd> suspend port tm node (port_id) (node_id)
2870
2871Resume port traffic management hierarchy node
2872~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2873
2874   testpmd> resume port tm node (port_id) (node_id)
2875
2876Commit port traffic management hierarchy
2877~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2878
2879Commit the traffic management hierarchy on the port::
2880
2881   testpmd> port tm hierarchy commit (port_id) (clean_on_fail)
2882
2883where:
2884
2885* ``clean_on_fail``: When set to non-zero, hierarchy is cleared on function
2886  call failure. On the other hand, hierarchy is preserved when this parameter
2887  is equal to zero.
2888
2889Set port traffic management mark VLAN dei
2890~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2891
2892Enables/Disables the traffic management marking on the port for VLAN packets::
2893
2894   testpmd> set port tm mark vlan_dei <port_id> <green> <yellow> <red>
2895
2896where:
2897
2898* ``port_id``: The port which on which VLAN packets marked as ``green`` or
2899  ``yellow`` or ``red`` will have dei bit enabled
2900
2901* ``green`` enable 1, disable 0 marking for dei bit of VLAN packets marked as green
2902
2903* ``yellow`` enable 1, disable 0 marking for dei bit of VLAN packets marked as yellow
2904
2905* ``red`` enable 1, disable 0 marking for dei bit of VLAN packets marked as red
2906
2907Set port traffic management mark IP dscp
2908~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2909
2910Enables/Disables the traffic management marking on the port for IP dscp packets::
2911
2912   testpmd> set port tm mark ip_dscp <port_id> <green> <yellow> <red>
2913
2914where:
2915
2916* ``port_id``: The port which on which IP packets marked as ``green`` or
2917  ``yellow`` or ``red`` will have IP dscp bits updated
2918
2919* ``green`` enable 1, disable 0 marking IP dscp to low drop precedence for green packets
2920
2921* ``yellow`` enable 1, disable 0 marking IP dscp to medium drop precedence for yellow packets
2922
2923* ``red`` enable 1, disable 0 marking IP dscp to high drop precedence for red packets
2924
2925Set port traffic management mark IP ecn
2926~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2927
2928Enables/Disables the traffic management marking on the port for IP ecn packets::
2929
2930   testpmd> set port tm mark ip_ecn <port_id> <green> <yellow> <red>
2931
2932where:
2933
2934* ``port_id``: The port which on which IP packets marked as ``green`` or
2935  ``yellow`` or ``red`` will have IP ecn bits updated
2936
2937* ``green`` enable 1, disable 0 marking IP ecn for green marked packets with ecn of 2'b01  or 2'b10
2938  to ecn of 2'b11 when IP is caring TCP or SCTP
2939
2940* ``yellow`` enable 1, disable 0 marking IP ecn for yellow marked packets with ecn of 2'b01  or 2'b10
2941  to ecn of 2'b11 when IP is caring TCP or SCTP
2942
2943* ``red`` enable 1, disable 0 marking IP ecn for yellow marked packets with ecn of 2'b01  or 2'b10
2944  to ecn of 2'b11 when IP is caring TCP or SCTP
2945
2946Congestion Management
2947---------------------
2948
2949Get capabilities
2950~~~~~~~~~~~~~~~~
2951
2952Retrieve congestion management capabilities supported by driver for given port.
2953Below example command retrieves capabilities for port 0::
2954
2955   testpmd> show port cman capa 0
2956
2957Get configuration
2958~~~~~~~~~~~~~~~~~
2959
2960Retrieve congestion management configuration for given port.
2961Below example command retrieves configuration for port 0::
2962
2963   testpmd> show port cman config 0
2964
2965Set configuration
2966~~~~~~~~~~~~~~~~~
2967
2968Configures congestion management settings on given queue
2969or mempool associated with queue.
2970Below example command configures RED as congestion management algorithm
2971for port 0 and queue 0::
2972
2973   testpmd> set port cman config 0 0 obj queue mode red 10 100 1
2974
2975.. _testpmd_rte_flow:
2976
2977Flow rules management
2978---------------------
2979
2980Control of the generic flow API (*rte_flow*) is fully exposed through the
2981``flow`` command (configuration, validation, creation, destruction, queries
2982and operation modes).
2983
2984``flow`` syntax
2985~~~~~~~~~~~~~~~
2986
2987Because the ``flow`` command uses dynamic tokens to handle the large number
2988of possible flow rules combinations, its behavior differs slightly from
2989other commands, in particular:
2990
2991- Pressing *?* or the *<tab>* key displays contextual help for the current
2992  token, not that of the entire command.
2993
2994- Optional and repeated parameters are supported (provided they are listed
2995  in the contextual help).
2996
2997The first parameter stands for the operation mode. Possible operations and
2998their general syntax are described below. They are covered in detail in the
2999following sections.
3000
3001- Get info about flow engine::
3002
3003   flow info {port_id}
3004
3005- Configure flow engine::
3006
3007   flow configure {port_id}
3008       [queues_number {number}] [queues_size {size}]
3009       [counters_number {number}]
3010       [aging_counters_number {number}]
3011       [meters_number {number}] [flags {number}]
3012
3013- Create a pattern template::
3014
3015   flow pattern_template {port_id} create [pattern_template_id {id}]
3016       [relaxed {boolean}] [ingress] [egress] [transfer]
3017       template {item} [/ {item} [...]] / end
3018
3019- Destroy a pattern template::
3020
3021   flow pattern_template {port_id} destroy pattern_template {id} [...]
3022
3023- Create an actions template::
3024
3025   flow actions_template {port_id} create [actions_template_id {id}]
3026       [ingress] [egress] [transfer]
3027       template {action} [/ {action} [...]] / end
3028       mask {action} [/ {action} [...]] / end
3029
3030- Destroy an actions template::
3031
3032   flow actions_template {port_id} destroy actions_template {id} [...]
3033
3034- Create a table::
3035
3036   flow table {port_id} create
3037       [table_id {id}] [resizable]
3038       [group {group_id}] [priority {level}] [ingress] [egress] [transfer]
3039       rules_number {number}
3040       pattern_template {pattern_template_id}
3041       actions_template {actions_template_id}
3042
3043- Resize a table::
3044
3045   flow template_table {port_id} resize
3046       table_resize_id {id} table_resize_rules_num {number}
3047
3048- Complete table resize::
3049
3050   flow template_table {port_id} resize_complete table {table_id}
3051
3052- Destroy a table::
3053
3054   flow table {port_id} destroy table {id} [...]
3055
3056- Check whether a flow rule can be created::
3057
3058   flow validate {port_id}
3059       [group {group_id}] [priority {level}] [ingress] [egress] [transfer]
3060       pattern {item} [/ {item} [...]] / end
3061       actions {action} [/ {action} [...]] / end
3062
3063- Enqueue creation of a flow rule::
3064
3065   flow queue {port_id} create {queue_id}
3066       [postpone {boolean}] template_table {table_id}
3067       pattern_template {pattern_template_index}
3068       actions_template {actions_template_index}
3069       pattern {item} [/ {item} [...]] / end
3070       actions {action} [/ {action} [...]] / end
3071
3072- Enqueue flow update following table resize::
3073
3074   flow queue {port_id} update_resized {table_id} rule {rule_id}
3075
3076- Enqueue destruction of specific flow rules::
3077
3078   flow queue {port_id} destroy {queue_id}
3079       [postpone {boolean}] rule {rule_id} [...]
3080
3081- Push enqueued operations::
3082
3083   flow push {port_id} queue {queue_id}
3084
3085- Pull all operations results from a queue::
3086
3087   flow pull {port_id} queue {queue_id}
3088
3089- Create a flow rule::
3090
3091   flow create {port_id}
3092       [group {group_id}] [priority {level}] [ingress] [egress]
3093       [transfer] [tunnel_set {tunnel_id}] [tunnel_match {tunnel_id}]
3094       [user_id {user_id}] pattern {item} [/ {item} [...]] / end
3095       actions {action} [/ {action} [...]] / end
3096
3097- Destroy specific flow rules::
3098
3099   flow destroy {port_id} rule {rule_id} [...] [user_id]
3100
3101- Update a flow rule with new actions::
3102
3103   flow update {port_id} {rule_id}
3104       actions {action} [/ {action} [...]] / end [user_id]
3105
3106- Destroy all flow rules::
3107
3108   flow flush {port_id}
3109
3110- Query an existing flow rule::
3111
3112   flow query {port_id} {rule_id} {action} [user_id]
3113
3114- List existing flow rules sorted by priority, filtered by group
3115  identifiers::
3116
3117   flow list {port_id} [group {group_id}] [...]
3118
3119- Restrict ingress traffic to the defined flow rules::
3120
3121   flow isolate {port_id} {boolean}
3122
3123- Dump internal representation information of all flows in hardware::
3124
3125   flow dump {port_id} all {output_file} [user_id]
3126
3127  for one flow::
3128
3129   flow dump {port_id} rule {rule_id} {output_file} [user_id]
3130
3131- List and destroy aged flow rules::
3132
3133   flow aged {port_id} [destroy]
3134
3135- Enqueue list and destroy aged flow rules::
3136
3137   flow queue {port_id} aged {queue_id} [destroy]
3138
3139- Tunnel offload - create a tunnel stub::
3140
3141   flow tunnel create {port_id} type {tunnel_type}
3142
3143- Tunnel offload - destroy a tunnel stub::
3144
3145   flow tunnel destroy {port_id} id {tunnel_id}
3146
3147- Tunnel offload - list port tunnel stubs::
3148
3149   flow tunnel list {port_id}
3150
3151Retrieving info about flow management engine
3152~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3153
3154``flow info`` retrieves info on pre-configurable resources in the underlying
3155device to give a hint of possible values for flow engine configuration.
3156
3157``rte_flow_info_get()``::
3158
3159   flow info {port_id}
3160
3161If successful, it will show::
3162
3163   Flow engine resources on port #[...]:
3164   Number of queues: #[...]
3165   Size of queues: #[...]
3166   Number of counters: #[...]
3167   Number of aging objects: #[...]
3168   Number of meters: #[...]
3169
3170Otherwise it will show an error message of the form::
3171
3172   Caught error type [...] ([...]): [...]
3173
3174Configuring flow management engine
3175~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3176
3177``flow configure`` pre-allocates all the needed resources in the underlying
3178device to be used later at the flow creation. Flow queues are allocated as well
3179for asynchronous flow creation/destruction operations. It is bound to
3180``rte_flow_configure()``::
3181
3182   flow configure {port_id}
3183       [queues_number {number}] [queues_size {size}]
3184       [counters_number {number}]
3185       [aging_counters_number {number}]
3186       [host_port {number}]
3187       [meters_number {number}]
3188       [flags {number}]
3189
3190If successful, it will show::
3191
3192   Configure flows on port #[...]: number of queues #[...] with #[...] elements
3193
3194Otherwise it will show an error message of the form::
3195
3196   Caught error type [...] ([...]): [...]
3197
3198Creating pattern templates
3199~~~~~~~~~~~~~~~~~~~~~~~~~~
3200
3201``flow pattern_template create`` creates the specified pattern template.
3202It is bound to ``rte_flow_pattern_template_create()``::
3203
3204   flow pattern_template {port_id} create [pattern_template_id {id}]
3205       [relaxed {boolean}] [ingress] [egress] [transfer]
3206	   template {item} [/ {item} [...]] / end
3207
3208If successful, it will show::
3209
3210   Pattern template #[...] created
3211
3212Otherwise it will show an error message of the form::
3213
3214   Caught error type [...] ([...]): [...]
3215
3216This command uses the same pattern items as ``flow create``,
3217their format is described in `Creating flow rules`_.
3218
3219Destroying pattern templates
3220~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3221
3222``flow pattern_template destroy`` destroys one or more pattern templates
3223from their template ID (as returned by ``flow pattern_template create``),
3224this command calls ``rte_flow_pattern_template_destroy()`` as many
3225times as necessary::
3226
3227   flow pattern_template {port_id} destroy pattern_template {id} [...]
3228
3229If successful, it will show::
3230
3231   Pattern template #[...] destroyed
3232
3233It does not report anything for pattern template IDs that do not exist.
3234The usual error message is shown when a pattern template cannot be destroyed::
3235
3236   Caught error type [...] ([...]): [...]
3237
3238Creating actions templates
3239~~~~~~~~~~~~~~~~~~~~~~~~~~
3240
3241``flow actions_template create`` creates the specified actions template.
3242It is bound to ``rte_flow_actions_template_create()``::
3243
3244   flow actions_template {port_id} create [actions_template_id {id}]
3245       [ingress] [egress] [transfer]
3246	   template {action} [/ {action} [...]] / end
3247       mask {action} [/ {action} [...]] / end
3248
3249If successful, it will show::
3250
3251   Actions template #[...] created
3252
3253Otherwise it will show an error message of the form::
3254
3255   Caught error type [...] ([...]): [...]
3256
3257This command uses the same actions as ``flow create``,
3258their format is described in `Creating flow rules`_.
3259
3260Destroying actions templates
3261~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3262
3263``flow actions_template destroy`` destroys one or more actions templates
3264from their template ID (as returned by ``flow actions_template create``),
3265this command calls ``rte_flow_actions_template_destroy()`` as many
3266times as necessary::
3267
3268   flow actions_template {port_id} destroy actions_template {id} [...]
3269
3270If successful, it will show::
3271
3272   Actions template #[...] destroyed
3273
3274It does not report anything for actions template IDs that do not exist.
3275The usual error message is shown when an actions template cannot be destroyed::
3276
3277   Caught error type [...] ([...]): [...]
3278
3279Creating template table
3280~~~~~~~~~~~~~~~~~~~~~~~
3281
3282``flow template_table create`` creates the specified template table.
3283It is bound to ``rte_flow_template_table_create()``::
3284
3285   flow template_table {port_id} create
3286       [table_id {id}] [group {group_id}]
3287       [priority {level}] [ingress] [egress]
3288       [transfer [vport_orig] [wire_orig]]
3289       rules_number {number}
3290       pattern_template {pattern_template_id}
3291       actions_template {actions_template_id}
3292
3293If successful, it will show::
3294
3295   Template table #[...] created
3296
3297Otherwise it will show an error message of the form::
3298
3299   Caught error type [...] ([...]): [...]
3300
3301Destroying flow table
3302~~~~~~~~~~~~~~~~~~~~~
3303
3304``flow template_table destroy`` destroys one or more template tables
3305from their table ID (as returned by ``flow template_table create``),
3306this command calls ``rte_flow_template_table_destroy()`` as many
3307times as necessary::
3308
3309   flow template_table {port_id} destroy table {id} [...]
3310
3311If successful, it will show::
3312
3313   Template table #[...] destroyed
3314
3315It does not report anything for table IDs that do not exist.
3316The usual error message is shown when a table cannot be destroyed::
3317
3318   Caught error type [...] ([...]): [...]
3319
3320Pushing enqueued operations
3321~~~~~~~~~~~~~~~~~~~~~~~~~~~
3322
3323``flow push`` pushes all the outstanding enqueued operations
3324to the underlying device immediately.
3325It is bound to ``rte_flow_push()``::
3326
3327   flow push {port_id} queue {queue_id}
3328
3329If successful, it will show::
3330
3331   Queue #[...] operations pushed
3332
3333The usual error message is shown when operations cannot be pushed::
3334
3335   Caught error type [...] ([...]): [...]
3336
3337Pulling flow operations results
3338~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3339
3340``flow pull`` asks the underlying device about flow queue operations
3341results and return all the processed (successfully or not) operations.
3342It is bound to ``rte_flow_pull()``::
3343
3344   flow pull {port_id} queue {queue_id}
3345
3346If successful, it will show::
3347
3348   Queue #[...] pulled #[...] operations (#[...] failed, #[...] succeeded)
3349
3350The usual error message is shown when operations results cannot be pulled::
3351
3352   Caught error type [...] ([...]): [...]
3353
3354Calculating hash
3355~~~~~~~~~~~~~~~~
3356
3357``flow hash {port_id} template_table`` calculates the hash for a given pattern.
3358It is bound to ``rte_flow_calc_table_hash()``::
3359
3360   flow hash {port_id} template_table {table_id}
3361       pattern_template {pattern_template_index}
3362       actions_template {actions_template_index}
3363       pattern {item} [/ {item} [...]] / end
3364
3365If successful, it will show the calculated hash result as seen below::
3366
3367   Hash results 0x[...]
3368
3369Otherwise, it will show an error message of the form::
3370
3371   Caught error type [...] ([...]): [...]
3372
3373This command uses the same pattern items as ``flow create``,
3374their format is described in `Creating flow rules`_.
3375
3376Simulate encap hash calculation
3377~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3378
3379``flow hash {port_id} encap`` adds hash query, that returns the hash value
3380that the HW will calculate when encapsulating a packet::
3381
3382   flow hash {port_id} encap {target field} pattern {item} [/ {item} [...]] / end
3383
3384If successful, it will show::
3385
3386   encap hash result #[...]
3387
3388The value will be shown as uint16_t without endian conversion.
3389
3390Otherwise it will show an error message of the form::
3391
3392   Failed to calculate encap hash - [...]
3393
3394Creating a tunnel stub for offload
3395~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3396
3397``flow tunnel create`` setup a tunnel stub for tunnel offload flow rules::
3398
3399   flow tunnel create {port_id} type {tunnel_type}
3400
3401If successful, it will return a tunnel stub ID usable with other commands::
3402
3403   port [...]: flow tunnel #[...] type [...]
3404
3405Tunnel stub ID is relative to a port.
3406
3407Destroying tunnel offload stub
3408~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3409
3410``flow tunnel destroy`` destroy port tunnel stub::
3411
3412   flow tunnel destroy {port_id} id {tunnel_id}
3413
3414Listing tunnel offload stubs
3415~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3416
3417``flow tunnel list`` list port tunnel offload stubs::
3418
3419   flow tunnel list {port_id}
3420
3421Validating flow rules
3422~~~~~~~~~~~~~~~~~~~~~
3423
3424``flow validate`` reports whether a flow rule would be accepted by the
3425underlying device in its current state but stops short of creating it. It is
3426bound to ``rte_flow_validate()``::
3427
3428   flow validate {port_id}
3429      [group {group_id}] [priority {level}] [ingress] [egress] [transfer]
3430      pattern {item} [/ {item} [...]] / end
3431      actions {action} [/ {action} [...]] / end
3432
3433If successful, it will show::
3434
3435   Flow rule validated
3436
3437Otherwise it will show an error message of the form::
3438
3439   Caught error type [...] ([...]): [...]
3440
3441This command uses the same parameters as ``flow create``, their format is
3442described in `Creating flow rules`_.
3443
3444Check whether redirecting any Ethernet packet received on port 0 to RX queue
3445index 6 is supported::
3446
3447   testpmd> flow validate 0 ingress pattern eth / end
3448      actions queue index 6 / end
3449   Flow rule validated
3450   testpmd>
3451
3452Port 0 does not support TCPv6 rules::
3453
3454   testpmd> flow validate 0 ingress pattern eth / ipv6 / tcp / end
3455      actions drop / end
3456   Caught error type 9 (specific pattern item): Invalid argument
3457   testpmd>
3458
3459Creating flow rules
3460~~~~~~~~~~~~~~~~~~~
3461
3462``flow create`` validates and creates the specified flow rule. It is bound
3463to ``rte_flow_create()``::
3464
3465   flow create {port_id}
3466      [group {group_id}] [priority {level}] [ingress] [egress] [transfer]
3467      [tunnel_set {tunnel_id}] [tunnel_match {tunnel_id}]
3468      [user_id {user_id}] pattern {item} [/ {item} [...]] / end
3469      actions {action} [/ {action} [...]] / end
3470
3471If successful, it will return a flow rule ID usable with other commands::
3472
3473   Flow rule #[...] created
3474
3475Or if ``user_id`` is provided::
3476
3477   Flow rule #[...] created, user-id [...]
3478
3479Otherwise it will show an error message of the form::
3480
3481   Caught error type [...] ([...]): [...]
3482
3483Parameters describe in the following order:
3484
3485- Attributes (*group*, *priority*, *ingress*, *egress*, *transfer* tokens).
3486- Tunnel offload specification (tunnel_set, tunnel_match)
3487- User identifier for the flow.
3488- A matching pattern, starting with the *pattern* token and terminated by an
3489  *end* pattern item.
3490- Actions, starting with the *actions* token and terminated by an *end*
3491  action.
3492
3493These translate directly to *rte_flow* objects provided as-is to the
3494underlying functions.
3495
3496The shortest valid definition only comprises mandatory tokens::
3497
3498   testpmd> flow create 0 pattern end actions end
3499
3500Note that PMDs may refuse rules that essentially do nothing such as this
3501one.
3502
3503**All unspecified object values are automatically initialized to 0.**
3504
3505Enqueueing creation of flow rules
3506~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3507
3508``flow queue create`` adds creation operation of a flow rule to a queue.
3509It is bound to ``rte_flow_async_create()``::
3510
3511   flow queue {port_id} create {queue_id}
3512       [postpone {boolean}] template_table {table_id}
3513       pattern_template {pattern_template_index}
3514       actions_template {actions_template_index}
3515       pattern {item} [/ {item} [...]] / end
3516       actions {action} [/ {action} [...]] / end
3517
3518If successful, it will return a flow rule ID usable with other commands::
3519
3520   Flow rule #[...] creaion enqueued
3521
3522Otherwise it will show an error message of the form::
3523
3524   Caught error type [...] ([...]): [...]
3525
3526This command uses the same pattern items and actions as ``flow create``,
3527their format is described in `Creating flow rules`_.
3528
3529``flow queue pull`` must be called to retrieve the operation status.
3530
3531Attributes
3532^^^^^^^^^^
3533
3534These tokens affect flow rule attributes (``struct rte_flow_attr``) and are
3535specified before the ``pattern`` token.
3536
3537- ``group {group id}``: priority group.
3538- ``priority {level}``: priority level within group.
3539- ``ingress``: rule applies to ingress traffic.
3540- ``egress``: rule applies to egress traffic.
3541- ``transfer``: apply rule directly to endpoints found in pattern.
3542
3543Please note that use of ``transfer`` attribute requires that the flow and
3544its indirect components be managed via so-called ``transfer`` proxy port.
3545See `show flow transfer proxy port ID for the given port`_ for details.
3546
3547Each instance of an attribute specified several times overrides the previous
3548value as shown below (group 4 is used)::
3549
3550   testpmd> flow create 0 group 42 group 24 group 4 [...]
3551
3552Note that once enabled, ``ingress`` and ``egress`` cannot be disabled.
3553
3554While not specifying a direction is an error, some rules may allow both
3555simultaneously.
3556
3557Most rules affect RX therefore contain the ``ingress`` token::
3558
3559   testpmd> flow create 0 ingress pattern [...]
3560
3561Tunnel offload
3562^^^^^^^^^^^^^^
3563
3564Indicate tunnel offload rule type
3565
3566- ``tunnel_set {tunnel_id}``: mark rule as tunnel offload decap_set type.
3567- ``tunnel_match {tunnel_id}``:  mark rule as tunnel offload match type.
3568
3569Matching pattern
3570^^^^^^^^^^^^^^^^
3571
3572A matching pattern starts after the ``pattern`` token. It is made of pattern
3573items and is terminated by a mandatory ``end`` item.
3574
3575Items are named after their type (*RTE_FLOW_ITEM_TYPE_* from ``enum
3576rte_flow_item_type``).
3577
3578The ``/`` token is used as a separator between pattern items as shown
3579below::
3580
3581   testpmd> flow create 0 ingress pattern eth / ipv4 / udp / end [...]
3582
3583Note that protocol items like these must be stacked from lowest to highest
3584layer to make sense. For instance, the following rule is either invalid or
3585unlikely to match any packet::
3586
3587   testpmd> flow create 0 ingress pattern eth / udp / ipv4 / end [...]
3588
3589More information on these restrictions can be found in the *rte_flow*
3590documentation.
3591
3592Several items support additional specification structures, for example
3593``ipv4`` allows specifying source and destination addresses as follows::
3594
3595   testpmd> flow create 0 ingress pattern eth / ipv4 src is 10.1.1.1
3596      dst is 10.2.0.0 / end [...]
3597
3598This rule matches all IPv4 traffic with the specified properties.
3599
3600In this example, ``src`` and ``dst`` are field names of the underlying
3601``struct rte_flow_item_ipv4`` object. All item properties can be specified
3602in a similar fashion.
3603
3604The ``is`` token means that the subsequent value must be matched exactly,
3605and assigns ``spec`` and ``mask`` fields in ``struct rte_flow_item``
3606accordingly. Possible assignment tokens are:
3607
3608- ``is``: match value perfectly (with full bit-mask).
3609- ``spec``: match value according to configured bit-mask.
3610- ``last``: specify upper bound to establish a range.
3611- ``mask``: specify bit-mask with relevant bits set to one.
3612- ``prefix``: generate bit-mask with <prefix-length> most-significant bits set to one.
3613
3614These yield identical results::
3615
3616   ipv4 src is 10.1.1.1
3617
3618::
3619
3620   ipv4 src spec 10.1.1.1 src mask 255.255.255.255
3621
3622::
3623
3624   ipv4 src spec 10.1.1.1 src prefix 32
3625
3626::
3627
3628   ipv4 src is 10.1.1.1 src last 10.1.1.1 # range with a single value
3629
3630::
3631
3632   ipv4 src is 10.1.1.1 src last 0 # 0 disables range
3633
3634Inclusive ranges can be defined with ``last``::
3635
3636   ipv4 src is 10.1.1.1 src last 10.2.3.4 # 10.1.1.1 to 10.2.3.4
3637
3638Note that ``mask`` affects both ``spec`` and ``last``::
3639
3640   ipv4 src is 10.1.1.1 src last 10.2.3.4 src mask 255.255.0.0
3641      # matches 10.1.0.0 to 10.2.255.255
3642
3643Properties can be modified multiple times::
3644
3645   ipv4 src is 10.1.1.1 src is 10.1.2.3 src is 10.2.3.4 # matches 10.2.3.4
3646
3647::
3648
3649   ipv4 src is 10.1.1.1 src prefix 24 src prefix 16 # matches 10.1.0.0/16
3650
3651Pattern items
3652^^^^^^^^^^^^^
3653
3654This section lists supported pattern items and their attributes, if any.
3655
3656- ``end``: end list of pattern items.
3657
3658- ``void``: no-op pattern item.
3659
3660- ``invert``: perform actions when pattern does not match.
3661
3662- ``any``: match any protocol for the current layer.
3663
3664  - ``num {unsigned}``: number of layers covered.
3665
3666- ``port_id``: match traffic from/to a given DPDK port ID.
3667
3668  - ``id {unsigned}``: DPDK port ID.
3669
3670- ``mark``: match value set in previously matched flow rule using the mark action.
3671
3672  - ``id {unsigned}``: arbitrary integer value.
3673
3674- ``raw``: match an arbitrary byte string.
3675
3676  - ``relative {boolean}``: look for pattern after the previous item.
3677  - ``search {boolean}``: search pattern from offset (see also limit).
3678  - ``offset {integer}``: absolute or relative offset for pattern.
3679  - ``limit {unsigned}``: search area limit for start of pattern.
3680  - ``pattern {string}``: byte string to look for.
3681  - ``pattern_hex {string}``: byte string (provided in hexadecimal) to look for.
3682
3683- ``eth``: match Ethernet header.
3684
3685  - ``dst {MAC-48}``: destination MAC.
3686  - ``src {MAC-48}``: source MAC.
3687  - ``type {unsigned}``: EtherType or TPID.
3688
3689- ``vlan``: match 802.1Q/ad VLAN tag.
3690
3691  - ``tci {unsigned}``: tag control information.
3692  - ``pcp {unsigned}``: priority code point.
3693  - ``dei {unsigned}``: drop eligible indicator.
3694  - ``vid {unsigned}``: VLAN identifier.
3695  - ``inner_type {unsigned}``: inner EtherType or TPID.
3696
3697- ``ipv4``: match IPv4 header.
3698
3699  - ``version_ihl {unsigned}``: IPv4 version and IP header length.
3700  - ``tos {unsigned}``: type of service.
3701  - ``ttl {unsigned}``: time to live.
3702  - ``proto {unsigned}``: next protocol ID.
3703  - ``src {ipv4 address}``: source address.
3704  - ``dst {ipv4 address}``: destination address.
3705
3706- ``ipv6``: match IPv6 header.
3707
3708  - ``tc {unsigned}``: traffic class.
3709  - ``flow {unsigned}``: flow label.
3710  - ``proto {unsigned}``: protocol (next header).
3711  - ``hop {unsigned}``: hop limit.
3712  - ``src {ipv6 address}``: source address.
3713  - ``dst {ipv6 address}``: destination address.
3714
3715- ``icmp``: match ICMP header.
3716
3717  - ``type {unsigned}``: ICMP packet type.
3718  - ``code {unsigned}``: ICMP packet code.
3719
3720- ``udp``: match UDP header.
3721
3722  - ``src {unsigned}``: UDP source port.
3723  - ``dst {unsigned}``: UDP destination port.
3724
3725- ``tcp``: match TCP header.
3726
3727  - ``src {unsigned}``: TCP source port.
3728  - ``dst {unsigned}``: TCP destination port.
3729
3730- ``sctp``: match SCTP header.
3731
3732  - ``src {unsigned}``: SCTP source port.
3733  - ``dst {unsigned}``: SCTP destination port.
3734  - ``tag {unsigned}``: validation tag.
3735  - ``cksum {unsigned}``: checksum.
3736
3737- ``vxlan``: match VXLAN header.
3738
3739  - ``vni {unsigned}``: VXLAN identifier.
3740  - ``flag_g {unsigned}``: VXLAN flag GBP bit.
3741  - ``flag_ver {unsigned}``: VXLAN flag GPE version.
3742  - ``flag_i {unsigned}``: VXLAN flag Instance bit.
3743  - ``flag_p {unsigned}``: VXLAN flag GPE Next Protocol bit.
3744  - ``flag_b {unsigned}``: VXLAN flag GPE Ingress-Replicated BUM.
3745  - ``flag_o {unsigned}``: VXLAN flag GPE OAM Packet bit.
3746  - ``flag_d {unsigned}``: VXLAN flag GBP Don't Learn bit.
3747  - ``flag_a {unsigned}``: VXLAN flag GBP Applied bit.
3748  - ``group_policy_id {unsigned}``: VXLAN GBP Group Policy ID.
3749  - ``protocol {unsigned}`` : VXLAN GPE next protocol.
3750  - ``first_rsvd {unsigned}`` : VXLAN rsvd0 first byte.
3751  - ``secnd_rsvd {unsigned}`` : VXLAN rsvd0 second byte.
3752  - ``third_rsvd {unsigned}`` : VXLAN rsvd0 third byte.
3753  - ``last_rsvd {unsigned}``: VXLAN last reserved byte.
3754
3755- ``e_tag``: match IEEE 802.1BR E-Tag header.
3756
3757  - ``grp_ecid_b {unsigned}``: GRP and E-CID base.
3758
3759- ``nvgre``: match NVGRE header.
3760
3761  - ``tni {unsigned}``: virtual subnet ID.
3762
3763- ``mpls``: match MPLS header.
3764
3765  - ``label {unsigned}``: MPLS label.
3766
3767- ``gre``: match GRE header.
3768
3769  - ``protocol {unsigned}``: protocol type.
3770
3771- ``gre_key``: match GRE optional key field.
3772
3773  - ``value {unsigned}``: key value.
3774
3775- ``gre_option``: match GRE optional fields(checksum/key/sequence).
3776
3777  - ``checksum {unsigned}``: checksum value.
3778  - ``key {unsigned}``: key value.
3779  - ``sequence {unsigned}``: sequence number value.
3780
3781- ``fuzzy``: fuzzy pattern match, expect faster than default.
3782
3783  - ``thresh {unsigned}``: accuracy threshold.
3784
3785- ``gtp``, ``gtpc``, ``gtpu``: match GTPv1 header.
3786
3787  - ``teid {unsigned}``: tunnel endpoint identifier.
3788
3789- ``geneve``: match GENEVE header.
3790
3791  - ``vni {unsigned}``: virtual network identifier.
3792  - ``protocol {unsigned}``: protocol type.
3793
3794- ``geneve-opt``: match GENEVE header option.
3795
3796  - ``class {unsigned}``: GENEVE option class.
3797  - ``type {unsigned}``: GENEVE option type.
3798  - ``length {unsigned}``: GENEVE option length in 32-bit words.
3799  - ``data {hex string}``: GENEVE option data, the length is defined by
3800    ``length`` field.
3801
3802- ``vxlan-gpe``: match VXLAN-GPE header.
3803
3804  - ``vni {unsigned}``: VXLAN-GPE identifier.
3805  - ``flags {unsigned}``: VXLAN-GPE flags.
3806  - ``protocol {unsigned}`` : VXLAN-GPE next protocol.
3807  - ``rsvd0 {unsigned}``: VXLAN-GPE reserved field 0.
3808  - ``rsvd1 {unsigned}``: VXLAN-GPE reserved field 1.
3809
3810- ``arp_eth_ipv4``: match ARP header for Ethernet/IPv4.
3811
3812  - ``sha {MAC-48}``: sender hardware address.
3813  - ``spa {ipv4 address}``: sender IPv4 address.
3814  - ``tha {MAC-48}``: target hardware address.
3815  - ``tpa {ipv4 address}``: target IPv4 address.
3816
3817- ``ipv6_ext``: match presence of any IPv6 extension header.
3818
3819  - ``next_hdr {unsigned}``: next header.
3820
3821- ``icmp6``: match any ICMPv6 header.
3822
3823  - ``type {unsigned}``: ICMPv6 type.
3824  - ``code {unsigned}``: ICMPv6 code.
3825
3826- ``icmp6_echo_request``: match ICMPv6 echo request.
3827
3828  - ``ident {unsigned}``: ICMPv6 echo request identifier.
3829  - ``seq {unsigned}``: ICMPv6 echo request sequence number.
3830
3831- ``icmp6_echo_reply``: match ICMPv6 echo reply.
3832
3833  - ``ident {unsigned}``: ICMPv6 echo reply identifier.
3834  - ``seq {unsigned}``: ICMPv6 echo reply sequence number.
3835
3836- ``icmp6_nd_ns``: match ICMPv6 neighbor discovery solicitation.
3837
3838  - ``target_addr {ipv6 address}``: target address.
3839
3840- ``icmp6_nd_na``: match ICMPv6 neighbor discovery advertisement.
3841
3842  - ``target_addr {ipv6 address}``: target address.
3843
3844- ``icmp6_nd_opt``: match presence of any ICMPv6 neighbor discovery option.
3845
3846  - ``type {unsigned}``: ND option type.
3847
3848- ``icmp6_nd_opt_sla_eth``: match ICMPv6 neighbor discovery source Ethernet
3849  link-layer address option.
3850
3851  - ``sla {MAC-48}``: source Ethernet LLA.
3852
3853- ``icmp6_nd_opt_tla_eth``: match ICMPv6 neighbor discovery target Ethernet
3854  link-layer address option.
3855
3856  - ``tla {MAC-48}``: target Ethernet LLA.
3857
3858- ``meta``: match application specific metadata.
3859
3860  - ``data {unsigned}``: metadata value.
3861
3862- ``random``: match application specific random value.
3863
3864  - ``value {unsigned}``: random value.
3865
3866- ``gtp_psc``: match GTP PDU extension header with type 0x85.
3867
3868  - ``pdu_type {unsigned}``: PDU type.
3869
3870  - ``qfi {unsigned}``: QoS flow identifier.
3871
3872- ``pppoes``, ``pppoed``: match PPPoE header.
3873
3874  - ``session_id {unsigned}``: session identifier.
3875
3876- ``pppoe_proto_id``: match PPPoE session protocol identifier.
3877
3878  - ``proto_id {unsigned}``: PPP protocol identifier.
3879
3880- ``l2tpv3oip``: match L2TPv3 over IP header.
3881
3882  - ``session_id {unsigned}``: L2TPv3 over IP session identifier.
3883
3884- ``ah``: match AH header.
3885
3886  - ``spi {unsigned}``: security parameters index.
3887
3888- ``pfcp``: match PFCP header.
3889
3890  - ``s_field {unsigned}``: S field.
3891  - ``seid {unsigned}``: session endpoint identifier.
3892
3893- ``integrity``: match packet integrity.
3894
3895   - ``level {unsigned}``: Packet encapsulation level the item should
3896     apply to. See rte_flow_action_rss for details.
3897   - ``value {unsigned}``: A bitmask that specify what packet elements
3898     must be matched for integrity.
3899
3900- ``conntrack``: match conntrack state.
3901
3902- ``port_representor``: match traffic entering the embedded switch from the given ethdev
3903
3904  - ``port_id {unsigned}``: ethdev port ID
3905
3906- ``represented_port``: match traffic entering the embedded switch from
3907  the entity represented by the given ethdev
3908
3909  - ``ethdev_port_id {unsigned}``: ethdev port ID
3910
3911- ``l2tpv2``: match L2TPv2 header.
3912
3913  - ``length {unsigned}``: L2TPv2 option length.
3914  - ``tunnel_id {unsigned}``: L2TPv2 tunnel identifier.
3915  - ``session_id {unsigned}``: L2TPv2 session identifier.
3916  - ``ns {unsigned}``: L2TPv2 option ns.
3917  - ``nr {unsigned}``: L2TPv2 option nr.
3918  - ``offset_size {unsigned}``: L2TPv2 option offset.
3919
3920- ``ppp``: match PPP header.
3921
3922  - ``addr {unsigned}``: PPP address.
3923  - ``ctrl {unsigned}``: PPP control.
3924  - ``proto_id {unsigned}``: PPP protocol identifier.
3925
3926- ``ib_bth``: match InfiniBand BTH(base transport header).
3927
3928  - ``opcode {unsigned}``: Opcode.
3929  - ``pkey {unsigned}``: Partition key.
3930  - ``dst_qp {unsigned}``: Destination Queue Pair.
3931  - ``psn {unsigned}``: Packet Sequence Number.
3932
3933- ``meter``: match meter color.
3934
3935  - ``color {value}``: meter color value (green/yellow/red).
3936
3937- ``aggr_affinity``: match aggregated port.
3938
3939  - ``affinity {value}``: aggregated port (starts from 1).
3940
3941- ``tx_queue``: match Tx queue of sent packet.
3942
3943  - ``tx_queue {value}``: send queue value (starts from 0).
3944
3945- ``send_to_kernel``: send packets to kernel.
3946
3947- ``ptype``: match the packet type (L2/L3/L4 and tunnel information).
3948
3949        - ``packet_type {unsigned}``: packet type.
3950
3951- ``compare``: match the comparison result between packet fields or value.
3952
3953        - ``op {string}``: comparison operation type.
3954        - ``a_type {string}``: compared field.
3955        - ``b_type {string}``: comparator field.
3956        - ``width {unsigned}``: comparison width.
3957
3958
3959Actions list
3960^^^^^^^^^^^^
3961
3962A list of actions starts after the ``actions`` token in the same fashion as
3963`Matching pattern`_; actions are separated by ``/`` tokens and the list is
3964terminated by a mandatory ``end`` action.
3965
3966Actions are named after their type (*RTE_FLOW_ACTION_TYPE_* from ``enum
3967rte_flow_action_type``).
3968
3969Dropping all incoming UDPv4 packets can be expressed as follows::
3970
3971   testpmd> flow create 0 ingress pattern eth / ipv4 / udp / end
3972      actions drop / end
3973
3974Several actions have configurable properties which must be specified when
3975there is no valid default value. For example, ``queue`` requires a target
3976queue index.
3977
3978This rule redirects incoming UDPv4 traffic to queue index 6::
3979
3980   testpmd> flow create 0 ingress pattern eth / ipv4 / udp / end
3981      actions queue index 6 / end
3982
3983While this one could be rejected by PMDs (unspecified queue index)::
3984
3985   testpmd> flow create 0 ingress pattern eth / ipv4 / udp / end
3986      actions queue / end
3987
3988As defined by *rte_flow*, the list is not ordered, all actions of a given
3989rule are performed simultaneously. These are equivalent::
3990
3991   queue index 6 / void / mark id 42 / end
3992
3993::
3994
3995   void / mark id 42 / queue index 6 / end
3996
3997All actions in a list should have different types, otherwise only the last
3998action of a given type is taken into account::
3999
4000   queue index 4 / queue index 5 / queue index 6 / end # will use queue 6
4001
4002::
4003
4004   drop / drop / drop / end # drop is performed only once
4005
4006::
4007
4008   mark id 42 / queue index 3 / mark id 24 / end # mark will be 24
4009
4010Considering they are performed simultaneously, opposite and overlapping
4011actions can sometimes be combined when the end result is unambiguous::
4012
4013   drop / queue index 6 / end # drop has no effect
4014
4015::
4016
4017   queue index 6 / rss queues 6 7 8 / end # queue has no effect
4018
4019::
4020
4021   drop / passthru / end # drop has no effect
4022
4023Note that PMDs may still refuse such combinations.
4024
4025Actions
4026^^^^^^^
4027
4028This section lists supported actions and their attributes, if any.
4029
4030- ``end``: end list of actions.
4031
4032- ``void``: no-op action.
4033
4034- ``passthru``: let subsequent rule process matched packets.
4035
4036- ``jump``: redirect traffic to group on device.
4037
4038  - ``group {unsigned}``: group to redirect to.
4039
4040- ``mark``: attach 32 bit value to packets.
4041
4042  - ``id {unsigned}``: 32 bit value to return with packets.
4043
4044- ``flag``: flag packets.
4045
4046- ``queue``: assign packets to a given queue index.
4047
4048  - ``index {unsigned}``: queue index to use.
4049
4050- ``drop``: drop packets (note: passthru has priority).
4051
4052- ``count``: enable counters for this rule.
4053
4054- ``rss``: spread packets among several queues.
4055
4056  - ``func {hash function}``: RSS hash function to apply, allowed tokens are
4057    ``toeplitz``, ``simple_xor``, ``symmetric_toeplitz`` and ``default``.
4058
4059  - ``level {unsigned}``: encapsulation level for ``types``.
4060
4061  - ``types [{RSS hash type} [...]] end``: specific RSS hash types.
4062    Note that an empty list does not disable RSS but instead requests
4063    unspecified "best-effort" settings.
4064
4065  - ``key {string}``: RSS hash key, overrides ``key_len``.
4066
4067  - ``key_len {unsigned}``: RSS hash key length in bytes, can be used in
4068    conjunction with ``key`` to pad or truncate it.
4069
4070  - ``queues [{unsigned} [...]] end``: queue indices to use.
4071
4072- ``pf``: direct traffic to physical function.
4073
4074- ``vf``: direct traffic to a virtual function ID.
4075
4076  - ``original {boolean}``: use original VF ID if possible.
4077  - ``id {unsigned}``: VF ID.
4078
4079- ``port_id``: direct matching traffic to a given DPDK port ID.
4080
4081  - ``original {boolean}``: use original DPDK port ID if possible.
4082  - ``id {unsigned}``: DPDK port ID.
4083
4084- ``of_set_mpls_ttl``: OpenFlow's ``OFPAT_SET_MPLS_TTL``.
4085
4086  - ``mpls_ttl``: MPLS TTL.
4087
4088- ``of_dec_mpls_ttl``: OpenFlow's ``OFPAT_DEC_MPLS_TTL``.
4089
4090- ``of_set_nw_ttl``: OpenFlow's ``OFPAT_SET_NW_TTL``.
4091
4092  - ``nw_ttl``: IP TTL.
4093
4094- ``of_dec_nw_ttl``: OpenFlow's ``OFPAT_DEC_NW_TTL``.
4095
4096- ``of_copy_ttl_out``: OpenFlow's ``OFPAT_COPY_TTL_OUT``.
4097
4098- ``of_copy_ttl_in``: OpenFlow's ``OFPAT_COPY_TTL_IN``.
4099
4100- ``of_pop_vlan``: OpenFlow's ``OFPAT_POP_VLAN``.
4101
4102- ``of_push_vlan``: OpenFlow's ``OFPAT_PUSH_VLAN``.
4103
4104  - ``ethertype``: Ethertype.
4105
4106- ``of_set_vlan_vid``: OpenFlow's ``OFPAT_SET_VLAN_VID``.
4107
4108  - ``vlan_vid``: VLAN id.
4109
4110- ``of_set_vlan_pcp``: OpenFlow's ``OFPAT_SET_VLAN_PCP``.
4111
4112  - ``vlan_pcp``: VLAN priority.
4113
4114- ``of_pop_mpls``: OpenFlow's ``OFPAT_POP_MPLS``.
4115
4116  - ``ethertype``: Ethertype.
4117
4118- ``of_push_mpls``: OpenFlow's ``OFPAT_PUSH_MPLS``.
4119
4120  - ``ethertype``: Ethertype.
4121
4122- ``vxlan_encap``: Performs a VXLAN encapsulation, outer layer configuration
4123  is done through `Config VXLAN Encap outer layers`_.
4124
4125- ``vxlan_decap``: Performs a decapsulation action by stripping all headers of
4126  the VXLAN tunnel network overlay from the matched flow.
4127
4128- ``nvgre_encap``: Performs a NVGRE encapsulation, outer layer configuration
4129  is done through `Config NVGRE Encap outer layers`_.
4130
4131- ``nvgre_decap``: Performs a decapsulation action by stripping all headers of
4132  the NVGRE tunnel network overlay from the matched flow.
4133
4134- ``l2_encap``: Performs a L2 encapsulation, L2 configuration
4135  is done through `Config L2 Encap`_.
4136
4137- ``l2_decap``: Performs a L2 decapsulation, L2 configuration
4138  is done through `Config L2 Decap`_.
4139
4140- ``mplsogre_encap``: Performs a MPLSoGRE encapsulation, outer layer
4141  configuration is done through `Config MPLSoGRE Encap outer layers`_.
4142
4143- ``mplsogre_decap``: Performs a MPLSoGRE decapsulation, outer layer
4144  configuration is done through `Config MPLSoGRE Decap outer layers`_.
4145
4146- ``mplsoudp_encap``: Performs a MPLSoUDP encapsulation, outer layer
4147  configuration is done through `Config MPLSoUDP Encap outer layers`_.
4148
4149- ``mplsoudp_decap``: Performs a MPLSoUDP decapsulation, outer layer
4150  configuration is done through `Config MPLSoUDP Decap outer layers`_.
4151
4152- ``set_ipv4_src``: Set a new IPv4 source address in the outermost IPv4 header.
4153
4154  - ``ipv4_addr``: New IPv4 source address.
4155
4156- ``set_ipv4_dst``: Set a new IPv4 destination address in the outermost IPv4
4157  header.
4158
4159  - ``ipv4_addr``: New IPv4 destination address.
4160
4161- ``set_ipv6_src``: Set a new IPv6 source address in the outermost IPv6 header.
4162
4163  - ``ipv6_addr``: New IPv6 source address.
4164
4165- ``set_ipv6_dst``: Set a new IPv6 destination address in the outermost IPv6
4166  header.
4167
4168  - ``ipv6_addr``: New IPv6 destination address.
4169
4170- ``set_tp_src``: Set a new source port number in the outermost TCP/UDP
4171  header.
4172
4173  - ``port``: New TCP/UDP source port number.
4174
4175- ``set_tp_dst``: Set a new destination port number in the outermost TCP/UDP
4176  header.
4177
4178  - ``port``: New TCP/UDP destination port number.
4179
4180- ``mac_swap``: Swap the source and destination MAC addresses in the outermost
4181  Ethernet header.
4182
4183- ``dec_ttl``: Performs a decrease TTL value action
4184
4185- ``set_ttl``: Set TTL value with specified value
4186  - ``ttl_value {unsigned}``: The new TTL value to be set
4187
4188- ``set_mac_src``: set source MAC address
4189
4190  - ``mac_addr {MAC-48}``: new source MAC address
4191
4192- ``set_mac_dst``: set destination MAC address
4193
4194  - ``mac_addr {MAC-48}``: new destination MAC address
4195
4196- ``inc_tcp_seq``: Increase sequence number in the outermost TCP header.
4197
4198  - ``value {unsigned}``: Value to increase TCP sequence number by.
4199
4200- ``dec_tcp_seq``: Decrease sequence number in the outermost TCP header.
4201
4202  - ``value {unsigned}``: Value to decrease TCP sequence number by.
4203
4204- ``inc_tcp_ack``: Increase acknowledgment number in the outermost TCP header.
4205
4206  - ``value {unsigned}``: Value to increase TCP acknowledgment number by.
4207
4208- ``dec_tcp_ack``: Decrease acknowledgment number in the outermost TCP header.
4209
4210  - ``value {unsigned}``: Value to decrease TCP acknowledgment number by.
4211
4212- ``set_ipv4_dscp``: Set IPv4 DSCP value with specified value
4213
4214  - ``dscp_value {unsigned}``: The new DSCP value to be set
4215
4216- ``set_ipv6_dscp``: Set IPv6 DSCP value with specified value
4217
4218  - ``dscp_value {unsigned}``: The new DSCP value to be set
4219
4220- ``indirect``: Use indirect action created via
4221  ``flow indirect_action {port_id} create``
4222
4223  - ``indirect_action_id {unsigned}``: Indirect action ID to use
4224
4225- ``color``: Color the packet to reflect the meter color result
4226
4227  - ``type {value}``: Set color type with specified value(green/yellow/red)
4228
4229- ``port_representor``: at embedded switch level, send matching traffic to
4230  the given ethdev
4231
4232  - ``port_id {unsigned}``: ethdev port ID
4233
4234- ``represented_port``: at embedded switch level, send matching traffic to
4235  the entity represented by the given ethdev
4236
4237  - ``ethdev_port_id {unsigned}``: ethdev port ID
4238
4239- ``meter_mark``:  meter the directed packets using profile and policy
4240
4241  - ``mtr_profile {unsigned}``: meter profile ID to use
4242  - ``mtr_policy {unsigned}``: meter policy ID to use
4243  - ``mtr_color_mode {unsigned}``: meter color-awareness mode (blind/aware)
4244  - ``mtr_init_color {value}``: initial color value (green/yellow/red)
4245  - ``mtr_state {unsigned}``: meter state (disabled/enabled)
4246
4247- ``modify_field``:  Modify packet field
4248
4249  - ``op``: modify operation (set/add/sub)
4250  - ``dst_type``: the destination field to be modified, the supported fields as
4251    ``enum rte_flow_field_id`` listed.
4252  - ``dst_level``: destination field level.
4253  - ``dst_tag_index``: destination field tag array.
4254  - ``dst_type_id``: destination field type ID.
4255  - ``dst_class``: destination field class ID.
4256  - ``dst_offset``: destination field bit offset.
4257  - ``src_type``: the modify source field, the supported fields as
4258    ``enum rte_flow_field_id`` listed.
4259  - ``src_level``: source field level.
4260  - ``src_tag_index``: source field tag array.
4261  - ``src_type_id``: source field type ID.
4262  - ``src_class``: source field class ID.
4263  - ``src_offset``: source field bit offset.
4264  - ``src_value``: source immediate value.
4265  - ``src_ptr``: pointer to source immediate value.
4266  - ``width``: number of bits to copy.
4267
4268- ``nat64``: NAT64 IP headers translation
4269
4270  - ``type {unsigned}``: NAT64 translation type
4271
4272Destroying flow rules
4273~~~~~~~~~~~~~~~~~~~~~
4274
4275``flow destroy`` destroys one or more rules from their rule ID (as returned
4276by ``flow create``), this command calls ``rte_flow_destroy()`` as many
4277times as necessary::
4278
4279   flow destroy {port_id} rule {rule_id} [...] [user_id]
4280
4281If successful, it will show::
4282
4283   Flow rule #[...] destroyed
4284
4285Or if ``user_id`` flag is provided::
4286
4287   Flow rule #[...] destroyed, user-id [...]
4288
4289Optional ``user_id`` is a flag that signifies the rule ID
4290is the one provided by the user at creation.
4291It does not report anything for rule IDs that do not exist. The usual error
4292message is shown when a rule cannot be destroyed::
4293
4294   Caught error type [...] ([...]): [...]
4295
4296``flow flush`` destroys all rules on a device and does not take extra
4297arguments. It is bound to ``rte_flow_flush()``::
4298
4299   flow flush {port_id}
4300
4301Any errors are reported as above.
4302
4303Creating several rules and destroying them::
4304
4305   testpmd> flow create 0 ingress pattern eth / ipv6 / end
4306      actions queue index 2 / end
4307   Flow rule #0 created
4308   testpmd> flow create 0 ingress pattern eth / ipv4 / end
4309      actions queue index 3 / end
4310   Flow rule #1 created
4311   testpmd> flow destroy 0 rule 0 rule 1
4312   Flow rule #1 destroyed
4313   Flow rule #0 destroyed
4314   testpmd>
4315
4316The same result can be achieved using ``flow flush``::
4317
4318   testpmd> flow create 0 ingress pattern eth / ipv6 / end
4319      actions queue index 2 / end
4320   Flow rule #0 created
4321   testpmd> flow create 0 ingress pattern eth / ipv4 / end
4322      actions queue index 3 / end
4323   Flow rule #1 created
4324   testpmd> flow flush 0
4325   testpmd>
4326
4327Non-existent rule IDs are ignored::
4328
4329   testpmd> flow create 0 ingress pattern eth / ipv6 / end
4330      actions queue index 2 / end
4331   Flow rule #0 created
4332   testpmd> flow create 0 ingress pattern eth / ipv4 / end
4333      actions queue index 3 / end
4334   Flow rule #1 created
4335   testpmd> flow destroy 0 rule 42 rule 10 rule 2
4336   testpmd>
4337   testpmd> flow destroy 0 rule 0
4338   Flow rule #0 destroyed
4339   testpmd>
4340
4341Updating flow rules with new actions
4342~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4343
4344``flow update`` updates a flow rule specified by a rule ID with a new action
4345list by making a call to ``rte_flow_actions_update()``::
4346
4347   flow update {port_id} {rule_id}
4348       actions {action} [/ {action} [...]] / end [user_id]
4349
4350If successful, it will show::
4351
4352   Flow rule #[...] updated with new actions
4353
4354Or if ``user_id`` flag is provided::
4355
4356   Flow rule #[...] updated with new actions, user-id [...]
4357
4358If a flow rule can not be found::
4359
4360   Failed to find flow [...]
4361
4362Otherwise it will show the usual error message of the form::
4363
4364   Caught error type [...] ([...]): [...]
4365
4366Optional ``user_id`` is a flag that signifies the rule ID is the one provided
4367by the user at creation.
4368
4369Action list is identical to the one described for the ``flow create``.
4370
4371Creating, updating and destroying a flow rule::
4372
4373   testpmd> flow create 0 group 1 pattern eth / end actions drop / end
4374   Flow rule #0 created
4375   testpmd> flow update 0 0 actions queue index 1 / end
4376   Flow rule #0 updated with new actions
4377   testpmd> flow destroy 0 rule 0
4378   Flow rule #0 destroyed
4379
4380Enqueueing destruction of flow rules
4381~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4382
4383``flow queue destroy`` adds destruction operations to destroy one or more rules
4384from their rule ID (as returned by ``flow queue create``) to a queue,
4385this command calls ``rte_flow_async_destroy()`` as many times as necessary::
4386
4387   flow queue {port_id} destroy {queue_id}
4388        [postpone {boolean}] rule {rule_id} [...]
4389
4390If successful, it will show::
4391
4392   Flow rule #[...] destruction enqueued
4393
4394It does not report anything for rule IDs that do not exist. The usual error
4395message is shown when a rule cannot be destroyed::
4396
4397   Caught error type [...] ([...]): [...]
4398
4399``flow queue pull`` must be called to retrieve the operation status.
4400
4401Querying flow rules
4402~~~~~~~~~~~~~~~~~~~
4403
4404``flow query`` queries a specific action of a flow rule having that
4405ability. Such actions collect information that can be reported using this
4406command. It is bound to ``rte_flow_query()``::
4407
4408   flow query {port_id} {rule_id} {action} [user_id]
4409
4410Optional ``user_id`` is a flag that signifies the rule ID
4411is the one provided by the user at creation.
4412If successful, it will display either the retrieved data for known actions
4413or the following message::
4414
4415   Cannot display result for action type [...] ([...])
4416
4417Otherwise, it will complain either that the rule does not exist or that some
4418error occurred::
4419
4420   Flow rule #[...] not found
4421
4422::
4423
4424   Caught error type [...] ([...]): [...]
4425
4426Currently only the ``count`` action is supported. This action reports the
4427number of packets that hit the flow rule and the total number of bytes. Its
4428output has the following format::
4429
4430   count:
4431    hits_set: [...] # whether "hits" contains a valid value
4432    bytes_set: [...] # whether "bytes" contains a valid value
4433    hits: [...] # number of packets
4434    bytes: [...] # number of bytes
4435
4436Querying counters for TCPv6 packets redirected to queue 6::
4437
4438   testpmd> flow create 0 ingress pattern eth / ipv6 / tcp / end
4439      actions queue index 6 / count / end
4440   Flow rule #4 created
4441   testpmd> flow query 0 4 count
4442   count:
4443    hits_set: 1
4444    bytes_set: 0
4445    hits: 386446
4446    bytes: 0
4447   testpmd>
4448
4449Listing flow rules
4450~~~~~~~~~~~~~~~~~~
4451
4452``flow list`` lists existing flow rules sorted by priority and optionally
4453filtered by group identifiers::
4454
4455   flow list {port_id} [group {group_id}] [...]
4456
4457This command only fails with the following message if the device does not
4458exist::
4459
4460   Invalid port [...]
4461
4462Output consists of a header line followed by a short description of each
4463flow rule, one per line. There is no output at all when no flow rules are
4464configured on the device::
4465
4466   ID      Group   Prio    Attr    Rule
4467   [...]   [...]   [...]   [...]   [...]
4468
4469``Attr`` column flags:
4470
4471- ``i`` for ``ingress``.
4472- ``e`` for ``egress``.
4473
4474Creating several flow rules and listing them::
4475
4476   testpmd> flow create 0 ingress pattern eth / ipv4 / end
4477      actions queue index 6 / end
4478   Flow rule #0 created
4479   testpmd> flow create 0 ingress pattern eth / ipv6 / end
4480      actions queue index 2 / end
4481   Flow rule #1 created
4482   testpmd> flow create 0 priority 5 ingress pattern eth / ipv4 / udp / end
4483      actions rss queues 6 7 8 end / end
4484   Flow rule #2 created
4485   testpmd> flow list 0
4486   ID      Group   Prio    Attr    Rule
4487   0       0       0       i-      ETH IPV4 => QUEUE
4488   1       0       0       i-      ETH IPV6 => QUEUE
4489   2       0       5       i-      ETH IPV4 UDP => RSS
4490   testpmd>
4491
4492Rules are sorted by priority (i.e. group ID first, then priority level)::
4493
4494   testpmd> flow list 1
4495   ID      Group   Prio    Attr    Rule
4496   0       0       0       i-      ETH => COUNT
4497   6       0       500     i-      ETH IPV6 TCP => DROP COUNT
4498   5       0       1000    i-      ETH IPV6 ICMP => QUEUE
4499   1       24      0       i-      ETH IPV4 UDP => QUEUE
4500   4       24      10      i-      ETH IPV4 TCP => DROP
4501   3       24      20      i-      ETH IPV4 => DROP
4502   2       24      42      i-      ETH IPV4 UDP => QUEUE
4503   7       63      0       i-      ETH IPV6 UDP VXLAN => MARK QUEUE
4504   testpmd>
4505
4506Output can be limited to specific groups::
4507
4508   testpmd> flow list 1 group 0 group 63
4509   ID      Group   Prio    Attr    Rule
4510   0       0       0       i-      ETH => COUNT
4511   6       0       500     i-      ETH IPV6 TCP => DROP COUNT
4512   5       0       1000    i-      ETH IPV6 ICMP => QUEUE
4513   7       63      0       i-      ETH IPV6 UDP VXLAN => MARK QUEUE
4514   testpmd>
4515
4516Toggling isolated mode
4517~~~~~~~~~~~~~~~~~~~~~~
4518
4519``flow isolate`` can be used to tell the underlying PMD that ingress traffic
4520must only be injected from the defined flow rules; that no default traffic
4521is expected outside those rules and the driver is free to assign more
4522resources to handle them. It is bound to ``rte_flow_isolate()``::
4523
4524 flow isolate {port_id} {boolean}
4525
4526If successful, enabling or disabling isolated mode shows either::
4527
4528 Ingress traffic on port [...]
4529    is now restricted to the defined flow rules
4530
4531Or::
4532
4533 Ingress traffic on port [...]
4534    is not restricted anymore to the defined flow rules
4535
4536Otherwise, in case of error::
4537
4538   Caught error type [...] ([...]): [...]
4539
4540Mainly due to its side effects, PMDs supporting this mode may not have the
4541ability to toggle it more than once without reinitializing affected ports
4542first (e.g. by exiting testpmd).
4543
4544Enabling isolated mode::
4545
4546 testpmd> flow isolate 0 true
4547 Ingress traffic on port 0 is now restricted to the defined flow rules
4548 testpmd>
4549
4550Disabling isolated mode::
4551
4552 testpmd> flow isolate 0 false
4553 Ingress traffic on port 0 is not restricted anymore to the defined flow rules
4554 testpmd>
4555
4556Dumping HW internal information
4557~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4558
4559``flow dump`` dumps the hardware's internal representation information of
4560all flows. It is bound to ``rte_flow_dev_dump()``::
4561
4562   flow dump {port_id} {output_file} [user_id]
4563
4564If successful, it will show::
4565
4566   Flow dump finished
4567
4568Otherwise, it will complain error occurred::
4569
4570   Caught error type [...] ([...]): [...]
4571
4572Optional ``user_id`` is a flag that signifies the rule ID
4573is the one provided by the user at creation.
4574
4575Listing and destroying aged flow rules
4576~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4577
4578``flow aged`` simply lists aged flow rules be get from api ``rte_flow_get_aged_flows``,
4579and ``destroy`` parameter can be used to destroy those flow rules in PMD::
4580
4581   flow aged {port_id} [destroy]
4582
4583Listing current aged flow rules::
4584
4585   testpmd> flow aged 0
4586   Port 0 total aged flows: 0
4587   testpmd> flow create 0 ingress pattern eth / ipv4 src is 2.2.2.14 / end
4588      actions age timeout 5 / queue index 0 /  end
4589   Flow rule #0 created
4590   testpmd> flow create 0 ingress pattern eth / ipv4 src is 2.2.2.15 / end
4591      actions age timeout 4 / queue index 0 /  end
4592   Flow rule #1 created
4593   testpmd> flow create 0 ingress pattern eth / ipv4 src is 2.2.2.16 / end
4594      actions age timeout 2 / queue index 0 /  end
4595   Flow rule #2 created
4596   testpmd> flow create 0 ingress pattern eth / ipv4 src is 2.2.2.17 / end
4597      actions age timeout 3 / queue index 0 /  end
4598   Flow rule #3 created
4599
4600
4601Aged Rules are simply list as command ``flow list {port_id}``, but strip the detail rule
4602information, all the aged flows are sorted by the longest timeout time. For example, if
4603those rules be configured in the same time, ID 2 will be the first aged out rule, the next
4604will be ID 3, ID 1, ID 0::
4605
4606   testpmd> flow aged 0
4607   Port 0 total aged flows: 4
4608   ID      Group   Prio    Attr
4609   2       0       0       i--
4610   3       0       0       i--
4611   1       0       0       i--
4612   0       0       0       i--
4613
4614If attach ``destroy`` parameter, the command will destroy all the list aged flow rules::
4615
4616   testpmd> flow aged 0 destroy
4617   Port 0 total aged flows: 4
4618   ID      Group   Prio    Attr
4619   2       0       0       i--
4620   3       0       0       i--
4621   1       0       0       i--
4622   0       0       0       i--
4623
4624   Flow rule #2 destroyed
4625   Flow rule #3 destroyed
4626   Flow rule #1 destroyed
4627   Flow rule #0 destroyed
4628   4 flows be destroyed
4629   testpmd> flow aged 0
4630   Port 0 total aged flows: 0
4631
4632
4633Enqueueing listing and destroying aged flow rules
4634~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4635
4636``flow queue aged`` simply lists aged flow rules be get from
4637``rte_flow_get_q_aged_flows`` API, and ``destroy`` parameter can be used to
4638destroy those flow rules in PMD::
4639
4640   flow queue {port_id} aged {queue_id} [destroy]
4641
4642Listing current aged flow rules::
4643
4644   testpmd> flow queue 0 aged 0
4645   Port 0 queue 0 total aged flows: 0
4646   testpmd> flow queue 0 create 0 ingress tanle 0 item_template 0 action_template 0
4647      pattern eth / ipv4 src is 2.2.2.14 / end
4648      actions age timeout 5 / queue index 0 /  end
4649   Flow rule #0 creation enqueued
4650   testpmd> flow queue 0 create 0 ingress tanle 0 item_template 0 action_template 0
4651      pattern eth / ipv4 src is 2.2.2.15 / end
4652      actions age timeout 4 / queue index 0 /  end
4653   Flow rule #1 creation enqueued
4654   testpmd> flow queue 0 create 0 ingress tanle 0 item_template 0 action_template 0
4655      pattern eth / ipv4 src is 2.2.2.16 / end
4656      actions age timeout 4 / queue index 0 /  end
4657   Flow rule #2 creation enqueued
4658   testpmd> flow queue 0 create 0 ingress tanle 0 item_template 0 action_template 0
4659      pattern eth / ipv4 src is 2.2.2.17 / end
4660      actions age timeout 4 / queue index 0 /  end
4661   Flow rule #3 creation enqueued
4662   testpmd> flow pull 0 queue 0
4663   Queue #0 pulled 4 operations (0 failed, 4 succeeded)
4664
4665Aged Rules are simply list as command ``flow queue {port_id} list {queue_id}``,
4666but strip the detail rule information, all the aged flows are sorted by the
4667longest timeout time. For example, if those rules is configured in the same time,
4668ID 2 will be the first aged out rule, the next will be ID 3, ID 1, ID 0::
4669
4670   testpmd> flow queue 0 aged 0
4671   Port 0 queue 0 total aged flows: 4
4672   ID      Group   Prio    Attr
4673   2       0       0       ---
4674   3       0       0       ---
4675   1       0       0       ---
4676   0       0       0       ---
4677
4678   0 flows destroyed
4679
4680If attach ``destroy`` parameter, the command will destroy all the list aged flow rules::
4681
4682   testpmd> flow queue 0 aged 0 destroy
4683   Port 0 queue 0 total aged flows: 4
4684   ID      Group   Prio    Attr
4685   2       0       0       ---
4686   3       0       0       ---
4687   1       0       0       ---
4688   0       0       0       ---
4689   Flow rule #2 destruction enqueued
4690   Flow rule #3 destruction enqueued
4691   Flow rule #1 destruction enqueued
4692   Flow rule #0 destruction enqueued
4693
4694   4 flows destroyed
4695   testpmd> flow queue 0 aged 0
4696   Port 0 total aged flows: 0
4697
4698.. note::
4699
4700   The queue must be empty before attaching ``destroy`` parameter.
4701
4702
4703Creating indirect actions
4704~~~~~~~~~~~~~~~~~~~~~~~~~
4705
4706``flow indirect_action {port_id} create`` creates indirect action with optional
4707indirect action ID. It is bound to ``rte_flow_action_handle_create()``::
4708
4709   flow indirect_action {port_id} create [action_id {indirect_action_id}]
4710      [ingress] [egress] [transfer] action {action} / end
4711
4712If successful, it will show::
4713
4714   Indirect action #[...] created
4715
4716Otherwise, it will complain either that indirect action already exists or that
4717some error occurred::
4718
4719   Indirect action #[...] is already assigned, delete it first
4720
4721::
4722
4723   Caught error type [...] ([...]): [...]
4724
4725Create indirect rss action with id 100 to queues 1 and 2 on port 0::
4726
4727   testpmd> flow indirect_action 0 create action_id 100 \
4728      ingress action rss queues 1 2 end / end
4729
4730Create indirect rss action with id assigned by testpmd to queues 1 and 2 on
4731port 0::
4732
4733	testpmd> flow indirect_action 0 create action_id \
4734		ingress action rss queues 0 1 end / end
4735
4736Enqueueing creation of indirect actions
4737~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4738
4739``flow queue indirect_action create`` adds creation operation of an indirect
4740action to a queue. It is bound to ``rte_flow_async_action_handle_create()``::
4741
4742   flow queue {port_id} create {queue_id} [postpone {boolean}]
4743       table {table_id} item_template {item_template_id}
4744       action_template {action_template_id}
4745       pattern {item} [/ {item} [...]] / end
4746       actions {action} [/ {action} [...]] / end
4747
4748If successful, it will show::
4749
4750   Indirect action #[...] creation queued
4751
4752Otherwise it will show an error message of the form::
4753
4754   Caught error type [...] ([...]): [...]
4755
4756This command uses the same parameters as  ``flow indirect_action create``,
4757described in `Creating indirect actions`_.
4758
4759``flow queue pull`` must be called to retrieve the operation status.
4760
4761Updating indirect actions
4762~~~~~~~~~~~~~~~~~~~~~~~~~
4763
4764``flow indirect_action {port_id} update`` updates configuration of the indirect
4765action from its indirect action ID (as returned by
4766``flow indirect_action {port_id} create``). It is bound to
4767``rte_flow_action_handle_update()``::
4768
4769   flow indirect_action {port_id} update {indirect_action_id}
4770      action {action} / end
4771
4772If successful, it will show::
4773
4774   Indirect action #[...] updated
4775
4776Otherwise, it will complain either that indirect action not found or that some
4777error occurred::
4778
4779   Failed to find indirect action #[...] on port [...]
4780
4781::
4782
4783   Caught error type [...] ([...]): [...]
4784
4785Update indirect rss action having id 100 on port 0 with rss to queues 0 and 3
4786(in create example above rss queues were 1 and 2)::
4787
4788   testpmd> flow indirect_action 0 update 100 action rss queues 0 3 end / end
4789
4790Enqueueing update of indirect actions
4791~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4792
4793``flow queue indirect_action update`` adds update operation for an indirect
4794action to a queue. It is bound to ``rte_flow_async_action_handle_update()``::
4795
4796   flow queue {port_id} indirect_action {queue_id} update
4797      {indirect_action_id} [postpone {boolean}] action {action} / end
4798
4799If successful, it will show::
4800
4801   Indirect action #[...] update queued
4802
4803Otherwise it will show an error message of the form::
4804
4805   Caught error type [...] ([...]): [...]
4806
4807``flow queue pull`` must be called to retrieve the operation status.
4808
4809Destroying indirect actions
4810~~~~~~~~~~~~~~~~~~~~~~~~~~~
4811
4812``flow indirect_action {port_id} destroy`` destroys one or more indirect actions
4813from their indirect action IDs (as returned by
4814``flow indirect_action {port_id} create``). It is bound to
4815``rte_flow_action_handle_destroy()``::
4816
4817   flow indirect_action {port_id} destroy action_id {indirect_action_id} [...]
4818
4819If successful, it will show::
4820
4821   Indirect action #[...] destroyed
4822
4823It does not report anything for indirect action IDs that do not exist.
4824The usual error message is shown when a indirect action cannot be destroyed::
4825
4826   Caught error type [...] ([...]): [...]
4827
4828Destroy indirect actions having id 100 & 101::
4829
4830   testpmd> flow indirect_action 0 destroy action_id 100 action_id 101
4831
4832Enqueueing destruction of indirect actions
4833~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4834
4835``flow queue indirect_action destroy`` adds destruction operation to destroy
4836one or more indirect actions from their indirect action IDs (as returned by
4837``flow queue {port_id} indirect_action {queue_id} create``) to a queue.
4838It is bound to ``rte_flow_async_action_handle_destroy()``::
4839
4840   flow queue {port_id} indirect_action {queue_id} destroy
4841      [postpone {boolean}] action_id {indirect_action_id} [...]
4842
4843If successful, it will show::
4844
4845   Indirect action #[...] destruction queued
4846
4847Otherwise it will show an error message of the form::
4848
4849   Caught error type [...] ([...]): [...]
4850
4851``flow queue pull`` must be called to retrieve the operation status.
4852
4853Query indirect actions
4854~~~~~~~~~~~~~~~~~~~~~~
4855
4856``flow indirect_action {port_id} query`` queries the indirect action from its
4857indirect action ID (as returned by ``flow indirect_action {port_id} create``).
4858It is bound to ``rte_flow_action_handle_query()``::
4859
4860  flow indirect_action {port_id} query {indirect_action_id}
4861
4862Currently only rss indirect action supported. If successful, it will show::
4863
4864   Indirect RSS action:
4865      refs:[...]
4866
4867Otherwise, it will complain either that indirect action not found or that some
4868error occurred::
4869
4870   Failed to find indirect action #[...] on port [...]
4871
4872::
4873
4874   Caught error type [...] ([...]): [...]
4875
4876Query indirect action having id 100::
4877
4878   testpmd> flow indirect_action 0 query 100
4879
4880Enqueueing query of indirect actions
4881~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4882
4883``flow queue indirect_action query`` adds query operation for an indirect
4884action to a queue. It is bound to ``rte_flow_async_action_handle_query()``::
4885
4886   flow queue {port_id} indirect_action {queue_id} query
4887      {indirect_action_id} [postpone {boolean}]
4888
4889If successful, it will show::
4890
4891   Indirect action #[...] query queued
4892
4893Otherwise it will show an error message of the form::
4894
4895   Caught error type [...] ([...]): [...]
4896
4897``flow queue pull`` must be called to retrieve the operation status.
4898
4899Sample QinQ flow rules
4900~~~~~~~~~~~~~~~~~~~~~~
4901
4902Before creating QinQ rule(s) the following commands should be issued to enable QinQ::
4903
4904   testpmd> port stop 0
4905   testpmd> vlan set extend on 0
4906
4907The above command sets the inner and outer TPID's to 0x8100.
4908
4909To change the TPID's the following commands should be used::
4910
4911   testpmd> vlan set outer tpid 0x88A8 0
4912   testpmd> vlan set inner tpid 0x8100 0
4913   testpmd> port start 0
4914
4915Validate and create a QinQ rule on port 0 to steer traffic to a VF queue in a VM.
4916
4917::
4918
4919   testpmd> flow validate 0 ingress pattern eth / vlan tci is 123 /
4920       vlan tci is 456 / end actions vf id 1 / queue index 0 / end
4921   Flow rule #0 validated
4922
4923   testpmd> flow create 0 ingress pattern eth / vlan tci is 4 /
4924       vlan tci is 456 / end actions vf id 123 / queue index 0 / end
4925   Flow rule #0 created
4926
4927   testpmd> flow list 0
4928   ID      Group   Prio    Attr    Rule
4929   0       0       0       i-      ETH VLAN VLAN=>VF QUEUE
4930
4931Validate and create a QinQ rule on port 0 to steer traffic to a queue on the host.
4932
4933::
4934
4935   testpmd> flow validate 0 ingress pattern eth / vlan tci is 321 /
4936        vlan tci is 654 / end actions pf / queue index 0 / end
4937   Flow rule #1 validated
4938
4939   testpmd> flow create 0 ingress pattern eth / vlan tci is 321 /
4940        vlan tci is 654 / end actions pf / queue index 1 / end
4941   Flow rule #1 created
4942
4943   testpmd> flow list 0
4944   ID      Group   Prio    Attr    Rule
4945   0       0       0       i-      ETH VLAN VLAN=>VF QUEUE
4946   1       0       0       i-      ETH VLAN VLAN=>PF QUEUE
4947
4948Sample VXLAN flow rules
4949~~~~~~~~~~~~~~~~~~~~~~~
4950
4951Before creating VXLAN rule(s), the UDP port should be added for VXLAN packet
4952filter on a port::
4953
4954  testpmd> rx_vxlan_port add 4789 0
4955
4956Create VXLAN rules on port 0 to steer traffic to PF queues.
4957
4958::
4959
4960  testpmd> flow create 0 ingress pattern eth / ipv4 / udp / vxlan /
4961         eth dst is 00:11:22:33:44:55 / end actions pf / queue index 1 / end
4962  Flow rule #0 created
4963
4964  testpmd> flow create 0 ingress pattern eth / ipv4 / udp / vxlan vni is 3 /
4965         eth dst is 00:11:22:33:44:55 / end actions pf / queue index 2 / end
4966  Flow rule #1 created
4967
4968  testpmd> flow create 0 ingress pattern eth / ipv4 / udp / vxlan /
4969         eth dst is 00:11:22:33:44:55 / vlan tci is 10 / end actions pf /
4970         queue index 3 / end
4971  Flow rule #2 created
4972
4973  testpmd> flow create 0 ingress pattern eth / ipv4 / udp / vxlan vni is 5 /
4974         eth dst is 00:11:22:33:44:55 / vlan tci is 20 / end actions pf /
4975         queue index 4 / end
4976  Flow rule #3 created
4977
4978  testpmd> flow create 0 ingress pattern eth dst is 00:00:00:00:01:00 / ipv4 /
4979         udp / vxlan vni is 6 /  eth dst is 00:11:22:33:44:55 / end actions pf /
4980         queue index 5 / end
4981  Flow rule #4 created
4982
4983  testpmd> flow list 0
4984  ID      Group   Prio    Attr    Rule
4985  0       0       0       i-      ETH IPV4 UDP VXLAN ETH => QUEUE
4986  1       0       0       i-      ETH IPV4 UDP VXLAN ETH => QUEUE
4987  2       0       0       i-      ETH IPV4 UDP VXLAN ETH VLAN => QUEUE
4988  3       0       0       i-      ETH IPV4 UDP VXLAN ETH VLAN => QUEUE
4989  4       0       0       i-      ETH IPV4 UDP VXLAN ETH => QUEUE
4990
4991Sample VXLAN encapsulation rule
4992~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4993
4994VXLAN encapsulation outer layer has default value pre-configured in testpmd
4995source code, those can be changed by using the following commands
4996
4997IPv4 VXLAN outer header::
4998
4999 testpmd> set vxlan ip-version ipv4 vni 4 udp-src 4 udp-dst 4 ip-src 127.0.0.1
5000        ip-dst 128.0.0.1 eth-src 11:11:11:11:11:11 eth-dst 22:22:22:22:22:22
5001 testpmd> flow create 0 ingress pattern end actions vxlan_encap /
5002        queue index 0 / end
5003
5004 testpmd> set vxlan-with-vlan ip-version ipv4 vni 4 udp-src 4 udp-dst 4 ip-src
5005         127.0.0.1 ip-dst 128.0.0.1 vlan-tci 34 eth-src 11:11:11:11:11:11
5006         eth-dst 22:22:22:22:22:22
5007 testpmd> flow create 0 ingress pattern end actions vxlan_encap /
5008         queue index 0 / end
5009
5010 testpmd> set vxlan-tos-ttl ip-version ipv4 vni 4 udp-src 4 udp-dst 4 ip-tos 0
5011         ip-ttl 255 ip-src 127.0.0.1 ip-dst 128.0.0.1 eth-src 11:11:11:11:11:11
5012         eth-dst 22:22:22:22:22:22
5013 testpmd> flow create 0 ingress pattern end actions vxlan_encap /
5014         queue index 0 / end
5015
5016IPv6 VXLAN outer header::
5017
5018 testpmd> set vxlan ip-version ipv6 vni 4 udp-src 4 udp-dst 4 ip-src ::1
5019        ip-dst ::2222 eth-src 11:11:11:11:11:11 eth-dst 22:22:22:22:22:22
5020 testpmd> flow create 0 ingress pattern end actions vxlan_encap /
5021         queue index 0 / end
5022
5023 testpmd> set vxlan-with-vlan ip-version ipv6 vni 4 udp-src 4 udp-dst 4
5024         ip-src ::1 ip-dst ::2222 vlan-tci 34 eth-src 11:11:11:11:11:11
5025         eth-dst 22:22:22:22:22:22
5026 testpmd> flow create 0 ingress pattern end actions vxlan_encap /
5027         queue index 0 / end
5028
5029 testpmd> set vxlan-tos-ttl ip-version ipv6 vni 4 udp-src 4 udp-dst 4
5030         ip-tos 0 ip-ttl 255 ::1 ip-dst ::2222 eth-src 11:11:11:11:11:11
5031         eth-dst 22:22:22:22:22:22
5032 testpmd> flow create 0 ingress pattern end actions vxlan_encap /
5033         queue index 0 / end
5034
5035Sample NVGRE encapsulation rule
5036~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5037
5038NVGRE encapsulation outer layer has default value pre-configured in testpmd
5039source code, those can be changed by using the following commands
5040
5041IPv4 NVGRE outer header::
5042
5043 testpmd> set nvgre ip-version ipv4 tni 4 ip-src 127.0.0.1 ip-dst 128.0.0.1
5044        eth-src 11:11:11:11:11:11 eth-dst 22:22:22:22:22:22
5045 testpmd> flow create 0 ingress pattern end actions nvgre_encap /
5046        queue index 0 / end
5047
5048 testpmd> set nvgre-with-vlan ip-version ipv4 tni 4 ip-src 127.0.0.1
5049         ip-dst 128.0.0.1 vlan-tci 34 eth-src 11:11:11:11:11:11
5050         eth-dst 22:22:22:22:22:22
5051 testpmd> flow create 0 ingress pattern end actions nvgre_encap /
5052         queue index 0 / end
5053
5054IPv6 NVGRE outer header::
5055
5056 testpmd> set nvgre ip-version ipv6 tni 4 ip-src ::1 ip-dst ::2222
5057        eth-src 11:11:11:11:11:11 eth-dst 22:22:22:22:22:22
5058 testpmd> flow create 0 ingress pattern end actions nvgre_encap /
5059        queue index 0 / end
5060
5061 testpmd> set nvgre-with-vlan ip-version ipv6 tni 4 ip-src ::1 ip-dst ::2222
5062        vlan-tci 34 eth-src 11:11:11:11:11:11 eth-dst 22:22:22:22:22:22
5063 testpmd> flow create 0 ingress pattern end actions nvgre_encap /
5064        queue index 0 / end
5065
5066Sample L2 encapsulation rule
5067~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5068
5069L2 encapsulation has default value pre-configured in testpmd
5070source code, those can be changed by using the following commands
5071
5072L2 header::
5073
5074 testpmd> set l2_encap ip-version ipv4
5075        eth-src 11:11:11:11:11:11 eth-dst 22:22:22:22:22:22
5076 testpmd> flow create 0 ingress pattern eth / ipv4 / udp / mpls / end actions
5077        mplsoudp_decap / l2_encap / end
5078
5079L2 with VXLAN header::
5080
5081 testpmd> set l2_encap-with-vlan ip-version ipv4 vlan-tci 34
5082         eth-src 11:11:11:11:11:11 eth-dst 22:22:22:22:22:22
5083 testpmd> flow create 0 ingress pattern eth / ipv4 / udp / mpls / end actions
5084        mplsoudp_decap / l2_encap / end
5085
5086Sample L2 decapsulation rule
5087~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5088
5089L2 decapsulation has default value pre-configured in testpmd
5090source code, those can be changed by using the following commands
5091
5092L2 header::
5093
5094 testpmd> set l2_decap
5095 testpmd> flow create 0 egress pattern eth / end actions l2_decap / mplsoudp_encap /
5096        queue index 0 / end
5097
5098L2 with VXLAN header::
5099
5100 testpmd> set l2_encap-with-vlan
5101 testpmd> flow create 0 egress pattern eth / end actions l2_encap / mplsoudp_encap /
5102         queue index 0 / end
5103
5104Sample MPLSoGRE encapsulation rule
5105~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5106
5107MPLSoGRE encapsulation outer layer has default value pre-configured in testpmd
5108source code, those can be changed by using the following commands
5109
5110IPv4 MPLSoGRE outer header::
5111
5112 testpmd> set mplsogre_encap ip-version ipv4 label 4
5113        ip-src 127.0.0.1 ip-dst 128.0.0.1 eth-src 11:11:11:11:11:11
5114        eth-dst 22:22:22:22:22:22
5115 testpmd> flow create 0 egress pattern eth / end actions l2_decap /
5116        mplsogre_encap / end
5117
5118IPv4 MPLSoGRE with VLAN outer header::
5119
5120 testpmd> set mplsogre_encap-with-vlan ip-version ipv4 label 4
5121        ip-src 127.0.0.1 ip-dst 128.0.0.1 vlan-tci 34
5122        eth-src 11:11:11:11:11:11 eth-dst 22:22:22:22:22:22
5123 testpmd> flow create 0 egress pattern eth / end actions l2_decap /
5124        mplsogre_encap / end
5125
5126IPv6 MPLSoGRE outer header::
5127
5128 testpmd> set mplsogre_encap ip-version ipv6 mask 4
5129        ip-src ::1 ip-dst ::2222 eth-src 11:11:11:11:11:11
5130        eth-dst 22:22:22:22:22:22
5131 testpmd> flow create 0 egress pattern eth / end actions l2_decap /
5132        mplsogre_encap / end
5133
5134IPv6 MPLSoGRE with VLAN outer header::
5135
5136 testpmd> set mplsogre_encap-with-vlan ip-version ipv6 mask 4
5137        ip-src ::1 ip-dst ::2222 vlan-tci 34
5138        eth-src 11:11:11:11:11:11 eth-dst 22:22:22:22:22:22
5139 testpmd> flow create 0 egress pattern eth / end actions l2_decap /
5140        mplsogre_encap / end
5141
5142Sample MPLSoGRE decapsulation rule
5143~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5144
5145MPLSoGRE decapsulation outer layer has default value pre-configured in testpmd
5146source code, those can be changed by using the following commands
5147
5148IPv4 MPLSoGRE outer header::
5149
5150 testpmd> set mplsogre_decap ip-version ipv4
5151 testpmd> flow create 0 ingress pattern eth / ipv4 / gre / mpls / end actions
5152        mplsogre_decap / l2_encap / end
5153
5154IPv4 MPLSoGRE with VLAN outer header::
5155
5156 testpmd> set mplsogre_decap-with-vlan ip-version ipv4
5157 testpmd> flow create 0 ingress pattern eth / vlan / ipv4 / gre / mpls / end
5158        actions mplsogre_decap / l2_encap / end
5159
5160IPv6 MPLSoGRE outer header::
5161
5162 testpmd> set mplsogre_decap ip-version ipv6
5163 testpmd> flow create 0 ingress pattern eth / ipv6 / gre / mpls / end
5164        actions mplsogre_decap / l2_encap / end
5165
5166IPv6 MPLSoGRE with VLAN outer header::
5167
5168 testpmd> set mplsogre_decap-with-vlan ip-version ipv6
5169 testpmd> flow create 0 ingress pattern eth / vlan / ipv6 / gre / mpls / end
5170        actions mplsogre_decap / l2_encap / end
5171
5172Sample MPLSoUDP encapsulation rule
5173~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5174
5175MPLSoUDP encapsulation outer layer has default value pre-configured in testpmd
5176source code, those can be changed by using the following commands
5177
5178IPv4 MPLSoUDP outer header::
5179
5180 testpmd> set mplsoudp_encap ip-version ipv4 label 4 udp-src 5 udp-dst 10
5181        ip-src 127.0.0.1 ip-dst 128.0.0.1 eth-src 11:11:11:11:11:11
5182        eth-dst 22:22:22:22:22:22
5183 testpmd> flow create 0 egress pattern eth / end actions l2_decap /
5184        mplsoudp_encap / end
5185
5186IPv4 MPLSoUDP with VLAN outer header::
5187
5188 testpmd> set mplsoudp_encap-with-vlan ip-version ipv4 label 4 udp-src 5
5189        udp-dst 10 ip-src 127.0.0.1 ip-dst 128.0.0.1 vlan-tci 34
5190        eth-src 11:11:11:11:11:11 eth-dst 22:22:22:22:22:22
5191 testpmd> flow create 0 egress pattern eth / end actions l2_decap /
5192        mplsoudp_encap / end
5193
5194IPv6 MPLSoUDP outer header::
5195
5196 testpmd> set mplsoudp_encap ip-version ipv6 mask 4 udp-src 5 udp-dst 10
5197        ip-src ::1 ip-dst ::2222 eth-src 11:11:11:11:11:11
5198        eth-dst 22:22:22:22:22:22
5199 testpmd> flow create 0 egress pattern eth / end actions l2_decap /
5200        mplsoudp_encap / end
5201
5202IPv6 MPLSoUDP with VLAN outer header::
5203
5204 testpmd> set mplsoudp_encap-with-vlan ip-version ipv6 mask 4 udp-src 5
5205        udp-dst 10 ip-src ::1 ip-dst ::2222 vlan-tci 34
5206        eth-src 11:11:11:11:11:11 eth-dst 22:22:22:22:22:22
5207 testpmd> flow create 0 egress pattern eth / end actions l2_decap /
5208        mplsoudp_encap / end
5209
5210Sample MPLSoUDP decapsulation rule
5211~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5212
5213MPLSoUDP decapsulation outer layer has default value pre-configured in testpmd
5214source code, those can be changed by using the following commands
5215
5216IPv4 MPLSoUDP outer header::
5217
5218 testpmd> set mplsoudp_decap ip-version ipv4
5219 testpmd> flow create 0 ingress pattern eth / ipv4 / udp / mpls / end actions
5220        mplsoudp_decap / l2_encap / end
5221
5222IPv4 MPLSoUDP with VLAN outer header::
5223
5224 testpmd> set mplsoudp_decap-with-vlan ip-version ipv4
5225 testpmd> flow create 0 ingress pattern eth / vlan / ipv4 / udp / mpls / end
5226        actions mplsoudp_decap / l2_encap / end
5227
5228IPv6 MPLSoUDP outer header::
5229
5230 testpmd> set mplsoudp_decap ip-version ipv6
5231 testpmd> flow create 0 ingress pattern eth / ipv6 / udp / mpls / end
5232        actions mplsoudp_decap / l2_encap / end
5233
5234IPv6 MPLSoUDP with VLAN outer header::
5235
5236 testpmd> set mplsoudp_decap-with-vlan ip-version ipv6
5237 testpmd> flow create 0 ingress pattern eth / vlan / ipv6 / udp / mpls / end
5238        actions mplsoudp_decap / l2_encap / end
5239
5240Sample Raw encapsulation rule
5241~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5242
5243Raw encapsulation configuration can be set by the following commands
5244
5245Encapsulating VxLAN::
5246
5247 testpmd> set raw_encap 4 eth src is 10:11:22:33:44:55 / vlan tci is 1
5248        inner_type is 0x0800 / ipv4 / udp dst is 4789 / vxlan vni
5249        is 2 / end_set
5250 testpmd> flow create 0 egress pattern eth / ipv4 / end actions
5251        raw_encap index 4 / end
5252
5253Sample Raw decapsulation rule
5254~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5255
5256Raw decapsulation configuration can be set by the following commands
5257
5258Decapsulating VxLAN::
5259
5260 testpmd> set raw_decap eth / ipv4 / udp / vxlan / end_set
5261 testpmd> flow create 0 ingress pattern eth / ipv4 / udp / vxlan / eth / ipv4 /
5262        end actions raw_decap / queue index 0 / end
5263
5264Sample ESP rules
5265~~~~~~~~~~~~~~~~
5266
5267ESP rules can be created by the following commands::
5268
5269 testpmd> flow create 0 ingress pattern eth / ipv4 / esp spi is 1 / end actions
5270        queue index 3 / end
5271 testpmd> flow create 0 ingress pattern eth / ipv4 / udp / esp spi is 1 / end
5272        actions queue index 3 / end
5273 testpmd> flow create 0 ingress pattern eth / ipv6 / esp spi is 1 / end actions
5274        queue index 3 / end
5275 testpmd> flow create 0 ingress pattern eth / ipv6 / udp / esp spi is 1 / end
5276        actions queue index 3 / end
5277
5278Sample AH rules
5279~~~~~~~~~~~~~~~~
5280
5281AH rules can be created by the following commands::
5282
5283 testpmd> flow create 0 ingress pattern eth / ipv4 / ah spi is 1 / end actions
5284        queue index 3 / end
5285 testpmd> flow create 0 ingress pattern eth / ipv4 / udp / ah spi is 1 / end
5286        actions queue index 3 / end
5287 testpmd> flow create 0 ingress pattern eth / ipv6 / ah spi is 1 / end actions
5288        queue index 3 / end
5289 testpmd> flow create 0 ingress pattern eth / ipv6 / udp / ah spi is 1 / end
5290        actions queue index 3 / end
5291
5292Sample PFCP rules
5293~~~~~~~~~~~~~~~~~
5294
5295PFCP rules can be created by the following commands(s_field need to be 1
5296if seid is set)::
5297
5298 testpmd> flow create 0 ingress pattern eth / ipv4 / pfcp s_field is 0 / end
5299        actions queue index 3 / end
5300 testpmd> flow create 0 ingress pattern eth / ipv4 / pfcp s_field is 1
5301        seid is 1 / end actions queue index 3 / end
5302 testpmd> flow create 0 ingress pattern eth / ipv6 / pfcp s_field is 0 / end
5303        actions queue index 3 / end
5304 testpmd> flow create 0 ingress pattern eth / ipv6 / pfcp s_field is 1
5305        seid is 1 / end actions queue index 3 / end
5306
5307Sample Sampling/Mirroring rules
5308~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5309
5310Sample/Mirroring rules can be set by the following commands
5311
5312NIC-RX Sampling rule, the matched ingress packets and sent to the queue 1,
5313and 50% packets are duplicated and marked with 0x1234 and sent to queue 0.
5314
5315::
5316
5317 testpmd> set sample_actions 0 mark id  0x1234 / queue index 0 / end
5318 testpmd> flow create 0 ingress group 1 pattern eth / end actions
5319        sample ratio 2 index 0 / queue index 1 / end
5320
5321Match packets coming from a VM which is referred to by means of
5322its representor ethdev (port 1), mirror 50% of them to the
5323said representor (for bookkeeping) as well as encapsulate
5324all the packets and steer them to the physical port:
5325
5326::
5327
5328   testpmd> set sample_actions 0 port_representor ethdev_port_id 1 / end
5329
5330   testpmd> set vxlan ip-version ipv4 vni 4 udp-src 32 udp-dst 4789 ip-src 127.0.0.1
5331      ip-dst 127.0.0.2 eth-src 11:11:11:11:11:11 eth-dst 22:22:22:22:22:22
5332
5333   testpmd> flow create 0 transfer pattern represented_port ethdev_port_id is 1 / end
5334      actions sample ratio 2 index 0 / vxlan_encap /
5335      represented_port ethdev_port_id 0 / end
5336
5337The rule is inserted via port 0 (assumed to have "transfer" privilege).
5338
5339Sample integrity rules
5340~~~~~~~~~~~~~~~~~~~~~~
5341
5342Integrity rules can be created by the following commands:
5343
5344Integrity rule that forwards valid TCP packets to group 1.
5345TCP packet integrity is matched with the ``l4_ok`` bit 3.
5346
5347::
5348
5349 testpmd> flow create 0 ingress
5350            pattern eth / ipv4 / tcp / integrity value mask 8 value spec 8 / end
5351            actions jump group 1 / end
5352
5353Integrity rule that forwards invalid packets to application.
5354General packet integrity is matched with the ``packet_ok`` bit 0.
5355
5356::
5357
5358 testpmd> flow create 0 ingress pattern integrity value mask 1 value spec 0 / end actions queue index 0 / end
5359
5360Sample conntrack rules
5361~~~~~~~~~~~~~~~~~~~~~~
5362
5363Conntrack rules can be set by the following commands
5364
5365Need to construct the connection context with provided information.
5366In the first table, create a flow rule by using conntrack action and jump to
5367the next table. In the next table, create a rule to check the state.
5368
5369::
5370
5371 testpmd> set conntrack com peer 1 is_orig 1 enable 1 live 1 sack 1 cack 0
5372        last_dir 0 liberal 0 state 1 max_ack_win 7 r_lim 5 last_win 510
5373        last_seq 2632987379 last_ack 2532480967 last_end 2632987379
5374        last_index 0x8
5375 testpmd> set conntrack orig scale 7 fin 0 acked 1 unack_data 0
5376        sent_end 2632987379 reply_end 2633016339 max_win 28960
5377        max_ack 2632987379
5378 testpmd> set conntrack rply scale 7 fin 0 acked 1 unack_data 0
5379        sent_end 2532480967 reply_end 2532546247 max_win 65280
5380        max_ack 2532480967
5381 testpmd> flow indirect_action 0 create ingress action conntrack / end
5382 testpmd> flow create 0 group 3 ingress pattern eth / ipv4 / tcp / end actions indirect 0 / jump group 5 / end
5383 testpmd> flow create 0 group 5 ingress pattern eth / ipv4 / tcp / conntrack is 1 / end actions queue index 5 / end
5384
5385Construct the conntrack again with only "is_orig" set to 0 (other fields are
5386ignored), then use "update" interface to update the direction. Create flow
5387rules like above for the peer port.
5388
5389::
5390
5391 testpmd> flow indirect_action 0 update 0 action conntrack_update dir / end
5392
5393Sample meter with policy rules
5394~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5395
5396Meter with policy rules can be created by the following commands:
5397
5398Need to create policy first and actions are set for green/yellow/red colors.
5399Create meter with policy id. Create flow with meter id.
5400
5401Example for policy with meter color action. The purpose is to color the packet
5402to reflect the meter color result.
5403The meter policy action list: ``green -> green, yellow -> yellow, red -> red``.
5404
5405::
5406
5407   testpmd> add port meter profile srtcm_rfc2697 0 13 21504 2688 0 0
5408   testpmd> add port meter policy 0 1 g_actions color type green / end y_actions color type yellow / end
5409            r_actions color type red / end
5410   testpmd> create port meter 0 1 13 1 yes 0xffff 0 0
5411   testpmd> flow create 0 priority 0 ingress group 1 pattern eth / end actions meter mtr_id 1 / end
5412
5413Sample L2TPv2 RSS rules
5414~~~~~~~~~~~~~~~~~~~~~~~
5415
5416L2TPv2 RSS rules can be created by the following commands::
5417
5418   testpmd> flow create 0 ingress pattern eth / ipv4 / udp / l2tpv2 type control
5419            / end actions rss types l2tpv2 end queues end / end
5420   testpmd> flow create 0 ingress pattern eth / ipv4 / udp / l2tpv2 / end
5421            actions rss types eth l2-src-only end queues end / end
5422   testpmd> flow create 0 ingress pattern eth / ipv4 / udp / l2tpv2 / ppp / end
5423            actions rss types l2tpv2 end queues end / end
5424   testpmd> flow create 0 ingress pattern eth / ipv4 / udp / l2tpv2 / ppp / ipv4
5425            / end actions rss types ipv4 end queues end / end
5426   testpmd> flow create 0 ingress pattern eth / ipv4 / udp / l2tpv2 / ppp / ipv6
5427            / udp / end actions rss types ipv6-udp end queues end / end
5428   testpmd> flow create 0 ingress pattern eth / ipv6 / udp / l2tpv2 / ppp / ipv4
5429            / tcp / end actions rss types ipv4-tcp end queues end / end
5430   testpmd> flow create 0 ingress pattern eth / ipv6 / udp / l2tpv2 / ppp / ipv6
5431            / end actions rss types ipv6 end queues end / end
5432
5433Sample L2TPv2 FDIR rules
5434~~~~~~~~~~~~~~~~~~~~~~~~
5435
5436L2TPv2 FDIR rules can be created by the following commands::
5437
5438   testpmd> flow create 0 ingress pattern eth / ipv4 / udp / l2tpv2 type control
5439            session_id is 0x1111 / end actions queue index 3 / end
5440   testpmd> flow create 0 ingress pattern eth src is 00:00:00:00:00:01 / ipv4
5441            / udp / l2tpv2 type data / end actions queue index 3 / end
5442   testpmd> flow create 0 ingress pattern eth / ipv4 / udp / l2tpv2 type data
5443            session_id is 0x1111 / ppp / end actions queue index 3 / end
5444   testpmd> flow create 0 ingress pattern eth / ipv4 / udp / l2tpv2 / ppp / ipv4
5445            src is 10.0.0.1 / end actions queue index 3 / end
5446   testpmd> flow create 0 ingress pattern eth / ipv6 / udp / l2tpv2 / ppp / ipv6
5447            dst is ABAB:910B:6666:3457:8295:3333:1800:2929 / end actions queue index 3 / end
5448   testpmd> flow create 0 ingress pattern eth / ipv4 / udp / l2tpv2 / ppp / ipv4
5449            / udp src is 22 / end actions queue index 3 / end
5450   testpmd> flow create 0 ingress pattern eth / ipv4 / udp / l2tpv2 / ppp / ipv4
5451            / tcp dst is 23 / end actions queue index 3 / end
5452
5453Sample RAW rule
5454~~~~~~~~~~~~~~~
5455
5456A RAW rule can be created as following using ``pattern_hex`` key and mask.
5457
5458::
5459
5460    testpmd> flow create 0 group 0 priority 1 ingress pattern raw relative is 0 search is 0 offset
5461             is 0 limit is 0 pattern_hex spec 00000000000000000000000000000000000000000000000000000a0a0a0a
5462             pattern_hex mask 0000000000000000000000000000000000000000000000000000ffffffff / end actions
5463             queue index 4 / end
5464
5465Sample match with comparison rule
5466~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5467
5468Match with comparison rule can be created as following using ``compare``.
5469
5470::
5471
5472    testpmd> flow pattern_template 0 create ingress pattern_template_id 1 template compare op mask le
5473             a_type mask tag a_tag_index mask 1 b_type mask tag b_tag_index mask 2 width mask 0xffffffff / end
5474    testpmd> flow actions_template 0 create ingress actions_template_id 1 template count / drop / end
5475             mask count / drop  / end
5476    testpmd> flow template_table 0 create table_id 1 group 2 priority 1  ingress rules_number 1
5477             pattern_template 1 actions_template 1
5478    testpmd> flow queue 0 create 0 template_table 1 pattern_template 0 actions_template 0 postpone no
5479             pattern compare op is le a_type is tag a_tag_index is 1 b_type is tag b_tag_index is 2 width is 32 / end
5480	     actions count / drop / end
5481
5482BPF Functions
5483--------------
5484
5485The following sections show functions to load/unload eBPF based filters.
5486
5487bpf-load
5488~~~~~~~~
5489
5490Load an eBPF program as a callback for particular RX/TX queue::
5491
5492   testpmd> bpf-load rx|tx (portid) (queueid) (load-flags) (bpf-prog-filename)
5493
5494The available load-flags are:
5495
5496* ``J``: use JIT generated native code, otherwise BPF interpreter will be used.
5497
5498* ``M``: assume input parameter is a pointer to rte_mbuf, otherwise assume it is a pointer to first segment's data.
5499
5500* ``-``: none.
5501
5502.. note::
5503
5504   You'll need clang v3.7 or above to build bpf program you'd like to load
5505
5506For example:
5507
5508.. code-block:: console
5509
5510   cd examples/bpf
5511   clang -O2 -target bpf -c t1.c
5512
5513Then to load (and JIT compile) t1.o at RX queue 0, port 1:
5514
5515.. code-block:: console
5516
5517   testpmd> bpf-load rx 1 0 J ./dpdk.org/examples/bpf/t1.o
5518
5519To load (not JITed) t1.o at TX queue 0, port 0:
5520
5521.. code-block:: console
5522
5523   testpmd> bpf-load tx 0 0 - ./dpdk.org/examples/bpf/t1.o
5524
5525bpf-unload
5526~~~~~~~~~~
5527
5528Unload previously loaded eBPF program for particular RX/TX queue::
5529
5530   testpmd> bpf-unload rx|tx (portid) (queueid)
5531
5532For example to unload BPF filter from TX queue 0, port 0:
5533
5534.. code-block:: console
5535
5536   testpmd> bpf-unload tx 0 0
5537
5538Flex Item Functions
5539-------------------
5540
5541The following sections show functions that configure and create flex item object,
5542create flex pattern and use it in a flow rule.
5543The commands will use 20 bytes IPv4 header for examples:
5544
5545::
5546
5547   0                   1                   2                   3
5548   0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
5549   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
5550   |  ver  |  IHL  |     TOS       |        length                 | +0
5551   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
5552   |       identification          | flg |    frag. offset         | +4
5553   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
5554   |       TTL     |  protocol     |        checksum               | +8
5555   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
5556   |               source IP address                               | +12
5557   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
5558   |              destination IP address                           | +16
5559   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
5560
5561
5562Create flex item
5563~~~~~~~~~~~~~~~~
5564
5565Flex item object is created by PMD according to a new header configuration. The
5566header configuration is compiled by the testpmd and stored in
5567``rte_flow_item_flex_conf`` type variable.
5568
5569::
5570
5571   # flow flex_item create <port> <flex id> <configuration file>
5572   testpmd> flow flex_item init 0 3 ipv4_flex_config.json
5573   port-0: created flex item #3
5574
5575Flex item configuration is kept in external JSON file.
5576It describes the following header elements:
5577
5578**New header length.**
5579
5580Specify whether the new header has fixed or variable length and the basic/minimal
5581header length value.
5582
5583If header length is not fixed, header location with a value that completes header
5584length calculation and scale/offset function must be added.
5585
5586Scale function depends on port hardware.
5587
5588**Next protocol.**
5589
5590Describes location in the new header that specify following network header type.
5591
5592**Flow match samples.**
5593
5594Describes locations in the new header that will be used in flow rules.
5595
5596Number of flow samples and sample maximal length depend of port hardware.
5597
5598**Input trigger.**
5599
5600Describes preceding network header configuration.
5601
5602**Output trigger.**
5603
5604Describes conditions that trigger transfer to following network header
5605
5606.. code-block:: json
5607
5608   {
5609      "next_header": { "field_mode": "FIELD_MODE_FIXED", "field_size": 20},
5610      "next_protocol": {"field_size": 8, "field_base": 72},
5611      "sample_data": [
5612         { "field_mode": "FIELD_MODE_FIXED", "field_size": 32, "field_base": 0},
5613         { "field_mode": "FIELD_MODE_FIXED", "field_size": 32, "field_base": 32},
5614         { "field_mode": "FIELD_MODE_FIXED", "field_size": 32, "field_base": 64},
5615         { "field_mode": "FIELD_MODE_FIXED", "field_size": 32, "field_base": 96}
5616      ],
5617      "input_link": [
5618         {"item": "eth type is 0x0800"},
5619         {"item": "vlan inner_type is 0x0800"}
5620      ],
5621      "output_link": [
5622         {"item": "udp", "next": 17},
5623         {"item": "tcp", "next": 6},
5624         {"item": "icmp", "next": 1}
5625      ]
5626   }
5627
5628
5629Flex pattern and flow rules
5630~~~~~~~~~~~~~~~~~~~~~~~~~~~
5631
5632Flex pattern describe parts of network header that will trigger flex flow item hit in a flow rule.
5633Flex pattern directly related to flex item samples configuration.
5634Flex pattern can be shared between ports.
5635
5636**Flex pattern and flow rule to match IPv4 version and 20 bytes length**
5637
5638::
5639
5640   # set flex_pattern <pattern_id> is <hex bytes sequence>
5641   testpmd> flow flex_item pattern 5 is 45FF
5642   created pattern #5
5643
5644   testpmd> flow create 0 ingress pattern eth / ipv4 / udp / flex item is 3 pattern is 5 / end actions mark id 1 / queue index 0 / end
5645   Flow rule #0 created
5646
5647**Flex pattern and flow rule to match packets with source address 1.2.3.4**
5648
5649::
5650
5651   testpmd> flow flex_item pattern 2 spec 45000000000000000000000001020304 mask FF0000000000000000000000FFFFFFFF
5652   created pattern #2
5653
5654   testpmd> flow create 0 ingress pattern eth / ipv4 / udp / flex item is 3 pattern is 2 / end actions mark id 1 / queue index 0 / end
5655   Flow rule #0 created
5656
5657Driver specific commands
5658------------------------
5659
5660Some drivers provide specific features.
5661See:
5662
5663- :ref:`net/bonding testpmd driver specific commands <bonding_testpmd_commands>`
5664- :ref:`net/i40e testpmd driver specific commands <net_i40e_testpmd_commands>`
5665- :ref:`net/ixgbe testpmd driver specific commands <net_ixgbe_testpmd_commands>`
5666