DPDK 22.11.7
rte_mtr.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2017 Intel Corporation
3 * Copyright 2017 NXP
4 * Copyright 2017 Cavium
5 */
6
7#ifndef __INCLUDE_RTE_MTR_H__
8#define __INCLUDE_RTE_MTR_H__
9
48#include <stdint.h>
49#include <rte_compat.h>
50#include <rte_common.h>
51#include <rte_meter.h>
52#include <rte_flow.h>
53
54#ifdef __cplusplus
55extern "C" {
56#endif
57
64
67
70
73
76
79
82
85};
86
92 uint64_t n_pkts[RTE_COLORS];
93
96
99
102};
103
114
117
120
123};
124
131
133 union {
135 struct {
140 uint64_t cir;
141
143 uint64_t cbs;
144
146 uint64_t ebs;
148
150 struct {
155 uint64_t cir;
156
161 uint64_t pir;
162
164 uint64_t cbs;
165
167 uint64_t pbs;
169
171 struct {
176 uint64_t cir;
177
182 uint64_t eir;
183
185 uint64_t cbs;
186
188 uint64_t ebs;
190 };
191
201};
202
214};
215
259};
260
269
280
339
343 uint64_t stats_mask;
344
347
353};
354
360 uint32_t n_max;
361
366 uint32_t n_shared_max;
367
372
377
383
389
401
412
418
424
430
437
444
450
456
462
469
476
483
490
497
504
508 uint64_t stats_mask;
509
514
519};
520
530 RTE_MTR_ERROR_TYPE_METER_PROFILE_ID,
531 RTE_MTR_ERROR_TYPE_METER_PROFILE,
532 RTE_MTR_ERROR_TYPE_METER_PROFILE_PACKET_MODE,
533 RTE_MTR_ERROR_TYPE_MTR_ID,
534 RTE_MTR_ERROR_TYPE_MTR_PARAMS,
535 RTE_MTR_ERROR_TYPE_POLICER_ACTION_GREEN,
536 RTE_MTR_ERROR_TYPE_POLICER_ACTION_YELLOW,
537 RTE_MTR_ERROR_TYPE_POLICER_ACTION_RED,
538 RTE_MTR_ERROR_TYPE_STATS_MASK,
539 RTE_MTR_ERROR_TYPE_STATS,
540 RTE_MTR_ERROR_TYPE_SHARED,
541 RTE_MTR_ERROR_TYPE_METER_POLICY_ID,
542 RTE_MTR_ERROR_TYPE_METER_POLICY,
543};
544
558 const void *cause;
559 const char *message;
560};
561
574__rte_experimental
575int
577 struct rte_mtr_capabilities *cap,
578 struct rte_mtr_error *error);
579
598__rte_experimental
599int
601 uint32_t meter_profile_id,
602 struct rte_mtr_meter_profile *profile,
603 struct rte_mtr_error *error);
604
620__rte_experimental
621int
623 uint32_t meter_profile_id,
624 struct rte_mtr_error *error);
625
640__rte_experimental
641struct rte_flow_meter_profile *
643 uint32_t meter_profile_id,
644 struct rte_mtr_error *error);
645
668__rte_experimental
669int
671 struct rte_mtr_meter_policy_params *policy,
672 struct rte_mtr_error *error);
673
695__rte_experimental
696int
698 uint32_t policy_id,
699 struct rte_mtr_meter_policy_params *policy,
700 struct rte_mtr_error *error);
701
716__rte_experimental
717struct rte_flow_meter_policy *
719 uint32_t policy_id,
720 struct rte_mtr_error *error);
721
726#define rte_mtr_policy_pass_color(policy) \
727struct rte_mtr_meter_policy_params policy = \
728{ \
729 .actions[RTE_COLOR_GREEN] = (struct rte_flow_action[]) { \
730 { \
731 .type = RTE_FLOW_ACTION_TYPE_METER_COLOR, \
732 .conf = &(struct rte_flow_action_meter_color) { \
733 .color = RTE_COLOR_GREEN, \
734 }, \
735 }, \
736 { \
737 .type = RTE_FLOW_ACTION_TYPE_END, \
738 }, \
739 }, \
740 .actions[RTE_COLOR_YELLOW] = (struct rte_flow_action[]) { \
741 { \
742 .type = RTE_FLOW_ACTION_TYPE_METER_COLOR, \
743 .conf = &(struct rte_flow_action_meter_color) { \
744 .color = RTE_COLOR_YELLOW, \
745 }, \
746 }, \
747 { \
748 .type = RTE_FLOW_ACTION_TYPE_END, \
749 }, \
750 }, \
751 .actions[RTE_COLOR_RED] = (struct rte_flow_action[]) { \
752 { \
753 .type = RTE_FLOW_ACTION_TYPE_METER_COLOR, \
754 .conf = &(struct rte_flow_action_meter_color) { \
755 .color = RTE_COLOR_RED, \
756 }, \
757 }, \
758 { \
759 .type = RTE_FLOW_ACTION_TYPE_END, \
760 }, \
761 }, \
762}
763
768#define rte_mtr_policy_drop_red(policy) \
769struct rte_mtr_meter_policy_params policy = \
770{ \
771 .actions[RTE_COLOR_GREEN] = NULL, \
772 .actions[RTE_COLOR_YELLOW] = NULL, \
773 .actions[RTE_COLOR_RED] = (struct rte_flow_action[]) { \
774 { \
775 .type = RTE_FLOW_ACTION_TYPE_DROP, \
776 }, \
777 { \
778 .type = RTE_FLOW_ACTION_TYPE_END, \
779 }, \
780 }, \
781}
782
798__rte_experimental
799int
801 uint32_t policy_id,
802 struct rte_mtr_error *error);
803
827__rte_experimental
828int
829rte_mtr_create(uint16_t port_id,
830 uint32_t mtr_id,
831 struct rte_mtr_params *params,
832 int shared,
833 struct rte_mtr_error *error);
834
851__rte_experimental
852int
853rte_mtr_destroy(uint16_t port_id,
854 uint32_t mtr_id,
855 struct rte_mtr_error *error);
856
879__rte_experimental
880int
881rte_mtr_meter_disable(uint16_t port_id,
882 uint32_t mtr_id,
883 struct rte_mtr_error *error);
884
901__rte_experimental
902int
903rte_mtr_meter_enable(uint16_t port_id,
904 uint32_t mtr_id,
905 struct rte_mtr_error *error);
906
921__rte_experimental
922int
924 uint32_t mtr_id,
925 uint32_t meter_profile_id,
926 struct rte_mtr_error *error);
927
942__rte_experimental
943int
945 uint32_t mtr_id,
946 uint32_t meter_policy_id,
947 struct rte_mtr_error *error);
948
969__rte_experimental
970int
972 uint32_t mtr_id, enum rte_mtr_color_in_protocol proto,
973 enum rte_color *dscp_table,
974 struct rte_mtr_error *error);
975
996__rte_experimental
997int
998rte_mtr_meter_vlan_table_update(uint16_t port_id, uint32_t mtr_id,
999 enum rte_mtr_color_in_protocol proto,
1000 enum rte_color *vlan_table,
1001 struct rte_mtr_error *error);
1002
1027__rte_experimental
1028int
1029rte_mtr_color_in_protocol_set(uint16_t port_id, uint32_t mtr_id,
1030 enum rte_mtr_color_in_protocol proto, uint32_t priority,
1031 struct rte_mtr_error *error);
1032
1048__rte_experimental
1049int
1050rte_mtr_color_in_protocol_get(uint16_t port_id, uint32_t mtr_id,
1051 uint64_t *proto_mask,
1052 struct rte_mtr_error *error);
1053
1070__rte_experimental
1071int
1072rte_mtr_color_in_protocol_priority_get(uint16_t port_id, uint32_t mtr_id,
1073 enum rte_mtr_color_in_protocol proto, uint32_t *priority,
1074 struct rte_mtr_error *error);
1075
1094__rte_experimental
1095int
1096rte_mtr_stats_update(uint16_t port_id,
1097 uint32_t mtr_id,
1098 uint64_t stats_mask,
1099 struct rte_mtr_error *error);
1100
1126__rte_experimental
1127int
1128rte_mtr_stats_read(uint16_t port_id,
1129 uint32_t mtr_id,
1130 struct rte_mtr_stats *stats,
1131 uint64_t *stats_mask,
1132 int clear,
1133 struct rte_mtr_error *error);
1134
1135#ifdef __cplusplus
1136}
1137#endif
1138
1139#endif /* __INCLUDE_RTE_MTR_H__ */
#define RTE_BIT64(nr)
Definition: rte_bitops.h:30
#define RTE_STD_C11
Definition: rte_common.h:39
rte_color
Definition: rte_meter.h:35
@ RTE_COLORS
Definition: rte_meter.h:39
__rte_experimental int rte_mtr_destroy(uint16_t port_id, uint32_t mtr_id, struct rte_mtr_error *error)
__rte_experimental int rte_mtr_meter_policy_delete(uint16_t port_id, uint32_t policy_id, struct rte_mtr_error *error)
__rte_experimental int rte_mtr_stats_read(uint16_t port_id, uint32_t mtr_id, struct rte_mtr_stats *stats, uint64_t *stats_mask, int clear, struct rte_mtr_error *error)
__rte_experimental int rte_mtr_meter_vlan_table_update(uint16_t port_id, uint32_t mtr_id, enum rte_mtr_color_in_protocol proto, enum rte_color *vlan_table, struct rte_mtr_error *error)
__rte_experimental int rte_mtr_meter_profile_update(uint16_t port_id, uint32_t mtr_id, uint32_t meter_profile_id, struct rte_mtr_error *error)
__rte_experimental int rte_mtr_color_in_protocol_set(uint16_t port_id, uint32_t mtr_id, enum rte_mtr_color_in_protocol proto, uint32_t priority, struct rte_mtr_error *error)
__rte_experimental int rte_mtr_meter_profile_delete(uint16_t port_id, uint32_t meter_profile_id, struct rte_mtr_error *error)
__rte_experimental struct rte_flow_meter_policy * rte_mtr_meter_policy_get(uint16_t port_id, uint32_t policy_id, struct rte_mtr_error *error)
__rte_experimental int rte_mtr_meter_policy_update(uint16_t port_id, uint32_t mtr_id, uint32_t meter_policy_id, struct rte_mtr_error *error)
rte_mtr_stats_type
Definition: rte_mtr.h:61
@ RTE_MTR_STATS_N_BYTES_GREEN
Definition: rte_mtr.h:75
@ RTE_MTR_STATS_N_PKTS_GREEN
Definition: rte_mtr.h:63
@ RTE_MTR_STATS_N_PKTS_RED
Definition: rte_mtr.h:69
@ RTE_MTR_STATS_N_BYTES_YELLOW
Definition: rte_mtr.h:78
@ RTE_MTR_STATS_N_PKTS_YELLOW
Definition: rte_mtr.h:66
@ RTE_MTR_STATS_N_PKTS_DROPPED
Definition: rte_mtr.h:72
@ RTE_MTR_STATS_N_BYTES_RED
Definition: rte_mtr.h:81
@ RTE_MTR_STATS_N_BYTES_DROPPED
Definition: rte_mtr.h:84
__rte_experimental int rte_mtr_stats_update(uint16_t port_id, uint32_t mtr_id, uint64_t stats_mask, struct rte_mtr_error *error)
__rte_experimental int rte_mtr_meter_profile_add(uint16_t port_id, uint32_t meter_profile_id, struct rte_mtr_meter_profile *profile, struct rte_mtr_error *error)
__rte_experimental int rte_mtr_create(uint16_t port_id, uint32_t mtr_id, struct rte_mtr_params *params, int shared, struct rte_mtr_error *error)
__rte_experimental int rte_mtr_color_in_protocol_priority_get(uint16_t port_id, uint32_t mtr_id, enum rte_mtr_color_in_protocol proto, uint32_t *priority, struct rte_mtr_error *error)
__rte_experimental struct rte_flow_meter_profile * rte_mtr_meter_profile_get(uint16_t port_id, uint32_t meter_profile_id, struct rte_mtr_error *error)
__rte_experimental int rte_mtr_color_in_protocol_get(uint16_t port_id, uint32_t mtr_id, uint64_t *proto_mask, struct rte_mtr_error *error)
__rte_experimental int rte_mtr_meter_policy_validate(uint16_t port_id, struct rte_mtr_meter_policy_params *policy, struct rte_mtr_error *error)
rte_mtr_algorithm
Definition: rte_mtr.h:107
@ RTE_MTR_SRTCM_RFC2697
Definition: rte_mtr.h:116
@ RTE_MTR_TRTCM_RFC4115
Definition: rte_mtr.h:122
@ RTE_MTR_NONE
Definition: rte_mtr.h:113
@ RTE_MTR_TRTCM_RFC2698
Definition: rte_mtr.h:119
__rte_experimental int rte_mtr_meter_policy_add(uint16_t port_id, uint32_t policy_id, struct rte_mtr_meter_policy_params *policy, struct rte_mtr_error *error)
rte_mtr_error_type
Definition: rte_mtr.h:527
@ RTE_MTR_ERROR_TYPE_NONE
Definition: rte_mtr.h:528
@ RTE_MTR_ERROR_TYPE_UNSPECIFIED
Definition: rte_mtr.h:529
__rte_experimental int rte_mtr_meter_enable(uint16_t port_id, uint32_t mtr_id, struct rte_mtr_error *error)
__rte_experimental int rte_mtr_meter_disable(uint16_t port_id, uint32_t mtr_id, struct rte_mtr_error *error)
__rte_experimental int rte_mtr_meter_dscp_table_update(uint16_t port_id, uint32_t mtr_id, enum rte_mtr_color_in_protocol proto, enum rte_color *dscp_table, struct rte_mtr_error *error)
__rte_experimental int rte_mtr_capabilities_get(uint16_t port_id, struct rte_mtr_capabilities *cap, struct rte_mtr_error *error)
rte_mtr_color_in_protocol
Definition: rte_mtr.h:228
@ RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN
Definition: rte_mtr.h:236
@ RTE_MTR_COLOR_IN_PROTO_OUTER_IP
Definition: rte_mtr.h:251
@ RTE_MTR_COLOR_IN_PROTO_INNER_IP
Definition: rte_mtr.h:258
@ RTE_MTR_COLOR_IN_PROTO_INNER_VLAN
Definition: rte_mtr.h:244
int trtcm_rfc4115_packet_mode_supported
Definition: rte_mtr.h:503
uint32_t meter_srtcm_rfc2697_n_max
Definition: rte_mtr.h:417
int color_aware_srtcm_rfc2697_supported
Definition: rte_mtr.h:449
int trtcm_rfc2698_packet_mode_supported
Definition: rte_mtr.h:489
int chaining_use_prev_mtr_color_supported
Definition: rte_mtr.h:400
uint64_t stats_mask
Definition: rte_mtr.h:508
uint32_t shared_n_flows_per_mtr_max
Definition: rte_mtr.h:382
uint32_t meter_trtcm_rfc2698_n_max
Definition: rte_mtr.h:423
uint32_t meter_trtcm_rfc4115_n_max
Definition: rte_mtr.h:429
int color_aware_trtcm_rfc4115_supported
Definition: rte_mtr.h:461
int srtcm_rfc2697_byte_mode_supported
Definition: rte_mtr.h:468
int chaining_use_prev_mtr_color_enforced
Definition: rte_mtr.h:411
int separate_input_color_table_per_port
Definition: rte_mtr.h:518
int trtcm_rfc2698_byte_mode_supported
Definition: rte_mtr.h:482
uint64_t meter_rate_max
Definition: rte_mtr.h:436
uint32_t chaining_n_mtrs_per_flow_max
Definition: rte_mtr.h:388
int color_aware_trtcm_rfc2698_supported
Definition: rte_mtr.h:455
uint64_t meter_policy_n_max
Definition: rte_mtr.h:443
int srtcm_rfc2697_packet_mode_supported
Definition: rte_mtr.h:475
int trtcm_rfc4115_byte_mode_supported
Definition: rte_mtr.h:496
uint32_t n_shared_max
Definition: rte_mtr.h:366
uint64_t input_color_proto_mask
Definition: rte_mtr.h:513
const char * message
Definition: rte_mtr.h:559
enum rte_mtr_error_type type
Definition: rte_mtr.h:557
const void * cause
Definition: rte_mtr.h:558
const struct rte_flow_action * actions[RTE_COLORS]
Definition: rte_mtr.h:213
enum rte_mtr_algorithm alg
Definition: rte_mtr.h:130
struct rte_mtr_meter_profile::@153::@157 trtcm_rfc4115
struct rte_mtr_meter_profile::@153::@155 srtcm_rfc2697
struct rte_mtr_meter_profile::@153::@156 trtcm_rfc2698
uint32_t meter_policy_id
Definition: rte_mtr.h:346
uint32_t meter_profile_id
Definition: rte_mtr.h:268
uint64_t stats_mask
Definition: rte_mtr.h:343
enum rte_color * dscp_table
Definition: rte_mtr.h:306
int use_prev_mtr_color
Definition: rte_mtr.h:279
int meter_enable
Definition: rte_mtr.h:338
enum rte_color default_input_color
Definition: rte_mtr.h:352
enum rte_color * vlan_table
Definition: rte_mtr.h:332
uint64_t n_pkts[RTE_COLORS]
Definition: rte_mtr.h:92
uint64_t n_bytes[RTE_COLORS]
Definition: rte_mtr.h:95
uint64_t n_pkts_dropped
Definition: rte_mtr.h:98
uint64_t n_bytes_dropped
Definition: rte_mtr.h:101