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 | |
Brian Russell | e3845d7 | 2021-02-08 15:33:18 +0000 | [diff] [blame] | 23 | #include <vnet/ip/ip_packet.h> |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 24 | #include <vnet/policer/police.h> |
| 25 | |
| 26 | /* |
Brian Russell | c5299ff | 2021-02-09 10:16:58 +0000 | [diff] [blame] | 27 | * edt: * enum qos_policer_type_en |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 28 | * Defines type of policer to be allocated |
| 29 | */ |
Brian Russell | c5299ff | 2021-02-09 10:16:58 +0000 | [diff] [blame] | 30 | typedef enum qos_policer_type_en_ |
Damjan Marion | 3891cd8 | 2016-10-27 10:27:00 +0200 | [diff] [blame] | 31 | { |
Brian Russell | c5299ff | 2021-02-09 10:16:58 +0000 | [diff] [blame] | 32 | QOS_POLICER_TYPE_1R2C = 0, |
| 33 | QOS_POLICER_TYPE_1R3C_RFC_2697 = 1, |
| 34 | QOS_POLICER_TYPE_2R3C_RFC_2698 = 2, |
| 35 | QOS_POLICER_TYPE_2R3C_RFC_4115 = 3, |
| 36 | QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1 = 4, |
| 37 | QOS_POLICER_TYPE_MAX |
| 38 | } qos_policer_type_en; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 39 | |
| 40 | /* |
| 41 | * edt: * enum |
| 42 | * Enum used to define type of rounding used when calculating policer values |
| 43 | */ |
Damjan Marion | 3891cd8 | 2016-10-27 10:27:00 +0200 | [diff] [blame] | 44 | typedef enum |
| 45 | { |
Brian Russell | c5299ff | 2021-02-09 10:16:58 +0000 | [diff] [blame] | 46 | QOS_ROUND_TO_CLOSEST = 0, |
| 47 | QOS_ROUND_TO_UP, |
| 48 | QOS_ROUND_TO_DOWN, |
| 49 | QOS_ROUND_INVALID |
| 50 | } qos_round_type_en; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 51 | |
| 52 | /* |
| 53 | * edt: * enum |
| 54 | * Enum used to define type of rate for configuration, either pps or kbps. |
| 55 | * If kbps, then burst is in bytes, if pps, then burst is in ms. |
| 56 | * |
| 57 | * Default of zero is kbps, which is inline with how it is programmed |
| 58 | * in actual hardware. However, the warning is that this is reverse logic |
Brian Russell | c5299ff | 2021-02-09 10:16:58 +0000 | [diff] [blame] | 59 | * of units_in_bits field in static_policer_parameters_st, which is |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 60 | * inline with sse_punt_drop.h. |
| 61 | */ |
Damjan Marion | 3891cd8 | 2016-10-27 10:27:00 +0200 | [diff] [blame] | 62 | typedef enum |
| 63 | { |
Brian Russell | c5299ff | 2021-02-09 10:16:58 +0000 | [diff] [blame] | 64 | QOS_RATE_KBPS = 0, |
| 65 | QOS_RATE_PPS, |
| 66 | QOS_RATE_INVALID |
| 67 | } qos_rate_type_en; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 68 | |
Matus Fabian | 4ac74c9 | 2016-05-31 07:33:29 -0700 | [diff] [blame] | 69 | /* |
| 70 | * edt: * enum |
| 71 | * Defines type of policer actions. |
| 72 | */ |
Damjan Marion | 3891cd8 | 2016-10-27 10:27:00 +0200 | [diff] [blame] | 73 | typedef enum |
| 74 | { |
Brian Russell | c5299ff | 2021-02-09 10:16:58 +0000 | [diff] [blame] | 75 | QOS_ACTION_DROP = 0, |
| 76 | QOS_ACTION_TRANSMIT, |
| 77 | QOS_ACTION_MARK_AND_TRANSMIT |
| 78 | } qos_action_type_en; |
Matus Fabian | 4ac74c9 | 2016-05-31 07:33:29 -0700 | [diff] [blame] | 79 | |
| 80 | /* |
Brian Russell | c5299ff | 2021-02-09 10:16:58 +0000 | [diff] [blame] | 81 | * edt * struct qos_pol_action_params_st |
Matus Fabian | 4ac74c9 | 2016-05-31 07:33:29 -0700 | [diff] [blame] | 82 | * This structure is used to hold user configured police action parameters. |
| 83 | * |
| 84 | * element: action_type |
Brian Russell | c5299ff | 2021-02-09 10:16:58 +0000 | [diff] [blame] | 85 | * Action type (see qos_action_type_en). |
Paul Vinciguerra | bdc0e6b | 2018-09-22 05:32:50 -0700 | [diff] [blame] | 86 | * element: dscp |
Brian Russell | c5299ff | 2021-02-09 10:16:58 +0000 | [diff] [blame] | 87 | * DSCP value to set when action is QOS_ACTION_MARK_AND_TRANSMIT. |
Matus Fabian | 4ac74c9 | 2016-05-31 07:33:29 -0700 | [diff] [blame] | 88 | */ |
Brian Russell | c5299ff | 2021-02-09 10:16:58 +0000 | [diff] [blame] | 89 | typedef struct qos_pol_action_params_st_ |
Damjan Marion | 3891cd8 | 2016-10-27 10:27:00 +0200 | [diff] [blame] | 90 | { |
| 91 | u8 action_type; |
Brian Russell | e3845d7 | 2021-02-08 15:33:18 +0000 | [diff] [blame] | 92 | ip_dscp_t dscp; |
Brian Russell | c5299ff | 2021-02-09 10:16:58 +0000 | [diff] [blame] | 93 | } qos_pol_action_params_st; |
Matus Fabian | 4ac74c9 | 2016-05-31 07:33:29 -0700 | [diff] [blame] | 94 | |
Damjan Marion | 3891cd8 | 2016-10-27 10:27:00 +0200 | [diff] [blame] | 95 | /* |
Brian Russell | c5299ff | 2021-02-09 10:16:58 +0000 | [diff] [blame] | 96 | * edt: * struct qos_pol_cfg_params_st |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 97 | * |
Damjan Marion | 3891cd8 | 2016-10-27 10:27:00 +0200 | [diff] [blame] | 98 | * Description: |
| 99 | * This structure is used to hold user configured policing parameters. |
| 100 | * |
| 101 | * element: cir_kbps |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 102 | * CIR in kbps. |
Damjan Marion | 3891cd8 | 2016-10-27 10:27:00 +0200 | [diff] [blame] | 103 | * element: eir_kbps |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 104 | * EIR or PIR in kbps. |
Damjan Marion | 3891cd8 | 2016-10-27 10:27:00 +0200 | [diff] [blame] | 105 | * element: cb_bytes |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 106 | * Committed Burst in bytes. |
Damjan Marion | 3891cd8 | 2016-10-27 10:27:00 +0200 | [diff] [blame] | 107 | * element: eb_bytes |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 108 | * Excess or Peak Burst in bytes. |
Damjan Marion | 3891cd8 | 2016-10-27 10:27:00 +0200 | [diff] [blame] | 109 | * element: cir_pps |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 110 | * CIR in pps. |
Damjan Marion | 3891cd8 | 2016-10-27 10:27:00 +0200 | [diff] [blame] | 111 | * element: eir_pps |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 112 | * EIR or PIR in pps. |
Damjan Marion | 3891cd8 | 2016-10-27 10:27:00 +0200 | [diff] [blame] | 113 | * element: cb_ms |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 114 | * Committed Burst in milliseconds. |
Damjan Marion | 3891cd8 | 2016-10-27 10:27:00 +0200 | [diff] [blame] | 115 | * element: eb_ms |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 116 | * Excess or Peak Burst in milliseconds. |
Damjan Marion | 3891cd8 | 2016-10-27 10:27:00 +0200 | [diff] [blame] | 117 | * element: rate_type |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 118 | * Indicates the union if in kbps/bytes or pps/ms. |
Damjan Marion | 3891cd8 | 2016-10-27 10:27:00 +0200 | [diff] [blame] | 119 | * element: rfc |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 120 | * Policer algorithm - 1R2C, 1R3C (2697), 2R3C (2698) or 2R3C (4115). See |
Brian Russell | c5299ff | 2021-02-09 10:16:58 +0000 | [diff] [blame] | 121 | * qos_policer_type_en |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 122 | * element: rnd_type |
Brian Russell | c5299ff | 2021-02-09 10:16:58 +0000 | [diff] [blame] | 123 | * Rounding type (see qos_round_type_en). Needed when policer values |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 124 | * need to be rounded. Caller can decide on type of rounding used |
| 125 | */ |
Brian Russell | c5299ff | 2021-02-09 10:16:58 +0000 | [diff] [blame] | 126 | typedef struct qos_pol_cfg_params_st_ |
Damjan Marion | 3891cd8 | 2016-10-27 10:27:00 +0200 | [diff] [blame] | 127 | { |
| 128 | union |
| 129 | { |
| 130 | struct |
| 131 | { |
| 132 | u32 cir_kbps; |
| 133 | u32 eir_kbps; |
| 134 | u64 cb_bytes; |
| 135 | u64 eb_bytes; |
| 136 | } kbps; |
| 137 | struct |
| 138 | { |
| 139 | u32 cir_pps; |
| 140 | u32 eir_pps; |
| 141 | u64 cb_ms; |
| 142 | u64 eb_ms; |
| 143 | } pps; |
| 144 | } rb; /* rate burst config */ |
Brian Russell | c5299ff | 2021-02-09 10:16:58 +0000 | [diff] [blame] | 145 | u8 rate_type; /* qos_rate_type_en */ |
| 146 | u8 rnd_type; /* qos_round_type_en */ |
| 147 | u8 rfc; /* qos_policer_type_en */ |
Damjan Marion | 3891cd8 | 2016-10-27 10:27:00 +0200 | [diff] [blame] | 148 | u8 color_aware; |
| 149 | u8 overwrite_bucket; /* for debugging purposes */ |
| 150 | u32 current_bucket; /* for debugging purposes */ |
| 151 | u32 extended_bucket; /* for debugging purposes */ |
Brian Russell | c5299ff | 2021-02-09 10:16:58 +0000 | [diff] [blame] | 152 | qos_pol_action_params_st conform_action; |
| 153 | qos_pol_action_params_st exceed_action; |
| 154 | qos_pol_action_params_st violate_action; |
| 155 | } qos_pol_cfg_params_st; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 156 | |
Brian Russell | c5299ff | 2021-02-09 10:16:58 +0000 | [diff] [blame] | 157 | typedef struct qos_pol_hw_params_st_ |
Damjan Marion | 3891cd8 | 2016-10-27 10:27:00 +0200 | [diff] [blame] | 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; |
Brian Russell | c5299ff | 2021-02-09 10:16:58 +0000 | [diff] [blame] | 170 | } qos_pol_hw_params_st; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 171 | |
Brian Russell | c5299ff | 2021-02-09 10:16:58 +0000 | [diff] [blame] | 172 | int pol_logical_2_physical (qos_pol_cfg_params_st *cfg, |
| 173 | policer_read_response_type_st *phys); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 174 | |
| 175 | #endif /* __included_xlate_h__ */ |
Damjan Marion | 3891cd8 | 2016-10-27 10:27:00 +0200 | [diff] [blame] | 176 | |
| 177 | /* |
| 178 | * fd.io coding-style-patch-verification: ON |
| 179 | * |
| 180 | * Local Variables: |
| 181 | * eval: (c-set-style "gnu") |
| 182 | * End: |
| 183 | */ |