| /******************************************************************************* |
| Copyright (C) Marvell International Ltd. and its affiliates |
| |
| This software file (the "File") is owned and distributed by Marvell |
| International Ltd. and/or its affiliates ("Marvell") under the following |
| alternative licensing terms. Once you have made an election to distribute the |
| File under one of the following license alternatives, please (i) delete this |
| introductory statement regarding license alternatives, (ii) delete the two |
| license alternatives that you have not elected to use and (iii) preserve the |
| Marvell copyright notice above. |
| |
| ******************************************************************************** |
| Marvell Commercial License Option |
| |
| If you received this File from Marvell and you have entered into a commercial |
| license agreement (a "Commercial License") with Marvell, the File is licensed |
| to you under the terms of the applicable Commercial License. |
| |
| ******************************************************************************** |
| Marvell GPL License Option |
| |
| If you received this File from Marvell, you may opt to use, redistribute and/or |
| modify this File in accordance with the terms and conditions of the General |
| Public License Version 2, June 1991 (the "GPL License"), a copy of which is |
| available along with the File in the license.txt file or by writing to the Free |
| Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or |
| on the worldwide web at http://www.gnu.org/licenses/gpl.txt. |
| |
| THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED |
| WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY |
| DISCLAIMED. The GPL License provides additional details about this warranty |
| disclaimer. |
| ******************************************************************************** |
| Marvell BSD License Option |
| |
| If you received this File from Marvell, you may opt to use, redistribute and/or |
| modify this File under the following licensing terms. |
| Redistribution and use in source and binary forms, with or without modification, |
| are permitted provided that the following conditions are met: |
| |
| * Redistributions of source code must retain the above copyright notice, |
| this list of conditions and the following disclaimer. |
| |
| * Redistributions in binary form must reproduce the above copyright |
| notice, this list of conditions and the following disclaimer in the |
| documentation and/or other materials provided with the distribution. |
| |
| * Neither the name of Marvell nor the names of its contributors may be |
| used to endorse or promote products derived from this software without |
| specific prior written permission. |
| |
| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
| ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR |
| ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON |
| ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| |
| ******************************************************************************/ |
| |
| /****************************************************************************** |
| * mv_tpm_sw_config.c |
| * |
| * |
| * MODULE : TPM Switch |
| * |
| * DESCRIPTION : This file config tpm switch |
| * |
| * MODIFICATION HISTORY: |
| * 28Apr2010 DimaM - initial version created. |
| * |
| * FILE REVISION NUMBER: |
| * $Revision: 1.47 $ |
| *******************************************************************************/ |
| |
| #include "tpm_common.h" |
| #include "tpm_header.h" |
| #include "../../mv_mac_learn/mv_mac_learn_header.h" |
| |
| uint32_t trace_sw_dbg_flag = 0; |
| |
| static tpm_swport_pm_1_t g_mc_tpm_swport_pm_1; |
| static tpm_swport_pm_3_all_t g_mc_tpm_swport_pm_3; |
| |
| #define IF_ERROR(ret)\ |
| if (ret != TPM_DB_OK) {\ |
| printk(KERN_ERR "ERROR: (%s) call not allowed, switch not initialized\n", __FUNCTION__);\ |
| return(ret);\ |
| } |
| |
| #define SWITCH_INIT_CHECK()\ |
| int32_t ret_init_check;\ |
| ret_init_check = tpm_sw_init_check();\ |
| IF_ERROR(ret_init_check) |
| |
| /******************************************************************************* |
| * tpm_sw_init_check |
| * |
| * DESCRIPTION: |
| * This function is to check switch is allowed to init or not |
| * |
| * INPUTS: |
| * NONE |
| * |
| * OUTPUTS: |
| * |
| * RETURNS: |
| * On success - TPM_RC_OK. |
| * On error different types are returned according to the case - see tpm_error_code_t. |
| * |
| * COMMENTS: |
| * NONE. |
| * |
| *******************************************************************************/ |
| tpm_error_code_t tpm_sw_init_check(void) |
| { |
| uint32_t switch_init; |
| int32_t ret; |
| |
| ret = tpm_db_switch_init_get(&switch_init); |
| IF_ERROR(ret); |
| if (!switch_init) |
| return ERR_SW_NOT_INIT; |
| |
| return TPM_RC_OK; |
| } |
| |
| /******************************************************************************* |
| * tpm_phy_access_check |
| * |
| * DESCRIPTION: |
| * This function check the PHY access path, direct or through switch. |
| * |
| * INPUTS: |
| * src_port - Source port in UNI port index, UNI0, UNI1...UNI4. |
| * |
| * OUTPUTS: |
| * phy_ctrl - the PHY SMI master indication |
| * phy_direct_addr - PHY address if PHY accessed directly |
| * |
| * RETURNS: |
| * On success - TPM_RC_OK. |
| * On error different types are returned according to the case - see tpm_error_code_t. |
| * |
| * COMMENTS: |
| * NONE. |
| * |
| *******************************************************************************/ |
| tpm_error_code_t tpm_phy_access_check(tpm_src_port_type_t src_port, |
| tpm_phy_ctrl_t *phy_access_way, |
| uint32_t *phy_direct_addr) |
| { |
| tpm_init_gmac_conn_conf_t gmac_conn_info; |
| uint32_t i; |
| tpm_db_chip_conn_t chip_con; |
| tpm_db_int_conn_t int_con; |
| uint32_t switch_port; |
| |
| /* Para check*/ |
| if ((NULL == phy_access_way) || (NULL == phy_direct_addr)) { |
| printk(KERN_ERR "ERROR: Invalid pointer\n"); |
| return ERR_GENERAL; |
| } |
| |
| /* Check gmac port connection info */ |
| for (i = 0; i < TPM_MAX_NUM_GMACS; i++) |
| { |
| if (TPM_DB_OK != tpm_db_gmac_conn_conf_get(i, &gmac_conn_info)) |
| { |
| printk(KERN_ERR "ERROR: (%s:%d) Gmac port(%d) connection info get failed\n", __FUNCTION__, __LINE__, i); |
| return ERR_PHY_SRC_PORT_CONN_INVALID; |
| } |
| if (TPM_TRUE == gmac_conn_info.valid && src_port == gmac_conn_info.port_src) |
| { |
| if(gmac_conn_info.conn == TPM_GMAC_CON_SGMII) |
| { |
| /* No PHY available */ |
| *phy_access_way = PHY_SGMII; |
| |
| if (trace_sw_dbg_flag) |
| printk(KERN_INFO "Port%d SGMII connection, no PHY\n", src_port, *phy_direct_addr); |
| |
| return TPM_RC_OK; |
| } |
| else // We keep the original code for the rest of cases |
| { |
| /* PHY access directly */ |
| *phy_access_way = PHY_SMI_MASTER_CPU; |
| /*get PHY addr on GMAC*/ |
| *phy_direct_addr = mvBoardPhyAddrGet(i); |
| |
| if (trace_sw_dbg_flag) |
| printk(KERN_INFO "Port%d PHY access directly, phyaddr %d\n", src_port, *phy_direct_addr); |
| |
| return TPM_RC_OK; |
| } |
| } |
| } |
| |
| /* Check eth port connection info */ |
| if (TPM_DB_OK != tpm_db_eth_port_conf_get(src_port, &chip_con, &int_con, &switch_port)) { |
| printk(KERN_ERR "ERROR: (%s:%d) Eth port(%d) connection info get failed\n", __FUNCTION__, __LINE__, src_port); |
| return ERR_PHY_SRC_PORT_CONN_INVALID; |
| } |
| /* Check QSGMII */ |
| if (TPM_CONN_QSGMII == chip_con && TPM_INTCON_SWITCH == int_con) { |
| /* Check MPP register, if value of MPP29 and MPP30 are both 4, then access PHY directly */ |
| if ((mvBoardMppGet(3) & DB_88F6535_MPP24_31) == DB_88F6535_MPP24_31) { |
| /* PHY access directly */ |
| *phy_access_way = PHY_SMI_MASTER_CPU; |
| /*get PHY addr on GMAC*/ |
| *phy_direct_addr = (uint32_t)src_port; |
| if (trace_sw_dbg_flag) |
| printk(KERN_INFO "Port%d QSGMII PHY access directly, phyaddr %d\n", src_port, *phy_direct_addr); |
| return TPM_RC_OK; |
| } |
| } |
| |
| *phy_access_way = PHY_SMI_MASTER_SWT; |
| if (trace_sw_dbg_flag) |
| printk(KERN_INFO "Port%d PHY access through switch\n", src_port); |
| |
| return TPM_RC_OK; |
| } |
| |
| tpm_error_code_t tpm_src_port_mac_map(tpm_src_port_type_t src_port, |
| tpm_gmacs_enum_t *gmac) |
| { |
| tpm_init_gmac_conn_conf_t gmac_conn_info; |
| uint32_t i; |
| |
| /* Check gmac port connection info */ |
| for (i = 0; i < TPM_MAX_NUM_GMACS; i++) { |
| if (TPM_DB_OK != tpm_db_gmac_conn_conf_get(i, &gmac_conn_info)) { |
| printk(KERN_ERR "ERROR: (%s:%d) Gmac port(%d) connection info get failed\n", __FUNCTION__, __LINE__, i); |
| return ERR_GENERAL; |
| } |
| if (TPM_TRUE == gmac_conn_info.valid && src_port == gmac_conn_info.port_src) { |
| *gmac = i; |
| return TPM_RC_OK; |
| } |
| } |
| if (i == TPM_MAX_NUM_GMACS) { |
| printk(KERN_ERR "ERROR: (%s:%d) src port(%d) map to MAC failed\n", __FUNCTION__, __LINE__, src_port); |
| return ERR_SRC_PORT_INVALID; |
| } |
| |
| return TPM_RC_OK; |
| } |
| |
| /******************************************************************************* |
| * tpm_sw_set_gmac_speed_duplex_fc |
| * |
| * DESCRIPTION: |
| * This function will update GMAC Port Auto-Negotiation Configuration Register if PHY is |
| * connected to GMAC directly. Maily for Media Convert. |
| * |
| * INPUTS: |
| * src_port - Source port in UNI port index, UNI0, UNI1...UNI4. |
| * auto_nego_en - Auto-negotiation enable status |
| * |
| * OUTPUTS: |
| * None. |
| * |
| * RETURNS: |
| * On success - TPM_RC_OK. |
| * On error different types are returned according to the case - see tpm_error_code_t. |
| * |
| * COMMENTS: |
| * NONE. |
| *******************************************************************************/ |
| static tpm_error_code_t tpm_sw_set_gmac_speed_duplex_fc(uint32_t owner_id, |
| tpm_src_port_type_t src_port, |
| bool auto_nego_en) |
| { |
| tpm_error_code_t retVal = TPM_RC_OK; |
| tpm_phy_ctrl_t phy_access_way; |
| uint32_t switch_init; |
| tpm_gmacs_enum_t gmac_port; |
| uint32_t phy_direct_addr; |
| tpm_phy_speed_t cfg_speed; |
| bool cfg_duplex, cfg_fc; |
| |
| retVal = tpm_phy_access_check(src_port, &phy_access_way, &phy_direct_addr); |
| if (retVal != TPM_RC_OK) { |
| printk(KERN_ERR |
| "Port%d PHY access way check failed\n", src_port); |
| return retVal; |
| } |
| /* check swicth init or not */ |
| if (tpm_db_switch_init_get(&switch_init) != TPM_DB_OK) { |
| printk(KERN_ERR "ERROR: (%s:%d) tpm_db_switch_init_get Failed\n", __FUNCTION__, __LINE__); |
| retVal = ERR_GENERAL; |
| return retVal; |
| } |
| /* The routine only apply PHY connected to GMAC */ |
| if ((PHY_SMI_MASTER_CPU == phy_access_way) && |
| (!switch_init)) { |
| for (gmac_port = TPM_ENUM_GMAC_0; gmac_port < TPM_MAX_NUM_GMACS; gmac_port++) { |
| if (phy_direct_addr == mvBoardPhyAddrGet(gmac_port)) |
| break; |
| } |
| if (gmac_port == TPM_MAX_NUM_GMACS) { |
| printk(KERN_ERR "ERROR: (%s:%d) Can not find gmac port\n", __FUNCTION__, __LINE__); |
| retVal = ERR_GENERAL; |
| return retVal; |
| } |
| |
| if (auto_nego_en) {/* auto-nego enable */ |
| if (mvNetaSpeedDuplexSet((int)gmac_port, MV_ETH_SPEED_AN, MV_ETH_DUPLEX_AN) != MV_OK) { |
| printk(KERN_ERR "ERROR: (%s:%d) mvNetaSpeedDuplexSet Failed\n", __FUNCTION__, __LINE__); |
| retVal = ERR_GENERAL; |
| return retVal; |
| } |
| if (mvNetaFlowCtrlSet((int)gmac_port, MV_ETH_FC_AN_NO) != MV_OK){ |
| printk(KERN_ERR "ERROR: (%s:%d) mvNetaFlowCtrlSet Failed\n", __FUNCTION__, __LINE__); |
| retVal = ERR_GENERAL; |
| return retVal; |
| } |
| } else {/* auto-nego disable */ |
| retVal = tpm_phy_get_port_speed(owner_id, src_port, &cfg_speed); |
| if (retVal) { |
| printk(KERN_ERR "ERROR: (%s:%d) PHY speed config get failed\n", __FUNCTION__, __LINE__); |
| return retVal; |
| } |
| retVal = tpm_phy_get_port_duplex_mode(owner_id, src_port, &cfg_duplex); |
| if (retVal) { |
| printk(KERN_ERR "ERROR: (%s:%d) PHY duplex config get failed\n", __FUNCTION__, __LINE__); |
| return retVal; |
| } |
| retVal = tpm_phy_get_port_flow_control_support(owner_id, src_port, &cfg_fc); |
| if (retVal) { |
| printk(KERN_ERR "ERROR: (%s:%d) PHY flow control config get failed\n", __FUNCTION__, __LINE__); |
| return retVal; |
| } |
| if (mvNetaSpeedDuplexSet((int)gmac_port, |
| (cfg_speed + MV_ETH_SPEED_10), |
| (cfg_duplex ? MV_ETH_DUPLEX_FULL : MV_ETH_DUPLEX_HALF)) != MV_OK) { |
| printk(KERN_ERR "ERROR: (%s:%d) mvNetaSpeedDuplexSet Failed\n", __FUNCTION__, __LINE__); |
| retVal = ERR_GENERAL; |
| return retVal; |
| } |
| if (mvNetaFlowCtrlSet((int)gmac_port, (cfg_fc ? MV_ETH_FC_ENABLE : MV_ETH_FC_DISABLE)) != MV_OK) { |
| printk(KERN_ERR "ERROR: (%s:%d) mvNetaFlowCtrlSet Failed\n", __FUNCTION__, __LINE__); |
| retVal = ERR_GENERAL; |
| return retVal; |
| } |
| } |
| } |
| else if (PHY_SGMII != phy_access_way) |
| { |
| printk(KERN_ERR "PHY not connected to GMAC\n"); |
| retVal = ERR_GENERAL; |
| return retVal; |
| } |
| |
| return retVal; |
| } |
| |
| /******************************************************************************* |
| * tpm_sw_set_debug_trace_flag |
| * |
| * DESCRIPTION: |
| * This function sets TPM trace flag. |
| * |
| * INPUTS: |
| * enDis - enable or disable |
| * |
| * OUTPUTS: |
| * |
| * RETURNS: |
| * On success - TPM_RC_OK. |
| * On error different types are returned according to the case - see tpm_error_code_t. |
| * |
| * COMMENTS: |
| * NONE. |
| * |
| *******************************************************************************/ |
| tpm_error_code_t tpm_sw_set_debug_trace_flag |
| ( |
| uint32_t enDis |
| ) |
| { |
| trace_sw_dbg_flag = enDis; |
| return TPM_RC_OK; |
| } |
| |
| /******************************************************************************* |
| * tpm_sw_add_static_mac |
| * |
| * DESCRIPTION: |
| * This function creates a static MAC entry in the MAC address table for a |
| * specific UNI port in the integrated switch |
| * |
| * INPUTS: |
| * owner_id - APP owner id, should be used for all API calls. |
| * src_port - Source port in UNI port index, UNI0, UNI1...UNI4. |
| * static_mac - 6 byte network order MAC source address. |
| * |
| * OUTPUTS: |
| * None. |
| * |
| * RETURNS: |
| * On success - TPM_RC_OK. |
| * On error different types are returned according to the case - see tpm_error_code_t. |
| * |
| * COMMENTS: |
| * None. |
| * |
| *******************************************************************************/ |
| tpm_error_code_t tpm_sw_add_static_mac |
| ( |
| uint32_t owner_id, |
| tpm_src_port_type_t src_port, |
| uint8_t static_mac[6] |
| ) |
| { |
| tpm_error_code_t retVal = TPM_RC_OK; |
| int32_t lPort = 0; |
| tpm_gmacs_enum_t gmac_i; |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==ENTER==%s: owner_id[%d],src_port[%d]\n\r \ |
| static_mac[%02x:%02x:%02x:%02x:%02x:%02x]\n\r", |
| __FUNCTION__,owner_id,src_port, static_mac[0],static_mac[1],static_mac[2],static_mac[3],static_mac[4],static_mac[5]); |
| } |
| |
| if (tpm_sw_init_check()) { |
| if (tpm_src_port_mac_map(src_port, &gmac_i)) { |
| printk(KERN_ERR "ERROR: (%s:%d) source port(%d) map to mac failed\n", __FUNCTION__, __LINE__, src_port); |
| return ERR_SRC_PORT_INVALID; |
| } |
| /* Check GMAC1 lpk status, if no lpk, no way to add static MAC */ |
| #ifdef CONFIG_MV_MAC_LEARN |
| if (tpm_db_gmac1_lpbk_en_get()) |
| retVal = mv_mac_learn_static_entry_add(&(static_mac[0])); |
| else { |
| printk(KERN_ERR "ERROR: (%s:%d) src port(%d) MAC learn not supported\n", __FUNCTION__, __LINE__, src_port); |
| return ERR_GENERAL; |
| } |
| #endif |
| } else { |
| lPort = tpm_db_eth_port_switch_port_get(src_port); |
| if (lPort == TPM_DB_ERR_PORT_NUM) |
| { |
| printk(KERN_ERR "ERROR: (%s:%d) source port(%d) is invalid\n", __FUNCTION__, __LINE__, src_port); |
| return ERR_SRC_PORT_INVALID; |
| } |
| |
| retVal = mv_switch_add_static_mac(lPort, &(static_mac[0])); |
| } |
| if (retVal != TPM_RC_OK) |
| { |
| printk(KERN_ERR |
| "%s:%d: function failed\r\n", __FUNCTION__,__LINE__); |
| } |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==EXIT== %s:\n\r",__FUNCTION__); |
| } |
| |
| return retVal; |
| } |
| |
| /******************************************************************************* |
| * tpm_sw_del_static_mac |
| * |
| * DESCRIPTION: |
| * This function removes an existing static MAC entry from the MAC address |
| * table in the integrated switch. |
| * |
| * INPUTS: |
| * owner_id - APP owner id - should be used for all API calls. |
| * static_mac - 6byte network order MAC source address. |
| * |
| * OUTPUTS: |
| * None. |
| * |
| * RETURNS: |
| * On success - TPM_RC_OK. |
| * On error different types are returned according to the case - see tpm_error_code_t. |
| * |
| * COMMENTS: |
| * None. |
| * |
| *******************************************************************************/ |
| tpm_error_code_t tpm_sw_del_static_mac |
| ( |
| uint32_t owner_id, |
| uint8_t static_mac[6] |
| ) |
| { |
| tpm_error_code_t retVal = TPM_RC_OK; |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==ENTER==%s: owner_id[%d]\n\r, \ |
| static_mac[%02x:%02x:%02x:%02x:%02x:%02x]\n\r", |
| __FUNCTION__,owner_id,static_mac[0],static_mac[1],static_mac[2],static_mac[3],static_mac[4],static_mac[5]); |
| } |
| |
| if (tpm_sw_init_check()) { |
| /* Check GMAC1 lpk status, if no lpk, no way to add static MAC */ |
| #ifdef CONFIG_MV_MAC_LEARN |
| if (tpm_db_gmac1_lpbk_en_get()) |
| retVal = mv_mac_learn_static_entry_del(&(static_mac[0])); |
| else { |
| printk(KERN_ERR "ERROR: (%s:%d) MAC learn not supported\n", __FUNCTION__, __LINE__); |
| return ERR_GENERAL; |
| } |
| #endif |
| } else { |
| retVal = mv_switch_del_static_mac(&(static_mac[0])); |
| } |
| if (retVal != TPM_RC_OK) |
| { |
| printk(KERN_ERR |
| "%s:%d: function failed\r\n", __FUNCTION__,__LINE__); |
| } |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==EXIT== %s:\n\r",__FUNCTION__); |
| } |
| |
| return retVal; |
| } |
| |
| /******************************************************************************* |
| * tpm_sw_set_static_mac_w_ports_mask |
| * |
| * DESCRIPTION: |
| * This function creates or destory a static MAC entry in the MAC address |
| * table for several specific ports in the integrated switch |
| * |
| * INPUTS: |
| * owner_id - APP owner id - should be used for all API calls. |
| * ports_mask - Ports mask. |
| * static_mac - 6byte network order MAC source address. |
| * |
| * OUTPUTS: |
| * None. |
| * |
| * RETURNS: |
| * On success - TPM_RC_OK. |
| * On error different types are returned according to the case - see tpm_error_code_t. |
| * |
| * COMMENTS: |
| * None. |
| * |
| *******************************************************************************/ |
| tpm_error_code_t tpm_sw_set_static_mac_w_ports_mask |
| ( |
| uint32_t owner_id, |
| uint32_t ports_mask, |
| uint8_t static_mac[6] |
| ) |
| { |
| tpm_error_code_t retVal = TPM_RC_OK; |
| #ifdef CONFIG_MV_MAC_LEARN |
| static uint32_t mask_check = 1; |
| #endif |
| |
| SWITCH_INIT_CHECK(); |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==ENTER==%s: owner_id[%d],ports_mask[0x%x]\n\r"\ |
| "static_mac[%02x:%02x:%02x:%02x:%02x:%02x]\n\r", |
| __FUNCTION__,owner_id, |
| ports_mask, |
| static_mac[0], |
| static_mac[1], |
| static_mac[2], |
| static_mac[3], |
| static_mac[4], |
| static_mac[5]); |
| } |
| |
| if (tpm_sw_init_check()) { |
| /* Check GMAC1 lpk status, if no lpk, no way to add static MAC */ |
| #ifdef CONFIG_MV_MAC_LEARN |
| if (tpm_db_gmac1_lpbk_en_get()) { |
| if (ports_mask & mask_check) |
| retVal = mv_mac_learn_static_entry_add(&(static_mac[0])); |
| } else { |
| printk(KERN_ERR "ERROR: (%s:%d) MAC learn not supported\n", __FUNCTION__, __LINE__); |
| return ERR_GENERAL; |
| } |
| #endif |
| } else { |
| retVal = mv_switch_mac_addr_set(&(static_mac[0]), 0, ports_mask, 1); |
| } |
| if (retVal != TPM_RC_OK) |
| { |
| printk(KERN_ERR |
| "%s:%d: function failed\r\n", __FUNCTION__,__LINE__); |
| } |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==EXIT== %s:\n\r",__FUNCTION__); |
| } |
| |
| return retVal; |
| } |
| |
| /******************************************************************************* |
| * tpm_sw_set_trunk_ports |
| * |
| * DESCRIPTION: |
| * This function creates trunk ports and trunk id |
| * |
| * INPUTS: |
| * owner_id - APP owner id - should be used for all API calls. |
| * trunk_id - valid from 0x0 to 0xf |
| * ports_mask - mask for real switch port, not logical port like TPM_SRC_PORT_UNI_0. |
| * |
| * OUTPUTS: |
| * None. |
| * |
| * RETURNS: |
| * On success - TPM_RC_OK. |
| * On error different types are returned according to the case - see tpm_error_code_t. |
| * |
| * COMMENTS: |
| * None. |
| * |
| *******************************************************************************/ |
| tpm_error_code_t tpm_sw_set_trunk_ports |
| ( |
| uint32_t owner_id, |
| uint32_t trunk_id, |
| uint32_t ports_mask |
| ) |
| { |
| tpm_error_code_t ret; |
| uint16_t reg_tmp = 0; |
| uint32_t switch_port = 0; |
| |
| SWITCH_INIT_CHECK(); |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==ENTER==%s: owner_id[%d], trunk_id[0x%x], ports_mask[0x%x]\n\r", |
| __FUNCTION__, owner_id, trunk_id, ports_mask); |
| } |
| |
| if (trunk_id > SW_TRUNK_ID_MAX) |
| { |
| printk(KERN_INFO |
| "==ENTER==%s: trunk_id[0x%x] is bigger than [0x%x]\n\r", |
| __FUNCTION__,trunk_id, SW_TRUNK_ID_MAX); |
| } |
| |
| for (switch_port = 0; switch_port <= TPM_SWITCH_NUM_PORTS; switch_port++) |
| { |
| if(0 == (ports_mask & (1 << switch_port))) |
| { |
| continue; |
| } |
| |
| /* get trunk reg from HW */ |
| ret = mv_switch_reg_read(switch_port, SW_TRUNK_ID_REG, MV_SWITCH_PORT_ACCESS, ®_tmp); |
| if (0 != ret) { |
| TPM_OS_ERROR(TPM_INIT_MOD, "Fail to get trunk reg, ret(%d)\n", ret); |
| return (TPM_FAIL); |
| } |
| |
| /* set bits 8, 9 to 11, as trunk_id */ |
| SW_CLEAR_REG_BIT(reg_tmp, SW_TRUNK_ID_BIT_OFF, SW_TRUNK_ID_BIT_LEN); |
| reg_tmp |= (trunk_id << SW_TRUNK_ID_BIT_OFF); |
| /* set bit 14, as trunk bit */ |
| reg_tmp |= (1 << SW_TRUNK_BIT_OFF); |
| ret = mv_switch_reg_write(switch_port, SW_TRUNK_ID_REG, MV_SWITCH_PORT_ACCESS, reg_tmp); |
| if (0 != ret) { |
| TPM_OS_ERROR(TPM_INIT_MOD, "Fail to set trunk reg, ret(%d)\n", ret); |
| return (TPM_FAIL); |
| } |
| } |
| |
| /* get trunk mapping reg from HW */ |
| ret = mv_switch_reg_read(0, SW_TRUNK_MAPPING_REG, MV_SWITCH_GLOBAL2_ACCESS, ®_tmp); |
| if (0 != ret) { |
| TPM_OS_ERROR(TPM_INIT_MOD, "Fail to get trunk mapping reg, ret(%d)\n", ret); |
| return (TPM_FAIL); |
| } |
| |
| /* set bits 11 to 14, as trunk_id */ |
| SW_CLEAR_REG_BIT(reg_tmp, SW_TRUNK_MAPPING_ID_BIT_OFF, SW_TRUNK_ID_BIT_LEN); |
| reg_tmp |= (trunk_id << SW_TRUNK_MAPPING_ID_BIT_OFF); |
| |
| /* set bits 0 to 6, as trunk map */ |
| SW_CLEAR_REG_BIT(reg_tmp, SW_TRUNK_MAPPING_BIT_OFF, SW_TRUNK_MAPPING_BIT_LEN); |
| reg_tmp |= (ports_mask << SW_TRUNK_MAPPING_BIT_OFF); |
| |
| /* set bits 15, as udpate bit */ |
| reg_tmp |= (1 << SW_REG_UPDATE_BIT_OFF); |
| |
| ret = mv_switch_reg_write(0, SW_TRUNK_MAPPING_REG, MV_SWITCH_GLOBAL2_ACCESS, reg_tmp); |
| if (0 != ret) { |
| TPM_OS_ERROR(TPM_INIT_MOD, "Fail to set trunk mapping reg, ret(%d)\n", ret); |
| return (TPM_FAIL); |
| } |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==EXIT== %s:\n\r",__FUNCTION__); |
| } |
| |
| return ret; |
| } |
| |
| |
| /******************************************************************************* |
| * tpm_sw_set_trunk_mask |
| * |
| * DESCRIPTION: |
| * This function sets trunk mask |
| * |
| * INPUTS: |
| * owner_id - APP owner id - should be used for all API calls. |
| * mask_num - trunk mask number, valid from 0 to 7. |
| * trunk_mask - mask for real switch port, not logical port like TPM_SRC_PORT_UNI_0. |
| * |
| * OUTPUTS: |
| * None. |
| * |
| * RETURNS: |
| * On success - TPM_RC_OK. |
| * On error different types are returned according to the case - see tpm_error_code_t. |
| * |
| * COMMENTS: |
| * None. |
| * |
| *******************************************************************************/ |
| tpm_error_code_t tpm_sw_set_trunk_mask |
| ( |
| uint32_t owner_id, |
| uint32_t mask_num, |
| uint32_t trunk_mask |
| ) |
| { |
| tpm_error_code_t ret; |
| uint16_t reg_tmp = 0; |
| |
| SWITCH_INIT_CHECK(); |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==ENTER==%s: owner_id[%d],mask_num[0x%x],trunk_mask[0x%x]\n\r", |
| __FUNCTION__, owner_id, mask_num, trunk_mask); |
| } |
| |
| if (mask_num > SW_TRUNK_MASK_NUM_MAX) |
| { |
| printk(KERN_INFO |
| "==ENTER==%s: mask_num[0x%x] is bigger than [0x%x]\n\r", |
| __FUNCTION__,mask_num, SW_TRUNK_MASK_NUM_MAX); |
| } |
| |
| if (trunk_mask > SW_TRUNK_MASK_MAX) |
| { |
| printk(KERN_INFO |
| "==ENTER==%s: trunk_mask[0x%x] is bigger than [0x%x]\n\r", |
| __FUNCTION__,trunk_mask, SW_TRUNK_MASK_MAX); |
| } |
| |
| /* get trunk mask reg from HW */ |
| ret = mv_switch_reg_read(0, SW_TRUNK_MASK_REG, MV_SWITCH_GLOBAL2_ACCESS, ®_tmp); |
| if (0 != ret) { |
| TPM_OS_ERROR(TPM_INIT_MOD, "Fail to get trunk mask reg, ret(%d)\n", ret); |
| return (TPM_FAIL); |
| } |
| |
| /* set bits 11 to 14, as mask_num */ |
| SW_CLEAR_REG_BIT(reg_tmp, SW_TRUNK_MASK_NUM_BIT_OFF, SW_TRUNK_MASK_NUM_BIT_LEN); |
| reg_tmp |= (mask_num << SW_TRUNK_MASK_NUM_BIT_OFF); |
| |
| /* set bits 0 to 6, as trunk_mask */ |
| SW_CLEAR_REG_BIT(reg_tmp, SW_TRUNK_MASK_BIT_OFF, SW_TRUNK_MASK_BIT_LEN); |
| reg_tmp |= (trunk_mask << SW_TRUNK_MASK_BIT_OFF); |
| |
| /* set bits 15, as udpate bit */ |
| reg_tmp |= (1 << SW_REG_UPDATE_BIT_OFF); |
| |
| ret = mv_switch_reg_write(0, SW_TRUNK_MASK_REG, MV_SWITCH_GLOBAL2_ACCESS, reg_tmp); |
| if (0 != ret) { |
| TPM_OS_ERROR(TPM_INIT_MOD, "Fail to set trunk mask reg, ret(%d)\n", ret); |
| return (TPM_FAIL); |
| } |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==EXIT== %s:\n\r",__FUNCTION__); |
| } |
| |
| return ret; |
| } |
| |
| /******************************************************************************* |
| * tpm_sw_clear_dynamic_mac |
| * |
| * DESCRIPTION: |
| * Clear all dynamic MAC. |
| * |
| * INPUTS: |
| * owner_id - APP owner id , should be used for all API calls. |
| * |
| * OUTPUTS: |
| * |
| * RETURNS: |
| * On success - TPM_RC_OK. |
| * On error different types are returned according to the case , see tpm_error_code_t. |
| * |
| * COMMENTS: |
| * None |
| * |
| *******************************************************************************/ |
| tpm_error_code_t tpm_sw_clear_dynamic_mac( uint32_t owner_id) |
| { |
| tpm_error_code_t retVal; |
| |
| SWITCH_INIT_CHECK(); |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==ENTER==%s: owner_id[%d]\n\r", __FUNCTION__, owner_id); |
| } |
| |
| retVal = mv_switch_clear_dynamic_mac(); |
| if (retVal != TPM_RC_OK) |
| { |
| printk(KERN_ERR |
| "%s:%d: function failed\r\n", __FUNCTION__,__LINE__); |
| } |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==EXIT== %s:\n\r",__FUNCTION__); |
| } |
| |
| return retVal; |
| } |
| |
| /******************************************************************************* |
| * tpm_sw_set_port_mirror |
| * |
| * DESCRIPTION: |
| * Set port mirror. |
| * |
| * INPUTS: |
| * owner_id - APP owner id , should be used for all API calls. |
| * sport - Source port. |
| * dport - Destination port. |
| * mode - mirror mode. |
| * enable - enable/disable mirror. |
| * |
| * OUTPUTS: |
| * None |
| * RETURNS: |
| * On success - TPM_RC_OK. |
| * On error different types are returned according to the case , see tpm_error_code_t. |
| * |
| * COMMENTS: |
| * None |
| * |
| *******************************************************************************/ |
| tpm_error_code_t tpm_sw_set_port_mirror |
| ( |
| uint32_t owner_id, |
| uint32_t sport, |
| uint32_t dport, |
| tpm_sw_mirror_type_t mode, |
| bool enable |
| ) |
| { |
| tpm_error_code_t retVal; |
| GT_BOOL state; |
| uint32_t sw_sport; |
| uint32_t sw_dport; |
| |
| SWITCH_INIT_CHECK(); |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==ENTER==%s: owner_id[%d] sport[%d] dport[%d] mode[%d] enable[%d]\n\r", |
| __FUNCTION__, owner_id, tpm_db_eth_port_switch_port_get(sport), |
| tpm_db_eth_port_switch_port_get(dport), mode, enable); |
| } |
| |
| if(enable == true) |
| state = GT_TRUE; |
| else |
| state = GT_FALSE; |
| |
| sw_sport = tpm_db_eth_port_switch_port_get(sport); |
| sw_dport = tpm_db_eth_port_switch_port_get(dport); |
| |
| if (TPM_DB_ERR_PORT_NUM == sw_sport || TPM_DB_ERR_PORT_NUM == sw_dport){ |
| TPM_OS_ERROR(TPM_INIT_MOD, "invalid port (sw_sport %d, sw_dport %d)\n", sw_sport, sw_dport); |
| return GT_FAIL; |
| } |
| |
| retVal = mv_switch_set_mirror(sw_sport, sw_dport, (GT_MIRROR_MODE)mode, state); |
| if (retVal != TPM_RC_OK) |
| { |
| printk(KERN_ERR |
| "%s:%d: function failed\r\n", __FUNCTION__,__LINE__); |
| } |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==EXIT== %s:\n\r",__FUNCTION__); |
| } |
| |
| return retVal; |
| } |
| |
| /******************************************************************************* |
| * tpm_sw_get_port_mirror |
| * |
| * DESCRIPTION: |
| * Get port mirror status. |
| * |
| * INPUTS: |
| * owner_id - APP owner id , should be used for all API calls. |
| * sport - Source port. |
| * dport - Destination port. |
| * mode - mirror mode. |
| * |
| * OUTPUTS: |
| * enable - enable/disable mirror. |
| * |
| * RETURNS: |
| * On success - TPM_RC_OK. |
| * On error different types are returned according to the case , see tpm_error_code_t. |
| * |
| * COMMENTS: |
| * None |
| * |
| *******************************************************************************/ |
| tpm_error_code_t tpm_sw_get_port_mirror |
| ( |
| uint32_t owner_id, |
| uint32_t sport, |
| uint32_t dport, |
| tpm_sw_mirror_type_t mode, |
| bool *enable |
| ) |
| { |
| tpm_error_code_t retVal; |
| GT_BOOL state; |
| |
| SWITCH_INIT_CHECK(); |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==ENTER==%s: owner_id[%d] sport[%d] dport[%d] mode[%d] \n\r", |
| __FUNCTION__, owner_id, tpm_db_eth_port_switch_port_get(sport), |
| tpm_db_eth_port_switch_port_get(dport), mode); |
| } |
| |
| retVal = mv_switch_get_mirror(tpm_db_eth_port_switch_port_get(sport), |
| tpm_db_eth_port_switch_port_get(dport), |
| (GT_MIRROR_MODE)mode, &state); |
| if (retVal != TPM_RC_OK) |
| { |
| printk(KERN_ERR |
| "%s:%d: function failed\r\n", __FUNCTION__,__LINE__); |
| } |
| |
| if(state == GT_FALSE) |
| *enable = false; |
| else |
| *enable = true; |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==EXIT== %s: enable[%d]\n\r",__FUNCTION__, *enable); |
| } |
| |
| return retVal; |
| } |
| |
| /******************************************************************************* |
| * tpm_sw_set_isolate_eth_port_vector() |
| * |
| * DESCRIPTION: Isolate port vector. |
| * |
| * INPUTS: |
| * owner_id - APP owner id should be used for all API calls. |
| * src_port - Source port in UNI port index, UNI0, UNI1...UNI4. |
| * port_vector - port vector. |
| * |
| * OUTPUTS: |
| * None. |
| * |
| * RETURNS: |
| * On success, the function returns TPM_RC_OK. On error different types are returned |
| * according to the case - see tpm_error_code_t. |
| * |
| *******************************************************************************/ |
| tpm_error_code_t tpm_sw_set_isolate_eth_port_vector |
| ( |
| uint32_t owner_id, |
| tpm_src_port_type_t src_port, |
| uint32_t port_vector |
| ) |
| { |
| #define MEM_PORTS_NR 7 |
| tpm_error_code_t retVal = TPM_RC_OK; |
| int32_t lPort = 0; |
| uint32_t memPorts[MEM_PORTS_NR] = {1}; |
| uint32_t i = 0; |
| uint8_t memPortsLen = MEM_PORTS_NR; |
| uint32_t sw_port_num; |
| |
| SWITCH_INIT_CHECK(); |
| |
| memset(memPorts, 1, sizeof(memPorts)); |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==ENTER==%s: owner_id[%d] src_port[%d] port_vector[%d]\n\r", |
| __FUNCTION__, owner_id, src_port, port_vector); |
| } |
| |
| lPort = tpm_db_eth_port_switch_port_get(src_port); |
| if (lPort == TPM_DB_ERR_PORT_NUM) |
| { |
| printk(KERN_ERR "ERROR: (%s:%d) source port(%d) is invalid\n", __FUNCTION__, __LINE__, src_port); |
| return ERR_SRC_PORT_INVALID; |
| } |
| |
| /*Init port list*/ |
| for(i=0; i<MEM_PORTS_NR; i++) |
| { |
| memPorts[i] = i; |
| } |
| |
| for (i=TPM_SRC_PORT_UNI_0; i<TPM_MAX_NUM_UNI_PORTS; i++) |
| { |
| sw_port_num = tpm_db_eth_port_switch_port_get(i); |
| |
| if (TPM_DB_ERR_PORT_NUM == sw_port_num) |
| continue; |
| |
| if (sw_port_num >= MEM_PORTS_NR) { |
| TPM_OS_ERROR(TPM_INIT_MOD, "sw_port_num too big! (%d >= MEM_PORTS_NR) \n", sw_port_num); |
| return ERR_SRC_PORT_INVALID; |
| } |
| |
| if(port_vector & (1 << i)) |
| { |
| memPorts[sw_port_num] = sw_port_num; |
| } |
| else |
| { |
| memPorts[sw_port_num] = 0x80; |
| } |
| } |
| |
| /*set VLAN member*/ |
| retVal = mv_switch_set_port_vlan_ports(lPort, memPorts, memPortsLen); |
| if (retVal != TPM_RC_OK) |
| { |
| printk(KERN_ERR |
| "%s:%d: function failed\r\n", __FUNCTION__,__LINE__); |
| } |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==EXIT== %s \n\r",__FUNCTION__); |
| } |
| |
| return retVal; |
| } |
| |
| /******************************************************************************* |
| * tpm_sw_get_isolate_eth_port_vector() |
| * |
| * DESCRIPTION: Isolate port vector. |
| * |
| * INPUTS: |
| * owner_id - APP owner id should be used for all API calls. |
| * src_port - Source port in UNI port index, UNI0, UNI1...UNI4. |
| * |
| * OUTPUTS: |
| * port_vector - port vector. |
| * |
| * RETURNS: |
| * On success, the function returns TPM_RC_OK. On error different types are returned |
| * according to the case - see tpm_error_code_t. |
| * |
| *******************************************************************************/ |
| tpm_error_code_t tpm_sw_get_isolate_eth_port_vector |
| ( |
| uint32_t owner_id, |
| tpm_src_port_type_t src_port, |
| uint32_t *port_vector |
| ) |
| { |
| tpm_error_code_t retVal = TPM_RC_OK; |
| int32_t lPort = 0; |
| uint32_t memPorts[7] = {0x80}; |
| uint32_t i = 0; |
| uint8_t memPortsLen = 7; |
| uint32_t sw_port_num; |
| uint32_t vector = 0; |
| |
| SWITCH_INIT_CHECK(); |
| |
| memset(memPorts, 1, sizeof(memPorts)); |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==ENTER==%s: owner_id[%d] src_port[%d] \n\r", |
| __FUNCTION__, owner_id, src_port); |
| } |
| |
| lPort = tpm_db_eth_port_switch_port_get(src_port); |
| if (lPort == TPM_DB_ERR_PORT_NUM) |
| { |
| printk(KERN_ERR "ERROR: (%s:%d) source port(%d) is invalid\n", __FUNCTION__, __LINE__, src_port); |
| return ERR_SRC_PORT_INVALID; |
| } |
| |
| /*get VLAN member*/ |
| retVal = mv_switch_get_port_vlan_ports(lPort, memPorts, &memPortsLen); |
| if (retVal != TPM_RC_OK) |
| { |
| printk(KERN_ERR |
| "%s:%d: function failed\r\n", __FUNCTION__,__LINE__); |
| } |
| |
| for(i=TPM_SRC_PORT_UNI_0; i<TPM_MAX_NUM_ETH_PORTS; i++) |
| { |
| sw_port_num = tpm_db_eth_port_switch_port_get(i); |
| if (TPM_DB_ERR_PORT_NUM == sw_port_num) |
| continue; |
| |
| if(memPorts[sw_port_num] == sw_port_num) |
| { |
| vector |= (1 << (i-1)); |
| } |
| } |
| |
| *port_vector = vector & 0x0000000F; |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==EXIT== %s: port_vector[%d]\n\r",__FUNCTION__, *port_vector); |
| } |
| |
| return retVal; |
| } |
| |
| /******************************************************************************* |
| * tpm_set_mtu_size |
| * |
| * DESCRIPTION: |
| * Set switch MTU size. |
| * |
| * INPUTS: |
| * owner_id - APP owner id , should be used for all API calls. |
| * type - MRU type:GMAC0, GMAC1, PONMAC, switch |
| * mtu - MTU size. |
| * |
| * OUTPUTS: |
| * None |
| * |
| * RETURNS: |
| * On success - TPM_RC_OK. |
| * On error different types are returned according to the case , see tpm_error_code_t. |
| * |
| * COMMENTS: |
| * None |
| * |
| *******************************************************************************/ |
| tpm_error_code_t tpm_set_mtu_size |
| ( |
| uint32_t owner_id, |
| tpm_mru_type_t type, |
| uint32_t mtu |
| ) |
| { |
| tpm_error_code_t retVal = TPM_RC_OK; |
| uint32_t switch_init = 0; |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==ENTER==%s: owner_id[%d],type[%d],mtu[%d]\r\n", |
| __FUNCTION__, owner_id, type, mtu); |
| |
| } |
| |
| switch(type) |
| { |
| case TPM_NETA_MTU_GMAC0: |
| /*GMAC0 port number: 0*/ |
| retVal = mv_eth_set_mtu(0, mtu); |
| break; |
| case TPM_NETA_MTU_GMAC1: |
| /*GMAC1 port number: 1*/ |
| retVal = mv_eth_set_mtu(1, mtu); |
| break; |
| case TPM_NETA_MTU_PONMAC: |
| /*PON GMAC port number: 2*/ |
| retVal = mv_eth_set_mtu(2, mtu); |
| break; |
| case TPM_NETA_MTU_SWITCH: |
| /*Set switch MTU if exist*/ |
| tpm_db_switch_init_get(&switch_init); |
| if (switch_init) |
| retVal = mv_switch_set_mtu(mtu); |
| break; |
| default: |
| break; |
| } |
| |
| if (retVal != TPM_RC_OK) |
| { |
| printk(KERN_ERR |
| "%s:%d: function failed\r\n", __FUNCTION__,__LINE__); |
| } |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==EXIT== %s:\n\r",__FUNCTION__); |
| } |
| |
| return retVal; |
| } |
| |
| /******************************************************************************* |
| * tpm_get_mtu_size |
| * |
| * DESCRIPTION: |
| * Get switch MTU size. |
| * |
| * INPUTS: |
| * owner_id - APP owner id , should be used for all API calls. |
| * type - MRU type:GMAC0, GMAC1, PONMAC, switch |
| * |
| * OUTPUTS: |
| * mtu - MTU size. |
| * |
| * RETURNS: |
| * On success - TPM_RC_OK. |
| * On error different types are returned according to the case , see tpm_error_code_t. |
| * |
| * COMMENTS: |
| * None |
| * |
| *******************************************************************************/ |
| tpm_error_code_t tpm_get_mtu_size |
| ( |
| uint32_t owner_id, |
| tpm_mru_type_t type, |
| uint32_t *mtu |
| ) |
| { |
| tpm_error_code_t retVal = TPM_RC_OK; |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==ENTER==%s: owner_id[%d],type[%d],", |
| __FUNCTION__,owner_id, type); |
| |
| } |
| |
| switch(type) |
| { |
| case TPM_NETA_MTU_GMAC0: |
| /*GMAC0 port number: 0*/ |
| retVal = mv_eth_get_mtu(0, mtu); |
| break; |
| case TPM_NETA_MTU_GMAC1: |
| /*GMAC1 port number: 1*/ |
| retVal = mv_eth_get_mtu(1, mtu); |
| break; |
| case TPM_NETA_MTU_PONMAC: |
| /*PON GMAC port number: 2*/ |
| retVal = mv_eth_get_mtu(2, mtu); |
| break; |
| case TPM_NETA_MTU_SWITCH: |
| /*Get switch MTU if exist*/ |
| if (!tpm_sw_init_check()) |
| retVal = mv_switch_get_mtu(mtu); |
| else |
| retVal = ERR_GENERAL; |
| break; |
| default: |
| break; |
| } |
| |
| if (retVal != TPM_RC_OK) |
| { |
| printk(KERN_ERR |
| "%s:%d: function failed\r\n", __FUNCTION__,__LINE__); |
| } |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==EXIT== %s:mtu[%d]\n\r",__FUNCTION__, *mtu); |
| } |
| |
| return retVal; |
| } |
| |
| /******************************************************************************* |
| * tpm_sw_set_port_max_macs |
| * |
| * DESCRIPTION: |
| * This function limits the number of MAC addresses per src_port. |
| * |
| * INPUTS: |
| * owner_id - APP owner id - should be used for all API calls. |
| * src_port - Source port in UNI port index, UNI0, UNI1...UNI4. |
| * mac_per_port - maximum number of MAC addresses per port (1-255). |
| * |
| * OUTPUTS: |
| * None. |
| * |
| * RETURNS: |
| * On success - TPM_RC_OK. |
| * On error different types are returned according to the case - see tpm_error_code_t. |
| * |
| * COMMENTS: |
| * The following care is needed when enabling this feature: |
| * 1) disable learning on the ports |
| * 2) flush all non-static addresses in the ATU |
| * 3) define the desired limit for the ports |
| * 4) re-enable learing on the ports |
| * |
| *******************************************************************************/ |
| tpm_error_code_t tpm_sw_set_port_max_macs |
| ( |
| uint32_t owner_id, |
| tpm_src_port_type_t src_port, |
| uint8_t mac_per_port |
| ) |
| { |
| tpm_error_code_t retVal = TPM_RC_OK; |
| int32_t lPort = 0; |
| tpm_gmacs_enum_t gmac_i; |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==ENTER==%s: owner_id[%d],src_port[%d],mac_per_port[%d]\r\n", |
| __FUNCTION__, owner_id, src_port, mac_per_port); |
| } |
| |
| if (tpm_sw_init_check()) { |
| if (tpm_src_port_mac_map(src_port, &gmac_i)) { |
| printk(KERN_ERR "ERROR: (%s:%d) source port(%d) map to mac failed\n", __FUNCTION__, __LINE__, src_port); |
| return ERR_SRC_PORT_INVALID; |
| } |
| #ifdef CONFIG_MV_MAC_LEARN |
| /* Check GMAC1 lpk status, if no lpk, no way to add static MAC */ |
| if (tpm_db_gmac1_lpbk_en_get()) |
| retVal = mv_mac_learn_max_count_set(mac_per_port); |
| else { |
| printk(KERN_ERR "ERROR: (%s:%d) src port(%d) MAC learn not supported\n", __FUNCTION__, __LINE__, src_port); |
| return ERR_GENERAL; |
| } |
| #endif |
| } else { |
| lPort = tpm_db_eth_port_switch_port_get(src_port); |
| if (lPort == TPM_DB_ERR_PORT_NUM) |
| { |
| printk(KERN_ERR "ERROR: (%s:%d) source port(%d) is invalid\n", __FUNCTION__, __LINE__, src_port); |
| return ERR_SRC_PORT_INVALID; |
| } |
| |
| retVal = mv_switch_set_port_max_macs(lPort, mac_per_port); |
| } |
| if (retVal != TPM_RC_OK) |
| { |
| printk(KERN_ERR |
| "%s:%d: function failed\r\n", __FUNCTION__,__LINE__); |
| } |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==EXIT== %s:\n\r",__FUNCTION__); |
| } |
| |
| return retVal; |
| } |
| |
| /******************************************************************************* |
| * tpm_sw_get_port_max_macs |
| * |
| * DESCRIPTION: |
| * Port's auto learning limit. When the limit is non-zero value, the number |
| * of MAC addresses that can be learned on this UNI port are limited to the value |
| * specified in this API. When the learn limit has been reached any frame |
| * that ingresses this UNI port with a source MAC address not already in the |
| * address database that is associated with this UNI port will be discarded. |
| * Normal auto-learning will resume on the UNI port as soon as the number of |
| * active unicast MAC addresses associated to this UNI port is less than the |
| * learn limit. |
| * CPU directed ATU Load, Purge, or Move will not have any effect on the |
| * learn limit. |
| * This feature is disabled when the limit is zero. |
| * The following care is needed when enabling this feature: |
| * 1) dsable learning on the ports |
| * 2) flush all non-static addresses in the ATU |
| * 3) define the desired limit for the ports |
| * 4) re-enable learing on the ports |
| * |
| * INPUTS: |
| * owner_id - APP owner id - should be used for all API calls. |
| * src_port - Source port in UNI port index, UNI0, UNI1...UNI4. |
| * |
| * |
| * OUTPUTS: |
| * limit - maximum number of MAC addresses per UNI port (1-255). |
| * |
| * RETURNS: |
| * On success - TPM_RC_OK. |
| * On error different types are returned according to the case - see tpm_error_code_t. |
| * |
| * COMMENTS: |
| * None. |
| * |
| *******************************************************************************/ |
| tpm_error_code_t tpm_sw_get_port_max_macs |
| ( |
| uint32_t owner_id, |
| tpm_src_port_type_t src_port, |
| uint32_t *limit |
| ) |
| { |
| tpm_error_code_t retVal = TPM_RC_OK; |
| int32_t lPort = 0; |
| tpm_gmacs_enum_t gmac_i; |
| tpm_db_pnc_range_conf_t range_conf; |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==ENTER==%s: owner_id[%d],src_port[%d]\r\n", |
| __FUNCTION__,owner_id,src_port); |
| } |
| |
| if (tpm_sw_init_check()) { |
| if (tpm_src_port_mac_map(src_port, &gmac_i)) { |
| printk(KERN_ERR "ERROR: (%s:%d) source port(%d) map to mac failed\n", __FUNCTION__, __LINE__, src_port); |
| return ERR_SRC_PORT_INVALID; |
| } |
| /* Check GMAC1 lpk status */ |
| if (tpm_db_gmac1_lpbk_en_get()) { |
| if (tpm_db_pnc_rng_conf_get(TPM_PNC_MAC_LEARN, &range_conf)) { |
| printk(KERN_ERR "ERROR: (%s:%d) tpm_db_pnc_rng_conf_get failed\n", __FUNCTION__, __LINE__); |
| return ERR_GENERAL; |
| } |
| *limit = range_conf.api_end - range_conf.api_start + 1; |
| if (*limit > MAC_LEARN_FDB_MAX_COUNT) |
| *limit = MAC_LEARN_FDB_MAX_COUNT; |
| } else { |
| printk(KERN_ERR "ERROR: (%s:%d) src port(%d) MAC learn not supported\n", __FUNCTION__, __LINE__, src_port); |
| return ERR_GENERAL; |
| } |
| } else { |
| lPort = tpm_db_eth_port_switch_port_get(src_port); |
| if (lPort == TPM_DB_ERR_PORT_NUM) |
| { |
| printk(KERN_ERR "ERROR: (%s:%d) source port(%d) is invalid\n", __FUNCTION__, __LINE__, src_port); |
| return ERR_SRC_PORT_INVALID; |
| } |
| |
| retVal = mv_switch_get_port_max_macs(lPort, limit); |
| } |
| if (retVal != TPM_RC_OK) |
| { |
| printk(KERN_ERR |
| "%s:%d: function failed\r\n", __FUNCTION__,__LINE__); |
| } |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==EXIT== %s: limit[%d]\n\r", |
| __FUNCTION__,*limit); |
| } |
| |
| return retVal; |
| } |
| |
| /******************************************************************************* |
| * tpm_sw_set_port_tagged |
| * |
| * DESCRIPTION: |
| * The API allows or drops tagged packets on a per UNI port basis. |
| * |
| * INPUTS: |
| * owner_id - APP owner id - should be used for all API calls. |
| * src_port - Source port in UNI port index, UNI0, UNI1...UNI4. |
| * drop_tagged - set to 1 = drop tagged packets per UNI port |
| * set to 0 = allow tagged packets per UNI port. |
| * |
| * OUTPUTS: |
| * None. |
| * |
| * RETURNS: |
| * On success - TPM_RC_OK. |
| * On error different types are returned according to the case - see tpm_error_code_t. |
| * |
| * COMMENTS: |
| * None. |
| * |
| *******************************************************************************/ |
| tpm_error_code_t tpm_sw_set_port_tagged |
| ( |
| uint32_t owner_id, |
| tpm_src_port_type_t src_port, |
| uint8_t drop_tagged |
| ) |
| { |
| tpm_error_code_t retVal = TPM_RC_OK; |
| int32_t lPort = 0; |
| GT_BOOL mode; |
| |
| SWITCH_INIT_CHECK(); |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==ENTER==%s: owner_id[%d],src_port[%d],drop_tagged[%d]\r\n", |
| __FUNCTION__,owner_id,src_port,drop_tagged); |
| |
| } |
| |
| lPort = tpm_db_eth_port_switch_port_get(src_port); |
| if (lPort == TPM_DB_ERR_PORT_NUM) |
| { |
| printk(KERN_ERR "ERROR: (%s:%d) source port(%d) is invalid\n", __FUNCTION__, __LINE__, src_port); |
| return ERR_SRC_PORT_INVALID; |
| } |
| |
| if (drop_tagged == 1) |
| { |
| mode = 1/*GT_TRUE*/; |
| } |
| else |
| { |
| mode = MV_FALSE; |
| } |
| |
| retVal = mv_switch_set_port_tagged(lPort, mode); |
| if (retVal != TPM_RC_OK) |
| { |
| printk(KERN_ERR |
| "%s:%d: function failed\r\n", __FUNCTION__,__LINE__); |
| } |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==EXIT== %s:\n\r",__FUNCTION__); |
| } |
| |
| return retVal; |
| } |
| |
| /******************************************************************************* |
| * tpm_sw_get_port_tagged |
| * |
| * DESCRIPTION: |
| * This routine gets DiscardTagged bit for the given UNI port. |
| * |
| * INPUTS: |
| * owner_id - APP owner id - should be used for all API calls. |
| * src_port - Source port in UNI port index, UNI0, UNI1...UNI4. |
| * |
| * OUTPUTS: |
| * mode - MV_TRUE if DiscardTagged bit is set, MV_FALSE otherwise |
| * |
| * RETURNS: |
| * On success - TPM_RC_OK. |
| * On error different types are returned according to the case - see tpm_error_code_t. |
| * |
| * COMMENTS: |
| * None. |
| * |
| *******************************************************************************/ |
| tpm_error_code_t tpm_sw_get_port_tagged |
| ( |
| uint32_t owner_id, |
| tpm_src_port_type_t src_port, |
| uint32_t *mode |
| ) |
| { |
| tpm_error_code_t retVal = TPM_RC_OK; |
| int32_t lPort = 0; |
| |
| SWITCH_INIT_CHECK(); |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==ENTER==%s: owner_id[%d],src_port[%d]\r\n", |
| __FUNCTION__,owner_id,src_port); |
| } |
| |
| lPort = tpm_db_eth_port_switch_port_get(src_port); |
| if (lPort == TPM_DB_ERR_PORT_NUM) |
| { |
| printk(KERN_ERR "ERROR: (%s:%d) source port(%d) is invalid\n", __FUNCTION__, __LINE__, src_port); |
| return ERR_SRC_PORT_INVALID; |
| } |
| |
| retVal = mv_switch_get_port_tagged(lPort, mode); |
| if (retVal != TPM_RC_OK) |
| { |
| printk(KERN_ERR |
| "%s:%d: function failed\r\n", __FUNCTION__,__LINE__); |
| } |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==EXIT== %s:mode[%d]\n\r",__FUNCTION__,*mode); |
| } |
| |
| return retVal; |
| } |
| |
| /******************************************************************************* |
| * tpm_sw_set_port_untagged |
| * |
| * DESCRIPTION: |
| * The API allows or drops untagged packets on a per UNI port basis. |
| * |
| * INPUTS: |
| * owner_id - APP owner id - should be used for all API calls. |
| * src_port - Source port in UNI port index, UNI0, UNI1...UNI4. |
| * drop_untagged - set to 1 = drop untagged packets per UNI port |
| * set to 0 = alow untagged packets per UNI port. |
| * |
| * OUTPUTS: |
| * None. |
| * |
| * RETURNS: |
| * On success - TPM_RC_OK. |
| * On error different types are returned according to the case - see tpm_error_code_t. |
| * |
| * COMMENTS: |
| * None. |
| * |
| *******************************************************************************/ |
| tpm_error_code_t tpm_sw_set_port_untagged |
| ( |
| uint32_t owner_id, |
| tpm_src_port_type_t src_port, |
| uint8_t drop_untagged |
| ) |
| { |
| tpm_error_code_t retVal = TPM_RC_OK; |
| int32_t lPort = 0; |
| GT_BOOL mode; |
| |
| SWITCH_INIT_CHECK(); |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==ENTER==%s: owner_id[%d],src_port[%d],drop_untagged[%d]\r\n", |
| __FUNCTION__,owner_id,src_port,drop_untagged); |
| } |
| |
| if (drop_untagged == 1) |
| { |
| mode = 1/*GT_TRUE*/; |
| } |
| else |
| { |
| mode = MV_FALSE; |
| } |
| |
| lPort = tpm_db_eth_port_switch_port_get(src_port); |
| if (lPort == TPM_DB_ERR_PORT_NUM) |
| { |
| printk(KERN_ERR "ERROR: (%s:%d) source port(%d) is invalid\n", __FUNCTION__, __LINE__, src_port); |
| return ERR_SRC_PORT_INVALID; |
| } |
| |
| retVal = mv_switch_set_port_untagged(lPort, mode); |
| if (retVal != TPM_RC_OK) |
| { |
| printk(KERN_ERR |
| "%s:%d: function failed\r\n", __FUNCTION__,__LINE__); |
| } |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==EXIT== %s:\n\r",__FUNCTION__); |
| } |
| |
| return retVal; |
| } |
| |
| /******************************************************************************* |
| * tpm_sw_get_port_untagged |
| * |
| * DESCRIPTION: |
| * This routine gets DiscardUntagged bit for the given UNI port. |
| * |
| * INPUTS: |
| * owner_id - APP owner id - should be used for all API calls. |
| * src_port - Source port in UNI port index, UNI0, UNI1...UNI4. |
| * |
| * OUTPUTS: |
| * mode - MV_TRUE if DiscardUntagged bit is set, MV_FALSE otherwise |
| * |
| * RETURNS: |
| * On success - TPM_RC_OK. |
| * On error different types are returned according to the case - see tpm_error_code_t. |
| * |
| * COMMENTS: |
| * None. |
| * |
| *******************************************************************************/ |
| tpm_error_code_t tpm_sw_get_port_untagged |
| ( |
| uint32_t owner_id, |
| tpm_src_port_type_t src_port, |
| uint32_t *mode |
| ) |
| { |
| tpm_error_code_t retVal = TPM_RC_OK; |
| int32_t lPort = 0; |
| |
| SWITCH_INIT_CHECK(); |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==ENTER==%s: owner_id[%d],src_port[%d]\r\n", |
| __FUNCTION__,owner_id,src_port); |
| } |
| |
| lPort = tpm_db_eth_port_switch_port_get(src_port); |
| if (lPort == TPM_DB_ERR_PORT_NUM) |
| { |
| printk(KERN_ERR "ERROR: (%s:%d) source port(%d) is invalid\n", __FUNCTION__, __LINE__, src_port); |
| return ERR_SRC_PORT_INVALID; |
| } |
| |
| retVal = mv_switch_get_port_untagged(lPort, mode); |
| if (retVal != TPM_RC_OK) |
| { |
| printk(KERN_ERR |
| "%s:%d: function failed\r\n", __FUNCTION__,__LINE__); |
| } |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==EXIT== %s:mode[%d]\n\r", |
| __FUNCTION__,*mode); |
| } |
| |
| return retVal; |
| } |
| |
| /******************************************************************************* |
| * tpm_sw_set_port_def_vlan |
| * |
| * DESCRIPTION: |
| * The API sets port default vlan id. |
| * |
| * INPUTS: |
| * owner_id - APP owner id - should be used for all API calls. |
| * src_port - Source port in UNI port index, UNI0, UNI1...UNI4. |
| * vid - the port vlan id. |
| * |
| * OUTPUTS: |
| * None. |
| * |
| * RETURNS: |
| * On success - TPM_RC_OK. |
| * On error different types are returned according to the case - see tpm_error_code_t. |
| * |
| * COMMENTS: |
| * None. |
| * |
| *******************************************************************************/ |
| tpm_error_code_t tpm_sw_set_port_def_vlan |
| ( |
| uint32_t owner_id, |
| tpm_src_port_type_t src_port, |
| uint16_t vid |
| ) |
| { |
| tpm_error_code_t retVal = TPM_RC_OK; |
| int32_t lPort = 0; |
| |
| SWITCH_INIT_CHECK(); |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==ENTER==%s: owner_id[%d],src_port[%d],vid[%d]\r\n", |
| __FUNCTION__,owner_id,src_port,vid); |
| } |
| |
| lPort = tpm_db_eth_port_switch_port_get(src_port); |
| if (lPort == TPM_DB_ERR_PORT_NUM) |
| { |
| printk(KERN_ERR "ERROR: (%s:%d) source port(%d) is invalid\n", __FUNCTION__, __LINE__, src_port); |
| return ERR_SRC_PORT_INVALID; |
| } |
| |
| if (vid > 4095) |
| { |
| printk(KERN_ERR |
| "%s:illegal VID[%d]\r\n", __FUNCTION__, vid); |
| return ERR_SW_VID_INVALID; |
| } |
| |
| retVal = mv_switch_set_port_def_vlan(lPort, vid); |
| if (retVal != TPM_RC_OK) |
| { |
| printk(KERN_ERR |
| "%s:%d: function failed\r\n", __FUNCTION__,__LINE__); |
| } |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==EXIT== %s:\n\r",__FUNCTION__); |
| } |
| |
| return retVal; |
| } |
| |
| /******************************************************************************* |
| * tpm_sw_get_port_def_vlan |
| * |
| * DESCRIPTION: |
| * The API gets port default vlan id. |
| * |
| * INPUTS: |
| * owner_id - APP owner id - should be used for all API calls. |
| * src_port - Source port in UNI port index, UNI0, UNI1...UNI4. |
| * |
| * OUTPUTS: |
| * vid - the port vlan id |
| * |
| * RETURNS: |
| * On success - TPM_RC_OK. |
| * On error different types are returned according to the case - see tpm_error_code_t. |
| * |
| * COMMENTS: |
| * None. |
| * |
| *******************************************************************************/ |
| tpm_error_code_t tpm_sw_get_port_def_vlan |
| ( |
| uint32_t owner_id, |
| tpm_src_port_type_t src_port, |
| uint16_t *vid |
| ) |
| { |
| tpm_error_code_t retVal = TPM_RC_OK; |
| int32_t lPort = 0; |
| |
| SWITCH_INIT_CHECK(); |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==ENTER==%s: owner_id[%d],src_port[%d]\r\n", |
| __FUNCTION__,owner_id,src_port); |
| } |
| |
| lPort = tpm_db_eth_port_switch_port_get(src_port); |
| if (lPort == TPM_DB_ERR_PORT_NUM) |
| { |
| printk(KERN_ERR "ERROR: (%s:%d) source port(%d) is invalid\n", __FUNCTION__, __LINE__, src_port); |
| return ERR_SRC_PORT_INVALID; |
| } |
| |
| retVal = mv_switch_get_port_def_vlan(lPort, vid); |
| if (retVal != TPM_RC_OK) |
| { |
| printk(KERN_ERR |
| "%s:%d: function failed\r\n", __FUNCTION__,__LINE__); |
| } |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==EXIT== %s:vid[%d]\n\r", |
| __FUNCTION__,*vid); |
| } |
| |
| return retVal; |
| } |
| |
| /******************************************************************************* |
| * tpm_sw_set_port_def_pri |
| * |
| * DESCRIPTION: |
| * The API sets port default priority. |
| * |
| * INPUTS: |
| * owner_id - APP owner id - should be used for all API calls. |
| * src_port - Source port in UNI port index, UNI0, UNI1...UNI4. |
| * pri - the port priority. |
| * |
| * OUTPUTS: |
| * None. |
| * |
| * RETURNS: |
| * On success - TPM_RC_OK. |
| * On error different types are returned according to the case - see tpm_error_code_t. |
| * |
| * COMMENTS: |
| * None. |
| * |
| *******************************************************************************/ |
| tpm_error_code_t tpm_sw_set_port_def_pri |
| ( |
| uint32_t owner_id, |
| tpm_src_port_type_t src_port, |
| uint8_t pri |
| ) |
| { |
| tpm_error_code_t retVal = TPM_RC_OK; |
| int32_t lPort = 0; |
| |
| SWITCH_INIT_CHECK(); |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==ENTER==%s: owner_id[%d],src_port[%d],pri[%d]\r\n", |
| __FUNCTION__,owner_id,src_port,pri); |
| } |
| |
| if (pri>7) |
| { |
| printk(KERN_ERR |
| "%s:illegal pri[%d]\r\n", __FUNCTION__, pri); |
| return ERR_GENERAL; |
| } |
| |
| lPort = tpm_db_eth_port_switch_port_get(src_port); |
| if (lPort == TPM_DB_ERR_PORT_NUM) |
| { |
| printk(KERN_ERR "ERROR: (%s:%d) source port(%d) is invalid\n", __FUNCTION__, __LINE__, src_port); |
| return ERR_SRC_PORT_INVALID; |
| } |
| |
| retVal = mv_switch_set_port_def_pri(lPort, pri); |
| if (retVal != TPM_RC_OK) |
| { |
| printk(KERN_ERR |
| "%s:%d: function failed\r\n", __FUNCTION__,__LINE__); |
| } |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==EXIT== %s:\n\r",__FUNCTION__); |
| } |
| |
| return retVal; |
| } |
| |
| /******************************************************************************* |
| * tpm_sw_get_port_def_pri |
| * |
| * DESCRIPTION: |
| * The API gets port default priority. |
| * |
| * INPUTS: |
| * owner_id - APP owner id - should be used for all API calls. |
| * src_port - Source port in UNI port index, UNI0, UNI1...UNI4. |
| * |
| * OUTPUTS: |
| * pri - the port priority. |
| * |
| * RETURNS: |
| * On success - TPM_RC_OK. |
| * On error different types are returned according to the case - see tpm_error_code_t. |
| * |
| * COMMENTS: |
| * None. |
| * |
| *******************************************************************************/ |
| tpm_error_code_t tpm_sw_get_port_def_pri |
| ( |
| uint32_t owner_id, |
| tpm_src_port_type_t src_port, |
| uint8_t *pri |
| ) |
| { |
| tpm_error_code_t retVal = TPM_RC_OK; |
| int32_t lPort = 0; |
| |
| SWITCH_INIT_CHECK(); |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==ENTER==%s: owner_id[%d],src_port[%d]\r\n", |
| __FUNCTION__,owner_id,src_port); |
| } |
| |
| lPort = tpm_db_eth_port_switch_port_get(src_port); |
| if (lPort == TPM_DB_ERR_PORT_NUM) |
| { |
| printk(KERN_ERR "ERROR: (%s:%d) source port(%d) is invalid\n", __FUNCTION__, __LINE__, src_port); |
| return ERR_SRC_PORT_INVALID; |
| } |
| |
| retVal = mv_switch_get_port_def_pri(lPort, pri); |
| if (retVal != TPM_RC_OK) |
| { |
| printk(KERN_ERR |
| "%s:%d: function failed\r\n", __FUNCTION__,__LINE__); |
| } |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==EXIT== %s:pri[%d]\n\r", |
| __FUNCTION__,*pri); |
| } |
| |
| return retVal; |
| } |
| |
| /******************************************************************************* |
| * tpm_sw_port_add_vid |
| * |
| * DESCRIPTION: |
| * The API adds a VID to the list of the allowed VIDs per UNI port. |
| * |
| * INPUTS: |
| * owner_id - APP owner id - should be used for all API calls. |
| * src_port - Source port in UNI port index, UNI0, UNI1...UNI4. |
| * vid - VLAN id. |
| * |
| * OUTPUTS: |
| * None. |
| * |
| * RETURNS: |
| * On success - TPM_RC_OK. |
| * On error different types are returned according to the case - see tpm_error_code_t. |
| * |
| * COMMENTS: |
| * see the example sample802_1qSetup(). |
| * |
| *******************************************************************************/ |
| tpm_error_code_t tpm_sw_port_add_vid |
| ( |
| uint32_t owner_id, |
| tpm_src_port_type_t src_port, |
| uint16_t vid |
| ) |
| { |
| tpm_error_code_t retVal = TPM_RC_OK; |
| int32_t lPort = 0; |
| |
| SWITCH_INIT_CHECK(); |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==ENTER==%s: owner_id[%d],src_port[%d],vid[%d]\n", |
| __FUNCTION__,owner_id,src_port,vid); |
| } |
| |
| if (vid >= TPM_MAX_VID) |
| { |
| printk(KERN_INFO |
| "%s:%d:==ERROR== invalid VID[%d]\r\n", __FUNCTION__,__LINE__,vid); |
| return ERR_SW_VID_INVALID; |
| } |
| |
| lPort = tpm_db_eth_port_switch_port_get(src_port); |
| if (lPort == TPM_DB_ERR_PORT_NUM) |
| { |
| printk(KERN_ERR "ERROR: (%s:%d) source port(%d) is invalid\n", __FUNCTION__, __LINE__, src_port); |
| return ERR_SRC_PORT_INVALID; |
| } |
| |
| retVal = mv_switch_port_add_vid(lPort, vid, TPM_GMAC0_AMBER_PORT_NUM); |
| if (retVal != TPM_RC_OK) |
| { |
| printk(KERN_ERR |
| "%s:%d: function failed\r\n", __FUNCTION__,__LINE__); |
| } |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==EXIT== %s:\n\r",__FUNCTION__); |
| } |
| |
| return retVal; |
| } |
| |
| /******************************************************************************* |
| * tpm_sw_clear_vid_per_port |
| * |
| * DESCRIPTION: |
| * The API delete all VID from the list of VIDs allowed per UNI port. |
| * |
| * INPUTS: |
| * owner_id - APP owner id should be used for all API calls. |
| * src_port - Source port in UNI port index, UNI0, UNI1...UNI4. |
| * |
| * OUTPUTS: |
| * None. |
| * |
| * RETURNS: |
| * On success - TPM_RC_OK. |
| * On error different types are returned according to the case see tpm_error_code_t. |
| * |
| * COMMENTS: |
| * None. |
| * |
| *******************************************************************************/ |
| tpm_error_code_t tpm_sw_clear_vid_per_port |
| ( |
| uint32_t owner_id, |
| tpm_src_port_type_t src_port |
| ) |
| { |
| tpm_error_code_t retVal = TPM_RC_OK; |
| int32_t lPort = 0; |
| uint16_t vid; |
| |
| SWITCH_INIT_CHECK(); |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==ENTER==%s: owner_id[%d],src_port[%d]\r\n", |
| __FUNCTION__,owner_id,src_port); |
| } |
| |
| lPort = tpm_db_eth_port_switch_port_get(src_port); |
| if (lPort == TPM_DB_ERR_PORT_NUM) |
| { |
| printk(KERN_ERR "ERROR: (%s:%d) source port(%d) is invalid\n", __FUNCTION__, __LINE__, src_port); |
| return ERR_SRC_PORT_INVALID; |
| } |
| |
| for(vid=1; vid < TPM_MAX_VID-1; vid++) |
| { |
| retVal = mv_switch_del_vid_per_port(lPort, vid); |
| if (retVal != TPM_RC_OK) |
| { |
| printk(KERN_ERR |
| "%s:%d: function failed\r\n", __FUNCTION__,__LINE__); |
| } |
| } |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==EXIT== %s:\n\r",__FUNCTION__); |
| } |
| |
| return retVal; |
| } |
| |
| /******************************************************************************* |
| * tpm_sw_add_all_vid_per_port |
| * |
| * DESCRIPTION: |
| * The API adds all allowed VIDs from 1 to 4095 per UNI port. |
| * |
| * INPUTS: |
| * owner_id - APP owner id should be used for all API calls. |
| * src_port - Source port in UNI port index, UNI0, UNI1...UNI4. |
| * |
| * OUTPUTS: |
| * None. |
| * |
| * RETURNS: |
| * On success - TPM_RC_OK. |
| * On error different types are returned according to the case , see tpm_error_code_t. |
| * |
| * COMMENTS: |
| * None. |
| * |
| *******************************************************************************/ |
| tpm_error_code_t tpm_sw_add_all_vid_per_port |
| ( |
| uint32_t owner_id, |
| tpm_src_port_type_t src_port |
| ) |
| { |
| tpm_error_code_t retVal = TPM_RC_OK; |
| int32_t lPort = 0; |
| uint16_t vid; |
| |
| SWITCH_INIT_CHECK(); |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==ENTER==%s: owner_id[%d],src_port[%d]\r\n", |
| __FUNCTION__,owner_id,src_port); |
| } |
| |
| lPort = tpm_db_eth_port_switch_port_get(src_port); |
| if (lPort == TPM_DB_ERR_PORT_NUM) |
| { |
| printk(KERN_ERR "ERROR: (%s:%d) source port(%d) is invalid\n", __FUNCTION__, __LINE__, src_port); |
| return ERR_SRC_PORT_INVALID; |
| } |
| |
| for(vid=1; vid < TPM_MAX_VID-1; vid++) |
| { |
| retVal = mv_switch_port_add_vid(lPort, vid, TPM_GMAC0_AMBER_PORT_NUM); |
| if (retVal != TPM_RC_OK) |
| { |
| printk(KERN_ERR |
| "%s:%d: function failed\r\n", __FUNCTION__,__LINE__); |
| } |
| } |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==EXIT== %s:\n\r",__FUNCTION__); |
| } |
| |
| return retVal; |
| } |
| |
| /******************************************************************************* |
| * tpm_sw_port_del_vid |
| * |
| * DESCRIPTION: |
| * The API delete and existing VID from the list of VIDs allowed per UNI port. |
| * |
| * INPUTS: |
| * owner_id - APP owner id - should be used for all API calls. |
| * src_port - Source port in UNI port index, UNI0, UNI1...UNI4. |
| * vid - VLAN id. |
| * |
| * OUTPUTS: |
| * None. |
| * |
| * RETURNS: |
| * On success - TPM_RC_OK. |
| * On error different types are returned according to the case - see tpm_error_code_t. |
| * |
| * COMMENTS: |
| * None. |
| * |
| *******************************************************************************/ |
| tpm_error_code_t tpm_sw_port_del_vid |
| ( |
| uint32_t owner_id, |
| tpm_src_port_type_t src_port, |
| uint16_t vid |
| ) |
| { |
| tpm_error_code_t retVal = TPM_RC_OK; |
| int32_t lPort = 0; |
| |
| SWITCH_INIT_CHECK(); |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==ENTER==%s: owner_id[%d],src_port[%d],vid[%d]\r\n", |
| __FUNCTION__, owner_id, src_port, vid); |
| } |
| |
| if (vid >= TPM_MAX_VID) |
| { |
| printk(KERN_INFO |
| "%s:%d:==ERROR== invalid VID[%d]\r\n", __FUNCTION__,__LINE__,vid); |
| return ERR_SW_VID_INVALID; |
| } |
| |
| lPort = tpm_db_eth_port_switch_port_get(src_port); |
| if (lPort == TPM_DB_ERR_PORT_NUM) |
| { |
| printk(KERN_ERR "ERROR: (%s:%d) source port(%d) is invalid\n", __FUNCTION__, __LINE__, src_port); |
| return ERR_SRC_PORT_INVALID; |
| } |
| |
| retVal = mv_switch_del_vid_per_port(lPort, vid); |
| if (retVal != TPM_RC_OK) |
| { |
| printk(KERN_ERR |
| "%s:%d: function failed\r\n", __FUNCTION__,__LINE__); |
| } |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==EXIT== %s:\n\r",__FUNCTION__); |
| } |
| |
| return retVal; |
| } |
| |
| /******************************************************************************* |
| * tpm_sw_set_port_vid_egress_mode |
| * |
| * DESCRIPTION: |
| * The API sets the egress mode for a member port of a vlan. |
| * |
| * INPUTS: |
| * owner_id - APP owner id should be used for all API calls. |
| * src_port - Source port in UNI port index, UNI0, UNI1...UNI4. |
| * vid - vlan id |
| * eMode - egress mode |
| * |
| * OUTPUTS: |
| * None. |
| * |
| * RETURNS: |
| * On success - TPM_RC_OK. |
| * On error different types are returned according to the case see tpm_error_code_t. |
| * |
| * COMMENTS: |
| * MEMBER_EGRESS_UNMODIFIED - 0 |
| * NOT_A_MEMBER - 1 |
| * MEMBER_EGRESS_UNTAGGED - 2 |
| * MEMBER_EGRESS_TAGGED - 3 |
| * |
| *******************************************************************************/ |
| tpm_error_code_t tpm_sw_set_port_vid_egress_mode |
| ( |
| uint32_t owner_id, |
| tpm_src_port_type_t src_port, |
| uint16_t vid, |
| uint8_t eMode |
| ) |
| { |
| tpm_error_code_t retVal = TPM_RC_OK; |
| int32_t lPort = 0; |
| |
| SWITCH_INIT_CHECK(); |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==ENTER==%s: owner_id[%d],src_port[%d],vid[%d],eMode[%d]\r\n", |
| __FUNCTION__,owner_id,src_port,vid,eMode); |
| } |
| |
| if (vid >= TPM_MAX_VID) |
| { |
| printk(KERN_INFO |
| "%s:%d:==ERROR== invalid VID[%d]\r\n", __FUNCTION__,__LINE__,vid); |
| return ERR_SW_VID_INVALID; |
| } |
| |
| lPort = tpm_db_eth_port_switch_port_get(src_port); |
| if (lPort == TPM_DB_ERR_PORT_NUM) |
| { |
| printk(KERN_ERR "ERROR: (%s:%d) source port(%d) is invalid\n", __FUNCTION__, __LINE__, src_port); |
| return ERR_SRC_PORT_INVALID; |
| } |
| |
| retVal = mv_switch_set_port_vid_egress_mode(lPort, vid, eMode); |
| if (retVal != TPM_RC_OK) |
| { |
| printk(KERN_ERR |
| "%s:%d: function failed\r\n",__FUNCTION__,__LINE__); |
| } |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==EXIT== %s:\n\r",__FUNCTION__); |
| } |
| |
| return retVal; |
| } |
| |
| /******************************************************************************* |
| * tpm_sw_port_get_vid |
| * |
| * DESCRIPTION: |
| * The API return VID to the list of the allowed VIDs per UNI port. |
| * |
| * INPUTS: |
| * owner_id - APP owner id should be used for all API calls. |
| * vid - searching VID. |
| * |
| * OUTPUTS: |
| * found - MV_TRUE, if the appropriate entry exists. |
| * |
| * RETURNS: |
| * On success - TPM_RC_OK. |
| * On error different types are returned according to the case see tpm_error_code_t. |
| * |
| * COMMENTS: |
| * None. |
| * |
| *******************************************************************************/ |
| tpm_error_code_t tpm_sw_port_get_vid |
| ( |
| uint32_t owner_id, |
| uint32_t vid, |
| uint32_t *found |
| ) |
| { |
| tpm_error_code_t retVal; |
| |
| SWITCH_INIT_CHECK(); |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==ENTER==%s: owner_id[%d],vid[%d]\r\n", |
| __FUNCTION__,owner_id,vid); |
| } |
| |
| if (vid >= TPM_MAX_VID) |
| { |
| printk(KERN_INFO |
| "%s:%d:==ERROR== invalid VID[%d]\r\n", __FUNCTION__,__LINE__,vid); |
| return ERR_SW_VID_INVALID; |
| } |
| |
| retVal = mv_switch_port_print_vid(vid, found); |
| if (retVal != TPM_RC_OK) |
| { |
| printk(KERN_ERR |
| "%s:%d: function failed\r\n", __FUNCTION__,__LINE__); |
| } |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==EXIT== %s: found[%d]\n\r",__FUNCTION__,*found); |
| } |
| |
| return retVal; |
| } |
| |
| /******************************************************************************* |
| * tpm_sw_port_add_vid_group() |
| * |
| * DESCRIPTION: Add a group of VID to the list of the allowed VIDs per port, |
| * and set the egress mode correspondingly. |
| * |
| * INPUTS: |
| * owner_id - APP owner id should be used for all API calls. |
| * src_port - Source port in UNI port index, UNI0, UNI1...UNI4. |
| * mode - VLAN egress mode. |
| * min_vid - min VLAN ID. |
| * max_vid - max VLAN ID. |
| * |
| * OUTPUTS: |
| * None. |
| * |
| * RETURNS: |
| * On success, the function returns TPM_RC_OK. On error different types are returned |
| * according to the case - see tpm_error_code_t. |
| * |
| *******************************************************************************/ |
| tpm_error_code_t tpm_sw_port_add_vid_group |
| ( |
| uint32_t owner_id, |
| tpm_src_port_type_t src_port, |
| uint8_t mode, |
| uint16_t min_vid, |
| uint16_t max_vid |
| ) |
| { |
| tpm_error_code_t retVal = TPM_RC_OK; |
| uint16_t vid; |
| |
| SWITCH_INIT_CHECK(); |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==ENTER==%s: owner_id[%d], src_port[%d], mode[%d], min_vid[%d] max_vid[%d]\r\n", |
| __FUNCTION__,owner_id, src_port, mode, min_vid, max_vid); |
| } |
| |
| /*check VID*/ |
| if (max_vid >= TPM_MAX_VID) |
| { |
| printk(KERN_INFO |
| "%s:%d:==ERROR== invalid max_vid[%d]\r\n", __FUNCTION__,__LINE__,max_vid); |
| return ERR_SW_VID_INVALID; |
| } |
| |
| if(min_vid > max_vid) |
| { |
| printk(KERN_INFO |
| "%s:%d:==ERROR== param error: min_vid[%d] > max_vid[%d] \r\n", __FUNCTION__,__LINE__, min_vid, max_vid); |
| return ERR_SW_VID_INVALID; |
| } |
| |
| for(vid=min_vid; vid<=max_vid; vid++) |
| { |
| /*set the VID*/ |
| retVal = tpm_sw_port_add_vid(owner_id, src_port, vid); |
| if(retVal !=TPM_RC_OK) |
| { |
| printk(KERN_ERR |
| "%s:%d: function failed\r\n", __FUNCTION__,__LINE__); |
| break; |
| } |
| |
| /*set VLAN egress mode*/ |
| retVal = tpm_sw_set_port_vid_egress_mode(owner_id, src_port, vid, mode); |
| if(retVal !=TPM_RC_OK) |
| { |
| printk(KERN_ERR |
| "%s:%d: function failed\r\n", __FUNCTION__,__LINE__); |
| break; |
| } |
| } |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==EXIT== %s\n\r",__FUNCTION__); |
| } |
| |
| return retVal; |
| } |
| |
| /******************************************************************************* |
| * tpm_sw_port_del_vid_group() |
| * |
| * DESCRIPTION: Delete a group of VID to the list of the allowed VIDs per port, |
| * and set the egress mode correspondingly. |
| * |
| * INPUTS: |
| * owner_id - APP owner id should be used for all API calls. |
| * src_port - Source port in UNI port index, UNI0, UNI1...UNI4. |
| * min_vid - min VLAN ID. |
| * max_vid - max VLAN ID. |
| * |
| * OUTPUTS: |
| * None. |
| * |
| * RETURNS: |
| * On success, the function returns TPM_RC_OK. On error different types are returned |
| * according to the case - see tpm_error_code_t. |
| * |
| *******************************************************************************/ |
| tpm_error_code_t tpm_sw_port_del_vid_group |
| ( |
| uint32_t owner_id, |
| tpm_src_port_type_t src_port, |
| uint16_t min_vid, |
| uint16_t max_vid |
| ) |
| { |
| tpm_error_code_t retVal = TPM_RC_OK; |
| uint16_t vid; |
| |
| SWITCH_INIT_CHECK(); |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==ENTER==%s: owner_id[%d], src_port[%d], min_vid[%d] max_vid[%d]\r\n", |
| __FUNCTION__,owner_id, src_port, min_vid, max_vid); |
| } |
| |
| /*check VID*/ |
| if (max_vid >= TPM_MAX_VID) |
| { |
| printk(KERN_INFO |
| "%s:%d:==ERROR== invalid max_vid[%d]\r\n", __FUNCTION__,__LINE__,max_vid); |
| return ERR_SW_VID_INVALID; |
| } |
| |
| if(min_vid > max_vid) |
| { |
| printk(KERN_INFO |
| "%s:%d:==ERROR== param error: min_vid[%d] > max_vid[%d] \r\n", __FUNCTION__,__LINE__, min_vid, max_vid); |
| return ERR_SW_VID_INVALID; |
| } |
| |
| for(vid=min_vid; vid<=max_vid; vid++) |
| { |
| /*Delete the VID*/ |
| retVal = tpm_sw_port_del_vid(owner_id, src_port, vid); |
| if(retVal !=TPM_RC_OK) |
| { |
| printk(KERN_ERR |
| "%s:%d: function failed\r\n", __FUNCTION__,__LINE__); |
| break; |
| } |
| } |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==EXIT== %s\n\r",__FUNCTION__); |
| } |
| |
| return retVal; |
| } |
| |
| /******************************************************************************* |
| * tpm_sw_prv_set_secure_mode |
| * |
| * DESCRIPTION: |
| * Change a port mode in the SW data base and remove it from all VLANs |
| * |
| * INPUTS: |
| * owner_id - APP owner id - should be used for all API calls. |
| * port - secure port number |
| * |
| * OUTPUTS: |
| * None. |
| * |
| * RETURNS: |
| * On success - TPM_RC_OK. |
| * On error different types are returned according to the case - see tpm_error_code_t. |
| * |
| * COMMENTS: |
| * None. |
| * |
| *******************************************************************************/ |
| tpm_error_code_t tpm_sw_prv_set_secure_mode |
| ( |
| uint32_t owner_id, |
| uint32_t port |
| ) |
| { |
| tpm_error_code_t retVal; |
| |
| SWITCH_INIT_CHECK(); |
| |
| retVal = mv_switch_prv_set_secure_mode(port); |
| if (retVal != TPM_RC_OK) |
| { |
| printk(KERN_ERR |
| "%s:%d: function failed\r\n", __FUNCTION__,__LINE__); |
| } |
| |
| return retVal; |
| } |
| |
| /******************************************************************************* |
| * tpm_sw_prv_set_fallback_mode |
| * |
| * DESCRIPTION: |
| * Change a port mode in the SW data base and add it to all VLANs |
| * |
| * INPUTS: |
| * owner_id - APP owner id - should be used for all API calls. |
| * port - secure port number |
| * |
| * OUTPUTS: |
| * None. |
| * |
| * RETURNS: |
| * On success - TPM_RC_OK. |
| * On error different types are returned according to the case - see tpm_error_code_t. |
| * |
| * COMMENTS: |
| * None. |
| * |
| *******************************************************************************/ |
| tpm_error_code_t tpm_sw_prv_set_fallback_mode |
| ( |
| uint32_t owner_id, |
| uint32_t port |
| ) |
| { |
| tpm_error_code_t retVal; |
| |
| SWITCH_INIT_CHECK(); |
| |
| retVal = mv_switch_prv_set_fallback_mode(port); |
| if (retVal != TPM_RC_OK) |
| { |
| printk(KERN_ERR |
| "%s:%d: function failed\r\n", __FUNCTION__,__LINE__); |
| } |
| |
| return retVal; |
| } |
| |
| /******************************************************************************* |
| * tpm_sw_port_set_vid_filter |
| * |
| * DESCRIPTION: |
| * The API sets the filtering mode of a certain UNI port. |
| * If the UNI port is in filtering mode, only the VIDs added by the |
| * tpm_sw_port_add_vid API will be allowed to ingress and egress the UNI port. |
| * |
| * INPUTS: |
| * owner_id - APP owner id - should be used for all API calls. |
| * src_port - Source port in UNI port index, UNI0, UNI1...UNI4. |
| * vid_filter - set to 1 - means the UNI port will DROP all packets which are NOT in |
| * the allowed VID list (built using API tpm_sw_port_add_vid). |
| * set to 0 - means that the list of VIDs allowed |
| * per UNI port has no significance (the list is not deleted). |
| * |
| * OUTPUTS: |
| * None. |
| * |
| * RETURNS: |
| * On success - TPM_RC_OK. |
| * On error different types are returned according to the case - see tpm_error_code_t. |
| * |
| * COMMENTS: |
| * None. |
| * |
| *******************************************************************************/ |
| tpm_error_code_t tpm_sw_port_set_vid_filter |
| ( |
| uint32_t owner_id, |
| tpm_src_port_type_t src_port, |
| uint8_t vid_filter |
| ) |
| { |
| tpm_error_code_t retVal = TPM_RC_OK; |
| int32_t lPort = 0; |
| |
| SWITCH_INIT_CHECK(); |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==ENTER==%s: owner_id[%d],src_port[%d],vid_filter[%d]\r\n", |
| __FUNCTION__,owner_id,src_port, vid_filter); |
| } |
| |
| lPort = tpm_db_eth_port_switch_port_get(src_port); |
| if (lPort == TPM_DB_ERR_PORT_NUM) |
| { |
| printk(KERN_ERR "ERROR: (%s:%d) source port(%d) is invalid\n", __FUNCTION__, __LINE__, src_port); |
| return ERR_SRC_PORT_INVALID; |
| } |
| |
| retVal = mv_switch_set_vid_filter_per_port(lPort, vid_filter); |
| if (retVal != TPM_RC_OK) |
| { |
| printk(KERN_ERR |
| "%s:%d: function failed\r\n", __FUNCTION__,__LINE__); |
| } |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==EXIT== %s:\n\r",__FUNCTION__); |
| } |
| |
| return retVal; |
| } |
| |
| /******************************************************************************* |
| * tpm_sw_get_vid_filter_per_port |
| * |
| * DESCRIPTION: |
| * This routine gets protected mode of a UNI port port. |
| * When this mode is set to GT_TRUE, frames are allowed to egress UNI port |
| * defined by the 802.1Q VLAN membership for the frame's VID 'AND' |
| * by the UNI port's VLANTable if 802.1Q is enabled on the UNI port. Both must |
| * allow the frame to Egress. |
| * |
| * INPUTS: |
| * owner_id - APP owner id - should be used for all API calls. |
| * src_port - Source port in UNI port index, UNI0, UNI1...UNI4. |
| * |
| * OUTPUTS: |
| * mode - GT_TRUE: header mode enabled |
| * GT_FALSE otherwise |
| * |
| * RETURNS: |
| * On success - TPM_RC_OK. |
| * On error different types are returned according to the case - see tpm_error_code_t. |
| * |
| * COMMENTS: |
| * None. |
| * |
| *******************************************************************************/ |
| tpm_error_code_t tpm_sw_get_vid_filter_per_port |
| ( |
| uint32_t owner_id, |
| tpm_src_port_type_t src_port, |
| uint32_t *mode |
| ) |
| { |
| tpm_error_code_t retVal = TPM_RC_OK; |
| int32_t lPort = 0; |
| uint8_t vid_filter; |
| |
| SWITCH_INIT_CHECK(); |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==ENTER==%s: owner_id[%d],src_port[%d]\r\n", |
| __FUNCTION__,owner_id,src_port); |
| } |
| |
| lPort = tpm_db_eth_port_switch_port_get(src_port); |
| if (lPort == TPM_DB_ERR_PORT_NUM) |
| { |
| printk(KERN_ERR "ERROR: (%s:%d) source port(%d) is invalid\n", __FUNCTION__, __LINE__, src_port); |
| return ERR_SRC_PORT_INVALID; |
| } |
| |
| retVal = mv_switch_get_vid_filter_per_port(lPort, &vid_filter); |
| if (retVal != TPM_RC_OK) |
| { |
| printk(KERN_ERR |
| "%s:%d: function failed\r\n", __FUNCTION__,__LINE__); |
| } |
| |
| *mode = (uint32_t)vid_filter; |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==EXIT== %s: mode[%d] \n\r",__FUNCTION__, *mode); |
| } |
| |
| return TPM_RC_OK; |
| } |
| |
| /******************************************************************************* |
| * tpm_sw_set_uni_sched() |
| * |
| * DESCRIPTION: Configures the scheduling mode per Ethernet port. |
| * |
| * INPUTS: |
| * owner_id - APP owner id should be used for all API calls. |
| * src_port - Source port in UNI port index, UNI0, UNI1...UNI4. |
| * sched_mode - scheduler mode per port |
| * |
| * OUTPUTS: |
| * None. |
| * |
| * RETURNS: |
| * On success, the function returns TPM_RC_OK. On error different types are returned |
| * according to the case - see tpm_error_code_t. |
| *DDD |
| *******************************************************************************/ |
| tpm_error_code_t tpm_sw_set_uni_sched |
| ( |
| uint32_t owner_id, |
| tpm_src_port_type_t src_port, |
| tpm_sw_sched_type_t sched_mode |
| ) |
| { |
| tpm_error_code_t retVal = TPM_RC_OK; |
| int32_t lPort = 0; |
| uint32_t mode; |
| |
| SWITCH_INIT_CHECK(); |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==ENTER==%s: owner_id[%d],src_port[%d],sched_mode[%d]\n\r", |
| __FUNCTION__,owner_id,src_port,sched_mode); |
| } |
| |
| switch(sched_mode) |
| { |
| case TPM_PP_SCHED_STRICT: |
| mode = PORT_SCHED_MODE_SPRI; |
| break; |
| |
| case TPM_PP_SCHED_WRR: |
| mode = PORT_SCHED_MODE_WRRB; |
| break; |
| |
| default: |
| printk(KERN_INFO "==Error== %s: sched_mode[1 or 2]\n\r",__FUNCTION__); |
| return ERR_GENERAL; |
| } |
| |
| lPort = tpm_db_eth_port_switch_port_get(src_port); |
| if (lPort == TPM_DB_ERR_PORT_NUM) |
| { |
| printk(KERN_ERR "ERROR: (%s:%d) source port(%d) is invalid\n", __FUNCTION__, __LINE__, src_port); |
| return ERR_SRC_PORT_INVALID; |
| } |
| |
| retVal = mv_switch_set_port_sched_mode(lPort, mode); |
| if (retVal != GT_OK) |
| { |
| printk(KERN_ERR |
| "%s:%d: function failed\r\n", __FUNCTION__,__LINE__); |
| } |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==EXIT== %s:\n\r",__FUNCTION__); |
| } |
| |
| return retVal; |
| } |
| |
| /******************************************************************************* |
| * tpm_sw_set_uni_q_weight |
| * |
| * DESCRIPTION: |
| * The API configures the weight of a queues for all |
| * Ethernet UNI ports in the integrated switch. |
| * |
| * INPUTS: |
| * owner_id - APP owner id - should be used for all API calls. |
| * weight - weight value per queue (1-8).queue (value 1-3). |
| * |
| * OUTPUTS: |
| * None. |
| * |
| * RETURNS: |
| * On success - TPM_RC_OK. |
| * On error different types are returned according to the case - see tpm_error_code_t. |
| * |
| * COMMENTS: |
| * None. DDD |
| * |
| *******************************************************************************/ |
| tpm_error_code_t tpm_sw_set_uni_q_weight |
| ( |
| uint32_t owner_id, |
| uint8_t queue_id, |
| uint8_t weight |
| ) |
| { |
| tpm_error_code_t retVal = GT_OK; |
| tpm_gmacs_enum_t gmac_i; |
| tpm_db_gmac_func_t gmac_func; |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==ENTER==%s: owner_id[%d],queue_id[%d] weight[%d]\n\r", |
| __FUNCTION__,owner_id,queue_id,weight); |
| } |
| |
| if (tpm_sw_init_check()) { |
| for (gmac_i = TPM_ENUM_GMAC_0; gmac_i < TPM_MAX_NUM_GMACS; gmac_i++) { |
| tpm_db_gmac_func_get(gmac_i, &gmac_func); |
| if (TPM_GMAC_FUNC_LAN_UNI == gmac_func || |
| TPM_GMAC_FUNC_US_MAC_LEARN_DS_LAN_UNI == gmac_func) |
| retVal |= mvNetaTxqWrrPrioSet(gmac_i, 0, queue_id, weight); |
| } |
| } else { |
| if ((queue_id == 0) || |
| (queue_id > SW_QOS_NUM_OF_QUEUES)) |
| { |
| printk(KERN_INFO |
| "%s:%d:==ERROR== invalid queue[%d]\r\n", __FUNCTION__,__LINE__,queue_id); |
| return ERR_SW_TM_QUEUE_INVALID; |
| } |
| |
| retVal = mv_switch_set_uni_q_weight(queue_id, weight); |
| } |
| if (retVal != GT_OK) |
| { |
| printk(KERN_ERR |
| "%s:%d: function failed\r\n", __FUNCTION__,__LINE__); |
| } |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==EXIT== %s:\n\r",__FUNCTION__); |
| } |
| |
| return retVal; |
| } |
| |
| /******************************************************************************* |
| * tpm_sw_set_uni_ingr_police_rate |
| * |
| * DESCRIPTION: |
| * The API Configures an ingress policing function for an Ethernet UNI port. |
| * |
| * INPUTS: |
| * owner_id - APP owner id, should be used for all API calls. |
| * src_port - Source port in UNI port index, UNI0, UNI1...UNI4. |
| * count_mode - count mode: |
| * TPM_SW_LIMIT_FRAME |
| * TPM_SW_LIMIT_LAYER1 |
| * TPM_SW_LIMIT_LAYER2 |
| * TPM_SW_LIMIT_LAYER3 |
| * cir - comited info rate. |
| * cbs - Committed Burst Size limit (expected to be 2kBytes) |
| * ebs - Excess Burst Size limit ( 0 ~ 0xFFFFFF) |
| * |
| * OUTPUTS: |
| * None. |
| * |
| * RETURNS: |
| * On success - TPM_RC_OK. |
| * On error different types are returned according to the case - see tpm_error_code_t. |
| * |
| * COMMENTS: |
| * |
| *******************************************************************************/ |
| tpm_error_code_t tpm_sw_set_uni_ingr_police_rate |
| ( |
| uint32_t owner_id, |
| tpm_src_port_type_t src_port, |
| tpm_limit_mode_t count_mode, |
| uint32_t cir, |
| uint32_t cbs, |
| uint32_t ebs |
| ) |
| { |
| tpm_error_code_t retVal = TPM_RC_OK; |
| int32_t lPort = 0; |
| GT_PIRL2_COUNT_MODE mode; |
| tpm_gmacs_enum_t gmac_i; |
| tpm_db_gmac_lpk_uni_ingr_rate_limit_t rate_limit; |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==ENTER==%s: owner_id[%d],src_port[%d],count_mode[%d], cir[%d], cbs[%d], ebs[%d]\r\n", |
| __FUNCTION__,owner_id,src_port,count_mode, cir, cbs,ebs); |
| } |
| |
| if (tpm_sw_init_check()) { |
| if (tpm_src_port_mac_map(src_port, &gmac_i)) { |
| printk(KERN_ERR "ERROR: (%s:%d) source port(%d) map to mac failed\n", __FUNCTION__, __LINE__, src_port); |
| return ERR_SRC_PORT_INVALID; |
| } |
| /* Check GMAC1 lpk status, if no lpk, no ingress rate for ingress */ |
| if (tpm_db_gmac1_lpbk_en_get()) { |
| retVal = tpm_tm_set_gmac0_ingr_rate_lim(owner_id, cir, cbs); |
| if (retVal == TPM_RC_OK) { |
| rate_limit.count_mode = count_mode; |
| rate_limit.cir = cir; |
| rate_limit.cbs = cbs; |
| rate_limit.ebs = ebs; |
| retVal = tpm_db_gmac_lpk_uni_ingr_rate_limit_set(src_port, rate_limit); |
| } |
| } else { |
| printk(KERN_ERR "ERROR: (%s:%d) src port(%d) ingr rate limit not support\n", __FUNCTION__, __LINE__, src_port); |
| return ERR_GENERAL; |
| } |
| } else { |
| |
| mode = (GT_PIRL2_COUNT_MODE)count_mode; |
| |
| lPort = tpm_db_eth_port_switch_port_get(src_port); |
| if (lPort == TPM_DB_ERR_PORT_NUM) |
| { |
| printk(KERN_ERR "ERROR: (%s:%d) source port(%d) is invalid\n", __FUNCTION__, __LINE__, src_port); |
| return ERR_SRC_PORT_INVALID; |
| } |
| |
| retVal = mv_switch_set_uni_ingr_police_rate(lPort, (GT_PIRL2_COUNT_MODE)mode, cir, cbs, ebs); |
| } |
| if (retVal != TPM_RC_OK) |
| { |
| printk(KERN_ERR |
| "%s:%d: function failed\r\n", __FUNCTION__,__LINE__); |
| } |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==EXIT== %s \n\r",__FUNCTION__); |
| } |
| |
| return retVal; |
| } |
| |
| /******************************************************************************* |
| * tpm_sw_get_uni_ingr_police_rate |
| * |
| * DESCRIPTION: |
| * The API gets an ingress policing function for an Ethernet UNI port. |
| * |
| * INPUTS: |
| * owner_id - APP owner id, should be used for all API calls. |
| * src_port - Source port in UNI port index, UNI0, UNI1...UNI4. |
| * |
| * |
| * OUTPUTS: |
| * count_mode - count mode: |
| * TPM_SW_LIMIT_FRAME |
| * TPM_SW_LIMIT_LAYER1 |
| * TPM_SW_LIMIT_LAYER2 |
| * TPM_SW_LIMIT_LAYER3 |
| * cir - comited info rate. |
| * cbs - Committed Burst Size limit (expected to be 2kBytes) |
| * ebs - Excess Burst Size limit ( 0 ~ 0xFFFFFF) |
| * |
| * RETURNS: |
| * On success - TPM_RC_OK. |
| * On error different types are returned according to the case - see tpm_error_code_t. |
| * |
| * COMMENTS: |
| * None. |
| * |
| *******************************************************************************/ |
| tpm_error_code_t tpm_sw_get_uni_ingr_police_rate |
| ( |
| uint32_t owner_id, |
| tpm_src_port_type_t src_port, |
| tpm_limit_mode_t *count_mode, |
| uint32_t *cir, |
| uint32_t *cbs, |
| uint32_t *ebs |
| ) |
| { |
| tpm_error_code_t retVal = TPM_RC_OK; |
| int32_t lPort = 0; |
| GT_PIRL2_COUNT_MODE mode; |
| tpm_gmacs_enum_t gmac_i; |
| tpm_db_gmac_lpk_uni_ingr_rate_limit_t rate_limit; |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==ENTER==%s: owner_id[%d],src_port[%d]\r\n", |
| __FUNCTION__,owner_id,src_port); |
| } |
| |
| if (tpm_sw_init_check()) { |
| if (tpm_src_port_mac_map(src_port, &gmac_i)) { |
| printk(KERN_ERR "ERROR: (%s:%d) source port(%d) map to mac failed\n", __FUNCTION__, __LINE__, src_port); |
| return ERR_SRC_PORT_INVALID; |
| } |
| /* Check GMAC1 lpk status, if no lpk, no ingress rate for ingress */ |
| if (tpm_db_gmac1_lpbk_en_get()) { |
| retVal = tpm_db_gmac_lpk_uni_ingr_rate_limit_get(src_port, &rate_limit); |
| if (retVal == TPM_RC_OK) { |
| mode = (GT_PIRL2_COUNT_MODE)rate_limit.count_mode; |
| *cir = rate_limit.cir; |
| *cbs = rate_limit.cbs; |
| *ebs = rate_limit.ebs; |
| } |
| } else { |
| printk(KERN_ERR "ERROR: (%s:%d) src port(%d) ingr rate limit not support\n", __FUNCTION__, __LINE__, src_port); |
| return ERR_GENERAL; |
| } |
| } else { |
| lPort = tpm_db_eth_port_switch_port_get(src_port); |
| if (lPort == TPM_DB_ERR_PORT_NUM) |
| { |
| printk(KERN_ERR "ERROR: (%s:%d) source port(%d) is invalid\n", __FUNCTION__, __LINE__, src_port); |
| return ERR_SRC_PORT_INVALID; |
| } |
| |
| retVal = mv_switch_get_uni_ingr_police_rate(lPort, &mode, cir, cbs, ebs); |
| } |
| if (retVal != TPM_RC_OK) |
| { |
| printk(KERN_ERR |
| "%s:%d: function failed\r\n", __FUNCTION__,__LINE__); |
| } |
| |
| *count_mode = (tpm_limit_mode_t)mode; |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==EXIT== %s:,count_mode[%d], cir[%d], cbs[%d], ebs[%d]\n\r", |
| __FUNCTION__, *count_mode, *cir, *cbs, *ebs); |
| } |
| |
| return retVal; |
| } |
| |
| /******************************************************************************* |
| * tpm_sw_set_uni_tc_ingr_police_rate |
| * |
| * DESCRIPTION: |
| * The API Configures a policer function for a traffic class for an Ethernet UNI port. |
| * There are 4 globally defined traffic classes in the integrated switch. |
| * |
| * INPUTS: |
| * owner_id - APP owner id - should be used for all API calls. |
| * src_port - Source port in UNI port index, UNI0, UNI1...UNI4. |
| * tc - traffic class ( a combination of p-bits and DSCP values). |
| * cir - comited info rate. |
| * cbs - comited burst rate. |
| * |
| * OUTPUTS: |
| * None. |
| * |
| * RETURNS: |
| * On success - TPM_RC_OK. |
| * On error different types are returned according to the case - see tpm_error_code_t. |
| * |
| * COMMENTS: |
| * |
| * |
| *******************************************************************************/ |
| tpm_error_code_t tpm_sw_set_uni_tc_ingr_police_rate |
| ( |
| uint32_t owner_id, |
| tpm_src_port_type_t src_port, |
| uint32_t tc, |
| uint32_t cir, |
| uint32_t cbs |
| ) |
| { |
| tpm_error_code_t retVal = TPM_RC_OK; |
| int32_t lPort = 0; |
| |
| SWITCH_INIT_CHECK(); |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==ENTER==%s: owner_id[%d],src_port[%d],tc[%d],cir[%d],cbs[%d]\r\n", |
| __FUNCTION__,owner_id,src_port,tc, cir, cbs); |
| } |
| |
| if ((tc == 0) || (tc > SW_QOS_NUM_OF_QUEUES)) |
| { |
| printk(KERN_INFO |
| "%s:%d:==ERROR== invalid tc[%d]\r\n", __FUNCTION__,__LINE__,tc); |
| return ERR_SW_TM_QUEUE_INVALID; |
| } |
| |
| lPort = tpm_db_eth_port_switch_port_get(src_port); |
| if (lPort == TPM_DB_ERR_PORT_NUM) |
| { |
| printk(KERN_ERR "ERROR: (%s:%d) source port(%d) is invalid\n", __FUNCTION__, __LINE__, src_port); |
| return ERR_SRC_PORT_INVALID; |
| } |
| |
| retVal = mv_switch_set_uni_tc_ingr_police_rate(lPort, tc, cir, cbs); |
| if (retVal != TPM_RC_OK) |
| { |
| printk(KERN_ERR |
| "%s:%d: function failed\r\n", __FUNCTION__,__LINE__); |
| } |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==EXIT== %s:\n\r",__FUNCTION__); |
| } |
| |
| return retVal; |
| } |
| |
| /******************************************************************************* |
| * tpm_sw_get_uni_tc_ingr_police_rate |
| * |
| * DESCRIPTION: |
| * This routine gets the UNI port's ingress data limit for priority 0 or 1 or 2 or 3 frames. |
| * |
| * INPUTS: |
| * owner_id - APP owner id - should be used for all API calls. |
| * src_port - Source port in UNI port index, UNI0, UNI1...UNI4. |
| * |
| * OUTPUTS: |
| * |
| * tc - traffic class ( a combination of p-bits and DSCP values). |
| * cir - comited info rate. |
| * cbs - comited burst rate |
| * |
| * RETURNS: |
| * On success - TPM_RC_OK. |
| * On error different types are returned according to the case - see tpm_error_code_t. |
| * |
| * COMMENTS: |
| * |
| *******************************************************************************/ |
| tpm_error_code_t tpm_sw_get_uni_tc_ingr_police_rate |
| ( |
| uint32_t owner_id, |
| tpm_src_port_type_t src_port, |
| uint32_t *tc, |
| uint32_t *cir, |
| uint32_t *cbs |
| ) |
| { |
| tpm_error_code_t retVal = TPM_RC_OK; |
| int32_t lPort = 0; |
| |
| SWITCH_INIT_CHECK(); |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==ENTER==%s: owner_id[%d],src_port[%d]\r\n", |
| __FUNCTION__,owner_id,src_port); |
| } |
| |
| lPort = tpm_db_eth_port_switch_port_get(src_port); |
| if (lPort == TPM_DB_ERR_PORT_NUM) |
| { |
| printk(KERN_ERR "ERROR: (%s:%d) source port(%d) is invalid\n", __FUNCTION__, __LINE__, src_port); |
| return ERR_SRC_PORT_INVALID; |
| } |
| |
| retVal = mv_switch_get_uni_tc_ingr_police_rate(lPort, tc, cir, cbs); |
| if (retVal != TPM_RC_OK) |
| { |
| printk(KERN_ERR |
| "%s:%d: function failed\r\n", __FUNCTION__,__LINE__); |
| } |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==EXIT== %s:tc[0x%x] cir[%d]\n\r", |
| __FUNCTION__,*tc,*cir); |
| } |
| |
| return retVal; |
| } |
| |
| /******************************************************************************* |
| * tpm_sw_set_uni_egr_rate_limit |
| * |
| * DESCRIPTION: |
| * The API Configures the egress frame rate limit of an Ethernet UNI port |
| * INPUTS: |
| * owner_id - APP owner id - should be used for all API calls. |
| * src_port - Source port in UNI port index, UNI0, UNI1...UNI4. |
| * mode - frame/rate limit mode |
| * frame_rate_limit_val - egress rate limit value. |
| * |
| * OUTPUTS: |
| * None. |
| * |
| * RETURNS: |
| * On success - TPM_RC_OK. |
| * On error different types are returned according to the case - see tpm_error_code_t. |
| * |
| * COMMENTS: |
| * GT_ERATE_TYPE used kbRate - frame rate valid values are: |
| * 7600,..., 9600, |
| * 10000, 20000, 30000, 40000, ..., 100000, |
| * 110000, 120000, 130000, ..., 1000000. |
| * |
| * |
| *******************************************************************************/ |
| tpm_error_code_t tpm_sw_set_uni_egr_rate_limit |
| ( |
| uint32_t owner_id, |
| tpm_src_port_type_t src_port, |
| tpm_limit_mode_t mode, |
| uint32_t frame_rate_limit_val |
| ) |
| { |
| tpm_error_code_t retVal = TPM_RC_OK; |
| int32_t lPort = 0; |
| tpm_gmacs_enum_t gmac_i; |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==ENTER==%s: owner_id[%d],src_port[%d],mode[%d],frame_rate_limit_val[%d]\r\n", |
| __FUNCTION__,owner_id,src_port,mode,frame_rate_limit_val); |
| } |
| |
| if (tpm_sw_init_check()) { |
| if (tpm_src_port_mac_map(src_port, &gmac_i)) { |
| printk(KERN_ERR "ERROR: (%s:%d) source port(%d) map to mac failed\n", __FUNCTION__, __LINE__, src_port); |
| return ERR_SRC_PORT_INVALID; |
| } |
| /* Set tx port rate limit on gmac_i */ |
| retVal = tpm_tm_set_tx_port_rate_lim(owner_id, gmac_i, frame_rate_limit_val, 0); |
| if (retVal == TPM_RC_OK) { |
| retVal = tpm_db_gmac_uni_egr_rate_limit_set(src_port, frame_rate_limit_val); |
| } |
| } else { |
| |
| lPort = tpm_db_eth_port_switch_port_get(src_port); |
| if (lPort == TPM_DB_ERR_PORT_NUM) |
| { |
| printk(KERN_ERR "ERROR: (%s:%d) source port(%d) is invalid\n", __FUNCTION__, __LINE__, src_port); |
| return ERR_SRC_PORT_INVALID; |
| } |
| |
| retVal = mv_switch_set_uni_egr_rate_limit(lPort, (GT_PIRL_ELIMIT_MODE)mode, frame_rate_limit_val); |
| } |
| if (retVal != TPM_RC_OK) |
| { |
| printk(KERN_ERR |
| "%s:%d: function failed\r\n", __FUNCTION__,__LINE__); |
| } |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==EXIT== %s:\n\r",__FUNCTION__); |
| } |
| |
| return retVal; |
| } |
| |
| /******************************************************************************* |
| * tpm_sw_get_uni_egr_rate_limit |
| * |
| * DESCRIPTION: |
| * The API return the egress frame rate limit of an Ethernet UNI port |
| * INPUTS: |
| * owner_id - APP owner id - should be used for all API calls. |
| * src_port - Source port in UNI port index, UNI0, UNI1...UNI4. |
| * |
| * OUTPUTS: |
| * mode - frame/rate limit mode |
| * rate_limit_val - egress rate limit value.. |
| * |
| * RETURNS: |
| * On success - TPM_RC_OK. |
| * On error different types are returned according to the case - see tpm_error_code_t. |
| * |
| * COMMENTS: |
| * GT_ERATE_TYPE used kbRate - frame rate valid values are: |
| * 7600,..., 9600, |
| * 10000, 20000, 30000, 40000, ..., 100000, |
| * 110000, 120000, 130000, ..., 1000000. |
| |
| * |
| *******************************************************************************/ |
| tpm_error_code_t tpm_sw_get_uni_egr_rate_limit |
| ( |
| uint32_t owner_id, |
| tpm_src_port_type_t src_port, |
| tpm_limit_mode_t *mode, |
| uint32_t *frame_rate_limit_val |
| ) |
| { |
| tpm_error_code_t retVal = TPM_RC_OK; |
| int32_t lPort = 0; |
| GT_PIRL_ELIMIT_MODE limit_mode; |
| tpm_gmacs_enum_t gmac_i; |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==ENTER==%s: owner_id[%d],src_port[%d]\r\n", |
| __FUNCTION__,owner_id,src_port); |
| } |
| |
| if (tpm_sw_init_check()) { |
| if (tpm_src_port_mac_map(src_port, &gmac_i)) { |
| printk(KERN_ERR "ERROR: (%s:%d) source port(%d) map to mac failed\n", __FUNCTION__, __LINE__, src_port); |
| return ERR_SRC_PORT_INVALID; |
| } |
| /* Set tx port rate limit on gmac_i */ |
| retVal = tpm_db_gmac_uni_egr_rate_limit_get(src_port, frame_rate_limit_val); |
| limit_mode = GT_PIRL_ELIMIT_FRAME; |
| } else { |
| lPort = tpm_db_eth_port_switch_port_get(src_port); |
| if (lPort == TPM_DB_ERR_PORT_NUM) |
| { |
| printk(KERN_ERR "ERROR: (%s:%d) source port(%d) is invalid\n", __FUNCTION__, __LINE__, src_port); |
| return ERR_SRC_PORT_INVALID; |
| } |
| |
| retVal = mv_switch_get_uni_egr_rate_limit(lPort, &limit_mode, frame_rate_limit_val); |
| } |
| if (retVal != TPM_RC_OK) |
| { |
| printk(KERN_ERR |
| "%s:%d: function failed\r\n", __FUNCTION__,__LINE__); |
| } |
| *mode = (tpm_limit_mode_t)limit_mode; |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==EXIT== %s: mode[%d], frame_rate_limit_val[%d]\n\r", |
| __FUNCTION__, *mode, *frame_rate_limit_val); |
| } |
| |
| return retVal; |
| } |
| |
| /******************************************************************************* |
| * tpm_sw_set_atu_size |
| * |
| * DESCRIPTION: |
| * This function Sets the Mac address table size. |
| * |
| * INPUTS: |
| * owner_id - APP owner id - should be used for all API calls. |
| * size - Table size |
| * |
| * OUTPUTS: |
| * None. |
| * |
| * RETURNS: |
| * On success - TPM_RC_OK. |
| * On error different types are returned according to the case - see tpm_error_code_t. |
| * |
| * COMMENTS: |
| * The device GT_88E6351 have fixed ATU size 8192. |
| * |
| *******************************************************************************/ |
| tpm_error_code_t tpm_sw_set_atu_size |
| ( |
| uint32_t owner_id, |
| uint32_t size |
| ) |
| { |
| tpm_error_code_t retVal = TPM_RC_OK; |
| uint32_t atu_size; |
| |
| SWITCH_INIT_CHECK(); |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==ENTER==%s: owner_id[%d],size[%d]\n\r", |
| __FUNCTION__,owner_id,size); |
| } |
| |
| switch(size) |
| { |
| case 0: atu_size = 0; /*ATU_SIZE_256*/ break; |
| case 1: atu_size = 1; /*ATU_SIZE_512*/ break; |
| case 2: atu_size = 2; /*ATU_SIZE_1024*/ break; |
| case 3: atu_size = 3; /*ATU_SIZE_2048*/ break; |
| case 4: atu_size = 4; /*ATU_SIZE_4096*/ break; |
| case 5: |
| printk(KERN_INFO "8192 entries not supported by driver\n");break; |
| |
| default: |
| printk(KERN_INFO "==Error== %s: size[0-4]\n\r",__FUNCTION__); |
| return ERR_GENERAL; |
| } |
| |
| /* The driver support only 8192 entry as constant value */ |
| printk(" The device GT_88E6351 have fixed ATU size 8192\r\n"); |
| |
| if (trace_sw_dbg_flag) |
| { |
| printk(KERN_INFO |
| "==EXIT== %s:\n\r",__FUNCTION__); |
| } |
| |
| return retVal; |
|