-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathrtl_acl.hpp
More file actions
493 lines (470 loc) · 17.4 KB
/
Copy pathrtl_acl.hpp
File metadata and controls
493 lines (470 loc) · 17.4 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
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
#ifndef _rtl_acl_hpp_
#define _rtl_acl_hpp_
extern "C"
{
#include "acl.h"
#include "rtk_types.h"
}
class rtl_acl
{
public:
/* Function Name:
* rtl_filter_igrAcl_field_add
* Description:
* Add comparison rule to an ACL configuration
* Input:
* pFilter_cfg - The ACL configuration that this function will add comparison rule
* pFilter_field - The comparison rule that will be added.
* Output:
* None
* Return:
* RT_ERR_OK - OK
* RT_ERR_FAILED - Failed
* RT_ERR_SMI - SMI access error
* RT_ERR_NULL_POINTER - Pointer pFilter_field or pFilter_cfg point to NULL.
* RT_ERR_INPUT - Invalid input parameters.
* Note:
* This function add a comparison rule (*pFilter_field) to an ACL configuration (*pFilter_cfg).
* Pointer pFilter_cfg points to an ACL configuration structure, this structure keeps multiple ACL
* comparison rules by means of linked list. Pointer pFilter_field will be added to linked
* list keeped by structure that pFilter_cfg points to.
*/
rtk_api_ret_t rtl_filter_igrAcl_field_add(rtk_filter_cfg_t *pFilter_cfg, rtk_filter_field_t *pFilter_field)
{
return rtk_filter_igrAcl_field_add(pFilter_cfg, pFilter_field);
}
/* Function Name:
* rtl_filter_igrAcl_cfg_add
* Description:
* Add an ACL configuration to ASIC
* Input:
* filter_id - Start index of ACL configuration.
* pFilter_cfg - The ACL configuration that this function will add comparison rule
* pFilter_action - Action(s) of ACL configuration.
* Output:
* ruleNum - number of rules written in acl table
* Return:
* RT_ERR_OK - OK
* RT_ERR_FAILED - Failed
* RT_ERR_SMI - SMI access error
* RT_ERR_NULL_POINTER - Pointer pFilter_field or pFilter_cfg point to NULL.
* RT_ERR_INPUT - Invalid input parameters.
* RT_ERR_ENTRY_INDEX - Invalid filter_id .
* RT_ERR_NULL_POINTER - Pointer pFilter_action or pFilter_cfg point to NULL.
* RT_ERR_FILTER_INACL_ACT_NOT_SUPPORT - Action is not supported in this chip.
* RT_ERR_FILTER_INACL_RULE_NOT_SUPPORT - Rule is not supported.
* Note:
* This function store pFilter_cfg, pFilter_action into ASIC. The starting
* index(es) is filter_id.
*/
rtk_api_ret_t rtl_filter_igrAcl_cfg_add(rtk_filter_id_t filter_id, rtk_filter_cfg_t *pFilter_cfg, rtk_filter_action_t *pAction, rtk_filter_number_t *ruleNum)
{
return rtk_filter_igrAcl_cfg_add(filter_id, pFilter_cfg, pAction, ruleNum);
}
/* Function Name:
* rtl_filter_igrAcl_cfg_del
* Description:
* Delete an ACL configuration from ASIC
* Input:
* filter_id - Start index of ACL configuration.
* Output:
* None
* Return:
* RT_ERR_OK - OK
* RT_ERR_FAILED - Failed
* RT_ERR_SMI - SMI access error
* RT_ERR_FILTER_ENTRYIDX - Invalid filter_id.
* Note:
* This function delete a group of ACL rules starting from filter_id.
*/
rtk_api_ret_t rtl_filter_igrAcl_cfg_del(rtk_filter_id_t filter_id)
{
return rtk_filter_igrAcl_cfg_del(filter_id);
}
/* Function Name:
* rtl_filter_igrAcl_cfg_delAll
* Description:
* Delete all ACL entries from ASIC
* Input:
* None
* Output:
* None
* Return:
* RT_ERR_OK - OK
* RT_ERR_FAILED - Failed
* RT_ERR_SMI - SMI access error
* Note:
* This function delete all ACL configuration from ASIC.
*/
rtk_api_ret_t rtl_filter_igrAcl_cfg_delAll()
{
return rtk_filter_igrAcl_cfg_delAll();
}
/* Function Name:
* rtl_filter_igrAcl_cfg_get
* Description:
* Get one ingress acl configuration from ASIC.
* Input:
* filter_id - Start index of ACL configuration.
* Output:
* pFilter_cfg - buffer pointer of ingress acl data
* pFilter_action - buffer pointer of ingress acl action
* Return:
* RT_ERR_OK - OK
* RT_ERR_FAILED - Failed
* RT_ERR_SMI - SMI access error
* RT_ERR_NULL_POINTER - Pointer pFilter_action or pFilter_cfg point to NULL.
* RT_ERR_FILTER_ENTRYIDX - Invalid entry index.
* Note:
* This function delete all ACL configuration from ASIC.
*/
rtk_api_ret_t rtl_filter_igrAcl_cfg_get(rtk_filter_id_t filter_id, rtk_filter_cfg_raw_t *pFilter_cfg, rtk_filter_action_t *pAction)
{
return rtk_filter_igrAcl_cfg_get(filter_id, pFilter_cfg, pAction);
}
/* Function Name:
* rtl_filter_igrAcl_unmatchAction_set
* Description:
* Set action to packets when no ACL configuration match
* Input:
* port - Port id.
* action - Action.
* Output:
* None
* Return:
* RT_ERR_OK - OK
* RT_ERR_FAILED - Failed
* RT_ERR_SMI - SMI access error
* RT_ERR_PORT_ID - Invalid port id.
* RT_ERR_INPUT - Invalid input parameters.
* Note:
* This function sets action of packets when no ACL configruation matches.
*/
rtk_api_ret_t rtl_filter_igrAcl_unmatchAction_set(rtk_port_t port, rtk_filter_unmatch_action_t action)
{
return rtk_filter_igrAcl_unmatchAction_set(port, action);
}
/* Function Name:
* rtl_filter_igrAcl_unmatchAction_get
* Description:
* Get action to packets when no ACL configuration match
* Input:
* port - Port id.
* Output:
* pAction - Action.
* Return:
* RT_ERR_OK - OK
* RT_ERR_FAILED - Failed
* RT_ERR_SMI - SMI access error
* RT_ERR_PORT_ID - Invalid port id.
* RT_ERR_INPUT - Invalid input parameters.
* Note:
* This function gets action of packets when no ACL configruation matches.
*/
rtk_api_ret_t rtl_filter_igrAcl_unmatchAction_get(rtk_port_t port, rtk_filter_unmatch_action_t *action)
{
return rtk_filter_igrAcl_unmatchAction_get(port, action);
}
/* Function Name:
* rtl_filter_igrAcl_state_set
* Description:
* Set state of ingress ACL.
* Input:
* port - Port id.
* state - Ingress ACL state.
* Output:
* None
* Return:
* RT_ERR_OK - OK
* RT_ERR_FAILED - Failed
* RT_ERR_SMI - SMI access error
* RT_ERR_PORT_ID - Invalid port id.
* RT_ERR_INPUT - Invalid input parameters.
* Note:
* This function gets action of packets when no ACL configruation matches.
*/
rtk_api_ret_t rtl_filter_igrAcl_state_set(rtk_port_t port, rtk_filter_state_t state)
{
return rtk_filter_igrAcl_state_set(port, state);
}
/* Function Name:
* rtl_filter_igrAcl_state_get
* Description:
* Get state of ingress ACL.
* Input:
* port - Port id.
* Output:
* pState - Ingress ACL state.
* Return:
* RT_ERR_OK - OK
* RT_ERR_FAILED - Failed
* RT_ERR_SMI - SMI access error
* RT_ERR_PORT_ID - Invalid port id.
* RT_ERR_INPUT - Invalid input parameters.
* Note:
* This function gets action of packets when no ACL configruation matches.
*/
rtk_api_ret_t rtl_filter_igrAcl_state_get(rtk_port_t port, rtk_filter_state_t *state)
{
return rtk_filter_igrAcl_state_get(port, state);
}
/* Function Name:
* rtl_filter_igrAcl_template_set
* Description:
* Set template of ingress ACL.
* Input:
* template - Ingress ACL template
* Output:
* None
* Return:
* RT_ERR_OK - OK
* RT_ERR_FAILED - Failed
* RT_ERR_SMI - SMI access error
* RT_ERR_INPUT - Invalid input parameters.
* Note:
* This function set ACL template.
*/
rtk_api_ret_t rtl_filter_igrAcl_template_set(rtk_filter_template_t *aclTemplate)
{
return rtk_filter_igrAcl_template_set(aclTemplate);
}
/* Function Name:
* rtl_filter_igrAcl_template_get
* Description:
* Get template of ingress ACL.
* Input:
* template - Ingress ACL template
* Output:
* None
* Return:
* RT_ERR_OK - OK
* RT_ERR_FAILED - Failed
* RT_ERR_SMI - SMI access error
* Note:
* This function gets template of ACL.
*/
rtk_api_ret_t rtl_filter_igrAcl_template_get(rtk_filter_template_t *aclTemplate)
{
return rtk_filter_igrAcl_template_get(aclTemplate);
}
/* Function Name:
* rtl_filter_igrAcl_field_sel_set
* Description:
* Set user defined field selectors in HSB
* Input:
* index - index of field selector 0-15
* format - Format of field selector
* offset - Retrieving data offset
* Output:
* None
* Return:
* RT_ERR_OK - OK
* RT_ERR_FAILED - Failed
* RT_ERR_SMI - SMI access error
* Note:
* System support 16 user defined field selctors.
* Each selector can be enabled or disable.
* User can defined retrieving 16-bits in many predefiend
* standard l2/l3/l4 payload.
*/
rtk_api_ret_t rtl_filter_igrAcl_field_sel_set(rtk_uint32 index, rtk_field_sel_t format, rtk_uint32 offset)
{
return rtk_filter_igrAcl_field_sel_set(index, format, offset);
}
/* Function Name:
* rtl_filter_igrAcl_field_sel_get
* Description:
* Get user defined field selectors in HSB
* Input:
* index - index of field selector 0-15
* Output:
* pFormat - Format of field selector
* pOffset - Retrieving data offset
* Return:
* RT_ERR_OK - OK
* RT_ERR_FAILED - Failed
* RT_ERR_SMI - SMI access error
* Note:
* None.
*/
rtk_api_ret_t rtl_filter_igrAcl_field_sel_get(rtk_uint32 index, rtk_field_sel_t *pFormat, rtk_uint32 *pOffset)
{
return rtk_filter_igrAcl_field_sel_get(index, pFormat, pOffset);
}
/* Function Name:
* rtl_filter_iprange_set
* Description:
* Set IP Range check
* Input:
* index - index of IP Range 0-15
* type - IP Range check type, 0:Delete a entry, 1: IPv4_SIP, 2: IPv4_DIP, 3:IPv6_SIP, 4:IPv6_DIP
* upperIp - The upper bound of IP range
* lowerIp - The lower Bound of IP range
* Output:
* None.
* Return:
* RT_ERR_OK - OK
* RT_ERR_FAILED - Failed
* RT_ERR_SMI - SMI access error
* RT_ERR_OUT_OF_RANGE - The parameter is out of range
* RT_ERR_INPUT - Input error
* Note:
* upperIp must be larger or equal than lowerIp.
*/
rtk_api_ret_t rtl_filter_iprange_set(rtk_uint32 index, rtk_filter_iprange_t type, ipaddr_t upperIp, ipaddr_t lowerIp)
{
return rtk_filter_iprange_set(index, type, upperIp, lowerIp);
}
/* Function Name:
* rtl_filter_iprange_get
* Description:
* Set IP Range check
* Input:
* index - index of IP Range 0-15
* Output:
* pType - IP Range check type, 0:Delete a entry, 1: IPv4_SIP, 2: IPv4_DIP, 3:IPv6_SIP, 4:IPv6_DIP
* pUpperIp - The upper bound of IP range
* pLowerIp - The lower Bound of IP range
* Return:
* RT_ERR_OK - OK
* RT_ERR_FAILED - Failed
* RT_ERR_SMI - SMI access error
* RT_ERR_OUT_OF_RANGE - The parameter is out of range
* Note:
* upperIp must be larger or equal than lowerIp.
*/
rtk_api_ret_t rtl_filter_iprange_get(rtk_uint32 index, rtk_filter_iprange_t *pType, ipaddr_t *pUpperIp, ipaddr_t *pLowerIp)
{
return rtk_filter_iprange_get(index, pType, pUpperIp, pLowerIp);
}
/* Function Name:
* rtl_filter_vidrange_set
* Description:
* Set VID Range check
* Input:
* index - index of VID Range 0-15
* type - IP Range check type, 0:Delete a entry, 1: CVID, 2: SVID
* upperVid - The upper bound of VID range
* lowerVid - The lower Bound of VID range
* Output:
* None.
* Return:
* RT_ERR_OK - OK
* RT_ERR_FAILED - Failed
* RT_ERR_SMI - SMI access error
* RT_ERR_OUT_OF_RANGE - The parameter is out of range
* RT_ERR_INPUT - Input error
* Note:
* upperVid must be larger or equal than lowerVid.
*/
rtk_api_ret_t rtl_filter_vidrange_set(rtk_uint32 index, rtk_filter_vidrange_t type, rtk_uint32 upperVid, rtk_uint32 lowerVid)
{
return rtk_filter_vidrange_set(index, type, upperVid, lowerVid);
}
/* Function Name:
* rtl_filter_vidrange_get
* Description:
* Get VID Range check
* Input:
* index - index of VID Range 0-15
* Output:
* pType - IP Range check type, 0:Unused, 1: CVID, 2: SVID
* pUpperVid - The upper bound of VID range
* pLowerVid - The lower Bound of VID range
* Return:
* RT_ERR_OK - OK
* RT_ERR_FAILED - Failed
* RT_ERR_SMI - SMI access error
* RT_ERR_OUT_OF_RANGE - The parameter is out of range
* Note:
* None.
*/
rtk_api_ret_t rtl_filter_vidrange_get(rtk_uint32 index, rtk_filter_vidrange_t *pType, rtk_uint32 *pUpperVid, rtk_uint32 *pLowerVid)
{
return rtk_filter_vidrange_get(index, pType, pUpperVid, pLowerVid);
}
/* Function Name:
* rtl_filter_portrange_set
* Description:
* Set Port Range check
* Input:
* index - index of Port Range 0-15
* type - IP Range check type, 0:Delete a entry, 1: Source Port, 2: Destnation Port
* upperPort - The upper bound of Port range
* lowerPort - The lower Bound of Port range
* Output:
* None.
* Return:
* RT_ERR_OK - OK
* RT_ERR_FAILED - Failed
* RT_ERR_SMI - SMI access error
* RT_ERR_OUT_OF_RANGE - The parameter is out of range
* RT_ERR_INPUT - Input error
* Note:
* upperPort must be larger or equal than lowerPort.
*/
rtk_api_ret_t rtl_filter_portrange_set(rtk_uint32 index, rtk_filter_portrange_t type, rtk_uint32 upperPort, rtk_uint32 lowerPort)
{
return rtk_filter_portrange_set(index, type, upperPort, lowerPort);
}
/* Function Name:
* rtl_filter_portrange_get
* Description:
* Set Port Range check
* Input:
* index - index of Port Range 0-15
* Output:
* pType - IP Range check type, 0:Delete a entry, 1: Source Port, 2: Destnation Port
* pUpperPort - The upper bound of Port range
* pLowerPort - The lower Bound of Port range
* Return:
* RT_ERR_OK - OK
* RT_ERR_FAILED - Failed
* RT_ERR_SMI - SMI access error
* RT_ERR_OUT_OF_RANGE - The parameter is out of range
* RT_ERR_INPUT - Input error
* Note:
* None.
*/
rtk_api_ret_t rtl_filter_portrange_get(rtk_uint32 index, rtk_filter_portrange_t *pType, rtk_uint32 *pUpperPort, rtk_uint32 *pLowerPort)
{
return rtk_filter_portrange_get(index, pType, pUpperPort, pLowerPort);
}
/* Function Name:
* rtl_filter_igrAclPolarity_set
* Description:
* Set ACL Goip control palarity
* Input:
* polarity - 1: High, 0: Low
* Output:
* None
* Return:
* RT_ERR_OK - Success
* RT_ERR_SMI - SMI access error
* Note:
* none
*/
rtk_api_ret_t rtl_filter_igrAclPolarity_set(rtk_uint32 polarity)
{
return rtk_filter_igrAclPolarity_set(polarity);
}
/* Function Name:
* rtl_filter_igrAclPolarity_get
* Description:
* Get ACL Goip control palarity
* Input:
* pPolarity - 1: High, 0: Low
* Output:
* None
* Return:
* RT_ERR_OK - Success
* RT_ERR_SMI - SMI access error
* Note:
* none
*/
rtk_api_ret_t rtl_filter_igrAclPolarity_get(rtk_uint32 *pPolarity)
{
return rtk_filter_igrAclPolarity_get(pPolarity);
}
};
#endif