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