DPDK  23.07.0
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 
258 };
259 
268 
279 
338 
342  uint64_t stats_mask;
343 
345  uint32_t meter_policy_id;
346 
351  enum rte_color default_input_color;
352 };
353 
359  uint32_t n_max;
360 
365  uint32_t n_shared_max;
366 
371 
376 
382 
388 
400 
411 
417 
423 
429 
435  uint64_t meter_rate_max;
436 
443 
449 
455 
461 
468 
475 
482 
489 
496 
503 
507  uint64_t stats_mask;
508 
513 
518 };
519 
529  RTE_MTR_ERROR_TYPE_METER_PROFILE_ID,
530  RTE_MTR_ERROR_TYPE_METER_PROFILE,
531  RTE_MTR_ERROR_TYPE_METER_PROFILE_PACKET_MODE,
532  RTE_MTR_ERROR_TYPE_MTR_ID,
533  RTE_MTR_ERROR_TYPE_MTR_PARAMS,
534  RTE_MTR_ERROR_TYPE_POLICER_ACTION_GREEN,
535  RTE_MTR_ERROR_TYPE_POLICER_ACTION_YELLOW,
536  RTE_MTR_ERROR_TYPE_POLICER_ACTION_RED,
537  RTE_MTR_ERROR_TYPE_STATS_MASK,
538  RTE_MTR_ERROR_TYPE_STATS,
539  RTE_MTR_ERROR_TYPE_SHARED,
540  RTE_MTR_ERROR_TYPE_METER_POLICY_ID,
541  RTE_MTR_ERROR_TYPE_METER_POLICY,
542 };
543 
556  enum rte_mtr_error_type type;
557  const void *cause;
558  const char *message;
559 };
560 
573 __rte_experimental
574 int
575 rte_mtr_capabilities_get(uint16_t port_id,
576  struct rte_mtr_capabilities *cap,
577  struct rte_mtr_error *error);
578 
597 __rte_experimental
598 int
599 rte_mtr_meter_profile_add(uint16_t port_id,
600  uint32_t meter_profile_id,
601  struct rte_mtr_meter_profile *profile,
602  struct rte_mtr_error *error);
603 
619 __rte_experimental
620 int
621 rte_mtr_meter_profile_delete(uint16_t port_id,
622  uint32_t meter_profile_id,
623  struct rte_mtr_error *error);
624 
639 __rte_experimental
640 struct rte_flow_meter_profile *
641 rte_mtr_meter_profile_get(uint16_t port_id,
642  uint32_t meter_profile_id,
643  struct rte_mtr_error *error);
644 
667 __rte_experimental
668 int
669 rte_mtr_meter_policy_validate(uint16_t port_id,
670  struct rte_mtr_meter_policy_params *policy,
671  struct rte_mtr_error *error);
672 
694 __rte_experimental
695 int
696 rte_mtr_meter_policy_add(uint16_t port_id,
697  uint32_t policy_id,
698  struct rte_mtr_meter_policy_params *policy,
699  struct rte_mtr_error *error);
700 
715 __rte_experimental
716 struct rte_flow_meter_policy *
717 rte_mtr_meter_policy_get(uint16_t port_id,
718  uint32_t policy_id,
719  struct rte_mtr_error *error);
720 
725 #define rte_mtr_policy_pass_color(policy) \
726 struct rte_mtr_meter_policy_params policy = \
727 { \
728  .actions[RTE_COLOR_GREEN] = (struct rte_flow_action[]) { \
729  { \
730  .type = RTE_FLOW_ACTION_TYPE_METER_COLOR, \
731  .conf = &(struct rte_flow_action_meter_color) { \
732  .color = RTE_COLOR_GREEN, \
733  }, \
734  }, \
735  { \
736  .type = RTE_FLOW_ACTION_TYPE_END, \
737  }, \
738  }, \
739  .actions[RTE_COLOR_YELLOW] = (struct rte_flow_action[]) { \
740  { \
741  .type = RTE_FLOW_ACTION_TYPE_METER_COLOR, \
742  .conf = &(struct rte_flow_action_meter_color) { \
743  .color = RTE_COLOR_YELLOW, \
744  }, \
745  }, \
746  { \
747  .type = RTE_FLOW_ACTION_TYPE_END, \
748  }, \
749  }, \
750  .actions[RTE_COLOR_RED] = (struct rte_flow_action[]) { \
751  { \
752  .type = RTE_FLOW_ACTION_TYPE_METER_COLOR, \
753  .conf = &(struct rte_flow_action_meter_color) { \
754  .color = RTE_COLOR_RED, \
755  }, \
756  }, \
757  { \
758  .type = RTE_FLOW_ACTION_TYPE_END, \
759  }, \
760  }, \
761 }
762 
767 #define rte_mtr_policy_drop_red(policy) \
768 struct rte_mtr_meter_policy_params policy = \
769 { \
770  .actions[RTE_COLOR_GREEN] = NULL, \
771  .actions[RTE_COLOR_YELLOW] = NULL, \
772  .actions[RTE_COLOR_RED] = (struct rte_flow_action[]) { \
773  { \
774  .type = RTE_FLOW_ACTION_TYPE_DROP, \
775  }, \
776  { \
777  .type = RTE_FLOW_ACTION_TYPE_END, \
778  }, \
779  }, \
780 }
781 
797 __rte_experimental
798 int
799 rte_mtr_meter_policy_delete(uint16_t port_id,
800  uint32_t policy_id,
801  struct rte_mtr_error *error);
802 
826 __rte_experimental
827 int
828 rte_mtr_create(uint16_t port_id,
829  uint32_t mtr_id,
830  struct rte_mtr_params *params,
831  int shared,
832  struct rte_mtr_error *error);
833 
850 __rte_experimental
851 int
852 rte_mtr_destroy(uint16_t port_id,
853  uint32_t mtr_id,
854  struct rte_mtr_error *error);
855 
878 __rte_experimental
879 int
880 rte_mtr_meter_disable(uint16_t port_id,
881  uint32_t mtr_id,
882  struct rte_mtr_error *error);
883 
900 __rte_experimental
901 int
902 rte_mtr_meter_enable(uint16_t port_id,
903  uint32_t mtr_id,
904  struct rte_mtr_error *error);
905 
920 __rte_experimental
921 int
922 rte_mtr_meter_profile_update(uint16_t port_id,
923  uint32_t mtr_id,
924  uint32_t meter_profile_id,
925  struct rte_mtr_error *error);
926 
941 __rte_experimental
942 int
943 rte_mtr_meter_policy_update(uint16_t port_id,
944  uint32_t mtr_id,
945  uint32_t meter_policy_id,
946  struct rte_mtr_error *error);
947 
968 __rte_experimental
969 int
970 rte_mtr_meter_dscp_table_update(uint16_t port_id,
971  uint32_t mtr_id, enum rte_mtr_color_in_protocol proto,
972  enum rte_color *dscp_table,
973  struct rte_mtr_error *error);
974 
995 __rte_experimental
996 int
997 rte_mtr_meter_vlan_table_update(uint16_t port_id, uint32_t mtr_id,
998  enum rte_mtr_color_in_protocol proto,
999  enum rte_color *vlan_table,
1000  struct rte_mtr_error *error);
1001 
1026 __rte_experimental
1027 int
1028 rte_mtr_color_in_protocol_set(uint16_t port_id, uint32_t mtr_id,
1029  enum rte_mtr_color_in_protocol proto, uint32_t priority,
1030  struct rte_mtr_error *error);
1031 
1046 __rte_experimental
1047 int
1048 rte_mtr_color_in_protocol_get(uint16_t port_id, uint32_t mtr_id,
1049  uint64_t *proto_mask,
1050  struct rte_mtr_error *error);
1051 
1068 __rte_experimental
1069 int
1070 rte_mtr_color_in_protocol_priority_get(uint16_t port_id, uint32_t mtr_id,
1071  enum rte_mtr_color_in_protocol proto, uint32_t *priority,
1072  struct rte_mtr_error *error);
1073 
1092 __rte_experimental
1093 int
1094 rte_mtr_stats_update(uint16_t port_id,
1095  uint32_t mtr_id,
1096  uint64_t stats_mask,
1097  struct rte_mtr_error *error);
1098 
1124 __rte_experimental
1125 int
1126 rte_mtr_stats_read(uint16_t port_id,
1127  uint32_t mtr_id,
1128  struct rte_mtr_stats *stats,
1129  uint64_t *stats_mask,
1130  int clear,
1131  struct rte_mtr_error *error);
1132 
1133 #ifdef __cplusplus
1134 }
1135 #endif
1136 
1137 #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:448
__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:416
__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:507
uint64_t input_color_proto_mask
Definition: rte_mtr.h:512
rte_mtr_error_type
Definition: rte_mtr.h:526
rte_mtr_algorithm
Definition: rte_mtr.h:107
uint32_t meter_trtcm_rfc2698_n_max
Definition: rte_mtr.h:422
int srtcm_rfc2697_byte_mode_supported
Definition: rte_mtr.h:467
uint64_t n_pkts_dropped
Definition: rte_mtr.h:98
uint32_t n_shared_max
Definition: rte_mtr.h:365
enum rte_color * vlan_table
Definition: rte_mtr.h:331
__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:558
__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:227
uint64_t meter_rate_max
Definition: rte_mtr.h:435
uint32_t meter_policy_id
Definition: rte_mtr.h:345
int separate_input_color_table_per_port
Definition: rte_mtr.h:517
__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:454
__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:474
int trtcm_rfc4115_byte_mode_supported
Definition: rte_mtr.h:495
__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:442
int color_aware_trtcm_rfc4115_supported
Definition: rte_mtr.h:460
rte_color
Definition: rte_meter.h:32
int use_prev_mtr_color
Definition: rte_mtr.h:278
#define RTE_STD_C11
Definition: rte_common.h:39
int chaining_use_prev_mtr_color_supported
Definition: rte_mtr.h:399
uint32_t meter_profile_id
Definition: rte_mtr.h:267
int chaining_use_prev_mtr_color_enforced
Definition: rte_mtr.h:410
__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:337
const void * cause
Definition: rte_mtr.h:557
uint32_t shared_n_flows_per_mtr_max
Definition: rte_mtr.h:381
enum rte_color * dscp_table
Definition: rte_mtr.h:305
#define RTE_BIT64(nr)
Definition: rte_bitops.h:30
int trtcm_rfc2698_packet_mode_supported
Definition: rte_mtr.h:488
int trtcm_rfc2698_byte_mode_supported
Definition: rte_mtr.h:481
uint32_t meter_trtcm_rfc4115_n_max
Definition: rte_mtr.h:428
uint64_t stats_mask
Definition: rte_mtr.h:342
__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:387
int trtcm_rfc4115_packet_mode_supported
Definition: rte_mtr.h:502