📄 piportmp.h
字号:
/*
* 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: piportmp.h
*
* Purpose: Logical and physical port mapping functions
*
* Author: Tevin Chen
*
* Date: Jan 08, 2002
*
*/
#ifndef _PIPORTMP_H
#define _PIPORTMP_H
#include "ttype.h"
#if !defined(__SWCFG_H__)
#include "swcfg.h"
#endif
/*--------------- Introduction to Terminologies -------------------*/
/*
* There are three layers of port id/name:
* - Physical Port: Used by hardware, which is transparent to UI/API.
* - Panel Port: The id shown on hardware case panel, not really used.
* - Logical Port: Used by UI. The id of single port is consistent with
* panel id, while the id of trunk group is group id
* plus trunk group base id.
*
* e.g. If a user sets P0 & P2 as TRUNK2, then the two ports would be disappered
* and replaced with TRUNK2. The content of array "g_abyLogIdList" would be
* 1, 3, 4, 5, 6, ...., 22, 23, 25, where 25 means TRUNK2.
*
* There is still another layer called "logical port pointer" which is the
* index of array "g_abyLogIdList". This layer could let UI ignore all port
* mapping stuff. All UI has to do is to set config by the corresponding
* logical pointer, the rest part would be completed by APIs.
*/
/*--------------------- Export Definitions -------------------------*/
// Logical id of trkN = PORTMAP_BASE_TRKGRP_LOG_ID + N
#define PORTMAP_BASE_TRKGRP_LOG_ID SWITCH_PORT_NUM
// End of logical port array
#define ENTRY_END_FLAG UINT8_MAX
/*--------------------- Export Classes -----------------------------*/
/*--------------------- Export Variables --------------------------*/
// Definition of port names
extern PSTR g_aszPortNameTable[SWITCH_PORT_NUM+SWITCH_TRUNK_GRP_NUM];
// Define port id to name mapping
extern UINT8 g_abyPanelIdToNameMap[SWITCH_PORT_NUM+SWITCH_TRUNK_GRP_NUM];
// Logical id list array
extern UINT8 g_byLogIdNum;
extern UINT8 g_bySingleMegaLogIdNum; // for sniff config
extern UINT8 g_byMegaLogIdNum;
extern UINT8 g_byModTrkMegaLogIdNum;
#define g_byTrunkLogIdNum (g_byMegaLogIdNum - g_bySingleMegaLogIdNum)
#define g_byModuleLogIdNum (g_byLogIdNum - g_byMegaLogIdNum)
#define g_bySingleLogIdNum (g_bySingleMegaLogIdNum + g_byModuleLogIdNum) // without Trunk ports
extern UINT8 g_abyLogIdList[SWITCH_PORT_NUM];
extern BOOL g_bIsModuleTrk;
extern UINT8 g_byModTrkLogIdNum;
extern UINT8 g_abyModTrkLogIdList[SWITCH_PORT_NUM];
/*--------------------- Export Functions/Macros -------------------*/
//
// NOTE All port mapping information are found from HARDWARE rather than EEPROM
//
// Transfer between logical id and physical id
// If return value = ENTRY_END_FLAG => input id invalid
UINT8 PIPORTMP_byLogIdToPhyId(UINT8 byLogId) ;
#define PIPORTMP_byPhyIdToLogId(byPhyId) PORTMPbyPhyIdToLog(byPhyId, FALSE)
// Transfer between logical ptr and physical id
// If return value = ENTRY_END_FLAG => input id invalid
#define PIPORTMP_byLogPtrToPhyId(byLogPtr) PIPORTMP_byLogIdToPhyId(g_abyLogIdList[byLogPtr])
#define PIPORTMP_byPhyIdToLogPtr(byPhyId) PORTMPbyPhyIdToLog(byPhyId, TRUE)
// Transfer from logical id/ptr to physical mask
UINT32 PIPORTMP_dwLogIdToPhyMsk (UINT8 byLogId) ;
#define PIPORTMP_dwLogPtrToPhyMsk(byLogPtr) PIPORTMP_dwLogIdToPhyMsk(g_abyLogIdList[byLogPtr])
// Transfer between logical id mask and physical mask
#define PIPORTMP_dwLogMskToPhyMsk(dwLogMsk) PORTMPdwLogMskToPhyMsk(dwLogMsk, FALSE)
#define PIPORTMP_dwPhyMskToLogMsk(dwPhyMsk) PORTMPdwPhyMskToLogMsk(dwPhyMsk, FALSE)
// Transfer between the logical ptr mask and physical mask
#define PIPORTMP_dwLogPtrMskToPhyMsk(dwLogPtrMsk) PORTMPdwLogMskToPhyMsk(dwLogPtrMsk, TRUE)
#define PIPORTMP_dwPhyMskToLogPtrMsk(dwPhyMsk) PORTMPdwPhyMskToLogMsk(dwPhyMsk, TRUE)
// check if is trunked port by logical ptr
BOOL PIPORTMP_bIsTrunkedByLogPtr (UINT8 byLogPtr);
// Update logical id list
void PIPORTMP_vUpdateLogIdList (void);
// Internal function used by above Macros
UINT8 PORTMPbyPhyIdToLog (UINT8 byPhyId, BOOL bIsLogPtr) ;
UINT32 PORTMPdwLogMskToPhyMsk (UINT32 dwLogMsk, BOOL bIsLogPtrMsk);
UINT32 PORTMPdwPhyMskToLogMsk (UINT32 dwPhyMsk, BOOL bIsLogPtrMsk);
#endif /* __PIPORTMP_H__ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -