📄 swmsttb.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: swmsttb.c
*
* Purpose: Multiple Spanning Tree state table operation functions
*
* Author: Henry Lin
*
* Date: Nov 05, 2004
*
* Functions:
*
* Revision History:
* 2005-07-15 LucasLin Clear Software_Valid bit in SWMSTTB_bGetEntry
*
*/
#if !defined(__STR_H__)
#include "str.h"
#endif
#if !defined(__SWITCH_H__)
#include "switch.h"
#endif
#if !defined(__SWREG_H__)
#include "swreg.h"
#endif
#if !defined(__SWSRAM_H__)
#include "swsram.h"
#endif
#if !defined(__SWMSTTB_H__)
#include "swmsttb.h"
#endif
/*--------------------- Static Definitions ------------------------*/
/*--------------------- Static Types ------------------------------*/
/*--------------------- Static Macros -----------------------------*/
#define MSTID_TO_SA(mid) (SRAM_STP_TBL_BASE_ADDR + (mid<<SHIFT_NUM_SIZE_8Byte))
/*--------------------- Static Classes ----------------------------*/
/*--------------------- Static Variables --------------------------*/
/*--------------------- Static Functions --------------------------*/
/*--------------------- Export Variables --------------------------*/
BOOL SWMSTTB_bGetEntry (UINT8 u8MstId, UINT32 *pu32STStHigh, UINT32 *pu32STStLow)
{
UINT8 au8EntryBuf[SRAM_ENTRY_SIZE_8Byte];
UINT32 u32Addr;
u32Addr = MSTID_TO_SA(u8MstId);
// read entry
SWSRAM_bReadEntry(u32Addr, au8EntryBuf);
SWSRAM_bReadEntry(u32Addr+4, au8EntryBuf+4);
/*
* 2005-07-15, Lucas
* Clear Software_Valid bit upon SWMSTTB_bGetEntry
*/
au8EntryBuf[3] &= ~STP_BPTN_VALID;
au8EntryBuf[7] &= ~STP_BPTN_VALID;
*pu32STStHigh = *((UINT32 *)&au8EntryBuf[4]);
*pu32STStLow = *((UINT32 *)&au8EntryBuf[0]);
return TRUE;
}
BOOL SWMSTTB_bInsEntry (UINT8 u8MstId, UINT32 u32STStHigh, UINT32 u32STStLow)
{
UINT8 au8EntryBuf[SRAM_ENTRY_SIZE_8Byte];
UINT32 u32Addr;
u32Addr = MSTID_TO_SA(u8MstId);
STR_pvMemset(au8EntryBuf, 0 , SRAM_ENTRY_SIZE_8Byte);
*((UINT32 *)au8EntryBuf) = u32STStLow;
*((UINT32 *)&au8EntryBuf[4]) = u32STStHigh;
//bit[26][58] only used by software
au8EntryBuf[3] |= STP_BPTN_VALID;
au8EntryBuf[7] |= STP_BPTN_VALID;
// write entry
SWSRAM_bWriteEntry(u32Addr, au8EntryBuf);
SWSRAM_bWriteEntry(u32Addr+4, au8EntryBuf+4);
return TRUE;
}
BOOL SWMSTTB_bDelEntry (UINT8 u8MstId)
{
UINT32 u32Addr;
UINT8 au8EntryBuf[SRAM_ENTRY_SIZE_8Byte];
u32Addr = MSTID_TO_SA(u8MstId);
STR_pvMemset(au8EntryBuf, 0 , SRAM_ENTRY_SIZE_8Byte);
// write entry
SWSRAM_bWriteEntry(u32Addr, au8EntryBuf);
SWSRAM_bWriteEntry(u32Addr+4, au8EntryBuf+4);
return TRUE;
}
BOOL SWMSTTB_bDelEntryBySA(UINT32 u32Addr)
{
UINT8 au8EntryBuf[SRAM_ENTRY_SIZE_8Byte];
STR_pvMemset(au8EntryBuf, 0 , SRAM_ENTRY_SIZE_8Byte);
// write entry
SWSRAM_bWriteEntry(u32Addr, au8EntryBuf);
SWSRAM_bWriteEntry(u32Addr+4, au8EntryBuf+4);
return TRUE;
}
/*
* Description : This function only be used by debug(anlz).
*/
BOOL SWMSTTB_bIsEntryValid (UINT32 u32Addr)
{
UINT8 au8EntryBuf[SRAM_ENTRY_SIZE_8Byte];
// read entry
SWSRAM_bReadEntry(u32Addr, au8EntryBuf);
SWSRAM_bReadEntry(u32Addr+4, au8EntryBuf+4);
// Check if bit[26],[58] is 1 of Valid array
if (((au8EntryBuf[3] & STP_BPTN_VALID) != 0) &&
((au8EntryBuf[7] & STP_BPTN_VALID) != 0) )
return TRUE;
return FALSE;
}
//
// Input: Multiple Spanning Tree ID(0~63)
// Output: Sram Addr for MST table
//
UINT32 SWMSTTB_dwGetSA(UINT8 byMid)
{
UINT32 dwAddr;
if (byMid > 63)
return UINT32_MAX;
dwAddr = SRAM_STP_TBL_BASE_ADDR + (byMid << SHIFT_NUM_SIZE_8Byte);
return dwAddr;
}
/*
* Description : This function only be used by debug(anlz).
*/
void SWMSTTB_vSetEntryValid(UINT32 u32Addr)
{
UINT8 au8EntryBuf[SRAM_ENTRY_SIZE_8Byte];
// Write sram data, because we want to set bit[26][58]
au8EntryBuf[3] = STP_BPTN_VALID;
au8EntryBuf[7] = STP_BPTN_VALID;
// write entry
SWSRAM_bWriteEntry(u32Addr, au8EntryBuf);
SWSRAM_bWriteEntry(u32Addr+4, au8EntryBuf+4);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -