DPDK  21.08.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 
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 
458  enum rte_mtr_error_type type;
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_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:360
__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:328
__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_policy_update(uint16_t port_id, uint32_t mtr_id, uint32_t meter_policy_id, struct rte_mtr_error *error)
uint64_t stats_mask
Definition: rte_mtr.h:419
rte_mtr_error_type
Definition: rte_mtr.h:428
rte_mtr_algorithm
Definition: rte_mtr.h:107
uint32_t meter_trtcm_rfc2698_n_max
Definition: rte_mtr.h:334
int srtcm_rfc2697_byte_mode_supported
Definition: rte_mtr.h:379
uint64_t n_pkts_dropped
Definition: rte_mtr.h:98
uint32_t n_shared_max
Definition: rte_mtr.h:277
__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:460
__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)
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)
uint64_t meter_rate_max
Definition: rte_mtr.h:347
uint32_t meter_policy_id
Definition: rte_mtr.h:263
__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:366
__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:386
int trtcm_rfc4115_byte_mode_supported
Definition: rte_mtr.h:407
__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:354
int color_aware_trtcm_rfc4115_supported
Definition: rte_mtr.h:372
rte_color
Definition: rte_meter.h:36
int use_prev_mtr_color
Definition: rte_mtr.h:234
#define RTE_STD_C11
Definition: rte_common.h:42
int chaining_use_prev_mtr_color_supported
Definition: rte_mtr.h:311
uint32_t meter_profile_id
Definition: rte_mtr.h:223
int chaining_use_prev_mtr_color_enforced
Definition: rte_mtr.h:322
__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)
int meter_enable
Definition: rte_mtr.h:255
const void * cause
Definition: rte_mtr.h:459
uint32_t shared_n_flows_per_mtr_max
Definition: rte_mtr.h:293
enum rte_color * dscp_table
Definition: rte_mtr.h:248
int trtcm_rfc2698_packet_mode_supported
Definition: rte_mtr.h:400
int trtcm_rfc2698_byte_mode_supported
Definition: rte_mtr.h:393
uint32_t meter_trtcm_rfc4115_n_max
Definition: rte_mtr.h:340
uint64_t stats_mask
Definition: rte_mtr.h:260
__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:299
int trtcm_rfc4115_packet_mode_supported
Definition: rte_mtr.h:414