📄 mdata.c
字号:
writeDescriptor(devNum, pLibDev->rx.descAddress, &localDesc);
//write RXDP
#if defined(COBRA_AP) && defined(PCI_INTERFACE)
if(isCobra(pLibDev->swDevID)) {
ar5kInitData[pLibDev->ar5kInitIndex].pMacAPI->writeRxDescriptor(devNum, pLibDev->rx.descAddress);
}
else {
ar5kInitData[pLibDev->ar5kInitIndex].pMacAPI->writeRxDescriptor(devNum, pLibDev->rx.descAddress | HOST_PCI_SDRAM_BASEADDR);
}
#else
ar5kInitData[pLibDev->ar5kInitIndex].pMacAPI->writeRxDescriptor(devNum, pLibDev->rx.descAddress);
#endif
//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;
//if we are sending probe packets, then only enable the probe queue
if((pLibDev->txProbePacketNext) && (pLibDev->tx[PROBE_QUEUE].txEnable)) {
activeQueues[activeQueueCount] = (A_UINT16)PROBE_QUEUE;
activeQueueCount++;
}
else {
for( i = 0; i < MAX_TX_QUEUE; i++ )
{
if ( pLibDev->tx[i].txEnable )
{
activeQueues[activeQueueCount] = (A_UINT16)i;
activeQueueCount++;
}
}
}
wfqCount = activeQueueCount;
startTime = milliTime();
#ifdef DEBUG_MEMORY
printf("SNOOP::txDataComplete::TXDP=%x:TXE=%x\n", REGR(devNum, 0x800), REGR(devNum, 0x840));
printf("SNOOP::txDataComplete::Memory at TXDP %x location is \n", REGR(devNum, 0x800));
memDisplay(devNum, REGR(devNum, 0x800), 12);
printf("SNOOP::txDataComplete::Frame contents at %x pointed location is \n", REGR(devNum, 0x800));
pLibDev->devMap.OSmemRead(devNum, REGR(devNum, 0x800)+4, (A_UCHAR*)&buf_ptr, sizeof(buf_ptr));
memDisplay(devNum, buf_ptr, 10);
printf("SNOOP::txDataComplete::Memory at baseaddress %x location is \n", pLibDev->tx[0].descAddress);
memDisplay(devNum, pLibDev->tx[0].descAddress, 12);
printf("SNOOP::txDataComplete::Frame contents at %x pointed location is \n", pLibDev->tx[0].descAddress);
pLibDev->devMap.OSmemRead(devNum, (pLibDev->tx[0].descAddress+4), (A_UCHAR*)&buf_ptr, sizeof(buf_ptr));
memDisplay(devNum, buf_ptr, 10);
printf("reg8000=%x:reg8004=%x:reg8008=%x:reg800c=%x:reg8014=%x\n", REGR(devNum, 0x8000), REGR(devNum, 0x8004), REGR(devNum, 0x8008), REGR(devNum, 0x800c), REGR(devNum, 0x8014));
#endif
//wait for event
for (i = 0; i < timeout && wfqCount; i++)
{
event = pLibDev->devMap.getISREvent(devNum);
if (event.valid)
{
#ifdef DEBUG_MEMORY
printf("SNOOP::txDataComplete::Got event\n");
#endif
//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++ )
{
if( !(remoteStats & SKIP_STATS_COLLECTION)) {
txAccumulateStats(devNum, deltaTimeArray[activeQueues[i]], activeQueues[i] );
}
//successful transmission of frames, so send special end packet
//ar5kInitData[pLibDev->ar5kInitIndex].pMacAPI->sendTxEndPacket(devNum, activeQueues[i] );
if(!pLibDev->txProbePacketNext) {
sendEndPacket(devNum, activeQueues[i]);
}
}
//send stats packets if enabled
if((remoteStats == ENABLE_STATS_SEND) && (!pLibDev->txProbePacketNext)){
#ifdef DEBUG_MEMORY
printf("SNOOP::txDataComplete::enable stats send\n");
#endif
// 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);
// reset "noEndPacket" flag
pLibDev->noEndPacket = FALSE;
// __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 );
if(pLibDev->txProbePacketNext) {
//clear probe packet next flag for next time.
pLibDev->txProbePacketNext = 0;
pLibDev->tx[PROBE_QUEUE].txEnable = 0;
pLibDev->selQueueIndex = pLibDev->backupSelectQueueIndex;
}
return;
}
////
////
////
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
/**************************************************************************
* rxDataSetup - create packet and descriptors for reception
*
*/
MANLIB_API void rxDataSetup
(
A_UINT32 devNum,
A_UINT32 numDesc,
A_UINT32 dataBodyLength,
A_UINT32 enablePPM
)
{
#ifdef _TIME_PROFILE
A_UINT32 rxDataSetup_start, rxDataSetup_end;
rxDataSetup_start=milliTime();
#endif
internalRxDataSetup(devNum, numDesc, dataBodyLength, enablePPM, RX_NORMAL);
#ifdef _TIME_PROFILE
rxDataSetup_end=milliTime();
printf(".................SNOOP::exit rxDataSetup:Time taken = %dms\n", (rxDataSetup_end-rxDataSetup_start));
#endif
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 buffAddrIncrement=0, lastDesc;
A_UINT32 descAddress;
MDK_ATHEROS_DESC *localDescPtr; //pointer to current descriptor being filled
MDK_ATHEROS_DESC *localDescBuffer; //create a local buffer to create descriptors
A_UINT32 sizeBufferMem, intrBit, descOp;
A_UINT32 falconAddrMod = 0;
A_BOOL falconTrue = FALSE;
A_UINT32 ppm_data_padding = PPM_DATA_SIZE;
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;
}
falconTrue = isFalcon(devNum) || isDragon(devNum);
if (falconTrue) {
if (pLibDev->libCfgParams.chainSelect == 2) {
ppm_data_padding = PPM_DATA_SIZE_FALCON_DUAL_CHAIN;
} else {
ppm_data_padding = PPM_DATA_SIZE_FALCON_SINGLE_CHAIN;
}
}
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 %d descriptors\n", devNum, pLibDev->rx.numDesc);
return;
}
// If getting the PPM data - increase the data body length before upsizing for stats
if(enablePPM) {
dataBodyLength += ppm_data_padding;
}
//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;
}
pLibDev->rx.bufferSize = dataBodyLength + sizeof(MDK_PACKET_HEADER)
+ sizeof(WLAN_DATA_MAC_HEADER3) + FCS_FIELD;
/* The above calculation makes the receive buffer the exact size. Want to
* add some extra bytes to end and also make sure buffers and 32 byte aligned.
* will have at least 0x20 spare bytes
*/
if ((pLibDev->rx.bufferSize & (cache_line_size - 1)) > 0) {
pLibDev->rx.bufferSize += (0x20 - (pLibDev->rx.bufferSize & (cache_line_size - 1)));
}
if ((pLibDev->rx.bufferSize + 0x20) < 4096) {
pLibDev->rx.bufferSize += 0x20;
}
sizeBufferMem = pLibDev->rx.numDesc * pLibDev->rx.bufferSize;
//check to see if should try overlapping buffers
if(sizeBufferMem > pLibDev->devMap.DEV_MEMORY_RANGE) {
//allocate 1 full buffer (as spare) then add headers + 32 bytes for each required descriptor
sizeBufferMem = pLibDev->rx.bufferSize +
(pLibDev->rx.numDesc * (sizeof(MDK_PACKET_HEADER) + sizeof(WLAN_DATA_MAC_HEADER3) + 0x22
+ (enablePPM ? ppm_data_padding : 0) ));
if(sizeBufferMem > pLibDev->devMap.DEV_MEMORY_RANGE) {
mError(devNum, ENOMEM, "Device Number %d:rxDataSetup: unable to allocate memory for buffers (even overlapped):%d\n", devNum, sizeBufferMem);
return;
}
pLibDev->rx.overlappingDesc = TRUE;
}
pLibDev->rx.bufferAddress = memAlloc(devNum, sizeBufferMem);
if (0 == pLibDev->rx.bufferAddress) {
mError(devNum, ENOMEM, "Device Number %d:rxDataSetup: unable to allocate memory for buffers:%d\n", devNum, sizeBufferMem);
return;
}
//initialize descriptors
#if defined(COBRA_AP) && defined(PCI_INTERFACE)
if(isCobra(pLibDev->swDevID)) {
descAddress = pLibDev->rx.descAddress;
bufferAddress = pLibDev->rx.bufferAddress;
if (falconTrue) {
falconAddrMod = FALCON_MEM_ADDR_MASK ;
}
else {
descAddress = pLibDev->rx.descAddress | HOST_PCI_SDRAM_BASEADDR;
bufferAddress = pLibDev->rx.bufferAddress | HOST_PCI_SDRAM_BASEADDR;
}
#else
descAddress = pLibDev->rx.descAddress;
bufferAddress = pLibDev->rx.bufferAddress;
#endif
localDescBuffer = (MDK_ATHEROS_DESC *)malloc(sizeof(MDK_ATHEROS_DESC) * pLibDev->rx.numDesc);
if(localDescBuffer == NULL) {
mError(devNum, ENOMEM, "Device Number %d:txDataSetup: unable to allocate local memory for descriptors\n", devNum);
return;
}
localDescPtr = localDescBuffer;
for (i = 0; i < pLibDev->rx.numDesc; i++)
{
localDescPtr->bufferPhysPtr = falconAddrMod | bufferAddress;
//update the link pointer
if (i == pLibDev->rx.numDesc - 1) { //ie its the last descriptor
//link it to itself
localDescPtr->nextPhysPtr = falconAddrMod | descAddress;
pLibDev->rx.lastDescAddress = descAddress;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -