policer: add api to bind policer to worker
[vpp.git] / src / vnet / policer / policer.h
1 /*
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:
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
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.
14  */
15 #ifndef __included_policer_h__
16 #define __included_policer_h__
17
18 #include <stdbool.h>
19
20 #include <vlib/vlib.h>
21 #include <vnet/vnet.h>
22
23 #include <vnet/policer/xlate.h>
24 #include <vnet/policer/police.h>
25
26 typedef struct
27 {
28   /* policer pool, aligned */
29   policer_read_response_type_st *policers;
30
31   /* config + template h/w policer instance parallel pools */
32   qos_pol_cfg_params_st *configs;
33   policer_read_response_type_st *policer_templates;
34
35   /* Config by name hash */
36   uword *policer_config_by_name;
37
38   /* Policer by name hash */
39   uword *policer_index_by_name;
40
41   /* Policer by sw_if_index vector */
42   u32 *policer_index_by_sw_if_index;
43
44   /* convenience */
45   vlib_main_t *vlib_main;
46   vnet_main_t *vnet_main;
47
48   vlib_log_class_t log_class;
49 } vnet_policer_main_t;
50
51 extern vnet_policer_main_t vnet_policer_main;
52
53 extern vlib_combined_counter_main_t policer_counters[];
54
55 typedef enum
56 {
57   VNET_POLICER_INDEX_BY_SW_IF_INDEX,
58   VNET_POLICER_INDEX_BY_OPAQUE,
59   VNET_POLICER_INDEX_BY_EITHER,
60 } vnet_policer_index_t;
61
62 typedef enum
63 {
64   VNET_POLICER_NEXT_TRANSMIT,
65   VNET_POLICER_NEXT_DROP,
66   VNET_POLICER_N_NEXT,
67 } vnet_policer_next_t;
68
69 u8 *format_policer_instance (u8 * s, va_list * va);
70 clib_error_t *policer_add_del (vlib_main_t *vm, u8 *name,
71                                qos_pol_cfg_params_st *cfg, u32 *policer_index,
72                                u8 is_add);
73 int policer_bind_worker (u8 *name, u32 worker, bool bind);
74
75 #endif /* __included_policer_h__ */
76
77 /*
78  * fd.io coding-style-patch-verification: ON
79  *
80  * Local Variables:
81  * eval: (c-set-style "gnu")
82  * End:
83  */