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

📄 pismacgp.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:    pismacgp.c
 *
 * Purpose: Static mac table module UI definitions
 *
 * Author:  Freeya Lin
 *
 * Date:    Feb 24, 2004
 *
 * Functions:
 *
 * Revision History:
 *
 */


#include "swreg.h"
#if !defined(__SWCFG_H__)
#include "swcfg.h"
#endif
#include "piportmp.h"
#include "swmsg.h"
#include "swsys.h"

#include "pismacgp.h"
#include "pismacep.h"

#include "pimacfltep.h"



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

// Definitions to reduce statement length
#define pSCurGrp            (&pSPageBuf->SCurGrp)

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

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

/*---------------------  Static Functions  --------------------------*/
static UINT8 s_byTrfrSrcIdUItoEepOrHW(UINT8 byLogPortIndex);

/*---------------------  Static Macros  -----------------------------*/

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

/*---------------------  Export Functions  --------------------------*/




//init Item(PortId) for selection
void PISMACGP_vInitAddOrEditGrpPage (SSMacPageCfg *pSPageBuf)
{ 
    // for ui engine
    pSPageBuf->SCurGrp.SStrTblMap.byListNum = g_byLogIdNum;
    STR_pvMemcpy(pSPageBuf->SCurGrp.abyDestPortList, g_abyLogIdList, g_byLogIdNum);
    pSPageBuf->SCurGrp.SStrTblMap.abyListIndex = pSPageBuf->SCurGrp.abyDestPortList;

}


// Get a group
UINT8 PISMACGP_byGetGrp (SSMacPageCfg *pSPageBuf)
{
    UINT16              wTblPtr;
    SMacEntry           sTblEntry;    //TOCHECK
    UINT8                abyMacBuff[MAC_ADDR_SIZE];     

    STR_pvMemset(&sTblEntry, 0, sizeof(SMacEntry)); //TOCHECK

    STR_vCvtMacStrtoVal(pSCurGrp->azMacAddr, (char*)abyMacBuff);  
    // If group id not exist, return error code
    wTblPtr = PISMACEP_wSearchEntry(abyMacBuff, pSCurGrp->u16Fid);
    if (wTblPtr == UINT16_MAX)
        return SMAC_OP_GRP_NOT_EXIST;

    // Get entry from EEPROM and transfer into config buffer format
    PISMACEP_vGetEntry(wTblPtr, &sTblEntry);
    PISMACGP_vTrfrEepOrHWtoUI(pSPageBuf, &sTblEntry);
    
    return OP_OK;

}


// Insert a group
UINT8 PISMACGP_byInsGrp (SSMacPageCfg *pSPageBuf)
{

    SMacEntry       sTblEntry;    //TOCHECK
    UINT8            abyMacBuff[MAC_ADDR_SIZE];     
    
    STR_pvMemset(&sTblEntry, 0, sizeof(SMacEntry)); //TOCHECK

    // If no empty group, return error code
    if (pSPageBuf->wValidEntryNum == SWITCH_SMAC_GRP_NUM )
        return SMAC_OP_NO_EMPTY_GRP;

    STR_vCvtMacStrtoVal(pSCurGrp->azMacAddr, (char*)abyMacBuff);    

    // If group already exist, return error code
    if (PISMACEP_wSearchEntry(abyMacBuff, pSCurGrp->u16Fid) != UINT16_MAX )
        return SMAC_OP_GRP_EXIST;

    if ( PIMACFLTEP_wSearchEntry(abyMacBuff, pSCurGrp->u16Fid) != UINT16_MAX )
        return SMAC_OP_GRP_EXIST_AS_FLT_SMAC;

    //need to trsfer logic portmsk to physical portmsk
    PISMACGP_vTrfrUItoEepOrHW(pSPageBuf, &sTblEntry);
    //set insert entry as static entry
    sTblEntry.bStatic = 1;
    //set into HW
    if (!SWMACTB_bInsEntry(&sTblEntry, 0)) 
        return SMAC_OP_GRP_EXIST;
        
    //set into Eep
    PISMACEP_byInsEntry(&sTblEntry);

    return OP_OK;
}


