4 * Copyright(c) 2017 Intel Corporation. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
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
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.
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.
34 #ifndef __INCLUDE_RTE_MTR_DRIVER_H__
35 #define __INCLUDE_RTE_MTR_DRIVER_H__
39 * RTE Generic Traffic Metering and Policing API (Driver Side)
41 * This file provides implementation helpers for internal use by PMDs, they
42 * are not intended to be exposed to applications and are not subject to ABI
48 #include <rte_errno.h>
49 #include "rte_ethdev.h"
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);
59 /**< @internal MTR capabilities get */
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);
65 /**< @internal MTR meter profile add */
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);
70 /**< @internal MTR meter profile delete */
72 typedef int (*rte_mtr_create_t)(struct rte_eth_dev *dev,
74 struct rte_mtr_params *params,
76 struct rte_mtr_error *error);
77 /**< @internal MTR object create */
79 typedef int (*rte_mtr_destroy_t)(struct rte_eth_dev *dev,
81 struct rte_mtr_error *error);
82 /**< @internal MTR object destroy */
84 typedef int (*rte_mtr_meter_enable_t)(struct rte_eth_dev *dev,
86 struct rte_mtr_error *error);
87 /**< @internal MTR object meter enable */
89 typedef int (*rte_mtr_meter_disable_t)(struct rte_eth_dev *dev,
91 struct rte_mtr_error *error);
92 /**< @internal MTR object meter disable */
94 typedef int (*rte_mtr_meter_profile_update_t)(struct rte_eth_dev *dev,
96 uint32_t meter_profile_id,
97 struct rte_mtr_error *error);
98 /**< @internal MTR object meter profile update */
100 typedef int (*rte_mtr_meter_dscp_table_update_t)(struct rte_eth_dev *dev,
102 enum rte_mtr_color *dscp_table,
103 struct rte_mtr_error *error);
104 /**< @internal MTR object meter DSCP table update */
106 typedef int (*rte_mtr_policer_actions_update_t)(struct rte_eth_dev *dev,
108 uint32_t action_mask,
109 enum rte_mtr_policer_action *actions,
110 struct rte_mtr_error *error);
111 /**< @internal MTR object policer action update*/
113 typedef int (*rte_mtr_stats_update_t)(struct rte_eth_dev *dev,
116 struct rte_mtr_error *error);
117 /**< @internal MTR object enabled stats update */
119 typedef int (*rte_mtr_stats_read_t)(struct rte_eth_dev *dev,
121 struct rte_mtr_stats *stats,
122 uint64_t *stats_mask,
124 struct rte_mtr_error *error);
125 /**< @internal MTR object stats read */
128 /** MTR capabilities get */
129 rte_mtr_capabilities_get_t capabilities_get;
131 /** MTR meter profile add */
132 rte_mtr_meter_profile_add_t meter_profile_add;
134 /** MTR meter profile delete */
135 rte_mtr_meter_profile_delete_t meter_profile_delete;
137 /** MTR object create */
138 rte_mtr_create_t create;
140 /** MTR object destroy */
141 rte_mtr_destroy_t destroy;
143 /** MTR object meter enable */
144 rte_mtr_meter_enable_t meter_enable;
146 /** MTR object meter disable */
147 rte_mtr_meter_disable_t meter_disable;
149 /** MTR object meter profile update */
150 rte_mtr_meter_profile_update_t meter_profile_update;
152 /** MTR object meter DSCP table update */
153 rte_mtr_meter_dscp_table_update_t meter_dscp_table_update;
155 /** MTR object policer action update */
156 rte_mtr_policer_actions_update_t policer_actions_update;
158 /** MTR object enabled stats update */
159 rte_mtr_stats_update_t stats_update;
161 /** MTR object stats read */
162 rte_mtr_stats_read_t stats_read;
166 * Initialize generic error structure.
168 * This function also sets rte_errno to a given value.
171 * Pointer to error structure (may be NULL).
173 * Related error code (rte_errno).
175 * Cause field and error type.
177 * Object responsible for the error.
179 * Human-readable error message.
185 rte_mtr_error_set(struct rte_mtr_error *error,
187 enum rte_mtr_error_type type,
192 *error = (struct rte_mtr_error){
203 * Get generic traffic metering and policing operations structure from a port
206 * The port identifier of the Ethernet device.
211 * The traffic metering and policing operations structure associated with
212 * port_id on success, NULL otherwise.
214 const struct rte_mtr_ops *
215 rte_mtr_ops_get(uint16_t port_id, struct rte_mtr_error *error);
221 #endif /* __INCLUDE_RTE_MTR_DRIVER_H__ */