DPDK 21.11.9
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
55extern "C" {
56#endif
57
64
67
70
73
76
79
82
85};
86
92 uint64_t n_pkts[RTE_COLORS];
93
96
99
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;
148
150 struct {
155 uint64_t cir;
156
161 uint64_t pir;
162
164 uint64_t cbs;
165
167 uint64_t pbs;
169
171 struct {
176 uint64_t cir;
177
182 uint64_t eir;
183
185 uint64_t cbs;
186
188 uint64_t ebs;
190 };
191
201};
202
214};
215
224
235
249
256
260 uint64_t stats_mask;
261
264};
265
271 uint32_t n_max;
272
277 uint32_t n_shared_max;
278
283
288
294
300
312
323
329
335
341
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
476int
478 struct rte_mtr_capabilities *cap,
479 struct rte_mtr_error *error);
480
499__rte_experimental
500int
502 uint32_t meter_profile_id,
503 struct rte_mtr_meter_profile *profile,
504 struct rte_mtr_error *error);
505
521__rte_experimental
522int
524 uint32_t meter_profile_id,
525 struct rte_mtr_error *error);
526
549__rte_experimental
550int
552 struct rte_mtr_meter_policy_params *policy,
553 struct rte_mtr_error *error);
554
576__rte_experimental
577int
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) \
588struct 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) \
630struct 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
660int
662 uint32_t policy_id,
663 struct rte_mtr_error *error);
664
688__rte_experimental
689int
690rte_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
713int
714rte_mtr_destroy(uint16_t port_id,
715 uint32_t mtr_id,
716 struct rte_mtr_error *error);
717
740__rte_experimental
741int
742rte_mtr_meter_disable(uint16_t port_id,
743 uint32_t mtr_id,
744 struct rte_mtr_error *error);
745
762__rte_experimental
763int
764rte_mtr_meter_enable(uint16_t port_id,
765 uint32_t mtr_id,
766 struct rte_mtr_error *error);
767
782__rte_experimental
783int
785 uint32_t mtr_id,
786 uint32_t meter_profile_id,
787 struct rte_mtr_error *error);
788
803__rte_experimental
804int
806 uint32_t mtr_id,
807 uint32_t meter_policy_id,
808 struct rte_mtr_error *error);
809
828__rte_experimental
829int
831 uint32_t mtr_id,
832 enum rte_color *dscp_table,
833 struct rte_mtr_error *error);
834
853__rte_experimental
854int
855rte_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
886int
887rte_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__ */
#define RTE_STD_C11
Definition: rte_common.h:42
rte_color
Definition: rte_meter.h:36
@ RTE_COLORS
Definition: rte_meter.h:40
__rte_experimental int rte_mtr_destroy(uint16_t port_id, uint32_t mtr_id, struct rte_mtr_error *error)
__rte_experimental int rte_mtr_meter_policy_delete(uint16_t port_id, uint32_t policy_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_meter_profile_update(uint16_t port_id, uint32_t mtr_id, uint32_t meter_profile_id, struct rte_mtr_error *error)
__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_meter_policy_update(uint16_t port_id, uint32_t mtr_id, uint32_t meter_policy_id, struct rte_mtr_error *error)
rte_mtr_stats_type
Definition: rte_mtr.h:61
@ RTE_MTR_STATS_N_BYTES_GREEN
Definition: rte_mtr.h:75
@ RTE_MTR_STATS_N_PKTS_GREEN
Definition: rte_mtr.h:63
@ RTE_MTR_STATS_N_PKTS_RED
Definition: rte_mtr.h:69
@ RTE_MTR_STATS_N_BYTES_YELLOW
Definition: rte_mtr.h:78
@ RTE_MTR_STATS_N_PKTS_YELLOW
Definition: rte_mtr.h:66
@ RTE_MTR_STATS_N_PKTS_DROPPED
Definition: rte_mtr.h:72
@ RTE_MTR_STATS_N_BYTES_RED
Definition: rte_mtr.h:81
@ RTE_MTR_STATS_N_BYTES_DROPPED
Definition: rte_mtr.h:84
__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_profile_add(uint16_t port_id, uint32_t meter_profile_id, struct rte_mtr_meter_profile *profile, struct rte_mtr_error *error)
__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_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_algorithm
Definition: rte_mtr.h:107
@ RTE_MTR_SRTCM_RFC2697
Definition: rte_mtr.h:116
@ RTE_MTR_TRTCM_RFC4115
Definition: rte_mtr.h:122
@ RTE_MTR_NONE
Definition: rte_mtr.h:113
@ RTE_MTR_TRTCM_RFC2698
Definition: rte_mtr.h:119
__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_error_type
Definition: rte_mtr.h:428
@ RTE_MTR_ERROR_TYPE_NONE
Definition: rte_mtr.h:429
@ RTE_MTR_ERROR_TYPE_UNSPECIFIED
Definition: rte_mtr.h:430
__rte_experimental int rte_mtr_meter_enable(uint16_t port_id, uint32_t mtr_id, struct rte_mtr_error *error)
__rte_experimental int rte_mtr_meter_disable(uint16_t port_id, uint32_t mtr_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_color *dscp_table, struct rte_mtr_error *error)
__rte_experimental int rte_mtr_capabilities_get(uint16_t port_id, struct rte_mtr_capabilities *cap, struct rte_mtr_error *error)
int trtcm_rfc4115_packet_mode_supported
Definition: rte_mtr.h:414
uint32_t meter_srtcm_rfc2697_n_max
Definition: rte_mtr.h:328
int color_aware_srtcm_rfc2697_supported
Definition: rte_mtr.h:360
int trtcm_rfc2698_packet_mode_supported
Definition: rte_mtr.h:400
int chaining_use_prev_mtr_color_supported
Definition: rte_mtr.h:311
uint64_t stats_mask
Definition: rte_mtr.h:419
uint32_t shared_n_flows_per_mtr_max
Definition: rte_mtr.h:293
uint32_t meter_trtcm_rfc2698_n_max
Definition: rte_mtr.h:334
uint32_t meter_trtcm_rfc4115_n_max
Definition: rte_mtr.h:340
int color_aware_trtcm_rfc4115_supported
Definition: rte_mtr.h:372
int srtcm_rfc2697_byte_mode_supported
Definition: rte_mtr.h:379
int chaining_use_prev_mtr_color_enforced
Definition: rte_mtr.h:322
int trtcm_rfc2698_byte_mode_supported
Definition: rte_mtr.h:393
uint64_t meter_rate_max
Definition: rte_mtr.h:347
uint32_t chaining_n_mtrs_per_flow_max
Definition: rte_mtr.h:299
int color_aware_trtcm_rfc2698_supported
Definition: rte_mtr.h:366
uint64_t meter_policy_n_max
Definition: rte_mtr.h:354
int srtcm_rfc2697_packet_mode_supported
Definition: rte_mtr.h:386
int trtcm_rfc4115_byte_mode_supported
Definition: rte_mtr.h:407
uint32_t n_shared_max
Definition: rte_mtr.h:277
const char * message
Definition: rte_mtr.h:460
enum rte_mtr_error_type type
Definition: rte_mtr.h:458
const void * cause
Definition: rte_mtr.h:459
const struct rte_flow_action * actions[RTE_COLORS]
Definition: rte_mtr.h:213
struct rte_mtr_meter_profile::@183::@186 trtcm_rfc2698
enum rte_mtr_algorithm alg
Definition: rte_mtr.h:130
struct rte_mtr_meter_profile::@183::@185 srtcm_rfc2697
struct rte_mtr_meter_profile::@183::@187 trtcm_rfc4115
uint32_t meter_policy_id
Definition: rte_mtr.h:263
uint32_t meter_profile_id
Definition: rte_mtr.h:223
uint64_t stats_mask
Definition: rte_mtr.h:260
enum rte_color * dscp_table
Definition: rte_mtr.h:248
int use_prev_mtr_color
Definition: rte_mtr.h:234
int meter_enable
Definition: rte_mtr.h:255
uint64_t n_pkts[RTE_COLORS]
Definition: rte_mtr.h:92
uint64_t n_bytes[RTE_COLORS]
Definition: rte_mtr.h:95
uint64_t n_pkts_dropped
Definition: rte_mtr.h:98
uint64_t n_bytes_dropped
Definition: rte_mtr.h:101