DPDK  22.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 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_stats_update_t)(struct rte_eth_dev *dev,
102  uint32_t mtr_id,
103  uint64_t stats_mask,
104  struct rte_mtr_error *error);
105 
107 typedef int (*rte_mtr_stats_read_t)(struct rte_eth_dev *dev,
108  uint32_t mtr_id,
109  struct rte_mtr_stats *stats,
110  uint64_t *stats_mask,
111  int clear,
112  struct rte_mtr_error *error);
113 
114 struct rte_mtr_ops {
116  rte_mtr_capabilities_get_t capabilities_get;
117 
119  rte_mtr_meter_profile_add_t meter_profile_add;
120 
122  rte_mtr_meter_profile_delete_t meter_profile_delete;
123 
125  rte_mtr_create_t create;
126 
128  rte_mtr_destroy_t destroy;
129 
131  rte_mtr_meter_enable_t meter_enable;
132 
134  rte_mtr_meter_disable_t meter_disable;
135 
137  rte_mtr_meter_profile_update_t meter_profile_update;
138 
140  rte_mtr_meter_dscp_table_update_t meter_dscp_table_update;
141 
143  rte_mtr_stats_update_t stats_update;
144 
146  rte_mtr_stats_read_t stats_read;
147 
149  rte_mtr_meter_policy_validate_t meter_policy_validate;
150 
152  rte_mtr_meter_policy_add_t meter_policy_add;
153 
155  rte_mtr_meter_policy_delete_t meter_policy_delete;
156 
158  rte_mtr_meter_policy_update_t meter_policy_update;
159 };
160 
180 static inline int
182  int code,
183  enum rte_mtr_error_type type,
184  const void *cause,
185  const char *message)
186 {
187  if (error) {
188  *error = (struct rte_mtr_error){
189  .type = type,
190  .cause = cause,
191  .message = message,
192  };
193  }
194  rte_errno = code;
195  return code;
196 }
197 
210 const struct rte_mtr_ops *
211 rte_mtr_ops_get(uint16_t port_id, struct rte_mtr_error *error);
212 
213 #ifdef __cplusplus
214 }
215 #endif
216 
217 #endif /* __INCLUDE_RTE_MTR_DRIVER_H__ */
rte_mtr_error_type
Definition: rte_mtr.h:428
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:458
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)