INT Set_P2P_Reset_Proc( IN PRTMP_ADAPTER pAd, IN PSTRING arg) { /*UINT32 DiscPerd = 0;*/ POS_COOKIE pObj; PRT_P2P_CONFIG pP2PCtrl = &pAd->P2pCfg; pObj = (POS_COOKIE) pAd->OS_Cookie; if (pObj->ioctl_if_type != INT_P2P) return 0; if (P2P_CLI_ON(pAd)) P2P_CliStop(pAd); else if (P2P_GO_ON(pAd)) { P2P_GoStop(pAd); if (INFRA_ON(pAd)) AsicEnableBssSync(pAd); } P2PCfgInit(pAd); P2pGroupTabInit(pAd); pP2PCtrl->Rule = P2P_IS_DEVICE; pAd->flg_p2p_OpStatusFlags = P2P_DISABLE; pP2PCtrl->ConfigMethod = 0x188; pAd->ApCfg.MBSSID[MAIN_MBSSID].WscControl.WscConfStatus = WSC_SCSTATE_UNCONFIGURED; pP2PCtrl->GoFormCurrentState = P2P_GO_FORM_IDLE; pP2PCtrl->DiscCurrentState = P2P_DISC_IDLE; pP2PCtrl->CtrlCurrentState = P2P_CTRL_IDLE; NdisZeroMemory(&pP2PCtrl->P2pCounter, sizeof(P2P_COUNTER_STRUCT)); pP2PCtrl->P2PConnectState = P2P_CONNECT_IDLE; return TRUE; }
INT Set_P2P_Reset_Proc( IN PRTMP_ADAPTER pAd, IN PSTRING arg) { /*UINT32 DiscPerd = 0;*/ POS_COOKIE pObj; PRT_P2P_CONFIG pP2PCtrl = &pAd->P2pCfg; pObj = (POS_COOKIE) pAd->OS_Cookie; if (pObj->ioctl_if_type != INT_P2P) return 0; if (P2P_CLI_ON(pAd)) P2P_CliStop(pAd); else if (P2P_GO_ON(pAd)) { P2P_GoStop(pAd); if (INFRA_ON(pAd)) AsicEnableBssSync(pAd); } P2PCfgInit(pAd); P2pGroupTabInit(pAd); pP2PCtrl->Rule = P2P_IS_DEVICE; pAd->flg_p2p_OpStatusFlags = P2P_DISABLE; pP2PCtrl->ConfigMethod = 0x188; pAd->ApCfg.MBSSID[MAIN_MBSSID].WscControl.WscConfStatus = WSC_SCSTATE_UNCONFIGURED; pP2PCtrl->GoFormCurrentState = P2P_GO_FORM_IDLE; pP2PCtrl->DiscCurrentState = P2P_DISC_IDLE; pP2PCtrl->CtrlCurrentState = P2P_CTRL_IDLE; NdisZeroMemory(&pP2PCtrl->P2pCounter, sizeof(P2P_COUNTER_STRUCT)); P2pSetListenIntBias(pAd, 3); RTMPZeroMemory(pAd->P2pCfg.SSID, MAX_LEN_OF_SSID); RTMPMoveMemory(pAd->P2pCfg.SSID, WILDP2PSSID, WILDP2PSSIDLEN); pP2PCtrl->SSIDLen = WILDP2PSSIDLEN; /* Set Dpid to "not specified". it means, GUI doesn't set for connection yet. */ pP2PCtrl->Dpid = DEV_PASS_ID_NOSPEC; RTMPZeroMemory(pAd->P2pCfg.ConnectingMAC, MAC_ADDR_LEN); return TRUE; }
VOID RTUSBBulkOutDataPacket( IN PRTMP_ADAPTER pAd, IN UCHAR BulkOutPipeId, IN UCHAR Index) { PHT_TX_CONTEXT pHTTXContext; PURB pUrb; int ret = 0; TXINFO_STRUC *pTxInfo, *pLastTxInfo = NULL; TXWI_STRUC *pTxWI; ULONG TmpBulkEndPos, ThisBulkSize; unsigned long IrqFlags = 0, IrqFlags2 = 0; PUCHAR pWirelessPkt, pAppendant; #ifdef USB_BULK_BUF_ALIGMENT BOOLEAN bLasAlignmentsectiontRound = FALSE; #else BOOLEAN bTxQLastRound = FALSE; UCHAR allzero[4]= {0x0,0x0,0x0,0x0}; #endif /* USB_BULK_BUF_ALIGMENT */ BULK_OUT_LOCK(&pAd->BulkOutLock[BulkOutPipeId], IrqFlags); if ((pAd->BulkOutPending[BulkOutPipeId] == TRUE) || RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NEED_STOP_TX) #ifdef PBF_MONITOR_SUPPORT || OPSTATUS_TEST_FLAG(pAd, fRTMP_ADAPTER_DISABLE_DATA_BULK_OUT) #endif /* PBF_MONITOR_SUPPORT */ ) { BULK_OUT_UNLOCK(&pAd->BulkOutLock[BulkOutPipeId], IrqFlags); return; } pAd->BulkOutPending[BulkOutPipeId] = TRUE; if (((!OPSTATUS_TEST_FLAG(pAd, fOP_AP_STATUS_MEDIA_STATE_CONNECTED)) && ( !OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED))) #ifdef P2P_SUPPORT && !(P2P_GO_ON(pAd) || P2P_CLI_ON(pAd)) #endif /* P2P_SUPPORT */ #ifdef RT_CFG80211_SUPPORT && !(RTMP_CFG80211_VIF_P2P_GO_ON(pAd) || RTMP_CFG80211_VIF_P2P_CLI_ON(pAd)) #endif ) { pAd->BulkOutPending[BulkOutPipeId] = FALSE; BULK_OUT_UNLOCK(&pAd->BulkOutLock[BulkOutPipeId], IrqFlags); return; } BULK_OUT_UNLOCK(&pAd->BulkOutLock[BulkOutPipeId], IrqFlags); pHTTXContext = &(pAd->TxContext[BulkOutPipeId]); BULK_OUT_LOCK(&pAd->TxContextQueueLock[BulkOutPipeId], IrqFlags2); #ifdef USB_BULK_BUF_ALIGMENT if ( (pHTTXContext->NextBulkIdx != pHTTXContext->CurtBulkIdx) || ((pHTTXContext->CurWriteRealPos > pHTTXContext->CurWritePosition) &&(pHTTXContext->NextBulkIdx == pHTTXContext->CurWriteIdx)) || ((pHTTXContext->CurWriteRealPos == 0) && (pHTTXContext->NextBulkIdx == pHTTXContext->CurWriteIdx)) ) #else if ((pHTTXContext->ENextBulkOutPosition == pHTTXContext->CurWritePosition) || ((pHTTXContext->ENextBulkOutPosition-8) == pHTTXContext->CurWritePosition)) #endif /* USB_BULK_BUF_ALIGMENT */ /* druing writing. */ { BULK_OUT_UNLOCK(&pAd->TxContextQueueLock[BulkOutPipeId], IrqFlags2); BULK_OUT_LOCK(&pAd->BulkOutLock[BulkOutPipeId], IrqFlags); pAd->BulkOutPending[BulkOutPipeId] = FALSE; /* Clear Data flag*/ RTUSB_CLEAR_BULK_FLAG(pAd, (fRTUSB_BULK_OUT_DATA_FRAG << BulkOutPipeId)); RTUSB_CLEAR_BULK_FLAG(pAd, (fRTUSB_BULK_OUT_DATA_NORMAL << BulkOutPipeId)); BULK_OUT_UNLOCK(&pAd->BulkOutLock[BulkOutPipeId], IrqFlags); return; } /* Clear Data flag*/ RTUSB_CLEAR_BULK_FLAG(pAd, (fRTUSB_BULK_OUT_DATA_FRAG << BulkOutPipeId)); RTUSB_CLEAR_BULK_FLAG(pAd, (fRTUSB_BULK_OUT_DATA_NORMAL << BulkOutPipeId)); /*DBGPRINT(RT_DEBUG_TRACE,("BulkOut-B:I=0x%lx, CWPos=%ld, CWRPos=%ld, NBPos=%ld, ENBPos=%ld, bCopy=%d!\n", in_interrupt(), */ /* pHTTXContext->CurWritePosition, pHTTXContext->CurWriteRealPos, pHTTXContext->NextBulkOutPosition, */ /* pHTTXContext->ENextBulkOutPosition, pHTTXContext->bCopySavePad));*/ pHTTXContext->NextBulkOutPosition = pHTTXContext->ENextBulkOutPosition; ThisBulkSize = 0; TmpBulkEndPos = pHTTXContext->NextBulkOutPosition; #ifdef USB_BULK_BUF_ALIGMENT INT idx; idx = pHTTXContext->NextBulkIdx; pWirelessPkt = &pHTTXContext->TransferBuffer[idx]->field.WirelessPacket[0]; #else pWirelessPkt = &pHTTXContext->TransferBuffer->field.WirelessPacket[0]; #endif /* USB_BULK_BUF_ALIGMENT */ #ifndef USB_BULK_BUF_ALIGMENT if ((pHTTXContext->bCopySavePad == TRUE)) { if (RTMPEqualMemory(pHTTXContext->SavedPad, allzero,4)) { DBGPRINT_RAW(RT_DEBUG_ERROR,("e1, allzero : %x %x %x %x %x %x %x %x \n", pHTTXContext->SavedPad[0], pHTTXContext->SavedPad[1], pHTTXContext->SavedPad[2],pHTTXContext->SavedPad[3] ,pHTTXContext->SavedPad[4], pHTTXContext->SavedPad[5], pHTTXContext->SavedPad[6],pHTTXContext->SavedPad[7])); } NdisMoveMemory(&pWirelessPkt[TmpBulkEndPos], pHTTXContext->SavedPad, 8); pHTTXContext->bCopySavePad = FALSE; if (pAd->bForcePrintTX == TRUE) DBGPRINT(RT_DEBUG_TRACE,("RTUSBBulkOutDataPacket --> COPY PAD. CurWrite = %ld, NextBulk = %ld. ENextBulk = %ld.\n", pHTTXContext->CurWritePosition, pHTTXContext->NextBulkOutPosition, pHTTXContext->ENextBulkOutPosition)); } #endif /* USB_BULK_BUF_ALIGMENT */ do { pTxInfo = (TXINFO_STRUC *)&pWirelessPkt[TmpBulkEndPos]; pTxWI = (TXWI_STRUC *)&pWirelessPkt[TmpBulkEndPos + TXINFO_SIZE]; if (pAd->bForcePrintTX == TRUE) DBGPRINT(RT_DEBUG_TRACE, ("RTUSBBulkOutDataPacket AMPDU = %d.\n", pTxWI->TxWIAMPDU)); /* add by Iverson, limit BulkOut size to 4k to pass WMM b mode 2T1R test items*/ /*if ((ThisBulkSize != 0) && (pTxWI->AMPDU == 0))*/ if ((ThisBulkSize != 0) && (pTxWI->TxWIPHYMODE == MODE_CCK)) { #ifdef INF_AMAZON_SE /*Iverson Add for AMAZON USB (RT2070 && RT3070) to pass WMM A2-T4 ~ A2-T10*/ if(OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_WMM_INUSED)) { /*Iverson patch for WMM A5-T07 ,WirelessStaToWirelessSta do not bulk out aggregate*/ if(pTxWI->PacketId == 6) { pHTTXContext->ENextBulkOutPosition = TmpBulkEndPos; break; } else if (((ThisBulkSize&0xffff8000) != 0) || ((ThisBulkSize&pAd->BulkOutDataSizeLimit[BulkOutPipeId]) == pAd->BulkOutDataSizeLimit[BulkOutPipeId])) { /*printk("===Bulkout size limit :%d ===\n",MaxBulkOutSize);*/ /*DBGPRINT(RT_DEBUG_TRACE,("b mode BulkOutPipeId %d pAd->BulkOutDataSizeLimit[BulkOutPipeId] %d \n",BulkOutPipeId,pAd->BulkOutDataSizeLimit[BulkOutPipeId]));*/ pHTTXContext->ENextBulkOutPosition = TmpBulkEndPos; break; } } else if (((ThisBulkSize&0xffff8000) != 0) || ((ThisBulkSize&0x1000) == 0x1000)) { /* Limit BulkOut size to about 4k bytes.*/ pHTTXContext->ENextBulkOutPosition = TmpBulkEndPos; break; } #endif /* INF_AMAZON_SE */ #ifndef INF_AMAZON_SE #ifndef USB_BULK_BUF_ALIGMENT if (((ThisBulkSize&0xffff8000) != 0) || ((ThisBulkSize&0x1000) == 0x1000)) { /* Limit BulkOut size to about 4k bytes.*/ pHTTXContext->ENextBulkOutPosition = TmpBulkEndPos; break; } #else if (((ThisBulkSize&0xffff8000) != 0) || ((ThisBulkSize&BULKOUT_SIZE) == BULKOUT_SIZE)) { /* Limit BulkOut size to about 24k bytes.*/ pHTTXContext->ENextBulkOutPosition = TmpBulkEndPos; /* when bulk size is > 6000, it mean that this is the lasttround at this alignmnet section. */ bLasAlignmentsectiontRound = TRUE; break; } #endif /* USB_BULK_BUF_ALIGMENT */ #endif /* INF_AMAZON_SE */ #ifndef USB_BULK_BUF_ALIGMENT else if (((pAd->BulkOutMaxPacketSize < 512) && ((ThisBulkSize&0xfffff800) != 0) ) /*|| ( (ThisBulkSize != 0) && (pTxWI->AMPDU == 0))*/) { /* For USB 1.1 or peer which didn't support AMPDU, limit the BulkOut size. */ /* For performence in b/g mode, now just check for USB 1.1 and didn't care about the APMDU or not! 2008/06/04.*/ pHTTXContext->ENextBulkOutPosition = TmpBulkEndPos; break; } #else else if (((pAd->BulkOutMaxPacketSize < 512) && (((ThisBulkSize&0xffff8000) != 0) || ((ThisBulkSize&BULKOUT_SIZE) == BULKOUT_SIZE)) )) { /* Limit BulkOut size to about 24k bytes.*/ pHTTXContext->ENextBulkOutPosition = TmpBulkEndPos; /* when bulk size is > 6000, it mean that this is the lasttround at this alignmnet section. */ bLasAlignmentsectiontRound = TRUE; break; } #endif /* USB_BULK_BUF_ALIGMENT */ } /* end Iverson*/ else { #ifdef USB_BULK_BUF_ALIGMENT if (((ThisBulkSize&0xffff8000) != 0) || ((ThisBulkSize&BULKOUT_SIZE) == BULKOUT_SIZE)) #else #ifdef PBF_MONITOR_SUPPORT if (((ThisBulkSize&0xffff8000) != 0) || ((ThisBulkSize&0x1000) == 0x1000)) #else if (((ThisBulkSize&0xffff8000) != 0) || ((ThisBulkSize&0x6000) == 0x6000)) #endif /* PBF_MONITOR_SUPPORT */ #endif /* USB_BULK_BUF_ALIGMENT */ { /* Limit BulkOut size to about 24k bytes.*/ pHTTXContext->ENextBulkOutPosition = TmpBulkEndPos; #ifdef USB_BULK_BUF_ALIGMENT /* when bulk size is > 0x6000, it mean that this is the lasttround at this alignmnet section. */ bLasAlignmentsectiontRound = TRUE; /* printk("data bulk out bLasAlignmentsectiontRound \n");*/ #endif /* USB_BULK_BUF_ALIGMENT */ break; } #ifdef INF_AMAZON_SE else if (((ThisBulkSize&0xffff8000) != 0) || ((ThisBulkSize&pAd->BulkOutDataSizeLimit[BulkOutPipeId]) == pAd->BulkOutDataSizeLimit[BulkOutPipeId])) { /*printk("===Bulkout size limit :%d ===\n",ThisBulkSize);*/ pHTTXContext->ENextBulkOutPosition = TmpBulkEndPos; break; } #endif /* INF_AMAZON_SE */ #ifndef USB_BULK_BUF_ALIGMENT else if (((pAd->BulkOutMaxPacketSize < 512) && ((ThisBulkSize&0xfffff800) != 0) ) /*|| ( (ThisBulkSize != 0) && (pTxWI->AMPDU == 0))*/) { /* For USB 1.1 or peer which didn't support AMPDU, limit the BulkOut size. */ /* For performence in b/g mode, now just check for USB 1.1 and didn't care about the APMDU or not! 2008/06/04.*/ pHTTXContext->ENextBulkOutPosition = TmpBulkEndPos; break; } #else else if (((pAd->BulkOutMaxPacketSize < 512) && (((ThisBulkSize&0xffff8000) != 0) || ((ThisBulkSize&BULKOUT_SIZE) == BULKOUT_SIZE)) )) { /* Limit BulkOut size to about 24k bytes.*/ pHTTXContext->ENextBulkOutPosition = TmpBulkEndPos; /* when bulk size is > 6000, it mean that this is the lasttround at this alignmnet section. */ bLasAlignmentsectiontRound = TRUE; break; } #endif /* USB_BULK_BUF_ALIGMENT */ } #ifdef USB_BULK_BUF_ALIGMENT if ((TmpBulkEndPos == pHTTXContext->CurWritePosition) && (pHTTXContext->NextBulkIdx == pHTTXContext->CurWriteIdx)) #else if (TmpBulkEndPos == pHTTXContext->CurWritePosition) #endif /* USB_BULK_BUF_ALIGMENT */ { pHTTXContext->ENextBulkOutPosition = TmpBulkEndPos; break; } if (pTxInfo->TxInfoQSEL != FIFO_EDCA) { DBGPRINT(RT_DEBUG_ERROR, ("%s(): ====> pTxInfo->QueueSel(%d)!= FIFO_EDCA!!!!\n", __FUNCTION__, pTxInfo->TxInfoQSEL)); DBGPRINT(RT_DEBUG_ERROR, ("\tCWPos=%ld, NBPos=%ld, ENBPos=%ld, bCopy=%d!\n", pHTTXContext->CurWritePosition, pHTTXContext->NextBulkOutPosition, pHTTXContext->ENextBulkOutPosition, pHTTXContext->bCopySavePad)); hex_dump("Wrong QSel Pkt:", (PUCHAR)&pWirelessPkt[TmpBulkEndPos], (pHTTXContext->CurWritePosition - pHTTXContext->NextBulkOutPosition)); } if (pTxInfo->TxInfoPktLen <= 8) { BULK_OUT_UNLOCK(&pAd->TxContextQueueLock[BulkOutPipeId], IrqFlags2); DBGPRINT(RT_DEBUG_ERROR /*RT_DEBUG_TRACE*/,("e2, TxInfoPktLen==0, Size=%ld, bCSPad=%d, CWPos=%ld, NBPos=%ld, CWRPos=%ld!\n", pHTTXContext->BulkOutSize, pHTTXContext->bCopySavePad, pHTTXContext->CurWritePosition, pHTTXContext->NextBulkOutPosition, pHTTXContext->CurWriteRealPos)); { DBGPRINT_RAW(RT_DEBUG_ERROR /*RT_DEBUG_TRACE*/,("%x %x %x %x %x %x %x %x \n", pHTTXContext->SavedPad[0], pHTTXContext->SavedPad[1], pHTTXContext->SavedPad[2],pHTTXContext->SavedPad[3] ,pHTTXContext->SavedPad[4], pHTTXContext->SavedPad[5], pHTTXContext->SavedPad[6],pHTTXContext->SavedPad[7])); } pAd->bForcePrintTX = TRUE; BULK_OUT_LOCK(&pAd->BulkOutLock[BulkOutPipeId], IrqFlags); pAd->BulkOutPending[BulkOutPipeId] = FALSE; BULK_OUT_UNLOCK(&pAd->BulkOutLock[BulkOutPipeId], IrqFlags); /*DBGPRINT(RT_DEBUG_LOUD,("Out:pTxInfo->TxInfoPktLen=%d!\n", pTxInfo->TxInfoPktLen));*/ return; } /* Increase Total transmit byte counter*/ pAd->RalinkCounters.OneSecTransmittedByteCount += pTxWI->TxWIMPDUByteCnt; pAd->RalinkCounters.TransmittedByteCount += pTxWI->TxWIMPDUByteCnt; pLastTxInfo = pTxInfo; /* Make sure we use EDCA QUEUE. */ pTxInfo->TxInfoQSEL = FIFO_EDCA; ThisBulkSize += (pTxInfo->TxInfoPktLen+4); TmpBulkEndPos += (pTxInfo->TxInfoPktLen+4); if (TmpBulkEndPos != pHTTXContext->CurWritePosition) pTxInfo->TxInfoUDMANextVld = 1; #ifdef USB_BULK_BUF_ALIGMENT /* this is for frag packet , because it will finish this section when ((((pHTTXContext->CurWritePosition + 3906)& 0x00007fff) & 0xffff6000) == 0x00006000) */ if (pTxInfo->TxInfoSwLstRnd == 1) { bLasAlignmentsectiontRound = TRUE; #ifdef RT_BIG_ENDIAN RTMPDescriptorEndianChange((PUCHAR)pTxInfo, TYPE_TXINFO); RTMPWIEndianChange(pAd, (PUCHAR)pTxWI, TYPE_TXWI); #endif /* RT_BIG_ENDIAN */ break; } #else if (pTxInfo->TxInfoSwLstRnd == 1) { if (pHTTXContext->CurWritePosition == 8) pTxInfo->TxInfoUDMANextVld = 0; pTxInfo->TxInfoSwLstRnd = 0; bTxQLastRound = TRUE; pHTTXContext->ENextBulkOutPosition = 8; #ifdef RT_BIG_ENDIAN RTMPDescriptorEndianChange((PUCHAR)pTxInfo, TYPE_TXINFO); RTMPWIEndianChange(pAd, (PUCHAR)pTxWI, TYPE_TXWI); #endif /* RT_BIG_ENDIAN */ break; } #endif /* USB_BULK_BUF_ALIGMENT */ #ifdef RT_BIG_ENDIAN RTMPDescriptorEndianChange((PUCHAR)pTxInfo, TYPE_TXINFO); RTMPWIEndianChange(pAd, (PUCHAR)pTxWI, TYPE_TXWI); #endif /* RT_BIG_ENDIAN */ }while (TRUE); /* adjust the pTxInfo->TxInfoUDMANextVld value of last pTxInfo.*/ if (pLastTxInfo) { #ifdef RT_BIG_ENDIAN RTMPDescriptorEndianChange((PUCHAR)pLastTxInfo, TYPE_TXINFO); #endif /* RT_BIG_ENDIAN */ pLastTxInfo->TxInfoUDMANextVld = 0; #ifdef RT_BIG_ENDIAN RTMPDescriptorEndianChange((PUCHAR)pLastTxInfo, TYPE_TXINFO); #endif /* RT_BIG_ENDIAN */ } /* We need to copy SavedPad when following condition matched! 1. Not the last round of the TxQueue and 2. any match of following cases: (1). The End Position of this bulk out is reach to the Currenct Write position and the TxInfo and related header already write to the CurWritePosition. =>(ENextBulkOutPosition == CurWritePosition) && (CurWriteRealPos > CurWritePosition) (2). The EndPosition of the bulk out is not reach to the Current Write Position. =>(ENextBulkOutPosition != CurWritePosition) */ #ifndef USB_BULK_BUF_ALIGMENT if ((bTxQLastRound == FALSE) && (((pHTTXContext->ENextBulkOutPosition == pHTTXContext->CurWritePosition) && (pHTTXContext->CurWriteRealPos > pHTTXContext->CurWritePosition)) || (pHTTXContext->ENextBulkOutPosition != pHTTXContext->CurWritePosition)) ) { NdisMoveMemory(pHTTXContext->SavedPad, &pWirelessPkt[pHTTXContext->ENextBulkOutPosition], 8); pHTTXContext->bCopySavePad = TRUE; if (RTMPEqualMemory(pHTTXContext->SavedPad, allzero,4)) { PUCHAR pBuf = &pHTTXContext->SavedPad[0]; DBGPRINT_RAW(RT_DEBUG_ERROR,("WARNING-Zero-3:%02x%02x%02x%02x%02x%02x%02x%02x,CWPos=%ld, CWRPos=%ld, bCW=%d, NBPos=%ld, TBPos=%ld, TBSize=%ld\n", pBuf[0], pBuf[1], pBuf[2],pBuf[3],pBuf[4], pBuf[5], pBuf[6],pBuf[7], pHTTXContext->CurWritePosition, pHTTXContext->CurWriteRealPos, pHTTXContext->bCurWriting, pHTTXContext->NextBulkOutPosition, TmpBulkEndPos, ThisBulkSize)); pBuf = &pWirelessPkt[pHTTXContext->CurWritePosition]; DBGPRINT_RAW(RT_DEBUG_ERROR,("\tCWPos=%02x%02x%02x%02x%02x%02x%02x%02x\n", pBuf[0], pBuf[1], pBuf[2],pBuf[3],pBuf[4], pBuf[5], pBuf[6],pBuf[7])); } /*DBGPRINT(RT_DEBUG_LOUD,("ENPos==CWPos=%ld, CWRPos=%ld, bCSPad=%d!\n", pHTTXContext->CurWritePosition, pHTTXContext->CurWriteRealPos, pHTTXContext->bCopySavePad));*/ } #endif /* USB_BULK_BUF_ALIGMENT */ if (pAd->bForcePrintTX == TRUE) DBGPRINT(RT_DEBUG_TRACE,("BulkOut-A:Size=%ld, CWPos=%ld, NBPos=%ld, ENBPos=%ld, bCopy=%d!\n", ThisBulkSize, pHTTXContext->CurWritePosition, pHTTXContext->NextBulkOutPosition, pHTTXContext->ENextBulkOutPosition, pHTTXContext->bCopySavePad)); /*DBGPRINT(RT_DEBUG_LOUD,("BulkOut-A:Size=%ld, CWPos=%ld, CWRPos=%ld, NBPos=%ld, ENBPos=%ld, bCopy=%d, bLRound=%d!\n", ThisBulkSize, pHTTXContext->CurWritePosition, pHTTXContext->CurWriteRealPos, pHTTXContext->NextBulkOutPosition, pHTTXContext->ENextBulkOutPosition, pHTTXContext->bCopySavePad, bTxQLastRound));*/ /* USB DMA engine requires to pad extra 4 bytes. This pad doesn't count into real bulkoutsize.*/ pAppendant = &pWirelessPkt[TmpBulkEndPos]; NdisZeroMemory(pAppendant, 8); ThisBulkSize += 4; pHTTXContext->LastOne = TRUE; pHTTXContext->BulkOutSize = ThisBulkSize; #ifdef USB_BULK_BUF_ALIGMENT /* if it is the last alignment section round,that we just need to add nextbulkindex, otherwise we both need to add nextbulkindex and CurWriteIdx (because when alignment section round happened, the CurWriteIdx is added at function writing resource.) */ if(bLasAlignmentsectiontRound == TRUE) { CUR_WRITE_IDX_INC(pHTTXContext->NextBulkIdx, BUF_ALIGMENT_RINGSIZE); pHTTXContext->ENextBulkOutPosition = 0; } else { CUR_WRITE_IDX_INC(pHTTXContext->NextBulkIdx, BUF_ALIGMENT_RINGSIZE); pHTTXContext->ENextBulkOutPosition = 0; CUR_WRITE_IDX_INC(pHTTXContext->CurWriteIdx, BUF_ALIGMENT_RINGSIZE); pHTTXContext->CurWritePosition = 0; } #endif /* USB_BULK_BUF_ALIGMENT */ pAd->watchDogTxPendingCnt[BulkOutPipeId] = 1; BULK_OUT_UNLOCK(&pAd->TxContextQueueLock[BulkOutPipeId], IrqFlags2); /* Init Tx context descriptor*/ RTUSBInitHTTxDesc(pAd, pHTTXContext, BulkOutPipeId, ThisBulkSize, (usb_complete_t)RtmpUsbBulkOutDataPacketComplete); #ifdef USB_BULK_BUF_ALIGMENT pUrb = pHTTXContext->pUrb[pHTTXContext->CurtBulkIdx]; #else pUrb = pHTTXContext->pUrb; #endif /* USB_BULK_BUF_ALIGMENT */ if((ret = RTUSB_SUBMIT_URB(pUrb))!=0) { DBGPRINT(RT_DEBUG_ERROR, ("RTUSBBulkOutDataPacket: Submit Tx URB failed %d\n", ret)); BULK_OUT_LOCK(&pAd->BulkOutLock[BulkOutPipeId], IrqFlags); pAd->BulkOutPending[BulkOutPipeId] = FALSE; pAd->watchDogTxPendingCnt[BulkOutPipeId] = 0; BULK_OUT_UNLOCK(&pAd->BulkOutLock[BulkOutPipeId], IrqFlags); return; } BULK_OUT_LOCK(&pAd->BulkOutLock[BulkOutPipeId], IrqFlags); pHTTXContext->IRPPending = TRUE; BULK_OUT_UNLOCK(&pAd->BulkOutLock[BulkOutPipeId], IrqFlags); pAd->BulkOutReq++; }
/* ======================================================================== Routine Description: Arguments: Return Value: Note: ======================================================================== */ VOID RTUSBKickBulkOut( IN PRTMP_ADAPTER pAd) { /* BulkIn Reset will reset whole USB PHY. So we need to make sure fRTMP_ADAPTER_BULKIN_RESET not flaged.*/ if (!RTMP_TEST_FLAG(pAd ,fRTMP_ADAPTER_NEED_STOP_TX) #ifdef RALINK_ATE && !(ATE_ON(pAd)) #endif /* RALINK_ATE */ ) { /* 2. PS-Poll frame is next*/ if (RTUSB_TEST_BULK_FLAG(pAd, fRTUSB_BULK_OUT_PSPOLL)) { RTUSBBulkOutPsPoll(pAd); } /* 5. Mlme frame is next*/ else if ((RTUSB_TEST_BULK_FLAG(pAd, fRTUSB_BULK_OUT_MLME)) || (pAd->MgmtRing.TxSwFreeIdx < MGMT_RING_SIZE)) { RTUSBBulkOutMLMEPacket(pAd, pAd->MgmtRing.TxDmaIdx); } /* 6. Data frame normal is next*/ if (RTUSB_TEST_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_NORMAL)) { if (((!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)) || (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED)) #ifdef P2P_SUPPORT || P2P_GO_ON(pAd) || P2P_CLI_ON(pAd) #endif /* P2P_SUPPORT */ #ifdef RT_CFG80211_SUPPORT || RTMP_CFG80211_VIF_P2P_GO_ON(pAd) || RTMP_CFG80211_VIF_P2P_CLI_ON(pAd) #endif )) { RTUSBBulkOutDataPacket(pAd, EDCA_AC0_PIPE, pAd->NextBulkOutIndex[EDCA_AC0_PIPE]); } } if (RTUSB_TEST_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_NORMAL_2)) { if (((!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)) || (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED)) #ifdef P2P_SUPPORT || P2P_GO_ON(pAd) || P2P_CLI_ON(pAd) #endif /* P2P_SUPPORT */ #ifdef RT_CFG80211_SUPPORT || RTMP_CFG80211_VIF_P2P_GO_ON(pAd) || RTMP_CFG80211_VIF_P2P_CLI_ON(pAd) #endif )) { RTUSBBulkOutDataPacket(pAd, EDCA_AC1_PIPE, pAd->NextBulkOutIndex[EDCA_AC1_PIPE]); } } if (RTUSB_TEST_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_NORMAL_3)) { if (((!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)) || (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED)) #ifdef P2P_SUPPORT || P2P_GO_ON(pAd) || P2P_CLI_ON(pAd) #endif /* P2P_SUPPORT */ #ifdef RT_CFG80211_SUPPORT || RTMP_CFG80211_VIF_P2P_GO_ON(pAd) || RTMP_CFG80211_VIF_P2P_CLI_ON(pAd) #endif )) { RTUSBBulkOutDataPacket(pAd, EDCA_AC2_PIPE, pAd->NextBulkOutIndex[EDCA_AC2_PIPE]); } } if (RTUSB_TEST_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_NORMAL_4)) { if (((!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)) || (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED)) )) { RTUSBBulkOutDataPacket(pAd, EDCA_AC3_PIPE, pAd->NextBulkOutIndex[EDCA_AC3_PIPE]); } } /* 7. Null frame is the last*/ else if (RTUSB_TEST_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_NULL)) { if (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)) { RTUSBBulkOutNullFrame(pAd); } else { DBGPRINT(RT_DEBUG_ERROR, ("%s - Fail in BSS_SCAN_IN_PROGRESS\n", __FUNCTION__)); } } /* 8. No data avaliable*/ else { } } #ifdef RALINK_ATE else if((ATE_ON(pAd)) && !RTMP_TEST_FLAG(pAd , fRTMP_ADAPTER_NEED_STOP_TX)) { if (RTUSB_TEST_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_ATE)) { ATE_RTUSBBulkOutDataPacket(pAd, EDCA_AC0_PIPE); } } #endif /* RALINK_ATE */ }
/* ======================================================================== Routine Description: Caller ensures we has 802.11n support. Calls at setting HT from AP/STASetinformation Arguments: pAd - Pointer to our adapter phymode - ======================================================================== */ VOID RTMPSetHT( IN RTMP_ADAPTER *pAd, IN OID_SET_HT_PHYMODE *pHTPhyMode) { UCHAR RxStream = pAd->CommonCfg.RxStream; #ifdef CONFIG_AP_SUPPORT INT apidx; #endif /* CONFIG_AP_SUPPORT */ INT bw; RT_HT_CAPABILITY *rt_ht_cap = &pAd->CommonCfg.DesiredHtPhy; HT_CAPABILITY_IE *ht_cap= &pAd->CommonCfg.HtCapability; #ifdef CONFIG_AP_SUPPORT /* sanity check for extention channel */ if (CHAN_PropertyCheck(pAd, pAd->CommonCfg.Channel, CHANNEL_NO_FAT_BELOW | CHANNEL_NO_FAT_ABOVE) == TRUE) { /* only 20MHz is allowed */ pHTPhyMode->BW = 0; } else if (pHTPhyMode->ExtOffset == EXTCHA_BELOW) { /* extension channel below this channel is not allowed */ if (CHAN_PropertyCheck(pAd, pAd->CommonCfg.Channel, CHANNEL_NO_FAT_BELOW) == TRUE) { pHTPhyMode->ExtOffset = EXTCHA_ABOVE; } } else if (pHTPhyMode->ExtOffset == EXTCHA_ABOVE) { /* extension channel above this channel is not allowed */ if (CHAN_PropertyCheck(pAd, pAd->CommonCfg.Channel, CHANNEL_NO_FAT_ABOVE) == TRUE) { pHTPhyMode->ExtOffset = EXTCHA_BELOW; } } #endif /* CONFIG_AP_SUPPORT */ DBGPRINT(RT_DEBUG_TRACE, ("RTMPSetHT : HT_mode(%d), ExtOffset(%d), MCS(%d), BW(%d), STBC(%d), SHORTGI(%d)\n", pHTPhyMode->HtMode, pHTPhyMode->ExtOffset, pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->SHORTGI)); /* Don't zero supportedHyPhy structure.*/ RTMPZeroMemory(ht_cap, sizeof(HT_CAPABILITY_IE)); RTMPZeroMemory(&pAd->CommonCfg.AddHTInfo, sizeof(pAd->CommonCfg.AddHTInfo)); RTMPZeroMemory(&pAd->CommonCfg.NewExtChanOffset, sizeof(pAd->CommonCfg.NewExtChanOffset)); RTMPZeroMemory(rt_ht_cap, sizeof(RT_HT_CAPABILITY)); if (pAd->CommonCfg.bRdg) { ht_cap->ExtHtCapInfo.PlusHTC = 1; ht_cap->ExtHtCapInfo.RDGSupport = 1; } else { ht_cap->ExtHtCapInfo.PlusHTC = 0; ht_cap->ExtHtCapInfo.RDGSupport = 0; } if (RxStream == 1) { ht_cap->HtCapParm.MaxRAmpduFactor = 2; rt_ht_cap->MaxRAmpduFactor = 2; } else { ht_cap->HtCapParm.MaxRAmpduFactor = 3; rt_ht_cap->MaxRAmpduFactor = 3; } DBGPRINT(RT_DEBUG_TRACE, ("RTMPSetHT : RxBAWinLimit = %d\n", pAd->CommonCfg.BACapability.field.RxBAWinLimit)); /* Mimo power save, A-MSDU size, */ rt_ht_cap->AmsduEnable = (USHORT)pAd->CommonCfg.BACapability.field.AmsduEnable; rt_ht_cap->AmsduSize = (UCHAR)pAd->CommonCfg.BACapability.field.AmsduSize; rt_ht_cap->MimoPs = (UCHAR)pAd->CommonCfg.BACapability.field.MMPSmode; rt_ht_cap->MpduDensity = (UCHAR)pAd->CommonCfg.BACapability.field.MpduDensity; ht_cap->HtCapInfo.AMsduSize = (USHORT)pAd->CommonCfg.BACapability.field.AmsduSize; ht_cap->HtCapInfo.MimoPs = (USHORT)pAd->CommonCfg.BACapability.field.MMPSmode; ht_cap->HtCapParm.MpduDensity = (UCHAR)pAd->CommonCfg.BACapability.field.MpduDensity; DBGPRINT(RT_DEBUG_TRACE, ("RTMPSetHT : AMsduSize = %d, MimoPs = %d, MpduDensity = %d, MaxRAmpduFactor = %d\n", rt_ht_cap->AmsduSize, rt_ht_cap->MimoPs, rt_ht_cap->MpduDensity, rt_ht_cap->MaxRAmpduFactor)); if(pHTPhyMode->HtMode == HTMODE_GF) { ht_cap->HtCapInfo.GF = 1; rt_ht_cap->GF = 1; } else rt_ht_cap->GF = 0; /* Decide Rx MCSSet*/ switch (RxStream) { case 3: ht_cap->MCSSet[2] = 0xff; case 2: ht_cap->MCSSet[1] = 0xff; case 1: default: ht_cap->MCSSet[0] = 0xff; break; } if (pAd->CommonCfg.bForty_Mhz_Intolerant && (pHTPhyMode->BW == BW_40)) { pHTPhyMode->BW = BW_20; ht_cap->HtCapInfo.Forty_Mhz_Intolerant = 1; } // TODO: shiang-6590, how about the "bw" when channel 14 for JP region??? bw = BW_20; if(pHTPhyMode->BW == BW_40) { ht_cap->MCSSet[4] = 0x1; /* MCS 32*/ ht_cap->HtCapInfo.ChannelWidth = 1; if (pAd->CommonCfg.Channel <= 14) ht_cap->HtCapInfo.CCKmodein40 = 1; rt_ht_cap->ChannelWidth = 1; pAd->CommonCfg.AddHTInfo.AddHtInfo.RecomWidth = 1; pAd->CommonCfg.AddHTInfo.AddHtInfo.ExtChanOffset = (pHTPhyMode->ExtOffset == EXTCHA_BELOW)? (EXTCHA_BELOW): EXTCHA_ABOVE; /* Set Regsiter for extension channel position.*/ rtmp_mac_set_ctrlch(pAd, pHTPhyMode->ExtOffset); /* Turn on BBP 40MHz mode now only as AP . */ /* Sta can turn on BBP 40MHz after connection with 40MHz AP. Sta only broadcast 40MHz capability before connection.*/ if ((pAd->OpMode == OPMODE_AP) || INFRA_ON(pAd) || ADHOC_ON(pAd) #ifdef P2P_SUPPORT || P2P_GO_ON(pAd) #endif /* P2P_SUPPORT */ ) { rtmp_bbp_set_ctrlch(pAd, pHTPhyMode->ExtOffset); #ifdef GREENAP_SUPPORT if (pAd->ApCfg.bGreenAPActive == 1) bw = BW_20; else #endif /* GREENAP_SUPPORT */ bw = BW_40; } } else { ht_cap->HtCapInfo.ChannelWidth = 0; rt_ht_cap->ChannelWidth = 0; pAd->CommonCfg.AddHTInfo.AddHtInfo.RecomWidth = 0; pAd->CommonCfg.AddHTInfo.AddHtInfo.ExtChanOffset = EXTCHA_NONE; pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel; /* Turn on BBP 20MHz mode by request here.*/ bw = BW_20; } #ifdef DOT11_VHT_AC if (pHTPhyMode->BW == BW_40 && pAd->CommonCfg.vht_bw == VHT_BW_80 && pAd->CommonCfg.vht_cent_ch) bw = BW_80; #endif /* DOT11_VHT_AC */ rtmp_bbp_set_bw(pAd, bw); if(pHTPhyMode->STBC == STBC_USE) { if (pAd->Antenna.field.TxPath >= 2) { ht_cap->HtCapInfo.TxSTBC = 1; rt_ht_cap->TxSTBC = 1; } else { ht_cap->HtCapInfo.TxSTBC = 0; rt_ht_cap->TxSTBC = 0; } /* RxSTBC 0: not support, 1: support for 1SS 2: support for 1SS, 2SS 3: support for 1SS, 2SS, 3SS */ if (pAd->Antenna.field.RxPath >= 1) { ht_cap->HtCapInfo.RxSTBC = 1; rt_ht_cap->RxSTBC = 1; } else { ht_cap->HtCapInfo.RxSTBC = 0; rt_ht_cap->RxSTBC = 0; } } else { rt_ht_cap->TxSTBC = 0; rt_ht_cap->RxSTBC = 0; } if(pHTPhyMode->SHORTGI == GI_400) { ht_cap->HtCapInfo.ShortGIfor20 = 1; ht_cap->HtCapInfo.ShortGIfor40 = 1; rt_ht_cap->ShortGIfor20 = 1; rt_ht_cap->ShortGIfor40 = 1; } else { ht_cap->HtCapInfo.ShortGIfor20 = 0; ht_cap->HtCapInfo.ShortGIfor40 = 0; rt_ht_cap->ShortGIfor20 = 0; rt_ht_cap->ShortGIfor40 = 0; } /* We support link adaptation for unsolicit MCS feedback, set to 2.*/ pAd->CommonCfg.AddHTInfo.ControlChan = pAd->CommonCfg.Channel; /* 1, the extension channel above the control channel. */ /* EDCA parameters used for AP's own transmission*/ if (pAd->CommonCfg.APEdcaParm.bValid == FALSE) { pAd->CommonCfg.APEdcaParm.bValid = TRUE; pAd->CommonCfg.APEdcaParm.Aifsn[0] = 3; pAd->CommonCfg.APEdcaParm.Aifsn[1] = 7; pAd->CommonCfg.APEdcaParm.Aifsn[2] = 1; pAd->CommonCfg.APEdcaParm.Aifsn[3] = 1; pAd->CommonCfg.APEdcaParm.Cwmin[0] = 4; pAd->CommonCfg.APEdcaParm.Cwmin[1] = 4; pAd->CommonCfg.APEdcaParm.Cwmin[2] = 3; pAd->CommonCfg.APEdcaParm.Cwmin[3] = 2; pAd->CommonCfg.APEdcaParm.Cwmax[0] = 6; pAd->CommonCfg.APEdcaParm.Cwmax[1] = 10; pAd->CommonCfg.APEdcaParm.Cwmax[2] = 4; pAd->CommonCfg.APEdcaParm.Cwmax[3] = 3; pAd->CommonCfg.APEdcaParm.Txop[0] = 0; pAd->CommonCfg.APEdcaParm.Txop[1] = 0; pAd->CommonCfg.APEdcaParm.Txop[2] = 94; pAd->CommonCfg.APEdcaParm.Txop[3] = 47; } AsicSetEdcaParm(pAd, &pAd->CommonCfg.APEdcaParm); #ifdef TXBF_SUPPORT if (pAd->chipCap.FlgHwTxBfCap) { /* Set ETxBF */ setETxBFCap(pAd, &ht_cap->TxBFCap); /* Check ITxBF */ pAd->CommonCfg.RegTransmitSetting.field.ITxBfEn &= rtmp_chk_itxbf_calibration(pAd); /* Apply to ASIC */ rtmp_asic_set_bf(pAd); } #endif /* TXBF_SUPPORT */ #ifdef CONFIG_AP_SUPPORT IF_DEV_CONFIG_OPMODE_ON_AP(pAd) { for (apidx = 0; apidx < pAd->ApCfg.BssidNum; apidx++) RTMPSetIndividualHT(pAd, apidx); #ifdef APCLI_SUPPORT for (apidx = 0; apidx < MAX_APCLI_NUM; apidx++) RTMPSetIndividualHT(pAd, apidx + MIN_NET_DEVICE_FOR_APCLI); #endif /* APCLI_SUPPORT */ } #endif /* CONFIG_AP_SUPPORT */ #ifdef CONFIG_STA_SUPPORT IF_DEV_CONFIG_OPMODE_ON_STA(pAd) { #ifdef P2P_SUPPORT for (apidx = 0; apidx < pAd->ApCfg.BssidNum; apidx++) RTMPSetIndividualHT(pAd, apidx + MIN_NET_DEVICE_FOR_P2P_GO); for (apidx = 0; apidx < MAX_APCLI_NUM; apidx++) RTMPSetIndividualHT(pAd, apidx + MIN_NET_DEVICE_FOR_APCLI); #endif /* P2P_SUPPORT */ RTMPSetIndividualHT(pAd, 0); } #endif /* CONFIG_STA_SUPPORT */ }
/* ======================================================================== Routine Description: Arguments: Return Value: Note: ======================================================================== */ VOID RTUSBKickBulkOut( IN PRTMP_ADAPTER pAd) { /* BulkIn Reset will reset whole USB PHY. So we need to make sure fRTMP_ADAPTER_BULKIN_RESET not flaged.*/ if (!RTMP_TEST_FLAG(pAd ,fRTMP_ADAPTER_NEED_STOP_TX) #ifdef RALINK_ATE && !(ATE_ON(pAd)) #endif /* RALINK_ATE */ ) { /* 2. PS-Poll frame is next*/ if (RTUSB_TEST_BULK_FLAG(pAd, fRTUSB_BULK_OUT_PSPOLL)) { RTUSBBulkOutPsPoll(pAd); } /* 5. Mlme frame is next*/ else if ((RTUSB_TEST_BULK_FLAG(pAd, fRTUSB_BULK_OUT_MLME)) || (pAd->MgmtRing.TxSwFreeIdx < MGMT_RING_SIZE)) { RTUSBBulkOutMLMEPacket(pAd, pAd->MgmtRing.TxDmaIdx); } /* 6. Data frame normal is next*/ if (RTUSB_TEST_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_NORMAL)) { if (((!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)) || (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED)) #ifdef P2P_SUPPORT || P2P_GO_ON(pAd) || P2P_CLI_ON(pAd) #endif /* P2P_SUPPORT */ )) { RTUSBBulkOutDataPacket(pAd, EDCA_AC0_PIPE, pAd->NextBulkOutIndex[EDCA_AC0_PIPE]); } } if (RTUSB_TEST_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_NORMAL_2)) { if (((!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)) || (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED)) #ifdef P2P_SUPPORT || P2P_GO_ON(pAd) || P2P_CLI_ON(pAd) #endif /* P2P_SUPPORT */ )) { RTUSBBulkOutDataPacket(pAd, EDCA_AC1_PIPE, pAd->NextBulkOutIndex[EDCA_AC1_PIPE]); } } if (RTUSB_TEST_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_NORMAL_3)) { if (((!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)) || (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED)) #ifdef P2P_SUPPORT || P2P_GO_ON(pAd) || P2P_CLI_ON(pAd) #endif /* P2P_SUPPORT */ )) { RTUSBBulkOutDataPacket(pAd, EDCA_AC2_PIPE, pAd->NextBulkOutIndex[EDCA_AC2_PIPE]); } } if (RTUSB_TEST_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_NORMAL_4)) { if (((!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)) || (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED)) )) { RTUSBBulkOutDataPacket(pAd, EDCA_AC3_PIPE, pAd->NextBulkOutIndex[EDCA_AC3_PIPE]); } } #ifdef CONFIG_MULTI_CHANNEL if (RTUSB_TEST_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_HCCA)) { if (((!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)) || (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED)) || P2P_GO_ON(pAd) || P2P_CLI_ON(pAd) )) { RTUSBBulkOutDataPacket(pAd, HCCA_PIPE, pAd->NextBulkOutIndex[HCCA_PIPE]); } } #endif /*CONFIG_MULTI_CHANNEL*/ /* 7. Null frame is the last*/ else if (RTUSB_TEST_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_NULL)) { #ifdef CONFIG_MULTI_CHANNEL if (INFRA_ON(pAd) && (pAd->CommonCfg.Channel == pAd->LatchRfRegs.Channel || pAd->CommonCfg.CentralChannel== pAd->LatchRfRegs.Channel )) #else if (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)) #endif /* CONFIG_MULTI_CHANNEL */ { RTUSBBulkOutNullFrame(pAd); } } #ifdef CONFIG_MULTI_CHANNEL else if (RTUSB_TEST_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_NULL_HCCA)) { if (INFRA_ON(pAd) && (pAd->CommonCfg.Channel == pAd->LatchRfRegs.Channel || pAd->CommonCfg.CentralChannel== pAd->LatchRfRegs.Channel )) RTUSBBulkOutNullFrame(pAd); } #endif /*CONFIG_MULTI_CHANNEL*/ /* 8. No data avaliable*/ else { } } #ifdef RALINK_ATE else if((ATE_ON(pAd)) && !RTMP_TEST_FLAG(pAd , fRTMP_ADAPTER_NEED_STOP_TX)) { if (RTUSB_TEST_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_ATE)) { ATE_RTUSBBulkOutDataPacket(pAd, EDCA_AC0_PIPE); } } #endif /* RALINK_ATE */ }
static VOID APPeerAuthReqAtIdleAction( IN PRTMP_ADAPTER pAd, IN MLME_QUEUE_ELEM *Elem) { INT i; USHORT Seq, Alg, RspReason, Status; UCHAR Addr1[MAC_ADDR_LEN] = {0}; UCHAR Addr2[MAC_ADDR_LEN] = {0}; CHAR Chtxt[CIPHER_TEXT_LEN]; UINT32 apidx; PHEADER_802_11 pRcvHdr; HEADER_802_11 AuthHdr; PUCHAR pOutBuffer = NULL; NDIS_STATUS NStatus; ULONG FrameLen = 0; MAC_TABLE_ENTRY *pEntry; UCHAR ChTxtIe = 16, ChTxtLen = CIPHER_TEXT_LEN; #ifdef BAND_STEERING BOOLEAN bAuthCheck = TRUE; #endif /* BAND_STEERING */ if (! APPeerAuthSanity(pAd, Elem->Msg, Elem->MsgLen, Addr1, Addr2, &Alg, &Seq, &Status, Chtxt)) { printk("APPeerAuthSanity: \nAddr1 is [%02x:%02x:%02x:%02x:%02x:%02x]" "Addr2 is [%02x:%02x:%02x:%02x:%02x:%02x]\n", PRINT_MAC(Addr1), PRINT_MAC(Addr2)); return; } #ifdef P2P_SUPPORT if (P2P_GO_ON(pAd) && (pAd->P2pCfg.bStopAuthRsp == TRUE)) { DBGPRINT(RT_DEBUG_TRACE, ("%s:: GO update not complete, stop Auth Rsp.\n", __FUNCTION__)); return; } #endif /* P2P_SUPPORT */ /* Find which MBSSID to be authenticate */ for (apidx=0; apidx<pAd->ApCfg.BssidNum; apidx++) { if (RTMPEqualMemory(Addr1, pAd->ApCfg.MBSSID[apidx].Bssid, MAC_ADDR_LEN)) break; } if (apidx >= pAd->ApCfg.BssidNum) { DBGPRINT(RT_DEBUG_TRACE, ("AUTH - Bssid not found\n")); return; } if ((pAd->ApCfg.MBSSID[apidx].MSSIDDev != NULL) && !(RTMP_OS_NETDEV_STATE_RUNNING(pAd->ApCfg.MBSSID[apidx].MSSIDDev))) { DBGPRINT(RT_DEBUG_TRACE, ("AUTH - Bssid IF didn't up yet.\n")); return; } /* End of if */ pEntry = MacTableLookup(pAd, Addr2); if (pEntry && IS_ENTRY_CLIENT(pEntry)) { if (!RTMPEqualMemory(Addr1, pAd->ApCfg.MBSSID[pEntry->apidx].Bssid, MAC_ADDR_LEN)) { MacTableDeleteEntry(pAd, pEntry->Aid, pEntry->Addr); pEntry = NULL; DBGPRINT(RT_DEBUG_WARN, ("AUTH - Bssid does not match\n")); } else { if (pEntry->bIAmBadAtheros == TRUE) { AsicUpdateProtect(pAd, 8, ALLN_SETPROTECT, FALSE, FALSE); DBGPRINT(RT_DEBUG_TRACE, ("Atheros Problem. Turn on RTS/CTS!!!\n")); pEntry->bIAmBadAtheros = FALSE; } #ifdef DOT11_N_SUPPORT BASessionTearDownALL(pAd, pEntry->Aid); #endif /* DOT11_N_SUPPORT */ ASSERT(pEntry->Aid == Elem->Wcid); } } pRcvHdr = (PHEADER_802_11)(Elem->Msg); DBGPRINT(RT_DEBUG_OFF, // liud debug ("AUTH - MBSS(%d), Rcv AUTH seq#%d, Alg=%d, Status=%d from " "[%02x:%02x:%02x:%02x:%02x:%02x] " "[wcid=%d]%02x:%02x:%02x:%02x:%02x:%02x\n", apidx, Seq, Alg, Status, Elem->Wcid, PRINT_MAC(Addr1), PRINT_MAC(Addr2))); #ifdef WSC_V2_SUPPORT /* Do not check ACL when WPS V2 is enabled and ACL policy is positive. */ if ((pAd->ApCfg.MBSSID[apidx].WscControl.WscConfMode != WSC_DISABLE) && (pAd->ApCfg.MBSSID[apidx].WscControl.WscV2Info.bEnableWpsV2) && (pAd->ApCfg.MBSSID[apidx].WscControl.WscV2Info.bWpsEnable) && (pAd->ApCfg.MBSSID[apidx].AccessControlList.Policy == 1)) ; else #endif /* WSC_V2_SUPPORT */ /* fail in ACL checking => send an AUTH-Fail seq#2. */ #if 0 // liudf comment the following code // no need to check; waste time if (! ApCheckAccessControlList(pAd, Addr2, apidx)){ ASSERT(Seq == 1); ASSERT(pEntry == NULL); APPeerAuthSimpleRspGenAndSend(pAd, pRcvHdr, Alg, Seq + 1, MLME_UNSPECIFY_FAIL); /* If this STA exists, delete it. */ if (pEntry) MacTableDeleteEntry(pAd, pEntry->Aid, pEntry->Addr); RTMPSendWirelessEvent(pAd, IW_MAC_FILTER_LIST_EVENT_FLAG, Addr2, apidx, 0); DBGPRINT(RT_DEBUG_TRACE, ("Failed in ACL checking => send an AUTH seq#2 with " "Status code = %d\n", MLME_UNSPECIFY_FAIL)); return; } #endif #ifdef BAND_STEERING BND_STRG_CHECK_CONNECTION_REQ( pAd, NULL, Addr2, Elem->MsgType, Elem->Rssi0, Elem->Rssi1, Elem->Rssi2, &bAuthCheck); if (bAuthCheck == FALSE) return; #endif /* BAND_STEERING */ if ((Alg == AUTH_MODE_OPEN) && (pAd->ApCfg.MBSSID[apidx].AuthMode != Ndis802_11AuthModeShared)) { if (!pEntry) pEntry = MacTableInsertEntry(pAd, Addr2, apidx, OPMODE_AP, TRUE); if (pEntry) { { pEntry->AuthState = AS_AUTH_OPEN; pEntry->Sst = SST_AUTH; /* what if it already in SST_ASSOC ??????? */ } APPeerAuthSimpleRspGenAndSend(pAd, pRcvHdr, Alg, Seq + 1, MLME_SUCCESS); #ifdef WAC_SUPPORT WAC_CheckWACEntry(pAd, pEntry); #endif /* WAC_SUPPORT */ } else ; /* MAC table full, what should we respond ????? */ } else if ((Alg == AUTH_MODE_KEY) && ((pAd->ApCfg.MBSSID[apidx].AuthMode == Ndis802_11AuthModeShared) || (pAd->ApCfg.MBSSID[apidx].AuthMode == Ndis802_11AuthModeAutoSwitch))) { if (!pEntry) pEntry = MacTableInsertEntry(pAd, Addr2, apidx, OPMODE_AP, TRUE); if (pEntry) { pEntry->AuthState = AS_AUTHENTICATING; pEntry->Sst = SST_NOT_AUTH; /* what if it already in SST_ASSOC ??????? */ /* log this STA in AuthRspAux machine, only one STA is stored. If two STAs using */ /* SHARED_KEY authentication mingled together, then the late comer will win. */ COPY_MAC_ADDR(&pAd->ApMlmeAux.Addr, Addr2); for(i=0; i<CIPHER_TEXT_LEN; i++) pAd->ApMlmeAux.Challenge[i] = RandomByte(pAd); RspReason = 0; Seq++; NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); if(NStatus != NDIS_STATUS_SUCCESS) return; /* if no memory, can't do anything */ DBGPRINT(RT_DEBUG_TRACE, ("AUTH - Send AUTH seq#2 (Challenge)\n")); MgtMacHeaderInit(pAd, &AuthHdr, SUBTYPE_AUTH, 0, Addr2, #ifdef P2P_SUPPORT pAd->ApCfg.MBSSID[apidx].Bssid, #endif /* P2P_SUPPORT */ pAd->ApCfg.MBSSID[apidx].Bssid); MakeOutgoingFrame(pOutBuffer, &FrameLen, sizeof(HEADER_802_11), &AuthHdr, 2, &Alg, 2, &Seq, 2, &RspReason, 1, &ChTxtIe, 1, &ChTxtLen, CIPHER_TEXT_LEN, pAd->ApMlmeAux.Challenge, END_OF_ARGS); MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen); MlmeFreeMemory(pAd, pOutBuffer); } else ; /* MAC table full, what should we respond ???? */ } else { /* wrong algorithm */ APPeerAuthSimpleRspGenAndSend(pAd, pRcvHdr, Alg, Seq + 1, MLME_ALG_NOT_SUPPORT); /* If this STA exists, delete it. */ if (pEntry) MacTableDeleteEntry(pAd, pEntry->Aid, pEntry->Addr); DBGPRINT(RT_DEBUG_TRACE, ("AUTH - Alg=%d, Seq=%d, AuthMode=%d\n", Alg, Seq, pAd->ApCfg.MBSSID[apidx].AuthMode)); } }
ULONG InsertWfdSubelmtTlv( IN PRTMP_ADAPTER pAd, IN UCHAR SubId, IN PUCHAR pInBuffer, IN PUCHAR pOutBuffer, IN UINT Action) { PRT_WFD_CONFIG pWFDCtrl = &pAd->StaCfg.WfdCfg; PUCHAR pDest; ULONG Length, tmpValue = 0; USHORT EidLen = 0; pDest = pOutBuffer; RTMPZeroMemory(pDest, 255); *pDest = SubId; pDest += 1; Length = 0; switch (SubId) { case SUBID_WFD_DEVICE_INFO: { WFD_DEVICE_INFO DevInfo; PUSHORT pDevInfo = &DevInfo; RTMPZeroMemory(&DevInfo, sizeof(WFD_DEVICE_INFO)); EidLen = SUBID_WFD_DEVICE_INFO_LEN; tmpValue = cpu2be16(EidLen); RTMPMoveMemory(pDest, &tmpValue, 2); DevInfo.DeviceType = pWFDCtrl->DeviceType; DevInfo.SourceCoupled = pWFDCtrl->SourceCoupled; DevInfo.SinkCoupled = pWFDCtrl->SinkCoupled; DevInfo.SessionAvail = pWFDCtrl->SessionAvail; DevInfo.WSD = pWFDCtrl->WSD; if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED) && (INFRA_ON(pAd))) DevInfo.PC = pWFDCtrl->PC; else DevInfo.PC = WFD_PC_P2P; DevInfo.CP = pWFDCtrl->CP; DevInfo.TimeSync = pWFDCtrl->TimeSync; /* RTMPMoveMemory(pDest + 1, &DevInfo, sizeof(WFD_DEVICE_INFO)); */ tmpValue = cpu2be16(*pDevInfo); RTMPMoveMemory((pDest + 2), &tmpValue, 2); tmpValue = cpu2be16(pWFDCtrl->RtspPort); RTMPMoveMemory((pDest + 4), &tmpValue, 2); tmpValue = cpu2be16(pWFDCtrl->MaxThroughput); RTMPMoveMemory((pDest + 6), &tmpValue, 2); Length = 9; break; } case SUBID_WFD_ASSOCIATED_BSSID: { UCHAR AllZero[MAC_ADDR_LEN] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0}; if ((Action == ACTION_GAS_INITIAL_REQ) || (Action == ACTION_GAS_INITIAL_RSP)) { EidLen = SUBID_WFD_ASSOCIATED_BSSID_LEN; tmpValue = cpu2be16(EidLen); RTMPMoveMemory(pDest, &tmpValue, 2); Length = EidLen + 3; if (!NdisEqualMemory(AllZero, pAd->CommonCfg.Bssid, MAC_ADDR_LEN) && (Action == ACTION_GAS_INITIAL_RSP)) { RTMPMoveMemory(pDest + 2, pAd->CommonCfg.Bssid, MAC_ADDR_LEN); } } else { if (!NdisEqualMemory(AllZero, pAd->CommonCfg.Bssid, MAC_ADDR_LEN)) { EidLen = SUBID_WFD_ASSOCIATED_BSSID_LEN; tmpValue = cpu2be16(EidLen); RTMPMoveMemory(pDest, &tmpValue, 2); RTMPMoveMemory(pDest + 2, pAd->CommonCfg.Bssid, MAC_ADDR_LEN); Length = EidLen + 3; } } break; } case SUBID_WFD_AUDIO_FORMATS: { if ((Action == ACTION_GAS_INITIAL_REQ) || (Action == ACTION_GAS_INITIAL_RSP)) { EidLen = SUBID_WFD_AUDIO_FORMATS_LEN; tmpValue = cpu2be16(EidLen); RTMPMoveMemory(pDest, &tmpValue, 2); Length = EidLen + 3; } break; } case SUBID_WFD_VIDEO_FORMATS: { if ((Action == ACTION_GAS_INITIAL_REQ) || (Action == ACTION_GAS_INITIAL_RSP)) { EidLen = SUBID_WFD_VIDEO_FORMATS_LEN; tmpValue = cpu2be16(EidLen); RTMPMoveMemory(pDest, &tmpValue, 2); Length = EidLen + 3; } break; } case SUBID_WFD_3D_VIDEO_FORMATS: { if ((Action == ACTION_GAS_INITIAL_REQ) || (Action == ACTION_GAS_INITIAL_RSP)) { EidLen = SUBID_WFD_3D_VIDEO_FORMATS_LEN; tmpValue = cpu2be16(EidLen); RTMPMoveMemory(pDest, &tmpValue, 2); Length = EidLen + 3; } break; } case SUBID_WFD_CONTENT_PROTECTION: { if ((Action == ACTION_GAS_INITIAL_REQ) || (Action == ACTION_GAS_INITIAL_RSP)) { EidLen = SUBID_WFD_CONTENT_PROTECTION_LEN; tmpValue = cpu2be16(EidLen); RTMPMoveMemory(pDest, &tmpValue, 2); Length = EidLen + 3; } break; } case SUBID_WFD_COUPLED_SINK_INFO: { // if ((pWFDCtrl->DeviceType != WFD_SOURCE ) && (pWFDCtrl->SinkCoupled == WFD_COUPLED_SUPPORT)) { WFD_COUPLED_SINK_INFO SinkInfo; RTMPZeroMemory(&SinkInfo, sizeof(WFD_COUPLED_SINK_INFO)); EidLen = SUBID_WFD_COUPLED_SINK_INFO_LEN; tmpValue = cpu2be16(EidLen); RTMPMoveMemory(pDest, &tmpValue, 2); SinkInfo.CoupledStat = pWFDCtrl->CoupledSinkStatus.CoupledStat; RTMPMoveMemory(pDest + 2, &SinkInfo, sizeof(WFD_COUPLED_SINK_INFO)); Length = EidLen + 3; } break; } case SUBID_WFD_EXTENDED_CAP: { if ((Action == ACTION_GAS_INITIAL_REQ) || (Action == ACTION_GAS_INITIAL_RSP)) { EidLen = SUBID_WFD_EXTENDED_CAP_LEN; tmpValue = cpu2be16(EidLen); RTMPMoveMemory(pDest, &tmpValue, 2); Length = EidLen + 3; } break; } case SUBID_WFD_LOCAL_IP_ADDR: { if ((Action == ACTION_GAS_INITIAL_REQ) || (Action == ACTION_GAS_INITIAL_RSP)) { EidLen = SUBID_WFD_LOCAL_IP_ADDR_LEN; tmpValue = cpu2be16(EidLen); RTMPMoveMemory(pDest, &tmpValue, 2); Length = EidLen + 3; } else { EidLen = SUBID_WFD_LOCAL_IP_ADDR_LEN; tmpValue = cpu2be16(EidLen); RTMPMoveMemory(pDest, &tmpValue, 2); RTMPMoveMemory(pDest + 2, &pWFDCtrl->wfd_serv_disc_query_info.wfd_local_ip_ie, SUBID_WFD_LOCAL_IP_ADDR_LEN); Length = EidLen + 3; } break; } case SUBID_WFD_SESSION_INFO: { INT i = 0, NumOfDev = 0; UCHAR P2pIdx = P2P_NOT_FOUND; PRT_P2P_TABLE Tab = &pAd->P2pTable; if (P2P_GO_ON(pAd) #ifdef RT_CFG80211_SUPPORT || (pWFDCtrl->bSuppGoOn) #endif /* RT_CFG80211_SUPPORT */ ) { for (i = 1; i < MAX_LEN_OF_MAC_TABLE; i++) { MAC_TABLE_ENTRY *pEntry = &pAd->MacTab.Content[i]; P2pIdx = P2pGroupTabSearch(pAd, pEntry->Addr); if ((P2pIdx < MAX_P2P_GROUP_SIZE) && (Tab->Client[P2pIdx].WfdEntryInfo.bWfdClient == TRUE)) NumOfDev++; } EidLen = 24*NumOfDev; tmpValue = cpu2be16(EidLen); RTMPMoveMemory(pDest, &tmpValue, 2); DBGPRINT(RT_DEBUG_INFO, ("%s:: NumOfDev = %d, Len = %d\n", __FUNCTION__, NumOfDev, *pDest)); pDest+=2; for (i = 1; i < MAX_LEN_OF_MAC_TABLE; i++) { MAC_TABLE_ENTRY *pEntry = &pAd->MacTab.Content[i]; P2pIdx = P2pGroupTabSearch(pAd, pEntry->Addr); if ((P2pIdx < MAX_P2P_GROUP_SIZE) && (Tab->Client[P2pIdx].WfdEntryInfo.bWfdClient == TRUE)) { INT j = 0; WFD_SESSION_INFO SessionInfo; RTMPZeroMemory(&SessionInfo, sizeof(WFD_SESSION_INFO)); SessionInfo.Length = 23; RTMPMoveMemory(&SessionInfo.DeviceAddr[0], &pAd->P2pTable.Client[P2pIdx].addr[0], MAC_ADDR_LEN); RTMPMoveMemory(&SessionInfo.Bssid[0], &pAd->P2pTable.Client[P2pIdx].WfdEntryInfo.assoc_addr[0], MAC_ADDR_LEN); /* Below is the WFD Device Information */ SessionInfo.WfdDevInfo.DeviceType = pAd->P2pTable.Client[P2pIdx].WfdEntryInfo.wfd_devive_type; SessionInfo.WfdDevInfo.SourceCoupled = pAd->P2pTable.Client[P2pIdx].WfdEntryInfo.source_coupled; SessionInfo.WfdDevInfo.SinkCoupled = pAd->P2pTable.Client[P2pIdx].WfdEntryInfo.sink_coupled; SessionInfo.WfdDevInfo.SessionAvail = pAd->P2pTable.Client[P2pIdx].WfdEntryInfo.session_avail; SessionInfo.WfdDevInfo.WSD = pAd->P2pTable.Client[P2pIdx].WfdEntryInfo.wfd_service_discovery; SessionInfo.WfdDevInfo.PC = pAd->P2pTable.Client[P2pIdx].WfdEntryInfo.wfd_PC; SessionInfo.WfdDevInfo.TimeSync = pAd->P2pTable.Client[P2pIdx].WfdEntryInfo.wfd_time_sync; SessionInfo.MaxThroughput = pAd->P2pTable.Client[P2pIdx].WfdEntryInfo.max_throughput; SessionInfo.CoupledSinkInfo = pAd->P2pTable.Client[P2pIdx].WfdEntryInfo.coupled_sink_status; /* So far we cannot know the address of coupled devices, the coupled address will be filled "0" until WiFi Display spec. is ready for this part. */ RTMPMoveMemory(&SessionInfo.CoupledPeerAddr[0], &pAd->P2pTable.Client[P2pIdx].WfdEntryInfo.coupled_peer_addr[0], MAC_ADDR_LEN); RTMPMoveMemory(pDest, &SessionInfo, sizeof(WFD_SESSION_INFO)); for (j = 0; j < 24; j++) DBGPRINT(RT_DEBUG_INFO, ("%02x ", *(pDest+j))); DBGPRINT(RT_DEBUG_INFO, ("\n")); pDest += 24; } } Length = 24*NumOfDev + 3; } break; } case SUBID_WFD_ALTERNATE_MAC_ADDR: { UCHAR AllZero[MAC_ADDR_LEN] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0}; if (!NdisEqualMemory(AllZero, pAd->CurrentAddress, MAC_ADDR_LEN)) { EidLen = SUBID_WFD_ALTERNATE_MAC_ADDR_LEN; *((PUSHORT) (pDest)) = cpu2be16(EidLen); RTMPMoveMemory(pDest + 2, pAd->CurrentAddress, MAC_ADDR_LEN); Length = EidLen + 3; } break; } default: *pDest = 0; Length = 0; break; } return Length; }
INT Set_PeerRtspPort_Proc( IN PRTMP_ADAPTER pAd, IN PSTRING arg) { PRT_WFD_CONFIG pWFDCtrl = &pAd->StaCfg.WfdCfg; UINT32 ip_addr; MAC_TABLE_ENTRY *pEntry; USHORT RtspPort = WFD_RTSP_DEFAULT_PORT; UCHAR P2pIdx = P2P_NOT_FOUND; PRT_P2P_CONFIG pP2PCtrl = &pAd->P2pCfg; INT i; #ifdef DOT11Z_TDLS_SUPPORT i = -1; if (pAd->StaCfg.TdlsInfo.bTDLSCapable && pAd->StaCfg.WfdCfg.PC == WFD_PC_TDLS) { PRT_802_11_TDLS pTDLS = NULL; DBGPRINT(RT_DEBUG_TRACE, ("%s - TDLS peer rtsp port get...\n", __FUNCTION__)); for (i = MAX_NUM_OF_TDLS_ENTRY - 1; i >= 0; i--) { if ((pAd->StaCfg.TdlsInfo.TDLSEntry[i].Valid) && (pAd->StaCfg.TdlsInfo.TDLSEntry[i].Status == TDLS_MODE_CONNECTED)) { pTDLS = &pAd->StaCfg.TdlsInfo.TDLSEntry[i]; RtspPort = pTDLS->WfdEntryInfo.rtsp_port; DBGPRINT(RT_DEBUG_TRACE, ("TDLS Entry[%d][%02x:%02x:%02x:%02x:%02x:%02x]\n", i, PRINT_MAC(pTDLS->MacAddr))); DBGPRINT(RT_DEBUG_TRACE, ("RTSP_PORT = %d.\n", pTDLS->WfdEntryInfo.rtsp_port)); break; } } if ((RtspPort == 0) && (pTDLS != NULL)) { DBGPRINT(RT_DEBUG_ERROR, ("TDLS peer rtsp port is zero, search P2P Entry!\n", RtspPort)); P2pIdx = P2pGroupTabSearch(pAd, pTDLS->MacAddr); if (P2pIdx != P2P_NOT_FOUND) { RtspPort = pAd->P2pTable.Client[P2pIdx].WfdEntryInfo.rtsp_port; DBGPRINT(RT_DEBUG_TRACE, ("P2P Entry[%d][%02x:%02x:%02x:%02x:%02x:%02x]\n", P2pIdx, PRINT_MAC(pTDLS->MacAddr))); DBGPRINT(RT_DEBUG_TRACE, ("RTSP_PORT = %d.\n", pAd->P2pTable.Client[P2pIdx].WfdEntryInfo.rtsp_port)); if (RtspPort == 0) RtspPort = WFD_RTSP_DEFAULT_PORT; } else { RtspPort = WFD_RTSP_DEFAULT_PORT; DBGPRINT(RT_DEBUG_ERROR, ("OID_802_11_P2P_PEER_RTSP_PORT::P2P not found, use default RTSP port\n")); } } } if (i < 0) #endif /* DOT11Z_TDLS_SUPPORT */ { DBGPRINT(RT_DEBUG_TRACE, ("%s - P2P peer rtsp port get...\n", __FUNCTION__)); if (P2P_GO_ON(pAd) || P2P_CLI_ON(pAd)) { for (i=0; i<MAX_LEN_OF_MAC_TABLE; i++) { pEntry = &pAd->MacTab.Content[i]; if (IS_P2P_GO_ENTRY(pEntry) || IS_P2P_CLI_ENTRY(pEntry)) { P2pIdx = P2pGroupTabSearch(pAd, pEntry->Addr); DBGPRINT(RT_DEBUG_TRACE, ("P2P Entry[%d][%02x:%02x:%02x:%02x:%02x:%02x]\n", pEntry->P2pInfo.p2pIndex, PRINT_MAC(pEntry->Addr))); DBGPRINT(RT_DEBUG_TRACE, ("RTSP_PORT = %d.\n", pAd->P2pTable.Client[pEntry->P2pInfo.p2pIndex].WfdEntryInfo.rtsp_port)); if (P2pIdx != P2P_NOT_FOUND) RtspPort = pAd->P2pTable.Client[P2pIdx].WfdEntryInfo.rtsp_port; else { RtspPort = WFD_RTSP_DEFAULT_PORT; DBGPRINT(RT_DEBUG_ERROR, ("OID_802_11_P2P_PEER_RTSP_PORT::P2P not found, use default RTSP port\n")); } if (pEntry->P2pInfo.p2pIndex < MAX_P2P_GROUP_SIZE) P2PPrintP2PEntry(pAd, pEntry->P2pInfo.p2pIndex); break; } } DBGPRINT(RT_DEBUG_TRACE, ("OID_802_11_P2P_PEER_RTSP_PORT bssid: %02x:%02x:%02x:%02x:%02x:%02x.\n", PRINT_MAC(pP2PCtrl->CurrentAddress))); } } DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_P2P_PEER_RTSP_PORT (=%d)\n", RtspPort)); return TRUE; }
INT Set_P2P_Cancel_Proc( IN PRTMP_ADAPTER pAd, IN PSTRING arg) { POS_COOKIE pObj; PRT_P2P_CONFIG pP2PCtrl = &pAd->P2pCfg; PWSC_CTRL pWscControl = NULL; INT val = (INT)simple_strtol(arg, 0, 10); pObj = (POS_COOKIE) pAd->OS_Cookie; if (pObj->ioctl_if_type != INT_P2P) return FALSE; if (val == 1) { pP2PCtrl->P2PConnectState = P2P_CONNECT_IDLE; if (!MAC_ADDR_EQUAL(&ZERO_MAC_ADDR[0], &pP2PCtrl->ConnectingMAC[0])) { UCHAR p2pindex; p2pindex = P2pGroupTabSearch(pAd, pP2PCtrl->ConnectingMAC); if (p2pindex < MAX_P2P_GROUP_SIZE) { if (pAd->P2pTable.Client[p2pindex].Rule == P2P_IS_GO) pAd->P2pTable.Client[p2pindex].P2pClientState = P2PSTATE_DISCOVERY_GO; else pAd->P2pTable.Client[p2pindex].P2pClientState = P2PSTATE_DISCOVERY; pAd->P2pTable.Client[p2pindex].StateCount = 0; } NdisZeroMemory(pP2PCtrl->ConnectingMAC, MAC_ADDR_LEN); } if (P2P_GO_ON(pAd)) { UINT32 i, p2pEntryCnt=0; MAC_TABLE_ENTRY *pEntry; INT IsAPConfigured; pWscControl = &pAd->ApCfg.MBSSID[MAIN_MBSSID].WscControl; IsAPConfigured = pWscControl->WscConfStatus; if (pWscControl->bWscTrigger) { WscStop(pAd, FALSE, pWscControl); pWscControl->WscPinCode = 0; WscBuildBeaconIE(pAd, IsAPConfigured, FALSE, 0, 0, MAIN_MBSSID, NULL, 0, AP_MODE); WscBuildProbeRespIE(pAd, WSC_MSGTYPE_AP_WLAN_MGR, IsAPConfigured, FALSE, 0, 0, (MAIN_MBSSID | MIN_NET_DEVICE_FOR_P2P_GO), NULL, 0, AP_MODE); APUpdateBeaconFrame(pAd, pObj->ioctl_if); } for (i=0; i<MAX_LEN_OF_MAC_TABLE; i++) { pEntry = &pAd->MacTab.Content[i]; if (IS_P2P_GO_ENTRY(pEntry) && (pEntry->WpaState == AS_PTKINITDONE)) p2pEntryCnt++; } DBGPRINT(RT_DEBUG_ERROR, ("%s:: Total= %d. p2pEntry = %d.\n", __FUNCTION__, pAd->MacTab.Size, p2pEntryCnt)); if ((p2pEntryCnt == 0) && (pAd->flg_p2p_OpStatusFlags == P2P_GO_UP)) { #ifdef RTMP_MAC_USB RTEnqueueInternalCmd(pAd, CMDTHREAD_SET_P2P_LINK_DOWN, NULL, 0); #endif /* RTMP_MAC_USB */ } } else if (P2P_CLI_ON(pAd)) { pWscControl = &pAd->ApCfg.MBSSID[MAIN_MBSSID].WscControl; pWscControl->WscPinCode = 0; if (pWscControl->bWscTrigger) WscStop(pAd, TRUE, pWscControl); P2pLinkDown(pAd, P2P_DISCONNECTED); } P2pStopScan(pAd); pP2PCtrl->bPeriodicListen = TRUE; /* Reset bConfirmByUI to its default value */ pP2PCtrl->bConfirmByUI = CONFIRM_BY_UI_DEFAULT; if (INFRA_ON(pAd) || P2P_GO_ON(pAd) || P2P_CLI_ON(pAd)) { INT ch; // TODO: shiang-6590, why we set bw as 40 when BBPCurrentBW == BW_40?? if (pAd->CommonCfg.BBPCurrentBW == BW_40) { rtmp_bbp_set_bw(pAd, BW_40); ch = pAd->CommonCfg.CentralChannel; } else { ch = pAd->CommonCfg.Channel; } AsicSwitchChannel(pAd, pAd->CommonCfg.CentralChannel, FALSE); AsicLockChannel(pAd, pAd->CommonCfg.CentralChannel); } } DBGPRINT(RT_DEBUG_TRACE, ("%s:: Cancel P2P action\n", __FUNCTION__)); return TRUE; }
/* ========================================================================== Description: Pre-build a BEACON frame in the shared memory ========================================================================== */ VOID APMakeBssBeacon( IN PRTMP_ADAPTER pAd, IN INT apidx) { UCHAR DsLen = 1, SsidLen;/*, TimLen = 4, */ /*BitmapControl = 0, VirtualBitmap = 0, EmptySsidLen = 0, SsidLen; */ /* UCHAR RSNIe=IE_WPA, RSNIe2=IE_WPA2; */ HEADER_802_11 BcnHdr; LARGE_INTEGER FakeTimestamp; ULONG FrameLen = 0; PTXWI_STRUC pTxWI = &pAd->BeaconTxWI; PUCHAR pBeaconFrame = (PUCHAR)pAd->ApCfg.MBSSID[apidx].BeaconBuf; UCHAR *ptr; UINT i; UINT32 longValue; HTTRANSMIT_SETTING BeaconTransmit; /* MGMT frame PHY rate setting when operatin at Ht rate. */ UCHAR PhyMode, SupRateLen; #ifdef SPECIFIC_BCN_BUF_SUPPORT unsigned long irqFlag = 0; #endif /* SPECIFIC_BCN_BUF_SUPPORT */ if(!BeaconTransmitRequired(pAd, apidx, &pAd->ApCfg.MBSSID[apidx])) return; PhyMode = pAd->ApCfg.MBSSID[apidx].PhyMode; if (pAd->ApCfg.MBSSID[apidx].bHideSsid) SsidLen = 0; else SsidLen = pAd->ApCfg.MBSSID[apidx].SsidLen; MgtMacHeaderInit(pAd, &BcnHdr, SUBTYPE_BEACON, 0, BROADCAST_ADDR, #ifdef P2P_SUPPORT pAd->ApCfg.MBSSID[apidx].Bssid, #endif /* P2P_SUPPORT */ pAd->ApCfg.MBSSID[apidx].Bssid); /* for update framelen to TxWI later. */ SupRateLen = pAd->CommonCfg.SupRateLen; if (PhyMode == PHY_11B) SupRateLen = 4; #ifdef P2P_SUPPORT if (P2P_GO_ON(pAd)) { UCHAR SupRate[MAX_LEN_OF_SUPPORTED_RATES]; UCHAR SupRateIe = IE_SUPP_RATES; UCHAR SupRateLen = 0; SupRate[0] = 0x8C; /* 6 mbps, in units of 0.5 Mbps, basic rate */ SupRate[1] = 0x12; /* 9 mbps, in units of 0.5 Mbps */ SupRate[2] = 0x98; /* 12 mbps, in units of 0.5 Mbps, basic rate */ SupRate[3] = 0x24; /* 18 mbps, in units of 0.5 Mbps */ SupRate[4] = 0xb0; /* 24 mbps, in units of 0.5 Mbps, basic rate */ SupRate[5] = 0x48; /* 36 mbps, in units of 0.5 Mbps */ SupRate[6] = 0x60; /* 48 mbps, in units of 0.5 Mbps */ SupRate[7] = 0x6c; /* 54 mbps, in units of 0.5 Mbps */ SupRateLen = 8; MakeOutgoingFrame(pBeaconFrame, &FrameLen, sizeof(HEADER_802_11), &BcnHdr, TIMESTAMP_LEN, &FakeTimestamp, 2, &pAd->CommonCfg.BeaconPeriod, 2, &pAd->ApCfg.MBSSID[apidx].CapabilityInfo, 1, &SsidIe, 1, &SsidLen, SsidLen, pAd->ApCfg.MBSSID[apidx].Ssid, 1, &SupRateIe, 1, &SupRateLen, SupRateLen, &SupRate, 1, &DsIe, 1, &DsLen, 1, &pAd->CommonCfg.Channel, END_OF_ARGS); } else #endif /* P2P_SUPPORT */ MakeOutgoingFrame(pBeaconFrame, &FrameLen, sizeof(HEADER_802_11), &BcnHdr, TIMESTAMP_LEN, &FakeTimestamp, 2, &pAd->CommonCfg.BeaconPeriod, 2, &pAd->ApCfg.MBSSID[apidx].CapabilityInfo, 1, &SsidIe, 1, &SsidLen, SsidLen, pAd->ApCfg.MBSSID[apidx].Ssid, 1, &SupRateIe, 1, &SupRateLen, SupRateLen, pAd->CommonCfg.SupRate, 1, &DsIe, 1, &DsLen, 1, &pAd->CommonCfg.Channel, END_OF_ARGS); if ((pAd->CommonCfg.ExtRateLen) && (PhyMode != PHY_11B)) { ULONG TmpLen; MakeOutgoingFrame(pBeaconFrame+FrameLen, &TmpLen, 1, &ExtRateIe, 1, &pAd->CommonCfg.ExtRateLen, pAd->CommonCfg.ExtRateLen, pAd->CommonCfg.ExtRate, END_OF_ARGS); FrameLen += TmpLen; } /* add country IE, power constraint IE */ if (pAd->CommonCfg.bCountryFlag) { ULONG TmpLen, TmpLen2=0; /* UCHAR TmpFrame[256]; */ UCHAR *TmpFrame = NULL; UCHAR CountryIe = IE_COUNTRY; os_alloc_mem(NULL, (UCHAR **)&TmpFrame, 256); if (TmpFrame != NULL) { NdisZeroMemory(TmpFrame, sizeof(TmpFrame)); /* prepare channel information */ #ifdef EXT_BUILD_CHANNEL_LIST BuildBeaconChList(pAd, TmpFrame, &TmpLen2); #else { UCHAR MaxTxPower = GetCuntryMaxTxPwr(pAd, pAd->CommonCfg.Channel); MakeOutgoingFrame(TmpFrame+TmpLen2, &TmpLen, 1, &pAd->ChannelList[0].Channel, 1, &pAd->ChannelListNum, 1, &MaxTxPower, END_OF_ARGS); TmpLen2 += TmpLen; } #endif /* EXT_BUILD_CHANNEL_LIST */ /* need to do the padding bit check, and concatenate it */ if ((TmpLen2%2) == 0) { UCHAR TmpLen3 = TmpLen2+4; MakeOutgoingFrame(pBeaconFrame+FrameLen,&TmpLen, 1, &CountryIe, 1, &TmpLen3, 3, pAd->CommonCfg.CountryCode, TmpLen2+1, TmpFrame, END_OF_ARGS); } else { UCHAR TmpLen3 = TmpLen2+3; MakeOutgoingFrame(pBeaconFrame+FrameLen,&TmpLen, 1, &CountryIe, 1, &TmpLen3, 3, pAd->CommonCfg.CountryCode, TmpLen2, TmpFrame, END_OF_ARGS); } FrameLen += TmpLen; os_free_mem(NULL, TmpFrame); } else DBGPRINT(RT_DEBUG_ERROR, ("%s: Allocate memory fail!!!\n", __FUNCTION__)); } #ifdef DOT11_N_SUPPORT /* AP Channel Report */ { UCHAR APChannelReportIe = IE_AP_CHANNEL_REPORT; ULONG TmpLen; /* 802.11n D2.0 Annex J */ /* USA */ /* regulatory class 32, channel set 1~7 */ /* regulatory class 33, channel set 5-11 */ UCHAR rclass32[]= {32, 1, 2, 3, 4, 5, 6, 7}; UCHAR rclass33[]= {33, 5, 6, 7, 8, 9, 10, 11}; UCHAR rclasslen = 8; /*sizeof(rclass32); */ if (PhyMode == PHY_11BGN_MIXED) { MakeOutgoingFrame(pBeaconFrame+FrameLen,&TmpLen, 1, &APChannelReportIe, 1, &rclasslen, rclasslen, rclass32, 1, &APChannelReportIe, 1, &rclasslen, rclasslen, rclass33, END_OF_ARGS); FrameLen += TmpLen; } } #endif /* DOT11_N_SUPPORT */ BeaconTransmit.word = 0; RTMPWriteTxWI(pAd, pTxWI, FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, 0, BSS0Mcast_WCID, FrameLen, PID_MGMT, 0, 0,IFS_HTTXOP, FALSE, &BeaconTransmit); /* */ /* step 6. move BEACON TXD and frame content to on-chip memory */ /* */ ptr = (PUCHAR)&pAd->BeaconTxWI; #ifdef RT_BIG_ENDIAN RTMPWIEndianChange(ptr, TYPE_TXWI); #endif #ifdef SPECIFIC_BCN_BUF_SUPPORT /* Shared memory access selection (higher 8KB shared memory) */ RTMP_MAC_SHR_MSEL_LOCK(pAd, HIGHER_SHRMEM, irqFlag); #endif /* SPECIFIC_BCN_BUF_SUPPORT */ for (i=0; i<TXWI_SIZE; i+=4) /* 16-byte TXWI field */ { longValue = *ptr + (*(ptr+1)<<8) + (*(ptr+2)<<16) + (*(ptr+3)<<24); RTMP_IO_WRITE32(pAd, pAd->BeaconOffset[pAd->ApCfg.MBSSID[apidx].BcnBufIdx] + i, longValue); ptr += 4; } /* update BEACON frame content. start right after the 16-byte TXWI field. */ ptr = (PUCHAR)pAd->ApCfg.MBSSID[apidx].BeaconBuf; #ifdef RT_BIG_ENDIAN RTMPFrameEndianChange(pAd, ptr, DIR_WRITE, FALSE); #endif for (i= 0; i< FrameLen; i+=4) { longValue = *ptr + (*(ptr+1)<<8) + (*(ptr+2)<<16) + (*(ptr+3)<<24); RTMP_IO_WRITE32(pAd, pAd->BeaconOffset[pAd->ApCfg.MBSSID[apidx].BcnBufIdx] + TXWI_SIZE + i, longValue); ptr += 4; } #ifdef SPECIFIC_BCN_BUF_SUPPORT /* Shared memory access selection (lower 16KB shared memory) */ RTMP_MAC_SHR_MSEL_UNLOCK(pAd, LOWER_SHRMEM, irqFlag); #endif /* SPECIFIC_BCN_BUF_SUPPORT */ pAd->ApCfg.MBSSID[apidx].TimIELocationInBeacon = (UCHAR)FrameLen; pAd->ApCfg.MBSSID[apidx].CapabilityInfoLocationInBeacon = sizeof(HEADER_802_11) + TIMESTAMP_LEN + 2; }
/* ========================================================================== Description: This is a periodic routine that check P2P Group Table's Status. One importatn task is to check if some frame that need transmission result is success or retry fail. Parameters: Note: ========================================================================== */ VOID P2pGroupMaintain( IN PRTMP_ADAPTER pAd) { PRT_P2P_CONFIG pP2PCtrl = &pAd->P2pCfg; UCHAR i; PRT_P2P_CLIENT_ENTRY pP2pEntry; ULONG Data; /*UCHAR Value;*/ /*BCN_TIME_CFG_STRUC csr;*/ BOOLEAN bAllPsm = TRUE; if (pP2PCtrl->GONoASchedule.bValid == TRUE) { /* Disable OppPS when NoA is ON. */ P2pStopOpPS(pAd); RTMP_IO_READ32(pAd, TSF_TIMER_DW1, &Data); if (Data != pP2PCtrl->GONoASchedule.TsfHighByte) { DBGPRINT(RT_DEBUG_ERROR, ("P2pGroupMaintain. Tsf MSB changed to %ld from %ld. restart NoA . \n",Data, pP2PCtrl->GONoASchedule.TsfHighByte )); /* I want to resume the NoA */ pP2PCtrl->GONoASchedule.bNeedResumeNoA = TRUE; P2pStopNoA(pAd, NULL); /* Ok. Now resume it. */ pP2PCtrl->GONoASchedule.bNeedResumeNoA = FALSE; P2pGOStartNoA(pAd); } } else if ((P2P_GO_ON(pAd)) && (pP2PCtrl->GONoASchedule.bValid == FALSE) && (IS_OPPS_ON(pAd))) { /* Since NoA is OFF, consider to enable OppPS. */ for (i = 0; i < MAX_LEN_OF_MAC_TABLE;i++) { PMAC_TABLE_ENTRY pEntry = &pAd->MacTab.Content[i]; if (IS_ENTRY_CLIENT(pEntry) && (pEntry->PsMode == PWR_ACTIVE)) { bAllPsm = FALSE; break; } } if ((bAllPsm == TRUE) && (pAd->MacTab.Size > 0)) { /* bit 7 is OppPS bit. set 1 to enable. bit [0:6] is in unit TU. */ if (IS_OPPS_ON(pAd)) { P2pStartOpPS(pAd); pP2PCtrl->CTWindows = 0x8a; } /* case 2 to turn on CTWindows. Not decide the case 2 rule yet. 2010-June */ else if (0) { pP2PCtrl->CTWindows = 0x8a; } } else if (P2P_TEST_BIT(pAd->P2pCfg.CTWindows, P2P_OPPS_BIT)) { P2pStopOpPS(pAd); } } if (pP2PCtrl->p2pidxForServiceCbReq < MAX_P2P_GROUP_SIZE) { if (pAd->P2pTable.Client[pAd->P2pCfg.p2pidxForServiceCbReq].ConfigTimeOut > 0) pAd->P2pTable.Client[pAd->P2pCfg.p2pidxForServiceCbReq].ConfigTimeOut--; if (pAd->P2pTable.Client[pAd->P2pCfg.p2pidxForServiceCbReq].P2pClientState == P2PSTATE_SERVICE_COMEBACK_COMMAND && (pAd->P2pTable.Client[pAd->P2pCfg.p2pidxForServiceCbReq].ConfigTimeOut == 0)) { /*P2pSendComebackReq(pAd, pAd->P2pCfg.p2pidxForServiceCbReq, pAd->P2pTable.Client[pAd->P2pCfg.p2pidxForServiceCbReq].addr); */ pP2PCtrl->p2pidxForServiceCbReq = MAX_P2P_GROUP_SIZE; } } if (IS_PERSISTENT_ON(pAd) && (!P2P_GO_ON(pAd)) && (!P2P_CLI_ON(pAd))) { for (i = 0; i < MAX_P2P_GROUP_SIZE; i++) { pP2pEntry = &pAd->P2pTable.Client[i]; /* Add some delay to connect to Persistent GO. Because some GO like broadcom need configuration time to start GO. */ if ((pP2pEntry->P2pClientState == P2PSTATE_REINVOKEINVITE_TILLCONFIGTIME)) { if (pP2pEntry->ConfigTimeOut > 0) pP2pEntry->ConfigTimeOut--; if (pP2pEntry->ConfigTimeOut == 0) { pP2PCtrl->P2PConnectState = P2P_DO_WPS_ENROLLEE; pP2pEntry->P2pClientState = P2PSTATE_GO_WPS; P2pWpsDone(pAd, pP2pEntry->addr); } } } } if (P2P_GO_ON(pAd)) { for (i = 0; i < MAX_P2P_GROUP_SIZE; i++) { pP2pEntry = &pAd->P2pTable.Client[i]; if (pP2pEntry->P2pClientState == P2PSTATE_WAIT_GO_DISCO_ACK_SUCCESS) { ULONG TotalFrameLen; DBGPRINT(RT_DEBUG_TRACE,("P2P P2PSTATE_WAIT_GO_DISCO_ACK_SUCCESS \n")); P2PSendDevDisRsp(pAd, P2PSTATUS_SUCCESS, pAd->P2pCfg.LatestP2pPublicFrame.Token, pAd->P2pCfg.LatestP2pPublicFrame.p80211Header.Addr2, &TotalFrameLen); pP2pEntry->P2pClientState = P2PSTATE_CLIENT_OPERATING; } else if ((pP2pEntry->P2pClientState == P2PSTATE_PROVISION_COMMAND) || (pP2pEntry->P2pClientState == P2PSTATE_INVITE_COMMAND)) { if (pP2pEntry->StateCount > 0) { /*DBGPRINT(RT_DEBUG_ERROR, ("pEntry[%d] StateCount = %d\n", i, pP2pEntry->StateCount)); */ pP2pEntry->StateCount--; } if ((pP2pEntry->StateCount == 0) && (pP2pEntry->bValid)) { DBGPRINT(RT_DEBUG_ERROR, ("P2P Table : idx=%d Send Probe Req. \n", i)); pP2pEntry->StateCount = 10; P2pSendProbeReq(pAd); } } } } /* time out case. */ else if ((pP2PCtrl->P2PConnectState == P2P_DO_GO_SCAN_BEGIN) && (pP2PCtrl->P2pCounter.GoScanBeginCounter100ms > 1200 /*GOSCANBEGINCOUNTER_MAX*/)) { DBGPRINT(RT_DEBUG_TRACE, ("P2P_DO_GO_SCAN_BEGIN Timeout. BAck to idle. \n")); pP2PCtrl->P2PConnectState = P2P_CONNECT_IDLE; } else if ((pAd->flg_p2p_OpStatusFlags == 0) && (!MAC_ADDR_EQUAL(&ZERO_MAC_ADDR, &pP2PCtrl->ConnectingMAC)) && (IS_P2P_SEARCH(pAd))) { for (i = 0; i < MAX_P2P_GROUP_SIZE; i++) { pP2pEntry = &pAd->P2pTable.Client[i]; if (pP2pEntry->P2pClientState == P2PSTATE_NONE) continue; if ((pP2pEntry->P2pClientState >= P2PSTATE_SENT_GO_NEG_REQ) && (pP2pEntry->P2pClientState <= P2PSTATE_WAIT_GO_COMFIRM_ACK)) { if (pP2pEntry->StateCount > 0) { /*DBGPRINT(RT_DEBUG_ERROR, ("pEntry[%d] StateCount = %d\n", i, pP2pEntry->StateCount)); */ pP2pEntry->StateCount--; } if ((pP2pEntry->StateCount == 0) && ((pP2pEntry->bValid))) { DBGPRINT(RT_DEBUG_ERROR, ("P2P Table : idx=%d Go Nego Req Retry. \n", i)); /*pP2pEntry->P2pClientState = P2PSTATE_CONNECT_COMMAND; */ /*pP2PCtrl->P2PConnectState = P2P_CONNECT_IDLE; */ /*pP2PCtrl->P2pCounter.Counter100ms = 0; */ pP2pEntry->StateCount = 50; P2pSendProbeReq(pAd); } } else if (pP2pEntry->P2pClientState == P2PSTATE_GO_COMFIRM_ACK_SUCCESS) { DBGPRINT(RT_DEBUG_ERROR, ("P2P Table : idx=%d Get Confirm Ask Success. p2pState = %d.\n", i, pP2PCtrl->P2PConnectState)); /* Don't leet ClientState keep in P2PSTATE_GO_COMFIRM_ACK_SUCCESS, */ /* Or will keep calling P2pGoNegoDone(). */ /* ClientState will be updated when GO receiving AuthReq. */ pP2pEntry->P2pClientState = P2PSTATE_GOT_GO_COMFIRM; P2pGoNegoDone(pAd, pP2pEntry); } else if (pP2pEntry->P2pClientState== P2PSTATE_REVOKEINVITE_RSP_ACK_SUCCESS) { /* Only when I am GO . I need to check the response ack success or not. */ /* doesn't check rule. start GO right away. */ pP2pEntry->P2pClientState = P2PSTATE_CLIENT_WPS; P2pStartAutoGo(pAd); DBGPRINT(RT_DEBUG_TRACE,("P2P Table : idx=%d Get Invite Rsp Ask Success. p2pState = %d.\n", i, pP2PCtrl->P2PConnectState)); pAd->StaCfg.WscControl.WscState = WSC_STATE_OFF; /* this is not Auto GO by command from GUI. So set the intent index to != 16 */ pAd->P2pCfg.GoIntentIdx = 15; } else if ((pP2pEntry->P2pClientState == P2PSTATE_CONNECT_COMMAND) || (pP2pEntry->P2pClientState == P2PSTATE_PROVISION_COMMAND) || (pP2pEntry->P2pClientState == P2PSTATE_INVITE_COMMAND)) { if (pP2pEntry->StateCount > 0) { /*DBGPRINT(RT_DEBUG_ERROR, ("pEntry[%d] StateCount = %d\n", i, pP2pEntry->StateCount)); */ pP2pEntry->StateCount--; } if ((pP2pEntry->StateCount == 0) && (pP2pEntry->bValid)) { DBGPRINT(RT_DEBUG_ERROR, ("P2P Table : idx=%d Send Probe Req. \n", i)); pP2pEntry->StateCount =10; P2pSendProbeReq(pAd); } } else if ((pP2pEntry->P2pClientState == P2PSTATE_DISCOVERY_GO) && (MAC_ADDR_EQUAL(pP2PCtrl->ConnectingMAC, pP2pEntry->addr))) { if (pP2pEntry->StateCount > 0) { /*DBGPRINT(RT_DEBUG_ERROR, ("pEntry[%d] StateCount = %d\n", i, pP2pEntry->StateCount)); */ pP2pEntry->StateCount--; } if ((pP2pEntry->StateCount == 0) && (pP2pEntry->bValid)) { DBGPRINT(RT_DEBUG_ERROR, ("P2P Table : idx=%d Send Probe Req. \n", i)); pP2pEntry->P2pClientState = P2PSTATE_PROVISION_COMMAND; pP2pEntry->StateCount =10; P2pSendProbeReq(pAd); } } } } }
UCHAR P2pPerstTabInsert( IN PRTMP_ADAPTER pAd, IN PUCHAR pAddr, IN PWSC_CREDENTIAL pProfile) { PRT_P2P_TABLE Tab = &pAd->P2pTable; UCHAR i, j; UCHAR index; /*WSC_CREDENTIAL *pProfile; */ index = P2pPerstTabSearch(pAd, pAddr, NULL, NULL); /* Doesn't have this entry. Add a new one. */ if (index == P2P_NOT_FOUND) { for (i = 0; i < MAX_P2P_TABLE_SIZE; i++) { if (Tab->PerstEntry[i].bValid == FALSE) { Tab->PerstEntry[i].bValid = TRUE; Tab->PerstNumber++; if (P2P_GO_ON(pAd)) Tab->PerstEntry[i].MyRule = P2P_IS_GO; else Tab->PerstEntry[i].MyRule = P2P_IS_CLIENT; RTMPMoveMemory(Tab->PerstEntry[i].Addr, pAddr, MAC_ADDR_LEN); DBGPRINT(RT_DEBUG_ERROR, ("Perst::Registra MacAddr = %x %x %x %x %x %x \n",Tab->PerstEntry[i].Addr[0], Tab->PerstEntry[i].Addr[1], Tab->PerstEntry[i].Addr[2],Tab->PerstEntry[i].Addr[3],Tab->PerstEntry[i].Addr[4],Tab->PerstEntry[i].Addr[5])); RTMPMoveMemory(&Tab->PerstEntry[i].Profile, pProfile, sizeof(WSC_CREDENTIAL)); DBGPRINT(RT_DEBUG_ERROR, ("Perst::SsidLen = %d\n",pProfile->SSID.SsidLength)); DBGPRINT(RT_DEBUG_ERROR, ("Perst::Ssid = %s.\n", pProfile->SSID.Ssid)); DBGPRINT(RT_DEBUG_ERROR, ("Perst::MacAddr = %02x:%02x:%02x:%02x:%02x:%02x.\n", PRINT_MAC(pProfile->MacAddr))); DBGPRINT(RT_DEBUG_ERROR, ("Perst::AuthType = 0x%x. EncrType = %d\n",pProfile->AuthType,pProfile->EncrType)); DBGPRINT(RT_DEBUG_ERROR, ("Perst::KeyIndex = %d\n",pProfile->KeyIndex)); DBGPRINT(RT_DEBUG_ERROR, ("Perst::KeyLength = %d\n",pProfile->KeyLength)); DBGPRINT(RT_DEBUG_ERROR, ("Perst::Key ==>\n")); for (j=0;j<16;) { DBGPRINT(RT_DEBUG_ERROR, (" 0x%x 0x%x 0x%x 0x%x\n",pProfile->Key[j], pProfile->Key[j+1], pProfile->Key[j+2],pProfile->Key[j+3])); j = j+4; } DBGPRINT(RT_DEBUG_ERROR, ("Perst::<===Key =\n")); /*DBGPRINT(RT_DEBUG_ERROR, ("Perst::MacAddr = %x %x %x %x %x %x\n",pProfile->MacAddr[0], pProfile->MacAddr[1], pProfile->MacAddr[2],pProfile->MacAddr[3],pProfile->MacAddr[4],pProfile->MacAddr[5]));*/ DBGPRINT(RT_DEBUG_ERROR, (" P2P -P2pPerstTabInsert to index = %x. Rule = %s.\n", i, decodeMyRule(Tab->PerstEntry[i].MyRule))); return i; } } } else if (index < MAX_P2P_TABLE_SIZE) { i = index; Tab->PerstEntry[i].bValid = TRUE; if (P2P_GO_ON(pAd)) Tab->PerstEntry[i].MyRule = P2P_IS_GO; else Tab->PerstEntry[i].MyRule = P2P_IS_CLIENT; RTMPMoveMemory(Tab->PerstEntry[i].Addr, pAddr, MAC_ADDR_LEN); RTMPMoveMemory(&Tab->PerstEntry[i].Profile, &pAd->StaCfg.WscControl.WscProfile.Profile[0], sizeof(WSC_CREDENTIAL)); pProfile = &Tab->PerstEntry[i].Profile; DBGPRINT(RT_DEBUG_ERROR, ("Perst::SsidLen = %d\n",pProfile->SSID.SsidLength)); DBGPRINT(RT_DEBUG_ERROR, ("Perst::Ssid = %c%c%c%c%c%c%c \n",pProfile->SSID.Ssid[0],pProfile->SSID.Ssid[1],pProfile->SSID.Ssid[2],pProfile->SSID.Ssid[3],pProfile->SSID.Ssid[4],pProfile->SSID.Ssid[5],pProfile->SSID.Ssid[6])); DBGPRINT(RT_DEBUG_ERROR, ("Perst::AuthType = 0x%x. EncrType = %d\n",pProfile->AuthType,pProfile->EncrType)); DBGPRINT(RT_DEBUG_ERROR, ("Perst::KeyIndex = %d\n",pProfile->KeyIndex)); DBGPRINT(RT_DEBUG_ERROR, ("Perst::KeyLength = %d\n",pProfile->KeyLength)); DBGPRINT(RT_DEBUG_ERROR, ("Perst::Key ==>\n")); for (j=0;j<16;) { DBGPRINT(RT_DEBUG_ERROR, (" 0x%x 0x%x 0x%x 0x%x\n",pProfile->Key[j], pProfile->Key[j+1], pProfile->Key[j+2],pProfile->Key[j+3])); j = j+4; } DBGPRINT(RT_DEBUG_ERROR, ("Perst::<===Key =\n")); DBGPRINT(RT_DEBUG_ERROR, ("Perst::MacAddr = %x %x %x %x %x %x\n",pProfile->MacAddr[0], pProfile->MacAddr[1], pProfile->MacAddr[2],pProfile->MacAddr[3],pProfile->MacAddr[4],pProfile->MacAddr[5])); DBGPRINT(RT_DEBUG_ERROR, (" P2P -P2pPerstTabInsert update to index = %x.\n", i)); return i; } DBGPRINT(RT_DEBUG_ERROR, ("P2P -P2pPerstTabInsert . PerstNumber = %d.\n", Tab->PerstNumber)); return index; }