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