xref: /dpdk/examples/qos_meter/rte_policer.c (revision c1656328dbc20420b7ba87b1abee7b699c8e84f4)
13998e2a0SBruce Richardson /* SPDX-License-Identifier: BSD-3-Clause
23998e2a0SBruce Richardson  * Copyright(c) 2010-2014 Intel Corporation
3e6541fdeSIntel  */
4e6541fdeSIntel 
5e6541fdeSIntel #include <stdlib.h>
6e6541fdeSIntel #include "rte_policer.h"
7e6541fdeSIntel 
8e6541fdeSIntel int
rte_phb_config(struct rte_phb * phb_table,uint32_t phb_table_index,enum rte_color pre_meter,enum rte_color post_meter,enum rte_phb_action action)9e6541fdeSIntel rte_phb_config(struct rte_phb *phb_table, uint32_t phb_table_index,
10*c1656328SJasvinder Singh 	enum rte_color pre_meter, enum rte_color post_meter, enum rte_phb_action action)
11e6541fdeSIntel {
12e6541fdeSIntel 	struct rte_phb *phb = NULL;
13e6541fdeSIntel 
14e6541fdeSIntel 	/* User argument checking */
15e6541fdeSIntel 	if (phb_table == NULL) {
16e6541fdeSIntel 		return -1;
17e6541fdeSIntel 	}
18e6541fdeSIntel 
19*c1656328SJasvinder Singh 	if ((pre_meter > RTE_COLOR_RED) || (post_meter > RTE_COLOR_RED) || (pre_meter > post_meter)) {
20e6541fdeSIntel 		return -2;
21e6541fdeSIntel 	}
22e6541fdeSIntel 
23e6541fdeSIntel 	/* Set action in PHB table entry */
24e6541fdeSIntel 	phb = &phb_table[phb_table_index];
25e6541fdeSIntel 	phb->actions[pre_meter][post_meter] = action;
26e6541fdeSIntel 
27e6541fdeSIntel 
28e6541fdeSIntel 	return 0;
29e6541fdeSIntel }
30