New upstream version 18.02
[deb_dpdk.git] / examples / qos_meter / rte_policer.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2014 Intel Corporation
3  */
4
5 #ifndef __INCLUDE_RTE_POLICER_H__
6 #define __INCLUDE_RTE_POLICER_H__
7
8 #include <stdint.h>
9 #include <rte_meter.h>
10
11 enum rte_phb_action {
12         e_RTE_PHB_ACTION_GREEN = e_RTE_METER_GREEN,
13         e_RTE_PHB_ACTION_YELLOW = e_RTE_METER_YELLOW,
14         e_RTE_PHB_ACTION_RED = e_RTE_METER_RED,
15         e_RTE_PHB_ACTION_DROP = 3,
16 };
17
18 struct rte_phb {
19         enum rte_phb_action actions[e_RTE_METER_COLORS][e_RTE_METER_COLORS];
20 };
21
22 int
23 rte_phb_config(struct rte_phb *phb_table, uint32_t phb_table_index,
24         enum rte_meter_color pre_meter, enum rte_meter_color post_meter, enum rte_phb_action action);
25
26 static inline enum rte_phb_action
27 policer_run(struct rte_phb *phb_table, uint32_t phb_table_index, enum rte_meter_color pre_meter, enum rte_meter_color post_meter)
28 {
29         struct rte_phb *phb = &phb_table[phb_table_index];
30         enum rte_phb_action action = phb->actions[pre_meter][post_meter];
31
32         return action;
33 }
34
35 #endif