LISP - fix bug in ip_prefix_normalize_ip6
[vpp.git] / vnet / 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/fix_types.h>
24 #include <vnet/policer/police.h>
25
26 /*
27  * edt: * enum sse2_qos_policer_type_en
28  *  Defines type of policer to be allocated
29  */
30 typedef enum sse2_qos_policer_type_en_ {
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     SSE2_QOS_ROUND_TO_CLOSEST = 0,
45     SSE2_QOS_ROUND_TO_UP,
46     SSE2_QOS_ROUND_TO_DOWN,
47     SSE2_QOS_ROUND_INVALID
48 } sse2_qos_round_type_en;
49
50 /*
51  * edt: * enum
52  *  Enum used to define type of rate for configuration, either pps or kbps.
53  *  If kbps, then burst is in bytes, if pps, then burst is in ms.
54  *
55  *  Default of zero is kbps, which is inline with how it is programmed
56  *  in actual hardware.  However, the warning is that this is reverse logic
57  *  of units_in_bits field in sse2_static_policer_parameters_st, which is
58  *  inline with sse_punt_drop.h.
59  */
60 typedef enum {
61     SSE2_QOS_RATE_KBPS = 0,
62     SSE2_QOS_RATE_PPS,
63     SSE2_QOS_RATE_INVALID
64 } sse2_qos_rate_type_en;
65
66 /*
67  * edt: * enum
68  * Defines type of policer actions.
69  */
70 typedef enum {
71     SSE2_QOS_ACTION_DROP = 0,
72     SSE2_QOS_ACTION_TRANSMIT,
73     SSE2_QOS_ACTION_MARK_AND_TRANSMIT
74 } sse2_qos_action_type_en;
75
76 /*
77  * edt * struct sse2_qos_pol_action_params_st
78  * This structure is used to hold user configured police action parameters.
79  *
80  * element: action_type
81  *      Action type (see sse2_qos_action_type_en).
82  * elemtnt: dscp
83  *      DSCP value to set when action is SSE2_QOS_ACTION_MARK_AND_TRANSMIT.
84  */
85 typedef struct sse2_qos_pol_action_params_st_ {
86     uint8_t  action_type;
87     uint8_t  dscp;
88 } sse2_qos_pol_action_params_st;
89
90 /* 
91  * edt: * struct sse2_qos_pol_cfg_params_st
92  *
93  * Description: 
94  * This structure is used to hold user configured policing parameters. 
95  * 
96  * element: cir_kbps 
97  *      CIR in kbps.
98  * element: eir_kbps 
99  *      EIR or PIR in kbps.
100  * element: cb_bytes 
101  *      Committed Burst in bytes.
102  * element: eb_bytes 
103  *      Excess or Peak Burst in bytes.
104  * element: cir_pps 
105  *      CIR in pps.
106  * element: eir_pps 
107  *      EIR or PIR in pps.
108  * element: cb_ms 
109  *      Committed Burst in milliseconds.
110  * element: eb_ms 
111  *      Excess or Peak Burst in milliseconds.
112  * element: rate_type 
113  *      Indicates the union if in kbps/bytes or pps/ms.
114  * element: rfc 
115  *      Policer algorithm - 1R2C, 1R3C (2697), 2R3C (2698) or 2R3C (4115). See
116  *      sse_qos_policer_type_en
117  * element: rnd_type
118  *      Rounding type (see sse_qos_round_type_en). Needed when policer values
119  *      need to be rounded. Caller can decide on type of rounding used
120  */
121 typedef struct sse2_qos_pol_cfg_params_st_ {
122     union {
123         struct {
124             uint32_t cir_kbps;
125             uint32_t eir_kbps;
126             uint64_t cb_bytes;
127             uint64_t eb_bytes;
128         } PACKED kbps;
129         struct {
130             uint32_t cir_pps;
131             uint32_t eir_pps;
132             uint64_t cb_ms;
133             uint64_t eb_ms;
134         } PACKED pps;
135     } PACKED rb;               /* rate burst config */
136     uint8_t  rate_type;        /* sse2_qos_rate_type_en */
137     uint8_t  rnd_type;         /* sse2_qos_round_type_en */
138     uint8_t  rfc;              /* sse2_qos_policer_type_en */
139     uint8_t  color_aware;
140     uint8_t  overwrite_bucket; /* for debugging purposes */
141     uint32_t current_bucket;   /* for debugging purposes */
142     uint32_t extended_bucket;  /* for debugging purposes */
143     sse2_qos_pol_action_params_st conform_action;
144     sse2_qos_pol_action_params_st exceed_action;
145     sse2_qos_pol_action_params_st violate_action;
146 } sse2_qos_pol_cfg_params_st;
147
148
149 typedef struct sse2_qos_pol_hw_params_st_ {
150     uint8_t  rfc;
151     uint8_t  allow_negative;
152     uint8_t  rate_exp;
153     uint16_t avg_rate_man;
154     uint16_t peak_rate_man;
155     uint8_t  comm_bkt_limit_exp;
156     uint8_t  comm_bkt_limit_man;
157     uint8_t  extd_bkt_limit_exp;
158     uint8_t  extd_bkt_limit_man;
159     uint32_t comm_bkt;
160     uint32_t extd_bkt;
161 } sse2_qos_pol_hw_params_st;
162
163
164 trans_layer_rc
165 sse2_pol_logical_2_physical (sse2_qos_pol_cfg_params_st    *cfg,
166                              policer_read_response_type_st *phys);
167
168
169 #endif /* __included_xlate_h__ */