realtek-doc/sources/rtk-gp3000/include/dal/ca8277b/dal_ca8277b_l2.h
2025-12-04 22:26:46 +05:00

640 lines
18 KiB
C
Executable file

/*
* Copyright (C) 2015 Realtek Semiconductor Corp.
* All Rights Reserved.
*
* This program is the proprietary software of Realtek Semiconductor
* Corporation and/or its licensors, and only be used, duplicated,
* modified or distributed under the authorized license from Realtek.
*
* ANY USE OF THE SOFTWARE OTHER THAN AS AUTHORIZED UNDER
* THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
*
* $Revision: $
* $Date: $
*
* Purpose : Definition of L2 API
*
* Feature : The file includes the following modules and sub-modules
* (1) Mac address flush
* (2) Address learning limit
* (3) Parameter for L2 lookup and learning engine
* (4) Unicast address
* (5) L2 multicast
* (6) IP multicast
* (7) Multicast forwarding table
* (8) CPU mac
* (9) Port move
* (10) Parameter for lookup miss
* (11) Parameter for MISC
*
*/
#ifndef __DAL_CA8277B_L2_H__
#define __DAL_CA8277B_L2_H__
/*
* Include Files
*/
#include <common/rt_type.h>
#include <rtk/l2.h>
/*
* Symbol Definition
*/
/****************************************************************/
/* Constant Definition */
/****************************************************************/
/****************************************************************/
/* Type Definition */
/****************************************************************/
/*
* Macro Declaration
*/
/*
* Function Declaration
*/
/* Module Name : L2 */
/* Sub-module Name: Global */
/* Function Name:
* dal_ca8277b_l2_init
* Description:
* Initialize l2 module of the specified device.
* Input:
* None
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* Note:
* Must initialize l2 module before calling any l2 APIs.
*/
extern int32
dal_ca8277b_l2_init(void);
/* Function Name:
* dal_ca8277b_l2_flushLinkDownPortAddrEnable_get
* Description:
* Get HW flush linkdown port mac configuration.
* Input:
* None
* Output:
* pEnable - pointer buffer of state of HW clear linkdown port mac
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* (1) Make sure chip have supported the function before using the API.
* (2) The API is apply to whole system.
* (3) The status of flush linkdown port address is as following:
* - DISABLED
* - ENABLED
*/
extern int32
dal_ca8277b_l2_flushLinkDownPortAddrEnable_get(rtk_enable_t *pEnable);
/* Function Name:
* dal_ca8277b_l2_flushLinkDownPortAddrEnable_set
* Description:
* Set HW flush linkdown port mac configuration.
* Input:
* enable - configure value
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_INPUT - invalid input parameter
* Note:
* (1) Make sure chip have supported the function before using the API.
* (2) The API is apply to whole system.
* (3) The status of flush linkdown port address is as following:
* - DISABLED
* - ENABLED
*/
extern int32
dal_ca8277b_l2_flushLinkDownPortAddrEnable_set(rtk_enable_t enable);
/* Function Name:
* dal_ca8277b_l2_portLimitLearningCnt_get
* Description:
* Get the maximum mac learning counts of the port.
* Input:
* port - port id
* Output:
* pMacCnt - pointer buffer of maximum mac learning counts
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* (1) The maximum mac learning counts only limit for dynamic learning mac
* address, not apply to static mac address.
*/
extern int32
dal_ca8277b_l2_portLimitLearningCnt_get(rtk_port_t port, uint32 *pMacCnt);
/* Function Name:
* dal_ca8277b_l2_portLimitLearningCnt_set
* Description:
* Set the maximum mac learning counts of the port.
* Input:
* port - port id
* macCnt - maximum mac learning counts
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_LIMITED_L2ENTRY_NUM - invalid limited L2 entry number
* Note:
* (1) The maximum mac learning counts only limit for dynamic learning mac
* address, not apply to static mac address.
* (2) Set the macCnt to 0 mean disable learning in the port.
*/
extern int32
dal_ca8277b_l2_portLimitLearningCnt_set(rtk_port_t port, uint32 macCnt);
/* Function Name:
* dal_ca8277b_l2_portLimitLearningCntAction_get
* Description:
* Get the action when over learning maximum mac counts of the port.
* Input:
* port - port id
* Output:
* pLearningAction - pointer buffer of action when over learning maximum mac counts
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* The action symbol as following
* - LIMIT_LEARN_CNT_ACTION_DROP
* - LIMIT_LEARN_CNT_ACTION_FORWARD
* - LIMIT_LEARN_CNT_ACTION_TO_CPU
* - LIMIT_LEARN_CNT_ACTION_COPY_CPU
*/
extern int32
dal_ca8277b_l2_portLimitLearningCntAction_get(rtk_port_t port, rtk_l2_limitLearnCntAction_t *pLearningAction);
/* Function Name:
* dal_ca8277b_l2_portLimitLearningCntAction_set
* Description:
* Set the action when over learning maximum mac counts of the port.
* Input:
* port - port id
* learningAction - action when over learning maximum mac counts
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_PORT_ID - invalid port id
* Note:
* The action symbol as following
* - LIMIT_LEARN_CNT_ACTION_DROP
* - LIMIT_LEARN_CNT_ACTION_FORWARD
* - LIMIT_LEARN_CNT_ACTION_TO_CPU
* - LIMIT_LEARN_CNT_ACTION_COPY_CPU
*/
extern int32
dal_ca8277b_l2_portLimitLearningCntAction_set(rtk_port_t port, rtk_l2_limitLearnCntAction_t learningAction);
/* Function Name:
* da_ca8277b_l2_aging_get
* Description:
* Get the dynamic address aging time.
* Input:
* None
* Output:
* pAgingTime - pointer buffer of aging time
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* Get aging_time as 0 mean disable aging mechanism. (0.1sec)
*/
extern int32
dal_ca8277b_l2_aging_get(uint32 *pAgingTime);
/* Function Name:
* dal_ca8277b_l2_aging_set
* Description:
* Set the dynamic address aging time.
* Input:
* agingTime - aging time
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_INPUT - invalid input parameter
* Note:
* (1) RTL8329/RTL8389 aging time is not configurable.
* (2) apply aging_time as 0 mean disable aging mechanism.
*/
extern int32
dal_ca8277b_l2_aging_set(uint32 agingTime);
/* Function Name:
* dal_ca8277b_l2_portAgingEnable_get
* Description:
* Get the dynamic address aging out setting of the specified port.
* Input:
* port - port id
* Output:
* pEnable - pointer to enable status of Age
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* None
*/
extern int32
dal_ca8277b_l2_portAgingEnable_get(rtk_port_t port, rtk_enable_t *pEnable);
/* Function Name:
* dal_ca8277b_l2_portAgingEnable_set
* Description:
* Set the dynamic address aging out configuration of the specified port
* Input:
* port - port id
* enable - enable status of Age
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_INPUT - invalid input parameter
* Note:
* None
*/
extern int32
dal_ca8277b_l2_portAgingEnable_set(rtk_port_t port, rtk_enable_t enable);
/* Module Name : L2 */
/* Sub-module Name: Parameter for lookup miss */
/* Function Name:
* dal_ca8277b_l2_lookupMissAction_get
* Description:
* Get forwarding action when destination address lookup miss.
* Input:
* type - type of lookup miss
* Output:
* pAction - pointer to forwarding action
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_INPUT - invalid type of lookup miss
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* Type of lookup missis as following:
* - DLF_TYPE_IPMC
* - DLF_TYPE_UCAST
* - DLF_TYPE_BCAST
* - DLF_TYPE_MCAST
*
* Forwarding action is as following:
* - ACTION_FORWARD
* - ACTION_DROP
* - ACTION_TRAP2CPU
* - ACTION_FLOOD_IN_VLAN
* - ACTION_FLOOD_IN_ALL_PORT (only for DLF_TYPE_MCAST)
* - ACTION_FLOOD_IN_ROUTER_PORTS (only for DLF_TYPE_IPMC)
* - ACTION_FOLLOW_FB
*/
extern int32
dal_ca8277b_l2_lookupMissAction_get(rtk_l2_lookupMissType_t type, rtk_action_t *pAction);
/* Function Name:
* dal_ca8277b_l2_lookupMissAction_set
* Description:
* Set forwarding action when destination address lookup miss.
* Input:
* type - type of lookup miss
* action - forwarding action
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_INPUT - invalid type of lookup miss
* RT_ERR_FWD_ACTION - invalid forwarding action
* Note:
* Type of lookup missis as following:
* - DLF_TYPE_IPMC
* - DLF_TYPE_UCAST
* - DLF_TYPE_BCAST
* - DLF_TYPE_MCAST
*
* Forwarding action is as following:
* - ACTION_FORWARD
* - ACTION_DROP
* - ACTION_TRAP2CPU
* - ACTION_FLOOD_IN_VLAN
* - ACTION_FLOOD_IN_ALL_PORT (only for DLF_TYPE_MCAST)
* - ACTION_FLOOD_IN_ROUTER_PORTS (only for DLF_TYPE_IPMC)
* - ACTION_FOLLOW_FB
*/
extern int32
dal_ca8277b_l2_lookupMissAction_set(rtk_l2_lookupMissType_t type, rtk_action_t action);
/* Function Name:
* dal_ca8277b_l2_portLookupMissAction_get
* Description:
* Get forwarding action of specified port when destination address lookup miss.
* Input:
* port - port id
* type - type of lookup miss
* Output:
* pAction - pointer to forwarding action
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_INPUT - invalid type of lookup miss
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* Type of lookup missis as following:
* - DLF_TYPE_IPMC
* - DLF_TYPE_UCAST
* - DLF_TYPE_MCAST
* - DLF_TYPE_BCAST
* - DLF_TYPE_IP6MC
*
* Forwarding action is as following:
* - ACTION_DROP
* - ACTION_TRAP2CPU
* - ACTION_FORWARD
* - ACTION_FOLLOW_FB
*/
extern int32
dal_ca8277b_l2_portLookupMissAction_get(rtk_port_t port, rtk_l2_lookupMissType_t type, rtk_action_t *pAction);
/* Function Name:
* dal_ca8277b_l2_portLookupMissAction_set
* Description:
* Set forwarding action of specified port when destination address lookup miss.
* Input:
* port - port id
* type - type of lookup miss
* action - forwarding action
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_INPUT - invalid type of lookup miss
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_FWD_ACTION - invalid forwarding action
* Note:
* Type of lookup missis as following:
* - DLF_TYPE_IPMC
* - DLF_TYPE_UCAST
* - DLF_TYPE_MCAST
* - DLF_TYPE_BCAST
* - DLF_TYPE_IP6MC
*
* Forwarding action is as following:
* - ACTION_DROP
* - ACTION_TRAP2CPU
* - ACTION_FORWARD
* - ACTION_FOLLOW_FB
*/
extern int32
dal_ca8277b_l2_portLookupMissAction_set(rtk_port_t port, rtk_l2_lookupMissType_t type, rtk_action_t action);
/* Function Name:
* dal_ca8277b_l2_nextValidAddr_get
* Description:
* Get next valid L2 unicast address entry from the specified device.
* Input:
* pScanIdx - currently scan index of l2 table to get next.
* include_static - the get type, include static mac or not.
* Output:
* pL2UcastData - structure of l2 address data
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_VLAN_VID - invalid vid
* RT_ERR_MAC - invalid mac address
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* RT_ERR_L2_ENTRY_NOTFOUND - specified entry not found
* Note:
* (1) The function will skip valid l2 multicast and ip multicast entry and
* reply next valid L2 unicast address is based on index order of l2 table.
* (2) Please input 0 for get the first entry of l2 table.
* (3) The pScanIdx is the input and also is the output argument.
*/
extern int32
dal_ca8277b_l2_nextValidAddr_get(
int32 *pScanIdx,
rtk_l2_ucastAddr_t *pL2UcastData);
/* Function Name:
* dal_ca8277b_l2_nextValidAddrOnPort_get
* Description:
* Get next valid L2 unicast address entry from specify port.
* Input:
* pScanIdx - currently scan index of l2 table to get next.
* Output:
* pL2UcastData - structure of l2 address data
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_VLAN_VID - invalid vid
* RT_ERR_MAC - invalid mac address
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* RT_ERR_L2_ENTRY_NOTFOUND - specified entry not found
* Note:
* (1) The function will skip valid l2 multicast and ip multicast entry and
* reply next valid L2 unicast address is based on index order of l2 table.
* (2) Please input 0 for get the first entry of l2 table.
* (3) The pScanIdx is the input and also is the output argument.
*/
extern int32
dal_ca8277b_l2_nextValidAddrOnPort_get(
rtk_port_t port,
int32 *pScanIdx,
rtk_l2_ucastAddr_t *pL2UcastData);
/* Function Name:
* dal_ca8277b_l2_nextValidEntry_get
* Description:
* Get LUT next valid entry.
* Input:
* pScanIdx - Index field in the structure.
* Output:
* pL2Entry - entry content
* Return:
* RT_ERR_OK - OK
* RT_ERR_FAILED - Failed
* RT_ERR_L2_EMPTY_ENTRY - Empty LUT entry.
* RT_ERR_INPUT - Invalid input parameters.
* Note:
* This API is used to get next valid LUT entry.
*/
extern int32
dal_ca8277b_l2_nextValidEntry_get(
int32 *pScanIdx,
rtk_l2_addr_table_t *pL2Entry);
/* Function Name:
* dal_ca8277b_l2_addr_add
* Description:
* Add L2 entry to ASIC.
* Input:
* pL2_addr - L2 entry
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_VLAN_VID - invalid vlan id
* RT_ERR_MAC - invalid mac address
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* RT_ERR_INPUT - invalid input parameter
* Note:
* Need to initialize L2 entry before add it.
*/
extern int32
dal_ca8277b_l2_addr_add(rtk_l2_ucastAddr_t *pL2Addr);
/* Function Name:
* dal_ca8277b_l2_addr_del
* Description:
* Delete a L2 unicast address entry.
* Input:
* pL2Addr - L2 entry
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_VLAN_VID - invalid vid
* RT_ERR_MAC - invalid mac address
* RT_ERR_L2_ENTRY_NOTFOUND - specified entry not found
* Note:
* If the mac has existed in the LUT, it will be deleted. Otherwise, it will return RT_ERR_L2_ENTRY_NOTFOUND.
*/
extern int32
dal_ca8277b_l2_addr_del(rtk_l2_ucastAddr_t *pL2Addr);
/* Function Name:
* dal_ca8277b_l2_addr_get
* Description:
* Get L2 entry based on specified vid and MAC address
* Input:
* None
* Output:
* pL2Addr - pointer to L2 entry
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_VLAN_VID - invalid vlan id
* RT_ERR_MAC - invalid mac address
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* RT_ERR_L2_ENTRY_NOTFOUND - specified entry not found
* Note:
* If the unicast mac address existed in LUT, it will return the port and fid where
* the mac is learned. Otherwise, it will return a RT_ERR_L2_ENTRY_NOTFOUND error.
*/
extern int32
dal_ca8277b_l2_addr_get(rtk_l2_ucastAddr_t *pL2Addr);
/* Function Name:
* dal_ca8277b_l2_addr_delAll
* Description:
* Delete all L2 unicast address entry.
* Input:
* includeStatic - include static mac or not?
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* Note:
* None
*/
extern int32
dal_ca8277b_l2_addr_delAll(uint32 includeStatic);
/* Module Name : L2 */
/* Sub-module Name: Port move */
/* Function Name:
* dal_ca8277b_l2_illegalPortMoveAction_get
* Description:
* Get forwarding action when illegal port moving happen on specified port.
* Input:
* port - port id
* Output:
* pFwdAction - pointer to forwarding action
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_NULL_POINTER - input parameter may be null pointer
* Note:
* Forwarding action is as following
* - ACTION_FORWARD
* - ACTION_DROP
* - ACTION_TRAP2CPU
* - ACTION_COPY2CPU
*/
extern int32
dal_ca8277b_l2_illegalPortMoveAction_get(
rtk_port_t port,
rtk_action_t *pFwdAction);
/* Function Name:
* dal_ca8277b_l2_illegalPortMoveAction_set
* Description:
* Set forwarding action when illegal port moving happen on specified port.
* Input:
* port - port id
* fwdAction - forwarding action
* Output:
* None
* Return:
* RT_ERR_OK
* RT_ERR_FAILED
* RT_ERR_NOT_INIT - The module is not initial
* RT_ERR_PORT_ID - invalid port id
* RT_ERR_FWD_ACTION - invalid forwarding action
* Note:
* Forwarding action is as following
* - ACTION_FORWARD
* - ACTION_DROP
* - ACTION_TRAP2CPU
* - ACTION_COPY2CPU
*/
extern int32
dal_ca8277b_l2_illegalPortMoveAction_set(
rtk_port_t port,
rtk_action_t fwdAction);
#endif /* __DAL_CA8277B_L2_H__ */