192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond/* 292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. 392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * All rights reserved. 492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * 592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * This program is free software; you can redistribute it and/or modify 692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * it under the terms of the GNU General Public License as published by 792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * the Free Software Foundation; either version 2 of the License, or 892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * (at your option) any later version. 992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * 1092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * This program is distributed in the hope that it will be useful, 1192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * but WITHOUT ANY WARRANTY; without even the implied warranty of 1292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * GNU General Public License for more details. 1492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * 1592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * You should have received a copy of the GNU General Public License along 1692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * with this program; if not, write to the Free Software Foundation, Inc., 1792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 1892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * 1992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * File: rxtx.c 2092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * 2192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * Purpose: handle WMAC/802.3/802.11 rx & tx functions 2292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * 2392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * Author: Lyndon Chen 2492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * 2592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * Date: May 20, 2003 2692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * 2792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * Functions: 28f77f13e22df4a40d237697df496152c8c37f3f2bGilles Espinasse * s_vGenerateTxParameter - Generate tx dma required parameter. 2992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * s_vGenerateMACHeader - Translate 802.3 to 802.11 header 3092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * csBeacon_xmit - beacon tx function 3192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * csMgmt_xmit - management tx function 3292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * s_uGetDataDuration - get tx data required duration 3392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * s_uFillDataHead- fulfill tx data duration header 34f77f13e22df4a40d237697df496152c8c37f3f2bGilles Espinasse * s_uGetRTSCTSDuration- get rtx/cts required duration 3592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * s_uGetRTSCTSRsvTime- get rts/cts reserved time 3692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * s_uGetTxRsvTime- get frame reserved time 3792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * s_vFillCTSHead- fulfill CTS ctl header 38f77f13e22df4a40d237697df496152c8c37f3f2bGilles Espinasse * s_vFillFragParameter- Set fragment ctl parameter. 3992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * s_vFillRTSHead- fulfill RTS ctl header 4092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * s_vFillTxKey- fulfill tx encrypt key 4192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * s_vSWencryption- Software encrypt header 4292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * vDMA0_tx_80211- tx 802.11 frame via dma0 4392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * vGenerateFIFOHeader- Generate tx FIFO ctl header 4492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * 4592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * Revision History: 4692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * 4792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond */ 4892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 4992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond#include "device.h" 5092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond#include "rxtx.h" 5192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond#include "tether.h" 5292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond#include "card.h" 5392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond#include "bssdb.h" 5492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond#include "mac.h" 5592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond#include "baseband.h" 5692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond#include "michael.h" 5792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond#include "tkip.h" 5892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond#include "tcrc.h" 5992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond#include "wctl.h" 6092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond#include "hostap.h" 6192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond#include "rf.h" 6292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond#include "datarate.h" 6392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond#include "usbpipe.h" 6492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond#include "iocmd.h" 659d26d60f99855056a20ac7c0b68eb5ed04619831Jim Lieb 6692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond/*--------------------- Static Definitions -------------------------*/ 6792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 6892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond/*--------------------- Static Classes ----------------------------*/ 6992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 7092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond/*--------------------- Static Variables --------------------------*/ 714a499de2d13786de626c3f689022d7ec25230911Mariano Reingartstatic int msglevel = MSG_LEVEL_INFO; 7292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 7392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond/*--------------------- Static Functions --------------------------*/ 7492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 7592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond/*--------------------- Static Definitions -------------------------*/ 7692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond#define CRITICAL_PACKET_LEN 256 // if packet size < 256 -> in-direct send 7792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // packet size >= 256 -> direct send 7892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 7992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bondconst WORD wTimeStampOff[2][MAX_RATE] = { 8092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond {384, 288, 226, 209, 54, 43, 37, 31, 28, 25, 24, 23}, // Long Preamble 8192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond {384, 192, 130, 113, 54, 43, 37, 31, 28, 25, 24, 23}, // Short Preamble 8292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond }; 8392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 8492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bondconst WORD wFB_Opt0[2][5] = { 8592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond {RATE_12M, RATE_18M, RATE_24M, RATE_36M, RATE_48M}, // fallback_rate0 8692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond {RATE_12M, RATE_12M, RATE_18M, RATE_24M, RATE_36M}, // fallback_rate1 8792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond }; 8892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bondconst WORD wFB_Opt1[2][5] = { 8992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond {RATE_12M, RATE_18M, RATE_24M, RATE_24M, RATE_36M}, // fallback_rate0 9092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond {RATE_6M , RATE_6M, RATE_12M, RATE_12M, RATE_18M}, // fallback_rate1 9192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond }; 9292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 9392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 9492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond#define RTSDUR_BB 0 9592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond#define RTSDUR_BA 1 9692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond#define RTSDUR_AA 2 9792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond#define CTSDUR_BA 3 9892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond#define RTSDUR_BA_F0 4 9992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond#define RTSDUR_AA_F0 5 10092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond#define RTSDUR_BA_F1 6 10192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond#define RTSDUR_AA_F1 7 10292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond#define CTSDUR_BA_F0 8 10392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond#define CTSDUR_BA_F1 9 10492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond#define DATADUR_B 10 10592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond#define DATADUR_A 11 10692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond#define DATADUR_A_F0 12 10792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond#define DATADUR_A_F1 13 10892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 10992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond/*--------------------- Static Functions --------------------------*/ 11092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 11192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bondstatic 1128611a29ab967bc197494db19d31994d1b5a26fdcAndres Morevoid 11392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bonds_vSaveTxPktInfo( 114592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More PSDevice pDevice, 115592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More BYTE byPktNum, 116592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More PBYTE pbyDestAddr, 117592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More WORD wPktLength, 118592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More WORD wFIFOCtl 11992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond); 12092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 12192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bondstatic 1228611a29ab967bc197494db19d31994d1b5a26fdcAndres Morevoid * 12392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bonds_vGetFreeContext( 12492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PSDevice pDevice 12592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ); 12692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 12792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 12892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bondstatic 1298611a29ab967bc197494db19d31994d1b5a26fdcAndres Morevoid 13092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bonds_vGenerateTxParameter( 131592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More PSDevice pDevice, 132592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More BYTE byPktType, 133592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More WORD wCurrentRate, 1348611a29ab967bc197494db19d31994d1b5a26fdcAndres More void *pTxBufHead, 1358611a29ab967bc197494db19d31994d1b5a26fdcAndres More void *pvRrvTime, 1368611a29ab967bc197494db19d31994d1b5a26fdcAndres More void *pvRTS, 1378611a29ab967bc197494db19d31994d1b5a26fdcAndres More void *pvCTS, 138cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int cbFrameSize, 139592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More BOOL bNeedACK, 140cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int uDMAIdx, 141592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More PSEthernetHeader psEthHeader 14292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ); 14392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 14492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 145cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres Morestatic unsigned int s_uFillDataHead( 146592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More PSDevice pDevice, 147592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More BYTE byPktType, 148592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More WORD wCurrentRate, 1498611a29ab967bc197494db19d31994d1b5a26fdcAndres More void *pTxDataHead, 150cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int cbFrameLength, 151cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int uDMAIdx, 152592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More BOOL bNeedAck, 153cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int uFragIdx, 154cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int cbLastFragmentSize, 155cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int uMACfragNum, 156592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More BYTE byFBOption 15792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ); 15892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 15992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 16092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 16192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 16292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bondstatic 1638611a29ab967bc197494db19d31994d1b5a26fdcAndres Morevoid 16492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bonds_vGenerateMACHeader ( 165592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More PSDevice pDevice, 166592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More PBYTE pbyBufferAddr, 167592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More WORD wDuration, 168592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More PSEthernetHeader psEthHeader, 169592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More BOOL bNeedEncrypt, 170592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More WORD wFragType, 171cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int uDMAIdx, 172cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int uFragIdx 17392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ); 17492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 17592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bondstatic 1768611a29ab967bc197494db19d31994d1b5a26fdcAndres Morevoid 17792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bonds_vFillTxKey( 178592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More PSDevice pDevice, 179592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More PBYTE pbyBuf, 180592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More PBYTE pbyIVHead, 181592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More PSKeyItem pTransmitKey, 182592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More PBYTE pbyHdrBuf, 183592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More WORD wPayloadLen, 1846f8c13c7dbe0d51e62bdb1aa11c1c38a8f8e3133Andres More PBYTE pMICHDR 18592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ); 18692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 18792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bondstatic 1888611a29ab967bc197494db19d31994d1b5a26fdcAndres Morevoid 18992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bonds_vSWencryption ( 190592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More PSDevice pDevice, 191592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More PSKeyItem pTransmitKey, 192592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More PBYTE pbyPayloadHead, 193592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More WORD wPayloadSize 19492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ); 19592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 196cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres Morestatic unsigned int s_uGetTxRsvTime( 197592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More PSDevice pDevice, 198592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More BYTE byPktType, 199cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int cbFrameLength, 200592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More WORD wRate, 201592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More BOOL bNeedAck 20292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ); 20392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 20492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 205cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres Morestatic unsigned int s_uGetRTSCTSRsvTime( 206592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More PSDevice pDevice, 207592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More BYTE byRTSRsvType, 208592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More BYTE byPktType, 209cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int cbFrameLength, 210592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More WORD wCurrentRate 21192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ); 21292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 21392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bondstatic 2148611a29ab967bc197494db19d31994d1b5a26fdcAndres Morevoid 21592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bonds_vFillCTSHead ( 216592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More PSDevice pDevice, 217cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int uDMAIdx, 218592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More BYTE byPktType, 2198611a29ab967bc197494db19d31994d1b5a26fdcAndres More void *pvCTS, 220cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int cbFrameLength, 221592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More BOOL bNeedAck, 222592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More BOOL bDisCRC, 223592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More WORD wCurrentRate, 224592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More BYTE byFBOption 22592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ); 22692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 22792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bondstatic 2288611a29ab967bc197494db19d31994d1b5a26fdcAndres Morevoid 22992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bonds_vFillRTSHead( 230592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More PSDevice pDevice, 231592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More BYTE byPktType, 2328611a29ab967bc197494db19d31994d1b5a26fdcAndres More void *pvRTS, 233cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int cbFrameLength, 234592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More BOOL bNeedAck, 235592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More BOOL bDisCRC, 236592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More PSEthernetHeader psEthHeader, 237592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More WORD wCurrentRate, 238592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More BYTE byFBOption 23992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ); 24092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 241cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres Morestatic unsigned int s_uGetDataDuration( 242592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More PSDevice pDevice, 243592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More BYTE byDurType, 244cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int cbFrameLength, 245592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More BYTE byPktType, 246592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More WORD wRate, 247592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More BOOL bNeedAck, 248cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int uFragIdx, 249cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int cbLastFragmentSize, 250cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int uMACfragNum, 251592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More BYTE byFBOption 25292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ); 25392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 25492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 25592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bondstatic 256cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres Moreunsigned int 25792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bonds_uGetRTSCTSDuration ( 258592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More PSDevice pDevice, 259592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More BYTE byDurType, 260cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int cbFrameLength, 261592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More BYTE byPktType, 262592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More WORD wRate, 263592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More BOOL bNeedAck, 264592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More BYTE byFBOption 26592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ); 26692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 26792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 26892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond/*--------------------- Export Variables --------------------------*/ 26992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 27092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bondstatic 2718611a29ab967bc197494db19d31994d1b5a26fdcAndres Morevoid * 27292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bonds_vGetFreeContext( 27392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PSDevice pDevice 27492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ) 27592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond{ 27692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PUSB_SEND_CONTEXT pContext = NULL; 27792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PUSB_SEND_CONTEXT pReturnContext = NULL; 278cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int ii; 27992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 28092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"GetFreeContext()\n"); 28192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 28292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond for (ii = 0; ii < pDevice->cbTD; ii++) { 28392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pContext = pDevice->apTD[ii]; 28492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pContext->bBoolInUse == FALSE) { 28592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pContext->bBoolInUse = TRUE; 28692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pReturnContext = pContext; 28792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond break; 28892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 28992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 29092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if ( ii == pDevice->cbTD ) { 29192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"No Free Tx Context\n"); 29292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 2938611a29ab967bc197494db19d31994d1b5a26fdcAndres More return (void *) pReturnContext; 29492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond} 29592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 29692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 29792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bondstatic 2988611a29ab967bc197494db19d31994d1b5a26fdcAndres Morevoid 29992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bonds_vSaveTxPktInfo(PSDevice pDevice, BYTE byPktNum, PBYTE pbyDestAddr, WORD wPktLength, WORD wFIFOCtl) 30092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond{ 30192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PSStatCounter pStatistic=&(pDevice->scStatistic); 30292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 3034b50fb4042a9e39cd24b411546020d6b56ff519bAndres More if (is_broadcast_ether_addr(pbyDestAddr)) 30492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pStatistic->abyTxPktInfo[byPktNum].byBroadMultiUni = TX_PKT_BROAD; 3054b50fb4042a9e39cd24b411546020d6b56ff519bAndres More else if (is_multicast_ether_addr(pbyDestAddr)) 30692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pStatistic->abyTxPktInfo[byPktNum].byBroadMultiUni = TX_PKT_MULTI; 30792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else 30892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pStatistic->abyTxPktInfo[byPktNum].byBroadMultiUni = TX_PKT_UNI; 30992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 31092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pStatistic->abyTxPktInfo[byPktNum].wLength = wPktLength; 31192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pStatistic->abyTxPktInfo[byPktNum].wFIFOCtl = wFIFOCtl; 3129a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More memcpy(pStatistic->abyTxPktInfo[byPktNum].abyDestAddr, 3139a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More pbyDestAddr, 3149a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More ETH_ALEN); 31592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond} 31692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 31792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bondstatic 3188611a29ab967bc197494db19d31994d1b5a26fdcAndres Morevoid 31992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bonds_vFillTxKey ( 320592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More PSDevice pDevice, 321592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More PBYTE pbyBuf, 322592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More PBYTE pbyIVHead, 323592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More PSKeyItem pTransmitKey, 324592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More PBYTE pbyHdrBuf, 325592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More WORD wPayloadLen, 3266f8c13c7dbe0d51e62bdb1aa11c1c38a8f8e3133Andres More PBYTE pMICHDR 32792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ) 32892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond{ 32992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PDWORD pdwIV = (PDWORD) pbyIVHead; 33092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PDWORD pdwExtIV = (PDWORD) ((PBYTE)pbyIVHead+4); 33192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond WORD wValue; 33292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PS802_11Header pMACHeader = (PS802_11Header)pbyHdrBuf; 33392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond DWORD dwRevIVCounter; 33492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 33592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 33692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 33792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Fill TXKEY 33892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pTransmitKey == NULL) 33992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond return; 34092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 34192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond dwRevIVCounter = cpu_to_le32(pDevice->dwIVCounter); 34292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond *pdwIV = pDevice->dwIVCounter; 34392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pDevice->byKeyIndex = pTransmitKey->dwKeyIndex & 0xf; 34492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 34592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pTransmitKey->byCipherSuite == KEY_CTL_WEP) { 34692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pTransmitKey->uKeyLength == WLAN_WEP232_KEYLEN ){ 3473e362598fd3c7b8729afd0383a4cdf08849b020eJim Lieb memcpy(pDevice->abyPRNG, (PBYTE)&(dwRevIVCounter), 3); 3483e362598fd3c7b8729afd0383a4cdf08849b020eJim Lieb memcpy(pDevice->abyPRNG+3, pTransmitKey->abyKey, pTransmitKey->uKeyLength); 34992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else { 3503e362598fd3c7b8729afd0383a4cdf08849b020eJim Lieb memcpy(pbyBuf, (PBYTE)&(dwRevIVCounter), 3); 3513e362598fd3c7b8729afd0383a4cdf08849b020eJim Lieb memcpy(pbyBuf+3, pTransmitKey->abyKey, pTransmitKey->uKeyLength); 35292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if(pTransmitKey->uKeyLength == WLAN_WEP40_KEYLEN) { 3533e362598fd3c7b8729afd0383a4cdf08849b020eJim Lieb memcpy(pbyBuf+8, (PBYTE)&(dwRevIVCounter), 3); 3543e362598fd3c7b8729afd0383a4cdf08849b020eJim Lieb memcpy(pbyBuf+11, pTransmitKey->abyKey, pTransmitKey->uKeyLength); 35592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 3563e362598fd3c7b8729afd0383a4cdf08849b020eJim Lieb memcpy(pDevice->abyPRNG, pbyBuf, 16); 35792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 35892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // Append IV after Mac Header 35992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond *pdwIV &= WEP_IV_MASK;//00000000 11111111 11111111 11111111 36092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond *pdwIV |= (pDevice->byKeyIndex << 30); 36192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond *pdwIV = cpu_to_le32(*pdwIV); 36292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pDevice->dwIVCounter++; 36392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pDevice->dwIVCounter > WEP_IV_MASK) { 36492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pDevice->dwIVCounter = 0; 36592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 36692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else if (pTransmitKey->byCipherSuite == KEY_CTL_TKIP) { 36792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTransmitKey->wTSC15_0++; 36892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pTransmitKey->wTSC15_0 == 0) { 36992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTransmitKey->dwTSC47_16++; 37092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 37192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond TKIPvMixKey(pTransmitKey->abyKey, pDevice->abyCurrentNetAddr, 37292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTransmitKey->wTSC15_0, pTransmitKey->dwTSC47_16, pDevice->abyPRNG); 3733e362598fd3c7b8729afd0383a4cdf08849b020eJim Lieb memcpy(pbyBuf, pDevice->abyPRNG, 16); 37492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // Make IV 3753e362598fd3c7b8729afd0383a4cdf08849b020eJim Lieb memcpy(pdwIV, pDevice->abyPRNG, 3); 37692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 37792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond *(pbyIVHead+3) = (BYTE)(((pDevice->byKeyIndex << 6) & 0xc0) | 0x20); // 0x20 is ExtIV 37892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // Append IV&ExtIV after Mac Header 37992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond *pdwExtIV = cpu_to_le32(pTransmitKey->dwTSC47_16); 38092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"vFillTxKey()---- pdwExtIV: %lx\n", *pdwExtIV); 38192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 38292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else if (pTransmitKey->byCipherSuite == KEY_CTL_CCMP) { 38392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTransmitKey->wTSC15_0++; 38492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pTransmitKey->wTSC15_0 == 0) { 38592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTransmitKey->dwTSC47_16++; 38692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 3873e362598fd3c7b8729afd0383a4cdf08849b020eJim Lieb memcpy(pbyBuf, pTransmitKey->abyKey, 16); 38892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 38992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // Make IV 39092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond *pdwIV = 0; 39192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond *(pbyIVHead+3) = (BYTE)(((pDevice->byKeyIndex << 6) & 0xc0) | 0x20); // 0x20 is ExtIV 39292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond *pdwIV |= cpu_to_le16((WORD)(pTransmitKey->wTSC15_0)); 39392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Append IV&ExtIV after Mac Header 39492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond *pdwExtIV = cpu_to_le32(pTransmitKey->dwTSC47_16); 39592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 39692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Fill MICHDR0 39792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond *pMICHDR = 0x59; 39892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond *((PBYTE)(pMICHDR+1)) = 0; // TxPriority 3993e362598fd3c7b8729afd0383a4cdf08849b020eJim Lieb memcpy(pMICHDR+2, &(pMACHeader->abyAddr2[0]), 6); 40092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond *((PBYTE)(pMICHDR+8)) = HIBYTE(HIWORD(pTransmitKey->dwTSC47_16)); 40192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond *((PBYTE)(pMICHDR+9)) = LOBYTE(HIWORD(pTransmitKey->dwTSC47_16)); 40292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond *((PBYTE)(pMICHDR+10)) = HIBYTE(LOWORD(pTransmitKey->dwTSC47_16)); 40392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond *((PBYTE)(pMICHDR+11)) = LOBYTE(LOWORD(pTransmitKey->dwTSC47_16)); 40492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond *((PBYTE)(pMICHDR+12)) = HIBYTE(pTransmitKey->wTSC15_0); 40592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond *((PBYTE)(pMICHDR+13)) = LOBYTE(pTransmitKey->wTSC15_0); 40692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond *((PBYTE)(pMICHDR+14)) = HIBYTE(wPayloadLen); 40792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond *((PBYTE)(pMICHDR+15)) = LOBYTE(wPayloadLen); 40892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 40992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Fill MICHDR1 41092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond *((PBYTE)(pMICHDR+16)) = 0; // HLEN[15:8] 41192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pDevice->bLongHeader) { 41292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond *((PBYTE)(pMICHDR+17)) = 28; // HLEN[7:0] 41392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else { 41492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond *((PBYTE)(pMICHDR+17)) = 22; // HLEN[7:0] 41592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 41692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond wValue = cpu_to_le16(pMACHeader->wFrameCtl & 0xC78F); 4173e362598fd3c7b8729afd0383a4cdf08849b020eJim Lieb memcpy(pMICHDR+18, (PBYTE)&wValue, 2); // MSKFRACTL 4183e362598fd3c7b8729afd0383a4cdf08849b020eJim Lieb memcpy(pMICHDR+20, &(pMACHeader->abyAddr1[0]), 6); 4193e362598fd3c7b8729afd0383a4cdf08849b020eJim Lieb memcpy(pMICHDR+26, &(pMACHeader->abyAddr2[0]), 6); 42092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 42192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Fill MICHDR2 4223e362598fd3c7b8729afd0383a4cdf08849b020eJim Lieb memcpy(pMICHDR+32, &(pMACHeader->abyAddr3[0]), 6); 42392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond wValue = pMACHeader->wSeqCtl; 42492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond wValue &= 0x000F; 42592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond wValue = cpu_to_le16(wValue); 4263e362598fd3c7b8729afd0383a4cdf08849b020eJim Lieb memcpy(pMICHDR+38, (PBYTE)&wValue, 2); // MSKSEQCTL 42792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pDevice->bLongHeader) { 4283e362598fd3c7b8729afd0383a4cdf08849b020eJim Lieb memcpy(pMICHDR+40, &(pMACHeader->abyAddr4[0]), 6); 42992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 43092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 43192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond} 43292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 43392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 43492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bondstatic 4358611a29ab967bc197494db19d31994d1b5a26fdcAndres Morevoid 43692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bonds_vSWencryption ( 437592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More PSDevice pDevice, 438592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More PSKeyItem pTransmitKey, 439592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More PBYTE pbyPayloadHead, 440592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More WORD wPayloadSize 44192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ) 44292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond{ 443cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int cbICVlen = 4; 44492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond DWORD dwICV = 0xFFFFFFFFL; 44592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PDWORD pdwICV; 44692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 44792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pTransmitKey == NULL) 44892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond return; 44992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 45092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pTransmitKey->byCipherSuite == KEY_CTL_WEP) { 45192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //======================================================================= 45292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // Append ICV after payload 45392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond dwICV = CRCdwGetCrc32Ex(pbyPayloadHead, wPayloadSize, dwICV);//ICV(Payload) 45492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pdwICV = (PDWORD)(pbyPayloadHead + wPayloadSize); 45592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // finally, we must invert dwCRC to get the correct answer 45692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond *pdwICV = cpu_to_le32(~dwICV); 45792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // RC4 encryption 45892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond rc4_init(&pDevice->SBox, pDevice->abyPRNG, pTransmitKey->uKeyLength + 3); 45992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond rc4_encrypt(&pDevice->SBox, pbyPayloadHead, pbyPayloadHead, wPayloadSize+cbICVlen); 46092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //======================================================================= 46192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else if (pTransmitKey->byCipherSuite == KEY_CTL_TKIP) { 46292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //======================================================================= 46392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Append ICV after payload 46492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond dwICV = CRCdwGetCrc32Ex(pbyPayloadHead, wPayloadSize, dwICV);//ICV(Payload) 46592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pdwICV = (PDWORD)(pbyPayloadHead + wPayloadSize); 46692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // finally, we must invert dwCRC to get the correct answer 46792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond *pdwICV = cpu_to_le32(~dwICV); 46892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // RC4 encryption 46992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond rc4_init(&pDevice->SBox, pDevice->abyPRNG, TKIP_KEY_LEN); 47092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond rc4_encrypt(&pDevice->SBox, pbyPayloadHead, pbyPayloadHead, wPayloadSize+cbICVlen); 47192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //======================================================================= 47292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 47392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond} 47492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 47592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 47692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 47792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 47892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond/*byPktType : PK_TYPE_11A 0 47992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PK_TYPE_11B 1 48092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PK_TYPE_11GB 2 48192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PK_TYPE_11GA 3 48292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond*/ 48392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bondstatic 484cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres Moreunsigned int 48592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bonds_uGetTxRsvTime ( 486592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More PSDevice pDevice, 487592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More BYTE byPktType, 488cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int cbFrameLength, 489592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More WORD wRate, 490592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More BOOL bNeedAck 49192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ) 49292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond{ 493cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int uDataTime, uAckTime; 49492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 49592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uDataTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, cbFrameLength, wRate); 49692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (byPktType == PK_TYPE_11B) {//llb,CCK mode 49792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, (WORD)pDevice->byTopCCKBasicRate); 49892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else {//11g 2.4G OFDM mode & 11a 5G OFDM mode 49992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, (WORD)pDevice->byTopOFDMBasicRate); 50092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 50192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 50292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (bNeedAck) { 50392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond return (uDataTime + pDevice->uSIFS + uAckTime); 50492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 50592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else { 50692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond return uDataTime; 50792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 50892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond} 50992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 51092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond//byFreqType: 0=>5GHZ 1=>2.4GHZ 51192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bondstatic 512cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres Moreunsigned int 51392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bonds_uGetRTSCTSRsvTime ( 514592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More PSDevice pDevice, 515592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More BYTE byRTSRsvType, 516592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More BYTE byPktType, 517cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int cbFrameLength, 518592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More WORD wCurrentRate 51992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ) 52092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond{ 521cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int uRrvTime , uRTSTime, uCTSTime, uAckTime, uDataTime; 52292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 52392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uRrvTime = uRTSTime = uCTSTime = uAckTime = uDataTime = 0; 52492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 52592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 52692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uDataTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, cbFrameLength, wCurrentRate); 52792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (byRTSRsvType == 0) { //RTSTxRrvTime_bb 52892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uRTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 20, pDevice->byTopCCKBasicRate); 52992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uCTSTime = uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopCCKBasicRate); 53092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 53192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else if (byRTSRsvType == 1){ //RTSTxRrvTime_ba, only in 2.4GHZ 53292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uRTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 20, pDevice->byTopCCKBasicRate); 53392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uCTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopCCKBasicRate); 53492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate); 53592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 53692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else if (byRTSRsvType == 2) { //RTSTxRrvTime_aa 53792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uRTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 20, pDevice->byTopOFDMBasicRate); 53892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uCTSTime = uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate); 53992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 54092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else if (byRTSRsvType == 3) { //CTSTxRrvTime_ba, only in 2.4GHZ 54192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uCTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopCCKBasicRate); 54292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate); 54392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uRrvTime = uCTSTime + uAckTime + uDataTime + 2*pDevice->uSIFS; 54492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond return uRrvTime; 54592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 54692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 54792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //RTSRrvTime 54892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uRrvTime = uRTSTime + uCTSTime + uAckTime + uDataTime + 3*pDevice->uSIFS; 54992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond return uRrvTime; 55092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond} 55192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 55292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond//byFreqType 0: 5GHz, 1:2.4Ghz 55392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bondstatic 554cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres Moreunsigned int 55592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bonds_uGetDataDuration ( 556592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More PSDevice pDevice, 557592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More BYTE byDurType, 558cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int cbFrameLength, 559592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More BYTE byPktType, 560592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More WORD wRate, 561592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More BOOL bNeedAck, 562cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int uFragIdx, 563cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int cbLastFragmentSize, 564cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int uMACfragNum, 565592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More BYTE byFBOption 56692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ) 56792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond{ 56892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond BOOL bLastFrag = 0; 569cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int uAckTime = 0, uNextPktTime = 0; 57092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 57192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (uFragIdx == (uMACfragNum-1)) { 57292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond bLastFrag = 1; 57392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 57492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 57592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond switch (byDurType) { 57692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 57792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond case DATADUR_B: //DATADUR_B 57892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (((uMACfragNum == 1)) || (bLastFrag == 1)) {//Non Frag or Last Frag 57992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (bNeedAck) { 58092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopCCKBasicRate); 58192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond return (pDevice->uSIFS + uAckTime); 58292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else { 58392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond return 0; 58492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 58592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 58692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else {//First Frag or Mid Frag 58792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (uFragIdx == (uMACfragNum-2)) { 58892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbLastFragmentSize, wRate, bNeedAck); 58992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else { 59092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wRate, bNeedAck); 59192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 59292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (bNeedAck) { 59392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopCCKBasicRate); 59492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond return (pDevice->uSIFS + uAckTime + uNextPktTime); 59592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else { 59692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond return (pDevice->uSIFS + uNextPktTime); 59792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 59892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 59992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond break; 60092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 60192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 60292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond case DATADUR_A: //DATADUR_A 60392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (((uMACfragNum==1)) || (bLastFrag==1)) {//Non Frag or Last Frag 60492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if(bNeedAck){ 60592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate); 60692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond return (pDevice->uSIFS + uAckTime); 60792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else { 60892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond return 0; 60992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 61092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 61192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else {//First Frag or Mid Frag 61292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if(uFragIdx == (uMACfragNum-2)){ 61392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbLastFragmentSize, wRate, bNeedAck); 61492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else { 61592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wRate, bNeedAck); 61692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 61792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if(bNeedAck){ 61892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate); 61992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond return (pDevice->uSIFS + uAckTime + uNextPktTime); 62092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else { 62192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond return (pDevice->uSIFS + uNextPktTime); 62292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 62392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 62492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond break; 62592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 62692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond case DATADUR_A_F0: //DATADUR_A_F0 62792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (((uMACfragNum==1)) || (bLastFrag==1)) {//Non Frag or Last Frag 62892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if(bNeedAck){ 62992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate); 63092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond return (pDevice->uSIFS + uAckTime); 63192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else { 63292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond return 0; 63392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 63492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 63592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else { //First Frag or Mid Frag 63692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (byFBOption == AUTO_FB_0) { 63792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (wRate < RATE_18M) 63892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond wRate = RATE_18M; 63992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else if (wRate > RATE_54M) 64092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond wRate = RATE_54M; 64192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 64292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if(uFragIdx == (uMACfragNum-2)){ 64392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbLastFragmentSize, wFB_Opt0[FB_RATE0][wRate-RATE_18M], bNeedAck); 64492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else { 64592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt0[FB_RATE0][wRate-RATE_18M], bNeedAck); 64692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 64792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else { // (byFBOption == AUTO_FB_1) 64892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (wRate < RATE_18M) 64992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond wRate = RATE_18M; 65092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else if (wRate > RATE_54M) 65192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond wRate = RATE_54M; 65292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 65392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if(uFragIdx == (uMACfragNum-2)){ 65492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbLastFragmentSize, wFB_Opt1[FB_RATE0][wRate-RATE_18M], bNeedAck); 65592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else { 65692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt1[FB_RATE0][wRate-RATE_18M], bNeedAck); 65792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 65892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 65992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 66092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if(bNeedAck){ 66192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate); 66292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond return (pDevice->uSIFS + uAckTime + uNextPktTime); 66392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else { 66492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond return (pDevice->uSIFS + uNextPktTime); 66592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 66692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 66792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond break; 66892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 66992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond case DATADUR_A_F1: //DATADUR_A_F1 67092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (((uMACfragNum==1)) || (bLastFrag==1)) {//Non Frag or Last Frag 67192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if(bNeedAck){ 67292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate); 67392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond return (pDevice->uSIFS + uAckTime); 67492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else { 67592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond return 0; 67692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 67792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 67892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else { //First Frag or Mid Frag 67992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (byFBOption == AUTO_FB_0) { 68092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (wRate < RATE_18M) 68192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond wRate = RATE_18M; 68292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else if (wRate > RATE_54M) 68392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond wRate = RATE_54M; 68492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 68592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if(uFragIdx == (uMACfragNum-2)){ 68692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbLastFragmentSize, wFB_Opt0[FB_RATE1][wRate-RATE_18M], bNeedAck); 68792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else { 68892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt0[FB_RATE1][wRate-RATE_18M], bNeedAck); 68992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 69092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 69192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else { // (byFBOption == AUTO_FB_1) 69292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (wRate < RATE_18M) 69392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond wRate = RATE_18M; 69492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else if (wRate > RATE_54M) 69592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond wRate = RATE_54M; 69692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 69792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if(uFragIdx == (uMACfragNum-2)){ 69892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbLastFragmentSize, wFB_Opt1[FB_RATE1][wRate-RATE_18M], bNeedAck); 69992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else { 70092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt1[FB_RATE1][wRate-RATE_18M], bNeedAck); 70192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 70292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 70392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if(bNeedAck){ 70492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate); 70592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond return (pDevice->uSIFS + uAckTime + uNextPktTime); 70692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else { 70792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond return (pDevice->uSIFS + uNextPktTime); 70892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 70992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 71092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond break; 71192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 71292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond default: 71392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond break; 71492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 71592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 71692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ASSERT(FALSE); 71792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond return 0; 71892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond} 71992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 72092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 72192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond//byFreqType: 0=>5GHZ 1=>2.4GHZ 72292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bondstatic 723cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres Moreunsigned int 72492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bonds_uGetRTSCTSDuration ( 725592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More PSDevice pDevice, 726592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More BYTE byDurType, 727cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int cbFrameLength, 728592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More BYTE byPktType, 729592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More WORD wRate, 730592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More BOOL bNeedAck, 731592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More BYTE byFBOption 73292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ) 73392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond{ 734cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int uCTSTime = 0, uDurTime = 0; 73592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 73692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 73792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond switch (byDurType) { 73892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 73992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond case RTSDUR_BB: //RTSDuration_bb 74092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uCTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopCCKBasicRate); 74192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uDurTime = uCTSTime + 2*pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wRate, bNeedAck); 74292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond break; 74392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 74492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond case RTSDUR_BA: //RTSDuration_ba 74592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uCTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopCCKBasicRate); 74692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uDurTime = uCTSTime + 2*pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wRate, bNeedAck); 74792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond break; 74892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 74992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond case RTSDUR_AA: //RTSDuration_aa 75092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uCTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate); 75192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uDurTime = uCTSTime + 2*pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wRate, bNeedAck); 75292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond break; 75392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 75492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond case CTSDUR_BA: //CTSDuration_ba 75592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uDurTime = pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wRate, bNeedAck); 75692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond break; 75792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 75892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond case RTSDUR_BA_F0: //RTSDuration_ba_f0 75992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uCTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopCCKBasicRate); 76092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if ((byFBOption == AUTO_FB_0) && (wRate >= RATE_18M) && (wRate <=RATE_54M)) { 76192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uDurTime = uCTSTime + 2*pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt0[FB_RATE0][wRate-RATE_18M], bNeedAck); 76292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else if ((byFBOption == AUTO_FB_1) && (wRate >= RATE_18M) && (wRate <=RATE_54M)) { 76392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uDurTime = uCTSTime + 2*pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt1[FB_RATE0][wRate-RATE_18M], bNeedAck); 76492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 76592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond break; 76692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 76792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond case RTSDUR_AA_F0: //RTSDuration_aa_f0 76892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uCTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate); 76992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if ((byFBOption == AUTO_FB_0) && (wRate >= RATE_18M) && (wRate <=RATE_54M)) { 77092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uDurTime = uCTSTime + 2*pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt0[FB_RATE0][wRate-RATE_18M], bNeedAck); 77192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else if ((byFBOption == AUTO_FB_1) && (wRate >= RATE_18M) && (wRate <=RATE_54M)) { 77292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uDurTime = uCTSTime + 2*pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt1[FB_RATE0][wRate-RATE_18M], bNeedAck); 77392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 77492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond break; 77592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 77692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond case RTSDUR_BA_F1: //RTSDuration_ba_f1 77792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uCTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopCCKBasicRate); 77892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if ((byFBOption == AUTO_FB_0) && (wRate >= RATE_18M) && (wRate <=RATE_54M)) { 77992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uDurTime = uCTSTime + 2*pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt0[FB_RATE1][wRate-RATE_18M], bNeedAck); 78092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else if ((byFBOption == AUTO_FB_1) && (wRate >= RATE_18M) && (wRate <=RATE_54M)) { 78192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uDurTime = uCTSTime + 2*pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt1[FB_RATE1][wRate-RATE_18M], bNeedAck); 78292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 78392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond break; 78492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 78592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond case RTSDUR_AA_F1: //RTSDuration_aa_f1 78692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uCTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate); 78792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if ((byFBOption == AUTO_FB_0) && (wRate >= RATE_18M) && (wRate <=RATE_54M)) { 78892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uDurTime = uCTSTime + 2*pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt0[FB_RATE1][wRate-RATE_18M], bNeedAck); 78992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else if ((byFBOption == AUTO_FB_1) && (wRate >= RATE_18M) && (wRate <=RATE_54M)) { 79092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uDurTime = uCTSTime + 2*pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt1[FB_RATE1][wRate-RATE_18M], bNeedAck); 79192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 79292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond break; 79392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 79492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond case CTSDUR_BA_F0: //CTSDuration_ba_f0 79592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if ((byFBOption == AUTO_FB_0) && (wRate >= RATE_18M) && (wRate <=RATE_54M)) { 79692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uDurTime = pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt0[FB_RATE0][wRate-RATE_18M], bNeedAck); 79792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else if ((byFBOption == AUTO_FB_1) && (wRate >= RATE_18M) && (wRate <=RATE_54M)) { 79892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uDurTime = pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt1[FB_RATE0][wRate-RATE_18M], bNeedAck); 79992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 80092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond break; 80192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 80292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond case CTSDUR_BA_F1: //CTSDuration_ba_f1 80392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if ((byFBOption == AUTO_FB_0) && (wRate >= RATE_18M) && (wRate <=RATE_54M)) { 80492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uDurTime = pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt0[FB_RATE1][wRate-RATE_18M], bNeedAck); 80592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else if ((byFBOption == AUTO_FB_1) && (wRate >= RATE_18M) && (wRate <=RATE_54M)) { 80692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uDurTime = pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt1[FB_RATE1][wRate-RATE_18M], bNeedAck); 80792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 80892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond break; 80992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 81092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond default: 81192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond break; 81292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 81392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 81492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond return uDurTime; 81592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 81692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond} 81792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 81892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 81992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 82092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 82192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bondstatic 822cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres Moreunsigned int 82392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bonds_uFillDataHead ( 824592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More PSDevice pDevice, 825592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More BYTE byPktType, 826592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More WORD wCurrentRate, 8278611a29ab967bc197494db19d31994d1b5a26fdcAndres More void *pTxDataHead, 828cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int cbFrameLength, 829cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int uDMAIdx, 830592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More BOOL bNeedAck, 831cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int uFragIdx, 832cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int cbLastFragmentSize, 833cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int uMACfragNum, 834592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More BYTE byFBOption 83592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ) 83692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond{ 83792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 83892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pTxDataHead == NULL) { 83992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond return 0; 84092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 84192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 84292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) { 843bd2bc4c763db8a9c6eeef0d2cf6f384514b6cb6cAndres More if ((uDMAIdx == TYPE_ATIMDMA) || (uDMAIdx == TYPE_BEACONDMA)) { 844bd2bc4c763db8a9c6eeef0d2cf6f384514b6cb6cAndres More PSTxDataHead_ab pBuf = (PSTxDataHead_ab) pTxDataHead; 84592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Get SignalField,ServiceField,Length 84692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond BBvCaculateParameter(pDevice, cbFrameLength, wCurrentRate, byPktType, 84792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond (PWORD)&(pBuf->wTransmitLength), (PBYTE)&(pBuf->byServiceField), (PBYTE)&(pBuf->bySignalField) 84892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ); 84992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Get Duration and TimeStampOff 85092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wDuration = (WORD)s_uGetDataDuration(pDevice, DATADUR_A, cbFrameLength, byPktType, 85192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond wCurrentRate, bNeedAck, uFragIdx, 85292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbLastFragmentSize, uMACfragNum, 85392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond byFBOption); //1: 2.4GHz 85492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if(uDMAIdx!=TYPE_ATIMDMA) { 85592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wTimeStampOff = wTimeStampOff[pDevice->byPreambleType%2][wCurrentRate%MAX_RATE]; 85692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 85792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond return (pBuf->wDuration); 85892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 85992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else { // DATA & MANAGE Frame 86092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (byFBOption == AUTO_FB_NONE) { 86192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PSTxDataHead_g pBuf = (PSTxDataHead_g)pTxDataHead; 86292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Get SignalField,ServiceField,Length 86392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond BBvCaculateParameter(pDevice, cbFrameLength, wCurrentRate, byPktType, 86492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond (PWORD)&(pBuf->wTransmitLength_a), (PBYTE)&(pBuf->byServiceField_a), (PBYTE)&(pBuf->bySignalField_a) 86592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ); 86692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond BBvCaculateParameter(pDevice, cbFrameLength, pDevice->byTopCCKBasicRate, PK_TYPE_11B, 86792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond (PWORD)&(pBuf->wTransmitLength_b), (PBYTE)&(pBuf->byServiceField_b), (PBYTE)&(pBuf->bySignalField_b) 86892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ); 86992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Get Duration and TimeStamp 87092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wDuration_a = (WORD)s_uGetDataDuration(pDevice, DATADUR_A, cbFrameLength, 87192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond byPktType, wCurrentRate, bNeedAck, uFragIdx, 87292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbLastFragmentSize, uMACfragNum, 87392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond byFBOption); //1: 2.4GHz 87492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wDuration_b = (WORD)s_uGetDataDuration(pDevice, DATADUR_B, cbFrameLength, 87592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PK_TYPE_11B, pDevice->byTopCCKBasicRate, 87692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond bNeedAck, uFragIdx, cbLastFragmentSize, 87792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uMACfragNum, byFBOption); //1: 2.4GHz 87892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 87992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wTimeStampOff_a = wTimeStampOff[pDevice->byPreambleType%2][wCurrentRate%MAX_RATE]; 88092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wTimeStampOff_b = wTimeStampOff[pDevice->byPreambleType%2][pDevice->byTopCCKBasicRate%MAX_RATE]; 88192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond return (pBuf->wDuration_a); 88292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else { 88392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // Auto Fallback 88492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PSTxDataHead_g_FB pBuf = (PSTxDataHead_g_FB)pTxDataHead; 88592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Get SignalField,ServiceField,Length 88692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond BBvCaculateParameter(pDevice, cbFrameLength, wCurrentRate, byPktType, 88792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond (PWORD)&(pBuf->wTransmitLength_a), (PBYTE)&(pBuf->byServiceField_a), (PBYTE)&(pBuf->bySignalField_a) 88892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ); 88992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond BBvCaculateParameter(pDevice, cbFrameLength, pDevice->byTopCCKBasicRate, PK_TYPE_11B, 89092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond (PWORD)&(pBuf->wTransmitLength_b), (PBYTE)&(pBuf->byServiceField_b), (PBYTE)&(pBuf->bySignalField_b) 89192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ); 89292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Get Duration and TimeStamp 89392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wDuration_a = (WORD)s_uGetDataDuration(pDevice, DATADUR_A, cbFrameLength, byPktType, 89492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond wCurrentRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption); //1: 2.4GHz 89592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wDuration_b = (WORD)s_uGetDataDuration(pDevice, DATADUR_B, cbFrameLength, PK_TYPE_11B, 89692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pDevice->byTopCCKBasicRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption); //1: 2.4GHz 89792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wDuration_a_f0 = (WORD)s_uGetDataDuration(pDevice, DATADUR_A_F0, cbFrameLength, byPktType, 89892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond wCurrentRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption); //1: 2.4GHz 89992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wDuration_a_f1 = (WORD)s_uGetDataDuration(pDevice, DATADUR_A_F1, cbFrameLength, byPktType, 90092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond wCurrentRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption); //1: 2.4GHz 90192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wTimeStampOff_a = wTimeStampOff[pDevice->byPreambleType%2][wCurrentRate%MAX_RATE]; 90292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wTimeStampOff_b = wTimeStampOff[pDevice->byPreambleType%2][pDevice->byTopCCKBasicRate%MAX_RATE]; 90392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond return (pBuf->wDuration_a); 90492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } //if (byFBOption == AUTO_FB_NONE) 90592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 90692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 90792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else if (byPktType == PK_TYPE_11A) { 90892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if ((byFBOption != AUTO_FB_NONE) && (uDMAIdx != TYPE_ATIMDMA) && (uDMAIdx != TYPE_BEACONDMA)) { 90992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // Auto Fallback 91092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PSTxDataHead_a_FB pBuf = (PSTxDataHead_a_FB)pTxDataHead; 91192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Get SignalField,ServiceField,Length 91292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond BBvCaculateParameter(pDevice, cbFrameLength, wCurrentRate, byPktType, 91392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond (PWORD)&(pBuf->wTransmitLength), (PBYTE)&(pBuf->byServiceField), (PBYTE)&(pBuf->bySignalField) 91492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ); 91592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Get Duration and TimeStampOff 91692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wDuration = (WORD)s_uGetDataDuration(pDevice, DATADUR_A, cbFrameLength, byPktType, 91792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond wCurrentRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption); //0: 5GHz 91892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wDuration_f0 = (WORD)s_uGetDataDuration(pDevice, DATADUR_A_F0, cbFrameLength, byPktType, 91992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond wCurrentRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption); //0: 5GHz 92092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wDuration_f1 = (WORD)s_uGetDataDuration(pDevice, DATADUR_A_F1, cbFrameLength, byPktType, 92192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond wCurrentRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption); //0: 5GHz 92292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if(uDMAIdx!=TYPE_ATIMDMA) { 92392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wTimeStampOff = wTimeStampOff[pDevice->byPreambleType%2][wCurrentRate%MAX_RATE]; 92492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 92592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond return (pBuf->wDuration); 92692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else { 92792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PSTxDataHead_ab pBuf = (PSTxDataHead_ab)pTxDataHead; 92892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Get SignalField,ServiceField,Length 92992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond BBvCaculateParameter(pDevice, cbFrameLength, wCurrentRate, byPktType, 93092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond (PWORD)&(pBuf->wTransmitLength), (PBYTE)&(pBuf->byServiceField), (PBYTE)&(pBuf->bySignalField) 93192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ); 93292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Get Duration and TimeStampOff 93392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wDuration = (WORD)s_uGetDataDuration(pDevice, DATADUR_A, cbFrameLength, byPktType, 93492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond wCurrentRate, bNeedAck, uFragIdx, 93592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbLastFragmentSize, uMACfragNum, 93692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond byFBOption); 93792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 93892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if(uDMAIdx!=TYPE_ATIMDMA) { 93992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wTimeStampOff = wTimeStampOff[pDevice->byPreambleType%2][wCurrentRate%MAX_RATE]; 94092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 94192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond return (pBuf->wDuration); 94292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 94392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 94492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else if (byPktType == PK_TYPE_11B) { 94592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PSTxDataHead_ab pBuf = (PSTxDataHead_ab)pTxDataHead; 94692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Get SignalField,ServiceField,Length 94792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond BBvCaculateParameter(pDevice, cbFrameLength, wCurrentRate, byPktType, 94892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond (PWORD)&(pBuf->wTransmitLength), (PBYTE)&(pBuf->byServiceField), (PBYTE)&(pBuf->bySignalField) 94992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ); 95092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Get Duration and TimeStampOff 95192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wDuration = (WORD)s_uGetDataDuration(pDevice, DATADUR_B, cbFrameLength, byPktType, 95292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond wCurrentRate, bNeedAck, uFragIdx, 95392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbLastFragmentSize, uMACfragNum, 95492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond byFBOption); 95592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (uDMAIdx != TYPE_ATIMDMA) { 95692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wTimeStampOff = wTimeStampOff[pDevice->byPreambleType%2][wCurrentRate%MAX_RATE]; 95792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 95892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond return (pBuf->wDuration); 95992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 96092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond return 0; 96192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond} 96292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 96392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 96492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 96592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 96692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bondstatic 9678611a29ab967bc197494db19d31994d1b5a26fdcAndres Morevoid 96892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bonds_vFillRTSHead ( 969592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More PSDevice pDevice, 970592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More BYTE byPktType, 9718611a29ab967bc197494db19d31994d1b5a26fdcAndres More void *pvRTS, 972cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int cbFrameLength, 973592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More BOOL bNeedAck, 974592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More BOOL bDisCRC, 975592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More PSEthernetHeader psEthHeader, 976592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More WORD wCurrentRate, 977592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More BYTE byFBOption 97892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ) 97992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond{ 980cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int uRTSFrameLen = 20; 98192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond WORD wLen = 0x0000; 98292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 98392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pvRTS == NULL) 98492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond return; 98592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 98692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (bDisCRC) { 98792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // When CRCDIS bit is on, H/W forgot to generate FCS for RTS frame, 98892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // in this case we need to decrease its length by 4. 98992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uRTSFrameLen -= 4; 99092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 99192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 99292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // Note: So far RTSHead dosen't appear in ATIM & Beacom DMA, so we don't need to take them into account. 99392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // Otherwise, we need to modified codes for them. 99492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) { 99592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (byFBOption == AUTO_FB_NONE) { 99692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PSRTS_g pBuf = (PSRTS_g)pvRTS; 99792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Get SignalField,ServiceField,Length 99892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond BBvCaculateParameter(pDevice, uRTSFrameLen, pDevice->byTopCCKBasicRate, PK_TYPE_11B, 99992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond (PWORD)&(wLen), (PBYTE)&(pBuf->byServiceField_b), (PBYTE)&(pBuf->bySignalField_b) 100092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ); 100192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wTransmitLength_b = cpu_to_le16(wLen); 100292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond BBvCaculateParameter(pDevice, uRTSFrameLen, pDevice->byTopOFDMBasicRate, byPktType, 100392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond (PWORD)&(wLen), (PBYTE)&(pBuf->byServiceField_a), (PBYTE)&(pBuf->bySignalField_a) 100492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ); 100592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wTransmitLength_a = cpu_to_le16(wLen); 100692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Get Duration 100792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wDuration_bb = cpu_to_le16((WORD)s_uGetRTSCTSDuration(pDevice, RTSDUR_BB, cbFrameLength, PK_TYPE_11B, pDevice->byTopCCKBasicRate, bNeedAck, byFBOption)); //0:RTSDuration_bb, 1:2.4G, 1:CCKData 100892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wDuration_aa = cpu_to_le16((WORD)s_uGetRTSCTSDuration(pDevice, RTSDUR_AA, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption)); //2:RTSDuration_aa, 1:2.4G, 2,3: 2.4G OFDMData 100992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wDuration_ba = cpu_to_le16((WORD)s_uGetRTSCTSDuration(pDevice, RTSDUR_BA, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption)); //1:RTSDuration_ba, 1:2.4G, 2,3:2.4G OFDM Data 101092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 101192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->Data.wDurationID = pBuf->wDuration_aa; 101292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Get RTS Frame body 101392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->Data.wFrameControl = TYPE_CTL_RTS;//0x00B4 10149a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More 10159a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More if ((pDevice->eOPMode == OP_MODE_ADHOC) || 10169a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More (pDevice->eOPMode == OP_MODE_AP)) { 10179a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More memcpy(&(pBuf->Data.abyRA[0]), 10189a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More &(psEthHeader->abyDstAddr[0]), 10199a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More ETH_ALEN); 10209a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More } 102192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else { 10229a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More memcpy(&(pBuf->Data.abyRA[0]), 10239a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More &(pDevice->abyBSSID[0]), 10249a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More ETH_ALEN); 10259a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More } 10269a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More if (pDevice->eOPMode == OP_MODE_AP) { 10279a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More memcpy(&(pBuf->Data.abyTA[0]), 10289a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More &(pDevice->abyBSSID[0]), 10299a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More ETH_ALEN); 10309a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More } 103192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else { 10329a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More memcpy(&(pBuf->Data.abyTA[0]), 10339a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More &(psEthHeader->abySrcAddr[0]), 10349a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More ETH_ALEN); 103592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 103692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 103792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else { 103892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PSRTS_g_FB pBuf = (PSRTS_g_FB)pvRTS; 103992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Get SignalField,ServiceField,Length 104092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond BBvCaculateParameter(pDevice, uRTSFrameLen, pDevice->byTopCCKBasicRate, PK_TYPE_11B, 104192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond (PWORD)&(wLen), (PBYTE)&(pBuf->byServiceField_b), (PBYTE)&(pBuf->bySignalField_b) 104292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ); 104392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wTransmitLength_b = cpu_to_le16(wLen); 104492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond BBvCaculateParameter(pDevice, uRTSFrameLen, pDevice->byTopOFDMBasicRate, byPktType, 104592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond (PWORD)&(wLen), (PBYTE)&(pBuf->byServiceField_a), (PBYTE)&(pBuf->bySignalField_a) 104692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ); 104792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wTransmitLength_a = cpu_to_le16(wLen); 104892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Get Duration 104992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wDuration_bb = cpu_to_le16((WORD)s_uGetRTSCTSDuration(pDevice, RTSDUR_BB, cbFrameLength, PK_TYPE_11B, pDevice->byTopCCKBasicRate, bNeedAck, byFBOption)); //0:RTSDuration_bb, 1:2.4G, 1:CCKData 105092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wDuration_aa = cpu_to_le16((WORD)s_uGetRTSCTSDuration(pDevice, RTSDUR_AA, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption)); //2:RTSDuration_aa, 1:2.4G, 2,3:2.4G OFDMData 105192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wDuration_ba = cpu_to_le16((WORD)s_uGetRTSCTSDuration(pDevice, RTSDUR_BA, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption)); //1:RTSDuration_ba, 1:2.4G, 2,3:2.4G OFDMData 105292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wRTSDuration_ba_f0 = cpu_to_le16((WORD)s_uGetRTSCTSDuration(pDevice, RTSDUR_BA_F0, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption)); //4:wRTSDuration_ba_f0, 1:2.4G, 1:CCKData 105392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wRTSDuration_aa_f0 = cpu_to_le16((WORD)s_uGetRTSCTSDuration(pDevice, RTSDUR_AA_F0, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption)); //5:wRTSDuration_aa_f0, 1:2.4G, 1:CCKData 105492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wRTSDuration_ba_f1 = cpu_to_le16((WORD)s_uGetRTSCTSDuration(pDevice, RTSDUR_BA_F1, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption)); //6:wRTSDuration_ba_f1, 1:2.4G, 1:CCKData 105592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wRTSDuration_aa_f1 = cpu_to_le16((WORD)s_uGetRTSCTSDuration(pDevice, RTSDUR_AA_F1, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption)); //7:wRTSDuration_aa_f1, 1:2.4G, 1:CCKData 105692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->Data.wDurationID = pBuf->wDuration_aa; 105792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Get RTS Frame body 105892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->Data.wFrameControl = TYPE_CTL_RTS;//0x00B4 105992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 10609a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More if ((pDevice->eOPMode == OP_MODE_ADHOC) || 10619a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More (pDevice->eOPMode == OP_MODE_AP)) { 10629a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More memcpy(&(pBuf->Data.abyRA[0]), 10639a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More &(psEthHeader->abyDstAddr[0]), 10649a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More ETH_ALEN); 10659a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More } 106692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else { 10679a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More memcpy(&(pBuf->Data.abyRA[0]), 10689a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More &(pDevice->abyBSSID[0]), 10699a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More ETH_ALEN); 107092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 107192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 10729a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More if (pDevice->eOPMode == OP_MODE_AP) { 10739a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More memcpy(&(pBuf->Data.abyTA[0]), 10749a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More &(pDevice->abyBSSID[0]), 10759a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More ETH_ALEN); 10769a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More } 107792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else { 10789a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More memcpy(&(pBuf->Data.abyTA[0]), 10799a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More &(psEthHeader->abySrcAddr[0]), 10809a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More ETH_ALEN); 108192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 108292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 108392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } // if (byFBOption == AUTO_FB_NONE) 108492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 108592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else if (byPktType == PK_TYPE_11A) { 108692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (byFBOption == AUTO_FB_NONE) { 108792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PSRTS_ab pBuf = (PSRTS_ab)pvRTS; 108892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Get SignalField,ServiceField,Length 108992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond BBvCaculateParameter(pDevice, uRTSFrameLen, pDevice->byTopOFDMBasicRate, byPktType, 109092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond (PWORD)&(wLen), (PBYTE)&(pBuf->byServiceField), (PBYTE)&(pBuf->bySignalField) 109192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ); 109292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wTransmitLength = cpu_to_le16(wLen); 109392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Get Duration 109492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wDuration = cpu_to_le16((WORD)s_uGetRTSCTSDuration(pDevice, RTSDUR_AA, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption)); //0:RTSDuration_aa, 0:5G, 0: 5G OFDMData 109592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->Data.wDurationID = pBuf->wDuration; 109692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Get RTS Frame body 109792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->Data.wFrameControl = TYPE_CTL_RTS;//0x00B4 109892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 10999a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More if ((pDevice->eOPMode == OP_MODE_ADHOC) || 11009a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More (pDevice->eOPMode == OP_MODE_AP)) { 11019a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More memcpy(&(pBuf->Data.abyRA[0]), 11029a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More &(psEthHeader->abyDstAddr[0]), 11039a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More ETH_ALEN); 11049a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More } else { 11059a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More memcpy(&(pBuf->Data.abyRA[0]), 11069a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More &(pDevice->abyBSSID[0]), 11079a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More ETH_ALEN); 11089a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More } 11099a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More 11109a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More if (pDevice->eOPMode == OP_MODE_AP) { 11119a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More memcpy(&(pBuf->Data.abyTA[0]), 11129a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More &(pDevice->abyBSSID[0]), 11139a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More ETH_ALEN); 11149a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More } else { 11159a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More memcpy(&(pBuf->Data.abyTA[0]), 11169a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More &(psEthHeader->abySrcAddr[0]), 11179a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More ETH_ALEN); 11189a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More } 111992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 112092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 112192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else { 112292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PSRTS_a_FB pBuf = (PSRTS_a_FB)pvRTS; 112392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Get SignalField,ServiceField,Length 112492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond BBvCaculateParameter(pDevice, uRTSFrameLen, pDevice->byTopOFDMBasicRate, byPktType, 112592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond (PWORD)&(wLen), (PBYTE)&(pBuf->byServiceField), (PBYTE)&(pBuf->bySignalField) 112692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ); 112792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wTransmitLength = cpu_to_le16(wLen); 112892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Get Duration 112992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wDuration = cpu_to_le16((WORD)s_uGetRTSCTSDuration(pDevice, RTSDUR_AA, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption)); //0:RTSDuration_aa, 0:5G, 0: 5G OFDMData 113092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wRTSDuration_f0 = cpu_to_le16((WORD)s_uGetRTSCTSDuration(pDevice, RTSDUR_AA_F0, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption)); //5:RTSDuration_aa_f0, 0:5G, 0: 5G OFDMData 113192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wRTSDuration_f1 = cpu_to_le16((WORD)s_uGetRTSCTSDuration(pDevice, RTSDUR_AA_F1, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption)); //7:RTSDuration_aa_f1, 0:5G, 0: 113292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->Data.wDurationID = pBuf->wDuration; 113392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Get RTS Frame body 113492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->Data.wFrameControl = TYPE_CTL_RTS;//0x00B4 113592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 11369a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More if ((pDevice->eOPMode == OP_MODE_ADHOC) || 11379a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More (pDevice->eOPMode == OP_MODE_AP)) { 11389a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More memcpy(&(pBuf->Data.abyRA[0]), 11399a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More &(psEthHeader->abyDstAddr[0]), 11409a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More ETH_ALEN); 11419a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More } else { 11429a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More memcpy(&(pBuf->Data.abyRA[0]), 11439a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More &(pDevice->abyBSSID[0]), 11449a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More ETH_ALEN); 11459a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More } 11469a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More if (pDevice->eOPMode == OP_MODE_AP) { 11479a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More memcpy(&(pBuf->Data.abyTA[0]), 11489a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More &(pDevice->abyBSSID[0]), 11499a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More ETH_ALEN); 11509a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More } else { 11519a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More memcpy(&(pBuf->Data.abyTA[0]), 11529a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More &(psEthHeader->abySrcAddr[0]), 11539a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More ETH_ALEN); 11549a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More } 115592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 115692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 115792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else if (byPktType == PK_TYPE_11B) { 115892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PSRTS_ab pBuf = (PSRTS_ab)pvRTS; 115992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Get SignalField,ServiceField,Length 116092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond BBvCaculateParameter(pDevice, uRTSFrameLen, pDevice->byTopCCKBasicRate, PK_TYPE_11B, 116192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond (PWORD)&(wLen), (PBYTE)&(pBuf->byServiceField), (PBYTE)&(pBuf->bySignalField) 116292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ); 116392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wTransmitLength = cpu_to_le16(wLen); 116492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Get Duration 116592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wDuration = cpu_to_le16((WORD)s_uGetRTSCTSDuration(pDevice, RTSDUR_BB, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption)); //0:RTSDuration_bb, 1:2.4G, 1:CCKData 116692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->Data.wDurationID = pBuf->wDuration; 116792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Get RTS Frame body 116892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->Data.wFrameControl = TYPE_CTL_RTS;//0x00B4 116992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 11709a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More if ((pDevice->eOPMode == OP_MODE_ADHOC) || 117192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond (pDevice->eOPMode == OP_MODE_AP)) { 11729a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More memcpy(&(pBuf->Data.abyRA[0]), 11739a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More &(psEthHeader->abyDstAddr[0]), 11749a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More ETH_ALEN); 117592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 117692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else { 11779a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More memcpy(&(pBuf->Data.abyRA[0]), 11789a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More &(pDevice->abyBSSID[0]), 11799a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More ETH_ALEN); 118092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 118192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 118292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pDevice->eOPMode == OP_MODE_AP) { 11839a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More memcpy(&(pBuf->Data.abyTA[0]), 11849a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More &(pDevice->abyBSSID[0]), 11859a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More ETH_ALEN); 11869a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More } else { 11879a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More memcpy(&(pBuf->Data.abyTA[0]), 11889a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More &(psEthHeader->abySrcAddr[0]), 11899a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More ETH_ALEN); 119092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 119192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 119292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond} 119392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 119492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bondstatic 11958611a29ab967bc197494db19d31994d1b5a26fdcAndres Morevoid 119692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bonds_vFillCTSHead ( 1197592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More PSDevice pDevice, 1198cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int uDMAIdx, 1199592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More BYTE byPktType, 12008611a29ab967bc197494db19d31994d1b5a26fdcAndres More void *pvCTS, 1201cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int cbFrameLength, 1202592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More BOOL bNeedAck, 1203592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More BOOL bDisCRC, 1204592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More WORD wCurrentRate, 1205592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More BYTE byFBOption 120692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ) 120792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond{ 1208cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int uCTSFrameLen = 14; 120992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond WORD wLen = 0x0000; 121092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 121192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pvCTS == NULL) { 121292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond return; 121392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 121492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 121592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (bDisCRC) { 121692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // When CRCDIS bit is on, H/W forgot to generate FCS for CTS frame, 121792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // in this case we need to decrease its length by 4. 121892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uCTSFrameLen -= 4; 121992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 122092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 122192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) { 122292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (byFBOption != AUTO_FB_NONE && uDMAIdx != TYPE_ATIMDMA && uDMAIdx != TYPE_BEACONDMA) { 122392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // Auto Fall back 122492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PSCTS_FB pBuf = (PSCTS_FB)pvCTS; 122592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Get SignalField,ServiceField,Length 122692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond BBvCaculateParameter(pDevice, uCTSFrameLen, pDevice->byTopCCKBasicRate, PK_TYPE_11B, 122792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond (PWORD)&(wLen), (PBYTE)&(pBuf->byServiceField_b), (PBYTE)&(pBuf->bySignalField_b) 122892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ); 122992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wTransmitLength_b = cpu_to_le16(wLen); 123092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wDuration_ba = (WORD)s_uGetRTSCTSDuration(pDevice, CTSDUR_BA, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption); //3:CTSDuration_ba, 1:2.4G, 2,3:2.4G OFDM Data 123192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wDuration_ba += pDevice->wCTSDuration; 123292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wDuration_ba = cpu_to_le16(pBuf->wDuration_ba); 123392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Get CTSDuration_ba_f0 123492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wCTSDuration_ba_f0 = (WORD)s_uGetRTSCTSDuration(pDevice, CTSDUR_BA_F0, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption); //8:CTSDuration_ba_f0, 1:2.4G, 2,3:2.4G OFDM Data 123592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wCTSDuration_ba_f0 += pDevice->wCTSDuration; 123692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wCTSDuration_ba_f0 = cpu_to_le16(pBuf->wCTSDuration_ba_f0); 123792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Get CTSDuration_ba_f1 123892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wCTSDuration_ba_f1 = (WORD)s_uGetRTSCTSDuration(pDevice, CTSDUR_BA_F1, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption); //9:CTSDuration_ba_f1, 1:2.4G, 2,3:2.4G OFDM Data 123992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wCTSDuration_ba_f1 += pDevice->wCTSDuration; 124092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wCTSDuration_ba_f1 = cpu_to_le16(pBuf->wCTSDuration_ba_f1); 124192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Get CTS Frame body 124292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->Data.wDurationID = pBuf->wDuration_ba; 124392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->Data.wFrameControl = TYPE_CTL_CTS;//0x00C4 124492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->Data.wReserved = 0x0000; 12459a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More memcpy(&(pBuf->Data.abyRA[0]), 12469a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More &(pDevice->abyCurrentNetAddr[0]), 12479a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More ETH_ALEN); 124892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else { //if (byFBOption != AUTO_FB_NONE && uDMAIdx != TYPE_ATIMDMA && uDMAIdx != TYPE_BEACONDMA) 124992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PSCTS pBuf = (PSCTS)pvCTS; 125092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Get SignalField,ServiceField,Length 125192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond BBvCaculateParameter(pDevice, uCTSFrameLen, pDevice->byTopCCKBasicRate, PK_TYPE_11B, 125292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond (PWORD)&(wLen), (PBYTE)&(pBuf->byServiceField_b), (PBYTE)&(pBuf->bySignalField_b) 125392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ); 125492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wTransmitLength_b = cpu_to_le16(wLen); 125592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Get CTSDuration_ba 125692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wDuration_ba = cpu_to_le16((WORD)s_uGetRTSCTSDuration(pDevice, CTSDUR_BA, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption)); //3:CTSDuration_ba, 1:2.4G, 2,3:2.4G OFDM Data 125792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wDuration_ba += pDevice->wCTSDuration; 125892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wDuration_ba = cpu_to_le16(pBuf->wDuration_ba); 125992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 126092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Get CTS Frame body 126192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->Data.wDurationID = pBuf->wDuration_ba; 126292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->Data.wFrameControl = TYPE_CTL_CTS;//0x00C4 126392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->Data.wReserved = 0x0000; 12649a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More memcpy(&(pBuf->Data.abyRA[0]), 12659a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More &(pDevice->abyCurrentNetAddr[0]), 12669a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More ETH_ALEN); 126792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 126892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 126992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond} 127092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 127192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond/*+ 127292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * 127392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * Description: 127492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * Generate FIFO control for MAC & Baseband controller 127592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * 127692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * Parameters: 127792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * In: 127892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * pDevice - Pointer to adpater 127992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * pTxDataHead - Transmit Data Buffer 128092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * pTxBufHead - pTxBufHead 128192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * pvRrvTime - pvRrvTime 128292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * pvRTS - RTS Buffer 128392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * pCTS - CTS Buffer 128492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * cbFrameSize - Transmit Data Length (Hdr+Payload+FCS) 128592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * bNeedACK - If need ACK 128692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * uDMAIdx - DMA Index 128792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * Out: 128892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * none 128992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * 129092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * Return Value: none 129192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * 129292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond-*/ 1293cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More 129492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bondstatic 12958611a29ab967bc197494db19d31994d1b5a26fdcAndres Morevoid 129692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bonds_vGenerateTxParameter ( 1297592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More PSDevice pDevice, 1298592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More BYTE byPktType, 1299592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More WORD wCurrentRate, 13008611a29ab967bc197494db19d31994d1b5a26fdcAndres More void *pTxBufHead, 13018611a29ab967bc197494db19d31994d1b5a26fdcAndres More void *pvRrvTime, 13028611a29ab967bc197494db19d31994d1b5a26fdcAndres More void *pvRTS, 13038611a29ab967bc197494db19d31994d1b5a26fdcAndres More void *pvCTS, 1304cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int cbFrameSize, 1305592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More BOOL bNeedACK, 1306cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int uDMAIdx, 1307592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More PSEthernetHeader psEthHeader 130892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ) 130992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond{ 1310cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int cbMACHdLen = WLAN_HDR_ADDR3_LEN; /* 24 */ 131192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond WORD wFifoCtl; 131292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond BOOL bDisCRC = FALSE; 131392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond BYTE byFBOption = AUTO_FB_NONE; 131492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond// WORD wCurrentRate = pDevice->wCurrentRate; 131592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 131692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"s_vGenerateTxParameter...\n"); 131792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PSTxBufHead pFifoHead = (PSTxBufHead)pTxBufHead; 131892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pFifoHead->wReserved = wCurrentRate; 131992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond wFifoCtl = pFifoHead->wFIFOCtl; 132092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 132192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (wFifoCtl & FIFOCTL_CRCDIS) { 132292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond bDisCRC = TRUE; 132392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 132492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 132592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (wFifoCtl & FIFOCTL_AUTO_FB_0) { 132692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond byFBOption = AUTO_FB_0; 132792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 132892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else if (wFifoCtl & FIFOCTL_AUTO_FB_1) { 132992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond byFBOption = AUTO_FB_1; 133092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 133192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 133292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pDevice->bLongHeader) 133392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbMACHdLen = WLAN_HDR_ADDR3_LEN + 6; 133492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 133592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) { 133692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 133792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pvRTS != NULL) { //RTS_need 133892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Fill RsvTime 133992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pvRrvTime) { 134092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PSRrvTime_gRTS pBuf = (PSRrvTime_gRTS)pvRrvTime; 134192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wRTSTxRrvTime_aa = cpu_to_le16((WORD)s_uGetRTSCTSRsvTime(pDevice, 2, byPktType, cbFrameSize, wCurrentRate));//2:RTSTxRrvTime_aa, 1:2.4GHz 134292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wRTSTxRrvTime_ba = cpu_to_le16((WORD)s_uGetRTSCTSRsvTime(pDevice, 1, byPktType, cbFrameSize, wCurrentRate));//1:RTSTxRrvTime_ba, 1:2.4GHz 134392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wRTSTxRrvTime_bb = cpu_to_le16((WORD)s_uGetRTSCTSRsvTime(pDevice, 0, byPktType, cbFrameSize, wCurrentRate));//0:RTSTxRrvTime_bb, 1:2.4GHz 134492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wTxRrvTime_a = cpu_to_le16((WORD) s_uGetTxRsvTime(pDevice, byPktType, cbFrameSize, wCurrentRate, bNeedACK));//2.4G OFDM 134592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wTxRrvTime_b = cpu_to_le16((WORD) s_uGetTxRsvTime(pDevice, PK_TYPE_11B, cbFrameSize, pDevice->byTopCCKBasicRate, bNeedACK));//1:CCK 134692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 134792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Fill RTS 134892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond s_vFillRTSHead(pDevice, byPktType, pvRTS, cbFrameSize, bNeedACK, bDisCRC, psEthHeader, wCurrentRate, byFBOption); 134992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 135092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else {//RTS_needless, PCF mode 135192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 135292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Fill RsvTime 135392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pvRrvTime) { 135492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PSRrvTime_gCTS pBuf = (PSRrvTime_gCTS)pvRrvTime; 135592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wTxRrvTime_a = cpu_to_le16((WORD)s_uGetTxRsvTime(pDevice, byPktType, cbFrameSize, wCurrentRate, bNeedACK));//2.4G OFDM 135692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wTxRrvTime_b = cpu_to_le16((WORD)s_uGetTxRsvTime(pDevice, PK_TYPE_11B, cbFrameSize, pDevice->byTopCCKBasicRate, bNeedACK));//1:CCK 135792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wCTSTxRrvTime_ba = cpu_to_le16((WORD)s_uGetRTSCTSRsvTime(pDevice, 3, byPktType, cbFrameSize, wCurrentRate));//3:CTSTxRrvTime_Ba, 1:2.4GHz 135892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 135992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Fill CTS 136092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond s_vFillCTSHead(pDevice, uDMAIdx, byPktType, pvCTS, cbFrameSize, bNeedACK, bDisCRC, wCurrentRate, byFBOption); 136192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 136292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 136392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else if (byPktType == PK_TYPE_11A) { 136492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 136592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pvRTS != NULL) {//RTS_need, non PCF mode 136692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Fill RsvTime 136792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pvRrvTime) { 136892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PSRrvTime_ab pBuf = (PSRrvTime_ab)pvRrvTime; 136992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wRTSTxRrvTime = cpu_to_le16((WORD)s_uGetRTSCTSRsvTime(pDevice, 2, byPktType, cbFrameSize, wCurrentRate));//2:RTSTxRrvTime_aa, 0:5GHz 137092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wTxRrvTime = cpu_to_le16((WORD)s_uGetTxRsvTime(pDevice, byPktType, cbFrameSize, wCurrentRate, bNeedACK));//0:OFDM 137192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 137292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Fill RTS 137392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond s_vFillRTSHead(pDevice, byPktType, pvRTS, cbFrameSize, bNeedACK, bDisCRC, psEthHeader, wCurrentRate, byFBOption); 137492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 137592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else if (pvRTS == NULL) {//RTS_needless, non PCF mode 137692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Fill RsvTime 137792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pvRrvTime) { 137892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PSRrvTime_ab pBuf = (PSRrvTime_ab)pvRrvTime; 137992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wTxRrvTime = cpu_to_le16((WORD)s_uGetTxRsvTime(pDevice, PK_TYPE_11A, cbFrameSize, wCurrentRate, bNeedACK)); //0:OFDM 138092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 138192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 138292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 138392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else if (byPktType == PK_TYPE_11B) { 138492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 138592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if ((pvRTS != NULL)) {//RTS_need, non PCF mode 138692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Fill RsvTime 138792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pvRrvTime) { 138892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PSRrvTime_ab pBuf = (PSRrvTime_ab)pvRrvTime; 138992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wRTSTxRrvTime = cpu_to_le16((WORD)s_uGetRTSCTSRsvTime(pDevice, 0, byPktType, cbFrameSize, wCurrentRate));//0:RTSTxRrvTime_bb, 1:2.4GHz 139092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wTxRrvTime = cpu_to_le16((WORD)s_uGetTxRsvTime(pDevice, PK_TYPE_11B, cbFrameSize, wCurrentRate, bNeedACK));//1:CCK 139192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 139292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Fill RTS 139392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond s_vFillRTSHead(pDevice, byPktType, pvRTS, cbFrameSize, bNeedACK, bDisCRC, psEthHeader, wCurrentRate, byFBOption); 139492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 139592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else { //RTS_needless, non PCF mode 139692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Fill RsvTime 139792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pvRrvTime) { 139892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PSRrvTime_ab pBuf = (PSRrvTime_ab)pvRrvTime; 139992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pBuf->wTxRrvTime = cpu_to_le16((WORD)s_uGetTxRsvTime(pDevice, PK_TYPE_11B, cbFrameSize, wCurrentRate, bNeedACK)); //1:CCK 140092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 140192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 140292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 140392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"s_vGenerateTxParameter END.\n"); 140492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond} 140592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond/* 140692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PBYTE pbyBuffer,//point to pTxBufHead 140792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond WORD wFragType,//00:Non-Frag, 01:Start, 02:Mid, 03:Last 1408cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int cbFragmentSize,//Hdr+payoad+FCS 140992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond*/ 141092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 141192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 141292b96797118e5836294a6d42a5a8e10b86f50e3fForest BondBOOL 141392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bonds_bPacketToWirelessUsb( 1414592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More PSDevice pDevice, 1415592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More BYTE byPktType, 1416592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More PBYTE usbPacketBuf, 1417592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More BOOL bNeedEncryption, 1418cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int uSkbPacketLen, 1419cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int uDMAIdx, 1420592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More PSEthernetHeader psEthHeader, 1421592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More PBYTE pPacket, 1422592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More PSKeyItem pTransmitKey, 1423cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int uNodeIndex, 1424592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More WORD wCurrentRate, 1425cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int *pcbHeaderLen, 1426cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int *pcbTotalLen 142792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ) 142892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond{ 142992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PSMgmtObject pMgmt = &(pDevice->sMgmtObj); 1430cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int cbFrameSize, cbFrameBodySize; 143192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PTX_BUFFER pTxBufHead; 1432cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int cb802_1_H_len; 1433cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int cbIVlen = 0, cbICVlen = 0, cbMIClen = 0, 1434cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More cbMACHdLen = 0, cbFCSlen = 4; 1435cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int cbMICHDR = 0; 143692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond BOOL bNeedACK,bRTS; 143792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PBYTE pbyType,pbyMacHdr,pbyIVHead,pbyPayloadHead,pbyTxBufferAddr; 1438cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More BYTE abySNAP_RFC1042[ETH_ALEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00}; 1439cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More BYTE abySNAP_Bridgetunnel[ETH_ALEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0xF8}; 1440cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int uDuration; 1441cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int cbHeaderLength = 0, uPadding = 0; 14428611a29ab967bc197494db19d31994d1b5a26fdcAndres More void *pvRrvTime; 144392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PSMICHDRHead pMICHDR; 14448611a29ab967bc197494db19d31994d1b5a26fdcAndres More void *pvRTS; 14458611a29ab967bc197494db19d31994d1b5a26fdcAndres More void *pvCTS; 14468611a29ab967bc197494db19d31994d1b5a26fdcAndres More void *pvTxDataHd; 144792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond BYTE byFBOption = AUTO_FB_NONE,byFragType; 144892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond WORD wTxBufSize; 144992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond DWORD dwMICKey0,dwMICKey1,dwMIC_Priority,dwCRC; 145092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PDWORD pdwMIC_L,pdwMIC_R; 145192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond BOOL bSoftWEP = FALSE; 145292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 145392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 145492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 145592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 145692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pvRrvTime = pMICHDR = pvRTS = pvCTS = pvTxDataHd = NULL; 145792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if ((bNeedEncryption) && (pTransmitKey != NULL)) { 145892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (((PSKeyTable) (pTransmitKey->pvKeyTable))->bSoftWEP == TRUE) { 145992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // WEP 256 146092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond bSoftWEP = TRUE; 146192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 146292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 146392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 146492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTxBufHead = (PTX_BUFFER) usbPacketBuf; 14653e362598fd3c7b8729afd0383a4cdf08849b020eJim Lieb memset(pTxBufHead, 0, sizeof(TX_BUFFER)); 146692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 146792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // Get pkt type 1468020c0a9a78f8d5215f09164f7e5c5252dea098f9Andres More if (ntohs(psEthHeader->wType) > ETH_DATA_LEN) { 146992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pDevice->dwDiagRefCount == 0) { 147092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cb802_1_H_len = 8; 147192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else { 147292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cb802_1_H_len = 2; 147392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 147492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else { 147592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cb802_1_H_len = 0; 147692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 147792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 147821ec51f3df9fd3c83ce0a4ac6a18e5083984b8aeCharles Clément cbFrameBodySize = uSkbPacketLen - ETH_HLEN + cb802_1_H_len; 147992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 148092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Set packet type 148192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTxBufHead->wFIFOCtl |= (WORD)(byPktType<<8); 148292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 148392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pDevice->dwDiagRefCount != 0) { 148492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond bNeedACK = FALSE; 148592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTxBufHead->wFIFOCtl = pTxBufHead->wFIFOCtl & (~FIFOCTL_NEEDACK); 148692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else { //if (pDevice->dwDiagRefCount != 0) { 148722040bbf84ae5cc39b2b97f064c97592aa425d06Andres More if ((pDevice->eOPMode == OP_MODE_ADHOC) || 148822040bbf84ae5cc39b2b97f064c97592aa425d06Andres More (pDevice->eOPMode == OP_MODE_AP)) { 148922040bbf84ae5cc39b2b97f064c97592aa425d06Andres More if (is_multicast_ether_addr(psEthHeader->abyDstAddr)) { 149022040bbf84ae5cc39b2b97f064c97592aa425d06Andres More bNeedACK = FALSE; 149122040bbf84ae5cc39b2b97f064c97592aa425d06Andres More pTxBufHead->wFIFOCtl = 149222040bbf84ae5cc39b2b97f064c97592aa425d06Andres More pTxBufHead->wFIFOCtl & (~FIFOCTL_NEEDACK); 149322040bbf84ae5cc39b2b97f064c97592aa425d06Andres More } else { 149422040bbf84ae5cc39b2b97f064c97592aa425d06Andres More bNeedACK = TRUE; 149522040bbf84ae5cc39b2b97f064c97592aa425d06Andres More pTxBufHead->wFIFOCtl |= FIFOCTL_NEEDACK; 149622040bbf84ae5cc39b2b97f064c97592aa425d06Andres More } 149792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 149892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else { 149992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // MSDUs in Infra mode always need ACK 150092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond bNeedACK = TRUE; 150192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTxBufHead->wFIFOCtl |= FIFOCTL_NEEDACK; 150292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 150392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } //if (pDevice->dwDiagRefCount != 0) { 150492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 150592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTxBufHead->wTimeStamp = DEFAULT_MSDU_LIFETIME_RES_64us; 150692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 150792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Set FIFOCTL_LHEAD 150892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pDevice->bLongHeader) 150992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTxBufHead->wFIFOCtl |= FIFOCTL_LHEAD; 151092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 151192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pDevice->bSoftwareGenCrcErr) { 151292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTxBufHead->wFIFOCtl |= FIFOCTL_CRCDIS; // set tx descriptors to NO hardware CRC 151392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 151492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 151592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Set FRAGCTL_MACHDCNT 151692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pDevice->bLongHeader) { 151792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbMACHdLen = WLAN_HDR_ADDR3_LEN + 6; 151892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else { 151992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbMACHdLen = WLAN_HDR_ADDR3_LEN; 152092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 152192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTxBufHead->wFragCtl |= (WORD)(cbMACHdLen << 10); 152292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 152392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Set FIFOCTL_GrpAckPolicy 152492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pDevice->bGrpAckPolicy == TRUE) {//0000 0100 0000 0000 152592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTxBufHead->wFIFOCtl |= FIFOCTL_GRPACK; 152692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 152792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 152892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Set Auto Fallback Ctl 152992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (wCurrentRate >= RATE_18M) { 153092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pDevice->byAutoFBCtrl == AUTO_FB_0) { 153192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTxBufHead->wFIFOCtl |= FIFOCTL_AUTO_FB_0; 153292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond byFBOption = AUTO_FB_0; 153392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else if (pDevice->byAutoFBCtrl == AUTO_FB_1) { 153492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTxBufHead->wFIFOCtl |= FIFOCTL_AUTO_FB_1; 153592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond byFBOption = AUTO_FB_1; 153692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 153792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 153892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 153992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (bSoftWEP != TRUE) { 154092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if ((bNeedEncryption) && (pTransmitKey != NULL)) { //WEP enabled 154192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pTransmitKey->byCipherSuite == KEY_CTL_WEP) { //WEP40 or WEP104 154292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTxBufHead->wFragCtl |= FRAGCTL_LEGACY; 154392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 154492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pTransmitKey->byCipherSuite == KEY_CTL_TKIP) { 154592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Tx Set wFragCtl == FRAGCTL_TKIP\n"); 154692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTxBufHead->wFragCtl |= FRAGCTL_TKIP; 154792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 154892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else if (pTransmitKey->byCipherSuite == KEY_CTL_CCMP) { //CCMP 154992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTxBufHead->wFragCtl |= FRAGCTL_AES; 155092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 155192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 155292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 155392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 155492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 155592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if ((bNeedEncryption) && (pTransmitKey != NULL)) { 155692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pTransmitKey->byCipherSuite == KEY_CTL_WEP) { 155792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbIVlen = 4; 155892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbICVlen = 4; 155992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 156092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else if (pTransmitKey->byCipherSuite == KEY_CTL_TKIP) { 156192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbIVlen = 8;//IV+ExtIV 156292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbMIClen = 8; 156392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbICVlen = 4; 156492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 156592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pTransmitKey->byCipherSuite == KEY_CTL_CCMP) { 156692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbIVlen = 8;//RSN Header 156792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbICVlen = 8;//MIC 156892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbMICHDR = sizeof(SMICHDRHead); 156992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 157092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (bSoftWEP == FALSE) { 157192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //MAC Header should be padding 0 to DW alignment. 157292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uPadding = 4 - (cbMACHdLen%4); 157392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uPadding %= 4; 157492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 157592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 157692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 157792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbFrameSize = cbMACHdLen + cbIVlen + (cbFrameBodySize + cbMIClen) + cbICVlen + cbFCSlen; 157892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 157992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if ( (bNeedACK == FALSE) ||(cbFrameSize < pDevice->wRTSThreshold) ) { 158092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond bRTS = FALSE; 158192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else { 158292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond bRTS = TRUE; 158392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTxBufHead->wFIFOCtl |= (FIFOCTL_RTS | FIFOCTL_LRETRY); 158492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 158592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 158692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pbyTxBufferAddr = (PBYTE) &(pTxBufHead->adwTxKey[0]); 158792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond wTxBufSize = sizeof(STxBufHead); 158892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) {//802.11g packet 158992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (byFBOption == AUTO_FB_NONE) { 159092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (bRTS == TRUE) {//RTS_need 159192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pvRrvTime = (PSRrvTime_gRTS) (pbyTxBufferAddr + wTxBufSize); 159292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pMICHDR = (PSMICHDRHead) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_gRTS)); 159392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pvRTS = (PSRTS_g) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_gRTS) + cbMICHDR); 159492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pvCTS = NULL; 159592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pvTxDataHd = (PSTxDataHead_g) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_gRTS) + cbMICHDR + sizeof(SRTS_g)); 159692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbHeaderLength = wTxBufSize + sizeof(SRrvTime_gRTS) + cbMICHDR + sizeof(SRTS_g) + sizeof(STxDataHead_g); 159792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 159892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else { //RTS_needless 159992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pvRrvTime = (PSRrvTime_gCTS) (pbyTxBufferAddr + wTxBufSize); 160092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pMICHDR = (PSMICHDRHead) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_gCTS)); 160192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pvRTS = NULL; 160292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pvCTS = (PSCTS) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_gCTS) + cbMICHDR); 160392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pvTxDataHd = (PSTxDataHead_g) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_gCTS) + cbMICHDR + sizeof(SCTS)); 160492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbHeaderLength = wTxBufSize + sizeof(SRrvTime_gCTS) + cbMICHDR + sizeof(SCTS) + sizeof(STxDataHead_g); 160592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 160692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else { 160792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // Auto Fall Back 160892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (bRTS == TRUE) {//RTS_need 160992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pvRrvTime = (PSRrvTime_gRTS) (pbyTxBufferAddr + wTxBufSize); 161092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pMICHDR = (PSMICHDRHead) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_gRTS)); 161192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pvRTS = (PSRTS_g_FB) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_gRTS) + cbMICHDR); 161292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pvCTS = NULL; 161392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pvTxDataHd = (PSTxDataHead_g_FB) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_gRTS) + cbMICHDR + sizeof(SRTS_g_FB)); 161492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbHeaderLength = wTxBufSize + sizeof(SRrvTime_gRTS) + cbMICHDR + sizeof(SRTS_g_FB) + sizeof(STxDataHead_g_FB); 161592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 161692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else if (bRTS == FALSE) { //RTS_needless 161792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pvRrvTime = (PSRrvTime_gCTS) (pbyTxBufferAddr + wTxBufSize); 161892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pMICHDR = (PSMICHDRHead) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_gCTS)); 161992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pvRTS = NULL; 162092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pvCTS = (PSCTS_FB) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_gCTS) + cbMICHDR); 162192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pvTxDataHd = (PSTxDataHead_g_FB) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_gCTS) + cbMICHDR + sizeof(SCTS_FB)); 162292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbHeaderLength = wTxBufSize + sizeof(SRrvTime_gCTS) + cbMICHDR + sizeof(SCTS_FB) + sizeof(STxDataHead_g_FB); 162392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 162492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } // Auto Fall Back 162592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 162692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else {//802.11a/b packet 162792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (byFBOption == AUTO_FB_NONE) { 162892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (bRTS == TRUE) {//RTS_need 162992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pvRrvTime = (PSRrvTime_ab) (pbyTxBufferAddr + wTxBufSize); 163092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pMICHDR = (PSMICHDRHead) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_ab)); 163192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pvRTS = (PSRTS_ab) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_ab) + cbMICHDR); 163292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pvCTS = NULL; 163392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pvTxDataHd = (PSTxDataHead_ab) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_ab) + cbMICHDR + sizeof(SRTS_ab)); 163492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbHeaderLength = wTxBufSize + sizeof(PSRrvTime_ab) + cbMICHDR + sizeof(SRTS_ab) + sizeof(STxDataHead_ab); 163592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 163692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else if (bRTS == FALSE) { //RTS_needless, no MICHDR 163792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pvRrvTime = (PSRrvTime_ab) (pbyTxBufferAddr + wTxBufSize); 163892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pMICHDR = (PSMICHDRHead) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_ab)); 163992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pvRTS = NULL; 164092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pvCTS = NULL; 164192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pvTxDataHd = (PSTxDataHead_ab) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_ab) + cbMICHDR); 164292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbHeaderLength = wTxBufSize + sizeof(SRrvTime_ab) + cbMICHDR + sizeof(STxDataHead_ab); 164392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 164492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else { 164592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // Auto Fall Back 164692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (bRTS == TRUE) {//RTS_need 164792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pvRrvTime = (PSRrvTime_ab) (pbyTxBufferAddr + wTxBufSize); 164892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pMICHDR = (PSMICHDRHead) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_ab)); 164992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pvRTS = (PSRTS_a_FB) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_ab) + cbMICHDR); 165092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pvCTS = NULL; 165192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pvTxDataHd = (PSTxDataHead_a_FB) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_ab) + cbMICHDR + sizeof(SRTS_a_FB)); 165292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbHeaderLength = wTxBufSize + sizeof(PSRrvTime_ab) + cbMICHDR + sizeof(SRTS_a_FB) + sizeof(STxDataHead_a_FB); 165392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 165492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else if (bRTS == FALSE) { //RTS_needless 165592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pvRrvTime = (PSRrvTime_ab) (pbyTxBufferAddr + wTxBufSize); 165692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pMICHDR = (PSMICHDRHead) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_ab)); 165792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pvRTS = NULL; 165892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pvCTS = NULL; 165992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pvTxDataHd = (PSTxDataHead_a_FB) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_ab) + cbMICHDR); 166092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbHeaderLength = wTxBufSize + sizeof(SRrvTime_ab) + cbMICHDR + sizeof(STxDataHead_a_FB); 166192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 166292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } // Auto Fall Back 166392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 166492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 166592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pbyMacHdr = (PBYTE)(pbyTxBufferAddr + cbHeaderLength); 166692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pbyIVHead = (PBYTE)(pbyMacHdr + cbMACHdLen + uPadding); 166792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pbyPayloadHead = (PBYTE)(pbyMacHdr + cbMACHdLen + uPadding + cbIVlen); 166892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 166992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 167092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //========================= 167192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // No Fragmentation 167292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //========================= 167392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"No Fragmentation...\n"); 167492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond byFragType = FRAGCTL_NONFRAG; 167592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //uDMAIdx = TYPE_AC0DMA; 167692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //pTxBufHead = (PSTxBufHead) &(pTxBufHead->adwTxKey[0]); 167792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 167892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 167992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Fill FIFO,RrvTime,RTS,and CTS 16808611a29ab967bc197494db19d31994d1b5a26fdcAndres More s_vGenerateTxParameter(pDevice, byPktType, wCurrentRate, 16818611a29ab967bc197494db19d31994d1b5a26fdcAndres More (void *)pbyTxBufferAddr, pvRrvTime, pvRTS, pvCTS, 168292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbFrameSize, bNeedACK, uDMAIdx, psEthHeader); 168392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Fill DataHead 168492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uDuration = s_uFillDataHead(pDevice, byPktType, wCurrentRate, pvTxDataHd, cbFrameSize, uDMAIdx, bNeedACK, 168592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 0, 0, 1/*uMACfragNum*/, byFBOption); 168692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // Generate TX MAC Header 168792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond s_vGenerateMACHeader(pDevice, pbyMacHdr, (WORD)uDuration, psEthHeader, bNeedEncryption, 168892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond byFragType, uDMAIdx, 0); 168992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 169092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (bNeedEncryption == TRUE) { 169192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Fill TXKEY 169292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond s_vFillTxKey(pDevice, (PBYTE)(pTxBufHead->adwTxKey), pbyIVHead, pTransmitKey, 169392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pbyMacHdr, (WORD)cbFrameBodySize, (PBYTE)pMICHDR); 169492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 169592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pDevice->bEnableHostWEP) { 169692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pMgmt->sNodeDBTable[uNodeIndex].dwTSC47_16 = pTransmitKey->dwTSC47_16; 169792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pMgmt->sNodeDBTable[uNodeIndex].wTSC15_0 = pTransmitKey->wTSC15_0; 169892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 169992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 170092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 170192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // 802.1H 1702020c0a9a78f8d5215f09164f7e5c5252dea098f9Andres More if (ntohs(psEthHeader->wType) > ETH_DATA_LEN) { 1703203e4615ee9d9fa8d3506b9d0ef30095e4d5bc90Andres More if (pDevice->dwDiagRefCount == 0) { 1704203e4615ee9d9fa8d3506b9d0ef30095e4d5bc90Andres More if ((psEthHeader->wType == cpu_to_le16(ETH_P_IPX)) || 1705203e4615ee9d9fa8d3506b9d0ef30095e4d5bc90Andres More (psEthHeader->wType == cpu_to_le16(0xF380))) { 1706203e4615ee9d9fa8d3506b9d0ef30095e4d5bc90Andres More memcpy((PBYTE) (pbyPayloadHead), 1707203e4615ee9d9fa8d3506b9d0ef30095e4d5bc90Andres More abySNAP_Bridgetunnel, 6); 170892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else { 17093e362598fd3c7b8729afd0383a4cdf08849b020eJim Lieb memcpy((PBYTE) (pbyPayloadHead), &abySNAP_RFC1042[0], 6); 171092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 171192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pbyType = (PBYTE) (pbyPayloadHead + 6); 17123e362598fd3c7b8729afd0383a4cdf08849b020eJim Lieb memcpy(pbyType, &(psEthHeader->wType), sizeof(WORD)); 171392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else { 17143e362598fd3c7b8729afd0383a4cdf08849b020eJim Lieb memcpy((PBYTE) (pbyPayloadHead), &(psEthHeader->wType), sizeof(WORD)); 171592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 171692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 171792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 171892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 171992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 172092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 172192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pPacket != NULL) { 172292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // Copy the Packet into a tx Buffer 17233e362598fd3c7b8729afd0383a4cdf08849b020eJim Lieb memcpy((pbyPayloadHead + cb802_1_H_len), 172421ec51f3df9fd3c83ce0a4ac6a18e5083984b8aeCharles Clément (pPacket + ETH_HLEN), 172521ec51f3df9fd3c83ce0a4ac6a18e5083984b8aeCharles Clément uSkbPacketLen - ETH_HLEN 172692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ); 172792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 172892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else { 172992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // while bRelayPacketSend psEthHeader is point to header+payload 173021ec51f3df9fd3c83ce0a4ac6a18e5083984b8aeCharles Clément memcpy((pbyPayloadHead + cb802_1_H_len), ((PBYTE)psEthHeader) + ETH_HLEN, uSkbPacketLen - ETH_HLEN); 173192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 173292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 173392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ASSERT(uLength == cbNdisBodySize); 173492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 173592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if ((bNeedEncryption == TRUE) && (pTransmitKey != NULL) && (pTransmitKey->byCipherSuite == KEY_CTL_TKIP)) { 173692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 173792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond /////////////////////////////////////////////////////////////////// 173892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 173992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pDevice->sMgmtObj.eAuthenMode == WMAC_AUTH_WPANONE) { 174092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond dwMICKey0 = *(PDWORD)(&pTransmitKey->abyKey[16]); 174192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond dwMICKey1 = *(PDWORD)(&pTransmitKey->abyKey[20]); 174292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 174392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else if ((pTransmitKey->dwKeyIndex & AUTHENTICATOR_KEY) != 0) { 174492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond dwMICKey0 = *(PDWORD)(&pTransmitKey->abyKey[16]); 174592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond dwMICKey1 = *(PDWORD)(&pTransmitKey->abyKey[20]); 174692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 174792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else { 174892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond dwMICKey0 = *(PDWORD)(&pTransmitKey->abyKey[24]); 174992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond dwMICKey1 = *(PDWORD)(&pTransmitKey->abyKey[28]); 175092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 175192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // DO Software Michael 175292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond MIC_vInit(dwMICKey0, dwMICKey1); 175392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond MIC_vAppend((PBYTE)&(psEthHeader->abyDstAddr[0]), 12); 175492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond dwMIC_Priority = 0; 175592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond MIC_vAppend((PBYTE)&dwMIC_Priority, 4); 175692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"MIC KEY: %lX, %lX\n", dwMICKey0, dwMICKey1); 175792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 175892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond /////////////////////////////////////////////////////////////////// 175992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 176092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //DBG_PRN_GRP12(("Length:%d, %d\n", cbFrameBodySize, uFromHDtoPLDLength)); 176192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //for (ii = 0; ii < cbFrameBodySize; ii++) { 176292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // DBG_PRN_GRP12(("%02x ", *((PBYTE)((pbyPayloadHead + cb802_1_H_len) + ii)))); 176392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //} 176492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //DBG_PRN_GRP12(("\n\n\n")); 176592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 176692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond MIC_vAppend(pbyPayloadHead, cbFrameBodySize); 176792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 176892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pdwMIC_L = (PDWORD)(pbyPayloadHead + cbFrameBodySize); 176992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pdwMIC_R = (PDWORD)(pbyPayloadHead + cbFrameBodySize + 4); 177092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 177192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond MIC_vGetMIC(pdwMIC_L, pdwMIC_R); 177292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond MIC_vUnInit(); 177392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 177492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pDevice->bTxMICFail == TRUE) { 177592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond *pdwMIC_L = 0; 177692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond *pdwMIC_R = 0; 177792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pDevice->bTxMICFail = FALSE; 177892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 177992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"uLength: %d, %d\n", uLength, cbFrameBodySize); 178092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"cbReqCount:%d, %d, %d, %d\n", cbReqCount, cbHeaderLength, uPadding, cbIVlen); 178192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"MIC:%lX, %lX\n", *pdwMIC_L, *pdwMIC_R); 178292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 178392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 178492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 178592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (bSoftWEP == TRUE) { 178692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 178792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond s_vSWencryption(pDevice, pTransmitKey, (pbyPayloadHead), (WORD)(cbFrameBodySize + cbMIClen)); 178892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 178992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else if ( ((pDevice->eEncryptionStatus == Ndis802_11Encryption1Enabled) && (bNeedEncryption == TRUE)) || 179092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ((pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled) && (bNeedEncryption == TRUE)) || 179192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ((pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled) && (bNeedEncryption == TRUE)) ) { 179292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbFrameSize -= cbICVlen; 179392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 179492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 179592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pDevice->bSoftwareGenCrcErr == TRUE) { 1796cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int cbLen; 179792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PDWORD pdwCRC; 179892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 179992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond dwCRC = 0xFFFFFFFFL; 180092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbLen = cbFrameSize - cbFCSlen; 180192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // calculate CRC, and wrtie CRC value to end of TD 180292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond dwCRC = CRCdwGetCrc32Ex(pbyMacHdr, cbLen, dwCRC); 180392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pdwCRC = (PDWORD)(pbyMacHdr + cbLen); 180492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // finally, we must invert dwCRC to get the correct answer 180592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond *pdwCRC = ~dwCRC; 180692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // Force Error 180792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond *pdwCRC -= 1; 180892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else { 180992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbFrameSize -= cbFCSlen; 181092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 181192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 181292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond *pcbHeaderLen = cbHeaderLength; 181392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond *pcbTotalLen = cbHeaderLength + cbFrameSize ; 181492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 181592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 181692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Set FragCtl in TxBufferHead 181792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTxBufHead->wFragCtl |= (WORD)byFragType; 181892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 181992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 182092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond return TRUE; 182192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 182292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond} 182392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 182492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 182592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond/*+ 182692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * 182792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * Description: 182892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * Translate 802.3 to 802.11 header 182992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * 183092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * Parameters: 183192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * In: 183292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * pDevice - Pointer to adpater 183392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * dwTxBufferAddr - Transmit Buffer 183492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * pPacket - Packet from upper layer 183592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * cbPacketSize - Transmit Data Length 183692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * Out: 183792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * pcbHeadSize - Header size of MAC&Baseband control and 802.11 Header 183892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * pcbAppendPayload - size of append payload for 802.1H translation 183992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * 184092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * Return Value: none 184192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * 184292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond-*/ 184392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 18448611a29ab967bc197494db19d31994d1b5a26fdcAndres Morevoid 184592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bonds_vGenerateMACHeader ( 1846592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More PSDevice pDevice, 1847592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More PBYTE pbyBufferAddr, 1848592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More WORD wDuration, 1849592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More PSEthernetHeader psEthHeader, 1850592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More BOOL bNeedEncrypt, 1851592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More WORD wFragType, 1852cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int uDMAIdx, 1853cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int uFragIdx 185492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ) 185592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond{ 185692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PS802_11Header pMACHeader = (PS802_11Header)pbyBufferAddr; 185792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 18583e362598fd3c7b8729afd0383a4cdf08849b020eJim Lieb memset(pMACHeader, 0, (sizeof(S802_11Header))); //- sizeof(pMACHeader->dwIV))); 185992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 186092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (uDMAIdx == TYPE_ATIMDMA) { 186192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pMACHeader->wFrameCtl = TYPE_802_11_ATIM; 186292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else { 186392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pMACHeader->wFrameCtl = TYPE_802_11_DATA; 186492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 186592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 186692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pDevice->eOPMode == OP_MODE_AP) { 18679a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More memcpy(&(pMACHeader->abyAddr1[0]), 18689a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More &(psEthHeader->abyDstAddr[0]), 18699a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More ETH_ALEN); 18709a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More memcpy(&(pMACHeader->abyAddr2[0]), &(pDevice->abyBSSID[0]), ETH_ALEN); 18719a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More memcpy(&(pMACHeader->abyAddr3[0]), 18729a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More &(psEthHeader->abySrcAddr[0]), 18739a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More ETH_ALEN); 187492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pMACHeader->wFrameCtl |= FC_FROMDS; 18759a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More } else { 18769a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More if (pDevice->eOPMode == OP_MODE_ADHOC) { 18779a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More memcpy(&(pMACHeader->abyAddr1[0]), 18789a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More &(psEthHeader->abyDstAddr[0]), 18799a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More ETH_ALEN); 18809a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More memcpy(&(pMACHeader->abyAddr2[0]), 18819a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More &(psEthHeader->abySrcAddr[0]), 18829a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More ETH_ALEN); 18839a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More memcpy(&(pMACHeader->abyAddr3[0]), 18849a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More &(pDevice->abyBSSID[0]), 18859a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More ETH_ALEN); 18869a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More } else { 18879a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More memcpy(&(pMACHeader->abyAddr3[0]), 18889a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More &(psEthHeader->abyDstAddr[0]), 18899a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More ETH_ALEN); 18909a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More memcpy(&(pMACHeader->abyAddr2[0]), 18919a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More &(psEthHeader->abySrcAddr[0]), 18929a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More ETH_ALEN); 18939a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More memcpy(&(pMACHeader->abyAddr1[0]), 18949a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More &(pDevice->abyBSSID[0]), 18959a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More ETH_ALEN); 189692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pMACHeader->wFrameCtl |= FC_TODS; 189792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 189892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 189992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 190092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (bNeedEncrypt) 190192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pMACHeader->wFrameCtl |= cpu_to_le16((WORD)WLAN_SET_FC_ISWEP(1)); 190292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 190392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pMACHeader->wDurationID = cpu_to_le16(wDuration); 190492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 190592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pDevice->bLongHeader) { 190692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PWLAN_80211HDR_A4 pMACA4Header = (PWLAN_80211HDR_A4) pbyBufferAddr; 190792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pMACHeader->wFrameCtl |= (FC_TODS | FC_FROMDS); 19083e362598fd3c7b8729afd0383a4cdf08849b020eJim Lieb memcpy(pMACA4Header->abyAddr4, pDevice->abyBSSID, WLAN_ADDR_LEN); 190992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 191092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pMACHeader->wSeqCtl = cpu_to_le16(pDevice->wSeqCounter << 4); 191192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 191292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Set FragNumber in Sequence Control 191392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pMACHeader->wSeqCtl |= cpu_to_le16((WORD)uFragIdx); 191492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 191592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if ((wFragType == FRAGCTL_ENDFRAG) || (wFragType == FRAGCTL_NONFRAG)) { 191692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pDevice->wSeqCounter++; 191792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pDevice->wSeqCounter > 0x0fff) 191892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pDevice->wSeqCounter = 0; 191992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 192092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 192192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if ((wFragType == FRAGCTL_STAFRAG) || (wFragType == FRAGCTL_MIDFRAG)) { //StartFrag or MidFrag 192292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pMACHeader->wFrameCtl |= FC_MOREFRAG; 192392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 192492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond} 192592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 192692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 192792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 192892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond/*+ 192992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * 193092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * Description: 193192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * Request instructs a MAC to transmit a 802.11 management packet through 193292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * the adapter onto the medium. 193392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * 193492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * Parameters: 193592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * In: 193692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * hDeviceContext - Pointer to the adapter 193792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * pPacket - A pointer to a descriptor for the packet to transmit 193892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * Out: 193992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * none 194092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * 194125985edcedea6396277003854657b5f3cb31a628Lucas De Marchi * Return Value: CMD_STATUS_PENDING if MAC Tx resource available; otherwise FALSE 194292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * 194392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond-*/ 194492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 194592b96797118e5836294a6d42a5a8e10b86f50e3fForest BondCMD_STATUS csMgmt_xmit( 1946592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More PSDevice pDevice, 1947592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More PSTxMgmtPacket pPacket 194892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ) 194992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond{ 195092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond BYTE byPktType; 195192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PBYTE pbyTxBufferAddr; 19528611a29ab967bc197494db19d31994d1b5a26fdcAndres More void *pvRTS; 195392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PSCTS pCTS; 19548611a29ab967bc197494db19d31994d1b5a26fdcAndres More void *pvTxDataHd; 1955cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int uDuration; 1956cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int cbReqCount; 195792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PS802_11Header pMACHeader; 1958cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int cbHeaderSize; 1959cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int cbFrameBodySize; 196092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond BOOL bNeedACK; 196192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond BOOL bIsPSPOLL = FALSE; 196292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PSTxBufHead pTxBufHead; 1963cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int cbFrameSize; 1964cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int cbIVlen = 0; 1965cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int cbICVlen = 0; 1966cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int cbMIClen = 0; 1967cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int cbFCSlen = 4; 1968cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int uPadding = 0; 196992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond WORD wTxBufSize; 1970cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int cbMacHdLen; 197192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond SEthernetHeader sEthHeader; 19728611a29ab967bc197494db19d31994d1b5a26fdcAndres More void *pvRrvTime; 19738611a29ab967bc197494db19d31994d1b5a26fdcAndres More void *pMICHDR; 197492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PSMgmtObject pMgmt = &(pDevice->sMgmtObj); 197592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond WORD wCurrentRate = RATE_1M; 197692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PTX_BUFFER pTX_Buffer; 197792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PUSB_SEND_CONTEXT pContext; 197892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 197992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 198092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 198192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pContext = (PUSB_SEND_CONTEXT)s_vGetFreeContext(pDevice); 198292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 198392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (NULL == pContext) { 198492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ManagementSend TX...NO CONTEXT!\n"); 198592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond return CMD_STATUS_RESOURCES; 198692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 198792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 198892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTX_Buffer = (PTX_BUFFER) (&pContext->Data[0]); 198992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pbyTxBufferAddr = (PBYTE)&(pTX_Buffer->adwTxKey[0]); 199092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbFrameBodySize = pPacket->cbPayloadLen; 199192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTxBufHead = (PSTxBufHead) pbyTxBufferAddr; 199292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond wTxBufSize = sizeof(STxBufHead); 199392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond memset(pTxBufHead, 0, wTxBufSize); 199492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 199592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pDevice->byBBType == BB_TYPE_11A) { 199692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond wCurrentRate = RATE_6M; 199792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond byPktType = PK_TYPE_11A; 199892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else { 199992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond wCurrentRate = RATE_1M; 200092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond byPktType = PK_TYPE_11B; 200192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 200292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 200392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // SetPower will cause error power TX state for OFDM Date packet in TX buffer. 200492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // 2004.11.11 Kyle -- Using OFDM power to tx MngPkt will decrease the connection capability. 200592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // And cmd timer will wait data pkt TX finish before scanning so it's OK 200692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // to set power here. 200792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pMgmt->eScanState != WMAC_NO_SCANNING) { 200892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond RFbSetPower(pDevice, wCurrentRate, pDevice->byCurrentCh); 200992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else { 201092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond RFbSetPower(pDevice, wCurrentRate, pMgmt->uCurrChannel); 201192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 201292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pDevice->wCurrentRate = wCurrentRate; 201392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 201492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 201592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Set packet type 201692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (byPktType == PK_TYPE_11A) {//0000 0000 0000 0000 201792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTxBufHead->wFIFOCtl = 0; 201892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 201992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else if (byPktType == PK_TYPE_11B) {//0000 0001 0000 0000 202092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTxBufHead->wFIFOCtl |= FIFOCTL_11B; 202192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 202292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else if (byPktType == PK_TYPE_11GB) {//0000 0010 0000 0000 202392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTxBufHead->wFIFOCtl |= FIFOCTL_11GB; 202492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 202592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else if (byPktType == PK_TYPE_11GA) {//0000 0011 0000 0000 202692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTxBufHead->wFIFOCtl |= FIFOCTL_11GA; 202792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 202892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 202992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTxBufHead->wFIFOCtl |= FIFOCTL_TMOEN; 203092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTxBufHead->wTimeStamp = cpu_to_le16(DEFAULT_MGN_LIFETIME_RES_64us); 203192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 203222040bbf84ae5cc39b2b97f064c97592aa425d06Andres More if (is_multicast_ether_addr(pPacket->p80211Header->sA3.abyAddr1)) { 203392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond bNeedACK = FALSE; 203492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 203592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else { 203692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond bNeedACK = TRUE; 203792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTxBufHead->wFIFOCtl |= FIFOCTL_NEEDACK; 203892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond }; 203992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 204092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) || 204192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) ) { 204292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 204392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTxBufHead->wFIFOCtl |= FIFOCTL_LRETRY; 204492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Set Preamble type always long 204592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //pDevice->byPreambleType = PREAMBLE_LONG; 204692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // probe-response don't retry 204792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //if ((pPacket->p80211Header->sA4.wFrameCtl & TYPE_SUBTYPE_MASK) == TYPE_MGMT_PROBE_RSP) { 204892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // bNeedACK = FALSE; 204992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // pTxBufHead->wFIFOCtl &= (~FIFOCTL_NEEDACK); 205092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //} 205192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 205292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 205392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTxBufHead->wFIFOCtl |= (FIFOCTL_GENINT | FIFOCTL_ISDMA0); 205492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 205592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if ((pPacket->p80211Header->sA4.wFrameCtl & TYPE_SUBTYPE_MASK) == TYPE_CTL_PSPOLL) { 205692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond bIsPSPOLL = TRUE; 205792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbMacHdLen = WLAN_HDR_ADDR2_LEN; 205892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else { 205992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbMacHdLen = WLAN_HDR_ADDR3_LEN; 206092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 206192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 206292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Set FRAGCTL_MACHDCNT 206392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTxBufHead->wFragCtl |= cpu_to_le16((WORD)(cbMacHdLen << 10)); 206492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 206592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // Notes: 206692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // Although spec says MMPDU can be fragmented; In most case, 206792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // no one will send a MMPDU under fragmentation. With RTS may occur. 206892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pDevice->bAES = FALSE; //Set FRAGCTL_WEPTYP 206992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 207092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (WLAN_GET_FC_ISWEP(pPacket->p80211Header->sA4.wFrameCtl) != 0) { 207192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pDevice->eEncryptionStatus == Ndis802_11Encryption1Enabled) { 207292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbIVlen = 4; 207392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbICVlen = 4; 207492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTxBufHead->wFragCtl |= FRAGCTL_LEGACY; 207592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 207692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else if (pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled) { 207792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbIVlen = 8;//IV+ExtIV 207892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbMIClen = 8; 207992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbICVlen = 4; 208092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTxBufHead->wFragCtl |= FRAGCTL_TKIP; 208192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //We need to get seed here for filling TxKey entry. 208292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //TKIPvMixKey(pTransmitKey->abyKey, pDevice->abyCurrentNetAddr, 208392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // pTransmitKey->wTSC15_0, pTransmitKey->dwTSC47_16, pDevice->abyPRNG); 208492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 208592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else if (pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled) { 208692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbIVlen = 8;//RSN Header 208792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbICVlen = 8;//MIC 208892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTxBufHead->wFragCtl |= FRAGCTL_AES; 208992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pDevice->bAES = TRUE; 209092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 209192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //MAC Header should be padding 0 to DW alignment. 209292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uPadding = 4 - (cbMacHdLen%4); 209392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uPadding %= 4; 209492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 209592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 209692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbFrameSize = cbMacHdLen + cbFrameBodySize + cbIVlen + cbMIClen + cbICVlen + cbFCSlen; 209792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 209892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Set FIFOCTL_GrpAckPolicy 209992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pDevice->bGrpAckPolicy == TRUE) {//0000 0100 0000 0000 210092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTxBufHead->wFIFOCtl |= FIFOCTL_GRPACK; 210192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 210292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //the rest of pTxBufHead->wFragCtl:FragTyp will be set later in s_vFillFragParameter() 210392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 210492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Set RrvTime/RTS/CTS Buffer 210592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) {//802.11g packet 210692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 210792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pvRrvTime = (PSRrvTime_gCTS) (pbyTxBufferAddr + wTxBufSize); 210892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pMICHDR = NULL; 210992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pvRTS = NULL; 211092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pCTS = (PSCTS) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_gCTS)); 211192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pvTxDataHd = (PSTxDataHead_g) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_gCTS) + sizeof(SCTS)); 211292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbHeaderSize = wTxBufSize + sizeof(SRrvTime_gCTS) + sizeof(SCTS) + sizeof(STxDataHead_g); 211392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 211492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else { // 802.11a/b packet 211592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pvRrvTime = (PSRrvTime_ab) (pbyTxBufferAddr + wTxBufSize); 211692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pMICHDR = NULL; 211792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pvRTS = NULL; 211892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pCTS = NULL; 211992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pvTxDataHd = (PSTxDataHead_ab) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_ab)); 212092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbHeaderSize = wTxBufSize + sizeof(SRrvTime_ab) + sizeof(STxDataHead_ab); 212192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 212292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 21238611a29ab967bc197494db19d31994d1b5a26fdcAndres More memset((void *)(pbyTxBufferAddr + wTxBufSize), 0, 21248611a29ab967bc197494db19d31994d1b5a26fdcAndres More (cbHeaderSize - wTxBufSize)); 212592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 21269a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More memcpy(&(sEthHeader.abyDstAddr[0]), 21279a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More &(pPacket->p80211Header->sA3.abyAddr1[0]), 21289a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More ETH_ALEN); 21299a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More memcpy(&(sEthHeader.abySrcAddr[0]), 21309a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More &(pPacket->p80211Header->sA3.abyAddr2[0]), 21319a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More ETH_ALEN); 213292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //========================= 213392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // No Fragmentation 213492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //========================= 213592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTxBufHead->wFragCtl |= (WORD)FRAGCTL_NONFRAG; 213692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 213792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 213892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Fill FIFO,RrvTime,RTS,and CTS 213992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond s_vGenerateTxParameter(pDevice, byPktType, wCurrentRate, pbyTxBufferAddr, pvRrvTime, pvRTS, pCTS, 214092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbFrameSize, bNeedACK, TYPE_TXDMA0, &sEthHeader); 214192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 214292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Fill DataHead 214392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uDuration = s_uFillDataHead(pDevice, byPktType, wCurrentRate, pvTxDataHd, cbFrameSize, TYPE_TXDMA0, bNeedACK, 214492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 0, 0, 1, AUTO_FB_NONE); 214592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 214692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pMACHeader = (PS802_11Header) (pbyTxBufferAddr + cbHeaderSize); 214792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 214892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbReqCount = cbHeaderSize + cbMacHdLen + uPadding + cbIVlen + cbFrameBodySize; 214992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 215092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (WLAN_GET_FC_ISWEP(pPacket->p80211Header->sA4.wFrameCtl) != 0) { 215192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PBYTE pbyIVHead; 215292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PBYTE pbyPayloadHead; 215392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PBYTE pbyBSSID; 215492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PSKeyItem pTransmitKey = NULL; 215592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 215692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pbyIVHead = (PBYTE)(pbyTxBufferAddr + cbHeaderSize + cbMacHdLen + uPadding); 215792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pbyPayloadHead = (PBYTE)(pbyTxBufferAddr + cbHeaderSize + cbMacHdLen + uPadding + cbIVlen); 215892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond do { 215992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if ((pDevice->eOPMode == OP_MODE_INFRASTRUCTURE) && 216092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond (pDevice->bLinkPass == TRUE)) { 216192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pbyBSSID = pDevice->abyBSSID; 216292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // get pairwise key 216392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, PAIRWISE_KEY, &pTransmitKey) == FALSE) { 216492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // get group key 216592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if(KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, GROUP_KEY, &pTransmitKey) == TRUE) { 216692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Get GTK.\n"); 216792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond break; 216892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 216992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else { 217092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Get PTK.\n"); 217192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond break; 217292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 217392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 217492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // get group key 217592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pbyBSSID = pDevice->abyBroadcastAddr; 217692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if(KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, GROUP_KEY, &pTransmitKey) == FALSE) { 217792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTransmitKey = NULL; 217892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"KEY is NULL. OP Mode[%d]\n", pDevice->eOPMode); 217992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else { 218092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Get GTK.\n"); 218192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 218292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } while(FALSE); 218392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Fill TXKEY 218492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond s_vFillTxKey(pDevice, (PBYTE)(pTxBufHead->adwTxKey), pbyIVHead, pTransmitKey, 218592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond (PBYTE)pMACHeader, (WORD)cbFrameBodySize, NULL); 218692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 21873e362598fd3c7b8729afd0383a4cdf08849b020eJim Lieb memcpy(pMACHeader, pPacket->p80211Header, cbMacHdLen); 21883e362598fd3c7b8729afd0383a4cdf08849b020eJim Lieb memcpy(pbyPayloadHead, ((PBYTE)(pPacket->p80211Header) + cbMacHdLen), 218992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbFrameBodySize); 219092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 219192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else { 219292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // Copy the Packet into a tx Buffer 21933e362598fd3c7b8729afd0383a4cdf08849b020eJim Lieb memcpy(pMACHeader, pPacket->p80211Header, pPacket->cbMPDULen); 219492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 219592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 219692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pMACHeader->wSeqCtl = cpu_to_le16(pDevice->wSeqCounter << 4); 219792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pDevice->wSeqCounter++ ; 219892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pDevice->wSeqCounter > 0x0fff) 219992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pDevice->wSeqCounter = 0; 220092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 220192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (bIsPSPOLL) { 220292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // The MAC will automatically replace the Duration-field of MAC header by Duration-field 220392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // of FIFO control header. 220492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // This will cause AID-field of PS-POLL packet be incorrect (Because PS-POLL's AID field is 220592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // in the same place of other packet's Duration-field). 220692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // And it will cause Cisco-AP to issue Disassociation-packet 220792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) { 220892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ((PSTxDataHead_g)pvTxDataHd)->wDuration_a = cpu_to_le16(pPacket->p80211Header->sA2.wDurationID); 220992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ((PSTxDataHead_g)pvTxDataHd)->wDuration_b = cpu_to_le16(pPacket->p80211Header->sA2.wDurationID); 221092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else { 221192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ((PSTxDataHead_ab)pvTxDataHd)->wDuration = cpu_to_le16(pPacket->p80211Header->sA2.wDurationID); 221292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 221392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 221492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 221592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 221692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTX_Buffer->wTxByteCount = cpu_to_le16((WORD)(cbReqCount)); 221792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTX_Buffer->byPKTNO = (BYTE) (((wCurrentRate<<4) &0x00F0) | ((pDevice->wSeqCounter - 1) & 0x000F)); 221892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTX_Buffer->byType = 0x00; 221992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 222092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pContext->pPacket = NULL; 222192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pContext->Type = CONTEXT_MGMT_PACKET; 222292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pContext->uBufLen = (WORD)cbReqCount + 4; //USB header 222392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 222492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (WLAN_GET_FC_TODS(pMACHeader->wFrameCtl) == 0) { 222592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond s_vSaveTxPktInfo(pDevice, (BYTE) (pTX_Buffer->byPKTNO & 0x0F), &(pMACHeader->abyAddr1[0]),(WORD)cbFrameSize,pTX_Buffer->wFIFOCtl); 222692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 222792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else { 222892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond s_vSaveTxPktInfo(pDevice, (BYTE) (pTX_Buffer->byPKTNO & 0x0F), &(pMACHeader->abyAddr3[0]),(WORD)cbFrameSize,pTX_Buffer->wFIFOCtl); 222992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 223092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 223192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PIPEnsSendBulkOut(pDevice,pContext); 223292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond return CMD_STATUS_PENDING; 223392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond} 223492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 223592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 223692b96797118e5836294a6d42a5a8e10b86f50e3fForest BondCMD_STATUS 223792b96797118e5836294a6d42a5a8e10b86f50e3fForest BondcsBeacon_xmit( 2238592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More PSDevice pDevice, 2239592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More PSTxMgmtPacket pPacket 224092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ) 224192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond{ 224292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 2243cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int cbFrameSize = pPacket->cbMPDULen + WLAN_FCS_LEN; 2244cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int cbHeaderSize = 0; 224592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond WORD wTxBufSize = sizeof(STxShortBufHead); 224692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PSTxShortBufHead pTxBufHead; 224792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PS802_11Header pMACHeader; 224892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PSTxDataHead_ab pTxDataHead; 224992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond WORD wCurrentRate; 2250cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int cbFrameBodySize; 2251cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int cbReqCount; 225292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PBEACON_BUFFER pTX_Buffer; 225392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PBYTE pbyTxBufferAddr; 225492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PUSB_SEND_CONTEXT pContext; 225592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond CMD_STATUS status; 225692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 225792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 225892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pContext = (PUSB_SEND_CONTEXT)s_vGetFreeContext(pDevice); 225992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (NULL == pContext) { 226092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond status = CMD_STATUS_RESOURCES; 226192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ManagementSend TX...NO CONTEXT!\n"); 226292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond return status ; 226392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 226492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTX_Buffer = (PBEACON_BUFFER) (&pContext->Data[0]); 226592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pbyTxBufferAddr = (PBYTE)&(pTX_Buffer->wFIFOCtl); 226692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 226792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbFrameBodySize = pPacket->cbPayloadLen; 226892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 226992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTxBufHead = (PSTxShortBufHead) pbyTxBufferAddr; 227092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond wTxBufSize = sizeof(STxShortBufHead); 227192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond memset(pTxBufHead, 0, wTxBufSize); 227292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 227392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pDevice->byBBType == BB_TYPE_11A) { 227492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond wCurrentRate = RATE_6M; 227592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTxDataHead = (PSTxDataHead_ab) (pbyTxBufferAddr + wTxBufSize); 227692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Get SignalField,ServiceField,Length 227792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond BBvCaculateParameter(pDevice, cbFrameSize, wCurrentRate, PK_TYPE_11A, 227892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond (PWORD)&(pTxDataHead->wTransmitLength), (PBYTE)&(pTxDataHead->byServiceField), (PBYTE)&(pTxDataHead->bySignalField) 227992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ); 228092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Get Duration and TimeStampOff 228192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTxDataHead->wDuration = cpu_to_le16((WORD)s_uGetDataDuration(pDevice, DATADUR_A, cbFrameSize, PK_TYPE_11A, 228292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond wCurrentRate, FALSE, 0, 0, 1, AUTO_FB_NONE)); 228392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTxDataHead->wTimeStampOff = wTimeStampOff[pDevice->byPreambleType%2][wCurrentRate%MAX_RATE]; 228492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbHeaderSize = wTxBufSize + sizeof(STxDataHead_ab); 228592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else { 228692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond wCurrentRate = RATE_1M; 228792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTxBufHead->wFIFOCtl |= FIFOCTL_11B; 228892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTxDataHead = (PSTxDataHead_ab) (pbyTxBufferAddr + wTxBufSize); 228992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Get SignalField,ServiceField,Length 229092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond BBvCaculateParameter(pDevice, cbFrameSize, wCurrentRate, PK_TYPE_11B, 229192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond (PWORD)&(pTxDataHead->wTransmitLength), (PBYTE)&(pTxDataHead->byServiceField), (PBYTE)&(pTxDataHead->bySignalField) 229292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ); 229392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Get Duration and TimeStampOff 229492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTxDataHead->wDuration = cpu_to_le16((WORD)s_uGetDataDuration(pDevice, DATADUR_B, cbFrameSize, PK_TYPE_11B, 229592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond wCurrentRate, FALSE, 0, 0, 1, AUTO_FB_NONE)); 229692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTxDataHead->wTimeStampOff = wTimeStampOff[pDevice->byPreambleType%2][wCurrentRate%MAX_RATE]; 229792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbHeaderSize = wTxBufSize + sizeof(STxDataHead_ab); 229892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 229992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 230092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Generate Beacon Header 230192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pMACHeader = (PS802_11Header)(pbyTxBufferAddr + cbHeaderSize); 23023e362598fd3c7b8729afd0383a4cdf08849b020eJim Lieb memcpy(pMACHeader, pPacket->p80211Header, pPacket->cbMPDULen); 230392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 230492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pMACHeader->wDurationID = 0; 230592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pMACHeader->wSeqCtl = cpu_to_le16(pDevice->wSeqCounter << 4); 230692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pDevice->wSeqCounter++ ; 230792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pDevice->wSeqCounter > 0x0fff) 230892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pDevice->wSeqCounter = 0; 230992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 231092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbReqCount = cbHeaderSize + WLAN_HDR_ADDR3_LEN + cbFrameBodySize; 231192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 231292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTX_Buffer->wTxByteCount = (WORD)cbReqCount; 231392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTX_Buffer->byPKTNO = (BYTE) (((wCurrentRate<<4) &0x00F0) | ((pDevice->wSeqCounter - 1) & 0x000F)); 231492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTX_Buffer->byType = 0x01; 231592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 231692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pContext->pPacket = NULL; 231792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pContext->Type = CONTEXT_MGMT_PACKET; 231892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pContext->uBufLen = (WORD)cbReqCount + 4; //USB header 231992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 232092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PIPEnsSendBulkOut(pDevice,pContext); 232192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond return CMD_STATUS_PENDING; 232292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 232392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond} 232492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 232592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 232692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 232792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 232892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 23298611a29ab967bc197494db19d31994d1b5a26fdcAndres Morevoid 233092b96797118e5836294a6d42a5a8e10b86f50e3fForest BondvDMA0_tx_80211(PSDevice pDevice, struct sk_buff *skb) { 233192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 233292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PSMgmtObject pMgmt = &(pDevice->sMgmtObj); 233392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond BYTE byPktType; 233492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PBYTE pbyTxBufferAddr; 23358611a29ab967bc197494db19d31994d1b5a26fdcAndres More void *pvRTS; 23368611a29ab967bc197494db19d31994d1b5a26fdcAndres More void *pvCTS; 23378611a29ab967bc197494db19d31994d1b5a26fdcAndres More void *pvTxDataHd; 2338cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int uDuration; 2339cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int cbReqCount; 234092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PS802_11Header pMACHeader; 2341cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int cbHeaderSize; 2342cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int cbFrameBodySize; 234392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond BOOL bNeedACK; 234492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond BOOL bIsPSPOLL = FALSE; 234592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PSTxBufHead pTxBufHead; 2346cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int cbFrameSize; 2347cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int cbIVlen = 0; 2348cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int cbICVlen = 0; 2349cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int cbMIClen = 0; 2350cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int cbFCSlen = 4; 2351cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int uPadding = 0; 2352cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int cbMICHDR = 0; 2353cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int uLength = 0; 235492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond DWORD dwMICKey0, dwMICKey1; 235592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond DWORD dwMIC_Priority; 235692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PDWORD pdwMIC_L; 235792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PDWORD pdwMIC_R; 235892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond WORD wTxBufSize; 2359cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int cbMacHdLen; 236092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond SEthernetHeader sEthHeader; 23618611a29ab967bc197494db19d31994d1b5a26fdcAndres More void *pvRrvTime; 23628611a29ab967bc197494db19d31994d1b5a26fdcAndres More void *pMICHDR; 236392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond WORD wCurrentRate = RATE_1M; 236492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PUWLAN_80211HDR p80211Header; 2365cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int uNodeIndex = 0; 236692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond BOOL bNodeExist = FALSE; 236792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond SKeyItem STempKey; 236892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PSKeyItem pTransmitKey = NULL; 236992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PBYTE pbyIVHead; 237092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PBYTE pbyPayloadHead; 237192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PBYTE pbyMacHdr; 2372cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int cbExtSuppRate = 0; 237392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PTX_BUFFER pTX_Buffer; 237492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PUSB_SEND_CONTEXT pContext; 237592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond// PWLAN_IE pItem; 237692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 237792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 237892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pvRrvTime = pMICHDR = pvRTS = pvCTS = pvTxDataHd = NULL; 237992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 238092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if(skb->len <= WLAN_HDR_ADDR3_LEN) { 238192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbFrameBodySize = 0; 238292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 238392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else { 238492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbFrameBodySize = skb->len - WLAN_HDR_ADDR3_LEN; 238592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 238692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond p80211Header = (PUWLAN_80211HDR)skb->data; 238792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 238892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pContext = (PUSB_SEND_CONTEXT)s_vGetFreeContext(pDevice); 238992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 239092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (NULL == pContext) { 239192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"DMA0 TX...NO CONTEXT!\n"); 239292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond dev_kfree_skb_irq(skb); 239392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond return ; 239492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 239592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 239692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTX_Buffer = (PTX_BUFFER)(&pContext->Data[0]); 239792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pbyTxBufferAddr = (PBYTE)(&pTX_Buffer->adwTxKey[0]); 239892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTxBufHead = (PSTxBufHead) pbyTxBufferAddr; 239992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond wTxBufSize = sizeof(STxBufHead); 240092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond memset(pTxBufHead, 0, wTxBufSize); 240192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 240292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pDevice->byBBType == BB_TYPE_11A) { 240392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond wCurrentRate = RATE_6M; 240492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond byPktType = PK_TYPE_11A; 240592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else { 240692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond wCurrentRate = RATE_1M; 240792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond byPktType = PK_TYPE_11B; 240892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 240992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 241092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // SetPower will cause error power TX state for OFDM Date packet in TX buffer. 241192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // 2004.11.11 Kyle -- Using OFDM power to tx MngPkt will decrease the connection capability. 241292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // And cmd timer will wait data pkt TX finish before scanning so it's OK 241392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // to set power here. 241492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pMgmt->eScanState != WMAC_NO_SCANNING) { 241592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond RFbSetPower(pDevice, wCurrentRate, pDevice->byCurrentCh); 241692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else { 241792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond RFbSetPower(pDevice, wCurrentRate, pMgmt->uCurrChannel); 241892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 241992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 242092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"vDMA0_tx_80211: p80211Header->sA3.wFrameCtl = %x \n", p80211Header->sA3.wFrameCtl); 242192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 242292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Set packet type 242392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (byPktType == PK_TYPE_11A) {//0000 0000 0000 0000 242492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTxBufHead->wFIFOCtl = 0; 242592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 242692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else if (byPktType == PK_TYPE_11B) {//0000 0001 0000 0000 242792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTxBufHead->wFIFOCtl |= FIFOCTL_11B; 242892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 242992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else if (byPktType == PK_TYPE_11GB) {//0000 0010 0000 0000 243092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTxBufHead->wFIFOCtl |= FIFOCTL_11GB; 243192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 243292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else if (byPktType == PK_TYPE_11GA) {//0000 0011 0000 0000 243392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTxBufHead->wFIFOCtl |= FIFOCTL_11GA; 243492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 243592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 243692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTxBufHead->wFIFOCtl |= FIFOCTL_TMOEN; 243792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTxBufHead->wTimeStamp = cpu_to_le16(DEFAULT_MGN_LIFETIME_RES_64us); 243892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 243922040bbf84ae5cc39b2b97f064c97592aa425d06Andres More if (is_multicast_ether_addr(p80211Header->sA3.abyAddr1)) { 244092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond bNeedACK = FALSE; 244192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pDevice->bEnableHostWEP) { 244292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uNodeIndex = 0; 244392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond bNodeExist = TRUE; 24449fc86028fa21f8831c0fdc701732cf491da1202cJoe Perches } 244592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 244692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else { 244792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pDevice->bEnableHostWEP) { 244892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (BSSbIsSTAInNodeDB(pDevice, (PBYTE)(p80211Header->sA3.abyAddr1), &uNodeIndex)) 244992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond bNodeExist = TRUE; 24509fc86028fa21f8831c0fdc701732cf491da1202cJoe Perches } 245192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond bNeedACK = TRUE; 245292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTxBufHead->wFIFOCtl |= FIFOCTL_NEEDACK; 245392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond }; 245492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 245592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) || 245692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) ) { 245792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 245892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTxBufHead->wFIFOCtl |= FIFOCTL_LRETRY; 245992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Set Preamble type always long 246092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //pDevice->byPreambleType = PREAMBLE_LONG; 246192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 246292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // probe-response don't retry 246392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //if ((p80211Header->sA4.wFrameCtl & TYPE_SUBTYPE_MASK) == TYPE_MGMT_PROBE_RSP) { 246492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // bNeedACK = FALSE; 246592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // pTxBufHead->wFIFOCtl &= (~FIFOCTL_NEEDACK); 246692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //} 246792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 246892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 246992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTxBufHead->wFIFOCtl |= (FIFOCTL_GENINT | FIFOCTL_ISDMA0); 247092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 247192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if ((p80211Header->sA4.wFrameCtl & TYPE_SUBTYPE_MASK) == TYPE_CTL_PSPOLL) { 247292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond bIsPSPOLL = TRUE; 247392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbMacHdLen = WLAN_HDR_ADDR2_LEN; 247492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else { 247592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbMacHdLen = WLAN_HDR_ADDR3_LEN; 247692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 247792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 247892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // hostapd deamon ext support rate patch 247992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (WLAN_GET_FC_FSTYPE(p80211Header->sA4.wFrameCtl) == WLAN_FSTYPE_ASSOCRESP) { 248092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 248192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates)->len != 0) { 248292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbExtSuppRate += ((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates)->len + WLAN_IEHDR_LEN; 248392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 248492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 248592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates)->len != 0) { 248692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbExtSuppRate += ((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates)->len + WLAN_IEHDR_LEN; 248792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 248892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 248992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (cbExtSuppRate >0) { 249092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbFrameBodySize = WLAN_ASSOCRESP_OFF_SUPP_RATES; 249192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 249292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 249392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 249492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 249592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Set FRAGCTL_MACHDCNT 249692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTxBufHead->wFragCtl |= cpu_to_le16((WORD)cbMacHdLen << 10); 249792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 249892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // Notes: 249992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // Although spec says MMPDU can be fragmented; In most case, 250092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // no one will send a MMPDU under fragmentation. With RTS may occur. 250192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pDevice->bAES = FALSE; //Set FRAGCTL_WEPTYP 250292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 250392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 250492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (WLAN_GET_FC_ISWEP(p80211Header->sA4.wFrameCtl) != 0) { 250592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pDevice->eEncryptionStatus == Ndis802_11Encryption1Enabled) { 250692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbIVlen = 4; 250792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbICVlen = 4; 250892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTxBufHead->wFragCtl |= FRAGCTL_LEGACY; 250992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 251092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else if (pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled) { 251192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbIVlen = 8;//IV+ExtIV 251292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbMIClen = 8; 251392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbICVlen = 4; 251492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTxBufHead->wFragCtl |= FRAGCTL_TKIP; 251592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //We need to get seed here for filling TxKey entry. 251692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //TKIPvMixKey(pTransmitKey->abyKey, pDevice->abyCurrentNetAddr, 251792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // pTransmitKey->wTSC15_0, pTransmitKey->dwTSC47_16, pDevice->abyPRNG); 251892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 251992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else if (pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled) { 252092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbIVlen = 8;//RSN Header 252192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbICVlen = 8;//MIC 252292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbMICHDR = sizeof(SMICHDRHead); 252392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTxBufHead->wFragCtl |= FRAGCTL_AES; 252492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pDevice->bAES = TRUE; 252592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 252692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //MAC Header should be padding 0 to DW alignment. 252792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uPadding = 4 - (cbMacHdLen%4); 252892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uPadding %= 4; 252992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 253092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 253192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbFrameSize = cbMacHdLen + cbFrameBodySize + cbIVlen + cbMIClen + cbICVlen + cbFCSlen + cbExtSuppRate; 253292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 253392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Set FIFOCTL_GrpAckPolicy 253492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pDevice->bGrpAckPolicy == TRUE) {//0000 0100 0000 0000 253592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTxBufHead->wFIFOCtl |= FIFOCTL_GRPACK; 253692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 253792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //the rest of pTxBufHead->wFragCtl:FragTyp will be set later in s_vFillFragParameter() 253892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 253992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 254092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) {//802.11g packet 254192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 254292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pvRrvTime = (PSRrvTime_gCTS) (pbyTxBufferAddr + wTxBufSize); 254392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pMICHDR = (PSMICHDRHead) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_gCTS)); 254492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pvRTS = NULL; 254592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pvCTS = (PSCTS) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_gCTS) + cbMICHDR); 254692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pvTxDataHd = (PSTxDataHead_g) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_gCTS) + cbMICHDR + sizeof(SCTS)); 254792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbHeaderSize = wTxBufSize + sizeof(SRrvTime_gCTS) + cbMICHDR + sizeof(SCTS) + sizeof(STxDataHead_g); 254892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 254992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 255092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else {//802.11a/b packet 255192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 255292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pvRrvTime = (PSRrvTime_ab) (pbyTxBufferAddr + wTxBufSize); 255392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pMICHDR = (PSMICHDRHead) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_ab)); 255492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pvRTS = NULL; 255592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pvCTS = NULL; 255692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pvTxDataHd = (PSTxDataHead_ab) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_ab) + cbMICHDR); 255792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbHeaderSize = wTxBufSize + sizeof(SRrvTime_ab) + cbMICHDR + sizeof(STxDataHead_ab); 255892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 25598611a29ab967bc197494db19d31994d1b5a26fdcAndres More memset((void *)(pbyTxBufferAddr + wTxBufSize), 0, 25608611a29ab967bc197494db19d31994d1b5a26fdcAndres More (cbHeaderSize - wTxBufSize)); 25619a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More memcpy(&(sEthHeader.abyDstAddr[0]), 25629a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More &(p80211Header->sA3.abyAddr1[0]), 25639a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More ETH_ALEN); 25649a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More memcpy(&(sEthHeader.abySrcAddr[0]), 25659a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More &(p80211Header->sA3.abyAddr2[0]), 25669a0e756c5280750c23bd44d2b855a1f5442ea7b4Andres More ETH_ALEN); 256792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //========================= 256892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // No Fragmentation 256992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //========================= 257092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTxBufHead->wFragCtl |= (WORD)FRAGCTL_NONFRAG; 257192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 257292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 257392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Fill FIFO,RrvTime,RTS,and CTS 257492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond s_vGenerateTxParameter(pDevice, byPktType, wCurrentRate, pbyTxBufferAddr, pvRrvTime, pvRTS, pvCTS, 257592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbFrameSize, bNeedACK, TYPE_TXDMA0, &sEthHeader); 257692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 257792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond //Fill DataHead 257892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uDuration = s_uFillDataHead(pDevice, byPktType, wCurrentRate, pvTxDataHd, cbFrameSize, TYPE_TXDMA0, bNeedACK, 257992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 0, 0, 1, AUTO_FB_NONE); 258092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 258192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pMACHeader = (PS802_11Header) (pbyTxBufferAddr + cbHeaderSize); 258292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 258392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond cbReqCount = cbHeaderSize + cbMacHdLen + uPadding + cbIVlen + (cbFrameBodySize + cbMIClen) + cbExtSuppRate; 258492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 258592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pbyMacHdr = (PBYTE)(pbyTxBufferAddr + cbHeaderSize); 258692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pbyPayloadHead = (PBYTE)(pbyMacHdr + cbMacHdLen + uPadding + cbIVlen); 258792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pbyIVHead = (PBYTE)(pbyMacHdr + cbMacHdLen + uPadding); 258892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 258992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // Copy the Packet into a tx Buffer 259092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond memcpy(pbyMacHdr, skb->data, cbMacHdLen); 259192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 259292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // version set to 0, patch for hostapd deamon 259392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pMACHeader->wFrameCtl &= cpu_to_le16(0xfffc); 259492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond memcpy(pbyPayloadHead, (skb->data + cbMacHdLen), cbFrameBodySize); 259592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 259692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // replace support rate, patch for hostapd deamon( only support 11M) 259792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (WLAN_GET_FC_FSTYPE(p80211Header->sA4.wFrameCtl) == WLAN_FSTYPE_ASSOCRESP) { 259892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (cbExtSuppRate != 0) { 259992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates)->len != 0) 260092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond memcpy((pbyPayloadHead + cbFrameBodySize), 260192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pMgmt->abyCurrSuppRates, 260292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates)->len + WLAN_IEHDR_LEN 260392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ); 260492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates)->len != 0) 260592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond memcpy((pbyPayloadHead + cbFrameBodySize) + ((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates)->len + WLAN_IEHDR_LEN, 260692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pMgmt->abyCurrExtSuppRates, 260792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates)->len + WLAN_IEHDR_LEN 260892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ); 260992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 261092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 261192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 261292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // Set wep 261392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (WLAN_GET_FC_ISWEP(p80211Header->sA4.wFrameCtl) != 0) { 261492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 261592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pDevice->bEnableHostWEP) { 261692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTransmitKey = &STempKey; 261792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTransmitKey->byCipherSuite = pMgmt->sNodeDBTable[uNodeIndex].byCipherSuite; 261892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTransmitKey->dwKeyIndex = pMgmt->sNodeDBTable[uNodeIndex].dwKeyIndex; 261992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTransmitKey->uKeyLength = pMgmt->sNodeDBTable[uNodeIndex].uWepKeyLength; 262092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTransmitKey->dwTSC47_16 = pMgmt->sNodeDBTable[uNodeIndex].dwTSC47_16; 262192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTransmitKey->wTSC15_0 = pMgmt->sNodeDBTable[uNodeIndex].wTSC15_0; 262292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond memcpy(pTransmitKey->abyKey, 262392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond &pMgmt->sNodeDBTable[uNodeIndex].abyWepKey[0], 262492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTransmitKey->uKeyLength 262592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ); 262692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 262792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 262892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if ((pTransmitKey != NULL) && (pTransmitKey->byCipherSuite == KEY_CTL_TKIP)) { 262992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 263092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond dwMICKey0 = *(PDWORD)(&pTransmitKey->abyKey[16]); 263192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond dwMICKey1 = *(PDWORD)(&pTransmitKey->abyKey[20]); 263292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 263392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // DO Software Michael 263492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond MIC_vInit(dwMICKey0, dwMICKey1); 263592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond MIC_vAppend((PBYTE)&(sEthHeader.abyDstAddr[0]), 12); 263692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond dwMIC_Priority = 0; 263792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond MIC_vAppend((PBYTE)&dwMIC_Priority, 4); 263892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"DMA0_tx_8021:MIC KEY: %lX, %lX\n", dwMICKey0, dwMICKey1); 263992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 264092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uLength = cbHeaderSize + cbMacHdLen + uPadding + cbIVlen; 264192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 264292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond MIC_vAppend((pbyTxBufferAddr + uLength), cbFrameBodySize); 264392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 264492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pdwMIC_L = (PDWORD)(pbyTxBufferAddr + uLength + cbFrameBodySize); 264592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pdwMIC_R = (PDWORD)(pbyTxBufferAddr + uLength + cbFrameBodySize + 4); 264692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 264792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond MIC_vGetMIC(pdwMIC_L, pdwMIC_R); 264892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond MIC_vUnInit(); 264992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 265092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pDevice->bTxMICFail == TRUE) { 265192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond *pdwMIC_L = 0; 265292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond *pdwMIC_R = 0; 265392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pDevice->bTxMICFail = FALSE; 265492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 265592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 265692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"uLength: %d, %d\n", uLength, cbFrameBodySize); 265792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"cbReqCount:%d, %d, %d, %d\n", cbReqCount, cbHeaderSize, uPadding, cbIVlen); 265892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"MIC:%lx, %lx\n", *pdwMIC_L, *pdwMIC_R); 265992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 266092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 266192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 266292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond s_vFillTxKey(pDevice, (PBYTE)(pTxBufHead->adwTxKey), pbyIVHead, pTransmitKey, 266392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pbyMacHdr, (WORD)cbFrameBodySize, (PBYTE)pMICHDR); 266492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 266592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pDevice->bEnableHostWEP) { 266692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pMgmt->sNodeDBTable[uNodeIndex].dwTSC47_16 = pTransmitKey->dwTSC47_16; 266792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pMgmt->sNodeDBTable[uNodeIndex].wTSC15_0 = pTransmitKey->wTSC15_0; 266892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 266992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 267092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if ((pDevice->byLocalID <= REV_ID_VT3253_A1)) { 267192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond s_vSWencryption(pDevice, pTransmitKey, pbyPayloadHead, (WORD)(cbFrameBodySize + cbMIClen)); 267292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 267392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 267492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 267592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pMACHeader->wSeqCtl = cpu_to_le16(pDevice->wSeqCounter << 4); 267692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pDevice->wSeqCounter++ ; 267792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pDevice->wSeqCounter > 0x0fff) 267892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pDevice->wSeqCounter = 0; 267992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 268092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 268192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (bIsPSPOLL) { 268292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // The MAC will automatically replace the Duration-field of MAC header by Duration-field 268392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // of FIFO control header. 268492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // This will cause AID-field of PS-POLL packet be incorrect (Because PS-POLL's AID field is 268592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // in the same place of other packet's Duration-field). 268692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // And it will cause Cisco-AP to issue Disassociation-packet 268792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) { 268892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ((PSTxDataHead_g)pvTxDataHd)->wDuration_a = cpu_to_le16(p80211Header->sA2.wDurationID); 268992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ((PSTxDataHead_g)pvTxDataHd)->wDuration_b = cpu_to_le16(p80211Header->sA2.wDurationID); 269092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else { 269192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ((PSTxDataHead_ab)pvTxDataHd)->wDuration = cpu_to_le16(p80211Header->sA2.wDurationID); 269292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 269392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 269492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 269592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTX_Buffer->wTxByteCount = cpu_to_le16((WORD)(cbReqCount)); 269692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTX_Buffer->byPKTNO = (BYTE) (((wCurrentRate<<4) &0x00F0) | ((pDevice->wSeqCounter - 1) & 0x000F)); 269792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTX_Buffer->byType = 0x00; 269892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 269992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pContext->pPacket = skb; 270092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pContext->Type = CONTEXT_MGMT_PACKET; 270192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pContext->uBufLen = (WORD)cbReqCount + 4; //USB header 270292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 270392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (WLAN_GET_FC_TODS(pMACHeader->wFrameCtl) == 0) { 270492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond s_vSaveTxPktInfo(pDevice, (BYTE) (pTX_Buffer->byPKTNO & 0x0F), &(pMACHeader->abyAddr1[0]),(WORD)cbFrameSize,pTX_Buffer->wFIFOCtl); 270592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 270692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else { 270792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond s_vSaveTxPktInfo(pDevice, (BYTE) (pTX_Buffer->byPKTNO & 0x0F), &(pMACHeader->abyAddr3[0]),(WORD)cbFrameSize,pTX_Buffer->wFIFOCtl); 270892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 270992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PIPEnsSendBulkOut(pDevice,pContext); 271092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond return ; 271192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 271292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond} 271392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 271492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 271592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 271692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 271792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond//TYPE_AC0DMA data tx 271892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond/* 271992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * Description: 272092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * Tx packet via AC0DMA(DMA1) 272192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * 272292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * Parameters: 272392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * In: 272492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * pDevice - Pointer to the adapter 272592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * skb - Pointer to tx skb packet 272692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * Out: 272792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * void 272892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * 272992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * Return Value: NULL 273092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond */ 273192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 27326487c49e8a739ae6020ccda9470f5837e792ab53Andres Moreint nsDMA_tx_packet(PSDevice pDevice, unsigned int uDMAIdx, struct sk_buff *skb) 273392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond{ 273492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PSMgmtObject pMgmt = &(pDevice->sMgmtObj); 2735cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int BytesToWrite = 0, uHeaderLen = 0; 2736cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int uNodeIndex = 0; 273792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond BYTE byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80}; 273892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond WORD wAID; 273992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond BYTE byPktType; 274092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond BOOL bNeedEncryption = FALSE; 274192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PSKeyItem pTransmitKey = NULL; 274292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond SKeyItem STempKey; 2743cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int ii; 274492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond BOOL bTKIP_UseGTK = FALSE; 274592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond BOOL bNeedDeAuth = FALSE; 274692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PBYTE pbyBSSID; 274792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond BOOL bNodeExist = FALSE; 274892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PUSB_SEND_CONTEXT pContext; 274992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond BOOL fConvertedPacket; 275092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PTX_BUFFER pTX_Buffer; 2751cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int status; 275292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond WORD wKeepRate = pDevice->wCurrentRate; 275392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond struct net_device_stats* pStats = &pDevice->stats; 275492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond BOOL bTxeapol_key = FALSE; 275592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 275692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 275792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) { 275892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 275992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pDevice->uAssocCount == 0) { 276092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond dev_kfree_skb_irq(skb); 276192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond return 0; 276292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 276392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 27644b50fb4042a9e39cd24b411546020d6b56ff519bAndres More if (is_multicast_ether_addr((PBYTE)(skb->data))) { 276592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uNodeIndex = 0; 276692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond bNodeExist = TRUE; 276792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pMgmt->sNodeDBTable[0].bPSEnable) { 276892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 276992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond skb_queue_tail(&(pMgmt->sNodeDBTable[0].sTxPSQueue), skb); 277092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pMgmt->sNodeDBTable[0].wEnQueueCnt++; 277192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // set tx map 277292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pMgmt->abyPSTxMap[0] |= byMask[0]; 277392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond return 0; 277492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 277592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // muticast/broadcast data rate 277692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 277792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pDevice->byBBType != BB_TYPE_11A) 277892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pDevice->wCurrentRate = RATE_2M; 277992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else 278092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pDevice->wCurrentRate = RATE_24M; 278192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // long preamble type 278292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pDevice->byPreambleType = PREAMBLE_SHORT; 278392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 278492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond }else { 278592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 278692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (BSSbIsSTAInNodeDB(pDevice, (PBYTE)(skb->data), &uNodeIndex)) { 278792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 278892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pMgmt->sNodeDBTable[uNodeIndex].bPSEnable) { 278992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 279092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond skb_queue_tail(&pMgmt->sNodeDBTable[uNodeIndex].sTxPSQueue, skb); 279192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 279292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pMgmt->sNodeDBTable[uNodeIndex].wEnQueueCnt++; 279392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // set tx map 279492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond wAID = pMgmt->sNodeDBTable[uNodeIndex].wAID; 279592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pMgmt->abyPSTxMap[wAID >> 3] |= byMask[wAID & 7]; 279692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set:pMgmt->abyPSTxMap[%d]= %d\n", 279792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond (wAID >> 3), pMgmt->abyPSTxMap[wAID >> 3]); 279892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 279992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond return 0; 280092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 280192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // AP rate decided from node 280292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pDevice->wCurrentRate = pMgmt->sNodeDBTable[uNodeIndex].wTxDataRate; 280392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // tx preamble decided from node 280492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 280592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pMgmt->sNodeDBTable[uNodeIndex].bShortPreamble) { 280692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pDevice->byPreambleType = pDevice->byShortPreamble; 280792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 280892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond }else { 280992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pDevice->byPreambleType = PREAMBLE_LONG; 281092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 281192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond bNodeExist = TRUE; 281292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 281392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 281492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 281592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (bNodeExist == FALSE) { 281692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond DBG_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG"Unknown STA not found in node DB \n"); 281792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond dev_kfree_skb_irq(skb); 281892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond return 0; 281992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 282092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 282192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 282292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pContext = (PUSB_SEND_CONTEXT)s_vGetFreeContext(pDevice); 282392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 282492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pContext == NULL) { 282592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond DBG_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG" pContext == NULL\n"); 282692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond dev_kfree_skb_irq(skb); 282792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond return STATUS_RESOURCES; 282892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 282992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 283021ec51f3df9fd3c83ce0a4ac6a18e5083984b8aeCharles Clément memcpy(pDevice->sTxEthHeader.abyDstAddr, (PBYTE)(skb->data), ETH_HLEN); 283192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 283292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond//mike add:station mode check eapol-key challenge---> 283392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond{ 283492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond BYTE Protocol_Version; //802.1x Authentication 283592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond BYTE Packet_Type; //802.1x Authentication 283692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond BYTE Descriptor_type; 283792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond WORD Key_info; 283892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 283921ec51f3df9fd3c83ce0a4ac6a18e5083984b8aeCharles Clément Protocol_Version = skb->data[ETH_HLEN]; 284021ec51f3df9fd3c83ce0a4ac6a18e5083984b8aeCharles Clément Packet_Type = skb->data[ETH_HLEN+1]; 284121ec51f3df9fd3c83ce0a4ac6a18e5083984b8aeCharles Clément Descriptor_type = skb->data[ETH_HLEN+1+1+2]; 284221ec51f3df9fd3c83ce0a4ac6a18e5083984b8aeCharles Clément Key_info = (skb->data[ETH_HLEN+1+1+2+1] << 8)|(skb->data[ETH_HLEN+1+1+2+2]); 2843203e4615ee9d9fa8d3506b9d0ef30095e4d5bc90Andres More if (pDevice->sTxEthHeader.wType == cpu_to_le16(ETH_P_PAE)) { 2844203e4615ee9d9fa8d3506b9d0ef30095e4d5bc90Andres More /* 802.1x OR eapol-key challenge frame transfer */ 2845203e4615ee9d9fa8d3506b9d0ef30095e4d5bc90Andres More if (((Protocol_Version == 1) || (Protocol_Version == 2)) && 2846203e4615ee9d9fa8d3506b9d0ef30095e4d5bc90Andres More (Packet_Type == 3)) { 284792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond bTxeapol_key = TRUE; 284892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if(!(Key_info & BIT3) && //WPA or RSN group-key challenge 284992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond (Key_info & BIT8) && (Key_info & BIT9)) { //send 2/2 key 285092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if(Descriptor_type==254) { 285192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pDevice->fWPA_Authened = TRUE; 285292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PRINT_K("WPA "); 285392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 285492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else { 285592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pDevice->fWPA_Authened = TRUE; 285692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PRINT_K("WPA2(re-keying) "); 285792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 285892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PRINT_K("Authentication completed!!\n"); 285992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 286092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else if((Key_info & BIT3) && (Descriptor_type==2) && //RSN pairse-key challenge 286192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond (Key_info & BIT8) && (Key_info & BIT9)) { 286292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pDevice->fWPA_Authened = TRUE; 286392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PRINT_K("WPA2 Authentication completed!!\n"); 286492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 286592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 286692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 286792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond} 286892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond//mike add:station mode check eapol-key challenge<--- 286992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 287092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pDevice->bEncryptionEnable == TRUE) { 287192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond bNeedEncryption = TRUE; 287292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // get Transmit key 287392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond do { 287492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if ((pMgmt->eCurrMode == WMAC_MODE_ESS_STA) && 287592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond (pMgmt->eCurrState == WMAC_STATE_ASSOC)) { 287692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pbyBSSID = pDevice->abyBSSID; 287792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // get pairwise key 287892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, PAIRWISE_KEY, &pTransmitKey) == FALSE) { 287992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // get group key 288092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if(KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, GROUP_KEY, &pTransmitKey) == TRUE) { 288192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond bTKIP_UseGTK = TRUE; 288292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond DBG_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG"Get GTK.\n"); 288392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond break; 288492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 288592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else { 288692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond DBG_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG"Get PTK.\n"); 288792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond break; 288892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 288992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond }else if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) { 289092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 289192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pbyBSSID = pDevice->sTxEthHeader.abyDstAddr; //TO_DS = 0 and FROM_DS = 0 --> 802.11 MAC Address1 289292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond DBG_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG"IBSS Serach Key: \n"); 289392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond for (ii = 0; ii< 6; ii++) 289492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond DBG_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG"%x \n", *(pbyBSSID+ii)); 289592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond DBG_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG"\n"); 289692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 289792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // get pairwise key 289892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if(KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, PAIRWISE_KEY, &pTransmitKey) == TRUE) 289992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond break; 290092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 290192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // get group key 290292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pbyBSSID = pDevice->abyBroadcastAddr; 290392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if(KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, GROUP_KEY, &pTransmitKey) == FALSE) { 290492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTransmitKey = NULL; 290592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) { 290692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond DBG_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG"IBSS and KEY is NULL. [%d]\n", pMgmt->eCurrMode); 290792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 290892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else 290992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond DBG_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG"NOT IBSS and KEY is NULL. [%d]\n", pMgmt->eCurrMode); 291092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else { 291192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond bTKIP_UseGTK = TRUE; 291292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond DBG_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG"Get GTK.\n"); 291392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 291492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } while(FALSE); 291592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 291692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 291792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pDevice->bEnableHostWEP) { 291892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond DBG_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG"acdma0: STA index %d\n", uNodeIndex); 291992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pDevice->bEncryptionEnable == TRUE) { 292092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTransmitKey = &STempKey; 292192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTransmitKey->byCipherSuite = pMgmt->sNodeDBTable[uNodeIndex].byCipherSuite; 292292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTransmitKey->dwKeyIndex = pMgmt->sNodeDBTable[uNodeIndex].dwKeyIndex; 292392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTransmitKey->uKeyLength = pMgmt->sNodeDBTable[uNodeIndex].uWepKeyLength; 292492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTransmitKey->dwTSC47_16 = pMgmt->sNodeDBTable[uNodeIndex].dwTSC47_16; 292592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTransmitKey->wTSC15_0 = pMgmt->sNodeDBTable[uNodeIndex].wTSC15_0; 292692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond memcpy(pTransmitKey->abyKey, 292792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond &pMgmt->sNodeDBTable[uNodeIndex].abyWepKey[0], 292892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTransmitKey->uKeyLength 292992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ); 293092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 293192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 293292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 293392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond byPktType = (BYTE)pDevice->byPacketType; 293492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 293592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pDevice->bFixRate) { 293692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pDevice->byBBType == BB_TYPE_11B) { 293792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pDevice->uConnectionRate >= RATE_11M) { 293892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pDevice->wCurrentRate = RATE_11M; 293992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else { 294092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pDevice->wCurrentRate = (WORD)pDevice->uConnectionRate; 294192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 294292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else { 294392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if ((pDevice->byBBType == BB_TYPE_11A) && 294492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond (pDevice->uConnectionRate <= RATE_6M)) { 294592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pDevice->wCurrentRate = RATE_6M; 294692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else { 294792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pDevice->uConnectionRate >= RATE_54M) 294892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pDevice->wCurrentRate = RATE_54M; 294992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else 295092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pDevice->wCurrentRate = (WORD)pDevice->uConnectionRate; 295192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 295292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 295392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 295492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else { 295592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pDevice->eOPMode == OP_MODE_ADHOC) { 295692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // Adhoc Tx rate decided from node DB 295722040bbf84ae5cc39b2b97f064c97592aa425d06Andres More if (is_multicast_ether_addr(pDevice->sTxEthHeader.abyDstAddr)) { 295892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // Multicast use highest data rate 295992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pDevice->wCurrentRate = pMgmt->sNodeDBTable[0].wTxDataRate; 296092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // preamble type 296192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pDevice->byPreambleType = pDevice->byShortPreamble; 296292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 296392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else { 296492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if(BSSbIsSTAInNodeDB(pDevice, &(pDevice->sTxEthHeader.abyDstAddr[0]), &uNodeIndex)) { 296592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pDevice->wCurrentRate = pMgmt->sNodeDBTable[uNodeIndex].wTxDataRate; 296692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pMgmt->sNodeDBTable[uNodeIndex].bShortPreamble) { 296792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pDevice->byPreambleType = pDevice->byShortPreamble; 296892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 296992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 297092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else { 297192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pDevice->byPreambleType = PREAMBLE_LONG; 297292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 297392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Found Node Index is [%d] Tx Data Rate:[%d]\n",uNodeIndex, pDevice->wCurrentRate); 297492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 297592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else { 297692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pDevice->byBBType != BB_TYPE_11A) 297792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pDevice->wCurrentRate = RATE_2M; 297892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else 297992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pDevice->wCurrentRate = RATE_24M; // refer to vMgrCreateOwnIBSS()'s 298092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // abyCurrExtSuppRates[] 298192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pDevice->byPreambleType = PREAMBLE_SHORT; 298292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Not Found Node use highest basic Rate.....\n"); 298392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 298492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 298592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 298692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pDevice->eOPMode == OP_MODE_INFRASTRUCTURE) { 298792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // Infra STA rate decided from AP Node, index = 0 298892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pDevice->wCurrentRate = pMgmt->sNodeDBTable[0].wTxDataRate; 298992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 299092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 299192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 2992203e4615ee9d9fa8d3506b9d0ef30095e4d5bc90Andres More if (pDevice->sTxEthHeader.wType == cpu_to_le16(ETH_P_PAE)) { 299392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pDevice->byBBType != BB_TYPE_11A) { 299492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pDevice->wCurrentRate = RATE_1M; 299592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pDevice->byACKRate = RATE_1M; 299692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pDevice->byTopCCKBasicRate = RATE_1M; 299792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pDevice->byTopOFDMBasicRate = RATE_6M; 299892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else { 299992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pDevice->wCurrentRate = RATE_6M; 300092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pDevice->byACKRate = RATE_6M; 300192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pDevice->byTopCCKBasicRate = RATE_1M; 300292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pDevice->byTopOFDMBasicRate = RATE_6M; 300392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 300492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 300592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 30060cbd8d9854284d3ff38d04aaa3ae726fb1c4a958Andres More DBG_PRT(MSG_LEVEL_DEBUG, 30070cbd8d9854284d3ff38d04aaa3ae726fb1c4a958Andres More KERN_INFO "dma_tx: pDevice->wCurrentRate = %d\n", 30080cbd8d9854284d3ff38d04aaa3ae726fb1c4a958Andres More pDevice->wCurrentRate); 300992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 301092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (wKeepRate != pDevice->wCurrentRate) { 30110cbd8d9854284d3ff38d04aaa3ae726fb1c4a958Andres More bScheduleCommand((void *) pDevice, WLAN_CMD_SETPOWER, NULL); 301292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 301392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 301492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pDevice->wCurrentRate <= RATE_11M) { 301592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond byPktType = PK_TYPE_11B; 301692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 301792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 301892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (bNeedEncryption == TRUE) { 301992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ntohs Pkt Type=%04x\n", ntohs(pDevice->sTxEthHeader.wType)); 3020203e4615ee9d9fa8d3506b9d0ef30095e4d5bc90Andres More if ((pDevice->sTxEthHeader.wType) == cpu_to_le16(ETH_P_PAE)) { 3021203e4615ee9d9fa8d3506b9d0ef30095e4d5bc90Andres More bNeedEncryption = FALSE; 302292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Pkt Type=%04x\n", (pDevice->sTxEthHeader.wType)); 302392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if ((pMgmt->eCurrMode == WMAC_MODE_ESS_STA) && (pMgmt->eCurrState == WMAC_STATE_ASSOC)) { 302492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pTransmitKey == NULL) { 302592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Don't Find TX KEY\n"); 302692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 302792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else { 302892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (bTKIP_UseGTK == TRUE) { 302992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"error: KEY is GTK!!~~\n"); 303092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 303192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else { 303292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Find PTK [%lX]\n", pTransmitKey->dwKeyIndex); 303392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond bNeedEncryption = TRUE; 303492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 303592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 303692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 303792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 303892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pDevice->byCntMeasure == 2) { 303992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond bNeedDeAuth = TRUE; 304092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pDevice->s802_11Counter.TKIPCounterMeasuresInvoked++; 304192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 304292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 304392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pDevice->bEnableHostWEP) { 304492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if ((uNodeIndex != 0) && 304592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond (pMgmt->sNodeDBTable[uNodeIndex].dwKeyIndex & PAIRWISE_KEY)) { 304692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Find PTK [%lX]\n", pTransmitKey->dwKeyIndex); 304792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond bNeedEncryption = TRUE; 304892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 304992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 305092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 305192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else { 305292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 305392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pTransmitKey == NULL) { 305492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"return no tx key\n"); 305592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond dev_kfree_skb_irq(skb); 305692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pStats->tx_dropped++; 305792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond return STATUS_FAILURE; 305892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 305992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 306092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 306192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 306292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond fConvertedPacket = s_bPacketToWirelessUsb(pDevice, byPktType, 306392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond (PBYTE)(&pContext->Data[0]), bNeedEncryption, 306492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond skb->len, uDMAIdx, &pDevice->sTxEthHeader, 306592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond (PBYTE)skb->data, pTransmitKey, uNodeIndex, 306692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pDevice->wCurrentRate, 306792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond &uHeaderLen, &BytesToWrite 306892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ); 306992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 307092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (fConvertedPacket == FALSE) { 307192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pContext->bBoolInUse = FALSE; 307292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond dev_kfree_skb_irq(skb); 307392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond return STATUS_FAILURE; 307492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 307592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 307692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if ( pDevice->bEnablePSMode == TRUE ) { 307792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if ( !pDevice->bPSModeTxBurst ) { 30780cbd8d9854284d3ff38d04aaa3ae726fb1c4a958Andres More bScheduleCommand((void *) pDevice, 30790cbd8d9854284d3ff38d04aaa3ae726fb1c4a958Andres More WLAN_CMD_MAC_DISPOWERSAVING, 30800cbd8d9854284d3ff38d04aaa3ae726fb1c4a958Andres More NULL); 308192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pDevice->bPSModeTxBurst = TRUE; 308292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 308392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 308492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 308592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTX_Buffer = (PTX_BUFFER)&(pContext->Data[0]); 308692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTX_Buffer->byPKTNO = (BYTE) (((pDevice->wCurrentRate<<4) &0x00F0) | ((pDevice->wSeqCounter - 1) & 0x000F)); 308792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTX_Buffer->wTxByteCount = (WORD)BytesToWrite; 308892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 308992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pContext->pPacket = skb; 309092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pContext->Type = CONTEXT_DATA_PACKET; 309192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pContext->uBufLen = (WORD)BytesToWrite + 4 ; //USB header 309292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 309392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond s_vSaveTxPktInfo(pDevice, (BYTE) (pTX_Buffer->byPKTNO & 0x0F), &(pContext->sEthHeader.abyDstAddr[0]),(WORD) (BytesToWrite-uHeaderLen),pTX_Buffer->wFIFOCtl); 309492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 309592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond status = PIPEnsSendBulkOut(pDevice,pContext); 309692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 309792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (bNeedDeAuth == TRUE) { 309892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond WORD wReason = WLAN_MGMT_REASON_MIC_FAILURE; 309992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 31000cbd8d9854284d3ff38d04aaa3ae726fb1c4a958Andres More bScheduleCommand((void *) pDevice, WLAN_CMD_DEAUTH, (PBYTE) &wReason); 310192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 310292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 310392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if(status!=STATUS_PENDING) { 310492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pContext->bBoolInUse = FALSE; 310592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond dev_kfree_skb_irq(skb); 310692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond return STATUS_FAILURE; 310792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 310892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else 310992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond return 0; 311092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 311192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond} 311292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 311392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 311492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 311592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond/* 311692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * Description: 311792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * Relay packet send (AC1DMA) from rx dpc. 311892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * 311992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * Parameters: 312092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * In: 312192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * pDevice - Pointer to the adapter 312292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * pPacket - Pointer to rx packet 312392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * cbPacketSize - rx ethernet frame size 312492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * Out: 312592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * TURE, FALSE 312692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * 312792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond * Return Value: Return TRUE if packet is copy to dma1; otherwise FALSE 312892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond */ 312992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 313092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 313192b96797118e5836294a6d42a5a8e10b86f50e3fForest BondBOOL 313292b96797118e5836294a6d42a5a8e10b86f50e3fForest BondbRelayPacketSend ( 3133592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More PSDevice pDevice, 3134592ccfebb3d7ae6d2fa367b97f080790befa3c6cAndres More PBYTE pbySkbData, 3135cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int uDataLen, 3136cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int uNodeIndex 313792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ) 313892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond{ 313992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PSMgmtObject pMgmt = &(pDevice->sMgmtObj); 3140cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int BytesToWrite = 0, uHeaderLen = 0; 314192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond BYTE byPktType = PK_TYPE_11B; 314292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond BOOL bNeedEncryption = FALSE; 314392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond SKeyItem STempKey; 314492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PSKeyItem pTransmitKey = NULL; 314592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PBYTE pbyBSSID; 314692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PUSB_SEND_CONTEXT pContext; 314792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond BYTE byPktTyp; 314892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond BOOL fConvertedPacket; 314992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond PTX_BUFFER pTX_Buffer; 3150cc856e61ee4ffb150ff352e3d6940978a2f819e8Andres More unsigned int status; 315192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond WORD wKeepRate = pDevice->wCurrentRate; 315292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 315392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 315492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 315592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pContext = (PUSB_SEND_CONTEXT)s_vGetFreeContext(pDevice); 315692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 315792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (NULL == pContext) { 315892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond return FALSE; 315992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 316092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 316121ec51f3df9fd3c83ce0a4ac6a18e5083984b8aeCharles Clément memcpy(pDevice->sTxEthHeader.abyDstAddr, (PBYTE)pbySkbData, ETH_HLEN); 316292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 316392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pDevice->bEncryptionEnable == TRUE) { 316492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond bNeedEncryption = TRUE; 316592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // get group key 316692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pbyBSSID = pDevice->abyBroadcastAddr; 316792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if(KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, GROUP_KEY, &pTransmitKey) == FALSE) { 316892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTransmitKey = NULL; 316992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond DBG_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG"KEY is NULL. [%d]\n", pMgmt->eCurrMode); 317092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else { 317192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond DBG_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG"Get GTK.\n"); 317292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 317392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 317492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 317592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pDevice->bEnableHostWEP) { 3176ee93e1971dc2dbc3133962b3d914b18d7c93a681Roel Kluin if (uNodeIndex < MAX_NODE_NUM + 1) { 317792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTransmitKey = &STempKey; 317892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTransmitKey->byCipherSuite = pMgmt->sNodeDBTable[uNodeIndex].byCipherSuite; 317992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTransmitKey->dwKeyIndex = pMgmt->sNodeDBTable[uNodeIndex].dwKeyIndex; 318092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTransmitKey->uKeyLength = pMgmt->sNodeDBTable[uNodeIndex].uWepKeyLength; 318192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTransmitKey->dwTSC47_16 = pMgmt->sNodeDBTable[uNodeIndex].dwTSC47_16; 318292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTransmitKey->wTSC15_0 = pMgmt->sNodeDBTable[uNodeIndex].wTSC15_0; 318392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond memcpy(pTransmitKey->abyKey, 318492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond &pMgmt->sNodeDBTable[uNodeIndex].abyWepKey[0], 318592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTransmitKey->uKeyLength 318692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ); 318792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 318892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 318992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 319092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if ( bNeedEncryption && (pTransmitKey == NULL) ) { 319192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pContext->bBoolInUse = FALSE; 319292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond return FALSE; 319392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 319492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 319592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond byPktTyp = (BYTE)pDevice->byPacketType; 319692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 319792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pDevice->bFixRate) { 319892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pDevice->byBBType == BB_TYPE_11B) { 319992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pDevice->uConnectionRate >= RATE_11M) { 320092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pDevice->wCurrentRate = RATE_11M; 320192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else { 320292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pDevice->wCurrentRate = (WORD)pDevice->uConnectionRate; 320392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 320492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else { 320592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if ((pDevice->byBBType == BB_TYPE_11A) && 320692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond (pDevice->uConnectionRate <= RATE_6M)) { 320792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pDevice->wCurrentRate = RATE_6M; 320892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } else { 320992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pDevice->uConnectionRate >= RATE_54M) 321092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pDevice->wCurrentRate = RATE_54M; 321192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else 321292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pDevice->wCurrentRate = (WORD)pDevice->uConnectionRate; 321392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 321492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 321592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 321692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond else { 321792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pDevice->wCurrentRate = pMgmt->sNodeDBTable[uNodeIndex].wTxDataRate; 321892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 321992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 322092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (wKeepRate != pDevice->wCurrentRate) { 32210cbd8d9854284d3ff38d04aaa3ae726fb1c4a958Andres More bScheduleCommand((void *) pDevice, WLAN_CMD_SETPOWER, NULL); 322292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 322392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 322492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (pDevice->wCurrentRate <= RATE_11M) 322592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond byPktType = PK_TYPE_11B; 322692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 3227abad19d07627a8b67b441452b0450e178416d2d0Andres More BytesToWrite = uDataLen + ETH_FCS_LEN; 3228abad19d07627a8b67b441452b0450e178416d2d0Andres More 322992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // Convert the packet to an usb frame and copy into our buffer 323092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond // and send the irp. 323192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 323292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond fConvertedPacket = s_bPacketToWirelessUsb(pDevice, byPktType, 323392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond (PBYTE)(&pContext->Data[0]), bNeedEncryption, 323492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond uDataLen, TYPE_AC0DMA, &pDevice->sTxEthHeader, 323592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pbySkbData, pTransmitKey, uNodeIndex, 323692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pDevice->wCurrentRate, 323792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond &uHeaderLen, &BytesToWrite 323892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond ); 323992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 324092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond if (fConvertedPacket == FALSE) { 324192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pContext->bBoolInUse = FALSE; 324292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond return FALSE; 324392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond } 324492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 324592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTX_Buffer = (PTX_BUFFER)&(pContext->Data[0]); 324692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTX_Buffer->byPKTNO = (BYTE) (((pDevice->wCurrentRate<<4) &0x00F0) | ((pDevice->wSeqCounter - 1) & 0x000F)); 324792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pTX_Buffer->wTxByteCount = (WORD)BytesToWrite; 324892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 324992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pContext->pPacket = NULL; 325092b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pContext->Type = CONTEXT_DATA_PACKET; 325192b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond pContext->uBufLen = (WORD)BytesToWrite + 4 ; //USB header 325292b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 325392b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond s_vSaveTxPktInfo(pDevice, (BYTE) (pTX_Buffer->byPKTNO & 0x0F), &(pContext->sEthHeader.abyDstAddr[0]),(WORD) (BytesToWrite-uHeaderLen),pTX_Buffer->wFIFOCtl); 325492b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 325592b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond status = PIPEnsSendBulkOut(pDevice,pContext); 325692b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 325792b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond return TRUE; 325892b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond} 325992b96797118e5836294a6d42a5a8e10b86f50e3fForest Bond 3260