DPDK  22.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 
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 
648 __rte_experimental
649 int
650 rte_mtr_meter_policy_validate(uint16_t port_id,
651  struct rte_mtr_meter_policy_params *policy,
652  struct rte_mtr_error *error);
653 
675 __rte_experimental
676 int
677 rte_mtr_meter_policy_add(uint16_t port_id,
678  uint32_t policy_id,
679  struct rte_mtr_meter_policy_params *policy,
680  struct rte_mtr_error *error);
681 
686 #define rte_mtr_policy_pass_color(policy) \
687 struct rte_mtr_meter_policy_params policy = \
688 { \
689  .actions[RTE_COLOR_GREEN] = (struct rte_flow_action[]) { \
690  { \
691  .type = RTE_FLOW_ACTION_TYPE_METER_COLOR, \
692  .conf = &(struct rte_flow_action_meter_color) { \
693  .color = RTE_COLOR_GREEN, \
694  }, \
695  }, \
696  { \
697  .type = RTE_FLOW_ACTION_TYPE_END, \
698  }, \
699  }, \
700  .actions[RTE_COLOR_YELLOW] = (struct rte_flow_action[]) { \
701  { \
702  .type = RTE_FLOW_ACTION_TYPE_METER_COLOR, \
703  .conf = &(struct rte_flow_action_meter_color) { \
704  .color = RTE_COLOR_YELLOW, \
705  }, \
706  }, \
707  { \
708  .type = RTE_FLOW_ACTION_TYPE_END, \
709  }, \
710  }, \
711  .actions[RTE_COLOR_RED] = (struct rte_flow_action[]) { \
712  { \
713  .type = RTE_FLOW_ACTION_TYPE_METER_COLOR, \
714  .conf = &(struct rte_flow_action_meter_color) { \
715  .color = RTE_COLOR_RED, \
716  }, \
717  }, \
718  { \
719  .type = RTE_FLOW_ACTION_TYPE_END, \
720  }, \
721  }, \
722 }
723 
728 #define rte_mtr_policy_drop_red(policy) \
729 struct rte_mtr_meter_policy_params policy = \
730 { \
731  .actions[RTE_COLOR_GREEN] = NULL, \
732  .actions[RTE_COLOR_YELLOW] = NULL, \
733  .actions[RTE_COLOR_RED] = (struct rte_flow_action[]) { \
734  { \
735  .type = RTE_FLOW_ACTION_TYPE_DROP, \
736  }, \
737  { \
738  .type = RTE_FLOW_ACTION_TYPE_END, \
739  }, \
740  }, \
741 }
742 
758 __rte_experimental
759 int
760 rte_mtr_meter_policy_delete(uint16_t port_id,
761  uint32_t policy_id,
762  struct rte_mtr_error *error);
763 
787 __rte_experimental
788 int
789 rte_mtr_create(uint16_t port_id,
790  uint32_t mtr_id,
791  struct rte_mtr_params *params,
792  int shared,
793  struct rte_mtr_error *error);
794 
811 __rte_experimental
812 int
813 rte_mtr_destroy(uint16_t port_id,
814  uint32_t mtr_id,
815  struct rte_mtr_error *error);
816 
839 __rte_experimental
840 int
841 rte_mtr_meter_disable(uint16_t port_id,
842  uint32_t mtr_id,
843  struct rte_mtr_error *error);
844 
861 __rte_experimental
862 int
863 rte_mtr_meter_enable(uint16_t port_id,
864  uint32_t mtr_id,
865  struct rte_mtr_error *error);
866 
881 __rte_experimental
882 int
883 rte_mtr_meter_profile_update(uint16_t port_id,
884  uint32_t mtr_id,
885  uint32_t meter_profile_id,
886  struct rte_mtr_error *error);
887 
902 __rte_experimental
903 int
904 rte_mtr_meter_policy_update(uint16_t port_id,
905  uint32_t mtr_id,
906  uint32_t meter_policy_id,
907  struct rte_mtr_error *error);
908 
927 __rte_experimental
928 int
929 rte_mtr_meter_dscp_table_update(uint16_t port_id,
930  uint32_t mtr_id,
931  enum rte_color *dscp_table,
932  struct rte_mtr_error *error);
933 
952 __rte_experimental
953 int
954 rte_mtr_meter_vlan_table_update(uint16_t port_id, uint32_t mtr_id,
955  enum rte_color *vlan_table,
956  struct rte_mtr_error *error);
957 
982 __rte_experimental
983 int
984 rte_mtr_color_in_protocol_set(uint16_t port_id, uint32_t mtr_id,
985  enum rte_mtr_color_in_protocol proto, uint32_t priority,
986  struct rte_mtr_error *error);
987 
1003 __rte_experimental
1004 int
1005 rte_mtr_color_in_protocol_get(uint16_t port_id, uint32_t mtr_id,
1006  uint64_t *proto_mask,
1007  struct rte_mtr_error *error);
1008 
1025 __rte_experimental
1026 int
1027 rte_mtr_color_in_protocol_priority_get(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 
1049 __rte_experimental
1050 int
1051 rte_mtr_stats_update(uint16_t port_id,
1052  uint32_t mtr_id,
1053  uint64_t stats_mask,
1054  struct rte_mtr_error *error);
1055 
1081 __rte_experimental
1082 int
1083 rte_mtr_stats_read(uint16_t port_id,
1084  uint32_t mtr_id,
1085  struct rte_mtr_stats *stats,
1086  uint64_t *stats_mask,
1087  int clear,
1088  struct rte_mtr_error *error);
1089 
1090 #ifdef __cplusplus
1091 }
1092 #endif
1093 
1094 #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 int rte_mtr_meter_dscp_table_update(uint16_t port_id, uint32_t mtr_id, enum rte_color *dscp_table, struct rte_mtr_error *error)
__rte_experimental int rte_mtr_meter_vlan_table_update(uint16_t port_id, uint32_t mtr_id, enum rte_color *vlan_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)
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 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:36
int use_prev_mtr_color
Definition: rte_mtr.h:279
#define RTE_STD_C11
Definition: rte_common.h:42
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