1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2017 Intel Corporation
5 #ifndef __INCLUDE_RTE_TM_DRIVER_H__
6 #define __INCLUDE_RTE_TM_DRIVER_H__
10 * RTE Generic Traffic Manager API (Driver Side)
12 * This file provides implementation helpers for internal use by PMDs, they
13 * are not intended to be exposed to applications and are not subject to ABI
19 #include <rte_errno.h>
20 #include "rte_ethdev.h"
21 #include "ethdev_driver.h"
28 /** @internal Traffic manager node ID validate and type get */
29 typedef int (*rte_tm_node_type_get_t)(struct rte_eth_dev *dev,
32 struct rte_tm_error *error);
34 /** @internal Traffic manager capabilities get */
35 typedef int (*rte_tm_capabilities_get_t)(struct rte_eth_dev *dev,
36 struct rte_tm_capabilities *cap,
37 struct rte_tm_error *error);
39 /** @internal Traffic manager level capabilities get */
40 typedef int (*rte_tm_level_capabilities_get_t)(struct rte_eth_dev *dev,
42 struct rte_tm_level_capabilities *cap,
43 struct rte_tm_error *error);
45 /** @internal Traffic manager node capabilities get */
46 typedef int (*rte_tm_node_capabilities_get_t)(struct rte_eth_dev *dev,
48 struct rte_tm_node_capabilities *cap,
49 struct rte_tm_error *error);
51 /** @internal Traffic manager WRED profile add */
52 typedef int (*rte_tm_wred_profile_add_t)(struct rte_eth_dev *dev,
53 uint32_t wred_profile_id,
54 struct rte_tm_wred_params *profile,
55 struct rte_tm_error *error);
57 /** @internal Traffic manager WRED profile delete */
58 typedef int (*rte_tm_wred_profile_delete_t)(struct rte_eth_dev *dev,
59 uint32_t wred_profile_id,
60 struct rte_tm_error *error);
62 /** @internal Traffic manager shared WRED context add */
63 typedef int (*rte_tm_shared_wred_context_add_update_t)(
64 struct rte_eth_dev *dev,
65 uint32_t shared_wred_context_id,
66 uint32_t wred_profile_id,
67 struct rte_tm_error *error);
69 /** @internal Traffic manager shared WRED context delete */
70 typedef int (*rte_tm_shared_wred_context_delete_t)(
71 struct rte_eth_dev *dev,
72 uint32_t shared_wred_context_id,
73 struct rte_tm_error *error);
75 /** @internal Traffic manager shaper profile add */
76 typedef int (*rte_tm_shaper_profile_add_t)(struct rte_eth_dev *dev,
77 uint32_t shaper_profile_id,
78 struct rte_tm_shaper_params *profile,
79 struct rte_tm_error *error);
81 /** @internal Traffic manager shaper profile delete */
82 typedef int (*rte_tm_shaper_profile_delete_t)(struct rte_eth_dev *dev,
83 uint32_t shaper_profile_id,
84 struct rte_tm_error *error);
86 /** @internal Traffic manager shared shaper add/update */
87 typedef int (*rte_tm_shared_shaper_add_update_t)(struct rte_eth_dev *dev,
88 uint32_t shared_shaper_id,
89 uint32_t shaper_profile_id,
90 struct rte_tm_error *error);
92 /** @internal Traffic manager shared shaper delete */
93 typedef int (*rte_tm_shared_shaper_delete_t)(struct rte_eth_dev *dev,
94 uint32_t shared_shaper_id,
95 struct rte_tm_error *error);
97 /** @internal Traffic manager node add */
98 typedef int (*rte_tm_node_add_t)(struct rte_eth_dev *dev,
100 uint32_t parent_node_id,
104 struct rte_tm_node_params *params,
105 struct rte_tm_error *error);
107 /** @internal Traffic manager node delete */
108 typedef int (*rte_tm_node_delete_t)(struct rte_eth_dev *dev,
110 struct rte_tm_error *error);
112 /** @internal Traffic manager node suspend */
113 typedef int (*rte_tm_node_suspend_t)(struct rte_eth_dev *dev,
115 struct rte_tm_error *error);
117 /** @internal Traffic manager node resume */
118 typedef int (*rte_tm_node_resume_t)(struct rte_eth_dev *dev,
120 struct rte_tm_error *error);
122 /** @internal Traffic manager hierarchy commit */
123 typedef int (*rte_tm_hierarchy_commit_t)(struct rte_eth_dev *dev,
125 struct rte_tm_error *error);
127 /** @internal Traffic manager node parent update */
128 typedef int (*rte_tm_node_parent_update_t)(struct rte_eth_dev *dev,
130 uint32_t parent_node_id,
133 struct rte_tm_error *error);
135 /** @internal Traffic manager node shaper update */
136 typedef int (*rte_tm_node_shaper_update_t)(struct rte_eth_dev *dev,
138 uint32_t shaper_profile_id,
139 struct rte_tm_error *error);
141 /** @internal Traffic manager node shaper update */
142 typedef int (*rte_tm_node_shared_shaper_update_t)(struct rte_eth_dev *dev,
144 uint32_t shared_shaper_id,
146 struct rte_tm_error *error);
148 /** @internal Traffic manager node stats update */
149 typedef int (*rte_tm_node_stats_update_t)(struct rte_eth_dev *dev,
152 struct rte_tm_error *error);
154 /** @internal Traffic manager node WFQ weight mode update */
155 typedef int (*rte_tm_node_wfq_weight_mode_update_t)(
156 struct rte_eth_dev *dev,
158 int *wfq_weight_mode,
159 uint32_t n_sp_priorities,
160 struct rte_tm_error *error);
162 /** @internal Traffic manager node congestion management mode update */
163 typedef int (*rte_tm_node_cman_update_t)(struct rte_eth_dev *dev,
165 enum rte_tm_cman_mode cman,
166 struct rte_tm_error *error);
168 /** @internal Traffic manager node WRED context update */
169 typedef int (*rte_tm_node_wred_context_update_t)(
170 struct rte_eth_dev *dev,
172 uint32_t wred_profile_id,
173 struct rte_tm_error *error);
175 /** @internal Traffic manager node WRED context update */
176 typedef int (*rte_tm_node_shared_wred_context_update_t)(
177 struct rte_eth_dev *dev,
179 uint32_t shared_wred_context_id,
181 struct rte_tm_error *error);
183 /** @internal Traffic manager read stats counters for specific node */
184 typedef int (*rte_tm_node_stats_read_t)(struct rte_eth_dev *dev,
186 struct rte_tm_node_stats *stats,
187 uint64_t *stats_mask,
189 struct rte_tm_error *error);
191 /** @internal Traffic manager packet marking - VLAN DEI */
192 typedef int (*rte_tm_mark_vlan_dei_t)(struct rte_eth_dev *dev,
196 struct rte_tm_error *error);
198 /** @internal Traffic manager packet marking - IPv4/IPv6 ECN */
199 typedef int (*rte_tm_mark_ip_ecn_t)(struct rte_eth_dev *dev,
203 struct rte_tm_error *error);
205 /** @internal Traffic manager packet marking - IPv4/IPv6 DSCP */
206 typedef int (*rte_tm_mark_ip_dscp_t)(struct rte_eth_dev *dev,
210 struct rte_tm_error *error);
213 /** Traffic manager node type get */
214 rte_tm_node_type_get_t node_type_get;
216 /** Traffic manager capabilities_get */
217 rte_tm_capabilities_get_t capabilities_get;
218 /** Traffic manager level capabilities_get */
219 rte_tm_level_capabilities_get_t level_capabilities_get;
220 /** Traffic manager node capabilities get */
221 rte_tm_node_capabilities_get_t node_capabilities_get;
223 /** Traffic manager WRED profile add */
224 rte_tm_wred_profile_add_t wred_profile_add;
225 /** Traffic manager WRED profile delete */
226 rte_tm_wred_profile_delete_t wred_profile_delete;
227 /** Traffic manager shared WRED context add/update */
228 rte_tm_shared_wred_context_add_update_t
229 shared_wred_context_add_update;
230 /** Traffic manager shared WRED context delete */
231 rte_tm_shared_wred_context_delete_t
232 shared_wred_context_delete;
234 /** Traffic manager shaper profile add */
235 rte_tm_shaper_profile_add_t shaper_profile_add;
236 /** Traffic manager shaper profile delete */
237 rte_tm_shaper_profile_delete_t shaper_profile_delete;
238 /** Traffic manager shared shaper add/update */
239 rte_tm_shared_shaper_add_update_t shared_shaper_add_update;
240 /** Traffic manager shared shaper delete */
241 rte_tm_shared_shaper_delete_t shared_shaper_delete;
243 /** Traffic manager node add */
244 rte_tm_node_add_t node_add;
245 /** Traffic manager node delete */
246 rte_tm_node_delete_t node_delete;
247 /** Traffic manager node suspend */
248 rte_tm_node_suspend_t node_suspend;
249 /** Traffic manager node resume */
250 rte_tm_node_resume_t node_resume;
251 /** Traffic manager hierarchy commit */
252 rte_tm_hierarchy_commit_t hierarchy_commit;
254 /** Traffic manager node parent update */
255 rte_tm_node_parent_update_t node_parent_update;
256 /** Traffic manager node shaper update */
257 rte_tm_node_shaper_update_t node_shaper_update;
258 /** Traffic manager node shared shaper update */
259 rte_tm_node_shared_shaper_update_t node_shared_shaper_update;
260 /** Traffic manager node stats update */
261 rte_tm_node_stats_update_t node_stats_update;
262 /** Traffic manager node WFQ weight mode update */
263 rte_tm_node_wfq_weight_mode_update_t node_wfq_weight_mode_update;
264 /** Traffic manager node congestion management mode update */
265 rte_tm_node_cman_update_t node_cman_update;
266 /** Traffic manager node WRED context update */
267 rte_tm_node_wred_context_update_t node_wred_context_update;
268 /** Traffic manager node shared WRED context update */
269 rte_tm_node_shared_wred_context_update_t
270 node_shared_wred_context_update;
271 /** Traffic manager read statistics counters for current node */
272 rte_tm_node_stats_read_t node_stats_read;
274 /** Traffic manager packet marking - VLAN DEI */
275 rte_tm_mark_vlan_dei_t mark_vlan_dei;
276 /** Traffic manager packet marking - IPv4/IPv6 ECN */
277 rte_tm_mark_ip_ecn_t mark_ip_ecn;
278 /** Traffic manager packet marking - IPv4/IPv6 DSCP */
279 rte_tm_mark_ip_dscp_t mark_ip_dscp;
283 * Initialize generic error structure.
285 * This function also sets rte_errno to a given value.
288 * Pointer to error structure (may be NULL).
290 * Related error code (rte_errno).
292 * Cause field and error type.
294 * Object responsible for the error.
296 * Human-readable error message.
302 rte_tm_error_set(struct rte_tm_error *error,
304 enum rte_tm_error_type type,
309 *error = (struct rte_tm_error){
320 * Get generic traffic manager operations structure from a port
323 * The port identifier of the Ethernet device.
328 * The traffic manager operations structure associated with port_id on
329 * success, NULL otherwise.
331 const struct rte_tm_ops *
332 rte_tm_ops_get(uint16_t port_id, struct rte_tm_error *error);
338 #endif /* __INCLUDE_RTE_TM_DRIVER_H__ */