xref: /dpdk/doc/guides/testpmd_app_ug/testpmd_funcs.rst (revision 732115ce38c63184cb706b9179c02ed04b961afa)
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
1885port attach
1886~~~~~~~~~~~
1887
1888Attach a port specified by pci address or virtual device args::
1889
1890   testpmd> port attach (identifier)
1891
1892To attach a new pci device, the device should be recognized by kernel first.
1893Then it should be moved under DPDK management.
1894Finally the port can be attached to testpmd.
1895
1896For example, to move a pci device using ixgbe under DPDK management:
1897
1898.. code-block:: console
1899
1900   # Check the status of the available devices.
1901   ./usertools/dpdk-devbind.py --status
1902
1903   Network devices using DPDK-compatible driver
1904   ============================================
1905   <none>
1906
1907   Network devices using kernel driver
1908   ===================================
1909   0000:0a:00.0 '82599ES 10-Gigabit' if=eth2 drv=ixgbe unused=
1910
1911
1912   # Bind the device to igb_uio.
1913   sudo ./usertools/dpdk-devbind.py -b igb_uio 0000:0a:00.0
1914
1915
1916   # Recheck the status of the devices.
1917   ./usertools/dpdk-devbind.py --status
1918   Network devices using DPDK-compatible driver
1919   ============================================
1920   0000:0a:00.0 '82599ES 10-Gigabit' drv=igb_uio unused=
1921
1922To attach a port created by virtual device, above steps are not needed.
1923
1924For example, to attach a port whose pci address is 0000:0a:00.0.
1925
1926.. code-block:: console
1927
1928   testpmd> port attach 0000:0a:00.0
1929   Attaching a new port...
1930   EAL: PCI device 0000:0a:00.0 on NUMA socket -1
1931   EAL:   probe driver: 8086:10fb rte_ixgbe_pmd
1932   EAL:   PCI memory mapped at 0x7f83bfa00000
1933   EAL:   PCI memory mapped at 0x7f83bfa80000
1934   PMD: eth_ixgbe_dev_init(): MAC: 2, PHY: 18, SFP+: 5
1935   PMD: eth_ixgbe_dev_init(): port 0 vendorID=0x8086 deviceID=0x10fb
1936   Port 0 is attached. Now total ports is 1
1937   Done
1938
1939For example, to attach a port created by pcap PMD.
1940
1941.. code-block:: console
1942
1943   testpmd> port attach net_pcap0
1944   Attaching a new port...
1945   PMD: Initializing pmd_pcap for net_pcap0
1946   PMD: Creating pcap-backed ethdev on numa socket 0
1947   Port 0 is attached. Now total ports is 1
1948   Done
1949
1950In this case, identifier is ``net_pcap0``.
1951This identifier format is the same as ``--vdev`` format of DPDK applications.
1952
1953For example, to re-attach a bonded port which has been previously detached,
1954the mode and slave parameters must be given.
1955
1956.. code-block:: console
1957
1958   testpmd> port attach net_bond_0,mode=0,slave=1
1959   Attaching a new port...
1960   EAL: Initializing pmd_bond for net_bond_0
1961   EAL: Create bonded device net_bond_0 on port 0 in mode 0 on socket 0.
1962   Port 0 is attached. Now total ports is 1
1963   Done
1964
1965
1966port detach
1967~~~~~~~~~~~
1968
1969Detach a specific port::
1970
1971   testpmd> port detach (port_id)
1972
1973Before detaching a port, the port should be stopped and closed.
1974
1975For example, to detach a pci device port 0.
1976
1977.. code-block:: console
1978
1979   testpmd> port stop 0
1980   Stopping ports...
1981   Done
1982   testpmd> port close 0
1983   Closing ports...
1984   Done
1985
1986   testpmd> port detach 0
1987   Detaching a port...
1988   EAL: PCI device 0000:0a:00.0 on NUMA socket -1
1989   EAL:   remove driver: 8086:10fb rte_ixgbe_pmd
1990   EAL:   PCI memory unmapped at 0x7f83bfa00000
1991   EAL:   PCI memory unmapped at 0x7f83bfa80000
1992   Done
1993
1994
1995For example, to detach a virtual device port 0.
1996
1997.. code-block:: console
1998
1999   testpmd> port stop 0
2000   Stopping ports...
2001   Done
2002   testpmd> port close 0
2003   Closing ports...
2004   Done
2005
2006   testpmd> port detach 0
2007   Detaching a port...
2008   PMD: Closing pcap ethdev on numa socket 0
2009   Port 'net_pcap0' is detached. Now total ports is 0
2010   Done
2011
2012To remove a pci device completely from the system, first detach the port from testpmd.
2013Then the device should be moved under kernel management.
2014Finally the device can be removed using kernel pci hotplug functionality.
2015
2016For example, to move a pci device under kernel management:
2017
2018.. code-block:: console
2019
2020   sudo ./usertools/dpdk-devbind.py -b ixgbe 0000:0a:00.0
2021
2022   ./usertools/dpdk-devbind.py --status
2023
2024   Network devices using DPDK-compatible driver
2025   ============================================
2026   <none>
2027
2028   Network devices using kernel driver
2029   ===================================
2030   0000:0a:00.0 '82599ES 10-Gigabit' if=eth2 drv=ixgbe unused=igb_uio
2031
2032To remove a port created by a virtual device, above steps are not needed.
2033
2034port start
2035~~~~~~~~~~
2036
2037Start all ports or a specific port::
2038
2039   testpmd> port start (port_id|all)
2040
2041port stop
2042~~~~~~~~~
2043
2044Stop all ports or a specific port::
2045
2046   testpmd> port stop (port_id|all)
2047
2048port close
2049~~~~~~~~~~
2050
2051Close all ports or a specific port::
2052
2053   testpmd> port close (port_id|all)
2054
2055port reset
2056~~~~~~~~~~
2057
2058Reset all ports or a specific port::
2059
2060   testpmd> port reset (port_id|all)
2061
2062User should stop port(s) before resetting and (re-)start after reset.
2063
2064port config - queue ring size
2065~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2066
2067Configure a rx/tx queue ring size::
2068
2069   testpmd> port (port_id) (rxq|txq) (queue_id) ring_size (value)
2070
2071Only take effect after command that (re-)start the port or command that setup specific queue.
2072
2073port start/stop queue
2074~~~~~~~~~~~~~~~~~~~~~
2075
2076Start/stop a rx/tx queue on a specific port::
2077
2078   testpmd> port (port_id) (rxq|txq) (queue_id) (start|stop)
2079
2080port config - queue deferred start
2081~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2082
2083Switch on/off deferred start of a specific port queue::
2084
2085   testpmd> port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)
2086
2087port setup queue
2088~~~~~~~~~~~~~~~~~~~~~
2089
2090Setup a rx/tx queue on a specific port::
2091
2092   testpmd> port (port_id) (rxq|txq) (queue_id) setup
2093
2094Only take effect when port is started.
2095
2096port config - speed
2097~~~~~~~~~~~~~~~~~~~
2098
2099Set the speed and duplex mode for all ports or a specific port::
2100
2101   testpmd> port config (port_id|all) speed (10|100|1000|10000|25000|40000|50000|100000|200000|auto) \
2102            duplex (half|full|auto)
2103
2104port config - queues/descriptors
2105~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2106
2107Set number of queues/descriptors for rxq, txq, rxd and txd::
2108
2109   testpmd> port config all (rxq|txq|rxd|txd) (value)
2110
2111This is equivalent to the ``--rxq``, ``--txq``, ``--rxd`` and ``--txd`` command-line options.
2112
2113port config - max-pkt-len
2114~~~~~~~~~~~~~~~~~~~~~~~~~
2115
2116Set the maximum packet length::
2117
2118   testpmd> port config all max-pkt-len (value)
2119
2120This is equivalent to the ``--max-pkt-len`` command-line option.
2121
2122port config - max-lro-pkt-size
2123~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2124
2125Set the maximum LRO aggregated packet size::
2126
2127   testpmd> port config all max-lro-pkt-size (value)
2128
2129This is equivalent to the ``--max-lro-pkt-size`` command-line option.
2130
2131port config - Drop Packets
2132~~~~~~~~~~~~~~~~~~~~~~~~~~
2133
2134Enable or disable packet drop on all RX queues of all ports when no receive buffers available::
2135
2136   testpmd> port config all drop-en (on|off)
2137
2138Packet dropping when no receive buffers available is off by default.
2139
2140The ``on`` option is equivalent to the ``--enable-drop-en`` command-line option.
2141
2142port config - RSS
2143~~~~~~~~~~~~~~~~~
2144
2145Set the RSS (Receive Side Scaling) mode on or off::
2146
2147   testpmd> port config all rss (all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|ecpri|mpls|l2tpv2|none)
2148
2149RSS is on by default.
2150
2151The ``all`` option is equivalent to eth|vlan|ip|tcp|udp|sctp|ether|l2tpv3|esp|ah|pfcp|l2tpv2.
2152
2153The ``default`` option enables all supported RSS types reported by device info.
2154
2155The ``none`` option is equivalent to the ``--disable-rss`` command-line option.
2156
2157port config - RSS Reta
2158~~~~~~~~~~~~~~~~~~~~~~
2159
2160Set the RSS (Receive Side Scaling) redirection table::
2161
2162   testpmd> port config all rss reta (hash,queue)[,(hash,queue)]
2163
2164port config - DCB
2165~~~~~~~~~~~~~~~~~
2166
2167Set the DCB mode for an individual port::
2168
2169   testpmd> port config (port_id) dcb vt (on|off) (traffic_class) pfc (on|off)
2170
2171The traffic class should be 4 or 8.
2172
2173port config - Burst
2174~~~~~~~~~~~~~~~~~~~
2175
2176Set the number of packets per burst::
2177
2178   testpmd> port config all burst (value)
2179
2180This is equivalent to the ``--burst`` command-line option.
2181
2182port config - Threshold
2183~~~~~~~~~~~~~~~~~~~~~~~
2184
2185Set thresholds for TX/RX queues::
2186
2187   testpmd> port config all (threshold) (value)
2188
2189Where the threshold type can be:
2190
2191* ``txpt:`` Set the prefetch threshold register of the TX rings, 0 <= value <= 255.
2192
2193* ``txht:`` Set the host threshold register of the TX rings, 0 <= value <= 255.
2194
2195* ``txwt:`` Set the write-back threshold register of the TX rings, 0 <= value <= 255.
2196
2197* ``rxpt:`` Set the prefetch threshold register of the RX rings, 0 <= value <= 255.
2198
2199* ``rxht:`` Set the host threshold register of the RX rings, 0 <= value <= 255.
2200
2201* ``rxwt:`` Set the write-back threshold register of the RX rings, 0 <= value <= 255.
2202
2203* ``txfreet:`` Set the transmit free threshold of the TX rings, 0 <= value <= txd.
2204
2205* ``rxfreet:`` Set the transmit free threshold of the RX rings, 0 <= value <= rxd.
2206
2207* ``txrst:`` Set the transmit RS bit threshold of TX rings, 0 <= value <= txd.
2208
2209These threshold options are also available from the command-line.
2210
2211port config pctype mapping
2212~~~~~~~~~~~~~~~~~~~~~~~~~~
2213
2214Reset pctype mapping table::
2215
2216   testpmd> port config (port_id) pctype mapping reset
2217
2218Update hardware defined pctype to software defined flow type mapping table::
2219
2220   testpmd> port config (port_id) pctype mapping update (pctype_id_0[,pctype_id_1]*) (flow_type_id)
2221
2222where:
2223
2224* ``pctype_id_x``: hardware pctype id as index of bit in bitmask value of the pctype mapping table.
2225
2226* ``flow_type_id``: software flow type id as the index of the pctype mapping table.
2227
2228port config input set
2229~~~~~~~~~~~~~~~~~~~~~
2230
2231Config RSS/FDIR/FDIR flexible payload input set for some pctype::
2232
2233   testpmd> port config (port_id) pctype (pctype_id) \
2234            (hash_inset|fdir_inset|fdir_flx_inset) \
2235	    (get|set|clear) field (field_idx)
2236
2237Clear RSS/FDIR/FDIR flexible payload input set for some pctype::
2238
2239   testpmd> port config (port_id) pctype (pctype_id) \
2240            (hash_inset|fdir_inset|fdir_flx_inset) clear all
2241
2242where:
2243
2244* ``pctype_id``: hardware packet classification types.
2245* ``field_idx``: hardware field index.
2246
2247port config udp_tunnel_port
2248~~~~~~~~~~~~~~~~~~~~~~~~~~~
2249
2250Add/remove UDP tunnel port for VXLAN/GENEVE tunneling protocols::
2251
2252    testpmd> port config (port_id) udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe|ecpri (udp_port)
2253
2254port config tx_metadata
2255~~~~~~~~~~~~~~~~~~~~~~~
2256
2257Set Tx metadata value per port.
2258testpmd will add this value to any Tx packet sent from this port::
2259
2260   testpmd> port config (port_id) tx_metadata (value)
2261
2262port config dynf
2263~~~~~~~~~~~~~~~~
2264
2265Set/clear dynamic flag per port.
2266testpmd will register this flag in the mbuf (same registration
2267for both Tx and Rx). Then set/clear this flag for each Tx
2268packet sent from this port. The set bit only works for Tx packet::
2269
2270   testpmd> port config (port_id) dynf (name) (set|clear)
2271
2272port config mtu
2273~~~~~~~~~~~~~~~
2274
2275To configure MTU(Maximum Transmission Unit) on devices using testpmd::
2276
2277   testpmd> port config mtu (port_id) (value)
2278
2279port config rss hash key
2280~~~~~~~~~~~~~~~~~~~~~~~~
2281
2282To configure the RSS hash key used to compute the RSS
2283hash of input [IP] packets received on port::
2284
2285   testpmd> port config <port_id> rss-hash-key (ipv4|ipv4-frag|\
2286                     ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|\
2287                     ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|\
2288                     ipv6-other|l2-payload|ipv6-ex|ipv6-tcp-ex|\
2289                     ipv6-udp-ex <string of hex digits \
2290                     (variable length, NIC dependent)>)
2291
2292port cleanup txq mbufs
2293~~~~~~~~~~~~~~~~~~~~~~
2294
2295To cleanup txq mbufs currently cached by driver::
2296
2297   testpmd> port cleanup (port_id) txq (queue_id) (free_cnt)
2298
2299If the value of ``free_cnt`` is 0, driver should free all cached mbufs.
2300
2301Device Functions
2302----------------
2303
2304The following sections show functions for device operations.
2305
2306device detach
2307~~~~~~~~~~~~~
2308
2309Detach a device specified by pci address or virtual device args::
2310
2311   testpmd> device detach (identifier)
2312
2313Before detaching a device associated with ports, the ports should be stopped and closed.
2314
2315For example, to detach a pci device whose address is 0002:03:00.0.
2316
2317.. code-block:: console
2318
2319    testpmd> device detach 0002:03:00.0
2320    Removing a device...
2321    Port 1 is now closed
2322    EAL: Releasing pci mapped resource for 0002:03:00.0
2323    EAL: Calling pci_unmap_resource for 0002:03:00.0 at 0x218a050000
2324    EAL: Calling pci_unmap_resource for 0002:03:00.0 at 0x218c050000
2325    Device 0002:03:00.0 is detached
2326    Now total ports is 1
2327
2328For example, to detach a port created by pcap PMD.
2329
2330.. code-block:: console
2331
2332    testpmd> device detach net_pcap0
2333    Removing a device...
2334    Port 0 is now closed
2335    Device net_pcap0 is detached
2336    Now total ports is 0
2337    Done
2338
2339In this case, identifier is ``net_pcap0``.
2340This identifier format is the same as ``--vdev`` format of DPDK applications.
2341
2342Link Bonding Functions
2343----------------------
2344
2345The Link Bonding functions make it possible to dynamically create and
2346manage link bonding devices from within testpmd interactive prompt.
2347
2348See :doc:`../prog_guide/link_bonding_poll_mode_drv_lib` for more information.
2349
2350Register Functions
2351------------------
2352
2353The Register Functions can be used to read from and write to registers on the network card referenced by a port number.
2354This is mainly useful for debugging purposes.
2355Reference should be made to the appropriate datasheet for the network card for details on the register addresses
2356and fields that can be accessed.
2357
2358read reg
2359~~~~~~~~
2360
2361Display the value of a port register::
2362
2363   testpmd> read reg (port_id) (address)
2364
2365For example, to examine the Flow Director control register (FDIRCTL, 0x0000EE000) on an Intel 82599 10 GbE Controller::
2366
2367   testpmd> read reg 0 0xEE00
2368   port 0 PCI register at offset 0xEE00: 0x4A060029 (1241907241)
2369
2370read regfield
2371~~~~~~~~~~~~~
2372
2373Display a port register bit field::
2374
2375   testpmd> read regfield (port_id) (address) (bit_x) (bit_y)
2376
2377For example, reading the lowest two bits from the register in the example above::
2378
2379   testpmd> read regfield 0 0xEE00 0 1
2380   port 0 PCI register at offset 0xEE00: bits[0, 1]=0x1 (1)
2381
2382read regbit
2383~~~~~~~~~~~
2384
2385Display a single port register bit::
2386
2387   testpmd> read regbit (port_id) (address) (bit_x)
2388
2389For example, reading the lowest bit from the register in the example above::
2390
2391   testpmd> read regbit 0 0xEE00 0
2392   port 0 PCI register at offset 0xEE00: bit 0=1
2393
2394write reg
2395~~~~~~~~~
2396
2397Set the value of a port register::
2398
2399   testpmd> write reg (port_id) (address) (value)
2400
2401For example, to clear a register::
2402
2403   testpmd> write reg 0 0xEE00 0x0
2404   port 0 PCI register at offset 0xEE00: 0x00000000 (0)
2405
2406write regfield
2407~~~~~~~~~~~~~~
2408
2409Set bit field of a port register::
2410
2411   testpmd> write regfield (port_id) (address) (bit_x) (bit_y) (value)
2412
2413For example, writing to the register cleared in the example above::
2414
2415   testpmd> write regfield 0 0xEE00 0 1 2
2416   port 0 PCI register at offset 0xEE00: 0x00000002 (2)
2417
2418write regbit
2419~~~~~~~~~~~~
2420
2421Set single bit value of a port register::
2422
2423   testpmd> write regbit (port_id) (address) (bit_x) (value)
2424
2425For example, to set the high bit in the register from the example above::
2426
2427   testpmd> write regbit 0 0xEE00 31 1
2428   port 0 PCI register at offset 0xEE00: 0x8000000A (2147483658)
2429
2430Traffic Metering and Policing
2431-----------------------------
2432
2433The following section shows functions for configuring traffic metering and
2434policing on the ethernet device through the use of generic ethdev API.
2435
2436show port traffic management capability
2437~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2438
2439Show traffic metering and policing capability of the port::
2440
2441   testpmd> show port meter cap (port_id)
2442
2443add port meter profile (srTCM rfc2967)
2444~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2445
2446Add meter profile (srTCM rfc2697) to the ethernet device::
2447
2448   testpmd> add port meter profile srtcm_rfc2697 (port_id) (profile_id) \
2449   (cir) (cbs) (ebs) (packet_mode)
2450
2451where:
2452
2453* ``profile_id``: ID for the meter profile.
2454* ``cir``: Committed Information Rate (CIR) (bytes per second or packets per second).
2455* ``cbs``: Committed Burst Size (CBS) (bytes or packets).
2456* ``ebs``: Excess Burst Size (EBS) (bytes or packets).
2457* ``packet_mode``: Packets mode for meter profile.
2458
2459add port meter profile (trTCM rfc2968)
2460~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2461
2462Add meter profile (srTCM rfc2698) to the ethernet device::
2463
2464   testpmd> add port meter profile trtcm_rfc2698 (port_id) (profile_id) \
2465   (cir) (pir) (cbs) (pbs) (packet_mode)
2466
2467where:
2468
2469* ``profile_id``: ID for the meter profile.
2470* ``cir``: Committed information rate (bytes per second or packets per second).
2471* ``pir``: Peak information rate (bytes per second or packets per second).
2472* ``cbs``: Committed burst size (bytes or packets).
2473* ``pbs``: Peak burst size (bytes or packets).
2474* ``packet_mode``: Packets mode for meter profile.
2475
2476add port meter profile (trTCM rfc4115)
2477~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2478
2479Add meter profile (trTCM rfc4115) to the ethernet device::
2480
2481   testpmd> add port meter profile trtcm_rfc4115 (port_id) (profile_id) \
2482   (cir) (eir) (cbs) (ebs) (packet_mode)
2483
2484where:
2485
2486* ``profile_id``: ID for the meter profile.
2487* ``cir``: Committed information rate (bytes per second or packets per second).
2488* ``eir``: Excess information rate (bytes per second or packets per second).
2489* ``cbs``: Committed burst size (bytes or packets).
2490* ``ebs``: Excess burst size (bytes or packets).
2491* ``packet_mode``: Packets mode for meter profile.
2492
2493delete port meter profile
2494~~~~~~~~~~~~~~~~~~~~~~~~~
2495
2496Delete meter profile from the ethernet device::
2497
2498   testpmd> del port meter profile (port_id) (profile_id)
2499
2500create port policy
2501~~~~~~~~~~~~~~~~~~
2502
2503Create new policy object for the ethernet device::
2504
2505   testpmd> add port meter policy (port_id) (policy_id) g_actions \
2506   {action} y_actions {action} r_actions {action}
2507
2508where:
2509
2510* ``policy_id``: policy ID.
2511* ``action``: action lists for green/yellow/red colors.
2512
2513delete port policy
2514~~~~~~~~~~~~~~~~~~
2515
2516Delete policy object for the ethernet device::
2517
2518   testpmd> del port meter policy (port_id) (policy_id)
2519
2520where:
2521
2522* ``policy_id``: policy ID.
2523
2524create port meter
2525~~~~~~~~~~~~~~~~~
2526
2527Create new meter object for the ethernet device::
2528
2529   testpmd> create port meter (port_id) (mtr_id) (profile_id) \
2530   (policy_id) (meter_enable) (stats_mask) (shared) (default_input_color) \
2531   (use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\
2532   (dscp_tbl_entry63)] [(vlan_tbl_entry0) (vlan_tbl_entry1) ... \
2533   (vlan_tbl_entry15)]
2534
2535where:
2536
2537* ``mtr_id``: meter object ID.
2538* ``profile_id``: ID for the meter profile.
2539* ``policy_id``: ID for the policy.
2540* ``meter_enable``: When this parameter has a non-zero value, the meter object
2541  gets enabled at the time of creation, otherwise remains disabled.
2542* ``stats_mask``: Mask of statistics counter types to be enabled for the
2543  meter object.
2544* ``shared``:  When this parameter has a non-zero value, the meter object is
2545  shared by multiple flows. Otherwise, meter object is used by single flow.
2546* ``default_input_color``:  Default input color for incoming packets.
2547  If incoming packet misses DSCP or VLAN input color table then it will be used
2548  as input color.
2549* ``use_pre_meter_color``: When this parameter has a non-zero value, the
2550  input color for the current meter object is determined by the latest meter
2551  object in the same flow. Otherwise, the current meter object uses the
2552  *dscp_table* to determine the input color.
2553* ``dscp_tbl_entryx``: DSCP table entry x providing meter providing input
2554  color, 0 <= x <= 63.
2555* ``vlan_tbl_entryx``: VLAN table entry x providing meter input color,
2556  0 <= x <= 15.
2557
2558enable port meter
2559~~~~~~~~~~~~~~~~~
2560
2561Enable meter for the ethernet device::
2562
2563   testpmd> enable port meter (port_id) (mtr_id)
2564
2565disable port meter
2566~~~~~~~~~~~~~~~~~~
2567
2568Disable meter for the ethernet device::
2569
2570   testpmd> disable port meter (port_id) (mtr_id)
2571
2572delete port meter
2573~~~~~~~~~~~~~~~~~
2574
2575Delete meter for the ethernet device::
2576
2577   testpmd> del port meter (port_id) (mtr_id)
2578
2579Set port meter profile
2580~~~~~~~~~~~~~~~~~~~~~~
2581
2582Set meter profile for the ethernet device::
2583
2584   testpmd> set port meter profile (port_id) (mtr_id) (profile_id)
2585
2586set port meter dscp table
2587~~~~~~~~~~~~~~~~~~~~~~~~~
2588
2589Set meter dscp table for the ethernet device::
2590
2591   testpmd> set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0) \
2592   (dscp_tbl_entry1)...(dscp_tbl_entry63)]
2593
2594set port meter vlan table
2595~~~~~~~~~~~~~~~~~~~~~~~~~
2596Set meter VLAN table for the Ethernet device::
2597
2598   testpmd> set port meter vlan table (port_id) (mtr_id) [(vlan_tbl_entry0) \
2599   (vlan_tbl_entry1)...(vlan_tbl_entry15)]
2600
2601set port meter protocol
2602~~~~~~~~~~~~~~~~~~~~~~~
2603Set meter protocol and corresponding priority::
2604
2605   testpmd> set port meter proto (port_id) (mtr_id) (proto) (prio)
2606
2607get port meter protocol
2608~~~~~~~~~~~~~~~~~~~~~~~
2609Get meter protocol::
2610
2611   testpmd> get port meter proto (port_id) (mtr_id)
2612
2613get port meter protocol priority
2614~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2615Get priority associated to meter protocol::
2616
2617   testpmd> get port meter proto_prio (port_id) (mtr_id) (proto)
2618
2619set port meter stats mask
2620~~~~~~~~~~~~~~~~~~~~~~~~~
2621
2622Set meter stats mask for the ethernet device::
2623
2624   testpmd> set port meter stats mask (port_id) (mtr_id) (stats_mask)
2625
2626where:
2627
2628* ``stats_mask``: Bit mask indicating statistics counter types to be enabled.
2629
2630show port meter stats
2631~~~~~~~~~~~~~~~~~~~~~
2632
2633Show meter stats of the ethernet device::
2634
2635   testpmd> show port meter stats (port_id) (mtr_id) (clear)
2636
2637where:
2638
2639* ``clear``: Flag that indicates whether the statistics counters should
2640  be cleared (i.e. set to zero) immediately after they have been read or not.
2641
2642Traffic Management
2643------------------
2644
2645The following section shows functions for configuring traffic management on
2646the ethernet device through the use of generic TM API.
2647
2648show port traffic management capability
2649~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2650
2651Show traffic management capability of the port::
2652
2653   testpmd> show port tm cap (port_id)
2654
2655show port traffic management capability (hierarchy level)
2656~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2657
2658Show traffic management hierarchy level capability of the port::
2659
2660   testpmd> show port tm level cap (port_id) (level_id)
2661
2662show port traffic management capability (hierarchy node level)
2663~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2664
2665Show the traffic management hierarchy node capability of the port::
2666
2667   testpmd> show port tm node cap (port_id) (node_id)
2668
2669show port traffic management hierarchy node type
2670~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2671
2672Show the port traffic management hierarchy node type::
2673
2674   testpmd> show port tm node type (port_id) (node_id)
2675
2676show port traffic management hierarchy node stats
2677~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2678
2679Show the port traffic management hierarchy node statistics::
2680
2681   testpmd> show port tm node stats (port_id) (node_id) (clear)
2682
2683where:
2684
2685* ``clear``: When this parameter has a non-zero value, the statistics counters
2686  are cleared (i.e. set to zero) immediately after they have been read,
2687  otherwise the statistics counters are left untouched.
2688
2689Add port traffic management private shaper profile
2690~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2691
2692Add the port traffic management private shaper profile::
2693
2694   testpmd> add port tm node shaper profile (port_id) (shaper_profile_id) \
2695   (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size) \
2696   (packet_length_adjust) (packet_mode)
2697
2698where:
2699
2700* ``shaper_profile id``: Shaper profile ID for the new profile.
2701* ``cmit_tb_rate``: Committed token bucket rate (bytes per second or packets per second).
2702* ``cmit_tb_size``: Committed token bucket size (bytes or packets).
2703* ``peak_tb_rate``: Peak token bucket rate (bytes per second or packets per second).
2704* ``peak_tb_size``: Peak token bucket size (bytes or packets).
2705* ``packet_length_adjust``: The value (bytes) to be added to the length of
2706  each packet for the purpose of shaping. This parameter value can be used to
2707  correct the packet length with the framing overhead bytes that are consumed
2708  on the wire.
2709* ``packet_mode``: Shaper configured in packet mode. This parameter value if
2710  zero, configures shaper in byte mode and if non-zero configures it in packet
2711  mode.
2712
2713Delete port traffic management private shaper profile
2714~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2715
2716Delete the port traffic management private shaper::
2717
2718   testpmd> del port tm node shaper profile (port_id) (shaper_profile_id)
2719
2720where:
2721
2722* ``shaper_profile id``: Shaper profile ID that needs to be deleted.
2723
2724Add port traffic management shared shaper
2725~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2726
2727Create the port traffic management shared shaper::
2728
2729   testpmd> add port tm node shared shaper (port_id) (shared_shaper_id) \
2730   (shaper_profile_id)
2731
2732where:
2733
2734* ``shared_shaper_id``: Shared shaper ID to be created.
2735* ``shaper_profile id``: Shaper profile ID for shared shaper.
2736
2737Set port traffic management shared shaper
2738~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2739
2740Update the port traffic management shared shaper::
2741
2742   testpmd> set port tm node shared shaper (port_id) (shared_shaper_id) \
2743   (shaper_profile_id)
2744
2745where:
2746
2747* ``shared_shaper_id``: Shared shaper ID to be update.
2748* ``shaper_profile id``: Shaper profile ID for shared shaper.
2749
2750Delete port traffic management shared shaper
2751~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2752
2753Delete the port traffic management shared shaper::
2754
2755   testpmd> del port tm node shared shaper (port_id) (shared_shaper_id)
2756
2757where:
2758
2759* ``shared_shaper_id``: Shared shaper ID to be deleted.
2760
2761Set port traffic management hierarchy node private shaper
2762~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2763
2764set the port traffic management hierarchy node private shaper::
2765
2766   testpmd> set port tm node shaper profile (port_id) (node_id) \
2767   (shaper_profile_id)
2768
2769where:
2770
2771* ``shaper_profile id``: Private shaper profile ID to be enabled on the
2772  hierarchy node.
2773
2774Add port traffic management WRED profile
2775~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2776
2777Create a new WRED profile::
2778
2779   testpmd> add port tm node wred profile (port_id) (wred_profile_id) \
2780   (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g) \
2781   (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y) \
2782   (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)
2783
2784where:
2785
2786* ``wred_profile id``: Identifier for the newly create WRED profile
2787* ``color_g``: Packet color (green)
2788* ``min_th_g``: Minimum queue threshold for packet with green color
2789* ``max_th_g``: Minimum queue threshold for packet with green color
2790* ``maxp_inv_g``: Inverse of packet marking probability maximum value (maxp)
2791* ``wq_log2_g``: Negated log2 of queue weight (wq)
2792* ``color_y``: Packet color (yellow)
2793* ``min_th_y``: Minimum queue threshold for packet with yellow color
2794* ``max_th_y``: Minimum queue threshold for packet with yellow color
2795* ``maxp_inv_y``: Inverse of packet marking probability maximum value (maxp)
2796* ``wq_log2_y``: Negated log2 of queue weight (wq)
2797* ``color_r``: Packet color (red)
2798* ``min_th_r``: Minimum queue threshold for packet with yellow color
2799* ``max_th_r``: Minimum queue threshold for packet with yellow color
2800* ``maxp_inv_r``: Inverse of packet marking probability maximum value (maxp)
2801* ``wq_log2_r``: Negated log2 of queue weight (wq)
2802
2803Delete port traffic management WRED profile
2804~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2805
2806Delete the WRED profile::
2807
2808   testpmd> del port tm node wred profile (port_id) (wred_profile_id)
2809
2810Add port traffic management hierarchy nonleaf node
2811~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2812
2813Add nonleaf node to port traffic management hierarchy::
2814
2815   testpmd> add port tm nonleaf node (port_id) (node_id) (parent_node_id) \
2816   (priority) (weight) (level_id) (shaper_profile_id) \
2817   (n_sp_priorities) (stats_mask) (n_shared_shapers) \
2818   [(shared_shaper_0) (shared_shaper_1) ...] \
2819
2820where:
2821
2822* ``parent_node_id``: Node ID of the parent.
2823* ``priority``: Node priority (highest node priority is zero). This is used by
2824  the SP algorithm running on the parent node for scheduling this node.
2825* ``weight``: Node weight (lowest weight is one). The node weight is relative
2826  to the weight sum of all siblings that have the same priority. It is used by
2827  the WFQ algorithm running on the parent node for scheduling this node.
2828* ``level_id``: Hierarchy level of the node.
2829* ``shaper_profile_id``: Shaper profile ID of the private shaper to be used by
2830  the node.
2831* ``n_sp_priorities``: Number of strict priorities.
2832* ``stats_mask``: Mask of statistics counter types to be enabled for this node.
2833* ``n_shared_shapers``: Number of shared shapers.
2834* ``shared_shaper_id``: Shared shaper id.
2835
2836Add port traffic management hierarchy nonleaf node with packet mode
2837~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2838
2839Add nonleaf node with packet mode to port traffic management hierarchy::
2840
2841   testpmd> add port tm nonleaf node pktmode (port_id) (node_id) (parent_node_id) \
2842   (priority) (weight) (level_id) (shaper_profile_id) \
2843   (n_sp_priorities) (stats_mask) (n_shared_shapers) \
2844   [(shared_shaper_0) (shared_shaper_1) ...] \
2845
2846where:
2847
2848* ``parent_node_id``: Node ID of the parent.
2849* ``priority``: Node priority (highest node priority is zero). This is used by
2850  the SP algorithm running on the parent node for scheduling this node.
2851* ``weight``: Node weight (lowest weight is one). The node weight is relative
2852  to the weight sum of all siblings that have the same priority. It is used by
2853  the WFQ algorithm running on the parent node for scheduling this node.
2854* ``level_id``: Hierarchy level of the node.
2855* ``shaper_profile_id``: Shaper profile ID of the private shaper to be used by
2856  the node.
2857* ``n_sp_priorities``: Number of strict priorities. Packet mode is enabled on
2858  all of them.
2859* ``stats_mask``: Mask of statistics counter types to be enabled for this node.
2860* ``n_shared_shapers``: Number of shared shapers.
2861* ``shared_shaper_id``: Shared shaper id.
2862
2863Add port traffic management hierarchy leaf node
2864~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2865
2866Add leaf node to port traffic management hierarchy::
2867
2868   testpmd> add port tm leaf node (port_id) (node_id) (parent_node_id) \
2869   (priority) (weight) (level_id) (shaper_profile_id) \
2870   (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers) \
2871   [(shared_shaper_id) (shared_shaper_id) ...] \
2872
2873where:
2874
2875* ``parent_node_id``: Node ID of the parent.
2876* ``priority``: Node priority (highest node priority is zero). This is used by
2877  the SP algorithm running on the parent node for scheduling this node.
2878* ``weight``: Node weight (lowest weight is one). The node weight is relative
2879  to the weight sum of all siblings that have the same priority. It is used by
2880  the WFQ algorithm running on the parent node for scheduling this node.
2881* ``level_id``: Hierarchy level of the node.
2882* ``shaper_profile_id``: Shaper profile ID of the private shaper to be used by
2883  the node.
2884* ``cman_mode``: Congestion management mode to be enabled for this node.
2885* ``wred_profile_id``: WRED profile id to be enabled for this node.
2886* ``stats_mask``: Mask of statistics counter types to be enabled for this node.
2887* ``n_shared_shapers``: Number of shared shapers.
2888* ``shared_shaper_id``: Shared shaper id.
2889
2890Delete port traffic management hierarchy node
2891~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2892
2893Delete node from port traffic management hierarchy::
2894
2895   testpmd> del port tm node (port_id) (node_id)
2896
2897Update port traffic management hierarchy parent node
2898~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2899
2900Update port traffic management hierarchy parent node::
2901
2902   testpmd> set port tm node parent (port_id) (node_id) (parent_node_id) \
2903   (priority) (weight)
2904
2905This function can only be called after the hierarchy commit invocation. Its
2906success depends on the port support for this operation, as advertised through
2907the port capability set. This function is valid for all nodes of the traffic
2908management hierarchy except root node.
2909
2910Suspend port traffic management hierarchy node
2911~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2912
2913   testpmd> suspend port tm node (port_id) (node_id)
2914
2915Resume port traffic management hierarchy node
2916~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2917
2918   testpmd> resume port tm node (port_id) (node_id)
2919
2920Commit port traffic management hierarchy
2921~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2922
2923Commit the traffic management hierarchy on the port::
2924
2925   testpmd> port tm hierarchy commit (port_id) (clean_on_fail)
2926
2927where:
2928
2929* ``clean_on_fail``: When set to non-zero, hierarchy is cleared on function
2930  call failure. On the other hand, hierarchy is preserved when this parameter
2931  is equal to zero.
2932
2933Set port traffic management mark VLAN dei
2934~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2935
2936Enables/Disables the traffic management marking on the port for VLAN packets::
2937
2938   testpmd> set port tm mark vlan_dei <port_id> <green> <yellow> <red>
2939
2940where:
2941
2942* ``port_id``: The port which on which VLAN packets marked as ``green`` or
2943  ``yellow`` or ``red`` will have dei bit enabled
2944
2945* ``green`` enable 1, disable 0 marking for dei bit of VLAN packets marked as green
2946
2947* ``yellow`` enable 1, disable 0 marking for dei bit of VLAN packets marked as yellow
2948
2949* ``red`` enable 1, disable 0 marking for dei bit of VLAN packets marked as red
2950
2951Set port traffic management mark IP dscp
2952~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2953
2954Enables/Disables the traffic management marking on the port for IP dscp packets::
2955
2956   testpmd> set port tm mark ip_dscp <port_id> <green> <yellow> <red>
2957
2958where:
2959
2960* ``port_id``: The port which on which IP packets marked as ``green`` or
2961  ``yellow`` or ``red`` will have IP dscp bits updated
2962
2963* ``green`` enable 1, disable 0 marking IP dscp to low drop precedence for green packets
2964
2965* ``yellow`` enable 1, disable 0 marking IP dscp to medium drop precedence for yellow packets
2966
2967* ``red`` enable 1, disable 0 marking IP dscp to high drop precedence for red packets
2968
2969Set port traffic management mark IP ecn
2970~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2971
2972Enables/Disables the traffic management marking on the port for IP ecn packets::
2973
2974   testpmd> set port tm mark ip_ecn <port_id> <green> <yellow> <red>
2975
2976where:
2977
2978* ``port_id``: The port which on which IP packets marked as ``green`` or
2979  ``yellow`` or ``red`` will have IP ecn bits updated
2980
2981* ``green`` enable 1, disable 0 marking IP ecn for green marked packets with ecn of 2'b01  or 2'b10
2982  to ecn of 2'b11 when IP is caring TCP or SCTP
2983
2984* ``yellow`` enable 1, disable 0 marking IP ecn for yellow marked packets with ecn of 2'b01  or 2'b10
2985  to ecn of 2'b11 when IP is caring TCP or SCTP
2986
2987* ``red`` enable 1, disable 0 marking IP ecn for yellow marked packets with ecn of 2'b01  or 2'b10
2988  to ecn of 2'b11 when IP is caring TCP or SCTP
2989
2990Filter Functions
2991----------------
2992
2993This section details the available filter functions that are available.
2994
2995Note these functions interface the deprecated legacy filtering framework,
2996superseded by *rte_flow*. See `Flow rules management`_.
2997
2998.. _testpmd_flow_director:
2999
3000flow_director_mask
3001~~~~~~~~~~~~~~~~~~
3002
3003Set flow director's input masks::
3004
3005   flow_director_mask (port_id) mode IP vlan (vlan_value) \
3006                      src_mask (ipv4_src) (ipv6_src) (src_port) \
3007                      dst_mask (ipv4_dst) (ipv6_dst) (dst_port)
3008
3009   flow_director_mask (port_id) mode MAC-VLAN vlan (vlan_value)
3010
3011   flow_director_mask (port_id) mode Tunnel vlan (vlan_value) \
3012                      mac (mac_value) tunnel-type (tunnel_type_value) \
3013                      tunnel-id (tunnel_id_value)
3014
3015Example, to set flow director mask on port 0::
3016
3017   testpmd> flow_director_mask 0 mode IP vlan 0xefff \
3018            src_mask 255.255.255.255 \
3019                FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF 0xFFFF \
3020            dst_mask 255.255.255.255 \
3021                FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF 0xFFFF
3022
3023flow_director_flex_payload
3024~~~~~~~~~~~~~~~~~~~~~~~~~~
3025
3026Configure flexible payload selection::
3027
3028   flow_director_flex_payload (port_id) (raw|l2|l3|l4) (config)
3029
3030For example, to select the first 16 bytes from the offset 4 (bytes) of packet's payload as flexible payload::
3031
3032   testpmd> flow_director_flex_payload 0 l4 \
3033            (4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19)
3034
3035
3036.. _testpmd_rte_flow:
3037
3038Flow rules management
3039---------------------
3040
3041Control of the generic flow API (*rte_flow*) is fully exposed through the
3042``flow`` command (configuration, validation, creation, destruction, queries
3043and operation modes).
3044
3045Considering *rte_flow* overlaps with all `Filter Functions`_, using both
3046features simultaneously may cause undefined side-effects and is therefore
3047not recommended.
3048
3049``flow`` syntax
3050~~~~~~~~~~~~~~~
3051
3052Because the ``flow`` command uses dynamic tokens to handle the large number
3053of possible flow rules combinations, its behavior differs slightly from
3054other commands, in particular:
3055
3056- Pressing *?* or the *<tab>* key displays contextual help for the current
3057  token, not that of the entire command.
3058
3059- Optional and repeated parameters are supported (provided they are listed
3060  in the contextual help).
3061
3062The first parameter stands for the operation mode. Possible operations and
3063their general syntax are described below. They are covered in detail in the
3064following sections.
3065
3066- Get info about flow engine::
3067
3068   flow info {port_id}
3069
3070- Configure flow engine::
3071
3072   flow configure {port_id}
3073       [queues_number {number}] [queues_size {size}]
3074       [counters_number {number}]
3075       [aging_counters_number {number}]
3076       [meters_number {number}]
3077
3078- Create a pattern template::
3079   flow pattern_template {port_id} create [pattern_template_id {id}]
3080       [relaxed {boolean}] [ingress] [egress] [transfer]
3081	   template {item} [/ {item} [...]] / end
3082
3083- Destroy a pattern template::
3084
3085   flow pattern_template {port_id} destroy pattern_template {id} [...]
3086
3087- Create an actions template::
3088
3089   flow actions_template {port_id} create [actions_template_id {id}]
3090       [ingress] [egress] [transfer]
3091       template {action} [/ {action} [...]] / end
3092       mask {action} [/ {action} [...]] / end
3093
3094- Destroy an actions template::
3095
3096   flow actions_template {port_id} destroy actions_template {id} [...]
3097
3098- Create a table::
3099
3100   flow table {port_id} create
3101       [table_id {id}]
3102       [group {group_id}] [priority {level}] [ingress] [egress] [transfer]
3103       rules_number {number}
3104       pattern_template {pattern_template_id}
3105       actions_template {actions_template_id}
3106
3107- Destroy a table::
3108
3109   flow table {port_id} destroy table {id} [...]
3110
3111- Check whether a flow rule can be created::
3112
3113   flow validate {port_id}
3114       [group {group_id}] [priority {level}] [ingress] [egress] [transfer]
3115       pattern {item} [/ {item} [...]] / end
3116       actions {action} [/ {action} [...]] / end
3117
3118- Enqueue creation of a flow rule::
3119
3120   flow queue {port_id} create {queue_id}
3121       [postpone {boolean}] template_table {table_id}
3122       pattern_template {pattern_template_index}
3123       actions_template {actions_template_index}
3124       pattern {item} [/ {item} [...]] / end
3125       actions {action} [/ {action} [...]] / end
3126
3127- Enqueue destruction of specific flow rules::
3128
3129   flow queue {port_id} destroy {queue_id}
3130       [postpone {boolean}] rule {rule_id} [...]
3131
3132- Push enqueued operations::
3133
3134   flow push {port_id} queue {queue_id}
3135
3136- Pull all operations results from a queue::
3137
3138   flow pull {port_id} queue {queue_id}
3139
3140- Create a flow rule::
3141
3142   flow create {port_id}
3143       [group {group_id}] [priority {level}] [ingress] [egress] [transfer]
3144       pattern {item} [/ {item} [...]] / end
3145       actions {action} [/ {action} [...]] / end
3146
3147- Destroy specific flow rules::
3148
3149   flow destroy {port_id} rule {rule_id} [...]
3150
3151- Destroy all flow rules::
3152
3153   flow flush {port_id}
3154
3155- Query an existing flow rule::
3156
3157   flow query {port_id} {rule_id} {action}
3158
3159- List existing flow rules sorted by priority, filtered by group
3160  identifiers::
3161
3162   flow list {port_id} [group {group_id}] [...]
3163
3164- Restrict ingress traffic to the defined flow rules::
3165
3166   flow isolate {port_id} {boolean}
3167
3168- Dump internal representation information of all flows in hardware::
3169
3170   flow dump {port_id} all {output_file}
3171
3172  for one flow::
3173
3174   flow dump {port_id} rule {rule_id} {output_file}
3175
3176- List and destroy aged flow rules::
3177
3178   flow aged {port_id} [destroy]
3179
3180- Tunnel offload - create a tunnel stub::
3181
3182   flow tunnel create {port_id} type {tunnel_type}
3183
3184- Tunnel offload - destroy a tunnel stub::
3185
3186   flow tunnel destroy {port_id} id {tunnel_id}
3187
3188- Tunnel offload - list port tunnel stubs::
3189
3190   flow tunnel list {port_id}
3191
3192Retrieving info about flow management engine
3193~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3194
3195``flow info`` retrieves info on pre-configurable resources in the underlying
3196device to give a hint of possible values for flow engine configuration.
3197
3198``rte_flow_info_get()``::
3199
3200   flow info {port_id}
3201
3202If successful, it will show::
3203
3204   Flow engine resources on port #[...]:
3205   Number of queues: #[...]
3206   Size of queues: #[...]
3207   Number of counters: #[...]
3208   Number of aging objects: #[...]
3209   Number of meters: #[...]
3210
3211Otherwise it will show an error message of the form::
3212
3213   Caught error type [...] ([...]): [...]
3214
3215Configuring flow management engine
3216~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3217
3218``flow configure`` pre-allocates all the needed resources in the underlying
3219device to be used later at the flow creation. Flow queues are allocated as well
3220for asynchronous flow creation/destruction operations. It is bound to
3221``rte_flow_configure()``::
3222
3223   flow configure {port_id}
3224       [queues_number {number}] [queues_size {size}]
3225       [counters_number {number}]
3226       [aging_counters_number {number}]
3227       [meters_number {number}]
3228
3229If successful, it will show::
3230
3231   Configure flows on port #[...]: number of queues #[...] with #[...] elements
3232
3233Otherwise it will show an error message of the form::
3234
3235   Caught error type [...] ([...]): [...]
3236
3237Creating pattern templates
3238~~~~~~~~~~~~~~~~~~~~~~~~~~
3239
3240``flow pattern_template create`` creates the specified pattern template.
3241It is bound to ``rte_flow_pattern_template_create()``::
3242
3243   flow pattern_template {port_id} create [pattern_template_id {id}]
3244       [relaxed {boolean}] [ingress] [egress] [transfer]
3245	   template {item} [/ {item} [...]] / end
3246
3247If successful, it will show::
3248
3249   Pattern template #[...] created
3250
3251Otherwise it will show an error message of the form::
3252
3253   Caught error type [...] ([...]): [...]
3254
3255This command uses the same pattern items as ``flow create``,
3256their format is described in `Creating flow rules`_.
3257
3258Destroying pattern templates
3259~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3260
3261``flow pattern_template destroy`` destroys one or more pattern templates
3262from their template ID (as returned by ``flow pattern_template create``),
3263this command calls ``rte_flow_pattern_template_destroy()`` as many
3264times as necessary::
3265
3266   flow pattern_template {port_id} destroy pattern_template {id} [...]
3267
3268If successful, it will show::
3269
3270   Pattern template #[...] destroyed
3271
3272It does not report anything for pattern template IDs that do not exist.
3273The usual error message is shown when a pattern template cannot be destroyed::
3274
3275   Caught error type [...] ([...]): [...]
3276
3277Creating actions templates
3278~~~~~~~~~~~~~~~~~~~~~~~~~~
3279
3280``flow actions_template create`` creates the specified actions template.
3281It is bound to ``rte_flow_actions_template_create()``::
3282
3283   flow actions_template {port_id} create [actions_template_id {id}]
3284       [ingress] [egress] [transfer]
3285	   template {action} [/ {action} [...]] / end
3286       mask {action} [/ {action} [...]] / end
3287
3288If successful, it will show::
3289
3290   Actions template #[...] created
3291
3292Otherwise it will show an error message of the form::
3293
3294   Caught error type [...] ([...]): [...]
3295
3296This command uses the same actions as ``flow create``,
3297their format is described in `Creating flow rules`_.
3298
3299Destroying actions templates
3300~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3301
3302``flow actions_template destroy`` destroys one or more actions templates
3303from their template ID (as returned by ``flow actions_template create``),
3304this command calls ``rte_flow_actions_template_destroy()`` as many
3305times as necessary::
3306
3307   flow actions_template {port_id} destroy actions_template {id} [...]
3308
3309If successful, it will show::
3310
3311   Actions template #[...] destroyed
3312
3313It does not report anything for actions template IDs that do not exist.
3314The usual error message is shown when an actions template cannot be destroyed::
3315
3316   Caught error type [...] ([...]): [...]
3317
3318Creating template table
3319~~~~~~~~~~~~~~~~~~~~~~~
3320
3321``flow template_table create`` creates the specified template table.
3322It is bound to ``rte_flow_template_table_create()``::
3323
3324   flow template_table {port_id} create
3325       [table_id {id}] [group {group_id}]
3326       [priority {level}] [ingress] [egress] [transfer]
3327       rules_number {number}
3328       pattern_template {pattern_template_id}
3329       actions_template {actions_template_id}
3330
3331If successful, it will show::
3332
3333   Template table #[...] created
3334
3335Otherwise it will show an error message of the form::
3336
3337   Caught error type [...] ([...]): [...]
3338
3339Destroying flow table
3340~~~~~~~~~~~~~~~~~~~~~
3341
3342``flow template_table destroy`` destroys one or more template tables
3343from their table ID (as returned by ``flow template_table create``),
3344this command calls ``rte_flow_template_table_destroy()`` as many
3345times as necessary::
3346
3347   flow template_table {port_id} destroy table {id} [...]
3348
3349If successful, it will show::
3350
3351   Template table #[...] destroyed
3352
3353It does not report anything for table IDs that do not exist.
3354The usual error message is shown when a table cannot be destroyed::
3355
3356   Caught error type [...] ([...]): [...]
3357
3358Pushing enqueued operations
3359~~~~~~~~~~~~~~~~~~~~~~~~~~~
3360
3361``flow push`` pushes all the outstanding enqueued operations
3362to the underlying device immediately.
3363It is bound to ``rte_flow_push()``::
3364
3365   flow push {port_id} queue {queue_id}
3366
3367If successful, it will show::
3368
3369   Queue #[...] operations pushed
3370
3371The usual error message is shown when operations cannot be pushed::
3372
3373   Caught error type [...] ([...]): [...]
3374
3375Pulling flow operations results
3376~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3377
3378``flow pull`` asks the underlying device about flow queue operations
3379results and return all the processed (successfully or not) operations.
3380It is bound to ``rte_flow_pull()``::
3381
3382   flow pull {port_id} queue {queue_id}
3383
3384If successful, it will show::
3385
3386   Queue #[...] pulled #[...] operations (#[...] failed, #[...] succeeded)
3387
3388The usual error message is shown when operations results cannot be pulled::
3389
3390   Caught error type [...] ([...]): [...]
3391
3392Creating a tunnel stub for offload
3393~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3394
3395``flow tunnel create`` setup a tunnel stub for tunnel offload flow rules::
3396
3397   flow tunnel create {port_id} type {tunnel_type}
3398
3399If successful, it will return a tunnel stub ID usable with other commands::
3400
3401   port [...]: flow tunnel #[...] type [...]
3402
3403Tunnel stub ID is relative to a port.
3404
3405Destroying tunnel offload stub
3406~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3407
3408``flow tunnel destroy`` destroy port tunnel stub::
3409
3410   flow tunnel destroy {port_id} id {tunnel_id}
3411
3412Listing tunnel offload stubs
3413~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3414
3415``flow tunnel list`` list port tunnel offload stubs::
3416
3417   flow tunnel list {port_id}
3418
3419Validating flow rules
3420~~~~~~~~~~~~~~~~~~~~~
3421
3422``flow validate`` reports whether a flow rule would be accepted by the
3423underlying device in its current state but stops short of creating it. It is
3424bound to ``rte_flow_validate()``::
3425
3426   flow validate {port_id}
3427      [group {group_id}] [priority {level}] [ingress] [egress] [transfer]
3428      pattern {item} [/ {item} [...]] / end
3429      actions {action} [/ {action} [...]] / end
3430
3431If successful, it will show::
3432
3433   Flow rule validated
3434
3435Otherwise it will show an error message of the form::
3436
3437   Caught error type [...] ([...]): [...]
3438
3439This command uses the same parameters as ``flow create``, their format is
3440described in `Creating flow rules`_.
3441
3442Check whether redirecting any Ethernet packet received on port 0 to RX queue
3443index 6 is supported::
3444
3445   testpmd> flow validate 0 ingress pattern eth / end
3446      actions queue index 6 / end
3447   Flow rule validated
3448   testpmd>
3449
3450Port 0 does not support TCPv6 rules::
3451
3452   testpmd> flow validate 0 ingress pattern eth / ipv6 / tcp / end
3453      actions drop / end
3454   Caught error type 9 (specific pattern item): Invalid argument
3455   testpmd>
3456
3457Creating flow rules
3458~~~~~~~~~~~~~~~~~~~
3459
3460``flow create`` validates and creates the specified flow rule. It is bound
3461to ``rte_flow_create()``::
3462
3463   flow create {port_id}
3464      [group {group_id}] [priority {level}] [ingress] [egress] [transfer]
3465      [tunnel_set {tunnel_id}] [tunnel_match {tunnel_id}]
3466      pattern {item} [/ {item} [...]] / end
3467      actions {action} [/ {action} [...]] / end
3468
3469If successful, it will return a flow rule ID usable with other commands::
3470
3471   Flow rule #[...] created
3472
3473Otherwise it will show an error message of the form::
3474
3475   Caught error type [...] ([...]): [...]
3476
3477Parameters describe in the following order:
3478
3479- Attributes (*group*, *priority*, *ingress*, *egress*, *transfer* tokens).
3480- Tunnel offload specification (tunnel_set, tunnel_match)
3481- A matching pattern, starting with the *pattern* token and terminated by an
3482  *end* pattern item.
3483- Actions, starting with the *actions* token and terminated by an *end*
3484  action.
3485
3486These translate directly to *rte_flow* objects provided as-is to the
3487underlying functions.
3488
3489The shortest valid definition only comprises mandatory tokens::
3490
3491   testpmd> flow create 0 pattern end actions end
3492
3493Note that PMDs may refuse rules that essentially do nothing such as this
3494one.
3495
3496**All unspecified object values are automatically initialized to 0.**
3497
3498Enqueueing creation of flow rules
3499~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3500
3501``flow queue create`` adds creation operation of a flow rule to a queue.
3502It is bound to ``rte_flow_async_create()``::
3503
3504   flow queue {port_id} create {queue_id}
3505       [postpone {boolean}] template_table {table_id}
3506       pattern_template {pattern_template_index}
3507       actions_template {actions_template_index}
3508       pattern {item} [/ {item} [...]] / end
3509       actions {action} [/ {action} [...]] / end
3510
3511If successful, it will return a flow rule ID usable with other commands::
3512
3513   Flow rule #[...] creaion enqueued
3514
3515Otherwise it will show an error message of the form::
3516
3517   Caught error type [...] ([...]): [...]
3518
3519This command uses the same pattern items and actions as ``flow create``,
3520their format is described in `Creating flow rules`_.
3521
3522``flow queue pull`` must be called to retrieve the operation status.
3523
3524Attributes
3525^^^^^^^^^^
3526
3527These tokens affect flow rule attributes (``struct rte_flow_attr``) and are
3528specified before the ``pattern`` token.
3529
3530- ``group {group id}``: priority group.
3531- ``priority {level}``: priority level within group.
3532- ``ingress``: rule applies to ingress traffic.
3533- ``egress``: rule applies to egress traffic.
3534- ``transfer``: apply rule directly to endpoints found in pattern.
3535
3536Please note that use of ``transfer`` attribute requires that the flow and
3537its indirect components be managed via so-called ``transfer`` proxy port.
3538See `show flow transfer proxy port ID for the given port`_ for details.
3539
3540Each instance of an attribute specified several times overrides the previous
3541value as shown below (group 4 is used)::
3542
3543   testpmd> flow create 0 group 42 group 24 group 4 [...]
3544
3545Note that once enabled, ``ingress`` and ``egress`` cannot be disabled.
3546
3547While not specifying a direction is an error, some rules may allow both
3548simultaneously.
3549
3550Most rules affect RX therefore contain the ``ingress`` token::
3551
3552   testpmd> flow create 0 ingress pattern [...]
3553
3554Tunnel offload
3555^^^^^^^^^^^^^^
3556
3557Indicate tunnel offload rule type
3558
3559- ``tunnel_set {tunnel_id}``: mark rule as tunnel offload decap_set type.
3560- ``tunnel_match {tunnel_id}``:  mark rule as tunnel offload match type.
3561
3562Matching pattern
3563^^^^^^^^^^^^^^^^
3564
3565A matching pattern starts after the ``pattern`` token. It is made of pattern
3566items and is terminated by a mandatory ``end`` item.
3567
3568Items are named after their type (*RTE_FLOW_ITEM_TYPE_* from ``enum
3569rte_flow_item_type``).
3570
3571The ``/`` token is used as a separator between pattern items as shown
3572below::
3573
3574   testpmd> flow create 0 ingress pattern eth / ipv4 / udp / end [...]
3575
3576Note that protocol items like these must be stacked from lowest to highest
3577layer to make sense. For instance, the following rule is either invalid or
3578unlikely to match any packet::
3579
3580   testpmd> flow create 0 ingress pattern eth / udp / ipv4 / end [...]
3581
3582More information on these restrictions can be found in the *rte_flow*
3583documentation.
3584
3585Several items support additional specification structures, for example
3586``ipv4`` allows specifying source and destination addresses as follows::
3587
3588   testpmd> flow create 0 ingress pattern eth / ipv4 src is 10.1.1.1
3589      dst is 10.2.0.0 / end [...]
3590
3591This rule matches all IPv4 traffic with the specified properties.
3592
3593In this example, ``src`` and ``dst`` are field names of the underlying
3594``struct rte_flow_item_ipv4`` object. All item properties can be specified
3595in a similar fashion.
3596
3597The ``is`` token means that the subsequent value must be matched exactly,
3598and assigns ``spec`` and ``mask`` fields in ``struct rte_flow_item``
3599accordingly. Possible assignment tokens are:
3600
3601- ``is``: match value perfectly (with full bit-mask).
3602- ``spec``: match value according to configured bit-mask.
3603- ``last``: specify upper bound to establish a range.
3604- ``mask``: specify bit-mask with relevant bits set to one.
3605- ``prefix``: generate bit-mask with <prefix-length> most-significant bits set to one.
3606
3607These yield identical results::
3608
3609   ipv4 src is 10.1.1.1
3610
3611::
3612
3613   ipv4 src spec 10.1.1.1 src mask 255.255.255.255
3614
3615::
3616
3617   ipv4 src spec 10.1.1.1 src prefix 32
3618
3619::
3620
3621   ipv4 src is 10.1.1.1 src last 10.1.1.1 # range with a single value
3622
3623::
3624
3625   ipv4 src is 10.1.1.1 src last 0 # 0 disables range
3626
3627Inclusive ranges can be defined with ``last``::
3628
3629   ipv4 src is 10.1.1.1 src last 10.2.3.4 # 10.1.1.1 to 10.2.3.4
3630
3631Note that ``mask`` affects both ``spec`` and ``last``::
3632
3633   ipv4 src is 10.1.1.1 src last 10.2.3.4 src mask 255.255.0.0
3634      # matches 10.1.0.0 to 10.2.255.255
3635
3636Properties can be modified multiple times::
3637
3638   ipv4 src is 10.1.1.1 src is 10.1.2.3 src is 10.2.3.4 # matches 10.2.3.4
3639
3640::
3641
3642   ipv4 src is 10.1.1.1 src prefix 24 src prefix 16 # matches 10.1.0.0/16
3643
3644Pattern items
3645^^^^^^^^^^^^^
3646
3647This section lists supported pattern items and their attributes, if any.
3648
3649- ``end``: end list of pattern items.
3650
3651- ``void``: no-op pattern item.
3652
3653- ``invert``: perform actions when pattern does not match.
3654
3655- ``any``: match any protocol for the current layer.
3656
3657  - ``num {unsigned}``: number of layers covered.
3658
3659- ``pf``: match traffic from/to the physical function.
3660
3661- ``vf``: match traffic from/to a virtual function ID.
3662
3663  - ``id {unsigned}``: VF ID.
3664
3665- ``phy_port``: match traffic from/to a specific physical port.
3666
3667  - ``index {unsigned}``: physical port index.
3668
3669- ``port_id``: match traffic from/to a given DPDK port ID.
3670
3671  - ``id {unsigned}``: DPDK port ID.
3672
3673- ``mark``: match value set in previously matched flow rule using the mark action.
3674
3675  - ``id {unsigned}``: arbitrary integer value.
3676
3677- ``raw``: match an arbitrary byte string.
3678
3679  - ``relative {boolean}``: look for pattern after the previous item.
3680  - ``search {boolean}``: search pattern from offset (see also limit).
3681  - ``offset {integer}``: absolute or relative offset for pattern.
3682  - ``limit {unsigned}``: search area limit for start of pattern.
3683  - ``pattern {string}``: byte string to look for.
3684  - ``pattern_hex {string}``: byte string (provided in hexadecimal) to look for.
3685
3686- ``eth``: match Ethernet header.
3687
3688  - ``dst {MAC-48}``: destination MAC.
3689  - ``src {MAC-48}``: source MAC.
3690  - ``type {unsigned}``: EtherType or TPID.
3691
3692- ``vlan``: match 802.1Q/ad VLAN tag.
3693
3694  - ``tci {unsigned}``: tag control information.
3695  - ``pcp {unsigned}``: priority code point.
3696  - ``dei {unsigned}``: drop eligible indicator.
3697  - ``vid {unsigned}``: VLAN identifier.
3698  - ``inner_type {unsigned}``: inner EtherType or TPID.
3699
3700- ``ipv4``: match IPv4 header.
3701
3702  - ``version_ihl {unsigned}``: IPv4 version and IP header length.
3703  - ``tos {unsigned}``: type of service.
3704  - ``ttl {unsigned}``: time to live.
3705  - ``proto {unsigned}``: next protocol ID.
3706  - ``src {ipv4 address}``: source address.
3707  - ``dst {ipv4 address}``: destination address.
3708
3709- ``ipv6``: match IPv6 header.
3710
3711  - ``tc {unsigned}``: traffic class.
3712  - ``flow {unsigned}``: flow label.
3713  - ``proto {unsigned}``: protocol (next header).
3714  - ``hop {unsigned}``: hop limit.
3715  - ``src {ipv6 address}``: source address.
3716  - ``dst {ipv6 address}``: destination address.
3717
3718- ``icmp``: match ICMP header.
3719
3720  - ``type {unsigned}``: ICMP packet type.
3721  - ``code {unsigned}``: ICMP packet code.
3722
3723- ``udp``: match UDP header.
3724
3725  - ``src {unsigned}``: UDP source port.
3726  - ``dst {unsigned}``: UDP destination port.
3727
3728- ``tcp``: match TCP header.
3729
3730  - ``src {unsigned}``: TCP source port.
3731  - ``dst {unsigned}``: TCP destination port.
3732
3733- ``sctp``: match SCTP header.
3734
3735  - ``src {unsigned}``: SCTP source port.
3736  - ``dst {unsigned}``: SCTP destination port.
3737  - ``tag {unsigned}``: validation tag.
3738  - ``cksum {unsigned}``: checksum.
3739
3740- ``vxlan``: match VXLAN header.
3741
3742  - ``vni {unsigned}``: VXLAN identifier.
3743  - ``last_rsvd {unsigned}``: VXLAN last reserved 8-bits.
3744
3745- ``e_tag``: match IEEE 802.1BR E-Tag header.
3746
3747  - ``grp_ecid_b {unsigned}``: GRP and E-CID base.
3748
3749- ``nvgre``: match NVGRE header.
3750
3751  - ``tni {unsigned}``: virtual subnet ID.
3752
3753- ``mpls``: match MPLS header.
3754
3755  - ``label {unsigned}``: MPLS label.
3756
3757- ``gre``: match GRE header.
3758
3759  - ``protocol {unsigned}``: protocol type.
3760
3761- ``gre_key``: match GRE optional key field.
3762
3763  - ``value {unsigned}``: key value.
3764
3765- ``gre_option``: match GRE optional fields(checksum/key/sequence).
3766
3767  - ``checksum {unsigned}``: checksum value.
3768  - ``key {unsigned}``: key value.
3769  - ``sequence {unsigned}``: sequence number value.
3770
3771- ``fuzzy``: fuzzy pattern match, expect faster than default.
3772
3773  - ``thresh {unsigned}``: accuracy threshold.
3774
3775- ``gtp``, ``gtpc``, ``gtpu``: match GTPv1 header.
3776
3777  - ``teid {unsigned}``: tunnel endpoint identifier.
3778
3779- ``geneve``: match GENEVE header.
3780
3781  - ``vni {unsigned}``: virtual network identifier.
3782  - ``protocol {unsigned}``: protocol type.
3783
3784- ``geneve-opt``: match GENEVE header option.
3785
3786  - ``class {unsigned}``: GENEVE option class.
3787  - ``type {unsigned}``: GENEVE option type.
3788  - ``length {unsigned}``: GENEVE option length in 32-bit words.
3789  - ``data {hex string}``: GENEVE option data, the length is defined by
3790    ``length`` field.
3791
3792- ``vxlan-gpe``: match VXLAN-GPE header.
3793
3794  - ``vni {unsigned}``: VXLAN-GPE identifier.
3795
3796- ``arp_eth_ipv4``: match ARP header for Ethernet/IPv4.
3797
3798  - ``sha {MAC-48}``: sender hardware address.
3799  - ``spa {ipv4 address}``: sender IPv4 address.
3800  - ``tha {MAC-48}``: target hardware address.
3801  - ``tpa {ipv4 address}``: target IPv4 address.
3802
3803- ``ipv6_ext``: match presence of any IPv6 extension header.
3804
3805  - ``next_hdr {unsigned}``: next header.
3806
3807- ``icmp6``: match any ICMPv6 header.
3808
3809  - ``type {unsigned}``: ICMPv6 type.
3810  - ``code {unsigned}``: ICMPv6 code.
3811
3812- ``icmp6_nd_ns``: match ICMPv6 neighbor discovery solicitation.
3813
3814  - ``target_addr {ipv6 address}``: target address.
3815
3816- ``icmp6_nd_na``: match ICMPv6 neighbor discovery advertisement.
3817
3818  - ``target_addr {ipv6 address}``: target address.
3819
3820- ``icmp6_nd_opt``: match presence of any ICMPv6 neighbor discovery option.
3821
3822  - ``type {unsigned}``: ND option type.
3823
3824- ``icmp6_nd_opt_sla_eth``: match ICMPv6 neighbor discovery source Ethernet
3825  link-layer address option.
3826
3827  - ``sla {MAC-48}``: source Ethernet LLA.
3828
3829- ``icmp6_nd_opt_tla_eth``: match ICMPv6 neighbor discovery target Ethernet
3830  link-layer address option.
3831
3832  - ``tla {MAC-48}``: target Ethernet LLA.
3833
3834- ``meta``: match application specific metadata.
3835
3836  - ``data {unsigned}``: metadata value.
3837
3838- ``gtp_psc``: match GTP PDU extension header with type 0x85.
3839
3840  - ``pdu_type {unsigned}``: PDU type.
3841
3842  - ``qfi {unsigned}``: QoS flow identifier.
3843
3844- ``pppoes``, ``pppoed``: match PPPoE header.
3845
3846  - ``session_id {unsigned}``: session identifier.
3847
3848- ``pppoe_proto_id``: match PPPoE session protocol identifier.
3849
3850  - ``proto_id {unsigned}``: PPP protocol identifier.
3851
3852- ``l2tpv3oip``: match L2TPv3 over IP header.
3853
3854  - ``session_id {unsigned}``: L2TPv3 over IP session identifier.
3855
3856- ``ah``: match AH header.
3857
3858  - ``spi {unsigned}``: security parameters index.
3859
3860- ``pfcp``: match PFCP header.
3861
3862  - ``s_field {unsigned}``: S field.
3863  - ``seid {unsigned}``: session endpoint identifier.
3864
3865- ``integrity``: match packet integrity.
3866
3867   - ``level {unsigned}``: Packet encapsulation level the item should
3868     apply to. See rte_flow_action_rss for details.
3869   - ``value {unsigned}``: A bitmask that specify what packet elements
3870     must be matched for integrity.
3871
3872- ``conntrack``: match conntrack state.
3873
3874- ``port_representor``: match traffic entering the embedded switch from the given ethdev
3875
3876  - ``port_id {unsigned}``: ethdev port ID
3877
3878- ``represented_port``: match traffic entering the embedded switch from
3879  the entity represented by the given ethdev
3880
3881  - ``ethdev_port_id {unsigned}``: ethdev port ID
3882
3883- ``l2tpv2``: match L2TPv2 header.
3884
3885  - ``length {unsigned}``: L2TPv2 option length.
3886  - ``tunnel_id {unsigned}``: L2TPv2 tunnel identifier.
3887  - ``session_id {unsigned}``: L2TPv2 session identifier.
3888  - ``ns {unsigned}``: L2TPv2 option ns.
3889  - ``nr {unsigned}``: L2TPv2 option nr.
3890  - ``offset_size {unsigned}``: L2TPv2 option offset.
3891
3892- ``ppp``: match PPP header.
3893
3894  - ``addr {unsigned}``: PPP address.
3895  - ``ctrl {unsigned}``: PPP control.
3896  - ``proto_id {unsigned}``: PPP protocol identifier.
3897
3898Actions list
3899^^^^^^^^^^^^
3900
3901A list of actions starts after the ``actions`` token in the same fashion as
3902`Matching pattern`_; actions are separated by ``/`` tokens and the list is
3903terminated by a mandatory ``end`` action.
3904
3905Actions are named after their type (*RTE_FLOW_ACTION_TYPE_* from ``enum
3906rte_flow_action_type``).
3907
3908Dropping all incoming UDPv4 packets can be expressed as follows::
3909
3910   testpmd> flow create 0 ingress pattern eth / ipv4 / udp / end
3911      actions drop / end
3912
3913Several actions have configurable properties which must be specified when
3914there is no valid default value. For example, ``queue`` requires a target
3915queue index.
3916
3917This rule redirects incoming UDPv4 traffic to queue index 6::
3918
3919   testpmd> flow create 0 ingress pattern eth / ipv4 / udp / end
3920      actions queue index 6 / end
3921
3922While this one could be rejected by PMDs (unspecified queue index)::
3923
3924   testpmd> flow create 0 ingress pattern eth / ipv4 / udp / end
3925      actions queue / end
3926
3927As defined by *rte_flow*, the list is not ordered, all actions of a given
3928rule are performed simultaneously. These are equivalent::
3929
3930   queue index 6 / void / mark id 42 / end
3931
3932::
3933
3934   void / mark id 42 / queue index 6 / end
3935
3936All actions in a list should have different types, otherwise only the last
3937action of a given type is taken into account::
3938
3939   queue index 4 / queue index 5 / queue index 6 / end # will use queue 6
3940
3941::
3942
3943   drop / drop / drop / end # drop is performed only once
3944
3945::
3946
3947   mark id 42 / queue index 3 / mark id 24 / end # mark will be 24
3948
3949Considering they are performed simultaneously, opposite and overlapping
3950actions can sometimes be combined when the end result is unambiguous::
3951
3952   drop / queue index 6 / end # drop has no effect
3953
3954::
3955
3956   queue index 6 / rss queues 6 7 8 / end # queue has no effect
3957
3958::
3959
3960   drop / passthru / end # drop has no effect
3961
3962Note that PMDs may still refuse such combinations.
3963
3964Actions
3965^^^^^^^
3966
3967This section lists supported actions and their attributes, if any.
3968
3969- ``end``: end list of actions.
3970
3971- ``void``: no-op action.
3972
3973- ``passthru``: let subsequent rule process matched packets.
3974
3975- ``jump``: redirect traffic to group on device.
3976
3977  - ``group {unsigned}``: group to redirect to.
3978
3979- ``mark``: attach 32 bit value to packets.
3980
3981  - ``id {unsigned}``: 32 bit value to return with packets.
3982
3983- ``flag``: flag packets.
3984
3985- ``queue``: assign packets to a given queue index.
3986
3987  - ``index {unsigned}``: queue index to use.
3988
3989- ``drop``: drop packets (note: passthru has priority).
3990
3991- ``count``: enable counters for this rule.
3992
3993- ``rss``: spread packets among several queues.
3994
3995  - ``func {hash function}``: RSS hash function to apply, allowed tokens are
3996    ``toeplitz``, ``simple_xor``, ``symmetric_toeplitz`` and ``default``.
3997
3998  - ``level {unsigned}``: encapsulation level for ``types``.
3999
4000  - ``types [{RSS hash type} [...]] end``: specific RSS hash types.
4001    Note that an empty list does not disable RSS but instead requests
4002    unspecified "best-effort" settings.
4003
4004  - ``key {string}``: RSS hash key, overrides ``key_len``.
4005
4006  - ``key_len {unsigned}``: RSS hash key length in bytes, can be used in
4007    conjunction with ``key`` to pad or truncate it.
4008
4009  - ``queues [{unsigned} [...]] end``: queue indices to use.
4010
4011- ``pf``: direct traffic to physical function.
4012
4013- ``vf``: direct traffic to a virtual function ID.
4014
4015  - ``original {boolean}``: use original VF ID if possible.
4016  - ``id {unsigned}``: VF ID.
4017
4018- ``phy_port``: direct packets to physical port index.
4019
4020  - ``original {boolean}``: use original port index if possible.
4021  - ``index {unsigned}``: physical port index.
4022
4023- ``port_id``: direct matching traffic to a given DPDK port ID.
4024
4025  - ``original {boolean}``: use original DPDK port ID if possible.
4026  - ``id {unsigned}``: DPDK port ID.
4027
4028- ``of_set_mpls_ttl``: OpenFlow's ``OFPAT_SET_MPLS_TTL``.
4029
4030  - ``mpls_ttl``: MPLS TTL.
4031
4032- ``of_dec_mpls_ttl``: OpenFlow's ``OFPAT_DEC_MPLS_TTL``.
4033
4034- ``of_set_nw_ttl``: OpenFlow's ``OFPAT_SET_NW_TTL``.
4035
4036  - ``nw_ttl``: IP TTL.
4037
4038- ``of_dec_nw_ttl``: OpenFlow's ``OFPAT_DEC_NW_TTL``.
4039
4040- ``of_copy_ttl_out``: OpenFlow's ``OFPAT_COPY_TTL_OUT``.
4041
4042- ``of_copy_ttl_in``: OpenFlow's ``OFPAT_COPY_TTL_IN``.
4043
4044- ``of_pop_vlan``: OpenFlow's ``OFPAT_POP_VLAN``.
4045
4046- ``of_push_vlan``: OpenFlow's ``OFPAT_PUSH_VLAN``.
4047
4048  - ``ethertype``: Ethertype.
4049
4050- ``of_set_vlan_vid``: OpenFlow's ``OFPAT_SET_VLAN_VID``.
4051
4052  - ``vlan_vid``: VLAN id.
4053
4054- ``of_set_vlan_pcp``: OpenFlow's ``OFPAT_SET_VLAN_PCP``.
4055
4056  - ``vlan_pcp``: VLAN priority.
4057
4058- ``of_pop_mpls``: OpenFlow's ``OFPAT_POP_MPLS``.
4059
4060  - ``ethertype``: Ethertype.
4061
4062- ``of_push_mpls``: OpenFlow's ``OFPAT_PUSH_MPLS``.
4063
4064  - ``ethertype``: Ethertype.
4065
4066- ``vxlan_encap``: Performs a VXLAN encapsulation, outer layer configuration
4067  is done through `Config VXLAN Encap outer layers`_.
4068
4069- ``vxlan_decap``: Performs a decapsulation action by stripping all headers of
4070  the VXLAN tunnel network overlay from the matched flow.
4071
4072- ``nvgre_encap``: Performs a NVGRE encapsulation, outer layer configuration
4073  is done through `Config NVGRE Encap outer layers`_.
4074
4075- ``nvgre_decap``: Performs a decapsulation action by stripping all headers of
4076  the NVGRE tunnel network overlay from the matched flow.
4077
4078- ``l2_encap``: Performs a L2 encapsulation, L2 configuration
4079  is done through `Config L2 Encap`_.
4080
4081- ``l2_decap``: Performs a L2 decapsulation, L2 configuration
4082  is done through `Config L2 Decap`_.
4083
4084- ``mplsogre_encap``: Performs a MPLSoGRE encapsulation, outer layer
4085  configuration is done through `Config MPLSoGRE Encap outer layers`_.
4086
4087- ``mplsogre_decap``: Performs a MPLSoGRE decapsulation, outer layer
4088  configuration is done through `Config MPLSoGRE Decap outer layers`_.
4089
4090- ``mplsoudp_encap``: Performs a MPLSoUDP encapsulation, outer layer
4091  configuration is done through `Config MPLSoUDP Encap outer layers`_.
4092
4093- ``mplsoudp_decap``: Performs a MPLSoUDP decapsulation, outer layer
4094  configuration is done through `Config MPLSoUDP Decap outer layers`_.
4095
4096- ``set_ipv4_src``: Set a new IPv4 source address in the outermost IPv4 header.
4097
4098  - ``ipv4_addr``: New IPv4 source address.
4099
4100- ``set_ipv4_dst``: Set a new IPv4 destination address in the outermost IPv4
4101  header.
4102
4103  - ``ipv4_addr``: New IPv4 destination address.
4104
4105- ``set_ipv6_src``: Set a new IPv6 source address in the outermost IPv6 header.
4106
4107  - ``ipv6_addr``: New IPv6 source address.
4108
4109- ``set_ipv6_dst``: Set a new IPv6 destination address in the outermost IPv6
4110  header.
4111
4112  - ``ipv6_addr``: New IPv6 destination address.
4113
4114- ``set_tp_src``: Set a new source port number in the outermost TCP/UDP
4115  header.
4116
4117  - ``port``: New TCP/UDP source port number.
4118
4119- ``set_tp_dst``: Set a new destination port number in the outermost TCP/UDP
4120  header.
4121
4122  - ``port``: New TCP/UDP destination port number.
4123
4124- ``mac_swap``: Swap the source and destination MAC addresses in the outermost
4125  Ethernet header.
4126
4127- ``dec_ttl``: Performs a decrease TTL value action
4128
4129- ``set_ttl``: Set TTL value with specified value
4130  - ``ttl_value {unsigned}``: The new TTL value to be set
4131
4132- ``set_mac_src``: set source MAC address
4133
4134  - ``mac_addr {MAC-48}``: new source MAC address
4135
4136- ``set_mac_dst``: set destination MAC address
4137
4138  - ``mac_addr {MAC-48}``: new destination MAC address
4139
4140- ``inc_tcp_seq``: Increase sequence number in the outermost TCP header.
4141
4142  - ``value {unsigned}``: Value to increase TCP sequence number by.
4143
4144- ``dec_tcp_seq``: Decrease sequence number in the outermost TCP header.
4145
4146  - ``value {unsigned}``: Value to decrease TCP sequence number by.
4147
4148- ``inc_tcp_ack``: Increase acknowledgment number in the outermost TCP header.
4149
4150  - ``value {unsigned}``: Value to increase TCP acknowledgment number by.
4151
4152- ``dec_tcp_ack``: Decrease acknowledgment number in the outermost TCP header.
4153
4154  - ``value {unsigned}``: Value to decrease TCP acknowledgment number by.
4155
4156- ``set_ipv4_dscp``: Set IPv4 DSCP value with specified value
4157
4158  - ``dscp_value {unsigned}``: The new DSCP value to be set
4159
4160- ``set_ipv6_dscp``: Set IPv6 DSCP value with specified value
4161
4162  - ``dscp_value {unsigned}``: The new DSCP value to be set
4163
4164- ``indirect``: Use indirect action created via
4165  ``flow indirect_action {port_id} create``
4166
4167  - ``indirect_action_id {unsigned}``: Indirect action ID to use
4168
4169- ``color``: Color the packet to reflect the meter color result
4170
4171  - ``type {value}``: Set color type with specified value(green/yellow/red)
4172
4173- ``port_representor``: at embedded switch level, send matching traffic to
4174  the given ethdev
4175
4176  - ``port_id {unsigned}``: ethdev port ID
4177
4178- ``represented_port``: at embedded switch level, send matching traffic to
4179  the entity represented by the given ethdev
4180
4181  - ``ethdev_port_id {unsigned}``: ethdev port ID
4182
4183Destroying flow rules
4184~~~~~~~~~~~~~~~~~~~~~
4185
4186``flow destroy`` destroys one or more rules from their rule ID (as returned
4187by ``flow create``), this command calls ``rte_flow_destroy()`` as many
4188times as necessary::
4189
4190   flow destroy {port_id} rule {rule_id} [...]
4191
4192If successful, it will show::
4193
4194   Flow rule #[...] destroyed
4195
4196It does not report anything for rule IDs that do not exist. The usual error
4197message is shown when a rule cannot be destroyed::
4198
4199   Caught error type [...] ([...]): [...]
4200
4201``flow flush`` destroys all rules on a device and does not take extra
4202arguments. It is bound to ``rte_flow_flush()``::
4203
4204   flow flush {port_id}
4205
4206Any errors are reported as above.
4207
4208Creating several rules and destroying them::
4209
4210   testpmd> flow create 0 ingress pattern eth / ipv6 / end
4211      actions queue index 2 / end
4212   Flow rule #0 created
4213   testpmd> flow create 0 ingress pattern eth / ipv4 / end
4214      actions queue index 3 / end
4215   Flow rule #1 created
4216   testpmd> flow destroy 0 rule 0 rule 1
4217   Flow rule #1 destroyed
4218   Flow rule #0 destroyed
4219   testpmd>
4220
4221The same result can be achieved using ``flow flush``::
4222
4223   testpmd> flow create 0 ingress pattern eth / ipv6 / end
4224      actions queue index 2 / end
4225   Flow rule #0 created
4226   testpmd> flow create 0 ingress pattern eth / ipv4 / end
4227      actions queue index 3 / end
4228   Flow rule #1 created
4229   testpmd> flow flush 0
4230   testpmd>
4231
4232Non-existent rule IDs are ignored::
4233
4234   testpmd> flow create 0 ingress pattern eth / ipv6 / end
4235      actions queue index 2 / end
4236   Flow rule #0 created
4237   testpmd> flow create 0 ingress pattern eth / ipv4 / end
4238      actions queue index 3 / end
4239   Flow rule #1 created
4240   testpmd> flow destroy 0 rule 42 rule 10 rule 2
4241   testpmd>
4242   testpmd> flow destroy 0 rule 0
4243   Flow rule #0 destroyed
4244   testpmd>
4245
4246Enqueueing destruction of flow rules
4247~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4248
4249``flow queue destroy`` adds destruction operations to destroy one or more rules
4250from their rule ID (as returned by ``flow queue create``) to a queue,
4251this command calls ``rte_flow_async_destroy()`` as many times as necessary::
4252
4253   flow queue {port_id} destroy {queue_id}
4254        [postpone {boolean}] rule {rule_id} [...]
4255
4256If successful, it will show::
4257
4258   Flow rule #[...] destruction enqueued
4259
4260It does not report anything for rule IDs that do not exist. The usual error
4261message is shown when a rule cannot be destroyed::
4262
4263   Caught error type [...] ([...]): [...]
4264
4265``flow queue pull`` must be called to retrieve the operation status.
4266
4267Querying flow rules
4268~~~~~~~~~~~~~~~~~~~
4269
4270``flow query`` queries a specific action of a flow rule having that
4271ability. Such actions collect information that can be reported using this
4272command. It is bound to ``rte_flow_query()``::
4273
4274   flow query {port_id} {rule_id} {action}
4275
4276If successful, it will display either the retrieved data for known actions
4277or the following message::
4278
4279   Cannot display result for action type [...] ([...])
4280
4281Otherwise, it will complain either that the rule does not exist or that some
4282error occurred::
4283
4284   Flow rule #[...] not found
4285
4286::
4287
4288   Caught error type [...] ([...]): [...]
4289
4290Currently only the ``count`` action is supported. This action reports the
4291number of packets that hit the flow rule and the total number of bytes. Its
4292output has the following format::
4293
4294   count:
4295    hits_set: [...] # whether "hits" contains a valid value
4296    bytes_set: [...] # whether "bytes" contains a valid value
4297    hits: [...] # number of packets
4298    bytes: [...] # number of bytes
4299
4300Querying counters for TCPv6 packets redirected to queue 6::
4301
4302   testpmd> flow create 0 ingress pattern eth / ipv6 / tcp / end
4303      actions queue index 6 / count / end
4304   Flow rule #4 created
4305   testpmd> flow query 0 4 count
4306   count:
4307    hits_set: 1
4308    bytes_set: 0
4309    hits: 386446
4310    bytes: 0
4311   testpmd>
4312
4313Listing flow rules
4314~~~~~~~~~~~~~~~~~~
4315
4316``flow list`` lists existing flow rules sorted by priority and optionally
4317filtered by group identifiers::
4318
4319   flow list {port_id} [group {group_id}] [...]
4320
4321This command only fails with the following message if the device does not
4322exist::
4323
4324   Invalid port [...]
4325
4326Output consists of a header line followed by a short description of each
4327flow rule, one per line. There is no output at all when no flow rules are
4328configured on the device::
4329
4330   ID      Group   Prio    Attr    Rule
4331   [...]   [...]   [...]   [...]   [...]
4332
4333``Attr`` column flags:
4334
4335- ``i`` for ``ingress``.
4336- ``e`` for ``egress``.
4337
4338Creating several flow rules and listing them::
4339
4340   testpmd> flow create 0 ingress pattern eth / ipv4 / end
4341      actions queue index 6 / end
4342   Flow rule #0 created
4343   testpmd> flow create 0 ingress pattern eth / ipv6 / end
4344      actions queue index 2 / end
4345   Flow rule #1 created
4346   testpmd> flow create 0 priority 5 ingress pattern eth / ipv4 / udp / end
4347      actions rss queues 6 7 8 end / end
4348   Flow rule #2 created
4349   testpmd> flow list 0
4350   ID      Group   Prio    Attr    Rule
4351   0       0       0       i-      ETH IPV4 => QUEUE
4352   1       0       0       i-      ETH IPV6 => QUEUE
4353   2       0       5       i-      ETH IPV4 UDP => RSS
4354   testpmd>
4355
4356Rules are sorted by priority (i.e. group ID first, then priority level)::
4357
4358   testpmd> flow list 1
4359   ID      Group   Prio    Attr    Rule
4360   0       0       0       i-      ETH => COUNT
4361   6       0       500     i-      ETH IPV6 TCP => DROP COUNT
4362   5       0       1000    i-      ETH IPV6 ICMP => QUEUE
4363   1       24      0       i-      ETH IPV4 UDP => QUEUE
4364   4       24      10      i-      ETH IPV4 TCP => DROP
4365   3       24      20      i-      ETH IPV4 => DROP
4366   2       24      42      i-      ETH IPV4 UDP => QUEUE
4367   7       63      0       i-      ETH IPV6 UDP VXLAN => MARK QUEUE
4368   testpmd>
4369
4370Output can be limited to specific groups::
4371
4372   testpmd> flow list 1 group 0 group 63
4373   ID      Group   Prio    Attr    Rule
4374   0       0       0       i-      ETH => COUNT
4375   6       0       500     i-      ETH IPV6 TCP => DROP COUNT
4376   5       0       1000    i-      ETH IPV6 ICMP => QUEUE
4377   7       63      0       i-      ETH IPV6 UDP VXLAN => MARK QUEUE
4378   testpmd>
4379
4380Toggling isolated mode
4381~~~~~~~~~~~~~~~~~~~~~~
4382
4383``flow isolate`` can be used to tell the underlying PMD that ingress traffic
4384must only be injected from the defined flow rules; that no default traffic
4385is expected outside those rules and the driver is free to assign more
4386resources to handle them. It is bound to ``rte_flow_isolate()``::
4387
4388 flow isolate {port_id} {boolean}
4389
4390If successful, enabling or disabling isolated mode shows either::
4391
4392 Ingress traffic on port [...]
4393    is now restricted to the defined flow rules
4394
4395Or::
4396
4397 Ingress traffic on port [...]
4398    is not restricted anymore to the defined flow rules
4399
4400Otherwise, in case of error::
4401
4402   Caught error type [...] ([...]): [...]
4403
4404Mainly due to its side effects, PMDs supporting this mode may not have the
4405ability to toggle it more than once without reinitializing affected ports
4406first (e.g. by exiting testpmd).
4407
4408Enabling isolated mode::
4409
4410 testpmd> flow isolate 0 true
4411 Ingress traffic on port 0 is now restricted to the defined flow rules
4412 testpmd>
4413
4414Disabling isolated mode::
4415
4416 testpmd> flow isolate 0 false
4417 Ingress traffic on port 0 is not restricted anymore to the defined flow rules
4418 testpmd>
4419
4420Dumping HW internal information
4421~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4422
4423``flow dump`` dumps the hardware's internal representation information of
4424all flows. It is bound to ``rte_flow_dev_dump()``::
4425
4426   flow dump {port_id} {output_file}
4427
4428If successful, it will show::
4429
4430   Flow dump finished
4431
4432Otherwise, it will complain error occurred::
4433
4434   Caught error type [...] ([...]): [...]
4435
4436Listing and destroying aged flow rules
4437~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4438
4439``flow aged`` simply lists aged flow rules be get from api ``rte_flow_get_aged_flows``,
4440and ``destroy`` parameter can be used to destroy those flow rules in PMD.
4441
4442   flow aged {port_id} [destroy]
4443
4444Listing current aged flow rules::
4445
4446   testpmd> flow aged 0
4447   Port 0 total aged flows: 0
4448   testpmd> flow create 0 ingress pattern eth / ipv4 src is 2.2.2.14 / end
4449      actions age timeout 5 / queue index 0 /  end
4450   Flow rule #0 created
4451   testpmd> flow create 0 ingress pattern eth / ipv4 src is 2.2.2.15 / end
4452      actions age timeout 4 / queue index 0 /  end
4453   Flow rule #1 created
4454   testpmd> flow create 0 ingress pattern eth / ipv4 src is 2.2.2.16 / end
4455      actions age timeout 2 / queue index 0 /  end
4456   Flow rule #2 created
4457   testpmd> flow create 0 ingress pattern eth / ipv4 src is 2.2.2.17 / end
4458      actions age timeout 3 / queue index 0 /  end
4459   Flow rule #3 created
4460
4461
4462Aged Rules are simply list as command ``flow list {port_id}``, but strip the detail rule
4463information, all the aged flows are sorted by the longest timeout time. For example, if
4464those rules be configured in the same time, ID 2 will be the first aged out rule, the next
4465will be ID 3, ID 1, ID 0::
4466
4467   testpmd> flow aged 0
4468   Port 0 total aged flows: 4
4469   ID      Group   Prio    Attr
4470   2       0       0       i--
4471   3       0       0       i--
4472   1       0       0       i--
4473   0       0       0       i--
4474
4475If attach ``destroy`` parameter, the command will destroy all the list aged flow rules.
4476
4477   testpmd> flow aged 0 destroy
4478   Port 0 total aged flows: 4
4479   ID      Group   Prio    Attr
4480   2       0       0       i--
4481   3       0       0       i--
4482   1       0       0       i--
4483   0       0       0       i--
4484
4485   Flow rule #2 destroyed
4486   Flow rule #3 destroyed
4487   Flow rule #1 destroyed
4488   Flow rule #0 destroyed
4489   4 flows be destroyed
4490   testpmd> flow aged 0
4491   Port 0 total aged flows: 0
4492
4493Creating indirect actions
4494~~~~~~~~~~~~~~~~~~~~~~~~~
4495
4496``flow indirect_action {port_id} create`` creates indirect action with optional
4497indirect action ID. It is bound to ``rte_flow_action_handle_create()``::
4498
4499   flow indirect_action {port_id} create [action_id {indirect_action_id}]
4500      [ingress] [egress] [transfer] action {action} / end
4501
4502If successful, it will show::
4503
4504   Indirect action #[...] created
4505
4506Otherwise, it will complain either that indirect action already exists or that
4507some error occurred::
4508
4509   Indirect action #[...] is already assigned, delete it first
4510
4511::
4512
4513   Caught error type [...] ([...]): [...]
4514
4515Create indirect rss action with id 100 to queues 1 and 2 on port 0::
4516
4517   testpmd> flow indirect_action 0 create action_id 100 \
4518      ingress action rss queues 1 2 end / end
4519
4520Create indirect rss action with id assigned by testpmd to queues 1 and 2 on
4521port 0::
4522
4523	testpmd> flow indirect_action 0 create action_id \
4524		ingress action rss queues 0 1 end / end
4525
4526Enqueueing creation of indirect actions
4527~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4528
4529``flow queue indirect_action create`` adds creation operation of an indirect
4530action to a queue. It is bound to ``rte_flow_async_action_handle_create()``::
4531
4532   flow queue {port_id} create {queue_id} [postpone {boolean}]
4533       table {table_id} item_template {item_template_id}
4534       action_template {action_template_id}
4535       pattern {item} [/ {item} [...]] / end
4536       actions {action} [/ {action} [...]] / end
4537
4538If successful, it will show::
4539
4540   Indirect action #[...] creation queued
4541
4542Otherwise it will show an error message of the form::
4543
4544   Caught error type [...] ([...]): [...]
4545
4546This command uses the same parameters as  ``flow indirect_action create``,
4547described in `Creating indirect actions`_.
4548
4549``flow queue pull`` must be called to retrieve the operation status.
4550
4551Updating indirect actions
4552~~~~~~~~~~~~~~~~~~~~~~~~~
4553
4554``flow indirect_action {port_id} update`` updates configuration of the indirect
4555action from its indirect action ID (as returned by
4556``flow indirect_action {port_id} create``). It is bound to
4557``rte_flow_action_handle_update()``::
4558
4559   flow indirect_action {port_id} update {indirect_action_id}
4560      action {action} / end
4561
4562If successful, it will show::
4563
4564   Indirect action #[...] updated
4565
4566Otherwise, it will complain either that indirect action not found or that some
4567error occurred::
4568
4569   Failed to find indirect action #[...] on port [...]
4570
4571::
4572
4573   Caught error type [...] ([...]): [...]
4574
4575Update indirect rss action having id 100 on port 0 with rss to queues 0 and 3
4576(in create example above rss queues were 1 and 2)::
4577
4578   testpmd> flow indirect_action 0 update 100 action rss queues 0 3 end / end
4579
4580Enqueueing update of indirect actions
4581~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4582
4583``flow queue indirect_action update`` adds update operation for an indirect
4584action to a queue. It is bound to ``rte_flow_async_action_handle_update()``::
4585
4586   flow queue {port_id} indirect_action {queue_id} update
4587      {indirect_action_id} [postpone {boolean}] action {action} / end
4588
4589If successful, it will show::
4590
4591   Indirect action #[...] update queued
4592
4593Otherwise it will show an error message of the form::
4594
4595   Caught error type [...] ([...]): [...]
4596
4597``flow queue pull`` must be called to retrieve the operation status.
4598
4599Destroying indirect actions
4600~~~~~~~~~~~~~~~~~~~~~~~~~~~
4601
4602``flow indirect_action {port_id} destroy`` destroys one or more indirect actions
4603from their indirect action IDs (as returned by
4604``flow indirect_action {port_id} create``). It is bound to
4605``rte_flow_action_handle_destroy()``::
4606
4607   flow indirect_action {port_id} destroy action_id {indirect_action_id} [...]
4608
4609If successful, it will show::
4610
4611   Indirect action #[...] destroyed
4612
4613It does not report anything for indirect action IDs that do not exist.
4614The usual error message is shown when a indirect action cannot be destroyed::
4615
4616   Caught error type [...] ([...]): [...]
4617
4618Destroy indirect actions having id 100 & 101::
4619
4620   testpmd> flow indirect_action 0 destroy action_id 100 action_id 101
4621
4622Enqueueing destruction of indirect actions
4623~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4624
4625``flow queue indirect_action destroy`` adds destruction operation to destroy
4626one or more indirect actions from their indirect action IDs (as returned by
4627``flow queue {port_id} indirect_action {queue_id} create``) to a queue.
4628It is bound to ``rte_flow_async_action_handle_destroy()``::
4629
4630   flow queue {port_id} indirect_action {queue_id} destroy
4631      [postpone {boolean}] action_id {indirect_action_id} [...]
4632
4633If successful, it will show::
4634
4635   Indirect action #[...] destruction queued
4636
4637Otherwise it will show an error message of the form::
4638
4639   Caught error type [...] ([...]): [...]
4640
4641``flow queue pull`` must be called to retrieve the operation status.
4642
4643Query indirect actions
4644~~~~~~~~~~~~~~~~~~~~~~
4645
4646``flow indirect_action {port_id} query`` queries the indirect action from its
4647indirect action ID (as returned by ``flow indirect_action {port_id} create``).
4648It is bound to ``rte_flow_action_handle_query()``::
4649
4650  flow indirect_action {port_id} query {indirect_action_id}
4651
4652Currently only rss indirect action supported. If successful, it will show::
4653
4654   Indirect RSS action:
4655      refs:[...]
4656
4657Otherwise, it will complain either that indirect action not found or that some
4658error occurred::
4659
4660   Failed to find indirect action #[...] on port [...]
4661
4662::
4663
4664   Caught error type [...] ([...]): [...]
4665
4666Query indirect action having id 100::
4667
4668   testpmd> flow indirect_action 0 query 100
4669
4670Sample QinQ flow rules
4671~~~~~~~~~~~~~~~~~~~~~~
4672
4673Before creating QinQ rule(s) the following commands should be issued to enable QinQ::
4674
4675   testpmd> port stop 0
4676   testpmd> vlan set extend on 0
4677
4678The above command sets the inner and outer TPID's to 0x8100.
4679
4680To change the TPID's the following commands should be used::
4681
4682   testpmd> vlan set outer tpid 0x88A8 0
4683   testpmd> vlan set inner tpid 0x8100 0
4684   testpmd> port start 0
4685
4686Validate and create a QinQ rule on port 0 to steer traffic to a VF queue in a VM.
4687
4688::
4689
4690   testpmd> flow validate 0 ingress pattern eth / vlan tci is 123 /
4691       vlan tci is 456 / end actions vf id 1 / queue index 0 / end
4692   Flow rule #0 validated
4693
4694   testpmd> flow create 0 ingress pattern eth / vlan tci is 4 /
4695       vlan tci is 456 / end actions vf id 123 / queue index 0 / end
4696   Flow rule #0 created
4697
4698   testpmd> flow list 0
4699   ID      Group   Prio    Attr    Rule
4700   0       0       0       i-      ETH VLAN VLAN=>VF QUEUE
4701
4702Validate and create a QinQ rule on port 0 to steer traffic to a queue on the host.
4703
4704::
4705
4706   testpmd> flow validate 0 ingress pattern eth / vlan tci is 321 /
4707        vlan tci is 654 / end actions pf / queue index 0 / end
4708   Flow rule #1 validated
4709
4710   testpmd> flow create 0 ingress pattern eth / vlan tci is 321 /
4711        vlan tci is 654 / end actions pf / queue index 1 / end
4712   Flow rule #1 created
4713
4714   testpmd> flow list 0
4715   ID      Group   Prio    Attr    Rule
4716   0       0       0       i-      ETH VLAN VLAN=>VF QUEUE
4717   1       0       0       i-      ETH VLAN VLAN=>PF QUEUE
4718
4719Sample VXLAN flow rules
4720~~~~~~~~~~~~~~~~~~~~~~~
4721
4722Before creating VXLAN rule(s), the UDP port should be added for VXLAN packet
4723filter on a port::
4724
4725  testpmd> rx_vxlan_port add 4789 0
4726
4727Create VXLAN rules on port 0 to steer traffic to PF queues.
4728
4729::
4730
4731  testpmd> flow create 0 ingress pattern eth / ipv4 / udp / vxlan /
4732         eth dst is 00:11:22:33:44:55 / end actions pf / queue index 1 / end
4733  Flow rule #0 created
4734
4735  testpmd> flow create 0 ingress pattern eth / ipv4 / udp / vxlan vni is 3 /
4736         eth dst is 00:11:22:33:44:55 / end actions pf / queue index 2 / end
4737  Flow rule #1 created
4738
4739  testpmd> flow create 0 ingress pattern eth / ipv4 / udp / vxlan /
4740         eth dst is 00:11:22:33:44:55 / vlan tci is 10 / end actions pf /
4741         queue index 3 / end
4742  Flow rule #2 created
4743
4744  testpmd> flow create 0 ingress pattern eth / ipv4 / udp / vxlan vni is 5 /
4745         eth dst is 00:11:22:33:44:55 / vlan tci is 20 / end actions pf /
4746         queue index 4 / end
4747  Flow rule #3 created
4748
4749  testpmd> flow create 0 ingress pattern eth dst is 00:00:00:00:01:00 / ipv4 /
4750         udp / vxlan vni is 6 /  eth dst is 00:11:22:33:44:55 / end actions pf /
4751         queue index 5 / end
4752  Flow rule #4 created
4753
4754  testpmd> flow list 0
4755  ID      Group   Prio    Attr    Rule
4756  0       0       0       i-      ETH IPV4 UDP VXLAN ETH => QUEUE
4757  1       0       0       i-      ETH IPV4 UDP VXLAN ETH => QUEUE
4758  2       0       0       i-      ETH IPV4 UDP VXLAN ETH VLAN => QUEUE
4759  3       0       0       i-      ETH IPV4 UDP VXLAN ETH VLAN => QUEUE
4760  4       0       0       i-      ETH IPV4 UDP VXLAN ETH => QUEUE
4761
4762Sample VXLAN encapsulation rule
4763~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4764
4765VXLAN encapsulation outer layer has default value pre-configured in testpmd
4766source code, those can be changed by using the following commands
4767
4768IPv4 VXLAN outer header::
4769
4770 testpmd> set vxlan ip-version ipv4 vni 4 udp-src 4 udp-dst 4 ip-src 127.0.0.1
4771        ip-dst 128.0.0.1 eth-src 11:11:11:11:11:11 eth-dst 22:22:22:22:22:22
4772 testpmd> flow create 0 ingress pattern end actions vxlan_encap /
4773        queue index 0 / end
4774
4775 testpmd> set vxlan-with-vlan ip-version ipv4 vni 4 udp-src 4 udp-dst 4 ip-src
4776         127.0.0.1 ip-dst 128.0.0.1 vlan-tci 34 eth-src 11:11:11:11:11:11
4777         eth-dst 22:22:22:22:22:22
4778 testpmd> flow create 0 ingress pattern end actions vxlan_encap /
4779         queue index 0 / end
4780
4781 testpmd> set vxlan-tos-ttl ip-version ipv4 vni 4 udp-src 4 udp-dst 4 ip-tos 0
4782         ip-ttl 255 ip-src 127.0.0.1 ip-dst 128.0.0.1 eth-src 11:11:11:11:11:11
4783         eth-dst 22:22:22:22:22:22
4784 testpmd> flow create 0 ingress pattern end actions vxlan_encap /
4785         queue index 0 / end
4786
4787IPv6 VXLAN outer header::
4788
4789 testpmd> set vxlan ip-version ipv6 vni 4 udp-src 4 udp-dst 4 ip-src ::1
4790        ip-dst ::2222 eth-src 11:11:11:11:11:11 eth-dst 22:22:22:22:22:22
4791 testpmd> flow create 0 ingress pattern end actions vxlan_encap /
4792         queue index 0 / end
4793
4794 testpmd> set vxlan-with-vlan ip-version ipv6 vni 4 udp-src 4 udp-dst 4
4795         ip-src ::1 ip-dst ::2222 vlan-tci 34 eth-src 11:11:11:11:11:11
4796         eth-dst 22:22:22:22:22:22
4797 testpmd> flow create 0 ingress pattern end actions vxlan_encap /
4798         queue index 0 / end
4799
4800 testpmd> set vxlan-tos-ttl ip-version ipv6 vni 4 udp-src 4 udp-dst 4
4801         ip-tos 0 ip-ttl 255 ::1 ip-dst ::2222 eth-src 11:11:11:11:11:11
4802         eth-dst 22:22:22:22:22:22
4803 testpmd> flow create 0 ingress pattern end actions vxlan_encap /
4804         queue index 0 / end
4805
4806Sample NVGRE encapsulation rule
4807~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4808
4809NVGRE encapsulation outer layer has default value pre-configured in testpmd
4810source code, those can be changed by using the following commands
4811
4812IPv4 NVGRE outer header::
4813
4814 testpmd> set nvgre ip-version ipv4 tni 4 ip-src 127.0.0.1 ip-dst 128.0.0.1
4815        eth-src 11:11:11:11:11:11 eth-dst 22:22:22:22:22:22
4816 testpmd> flow create 0 ingress pattern end actions nvgre_encap /
4817        queue index 0 / end
4818
4819 testpmd> set nvgre-with-vlan ip-version ipv4 tni 4 ip-src 127.0.0.1
4820         ip-dst 128.0.0.1 vlan-tci 34 eth-src 11:11:11:11:11:11
4821         eth-dst 22:22:22:22:22:22
4822 testpmd> flow create 0 ingress pattern end actions nvgre_encap /
4823         queue index 0 / end
4824
4825IPv6 NVGRE outer header::
4826
4827 testpmd> set nvgre ip-version ipv6 tni 4 ip-src ::1 ip-dst ::2222
4828        eth-src 11:11:11:11:11:11 eth-dst 22:22:22:22:22:22
4829 testpmd> flow create 0 ingress pattern end actions nvgre_encap /
4830        queue index 0 / end
4831
4832 testpmd> set nvgre-with-vlan ip-version ipv6 tni 4 ip-src ::1 ip-dst ::2222
4833        vlan-tci 34 eth-src 11:11:11:11:11:11 eth-dst 22:22:22:22:22:22
4834 testpmd> flow create 0 ingress pattern end actions nvgre_encap /
4835        queue index 0 / end
4836
4837Sample L2 encapsulation rule
4838~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4839
4840L2 encapsulation has default value pre-configured in testpmd
4841source code, those can be changed by using the following commands
4842
4843L2 header::
4844
4845 testpmd> set l2_encap ip-version ipv4
4846        eth-src 11:11:11:11:11:11 eth-dst 22:22:22:22:22:22
4847 testpmd> flow create 0 ingress pattern eth / ipv4 / udp / mpls / end actions
4848        mplsoudp_decap / l2_encap / end
4849
4850L2 with VXLAN header::
4851
4852 testpmd> set l2_encap-with-vlan ip-version ipv4 vlan-tci 34
4853         eth-src 11:11:11:11:11:11 eth-dst 22:22:22:22:22:22
4854 testpmd> flow create 0 ingress pattern eth / ipv4 / udp / mpls / end actions
4855        mplsoudp_decap / l2_encap / end
4856
4857Sample L2 decapsulation rule
4858~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4859
4860L2 decapsulation has default value pre-configured in testpmd
4861source code, those can be changed by using the following commands
4862
4863L2 header::
4864
4865 testpmd> set l2_decap
4866 testpmd> flow create 0 egress pattern eth / end actions l2_decap / mplsoudp_encap /
4867        queue index 0 / end
4868
4869L2 with VXLAN header::
4870
4871 testpmd> set l2_encap-with-vlan
4872 testpmd> flow create 0 egress pattern eth / end actions l2_encap / mplsoudp_encap /
4873         queue index 0 / end
4874
4875Sample MPLSoGRE encapsulation rule
4876~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4877
4878MPLSoGRE encapsulation outer layer has default value pre-configured in testpmd
4879source code, those can be changed by using the following commands
4880
4881IPv4 MPLSoGRE outer header::
4882
4883 testpmd> set mplsogre_encap ip-version ipv4 label 4
4884        ip-src 127.0.0.1 ip-dst 128.0.0.1 eth-src 11:11:11:11:11:11
4885        eth-dst 22:22:22:22:22:22
4886 testpmd> flow create 0 egress pattern eth / end actions l2_decap /
4887        mplsogre_encap / end
4888
4889IPv4 MPLSoGRE with VLAN outer header::
4890
4891 testpmd> set mplsogre_encap-with-vlan ip-version ipv4 label 4
4892        ip-src 127.0.0.1 ip-dst 128.0.0.1 vlan-tci 34
4893        eth-src 11:11:11:11:11:11 eth-dst 22:22:22:22:22:22
4894 testpmd> flow create 0 egress pattern eth / end actions l2_decap /
4895        mplsogre_encap / end
4896
4897IPv6 MPLSoGRE outer header::
4898
4899 testpmd> set mplsogre_encap ip-version ipv6 mask 4
4900        ip-src ::1 ip-dst ::2222 eth-src 11:11:11:11:11:11
4901        eth-dst 22:22:22:22:22:22
4902 testpmd> flow create 0 egress pattern eth / end actions l2_decap /
4903        mplsogre_encap / end
4904
4905IPv6 MPLSoGRE with VLAN outer header::
4906
4907 testpmd> set mplsogre_encap-with-vlan ip-version ipv6 mask 4
4908        ip-src ::1 ip-dst ::2222 vlan-tci 34
4909        eth-src 11:11:11:11:11:11 eth-dst 22:22:22:22:22:22
4910 testpmd> flow create 0 egress pattern eth / end actions l2_decap /
4911        mplsogre_encap / end
4912
4913Sample MPLSoGRE decapsulation rule
4914~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4915
4916MPLSoGRE decapsulation outer layer has default value pre-configured in testpmd
4917source code, those can be changed by using the following commands
4918
4919IPv4 MPLSoGRE outer header::
4920
4921 testpmd> set mplsogre_decap ip-version ipv4
4922 testpmd> flow create 0 ingress pattern eth / ipv4 / gre / mpls / end actions
4923        mplsogre_decap / l2_encap / end
4924
4925IPv4 MPLSoGRE with VLAN outer header::
4926
4927 testpmd> set mplsogre_decap-with-vlan ip-version ipv4
4928 testpmd> flow create 0 ingress pattern eth / vlan / ipv4 / gre / mpls / end
4929        actions mplsogre_decap / l2_encap / end
4930
4931IPv6 MPLSoGRE outer header::
4932
4933 testpmd> set mplsogre_decap ip-version ipv6
4934 testpmd> flow create 0 ingress pattern eth / ipv6 / gre / mpls / end
4935        actions mplsogre_decap / l2_encap / end
4936
4937IPv6 MPLSoGRE with VLAN outer header::
4938
4939 testpmd> set mplsogre_decap-with-vlan ip-version ipv6
4940 testpmd> flow create 0 ingress pattern eth / vlan / ipv6 / gre / mpls / end
4941        actions mplsogre_decap / l2_encap / end
4942
4943Sample MPLSoUDP encapsulation rule
4944~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4945
4946MPLSoUDP encapsulation outer layer has default value pre-configured in testpmd
4947source code, those can be changed by using the following commands
4948
4949IPv4 MPLSoUDP outer header::
4950
4951 testpmd> set mplsoudp_encap ip-version ipv4 label 4 udp-src 5 udp-dst 10
4952        ip-src 127.0.0.1 ip-dst 128.0.0.1 eth-src 11:11:11:11:11:11
4953        eth-dst 22:22:22:22:22:22
4954 testpmd> flow create 0 egress pattern eth / end actions l2_decap /
4955        mplsoudp_encap / end
4956
4957IPv4 MPLSoUDP with VLAN outer header::
4958
4959 testpmd> set mplsoudp_encap-with-vlan ip-version ipv4 label 4 udp-src 5
4960        udp-dst 10 ip-src 127.0.0.1 ip-dst 128.0.0.1 vlan-tci 34
4961        eth-src 11:11:11:11:11:11 eth-dst 22:22:22:22:22:22
4962 testpmd> flow create 0 egress pattern eth / end actions l2_decap /
4963        mplsoudp_encap / end
4964
4965IPv6 MPLSoUDP outer header::
4966
4967 testpmd> set mplsoudp_encap ip-version ipv6 mask 4 udp-src 5 udp-dst 10
4968        ip-src ::1 ip-dst ::2222 eth-src 11:11:11:11:11:11
4969        eth-dst 22:22:22:22:22:22
4970 testpmd> flow create 0 egress pattern eth / end actions l2_decap /
4971        mplsoudp_encap / end
4972
4973IPv6 MPLSoUDP with VLAN outer header::
4974
4975 testpmd> set mplsoudp_encap-with-vlan ip-version ipv6 mask 4 udp-src 5
4976        udp-dst 10 ip-src ::1 ip-dst ::2222 vlan-tci 34
4977        eth-src 11:11:11:11:11:11 eth-dst 22:22:22:22:22:22
4978 testpmd> flow create 0 egress pattern eth / end actions l2_decap /
4979        mplsoudp_encap / end
4980
4981Sample MPLSoUDP decapsulation rule
4982~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4983
4984MPLSoUDP decapsulation outer layer has default value pre-configured in testpmd
4985source code, those can be changed by using the following commands
4986
4987IPv4 MPLSoUDP outer header::
4988
4989 testpmd> set mplsoudp_decap ip-version ipv4
4990 testpmd> flow create 0 ingress pattern eth / ipv4 / udp / mpls / end actions
4991        mplsoudp_decap / l2_encap / end
4992
4993IPv4 MPLSoUDP with VLAN outer header::
4994
4995 testpmd> set mplsoudp_decap-with-vlan ip-version ipv4
4996 testpmd> flow create 0 ingress pattern eth / vlan / ipv4 / udp / mpls / end
4997        actions mplsoudp_decap / l2_encap / end
4998
4999IPv6 MPLSoUDP outer header::
5000
5001 testpmd> set mplsoudp_decap ip-version ipv6
5002 testpmd> flow create 0 ingress pattern eth / ipv6 / udp / mpls / end
5003        actions mplsoudp_decap / l2_encap / end
5004
5005IPv6 MPLSoUDP with VLAN outer header::
5006
5007 testpmd> set mplsoudp_decap-with-vlan ip-version ipv6
5008 testpmd> flow create 0 ingress pattern eth / vlan / ipv6 / udp / mpls / end
5009        actions mplsoudp_decap / l2_encap / end
5010
5011Sample Raw encapsulation rule
5012~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5013
5014Raw encapsulation configuration can be set by the following commands
5015
5016Encapsulating VxLAN::
5017
5018 testpmd> set raw_encap 4 eth src is 10:11:22:33:44:55 / vlan tci is 1
5019        inner_type is 0x0800 / ipv4 / udp dst is 4789 / vxlan vni
5020        is 2 / end_set
5021 testpmd> flow create 0 egress pattern eth / ipv4 / end actions
5022        raw_encap index 4 / end
5023
5024Sample Raw decapsulation rule
5025~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5026
5027Raw decapsulation configuration can be set by the following commands
5028
5029Decapsulating VxLAN::
5030
5031 testpmd> set raw_decap eth / ipv4 / udp / vxlan / end_set
5032 testpmd> flow create 0 ingress pattern eth / ipv4 / udp / vxlan / eth / ipv4 /
5033        end actions raw_decap / queue index 0 / end
5034
5035Sample ESP rules
5036~~~~~~~~~~~~~~~~
5037
5038ESP rules can be created by the following commands::
5039
5040 testpmd> flow create 0 ingress pattern eth / ipv4 / esp spi is 1 / end actions
5041        queue index 3 / end
5042 testpmd> flow create 0 ingress pattern eth / ipv4 / udp / esp spi is 1 / end
5043        actions queue index 3 / end
5044 testpmd> flow create 0 ingress pattern eth / ipv6 / esp spi is 1 / end actions
5045        queue index 3 / end
5046 testpmd> flow create 0 ingress pattern eth / ipv6 / udp / esp spi is 1 / end
5047        actions queue index 3 / end
5048
5049Sample AH rules
5050~~~~~~~~~~~~~~~~
5051
5052AH rules can be created by the following commands::
5053
5054 testpmd> flow create 0 ingress pattern eth / ipv4 / ah spi is 1 / end actions
5055        queue index 3 / end
5056 testpmd> flow create 0 ingress pattern eth / ipv4 / udp / ah spi is 1 / end
5057        actions queue index 3 / end
5058 testpmd> flow create 0 ingress pattern eth / ipv6 / ah spi is 1 / end actions
5059        queue index 3 / end
5060 testpmd> flow create 0 ingress pattern eth / ipv6 / udp / ah spi is 1 / end
5061        actions queue index 3 / end
5062
5063Sample PFCP rules
5064~~~~~~~~~~~~~~~~~
5065
5066PFCP rules can be created by the following commands(s_field need to be 1
5067if seid is set)::
5068
5069 testpmd> flow create 0 ingress pattern eth / ipv4 / pfcp s_field is 0 / end
5070        actions queue index 3 / end
5071 testpmd> flow create 0 ingress pattern eth / ipv4 / pfcp s_field is 1
5072        seid is 1 / end actions queue index 3 / end
5073 testpmd> flow create 0 ingress pattern eth / ipv6 / pfcp s_field is 0 / end
5074        actions queue index 3 / end
5075 testpmd> flow create 0 ingress pattern eth / ipv6 / pfcp s_field is 1
5076        seid is 1 / end actions queue index 3 / end
5077
5078Sample Sampling/Mirroring rules
5079~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5080
5081Sample/Mirroring rules can be set by the following commands
5082
5083NIC-RX Sampling rule, the matched ingress packets and sent to the queue 1,
5084and 50% packets are duplicated and marked with 0x1234 and sent to queue 0.
5085
5086::
5087
5088 testpmd> set sample_actions 0 mark id  0x1234 / queue index 0 / end
5089 testpmd> flow create 0 ingress group 1 pattern eth / end actions
5090        sample ratio 2 index 0 / queue index 1 / end
5091
5092Mirroring rule with port representors (with "transfer" attribute), the matched
5093ingress packets with encapsulation header are sent to port id 0, and also
5094mirrored the packets and sent to port id 2.
5095
5096::
5097
5098 testpmd> set sample_actions 0 port_id id 2 / end
5099 testpmd> flow create 1 ingress transfer pattern eth / end actions
5100        sample ratio 1 index 0  / raw_encap / port_id id 0 / end
5101
5102Mirroring rule with port representors (with "transfer" attribute), the matched
5103ingress packets are sent to port id 2, and also mirrored the packets with
5104encapsulation header and sent to port id 0.
5105
5106::
5107
5108 testpmd> set sample_actions 0 raw_encap / port_id id 0 / end
5109 testpmd> flow create 0 ingress transfer pattern eth / end actions
5110        sample ratio 1 index 0  / port_id id 2 / end
5111
5112Mirroring rule with port representors (with "transfer" attribute), the matched
5113ingress packets are sent to port id 2, and also mirrored the packets with
5114VXLAN encapsulation header and sent to port id 0.
5115
5116::
5117
5118 testpmd> set vxlan ip-version ipv4 vni 4 udp-src 4 udp-dst 4 ip-src 127.0.0.1
5119        ip-dst 128.0.0.1 eth-src 11:11:11:11:11:11 eth-dst 22:22:22:22:22:22
5120 testpmd> set sample_actions 0 vxlan_encap / port_id id 0 / end
5121 testpmd> flow create 0 ingress transfer pattern eth / end actions
5122        sample ratio 1 index 0  / port_id id 2 / end
5123
5124Mirroring rule with port representors (with "transfer" attribute), the matched
5125ingress packets are sent to port id 2, and also mirrored the packets with
5126NVGRE encapsulation header and sent to port id 0.
5127
5128::
5129
5130 testpmd> set nvgre ip-version ipv4 tni 4 ip-src 127.0.0.1 ip-dst 128.0.0.1
5131        eth-src 11:11:11:11:11:11 eth-dst 22:22:22:22:22:22
5132 testpmd> set sample_actions 0 nvgre_encap / port_id id 0 / end
5133 testpmd> flow create 0 ingress transfer pattern eth / end actions
5134        sample ratio 1 index 0  / port_id id 2 / end
5135
5136Sample integrity rules
5137~~~~~~~~~~~~~~~~~~~~~~
5138
5139Integrity rules can be created by the following commands:
5140
5141Integrity rule that forwards valid TCP packets to group 1.
5142TCP packet integrity is matched with the ``l4_ok`` bit 3.
5143
5144::
5145
5146 testpmd> flow create 0 ingress
5147            pattern eth / ipv4 / tcp / integrity value mask 8 value spec 8 / end
5148            actions jump group 1 / end
5149
5150Integrity rule that forwards invalid packets to application.
5151General packet integrity is matched with the ``packet_ok`` bit 0.
5152
5153::
5154
5155 testpmd> flow create 0 ingress pattern integrity value mask 1 value spec 0 / end actions queue index 0 / end
5156
5157Sample conntrack rules
5158~~~~~~~~~~~~~~~~~~~~~~
5159
5160Conntrack rules can be set by the following commands
5161
5162Need to construct the connection context with provided information.
5163In the first table, create a flow rule by using conntrack action and jump to
5164the next table. In the next table, create a rule to check the state.
5165
5166::
5167
5168 testpmd> set conntrack com peer 1 is_orig 1 enable 1 live 1 sack 1 cack 0
5169        last_dir 0 liberal 0 state 1 max_ack_win 7 r_lim 5 last_win 510
5170        last_seq 2632987379 last_ack 2532480967 last_end 2632987379
5171        last_index 0x8
5172 testpmd> set conntrack orig scale 7 fin 0 acked 1 unack_data 0
5173        sent_end 2632987379 reply_end 2633016339 max_win 28960
5174        max_ack 2632987379
5175 testpmd> set conntrack rply scale 7 fin 0 acked 1 unack_data 0
5176        sent_end 2532480967 reply_end 2532546247 max_win 65280
5177        max_ack 2532480967
5178 testpmd> flow indirect_action 0 create ingress action conntrack / end
5179 testpmd> flow create 0 group 3 ingress pattern eth / ipv4 / tcp / end actions indirect 0 / jump group 5 / end
5180 testpmd> flow create 0 group 5 ingress pattern eth / ipv4 / tcp / conntrack is 1 / end actions queue index 5 / end
5181
5182Construct the conntrack again with only "is_orig" set to 0 (other fields are
5183ignored), then use "update" interface to update the direction. Create flow
5184rules like above for the peer port.
5185
5186::
5187
5188 testpmd> flow indirect_action 0 update 0 action conntrack_update dir / end
5189
5190Sample meter with policy rules
5191~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5192
5193Meter with policy rules can be created by the following commands:
5194
5195Need to create policy first and actions are set for green/yellow/red colors.
5196Create meter with policy id. Create flow with meter id.
5197
5198Example for policy with meter color action. The purpose is to color the packet
5199to reflect the meter color result.
5200The meter policy action list: ``green -> green, yellow -> yellow, red -> red``.
5201
5202::
5203
5204   testpmd> add port meter profile srtcm_rfc2697 0 13 21504 2688 0 0
5205   testpmd> add port meter policy 0 1 g_actions color type green / end y_actions color type yellow / end
5206            r_actions color type red / end
5207   testpmd> create port meter 0 1 13 1 yes 0xffff 0 0
5208   testpmd> flow create 0 priority 0 ingress group 1 pattern eth / end actions meter mtr_id 1 / end
5209
5210Sample L2TPv2 RSS rules
5211~~~~~~~~~~~~~~~~~~~~~~~
5212
5213L2TPv2 RSS rules can be created by the following commands::
5214
5215   testpmd> flow create 0 ingress pattern eth / ipv4 / udp / l2tpv2 type control
5216            / end actions rss types l2tpv2 end queues end / end
5217   testpmd> flow create 0 ingress pattern eth / ipv4 / udp / l2tpv2 / end
5218            actions rss types eth l2-src-only end queues end / end
5219   testpmd> flow create 0 ingress pattern eth / ipv4 / udp / l2tpv2 / ppp / end
5220            actions rss types l2tpv2 end queues end / end
5221   testpmd> flow create 0 ingress pattern eth / ipv4 / udp / l2tpv2 / ppp / ipv4
5222            / end actions rss types ipv4 end queues end / end
5223   testpmd> flow create 0 ingress pattern eth / ipv4 / udp / l2tpv2 / ppp / ipv6
5224            / udp / end actions rss types ipv6-udp end queues end / end
5225   testpmd> flow create 0 ingress pattern eth / ipv6 / udp / l2tpv2 / ppp / ipv4
5226            / tcp / end actions rss types ipv4-tcp end queues end / end
5227   testpmd> flow create 0 ingress pattern eth / ipv6 / udp / l2tpv2 / ppp / ipv6
5228            / end actions rss types ipv6 end queues end / end
5229
5230Sample L2TPv2 FDIR rules
5231~~~~~~~~~~~~~~~~~~~~~~~~
5232
5233L2TPv2 FDIR rules can be created by the following commands::
5234
5235   testpmd> flow create 0 ingress pattern eth / ipv4 / udp / l2tpv2 type control
5236            session_id is 0x1111 / end actions queue index 3 / end
5237   testpmd> flow create 0 ingress pattern eth src is 00:00:00:00:00:01 / ipv4
5238            / udp / l2tpv2 type data / end actions queue index 3 / end
5239   testpmd> flow create 0 ingress pattern eth / ipv4 / udp / l2tpv2 type data
5240            session_id is 0x1111 / ppp / end actions queue index 3 / end
5241   testpmd> flow create 0 ingress pattern eth / ipv4 / udp / l2tpv2 / ppp / ipv4
5242            src is 10.0.0.1 / end actions queue index 3 / end
5243   testpmd> flow create 0 ingress pattern eth / ipv6 / udp / l2tpv2 / ppp / ipv6
5244            dst is ABAB:910B:6666:3457:8295:3333:1800:2929 / end actions queue index 3 / end
5245   testpmd> flow create 0 ingress pattern eth / ipv4 / udp / l2tpv2 / ppp / ipv4
5246            / udp src is 22 / end actions queue index 3 / end
5247   testpmd> flow create 0 ingress pattern eth / ipv4 / udp / l2tpv2 / ppp / ipv4
5248            / tcp dst is 23 / end actions queue index 3 / end
5249
5250Sample RAW rule
5251~~~~~~~~~~~~~~~
5252
5253A RAW rule can be created as following using ``pattern_hex`` key and mask.
5254
5255::
5256
5257    testpmd> flow create 0 group 0 priority 1 ingress pattern raw relative is 0 search is 0 offset
5258             is 0 limit is 0 pattern_hex spec 00000000000000000000000000000000000000000000000000000a0a0a0a
5259             pattern_hex mask 0000000000000000000000000000000000000000000000000000ffffffff / end actions
5260             queue index 4 / end
5261
5262BPF Functions
5263--------------
5264
5265The following sections show functions to load/unload eBPF based filters.
5266
5267bpf-load
5268~~~~~~~~
5269
5270Load an eBPF program as a callback for particular RX/TX queue::
5271
5272   testpmd> bpf-load rx|tx (portid) (queueid) (load-flags) (bpf-prog-filename)
5273
5274The available load-flags are:
5275
5276* ``J``: use JIT generated native code, otherwise BPF interpreter will be used.
5277
5278* ``M``: assume input parameter is a pointer to rte_mbuf, otherwise assume it is a pointer to first segment's data.
5279
5280* ``-``: none.
5281
5282.. note::
5283
5284   You'll need clang v3.7 or above to build bpf program you'd like to load
5285
5286For example:
5287
5288.. code-block:: console
5289
5290   cd examples/bpf
5291   clang -O2 -target bpf -c t1.c
5292
5293Then to load (and JIT compile) t1.o at RX queue 0, port 1:
5294
5295.. code-block:: console
5296
5297   testpmd> bpf-load rx 1 0 J ./dpdk.org/examples/bpf/t1.o
5298
5299To load (not JITed) t1.o at TX queue 0, port 0:
5300
5301.. code-block:: console
5302
5303   testpmd> bpf-load tx 0 0 - ./dpdk.org/examples/bpf/t1.o
5304
5305bpf-unload
5306~~~~~~~~~~
5307
5308Unload previously loaded eBPF program for particular RX/TX queue::
5309
5310   testpmd> bpf-unload rx|tx (portid) (queueid)
5311
5312For example to unload BPF filter from TX queue 0, port 0:
5313
5314.. code-block:: console
5315
5316   testpmd> bpf-unload tx 0 0
5317
5318Flex Item Functions
5319-------------------
5320
5321The following sections show functions that configure and create flex item object,
5322create flex pattern and use it in a flow rule.
5323The commands will use 20 bytes IPv4 header for examples:
5324
5325::
5326
5327   0                   1                   2                   3
5328   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
5329   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
5330   |  ver  |  IHL  |     TOS       |        length                 | +0
5331   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
5332   |       identification          | flg |    frag. offset         | +4
5333   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
5334   |       TTL     |  protocol     |        checksum               | +8
5335   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
5336   |               source IP address                               | +12
5337   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
5338   |              destination IP address                           | +16
5339   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
5340
5341
5342Create flex item
5343~~~~~~~~~~~~~~~~
5344
5345Flex item object is created by PMD according to a new header configuration. The
5346header configuration is compiled by the testpmd and stored in
5347``rte_flow_item_flex_conf`` type variable.
5348
5349::
5350
5351   # flow flex_item create <port> <flex id> <configuration file>
5352   testpmd> flow flex_item init 0 3 ipv4_flex_config.json
5353   port-0: created flex item #3
5354
5355Flex item configuration is kept in external JSON file.
5356It describes the following header elements:
5357
5358**New header length.**
5359
5360Specify whether the new header has fixed or variable length and the basic/minimal
5361header length value.
5362
5363If header length is not fixed, header location with a value that completes header
5364length calculation and scale/offset function must be added.
5365
5366Scale function depends on port hardware.
5367
5368**Next protocol.**
5369
5370Describes location in the new header that specify following network header type.
5371
5372**Flow match samples.**
5373
5374Describes locations in the new header that will be used in flow rules.
5375
5376Number of flow samples and sample maximal length depend of port hardware.
5377
5378**Input trigger.**
5379
5380Describes preceding network header configuration.
5381
5382**Output trigger.**
5383
5384Describes conditions that trigger transfer to following network header
5385
5386.. code-block:: json
5387
5388   {
5389      "next_header": { "field_mode": "FIELD_MODE_FIXED", "field_size": 20},
5390      "next_protocol": {"field_size": 8, "field_base": 72},
5391      "sample_data": [
5392         { "field_mode": "FIELD_MODE_FIXED", "field_size": 32, "field_base": 0},
5393         { "field_mode": "FIELD_MODE_FIXED", "field_size": 32, "field_base": 32},
5394         { "field_mode": "FIELD_MODE_FIXED", "field_size": 32, "field_base": 64},
5395         { "field_mode": "FIELD_MODE_FIXED", "field_size": 32, "field_base": 96}
5396      ],
5397      "input_link": [
5398         {"item": "eth type is 0x0800"},
5399         {"item": "vlan inner_type is 0x0800"}
5400      ],
5401      "output_link": [
5402         {"item": "udp", "next": 17},
5403         {"item": "tcp", "next": 6},
5404         {"item": "icmp", "next": 1}
5405      ]
5406   }
5407
5408
5409Flex pattern and flow rules
5410~~~~~~~~~~~~~~~~~~~~~~~~~~~
5411
5412Flex pattern describe parts of network header that will trigger flex flow item hit in a flow rule.
5413Flex pattern directly related to flex item samples configuration.
5414Flex pattern can be shared between ports.
5415
5416**Flex pattern and flow rule to match IPv4 version and 20 bytes length**
5417
5418::
5419
5420   # set flex_pattern <pattern_id> is <hex bytes sequence>
5421   testpmd> flow flex_item pattern 5 is 45FF
5422   created pattern #5
5423
5424   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
5425   Flow rule #0 created
5426
5427**Flex pattern and flow rule to match packets with source address 1.2.3.4**
5428
5429::
5430
5431   testpmd> flow flex_item pattern 2 spec 45000000000000000000000001020304 mask FF0000000000000000000000FFFFFFFF
5432   created pattern #2
5433
5434   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
5435   Flow rule #0 created
5436
5437Driver specific commands
5438------------------------
5439
5440Some drivers provide specific features.
5441See:
5442
5443- :ref:`net/bonding testpmd driver specific commands <bonding_testpmd_commands>`
5444- :ref:`net/i40e testpmd driver specific commands <net_i40e_testpmd_commands>`
5445