DPDK  21.08.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 
28 typedef int (*rte_mtr_capabilities_get_t)(struct rte_eth_dev *dev,
29  struct rte_mtr_capabilities *cap,
30  struct rte_mtr_error *error);
33 typedef int (*rte_mtr_meter_profile_add_t)(struct rte_eth_dev *dev,
34  uint32_t meter_profile_id,
35  struct rte_mtr_meter_profile *profile,
36  struct rte_mtr_error *error);
39 typedef int (*rte_mtr_meter_profile_delete_t)(struct rte_eth_dev *dev,
40  uint32_t meter_profile_id,
41  struct rte_mtr_error *error);
44 typedef int (*rte_mtr_meter_policy_validate_t)(struct rte_eth_dev *dev,
45  struct rte_mtr_meter_policy_params *policy,
46  struct rte_mtr_error *error);
49 typedef int (*rte_mtr_meter_policy_add_t)(struct rte_eth_dev *dev,
50  uint32_t policy_id,
51  struct rte_mtr_meter_policy_params *policy,
52  struct rte_mtr_error *error);
55 typedef int (*rte_mtr_meter_policy_delete_t)(struct rte_eth_dev *dev,
56  uint32_t policy_id,
57  struct rte_mtr_error *error);
60 typedef int (*rte_mtr_create_t)(struct rte_eth_dev *dev,
61  uint32_t mtr_id,
62  struct rte_mtr_params *params,
63  int shared,
64  struct rte_mtr_error *error);
67 typedef int (*rte_mtr_destroy_t)(struct rte_eth_dev *dev,
68  uint32_t mtr_id,
69  struct rte_mtr_error *error);
72 typedef int (*rte_mtr_meter_enable_t)(struct rte_eth_dev *dev,
73  uint32_t mtr_id,
74  struct rte_mtr_error *error);
77 typedef int (*rte_mtr_meter_disable_t)(struct rte_eth_dev *dev,
78  uint32_t mtr_id,
79  struct rte_mtr_error *error);
82 typedef int (*rte_mtr_meter_profile_update_t)(struct rte_eth_dev *dev,
83  uint32_t mtr_id,
84  uint32_t meter_profile_id,
85  struct rte_mtr_error *error);
88 typedef int (*rte_mtr_meter_policy_update_t)(struct rte_eth_dev *dev,
89  uint32_t mtr_id,
90  uint32_t meter_policy_id,
91  struct rte_mtr_error *error);
94 typedef int (*rte_mtr_meter_dscp_table_update_t)(struct rte_eth_dev *dev,
95  uint32_t mtr_id,
96  enum rte_color *dscp_table,
97  struct rte_mtr_error *error);
100 typedef int (*rte_mtr_stats_update_t)(struct rte_eth_dev *dev,
101  uint32_t mtr_id,
102  uint64_t stats_mask,
103  struct rte_mtr_error *error);
106 typedef int (*rte_mtr_stats_read_t)(struct rte_eth_dev *dev,
107  uint32_t mtr_id,
108  struct rte_mtr_stats *stats,
109  uint64_t *stats_mask,
110  int clear,
111  struct rte_mtr_error *error);
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)