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