📄 pivlnmod.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: pivlnmod.c
*
* Purpose: VLAN mode setting UI callback functions
*
* Author: Tevin Chen
*
* Date: Jan 08, 2002
*
* Functions:
*
* Revision History:
*
*/
#include "str.h"
#include "swvlan.h"
#include "swfwd.h"
#include "swsys.h"
#include "piportmp.h"
#include "picfgmp.h"
#include "pivlnmod.h"
#include "pivlngrp.h"
#include "pivlneep.h"
/*--------------------- Static Definitions -------------------------*/
// Default 802.1Q group member are untagged
#define DEFAULT_8021Q_MEMBER_BYTE_CFG 0xAA // VLAN_GRP_UNTAG_MBR => 0x10
// Definitions to reduce statement length
#define pSCurGrp (&pSPageBuf->SCurGrp)
/*--------------------- Static Classes ----------------------------*/
/*--------------------- Static Variables --------------------------*/
/*--------------------- Static Functions --------------------------*/
static void s_vSetEepDefault (SVlanPageCfg *pSPageBuf) DIRECT_FUNTYPE_REENT;
/*--------------------- Static Macros -----------------------------*/
/*--------------------- Export Variables --------------------------*/
/*--------------------- Export Functions --------------------------*/
// Get config from EEPROM and set into page buf
void PIVLAN_vInitPage (SVlanPageCfg *pSPageBuf) DIRECT_FUNTYPE_REENT
{
PIVLAN_vGetVlanMode(&pSPageBuf->byVlanMode);
PIVLNEEP_vStatisTblInfo(pSPageBuf);
// decide max vid by chip type
pSPageBuf->wMaxVid = ((CHIP_VT3221 == (SWSYS_byGetChipType())) ? VLAN_MAX_VALID_VID_3221 : VLAN_MAX_VALID_VID_3077);
}
// Get config from EEPROM and set into hardeare
void PIVLAN_vSetHwFromEep (SVlanPageCfg *pSPageBuf) DIRECT_FUNTYPE_REENT
{
UINT8 si;
// Initialize page and set vlan mode into hardware
PIVLAN_vInitPage(pSPageBuf);
SWVLAN_vSetVlanMode(pSPageBuf->byVlanMode);
// Clear system PVID setting
if (pSPageBuf->byVlanMode == VLAN_MODE_8021Q) {
for (si = 0; si < SWITCH_PORT_NUM; si++)
SWVLAN_vSetPvid(si, 0);
}
// If vlan enabled, add groups into hardware
for (si = 0; si < pSPageBuf->byValidEntryNum; si++) {
pSCurGrp->wVid = pSPageBuf->awValidGrpIdList[si];
PIVLAN_byGetGrp(pSPageBuf);
// Add portbase group
if (pSPageBuf->byVlanMode == VLAN_MODE_PORTBASE)
VLANvInsPortBaseGrp(pSCurGrp);
// Add 802.1Q group
else
VLANvIns8021QEntry(pSPageBuf);
}
// Finish port base table setting
if (pSPageBuf->byVlanMode == VLAN_MODE_PORTBASE)
SWVLAN_vSetPortBaseCfgForAllGrp();
}
// Set default vlan mode into EEPROM
void PIVLAN_vSetEepDefault (SVlanPageCfg *pSPageBuf) DIRECT_FUNTYPE_REENT
{
PIVLAN_vInitPage(pSPageBuf);
pSPageBuf->byVlanMode = VLAN_MODE_DISABLE;
PIVLAN_vSetVlanMode(pSPageBuf);
}
// Set vlan mode function
// Jenda 0502: write default vlan ingress filtering setting after change vlan mode from 802.1Q
void PIVLAN_vSetVlanMode (SVlanPageCfg *pSPageBuf) DIRECT_FUNTYPE_REENT
{
UINT8 si, byOldVlanMode;
// Clear VLAN table according to the original vlan mode
PIVLAN_vGetVlanMode(&byOldVlanMode);
if (byOldVlanMode == VLAN_MODE_8021Q) {
for (si = 0; si < pSPageBuf->byValidEntryNum; si++) {
pSCurGrp->wVid = pSPageBuf->awValidGrpIdList[si];
SWVLAN_vClearEntry(pSCurGrp->wVid);
}
}
else if (byOldVlanMode == VLAN_MODE_PORTBASE)
SWVLAN_vClearAllPortBaseGrp();
// Set EEPROM content to default value of new vlan mode
s_vSetEepDefault(pSPageBuf);
// Get config from EEPROM and set into hardware
PIVLAN_vSetHwFromEep(pSPageBuf);
// Set default vlan ingress filtering setting
if (byOldVlanMode == VLAN_MODE_8021Q) {
PIVLNFLT_vSetEepDefault((SVlanIngrFilterPageCfg*)pSCurGrp);
PIVLNFLT_vSetHwFromEep((SVlanIngrFilterPageCfg*)pSCurGrp);
}
// Clear MAC table to prevent lookup problems
SWFWD_vClearMacTable();
}
// Set EEPROM default value of each vlan mode
static void s_vSetEepDefault (SVlanPageCfg *pSPageBuf) DIRECT_FUNTYPE_REENT
{
UINT16 wTmp = 0; // used for "PIEEP_vSetCfgIntoEep"
UINT8 byStartId, si;
// Set vlan mode into eeprom
PIEEP_vSetCfgIntoEep(&pSPageBuf->byVlanMode, EEP_ADDR_VLAN_CFG, EEP_SIZE_VLAN_MODE);
// If 802.1Q => Add default group into EEPROM
if (pSPageBuf->byVlanMode == VLAN_MODE_8021Q) {
pSCurGrp->wVid = VLAN_DEFAULT_GROUP_VID;
STRvMemset( pSCurGrp->abyMbrMsk, 0, BYTE_NUM_OF_CFGBUF_BIT_MASK ); // Tagged member => 0
STRvMemset( pSCurGrp->abyMbrMsk + BYTE_NUM_OF_CFGBUF_BIT_MASK,
0xFF, BYTE_NUM_OF_CFGBUF_BIT_MASK ); // Untagged member => all ports
PIVLNEEP_vEditEntry(0, pSCurGrp);
byStartId = 1;
}
else
byStartId = 0;
// Clear group id of each entry buffer
for ( si = byStartId; si < SWITCH_VLAN_GRP_NUM; si++ )
PIEEP_vSetCfgIntoEep((PBYTE)&wTmp, PIVLNEEP_byEntryEepAddr(si), SIZE_OF_VID);
// Update checksum and return
PIEEP_vUpdateChecksum();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -