DPDK  21.11.6
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 
214 };
215 
224 
235 
249 
256 
260  uint64_t stats_mask;
261 
263  uint32_t meter_policy_id;
264 };
265 
271  uint32_t n_max;
272 
277  uint32_t n_shared_max;
278 
283 
288 
294 
300 
312 
323 
329 
335 
341 
347  uint64_t meter_rate_max;
348 
355 
361 
367 
373 
380 
387 
394 
401 
408 
415 
419  uint64_t stats_mask;
420 };
421 
431  RTE_MTR_ERROR_TYPE_METER_PROFILE_ID,
432  RTE_MTR_ERROR_TYPE_METER_PROFILE,
433  RTE_MTR_ERROR_TYPE_METER_PROFILE_PACKET_MODE,
434  RTE_MTR_ERROR_TYPE_MTR_ID,
435  RTE_MTR_ERROR_TYPE_MTR_PARAMS,
436  RTE_MTR_ERROR_TYPE_POLICER_ACTION_GREEN,
437  RTE_MTR_ERROR_TYPE_POLICER_ACTION_YELLOW,
438  RTE_MTR_ERROR_TYPE_POLICER_ACTION_RED,
439  RTE_MTR_ERROR_TYPE_STATS_MASK,
440  RTE_MTR_ERROR_TYPE_STATS,
441  RTE_MTR_ERROR_TYPE_SHARED,
442  RTE_MTR_ERROR_TYPE_METER_POLICY_ID,
443  RTE_MTR_ERROR_TYPE_METER_POLICY,
444 };
445 
459  const void *cause;
460  const char *message;
461 };
462 
475 __rte_experimental
476 int
477 rte_mtr_capabilities_get(uint16_t port_id,
478  struct rte_mtr_capabilities *cap,
479  struct rte_mtr_error *error);
480 
499 __rte_experimental
500 int
501 rte_mtr_meter_profile_add(uint16_t port_id,
502  uint32_t meter_profile_id,
503  struct rte_mtr_meter_profile *profile,
504  struct rte_mtr_error *error);
505 
521 __rte_experimental
522 int
523 rte_mtr_meter_profile_delete(uint16_t port_id,
524  uint32_t meter_profile_id,
525  struct rte_mtr_error *error);
526 
549 __rte_experimental
550 int
551 rte_mtr_meter_policy_validate(uint16_t port_id,
552  struct rte_mtr_meter_policy_params *policy,
553  struct rte_mtr_error *error);
554 
576 __rte_experimental
577 int
578 rte_mtr_meter_policy_add(uint16_t port_id,
579  uint32_t policy_id,
580  struct rte_mtr_meter_policy_params *policy,
581  struct rte_mtr_error *error);
582 
587 #define rte_mtr_policy_pass_color(policy) \
588 struct rte_mtr_meter_policy_params policy = \
589 { \
590  .actions[RTE_COLOR_GREEN] = (struct rte_flow_action[]) { \
591  { \
592  .type = RTE_FLOW_ACTION_TYPE_METER_COLOR, \
593  .conf = &(struct rte_flow_action_meter_color) { \
594  .color = RTE_COLOR_GREEN, \
595  }, \
596  }, \
597  { \
598  .type = RTE_FLOW_ACTION_TYPE_END, \
599  }, \
600  }, \
601  .actions[RTE_COLOR_YELLOW] = (struct rte_flow_action[]) { \
602  { \
603  .type = RTE_FLOW_ACTION_TYPE_METER_COLOR, \
604  .conf = &(struct rte_flow_action_meter_color) { \
605  .color = RTE_COLOR_YELLOW, \
606  }, \
607  }, \
608  { \
609  .type = RTE_FLOW_ACTION_TYPE_END, \
610  }, \
611  }, \
612  .actions[RTE_COLOR_RED] = (struct rte_flow_action[]) { \
613  { \
614  .type = RTE_FLOW_ACTION_TYPE_METER_COLOR, \
615  .conf = &(struct rte_flow_action_meter_color) { \
616  .color = RTE_COLOR_RED, \
617  }, \
618  }, \
619  { \
620  .type = RTE_FLOW_ACTION_TYPE_END, \
621  }, \
622  }, \
623 }
624 
629 #define rte_mtr_policy_drop_red(policy) \
630 struct rte_mtr_meter_policy_params policy = \
631 { \
632  .actions[RTE_COLOR_GREEN] = NULL, \
633  .actions[RTE_COLOR_YELLOW] = NULL, \
634  .actions[RTE_COLOR_RED] = (struct rte_flow_action[]) { \
635  { \
636  .type = RTE_FLOW_ACTION_TYPE_DROP, \
637  }, \
638  { \
639  .type = RTE_FLOW_ACTION_TYPE_END, \
640  }, \
641  }, \
642 }
643 
659 __rte_experimental
660 int
661 rte_mtr_meter_policy_delete(uint16_t port_id,
662  uint32_t policy_id,
663  struct rte_mtr_error *error);
664 
688 __rte_experimental
689 int
690 rte_mtr_create(uint16_t port_id,
691  uint32_t mtr_id,
692  struct rte_mtr_params *params,
693  int shared,
694  struct rte_mtr_error *error);
695 
712 __rte_experimental
713 int
714 rte_mtr_destroy(uint16_t port_id,
715  uint32_t mtr_id,
716  struct rte_mtr_error *error);
717 
740 __rte_experimental
741 int
742 rte_mtr_meter_disable(uint16_t port_id,
743  uint32_t mtr_id,
744  struct rte_mtr_error *error);
745 
762 __rte_experimental
763 int
764 rte_mtr_meter_enable(uint16_t port_id,
765  uint32_t mtr_id,
766  struct rte_mtr_error *error);
767 
782 __rte_experimental
783 int
784 rte_mtr_meter_profile_update(uint16_t port_id,
785  uint32_t mtr_id,
786  uint32_t meter_profile_id,
787  struct rte_mtr_error *error);
788 
803 __rte_experimental
804 int
805 rte_mtr_meter_policy_update(uint16_t port_id,
806  uint32_t mtr_id,
807  uint32_t meter_policy_id,
808  struct rte_mtr_error *error);
809 
828 __rte_experimental
829 int
830 rte_mtr_meter_dscp_table_update(uint16_t port_id,
831  uint32_t mtr_id,
832  enum rte_color *dscp_table,
833  struct rte_mtr_error *error);
834 
853 __rte_experimental
854 int
855 rte_mtr_stats_update(uint16_t port_id,
856  uint32_t mtr_id,
857  uint64_t stats_mask,
858  struct rte_mtr_error *error);
859 
885 __rte_experimental
886 int
887 rte_mtr_stats_read(uint16_t port_id,
888  uint32_t mtr_id,
889  struct rte_mtr_stats *stats,
890  uint64_t *stats_mask,
891  int clear,
892  struct rte_mtr_error *error);
893 
894 #ifdef __cplusplus
895 }
896 #endif
897 
898 #endif /* __INCLUDE_RTE_MTR_H__ */
rte_mtr_capabilities::srtcm_rfc2697_byte_mode_supported
int srtcm_rfc2697_byte_mode_supported
Definition: rte_mtr.h:379
rte_mtr_capabilities::chaining_use_prev_mtr_color_supported
int chaining_use_prev_mtr_color_supported
Definition: rte_mtr.h:311
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:260
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:372
rte_mtr_capabilities::identical
int identical
Definition: rte_mtr.h:282
rte_mtr_error
Definition: rte_mtr.h:457
RTE_MTR_ERROR_TYPE_UNSPECIFIED
@ RTE_MTR_ERROR_TYPE_UNSPECIFIED
Definition: rte_mtr.h:430
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_error::message
const char * message
Definition: rte_mtr.h:460
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:347
rte_mtr_capabilities::stats_mask
uint64_t stats_mask
Definition: rte_mtr.h:419
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_stats
Definition: rte_mtr.h:90
rte_mtr_capabilities::color_aware_trtcm_rfc2698_supported
int color_aware_trtcm_rfc2698_supported
Definition: rte_mtr.h:366
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:234
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:354
rte_mtr_capabilities::color_aware_srtcm_rfc2697_supported
int color_aware_srtcm_rfc2697_supported
Definition: rte_mtr.h:360
rte_mtr_error::type
enum rte_mtr_error_type type
Definition: rte_mtr.h:458
rte_mtr_capabilities::n_max
uint32_t n_max
Definition: rte_mtr.h:271
rte_mtr_params
Definition: rte_mtr.h:221
rte_mtr_capabilities::trtcm_rfc2698_byte_mode_supported
int trtcm_rfc2698_byte_mode_supported
Definition: rte_mtr.h:393
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:36
rte_mtr_capabilities::meter_srtcm_rfc2697_n_max
uint32_t meter_srtcm_rfc2697_n_max
Definition: rte_mtr.h:328
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_color *dscp_table, struct rte_mtr_error *error)
rte_mtr_capabilities::chaining_use_prev_mtr_color_enforced
int chaining_use_prev_mtr_color_enforced
Definition: rte_mtr.h:322
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:428
rte_mtr_capabilities::trtcm_rfc4115_packet_mode_supported
int trtcm_rfc4115_packet_mode_supported
Definition: rte_mtr.h:414
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:334
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:340
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:293
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:287
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:277
rte_mtr_params::meter_policy_id
uint32_t meter_policy_id
Definition: rte_mtr.h:263
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:42
rte_mtr_capabilities
Definition: rte_mtr.h:269
rte_mtr_error::cause
const void * cause
Definition: rte_mtr.h:459
rte_mtr_params::meter_enable
int meter_enable
Definition: rte_mtr.h:255
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:386
rte_mtr_capabilities::trtcm_rfc2698_packet_mode_supported
int trtcm_rfc2698_packet_mode_supported
Definition: rte_mtr.h:400
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::trtcm_rfc2698
struct rte_mtr_meter_profile::@183::@186 trtcm_rfc2698
rte_mtr_capabilities::chaining_n_mtrs_per_flow_max
uint32_t chaining_n_mtrs_per_flow_max
Definition: rte_mtr.h:299
RTE_MTR_ERROR_TYPE_NONE
@ RTE_MTR_ERROR_TYPE_NONE
Definition: rte_mtr.h:429
rte_mtr_params::dscp_table
enum rte_color * dscp_table
Definition: rte_mtr.h:248
rte_mtr_stats::n_bytes_dropped
uint64_t n_bytes_dropped
Definition: rte_mtr.h:101
rte_mtr_meter_profile::srtcm_rfc2697
struct rte_mtr_meter_profile::@183::@185 srtcm_rfc2697
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:40
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::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:223
rte_flow_action
Definition: rte_flow.h:3770
rte_mtr_stats::n_pkts
uint64_t n_pkts[RTE_COLORS]
Definition: rte_mtr.h:92
rte_mtr_capabilities::trtcm_rfc4115_byte_mode_supported
int trtcm_rfc4115_byte_mode_supported
Definition: rte_mtr.h:407
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_profile::trtcm_rfc4115
struct rte_mtr_meter_profile::@183::@187 trtcm_rfc4115
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