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