DPDK  17.11.10
rte_mtr_driver.h
Go to the documentation of this file.
1 /*-
2  * BSD LICENSE
3  *
4  * Copyright(c) 2017 Intel Corporation. All rights reserved.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in
15  * the documentation and/or other materials provided with the
16  * distribution.
17  * * Neither the name of Intel Corporation nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33 
34 #ifndef __INCLUDE_RTE_MTR_DRIVER_H__
35 #define __INCLUDE_RTE_MTR_DRIVER_H__
36 
46 #include <stdint.h>
47 
48 #include <rte_errno.h>
49 #include "rte_ethdev.h"
50 #include "rte_mtr.h"
51 
52 #ifdef __cplusplus
53 extern "C" {
54 #endif
55 
56 typedef int (*rte_mtr_capabilities_get_t)(struct rte_eth_dev *dev,
57  struct rte_mtr_capabilities *cap,
58  struct rte_mtr_error *error);
61 typedef int (*rte_mtr_meter_profile_add_t)(struct rte_eth_dev *dev,
62  uint32_t meter_profile_id,
63  struct rte_mtr_meter_profile *profile,
64  struct rte_mtr_error *error);
67 typedef int (*rte_mtr_meter_profile_delete_t)(struct rte_eth_dev *dev,
68  uint32_t meter_profile_id,
69  struct rte_mtr_error *error);
72 typedef int (*rte_mtr_create_t)(struct rte_eth_dev *dev,
73  uint32_t mtr_id,
74  struct rte_mtr_params *params,
75  int shared,
76  struct rte_mtr_error *error);
79 typedef int (*rte_mtr_destroy_t)(struct rte_eth_dev *dev,
80  uint32_t mtr_id,
81  struct rte_mtr_error *error);
84 typedef int (*rte_mtr_meter_enable_t)(struct rte_eth_dev *dev,
85  uint32_t mtr_id,
86  struct rte_mtr_error *error);
89 typedef int (*rte_mtr_meter_disable_t)(struct rte_eth_dev *dev,
90  uint32_t mtr_id,
91  struct rte_mtr_error *error);
94 typedef int (*rte_mtr_meter_profile_update_t)(struct rte_eth_dev *dev,
95  uint32_t mtr_id,
96  uint32_t meter_profile_id,
97  struct rte_mtr_error *error);
100 typedef int (*rte_mtr_meter_dscp_table_update_t)(struct rte_eth_dev *dev,
101  uint32_t mtr_id,
102  enum rte_mtr_color *dscp_table,
103  struct rte_mtr_error *error);
106 typedef int (*rte_mtr_policer_actions_update_t)(struct rte_eth_dev *dev,
107  uint32_t mtr_id,
108  uint32_t action_mask,
109  enum rte_mtr_policer_action *actions,
110  struct rte_mtr_error *error);
113 typedef int (*rte_mtr_stats_update_t)(struct rte_eth_dev *dev,
114  uint32_t mtr_id,
115  uint64_t stats_mask,
116  struct rte_mtr_error *error);
119 typedef int (*rte_mtr_stats_read_t)(struct rte_eth_dev *dev,
120  uint32_t mtr_id,
121  struct rte_mtr_stats *stats,
122  uint64_t *stats_mask,
123  int clear,
124  struct rte_mtr_error *error);
127 struct rte_mtr_ops {
129  rte_mtr_capabilities_get_t capabilities_get;
130 
132  rte_mtr_meter_profile_add_t meter_profile_add;
133 
135  rte_mtr_meter_profile_delete_t meter_profile_delete;
136 
138  rte_mtr_create_t create;
139 
141  rte_mtr_destroy_t destroy;
142 
144  rte_mtr_meter_enable_t meter_enable;
145 
147  rte_mtr_meter_disable_t meter_disable;
148 
150  rte_mtr_meter_profile_update_t meter_profile_update;
151 
153  rte_mtr_meter_dscp_table_update_t meter_dscp_table_update;
154 
156  rte_mtr_policer_actions_update_t policer_actions_update;
157 
159  rte_mtr_stats_update_t stats_update;
160 
162  rte_mtr_stats_read_t stats_read;
163 };
164 
184 static inline int
186  int code,
187  enum rte_mtr_error_type type,
188  const void *cause,
189  const char *message)
190 {
191  if (error) {
192  *error = (struct rte_mtr_error){
193  .type = type,
194  .cause = cause,
195  .message = message,
196  };
197  }
198  rte_errno = code;
199  return code;
200 }
201 
214 const struct rte_mtr_ops *
215 rte_mtr_ops_get(uint16_t port_id, struct rte_mtr_error *error);
216 
217 #ifdef __cplusplus
218 }
219 #endif
220 
221 #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:58
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)