DPDK  19.05.0
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 "rte_tm.h"
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
28 typedef int (*rte_tm_node_type_get_t)(struct rte_eth_dev *dev,
29  uint32_t node_id,
30  int *is_leaf,
31  struct rte_tm_error *error);
32 
34 typedef int (*rte_tm_capabilities_get_t)(struct rte_eth_dev *dev,
35  struct rte_tm_capabilities *cap,
36  struct rte_tm_error *error);
37 
39 typedef int (*rte_tm_level_capabilities_get_t)(struct rte_eth_dev *dev,
40  uint32_t level_id,
41  struct rte_tm_level_capabilities *cap,
42  struct rte_tm_error *error);
43 
45 typedef int (*rte_tm_node_capabilities_get_t)(struct rte_eth_dev *dev,
46  uint32_t node_id,
47  struct rte_tm_node_capabilities *cap,
48  struct rte_tm_error *error);
49 
51 typedef int (*rte_tm_wred_profile_add_t)(struct rte_eth_dev *dev,
52  uint32_t wred_profile_id,
53  struct rte_tm_wred_params *profile,
54  struct rte_tm_error *error);
55 
57 typedef int (*rte_tm_wred_profile_delete_t)(struct rte_eth_dev *dev,
58  uint32_t wred_profile_id,
59  struct rte_tm_error *error);
60 
62 typedef int (*rte_tm_shared_wred_context_add_update_t)(
63  struct rte_eth_dev *dev,
64  uint32_t shared_wred_context_id,
65  uint32_t wred_profile_id,
66  struct rte_tm_error *error);
67 
69 typedef int (*rte_tm_shared_wred_context_delete_t)(
70  struct rte_eth_dev *dev,
71  uint32_t shared_wred_context_id,
72  struct rte_tm_error *error);
73 
75 typedef int (*rte_tm_shaper_profile_add_t)(struct rte_eth_dev *dev,
76  uint32_t shaper_profile_id,
77  struct rte_tm_shaper_params *profile,
78  struct rte_tm_error *error);
79 
81 typedef int (*rte_tm_shaper_profile_delete_t)(struct rte_eth_dev *dev,
82  uint32_t shaper_profile_id,
83  struct rte_tm_error *error);
84 
86 typedef int (*rte_tm_shared_shaper_add_update_t)(struct rte_eth_dev *dev,
87  uint32_t shared_shaper_id,
88  uint32_t shaper_profile_id,
89  struct rte_tm_error *error);
90 
92 typedef int (*rte_tm_shared_shaper_delete_t)(struct rte_eth_dev *dev,
93  uint32_t shared_shaper_id,
94  struct rte_tm_error *error);
95 
97 typedef int (*rte_tm_node_add_t)(struct rte_eth_dev *dev,
98  uint32_t node_id,
99  uint32_t parent_node_id,
100  uint32_t priority,
101  uint32_t weight,
102  uint32_t level_id,
103  struct rte_tm_node_params *params,
104  struct rte_tm_error *error);
105 
107 typedef int (*rte_tm_node_delete_t)(struct rte_eth_dev *dev,
108  uint32_t node_id,
109  struct rte_tm_error *error);
110 
112 typedef int (*rte_tm_node_suspend_t)(struct rte_eth_dev *dev,
113  uint32_t node_id,
114  struct rte_tm_error *error);
115 
117 typedef int (*rte_tm_node_resume_t)(struct rte_eth_dev *dev,
118  uint32_t node_id,
119  struct rte_tm_error *error);
120 
122 typedef int (*rte_tm_hierarchy_commit_t)(struct rte_eth_dev *dev,
123  int clear_on_fail,
124  struct rte_tm_error *error);
125 
127 typedef int (*rte_tm_node_parent_update_t)(struct rte_eth_dev *dev,
128  uint32_t node_id,
129  uint32_t parent_node_id,
130  uint32_t priority,
131  uint32_t weight,
132  struct rte_tm_error *error);
133 
135 typedef int (*rte_tm_node_shaper_update_t)(struct rte_eth_dev *dev,
136  uint32_t node_id,
137  uint32_t shaper_profile_id,
138  struct rte_tm_error *error);
139 
141 typedef int (*rte_tm_node_shared_shaper_update_t)(struct rte_eth_dev *dev,
142  uint32_t node_id,
143  uint32_t shared_shaper_id,
144  int32_t add,
145  struct rte_tm_error *error);
146 
148 typedef int (*rte_tm_node_stats_update_t)(struct rte_eth_dev *dev,
149  uint32_t node_id,
150  uint64_t stats_mask,
151  struct rte_tm_error *error);
152 
154 typedef int (*rte_tm_node_wfq_weight_mode_update_t)(
155  struct rte_eth_dev *dev,
156  uint32_t node_id,
157  int *wfq_weight_mode,
158  uint32_t n_sp_priorities,
159  struct rte_tm_error *error);
160 
162 typedef int (*rte_tm_node_cman_update_t)(struct rte_eth_dev *dev,
163  uint32_t node_id,
164  enum rte_tm_cman_mode cman,
165  struct rte_tm_error *error);
166 
168 typedef int (*rte_tm_node_wred_context_update_t)(
169  struct rte_eth_dev *dev,
170  uint32_t node_id,
171  uint32_t wred_profile_id,
172  struct rte_tm_error *error);
173 
175 typedef int (*rte_tm_node_shared_wred_context_update_t)(
176  struct rte_eth_dev *dev,
177  uint32_t node_id,
178  uint32_t shared_wred_context_id,
179  int add,
180  struct rte_tm_error *error);
181 
183 typedef int (*rte_tm_node_stats_read_t)(struct rte_eth_dev *dev,
184  uint32_t node_id,
185  struct rte_tm_node_stats *stats,
186  uint64_t *stats_mask,
187  int clear,
188  struct rte_tm_error *error);
189 
191 typedef int (*rte_tm_mark_vlan_dei_t)(struct rte_eth_dev *dev,
192  int mark_green,
193  int mark_yellow,
194  int mark_red,
195  struct rte_tm_error *error);
196 
198 typedef int (*rte_tm_mark_ip_ecn_t)(struct rte_eth_dev *dev,
199  int mark_green,
200  int mark_yellow,
201  int mark_red,
202  struct rte_tm_error *error);
203 
205 typedef int (*rte_tm_mark_ip_dscp_t)(struct rte_eth_dev *dev,
206  int mark_green,
207  int mark_yellow,
208  int mark_red,
209  struct rte_tm_error *error);
210 
211 struct rte_tm_ops {
213  rte_tm_node_type_get_t node_type_get;
214 
216  rte_tm_capabilities_get_t capabilities_get;
218  rte_tm_level_capabilities_get_t level_capabilities_get;
220  rte_tm_node_capabilities_get_t node_capabilities_get;
221 
223  rte_tm_wred_profile_add_t wred_profile_add;
225  rte_tm_wred_profile_delete_t wred_profile_delete;
227  rte_tm_shared_wred_context_add_update_t
228  shared_wred_context_add_update;
230  rte_tm_shared_wred_context_delete_t
231  shared_wred_context_delete;
232 
234  rte_tm_shaper_profile_add_t shaper_profile_add;
236  rte_tm_shaper_profile_delete_t shaper_profile_delete;
238  rte_tm_shared_shaper_add_update_t shared_shaper_add_update;
240  rte_tm_shared_shaper_delete_t shared_shaper_delete;
241 
243  rte_tm_node_add_t node_add;
245  rte_tm_node_delete_t node_delete;
247  rte_tm_node_suspend_t node_suspend;
249  rte_tm_node_resume_t node_resume;
251  rte_tm_hierarchy_commit_t hierarchy_commit;
252 
254  rte_tm_node_parent_update_t node_parent_update;
256  rte_tm_node_shaper_update_t node_shaper_update;
258  rte_tm_node_shared_shaper_update_t node_shared_shaper_update;
260  rte_tm_node_stats_update_t node_stats_update;
262  rte_tm_node_wfq_weight_mode_update_t node_wfq_weight_mode_update;
264  rte_tm_node_cman_update_t node_cman_update;
266  rte_tm_node_wred_context_update_t node_wred_context_update;
268  rte_tm_node_shared_wred_context_update_t
269  node_shared_wred_context_update;
271  rte_tm_node_stats_read_t node_stats_read;
272 
274  rte_tm_mark_vlan_dei_t mark_vlan_dei;
276  rte_tm_mark_ip_ecn_t mark_ip_ecn;
278  rte_tm_mark_ip_dscp_t mark_ip_dscp;
279 };
280 
300 static inline int
302  int code,
303  enum rte_tm_error_type type,
304  const void *cause,
305  const char *message)
306 {
307  if (error) {
308  *error = (struct rte_tm_error){
309  .type = type,
310  .cause = cause,
311  .message = message,
312  };
313  }
314  rte_errno = code;
315  return code;
316 }
317 
330 const struct rte_tm_ops *
331 rte_tm_ops_get(uint16_t port_id, struct rte_tm_error *error);
332 
333 #ifdef __cplusplus
334 }
335 #endif
336 
337 #endif /* __INCLUDE_RTE_TM_DRIVER_H__ */