Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 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 | |
Brian Russell | 48e2636 | 2021-02-10 13:53:42 +0000 | [diff] [blame] | 18 | #include <stdbool.h> |
| 19 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 20 | #include <vlib/vlib.h> |
| 21 | #include <vnet/vnet.h> |
| 22 | |
| 23 | #include <vnet/policer/xlate.h> |
| 24 | #include <vnet/policer/police.h> |
| 25 | |
Damjan Marion | 3891cd8 | 2016-10-27 10:27:00 +0200 | [diff] [blame] | 26 | typedef struct |
| 27 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 28 | /* policer pool, aligned */ |
Brian Russell | 54be0cc | 2021-02-15 11:49:42 +0000 | [diff] [blame] | 29 | policer_t *policers; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 30 | |
| 31 | /* config + template h/w policer instance parallel pools */ |
Brian Russell | c5299ff | 2021-02-09 10:16:58 +0000 | [diff] [blame] | 32 | qos_pol_cfg_params_st *configs; |
Brian Russell | 54be0cc | 2021-02-15 11:49:42 +0000 | [diff] [blame] | 33 | policer_t *policer_templates; |
Damjan Marion | 3891cd8 | 2016-10-27 10:27:00 +0200 | [diff] [blame] | 34 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 35 | /* Config by name hash */ |
Damjan Marion | 3891cd8 | 2016-10-27 10:27:00 +0200 | [diff] [blame] | 36 | uword *policer_config_by_name; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 37 | |
Matus Fabian | 70e6a8d | 2016-06-20 08:10:42 -0700 | [diff] [blame] | 38 | /* Policer by name hash */ |
Damjan Marion | 3891cd8 | 2016-10-27 10:27:00 +0200 | [diff] [blame] | 39 | uword *policer_index_by_name; |
Matus Fabian | 70e6a8d | 2016-06-20 08:10:42 -0700 | [diff] [blame] | 40 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 41 | /* Policer by sw_if_index vector */ |
Damjan Marion | 3891cd8 | 2016-10-27 10:27:00 +0200 | [diff] [blame] | 42 | u32 *policer_index_by_sw_if_index; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 43 | |
| 44 | /* convenience */ |
Damjan Marion | 3891cd8 | 2016-10-27 10:27:00 +0200 | [diff] [blame] | 45 | vlib_main_t *vlib_main; |
| 46 | vnet_main_t *vnet_main; |
Brian Russell | bbccdc5 | 2021-02-10 18:34:48 +0000 | [diff] [blame] | 47 | |
| 48 | vlib_log_class_t log_class; |
Brian Russell | 1aa9912 | 2021-02-18 11:00:38 +0000 | [diff] [blame] | 49 | |
| 50 | /* frame queue for thread handoff */ |
| 51 | u32 fq_index; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 52 | } vnet_policer_main_t; |
| 53 | |
Dave Wallace | 71612d6 | 2017-10-24 01:32:41 -0400 | [diff] [blame] | 54 | extern vnet_policer_main_t vnet_policer_main; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 55 | |
Brian Russell | a71ed78 | 2021-01-27 11:34:33 +0000 | [diff] [blame] | 56 | extern vlib_combined_counter_main_t policer_counters[]; |
| 57 | |
Brian Russell | 1aa9912 | 2021-02-18 11:00:38 +0000 | [diff] [blame] | 58 | extern vlib_node_registration_t policer_input_node; |
| 59 | |
Damjan Marion | 3891cd8 | 2016-10-27 10:27:00 +0200 | [diff] [blame] | 60 | typedef enum |
| 61 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 62 | VNET_POLICER_NEXT_DROP, |
Brian Russell | 1aa9912 | 2021-02-18 11:00:38 +0000 | [diff] [blame] | 63 | VNET_POLICER_NEXT_HANDOFF, |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 64 | VNET_POLICER_N_NEXT, |
| 65 | } vnet_policer_next_t; |
| 66 | |
Damjan Marion | 3891cd8 | 2016-10-27 10:27:00 +0200 | [diff] [blame] | 67 | u8 *format_policer_instance (u8 * s, va_list * va); |
Brian Russell | c5299ff | 2021-02-09 10:16:58 +0000 | [diff] [blame] | 68 | clib_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 Russell | 48e2636 | 2021-02-10 13:53:42 +0000 | [diff] [blame] | 71 | int policer_bind_worker (u8 *name, u32 worker, bool bind); |
Brian Russell | b046830 | 2021-02-17 15:51:45 +0000 | [diff] [blame] | 72 | int policer_input (u8 *name, u32 sw_if_index, bool apply); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 73 | |
| 74 | #endif /* __included_policer_h__ */ |
Damjan Marion | 3891cd8 | 2016-10-27 10:27:00 +0200 | [diff] [blame] | 75 | |
| 76 | /* |
| 77 | * fd.io coding-style-patch-verification: ON |
| 78 | * |
| 79 | * Local Variables: |
| 80 | * eval: (c-set-style "gnu") |
| 81 | * End: |
| 82 | */ |