📄 mdata.c
字号:
if(pLibDev->tx[queueIndex].endPktAddr) {
memFree(devNum, pLibDev->tx[queueIndex].endPktAddr);
memFree(devNum, pLibDev->tx[queueIndex].endPktDesc);
pLibDev->tx[queueIndex].endPktAddr = 0;
pLibDev->tx[queueIndex].endPktDesc = 0;
}
}
/**************************************************************************
* enableWep - setup the keycache with default keys and set an internel
* wep enable flag
* For now the software will hardcode some keys in here.
* eventually I will change the interface on here to allow
* keycache to be setup.
*
*/
MANLIB_API void enableWep
(
A_UINT32 devNum,
A_UCHAR key //which of the default keys to use
)
{
LIB_DEV_INFO *pLibDev = gLibInfo.pLibDevArray[devNum];
if (checkDevNum(devNum) == FALSE) {
mError(devNum, EINVAL, "Device Number %d:enableWep\n", devNum);
return;
}
if(pLibDev->devState < RESET_STATE) {
mError(devNum, EILSEQ, "Device Number %d:enableWep: device not in reset state - resetDevice must be run first\n", devNum);
return;
}
//program keys 1-3 in the key cache.
REGW(devNum, 0x9000, 0x22222222);
REGW(devNum, 0x9004, 0x11);
REGW(devNum, 0x9014, 0x00); //40 bit key
REGW(devNum, 0x901c, 0x8000); //valid bit
REGW(devNum, 0x9010, 0x22222222);
REGW(devNum, 0x9024, 0x11);
REGW(devNum, 0x9034, 0x00); //40 bit key
REGW(devNum, 0x903c, 0x8000); //valid bit
REGW(devNum, 0x9040, 0x22222222);
REGW(devNum, 0x9044, 0x11);
REGW(devNum, 0x9054, 0x00); //40 bit key
REGW(devNum, 0x905c, 0x8000); //valid bit
REGW(devNum, 0x9060, 0x22222222);
REGW(devNum, 0x9064, 0x11);
REGW(devNum, 0x9074, 0x00); //40 bit key
REGW(devNum, 0x907c, 0x8000); //valid bit
REGW(devNum, 0x8800, 0x22222222);
REGW(devNum, 0x8804, 0x11);
REGW(devNum, 0x8814, 0x00); //40 bit key
REGW(devNum, 0x881c, 0x8000); //valid bit
REGW(devNum, 0x8810, 0x22222222);
REGW(devNum, 0x8824, 0x11);
REGW(devNum, 0x8834, 0x00); //40 bit key
REGW(devNum, 0x883c, 0x8000); //valid bit
REGW(devNum, 0x8840, 0x22222222);
REGW(devNum, 0x8844, 0x11);
REGW(devNum, 0x8854, 0x00); //40 bit key
REGW(devNum, 0x885c, 0x8000); //valid bit
REGW(devNum, 0x8860, 0x22222222);
REGW(devNum, 0x8864, 0x11);
REGW(devNum, 0x8874, 0x00); //40 bit key
REGW(devNum, 0x887c, 0x8000); //valid bit
pLibDev->wepEnable = 1;
pLibDev->wepKey = key;
}
/**************************************************************************
* txDataBegin - start transmission
*
*/
MANLIB_API void txDataBegin
(
A_UINT32 devNum,
A_UINT32 timeout,
A_UINT32 remoteStats
)
{
txDataStart( devNum );
txDataComplete( devNum, timeout, remoteStats );
}
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
////
////
/**************************************************************************
* txDataBegin - start transmission
*
*/
MANLIB_API void txDataStart
(
A_UINT32 devNum
)
{
LIB_DEV_INFO *pLibDev = gLibInfo.pLibDevArray[devNum];
MDK_ATHEROS_DESC localDesc;
static A_UINT16 activeQueues[MAX_TX_QUEUE] = {0}; // Index of the active queue
A_UINT16 activeQueueCount = 0; // active queues count
int i = 0;
for( i = 0; i < MAX_TX_QUEUE; i++ )
{
if ( pLibDev->tx[i].txEnable )
{
activeQueues[activeQueueCount] = (A_UINT16)i;
activeQueueCount++;
}
}
for( i = 0; i < activeQueueCount; i++ )
{
if (checkDevNum(devNum) == FALSE) {
mError(devNum, EINVAL, "Device Number %d:txDataStart\n", devNum);
return;
}
if(pLibDev->devState < RESET_STATE) {
mError(devNum, EILSEQ, "Device Number %d:txDataStart: device not in reset state - resetDevice must be run first\n", devNum);
return;
}
if (!pLibDev->tx[activeQueues[i]].txEnable) {
mError(devNum, EILSEQ,
"Device Number %d:txDataStart: txDataSetup must successfully complete before running txDataBegin\n", devNum);
return;
}
//zero out the local tx stats structures
memset(&(pLibDev->tx[activeQueues[i]].txStats[0]), 0, sizeof(TX_STATS_STRUCT) * STATS_BINS);
pLibDev->tx[activeQueues[i]].haveStats = 0;
}
// cleanup descriptors created by the last begin
if (pLibDev->rx.rxEnable || pLibDev->rx.bufferAddress) {
memFree(devNum, pLibDev->rx.bufferAddress);
pLibDev->rx.bufferAddress = 0;
memFree(devNum, pLibDev->rx.descAddress);
pLibDev->rx.descAddress = 0;
pLibDev->rx.rxEnable = 0;
pLibDev->rx.numDesc = 0;
pLibDev->rx.bufferSize = 0;
}
// Add a local self-linked rx descriptor and buffer to stop receive overrun
pLibDev->rx.descAddress = memAlloc( devNum, sizeof(MDK_ATHEROS_DESC));
if (0 == pLibDev->rx.descAddress) {
mError(devNum, ENOMEM, "Device Number %d:txDataStart: unable to allocate memory for rx-descriptor to prevent overrun\n", devNum);
return;
}
pLibDev->rx.bufferSize = 512;
pLibDev->rx.bufferAddress = memAlloc(devNum, pLibDev->rx.bufferSize);
if (0 == pLibDev->rx.bufferAddress) {
mError(devNum, ENOMEM, "Device Number %d:txDataStart: unable to allocate memory for rx-buffer to prevent overrun\n", devNum);
return;
}
localDesc.bufferPhysPtr = pLibDev->rx.bufferAddress;
localDesc.nextPhysPtr = pLibDev->rx.descAddress;
localDesc.hwControl[1] = pLibDev->rx.bufferSize;
localDesc.hwControl[0] = 0;
writeDescriptor(devNum, pLibDev->rx.descAddress, &localDesc);
//write RXDP
ar5kInitData[pLibDev->ar5kInitIndex].pMacAPI->writeRxDescriptor(devNum, pLibDev->rx.descAddress);
//program registers
ar5kInitData[pLibDev->ar5kInitIndex].pMacAPI->txBeginConfig(devNum, 1);
pLibDev->start=milliTime();
} // txDataStart
MANLIB_API void txDataComplete
(
A_UINT32 devNum,
A_UINT32 timeout,
A_UINT32 remoteStats
)
{
LIB_DEV_INFO *pLibDev = gLibInfo.pLibDevArray[devNum];
ISR_EVENT event;
A_UINT32 finish;
A_UINT32 i = 0;
A_UINT32 statsLoop = 0;
static A_UINT32 deltaTimeArray[MAX_TX_QUEUE] = {0}; // array to store the delta time
static A_UINT16 activeQueues[MAX_TX_QUEUE] = {0}; // Index of the active queue
A_UINT16 activeQueueCount = 0; // active queues count
A_UINT16 wfqCount = 0; // wait for queues count
A_UINT32 startTime;
A_UINT32 curTime;
for( i = 0; i < MAX_TX_QUEUE; i++ )
{
if ( pLibDev->tx[i].txEnable )
{
activeQueues[activeQueueCount] = (A_UINT16)i;
activeQueueCount++;
}
}
wfqCount = activeQueueCount;
startTime = milliTime();
//wait for event
for (i = 0; i < timeout && wfqCount; i++)
{
event = pLibDev->devMap.getISREvent(devNum);
if (event.valid)
{
//see if it is the TX_EOL interrupt
if ( ar5kInitData[pLibDev->ar5kInitIndex].pMacAPI->isTxdescEvent(event.ISRValue)
/*event.ISRValue & F2_ISR_TXDESC*/) {
//This is the event we are waiting for
//stop the clock
finish=milliTime();
// __TODO__
// THE "EVENT" WILL HAVE THE INFO. ABOUT THE QUEUE INDEX
// SO WE COULD STORE THE TIME DELTA AND PROCESS THE
// STATS AFTER WE GET ALL THE EOL OR TIMESOUT (i.e. AFTER
// WE GET OUT OF THIS LOOP
//
// deltaTimeArray[event.queueIndex] = finish - start;
//
{
// DWORD dwReg1 = REGR( devNum, 0x00c4 );
// DWORD dwReg2 = REGR( devNum, 0x00c8 );
// DWORD dwReg3 = REGR( devNum, 0x00cc );
// DWORD dwReg4 = REGR( devNum, 0x00d0 );
// DWORD dwReg5 = REGR( devNum, 0x00d4 );
// DWORD dwQ = dwReg1 >> 16;
}
deltaTimeArray[pLibDev->selQueueIndex] = finish - pLibDev->start; // __TODO__ GET THE CORRECT INDEX
//get the stats
//txAccumulateStats(devNum, finish - start); // MOVED OUT OF THIS LOOP
wfqCount--;
if ( !wfqCount )
{
break;
}
continue; // skip the sleep; we got an interrupt, maybe there is more in the event queue
}
}
curTime = milliTime();
if (curTime > (startTime+timeout)) {
i = timeout;
break;
}
mSleep(1);
}
if (i == timeout)
{
mError(devNum, EIO, "Device Number %d:txDataComplete: timeout reached before all frames transmitted\n", devNum);
finish=milliTime();
//return;
}
// Get the stats for all active queues and send end packets
//
for( i = 0; i < activeQueueCount; i++ )
{
txAccumulateStats(devNum, deltaTimeArray[activeQueues[i]], activeQueues[i] );
//successful transmission of frames, so send special end packet
// ar5kInitData[pLibDev->ar5kInitIndex].pMacAPI->sendTxEndPacket(devNum, activeQueues[i] );
sendEndPacket(devNum, activeQueues[i]);
}
//send stats packets if enabled
if(remoteStats == ENABLE_STATS_SEND) {
// send the stats for all the active queues
for( i = 0; i < activeQueueCount; i++ )
{
for(statsLoop = 1; statsLoop < STATS_BINS; statsLoop++)
{
if((pLibDev->tx[activeQueues[i]].txStats[statsLoop].excessiveRetries > 0) ||
(pLibDev->tx[activeQueues[i]].txStats[statsLoop].goodPackets > 0)) {
sendStatsPkt(devNum, statsLoop, MDK_TX_STATS_PKT, pLibDev->tx[activeQueues[i]].destAddr.octets);
}
}
sendStatsPkt(devNum, 0, MDK_TX_STATS_PKT, pLibDev->tx[activeQueues[i]].destAddr.octets);
}
}
//cleanup
ar5kInitData[pLibDev->ar5kInitIndex].pMacAPI->txCleanupConfig(devNum);
// __TODO__
// WRITE TO EACH DCU FOR MAUI, WILL CALL THE FNPTR HERE
//
//write back the retry value
//REGW(devNum, F2_RETRY_LMT, pLibDev->tx[queueIndex].retryValue);
//setRetryLimitAr5210( devNum, 0 ); // 5210
//gMdataFnTable[pLibDev->ar5kInitIndex].setRetryLimit( devNum, 0 );
ar5kInitData[pLibDev->ar5kInitIndex].pMacAPI->setRetryLimit( devNum, 0 );
return;
}
////
////
////
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
/**************************************************************************
* rxDataSetup - create packet and descriptors for reception
*
*/
MANLIB_API void rxDataSetup
(
A_UINT32 devNum,
A_UINT32 numDesc,
A_UINT32 dataBodyLength,
A_UINT32 enablePPM
)
{
internalRxDataSetup(devNum, numDesc, dataBodyLength, enablePPM, RX_NORMAL);
return;
}
MANLIB_API void rxDataSetupFixedNumber
(
A_UINT32 devNum,
A_UINT32 numDesc,
A_UINT32 dataBodyLength,
A_UINT32 enablePPM
)
{
internalRxDataSetup(devNum, numDesc, dataBodyLength, enablePPM, RX_FIXED_NUMBER);
return;
}
void internalRxDataSetup
(
A_UINT32 devNum,
A_UINT32 numDesc,
A_UINT32 dataBodyLength,
A_UINT32 enablePPM,
A_UINT32 mode
)
{
A_UINT32 i;
A_UINT32 bufferAddress;
A_UINT32 descAddress;
MDK_ATHEROS_DESC localDesc;
A_UINT32 sizeBufferMem;
LIB_DEV_INFO *pLibDev = gLibInfo.pLibDevArray[devNum];
if (checkDevNum(devNum) == FALSE) {
mError(devNum, EINVAL, "Device Number %d:rxDataSetup\n", devNum);
return;
}
if(pLibDev->devState < RESET_STATE) {
mError(devNum, EILSEQ, "Device Number %d:rxDataSetup: device not in reset state - resetDevice must be run first\n", devNum);
return;
}
if((pLibDev->mode == MODE_11B) && (enablePPM)) {
//not supported for 11b mode.
enablePPM = 0;
}
// cleanup descriptors created last time
if (pLibDev->rx.rxEnable || pLibDev->rx.bufferAddress) {
memFree(devNum, pLibDev->rx.bufferAddress);
pLibDev->rx.bufferAddress = 0;
memFree(devNum, pLibDev->rx.descAddress);
pLibDev->rx.descAddress = 0;
pLibDev->rx.rxEnable = 0;
}
pLibDev->rx.overlappingDesc = FALSE;
pLibDev->rx.numDesc = numDesc + 11;
pLibDev->rx.numExpectedPackets = numDesc;
pLibDev->rx.rxMode = mode;
/*
* create descriptors, create eleven extra descriptors and buffers:
* - one to receive the special "last packet"
* - up to 9 to receive the stats packet (incase this is enabled)
* - one linked to itself to prevent overruns
*/
pLibDev->rx.descAddress = memAlloc( devNum, pLibDev->rx.numDesc * sizeof(MDK_ATHEROS_DESC));
if (0 == pLibDev->rx.descAddress) {
mError(devNum, ENOMEM, "Device Number %d:rxDataSetup: unable to allocate memory for descriptors\n", devNum);
return;
}
// If getting the PPM data - increase the data body length before upsizing for stats
if(enablePPM) {
dataBodyLength += PPM_DATA_SIZE;
}
//create buffers
//make sure dataBody length is large enough to take a stats packet, if not then
//pad it out. The 8 accounts for the rateBin labels at the front of the packets
if (dataBodyLength < (sizeof(TX_STATS_STRUCT) + sizeof(RX_STATS_STRUCT) + 8)) {
dataBodyLength = sizeof(TX_STATS_STRUCT) + sizeof(RX_STATS_STRUCT) + 8;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -