⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pi8021x.c

📁 vt6528芯片交换机API函数和文档运行程序
💻 C
字号:
/*
 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
 * All rights reserved.
 *
 * This software is copyrighted by and is the sole property of
 * VIA Networking Technologies, Inc. This software may only be used
 * in accordance with the corresponding license agreement. Any unauthorized
 * use, duplication, transmission, distribution, or disclosure of this
 * software is expressly forbidden.
 *
 * This software is provided by VIA Networking Technologies, Inc. "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 VIA Networking Technologies, Inc.
 * be liable for any direct, indirect, incidental, special, exemplary, or
 * consequential damages.
 *
 *
 * File:    pi8021x.c
 *
 * Purpose: 8021.X module UI callback functions
 *
 * Author:  Freeya Lin
 *
 * Date:    Dec 10, 2003
 *
 * Functions:
 *
 * Revision History:
 *
 */


#include "str.h"
#include "swproto.h"
#include "swmsg.h"
#include "pigencfg.h"
#include "pi8021x.h"
#include "piportmp.h"
#include "pidef.h"



/*---------------------  Static Definitions -------------------------*/

/*---------------------  Static Classes  ----------------------------*/

/*---------------------  Static Variables  --------------------------*/

/*---------------------  Static Functions  --------------------------*/
static UINT8 s_bySetCfgToHW(S8021XPageCfg* pSPageCfg_8021X);

/*---------------------  Export Variables  --------------------------*/

/*---------------------  Export Macros  -----------------------------*/

/*---------------------  Export Functions  --------------------------*/
void PI8021X_vInitPage(S8021XPageCfg* pSPageCfg_8021X)
{    
    STR_pvMemset(pSPageCfg_8021X, 0, EEP_SIZE_PROV_8021X_CFG);

    PIEEP_vGetCfgFromEep(EEP_ADDR_PROV_8021X_CFG , EEP_SIZE_PROV_8021X_CFG, (PUINT8)pSPageCfg_8021X);
    
    PICFGMP_v4BPhyMskTo1bLogPtrMsk(pSPageCfg_8021X->abySecPortMsk);
}


void PI8021X_vSetEepDefault(S8021XPageCfg* pSPageCfg_8021X, BOOL bWriteDefault)
{    
    STR_pvMemset(pSPageCfg_8021X, 0, EEP_SIZE_PROV_8021X_CFG);
    if (bWriteDefault) {
        // Set value to nvram software cache
        STR_pvMemcpy(g_pu8NVRSwCache + (EEP_ADDR_PROV_8021X_CFG - NVR_ADDR_DATA_AREA_START), (PUINT8)pSPageCfg_8021X, EEP_SIZE_PROV_8021X_CFG);                  
    }
    else {
        PIEEP_vSetCfgIntoEep((PUINT8)pSPageCfg_8021X, EEP_ADDR_PROV_8021X_CFG, EEP_SIZE_PROV_8021X_CFG);
        NVRAM_vUpdateChecksum(EEP_SIZE_DATA_AREA);
    }
}


void PI8021X_vSetHwFromEep(S8021XPageCfg* pSPageCfg_8021X)
{
    PIEEP_vGetCfgFromEep(EEP_ADDR_PROV_8021X_CFG, EEP_SIZE_PROV_8021X_CFG, (PUINT8)pSPageCfg_8021X);
    s_bySetCfgToHW(pSPageCfg_8021X);
}


UINT8 PI8021X_bySavePage(S8021XPageCfg* pSPageCfg_8021X)
{
    UINT8    byRes = 0;

    PICFGMP_v1bLogPtrMskTo4BPhyMsk(pSPageCfg_8021X->abySecPortMsk);
    
    if (!pSPageCfg_8021X->byMode)  //disable: reset all config to default value
        STR_pvMemset(pSPageCfg_8021X, 0, EEP_SIZE_PROV_8021X_CFG);

    // Set config into HW
    byRes = s_bySetCfgToHW(pSPageCfg_8021X);
    if (byRes != OP_OK)
        return byRes;        

    // Set config into EEPROM and return
    PIEEP_vSetCfgIntoEep((PUINT8)pSPageCfg_8021X, EEP_ADDR_PROV_8021X_CFG, EEP_SIZE_PROV_8021X_CFG);
    NVRAM_vUpdateChecksum(EEP_SIZE_DATA_AREA);

    return byRes;
}


static UINT8 s_bySetCfgToHW(S8021XPageCfg* pSPageCfg_8021X)
{
    UINT8    byPhyPID;
    UINT32  dwPortMsk = 0;
    
    STR_pvMemcpy( (PUINT8)(&dwPortMsk)+BYTE_OFFSET_IN_DWORD_OF_CFGMASK,
                pSPageCfg_8021X->abySecPortMsk, BYTE_NUM_OF_CFGBUF_BIT_MASK );
                
                    
    SWPROTO_b8021xSetEn(pSPageCfg_8021X->byMode);
    
    for (byPhyPID = 0; byPhyPID < SWITCH_PORT_NUM; byPhyPID++) {
        if (dwPortMsk & 0x00000001)
            SWPROTO_v8021xSetSecureEn(byPhyPID, TRUE);
        else
            SWPROTO_v8021xSetSecureEn(byPhyPID, FALSE);       
            
        dwPortMsk >>= 1;  
    }
    
    return OP_OK;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -