📄 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
* Henry Lin
*
* Date: Jan 08, 2002
* Apr 26, 2005
*
* Functions:
*
* Revision History:
*
*/
#if !defined(__SWCFG_H__)
#include "swcfg.h"
#endif
#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
#if !defined(__SWTRK_H__)
#include "swtrk.h"
#endif
/*--------------------- Static Definitions ------------------------*/
#define pSCfg ((SPortTrkCfg*)&u16Cfg)
/*--------------------- Static Types ------------------------------*/
/*--------------------- Static Macros -----------------------------*/
/*--------------------- Static Classes ----------------------------*/
/*--------------------- Static Variables --------------------------*/
UINT8 s_abyTrkAdmTbl[MAX_TRK_MBR_NUM][MAX_TRK_MBR_NUM] = {
{0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
// 1 Mbr => 11111111b
{0x55, 0xAA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
// 2 Mbrs => 0101_0101b,
// 1010_1010b
{0x92, 0x49, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00},
// 3 Mbrs => 1001_0010b,
// 0100_1001b,
// 0010_0100b
{0x88, 0x44, 0x22, 0x11, 0x00, 0x00, 0x00, 0x00},
// 4 Mbrs => 1000_1000b,
// 0100_0100b,
// 0010_0010b,
// 0001_0001b
{0x84, 0x42, 0x21, 0x10, 0x08, 0x00, 0x00, 0x00},
// 5 Mbrs => 1000_0100b,
// 0100_0010b,
// 0010_0001b,
// 0001_0000b,
// 0000_1000b
{0x82, 0x41, 0x20, 0x10, 0x08, 0x04, 0x00, 0x00},
// 6 Mbrs => 1000_0010b,
// 0100_0001b,
// 0010_0000b,
// 0001_0000b,
// 0000_1000b,
// 0000_0100b
{0x81, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x00},
// 7 Mbrs => 1000_0001b,
// 0100_0000b,
// 0010_0000b,
// 0001_0000b,
// 0000_1000b,
// 0000_0100b
// 0000_0010b
{0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01}
// 8 Mbrs => 1000_0000b,
// 0100_0000b,
// 0010_0000b,
// 0001_0000b,
// 0000_1000b,
// 0000_0100b
// 0000_0010b
// 0000_0001b
};
/*--------------------- Static Functions --------------------------*/
/*--------------------- Export Variables --------------------------*/
UINT8 SWTRK_byInsGrp (UINT8 byGrpId, UINT32 dwMbrMsk)
{
UINT32 dwLinkMbrMsk = 0, dwShftBuf = 0x00000001;
UINT8 byTmp = 0, byLinkMbrCnt = 0, uu;
UINT16 u16Cfg;
SWREG_vReadU32(PHYCTL_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 = 0x00000001;
byTmp = 0;
for (uu = 0; uu < SWITCH_TRUNKABLE_PORT_NUM; uu++) {
if (dwMbrMsk & dwShftBuf) {
pSCfg->f4GrpId = byGrpId;
pSCfg->f1Enable = TRUE;
if (dwLinkMbrMsk & dwShftBuf ) {
pSCfg->byCriteria = s_abyTrkAdmTbl[byLinkMbrCnt-1][byTmp];
byTmp++;
}
else {
pSCfg->byCriteria = 0;
}
SWREG_vWriteU16(PORTCFG_TRUNK_CRITERIA_BASE + (uu * PORTCFG_PORT_OFFSET), u16Cfg);
}
dwShftBuf <<= 1;
}
return OP_OK;
}
void SWTRK_vDelGrp (UINT32 dwMbrMsk)
{
UINT8 uu;
for (uu = 0; uu < SWITCH_TRUNKABLE_PORT_NUM; uu++) {
if (dwMbrMsk & 0x00000001)
SWREG_vWriteU16(PORTCFG_TRUNK_CRITERIA_BASE + (uu * PORTCFG_PORT_OFFSET), 0);
dwMbrMsk >>= 1;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -