DPDK  17.11.10
rte_tm_driver.h
Go to the documentation of this file.
1 /*-
2  * BSD LICENSE
3  *
4  * Copyright(c) 2017 Intel Corporation. All rights reserved.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
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
16  * distribution.
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.
20  *
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.
32  */
33 
34 #ifndef __INCLUDE_RTE_TM_DRIVER_H__
35 #define __INCLUDE_RTE_TM_DRIVER_H__
36 
46 #include <stdint.h>
47 
48 #include <rte_errno.h>
49 #include "rte_ethdev.h"
50 #include "rte_tm.h"
51 
52 #ifdef __cplusplus
53 extern "C" {
54 #endif
55 
57 typedef int (*rte_tm_node_type_get_t)(struct rte_eth_dev *dev,
58  uint32_t node_id,
59  int *is_leaf,
60  struct rte_tm_error *error);
61 
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);
66 
68 typedef int (*rte_tm_level_capabilities_get_t)(struct rte_eth_dev *dev,
69  uint32_t level_id,
70  struct rte_tm_level_capabilities *cap,
71  struct rte_tm_error *error);
72 
74 typedef int (*rte_tm_node_capabilities_get_t)(struct rte_eth_dev *dev,
75  uint32_t node_id,
76  struct rte_tm_node_capabilities *cap,
77  struct rte_tm_error *error);
78 
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);
84 
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);
89 
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);
96 
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);
102 
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);
108 
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);
113 
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);
119 
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);
124 
126 typedef int (*rte_tm_node_add_t)(struct rte_eth_dev *dev,
127  uint32_t node_id,
128  uint32_t parent_node_id,
129  uint32_t priority,
130  uint32_t weight,
131  uint32_t level_id,
132  struct rte_tm_node_params *params,
133  struct rte_tm_error *error);
134 
136 typedef int (*rte_tm_node_delete_t)(struct rte_eth_dev *dev,
137  uint32_t node_id,
138  struct rte_tm_error *error);
139 
141 typedef int (*rte_tm_node_suspend_t)(struct rte_eth_dev *dev,
142  uint32_t node_id,
143  struct rte_tm_error *error);
144 
146 typedef int (*rte_tm_node_resume_t)(struct rte_eth_dev *dev,
147  uint32_t node_id,
148  struct rte_tm_error *error);
149 
151 typedef int (*rte_tm_hierarchy_commit_t)(struct rte_eth_dev *dev,
152  int clear_on_fail,
153  struct rte_tm_error *error);
154 
156 typedef int (*rte_tm_node_parent_update_t)(struct rte_eth_dev *dev,
157  uint32_t node_id,
158  uint32_t parent_node_id,
159  uint32_t priority,
160  uint32_t weight,
161  struct rte_tm_error *error);
162 
164 typedef int (*rte_tm_node_shaper_update_t)(struct rte_eth_dev *dev,
165  uint32_t node_id,
166  uint32_t shaper_profile_id,
167  struct rte_tm_error *error);
168 
170 typedef int (*rte_tm_node_shared_shaper_update_t)(struct rte_eth_dev *dev,
171  uint32_t node_id,
172  uint32_t shared_shaper_id,
173  int32_t add,
174  struct rte_tm_error *error);
175 
177 typedef int (*rte_tm_node_stats_update_t)(struct rte_eth_dev *dev,
178  uint32_t node_id,
179  uint64_t stats_mask,
180  struct rte_tm_error *error);
181 
183 typedef int (*rte_tm_node_wfq_weight_mode_update_t)(
184  struct rte_eth_dev *dev,
185  uint32_t node_id,
186  int *wfq_weight_mode,
187  uint32_t n_sp_priorities,
188  struct rte_tm_error *error);
189 
191 typedef int (*rte_tm_node_cman_update_t)(struct rte_eth_dev *dev,
192  uint32_t node_id,
193  enum rte_tm_cman_mode cman,
194  struct rte_tm_error *error);
195 
197 typedef int (*rte_tm_node_wred_context_update_t)(
198  struct rte_eth_dev *dev,
199  uint32_t node_id,
200  uint32_t wred_profile_id,
201  struct rte_tm_error *error);
202 
204 typedef int (*rte_tm_node_shared_wred_context_update_t)(
205  struct rte_eth_dev *dev,
206  uint32_t node_id,
207  uint32_t shared_wred_context_id,
208  int add,
209  struct rte_tm_error *error);
210 
212 typedef int (*rte_tm_node_stats_read_t)(struct rte_eth_dev *dev,
213  uint32_t node_id,
214  struct rte_tm_node_stats *stats,
215  uint64_t *stats_mask,
216  int clear,
217  struct rte_tm_error *error);
218 
220 typedef int (*rte_tm_mark_vlan_dei_t)(struct rte_eth_dev *dev,
221  int mark_green,
222  int mark_yellow,
223  int mark_red,
224  struct rte_tm_error *error);
225 
227 typedef int (*rte_tm_mark_ip_ecn_t)(struct rte_eth_dev *dev,
228  int mark_green,
229  int mark_yellow,
230  int mark_red,
231  struct rte_tm_error *error);
232 
234 typedef int (*rte_tm_mark_ip_dscp_t)(struct rte_eth_dev *dev,
235  int mark_green,
236  int mark_yellow,
237  int mark_red,
238  struct rte_tm_error *error);
239 
240 struct rte_tm_ops {
242  rte_tm_node_type_get_t node_type_get;
243 
245  rte_tm_capabilities_get_t capabilities_get;
247  rte_tm_level_capabilities_get_t level_capabilities_get;
249  rte_tm_node_capabilities_get_t node_capabilities_get;
250 
252  rte_tm_wred_profile_add_t wred_profile_add;
254  rte_tm_wred_profile_delete_t wred_profile_delete;
256  rte_tm_shared_wred_context_add_update_t
257  shared_wred_context_add_update;
259  rte_tm_shared_wred_context_delete_t
260  shared_wred_context_delete;
261 
263  rte_tm_shaper_profile_add_t shaper_profile_add;
265  rte_tm_shaper_profile_delete_t shaper_profile_delete;
267  rte_tm_shared_shaper_add_update_t shared_shaper_add_update;
269  rte_tm_shared_shaper_delete_t shared_shaper_delete;
270 
272  rte_tm_node_add_t node_add;
274  rte_tm_node_delete_t node_delete;
276  rte_tm_node_suspend_t node_suspend;
278  rte_tm_node_resume_t node_resume;
280  rte_tm_hierarchy_commit_t hierarchy_commit;
281 
283  rte_tm_node_parent_update_t node_parent_update;
285  rte_tm_node_shaper_update_t node_shaper_update;
287  rte_tm_node_shared_shaper_update_t node_shared_shaper_update;
289  rte_tm_node_stats_update_t node_stats_update;
291  rte_tm_node_wfq_weight_mode_update_t node_wfq_weight_mode_update;
293  rte_tm_node_cman_update_t node_cman_update;
295  rte_tm_node_wred_context_update_t node_wred_context_update;
297  rte_tm_node_shared_wred_context_update_t
298  node_shared_wred_context_update;
300  rte_tm_node_stats_read_t node_stats_read;
301 
303  rte_tm_mark_vlan_dei_t mark_vlan_dei;
305  rte_tm_mark_ip_ecn_t mark_ip_ecn;
307  rte_tm_mark_ip_dscp_t mark_ip_dscp;
308 };
309 
329 static inline int
331  int code,
332  enum rte_tm_error_type type,
333  const void *cause,
334  const char *message)
335 {
336  if (error) {
337  *error = (struct rte_tm_error){
338  .type = type,
339  .cause = cause,
340  .message = message,
341  };
342  }
343  rte_errno = code;
344  return code;
345 }
346 
359 const struct rte_tm_ops *
360 rte_tm_ops_get(uint16_t port_id, struct rte_tm_error *error);
361 
362 #ifdef __cplusplus
363 }
364 #endif
365 
366 #endif /* __INCLUDE_RTE_TM_DRIVER_H__ */
const void * cause
Definition: rte_tm.h:1021
#define rte_errno
Definition: rte_errno.h:58
const char * message
Definition: rte_tm.h:1022
enum rte_tm_error_type type
Definition: rte_tm.h:1020
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:972
rte_tm_cman_mode
Definition: rte_tm.h:783