DPDK 26.11.0-rc1
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
45#include <stdint.h>
46#include <rte_compat.h>
47#include <rte_common.h>
48#include <rte_meter.h>
49#include <rte_flow.h>
50
51#ifdef __cplusplus
52extern "C" {
53#endif
54
61
64
67
70
73
76
79
82};
83
89 uint64_t n_pkts[RTE_COLORS];
90
93
96
99};
100
111
114
117
120};
121
128
129 union {
131 struct {
136 uint64_t cir;
137
139 uint64_t cbs;
140
142 uint64_t ebs;
144
146 struct {
151 uint64_t cir;
152
157 uint64_t pir;
158
160 uint64_t cbs;
161
163 uint64_t pbs;
165
167 struct {
172 uint64_t cir;
173
178 uint64_t eir;
179
181 uint64_t cbs;
182
184 uint64_t ebs;
186 };
187
197};
198
210};
211
254};
255
264
275
334
338 uint64_t stats_mask;
339
342
348};
349
355 uint32_t n_max;
356
361 uint32_t n_shared_max;
362
367
372
378
384
396
407
413
419
425
432
439
445
451
457
464
471
478
485
492
499
503 uint64_t stats_mask;
504
509
514};
515
525 RTE_MTR_ERROR_TYPE_METER_PROFILE_ID,
526 RTE_MTR_ERROR_TYPE_METER_PROFILE,
527 RTE_MTR_ERROR_TYPE_METER_PROFILE_PACKET_MODE,
528 RTE_MTR_ERROR_TYPE_MTR_ID,
529 RTE_MTR_ERROR_TYPE_MTR_PARAMS,
530 RTE_MTR_ERROR_TYPE_POLICER_ACTION_GREEN,
531 RTE_MTR_ERROR_TYPE_POLICER_ACTION_YELLOW,
532 RTE_MTR_ERROR_TYPE_POLICER_ACTION_RED,
533 RTE_MTR_ERROR_TYPE_STATS_MASK,
534 RTE_MTR_ERROR_TYPE_STATS,
535 RTE_MTR_ERROR_TYPE_SHARED,
536 RTE_MTR_ERROR_TYPE_METER_POLICY_ID,
537 RTE_MTR_ERROR_TYPE_METER_POLICY,
538};
539
553 const void *cause;
554 const char *message;
555};
556
569int
571 struct rte_mtr_capabilities *cap,
572 struct rte_mtr_error *error);
573
592int
594 uint32_t meter_profile_id,
595 struct rte_mtr_meter_profile *profile,
596 struct rte_mtr_error *error);
597
613int
615 uint32_t meter_profile_id,
616 struct rte_mtr_error *error);
617
632struct rte_flow_meter_profile *
634 uint32_t meter_profile_id,
635 struct rte_mtr_error *error);
636
659int
661 struct rte_mtr_meter_policy_params *policy,
662 struct rte_mtr_error *error);
663
685int
687 uint32_t policy_id,
688 struct rte_mtr_meter_policy_params *policy,
689 struct rte_mtr_error *error);
690
705struct rte_flow_meter_policy *
707 uint32_t policy_id,
708 struct rte_mtr_error *error);
709
714#define rte_mtr_policy_pass_color(policy) \
715struct rte_mtr_meter_policy_params policy = \
716{ \
717 .actions[RTE_COLOR_GREEN] = (struct rte_flow_action[]) { \
718 { \
719 .type = RTE_FLOW_ACTION_TYPE_METER_COLOR, \
720 .conf = &(struct rte_flow_action_meter_color) { \
721 .color = RTE_COLOR_GREEN, \
722 }, \
723 }, \
724 { \
725 .type = RTE_FLOW_ACTION_TYPE_END, \
726 }, \
727 }, \
728 .actions[RTE_COLOR_YELLOW] = (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_YELLOW, \
733 }, \
734 }, \
735 { \
736 .type = RTE_FLOW_ACTION_TYPE_END, \
737 }, \
738 }, \
739 .actions[RTE_COLOR_RED] = (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_RED, \
744 }, \
745 }, \
746 { \
747 .type = RTE_FLOW_ACTION_TYPE_END, \
748 }, \
749 }, \
750}
751
756#define rte_mtr_policy_drop_red(policy) \
757struct rte_mtr_meter_policy_params policy = \
758{ \
759 .actions[RTE_COLOR_GREEN] = NULL, \
760 .actions[RTE_COLOR_YELLOW] = NULL, \
761 .actions[RTE_COLOR_RED] = (struct rte_flow_action[]) { \
762 { \
763 .type = RTE_FLOW_ACTION_TYPE_DROP, \
764 }, \
765 { \
766 .type = RTE_FLOW_ACTION_TYPE_END, \
767 }, \
768 }, \
769}
770
786int
788 uint32_t policy_id,
789 struct rte_mtr_error *error);
790
814int
815rte_mtr_create(uint16_t port_id,
816 uint32_t mtr_id,
817 struct rte_mtr_params *params,
818 int shared,
819 struct rte_mtr_error *error);
820
837int
838rte_mtr_destroy(uint16_t port_id,
839 uint32_t mtr_id,
840 struct rte_mtr_error *error);
841
864int
865rte_mtr_meter_disable(uint16_t port_id,
866 uint32_t mtr_id,
867 struct rte_mtr_error *error);
868
885int
886rte_mtr_meter_enable(uint16_t port_id,
887 uint32_t mtr_id,
888 struct rte_mtr_error *error);
889
904int
906 uint32_t mtr_id,
907 uint32_t meter_profile_id,
908 struct rte_mtr_error *error);
909
924int
926 uint32_t mtr_id,
927 uint32_t meter_policy_id,
928 struct rte_mtr_error *error);
929
950int
952 uint32_t mtr_id, enum rte_mtr_color_in_protocol proto,
953 enum rte_color *dscp_table,
954 struct rte_mtr_error *error);
955
976int
977rte_mtr_meter_vlan_table_update(uint16_t port_id, uint32_t mtr_id,
978 enum rte_mtr_color_in_protocol proto,
979 enum rte_color *vlan_table,
980 struct rte_mtr_error *error);
981
1006int
1007rte_mtr_color_in_protocol_set(uint16_t port_id, uint32_t mtr_id,
1008 enum rte_mtr_color_in_protocol proto, uint32_t priority,
1009 struct rte_mtr_error *error);
1010
1025int
1026rte_mtr_color_in_protocol_get(uint16_t port_id, uint32_t mtr_id,
1027 uint64_t *proto_mask,
1028 struct rte_mtr_error *error);
1029
1046int
1047rte_mtr_color_in_protocol_priority_get(uint16_t port_id, uint32_t mtr_id,
1048 enum rte_mtr_color_in_protocol proto, uint32_t *priority,
1049 struct rte_mtr_error *error);
1050
1069int
1070rte_mtr_stats_update(uint16_t port_id,
1071 uint32_t mtr_id,
1072 uint64_t stats_mask,
1073 struct rte_mtr_error *error);
1074
1100int
1101rte_mtr_stats_read(uint16_t port_id,
1102 uint32_t mtr_id,
1103 struct rte_mtr_stats *stats,
1104 uint64_t *stats_mask,
1105 int clear,
1106 struct rte_mtr_error *error);
1107
1108#ifdef __cplusplus
1109}
1110#endif
1111
1112#endif /* __INCLUDE_RTE_MTR_H__ */
#define RTE_BIT64(nr)
Definition: rte_bitops.h:36
rte_color
Definition: rte_meter.h:31
@ RTE_COLORS
Definition: rte_meter.h:35
int rte_mtr_capabilities_get(uint16_t port_id, struct rte_mtr_capabilities *cap, struct rte_mtr_error *error)
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 rte_mtr_meter_policy_validate(uint16_t port_id, struct rte_mtr_meter_policy_params *policy, struct rte_mtr_error *error)
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)
int rte_mtr_meter_policy_delete(uint16_t port_id, uint32_t policy_id, struct rte_mtr_error *error)
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)
int rte_mtr_meter_disable(uint16_t port_id, uint32_t mtr_id, struct rte_mtr_error *error)
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_mtr_stats_type
Definition: rte_mtr.h:58
@ RTE_MTR_STATS_N_BYTES_GREEN
Definition: rte_mtr.h:72
@ RTE_MTR_STATS_N_PKTS_GREEN
Definition: rte_mtr.h:60
@ RTE_MTR_STATS_N_PKTS_RED
Definition: rte_mtr.h:66
@ RTE_MTR_STATS_N_BYTES_YELLOW
Definition: rte_mtr.h:75
@ RTE_MTR_STATS_N_PKTS_YELLOW
Definition: rte_mtr.h:63
@ RTE_MTR_STATS_N_PKTS_DROPPED
Definition: rte_mtr.h:69
@ RTE_MTR_STATS_N_BYTES_RED
Definition: rte_mtr.h:78
@ RTE_MTR_STATS_N_BYTES_DROPPED
Definition: rte_mtr.h:81
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 rte_mtr_meter_policy_update(uint16_t port_id, uint32_t mtr_id, uint32_t meter_policy_id, struct rte_mtr_error *error)
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)
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)
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 rte_mtr_destroy(uint16_t port_id, uint32_t mtr_id, struct rte_mtr_error *error)
rte_mtr_algorithm
Definition: rte_mtr.h:104
@ RTE_MTR_SRTCM_RFC2697
Definition: rte_mtr.h:113
@ RTE_MTR_TRTCM_RFC4115
Definition: rte_mtr.h:119
@ RTE_MTR_NONE
Definition: rte_mtr.h:110
@ RTE_MTR_TRTCM_RFC2698
Definition: rte_mtr.h:116
int rte_mtr_stats_update(uint16_t port_id, uint32_t mtr_id, uint64_t stats_mask, struct rte_mtr_error *error)
int rte_mtr_meter_enable(uint16_t port_id, uint32_t mtr_id, struct rte_mtr_error *error)
rte_mtr_error_type
Definition: rte_mtr.h:522
@ RTE_MTR_ERROR_TYPE_NONE
Definition: rte_mtr.h:523
@ RTE_MTR_ERROR_TYPE_UNSPECIFIED
Definition: rte_mtr.h:524
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)
struct rte_flow_meter_policy * rte_mtr_meter_policy_get(uint16_t port_id, uint32_t policy_id, struct rte_mtr_error *error)
int rte_mtr_meter_profile_update(uint16_t port_id, uint32_t mtr_id, uint32_t meter_profile_id, struct rte_mtr_error *error)
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)
int rte_mtr_meter_profile_delete(uint16_t port_id, uint32_t meter_profile_id, struct rte_mtr_error *error)
rte_mtr_color_in_protocol
Definition: rte_mtr.h:223
@ RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN
Definition: rte_mtr.h:231
@ RTE_MTR_COLOR_IN_PROTO_OUTER_IP
Definition: rte_mtr.h:246
@ RTE_MTR_COLOR_IN_PROTO_INNER_IP
Definition: rte_mtr.h:253
@ RTE_MTR_COLOR_IN_PROTO_INNER_VLAN
Definition: rte_mtr.h:239
int trtcm_rfc4115_packet_mode_supported
Definition: rte_mtr.h:498
uint32_t meter_srtcm_rfc2697_n_max
Definition: rte_mtr.h:412
int color_aware_srtcm_rfc2697_supported
Definition: rte_mtr.h:444
int trtcm_rfc2698_packet_mode_supported
Definition: rte_mtr.h:484
int chaining_use_prev_mtr_color_supported
Definition: rte_mtr.h:395
uint64_t stats_mask
Definition: rte_mtr.h:503
uint32_t shared_n_flows_per_mtr_max
Definition: rte_mtr.h:377
uint32_t meter_trtcm_rfc2698_n_max
Definition: rte_mtr.h:418
uint32_t meter_trtcm_rfc4115_n_max
Definition: rte_mtr.h:424
int color_aware_trtcm_rfc4115_supported
Definition: rte_mtr.h:456
int srtcm_rfc2697_byte_mode_supported
Definition: rte_mtr.h:463
int chaining_use_prev_mtr_color_enforced
Definition: rte_mtr.h:406
int separate_input_color_table_per_port
Definition: rte_mtr.h:513
int trtcm_rfc2698_byte_mode_supported
Definition: rte_mtr.h:477
uint64_t meter_rate_max
Definition: rte_mtr.h:431
uint32_t chaining_n_mtrs_per_flow_max
Definition: rte_mtr.h:383
int color_aware_trtcm_rfc2698_supported
Definition: rte_mtr.h:450
uint64_t meter_policy_n_max
Definition: rte_mtr.h:438
int srtcm_rfc2697_packet_mode_supported
Definition: rte_mtr.h:470
int trtcm_rfc4115_byte_mode_supported
Definition: rte_mtr.h:491
uint32_t n_shared_max
Definition: rte_mtr.h:361
uint64_t input_color_proto_mask
Definition: rte_mtr.h:508
const char * message
Definition: rte_mtr.h:554
enum rte_mtr_error_type type
Definition: rte_mtr.h:552
const void * cause
Definition: rte_mtr.h:553
const struct rte_flow_action * actions[RTE_COLORS]
Definition: rte_mtr.h:209
struct rte_mtr_meter_profile::@233::@237 trtcm_rfc4115
enum rte_mtr_algorithm alg
Definition: rte_mtr.h:127
struct rte_mtr_meter_profile::@233::@235 srtcm_rfc2697
struct rte_mtr_meter_profile::@233::@236 trtcm_rfc2698
uint32_t meter_policy_id
Definition: rte_mtr.h:341
uint32_t meter_profile_id
Definition: rte_mtr.h:263
uint64_t stats_mask
Definition: rte_mtr.h:338
enum rte_color * dscp_table
Definition: rte_mtr.h:301
int use_prev_mtr_color
Definition: rte_mtr.h:274
int meter_enable
Definition: rte_mtr.h:333
enum rte_color default_input_color
Definition: rte_mtr.h:347
enum rte_color * vlan_table
Definition: rte_mtr.h:327
uint64_t n_pkts[RTE_COLORS]
Definition: rte_mtr.h:89
uint64_t n_bytes[RTE_COLORS]
Definition: rte_mtr.h:92
uint64_t n_pkts_dropped
Definition: rte_mtr.h:95
uint64_t n_bytes_dropped
Definition: rte_mtr.h:98