mbuf: remove control mbuf
[dpdk.git] / doc / guides / prog_guide / traffic_metering_and_policing.rst
1 ..  BSD LICENSE
2     Copyright(c) 2017 Intel Corporation. All rights reserved.
3     All rights reserved.
4
5     Redistribution and use in source and binary forms, with or without
6     modification, are permitted provided that the following conditions
7     are met:
8
9     * Redistributions of source code must retain the above copyright
10     notice, this list of conditions and the following disclaimer.
11     * Redistributions in binary form must reproduce the above copyright
12     notice, this list of conditions and the following disclaimer in
13     the documentation and/or other materials provided with the
14     distribution.
15     * Neither the name of Intel Corporation nor the names of its
16     contributors may be used to endorse or promote products derived
17     from this software without specific prior written permission.
18
19     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20     "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21     LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22     A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23     OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24     SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25     LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26     DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27     THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29     OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
31
32 Traffic Metering and Policing API
33 =================================
34
35
36 Overview
37 --------
38
39 This is the generic API for the Quality of Service (QoS) Traffic Metering and
40 Policing (MTR) of Ethernet devices. This API is agnostic of the underlying HW,
41 SW or mixed HW-SW implementation.
42
43 The main features are:
44
45 * Part of DPDK rte_ethdev API
46 * Capability query API
47 * Metering algorithms: RFC 2697 Single Rate Three Color Marker (srTCM), RFC 2698
48   and RFC 4115 Two Rate Three Color Marker (trTCM)
49 * Policer actions (per meter output color): recolor, drop
50 * Statistics (per policer output color)
51
52 Configuration steps
53 -------------------
54
55 The metering and policing stage typically sits on top of flow classification,
56 which is why the MTR objects are enabled through a special "meter" action.
57
58 The MTR objects are created and updated in their own name space (``rte_mtr``)
59 within the ``librte_ether`` library. Whether an MTR object is private to a
60 flow or potentially shared by several flows has to be specified at its
61 creation time.
62
63 Once successfully created, an MTR object is hooked into the RX processing path
64 of the Ethernet device by linking it to one or several flows through the
65 dedicated "meter" flow action. One or several "meter" actions can be registered
66 for the same flow. An MTR object can only be destroyed if there are no flows
67 using it.
68
69 Run-time processing
70 -------------------
71
72 Traffic metering determines the color for the current packet (green, yellow,
73 red) based on the previous history for this flow as maintained by the MTR
74 object. The policer can do nothing, override the color the packet or drop the
75 packet. Statistics counters are maintained for MTR object, as configured.
76
77 The processing done for each input packet hitting an MTR object is:
78
79 * Traffic metering: The packet is assigned a color (the meter output color)
80   based on the previous traffic history reflected in the current state of the
81   MTR object, according to the specific traffic metering algorithm. The
82   traffic metering algorithm can typically work in color aware mode, in which
83   case the input packet already has an initial color (the input color), or in
84   color blind mode, which is equivalent to considering all input packets
85   initially colored as green.
86
87 * Policing: There is a separate policer action configured for each meter
88   output color, which can:
89
90   * Drop the packet.
91
92   * Keep the same packet color: the policer output color matches the meter
93     output color (essentially a no-op action).
94
95   * Recolor the packet: the policer output color is set to a different color
96     than the meter output color. The policer output color is the output color
97     of the packet, which is set in the packet meta-data (i.e. struct
98     ``rte_mbuf::sched::color``).
99
100 * Statistics: The set of counters maintained for each MTR object is
101   configurable and subject to the implementation support. This set includes
102   the number of packets and bytes dropped or passed for each output color.