// Edit a group
UINT8 PISMACGP_byEditGrp (SSMacPageCfg *pSPageBuf)
{

    UINT16          wTblPtr;
    SMacEntry       sTblEntry; //TOCHECK
    UINT8            abyMacBuff[MAC_ADDR_SIZE]; 
    
    STR_pvMemset(&sTblEntry, 0, sizeof(SMacEntry)); //TOCHECK
    
    STR_vCvtMacStrtoVal(pSCurGrp->azMacAddr, (char*)abyMacBuff); 
    // If group id not exist, return error code
    wTblPtr = PISMACEP_wSearchEntry(abyMacBuff, pSCurGrp->u16Fid);
    if (wTblPtr == UINT16_MAX)
        return SMAC_OP_GRP_NOT_EXIST;

    SWMACTB_bDelEntry(abyMacBuff, pSCurGrp->u16Fid);    
    PISMACEP_vDelEntry(wTblPtr);

    PISMACGP_vTrfrUItoEepOrHW(pSPageBuf, &sTblEntry);
    //set insert entry as static entry
    sTblEntry.bStatic = 1;
    //set into HW
    SWMACTB_bInsEntry(&sTblEntry, 0);        
    //set into Eep
    PISMACEP_byInsEntry(&sTblEntry);
    
    return OP_OK;
}

void PISMACGP_vTrfrUItoEepOrHW (SSMacPageCfg *pSPageBuf, SMacEntry *pSTblEntry) //TOCHECK
{    
    //check by logical ptr
    pSTblEntry->bTrkGrp = PIPORTMP_bIsTrunkedByLogPtr(pSCurGrp->bySrcId);
    //convert logical ptr to physical portid
    pSCurGrp->bySrcId = s_byTrfrSrcIdUItoEepOrHW(pSCurGrp->bySrcId);

    STR_vCvtMacStrtoVal(pSCurGrp->azMacAddr, (char*)pSTblEntry->abyMacAddr);    
        
    pSTblEntry->u16Fid = pSCurGrp->u16Fid;
    pSTblEntry->u8SrcId = pSCurGrp->bySrcId; //TOCHECK
    pSTblEntry->bPriDmac = pSCurGrp->bHiPriDmac; //TOCHECK
    //pSTblEntry->bHiPriSmac = pSCurGrp->bHiPriSmac; //TOCHECK
}

static UINT8 s_byTrfrSrcIdUItoEepOrHW(UINT8 byLogPortIndex)
{
    UINT32  dwPhyPortMask = 0;
    UINT8   byPhyPID;
               
    dwPhyPortMask = PIPORTMP_dwLogPtrToPhyMsk(byLogPortIndex);

    for (byPhyPID = 0; byPhyPID < SWITCH_PORT_NUM; byPhyPID++) {
        if (dwPhyPortMask & 0x00000001)
            break;

        dwPhyPortMask >>=1 ;
    }
    
    return  byPhyPID;  
}

void PISMACGP_vTrfrEepOrHWtoUI (SSMacPageCfg *pSPageBuf, SMacEntry *pSTblEntry) //TOCHECK
{

    STR_vCvtMacValtoStr(pSCurGrp->azMacAddr, (char*)pSTblEntry->abyMacAddr);

    pSCurGrp->u16Fid = pSTblEntry->u16Fid;
    pSCurGrp->bySrcId = PIPORTMP_byPhyIdToLogPtr(pSTblEntry->u8SrcId); //TOCHECK
    pSCurGrp->bHiPriDmac = pSTblEntry->bPriDmac; //TOCHECK
    //pSCurGrp->bHiPriSmac = pSTblEntry->bHiPriSmac; //TOCHECK
}


// Delete a group
UINT8 PISMACGP_byDelGrp (SSMacPageCfg *pSPageBuf)
{
    UINT16  wTblPtr;
    UINT8    abyMacBuff[MAC_ADDR_SIZE];     
        
    STR_vCvtMacStrtoVal(pSCurGrp->azMacAddr, (char*)abyMacBuff);    
    wTblPtr = PISMACEP_wSearchEntry(abyMacBuff, pSCurGrp->u16Fid);
    if (wTblPtr == UINT16_MAX)
        return SMAC_OP_GRP_NOT_EXIST;

    //clear entry in hw table
    if (!SWMACTB_bDelEntry(abyMacBuff, pSCurGrp->u16Fid))
        return SMAC_OP_GRP_NOT_EXIST;
    
    // Delete group from EEPROM and return
    PISMACEP_vDelEntry(wTblPtr);
    PISMACEP_vStatisTblInfo(pSPageBuf);
    
    return OP_OK;
}

⌨️ 快捷键说明

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