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