📄 swstp.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: swstp.c
*
* Purpose: STP functions
*
* Author: Tevin Chen
*
* Date: Jan 08, 2002
*
* Functions:
*
* Revision History:
*
*/
#if !defined(__SWITCH_H__)
#include "switch.h"
#endif
#if !defined(__SWREG_H__)
#include "swreg.h"
#endif
#if !defined(__SWSTP_H__)
#include "swstp.h"
#endif
/*--------------------- Static Definitions ------------------------*/
/*--------------------- Static Types ------------------------------*/
/*--------------------- Static Macros -----------------------------*/
/*--------------------- Static Classes ----------------------------*/
/*--------------------- Static Variables --------------------------*/
UINT8 au8PortState[SWITCH_PORT_NUM] = {
FORWARDING, FORWARDING, FORWARDING, FORWARDING, FORWARDING, FORWARDING, FORWARDING, FORWARDING,
FORWARDING, FORWARDING, FORWARDING, FORWARDING, FORWARDING, FORWARDING, FORWARDING, FORWARDING,
FORWARDING, FORWARDING, FORWARDING, FORWARDING, FORWARDING, FORWARDING, FORWARDING, FORWARDING,
FORWARDING, FORWARDING
};
UINT32 u32PortStateMsk = 0x03FFFFFFUL;
/*--------------------- Static Functions --------------------------*/
static BOOL s_bSetStpState(UINT8 byPortId, BYTE byStpState);
/*--------------------- Export Variables --------------------------*/
BOOL SWSTP_bSetStpStatus(BOOL bStatus)
{
UINT8 u8Temp;
UINT8 u8Msk=0x3;
SWREG_vReadB(RB_STP_CPU_FWD_ADDR, &u8Temp);
if (bStatus) {
u8Temp &= ~u8Msk;
u8Temp |= FWD_BPUD_PKT_2_CPU_ONLY ;
}
else {
u8Temp &= ~u8Msk;
u8Temp |= FWD_BPDU_PKT_2_ALL_BUT_CPU ;
}
SWREG_vWriteB(RB_STP_CPU_FWD_ADDR, u8Temp);
return TRUE;
}
static BOOL s_bSetStpState(UINT8 byPortId, BYTE byStpState)
{
switch( byStpState ) {
case DISABLED:
SWREG_vWriteB(RB_STP_PORT_START_ADDR+byPortId, DISABLED);
break;
case BLOCKING:
SWREG_vWriteB(RB_STP_PORT_START_ADDR+byPortId, BLOCKING);
break;
case LISTENING:
SWREG_vWriteB(RB_STP_PORT_START_ADDR+byPortId, BLOCKING);
break;
case LEARNING:
SWREG_vWriteB(RB_STP_PORT_START_ADDR+byPortId, LEARNING);
break;
case FORWARDING:
SWREG_vWriteB(RB_STP_PORT_START_ADDR+byPortId, FORWARDING);
break;
default:
return FALSE;
}
return TRUE;
}
void SWSTP_vSetPortState(UINT8 u8Port, UINT8 u8State)
{
UINT32 u32Msk = 0x1;
au8PortState[u8Port] = u8State;
switch (u8State) {
case DISABLED:
s_bSetStpState(u8Port, u8State);
u32PortStateMsk &= ~(u32Msk<<u8Port) ;
break;
case BLOCKING:
s_bSetStpState(u8Port, u8State);
u32PortStateMsk &= ~(u32Msk<<u8Port) ;
break;
case LISTENING:
s_bSetStpState(u8Port, u8State);
u32PortStateMsk &= ~(u32Msk<<u8Port) ;
break;
case LEARNING:
s_bSetStpState(u8Port, u8State);
u32PortStateMsk &= ~(u32Msk<<u8Port) ;
break;
case FORWARDING:
s_bSetStpState(u8Port, u8State);
u32PortStateMsk |= (u32Msk<<u8Port) ;
break;
default:
break;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -