doc: fix a typo in EAL guide
[dpdk.git] / doc / guides / prog_guide / traffic_metering_and_policing.rst
1 ..  SPDX-License-Identifier: BSD-3-Clause
2     Copyright(c) 2017 Intel Corporation.
3
4 Traffic Metering and Policing API
5 =================================
6
7
8 Overview
9 --------
10
11 This is the generic API for the Quality of Service (QoS) Traffic Metering and
12 Policing (MTR) of Ethernet devices. This API is agnostic of the underlying HW,
13 SW or mixed HW-SW implementation.
14
15 The main features are:
16
17 * Part of DPDK rte_ethdev API
18 * Capability query API
19 * Metering algorithms: RFC 2697 Single Rate Three Color Marker (srTCM), RFC 2698
20   and RFC 4115 Two Rate Three Color Marker (trTCM)
21 * Policer actions (per meter output color): recolor, drop
22 * Statistics (per policer output color)
23 * Chaining multiple meter objects
24
25 Configuration steps
26 -------------------
27
28 The metering and policing stage typically sits on top of flow classification,
29 which is why the MTR objects are enabled through a special "meter" action.
30
31 The MTR objects are created and updated in their own name space (``rte_mtr``)
32 within the ``librte_ethdev`` library. Whether an MTR object is private to a
33 flow or potentially shared by several flows has to be specified at its
34 creation time.
35
36 Once successfully created, an MTR object is hooked into the RX processing path
37 of the Ethernet device by linking it to one or several flows through the
38 dedicated "meter" flow action. One or several "meter" actions can be registered
39 for the same flow. An MTR object can only be destroyed if there are no flows
40 using it.
41
42 Run-time processing
43 -------------------
44
45 Traffic metering determines the color for the current packet (green, yellow,
46 red) based on the previous history for this flow as maintained by the MTR
47 object. The policer can do nothing, override the color the packet or drop the
48 packet. Statistics counters are maintained for MTR object, as configured.
49
50 The processing done for each input packet hitting an MTR object is:
51
52 * Traffic metering: The packet is assigned a color (the meter output color)
53   based on the previous traffic history reflected in the current state of the
54   MTR object, according to the specific traffic metering algorithm. The
55   traffic metering algorithm can typically work in color aware mode, in which
56   case the input packet already has an initial color (the input color), or in
57   color blind mode, which is equivalent to considering all input packets
58   initially colored as green.
59
60 * There is a meter policy API to manage pre-defined policies for meter.
61   Any rte_flow action list can be configured per color for each policy.
62   A meter object configured with a policy executes the actions per packet
63   according to the packet color.
64
65 * Statistics: The set of counters maintained for each MTR object is
66   configurable and subject to the implementation support. This set includes
67   the number of packets and bytes dropped or passed for each output color.
68
69 API walk-through
70 ----------------
71
72 .. _figure_rte_mtr_chaining:
73
74 .. figure:: img/rte_mtr_meter_chaining.*
75
76    Meter components
77
78 This section will introduce the reader to the critical APIs to use
79 the traffic meter and policing library.
80
81 In general, the application performs the following steps to configure the
82 traffic meter and policing library.
83
84 #. Application gets the meter driver capabilities using ``rte_mtr_capabilities_get()``.
85 #. The application creates the required meter profiles by using the
86    ``rte_mtr_meter_profile_add()`` API function.
87 #. The application creates the required meter policies by using the
88    ``rte_mtr_meter_policy_add()`` API function.
89 #. The application creates a meter object using the ``rte_mtr_create()`` API
90    function. One of the previously created meter profile
91    (``struct rte_mtr_params::meter_profile_id``) and meter policy
92    (``struct rte_mtr_params::meter_policy_id``) are provided as arguments
93    at this step.
94 #. The application enables the meter object execution as part of the flow action
95    processing by calling the ``rte_flow_create()`` API function with one of the
96    flow action set to ``RTE_FLOW_ACTION_TYPE_METER`` and the associated
97    meter object ID set to this meter object.
98 #. The API allows chaining the meter objects to create complex metering topology
99    by the following methods.
100
101    * Adding multiple flow actions of the type ``RTE_FLOW_ACTION_TYPE_METER`` to
102      the same flow.
103      Each of the meter action typically refers to a different meter object.
104
105    * Adding one (or multiple) actions of the type ``RTE_FLOW_ACTION_TYPE_METER``
106      to the list of meter actions (``struct rte_mtr_meter_policy_params::actions``)
107      specified per color as show in :numref:`figure_rte_mtr_chaining`.