/* * Copyright (C) 2009-2016 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 those public global APIs and its data type in the SDK. * * Feature : Parameter settings for the system-wise view * */ #ifndef __DAL_CYPRESS_SWITCH_H__ #define __DAL_CYPRESS_SWITCH_H__ /* * Include Files */ #include #include #include #include /* * Symbol Definition */ /* * Data Declaration */ /* * Macro Definition */ /* * Function Declaration */ /* Function Name: * dal_cypress_switchMapper_init * Description: * Hook switch module of the specified device. * Input: * unit - unit id * Output: * None * Return: * RT_ERR_OK * RT_ERR_FAILED * Note: * Must Hook switch module before calling any switch APIs. */ extern int32 dal_cypress_switchMapper_init(dal_mapper_t *pMapper); /* Function Name: * dal_cypress_switch_init * Description: * Initialize switch module of the specified device. * Input: * unit - unit id * Output: * None * Return: * RT_ERR_OK * RT_ERR_FAILED * RT_ERR_UNIT_ID - invalid unit id * Note: * 1. Module must be initialized before using all of APIs in this module */ extern int32 dal_cypress_switch_init(uint32 unit); /* Function Name: * dal_cypress_switch_cpuMaxPktLen_get * Description: * Get the max packet length setting on CPU port of the specific unit * Input: * unit - unit id * dir - direction of packet * Output: * pLen - pointer to the max packet length * Return: * RT_ERR_OK * RT_ERR_FAILED * RT_ERR_UNIT_ID - invalid unit id * RT_ERR_INPUT - invalid packet direction * RT_ERR_NULL_POINTER - input parameter may be null pointer * Note: * None */ extern int32 dal_cypress_switch_cpuMaxPktLen_get(uint32 unit, rtk_switch_pktDir_t dir, uint32 *pLen); /* Function Name: * dal_cypress_switch_cpuMaxPktLen_set * Description: * Set the max packet length setting on CPU port of the specific unit * Input: * unit - unit id * dir - direction of packet * len - max packet length * Output: * None * Return: * RT_ERR_OK * RT_ERR_FAILED * RT_ERR_UNIT_ID - invalid unit id * RT_ERR_INPUT - invalid packet direction * RT_ERR_OUT_OF_RANGE - invalid packet length * Note: * None */ extern int32 dal_cypress_switch_cpuMaxPktLen_set(uint32 unit, rtk_switch_pktDir_t dir, uint32 len); /* Function Name: * dal_cypress_switch_maxPktLenLinkSpeed_get * Description: * Get the max packet length setting of the specific speed type * Input: * unit - unit id * speed - speed type * Output: * pLen - pointer to the max packet length * Return: * RT_ERR_OK * RT_ERR_FAILED * RT_ERR_UNIT_ID - invalid unit id * RT_ERR_NULL_POINTER - input parameter may be null pointer * RT_ERR_INPUT - invalid enum speed type * Note: * Max packet length setting speed type * - MAXPKTLEN_LINK_SPEED_FE * - MAXPKTLEN_LINK_SPEED_GE */ extern int32 dal_cypress_switch_maxPktLenLinkSpeed_get(uint32 unit, rtk_switch_maxPktLen_linkSpeed_t speed, uint32 *pLen); /* Function Name: * dal_cypress_switch_maxPktLenLinkSpeed_set * Description: * Set the max packet length of the specific speed type * Input: * unit - unit id * speed - speed type * len - max packet length * Output: * None * Return: * RT_ERR_OK * RT_ERR_FAILED * RT_ERR_INPUT - invalid enum speed type * RT_ERR_OUT_OF_RANGE - invalid packet length * Note: * Max packet length setting speed type * - MAXPKTLEN_LINK_SPEED_FE * - MAXPKTLEN_LINK_SPEED_GE */ extern int32 dal_cypress_switch_maxPktLenLinkSpeed_set(uint32 unit, rtk_switch_maxPktLen_linkSpeed_t speed, uint32 len); /* Function Name: * dal_cypress_switch_maxPktLenLinkSpeed_get * Description: * Get include or exclude tag length state of max packet length in the specified device. * Input: * unit - unit id * Output: * pEnable - pointer buffer of including/excluding tag length * Return: * RT_ERR_OK * RT_ERR_FAILED * RT_ERR_UNIT_ID - invalid unit id * RT_ERR_NULL_POINTER - input parameter may be null pointer * Note: * None */ extern int32 dal_cypress_switch_maxPktLenTagLenCntIncEnable_get(uint32 unit, rtk_enable_t *pEnable); /* Function Name: * dal_cypress_switch_maxPktLenLinkSpeed_set * Description: * Set the max packet length to include or exclude tag length in the specified device. * Input: * unit - unit id * enable - include/exclude Tag length * Output: * None * Return: * RT_ERR_OK * RT_ERR_FAILED * RT_ERR_UNIT_ID - invalid unit id * RT_ERR_INPUT - invalid input parameter * Note: * None */ extern int32 dal_cypress_switch_maxPktLenTagLenCntIncEnable_set(uint32 unit, rtk_enable_t enable); /* Function Name: * dal_cypress_switch_snapMode_get * Description: * Get SNAP mode. * Input: * unit - unit id * Output: * pSnapMode - pointer to SNAP mode * Return: * RT_ERR_OK * RT_ERR_FAILED * RT_ERR_NOT_INIT - The module is not initial * RT_ERR_UNIT_ID - invalid unit id * RT_ERR_NULL_POINTER - input parameter may be null pointer * Note: * SNAP mode is as following * - SNAP_MODE_AAAA03000000 * - SNAP_MODE_AAAA03 */ extern int32 dal_cypress_switch_snapMode_get(uint32 unit, rtk_snapMode_t *pSnapMode); /* Function Name: * dal_cypress_switch_snapMode_set * Description: * Set SNAP mode. * Input: * unit - unit id * snapMode - SNAP mode * Output: * None * Return: * RT_ERR_OK * RT_ERR_FAILED * RT_ERR_NOT_INIT - The module is not initial * RT_ERR_UNIT_ID - invalid unit id * RT_ERR_INPUT - invalid input parameter * Note: * SNAP mode is as following * - SNAP_MODE_AAAA03000000 * - SNAP_MODE_AAAA03 */ extern int32 dal_cypress_switch_snapMode_set(uint32 unit, rtk_snapMode_t snapMode); /* Function Name: * dal_cypress_switch_chksumFailAction_get * Description: * Get forwarding action of checksum error on specified port. * Input: * unit - unit id * port - port id * failType - checksum fail type * Output: * pAction - pointer to forwarding action * Return: * RT_ERR_OK * RT_ERR_FAILED * RT_ERR_NOT_INIT - The module is not initial * RT_ERR_UNIT_ID - invalid unit id * RT_ERR_PORT_ID - invalid port id * RT_ERR_INPUT - invalid input parameter * RT_ERR_NULL_POINTER - input parameter may be null pointer * Note: * Checksum fail type is as following * - LAYER2_CHKSUM_FAIL * - LAYER3_CHKSUM_FAIL * - LAYER4_CHKSUM_FAIL * * Forwarding action is as following * - ACTION_FORWARD * - ACTION_DROP */ extern int32 dal_cypress_switch_chksumFailAction_get( uint32 unit, rtk_port_t port, rtk_switch_chksum_fail_t failType, rtk_action_t *pAction); /* Function Name: * dal_cypress_switch_chksumFailAction_set * Description: * Set forwarding action of checksum error on specified port. * Input: * unit - unit id * port - port id * failType - checksum fail type * action - forwarding action * Output: * None * Return: * RT_ERR_OK * RT_ERR_FAILED * RT_ERR_NOT_INIT - The module is not initial * RT_ERR_UNIT_ID - invalid unit id * RT_ERR_PORT_ID - invalid port id * RT_ERR_FWD_ACTION - invalid error forwarding action * RT_ERR_INPUT - invalid input parameter * Note: * Checksum fail type is as following * - LAYER2_CHKSUM_FAIL * - LAYER3_CHKSUM_FAIL * - LAYER4_CHKSUM_FAIL * * Forwarding action is as following * - ACTION_FORWARD * - ACTION_DROP */ extern int32 dal_cypress_switch_chksumFailAction_set( uint32 unit, rtk_port_t port, rtk_switch_chksum_fail_t failType, rtk_action_t action); /* Function Name: * dal_cypress_switch_recalcCRCEnable_get * Description: * Get enable status of recaculate CRC on specified port. * Input: * unit - unit id * port - port id * Output: * pEnable - pointer to enable status of recaculate CRC * Return: * RT_ERR_OK * RT_ERR_FAILED * RT_ERR_NOT_INIT - The module is not initial * RT_ERR_UNIT_ID - invalid unit id * RT_ERR_PORT_ID - invalid port id * RT_ERR_NULL_POINTER - input parameter may be null pointer * Note: * When enable, mirrored packet with bad CRC will be recaculate at mirroring port. */ extern int32 dal_cypress_switch_recalcCRCEnable_get(uint32 unit, rtk_port_t port, rtk_enable_t *pEnable); /* Function Name: * dal_cypress_switch_recalcCRCEnable_set * Description: * Set enable status of recaculate CRC on specified port. * Input: * unit - unit id * port - port id * enable - enable status of recaculate CRC * Output: * None * Return: * RT_ERR_OK * RT_ERR_FAILED * RT_ERR_NOT_INIT - The module is not initial * RT_ERR_UNIT_ID - invalid unit id * RT_ERR_PORT_ID - invalid port id * RT_ERR_INPUT - invalid input parameter * Note: * When enable, mirrored packet with bad CRC will be recaculate at mirroring port. */ extern int32 dal_cypress_switch_recalcCRCEnable_set(uint32 unit, rtk_port_t port, rtk_enable_t enable); /* Function Name: * dal_cypress_switch_mgmtMacAddr_get * Description: * Get Mac address of switch. * Input: * unit - unit id * Output: * pMac - pointer to Mac address * Return: * RT_ERR_OK * RT_ERR_FAILED * RT_ERR_NOT_INIT - The module is not initial * RT_ERR_UNIT_ID - invalid unit id * RT_ERR_NULL_POINTER - input parameter may be null pointer * Note: * */ extern int32 dal_cypress_switch_mgmtMacAddr_get(uint32 unit, rtk_mac_t *pMac); /* Function Name: * dal_cypress_switch_mgmtMacAddr_set * Description: * Set Mac address of switch. * Input: * unit - unit id * pMac - pointer to Mac address * Output: * None * Return: * RT_ERR_OK * RT_ERR_FAILED * RT_ERR_NOT_INIT - The module is not initial * RT_ERR_UNIT_ID - invalid unit id * RT_ERR_NULL_POINTER - input parameter may be null pointer * RT_ERR_MAC - invalid mac address * Note: * None */ extern int32 dal_cypress_switch_mgmtMacAddr_set(uint32 unit, rtk_mac_t *pMac); /* Function Name: * dal_cypress_switch_pppoeIpParseEnable_get * Description: * Get enable status of PPPoE pass-through functionality. * Input: * unit - unit id * Output: * pEnable - pointer to enable status of PPPoE parse functionality * Return: * RT_ERR_OK * RT_ERR_FAILED * RT_ERR_NOT_INIT - The module is not initial * RT_ERR_UNIT_ID - invalid unit id * RT_ERR_NULL_POINTER - input parameter may be null pointer * Note: * None */ extern int32 dal_cypress_switch_pppoeIpParseEnable_get(uint32 unit, rtk_enable_t *pEnable); /* Function Name: * dal_cypress_switch_pppoeIpParseEnable_set * Description: * Set enable status of PPPoE pass-through functionality. * Input: * unit - unit id * enable - enable status * Output: * None * Return: * RT_ERR_OK * RT_ERR_FAILED * RT_ERR_NOT_INIT - The module is not initial * RT_ERR_UNIT_ID - invalid unit id * RT_ERR_INPUT - invalid input parameter * Note: * None */ extern int32 dal_cypress_switch_pppoeIpParseEnable_set(uint32 unit, rtk_enable_t enable); /* Function Name: * dal_cypress_switch_IPv4Addr_get * Description: * Get IPv4 address of switch. * Input: * unit - unit id * Output: * pIpAddr - pointer to IPv4 address * Return: * RT_ERR_OK * RT_ERR_FAILED * RT_ERR_NOT_INIT - The module is not initial * RT_ERR_UNIT_ID - invalid unit id * RT_ERR_NULL_POINTER - input parameter may be null pointer * Note: * */ extern int32 dal_cypress_switch_IPv4Addr_get(uint32 unit, uint32 *pIpAddr); /* Function Name: * dal_cypress_switch_IPv4Addr_set * Description: * Set IPv4 address of switch. * Input: * unit - unit id * ipAddr - IPv4 address * Output: * None * Return: * RT_ERR_OK * RT_ERR_FAILED * RT_ERR_NOT_INIT - The module is not initial * RT_ERR_UNIT_ID - invalid unit id * RT_ERR_IPV4_ADDRESS - invalid IPv4 address * Note: * None */ extern int32 dal_cypress_switch_IPv4Addr_set(uint32 unit, uint32 ipAddr); /* Function Name: * dal_cypress_switch_pkt2CpuTypeFormat_get * Description: * Get the configuration about content state for packet to CPU * Input: * unit - unit id * type - method of packet to CPU * Output: * pFormat - type of format * Return: * RT_ERR_OK * RT_ERR_FAILED * RT_ERR_INPUT - invalid input parameter * RT_ERR_NULL_POINTER - NULL pointer * Note: * The type of packet to CPU: * - PKT2CPU_TYPE_FORWARD * - PKT2CPU_TYPE_TRAP * * The type of format: * - TRAP_PKT_ORIGINAL * - TRAP_PKT_MODIFIED */ extern int32 dal_cypress_switch_pkt2CpuTypeFormat_get(uint32 unit, rtk_switch_pkt2CpuType_t type, rtk_pktFormat_t *pFormat); /* Function Name: * dal_cypress_switch_pkt2CpuTypeFormat_set * Description: * Set the configuration about content state for packet to CPU * Input: * unit - unit id * type - method of packet to CPU * format - packet format to CPU * Output: * None * Return: * RT_ERR_OK * RT_ERR_FAILED * RT_ERR_INPUT - invalid input parameter * Note: * The type of format: * - TRAP_PKT_ORIGINAL * - TRAP_PKT_MODIFIED */ extern int32 dal_cypress_switch_pkt2CpuTypeFormat_set(uint32 unit, rtk_switch_pkt2CpuType_t type, rtk_pktFormat_t format); /* Function Name: * dal_cypress_switch_cpuPktTruncateEnable_get * Description: * Get CPU port truncation function state. * Input: * unit - unit id * Output: * pEnable - enable state * Return: * RT_ERR_OK * RT_ERR_FAILED * RT_ERR_NOT_INIT - The module is not initial * RT_ERR_NULL_POINTER - input parameter may be null pointer * Note: * (1) Packet is truncated to specified length if it is trap/forward to CPU and packet length is * over than the truncation length. * (2) The truncation length is specified by rtk_switch_cpuPktTruncateLen_set. */ extern int32 dal_cypress_switch_cpuPktTruncateEnable_get(uint32 unit, rtk_enable_t *pEnable); /* Function Name: * dal_cypress_switch_cpuPktTruncateEnable_set * Description: * Set CPU port truncation function state. * Input: * unit - unit id * enable - enable state * Output: * None * Return: * RT_ERR_OK * RT_ERR_FAILED * RT_ERR_NOT_INIT - The module is not initial * RT_ERR_INPUT - invalid input parameter * Note: * (1) Packet is truncated to specified length if it is trap/forward to CPU and packet length is * over than the truncation length. * (2) The truncation length is specified by rtk_switch_cpuPktTruncateLen_set. */ extern int32 dal_cypress_switch_cpuPktTruncateEnable_set(uint32 unit, rtk_enable_t enable); /* Function Name: * dal_cypress_switch_cpuPktTruncateLen_get * Description: * Get the packet length for CPU port truncation function. * Input: * unit - unit id * Output: * pLen - packet length to truncate * Return: * RT_ERR_OK * RT_ERR_FAILED * RT_ERR_NOT_INIT - The module is not initial * RT_ERR_NULL_POINTER - input parameter may be null pointer * Note: * (1) Packet is truncated to specified length if it is trap/forward to CPU and packet length is * over than the truncation length. * (2) The truncation function takes effect if rtk_switch_cpuPktTruncateEnable_set is enabled. */ extern int32 dal_cypress_switch_cpuPktTruncateLen_get(uint32 unit, uint32 *pLen); /* Function Name: * dal_cypress_switch_cpuPktTruncateLen_set * Description: * Set the packet length for CPU port truncation function. * Input: * unit - unit id * len - packet length to truncate * Output: * None * Return: * RT_ERR_OK * RT_ERR_FAILED * RT_ERR_NOT_INIT - The module is not initial * RT_ERR_OUT_OF_RANGE - invalid truncation length * Note: * (1) Packet is truncated to specified length if it is trap/forward to CPU and packet length is * over than the truncation length. * (2) The truncation function takes effect if rtk_switch_cpuPktTruncateEnable_set is enabled. */ extern int32 dal_cypress_switch_cpuPktTruncateLen_set(uint32 unit, uint32 len); #endif /* __DAL_CYPRESS_SWITCH_H__ */