2018-02-01 17:18:17 +00:00
|
|
|
|
.. SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
|
Copyright(c) 2010-2014 Intel Corporation.
|
2014-12-02 14:02:46 +00:00
|
|
|
|
|
|
|
|
|
Distributor Sample Application
|
|
|
|
|
==============================
|
|
|
|
|
|
|
|
|
|
The distributor sample application is a simple example of packet distribution
|
2019-05-02 11:18:13 +00:00
|
|
|
|
to cores using the Data Plane Development Kit (DPDK). It also makes use of
|
|
|
|
|
Intel Speed Select Technology - Base Frequency (Intel SST-BF) to pin the
|
|
|
|
|
distributor to the higher frequency core if available.
|
2014-12-02 14:02:46 +00:00
|
|
|
|
|
|
|
|
|
Overview
|
|
|
|
|
--------
|
|
|
|
|
|
|
|
|
|
The distributor application performs the distribution of packets that are received
|
|
|
|
|
on an RX_PORT to different cores. When processed by the cores, the destination
|
|
|
|
|
port of a packet is the port from the enabled port mask adjacent to the one on
|
|
|
|
|
which the packet was received, that is, if the first four ports are enabled
|
|
|
|
|
(port mask 0xf), ports 0 and 1 RX/TX into each other, and ports 2 and 3 RX/TX
|
|
|
|
|
into each other.
|
|
|
|
|
|
|
|
|
|
This application can be used to benchmark performance using the traffic
|
|
|
|
|
generator as shown in the figure below.
|
|
|
|
|
|
2015-05-18 11:34:06 +00:00
|
|
|
|
.. _figure_dist_perf:
|
2014-12-02 14:02:46 +00:00
|
|
|
|
|
2015-05-18 11:34:06 +00:00
|
|
|
|
.. figure:: img/dist_perf.*
|
|
|
|
|
|
|
|
|
|
Performance Benchmarking Setup (Basic Environment)
|
2014-12-02 14:02:46 +00:00
|
|
|
|
|
|
|
|
|
Compiling the Application
|
|
|
|
|
-------------------------
|
|
|
|
|
|
2017-10-25 15:50:59 +00:00
|
|
|
|
To compile the sample application see :doc:`compiling`.
|
2014-12-02 14:02:46 +00:00
|
|
|
|
|
2017-10-25 15:50:59 +00:00
|
|
|
|
The application is located in the ``distributor`` sub-directory.
|
2014-12-02 14:02:46 +00:00
|
|
|
|
|
|
|
|
|
Running the Application
|
|
|
|
|
-----------------------
|
|
|
|
|
|
|
|
|
|
#. The application has a number of command line options:
|
|
|
|
|
|
|
|
|
|
.. code-block:: console
|
|
|
|
|
|
|
|
|
|
./build/distributor_app [EAL options] -- -p PORTMASK
|
|
|
|
|
|
|
|
|
|
where,
|
|
|
|
|
|
|
|
|
|
* -p PORTMASK: Hexadecimal bitmask of ports to configure
|
|
|
|
|
|
2019-03-06 16:22:42 +00:00
|
|
|
|
#. To run the application in linux environment with 10 lcores, 4 ports,
|
2014-12-02 14:02:46 +00:00
|
|
|
|
issue the command:
|
|
|
|
|
|
|
|
|
|
.. code-block:: console
|
|
|
|
|
|
2017-02-27 19:13:40 +00:00
|
|
|
|
$ ./build/distributor_app -l 1-9,22 -n 4 -- -p f
|
2014-12-02 14:02:46 +00:00
|
|
|
|
|
|
|
|
|
#. Refer to the DPDK Getting Started Guide for general information on running
|
|
|
|
|
applications and the Environment Abstraction Layer (EAL) options.
|
|
|
|
|
|
|
|
|
|
Explanation
|
|
|
|
|
-----------
|
|
|
|
|
|
2017-03-20 10:08:41 +00:00
|
|
|
|
The distributor application consists of four types of threads: a receive
|
|
|
|
|
thread (``lcore_rx()``), a distributor thread (``lcore_dist()``), a set of
|
|
|
|
|
worker threads (``lcore_worker()``), and a transmit thread(``lcore_tx()``).
|
|
|
|
|
How these threads work together is shown in :numref:`figure_dist_app` below.
|
|
|
|
|
The ``main()`` function launches threads of these four types. Each thread
|
|
|
|
|
has a while loop which will be doing processing and which is terminated
|
|
|
|
|
only upon SIGINT or ctrl+C.
|
|
|
|
|
|
|
|
|
|
The receive thread receives the packets using ``rte_eth_rx_burst()`` and will
|
|
|
|
|
enqueue them to an rte_ring. The distributor thread will dequeue the packets
|
|
|
|
|
from the ring and assign them to workers (using ``rte_distributor_process()`` API).
|
|
|
|
|
This assignment is based on the tag (or flow ID) of the packet - indicated by
|
|
|
|
|
the hash field in the mbuf. For IP traffic, this field is automatically filled
|
|
|
|
|
by the NIC with the "usr" hash value for the packet, which works as a per-flow
|
|
|
|
|
tag. The distributor thread communicates with the worker threads using a
|
|
|
|
|
cache-line swapping mechanism, passing up to 8 mbuf pointers at a time
|
|
|
|
|
(one cache line) to each worker.
|
2014-12-02 14:02:46 +00:00
|
|
|
|
|
|
|
|
|
More than one worker thread can exist as part of the application, and these
|
|
|
|
|
worker threads do simple packet processing by requesting packets from
|
|
|
|
|
the distributor, doing a simple XOR operation on the input port mbuf field
|
|
|
|
|
(to indicate the output port which will be used later for packet transmission)
|
2017-03-20 10:08:41 +00:00
|
|
|
|
and then finally returning the packets back to the distributor thread.
|
2014-12-02 14:02:46 +00:00
|
|
|
|
|
2017-03-20 10:08:41 +00:00
|
|
|
|
The distributor thread will then call the distributor api
|
|
|
|
|
``rte_distributor_returned_pkts()`` to get the processed packets, and will enqueue
|
|
|
|
|
them to another rte_ring for transfer to the TX thread for transmission on the
|
|
|
|
|
output port. The transmit thread will dequeue the packets from the ring and
|
|
|
|
|
transmit them on the output port specified in packet mbuf.
|
2014-12-02 14:02:46 +00:00
|
|
|
|
|
|
|
|
|
Users who wish to terminate the running of the application have to press ctrl+C
|
|
|
|
|
(or send SIGINT to the app). Upon this signal, a signal handler provided
|
|
|
|
|
in the application will terminate all running threads gracefully and print
|
|
|
|
|
final statistics to the user.
|
|
|
|
|
|
2015-05-18 11:34:06 +00:00
|
|
|
|
.. _figure_dist_app:
|
|
|
|
|
|
|
|
|
|
.. figure:: img/dist_app.*
|
2014-12-02 14:02:46 +00:00
|
|
|
|
|
2015-05-18 11:34:06 +00:00
|
|
|
|
Distributor Sample Application Layout
|
2014-12-02 14:02:46 +00:00
|
|
|
|
|
|
|
|
|
|
2019-05-02 11:18:13 +00:00
|
|
|
|
Intel SST-BF Support
|
|
|
|
|
--------------------
|
|
|
|
|
|
|
|
|
|
In DPDK 19.05, support was added to the power management library for
|
|
|
|
|
Intel-SST-BF, a technology that allows some cores to run at a higher
|
|
|
|
|
frequency than others. An application note for Intel SST-BF is available,
|
|
|
|
|
and is entitled
|
|
|
|
|
`Intel Speed Select Technology – Base Frequency - Enhancing Performance <https://builders.intel.com/docs/networkbuilders/intel-speed-select-technology-base-frequency-enhancing-performance.pdf>`_
|
|
|
|
|
|
|
|
|
|
The distributor application was also enhanced to be aware of these higher
|
|
|
|
|
frequency SST-BF cores, and when starting the application, if high frequency
|
|
|
|
|
SST-BF cores are present in the core mask, the application will identify these
|
|
|
|
|
cores and pin the workloads appropriately. The distributor core is usually
|
|
|
|
|
the bottleneck, so this is given first choice of the high frequency SST-BF
|
|
|
|
|
cores, followed by the rx core and the tx core.
|
|
|
|
|
|
2014-12-02 14:02:46 +00:00
|
|
|
|
Debug Logging Support
|
|
|
|
|
---------------------
|
|
|
|
|
|
|
|
|
|
Debug logging is provided as part of the application; the user needs to uncomment
|
|
|
|
|
the line "#define DEBUG" defined in start of the application in main.c to enable debug logs.
|
|
|
|
|
|
|
|
|
|
Statistics
|
|
|
|
|
----------
|
|
|
|
|
|
2017-03-20 10:08:41 +00:00
|
|
|
|
The main function will print statistics on the console every second. These
|
|
|
|
|
statistics include the number of packets enqueued and dequeued at each stage
|
|
|
|
|
in the application, and also key statistics per worker, including how many
|
|
|
|
|
packets of each burst size (1-8) were sent to each worker thread.
|
2014-12-02 14:02:46 +00:00
|
|
|
|
|
|
|
|
|
Application Initialization
|
|
|
|
|
--------------------------
|
|
|
|
|
|
|
|
|
|
Command line parsing is done in the same way as it is done in the L2 Forwarding Sample
|
2016-02-25 17:02:27 +00:00
|
|
|
|
Application. See :ref:`l2_fwd_app_cmd_arguments`.
|
2014-12-02 14:02:46 +00:00
|
|
|
|
|
|
|
|
|
Mbuf pool initialization is done in the same way as it is done in the L2 Forwarding
|
2016-02-25 17:02:27 +00:00
|
|
|
|
Sample Application. See :ref:`l2_fwd_app_mbuf_init`.
|
2014-12-02 14:02:46 +00:00
|
|
|
|
|
|
|
|
|
Driver Initialization is done in same way as it is done in the L2 Forwarding Sample
|
2016-02-25 17:02:27 +00:00
|
|
|
|
Application. See :ref:`l2_fwd_app_dvr_init`.
|
2014-12-02 14:02:46 +00:00
|
|
|
|
|
|
|
|
|
RX queue initialization is done in the same way as it is done in the L2 Forwarding
|
2016-02-25 17:02:27 +00:00
|
|
|
|
Sample Application. See :ref:`l2_fwd_app_rx_init`.
|
2014-12-02 14:02:46 +00:00
|
|
|
|
|
|
|
|
|
TX queue initialization is done in the same way as it is done in the L2 Forwarding
|
2016-02-25 17:02:27 +00:00
|
|
|
|
Sample Application. See :ref:`l2_fwd_app_tx_init`.
|