⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rtmp_data.c

📁 Ralink RT61 SoftAP Driver source code. RT61:MiniPCI
💻 C
📖 第 1 页 / 共 5 页
字号:
                    {
                        // For TKIP frame, calculate the MIC value
                        if (pRxD->CipherAlg == CIPHER_TKIP)
                        {
                            PCIPHER_KEY pWpaKey;

                            if (!pEntry)
                        		break;
                       		pWpaKey = &pEntry->PairwiseKey;
                        
                            // Minus MIC length
                            pAd->FragFrame.RxSize -= 8;
                                                                    
                            if (pAd->FragFrame.Flags & 0x00000001)
                            {
                                // originally there's an LLC/SNAP field in the first fragment
                                // but been removed in re-assembly buffer. here we have to include
                                // this LLC/SNAP field upon calculating TKIP MIC
                                // pData = pAd->FragFrame.Header_LLC;
                                // Copy LLC data to the position in front of real data for MIC calculation
                                NdisMoveMemory(&pAd->FragFrame.Buffer[LENGTH_802_3 - LENGTH_802_1_H],
                                    pAd->FragFrame.Header_LLC, 
                                    LENGTH_802_1_H);
                                pData = (PUCHAR) &pAd->FragFrame.Buffer[LENGTH_802_3 - LENGTH_802_1_H];                                        
                                DataSize = (USHORT)pAd->FragFrame.RxSize + LENGTH_802_1_H;
                            }
                            else
                            {
                                pData = (PUCHAR) &pAd->FragFrame.Buffer[LENGTH_802_3];
                                DataSize = (USHORT)pAd->FragFrame.RxSize;
                            }
                        
                            if (RTMPTkipCompareMICValue(pAd,
                                                        pData,
                                                        pDA,
                                                        pSA,
                                                        pWpaKey->RxMic,
                                                        DataSize) == FALSE)
                            {
                                DBGPRINT(RT_DEBUG_ERROR,"Rx MIC Value error 2\n");                            
                                if (pEntry)
                                {
                                	HandleCounterMeasure(pAd, pEntry);
                                }
                                break;  // give up this frame
                            }
                                                    
                        }               

                        // check if DA is another associted WSTA reachable via wireless bridging,
                        // if it is, then no need to indicate to LLC
                        if (RTMPBridgeToWdsAndWirelessSta(pAd, pAd->FragFrame.Header802_3, LENGTH_802_3, &pAd->FragFrame.Buffer[LENGTH_802_3], pAd->FragFrame.RxSize, apidx) == FALSE)
                        {
                            pData = &pAd->FragFrame.Buffer[LENGTH_802_3];
                            REPORT_ETHERNET_FRAME_TO_LLC(pAd, pAd->FragFrame.Header802_3, pData, pAd->FragFrame.RxSize, net_dev);
							DBGPRINT(RT_DEBUG_INFO, "!!! report DATA (fragmented) to LLC (len=%d) !!!\n", pAd->FragFrame.RxSize);
                        }
                                
                        // Clear Fragment frame contents
                        NdisZeroMemory(&pAd->FragFrame, sizeof(FRAGMENT_FRAME));
                    }
                }
                break;
            }

            //
            // CASE II. receive a MGMT frame
            //
            else if (pHeader->FC.Type == BTYPE_MGMT)
            {
                if (pAd->PortCfg.MBSSID[apidx].BANClass3Data == TRUE)
                {
                    // disallow new association
                    if ((pHeader->FC.SubType == SUBTYPE_ASSOC_REQ) || (pHeader->FC.SubType == SUBTYPE_AUTH))
                    {
                        DBGPRINT(RT_DEBUG_TRACE, "Disallow new Association \n ");
                        break; // give up this frame
                    }
                }
                
                REPORT_MGMT_FRAME_TO_MLME(pAd, pHeader, pRxD->DataByteCnt, pRxD->PlcpRssi, Offset);
                break;  // end of processing this frame
            }

            //
            // CASE III. receive a CNTL frame
            //
            else if (pHeader->FC.Type == BTYPE_CNTL)
            {
                // handle PS-POLL here
                if ((pRxD->U2M) && (pHeader->FC.SubType == SUBTYPE_PS_POLL))
                {
                    PUCHAR pAddr = pHeader->Addr2;
                                        
                    pEntry = MacTableLookup(pAd, pAddr);
                	if (pEntry)
                	{
	                    if (pHeader->FC.PwrMgmt)
	                    	RTMPHandleRxPsPoll(pAd, pAddr, pEntry, FALSE);
						else
							RTMPHandleRxPsPoll(pAd, pAddr, pEntry, TRUE);
                	}
                }
                else
                {
                     DBGPRINT(RT_DEBUG_TRACE,"ignore CNTL (subtype=%d)\n", pHeader->FC.SubType);
                }
                break; // end of processing this frame
            }

            //
            // CASE IV. receive a frame of invalid type
            //
            else
                break; // give up this frame
        
        } while (FALSE);

        pRxD->Owner = DESC_OWN_NIC;
