📄 pigmrpgp.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: pigmrpgp.c
*
* Purpose: GMRP group setting UI callback functions
*
* Author: Freeya Lin
*
* Date: Feb 25, 2004
*
* Functions:
*
* Revision History:
*
*/
#include "swreg.h"
#include "switch.h"
#include "str.h"
#include "piportmp.h"
#include "picfgmp.h"
#include "swmsg.h"
#include "swsys.h"
#include "pigmrpep.h"
#include "pigmrpgp.h"
/*--------------------- EEPROM Content Statement ------------------*/
/*--------------------- Static Definitions -------------------------*/
// Definitions to reduce statement length
#define pSCurGrp (&pSPageBuf->SCurGrp)
/*--------------------- Static Classes ----------------------------*/
/*--------------------- Static Variables --------------------------*/
/*--------------------- Static Functions --------------------------*/
/*--------------------- Static Macros -----------------------------*/
/*--------------------- Export Variables --------------------------*/
/*--------------------- Export Functions --------------------------*/
// Get a gmrp group
UINT8 PIGMRP_byGetGrp (SGMRPPageCfg *pSPageBuf)
{
UINT16 wTblPtr;
SGMRPEntry sTblEntry; //TOCHECK
UINT8 abyMacBuff[MAC_ADDR_SIZE];
STR_pvMemset(&sTblEntry, 0, sizeof(SGMRPEntry)); //TOCHECK
STR_vCvtMacStrtoVal(pSCurGrp->azMacAddr, (char*)abyMacBuff);
// If group id not exist, return error code
wTblPtr = PIGMRPEP_wSearchEntry(abyMacBuff, pSCurGrp->u16Fid);
if (wTblPtr == UINT16_MAX)
return GMRP_OP_GRP_NOT_EXIST;
// Get entry from EEPROM and transfer into config buffer format
PIGMRPEP_vGetEntry(wTblPtr, &sTblEntry);
PIGMRP_vTrfrEepOrHWtoUI(pSPageBuf, &sTblEntry);
return OP_OK;
}
// Insert a gmrp group
UINT8 PIGMRP_byInsGrp (SGMRPPageCfg *pSPageBuf)
{
SGMRPEntry sTblEntry; //TOCHECK
UINT8 abyMacBuff[MAC_ADDR_SIZE];
STR_pvMemset(&sTblEntry, 0, sizeof(SGMRPEntry)); //TOCHECK
// If no empty group, return error code
if (pSPageBuf->wValidEntryNum == SWITCH_GMRP_GRP_NUM )
return GMRP_OP_NO_EMPTY_GRP;
STR_vCvtMacStrtoVal(pSCurGrp->azMacAddr, (char*)abyMacBuff);
// If group already exist, return error code
if (PIGMRPEP_wSearchEntry(abyMacBuff, pSCurGrp->u16Fid) != UINT16_MAX )
return GMRP_OP_GRP_EXIST;
//need to trsfer logic portmsk to physical portmsk
PIGMRP_vTrfrUItoEepOrHW(pSPageBuf, &sTblEntry);
//set insert entry as static entry
sTblEntry.sMacEntry.bStatic = 1; //TOCHECK
//set into HW
if (!SWGMRPTB_bInsEntry(&sTblEntry, 0))
return GMRP_OP_GRP_EXIST;
//set into Eep
PIGMRPEP_byInsEntry(&sTblEntry);
return OP_OK;
}
// Edit a gmrp group
UINT8 PIGMRP_byEditGrp (SGMRPPageCfg *pSPageBuf)
{
UINT16 wTblPtr;
SGMRPEntry sTblEntry; //TOCHECK
UINT8 abyMacBuff[MAC_ADDR_SIZE];
STR_pvMemset(&sTblEntry, 0, sizeof(SGMRPEntry)); //TOCHECK
STR_vCvtMacStrtoVal(pSCurGrp->azMacAddr, (char*)abyMacBuff);
// If group id not exist, return error code
wTblPtr = PIGMRPEP_wSearchEntry(abyMacBuff, pSCurGrp->u16Fid);
if (wTblPtr == UINT16_MAX)
return GMRP_OP_GRP_NOT_EXIST;
SWGMRPTB_bDelEntry(abyMacBuff, pSCurGrp->u16Fid);
PIGMRPEP_vDelEntry(wTblPtr);
PIGMRP_vTrfrUItoEepOrHW(pSPageBuf, &sTblEntry);
//set insert entry as static entry
sTblEntry.sMacEntry.bStatic = 1; //TOCHECK
//set into HW
SWGMRPTB_bInsEntry(&sTblEntry, 0); //1 means "overwrite"
//set into Eep
PIGMRPEP_byInsEntry(&sTblEntry);
return OP_OK;
}
//transfer ui(logic portmsk) to HW/Eeprom(physical portmsk)
void PIGMRP_vTrfrUItoEepOrHW(SGMRPPageCfg *pSPageBuf, SGMRPEntry *pSTblEntry) //TOCHECK
{
UINT8 abyMbrMsk[BYTE_NUM_OF_CFGBUF_BIT_MASK];
UINT8 si;
//this function will convert dword(abyMbrMsk[]) if it is Big-Endian,
//so if it save fail, we must return the original value without any changes
STR_pvMemset(abyMbrMsk, 0, BYTE_NUM_OF_CFGBUF_BIT_MASK);
for (si = 0; si < BYTE_NUM_OF_CFGBUF_BIT_MASK; si++)
abyMbrMsk[si] = pSCurGrp->abyMbrMsk[si];
STR_vCvtMacStrtoVal(pSCurGrp->azMacAddr, (char*)pSTblEntry->sMacEntry.abyMacAddr); //TOCHECK
pSTblEntry->sMacEntry.u16Fid = pSCurGrp->u16Fid; //TOCHECK
pSTblEntry->sMacEntry.bPriDmac = pSCurGrp->bHiPriDmac; //TOCHECK
pSTblEntry->sMacEntry.bPriSmac = pSCurGrp->bHiPriSmac; //TOCHECK
//from logic portmsk to physical portmsk
PICFGMP_v1bLogPtrMskTo4BPhyMsk(abyMbrMsk);
STR_pvMemcpy( (PUINT8)(&pSTblEntry->u32PortMask)+BYTE_OFFSET_IN_DWORD_OF_CFGMASK, //TOCHECK
abyMbrMsk, BYTE_NUM_OF_CFGBUF_BIT_MASK );
}
//transfer HW/Eeprom(physical portmsk) to ui(logic portmsk)
void PIGMRP_vTrfrEepOrHWtoUI(SGMRPPageCfg *pSPageBuf, SGMRPEntry *pSTblEntry) //TOCHECK
{
STR_vCvtMacValtoStr(pSCurGrp->azMacAddr, (char*)pSTblEntry->sMacEntry.abyMacAddr); //TOCHECK
pSCurGrp->u16Fid = pSTblEntry->sMacEntry.u16Fid; //TOCHECK
pSCurGrp->bHiPriDmac = pSTblEntry->sMacEntry.bPriDmac; //TOCHECK
pSCurGrp->bHiPriSmac = pSTblEntry->sMacEntry.bPriSmac; //TOCHECK
//from physical portmsk to logic portmsk
STR_pvMemcpy( pSCurGrp->abyMbrMsk,
(PUINT8)(&pSTblEntry->u32PortMask)+BYTE_OFFSET_IN_DWORD_OF_CFGMASK, BYTE_NUM_OF_CFGBUF_BIT_MASK ); //TOCHECK
PICFGMP_v4BPhyMskTo1bLogPtrMsk(pSCurGrp->abyMbrMsk);
}
// Delete a gmrp group
UINT8 PIGMRP_byDelGrp (SGMRPPageCfg *pSPageBuf)
{
UINT16 wTblPtr;
UINT8 abyMacBuff[MAC_ADDR_SIZE];
STR_vCvtMacStrtoVal(pSCurGrp->azMacAddr, (char*)abyMacBuff);
wTblPtr = PIGMRPEP_wSearchEntry(abyMacBuff, pSCurGrp->u16Fid);
if (wTblPtr == UINT16_MAX)
return GMRP_OP_GRP_NOT_EXIST;
//clear entry in hw table
if (!SWGMRPTB_bDelEntry(abyMacBuff, pSCurGrp->u16Fid))
return GMRP_OP_GRP_NOT_EXIST;
// Delete group from EEPROM and return
PIGMRPEP_vDelEntry(wTblPtr);
PIGMRPEP_vStatisTblInfo(pSPageBuf);
return OP_OK;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -