📄 swtrk.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: swtrk.c
*
* Purpose: Trunk hardware accessing 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(__SWMSG_H__)
#include "swmsg.h"
#endif
#if !defined(__SWPORT_H__)
#include "swport.h"
#endif
#include "swtrk.h"
/*--------------------- Static Definitions ------------------------*/
#define pSCfg ((SPortTrkCfg*)&byCfg)
/*--------------------- Static Types ------------------------------*/
/*--------------------- Static Macros -----------------------------*/
/*--------------------- Static Classes ----------------------------*/
/*--------------------- Static Variables --------------------------*/
DIRECT_MEMTYPE_CODE BYTE s_abyTrkAdmTbl[MAX_TRK_MBR_NUM][MAX_TRK_MBR_NUM] =
{
{0x0F, 0x00, 0x00, 0x00}, // 1 Mbr => 1111b
{0x05, 0x0A, 0x00, 0x00}, // 2 Mbrs => 0101b, 1010b
{0x01, 0x06, 0x08, 0x00}, // 3 Mbrs => 0001b, 0110b, 1000b
{0x01, 0x02, 0x04, 0x08} // 4 Mbrs => 0001b, 0010b, 0100b, 1000b
};
/*--------------------- Static Functions --------------------------*/
/*--------------------- Export Variables --------------------------*/
BYTE SWTRK_byInsGrp (UINT8 byGrpId, UINT32 dwMbrMsk) DIRECT_FUNTYPE_REENT
{
UINT32 dwLinkMbrMsk = 0, dwShftBuf = 0x01;
UINT8 byCfg, byTmp = 0, byLinkMbrCnt = 0, uu;
SWREG_vReadDW(PHY_LINK_STATUS, &dwLinkMbrMsk);
dwLinkMbrMsk &= dwMbrMsk;
// Check status of each member port
for (uu = 0; uu < SWITCH_TRUNKABLE_PORT_NUM; uu++) {
if (dwMbrMsk & dwShftBuf)
byTmp++;
if (dwLinkMbrMsk & dwShftBuf)
byLinkMbrCnt++;
dwShftBuf <<= 1;
}
if (byTmp < MIN_TRK_MBR_NUM || byTmp > MAX_TRK_MBR_NUM)
return TRK_OP_MBR_NUM_INVALID;
// Caculate admin criteria of each member and then write into hardware
dwShftBuf = 0x01;
byTmp = 0;
for (uu = 0; uu < SWITCH_TRUNKABLE_PORT_NUM; uu++) {
if (dwMbrMsk & dwShftBuf) {
pSCfg->f3GrpId = byGrpId;
pSCfg->f1Enable = TRUE;
if ( dwLinkMbrMsk & dwShftBuf ) {
pSCfg->f4Criteria = s_abyTrkAdmTbl[byLinkMbrCnt-1][byTmp];
byTmp++;
}
else {
pSCfg->f4Criteria = 0;
}
SWREG_vWriteB((UINT16)(FWD_TRUNK_CFG_BASE + uu), byCfg);
}
dwShftBuf <<= 1;
}
return OP_OK;
}
void SWTRK_vDelGrp (UINT32 dwMbrMsk) DIRECT_FUNTYPE_REENT
{
UINT8 uu;
for (uu = 0; uu < SWITCH_TRUNKABLE_PORT_NUM; uu++) {
if (dwMbrMsk & 0x01)
SWREG_vWriteB((UINT16)(FWD_TRUNK_CFG_BASE + uu), 0);
dwMbrMsk >>= 1;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -