2009-04-25 14:30:44 +00:00
/*
* Copyright ( c ) 1996 , 2003 VIA Networking Technologies , Inc .
* All rights reserved .
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation ; either version 2 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License along
* with this program ; if not , write to the Free Software Foundation , Inc . ,
* 51 Franklin Street , Fifth Floor , Boston , MA 02110 - 1301 USA .
*
* File : rxtx . c
*
* Purpose : handle WMAC / 802.3 / 802.11 rx & tx functions
*
* Author : Lyndon Chen
*
* Date : May 20 , 2003
*
* Functions :
2010-03-29 13:41:47 +00:00
* s_vGenerateTxParameter - Generate tx dma required parameter .
2009-04-25 14:30:44 +00:00
* vGenerateMACHeader - Translate 802.3 to 802.11 header
2012-08-20 15:43:15 +00:00
* cbGetFragCount - Calculate fragment number count
2009-04-25 14:30:44 +00:00
* csBeacon_xmit - beacon tx function
* csMgmt_xmit - management tx function
* s_cbFillTxBufHead - fulfill tx dma buffer header
* s_uGetDataDuration - get tx data required duration
* s_uFillDataHead - fulfill tx data duration header
2010-03-29 13:41:47 +00:00
* s_uGetRTSCTSDuration - get rtx / cts required duration
2009-04-25 14:30:44 +00:00
* s_uGetRTSCTSRsvTime - get rts / cts reserved time
* s_uGetTxRsvTime - get frame reserved time
* s_vFillCTSHead - fulfill CTS ctl header
2010-03-29 13:41:47 +00:00
* s_vFillFragParameter - Set fragment ctl parameter .
2009-04-25 14:30:44 +00:00
* s_vFillRTSHead - fulfill RTS ctl header
* s_vFillTxKey - fulfill tx encrypt key
* s_vSWencryption - Software encrypt header
* vDMA0_tx_80211 - tx 802.11 frame via dma0
* vGenerateFIFOHeader - Generate tx FIFO ctl header
*
* Revision History :
*
*/
# include "device.h"
# include "rxtx.h"
# include "tether.h"
# include "card.h"
# include "bssdb.h"
# include "mac.h"
# include "baseband.h"
# include "michael.h"
# include "tkip.h"
# include "tcrc.h"
# include "wctl.h"
# include "wroute.h"
# include "hostap.h"
# include "rf.h"
/*--------------------- Static Definitions -------------------------*/
/*--------------------- Static Classes ----------------------------*/
/*--------------------- Static Variables --------------------------*/
//static int msglevel =MSG_LEVEL_DEBUG;
static int msglevel = MSG_LEVEL_INFO ;
# define PLICE_DEBUG
/*--------------------- Static Functions --------------------------*/
/*--------------------- Static Definitions -------------------------*/
# define CRITICAL_PACKET_LEN 256 // if packet size < 256 -> in-direct send
// packet size >= 256 -> direct send
2010-06-24 18:02:26 +00:00
const unsigned short wTimeStampOff [ 2 ] [ MAX_RATE ] = {
2009-04-25 14:30:44 +00:00
{ 384 , 288 , 226 , 209 , 54 , 43 , 37 , 31 , 28 , 25 , 24 , 23 } , // Long Preamble
{ 384 , 192 , 130 , 113 , 54 , 43 , 37 , 31 , 28 , 25 , 24 , 23 } , // Short Preamble
} ;
2010-06-24 18:02:26 +00:00
const unsigned short wFB_Opt0 [ 2 ] [ 5 ] = {
2009-04-25 14:30:44 +00:00
{ RATE_12M , RATE_18M , RATE_24M , RATE_36M , RATE_48M } , // fallback_rate0
{ RATE_12M , RATE_12M , RATE_18M , RATE_24M , RATE_36M } , // fallback_rate1
} ;
2010-06-24 18:02:26 +00:00
const unsigned short wFB_Opt1 [ 2 ] [ 5 ] = {
2009-04-25 14:30:44 +00:00
{ RATE_12M , RATE_18M , RATE_24M , RATE_24M , RATE_36M } , // fallback_rate0
{ RATE_6M , RATE_6M , RATE_12M , RATE_12M , RATE_18M } , // fallback_rate1
} ;
# define RTSDUR_BB 0
# define RTSDUR_BA 1
# define RTSDUR_AA 2
# define CTSDUR_BA 3
# define RTSDUR_BA_F0 4
# define RTSDUR_AA_F0 5
# define RTSDUR_BA_F1 6
# define RTSDUR_AA_F1 7
# define CTSDUR_BA_F0 8
# define CTSDUR_BA_F1 9
# define DATADUR_B 10
# define DATADUR_A 11
# define DATADUR_A_F0 12
# define DATADUR_A_F1 13
/*--------------------- Static Functions --------------------------*/
static
2010-05-07 19:30:19 +00:00
void
2009-04-25 14:30:44 +00:00
s_vFillTxKey (
2010-05-13 03:54:39 +00:00
PSDevice pDevice ,
2010-06-05 22:13:47 +00:00
unsigned char * pbyBuf ,
unsigned char * pbyIVHead ,
2010-05-13 03:54:39 +00:00
PSKeyItem pTransmitKey ,
2010-06-05 22:13:47 +00:00
unsigned char * pbyHdrBuf ,
2010-06-24 18:02:26 +00:00
unsigned short wPayloadLen ,
2010-06-05 22:13:47 +00:00
unsigned char * pMICHDR
2009-04-25 14:30:44 +00:00
) ;
static
2010-05-07 19:30:19 +00:00
void
2009-04-25 14:30:44 +00:00
s_vFillRTSHead (
2010-05-13 03:54:39 +00:00
PSDevice pDevice ,
2010-06-24 18:02:27 +00:00
unsigned char byPktType ,
2010-05-13 03:54:39 +00:00
void * pvRTS ,
2010-06-02 16:52:01 +00:00
unsigned int cbFrameLength ,
2010-08-01 15:15:50 +00:00
bool bNeedAck ,
bool bDisCRC ,
2010-05-13 03:54:39 +00:00
PSEthernetHeader psEthHeader ,
2010-06-24 18:02:26 +00:00
unsigned short wCurrentRate ,
2010-06-24 18:02:27 +00:00
unsigned char byFBOption
2009-04-25 14:30:44 +00:00
) ;
static
2010-05-07 19:30:19 +00:00
void
2009-04-25 14:30:44 +00:00
s_vGenerateTxParameter (
2010-05-13 03:54:39 +00:00
PSDevice pDevice ,
2010-06-24 18:02:27 +00:00
unsigned char byPktType ,
2010-05-13 03:54:39 +00:00
void * pTxBufHead ,
void * pvRrvTime ,
void * pvRTS ,
void * pvCTS ,
2010-06-02 16:52:01 +00:00
unsigned int cbFrameSize ,
2010-08-01 15:15:50 +00:00
bool bNeedACK ,
2010-06-02 16:52:01 +00:00
unsigned int uDMAIdx ,
2010-05-13 03:54:39 +00:00
PSEthernetHeader psEthHeader ,
2010-06-24 18:02:26 +00:00
unsigned short wCurrentRate
2009-04-25 14:30:44 +00:00
) ;
static void s_vFillFragParameter (
2010-05-13 03:54:39 +00:00
PSDevice pDevice ,
2010-06-05 22:13:47 +00:00
unsigned char * pbyBuffer ,
2010-06-02 16:52:01 +00:00
unsigned int uTxType ,
2010-05-13 03:54:39 +00:00
void * pvtdCurr ,
2010-06-24 18:02:26 +00:00
unsigned short wFragType ,
2010-06-02 16:52:01 +00:00
unsigned int cbReqCount
2009-04-25 14:30:44 +00:00
) ;
2010-06-25 17:48:53 +00:00
static unsigned int
s_cbFillTxBufHead ( PSDevice pDevice , unsigned char byPktType , unsigned char * pbyTxBufferAddr ,
unsigned int cbFrameBodySize , unsigned int uDMAIdx , PSTxDesc pHeadTD ,
2010-08-01 15:15:50 +00:00
PSEthernetHeader psEthHeader , unsigned char * pPacket , bool bNeedEncrypt ,
2010-06-25 17:48:53 +00:00
PSKeyItem pTransmitKey , unsigned int uNodeIndex , unsigned int * puMACfragNum ) ;
2009-04-25 14:30:44 +00:00
static
2010-06-02 16:52:01 +00:00
unsigned int
2009-04-25 14:30:44 +00:00
s_uFillDataHead (
2010-05-13 03:54:39 +00:00
PSDevice pDevice ,
2010-06-24 18:02:27 +00:00
unsigned char byPktType ,
2010-05-13 03:54:39 +00:00
void * pTxDataHead ,
2010-06-02 16:52:01 +00:00
unsigned int cbFrameLength ,
unsigned int uDMAIdx ,
2010-08-01 15:15:50 +00:00
bool bNeedAck ,
2010-06-02 16:52:01 +00:00
unsigned int uFragIdx ,
unsigned int cbLastFragmentSize ,
unsigned int uMACfragNum ,
2010-06-24 18:02:27 +00:00
unsigned char byFBOption ,
2010-06-24 18:02:26 +00:00
unsigned short wCurrentRate
2009-04-25 14:30:44 +00:00
) ;
/*--------------------- Export Variables --------------------------*/
static
2010-05-07 19:30:19 +00:00
void
2009-04-25 14:30:44 +00:00
s_vFillTxKey (
2010-05-13 03:54:39 +00:00
PSDevice pDevice ,
2010-06-05 22:13:47 +00:00
unsigned char * pbyBuf ,
unsigned char * pbyIVHead ,
2010-05-13 03:54:39 +00:00
PSKeyItem pTransmitKey ,
2010-06-05 22:13:47 +00:00
unsigned char * pbyHdrBuf ,
2010-06-24 18:02:26 +00:00
unsigned short wPayloadLen ,
2010-06-05 22:13:47 +00:00
unsigned char * pMICHDR
2009-04-25 14:30:44 +00:00
)
{
2010-06-05 22:13:49 +00:00
unsigned long * pdwIV = ( unsigned long * ) pbyIVHead ;
unsigned long * pdwExtIV = ( unsigned long * ) ( ( unsigned char * ) pbyIVHead + 4 ) ;
2010-06-24 18:02:26 +00:00
unsigned short wValue ;
2009-04-25 14:30:44 +00:00
PS802_11Header pMACHeader = ( PS802_11Header ) pbyHdrBuf ;
2010-06-24 18:02:25 +00:00
unsigned long dwRevIVCounter ;
2010-06-24 18:02:27 +00:00
unsigned char byKeyIndex = 0 ;
2009-04-25 14:30:44 +00:00
//Fill TXKEY
if ( pTransmitKey = = NULL )
return ;
dwRevIVCounter = cpu_to_le32 ( pDevice - > dwIVCounter ) ;
* pdwIV = pDevice - > dwIVCounter ;
byKeyIndex = pTransmitKey - > dwKeyIndex & 0xf ;
if ( pTransmitKey - > byCipherSuite = = KEY_CTL_WEP ) {
if ( pTransmitKey - > uKeyLength = = WLAN_WEP232_KEYLEN ) {
2010-06-05 22:13:47 +00:00
memcpy ( pDevice - > abyPRNG , ( unsigned char * ) & ( dwRevIVCounter ) , 3 ) ;
2009-08-12 21:54:10 +00:00
memcpy ( pDevice - > abyPRNG + 3 , pTransmitKey - > abyKey , pTransmitKey - > uKeyLength ) ;
2009-04-25 14:30:44 +00:00
} else {
2010-06-05 22:13:47 +00:00
memcpy ( pbyBuf , ( unsigned char * ) & ( dwRevIVCounter ) , 3 ) ;
2009-08-12 21:54:10 +00:00
memcpy ( pbyBuf + 3 , pTransmitKey - > abyKey , pTransmitKey - > uKeyLength ) ;
2009-04-25 14:30:44 +00:00
if ( pTransmitKey - > uKeyLength = = WLAN_WEP40_KEYLEN ) {
2010-06-05 22:13:47 +00:00
memcpy ( pbyBuf + 8 , ( unsigned char * ) & ( dwRevIVCounter ) , 3 ) ;
2009-08-12 21:54:10 +00:00
memcpy ( pbyBuf + 11 , pTransmitKey - > abyKey , pTransmitKey - > uKeyLength ) ;
2009-04-25 14:30:44 +00:00
}
2009-08-12 21:54:10 +00:00
memcpy ( pDevice - > abyPRNG , pbyBuf , 16 ) ;
2009-04-25 14:30:44 +00:00
}
// Append IV after Mac Header
* pdwIV & = WEP_IV_MASK ; //00000000 11111111 11111111 11111111
2012-10-11 06:54:05 +00:00
* pdwIV | = ( unsigned long ) byKeyIndex < < 30 ;
2009-04-25 14:30:44 +00:00
* pdwIV = cpu_to_le32 ( * pdwIV ) ;
pDevice - > dwIVCounter + + ;
if ( pDevice - > dwIVCounter > WEP_IV_MASK ) {
pDevice - > dwIVCounter = 0 ;
}
} else if ( pTransmitKey - > byCipherSuite = = KEY_CTL_TKIP ) {
pTransmitKey - > wTSC15_0 + + ;
if ( pTransmitKey - > wTSC15_0 = = 0 ) {
pTransmitKey - > dwTSC47_16 + + ;
}
TKIPvMixKey ( pTransmitKey - > abyKey , pDevice - > abyCurrentNetAddr ,
pTransmitKey - > wTSC15_0 , pTransmitKey - > dwTSC47_16 , pDevice - > abyPRNG ) ;
2009-08-12 21:54:10 +00:00
memcpy ( pbyBuf , pDevice - > abyPRNG , 16 ) ;
2009-04-25 14:30:44 +00:00
// Make IV
2009-08-12 21:54:10 +00:00
memcpy ( pdwIV , pDevice - > abyPRNG , 3 ) ;
2009-04-25 14:30:44 +00:00
2010-06-24 18:02:27 +00:00
* ( pbyIVHead + 3 ) = ( unsigned char ) ( ( ( byKeyIndex < < 6 ) & 0xc0 ) | 0x20 ) ; // 0x20 is ExtIV
2009-04-25 14:30:44 +00:00
// Append IV&ExtIV after Mac Header
* pdwExtIV = cpu_to_le32 ( pTransmitKey - > dwTSC47_16 ) ;
2009-07-30 17:27:21 +00:00
DBG_PRT ( MSG_LEVEL_DEBUG , KERN_INFO " vFillTxKey()---- pdwExtIV: %lx \n " , * pdwExtIV ) ;
2009-04-25 14:30:44 +00:00
} else if ( pTransmitKey - > byCipherSuite = = KEY_CTL_CCMP ) {
pTransmitKey - > wTSC15_0 + + ;
if ( pTransmitKey - > wTSC15_0 = = 0 ) {
pTransmitKey - > dwTSC47_16 + + ;
}
2009-08-12 21:54:10 +00:00
memcpy ( pbyBuf , pTransmitKey - > abyKey , 16 ) ;
2009-04-25 14:30:44 +00:00
// Make IV
* pdwIV = 0 ;
2010-06-24 18:02:27 +00:00
* ( pbyIVHead + 3 ) = ( unsigned char ) ( ( ( byKeyIndex < < 6 ) & 0xc0 ) | 0x20 ) ; // 0x20 is ExtIV
2010-06-24 18:02:26 +00:00
* pdwIV | = cpu_to_le16 ( ( unsigned short ) ( pTransmitKey - > wTSC15_0 ) ) ;
2009-04-25 14:30:44 +00:00
//Append IV&ExtIV after Mac Header
* pdwExtIV = cpu_to_le32 ( pTransmitKey - > dwTSC47_16 ) ;
//Fill MICHDR0
* pMICHDR = 0x59 ;
2010-06-05 22:13:47 +00:00
* ( ( unsigned char * ) ( pMICHDR + 1 ) ) = 0 ; // TxPriority
2009-08-12 21:54:10 +00:00
memcpy ( pMICHDR + 2 , & ( pMACHeader - > abyAddr2 [ 0 ] ) , 6 ) ;
2010-06-05 22:13:47 +00:00
* ( ( unsigned char * ) ( pMICHDR + 8 ) ) = HIBYTE ( HIWORD ( pTransmitKey - > dwTSC47_16 ) ) ;
* ( ( unsigned char * ) ( pMICHDR + 9 ) ) = LOBYTE ( HIWORD ( pTransmitKey - > dwTSC47_16 ) ) ;
* ( ( unsigned char * ) ( pMICHDR + 10 ) ) = HIBYTE ( LOWORD ( pTransmitKey - > dwTSC47_16 ) ) ;
* ( ( unsigned char * ) ( pMICHDR + 11 ) ) = LOBYTE ( LOWORD ( pTransmitKey - > dwTSC47_16 ) ) ;
* ( ( unsigned char * ) ( pMICHDR + 12 ) ) = HIBYTE ( pTransmitKey - > wTSC15_0 ) ;
* ( ( unsigned char * ) ( pMICHDR + 13 ) ) = LOBYTE ( pTransmitKey - > wTSC15_0 ) ;
* ( ( unsigned char * ) ( pMICHDR + 14 ) ) = HIBYTE ( wPayloadLen ) ;
* ( ( unsigned char * ) ( pMICHDR + 15 ) ) = LOBYTE ( wPayloadLen ) ;
2009-04-25 14:30:44 +00:00
//Fill MICHDR1
2010-06-05 22:13:47 +00:00
* ( ( unsigned char * ) ( pMICHDR + 16 ) ) = 0 ; // HLEN[15:8]
2009-04-25 14:30:44 +00:00
if ( pDevice - > bLongHeader ) {
2010-06-05 22:13:47 +00:00
* ( ( unsigned char * ) ( pMICHDR + 17 ) ) = 28 ; // HLEN[7:0]
2009-04-25 14:30:44 +00:00
} else {
2010-06-05 22:13:47 +00:00
* ( ( unsigned char * ) ( pMICHDR + 17 ) ) = 22 ; // HLEN[7:0]
2009-04-25 14:30:44 +00:00
}
wValue = cpu_to_le16 ( pMACHeader - > wFrameCtl & 0xC78F ) ;
2010-06-05 22:13:47 +00:00
memcpy ( pMICHDR + 18 , ( unsigned char * ) & wValue , 2 ) ; // MSKFRACTL
2009-08-12 21:54:10 +00:00
memcpy ( pMICHDR + 20 , & ( pMACHeader - > abyAddr1 [ 0 ] ) , 6 ) ;
memcpy ( pMICHDR + 26 , & ( pMACHeader - > abyAddr2 [ 0 ] ) , 6 ) ;
2009-04-25 14:30:44 +00:00
//Fill MICHDR2
2009-08-12 21:54:10 +00:00
memcpy ( pMICHDR + 32 , & ( pMACHeader - > abyAddr3 [ 0 ] ) , 6 ) ;
2009-04-25 14:30:44 +00:00
wValue = pMACHeader - > wSeqCtl ;
wValue & = 0x000F ;
wValue = cpu_to_le16 ( wValue ) ;
2010-06-05 22:13:47 +00:00
memcpy ( pMICHDR + 38 , ( unsigned char * ) & wValue , 2 ) ; // MSKSEQCTL
2009-04-25 14:30:44 +00:00
if ( pDevice - > bLongHeader ) {
2009-08-12 21:54:10 +00:00
memcpy ( pMICHDR + 40 , & ( pMACHeader - > abyAddr4 [ 0 ] ) , 6 ) ;
2009-04-25 14:30:44 +00:00
}
}
}
static
2010-05-07 19:30:19 +00:00
void
2009-04-25 14:30:44 +00:00
s_vSWencryption (
2010-05-13 03:54:39 +00:00
PSDevice pDevice ,
PSKeyItem pTransmitKey ,
2010-06-05 22:13:47 +00:00
unsigned char * pbyPayloadHead ,
2010-06-24 18:02:26 +00:00
unsigned short wPayloadSize
2009-04-25 14:30:44 +00:00
)
{
2010-06-02 16:52:01 +00:00
unsigned int cbICVlen = 4 ;
2010-06-24 18:02:25 +00:00
unsigned long dwICV = 0xFFFFFFFFL ;
2010-06-05 22:13:49 +00:00
unsigned long * pdwICV ;
2009-04-25 14:30:44 +00:00
if ( pTransmitKey = = NULL )
return ;
if ( pTransmitKey - > byCipherSuite = = KEY_CTL_WEP ) {
//=======================================================================
// Append ICV after payload
dwICV = CRCdwGetCrc32Ex ( pbyPayloadHead , wPayloadSize , dwICV ) ; //ICV(Payload)
2010-06-05 22:13:49 +00:00
pdwICV = ( unsigned long * ) ( pbyPayloadHead + wPayloadSize ) ;
2009-04-25 14:30:44 +00:00
// finally, we must invert dwCRC to get the correct answer
* pdwICV = cpu_to_le32 ( ~ dwICV ) ;
// RC4 encryption
rc4_init ( & pDevice - > SBox , pDevice - > abyPRNG , pTransmitKey - > uKeyLength + 3 ) ;
rc4_encrypt ( & pDevice - > SBox , pbyPayloadHead , pbyPayloadHead , wPayloadSize + cbICVlen ) ;
//=======================================================================
} else if ( pTransmitKey - > byCipherSuite = = KEY_CTL_TKIP ) {
//=======================================================================
//Append ICV after payload
dwICV = CRCdwGetCrc32Ex ( pbyPayloadHead , wPayloadSize , dwICV ) ; //ICV(Payload)
2010-06-05 22:13:49 +00:00
pdwICV = ( unsigned long * ) ( pbyPayloadHead + wPayloadSize ) ;
2009-04-25 14:30:44 +00:00
// finally, we must invert dwCRC to get the correct answer
* pdwICV = cpu_to_le32 ( ~ dwICV ) ;
// RC4 encryption
rc4_init ( & pDevice - > SBox , pDevice - > abyPRNG , TKIP_KEY_LEN ) ;
rc4_encrypt ( & pDevice - > SBox , pbyPayloadHead , pbyPayloadHead , wPayloadSize + cbICVlen ) ;
//=======================================================================
}
}
2009-07-30 17:27:21 +00:00
/*byPktType : PK_TYPE_11A 0
2009-04-25 14:30:44 +00:00
PK_TYPE_11B 1
PK_TYPE_11GB 2
PK_TYPE_11GA 3
*/
static
2010-06-02 16:52:01 +00:00
unsigned int
2009-04-25 14:30:44 +00:00
s_uGetTxRsvTime (
2010-05-13 03:54:39 +00:00
PSDevice pDevice ,
2010-06-24 18:02:27 +00:00
unsigned char byPktType ,
2010-06-02 16:52:01 +00:00
unsigned int cbFrameLength ,
2010-06-24 18:02:26 +00:00
unsigned short wRate ,
2010-08-01 15:15:50 +00:00
bool bNeedAck
2009-04-25 14:30:44 +00:00
)
{
2010-06-02 16:52:01 +00:00
unsigned int uDataTime , uAckTime ;
2009-04-25 14:30:44 +00:00
2009-07-30 17:27:21 +00:00
uDataTime = BBuGetFrameTime ( pDevice - > byPreambleType , byPktType , cbFrameLength , wRate ) ;
2009-04-25 14:30:44 +00:00
# ifdef PLICE_DEBUG
//printk("s_uGetTxRsvTime is %d\n",uDataTime);
# endif
2009-07-30 17:27:21 +00:00
if ( byPktType = = PK_TYPE_11B ) { //llb,CCK mode
2010-06-24 18:02:26 +00:00
uAckTime = BBuGetFrameTime ( pDevice - > byPreambleType , byPktType , 14 , ( unsigned short ) pDevice - > byTopCCKBasicRate ) ;
2009-04-25 14:30:44 +00:00
} else { //11g 2.4G OFDM mode & 11a 5G OFDM mode
2010-06-24 18:02:26 +00:00
uAckTime = BBuGetFrameTime ( pDevice - > byPreambleType , byPktType , 14 , ( unsigned short ) pDevice - > byTopOFDMBasicRate ) ;
2009-04-25 14:30:44 +00:00
}
if ( bNeedAck ) {
return ( uDataTime + pDevice - > uSIFS + uAckTime ) ;
}
else {
return uDataTime ;
}
}
//byFreqType: 0=>5GHZ 1=>2.4GHZ
static
2010-06-02 16:52:01 +00:00
unsigned int
2009-04-25 14:30:44 +00:00
s_uGetRTSCTSRsvTime (
2010-05-13 03:54:39 +00:00
PSDevice pDevice ,
2010-06-24 18:02:27 +00:00
unsigned char byRTSRsvType ,
unsigned char byPktType ,
2010-06-02 16:52:01 +00:00
unsigned int cbFrameLength ,
2010-06-24 18:02:26 +00:00
unsigned short wCurrentRate
2009-04-25 14:30:44 +00:00
)
{
2010-06-02 16:52:01 +00:00
unsigned int uRrvTime , uRTSTime , uCTSTime , uAckTime , uDataTime ;
2009-04-25 14:30:44 +00:00
uRrvTime = uRTSTime = uCTSTime = uAckTime = uDataTime = 0 ;
2009-07-30 17:27:21 +00:00
uDataTime = BBuGetFrameTime ( pDevice - > byPreambleType , byPktType , cbFrameLength , wCurrentRate ) ;
2009-04-25 14:30:44 +00:00
if ( byRTSRsvType = = 0 ) { //RTSTxRrvTime_bb
2009-07-30 17:27:21 +00:00
uRTSTime = BBuGetFrameTime ( pDevice - > byPreambleType , byPktType , 20 , pDevice - > byTopCCKBasicRate ) ;
uCTSTime = uAckTime = BBuGetFrameTime ( pDevice - > byPreambleType , byPktType , 14 , pDevice - > byTopCCKBasicRate ) ;
2009-04-25 14:30:44 +00:00
}
else if ( byRTSRsvType = = 1 ) { //RTSTxRrvTime_ba, only in 2.4GHZ
2009-07-30 17:27:21 +00:00
uRTSTime = BBuGetFrameTime ( pDevice - > byPreambleType , byPktType , 20 , pDevice - > byTopCCKBasicRate ) ;
uCTSTime = BBuGetFrameTime ( pDevice - > byPreambleType , byPktType , 14 , pDevice - > byTopCCKBasicRate ) ;
uAckTime = BBuGetFrameTime ( pDevice - > byPreambleType , byPktType , 14 , pDevice - > byTopOFDMBasicRate ) ;
2009-04-25 14:30:44 +00:00
}
else if ( byRTSRsvType = = 2 ) { //RTSTxRrvTime_aa
2009-07-30 17:27:21 +00:00
uRTSTime = BBuGetFrameTime ( pDevice - > byPreambleType , byPktType , 20 , pDevice - > byTopOFDMBasicRate ) ;
uCTSTime = uAckTime = BBuGetFrameTime ( pDevice - > byPreambleType , byPktType , 14 , pDevice - > byTopOFDMBasicRate ) ;
2009-04-25 14:30:44 +00:00
}
else if ( byRTSRsvType = = 3 ) { //CTSTxRrvTime_ba, only in 2.4GHZ
2009-07-30 17:27:21 +00:00
uCTSTime = BBuGetFrameTime ( pDevice - > byPreambleType , byPktType , 14 , pDevice - > byTopCCKBasicRate ) ;
uAckTime = BBuGetFrameTime ( pDevice - > byPreambleType , byPktType , 14 , pDevice - > byTopOFDMBasicRate ) ;
2009-04-25 14:30:44 +00:00
uRrvTime = uCTSTime + uAckTime + uDataTime + 2 * pDevice - > uSIFS ;
return uRrvTime ;
}
//RTSRrvTime
uRrvTime = uRTSTime + uCTSTime + uAckTime + uDataTime + 3 * pDevice - > uSIFS ;
return uRrvTime ;
}
//byFreqType 0: 5GHz, 1:2.4Ghz
static
2010-06-02 16:52:01 +00:00
unsigned int
2009-04-25 14:30:44 +00:00
s_uGetDataDuration (
2010-05-13 03:54:39 +00:00
PSDevice pDevice ,
2010-06-24 18:02:27 +00:00
unsigned char byDurType ,
2010-06-02 16:52:01 +00:00
unsigned int cbFrameLength ,
2010-06-24 18:02:27 +00:00
unsigned char byPktType ,
2010-06-24 18:02:26 +00:00
unsigned short wRate ,
2010-08-01 15:15:50 +00:00
bool bNeedAck ,
2010-06-02 16:52:01 +00:00
unsigned int uFragIdx ,
unsigned int cbLastFragmentSize ,
unsigned int uMACfragNum ,
2010-06-24 18:02:27 +00:00
unsigned char byFBOption
2009-04-25 14:30:44 +00:00
)
{
2010-08-01 15:15:50 +00:00
bool bLastFrag = 0 ;
2010-06-02 16:52:01 +00:00
unsigned int uAckTime = 0 , uNextPktTime = 0 ;
2009-04-25 14:30:44 +00:00
if ( uFragIdx = = ( uMACfragNum - 1 ) ) {
bLastFrag = 1 ;
}
switch ( byDurType ) {
case DATADUR_B : //DATADUR_B
if ( ( ( uMACfragNum = = 1 ) ) | | ( bLastFrag = = 1 ) ) { //Non Frag or Last Frag
if ( bNeedAck ) {
uAckTime = BBuGetFrameTime ( pDevice - > byPreambleType , byPktType , 14 , pDevice - > byTopCCKBasicRate ) ;
return ( pDevice - > uSIFS + uAckTime ) ;
} else {
return 0 ;
}
}
else { //First Frag or Mid Frag
if ( uFragIdx = = ( uMACfragNum - 2 ) ) {
uNextPktTime = s_uGetTxRsvTime ( pDevice , byPktType , cbLastFragmentSize , wRate , bNeedAck ) ;
} else {
uNextPktTime = s_uGetTxRsvTime ( pDevice , byPktType , cbFrameLength , wRate , bNeedAck ) ;
}
if ( bNeedAck ) {
uAckTime = BBuGetFrameTime ( pDevice - > byPreambleType , byPktType , 14 , pDevice - > byTopCCKBasicRate ) ;
return ( pDevice - > uSIFS + uAckTime + uNextPktTime ) ;
} else {
return ( pDevice - > uSIFS + uNextPktTime ) ;
}
}
break ;
case DATADUR_A : //DATADUR_A
if ( ( ( uMACfragNum = = 1 ) ) | | ( bLastFrag = = 1 ) ) { //Non Frag or Last Frag
if ( bNeedAck ) {
uAckTime = BBuGetFrameTime ( pDevice - > byPreambleType , byPktType , 14 , pDevice - > byTopOFDMBasicRate ) ;
return ( pDevice - > uSIFS + uAckTime ) ;
} else {
return 0 ;
}
}
else { //First Frag or Mid Frag
if ( uFragIdx = = ( uMACfragNum - 2 ) ) {
uNextPktTime = s_uGetTxRsvTime ( pDevice , byPktType , cbLastFragmentSize , wRate , bNeedAck ) ;
} else {
uNextPktTime = s_uGetTxRsvTime ( pDevice , byPktType , cbFrameLength , wRate , bNeedAck ) ;
}
if ( bNeedAck ) {
uAckTime = BBuGetFrameTime ( pDevice - > byPreambleType , byPktType , 14 , pDevice - > byTopOFDMBasicRate ) ;
return ( pDevice - > uSIFS + uAckTime + uNextPktTime ) ;
} else {
return ( pDevice - > uSIFS + uNextPktTime ) ;
}
}
break ;
case DATADUR_A_F0 : //DATADUR_A_F0
if ( ( ( uMACfragNum = = 1 ) ) | | ( bLastFrag = = 1 ) ) { //Non Frag or Last Frag
if ( bNeedAck ) {
uAckTime = BBuGetFrameTime ( pDevice - > byPreambleType , byPktType , 14 , pDevice - > byTopOFDMBasicRate ) ;
return ( pDevice - > uSIFS + uAckTime ) ;
} else {
return 0 ;
}
}
else { //First Frag or Mid Frag
if ( byFBOption = = AUTO_FB_0 ) {
if ( wRate < RATE_18M )
wRate = RATE_18M ;
else if ( wRate > RATE_54M )
wRate = RATE_54M ;
if ( uFragIdx = = ( uMACfragNum - 2 ) ) {
uNextPktTime = s_uGetTxRsvTime ( pDevice , byPktType , cbLastFragmentSize , wFB_Opt0 [ FB_RATE0 ] [ wRate - RATE_18M ] , bNeedAck ) ;
} else {
uNextPktTime = s_uGetTxRsvTime ( pDevice , byPktType , cbFrameLength , wFB_Opt0 [ FB_RATE0 ] [ wRate - RATE_18M ] , bNeedAck ) ;
}
} else { // (byFBOption == AUTO_FB_1)
if ( wRate < RATE_18M )
wRate = RATE_18M ;
else if ( wRate > RATE_54M )
wRate = RATE_54M ;
if ( uFragIdx = = ( uMACfragNum - 2 ) ) {
uNextPktTime = s_uGetTxRsvTime ( pDevice , byPktType , cbLastFragmentSize , wFB_Opt1 [ FB_RATE0 ] [ wRate - RATE_18M ] , bNeedAck ) ;
} else {
uNextPktTime = s_uGetTxRsvTime ( pDevice , byPktType , cbFrameLength , wFB_Opt1 [ FB_RATE0 ] [ wRate - RATE_18M ] , bNeedAck ) ;
}
}
if ( bNeedAck ) {
uAckTime = BBuGetFrameTime ( pDevice - > byPreambleType , byPktType , 14 , pDevice - > byTopOFDMBasicRate ) ;
return ( pDevice - > uSIFS + uAckTime + uNextPktTime ) ;
} else {
return ( pDevice - > uSIFS + uNextPktTime ) ;
}
}
break ;
case DATADUR_A_F1 : //DATADUR_A_F1
if ( ( ( uMACfragNum = = 1 ) ) | | ( bLastFrag = = 1 ) ) { //Non Frag or Last Frag
if ( bNeedAck ) {
uAckTime = BBuGetFrameTime ( pDevice - > byPreambleType , byPktType , 14 , pDevice - > byTopOFDMBasicRate ) ;
return ( pDevice - > uSIFS + uAckTime ) ;
} else {
return 0 ;
}
}
else { //First Frag or Mid Frag
if ( byFBOption = = AUTO_FB_0 ) {
if ( wRate < RATE_18M )
wRate = RATE_18M ;
else if ( wRate > RATE_54M )
wRate = RATE_54M ;
if ( uFragIdx = = ( uMACfragNum - 2 ) ) {
uNextPktTime = s_uGetTxRsvTime ( pDevice , byPktType , cbLastFragmentSize , wFB_Opt0 [ FB_RATE1 ] [ wRate - RATE_18M ] , bNeedAck ) ;
} else {
uNextPktTime = s_uGetTxRsvTime ( pDevice , byPktType , cbFrameLength , wFB_Opt0 [ FB_RATE1 ] [ wRate - RATE_18M ] , bNeedAck ) ;
}
} else { // (byFBOption == AUTO_FB_1)
if ( wRate < RATE_18M )
wRate = RATE_18M ;
else if ( wRate > RATE_54M )
wRate = RATE_54M ;
if ( uFragIdx = = ( uMACfragNum - 2 ) ) {
uNextPktTime = s_uGetTxRsvTime ( pDevice , byPktType , cbLastFragmentSize , wFB_Opt1 [ FB_RATE1 ] [ wRate - RATE_18M ] , bNeedAck ) ;
} else {
uNextPktTime = s_uGetTxRsvTime ( pDevice , byPktType , cbFrameLength , wFB_Opt1 [ FB_RATE1 ] [ wRate - RATE_18M ] , bNeedAck ) ;
}
}
if ( bNeedAck ) {
uAckTime = BBuGetFrameTime ( pDevice - > byPreambleType , byPktType , 14 , pDevice - > byTopOFDMBasicRate ) ;
return ( pDevice - > uSIFS + uAckTime + uNextPktTime ) ;
} else {
return ( pDevice - > uSIFS + uNextPktTime ) ;
}
}
break ;
default :
break ;
}
2010-08-01 15:15:49 +00:00
ASSERT ( false ) ;
2009-04-25 14:30:44 +00:00
return 0 ;
}
//byFreqType: 0=>5GHZ 1=>2.4GHZ
static
2010-06-02 16:52:01 +00:00
unsigned int
2009-04-25 14:30:44 +00:00
s_uGetRTSCTSDuration (
2010-05-13 03:54:39 +00:00
PSDevice pDevice ,
2010-06-24 18:02:27 +00:00
unsigned char byDurType ,
2010-06-02 16:52:01 +00:00
unsigned int cbFrameLength ,
2010-06-24 18:02:27 +00:00
unsigned char byPktType ,
2010-06-24 18:02:26 +00:00
unsigned short wRate ,
2010-08-01 15:15:50 +00:00
bool bNeedAck ,
2010-06-24 18:02:27 +00:00
unsigned char byFBOption
2009-04-25 14:30:44 +00:00
)
{
2010-06-02 16:52:01 +00:00
unsigned int uCTSTime = 0 , uDurTime = 0 ;
2009-04-25 14:30:44 +00:00
switch ( byDurType ) {
case RTSDUR_BB : //RTSDuration_bb
uCTSTime = BBuGetFrameTime ( pDevice - > byPreambleType , byPktType , 14 , pDevice - > byTopCCKBasicRate ) ;
uDurTime = uCTSTime + 2 * pDevice - > uSIFS + s_uGetTxRsvTime ( pDevice , byPktType , cbFrameLength , wRate , bNeedAck ) ;
break ;
case RTSDUR_BA : //RTSDuration_ba
uCTSTime = BBuGetFrameTime ( pDevice - > byPreambleType , byPktType , 14 , pDevice - > byTopCCKBasicRate ) ;
uDurTime = uCTSTime + 2 * pDevice - > uSIFS + s_uGetTxRsvTime ( pDevice , byPktType , cbFrameLength , wRate , bNeedAck ) ;
break ;
case RTSDUR_AA : //RTSDuration_aa
uCTSTime = BBuGetFrameTime ( pDevice - > byPreambleType , byPktType , 14 , pDevice - > byTopOFDMBasicRate ) ;
uDurTime = uCTSTime + 2 * pDevice - > uSIFS + s_uGetTxRsvTime ( pDevice , byPktType , cbFrameLength , wRate , bNeedAck ) ;
break ;
case CTSDUR_BA : //CTSDuration_ba
uDurTime = pDevice - > uSIFS + s_uGetTxRsvTime ( pDevice , byPktType , cbFrameLength , wRate , bNeedAck ) ;
break ;
case RTSDUR_BA_F0 : //RTSDuration_ba_f0
uCTSTime = BBuGetFrameTime ( pDevice - > byPreambleType , byPktType , 14 , pDevice - > byTopCCKBasicRate ) ;
if ( ( byFBOption = = AUTO_FB_0 ) & & ( wRate > = RATE_18M ) & & ( wRate < = RATE_54M ) ) {
uDurTime = uCTSTime + 2 * pDevice - > uSIFS + s_uGetTxRsvTime ( pDevice , byPktType , cbFrameLength , wFB_Opt0 [ FB_RATE0 ] [ wRate - RATE_18M ] , bNeedAck ) ;
} else if ( ( byFBOption = = AUTO_FB_1 ) & & ( wRate > = RATE_18M ) & & ( wRate < = RATE_54M ) ) {
uDurTime = uCTSTime + 2 * pDevice - > uSIFS + s_uGetTxRsvTime ( pDevice , byPktType , cbFrameLength , wFB_Opt1 [ FB_RATE0 ] [ wRate - RATE_18M ] , bNeedAck ) ;
}
break ;
case RTSDUR_AA_F0 : //RTSDuration_aa_f0
uCTSTime = BBuGetFrameTime ( pDevice - > byPreambleType , byPktType , 14 , pDevice - > byTopOFDMBasicRate ) ;
if ( ( byFBOption = = AUTO_FB_0 ) & & ( wRate > = RATE_18M ) & & ( wRate < = RATE_54M ) ) {
uDurTime = uCTSTime + 2 * pDevice - > uSIFS + s_uGetTxRsvTime ( pDevice , byPktType , cbFrameLength , wFB_Opt0 [ FB_RATE0 ] [ wRate - RATE_18M ] , bNeedAck ) ;
} else if ( ( byFBOption = = AUTO_FB_1 ) & & ( wRate > = RATE_18M ) & & ( wRate < = RATE_54M ) ) {
uDurTime = uCTSTime + 2 * pDevice - > uSIFS + s_uGetTxRsvTime ( pDevice , byPktType , cbFrameLength , wFB_Opt1 [ FB_RATE0 ] [ wRate - RATE_18M ] , bNeedAck ) ;
}
break ;
case RTSDUR_BA_F1 : //RTSDuration_ba_f1
uCTSTime = BBuGetFrameTime ( pDevice - > byPreambleType , byPktType , 14 , pDevice - > byTopCCKBasicRate ) ;
if ( ( byFBOption = = AUTO_FB_0 ) & & ( wRate > = RATE_18M ) & & ( wRate < = RATE_54M ) ) {
uDurTime = uCTSTime + 2 * pDevice - > uSIFS + s_uGetTxRsvTime ( pDevice , byPktType , cbFrameLength , wFB_Opt0 [ FB_RATE1 ] [ wRate - RATE_18M ] , bNeedAck ) ;
} else if ( ( byFBOption = = AUTO_FB_1 ) & & ( wRate > = RATE_18M ) & & ( wRate < = RATE_54M ) ) {
uDurTime = uCTSTime + 2 * pDevice - > uSIFS + s_uGetTxRsvTime ( pDevice , byPktType , cbFrameLength , wFB_Opt1 [ FB_RATE1 ] [ wRate - RATE_18M ] , bNeedAck ) ;
}
break ;
case RTSDUR_AA_F1 : //RTSDuration_aa_f1
uCTSTime = BBuGetFrameTime ( pDevice - > byPreambleType , byPktType , 14 , pDevice - > byTopOFDMBasicRate ) ;
if ( ( byFBOption = = AUTO_FB_0 ) & & ( wRate > = RATE_18M ) & & ( wRate < = RATE_54M ) ) {
uDurTime = uCTSTime + 2 * pDevice - > uSIFS + s_uGetTxRsvTime ( pDevice , byPktType , cbFrameLength , wFB_Opt0 [ FB_RATE1 ] [ wRate - RATE_18M ] , bNeedAck ) ;
} else if ( ( byFBOption = = AUTO_FB_1 ) & & ( wRate > = RATE_18M ) & & ( wRate < = RATE_54M ) ) {
uDurTime = uCTSTime + 2 * pDevice - > uSIFS + s_uGetTxRsvTime ( pDevice , byPktType , cbFrameLength , wFB_Opt1 [ FB_RATE1 ] [ wRate - RATE_18M ] , bNeedAck ) ;
}
break ;
case CTSDUR_BA_F0 : //CTSDuration_ba_f0
if ( ( byFBOption = = AUTO_FB_0 ) & & ( wRate > = RATE_18M ) & & ( wRate < = RATE_54M ) ) {
uDurTime = pDevice - > uSIFS + s_uGetTxRsvTime ( pDevice , byPktType , cbFrameLength , wFB_Opt0 [ FB_RATE0 ] [ wRate - RATE_18M ] , bNeedAck ) ;
} else if ( ( byFBOption = = AUTO_FB_1 ) & & ( wRate > = RATE_18M ) & & ( wRate < = RATE_54M ) ) {
uDurTime = pDevice - > uSIFS + s_uGetTxRsvTime ( pDevice , byPktType , cbFrameLength , wFB_Opt1 [ FB_RATE0 ] [ wRate - RATE_18M ] , bNeedAck ) ;
}
break ;
case CTSDUR_BA_F1 : //CTSDuration_ba_f1
if ( ( byFBOption = = AUTO_FB_0 ) & & ( wRate > = RATE_18M ) & & ( wRate < = RATE_54M ) ) {
uDurTime = pDevice - > uSIFS + s_uGetTxRsvTime ( pDevice , byPktType , cbFrameLength , wFB_Opt0 [ FB_RATE1 ] [ wRate - RATE_18M ] , bNeedAck ) ;
} else if ( ( byFBOption = = AUTO_FB_1 ) & & ( wRate > = RATE_18M ) & & ( wRate < = RATE_54M ) ) {
uDurTime = pDevice - > uSIFS + s_uGetTxRsvTime ( pDevice , byPktType , cbFrameLength , wFB_Opt1 [ FB_RATE1 ] [ wRate - RATE_18M ] , bNeedAck ) ;
}
break ;
default :
break ;
}
return uDurTime ;
}
static
2010-06-02 16:52:01 +00:00
unsigned int
2009-04-25 14:30:44 +00:00
s_uFillDataHead (
2010-05-13 03:54:39 +00:00
PSDevice pDevice ,
2010-06-24 18:02:27 +00:00
unsigned char byPktType ,
2010-05-13 03:54:39 +00:00
void * pTxDataHead ,
2010-06-02 16:52:01 +00:00
unsigned int cbFrameLength ,
unsigned int uDMAIdx ,
2010-08-01 15:15:50 +00:00
bool bNeedAck ,
2010-06-02 16:52:01 +00:00
unsigned int uFragIdx ,
unsigned int cbLastFragmentSize ,
unsigned int uMACfragNum ,
2010-06-24 18:02:27 +00:00
unsigned char byFBOption ,
2010-06-24 18:02:26 +00:00
unsigned short wCurrentRate
2009-04-25 14:30:44 +00:00
)
{
2010-06-24 18:02:26 +00:00
unsigned short wLen = 0x0000 ;
2009-04-25 14:30:44 +00:00
if ( pTxDataHead = = NULL ) {
return 0 ;
}
2009-07-30 17:27:21 +00:00
if ( byPktType = = PK_TYPE_11GB | | byPktType = = PK_TYPE_11GA ) {
2009-04-25 14:30:44 +00:00
if ( byFBOption = = AUTO_FB_NONE ) {
PSTxDataHead_g pBuf = ( PSTxDataHead_g ) pTxDataHead ;
//Get SignalField,ServiceField,Length
2012-08-20 15:43:15 +00:00
BBvCalculateParameter ( pDevice , cbFrameLength , wCurrentRate , byPktType ,
2010-06-05 22:13:48 +00:00
( unsigned short * ) & ( wLen ) , ( unsigned char * ) & ( pBuf - > byServiceField_a ) , ( unsigned char * ) & ( pBuf - > bySignalField_a )
2009-04-25 14:30:44 +00:00
) ;
pBuf - > wTransmitLength_a = cpu_to_le16 ( wLen ) ;
2012-08-20 15:43:15 +00:00
BBvCalculateParameter ( pDevice , cbFrameLength , pDevice - > byTopCCKBasicRate , PK_TYPE_11B ,
2010-06-05 22:13:48 +00:00
( unsigned short * ) & ( wLen ) , ( unsigned char * ) & ( pBuf - > byServiceField_b ) , ( unsigned char * ) & ( pBuf - > bySignalField_b )
2009-04-25 14:30:44 +00:00
) ;
pBuf - > wTransmitLength_b = cpu_to_le16 ( wLen ) ;
//Get Duration and TimeStamp
2010-06-24 18:02:26 +00:00
pBuf - > wDuration_a = cpu_to_le16 ( ( unsigned short ) s_uGetDataDuration ( pDevice , DATADUR_A , cbFrameLength ,
2009-07-30 17:27:21 +00:00
byPktType , wCurrentRate , bNeedAck , uFragIdx ,
2009-04-25 14:30:44 +00:00
cbLastFragmentSize , uMACfragNum ,
byFBOption ) ) ; //1: 2.4GHz
2010-06-24 18:02:26 +00:00
pBuf - > wDuration_b = cpu_to_le16 ( ( unsigned short ) s_uGetDataDuration ( pDevice , DATADUR_B , cbFrameLength ,
2009-04-25 14:30:44 +00:00
PK_TYPE_11B , pDevice - > byTopCCKBasicRate ,
bNeedAck , uFragIdx , cbLastFragmentSize ,
uMACfragNum , byFBOption ) ) ; //1: 2.4
pBuf - > wTimeStampOff_a = cpu_to_le16 ( wTimeStampOff [ pDevice - > byPreambleType % 2 ] [ wCurrentRate % MAX_RATE ] ) ;
pBuf - > wTimeStampOff_b = cpu_to_le16 ( wTimeStampOff [ pDevice - > byPreambleType % 2 ] [ pDevice - > byTopCCKBasicRate % MAX_RATE ] ) ;
return ( pBuf - > wDuration_a ) ;
} else {
// Auto Fallback
PSTxDataHead_g_FB pBuf = ( PSTxDataHead_g_FB ) pTxDataHead ;
//Get SignalField,ServiceField,Length
2012-08-20 15:43:15 +00:00
BBvCalculateParameter ( pDevice , cbFrameLength , wCurrentRate , byPktType ,
2010-06-05 22:13:48 +00:00
( unsigned short * ) & ( wLen ) , ( unsigned char * ) & ( pBuf - > byServiceField_a ) , ( unsigned char * ) & ( pBuf - > bySignalField_a )
2009-04-25 14:30:44 +00:00
) ;
pBuf - > wTransmitLength_a = cpu_to_le16 ( wLen ) ;
2012-08-20 15:43:15 +00:00
BBvCalculateParameter ( pDevice , cbFrameLength , pDevice - > byTopCCKBasicRate , PK_TYPE_11B ,
2010-06-05 22:13:48 +00:00
( unsigned short * ) & ( wLen ) , ( unsigned char * ) & ( pBuf - > byServiceField_b ) , ( unsigned char * ) & ( pBuf - > bySignalField_b )
2009-04-25 14:30:44 +00:00
) ;
pBuf - > wTransmitLength_b = cpu_to_le16 ( wLen ) ;
//Get Duration and TimeStamp
2010-06-24 18:02:26 +00:00
pBuf - > wDuration_a = cpu_to_le16 ( ( unsigned short ) s_uGetDataDuration ( pDevice , DATADUR_A , cbFrameLength , byPktType ,
2009-04-25 14:30:44 +00:00
wCurrentRate , bNeedAck , uFragIdx , cbLastFragmentSize , uMACfragNum , byFBOption ) ) ; //1: 2.4GHz
2010-06-24 18:02:26 +00:00
pBuf - > wDuration_b = cpu_to_le16 ( ( unsigned short ) s_uGetDataDuration ( pDevice , DATADUR_B , cbFrameLength , PK_TYPE_11B ,
2009-04-25 14:30:44 +00:00
pDevice - > byTopCCKBasicRate , bNeedAck , uFragIdx , cbLastFragmentSize , uMACfragNum , byFBOption ) ) ; //1: 2.4GHz
2010-06-24 18:02:26 +00:00
pBuf - > wDuration_a_f0 = cpu_to_le16 ( ( unsigned short ) s_uGetDataDuration ( pDevice , DATADUR_A_F0 , cbFrameLength , byPktType ,
2009-04-25 14:30:44 +00:00
wCurrentRate , bNeedAck , uFragIdx , cbLastFragmentSize , uMACfragNum , byFBOption ) ) ; //1: 2.4GHz
2010-06-24 18:02:26 +00:00
pBuf - > wDuration_a_f1 = cpu_to_le16 ( ( unsigned short ) s_uGetDataDuration ( pDevice , DATADUR_A_F1 , cbFrameLength , byPktType ,
2009-04-25 14:30:44 +00:00
wCurrentRate , bNeedAck , uFragIdx , cbLastFragmentSize , uMACfragNum , byFBOption ) ) ; //1: 2.4GHz
pBuf - > wTimeStampOff_a = cpu_to_le16 ( wTimeStampOff [ pDevice - > byPreambleType % 2 ] [ wCurrentRate % MAX_RATE ] ) ;
pBuf - > wTimeStampOff_b = cpu_to_le16 ( wTimeStampOff [ pDevice - > byPreambleType % 2 ] [ pDevice - > byTopCCKBasicRate % MAX_RATE ] ) ;
return ( pBuf - > wDuration_a ) ;
} //if (byFBOption == AUTO_FB_NONE)
}
2009-07-30 17:27:21 +00:00
else if ( byPktType = = PK_TYPE_11A ) {
2009-04-25 14:30:44 +00:00
if ( ( byFBOption ! = AUTO_FB_NONE ) ) {
// Auto Fallback
PSTxDataHead_a_FB pBuf = ( PSTxDataHead_a_FB ) pTxDataHead ;
//Get SignalField,ServiceField,Length
2012-08-20 15:43:15 +00:00
BBvCalculateParameter ( pDevice , cbFrameLength , wCurrentRate , byPktType ,
2010-06-05 22:13:48 +00:00
( unsigned short * ) & ( wLen ) , ( unsigned char * ) & ( pBuf - > byServiceField ) , ( unsigned char * ) & ( pBuf - > bySignalField )
2009-04-25 14:30:44 +00:00
) ;
pBuf - > wTransmitLength = cpu_to_le16 ( wLen ) ;
//Get Duration and TimeStampOff
2010-06-24 18:02:26 +00:00
pBuf - > wDuration = cpu_to_le16 ( ( unsigned short ) s_uGetDataDuration ( pDevice , DATADUR_A , cbFrameLength , byPktType ,
2009-04-25 14:30:44 +00:00
wCurrentRate , bNeedAck , uFragIdx , cbLastFragmentSize , uMACfragNum , byFBOption ) ) ; //0: 5GHz
2010-06-24 18:02:26 +00:00
pBuf - > wDuration_f0 = cpu_to_le16 ( ( unsigned short ) s_uGetDataDuration ( pDevice , DATADUR_A_F0 , cbFrameLength , byPktType ,
2009-04-25 14:30:44 +00:00
wCurrentRate , bNeedAck , uFragIdx , cbLastFragmentSize , uMACfragNum , byFBOption ) ) ; //0: 5GHz
2010-06-24 18:02:26 +00:00
pBuf - > wDuration_f1 = cpu_to_le16 ( ( unsigned short ) s_uGetDataDuration ( pDevice , DATADUR_A_F1 , cbFrameLength , byPktType ,
2009-04-25 14:30:44 +00:00
wCurrentRate , bNeedAck , uFragIdx , cbLastFragmentSize , uMACfragNum , byFBOption ) ) ; //0: 5GHz
pBuf - > wTimeStampOff = cpu_to_le16 ( wTimeStampOff [ pDevice - > byPreambleType % 2 ] [ wCurrentRate % MAX_RATE ] ) ;
return ( pBuf - > wDuration ) ;
} else {
PSTxDataHead_ab pBuf = ( PSTxDataHead_ab ) pTxDataHead ;
//Get SignalField,ServiceField,Length
2012-08-20 15:43:15 +00:00
BBvCalculateParameter ( pDevice , cbFrameLength , wCurrentRate , byPktType ,
2010-06-05 22:13:48 +00:00
( unsigned short * ) & ( wLen ) , ( unsigned char * ) & ( pBuf - > byServiceField ) , ( unsigned char * ) & ( pBuf - > bySignalField )
2009-04-25 14:30:44 +00:00
) ;
pBuf - > wTransmitLength = cpu_to_le16 ( wLen ) ;
//Get Duration and TimeStampOff
2010-06-24 18:02:26 +00:00
pBuf - > wDuration = cpu_to_le16 ( ( unsigned short ) s_uGetDataDuration ( pDevice , DATADUR_A , cbFrameLength , byPktType ,
2009-04-25 14:30:44 +00:00
wCurrentRate , bNeedAck , uFragIdx ,
cbLastFragmentSize , uMACfragNum ,
byFBOption ) ) ;
pBuf - > wTimeStampOff = cpu_to_le16 ( wTimeStampOff [ pDevice - > byPreambleType % 2 ] [ wCurrentRate % MAX_RATE ] ) ;
return ( pBuf - > wDuration ) ;
}
}
else {
PSTxDataHead_ab pBuf = ( PSTxDataHead_ab ) pTxDataHead ;
//Get SignalField,ServiceField,Length
2012-08-20 15:43:15 +00:00
BBvCalculateParameter ( pDevice , cbFrameLength , wCurrentRate , byPktType ,
2010-06-05 22:13:48 +00:00
( unsigned short * ) & ( wLen ) , ( unsigned char * ) & ( pBuf - > byServiceField ) , ( unsigned char * ) & ( pBuf - > bySignalField )
2009-04-25 14:30:44 +00:00
) ;
pBuf - > wTransmitLength = cpu_to_le16 ( wLen ) ;
//Get Duration and TimeStampOff
2010-06-24 18:02:26 +00:00
pBuf - > wDuration = cpu_to_le16 ( ( unsigned short ) s_uGetDataDuration ( pDevice , DATADUR_B , cbFrameLength , byPktType ,
2009-04-25 14:30:44 +00:00
wCurrentRate , bNeedAck , uFragIdx ,
cbLastFragmentSize , uMACfragNum ,
byFBOption ) ) ;
pBuf - > wTimeStampOff = cpu_to_le16 ( wTimeStampOff [ pDevice - > byPreambleType % 2 ] [ wCurrentRate % MAX_RATE ] ) ;
return ( pBuf - > wDuration ) ;
}
return 0 ;
}
static
2010-05-07 19:30:19 +00:00
void
2009-04-25 14:30:44 +00:00
s_vFillRTSHead (
2010-05-13 03:54:39 +00:00
PSDevice pDevice ,
2010-06-24 18:02:27 +00:00
unsigned char byPktType ,
2010-05-13 03:54:39 +00:00
void * pvRTS ,
2010-06-02 16:52:01 +00:00
unsigned int cbFrameLength ,
2010-08-01 15:15:50 +00:00
bool bNeedAck ,
bool bDisCRC ,
2010-05-13 03:54:39 +00:00
PSEthernetHeader psEthHeader ,
2010-06-24 18:02:26 +00:00
unsigned short wCurrentRate ,
2010-06-24 18:02:27 +00:00
unsigned char byFBOption
2009-04-25 14:30:44 +00:00
)
{
2010-06-02 16:52:01 +00:00
unsigned int uRTSFrameLen = 20 ;
2010-06-24 18:02:26 +00:00
unsigned short wLen = 0x0000 ;
2009-04-25 14:30:44 +00:00
if ( pvRTS = = NULL )
return ;
if ( bDisCRC ) {
// When CRCDIS bit is on, H/W forgot to generate FCS for RTS frame,
// in this case we need to decrease its length by 4.
uRTSFrameLen - = 4 ;
}
// Note: So far RTSHead dosen't appear in ATIM & Beacom DMA, so we don't need to take them into account.
2010-03-29 13:41:47 +00:00
// Otherwise, we need to modify codes for them.
2009-07-30 17:27:21 +00:00
if ( byPktType = = PK_TYPE_11GB | | byPktType = = PK_TYPE_11GA ) {
2009-04-25 14:30:44 +00:00
if ( byFBOption = = AUTO_FB_NONE ) {
PSRTS_g pBuf = ( PSRTS_g ) pvRTS ;
//Get SignalField,ServiceField,Length
2012-08-20 15:43:15 +00:00
BBvCalculateParameter ( pDevice , uRTSFrameLen , pDevice - > byTopCCKBasicRate , PK_TYPE_11B ,
2010-06-05 22:13:48 +00:00
( unsigned short * ) & ( wLen ) , ( unsigned char * ) & ( pBuf - > byServiceField_b ) , ( unsigned char * ) & ( pBuf - > bySignalField_b )
2009-04-25 14:30:44 +00:00
) ;
pBuf - > wTransmitLength_b = cpu_to_le16 ( wLen ) ;
2012-08-20 15:43:15 +00:00
BBvCalculateParameter ( pDevice , uRTSFrameLen , pDevice - > byTopOFDMBasicRate , byPktType ,
2010-06-05 22:13:48 +00:00
( unsigned short * ) & ( wLen ) , ( unsigned char * ) & ( pBuf - > byServiceField_a ) , ( unsigned char * ) & ( pBuf - > bySignalField_a )
2009-04-25 14:30:44 +00:00
) ;
pBuf - > wTransmitLength_a = cpu_to_le16 ( wLen ) ;
//Get Duration
2010-06-24 18:02:26 +00:00
pBuf - > wDuration_bb = cpu_to_le16 ( ( unsigned short ) s_uGetRTSCTSDuration ( pDevice , RTSDUR_BB , cbFrameLength , PK_TYPE_11B , pDevice - > byTopCCKBasicRate , bNeedAck , byFBOption ) ) ; //0:RTSDuration_bb, 1:2.4G, 1:CCKData
pBuf - > wDuration_aa = cpu_to_le16 ( ( unsigned short ) s_uGetRTSCTSDuration ( pDevice , RTSDUR_AA , cbFrameLength , byPktType , wCurrentRate , bNeedAck , byFBOption ) ) ; //2:RTSDuration_aa, 1:2.4G, 2,3: 2.4G OFDMData
pBuf - > wDuration_ba = cpu_to_le16 ( ( unsigned short ) s_uGetRTSCTSDuration ( pDevice , RTSDUR_BA , cbFrameLength , byPktType , wCurrentRate , bNeedAck , byFBOption ) ) ; //1:RTSDuration_ba, 1:2.4G, 2,3:2.4G OFDM Data
2009-04-25 14:30:44 +00:00
pBuf - > Data . wDurationID = pBuf - > wDuration_aa ;
//Get RTS Frame body
pBuf - > Data . wFrameControl = TYPE_CTL_RTS ; //0x00B4
if ( ( pDevice - > eOPMode = = OP_MODE_ADHOC ) | |
( pDevice - > eOPMode = = OP_MODE_AP ) ) {
2010-05-15 02:37:32 +00:00
memcpy ( & ( pBuf - > Data . abyRA [ 0 ] ) , & ( psEthHeader - > abyDstAddr [ 0 ] ) , ETH_ALEN ) ;
2009-04-25 14:30:44 +00:00
}
else {
2010-05-15 02:37:32 +00:00
memcpy ( & ( pBuf - > Data . abyRA [ 0 ] ) , & ( pDevice - > abyBSSID [ 0 ] ) , ETH_ALEN ) ;
2009-04-25 14:30:44 +00:00
}
if ( pDevice - > eOPMode = = OP_MODE_AP ) {
2010-05-15 02:37:32 +00:00
memcpy ( & ( pBuf - > Data . abyTA [ 0 ] ) , & ( pDevice - > abyBSSID [ 0 ] ) , ETH_ALEN ) ;
2009-04-25 14:30:44 +00:00
}
else {
2010-05-15 02:37:32 +00:00
memcpy ( & ( pBuf - > Data . abyTA [ 0 ] ) , & ( psEthHeader - > abySrcAddr [ 0 ] ) , ETH_ALEN ) ;
2009-04-25 14:30:44 +00:00
}
}
else {
PSRTS_g_FB pBuf = ( PSRTS_g_FB ) pvRTS ;
//Get SignalField,ServiceField,Length
2012-08-20 15:43:15 +00:00
BBvCalculateParameter ( pDevice , uRTSFrameLen , pDevice - > byTopCCKBasicRate , PK_TYPE_11B ,
2010-06-05 22:13:48 +00:00
( unsigned short * ) & ( wLen ) , ( unsigned char * ) & ( pBuf - > byServiceField_b ) , ( unsigned char * ) & ( pBuf - > bySignalField_b )
2009-04-25 14:30:44 +00:00
) ;
pBuf - > wTransmitLength_b = cpu_to_le16 ( wLen ) ;
2012-08-20 15:43:15 +00:00
BBvCalculateParameter ( pDevice , uRTSFrameLen , pDevice - > byTopOFDMBasicRate , byPktType ,
2010-06-05 22:13:48 +00:00
( unsigned short * ) & ( wLen ) , ( unsigned char * ) & ( pBuf - > byServiceField_a ) , ( unsigned char * ) & ( pBuf - > bySignalField_a )
2009-04-25 14:30:44 +00:00
) ;
pBuf - > wTransmitLength_a = cpu_to_le16 ( wLen ) ;
//Get Duration
2010-06-24 18:02:26 +00:00
pBuf - > wDuration_bb = cpu_to_le16 ( ( unsigned short ) s_uGetRTSCTSDuration ( pDevice , RTSDUR_BB , cbFrameLength , PK_TYPE_11B , pDevice - > byTopCCKBasicRate , bNeedAck , byFBOption ) ) ; //0:RTSDuration_bb, 1:2.4G, 1:CCKData
pBuf - > wDuration_aa = cpu_to_le16 ( ( unsigned short ) s_uGetRTSCTSDuration ( pDevice , RTSDUR_AA , cbFrameLength , byPktType , wCurrentRate , bNeedAck , byFBOption ) ) ; //2:RTSDuration_aa, 1:2.4G, 2,3:2.4G OFDMData
pBuf - > wDuration_ba = cpu_to_le16 ( ( unsigned short ) s_uGetRTSCTSDuration ( pDevice , RTSDUR_BA , cbFrameLength , byPktType , wCurrentRate , bNeedAck , byFBOption ) ) ; //1:RTSDuration_ba, 1:2.4G, 2,3:2.4G OFDMData
pBuf - > wRTSDuration_ba_f0 = cpu_to_le16 ( ( unsigned short ) s_uGetRTSCTSDuration ( pDevice , RTSDUR_BA_F0 , cbFrameLength , byPktType , wCurrentRate , bNeedAck , byFBOption ) ) ; //4:wRTSDuration_ba_f0, 1:2.4G, 1:CCKData
pBuf - > wRTSDuration_aa_f0 = cpu_to_le16 ( ( unsigned short ) s_uGetRTSCTSDuration ( pDevice , RTSDUR_AA_F0 , cbFrameLength , byPktType , wCurrentRate , bNeedAck , byFBOption ) ) ; //5:wRTSDuration_aa_f0, 1:2.4G, 1:CCKData
pBuf - > wRTSDuration_ba_f1 = cpu_to_le16 ( ( unsigned short ) s_uGetRTSCTSDuration ( pDevice , RTSDUR_BA_F1 , cbFrameLength , byPktType , wCurrentRate , bNeedAck , byFBOption ) ) ; //6:wRTSDuration_ba_f1, 1:2.4G, 1:CCKData
pBuf - > wRTSDuration_aa_f1 = cpu_to_le16 ( ( unsigned short ) s_uGetRTSCTSDuration ( pDevice , RTSDUR_AA_F1 , cbFrameLength , byPktType , wCurrentRate , bNeedAck , byFBOption ) ) ; //7:wRTSDuration_aa_f1, 1:2.4G, 1:CCKData
2009-04-25 14:30:44 +00:00
pBuf - > Data . wDurationID = pBuf - > wDuration_aa ;
//Get RTS Frame body
pBuf - > Data . wFrameControl = TYPE_CTL_RTS ; //0x00B4
if ( ( pDevice - > eOPMode = = OP_MODE_ADHOC ) | |
( pDevice - > eOPMode = = OP_MODE_AP ) ) {
2010-05-15 02:37:32 +00:00
memcpy ( & ( pBuf - > Data . abyRA [ 0 ] ) , & ( psEthHeader - > abyDstAddr [ 0 ] ) , ETH_ALEN ) ;
2009-04-25 14:30:44 +00:00
}
else {
2010-05-15 02:37:32 +00:00
memcpy ( & ( pBuf - > Data . abyRA [ 0 ] ) , & ( pDevice - > abyBSSID [ 0 ] ) , ETH_ALEN ) ;
2009-04-25 14:30:44 +00:00
}
if ( pDevice - > eOPMode = = OP_MODE_AP ) {
2010-05-15 02:37:32 +00:00
memcpy ( & ( pBuf - > Data . abyTA [ 0 ] ) , & ( pDevice - > abyBSSID [ 0 ] ) , ETH_ALEN ) ;
2009-04-25 14:30:44 +00:00
}
else {
2010-05-15 02:37:32 +00:00
memcpy ( & ( pBuf - > Data . abyTA [ 0 ] ) , & ( psEthHeader - > abySrcAddr [ 0 ] ) , ETH_ALEN ) ;
2009-04-25 14:30:44 +00:00
}
} // if (byFBOption == AUTO_FB_NONE)
}
2009-07-30 17:27:21 +00:00
else if ( byPktType = = PK_TYPE_11A ) {
2009-04-25 14:30:44 +00:00
if ( byFBOption = = AUTO_FB_NONE ) {
PSRTS_ab pBuf = ( PSRTS_ab ) pvRTS ;
//Get SignalField,ServiceField,Length
2012-08-20 15:43:15 +00:00
BBvCalculateParameter ( pDevice , uRTSFrameLen , pDevice - > byTopOFDMBasicRate , byPktType ,
2010-06-05 22:13:48 +00:00
( unsigned short * ) & ( wLen ) , ( unsigned char * ) & ( pBuf - > byServiceField ) , ( unsigned char * ) & ( pBuf - > bySignalField )
2009-04-25 14:30:44 +00:00
) ;
pBuf - > wTransmitLength = cpu_to_le16 ( wLen ) ;
//Get Duration
2010-06-24 18:02:26 +00:00
pBuf - > wDuration = cpu_to_le16 ( ( unsigned short ) s_uGetRTSCTSDuration ( pDevice , RTSDUR_AA , cbFrameLength , byPktType , wCurrentRate , bNeedAck , byFBOption ) ) ; //0:RTSDuration_aa, 0:5G, 0: 5G OFDMData
2009-04-25 14:30:44 +00:00
pBuf - > Data . wDurationID = pBuf - > wDuration ;
//Get RTS Frame body
pBuf - > Data . wFrameControl = TYPE_CTL_RTS ; //0x00B4
if ( ( pDevice - > eOPMode = = OP_MODE_ADHOC ) | |
( pDevice - > eOPMode = = OP_MODE_AP ) ) {
2010-05-15 02:37:32 +00:00
memcpy ( & ( pBuf - > Data . abyRA [ 0 ] ) , & ( psEthHeader - > abyDstAddr [ 0 ] ) , ETH_ALEN ) ;
2009-04-25 14:30:44 +00:00
}
else {
2010-05-15 02:37:32 +00:00
memcpy ( & ( pBuf - > Data . abyRA [ 0 ] ) , & ( pDevice - > abyBSSID [ 0 ] ) , ETH_ALEN ) ;
2009-04-25 14:30:44 +00:00
}
if ( pDevice - > eOPMode = = OP_MODE_AP ) {
2010-05-15 02:37:32 +00:00
memcpy ( & ( pBuf - > Data . abyTA [ 0 ] ) , & ( pDevice - > abyBSSID [ 0 ] ) , ETH_ALEN ) ;
2009-04-25 14:30:44 +00:00
}
else {
2010-05-15 02:37:32 +00:00
memcpy ( & ( pBuf - > Data . abyTA [ 0 ] ) , & ( psEthHeader - > abySrcAddr [ 0 ] ) , ETH_ALEN ) ;
2009-04-25 14:30:44 +00:00
}
}
else {
PSRTS_a_FB pBuf = ( PSRTS_a_FB ) pvRTS ;
//Get SignalField,ServiceField,Length
2012-08-20 15:43:15 +00:00
BBvCalculateParameter ( pDevice , uRTSFrameLen , pDevice - > byTopOFDMBasicRate , byPktType ,
2010-06-05 22:13:48 +00:00
( unsigned short * ) & ( wLen ) , ( unsigned char * ) & ( pBuf - > byServiceField ) , ( unsigned char * ) & ( pBuf - > bySignalField )
2009-04-25 14:30:44 +00:00
) ;
pBuf - > wTransmitLength = cpu_to_le16 ( wLen ) ;
//Get Duration
2010-06-24 18:02:26 +00:00
pBuf - > wDuration = cpu_to_le16 ( ( unsigned short ) s_uGetRTSCTSDuration ( pDevice , RTSDUR_AA , cbFrameLength , byPktType , wCurrentRate , bNeedAck , byFBOption ) ) ; //0:RTSDuration_aa, 0:5G, 0: 5G OFDMData
pBuf - > wRTSDuration_f0 = cpu_to_le16 ( ( unsigned short ) s_uGetRTSCTSDuration ( pDevice , RTSDUR_AA_F0 , cbFrameLength , byPktType , wCurrentRate , bNeedAck , byFBOption ) ) ; //5:RTSDuration_aa_f0, 0:5G, 0: 5G OFDMData
pBuf - > wRTSDuration_f1 = cpu_to_le16 ( ( unsigned short ) s_uGetRTSCTSDuration ( pDevice , RTSDUR_AA_F1 , cbFrameLength , byPktType , wCurrentRate , bNeedAck , byFBOption ) ) ; //7:RTSDuration_aa_f1, 0:5G, 0:
2009-04-25 14:30:44 +00:00
pBuf - > Data . wDurationID = pBuf - > wDuration ;
//Get RTS Frame body
pBuf - > Data . wFrameControl = TYPE_CTL_RTS ; //0x00B4
if ( ( pDevice - > eOPMode = = OP_MODE_ADHOC ) | |
( pDevice - > eOPMode = = OP_MODE_AP ) ) {
2010-05-15 02:37:32 +00:00
memcpy ( & ( pBuf - > Data . abyRA [ 0 ] ) , & ( psEthHeader - > abyDstAddr [ 0 ] ) , ETH_ALEN ) ;
2009-04-25 14:30:44 +00:00
}
else {
2010-05-15 02:37:32 +00:00
memcpy ( & ( pBuf - > Data . abyRA [ 0 ] ) , & ( pDevice - > abyBSSID [ 0 ] ) , ETH_ALEN ) ;
2009-04-25 14:30:44 +00:00
}
if ( pDevice - > eOPMode = = OP_MODE_AP ) {
2010-05-15 02:37:32 +00:00
memcpy ( & ( pBuf - > Data . abyTA [ 0 ] ) , & ( pDevice - > abyBSSID [ 0 ] ) , ETH_ALEN ) ;
2009-04-25 14:30:44 +00:00
}
else {
2010-05-15 02:37:32 +00:00
memcpy ( & ( pBuf - > Data . abyTA [ 0 ] ) , & ( psEthHeader - > abySrcAddr [ 0 ] ) , ETH_ALEN ) ;
2009-04-25 14:30:44 +00:00
}
}
}
2009-07-30 17:27:21 +00:00
else if ( byPktType = = PK_TYPE_11B ) {
2009-04-25 14:30:44 +00:00
PSRTS_ab pBuf = ( PSRTS_ab ) pvRTS ;
//Get SignalField,ServiceField,Length
2012-08-20 15:43:15 +00:00
BBvCalculateParameter ( pDevice , uRTSFrameLen , pDevice - > byTopCCKBasicRate , PK_TYPE_11B ,
2010-06-05 22:13:48 +00:00
( unsigned short * ) & ( wLen ) , ( unsigned char * ) & ( pBuf - > byServiceField ) , ( unsigned char * ) & ( pBuf - > bySignalField )
2009-04-25 14:30:44 +00:00
) ;
pBuf - > wTransmitLength = cpu_to_le16 ( wLen ) ;
//Get Duration
2010-06-24 18:02:26 +00:00
pBuf - > wDuration = cpu_to_le16 ( ( unsigned short ) s_uGetRTSCTSDuration ( pDevice , RTSDUR_BB , cbFrameLength , byPktType , wCurrentRate , bNeedAck , byFBOption ) ) ; //0:RTSDuration_bb, 1:2.4G, 1:CCKData
2009-04-25 14:30:44 +00:00
pBuf - > Data . wDurationID = pBuf - > wDuration ;
//Get RTS Frame body
pBuf - > Data . wFrameControl = TYPE_CTL_RTS ; //0x00B4
if ( ( pDevice - > eOPMode = = OP_MODE_ADHOC ) | |
( pDevice - > eOPMode = = OP_MODE_AP ) ) {
2010-05-15 02:37:32 +00:00
memcpy ( & ( pBuf - > Data . abyRA [ 0 ] ) , & ( psEthHeader - > abyDstAddr [ 0 ] ) , ETH_ALEN ) ;
2009-04-25 14:30:44 +00:00
}
else {
2010-05-15 02:37:32 +00:00
memcpy ( & ( pBuf - > Data . abyRA [ 0 ] ) , & ( pDevice - > abyBSSID [ 0 ] ) , ETH_ALEN ) ;
2009-04-25 14:30:44 +00:00
}
if ( pDevice - > eOPMode = = OP_MODE_AP ) {
2010-05-15 02:37:32 +00:00
memcpy ( & ( pBuf - > Data . abyTA [ 0 ] ) , & ( pDevice - > abyBSSID [ 0 ] ) , ETH_ALEN ) ;
2009-04-25 14:30:44 +00:00
}
else {
2010-05-15 02:37:32 +00:00
memcpy ( & ( pBuf - > Data . abyTA [ 0 ] ) , & ( psEthHeader - > abySrcAddr [ 0 ] ) , ETH_ALEN ) ;
2009-04-25 14:30:44 +00:00
}
}
}
static
2010-05-07 19:30:19 +00:00
void
2009-04-25 14:30:44 +00:00
s_vFillCTSHead (
2010-05-13 03:54:39 +00:00
PSDevice pDevice ,
2010-06-02 16:52:01 +00:00
unsigned int uDMAIdx ,
2010-06-24 18:02:27 +00:00
unsigned char byPktType ,
2010-05-13 03:54:39 +00:00
void * pvCTS ,
2010-06-02 16:52:01 +00:00
unsigned int cbFrameLength ,
2010-08-01 15:15:50 +00:00
bool bNeedAck ,
bool bDisCRC ,
2010-06-24 18:02:26 +00:00
unsigned short wCurrentRate ,
2010-06-24 18:02:27 +00:00
unsigned char byFBOption
2009-04-25 14:30:44 +00:00
)
{
2010-06-02 16:52:01 +00:00
unsigned int uCTSFrameLen = 14 ;
2010-06-24 18:02:26 +00:00
unsigned short wLen = 0x0000 ;
2009-04-25 14:30:44 +00:00
if ( pvCTS = = NULL ) {
return ;
}
if ( bDisCRC ) {
// When CRCDIS bit is on, H/W forgot to generate FCS for CTS frame,
// in this case we need to decrease its length by 4.
uCTSFrameLen - = 4 ;
}
2009-07-30 17:27:21 +00:00
if ( byPktType = = PK_TYPE_11GB | | byPktType = = PK_TYPE_11GA ) {
2009-04-25 14:30:44 +00:00
if ( byFBOption ! = AUTO_FB_NONE & & uDMAIdx ! = TYPE_ATIMDMA & & uDMAIdx ! = TYPE_BEACONDMA ) {
// Auto Fall back
PSCTS_FB pBuf = ( PSCTS_FB ) pvCTS ;
//Get SignalField,ServiceField,Length
2012-08-20 15:43:15 +00:00
BBvCalculateParameter ( pDevice , uCTSFrameLen , pDevice - > byTopCCKBasicRate , PK_TYPE_11B ,
2010-06-05 22:13:48 +00:00
( unsigned short * ) & ( wLen ) , ( unsigned char * ) & ( pBuf - > byServiceField_b ) , ( unsigned char * ) & ( pBuf - > bySignalField_b )
2009-04-25 14:30:44 +00:00
) ;
pBuf - > wTransmitLength_b = cpu_to_le16 ( wLen ) ;
2010-06-24 18:02:26 +00:00
pBuf - > wDuration_ba = ( unsigned short ) s_uGetRTSCTSDuration ( pDevice , CTSDUR_BA , cbFrameLength , byPktType , wCurrentRate , bNeedAck , byFBOption ) ; //3:CTSDuration_ba, 1:2.4G, 2,3:2.4G OFDM Data
2009-04-25 14:30:44 +00:00
pBuf - > wDuration_ba + = pDevice - > wCTSDuration ;
pBuf - > wDuration_ba = cpu_to_le16 ( pBuf - > wDuration_ba ) ;
//Get CTSDuration_ba_f0
2010-06-24 18:02:26 +00:00
pBuf - > wCTSDuration_ba_f0 = ( unsigned short ) s_uGetRTSCTSDuration ( pDevice , CTSDUR_BA_F0 , cbFrameLength , byPktType , wCurrentRate , bNeedAck , byFBOption ) ; //8:CTSDuration_ba_f0, 1:2.4G, 2,3:2.4G OFDM Data
2009-04-25 14:30:44 +00:00
pBuf - > wCTSDuration_ba_f0 + = pDevice - > wCTSDuration ;
pBuf - > wCTSDuration_ba_f0 = cpu_to_le16 ( pBuf - > wCTSDuration_ba_f0 ) ;
//Get CTSDuration_ba_f1
2010-06-24 18:02:26 +00:00
pBuf - > wCTSDuration_ba_f1 = ( unsigned short ) s_uGetRTSCTSDuration ( pDevice , CTSDUR_BA_F1 , cbFrameLength , byPktType , wCurrentRate , bNeedAck , byFBOption ) ; //9:CTSDuration_ba_f1, 1:2.4G, 2,3:2.4G OFDM Data
2009-04-25 14:30:44 +00:00
pBuf - > wCTSDuration_ba_f1 + = pDevice - > wCTSDuration ;
pBuf - > wCTSDuration_ba_f1 = cpu_to_le16 ( pBuf - > wCTSDuration_ba_f1 ) ;
//Get CTS Frame body
pBuf - > Data . wDurationID = pBuf - > wDuration_ba ;
pBuf - > Data . wFrameControl = TYPE_CTL_CTS ; //0x00C4
pBuf - > Data . wReserved = 0x0000 ;
2010-05-15 02:37:32 +00:00
memcpy ( & ( pBuf - > Data . abyRA [ 0 ] ) , & ( pDevice - > abyCurrentNetAddr [ 0 ] ) , ETH_ALEN ) ;
2009-04-25 14:30:44 +00:00
} else { //if (byFBOption != AUTO_FB_NONE && uDMAIdx != TYPE_ATIMDMA && uDMAIdx != TYPE_BEACONDMA)
PSCTS pBuf = ( PSCTS ) pvCTS ;
//Get SignalField,ServiceField,Length
2012-08-20 15:43:15 +00:00
BBvCalculateParameter ( pDevice , uCTSFrameLen , pDevice - > byTopCCKBasicRate , PK_TYPE_11B ,
2010-06-05 22:13:48 +00:00
( unsigned short * ) & ( wLen ) , ( unsigned char * ) & ( pBuf - > byServiceField_b ) , ( unsigned char * ) & ( pBuf - > bySignalField_b )
2009-04-25 14:30:44 +00:00
) ;
pBuf - > wTransmitLength_b = cpu_to_le16 ( wLen ) ;
//Get CTSDuration_ba
2010-06-24 18:02:26 +00:00
pBuf - > wDuration_ba = cpu_to_le16 ( ( unsigned short ) s_uGetRTSCTSDuration ( pDevice , CTSDUR_BA , cbFrameLength , byPktType , wCurrentRate , bNeedAck , byFBOption ) ) ; //3:CTSDuration_ba, 1:2.4G, 2,3:2.4G OFDM Data
2009-04-25 14:30:44 +00:00
pBuf - > wDuration_ba + = pDevice - > wCTSDuration ;
pBuf - > wDuration_ba = cpu_to_le16 ( pBuf - > wDuration_ba ) ;
//Get CTS Frame body
pBuf - > Data . wDurationID = pBuf - > wDuration_ba ;
pBuf - > Data . wFrameControl = TYPE_CTL_CTS ; //0x00C4
pBuf - > Data . wReserved = 0x0000 ;
2010-05-15 02:37:32 +00:00
memcpy ( & ( pBuf - > Data . abyRA [ 0 ] ) , & ( pDevice - > abyCurrentNetAddr [ 0 ] ) , ETH_ALEN ) ;
2009-04-25 14:30:44 +00:00
}
}
}
/*+
*
* Description :
* Generate FIFO control for MAC & Baseband controller
*
* Parameters :
* In :
2010-03-29 13:41:47 +00:00
* pDevice - Pointer to adapter
2009-04-25 14:30:44 +00:00
* pTxDataHead - Transmit Data Buffer
* pTxBufHead - pTxBufHead
* pvRrvTime - pvRrvTime
* pvRTS - RTS Buffer
* pCTS - CTS Buffer
* cbFrameSize - Transmit Data Length ( Hdr + Payload + FCS )
* bNeedACK - If need ACK
* uDescIdx - Desc Index
* Out :
* none
*
* Return Value : none
*
- */
2010-06-02 16:52:01 +00:00
// unsigned int cbFrameSize,//Hdr+Payload+FCS
2009-04-25 14:30:44 +00:00
static
2010-05-07 19:30:19 +00:00
void
2009-04-25 14:30:44 +00:00
s_vGenerateTxParameter (
2010-05-13 03:54:39 +00:00
PSDevice pDevice ,
2010-06-24 18:02:27 +00:00
unsigned char byPktType ,
2010-05-13 03:54:39 +00:00
void * pTxBufHead ,
void * pvRrvTime ,
void * pvRTS ,
void * pvCTS ,
2010-06-02 16:52:01 +00:00
unsigned int cbFrameSize ,
2010-08-01 15:15:50 +00:00
bool bNeedACK ,
2010-06-02 16:52:01 +00:00
unsigned int uDMAIdx ,
2010-05-13 03:54:39 +00:00
PSEthernetHeader psEthHeader ,
2010-06-24 18:02:26 +00:00
unsigned short wCurrentRate
2009-04-25 14:30:44 +00:00
)
{
2010-06-02 16:52:01 +00:00
unsigned int cbMACHdLen = WLAN_HDR_ADDR3_LEN ; //24
2010-06-24 18:02:26 +00:00
unsigned short wFifoCtl ;
2010-08-01 15:15:50 +00:00
bool bDisCRC = false ;
2010-06-24 18:02:27 +00:00
unsigned char byFBOption = AUTO_FB_NONE ;
2010-06-24 18:02:26 +00:00
// unsigned short wCurrentRate = pDevice->wCurrentRate;
2009-04-25 14:30:44 +00:00
2009-07-30 17:27:21 +00:00
//DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"s_vGenerateTxParameter...\n");
2009-04-25 14:30:44 +00:00
PSTxBufHead pFifoHead = ( PSTxBufHead ) pTxBufHead ;
pFifoHead - > wReserved = wCurrentRate ;
wFifoCtl = pFifoHead - > wFIFOCtl ;
if ( wFifoCtl & FIFOCTL_CRCDIS ) {
2010-08-01 15:15:48 +00:00
bDisCRC = true ;
2009-04-25 14:30:44 +00:00
}
if ( wFifoCtl & FIFOCTL_AUTO_FB_0 ) {
byFBOption = AUTO_FB_0 ;
}
else if ( wFifoCtl & FIFOCTL_AUTO_FB_1 ) {
byFBOption = AUTO_FB_1 ;
}
if ( pDevice - > bLongHeader )
cbMACHdLen = WLAN_HDR_ADDR3_LEN + 6 ;
2009-07-30 17:27:21 +00:00
if ( byPktType = = PK_TYPE_11GB | | byPktType = = PK_TYPE_11GA ) {
2009-04-25 14:30:44 +00:00
if ( pvRTS ! = NULL ) { //RTS_need
//Fill RsvTime
if ( pvRrvTime ) {
PSRrvTime_gRTS pBuf = ( PSRrvTime_gRTS ) pvRrvTime ;
2010-06-24 18:02:26 +00:00
pBuf - > wRTSTxRrvTime_aa = cpu_to_le16 ( ( unsigned short ) s_uGetRTSCTSRsvTime ( pDevice , 2 , byPktType , cbFrameSize , wCurrentRate ) ) ; //2:RTSTxRrvTime_aa, 1:2.4GHz
pBuf - > wRTSTxRrvTime_ba = cpu_to_le16 ( ( unsigned short ) s_uGetRTSCTSRsvTime ( pDevice , 1 , byPktType , cbFrameSize , wCurrentRate ) ) ; //1:RTSTxRrvTime_ba, 1:2.4GHz
pBuf - > wRTSTxRrvTime_bb = cpu_to_le16 ( ( unsigned short ) s_uGetRTSCTSRsvTime ( pDevice , 0 , byPktType , cbFrameSize , wCurrentRate ) ) ; //0:RTSTxRrvTime_bb, 1:2.4GHz
pBuf - > wTxRrvTime_a = cpu_to_le16 ( ( unsigned short ) s_uGetTxRsvTime ( pDevice , byPktType , cbFrameSize , wCurrentRate , bNeedACK ) ) ; //2.4G OFDM
pBuf - > wTxRrvTime_b = cpu_to_le16 ( ( unsigned short ) s_uGetTxRsvTime ( pDevice , PK_TYPE_11B , cbFrameSize , pDevice - > byTopCCKBasicRate , bNeedACK ) ) ; //1:CCK
2009-04-25 14:30:44 +00:00
}
//Fill RTS
2009-07-30 17:27:21 +00:00
s_vFillRTSHead ( pDevice , byPktType , pvRTS , cbFrameSize , bNeedACK , bDisCRC , psEthHeader , wCurrentRate , byFBOption ) ;
2009-04-25 14:30:44 +00:00
}
else { //RTS_needless, PCF mode
//Fill RsvTime
if ( pvRrvTime ) {
PSRrvTime_gCTS pBuf = ( PSRrvTime_gCTS ) pvRrvTime ;
2010-06-24 18:02:26 +00:00
pBuf - > wTxRrvTime_a = cpu_to_le16 ( ( unsigned short ) s_uGetTxRsvTime ( pDevice , byPktType , cbFrameSize , wCurrentRate , bNeedACK ) ) ; //2.4G OFDM
pBuf - > wTxRrvTime_b = cpu_to_le16 ( ( unsigned short ) s_uGetTxRsvTime ( pDevice , PK_TYPE_11B , cbFrameSize , pDevice - > byTopCCKBasicRate , bNeedACK ) ) ; //1:CCK
pBuf - > wCTSTxRrvTime_ba = cpu_to_le16 ( ( unsigned short ) s_uGetRTSCTSRsvTime ( pDevice , 3 , byPktType , cbFrameSize , wCurrentRate ) ) ; //3:CTSTxRrvTime_Ba, 1:2.4GHz
2009-04-25 14:30:44 +00:00
}
//Fill CTS
2009-07-30 17:27:21 +00:00
s_vFillCTSHead ( pDevice , uDMAIdx , byPktType , pvCTS , cbFrameSize , bNeedACK , bDisCRC , wCurrentRate , byFBOption ) ;
2009-04-25 14:30:44 +00:00
}
}
2009-07-30 17:27:21 +00:00
else if ( byPktType = = PK_TYPE_11A ) {
2009-04-25 14:30:44 +00:00
if ( pvRTS ! = NULL ) { //RTS_need, non PCF mode
//Fill RsvTime
if ( pvRrvTime ) {
PSRrvTime_ab pBuf = ( PSRrvTime_ab ) pvRrvTime ;
2010-06-24 18:02:26 +00:00
pBuf - > wRTSTxRrvTime = cpu_to_le16 ( ( unsigned short ) s_uGetRTSCTSRsvTime ( pDevice , 2 , byPktType , cbFrameSize , wCurrentRate ) ) ; //2:RTSTxRrvTime_aa, 0:5GHz
pBuf - > wTxRrvTime = cpu_to_le16 ( ( unsigned short ) s_uGetTxRsvTime ( pDevice , byPktType , cbFrameSize , wCurrentRate , bNeedACK ) ) ; //0:OFDM
2009-04-25 14:30:44 +00:00
}
//Fill RTS
2009-07-30 17:27:21 +00:00
s_vFillRTSHead ( pDevice , byPktType , pvRTS , cbFrameSize , bNeedACK , bDisCRC , psEthHeader , wCurrentRate , byFBOption ) ;
2009-04-25 14:30:44 +00:00
}
else if ( pvRTS = = NULL ) { //RTS_needless, non PCF mode
//Fill RsvTime
if ( pvRrvTime ) {
PSRrvTime_ab pBuf = ( PSRrvTime_ab ) pvRrvTime ;
2010-06-24 18:02:26 +00:00
pBuf - > wTxRrvTime = cpu_to_le16 ( ( unsigned short ) s_uGetTxRsvTime ( pDevice , PK_TYPE_11A , cbFrameSize , wCurrentRate , bNeedACK ) ) ; //0:OFDM
2009-04-25 14:30:44 +00:00
}
}
}
2009-07-30 17:27:21 +00:00
else if ( byPktType = = PK_TYPE_11B ) {
2009-04-25 14:30:44 +00:00
if ( ( pvRTS ! = NULL ) ) { //RTS_need, non PCF mode
//Fill RsvTime
if ( pvRrvTime ) {
PSRrvTime_ab pBuf = ( PSRrvTime_ab ) pvRrvTime ;
2010-06-24 18:02:26 +00:00
pBuf - > wRTSTxRrvTime = cpu_to_le16 ( ( unsigned short ) s_uGetRTSCTSRsvTime ( pDevice , 0 , byPktType , cbFrameSize , wCurrentRate ) ) ; //0:RTSTxRrvTime_bb, 1:2.4GHz
pBuf - > wTxRrvTime = cpu_to_le16 ( ( unsigned short ) s_uGetTxRsvTime ( pDevice , PK_TYPE_11B , cbFrameSize , wCurrentRate , bNeedACK ) ) ; //1:CCK
2009-04-25 14:30:44 +00:00
}
//Fill RTS
2009-07-30 17:27:21 +00:00
s_vFillRTSHead ( pDevice , byPktType , pvRTS , cbFrameSize , bNeedACK , bDisCRC , psEthHeader , wCurrentRate , byFBOption ) ;
2009-04-25 14:30:44 +00:00
}
else { //RTS_needless, non PCF mode
//Fill RsvTime
if ( pvRrvTime ) {
PSRrvTime_ab pBuf = ( PSRrvTime_ab ) pvRrvTime ;
2010-06-24 18:02:26 +00:00
pBuf - > wTxRrvTime = cpu_to_le16 ( ( unsigned short ) s_uGetTxRsvTime ( pDevice , PK_TYPE_11B , cbFrameSize , wCurrentRate , bNeedACK ) ) ; //1:CCK
2009-04-25 14:30:44 +00:00
}
}
}
2009-07-30 17:27:21 +00:00
//DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"s_vGenerateTxParameter END.\n");
2009-04-25 14:30:44 +00:00
}
/*
2010-06-05 22:13:47 +00:00
unsigned char * pbyBuffer , //point to pTxBufHead
2010-06-24 18:02:26 +00:00
unsigned short wFragType , //00:Non-Frag, 01:Start, 02:Mid, 03:Last
2010-06-02 16:52:01 +00:00
unsigned int cbFragmentSize , //Hdr+payoad+FCS
2009-04-25 14:30:44 +00:00
*/
static
2010-05-07 19:30:19 +00:00
void
2009-04-25 14:30:44 +00:00
s_vFillFragParameter (
2010-05-13 03:54:39 +00:00
PSDevice pDevice ,
2010-06-05 22:13:47 +00:00
unsigned char * pbyBuffer ,
2010-06-02 16:52:01 +00:00
unsigned int uTxType ,
2010-05-13 03:54:39 +00:00
void * pvtdCurr ,
2010-06-24 18:02:26 +00:00
unsigned short wFragType ,
2010-06-02 16:52:01 +00:00
unsigned int cbReqCount
2009-04-25 14:30:44 +00:00
)
{
PSTxBufHead pTxBufHead = ( PSTxBufHead ) pbyBuffer ;
2009-07-30 17:27:21 +00:00
//DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"s_vFillFragParameter...\n");
2009-04-25 14:30:44 +00:00
if ( uTxType = = TYPE_SYNCDMA ) {
//PSTxSyncDesc ptdCurr = (PSTxSyncDesc)s_pvGetTxDescHead(pDevice, uTxType, uCurIdx);
PSTxSyncDesc ptdCurr = ( PSTxSyncDesc ) pvtdCurr ;
//Set FIFOCtl & TimeStamp in TxSyncDesc
ptdCurr - > m_wFIFOCtl = pTxBufHead - > wFIFOCtl ;
ptdCurr - > m_wTimeStamp = pTxBufHead - > wTimeStamp ;
//Set TSR1 & ReqCount in TxDescHead
2010-06-24 18:02:26 +00:00
ptdCurr - > m_td1TD1 . wReqCount = cpu_to_le16 ( ( unsigned short ) ( cbReqCount ) ) ;
2009-04-25 14:30:44 +00:00
if ( wFragType = = FRAGCTL_ENDFRAG ) { //Last Fragmentation
ptdCurr - > m_td1TD1 . byTCR | = ( TCR_STP | TCR_EDP | EDMSDU ) ;
}
else {
ptdCurr - > m_td1TD1 . byTCR | = ( TCR_STP | TCR_EDP ) ;
}
}
else {
//PSTxDesc ptdCurr = (PSTxDesc)s_pvGetTxDescHead(pDevice, uTxType, uCurIdx);
PSTxDesc ptdCurr = ( PSTxDesc ) pvtdCurr ;
//Set TSR1 & ReqCount in TxDescHead
2010-06-24 18:02:26 +00:00
ptdCurr - > m_td1TD1 . wReqCount = cpu_to_le16 ( ( unsigned short ) ( cbReqCount ) ) ;
2009-04-25 14:30:44 +00:00
if ( wFragType = = FRAGCTL_ENDFRAG ) { //Last Fragmentation
ptdCurr - > m_td1TD1 . byTCR | = ( TCR_STP | TCR_EDP | EDMSDU ) ;
}
else {
ptdCurr - > m_td1TD1 . byTCR | = ( TCR_STP | TCR_EDP ) ;
}
}
2010-06-24 18:02:26 +00:00
pTxBufHead - > wFragCtl | = ( unsigned short ) wFragType ; //0x0001; //0000 0000 0000 0001
2009-04-25 14:30:44 +00:00
2009-07-30 17:27:21 +00:00
//DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"s_vFillFragParameter END\n");
2009-04-25 14:30:44 +00:00
}
2010-06-25 17:48:53 +00:00
static unsigned int
s_cbFillTxBufHead ( PSDevice pDevice , unsigned char byPktType , unsigned char * pbyTxBufferAddr ,
unsigned int cbFrameBodySize , unsigned int uDMAIdx , PSTxDesc pHeadTD ,
2010-08-01 15:15:50 +00:00
PSEthernetHeader psEthHeader , unsigned char * pPacket , bool bNeedEncrypt ,
2010-06-25 17:48:53 +00:00
PSKeyItem pTransmitKey , unsigned int uNodeIndex , unsigned int * puMACfragNum )
2009-04-25 14:30:44 +00:00
{
2010-06-02 16:52:01 +00:00
unsigned int cbMACHdLen ;
unsigned int cbFrameSize ;
unsigned int cbFragmentSize ; //Hdr+(IV)+payoad+(MIC)+(ICV)+FCS
unsigned int cbFragPayloadSize ;
unsigned int cbLastFragmentSize ; //Hdr+(IV)+payoad+(MIC)+(ICV)+FCS
unsigned int cbLastFragPayloadSize ;
unsigned int uFragIdx ;
2010-06-05 22:13:47 +00:00
unsigned char * pbyPayloadHead ;
unsigned char * pbyIVHead ;
unsigned char * pbyMacHdr ;
2010-06-24 18:02:26 +00:00
unsigned short wFragType ; //00:Non-Frag, 01:Start, 10:Mid, 11:Last
2010-06-02 16:52:01 +00:00
unsigned int uDuration ;
2010-06-05 22:13:47 +00:00
unsigned char * pbyBuffer ;
2010-06-02 16:52:01 +00:00
// unsigned int uKeyEntryIdx = NUM_KEY_ENTRY+1;
2010-06-24 18:02:27 +00:00
// unsigned char byKeySel = 0xFF;
2010-06-02 16:52:01 +00:00
unsigned int cbIVlen = 0 ;
unsigned int cbICVlen = 0 ;
unsigned int cbMIClen = 0 ;
unsigned int cbFCSlen = 4 ;
unsigned int cb802_1_H_len = 0 ;
unsigned int uLength = 0 ;
unsigned int uTmpLen = 0 ;
2010-06-24 18:02:27 +00:00
// unsigned char abyTmp[8];
2010-06-24 18:02:25 +00:00
// unsigned long dwCRC;
2010-06-02 16:52:01 +00:00
unsigned int cbMICHDR = 0 ;
2010-06-24 18:02:25 +00:00
unsigned long dwMICKey0 , dwMICKey1 ;
unsigned long dwMIC_Priority ;
2010-06-05 22:13:49 +00:00
unsigned long * pdwMIC_L ;
unsigned long * pdwMIC_R ;
2010-06-24 18:02:25 +00:00
unsigned long dwSafeMIC_L , dwSafeMIC_R ; //Fix "Last Frag Size" < "MIC length".
2010-08-01 15:15:50 +00:00
bool bMIC2Frag = false ;
2010-06-02 16:52:01 +00:00
unsigned int uMICFragLen = 0 ;
unsigned int uMACfragNum = 1 ;
unsigned int uPadding = 0 ;
unsigned int cbReqCount = 0 ;
2009-04-25 14:30:44 +00:00
2010-08-01 15:15:50 +00:00
bool bNeedACK ;
bool bRTS ;
bool bIsAdhoc ;
2010-06-05 22:13:47 +00:00
unsigned char * pbyType ;
2009-04-25 14:30:44 +00:00
PSTxDesc ptdCurr ;
PSTxBufHead psTxBufHd = ( PSTxBufHead ) pbyTxBufferAddr ;
2010-06-02 16:52:01 +00:00
// unsigned int tmpDescIdx;
unsigned int cbHeaderLength = 0 ;
2010-05-07 19:30:20 +00:00
void * pvRrvTime ;
2009-04-25 14:30:44 +00:00
PSMICHDRHead pMICHDR ;
2010-05-07 19:30:20 +00:00
void * pvRTS ;
void * pvCTS ;
void * pvTxDataHd ;
2010-06-24 18:02:26 +00:00
unsigned short wTxBufSize ; // FFinfo size
2010-06-02 16:52:01 +00:00
unsigned int uTotalCopyLength = 0 ;
2010-06-24 18:02:27 +00:00
unsigned char byFBOption = AUTO_FB_NONE ;
2010-08-01 15:15:50 +00:00
bool bIsWEP256 = false ;
2009-04-25 14:30:44 +00:00
PSMgmtObject pMgmt = pDevice - > pMgmt ;
pvRrvTime = pMICHDR = pvRTS = pvCTS = pvTxDataHd = NULL ;
2009-07-30 17:27:21 +00:00
//DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"s_cbFillTxBufHead...\n");
2009-04-25 14:30:44 +00:00
if ( ( pDevice - > eOPMode = = OP_MODE_ADHOC ) | |
( pDevice - > eOPMode = = OP_MODE_AP ) ) {
2010-06-30 07:46:24 +00:00
if ( is_multicast_ether_addr ( & ( psEthHeader - > abyDstAddr [ 0 ] ) ) )
2010-08-01 15:15:49 +00:00
bNeedACK = false ;
2010-06-30 07:46:24 +00:00
else
2010-08-01 15:15:48 +00:00
bNeedACK = true ;
bIsAdhoc = true ;
2009-04-25 14:30:44 +00:00
}
else {
// MSDUs in Infra mode always need ACK
2010-08-01 15:15:48 +00:00
bNeedACK = true ;
2010-08-01 15:15:49 +00:00
bIsAdhoc = false ;
2009-04-25 14:30:44 +00:00
}
if ( pDevice - > bLongHeader )
cbMACHdLen = WLAN_HDR_ADDR3_LEN + 6 ;
else
cbMACHdLen = WLAN_HDR_ADDR3_LEN ;
2010-08-01 15:15:48 +00:00
if ( ( bNeedEncrypt = = true ) & & ( pTransmitKey ! = NULL ) ) {
2009-04-25 14:30:44 +00:00
if ( pTransmitKey - > byCipherSuite = = KEY_CTL_WEP ) {
cbIVlen = 4 ;
cbICVlen = 4 ;
if ( pTransmitKey - > uKeyLength = = WLAN_WEP232_KEYLEN ) {
2010-08-01 15:15:48 +00:00
bIsWEP256 = true ;
2009-04-25 14:30:44 +00:00
}
}
if ( pTransmitKey - > byCipherSuite = = KEY_CTL_TKIP ) {
cbIVlen = 8 ; //IV+ExtIV
cbMIClen = 8 ;
cbICVlen = 4 ;
}
if ( pTransmitKey - > byCipherSuite = = KEY_CTL_CCMP ) {
cbIVlen = 8 ; //RSN Header
cbICVlen = 8 ; //MIC
cbMICHDR = sizeof ( SMICHDRHead ) ;
}
if ( pDevice - > byLocalID > REV_ID_VT3253_A1 ) {
//MAC Header should be padding 0 to DW alignment.
uPadding = 4 - ( cbMACHdLen % 4 ) ;
uPadding % = 4 ;
}
}
cbFrameSize = cbMACHdLen + cbIVlen + ( cbFrameBodySize + cbMIClen ) + cbICVlen + cbFCSlen ;
2010-08-01 15:15:49 +00:00
if ( ( bNeedACK = = false ) | |
2009-04-25 14:30:44 +00:00
( cbFrameSize < pDevice - > wRTSThreshold ) | |
( ( cbFrameSize > = pDevice - > wFragmentationThreshold ) & & ( pDevice - > wFragmentationThreshold < = pDevice - > wRTSThreshold ) )
) {
2010-08-01 15:15:49 +00:00
bRTS = false ;
2009-04-25 14:30:44 +00:00
}
else {
2010-08-01 15:15:48 +00:00
bRTS = true ;
2009-04-25 14:30:44 +00:00
psTxBufHd - > wFIFOCtl | = ( FIFOCTL_RTS | FIFOCTL_LRETRY ) ;
}
//
// Use for AUTO FALL BACK
//
if ( psTxBufHd - > wFIFOCtl & FIFOCTL_AUTO_FB_0 ) {
byFBOption = AUTO_FB_0 ;
}
else if ( psTxBufHd - > wFIFOCtl & FIFOCTL_AUTO_FB_1 ) {
byFBOption = AUTO_FB_1 ;
}
//////////////////////////////////////////////////////
//Set RrvTime/RTS/CTS Buffer
wTxBufSize = sizeof ( STxBufHead ) ;
2009-07-30 17:27:21 +00:00
if ( byPktType = = PK_TYPE_11GB | | byPktType = = PK_TYPE_11GA ) { //802.11g packet
2009-04-25 14:30:44 +00:00
if ( byFBOption = = AUTO_FB_NONE ) {
2010-08-01 15:15:48 +00:00
if ( bRTS = = true ) { //RTS_need
2009-04-25 14:30:44 +00:00
pvRrvTime = ( PSRrvTime_gRTS ) ( pbyTxBufferAddr + wTxBufSize ) ;
pMICHDR = ( PSMICHDRHead ) ( pbyTxBufferAddr + wTxBufSize + sizeof ( SRrvTime_gRTS ) ) ;
pvRTS = ( PSRTS_g ) ( pbyTxBufferAddr + wTxBufSize + sizeof ( SRrvTime_gRTS ) + cbMICHDR ) ;
pvCTS = NULL ;
pvTxDataHd = ( PSTxDataHead_g ) ( pbyTxBufferAddr + wTxBufSize + sizeof ( SRrvTime_gRTS ) + cbMICHDR + sizeof ( SRTS_g ) ) ;
cbHeaderLength = wTxBufSize + sizeof ( SRrvTime_gRTS ) + cbMICHDR + sizeof ( SRTS_g ) + sizeof ( STxDataHead_g ) ;
}
else { //RTS_needless
pvRrvTime = ( PSRrvTime_gCTS ) ( pbyTxBufferAddr + wTxBufSize ) ;
pMICHDR = ( PSMICHDRHead ) ( pbyTxBufferAddr + wTxBufSize + sizeof ( SRrvTime_gCTS ) ) ;
pvRTS = NULL ;
pvCTS = ( PSCTS ) ( pbyTxBufferAddr + wTxBufSize + sizeof ( SRrvTime_gCTS ) + cbMICHDR ) ;
pvTxDataHd = ( PSTxDataHead_g ) ( pbyTxBufferAddr + wTxBufSize + sizeof ( SRrvTime_gCTS ) + cbMICHDR + sizeof ( SCTS ) ) ;
cbHeaderLength = wTxBufSize + sizeof ( SRrvTime_gCTS ) + cbMICHDR + sizeof ( SCTS ) + sizeof ( STxDataHead_g ) ;
}
} else {
// Auto Fall Back
2010-08-01 15:15:48 +00:00
if ( bRTS = = true ) { //RTS_need
2009-04-25 14:30:44 +00:00
pvRrvTime = ( PSRrvTime_gRTS ) ( pbyTxBufferAddr + wTxBufSize ) ;
pMICHDR = ( PSMICHDRHead ) ( pbyTxBufferAddr + wTxBufSize + sizeof ( SRrvTime_gRTS ) ) ;
pvRTS = ( PSRTS_g_FB ) ( pbyTxBufferAddr + wTxBufSize + sizeof ( SRrvTime_gRTS ) + cbMICHDR ) ;
pvCTS = NULL ;
pvTxDataHd = ( PSTxDataHead_g_FB ) ( pbyTxBufferAddr + wTxBufSize + sizeof ( SRrvTime_gRTS ) + cbMICHDR + sizeof ( SRTS_g_FB ) ) ;
cbHeaderLength = wTxBufSize + sizeof ( SRrvTime_gRTS ) + cbMICHDR + sizeof ( SRTS_g_FB ) + sizeof ( STxDataHead_g_FB ) ;
}
else { //RTS_needless
pvRrvTime = ( PSRrvTime_gCTS ) ( pbyTxBufferAddr + wTxBufSize ) ;
pMICHDR = ( PSMICHDRHead ) ( pbyTxBufferAddr + wTxBufSize + sizeof ( SRrvTime_gCTS ) ) ;
pvRTS = NULL ;
pvCTS = ( PSCTS_FB ) ( pbyTxBufferAddr + wTxBufSize + sizeof ( SRrvTime_gCTS ) + cbMICHDR ) ;
pvTxDataHd = ( PSTxDataHead_g_FB ) ( pbyTxBufferAddr + wTxBufSize + sizeof ( SRrvTime_gCTS ) + cbMICHDR + sizeof ( SCTS_FB ) ) ;
cbHeaderLength = wTxBufSize + sizeof ( SRrvTime_gCTS ) + cbMICHDR + sizeof ( SCTS_FB ) + sizeof ( STxDataHead_g_FB ) ;
}
} // Auto Fall Back
}
else { //802.11a/b packet
if ( byFBOption = = AUTO_FB_NONE ) {
2010-08-01 15:15:48 +00:00
if ( bRTS = = true ) {
2009-04-25 14:30:44 +00:00
pvRrvTime = ( PSRrvTime_ab ) ( pbyTxBufferAddr + wTxBufSize ) ;
pMICHDR = ( PSMICHDRHead ) ( pbyTxBufferAddr + wTxBufSize + sizeof ( SRrvTime_ab ) ) ;
pvRTS = ( PSRTS_ab ) ( pbyTxBufferAddr + wTxBufSize + sizeof ( SRrvTime_ab ) + cbMICHDR ) ;
pvCTS = NULL ;
pvTxDataHd = ( PSTxDataHead_ab ) ( pbyTxBufferAddr + wTxBufSize + sizeof ( PSRrvTime_ab ) + cbMICHDR + sizeof ( SRTS_ab ) ) ;
cbHeaderLength = wTxBufSize + sizeof ( PSRrvTime_ab ) + cbMICHDR + sizeof ( SRTS_ab ) + sizeof ( STxDataHead_ab ) ;
}
else { //RTS_needless, need MICHDR
pvRrvTime = ( PSRrvTime_ab ) ( pbyTxBufferAddr + wTxBufSize ) ;
pMICHDR = ( PSMICHDRHead ) ( pbyTxBufferAddr + wTxBufSize + sizeof ( SRrvTime_ab ) ) ;
pvRTS = NULL ;
pvCTS = NULL ;
pvTxDataHd = ( PSTxDataHead_ab ) ( pbyTxBufferAddr + wTxBufSize + sizeof ( SRrvTime_ab ) + cbMICHDR ) ;
cbHeaderLength = wTxBufSize + sizeof ( SRrvTime_ab ) + cbMICHDR + sizeof ( STxDataHead_ab ) ;
}
} else {
// Auto Fall Back
2010-08-01 15:15:48 +00:00
if ( bRTS = = true ) { //RTS_need
2009-04-25 14:30:44 +00:00
pvRrvTime = ( PSRrvTime_ab ) ( pbyTxBufferAddr + wTxBufSize ) ;
pMICHDR = ( PSMICHDRHead ) ( pbyTxBufferAddr + wTxBufSize + sizeof ( SRrvTime_ab ) ) ;
pvRTS = ( PSRTS_a_FB ) ( pbyTxBufferAddr + wTxBufSize + sizeof ( SRrvTime_ab ) + cbMICHDR ) ;
pvCTS = NULL ;
pvTxDataHd = ( PSTxDataHead_a_FB ) ( pbyTxBufferAddr + wTxBufSize + sizeof ( PSRrvTime_ab ) + cbMICHDR + sizeof ( SRTS_a_FB ) ) ;
cbHeaderLength = wTxBufSize + sizeof ( PSRrvTime_ab ) + cbMICHDR + sizeof ( SRTS_a_FB ) + sizeof ( STxDataHead_a_FB ) ;
}
else { //RTS_needless
pvRrvTime = ( PSRrvTime_ab ) ( pbyTxBufferAddr + wTxBufSize ) ;
pMICHDR = ( PSMICHDRHead ) ( pbyTxBufferAddr + wTxBufSize + sizeof ( SRrvTime_ab ) ) ;
pvRTS = NULL ;
pvCTS = NULL ;
pvTxDataHd = ( PSTxDataHead_a_FB ) ( pbyTxBufferAddr + wTxBufSize + sizeof ( SRrvTime_ab ) + cbMICHDR ) ;
cbHeaderLength = wTxBufSize + sizeof ( SRrvTime_ab ) + cbMICHDR + sizeof ( STxDataHead_a_FB ) ;
}
} // Auto Fall Back
}
2010-05-07 19:30:20 +00:00
memset ( ( void * ) ( pbyTxBufferAddr + wTxBufSize ) , 0 , ( cbHeaderLength - wTxBufSize ) ) ;
2009-04-25 14:30:44 +00:00
//////////////////////////////////////////////////////////////////
2010-08-01 15:15:48 +00:00
if ( ( bNeedEncrypt = = true ) & & ( pTransmitKey ! = NULL ) & & ( pTransmitKey - > byCipherSuite = = KEY_CTL_TKIP ) ) {
2009-04-25 14:30:44 +00:00
if ( pDevice - > pMgmt - > eAuthenMode = = WMAC_AUTH_WPANONE ) {
2010-06-05 22:13:49 +00:00
dwMICKey0 = * ( unsigned long * ) ( & pTransmitKey - > abyKey [ 16 ] ) ;
dwMICKey1 = * ( unsigned long * ) ( & pTransmitKey - > abyKey [ 20 ] ) ;
2009-04-25 14:30:44 +00:00
}
else if ( ( pTransmitKey - > dwKeyIndex & AUTHENTICATOR_KEY ) ! = 0 ) {
2010-06-05 22:13:49 +00:00
dwMICKey0 = * ( unsigned long * ) ( & pTransmitKey - > abyKey [ 16 ] ) ;
dwMICKey1 = * ( unsigned long * ) ( & pTransmitKey - > abyKey [ 20 ] ) ;
2009-04-25 14:30:44 +00:00
}
else {
2010-06-05 22:13:49 +00:00
dwMICKey0 = * ( unsigned long * ) ( & pTransmitKey - > abyKey [ 24 ] ) ;
dwMICKey1 = * ( unsigned long * ) ( & pTransmitKey - > abyKey [ 28 ] ) ;
2009-04-25 14:30:44 +00:00
}
// DO Software Michael
MIC_vInit ( dwMICKey0 , dwMICKey1 ) ;
2010-06-05 22:13:47 +00:00
MIC_vAppend ( ( unsigned char * ) & ( psEthHeader - > abyDstAddr [ 0 ] ) , 12 ) ;
2009-04-25 14:30:44 +00:00
dwMIC_Priority = 0 ;
2010-06-05 22:13:47 +00:00
MIC_vAppend ( ( unsigned char * ) & dwMIC_Priority , 4 ) ;
2009-07-30 17:27:21 +00:00
DBG_PRT ( MSG_LEVEL_DEBUG , KERN_INFO " MIC KEY: %lX, %lX \n " , dwMICKey0 , dwMICKey1 ) ;
2009-04-25 14:30:44 +00:00
}
///////////////////////////////////////////////////////////////////
2010-06-05 22:13:47 +00:00
pbyMacHdr = ( unsigned char * ) ( pbyTxBufferAddr + cbHeaderLength ) ;
pbyPayloadHead = ( unsigned char * ) ( pbyMacHdr + cbMACHdLen + uPadding + cbIVlen ) ;
pbyIVHead = ( unsigned char * ) ( pbyMacHdr + cbMACHdLen + uPadding ) ;
2009-04-25 14:30:44 +00:00
2010-08-01 15:15:49 +00:00
if ( ( cbFrameSize > pDevice - > wFragmentationThreshold ) & & ( bNeedACK = = true ) & & ( bIsWEP256 = = false ) ) {
2009-04-25 14:30:44 +00:00
// Fragmentation
// FragThreshold = Fragment size(Hdr+(IV)+fragment payload+(MIC)+(ICV)+FCS)
cbFragmentSize = pDevice - > wFragmentationThreshold ;
cbFragPayloadSize = cbFragmentSize - cbMACHdLen - cbIVlen - cbICVlen - cbFCSlen ;
//FragNum = (FrameSize-(Hdr+FCS))/(Fragment Size -(Hrd+FCS)))
2010-06-24 18:02:26 +00:00
uMACfragNum = ( unsigned short ) ( ( cbFrameBodySize + cbMIClen ) / cbFragPayloadSize ) ;
2009-04-25 14:30:44 +00:00
cbLastFragPayloadSize = ( cbFrameBodySize + cbMIClen ) % cbFragPayloadSize ;
if ( cbLastFragPayloadSize = = 0 ) {
cbLastFragPayloadSize = cbFragPayloadSize ;
} else {
uMACfragNum + + ;
}
//[Hdr+(IV)+last fragment payload+(MIC)+(ICV)+FCS]
cbLastFragmentSize = cbMACHdLen + cbLastFragPayloadSize + cbIVlen + cbICVlen + cbFCSlen ;
for ( uFragIdx = 0 ; uFragIdx < uMACfragNum ; uFragIdx + + ) {
if ( uFragIdx = = 0 ) {
//=========================
// Start Fragmentation
//=========================
2009-07-30 17:27:21 +00:00
DBG_PRT ( MSG_LEVEL_DEBUG , KERN_INFO " Start Fragmentation... \n " ) ;
2009-04-25 14:30:44 +00:00
wFragType = FRAGCTL_STAFRAG ;
//Fill FIFO,RrvTime,RTS,and CTS
2010-05-07 19:30:20 +00:00
s_vGenerateTxParameter ( pDevice , byPktType , ( void * ) psTxBufHd , pvRrvTime , pvRTS , pvCTS ,
2009-04-25 14:30:44 +00:00
cbFragmentSize , bNeedACK , uDMAIdx , psEthHeader , pDevice - > wCurrentRate ) ;
//Fill DataHead
2009-07-30 17:27:21 +00:00
uDuration = s_uFillDataHead ( pDevice , byPktType , pvTxDataHd , cbFragmentSize , uDMAIdx , bNeedACK ,
2009-04-25 14:30:44 +00:00
uFragIdx , cbLastFragmentSize , uMACfragNum , byFBOption , pDevice - > wCurrentRate ) ;
// Generate TX MAC Header
2010-06-24 18:02:26 +00:00
vGenerateMACHeader ( pDevice , pbyMacHdr , ( unsigned short ) uDuration , psEthHeader , bNeedEncrypt ,
2009-04-25 14:30:44 +00:00
wFragType , uDMAIdx , uFragIdx ) ;
2010-08-01 15:15:48 +00:00
if ( bNeedEncrypt = = true ) {
2009-04-25 14:30:44 +00:00
//Fill TXKEY
2010-06-05 22:13:47 +00:00
s_vFillTxKey ( pDevice , ( unsigned char * ) ( psTxBufHd - > adwTxKey ) , pbyIVHead , pTransmitKey ,
2010-06-24 18:02:26 +00:00
pbyMacHdr , ( unsigned short ) cbFragPayloadSize , ( unsigned char * ) pMICHDR ) ;
2009-04-25 14:30:44 +00:00
//Fill IV(ExtIV,RSNHDR)
if ( pDevice - > bEnableHostWEP ) {
pMgmt - > sNodeDBTable [ uNodeIndex ] . dwTSC47_16 = pTransmitKey - > dwTSC47_16 ;
pMgmt - > sNodeDBTable [ uNodeIndex ] . wTSC15_0 = pTransmitKey - > wTSC15_0 ;
}
}
// 802.1H
2010-05-18 18:30:19 +00:00
if ( ntohs ( psEthHeader - > wType ) > ETH_DATA_LEN ) {
2009-04-25 14:30:44 +00:00
if ( ( psEthHeader - > wType = = TYPE_PKT_IPX ) | |
( psEthHeader - > wType = = cpu_to_le16 ( 0xF380 ) ) ) {
2010-06-05 22:13:47 +00:00
memcpy ( ( unsigned char * ) ( pbyPayloadHead ) , & pDevice - > abySNAP_Bridgetunnel [ 0 ] , 6 ) ;
2009-04-25 14:30:44 +00:00
}
else {
2010-06-05 22:13:47 +00:00
memcpy ( ( unsigned char * ) ( pbyPayloadHead ) , & pDevice - > abySNAP_RFC1042 [ 0 ] , 6 ) ;
2009-04-25 14:30:44 +00:00
}
2010-06-05 22:13:47 +00:00
pbyType = ( unsigned char * ) ( pbyPayloadHead + 6 ) ;
2010-06-24 18:02:26 +00:00
memcpy ( pbyType , & ( psEthHeader - > wType ) , sizeof ( unsigned short ) ) ;
2009-04-25 14:30:44 +00:00
cb802_1_H_len = 8 ;
}
cbReqCount = cbHeaderLength + cbMACHdLen + uPadding + cbIVlen + cbFragPayloadSize ;
//---------------------------
// S/W or H/W Encryption
//---------------------------
//Fill MICHDR
//if (pDevice->bAES) {
2010-06-24 18:02:26 +00:00
// s_vFillMICHDR(pDevice, (unsigned char *)pMICHDR, pbyMacHdr, (unsigned short)cbFragPayloadSize);
2009-04-25 14:30:44 +00:00
//}
2010-05-07 19:30:20 +00:00
//cbReqCount += s_uDoEncryption(pDevice, psEthHeader, (void *)psTxBufHd, byKeySel,
2010-06-24 18:02:26 +00:00
// pbyPayloadHead, (unsigned short)cbFragPayloadSize, uDMAIdx);
2009-04-25 14:30:44 +00:00
2010-06-05 22:13:47 +00:00
//pbyBuffer = (unsigned char *)pDevice->aamTxBuf[uDMAIdx][uDescIdx].pbyVAddr;
pbyBuffer = ( unsigned char * ) pHeadTD - > pTDInfo - > buf ;
2009-04-25 14:30:44 +00:00
uLength = cbHeaderLength + cbMACHdLen + uPadding + cbIVlen + cb802_1_H_len ;
//copy TxBufferHeader + MacHeader to desc
2010-05-07 19:30:20 +00:00
memcpy ( pbyBuffer , ( void * ) psTxBufHd , uLength ) ;
2009-04-25 14:30:44 +00:00
// Copy the Packet into a tx Buffer
2009-08-12 21:54:10 +00:00
memcpy ( ( pbyBuffer + uLength ) , ( pPacket + 14 ) , ( cbFragPayloadSize - cb802_1_H_len ) ) ;
2009-04-25 14:30:44 +00:00
uTotalCopyLength + = cbFragPayloadSize - cb802_1_H_len ;
2010-08-01 15:15:48 +00:00
if ( ( bNeedEncrypt = = true ) & & ( pTransmitKey ! = NULL ) & & ( pTransmitKey - > byCipherSuite = = KEY_CTL_TKIP ) ) {
2009-07-30 17:27:21 +00:00
DBG_PRT ( MSG_LEVEL_DEBUG , KERN_INFO " Start MIC: %d \n " , cbFragPayloadSize ) ;
2009-04-25 14:30:44 +00:00
MIC_vAppend ( ( pbyBuffer + uLength - cb802_1_H_len ) , cbFragPayloadSize ) ;
}
//---------------------------
// S/W Encryption
//---------------------------
if ( ( pDevice - > byLocalID < = REV_ID_VT3253_A1 ) ) {
if ( bNeedEncrypt ) {
2010-06-24 18:02:26 +00:00
s_vSWencryption ( pDevice , pTransmitKey , ( pbyBuffer + uLength - cb802_1_H_len ) , ( unsigned short ) cbFragPayloadSize ) ;
2009-04-25 14:30:44 +00:00
cbReqCount + = cbICVlen ;
}
}
ptdCurr = ( PSTxDesc ) pHeadTD ;
//--------------------
//1.Set TSR1 & ReqCount in TxDescHead
//2.Set FragCtl in TxBufferHead
//3.Set Frame Control
//4.Set Sequence Control
//5.Get S/W generate FCS
//--------------------
2010-05-07 19:30:20 +00:00
s_vFillFragParameter ( pDevice , pbyBuffer , uDMAIdx , ( void * ) ptdCurr , wFragType , cbReqCount ) ;
2009-04-25 14:30:44 +00:00
ptdCurr - > pTDInfo - > dwReqCount = cbReqCount - uPadding ;
ptdCurr - > pTDInfo - > dwHeaderLength = cbHeaderLength ;
ptdCurr - > pTDInfo - > skb_dma = ptdCurr - > pTDInfo - > buf_dma ;
ptdCurr - > buff_addr = cpu_to_le32 ( ptdCurr - > pTDInfo - > skb_dma ) ;
pDevice - > iTDUsed [ uDMAIdx ] + + ;
pHeadTD = ptdCurr - > next ;
}
else if ( uFragIdx = = ( uMACfragNum - 1 ) ) {
//=========================
// Last Fragmentation
//=========================
2009-07-30 17:27:21 +00:00
DBG_PRT ( MSG_LEVEL_DEBUG , KERN_INFO " Last Fragmentation... \n " ) ;
2009-04-25 14:30:44 +00:00
//tmpDescIdx = (uDescIdx + uFragIdx) % pDevice->cbTD[uDMAIdx];
wFragType = FRAGCTL_ENDFRAG ;
//Fill FIFO,RrvTime,RTS,and CTS
2010-05-07 19:30:20 +00:00
s_vGenerateTxParameter ( pDevice , byPktType , ( void * ) psTxBufHd , pvRrvTime , pvRTS , pvCTS ,
2009-04-25 14:30:44 +00:00
cbLastFragmentSize , bNeedACK , uDMAIdx , psEthHeader , pDevice - > wCurrentRate ) ;
//Fill DataHead
2009-07-30 17:27:21 +00:00
uDuration = s_uFillDataHead ( pDevice , byPktType , pvTxDataHd , cbLastFragmentSize , uDMAIdx , bNeedACK ,
2009-04-25 14:30:44 +00:00
uFragIdx , cbLastFragmentSize , uMACfragNum , byFBOption , pDevice - > wCurrentRate ) ;
// Generate TX MAC Header
2010-06-24 18:02:26 +00:00
vGenerateMACHeader ( pDevice , pbyMacHdr , ( unsigned short ) uDuration , psEthHeader , bNeedEncrypt ,
2009-04-25 14:30:44 +00:00
wFragType , uDMAIdx , uFragIdx ) ;
2010-08-01 15:15:48 +00:00
if ( bNeedEncrypt = = true ) {
2009-04-25 14:30:44 +00:00
//Fill TXKEY
2010-06-05 22:13:47 +00:00
s_vFillTxKey ( pDevice , ( unsigned char * ) ( psTxBufHd - > adwTxKey ) , pbyIVHead , pTransmitKey ,
2010-06-24 18:02:26 +00:00
pbyMacHdr , ( unsigned short ) cbLastFragPayloadSize , ( unsigned char * ) pMICHDR ) ;
2009-04-25 14:30:44 +00:00
if ( pDevice - > bEnableHostWEP ) {
pMgmt - > sNodeDBTable [ uNodeIndex ] . dwTSC47_16 = pTransmitKey - > dwTSC47_16 ;
pMgmt - > sNodeDBTable [ uNodeIndex ] . wTSC15_0 = pTransmitKey - > wTSC15_0 ;
}
}
cbReqCount = cbHeaderLength + cbMACHdLen + uPadding + cbIVlen + cbLastFragPayloadSize ;
//---------------------------
// S/W or H/W Encryption
//---------------------------
2010-06-05 22:13:47 +00:00
pbyBuffer = ( unsigned char * ) pHeadTD - > pTDInfo - > buf ;
//pbyBuffer = (unsigned char *)pDevice->aamTxBuf[uDMAIdx][tmpDescIdx].pbyVAddr;
2009-04-25 14:30:44 +00:00
uLength = cbHeaderLength + cbMACHdLen + uPadding + cbIVlen ;
//copy TxBufferHeader + MacHeader to desc
2010-05-07 19:30:20 +00:00
memcpy ( pbyBuffer , ( void * ) psTxBufHd , uLength ) ;
2009-04-25 14:30:44 +00:00
// Copy the Packet into a tx Buffer
2010-08-01 15:15:49 +00:00
if ( bMIC2Frag = = false ) {
2009-04-25 14:30:44 +00:00
2009-08-12 21:54:10 +00:00
memcpy ( ( pbyBuffer + uLength ) ,
2009-04-25 14:30:44 +00:00
( pPacket + 14 + uTotalCopyLength ) ,
( cbLastFragPayloadSize - cbMIClen )
) ;
//TODO check uTmpLen !
uTmpLen = cbLastFragPayloadSize - cbMIClen ;
}
2010-08-01 15:15:48 +00:00
if ( ( bNeedEncrypt = = true ) & & ( pTransmitKey ! = NULL ) & & ( pTransmitKey - > byCipherSuite = = KEY_CTL_TKIP ) ) {
2009-07-30 17:27:21 +00:00
DBG_PRT ( MSG_LEVEL_DEBUG , KERN_INFO " LAST: uMICFragLen:%d, cbLastFragPayloadSize:%d, uTmpLen:%d \n " ,
2009-04-25 14:30:44 +00:00
uMICFragLen , cbLastFragPayloadSize , uTmpLen ) ;
2010-08-01 15:15:49 +00:00
if ( bMIC2Frag = = false ) {
2009-04-25 14:30:44 +00:00
if ( uTmpLen ! = 0 )
MIC_vAppend ( ( pbyBuffer + uLength ) , uTmpLen ) ;
2010-06-05 22:13:49 +00:00
pdwMIC_L = ( unsigned long * ) ( pbyBuffer + uLength + uTmpLen ) ;
pdwMIC_R = ( unsigned long * ) ( pbyBuffer + uLength + uTmpLen + 4 ) ;
2009-04-25 14:30:44 +00:00
MIC_vGetMIC ( pdwMIC_L , pdwMIC_R ) ;
2009-07-30 17:27:21 +00:00
DBG_PRT ( MSG_LEVEL_DEBUG , KERN_INFO " Last MIC:%lX, %lX \n " , * pdwMIC_L , * pdwMIC_R ) ;
2009-04-25 14:30:44 +00:00
} else {
if ( uMICFragLen > = 4 ) {
2010-06-05 22:13:47 +00:00
memcpy ( ( pbyBuffer + uLength ) , ( ( unsigned char * ) & dwSafeMIC_R + ( uMICFragLen - 4 ) ) ,
2009-04-25 14:30:44 +00:00
( cbMIClen - uMICFragLen ) ) ;
2009-07-30 17:27:21 +00:00
DBG_PRT ( MSG_LEVEL_DEBUG , KERN_INFO " LAST: uMICFragLen >= 4: %X, %d \n " ,
2010-06-05 22:13:47 +00:00
* ( unsigned char * ) ( ( unsigned char * ) & dwSafeMIC_R + ( uMICFragLen - 4 ) ) ,
2009-04-25 14:30:44 +00:00
( cbMIClen - uMICFragLen ) ) ;
} else {
2010-06-05 22:13:47 +00:00
memcpy ( ( pbyBuffer + uLength ) , ( ( unsigned char * ) & dwSafeMIC_L + uMICFragLen ) ,
2009-04-25 14:30:44 +00:00
( 4 - uMICFragLen ) ) ;
2009-08-12 21:54:10 +00:00
memcpy ( ( pbyBuffer + uLength + ( 4 - uMICFragLen ) ) , & dwSafeMIC_R , 4 ) ;
2009-07-30 17:27:21 +00:00
DBG_PRT ( MSG_LEVEL_DEBUG , KERN_INFO " LAST: uMICFragLen < 4: %X, %d \n " ,
2010-06-05 22:13:47 +00:00
* ( unsigned char * ) ( ( unsigned char * ) & dwSafeMIC_R + uMICFragLen - 4 ) ,
2009-04-25 14:30:44 +00:00
( cbMIClen - uMICFragLen ) ) ;
}
/*
for ( ii = 0 ; ii < cbLastFragPayloadSize + 8 + 24 ; ii + + ) {
2010-06-05 22:13:47 +00:00
DBG_PRT ( MSG_LEVEL_DEBUG , KERN_INFO " %02x " , * ( ( unsigned char * ) ( ( pbyBuffer + uLength ) + ii - 8 - 24 ) ) ) ;
2009-04-25 14:30:44 +00:00
}
2009-07-30 17:27:21 +00:00
DBG_PRT ( MSG_LEVEL_DEBUG , KERN_INFO " \n \n " ) ;
2009-04-25 14:30:44 +00:00
*/
}
MIC_vUnInit ( ) ;
} else {
ASSERT ( uTmpLen = = ( cbLastFragPayloadSize - cbMIClen ) ) ;
}
//---------------------------
// S/W Encryption
//---------------------------
if ( ( pDevice - > byLocalID < = REV_ID_VT3253_A1 ) ) {
if ( bNeedEncrypt ) {
2010-06-24 18:02:26 +00:00
s_vSWencryption ( pDevice , pTransmitKey , ( pbyBuffer + uLength ) , ( unsigned short ) cbLastFragPayloadSize ) ;
2009-04-25 14:30:44 +00:00
cbReqCount + = cbICVlen ;
}
}
ptdCurr = ( PSTxDesc ) pHeadTD ;
//--------------------
//1.Set TSR1 & ReqCount in TxDescHead
//2.Set FragCtl in TxBufferHead
//3.Set Frame Control
//4.Set Sequence Control
//5.Get S/W generate FCS
//--------------------
2010-05-07 19:30:20 +00:00
s_vFillFragParameter ( pDevice , pbyBuffer , uDMAIdx , ( void * ) ptdCurr , wFragType , cbReqCount ) ;
2009-04-25 14:30:44 +00:00
ptdCurr - > pTDInfo - > dwReqCount = cbReqCount - uPadding ;
ptdCurr - > pTDInfo - > dwHeaderLength = cbHeaderLength ;
ptdCurr - > pTDInfo - > skb_dma = ptdCurr - > pTDInfo - > buf_dma ;
ptdCurr - > buff_addr = cpu_to_le32 ( ptdCurr - > pTDInfo - > skb_dma ) ;
pDevice - > iTDUsed [ uDMAIdx ] + + ;
pHeadTD = ptdCurr - > next ;
}
else {
//=========================
// Middle Fragmentation
//=========================
2009-07-30 17:27:21 +00:00
DBG_PRT ( MSG_LEVEL_DEBUG , KERN_INFO " Middle Fragmentation... \n " ) ;
2009-04-25 14:30:44 +00:00
//tmpDescIdx = (uDescIdx + uFragIdx) % pDevice->cbTD[uDMAIdx];
wFragType = FRAGCTL_MIDFRAG ;
//Fill FIFO,RrvTime,RTS,and CTS
2010-05-07 19:30:20 +00:00
s_vGenerateTxParameter ( pDevice , byPktType , ( void * ) psTxBufHd , pvRrvTime , pvRTS , pvCTS ,
2009-04-25 14:30:44 +00:00
cbFragmentSize , bNeedACK , uDMAIdx , psEthHeader , pDevice - > wCurrentRate ) ;
//Fill DataHead
2009-07-30 17:27:21 +00:00
uDuration = s_uFillDataHead ( pDevice , byPktType , pvTxDataHd , cbFragmentSize , uDMAIdx , bNeedACK ,
2009-04-25 14:30:44 +00:00
uFragIdx , cbLastFragmentSize , uMACfragNum , byFBOption , pDevice - > wCurrentRate ) ;
// Generate TX MAC Header
2010-06-24 18:02:26 +00:00
vGenerateMACHeader ( pDevice , pbyMacHdr , ( unsigned short ) uDuration , psEthHeader , bNeedEncrypt ,
2009-04-25 14:30:44 +00:00
wFragType , uDMAIdx , uFragIdx ) ;
2010-08-01 15:15:48 +00:00
if ( bNeedEncrypt = = true ) {
2009-04-25 14:30:44 +00:00
//Fill TXKEY
2010-06-05 22:13:47 +00:00
s_vFillTxKey ( pDevice , ( unsigned char * ) ( psTxBufHd - > adwTxKey ) , pbyIVHead , pTransmitKey ,
2010-06-24 18:02:26 +00:00
pbyMacHdr , ( unsigned short ) cbFragPayloadSize , ( unsigned char * ) pMICHDR ) ;
2009-04-25 14:30:44 +00:00
if ( pDevice - > bEnableHostWEP ) {
pMgmt - > sNodeDBTable [ uNodeIndex ] . dwTSC47_16 = pTransmitKey - > dwTSC47_16 ;
pMgmt - > sNodeDBTable [ uNodeIndex ] . wTSC15_0 = pTransmitKey - > wTSC15_0 ;
}
}
cbReqCount = cbHeaderLength + cbMACHdLen + uPadding + cbIVlen + cbFragPayloadSize ;
//---------------------------
// S/W or H/W Encryption
//---------------------------
//Fill MICHDR
//if (pDevice->bAES) {
2010-06-24 18:02:26 +00:00
// s_vFillMICHDR(pDevice, (unsigned char *)pMICHDR, pbyMacHdr, (unsigned short)cbFragPayloadSize);
2009-04-25 14:30:44 +00:00
//}
2010-05-07 19:30:20 +00:00
//cbReqCount += s_uDoEncryption(pDevice, psEthHeader, (void *)psTxBufHd, byKeySel,
2010-06-24 18:02:26 +00:00
// pbyPayloadHead, (unsigned short)cbFragPayloadSize, uDMAIdx);
2009-04-25 14:30:44 +00:00
2010-06-05 22:13:47 +00:00
pbyBuffer = ( unsigned char * ) pHeadTD - > pTDInfo - > buf ;
//pbyBuffer = (unsigned char *)pDevice->aamTxBuf[uDMAIdx][tmpDescIdx].pbyVAddr;
2009-04-25 14:30:44 +00:00
uLength = cbHeaderLength + cbMACHdLen + uPadding + cbIVlen ;
//copy TxBufferHeader + MacHeader to desc
2010-05-07 19:30:20 +00:00
memcpy ( pbyBuffer , ( void * ) psTxBufHd , uLength ) ;
2009-04-25 14:30:44 +00:00
// Copy the Packet into a tx Buffer
2009-08-12 21:54:10 +00:00
memcpy ( ( pbyBuffer + uLength ) ,
2009-04-25 14:30:44 +00:00
( pPacket + 14 + uTotalCopyLength ) ,
cbFragPayloadSize
) ;
uTmpLen = cbFragPayloadSize ;
uTotalCopyLength + = uTmpLen ;
2010-08-01 15:15:48 +00:00
if ( ( bNeedEncrypt = = true ) & & ( pTransmitKey ! = NULL ) & & ( pTransmitKey - > byCipherSuite = = KEY_CTL_TKIP ) ) {
2009-04-25 14:30:44 +00:00
MIC_vAppend ( ( pbyBuffer + uLength ) , uTmpLen ) ;
if ( uTmpLen < cbFragPayloadSize ) {
2010-08-01 15:15:48 +00:00
bMIC2Frag = true ;
2009-04-25 14:30:44 +00:00
uMICFragLen = cbFragPayloadSize - uTmpLen ;
ASSERT ( uMICFragLen < cbMIClen ) ;
2010-06-05 22:13:49 +00:00
pdwMIC_L = ( unsigned long * ) ( pbyBuffer + uLength + uTmpLen ) ;
pdwMIC_R = ( unsigned long * ) ( pbyBuffer + uLength + uTmpLen + 4 ) ;
2009-04-25 14:30:44 +00:00
MIC_vGetMIC ( pdwMIC_L , pdwMIC_R ) ;
dwSafeMIC_L = * pdwMIC_L ;
dwSafeMIC_R = * pdwMIC_R ;
2009-07-30 17:27:21 +00:00
DBG_PRT ( MSG_LEVEL_DEBUG , KERN_INFO " MIDDLE: uMICFragLen:%d, cbFragPayloadSize:%d, uTmpLen:%d \n " ,
2009-04-25 14:30:44 +00:00
uMICFragLen , cbFragPayloadSize , uTmpLen ) ;
2009-07-30 17:27:21 +00:00
DBG_PRT ( MSG_LEVEL_DEBUG , KERN_INFO " Fill MIC in Middle frag [%d] \n " , uMICFragLen ) ;
2009-04-25 14:30:44 +00:00
/*
for ( ii = 0 ; ii < uMICFragLen ; ii + + ) {
2010-06-05 22:13:47 +00:00
DBG_PRT ( MSG_LEVEL_DEBUG , KERN_INFO " %02x " , * ( ( unsigned char * ) ( ( pbyBuffer + uLength + uTmpLen ) + ii ) ) ) ;
2009-04-25 14:30:44 +00:00
}
2009-07-30 17:27:21 +00:00
DBG_PRT ( MSG_LEVEL_DEBUG , KERN_INFO " \n " ) ;
2009-04-25 14:30:44 +00:00
*/
2009-07-30 17:27:21 +00:00
DBG_PRT ( MSG_LEVEL_DEBUG , KERN_INFO " Get MIC:%lX, %lX \n " , * pdwMIC_L , * pdwMIC_R ) ;
2009-04-25 14:30:44 +00:00
}
2009-07-30 17:27:21 +00:00
DBG_PRT ( MSG_LEVEL_DEBUG , KERN_INFO " Middle frag len: %d \n " , uTmpLen ) ;
2009-04-25 14:30:44 +00:00
/*
for ( ii = 0 ; ii < uTmpLen ; ii + + ) {
2010-06-05 22:13:47 +00:00
DBG_PRT ( MSG_LEVEL_DEBUG , KERN_INFO " %02x " , * ( ( unsigned char * ) ( ( pbyBuffer + uLength ) + ii ) ) ) ;
2009-04-25 14:30:44 +00:00
}
2009-07-30 17:27:21 +00:00
DBG_PRT ( MSG_LEVEL_DEBUG , KERN_INFO " \n \n " ) ;
2009-04-25 14:30:44 +00:00
*/
} else {
ASSERT ( uTmpLen = = ( cbFragPayloadSize ) ) ;
}
if ( ( pDevice - > byLocalID < = REV_ID_VT3253_A1 ) ) {
if ( bNeedEncrypt ) {
2010-06-24 18:02:26 +00:00
s_vSWencryption ( pDevice , pTransmitKey , ( pbyBuffer + uLength ) , ( unsigned short ) cbFragPayloadSize ) ;
2009-04-25 14:30:44 +00:00
cbReqCount + = cbICVlen ;
}
}
ptdCurr = ( PSTxDesc ) pHeadTD ;
//--------------------
//1.Set TSR1 & ReqCount in TxDescHead
//2.Set FragCtl in TxBufferHead
//3.Set Frame Control
//4.Set Sequence Control
//5.Get S/W generate FCS
//--------------------
2010-05-07 19:30:20 +00:00
s_vFillFragParameter ( pDevice , pbyBuffer , uDMAIdx , ( void * ) ptdCurr , wFragType , cbReqCount ) ;
2009-04-25 14:30:44 +00:00
ptdCurr - > pTDInfo - > dwReqCount = cbReqCount - uPadding ;
ptdCurr - > pTDInfo - > dwHeaderLength = cbHeaderLength ;
ptdCurr - > pTDInfo - > skb_dma = ptdCurr - > pTDInfo - > buf_dma ;
ptdCurr - > buff_addr = cpu_to_le32 ( ptdCurr - > pTDInfo - > skb_dma ) ;
pDevice - > iTDUsed [ uDMAIdx ] + + ;
pHeadTD = ptdCurr - > next ;
}
} // for (uMACfragNum)
}
else {
//=========================
// No Fragmentation
//=========================
2009-07-30 17:27:21 +00:00
//DBG_PRTGRP03(("No Fragmentation...\n"));
//DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"No Fragmentation...\n");
2009-04-25 14:30:44 +00:00
wFragType = FRAGCTL_NONFRAG ;
//Set FragCtl in TxBufferHead
2010-06-24 18:02:26 +00:00
psTxBufHd - > wFragCtl | = ( unsigned short ) wFragType ;
2009-04-25 14:30:44 +00:00
//Fill FIFO,RrvTime,RTS,and CTS
2010-05-07 19:30:20 +00:00
s_vGenerateTxParameter ( pDevice , byPktType , ( void * ) psTxBufHd , pvRrvTime , pvRTS , pvCTS ,
2009-04-25 14:30:44 +00:00
cbFrameSize , bNeedACK , uDMAIdx , psEthHeader , pDevice - > wCurrentRate ) ;
//Fill DataHead
2009-07-30 17:27:21 +00:00
uDuration = s_uFillDataHead ( pDevice , byPktType , pvTxDataHd , cbFrameSize , uDMAIdx , bNeedACK ,
2009-04-25 14:30:44 +00:00
0 , 0 , uMACfragNum , byFBOption , pDevice - > wCurrentRate ) ;
// Generate TX MAC Header
2010-06-24 18:02:26 +00:00
vGenerateMACHeader ( pDevice , pbyMacHdr , ( unsigned short ) uDuration , psEthHeader , bNeedEncrypt ,
2009-04-25 14:30:44 +00:00
wFragType , uDMAIdx , 0 ) ;
2010-08-01 15:15:48 +00:00
if ( bNeedEncrypt = = true ) {
2009-04-25 14:30:44 +00:00
//Fill TXKEY
2010-06-05 22:13:47 +00:00
s_vFillTxKey ( pDevice , ( unsigned char * ) ( psTxBufHd - > adwTxKey ) , pbyIVHead , pTransmitKey ,
2010-06-24 18:02:26 +00:00
pbyMacHdr , ( unsigned short ) cbFrameBodySize , ( unsigned char * ) pMICHDR ) ;
2009-04-25 14:30:44 +00:00
if ( pDevice - > bEnableHostWEP ) {
pMgmt - > sNodeDBTable [ uNodeIndex ] . dwTSC47_16 = pTransmitKey - > dwTSC47_16 ;
pMgmt - > sNodeDBTable [ uNodeIndex ] . wTSC15_0 = pTransmitKey - > wTSC15_0 ;
}
}
// 802.1H
2010-05-18 18:30:19 +00:00
if ( ntohs ( psEthHeader - > wType ) > ETH_DATA_LEN ) {
2009-04-25 14:30:44 +00:00
if ( ( psEthHeader - > wType = = TYPE_PKT_IPX ) | |
( psEthHeader - > wType = = cpu_to_le16 ( 0xF380 ) ) ) {
2010-06-05 22:13:47 +00:00
memcpy ( ( unsigned char * ) ( pbyPayloadHead ) , & pDevice - > abySNAP_Bridgetunnel [ 0 ] , 6 ) ;
2009-04-25 14:30:44 +00:00
}
else {
2010-06-05 22:13:47 +00:00
memcpy ( ( unsigned char * ) ( pbyPayloadHead ) , & pDevice - > abySNAP_RFC1042 [ 0 ] , 6 ) ;
2009-04-25 14:30:44 +00:00
}
2010-06-05 22:13:47 +00:00
pbyType = ( unsigned char * ) ( pbyPayloadHead + 6 ) ;
2010-06-24 18:02:26 +00:00
memcpy ( pbyType , & ( psEthHeader - > wType ) , sizeof ( unsigned short ) ) ;
2009-04-25 14:30:44 +00:00
cb802_1_H_len = 8 ;
}
cbReqCount = cbHeaderLength + cbMACHdLen + uPadding + cbIVlen + ( cbFrameBodySize + cbMIClen ) ;
//---------------------------
// S/W or H/W Encryption
//---------------------------
//Fill MICHDR
//if (pDevice->bAES) {
2009-07-30 17:27:21 +00:00
// DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Fill MICHDR...\n");
2010-06-24 18:02:26 +00:00
// s_vFillMICHDR(pDevice, (unsigned char *)pMICHDR, pbyMacHdr, (unsigned short)cbFrameBodySize);
2009-04-25 14:30:44 +00:00
//}
2010-06-05 22:13:47 +00:00
pbyBuffer = ( unsigned char * ) pHeadTD - > pTDInfo - > buf ;
//pbyBuffer = (unsigned char *)pDevice->aamTxBuf[uDMAIdx][uDescIdx].pbyVAddr;
2009-04-25 14:30:44 +00:00
uLength = cbHeaderLength + cbMACHdLen + uPadding + cbIVlen + cb802_1_H_len ;
//copy TxBufferHeader + MacHeader to desc
2010-05-07 19:30:20 +00:00
memcpy ( pbyBuffer , ( void * ) psTxBufHd , uLength ) ;
2009-04-25 14:30:44 +00:00
// Copy the Packet into a tx Buffer
2009-08-12 21:54:10 +00:00
memcpy ( ( pbyBuffer + uLength ) ,
2009-04-25 14:30:44 +00:00
( pPacket + 14 ) ,
cbFrameBodySize - cb802_1_H_len
) ;
2010-08-01 15:15:48 +00:00
if ( ( bNeedEncrypt = = true ) & & ( pTransmitKey ! = NULL ) & & ( pTransmitKey - > byCipherSuite = = KEY_CTL_TKIP ) ) {
2009-04-25 14:30:44 +00:00
2009-07-30 17:27:21 +00:00
DBG_PRT ( MSG_LEVEL_DEBUG , KERN_INFO " Length:%d, %d \n " , cbFrameBodySize - cb802_1_H_len , uLength ) ;
2009-04-25 14:30:44 +00:00
/*
for ( ii = 0 ; ii < ( cbFrameBodySize - cb802_1_H_len ) ; ii + + ) {
2010-06-05 22:13:47 +00:00
DBG_PRT ( MSG_LEVEL_DEBUG , KERN_INFO " %02x " , * ( ( unsigned char * ) ( ( pbyBuffer + uLength ) + ii ) ) ) ;
2009-04-25 14:30:44 +00:00
}
2009-07-30 17:27:21 +00:00
DBG_PRT ( MSG_LEVEL_DEBUG , KERN_INFO " \n " ) ;
2009-04-25 14:30:44 +00:00
*/
MIC_vAppend ( ( pbyBuffer + uLength - cb802_1_H_len ) , cbFrameBodySize ) ;
2010-06-05 22:13:49 +00:00
pdwMIC_L = ( unsigned long * ) ( pbyBuffer + uLength - cb802_1_H_len + cbFrameBodySize ) ;
pdwMIC_R = ( unsigned long * ) ( pbyBuffer + uLength - cb802_1_H_len + cbFrameBodySize + 4 ) ;
2009-04-25 14:30:44 +00:00
MIC_vGetMIC ( pdwMIC_L , pdwMIC_R ) ;
MIC_vUnInit ( ) ;
2010-08-01 15:15:48 +00:00
if ( pDevice - > bTxMICFail = = true ) {
2009-04-25 14:30:44 +00:00
* pdwMIC_L = 0 ;
* pdwMIC_R = 0 ;
2010-08-01 15:15:49 +00:00
pDevice - > bTxMICFail = false ;
2009-04-25 14:30:44 +00:00
}
2009-07-30 17:27:21 +00:00
DBG_PRT ( MSG_LEVEL_DEBUG , KERN_INFO " uLength: %d, %d \n " , uLength , cbFrameBodySize ) ;
DBG_PRT ( MSG_LEVEL_DEBUG , KERN_INFO " cbReqCount:%d, %d, %d, %d \n " , cbReqCount , cbHeaderLength , uPadding , cbIVlen ) ;
DBG_PRT ( MSG_LEVEL_DEBUG , KERN_INFO " MIC:%lx, %lx \n " , * pdwMIC_L , * pdwMIC_R ) ;
2009-04-25 14:30:44 +00:00
/*
for ( ii = 0 ; ii < 8 ; ii + + ) {
2010-06-05 22:13:47 +00:00
DBG_PRT ( MSG_LEVEL_DEBUG , KERN_INFO " %02x " , * ( ( ( unsigned char * ) ( pdwMIC_L ) + ii ) ) ) ;
2009-04-25 14:30:44 +00:00
}
2009-07-30 17:27:21 +00:00
DBG_PRT ( MSG_LEVEL_DEBUG , KERN_INFO " \n " ) ;
2009-04-25 14:30:44 +00:00
*/
}
if ( ( pDevice - > byLocalID < = REV_ID_VT3253_A1 ) ) {
if ( bNeedEncrypt ) {
s_vSWencryption ( pDevice , pTransmitKey , ( pbyBuffer + uLength - cb802_1_H_len ) ,
2010-06-24 18:02:26 +00:00
( unsigned short ) ( cbFrameBodySize + cbMIClen ) ) ;
2009-04-25 14:30:44 +00:00
cbReqCount + = cbICVlen ;
}
}
ptdCurr = ( PSTxDesc ) pHeadTD ;
ptdCurr - > pTDInfo - > dwReqCount = cbReqCount - uPadding ;
ptdCurr - > pTDInfo - > dwHeaderLength = cbHeaderLength ;
ptdCurr - > pTDInfo - > skb_dma = ptdCurr - > pTDInfo - > buf_dma ;
ptdCurr - > buff_addr = cpu_to_le32 ( ptdCurr - > pTDInfo - > skb_dma ) ;
//Set TSR1 & ReqCount in TxDescHead
ptdCurr - > m_td1TD1 . byTCR | = ( TCR_STP | TCR_EDP | EDMSDU ) ;
2010-06-24 18:02:26 +00:00
ptdCurr - > m_td1TD1 . wReqCount = cpu_to_le16 ( ( unsigned short ) ( cbReqCount ) ) ;
2009-04-25 14:30:44 +00:00
pDevice - > iTDUsed [ uDMAIdx ] + + ;
2009-07-30 17:27:21 +00:00
// DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" ptdCurr->m_dwReserved0[%d] ptdCurr->m_dwReserved1[%d].\n", ptdCurr->pTDInfo->dwReqCount, ptdCurr->pTDInfo->dwHeaderLength);
// DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" cbHeaderLength[%d]\n", cbHeaderLength);
2009-04-25 14:30:44 +00:00
}
* puMACfragNum = uMACfragNum ;
2009-07-30 17:27:21 +00:00
//DBG_PRTGRP03(("s_cbFillTxBufHead END\n"));
2009-04-25 14:30:44 +00:00
return cbHeaderLength ;
}
2010-05-07 19:30:19 +00:00
void
2010-06-25 17:48:53 +00:00
vGenerateFIFOHeader ( PSDevice pDevice , unsigned char byPktType , unsigned char * pbyTxBufferAddr ,
2010-08-01 15:15:50 +00:00
bool bNeedEncrypt , unsigned int cbPayloadSize , unsigned int uDMAIdx ,
2010-06-25 17:48:53 +00:00
PSTxDesc pHeadTD , PSEthernetHeader psEthHeader , unsigned char * pPacket ,
PSKeyItem pTransmitKey , unsigned int uNodeIndex , unsigned int * puMACfragNum ,
unsigned int * pcbHeaderSize )
2009-04-25 14:30:44 +00:00
{
2010-06-02 16:52:01 +00:00
unsigned int wTxBufSize ; // FFinfo size
2010-08-01 15:15:50 +00:00
bool bNeedACK ;
bool bIsAdhoc ;
2010-06-24 18:02:26 +00:00
unsigned short cbMacHdLen ;
2009-04-25 14:30:44 +00:00
PSTxBufHead pTxBufHead = ( PSTxBufHead ) pbyTxBufferAddr ;
wTxBufSize = sizeof ( STxBufHead ) ;
2009-08-12 21:54:10 +00:00
memset ( pTxBufHead , 0 , wTxBufSize ) ;
2009-04-25 14:30:44 +00:00
//Set FIFOCTL_NEEDACK
if ( ( pDevice - > eOPMode = = OP_MODE_ADHOC ) | |
( pDevice - > eOPMode = = OP_MODE_AP ) ) {
2010-06-30 07:46:24 +00:00
if ( is_multicast_ether_addr ( & ( psEthHeader - > abyDstAddr [ 0 ] ) ) ) {
2010-08-01 15:15:49 +00:00
bNeedACK = false ;
2009-04-25 14:30:44 +00:00
pTxBufHead - > wFIFOCtl = pTxBufHead - > wFIFOCtl & ( ~ FIFOCTL_NEEDACK ) ;
}
else {
2010-08-01 15:15:48 +00:00
bNeedACK = true ;
2009-04-25 14:30:44 +00:00
pTxBufHead - > wFIFOCtl | = FIFOCTL_NEEDACK ;
}
2010-08-01 15:15:48 +00:00
bIsAdhoc = true ;
2009-04-25 14:30:44 +00:00
}
else {
// MSDUs in Infra mode always need ACK
2010-08-01 15:15:48 +00:00
bNeedACK = true ;
2009-04-25 14:30:44 +00:00
pTxBufHead - > wFIFOCtl | = FIFOCTL_NEEDACK ;
2010-08-01 15:15:49 +00:00
bIsAdhoc = false ;
2009-04-25 14:30:44 +00:00
}
pTxBufHead - > wFIFOCtl | = FIFOCTL_TMOEN ;
pTxBufHead - > wTimeStamp = cpu_to_le16 ( DEFAULT_MSDU_LIFETIME_RES_64us ) ;
//Set FIFOCTL_LHEAD
if ( pDevice - > bLongHeader )
pTxBufHead - > wFIFOCtl | = FIFOCTL_LHEAD ;
//Set FIFOCTL_GENINT
pTxBufHead - > wFIFOCtl | = FIFOCTL_GENINT ;
//Set FIFOCTL_ISDMA0
if ( TYPE_TXDMA0 = = uDMAIdx ) {
pTxBufHead - > wFIFOCtl | = FIFOCTL_ISDMA0 ;
}
//Set FRAGCTL_MACHDCNT
if ( pDevice - > bLongHeader ) {
cbMacHdLen = WLAN_HDR_ADDR3_LEN + 6 ;
} else {
cbMacHdLen = WLAN_HDR_ADDR3_LEN ;
}
2010-06-24 18:02:26 +00:00
pTxBufHead - > wFragCtl | = cpu_to_le16 ( ( unsigned short ) ( cbMacHdLen < < 10 ) ) ;
2009-04-25 14:30:44 +00:00
//Set packet type
2009-07-30 17:27:21 +00:00
if ( byPktType = = PK_TYPE_11A ) { //0000 0000 0000 0000
2009-04-25 14:30:44 +00:00
;
}
2009-07-30 17:27:21 +00:00
else if ( byPktType = = PK_TYPE_11B ) { //0000 0001 0000 0000
2009-04-25 14:30:44 +00:00
pTxBufHead - > wFIFOCtl | = FIFOCTL_11B ;
}
2009-07-30 17:27:21 +00:00
else if ( byPktType = = PK_TYPE_11GB ) { //0000 0010 0000 0000
2009-04-25 14:30:44 +00:00
pTxBufHead - > wFIFOCtl | = FIFOCTL_11GB ;
}
2009-07-30 17:27:21 +00:00
else if ( byPktType = = PK_TYPE_11GA ) { //0000 0011 0000 0000
2009-04-25 14:30:44 +00:00
pTxBufHead - > wFIFOCtl | = FIFOCTL_11GA ;
}
//Set FIFOCTL_GrpAckPolicy
2010-08-01 15:15:48 +00:00
if ( pDevice - > bGrpAckPolicy = = true ) { //0000 0100 0000 0000
2009-04-25 14:30:44 +00:00
pTxBufHead - > wFIFOCtl | = FIFOCTL_GRPACK ;
}
//Set Auto Fallback Ctl
if ( pDevice - > wCurrentRate > = RATE_18M ) {
if ( pDevice - > byAutoFBCtrl = = AUTO_FB_0 ) {
pTxBufHead - > wFIFOCtl | = FIFOCTL_AUTO_FB_0 ;
} else if ( pDevice - > byAutoFBCtrl = = AUTO_FB_1 ) {
pTxBufHead - > wFIFOCtl | = FIFOCTL_AUTO_FB_1 ;
}
}
//Set FRAGCTL_WEPTYP
2010-08-01 15:15:49 +00:00
pDevice - > bAES = false ;
2009-04-25 14:30:44 +00:00
//Set FRAGCTL_WEPTYP
if ( pDevice - > byLocalID > REV_ID_VT3253_A1 ) {
if ( ( bNeedEncrypt ) & & ( pTransmitKey ! = NULL ) ) { //WEP enabled
if ( pTransmitKey - > byCipherSuite = = KEY_CTL_TKIP ) {
pTxBufHead - > wFragCtl | = FRAGCTL_TKIP ;
}
else if ( pTransmitKey - > byCipherSuite = = KEY_CTL_WEP ) { //WEP40 or WEP104
if ( pTransmitKey - > uKeyLength ! = WLAN_WEP232_KEYLEN )
pTxBufHead - > wFragCtl | = FRAGCTL_LEGACY ;
}
else if ( pTransmitKey - > byCipherSuite = = KEY_CTL_CCMP ) { //CCMP
pTxBufHead - > wFragCtl | = FRAGCTL_AES ;
}
}
}
# ifdef PLICE_DEBUG
//printk("Func:vGenerateFIFOHeader:TxDataRate is %d,TxPower is %d\n",pDevice->wCurrentRate,pDevice->byCurPwr);
//if (pDevice->wCurrentRate <= 3)
//{
// RFbRawSetPower(pDevice,36,pDevice->wCurrentRate);
//}
//else
RFbSetPower ( pDevice , pDevice - > wCurrentRate , pDevice - > byCurrentCh ) ;
# endif
//if (pDevice->wCurrentRate == 3)
//pDevice->byCurPwr = 46;
pTxBufHead - > byTxPower = pDevice - > byCurPwr ;
/*
if ( pDevice - > bEnableHostWEP )
pTxBufHead - > wFragCtl & = ~ ( FRAGCTL_TKIP | FRAGCTL_LEGACY | FRAGCTL_AES ) ;
*/
2009-07-30 17:27:21 +00:00
* pcbHeaderSize = s_cbFillTxBufHead ( pDevice , byPktType , pbyTxBufferAddr , cbPayloadSize ,
2009-04-25 14:30:44 +00:00
uDMAIdx , pHeadTD , psEthHeader , pPacket , bNeedEncrypt ,
pTransmitKey , uNodeIndex , puMACfragNum ) ;
return ;
}
/*+
*
* Description :
* Translate 802.3 to 802.11 header
*
* Parameters :
* In :
2010-03-29 13:41:47 +00:00
* pDevice - Pointer to adapter
2009-04-25 14:30:44 +00:00
* dwTxBufferAddr - Transmit Buffer
* pPacket - Packet from upper layer
* cbPacketSize - Transmit Data Length
* Out :
* pcbHeadSize - Header size of MAC & Baseband control and 802.11 Header
* pcbAppendPayload - size of append payload for 802.1 H translation
*
* Return Value : none
*
- */
2010-05-07 19:30:19 +00:00
void
2009-04-25 14:30:44 +00:00
vGenerateMACHeader (
2010-05-13 03:54:39 +00:00
PSDevice pDevice ,
2010-06-05 22:13:47 +00:00
unsigned char * pbyBufferAddr ,
2010-06-24 18:02:26 +00:00
unsigned short wDuration ,
2010-05-13 03:54:39 +00:00
PSEthernetHeader psEthHeader ,
2010-08-01 15:15:50 +00:00
bool bNeedEncrypt ,
2010-06-24 18:02:26 +00:00
unsigned short wFragType ,
2010-06-02 16:52:01 +00:00
unsigned int uDMAIdx ,
unsigned int uFragIdx
2009-04-25 14:30:44 +00:00
)
{
PS802_11Header pMACHeader = ( PS802_11Header ) pbyBufferAddr ;
2009-08-12 21:54:10 +00:00
memset ( pMACHeader , 0 , ( sizeof ( S802_11Header ) ) ) ; //- sizeof(pMACHeader->dwIV)));
2009-04-25 14:30:44 +00:00
if ( uDMAIdx = = TYPE_ATIMDMA ) {
pMACHeader - > wFrameCtl = TYPE_802_11_ATIM ;
} else {
pMACHeader - > wFrameCtl = TYPE_802_11_DATA ;
}
if ( pDevice - > eOPMode = = OP_MODE_AP ) {
2010-05-15 02:37:32 +00:00
memcpy ( & ( pMACHeader - > abyAddr1 [ 0 ] ) , & ( psEthHeader - > abyDstAddr [ 0 ] ) , ETH_ALEN ) ;
memcpy ( & ( pMACHeader - > abyAddr2 [ 0 ] ) , & ( pDevice - > abyBSSID [ 0 ] ) , ETH_ALEN ) ;
memcpy ( & ( pMACHeader - > abyAddr3 [ 0 ] ) , & ( psEthHeader - > abySrcAddr [ 0 ] ) , ETH_ALEN ) ;
2009-04-25 14:30:44 +00:00
pMACHeader - > wFrameCtl | = FC_FROMDS ;
}
else {
if ( pDevice - > eOPMode = = OP_MODE_ADHOC ) {
2010-05-15 02:37:32 +00:00
memcpy ( & ( pMACHeader - > abyAddr1 [ 0 ] ) , & ( psEthHeader - > abyDstAddr [ 0 ] ) , ETH_ALEN ) ;
memcpy ( & ( pMACHeader - > abyAddr2 [ 0 ] ) , & ( psEthHeader - > abySrcAddr [ 0 ] ) , ETH_ALEN ) ;
memcpy ( & ( pMACHeader - > abyAddr3 [ 0 ] ) , & ( pDevice - > abyBSSID [ 0 ] ) , ETH_ALEN ) ;
2009-04-25 14:30:44 +00:00
}
else {
2010-05-15 02:37:32 +00:00
memcpy ( & ( pMACHeader - > abyAddr3 [ 0 ] ) , & ( psEthHeader - > abyDstAddr [ 0 ] ) , ETH_ALEN ) ;
memcpy ( & ( pMACHeader - > abyAddr2 [ 0 ] ) , & ( psEthHeader - > abySrcAddr [ 0 ] ) , ETH_ALEN ) ;
memcpy ( & ( pMACHeader - > abyAddr1 [ 0 ] ) , & ( pDevice - > abyBSSID [ 0 ] ) , ETH_ALEN ) ;
2009-04-25 14:30:44 +00:00
pMACHeader - > wFrameCtl | = FC_TODS ;
}
}
if ( bNeedEncrypt )
2010-06-24 18:02:26 +00:00
pMACHeader - > wFrameCtl | = cpu_to_le16 ( ( unsigned short ) WLAN_SET_FC_ISWEP ( 1 ) ) ;
2009-04-25 14:30:44 +00:00
pMACHeader - > wDurationID = cpu_to_le16 ( wDuration ) ;
if ( pDevice - > bLongHeader ) {
PWLAN_80211HDR_A4 pMACA4Header = ( PWLAN_80211HDR_A4 ) pbyBufferAddr ;
pMACHeader - > wFrameCtl | = ( FC_TODS | FC_FROMDS ) ;
2009-08-12 21:54:10 +00:00
memcpy ( pMACA4Header - > abyAddr4 , pDevice - > abyBSSID , WLAN_ADDR_LEN ) ;
2009-04-25 14:30:44 +00:00
}
pMACHeader - > wSeqCtl = cpu_to_le16 ( pDevice - > wSeqCounter < < 4 ) ;
//Set FragNumber in Sequence Control
2010-06-24 18:02:26 +00:00
pMACHeader - > wSeqCtl | = cpu_to_le16 ( ( unsigned short ) uFragIdx ) ;
2009-04-25 14:30:44 +00:00
if ( ( wFragType = = FRAGCTL_ENDFRAG ) | | ( wFragType = = FRAGCTL_NONFRAG ) ) {
pDevice - > wSeqCounter + + ;
if ( pDevice - > wSeqCounter > 0x0fff )
pDevice - > wSeqCounter = 0 ;
}
if ( ( wFragType = = FRAGCTL_STAFRAG ) | | ( wFragType = = FRAGCTL_MIDFRAG ) ) { //StartFrag or MidFrag
pMACHeader - > wFrameCtl | = FC_MOREFRAG ;
}
}
CMD_STATUS csMgmt_xmit ( PSDevice pDevice , PSTxMgmtPacket pPacket ) {
PSTxDesc pFrstTD ;
2010-06-24 18:02:27 +00:00
unsigned char byPktType ;
2010-06-05 22:13:47 +00:00
unsigned char * pbyTxBufferAddr ;
2010-05-07 19:30:20 +00:00
void * pvRTS ;
2009-04-25 14:30:44 +00:00
PSCTS pCTS ;
2010-05-07 19:30:20 +00:00
void * pvTxDataHd ;
2010-06-02 16:52:01 +00:00
unsigned int uDuration ;
unsigned int cbReqCount ;
2009-04-25 14:30:44 +00:00
PS802_11Header pMACHeader ;
2010-06-02 16:52:01 +00:00
unsigned int cbHeaderSize ;
unsigned int cbFrameBodySize ;
2010-08-01 15:15:50 +00:00
bool bNeedACK ;
bool bIsPSPOLL = false ;
2009-04-25 14:30:44 +00:00
PSTxBufHead pTxBufHead ;
2010-06-02 16:52:01 +00:00
unsigned int cbFrameSize ;
unsigned int cbIVlen = 0 ;
unsigned int cbICVlen = 0 ;
unsigned int cbMIClen = 0 ;
unsigned int cbFCSlen = 4 ;
unsigned int uPadding = 0 ;
2010-06-24 18:02:26 +00:00
unsigned short wTxBufSize ;
2010-06-02 16:52:01 +00:00
unsigned int cbMacHdLen ;
2009-04-25 14:30:44 +00:00
SEthernetHeader sEthHeader ;
2010-05-07 19:30:20 +00:00
void * pvRrvTime ;
void * pMICHDR ;
2009-04-25 14:30:44 +00:00
PSMgmtObject pMgmt = pDevice - > pMgmt ;
2010-06-24 18:02:26 +00:00
unsigned short wCurrentRate = RATE_1M ;
2009-04-25 14:30:44 +00:00
if ( AVAIL_TD ( pDevice , TYPE_TXDMA0 ) < = 0 ) {
return CMD_STATUS_RESOURCES ;
}
pFrstTD = pDevice - > apCurrTD [ TYPE_TXDMA0 ] ;
2010-06-05 22:13:47 +00:00
pbyTxBufferAddr = ( unsigned char * ) pFrstTD - > pTDInfo - > buf ;
2009-04-25 14:30:44 +00:00
cbFrameBodySize = pPacket - > cbPayloadLen ;
pTxBufHead = ( PSTxBufHead ) pbyTxBufferAddr ;
wTxBufSize = sizeof ( STxBufHead ) ;
memset ( pTxBufHead , 0 , wTxBufSize ) ;
if ( pDevice - > eCurrentPHYType = = PHY_TYPE_11A ) {
wCurrentRate = RATE_6M ;
2009-07-30 17:27:21 +00:00
byPktType = PK_TYPE_11A ;
2009-04-25 14:30:44 +00:00
} else {
wCurrentRate = RATE_1M ;
2009-07-30 17:27:21 +00:00
byPktType = PK_TYPE_11B ;
2009-04-25 14:30:44 +00:00
}
// SetPower will cause error power TX state for OFDM Date packet in TX buffer.
// 2004.11.11 Kyle -- Using OFDM power to tx MngPkt will decrease the connection capability.
// And cmd timer will wait data pkt TX finish before scanning so it's OK
// to set power here.
if ( pDevice - > pMgmt - > eScanState ! = WMAC_NO_SCANNING ) {
RFbSetPower ( pDevice , wCurrentRate , pDevice - > byCurrentCh ) ;
} else {
RFbSetPower ( pDevice , wCurrentRate , pMgmt - > uCurrChannel ) ;
}
pTxBufHead - > byTxPower = pDevice - > byCurPwr ;
//+++++++++++++++++++++ Patch VT3253 A1 performance +++++++++++++++++++++++++++
if ( pDevice - > byFOETuning ) {
if ( ( pPacket - > p80211Header - > sA3 . wFrameCtl & TYPE_DATE_NULL ) = = TYPE_DATE_NULL ) {
wCurrentRate = RATE_24M ;
2009-07-30 17:27:21 +00:00
byPktType = PK_TYPE_11GA ;
2009-04-25 14:30:44 +00:00
}
}
//Set packet type
2009-07-30 17:27:21 +00:00
if ( byPktType = = PK_TYPE_11A ) { //0000 0000 0000 0000
2009-04-25 14:30:44 +00:00
pTxBufHead - > wFIFOCtl = 0 ;
}
2009-07-30 17:27:21 +00:00
else if ( byPktType = = PK_TYPE_11B ) { //0000 0001 0000 0000
2009-04-25 14:30:44 +00:00
pTxBufHead - > wFIFOCtl | = FIFOCTL_11B ;
}
2009-07-30 17:27:21 +00:00
else if ( byPktType = = PK_TYPE_11GB ) { //0000 0010 0000 0000
2009-04-25 14:30:44 +00:00
pTxBufHead - > wFIFOCtl | = FIFOCTL_11GB ;
}
2009-07-30 17:27:21 +00:00
else if ( byPktType = = PK_TYPE_11GA ) { //0000 0011 0000 0000
2009-04-25 14:30:44 +00:00
pTxBufHead - > wFIFOCtl | = FIFOCTL_11GA ;
}
pTxBufHead - > wFIFOCtl | = FIFOCTL_TMOEN ;
pTxBufHead - > wTimeStamp = cpu_to_le16 ( DEFAULT_MGN_LIFETIME_RES_64us ) ;
2010-06-30 07:46:24 +00:00
if ( is_multicast_ether_addr ( & ( pPacket - > p80211Header - > sA3 . abyAddr1 [ 0 ] ) ) )
2010-08-01 15:15:49 +00:00
bNeedACK = false ;
2009-04-25 14:30:44 +00:00
else {
2010-08-01 15:15:48 +00:00
bNeedACK = true ;
2009-04-25 14:30:44 +00:00
pTxBufHead - > wFIFOCtl | = FIFOCTL_NEEDACK ;
} ;
if ( ( pMgmt - > eCurrMode = = WMAC_MODE_ESS_AP ) | |
( pMgmt - > eCurrMode = = WMAC_MODE_IBSS_STA ) ) {
pTxBufHead - > wFIFOCtl | = FIFOCTL_LRETRY ;
//Set Preamble type always long
//pDevice->byPreambleType = PREAMBLE_LONG;
// probe-response don't retry
//if ((pPacket->p80211Header->sA4.wFrameCtl & TYPE_SUBTYPE_MASK) == TYPE_MGMT_PROBE_RSP) {
2010-08-01 15:15:49 +00:00
// bNeedACK = false;
2009-04-25 14:30:44 +00:00
// pTxBufHead->wFIFOCtl &= (~FIFOCTL_NEEDACK);
//}
}
pTxBufHead - > wFIFOCtl | = ( FIFOCTL_GENINT | FIFOCTL_ISDMA0 ) ;
if ( ( pPacket - > p80211Header - > sA4 . wFrameCtl & TYPE_SUBTYPE_MASK ) = = TYPE_CTL_PSPOLL ) {
2010-08-01 15:15:48 +00:00
bIsPSPOLL = true ;
2009-04-25 14:30:44 +00:00
cbMacHdLen = WLAN_HDR_ADDR2_LEN ;
} else {
cbMacHdLen = WLAN_HDR_ADDR3_LEN ;
}
//Set FRAGCTL_MACHDCNT
2010-06-24 18:02:26 +00:00
pTxBufHead - > wFragCtl | = cpu_to_le16 ( ( unsigned short ) ( cbMacHdLen < < 10 ) ) ;
2009-04-25 14:30:44 +00:00
// Notes:
2012-12-25 16:23:29 +00:00
// Although spec says MMPDU can be fragmented; In most cases,
2009-04-25 14:30:44 +00:00
// no one will send a MMPDU under fragmentation. With RTS may occur.
2010-08-01 15:15:49 +00:00
pDevice - > bAES = false ; //Set FRAGCTL_WEPTYP
2009-04-25 14:30:44 +00:00
if ( WLAN_GET_FC_ISWEP ( pPacket - > p80211Header - > sA4 . wFrameCtl ) ! = 0 ) {
if ( pDevice - > eEncryptionStatus = = Ndis802_11Encryption1Enabled ) {
cbIVlen = 4 ;
cbICVlen = 4 ;
pTxBufHead - > wFragCtl | = FRAGCTL_LEGACY ;
}
else if ( pDevice - > eEncryptionStatus = = Ndis802_11Encryption2Enabled ) {
cbIVlen = 8 ; //IV+ExtIV
cbMIClen = 8 ;
cbICVlen = 4 ;
pTxBufHead - > wFragCtl | = FRAGCTL_TKIP ;
//We need to get seed here for filling TxKey entry.
//TKIPvMixKey(pTransmitKey->abyKey, pDevice->abyCurrentNetAddr,
// pTransmitKey->wTSC15_0, pTransmitKey->dwTSC47_16, pDevice->abyPRNG);
}
else if ( pDevice - > eEncryptionStatus = = Ndis802_11Encryption3Enabled ) {
cbIVlen = 8 ; //RSN Header
cbICVlen = 8 ; //MIC
pTxBufHead - > wFragCtl | = FRAGCTL_AES ;
2010-08-01 15:15:48 +00:00
pDevice - > bAES = true ;
2009-04-25 14:30:44 +00:00
}
//MAC Header should be padding 0 to DW alignment.
uPadding = 4 - ( cbMacHdLen % 4 ) ;
uPadding % = 4 ;
}
cbFrameSize = cbMacHdLen + cbFrameBodySize + cbIVlen + cbMIClen + cbICVlen + cbFCSlen ;
//Set FIFOCTL_GrpAckPolicy
2010-08-01 15:15:48 +00:00
if ( pDevice - > bGrpAckPolicy = = true ) { //0000 0100 0000 0000
2009-04-25 14:30:44 +00:00
pTxBufHead - > wFIFOCtl | = FIFOCTL_GRPACK ;
}
//the rest of pTxBufHead->wFragCtl:FragTyp will be set later in s_vFillFragParameter()
//Set RrvTime/RTS/CTS Buffer
2009-07-30 17:27:21 +00:00
if ( byPktType = = PK_TYPE_11GB | | byPktType = = PK_TYPE_11GA ) { //802.11g packet
2009-04-25 14:30:44 +00:00
pvRrvTime = ( PSRrvTime_gCTS ) ( pbyTxBufferAddr + wTxBufSize ) ;
pMICHDR = NULL ;
pvRTS = NULL ;
pCTS = ( PSCTS ) ( pbyTxBufferAddr + wTxBufSize + sizeof ( SRrvTime_gCTS ) ) ;
pvTxDataHd = ( PSTxDataHead_g ) ( pbyTxBufferAddr + wTxBufSize + sizeof ( SRrvTime_gCTS ) + sizeof ( SCTS ) ) ;
cbHeaderSize = wTxBufSize + sizeof ( SRrvTime_gCTS ) + sizeof ( SCTS ) + sizeof ( STxDataHead_g ) ;
}
else { // 802.11a/b packet
pvRrvTime = ( PSRrvTime_ab ) ( pbyTxBufferAddr + wTxBufSize ) ;
pMICHDR = NULL ;
pvRTS = NULL ;
pCTS = NULL ;
pvTxDataHd = ( PSTxDataHead_ab ) ( pbyTxBufferAddr + wTxBufSize + sizeof ( SRrvTime_ab ) ) ;
cbHeaderSize = wTxBufSize + sizeof ( SRrvTime_ab ) + sizeof ( STxDataHead_ab ) ;
}
2010-05-07 19:30:20 +00:00
memset ( ( void * ) ( pbyTxBufferAddr + wTxBufSize ) , 0 , ( cbHeaderSize - wTxBufSize ) ) ;
2009-04-25 14:30:44 +00:00
2010-05-15 02:37:32 +00:00
memcpy ( & ( sEthHeader . abyDstAddr [ 0 ] ) , & ( pPacket - > p80211Header - > sA3 . abyAddr1 [ 0 ] ) , ETH_ALEN ) ;
memcpy ( & ( sEthHeader . abySrcAddr [ 0 ] ) , & ( pPacket - > p80211Header - > sA3 . abyAddr2 [ 0 ] ) , ETH_ALEN ) ;
2009-04-25 14:30:44 +00:00
//=========================
// No Fragmentation
//=========================
2010-06-24 18:02:26 +00:00
pTxBufHead - > wFragCtl | = ( unsigned short ) FRAGCTL_NONFRAG ;
2009-04-25 14:30:44 +00:00
//Fill FIFO,RrvTime,RTS,and CTS
2009-07-30 17:27:21 +00:00
s_vGenerateTxParameter ( pDevice , byPktType , pbyTxBufferAddr , pvRrvTime , pvRTS , pCTS ,
2009-04-25 14:30:44 +00:00
cbFrameSize , bNeedACK , TYPE_TXDMA0 , & sEthHeader , wCurrentRate ) ;
//Fill DataHead
2009-07-30 17:27:21 +00:00
uDuration = s_uFillDataHead ( pDevice , byPktType , pvTxDataHd , cbFrameSize , TYPE_TXDMA0 , bNeedACK ,
2009-04-25 14:30:44 +00:00
0 , 0 , 1 , AUTO_FB_NONE , wCurrentRate ) ;
pMACHeader = ( PS802_11Header ) ( pbyTxBufferAddr + cbHeaderSize ) ;
cbReqCount = cbHeaderSize + cbMacHdLen + uPadding + cbIVlen + cbFrameBodySize ;
if ( WLAN_GET_FC_ISWEP ( pPacket - > p80211Header - > sA4 . wFrameCtl ) ! = 0 ) {
2010-06-05 22:13:47 +00:00
unsigned char * pbyIVHead ;
unsigned char * pbyPayloadHead ;
unsigned char * pbyBSSID ;
2009-04-25 14:30:44 +00:00
PSKeyItem pTransmitKey = NULL ;
2010-06-05 22:13:47 +00:00
pbyIVHead = ( unsigned char * ) ( pbyTxBufferAddr + cbHeaderSize + cbMacHdLen + uPadding ) ;
pbyPayloadHead = ( unsigned char * ) ( pbyTxBufferAddr + cbHeaderSize + cbMacHdLen + uPadding + cbIVlen ) ;
2009-04-25 14:30:44 +00:00
//Fill TXKEY
2012-12-25 16:23:29 +00:00
//Kyle: Need fix: TKIP and AES did't encrypt Mnt Packet.
2010-06-05 22:13:47 +00:00
//s_vFillTxKey(pDevice, (unsigned char *)pTxBufHead->adwTxKey, NULL);
2009-04-25 14:30:44 +00:00
//Fill IV(ExtIV,RSNHDR)
//s_vFillPrePayload(pDevice, pbyIVHead, NULL);
//---------------------------
// S/W or H/W Encryption
//---------------------------
//Fill MICHDR
//if (pDevice->bAES) {
2010-06-24 18:02:26 +00:00
// s_vFillMICHDR(pDevice, (unsigned char *)pMICHDR, (unsigned char *)pMACHeader, (unsigned short)cbFrameBodySize);
2009-04-25 14:30:44 +00:00
//}
do {
if ( ( pDevice - > eOPMode = = OP_MODE_INFRASTRUCTURE ) & &
2010-08-01 15:15:48 +00:00
( pDevice - > bLinkPass = = true ) ) {
2009-04-25 14:30:44 +00:00
pbyBSSID = pDevice - > abyBSSID ;
// get pairwise key
2010-08-01 15:15:49 +00:00
if ( KeybGetTransmitKey ( & ( pDevice - > sKey ) , pbyBSSID , PAIRWISE_KEY , & pTransmitKey ) = = false ) {
2009-04-25 14:30:44 +00:00
// get group key
2010-08-01 15:15:48 +00:00
if ( KeybGetTransmitKey ( & ( pDevice - > sKey ) , pbyBSSID , GROUP_KEY , & pTransmitKey ) = = true ) {
2009-07-30 17:27:21 +00:00
DBG_PRT ( MSG_LEVEL_DEBUG , KERN_INFO " Get GTK. \n " ) ;
2009-04-25 14:30:44 +00:00
break ;
}
} else {
2009-07-30 17:27:21 +00:00
DBG_PRT ( MSG_LEVEL_DEBUG , KERN_INFO " Get PTK. \n " ) ;
2009-04-25 14:30:44 +00:00
break ;
}
}
// get group key
pbyBSSID = pDevice - > abyBroadcastAddr ;
2010-08-01 15:15:49 +00:00
if ( KeybGetTransmitKey ( & ( pDevice - > sKey ) , pbyBSSID , GROUP_KEY , & pTransmitKey ) = = false ) {
2009-04-25 14:30:44 +00:00
pTransmitKey = NULL ;
2009-07-30 17:27:21 +00:00
DBG_PRT ( MSG_LEVEL_DEBUG , KERN_INFO " KEY is NULL. OP Mode[%d] \n " , pDevice - > eOPMode ) ;
2009-04-25 14:30:44 +00:00
} else {
2009-07-30 17:27:21 +00:00
DBG_PRT ( MSG_LEVEL_DEBUG , KERN_INFO " Get GTK. \n " ) ;
2009-04-25 14:30:44 +00:00
}
2010-08-01 15:15:49 +00:00
} while ( false ) ;
2009-04-25 14:30:44 +00:00
//Fill TXKEY
2010-06-05 22:13:47 +00:00
s_vFillTxKey ( pDevice , ( unsigned char * ) ( pTxBufHead - > adwTxKey ) , pbyIVHead , pTransmitKey ,
2010-06-24 18:02:26 +00:00
( unsigned char * ) pMACHeader , ( unsigned short ) cbFrameBodySize , NULL ) ;
2009-04-25 14:30:44 +00:00
2009-08-12 21:54:10 +00:00
memcpy ( pMACHeader , pPacket - > p80211Header , cbMacHdLen ) ;
2010-06-05 22:13:47 +00:00
memcpy ( pbyPayloadHead , ( ( unsigned char * ) ( pPacket - > p80211Header ) + cbMacHdLen ) ,
2009-04-25 14:30:44 +00:00
cbFrameBodySize ) ;
}
else {
// Copy the Packet into a tx Buffer
2009-08-12 21:54:10 +00:00
memcpy ( pMACHeader , pPacket - > p80211Header , pPacket - > cbMPDULen ) ;
2009-04-25 14:30:44 +00:00
}
pMACHeader - > wSeqCtl = cpu_to_le16 ( pDevice - > wSeqCounter < < 4 ) ;
pDevice - > wSeqCounter + + ;
if ( pDevice - > wSeqCounter > 0x0fff )
pDevice - > wSeqCounter = 0 ;
if ( bIsPSPOLL ) {
// The MAC will automatically replace the Duration-field of MAC header by Duration-field
// of FIFO control header.
2012-08-20 15:43:13 +00:00
// This will cause AID-field of PS-POLL packet to be incorrect (Because PS-POLL's AID field is
2009-04-25 14:30:44 +00:00
// in the same place of other packet's Duration-field).
// And it will cause Cisco-AP to issue Disassociation-packet
2009-07-30 17:27:21 +00:00
if ( byPktType = = PK_TYPE_11GB | | byPktType = = PK_TYPE_11GA ) {
2009-04-25 14:30:44 +00:00
( ( PSTxDataHead_g ) pvTxDataHd ) - > wDuration_a = cpu_to_le16 ( pPacket - > p80211Header - > sA2 . wDurationID ) ;
( ( PSTxDataHead_g ) pvTxDataHd ) - > wDuration_b = cpu_to_le16 ( pPacket - > p80211Header - > sA2 . wDurationID ) ;
} else {
( ( PSTxDataHead_ab ) pvTxDataHd ) - > wDuration = cpu_to_le16 ( pPacket - > p80211Header - > sA2 . wDurationID ) ;
}
}
// first TD is the only TD
//Set TSR1 & ReqCount in TxDescHead
pFrstTD - > m_td1TD1 . byTCR = ( TCR_STP | TCR_EDP | EDMSDU ) ;
pFrstTD - > pTDInfo - > skb_dma = pFrstTD - > pTDInfo - > buf_dma ;
2010-06-24 18:02:26 +00:00
pFrstTD - > m_td1TD1 . wReqCount = cpu_to_le16 ( ( unsigned short ) ( cbReqCount ) ) ;
2009-04-25 14:30:44 +00:00
pFrstTD - > buff_addr = cpu_to_le32 ( pFrstTD - > pTDInfo - > skb_dma ) ;
pFrstTD - > pTDInfo - > byFlags = 0 ;
if ( MACbIsRegBitsOn ( pDevice - > PortOffset , MAC_REG_PSCTL , PSCTL_PS ) ) {
// Disable PS
MACbPSWakeup ( pDevice - > PortOffset ) ;
}
2010-08-01 15:15:49 +00:00
pDevice - > bPWBitOn = false ;
2009-04-25 14:30:44 +00:00
wmb ( ) ;
pFrstTD - > m_td0TD0 . f1Owner = OWNED_BY_NIC ;
wmb ( ) ;
pDevice - > iTDUsed [ TYPE_TXDMA0 ] + + ;
if ( AVAIL_TD ( pDevice , TYPE_TXDMA0 ) < = 1 ) {
2009-07-30 17:27:21 +00:00
DBG_PRT ( MSG_LEVEL_DEBUG , KERN_INFO " available td0 <= 1 \n " ) ;
2009-04-25 14:30:44 +00:00
}
pDevice - > apCurrTD [ TYPE_TXDMA0 ] = pFrstTD - > next ;
# ifdef PLICE_DEBUG
//printk("SCAN:CurrentRate is %d,TxPower is %d\n",wCurrentRate,pTxBufHead->byTxPower);
# endif
# ifdef TxInSleep
pDevice - > nTxDataTimeCout = 0 ; //2008-8-21 chester <add> for send null packet
# endif
// Poll Transmit the adapter
MACvTransmit0 ( pDevice - > PortOffset ) ;
return CMD_STATUS_PENDING ;
}
CMD_STATUS csBeacon_xmit ( PSDevice pDevice , PSTxMgmtPacket pPacket ) {
2010-06-24 18:02:27 +00:00
unsigned char byPktType ;
2010-06-05 22:13:47 +00:00
unsigned char * pbyBuffer = ( unsigned char * ) pDevice - > tx_beacon_bufs ;
2010-06-02 16:52:01 +00:00
unsigned int cbFrameSize = pPacket - > cbMPDULen + WLAN_FCS_LEN ;
unsigned int cbHeaderSize = 0 ;
2010-06-24 18:02:26 +00:00
unsigned short wTxBufSize = sizeof ( STxShortBufHead ) ;
2009-04-25 14:30:44 +00:00
PSTxShortBufHead pTxBufHead = ( PSTxShortBufHead ) pbyBuffer ;
PSTxDataHead_ab pTxDataHead = ( PSTxDataHead_ab ) ( pbyBuffer + wTxBufSize ) ;
PS802_11Header pMACHeader ;
2010-06-24 18:02:26 +00:00
unsigned short wCurrentRate ;
unsigned short wLen = 0x0000 ;
2009-04-25 14:30:44 +00:00
memset ( pTxBufHead , 0 , wTxBufSize ) ;
if ( pDevice - > eCurrentPHYType = = PHY_TYPE_11A ) {
wCurrentRate = RATE_6M ;
2009-07-30 17:27:21 +00:00
byPktType = PK_TYPE_11A ;
2009-04-25 14:30:44 +00:00
} else {
wCurrentRate = RATE_2M ;
2009-07-30 17:27:21 +00:00
byPktType = PK_TYPE_11B ;
2009-04-25 14:30:44 +00:00
}
//Set Preamble type always long
pDevice - > byPreambleType = PREAMBLE_LONG ;
//Set FIFOCTL_GENINT
pTxBufHead - > wFIFOCtl | = FIFOCTL_GENINT ;
//Set packet type & Get Duration
2009-07-30 17:27:21 +00:00
if ( byPktType = = PK_TYPE_11A ) { //0000 0000 0000 0000
2010-06-24 18:02:26 +00:00
pTxDataHead - > wDuration = cpu_to_le16 ( ( unsigned short ) s_uGetDataDuration ( pDevice , DATADUR_A , cbFrameSize , byPktType ,
2010-08-01 15:15:49 +00:00
wCurrentRate , false , 0 , 0 , 1 , AUTO_FB_NONE ) ) ;
2009-04-25 14:30:44 +00:00
}
2009-07-30 17:27:21 +00:00
else if ( byPktType = = PK_TYPE_11B ) { //0000 0001 0000 0000
2009-04-25 14:30:44 +00:00
pTxBufHead - > wFIFOCtl | = FIFOCTL_11B ;
2010-06-24 18:02:26 +00:00
pTxDataHead - > wDuration = cpu_to_le16 ( ( unsigned short ) s_uGetDataDuration ( pDevice , DATADUR_B , cbFrameSize , byPktType ,
2010-08-01 15:15:49 +00:00
wCurrentRate , false , 0 , 0 , 1 , AUTO_FB_NONE ) ) ;
2009-04-25 14:30:44 +00:00
}
2012-08-20 15:43:15 +00:00
BBvCalculateParameter ( pDevice , cbFrameSize , wCurrentRate , byPktType ,
2010-06-05 22:13:48 +00:00
( unsigned short * ) & ( wLen ) , ( unsigned char * ) & ( pTxDataHead - > byServiceField ) , ( unsigned char * ) & ( pTxDataHead - > bySignalField )
2009-04-25 14:30:44 +00:00
) ;
pTxDataHead - > wTransmitLength = cpu_to_le16 ( wLen ) ;
//Get TimeStampOff
pTxDataHead - > wTimeStampOff = cpu_to_le16 ( wTimeStampOff [ pDevice - > byPreambleType % 2 ] [ wCurrentRate % MAX_RATE ] ) ;
cbHeaderSize = wTxBufSize + sizeof ( STxDataHead_ab ) ;
//Generate Beacon Header
pMACHeader = ( PS802_11Header ) ( pbyBuffer + cbHeaderSize ) ;
2009-08-12 21:54:10 +00:00
memcpy ( pMACHeader , pPacket - > p80211Header , pPacket - > cbMPDULen ) ;
2009-04-25 14:30:44 +00:00
pMACHeader - > wDurationID = 0 ;
pMACHeader - > wSeqCtl = cpu_to_le16 ( pDevice - > wSeqCounter < < 4 ) ;
pDevice - > wSeqCounter + + ;
if ( pDevice - > wSeqCounter > 0x0fff )
pDevice - > wSeqCounter = 0 ;
// Set Beacon buffer length
pDevice - > wBCNBufLen = pPacket - > cbMPDULen + cbHeaderSize ;
MACvSetCurrBCNTxDescAddr ( pDevice - > PortOffset , ( pDevice - > tx_beacon_dma ) ) ;
MACvSetCurrBCNLength ( pDevice - > PortOffset , pDevice - > wBCNBufLen ) ;
// Set auto Transmit on
MACvRegBitsOn ( pDevice - > PortOffset , MAC_REG_TCR , TCR_AUTOBCNTX ) ;
// Poll Transmit the adapter
MACvTransmitBCN ( pDevice - > PortOffset ) ;
return CMD_STATUS_PENDING ;
}
2010-06-02 16:52:01 +00:00
unsigned int
2009-04-25 14:30:44 +00:00
cbGetFragCount (
2010-05-13 03:54:39 +00:00
PSDevice pDevice ,
PSKeyItem pTransmitKey ,
2010-06-02 16:52:01 +00:00
unsigned int cbFrameBodySize ,
2010-05-13 03:54:39 +00:00
PSEthernetHeader psEthHeader
2009-04-25 14:30:44 +00:00
)
{
2010-06-02 16:52:01 +00:00
unsigned int cbMACHdLen ;
unsigned int cbFrameSize ;
unsigned int cbFragmentSize ; //Hdr+(IV)+payoad+(MIC)+(ICV)+FCS
unsigned int cbFragPayloadSize ;
unsigned int cbLastFragPayloadSize ;
unsigned int cbIVlen = 0 ;
unsigned int cbICVlen = 0 ;
unsigned int cbMIClen = 0 ;
unsigned int cbFCSlen = 4 ;
unsigned int uMACfragNum = 1 ;
2010-08-01 15:15:50 +00:00
bool bNeedACK ;
2009-04-25 14:30:44 +00:00
if ( ( pDevice - > eOPMode = = OP_MODE_ADHOC ) | |
( pDevice - > eOPMode = = OP_MODE_AP ) ) {
2010-06-30 07:46:24 +00:00
if ( is_multicast_ether_addr ( & ( psEthHeader - > abyDstAddr [ 0 ] ) ) )
2010-08-01 15:15:49 +00:00
bNeedACK = false ;
2010-06-30 07:46:24 +00:00
else
2010-08-01 15:15:48 +00:00
bNeedACK = true ;
2009-04-25 14:30:44 +00:00
}
else {
// MSDUs in Infra mode always need ACK
2010-08-01 15:15:48 +00:00
bNeedACK = true ;
2009-04-25 14:30:44 +00:00
}
if ( pDevice - > bLongHeader )
cbMACHdLen = WLAN_HDR_ADDR3_LEN + 6 ;
else
cbMACHdLen = WLAN_HDR_ADDR3_LEN ;
2010-08-01 15:15:48 +00:00
if ( pDevice - > bEncryptionEnable = = true ) {
2009-04-25 14:30:44 +00:00
if ( pTransmitKey = = NULL ) {
if ( ( pDevice - > eEncryptionStatus = = Ndis802_11Encryption1Enabled ) | |
( pDevice - > pMgmt - > eAuthenMode < WMAC_AUTH_WPA ) ) {
cbIVlen = 4 ;
cbICVlen = 4 ;
} else if ( pDevice - > eEncryptionStatus = = Ndis802_11Encryption2Enabled ) {
cbIVlen = 8 ; //IV+ExtIV
cbMIClen = 8 ;
cbICVlen = 4 ;
} else if ( pDevice - > eEncryptionStatus = = Ndis802_11Encryption3Enabled ) {
cbIVlen = 8 ; //RSN Header
cbICVlen = 8 ; //MIC
}
} else if ( pTransmitKey - > byCipherSuite = = KEY_CTL_WEP ) {
cbIVlen = 4 ;
cbICVlen = 4 ;
} else if ( pTransmitKey - > byCipherSuite = = KEY_CTL_TKIP ) {
cbIVlen = 8 ; //IV+ExtIV
cbMIClen = 8 ;
cbICVlen = 4 ;
} else if ( pTransmitKey - > byCipherSuite = = KEY_CTL_CCMP ) {
cbIVlen = 8 ; //RSN Header
cbICVlen = 8 ; //MIC
}
}
cbFrameSize = cbMACHdLen + cbIVlen + ( cbFrameBodySize + cbMIClen ) + cbICVlen + cbFCSlen ;
2010-08-01 15:15:48 +00:00
if ( ( cbFrameSize > pDevice - > wFragmentationThreshold ) & & ( bNeedACK = = true ) ) {
2009-04-25 14:30:44 +00:00
// Fragmentation
cbFragmentSize = pDevice - > wFragmentationThreshold ;
cbFragPayloadSize = cbFragmentSize - cbMACHdLen - cbIVlen - cbICVlen - cbFCSlen ;
2010-06-24 18:02:26 +00:00
uMACfragNum = ( unsigned short ) ( ( cbFrameBodySize + cbMIClen ) / cbFragPayloadSize ) ;
2009-04-25 14:30:44 +00:00
cbLastFragPayloadSize = ( cbFrameBodySize + cbMIClen ) % cbFragPayloadSize ;
if ( cbLastFragPayloadSize = = 0 ) {
cbLastFragPayloadSize = cbFragPayloadSize ;
} else {
uMACfragNum + + ;
}
}
return uMACfragNum ;
}
2010-05-07 19:30:19 +00:00
void
2010-06-05 22:13:47 +00:00
vDMA0_tx_80211 ( PSDevice pDevice , struct sk_buff * skb , unsigned char * pbMPDU , unsigned int cbMPDULen ) {
2009-04-25 14:30:44 +00:00
PSTxDesc pFrstTD ;
2010-06-24 18:02:27 +00:00
unsigned char byPktType ;
2010-06-05 22:13:47 +00:00
unsigned char * pbyTxBufferAddr ;
2010-05-07 19:30:20 +00:00
void * pvRTS ;
void * pvCTS ;
void * pvTxDataHd ;
2010-06-02 16:52:01 +00:00
unsigned int uDuration ;
unsigned int cbReqCount ;
2009-04-25 14:30:44 +00:00
PS802_11Header pMACHeader ;
2010-06-02 16:52:01 +00:00
unsigned int cbHeaderSize ;
unsigned int cbFrameBodySize ;
2010-08-01 15:15:50 +00:00
bool bNeedACK ;
bool bIsPSPOLL = false ;
2009-04-25 14:30:44 +00:00
PSTxBufHead pTxBufHead ;
2010-06-02 16:52:01 +00:00
unsigned int cbFrameSize ;
unsigned int cbIVlen = 0 ;
unsigned int cbICVlen = 0 ;
unsigned int cbMIClen = 0 ;
unsigned int cbFCSlen = 4 ;
unsigned int uPadding = 0 ;
unsigned int cbMICHDR = 0 ;
unsigned int uLength = 0 ;
2010-06-24 18:02:25 +00:00
unsigned long dwMICKey0 , dwMICKey1 ;
unsigned long dwMIC_Priority ;
2010-06-05 22:13:49 +00:00
unsigned long * pdwMIC_L ;
unsigned long * pdwMIC_R ;
2010-06-24 18:02:26 +00:00
unsigned short wTxBufSize ;
2010-06-02 16:52:01 +00:00
unsigned int cbMacHdLen ;
2009-04-25 14:30:44 +00:00
SEthernetHeader sEthHeader ;
2010-05-07 19:30:20 +00:00
void * pvRrvTime ;
void * pMICHDR ;
2009-04-25 14:30:44 +00:00
PSMgmtObject pMgmt = pDevice - > pMgmt ;
2010-06-24 18:02:26 +00:00
unsigned short wCurrentRate = RATE_1M ;
2009-04-25 14:30:44 +00:00
PUWLAN_80211HDR p80211Header ;
2010-06-02 16:52:01 +00:00
unsigned int uNodeIndex = 0 ;
2010-08-01 15:15:50 +00:00
bool bNodeExist = false ;
2009-04-25 14:30:44 +00:00
SKeyItem STempKey ;
PSKeyItem pTransmitKey = NULL ;
2010-06-05 22:13:47 +00:00
unsigned char * pbyIVHead ;
unsigned char * pbyPayloadHead ;
unsigned char * pbyMacHdr ;
2009-04-25 14:30:44 +00:00
2010-06-02 16:52:01 +00:00
unsigned int cbExtSuppRate = 0 ;
2009-04-25 14:30:44 +00:00
// PWLAN_IE pItem;
pvRrvTime = pMICHDR = pvRTS = pvCTS = pvTxDataHd = NULL ;
if ( cbMPDULen < = WLAN_HDR_ADDR3_LEN ) {
cbFrameBodySize = 0 ;
}
else {
cbFrameBodySize = cbMPDULen - WLAN_HDR_ADDR3_LEN ;
}
p80211Header = ( PUWLAN_80211HDR ) pbMPDU ;
pFrstTD = pDevice - > apCurrTD [ TYPE_TXDMA0 ] ;
2010-06-05 22:13:47 +00:00
pbyTxBufferAddr = ( unsigned char * ) pFrstTD - > pTDInfo - > buf ;
2009-04-25 14:30:44 +00:00
pTxBufHead = ( PSTxBufHead ) pbyTxBufferAddr ;
wTxBufSize = sizeof ( STxBufHead ) ;
memset ( pTxBufHead , 0 , wTxBufSize ) ;
if ( pDevice - > eCurrentPHYType = = PHY_TYPE_11A ) {
wCurrentRate = RATE_6M ;
2009-07-30 17:27:21 +00:00
byPktType = PK_TYPE_11A ;
2009-04-25 14:30:44 +00:00
} else {
wCurrentRate = RATE_1M ;
2009-07-30 17:27:21 +00:00
byPktType = PK_TYPE_11B ;
2009-04-25 14:30:44 +00:00
}
// SetPower will cause error power TX state for OFDM Date packet in TX buffer.
// 2004.11.11 Kyle -- Using OFDM power to tx MngPkt will decrease the connection capability.
2012-08-20 15:43:13 +00:00
// And cmd timer will wait data pkt TX to finish before scanning so it's OK
2009-04-25 14:30:44 +00:00
// to set power here.
if ( pDevice - > pMgmt - > eScanState ! = WMAC_NO_SCANNING ) {
RFbSetPower ( pDevice , wCurrentRate , pDevice - > byCurrentCh ) ;
} else {
RFbSetPower ( pDevice , wCurrentRate , pMgmt - > uCurrChannel ) ;
}
pTxBufHead - > byTxPower = pDevice - > byCurPwr ;
//+++++++++++++++++++++ Patch VT3253 A1 performance +++++++++++++++++++++++++++
if ( pDevice - > byFOETuning ) {
if ( ( p80211Header - > sA3 . wFrameCtl & TYPE_DATE_NULL ) = = TYPE_DATE_NULL ) {
wCurrentRate = RATE_24M ;
2009-07-30 17:27:21 +00:00
byPktType = PK_TYPE_11GA ;
2009-04-25 14:30:44 +00:00
}
}
2009-07-30 17:27:21 +00:00
DBG_PRT ( MSG_LEVEL_DEBUG , KERN_INFO " vDMA0_tx_80211: p80211Header->sA3.wFrameCtl = %x \n " , p80211Header - > sA3 . wFrameCtl ) ;
2009-04-25 14:30:44 +00:00
//Set packet type
2009-07-30 17:27:21 +00:00
if ( byPktType = = PK_TYPE_11A ) { //0000 0000 0000 0000
2009-04-25 14:30:44 +00:00
pTxBufHead - > wFIFOCtl = 0 ;
}
2009-07-30 17:27:21 +00:00
else if ( byPktType = = PK_TYPE_11B ) { //0000 0001 0000 0000
2009-04-25 14:30:44 +00:00
pTxBufHead - > wFIFOCtl | = FIFOCTL_11B ;
}
2009-07-30 17:27:21 +00:00
else if ( byPktType = = PK_TYPE_11GB ) { //0000 0010 0000 0000
2009-04-25 14:30:44 +00:00
pTxBufHead - > wFIFOCtl | = FIFOCTL_11GB ;
}
2009-07-30 17:27:21 +00:00
else if ( byPktType = = PK_TYPE_11GA ) { //0000 0011 0000 0000
2009-04-25 14:30:44 +00:00
pTxBufHead - > wFIFOCtl | = FIFOCTL_11GA ;
}
pTxBufHead - > wFIFOCtl | = FIFOCTL_TMOEN ;
pTxBufHead - > wTimeStamp = cpu_to_le16 ( DEFAULT_MGN_LIFETIME_RES_64us ) ;
2010-06-30 07:46:24 +00:00
if ( is_multicast_ether_addr ( & ( p80211Header - > sA3 . abyAddr1 [ 0 ] ) ) ) {
2010-08-01 15:15:49 +00:00
bNeedACK = false ;
2009-04-25 14:30:44 +00:00
if ( pDevice - > bEnableHostWEP ) {
uNodeIndex = 0 ;
2010-08-01 15:15:48 +00:00
bNodeExist = true ;
2011-04-10 21:31:32 +00:00
}
2009-04-25 14:30:44 +00:00
}
else {
if ( pDevice - > bEnableHostWEP ) {
2010-06-05 22:13:47 +00:00
if ( BSSDBbIsSTAInNodeDB ( pDevice - > pMgmt , ( unsigned char * ) ( p80211Header - > sA3 . abyAddr1 ) , & uNodeIndex ) )
2010-08-01 15:15:48 +00:00
bNodeExist = true ;
2011-04-10 21:31:32 +00:00
}
2010-08-01 15:15:48 +00:00
bNeedACK = true ;
2009-04-25 14:30:44 +00:00
pTxBufHead - > wFIFOCtl | = FIFOCTL_NEEDACK ;
} ;
if ( ( pMgmt - > eCurrMode = = WMAC_MODE_ESS_AP ) | |
( pMgmt - > eCurrMode = = WMAC_MODE_IBSS_STA ) ) {
pTxBufHead - > wFIFOCtl | = FIFOCTL_LRETRY ;
//Set Preamble type always long
//pDevice->byPreambleType = PREAMBLE_LONG;
// probe-response don't retry
//if ((p80211Header->sA4.wFrameCtl & TYPE_SUBTYPE_MASK) == TYPE_MGMT_PROBE_RSP) {
2010-08-01 15:15:49 +00:00
// bNeedACK = false;
2009-04-25 14:30:44 +00:00
// pTxBufHead->wFIFOCtl &= (~FIFOCTL_NEEDACK);
//}
}
pTxBufHead - > wFIFOCtl | = ( FIFOCTL_GENINT | FIFOCTL_ISDMA0 ) ;
if ( ( p80211Header - > sA4 . wFrameCtl & TYPE_SUBTYPE_MASK ) = = TYPE_CTL_PSPOLL ) {
2010-08-01 15:15:48 +00:00
bIsPSPOLL = true ;
2009-04-25 14:30:44 +00:00
cbMacHdLen = WLAN_HDR_ADDR2_LEN ;
} else {
cbMacHdLen = WLAN_HDR_ADDR3_LEN ;
}
// hostapd deamon ext support rate patch
if ( WLAN_GET_FC_FSTYPE ( p80211Header - > sA4 . wFrameCtl ) = = WLAN_FSTYPE_ASSOCRESP ) {
if ( ( ( PWLAN_IE_SUPP_RATES ) pMgmt - > abyCurrSuppRates ) - > len ! = 0 ) {
cbExtSuppRate + = ( ( PWLAN_IE_SUPP_RATES ) pMgmt - > abyCurrSuppRates ) - > len + WLAN_IEHDR_LEN ;
}
if ( ( ( PWLAN_IE_SUPP_RATES ) pMgmt - > abyCurrExtSuppRates ) - > len ! = 0 ) {
cbExtSuppRate + = ( ( PWLAN_IE_SUPP_RATES ) pMgmt - > abyCurrExtSuppRates ) - > len + WLAN_IEHDR_LEN ;
}
if ( cbExtSuppRate > 0 ) {
cbFrameBodySize = WLAN_ASSOCRESP_OFF_SUPP_RATES ;
}
}
//Set FRAGCTL_MACHDCNT
2010-06-24 18:02:26 +00:00
pTxBufHead - > wFragCtl | = cpu_to_le16 ( ( unsigned short ) cbMacHdLen < < 10 ) ;
2009-04-25 14:30:44 +00:00
// Notes:
2012-12-25 16:23:29 +00:00
// Although spec says MMPDU can be fragmented; In most cases,
2009-04-25 14:30:44 +00:00
// no one will send a MMPDU under fragmentation. With RTS may occur.
2010-08-01 15:15:49 +00:00
pDevice - > bAES = false ; //Set FRAGCTL_WEPTYP
2009-04-25 14:30:44 +00:00
if ( WLAN_GET_FC_ISWEP ( p80211Header - > sA4 . wFrameCtl ) ! = 0 ) {
if ( pDevice - > eEncryptionStatus = = Ndis802_11Encryption1Enabled ) {
cbIVlen = 4 ;
cbICVlen = 4 ;
pTxBufHead - > wFragCtl | = FRAGCTL_LEGACY ;
}
else if ( pDevice - > eEncryptionStatus = = Ndis802_11Encryption2Enabled ) {
cbIVlen = 8 ; //IV+ExtIV
cbMIClen = 8 ;
cbICVlen = 4 ;
pTxBufHead - > wFragCtl | = FRAGCTL_TKIP ;
//We need to get seed here for filling TxKey entry.
//TKIPvMixKey(pTransmitKey->abyKey, pDevice->abyCurrentNetAddr,
// pTransmitKey->wTSC15_0, pTransmitKey->dwTSC47_16, pDevice->abyPRNG);
}
else if ( pDevice - > eEncryptionStatus = = Ndis802_11Encryption3Enabled ) {
cbIVlen = 8 ; //RSN Header
cbICVlen = 8 ; //MIC
cbMICHDR = sizeof ( SMICHDRHead ) ;
pTxBufHead - > wFragCtl | = FRAGCTL_AES ;
2010-08-01 15:15:48 +00:00
pDevice - > bAES = true ;
2009-04-25 14:30:44 +00:00
}
//MAC Header should be padding 0 to DW alignment.
uPadding = 4 - ( cbMacHdLen % 4 ) ;
uPadding % = 4 ;
}
cbFrameSize = cbMacHdLen + cbFrameBodySize + cbIVlen + cbMIClen + cbICVlen + cbFCSlen + cbExtSuppRate ;
//Set FIFOCTL_GrpAckPolicy
2010-08-01 15:15:48 +00:00
if ( pDevice - > bGrpAckPolicy = = true ) { //0000 0100 0000 0000
2009-04-25 14:30:44 +00:00
pTxBufHead - > wFIFOCtl | = FIFOCTL_GRPACK ;
}
//the rest of pTxBufHead->wFragCtl:FragTyp will be set later in s_vFillFragParameter()
2009-07-30 17:27:21 +00:00
if ( byPktType = = PK_TYPE_11GB | | byPktType = = PK_TYPE_11GA ) { //802.11g packet
2009-04-25 14:30:44 +00:00
pvRrvTime = ( PSRrvTime_gCTS ) ( pbyTxBufferAddr + wTxBufSize ) ;
pMICHDR = ( PSMICHDRHead ) ( pbyTxBufferAddr + wTxBufSize + sizeof ( SRrvTime_gCTS ) ) ;
pvRTS = NULL ;
pvCTS = ( PSCTS ) ( pbyTxBufferAddr + wTxBufSize + sizeof ( SRrvTime_gCTS ) + cbMICHDR ) ;
pvTxDataHd = ( PSTxDataHead_g ) ( pbyTxBufferAddr + wTxBufSize + sizeof ( SRrvTime_gCTS ) + cbMICHDR + sizeof ( SCTS ) ) ;
cbHeaderSize = wTxBufSize + sizeof ( SRrvTime_gCTS ) + cbMICHDR + sizeof ( SCTS ) + sizeof ( STxDataHead_g ) ;
}
else { //802.11a/b packet
pvRrvTime = ( PSRrvTime_ab ) ( pbyTxBufferAddr + wTxBufSize ) ;
pMICHDR = ( PSMICHDRHead ) ( pbyTxBufferAddr + wTxBufSize + sizeof ( SRrvTime_ab ) ) ;
pvRTS = NULL ;
pvCTS = NULL ;
pvTxDataHd = ( PSTxDataHead_ab ) ( pbyTxBufferAddr + wTxBufSize + sizeof ( SRrvTime_ab ) + cbMICHDR ) ;
cbHeaderSize = wTxBufSize + sizeof ( SRrvTime_ab ) + cbMICHDR + sizeof ( STxDataHead_ab ) ;
}
2010-05-07 19:30:20 +00:00
memset ( ( void * ) ( pbyTxBufferAddr + wTxBufSize ) , 0 , ( cbHeaderSize - wTxBufSize ) ) ;
2010-05-15 02:37:32 +00:00
memcpy ( & ( sEthHeader . abyDstAddr [ 0 ] ) , & ( p80211Header - > sA3 . abyAddr1 [ 0 ] ) , ETH_ALEN ) ;
memcpy ( & ( sEthHeader . abySrcAddr [ 0 ] ) , & ( p80211Header - > sA3 . abyAddr2 [ 0 ] ) , ETH_ALEN ) ;
2009-04-25 14:30:44 +00:00
//=========================
// No Fragmentation
//=========================
2010-06-24 18:02:26 +00:00
pTxBufHead - > wFragCtl | = ( unsigned short ) FRAGCTL_NONFRAG ;
2009-04-25 14:30:44 +00:00
//Fill FIFO,RrvTime,RTS,and CTS
2009-07-30 17:27:21 +00:00
s_vGenerateTxParameter ( pDevice , byPktType , pbyTxBufferAddr , pvRrvTime , pvRTS , pvCTS ,
2009-04-25 14:30:44 +00:00
cbFrameSize , bNeedACK , TYPE_TXDMA0 , & sEthHeader , wCurrentRate ) ;
//Fill DataHead
2009-07-30 17:27:21 +00:00
uDuration = s_uFillDataHead ( pDevice , byPktType , pvTxDataHd , cbFrameSize , TYPE_TXDMA0 , bNeedACK ,
2009-04-25 14:30:44 +00:00
0 , 0 , 1 , AUTO_FB_NONE , wCurrentRate ) ;
pMACHeader = ( PS802_11Header ) ( pbyTxBufferAddr + cbHeaderSize ) ;
cbReqCount = cbHeaderSize + cbMacHdLen + uPadding + cbIVlen + ( cbFrameBodySize + cbMIClen ) + cbExtSuppRate ;
2010-06-05 22:13:47 +00:00
pbyMacHdr = ( unsigned char * ) ( pbyTxBufferAddr + cbHeaderSize ) ;
pbyPayloadHead = ( unsigned char * ) ( pbyMacHdr + cbMacHdLen + uPadding + cbIVlen ) ;
pbyIVHead = ( unsigned char * ) ( pbyMacHdr + cbMacHdLen + uPadding ) ;
2009-04-25 14:30:44 +00:00
// Copy the Packet into a tx Buffer
memcpy ( pbyMacHdr , pbMPDU , cbMacHdLen ) ;
// version set to 0, patch for hostapd deamon
pMACHeader - > wFrameCtl & = cpu_to_le16 ( 0xfffc ) ;
memcpy ( pbyPayloadHead , ( pbMPDU + cbMacHdLen ) , cbFrameBodySize ) ;
// replace support rate, patch for hostapd deamon( only support 11M)
if ( WLAN_GET_FC_FSTYPE ( p80211Header - > sA4 . wFrameCtl ) = = WLAN_FSTYPE_ASSOCRESP ) {
if ( cbExtSuppRate ! = 0 ) {
if ( ( ( PWLAN_IE_SUPP_RATES ) pMgmt - > abyCurrSuppRates ) - > len ! = 0 )
memcpy ( ( pbyPayloadHead + cbFrameBodySize ) ,
pMgmt - > abyCurrSuppRates ,
( ( PWLAN_IE_SUPP_RATES ) pMgmt - > abyCurrSuppRates ) - > len + WLAN_IEHDR_LEN
) ;
if ( ( ( PWLAN_IE_SUPP_RATES ) pMgmt - > abyCurrExtSuppRates ) - > len ! = 0 )
memcpy ( ( pbyPayloadHead + cbFrameBodySize ) + ( ( PWLAN_IE_SUPP_RATES ) pMgmt - > abyCurrSuppRates ) - > len + WLAN_IEHDR_LEN ,
pMgmt - > abyCurrExtSuppRates ,
( ( PWLAN_IE_SUPP_RATES ) pMgmt - > abyCurrExtSuppRates ) - > len + WLAN_IEHDR_LEN
) ;
}
}
// Set wep
if ( WLAN_GET_FC_ISWEP ( p80211Header - > sA4 . wFrameCtl ) ! = 0 ) {
if ( pDevice - > bEnableHostWEP ) {
pTransmitKey = & STempKey ;
pTransmitKey - > byCipherSuite = pMgmt - > sNodeDBTable [ uNodeIndex ] . byCipherSuite ;
pTransmitKey - > dwKeyIndex = pMgmt - > sNodeDBTable [ uNodeIndex ] . dwKeyIndex ;
pTransmitKey - > uKeyLength = pMgmt - > sNodeDBTable [ uNodeIndex ] . uWepKeyLength ;
pTransmitKey - > dwTSC47_16 = pMgmt - > sNodeDBTable [ uNodeIndex ] . dwTSC47_16 ;
pTransmitKey - > wTSC15_0 = pMgmt - > sNodeDBTable [ uNodeIndex ] . wTSC15_0 ;
memcpy ( pTransmitKey - > abyKey ,
& pMgmt - > sNodeDBTable [ uNodeIndex ] . abyWepKey [ 0 ] ,
pTransmitKey - > uKeyLength
) ;
}
if ( ( pTransmitKey ! = NULL ) & & ( pTransmitKey - > byCipherSuite = = KEY_CTL_TKIP ) ) {
2010-06-05 22:13:49 +00:00
dwMICKey0 = * ( unsigned long * ) ( & pTransmitKey - > abyKey [ 16 ] ) ;
dwMICKey1 = * ( unsigned long * ) ( & pTransmitKey - > abyKey [ 20 ] ) ;
2009-04-25 14:30:44 +00:00
// DO Software Michael
MIC_vInit ( dwMICKey0 , dwMICKey1 ) ;
2010-06-05 22:13:47 +00:00
MIC_vAppend ( ( unsigned char * ) & ( sEthHeader . abyDstAddr [ 0 ] ) , 12 ) ;
2009-04-25 14:30:44 +00:00
dwMIC_Priority = 0 ;
2010-06-05 22:13:47 +00:00
MIC_vAppend ( ( unsigned char * ) & dwMIC_Priority , 4 ) ;
2009-07-30 17:27:21 +00:00
DBG_PRT ( MSG_LEVEL_DEBUG , KERN_INFO " DMA0_tx_8021:MIC KEY: %lX, %lX \n " , dwMICKey0 , dwMICKey1 ) ;
2009-04-25 14:30:44 +00:00
uLength = cbHeaderSize + cbMacHdLen + uPadding + cbIVlen ;
MIC_vAppend ( ( pbyTxBufferAddr + uLength ) , cbFrameBodySize ) ;
2010-06-05 22:13:49 +00:00
pdwMIC_L = ( unsigned long * ) ( pbyTxBufferAddr + uLength + cbFrameBodySize ) ;
pdwMIC_R = ( unsigned long * ) ( pbyTxBufferAddr + uLength + cbFrameBodySize + 4 ) ;
2009-04-25 14:30:44 +00:00
MIC_vGetMIC ( pdwMIC_L , pdwMIC_R ) ;
MIC_vUnInit ( ) ;
2010-08-01 15:15:48 +00:00
if ( pDevice - > bTxMICFail = = true ) {
2009-04-25 14:30:44 +00:00
* pdwMIC_L = 0 ;
* pdwMIC_R = 0 ;
2010-08-01 15:15:49 +00:00
pDevice - > bTxMICFail = false ;
2009-04-25 14:30:44 +00:00
}
2009-07-30 17:27:21 +00:00
DBG_PRT ( MSG_LEVEL_DEBUG , KERN_INFO " uLength: %d, %d \n " , uLength , cbFrameBodySize ) ;
DBG_PRT ( MSG_LEVEL_DEBUG , KERN_INFO " cbReqCount:%d, %d, %d, %d \n " , cbReqCount , cbHeaderSize , uPadding , cbIVlen ) ;
DBG_PRT ( MSG_LEVEL_DEBUG , KERN_INFO " MIC:%lx, %lx \n " , * pdwMIC_L , * pdwMIC_R ) ;
2009-04-25 14:30:44 +00:00
}
2010-06-05 22:13:47 +00:00
s_vFillTxKey ( pDevice , ( unsigned char * ) ( pTxBufHead - > adwTxKey ) , pbyIVHead , pTransmitKey ,
2010-06-24 18:02:26 +00:00
pbyMacHdr , ( unsigned short ) cbFrameBodySize , ( unsigned char * ) pMICHDR ) ;
2009-04-25 14:30:44 +00:00
if ( pDevice - > bEnableHostWEP ) {
pMgmt - > sNodeDBTable [ uNodeIndex ] . dwTSC47_16 = pTransmitKey - > dwTSC47_16 ;
pMgmt - > sNodeDBTable [ uNodeIndex ] . wTSC15_0 = pTransmitKey - > wTSC15_0 ;
}
if ( ( pDevice - > byLocalID < = REV_ID_VT3253_A1 ) ) {
2010-06-24 18:02:26 +00:00
s_vSWencryption ( pDevice , pTransmitKey , pbyPayloadHead , ( unsigned short ) ( cbFrameBodySize + cbMIClen ) ) ;
2009-04-25 14:30:44 +00:00
}
}
pMACHeader - > wSeqCtl = cpu_to_le16 ( pDevice - > wSeqCounter < < 4 ) ;
pDevice - > wSeqCounter + + ;
if ( pDevice - > wSeqCounter > 0x0fff )
pDevice - > wSeqCounter = 0 ;
if ( bIsPSPOLL ) {
// The MAC will automatically replace the Duration-field of MAC header by Duration-field
// of FIFO control header.
// This will cause AID-field of PS-POLL packet be incorrect (Because PS-POLL's AID field is
// in the same place of other packet's Duration-field).
// And it will cause Cisco-AP to issue Disassociation-packet
2009-07-30 17:27:21 +00:00
if ( byPktType = = PK_TYPE_11GB | | byPktType = = PK_TYPE_11GA ) {
2009-04-25 14:30:44 +00:00
( ( PSTxDataHead_g ) pvTxDataHd ) - > wDuration_a = cpu_to_le16 ( p80211Header - > sA2 . wDurationID ) ;
( ( PSTxDataHead_g ) pvTxDataHd ) - > wDuration_b = cpu_to_le16 ( p80211Header - > sA2 . wDurationID ) ;
} else {
( ( PSTxDataHead_ab ) pvTxDataHd ) - > wDuration = cpu_to_le16 ( p80211Header - > sA2 . wDurationID ) ;
}
}
// first TD is the only TD
//Set TSR1 & ReqCount in TxDescHead
pFrstTD - > pTDInfo - > skb = skb ;
pFrstTD - > m_td1TD1 . byTCR = ( TCR_STP | TCR_EDP | EDMSDU ) ;
pFrstTD - > pTDInfo - > skb_dma = pFrstTD - > pTDInfo - > buf_dma ;
pFrstTD - > m_td1TD1 . wReqCount = cpu_to_le16 ( cbReqCount ) ;
pFrstTD - > buff_addr = cpu_to_le32 ( pFrstTD - > pTDInfo - > skb_dma ) ;
pFrstTD - > pTDInfo - > byFlags = 0 ;
pFrstTD - > pTDInfo - > byFlags | = TD_FLAGS_PRIV_SKB ;
if ( MACbIsRegBitsOn ( pDevice - > PortOffset , MAC_REG_PSCTL , PSCTL_PS ) ) {
// Disable PS
MACbPSWakeup ( pDevice - > PortOffset ) ;
}
2010-08-01 15:15:49 +00:00
pDevice - > bPWBitOn = false ;
2009-04-25 14:30:44 +00:00
wmb ( ) ;
pFrstTD - > m_td0TD0 . f1Owner = OWNED_BY_NIC ;
wmb ( ) ;
pDevice - > iTDUsed [ TYPE_TXDMA0 ] + + ;
if ( AVAIL_TD ( pDevice , TYPE_TXDMA0 ) < = 1 ) {
2009-07-30 17:27:21 +00:00
DBG_PRT ( MSG_LEVEL_DEBUG , KERN_INFO " available td0 <= 1 \n " ) ;
2009-04-25 14:30:44 +00:00
}
pDevice - > apCurrTD [ TYPE_TXDMA0 ] = pFrstTD - > next ;
// Poll Transmit the adapter
MACvTransmit0 ( pDevice - > PortOffset ) ;
return ;
}