📄 swmib.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: swmib.c
*
* Purpose: Mib table operation functions
*
* Author: Tevin Chen
*
* Date: Jan 08, 2002
*
* Functions:
*
* Revision History:
*
*/
#if !defined(__BITOP_H__)
#include "bitop.h"
#endif
#if !defined(__STR_H__)
#include "str.h"
#endif
#if !defined(__SWITCH_H__)
#include "switch.h"
#endif
#if !defined(__SWSRAM_H__)
#include "swsram.h"
#endif
#if !defined(__SWMIB_H__)
#include "swmib.h"
#endif
/*--------------------- Static Definitions ------------------------*/
#define MIB_TBL_BASE_ADDR (SRAM_CTRL_BLK_BASE_ADDR + 0x3C00)
#define MIB_TBL_SIZE 0x340
#define MIB_TBL_PORT_OFFSET 0x0010
#define SLOT_ENTRY_NUM 2
/*--------------------- Static Types ------------------------------*/
/*--------------------- Static Macros -----------------------------*/
/*--------------------- Static Classes ----------------------------*/
/*--------------------- Static Variables --------------------------*/
/*--------------------- Static Functions --------------------------*/
/*--------------------- Export Variables --------------------------*/
void SWMIB_vGetCntr(BYTE byPortId, BYTE byCntrId, UINT32 *pdwCntr)
{
BYTE abySlotBuf[SRAM_CTRL_SLOT_SIZE];
UINT16 wAddr;
wAddr = MIB_TBL_BASE_ADDR + (byPortId * MIB_TBL_PORT_OFFSET) + (byCntrId / SLOT_ENTRY_NUM);
SWSRAM_bReadSlot(wAddr, abySlotBuf);
BITvExtractBits( abySlotBuf,
(BYTE)( 8 * (byCntrId % SLOT_ENTRY_NUM) ),
(BYTE)( 8 * ((byCntrId % SLOT_ENTRY_NUM) + 1) - 1 ),
(PBYTE)pdwCntr );
}
void SWMIB_vClearCntr(BYTE byPortId, BYTE byCntrId)
{
BYTE abySlotBuf[SRAM_CTRL_SLOT_SIZE];
BYTE abyValueBuf[SRAM_CTRL_SLOT_SIZE];
UINT16 wAddr;
STRvMemset(abyValueBuf, 0, SRAM_CTRL_SLOT_SIZE);
wAddr = MIB_TBL_BASE_ADDR + (byPortId * MIB_TBL_PORT_OFFSET) + (byCntrId / SLOT_ENTRY_NUM);
SWSRAM_bReadSlot(wAddr, abySlotBuf);
BITvModifyBits( abySlotBuf,
(BYTE)( 8 * (byCntrId % SLOT_ENTRY_NUM) ),
(BYTE)( 8 * ((byCntrId % SLOT_ENTRY_NUM) + 1) - 1),
abyValueBuf );
SWSRAM_bWriteSlot(wAddr, abySlotBuf);
}
void SWMIB_vGetAllCntr(BYTE byPortId, SMibCntr *pSMibCntr)
{
PUINT32 pdwTmp;
BYTE uu;
for (uu = 0; uu < MIBTBL_CNTR_NUM; uu++) {
pdwTmp = (PUINT32)( (PBYTE)&(pSMibCntr->dwRxBcastPkt) + uu * sizeof(UINT32) );
SWMIB_vGetCntr(byPortId, uu, pdwTmp);
}
}
void SWMIB_vClearAllCntr(BYTE byPortId)
{
BYTE abySlotBuf[SRAM_CTRL_SLOT_SIZE];
BYTE uu;
STRvMemset(abySlotBuf, 0, SRAM_CTRL_SLOT_SIZE);
for (uu = 0; uu < (MIBTBL_CNTR_NUM / SLOT_ENTRY_NUM); uu++)
SWSRAM_bWriteSlot(MIB_TBL_BASE_ADDR + (byPortId * MIB_TBL_PORT_OFFSET) + uu, abySlotBuf);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -