1/*
2 * Copyright (c) 2014, The Linux Foundation. All rights reserved.
3 * Permission to use, copy, modify, and/or distribute this software for
4 * any purpose with or without fee is hereby granted, provided that the
5 * above copyright notice and this permission notice appear in all copies.
6 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
7 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
8 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
9 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
10 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
11 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
12 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
13 */
14
15
16/**
17 * @defgroup fal_rate FAL_RATE
18 * @{
19 */
20#ifndef _FAL_RATE_H_
21#define _FAL_RATE_H_
22
23#ifdef __cplusplus
24extern "C" {
25#endif                          /* __cplusplus */
26
27#include "common/sw.h"
28#include "fal/fal_type.h"
29
30    /**
31    @brief This enum defines storm type
32    */
33    typedef enum {
34        FAL_UNICAST_STORM = 0,      /**<  storm caused by unknown unicast packets */
35        FAL_MULTICAST_STORM,        /**<  storm caused by unknown multicast packets */
36        FAL_BROADCAST_STORM,        /**<  storm caused by broadcast packets */
37        FAL_STORM_TYPE_BUTT
38    }
39    fal_storm_type_t;
40
41
42
43    sw_error_t
44    fal_rate_queue_egrl_set(a_uint32_t dev_id, fal_port_t port_id,
45                            fal_queue_t queue_id, a_uint32_t * speed,
46                            a_bool_t enable);
47
48
49
50    sw_error_t
51    fal_rate_queue_egrl_get(a_uint32_t dev_id, fal_port_t port_id,
52                            fal_queue_t queue_id, a_uint32_t * speed,
53                            a_bool_t * enable);
54
55
56
57    sw_error_t
58    fal_rate_port_egrl_set(a_uint32_t dev_id, fal_port_t port_id,
59                           a_uint32_t * speed, a_bool_t enable);
60
61
62
63    sw_error_t
64    fal_rate_port_egrl_get(a_uint32_t dev_id, fal_port_t port_id,
65                           a_uint32_t * speed, a_bool_t * enable);
66
67
68
69    sw_error_t
70    fal_rate_port_inrl_set(a_uint32_t dev_id, fal_port_t port_id,
71                           a_uint32_t * speed, a_bool_t enable);
72
73
74
75    sw_error_t
76    fal_rate_port_inrl_get(a_uint32_t dev_id, fal_port_t port_id,
77                           a_uint32_t * speed, a_bool_t * enable);
78
79
80
81    sw_error_t
82    fal_storm_ctrl_frame_set(a_uint32_t dev_id, fal_port_t port_id,
83                             fal_storm_type_t frame_type, a_bool_t enable);
84
85
86
87    sw_error_t
88    fal_storm_ctrl_frame_get(a_uint32_t dev_id, fal_port_t port_id,
89                             fal_storm_type_t frame_type,
90                             a_bool_t * enable);
91
92
93
94    sw_error_t
95    fal_storm_ctrl_rate_set(a_uint32_t dev_id, fal_port_t port_id,
96                            a_uint32_t * rate);
97
98
99
100    sw_error_t
101    fal_storm_ctrl_rate_get(a_uint32_t dev_id, fal_port_t port_id,
102                            a_uint32_t * rate);
103
104
105    typedef enum
106    {
107        FAL_RATE_MI_100US = 0,
108        FAL_RATE_MI_1MS,
109        FAL_RATE_MI_10MS,
110        FAL_RATE_MI_100MS,
111    } fal_rate_mt_t;
112
113
114    typedef struct
115    {
116        fal_traffic_unit_t meter_unit;
117        a_uint32_t         cir;
118        a_uint32_t         eir;
119        a_uint32_t         cbs;
120        a_uint32_t         ebs;
121    } fal_egress_shaper_t;
122
123
124#define FAL_INGRESS_POLICING_TCP_CTRL     0x2
125#define FAL_INGRESS_POLICING_MANAGEMENT   0x4
126#define FAL_INGRESS_POLICING_BROAD        0x8
127#define FAL_INGRESS_POLICING_UNK_UNI      0x10
128#define FAL_INGRESS_POLICING_UNK_MUL      0x20
129#define FAL_INGRESS_POLICING_UNI          0x40
130#define FAL_INGRESS_POLICING_MUL          0x80
131
132
133    typedef struct
134    {
135        a_bool_t           c_enable;
136        a_bool_t           e_enable;
137        a_bool_t           combine_mode;
138        fal_traffic_unit_t meter_unit;
139        a_bool_t           color_mode;
140        a_bool_t           couple_flag;
141        a_bool_t           deficit_en;
142        a_uint32_t         cir;
143        a_uint32_t         eir;
144        a_uint32_t         cbs;
145        a_uint32_t         ebs;
146        a_uint32_t         c_rate_flag;
147        a_uint32_t         e_rate_flag;
148        fal_rate_mt_t      c_meter_interval;
149        fal_rate_mt_t      e_meter_interval;
150    } fal_port_policer_t;
151
152
153    typedef struct
154    {
155        a_bool_t           counter_mode;
156        fal_traffic_unit_t meter_unit;
157        fal_rate_mt_t      meter_interval;
158        a_bool_t           color_mode;
159        a_bool_t           couple_flag;
160        a_bool_t           deficit_en;
161        a_uint32_t         cir;
162        a_uint32_t         eir;
163        a_uint32_t         cbs;
164        a_uint32_t         ebs;
165        a_uint32_t         counter_high;
166        a_uint32_t         counter_low;
167    } fal_acl_policer_t;
168
169
170    sw_error_t
171    fal_rate_port_policer_set(a_uint32_t dev_id, fal_port_t port_id,
172                              fal_port_policer_t * policer);
173
174
175    sw_error_t
176    fal_rate_port_policer_get(a_uint32_t dev_id, fal_port_t port_id,
177                              fal_port_policer_t * policer);
178
179
180    sw_error_t
181    fal_rate_port_shaper_set(a_uint32_t dev_id, fal_port_t port_id,
182                             a_bool_t enable, fal_egress_shaper_t * shaper);
183
184
185    sw_error_t
186    fal_rate_port_shaper_get(a_uint32_t dev_id, fal_port_t port_id,
187                             a_bool_t * enable, fal_egress_shaper_t * shaper);
188
189
190    sw_error_t
191    fal_rate_queue_shaper_set(a_uint32_t dev_id, fal_port_t port_id,
192                              fal_queue_t queue_id, a_bool_t enable,
193                              fal_egress_shaper_t * shaper);
194
195
196    sw_error_t
197    fal_rate_queue_shaper_get(a_uint32_t dev_id, fal_port_t port_id,
198                              fal_queue_t queue_id, a_bool_t * enable,
199                              fal_egress_shaper_t * shaper);
200
201
202    sw_error_t
203    fal_rate_acl_policer_set(a_uint32_t dev_id, a_uint32_t policer_id,
204                             fal_acl_policer_t * policer);
205
206
207    sw_error_t
208    fal_rate_acl_policer_get(a_uint32_t dev_id, a_uint32_t policer_id,
209                             fal_acl_policer_t * policer);
210
211    sw_error_t
212    fal_rate_port_add_rate_byte_set(a_uint32_t dev_id, fal_port_t port_id,
213                                    a_uint32_t  number);
214
215    sw_error_t
216    fal_rate_port_add_rate_byte_get(a_uint32_t dev_id, fal_port_t port_id,
217                                    a_uint32_t  *number);
218
219    sw_error_t
220    fal_rate_port_gol_flow_en_set(a_uint32_t dev_id, fal_port_t port_id,
221                                  a_bool_t  enable);
222    sw_error_t
223    fal_rate_port_gol_flow_en_get(a_uint32_t dev_id, fal_port_t port_id,
224                                  a_bool_t*  enable);
225
226
227
228#ifdef __cplusplus
229}
230#endif                          /* __cplusplus */
231#endif                          /* _FAL_RATE_H_ */
232/**
233 * @}
234 */
235