DPDK  22.11.5
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 
133  union {
135  struct {
140  uint64_t cir;
141 
143  uint64_t cbs;
144 
146  uint64_t ebs;
147  } srtcm_rfc2697;
148 
150  struct {
155  uint64_t cir;
156 
161  uint64_t pir;
162 
164  uint64_t cbs;
165 
167  uint64_t pbs;
168  } trtcm_rfc2698;
169 
171  struct {
176  uint64_t cir;
177 
182  uint64_t eir;
183 
185  uint64_t cbs;
186 
188  uint64_t ebs;
189  } trtcm_rfc4115;
190  };
191 
201 };
202 
213  const struct rte_flow_action *actions[RTE_COLORS];
214 };
215 
259 };
260 
269 
280 
339 
343  uint64_t stats_mask;
344 
346  uint32_t meter_policy_id;
347 
352  enum rte_color default_input_color;
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
622 rte_mtr_meter_profile_delete(uint16_t port_id,
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
670 rte_mtr_meter_policy_validate(uint16_t port_id,
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
800 rte_mtr_meter_policy_delete(uint16_t port_id,
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
923 rte_mtr_meter_profile_update(uint16_t port_id,
924  uint32_t mtr_id,
925  uint32_t meter_profile_id,
926  struct rte_mtr_error *error);
927 
942 __rte_experimental
943 int
944 rte_mtr_meter_policy_update(uint16_t port_id,
945  uint32_t mtr_id,
946  uint32_t meter_policy_id,
947  struct rte_mtr_error *error);
948 
969 __rte_experimental
970 int
971 rte_mtr_meter_dscp_table_update(uint16_t port_id,
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_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:449
__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:417
__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:508
uint64_t input_color_proto_mask
Definition: rte_mtr.h:513
rte_mtr_error_type
Definition: rte_mtr.h:527
rte_mtr_algorithm
Definition: rte_mtr.h:107
uint32_t meter_trtcm_rfc2698_n_max
Definition: rte_mtr.h:423
int srtcm_rfc2697_byte_mode_supported
Definition: rte_mtr.h:468
uint64_t n_pkts_dropped
Definition: rte_mtr.h:98
uint32_t n_shared_max
Definition: rte_mtr.h:366
enum rte_color * vlan_table
Definition: rte_mtr.h:332
__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:559
__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:228
uint64_t meter_rate_max
Definition: rte_mtr.h:436
uint32_t meter_policy_id
Definition: rte_mtr.h:346
int separate_input_color_table_per_port
Definition: rte_mtr.h:518
__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:455
__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:475
int trtcm_rfc4115_byte_mode_supported
Definition: rte_mtr.h:496
__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:443
int color_aware_trtcm_rfc4115_supported
Definition: rte_mtr.h:461
rte_color
Definition: rte_meter.h:35
int use_prev_mtr_color
Definition: rte_mtr.h:279
#define RTE_STD_C11
Definition: rte_common.h:39
int chaining_use_prev_mtr_color_supported
Definition: rte_mtr.h:400
uint32_t meter_profile_id
Definition: rte_mtr.h:268
int chaining_use_prev_mtr_color_enforced
Definition: rte_mtr.h:411
__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:338
const void * cause
Definition: rte_mtr.h:558
uint32_t shared_n_flows_per_mtr_max
Definition: rte_mtr.h:382
enum rte_color * dscp_table
Definition: rte_mtr.h:306
#define RTE_BIT64(nr)
Definition: rte_bitops.h:30
int trtcm_rfc2698_packet_mode_supported
Definition: rte_mtr.h:489
int trtcm_rfc2698_byte_mode_supported
Definition: rte_mtr.h:482
uint32_t meter_trtcm_rfc4115_n_max
Definition: rte_mtr.h:429
uint64_t stats_mask
Definition: rte_mtr.h:343
__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:388
int trtcm_rfc4115_packet_mode_supported
Definition: rte_mtr.h:503