19a82259dSJunyu Jiang.. SPDX-License-Identifier: BSD-3-Clause 29a82259dSJunyu Jiang Copyright(c) 2020 Intel Corporation. 39a82259dSJunyu Jiang 49a82259dSJunyu JiangVMDq Forwarding Sample Application 59a82259dSJunyu Jiang========================================== 69a82259dSJunyu Jiang 79a82259dSJunyu JiangThe VMDq Forwarding sample application is a simple example of packet processing using the DPDK. 89a82259dSJunyu JiangThe application performs L2 forwarding using VMDq to divide the incoming traffic into queues. 99a82259dSJunyu JiangThe traffic splitting is performed in hardware by the VMDq feature of the Intel® 82599 and X710/XL710 Ethernet Controllers. 109a82259dSJunyu Jiang 119a82259dSJunyu JiangOverview 129a82259dSJunyu Jiang-------- 139a82259dSJunyu Jiang 149a82259dSJunyu JiangThis sample application can be used as a starting point for developing a new application that is based on the DPDK and 159a82259dSJunyu Jianguses VMDq for traffic partitioning. 169a82259dSJunyu Jiang 179a82259dSJunyu JiangVMDq filters split the incoming packets up into different "pools" - each with its own set of RX queues - based upon 189a82259dSJunyu Jiangthe MAC address and VLAN ID within the VLAN tag of the packet. 199a82259dSJunyu Jiang 209a82259dSJunyu JiangAll traffic is read from a single incoming port and output on another port, without any processing being performed. 219a82259dSJunyu JiangWith Intel® 82599 NIC, for example, the traffic is split into 128 queues on input, where each thread of the application reads from 229a82259dSJunyu Jiangmultiple queues. When run with 8 threads, that is, with the -c FF option, each thread receives and forwards packets from 16 queues. 239a82259dSJunyu Jiang 249a82259dSJunyu JiangAs supplied, the sample application configures the VMDq feature to have 32 pools with 4 queues each. 259a82259dSJunyu JiangThe Intel® 82599 10 Gigabit Ethernet Controller NIC also supports the splitting of traffic into 16 pools of 2 queues. 269a82259dSJunyu JiangWhile the Intel® X710 or XL710 Ethernet Controller NICs support many configurations of VMDq pools of 4 or 8 queues each. 27e2a94f9aSCiara PowerAnd queues numbers for each VMDq pool can be changed by setting RTE_LIBRTE_I40E_QUEUE_NUM_PER_VM 28e2a94f9aSCiara Powerin config/rte_config.h file. 298f5b4af7SJunyu JiangThe nb-pools and enable-rss parameters can be passed on the command line, after the EAL parameters: 309a82259dSJunyu Jiang 319a82259dSJunyu Jiang.. code-block:: console 329a82259dSJunyu Jiang 33e2a94f9aSCiara Power ./<build_dir>/examples/dpdk-vmdq [EAL options] -- -p PORTMASK --nb-pools NP --enable-rss 349a82259dSJunyu Jiang 358f5b4af7SJunyu Jiangwhere, NP can be 8, 16 or 32, rss is disabled by default. 369a82259dSJunyu Jiang 379a82259dSJunyu JiangIn Linux* user space, the application can display statistics with the number of packets received on each queue. 389a82259dSJunyu JiangTo have the application display the statistics, send a SIGHUP signal to the running application process. 399a82259dSJunyu Jiang 409a82259dSJunyu JiangThe VMDq Forwarding sample application is in many ways simpler than the L2 Forwarding application 419a82259dSJunyu Jiang(see :doc:`l2_forward_real_virtual`) 429a82259dSJunyu Jiangas it performs unidirectional L2 forwarding of packets from one port to a second port. 439a82259dSJunyu JiangNo command-line options are taken by this application apart from the standard EAL command-line options. 449a82259dSJunyu Jiang 459a82259dSJunyu JiangCompiling the Application 469a82259dSJunyu Jiang------------------------- 479a82259dSJunyu Jiang 489a82259dSJunyu JiangTo compile the sample application see :doc:`compiling`. 499a82259dSJunyu Jiang 509a82259dSJunyu JiangThe application is located in the ``vmdq`` sub-directory. 519a82259dSJunyu Jiang 529a82259dSJunyu JiangRunning the Application 539a82259dSJunyu Jiang----------------------- 549a82259dSJunyu Jiang 559a82259dSJunyu JiangTo run the example in a Linux environment: 569a82259dSJunyu Jiang 579a82259dSJunyu Jiang.. code-block:: console 589a82259dSJunyu Jiang 59e2a94f9aSCiara Power user@target:~$ ./<build_dir>/examples/dpdk-vmdq -l 0-3 -n 4 -- -p 0x3 --nb-pools 16 609a82259dSJunyu Jiang 619a82259dSJunyu JiangRefer to the *DPDK Getting Started Guide* for general information on running applications and 629a82259dSJunyu Jiangthe Environment Abstraction Layer (EAL) options. 639a82259dSJunyu Jiang 649a82259dSJunyu JiangExplanation 659a82259dSJunyu Jiang----------- 669a82259dSJunyu Jiang 679a82259dSJunyu JiangThe following sections provide some explanation of the code. 689a82259dSJunyu Jiang 699a82259dSJunyu JiangInitialization 709a82259dSJunyu Jiang~~~~~~~~~~~~~~ 719a82259dSJunyu Jiang 729a82259dSJunyu JiangThe EAL, driver and PCI configuration is performed largely as in the L2 Forwarding sample application, 739a82259dSJunyu Jiangas is the creation of the mbuf pool. 749a82259dSJunyu JiangSee :doc:`l2_forward_real_virtual`. 759a82259dSJunyu JiangWhere this example application differs is in the configuration of the NIC port for RX. 769a82259dSJunyu Jiang 779a82259dSJunyu JiangThe VMDq hardware feature is configured at port initialization time by setting the appropriate values in the 789a82259dSJunyu Jiangrte_eth_conf structure passed to the rte_eth_dev_configure() API. 799a82259dSJunyu JiangInitially in the application, 809a82259dSJunyu Jianga default structure is provided for VMDq configuration to be filled in later by the application. 819a82259dSJunyu Jiang 829a212dc0SConor Fogarty.. literalinclude:: ../../../examples/vmdq/main.c 839a212dc0SConor Fogarty :language: c 849a212dc0SConor Fogarty :start-after: Default structure for VMDq. 8< 859a212dc0SConor Fogarty :end-before: >8 End of Empty vdmq configuration structure. 869a82259dSJunyu Jiang 879a82259dSJunyu JiangThe get_eth_conf() function fills in an rte_eth_conf structure with the appropriate values, 889a82259dSJunyu Jiangbased on the global vlan_tags array. 899a82259dSJunyu JiangFor the VLAN IDs, each one can be allocated to possibly multiple pools of queues. 909a82259dSJunyu JiangFor destination MAC, each VMDq pool will be assigned with a MAC address. In this sample, each VMDq pool 919a82259dSJunyu Jiangis assigned to the MAC like 52:54:00:12:<port_id>:<pool_id>, that is, 929a82259dSJunyu Jiangthe MAC of VMDq pool 2 on port 1 is 52:54:00:12:01:02. 939a82259dSJunyu Jiang 949a212dc0SConor Fogarty.. literalinclude:: ../../../examples/vmdq/main.c 959a212dc0SConor Fogarty :language: c 969a212dc0SConor Fogarty :start-after: vlan_tags 8< 979a212dc0SConor Fogarty :end-before: >8 End of vlan_tags. 989a82259dSJunyu Jiang 999a212dc0SConor Fogarty.. literalinclude:: ../../../examples/vmdq/main.c 1009a212dc0SConor Fogarty :language: c 1019a212dc0SConor Fogarty :start-after: Pool mac address template. 8< 1029a212dc0SConor Fogarty :end-before: >8 End of mac addr template. 1039a82259dSJunyu Jiang 1049a212dc0SConor Fogarty.. literalinclude:: ../../../examples/vmdq/main.c 1059a212dc0SConor Fogarty :language: c 106*a2a43d3aSRay Kinsella :start-after: Building correct configuration for vdmq. 8< 1079a212dc0SConor Fogarty :end-before: >8 End of get_eth_conf. 1089a82259dSJunyu Jiang 1099a82259dSJunyu JiangOnce the network port has been initialized using the correct VMDq values, 1109a82259dSJunyu Jiangthe initialization of the port's RX and TX hardware rings is performed similarly to that 1119a82259dSJunyu Jiangin the L2 Forwarding sample application. 1129a82259dSJunyu JiangSee :doc:`l2_forward_real_virtual` for more information. 1139a82259dSJunyu Jiang 1149a82259dSJunyu JiangStatistics Display 1159a82259dSJunyu Jiang~~~~~~~~~~~~~~~~~~ 1169a82259dSJunyu Jiang 1179a82259dSJunyu JiangWhen run in a Linux environment, 1189a82259dSJunyu Jiangthe VMDq Forwarding sample application can display statistics showing the number of packets read from each RX queue. 1199a82259dSJunyu JiangThis is provided by way of a signal handler for the SIGHUP signal, 1209a82259dSJunyu Jiangwhich simply prints to standard output the packet counts in grid form. 1219a82259dSJunyu JiangEach row of the output is a single pool with the columns being the queue number within that pool. 1229a82259dSJunyu Jiang 1239a82259dSJunyu JiangTo generate the statistics output, use the following command: 1249a82259dSJunyu Jiang 1259a82259dSJunyu Jiang.. code-block:: console 1269a82259dSJunyu Jiang 1279a82259dSJunyu Jiang user@host$ sudo killall -HUP vmdq_app 1289a82259dSJunyu Jiang 1299a82259dSJunyu JiangPlease note that the statistics output will appear on the terminal where the vmdq_app is running, 1309a82259dSJunyu Jiangrather than the terminal from which the HUP signal was sent. 131