4 * Copyright(c) 2017 Intel Corporation. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of Intel Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 #ifndef __INCLUDE_RTE_TM_DRIVER_H__
35 #define __INCLUDE_RTE_TM_DRIVER_H__
39 * RTE Generic Traffic Manager API (Driver Side)
41 * This file provides implementation helpers for internal use by PMDs, they
42 * are not intended to be exposed to applications and are not subject to ABI
48 #include <rte_errno.h>
49 #include "rte_ethdev.h"
56 /** @internal Traffic manager node ID validate and type get */
57 typedef int (*rte_tm_node_type_get_t)(struct rte_eth_dev *dev,
60 struct rte_tm_error *error);
62 /** @internal Traffic manager capabilities get */
63 typedef int (*rte_tm_capabilities_get_t)(struct rte_eth_dev *dev,
64 struct rte_tm_capabilities *cap,
65 struct rte_tm_error *error);
67 /** @internal Traffic manager level capabilities get */
68 typedef int (*rte_tm_level_capabilities_get_t)(struct rte_eth_dev *dev,
70 struct rte_tm_level_capabilities *cap,
71 struct rte_tm_error *error);
73 /** @internal Traffic manager node capabilities get */
74 typedef int (*rte_tm_node_capabilities_get_t)(struct rte_eth_dev *dev,
76 struct rte_tm_node_capabilities *cap,
77 struct rte_tm_error *error);
79 /** @internal Traffic manager WRED profile add */
80 typedef int (*rte_tm_wred_profile_add_t)(struct rte_eth_dev *dev,
81 uint32_t wred_profile_id,
82 struct rte_tm_wred_params *profile,
83 struct rte_tm_error *error);
85 /** @internal Traffic manager WRED profile delete */
86 typedef int (*rte_tm_wred_profile_delete_t)(struct rte_eth_dev *dev,
87 uint32_t wred_profile_id,
88 struct rte_tm_error *error);
90 /** @internal Traffic manager shared WRED context add */
91 typedef int (*rte_tm_shared_wred_context_add_update_t)(
92 struct rte_eth_dev *dev,
93 uint32_t shared_wred_context_id,
94 uint32_t wred_profile_id,
95 struct rte_tm_error *error);
97 /** @internal Traffic manager shared WRED context delete */
98 typedef int (*rte_tm_shared_wred_context_delete_t)(
99 struct rte_eth_dev *dev,
100 uint32_t shared_wred_context_id,
101 struct rte_tm_error *error);
103 /** @internal Traffic manager shaper profile add */
104 typedef int (*rte_tm_shaper_profile_add_t)(struct rte_eth_dev *dev,
105 uint32_t shaper_profile_id,
106 struct rte_tm_shaper_params *profile,
107 struct rte_tm_error *error);
109 /** @internal Traffic manager shaper profile delete */
110 typedef int (*rte_tm_shaper_profile_delete_t)(struct rte_eth_dev *dev,
111 uint32_t shaper_profile_id,
112 struct rte_tm_error *error);
114 /** @internal Traffic manager shared shaper add/update */
115 typedef int (*rte_tm_shared_shaper_add_update_t)(struct rte_eth_dev *dev,
116 uint32_t shared_shaper_id,
117 uint32_t shaper_profile_id,
118 struct rte_tm_error *error);
120 /** @internal Traffic manager shared shaper delete */
121 typedef int (*rte_tm_shared_shaper_delete_t)(struct rte_eth_dev *dev,
122 uint32_t shared_shaper_id,
123 struct rte_tm_error *error);
125 /** @internal Traffic manager node add */
126 typedef int (*rte_tm_node_add_t)(struct rte_eth_dev *dev,
128 uint32_t parent_node_id,
132 struct rte_tm_node_params *params,
133 struct rte_tm_error *error);
135 /** @internal Traffic manager node delete */
136 typedef int (*rte_tm_node_delete_t)(struct rte_eth_dev *dev,
138 struct rte_tm_error *error);
140 /** @internal Traffic manager node suspend */
141 typedef int (*rte_tm_node_suspend_t)(struct rte_eth_dev *dev,
143 struct rte_tm_error *error);
145 /** @internal Traffic manager node resume */
146 typedef int (*rte_tm_node_resume_t)(struct rte_eth_dev *dev,
148 struct rte_tm_error *error);
150 /** @internal Traffic manager hierarchy commit */
151 typedef int (*rte_tm_hierarchy_commit_t)(struct rte_eth_dev *dev,
153 struct rte_tm_error *error);
155 /** @internal Traffic manager node parent update */
156 typedef int (*rte_tm_node_parent_update_t)(struct rte_eth_dev *dev,
158 uint32_t parent_node_id,
161 struct rte_tm_error *error);
163 /** @internal Traffic manager node shaper update */
164 typedef int (*rte_tm_node_shaper_update_t)(struct rte_eth_dev *dev,
166 uint32_t shaper_profile_id,
167 struct rte_tm_error *error);
169 /** @internal Traffic manager node shaper update */
170 typedef int (*rte_tm_node_shared_shaper_update_t)(struct rte_eth_dev *dev,
172 uint32_t shared_shaper_id,
174 struct rte_tm_error *error);
176 /** @internal Traffic manager node stats update */
177 typedef int (*rte_tm_node_stats_update_t)(struct rte_eth_dev *dev,
180 struct rte_tm_error *error);
182 /** @internal Traffic manager node WFQ weight mode update */
183 typedef int (*rte_tm_node_wfq_weight_mode_update_t)(
184 struct rte_eth_dev *dev,
186 int *wfq_weigth_mode,
187 uint32_t n_sp_priorities,
188 struct rte_tm_error *error);
190 /** @internal Traffic manager node congestion management mode update */
191 typedef int (*rte_tm_node_cman_update_t)(struct rte_eth_dev *dev,
193 enum rte_tm_cman_mode cman,
194 struct rte_tm_error *error);
196 /** @internal Traffic manager node WRED context update */
197 typedef int (*rte_tm_node_wred_context_update_t)(
198 struct rte_eth_dev *dev,
200 uint32_t wred_profile_id,
201 struct rte_tm_error *error);
203 /** @internal Traffic manager node WRED context update */
204 typedef int (*rte_tm_node_shared_wred_context_update_t)(
205 struct rte_eth_dev *dev,
207 uint32_t shared_wred_context_id,
209 struct rte_tm_error *error);
211 /** @internal Traffic manager read stats counters for specific node */
212 typedef int (*rte_tm_node_stats_read_t)(struct rte_eth_dev *dev,
214 struct rte_tm_node_stats *stats,
215 uint64_t *stats_mask,
217 struct rte_tm_error *error);
219 /** @internal Traffic manager packet marking - VLAN DEI */
220 typedef int (*rte_tm_mark_vlan_dei_t)(struct rte_eth_dev *dev,
224 struct rte_tm_error *error);
226 /** @internal Traffic manager packet marking - IPv4/IPv6 ECN */
227 typedef int (*rte_tm_mark_ip_ecn_t)(struct rte_eth_dev *dev,
231 struct rte_tm_error *error);
233 /** @internal Traffic manager packet marking - IPv4/IPv6 DSCP */
234 typedef int (*rte_tm_mark_ip_dscp_t)(struct rte_eth_dev *dev,
238 struct rte_tm_error *error);
241 /** Traffic manager node type get */
242 rte_tm_node_type_get_t node_type_get;
244 /** Traffic manager capabilities_get */
245 rte_tm_capabilities_get_t capabilities_get;
246 /** Traffic manager level capabilities_get */
247 rte_tm_level_capabilities_get_t level_capabilities_get;
248 /** Traffic manager node capabilities get */
249 rte_tm_node_capabilities_get_t node_capabilities_get;
251 /** Traffic manager WRED profile add */
252 rte_tm_wred_profile_add_t wred_profile_add;
253 /** Traffic manager WRED profile delete */
254 rte_tm_wred_profile_delete_t wred_profile_delete;
255 /** Traffic manager shared WRED context add/update */
256 rte_tm_shared_wred_context_add_update_t
257 shared_wred_context_add_update;
258 /** Traffic manager shared WRED context delete */
259 rte_tm_shared_wred_context_delete_t
260 shared_wred_context_delete;
262 /** Traffic manager shaper profile add */
263 rte_tm_shaper_profile_add_t shaper_profile_add;
264 /** Traffic manager shaper profile delete */
265 rte_tm_shaper_profile_delete_t shaper_profile_delete;
266 /** Traffic manager shared shaper add/update */
267 rte_tm_shared_shaper_add_update_t shared_shaper_add_update;
268 /** Traffic manager shared shaper delete */
269 rte_tm_shared_shaper_delete_t shared_shaper_delete;
271 /** Traffic manager node add */
272 rte_tm_node_add_t node_add;
273 /** Traffic manager node delete */
274 rte_tm_node_delete_t node_delete;
275 /** Traffic manager node suspend */
276 rte_tm_node_suspend_t node_suspend;
277 /** Traffic manager node resume */
278 rte_tm_node_resume_t node_resume;
279 /** Traffic manager hierarchy commit */
280 rte_tm_hierarchy_commit_t hierarchy_commit;
282 /** Traffic manager node parent update */
283 rte_tm_node_parent_update_t node_parent_update;
284 /** Traffic manager node shaper update */
285 rte_tm_node_shaper_update_t node_shaper_update;
286 /** Traffic manager node shared shaper update */
287 rte_tm_node_shared_shaper_update_t node_shared_shaper_update;
288 /** Traffic manager node stats update */
289 rte_tm_node_stats_update_t node_stats_update;
290 /** Traffic manager node WFQ weight mode update */
291 rte_tm_node_wfq_weight_mode_update_t node_wfq_weight_mode_update;
292 /** Traffic manager node congestion management mode update */
293 rte_tm_node_cman_update_t node_cman_update;
294 /** Traffic manager node WRED context update */
295 rte_tm_node_wred_context_update_t node_wred_context_update;
296 /** Traffic manager node shared WRED context update */
297 rte_tm_node_shared_wred_context_update_t
298 node_shared_wred_context_update;
299 /** Traffic manager read statistics counters for current node */
300 rte_tm_node_stats_read_t node_stats_read;
302 /** Traffic manager packet marking - VLAN DEI */
303 rte_tm_mark_vlan_dei_t mark_vlan_dei;
304 /** Traffic manager packet marking - IPv4/IPv6 ECN */
305 rte_tm_mark_ip_ecn_t mark_ip_ecn;
306 /** Traffic manager packet marking - IPv4/IPv6 DSCP */
307 rte_tm_mark_ip_dscp_t mark_ip_dscp;
311 * Initialize generic error structure.
313 * This function also sets rte_errno to a given value.
316 * Pointer to error structure (may be NULL).
318 * Related error code (rte_errno).
320 * Cause field and error type.
322 * Object responsible for the error.
324 * Human-readable error message.
330 rte_tm_error_set(struct rte_tm_error *error,
332 enum rte_tm_error_type type,
337 *error = (struct rte_tm_error){
348 * Get generic traffic manager operations structure from a port
351 * The port identifier of the Ethernet device.
356 * The traffic manager operations structure associated with port_id on
357 * success, NULL otherwise.
359 const struct rte_tm_ops *
360 rte_tm_ops_get(uint8_t port_id, struct rte_tm_error *error);
366 #endif /* __INCLUDE_RTE_TM_DRIVER_H__ */