xref: /dpdk/doc/guides/sample_app_ug/qos_metering.rst (revision 9a212dc06c7aaf09b146d9c3dcfd584d741634c1)
15630257fSFerruh Yigit..  SPDX-License-Identifier: BSD-3-Clause
25630257fSFerruh Yigit    Copyright(c) 2010-2014 Intel Corporation.
3d0dff9baSBernard Iremonger
4d0dff9baSBernard IremongerQoS Metering Sample Application
5d0dff9baSBernard Iremonger===============================
6d0dff9baSBernard Iremonger
7e0c7c473SSiobhan ButlerThe QoS meter sample application is an example that demonstrates the use of DPDK to provide QoS marking and metering,
8d0dff9baSBernard Iremongeras defined by RFC2697 for Single Rate Three Color Marker (srTCM) and RFC 2698 for Two Rate Three Color Marker (trTCM) algorithm.
9d0dff9baSBernard Iremonger
10d0dff9baSBernard IremongerOverview
11d0dff9baSBernard Iremonger--------
12d0dff9baSBernard Iremonger
13d0dff9baSBernard IremongerThe application uses a single thread for reading the packets from the RX port,
14d0dff9baSBernard Iremongermetering, marking them with the appropriate color (green, yellow or red) and writing them to the TX port.
15d0dff9baSBernard Iremonger
16d0dff9baSBernard IremongerA policing scheme can be applied before writing the packets to the TX port by dropping or
17d0dff9baSBernard Iremongerchanging the color of the packet in a static manner depending on both the input and output colors of the packets that are processed by the meter.
18d0dff9baSBernard Iremonger
19d0dff9baSBernard IremongerThe operation mode can be selected as compile time out of the following options:
20d0dff9baSBernard Iremonger
21d0dff9baSBernard Iremonger*   Simple forwarding
22d0dff9baSBernard Iremonger
23d0dff9baSBernard Iremonger*   srTCM color blind
24d0dff9baSBernard Iremonger
25d0dff9baSBernard Iremonger*   srTCM color aware
26d0dff9baSBernard Iremonger
27d0dff9baSBernard Iremonger*   srTCM color blind
28d0dff9baSBernard Iremonger
29d0dff9baSBernard Iremonger*   srTCM color aware
30d0dff9baSBernard Iremonger
31d0dff9baSBernard IremongerPlease refer to RFC2697 and RFC2698 for details about the srTCM and trTCM configurable parameters
32d0dff9baSBernard Iremonger(CIR, CBS and EBS for srTCM; CIR, PIR, CBS and PBS for trTCM).
33d0dff9baSBernard Iremonger
34d0dff9baSBernard IremongerThe color blind modes are functionally equivalent with the color-aware modes when
35d0dff9baSBernard Iremongerall the incoming packets are colored as green.
36d0dff9baSBernard Iremonger
37d0dff9baSBernard IremongerCompiling the Application
38d0dff9baSBernard Iremonger-------------------------
39d0dff9baSBernard Iremonger
407cacb056SHerakliusz LipiecTo compile the sample application see :doc:`compiling`.
41d0dff9baSBernard Iremonger
427cacb056SHerakliusz LipiecThe application is located in the ``qos_meter`` sub-directory.
43d0dff9baSBernard Iremonger
44d0dff9baSBernard IremongerRunning the Application
45d0dff9baSBernard Iremonger-----------------------
46d0dff9baSBernard Iremonger
47d0dff9baSBernard IremongerThe application execution command line is as below:
48d0dff9baSBernard Iremonger
49d0dff9baSBernard Iremonger.. code-block:: console
50d0dff9baSBernard Iremonger
51e2a94f9aSCiara Power    ./dpdk-qos_meter [EAL options] -- -p PORTMASK
52d0dff9baSBernard Iremonger
53d0dff9baSBernard IremongerThe application is constrained to use a single core in the EAL core mask and 2 ports only in the application port mask
54d0dff9baSBernard Iremonger(first port from the port mask is used for RX and the other port in the core mask is used for TX).
55d0dff9baSBernard Iremonger
56e0c7c473SSiobhan ButlerRefer to *DPDK Getting Started Guide* for general information on running applications and
57d0dff9baSBernard Iremongerthe Environment Abstraction Layer (EAL) options.
58d0dff9baSBernard Iremonger
59d0dff9baSBernard IremongerExplanation
60d0dff9baSBernard Iremonger-----------
61d0dff9baSBernard Iremonger
62d0dff9baSBernard IremongerSelecting one of the metering modes is done with these defines:
63d0dff9baSBernard Iremonger
64*9a212dc0SConor Fogarty.. literalinclude:: ../../../examples/qos_meter/main.c
65*9a212dc0SConor Fogarty        :language: c
66*9a212dc0SConor Fogarty        :start-after: Traffic metering configuration. 8<
67*9a212dc0SConor Fogarty        :end-before: >8 End of traffic metering configuration.
68d0dff9baSBernard Iremonger
69d0dff9baSBernard IremongerTo simplify debugging (for example, by using the traffic generator RX side MAC address based packet filtering feature),
70d0dff9baSBernard Iremongerthe color is defined as the LSB byte of the destination MAC address.
71d0dff9baSBernard Iremonger
72d0dff9baSBernard IremongerThe traffic meter parameters are configured in the application source code with following default values:
73d0dff9baSBernard Iremonger
74*9a212dc0SConor Fogarty.. literalinclude:: ../../../examples/qos_meter/main.c
75*9a212dc0SConor Fogarty        :language: c
76*9a212dc0SConor Fogarty        :start-after: Traffic meter parameters are configured in the application. 8<
77*9a212dc0SConor Fogarty        :end-before: >8 End of traffic meter parameters are configured in the application.
78d0dff9baSBernard Iremonger
79d0dff9baSBernard IremongerAssuming the input traffic is generated at line rate and all packets are 64 bytes Ethernet frames (IPv4 packet size of 46 bytes)
80d0dff9baSBernard Iremongerand green, the expected output traffic should be marked as shown in the following table:
81d0dff9baSBernard Iremonger
828c9a3374SJohn McNamara.. _table_qos_metering_1:
83d0dff9baSBernard Iremonger
848c9a3374SJohn McNamara.. table:: Output Traffic Marking
85d0dff9baSBernard Iremonger
86d0dff9baSBernard Iremonger   +-------------+------------------+-------------------+----------------+
87d0dff9baSBernard Iremonger   | **Mode**    | **Green (Mpps)** | **Yellow (Mpps)** | **Red (Mpps)** |
88d0dff9baSBernard Iremonger   |             |                  |                   |                |
89d0dff9baSBernard Iremonger   +=============+==================+===================+================+
90d0dff9baSBernard Iremonger   | srTCM blind | 1                | 1                 | 12.88          |
91d0dff9baSBernard Iremonger   |             |                  |                   |                |
92d0dff9baSBernard Iremonger   +-------------+------------------+-------------------+----------------+
93d0dff9baSBernard Iremonger   | srTCM color | 1                | 1                 | 12.88          |
94d0dff9baSBernard Iremonger   |             |                  |                   |                |
95d0dff9baSBernard Iremonger   +-------------+------------------+-------------------+----------------+
96d0dff9baSBernard Iremonger   | trTCM blind | 1                | 0.5               | 13.38          |
97d0dff9baSBernard Iremonger   |             |                  |                   |                |
98d0dff9baSBernard Iremonger   +-------------+------------------+-------------------+----------------+
99d0dff9baSBernard Iremonger   | trTCM color | 1                | 0.5               | 13.38          |
100d0dff9baSBernard Iremonger   |             |                  |                   |                |
101d0dff9baSBernard Iremonger   +-------------+------------------+-------------------+----------------+
102d0dff9baSBernard Iremonger   | FWD         | 14.88            | 0                 | 0              |
103d0dff9baSBernard Iremonger   |             |                  |                   |                |
104d0dff9baSBernard Iremonger   +-------------+------------------+-------------------+----------------+
105d0dff9baSBernard Iremonger
106d0dff9baSBernard IremongerTo set up the policing scheme as desired, it is necessary to modify the main.h source file,
107d0dff9baSBernard Iremongerwhere this policy is implemented as a static structure, as follows:
108d0dff9baSBernard Iremonger
109*9a212dc0SConor Fogarty.. literalinclude:: ../../../examples/qos_meter/main.h
110*9a212dc0SConor Fogarty        :language: c
111*9a212dc0SConor Fogarty        :start-after: Policy implemented as a static structure. 8<
112*9a212dc0SConor Fogarty        :end-before: >8 End of policy implemented as a static structure.
113d0dff9baSBernard Iremonger
114d0dff9baSBernard IremongerWhere rows indicate the input color, columns indicate the output color,
115d0dff9baSBernard Iremongerand the value that is stored in the table indicates the action to be taken for that particular case.
116d0dff9baSBernard Iremonger
117d0dff9baSBernard IremongerThere are four different actions:
118d0dff9baSBernard Iremonger
119d0dff9baSBernard Iremonger*   GREEN: The packet's color is changed to green.
120d0dff9baSBernard Iremonger
121d0dff9baSBernard Iremonger*   YELLOW: The packet's color is changed to yellow.
122d0dff9baSBernard Iremonger
123d0dff9baSBernard Iremonger*   RED: The packet's color is changed to red.
124d0dff9baSBernard Iremonger
125d0dff9baSBernard Iremonger*   DROP: The packet is dropped.
126d0dff9baSBernard Iremonger
127d0dff9baSBernard IremongerIn this particular case:
128d0dff9baSBernard Iremonger
129d0dff9baSBernard Iremonger*   Every packet which input and output color are the same, keeps the same color.
130d0dff9baSBernard Iremonger
131d0dff9baSBernard Iremonger*   Every packet which color has improved is dropped (this particular case can't happen, so these values will not be used).
132d0dff9baSBernard Iremonger
133d0dff9baSBernard Iremonger*   For the rest of the cases, the color is changed to red.
134331ce43dSVipin Varghese
135331ce43dSVipin Varghese.. note::
136d629b7b5SJohn McNamara    * In color blind mode, first row GREEN color is only valid.
137331ce43dSVipin Varghese    * To drop the packet, policer_table action has to be set to DROP.
138