aboutsummaryrefslogtreecommitdiffstats
path: root/doc/guides/sample_app_ug/dist_app.rst
blob: 1f68d081cf83d67ba07786cb2f002dd6518e1641 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
..  SPDX-License-Identifier: BSD-3-Clause
    Copyright(c) 2010-2014 Intel Corporation.

Distributor Sample Application
==============================

The distributor sample application is a simple example of packet distribution
to cores using the Data Plane Development Kit (DPDK).

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.

.. _figure_dist_perf:

.. figure:: img/dist_perf.*

   Performance Benchmarking Setup (Basic Environment)

Compiling the Application
-------------------------

To compile the sample application see :doc:`compiling`.

The application is located in the ``distributor`` sub-directory.

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

#. To run the application in linuxapp environment with 10 lcores, 4 ports,
   issue the command:

   ..  code-block:: console

       $ ./build/distributor_app -l 1-9,22 -n 4 -- -p f

#. Refer to the DPDK Getting Started Guide for general information on running
   applications and the Environment Abstraction Layer (EAL) options.

Explanation
-----------

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.

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)
and then finally returning the packets back to the distributor thread.

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.

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.

.. _figure_dist_app:

.. figure:: img/dist_app.*

   Distributor Sample Application Layout


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
----------

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.

Application Initialization
--------------------------

Command line parsing is done in the same way as it is done in the L2 Forwarding Sample
Application. See :ref:`l2_fwd_app_cmd_arguments`.

Mbuf pool initialization is done in the same way as it is done in the L2 Forwarding
Sample Application. See :ref:`l2_fwd_app_mbuf_init`.

Driver Initialization is done in same way as it is done in the L2 Forwarding Sample
Application. See :ref:`l2_fwd_app_dvr_init`.

RX queue initialization is done in the same way as it is done in the L2 Forwarding
Sample Application. See :ref:`l2_fwd_app_rx_init`.

TX queue initialization is done in the same way as it is done in the L2 Forwarding
Sample Application. See :ref:`l2_fwd_app_tx_init`.