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 | |
| 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 Marion | 3891cd8 | 2016-10-27 10:27:00 +0200 | [diff] [blame] | 24 | typedef struct |
| 25 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 26 | /* policer pool, aligned */ |
Damjan Marion | 3891cd8 | 2016-10-27 10:27:00 +0200 | [diff] [blame] | 27 | policer_read_response_type_st *policers; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 28 | |
| 29 | /* config + template h/w policer instance parallel pools */ |
Damjan Marion | 3891cd8 | 2016-10-27 10:27:00 +0200 | [diff] [blame] | 30 | sse2_qos_pol_cfg_params_st *configs; |
| 31 | policer_read_response_type_st *policer_templates; |
| 32 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 33 | /* Config by name hash */ |
Damjan Marion | 3891cd8 | 2016-10-27 10:27:00 +0200 | [diff] [blame] | 34 | uword *policer_config_by_name; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 35 | |
Matus Fabian | 70e6a8d | 2016-06-20 08:10:42 -0700 | [diff] [blame] | 36 | /* Policer by name hash */ |
Damjan Marion | 3891cd8 | 2016-10-27 10:27:00 +0200 | [diff] [blame] | 37 | uword *policer_index_by_name; |
Matus Fabian | 70e6a8d | 2016-06-20 08:10:42 -0700 | [diff] [blame] | 38 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 39 | /* Policer by sw_if_index vector */ |
Damjan Marion | 3891cd8 | 2016-10-27 10:27:00 +0200 | [diff] [blame] | 40 | u32 *policer_index_by_sw_if_index; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 41 | |
| 42 | /* convenience */ |
Damjan Marion | 3891cd8 | 2016-10-27 10:27:00 +0200 | [diff] [blame] | 43 | vlib_main_t *vlib_main; |
| 44 | vnet_main_t *vnet_main; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 45 | } vnet_policer_main_t; |
| 46 | |
Dave Wallace | 71612d6 | 2017-10-24 01:32:41 -0400 | [diff] [blame] | 47 | extern vnet_policer_main_t vnet_policer_main; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 48 | |
Damjan Marion | 3891cd8 | 2016-10-27 10:27:00 +0200 | [diff] [blame] | 49 | typedef enum |
| 50 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 51 | VNET_POLICER_INDEX_BY_SW_IF_INDEX, |
| 52 | VNET_POLICER_INDEX_BY_OPAQUE, |
| 53 | VNET_POLICER_INDEX_BY_EITHER, |
| 54 | } vnet_policer_index_t; |
| 55 | |
Damjan Marion | 3891cd8 | 2016-10-27 10:27:00 +0200 | [diff] [blame] | 56 | typedef enum |
| 57 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 58 | VNET_POLICER_NEXT_TRANSMIT, |
| 59 | VNET_POLICER_NEXT_DROP, |
| 60 | VNET_POLICER_N_NEXT, |
| 61 | } vnet_policer_next_t; |
| 62 | |
Matus Fabian | 4ac74c9 | 2016-05-31 07:33:29 -0700 | [diff] [blame] | 63 | #define foreach_vnet_dscp \ |
| 64 | _(0 , CS0, "CS0") \ |
| 65 | _(8 , CS1, "CS1") \ |
| 66 | _(10, AF11, "AF11") \ |
| 67 | _(12, AF12, "AF12") \ |
| 68 | _(14, AF13, "AF13") \ |
| 69 | _(16, CS2, "CS2") \ |
| 70 | _(18, AF21, "AF21") \ |
| 71 | _(20, AF22, "AF22") \ |
| 72 | _(22, AF23, "AF23") \ |
| 73 | _(24, CS3, "CS3") \ |
| 74 | _(26, AF31, "AF31") \ |
| 75 | _(28, AF32, "AF32") \ |
| 76 | _(30, AF33, "AF33") \ |
| 77 | _(32, CS4, "CS4") \ |
| 78 | _(34, AF41, "AF41") \ |
| 79 | _(36, AF42, "AF42") \ |
| 80 | _(38, AF43, "AF43") \ |
| 81 | _(40, CS5, "CS5") \ |
| 82 | _(46, EF, "EF") \ |
| 83 | _(48, CS6, "CS6") \ |
| 84 | _(50, CS7, "CS7") |
| 85 | |
Damjan Marion | 3891cd8 | 2016-10-27 10:27:00 +0200 | [diff] [blame] | 86 | typedef enum |
| 87 | { |
Matus Fabian | 4ac74c9 | 2016-05-31 07:33:29 -0700 | [diff] [blame] | 88 | #define _(v,f,str) VNET_DSCP_##f = v, |
| 89 | foreach_vnet_dscp |
| 90 | #undef _ |
| 91 | } vnet_dscp_t; |
| 92 | |
Damjan Marion | 3891cd8 | 2016-10-27 10:27:00 +0200 | [diff] [blame] | 93 | u8 *format_policer_instance (u8 * s, va_list * va); |
| 94 | clib_error_t *policer_add_del (vlib_main_t * vm, |
| 95 | u8 * name, |
| 96 | sse2_qos_pol_cfg_params_st * cfg, |
| 97 | u32 * policer_index, u8 is_add); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 98 | |
| 99 | #endif /* __included_policer_h__ */ |
Damjan Marion | 3891cd8 | 2016-10-27 10:27:00 +0200 | [diff] [blame] | 100 | |
| 101 | /* |
| 102 | * fd.io coding-style-patch-verification: ON |
| 103 | * |
| 104 | * Local Variables: |
| 105 | * eval: (c-set-style "gnu") |
| 106 | * End: |
| 107 | */ |