New upstream version 18.02
[deb_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
24 Configuration steps
25 -------------------
26
27 The metering and policing stage typically sits on top of flow classification,
28 which is why the MTR objects are enabled through a special "meter" action.
29
30 The MTR objects are created and updated in their own name space (``rte_mtr``)
31 within the ``librte_ether`` library. Whether an MTR object is private to a
32 flow or potentially shared by several flows has to be specified at its
33 creation time.
34
35 Once successfully created, an MTR object is hooked into the RX processing path
36 of the Ethernet device by linking it to one or several flows through the
37 dedicated "meter" flow action. One or several "meter" actions can be registered
38 for the same flow. An MTR object can only be destroyed if there are no flows
39 using it.
40
41 Run-time processing
42 -------------------
43
44 Traffic metering determines the color for the current packet (green, yellow,
45 red) based on the previous history for this flow as maintained by the MTR
46 object. The policer can do nothing, override the color the packet or drop the
47 packet. Statistics counters are maintained for MTR object, as configured.
48
49 The 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.