Trivial: Clean up some typos.
[vpp.git] / src / vnet / policer / xlate.h
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
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  */
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
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  */
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
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  */
61 typedef enum
62 {
63   SSE2_QOS_RATE_KBPS = 0,
64   SSE2_QOS_RATE_PPS,
65   SSE2_QOS_RATE_INVALID
66 } sse2_qos_rate_type_en;
67
68 /*
69  * edt: * enum
70  * Defines type of policer actions.
71  */
72 typedef enum
73 {
74   SSE2_QOS_ACTION_DROP = 0,
75   SSE2_QOS_ACTION_TRANSMIT,
76   SSE2_QOS_ACTION_MARK_AND_TRANSMIT
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  * element: dscp
86  *      DSCP value to set when action is SSE2_QOS_ACTION_MARK_AND_TRANSMIT.
87  */
88 typedef struct sse2_qos_pol_action_params_st_
89 {
90   u8 action_type;
91   u8 dscp;
92 } sse2_qos_pol_action_params_st;
93
94 /*
95  * edt: * struct sse2_qos_pol_cfg_params_st
96  *
97  * Description:
98  * This structure is used to hold user configured policing parameters.
99  *
100  * element: cir_kbps
101  *      CIR in kbps.
102  * element: eir_kbps
103  *      EIR or PIR in kbps.
104  * element: cb_bytes
105  *      Committed Burst in bytes.
106  * element: eb_bytes
107  *      Excess or Peak Burst in bytes.
108  * element: cir_pps
109  *      CIR in pps.
110  * element: eir_pps
111  *      EIR or PIR in pps.
112  * element: cb_ms
113  *      Committed Burst in milliseconds.
114  * element: eb_ms
115  *      Excess or Peak Burst in milliseconds.
116  * element: rate_type
117  *      Indicates the union if in kbps/bytes or pps/ms.
118  * element: rfc
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  */
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;
154 } sse2_qos_pol_cfg_params_st;
155
156
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;
170 } sse2_qos_pol_hw_params_st;
171
172
173 int
174 sse2_pol_logical_2_physical (sse2_qos_pol_cfg_params_st * cfg,
175                              policer_read_response_type_st * phys);
176
177
178 #endif /* __included_xlate_h__ */
179
180 /*
181  * fd.io coding-style-patch-verification: ON
182  *
183  * Local Variables:
184  * eval: (c-set-style "gnu")
185  * End:
186  */