199a2dd95SBruce Richardson /* SPDX-License-Identifier: BSD-3-Clause 299a2dd95SBruce Richardson * Copyright 2017 Intel Corporation 399a2dd95SBruce Richardson * Copyright 2017 NXP 499a2dd95SBruce Richardson * Copyright 2017 Cavium 599a2dd95SBruce Richardson */ 699a2dd95SBruce Richardson 799a2dd95SBruce Richardson #ifndef __INCLUDE_RTE_MTR_H__ 899a2dd95SBruce Richardson #define __INCLUDE_RTE_MTR_H__ 999a2dd95SBruce Richardson 1099a2dd95SBruce Richardson /** 1199a2dd95SBruce Richardson * @file 1299a2dd95SBruce Richardson * RTE Generic Traffic Metering and Policing API 1399a2dd95SBruce Richardson * 1499a2dd95SBruce Richardson * This interface provides the ability to configure the traffic metering and 1599a2dd95SBruce Richardson * policing (MTR) in a generic way. 1699a2dd95SBruce Richardson * 1799a2dd95SBruce Richardson * The processing done for each input packet hitting a MTR object is: 1899a2dd95SBruce Richardson * A) Traffic metering: The packet is assigned a color (the meter output 1999a2dd95SBruce Richardson * color), based on the previous history of the flow reflected in the 2099a2dd95SBruce Richardson * current state of the MTR object, according to the specific traffic 2199a2dd95SBruce Richardson * metering algorithm. The traffic metering algorithm can typically work 2299a2dd95SBruce Richardson * in color aware mode, in which case the input packet already has an 2399a2dd95SBruce Richardson * initial color (the input color), or in color blind mode, which is 2499a2dd95SBruce Richardson * equivalent to considering all input packets initially colored as green. 2599a2dd95SBruce Richardson * B) Policing: There is a separate policer action configured for each meter 2699a2dd95SBruce Richardson * output color, which can: 2799a2dd95SBruce Richardson * a) Drop the packet. 2899a2dd95SBruce Richardson * b) Keep the same packet color: the policer output color matches the 2999a2dd95SBruce Richardson * meter output color (essentially a no-op action). 3099a2dd95SBruce Richardson * c) Recolor the packet: the policer output color is different than 3199a2dd95SBruce Richardson * the meter output color. 3299a2dd95SBruce Richardson * The policer output color is the output color of the packet, which is 3399a2dd95SBruce Richardson * set in the packet meta-data (i.e. struct rte_mbuf::sched::color). 3499a2dd95SBruce Richardson * C) Statistics: The set of counters maintained for each MTR object is 3599a2dd95SBruce Richardson * configurable and subject to the implementation support. This set 3699a2dd95SBruce Richardson * includes the number of packets and bytes dropped or passed for each 3799a2dd95SBruce Richardson * output color. 3899a2dd95SBruce Richardson * 3999a2dd95SBruce Richardson * Once successfully created, an MTR object is linked to one or several flows 4099a2dd95SBruce Richardson * through the meter action of the flow API. 4199a2dd95SBruce Richardson * A) Whether an MTR object is private to a flow or potentially shared by 4299a2dd95SBruce Richardson * several flows has to be specified at creation time. 4399a2dd95SBruce Richardson * B) Several meter actions can be potentially registered for the same flow. 4499a2dd95SBruce Richardson * 4599a2dd95SBruce Richardson * @warning 4699a2dd95SBruce Richardson * @b EXPERIMENTAL: this API may change without prior notice 4799a2dd95SBruce Richardson */ 4899a2dd95SBruce Richardson #include <stdint.h> 4999a2dd95SBruce Richardson #include <rte_compat.h> 5099a2dd95SBruce Richardson #include <rte_common.h> 5199a2dd95SBruce Richardson #include <rte_meter.h> 525f0d54f3SLi Zhang #include <rte_flow.h> 5399a2dd95SBruce Richardson 5499a2dd95SBruce Richardson #ifdef __cplusplus 5599a2dd95SBruce Richardson extern "C" { 5699a2dd95SBruce Richardson #endif 5799a2dd95SBruce Richardson 5899a2dd95SBruce Richardson /** 5999a2dd95SBruce Richardson * Statistics counter type 6099a2dd95SBruce Richardson */ 6199a2dd95SBruce Richardson enum rte_mtr_stats_type { 6299a2dd95SBruce Richardson /** Number of packets passed as green by the policer. */ 6399a2dd95SBruce Richardson RTE_MTR_STATS_N_PKTS_GREEN = 1 << 0, 6499a2dd95SBruce Richardson 6599a2dd95SBruce Richardson /** Number of packets passed as yellow by the policer. */ 6699a2dd95SBruce Richardson RTE_MTR_STATS_N_PKTS_YELLOW = 1 << 1, 6799a2dd95SBruce Richardson 6899a2dd95SBruce Richardson /** Number of packets passed as red by the policer. */ 6999a2dd95SBruce Richardson RTE_MTR_STATS_N_PKTS_RED = 1 << 2, 7099a2dd95SBruce Richardson 7199a2dd95SBruce Richardson /** Number of packets dropped by the policer. */ 7299a2dd95SBruce Richardson RTE_MTR_STATS_N_PKTS_DROPPED = 1 << 3, 7399a2dd95SBruce Richardson 7499a2dd95SBruce Richardson /** Number of bytes passed as green by the policer. */ 7599a2dd95SBruce Richardson RTE_MTR_STATS_N_BYTES_GREEN = 1 << 4, 7699a2dd95SBruce Richardson 7799a2dd95SBruce Richardson /** Number of bytes passed as yellow by the policer. */ 7899a2dd95SBruce Richardson RTE_MTR_STATS_N_BYTES_YELLOW = 1 << 5, 7999a2dd95SBruce Richardson 8099a2dd95SBruce Richardson /** Number of bytes passed as red by the policer. */ 8199a2dd95SBruce Richardson RTE_MTR_STATS_N_BYTES_RED = 1 << 6, 8299a2dd95SBruce Richardson 8399a2dd95SBruce Richardson /** Number of bytes dropped by the policer. */ 8499a2dd95SBruce Richardson RTE_MTR_STATS_N_BYTES_DROPPED = 1 << 7, 8599a2dd95SBruce Richardson }; 8699a2dd95SBruce Richardson 8799a2dd95SBruce Richardson /** 8899a2dd95SBruce Richardson * Statistics counters 8999a2dd95SBruce Richardson */ 9099a2dd95SBruce Richardson struct rte_mtr_stats { 9199a2dd95SBruce Richardson /** Number of packets passed by the policer (per color). */ 9299a2dd95SBruce Richardson uint64_t n_pkts[RTE_COLORS]; 9399a2dd95SBruce Richardson 9499a2dd95SBruce Richardson /** Number of bytes passed by the policer (per color). */ 9599a2dd95SBruce Richardson uint64_t n_bytes[RTE_COLORS]; 9699a2dd95SBruce Richardson 9799a2dd95SBruce Richardson /** Number of packets dropped by the policer. */ 9899a2dd95SBruce Richardson uint64_t n_pkts_dropped; 9999a2dd95SBruce Richardson 10099a2dd95SBruce Richardson /** Number of bytes passed by the policer. */ 10199a2dd95SBruce Richardson uint64_t n_bytes_dropped; 10299a2dd95SBruce Richardson }; 10399a2dd95SBruce Richardson 10499a2dd95SBruce Richardson /** 10599a2dd95SBruce Richardson * Traffic metering algorithms 10699a2dd95SBruce Richardson */ 10799a2dd95SBruce Richardson enum rte_mtr_algorithm { 10899a2dd95SBruce Richardson /** No traffic metering performed, the output color is the same as the 10999a2dd95SBruce Richardson * input color for every input packet. The meter of the MTR object is 11099a2dd95SBruce Richardson * working in pass-through mode, having same effect as meter disable. 11199a2dd95SBruce Richardson * @see rte_mtr_meter_disable() 11299a2dd95SBruce Richardson */ 11399a2dd95SBruce Richardson RTE_MTR_NONE = 0, 11499a2dd95SBruce Richardson 11599a2dd95SBruce Richardson /** Single Rate Three Color Marker (srTCM) - IETF RFC 2697. */ 11699a2dd95SBruce Richardson RTE_MTR_SRTCM_RFC2697, 11799a2dd95SBruce Richardson 11899a2dd95SBruce Richardson /** Two Rate Three Color Marker (trTCM) - IETF RFC 2698. */ 11999a2dd95SBruce Richardson RTE_MTR_TRTCM_RFC2698, 12099a2dd95SBruce Richardson 12199a2dd95SBruce Richardson /** Two Rate Three Color Marker (trTCM) - IETF RFC 4115. */ 12299a2dd95SBruce Richardson RTE_MTR_TRTCM_RFC4115, 12399a2dd95SBruce Richardson }; 12499a2dd95SBruce Richardson 12599a2dd95SBruce Richardson /** 12699a2dd95SBruce Richardson * Meter profile 12799a2dd95SBruce Richardson */ 12899a2dd95SBruce Richardson struct rte_mtr_meter_profile { 12999a2dd95SBruce Richardson /** Traffic metering algorithm. */ 13099a2dd95SBruce Richardson enum rte_mtr_algorithm alg; 13199a2dd95SBruce Richardson 13299a2dd95SBruce Richardson RTE_STD_C11 13399a2dd95SBruce Richardson union { 13499a2dd95SBruce Richardson /** Items only valid when *alg* is set to srTCM - RFC 2697. */ 13599a2dd95SBruce Richardson struct { 13699a2dd95SBruce Richardson /** 13799a2dd95SBruce Richardson * Committed Information Rate (CIR) 13899a2dd95SBruce Richardson * (bytes per second or packets per second). 13999a2dd95SBruce Richardson */ 14099a2dd95SBruce Richardson uint64_t cir; 14199a2dd95SBruce Richardson 14299a2dd95SBruce Richardson /** Committed Burst Size (CBS) (bytes or packets). */ 14399a2dd95SBruce Richardson uint64_t cbs; 14499a2dd95SBruce Richardson 14599a2dd95SBruce Richardson /** Excess Burst Size (EBS) (bytes or packets). */ 14699a2dd95SBruce Richardson uint64_t ebs; 14799a2dd95SBruce Richardson } srtcm_rfc2697; 14899a2dd95SBruce Richardson 14999a2dd95SBruce Richardson /** Items only valid when *alg* is set to trTCM - RFC 2698. */ 15099a2dd95SBruce Richardson struct { 15199a2dd95SBruce Richardson /** 15299a2dd95SBruce Richardson * Committed Information Rate (CIR) 15399a2dd95SBruce Richardson * (bytes per second or packets per second). 15499a2dd95SBruce Richardson */ 15599a2dd95SBruce Richardson uint64_t cir; 15699a2dd95SBruce Richardson 15799a2dd95SBruce Richardson /** 15899a2dd95SBruce Richardson * Peak Information Rate (PIR) 15999a2dd95SBruce Richardson * (bytes per second or packets per second). 16099a2dd95SBruce Richardson */ 16199a2dd95SBruce Richardson uint64_t pir; 16299a2dd95SBruce Richardson 16399a2dd95SBruce Richardson /** Committed Burst Size (CBS) (bytes or packets). */ 16499a2dd95SBruce Richardson uint64_t cbs; 16599a2dd95SBruce Richardson 16699a2dd95SBruce Richardson /** Peak Burst Size (PBS) (bytes or packets). */ 16799a2dd95SBruce Richardson uint64_t pbs; 16899a2dd95SBruce Richardson } trtcm_rfc2698; 16999a2dd95SBruce Richardson 17099a2dd95SBruce Richardson /** Items only valid when *alg* is set to trTCM - RFC 4115. */ 17199a2dd95SBruce Richardson struct { 17299a2dd95SBruce Richardson /** 17399a2dd95SBruce Richardson * Committed Information Rate (CIR) 17499a2dd95SBruce Richardson * (bytes per second or packets per second). 17599a2dd95SBruce Richardson */ 17699a2dd95SBruce Richardson uint64_t cir; 17799a2dd95SBruce Richardson 17899a2dd95SBruce Richardson /** 17999a2dd95SBruce Richardson * Excess Information Rate (EIR) 18099a2dd95SBruce Richardson * (bytes per second or packets per second). 18199a2dd95SBruce Richardson */ 18299a2dd95SBruce Richardson uint64_t eir; 18399a2dd95SBruce Richardson 18499a2dd95SBruce Richardson /** Committed Burst Size (CBS) (bytes or packets). */ 18599a2dd95SBruce Richardson uint64_t cbs; 18699a2dd95SBruce Richardson 18799a2dd95SBruce Richardson /** Excess Burst Size (EBS) (bytes or packets). */ 18899a2dd95SBruce Richardson uint64_t ebs; 18999a2dd95SBruce Richardson } trtcm_rfc4115; 19099a2dd95SBruce Richardson }; 19199a2dd95SBruce Richardson 19299a2dd95SBruce Richardson /** 19399a2dd95SBruce Richardson * When zero, the byte mode is enabled for the current profile, so the 19499a2dd95SBruce Richardson * *rate* and *size* fields are specified in bytes per second 19599a2dd95SBruce Richardson * and bytes, respectively. 19699a2dd95SBruce Richardson * When non-zero, the packet mode is enabled for the current profile, 19799a2dd95SBruce Richardson * so the *rate* and *size* fields are specified in packets per second 19899a2dd95SBruce Richardson * and packets, respectively. 19999a2dd95SBruce Richardson */ 20099a2dd95SBruce Richardson int packet_mode; 20199a2dd95SBruce Richardson }; 20299a2dd95SBruce Richardson 20399a2dd95SBruce Richardson /** 2045f0d54f3SLi Zhang * Meter policy 20599a2dd95SBruce Richardson */ 2065f0d54f3SLi Zhang struct rte_mtr_meter_policy_params { 2075f0d54f3SLi Zhang /** 2085f0d54f3SLi Zhang * Policy action list per color. 2095f0d54f3SLi Zhang * actions[i] potentially represents a chain of rte_flow actions 2105f0d54f3SLi Zhang * terminated by the END action, exactly as specified by the rte_flow 2115f0d54f3SLi Zhang * API for the flow definition, and not just a single action. 2125f0d54f3SLi Zhang */ 2135f0d54f3SLi Zhang const struct rte_flow_action *actions[RTE_COLORS]; 21499a2dd95SBruce Richardson }; 21599a2dd95SBruce Richardson 21699a2dd95SBruce Richardson /** 21799a2dd95SBruce Richardson * Parameters for each traffic metering & policing object 21899a2dd95SBruce Richardson * 21999a2dd95SBruce Richardson * @see enum rte_mtr_stats_type 22099a2dd95SBruce Richardson */ 22199a2dd95SBruce Richardson struct rte_mtr_params { 222*44f44b80SJerin Jacob /** Meter profile ID. @see rte_mtr_meter_profile_add() */ 22399a2dd95SBruce Richardson uint32_t meter_profile_id; 22499a2dd95SBruce Richardson 22599a2dd95SBruce Richardson /** Meter input color in case of MTR object chaining. When non-zero: if 22699a2dd95SBruce Richardson * a previous MTR object is enabled in the same flow, then the color 22799a2dd95SBruce Richardson * determined by the latest MTR object in the same flow is used as the 22899a2dd95SBruce Richardson * input color by the current MTR object, otherwise the current MTR 22999a2dd95SBruce Richardson * object uses the *dscp_table* to determine the input color. When zero: 23099a2dd95SBruce Richardson * the color determined by any previous MTR object in same flow is 23199a2dd95SBruce Richardson * ignored by the current MTR object, which uses the *dscp_table* to 23299a2dd95SBruce Richardson * determine the input color. 23399a2dd95SBruce Richardson */ 23499a2dd95SBruce Richardson int use_prev_mtr_color; 23599a2dd95SBruce Richardson 23699a2dd95SBruce Richardson /** Meter input color. When non-NULL: it points to a pre-allocated and 23799a2dd95SBruce Richardson * pre-populated table with exactly 64 elements providing the input 23899a2dd95SBruce Richardson * color for each value of the IPv4/IPv6 Differentiated Services Code 23999a2dd95SBruce Richardson * Point (DSCP) input packet field. When NULL: it is equivalent to 24099a2dd95SBruce Richardson * setting this parameter to an all-green populated table (i.e. table 24199a2dd95SBruce Richardson * with all the 64 elements set to green color). The color blind mode 24299a2dd95SBruce Richardson * is configured by setting *use_prev_mtr_color* to 0 and *dscp_table* 24399a2dd95SBruce Richardson * to either NULL or to an all-green populated table. When 24499a2dd95SBruce Richardson * *use_prev_mtr_color* is non-zero value or when *dscp_table* contains 24599a2dd95SBruce Richardson * at least one yellow or red color element, then the color aware mode 24699a2dd95SBruce Richardson * is configured. 24799a2dd95SBruce Richardson */ 24899a2dd95SBruce Richardson enum rte_color *dscp_table; 24999a2dd95SBruce Richardson 25099a2dd95SBruce Richardson /** Non-zero to enable the meter, zero to disable the meter at the time 25199a2dd95SBruce Richardson * of MTR object creation. Ignored when the meter profile indicated by 25299a2dd95SBruce Richardson * *meter_profile_id* is set to NONE. 25399a2dd95SBruce Richardson * @see rte_mtr_meter_disable() 25499a2dd95SBruce Richardson */ 25599a2dd95SBruce Richardson int meter_enable; 25699a2dd95SBruce Richardson 25799a2dd95SBruce Richardson /** Set of stats counters to be enabled. 25899a2dd95SBruce Richardson * @see enum rte_mtr_stats_type 25999a2dd95SBruce Richardson */ 26099a2dd95SBruce Richardson uint64_t stats_mask; 2615f0d54f3SLi Zhang 262*44f44b80SJerin Jacob /** Meter policy ID. @see rte_mtr_meter_policy_add() */ 2635f0d54f3SLi Zhang uint32_t meter_policy_id; 26499a2dd95SBruce Richardson }; 26599a2dd95SBruce Richardson 26699a2dd95SBruce Richardson /** 26799a2dd95SBruce Richardson * MTR capabilities 26899a2dd95SBruce Richardson */ 26999a2dd95SBruce Richardson struct rte_mtr_capabilities { 27099a2dd95SBruce Richardson /** Maximum number of MTR objects. */ 27199a2dd95SBruce Richardson uint32_t n_max; 27299a2dd95SBruce Richardson 27399a2dd95SBruce Richardson /** Maximum number of MTR objects that can be shared by multiple flows. 27499a2dd95SBruce Richardson * The value of zero indicates that shared MTR objects are not 27599a2dd95SBruce Richardson * supported. The maximum value is *n_max*. 27699a2dd95SBruce Richardson */ 27799a2dd95SBruce Richardson uint32_t n_shared_max; 27899a2dd95SBruce Richardson 27999a2dd95SBruce Richardson /** When non-zero, this flag indicates that all the MTR objects that 28099a2dd95SBruce Richardson * cannot be shared by multiple flows have identical capability set. 28199a2dd95SBruce Richardson */ 28299a2dd95SBruce Richardson int identical; 28399a2dd95SBruce Richardson 28499a2dd95SBruce Richardson /** When non-zero, this flag indicates that all the MTR objects that 28599a2dd95SBruce Richardson * can be shared by multiple flows have identical capability set. 28699a2dd95SBruce Richardson */ 28799a2dd95SBruce Richardson int shared_identical; 28899a2dd95SBruce Richardson 28999a2dd95SBruce Richardson /** Maximum number of flows that can share the same MTR object. The 29099a2dd95SBruce Richardson * value of zero is invalid. The value of 1 means that shared MTR 29199a2dd95SBruce Richardson * objects not supported. 29299a2dd95SBruce Richardson */ 29399a2dd95SBruce Richardson uint32_t shared_n_flows_per_mtr_max; 29499a2dd95SBruce Richardson 29599a2dd95SBruce Richardson /** Maximum number of MTR objects that can be part of the same flow. The 29699a2dd95SBruce Richardson * value of zero is invalid. The value of 1 indicates that MTR object 29799a2dd95SBruce Richardson * chaining is not supported. The maximum value is *n_max*. 29899a2dd95SBruce Richardson */ 29999a2dd95SBruce Richardson uint32_t chaining_n_mtrs_per_flow_max; 30099a2dd95SBruce Richardson 30199a2dd95SBruce Richardson /** 30299a2dd95SBruce Richardson * When non-zero, it indicates that the packet color identified by one 30399a2dd95SBruce Richardson * MTR object can be used as the packet input color by any subsequent 30499a2dd95SBruce Richardson * MTR object from the same flow. When zero, it indicates that the color 30599a2dd95SBruce Richardson * determined by one MTR object is always ignored by any subsequent MTR 30699a2dd95SBruce Richardson * object from the same flow. Only valid when MTR chaining is supported, 30799a2dd95SBruce Richardson * i.e. *chaining_n_mtrs_per_flow_max* is greater than 1. When non-zero, 30899a2dd95SBruce Richardson * it also means that the color aware mode is supported by at least one 30999a2dd95SBruce Richardson * metering algorithm. 31099a2dd95SBruce Richardson */ 31199a2dd95SBruce Richardson int chaining_use_prev_mtr_color_supported; 31299a2dd95SBruce Richardson 31399a2dd95SBruce Richardson /** 31499a2dd95SBruce Richardson * When non-zero, it indicates that the packet color identified by one 31599a2dd95SBruce Richardson * MTR object is always used as the packet input color by any subsequent 31699a2dd95SBruce Richardson * MTR object that is part of the same flow. When zero, it indicates 31799a2dd95SBruce Richardson * that whether the color determined by one MTR object is either ignored 31899a2dd95SBruce Richardson * or used as the packet input color by any subsequent MTR object from 31999a2dd95SBruce Richardson * the same flow is individually configurable for each MTR object. Only 32099a2dd95SBruce Richardson * valid when *chaining_use_prev_mtr_color_supported* is non-zero. 32199a2dd95SBruce Richardson */ 32299a2dd95SBruce Richardson int chaining_use_prev_mtr_color_enforced; 32399a2dd95SBruce Richardson 32499a2dd95SBruce Richardson /** Maximum number of MTR objects that can have their meter configured 32599a2dd95SBruce Richardson * to run the srTCM RFC 2697 algorithm. The value of 0 indicates this 32699a2dd95SBruce Richardson * metering algorithm is not supported. The maximum value is *n_max*. 32799a2dd95SBruce Richardson */ 32899a2dd95SBruce Richardson uint32_t meter_srtcm_rfc2697_n_max; 32999a2dd95SBruce Richardson 33099a2dd95SBruce Richardson /** Maximum number of MTR objects that can have their meter configured 33199a2dd95SBruce Richardson * to run the trTCM RFC 2698 algorithm. The value of 0 indicates this 33299a2dd95SBruce Richardson * metering algorithm is not supported. The maximum value is *n_max*. 33399a2dd95SBruce Richardson */ 33499a2dd95SBruce Richardson uint32_t meter_trtcm_rfc2698_n_max; 33599a2dd95SBruce Richardson 33699a2dd95SBruce Richardson /** Maximum number of MTR objects that can have their meter configured 33799a2dd95SBruce Richardson * to run the trTCM RFC 4115 algorithm. The value of 0 indicates this 33899a2dd95SBruce Richardson * metering algorithm is not supported. The maximum value is *n_max*. 33999a2dd95SBruce Richardson */ 34099a2dd95SBruce Richardson uint32_t meter_trtcm_rfc4115_n_max; 34199a2dd95SBruce Richardson 34299a2dd95SBruce Richardson /** Maximum traffic rate that can be metered by a single MTR object. For 34399a2dd95SBruce Richardson * srTCM RFC 2697, this is the maximum CIR rate. For trTCM RFC 2698, 34499a2dd95SBruce Richardson * this is the maximum PIR rate. For trTCM RFC 4115, this is the maximum 34599a2dd95SBruce Richardson * value for the sum of PIR and EIR rates. 34699a2dd95SBruce Richardson */ 34799a2dd95SBruce Richardson uint64_t meter_rate_max; 34899a2dd95SBruce Richardson 34999a2dd95SBruce Richardson /** 3505f0d54f3SLi Zhang * Maximum number of policy objects that can have. 3515f0d54f3SLi Zhang * The value of 0 is invalid. Policy must be supported for meter. 3525f0d54f3SLi Zhang * The maximum value is *n_max*. 3535f0d54f3SLi Zhang */ 3545f0d54f3SLi Zhang uint64_t meter_policy_n_max; 3555f0d54f3SLi Zhang 3565f0d54f3SLi Zhang /** 35799a2dd95SBruce Richardson * When non-zero, it indicates that color aware mode is supported for 35899a2dd95SBruce Richardson * the srTCM RFC 2697 metering algorithm. 35999a2dd95SBruce Richardson */ 36099a2dd95SBruce Richardson int color_aware_srtcm_rfc2697_supported; 36199a2dd95SBruce Richardson 36299a2dd95SBruce Richardson /** 36399a2dd95SBruce Richardson * When non-zero, it indicates that color aware mode is supported for 36499a2dd95SBruce Richardson * the trTCM RFC 2698 metering algorithm. 36599a2dd95SBruce Richardson */ 36699a2dd95SBruce Richardson int color_aware_trtcm_rfc2698_supported; 36799a2dd95SBruce Richardson 36899a2dd95SBruce Richardson /** 36999a2dd95SBruce Richardson * When non-zero, it indicates that color aware mode is supported for 37099a2dd95SBruce Richardson * the trTCM RFC 4115 metering algorithm. 37199a2dd95SBruce Richardson */ 37299a2dd95SBruce Richardson int color_aware_trtcm_rfc4115_supported; 37399a2dd95SBruce Richardson 37499a2dd95SBruce Richardson /** 37599a2dd95SBruce Richardson * srTCM rfc2697 byte mode supported. 37699a2dd95SBruce Richardson * When non-zero, it indicates that byte mode is supported for 37799a2dd95SBruce Richardson * the srTCM RFC 2697 metering algorithm. 37899a2dd95SBruce Richardson */ 37999a2dd95SBruce Richardson int srtcm_rfc2697_byte_mode_supported; 38099a2dd95SBruce Richardson 38199a2dd95SBruce Richardson /** 38299a2dd95SBruce Richardson * srTCM rfc2697 packet mode supported. 38399a2dd95SBruce Richardson * When non-zero, it indicates that packet mode is supported for 38499a2dd95SBruce Richardson * the srTCM RFC 2697 metering algorithm. 38599a2dd95SBruce Richardson */ 38699a2dd95SBruce Richardson int srtcm_rfc2697_packet_mode_supported; 38799a2dd95SBruce Richardson 38899a2dd95SBruce Richardson /** 38999a2dd95SBruce Richardson * trTCM rfc2698 byte mode supported. 39099a2dd95SBruce Richardson * When non-zero, it indicates that byte mode is supported for 39199a2dd95SBruce Richardson * the trTCM RFC 2698 metering algorithm. 39299a2dd95SBruce Richardson */ 39399a2dd95SBruce Richardson int trtcm_rfc2698_byte_mode_supported; 39499a2dd95SBruce Richardson 39599a2dd95SBruce Richardson /** 39699a2dd95SBruce Richardson * trTCM rfc2698 packet mode supported. 39799a2dd95SBruce Richardson * When non-zero, it indicates that packet mode is supported for 39899a2dd95SBruce Richardson * the trTCM RFC 2698 metering algorithm. 39999a2dd95SBruce Richardson */ 40099a2dd95SBruce Richardson int trtcm_rfc2698_packet_mode_supported; 40199a2dd95SBruce Richardson 40299a2dd95SBruce Richardson /** 40399a2dd95SBruce Richardson * trTCM rfc4115 byte mode supported. 40499a2dd95SBruce Richardson * When non-zero, it indicates that byte mode is supported for 40599a2dd95SBruce Richardson * the trTCM RFC 4115 metering algorithm. 40699a2dd95SBruce Richardson */ 40799a2dd95SBruce Richardson int trtcm_rfc4115_byte_mode_supported; 40899a2dd95SBruce Richardson 40999a2dd95SBruce Richardson /** 41099a2dd95SBruce Richardson * trTCM rfc4115 packet mode supported. 41199a2dd95SBruce Richardson * When non-zero, it indicates that packet mode is supported for 41299a2dd95SBruce Richardson * the trTCM RFC 4115 metering algorithm. 41399a2dd95SBruce Richardson */ 41499a2dd95SBruce Richardson int trtcm_rfc4115_packet_mode_supported; 41599a2dd95SBruce Richardson 41699a2dd95SBruce Richardson /** Set of supported statistics counter types. 41799a2dd95SBruce Richardson * @see enum rte_mtr_stats_type 41899a2dd95SBruce Richardson */ 41999a2dd95SBruce Richardson uint64_t stats_mask; 42099a2dd95SBruce Richardson }; 42199a2dd95SBruce Richardson 42299a2dd95SBruce Richardson /** 42399a2dd95SBruce Richardson * Verbose error types. 42499a2dd95SBruce Richardson * 42599a2dd95SBruce Richardson * Most of them provide the type of the object referenced by struct 42699a2dd95SBruce Richardson * rte_mtr_error::cause. 42799a2dd95SBruce Richardson */ 42899a2dd95SBruce Richardson enum rte_mtr_error_type { 42999a2dd95SBruce Richardson RTE_MTR_ERROR_TYPE_NONE, /**< No error. */ 43099a2dd95SBruce Richardson RTE_MTR_ERROR_TYPE_UNSPECIFIED, /**< Cause unspecified. */ 43199a2dd95SBruce Richardson RTE_MTR_ERROR_TYPE_METER_PROFILE_ID, 43299a2dd95SBruce Richardson RTE_MTR_ERROR_TYPE_METER_PROFILE, 43399a2dd95SBruce Richardson RTE_MTR_ERROR_TYPE_METER_PROFILE_PACKET_MODE, 43499a2dd95SBruce Richardson RTE_MTR_ERROR_TYPE_MTR_ID, 43599a2dd95SBruce Richardson RTE_MTR_ERROR_TYPE_MTR_PARAMS, 43699a2dd95SBruce Richardson RTE_MTR_ERROR_TYPE_POLICER_ACTION_GREEN, 43799a2dd95SBruce Richardson RTE_MTR_ERROR_TYPE_POLICER_ACTION_YELLOW, 43899a2dd95SBruce Richardson RTE_MTR_ERROR_TYPE_POLICER_ACTION_RED, 43999a2dd95SBruce Richardson RTE_MTR_ERROR_TYPE_STATS_MASK, 44099a2dd95SBruce Richardson RTE_MTR_ERROR_TYPE_STATS, 44199a2dd95SBruce Richardson RTE_MTR_ERROR_TYPE_SHARED, 4425f0d54f3SLi Zhang RTE_MTR_ERROR_TYPE_METER_POLICY_ID, 4435f0d54f3SLi Zhang RTE_MTR_ERROR_TYPE_METER_POLICY, 44499a2dd95SBruce Richardson }; 44599a2dd95SBruce Richardson 44699a2dd95SBruce Richardson /** 44799a2dd95SBruce Richardson * Verbose error structure definition. 44899a2dd95SBruce Richardson * 44999a2dd95SBruce Richardson * This object is normally allocated by applications and set by PMDs, the 45099a2dd95SBruce Richardson * message points to a constant string which does not need to be freed by 45199a2dd95SBruce Richardson * the application, however its pointer can be considered valid only as long 45299a2dd95SBruce Richardson * as its associated DPDK port remains configured. Closing the underlying 45399a2dd95SBruce Richardson * device or unloading the PMD invalidates it. 45499a2dd95SBruce Richardson * 45599a2dd95SBruce Richardson * Both cause and message may be NULL regardless of the error type. 45699a2dd95SBruce Richardson */ 45799a2dd95SBruce Richardson struct rte_mtr_error { 45899a2dd95SBruce Richardson enum rte_mtr_error_type type; /**< Cause field and error type. */ 45999a2dd95SBruce Richardson const void *cause; /**< Object responsible for the error. */ 46099a2dd95SBruce Richardson const char *message; /**< Human-readable error message. */ 46199a2dd95SBruce Richardson }; 46299a2dd95SBruce Richardson 46399a2dd95SBruce Richardson /** 46499a2dd95SBruce Richardson * MTR capabilities get 46599a2dd95SBruce Richardson * 46699a2dd95SBruce Richardson * @param[in] port_id 46799a2dd95SBruce Richardson * The port identifier of the Ethernet device. 46899a2dd95SBruce Richardson * @param[out] cap 46999a2dd95SBruce Richardson * MTR capabilities. Needs to be pre-allocated and valid. 47099a2dd95SBruce Richardson * @param[out] error 47199a2dd95SBruce Richardson * Error details. Filled in only on error, when not NULL. 47299a2dd95SBruce Richardson * @return 47399a2dd95SBruce Richardson * 0 on success, non-zero error code otherwise. 47499a2dd95SBruce Richardson */ 47599a2dd95SBruce Richardson __rte_experimental 47699a2dd95SBruce Richardson int 47799a2dd95SBruce Richardson rte_mtr_capabilities_get(uint16_t port_id, 47899a2dd95SBruce Richardson struct rte_mtr_capabilities *cap, 47999a2dd95SBruce Richardson struct rte_mtr_error *error); 48099a2dd95SBruce Richardson 48199a2dd95SBruce Richardson /** 48299a2dd95SBruce Richardson * Meter profile add 48399a2dd95SBruce Richardson * 48499a2dd95SBruce Richardson * Create a new meter profile with ID set to *meter_profile_id*. The new profile 48599a2dd95SBruce Richardson * is used to create one or several MTR objects. 48699a2dd95SBruce Richardson * 48799a2dd95SBruce Richardson * @param[in] port_id 48899a2dd95SBruce Richardson * The port identifier of the Ethernet device. 48999a2dd95SBruce Richardson * @param[in] meter_profile_id 49099a2dd95SBruce Richardson * ID for the new meter profile. Needs to be unused by any of the existing 49199a2dd95SBruce Richardson * meter profiles added for the current port. 49299a2dd95SBruce Richardson * @param[in] profile 49399a2dd95SBruce Richardson * Meter profile parameters. Needs to be pre-allocated and valid. 49499a2dd95SBruce Richardson * @param[out] error 49599a2dd95SBruce Richardson * Error details. Filled in only on error, when not NULL. 49699a2dd95SBruce Richardson * @return 49799a2dd95SBruce Richardson * 0 on success, non-zero error code otherwise. 49899a2dd95SBruce Richardson */ 49999a2dd95SBruce Richardson __rte_experimental 50099a2dd95SBruce Richardson int 50199a2dd95SBruce Richardson rte_mtr_meter_profile_add(uint16_t port_id, 50299a2dd95SBruce Richardson uint32_t meter_profile_id, 50399a2dd95SBruce Richardson struct rte_mtr_meter_profile *profile, 50499a2dd95SBruce Richardson struct rte_mtr_error *error); 50599a2dd95SBruce Richardson 50699a2dd95SBruce Richardson /** 50799a2dd95SBruce Richardson * Meter profile delete 50899a2dd95SBruce Richardson * 50999a2dd95SBruce Richardson * Delete an existing meter profile. This operation fails when there is 51099a2dd95SBruce Richardson * currently at least one user (i.e. MTR object) of this profile. 51199a2dd95SBruce Richardson * 51299a2dd95SBruce Richardson * @param[in] port_id 51399a2dd95SBruce Richardson * The port identifier of the Ethernet device. 51499a2dd95SBruce Richardson * @param[in] meter_profile_id 51599a2dd95SBruce Richardson * Meter profile ID. Needs to be the valid. 51699a2dd95SBruce Richardson * @param[out] error 51799a2dd95SBruce Richardson * Error details. Filled in only on error, when not NULL. 51899a2dd95SBruce Richardson * @return 51999a2dd95SBruce Richardson * 0 on success, non-zero error code otherwise. 52099a2dd95SBruce Richardson */ 52199a2dd95SBruce Richardson __rte_experimental 52299a2dd95SBruce Richardson int 52399a2dd95SBruce Richardson rte_mtr_meter_profile_delete(uint16_t port_id, 52499a2dd95SBruce Richardson uint32_t meter_profile_id, 52599a2dd95SBruce Richardson struct rte_mtr_error *error); 52699a2dd95SBruce Richardson 52799a2dd95SBruce Richardson /** 5285f0d54f3SLi Zhang * Check whether a meter policy can be created on a given port. 5295f0d54f3SLi Zhang * 5305f0d54f3SLi Zhang * The meter policy is validated for correctness and 5315f0d54f3SLi Zhang * whether it could be accepted by the device given sufficient resources. 5325f0d54f3SLi Zhang * The policy is checked against the current capability information 5335f0d54f3SLi Zhang * meter_policy_n_max configuration. 5345f0d54f3SLi Zhang * The policy may also optionally be validated against existing 5355f0d54f3SLi Zhang * device policy resources. 5365f0d54f3SLi Zhang * This function has no effect on the target device. 5375f0d54f3SLi Zhang * 5385f0d54f3SLi Zhang * @param[in] port_id 5395f0d54f3SLi Zhang * The port identifier of the Ethernet device. 5405f0d54f3SLi Zhang * @param[in] policy 5415f0d54f3SLi Zhang * Associated action list per color. 5425f0d54f3SLi Zhang * list NULL is legal and means no special action. 5435f0d54f3SLi Zhang * (list terminated by the END action). 5445f0d54f3SLi Zhang * @param[out] error 5455f0d54f3SLi Zhang * Error details. Filled in only on error, when not NULL. 5465f0d54f3SLi Zhang * @return 5475f0d54f3SLi Zhang * 0 on success, non-zero error code otherwise. 5485f0d54f3SLi Zhang */ 5495f0d54f3SLi Zhang __rte_experimental 5505f0d54f3SLi Zhang int 5515f0d54f3SLi Zhang rte_mtr_meter_policy_validate(uint16_t port_id, 5525f0d54f3SLi Zhang struct rte_mtr_meter_policy_params *policy, 5535f0d54f3SLi Zhang struct rte_mtr_error *error); 5545f0d54f3SLi Zhang 5555f0d54f3SLi Zhang /** 5565f0d54f3SLi Zhang * Meter policy add 5575f0d54f3SLi Zhang * 5585f0d54f3SLi Zhang * Create a new meter policy. The new policy 5595f0d54f3SLi Zhang * is used to create single or multiple MTR objects. 5605f0d54f3SLi Zhang * The same policy can be used to create multiple MTR objects. 5615f0d54f3SLi Zhang * 5625f0d54f3SLi Zhang * @param[in] port_id 5635f0d54f3SLi Zhang * The port identifier of the Ethernet device. 5645f0d54f3SLi Zhang * @param[in] policy_id 5655f0d54f3SLi Zhang * Policy identifier for the new meter policy. 5665f0d54f3SLi Zhang * @param[in] policy 5675f0d54f3SLi Zhang * Associated actions per color. 5685f0d54f3SLi Zhang * list NULL is legal and means no special action. 5695f0d54f3SLi Zhang * Non-NULL list must be terminated. 5705f0d54f3SLi Zhang * (list terminated by the END action). 5715f0d54f3SLi Zhang * @param[out] error 5725f0d54f3SLi Zhang * Error details. Filled in only on error, when not NULL. 5735f0d54f3SLi Zhang * @return 5745f0d54f3SLi Zhang * 0 on success, non-zero error code otherwise. 5755f0d54f3SLi Zhang */ 5765f0d54f3SLi Zhang __rte_experimental 5775f0d54f3SLi Zhang int 5785f0d54f3SLi Zhang rte_mtr_meter_policy_add(uint16_t port_id, 5795f0d54f3SLi Zhang uint32_t policy_id, 5805f0d54f3SLi Zhang struct rte_mtr_meter_policy_params *policy, 5815f0d54f3SLi Zhang struct rte_mtr_error *error); 5825f0d54f3SLi Zhang 5835f0d54f3SLi Zhang /** 5845f0d54f3SLi Zhang * Define meter policy action list: 5855f0d54f3SLi Zhang * GREEN - GREEN, YELLOW - YELLOW, RED - RED 5865f0d54f3SLi Zhang */ 5875f0d54f3SLi Zhang #define rte_mtr_policy_pass_color(policy) \ 5885f0d54f3SLi Zhang struct rte_mtr_meter_policy_params policy = \ 5895f0d54f3SLi Zhang { \ 5905f0d54f3SLi Zhang .actions[RTE_COLOR_GREEN] = (struct rte_flow_action[]) { \ 5915f0d54f3SLi Zhang { \ 5925f0d54f3SLi Zhang .type = RTE_FLOW_ACTION_TYPE_METER_COLOR, \ 5935f0d54f3SLi Zhang .conf = &(struct rte_flow_action_meter_color) { \ 5945f0d54f3SLi Zhang .color = RTE_COLOR_GREEN, \ 5955f0d54f3SLi Zhang }, \ 5965f0d54f3SLi Zhang }, \ 5975f0d54f3SLi Zhang { \ 5985f0d54f3SLi Zhang .type = RTE_FLOW_ACTION_TYPE_END, \ 5995f0d54f3SLi Zhang }, \ 6005f0d54f3SLi Zhang }, \ 6015f0d54f3SLi Zhang .actions[RTE_COLOR_YELLOW] = (struct rte_flow_action[]) { \ 6025f0d54f3SLi Zhang { \ 6035f0d54f3SLi Zhang .type = RTE_FLOW_ACTION_TYPE_METER_COLOR, \ 6045f0d54f3SLi Zhang .conf = &(struct rte_flow_action_meter_color) { \ 6055f0d54f3SLi Zhang .color = RTE_COLOR_YELLOW, \ 6065f0d54f3SLi Zhang }, \ 6075f0d54f3SLi Zhang }, \ 6085f0d54f3SLi Zhang { \ 6095f0d54f3SLi Zhang .type = RTE_FLOW_ACTION_TYPE_END, \ 6105f0d54f3SLi Zhang }, \ 6115f0d54f3SLi Zhang }, \ 6125f0d54f3SLi Zhang .actions[RTE_COLOR_RED] = (struct rte_flow_action[]) { \ 6135f0d54f3SLi Zhang { \ 6145f0d54f3SLi Zhang .type = RTE_FLOW_ACTION_TYPE_METER_COLOR, \ 6155f0d54f3SLi Zhang .conf = &(struct rte_flow_action_meter_color) { \ 6165f0d54f3SLi Zhang .color = RTE_COLOR_RED, \ 6175f0d54f3SLi Zhang }, \ 6185f0d54f3SLi Zhang }, \ 6195f0d54f3SLi Zhang { \ 6205f0d54f3SLi Zhang .type = RTE_FLOW_ACTION_TYPE_END, \ 6215f0d54f3SLi Zhang }, \ 6225f0d54f3SLi Zhang }, \ 6235f0d54f3SLi Zhang } 6245f0d54f3SLi Zhang 6255f0d54f3SLi Zhang /** 6265f0d54f3SLi Zhang * Define meter policy action list: 6275f0d54f3SLi Zhang * GREEN - Do nothing, YELLOW - Do nothing, RED - DROP 6285f0d54f3SLi Zhang */ 6295f0d54f3SLi Zhang #define rte_mtr_policy_drop_red(policy) \ 6305f0d54f3SLi Zhang struct rte_mtr_meter_policy_params policy = \ 6315f0d54f3SLi Zhang { \ 6325f0d54f3SLi Zhang .actions[RTE_COLOR_GREEN] = NULL, \ 6335f0d54f3SLi Zhang .actions[RTE_COLOR_YELLOW] = NULL, \ 6345f0d54f3SLi Zhang .actions[RTE_COLOR_RED] = (struct rte_flow_action[]) { \ 6355f0d54f3SLi Zhang { \ 6365f0d54f3SLi Zhang .type = RTE_FLOW_ACTION_TYPE_DROP, \ 6375f0d54f3SLi Zhang }, \ 6385f0d54f3SLi Zhang { \ 6395f0d54f3SLi Zhang .type = RTE_FLOW_ACTION_TYPE_END, \ 6405f0d54f3SLi Zhang }, \ 6415f0d54f3SLi Zhang }, \ 6425f0d54f3SLi Zhang } 6435f0d54f3SLi Zhang 6445f0d54f3SLi Zhang /** 6455f0d54f3SLi Zhang * Meter policy delete 6465f0d54f3SLi Zhang * 6475f0d54f3SLi Zhang * Delete an existing meter policy. This operation fails when there is 6485f0d54f3SLi Zhang * currently at least one user (i.e. MTR object) of this policy. 6495f0d54f3SLi Zhang * 6505f0d54f3SLi Zhang * @param[in] port_id 6515f0d54f3SLi Zhang * The port identifier of the Ethernet device. 6525f0d54f3SLi Zhang * @param[in] policy_id 6535f0d54f3SLi Zhang * Policy identifier. 6545f0d54f3SLi Zhang * @param[out] error 6555f0d54f3SLi Zhang * Error details. Filled in only on error, when not NULL. 6565f0d54f3SLi Zhang * @return 6575f0d54f3SLi Zhang * 0 on success, non-zero error code otherwise. 6585f0d54f3SLi Zhang */ 6595f0d54f3SLi Zhang __rte_experimental 6605f0d54f3SLi Zhang int 6615f0d54f3SLi Zhang rte_mtr_meter_policy_delete(uint16_t port_id, 6625f0d54f3SLi Zhang uint32_t policy_id, 6635f0d54f3SLi Zhang struct rte_mtr_error *error); 6645f0d54f3SLi Zhang 6655f0d54f3SLi Zhang /** 66699a2dd95SBruce Richardson * MTR object create 66799a2dd95SBruce Richardson * 66899a2dd95SBruce Richardson * Create a new MTR object for the current port. This object is run as part of 66999a2dd95SBruce Richardson * associated flow action for traffic metering and policing. 67099a2dd95SBruce Richardson * 67199a2dd95SBruce Richardson * @param[in] port_id 67299a2dd95SBruce Richardson * The port identifier of the Ethernet device. 67399a2dd95SBruce Richardson * @param[in] mtr_id 67499a2dd95SBruce Richardson * MTR object ID. Needs to be unused by any of the existing MTR objects. 67599a2dd95SBruce Richardson * created for the current port. 67699a2dd95SBruce Richardson * @param[in] params 67799a2dd95SBruce Richardson * MTR object params. Needs to be pre-allocated and valid. 67899a2dd95SBruce Richardson * @param[in] shared 67999a2dd95SBruce Richardson * Non-zero when this MTR object can be shared by multiple flows, zero when 68099a2dd95SBruce Richardson * this MTR object can be used by a single flow. 68199a2dd95SBruce Richardson * @param[out] error 68299a2dd95SBruce Richardson * Error details. Filled in only on error, when not NULL. 68399a2dd95SBruce Richardson * @return 68499a2dd95SBruce Richardson * 0 on success, non-zero error code otherwise. 68599a2dd95SBruce Richardson * 68699a2dd95SBruce Richardson * @see enum rte_flow_action_type::RTE_FLOW_ACTION_TYPE_METER 68799a2dd95SBruce Richardson */ 68899a2dd95SBruce Richardson __rte_experimental 68999a2dd95SBruce Richardson int 69099a2dd95SBruce Richardson rte_mtr_create(uint16_t port_id, 69199a2dd95SBruce Richardson uint32_t mtr_id, 69299a2dd95SBruce Richardson struct rte_mtr_params *params, 69399a2dd95SBruce Richardson int shared, 69499a2dd95SBruce Richardson struct rte_mtr_error *error); 69599a2dd95SBruce Richardson 69699a2dd95SBruce Richardson /** 69799a2dd95SBruce Richardson * MTR object destroy 69899a2dd95SBruce Richardson * 69999a2dd95SBruce Richardson * Delete an existing MTR object. This operation fails when there is currently 70099a2dd95SBruce Richardson * at least one user (i.e. flow) of this MTR object. 70199a2dd95SBruce Richardson * 70299a2dd95SBruce Richardson * @param[in] port_id 70399a2dd95SBruce Richardson * The port identifier of the Ethernet device. 70499a2dd95SBruce Richardson * @param[in] mtr_id 70599a2dd95SBruce Richardson * MTR object ID. Needs to be valid. 70699a2dd95SBruce Richardson * created for the current port. 70799a2dd95SBruce Richardson * @param[out] error 70899a2dd95SBruce Richardson * Error details. Filled in only on error, when not NULL. 70999a2dd95SBruce Richardson * @return 71099a2dd95SBruce Richardson * 0 on success, non-zero error code otherwise. 71199a2dd95SBruce Richardson */ 71299a2dd95SBruce Richardson __rte_experimental 71399a2dd95SBruce Richardson int 71499a2dd95SBruce Richardson rte_mtr_destroy(uint16_t port_id, 71599a2dd95SBruce Richardson uint32_t mtr_id, 71699a2dd95SBruce Richardson struct rte_mtr_error *error); 71799a2dd95SBruce Richardson 71899a2dd95SBruce Richardson /** 71999a2dd95SBruce Richardson * MTR object meter disable 72099a2dd95SBruce Richardson * 72199a2dd95SBruce Richardson * Disable the meter of an existing MTR object. In disabled state, the meter of 72299a2dd95SBruce Richardson * the current MTR object works in pass-through mode, meaning that for each 72399a2dd95SBruce Richardson * input packet the meter output color is always the same as the input color. In 72499a2dd95SBruce Richardson * particular, when the meter of the current MTR object is configured in color 72599a2dd95SBruce Richardson * blind mode, the input color is always green, so the meter output color is 72699a2dd95SBruce Richardson * also always green. Note that the policer and the statistics of the current 72799a2dd95SBruce Richardson * MTR object are working as usual while the meter is disabled. No action is 72899a2dd95SBruce Richardson * taken and this function returns successfully when the meter of the current 72999a2dd95SBruce Richardson * MTR object is already disabled. 73099a2dd95SBruce Richardson * 73199a2dd95SBruce Richardson * @param[in] port_id 73299a2dd95SBruce Richardson * The port identifier of the Ethernet device. 73399a2dd95SBruce Richardson * @param[in] mtr_id 73499a2dd95SBruce Richardson * MTR object ID. 73599a2dd95SBruce Richardson * @param[out] error 73699a2dd95SBruce Richardson * Error details. Filled in only on error, when not NULL. 73799a2dd95SBruce Richardson * @return 73899a2dd95SBruce Richardson * 0 on success, non-zero error code otherwise. 73999a2dd95SBruce Richardson */ 74099a2dd95SBruce Richardson __rte_experimental 74199a2dd95SBruce Richardson int 74299a2dd95SBruce Richardson rte_mtr_meter_disable(uint16_t port_id, 74399a2dd95SBruce Richardson uint32_t mtr_id, 74499a2dd95SBruce Richardson struct rte_mtr_error *error); 74599a2dd95SBruce Richardson 74699a2dd95SBruce Richardson /** 74799a2dd95SBruce Richardson * MTR object meter enable 74899a2dd95SBruce Richardson * 74999a2dd95SBruce Richardson * Enable the meter of an existing MTR object. If the MTR object has its meter 75099a2dd95SBruce Richardson * already enabled, then no action is taken and this function returns 75199a2dd95SBruce Richardson * successfully. 75299a2dd95SBruce Richardson * 75399a2dd95SBruce Richardson * @param[in] port_id 75499a2dd95SBruce Richardson * The port identifier of the Ethernet device. 75599a2dd95SBruce Richardson * @param[in] mtr_id 75699a2dd95SBruce Richardson * MTR object ID. 75799a2dd95SBruce Richardson * @param[out] error 75899a2dd95SBruce Richardson * Error details. Filled in only on error, when not NULL. 75999a2dd95SBruce Richardson * @return 76099a2dd95SBruce Richardson * 0 on success, non-zero error code otherwise. 76199a2dd95SBruce Richardson */ 76299a2dd95SBruce Richardson __rte_experimental 76399a2dd95SBruce Richardson int 76499a2dd95SBruce Richardson rte_mtr_meter_enable(uint16_t port_id, 76599a2dd95SBruce Richardson uint32_t mtr_id, 76699a2dd95SBruce Richardson struct rte_mtr_error *error); 76799a2dd95SBruce Richardson 76899a2dd95SBruce Richardson /** 76999a2dd95SBruce Richardson * MTR object meter profile update 77099a2dd95SBruce Richardson * 77199a2dd95SBruce Richardson * @param[in] port_id 77299a2dd95SBruce Richardson * The port identifier of the Ethernet device. 77399a2dd95SBruce Richardson * @param[in] mtr_id 77499a2dd95SBruce Richardson * MTR object ID. Needs to be valid. 77599a2dd95SBruce Richardson * @param[in] meter_profile_id 77699a2dd95SBruce Richardson * Meter profile ID for the current MTR object. Needs to be valid. 77799a2dd95SBruce Richardson * @param[out] error 77899a2dd95SBruce Richardson * Error details. Filled in only on error, when not NULL. 77999a2dd95SBruce Richardson * @return 78099a2dd95SBruce Richardson * 0 on success, non-zero error code otherwise. 78199a2dd95SBruce Richardson */ 78299a2dd95SBruce Richardson __rte_experimental 78399a2dd95SBruce Richardson int 78499a2dd95SBruce Richardson rte_mtr_meter_profile_update(uint16_t port_id, 78599a2dd95SBruce Richardson uint32_t mtr_id, 78699a2dd95SBruce Richardson uint32_t meter_profile_id, 78799a2dd95SBruce Richardson struct rte_mtr_error *error); 78899a2dd95SBruce Richardson 78999a2dd95SBruce Richardson /** 7905f0d54f3SLi Zhang * MTR object meter policy update 7915f0d54f3SLi Zhang * 7925f0d54f3SLi Zhang * @param[in] port_id 7935f0d54f3SLi Zhang * The port identifier of the Ethernet device. 7945f0d54f3SLi Zhang * @param[in] mtr_id 7955f0d54f3SLi Zhang * MTR object ID. Needs to be valid. 7965f0d54f3SLi Zhang * @param[in] meter_policy_id 7975f0d54f3SLi Zhang * Meter policy ID for the current MTR object. Needs to be valid. 7985f0d54f3SLi Zhang * @param[out] error 7995f0d54f3SLi Zhang * Error details. Filled in only on error, when not NULL. 8005f0d54f3SLi Zhang * @return 8015f0d54f3SLi Zhang * 0 on success, non-zero error code otherwise. 8025f0d54f3SLi Zhang */ 8035f0d54f3SLi Zhang __rte_experimental 8045f0d54f3SLi Zhang int 8055f0d54f3SLi Zhang rte_mtr_meter_policy_update(uint16_t port_id, 8065f0d54f3SLi Zhang uint32_t mtr_id, 8075f0d54f3SLi Zhang uint32_t meter_policy_id, 8085f0d54f3SLi Zhang struct rte_mtr_error *error); 8095f0d54f3SLi Zhang 8105f0d54f3SLi Zhang /** 81199a2dd95SBruce Richardson * MTR object DSCP table update 81299a2dd95SBruce Richardson * 81399a2dd95SBruce Richardson * @param[in] port_id 81499a2dd95SBruce Richardson * The port identifier of the Ethernet device. 81599a2dd95SBruce Richardson * @param[in] mtr_id 81699a2dd95SBruce Richardson * MTR object ID. Needs to be valid. 81799a2dd95SBruce Richardson * @param[in] dscp_table 81899a2dd95SBruce Richardson * When non-NULL: it points to a pre-allocated and pre-populated table with 81999a2dd95SBruce Richardson * exactly 64 elements providing the input color for each value of the 82099a2dd95SBruce Richardson * IPv4/IPv6 Differentiated Services Code Point (DSCP) input packet field. 8215f0d54f3SLi Zhang * When NULL: it is equivalent to setting this parameter to an "all-green" 82299a2dd95SBruce Richardson * populated table (i.e. table with all the 64 elements set to green color). 82399a2dd95SBruce Richardson * @param[out] error 82499a2dd95SBruce Richardson * Error details. Filled in only on error, when not NULL. 82599a2dd95SBruce Richardson * @return 82699a2dd95SBruce Richardson * 0 on success, non-zero error code otherwise. 82799a2dd95SBruce Richardson */ 82899a2dd95SBruce Richardson __rte_experimental 82999a2dd95SBruce Richardson int 83099a2dd95SBruce Richardson rte_mtr_meter_dscp_table_update(uint16_t port_id, 83199a2dd95SBruce Richardson uint32_t mtr_id, 83299a2dd95SBruce Richardson enum rte_color *dscp_table, 83399a2dd95SBruce Richardson struct rte_mtr_error *error); 83499a2dd95SBruce Richardson 83599a2dd95SBruce Richardson /** 83699a2dd95SBruce Richardson * MTR object enabled statistics counters update 83799a2dd95SBruce Richardson * 83899a2dd95SBruce Richardson * @param[in] port_id 83999a2dd95SBruce Richardson * The port identifier of the Ethernet device. 84099a2dd95SBruce Richardson * @param[in] mtr_id 84199a2dd95SBruce Richardson * MTR object ID. Needs to be valid. 84299a2dd95SBruce Richardson * @param[in] stats_mask 84399a2dd95SBruce Richardson * Mask of statistics counter types to be enabled for the current MTR object. 84499a2dd95SBruce Richardson * Any statistics counter type not included in this set is to be disabled for 84599a2dd95SBruce Richardson * the current MTR object. 84699a2dd95SBruce Richardson * @param[out] error 84799a2dd95SBruce Richardson * Error details. Filled in only on error, when not NULL. 84899a2dd95SBruce Richardson * @return 84999a2dd95SBruce Richardson * 0 on success, non-zero error code otherwise. 85099a2dd95SBruce Richardson * 85199a2dd95SBruce Richardson * @see enum rte_mtr_stats_type 85299a2dd95SBruce Richardson */ 85399a2dd95SBruce Richardson __rte_experimental 85499a2dd95SBruce Richardson int 85599a2dd95SBruce Richardson rte_mtr_stats_update(uint16_t port_id, 85699a2dd95SBruce Richardson uint32_t mtr_id, 85799a2dd95SBruce Richardson uint64_t stats_mask, 85899a2dd95SBruce Richardson struct rte_mtr_error *error); 85999a2dd95SBruce Richardson 86099a2dd95SBruce Richardson /** 86199a2dd95SBruce Richardson * MTR object statistics counters read 86299a2dd95SBruce Richardson * 86399a2dd95SBruce Richardson * @param[in] port_id 86499a2dd95SBruce Richardson * The port identifier of the Ethernet device. 86599a2dd95SBruce Richardson * @param[in] mtr_id 86699a2dd95SBruce Richardson * MTR object ID. Needs to be valid. 86799a2dd95SBruce Richardson * @param[out] stats 86899a2dd95SBruce Richardson * When non-NULL, it contains the current value for the statistics counters 86999a2dd95SBruce Richardson * enabled for the current MTR object. 87099a2dd95SBruce Richardson * @param[out] stats_mask 87199a2dd95SBruce Richardson * When non-NULL, it contains the mask of statistics counter types that are 87299a2dd95SBruce Richardson * currently enabled for this MTR object, indicating which of the counters 87399a2dd95SBruce Richardson * retrieved with the *stats* structure are valid. 87499a2dd95SBruce Richardson * @param[in] clear 87599a2dd95SBruce Richardson * When this parameter has a non-zero value, the statistics counters are 87699a2dd95SBruce Richardson * cleared (i.e. set to zero) immediately after they have been read, 87799a2dd95SBruce Richardson * otherwise the statistics counters are left untouched. 87899a2dd95SBruce Richardson * @param[out] error 87999a2dd95SBruce Richardson * Error details. Filled in only on error, when not NULL. 88099a2dd95SBruce Richardson * @return 88199a2dd95SBruce Richardson * 0 on success, non-zero error code otherwise. 88299a2dd95SBruce Richardson * 88399a2dd95SBruce Richardson * @see enum rte_mtr_stats_type 88499a2dd95SBruce Richardson */ 88599a2dd95SBruce Richardson __rte_experimental 88699a2dd95SBruce Richardson int 88799a2dd95SBruce Richardson rte_mtr_stats_read(uint16_t port_id, 88899a2dd95SBruce Richardson uint32_t mtr_id, 88999a2dd95SBruce Richardson struct rte_mtr_stats *stats, 89099a2dd95SBruce Richardson uint64_t *stats_mask, 89199a2dd95SBruce Richardson int clear, 89299a2dd95SBruce Richardson struct rte_mtr_error *error); 89399a2dd95SBruce Richardson 89499a2dd95SBruce Richardson #ifdef __cplusplus 89599a2dd95SBruce Richardson } 89699a2dd95SBruce Richardson #endif 89799a2dd95SBruce Richardson 89899a2dd95SBruce Richardson #endif /* __INCLUDE_RTE_MTR_H__ */ 899