-
Notifications
You must be signed in to change notification settings - Fork 492
/
Copy pathsaipolicer.h
408 lines (352 loc) · 11.1 KB
/
saipolicer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
/**
* Copyright (c) 2014 Microsoft Open Technologies, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT
* LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS
* FOR A PARTICULAR PURPOSE, MERCHANTABILITY OR NON-INFRINGEMENT.
*
* See the Apache Version 2.0 License for specific language governing
* permissions and limitations under the License.
*
* Microsoft would like to thank the following companies for their review and
* assistance with these files: Intel Corporation, Mellanox Technologies Ltd,
* Dell Products, L.P., Facebook, Inc., Marvell International Ltd.
*
* @file saipolicer.h
*
* @brief This module defines SAI QOS Policer interface
*/
#if !defined (__SAIPOLICER_H_)
#define __SAIPOLICER_H_
#include <saitypes.h>
/**
* @defgroup SAIPOLICER SAI - QOS Policer specific API definitions
*
* @{
*/
/**
* @brief Enum defining types of meters
*/
typedef enum _sai_meter_type_t
{
/** Metering is done based on packets */
SAI_METER_TYPE_PACKETS = 0x00000000,
/** Metering is done based on bytes */
SAI_METER_TYPE_BYTES = 0x00000001,
/** Custom range base value */
SAI_METER_TYPE_CUSTOM_RANGE_BASE = 0x10000000
} sai_meter_type_t;
/**
* @brief Enum defining mode of the policer object
*/
typedef enum _sai_policer_mode_t
{
/** RFC 2697, Single Rate Three color marker, CIR, CBS and PBS, G, Y and R */
SAI_POLICER_MODE_SR_TCM = 0x00000000,
/** RFC 2698, Two Rate Three color marker, CIR, CBS, PIR and PBS, G, Y and R */
SAI_POLICER_MODE_TR_TCM = 0x00000001,
/** Storm control mode. Single Rate Two color CIR, CBS, G and R */
SAI_POLICER_MODE_STORM_CONTROL = 0x00000002,
/** Custom range base value */
SAI_POLICER_MODE_CUSTOM_RANGE_BASE = 0x10000000
} sai_policer_mode_t;
/**
* @brief Enum defining Policer color source
*/
typedef enum _sai_policer_color_source_t
{
/** Previous coloring schemes are ignored */
SAI_POLICER_COLOR_SOURCE_BLIND = 0x00000000,
/** Previous coloring schemes are used */
SAI_POLICER_COLOR_SOURCE_AWARE = 0x00000001,
/** Custom range base value */
SAI_POLICER_COLOR_SOURCE_CUSTOM_RANGE_BASE = 0x10000000
} sai_policer_color_source_t;
/**
* @brief Enum defining Policer Attributes
*/
typedef enum _sai_policer_attr_t
{
/**
* @brief Start of attributes
*/
SAI_POLICER_ATTR_START = 0x00000000,
/**
* @brief Policer Meter Type
*
* @type sai_meter_type_t
* @flags MANDATORY_ON_CREATE | CREATE_ONLY
*/
SAI_POLICER_ATTR_METER_TYPE = SAI_POLICER_ATTR_START,
/**
* @brief Policer mode
*
* @type sai_policer_mode_t
* @flags MANDATORY_ON_CREATE | CREATE_ONLY
*/
SAI_POLICER_ATTR_MODE = 0x00000001,
/**
* @brief Policer Color Source
*
* @type sai_policer_color_source_t
* @flags CREATE_ONLY
* @default SAI_POLICER_COLOR_SOURCE_AWARE
*/
SAI_POLICER_ATTR_COLOR_SOURCE = 0x00000002,
/**
* @brief Committed burst size bytes/packets based on
* #SAI_POLICER_ATTR_METER_TYPE
*
* @type sai_uint64_t
* @flags CREATE_AND_SET
* @default 0
*/
SAI_POLICER_ATTR_CBS = 0x00000003,
/**
* @brief Committed information rate BPS/PPS based on
* #SAI_POLICER_ATTR_METER_TYPE
*
* @type sai_uint64_t
* @flags CREATE_AND_SET
* @default 0
*/
SAI_POLICER_ATTR_CIR = 0x00000004,
/**
* @brief Peak burst size bytes/packets based on
* #SAI_POLICER_ATTR_METER_TYPE
*
* @type sai_uint64_t
* @flags CREATE_AND_SET
* @default 0
*/
SAI_POLICER_ATTR_PBS = 0x00000005,
/**
* @brief Peak information rate BPS/PPS based on
* #SAI_POLICER_ATTR_METER_TYPE
*
* @type sai_uint64_t
* @flags CREATE_AND_SET
* @default 0
* @validonly SAI_POLICER_ATTR_MODE == SAI_POLICER_MODE_TR_TCM
*/
SAI_POLICER_ATTR_PIR = 0x00000006,
/**
* @brief Action to take for Green color packets
*
* @type sai_packet_action_t
* @flags CREATE_AND_SET
* @default SAI_PACKET_ACTION_FORWARD
*/
SAI_POLICER_ATTR_GREEN_PACKET_ACTION = 0x00000007,
/**
* @brief Action to take for Yellow color packets
*
* @type sai_packet_action_t
* @flags CREATE_AND_SET
* @default SAI_PACKET_ACTION_FORWARD
*/
SAI_POLICER_ATTR_YELLOW_PACKET_ACTION = 0x00000008,
/**
* @brief Action to take for RED color packets
*
* For storm control action should be used as red packet action.
*
* @type sai_packet_action_t
* @flags CREATE_AND_SET
* @default SAI_PACKET_ACTION_FORWARD
*/
SAI_POLICER_ATTR_RED_PACKET_ACTION = 0x00000009,
/**
* @brief Enable/disable counter
*
* Default disabled. Modify list needs full new set.
*
* @type sai_s32_list_t sai_packet_action_t
* @flags CREATE_AND_SET
* @default empty
*/
SAI_POLICER_ATTR_ENABLE_COUNTER_PACKET_ACTION_LIST = 0x0000000a,
/**
* @brief Policer pool stage
*
* @type sai_object_stage_t
* @flags CREATE_ONLY
* @default SAI_OBJECT_STAGE_BOTH
*/
SAI_POLICER_ATTR_OBJECT_STAGE = 0x0000000b,
/**
* @brief Set policer statistics counting mode
*
* @type sai_stats_count_mode_t
* @flags CREATE_AND_SET
* @default SAI_STATS_COUNT_MODE_PACKET_AND_BYTE
*/
SAI_POLICER_ATTR_STATS_COUNT_MODE,
/**
* @brief Attach counter object list
*
* Counter object should be of type Selective.
* Fill (#SAI_COUNTER_ATTR_TYPE with #SAI_COUNTER_TYPE_SELECTIVE).
*
* @type sai_object_list_t
* @flags CREATE_AND_SET
* @objects SAI_OBJECT_TYPE_COUNTER
* @default empty
*/
SAI_POLICER_ATTR_SELECTIVE_COUNTER_LIST,
/**
* @brief Label attribute used to uniquely identify identical policers.
*
* @type char
* @flags CREATE_AND_SET
* @default ""
*/
SAI_POLICER_ATTR_LABEL,
/**
* @brief End of attributes
*/
SAI_POLICER_ATTR_END,
/** Custom range base value */
SAI_POLICER_ATTR_CUSTOM_RANGE_START = 0x10000000,
/** End of custom range base */
SAI_POLICER_ATTR_CUSTOM_RANGE_END
} sai_policer_attr_t;
/**
* @brief Enum defining policer statistics
*/
typedef enum _sai_policer_stat_t
{
/** Get/set packet count [uint64_t] */
SAI_POLICER_STAT_PACKETS = 0x00000000,
/** Get/set byte count [uint64_t] */
SAI_POLICER_STAT_ATTR_BYTES = 0x00000001,
/** Get/set green packet count [uint64_t] */
SAI_POLICER_STAT_GREEN_PACKETS = 0x00000002,
/** Get/set green byte count [uint64_t] */
SAI_POLICER_STAT_GREEN_BYTES = 0x00000003,
/** Get/set yellow packet count [uint64_t] */
SAI_POLICER_STAT_YELLOW_PACKETS = 0x00000004,
/** Get/set yellow byte count [uint64_t] */
SAI_POLICER_STAT_YELLOW_BYTES = 0x00000005,
/** Get/set red packet count [uint64_t] */
SAI_POLICER_STAT_RED_PACKETS = 0x00000006,
/** Get/set red byte count [uint64_t] */
SAI_POLICER_STAT_RED_BYTES = 0x00000007,
/** Custom range base value */
SAI_POLICER_STAT_CUSTOM_RANGE_BASE = 0x10000000
} sai_policer_stat_t;
/**
* @brief Create Policer
*
* @param[out] policer_id The policer id
* @param[in] switch_id Switch id
* @param[in] attr_count Number of attributes
* @param[in] attr_list Array of attributes
*
* @return #SAI_STATUS_SUCCESS on success, failure status code on error
*/
typedef sai_status_t (*sai_create_policer_fn)(
_Out_ sai_object_id_t *policer_id,
_In_ sai_object_id_t switch_id,
_In_ uint32_t attr_count,
_In_ const sai_attribute_t *attr_list);
/**
* @brief Delete policer
*
* @param[in] policer_id Policer id
*
* @return #SAI_STATUS_SUCCESS on success, failure status code on error
*/
typedef sai_status_t (*sai_remove_policer_fn)(
_In_ sai_object_id_t policer_id);
/**
* @brief Set Policer attribute
*
* @param[in] policer_id Policer id
* @param[in] attr Attribute
*
* @return #SAI_STATUS_SUCCESS on success, failure status code on error
*/
typedef sai_status_t (*sai_set_policer_attribute_fn)(
_In_ sai_object_id_t policer_id,
_In_ const sai_attribute_t *attr);
/**
* @brief Get Policer attribute
*
* @param[in] policer_id Policer id
* @param[in] attr_count Number of attributes
* @param[inout] attr_list Array of attributes
*
* @return #SAI_STATUS_SUCCESS on success, failure status code on error
*/
typedef sai_status_t (*sai_get_policer_attribute_fn)(
_In_ sai_object_id_t policer_id,
_In_ uint32_t attr_count,
_Inout_ sai_attribute_t *attr_list);
/**
* @brief Get Policer Statistics. Deprecated for backward compatibility.
*
* @param[in] policer_id Policer id
* @param[in] number_of_counters Number of counters in the array
* @param[in] counter_ids Array of counter ids
* @param[out] counters Array of resulting counter values.
*
* @return #SAI_STATUS_SUCCESS on success, failure status code on error
*/
typedef sai_status_t (*sai_get_policer_stats_fn)(
_In_ sai_object_id_t policer_id,
_In_ uint32_t number_of_counters,
_In_ const sai_stat_id_t *counter_ids,
_Out_ uint64_t *counters);
/**
* @brief Get Policer Statistics extended
*
* @param[in] policer_id Policer id
* @param[in] number_of_counters Number of counters in the array
* @param[in] counter_ids Array of counter ids
* @param[in] mode Statistics mode
* @param[out] counters Array of resulting counter values.
*
* @return #SAI_STATUS_SUCCESS on success, failure status code on error
*/
typedef sai_status_t (*sai_get_policer_stats_ext_fn)(
_In_ sai_object_id_t policer_id,
_In_ uint32_t number_of_counters,
_In_ const sai_stat_id_t *counter_ids,
_In_ sai_stats_mode_t mode,
_Out_ uint64_t *counters);
/**
* @brief Clear Policer statistics counters.
*
* @param[in] policer_id Policer id
* @param[in] number_of_counters Number of counters in the array
* @param[in] counter_ids Specifies the array of counter ids
*
* @return #SAI_STATUS_SUCCESS on success, failure status code on error
*/
typedef sai_status_t (*sai_clear_policer_stats_fn)(
_In_ sai_object_id_t policer_id,
_In_ uint32_t number_of_counters,
_In_ const sai_stat_id_t *counter_ids);
/**
* @brief Policer methods table retrieved with sai_api_query()
*/
typedef struct _sai_policer_api_t
{
sai_create_policer_fn create_policer;
sai_remove_policer_fn remove_policer;
sai_set_policer_attribute_fn set_policer_attribute;
sai_get_policer_attribute_fn get_policer_attribute;
sai_get_policer_stats_fn get_policer_stats;
sai_get_policer_stats_ext_fn get_policer_stats_ext;
sai_clear_policer_stats_fn clear_policer_stats;
} sai_policer_api_t;
/**
* @}
*/
#endif /** __SAIPOLICER_H_ */