DPDK  21.02.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_create_t)(struct rte_eth_dev *dev,
45  uint32_t mtr_id,
46  struct rte_mtr_params *params,
47  int shared,
48  struct rte_mtr_error *error);
51 typedef int (*rte_mtr_destroy_t)(struct rte_eth_dev *dev,
52  uint32_t mtr_id,
53  struct rte_mtr_error *error);
56 typedef int (*rte_mtr_meter_enable_t)(struct rte_eth_dev *dev,
57  uint32_t mtr_id,
58  struct rte_mtr_error *error);
61 typedef int (*rte_mtr_meter_disable_t)(struct rte_eth_dev *dev,
62  uint32_t mtr_id,
63  struct rte_mtr_error *error);
66 typedef int (*rte_mtr_meter_profile_update_t)(struct rte_eth_dev *dev,
67  uint32_t mtr_id,
68  uint32_t meter_profile_id,
69  struct rte_mtr_error *error);
72 typedef int (*rte_mtr_meter_dscp_table_update_t)(struct rte_eth_dev *dev,
73  uint32_t mtr_id,
74  enum rte_color *dscp_table,
75  struct rte_mtr_error *error);
78 typedef int (*rte_mtr_policer_actions_update_t)(struct rte_eth_dev *dev,
79  uint32_t mtr_id,
80  uint32_t action_mask,
81  enum rte_mtr_policer_action *actions,
82  struct rte_mtr_error *error);
85 typedef int (*rte_mtr_stats_update_t)(struct rte_eth_dev *dev,
86  uint32_t mtr_id,
87  uint64_t stats_mask,
88  struct rte_mtr_error *error);
91 typedef int (*rte_mtr_stats_read_t)(struct rte_eth_dev *dev,
92  uint32_t mtr_id,
93  struct rte_mtr_stats *stats,
94  uint64_t *stats_mask,
95  int clear,
96  struct rte_mtr_error *error);
99 struct rte_mtr_ops {
101  rte_mtr_capabilities_get_t capabilities_get;
102 
104  rte_mtr_meter_profile_add_t meter_profile_add;
105 
107  rte_mtr_meter_profile_delete_t meter_profile_delete;
108 
110  rte_mtr_create_t create;
111 
113  rte_mtr_destroy_t destroy;
114 
116  rte_mtr_meter_enable_t meter_enable;
117 
119  rte_mtr_meter_disable_t meter_disable;
120 
122  rte_mtr_meter_profile_update_t meter_profile_update;
123 
125  rte_mtr_meter_dscp_table_update_t meter_dscp_table_update;
126 
128  rte_mtr_policer_actions_update_t policer_actions_update;
129 
131  rte_mtr_stats_update_t stats_update;
132 
134  rte_mtr_stats_read_t stats_read;
135 };
136 
156 static inline int
158  int code,
159  enum rte_mtr_error_type type,
160  const void *cause,
161  const char *message)
162 {
163  if (error) {
164  *error = (struct rte_mtr_error){
165  .type = type,
166  .cause = cause,
167  .message = message,
168  };
169  }
170  rte_errno = code;
171  return code;
172 }
173 
186 const struct rte_mtr_ops *
187 rte_mtr_ops_get(uint16_t port_id, struct rte_mtr_error *error);
188 
189 #ifdef __cplusplus
190 }
191 #endif
192 
193 #endif /* __INCLUDE_RTE_MTR_DRIVER_H__ */
rte_mtr_policer_action
Definition: rte_mtr.h:180
rte_mtr_error_type
Definition: rte_mtr.h:369
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:396
const char * message
Definition: rte_mtr.h:398
rte_color
Definition: rte_meter.h:36
const void * cause
Definition: rte_mtr.h:397
const struct rte_mtr_ops * rte_mtr_ops_get(uint16_t port_id, struct rte_mtr_error *error)