DPDK  22.07.0
rte_mtr_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_MTR_DRIVER_H__
6 #define __INCLUDE_RTE_MTR_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_mtr.h"
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
29 typedef int (*rte_mtr_capabilities_get_t)(struct rte_eth_dev *dev,
30  struct rte_mtr_capabilities *cap,
31  struct rte_mtr_error *error);
32 
34 typedef int (*rte_mtr_meter_profile_add_t)(struct rte_eth_dev *dev,
35  uint32_t meter_profile_id,
36  struct rte_mtr_meter_profile *profile,
37  struct rte_mtr_error *error);
38 
40 typedef int (*rte_mtr_meter_profile_delete_t)(struct rte_eth_dev *dev,
41  uint32_t meter_profile_id,
42  struct rte_mtr_error *error);
43 
45 typedef int (*rte_mtr_meter_policy_validate_t)(struct rte_eth_dev *dev,
46  struct rte_mtr_meter_policy_params *policy,
47  struct rte_mtr_error *error);
48 
50 typedef int (*rte_mtr_meter_policy_add_t)(struct rte_eth_dev *dev,
51  uint32_t policy_id,
52  struct rte_mtr_meter_policy_params *policy,
53  struct rte_mtr_error *error);
54 
56 typedef int (*rte_mtr_meter_policy_delete_t)(struct rte_eth_dev *dev,
57  uint32_t policy_id,
58  struct rte_mtr_error *error);
59 
61 typedef int (*rte_mtr_create_t)(struct rte_eth_dev *dev,
62  uint32_t mtr_id,
63  struct rte_mtr_params *params,
64  int shared,
65  struct rte_mtr_error *error);
66 
68 typedef int (*rte_mtr_destroy_t)(struct rte_eth_dev *dev,
69  uint32_t mtr_id,
70  struct rte_mtr_error *error);
71 
73 typedef int (*rte_mtr_meter_enable_t)(struct rte_eth_dev *dev,
74  uint32_t mtr_id,
75  struct rte_mtr_error *error);
76 
78 typedef int (*rte_mtr_meter_disable_t)(struct rte_eth_dev *dev,
79  uint32_t mtr_id,
80  struct rte_mtr_error *error);
81 
83 typedef int (*rte_mtr_meter_profile_update_t)(struct rte_eth_dev *dev,
84  uint32_t mtr_id,
85  uint32_t meter_profile_id,
86  struct rte_mtr_error *error);
87 
89 typedef int (*rte_mtr_meter_policy_update_t)(struct rte_eth_dev *dev,
90  uint32_t mtr_id,
91  uint32_t meter_policy_id,
92  struct rte_mtr_error *error);
93 
95 typedef int (*rte_mtr_meter_dscp_table_update_t)(struct rte_eth_dev *dev,
96  uint32_t mtr_id,
97  enum rte_color *dscp_table,
98  struct rte_mtr_error *error);
99 
101 typedef int (*rte_mtr_meter_vlan_table_update_t)(struct rte_eth_dev *dev,
102  uint32_t mtr_id,
103  enum rte_color *vlan_table,
104  struct rte_mtr_error *error);
105 
107 typedef int (*rte_mtr_meter_color_in_proto_set_t)(struct rte_eth_dev *dev,
108  uint32_t mtr_id,
109  enum rte_mtr_color_in_protocol proto,
110  uint32_t priority,
111  struct rte_mtr_error *error);
112 
114 typedef int (*rte_mtr_meter_color_in_proto_get_t)(struct rte_eth_dev *dev,
115  uint32_t mtr_id,
116  uint64_t *proto_mask,
117  struct rte_mtr_error *error);
118 
120 typedef int (*rte_mtr_meter_color_in_proto_prio_get_t)(struct rte_eth_dev *dev,
121  uint32_t mtr_id,
122  enum rte_mtr_color_in_protocol proto,
123  uint32_t *priority,
124  struct rte_mtr_error *error);
125 
127 typedef int (*rte_mtr_stats_update_t)(struct rte_eth_dev *dev,
128  uint32_t mtr_id,
129  uint64_t stats_mask,
130  struct rte_mtr_error *error);
131 
133 typedef int (*rte_mtr_stats_read_t)(struct rte_eth_dev *dev,
134  uint32_t mtr_id,
135  struct rte_mtr_stats *stats,
136  uint64_t *stats_mask,
137  int clear,
138  struct rte_mtr_error *error);
139 
140 struct rte_mtr_ops {
142  rte_mtr_capabilities_get_t capabilities_get;
143 
145  rte_mtr_meter_profile_add_t meter_profile_add;
146 
148  rte_mtr_meter_profile_delete_t meter_profile_delete;
149 
151  rte_mtr_create_t create;
152 
154  rte_mtr_destroy_t destroy;
155 
157  rte_mtr_meter_enable_t meter_enable;
158 
160  rte_mtr_meter_disable_t meter_disable;
161 
163  rte_mtr_meter_profile_update_t meter_profile_update;
164 
166  rte_mtr_meter_dscp_table_update_t meter_dscp_table_update;
167 
169  rte_mtr_meter_vlan_table_update_t meter_vlan_table_update;
170 
172  rte_mtr_meter_color_in_proto_set_t in_proto_set;
173 
175  rte_mtr_meter_color_in_proto_get_t in_proto_get;
176 
178  rte_mtr_meter_color_in_proto_prio_get_t in_proto_prio_get;
179 
181  rte_mtr_stats_update_t stats_update;
182 
184  rte_mtr_stats_read_t stats_read;
185 
187  rte_mtr_meter_policy_validate_t meter_policy_validate;
188 
190  rte_mtr_meter_policy_add_t meter_policy_add;
191 
193  rte_mtr_meter_policy_delete_t meter_policy_delete;
194 
196  rte_mtr_meter_policy_update_t meter_policy_update;
197 };
198 
218 static inline int
220  int code,
221  enum rte_mtr_error_type type,
222  const void *cause,
223  const char *message)
224 {
225  if (error) {
226  *error = (struct rte_mtr_error){
227  .type = type,
228  .cause = cause,
229  .message = message,
230  };
231  }
232  rte_errno = code;
233  return code;
234 }
235 
248 const struct rte_mtr_ops *
249 rte_mtr_ops_get(uint16_t port_id, struct rte_mtr_error *error);
250 
251 #ifdef __cplusplus
252 }
253 #endif
254 
255 #endif /* __INCLUDE_RTE_MTR_DRIVER_H__ */
rte_mtr_error_type
Definition: rte_mtr.h:527
static int rte_mtr_error_set(struct rte_mtr_error *error, int code, enum rte_mtr_error_type type, const void *cause, const char *message)
#define rte_errno
Definition: rte_errno.h:29
enum rte_mtr_error_type type
Definition: rte_mtr.h:557
rte_mtr_color_in_protocol
Definition: rte_mtr.h:228
rte_color
Definition: rte_meter.h:36
const struct rte_mtr_ops * rte_mtr_ops_get(uint16_t port_id, struct rte_mtr_error *error)