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 | /*--------------------------------------------------------------------------- |
| 16 | * from gdp_logical_qos.h |
| 17 | *--------------------------------------------------------------------------- |
| 18 | */ |
| 19 | |
| 20 | #ifndef __included_xlate_h__ |
| 21 | #define __included_xlate_h__ |
| 22 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 23 | #include <vnet/policer/police.h> |
| 24 | |
| 25 | /* |
| 26 | * edt: * enum sse2_qos_policer_type_en |
| 27 | * Defines type of policer to be allocated |
| 28 | */ |
Damjan Marion | 3891cd8 | 2016-10-27 10:27:00 +0200 | [diff] [blame] | 29 | typedef enum sse2_qos_policer_type_en_ |
| 30 | { |
| 31 | SSE2_QOS_POLICER_TYPE_1R2C = 0, |
| 32 | SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697 = 1, |
| 33 | SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698 = 2, |
| 34 | SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115 = 3, |
| 35 | SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1 = 4, |
| 36 | SSE2_QOS_POLICER_TYPE_MAX |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 37 | } sse2_qos_policer_type_en; |
| 38 | |
| 39 | /* |
| 40 | * edt: * enum |
| 41 | * Enum used to define type of rounding used when calculating policer values |
| 42 | */ |
Damjan Marion | 3891cd8 | 2016-10-27 10:27:00 +0200 | [diff] [blame] | 43 | typedef enum |
| 44 | { |
| 45 | SSE2_QOS_ROUND_TO_CLOSEST = 0, |
| 46 | SSE2_QOS_ROUND_TO_UP, |
| 47 | SSE2_QOS_ROUND_TO_DOWN, |
| 48 | SSE2_QOS_ROUND_INVALID |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 49 | } sse2_qos_round_type_en; |
| 50 | |
| 51 | /* |
| 52 | * edt: * enum |
| 53 | * Enum used to define type of rate for configuration, either pps or kbps. |
| 54 | * If kbps, then burst is in bytes, if pps, then burst is in ms. |
| 55 | * |
| 56 | * Default of zero is kbps, which is inline with how it is programmed |
| 57 | * in actual hardware. However, the warning is that this is reverse logic |
| 58 | * of units_in_bits field in sse2_static_policer_parameters_st, which is |
| 59 | * inline with sse_punt_drop.h. |
| 60 | */ |
Damjan Marion | 3891cd8 | 2016-10-27 10:27:00 +0200 | [diff] [blame] | 61 | typedef enum |
| 62 | { |
| 63 | SSE2_QOS_RATE_KBPS = 0, |
| 64 | SSE2_QOS_RATE_PPS, |
| 65 | SSE2_QOS_RATE_INVALID |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 66 | } sse2_qos_rate_type_en; |
| 67 | |
Matus Fabian | 4ac74c9 | 2016-05-31 07:33:29 -0700 | [diff] [blame] | 68 | /* |
| 69 | * edt: * enum |
| 70 | * Defines type of policer actions. |
| 71 | */ |
Damjan Marion | 3891cd8 | 2016-10-27 10:27:00 +0200 | [diff] [blame] | 72 | typedef enum |
| 73 | { |
| 74 | SSE2_QOS_ACTION_DROP = 0, |
| 75 | SSE2_QOS_ACTION_TRANSMIT, |
| 76 | SSE2_QOS_ACTION_MARK_AND_TRANSMIT |
Matus Fabian | 4ac74c9 | 2016-05-31 07:33:29 -0700 | [diff] [blame] | 77 | } sse2_qos_action_type_en; |
| 78 | |
| 79 | /* |
| 80 | * edt * struct sse2_qos_pol_action_params_st |
| 81 | * This structure is used to hold user configured police action parameters. |
| 82 | * |
| 83 | * element: action_type |
| 84 | * Action type (see sse2_qos_action_type_en). |
| 85 | * elemtnt: dscp |
| 86 | * DSCP value to set when action is SSE2_QOS_ACTION_MARK_AND_TRANSMIT. |
| 87 | */ |
Damjan Marion | 3891cd8 | 2016-10-27 10:27:00 +0200 | [diff] [blame] | 88 | typedef struct sse2_qos_pol_action_params_st_ |
| 89 | { |
| 90 | u8 action_type; |
| 91 | u8 dscp; |
Matus Fabian | 4ac74c9 | 2016-05-31 07:33:29 -0700 | [diff] [blame] | 92 | } sse2_qos_pol_action_params_st; |
| 93 | |
Damjan Marion | 3891cd8 | 2016-10-27 10:27:00 +0200 | [diff] [blame] | 94 | /* |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 95 | * edt: * struct sse2_qos_pol_cfg_params_st |
| 96 | * |
Damjan Marion | 3891cd8 | 2016-10-27 10:27:00 +0200 | [diff] [blame] | 97 | * Description: |
| 98 | * This structure is used to hold user configured policing parameters. |
| 99 | * |
| 100 | * element: cir_kbps |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 101 | * CIR in kbps. |
Damjan Marion | 3891cd8 | 2016-10-27 10:27:00 +0200 | [diff] [blame] | 102 | * element: eir_kbps |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 103 | * EIR or PIR in kbps. |
Damjan Marion | 3891cd8 | 2016-10-27 10:27:00 +0200 | [diff] [blame] | 104 | * element: cb_bytes |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 105 | * Committed Burst in bytes. |
Damjan Marion | 3891cd8 | 2016-10-27 10:27:00 +0200 | [diff] [blame] | 106 | * element: eb_bytes |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 107 | * Excess or Peak Burst in bytes. |
Damjan Marion | 3891cd8 | 2016-10-27 10:27:00 +0200 | [diff] [blame] | 108 | * element: cir_pps |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 109 | * CIR in pps. |
Damjan Marion | 3891cd8 | 2016-10-27 10:27:00 +0200 | [diff] [blame] | 110 | * element: eir_pps |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 111 | * EIR or PIR in pps. |
Damjan Marion | 3891cd8 | 2016-10-27 10:27:00 +0200 | [diff] [blame] | 112 | * element: cb_ms |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 113 | * Committed Burst in milliseconds. |
Damjan Marion | 3891cd8 | 2016-10-27 10:27:00 +0200 | [diff] [blame] | 114 | * element: eb_ms |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 115 | * Excess or Peak Burst in milliseconds. |
Damjan Marion | 3891cd8 | 2016-10-27 10:27:00 +0200 | [diff] [blame] | 116 | * element: rate_type |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 117 | * Indicates the union if in kbps/bytes or pps/ms. |
Damjan Marion | 3891cd8 | 2016-10-27 10:27:00 +0200 | [diff] [blame] | 118 | * element: rfc |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 119 | * Policer algorithm - 1R2C, 1R3C (2697), 2R3C (2698) or 2R3C (4115). See |
| 120 | * sse_qos_policer_type_en |
| 121 | * element: rnd_type |
| 122 | * Rounding type (see sse_qos_round_type_en). Needed when policer values |
| 123 | * need to be rounded. Caller can decide on type of rounding used |
| 124 | */ |
Damjan Marion | 3891cd8 | 2016-10-27 10:27:00 +0200 | [diff] [blame] | 125 | typedef struct sse2_qos_pol_cfg_params_st_ |
| 126 | { |
| 127 | union |
| 128 | { |
| 129 | struct |
| 130 | { |
| 131 | u32 cir_kbps; |
| 132 | u32 eir_kbps; |
| 133 | u64 cb_bytes; |
| 134 | u64 eb_bytes; |
| 135 | } kbps; |
| 136 | struct |
| 137 | { |
| 138 | u32 cir_pps; |
| 139 | u32 eir_pps; |
| 140 | u64 cb_ms; |
| 141 | u64 eb_ms; |
| 142 | } pps; |
| 143 | } rb; /* rate burst config */ |
| 144 | u8 rate_type; /* sse2_qos_rate_type_en */ |
| 145 | u8 rnd_type; /* sse2_qos_round_type_en */ |
| 146 | u8 rfc; /* sse2_qos_policer_type_en */ |
| 147 | u8 color_aware; |
| 148 | u8 overwrite_bucket; /* for debugging purposes */ |
| 149 | u32 current_bucket; /* for debugging purposes */ |
| 150 | u32 extended_bucket; /* for debugging purposes */ |
| 151 | sse2_qos_pol_action_params_st conform_action; |
| 152 | sse2_qos_pol_action_params_st exceed_action; |
| 153 | sse2_qos_pol_action_params_st violate_action; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 154 | } sse2_qos_pol_cfg_params_st; |
| 155 | |
| 156 | |
Damjan Marion | 3891cd8 | 2016-10-27 10:27:00 +0200 | [diff] [blame] | 157 | typedef struct sse2_qos_pol_hw_params_st_ |
| 158 | { |
| 159 | u8 rfc; |
| 160 | u8 allow_negative; |
| 161 | u8 rate_exp; |
| 162 | u16 avg_rate_man; |
| 163 | u16 peak_rate_man; |
| 164 | u8 comm_bkt_limit_exp; |
| 165 | u8 comm_bkt_limit_man; |
| 166 | u8 extd_bkt_limit_exp; |
| 167 | u8 extd_bkt_limit_man; |
| 168 | u32 comm_bkt; |
| 169 | u32 extd_bkt; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 170 | } sse2_qos_pol_hw_params_st; |
| 171 | |
| 172 | |
Damjan Marion | 3891cd8 | 2016-10-27 10:27:00 +0200 | [diff] [blame] | 173 | int |
| 174 | sse2_pol_logical_2_physical (sse2_qos_pol_cfg_params_st * cfg, |
| 175 | policer_read_response_type_st * phys); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 176 | |
| 177 | |
| 178 | #endif /* __included_xlate_h__ */ |
Damjan Marion | 3891cd8 | 2016-10-27 10:27:00 +0200 | [diff] [blame] | 179 | |
| 180 | /* |
| 181 | * fd.io coding-style-patch-verification: ON |
| 182 | * |
| 183 | * Local Variables: |
| 184 | * eval: (c-set-style "gnu") |
| 185 | * End: |
| 186 | */ |