blob: d9c4ed2a45198bdd15d8ea57574bd6cd6a6ea592 [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
Brian Russell48e26362021-02-10 13:53:42 +000018#include <stdbool.h>
19
Ed Warnickecb9cada2015-12-08 15:45:58 -070020#include <vlib/vlib.h>
21#include <vnet/vnet.h>
22
23#include <vnet/policer/xlate.h>
24#include <vnet/policer/police.h>
25
Damjan Marion3891cd82016-10-27 10:27:00 +020026typedef struct
27{
Ed Warnickecb9cada2015-12-08 15:45:58 -070028 /* policer pool, aligned */
Brian Russell54be0cc2021-02-15 11:49:42 +000029 policer_t *policers;
Ed Warnickecb9cada2015-12-08 15:45:58 -070030
31 /* config + template h/w policer instance parallel pools */
Brian Russellc5299ff2021-02-09 10:16:58 +000032 qos_pol_cfg_params_st *configs;
Brian Russell54be0cc2021-02-15 11:49:42 +000033 policer_t *policer_templates;
Damjan Marion3891cd82016-10-27 10:27:00 +020034
Ed Warnickecb9cada2015-12-08 15:45:58 -070035 /* Config by name hash */
Damjan Marion3891cd82016-10-27 10:27:00 +020036 uword *policer_config_by_name;
Ed Warnickecb9cada2015-12-08 15:45:58 -070037
Matus Fabian70e6a8d2016-06-20 08:10:42 -070038 /* Policer by name hash */
Damjan Marion3891cd82016-10-27 10:27:00 +020039 uword *policer_index_by_name;
Matus Fabian70e6a8d2016-06-20 08:10:42 -070040
Ed Warnickecb9cada2015-12-08 15:45:58 -070041 /* Policer by sw_if_index vector */
Damjan Marion3891cd82016-10-27 10:27:00 +020042 u32 *policer_index_by_sw_if_index;
Ed Warnickecb9cada2015-12-08 15:45:58 -070043
44 /* convenience */
Damjan Marion3891cd82016-10-27 10:27:00 +020045 vlib_main_t *vlib_main;
46 vnet_main_t *vnet_main;
Brian Russellbbccdc52021-02-10 18:34:48 +000047
48 vlib_log_class_t log_class;
Brian Russell1aa99122021-02-18 11:00:38 +000049
50 /* frame queue for thread handoff */
51 u32 fq_index;
Ed Warnickecb9cada2015-12-08 15:45:58 -070052} vnet_policer_main_t;
53
Dave Wallace71612d62017-10-24 01:32:41 -040054extern vnet_policer_main_t vnet_policer_main;
Ed Warnickecb9cada2015-12-08 15:45:58 -070055
Brian Russella71ed782021-01-27 11:34:33 +000056extern vlib_combined_counter_main_t policer_counters[];
57
Brian Russell1aa99122021-02-18 11:00:38 +000058extern vlib_node_registration_t policer_input_node;
59
Damjan Marion3891cd82016-10-27 10:27:00 +020060typedef enum
61{
Ed Warnickecb9cada2015-12-08 15:45:58 -070062 VNET_POLICER_NEXT_DROP,
Brian Russell1aa99122021-02-18 11:00:38 +000063 VNET_POLICER_NEXT_HANDOFF,
Ed Warnickecb9cada2015-12-08 15:45:58 -070064 VNET_POLICER_N_NEXT,
65} vnet_policer_next_t;
66
Damjan Marion3891cd82016-10-27 10:27:00 +020067u8 *format_policer_instance (u8 * s, va_list * va);
Brian Russellc5299ff2021-02-09 10:16:58 +000068clib_error_t *policer_add_del (vlib_main_t *vm, u8 *name,
69 qos_pol_cfg_params_st *cfg, u32 *policer_index,
70 u8 is_add);
Brian Russell48e26362021-02-10 13:53:42 +000071int policer_bind_worker (u8 *name, u32 worker, bool bind);
Brian Russellb0468302021-02-17 15:51:45 +000072int policer_input (u8 *name, u32 sw_if_index, bool apply);
Ed Warnickecb9cada2015-12-08 15:45:58 -070073
74#endif /* __included_policer_h__ */
Damjan Marion3891cd82016-10-27 10:27:00 +020075
76/*
77 * fd.io coding-style-patch-verification: ON
78 *
79 * Local Variables:
80 * eval: (c-set-style "gnu")
81 * End:
82 */