📄 swmactblscan.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: swmactblscan.c
*
* Purpose: Mac table scan hardware accessing functions
*
* Author: Tim Feng
*
* Date: Feb 17, 2006
*
* Functions:
*
* Revision History:
*
*/
#if !defined(__SWITCH_H__)
#include "switch.h"
#endif
#if !defined(__SWREG_H__)
#include "swreg.h"
#endif
#if !defined(__SWSCAN_H__)
#include "swmactblscan.h"
#endif
/*--------------------- Static Definitions ------------------------*/
#define SCAN_CFG_FID_BIT_OFST 0
#define SCAN_CFG_FID_ENABLE_BIT_OFST 13
#define SCAN_CFG_MVFRM_PORT_BIT_OFST 0
#define SCAN_CFG_MVFRM_PORT_TYPE_BIT_OFST 5
#define SCAN_CFG_MVFRM_PORT_ENABLE_BIT_OFST 6
#define SCAN_CFG_MVTO_PORT_BIT_OFST 0
#define SCAN_CFG_MVTO_PORT_TYPE_BIT_OFST 5
/*--------------------- Static Types ------------------------------*/
/*--------------------- Static Macros -----------------------------*/
/*--------------------- Static Classes ----------------------------*/
/*--------------------- Static Variables --------------------------*/
/*--------------------- Static Functions --------------------------*/
/*--------------------- Export Variables --------------------------*/
void SWMACTBLSCAN_vGetScanCfg(SMacTblScanCfg *psScanCfg)
{
UINT16 u16MvFrmFidCfg = 0;
UINT16 u16MvFrmPortCfg = 0;
UINT16 u16MvToPortCfg = 0;
SWREG_vReadU16(FWDCTL_SCAN_CMD_MV_FRM_FID, &u16MvFrmFidCfg);
SWREG_vReadU16(FWDCTL_SCAN_CMD_MV_FRM_PORT, &u16MvFrmPortCfg);
SWREG_vReadU16(FWDCTL_SCAN_CMD_MV_TO_PORT, &u16MvToPortCfg);
SWREG_vReadU8(FWDCTL_SCAN_CMD, &psScanCfg->byCmd);
psScanCfg->wMvFrmFid = u16MvFrmFidCfg & ((0x01<<SCAN_CFG_FID_ENABLE_BIT_OFST) -1) ;
psScanCfg->bMvFrmFidEn = (u16MvFrmFidCfg >> SCAN_CFG_FID_ENABLE_BIT_OFST) & 0x01;
psScanCfg->byMvFrmPortId = u16MvFrmPortCfg & ((0x01<<SCAN_CFG_MVFRM_PORT_TYPE_BIT_OFST) -1) ;
psScanCfg->bMvFrmTrunk = (u16MvFrmPortCfg >> SCAN_CFG_MVFRM_PORT_TYPE_BIT_OFST) & 0x01;
psScanCfg->bMvFrmPortEn= (u16MvFrmPortCfg >> SCAN_CFG_MVFRM_PORT_ENABLE_BIT_OFST) & 0x01 ;
psScanCfg->byMvToPortId = u16MvToPortCfg & ((0x01<<SCAN_CFG_MVTO_PORT_TYPE_BIT_OFST) -1) ;
psScanCfg->bMvToTrunk = (u16MvToPortCfg >> SCAN_CFG_MVTO_PORT_TYPE_BIT_OFST) & 0x01 ;
}
void SWMACTBLSCAN_vSetScanCfg(SMacTblScanCfg sScanCfg)
{
UINT16 u16MvFrmFidCfg = 0;
UINT16 u16MvFrmPortCfg = 0;
UINT16 u16MvToPortCfg = 0;
u16MvFrmFidCfg |= sScanCfg.wMvFrmFid << SCAN_CFG_FID_BIT_OFST;
u16MvFrmFidCfg |= sScanCfg.bMvFrmFidEn << SCAN_CFG_FID_ENABLE_BIT_OFST;
u16MvFrmPortCfg |= sScanCfg.byMvFrmPortId <<SCAN_CFG_MVFRM_PORT_BIT_OFST;
u16MvFrmPortCfg |= sScanCfg.bMvFrmTrunk << SCAN_CFG_MVFRM_PORT_TYPE_BIT_OFST;
u16MvFrmPortCfg |= sScanCfg.bMvFrmPortEn <<SCAN_CFG_MVFRM_PORT_ENABLE_BIT_OFST;
u16MvFrmPortCfg |= sScanCfg.byMvToPortId << SCAN_CFG_MVTO_PORT_BIT_OFST;
u16MvFrmPortCfg |= sScanCfg.bMvToTrunk << SCAN_CFG_MVTO_PORT_TYPE_BIT_OFST;
SWREG_vWriteU16(FWDCTL_SCAN_CMD_MV_FRM_FID, u16MvFrmFidCfg);
SWREG_vWriteU16(FWDCTL_SCAN_CMD_MV_FRM_PORT, u16MvFrmPortCfg);
SWREG_vWriteU16(FWDCTL_SCAN_CMD_MV_TO_PORT, u16MvToPortCfg);
SWREG_vWriteU8(FWDCTL_SCAN_CMD, sScanCfg.byCmd);
SWREG_bWaitStatus(FWDCTL_SCAN_STATUS, SCAN_STATUS_BUSY, TRUE);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -