DPDK  19.02.0
rte_mtr.h
Go to the documentation of this file.
1 /*-
2  * BSD LICENSE
3  *
4  * Copyright 2017 Intel Corporation
5  * Copyright 2017 NXP
6  * Copyright 2017 Cavium
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * * Redistributions in binary form must reproduce the above copyright
15  * notice, this list of conditions and the following disclaimer in
16  * the documentation and/or other materials provided with the
17  * distribution.
18  * * Neither the name of Intel Corporation nor the names of its
19  * contributors may be used to endorse or promote products derived
20  * from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  */
34 
35 #ifndef __INCLUDE_RTE_MTR_H__
36 #define __INCLUDE_RTE_MTR_H__
37 
76 #include <stdint.h>
77 #include <rte_compat.h>
78 #include <rte_common.h>
79 #include <rte_meter.h>
80 
81 #ifdef __cplusplus
82 extern "C" {
83 #endif
84 
85 /* New rte_color is defined and used to deprecate rte_mtr_color soon. */
86 #define rte_mtr_color rte_color
87 #define RTE_MTR_GREEN RTE_COLOR_GREEN
88 #define RTE_MTR_YELLOW RTE_COLOR_YELLOW
89 #define RTE_MTR_RED RTE_COLOR_RED
90 #define RTE_MTR_COLORS RTE_COLORS
91 
98 
101 
104 
107 
110 
113 
116 
119 };
120 
126  uint64_t n_pkts[RTE_MTR_COLORS];
127 
129  uint64_t n_bytes[RTE_MTR_COLORS];
130 
132  uint64_t n_pkts_dropped;
133 
135  uint64_t n_bytes_dropped;
136 };
137 
148 
151 
154 
157 };
158 
165 
167  union {
169  struct {
171  uint64_t cir;
172 
174  uint64_t cbs;
175 
177  uint64_t ebs;
178  } srtcm_rfc2697;
179 
181  struct {
183  uint64_t cir;
184 
186  uint64_t pir;
187 
189  uint64_t cbs;
190 
192  uint64_t pbs;
193  } trtcm_rfc2698;
194 
196  struct {
198  uint64_t cir;
199 
201  uint64_t eir;
202 
204  uint64_t cbs;
205 
207  uint64_t ebs;
208  } trtcm_rfc4115;
209  };
210 };
211 
218 
221 
224 
227 };
228 
237 
248 
261  enum rte_mtr_color *dscp_table;
262 
269 
271  enum rte_mtr_policer_action action[RTE_MTR_COLORS];
272 
276  uint64_t stats_mask;
277 };
278 
284  uint32_t n_max;
285 
290  uint32_t n_shared_max;
291 
296 
301 
307 
313 
325 
336 
342 
348 
354 
360  uint64_t meter_rate_max;
361 
367 
373 
379 
385 
391 
395  uint64_t stats_mask;
396 };
397 
407  RTE_MTR_ERROR_TYPE_METER_PROFILE_ID,
408  RTE_MTR_ERROR_TYPE_METER_PROFILE,
409  RTE_MTR_ERROR_TYPE_MTR_ID,
410  RTE_MTR_ERROR_TYPE_MTR_PARAMS,
411  RTE_MTR_ERROR_TYPE_POLICER_ACTION_GREEN,
412  RTE_MTR_ERROR_TYPE_POLICER_ACTION_YELLOW,
413  RTE_MTR_ERROR_TYPE_POLICER_ACTION_RED,
414  RTE_MTR_ERROR_TYPE_STATS_MASK,
415  RTE_MTR_ERROR_TYPE_STATS,
416  RTE_MTR_ERROR_TYPE_SHARED,
417 };
418 
432  const void *cause;
433  const char *message;
434 };
435 
448 int __rte_experimental
449 rte_mtr_capabilities_get(uint16_t port_id,
450  struct rte_mtr_capabilities *cap,
451  struct rte_mtr_error *error);
452 
471 int __rte_experimental
472 rte_mtr_meter_profile_add(uint16_t port_id,
473  uint32_t meter_profile_id,
474  struct rte_mtr_meter_profile *profile,
475  struct rte_mtr_error *error);
476 
492 int __rte_experimental
493 rte_mtr_meter_profile_delete(uint16_t port_id,
494  uint32_t meter_profile_id,
495  struct rte_mtr_error *error);
496 
520 int __rte_experimental
521 rte_mtr_create(uint16_t port_id,
522  uint32_t mtr_id,
523  struct rte_mtr_params *params,
524  int shared,
525  struct rte_mtr_error *error);
526 
543 int __rte_experimental
544 rte_mtr_destroy(uint16_t port_id,
545  uint32_t mtr_id,
546  struct rte_mtr_error *error);
547 
570 int __rte_experimental
571 rte_mtr_meter_disable(uint16_t port_id,
572  uint32_t mtr_id,
573  struct rte_mtr_error *error);
574 
591 int __rte_experimental
592 rte_mtr_meter_enable(uint16_t port_id,
593  uint32_t mtr_id,
594  struct rte_mtr_error *error);
595 
610 int __rte_experimental
611 rte_mtr_meter_profile_update(uint16_t port_id,
612  uint32_t mtr_id,
613  uint32_t meter_profile_id,
614  struct rte_mtr_error *error);
615 
634 int __rte_experimental
635 rte_mtr_meter_dscp_table_update(uint16_t port_id,
636  uint32_t mtr_id,
637  enum rte_mtr_color *dscp_table,
638  struct rte_mtr_error *error);
639 
660 int __rte_experimental
661 rte_mtr_policer_actions_update(uint16_t port_id,
662  uint32_t mtr_id,
663  uint32_t action_mask,
664  enum rte_mtr_policer_action *actions,
665  struct rte_mtr_error *error);
666 
685 int __rte_experimental
686 rte_mtr_stats_update(uint16_t port_id,
687  uint32_t mtr_id,
688  uint64_t stats_mask,
689  struct rte_mtr_error *error);
690 
716 int __rte_experimental
717 rte_mtr_stats_read(uint16_t port_id,
718  uint32_t mtr_id,
719  struct rte_mtr_stats *stats,
720  uint64_t *stats_mask,
721  int clear,
722  struct rte_mtr_error *error);
723 
724 #ifdef __cplusplus
725 }
726 #endif
727 
728 #endif /* __INCLUDE_RTE_MTR_H__ */