DPDK  24.11.0-rc3
rte_tm_driver.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2017 Intel Corporation
3  */
4 
5 #ifndef __INCLUDE_RTE_TM_DRIVER_H__
6 #define __INCLUDE_RTE_TM_DRIVER_H__
7 
17 #include <stdint.h>
18 
19 #include <rte_errno.h>
20 #include "rte_ethdev.h"
21 #include "ethdev_driver.h"
22 #include "rte_tm.h"
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
29 typedef int (*rte_tm_node_type_get_t)(struct rte_eth_dev *dev,
30  uint32_t node_id,
31  int *is_leaf,
32  struct rte_tm_error *error);
33 
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);
38 
40 typedef int (*rte_tm_level_capabilities_get_t)(struct rte_eth_dev *dev,
41  uint32_t level_id,
42  struct rte_tm_level_capabilities *cap,
43  struct rte_tm_error *error);
44 
46 typedef int (*rte_tm_node_capabilities_get_t)(struct rte_eth_dev *dev,
47  uint32_t node_id,
48  struct rte_tm_node_capabilities *cap,
49  struct rte_tm_error *error);
50 
52 typedef int (*rte_tm_wred_profile_add_t)(struct rte_eth_dev *dev,
53  uint32_t wred_profile_id,
54  const struct rte_tm_wred_params *profile,
55  struct rte_tm_error *error);
56 
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);
61 
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);
68 
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);
74 
76 typedef int (*rte_tm_shaper_profile_add_t)(struct rte_eth_dev *dev,
77  uint32_t shaper_profile_id,
78  const struct rte_tm_shaper_params *profile,
79  struct rte_tm_error *error);
80 
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);
85 
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);
91 
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);
96 
98 typedef int (*rte_tm_node_add_t)(struct rte_eth_dev *dev,
99  uint32_t node_id,
100  uint32_t parent_node_id,
101  uint32_t priority,
102  uint32_t weight,
103  uint32_t level_id,
104  const struct rte_tm_node_params *params,
105  struct rte_tm_error *error);
106 
108 typedef int (*rte_tm_node_delete_t)(struct rte_eth_dev *dev,
109  uint32_t node_id,
110  struct rte_tm_error *error);
111 
113 typedef int (*rte_tm_node_suspend_t)(struct rte_eth_dev *dev,
114  uint32_t node_id,
115  struct rte_tm_error *error);
116 
118 typedef int (*rte_tm_node_resume_t)(struct rte_eth_dev *dev,
119  uint32_t node_id,
120  struct rte_tm_error *error);
121 
123 typedef int (*rte_tm_node_query_t)(const struct rte_eth_dev *dev,
124  uint32_t node_id,
125  uint32_t *parent_node_id,
126  uint32_t *priority,
127  uint32_t *weight,
128  uint32_t *level_id,
129  struct rte_tm_node_params *params,
130  struct rte_tm_error *error);
131 
133 typedef int (*rte_tm_hierarchy_commit_t)(struct rte_eth_dev *dev,
134  int clear_on_fail,
135  struct rte_tm_error *error);
136 
138 typedef int (*rte_tm_node_parent_update_t)(struct rte_eth_dev *dev,
139  uint32_t node_id,
140  uint32_t parent_node_id,
141  uint32_t priority,
142  uint32_t weight,
143  struct rte_tm_error *error);
144 
146 typedef int (*rte_tm_node_shaper_update_t)(struct rte_eth_dev *dev,
147  uint32_t node_id,
148  uint32_t shaper_profile_id,
149  struct rte_tm_error *error);
150 
152 typedef int (*rte_tm_node_shared_shaper_update_t)(struct rte_eth_dev *dev,
153  uint32_t node_id,
154  uint32_t shared_shaper_id,
155  int32_t add,
156  struct rte_tm_error *error);
157 
159 typedef int (*rte_tm_node_stats_update_t)(struct rte_eth_dev *dev,
160  uint32_t node_id,
161  uint64_t stats_mask,
162  struct rte_tm_error *error);
163 
165 typedef int (*rte_tm_node_wfq_weight_mode_update_t)(
166  struct rte_eth_dev *dev,
167  uint32_t node_id,
168  int *wfq_weight_mode,
169  uint32_t n_sp_priorities,
170  struct rte_tm_error *error);
171 
173 typedef int (*rte_tm_node_cman_update_t)(struct rte_eth_dev *dev,
174  uint32_t node_id,
175  enum rte_tm_cman_mode cman,
176  struct rte_tm_error *error);
177 
179 typedef int (*rte_tm_node_wred_context_update_t)(
180  struct rte_eth_dev *dev,
181  uint32_t node_id,
182  uint32_t wred_profile_id,
183  struct rte_tm_error *error);
184 
186 typedef int (*rte_tm_node_shared_wred_context_update_t)(
187  struct rte_eth_dev *dev,
188  uint32_t node_id,
189  uint32_t shared_wred_context_id,
190  int add,
191  struct rte_tm_error *error);
192 
194 typedef int (*rte_tm_node_stats_read_t)(struct rte_eth_dev *dev,
195  uint32_t node_id,
196  struct rte_tm_node_stats *stats,
197  uint64_t *stats_mask,
198  int clear,
199  struct rte_tm_error *error);
200 
202 typedef int (*rte_tm_mark_vlan_dei_t)(struct rte_eth_dev *dev,
203  int mark_green,
204  int mark_yellow,
205  int mark_red,
206  struct rte_tm_error *error);
207 
209 typedef int (*rte_tm_mark_ip_ecn_t)(struct rte_eth_dev *dev,
210  int mark_green,
211  int mark_yellow,
212  int mark_red,
213  struct rte_tm_error *error);
214 
216 typedef int (*rte_tm_mark_ip_dscp_t)(struct rte_eth_dev *dev,
217  int mark_green,
218  int mark_yellow,
219  int mark_red,
220  struct rte_tm_error *error);
221 
222 struct rte_tm_ops {
224  rte_tm_node_type_get_t node_type_get;
225 
227  rte_tm_capabilities_get_t capabilities_get;
229  rte_tm_level_capabilities_get_t level_capabilities_get;
231  rte_tm_node_capabilities_get_t node_capabilities_get;
232 
234  rte_tm_wred_profile_add_t wred_profile_add;
236  rte_tm_wred_profile_delete_t wred_profile_delete;
238  rte_tm_shared_wred_context_add_update_t
239  shared_wred_context_add_update;
241  rte_tm_shared_wred_context_delete_t
242  shared_wred_context_delete;
243 
245  rte_tm_shaper_profile_add_t shaper_profile_add;
247  rte_tm_shaper_profile_delete_t shaper_profile_delete;
249  rte_tm_shared_shaper_add_update_t shared_shaper_add_update;
251  rte_tm_shared_shaper_delete_t shared_shaper_delete;
252 
254  rte_tm_node_add_t node_add;
256  rte_tm_node_delete_t node_delete;
258  rte_tm_node_suspend_t node_suspend;
260  rte_tm_node_resume_t node_resume;
262  rte_tm_node_query_t node_query;
264  rte_tm_hierarchy_commit_t hierarchy_commit;
265 
267  rte_tm_node_parent_update_t node_parent_update;
269  rte_tm_node_shaper_update_t node_shaper_update;
271  rte_tm_node_shared_shaper_update_t node_shared_shaper_update;
273  rte_tm_node_stats_update_t node_stats_update;
275  rte_tm_node_wfq_weight_mode_update_t node_wfq_weight_mode_update;
277  rte_tm_node_cman_update_t node_cman_update;
279  rte_tm_node_wred_context_update_t node_wred_context_update;
281  rte_tm_node_shared_wred_context_update_t
282  node_shared_wred_context_update;
284  rte_tm_node_stats_read_t node_stats_read;
285 
287  rte_tm_mark_vlan_dei_t mark_vlan_dei;
289  rte_tm_mark_ip_ecn_t mark_ip_ecn;
291  rte_tm_mark_ip_dscp_t mark_ip_dscp;
292 };
293 
313 static inline int
315  int code,
316  enum rte_tm_error_type type,
317  const void *cause,
318  const char *message)
319 {
320  if (error) {
321  *error = (struct rte_tm_error){
322  .type = type,
323  .cause = cause,
324  .message = message,
325  };
326  }
327  rte_errno = code;
328  return code;
329 }
330 
343 const struct rte_tm_ops *
344 rte_tm_ops_get(uint16_t port_id, struct rte_tm_error *error);
345 
346 #ifdef __cplusplus
347 }
348 #endif
349 
350 #endif /* __INCLUDE_RTE_TM_DRIVER_H__ */
#define rte_errno
Definition: rte_errno.h:29
enum rte_tm_error_type type
Definition: rte_tm.h:1219
const struct rte_tm_ops * rte_tm_ops_get(uint16_t port_id, struct rte_tm_error *error)
static int rte_tm_error_set(struct rte_tm_error *error, int code, enum rte_tm_error_type type, const void *cause, const char *message)
rte_tm_error_type
Definition: rte_tm.h:1170
rte_tm_cman_mode
Definition: rte_tm.h:955