mediatek: add support for rtl8367c
[openwrt/staging/jow.git] / target / linux / mediatek / files-5.4 / drivers / net / phy / rtk / rtl8367c / include / l2.h
1 /*
2 * Copyright (C) 2013 Realtek Semiconductor Corp.
3 * All Rights Reserved.
4 *
5 * Unless you and Realtek execute a separate written software license
6 * agreement governing use of this software, this software is licensed
7 * to you under the terms of the GNU General Public License version 2,
8 * available at https://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
9 *
10 * Purpose : RTL8367/RTL8367C switch high-level API
11 *
12 * Feature : The file includes L2 module high-layer API defination
13 *
14 */
15
16 #ifndef __RTK_API_L2_H__
17 #define __RTK_API_L2_H__
18
19
20 /*
21 * Data Type Declaration
22 */
23 #define RTK_MAX_NUM_OF_LEARN_LIMIT (rtk_switch_maxLutAddrNumber_get())
24
25 #define RTK_MAC_ADDR_LEN 6
26 #define RTK_MAX_LUT_ADDRESS (RTK_MAX_NUM_OF_LEARN_LIMIT)
27 #define RTK_MAX_LUT_ADDR_ID (RTK_MAX_LUT_ADDRESS - 1)
28
29 typedef rtk_uint32 rtk_l2_age_time_t;
30
31 typedef enum rtk_l2_flood_type_e
32 {
33 FLOOD_UNKNOWNDA = 0,
34 FLOOD_UNKNOWNMC,
35 FLOOD_BC,
36 FLOOD_END
37 } rtk_l2_flood_type_t;
38
39 typedef rtk_uint32 rtk_l2_flushItem_t;
40
41 typedef enum rtk_l2_flushType_e
42 {
43 FLUSH_TYPE_BY_PORT = 0, /* physical port */
44 FLUSH_TYPE_BY_PORT_VID, /* physical port + VID */
45 FLUSH_TYPE_BY_PORT_FID, /* physical port + FID */
46 FLUSH_TYPE_END
47 } rtk_l2_flushType_t;
48
49 typedef struct rtk_l2_flushCfg_s
50 {
51 rtk_enable_t flushByVid;
52 rtk_vlan_t vid;
53 rtk_enable_t flushByFid;
54 rtk_uint32 fid;
55 rtk_enable_t flushByPort;
56 rtk_port_t port;
57 rtk_enable_t flushByMac;
58 rtk_mac_t ucastAddr;
59 rtk_enable_t flushStaticAddr;
60 rtk_enable_t flushAddrOnAllPorts; /* this is used when flushByVid */
61 } rtk_l2_flushCfg_t;
62
63 typedef enum rtk_l2_read_method_e{
64
65 READMETHOD_MAC = 0,
66 READMETHOD_ADDRESS,
67 READMETHOD_NEXT_ADDRESS,
68 READMETHOD_NEXT_L2UC,
69 READMETHOD_NEXT_L2MC,
70 READMETHOD_NEXT_L3MC,
71 READMETHOD_NEXT_L2L3MC,
72 READMETHOD_NEXT_L2UCSPA,
73 READMETHOD_END
74 }rtk_l2_read_method_t;
75
76 /* l2 limit learning count action */
77 typedef enum rtk_l2_limitLearnCntAction_e
78 {
79 LIMIT_LEARN_CNT_ACTION_DROP = 0,
80 LIMIT_LEARN_CNT_ACTION_FORWARD,
81 LIMIT_LEARN_CNT_ACTION_TO_CPU,
82 LIMIT_LEARN_CNT_ACTION_END
83 } rtk_l2_limitLearnCntAction_t;
84
85 typedef enum rtk_l2_ipmc_lookup_type_e
86 {
87 LOOKUP_MAC = 0,
88 LOOKUP_IP,
89 LOOKUP_IP_VID,
90 LOOKUP_END
91 } rtk_l2_ipmc_lookup_type_t;
92
93 /* l2 address table - unicast data structure */
94 typedef struct rtk_l2_ucastAddr_s
95 {
96 rtk_mac_t mac;
97 rtk_uint32 ivl;
98 rtk_uint32 cvid;
99 rtk_uint32 fid;
100 rtk_uint32 efid;
101 rtk_uint32 port;
102 rtk_uint32 sa_block;
103 rtk_uint32 da_block;
104 rtk_uint32 auth;
105 rtk_uint32 is_static;
106 rtk_uint32 priority;
107 rtk_uint32 sa_pri_en;
108 rtk_uint32 fwd_pri_en;
109 rtk_uint32 address;
110 }rtk_l2_ucastAddr_t;
111
112 /* l2 address table - multicast data structure */
113 typedef struct rtk_l2_mcastAddr_s
114 {
115 rtk_uint32 vid;
116 rtk_mac_t mac;
117 rtk_uint32 fid;
118 rtk_portmask_t portmask;
119 rtk_uint32 ivl;
120 rtk_uint32 priority;
121 rtk_uint32 fwd_pri_en;
122 rtk_uint32 igmp_asic;
123 rtk_uint32 igmp_index;
124 rtk_uint32 address;
125 }rtk_l2_mcastAddr_t;
126
127 /* l2 address table - ip multicast data structure */
128 typedef struct rtk_l2_ipMcastAddr_s
129 {
130 ipaddr_t dip;
131 ipaddr_t sip;
132 rtk_portmask_t portmask;
133 rtk_uint32 priority;
134 rtk_uint32 fwd_pri_en;
135 rtk_uint32 igmp_asic;
136 rtk_uint32 igmp_index;
137 rtk_uint32 address;
138 }rtk_l2_ipMcastAddr_t;
139
140 /* l2 address table - ip VID multicast data structure */
141 typedef struct rtk_l2_ipVidMcastAddr_s
142 {
143 ipaddr_t dip;
144 ipaddr_t sip;
145 rtk_uint32 vid;
146 rtk_portmask_t portmask;
147 rtk_uint32 address;
148 }rtk_l2_ipVidMcastAddr_t;
149
150 typedef struct rtk_l2_addr_table_s
151 {
152 rtk_uint32 index;
153 ipaddr_t sip;
154 ipaddr_t dip;
155 rtk_mac_t mac;
156 rtk_uint32 sa_block;
157 rtk_uint32 auth;
158 rtk_portmask_t portmask;
159 rtk_uint32 age;
160 rtk_uint32 ivl;
161 rtk_uint32 cvid;
162 rtk_uint32 fid;
163 rtk_uint32 is_ipmul;
164 rtk_uint32 is_static;
165 rtk_uint32 is_ipvidmul;
166 rtk_uint32 l3_vid;
167 }rtk_l2_addr_table_t;
168
169 typedef enum rtk_l2_clearStatus_e
170 {
171 L2_CLEAR_STATE_FINISH = 0,
172 L2_CLEAR_STATE_BUSY,
173 L2_CLEAR_STATE_END
174 }rtk_l2_clearStatus_t;
175
176 /* Function Name:
177 * rtk_l2_init
178 * Description:
179 * Initialize l2 module of the specified device.
180 * Input:
181 * None
182 * Output:
183 * None
184 * Return:
185 * RT_ERR_OK - OK
186 * RT_ERR_FAILED - Failed
187 * RT_ERR_SMI - SMI access error
188 * Note:
189 * Initialize l2 module before calling any l2 APIs.
190 */
191 extern rtk_api_ret_t rtk_l2_init(void);
192
193 /* Function Name:
194 * rtk_l2_addr_add
195 * Description:
196 * Add LUT unicast entry.
197 * Input:
198 * pMac - 6 bytes unicast(I/G bit is 0) mac address to be written into LUT.
199 * pL2_data - Unicast entry parameter
200 * Output:
201 * None
202 * Return:
203 * RT_ERR_OK - OK
204 * RT_ERR_FAILED - Failed
205 * RT_ERR_SMI - SMI access error
206 * RT_ERR_PORT_ID - Invalid port number.
207 * RT_ERR_MAC - Invalid MAC address.
208 * RT_ERR_L2_FID - Invalid FID .
209 * RT_ERR_L2_INDEXTBL_FULL - hashed index is full of entries.
210 * RT_ERR_INPUT - Invalid input parameters.
211 * Note:
212 * If the unicast mac address already existed in LUT, it will udpate the status of the entry.
213 * Otherwise, it will find an empty or asic auto learned entry to write. If all the entries
214 * with the same hash value can't be replaced, ASIC will return a RT_ERR_L2_INDEXTBL_FULL error.
215 */
216 extern rtk_api_ret_t rtk_l2_addr_add(rtk_mac_t *pMac, rtk_l2_ucastAddr_t *pL2_data);
217
218 /* Function Name:
219 * rtk_l2_addr_get
220 * Description:
221 * Get LUT unicast entry.
222 * Input:
223 * pMac - 6 bytes unicast(I/G bit is 0) mac address to be written into LUT.
224 * Output:
225 * pL2_data - Unicast entry parameter
226 * Return:
227 * RT_ERR_OK - OK
228 * RT_ERR_FAILED - Failed
229 * RT_ERR_SMI - SMI access error
230 * RT_ERR_PORT_ID - Invalid port number.
231 * RT_ERR_MAC - Invalid MAC address.
232 * RT_ERR_L2_FID - Invalid FID .
233 * RT_ERR_L2_ENTRY_NOTFOUND - No such LUT entry.
234 * RT_ERR_INPUT - Invalid input parameters.
235 * Note:
236 * If the unicast mac address existed in LUT, it will return the port and fid where
237 * the mac is learned. Otherwise, it will return a RT_ERR_L2_ENTRY_NOTFOUND error.
238 */
239 extern rtk_api_ret_t rtk_l2_addr_get(rtk_mac_t *pMac, rtk_l2_ucastAddr_t *pL2_data);
240
241 /* Function Name:
242 * rtk_l2_addr_next_get
243 * Description:
244 * Get Next LUT unicast entry.
245 * Input:
246 * read_method - The reading method.
247 * port - The port number if the read_metohd is READMETHOD_NEXT_L2UCSPA
248 * pAddress - The Address ID
249 * Output:
250 * pL2_data - Unicast entry parameter
251 * Return:
252 * RT_ERR_OK - OK
253 * RT_ERR_FAILED - Failed
254 * RT_ERR_SMI - SMI access error
255 * RT_ERR_PORT_ID - Invalid port number.
256 * RT_ERR_MAC - Invalid MAC address.
257 * RT_ERR_L2_FID - Invalid FID .
258 * RT_ERR_L2_ENTRY_NOTFOUND - No such LUT entry.
259 * RT_ERR_INPUT - Invalid input parameters.
260 * Note:
261 * Get the next unicast entry after the current entry pointed by pAddress.
262 * The address of next entry is returned by pAddress. User can use (address + 1)
263 * as pAddress to call this API again for dumping all entries is LUT.
264 */
265 extern rtk_api_ret_t rtk_l2_addr_next_get(rtk_l2_read_method_t read_method, rtk_port_t port, rtk_uint32 *pAddress, rtk_l2_ucastAddr_t *pL2_data);
266
267 /* Function Name:
268 * rtk_l2_addr_del
269 * Description:
270 * Delete LUT unicast entry.
271 * Input:
272 * pMac - 6 bytes unicast(I/G bit is 0) mac address to be written into LUT.
273 * fid - Filtering database
274 * Output:
275 * None
276 * Return:
277 * RT_ERR_OK - OK
278 * RT_ERR_FAILED - Failed
279 * RT_ERR_SMI - SMI access error
280 * RT_ERR_PORT_ID - Invalid port number.
281 * RT_ERR_MAC - Invalid MAC address.
282 * RT_ERR_L2_FID - Invalid FID .
283 * RT_ERR_L2_ENTRY_NOTFOUND - No such LUT entry.
284 * RT_ERR_INPUT - Invalid input parameters.
285 * Note:
286 * If the mac has existed in the LUT, it will be deleted. Otherwise, it will return RT_ERR_L2_ENTRY_NOTFOUND.
287 */
288 extern rtk_api_ret_t rtk_l2_addr_del(rtk_mac_t *pMac, rtk_l2_ucastAddr_t *pL2_data);
289
290 /* Function Name:
291 * rtk_l2_mcastAddr_add
292 * Description:
293 * Add LUT multicast entry.
294 * Input:
295 * pMcastAddr - L2 multicast entry structure
296 * Output:
297 * None
298 * Return:
299 * RT_ERR_OK - OK
300 * RT_ERR_FAILED - Failed
301 * RT_ERR_SMI - SMI access error
302 * RT_ERR_PORT_ID - Invalid port number.
303 * RT_ERR_MAC - Invalid MAC address.
304 * RT_ERR_L2_FID - Invalid FID .
305 * RT_ERR_L2_VID - Invalid VID .
306 * RT_ERR_L2_INDEXTBL_FULL - hashed index is full of entries.
307 * RT_ERR_PORT_MASK - Invalid portmask.
308 * RT_ERR_INPUT - Invalid input parameters.
309 * Note:
310 * If the multicast mac address already existed in the LUT, it will udpate the
311 * port mask of the entry. Otherwise, it will find an empty or asic auto learned
312 * entry to write. If all the entries with the same hash value can't be replaced,
313 * ASIC will return a RT_ERR_L2_INDEXTBL_FULL error.
314 */
315 extern rtk_api_ret_t rtk_l2_mcastAddr_add(rtk_l2_mcastAddr_t *pMcastAddr);
316
317 /* Function Name:
318 * rtk_l2_mcastAddr_get
319 * Description:
320 * Get LUT multicast entry.
321 * Input:
322 * pMcastAddr - L2 multicast entry structure
323 * Output:
324 * pMcastAddr - L2 multicast entry structure
325 * Return:
326 * RT_ERR_OK - OK
327 * RT_ERR_FAILED - Failed
328 * RT_ERR_SMI - SMI access error
329 * RT_ERR_MAC - Invalid MAC address.
330 * RT_ERR_L2_FID - Invalid FID .
331 * RT_ERR_L2_VID - Invalid VID .
332 * RT_ERR_L2_ENTRY_NOTFOUND - No such LUT entry.
333 * RT_ERR_INPUT - Invalid input parameters.
334 * Note:
335 * If the multicast mac address existed in the LUT, it will return the port where
336 * the mac is learned. Otherwise, it will return a RT_ERR_L2_ENTRY_NOTFOUND error.
337 */
338 extern rtk_api_ret_t rtk_l2_mcastAddr_get(rtk_l2_mcastAddr_t *pMcastAddr);
339
340 /* Function Name:
341 * rtk_l2_mcastAddr_next_get
342 * Description:
343 * Get Next L2 Multicast entry.
344 * Input:
345 * pAddress - The Address ID
346 * Output:
347 * pMcastAddr - L2 multicast entry structure
348 * Return:
349 * RT_ERR_OK - OK
350 * RT_ERR_FAILED - Failed
351 * RT_ERR_SMI - SMI access error
352 * RT_ERR_L2_ENTRY_NOTFOUND - No such LUT entry.
353 * RT_ERR_INPUT - Invalid input parameters.
354 * Note:
355 * Get the next L2 multicast entry after the current entry pointed by pAddress.
356 * The address of next entry is returned by pAddress. User can use (address + 1)
357 * as pAddress to call this API again for dumping all multicast entries is LUT.
358 */
359 extern rtk_api_ret_t rtk_l2_mcastAddr_next_get(rtk_uint32 *pAddress, rtk_l2_mcastAddr_t *pMcastAddr);
360
361 /* Function Name:
362 * rtk_l2_mcastAddr_del
363 * Description:
364 * Delete LUT multicast entry.
365 * Input:
366 * pMcastAddr - L2 multicast entry structure
367 * Output:
368 * None
369 * Return:
370 * RT_ERR_OK - OK
371 * RT_ERR_FAILED - Failed
372 * RT_ERR_SMI - SMI access error
373 * RT_ERR_MAC - Invalid MAC address.
374 * RT_ERR_L2_FID - Invalid FID .
375 * RT_ERR_L2_VID - Invalid VID .
376 * RT_ERR_L2_ENTRY_NOTFOUND - No such LUT entry.
377 * RT_ERR_INPUT - Invalid input parameters.
378 * Note:
379 * If the mac has existed in the LUT, it will be deleted. Otherwise, it will return RT_ERR_L2_ENTRY_NOTFOUND.
380 */
381 extern rtk_api_ret_t rtk_l2_mcastAddr_del(rtk_l2_mcastAddr_t *pMcastAddr);
382
383 /* Function Name:
384 * rtk_l2_ipMcastAddr_add
385 * Description:
386 * Add Lut IP multicast entry
387 * Input:
388 * pIpMcastAddr - IP Multicast entry
389 * Output:
390 * None
391 * Return:
392 * RT_ERR_OK - OK
393 * RT_ERR_FAILED - Failed
394 * RT_ERR_SMI - SMI access error
395 * RT_ERR_PORT_ID - Invalid port number.
396 * RT_ERR_L2_INDEXTBL_FULL - hashed index is full of entries.
397 * RT_ERR_PORT_MASK - Invalid portmask.
398 * RT_ERR_INPUT - Invalid input parameters.
399 * Note:
400 * System supports L2 entry with IP multicast DIP/SIP to forward IP multicasting frame as user
401 * desired. If this function is enabled, then system will be looked up L2 IP multicast entry to
402 * forward IP multicast frame directly without flooding.
403 */
404 extern rtk_api_ret_t rtk_l2_ipMcastAddr_add(rtk_l2_ipMcastAddr_t *pIpMcastAddr);
405
406 /* Function Name:
407 * rtk_l2_ipMcastAddr_get
408 * Description:
409 * Get LUT IP multicast entry.
410 * Input:
411 * pIpMcastAddr - IP Multicast entry
412 * Output:
413 * pIpMcastAddr - IP Multicast entry
414 * Return:
415 * RT_ERR_OK - OK
416 * RT_ERR_FAILED - Failed
417 * RT_ERR_SMI - SMI access error
418 * RT_ERR_L2_ENTRY_NOTFOUND - No such LUT entry.
419 * RT_ERR_INPUT - Invalid input parameters.
420 * Note:
421 * The API can get Lut table of IP multicast entry.
422 */
423 extern rtk_api_ret_t rtk_l2_ipMcastAddr_get(rtk_l2_ipMcastAddr_t *pIpMcastAddr);
424
425 /* Function Name:
426 * rtk_l2_ipMcastAddr_next_get
427 * Description:
428 * Get Next IP Multicast entry.
429 * Input:
430 * pAddress - The Address ID
431 * Output:
432 * pIpMcastAddr - IP Multicast entry
433 * Return:
434 * RT_ERR_OK - OK
435 * RT_ERR_FAILED - Failed
436 * RT_ERR_SMI - SMI access error
437 * RT_ERR_L2_ENTRY_NOTFOUND - No such LUT entry.
438 * RT_ERR_INPUT - Invalid input parameters.
439 * Note:
440 * Get the next IP multicast entry after the current entry pointed by pAddress.
441 * The address of next entry is returned by pAddress. User can use (address + 1)
442 * as pAddress to call this API again for dumping all IP multicast entries is LUT.
443 */
444 extern rtk_api_ret_t rtk_l2_ipMcastAddr_next_get(rtk_uint32 *pAddress, rtk_l2_ipMcastAddr_t *pIpMcastAddr);
445
446 /* Function Name:
447 * rtk_l2_ipMcastAddr_del
448 * Description:
449 * Delete a ip multicast address entry from the specified device.
450 * Input:
451 * pIpMcastAddr - IP Multicast entry
452 * Output:
453 * None
454 * Return:
455 * RT_ERR_OK - OK
456 * RT_ERR_FAILED - Failed
457 * RT_ERR_SMI - SMI access error
458 * RT_ERR_L2_ENTRY_NOTFOUND - No such LUT entry.
459 * RT_ERR_INPUT - Invalid input parameters.
460 * Note:
461 * The API can delete a IP multicast address entry from the specified device.
462 */
463 extern rtk_api_ret_t rtk_l2_ipMcastAddr_del(rtk_l2_ipMcastAddr_t *pIpMcastAddr);
464
465 /* Function Name:
466 * rtk_l2_ipVidMcastAddr_add
467 * Description:
468 * Add Lut IP multicast+VID entry
469 * Input:
470 * pIpVidMcastAddr - IP & VID multicast Entry
471 * Output:
472 * None
473 * Return:
474 * RT_ERR_OK - OK
475 * RT_ERR_FAILED - Failed
476 * RT_ERR_SMI - SMI access error
477 * RT_ERR_PORT_ID - Invalid port number.
478 * RT_ERR_L2_INDEXTBL_FULL - hashed index is full of entries.
479 * RT_ERR_PORT_MASK - Invalid portmask.
480 * RT_ERR_INPUT - Invalid input parameters.
481 * Note:
482 *
483 */
484 extern rtk_api_ret_t rtk_l2_ipVidMcastAddr_add(rtk_l2_ipVidMcastAddr_t *pIpVidMcastAddr);
485
486 /* Function Name:
487 * rtk_l2_ipVidMcastAddr_get
488 * Description:
489 * Get LUT IP multicast+VID entry.
490 * Input:
491 * pIpVidMcastAddr - IP & VID multicast Entry
492 * Output:
493 * pIpVidMcastAddr - IP & VID multicast Entry
494 * Return:
495 * RT_ERR_OK - OK
496 * RT_ERR_FAILED - Failed
497 * RT_ERR_SMI - SMI access error
498 * RT_ERR_L2_ENTRY_NOTFOUND - No such LUT entry.
499 * RT_ERR_INPUT - Invalid input parameters.
500 * Note:
501 *
502 */
503 extern rtk_api_ret_t rtk_l2_ipVidMcastAddr_get(rtk_l2_ipVidMcastAddr_t *pIpVidMcastAddr);
504
505 /* Function Name:
506 * rtk_l2_ipVidMcastAddr_next_get
507 * Description:
508 * Get Next IP Multicast+VID entry.
509 * Input:
510 * pAddress - The Address ID
511 * Output:
512 * pIpVidMcastAddr - IP & VID multicast Entry
513 * Return:
514 * RT_ERR_OK - OK
515 * RT_ERR_FAILED - Failed
516 * RT_ERR_SMI - SMI access error
517 * RT_ERR_L2_ENTRY_NOTFOUND - No such LUT entry.
518 * RT_ERR_INPUT - Invalid input parameters.
519 * Note:
520 * Get the next IP multicast entry after the current entry pointed by pAddress.
521 * The address of next entry is returned by pAddress. User can use (address + 1)
522 * as pAddress to call this API again for dumping all IP multicast entries is LUT.
523 */
524 extern rtk_api_ret_t rtk_l2_ipVidMcastAddr_next_get(rtk_uint32 *pAddress, rtk_l2_ipVidMcastAddr_t *pIpVidMcastAddr);
525
526 /* Function Name:
527 * rtk_l2_ipVidMcastAddr_del
528 * Description:
529 * Delete a ip multicast+VID address entry from the specified device.
530 * Input:
531 * pIpVidMcastAddr - IP & VID multicast Entry
532 * Output:
533 * None
534 * Return:
535 * RT_ERR_OK - OK
536 * RT_ERR_FAILED - Failed
537 * RT_ERR_SMI - SMI access error
538 * RT_ERR_L2_ENTRY_NOTFOUND - No such LUT entry.
539 * RT_ERR_INPUT - Invalid input parameters.
540 * Note:
541 *
542 */
543 extern rtk_api_ret_t rtk_l2_ipVidMcastAddr_del(rtk_l2_ipVidMcastAddr_t *pIpVidMcastAddr);
544
545 /* Function Name:
546 * rtk_l2_ucastAddr_flush
547 * Description:
548 * Flush L2 mac address by type in the specified device (both dynamic and static).
549 * Input:
550 * pConfig - flush configuration
551 * Output:
552 * None
553 * Return:
554 * RT_ERR_OK - OK
555 * RT_ERR_FAILED - Failed
556 * RT_ERR_SMI - SMI access error
557 * RT_ERR_PORT_ID - Invalid port number.
558 * RT_ERR_VLAN_VID - Invalid VID parameter.
559 * RT_ERR_INPUT - Invalid input parameters.
560 * Note:
561 * flushByVid - 1: Flush by VID, 0: Don't flush by VID
562 * vid - VID (0 ~ 4095)
563 * flushByFid - 1: Flush by FID, 0: Don't flush by FID
564 * fid - FID (0 ~ 15)
565 * flushByPort - 1: Flush by Port, 0: Don't flush by Port
566 * port - Port ID
567 * flushByMac - Not Supported
568 * ucastAddr - Not Supported
569 * flushStaticAddr - 1: Flush both Static and Dynamic entries, 0: Flush only Dynamic entries
570 * flushAddrOnAllPorts - 1: Flush VID-matched entries at all ports, 0: Flush VID-matched entries per port.
571 */
572 extern rtk_api_ret_t rtk_l2_ucastAddr_flush(rtk_l2_flushCfg_t *pConfig);
573
574 /* Function Name:
575 * rtk_l2_table_clear
576 * Description:
577 * Flush all static & dynamic entries in LUT.
578 * Input:
579 * None
580 * Output:
581 * None
582 * Return:
583 * RT_ERR_OK - OK
584 * RT_ERR_FAILED - Failed
585 * RT_ERR_SMI - SMI access error
586 * Note:
587 *
588 */
589 extern rtk_api_ret_t rtk_l2_table_clear(void);
590
591 /* Function Name:
592 * rtk_l2_table_clearStatus_get
593 * Description:
594 * Get table clear status
595 * Input:
596 * None
597 * Output:
598 * pStatus - Clear status, 1:Busy, 0:finish
599 * Return:
600 * RT_ERR_OK - OK
601 * RT_ERR_FAILED - Failed
602 * RT_ERR_SMI - SMI access error
603 * Note:
604 *
605 */
606 extern rtk_api_ret_t rtk_l2_table_clearStatus_get(rtk_l2_clearStatus_t *pStatus);
607
608 /* Function Name:
609 * rtk_l2_flushLinkDownPortAddrEnable_set
610 * Description:
611 * Set HW flush linkdown port mac configuration of the specified device.
612 * Input:
613 * port - Port id.
614 * enable - link down flush status
615 * Output:
616 * None
617 * Return:
618 * RT_ERR_OK - OK
619 * RT_ERR_FAILED - Failed
620 * RT_ERR_SMI - SMI access error
621 * RT_ERR_PORT_ID - Invalid port number.
622 * RT_ERR_ENABLE - Invalid enable input.
623 * Note:
624 * The status of flush linkdown port address is as following:
625 * - DISABLED
626 * - ENABLED
627 */
628 extern rtk_api_ret_t rtk_l2_flushLinkDownPortAddrEnable_set(rtk_port_t port, rtk_enable_t enable);
629
630 /* Function Name:
631 * rtk_l2_flushLinkDownPortAddrEnable_get
632 * Description:
633 * Get HW flush linkdown port mac configuration of the specified device.
634 * Input:
635 * port - Port id.
636 * Output:
637 * pEnable - link down flush status
638 * Return:
639 * RT_ERR_OK - OK
640 * RT_ERR_FAILED - Failed
641 * RT_ERR_SMI - SMI access error
642 * RT_ERR_PORT_ID - Invalid port number.
643 * Note:
644 * The status of flush linkdown port address is as following:
645 * - DISABLED
646 * - ENABLED
647 */
648 extern rtk_api_ret_t rtk_l2_flushLinkDownPortAddrEnable_get(rtk_port_t port, rtk_enable_t *pEnable);
649
650 /* Function Name:
651 * rtk_l2_agingEnable_set
652 * Description:
653 * Set L2 LUT aging status per port setting.
654 * Input:
655 * port - Port id.
656 * enable - Aging status
657 * Output:
658 * None
659 * Return:
660 * RT_ERR_OK - OK
661 * RT_ERR_FAILED - Failed
662 * RT_ERR_SMI - SMI access error
663 * RT_ERR_PORT_ID - Invalid port number.
664 * RT_ERR_ENABLE - Invalid enable input.
665 * Note:
666 * This API can be used to set L2 LUT aging status per port.
667 */
668 extern rtk_api_ret_t rtk_l2_agingEnable_set(rtk_port_t port, rtk_enable_t enable);
669
670 /* Function Name:
671 * rtk_l2_agingEnable_get
672 * Description:
673 * Get L2 LUT aging status per port setting.
674 * Input:
675 * port - Port id.
676 * Output:
677 * pEnable - Aging status
678 * Return:
679 * RT_ERR_OK - OK
680 * RT_ERR_FAILED - Failed
681 * RT_ERR_SMI - SMI access error
682 * RT_ERR_PORT_ID - Invalid port number.
683 * Note:
684 * This API can be used to get L2 LUT aging function per port.
685 */
686 extern rtk_api_ret_t rtk_l2_agingEnable_get(rtk_port_t port, rtk_enable_t *pEnable);
687
688 /* Function Name:
689 * rtk_l2_limitLearningCnt_set
690 * Description:
691 * Set per-Port auto learning limit number
692 * Input:
693 * port - Port id.
694 * mac_cnt - Auto learning entries limit number
695 * Output:
696 * None
697 * Return:
698 * RT_ERR_OK - OK
699 * RT_ERR_FAILED - Failed
700 * RT_ERR_SMI - SMI access error
701 * RT_ERR_PORT_ID - Invalid port number.
702 * RT_ERR_LIMITED_L2ENTRY_NUM - Invalid auto learning limit number
703 * Note:
704 * The API can set per-port ASIC auto learning limit number from 0(disable learning)
705 * to 8k.
706 */
707 extern rtk_api_ret_t rtk_l2_limitLearningCnt_set(rtk_port_t port, rtk_mac_cnt_t mac_cnt);
708
709 /* Function Name:
710 * rtk_l2_limitLearningCnt_get
711 * Description:
712 * Get per-Port auto learning limit number
713 * Input:
714 * port - Port id.
715 * Output:
716 * pMac_cnt - Auto learning entries limit number
717 * Return:
718 * RT_ERR_OK - OK
719 * RT_ERR_FAILED - Failed
720 * RT_ERR_SMI - SMI access error
721 * RT_ERR_PORT_ID - Invalid port number.
722 * Note:
723 * The API can get per-port ASIC auto learning limit number.
724 */
725 extern rtk_api_ret_t rtk_l2_limitLearningCnt_get(rtk_port_t port, rtk_mac_cnt_t *pMac_cnt);
726
727 /* Function Name:
728 * rtk_l2_limitSystemLearningCnt_set
729 * Description:
730 * Set System auto learning limit number
731 * Input:
732 * mac_cnt - Auto learning entries limit number
733 * Output:
734 * None
735 * Return:
736 * RT_ERR_OK - OK
737 * RT_ERR_FAILED - Failed
738 * RT_ERR_SMI - SMI access error
739 * RT_ERR_LIMITED_L2ENTRY_NUM - Invalid auto learning limit number
740 * Note:
741 * The API can set system ASIC auto learning limit number from 0(disable learning)
742 * to 2112.
743 */
744 extern rtk_api_ret_t rtk_l2_limitSystemLearningCnt_set(rtk_mac_cnt_t mac_cnt);
745
746 /* Function Name:
747 * rtk_l2_limitSystemLearningCnt_get
748 * Description:
749 * Get System auto learning limit number
750 * Input:
751 * None
752 * Output:
753 * pMac_cnt - Auto learning entries limit number
754 * Return:
755 * RT_ERR_OK - OK
756 * RT_ERR_FAILED - Failed
757 * RT_ERR_SMI - SMI access error
758 * RT_ERR_PORT_ID - Invalid port number.
759 * Note:
760 * The API can get system ASIC auto learning limit number.
761 */
762 extern rtk_api_ret_t rtk_l2_limitSystemLearningCnt_get(rtk_mac_cnt_t *pMac_cnt);
763
764 /* Function Name:
765 * rtk_l2_limitLearningCntAction_set
766 * Description:
767 * Configure auto learn over limit number action.
768 * Input:
769 * port - Port id.
770 * action - Auto learning entries limit number
771 * Output:
772 * None
773 * Return:
774 * RT_ERR_OK - OK
775 * RT_ERR_FAILED - Failed
776 * RT_ERR_SMI - SMI access error
777 * RT_ERR_PORT_ID - Invalid port number.
778 * RT_ERR_NOT_ALLOWED - Invalid learn over action
779 * Note:
780 * The API can set SA unknown packet action while auto learn limit number is over
781 * The action symbol as following:
782 * - LIMIT_LEARN_CNT_ACTION_DROP,
783 * - LIMIT_LEARN_CNT_ACTION_FORWARD,
784 * - LIMIT_LEARN_CNT_ACTION_TO_CPU,
785 */
786 extern rtk_api_ret_t rtk_l2_limitLearningCntAction_set(rtk_port_t port, rtk_l2_limitLearnCntAction_t action);
787
788 /* Function Name:
789 * rtk_l2_limitLearningCntAction_get
790 * Description:
791 * Get auto learn over limit number action.
792 * Input:
793 * port - Port id.
794 * Output:
795 * pAction - Learn over action
796 * Return:
797 * RT_ERR_OK - OK
798 * RT_ERR_FAILED - Failed
799 * RT_ERR_SMI - SMI access error
800 * RT_ERR_PORT_ID - Invalid port number.
801 * Note:
802 * The API can get SA unknown packet action while auto learn limit number is over
803 * The action symbol as following:
804 * - LIMIT_LEARN_CNT_ACTION_DROP,
805 * - LIMIT_LEARN_CNT_ACTION_FORWARD,
806 * - LIMIT_LEARN_CNT_ACTION_TO_CPU,
807 */
808 extern rtk_api_ret_t rtk_l2_limitLearningCntAction_get(rtk_port_t port, rtk_l2_limitLearnCntAction_t *pAction);
809
810 /* Function Name:
811 * rtk_l2_limitSystemLearningCntAction_set
812 * Description:
813 * Configure system auto learn over limit number action.
814 * Input:
815 * port - Port id.
816 * action - Auto learning entries limit number
817 * Output:
818 * None
819 * Return:
820 * RT_ERR_OK - OK
821 * RT_ERR_FAILED - Failed
822 * RT_ERR_SMI - SMI access error
823 * RT_ERR_PORT_ID - Invalid port number.
824 * RT_ERR_NOT_ALLOWED - Invalid learn over action
825 * Note:
826 * The API can set SA unknown packet action while auto learn limit number is over
827 * The action symbol as following:
828 * - LIMIT_LEARN_CNT_ACTION_DROP,
829 * - LIMIT_LEARN_CNT_ACTION_FORWARD,
830 * - LIMIT_LEARN_CNT_ACTION_TO_CPU,
831 */
832 extern rtk_api_ret_t rtk_l2_limitSystemLearningCntAction_set(rtk_l2_limitLearnCntAction_t action);
833
834 /* Function Name:
835 * rtk_l2_limitSystemLearningCntAction_get
836 * Description:
837 * Get system auto learn over limit number action.
838 * Input:
839 * None.
840 * Output:
841 * pAction - Learn over action
842 * Return:
843 * RT_ERR_OK - OK
844 * RT_ERR_FAILED - Failed
845 * RT_ERR_SMI - SMI access error
846 * RT_ERR_PORT_ID - Invalid port number.
847 * Note:
848 * The API can get SA unknown packet action while auto learn limit number is over
849 * The action symbol as following:
850 * - LIMIT_LEARN_CNT_ACTION_DROP,
851 * - LIMIT_LEARN_CNT_ACTION_FORWARD,
852 * - LIMIT_LEARN_CNT_ACTION_TO_CPU,
853 */
854 extern rtk_api_ret_t rtk_l2_limitSystemLearningCntAction_get(rtk_l2_limitLearnCntAction_t *pAction);
855
856 /* Function Name:
857 * rtk_l2_limitSystemLearningCntPortMask_set
858 * Description:
859 * Configure system auto learn portmask
860 * Input:
861 * pPortmask - Port Mask
862 * Output:
863 * None
864 * Return:
865 * RT_ERR_OK - OK
866 * RT_ERR_FAILED - Failed
867 * RT_ERR_SMI - SMI access error
868 * RT_ERR_PORT_MASK - Invalid port mask.
869 * Note:
870 *
871 */
872 extern rtk_api_ret_t rtk_l2_limitSystemLearningCntPortMask_set(rtk_portmask_t *pPortmask);
873
874 /* Function Name:
875 * rtk_l2_limitSystemLearningCntPortMask_get
876 * Description:
877 * get system auto learn portmask
878 * Input:
879 * None
880 * Output:
881 * pPortmask - Port Mask
882 * Return:
883 * RT_ERR_OK - OK
884 * RT_ERR_FAILED - Failed
885 * RT_ERR_SMI - SMI access error
886 * RT_ERR_NULL_POINTER - Null pointer.
887 * Note:
888 *
889 */
890 extern rtk_api_ret_t rtk_l2_limitSystemLearningCntPortMask_get(rtk_portmask_t *pPortmask);
891
892 /* Function Name:
893 * rtk_l2_learningCnt_get
894 * Description:
895 * Get per-Port current auto learning number
896 * Input:
897 * port - Port id.
898 * Output:
899 * pMac_cnt - ASIC auto learning entries number
900 * Return:
901 * RT_ERR_OK - OK
902 * RT_ERR_FAILED - Failed
903 * RT_ERR_SMI - SMI access error
904 * RT_ERR_PORT_ID - Invalid port number.
905 * Note:
906 * The API can get per-port ASIC auto learning number
907 */
908 extern rtk_api_ret_t rtk_l2_learningCnt_get(rtk_port_t port, rtk_mac_cnt_t *pMac_cnt);
909
910 /* Function Name:
911 * rtk_l2_floodPortMask_set
912 * Description:
913 * Set flooding portmask
914 * Input:
915 * type - flooding type.
916 * pFlood_portmask - flooding porkmask
917 * Output:
918 * None
919 * Return:
920 * RT_ERR_OK - OK
921 * RT_ERR_FAILED - Failed
922 * RT_ERR_SMI - SMI access error
923 * RT_ERR_PORT_MASK - Invalid portmask.
924 * RT_ERR_INPUT - Invalid input parameters.
925 * Note:
926 * This API can set the flooding mask.
927 * The flooding type is as following:
928 * - FLOOD_UNKNOWNDA
929 * - FLOOD_UNKNOWNMC
930 * - FLOOD_BC
931 */
932 extern rtk_api_ret_t rtk_l2_floodPortMask_set(rtk_l2_flood_type_t floood_type, rtk_portmask_t *pFlood_portmask);
933
934 /* Function Name:
935 * rtk_l2_floodPortMask_get
936 * Description:
937 * Get flooding portmask
938 * Input:
939 * type - flooding type.
940 * Output:
941 * pFlood_portmask - flooding porkmask
942 * Return:
943 * RT_ERR_OK - OK
944 * RT_ERR_FAILED - Failed
945 * RT_ERR_SMI - SMI access error
946 * RT_ERR_PORT_ID - Invalid port number.
947 * Note:
948 * This API can get the flooding mask.
949 * The flooding type is as following:
950 * - FLOOD_UNKNOWNDA
951 * - FLOOD_UNKNOWNMC
952 * - FLOOD_BC
953 */
954 extern rtk_api_ret_t rtk_l2_floodPortMask_get(rtk_l2_flood_type_t floood_type, rtk_portmask_t *pFlood_portmask);
955
956 /* Function Name:
957 * rtk_l2_localPktPermit_set
958 * Description:
959 * Set permittion of frames if source port and destination port are the same.
960 * Input:
961 * port - Port id.
962 * permit - permittion status
963 * Output:
964 * None
965 * Return:
966 * RT_ERR_OK - OK
967 * RT_ERR_FAILED - Failed
968 * RT_ERR_SMI - SMI access error
969 * RT_ERR_PORT_ID - Invalid port number.
970 * RT_ERR_ENABLE - Invalid permit value.
971 * Note:
972 * This API is setted to permit frame if its source port is equal to destination port.
973 */
974 extern rtk_api_ret_t rtk_l2_localPktPermit_set(rtk_port_t port, rtk_enable_t permit);
975
976 /* Function Name:
977 * rtk_l2_localPktPermit_get
978 * Description:
979 * Get permittion of frames if source port and destination port are the same.
980 * Input:
981 * port - Port id.
982 * Output:
983 * pPermit - permittion status
984 * Return:
985 * RT_ERR_OK - OK
986 * RT_ERR_FAILED - Failed
987 * RT_ERR_SMI - SMI access error
988 * RT_ERR_PORT_ID - Invalid port number.
989 * Note:
990 * This API is to get permittion status for frames if its source port is equal to destination port.
991 */
992 extern rtk_api_ret_t rtk_l2_localPktPermit_get(rtk_port_t port, rtk_enable_t *pPermit);
993
994 /* Function Name:
995 * rtk_l2_aging_set
996 * Description:
997 * Set LUT agging out speed
998 * Input:
999 * aging_time - Agging out time.
1000 * Output:
1001 * None
1002 * Return:
1003 * RT_ERR_OK - OK
1004 * RT_ERR_FAILED - Failed
1005 * RT_ERR_SMI - SMI access error
1006 * RT_ERR_OUT_OF_RANGE - input out of range.
1007 * Note:
1008 * The API can set LUT agging out period for each entry and the range is from 14s to 800s.
1009 */
1010 extern rtk_api_ret_t rtk_l2_aging_set(rtk_l2_age_time_t aging_time);
1011
1012 /* Function Name:
1013 * rtk_l2_aging_get
1014 * Description:
1015 * Get LUT agging out time
1016 * Input:
1017 * None
1018 * Output:
1019 * pEnable - Aging status
1020 * Return:
1021 * RT_ERR_OK - OK
1022 * RT_ERR_FAILED - Failed
1023 * RT_ERR_SMI - SMI access error
1024 * RT_ERR_PORT_ID - Invalid port number.
1025 * Note:
1026 * The API can get LUT agging out period for each entry.
1027 */
1028 extern rtk_api_ret_t rtk_l2_aging_get(rtk_l2_age_time_t *pAging_time);
1029
1030 /* Function Name:
1031 * rtk_l2_ipMcastAddrLookup_set
1032 * Description:
1033 * Set Lut IP multicast lookup function
1034 * Input:
1035 * type - Lookup type for IPMC packet.
1036 * Output:
1037 * None.
1038 * Return:
1039 * RT_ERR_OK - OK
1040 * RT_ERR_FAILED - Failed
1041 * RT_ERR_SMI - SMI access error
1042 * Note:
1043 * This API can work with rtk_l2_ipMcastAddrLookupException_add.
1044 * If users set the lookup type to DIP, the group in exception table
1045 * will be lookup by DIP+SIP
1046 * If users set the lookup type to DIP+SIP, the group in exception table
1047 * will be lookup by only DIP
1048 */
1049 extern rtk_api_ret_t rtk_l2_ipMcastAddrLookup_set(rtk_l2_ipmc_lookup_type_t type);
1050
1051 /* Function Name:
1052 * rtk_l2_ipMcastAddrLookup_get
1053 * Description:
1054 * Get Lut IP multicast lookup function
1055 * Input:
1056 * None.
1057 * Output:
1058 * pType - Lookup type for IPMC packet.
1059 * Return:
1060 * RT_ERR_OK - OK
1061 * RT_ERR_FAILED - Failed
1062 * RT_ERR_SMI - SMI access error
1063 * Note:
1064 * None.
1065 */
1066 extern rtk_api_ret_t rtk_l2_ipMcastAddrLookup_get(rtk_l2_ipmc_lookup_type_t *pType);
1067
1068 /* Function Name:
1069 * rtk_l2_ipMcastForwardRouterPort_set
1070 * Description:
1071 * Set IPMC packet forward to rounter port also or not
1072 * Input:
1073 * enabled - 1: Inlcude router port, 0, exclude router port
1074 * Output:
1075 * None.
1076 * Return:
1077 * RT_ERR_OK - OK
1078 * RT_ERR_FAILED - Failed
1079 * RT_ERR_SMI - SMI access error
1080 * Note:
1081 *
1082 */
1083 extern rtk_api_ret_t rtk_l2_ipMcastForwardRouterPort_set(rtk_enable_t enabled);
1084
1085 /* Function Name:
1086 * rtk_l2_ipMcastForwardRouterPort_get
1087 * Description:
1088 * Get IPMC packet forward to rounter port also or not
1089 * Input:
1090 * None.
1091 * Output:
1092 * pEnabled - 1: Inlcude router port, 0, exclude router port
1093 * Return:
1094 * RT_ERR_OK - OK
1095 * RT_ERR_FAILED - Failed
1096 * RT_ERR_NULL_POINTER - Null pointer
1097 * Note:
1098 *
1099 */
1100 extern rtk_api_ret_t rtk_l2_ipMcastForwardRouterPort_get(rtk_enable_t *pEnabled);
1101
1102 /* Function Name:
1103 * rtk_l2_ipMcastGroupEntry_add
1104 * Description:
1105 * Add an IP Multicast entry to group table
1106 * Input:
1107 * ip_addr - IP address
1108 * vid - VLAN ID
1109 * pPortmask - portmask
1110 * Output:
1111 * None.
1112 * Return:
1113 * RT_ERR_OK - OK
1114 * RT_ERR_FAILED - Failed
1115 * RT_ERR_SMI - SMI access error
1116 * RT_ERR_TBL_FULL - Table Full
1117 * Note:
1118 * Add an entry to IP Multicast Group table.
1119 */
1120 extern rtk_api_ret_t rtk_l2_ipMcastGroupEntry_add(ipaddr_t ip_addr, rtk_uint32 vid, rtk_portmask_t *pPortmask);
1121
1122 /* Function Name:
1123 * rtk_l2_ipMcastGroupEntry_del
1124 * Description:
1125 * Delete an entry from IP Multicast group table
1126 * Input:
1127 * ip_addr - IP address
1128 * vid - VLAN ID
1129 * Output:
1130 * None.
1131 * Return:
1132 * RT_ERR_OK - OK
1133 * RT_ERR_FAILED - Failed
1134 * RT_ERR_SMI - SMI access error
1135 * RT_ERR_TBL_FULL - Table Full
1136 * Note:
1137 * Delete an entry from IP Multicast group table.
1138 */
1139 extern rtk_api_ret_t rtk_l2_ipMcastGroupEntry_del(ipaddr_t ip_addr, rtk_uint32 vid);
1140
1141 /* Function Name:
1142 * rtk_l2_ipMcastGroupEntry_get
1143 * Description:
1144 * get an entry from IP Multicast group table
1145 * Input:
1146 * ip_addr - IP address
1147 * vid - VLAN ID
1148 * Output:
1149 * pPortmask - member port mask
1150 * Return:
1151 * RT_ERR_OK - OK
1152 * RT_ERR_FAILED - Failed
1153 * RT_ERR_SMI - SMI access error
1154 * RT_ERR_TBL_FULL - Table Full
1155 * Note:
1156 * Delete an entry from IP Multicast group table.
1157 */
1158 extern rtk_api_ret_t rtk_l2_ipMcastGroupEntry_get(ipaddr_t ip_addr, rtk_uint32 vid, rtk_portmask_t *pPortmask);
1159
1160 /* Function Name:
1161 * rtk_l2_entry_get
1162 * Description:
1163 * Get LUT unicast entry.
1164 * Input:
1165 * pL2_entry - Index field in the structure.
1166 * Output:
1167 * pL2_entry - other fields such as MAC, port, age...
1168 * Return:
1169 * RT_ERR_OK - OK
1170 * RT_ERR_FAILED - Failed
1171 * RT_ERR_SMI - SMI access error
1172 * RT_ERR_L2_EMPTY_ENTRY - Empty LUT entry.
1173 * RT_ERR_INPUT - Invalid input parameters.
1174 * Note:
1175 * This API is used to get address by index from 0~2111.
1176 */
1177 extern rtk_api_ret_t rtk_l2_entry_get(rtk_l2_addr_table_t *pL2_entry);
1178
1179
1180 #endif /* __RTK_API_L2_H__ */
1181