blob: 5253bb6c4326409ab98305dc3a6c9b25eb2581b3 [file] [log] [blame]
Ed Warnickecb9cada2015-12-08 15:45:58 -07001/*
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 <vlib/vlib.h>
19#include <vnet/vnet.h>
20
21#include <vnet/policer/xlate.h>
22#include <vnet/policer/police.h>
23
Damjan Marion3891cd82016-10-27 10:27:00 +020024typedef struct
25{
Ed Warnickecb9cada2015-12-08 15:45:58 -070026 /* policer pool, aligned */
Damjan Marion3891cd82016-10-27 10:27:00 +020027 policer_read_response_type_st *policers;
Ed Warnickecb9cada2015-12-08 15:45:58 -070028
29 /* config + template h/w policer instance parallel pools */
Damjan Marion3891cd82016-10-27 10:27:00 +020030 sse2_qos_pol_cfg_params_st *configs;
31 policer_read_response_type_st *policer_templates;
32
Ed Warnickecb9cada2015-12-08 15:45:58 -070033 /* Config by name hash */
Damjan Marion3891cd82016-10-27 10:27:00 +020034 uword *policer_config_by_name;
Ed Warnickecb9cada2015-12-08 15:45:58 -070035
Matus Fabian70e6a8d2016-06-20 08:10:42 -070036 /* Policer by name hash */
Damjan Marion3891cd82016-10-27 10:27:00 +020037 uword *policer_index_by_name;
Matus Fabian70e6a8d2016-06-20 08:10:42 -070038
Ed Warnickecb9cada2015-12-08 15:45:58 -070039 /* Policer by sw_if_index vector */
Damjan Marion3891cd82016-10-27 10:27:00 +020040 u32 *policer_index_by_sw_if_index;
Ed Warnickecb9cada2015-12-08 15:45:58 -070041
42 /* convenience */
Damjan Marion3891cd82016-10-27 10:27:00 +020043 vlib_main_t *vlib_main;
44 vnet_main_t *vnet_main;
Ed Warnickecb9cada2015-12-08 15:45:58 -070045} vnet_policer_main_t;
46
Dave Wallace71612d62017-10-24 01:32:41 -040047extern vnet_policer_main_t vnet_policer_main;
Ed Warnickecb9cada2015-12-08 15:45:58 -070048
Brian Russella71ed782021-01-27 11:34:33 +000049extern vlib_combined_counter_main_t policer_counters[];
50
Damjan Marion3891cd82016-10-27 10:27:00 +020051typedef enum
52{
Ed Warnickecb9cada2015-12-08 15:45:58 -070053 VNET_POLICER_INDEX_BY_SW_IF_INDEX,
54 VNET_POLICER_INDEX_BY_OPAQUE,
55 VNET_POLICER_INDEX_BY_EITHER,
56} vnet_policer_index_t;
57
Damjan Marion3891cd82016-10-27 10:27:00 +020058typedef enum
59{
Ed Warnickecb9cada2015-12-08 15:45:58 -070060 VNET_POLICER_NEXT_TRANSMIT,
61 VNET_POLICER_NEXT_DROP,
62 VNET_POLICER_N_NEXT,
63} vnet_policer_next_t;
64
Damjan Marion3891cd82016-10-27 10:27:00 +020065u8 *format_policer_instance (u8 * s, va_list * va);
66clib_error_t *policer_add_del (vlib_main_t * vm,
67 u8 * name,
68 sse2_qos_pol_cfg_params_st * cfg,
69 u32 * policer_index, u8 is_add);
Ed Warnickecb9cada2015-12-08 15:45:58 -070070
71#endif /* __included_policer_h__ */
Damjan Marion3891cd82016-10-27 10:27:00 +020072
73/*
74 * fd.io coding-style-patch-verification: ON
75 *
76 * Local Variables:
77 * eval: (c-set-style "gnu")
78 * End:
79 */