2 * Copyright (C) 2013 Realtek Semiconductor Corp.
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
10 * Purpose : RTL8367/RTL8367C switch high-level API
12 * Feature : The file includes L2 module high-layer API defination
16 #ifndef __RTK_API_L2_H__
17 #define __RTK_API_L2_H__
21 * Data Type Declaration
23 #define RTK_MAX_NUM_OF_LEARN_LIMIT (rtk_switch_maxLutAddrNumber_get())
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)
29 typedef rtk_uint32 rtk_l2_age_time_t
;
31 typedef enum rtk_l2_flood_type_e
37 } rtk_l2_flood_type_t
;
39 typedef rtk_uint32 rtk_l2_flushItem_t
;
41 typedef enum rtk_l2_flushType_e
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 */
49 typedef struct rtk_l2_flushCfg_s
51 rtk_enable_t flushByVid
;
53 rtk_enable_t flushByFid
;
55 rtk_enable_t flushByPort
;
57 rtk_enable_t flushByMac
;
59 rtk_enable_t flushStaticAddr
;
60 rtk_enable_t flushAddrOnAllPorts
; /* this is used when flushByVid */
63 typedef enum rtk_l2_read_method_e
{
67 READMETHOD_NEXT_ADDRESS
,
71 READMETHOD_NEXT_L2L3MC
,
72 READMETHOD_NEXT_L2UCSPA
,
74 }rtk_l2_read_method_t
;
76 /* l2 limit learning count action */
77 typedef enum rtk_l2_limitLearnCntAction_e
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
;
85 typedef enum rtk_l2_ipmc_lookup_type_e
91 } rtk_l2_ipmc_lookup_type_t
;
93 /* l2 address table - unicast data structure */
94 typedef struct rtk_l2_ucastAddr_s
105 rtk_uint32 is_static
;
107 rtk_uint32 sa_pri_en
;
108 rtk_uint32 fwd_pri_en
;
112 /* l2 address table - multicast data structure */
113 typedef struct rtk_l2_mcastAddr_s
118 rtk_portmask_t portmask
;
121 rtk_uint32 fwd_pri_en
;
122 rtk_uint32 igmp_asic
;
123 rtk_uint32 igmp_index
;
127 /* l2 address table - ip multicast data structure */
128 typedef struct rtk_l2_ipMcastAddr_s
132 rtk_portmask_t portmask
;
134 rtk_uint32 fwd_pri_en
;
135 rtk_uint32 igmp_asic
;
136 rtk_uint32 igmp_index
;
138 }rtk_l2_ipMcastAddr_t
;
140 /* l2 address table - ip VID multicast data structure */
141 typedef struct rtk_l2_ipVidMcastAddr_s
146 rtk_portmask_t portmask
;
148 }rtk_l2_ipVidMcastAddr_t
;
150 typedef struct rtk_l2_addr_table_s
158 rtk_portmask_t portmask
;
164 rtk_uint32 is_static
;
165 rtk_uint32 is_ipvidmul
;
167 }rtk_l2_addr_table_t
;
169 typedef enum rtk_l2_clearStatus_e
171 L2_CLEAR_STATE_FINISH
= 0,
174 }rtk_l2_clearStatus_t
;
179 * Initialize l2 module of the specified device.
186 * RT_ERR_FAILED - Failed
187 * RT_ERR_SMI - SMI access error
189 * Initialize l2 module before calling any l2 APIs.
191 extern rtk_api_ret_t
rtk_l2_init(void);
196 * Add LUT unicast entry.
198 * pMac - 6 bytes unicast(I/G bit is 0) mac address to be written into LUT.
199 * pL2_data - Unicast entry parameter
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.
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.
216 extern rtk_api_ret_t
rtk_l2_addr_add(rtk_mac_t
*pMac
, rtk_l2_ucastAddr_t
*pL2_data
);
221 * Get LUT unicast entry.
223 * pMac - 6 bytes unicast(I/G bit is 0) mac address to be written into LUT.
225 * pL2_data - Unicast entry parameter
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.
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.
239 extern rtk_api_ret_t
rtk_l2_addr_get(rtk_mac_t
*pMac
, rtk_l2_ucastAddr_t
*pL2_data
);
242 * rtk_l2_addr_next_get
244 * Get Next LUT unicast entry.
246 * read_method - The reading method.
247 * port - The port number if the read_metohd is READMETHOD_NEXT_L2UCSPA
248 * pAddress - The Address ID
250 * pL2_data - Unicast entry parameter
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.
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.
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
);
270 * Delete LUT unicast entry.
272 * pMac - 6 bytes unicast(I/G bit is 0) mac address to be written into LUT.
273 * fid - Filtering database
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.
286 * If the mac has existed in the LUT, it will be deleted. Otherwise, it will return RT_ERR_L2_ENTRY_NOTFOUND.
288 extern rtk_api_ret_t
rtk_l2_addr_del(rtk_mac_t
*pMac
, rtk_l2_ucastAddr_t
*pL2_data
);
291 * rtk_l2_mcastAddr_add
293 * Add LUT multicast entry.
295 * pMcastAddr - L2 multicast entry structure
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.
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.
315 extern rtk_api_ret_t
rtk_l2_mcastAddr_add(rtk_l2_mcastAddr_t
*pMcastAddr
);
318 * rtk_l2_mcastAddr_get
320 * Get LUT multicast entry.
322 * pMcastAddr - L2 multicast entry structure
324 * pMcastAddr - L2 multicast entry structure
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.
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.
338 extern rtk_api_ret_t
rtk_l2_mcastAddr_get(rtk_l2_mcastAddr_t
*pMcastAddr
);
341 * rtk_l2_mcastAddr_next_get
343 * Get Next L2 Multicast entry.
345 * pAddress - The Address ID
347 * pMcastAddr - L2 multicast entry structure
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.
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.
359 extern rtk_api_ret_t
rtk_l2_mcastAddr_next_get(rtk_uint32
*pAddress
, rtk_l2_mcastAddr_t
*pMcastAddr
);
362 * rtk_l2_mcastAddr_del
364 * Delete LUT multicast entry.
366 * pMcastAddr - L2 multicast entry structure
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.
379 * If the mac has existed in the LUT, it will be deleted. Otherwise, it will return RT_ERR_L2_ENTRY_NOTFOUND.
381 extern rtk_api_ret_t
rtk_l2_mcastAddr_del(rtk_l2_mcastAddr_t
*pMcastAddr
);
384 * rtk_l2_ipMcastAddr_add
386 * Add Lut IP multicast entry
388 * pIpMcastAddr - IP Multicast entry
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.
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.
404 extern rtk_api_ret_t
rtk_l2_ipMcastAddr_add(rtk_l2_ipMcastAddr_t
*pIpMcastAddr
);
407 * rtk_l2_ipMcastAddr_get
409 * Get LUT IP multicast entry.
411 * pIpMcastAddr - IP Multicast entry
413 * pIpMcastAddr - IP Multicast entry
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.
421 * The API can get Lut table of IP multicast entry.
423 extern rtk_api_ret_t
rtk_l2_ipMcastAddr_get(rtk_l2_ipMcastAddr_t
*pIpMcastAddr
);
426 * rtk_l2_ipMcastAddr_next_get
428 * Get Next IP Multicast entry.
430 * pAddress - The Address ID
432 * pIpMcastAddr - IP Multicast entry
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.
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.
444 extern rtk_api_ret_t
rtk_l2_ipMcastAddr_next_get(rtk_uint32
*pAddress
, rtk_l2_ipMcastAddr_t
*pIpMcastAddr
);
447 * rtk_l2_ipMcastAddr_del
449 * Delete a ip multicast address entry from the specified device.
451 * pIpMcastAddr - IP Multicast entry
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.
461 * The API can delete a IP multicast address entry from the specified device.
463 extern rtk_api_ret_t
rtk_l2_ipMcastAddr_del(rtk_l2_ipMcastAddr_t
*pIpMcastAddr
);
466 * rtk_l2_ipVidMcastAddr_add
468 * Add Lut IP multicast+VID entry
470 * pIpVidMcastAddr - IP & VID multicast Entry
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.
484 extern rtk_api_ret_t
rtk_l2_ipVidMcastAddr_add(rtk_l2_ipVidMcastAddr_t
*pIpVidMcastAddr
);
487 * rtk_l2_ipVidMcastAddr_get
489 * Get LUT IP multicast+VID entry.
491 * pIpVidMcastAddr - IP & VID multicast Entry
493 * pIpVidMcastAddr - IP & VID multicast Entry
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.
503 extern rtk_api_ret_t
rtk_l2_ipVidMcastAddr_get(rtk_l2_ipVidMcastAddr_t
*pIpVidMcastAddr
);
506 * rtk_l2_ipVidMcastAddr_next_get
508 * Get Next IP Multicast+VID entry.
510 * pAddress - The Address ID
512 * pIpVidMcastAddr - IP & VID multicast Entry
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.
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.
524 extern rtk_api_ret_t
rtk_l2_ipVidMcastAddr_next_get(rtk_uint32
*pAddress
, rtk_l2_ipVidMcastAddr_t
*pIpVidMcastAddr
);
527 * rtk_l2_ipVidMcastAddr_del
529 * Delete a ip multicast+VID address entry from the specified device.
531 * pIpVidMcastAddr - IP & VID multicast Entry
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.
543 extern rtk_api_ret_t
rtk_l2_ipVidMcastAddr_del(rtk_l2_ipVidMcastAddr_t
*pIpVidMcastAddr
);
546 * rtk_l2_ucastAddr_flush
548 * Flush L2 mac address by type in the specified device (both dynamic and static).
550 * pConfig - flush configuration
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.
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
565 * flushByPort - 1: Flush by Port, 0: Don't flush by Port
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.
572 extern rtk_api_ret_t
rtk_l2_ucastAddr_flush(rtk_l2_flushCfg_t
*pConfig
);
577 * Flush all static & dynamic entries in LUT.
584 * RT_ERR_FAILED - Failed
585 * RT_ERR_SMI - SMI access error
589 extern rtk_api_ret_t
rtk_l2_table_clear(void);
592 * rtk_l2_table_clearStatus_get
594 * Get table clear status
598 * pStatus - Clear status, 1:Busy, 0:finish
601 * RT_ERR_FAILED - Failed
602 * RT_ERR_SMI - SMI access error
606 extern rtk_api_ret_t
rtk_l2_table_clearStatus_get(rtk_l2_clearStatus_t
*pStatus
);
609 * rtk_l2_flushLinkDownPortAddrEnable_set
611 * Set HW flush linkdown port mac configuration of the specified device.
614 * enable - link down flush status
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.
624 * The status of flush linkdown port address is as following:
628 extern rtk_api_ret_t
rtk_l2_flushLinkDownPortAddrEnable_set(rtk_port_t port
, rtk_enable_t enable
);
631 * rtk_l2_flushLinkDownPortAddrEnable_get
633 * Get HW flush linkdown port mac configuration of the specified device.
637 * pEnable - link down flush status
640 * RT_ERR_FAILED - Failed
641 * RT_ERR_SMI - SMI access error
642 * RT_ERR_PORT_ID - Invalid port number.
644 * The status of flush linkdown port address is as following:
648 extern rtk_api_ret_t
rtk_l2_flushLinkDownPortAddrEnable_get(rtk_port_t port
, rtk_enable_t
*pEnable
);
651 * rtk_l2_agingEnable_set
653 * Set L2 LUT aging status per port setting.
656 * enable - Aging status
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.
666 * This API can be used to set L2 LUT aging status per port.
668 extern rtk_api_ret_t
rtk_l2_agingEnable_set(rtk_port_t port
, rtk_enable_t enable
);
671 * rtk_l2_agingEnable_get
673 * Get L2 LUT aging status per port setting.
677 * pEnable - Aging status
680 * RT_ERR_FAILED - Failed
681 * RT_ERR_SMI - SMI access error
682 * RT_ERR_PORT_ID - Invalid port number.
684 * This API can be used to get L2 LUT aging function per port.
686 extern rtk_api_ret_t
rtk_l2_agingEnable_get(rtk_port_t port
, rtk_enable_t
*pEnable
);
689 * rtk_l2_limitLearningCnt_set
691 * Set per-Port auto learning limit number
694 * mac_cnt - Auto learning entries limit number
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
704 * The API can set per-port ASIC auto learning limit number from 0(disable learning)
707 extern rtk_api_ret_t
rtk_l2_limitLearningCnt_set(rtk_port_t port
, rtk_mac_cnt_t mac_cnt
);
710 * rtk_l2_limitLearningCnt_get
712 * Get per-Port auto learning limit number
716 * pMac_cnt - Auto learning entries limit number
719 * RT_ERR_FAILED - Failed
720 * RT_ERR_SMI - SMI access error
721 * RT_ERR_PORT_ID - Invalid port number.
723 * The API can get per-port ASIC auto learning limit number.
725 extern rtk_api_ret_t
rtk_l2_limitLearningCnt_get(rtk_port_t port
, rtk_mac_cnt_t
*pMac_cnt
);
728 * rtk_l2_limitSystemLearningCnt_set
730 * Set System auto learning limit number
732 * mac_cnt - Auto learning entries limit number
737 * RT_ERR_FAILED - Failed
738 * RT_ERR_SMI - SMI access error
739 * RT_ERR_LIMITED_L2ENTRY_NUM - Invalid auto learning limit number
741 * The API can set system ASIC auto learning limit number from 0(disable learning)
744 extern rtk_api_ret_t
rtk_l2_limitSystemLearningCnt_set(rtk_mac_cnt_t mac_cnt
);
747 * rtk_l2_limitSystemLearningCnt_get
749 * Get System auto learning limit number
753 * pMac_cnt - Auto learning entries limit number
756 * RT_ERR_FAILED - Failed
757 * RT_ERR_SMI - SMI access error
758 * RT_ERR_PORT_ID - Invalid port number.
760 * The API can get system ASIC auto learning limit number.
762 extern rtk_api_ret_t
rtk_l2_limitSystemLearningCnt_get(rtk_mac_cnt_t
*pMac_cnt
);
765 * rtk_l2_limitLearningCntAction_set
767 * Configure auto learn over limit number action.
770 * action - Auto learning entries limit number
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
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,
786 extern rtk_api_ret_t
rtk_l2_limitLearningCntAction_set(rtk_port_t port
, rtk_l2_limitLearnCntAction_t action
);
789 * rtk_l2_limitLearningCntAction_get
791 * Get auto learn over limit number action.
795 * pAction - Learn over action
798 * RT_ERR_FAILED - Failed
799 * RT_ERR_SMI - SMI access error
800 * RT_ERR_PORT_ID - Invalid port number.
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,
808 extern rtk_api_ret_t
rtk_l2_limitLearningCntAction_get(rtk_port_t port
, rtk_l2_limitLearnCntAction_t
*pAction
);
811 * rtk_l2_limitSystemLearningCntAction_set
813 * Configure system auto learn over limit number action.
816 * action - Auto learning entries limit number
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
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,
832 extern rtk_api_ret_t
rtk_l2_limitSystemLearningCntAction_set(rtk_l2_limitLearnCntAction_t action
);
835 * rtk_l2_limitSystemLearningCntAction_get
837 * Get system auto learn over limit number action.
841 * pAction - Learn over action
844 * RT_ERR_FAILED - Failed
845 * RT_ERR_SMI - SMI access error
846 * RT_ERR_PORT_ID - Invalid port number.
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,
854 extern rtk_api_ret_t
rtk_l2_limitSystemLearningCntAction_get(rtk_l2_limitLearnCntAction_t
*pAction
);
857 * rtk_l2_limitSystemLearningCntPortMask_set
859 * Configure system auto learn portmask
861 * pPortmask - Port Mask
866 * RT_ERR_FAILED - Failed
867 * RT_ERR_SMI - SMI access error
868 * RT_ERR_PORT_MASK - Invalid port mask.
872 extern rtk_api_ret_t
rtk_l2_limitSystemLearningCntPortMask_set(rtk_portmask_t
*pPortmask
);
875 * rtk_l2_limitSystemLearningCntPortMask_get
877 * get system auto learn portmask
881 * pPortmask - Port Mask
884 * RT_ERR_FAILED - Failed
885 * RT_ERR_SMI - SMI access error
886 * RT_ERR_NULL_POINTER - Null pointer.
890 extern rtk_api_ret_t
rtk_l2_limitSystemLearningCntPortMask_get(rtk_portmask_t
*pPortmask
);
893 * rtk_l2_learningCnt_get
895 * Get per-Port current auto learning number
899 * pMac_cnt - ASIC auto learning entries number
902 * RT_ERR_FAILED - Failed
903 * RT_ERR_SMI - SMI access error
904 * RT_ERR_PORT_ID - Invalid port number.
906 * The API can get per-port ASIC auto learning number
908 extern rtk_api_ret_t
rtk_l2_learningCnt_get(rtk_port_t port
, rtk_mac_cnt_t
*pMac_cnt
);
911 * rtk_l2_floodPortMask_set
913 * Set flooding portmask
915 * type - flooding type.
916 * pFlood_portmask - flooding porkmask
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.
926 * This API can set the flooding mask.
927 * The flooding type is as following:
932 extern rtk_api_ret_t
rtk_l2_floodPortMask_set(rtk_l2_flood_type_t floood_type
, rtk_portmask_t
*pFlood_portmask
);
935 * rtk_l2_floodPortMask_get
937 * Get flooding portmask
939 * type - flooding type.
941 * pFlood_portmask - flooding porkmask
944 * RT_ERR_FAILED - Failed
945 * RT_ERR_SMI - SMI access error
946 * RT_ERR_PORT_ID - Invalid port number.
948 * This API can get the flooding mask.
949 * The flooding type is as following:
954 extern rtk_api_ret_t
rtk_l2_floodPortMask_get(rtk_l2_flood_type_t floood_type
, rtk_portmask_t
*pFlood_portmask
);
957 * rtk_l2_localPktPermit_set
959 * Set permittion of frames if source port and destination port are the same.
962 * permit - permittion status
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.
972 * This API is setted to permit frame if its source port is equal to destination port.
974 extern rtk_api_ret_t
rtk_l2_localPktPermit_set(rtk_port_t port
, rtk_enable_t permit
);
977 * rtk_l2_localPktPermit_get
979 * Get permittion of frames if source port and destination port are the same.
983 * pPermit - permittion status
986 * RT_ERR_FAILED - Failed
987 * RT_ERR_SMI - SMI access error
988 * RT_ERR_PORT_ID - Invalid port number.
990 * This API is to get permittion status for frames if its source port is equal to destination port.
992 extern rtk_api_ret_t
rtk_l2_localPktPermit_get(rtk_port_t port
, rtk_enable_t
*pPermit
);
997 * Set LUT agging out speed
999 * aging_time - Agging out time.
1004 * RT_ERR_FAILED - Failed
1005 * RT_ERR_SMI - SMI access error
1006 * RT_ERR_OUT_OF_RANGE - input out of range.
1008 * The API can set LUT agging out period for each entry and the range is from 14s to 800s.
1010 extern rtk_api_ret_t
rtk_l2_aging_set(rtk_l2_age_time_t aging_time
);
1015 * Get LUT agging out time
1019 * pEnable - Aging status
1022 * RT_ERR_FAILED - Failed
1023 * RT_ERR_SMI - SMI access error
1024 * RT_ERR_PORT_ID - Invalid port number.
1026 * The API can get LUT agging out period for each entry.
1028 extern rtk_api_ret_t
rtk_l2_aging_get(rtk_l2_age_time_t
*pAging_time
);
1031 * rtk_l2_ipMcastAddrLookup_set
1033 * Set Lut IP multicast lookup function
1035 * type - Lookup type for IPMC packet.
1040 * RT_ERR_FAILED - Failed
1041 * RT_ERR_SMI - SMI access error
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
1049 extern rtk_api_ret_t
rtk_l2_ipMcastAddrLookup_set(rtk_l2_ipmc_lookup_type_t type
);
1052 * rtk_l2_ipMcastAddrLookup_get
1054 * Get Lut IP multicast lookup function
1058 * pType - Lookup type for IPMC packet.
1061 * RT_ERR_FAILED - Failed
1062 * RT_ERR_SMI - SMI access error
1066 extern rtk_api_ret_t
rtk_l2_ipMcastAddrLookup_get(rtk_l2_ipmc_lookup_type_t
*pType
);
1069 * rtk_l2_ipMcastForwardRouterPort_set
1071 * Set IPMC packet forward to rounter port also or not
1073 * enabled - 1: Inlcude router port, 0, exclude router port
1078 * RT_ERR_FAILED - Failed
1079 * RT_ERR_SMI - SMI access error
1083 extern rtk_api_ret_t
rtk_l2_ipMcastForwardRouterPort_set(rtk_enable_t enabled
);
1086 * rtk_l2_ipMcastForwardRouterPort_get
1088 * Get IPMC packet forward to rounter port also or not
1092 * pEnabled - 1: Inlcude router port, 0, exclude router port
1095 * RT_ERR_FAILED - Failed
1096 * RT_ERR_NULL_POINTER - Null pointer
1100 extern rtk_api_ret_t
rtk_l2_ipMcastForwardRouterPort_get(rtk_enable_t
*pEnabled
);
1103 * rtk_l2_ipMcastGroupEntry_add
1105 * Add an IP Multicast entry to group table
1107 * ip_addr - IP address
1109 * pPortmask - portmask
1114 * RT_ERR_FAILED - Failed
1115 * RT_ERR_SMI - SMI access error
1116 * RT_ERR_TBL_FULL - Table Full
1118 * Add an entry to IP Multicast Group table.
1120 extern rtk_api_ret_t
rtk_l2_ipMcastGroupEntry_add(ipaddr_t ip_addr
, rtk_uint32 vid
, rtk_portmask_t
*pPortmask
);
1123 * rtk_l2_ipMcastGroupEntry_del
1125 * Delete an entry from IP Multicast group table
1127 * ip_addr - IP address
1133 * RT_ERR_FAILED - Failed
1134 * RT_ERR_SMI - SMI access error
1135 * RT_ERR_TBL_FULL - Table Full
1137 * Delete an entry from IP Multicast group table.
1139 extern rtk_api_ret_t
rtk_l2_ipMcastGroupEntry_del(ipaddr_t ip_addr
, rtk_uint32 vid
);
1142 * rtk_l2_ipMcastGroupEntry_get
1144 * get an entry from IP Multicast group table
1146 * ip_addr - IP address
1149 * pPortmask - member port mask
1152 * RT_ERR_FAILED - Failed
1153 * RT_ERR_SMI - SMI access error
1154 * RT_ERR_TBL_FULL - Table Full
1156 * Delete an entry from IP Multicast group table.
1158 extern rtk_api_ret_t
rtk_l2_ipMcastGroupEntry_get(ipaddr_t ip_addr
, rtk_uint32 vid
, rtk_portmask_t
*pPortmask
);
1163 * Get LUT unicast entry.
1165 * pL2_entry - Index field in the structure.
1167 * pL2_entry - other fields such as MAC, port, age...
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.
1175 * This API is used to get address by index from 0~2111.
1177 extern rtk_api_ret_t
rtk_l2_entry_get(rtk_l2_addr_table_t
*pL2_entry
);
1180 #endif /* __RTK_API_L2_H__ */