blob: 535006569f50731960845c5713f318d10e460d51 [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/*---------------------------------------------------------------------------
16 * from gdp_logical_qos.h
17 *---------------------------------------------------------------------------
18 */
19
20#ifndef __included_xlate_h__
21#define __included_xlate_h__
22
Brian Russelle3845d72021-02-08 15:33:18 +000023#include <vnet/ip/ip_packet.h>
Ed Warnickecb9cada2015-12-08 15:45:58 -070024#include <vnet/policer/police.h>
25
26/*
27 * edt: * enum sse2_qos_policer_type_en
28 * Defines type of policer to be allocated
29 */
Damjan Marion3891cd82016-10-27 10:27:00 +020030typedef enum sse2_qos_policer_type_en_
31{
32 SSE2_QOS_POLICER_TYPE_1R2C = 0,
33 SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697 = 1,
34 SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698 = 2,
35 SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115 = 3,
36 SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1 = 4,
37 SSE2_QOS_POLICER_TYPE_MAX
Ed Warnickecb9cada2015-12-08 15:45:58 -070038} sse2_qos_policer_type_en;
39
40/*
41 * edt: * enum
42 * Enum used to define type of rounding used when calculating policer values
43 */
Damjan Marion3891cd82016-10-27 10:27:00 +020044typedef enum
45{
46 SSE2_QOS_ROUND_TO_CLOSEST = 0,
47 SSE2_QOS_ROUND_TO_UP,
48 SSE2_QOS_ROUND_TO_DOWN,
49 SSE2_QOS_ROUND_INVALID
Ed Warnickecb9cada2015-12-08 15:45:58 -070050} sse2_qos_round_type_en;
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
59 * of units_in_bits field in sse2_static_policer_parameters_st, which is
60 * inline with sse_punt_drop.h.
61 */
Damjan Marion3891cd82016-10-27 10:27:00 +020062typedef enum
63{
64 SSE2_QOS_RATE_KBPS = 0,
65 SSE2_QOS_RATE_PPS,
66 SSE2_QOS_RATE_INVALID
Ed Warnickecb9cada2015-12-08 15:45:58 -070067} sse2_qos_rate_type_en;
68
Matus Fabian4ac74c92016-05-31 07:33:29 -070069/*
70 * edt: * enum
71 * Defines type of policer actions.
72 */
Damjan Marion3891cd82016-10-27 10:27:00 +020073typedef enum
74{
75 SSE2_QOS_ACTION_DROP = 0,
76 SSE2_QOS_ACTION_TRANSMIT,
77 SSE2_QOS_ACTION_MARK_AND_TRANSMIT
Matus Fabian4ac74c92016-05-31 07:33:29 -070078} sse2_qos_action_type_en;
79
80/*
81 * edt * struct sse2_qos_pol_action_params_st
82 * This structure is used to hold user configured police action parameters.
83 *
84 * element: action_type
85 * Action type (see sse2_qos_action_type_en).
Paul Vinciguerrabdc0e6b2018-09-22 05:32:50 -070086 * element: dscp
Matus Fabian4ac74c92016-05-31 07:33:29 -070087 * DSCP value to set when action is SSE2_QOS_ACTION_MARK_AND_TRANSMIT.
88 */
Damjan Marion3891cd82016-10-27 10:27:00 +020089typedef struct sse2_qos_pol_action_params_st_
90{
91 u8 action_type;
Brian Russelle3845d72021-02-08 15:33:18 +000092 ip_dscp_t dscp;
Matus Fabian4ac74c92016-05-31 07:33:29 -070093} sse2_qos_pol_action_params_st;
94
Damjan Marion3891cd82016-10-27 10:27:00 +020095/*
Ed Warnickecb9cada2015-12-08 15:45:58 -070096 * edt: * struct sse2_qos_pol_cfg_params_st
97 *
Damjan Marion3891cd82016-10-27 10:27:00 +020098 * Description:
99 * This structure is used to hold user configured policing parameters.
100 *
101 * element: cir_kbps
Ed Warnickecb9cada2015-12-08 15:45:58 -0700102 * CIR in kbps.
Damjan Marion3891cd82016-10-27 10:27:00 +0200103 * element: eir_kbps
Ed Warnickecb9cada2015-12-08 15:45:58 -0700104 * EIR or PIR in kbps.
Damjan Marion3891cd82016-10-27 10:27:00 +0200105 * element: cb_bytes
Ed Warnickecb9cada2015-12-08 15:45:58 -0700106 * Committed Burst in bytes.
Damjan Marion3891cd82016-10-27 10:27:00 +0200107 * element: eb_bytes
Ed Warnickecb9cada2015-12-08 15:45:58 -0700108 * Excess or Peak Burst in bytes.
Damjan Marion3891cd82016-10-27 10:27:00 +0200109 * element: cir_pps
Ed Warnickecb9cada2015-12-08 15:45:58 -0700110 * CIR in pps.
Damjan Marion3891cd82016-10-27 10:27:00 +0200111 * element: eir_pps
Ed Warnickecb9cada2015-12-08 15:45:58 -0700112 * EIR or PIR in pps.
Damjan Marion3891cd82016-10-27 10:27:00 +0200113 * element: cb_ms
Ed Warnickecb9cada2015-12-08 15:45:58 -0700114 * Committed Burst in milliseconds.
Damjan Marion3891cd82016-10-27 10:27:00 +0200115 * element: eb_ms
Ed Warnickecb9cada2015-12-08 15:45:58 -0700116 * Excess or Peak Burst in milliseconds.
Damjan Marion3891cd82016-10-27 10:27:00 +0200117 * element: rate_type
Ed Warnickecb9cada2015-12-08 15:45:58 -0700118 * Indicates the union if in kbps/bytes or pps/ms.
Damjan Marion3891cd82016-10-27 10:27:00 +0200119 * element: rfc
Ed Warnickecb9cada2015-12-08 15:45:58 -0700120 * Policer algorithm - 1R2C, 1R3C (2697), 2R3C (2698) or 2R3C (4115). See
121 * sse_qos_policer_type_en
122 * element: rnd_type
123 * Rounding type (see sse_qos_round_type_en). Needed when policer values
124 * need to be rounded. Caller can decide on type of rounding used
125 */
Damjan Marion3891cd82016-10-27 10:27:00 +0200126typedef struct sse2_qos_pol_cfg_params_st_
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 */
145 u8 rate_type; /* sse2_qos_rate_type_en */
146 u8 rnd_type; /* sse2_qos_round_type_en */
147 u8 rfc; /* sse2_qos_policer_type_en */
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 */
152 sse2_qos_pol_action_params_st conform_action;
153 sse2_qos_pol_action_params_st exceed_action;
154 sse2_qos_pol_action_params_st violate_action;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700155} sse2_qos_pol_cfg_params_st;
156
157
Damjan Marion3891cd82016-10-27 10:27:00 +0200158typedef struct sse2_qos_pol_hw_params_st_
159{
160 u8 rfc;
161 u8 allow_negative;
162 u8 rate_exp;
163 u16 avg_rate_man;
164 u16 peak_rate_man;
165 u8 comm_bkt_limit_exp;
166 u8 comm_bkt_limit_man;
167 u8 extd_bkt_limit_exp;
168 u8 extd_bkt_limit_man;
169 u32 comm_bkt;
170 u32 extd_bkt;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700171} sse2_qos_pol_hw_params_st;
172
173
Damjan Marion3891cd82016-10-27 10:27:00 +0200174int
175sse2_pol_logical_2_physical (sse2_qos_pol_cfg_params_st * cfg,
176 policer_read_response_type_st * phys);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700177
178
179#endif /* __included_xlate_h__ */
Damjan Marion3891cd82016-10-27 10:27:00 +0200180
181/*
182 * fd.io coding-style-patch-verification: ON
183 *
184 * Local Variables:
185 * eval: (c-set-style "gnu")
186 * End:
187 */