DPDK  18.11.11
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 "rte_mtr.h"
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 typedef int (*rte_mtr_capabilities_get_t)(struct rte_eth_dev *dev,
28  struct rte_mtr_capabilities *cap,
29  struct rte_mtr_error *error);
32 typedef int (*rte_mtr_meter_profile_add_t)(struct rte_eth_dev *dev,
33  uint32_t meter_profile_id,
34  struct rte_mtr_meter_profile *profile,
35  struct rte_mtr_error *error);
38 typedef int (*rte_mtr_meter_profile_delete_t)(struct rte_eth_dev *dev,
39  uint32_t meter_profile_id,
40  struct rte_mtr_error *error);
43 typedef int (*rte_mtr_create_t)(struct rte_eth_dev *dev,
44  uint32_t mtr_id,
45  struct rte_mtr_params *params,
46  int shared,
47  struct rte_mtr_error *error);
50 typedef int (*rte_mtr_destroy_t)(struct rte_eth_dev *dev,
51  uint32_t mtr_id,
52  struct rte_mtr_error *error);
55 typedef int (*rte_mtr_meter_enable_t)(struct rte_eth_dev *dev,
56  uint32_t mtr_id,
57  struct rte_mtr_error *error);
60 typedef int (*rte_mtr_meter_disable_t)(struct rte_eth_dev *dev,
61  uint32_t mtr_id,
62  struct rte_mtr_error *error);
65 typedef int (*rte_mtr_meter_profile_update_t)(struct rte_eth_dev *dev,
66  uint32_t mtr_id,
67  uint32_t meter_profile_id,
68  struct rte_mtr_error *error);
71 typedef int (*rte_mtr_meter_dscp_table_update_t)(struct rte_eth_dev *dev,
72  uint32_t mtr_id,
73  enum rte_mtr_color *dscp_table,
74  struct rte_mtr_error *error);
77 typedef int (*rte_mtr_policer_actions_update_t)(struct rte_eth_dev *dev,
78  uint32_t mtr_id,
79  uint32_t action_mask,
80  enum rte_mtr_policer_action *actions,
81  struct rte_mtr_error *error);
84 typedef int (*rte_mtr_stats_update_t)(struct rte_eth_dev *dev,
85  uint32_t mtr_id,
86  uint64_t stats_mask,
87  struct rte_mtr_error *error);
90 typedef int (*rte_mtr_stats_read_t)(struct rte_eth_dev *dev,
91  uint32_t mtr_id,
92  struct rte_mtr_stats *stats,
93  uint64_t *stats_mask,
94  int clear,
95  struct rte_mtr_error *error);
98 struct rte_mtr_ops {
100  rte_mtr_capabilities_get_t capabilities_get;
101 
103  rte_mtr_meter_profile_add_t meter_profile_add;
104 
106  rte_mtr_meter_profile_delete_t meter_profile_delete;
107 
109  rte_mtr_create_t create;
110 
112  rte_mtr_destroy_t destroy;
113 
115  rte_mtr_meter_enable_t meter_enable;
116 
118  rte_mtr_meter_disable_t meter_disable;
119 
121  rte_mtr_meter_profile_update_t meter_profile_update;
122 
124  rte_mtr_meter_dscp_table_update_t meter_dscp_table_update;
125 
127  rte_mtr_policer_actions_update_t policer_actions_update;
128 
130  rte_mtr_stats_update_t stats_update;
131 
133  rte_mtr_stats_read_t stats_read;
134 };
135 
155 static inline int
157  int code,
158  enum rte_mtr_error_type type,
159  const void *cause,
160  const char *message)
161 {
162  if (error) {
163  *error = (struct rte_mtr_error){
164  .type = type,
165  .cause = cause,
166  .message = message,
167  };
168  }
169  rte_errno = code;
170  return code;
171 }
172 
185 const struct rte_mtr_ops *
186 rte_mtr_ops_get(uint16_t port_id, struct rte_mtr_error *error);
187 
188 #ifdef __cplusplus
189 }
190 #endif
191 
192 #endif /* __INCLUDE_RTE_MTR_DRIVER_H__ */
rte_mtr_policer_action
Definition: rte_mtr.h:217
rte_mtr_error_type
Definition: rte_mtr.h:406
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:433
const char * message
Definition: rte_mtr.h:435
rte_mtr_color
Definition: rte_mtr.h:87
const void * cause
Definition: rte_mtr.h:434
const struct rte_mtr_ops * rte_mtr_ops_get(uint16_t port_id, struct rte_mtr_error *error)