1..  SPDX-License-Identifier: BSD-3-Clause
2    Copyright(c) 2017 Intel Corporation.
3
4Traffic Metering and Policing API
5=================================
6
7
8Overview
9--------
10
11This is the generic API for the Quality of Service (QoS) Traffic Metering and
12Policing (MTR) of Ethernet devices. This API is agnostic of the underlying HW,
13SW or mixed HW-SW implementation.
14
15The 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
24Configuration steps
25-------------------
26
27The metering and policing stage typically sits on top of flow classification,
28which is why the MTR objects are enabled through a special "meter" action.
29
30The MTR objects are created and updated in their own name space (``rte_mtr``)
31within the ``librte_ethdev`` library. Whether an MTR object is private to a
32flow or potentially shared by several flows has to be specified at its
33creation time.
34
35Once successfully created, an MTR object is hooked into the RX processing path
36of the Ethernet device by linking it to one or several flows through the
37dedicated "meter" flow action. One or several "meter" actions can be registered
38for the same flow. An MTR object can only be destroyed if there are no flows
39using it.
40
41Run-time processing
42-------------------
43
44Traffic metering determines the color for the current packet (green, yellow,
45red) based on the previous history for this flow as maintained by the MTR
46object. The policer can do nothing, override the color the packet or drop the
47packet. Statistics counters are maintained for MTR object, as configured.
48
49The processing done for each input packet hitting an MTR object is:
50
51* Traffic metering: The packet is assigned a color (the meter output color)
52  based on the previous traffic history reflected in the current state of the
53  MTR object, according to the specific traffic metering algorithm. The
54  traffic metering algorithm can typically work in color aware mode, in which
55  case the input packet already has an initial color (the input color), or in
56  color blind mode, which is equivalent to considering all input packets
57  initially colored as green.
58
59* Policing: There is a separate policer action configured for each meter
60  output color, which can:
61
62  * Drop the packet.
63
64  * Keep the same packet color: the policer output color matches the meter
65    output color (essentially a no-op action).
66
67  * Recolor the packet: the policer output color is set to a different color
68    than the meter output color. The policer output color is the output color
69    of the packet, which is set in the packet meta-data (i.e. struct
70    ``rte_mbuf::sched::color``).
71
72* Statistics: The set of counters maintained for each MTR object is
73  configurable and subject to the implementation support. This set includes
74  the number of packets and bytes dropped or passed for each output color.
75