blob: 97d033ecb8ed6c05de2a6b72d12ab5b34f6aabdf [file] [log] [blame]
/*******************************************************************************
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.
******************************************************************************/
/******************************************************************************
*
* tpm_db.c
*
* DESCRIPTION:
* Traffic Processor Manager = TPM
*
* DEPENDENCIES:
* None
*
* CREATED BY: OctaviaP
*
* DATE CREATED:
*
* FILE REVISION NUMBER:
* Revision: 1.4
*
*
*******************************************************************************/
#include "tpm_common.h"
#include "tpm_header.h"
#include <linux/vmalloc.h>
/* Local definitions */
#define PNC_RANGE_OPER(x) tpm_db.pnc_range[x].pnc_range_oper
#define PNC_RANGE_CONF(x) tpm_db.pnc_range[x].pnc_range_conf
#define TPM_DBVAL_CON(dbval) ((dbval == TPM_DB_VALID) ? TPM_TRUE : TPM_FALSE)
#define TPM_DB_DIVIDED_BY_32(x) (x >> 5)
#define TPM_DB_MOD_32(x) (x & 0x1f)
#define MEM_MARGIN_PATTERN (0xA3)
#define API_ENT_I(api_sec, i) tpm_db.api_ent_mem_area[(tpm_db.api_section[api_sec].table_start) + i]
#define IF_ERROR(ret) \
if (ret != TPM_DB_OK) { \
TPM_OS_ERROR(TPM_DB_MOD, " recvd ret_code(%d)\n", ret); \
return(ret); \
}
#define IF_ERROR_I(ret, i) \
if (ret != TPM_DB_OK) { \
TPM_OS_ERROR(TPM_DB_MOD, " For index(%d), recvd ret_code(%d)\n", i, ret); \
return(ret); \
}
/* TODO - change to static variable after updating print functions */
tpm_db_t tpm_db;
tpm_db_hot_swap_bak_db_t hot_swap_bak_db;
static uint32_t mem_alloc_start_ind;
const char *entry_state_str[TPM_MOD_ENTRY_STATUS_MAX] = { "F", "B", "O", "R", "S" };
uint32_t *tpm_db_mod2_jump_booked_entry_bm[TPM_MAX_NUM_GMACS];
uint32_t *tpm_db_mod2_jump_occupied_entry_bm[TPM_MAX_NUM_GMACS];
uint32_t *tpm_db_mod2_jump_split_mod_occupied_entry_bm[TPM_MAX_NUM_GMACS];
uint32_t *tpm_db_mod2_jump_split_mod_all_entry_bm[TPM_MAX_NUM_GMACS];
uint32_t tpm_db_mod2_jump_bm_group;
uint32_t *tpm_db_mod2_chain_booked_entry_bm[TPM_MAX_NUM_GMACS][TPM_CHAIN_TYPE_MAX];
uint32_t *tpm_db_mod2_chain_occupied_entry_bm[TPM_MAX_NUM_GMACS][TPM_CHAIN_TYPE_MAX];
uint32_t tpm_db_mod2_chain_bm_group[TPM_CHAIN_TYPE_MAX];
tpm_mod2_jump_pmt_info_t *tpm_db_mod2_jump_pmt_info[TPM_MAX_NUM_GMACS];
tpm_mod2_chain_pmt_info_t *tpm_db_mod2_chain_pmt_info[TPM_MAX_NUM_GMACS];
tpm_mod2_chain_info_t *tpm_db_mod2_chain_info[TPM_MAX_NUM_GMACS][TPM_CHAIN_TYPE_MAX];
tpm_mod2_jump_cfg_t tpm_db_mod2_jump_area_cfg;
tpm_mod2_chain_cfg_t tpm_db_mod2_chain_cfg[TPM_CHAIN_TYPE_MAX];
uint16_t tpm_mod2_chain_area_base;
uint16_t tpm_mod2_total_chain_num;
uint8_t tpm_mod2_multicast_mh_enable;
uint8_t tpm_mod2_pppoe_add_mod_enable;
uint8_t tpm_mod2_double_tag_enable;
uint8_t tpm_mod2_udp_checksum_use_init_bm_enable;
uint8_t tpm_mod2_udp_checksum_enable;
tpm_db_mc_stream_entry_t *tpm_db_mc_stream_table[TPM_MC_MAX_STREAM_NUM];
tpm_db_mc_mac_entry_t *tpm_db_mc_mac_table[TPM_MC_MAX_MAC_NUM];
uint32_t tpm_db_mc_lpbk_entries_num;
tpm_db_mc_lpbk_entry_t *tpm_db_mc_lpbk_table[TPM_MC_MAX_LPBK_ENTRIES_NUM];
tpm_db_mc_vlan_entry_t *tpm_db_mc_vlan_xits_table[TPM_MC_MAX_MVLAN_XITS_NUM];
uint8_t tpm_db_mc_virt_uni_entry_state_table[TPM_MC_MAX_STREAM_NUM];
uint8_t tpm_db_mc_igmp_proxy_sa_mac[6];
uint8_t tpm_db_mc_igmp_proxy_sa_mac_valid;
static uint32_t tpm_db_global_rule_idx = 1000;
/* Function Declarations */
int32_t tpm_db_api_freeentry_get(tpm_api_sections_t api_section, int32_t *index);
int32_t tpm_db_api_entry_ind_get(tpm_api_sections_t api_section, uint32_t rule_num, int32_t *index);
int32_t tpm_db_mod_shdw_par_check(tpm_gmacs_enum_t gmac, uint32_t mod_entry);
/*******************************************************************************
* tpm_db_eth_port_conf_get()
*
* DESCRIPTION: Function to get an ethernet port physical configuration from the DB
*
* INPUTS:
* ext_port - External Port Identifier, can be any positive number
*
* OUTPUTS:
* - See explanation in tpm_db_eth_port_conf_t structure
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS: Perfom only DB integrity checks, not data correctness checks
*
*******************************************************************************/
bool tpm_db_eth_port_valid(tpm_src_port_type_t src_port_num)
{
uint32_t i;
for (i = 0; i < TPM_MAX_NUM_ETH_PORTS; i++) {
if ((tpm_db.eth_ports[i].port_src == src_port_num)
&& (tpm_db.eth_ports[i].valid == TPM_DB_VALID))
return (true);
}
return false;
}
/*******************************************************************************
* tpm_db_eth_port_conf_get()
*
* DESCRIPTION: Function to get an ethernet port physical configuration from the DB
*
* INPUTS:
* ext_port - External Port Identifier, can be any positive number
*
* OUTPUTS:
* - See explanation in tpm_db_eth_port_conf_t structure
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS: Perfom only DB integrity checks, not data correctness checks
*
*******************************************************************************/
int32_t tpm_db_eth_port_conf_get(tpm_src_port_type_t src_port_num,
tpm_db_chip_conn_t *chip_con,
tpm_db_int_conn_t *int_con,
uint32_t *switch_port)
{
uint32_t i;
for (i = 0; i < TPM_MAX_NUM_ETH_PORTS; i++) {
if ((tpm_db.eth_ports[i].port_src == src_port_num)
&& (tpm_db.eth_ports[i].valid == TPM_DB_VALID)) {
*chip_con = tpm_db.eth_ports[i].chip_connect;
*int_con = tpm_db.eth_ports[i].int_connect;
*switch_port = tpm_db.eth_ports[i].switch_port;
return (TPM_DB_OK);
}
}
return (TPM_DB_ERR_REC_NOT_EXIST);
}
/*******************************************************************************
* tpm_db_eth_port_switch_port_get()
*
* DESCRIPTION: Function to get an ethernet port physical configuration from the DB
*
* INPUTS:
* ext_port - UNI Port Identifier, can be any positive number
*
* OUTPUTS:
*
* RETURNS:
* On success, the function returns the switch port number.
* On error, TPM_DB_ERR_PORT_NUM = 0xFF is returned.
*
* COMMENTS:
*
*******************************************************************************/
int32_t tpm_db_eth_port_switch_port_get(tpm_src_port_type_t src_port)
{
uint32_t i;
if (TPM_SRC_PORT_UNI_VIRT == src_port) {
if (TPM_DB_VALID == tpm_db.func_profile.virt_uni_info.enabled)
return tpm_db.func_profile.virt_uni_info.switch_port;
else
return TPM_DB_ERR_PORT_NUM;
} else if (TPM_SRC_PORT_WAN == src_port) {
for (i = TPM_ENUM_GMAC_0; i < TPM_MAX_GMAC; i++) {
/* in case traffic from WAN, the dest is LAN,
so we search for switch port connected to GMAC LAN functionality */
if (TPM_GMAC_FUNC_LAN == tpm_db.gmac_func[i]){
if (TPM_GMAC_CON_SWITCH_4 == tpm_db.gmac_port_conf[i].conn)
return TPM_GMAC0_AMBER_PORT_NUM;
else
return TPM_GMAC1_AMBER_PORT_NUM;
}
}
} else {
for (i = 0; i < TPM_MAX_NUM_ETH_PORTS; i++) {
if ((tpm_db.eth_ports[i].port_src == src_port) &&
(TPM_DB_VALID == tpm_db.eth_ports[i].valid))
return (tpm_db.eth_ports[i].switch_port);
}
}
return (TPM_DB_ERR_PORT_NUM);
}
uint32_t tpm_db_rule_index_get(void)
{
return tpm_db_global_rule_idx;
}
int32_t tpm_db_rule_index_set(uint32_t rule_index)
{
tpm_db_global_rule_idx = rule_index;
return TPM_DB_OK;
}
void tpm_db_rule_index_incrs(void)
{
tpm_db_global_rule_idx++;
}
bool tpm_db_gmac1_lpbk_en_get(void)
{
return tpm_db.func_profile.gmac1_loopback_en;
}
void tpm_db_gmac1_lpbk_en_set(bool en)
{
tpm_db.func_profile.gmac1_loopback_en = en;
}
bool tpm_db_cpu_wan_lpbk_en_get(void)
{
return tpm_db.func_profile.cpu_wan_loopback_en;
}
void tpm_db_cpu_wan_lpbk_en_set(bool en)
{
tpm_db.func_profile.cpu_wan_loopback_en = en;
}
bool tpm_db_ds_load_bal_en_get(void)
{
return tpm_db.func_profile.ds_load_bal_en;
}
void tpm_db_ds_load_bal_en_set(bool en)
{
tpm_db.func_profile.ds_load_bal_en = en;
}
bool tpm_db_switch_active_wan_en_get(void)
{
return tpm_db.func_profile.switch_active_wan_en;
}
void tpm_db_switch_active_wan_en_set(bool en)
{
tpm_db.func_profile.switch_active_wan_en = en;
}
int32_t tpm_db_get_valid_uni_ports_num(uint32_t *num_ports)
{
uint32_t i, _num_ports = 0;
for (i = 0; i < TPM_MAX_NUM_ETH_PORTS; i++) {
if (tpm_db.eth_ports[i].valid == TPM_DB_VALID) {
if (tpm_db.eth_ports[i].port_src >= TPM_SRC_PORT_UNI_0 &&
tpm_db.eth_ports[i].port_src <= TPM_SRC_PORT_UNI_7)
_num_ports++;
}
}
if (tpm_db.func_profile.virt_uni_info.enabled == TPM_DB_VALID)
_num_ports++;
return (TPM_DB_OK);
}
/*******************************************************************************
* tpm_db_phy_convert_port_index()
*
* DESCRIPTION: Function to get an ethernet port physical configuration from the DB
*
* INPUTS:
* switch_port - External Port Identifier, can be any positive number
*
* OUTPUTS:
*
* RETURNS:
* On success, the function returns the switch port number.
* On error, TPM_DB_ERR_PORT_NUM = 0xFF is returned.
*
* COMMENTS:
*
*******************************************************************************/
int32_t tpm_db_phy_convert_port_index(int32_t switch_port)
{
uint32_t i;
for (i = 0; i < TPM_MAX_NUM_ETH_PORTS; i++) {
if ((tpm_db.eth_ports[i].switch_port == switch_port)
&& (tpm_db.eth_ports[i].valid == TPM_DB_VALID))
return (tpm_db.eth_ports[i].port_src);
}
return (TPM_DB_ERR_PORT_NUM);
}
EXPORT_SYMBOL(tpm_db_phy_convert_port_index);
/*******************************************************************************
* tpm_db_eth_cmplx_profile_set()
*
* DESCRIPTION: Function to set the Ethernet Complex Profile in the DB
*
* INPUTS:
* eth_cmplx_profile - the profile enumartion number
*
* OUTPUTS:
*
* RETURNS:
*
* COMMENTS:
*
*******************************************************************************/
int32_t tpm_db_eth_cmplx_profile_set(tpm_eth_complex_profile_t eth_cmplx_profile)
{
tpm_db.eth_cmplx_profile = eth_cmplx_profile;
return (TPM_DB_OK);
}
/*******************************************************************************
* tpm_db_eth_cmplx_profile_get()
*
* DESCRIPTION: Function returns the Ethernet Complex Profile from the DB
*
* INPUTS:
*
* OUTPUTS:
* the profile enumartion number
* RETURNS:
*
* COMMENTS:
*
*******************************************************************************/
tpm_eth_complex_profile_t tpm_db_eth_cmplx_profile_get(void)
{
return tpm_db.eth_cmplx_profile;
}
/*******************************************************************************
* tpm_db_mac_func_set()
*
* DESCRIPTION: Sets all gmacs functionality according to EthCmplx profile
*
* INPUTS:
*
* OUTPUTS:
*
* RETURNS:
*
* COMMENTS:
* On success, returns TPM_OK
* On error, returns tpm_db_gmac_func_set error
*******************************************************************************/
int32_t tpm_db_mac_func_set(void)
{
tpm_db_gmac_func_t pon = 0,
gmac0 = 0,
gmac1 = 0;
int32_t ret_code;
tpm_db_ds_mac_based_trunk_enable_t ds_mac_based_trunk_enable;
#ifdef CONFIG_MV_INCLUDE_PON
PON_SHUTDOWN_FUNC pon_callback_func = NULL;
#endif
switch(tpm_db.eth_cmplx_profile)
{
case TPM_PON_WAN_DUAL_MAC_INT_SWITCH:
pon = TPM_GMAC_FUNC_WAN;
gmac0 = TPM_GMAC_FUNC_LAN;
if (0 != tpm_db.func_profile.virt_uni_info.enabled)
gmac1 = TPM_GMAC_FUNC_VIRT_UNI;
else
gmac1 = TPM_GMAC_FUNC_NONE;
break;
case TPM_PON_WAN_DUAL_MAC_EXT_SWITCH:
/* ofer: phase#2, diferentiate between gmacs */
pon = TPM_GMAC_FUNC_WAN;
gmac0 = TPM_GMAC_FUNC_LAN;
gmac1 = TPM_GMAC_FUNC_NONE;
break;
case TPM_PON_WAN_G1_LAN_G0_INT_SWITCH:
pon = TPM_GMAC_FUNC_WAN;
gmac0 = TPM_GMAC_FUNC_LAN;
gmac1 = TPM_GMAC_FUNC_LAN_UNI;
break;
case TPM_PON_WAN_G0_INT_SWITCH:
pon = TPM_GMAC_FUNC_WAN;
gmac0 = TPM_GMAC_FUNC_LAN;
gmac1 = TPM_GMAC_FUNC_NONE;
break;
case TPM_PON_WAN_G0_SINGLE_PORT:
pon = TPM_GMAC_FUNC_WAN;
gmac0 = TPM_GMAC_FUNC_LAN;
gmac1 = TPM_GMAC_FUNC_NONE;
break;
case TPM_G0_WAN_G1_INT_SWITCH:
pon = TPM_GMAC_FUNC_NONE;
gmac0 = TPM_GMAC_FUNC_WAN;
gmac1 = TPM_GMAC_FUNC_LAN;
break;
case TPM_G1_WAN_G0_INT_SWITCH:
pon = TPM_GMAC_FUNC_NONE;
gmac0 = TPM_GMAC_FUNC_LAN;
gmac1 = TPM_GMAC_FUNC_WAN;
break;
case TPM_PON_G1_WAN_G0_INT_SWITCH:
if (TPM_ENUM_GMAC_1 == tpm_db.init_misc.active_wan) {
pon = TPM_GMAC_FUNC_NONE;
gmac1 = TPM_GMAC_FUNC_WAN;
}else{
gmac1 = TPM_GMAC_FUNC_NONE;
pon = TPM_GMAC_FUNC_WAN;
}
gmac0 = TPM_GMAC_FUNC_LAN;
break;
case TPM_PON_G1_WAN_G0_SINGLE_PORT:
if (TPM_ENUM_GMAC_1 == tpm_db.init_misc.active_wan) {
pon = TPM_GMAC_FUNC_NONE;
gmac1 = TPM_GMAC_FUNC_WAN;
}else{
gmac1 = TPM_GMAC_FUNC_NONE;
pon = TPM_GMAC_FUNC_WAN;
}
gmac0 = TPM_GMAC_FUNC_LAN_UNI;
break;
case TPM_PON_G0_WAN_G1_INT_SWITCH:
if (TPM_ENUM_GMAC_0 == tpm_db.init_misc.active_wan) {
pon = TPM_GMAC_FUNC_NONE;
gmac0 = TPM_GMAC_FUNC_WAN;
}else{
gmac0 = TPM_GMAC_FUNC_NONE;
pon = TPM_GMAC_FUNC_WAN;
}
gmac1 = TPM_GMAC_FUNC_LAN_UNI;
break;
case TPM_PON_G0_WAN_G1_SINGLE_PORT:
if (TPM_ENUM_GMAC_0 == tpm_db.init_misc.active_wan) {
pon = TPM_GMAC_FUNC_NONE;
gmac0 = TPM_GMAC_FUNC_WAN;
}else{
gmac0 = TPM_GMAC_FUNC_NONE;
pon = TPM_GMAC_FUNC_WAN;
}
gmac1 = TPM_GMAC_FUNC_LAN;
break;
case TPM_PON_WAN_G1_MNG_EXT_SWITCH:
case TPM_PON_WAN_G1_SINGLE_PORT:
pon = TPM_GMAC_FUNC_WAN;
gmac0 = TPM_GMAC_FUNC_NONE;
gmac1 = TPM_GMAC_FUNC_LAN_UNI;
break;
case TPM_PON_WAN_G0_G1_LPBK:
pon = TPM_GMAC_FUNC_WAN;
gmac0 = TPM_GMAC_FUNC_US_MAC_LEARN_DS_LAN_UNI;
gmac1 = TPM_GMAC_FUNC_LAN;
break;
case TPM_PON_WAN_G0_G1_DUAL_LAN:
pon = TPM_GMAC_FUNC_WAN;
gmac0 = TPM_GMAC_FUNC_LAN_UNI;
gmac1 = TPM_GMAC_FUNC_LAN_UNI;
break;
}
/* when ds load balance on G0 and G1 is enabled, G0/1 are both LAN */
tpm_db_ds_mac_based_trunk_enable_get(&ds_mac_based_trunk_enable);
if (TPM_DS_MAC_BASED_TRUNK_ENABLED == ds_mac_based_trunk_enable)
gmac1 = TPM_GMAC_FUNC_LAN;
ret_code = tpm_db_gmac_func_set(TPM_ENUM_PMAC, pon);
IF_ERROR(ret_code);
ret_code = tpm_db_gmac_func_set(TPM_ENUM_GMAC_0, gmac0);
IF_ERROR(ret_code);
ret_code = tpm_db_gmac_func_set(TPM_ENUM_GMAC_1, gmac1);
IF_ERROR(ret_code);
#ifdef CONFIG_MV_INCLUDE_PON
/* shut down or enable PON */
ret_code = tpm_db_get_pon_callback(&pon_callback_func);
IF_ERROR(ret_code);
if (pon_callback_func) {
if (pon == TPM_GMAC_FUNC_WAN)
pon_callback_func(1);
else
pon_callback_func(0);
}
#endif
return (TPM_OK);
}
/*******************************************************************************
* tpm_db_eth_max_uni_port_set()
*
* DESCRIPTION: Sets the max_uni_port_nr according to EthCmplx profile
*
* INPUTS:
*
* OUTPUTS:
*
* RETURNS:
*
* COMMENTS:
* On success, returns TPM_OK
* On error, returns tpm_db_gmac_func_set error
*******************************************************************************/
int32_t tpm_db_eth_max_uni_port_set(void)
{
switch (tpm_db.eth_cmplx_profile) {
case TPM_PON_WAN_G0_SINGLE_PORT:
case TPM_PON_WAN_G1_SINGLE_PORT:
case TPM_PON_WAN_G0_G1_LPBK:
tpm_db.max_uni_port_nr = TPM_SRC_PORT_UNI_0;
break;
case TPM_PON_G0_WAN_G1_SINGLE_PORT:
case TPM_PON_G1_WAN_G0_SINGLE_PORT:
case TPM_PON_WAN_G0_G1_DUAL_LAN:
tpm_db.max_uni_port_nr = TPM_SRC_PORT_UNI_1;
break;
case TPM_PON_WAN_G0_INT_SWITCH:
case TPM_PON_WAN_G1_LAN_G0_INT_SWITCH:
case TPM_PON_WAN_DUAL_MAC_INT_SWITCH:
case TPM_G0_WAN_G1_INT_SWITCH:
case TPM_G1_WAN_G0_INT_SWITCH:
case TPM_PON_G1_WAN_G0_INT_SWITCH:
case TPM_PON_G0_WAN_G1_INT_SWITCH:
tpm_db.max_uni_port_nr = TPM_SRC_PORT_UNI_3;
break;
case TPM_PON_WAN_G1_MNG_EXT_SWITCH:
tpm_db.max_uni_port_nr = TPM_SRC_PORT_UNI_6;
break;
case TPM_PON_WAN_DUAL_MAC_EXT_SWITCH:
tpm_db.max_uni_port_nr = TPM_SRC_PORT_UNI_7;
break;
default:
return TPM_DB_ERR_REC_EXIST;
}
/* increment the counter since UNI enumeration starts @ zero */
tpm_db.max_uni_port_nr++;
return (TPM_DB_OK);
}
tpm_src_port_type_t tpm_db_trg_port_uni_any_bmp_get(bool inc_virt_uni)
{
uint32_t dst_port, trg_port_uni_any_bmp = 0;
tpm_src_port_type_t src_port;
for (dst_port = TPM_TRG_UNI_0, src_port = TPM_SRC_PORT_UNI_0;
dst_port <= TPM_TRG_UNI_7;
dst_port = (dst_port << 1), src_port += 1) {
/* if port is valid */
if(tpm_db_eth_port_valid(src_port))
trg_port_uni_any_bmp |= dst_port;
}
if (tpm_db.func_profile.virt_uni_info.enabled != 0 && true == inc_virt_uni)
trg_port_uni_any_bmp |= TPM_TRG_UNI_VIRT;
return trg_port_uni_any_bmp;
}
bool tpm_db_gmac_valid(tpm_gmacs_enum_t gmac)
{
if (((TPM_ENUM_PMAC == gmac) && (TPM_NONE != tpm_db.init_misc.pon_type)) ||
((1 == tpm_db.gmac_port_conf[gmac].valid) && (TPM_GMAC_CON_DISC != tpm_db.gmac_port_conf[gmac].conn)))
return true;
return false;
}
int32_t tpm_db_target_to_gmac(tpm_pnc_trg_t pnc_target, tpm_gmacs_enum_t *gmac)
{
if (TPM_PNC_TRG_GMAC0 == pnc_target)
*gmac = TPM_ENUM_GMAC_0;
else if (TPM_PNC_TRG_GMAC1 == pnc_target)
*gmac = TPM_ENUM_GMAC_1;
else if (TPM_PNC_TRG_CPU == pnc_target) {
TPM_OS_ERROR(TPM_DB_MOD, "target to CPU, no GMAC valid\n");
return TPM_DB_ERR_INV_INPUT;
} else
*gmac = TPM_ENUM_PMAC;
return TPM_DB_OK;
}
/*******************************************************************************
* tpm_db_to_lan_gmac_get()
*
* DESCRIPTION: returns the GMAC target for traffic to LAN according to target
* port bitmap
* INPUTS:
* trg_port target port bitmap
*
* OUTPUTS:
* pnc_target gmac target
*
* RETURNS:
* On success, the function returns TPM_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS:
*
*******************************************************************************/
int32_t tpm_db_to_lan_gmac_get(tpm_trg_port_type_t trg_port, tpm_pnc_trg_t *pnc_target)
{
uint32_t i;
tpm_pnc_trg_t gmac_vec = 0;
bool trg_port_on_switch = false;
if (NULL == pnc_target)
return (TPM_DB_ERR_INV_INPUT);
*pnc_target = TPM_INVALID_PNC_TRG;
/* for UNI_ANY we search the gmac_func for lan cababilities */
if (TPM_TRG_PORT_UNI_ANY == trg_port) {
for (i = TPM_ENUM_GMAC_0; i < TPM_MAX_GMAC; i++) {
if (!tpm_db_gmac_valid(i))
continue;
if (!tpm_db_gmac1_lpbk_en_get()) {
if (TPM_GMAC_FUNC_LAN == tpm_db.gmac_func[i] ||
TPM_GMAC_FUNC_LAN_UNI == tpm_db.gmac_func[i]) {
gmac_vec |= (TPM_ENUM_GMAC_0 == i) ? TPM_PNC_TRG_GMAC0 : TPM_PNC_TRG_GMAC1;
break;/* target only one, no others */
}
} else {
gmac_vec |= TPM_PNC_TRG_GMAC0;
break;
}
}
TPM_OS_DEBUG(TPM_TPM_LOG_MOD, "trg_port(%x) gmac_vec(%x)\n", trg_port, gmac_vec);
*pnc_target = gmac_vec;
return TPM_DB_OK;
}
/* if target is virt uni, search for the gmac that acts as LAN */
if (TPM_TRG_UNI_VIRT & trg_port) {
for (i = TPM_ENUM_GMAC_0; i < TPM_MAX_GMAC; i++) {
if (!tpm_db_gmac_valid(i))
continue;
/* need only virt uni lan ports */
if (TPM_GMAC_FUNC_LAN == tpm_db.gmac_func[i]){
gmac_vec |= (TPM_ENUM_GMAC_0 == i) ? TPM_PNC_TRG_GMAC0 : TPM_PNC_TRG_GMAC1;
break;
}
}
}
/* search ethernet ports */
for (i = 0; i < TPM_MAX_NUM_ETH_PORTS; i++) {
if (TPM_DB_VALID != tpm_db.eth_ports[i].valid ||
TPM_SRC_PORT_ILLEGAL == tpm_db.eth_ports[i].port_src ||
TPM_SRC_PORT_WAN == tpm_db.eth_ports[i].port_src)
continue;
if ((1 << tpm_db.eth_ports[i].port_src) & (trg_port >> TPM_TRG_UNI_OFFSET)){
if (TPM_INTCON_SWITCH == tpm_db.eth_ports[i].int_connect) {
/* port on switch, set the flag */
trg_port_on_switch = true;
} else if (TPM_INTCON_GMAC0 == tpm_db.eth_ports[i].int_connect){
/* port on GMAC0 */
gmac_vec |= TPM_PNC_TRG_GMAC0;
} else if (TPM_INTCON_GMAC1 == tpm_db.eth_ports[i].int_connect){
/* port on GMAC1 */
gmac_vec |= TPM_PNC_TRG_GMAC1;
}
}
}
/* if port connected to switch, search gmac_func for the connected GMAC */
if (true == trg_port_on_switch) {
for (i = TPM_ENUM_GMAC_0; i < TPM_MAX_GMAC; i++) {
if (!tpm_db_gmac_valid(i))
continue;
/* need only LAN ports */
if (TPM_GMAC_FUNC_LAN == tpm_db.gmac_func[i] ||
TPM_GMAC_FUNC_LAN_UNI == tpm_db.gmac_func[i]){
if (TPM_GMAC_CON_SWITCH_4 == tpm_db.gmac_port_conf[i].conn ||
TPM_GMAC_CON_SWITCH_5 == tpm_db.gmac_port_conf[i].conn) {
gmac_vec |= (TPM_ENUM_GMAC_0 == i) ? TPM_PNC_TRG_GMAC0 : TPM_PNC_TRG_GMAC1;
}
}
}
}
if (TPM_INVALID_PNC_TRG == gmac_vec)
return TPM_DB_ERR_REC_NOT_EXIST;
TPM_OS_DEBUG(TPM_TPM_LOG_MOD, "trg_port(%x) gmac_vec(%x)\n", trg_port, gmac_vec);
*pnc_target = gmac_vec;
return TPM_DB_OK;
}
/*******************************************************************************
* tpm_db_src_gmac_func_get()
*
* DESCRIPTION: returns the GMAC target for traffic to LAN according to target
* port bitmap
* INPUTS:
* trg_port target port bitmap
*
* OUTPUTS:
* pnc_target gmac target
*
* RETURNS:
* On success, the function returns TPM_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS:
*
*******************************************************************************/
int32_t tpm_db_src_gmac_func_get(tpm_src_port_type_t src_port, tpm_db_gmac_func_t *gmac_func)
{
uint32_t i;
if (NULL == gmac_func)
return (TPM_DB_ERR_INV_INPUT);
*gmac_func = TPM_GMAC_FUNC_NONE;
if (TPM_SRC_PORT_WAN == src_port){
*gmac_func = TPM_GMAC_FUNC_WAN;
return TPM_DB_OK;
}
if (TPM_SRC_PORT_UNI_VIRT == src_port){
if (TPM_FALSE == tpm_db.func_profile.virt_uni_info.enabled)
return TPM_DB_ERR_REC_NOT_EXIST;
tpm_db_gmac_func_get(TPM_ENUM_GMAC_1, gmac_func);
return TPM_DB_OK;
}
/* start gmac ports */
for (i = 0; i < TPM_NUM_GMACS; i++) {
if (TPM_FALSE == tpm_db.gmac_port_conf[i].valid)
continue;
if (tpm_db.gmac_port_conf[i].port_src == src_port){
*gmac_func = tpm_db.gmac_func[i];
return TPM_DB_OK;
}
}
/* search switch ports */
for (i = 0; i < TPM_MAX_NUM_ETH_PORTS; i++) {
if (TPM_DB_VALID != tpm_db.eth_ports[i].valid)
continue;
/* port_src found on switch */
if (tpm_db.eth_ports[i].port_src == src_port){
uint32_t j;
/* now search gmac table to find connecting port */
for (j = 0; j < TPM_NUM_GMACS-1; j++) {
if (TPM_FALSE == tpm_db.gmac_port_conf[j].valid)
continue;
if ((TPM_SRC_PORT_ILLEGAL == tpm_db.gmac_port_conf[j].port_src) &&
((TPM_GMAC_CON_SWITCH_5 == tpm_db.gmac_port_conf[j].conn) ||
(TPM_GMAC_CON_SWITCH_4 == tpm_db.gmac_port_conf[j].conn))){
*gmac_func = (TPM_ENUM_GMAC_0 == i) ? tpm_db.gmac_func[0] : tpm_db.gmac_func[1];
return TPM_DB_OK;
}
}
}
}
return TPM_DB_ERR_REC_NOT_EXIST;
}
int32_t tpm_db_src_port_on_switch(tpm_src_port_type_t src_port)
{
uint32_t i;
/* switch ports can not act as WAN source port */
if (TPM_SRC_PORT_WAN == src_port)
return TPM_FALSE;
/* start gmac ports */
for (i = 0; i < TPM_NUM_GMACS; i++) {
if (TPM_FALSE == tpm_db.gmac_port_conf[i].valid)
continue;
if (tpm_db.gmac_port_conf[i].port_src == src_port)
return TPM_FALSE;
}
/* search switch ports */
for (i = 0; i < TPM_MAX_NUM_ETH_PORTS; i++) {
if (TPM_DB_VALID != tpm_db.eth_ports[i].valid)
continue;
if (tpm_db.eth_ports[i].port_src == src_port)
return TPM_TRUE;
}
return TPM_FALSE;
}
/*******************************************************************************
* tpm_db_trg_port_switch_port_get()
*
* DESCRIPTION: Function to get the target port bitmap
*
* INPUTS:
* ext_port - External Port Identifier, can be any positive number
*
* OUTPUTS:
*
* RETURNS:
* The function returns the target ports bitmap for an external port.
* In case of no matching - it returns empty bitmap 0x0.
*
* COMMENTS:
*
*******************************************************************************/
int32_t tpm_db_trg_port_switch_port_get(tpm_trg_port_type_t ext_port)
{
uint32_t portVec = 0;
if (ext_port & TPM_TRG_PORT_UNI_ANY) {
ext_port |= (TPM_TRG_UNI_0 | TPM_TRG_UNI_1 | TPM_TRG_UNI_2 | TPM_TRG_UNI_3 |
TPM_TRG_UNI_4 | TPM_TRG_UNI_5 | TPM_TRG_UNI_6 | TPM_TRG_UNI_7);
if (tpm_db.func_profile.virt_uni_info.enabled != 0)
ext_port |= TPM_TRG_UNI_VIRT;
}
if (ext_port & TPM_TRG_UNI_0)
portVec |= 1 << tpm_db_eth_port_switch_port_get(TPM_SRC_PORT_UNI_0);
if (ext_port & TPM_TRG_UNI_1)
portVec |= 1 << tpm_db_eth_port_switch_port_get(TPM_SRC_PORT_UNI_1);
if (ext_port & TPM_TRG_UNI_2)
portVec |= 1 << tpm_db_eth_port_switch_port_get(TPM_SRC_PORT_UNI_2);
if (ext_port & TPM_TRG_UNI_3)
portVec |= 1 << tpm_db_eth_port_switch_port_get(TPM_SRC_PORT_UNI_3);
if (ext_port & TPM_TRG_UNI_4)
portVec |= 1 << tpm_db_eth_port_switch_port_get(TPM_SRC_PORT_UNI_4);
if (ext_port & TPM_TRG_UNI_5)
portVec |= 1 << tpm_db_eth_port_switch_port_get(TPM_SRC_PORT_UNI_5);
if (ext_port & TPM_TRG_UNI_6)
portVec |= 1 << tpm_db_eth_port_switch_port_get(TPM_SRC_PORT_UNI_6);
if (ext_port & TPM_TRG_UNI_7)
portVec |= 1 << tpm_db_eth_port_switch_port_get(TPM_SRC_PORT_UNI_7);
if (ext_port & TPM_TRG_UNI_VIRT)
portVec |= 1 << tpm_db_eth_port_switch_port_get(TPM_SRC_PORT_UNI_VIRT);
if (ext_port & TPM_TRG_PORT_CPU)
portVec |= 1 << tpm_db_eth_port_switch_port_get(TPM_SRC_PORT_WAN);
return (portVec);
}
/*******************************************************************************
* tpm_db_eth_port_conf_set()
*
* DESCRIPTION: Function to set an ethernet physical and internal configuration in the DB
*
* INPUTS:
* ext_port - External Port Identifier, can be any positive number
* other inputs - See explanation in tpm_db_eth_port_conf_t structure
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS: Perfom only DB integrity checks, not data correctness checks
*
*******************************************************************************/
int32_t tpm_db_eth_port_conf_set(tpm_init_eth_port_conf_t *eth_port_conf)
{
uint32_t i;
int32_t free_entry = -1;
if (NULL == eth_port_conf)
return (TPM_DB_ERR_INV_INPUT);
TPM_OS_DEBUG(TPM_DB_MOD, "src_port (%d)\n", eth_port_conf->port_src);
for (i = 0; i < TPM_MAX_NUM_ETH_PORTS; i++) {
/* Check entry does not exist */
if ((tpm_db.eth_ports[i].port_src == eth_port_conf->port_src)
&& (tpm_db.eth_ports[i].valid == TPM_DB_VALID))
return (TPM_DB_ERR_REC_EXIST);
/* Find first invalid entry */
if ((free_entry == -1) && (tpm_db.eth_ports[i].valid == TPM_DB_INVALID))
free_entry = i;
}
/* No free Entry */
if (free_entry == -1)
return (TPM_DB_ERR_DB_TBL_FULL);
/* Set entry */
tpm_db.eth_ports[free_entry].port_src = eth_port_conf->port_src;
tpm_db.eth_ports[free_entry].int_connect = eth_port_conf->int_connect;
tpm_db.eth_ports[free_entry].chip_connect = eth_port_conf->chip_connect;
tpm_db.eth_ports[free_entry].switch_port = eth_port_conf->switch_port;
tpm_db.eth_ports[free_entry].valid = TPM_DB_VALID;
return (TPM_DB_OK);
}
int32_t tpm_db_gmac_conn_conf_set(tpm_init_gmac_conn_conf_t *gmac_port_conf, uint32_t arr_size)
{
uint32_t i;
if (NULL == gmac_port_conf)
return (TPM_DB_ERR_INV_INPUT);
for (i = 0; i < arr_size; i++) {
TPM_OS_DEBUG(TPM_DB_MOD, "gmac src_port (%d)\n", gmac_port_conf[i].port_src);
/* Set entry */
tpm_db.gmac_port_conf[i].port_src = gmac_port_conf[i].port_src;
tpm_db.gmac_port_conf[i].conn = gmac_port_conf[i].conn;
tpm_db.gmac_port_conf[i].valid = gmac_port_conf[i].valid;
}
return (TPM_DB_OK);
}
/*******************************************************************************
* tpm_db_gmac_conn_conf_get()
*
* DESCRIPTION: Function to get GMAC connection information from DB
*
* INPUTS:
* gmac - GMAC port
*
* OUTPUTS:
* gmac_port_conf - connection info
*
* RETURNS:
* On success, the function returns TPM_DB_OK.
*
*******************************************************************************/
int32_t tpm_db_gmac_conn_conf_get(tpm_gmacs_enum_t gmac, tpm_init_gmac_conn_conf_t *gmac_port_conf)
{
if (NULL == gmac_port_conf)
return (TPM_DB_ERR_INV_INPUT);
memcpy(gmac_port_conf, &tpm_db.gmac_port_conf[gmac], sizeof(tpm_init_gmac_conn_conf_t));
return (TPM_DB_OK);
}
/*******************************************************************************
* tpm_db_gmac_tcont_llid_set()
*
* DESCRIPTION: Function to set the GMAC connection and T-CONTs in the DB
*
* INPUTS:
* num_tcont_llid - Number of T-CONTs/LLIDs
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS: Perfom only DB integrity checks, not data correctness checks
*
*******************************************************************************/
int32_t tpm_db_gmac_tcont_llid_set(uint32_t num_tcont_llid)
{
tpm_db.num_valid_tcont_llid = num_tcont_llid;
return (TPM_DB_OK);
}
/*******************************************************************************
* tpm_db_gmac_conn_get()
*
* DESCRIPTION: Function to get the Connection of an Ethernet GMAC
*
* INPUTS:
* gmac - GMAC number
* OUTPUTS:
* gmac_con - GMAC internal Physical connection (see tpm_db_gmac_conn_t)
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS: Perfom only DB integrity checks, not data correctness checks
*
*******************************************************************************/
int32_t tpm_db_gmac_conn_get(tpm_gmacs_enum_t gmac, tpm_db_gmac_conn_t *gmac_con)
{
if (gmac == TPM_ENUM_GMAC_0)
*gmac_con = tpm_db.gmac_port_conf[0].conn;
else if (gmac == TPM_ENUM_GMAC_1)
*gmac_con = tpm_db.gmac_port_conf[1].conn;
else
return (TPM_DB_ERR_INV_INPUT);
return (TPM_DB_OK);
}
/*******************************************************************************
* tpm_db_gmac_mh_en_conf_set()
*
* DESCRIPTION: Function to set the GMAC connection and T-CONTs in the DB
*
* INPUTS:
* gmac - GMAC
* mh_en - MH enable TRUE/FALSE
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS: Perfom only DB integrity checks, not data correctness checks
*
*******************************************************************************/
int32_t tpm_db_gmac_mh_en_conf_set(tpm_gmacs_enum_t gmac, uint32_t mh_en)
{
tpm_db.gmac_mh_en[gmac] = mh_en;
return (TPM_DB_OK);
}
/*******************************************************************************
* tpm_db_gmac_mh_en_conf_get()
*
* DESCRIPTION: Function to set the GMAC connection and T-CONTs in the DB
*
* INPUTS:
* gmac - GMAC
*
* OUTPUTS:
* mh_en - MH enable TRUE/FALSE
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS: Perfom only DB integrity checks, not data correctness checks
*
*******************************************************************************/
int32_t tpm_db_gmac_mh_en_conf_get(tpm_gmacs_enum_t gmac, uint32_t *mh_en)
{
*mh_en = tpm_db.gmac_mh_en[gmac];
return (TPM_DB_OK);
}
/*******************************************************************************
* tpm_db_gmac_bm_bufs_conf_set()
*
* DESCRIPTION: Function to set the GMAC number of Buffer Mngmt large_bufers, short_buffers
*
* INPUTS:
* gmac - GMAC
* large_pkt_buffers - number of buffers in the GMAC long packets pool
* small_pkt_buffers - number of buffers in the GMAC short packets pool
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS: Perfom only DB integrity checks, not data correctness checks
*
*******************************************************************************/
int32_t tpm_db_gmac_bm_bufs_conf_set(tpm_gmacs_enum_t gmac, uint32_t large_pkt_buffers, uint32_t small_pkt_buffers)
{
tpm_db.gmac_bp_bufs[gmac].valid = TPM_DB_VALID;
tpm_db.gmac_bp_bufs[gmac].large_pkt_buffers = large_pkt_buffers;
tpm_db.gmac_bp_bufs[gmac].small_pkt_buffers = small_pkt_buffers;
return (TPM_DB_OK);
}
/*******************************************************************************
* tpm_db_gmac_bm_bufs_conf_get()
*
* DESCRIPTION: Function to set the GMAC number of Buffer Mngmt large_bufers, short_buffers
*
* INPUTS:
* gmac - GMAC
* valid - Is the entry valid in the db
* large_pkt_buffers - number of buffers in the GMAC long packets pool
* small_pkt_buffers - number of buffers in the GMAC short packets pool
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS: Perfom only DB integrity checks, not data correctness checks
*
*******************************************************************************/
int32_t tpm_db_gmac_bm_bufs_conf_get(tpm_gmacs_enum_t gmac,
uint32_t *valid, uint32_t *large_pkt_buffers, uint32_t *small_pkt_buffers)
{
if ((valid == NULL) || (gmac >= TPM_MAX_NUM_GMACS))
return (TPM_DB_ERR_INV_INPUT);
*valid = (tpm_db.gmac_bp_bufs[gmac].valid == TPM_DB_VALID ? 1 : 0);
if (large_pkt_buffers != NULL)
*large_pkt_buffers = tpm_db.gmac_bp_bufs[gmac].large_pkt_buffers;
if (small_pkt_buffers != NULL)
*small_pkt_buffers = tpm_db.gmac_bp_bufs[gmac].small_pkt_buffers;
return (TPM_DB_OK);
}
/*******************************************************************************
* tpm_db_intport_int_con_get()
*
* DESCRIPTION: Function returns internal connectivity of an internal port num
*
* INPUTS:
* int_port_num - Internal Port Identifier, UNI#0..UNI#4 or WAN Port
*
* OUTPUTS:
* int_con - Port internal L2 Connection (G0, G1, Amber switch)
* switch_port - Amber Switch Port number
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS: Perfom only DB integrity checks, not data correctness checks
*
*******************************************************************************/
int32_t tpm_db_intport_int_con_get(tpm_src_port_type_t int_port_num,
tpm_db_int_conn_t *int_con,
uint32_t *switch_port)
{
int32_t ret_code;
tpm_db_chip_conn_t dummy_chip_con;
tpm_db_int_conn_t l_int_conn;
uint32_t l_switch_port;
if (int_port_num == TPM_SRC_PORT_UNI_VIRT) {
*int_con = TPM_INTCON_SWITCH;
*switch_port = tpm_db.func_profile.virt_uni_info.switch_port;
return (TPM_DB_OK);
}
/* Get External Port Config */
ret_code = tpm_db_eth_port_conf_get(int_port_num,
&dummy_chip_con,
&l_int_conn,
&l_switch_port);
IF_ERROR(ret_code);
/* Return data */
*int_con = l_int_conn;
*switch_port = l_switch_port;
return (TPM_DB_OK);
}
/*******************************************************************************
* tpm_db_num_tcont_llid_get()
*
* DESCRIPTION: Function to get the number of T-CONTs/LLIDs
*
* INPUTS:
* OUTPUTS:
* num_tcont_llid - Number of GPON TCONTs or EPON LLIDs
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
*
*******************************************************************************/
int32_t tpm_db_num_tcont_llid_get(uint32_t *num_tcont_llid)
{
*num_tcont_llid = tpm_db.num_valid_tcont_llid;
return (TPM_DB_OK);
}
/*******************************************************************************
* tpm_db_gmac_tx_q_conf_set()
*
* DESCRIPTION: Function to set the parameters of a Packet Processor Component Tx queue
*
* INPUTS:
* tx_mod - Tx module (G0, G1, or TCONT/LLID0-7)
* OUTPUTS:
* gmac_con - GMAC0 connection
* queue_num - Queue number in this Tx
* sched_method - The Tx Scheduler this queue is added to (the WRR or the Strict scheduler)
* queue_owner - The single hardware owner, that is feeding this queue.
* Can be the CPU, or one of the PAcket Processor Rx components.
* owner_queue_num - The relative queue number of the owner of this queue.
* queue_weight - Weight, if the queue is added to the WRR Scheduler.
* queue_size -
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS: Perfom only DB integrity checks, not data correctness checks
*
*******************************************************************************/
int32_t tpm_db_gmac_tx_q_conf_set(tpm_db_tx_mod_t tx_mod,
uint32_t queue_num,
tpm_db_sched_t sched_method,
tpm_db_txq_owner_t queue_owner,
uint32_t owner_queue_num, uint32_t queue_size, uint32_t queue_weight)
{
tpm_db.gmac_tx[tx_mod].tx_queue[queue_num].queue_owner = queue_owner;
tpm_db.gmac_tx[tx_mod].tx_queue[queue_num].owner_queue_num = owner_queue_num;
tpm_db.gmac_tx[tx_mod].tx_queue[queue_num].sched_method = sched_method;
tpm_db.gmac_tx[tx_mod].tx_queue[queue_num].queue_size = queue_size;
tpm_db.gmac_tx[tx_mod].tx_queue[queue_num].queue_weight = queue_weight;
tpm_db.gmac_tx[tx_mod].tx_queue[queue_num].valid = TPM_DB_VALID;
return (TPM_DB_OK);
}
/*******************************************************************************
* tpm_db_gmac_tx_q_conf_get()
*
* DESCRIPTION: Function to set the parameters of a Packet Processor Tx Component
*
* INPUTS:
* tx_mod - Tx module (G0, G1, or TCONT/LLID0-7)
* queue_num - Queue number in this Tx
*
* OUTPUTS:
* valid - Queue exists
* sched_method - The Tx Scheduler this queue is added to (the WRR or the Strict scheduler)
* queue_owner - The single hardware owner, that is feeding this queue.
* Can be the CPU, or one of the PAcket Processor Rx components.
* owner_queue_num - The relative queue number of the owner of this queue.
* queue_weight - Weight, if the queue is added to the WRR Scheduler.
* queue_size -
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS: Perfom only DB integrity checks, not data correctness checks
*
*******************************************************************************/
int32_t tpm_db_gmac_tx_q_conf_get(tpm_db_tx_mod_t tx_mod,
uint32_t queue_num,
uint32_t *valid,
tpm_db_sched_t *sched_method,
tpm_db_txq_owner_t *queue_owner,
uint32_t *owner_queue_num, uint32_t *queue_size, uint32_t *queue_weight)
{
if (valid == NULL)
return (TPM_DB_ERR_INV_INPUT);
if (tpm_db.gmac_tx[tx_mod].tx_queue[queue_num].valid == TPM_DB_VALID) {
*valid = TPM_TRUE;
if (sched_method != NULL)
*sched_method = tpm_db.gmac_tx[tx_mod].tx_queue[queue_num].sched_method;
if (queue_owner != NULL)
*queue_owner = tpm_db.gmac_tx[tx_mod].tx_queue[queue_num].queue_owner;
if (owner_queue_num != NULL)
*owner_queue_num = tpm_db.gmac_tx[tx_mod].tx_queue[queue_num].owner_queue_num;
if (queue_size != NULL)
*queue_size = tpm_db.gmac_tx[tx_mod].tx_queue[queue_num].queue_size;
if (queue_weight != NULL)
*queue_weight = tpm_db.gmac_tx[tx_mod].tx_queue[queue_num].queue_weight;
} else {
*valid = TPM_FALSE;
}
return (TPM_DB_OK);
}
/*******************************************************************************
* tpm_db_gmac_rx_q_conf_set()
*
* DESCRIPTION: Function to set the parameters of a Packet Processor Tx Component
*
* INPUTS:
* gmac - GMAC
* OUTPUTS:
* queue_num - Queue number in this Tx
* queue_size -
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS: Perfom only DB integrity checks, not data correctness checks
*
*******************************************************************************/
int32_t tpm_db_gmac_rx_q_conf_set(tpm_gmacs_enum_t gmac, uint32_t queue_num, uint32_t queue_size)
{
if ((gmac >= TPM_MAX_NUM_GMACS) || (queue_num >= TPM_MAX_NUM_RX_QUEUE))
return (TPM_DB_ERR_INV_INPUT);
tpm_db.gmac_rx[gmac].rx_queue[queue_num].queue_size = queue_size;
tpm_db.gmac_rx[gmac].rx_queue[queue_num].valid = TPM_DB_VALID;
return (TPM_DB_OK);
}
int32_t tpm_db_gmac_rx_q_conf_get(tpm_gmacs_enum_t gmac, uint32_t queue_num, uint32_t *valid, uint32_t *queue_size)
{
if ((valid == NULL) || (gmac >= TPM_MAX_NUM_GMACS) || (queue_num >= TPM_MAX_NUM_RX_QUEUE))
return (TPM_DB_ERR_INV_INPUT);
if (tpm_db.gmac_rx[gmac].rx_queue[queue_num].valid == TPM_DB_VALID) {
*valid = TPM_TRUE;
if (queue_size != NULL)
*queue_size = tpm_db.gmac_rx[gmac].rx_queue[queue_num].queue_size;
} else
*valid = TPM_FALSE;
return (TPM_DB_OK);
}
/*******************************************************************************
* tpm_db_gmac_tx_val_set()
*
* DESCRIPTION: Function to set the parameters of a Tx module
*
* INPUTS:
* tx_mod - Tx Module to validate
* OUTPUTS:
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS: Perfom only DB integrity checks, not data correctness checks
*
*******************************************************************************/
int32_t tpm_db_gmac_tx_val_set(tpm_db_tx_mod_t tx_mod)
{
tpm_db.gmac_tx[tx_mod].valid = TPM_DB_VALID;
return (TPM_DB_OK);
}
/*******************************************************************************
* tpm_db_gmac_rx_val_set()
*
* DESCRIPTION: Function to set the parameters of a Tx module
*
* INPUTS:
* gmac - GMAC to set active
* OUTPUTS:
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS: Perfom only DB integrity checks, not data correctness checks
*
*******************************************************************************/
int32_t tpm_db_gmac_rx_val_set(tpm_gmacs_enum_t gmac)
{
tpm_db.gmac_rx[gmac].valid = TPM_DB_VALID;
return (TPM_DB_OK);
}
uint32_t tpm_db_gmac_rx_val_get(tpm_gmacs_enum_t gmac)
{
if (tpm_db.gmac_rx[gmac].valid == TPM_DB_VALID)
return (TPM_TRUE);
else
return (TPM_FALSE);
}
/*******************************************************************************
* tpm_db_gmac_func_get()
*
* DESCRIPTION: Check the Function of a GMAC (LAN, WAN or no function)
*
* INPUTS:
* gmac - GMAC to check
* OUTPUTS:
* gfunc - Functionality the GMAC is performing (None, LAN or WAN)
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS: Perfom only DB integrity checks, not data correctness checks
*
*******************************************************************************/
int32_t tpm_db_gmac_func_get(tpm_gmacs_enum_t gmac, tpm_db_gmac_func_t *gfunc)
{
if (gmac > TPM_MAX_GMAC)
return (TPM_DB_ERR_INV_INPUT);
*gfunc = tpm_db.gmac_func[gmac];
return (TPM_DB_OK);
}
/*******************************************************************************
* tpm_db_gmac_func_set()
*
* DESCRIPTION: Sets the Function of a GMAC (LAN, WAN or no function)
*
* INPUTS:
* gmac - GMAC to set
* gfunc - Functionality the GMAC is performing (None, LAN or WAN)
* OUTPUTS:
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS: Perfom only DB integrity checks, not data correctness checks
*
*******************************************************************************/
int32_t tpm_db_gmac_func_set(tpm_gmacs_enum_t gmac, tpm_db_gmac_func_t gfunc)
{
if (gmac > TPM_MAX_GMAC)
return (TPM_DB_ERR_INV_INPUT);
tpm_db.gmac_func[gmac] = gfunc;
return (TPM_DB_OK);
}
/*******************************************************************************
* tpm_db_gmac_tx_val_get()
*
* DESCRIPTION: Function check the validity of a Tx module
*
* INPUTS:
* tx_mod - Tx module to check
* OUTPUTS:
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS: Perfom only DB integrity checks, not data correctness checks
*
*******************************************************************************/
uint32_t tpm_db_gmac_tx_val_get(tpm_db_tx_mod_t tx_mod)
{
if (tpm_db.gmac_tx[tx_mod].valid == TPM_DB_VALID)
return (TPM_TRUE);
else
return (TPM_FALSE);
}
/*******************************************************************************
* tpm_db_gmac_lpk_queue_get()
*
* DESCRIPTION: Function to get the queue id used to do gmac loopback on MC, min queue id for data traffic,
* max queue id for MAC learning
* INPUTS:
* queue_type - queue type for GMAC1 loopback, for data traffic or for MAC learning
* OUTPUTS:
* gmac - gmac on which loopback is done
* queue_idx - queue index which do loopback
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*******************************************************************************/
uint32_t tpm_db_gmac_lpk_queue_get(tpm_gmacs_enum_t *gmac,
uint32_t *queue_idx,
tpm_db_gmac1_lpk_queue_type_t queue_type)
{
uint32_t queue_id, q_valid, gmac_id;
tpm_db_txq_owner_t queue_owner, lpk_queue_owner = TPM_Q_OWNER_GMAC0;
tpm_db_gmac_func_t lpk_gmac_func;
tpm_db_tx_mod_t tx_mod;
uint32_t q_expected = TPM_MAX_NUM_TX_QUEUE;
/*check input parameters*/
if (NULL == gmac || NULL == queue_idx) {
TPM_OS_ERROR(TPM_DB_MOD, "Invalid input \n");
return TPM_DB_ERR_INV_INPUT;
}
/*check func profile*/
if (!tpm_db_gmac1_lpbk_en_get()) {
TPM_OS_ERROR(TPM_DB_MOD, "GMAC1 loopback has not been enabled!\n");
return TPM_FALSE;
}
/*Find the GMAC used to do loopback*/
for (gmac_id = TPM_ENUM_GMAC_0; gmac_id < TPM_MAX_NUM_GMACS; gmac_id ++) {
if (TPM_DB_OK == tpm_db_gmac_func_get(gmac_id, &lpk_gmac_func)) {
if (TPM_GMAC_FUNC_LAN == lpk_gmac_func)
break;
} else {
continue;
}
}
if (gmac_id == TPM_MAX_NUM_GMACS) {
TPM_OS_ERROR(TPM_DB_MOD, "Loopback GMAC get failed \n");
return TPM_FALSE;
} else {
tx_mod = (tpm_db_tx_mod_t)gmac_id;
lpk_queue_owner = TPM_Q_OWNER_GMAC0;
}
/* get the Tx queue of GMAC1, if more than 1 queue belong to gmac0, lowest index is selected */
for (queue_id = 0; queue_id < TPM_MAX_NUM_TX_QUEUE; queue_id++) {
if (TPM_DB_OK != tpm_db_gmac_tx_q_conf_get(tx_mod, queue_id, &q_valid, NULL,
&queue_owner, NULL, NULL, NULL))
continue;
if (q_valid == TPM_TRUE && queue_owner == lpk_queue_owner) {
q_expected = queue_id;
if (TPM_GMAC1_QUEUE_DATA_TRAFFIC == queue_type)
break;
else if (TPM_GMAC1_QUEUE_MAC_LEARN_TRAFFIC == queue_type)
continue;
}
}
if (q_expected >= TPM_MAX_NUM_TX_QUEUE) {
TPM_OS_ERROR(TPM_DB_MOD, "Invalid Tx queue %d of GMAC1 assigned to GMAC0 \n", q_expected);
return ERR_SW_TM_QUEUE_INVALID;
}
*gmac = gmac_id;
*queue_idx = q_expected;
return (TPM_DB_OK);
}
/*******************************************************************************
* tpm_db_pnc_rng_create()
*
* DESCRIPTION: Function to create a range in the DB
*
* INPUTS:
* pnc_range_conf - Pointer to all config information needed for an entry
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS: Perfom only DB integrity checks, not data correctness checks
*
*******************************************************************************/
int32_t tpm_db_pnc_rng_create(tpm_db_pnc_range_conf_t *pnc_range_conf)
{
uint32_t i;
int32_t free_entry = -1;
/* Check NULL Pointer */
if (pnc_range_conf == NULL)
return (TPM_DB_ERR_INV_INPUT);
/* Check range_id is not already in DB, and that DB is not full */
for (i = 0; i < TPM_MAX_NUM_RANGES; i++) {
if (tpm_db.pnc_range[i].valid == TPM_DB_VALID && PNC_RANGE_CONF(i).range_id == pnc_range_conf->range_id)
return (TPM_DB_ERR_RANGE_EXIST);
if ((tpm_db.pnc_range[i].valid == TPM_DB_INVALID) && (free_entry == -1))
free_entry = i;
}
if (free_entry == -1)
return (TPM_DB_ERR_DB_TBL_FULL);
/* Copy Config Structure into DB */
memcpy(&(tpm_db.pnc_range[free_entry].pnc_range_conf), pnc_range_conf, sizeof(tpm_db_pnc_range_conf_t));
/* Init Operational Data */
PNC_RANGE_OPER(free_entry).free_entries = (pnc_range_conf->api_end - pnc_range_conf->api_start + 1);
PNC_RANGE_OPER(free_entry).num_resets = 0;
tpm_db.pnc_range[free_entry].valid = TPM_DB_VALID;
return (TPM_DB_OK);
}
/*******************************************************************************
* tpm_db_pnc_rng_delete()
*
* DESCRIPTION: Initializes and invalidates PnC range
*
* INPUTS:
* pnc_range - The id of the pnc range that is deleted
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS:
*
*******************************************************************************/
int32_t tpm_db_pnc_rng_delete(tpm_pnc_ranges_t pnc_range)
{
uint32_t i;
/* Check PnC range exists in DB */
for (i = 0; i < TPM_MAX_NUM_RANGES; i++) {
/* Reset Operational values */
if (tpm_db.pnc_range[i].valid == TPM_DB_VALID &&
tpm_db.pnc_range[i].pnc_range_conf.range_id == pnc_range) {
memset(&(tpm_db.pnc_range[i]), 0, sizeof(tpm_pnc_ranges_t));
tpm_db.pnc_range[i].valid = TPM_DB_INVALID;
}
}
/* pnc_range not found */
return (TPM_DB_ERR_REC_NOT_EXIST);
}
/*******************************************************************************
* tpm_db_pnc_rng_reset()
*
* DESCRIPTION: Resets PnC range, all entries are returned to free
*
* INPUTS:
* pnc_range - The id of the pnc range that is reset
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS:
*
*******************************************************************************/
int32_t tpm_db_pnc_rng_reset(tpm_pnc_ranges_t pnc_range)
{
uint32_t i;
/* Check PnC range exists in DB */
for (i = 0; i < TPM_MAX_NUM_RANGES; i++) {
/* reach the range to be reset */
if (tpm_db.pnc_range[i].pnc_range_conf.range_id == pnc_range) {
/* Reset Operational values */
if (tpm_db.pnc_range[i].valid == TPM_DB_VALID) {
/* both hardcoded and non-hardcoded entries will behave the same from free_entries point of view */
PNC_RANGE_OPER(i).free_entries =
PNC_RANGE_CONF(i).api_end - PNC_RANGE_CONF(i).api_start + 1;
(PNC_RANGE_OPER(i).num_resets)++;
return (TPM_DB_OK);
}
}
}
/* pnc_range not found */
return (TPM_DB_ERR_REC_NOT_EXIST);
}
/*******************************************************************************
* tpm_db_pnc_rng_free_ent_inc()
*
* DESCRIPTION: Increases number of free entries for a PnC range
*
* INPUTS:
* pnc_range - The id of the pnc range that it's free entries is increased
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS:
*
*******************************************************************************/
int32_t tpm_db_pnc_rng_free_ent_inc(tpm_pnc_ranges_t pnc_range)
{
uint32_t i;
/* Check PnC range exists in DB */
for (i = 0; i < TPM_MAX_NUM_RANGES; i++) {
if (tpm_db.pnc_range[i].valid == TPM_DB_VALID
&& tpm_db.pnc_range[i].pnc_range_conf.range_id == pnc_range) {
/* Check number of free entries is not too big */
if (PNC_RANGE_OPER(i).free_entries
< (PNC_RANGE_CONF(i).api_end - PNC_RANGE_CONF(i).api_start + 1)) {
(PNC_RANGE_OPER(i).free_entries)++;
return (TPM_DB_OK);
} else
return (TPM_DB_ERR_DB_INCONSISTENCY);
}
}
/* pnc_range not found */
return (TPM_DB_ERR_REC_NOT_EXIST);
}
/*******************************************************************************
* tpm_db_pnc_rng_free_ent_dec()
*
* DESCRIPTION: Decreases number of free entries for a PnC range
*
* INPUTS:
* pnc_range - The id of the pnc range that it's free entries is decreased
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS:
*
*******************************************************************************/
int32_t tpm_db_pnc_rng_free_ent_dec(tpm_pnc_ranges_t pnc_range)
{
uint32_t i;
/* Check PnC range exists in DB */
for (i = 0; i < TPM_MAX_NUM_RANGES; i++) {
if (tpm_db.pnc_range[i].valid == TPM_DB_VALID && PNC_RANGE_CONF(i).range_id == pnc_range) {
TPM_OS_DEBUG(TPM_DB_MOD, "range_id(%d), free_ent(%d)\n", pnc_range,
PNC_RANGE_OPER(i).free_entries);
/* Check number of free entries is not zero */
if (PNC_RANGE_OPER(i).free_entries > 0) {
(PNC_RANGE_OPER(i).free_entries)--;
return (TPM_DB_OK);
} else {
TPM_OS_ERROR(TPM_DB_MOD, "no free entries \n");
return (TPM_DB_ERR_DB_INCONSISTENCY);
}
}
}
/* pnc_range not found */
TPM_OS_ERROR(TPM_DB_MOD, "range_id(%d) not found\n", pnc_range);
return (TPM_DB_ERR_REC_NOT_EXIST);
}
/*******************************************************************************
* tpm_db_pnc_get_lu_conf()
*
* DESCRIPTION: Get PnC least used config for specific PnC range
*
* INPUTS:
* range_id - The PnC range id
*
* OUTPUTS:
* lu_conf - Least used configuration for PnC range
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS:
*
*******************************************************************************/
int32_t tpm_db_pnc_get_lu_conf(tpm_pnc_ranges_t range_id, tpm_api_lu_conf_t *lu_conf)
{
tpm_pnc_ranges_t l_range_idx;
/* Check PnC range */
if ((range_id < 0) || (range_id > (TPM_MAX_NUM_RANGES - 1))) {
TPM_OS_ERROR(TPM_DB_MOD, "Error, range_id(%d) is illegal \n", range_id);
return (TPM_DB_ERR_INV_INPUT);
}
/* Check input param */
if (lu_conf == NULL) {
TPM_OS_ERROR(TPM_DB_MOD, "Error, lu_conf is NULL \n");
return (TPM_DB_ERR_INV_INPUT);
}
/* Get the config from TPM db */
for (l_range_idx = 0; l_range_idx < TPM_MAX_RANGE; l_range_idx++) {
if (tpm_db.pnc_range[l_range_idx].valid == TPM_DB_VALID
&& (PNC_RANGE_CONF(l_range_idx).range_id == range_id)) {
lu_conf->cntr_grp = tpm_db.pnc_range[l_range_idx].pnc_range_conf.cntr_grp;
lu_conf->lu_mask = tpm_db.pnc_range[l_range_idx].pnc_range_conf.lu_mask;
break;
}
}
return (TPM_DB_OK);
}
/*******************************************************************************
* tpm_db_pnc_rng_api_start_inc()
*
* DESCRIPTION: Increases number of free entries for a PnC range
*
* INPUTS:
* pnc_range - The id of the pnc range that it's free entries is increased
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS:
*
*******************************************************************************/
int32_t tpm_db_pnc_rng_api_start_inc(tpm_pnc_ranges_t pnc_range)
{
uint32_t i;
/* Check PnC range exists in DB */
for (i = 0; i < TPM_MAX_NUM_RANGES; i++) {
if (tpm_db.pnc_range[i].valid == TPM_DB_VALID
&& tpm_db.pnc_range[i].pnc_range_conf.range_id == pnc_range) {
/* Check number of free entries is not too big */
if (PNC_RANGE_OPER(i).free_entries >= 1) {
(PNC_RANGE_CONF(i).api_start)++;
(PNC_RANGE_OPER(i).free_entries)--;
return (TPM_DB_OK);
} else
return (TPM_DB_ERR_DB_INCONSISTENCY);
}
}
/* pnc_range not found */
return (TPM_DB_ERR_REC_NOT_EXIST);
}
/*******************************************************************************
* tpm_db_pnc_rng_api_end_dec()
*
* DESCRIPTION: Decrease number of api_end for a PnC range
* The reason might be addition of an entry at the end of the range.
*
* INPUTS:
* pnc_range - The id of the pnc range that it's free entries is increased
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS:
*
*******************************************************************************/
int32_t tpm_db_pnc_rng_api_end_dec(tpm_pnc_ranges_t pnc_range)
{
uint32_t i;
/* Check PnC range exists in DB */
for (i = 0; i < TPM_MAX_NUM_RANGES; i++) {
if (tpm_db.pnc_range[i].valid == TPM_DB_VALID
&& tpm_db.pnc_range[i].pnc_range_conf.range_id == pnc_range) {
/* Check number of free entries is not too big */
if (PNC_RANGE_OPER(i).free_entries >= 1) {
(PNC_RANGE_CONF(i).api_end)--;
(PNC_RANGE_OPER(i).free_entries)--;
return (TPM_DB_OK);
} else
return (TPM_DB_ERR_DB_INCONSISTENCY);
}
}
/* pnc_range not found */
return (TPM_DB_ERR_REC_NOT_EXIST);
}
int32_t tpm_db_api_section_get_from_api_type(tpm_api_type_t api_type, tpm_api_sections_t *api_section)
{
int32_t error_code = TPM_DB_OK;
/*TODO - replace this w/ conf structure */
switch (api_type) {
case TPM_API_MAC_LEARN:
*api_section = TPM_PNC_MAC_LEARN_ACL;
break;
case TPM_API_CPU_LOOPBACK:
*api_section = TPM_CPU_LOOPBACK_ACL;
break;
case TPM_API_DS_LOAD_BALANCE:
*api_section = TPM_DS_LOAD_BALANCE_ACL;
break;
case TPM_API_L2_PRIM:
*api_section = TPM_L2_PRIM_ACL;
break;
case TPM_API_L3_TYPE:
*api_section = TPM_L3_TYPE_ACL;
break;
case TPM_API_IPV4:
*api_section = TPM_IPV4_ACL;
break;
case TPM_API_IPV4_MC:
*api_section = TPM_IPV4_MC;
break;
case TPM_API_IPV6_GEN:
*api_section = TPM_IPV6_GEN_ACL;
break;
case TPM_API_IPV6_MC:
*api_section = TPM_IPV6_MC_ACL;
break;
case TPM_API_IPV6_DIP:
*api_section = TPM_IPV6_DIP_ACL;
break;
case TPM_API_IPV6_NH:
*api_section = TPM_IPV6_NH_ACL;
break;
case TPM_API_IPV6_L4:
*api_section = TPM_L4_ACL;
break;
case TPM_API_CNM:
*api_section = TPM_CNM_MAIN_ACL;
break;
default:
error_code = TPM_DB_ERR_REC_NOT_EXIST;
}
return (error_code);
}
int32_t tpm_db_api_type_get_from_api_section(tpm_api_sections_t api_section, tpm_api_type_t *api_type)
{
int32_t error_code = TPM_DB_OK;
/*TODO - replace this w/ conf structure */
switch (api_section) {
case TPM_PNC_MAC_LEARN_ACL:
*api_type = TPM_API_MAC_LEARN;
break;
case TPM_CPU_LOOPBACK_ACL:
*api_type = TPM_API_CPU_LOOPBACK;
break;
case TPM_DS_LOAD_BALANCE_ACL:
*api_type = TPM_API_DS_LOAD_BALANCE;
break;
case TPM_L2_PRIM_ACL:
*api_type = TPM_API_L2_PRIM;
break;
case TPM_L3_TYPE_ACL:
*api_type = TPM_API_L3_TYPE;
break;
case TPM_IPV4_ACL:
*api_type = TPM_API_IPV4;
break;
case TPM_IPV4_MC:
*api_type = TPM_API_IPV4_MC;
break;
case TPM_IPV6_GEN_ACL:
*api_type = TPM_API_IPV6_GEN;
break;
case TPM_IPV6_DIP_ACL:
*api_type = TPM_API_IPV6_DIP;
break;
case TPM_IPV6_NH_ACL:
*api_type = TPM_API_IPV6_NH;
break;
case TPM_L4_ACL:
*api_type = TPM_API_IPV6_L4;
break;
default:
error_code = TPM_DB_ERR_REC_NOT_EXIST;
}
return (error_code);
}
/*******************************************************************************
* tpm_db_pnc_rng_get()
*
* DESCRIPTION: Returns DB info of PnC range
*
* INPUTS:
* pnc_range - The id of the pnc range to get data for
* OUTPUTS:
* range_data - Returned DB structure of returned entry.
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS:
*
*******************************************************************************/
int32_t tpm_db_pnc_rng_get(tpm_pnc_ranges_t pnc_range, tpm_db_pnc_range_t *range_data)
{
uint32_t i;
if ((pnc_range < 0) || (pnc_range > (TPM_MAX_NUM_RANGES - 1)))
return (TPM_DB_ERR_INV_INPUT);
/* Check PnC range exists in DB */
for (i = 0; i < TPM_MAX_NUM_RANGES; i++) {
if (tpm_db.pnc_range[i].valid == TPM_DB_VALID && PNC_RANGE_CONF(i).range_id == pnc_range) {
memcpy(range_data, &(tpm_db.pnc_range[i]), sizeof(tpm_db_pnc_range_t));
return (TPM_DB_OK);
}
}
return (TPM_DB_ERR_REC_NOT_EXIST);
}
/*******************************************************************************
* tpm_db_pnc_rng_get_range_start_end()
*
* DESCRIPTION: Returns DB info of PnC range
*
* INPUTS:
* pnc_range - The id of the pnc range to get data for
* OUTPUTS:
* range_start - Returned the start of specific PnC range.
* range_end - Returned the end of specific PnC range.
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS:
*
*******************************************************************************/
int32_t tpm_db_pnc_rng_get_range_start_end(tpm_pnc_ranges_t pnc_range, uint32_t *range_start, uint32_t *range_end)
{
uint32_t i;
if ((pnc_range < 0) || (pnc_range > (TPM_MAX_NUM_RANGES - 1)))
return(TPM_DB_ERR_INV_INPUT);
/* Check PnC range exists in DB */
for (i = 0; i < TPM_MAX_NUM_RANGES; i++) {
if ((tpm_db.pnc_range[i].valid == TPM_DB_VALID)
&& (PNC_RANGE_CONF(i).range_id == pnc_range)) {
*range_start = PNC_RANGE_CONF(i).range_start + PNC_RANGE_CONF(i).api_start;
*range_end = PNC_RANGE_CONF(i).range_end;
return(TPM_DB_OK);
}
}
return (TPM_DB_ERR_REC_NOT_EXIST);
}
/*******************************************************************************
* tpm_db_pnc_rng_tbl_val_get_next()
*
* DESCRIPTION: Returns DB info of PnC range
*
* INPUTS:
* cur_ind - The current index (handle) to the pnc_range table. Function returns the next valid
* pnc range entry > cur_index. cur_index < 0 indicates to return first valid entry in table,
* valid next_ind values are 0 or higher
* OUTPUTS:
* next_ind - See cur_ind. If end of table was reached before valid entry, (-1) is returned in next_ind
* range_data - Returned DB structure of returned entry. When entry is invalid, range_data filled with zero.
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS:
*
*******************************************************************************/
int32_t tpm_db_pnc_rng_tbl_val_get_next(int32_t cur_ind, int32_t *next_ind, tpm_db_pnc_range_t *range_data)
{
int32_t i;
/* Initialize first next_ind */
if (cur_ind < 0)
i = 0;
else
i = cur_ind + 1;
/* Check PnC range exists in DB */
for (; i < TPM_MAX_NUM_RANGES; i++) {
if (tpm_db.pnc_range[i].valid == TPM_DB_VALID) {
/* Return Data Structure */
memcpy(range_data, &(tpm_db.pnc_range[i]), sizeof(tpm_db_pnc_range_t));
*next_ind = i;
return (TPM_DB_OK);
}
}
*next_ind = -1;
return (TPM_DB_OK);
}
/*******************************************************************************
* tpm_db_pnc_rng_val_get_next()
*
* DESCRIPTION: Returns DB info of the next valid PnC range.
* Similar to "tpm_db_pnc_rng_tbl_val_get_next", but the handle is the range_id, not the table_index.
*
* INPUTS:
* cur_range - The current pnc_range in the pnc_range table. Function returns the next valid
* pnc_range > cur_range. cur_range < 0 indicates to return first valid entry in table,
* valid next_ind values are 0 or higher
* OUTPUTS:
* next_range - See cur_range. If end of table was reached before valid entry, (-1) is returned in next_range
* range_data - Returned DB structure of returned entry. When entry is invalid, range_data filled with zero.
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS:
*
*******************************************************************************/
int32_t tpm_db_pnc_rng_val_get_next(tpm_pnc_ranges_t cur_range,
tpm_pnc_ranges_t *next_range, tpm_db_pnc_range_t *range_data)
{
uint32_t i;
uint32_t l_min_index = 0; /* oren - add init value, need to check */
tpm_pnc_ranges_t l_min_range = TPM_MAX_RANGE + 1;
/* Check smallest valid next_PnC range in DB */
for (i = 0; i < TPM_MAX_NUM_RANGES; i++) {
/*printf("i(%d) valid(%x) range_id(%d), cur_range(%d) l_min_range(%d)\n",
i,tpm_db.pnc_range[i].valid, PNC_RANGE_CONF(i).range_id, cur_range,l_min_range); */
if ((tpm_db.pnc_range[i].valid == TPM_DB_VALID) && (PNC_RANGE_CONF(i).range_id > cur_range)
&& (PNC_RANGE_CONF(i).range_id < l_min_range)) {
l_min_range = PNC_RANGE_CONF(i).range_id;
l_min_index = i;
}
}
if (l_min_range <= TPM_MAX_RANGE) {
/* Return Data Structure */
memcpy(range_data, &(tpm_db.pnc_range[l_min_index]), sizeof(tpm_db_pnc_range_t));
*next_range = l_min_range;
return (TPM_DB_OK);
}
/* No valid next range found */
*next_range = -1;
return (TPM_DB_OK);
}
/*******************************************************************************
* tpm_db_pnc_rng_conf_get()
*
* DESCRIPTION: Returns DB info of PnC range
*
* INPUTS:
* range_id - Range number to retrieve configuration for
* OUTPUTS:
* range_conf - Structure for pnc_range Configuration Info
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS:
*
*******************************************************************************/
int32_t tpm_db_pnc_rng_conf_get(tpm_pnc_ranges_t range_id, tpm_db_pnc_range_conf_t *range_conf)
{
uint32_t i;
/* Check PnC range exists in DB */
for (i = 0; i < TPM_MAX_NUM_RANGES; i++) {
if (tpm_db.pnc_range[i].valid == TPM_DB_VALID
&& tpm_db.pnc_range[i].pnc_range_conf.range_id == range_id) {
/* Return Data Structure */
memcpy(range_conf, &(tpm_db.pnc_range[i].pnc_range_conf), sizeof(tpm_db_pnc_range_conf_t));
return (TPM_DB_OK);
}
}
/* pnc_range not found */
return (TPM_DB_ERR_REC_NOT_EXIST);
}
/*******************************************************************************
* tpm_db_pnc_rng_oper_get()
*
* DESCRIPTION: Returns DB info of PnC range
*
* INPUTS:
* range_id - Range number to retrieve configuration for
* OUTPUTS:
* range_oper - Structure for pnc_range Operational Info
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS:
*
*******************************************************************************/
int32_t tpm_db_pnc_rng_oper_get(tpm_pnc_ranges_t range_id, tpm_db_pnc_range_oper_t *range_oper)
{
uint32_t i;
/* Check PnC range exists in DB */
for (i = 0; i < TPM_MAX_NUM_RANGES; i++) {
if (tpm_db.pnc_range[i].valid == TPM_DB_VALID
&& tpm_db.pnc_range[i].pnc_range_conf.range_id == range_id) {
/* Return Data Structure */
memcpy(range_oper, &(tpm_db.pnc_range[i].pnc_range_oper), sizeof(tpm_db_pnc_range_oper_t));
return (TPM_DB_OK);
}
}
/* pnc_range not found */
return (TPM_DB_ERR_REC_NOT_EXIST);
}
/*******************************************************************************
* tpm_db_pnc_rng_free_ent_get()
*
* DESCRIPTION: Returns number of free entries of PnC range
*
* INPUTS:
* range_id - Range number to retrieve number of free entries
* OUTPUTS:
* free_entries - Number of free entries in Table
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS:
*
*******************************************************************************/
int32_t tpm_db_pnc_rng_free_ent_get(tpm_pnc_ranges_t range_id, uint32_t *free_entries)
{
uint32_t i;
/* Check PnC range exists in DB */
for (i = 0; i < TPM_MAX_NUM_RANGES; i++) {
if (tpm_db.pnc_range[i].valid == TPM_DB_VALID
&& tpm_db.pnc_range[i].pnc_range_conf.range_id == range_id) {
/* Return Free Entries */
*free_entries = PNC_RANGE_OPER(i).free_entries;
return (TPM_DB_OK);
}
}
/* pnc_range not found */
*free_entries = 0;
return (TPM_DB_ERR_REC_NOT_EXIST);
}
/*******************************************************************************
* tpm_db_owner_set()
*
* DESCRIPTION: Creates an owner_id in the DB.
*
* INPUTS:
* owner_id - Id of new owner
* OUTPUTS:
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS:
*
*******************************************************************************/
int32_t tpm_db_owner_set(uint32_t owner_id)
{
uint32_t i;
int32_t free_ind = -1;
/* Check owner was not already set */
for (i = 0; i < TPM_MAX_API_TYPES; i++) {
if ((tpm_db.owners[i].valid == TPM_DB_VALID) && (tpm_db.owners[i].owner_id == owner_id))
return (TPM_DB_ERR_REC_EXIST);
if ((free_ind == -1) && (tpm_db.owners[i].valid == TPM_DB_INVALID))
free_ind = i;
}
if (free_ind == -1)
return (TPM_DB_ERR_DB_TBL_FULL);
/* Set on first free index */
tpm_db.owners[free_ind].valid = TPM_DB_VALID;
tpm_db.owners[free_ind].owner_id = owner_id;
return (TPM_DB_OK);
}
/*******************************************************************************
* tpm_db_owner_get_next()
*
* DESCRIPTION: Returns DB info of PnC range
*
* INPUTS:
* cur_ind - The current index (handle) to the owner table. Function returns the next
* valid table entry > cur_index. cur_index < 0 indicates to return first valid entry in table,
* valid next_ind values are 0 or higher.
* OUTPUTS:
* next_ind - See cur_ind. If end of table was reached before valid entry, (-1) is returned in next_ind
* owner - Returns the owner of the next index.
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t. No more owners is not considered error.
*
* COMMENTS:
*
*******************************************************************************/
int32_t tpm_db_owner_get_next(int32_t cur_ind, int32_t *next_ind, uint32_t *owner)
{
uint32_t i;
/* Initialize first next_ind */
if (cur_ind < 0)
i = 0;
else
i = cur_ind + 1;
/* Check owner exists in DB */
for (; i < TPM_MAX_API_TYPES; i++) {
if (tpm_db.owners[i].valid == TPM_DB_VALID) { /* oren - changed = to ==, need to check */
/* Return Data Structure */
*next_ind = i;
*owner = tpm_db.owners[i].owner_id;
return (TPM_DB_OK);
}
}
/* No valid entry found */
*next_ind = -1;
return (TPM_DB_OK);
}
#if 0
/*******************************************************************************
* tpm_db_apig_set()
*
* DESCRIPTION: Creates an API Group in the DB.
*
* INPUTS:
* owner_id - owner of the API Group
* api_type - API Group being created
* OUTPUTS:
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS:
*
*******************************************************************************/
int32_t tpm_db_apig_set(uint32_t owner_id, tpm_api_type_t api_type)
{
uint32_t i;
/* Check owner exists */
for (i = 0; i < TPM_MAX_API_TYPES; i++) {
if ((tpm_db.owners[i].valid == TPM_DB_VALID) && (tpm_db.owners[i].owner_id == owner_id))
break;
}
if (i == TPM_MAX_API_TYPES)
return (TPM_DB_ERR_REC_NOT_EXIST);
/* Check api_type does not exist */
if (tpm_db.api_groups[api_type].valid == TPM_DB_VALID)
return (TPM_DB_ERR_REC_EXIST);
tpm_db.api_groups[api_type].valid = TPM_DB_VALID;
tpm_db.api_groups[api_type].api_owner_id = owner_id;
tpm_db.api_groups[api_type].api_type = api_type;
return (TPM_DB_OK);
}
/*******************************************************************************
* tpm_db_apig_get_next()
*
* DESCRIPTION: Returns DB info of API Group
*
* INPUTS:
* cur_ind - The current index (handle) to the owner table. Function returns the next
* valid table entry > cur_index. cur_index < 0 indicates to return first valid entry in table,
* valid next_ind values are 0 or higher.
* OUTPUTS:
* next_ind - See cur_ind. If end of table was reached before valid entry, (-1) is returned in next_ind
* api_type - Returns the API Group.
* owner - Returns the owner of the API Group.
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS:
*
*******************************************************************************/
int32_t tpm_db_apig_get_next(int32_t cur_ind, int32_t *next_ind, uint32_t *owner, tpm_api_type_t *api_type)
{
uint32_t i;
/* Initialize first next_ind */
if (cur_ind < 0)
i = 0;
else
i = cur_ind + 1;
/* Check API Group exists in DB */
for (; i < TPM_MAX_API_TYPES; i++) {
if (tpm_db.api_groups[i].valid == TPM_DB_VALID) {
/* Return Data */
*next_ind = i;
*api_type = tpm_db.api_groups[i].api_type;
*owner = tpm_db.api_groups[i].api_owner_id;
return (TPM_DB_OK);
}
}
/* No valid entry found */
*next_ind = -1;
return (TPM_DB_OK);
}
#endif
/*******************************************************************************
* tpm_db_igmp_set_port_frwd_mode()
*
* DESCRIPTION: Set the IGMP status of a UNI port or WAN port
*
* INPUTS:
* src_port - source port to set
* igmp_state - how to process IGMP packets
*
* OUTPUTS:
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS:
*
*******************************************************************************/
int32_t tpm_db_igmp_set_port_frwd_mode(uint32_t port, uint32_t mode)
{
tpm_db.igmp_def.frwd_mode[port] = mode;
return (TPM_DB_OK);
}
/*******************************************************************************
* tpm_db_igmp_get_port_frwd_mode()
*
* DESCRIPTION: Get the IGMP status of a UNI port or WAN port
*
* INPUTS:
* src_port - source port to get
*
* OUTPUTS:
* igmp_state - how to process IGMP packets
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS:
*
*******************************************************************************/
int32_t tpm_db_igmp_get_port_frwd_mode(uint32_t port, uint32_t *mode)
{
*mode = tpm_db.igmp_def.frwd_mode[port];
return (TPM_DB_OK);
}
/*******************************************************************************
* tpm_db_igmp_set_cpu_queue()
*
* DESCRIPTION: Set queue number which IGMP packets are forwarded to
*
* INPUTS:
* igmp_snoop - queue number
*
* OUTPUTS:
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS:
*
*******************************************************************************/
int32_t tpm_db_igmp_set_cpu_queue(uint32_t queue)
{
tpm_db.igmp_def.cpu_queue = queue;
return (TPM_DB_OK);
}
/*******************************************************************************
* tpm_db_igmp_get_cpu_queue()
*
* DESCRIPTION: Get queue number which IGMP packets are forwarded to
*
* INPUTS:
*
* OUTPUTS:
* igmp_snoop - queue number
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS:
*
*******************************************************************************/
int32_t tpm_db_igmp_get_cpu_queue(uint32_t *queue)
{
*queue = tpm_db.igmp_def.cpu_queue;
return (TPM_DB_OK);
}
/*******************************************************************************
* tpm_db_igmp_set_snoop_enable()
*
* DESCRIPTION: Set IGMP snoop enable
*
* INPUTS:
* igmp_snoop_enable - IGMP snoop enable
*
* OUTPUTS:
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS:
*
*******************************************************************************/
int32_t tpm_db_igmp_set_snoop_enable(uint32_t igmp_snoop_enable)
{
tpm_db.igmp_def.igmp_snoop_enable = igmp_snoop_enable;
return (TPM_DB_OK);
}
/*******************************************************************************
* tpm_db_igmp_get_snoop_enable()
*
* DESCRIPTION: Get IGMP snoop enable
*
* INPUTS:
*
* OUTPUTS:
* igmp_snoop_enable - IGMP snoop enable
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS:
*
*******************************************************************************/
int32_t tpm_db_igmp_get_snoop_enable(uint32_t *igmp_snoop_enable)
{
*igmp_snoop_enable = tpm_db.igmp_def.igmp_snoop_enable;
return (TPM_DB_OK);
}
/*******************************************************************************
* tpm_db_omci_type_set()
*
* DESCRIPTION: Set OMCI ethertype
*
* INPUTS:
* omci_etype - OMCI Ethertype
* OUTPUTS:
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS:
*
*******************************************************************************/
int32_t tpm_db_omci_type_set(uint32_t omci_etype)
{
tpm_db.init_misc.omci_etype = omci_etype;
return (TPM_DB_OK);
}
/*******************************************************************************
* tpm_db_omci_type_get()
*
* DESCRIPTION: Get OMCI ethertype
*
* OUTPUTS:
* omci_etype - OMCI Ethertype
* OUTPUTS:
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS:
*
*******************************************************************************/
int32_t tpm_db_omci_type_get(uint32_t *omci_etype)
{
*omci_etype = tpm_db.init_misc.omci_etype;
return (TPM_DB_OK);
}
/*******************************************************************************
* tpm_db_omci_channel_set()
*
* DESCRIPTION: Set OMCI channel parameters
*
* INPUTS:
* gemport - OMCI GEM port ID
* cpu_rx_q - OMCI cpu rx queue
* cpu_tx_q - OMCI cpu tx queue
* tcont_id - OMCI tcont ID
* OUTPUTS:
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS:
*
*******************************************************************************/
int32_t tpm_db_omci_channel_set(uint16_t gemport, uint32_t cpu_rx_q, uint32_t cpu_tx_q, uint32_t tcont_id)
{
tpm_db.init_misc.omci_gemport = gemport;
tpm_db.init_misc.oam_cpu_rx_q = cpu_rx_q;
tpm_db.init_misc.oam_cpu_tx_q = cpu_tx_q;
tpm_db.init_misc.oam_cpu_tx_port = tcont_id;
tpm_db.init_misc.oam_channel_configured = 1;
return (TPM_DB_OK);
}
/*******************************************************************************
* tpm_db_omci_channel_remove()
*
* DESCRIPTION: Remove OMCI channel parameters
*
* INPUTS:
* OUTPUTS:
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS:
*
*******************************************************************************/
int32_t tpm_db_omci_channel_remove(void)
{
tpm_db.init_misc.omci_gemport = 0;
tpm_db.init_misc.oam_cpu_rx_q = 0;
tpm_db.init_misc.oam_cpu_tx_q = 0;
tpm_db.init_misc.oam_cpu_tx_port = 0;
tpm_db.init_misc.oam_channel_configured = 0;
return (TPM_DB_OK);
}
/*******************************************************************************
* tpm_db_oam_loopback_state_get()
*
* DESCRIPTION: Get OAM loopback configure state
*
* OUTPUTS:
* omci_etype - OMCI Ethertype
* OUTPUTS:
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS:
*
*******************************************************************************/
int32_t tpm_db_oam_loopback_state_get(uint32_t *loopback)
{
*loopback = tpm_db.init_misc.oam_loopback_channel_configured;
return (TPM_DB_OK);
}
/*******************************************************************************
* tpm_db_oam_loopback_channel_set()
*
* DESCRIPTION: Set OAM loopback channel state
*
* INPUTS:
*
* OUTPUTS:
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS:
*
*******************************************************************************/
int32_t tpm_db_oam_loopback_channel_set(void)
{
tpm_db.init_misc.oam_loopback_channel_configured = 1;
return (TPM_DB_OK);
}
/*******************************************************************************
* tpm_db_omci_channel_remove()
*
* DESCRIPTION: Remove OMCI channel parameters
*
* INPUTS:
* OUTPUTS:
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS:
*
*******************************************************************************/
int32_t tpm_db_oam_loopback_channel_remove(void)
{
tpm_db.init_misc.oam_loopback_channel_configured = 0;
return (TPM_DB_OK);
}
/*******************************************************************************
* tpm_db_omci_channel_get()
*
* DESCRIPTION: Get OMCI channel parameters
*
* INPUTS:
* gemport - OMCI GEM port ID
* cpu_rx_q - OMCI cpu rx queue
* cpu_tx_q - OMCI cpu tx queue
* tcont_id - OMCI tcont ID
* OUTPUTS:
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS:
*
*******************************************************************************/
int32_t tpm_db_omci_channel_get(uint32_t *valid, uint16_t *gemport, uint32_t *cpu_rx_q, uint32_t *cpu_tx_q,
uint32_t *tcont_id)
{
*gemport = tpm_db.init_misc.omci_gemport;
*cpu_rx_q = tpm_db.init_misc.oam_cpu_rx_q;
*cpu_tx_q = tpm_db.init_misc.oam_cpu_tx_q;
*tcont_id = tpm_db.init_misc.oam_cpu_tx_port;
*valid = tpm_db.init_misc.oam_channel_configured;
return (TPM_DB_OK);
}
/*******************************************************************************
* tpm_db_oam_channel_set()
*
* DESCRIPTION: Set OAM channel parameters
*
* INPUTS:
* cpu_rx_q - OAM cpu rx queue
* cpu_tx_q - OAM cpu tx queue
* llid - OAM LLID
* OUTPUTS:
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS:
*
*******************************************************************************/
int32_t tpm_db_oam_channel_set(uint32_t cpu_rx_q, uint32_t cpu_tx_q, uint32_t llid)
{
tpm_db.init_misc.oam_cpu_rx_q = cpu_rx_q;
tpm_db.init_misc.oam_cpu_tx_q = cpu_tx_q;
tpm_db.init_misc.oam_cpu_tx_port = llid;
tpm_db.init_misc.oam_channel_configured = 1;
return (TPM_DB_OK);
}
/*******************************************************************************
* tpm_db_oam_channel_remove()
*
* DESCRIPTION: Remove OAM channel parameters
*
* INPUTS:
* OUTPUTS:
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS:
*
*******************************************************************************/
int32_t tpm_db_oam_channel_remove(void)
{
tpm_db.init_misc.omci_gemport = 0;
tpm_db.init_misc.oam_cpu_rx_q = 0;
tpm_db.init_misc.oam_cpu_tx_q = 0;
tpm_db.init_misc.oam_cpu_tx_port = 0;
tpm_db.init_misc.oam_channel_configured = 0;
return (TPM_DB_OK);
}
/*******************************************************************************
* tpm_db_oam_channel_get()
*
* DESCRIPTION: Get OAM channel parameters
*
* INPUTS:
* cpu_rx_q - OAM cpu rx queue
* cpu_tx_q - OAM cpu tx queue
* tcont_id - OAM llid
* OUTPUTS:
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS:
*
*******************************************************************************/
int32_t tpm_db_oam_channel_get(uint32_t *valid, uint32_t *cpu_rx_q, uint32_t *cpu_tx_q, uint32_t *llid)
{
*cpu_rx_q = tpm_db.init_misc.oam_cpu_rx_q;
*cpu_tx_q = tpm_db.init_misc.oam_cpu_tx_q;
*llid = tpm_db.init_misc.oam_cpu_tx_port;
*valid = tpm_db.init_misc.oam_channel_configured;
return (TPM_DB_OK);
}
/*******************************************************************************
* tpm_db_pnc_init_deb_port_set()
*
* DESCRIPTION: Set Init Debug Port
*
* INPUTS:
* pnc_init_debug_port - Set the debug Port, which will be preconfigured to send
* all traffic to CPU (NFS port for development)
* OUTPUTS:
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS:
*
*******************************************************************************/
#if 0
int32_t tpm_db_pnc_init_deb_port_set(uint32_t pnc_init_debug_port)
{
tpm_db.init_misc.pnc_init_debug_port = pnc_init_debug_port;
return (TPM_DB_OK);
}
#endif
/*******************************************************************************
* tpm_db_pnc_init_deb_port_get()
*
* DESCRIPTION: Get Debug Port
*
* OUTPUTS:
* pnc_init_debug_port - Get the debug Port, which will be preconfigured to send all
* traffic to CPU (NFS port for development)
* OUTPUTS:
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS:
*
*******************************************************************************/
#if 0
int32_t tpm_db_pnc_init_deb_port_get(uint32_t *pnc_init_debug_port)
{
*pnc_init_debug_port = tpm_db.init_misc.pnc_init_debug_port;
return (TPM_DB_OK);
}
#endif
/*******************************************************************************
* tpm_db_init_done_set()
*
* DESCRIPTION: Set TPM was successfully Initialized
*
* INPUTS:
* OUTPUTS:
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS:
*
*******************************************************************************/
int32_t tpm_db_init_done_set(void)
{
tpm_db.init_misc.tpm_init_succeeded = TPM_DB_VALID;
return (TPM_DB_OK);
}
/*******************************************************************************
* tpm_db_init_done_get()
*
* DESCRIPTION: Get value if TPM was successfully Initialized
*
* OUTPUTS:
* tpm_init_succeeded -
* OUTPUTS:
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS:
*
*******************************************************************************/
int32_t tpm_db_init_done_get(void)
{
if (tpm_db.init_misc.tpm_init_succeeded == TPM_DB_VALID)
return (1);
return (0);
}
/*******************************************************************************
* tpm_db_pon_type_set()
*
* DESCRIPTION: Set WAN technology
*
* INPUTS:
* pon_type - GPON, EPON, Ethernet or None
* OUTPUTS:
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS:
*
*******************************************************************************/
int32_t tpm_db_pon_type_set(tpm_db_pon_type_t pon_type)
{
tpm_db.init_misc.pon_type = pon_type;
return (TPM_DB_OK);
}
/*******************************************************************************
* tpm_db_pon_type_get()
*
* DESCRIPTION: Get WAN technology
*
* OUTPUTS:
* pon_type - GPON, EPON, Ethernet or None
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS:
*
*******************************************************************************/
int32_t tpm_db_pon_type_get(tpm_db_pon_type_t *pon_type)
{
*pon_type = tpm_db.init_misc.pon_type;
return (TPM_DB_OK);
}
/*******************************************************************************
* tpm_db_active_wan_set()
*
* DESCRIPTION: Set WAN technology
*
* INPUTS:
* pon_type - GPON, EPON, Ethernet or None
* OUTPUTS:
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS:
*
*******************************************************************************/
int32_t tpm_db_active_wan_set(tpm_gmacs_enum_t active_wan)
{
tpm_db.init_misc.active_wan = active_wan;
return (TPM_DB_OK);
}
/*******************************************************************************
* tpm_db_active_wan_get()
*
* DESCRIPTION: Set WAN technology
*
* INPUTS:
* pon_type - GPON, EPON, Ethernet or None
* OUTPUTS:
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS:
*
*******************************************************************************/
tpm_gmacs_enum_t tpm_db_active_wan_get()
{
return tpm_db.init_misc.active_wan;
}
/*******************************************************************************
* tpm_db_pnc_mac_learn_enable_set()
*
* DESCRIPTION:
*
* INPUTS:
*
* OUTPUTS:
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS:
*
*******************************************************************************/
int32_t tpm_db_pnc_mac_learn_enable_set(tpm_init_pnc_mac_learn_enable_t pnc_mac_learn_enable)
{
tpm_db.init_misc.pnc_mac_learn_enable = pnc_mac_learn_enable;
return (TPM_DB_OK);
}
/*******************************************************************************
* tpm_db_pnc_mac_learn_enable_get()
*
* DESCRIPTION:
*
* OUTPUTS:
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS:
*
*******************************************************************************/
int32_t tpm_db_pnc_mac_learn_enable_get(tpm_init_pnc_mac_learn_enable_t *pnc_mac_learn_enable)
{
*pnc_mac_learn_enable = tpm_db.init_misc.pnc_mac_learn_enable;
return (TPM_DB_OK);
}
/*******************************************************************************
* tpm_db_fc_conf_set()
*
* DESCRIPTION:
*
* OUTPUTS:
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS:
*
*******************************************************************************/
int32_t tpm_db_fc_conf_set(tpm_init_fc_params_t *port_fc_conf)
{
memcpy(&tpm_db.port_fc_conf, port_fc_conf, sizeof(tpm_db_fc_params_t));
return (TPM_DB_OK);
}
/*******************************************************************************
* tpm_db_fc_conf_get()
*
* DESCRIPTION:
*
* OUTPUTS:
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS:
*
*******************************************************************************/
int32_t tpm_db_fc_conf_get(tpm_init_fc_params_t *port_fc_conf)
{
memcpy(port_fc_conf, &tpm_db.port_fc_conf, sizeof(tpm_db_fc_params_t));
return (TPM_DB_OK);
}
/*******************************************************************************
* tpm_db_switch_init_set()
*
* DESCRIPTION: Set Amber Initialization
*
* INPUTS:
* switch_init
* OUTPUTS:
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS:
*
*******************************************************************************/
int32_t tpm_db_switch_init_set(uint32_t switch_init)
{
tpm_db.func_profile.switch_init = switch_init;
return (TPM_DB_OK);
}
/*******************************************************************************
* tpm_db_switch_init_get()
*
* DESCRIPTION: Get Amber Initialization
*
* INPUTS:
* switch_init
* OUTPUTS:
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS:
*
*******************************************************************************/
int32_t tpm_db_switch_init_get(uint32_t *switch_init)
{
*switch_init = tpm_db.func_profile.switch_init;
return (TPM_DB_OK);
}
/*******************************************************************************
* tpm_db_ds_mh_set_conf_set()
*
* DESCRIPTION: Set downstream marvell header source select
*
* INPUTS:
* ds_mh_set_conf - Allow set MH in Pnc or not
* OUTPUTS:
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS:
*
*******************************************************************************/
int32_t tpm_db_ds_mh_set_conf_set(tpm_db_mh_src_t ds_mh_set_conf)
{
tpm_db.init_misc.ds_mh_set_conf = ds_mh_set_conf;
return (TPM_DB_OK);
}
/*******************************************************************************
* tpm_db_ds_mh_get_conf_set()
*
* DESCRIPTION: Set downstream marvell header source select
*
* INPUTS:
*
* OUTPUTS:
* ds_mh_set_conf - Allow set MH in Pnc or not
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS:
*
*******************************************************************************/
int32_t tpm_db_ds_mh_get_conf_set(tpm_db_mh_src_t *ds_mh_set_conf)
{
*ds_mh_set_conf = tpm_db.init_misc.ds_mh_set_conf;
return (TPM_DB_OK);
}
/*******************************************************************************
* tpm_db_cfg_pnc_parse_set()
*
* DESCRIPTION: Set config PNC parse enabled/disabled in DB
*
* INPUTS:
* cfg_pnc_parse 0=DISABLED / 1=ENABLED
* OUTPUTS:
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS:
*
*******************************************************************************/
int32_t tpm_db_cfg_pnc_parse_set(tpm_init_cfg_pnc_parse_t cfg_pnc_parse)
{
tpm_db.init_misc.cfg_pnc_parse = cfg_pnc_parse;
return (TPM_DB_OK);
}
/*******************************************************************************
* tpm_db_cpu_loopback_set()
*
* DESCRIPTION: Set cpu loopback enabled/disabled in DB
*
* INPUTS:
* cpu_loopback 0=DISABLED / 1=ENABLED
* OUTPUTS:
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS:
*
*******************************************************************************/
int32_t tpm_db_cpu_loopback_set(tpm_init_cpu_loopback_t cpu_loopback)
{
tpm_db.init_misc.cpu_loopback = cpu_loopback;
return (TPM_DB_OK);
}
/*******************************************************************************
* tpm_db_cfg_pnc_parse_get()
*
* DESCRIPTION: Get config PNC parse enabled/disabled in DB
*
* OUTPUTS:
* cfg_pnc_parse_val 0=DISABLED / 1=ENABLED
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS:
*
*******************************************************************************/
int32_t tpm_db_cfg_pnc_parse_get(tpm_init_cfg_pnc_parse_t *cfg_pnc_parse_val)
{
*cfg_pnc_parse_val = tpm_db.init_misc.cfg_pnc_parse;
return (TPM_DB_OK);
}
/*******************************************************************************
* tpm_db_cpu_loopback_get()
*
* DESCRIPTION: Get CPU loopback enabled/disabled in DB
*
* OUTPUTS:
* cpu_loopback_val 0=DISABLED / 1=ENABLED
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS:
*
*******************************************************************************/
int32_t tpm_db_cpu_loopback_get(tpm_init_cpu_loopback_t *cpu_loopback_val)
{
*cpu_loopback_val = tpm_db.init_misc.cpu_loopback;
return (TPM_DB_OK);
}
/*******************************************************************************
* tpm_db_double_tag_support_set()
*
* DESCRIPTION: Set config double tagged supported in DB
*
* INPUTS:
* dbl_tag 0=DISABLED / 1=ENABLED
* OUTPUTS:
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS:
*
*******************************************************************************/
int32_t tpm_db_double_tag_support_set(tpm_init_double_tag_t dbl_tag)
{
tpm_db.init_misc.dbl_tag = dbl_tag;
return (TPM_DB_OK);
}
/*******************************************************************************
* tpm_db_double_tag_support_get()
*
* DESCRIPTION: Get config double tagged supported in DB
*
* OUTPUTS:
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS:
*
*******************************************************************************/
int32_t tpm_db_double_tag_support_get(tpm_init_double_tag_t *dbl_tag)
{
*dbl_tag = tpm_db.init_misc.dbl_tag;
return (TPM_DB_OK);
}
#if 0
/*******************************************************************************
* tpm_db_default_tag_tpid_set()
*
* DESCRIPTION: Set tpid of one/two vlan tag in DB
*
* INPUTS:
* OUTPUTS:
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS:
*
*******************************************************************************/
int32_t tpm_db_default_tag_tpid_set(uint16_t vlan1_tpid, uint16_t vlan2_tpid)
{
tpm_db.init_misc.vlan1_tpid = vlan1_tpid;
tpm_db.init_misc.vlan2_tpid = vlan2_tpid;
return (TPM_DB_OK);
}
/*******************************************************************************
* tpm_db_default_tag_tpid_get()
*
* DESCRIPTION: Get tpid of one/two vlan tag in DB
*
* OUTPUTS:
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS:
*
*******************************************************************************/
int32_t tpm_db_default_tag_tpid_get(uint16_t *vlan1_tpid, uint16_t *vlan2_tpid)
{
*vlan1_tpid = tpm_db.init_misc.vlan1_tpid;
*vlan2_tpid = tpm_db.init_misc.vlan2_tpid;
return (TPM_DB_OK);
}
#endif
/*******************************************************************************
* tpm_db_default_tag_tpid_set()
*
* DESCRIPTION: Set tpid of one/two vlan tag in DB
*
* INPUTS:
* OUTPUTS:
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS:
*
*******************************************************************************/
int32_t tpm_db_default_tag_tpid_set(tpm_init_tpid_opt_t *tag_tpid)
{
memcpy(&tpm_db.init_misc.tag_tpid, tag_tpid, sizeof(tpm_init_tpid_opt_t));
return(TPM_DB_OK);
}
/*******************************************************************************
* tpm_db_default_tag_tpid_get()
*
* DESCRIPTION: Get tpid of one/two vlan tag in DB
*
* OUTPUTS:
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned
* according to the case - see tpm_db_err_t.
*
* COMMENTS:
*
*******************************************************************************/
int32_t tpm_db_default_tag_tpid_get(tpm_init_tpid_opt_t *tag_tpid)
{
memcpy(tag_tpid, &tpm_db.init_misc.tag_tpid, sizeof(tpm_init_tpid_opt_t));
return(TPM_DB_OK);
}
/*******************************************************************************
* tpm_db_virt_info_set()
*
* DESCRIPTION: Set wifi via UNI in TPM DB
*
* INPUTS:
* virt_uni_info.enabled 0=DISABLED / 1=ENABLED
* virt_uni_info.uni_port port#
* OUTPUTS:
*
* RETURNS:
* On success, the function returns TPM_DB_OK. On error different types are returned