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
55 extern "C" {
56 #endif
57 
64 
67 
70 
73 
76 
79 
82 
85 };
86 
90 struct rte_mtr_stats {
92  uint64_t n_pkts[RTE_COLORS];
93 
95  uint64_t n_bytes[RTE_COLORS];
96 
98  uint64_t n_pkts_dropped;
99 
101  uint64_t n_bytes_dropped;
102 };
103 
114 
117 
120 
123 };
124 
130  enum rte_mtr_algorithm alg;
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 
346  uint32_t meter_policy_id;
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 
436  uint64_t meter_rate_max;
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 
557  enum rte_mtr_error_type type;
558  const void *cause;
559  const char *message;
560 };
561 
574 __rte_experimental
575 int
576 rte_mtr_capabilities_get(uint16_t port_id,
577  struct rte_mtr_capabilities *cap,
578  struct rte_mtr_error *error);
579 
598 __rte_experimental
599 int
600 rte_mtr_meter_profile_add(uint16_t port_id,
601  uint32_t meter_profile_id,
602  struct rte_mtr_meter_profile *profile,
603  struct rte_mtr_error *error);
604 
620 __rte_experimental
621 int
623  uint32_t meter_profile_id,
624  struct rte_mtr_error *error);
625 
640 __rte_experimental
641 struct rte_flow_meter_profile *
642 rte_mtr_meter_profile_get(uint16_t port_id,
643  uint32_t meter_profile_id,
644  struct rte_mtr_error *error);
645 
668 __rte_experimental
669 int
671  struct rte_mtr_meter_policy_params *policy,
672  struct rte_mtr_error *error);
673 
695 __rte_experimental
696 int
697 rte_mtr_meter_policy_add(uint16_t port_id,
698  uint32_t policy_id,
699  struct rte_mtr_meter_policy_params *policy,
700  struct rte_mtr_error *error);
701 
716 __rte_experimental
717 struct rte_flow_meter_policy *
718 rte_mtr_meter_policy_get(uint16_t port_id,
719  uint32_t policy_id,
720  struct rte_mtr_error *error);
721 
726 #define rte_mtr_policy_pass_color(policy) \
727 struct 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) \
769 struct 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
799 int
801  uint32_t policy_id,
802  struct rte_mtr_error *error);
803 
827 __rte_experimental
828 int
829 rte_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
852 int
853 rte_mtr_destroy(uint16_t port_id,
854  uint32_t mtr_id,
855  struct rte_mtr_error *error);
856 
879 __rte_experimental
880 int
881 rte_mtr_meter_disable(uint16_t port_id,
882  uint32_t mtr_id,
883  struct rte_mtr_error *error);
884 
901 __rte_experimental
902 int
903 rte_mtr_meter_enable(uint16_t port_id,
904  uint32_t mtr_id,
905  struct rte_mtr_error *error);
906 
921 __rte_experimental
922 int
924  uint32_t mtr_id,
925  uint32_t meter_profile_id,
926  struct rte_mtr_error *error);
927 
942 __rte_experimental
943 int
945  uint32_t mtr_id,
946  uint32_t meter_policy_id,
947  struct rte_mtr_error *error);
948 
969 __rte_experimental
970 int
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
997 int
998 rte_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
1028 int
1029 rte_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
1049 int
1050 rte_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
1071 int
1072 rte_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
1095 int
1096 rte_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
1127 int
1128 rte_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__ */
rte_mtr_capabilities::srtcm_rfc2697_byte_mode_supported
int srtcm_rfc2697_byte_mode_supported
Definition: rte_mtr.h:468
rte_mtr_capabilities::chaining_use_prev_mtr_color_supported
int chaining_use_prev_mtr_color_supported
Definition: rte_mtr.h:400
RTE_MTR_STATS_N_PKTS_DROPPED
@ RTE_MTR_STATS_N_PKTS_DROPPED
Definition: rte_mtr.h:72
rte_mtr_params::stats_mask
uint64_t stats_mask
Definition: rte_mtr.h:343
RTE_MTR_STATS_N_BYTES_RED
@ RTE_MTR_STATS_N_BYTES_RED
Definition: rte_mtr.h:81
rte_mtr_capabilities::color_aware_trtcm_rfc4115_supported
int color_aware_trtcm_rfc4115_supported
Definition: rte_mtr.h:461
rte_mtr_capabilities::identical
int identical
Definition: rte_mtr.h:371
rte_mtr_error
Definition: rte_mtr.h:556
rte_mtr_meter_vlan_table_update
__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_MTR_ERROR_TYPE_UNSPECIFIED
@ RTE_MTR_ERROR_TYPE_UNSPECIFIED
Definition: rte_mtr.h:529
RTE_MTR_STATS_N_PKTS_RED
@ RTE_MTR_STATS_N_PKTS_RED
Definition: rte_mtr.h:69
rte_meter.h
rte_mtr_meter_profile::pbs
uint64_t pbs
Definition: rte_mtr.h:167
rte_mtr_meter_profile_get
__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_MTR_COLOR_IN_PROTO_OUTER_IP
@ RTE_MTR_COLOR_IN_PROTO_OUTER_IP
Definition: rte_mtr.h:251
rte_mtr_color_in_protocol_priority_get
__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_mtr_error::message
const char * message
Definition: rte_mtr.h:559
rte_mtr_color_in_protocol
rte_mtr_color_in_protocol
Definition: rte_mtr.h:228
rte_mtr_destroy
__rte_experimental int rte_mtr_destroy(uint16_t port_id, uint32_t mtr_id, struct rte_mtr_error *error)
rte_mtr_capabilities::meter_rate_max
uint64_t meter_rate_max
Definition: rte_mtr.h:436
rte_mtr_capabilities::stats_mask
uint64_t stats_mask
Definition: rte_mtr.h:508
rte_mtr_color_in_protocol_set
__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_mtr_stats_update
__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_MTR_COLOR_IN_PROTO_INNER_IP
@ RTE_MTR_COLOR_IN_PROTO_INNER_IP
Definition: rte_mtr.h:258
rte_mtr_stats
Definition: rte_mtr.h:90
rte_mtr_capabilities::color_aware_trtcm_rfc2698_supported
int color_aware_trtcm_rfc2698_supported
Definition: rte_mtr.h:455
rte_mtr_stats_type
rte_mtr_stats_type
Definition: rte_mtr.h:61
rte_mtr_params::use_prev_mtr_color
int use_prev_mtr_color
Definition: rte_mtr.h:279
rte_mtr_meter_policy_params
Definition: rte_mtr.h:206
rte_mtr_capabilities::meter_policy_n_max
uint64_t meter_policy_n_max
Definition: rte_mtr.h:443
rte_mtr_capabilities::color_aware_srtcm_rfc2697_supported
int color_aware_srtcm_rfc2697_supported
Definition: rte_mtr.h:449
rte_mtr_meter_profile::trtcm_rfc2698
struct rte_mtr_meter_profile::@153::@156 trtcm_rfc2698
rte_mtr_error::type
enum rte_mtr_error_type type
Definition: rte_mtr.h:557
RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN
@ RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN
Definition: rte_mtr.h:236
rte_mtr_capabilities::n_max
uint32_t n_max
Definition: rte_mtr.h:360
rte_mtr_params
Definition: rte_mtr.h:266
rte_mtr_capabilities::trtcm_rfc2698_byte_mode_supported
int trtcm_rfc2698_byte_mode_supported
Definition: rte_mtr.h:482
RTE_MTR_STATS_N_PKTS_GREEN
@ RTE_MTR_STATS_N_PKTS_GREEN
Definition: rte_mtr.h:63
rte_color
rte_color
Definition: rte_meter.h:35
rte_mtr_capabilities::meter_srtcm_rfc2697_n_max
uint32_t meter_srtcm_rfc2697_n_max
Definition: rte_mtr.h:417
rte_mtr_capabilities::input_color_proto_mask
uint64_t input_color_proto_mask
Definition: rte_mtr.h:513
rte_mtr_capabilities::chaining_use_prev_mtr_color_enforced
int chaining_use_prev_mtr_color_enforced
Definition: rte_mtr.h:411
rte_mtr_color_in_protocol_get
__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_mtr_params::vlan_table
enum rte_color * vlan_table
Definition: rte_mtr.h:332
rte_mtr_meter_profile::cbs
uint64_t cbs
Definition: rte_mtr.h:143
RTE_MTR_SRTCM_RFC2697
@ RTE_MTR_SRTCM_RFC2697
Definition: rte_mtr.h:116
rte_mtr_meter_disable
__rte_experimental int rte_mtr_meter_disable(uint16_t port_id, uint32_t mtr_id, struct rte_mtr_error *error)
rte_mtr_error_type
rte_mtr_error_type
Definition: rte_mtr.h:527
rte_mtr_capabilities::trtcm_rfc4115_packet_mode_supported
int trtcm_rfc4115_packet_mode_supported
Definition: rte_mtr.h:503
rte_mtr_meter_profile::ebs
uint64_t ebs
Definition: rte_mtr.h:146
rte_flow.h
rte_mtr_capabilities::meter_trtcm_rfc2698_n_max
uint32_t meter_trtcm_rfc2698_n_max
Definition: rte_mtr.h:423
rte_mtr_meter_profile::eir
uint64_t eir
Definition: rte_mtr.h:182
rte_mtr_meter_profile::alg
enum rte_mtr_algorithm alg
Definition: rte_mtr.h:130
rte_mtr_meter_profile_update
__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_mtr_meter_profile::pir
uint64_t pir
Definition: rte_mtr.h:161
rte_mtr_meter_policy_validate
__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_capabilities::meter_trtcm_rfc4115_n_max
uint32_t meter_trtcm_rfc4115_n_max
Definition: rte_mtr.h:429
rte_common.h
rte_mtr_algorithm
rte_mtr_algorithm
Definition: rte_mtr.h:107
rte_mtr_capabilities::shared_n_flows_per_mtr_max
uint32_t shared_n_flows_per_mtr_max
Definition: rte_mtr.h:382
RTE_MTR_TRTCM_RFC4115
@ RTE_MTR_TRTCM_RFC4115
Definition: rte_mtr.h:122
rte_mtr_capabilities::shared_identical
int shared_identical
Definition: rte_mtr.h:376
rte_mtr_meter_policy_add
__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_STATS_N_BYTES_GREEN
@ RTE_MTR_STATS_N_BYTES_GREEN
Definition: rte_mtr.h:75
rte_mtr_capabilities::n_shared_max
uint32_t n_shared_max
Definition: rte_mtr.h:366
rte_mtr_params::meter_policy_id
uint32_t meter_policy_id
Definition: rte_mtr.h:346
rte_mtr_stats_read
__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_mtr_stats::n_pkts_dropped
uint64_t n_pkts_dropped
Definition: rte_mtr.h:98
RTE_STD_C11
#define RTE_STD_C11
Definition: rte_common.h:39
rte_mtr_capabilities
Definition: rte_mtr.h:358
rte_mtr_error::cause
const void * cause
Definition: rte_mtr.h:558
rte_mtr_params::meter_enable
int meter_enable
Definition: rte_mtr.h:338
RTE_MTR_NONE
@ RTE_MTR_NONE
Definition: rte_mtr.h:113
rte_mtr_create
__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_MTR_STATS_N_PKTS_YELLOW
@ RTE_MTR_STATS_N_PKTS_YELLOW
Definition: rte_mtr.h:66
rte_mtr_meter_profile
Definition: rte_mtr.h:128
rte_mtr_capabilities::srtcm_rfc2697_packet_mode_supported
int srtcm_rfc2697_packet_mode_supported
Definition: rte_mtr.h:475
rte_mtr_capabilities::separate_input_color_table_per_port
int separate_input_color_table_per_port
Definition: rte_mtr.h:518
rte_mtr_capabilities::trtcm_rfc2698_packet_mode_supported
int trtcm_rfc2698_packet_mode_supported
Definition: rte_mtr.h:489
rte_mtr_meter_dscp_table_update
__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_mtr_meter_policy_get
__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_mtr_meter_profile_delete
__rte_experimental int rte_mtr_meter_profile_delete(uint16_t port_id, uint32_t meter_profile_id, struct rte_mtr_error *error)
RTE_MTR_TRTCM_RFC2698
@ RTE_MTR_TRTCM_RFC2698
Definition: rte_mtr.h:119
rte_mtr_meter_profile::cir
uint64_t cir
Definition: rte_mtr.h:140
rte_mtr_meter_policy_update
__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_meter_profile::srtcm_rfc2697
struct rte_mtr_meter_profile::@153::@155 srtcm_rfc2697
RTE_BIT64
#define RTE_BIT64(nr)
Definition: rte_bitops.h:30
rte_mtr_capabilities::chaining_n_mtrs_per_flow_max
uint32_t chaining_n_mtrs_per_flow_max
Definition: rte_mtr.h:388
RTE_MTR_ERROR_TYPE_NONE
@ RTE_MTR_ERROR_TYPE_NONE
Definition: rte_mtr.h:528
rte_mtr_params::dscp_table
enum rte_color * dscp_table
Definition: rte_mtr.h:306
rte_mtr_stats::n_bytes_dropped
uint64_t n_bytes_dropped
Definition: rte_mtr.h:101
rte_mtr_meter_enable
__rte_experimental int rte_mtr_meter_enable(uint16_t port_id, uint32_t mtr_id, struct rte_mtr_error *error)
RTE_COLORS
@ RTE_COLORS
Definition: rte_meter.h:39
rte_mtr_meter_profile_add
__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_mtr_meter_profile::trtcm_rfc4115
struct rte_mtr_meter_profile::@153::@157 trtcm_rfc4115
rte_mtr_meter_profile::packet_mode
int packet_mode
Definition: rte_mtr.h:200
rte_mtr_capabilities_get
__rte_experimental int rte_mtr_capabilities_get(uint16_t port_id, struct rte_mtr_capabilities *cap, struct rte_mtr_error *error)
rte_mtr_meter_policy_delete
__rte_experimental int rte_mtr_meter_policy_delete(uint16_t port_id, uint32_t policy_id, struct rte_mtr_error *error)
rte_mtr_params::meter_profile_id
uint32_t meter_profile_id
Definition: rte_mtr.h:268
rte_flow_action
Definition: rte_flow.h:3674
rte_mtr_stats::n_pkts
uint64_t n_pkts[RTE_COLORS]
Definition: rte_mtr.h:92
rte_mtr_params::default_input_color
enum rte_color default_input_color
Definition: rte_mtr.h:352
rte_mtr_capabilities::trtcm_rfc4115_byte_mode_supported
int trtcm_rfc4115_byte_mode_supported
Definition: rte_mtr.h:496
RTE_MTR_COLOR_IN_PROTO_INNER_VLAN
@ RTE_MTR_COLOR_IN_PROTO_INNER_VLAN
Definition: rte_mtr.h:244
rte_mtr_stats::n_bytes
uint64_t n_bytes[RTE_COLORS]
Definition: rte_mtr.h:95
RTE_MTR_STATS_N_BYTES_DROPPED
@ RTE_MTR_STATS_N_BYTES_DROPPED
Definition: rte_mtr.h:84
rte_mtr_meter_policy_params::actions
const struct rte_flow_action * actions[RTE_COLORS]
Definition: rte_mtr.h:213
RTE_MTR_STATS_N_BYTES_YELLOW
@ RTE_MTR_STATS_N_BYTES_YELLOW
Definition: rte_mtr.h:78