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"
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);
30 /**< @internal MTR capabilities get */
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);
36 /**< @internal MTR meter profile add */
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);
41 /**< @internal MTR meter profile delete */
43 typedef int (*rte_mtr_create_t)(struct rte_eth_dev *dev,
45 struct rte_mtr_params *params,
47 struct rte_mtr_error *error);
48 /**< @internal MTR object create */
50 typedef int (*rte_mtr_destroy_t)(struct rte_eth_dev *dev,
52 struct rte_mtr_error *error);
53 /**< @internal MTR object destroy */
55 typedef int (*rte_mtr_meter_enable_t)(struct rte_eth_dev *dev,
57 struct rte_mtr_error *error);
58 /**< @internal MTR object meter enable */
60 typedef int (*rte_mtr_meter_disable_t)(struct rte_eth_dev *dev,
62 struct rte_mtr_error *error);
63 /**< @internal MTR object meter disable */
65 typedef int (*rte_mtr_meter_profile_update_t)(struct rte_eth_dev *dev,
67 uint32_t meter_profile_id,
68 struct rte_mtr_error *error);
69 /**< @internal MTR object meter profile update */
71 typedef int (*rte_mtr_meter_dscp_table_update_t)(struct rte_eth_dev *dev,
73 enum rte_mtr_color *dscp_table,
74 struct rte_mtr_error *error);
75 /**< @internal MTR object meter DSCP table update */
77 typedef int (*rte_mtr_policer_actions_update_t)(struct rte_eth_dev *dev,
80 enum rte_mtr_policer_action *actions,
81 struct rte_mtr_error *error);
82 /**< @internal MTR object policer action update*/
84 typedef int (*rte_mtr_stats_update_t)(struct rte_eth_dev *dev,
87 struct rte_mtr_error *error);
88 /**< @internal MTR object enabled stats update */
90 typedef int (*rte_mtr_stats_read_t)(struct rte_eth_dev *dev,
92 struct rte_mtr_stats *stats,
95 struct rte_mtr_error *error);
96 /**< @internal MTR object stats read */
99 /** MTR capabilities get */
100 rte_mtr_capabilities_get_t capabilities_get;
102 /** MTR meter profile add */
103 rte_mtr_meter_profile_add_t meter_profile_add;
105 /** MTR meter profile delete */
106 rte_mtr_meter_profile_delete_t meter_profile_delete;
108 /** MTR object create */
109 rte_mtr_create_t create;
111 /** MTR object destroy */
112 rte_mtr_destroy_t destroy;
114 /** MTR object meter enable */
115 rte_mtr_meter_enable_t meter_enable;
117 /** MTR object meter disable */
118 rte_mtr_meter_disable_t meter_disable;
120 /** MTR object meter profile update */
121 rte_mtr_meter_profile_update_t meter_profile_update;
123 /** MTR object meter DSCP table update */
124 rte_mtr_meter_dscp_table_update_t meter_dscp_table_update;
126 /** MTR object policer action update */
127 rte_mtr_policer_actions_update_t policer_actions_update;
129 /** MTR object enabled stats update */
130 rte_mtr_stats_update_t stats_update;
132 /** MTR object stats read */
133 rte_mtr_stats_read_t stats_read;
137 * Initialize generic error structure.
139 * This function also sets rte_errno to a given value.
142 * Pointer to error structure (may be NULL).
144 * Related error code (rte_errno).
146 * Cause field and error type.
148 * Object responsible for the error.
150 * Human-readable error message.
156 rte_mtr_error_set(struct rte_mtr_error *error,
158 enum rte_mtr_error_type type,
163 *error = (struct rte_mtr_error){
174 * Get generic traffic metering and policing operations structure from a port
177 * The port identifier of the Ethernet device.
182 * The traffic metering and policing operations structure associated with
183 * port_id on success, NULL otherwise.
185 const struct rte_mtr_ops *
186 rte_mtr_ops_get(uint16_t port_id, struct rte_mtr_error *error);
192 #endif /* __INCLUDE_RTE_MTR_DRIVER_H__ */