DPDK  24.11.0-rc3
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 
131 
132  union {
134  struct {
139  uint64_t cir;
140 
142  uint64_t cbs;
143 
145  uint64_t ebs;
146  } srtcm_rfc2697;
147 
149  struct {
154  uint64_t cir;
155 
160  uint64_t pir;
161 
163  uint64_t cbs;
164 
166  uint64_t pbs;
167  } trtcm_rfc2698;
168 
170  struct {
175  uint64_t cir;
176 
181  uint64_t eir;
182 
184  uint64_t cbs;
185 
187  uint64_t ebs;
188  } trtcm_rfc4115;
189  };
190 
200 };
201 
212  const struct rte_flow_action *actions[RTE_COLORS];
213 };
214 
257 };
258 
267 
278 
337 
341  uint64_t stats_mask;
342 
344  uint32_t meter_policy_id;
345 
350  enum rte_color default_input_color;
351 };
352 
358  uint32_t n_max;
359 
364  uint32_t n_shared_max;
365 
370 
375 
381 
387 
399 
410 
416 
422 
428 
434  uint64_t meter_rate_max;
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 
555  enum rte_mtr_error_type type;
556  const void *cause;
557  const char *message;
558 };
559 
572 __rte_experimental
573 int
574 rte_mtr_capabilities_get(uint16_t port_id,
575  struct rte_mtr_capabilities *cap,
576  struct rte_mtr_error *error);
577 
596 __rte_experimental
597 int
598 rte_mtr_meter_profile_add(uint16_t port_id,
599  uint32_t meter_profile_id,
600  struct rte_mtr_meter_profile *profile,
601  struct rte_mtr_error *error);
602 
618 __rte_experimental
619 int
620 rte_mtr_meter_profile_delete(uint16_t port_id,
621  uint32_t meter_profile_id,
622  struct rte_mtr_error *error);
623 
638 __rte_experimental
639 struct rte_flow_meter_profile *
640 rte_mtr_meter_profile_get(uint16_t port_id,
641  uint32_t meter_profile_id,
642  struct rte_mtr_error *error);
643 
666 __rte_experimental
667 int
668 rte_mtr_meter_policy_validate(uint16_t port_id,
669  struct rte_mtr_meter_policy_params *policy,
670  struct rte_mtr_error *error);
671 
693 __rte_experimental
694 int
695 rte_mtr_meter_policy_add(uint16_t port_id,
696  uint32_t policy_id,
697  struct rte_mtr_meter_policy_params *policy,
698  struct rte_mtr_error *error);
699 
714 __rte_experimental
715 struct rte_flow_meter_policy *
716 rte_mtr_meter_policy_get(uint16_t port_id,
717  uint32_t policy_id,
718  struct rte_mtr_error *error);
719 
724 #define rte_mtr_policy_pass_color(policy) \
725 struct 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) \
767 struct 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
797 int
798 rte_mtr_meter_policy_delete(uint16_t port_id,
799  uint32_t policy_id,
800  struct rte_mtr_error *error);
801 
825 __rte_experimental
826 int
827 rte_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
850 int
851 rte_mtr_destroy(uint16_t port_id,
852  uint32_t mtr_id,
853  struct rte_mtr_error *error);
854 
877 __rte_experimental
878 int
879 rte_mtr_meter_disable(uint16_t port_id,
880  uint32_t mtr_id,
881  struct rte_mtr_error *error);
882 
899 __rte_experimental
900 int
901 rte_mtr_meter_enable(uint16_t port_id,
902  uint32_t mtr_id,
903  struct rte_mtr_error *error);
904 
919 __rte_experimental
920 int
921 rte_mtr_meter_profile_update(uint16_t port_id,
922  uint32_t mtr_id,
923  uint32_t meter_profile_id,
924  struct rte_mtr_error *error);
925 
940 __rte_experimental
941 int
942 rte_mtr_meter_policy_update(uint16_t port_id,
943  uint32_t mtr_id,
944  uint32_t meter_policy_id,
945  struct rte_mtr_error *error);
946 
967 __rte_experimental
968 int
969 rte_mtr_meter_dscp_table_update(uint16_t port_id,
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
995 int
996 rte_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
1026 int
1027 rte_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
1046 int
1047 rte_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
1068 int
1069 rte_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
1092 int
1093 rte_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
1124 int
1125 rte_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__ */
__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)
int color_aware_srtcm_rfc2697_supported
Definition: rte_mtr.h:447
__rte_experimental int rte_mtr_meter_policy_delete(uint16_t port_id, uint32_t policy_id, struct rte_mtr_error *error)
uint32_t meter_srtcm_rfc2697_n_max
Definition: rte_mtr.h:415
__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_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_meter_policy_update(uint16_t port_id, uint32_t mtr_id, uint32_t meter_policy_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)
uint64_t stats_mask
Definition: rte_mtr.h:506
uint64_t input_color_proto_mask
Definition: rte_mtr.h:511
rte_mtr_error_type
Definition: rte_mtr.h:525
rte_mtr_algorithm
Definition: rte_mtr.h:107
uint32_t meter_trtcm_rfc2698_n_max
Definition: rte_mtr.h:421
int srtcm_rfc2697_byte_mode_supported
Definition: rte_mtr.h:466
uint64_t n_pkts_dropped
Definition: rte_mtr.h:98
uint32_t n_shared_max
Definition: rte_mtr.h:364
enum rte_color * vlan_table
Definition: rte_mtr.h:330
__rte_experimental int rte_mtr_meter_disable(uint16_t port_id, uint32_t mtr_id, struct rte_mtr_error *error)
const char * message
Definition: rte_mtr.h:557
__rte_experimental int rte_mtr_meter_profile_delete(uint16_t port_id, uint32_t meter_profile_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_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)
uint64_t n_pkts[RTE_COLORS]
Definition: rte_mtr.h:92
__rte_experimental int rte_mtr_meter_enable(uint16_t port_id, uint32_t mtr_id, struct rte_mtr_error *error)
uint64_t n_bytes_dropped
Definition: rte_mtr.h:101
uint64_t n_bytes[RTE_COLORS]
Definition: rte_mtr.h:95
__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_color_in_protocol
Definition: rte_mtr.h:226
uint64_t meter_rate_max
Definition: rte_mtr.h:434
uint32_t meter_policy_id
Definition: rte_mtr.h:344
int separate_input_color_table_per_port
Definition: rte_mtr.h:516
__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_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)
int color_aware_trtcm_rfc2698_supported
Definition: rte_mtr.h:453
__rte_experimental int rte_mtr_meter_policy_validate(uint16_t port_id, struct rte_mtr_meter_policy_params *policy, struct rte_mtr_error *error)
int srtcm_rfc2697_packet_mode_supported
Definition: rte_mtr.h:473
int trtcm_rfc4115_byte_mode_supported
Definition: rte_mtr.h:494
__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_profile_update(uint16_t port_id, uint32_t mtr_id, uint32_t meter_profile_id, struct rte_mtr_error *error)
uint64_t meter_policy_n_max
Definition: rte_mtr.h:441
int color_aware_trtcm_rfc4115_supported
Definition: rte_mtr.h:459
rte_color
Definition: rte_meter.h:32
int use_prev_mtr_color
Definition: rte_mtr.h:277
int chaining_use_prev_mtr_color_supported
Definition: rte_mtr.h:398
uint32_t meter_profile_id
Definition: rte_mtr.h:266
int chaining_use_prev_mtr_color_enforced
Definition: rte_mtr.h:409
__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_stats_type
Definition: rte_mtr.h:61
__rte_experimental int rte_mtr_capabilities_get(uint16_t port_id, struct rte_mtr_capabilities *cap, 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)
int meter_enable
Definition: rte_mtr.h:336
const void * cause
Definition: rte_mtr.h:556
uint32_t shared_n_flows_per_mtr_max
Definition: rte_mtr.h:380
enum rte_color * dscp_table
Definition: rte_mtr.h:304
#define RTE_BIT64(nr)
Definition: rte_bitops.h:36
int trtcm_rfc2698_packet_mode_supported
Definition: rte_mtr.h:487
int trtcm_rfc2698_byte_mode_supported
Definition: rte_mtr.h:480
uint32_t meter_trtcm_rfc4115_n_max
Definition: rte_mtr.h:427
uint64_t stats_mask
Definition: rte_mtr.h:341
__rte_experimental int rte_mtr_destroy(uint16_t port_id, uint32_t mtr_id, struct rte_mtr_error *error)
uint32_t chaining_n_mtrs_per_flow_max
Definition: rte_mtr.h:386
int trtcm_rfc4115_packet_mode_supported
Definition: rte_mtr.h:501