blob: 7f6ebe7b65d72854952847c77f893e1be7f557bb [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/*
Brian Russellc5299ff2021-02-09 10:16:58 +000027 * edt: * enum qos_policer_type_en
Ed Warnickecb9cada2015-12-08 15:45:58 -070028 * Defines type of policer to be allocated
29 */
Brian Russellc5299ff2021-02-09 10:16:58 +000030typedef enum qos_policer_type_en_
Damjan Marion3891cd82016-10-27 10:27:00 +020031{
Brian Russellc5299ff2021-02-09 10:16:58 +000032 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
Brian Russellb2aae752021-02-09 11:36:31 +000038} __clib_packed qos_policer_type_en;
Ed Warnickecb9cada2015-12-08 15:45:58 -070039
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{
Brian Russellc5299ff2021-02-09 10:16:58 +000046 QOS_ROUND_TO_CLOSEST = 0,
47 QOS_ROUND_TO_UP,
48 QOS_ROUND_TO_DOWN,
49 QOS_ROUND_INVALID
Brian Russellb2aae752021-02-09 11:36:31 +000050} __clib_packed qos_round_type_en;
Ed Warnickecb9cada2015-12-08 15:45:58 -070051
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 Russellc5299ff2021-02-09 10:16:58 +000059 * of units_in_bits field in static_policer_parameters_st, which is
Ed Warnickecb9cada2015-12-08 15:45:58 -070060 * inline with sse_punt_drop.h.
61 */
Damjan Marion3891cd82016-10-27 10:27:00 +020062typedef enum
63{
Brian Russellc5299ff2021-02-09 10:16:58 +000064 QOS_RATE_KBPS = 0,
65 QOS_RATE_PPS,
66 QOS_RATE_INVALID
Brian Russellb2aae752021-02-09 11:36:31 +000067} __clib_packed qos_rate_type_en;
Matus Fabian4ac74c92016-05-31 07:33:29 -070068
69/*
Brian Russellc5299ff2021-02-09 10:16:58 +000070 * edt * struct qos_pol_action_params_st
Matus Fabian4ac74c92016-05-31 07:33:29 -070071 * This structure is used to hold user configured police action parameters.
72 *
73 * element: action_type
Brian Russellc5299ff2021-02-09 10:16:58 +000074 * Action type (see qos_action_type_en).
Paul Vinciguerrabdc0e6b2018-09-22 05:32:50 -070075 * element: dscp
Brian Russellc5299ff2021-02-09 10:16:58 +000076 * DSCP value to set when action is QOS_ACTION_MARK_AND_TRANSMIT.
Matus Fabian4ac74c92016-05-31 07:33:29 -070077 */
Brian Russellc5299ff2021-02-09 10:16:58 +000078typedef struct qos_pol_action_params_st_
Damjan Marion3891cd82016-10-27 10:27:00 +020079{
Brian Russellb2aae752021-02-09 11:36:31 +000080 qos_action_type_en action_type;
Brian Russelle3845d72021-02-08 15:33:18 +000081 ip_dscp_t dscp;
Brian Russellc5299ff2021-02-09 10:16:58 +000082} qos_pol_action_params_st;
Matus Fabian4ac74c92016-05-31 07:33:29 -070083
Damjan Marion3891cd82016-10-27 10:27:00 +020084/*
Brian Russellc5299ff2021-02-09 10:16:58 +000085 * edt: * struct qos_pol_cfg_params_st
Ed Warnickecb9cada2015-12-08 15:45:58 -070086 *
Damjan Marion3891cd82016-10-27 10:27:00 +020087 * Description:
88 * This structure is used to hold user configured policing parameters.
89 *
90 * element: cir_kbps
Ed Warnickecb9cada2015-12-08 15:45:58 -070091 * CIR in kbps.
Damjan Marion3891cd82016-10-27 10:27:00 +020092 * element: eir_kbps
Ed Warnickecb9cada2015-12-08 15:45:58 -070093 * EIR or PIR in kbps.
Damjan Marion3891cd82016-10-27 10:27:00 +020094 * element: cb_bytes
Ed Warnickecb9cada2015-12-08 15:45:58 -070095 * Committed Burst in bytes.
Damjan Marion3891cd82016-10-27 10:27:00 +020096 * element: eb_bytes
Ed Warnickecb9cada2015-12-08 15:45:58 -070097 * Excess or Peak Burst in bytes.
Damjan Marion3891cd82016-10-27 10:27:00 +020098 * element: cir_pps
Ed Warnickecb9cada2015-12-08 15:45:58 -070099 * CIR in pps.
Damjan Marion3891cd82016-10-27 10:27:00 +0200100 * element: eir_pps
Ed Warnickecb9cada2015-12-08 15:45:58 -0700101 * EIR or PIR in pps.
Damjan Marion3891cd82016-10-27 10:27:00 +0200102 * element: cb_ms
Ed Warnickecb9cada2015-12-08 15:45:58 -0700103 * Committed Burst in milliseconds.
Damjan Marion3891cd82016-10-27 10:27:00 +0200104 * element: eb_ms
Ed Warnickecb9cada2015-12-08 15:45:58 -0700105 * Excess or Peak Burst in milliseconds.
Damjan Marion3891cd82016-10-27 10:27:00 +0200106 * element: rate_type
Ed Warnickecb9cada2015-12-08 15:45:58 -0700107 * Indicates the union if in kbps/bytes or pps/ms.
Damjan Marion3891cd82016-10-27 10:27:00 +0200108 * element: rfc
Ed Warnickecb9cada2015-12-08 15:45:58 -0700109 * Policer algorithm - 1R2C, 1R3C (2697), 2R3C (2698) or 2R3C (4115). See
Brian Russellc5299ff2021-02-09 10:16:58 +0000110 * qos_policer_type_en
Ed Warnickecb9cada2015-12-08 15:45:58 -0700111 * element: rnd_type
Brian Russellc5299ff2021-02-09 10:16:58 +0000112 * Rounding type (see qos_round_type_en). Needed when policer values
Ed Warnickecb9cada2015-12-08 15:45:58 -0700113 * need to be rounded. Caller can decide on type of rounding used
114 */
Brian Russellc5299ff2021-02-09 10:16:58 +0000115typedef struct qos_pol_cfg_params_st_
Damjan Marion3891cd82016-10-27 10:27:00 +0200116{
117 union
118 {
119 struct
120 {
121 u32 cir_kbps;
122 u32 eir_kbps;
123 u64 cb_bytes;
124 u64 eb_bytes;
125 } kbps;
126 struct
127 {
128 u32 cir_pps;
129 u32 eir_pps;
130 u64 cb_ms;
131 u64 eb_ms;
132 } pps;
133 } rb; /* rate burst config */
Brian Russellb2aae752021-02-09 11:36:31 +0000134 qos_rate_type_en rate_type;
135 qos_round_type_en rnd_type;
136 qos_policer_type_en rfc;
Damjan Marion3891cd82016-10-27 10:27:00 +0200137 u8 color_aware;
138 u8 overwrite_bucket; /* for debugging purposes */
139 u32 current_bucket; /* for debugging purposes */
140 u32 extended_bucket; /* for debugging purposes */
Brian Russellc5299ff2021-02-09 10:16:58 +0000141 qos_pol_action_params_st conform_action;
142 qos_pol_action_params_st exceed_action;
143 qos_pol_action_params_st violate_action;
144} qos_pol_cfg_params_st;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700145
Brian Russellc5299ff2021-02-09 10:16:58 +0000146typedef struct qos_pol_hw_params_st_
Damjan Marion3891cd82016-10-27 10:27:00 +0200147{
148 u8 rfc;
149 u8 allow_negative;
150 u8 rate_exp;
151 u16 avg_rate_man;
152 u16 peak_rate_man;
153 u8 comm_bkt_limit_exp;
154 u8 comm_bkt_limit_man;
155 u8 extd_bkt_limit_exp;
156 u8 extd_bkt_limit_man;
157 u32 comm_bkt;
158 u32 extd_bkt;
Brian Russellc5299ff2021-02-09 10:16:58 +0000159} qos_pol_hw_params_st;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700160
Maxime Peim2d1a62b2023-01-06 11:57:38 +0000161int pol_logical_2_physical (const qos_pol_cfg_params_st *cfg, policer_t *phys);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700162
163#endif /* __included_xlate_h__ */
Damjan Marion3891cd82016-10-27 10:27:00 +0200164
165/*
166 * fd.io coding-style-patch-verification: ON
167 *
168 * Local Variables:
169 * eval: (c-set-style "gnu")
170 * End:
171 */