13998e2a0SBruce Richardson /* SPDX-License-Identifier: BSD-3-Clause
23998e2a0SBruce Richardson * Copyright(c) 2010-2014 Intel Corporation
3e6541fdeSIntel */
4e6541fdeSIntel
5e6541fdeSIntel #ifndef __INCLUDE_RTE_POLICER_H__
6e6541fdeSIntel #define __INCLUDE_RTE_POLICER_H__
7e6541fdeSIntel
8e6541fdeSIntel #include <stdint.h>
9e6541fdeSIntel #include <rte_meter.h>
10e6541fdeSIntel
11e6541fdeSIntel enum rte_phb_action {
12*c1656328SJasvinder Singh e_RTE_PHB_ACTION_GREEN = RTE_COLOR_GREEN,
13*c1656328SJasvinder Singh e_RTE_PHB_ACTION_YELLOW = RTE_COLOR_YELLOW,
14*c1656328SJasvinder Singh e_RTE_PHB_ACTION_RED = RTE_COLOR_RED,
15e6541fdeSIntel e_RTE_PHB_ACTION_DROP = 3,
16e6541fdeSIntel };
17e6541fdeSIntel
18e6541fdeSIntel struct rte_phb {
19*c1656328SJasvinder Singh enum rte_phb_action actions[RTE_COLORS][RTE_COLORS];
20e6541fdeSIntel };
21e6541fdeSIntel
22e6541fdeSIntel int
23e6541fdeSIntel rte_phb_config(struct rte_phb *phb_table, uint32_t phb_table_index,
24*c1656328SJasvinder Singh enum rte_color pre_meter, enum rte_color post_meter, enum rte_phb_action action);
25e6541fdeSIntel
26e6541fdeSIntel static inline enum rte_phb_action
policer_run(struct rte_phb * phb_table,uint32_t phb_table_index,enum rte_color pre_meter,enum rte_color post_meter)27*c1656328SJasvinder Singh policer_run(struct rte_phb *phb_table, uint32_t phb_table_index, enum rte_color pre_meter, enum rte_color post_meter)
28e6541fdeSIntel {
29e6541fdeSIntel struct rte_phb *phb = &phb_table[phb_table_index];
30e6541fdeSIntel enum rte_phb_action action = phb->actions[pre_meter][post_meter];
31e6541fdeSIntel
32e6541fdeSIntel return action;
33e6541fdeSIntel }
34e6541fdeSIntel
35e6541fdeSIntel #endif
36