📄 ks_diag.c
字号:
#endif /* _EZ80L92 */
DBG_PRINT( "Received %d packets."NEWLINE, ( int ) totalRxPacket);
DBG_PRINT( NEWLINE);
return TRUE ;
}
/*****************************************************************
*
* Command: hwtableread
*
* Format: "hwtableread Table Index Count"
*
******************************************************************/
int hwtableread
(
char FAR *pbTableName,
unsigned long Index,
unsigned long Count
)
{
#ifdef DEF_VXWORKS
PHARDWARE phw = gpDrvCtrl[0]->pHW;
#endif
unsigned short wRegDataH ;
unsigned long dwRegDataH ;
unsigned long dwRegDataL ;
unsigned long dwTableID ;
/*
* Validate parameters
*/
if ( phw == NULL )
{
DisplayErrRetMsg( 3 ) ;
return FALSE;
}
if ( !(TableNameXlat( pbTableName, &dwTableID )) )
{
DisplayErrRetMsg( 1 ) ;
return FALSE ;
}
switch ( dwTableID )
{
case TABLE_STATIC_MAC:
if ( (Index + Count) > STATIC_MAC_TABLE_ENTRIES )
{
DisplayErrRetMsg( 1 ) ;
return FALSE ;
}
break;
case TABLE_VLAN:
if ( (Index + Count) > VLAN_TABLE_ENTRIES )
{
DisplayErrRetMsg( 1 ) ;
return FALSE ;
}
break;
case TABLE_DYNAMIC_MAC:
if ( (Index + Count) > LEARNED_MAC_TABLE_ENTRIES ) /* 1K entry */
{
DisplayErrRetMsg( 1 ) ;
return FALSE ;
}
break;
case TABLE_MIB:
if ( (Index + Count) > MIB_TABLE_ENTRIES )
{
DisplayErrRetMsg( 1 ) ;
return FALSE ;
}
break;
}
/*
* Read and display Count number of table entries
*/
DBG_PRINT(" DataH DataM DataL"NEWLINE);
while (Count--)
{
#ifdef KS_ISA_BUS
SwitchReadTableAllword_ISA( phw, dwTableID, ( USHORT ) Index, &wRegDataH, &dwRegDataH, &dwRegDataL );
#else
SwitchReadTableAllword_PCI( phw, dwTableID, ( USHORT ) Index, &wRegDataH, &dwRegDataH, &dwRegDataL );
#endif
DBG_PRINT( "%04lx ", Index ) ;
DBG_PRINT( " %04x %08lx %08lx" NEWLINE, wRegDataH, dwRegDataH, dwRegDataL );
Index++ ;
}
DBG_PRINT( NEWLINE);
return TRUE ;
}
/*****************************************************************
*
* Command: hwtablewrite
*
* Format: "hwtablewrite Table Index RegDataH RegDataL"
*
******************************************************************/
int hwtablewrite
(
char FAR *pbTableName,
unsigned long Index,
unsigned long RegDataH,
unsigned long RegDataL
)
{
#ifdef DEF_VXWORKS
PHARDWARE phw = gpDrvCtrl[0]->pHW;
#endif
unsigned long dwTableID ;
/*
* Validate parameters
*/
if ( phw == NULL )
{
DisplayErrRetMsg( 3 ) ;
return FALSE;
}
if ( !(TableNameXlat( pbTableName, &dwTableID )) )
{
DisplayErrRetMsg( 1 ) ;
return FALSE ;
}
switch ( dwTableID )
{
case TABLE_STATIC_MAC:
if ( Index >= STATIC_MAC_TABLE_ENTRIES )
{
DisplayErrRetMsg( 1 ) ;
return FALSE ;
}
break;
case TABLE_VLAN:
if ( Index >= VLAN_TABLE_ENTRIES )
{
DisplayErrRetMsg( 1 ) ;
return FALSE ;
}
break;
case TABLE_DYNAMIC_MAC:
case TABLE_MIB:
DisplayErrRetMsg( 10 ) ;
return FALSE ;
}
/*
* Write to table entry
*/
#ifdef KS_ISA_BUS
SwitchWriteTableQword_ISA( phw, dwTableID, ( USHORT ) Index, RegDataH, RegDataL );
#else
SwitchWriteTableQword_PCI( phw, dwTableID, ( USHORT ) Index, RegDataH, RegDataL );
#endif
DBG_PRINT( NEWLINE);
return TRUE ;
}
/*****************************************************************
*
* Command: hwtableshow
*
* Format: "hwtableshow Table Index Count "
*
******************************************************************/
int hwtableshow
(
char FAR *pbTableName,
unsigned long Index,
unsigned long Count,
BOOLEAN fDidplay
)
{
#ifdef DEF_VXWORKS
PHARDWARE phw = gpDrvCtrl[0]->pHW;
#endif
unsigned long dwTableID ;
unsigned char mac[6] ;
unsigned char bPorts=0 ;
unsigned char bFid=0 ;
unsigned short wVid=0 ;
unsigned char bTimestamp=0;
unsigned short wEntries;
BOOLEAN fOverride=FALSE;
BOOLEAN fUseFID=FALSE;
#if 0
unsigned char bInvalid;
#endif
unsigned long status = 1;
BOOLEAN fEntryReady=TRUE;
/*
* Validate parameters
*/
if ( phw == NULL )
{
DisplayErrRetMsg( 3 ) ;
return FALSE;
}
if ( !(TableNameXlat( pbTableName, &dwTableID )) )
{
DisplayErrRetMsg( 1 ) ;
return FALSE ;
}
switch ( dwTableID )
{
case TABLE_STATIC_MAC:
if ( (Index + Count) > STATIC_MAC_TABLE_ENTRIES )
{
DisplayErrRetMsg( 1 ) ;
return FALSE ;
}
break;
case TABLE_DYNAMIC_MAC:
if ( (Index + Count) > LEARNED_MAC_TABLE_ENTRIES ) /* 1K entry */
{
DisplayErrRetMsg( 1 ) ;
return FALSE ;
}
break;
case TABLE_VLAN:
if ( (Index + Count) > VLAN_TABLE_ENTRIES )
{
DisplayErrRetMsg( 1 ) ;
return FALSE ;
}
break;
case TABLE_MIB:
Count = 1;
break;
}
/*
* Read and display Count number of table entries
*/
if ( fDidplay )
{
DBG_PRINT( NEWLINE );
macDisplayTitle( dwTableID );
}
while (Count--)
{
memset ( mac, 0, 6);
switch ( dwTableID )
{
case TABLE_STATIC_MAC:
/* read static mac table from ks884x */
status = 3;
if ( !(SwitchReadStaticMacTable( phw, ( USHORT ) Index, mac, &bPorts, &fOverride, &fUseFID, &bFid) ) )
status = 1;
/*status = 3;*/
break;
case TABLE_DYNAMIC_MAC:
/* read dynamic mac table from ks884x */
status = 2;
fEntryReady = SwitchReadDynMacTable ( phw, ( USHORT ) Index, mac, &bFid, &bPorts, &bTimestamp, &wEntries );
if (bPorts == 0)
bPorts += 1;
else
bPorts <<= 1;
if (Index < wEntries )
status = 2; /* within the valid entry, this entry is valid */
else
status = 1; /* beyond the valid entry, this entry is invalid */
break;
case TABLE_VLAN:
status = 0;
if ( !(SwitchReadVlanTable( phw, ( USHORT ) Index, &wVid, &bFid, &bPorts) ) )
status = 1;
break;
case TABLE_MIB:
status = 0;
PortReadCounters( phw, 0 );
#ifdef DEF_KS8842
PortReadCounters( phw, 1 );
#endif
PortReadCounters( phw, 2 );
break;
}
/* display table */
if ( fEntryReady == FALSE)
{
Index++ ;
continue;
}
if ( fDidplay )
{
if ( dwTableID == TABLE_MIB)
showMibTable( phw );
else
showTableEntry( dwTableID, Index, bFid, wVid, mac, bPorts, fOverride, fUseFID, bTimestamp, status );
}
Index++ ;
}
DBG_PRINT( NEWLINE);
return TRUE ;
}
/*****************************************************************
*
* Command: hwclearmib
*
* Format: "hwclearmib Port"
*
******************************************************************/
int hwclearmib
(
unsigned long Port
)
{
#if 0
PPORT_CONFIG pPort;
#endif
unsigned char bPort;
#ifdef DEF_VXWORKS
DRV_CTRL * pDrvCtrl= gpDrvCtrl[0]; /* device ptr */
PHARDWARE phw = gpDrvCtrl[0]->pHW;
#endif
/*
* Validate parameters
*/
if ( (Port > 4 ) || (Port < 1) )
{
DisplayErrRetMsg( 1 ) ;
return FALSE ;
}
if ( phw == NULL )
{
DisplayErrRetMsg( 3 ) ;
return FALSE ;
}
/*
* Clear MIB counter database.
*/
if ( Port < 4)
{
/* clear individual Port's MIB counter database */
phw->m_bPortSelect = ( UCHAR )( Port - 1 );
HardwareClearCounters( phw );
}
else
{
/* clear all Port's MIB counter database */
for (bPort=0; bPort<TOTAL_PORT_NUM; bPort++)
{
phw->m_bPortSelect = bPort;
HardwareClearCounters( phw );
}
}
/*
DBG_PRINT( NEWLINE );
hwtableshow ( "mib", 0, 1, TRUE );
*/
#ifdef KS_QC_TEST
DBG_PRINT( "^[ok]$" );
#endif
DBG_PRINT( NEWLINE);
return TRUE ;
}
/*****************************************************************
*
* Command: hwdumprx
*
* Format: "hwdumprx DumpFlag"
*
******************************************************************/
int hwdumprx
(
unsigned long DumpFlag
)
{
#ifdef DEF_VXWORKS
PHARDWARE phw = gpDrvCtrl[0]->pHW;
#endif
/*
* Validate parameters
*/
if ( DumpFlag > 1 )
return FALSE;
if ( phw == NUL
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -