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