-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtcam_write.h
382 lines (337 loc) · 6.92 KB
/
tcam_write.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
#include "common.h"
#include "cm_hash.h"
#define SYS_ACL_REMEMBER_BASE 10
#define SYS_ACL_INVALID_INDEX -1
#define CM_ACLQOS_ENTRY_ID_HEAD 0
#define CM_ACLQOS_ENTRY_ID_TAIL 0xffffffff
enum cm_aclqos_label_type_e{
ACL_LABEL,
QOS_LABEL,
SERVICE_LABEL
};
typedef enum cm_aclqos_label_type_e cm_aclqos_label_type_t;
struct sys_chip_master_s
{
uint8 lchip_num;
uint8 resv;
uint8 g_chip_id[MAX_LOCAL_CHIP_NUM];
};
typedef struct sys_chip_master_s sys_chip_master_t;
struct _fpa_target_s
{
uint16 t_idx;//target index
uint16 o_idx;//old index
};
typedef struct _fpa_target_s _fpa_target_t;
struct sys_aclqos_flag_s
{
uint32 discard:1,
deny_replace_cos:1,
deny_replace_dscp:1,
deny_bridge:1,
deny_learning:1,
deny_route:1,
stats:1,
flow_policer:1,
trust:1,
priority:1,
random_log:1,
fwd:1,
fwd_to_cpu:1,
flow_id:1,
stats_mode:1,
invalid:1,
pbr_fwd:1,
pbr_ttl_check:1,
pbr_icmp_check:1,
pbr_ecmp:1,
pbr_copy_to_cpu:1,
pbr_deny:1,
rsv:10;
};
typedef struct sys_aclqos_flag_s sys_aclqos_flag_t;
struct sys_aclqos_action_s
{
sys_aclqos_action_flag_t flag;
union
{
uint32 fwd_nh_id;
uint32 fwd_reason;
}fwd;
union
{
uint16 stats_ptr;
uint16 flow_id;
}stats_or_flowid;
uint16 rsv1;
uint32 policer_id;
uint32 priority:6,
color:2,
trust:3,
acl_log_id:2,
random_threshold_shift:4,
ds_fwd_ptr:12,
rsv2:15;
uint32 pbr_fwd_ptr :20,
rsv:12;
uint16 pbr_vrfid;
uint8 pbr_ecpn;
uint8 rsv4;
};
typedef struct sys_aclqos_action_s sys_aclqos_action_t;
struct sys_aclqos_mac_key_flag_s
{
uint32 macda:1,
macsa:1,
vlan_ptr:1,
cos:1,
cvlan:1,
ctag_cos:1,
ctag_cfi:1,
svlan:1,
stag_cos:1,
stag_cfi:1,
eth_type:1,
l2_type:1,
l3_type:1,
acl_type:1,
qos_type:1,
l2_qos_label:1,
l3_qos_label:1,
is_glb_entry:1,
rsv:14;
};
typedef struct sys_aclqos_mac_key_flag_s sys_aclqos_mac_key_flag_t;
struct sys_aclqos_mac_key_s
{
sys_aclqos_mac_key_flag_t flag;
mac_addr_t mac_da;
mac_addr_t mac_da_mask;
mac_addr_t mac_sa;
mac_addr_t mac_sa_mask;
uint32 vlan_ptr:14,
eth_type:16,
rsv1:2;
uint32 cvlan:12,
ctag_cos_cfi:4,
svlan:12,
stag_cos_cfi:4;
uint32 cvlan_mask:12,
svlan_mask:12,
rsv2:8;
uint32 l2_type:4,
l3_type:4,
cos:3,
rsv3:21;
uint32 acl_label:8,
qos_label:8,
l2_qos_label:8,
l3_qos_label:8;
uint32 eth_type_mask:8,
table_id0:4,
table_id1:4,
table_id2:4,
table_id3:4;
};
typedef struct sys_aclqos_mac_key_s sys_aclqos_mac_key_t;
struct sys_aclqos_ipv4_key_flag_s
{
uint32 ipda:1,
ipsa:1,
l4info_mapped:1,
is_application:1,
is_tcp:1,
is_udp:1,
l4_src_port:1,
l4_dst_port:1,
tcp_flag:1,
dscp:1,
frag_info:1,
ip_option:1,
routed_packet:1,
macda:1,
macsa:1,
cos:1,
cvlan:1,
ctag_cos:1,
ctag_cfi:1,
svlan:1,
stag_cos:1,
stag_cfi:1,
l2_type:1,
l3_type:1,
acl_label:1,
qos_label:1,
l2_qos_label:1,
l3_qos_label:1,
is_glb_entry:1,
rsv:2;
};
typedef struct sys_aclqos_ipv4_key_flag_s sys_aclqos_ipv4_key_flag_t;
struct sys_aclqos_ipv4_key_s
{
sys_aclqos_ipv4_key_flag_t flag;
uint32 ip_sa;
uint32 ip_sa_mask;
uint32 ip_da;
uint32 ip_da_mask;
uint16 l4_src_port;
uint16 l4_src_port_mask;
uint16 l4_dst_port;
uint16 l4_dst_port_mask;
uint16 l4info_mapped;
uint16 l4info_mapped_mask;
uint32 frag_info:2,
frag_info_mask:2,
dscp:6,
dcsp_mask:6,
is_application:1,
is_tcp:1,
is_udp:1,
routed_packet:1,
ip_pbr_error:1,
rsv1:11;
mac_addr_t mac_da;
mac_addr_t mac_da_mask;
mac_addr_t mac_sa;
mac_addr_t mac_sa_mask;
uint32 cvlan:12,
ctag_cos_cfi:4,
svlan:12,
stag_cos_cfi:4;
uint32 cvlan_mask:12,
svlan_mask:12,
rsv4:8;
uint32 cos:3,
l2_type:4,
l3_type:4,
rsv2:21;
uint32 acl_label:8,
qos_label:8,
l2_qos_label:8,
l3_qos_label:8;
uint32 acl_label_mask:8,
qos_label_mask:8,
l2_qos_label_mask:8,
l3_qos_label_mask:8;
uint32 table_id0:4,
table_id1:4,
table_id2:4,
table_id3:4,
rsv3;16;
};
typedef struct sys_aclqos_ipv4_key_s sys_aclqos_ipv4_key_t;
struct sys_aclqos_sub_entry_info_flag_s
{
uint32 l4_src_port:1,
l4_dst_port:1,
frag_info:1,
ext_hdrL:1,
reset_l4info:1,
rsv:27;
};
typedef struct sys_aclqos_sub_entry_info_flag_s sys_aclqos_sub_entry_info_flag_t;
struct sys_aclqos_sub_entry_info_s
{
sys_aclqos_sub_entry_info_flag_t flag;
uint16 l4_src_port;
uint16 l4_src_port_mask;
uint16 l4_dst_port;
uint16 l4_dst_port_mask;
uint8 frag_info;
uint8 frag_info_mask;
uint8 ext_hdr;
uint8 ext_hdr_mask;
uint32 offset;
};
typedef struct sys_aclqos_sub_entry_info_s sys_aclqos_sub_entry_info_t;
enum cm_aclqos_key_type_e
{
CTC_ACLQOS_MAC_KEY = 0,
CTC_ACLQOS_IPV4_KEY
};
typedef enum cm_aclqos_key_type_e cm_aclqos_key_type_t;
struct sys_aclqos_key_s
{
cm_aclqos_key_type_t type;
union
{
sys_aclqos_mac_key_t mac_key;
sys_aclqos_ipv4_key_t ipv4_key;
}key_info;
};
typedef struct sys_aclqos_key_s sys_aclqos_key_t;
typedef struct cm_list_pointer_node_s
{
struct cm_list_pointer_node_s* p_next;
struct cm_list_pointer_node_s* p_prev;
}cm_list_pointer_node_t;
enum sys_aclqos_label_type_e
{
SYS_PORT_ACL_LABEL,
SYS_VLAN_ACL_LABEL,
SYS_PBR_ACL_LABEL,
SYS_PORT_QOS_LABEL,
SYS_VLAN_QOS_LABEL,
SYS_SERVICE_ACLQOS_LABEL,
MAX_SYS_ACLQOS_LABEL
};
typedef enum sys_aclqos_label_type_e sys_aclqos_label_type_t;
struct sys_aclqos_label_s
{
uint32 id;
sys_aclqos_label_index_t *p_index[MAX_LOCAL_CHIP_NUM];// MAX_LOCAL_CHIP_NUM = 2
uint8 type;/* SYS_XXX_LABEL*/
uint8 dir;
uint8 ref;
};
typedef struct sys_aclqos_label_s sys_aclqos_label_t;
struct sys_aclqos_entry_s
{
cm_list_pointer_node_t head;//double direction link
uint32 entry_id;
sys_aclqos_action_t action;
sys_aclqos_key_t key;
uint16 block_index;
void *p_label;/*sys_aclqos_label_t*/
};
typedef struct sys_aclqos_entry_s sys_aclqos_entry_t;
typedef struct sys_aclqos_entry_s sys_acl_entry_t;
struct sys_aclqos_global_entryid_list_s
{
cm_list_pointer_node_t head;
sys_aclqos_entry_t *p_entry;
};
typedef struct sys_aclqos_global_entryid_list_s sys_aclqos_global_entryid_list_t;
struct sys_acl_block_s
{
uint8 block_number;/*physical block 0~4*/
uint8 block_type;/*mac/ipv4*/
uint16 entry_count;/*entry count on each block, 512, uint16 is enough*/
uint16 entry_dft_cnt;
uint16 entry_dft_max;
uint16 free_count;
sys_aclqos_entry_t **entries;
uint8 lchip;
uint16 after_0_cnt;//entry count < SYS_REMEMBER_BASE
uint16 after_1_cnt;
};
typedef struct sys_acl_block_s sys_acl_block_t;
#define SYS_ACL_ASIC_TYPE_MAX 2
struct sys_aclqos_entry_ctl_s
{
uint8 entry_sort_mode;
uint8 is_merge_mac_ip_key;
uint8 is_dual_aclqos_lookup;
uint8 disable_merge_mac_ip_key_physical;
uint16 mac_ipv4_acl_entry_num;
uint16 ipv6_acl_entry_num;
uint16 mac_ipv4_acl_entry_num;
uint32 acl_fwd_base;
uint32 global_aclqos_entry_head_num;
uint32 global_aclqos_entry_tail_num;
cm_hash_t* entry;
sys_acl_block_t block[SYS_ACL_ASIC_TYPE_MAX];// SYS_ACL_ASIC_TYPE_MAX = 2
uint8 asic_type[MAX_CTC_ACLQOS_KEY];
};
typedef struct sys_aclqos_entry_ctl_s sys_aclqos_entry_ctl_t;