1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2017 Intel Corporation
5 #ifndef __INCLUDE_RTE_MTR_DRIVER_H__
6 #define __INCLUDE_RTE_MTR_DRIVER_H__
10 * RTE Generic Traffic Metering and Policing API (Driver Side)
12 * This file provides implementation helpers for internal use by PMDs, they
13 * are not intended to be exposed to applications and are not subject to ABI
19 #include <rte_errno.h>
20 #include "rte_ethdev.h"
21 #include "ethdev_driver.h"
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);
31 /**< @internal MTR capabilities get */
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);
37 /**< @internal MTR meter profile add */
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);
42 /**< @internal MTR meter profile delete */
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);
47 /**< @internal MTR meter policy validate */
49 typedef int (*rte_mtr_meter_policy_add_t)(struct rte_eth_dev *dev,
51 struct rte_mtr_meter_policy_params *policy,
52 struct rte_mtr_error *error);
53 /**< @internal MTR meter policy add */
55 typedef int (*rte_mtr_meter_policy_delete_t)(struct rte_eth_dev *dev,
57 struct rte_mtr_error *error);
58 /**< @internal MTR meter policy delete */
60 typedef int (*rte_mtr_create_t)(struct rte_eth_dev *dev,
62 struct rte_mtr_params *params,
64 struct rte_mtr_error *error);
65 /**< @internal MTR object create */
67 typedef int (*rte_mtr_destroy_t)(struct rte_eth_dev *dev,
69 struct rte_mtr_error *error);
70 /**< @internal MTR object destroy */
72 typedef int (*rte_mtr_meter_enable_t)(struct rte_eth_dev *dev,
74 struct rte_mtr_error *error);
75 /**< @internal MTR object meter enable */
77 typedef int (*rte_mtr_meter_disable_t)(struct rte_eth_dev *dev,
79 struct rte_mtr_error *error);
80 /**< @internal MTR object meter disable */
82 typedef int (*rte_mtr_meter_profile_update_t)(struct rte_eth_dev *dev,
84 uint32_t meter_profile_id,
85 struct rte_mtr_error *error);
86 /**< @internal MTR object meter profile update */
88 typedef int (*rte_mtr_meter_policy_update_t)(struct rte_eth_dev *dev,
90 uint32_t meter_policy_id,
91 struct rte_mtr_error *error);
92 /**< @internal MTR object meter policy update */
94 typedef int (*rte_mtr_meter_dscp_table_update_t)(struct rte_eth_dev *dev,
96 enum rte_color *dscp_table,
97 struct rte_mtr_error *error);
98 /**< @internal MTR object meter DSCP table update */
100 typedef int (*rte_mtr_stats_update_t)(struct rte_eth_dev *dev,
103 struct rte_mtr_error *error);
104 /**< @internal MTR object enabled stats update */
106 typedef int (*rte_mtr_stats_read_t)(struct rte_eth_dev *dev,
108 struct rte_mtr_stats *stats,
109 uint64_t *stats_mask,
111 struct rte_mtr_error *error);
112 /**< @internal MTR object stats read */
115 /** MTR capabilities get */
116 rte_mtr_capabilities_get_t capabilities_get;
118 /** MTR meter profile add */
119 rte_mtr_meter_profile_add_t meter_profile_add;
121 /** MTR meter profile delete */
122 rte_mtr_meter_profile_delete_t meter_profile_delete;
124 /** MTR object create */
125 rte_mtr_create_t create;
127 /** MTR object destroy */
128 rte_mtr_destroy_t destroy;
130 /** MTR object meter enable */
131 rte_mtr_meter_enable_t meter_enable;
133 /** MTR object meter disable */
134 rte_mtr_meter_disable_t meter_disable;
136 /** MTR object meter profile update */
137 rte_mtr_meter_profile_update_t meter_profile_update;
139 /** MTR object meter DSCP table update */
140 rte_mtr_meter_dscp_table_update_t meter_dscp_table_update;
142 /** MTR object enabled stats update */
143 rte_mtr_stats_update_t stats_update;
145 /** MTR object stats read */
146 rte_mtr_stats_read_t stats_read;
148 /** MTR meter policy validate */
149 rte_mtr_meter_policy_validate_t meter_policy_validate;
151 /** MTR meter policy add */
152 rte_mtr_meter_policy_add_t meter_policy_add;
154 /** MTR meter policy delete */
155 rte_mtr_meter_policy_delete_t meter_policy_delete;
157 /** MTR object meter policy update */
158 rte_mtr_meter_policy_update_t meter_policy_update;
162 * Initialize generic error structure.
164 * This function also sets rte_errno to a given value.
167 * Pointer to error structure (may be NULL).
169 * Related error code (rte_errno).
171 * Cause field and error type.
173 * Object responsible for the error.
175 * Human-readable error message.
181 rte_mtr_error_set(struct rte_mtr_error *error,
183 enum rte_mtr_error_type type,
188 *error = (struct rte_mtr_error){
199 * Get generic traffic metering and policing operations structure from a port
202 * The port identifier of the Ethernet device.
207 * The traffic metering and policing operations structure associated with
208 * port_id on success, NULL otherwise.
210 const struct rte_mtr_ops *
211 rte_mtr_ops_get(uint16_t port_id, struct rte_mtr_error *error);
217 #endif /* __INCLUDE_RTE_MTR_DRIVER_H__ */