DPDK 24.11.1
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
132 union {
134 struct {
139 uint64_t cir;
140
142 uint64_t cbs;
143
145 uint64_t ebs;
147
149 struct {
154 uint64_t cir;
155
160 uint64_t pir;
161
163 uint64_t cbs;
164
166 uint64_t pbs;
168
170 struct {
175 uint64_t cir;
176
181 uint64_t eir;
182
184 uint64_t cbs;
185
187 uint64_t ebs;
189 };
190
200};
201
213};
214
257};
258
267
278
337
341 uint64_t stats_mask;
342
345
351};
352
358 uint32_t n_max;
359
364 uint32_t n_shared_max;
365
370
375
381
387
399
410
416
422
428
435
442
448
454
460
467
474
481
488
495
502
506 uint64_t stats_mask;
507
512
517};
518
528 RTE_MTR_ERROR_TYPE_METER_PROFILE_ID,
529 RTE_MTR_ERROR_TYPE_METER_PROFILE,
530 RTE_MTR_ERROR_TYPE_METER_PROFILE_PACKET_MODE,
531 RTE_MTR_ERROR_TYPE_MTR_ID,
532 RTE_MTR_ERROR_TYPE_MTR_PARAMS,
533 RTE_MTR_ERROR_TYPE_POLICER_ACTION_GREEN,
534 RTE_MTR_ERROR_TYPE_POLICER_ACTION_YELLOW,
535 RTE_MTR_ERROR_TYPE_POLICER_ACTION_RED,
536 RTE_MTR_ERROR_TYPE_STATS_MASK,
537 RTE_MTR_ERROR_TYPE_STATS,
538 RTE_MTR_ERROR_TYPE_SHARED,
539 RTE_MTR_ERROR_TYPE_METER_POLICY_ID,
540 RTE_MTR_ERROR_TYPE_METER_POLICY,
541};
542
556 const void *cause;
557 const char *message;
558};
559
572__rte_experimental
573int
575 struct rte_mtr_capabilities *cap,
576 struct rte_mtr_error *error);
577
596__rte_experimental
597int
599 uint32_t meter_profile_id,
600 struct rte_mtr_meter_profile *profile,
601 struct rte_mtr_error *error);
602
618__rte_experimental
619int
621 uint32_t meter_profile_id,
622 struct rte_mtr_error *error);
623
638__rte_experimental
639struct rte_flow_meter_profile *
641 uint32_t meter_profile_id,
642 struct rte_mtr_error *error);
643
666__rte_experimental
667int
669 struct rte_mtr_meter_policy_params *policy,
670 struct rte_mtr_error *error);
671
693__rte_experimental
694int
696 uint32_t policy_id,
697 struct rte_mtr_meter_policy_params *policy,
698 struct rte_mtr_error *error);
699
714__rte_experimental
715struct rte_flow_meter_policy *
717 uint32_t policy_id,
718 struct rte_mtr_error *error);
719
724#define rte_mtr_policy_pass_color(policy) \
725struct rte_mtr_meter_policy_params policy = \
726{ \
727 .actions[RTE_COLOR_GREEN] = (struct rte_flow_action[]) { \
728 { \
729 .type = RTE_FLOW_ACTION_TYPE_METER_COLOR, \
730 .conf = &(struct rte_flow_action_meter_color) { \
731 .color = RTE_COLOR_GREEN, \
732 }, \
733 }, \
734 { \
735 .type = RTE_FLOW_ACTION_TYPE_END, \
736 }, \
737 }, \
738 .actions[RTE_COLOR_YELLOW] = (struct rte_flow_action[]) { \
739 { \
740 .type = RTE_FLOW_ACTION_TYPE_METER_COLOR, \
741 .conf = &(struct rte_flow_action_meter_color) { \
742 .color = RTE_COLOR_YELLOW, \
743 }, \
744 }, \
745 { \
746 .type = RTE_FLOW_ACTION_TYPE_END, \
747 }, \
748 }, \
749 .actions[RTE_COLOR_RED] = (struct rte_flow_action[]) { \
750 { \
751 .type = RTE_FLOW_ACTION_TYPE_METER_COLOR, \
752 .conf = &(struct rte_flow_action_meter_color) { \
753 .color = RTE_COLOR_RED, \
754 }, \
755 }, \
756 { \
757 .type = RTE_FLOW_ACTION_TYPE_END, \
758 }, \
759 }, \
760}
761
766#define rte_mtr_policy_drop_red(policy) \
767struct rte_mtr_meter_policy_params policy = \
768{ \
769 .actions[RTE_COLOR_GREEN] = NULL, \
770 .actions[RTE_COLOR_YELLOW] = NULL, \
771 .actions[RTE_COLOR_RED] = (struct rte_flow_action[]) { \
772 { \
773 .type = RTE_FLOW_ACTION_TYPE_DROP, \
774 }, \
775 { \
776 .type = RTE_FLOW_ACTION_TYPE_END, \
777 }, \
778 }, \
779}
780
796__rte_experimental
797int
799 uint32_t policy_id,
800 struct rte_mtr_error *error);
801
825__rte_experimental
826int
827rte_mtr_create(uint16_t port_id,
828 uint32_t mtr_id,
829 struct rte_mtr_params *params,
830 int shared,
831 struct rte_mtr_error *error);
832
849__rte_experimental
850int
851rte_mtr_destroy(uint16_t port_id,
852 uint32_t mtr_id,
853 struct rte_mtr_error *error);
854
877__rte_experimental
878int
879rte_mtr_meter_disable(uint16_t port_id,
880 uint32_t mtr_id,
881 struct rte_mtr_error *error);
882
899__rte_experimental
900int
901rte_mtr_meter_enable(uint16_t port_id,
902 uint32_t mtr_id,
903 struct rte_mtr_error *error);
904
919__rte_experimental
920int
922 uint32_t mtr_id,
923 uint32_t meter_profile_id,
924 struct rte_mtr_error *error);
925
940__rte_experimental
941int
943 uint32_t mtr_id,
944 uint32_t meter_policy_id,
945 struct rte_mtr_error *error);
946
967__rte_experimental
968int
970 uint32_t mtr_id, enum rte_mtr_color_in_protocol proto,
971 enum rte_color *dscp_table,
972 struct rte_mtr_error *error);
973
994__rte_experimental
995int
996rte_mtr_meter_vlan_table_update(uint16_t port_id, uint32_t mtr_id,
997 enum rte_mtr_color_in_protocol proto,
998 enum rte_color *vlan_table,
999 struct rte_mtr_error *error);
1000
1025__rte_experimental
1026int
1027rte_mtr_color_in_protocol_set(uint16_t port_id, uint32_t mtr_id,
1028 enum rte_mtr_color_in_protocol proto, uint32_t priority,
1029 struct rte_mtr_error *error);
1030
1045__rte_experimental
1046int
1047rte_mtr_color_in_protocol_get(uint16_t port_id, uint32_t mtr_id,
1048 uint64_t *proto_mask,
1049 struct rte_mtr_error *error);
1050
1067__rte_experimental
1068int
1069rte_mtr_color_in_protocol_priority_get(uint16_t port_id, uint32_t mtr_id,
1070 enum rte_mtr_color_in_protocol proto, uint32_t *priority,
1071 struct rte_mtr_error *error);
1072
1091__rte_experimental
1092int
1093rte_mtr_stats_update(uint16_t port_id,
1094 uint32_t mtr_id,
1095 uint64_t stats_mask,
1096 struct rte_mtr_error *error);
1097
1123__rte_experimental
1124int
1125rte_mtr_stats_read(uint16_t port_id,
1126 uint32_t mtr_id,
1127 struct rte_mtr_stats *stats,
1128 uint64_t *stats_mask,
1129 int clear,
1130 struct rte_mtr_error *error);
1131
1132#ifdef __cplusplus
1133}
1134#endif
1135
1136#endif /* __INCLUDE_RTE_MTR_H__ */
#define RTE_BIT64(nr)
Definition: rte_bitops.h:36
rte_color
Definition: rte_meter.h:32
@ RTE_COLORS
Definition: rte_meter.h:36
__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:525
@ RTE_MTR_ERROR_TYPE_NONE
Definition: rte_mtr.h:526
@ RTE_MTR_ERROR_TYPE_UNSPECIFIED
Definition: rte_mtr.h:527
__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:226
@ RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN
Definition: rte_mtr.h:234
@ RTE_MTR_COLOR_IN_PROTO_OUTER_IP
Definition: rte_mtr.h:249
@ RTE_MTR_COLOR_IN_PROTO_INNER_IP
Definition: rte_mtr.h:256
@ RTE_MTR_COLOR_IN_PROTO_INNER_VLAN
Definition: rte_mtr.h:242
int trtcm_rfc4115_packet_mode_supported
Definition: rte_mtr.h:501
uint32_t meter_srtcm_rfc2697_n_max
Definition: rte_mtr.h:415
int color_aware_srtcm_rfc2697_supported
Definition: rte_mtr.h:447
int trtcm_rfc2698_packet_mode_supported
Definition: rte_mtr.h:487
int chaining_use_prev_mtr_color_supported
Definition: rte_mtr.h:398
uint64_t stats_mask
Definition: rte_mtr.h:506
uint32_t shared_n_flows_per_mtr_max
Definition: rte_mtr.h:380
uint32_t meter_trtcm_rfc2698_n_max
Definition: rte_mtr.h:421
uint32_t meter_trtcm_rfc4115_n_max
Definition: rte_mtr.h:427
int color_aware_trtcm_rfc4115_supported
Definition: rte_mtr.h:459
int srtcm_rfc2697_byte_mode_supported
Definition: rte_mtr.h:466
int chaining_use_prev_mtr_color_enforced
Definition: rte_mtr.h:409
int separate_input_color_table_per_port
Definition: rte_mtr.h:516
int trtcm_rfc2698_byte_mode_supported
Definition: rte_mtr.h:480
uint64_t meter_rate_max
Definition: rte_mtr.h:434
uint32_t chaining_n_mtrs_per_flow_max
Definition: rte_mtr.h:386
int color_aware_trtcm_rfc2698_supported
Definition: rte_mtr.h:453
uint64_t meter_policy_n_max
Definition: rte_mtr.h:441
int srtcm_rfc2697_packet_mode_supported
Definition: rte_mtr.h:473
int trtcm_rfc4115_byte_mode_supported
Definition: rte_mtr.h:494
uint32_t n_shared_max
Definition: rte_mtr.h:364
uint64_t input_color_proto_mask
Definition: rte_mtr.h:511
const char * message
Definition: rte_mtr.h:557
enum rte_mtr_error_type type
Definition: rte_mtr.h:555
const void * cause
Definition: rte_mtr.h:556
const struct rte_flow_action * actions[RTE_COLORS]
Definition: rte_mtr.h:212
struct rte_mtr_meter_profile::@207::@209 srtcm_rfc2697
enum rte_mtr_algorithm alg
Definition: rte_mtr.h:130
struct rte_mtr_meter_profile::@207::@210 trtcm_rfc2698
struct rte_mtr_meter_profile::@207::@211 trtcm_rfc4115
uint32_t meter_policy_id
Definition: rte_mtr.h:344
uint32_t meter_profile_id
Definition: rte_mtr.h:266
uint64_t stats_mask
Definition: rte_mtr.h:341
enum rte_color * dscp_table
Definition: rte_mtr.h:304
int use_prev_mtr_color
Definition: rte_mtr.h:277
int meter_enable
Definition: rte_mtr.h:336
enum rte_color default_input_color
Definition: rte_mtr.h:350
enum rte_color * vlan_table
Definition: rte_mtr.h:330
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