DPDK  23.03.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 struct rte_flow_meter_profile *
46 (*rte_mtr_meter_profile_get_t)(struct rte_eth_dev *dev,
47  uint32_t meter_profile_id,
48  struct rte_mtr_error *error);
49 
51 typedef int (*rte_mtr_meter_policy_validate_t)(struct rte_eth_dev *dev,
52  struct rte_mtr_meter_policy_params *policy,
53  struct rte_mtr_error *error);
54 
56 typedef int (*rte_mtr_meter_policy_add_t)(struct rte_eth_dev *dev,
57  uint32_t policy_id,
58  struct rte_mtr_meter_policy_params *policy,
59  struct rte_mtr_error *error);
60 
62 typedef int (*rte_mtr_meter_policy_delete_t)(struct rte_eth_dev *dev,
63  uint32_t policy_id,
64  struct rte_mtr_error *error);
65 
67 typedef struct rte_flow_meter_policy *
68 (*rte_mtr_meter_policy_get_t)(struct rte_eth_dev *dev,
69  uint32_t policy_id,
70  struct rte_mtr_error *error);
71 
72 
74 typedef int (*rte_mtr_create_t)(struct rte_eth_dev *dev,
75  uint32_t mtr_id,
76  struct rte_mtr_params *params,
77  int shared,
78  struct rte_mtr_error *error);
79 
81 typedef int (*rte_mtr_destroy_t)(struct rte_eth_dev *dev,
82  uint32_t mtr_id,
83  struct rte_mtr_error *error);
84 
86 typedef int (*rte_mtr_meter_enable_t)(struct rte_eth_dev *dev,
87  uint32_t mtr_id,
88  struct rte_mtr_error *error);
89 
91 typedef int (*rte_mtr_meter_disable_t)(struct rte_eth_dev *dev,
92  uint32_t mtr_id,
93  struct rte_mtr_error *error);
94 
96 typedef int (*rte_mtr_meter_profile_update_t)(struct rte_eth_dev *dev,
97  uint32_t mtr_id,
98  uint32_t meter_profile_id,
99  struct rte_mtr_error *error);
100 
102 typedef int (*rte_mtr_meter_policy_update_t)(struct rte_eth_dev *dev,
103  uint32_t mtr_id,
104  uint32_t meter_policy_id,
105  struct rte_mtr_error *error);
106 
108 typedef int (*rte_mtr_meter_dscp_table_update_t)(struct rte_eth_dev *dev,
109  uint32_t mtr_id, enum rte_mtr_color_in_protocol proto,
110  enum rte_color *dscp_table,
111  struct rte_mtr_error *error);
112 
114 typedef int (*rte_mtr_meter_vlan_table_update_t)(struct rte_eth_dev *dev,
115  uint32_t mtr_id, enum rte_mtr_color_in_protocol proto,
116  enum rte_color *vlan_table,
117  struct rte_mtr_error *error);
118 
120 typedef int (*rte_mtr_meter_color_in_proto_set_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_meter_color_in_proto_get_t)(struct rte_eth_dev *dev,
128  uint32_t mtr_id,
129  uint64_t *proto_mask,
130  struct rte_mtr_error *error);
131 
133 typedef int (*rte_mtr_meter_color_in_proto_prio_get_t)(struct rte_eth_dev *dev,
134  uint32_t mtr_id,
135  enum rte_mtr_color_in_protocol proto,
136  uint32_t *priority,
137  struct rte_mtr_error *error);
138 
140 typedef int (*rte_mtr_stats_update_t)(struct rte_eth_dev *dev,
141  uint32_t mtr_id,
142  uint64_t stats_mask,
143  struct rte_mtr_error *error);
144 
146 typedef int (*rte_mtr_stats_read_t)(struct rte_eth_dev *dev,
147  uint32_t mtr_id,
148  struct rte_mtr_stats *stats,
149  uint64_t *stats_mask,
150  int clear,
151  struct rte_mtr_error *error);
152 
153 struct rte_mtr_ops {
155  rte_mtr_capabilities_get_t capabilities_get;
156 
158  rte_mtr_meter_profile_add_t meter_profile_add;
159 
161  rte_mtr_meter_profile_delete_t meter_profile_delete;
162 
164  rte_mtr_create_t create;
165 
167  rte_mtr_destroy_t destroy;
168 
170  rte_mtr_meter_enable_t meter_enable;
171 
173  rte_mtr_meter_disable_t meter_disable;
174 
176  rte_mtr_meter_profile_update_t meter_profile_update;
177 
179  rte_mtr_meter_dscp_table_update_t meter_dscp_table_update;
180 
182  rte_mtr_meter_vlan_table_update_t meter_vlan_table_update;
183 
185  rte_mtr_meter_color_in_proto_set_t in_proto_set;
186 
188  rte_mtr_meter_color_in_proto_get_t in_proto_get;
189 
191  rte_mtr_meter_color_in_proto_prio_get_t in_proto_prio_get;
192 
194  rte_mtr_stats_update_t stats_update;
195 
197  rte_mtr_stats_read_t stats_read;
198 
200  rte_mtr_meter_policy_validate_t meter_policy_validate;
201 
203  rte_mtr_meter_policy_add_t meter_policy_add;
204 
206  rte_mtr_meter_policy_delete_t meter_policy_delete;
207 
209  rte_mtr_meter_policy_update_t meter_policy_update;
210 
212  rte_mtr_meter_profile_get_t meter_profile_get;
213 
215  rte_mtr_meter_policy_get_t meter_policy_get;
216 };
217 
237 static inline int
239  int code,
240  enum rte_mtr_error_type type,
241  const void *cause,
242  const char *message)
243 {
244  if (error) {
245  *error = (struct rte_mtr_error){
246  .type = type,
247  .cause = cause,
248  .message = message,
249  };
250  }
251  rte_errno = code;
252  return code;
253 }
254 
267 const struct rte_mtr_ops *
268 rte_mtr_ops_get(uint16_t port_id, struct rte_mtr_error *error);
269 
270 #ifdef __cplusplus
271 }
272 #endif
273 
274 #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:35
const struct rte_mtr_ops * rte_mtr_ops_get(uint16_t port_id, struct rte_mtr_error *error)