-
Notifications
You must be signed in to change notification settings - Fork 609
Expand file tree
/
Copy pathsaiudf.h
More file actions
476 lines (419 loc) · 11.5 KB
/
Copy pathsaiudf.h
File metadata and controls
476 lines (419 loc) · 11.5 KB
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
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
/**
* 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 saiudf.h
*
* @brief This module defines SAI UDF (User Defined Field) interface
*/
#if !defined (__SAIUDF_H_)
#define __SAIUDF_H_
#include <saitypes.h>
/**
* @defgroup SAIUDF SAI - User Defined Field specific API definitions
*
* @{
*/
/**
* @brief UDF base enum
*/
typedef enum _sai_udf_base_t
{
/** UDF offset base from the start of L2 header */
SAI_UDF_BASE_L2,
/** UDF offset base from the start of L3 header */
SAI_UDF_BASE_L3,
/** UDF offset base from the start of L4 header */
SAI_UDF_BASE_L4,
} sai_udf_base_t;
/**
* @brief Attribute id for UDF
*/
typedef enum _sai_udf_attr_t
{
/**
* @brief Start of attributes
*/
SAI_UDF_ATTR_START,
/**
* @brief UDF match ID
*
* @type sai_object_id_t
* @flags MANDATORY_ON_CREATE | CREATE_ONLY
* @objects SAI_OBJECT_TYPE_UDF_MATCH
*/
SAI_UDF_ATTR_MATCH_ID = SAI_UDF_ATTR_START,
/**
* @brief UDF group id
*
* @type sai_object_id_t
* @flags MANDATORY_ON_CREATE | CREATE_ONLY
* @objects SAI_OBJECT_TYPE_UDF_GROUP
*/
SAI_UDF_ATTR_GROUP_ID,
/**
* @brief UDF base
*
* @type sai_udf_base_t
* @flags CREATE_AND_SET
* @default SAI_UDF_BASE_L2
*/
SAI_UDF_ATTR_BASE,
/**
* @brief UDF byte offset
*
* @type sai_uint16_t
* @flags MANDATORY_ON_CREATE | CREATE_ONLY
* @isvlan false
*/
SAI_UDF_ATTR_OFFSET,
/**
* @brief UDF Mask
*
* Default to 2 bytes, value 0xFF, 0xFF
*
* The count in the list must be equal to the UDF byte length.
* The mask only applies to extracted UDF when it is used for hash,
* it does not apply to the extracted UDF when it is used for ACL.
*
* @type sai_u8_list_t
* @flags CREATE_AND_SET
* @default const
*/
SAI_UDF_ATTR_HASH_MASK,
/**
* @brief End of attributes
*/
SAI_UDF_ATTR_END,
/** Custom range base value */
SAI_UDF_ATTR_CUSTOM_RANGE_START = 0x10000000,
/** End of custom range base */
SAI_UDF_ATTR_CUSTOM_RANGE_END
} sai_udf_attr_t;
/**
* @brief Attribute id for UDF match
*/
typedef enum _sai_udf_match_attr_t
{
/**
* @brief Start of attributes
*/
SAI_UDF_MATCH_ATTR_START,
/**
* @brief UDF L2 match rule
*
* Default to None
*
* @type sai_acl_field_data_t sai_uint16_t
* @flags CREATE_ONLY
* @isvlan false
* @default 0
*/
SAI_UDF_MATCH_ATTR_L2_TYPE = SAI_UDF_MATCH_ATTR_START,
/**
* @brief UDF L3 match rule
*
* Default to None
*
* @type sai_acl_field_data_t sai_uint8_t
* @flags CREATE_ONLY
* @default 0
*/
SAI_UDF_MATCH_ATTR_L3_TYPE,
/**
* @brief UDF GRE match rule
*
* Default to None
*
* @type sai_acl_field_data_t sai_uint16_t
* @flags CREATE_ONLY
* @isvlan false
* @default 0
*/
SAI_UDF_MATCH_ATTR_GRE_TYPE,
/**
* @brief UDF match priority
*
* @type sai_uint8_t
* @flags CREATE_ONLY
* @default 0
*/
SAI_UDF_MATCH_ATTR_PRIORITY,
/**
* @brief UDF L4 Dst port rule
*
* Default to None
*
* @type sai_acl_field_data_t sai_uint16_t
* @flags CREATE_ONLY
* @isvlan false
* @default 0
*/
SAI_UDF_MATCH_ATTR_L4_DST_PORT_TYPE,
/**
* @brief End of attributes
*/
SAI_UDF_MATCH_ATTR_END,
/** Custom range base value */
SAI_UDF_MATCH_ATTR_CUSTOM_RANGE_START = 0x10000000,
/** End of custom range base */
SAI_UDF_MATCH_ATTR_CUSTOM_RANGE_END
} sai_udf_match_attr_t;
/**
* @brief UDF group type.
*/
typedef enum _sai_udf_group_type_t
{
/** Start of group type */
SAI_UDF_GROUP_TYPE_START,
/** Generic UDF group */
SAI_UDF_GROUP_TYPE_GENERIC = SAI_UDF_GROUP_TYPE_START,
/** UDF group for hash */
SAI_UDF_GROUP_TYPE_HASH,
/** End of group type */
SAI_UDF_GROUP_TYPE_END
} sai_udf_group_type_t;
/**
* @brief Attribute id for UDF group
*/
typedef enum _sai_udf_group_attr_t
{
/**
* @brief Start of attributes
*/
SAI_UDF_GROUP_ATTR_START,
/**
* @brief UDF list
*
* @type sai_object_list_t
* @flags READ_ONLY
* @objects SAI_OBJECT_TYPE_UDF
*/
SAI_UDF_GROUP_ATTR_UDF_LIST = SAI_UDF_GROUP_ATTR_START,
/**
* @brief UDF group type
*
* @type sai_udf_group_type_t
* @flags CREATE_ONLY
* @default SAI_UDF_GROUP_TYPE_GENERIC
*/
SAI_UDF_GROUP_ATTR_TYPE,
/**
* @brief UDF byte length
*
* @type sai_uint16_t
* @flags MANDATORY_ON_CREATE | CREATE_ONLY
* @isvlan false
*/
SAI_UDF_GROUP_ATTR_LENGTH,
/**
* @brief Label attribute used to uniquely identify UDF group.
*
* @type char
* @flags CREATE_AND_SET
* @default ""
* @deprecated true
*/
SAI_UDF_GROUP_ATTR_LABEL,
/**
* @brief Wide label attribute used to uniquely identify UDF group.
*
* Replaces #SAI_UDF_GROUP_ATTR_LABEL, which is limited to 32 bytes.
* Exactly one of the two attributes may be set to a non-default
* value; setting both is invalid.
*
* @type sai_s8_list_t
* @flags CREATE_AND_SET
* @default empty
*/
SAI_UDF_GROUP_ATTR_LABEL_WIDE,
/**
* @brief End of attributes
*/
SAI_UDF_GROUP_ATTR_END,
/** Custom range base value */
SAI_UDF_GROUP_ATTR_CUSTOM_RANGE_START = 0x10000000,
/** End of custom range base */
SAI_UDF_GROUP_ATTR_CUSTOM_RANGE_END
} sai_udf_group_attr_t;
/**
* @brief Create UDF
*
* @param[out] udf_id UDF 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_udf_fn)(
_Out_ sai_object_id_t *udf_id,
_In_ sai_object_id_t switch_id,
_In_ uint32_t attr_count,
_In_ const sai_attribute_t *attr_list);
/**
* @brief Remove UDF
*
* @param[in] udf_id UDF id
*
* @return #SAI_STATUS_SUCCESS on success, failure status code on error
*/
typedef sai_status_t (*sai_remove_udf_fn)(
_In_ sai_object_id_t udf_id);
/**
* @brief Set UDF attribute
*
* @param[in] udf_id UDF id
* @param[in] attr Attribute
*
* @return #SAI_STATUS_SUCCESS on success, failure status code on error
*/
typedef sai_status_t (*sai_set_udf_attribute_fn)(
_In_ sai_object_id_t udf_id,
_In_ const sai_attribute_t *attr);
/**
* @brief Get UDF attribute value
*
* @param[in] udf_id UDF 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_udf_attribute_fn)(
_In_ sai_object_id_t udf_id,
_In_ uint32_t attr_count,
_Inout_ sai_attribute_t *attr_list);
/**
* @brief Create UDF match
*
* @param[out] udf_match_id UDF match 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_udf_match_fn)(
_Out_ sai_object_id_t *udf_match_id,
_In_ sai_object_id_t switch_id,
_In_ uint32_t attr_count,
_In_ const sai_attribute_t *attr_list);
/**
* @brief Remove UDF match
*
* @param[in] udf_match_id UDF match id
*
* @return #SAI_STATUS_SUCCESS on success, failure status code on error
*/
typedef sai_status_t (*sai_remove_udf_match_fn)(
_In_ sai_object_id_t udf_match_id);
/**
* @brief Set UDF match attribute
*
* @param[in] udf_match_id UDF match id
* @param[in] attr Attribute
*
* @return #SAI_STATUS_SUCCESS on success, failure status code on error
*/
typedef sai_status_t (*sai_set_udf_match_attribute_fn)(
_In_ sai_object_id_t udf_match_id,
_In_ const sai_attribute_t *attr);
/**
* @brief Get UDF match attribute value
*
* @param[in] udf_match_id UDF match id
* @param[in] attr_count Number of attributes
* @param[inout] attr_list List of attributes
*
* @return #SAI_STATUS_SUCCESS on success, failure status code on error
*/
typedef sai_status_t (*sai_get_udf_match_attribute_fn)(
_In_ sai_object_id_t udf_match_id,
_In_ uint32_t attr_count,
_Inout_ sai_attribute_t *attr_list);
/**
* @brief Create UDF group
*
* @param[out] udf_group_id UDF group 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_udf_group_fn)(
_Out_ sai_object_id_t *udf_group_id,
_In_ sai_object_id_t switch_id,
_In_ uint32_t attr_count,
_In_ const sai_attribute_t *attr_list);
/**
* @brief Remove UDF group
*
* @param[in] udf_group_id UDF group id
*
* @return #SAI_STATUS_SUCCESS on success, failure status code on error
*/
typedef sai_status_t (*sai_remove_udf_group_fn)(
_In_ sai_object_id_t udf_group_id);
/**
* @brief Set UDF group attribute
*
* @param[in] udf_group_id UDF group id
* @param[in] attr Attribute
*
* @return #SAI_STATUS_SUCCESS on success, failure status code on error
*/
typedef sai_status_t (*sai_set_udf_group_attribute_fn)(
_In_ sai_object_id_t udf_group_id,
_In_ const sai_attribute_t *attr);
/**
* @brief Get UDF group attribute value
*
* @param[in] udf_group_id UDF group 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_udf_group_attribute_fn)(
_In_ sai_object_id_t udf_group_id,
_In_ uint32_t attr_count,
_Inout_ sai_attribute_t *attr_list);
/**
* @brief UDF methods, retrieved via sai_api_query()
*/
typedef struct _sai_udf_api_t
{
sai_create_udf_fn create_udf;
sai_remove_udf_fn remove_udf;
sai_set_udf_attribute_fn set_udf_attribute;
sai_get_udf_attribute_fn get_udf_attribute;
sai_create_udf_match_fn create_udf_match;
sai_remove_udf_match_fn remove_udf_match;
sai_set_udf_match_attribute_fn set_udf_match_attribute;
sai_get_udf_match_attribute_fn get_udf_match_attribute;
sai_create_udf_group_fn create_udf_group;
sai_remove_udf_group_fn remove_udf_group;
sai_set_udf_group_attribute_fn set_udf_group_attribute;
sai_get_udf_group_attribute_fn get_udf_group_attribute;
} sai_udf_api_t;
/**
* @}
*/
#endif /** __SAIUDF_H_ */