2 * Copyright (c) 2015 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
15 #ifndef __included_policer_h__
16 #define __included_policer_h__
20 #include <vlib/vlib.h>
21 #include <vnet/vnet.h>
23 #include <vnet/policer/xlate.h>
24 #include <vnet/policer/police.h>
28 /* policer pool, aligned */
31 /* config + template h/w policer instance parallel pools */
32 qos_pol_cfg_params_st *configs;
33 policer_t *policer_templates;
35 /* Config by policer name hash */
36 uword *policer_config_by_name;
38 /* Policer by name hash */
39 uword *policer_index_by_name;
41 /* Policer by sw_if_index vector */
42 u32 *policer_index_by_sw_if_index[VLIB_N_RX_TX];
45 vlib_main_t *vlib_main;
46 vnet_main_t *vnet_main;
48 vlib_log_class_t log_class;
50 /* frame queue for thread handoff */
51 u32 fq_index[VLIB_N_RX_TX];
54 } vnet_policer_main_t;
56 extern vnet_policer_main_t vnet_policer_main;
58 extern vlib_combined_counter_main_t policer_counters[];
60 extern vlib_node_registration_t policer_input_node;
61 extern vlib_node_registration_t policer_output_node;
65 VNET_POLICER_NEXT_DROP,
66 VNET_POLICER_NEXT_HANDOFF,
68 } vnet_policer_next_t;
70 u8 *format_policer_instance (u8 * s, va_list * va);
71 int policer_add (vlib_main_t *vm, const u8 *name,
72 const qos_pol_cfg_params_st *cfg, u32 *policer_index);
74 int policer_update (vlib_main_t *vm, u32 policer_index,
75 const qos_pol_cfg_params_st *cfg);
76 int policer_del (vlib_main_t *vm, u32 policer_index);
77 int policer_reset (vlib_main_t *vm, u32 policer_index);
78 int policer_bind_worker (u32 policer_index, u32 worker, bool bind);
79 int policer_input (u32 policer_index, u32 sw_if_index, vlib_dir_t dir,
82 #endif /* __included_policer_h__ */
85 * fd.io coding-style-patch-verification: ON
88 * eval: (c-set-style "gnu")