#ifdef BIG_ENDIAN
        RTMPDescriptorEndianChange((PUCHAR)pRxD, TYPE_RXD);    
        WriteBackToDescriptor((PUCHAR)pDestRxD, (PUCHAR)pRxD, FALSE, TYPE_RXD);
#endif
        INC_RING_INDEX(pAd->RxRing.CurRxIndex, RX_RING_SIZE);
    }
        
    // Make sure to release Rx ring resource
    RTMP_SEM_UNLOCK(&pAd->RxRingLock, IrqFlags);
}

/*
	========================================================================

	Routine	Description:
		Process	TxDone interrupt, running in	DPC	level

	Arguments:
		Adapter		Pointer	to our adapter

	Return Value:
		None

	Note:

	========================================================================
*/
VOID	RTMPHandleTxDoneInterrupt(
	IN	PRTMP_ADAPTER	pAd)
{
	STA_CSR4_STRUC csr;
	int i;
	UCHAR UpRate;

//	DBGPRINT(RT_DEBUG_INFO, ("====> RTMPHandleTxDoneInterrupt\n"));

    for (i=0; i<MAX_TX_DONE_PROCESS; i++)
    {
        RTMP_IO_READ32(pAd, STA_CSR4, &csr.word);
        if (! csr.field.bValid)
            break;

        pAd->RalinkCounters.OneSecTxDoneCount++;
        switch (csr.field.TxResult)
        {
    		case TX_RESULT_SUCCESS:			// Success with or without retry
		    	// DBGPRINT(RT_DEBUG_INFO, ("TX Success without retry<<<\n"));
	    		pAd->WlanCounters.TransmittedFragmentCount++;
    			pAd->Counters8023.GoodTransmits++;

                if ((csr.field.PidType == (PTYPE_SPECIAL >> 6)) && (csr.field.PidSubtype == PSUBTYPE_RTS))
                    pAd->WlanCounters.RTSSuccessCount++;
                    
                // case 1. no retry
                if (csr.field.RetryCount == 0)
                {
                    // update DRS related counters
                    if (csr.field.PidType == (PTYPE_DATA_REQUIRE_ACK >> 6))
                    {
                        pAd->RalinkCounters.OneSecTxNoRetryOkCount ++;

#ifdef APCLI_SUPPORT
						if (csr.field.PidSubtype >= APCLI_PAIRWISE_KEY_OFFSET)						
                            pAd->ApCliTab.ApCliEntry[csr.field.PidSubtype - APCLI_PAIRWISE_KEY_OFFSET].OneSecTxOkCount++;
                        else
#endif					
						if (csr.field.PidSubtype >= WDS_PAIRWISE_KEY_OFFSET)
                            pAd->WdsTab.WdsEntry[csr.field.PidSubtype - WDS_PAIRWISE_KEY_OFFSET].OneSecTxOkCount++;
						else
                        	// AP mode
                            pAd->MacTab.Content[csr.field.PidSubtype].OneSecTxOkCount++;
	
                    }
                }
                else
                {
                    // case 2. one or multiple retry
    			    pAd->WlanCounters.RetryCount++;
        			pAd->WlanCounters.ACKFailureCount++;
    			    if (csr.field.RetryCount > 1)
    			    {
    				    pAd->WlanCounters.MultipleRetryCount++;
    				    pAd->Counters8023.MoreCollisions++;
        			}
    	    		else
        				pAd->Counters8023.OneCollision++;
			
                    // update DRS related counters
                    if (csr.field.PidType == (PTYPE_NULL_AT_HIGH_RATE >> 6))
                    {
                        // DRS - must be NULL frame retried @ UpRate; downgrade 
                        //       TxQuality[UpRate] so that not upgrade TX rate
#ifdef APCLI_SUPPORT
						if (csr.field.PidSubtype >= APCLI_PAIRWISE_KEY_OFFSET)
                        {
							UCHAR ApCliIdx = (UCHAR)(csr.field.PidSubtype - APCLI_PAIRWISE_KEY_OFFSET);

                        	if (pAd->PortCfg.Channel > 14)
                            	UpRate = Phy11ANextRateUpward[pAd->ApCliTab.ApCliEntry[ApCliIdx].CurrTxRate];
                        	else
                            	UpRate = Phy11BGNextRateUpward[pAd->ApCliTab.ApCliEntry[ApCliIdx].CurrTxRate];
                        	
                            pAd->ApCliTab.ApCliEntry[ApCliIdx].TxQuality[UpRate] += 2;
                            if (pAd->ApCliTab.ApCliEntry[ApCliIdx].TxQuality[UpRate] > DRS_TX_QUALITY_WORST_BOUND)
                                pAd->ApCliTab.ApCliEntry[ApCliIdx].TxQuality[UpRate] = DRS_TX_QUALITY_WORST_BOUND;																		
                        }
						else // operate in WDS mode					
#endif					
						if (csr.field.PidSubtype >= WDS_PAIRWISE_KEY_OFFSET) 		
                        {
                            UCHAR WdsIdx = (UCHAR)(csr.field.PidSubtype - WDS_PAIRWISE_KEY_OFFSET);

                            if (pAd->PortCfg.Channel > 14)
                            	UpRate = Phy11ANextRateUpward[pAd->WdsTab.WdsEntry[WdsIdx].CurrTxRate];
                            else
                            	UpRate = Phy11BGNextRateUpward[pAd->WdsTab.WdsEntry[WdsIdx].CurrTxRate];
                            
                            pAd->WdsTab.WdsEntry[WdsIdx].TxQuality[UpRate] += 2;
                            if (pAd->WdsTab.WdsEntry[WdsIdx].TxQuality[UpRate] > DRS_TX_QUALITY_WORST_BOUND)
                                pAd->WdsTab.WdsEntry[WdsIdx].TxQuality[UpRate] = DRS_TX_QUALITY_WORST_BOUND;
                        }
						else  // operate in AP mode
                        {
                        	if (pAd->PortCfg.Channel > 14)
                        		UpRate = Phy11ANextRateUpward[pAd->MacTab.Content[csr.field.PidSubtype].CurrTxRate];
                        	else
                        		UpRate = Phy11BGNextRateUpward[pAd->MacTab.Content[csr.field.PidSubtype].CurrTxRate];
                        	
                            pAd->MacTab.Content[csr.field.PidSubtype].TxQuality[UpRate] += 2;
                            if (pAd->MacTab.Content[csr.field.PidSubtype].TxQuality[UpRate] > DRS_TX_QUALITY_WORST_BOUND)
                                pAd->MacTab.Content[csr.field.PidSubtype].TxQuality[UpRate] = DRS_TX_QUALITY_WORST_BOUND;
                        }
                    }
                    else if (csr.field.PidType == (PTYPE_DATA_REQUIRE_ACK >> 6))
                    {
                        pAd->RalinkCounters.OneSecTxRetryOkCount ++;
#ifdef APCLI_SUPPORT
						if (csr.field.PidSubtype >= APCLI_PAIRWISE_KEY_OFFSET)
							pAd->ApCliTab.ApCliEntry[csr.field.PidSubtype - APCLI_PAIRWISE_KEY_OFFSET].OneSecTxRetryOkCount++;
						else //WDS
#endif                    
                        if (csr.field.PidSubtype >= WDS_PAIRWISE_KEY_OFFSET)
                            pAd->WdsTab.WdsEntry[csr.field.PidSubtype - WDS_PAIRWISE_KEY_OFFSET].OneSecTxRetryOkCount++;
                        else //AP
                            pAd->MacTab.Content[csr.field.PidSubtype].OneSecTxRetryOkCount++;
                    }
                }
			    break;
			  
		    case TX_RESULT_RETRY_FAIL:				// Fail on hitting retry count limit
			    DBGPRINT(RT_DEBUG_INFO, "TX Failed (RETRY LIMIT)<<<\n");
			    pAd->WlanCounters.FailedCount++;
			    pAd->WlanCounters.ACKFailureCount++;
			    pAd->Counters8023.TxErrors++;
                if ((csr.field.PidType == (PTYPE_SPECIAL >> 6)) && (csr.field.PidSubtype == PSUBTYPE_RTS))
                    pAd->WlanCounters.RTSFailureCount++;
			
                // update DRS related counters
                if (csr.field.PidType == (PTYPE_NULL_AT_HIGH_RATE >> 6))
                {
                    // DRS - must be NULL frame failed @ UpRate; downgrade 
                    //       TxQuality[UpRate] so that not upgrade TX rate
#ifdef APCLI_SUPPORT
                    if (csr.field.PidSubtype >= APCLI_PAIRWISE_KEY_OFFSET)
                    {
                        UCHAR ApCliIdx = (UCHAR)(csr.field.PidSubtype - APCLI_PAIRWISE_KEY_OFFSET);

                        UpRate = Phy11BGNextRateUpward[pAd->ApCliTab.ApCliEntry[ApCliIdx].CurrTxRate];
                        pAd->ApCliTab.ApCliEntry[ApCliIdx].TxQuality[UpRate] = DRS_TX_QUALITY_WORST_BOUND;										
                    }
                    else
#endif
                    if (csr.field.PidSubtype >= WDS_PAIRWISE_KEY_OFFSET) // operate in AP mode
                    {
                        UCHAR WdsIdx = (UCHAR)(csr.field.PidSubtype - WDS_PAIRWISE_KEY_OFFSET);

                        UpRate = Phy11BGNextRateUpward[pAd->WdsTab.WdsEntry[WdsIdx].CurrTxRate];
                        pAd->WdsTab.WdsEnt

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -