blob: cc7327d7e0fb1dddc0e17dc86df9edacabf8dd66 [file] [log] [blame]
Charles Chancaebcf32021-09-20 22:17:52 -07001QoS and Slicing
2===============
Daniele Moroed033562021-10-04 16:12:31 +02003
4.. _qos_configuration:
5
6Configuration
7-------------
8.. note:: QoS and slicing configuration is currently statically configured at switch startup.
9 Dynamic configuration will be supported in a next SD-Fabric release.
10
11QoS and Slicing is configured via the ``vendor_config`` portion of the Stratum Chassis Config (see :ref:`stratum_chassis_config`),
12where the queues and schedulers can be configured.
13We provide a convenient `script <https://github.com/stratum/fabric-tna/blob/main/util/gen-stratum-qos-config.py>`_
14to generate the configuration starting from a higher-level description provided via a YAML file.
15This file allows to configure the parameters for the traffic classes listed in the previous sections.
16
17Here's a list of parameters that you can configure via the YAML QoS configuration file:
18
19* ``max_cells``: Maximum number of buffer cells, depends on the ASIC SKU/revision.
20
21* ``pool_allocations``: Percentage of buffer cells allocated to each traffic class.
22 The sum should be 100. Usually, we leave a portion of the buffer ``unassigned``
23 for queues that do not have a pool (yet).
24 Example of such queues are those for the recirculation port, CPU port, etc.
25
26 .. code-block:: yaml
27
28 pool_allocations:
29 control: 1
30 realtime: 9
31 elastic: 80
32 besteffort: 9
33 unassigned: 1
34
35* **Control** Traffic Class: The available bandwidth dedicated to Control traffic is divided in *slots*.
36 Each slot has a maximum rate and burst (in packets of the given MTU).
37 A slice can use one or more slots by appropriately configuring meters in the fabric ingress pipeline.
38
39 * ``control_slot_count``: Number of slots.
40 * ``control_slot_rate_pps``: Packet per second rate of each slot.
41 * ``control_slot_burst_pkts``: Number of packets per burst of each slot.
42 * ``control_mtu_bytes``: MTU of packets for the PPS and burst values.
43
44 .. code-block:: yaml
45
46 control_slot_count: 50
47 control_slot_rate_pps: 100
48 control_slot_burst_pkts: 10
49 control_mtu_bytes: 1500
50
51* **Real-Time** Traffic Class Configuration:
52
53 * ``realtime_max_rates_bps``: List of maximum shaping rates for Real-Time queues,
54 one per slice requesting such service.
55
56 * ``realtime_max_burst_s``: Maximum amount of time that a Real-Time queue can
57 burst at the port speed. This parameter is used to limit delay for Elastic
58 queues.
59
60 .. code-block:: yaml
61
62 realtime_max_rates_bps:
63 - 45000000 # 45 Mbps
64 - 30000000 # 30 Mbps
65 - 25000000 # 25 Mbps
66 realtime_max_burst_s: 0.005 # 5 ms
67
68* **Elastic** Traffic Class Configuration:
69
70 * ``elastic_min_rates_bps``: List of minimum guaranteed rates for Elastic queues,
71 one per slice requesting such service.
72
73 .. code-block:: yaml
74
75 elastic_min_rates_bps:
76 - 100000000 # 100 Mbps
77 - 200000000 # 200 Mbps
78
79* ``port_templates`` section: List of switch port for which we want to configure
80 queues.
81
82 Every ``port_templates`` element contains:
83
84 * ``descr``: Description of the port purpose.
85
86 * ``rate_bps``: Port speed in bit per second.
87
88 * ``is_shaping_enabled``: ``true`` if the rate is enforced using shaping,
89 ``false`` if the rate is the channel speed.
90
91 * ``shaping_burst_bytes``: Burst size in bytes, meaningful only if port speed
92 is shaped (when ``is_shaping_enabled: true``).
93
94 * ``queue_count``: Number of queues assigned to the port.
95
96 * ``port_ids``: List of Stratum port IDs (:ref:`singleton_port` from Stratum Chassis Config),
97 using this port template. Used for port that corresponds to switch front-panel ports.
98
99 Mutually exclusive with ``sdk_port_ids`` field.
100
101 * ``sdk_port_ids``: List of SDK port numbers (i.e., Tofino DP_ID) using this port template.
102 Used for internal ports (e.g., recirculation ports).
103
104 Mutually exclusive with ``port_ids`` field.
105
106 .. code-block:: yaml
107
108 port_templates:
109 - descr: "Base station"
110 rate_bps: 1000000000 # 1 Gbps
111 is_shaping_enabled: true
112 shaping_burst_bytes: 18000 # 2x jumbo frames
113 queue_count: 16
114 port_ids:
115 - 100
116 - descr: "Servers"
117 port_ids:
118 - 200
119 rate_bps: 40000000000 # 40 Gbps
120 is_shaping_enabled: false
121 queue_count: 16
122 - descr: "Recirculation"
123 sdk_port_ids:
124 - 68
125 rate_bps: 100000000000 # 100 Gbps
126 is_shaping_enabled: false
127 queue_count: 16
128
129An example of a complete QoS and Slicing configuration can be found `here <https://github.com/stratum/fabric-tna/blob/main/util/sample-qos-config.yaml>`_.
Wailok Shum08311e52021-09-30 23:22:12 +0800130
131REST API
132--------
133REST API supports adding/removing/querying slices and traffic classes.
134We can also classify a flow (identified by five tuples) via REST API.
135
136Slice
137^^^^^
138
139Add a slice
140"""""""""""
141A POST request with Slice ID as path parameter.
142``/slicing/slice/{sliceId}``
143
144.. image:: ../images/qos-rest-slice-add.png
145 :width: 700px
146
147Remove a slice
148"""""""""""""""
149A DELETE request with Slice ID as path parameter.
150``/slicing/slice/{sliceId}``
151
152.. image:: ../images/qos-rest-slice-remove.png
153 :width: 700px
154
155Get all slices
156""""""""""""""
157A GET request.
158Returns a collection of slice id.
159/slicing/slice
160
161.. image:: ../images/qos-rest-slice-get.png
162 :width: 700px
163
164Traffic Class
165^^^^^^^^^^^^^
166.. tip::
167 Traffic Class has following attributes: ``BEST_EFFORT``, ``CONTROL``, ``REAL_TIME``, ``ELASTIC``.
168
169Add a traffic class to a slice
170""""""""""""""""""""""""""""""
171A POST request with Slice ID and Traffic Class as path parameters.
172``/slicing/tc/{sliceId}/{tc}``
173
174.. image:: ../images/qos-rest-tc-add.png
175 :width: 700px
176
177Remove a traffic class from a slice
178"""""""""""""""""""""""""""""""""""
179A DELETE request with Slice ID and Traffic Class as path parameters.
180``/slicing/tc/{sliceId}/{tc}``
181
182.. image:: ../images/qos-rest-tc-remove.png
183 :width: 700px
184
185Get all traffic classes from a slice
186""""""""""""""""""""""""""""""""""""
187A GET request with Slice ID as path parameters.
188Returns a collection of traffic class.
189``/slicing/tc/{sliceId}``
190
191.. image:: ../images/qos-rest-tc-get.png
192 :width: 700px
193
194Classify Flow
195^^^^^^^^^^^^^
196
197A flow can be defined as
198
199.. code-block:: json
200
201 {
202 "criteria": [
203 {
204 "type": "IPV4_SRC",
205 "ip": "10.0.0.1/32"
206 },
207 {
208 "type": "IPV4_DST",
209 "ip": "10.0.0.2/32"
210 },
211 {
212 "type": "IP_PROTO",
213 "protocol": 6
214 },
215 {
216 "type": "TCP_SRC",
217 "tcpPort": 1000
218 },
219 {
220 "type": "TCP_DST",
221 "tcpPort": 80
222 },
223 {
224 "type": "UDP_SRC",
225 "udpPort": 1000
226 },
227 {
228 "type": "UDP_DST",
229 "udpPort": 1812
230 }
231 ]
232 }
233
234- ``IPV4_SRC``: Source IPv4 prefix
235
236- ``IPV4_DST``: Destination IPv4 prefix
237
238- ``IP_PROTO``: IP Protocol, accept 6 (TCP) and 17 (UDP)
239
240- ``TCP_SRC``: Source L4 (TCP) port
241
242- ``TCP_DST``: Destination L4 (TCP) port
243
244- ``UDP_SRC``: Source L4 (UDP) port
245
246- ``UDP_DST``: Destination L4 (UDP) port
247
248.. note::
249 SD-Fabric currently supports 5-tuple only.
250
251Classify a flow to a slice and traffic class
252""""""""""""""""""""""""""""""""""""""""""""
253A POST request with Slice ID and Traffic Class as path parameters.
254And a Json of a flow as body parameters.
255``/slicing/flow/{sliceId}/{tc}``
256
257.. image:: ../images/qos-rest-classifier-add.png
258 :width: 700px
259
260Remove a flow from a slice and traffic class
261""""""""""""""""""""""""""""""""""""""""""""
262A DELETE request with Slice ID and Traffic Class as path parameters.
263And a Json of a flow as body parameters.
264``/slicing/flow/{sliceId}/{tc}``
265
266.. image:: ../images/qos-rest-classifier-remove.png
267 :width: 700px
268
269Get all classified flows from a slice and traffic class
270"""""""""""""""""""""""""""""""""""""""""""""""""""""""
271A GET request with Slice ID and Traffic Class as path parameters.
272Returns a collection of flow.
273``/slicing/flow/{sliceId}``
274
275.. image:: ../images/qos-rest-classifier-get.png
276 :width: 700px