?? mdata.c
字號(hào):
pLibDev->devMap.r_createDescriptors(devNum, (pLibDev->tx[queueIndex].descAddress + \
(dIndex * sizeof(MDK_ATHEROS_DESC))), \
lastDesc | numDescPerRate | \
(sizeof(MDK_ATHEROS_DESC)/sizeof(A_UINT32) << DESC_INFO_NUM_DESC_WORDS_BIT_START), \
0, \
descOp, \
(A_UINT32 *)localDescPtr);
dIndex = i+1;
}
}
else {
j++;
}
}
//increment descriptor address
descAddress += sizeof(MDK_ATHEROS_DESC);
localDescPtr ++;
}
//write all the descriptors in one shot
if (!pLibDev->devMap.remoteLib || !(rateMask & RATE_GROUP)) {
writeDescriptors(devNum, pLibDev->tx[queueIndex].descAddress, localDescBuffer, pLibDev->tx[queueIndex].numDesc);
#ifdef DEBUG_MEMORY
printf("SNOOP::Desc contents are\n");
memDisplay(devNum, pLibDev->tx[queueIndex].descAddress, 16);
#endif
}
free(localDescBuffer);
#ifdef DEBUG_MEMORY
printf("SNOOP::createEndPacket to \n");
printf("SNOOP::dest %x:%x:%x:%x:%x:%x\n", dest[6], dest[5], dest[4], dest[3], dest[2], dest[1], dest[0]);
#endif
//create the end packet
createEndPacket(devNum, queueIndex, dest, antMode, probePkt);
// Set broadcast for Begin
if(broadcast) {
pLibDev->tx[queueIndex].broadcast = 1;
}
else {
pLibDev->tx[queueIndex].broadcast = 0;
}
pLibDev->tx[queueIndex].txEnable = 1;
ar5kInitData[pLibDev->ar5kInitIndex].pMacAPI->setRetryLimit( devNum, queueIndex );
#ifdef _TIME_PROFILE
txDataSetup_end=milliTime();
printf(".................SNOOP::exit txDataSetup:Time taken = %dms\n", (txDataSetup_end-txDataSetup_start));
#endif
return;
}
MANLIB_API void cleanupTxRxMemory
(
A_UINT32 devNum,
A_UINT32 flags
)
{
LIB_DEV_INFO *pLibDev = gLibInfo.pLibDevArray[devNum];
A_UINT16 queueIndex;
pLibDev->selQueueIndex = 0;
pLibDev->tx[0].dcuIndex = 0;
queueIndex = pLibDev->selQueueIndex;
if(flags & TX_CLEAN) {
if (pLibDev->tx[queueIndex].pktAddress) {
memFree(devNum, pLibDev->tx[queueIndex].pktAddress);
pLibDev->tx[queueIndex].pktAddress = 0;
memFree(devNum, pLibDev->tx[queueIndex].descAddress);
pLibDev->tx[queueIndex].descAddress = 0;
pLibDev->tx[queueIndex].txEnable = 0;
}
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;
}
if(pLibDev->tx[PROBE_QUEUE].pktAddress) {
memFree(devNum, pLibDev->tx[PROBE_QUEUE].pktAddress);
pLibDev->tx[PROBE_QUEUE].pktAddress = 0;
memFree(devNum, pLibDev->tx[PROBE_QUEUE].descAddress);
pLibDev->tx[PROBE_QUEUE].descAddress = 0;
pLibDev->tx[PROBE_QUEUE].txEnable = 0;
}
}
if(flags & RX_CLEAN) {
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;
}
}
}
void
createEndPacket
(
A_UINT32 devNum,
A_UINT16 queueIndex,
A_UCHAR *dest,
A_UINT32 antMode,
A_BOOL probePkt
)
{
LIB_DEV_INFO *pLibDev = gLibInfo.pLibDevArray[devNum];
A_UINT32 pktSize;
MDK_ATHEROS_DESC localDesc;
A_UINT32 retryValue;
A_UINT16 endPktType = MDK_LAST_PKT;
if (pLibDev->noEndPacket) {
return;
}
pLibDev->tx[queueIndex].endPktDesc =
memAlloc( devNum, 1 * sizeof(MDK_ATHEROS_DESC));
if(probePkt) {
endPktType = MDK_PROBE_LAST_PKT;
}
// this is the special end descriptor
createTransmitPacket(devNum, endPktType, dest, 1, 0, NULL, 0, 0,
queueIndex, &pktSize, &(pLibDev->tx[queueIndex].endPktAddr));
//write buffer ptr to descriptor
#if defined(COBRA_AP) && defined(PCI_INTERFACE)
if(isCobra(pLibDev->swDevID)) {
localDesc.bufferPhysPtr = pLibDev->tx[queueIndex].endPktAddr;
}
else {
localDesc.bufferPhysPtr = pLibDev->tx[queueIndex].endPktAddr | HOST_PCI_SDRAM_BASEADDR;
}
#else
localDesc.bufferPhysPtr = pLibDev->tx[queueIndex].endPktAddr;
#endif
//Venice needs to have the retries set for end packets
//so take a copy and artificially set it
retryValue = pLibDev->tx[queueIndex].retryValue;
if(probePkt) {
pLibDev->tx[queueIndex].retryValue = 0;
}
else {
pLibDev->tx[queueIndex].retryValue = 0xf;
}
if (pLibDev->libCfgParams.enableXR) {
if (isFalcon(devNum) || isDragon(devNum)) {
setDescriptorEndPacketAr5513( devNum, &localDesc, pktSize,
antMode, 0, rateValues[15], 0);
} else {
setDescriptorEndPacketAr5212( devNum, &localDesc, pktSize,
antMode, 0, rateValues[15], 0);
}
}
else if (((pLibDev->swDevID & 0x00ff) >= 0x0013) && (pLibDev->mode == MODE_11G) && (!pLibDev->turbo)) {
if (isFalcon(devNum) || isDragon(devNum)) {
setDescriptorEndPacketAr5513( devNum, &localDesc, pktSize,
antMode, 0, rateValues[8], 0);
} else {
setDescriptorEndPacketAr5212( devNum, &localDesc, pktSize,
antMode, 0, rateValues[8], 0);
}
} else {
ar5kInitData[pLibDev->ar5kInitIndex].pMacAPI->setDescriptor( devNum, &localDesc, pktSize,
antMode, 0, rateValues[0], 0);
}
//restore the retry value
pLibDev->tx[queueIndex].retryValue = retryValue;
localDesc.nextPhysPtr = 0;
writeDescriptor(devNum, pLibDev->tx[queueIndex].endPktDesc, &localDesc);
}
void
sendEndPacket
(
A_UINT32 devNum,
A_UINT16 queueIndex
)
{
LIB_DEV_INFO *pLibDev = gLibInfo.pLibDevArray[devNum];
if (pLibDev->noEndPacket) {
return;
}
#ifdef DEBUG_MEMORY
printf("SNOOP:sendEndPacket::start Send end packet\n");
#endif
//successful transmission of frames, so send special end packet
ar5kInitData[pLibDev->ar5kInitIndex].pMacAPI->sendTxEndPacket(devNum, queueIndex );
//cleanup end packet memory allocation
// 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;
//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++;
}
}
}
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;
}
// 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;
}
#if defined(COBRA_AP) && defined(PCI_INTERFACE)
if(isCobra(pLibDev->swDevID)) {
localDesc.bufferPhysPtr = pLibDev->rx.bufferAddress;
localDesc.nextPhysPtr = pLibDev->rx.descAddress;
}
else {
localDesc.bufferPhysPtr = pLibDev->rx.bufferAddress | HOST_PCI_SDRAM_BASEADDR;
localDesc.nextPhysPtr = pLibDev->rx.descAddress | HOST_PCI_SDRAM_BASEADDR;
}
#else
localDesc.bufferPhysPtr = pLibDev->rx.bufferAddress;
localDesc.nextPhysPtr = pLibDev->rx.descAddress;
#endif
localDesc.hwControl[1] = pLibDev->rx.bufferSize;
localDesc.hwControl[0] = 0;
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -