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 union { 13399a2dd95SBruce Richardson /** Items only valid when *alg* is set to srTCM - RFC 2697. */ 13499a2dd95SBruce Richardson struct { 13599a2dd95SBruce Richardson /** 13699a2dd95SBruce Richardson * Committed Information Rate (CIR) 13799a2dd95SBruce Richardson * (bytes per second or packets per second). 13899a2dd95SBruce Richardson */ 13999a2dd95SBruce Richardson uint64_t cir; 14099a2dd95SBruce Richardson 14199a2dd95SBruce Richardson /** Committed Burst Size (CBS) (bytes or packets). */ 14299a2dd95SBruce Richardson uint64_t cbs; 14399a2dd95SBruce Richardson 14499a2dd95SBruce Richardson /** Excess Burst Size (EBS) (bytes or packets). */ 14599a2dd95SBruce Richardson uint64_t ebs; 14699a2dd95SBruce Richardson } srtcm_rfc2697; 14799a2dd95SBruce Richardson 14899a2dd95SBruce Richardson /** Items only valid when *alg* is set to trTCM - RFC 2698. */ 14999a2dd95SBruce Richardson struct { 15099a2dd95SBruce Richardson /** 15199a2dd95SBruce Richardson * Committed Information Rate (CIR) 15299a2dd95SBruce Richardson * (bytes per second or packets per second). 15399a2dd95SBruce Richardson */ 15499a2dd95SBruce Richardson uint64_t cir; 15599a2dd95SBruce Richardson 15699a2dd95SBruce Richardson /** 15799a2dd95SBruce Richardson * Peak Information Rate (PIR) 15899a2dd95SBruce Richardson * (bytes per second or packets per second). 15999a2dd95SBruce Richardson */ 16099a2dd95SBruce Richardson uint64_t pir; 16199a2dd95SBruce Richardson 16299a2dd95SBruce Richardson /** Committed Burst Size (CBS) (bytes or packets). */ 16399a2dd95SBruce Richardson uint64_t cbs; 16499a2dd95SBruce Richardson 16599a2dd95SBruce Richardson /** Peak Burst Size (PBS) (bytes or packets). */ 16699a2dd95SBruce Richardson uint64_t pbs; 16799a2dd95SBruce Richardson } trtcm_rfc2698; 16899a2dd95SBruce Richardson 16999a2dd95SBruce Richardson /** Items only valid when *alg* is set to trTCM - RFC 4115. */ 17099a2dd95SBruce Richardson struct { 17199a2dd95SBruce Richardson /** 17299a2dd95SBruce Richardson * Committed Information Rate (CIR) 17399a2dd95SBruce Richardson * (bytes per second or packets per second). 17499a2dd95SBruce Richardson */ 17599a2dd95SBruce Richardson uint64_t cir; 17699a2dd95SBruce Richardson 17799a2dd95SBruce Richardson /** 17899a2dd95SBruce Richardson * Excess Information Rate (EIR) 17999a2dd95SBruce Richardson * (bytes per second or packets per second). 18099a2dd95SBruce Richardson */ 18199a2dd95SBruce Richardson uint64_t eir; 18299a2dd95SBruce Richardson 18399a2dd95SBruce Richardson /** Committed Burst Size (CBS) (bytes or packets). */ 18499a2dd95SBruce Richardson uint64_t cbs; 18599a2dd95SBruce Richardson 18699a2dd95SBruce Richardson /** Excess Burst Size (EBS) (bytes or packets). */ 18799a2dd95SBruce Richardson uint64_t ebs; 18899a2dd95SBruce Richardson } trtcm_rfc4115; 18999a2dd95SBruce Richardson }; 19099a2dd95SBruce Richardson 19199a2dd95SBruce Richardson /** 19299a2dd95SBruce Richardson * When zero, the byte mode is enabled for the current profile, so the 19399a2dd95SBruce Richardson * *rate* and *size* fields are specified in bytes per second 19499a2dd95SBruce Richardson * and bytes, respectively. 19599a2dd95SBruce Richardson * When non-zero, the packet mode is enabled for the current profile, 19699a2dd95SBruce Richardson * so the *rate* and *size* fields are specified in packets per second 19799a2dd95SBruce Richardson * and packets, respectively. 19899a2dd95SBruce Richardson */ 19999a2dd95SBruce Richardson int packet_mode; 20099a2dd95SBruce Richardson }; 20199a2dd95SBruce Richardson 20299a2dd95SBruce Richardson /** 2035f0d54f3SLi Zhang * Meter policy 20499a2dd95SBruce Richardson */ 2055f0d54f3SLi Zhang struct rte_mtr_meter_policy_params { 2065f0d54f3SLi Zhang /** 2075f0d54f3SLi Zhang * Policy action list per color. 2085f0d54f3SLi Zhang * actions[i] potentially represents a chain of rte_flow actions 2095f0d54f3SLi Zhang * terminated by the END action, exactly as specified by the rte_flow 2105f0d54f3SLi Zhang * API for the flow definition, and not just a single action. 2115f0d54f3SLi Zhang */ 2125f0d54f3SLi Zhang const struct rte_flow_action *actions[RTE_COLORS]; 21399a2dd95SBruce Richardson }; 21499a2dd95SBruce Richardson 21599a2dd95SBruce Richardson /** 216d04fb3b5SJerin Jacob * Input color protocol method 217d04fb3b5SJerin Jacob * 218d04fb3b5SJerin Jacob * More than one of the method can be enabled for a given meter. 219d04fb3b5SJerin Jacob * Even if enabled, a method might not be applicable to each input packet, 220d04fb3b5SJerin Jacob * in case the associated protocol header is not present in the packet. 221d04fb3b5SJerin Jacob * The highest priority method that is both enabled for the meter and also 222d04fb3b5SJerin Jacob * applicable for the current input packet wins; 223d04fb3b5SJerin Jacob * if none is both enabled and applicable, the default input color is used. 224d04fb3b5SJerin Jacob * @see function rte_mtr_color_in_protocol_set() 225d04fb3b5SJerin Jacob */ 226d04fb3b5SJerin Jacob enum rte_mtr_color_in_protocol { 227d04fb3b5SJerin Jacob /** 228d04fb3b5SJerin Jacob * Enable the detection of the packet input color based on the outermost 229d04fb3b5SJerin Jacob * VLAN header fields DEI (1 bit) and PCP (3 bits). 230d04fb3b5SJerin Jacob * These fields are used as index into the VLAN table. 231d04fb3b5SJerin Jacob * 232d04fb3b5SJerin Jacob * @see struct rte_mtr_params::vlan_table 233d04fb3b5SJerin Jacob */ 234d04fb3b5SJerin Jacob RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN = RTE_BIT64(0), 235d04fb3b5SJerin Jacob /** 236d04fb3b5SJerin Jacob * Enable the detection of the packet input color based on the innermost 237d04fb3b5SJerin Jacob * VLAN header fields DEI (1 bit) and PCP (3 bits). 238d04fb3b5SJerin Jacob * These fields are used as index into the VLAN table. 239d04fb3b5SJerin Jacob * 240d04fb3b5SJerin Jacob * @see struct rte_mtr_params::vlan_table 241d04fb3b5SJerin Jacob */ 242d04fb3b5SJerin Jacob RTE_MTR_COLOR_IN_PROTO_INNER_VLAN = RTE_BIT64(1), 243d04fb3b5SJerin Jacob /** 244d04fb3b5SJerin Jacob * Enable the detection of the packet input color based on the outermost 245d04fb3b5SJerin Jacob * IP DSCP field. These fields are used as index into the DSCP table. 246d04fb3b5SJerin Jacob * 247d04fb3b5SJerin Jacob * @see struct rte_mtr_params::dscp_table 248d04fb3b5SJerin Jacob */ 249d04fb3b5SJerin Jacob RTE_MTR_COLOR_IN_PROTO_OUTER_IP = RTE_BIT64(2), 250d04fb3b5SJerin Jacob /** 251d04fb3b5SJerin Jacob * Enable the detection of the packet input color based on the innermost 252d04fb3b5SJerin Jacob * IP DSCP field. These fields are used as index into the DSCP table. 253d04fb3b5SJerin Jacob * 254d04fb3b5SJerin Jacob * @see struct rte_mtr_params::dscp_table 255d04fb3b5SJerin Jacob */ 256d04fb3b5SJerin Jacob RTE_MTR_COLOR_IN_PROTO_INNER_IP = RTE_BIT64(3), 257d04fb3b5SJerin Jacob }; 258d04fb3b5SJerin Jacob 259d04fb3b5SJerin Jacob /** 26099a2dd95SBruce Richardson * Parameters for each traffic metering & policing object 26199a2dd95SBruce Richardson * 26299a2dd95SBruce Richardson * @see enum rte_mtr_stats_type 26399a2dd95SBruce Richardson */ 26499a2dd95SBruce Richardson struct rte_mtr_params { 26544f44b80SJerin Jacob /** Meter profile ID. @see rte_mtr_meter_profile_add() */ 26699a2dd95SBruce Richardson uint32_t meter_profile_id; 26799a2dd95SBruce Richardson 26899a2dd95SBruce Richardson /** Meter input color in case of MTR object chaining. When non-zero: if 26999a2dd95SBruce Richardson * a previous MTR object is enabled in the same flow, then the color 27099a2dd95SBruce Richardson * determined by the latest MTR object in the same flow is used as the 27199a2dd95SBruce Richardson * input color by the current MTR object, otherwise the current MTR 27299a2dd95SBruce Richardson * object uses the *dscp_table* to determine the input color. When zero: 27399a2dd95SBruce Richardson * the color determined by any previous MTR object in same flow is 27499a2dd95SBruce Richardson * ignored by the current MTR object, which uses the *dscp_table* to 27599a2dd95SBruce Richardson * determine the input color. 27699a2dd95SBruce Richardson */ 27799a2dd95SBruce Richardson int use_prev_mtr_color; 27899a2dd95SBruce Richardson 279d04fb3b5SJerin Jacob /** Meter input color based on IP DSCP protocol field. 280d04fb3b5SJerin Jacob * 281d04fb3b5SJerin Jacob * Valid when *input_color_proto_mask* set to any of the following 282d04fb3b5SJerin Jacob * RTE_MTR_COLOR_IN_PROTO_OUTER_IP, 283d04fb3b5SJerin Jacob * RTE_MTR_COLOR_IN_PROTO_INNER_IP 284d04fb3b5SJerin Jacob * 285d04fb3b5SJerin Jacob * When non-NULL: it points to a pre-allocated and 28699a2dd95SBruce Richardson * pre-populated table with exactly 64 elements providing the input 28799a2dd95SBruce Richardson * color for each value of the IPv4/IPv6 Differentiated Services Code 288d04fb3b5SJerin Jacob * Point (DSCP) input packet field. 289d04fb3b5SJerin Jacob * 290d04fb3b5SJerin Jacob * When NULL: it is equivalent to setting this parameter to an all-green 291d04fb3b5SJerin Jacob * populated table (i.e. table with all the 64 elements set to green 292d04fb3b5SJerin Jacob * color). The color blind mode is configured by setting 293d04fb3b5SJerin Jacob * *use_prev_mtr_color* to 0 and *dscp_table* to either NULL or to an 294d04fb3b5SJerin Jacob * all-green populated table. 295d04fb3b5SJerin Jacob * 296d04fb3b5SJerin Jacob * When *use_prev_mtr_color* is non-zero value or when *dscp_table* 297d04fb3b5SJerin Jacob * contains at least one yellow or red color element, then the color 298d04fb3b5SJerin Jacob * aware mode is configured. 299d04fb3b5SJerin Jacob * 300d04fb3b5SJerin Jacob * @see enum rte_mtr_color_in_protocol::RTE_MTR_COLOR_IN_PROTO_OUTER_IP 301d04fb3b5SJerin Jacob * @see enum rte_mtr_color_in_protocol::RTE_MTR_COLOR_IN_PROTO_INNER_IP 302d04fb3b5SJerin Jacob * @see struct rte_mtr_params::input_color_proto_mask 30399a2dd95SBruce Richardson */ 30499a2dd95SBruce Richardson enum rte_color *dscp_table; 305d04fb3b5SJerin Jacob /** Meter input color based on VLAN DEI(1bit), PCP(3 bits) protocol 306d04fb3b5SJerin Jacob * fields. 307d04fb3b5SJerin Jacob * 308d04fb3b5SJerin Jacob * Valid when *input_color_proto_mask* set to any of the following 309d04fb3b5SJerin Jacob * RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN, 310d04fb3b5SJerin Jacob * RTE_MTR_COLOR_IN_PROTO_INNER_VLAN 311d04fb3b5SJerin Jacob * 312d04fb3b5SJerin Jacob * When non-NULL: it points to a pre-allocated and pre-populated 313d04fb3b5SJerin Jacob * table with exactly 16 elements providing the input color for 314d04fb3b5SJerin Jacob * each value of the DEI(1bit), PCP(3 bits) input packet field. 315d04fb3b5SJerin Jacob * 316d04fb3b5SJerin Jacob * When NULL: it is equivalent to setting this parameter to an 317d04fb3b5SJerin Jacob * all-green populated table (i.e. table with 318d04fb3b5SJerin Jacob * all the 16 elements set to green color). The color blind mode 319d04fb3b5SJerin Jacob * is configured by setting *use_prev_mtr_color* to 0 and 320d04fb3b5SJerin Jacob * *vlan_table* to either NULL or to an all-green populated table. 321d04fb3b5SJerin Jacob * 322d04fb3b5SJerin Jacob * When *use_prev_mtr_color* is non-zero value 323d04fb3b5SJerin Jacob * or when *vlan_table* contains at least one yellow or 324d04fb3b5SJerin Jacob * red color element, then the color aware mode is configured. 325d04fb3b5SJerin Jacob * 326d04fb3b5SJerin Jacob * @see enum rte_mtr_color_in_protocol::RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN 327d04fb3b5SJerin Jacob * @see enum rte_mtr_color_in_protocol::RTE_MTR_COLOR_IN_PROTO_INNER_VLAN 328d04fb3b5SJerin Jacob * @see struct rte_mtr_params::input_color_proto_mask 329d04fb3b5SJerin Jacob */ 330d04fb3b5SJerin Jacob enum rte_color *vlan_table; 33199a2dd95SBruce Richardson /** Non-zero to enable the meter, zero to disable the meter at the time 33299a2dd95SBruce Richardson * of MTR object creation. Ignored when the meter profile indicated by 33399a2dd95SBruce Richardson * *meter_profile_id* is set to NONE. 33499a2dd95SBruce Richardson * @see rte_mtr_meter_disable() 33599a2dd95SBruce Richardson */ 33699a2dd95SBruce Richardson int meter_enable; 33799a2dd95SBruce Richardson 33899a2dd95SBruce Richardson /** Set of stats counters to be enabled. 33999a2dd95SBruce Richardson * @see enum rte_mtr_stats_type 34099a2dd95SBruce Richardson */ 34199a2dd95SBruce Richardson uint64_t stats_mask; 3425f0d54f3SLi Zhang 34344f44b80SJerin Jacob /** Meter policy ID. @see rte_mtr_meter_policy_add() */ 3445f0d54f3SLi Zhang uint32_t meter_policy_id; 345d04fb3b5SJerin Jacob 346d04fb3b5SJerin Jacob /** Input color to be set for the input packet when none of the 347d04fb3b5SJerin Jacob * enabled input color methods is applicable to the input packet. 348d04fb3b5SJerin Jacob * Ignored when this when *input_color_proto_mask* set to zero. 349d04fb3b5SJerin Jacob */ 350d04fb3b5SJerin Jacob enum rte_color default_input_color; 35199a2dd95SBruce Richardson }; 35299a2dd95SBruce Richardson 35399a2dd95SBruce Richardson /** 35499a2dd95SBruce Richardson * MTR capabilities 35599a2dd95SBruce Richardson */ 35699a2dd95SBruce Richardson struct rte_mtr_capabilities { 35799a2dd95SBruce Richardson /** Maximum number of MTR objects. */ 35899a2dd95SBruce Richardson uint32_t n_max; 35999a2dd95SBruce Richardson 36099a2dd95SBruce Richardson /** Maximum number of MTR objects that can be shared by multiple flows. 36199a2dd95SBruce Richardson * The value of zero indicates that shared MTR objects are not 36299a2dd95SBruce Richardson * supported. The maximum value is *n_max*. 36399a2dd95SBruce Richardson */ 36499a2dd95SBruce Richardson uint32_t n_shared_max; 36599a2dd95SBruce Richardson 36699a2dd95SBruce Richardson /** When non-zero, this flag indicates that all the MTR objects that 36799a2dd95SBruce Richardson * cannot be shared by multiple flows have identical capability set. 36899a2dd95SBruce Richardson */ 36999a2dd95SBruce Richardson int identical; 37099a2dd95SBruce Richardson 37199a2dd95SBruce Richardson /** When non-zero, this flag indicates that all the MTR objects that 37299a2dd95SBruce Richardson * can be shared by multiple flows have identical capability set. 37399a2dd95SBruce Richardson */ 37499a2dd95SBruce Richardson int shared_identical; 37599a2dd95SBruce Richardson 37699a2dd95SBruce Richardson /** Maximum number of flows that can share the same MTR object. The 37799a2dd95SBruce Richardson * value of zero is invalid. The value of 1 means that shared MTR 37899a2dd95SBruce Richardson * objects not supported. 37999a2dd95SBruce Richardson */ 38099a2dd95SBruce Richardson uint32_t shared_n_flows_per_mtr_max; 38199a2dd95SBruce Richardson 38299a2dd95SBruce Richardson /** Maximum number of MTR objects that can be part of the same flow. The 38399a2dd95SBruce Richardson * value of zero is invalid. The value of 1 indicates that MTR object 38499a2dd95SBruce Richardson * chaining is not supported. The maximum value is *n_max*. 38599a2dd95SBruce Richardson */ 38699a2dd95SBruce Richardson uint32_t chaining_n_mtrs_per_flow_max; 38799a2dd95SBruce Richardson 38899a2dd95SBruce Richardson /** 38999a2dd95SBruce Richardson * When non-zero, it indicates that the packet color identified by one 39099a2dd95SBruce Richardson * MTR object can be used as the packet input color by any subsequent 39199a2dd95SBruce Richardson * MTR object from the same flow. When zero, it indicates that the color 39299a2dd95SBruce Richardson * determined by one MTR object is always ignored by any subsequent MTR 39399a2dd95SBruce Richardson * object from the same flow. Only valid when MTR chaining is supported, 39499a2dd95SBruce Richardson * i.e. *chaining_n_mtrs_per_flow_max* is greater than 1. When non-zero, 39599a2dd95SBruce Richardson * it also means that the color aware mode is supported by at least one 39699a2dd95SBruce Richardson * metering algorithm. 39799a2dd95SBruce Richardson */ 39899a2dd95SBruce Richardson int chaining_use_prev_mtr_color_supported; 39999a2dd95SBruce Richardson 40099a2dd95SBruce Richardson /** 40199a2dd95SBruce Richardson * When non-zero, it indicates that the packet color identified by one 40299a2dd95SBruce Richardson * MTR object is always used as the packet input color by any subsequent 40399a2dd95SBruce Richardson * MTR object that is part of the same flow. When zero, it indicates 40499a2dd95SBruce Richardson * that whether the color determined by one MTR object is either ignored 40599a2dd95SBruce Richardson * or used as the packet input color by any subsequent MTR object from 40699a2dd95SBruce Richardson * the same flow is individually configurable for each MTR object. Only 40799a2dd95SBruce Richardson * valid when *chaining_use_prev_mtr_color_supported* is non-zero. 40899a2dd95SBruce Richardson */ 40999a2dd95SBruce Richardson int chaining_use_prev_mtr_color_enforced; 41099a2dd95SBruce Richardson 41199a2dd95SBruce Richardson /** Maximum number of MTR objects that can have their meter configured 41299a2dd95SBruce Richardson * to run the srTCM RFC 2697 algorithm. The value of 0 indicates this 41399a2dd95SBruce Richardson * metering algorithm is not supported. The maximum value is *n_max*. 41499a2dd95SBruce Richardson */ 41599a2dd95SBruce Richardson uint32_t meter_srtcm_rfc2697_n_max; 41699a2dd95SBruce Richardson 41799a2dd95SBruce Richardson /** Maximum number of MTR objects that can have their meter configured 41899a2dd95SBruce Richardson * to run the trTCM RFC 2698 algorithm. The value of 0 indicates this 41999a2dd95SBruce Richardson * metering algorithm is not supported. The maximum value is *n_max*. 42099a2dd95SBruce Richardson */ 42199a2dd95SBruce Richardson uint32_t meter_trtcm_rfc2698_n_max; 42299a2dd95SBruce Richardson 42399a2dd95SBruce Richardson /** Maximum number of MTR objects that can have their meter configured 42499a2dd95SBruce Richardson * to run the trTCM RFC 4115 algorithm. The value of 0 indicates this 42599a2dd95SBruce Richardson * metering algorithm is not supported. The maximum value is *n_max*. 42699a2dd95SBruce Richardson */ 42799a2dd95SBruce Richardson uint32_t meter_trtcm_rfc4115_n_max; 42899a2dd95SBruce Richardson 42999a2dd95SBruce Richardson /** Maximum traffic rate that can be metered by a single MTR object. For 43099a2dd95SBruce Richardson * srTCM RFC 2697, this is the maximum CIR rate. For trTCM RFC 2698, 43199a2dd95SBruce Richardson * this is the maximum PIR rate. For trTCM RFC 4115, this is the maximum 43299a2dd95SBruce Richardson * value for the sum of PIR and EIR rates. 43399a2dd95SBruce Richardson */ 43499a2dd95SBruce Richardson uint64_t meter_rate_max; 43599a2dd95SBruce Richardson 43699a2dd95SBruce Richardson /** 4375f0d54f3SLi Zhang * Maximum number of policy objects that can have. 4385f0d54f3SLi Zhang * The value of 0 is invalid. Policy must be supported for meter. 4395f0d54f3SLi Zhang * The maximum value is *n_max*. 4405f0d54f3SLi Zhang */ 4415f0d54f3SLi Zhang uint64_t meter_policy_n_max; 4425f0d54f3SLi Zhang 4435f0d54f3SLi Zhang /** 44499a2dd95SBruce Richardson * When non-zero, it indicates that color aware mode is supported for 44599a2dd95SBruce Richardson * the srTCM RFC 2697 metering algorithm. 44699a2dd95SBruce Richardson */ 44799a2dd95SBruce Richardson int color_aware_srtcm_rfc2697_supported; 44899a2dd95SBruce Richardson 44999a2dd95SBruce Richardson /** 45099a2dd95SBruce Richardson * When non-zero, it indicates that color aware mode is supported for 45199a2dd95SBruce Richardson * the trTCM RFC 2698 metering algorithm. 45299a2dd95SBruce Richardson */ 45399a2dd95SBruce Richardson int color_aware_trtcm_rfc2698_supported; 45499a2dd95SBruce Richardson 45599a2dd95SBruce Richardson /** 45699a2dd95SBruce Richardson * When non-zero, it indicates that color aware mode is supported for 45799a2dd95SBruce Richardson * the trTCM RFC 4115 metering algorithm. 45899a2dd95SBruce Richardson */ 45999a2dd95SBruce Richardson int color_aware_trtcm_rfc4115_supported; 46099a2dd95SBruce Richardson 46199a2dd95SBruce Richardson /** 46299a2dd95SBruce Richardson * srTCM rfc2697 byte mode supported. 46399a2dd95SBruce Richardson * When non-zero, it indicates that byte mode is supported for 46499a2dd95SBruce Richardson * the srTCM RFC 2697 metering algorithm. 46599a2dd95SBruce Richardson */ 46699a2dd95SBruce Richardson int srtcm_rfc2697_byte_mode_supported; 46799a2dd95SBruce Richardson 46899a2dd95SBruce Richardson /** 46999a2dd95SBruce Richardson * srTCM rfc2697 packet mode supported. 47099a2dd95SBruce Richardson * When non-zero, it indicates that packet mode is supported for 47199a2dd95SBruce Richardson * the srTCM RFC 2697 metering algorithm. 47299a2dd95SBruce Richardson */ 47399a2dd95SBruce Richardson int srtcm_rfc2697_packet_mode_supported; 47499a2dd95SBruce Richardson 47599a2dd95SBruce Richardson /** 47699a2dd95SBruce Richardson * trTCM rfc2698 byte mode supported. 47799a2dd95SBruce Richardson * When non-zero, it indicates that byte mode is supported for 47899a2dd95SBruce Richardson * the trTCM RFC 2698 metering algorithm. 47999a2dd95SBruce Richardson */ 48099a2dd95SBruce Richardson int trtcm_rfc2698_byte_mode_supported; 48199a2dd95SBruce Richardson 48299a2dd95SBruce Richardson /** 48399a2dd95SBruce Richardson * trTCM rfc2698 packet mode supported. 48499a2dd95SBruce Richardson * When non-zero, it indicates that packet mode is supported for 48599a2dd95SBruce Richardson * the trTCM RFC 2698 metering algorithm. 48699a2dd95SBruce Richardson */ 48799a2dd95SBruce Richardson int trtcm_rfc2698_packet_mode_supported; 48899a2dd95SBruce Richardson 48999a2dd95SBruce Richardson /** 49099a2dd95SBruce Richardson * trTCM rfc4115 byte mode supported. 49199a2dd95SBruce Richardson * When non-zero, it indicates that byte mode is supported for 49299a2dd95SBruce Richardson * the trTCM RFC 4115 metering algorithm. 49399a2dd95SBruce Richardson */ 49499a2dd95SBruce Richardson int trtcm_rfc4115_byte_mode_supported; 49599a2dd95SBruce Richardson 49699a2dd95SBruce Richardson /** 49799a2dd95SBruce Richardson * trTCM rfc4115 packet mode supported. 49899a2dd95SBruce Richardson * When non-zero, it indicates that packet mode is supported for 49999a2dd95SBruce Richardson * the trTCM RFC 4115 metering algorithm. 50099a2dd95SBruce Richardson */ 50199a2dd95SBruce Richardson int trtcm_rfc4115_packet_mode_supported; 50299a2dd95SBruce Richardson 50399a2dd95SBruce Richardson /** Set of supported statistics counter types. 50499a2dd95SBruce Richardson * @see enum rte_mtr_stats_type 50599a2dd95SBruce Richardson */ 50699a2dd95SBruce Richardson uint64_t stats_mask; 507d04fb3b5SJerin Jacob 508d04fb3b5SJerin Jacob /** Set of supported input color protocol. 509d04fb3b5SJerin Jacob * @see enum rte_mtr_color_in_protocol 510d04fb3b5SJerin Jacob */ 511d04fb3b5SJerin Jacob uint64_t input_color_proto_mask; 512d04fb3b5SJerin Jacob 513d04fb3b5SJerin Jacob /** When non-zero, it indicates that driver supports separate 514d04fb3b5SJerin Jacob * input color table for given ethdev port. 515d04fb3b5SJerin Jacob */ 516d04fb3b5SJerin Jacob int separate_input_color_table_per_port; 51799a2dd95SBruce Richardson }; 51899a2dd95SBruce Richardson 51999a2dd95SBruce Richardson /** 52099a2dd95SBruce Richardson * Verbose error types. 52199a2dd95SBruce Richardson * 52299a2dd95SBruce Richardson * Most of them provide the type of the object referenced by struct 52399a2dd95SBruce Richardson * rte_mtr_error::cause. 52499a2dd95SBruce Richardson */ 52599a2dd95SBruce Richardson enum rte_mtr_error_type { 52699a2dd95SBruce Richardson RTE_MTR_ERROR_TYPE_NONE, /**< No error. */ 52799a2dd95SBruce Richardson RTE_MTR_ERROR_TYPE_UNSPECIFIED, /**< Cause unspecified. */ 52899a2dd95SBruce Richardson RTE_MTR_ERROR_TYPE_METER_PROFILE_ID, 52999a2dd95SBruce Richardson RTE_MTR_ERROR_TYPE_METER_PROFILE, 53099a2dd95SBruce Richardson RTE_MTR_ERROR_TYPE_METER_PROFILE_PACKET_MODE, 53199a2dd95SBruce Richardson RTE_MTR_ERROR_TYPE_MTR_ID, 53299a2dd95SBruce Richardson RTE_MTR_ERROR_TYPE_MTR_PARAMS, 53399a2dd95SBruce Richardson RTE_MTR_ERROR_TYPE_POLICER_ACTION_GREEN, 53499a2dd95SBruce Richardson RTE_MTR_ERROR_TYPE_POLICER_ACTION_YELLOW, 53599a2dd95SBruce Richardson RTE_MTR_ERROR_TYPE_POLICER_ACTION_RED, 53699a2dd95SBruce Richardson RTE_MTR_ERROR_TYPE_STATS_MASK, 53799a2dd95SBruce Richardson RTE_MTR_ERROR_TYPE_STATS, 53899a2dd95SBruce Richardson RTE_MTR_ERROR_TYPE_SHARED, 5395f0d54f3SLi Zhang RTE_MTR_ERROR_TYPE_METER_POLICY_ID, 5405f0d54f3SLi Zhang RTE_MTR_ERROR_TYPE_METER_POLICY, 54199a2dd95SBruce Richardson }; 54299a2dd95SBruce Richardson 54399a2dd95SBruce Richardson /** 54499a2dd95SBruce Richardson * Verbose error structure definition. 54599a2dd95SBruce Richardson * 54699a2dd95SBruce Richardson * This object is normally allocated by applications and set by PMDs, the 54799a2dd95SBruce Richardson * message points to a constant string which does not need to be freed by 54899a2dd95SBruce Richardson * the application, however its pointer can be considered valid only as long 54999a2dd95SBruce Richardson * as its associated DPDK port remains configured. Closing the underlying 55099a2dd95SBruce Richardson * device or unloading the PMD invalidates it. 55199a2dd95SBruce Richardson * 55299a2dd95SBruce Richardson * Both cause and message may be NULL regardless of the error type. 55399a2dd95SBruce Richardson */ 55499a2dd95SBruce Richardson struct rte_mtr_error { 55599a2dd95SBruce Richardson enum rte_mtr_error_type type; /**< Cause field and error type. */ 55699a2dd95SBruce Richardson const void *cause; /**< Object responsible for the error. */ 55799a2dd95SBruce Richardson const char *message; /**< Human-readable error message. */ 55899a2dd95SBruce Richardson }; 55999a2dd95SBruce Richardson 56099a2dd95SBruce Richardson /** 56199a2dd95SBruce Richardson * MTR capabilities get 56299a2dd95SBruce Richardson * 56399a2dd95SBruce Richardson * @param[in] port_id 56499a2dd95SBruce Richardson * The port identifier of the Ethernet device. 56599a2dd95SBruce Richardson * @param[out] cap 56699a2dd95SBruce Richardson * MTR capabilities. Needs to be pre-allocated and valid. 56799a2dd95SBruce Richardson * @param[out] error 56899a2dd95SBruce Richardson * Error details. Filled in only on error, when not NULL. 56999a2dd95SBruce Richardson * @return 57099a2dd95SBruce Richardson * 0 on success, non-zero error code otherwise. 57199a2dd95SBruce Richardson */ 57299a2dd95SBruce Richardson __rte_experimental 57399a2dd95SBruce Richardson int 57499a2dd95SBruce Richardson rte_mtr_capabilities_get(uint16_t port_id, 57599a2dd95SBruce Richardson struct rte_mtr_capabilities *cap, 57699a2dd95SBruce Richardson struct rte_mtr_error *error); 57799a2dd95SBruce Richardson 57899a2dd95SBruce Richardson /** 57999a2dd95SBruce Richardson * Meter profile add 58099a2dd95SBruce Richardson * 58199a2dd95SBruce Richardson * Create a new meter profile with ID set to *meter_profile_id*. The new profile 58299a2dd95SBruce Richardson * is used to create one or several MTR objects. 58399a2dd95SBruce Richardson * 58499a2dd95SBruce Richardson * @param[in] port_id 58599a2dd95SBruce Richardson * The port identifier of the Ethernet device. 58699a2dd95SBruce Richardson * @param[in] meter_profile_id 58799a2dd95SBruce Richardson * ID for the new meter profile. Needs to be unused by any of the existing 58899a2dd95SBruce Richardson * meter profiles added for the current port. 58999a2dd95SBruce Richardson * @param[in] profile 59099a2dd95SBruce Richardson * Meter profile parameters. Needs to be pre-allocated and valid. 59199a2dd95SBruce Richardson * @param[out] error 59299a2dd95SBruce Richardson * Error details. Filled in only on error, when not NULL. 59399a2dd95SBruce Richardson * @return 59499a2dd95SBruce Richardson * 0 on success, non-zero error code otherwise. 59599a2dd95SBruce Richardson */ 59699a2dd95SBruce Richardson __rte_experimental 59799a2dd95SBruce Richardson int 59899a2dd95SBruce Richardson rte_mtr_meter_profile_add(uint16_t port_id, 59999a2dd95SBruce Richardson uint32_t meter_profile_id, 60099a2dd95SBruce Richardson struct rte_mtr_meter_profile *profile, 60199a2dd95SBruce Richardson struct rte_mtr_error *error); 60299a2dd95SBruce Richardson 60399a2dd95SBruce Richardson /** 60499a2dd95SBruce Richardson * Meter profile delete 60599a2dd95SBruce Richardson * 60699a2dd95SBruce Richardson * Delete an existing meter profile. This operation fails when there is 60799a2dd95SBruce Richardson * currently at least one user (i.e. MTR object) of this profile. 60899a2dd95SBruce Richardson * 60999a2dd95SBruce Richardson * @param[in] port_id 61099a2dd95SBruce Richardson * The port identifier of the Ethernet device. 61199a2dd95SBruce Richardson * @param[in] meter_profile_id 61299a2dd95SBruce Richardson * Meter profile ID. Needs to be the valid. 61399a2dd95SBruce Richardson * @param[out] error 61499a2dd95SBruce Richardson * Error details. Filled in only on error, when not NULL. 61599a2dd95SBruce Richardson * @return 61699a2dd95SBruce Richardson * 0 on success, non-zero error code otherwise. 61799a2dd95SBruce Richardson */ 61899a2dd95SBruce Richardson __rte_experimental 61999a2dd95SBruce Richardson int 62099a2dd95SBruce Richardson rte_mtr_meter_profile_delete(uint16_t port_id, 62199a2dd95SBruce Richardson uint32_t meter_profile_id, 62299a2dd95SBruce Richardson struct rte_mtr_error *error); 62399a2dd95SBruce Richardson 62499a2dd95SBruce Richardson /** 625ece19ccaSAlexander Kozyrev * Meter profile object get 626ece19ccaSAlexander Kozyrev * 627ece19ccaSAlexander Kozyrev * Get meter profile object for a given meter profile ID. 628ece19ccaSAlexander Kozyrev * 629ece19ccaSAlexander Kozyrev * @param[in] port_id 630ece19ccaSAlexander Kozyrev * The port identifier of the Ethernet device. 631ece19ccaSAlexander Kozyrev * @param[in] meter_profile_id 632ece19ccaSAlexander Kozyrev * Meter profile ID. Needs to be the valid. 633ece19ccaSAlexander Kozyrev * @param[out] error 634ece19ccaSAlexander Kozyrev * Error details. Filled in only on error, when not NULL. 635ece19ccaSAlexander Kozyrev * @return 636ece19ccaSAlexander Kozyrev * A valid handle in case of success, NULL otherwise. 637ece19ccaSAlexander Kozyrev */ 638ece19ccaSAlexander Kozyrev __rte_experimental 639ece19ccaSAlexander Kozyrev struct rte_flow_meter_profile * 640ece19ccaSAlexander Kozyrev rte_mtr_meter_profile_get(uint16_t port_id, 641ece19ccaSAlexander Kozyrev uint32_t meter_profile_id, 642ece19ccaSAlexander Kozyrev struct rte_mtr_error *error); 643ece19ccaSAlexander Kozyrev 644ece19ccaSAlexander Kozyrev /** 6455f0d54f3SLi Zhang * Check whether a meter policy can be created on a given port. 6465f0d54f3SLi Zhang * 6475f0d54f3SLi Zhang * The meter policy is validated for correctness and 6485f0d54f3SLi Zhang * whether it could be accepted by the device given sufficient resources. 6495f0d54f3SLi Zhang * The policy is checked against the current capability information 6505f0d54f3SLi Zhang * meter_policy_n_max configuration. 6515f0d54f3SLi Zhang * The policy may also optionally be validated against existing 6525f0d54f3SLi Zhang * device policy resources. 6535f0d54f3SLi Zhang * This function has no effect on the target device. 6545f0d54f3SLi Zhang * 6555f0d54f3SLi Zhang * @param[in] port_id 6565f0d54f3SLi Zhang * The port identifier of the Ethernet device. 6575f0d54f3SLi Zhang * @param[in] policy 6585f0d54f3SLi Zhang * Associated action list per color. 6595f0d54f3SLi Zhang * list NULL is legal and means no special action. 6605f0d54f3SLi Zhang * (list terminated by the END action). 6615f0d54f3SLi Zhang * @param[out] error 6625f0d54f3SLi Zhang * Error details. Filled in only on error, when not NULL. 6635f0d54f3SLi Zhang * @return 6645f0d54f3SLi Zhang * 0 on success, non-zero error code otherwise. 6655f0d54f3SLi Zhang */ 6665f0d54f3SLi Zhang __rte_experimental 6675f0d54f3SLi Zhang int 6685f0d54f3SLi Zhang rte_mtr_meter_policy_validate(uint16_t port_id, 6695f0d54f3SLi Zhang struct rte_mtr_meter_policy_params *policy, 6705f0d54f3SLi Zhang struct rte_mtr_error *error); 6715f0d54f3SLi Zhang 6725f0d54f3SLi Zhang /** 6735f0d54f3SLi Zhang * Meter policy add 6745f0d54f3SLi Zhang * 6755f0d54f3SLi Zhang * Create a new meter policy. The new policy 6765f0d54f3SLi Zhang * is used to create single or multiple MTR objects. 6775f0d54f3SLi Zhang * The same policy can be used to create multiple MTR objects. 6785f0d54f3SLi Zhang * 6795f0d54f3SLi Zhang * @param[in] port_id 6805f0d54f3SLi Zhang * The port identifier of the Ethernet device. 6815f0d54f3SLi Zhang * @param[in] policy_id 6825f0d54f3SLi Zhang * Policy identifier for the new meter policy. 6835f0d54f3SLi Zhang * @param[in] policy 6845f0d54f3SLi Zhang * Associated actions per color. 6855f0d54f3SLi Zhang * list NULL is legal and means no special action. 6865f0d54f3SLi Zhang * Non-NULL list must be terminated. 6875f0d54f3SLi Zhang * (list terminated by the END action). 6885f0d54f3SLi Zhang * @param[out] error 6895f0d54f3SLi Zhang * Error details. Filled in only on error, when not NULL. 6905f0d54f3SLi Zhang * @return 6915f0d54f3SLi Zhang * 0 on success, non-zero error code otherwise. 6925f0d54f3SLi Zhang */ 6935f0d54f3SLi Zhang __rte_experimental 6945f0d54f3SLi Zhang int 6955f0d54f3SLi Zhang rte_mtr_meter_policy_add(uint16_t port_id, 6965f0d54f3SLi Zhang uint32_t policy_id, 6975f0d54f3SLi Zhang struct rte_mtr_meter_policy_params *policy, 6985f0d54f3SLi Zhang struct rte_mtr_error *error); 6995f0d54f3SLi Zhang 7005f0d54f3SLi Zhang /** 701ece19ccaSAlexander Kozyrev * Meter policy object get 702ece19ccaSAlexander Kozyrev * 703ece19ccaSAlexander Kozyrev * Get meter policy object for a given meter policy ID. 704ece19ccaSAlexander Kozyrev * 705ece19ccaSAlexander Kozyrev * @param[in] port_id 706ece19ccaSAlexander Kozyrev * The port identifier of the Ethernet device. 707ece19ccaSAlexander Kozyrev * @param[in] policy_id 708ece19ccaSAlexander Kozyrev * Meter policy ID. Needs to be the valid. 709ece19ccaSAlexander Kozyrev * @param[out] error 710ece19ccaSAlexander Kozyrev * Error details. Filled in only on error, when not NULL. 711ece19ccaSAlexander Kozyrev * @return 712ece19ccaSAlexander Kozyrev * A valid handle in case of success, NULL otherwise. 713ece19ccaSAlexander Kozyrev */ 714ece19ccaSAlexander Kozyrev __rte_experimental 715ece19ccaSAlexander Kozyrev struct rte_flow_meter_policy * 716ece19ccaSAlexander Kozyrev rte_mtr_meter_policy_get(uint16_t port_id, 717ece19ccaSAlexander Kozyrev uint32_t policy_id, 718ece19ccaSAlexander Kozyrev struct rte_mtr_error *error); 719ece19ccaSAlexander Kozyrev 720ece19ccaSAlexander Kozyrev /** 7215f0d54f3SLi Zhang * Define meter policy action list: 7225f0d54f3SLi Zhang * GREEN - GREEN, YELLOW - YELLOW, RED - RED 7235f0d54f3SLi Zhang */ 7245f0d54f3SLi Zhang #define rte_mtr_policy_pass_color(policy) \ 7255f0d54f3SLi Zhang struct rte_mtr_meter_policy_params policy = \ 7265f0d54f3SLi Zhang { \ 7275f0d54f3SLi Zhang .actions[RTE_COLOR_GREEN] = (struct rte_flow_action[]) { \ 7285f0d54f3SLi Zhang { \ 7295f0d54f3SLi Zhang .type = RTE_FLOW_ACTION_TYPE_METER_COLOR, \ 7305f0d54f3SLi Zhang .conf = &(struct rte_flow_action_meter_color) { \ 7315f0d54f3SLi Zhang .color = RTE_COLOR_GREEN, \ 7325f0d54f3SLi Zhang }, \ 7335f0d54f3SLi Zhang }, \ 7345f0d54f3SLi Zhang { \ 7355f0d54f3SLi Zhang .type = RTE_FLOW_ACTION_TYPE_END, \ 7365f0d54f3SLi Zhang }, \ 7375f0d54f3SLi Zhang }, \ 7385f0d54f3SLi Zhang .actions[RTE_COLOR_YELLOW] = (struct rte_flow_action[]) { \ 7395f0d54f3SLi Zhang { \ 7405f0d54f3SLi Zhang .type = RTE_FLOW_ACTION_TYPE_METER_COLOR, \ 7415f0d54f3SLi Zhang .conf = &(struct rte_flow_action_meter_color) { \ 7425f0d54f3SLi Zhang .color = RTE_COLOR_YELLOW, \ 7435f0d54f3SLi Zhang }, \ 7445f0d54f3SLi Zhang }, \ 7455f0d54f3SLi Zhang { \ 7465f0d54f3SLi Zhang .type = RTE_FLOW_ACTION_TYPE_END, \ 7475f0d54f3SLi Zhang }, \ 7485f0d54f3SLi Zhang }, \ 7495f0d54f3SLi Zhang .actions[RTE_COLOR_RED] = (struct rte_flow_action[]) { \ 7505f0d54f3SLi Zhang { \ 7515f0d54f3SLi Zhang .type = RTE_FLOW_ACTION_TYPE_METER_COLOR, \ 7525f0d54f3SLi Zhang .conf = &(struct rte_flow_action_meter_color) { \ 7535f0d54f3SLi Zhang .color = RTE_COLOR_RED, \ 7545f0d54f3SLi Zhang }, \ 7555f0d54f3SLi Zhang }, \ 7565f0d54f3SLi Zhang { \ 7575f0d54f3SLi Zhang .type = RTE_FLOW_ACTION_TYPE_END, \ 7585f0d54f3SLi Zhang }, \ 7595f0d54f3SLi Zhang }, \ 7605f0d54f3SLi Zhang } 7615f0d54f3SLi Zhang 7625f0d54f3SLi Zhang /** 7635f0d54f3SLi Zhang * Define meter policy action list: 7645f0d54f3SLi Zhang * GREEN - Do nothing, YELLOW - Do nothing, RED - DROP 7655f0d54f3SLi Zhang */ 7665f0d54f3SLi Zhang #define rte_mtr_policy_drop_red(policy) \ 7675f0d54f3SLi Zhang struct rte_mtr_meter_policy_params policy = \ 7685f0d54f3SLi Zhang { \ 7695f0d54f3SLi Zhang .actions[RTE_COLOR_GREEN] = NULL, \ 7705f0d54f3SLi Zhang .actions[RTE_COLOR_YELLOW] = NULL, \ 7715f0d54f3SLi Zhang .actions[RTE_COLOR_RED] = (struct rte_flow_action[]) { \ 7725f0d54f3SLi Zhang { \ 7735f0d54f3SLi Zhang .type = RTE_FLOW_ACTION_TYPE_DROP, \ 7745f0d54f3SLi Zhang }, \ 7755f0d54f3SLi Zhang { \ 7765f0d54f3SLi Zhang .type = RTE_FLOW_ACTION_TYPE_END, \ 7775f0d54f3SLi Zhang }, \ 7785f0d54f3SLi Zhang }, \ 7795f0d54f3SLi Zhang } 7805f0d54f3SLi Zhang 7815f0d54f3SLi Zhang /** 7825f0d54f3SLi Zhang * Meter policy delete 7835f0d54f3SLi Zhang * 7845f0d54f3SLi Zhang * Delete an existing meter policy. This operation fails when there is 7855f0d54f3SLi Zhang * currently at least one user (i.e. MTR object) of this policy. 7865f0d54f3SLi Zhang * 7875f0d54f3SLi Zhang * @param[in] port_id 7885f0d54f3SLi Zhang * The port identifier of the Ethernet device. 7895f0d54f3SLi Zhang * @param[in] policy_id 7905f0d54f3SLi Zhang * Policy identifier. 7915f0d54f3SLi Zhang * @param[out] error 7925f0d54f3SLi Zhang * Error details. Filled in only on error, when not NULL. 7935f0d54f3SLi Zhang * @return 7945f0d54f3SLi Zhang * 0 on success, non-zero error code otherwise. 7955f0d54f3SLi Zhang */ 7965f0d54f3SLi Zhang __rte_experimental 7975f0d54f3SLi Zhang int 7985f0d54f3SLi Zhang rte_mtr_meter_policy_delete(uint16_t port_id, 7995f0d54f3SLi Zhang uint32_t policy_id, 8005f0d54f3SLi Zhang struct rte_mtr_error *error); 8015f0d54f3SLi Zhang 8025f0d54f3SLi Zhang /** 80399a2dd95SBruce Richardson * MTR object create 80499a2dd95SBruce Richardson * 80599a2dd95SBruce Richardson * Create a new MTR object for the current port. This object is run as part of 80699a2dd95SBruce Richardson * associated flow action for traffic metering and policing. 80799a2dd95SBruce Richardson * 80899a2dd95SBruce Richardson * @param[in] port_id 80999a2dd95SBruce Richardson * The port identifier of the Ethernet device. 81099a2dd95SBruce Richardson * @param[in] mtr_id 81199a2dd95SBruce Richardson * MTR object ID. Needs to be unused by any of the existing MTR objects. 81299a2dd95SBruce Richardson * created for the current port. 81399a2dd95SBruce Richardson * @param[in] params 81499a2dd95SBruce Richardson * MTR object params. Needs to be pre-allocated and valid. 81599a2dd95SBruce Richardson * @param[in] shared 81699a2dd95SBruce Richardson * Non-zero when this MTR object can be shared by multiple flows, zero when 81799a2dd95SBruce Richardson * this MTR object can be used by a single flow. 81899a2dd95SBruce Richardson * @param[out] error 81999a2dd95SBruce Richardson * Error details. Filled in only on error, when not NULL. 82099a2dd95SBruce Richardson * @return 82199a2dd95SBruce Richardson * 0 on success, non-zero error code otherwise. 82299a2dd95SBruce Richardson * 82399a2dd95SBruce Richardson * @see enum rte_flow_action_type::RTE_FLOW_ACTION_TYPE_METER 82499a2dd95SBruce Richardson */ 82599a2dd95SBruce Richardson __rte_experimental 82699a2dd95SBruce Richardson int 82799a2dd95SBruce Richardson rte_mtr_create(uint16_t port_id, 82899a2dd95SBruce Richardson uint32_t mtr_id, 82999a2dd95SBruce Richardson struct rte_mtr_params *params, 83099a2dd95SBruce Richardson int shared, 83199a2dd95SBruce Richardson struct rte_mtr_error *error); 83299a2dd95SBruce Richardson 83399a2dd95SBruce Richardson /** 83499a2dd95SBruce Richardson * MTR object destroy 83599a2dd95SBruce Richardson * 83699a2dd95SBruce Richardson * Delete an existing MTR object. This operation fails when there is currently 83799a2dd95SBruce Richardson * at least one user (i.e. flow) of this MTR object. 83899a2dd95SBruce Richardson * 83999a2dd95SBruce Richardson * @param[in] port_id 84099a2dd95SBruce Richardson * The port identifier of the Ethernet device. 84199a2dd95SBruce Richardson * @param[in] mtr_id 84299a2dd95SBruce Richardson * MTR object ID. Needs to be valid. 84399a2dd95SBruce Richardson * created for the current port. 84499a2dd95SBruce Richardson * @param[out] error 84599a2dd95SBruce Richardson * Error details. Filled in only on error, when not NULL. 84699a2dd95SBruce Richardson * @return 84799a2dd95SBruce Richardson * 0 on success, non-zero error code otherwise. 84899a2dd95SBruce Richardson */ 84999a2dd95SBruce Richardson __rte_experimental 85099a2dd95SBruce Richardson int 85199a2dd95SBruce Richardson rte_mtr_destroy(uint16_t port_id, 85299a2dd95SBruce Richardson uint32_t mtr_id, 85399a2dd95SBruce Richardson struct rte_mtr_error *error); 85499a2dd95SBruce Richardson 85599a2dd95SBruce Richardson /** 85699a2dd95SBruce Richardson * MTR object meter disable 85799a2dd95SBruce Richardson * 85899a2dd95SBruce Richardson * Disable the meter of an existing MTR object. In disabled state, the meter of 85999a2dd95SBruce Richardson * the current MTR object works in pass-through mode, meaning that for each 86099a2dd95SBruce Richardson * input packet the meter output color is always the same as the input color. In 86199a2dd95SBruce Richardson * particular, when the meter of the current MTR object is configured in color 86299a2dd95SBruce Richardson * blind mode, the input color is always green, so the meter output color is 86399a2dd95SBruce Richardson * also always green. Note that the policer and the statistics of the current 86499a2dd95SBruce Richardson * MTR object are working as usual while the meter is disabled. No action is 86599a2dd95SBruce Richardson * taken and this function returns successfully when the meter of the current 86699a2dd95SBruce Richardson * MTR object is already disabled. 86799a2dd95SBruce Richardson * 86899a2dd95SBruce Richardson * @param[in] port_id 86999a2dd95SBruce Richardson * The port identifier of the Ethernet device. 87099a2dd95SBruce Richardson * @param[in] mtr_id 87199a2dd95SBruce Richardson * MTR object ID. 87299a2dd95SBruce Richardson * @param[out] error 87399a2dd95SBruce Richardson * Error details. Filled in only on error, when not NULL. 87499a2dd95SBruce Richardson * @return 87599a2dd95SBruce Richardson * 0 on success, non-zero error code otherwise. 87699a2dd95SBruce Richardson */ 87799a2dd95SBruce Richardson __rte_experimental 87899a2dd95SBruce Richardson int 87999a2dd95SBruce Richardson rte_mtr_meter_disable(uint16_t port_id, 88099a2dd95SBruce Richardson uint32_t mtr_id, 88199a2dd95SBruce Richardson struct rte_mtr_error *error); 88299a2dd95SBruce Richardson 88399a2dd95SBruce Richardson /** 88499a2dd95SBruce Richardson * MTR object meter enable 88599a2dd95SBruce Richardson * 88699a2dd95SBruce Richardson * Enable the meter of an existing MTR object. If the MTR object has its meter 88799a2dd95SBruce Richardson * already enabled, then no action is taken and this function returns 88899a2dd95SBruce Richardson * successfully. 88999a2dd95SBruce Richardson * 89099a2dd95SBruce Richardson * @param[in] port_id 89199a2dd95SBruce Richardson * The port identifier of the Ethernet device. 89299a2dd95SBruce Richardson * @param[in] mtr_id 89399a2dd95SBruce Richardson * MTR object ID. 89499a2dd95SBruce Richardson * @param[out] error 89599a2dd95SBruce Richardson * Error details. Filled in only on error, when not NULL. 89699a2dd95SBruce Richardson * @return 89799a2dd95SBruce Richardson * 0 on success, non-zero error code otherwise. 89899a2dd95SBruce Richardson */ 89999a2dd95SBruce Richardson __rte_experimental 90099a2dd95SBruce Richardson int 90199a2dd95SBruce Richardson rte_mtr_meter_enable(uint16_t port_id, 90299a2dd95SBruce Richardson uint32_t mtr_id, 90399a2dd95SBruce Richardson struct rte_mtr_error *error); 90499a2dd95SBruce Richardson 90599a2dd95SBruce Richardson /** 90699a2dd95SBruce Richardson * MTR object meter profile update 90799a2dd95SBruce Richardson * 90899a2dd95SBruce Richardson * @param[in] port_id 90999a2dd95SBruce Richardson * The port identifier of the Ethernet device. 91099a2dd95SBruce Richardson * @param[in] mtr_id 91199a2dd95SBruce Richardson * MTR object ID. Needs to be valid. 91299a2dd95SBruce Richardson * @param[in] meter_profile_id 91399a2dd95SBruce Richardson * Meter profile ID for the current MTR object. Needs to be valid. 91499a2dd95SBruce Richardson * @param[out] error 91599a2dd95SBruce Richardson * Error details. Filled in only on error, when not NULL. 91699a2dd95SBruce Richardson * @return 91799a2dd95SBruce Richardson * 0 on success, non-zero error code otherwise. 91899a2dd95SBruce Richardson */ 91999a2dd95SBruce Richardson __rte_experimental 92099a2dd95SBruce Richardson int 92199a2dd95SBruce Richardson rte_mtr_meter_profile_update(uint16_t port_id, 92299a2dd95SBruce Richardson uint32_t mtr_id, 92399a2dd95SBruce Richardson uint32_t meter_profile_id, 92499a2dd95SBruce Richardson struct rte_mtr_error *error); 92599a2dd95SBruce Richardson 92699a2dd95SBruce Richardson /** 9275f0d54f3SLi Zhang * MTR object meter policy update 9285f0d54f3SLi Zhang * 9295f0d54f3SLi Zhang * @param[in] port_id 9305f0d54f3SLi Zhang * The port identifier of the Ethernet device. 9315f0d54f3SLi Zhang * @param[in] mtr_id 9325f0d54f3SLi Zhang * MTR object ID. Needs to be valid. 9335f0d54f3SLi Zhang * @param[in] meter_policy_id 9345f0d54f3SLi Zhang * Meter policy ID for the current MTR object. Needs to be valid. 9355f0d54f3SLi Zhang * @param[out] error 9365f0d54f3SLi Zhang * Error details. Filled in only on error, when not NULL. 9375f0d54f3SLi Zhang * @return 9385f0d54f3SLi Zhang * 0 on success, non-zero error code otherwise. 9395f0d54f3SLi Zhang */ 9405f0d54f3SLi Zhang __rte_experimental 9415f0d54f3SLi Zhang int 9425f0d54f3SLi Zhang rte_mtr_meter_policy_update(uint16_t port_id, 9435f0d54f3SLi Zhang uint32_t mtr_id, 9445f0d54f3SLi Zhang uint32_t meter_policy_id, 9455f0d54f3SLi Zhang struct rte_mtr_error *error); 9465f0d54f3SLi Zhang 9475f0d54f3SLi Zhang /** 94899a2dd95SBruce Richardson * MTR object DSCP table update 94999a2dd95SBruce Richardson * 95099a2dd95SBruce Richardson * @param[in] port_id 95199a2dd95SBruce Richardson * The port identifier of the Ethernet device. 95299a2dd95SBruce Richardson * @param[in] mtr_id 95399a2dd95SBruce Richardson * MTR object ID. Needs to be valid. 954*204daeeaSSunil Kumar Kori * @param[in] proto 955*204daeeaSSunil Kumar Kori * Input color protocol. 95699a2dd95SBruce Richardson * @param[in] dscp_table 95799a2dd95SBruce Richardson * When non-NULL: it points to a pre-allocated and pre-populated table with 95899a2dd95SBruce Richardson * exactly 64 elements providing the input color for each value of the 95999a2dd95SBruce Richardson * IPv4/IPv6 Differentiated Services Code Point (DSCP) input packet field. 9605f0d54f3SLi Zhang * When NULL: it is equivalent to setting this parameter to an "all-green" 96199a2dd95SBruce Richardson * populated table (i.e. table with all the 64 elements set to green color). 96299a2dd95SBruce Richardson * @param[out] error 96399a2dd95SBruce Richardson * Error details. Filled in only on error, when not NULL. 96499a2dd95SBruce Richardson * @return 96599a2dd95SBruce Richardson * 0 on success, non-zero error code otherwise. 96699a2dd95SBruce Richardson */ 96799a2dd95SBruce Richardson __rte_experimental 96899a2dd95SBruce Richardson int 96999a2dd95SBruce Richardson rte_mtr_meter_dscp_table_update(uint16_t port_id, 970*204daeeaSSunil Kumar Kori uint32_t mtr_id, enum rte_mtr_color_in_protocol proto, 97199a2dd95SBruce Richardson enum rte_color *dscp_table, 97299a2dd95SBruce Richardson struct rte_mtr_error *error); 97399a2dd95SBruce Richardson 97499a2dd95SBruce Richardson /** 975d04fb3b5SJerin Jacob * MTR object VLAN table update 976d04fb3b5SJerin Jacob * 977d04fb3b5SJerin Jacob * @param[in] port_id 978d04fb3b5SJerin Jacob * The port identifier of the Ethernet device. 979d04fb3b5SJerin Jacob * @param[in] mtr_id 980d04fb3b5SJerin Jacob * MTR object ID. Needs to be valid. 981*204daeeaSSunil Kumar Kori * @param[in] proto 982*204daeeaSSunil Kumar Kori * Input color protocol. 983d04fb3b5SJerin Jacob * @param[in] vlan_table 984d04fb3b5SJerin Jacob * When non-NULL: it points to a pre-allocated and pre-populated table with 985d04fb3b5SJerin Jacob * exactly 16 elements providing the input color for each value of the 986d04fb3b5SJerin Jacob * each value of the DEI(1bit), PCP(3 bits) input packet field. 987d04fb3b5SJerin Jacob * When NULL: it is equivalent to setting this parameter to an "all-green" 988d04fb3b5SJerin Jacob * populated table (i.e. table with all the 16 elements set to green color). 989d04fb3b5SJerin Jacob * @param[out] error 990d04fb3b5SJerin Jacob * Error details. Filled in only on error, when not NULL. 991d04fb3b5SJerin Jacob * @return 992d04fb3b5SJerin Jacob * 0 on success, non-zero error code otherwise. 993d04fb3b5SJerin Jacob */ 994d04fb3b5SJerin Jacob __rte_experimental 995d04fb3b5SJerin Jacob int 996d04fb3b5SJerin Jacob rte_mtr_meter_vlan_table_update(uint16_t port_id, uint32_t mtr_id, 997*204daeeaSSunil Kumar Kori enum rte_mtr_color_in_protocol proto, 998d04fb3b5SJerin Jacob enum rte_color *vlan_table, 999d04fb3b5SJerin Jacob struct rte_mtr_error *error); 1000d04fb3b5SJerin Jacob 1001d04fb3b5SJerin Jacob /** 1002d04fb3b5SJerin Jacob * Set the input color protocol for a given MTR object 1003d04fb3b5SJerin Jacob * 1004d04fb3b5SJerin Jacob * More than one of the method can be enabled for a given meter. 1005d04fb3b5SJerin Jacob * Even if enabled, a method might not be applicable to each input packet, 1006d04fb3b5SJerin Jacob * in case the associated protocol header is not present in the packet. 1007d04fb3b5SJerin Jacob * The highest priority method that is both enabled for the meter and also 1008d04fb3b5SJerin Jacob * applicable for the current input packet wins; 1009d04fb3b5SJerin Jacob * if none is both enabled and applicable, the default input color is used. 1010d04fb3b5SJerin Jacob * 1011d04fb3b5SJerin Jacob * @param[in] port_id 1012d04fb3b5SJerin Jacob * The port identifier of the Ethernet device. 1013d04fb3b5SJerin Jacob * @param[in] mtr_id 1014d04fb3b5SJerin Jacob * MTR object ID. Needs to be valid. 1015d04fb3b5SJerin Jacob * @param[in] proto 1016d04fb3b5SJerin Jacob * Input color protocol. 1017d04fb3b5SJerin Jacob * @param[in] priority 1018d04fb3b5SJerin Jacob * Input color protocol priority. Value zero indicates 1019d04fb3b5SJerin Jacob * the highest priority. 1020d04fb3b5SJerin Jacob * @param[out] error 1021d04fb3b5SJerin Jacob * Error details. Filled in only on error, when not NULL. 1022d04fb3b5SJerin Jacob * @return 1023d04fb3b5SJerin Jacob * 0 on success, non-zero error code otherwise. 1024d04fb3b5SJerin Jacob */ 1025d04fb3b5SJerin Jacob __rte_experimental 1026d04fb3b5SJerin Jacob int 1027d04fb3b5SJerin Jacob rte_mtr_color_in_protocol_set(uint16_t port_id, uint32_t mtr_id, 1028d04fb3b5SJerin Jacob enum rte_mtr_color_in_protocol proto, uint32_t priority, 1029d04fb3b5SJerin Jacob struct rte_mtr_error *error); 1030d04fb3b5SJerin Jacob 1031d04fb3b5SJerin Jacob /** 1032d04fb3b5SJerin Jacob * Get the input color protocol for a given MTR object 1033d04fb3b5SJerin Jacob * 1034d04fb3b5SJerin Jacob * @param[in] port_id 1035d04fb3b5SJerin Jacob * The port identifier of the Ethernet device. 1036d04fb3b5SJerin Jacob * @param[in] mtr_id 1037d04fb3b5SJerin Jacob * MTR object ID. Needs to be valid. 1038d04fb3b5SJerin Jacob * @param[out] proto_mask 1039d04fb3b5SJerin Jacob * Selected input color protocols as bit mask. 1040d04fb3b5SJerin Jacob * @param[out] error 1041d04fb3b5SJerin Jacob * Error details. Filled in only on error, when not NULL. 1042d04fb3b5SJerin Jacob * @return 1043d04fb3b5SJerin Jacob * 0 on success, non-zero error code otherwise. 1044d04fb3b5SJerin Jacob */ 1045d04fb3b5SJerin Jacob __rte_experimental 1046d04fb3b5SJerin Jacob int 1047d04fb3b5SJerin Jacob rte_mtr_color_in_protocol_get(uint16_t port_id, uint32_t mtr_id, 1048d04fb3b5SJerin Jacob uint64_t *proto_mask, 1049d04fb3b5SJerin Jacob struct rte_mtr_error *error); 1050d04fb3b5SJerin Jacob 1051d04fb3b5SJerin Jacob /** 1052d04fb3b5SJerin Jacob * Get the priority associated with input color protocol for a given MTR object 1053d04fb3b5SJerin Jacob * 1054d04fb3b5SJerin Jacob * @param[in] port_id 1055d04fb3b5SJerin Jacob * The port identifier of the Ethernet device. 1056d04fb3b5SJerin Jacob * @param[in] mtr_id 1057d04fb3b5SJerin Jacob * MTR object ID. Needs to be valid. 1058d04fb3b5SJerin Jacob * @param[in] proto 1059d04fb3b5SJerin Jacob * Input color protocol. 1060d04fb3b5SJerin Jacob * @param[out] priority 1061d04fb3b5SJerin Jacob * Input color protocol priority associated with proto. 1062d04fb3b5SJerin Jacob * @param[out] error 1063d04fb3b5SJerin Jacob * Error details. Filled in only on error, when not NULL. 1064d04fb3b5SJerin Jacob * @return 1065d04fb3b5SJerin Jacob * 0 on success, non-zero error code otherwise. 1066d04fb3b5SJerin Jacob */ 1067d04fb3b5SJerin Jacob __rte_experimental 1068d04fb3b5SJerin Jacob int 1069d04fb3b5SJerin Jacob rte_mtr_color_in_protocol_priority_get(uint16_t port_id, uint32_t mtr_id, 1070d04fb3b5SJerin Jacob enum rte_mtr_color_in_protocol proto, uint32_t *priority, 1071d04fb3b5SJerin Jacob struct rte_mtr_error *error); 1072d04fb3b5SJerin Jacob 1073d04fb3b5SJerin Jacob /** 107499a2dd95SBruce Richardson * MTR object enabled statistics counters update 107599a2dd95SBruce Richardson * 107699a2dd95SBruce Richardson * @param[in] port_id 107799a2dd95SBruce Richardson * The port identifier of the Ethernet device. 107899a2dd95SBruce Richardson * @param[in] mtr_id 107999a2dd95SBruce Richardson * MTR object ID. Needs to be valid. 108099a2dd95SBruce Richardson * @param[in] stats_mask 108199a2dd95SBruce Richardson * Mask of statistics counter types to be enabled for the current MTR object. 108299a2dd95SBruce Richardson * Any statistics counter type not included in this set is to be disabled for 108399a2dd95SBruce Richardson * the current MTR object. 108499a2dd95SBruce Richardson * @param[out] error 108599a2dd95SBruce Richardson * Error details. Filled in only on error, when not NULL. 108699a2dd95SBruce Richardson * @return 108799a2dd95SBruce Richardson * 0 on success, non-zero error code otherwise. 108899a2dd95SBruce Richardson * 108999a2dd95SBruce Richardson * @see enum rte_mtr_stats_type 109099a2dd95SBruce Richardson */ 109199a2dd95SBruce Richardson __rte_experimental 109299a2dd95SBruce Richardson int 109399a2dd95SBruce Richardson rte_mtr_stats_update(uint16_t port_id, 109499a2dd95SBruce Richardson uint32_t mtr_id, 109599a2dd95SBruce Richardson uint64_t stats_mask, 109699a2dd95SBruce Richardson struct rte_mtr_error *error); 109799a2dd95SBruce Richardson 109899a2dd95SBruce Richardson /** 109999a2dd95SBruce Richardson * MTR object statistics counters read 110099a2dd95SBruce Richardson * 110199a2dd95SBruce Richardson * @param[in] port_id 110299a2dd95SBruce Richardson * The port identifier of the Ethernet device. 110399a2dd95SBruce Richardson * @param[in] mtr_id 110499a2dd95SBruce Richardson * MTR object ID. Needs to be valid. 110599a2dd95SBruce Richardson * @param[out] stats 110699a2dd95SBruce Richardson * When non-NULL, it contains the current value for the statistics counters 110799a2dd95SBruce Richardson * enabled for the current MTR object. 110899a2dd95SBruce Richardson * @param[out] stats_mask 110999a2dd95SBruce Richardson * When non-NULL, it contains the mask of statistics counter types that are 111099a2dd95SBruce Richardson * currently enabled for this MTR object, indicating which of the counters 111199a2dd95SBruce Richardson * retrieved with the *stats* structure are valid. 111299a2dd95SBruce Richardson * @param[in] clear 111399a2dd95SBruce Richardson * When this parameter has a non-zero value, the statistics counters are 111499a2dd95SBruce Richardson * cleared (i.e. set to zero) immediately after they have been read, 111599a2dd95SBruce Richardson * otherwise the statistics counters are left untouched. 111699a2dd95SBruce Richardson * @param[out] error 111799a2dd95SBruce Richardson * Error details. Filled in only on error, when not NULL. 111899a2dd95SBruce Richardson * @return 111999a2dd95SBruce Richardson * 0 on success, non-zero error code otherwise. 112099a2dd95SBruce Richardson * 112199a2dd95SBruce Richardson * @see enum rte_mtr_stats_type 112299a2dd95SBruce Richardson */ 112399a2dd95SBruce Richardson __rte_experimental 112499a2dd95SBruce Richardson int 112599a2dd95SBruce Richardson rte_mtr_stats_read(uint16_t port_id, 112699a2dd95SBruce Richardson uint32_t mtr_id, 112799a2dd95SBruce Richardson struct rte_mtr_stats *stats, 112899a2dd95SBruce Richardson uint64_t *stats_mask, 112999a2dd95SBruce Richardson int clear, 113099a2dd95SBruce Richardson struct rte_mtr_error *error); 113199a2dd95SBruce Richardson 113299a2dd95SBruce Richardson #ifdef __cplusplus 113399a2dd95SBruce Richardson } 113499a2dd95SBruce Richardson #endif 113599a2dd95SBruce Richardson 113699a2dd95SBruce Richardson #endif /* __INCLUDE_RTE_MTR_H__ */ 1137