📄 ks_rate.c
字号:
PortConfigRate
Description:
This routine configures the priority rate of the port.
Parameters:
PHARDWARE pHardware
Pointer to hardware instance.
UCHAR bPort
The port index.
UCHAR bOffset
The receive or transmit, high or low priority, rate offset.
UCHAR bShift
The shift position to set the value.
ULONG dwRate
The rate limit in number of Kbps.
Return (None):
*/
static
void PortConfigRate (
PHARDWARE pHardware,
UCHAR bPort,
UCHAR bOffset,
UCHAR bShift,
ULONG dwRate )
{
#ifdef SH_16BIT_WRITE
USHORT usData;
UCHAR bByteShift = bOffset & 1;
#endif
UCHAR factor = 0;
UCHAR bData;
factor = ( UCHAR ) getRateToRegValue ( dwRate );
#ifdef SH_16BIT_WRITE
bOffset &= ~1;
bByteShift <<= 3;
PortConfigReadWord( pHardware, bPort,
REG_PORT_CTRL_BANK,
bOffset, &usData );
bData = ( UCHAR )( usData >> bByteShift );
#else
PortConfigReadByte( pHardware, bPort,
#ifdef KS_ISA_BUS
REG_PORT_CTRL_BANK,
#endif
bOffset, &bData );
#endif
bData &= ~( PORT_PRIORITY_RATE << bShift );
bData |= ( UCHAR )( factor << bShift );
#ifdef SH_16BIT_WRITE
usData &= 0x00FF << bByteShift;
usData |= ( USHORT ) bData << bByteShift;
PortConfigWriteWord( pHardware, bPort,
REG_PORT_CTRL_BANK,
bOffset, usData );
#else
PortConfigWriteByte( pHardware, bPort,
#ifdef KS_ISA_BUS
REG_PORT_CTRL_BANK,
#endif
bOffset, bData );
#endif
} /* PortConfigRate */
/*
PortGetRate
Description:
This routine retrieves the priority rate of the port.
Parameters:
PHARDWARE pHardware
Pointer to hardware instance.
UCHAR bPort
The port index.
UCHAR bOffset
The receive or transmit, high or low priority, rate offset.
UCHAR bShift
The shift position to get the value.
PULONG pdwBytes
Buffer to store the data rate in number of of Kbps.
Return (None):
*/
static
void PortGetRate (
PHARDWARE pHardware,
UCHAR bPort,
UCHAR bOffset,
UCHAR bShift,
PULONG pdwBytes )
{
UCHAR bData;
PortConfigReadByte( pHardware, bPort,
#ifdef KS_ISA_BUS
REG_PORT_CTRL_BANK,
#endif
bOffset, &bData );
bData >>= bShift;
bData &= PORT_PRIORITY_RATE;
*pdwBytes = getRegValueToRate ( bData );
} /* PortGetRate */
/*
HardwareConfigRxPriorityRate
Description:
This routine configures the receive priority rate of the port. It
is called by user functions. The hardware should be acquired first.
Parameters:
PHARDWARE pHardware
Pointer to hardware instance.
UCHAR bPort
The port index.
UCHAR bPriority
The priority index to configure.
ULONG dwRate
The rate limit in number of Kbps.
Return (None):
*/
#ifdef KS_PCI_BUS
void HardwareConfigRxPriorityRate_PCI
#else
void HardwareConfigRxPriorityRate_ISA
#endif
(
PHARDWARE pHardware,
UCHAR bPort,
UCHAR bPriority,
ULONG dwRate )
{
UCHAR bOffset;
UCHAR bShift;
ASSERT( pHardware->m_bAcquire );
bOffset = REG_PORT_IN_RATE_OFFSET;
bOffset += bPriority / 2;
bShift = PORT_PRIORITY_RATE_SHIFT * ( bPriority & 1 );
PortConfigRate( pHardware, bPort, bOffset, bShift, dwRate );
PortGetRate( pHardware, bPort, bOffset, bShift,
&pHardware->m_Port[ bPort ].dwRxRate[ bPriority ]);
} /* HardwareConfigRxPriorityRate */
/*
HardwareConfigTxPriorityRate
Description:
This routine configures the transmit priority rate of the port. It
is called by user functions. The hardware should be acquired first.
Parameters:
PHARDWARE pHardware
Pointer to hardware instance.
UCHAR bPort
The port index.
UCHAR bPriority
The priority index to configure.
ULONG dwRate
The rate limit in number of Kbps.
Return (None):
*/
#ifdef KS_PCI_BUS
void HardwareConfigTxPriorityRate_PCI
#else
void HardwareConfigTxPriorityRate_ISA
#endif
(
PHARDWARE pHardware,
UCHAR bPort,
UCHAR bPriority,
ULONG dwRate )
{
UCHAR bOffset;
UCHAR bShift;
ASSERT( pHardware->m_bAcquire );
bOffset = REG_PORT_OUT_RATE_OFFSET;
bOffset += bPriority / 2;
bShift = PORT_PRIORITY_RATE_SHIFT * ( bPriority & 1 );
PortConfigRate( pHardware, bPort, bOffset, bShift, dwRate );
PortGetRate( pHardware, bPort, bOffset, bShift,
&pHardware->m_Port[ bPort ].dwTxRate[ bPriority ]);
} /* HardwareConfigTxPriorityRate */
/*
SwitchDisablePriorityRate
Description:
This routine disables the priority rate function of the switch.
Parameters:
PHARDWARE pHardware
Pointer to hardware instance.
UCHAR bPort
The port index.
Return (None):
*/
#ifdef KS_PCI_BUS
void SwitchDisablePriorityRate_PCI
#else
void SwitchDisablePriorityRate_ISA
#endif
(
PHARDWARE pHardware,
UCHAR bPort
)
{
ASSERT( pHardware->m_bAcquire );
{
#ifdef KS_PCI_BUS
ULONG ulAddr;
PORT_CTRL_ADDR( bPort, ulAddr );
ulAddr += REG_PORT_IN_RATE_OFFSET;
HW_WRITE_DWORD( pHardware, ulAddr, 0 );
#else
UCHAR bBank = REG_PORT_CTRL_BANK + bPort * PORT_BANK_INTERVAL;
HardwareSelectBank( pHardware, bBank );
HW_WRITE_WORD( pHardware, REG_PORT_IN_RATE_OFFSET, 0 );
HW_WRITE_WORD( pHardware, REG_PORT_OUT_RATE_OFFSET, 0 );
#endif
}
} /* SwitchDisablePriorityRate */
/*
SwitchEnablePriorityRate
Description:
This routine enables the priority rate function of the switch.
Parameters:
PHARDWARE pHardware
Pointer to hardware instance.
UCHAR bPort
The port index.
Return (None):
*/
#ifdef KS_PCI_BUS
void SwitchEnablePriorityRate_PCI
#else
void SwitchEnablePriorityRate_ISA
#endif
(
PHARDWARE pHardware,
UCHAR bPort
)
{
UCHAR bPriority;
ASSERT( pHardware->m_bAcquire );
for ( bPriority = 0; bPriority < 4; bPriority++ )
{
HardwareConfigRxPriorityRate( pHardware, bPort, bPriority,
pHardware->m_Port[ bPort ].dwRxRate[ bPriority ]);
HardwareConfigTxPriorityRate( pHardware, bPort, bPriority,
pHardware->m_Port[ bPort ].dwTxRate[ bPriority ]);
}
} /* SwitchEnablePriorityRate */
#if defined( KS_ISA_BUS ) || !defined( KS_ISA )
/*
SwitchInitPriorityRate
Description:
This routine initializes the priority rate function of the switch.
Parameters:
PHARDWARE pHardware
Pointer to hardware instance.
Return (None):
*/
void SwitchInitPriorityRate (
PHARDWARE pHardware )
{
UCHAR bPort;
UCHAR bPriority;
for ( bPort = 0; bPort < TOTAL_PORT_NUM; bPort++ )
{
for ( bPriority = 0; bPriority < 4; bPriority++ )
{
pHardware->m_Port[ bPort ].dwRxRate[ bPriority ] =
pHardware->m_Port[ bPort ].dwTxRate[ bPriority ] = 0;
}
SwitchDisablePriorityRate( pHardware, bPort );
}
} /* SwitchInitPriorityRate */
#endif
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -