Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. |
| 3 | * All rights reserved. |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License along |
| 16 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 | * |
| 19 | * File: rxtx.c |
| 20 | * |
| 21 | * Purpose: handle WMAC/802.3/802.11 rx & tx functions |
| 22 | * |
| 23 | * Author: Lyndon Chen |
| 24 | * |
| 25 | * Date: May 20, 2003 |
| 26 | * |
| 27 | * Functions: |
Gilles Espinasse | f77f13e | 2010-03-29 15:41:47 +0200 | [diff] [blame] | 28 | * s_vGenerateTxParameter - Generate tx dma required parameter. |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 29 | * s_vGenerateMACHeader - Translate 802.3 to 802.11 header |
| 30 | * csBeacon_xmit - beacon tx function |
| 31 | * csMgmt_xmit - management tx function |
| 32 | * s_uGetDataDuration - get tx data required duration |
| 33 | * s_uFillDataHead- fulfill tx data duration header |
Gilles Espinasse | f77f13e | 2010-03-29 15:41:47 +0200 | [diff] [blame] | 34 | * s_uGetRTSCTSDuration- get rtx/cts required duration |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 35 | * s_uGetRTSCTSRsvTime- get rts/cts reserved time |
| 36 | * s_uGetTxRsvTime- get frame reserved time |
| 37 | * s_vFillCTSHead- fulfill CTS ctl header |
Gilles Espinasse | f77f13e | 2010-03-29 15:41:47 +0200 | [diff] [blame] | 38 | * s_vFillFragParameter- Set fragment ctl parameter. |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 39 | * s_vFillRTSHead- fulfill RTS ctl header |
| 40 | * s_vFillTxKey- fulfill tx encrypt key |
| 41 | * s_vSWencryption- Software encrypt header |
| 42 | * vDMA0_tx_80211- tx 802.11 frame via dma0 |
| 43 | * vGenerateFIFOHeader- Generate tx FIFO ctl header |
| 44 | * |
| 45 | * Revision History: |
| 46 | * |
| 47 | */ |
| 48 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 49 | #include "device.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 50 | #include "rxtx.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 51 | #include "tether.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 52 | #include "card.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 53 | #include "bssdb.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 54 | #include "mac.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 55 | #include "michael.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 56 | #include "tkip.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 57 | #include "tcrc.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 58 | #include "wctl.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 59 | #include "hostap.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 60 | #include "rf.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 61 | #include "datarate.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 62 | #include "usbpipe.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 63 | #include "iocmd.h" |
Jim Lieb | 9d26d60 | 2009-08-12 14:54:08 -0700 | [diff] [blame] | 64 | |
Mariano Reingart | 4a499de | 2010-10-29 19:15:26 -0300 | [diff] [blame] | 65 | static int msglevel = MSG_LEVEL_INFO; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 66 | |
Andres More | 3eaca0d | 2013-02-25 20:32:52 -0500 | [diff] [blame] | 67 | const u16 wTimeStampOff[2][MAX_RATE] = { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 68 | {384, 288, 226, 209, 54, 43, 37, 31, 28, 25, 24, 23}, // Long Preamble |
| 69 | {384, 192, 130, 113, 54, 43, 37, 31, 28, 25, 24, 23}, // Short Preamble |
| 70 | }; |
| 71 | |
Andres More | 3eaca0d | 2013-02-25 20:32:52 -0500 | [diff] [blame] | 72 | const u16 wFB_Opt0[2][5] = { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 73 | {RATE_12M, RATE_18M, RATE_24M, RATE_36M, RATE_48M}, // fallback_rate0 |
| 74 | {RATE_12M, RATE_12M, RATE_18M, RATE_24M, RATE_36M}, // fallback_rate1 |
| 75 | }; |
Andres More | 3eaca0d | 2013-02-25 20:32:52 -0500 | [diff] [blame] | 76 | const u16 wFB_Opt1[2][5] = { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 77 | {RATE_12M, RATE_18M, RATE_24M, RATE_24M, RATE_36M}, // fallback_rate0 |
| 78 | {RATE_6M , RATE_6M, RATE_12M, RATE_12M, RATE_18M}, // fallback_rate1 |
| 79 | }; |
| 80 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 81 | #define RTSDUR_BB 0 |
| 82 | #define RTSDUR_BA 1 |
| 83 | #define RTSDUR_AA 2 |
| 84 | #define CTSDUR_BA 3 |
| 85 | #define RTSDUR_BA_F0 4 |
| 86 | #define RTSDUR_AA_F0 5 |
| 87 | #define RTSDUR_BA_F1 6 |
| 88 | #define RTSDUR_AA_F1 7 |
| 89 | #define CTSDUR_BA_F0 8 |
| 90 | #define CTSDUR_BA_F1 9 |
| 91 | #define DATADUR_B 10 |
| 92 | #define DATADUR_A 11 |
| 93 | #define DATADUR_A_F0 12 |
| 94 | #define DATADUR_A_F1 13 |
| 95 | |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 96 | static void s_vSaveTxPktInfo(struct vnt_private *pDevice, u8 byPktNum, |
| 97 | u8 *pbyDestAddr, u16 wPktLength, u16 wFIFOCtl); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 98 | |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 99 | static void *s_vGetFreeContext(struct vnt_private *pDevice); |
| 100 | |
| 101 | static void s_vGenerateTxParameter(struct vnt_private *pDevice, |
| 102 | u8 byPktType, u16 wCurrentRate, void *pTxBufHead, void *pvRrvTime, |
| 103 | void *pvRTS, void *pvCTS, u32 cbFrameSize, int bNeedACK, u32 uDMAIdx, |
Andres More | ceb8c5d | 2013-03-18 20:33:49 -0500 | [diff] [blame] | 104 | struct ethhdr *psEthHeader); |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 105 | |
| 106 | static u32 s_uFillDataHead(struct vnt_private *pDevice, |
| 107 | u8 byPktType, u16 wCurrentRate, void *pTxDataHead, u32 cbFrameLength, |
Malcolm Priestley | ab01fed | 2013-08-07 21:31:48 +0100 | [diff] [blame] | 108 | u32 uDMAIdx, int bNeedAck, u8 byFBOption); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 109 | |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 110 | static void s_vGenerateMACHeader(struct vnt_private *pDevice, |
Andres More | ceb8c5d | 2013-03-18 20:33:49 -0500 | [diff] [blame] | 111 | u8 *pbyBufferAddr, u16 wDuration, struct ethhdr *psEthHeader, |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 112 | int bNeedEncrypt, u16 wFragType, u32 uDMAIdx, u32 uFragIdx); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 113 | |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 114 | static void s_vFillTxKey(struct vnt_private *pDevice, u8 *pbyBuf, |
| 115 | u8 *pbyIVHead, PSKeyItem pTransmitKey, u8 *pbyHdrBuf, u16 wPayloadLen, |
Malcolm Priestley | ec37d8b | 2013-08-23 14:37:48 +0100 | [diff] [blame] | 116 | struct vnt_mic_hdr *mic_hdr); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 117 | |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 118 | static void s_vSWencryption(struct vnt_private *pDevice, |
| 119 | PSKeyItem pTransmitKey, u8 *pbyPayloadHead, u16 wPayloadSize); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 120 | |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 121 | static unsigned int s_uGetTxRsvTime(struct vnt_private *pDevice, u8 byPktType, |
| 122 | u32 cbFrameLength, u16 wRate, int bNeedAck); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 123 | |
Malcolm Priestley | cfabe4b | 2013-08-22 21:03:40 +0100 | [diff] [blame] | 124 | static u16 s_uGetRTSCTSRsvTime(struct vnt_private *pDevice, u8 byRTSRsvType, |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 125 | u8 byPktType, u32 cbFrameLength, u16 wCurrentRate); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 126 | |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 127 | static void s_vFillCTSHead(struct vnt_private *pDevice, u32 uDMAIdx, |
| 128 | u8 byPktType, void *pvCTS, u32 cbFrameLength, int bNeedAck, |
Malcolm Priestley | 09bd0f3 | 2013-08-24 12:56:11 +0100 | [diff] [blame] | 129 | u16 wCurrentRate, u8 byFBOption); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 130 | |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 131 | static void s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType, |
Malcolm Priestley | fedbfe7 | 2013-08-24 12:50:50 +0100 | [diff] [blame] | 132 | void *pvRTS, u32 cbFrameLength, int bNeedAck, |
Andres More | ceb8c5d | 2013-03-18 20:33:49 -0500 | [diff] [blame] | 133 | struct ethhdr *psEthHeader, u16 wCurrentRate, u8 byFBOption); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 134 | |
Malcolm Priestley | 6b5ad9d | 2013-08-21 22:16:04 +0100 | [diff] [blame] | 135 | static u16 s_uGetDataDuration(struct vnt_private *pDevice, |
Malcolm Priestley | 3ed210e | 2013-08-07 21:28:45 +0100 | [diff] [blame] | 136 | u8 byPktType, int bNeedAck); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 137 | |
Malcolm Priestley | e34f9db | 2013-08-13 20:17:11 +0100 | [diff] [blame] | 138 | static u16 s_uGetRTSCTSDuration(struct vnt_private *pDevice, |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 139 | u8 byDurType, u32 cbFrameLength, u8 byPktType, u16 wRate, |
| 140 | int bNeedAck, u8 byFBOption); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 141 | |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 142 | static void *s_vGetFreeContext(struct vnt_private *pDevice) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 143 | { |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 144 | PUSB_SEND_CONTEXT pContext = NULL; |
| 145 | PUSB_SEND_CONTEXT pReturnContext = NULL; |
| 146 | int ii; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 147 | |
| 148 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"GetFreeContext()\n"); |
| 149 | |
| 150 | for (ii = 0; ii < pDevice->cbTD; ii++) { |
| 151 | pContext = pDevice->apTD[ii]; |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 152 | if (pContext->bBoolInUse == false) { |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 153 | pContext->bBoolInUse = true; |
Malcolm Priestley | c0de17e | 2013-08-05 21:09:14 +0100 | [diff] [blame] | 154 | memset(pContext->Data, 0, MAX_TOTAL_SIZE_WITH_ALL_HEADERS); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 155 | pReturnContext = pContext; |
| 156 | break; |
| 157 | } |
| 158 | } |
| 159 | if ( ii == pDevice->cbTD ) { |
| 160 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"No Free Tx Context\n"); |
| 161 | } |
Andres More | 8611a29 | 2010-05-01 14:25:00 -0300 | [diff] [blame] | 162 | return (void *) pReturnContext; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 163 | } |
| 164 | |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 165 | static void s_vSaveTxPktInfo(struct vnt_private *pDevice, u8 byPktNum, |
| 166 | u8 *pbyDestAddr, u16 wPktLength, u16 wFIFOCtl) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 167 | { |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 168 | PSStatCounter pStatistic = &pDevice->scStatistic; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 169 | |
Andres More | 4b50fb4 | 2010-06-22 21:57:42 -0300 | [diff] [blame] | 170 | if (is_broadcast_ether_addr(pbyDestAddr)) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 171 | pStatistic->abyTxPktInfo[byPktNum].byBroadMultiUni = TX_PKT_BROAD; |
Andres More | 4b50fb4 | 2010-06-22 21:57:42 -0300 | [diff] [blame] | 172 | else if (is_multicast_ether_addr(pbyDestAddr)) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 173 | pStatistic->abyTxPktInfo[byPktNum].byBroadMultiUni = TX_PKT_MULTI; |
| 174 | else |
| 175 | pStatistic->abyTxPktInfo[byPktNum].byBroadMultiUni = TX_PKT_UNI; |
| 176 | |
| 177 | pStatistic->abyTxPktInfo[byPktNum].wLength = wPktLength; |
| 178 | pStatistic->abyTxPktInfo[byPktNum].wFIFOCtl = wFIFOCtl; |
Andres More | 9a0e756 | 2010-04-13 21:54:48 -0300 | [diff] [blame] | 179 | memcpy(pStatistic->abyTxPktInfo[byPktNum].abyDestAddr, |
| 180 | pbyDestAddr, |
| 181 | ETH_ALEN); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 182 | } |
| 183 | |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 184 | static void s_vFillTxKey(struct vnt_private *pDevice, u8 *pbyBuf, |
| 185 | u8 *pbyIVHead, PSKeyItem pTransmitKey, u8 *pbyHdrBuf, |
Malcolm Priestley | ec37d8b | 2013-08-23 14:37:48 +0100 | [diff] [blame] | 186 | u16 wPayloadLen, struct vnt_mic_hdr *mic_hdr) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 187 | { |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 188 | u32 *pdwIV = (u32 *)pbyIVHead; |
| 189 | u32 *pdwExtIV = (u32 *)((u8 *)pbyIVHead + 4); |
Andres More | 1cac4a4 | 2013-03-18 20:33:50 -0500 | [diff] [blame] | 190 | struct ieee80211_hdr *pMACHeader = (struct ieee80211_hdr *)pbyHdrBuf; |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 191 | u32 dwRevIVCounter; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 192 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 193 | //Fill TXKEY |
| 194 | if (pTransmitKey == NULL) |
| 195 | return; |
| 196 | |
| 197 | dwRevIVCounter = cpu_to_le32(pDevice->dwIVCounter); |
| 198 | *pdwIV = pDevice->dwIVCounter; |
| 199 | pDevice->byKeyIndex = pTransmitKey->dwKeyIndex & 0xf; |
| 200 | |
| 201 | if (pTransmitKey->byCipherSuite == KEY_CTL_WEP) { |
| 202 | if (pTransmitKey->uKeyLength == WLAN_WEP232_KEYLEN ){ |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 203 | memcpy(pDevice->abyPRNG, (u8 *)&(dwRevIVCounter), 3); |
Jim Lieb | 3e36259 | 2009-08-12 14:54:11 -0700 | [diff] [blame] | 204 | memcpy(pDevice->abyPRNG+3, pTransmitKey->abyKey, pTransmitKey->uKeyLength); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 205 | } else { |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 206 | memcpy(pbyBuf, (u8 *)&(dwRevIVCounter), 3); |
Jim Lieb | 3e36259 | 2009-08-12 14:54:11 -0700 | [diff] [blame] | 207 | memcpy(pbyBuf+3, pTransmitKey->abyKey, pTransmitKey->uKeyLength); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 208 | if(pTransmitKey->uKeyLength == WLAN_WEP40_KEYLEN) { |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 209 | memcpy(pbyBuf+8, (u8 *)&(dwRevIVCounter), 3); |
Jim Lieb | 3e36259 | 2009-08-12 14:54:11 -0700 | [diff] [blame] | 210 | memcpy(pbyBuf+11, pTransmitKey->abyKey, pTransmitKey->uKeyLength); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 211 | } |
Jim Lieb | 3e36259 | 2009-08-12 14:54:11 -0700 | [diff] [blame] | 212 | memcpy(pDevice->abyPRNG, pbyBuf, 16); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 213 | } |
| 214 | // Append IV after Mac Header |
| 215 | *pdwIV &= WEP_IV_MASK;//00000000 11111111 11111111 11111111 |
Malcolm Priestley | d5bbef7 | 2012-11-11 15:53:14 +0000 | [diff] [blame] | 216 | *pdwIV |= (u32)pDevice->byKeyIndex << 30; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 217 | *pdwIV = cpu_to_le32(*pdwIV); |
| 218 | pDevice->dwIVCounter++; |
| 219 | if (pDevice->dwIVCounter > WEP_IV_MASK) { |
| 220 | pDevice->dwIVCounter = 0; |
| 221 | } |
| 222 | } else if (pTransmitKey->byCipherSuite == KEY_CTL_TKIP) { |
| 223 | pTransmitKey->wTSC15_0++; |
| 224 | if (pTransmitKey->wTSC15_0 == 0) { |
| 225 | pTransmitKey->dwTSC47_16++; |
| 226 | } |
| 227 | TKIPvMixKey(pTransmitKey->abyKey, pDevice->abyCurrentNetAddr, |
| 228 | pTransmitKey->wTSC15_0, pTransmitKey->dwTSC47_16, pDevice->abyPRNG); |
Jim Lieb | 3e36259 | 2009-08-12 14:54:11 -0700 | [diff] [blame] | 229 | memcpy(pbyBuf, pDevice->abyPRNG, 16); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 230 | // Make IV |
Jim Lieb | 3e36259 | 2009-08-12 14:54:11 -0700 | [diff] [blame] | 231 | memcpy(pdwIV, pDevice->abyPRNG, 3); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 232 | |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 233 | *(pbyIVHead+3) = (u8)(((pDevice->byKeyIndex << 6) & 0xc0) | 0x20); // 0x20 is ExtIV |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 234 | // Append IV&ExtIV after Mac Header |
| 235 | *pdwExtIV = cpu_to_le32(pTransmitKey->dwTSC47_16); |
Malcolm Priestley | b4dc03a | 2012-11-11 15:45:52 +0000 | [diff] [blame] | 236 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"vFillTxKey()---- pdwExtIV: %x\n", |
| 237 | *pdwExtIV); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 238 | |
| 239 | } else if (pTransmitKey->byCipherSuite == KEY_CTL_CCMP) { |
| 240 | pTransmitKey->wTSC15_0++; |
| 241 | if (pTransmitKey->wTSC15_0 == 0) { |
| 242 | pTransmitKey->dwTSC47_16++; |
| 243 | } |
Jim Lieb | 3e36259 | 2009-08-12 14:54:11 -0700 | [diff] [blame] | 244 | memcpy(pbyBuf, pTransmitKey->abyKey, 16); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 245 | |
| 246 | // Make IV |
| 247 | *pdwIV = 0; |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 248 | *(pbyIVHead+3) = (u8)(((pDevice->byKeyIndex << 6) & 0xc0) | 0x20); // 0x20 is ExtIV |
Andres More | 3eaca0d | 2013-02-25 20:32:52 -0500 | [diff] [blame] | 249 | *pdwIV |= cpu_to_le16((u16)(pTransmitKey->wTSC15_0)); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 250 | //Append IV&ExtIV after Mac Header |
| 251 | *pdwExtIV = cpu_to_le32(pTransmitKey->dwTSC47_16); |
| 252 | |
Malcolm Priestley | ec37d8b | 2013-08-23 14:37:48 +0100 | [diff] [blame] | 253 | if (!mic_hdr) |
| 254 | return; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 255 | |
Malcolm Priestley | ec37d8b | 2013-08-23 14:37:48 +0100 | [diff] [blame] | 256 | /* MICHDR0 */ |
| 257 | mic_hdr->id = 0x59; |
| 258 | mic_hdr->payload_len = cpu_to_be16(wPayloadLen); |
| 259 | memcpy(mic_hdr->mic_addr2, pMACHeader->addr2, ETH_ALEN); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 260 | |
Malcolm Priestley | ec37d8b | 2013-08-23 14:37:48 +0100 | [diff] [blame] | 261 | mic_hdr->tsc_47_16 = cpu_to_be32(pTransmitKey->dwTSC47_16); |
| 262 | mic_hdr->tsc_15_0 = cpu_to_be16(pTransmitKey->wTSC15_0); |
| 263 | |
| 264 | /* MICHDR1 */ |
| 265 | if (pDevice->bLongHeader) |
| 266 | mic_hdr->hlen = cpu_to_be16(28); |
| 267 | else |
| 268 | mic_hdr->hlen = cpu_to_be16(22); |
| 269 | |
| 270 | memcpy(mic_hdr->addr1, pMACHeader->addr1, ETH_ALEN); |
| 271 | memcpy(mic_hdr->addr2, pMACHeader->addr2, ETH_ALEN); |
| 272 | |
| 273 | /* MICHDR2 */ |
| 274 | memcpy(mic_hdr->addr3, pMACHeader->addr3, ETH_ALEN); |
| 275 | mic_hdr->frame_control = cpu_to_le16(pMACHeader->frame_control |
| 276 | & 0xc78f); |
| 277 | mic_hdr->seq_ctrl = cpu_to_le16(pMACHeader->seq_ctrl & 0xf); |
| 278 | |
| 279 | if (pDevice->bLongHeader) |
| 280 | memcpy(mic_hdr->addr4, pMACHeader->addr4, ETH_ALEN); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 281 | } |
| 282 | } |
| 283 | |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 284 | static void s_vSWencryption(struct vnt_private *pDevice, |
| 285 | PSKeyItem pTransmitKey, u8 *pbyPayloadHead, u16 wPayloadSize) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 286 | { |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 287 | u32 cbICVlen = 4; |
| 288 | u32 dwICV = 0xffffffff; |
| 289 | u32 *pdwICV; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 290 | |
| 291 | if (pTransmitKey == NULL) |
| 292 | return; |
| 293 | |
| 294 | if (pTransmitKey->byCipherSuite == KEY_CTL_WEP) { |
| 295 | //======================================================================= |
| 296 | // Append ICV after payload |
| 297 | dwICV = CRCdwGetCrc32Ex(pbyPayloadHead, wPayloadSize, dwICV);//ICV(Payload) |
Andres More | 52a7e64 | 2013-02-25 20:32:53 -0500 | [diff] [blame] | 298 | pdwICV = (u32 *)(pbyPayloadHead + wPayloadSize); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 299 | // finally, we must invert dwCRC to get the correct answer |
| 300 | *pdwICV = cpu_to_le32(~dwICV); |
| 301 | // RC4 encryption |
| 302 | rc4_init(&pDevice->SBox, pDevice->abyPRNG, pTransmitKey->uKeyLength + 3); |
| 303 | rc4_encrypt(&pDevice->SBox, pbyPayloadHead, pbyPayloadHead, wPayloadSize+cbICVlen); |
| 304 | //======================================================================= |
| 305 | } else if (pTransmitKey->byCipherSuite == KEY_CTL_TKIP) { |
| 306 | //======================================================================= |
| 307 | //Append ICV after payload |
| 308 | dwICV = CRCdwGetCrc32Ex(pbyPayloadHead, wPayloadSize, dwICV);//ICV(Payload) |
Andres More | 52a7e64 | 2013-02-25 20:32:53 -0500 | [diff] [blame] | 309 | pdwICV = (u32 *)(pbyPayloadHead + wPayloadSize); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 310 | // finally, we must invert dwCRC to get the correct answer |
| 311 | *pdwICV = cpu_to_le32(~dwICV); |
| 312 | // RC4 encryption |
| 313 | rc4_init(&pDevice->SBox, pDevice->abyPRNG, TKIP_KEY_LEN); |
| 314 | rc4_encrypt(&pDevice->SBox, pbyPayloadHead, pbyPayloadHead, wPayloadSize+cbICVlen); |
| 315 | //======================================================================= |
| 316 | } |
| 317 | } |
| 318 | |
Malcolm Priestley | f115e76 | 2013-08-23 11:48:46 +0100 | [diff] [blame] | 319 | static u16 vnt_time_stamp_off(struct vnt_private *priv, u16 rate) |
| 320 | { |
| 321 | return cpu_to_le16(wTimeStampOff[priv->byPreambleType % 2] |
| 322 | [rate % MAX_RATE]); |
| 323 | } |
| 324 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 325 | /*byPktType : PK_TYPE_11A 0 |
| 326 | PK_TYPE_11B 1 |
| 327 | PK_TYPE_11GB 2 |
| 328 | PK_TYPE_11GA 3 |
| 329 | */ |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 330 | static u32 s_uGetTxRsvTime(struct vnt_private *pDevice, u8 byPktType, |
| 331 | u32 cbFrameLength, u16 wRate, int bNeedAck) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 332 | { |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 333 | u32 uDataTime, uAckTime; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 334 | |
| 335 | uDataTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, cbFrameLength, wRate); |
| 336 | if (byPktType == PK_TYPE_11B) {//llb,CCK mode |
Andres More | 3eaca0d | 2013-02-25 20:32:52 -0500 | [diff] [blame] | 337 | uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, (u16)pDevice->byTopCCKBasicRate); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 338 | } else {//11g 2.4G OFDM mode & 11a 5G OFDM mode |
Andres More | 3eaca0d | 2013-02-25 20:32:52 -0500 | [diff] [blame] | 339 | uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, (u16)pDevice->byTopOFDMBasicRate); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 340 | } |
| 341 | |
| 342 | if (bNeedAck) { |
| 343 | return (uDataTime + pDevice->uSIFS + uAckTime); |
| 344 | } |
| 345 | else { |
| 346 | return uDataTime; |
| 347 | } |
| 348 | } |
| 349 | |
Malcolm Priestley | 9c3806d | 2013-08-23 11:32:26 +0100 | [diff] [blame] | 350 | static u16 vnt_rxtx_rsvtime_le16(struct vnt_private *priv, u8 pkt_type, |
| 351 | u32 frame_length, u16 rate, int need_ack) |
| 352 | { |
| 353 | return cpu_to_le16((u16)s_uGetTxRsvTime(priv, pkt_type, |
| 354 | frame_length, rate, need_ack)); |
| 355 | } |
| 356 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 357 | //byFreqType: 0=>5GHZ 1=>2.4GHZ |
Malcolm Priestley | cfabe4b | 2013-08-22 21:03:40 +0100 | [diff] [blame] | 358 | static u16 s_uGetRTSCTSRsvTime(struct vnt_private *pDevice, |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 359 | u8 byRTSRsvType, u8 byPktType, u32 cbFrameLength, u16 wCurrentRate) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 360 | { |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 361 | u32 uRrvTime, uRTSTime, uCTSTime, uAckTime, uDataTime; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 362 | |
| 363 | uRrvTime = uRTSTime = uCTSTime = uAckTime = uDataTime = 0; |
| 364 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 365 | uDataTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, cbFrameLength, wCurrentRate); |
| 366 | if (byRTSRsvType == 0) { //RTSTxRrvTime_bb |
| 367 | uRTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 20, pDevice->byTopCCKBasicRate); |
| 368 | uCTSTime = uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopCCKBasicRate); |
| 369 | } |
| 370 | else if (byRTSRsvType == 1){ //RTSTxRrvTime_ba, only in 2.4GHZ |
| 371 | uRTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 20, pDevice->byTopCCKBasicRate); |
| 372 | uCTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopCCKBasicRate); |
| 373 | uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate); |
| 374 | } |
| 375 | else if (byRTSRsvType == 2) { //RTSTxRrvTime_aa |
| 376 | uRTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 20, pDevice->byTopOFDMBasicRate); |
| 377 | uCTSTime = uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate); |
| 378 | } |
| 379 | else if (byRTSRsvType == 3) { //CTSTxRrvTime_ba, only in 2.4GHZ |
| 380 | uCTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopCCKBasicRate); |
| 381 | uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate); |
| 382 | uRrvTime = uCTSTime + uAckTime + uDataTime + 2*pDevice->uSIFS; |
| 383 | return uRrvTime; |
| 384 | } |
| 385 | |
| 386 | //RTSRrvTime |
| 387 | uRrvTime = uRTSTime + uCTSTime + uAckTime + uDataTime + 3*pDevice->uSIFS; |
Malcolm Priestley | cfabe4b | 2013-08-22 21:03:40 +0100 | [diff] [blame] | 388 | return cpu_to_le16((u16)uRrvTime); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 389 | } |
| 390 | |
| 391 | //byFreqType 0: 5GHz, 1:2.4Ghz |
Malcolm Priestley | 6b5ad9d | 2013-08-21 22:16:04 +0100 | [diff] [blame] | 392 | static u16 s_uGetDataDuration(struct vnt_private *pDevice, |
| 393 | u8 byPktType, int bNeedAck) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 394 | { |
Malcolm Priestley | 0005cb0 | 2013-08-07 21:26:12 +0100 | [diff] [blame] | 395 | u32 uAckTime = 0; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 396 | |
Malcolm Priestley | b02ccd5 | 2013-08-13 19:59:31 +0100 | [diff] [blame] | 397 | if (bNeedAck) { |
Malcolm Priestley | 6b5ad9d | 2013-08-21 22:16:04 +0100 | [diff] [blame] | 398 | if (byPktType == PK_TYPE_11B) |
Malcolm Priestley | b02ccd5 | 2013-08-13 19:59:31 +0100 | [diff] [blame] | 399 | uAckTime = BBuGetFrameTime(pDevice->byPreambleType, |
| 400 | byPktType, 14, pDevice->byTopCCKBasicRate); |
| 401 | else |
| 402 | uAckTime = BBuGetFrameTime(pDevice->byPreambleType, |
| 403 | byPktType, 14, pDevice->byTopOFDMBasicRate); |
Malcolm Priestley | d500595 | 2013-08-21 21:58:37 +0100 | [diff] [blame] | 404 | return cpu_to_le16((u16)(pDevice->uSIFS + uAckTime)); |
Malcolm Priestley | b02ccd5 | 2013-08-13 19:59:31 +0100 | [diff] [blame] | 405 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 406 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 407 | return 0; |
| 408 | } |
| 409 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 410 | //byFreqType: 0=>5GHZ 1=>2.4GHZ |
Malcolm Priestley | e34f9db | 2013-08-13 20:17:11 +0100 | [diff] [blame] | 411 | static u16 s_uGetRTSCTSDuration(struct vnt_private *pDevice, u8 byDurType, |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 412 | u32 cbFrameLength, u8 byPktType, u16 wRate, int bNeedAck, |
| 413 | u8 byFBOption) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 414 | { |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 415 | u32 uCTSTime = 0, uDurTime = 0; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 416 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 417 | switch (byDurType) { |
| 418 | |
| 419 | case RTSDUR_BB: //RTSDuration_bb |
| 420 | uCTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopCCKBasicRate); |
| 421 | uDurTime = uCTSTime + 2*pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wRate, bNeedAck); |
| 422 | break; |
| 423 | |
| 424 | case RTSDUR_BA: //RTSDuration_ba |
| 425 | uCTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopCCKBasicRate); |
| 426 | uDurTime = uCTSTime + 2*pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wRate, bNeedAck); |
| 427 | break; |
| 428 | |
| 429 | case RTSDUR_AA: //RTSDuration_aa |
| 430 | uCTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate); |
| 431 | uDurTime = uCTSTime + 2*pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wRate, bNeedAck); |
| 432 | break; |
| 433 | |
| 434 | case CTSDUR_BA: //CTSDuration_ba |
| 435 | uDurTime = pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wRate, bNeedAck); |
| 436 | break; |
| 437 | |
| 438 | case RTSDUR_BA_F0: //RTSDuration_ba_f0 |
| 439 | uCTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopCCKBasicRate); |
| 440 | if ((byFBOption == AUTO_FB_0) && (wRate >= RATE_18M) && (wRate <=RATE_54M)) { |
| 441 | uDurTime = uCTSTime + 2*pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt0[FB_RATE0][wRate-RATE_18M], bNeedAck); |
| 442 | } else if ((byFBOption == AUTO_FB_1) && (wRate >= RATE_18M) && (wRate <=RATE_54M)) { |
| 443 | uDurTime = uCTSTime + 2*pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt1[FB_RATE0][wRate-RATE_18M], bNeedAck); |
| 444 | } |
| 445 | break; |
| 446 | |
| 447 | case RTSDUR_AA_F0: //RTSDuration_aa_f0 |
| 448 | uCTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate); |
| 449 | if ((byFBOption == AUTO_FB_0) && (wRate >= RATE_18M) && (wRate <=RATE_54M)) { |
| 450 | uDurTime = uCTSTime + 2*pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt0[FB_RATE0][wRate-RATE_18M], bNeedAck); |
| 451 | } else if ((byFBOption == AUTO_FB_1) && (wRate >= RATE_18M) && (wRate <=RATE_54M)) { |
| 452 | uDurTime = uCTSTime + 2*pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt1[FB_RATE0][wRate-RATE_18M], bNeedAck); |
| 453 | } |
| 454 | break; |
| 455 | |
| 456 | case RTSDUR_BA_F1: //RTSDuration_ba_f1 |
| 457 | uCTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopCCKBasicRate); |
| 458 | if ((byFBOption == AUTO_FB_0) && (wRate >= RATE_18M) && (wRate <=RATE_54M)) { |
| 459 | uDurTime = uCTSTime + 2*pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt0[FB_RATE1][wRate-RATE_18M], bNeedAck); |
| 460 | } else if ((byFBOption == AUTO_FB_1) && (wRate >= RATE_18M) && (wRate <=RATE_54M)) { |
| 461 | uDurTime = uCTSTime + 2*pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt1[FB_RATE1][wRate-RATE_18M], bNeedAck); |
| 462 | } |
| 463 | break; |
| 464 | |
| 465 | case RTSDUR_AA_F1: //RTSDuration_aa_f1 |
| 466 | uCTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate); |
| 467 | if ((byFBOption == AUTO_FB_0) && (wRate >= RATE_18M) && (wRate <=RATE_54M)) { |
| 468 | uDurTime = uCTSTime + 2*pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt0[FB_RATE1][wRate-RATE_18M], bNeedAck); |
| 469 | } else if ((byFBOption == AUTO_FB_1) && (wRate >= RATE_18M) && (wRate <=RATE_54M)) { |
| 470 | uDurTime = uCTSTime + 2*pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt1[FB_RATE1][wRate-RATE_18M], bNeedAck); |
| 471 | } |
| 472 | break; |
| 473 | |
| 474 | case CTSDUR_BA_F0: //CTSDuration_ba_f0 |
| 475 | if ((byFBOption == AUTO_FB_0) && (wRate >= RATE_18M) && (wRate <=RATE_54M)) { |
| 476 | uDurTime = pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt0[FB_RATE0][wRate-RATE_18M], bNeedAck); |
| 477 | } else if ((byFBOption == AUTO_FB_1) && (wRate >= RATE_18M) && (wRate <=RATE_54M)) { |
| 478 | uDurTime = pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt1[FB_RATE0][wRate-RATE_18M], bNeedAck); |
| 479 | } |
| 480 | break; |
| 481 | |
| 482 | case CTSDUR_BA_F1: //CTSDuration_ba_f1 |
| 483 | if ((byFBOption == AUTO_FB_0) && (wRate >= RATE_18M) && (wRate <=RATE_54M)) { |
| 484 | uDurTime = pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt0[FB_RATE1][wRate-RATE_18M], bNeedAck); |
| 485 | } else if ((byFBOption == AUTO_FB_1) && (wRate >= RATE_18M) && (wRate <=RATE_54M)) { |
| 486 | uDurTime = pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt1[FB_RATE1][wRate-RATE_18M], bNeedAck); |
| 487 | } |
| 488 | break; |
| 489 | |
| 490 | default: |
| 491 | break; |
| 492 | } |
| 493 | |
Malcolm Priestley | e34f9db | 2013-08-13 20:17:11 +0100 | [diff] [blame] | 494 | return cpu_to_le16((u16)uDurTime); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 495 | } |
| 496 | |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 497 | static u32 s_uFillDataHead(struct vnt_private *pDevice, |
| 498 | u8 byPktType, u16 wCurrentRate, void *pTxDataHead, u32 cbFrameLength, |
Malcolm Priestley | ab01fed | 2013-08-07 21:31:48 +0100 | [diff] [blame] | 499 | u32 uDMAIdx, int bNeedAck, u8 byFBOption) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 500 | { |
| 501 | |
| 502 | if (pTxDataHead == NULL) { |
| 503 | return 0; |
| 504 | } |
| 505 | |
| 506 | if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 507 | if (byFBOption == AUTO_FB_NONE) { |
Malcolm Priestley | 7e60a3de | 2013-08-16 23:48:03 +0100 | [diff] [blame] | 508 | struct vnt_tx_datahead_g *pBuf = |
| 509 | (struct vnt_tx_datahead_g *)pTxDataHead; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 510 | //Get SignalField,ServiceField,Length |
Malcolm Priestley | aed387c | 2013-08-20 22:52:30 +0100 | [diff] [blame] | 511 | BBvCalculateParameter(pDevice, cbFrameLength, wCurrentRate, |
| 512 | byPktType, &pBuf->a); |
| 513 | BBvCalculateParameter(pDevice, cbFrameLength, |
| 514 | pDevice->byTopCCKBasicRate, PK_TYPE_11B, &pBuf->b); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 515 | //Get Duration and TimeStamp |
Malcolm Priestley | 6b5ad9d | 2013-08-21 22:16:04 +0100 | [diff] [blame] | 516 | pBuf->wDuration_a = s_uGetDataDuration(pDevice, |
Malcolm Priestley | 3ed210e | 2013-08-07 21:28:45 +0100 | [diff] [blame] | 517 | byPktType, bNeedAck); |
Malcolm Priestley | 6b5ad9d | 2013-08-21 22:16:04 +0100 | [diff] [blame] | 518 | pBuf->wDuration_b = s_uGetDataDuration(pDevice, |
Malcolm Priestley | 3ed210e | 2013-08-07 21:28:45 +0100 | [diff] [blame] | 519 | PK_TYPE_11B, bNeedAck); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 520 | |
Malcolm Priestley | f115e76 | 2013-08-23 11:48:46 +0100 | [diff] [blame] | 521 | pBuf->wTimeStampOff_a = vnt_time_stamp_off(pDevice, |
| 522 | wCurrentRate); |
| 523 | pBuf->wTimeStampOff_b = vnt_time_stamp_off(pDevice, |
| 524 | pDevice->byTopCCKBasicRate); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 525 | return (pBuf->wDuration_a); |
| 526 | } else { |
| 527 | // Auto Fallback |
Malcolm Priestley | 7c05c54 | 2013-08-16 23:49:15 +0100 | [diff] [blame] | 528 | struct vnt_tx_datahead_g_fb *pBuf = |
| 529 | (struct vnt_tx_datahead_g_fb *)pTxDataHead; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 530 | //Get SignalField,ServiceField,Length |
Malcolm Priestley | aed387c | 2013-08-20 22:52:30 +0100 | [diff] [blame] | 531 | BBvCalculateParameter(pDevice, cbFrameLength, wCurrentRate, |
| 532 | byPktType, &pBuf->a); |
| 533 | BBvCalculateParameter(pDevice, cbFrameLength, |
| 534 | pDevice->byTopCCKBasicRate, PK_TYPE_11B, &pBuf->b); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 535 | //Get Duration and TimeStamp |
Malcolm Priestley | 6b5ad9d | 2013-08-21 22:16:04 +0100 | [diff] [blame] | 536 | pBuf->wDuration_a = s_uGetDataDuration(pDevice, |
Malcolm Priestley | 3ed210e | 2013-08-07 21:28:45 +0100 | [diff] [blame] | 537 | byPktType, bNeedAck); |
Malcolm Priestley | 6b5ad9d | 2013-08-21 22:16:04 +0100 | [diff] [blame] | 538 | pBuf->wDuration_b = s_uGetDataDuration(pDevice, |
Malcolm Priestley | 3ed210e | 2013-08-07 21:28:45 +0100 | [diff] [blame] | 539 | PK_TYPE_11B, bNeedAck); |
Malcolm Priestley | d500595 | 2013-08-21 21:58:37 +0100 | [diff] [blame] | 540 | pBuf->wDuration_a_f0 = s_uGetDataDuration(pDevice, |
Malcolm Priestley | 6b5ad9d | 2013-08-21 22:16:04 +0100 | [diff] [blame] | 541 | byPktType, bNeedAck); |
Malcolm Priestley | d500595 | 2013-08-21 21:58:37 +0100 | [diff] [blame] | 542 | pBuf->wDuration_a_f1 = s_uGetDataDuration(pDevice, |
Malcolm Priestley | 6b5ad9d | 2013-08-21 22:16:04 +0100 | [diff] [blame] | 543 | byPktType, bNeedAck); |
Malcolm Priestley | f115e76 | 2013-08-23 11:48:46 +0100 | [diff] [blame] | 544 | pBuf->wTimeStampOff_a = vnt_time_stamp_off(pDevice, |
| 545 | wCurrentRate); |
| 546 | pBuf->wTimeStampOff_b = vnt_time_stamp_off(pDevice, |
| 547 | pDevice->byTopCCKBasicRate); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 548 | return (pBuf->wDuration_a); |
| 549 | } //if (byFBOption == AUTO_FB_NONE) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 550 | } |
| 551 | else if (byPktType == PK_TYPE_11A) { |
Malcolm Priestley | c921cc8 | 2013-08-20 20:47:49 +0100 | [diff] [blame] | 552 | if (byFBOption != AUTO_FB_NONE) { |
Malcolm Priestley | 1da4ee2 | 2013-08-16 23:51:38 +0100 | [diff] [blame] | 553 | struct vnt_tx_datahead_a_fb *pBuf = |
| 554 | (struct vnt_tx_datahead_a_fb *)pTxDataHead; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 555 | //Get SignalField,ServiceField,Length |
Malcolm Priestley | aed387c | 2013-08-20 22:52:30 +0100 | [diff] [blame] | 556 | BBvCalculateParameter(pDevice, cbFrameLength, wCurrentRate, |
| 557 | byPktType, &pBuf->a); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 558 | //Get Duration and TimeStampOff |
Malcolm Priestley | 6b5ad9d | 2013-08-21 22:16:04 +0100 | [diff] [blame] | 559 | pBuf->wDuration = s_uGetDataDuration(pDevice, |
Malcolm Priestley | 3ed210e | 2013-08-07 21:28:45 +0100 | [diff] [blame] | 560 | byPktType, bNeedAck); |
Malcolm Priestley | d500595 | 2013-08-21 21:58:37 +0100 | [diff] [blame] | 561 | pBuf->wDuration_f0 = s_uGetDataDuration(pDevice, |
Malcolm Priestley | 6b5ad9d | 2013-08-21 22:16:04 +0100 | [diff] [blame] | 562 | byPktType, bNeedAck); |
Malcolm Priestley | d500595 | 2013-08-21 21:58:37 +0100 | [diff] [blame] | 563 | pBuf->wDuration_f1 = s_uGetDataDuration(pDevice, |
Malcolm Priestley | 6b5ad9d | 2013-08-21 22:16:04 +0100 | [diff] [blame] | 564 | byPktType, bNeedAck); |
Malcolm Priestley | f115e76 | 2013-08-23 11:48:46 +0100 | [diff] [blame] | 565 | pBuf->wTimeStampOff = vnt_time_stamp_off(pDevice, |
| 566 | wCurrentRate); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 567 | return (pBuf->wDuration); |
| 568 | } else { |
Malcolm Priestley | 558becf | 2013-08-16 23:50:32 +0100 | [diff] [blame] | 569 | struct vnt_tx_datahead_ab *pBuf = |
| 570 | (struct vnt_tx_datahead_ab *)pTxDataHead; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 571 | //Get SignalField,ServiceField,Length |
Malcolm Priestley | aed387c | 2013-08-20 22:52:30 +0100 | [diff] [blame] | 572 | BBvCalculateParameter(pDevice, cbFrameLength, wCurrentRate, |
| 573 | byPktType, &pBuf->ab); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 574 | //Get Duration and TimeStampOff |
Malcolm Priestley | 6b5ad9d | 2013-08-21 22:16:04 +0100 | [diff] [blame] | 575 | pBuf->wDuration = s_uGetDataDuration(pDevice, |
Malcolm Priestley | 3ed210e | 2013-08-07 21:28:45 +0100 | [diff] [blame] | 576 | byPktType, bNeedAck); |
Malcolm Priestley | f115e76 | 2013-08-23 11:48:46 +0100 | [diff] [blame] | 577 | pBuf->wTimeStampOff = vnt_time_stamp_off(pDevice, |
| 578 | wCurrentRate); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 579 | return (pBuf->wDuration); |
| 580 | } |
| 581 | } |
| 582 | else if (byPktType == PK_TYPE_11B) { |
Malcolm Priestley | 558becf | 2013-08-16 23:50:32 +0100 | [diff] [blame] | 583 | struct vnt_tx_datahead_ab *pBuf = |
| 584 | (struct vnt_tx_datahead_ab *)pTxDataHead; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 585 | //Get SignalField,ServiceField,Length |
Malcolm Priestley | aed387c | 2013-08-20 22:52:30 +0100 | [diff] [blame] | 586 | BBvCalculateParameter(pDevice, cbFrameLength, wCurrentRate, |
| 587 | byPktType, &pBuf->ab); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 588 | //Get Duration and TimeStampOff |
Malcolm Priestley | 6b5ad9d | 2013-08-21 22:16:04 +0100 | [diff] [blame] | 589 | pBuf->wDuration = s_uGetDataDuration(pDevice, |
Malcolm Priestley | 3ed210e | 2013-08-07 21:28:45 +0100 | [diff] [blame] | 590 | byPktType, bNeedAck); |
Malcolm Priestley | f115e76 | 2013-08-23 11:48:46 +0100 | [diff] [blame] | 591 | pBuf->wTimeStampOff = vnt_time_stamp_off(pDevice, |
| 592 | wCurrentRate); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 593 | return (pBuf->wDuration); |
| 594 | } |
| 595 | return 0; |
| 596 | } |
| 597 | |
Malcolm Priestley | 5e67ee4 | 2013-08-26 11:04:50 +0100 | [diff] [blame] | 598 | static int vnt_fill_ieee80211_rts(struct vnt_private *priv, |
| 599 | struct ieee80211_rts *rts, struct ethhdr *eth_hdr, |
| 600 | u16 duration) |
| 601 | { |
| 602 | rts->duration = duration; |
| 603 | rts->frame_control = TYPE_CTL_RTS; |
| 604 | |
| 605 | if (priv->eOPMode == OP_MODE_ADHOC || priv->eOPMode == OP_MODE_AP) |
| 606 | memcpy(rts->ra, eth_hdr->h_dest, ETH_ALEN); |
| 607 | else |
| 608 | memcpy(rts->ra, priv->abyBSSID, ETH_ALEN); |
| 609 | |
| 610 | if (priv->eOPMode == OP_MODE_AP) |
| 611 | memcpy(rts->ta, priv->abyBSSID, ETH_ALEN); |
| 612 | else |
| 613 | memcpy(rts->ta, eth_hdr->h_source, ETH_ALEN); |
| 614 | |
| 615 | return 0; |
| 616 | } |
| 617 | |
| 618 | static int vnt_rxtx_rts_g_head(struct vnt_private *priv, |
| 619 | struct vnt_rts_g *buf, struct ethhdr *eth_hdr, |
| 620 | u8 pkt_type, u32 frame_len, int need_ack, |
| 621 | u16 current_rate, u8 fb_option) |
| 622 | { |
| 623 | u16 rts_frame_len = 20; |
| 624 | |
| 625 | BBvCalculateParameter(priv, rts_frame_len, priv->byTopCCKBasicRate, |
| 626 | PK_TYPE_11B, &buf->b); |
| 627 | BBvCalculateParameter(priv, rts_frame_len, |
| 628 | priv->byTopOFDMBasicRate, pkt_type, &buf->a); |
| 629 | |
| 630 | buf->wDuration_bb = s_uGetRTSCTSDuration(priv, RTSDUR_BB, frame_len, |
| 631 | PK_TYPE_11B, priv->byTopCCKBasicRate, need_ack, fb_option); |
| 632 | buf->wDuration_aa = s_uGetRTSCTSDuration(priv, RTSDUR_AA, frame_len, |
| 633 | pkt_type, current_rate, need_ack, fb_option); |
| 634 | buf->wDuration_ba = s_uGetRTSCTSDuration(priv, RTSDUR_BA, frame_len, |
| 635 | pkt_type, current_rate, need_ack, fb_option); |
| 636 | |
| 637 | vnt_fill_ieee80211_rts(priv, &buf->data, eth_hdr, buf->wDuration_aa); |
| 638 | |
| 639 | return 0; |
| 640 | } |
| 641 | |
Malcolm Priestley | ec91713 | 2013-08-26 11:07:46 +0100 | [diff] [blame] | 642 | static int vnt_rxtx_rts_g_fb_head(struct vnt_private *priv, |
| 643 | struct vnt_rts_g_fb *buf, struct ethhdr *eth_hdr, |
| 644 | u8 pkt_type, u32 frame_len, int need_ack, |
| 645 | u16 current_rate, u8 fb_option) |
| 646 | { |
| 647 | u16 rts_frame_len = 20; |
| 648 | |
| 649 | BBvCalculateParameter(priv, rts_frame_len, priv->byTopCCKBasicRate, |
| 650 | PK_TYPE_11B, &buf->b); |
| 651 | BBvCalculateParameter(priv, rts_frame_len, |
| 652 | priv->byTopOFDMBasicRate, pkt_type, &buf->a); |
| 653 | |
| 654 | |
| 655 | buf->wDuration_bb = s_uGetRTSCTSDuration(priv, RTSDUR_BB, frame_len, |
| 656 | PK_TYPE_11B, priv->byTopCCKBasicRate, need_ack, fb_option); |
| 657 | buf->wDuration_aa = s_uGetRTSCTSDuration(priv, RTSDUR_AA, frame_len, |
| 658 | pkt_type, current_rate, need_ack, fb_option); |
| 659 | buf->wDuration_ba = s_uGetRTSCTSDuration(priv, RTSDUR_BA, frame_len, |
| 660 | pkt_type, current_rate, need_ack, fb_option); |
| 661 | |
| 662 | |
| 663 | buf->wRTSDuration_ba_f0 = s_uGetRTSCTSDuration(priv, RTSDUR_BA_F0, |
| 664 | frame_len, pkt_type, current_rate, need_ack, fb_option); |
| 665 | buf->wRTSDuration_aa_f0 = s_uGetRTSCTSDuration(priv, RTSDUR_AA_F0, |
| 666 | frame_len, pkt_type, current_rate, need_ack, fb_option); |
| 667 | buf->wRTSDuration_ba_f1 = s_uGetRTSCTSDuration(priv, RTSDUR_BA_F1, |
| 668 | frame_len, pkt_type, current_rate, need_ack, fb_option); |
| 669 | buf->wRTSDuration_aa_f1 = s_uGetRTSCTSDuration(priv, RTSDUR_AA_F1, |
| 670 | frame_len, pkt_type, current_rate, need_ack, fb_option); |
| 671 | |
| 672 | vnt_fill_ieee80211_rts(priv, &buf->data, eth_hdr, buf->wDuration_aa); |
| 673 | |
| 674 | return 0; |
| 675 | } |
| 676 | |
Malcolm Priestley | 1712633 | 2013-08-26 11:09:38 +0100 | [diff] [blame] | 677 | static int vnt_rxtx_rts_ab_head(struct vnt_private *priv, |
| 678 | struct vnt_rts_ab *buf, struct ethhdr *eth_hdr, |
| 679 | u8 pkt_type, u32 frame_len, int need_ack, |
| 680 | u16 current_rate, u8 fb_option) |
| 681 | { |
| 682 | u16 rts_frame_len = 20; |
| 683 | |
| 684 | BBvCalculateParameter(priv, rts_frame_len, |
| 685 | priv->byTopOFDMBasicRate, pkt_type, &buf->ab); |
| 686 | |
| 687 | buf->wDuration = s_uGetRTSCTSDuration(priv, RTSDUR_AA, frame_len, |
| 688 | pkt_type, current_rate, need_ack, fb_option); |
| 689 | |
| 690 | vnt_fill_ieee80211_rts(priv, &buf->data, eth_hdr, buf->wDuration); |
| 691 | |
| 692 | return 0; |
| 693 | } |
| 694 | |
Malcolm Priestley | 9d2578c | 2013-08-26 11:12:00 +0100 | [diff] [blame] | 695 | static int vnt_rxtx_rts_a_fb_head(struct vnt_private *priv, |
| 696 | struct vnt_rts_a_fb *buf, struct ethhdr *eth_hdr, |
| 697 | u8 pkt_type, u32 frame_len, int need_ack, |
| 698 | u16 current_rate, u8 fb_option) |
| 699 | { |
| 700 | u16 rts_frame_len = 20; |
| 701 | |
| 702 | BBvCalculateParameter(priv, rts_frame_len, |
| 703 | priv->byTopOFDMBasicRate, pkt_type, &buf->a); |
| 704 | |
| 705 | buf->wDuration = s_uGetRTSCTSDuration(priv, RTSDUR_AA, frame_len, |
| 706 | pkt_type, current_rate, need_ack, fb_option); |
| 707 | |
| 708 | buf->wRTSDuration_f0 = s_uGetRTSCTSDuration(priv, RTSDUR_AA_F0, |
| 709 | frame_len, pkt_type, current_rate, need_ack, fb_option); |
| 710 | |
| 711 | buf->wRTSDuration_f1 = s_uGetRTSCTSDuration(priv, RTSDUR_AA_F1, |
| 712 | frame_len, pkt_type, current_rate, need_ack, fb_option); |
| 713 | |
| 714 | vnt_fill_ieee80211_rts(priv, &buf->data, eth_hdr, buf->wDuration); |
| 715 | |
| 716 | return 0; |
| 717 | } |
| 718 | |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 719 | static void s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType, |
Malcolm Priestley | fedbfe7 | 2013-08-24 12:50:50 +0100 | [diff] [blame] | 720 | void *pvRTS, u32 cbFrameLength, int bNeedAck, |
Andres More | ceb8c5d | 2013-03-18 20:33:49 -0500 | [diff] [blame] | 721 | struct ethhdr *psEthHeader, u16 wCurrentRate, u8 byFBOption) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 722 | { |
Malcolm Priestley | 13fe62a | 2013-08-26 11:17:52 +0100 | [diff] [blame] | 723 | union vnt_tx_data_head *head = pvRTS; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 724 | |
Malcolm Priestley | 13fe62a | 2013-08-26 11:17:52 +0100 | [diff] [blame] | 725 | if (!head) |
| 726 | return; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 727 | |
Malcolm Priestley | 9d5829b | 2013-08-26 11:21:11 +0100 | [diff] [blame] | 728 | /* Note: So far RTSHead doesn't appear in ATIM |
| 729 | * & Beacom DMA, so we don't need to take them |
| 730 | * into account. |
| 731 | * Otherwise, we need to modified codes for them. |
| 732 | */ |
Malcolm Priestley | 0bddd30 | 2013-08-27 09:56:50 +0100 | [diff] [blame^] | 733 | switch (byPktType) { |
| 734 | case PK_TYPE_11GB: |
| 735 | case PK_TYPE_11GA: |
Malcolm Priestley | 9d5829b | 2013-08-26 11:21:11 +0100 | [diff] [blame] | 736 | if (byFBOption == AUTO_FB_NONE) |
| 737 | vnt_rxtx_rts_g_head(pDevice, &head->rts_g, |
Malcolm Priestley | 5e67ee4 | 2013-08-26 11:04:50 +0100 | [diff] [blame] | 738 | psEthHeader, byPktType, cbFrameLength, |
| 739 | bNeedAck, wCurrentRate, byFBOption); |
Malcolm Priestley | 9d5829b | 2013-08-26 11:21:11 +0100 | [diff] [blame] | 740 | else |
| 741 | vnt_rxtx_rts_g_fb_head(pDevice, &head->rts_g_fb, |
Malcolm Priestley | ec91713 | 2013-08-26 11:07:46 +0100 | [diff] [blame] | 742 | psEthHeader, byPktType, cbFrameLength, |
| 743 | bNeedAck, wCurrentRate, byFBOption); |
Malcolm Priestley | 0bddd30 | 2013-08-27 09:56:50 +0100 | [diff] [blame^] | 744 | break; |
| 745 | case PK_TYPE_11A: |
Malcolm Priestley | 9d5829b | 2013-08-26 11:21:11 +0100 | [diff] [blame] | 746 | if (byFBOption == AUTO_FB_NONE) |
| 747 | vnt_rxtx_rts_ab_head(pDevice, &head->rts_ab, |
| 748 | psEthHeader, byPktType, cbFrameLength, |
| 749 | bNeedAck, wCurrentRate, byFBOption); |
| 750 | else |
| 751 | vnt_rxtx_rts_a_fb_head(pDevice, &head->rts_a_fb, |
| 752 | psEthHeader, byPktType, cbFrameLength, |
| 753 | bNeedAck, wCurrentRate, byFBOption); |
Malcolm Priestley | 0bddd30 | 2013-08-27 09:56:50 +0100 | [diff] [blame^] | 754 | break; |
| 755 | case PK_TYPE_11B: |
Malcolm Priestley | 13fe62a | 2013-08-26 11:17:52 +0100 | [diff] [blame] | 756 | vnt_rxtx_rts_ab_head(pDevice, &head->rts_ab, |
Malcolm Priestley | 1712633 | 2013-08-26 11:09:38 +0100 | [diff] [blame] | 757 | psEthHeader, byPktType, cbFrameLength, |
| 758 | bNeedAck, wCurrentRate, byFBOption); |
Malcolm Priestley | 9d5829b | 2013-08-26 11:21:11 +0100 | [diff] [blame] | 759 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 760 | } |
| 761 | |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 762 | static void s_vFillCTSHead(struct vnt_private *pDevice, u32 uDMAIdx, |
| 763 | u8 byPktType, void *pvCTS, u32 cbFrameLength, int bNeedAck, |
Malcolm Priestley | 09bd0f3 | 2013-08-24 12:56:11 +0100 | [diff] [blame] | 764 | u16 wCurrentRate, u8 byFBOption) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 765 | { |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 766 | u32 uCTSFrameLen = 14; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 767 | |
| 768 | if (pvCTS == NULL) { |
| 769 | return; |
| 770 | } |
| 771 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 772 | if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) { |
Malcolm Priestley | c921cc8 | 2013-08-20 20:47:49 +0100 | [diff] [blame] | 773 | if (byFBOption != AUTO_FB_NONE) { |
| 774 | /* Auto Fall back */ |
Malcolm Priestley | f0c5ba2 | 2013-08-15 21:27:22 +0100 | [diff] [blame] | 775 | struct vnt_cts_fb *pBuf = (struct vnt_cts_fb *)pvCTS; |
Malcolm Priestley | aed387c | 2013-08-20 22:52:30 +0100 | [diff] [blame] | 776 | /* Get SignalField,ServiceField,Length */ |
| 777 | BBvCalculateParameter(pDevice, uCTSFrameLen, |
| 778 | pDevice->byTopCCKBasicRate, PK_TYPE_11B, &pBuf->b); |
Malcolm Priestley | e34f9db | 2013-08-13 20:17:11 +0100 | [diff] [blame] | 779 | pBuf->wDuration_ba = s_uGetRTSCTSDuration(pDevice, CTSDUR_BA, |
| 780 | cbFrameLength, byPktType, |
| 781 | wCurrentRate, bNeedAck, byFBOption); |
| 782 | /* Get CTSDuration_ba_f0 */ |
| 783 | pBuf->wCTSDuration_ba_f0 = s_uGetRTSCTSDuration(pDevice, |
| 784 | CTSDUR_BA_F0, cbFrameLength, byPktType, wCurrentRate, |
| 785 | bNeedAck, byFBOption); |
| 786 | /* Get CTSDuration_ba_f1 */ |
| 787 | pBuf->wCTSDuration_ba_f1 = s_uGetRTSCTSDuration(pDevice, |
| 788 | CTSDUR_BA_F1, cbFrameLength, byPktType, wCurrentRate, |
| 789 | bNeedAck, byFBOption); |
Malcolm Priestley | 14840cd | 2013-08-05 22:12:42 +0100 | [diff] [blame] | 790 | /* Get CTS Frame body */ |
| 791 | pBuf->data.duration = pBuf->wDuration_ba; |
| 792 | pBuf->data.frame_control = TYPE_CTL_CTS; |
| 793 | memcpy(pBuf->data.ra, pDevice->abyCurrentNetAddr, ETH_ALEN); |
Malcolm Priestley | c921cc8 | 2013-08-20 20:47:49 +0100 | [diff] [blame] | 794 | } else { |
Malcolm Priestley | f0c5ba2 | 2013-08-15 21:27:22 +0100 | [diff] [blame] | 795 | struct vnt_cts *pBuf = (struct vnt_cts *)pvCTS; |
Malcolm Priestley | aed387c | 2013-08-20 22:52:30 +0100 | [diff] [blame] | 796 | /* Get SignalField,ServiceField,Length */ |
| 797 | BBvCalculateParameter(pDevice, uCTSFrameLen, |
| 798 | pDevice->byTopCCKBasicRate, PK_TYPE_11B, &pBuf->b); |
Malcolm Priestley | e34f9db | 2013-08-13 20:17:11 +0100 | [diff] [blame] | 799 | /* Get CTSDuration_ba */ |
| 800 | pBuf->wDuration_ba = s_uGetRTSCTSDuration(pDevice, |
| 801 | CTSDUR_BA, cbFrameLength, byPktType, |
| 802 | wCurrentRate, bNeedAck, byFBOption); |
Malcolm Priestley | 14840cd | 2013-08-05 22:12:42 +0100 | [diff] [blame] | 803 | /*Get CTS Frame body*/ |
| 804 | pBuf->data.duration = pBuf->wDuration_ba; |
| 805 | pBuf->data.frame_control = TYPE_CTL_CTS; |
| 806 | memcpy(pBuf->data.ra, pDevice->abyCurrentNetAddr, ETH_ALEN); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 807 | } |
| 808 | } |
| 809 | } |
| 810 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 811 | /*+ |
| 812 | * |
| 813 | * Description: |
| 814 | * Generate FIFO control for MAC & Baseband controller |
| 815 | * |
| 816 | * Parameters: |
| 817 | * In: |
| 818 | * pDevice - Pointer to adpater |
| 819 | * pTxDataHead - Transmit Data Buffer |
| 820 | * pTxBufHead - pTxBufHead |
| 821 | * pvRrvTime - pvRrvTime |
| 822 | * pvRTS - RTS Buffer |
| 823 | * pCTS - CTS Buffer |
| 824 | * cbFrameSize - Transmit Data Length (Hdr+Payload+FCS) |
| 825 | * bNeedACK - If need ACK |
| 826 | * uDMAIdx - DMA Index |
| 827 | * Out: |
| 828 | * none |
| 829 | * |
| 830 | * Return Value: none |
| 831 | * |
| 832 | -*/ |
Andres More | cc856e6 | 2010-05-17 21:34:01 -0300 | [diff] [blame] | 833 | |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 834 | static void s_vGenerateTxParameter(struct vnt_private *pDevice, |
| 835 | u8 byPktType, u16 wCurrentRate, void *pTxBufHead, void *pvRrvTime, |
| 836 | void *pvRTS, void *pvCTS, u32 cbFrameSize, int bNeedACK, u32 uDMAIdx, |
Andres More | ceb8c5d | 2013-03-18 20:33:49 -0500 | [diff] [blame] | 837 | struct ethhdr *psEthHeader) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 838 | { |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 839 | u32 cbMACHdLen = WLAN_HDR_ADDR3_LEN; /* 24 */ |
| 840 | u16 wFifoCtl; |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 841 | u8 byFBOption = AUTO_FB_NONE; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 842 | |
| 843 | //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"s_vGenerateTxParameter...\n"); |
| 844 | PSTxBufHead pFifoHead = (PSTxBufHead)pTxBufHead; |
| 845 | pFifoHead->wReserved = wCurrentRate; |
| 846 | wFifoCtl = pFifoHead->wFIFOCtl; |
| 847 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 848 | if (wFifoCtl & FIFOCTL_AUTO_FB_0) { |
| 849 | byFBOption = AUTO_FB_0; |
| 850 | } |
| 851 | else if (wFifoCtl & FIFOCTL_AUTO_FB_1) { |
| 852 | byFBOption = AUTO_FB_1; |
| 853 | } |
| 854 | |
Malcolm Priestley | 2dc22d5 | 2013-08-24 13:15:32 +0100 | [diff] [blame] | 855 | if (!pvRrvTime) |
| 856 | return; |
| 857 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 858 | if (pDevice->bLongHeader) |
| 859 | cbMACHdLen = WLAN_HDR_ADDR3_LEN + 6; |
| 860 | |
| 861 | if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) { |
| 862 | |
| 863 | if (pvRTS != NULL) { //RTS_need |
| 864 | //Fill RsvTime |
Malcolm Priestley | 6398a59 | 2013-08-16 21:26:55 +0100 | [diff] [blame] | 865 | struct vnt_rrv_time_rts *pBuf = |
| 866 | (struct vnt_rrv_time_rts *)pvRrvTime; |
Malcolm Priestley | cfabe4b | 2013-08-22 21:03:40 +0100 | [diff] [blame] | 867 | pBuf->wRTSTxRrvTime_aa = s_uGetRTSCTSRsvTime(pDevice, 2, |
| 868 | byPktType, cbFrameSize, wCurrentRate); |
| 869 | pBuf->wRTSTxRrvTime_ba = s_uGetRTSCTSRsvTime(pDevice, 1, |
| 870 | byPktType, cbFrameSize, wCurrentRate); |
| 871 | pBuf->wRTSTxRrvTime_bb = s_uGetRTSCTSRsvTime(pDevice, 0, |
| 872 | byPktType, cbFrameSize, wCurrentRate); |
Malcolm Priestley | 9c3806d | 2013-08-23 11:32:26 +0100 | [diff] [blame] | 873 | pBuf->wTxRrvTime_a = vnt_rxtx_rsvtime_le16(pDevice, |
| 874 | byPktType, cbFrameSize, wCurrentRate, bNeedACK); |
| 875 | pBuf->wTxRrvTime_b = vnt_rxtx_rsvtime_le16(pDevice, |
| 876 | PK_TYPE_11B, cbFrameSize, pDevice->byTopCCKBasicRate, |
| 877 | bNeedACK); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 878 | //Fill RTS |
Malcolm Priestley | fedbfe7 | 2013-08-24 12:50:50 +0100 | [diff] [blame] | 879 | s_vFillRTSHead(pDevice, byPktType, pvRTS, cbFrameSize, bNeedACK, |
| 880 | psEthHeader, wCurrentRate, byFBOption); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 881 | } |
| 882 | else {//RTS_needless, PCF mode |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 883 | //Fill RsvTime |
Malcolm Priestley | 4f99005 | 2013-08-16 23:38:57 +0100 | [diff] [blame] | 884 | struct vnt_rrv_time_cts *pBuf = |
| 885 | (struct vnt_rrv_time_cts *)pvRrvTime; |
Malcolm Priestley | 9c3806d | 2013-08-23 11:32:26 +0100 | [diff] [blame] | 886 | pBuf->wTxRrvTime_a = vnt_rxtx_rsvtime_le16(pDevice, byPktType, |
| 887 | cbFrameSize, wCurrentRate, bNeedACK); |
| 888 | pBuf->wTxRrvTime_b = vnt_rxtx_rsvtime_le16(pDevice, |
| 889 | PK_TYPE_11B, cbFrameSize, |
| 890 | pDevice->byTopCCKBasicRate, bNeedACK); |
Malcolm Priestley | cfabe4b | 2013-08-22 21:03:40 +0100 | [diff] [blame] | 891 | pBuf->wCTSTxRrvTime_ba = s_uGetRTSCTSRsvTime(pDevice, 3, |
| 892 | byPktType, cbFrameSize, wCurrentRate); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 893 | //Fill CTS |
Malcolm Priestley | 09bd0f3 | 2013-08-24 12:56:11 +0100 | [diff] [blame] | 894 | s_vFillCTSHead(pDevice, uDMAIdx, byPktType, pvCTS, cbFrameSize, |
| 895 | bNeedACK, wCurrentRate, byFBOption); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 896 | } |
| 897 | } |
| 898 | else if (byPktType == PK_TYPE_11A) { |
| 899 | |
| 900 | if (pvRTS != NULL) {//RTS_need, non PCF mode |
| 901 | //Fill RsvTime |
Malcolm Priestley | 976467d | 2013-08-16 23:44:04 +0100 | [diff] [blame] | 902 | struct vnt_rrv_time_ab *pBuf = |
| 903 | (struct vnt_rrv_time_ab *)pvRrvTime; |
Malcolm Priestley | cfabe4b | 2013-08-22 21:03:40 +0100 | [diff] [blame] | 904 | pBuf->wRTSTxRrvTime = s_uGetRTSCTSRsvTime(pDevice, 2, |
| 905 | byPktType, cbFrameSize, wCurrentRate); |
Malcolm Priestley | 9c3806d | 2013-08-23 11:32:26 +0100 | [diff] [blame] | 906 | pBuf->wTxRrvTime = vnt_rxtx_rsvtime_le16(pDevice, byPktType, |
| 907 | cbFrameSize, wCurrentRate, bNeedACK); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 908 | //Fill RTS |
Malcolm Priestley | fedbfe7 | 2013-08-24 12:50:50 +0100 | [diff] [blame] | 909 | s_vFillRTSHead(pDevice, byPktType, pvRTS, cbFrameSize, bNeedACK, |
| 910 | psEthHeader, wCurrentRate, byFBOption); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 911 | } |
| 912 | else if (pvRTS == NULL) {//RTS_needless, non PCF mode |
| 913 | //Fill RsvTime |
Malcolm Priestley | 976467d | 2013-08-16 23:44:04 +0100 | [diff] [blame] | 914 | struct vnt_rrv_time_ab *pBuf = |
| 915 | (struct vnt_rrv_time_ab *)pvRrvTime; |
Malcolm Priestley | 9c3806d | 2013-08-23 11:32:26 +0100 | [diff] [blame] | 916 | pBuf->wTxRrvTime = vnt_rxtx_rsvtime_le16(pDevice, PK_TYPE_11A, |
| 917 | cbFrameSize, wCurrentRate, bNeedACK); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 918 | } |
| 919 | } |
| 920 | else if (byPktType == PK_TYPE_11B) { |
| 921 | |
| 922 | if ((pvRTS != NULL)) {//RTS_need, non PCF mode |
| 923 | //Fill RsvTime |
Malcolm Priestley | 976467d | 2013-08-16 23:44:04 +0100 | [diff] [blame] | 924 | struct vnt_rrv_time_ab *pBuf = |
| 925 | (struct vnt_rrv_time_ab *)pvRrvTime; |
Malcolm Priestley | cfabe4b | 2013-08-22 21:03:40 +0100 | [diff] [blame] | 926 | pBuf->wRTSTxRrvTime = s_uGetRTSCTSRsvTime(pDevice, 0, |
| 927 | byPktType, cbFrameSize, wCurrentRate); |
Malcolm Priestley | 9c3806d | 2013-08-23 11:32:26 +0100 | [diff] [blame] | 928 | pBuf->wTxRrvTime = vnt_rxtx_rsvtime_le16(pDevice, PK_TYPE_11B, |
| 929 | cbFrameSize, wCurrentRate, bNeedACK); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 930 | //Fill RTS |
Malcolm Priestley | fedbfe7 | 2013-08-24 12:50:50 +0100 | [diff] [blame] | 931 | s_vFillRTSHead(pDevice, byPktType, pvRTS, cbFrameSize, bNeedACK, |
| 932 | psEthHeader, wCurrentRate, byFBOption); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 933 | } |
| 934 | else { //RTS_needless, non PCF mode |
| 935 | //Fill RsvTime |
Malcolm Priestley | 976467d | 2013-08-16 23:44:04 +0100 | [diff] [blame] | 936 | struct vnt_rrv_time_ab *pBuf = |
| 937 | (struct vnt_rrv_time_ab *)pvRrvTime; |
Malcolm Priestley | 9c3806d | 2013-08-23 11:32:26 +0100 | [diff] [blame] | 938 | pBuf->wTxRrvTime = vnt_rxtx_rsvtime_le16(pDevice, PK_TYPE_11B, |
| 939 | cbFrameSize, wCurrentRate, bNeedACK); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 940 | } |
| 941 | } |
| 942 | //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"s_vGenerateTxParameter END.\n"); |
| 943 | } |
| 944 | /* |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 945 | u8 * pbyBuffer,//point to pTxBufHead |
Andres More | 3eaca0d | 2013-02-25 20:32:52 -0500 | [diff] [blame] | 946 | u16 wFragType,//00:Non-Frag, 01:Start, 02:Mid, 03:Last |
Andres More | cc856e6 | 2010-05-17 21:34:01 -0300 | [diff] [blame] | 947 | unsigned int cbFragmentSize,//Hdr+payoad+FCS |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 948 | */ |
| 949 | |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 950 | static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, |
Malcolm Priestley | d0a2b8f | 2013-08-15 19:37:04 +0100 | [diff] [blame] | 951 | struct vnt_tx_buffer *pTxBufHead, int bNeedEncryption, |
| 952 | u32 uSkbPacketLen, u32 uDMAIdx, struct ethhdr *psEthHeader, |
| 953 | u8 *pPacket, PSKeyItem pTransmitKey, u32 uNodeIndex, u16 wCurrentRate, |
| 954 | u32 *pcbHeaderLen, u32 *pcbTotalLen) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 955 | { |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 956 | struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; |
| 957 | u32 cbFrameSize, cbFrameBodySize; |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 958 | u32 cb802_1_H_len; |
| 959 | u32 cbIVlen = 0, cbICVlen = 0, cbMIClen = 0, cbMACHdLen = 0; |
| 960 | u32 cbFCSlen = 4, cbMICHDR = 0; |
| 961 | int bNeedACK, bRTS; |
| 962 | u8 *pbyType, *pbyMacHdr, *pbyIVHead, *pbyPayloadHead, *pbyTxBufferAddr; |
| 963 | u8 abySNAP_RFC1042[ETH_ALEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00}; |
| 964 | u8 abySNAP_Bridgetunnel[ETH_ALEN] |
| 965 | = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0xF8}; |
| 966 | u32 uDuration; |
| 967 | u32 cbHeaderLength = 0, uPadding = 0; |
| 968 | void *pvRrvTime; |
Malcolm Priestley | 5a5d6a8 | 2013-08-23 14:33:55 +0100 | [diff] [blame] | 969 | struct vnt_mic_hdr *pMICHDR; |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 970 | void *pvRTS; |
| 971 | void *pvCTS; |
| 972 | void *pvTxDataHd; |
| 973 | u8 byFBOption = AUTO_FB_NONE, byFragType; |
| 974 | u16 wTxBufSize; |
Malcolm Priestley | 4235f72 | 2013-08-24 12:42:01 +0100 | [diff] [blame] | 975 | u32 dwMICKey0, dwMICKey1, dwMIC_Priority; |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 976 | u32 *pdwMIC_L, *pdwMIC_R; |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 977 | int bSoftWEP = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 978 | |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 979 | pvRrvTime = pMICHDR = pvRTS = pvCTS = pvTxDataHd = NULL; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 980 | |
Malcolm Priestley | e2efba7 | 2012-11-11 15:20:52 +0000 | [diff] [blame] | 981 | if (bNeedEncryption && pTransmitKey->pvKeyTable) { |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 982 | if (((PSKeyTable)pTransmitKey->pvKeyTable)->bSoftWEP == true) |
| 983 | bSoftWEP = true; /* WEP 256 */ |
Malcolm Priestley | e2efba7 | 2012-11-11 15:20:52 +0000 | [diff] [blame] | 984 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 985 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 986 | // Get pkt type |
Andres More | ceb8c5d | 2013-03-18 20:33:49 -0500 | [diff] [blame] | 987 | if (ntohs(psEthHeader->h_proto) > ETH_DATA_LEN) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 988 | if (pDevice->dwDiagRefCount == 0) { |
| 989 | cb802_1_H_len = 8; |
| 990 | } else { |
| 991 | cb802_1_H_len = 2; |
| 992 | } |
| 993 | } else { |
| 994 | cb802_1_H_len = 0; |
| 995 | } |
| 996 | |
Charles Clément | 21ec51f | 2010-05-18 10:08:14 -0700 | [diff] [blame] | 997 | cbFrameBodySize = uSkbPacketLen - ETH_HLEN + cb802_1_H_len; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 998 | |
| 999 | //Set packet type |
Andres More | 3eaca0d | 2013-02-25 20:32:52 -0500 | [diff] [blame] | 1000 | pTxBufHead->wFIFOCtl |= (u16)(byPktType<<8); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1001 | |
| 1002 | if (pDevice->dwDiagRefCount != 0) { |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 1003 | bNeedACK = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1004 | pTxBufHead->wFIFOCtl = pTxBufHead->wFIFOCtl & (~FIFOCTL_NEEDACK); |
| 1005 | } else { //if (pDevice->dwDiagRefCount != 0) { |
Andres More | 22040bb | 2010-08-02 20:21:44 -0300 | [diff] [blame] | 1006 | if ((pDevice->eOPMode == OP_MODE_ADHOC) || |
| 1007 | (pDevice->eOPMode == OP_MODE_AP)) { |
Andres More | ceb8c5d | 2013-03-18 20:33:49 -0500 | [diff] [blame] | 1008 | if (is_multicast_ether_addr(psEthHeader->h_dest)) { |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 1009 | bNeedACK = false; |
Andres More | 22040bb | 2010-08-02 20:21:44 -0300 | [diff] [blame] | 1010 | pTxBufHead->wFIFOCtl = |
| 1011 | pTxBufHead->wFIFOCtl & (~FIFOCTL_NEEDACK); |
| 1012 | } else { |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 1013 | bNeedACK = true; |
Andres More | 22040bb | 2010-08-02 20:21:44 -0300 | [diff] [blame] | 1014 | pTxBufHead->wFIFOCtl |= FIFOCTL_NEEDACK; |
| 1015 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1016 | } |
| 1017 | else { |
| 1018 | // MSDUs in Infra mode always need ACK |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 1019 | bNeedACK = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1020 | pTxBufHead->wFIFOCtl |= FIFOCTL_NEEDACK; |
| 1021 | } |
| 1022 | } //if (pDevice->dwDiagRefCount != 0) { |
| 1023 | |
| 1024 | pTxBufHead->wTimeStamp = DEFAULT_MSDU_LIFETIME_RES_64us; |
| 1025 | |
| 1026 | //Set FIFOCTL_LHEAD |
| 1027 | if (pDevice->bLongHeader) |
| 1028 | pTxBufHead->wFIFOCtl |= FIFOCTL_LHEAD; |
| 1029 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1030 | //Set FRAGCTL_MACHDCNT |
| 1031 | if (pDevice->bLongHeader) { |
| 1032 | cbMACHdLen = WLAN_HDR_ADDR3_LEN + 6; |
| 1033 | } else { |
| 1034 | cbMACHdLen = WLAN_HDR_ADDR3_LEN; |
| 1035 | } |
Andres More | 3eaca0d | 2013-02-25 20:32:52 -0500 | [diff] [blame] | 1036 | pTxBufHead->wFragCtl |= (u16)(cbMACHdLen << 10); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1037 | |
| 1038 | //Set FIFOCTL_GrpAckPolicy |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 1039 | if (pDevice->bGrpAckPolicy == true) {//0000 0100 0000 0000 |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1040 | pTxBufHead->wFIFOCtl |= FIFOCTL_GRPACK; |
| 1041 | } |
| 1042 | |
| 1043 | //Set Auto Fallback Ctl |
| 1044 | if (wCurrentRate >= RATE_18M) { |
| 1045 | if (pDevice->byAutoFBCtrl == AUTO_FB_0) { |
| 1046 | pTxBufHead->wFIFOCtl |= FIFOCTL_AUTO_FB_0; |
| 1047 | byFBOption = AUTO_FB_0; |
| 1048 | } else if (pDevice->byAutoFBCtrl == AUTO_FB_1) { |
| 1049 | pTxBufHead->wFIFOCtl |= FIFOCTL_AUTO_FB_1; |
| 1050 | byFBOption = AUTO_FB_1; |
| 1051 | } |
| 1052 | } |
| 1053 | |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 1054 | if (bSoftWEP != true) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1055 | if ((bNeedEncryption) && (pTransmitKey != NULL)) { //WEP enabled |
| 1056 | if (pTransmitKey->byCipherSuite == KEY_CTL_WEP) { //WEP40 or WEP104 |
| 1057 | pTxBufHead->wFragCtl |= FRAGCTL_LEGACY; |
| 1058 | } |
| 1059 | if (pTransmitKey->byCipherSuite == KEY_CTL_TKIP) { |
| 1060 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Tx Set wFragCtl == FRAGCTL_TKIP\n"); |
| 1061 | pTxBufHead->wFragCtl |= FRAGCTL_TKIP; |
| 1062 | } |
| 1063 | else if (pTransmitKey->byCipherSuite == KEY_CTL_CCMP) { //CCMP |
| 1064 | pTxBufHead->wFragCtl |= FRAGCTL_AES; |
| 1065 | } |
| 1066 | } |
| 1067 | } |
| 1068 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1069 | if ((bNeedEncryption) && (pTransmitKey != NULL)) { |
| 1070 | if (pTransmitKey->byCipherSuite == KEY_CTL_WEP) { |
| 1071 | cbIVlen = 4; |
| 1072 | cbICVlen = 4; |
| 1073 | } |
| 1074 | else if (pTransmitKey->byCipherSuite == KEY_CTL_TKIP) { |
| 1075 | cbIVlen = 8;//IV+ExtIV |
| 1076 | cbMIClen = 8; |
| 1077 | cbICVlen = 4; |
| 1078 | } |
| 1079 | if (pTransmitKey->byCipherSuite == KEY_CTL_CCMP) { |
| 1080 | cbIVlen = 8;//RSN Header |
| 1081 | cbICVlen = 8;//MIC |
Malcolm Priestley | 5a5d6a8 | 2013-08-23 14:33:55 +0100 | [diff] [blame] | 1082 | cbMICHDR = sizeof(struct vnt_mic_hdr); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1083 | } |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 1084 | if (bSoftWEP == false) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1085 | //MAC Header should be padding 0 to DW alignment. |
| 1086 | uPadding = 4 - (cbMACHdLen%4); |
| 1087 | uPadding %= 4; |
| 1088 | } |
| 1089 | } |
| 1090 | |
| 1091 | cbFrameSize = cbMACHdLen + cbIVlen + (cbFrameBodySize + cbMIClen) + cbICVlen + cbFCSlen; |
| 1092 | |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 1093 | if ( (bNeedACK == false) ||(cbFrameSize < pDevice->wRTSThreshold) ) { |
| 1094 | bRTS = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1095 | } else { |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 1096 | bRTS = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1097 | pTxBufHead->wFIFOCtl |= (FIFOCTL_RTS | FIFOCTL_LRETRY); |
| 1098 | } |
| 1099 | |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 1100 | pbyTxBufferAddr = (u8 *) &(pTxBufHead->adwTxKey[0]); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1101 | wTxBufSize = sizeof(STxBufHead); |
| 1102 | if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) {//802.11g packet |
| 1103 | if (byFBOption == AUTO_FB_NONE) { |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 1104 | if (bRTS == true) {//RTS_need |
Malcolm Priestley | 6398a59 | 2013-08-16 21:26:55 +0100 | [diff] [blame] | 1105 | pvRrvTime = (struct vnt_rrv_time_rts *) |
| 1106 | (pbyTxBufferAddr + wTxBufSize); |
Malcolm Priestley | 5a5d6a8 | 2013-08-23 14:33:55 +0100 | [diff] [blame] | 1107 | pMICHDR = (struct vnt_mic_hdr *)(pbyTxBufferAddr + wTxBufSize + |
Malcolm Priestley | 6398a59 | 2013-08-16 21:26:55 +0100 | [diff] [blame] | 1108 | sizeof(struct vnt_rrv_time_rts)); |
Malcolm Priestley | c521cb5 | 2013-08-15 21:23:25 +0100 | [diff] [blame] | 1109 | pvRTS = (struct vnt_rts_g *) (pbyTxBufferAddr + wTxBufSize + |
Malcolm Priestley | 6398a59 | 2013-08-16 21:26:55 +0100 | [diff] [blame] | 1110 | sizeof(struct vnt_rrv_time_rts) + cbMICHDR); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1111 | pvCTS = NULL; |
Malcolm Priestley | 7e60a3de | 2013-08-16 23:48:03 +0100 | [diff] [blame] | 1112 | pvTxDataHd = (struct vnt_tx_datahead_g *) (pbyTxBufferAddr + |
| 1113 | wTxBufSize + sizeof(struct vnt_rrv_time_rts) + |
| 1114 | cbMICHDR + sizeof(struct vnt_rts_g)); |
Malcolm Priestley | 6398a59 | 2013-08-16 21:26:55 +0100 | [diff] [blame] | 1115 | cbHeaderLength = wTxBufSize + sizeof(struct vnt_rrv_time_rts) + |
Malcolm Priestley | c521cb5 | 2013-08-15 21:23:25 +0100 | [diff] [blame] | 1116 | cbMICHDR + sizeof(struct vnt_rts_g) + |
Malcolm Priestley | 7e60a3de | 2013-08-16 23:48:03 +0100 | [diff] [blame] | 1117 | sizeof(struct vnt_tx_datahead_g); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1118 | } |
| 1119 | else { //RTS_needless |
Malcolm Priestley | 4f99005 | 2013-08-16 23:38:57 +0100 | [diff] [blame] | 1120 | pvRrvTime = (struct vnt_rrv_time_cts *) |
| 1121 | (pbyTxBufferAddr + wTxBufSize); |
Malcolm Priestley | 5a5d6a8 | 2013-08-23 14:33:55 +0100 | [diff] [blame] | 1122 | pMICHDR = (struct vnt_mic_hdr *) (pbyTxBufferAddr + wTxBufSize + |
Malcolm Priestley | 4f99005 | 2013-08-16 23:38:57 +0100 | [diff] [blame] | 1123 | sizeof(struct vnt_rrv_time_cts)); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1124 | pvRTS = NULL; |
Malcolm Priestley | f0c5ba2 | 2013-08-15 21:27:22 +0100 | [diff] [blame] | 1125 | pvCTS = (struct vnt_cts *) (pbyTxBufferAddr + wTxBufSize + |
Malcolm Priestley | 4f99005 | 2013-08-16 23:38:57 +0100 | [diff] [blame] | 1126 | sizeof(struct vnt_rrv_time_cts) + cbMICHDR); |
Malcolm Priestley | 7e60a3de | 2013-08-16 23:48:03 +0100 | [diff] [blame] | 1127 | pvTxDataHd = (struct vnt_tx_datahead_g *)(pbyTxBufferAddr + |
| 1128 | wTxBufSize + sizeof(struct vnt_rrv_time_cts) + |
| 1129 | cbMICHDR + sizeof(struct vnt_cts)); |
Malcolm Priestley | 4f99005 | 2013-08-16 23:38:57 +0100 | [diff] [blame] | 1130 | cbHeaderLength = wTxBufSize + sizeof(struct vnt_rrv_time_cts) + |
| 1131 | cbMICHDR + sizeof(struct vnt_cts) + |
Malcolm Priestley | 7e60a3de | 2013-08-16 23:48:03 +0100 | [diff] [blame] | 1132 | sizeof(struct vnt_tx_datahead_g); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1133 | } |
| 1134 | } else { |
| 1135 | // Auto Fall Back |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 1136 | if (bRTS == true) {//RTS_need |
Malcolm Priestley | 6398a59 | 2013-08-16 21:26:55 +0100 | [diff] [blame] | 1137 | pvRrvTime = (struct vnt_rrv_time_rts *)(pbyTxBufferAddr + |
| 1138 | wTxBufSize); |
Malcolm Priestley | 5a5d6a8 | 2013-08-23 14:33:55 +0100 | [diff] [blame] | 1139 | pMICHDR = (struct vnt_mic_hdr *) (pbyTxBufferAddr + wTxBufSize + |
Malcolm Priestley | 6398a59 | 2013-08-16 21:26:55 +0100 | [diff] [blame] | 1140 | sizeof(struct vnt_rrv_time_rts)); |
Malcolm Priestley | c521cb5 | 2013-08-15 21:23:25 +0100 | [diff] [blame] | 1141 | pvRTS = (struct vnt_rts_g_fb *) (pbyTxBufferAddr + wTxBufSize + |
Malcolm Priestley | 6398a59 | 2013-08-16 21:26:55 +0100 | [diff] [blame] | 1142 | sizeof(struct vnt_rrv_time_rts) + cbMICHDR); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1143 | pvCTS = NULL; |
Malcolm Priestley | 7c05c54 | 2013-08-16 23:49:15 +0100 | [diff] [blame] | 1144 | pvTxDataHd = (struct vnt_tx_datahead_g_fb *) (pbyTxBufferAddr + |
| 1145 | wTxBufSize + sizeof(struct vnt_rrv_time_rts) + |
| 1146 | cbMICHDR + sizeof(struct vnt_rts_g_fb)); |
Malcolm Priestley | 6398a59 | 2013-08-16 21:26:55 +0100 | [diff] [blame] | 1147 | cbHeaderLength = wTxBufSize + sizeof(struct vnt_rrv_time_rts) + |
| 1148 | cbMICHDR + sizeof(struct vnt_rts_g_fb) + |
Malcolm Priestley | 7c05c54 | 2013-08-16 23:49:15 +0100 | [diff] [blame] | 1149 | sizeof(struct vnt_tx_datahead_g_fb); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1150 | } |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 1151 | else if (bRTS == false) { //RTS_needless |
Malcolm Priestley | 4f99005 | 2013-08-16 23:38:57 +0100 | [diff] [blame] | 1152 | pvRrvTime = (struct vnt_rrv_time_cts *) |
| 1153 | (pbyTxBufferAddr + wTxBufSize); |
Malcolm Priestley | 5a5d6a8 | 2013-08-23 14:33:55 +0100 | [diff] [blame] | 1154 | pMICHDR = (struct vnt_mic_hdr *) (pbyTxBufferAddr + wTxBufSize + |
Malcolm Priestley | 4f99005 | 2013-08-16 23:38:57 +0100 | [diff] [blame] | 1155 | sizeof(struct vnt_rrv_time_cts)); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1156 | pvRTS = NULL; |
Malcolm Priestley | f0c5ba2 | 2013-08-15 21:27:22 +0100 | [diff] [blame] | 1157 | pvCTS = (struct vnt_cts_fb *) (pbyTxBufferAddr + wTxBufSize + |
Malcolm Priestley | 4f99005 | 2013-08-16 23:38:57 +0100 | [diff] [blame] | 1158 | sizeof(struct vnt_rrv_time_cts) + cbMICHDR); |
Malcolm Priestley | 7c05c54 | 2013-08-16 23:49:15 +0100 | [diff] [blame] | 1159 | pvTxDataHd = (struct vnt_tx_datahead_g_fb *) (pbyTxBufferAddr + |
Malcolm Priestley | 4f99005 | 2013-08-16 23:38:57 +0100 | [diff] [blame] | 1160 | wTxBufSize + sizeof(struct vnt_rrv_time_cts) + |
| 1161 | cbMICHDR + sizeof(struct vnt_cts_fb)); |
| 1162 | cbHeaderLength = wTxBufSize + sizeof(struct vnt_rrv_time_cts) + |
Malcolm Priestley | f0c5ba2 | 2013-08-15 21:27:22 +0100 | [diff] [blame] | 1163 | cbMICHDR + sizeof(struct vnt_cts_fb) + |
Malcolm Priestley | 7c05c54 | 2013-08-16 23:49:15 +0100 | [diff] [blame] | 1164 | sizeof(struct vnt_tx_datahead_g_fb); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1165 | } |
| 1166 | } // Auto Fall Back |
| 1167 | } |
| 1168 | else {//802.11a/b packet |
| 1169 | if (byFBOption == AUTO_FB_NONE) { |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 1170 | if (bRTS == true) {//RTS_need |
Malcolm Priestley | 976467d | 2013-08-16 23:44:04 +0100 | [diff] [blame] | 1171 | pvRrvTime = (struct vnt_rrv_time_ab *) (pbyTxBufferAddr + |
| 1172 | wTxBufSize); |
Malcolm Priestley | 5a5d6a8 | 2013-08-23 14:33:55 +0100 | [diff] [blame] | 1173 | pMICHDR = (struct vnt_mic_hdr *)(pbyTxBufferAddr + wTxBufSize + |
Malcolm Priestley | 976467d | 2013-08-16 23:44:04 +0100 | [diff] [blame] | 1174 | sizeof(struct vnt_rrv_time_ab)); |
Malcolm Priestley | c521cb5 | 2013-08-15 21:23:25 +0100 | [diff] [blame] | 1175 | pvRTS = (struct vnt_rts_ab *) (pbyTxBufferAddr + wTxBufSize + |
Malcolm Priestley | 976467d | 2013-08-16 23:44:04 +0100 | [diff] [blame] | 1176 | sizeof(struct vnt_rrv_time_ab) + cbMICHDR); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1177 | pvCTS = NULL; |
Malcolm Priestley | 558becf | 2013-08-16 23:50:32 +0100 | [diff] [blame] | 1178 | pvTxDataHd = (struct vnt_tx_datahead_ab *)(pbyTxBufferAddr + |
| 1179 | wTxBufSize + sizeof(struct vnt_rrv_time_ab) + cbMICHDR + |
Malcolm Priestley | c521cb5 | 2013-08-15 21:23:25 +0100 | [diff] [blame] | 1180 | sizeof(struct vnt_rts_ab)); |
Malcolm Priestley | 976467d | 2013-08-16 23:44:04 +0100 | [diff] [blame] | 1181 | cbHeaderLength = wTxBufSize + sizeof(struct vnt_rrv_time_ab) + |
| 1182 | cbMICHDR + sizeof(struct vnt_rts_ab) + |
Malcolm Priestley | 558becf | 2013-08-16 23:50:32 +0100 | [diff] [blame] | 1183 | sizeof(struct vnt_tx_datahead_ab); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1184 | } |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 1185 | else if (bRTS == false) { //RTS_needless, no MICHDR |
Malcolm Priestley | 976467d | 2013-08-16 23:44:04 +0100 | [diff] [blame] | 1186 | pvRrvTime = (struct vnt_rrv_time_ab *)(pbyTxBufferAddr + |
| 1187 | wTxBufSize); |
Malcolm Priestley | 5a5d6a8 | 2013-08-23 14:33:55 +0100 | [diff] [blame] | 1188 | pMICHDR = (struct vnt_mic_hdr *) (pbyTxBufferAddr + wTxBufSize + |
Malcolm Priestley | 976467d | 2013-08-16 23:44:04 +0100 | [diff] [blame] | 1189 | sizeof(struct vnt_rrv_time_ab)); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1190 | pvRTS = NULL; |
| 1191 | pvCTS = NULL; |
Malcolm Priestley | 558becf | 2013-08-16 23:50:32 +0100 | [diff] [blame] | 1192 | pvTxDataHd = (struct vnt_tx_datahead_ab *)(pbyTxBufferAddr + |
| 1193 | wTxBufSize + sizeof(struct vnt_rrv_time_ab) + cbMICHDR); |
Malcolm Priestley | 976467d | 2013-08-16 23:44:04 +0100 | [diff] [blame] | 1194 | cbHeaderLength = wTxBufSize + sizeof(struct vnt_rrv_time_ab) + |
Malcolm Priestley | 558becf | 2013-08-16 23:50:32 +0100 | [diff] [blame] | 1195 | cbMICHDR + sizeof(struct vnt_tx_datahead_ab); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1196 | } |
| 1197 | } else { |
| 1198 | // Auto Fall Back |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 1199 | if (bRTS == true) {//RTS_need |
Malcolm Priestley | 976467d | 2013-08-16 23:44:04 +0100 | [diff] [blame] | 1200 | pvRrvTime = (struct vnt_rrv_time_ab *)(pbyTxBufferAddr + |
| 1201 | wTxBufSize); |
Malcolm Priestley | 5a5d6a8 | 2013-08-23 14:33:55 +0100 | [diff] [blame] | 1202 | pMICHDR = (struct vnt_mic_hdr *) (pbyTxBufferAddr + wTxBufSize + |
Malcolm Priestley | 976467d | 2013-08-16 23:44:04 +0100 | [diff] [blame] | 1203 | sizeof(struct vnt_rrv_time_ab)); |
Malcolm Priestley | c521cb5 | 2013-08-15 21:23:25 +0100 | [diff] [blame] | 1204 | pvRTS = (struct vnt_rts_a_fb *) (pbyTxBufferAddr + wTxBufSize + |
Malcolm Priestley | 976467d | 2013-08-16 23:44:04 +0100 | [diff] [blame] | 1205 | sizeof(struct vnt_rrv_time_ab) + cbMICHDR); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1206 | pvCTS = NULL; |
Malcolm Priestley | 1da4ee2 | 2013-08-16 23:51:38 +0100 | [diff] [blame] | 1207 | pvTxDataHd = (struct vnt_tx_datahead_a_fb *)(pbyTxBufferAddr + |
| 1208 | wTxBufSize + sizeof(struct vnt_rrv_time_ab) + cbMICHDR + |
Malcolm Priestley | c521cb5 | 2013-08-15 21:23:25 +0100 | [diff] [blame] | 1209 | sizeof(struct vnt_rts_a_fb)); |
Malcolm Priestley | 976467d | 2013-08-16 23:44:04 +0100 | [diff] [blame] | 1210 | cbHeaderLength = wTxBufSize + sizeof(struct vnt_rrv_time_ab) + |
| 1211 | cbMICHDR + sizeof(struct vnt_rts_a_fb) + |
Malcolm Priestley | 1da4ee2 | 2013-08-16 23:51:38 +0100 | [diff] [blame] | 1212 | sizeof(struct vnt_tx_datahead_a_fb); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1213 | } |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 1214 | else if (bRTS == false) { //RTS_needless |
Malcolm Priestley | 976467d | 2013-08-16 23:44:04 +0100 | [diff] [blame] | 1215 | pvRrvTime = (struct vnt_rrv_time_ab *)(pbyTxBufferAddr + |
| 1216 | wTxBufSize); |
Malcolm Priestley | 5a5d6a8 | 2013-08-23 14:33:55 +0100 | [diff] [blame] | 1217 | pMICHDR = (struct vnt_mic_hdr *)(pbyTxBufferAddr + wTxBufSize + |
Malcolm Priestley | 976467d | 2013-08-16 23:44:04 +0100 | [diff] [blame] | 1218 | sizeof(struct vnt_rrv_time_ab)); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1219 | pvRTS = NULL; |
| 1220 | pvCTS = NULL; |
Malcolm Priestley | 1da4ee2 | 2013-08-16 23:51:38 +0100 | [diff] [blame] | 1221 | pvTxDataHd = (struct vnt_tx_datahead_a_fb *)(pbyTxBufferAddr + |
| 1222 | wTxBufSize + sizeof(struct vnt_rrv_time_ab) + cbMICHDR); |
Malcolm Priestley | 976467d | 2013-08-16 23:44:04 +0100 | [diff] [blame] | 1223 | cbHeaderLength = wTxBufSize + sizeof(struct vnt_rrv_time_ab) + |
Malcolm Priestley | 1da4ee2 | 2013-08-16 23:51:38 +0100 | [diff] [blame] | 1224 | cbMICHDR + sizeof(struct vnt_tx_datahead_a_fb); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1225 | } |
| 1226 | } // Auto Fall Back |
| 1227 | } |
| 1228 | |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 1229 | pbyMacHdr = (u8 *)(pbyTxBufferAddr + cbHeaderLength); |
| 1230 | pbyIVHead = (u8 *)(pbyMacHdr + cbMACHdLen + uPadding); |
| 1231 | pbyPayloadHead = (u8 *)(pbyMacHdr + cbMACHdLen + uPadding + cbIVlen); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1232 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1233 | //========================= |
| 1234 | // No Fragmentation |
| 1235 | //========================= |
| 1236 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"No Fragmentation...\n"); |
| 1237 | byFragType = FRAGCTL_NONFRAG; |
| 1238 | //uDMAIdx = TYPE_AC0DMA; |
| 1239 | //pTxBufHead = (PSTxBufHead) &(pTxBufHead->adwTxKey[0]); |
| 1240 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1241 | //Fill FIFO,RrvTime,RTS,and CTS |
Andres More | 8611a29 | 2010-05-01 14:25:00 -0300 | [diff] [blame] | 1242 | s_vGenerateTxParameter(pDevice, byPktType, wCurrentRate, |
| 1243 | (void *)pbyTxBufferAddr, pvRrvTime, pvRTS, pvCTS, |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1244 | cbFrameSize, bNeedACK, uDMAIdx, psEthHeader); |
| 1245 | //Fill DataHead |
| 1246 | uDuration = s_uFillDataHead(pDevice, byPktType, wCurrentRate, pvTxDataHd, cbFrameSize, uDMAIdx, bNeedACK, |
Malcolm Priestley | ab01fed | 2013-08-07 21:31:48 +0100 | [diff] [blame] | 1247 | byFBOption); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1248 | // Generate TX MAC Header |
Andres More | 3eaca0d | 2013-02-25 20:32:52 -0500 | [diff] [blame] | 1249 | s_vGenerateMACHeader(pDevice, pbyMacHdr, (u16)uDuration, psEthHeader, bNeedEncryption, |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1250 | byFragType, uDMAIdx, 0); |
| 1251 | |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 1252 | if (bNeedEncryption == true) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1253 | //Fill TXKEY |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 1254 | s_vFillTxKey(pDevice, (u8 *)(pTxBufHead->adwTxKey), pbyIVHead, pTransmitKey, |
Malcolm Priestley | ec37d8b | 2013-08-23 14:37:48 +0100 | [diff] [blame] | 1255 | pbyMacHdr, (u16)cbFrameBodySize, pMICHDR); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1256 | |
| 1257 | if (pDevice->bEnableHostWEP) { |
| 1258 | pMgmt->sNodeDBTable[uNodeIndex].dwTSC47_16 = pTransmitKey->dwTSC47_16; |
| 1259 | pMgmt->sNodeDBTable[uNodeIndex].wTSC15_0 = pTransmitKey->wTSC15_0; |
| 1260 | } |
| 1261 | } |
| 1262 | |
| 1263 | // 802.1H |
Andres More | ceb8c5d | 2013-03-18 20:33:49 -0500 | [diff] [blame] | 1264 | if (ntohs(psEthHeader->h_proto) > ETH_DATA_LEN) { |
Andres More | 203e461 | 2010-08-04 19:12:34 -0300 | [diff] [blame] | 1265 | if (pDevice->dwDiagRefCount == 0) { |
Andres More | ceb8c5d | 2013-03-18 20:33:49 -0500 | [diff] [blame] | 1266 | if ((psEthHeader->h_proto == cpu_to_be16(ETH_P_IPX)) || |
| 1267 | (psEthHeader->h_proto == cpu_to_le16(0xF380))) { |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 1268 | memcpy((u8 *) (pbyPayloadHead), |
Andres More | 203e461 | 2010-08-04 19:12:34 -0300 | [diff] [blame] | 1269 | abySNAP_Bridgetunnel, 6); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1270 | } else { |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 1271 | memcpy((u8 *) (pbyPayloadHead), &abySNAP_RFC1042[0], 6); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1272 | } |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 1273 | pbyType = (u8 *) (pbyPayloadHead + 6); |
Andres More | ceb8c5d | 2013-03-18 20:33:49 -0500 | [diff] [blame] | 1274 | memcpy(pbyType, &(psEthHeader->h_proto), sizeof(u16)); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1275 | } else { |
Andres More | ceb8c5d | 2013-03-18 20:33:49 -0500 | [diff] [blame] | 1276 | memcpy((u8 *) (pbyPayloadHead), &(psEthHeader->h_proto), sizeof(u16)); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1277 | |
| 1278 | } |
| 1279 | |
| 1280 | } |
| 1281 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1282 | if (pPacket != NULL) { |
| 1283 | // Copy the Packet into a tx Buffer |
Jim Lieb | 3e36259 | 2009-08-12 14:54:11 -0700 | [diff] [blame] | 1284 | memcpy((pbyPayloadHead + cb802_1_H_len), |
Charles Clément | 21ec51f | 2010-05-18 10:08:14 -0700 | [diff] [blame] | 1285 | (pPacket + ETH_HLEN), |
| 1286 | uSkbPacketLen - ETH_HLEN |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1287 | ); |
| 1288 | |
| 1289 | } else { |
| 1290 | // while bRelayPacketSend psEthHeader is point to header+payload |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 1291 | memcpy((pbyPayloadHead + cb802_1_H_len), ((u8 *)psEthHeader) + ETH_HLEN, uSkbPacketLen - ETH_HLEN); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1292 | } |
| 1293 | |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 1294 | if ((bNeedEncryption == true) && (pTransmitKey != NULL) && (pTransmitKey->byCipherSuite == KEY_CTL_TKIP)) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1295 | |
| 1296 | /////////////////////////////////////////////////////////////////// |
| 1297 | |
Malcolm Priestley | 14c5ef5 | 2013-01-17 23:19:37 +0000 | [diff] [blame] | 1298 | if (pDevice->vnt_mgmt.eAuthenMode == WMAC_AUTH_WPANONE) { |
| 1299 | dwMICKey0 = *(u32 *)(&pTransmitKey->abyKey[16]); |
| 1300 | dwMICKey1 = *(u32 *)(&pTransmitKey->abyKey[20]); |
| 1301 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1302 | else if ((pTransmitKey->dwKeyIndex & AUTHENTICATOR_KEY) != 0) { |
Andres More | 52a7e64 | 2013-02-25 20:32:53 -0500 | [diff] [blame] | 1303 | dwMICKey0 = *(u32 *)(&pTransmitKey->abyKey[16]); |
| 1304 | dwMICKey1 = *(u32 *)(&pTransmitKey->abyKey[20]); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1305 | } |
| 1306 | else { |
Andres More | 52a7e64 | 2013-02-25 20:32:53 -0500 | [diff] [blame] | 1307 | dwMICKey0 = *(u32 *)(&pTransmitKey->abyKey[24]); |
| 1308 | dwMICKey1 = *(u32 *)(&pTransmitKey->abyKey[28]); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1309 | } |
| 1310 | // DO Software Michael |
| 1311 | MIC_vInit(dwMICKey0, dwMICKey1); |
Andres More | ceb8c5d | 2013-03-18 20:33:49 -0500 | [diff] [blame] | 1312 | MIC_vAppend((u8 *)&(psEthHeader->h_dest[0]), 12); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1313 | dwMIC_Priority = 0; |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 1314 | MIC_vAppend((u8 *)&dwMIC_Priority, 4); |
Malcolm Priestley | b4dc03a | 2012-11-11 15:45:52 +0000 | [diff] [blame] | 1315 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"MIC KEY: %X, %X\n", |
| 1316 | dwMICKey0, dwMICKey1); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1317 | |
| 1318 | /////////////////////////////////////////////////////////////////// |
| 1319 | |
| 1320 | //DBG_PRN_GRP12(("Length:%d, %d\n", cbFrameBodySize, uFromHDtoPLDLength)); |
| 1321 | //for (ii = 0; ii < cbFrameBodySize; ii++) { |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 1322 | // DBG_PRN_GRP12(("%02x ", *((u8 *)((pbyPayloadHead + cb802_1_H_len) + ii)))); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1323 | //} |
| 1324 | //DBG_PRN_GRP12(("\n\n\n")); |
| 1325 | |
| 1326 | MIC_vAppend(pbyPayloadHead, cbFrameBodySize); |
| 1327 | |
Andres More | 52a7e64 | 2013-02-25 20:32:53 -0500 | [diff] [blame] | 1328 | pdwMIC_L = (u32 *)(pbyPayloadHead + cbFrameBodySize); |
| 1329 | pdwMIC_R = (u32 *)(pbyPayloadHead + cbFrameBodySize + 4); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1330 | |
| 1331 | MIC_vGetMIC(pdwMIC_L, pdwMIC_R); |
| 1332 | MIC_vUnInit(); |
| 1333 | |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 1334 | if (pDevice->bTxMICFail == true) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1335 | *pdwMIC_L = 0; |
| 1336 | *pdwMIC_R = 0; |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 1337 | pDevice->bTxMICFail = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1338 | } |
| 1339 | //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"uLength: %d, %d\n", uLength, cbFrameBodySize); |
| 1340 | //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"cbReqCount:%d, %d, %d, %d\n", cbReqCount, cbHeaderLength, uPadding, cbIVlen); |
| 1341 | //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"MIC:%lX, %lX\n", *pdwMIC_L, *pdwMIC_R); |
| 1342 | } |
| 1343 | |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 1344 | if (bSoftWEP == true) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1345 | |
Andres More | 3eaca0d | 2013-02-25 20:32:52 -0500 | [diff] [blame] | 1346 | s_vSWencryption(pDevice, pTransmitKey, (pbyPayloadHead), (u16)(cbFrameBodySize + cbMIClen)); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1347 | |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 1348 | } else if ( ((pDevice->eEncryptionStatus == Ndis802_11Encryption1Enabled) && (bNeedEncryption == true)) || |
| 1349 | ((pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled) && (bNeedEncryption == true)) || |
| 1350 | ((pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled) && (bNeedEncryption == true)) ) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1351 | cbFrameSize -= cbICVlen; |
| 1352 | } |
| 1353 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1354 | cbFrameSize -= cbFCSlen; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1355 | |
| 1356 | *pcbHeaderLen = cbHeaderLength; |
| 1357 | *pcbTotalLen = cbHeaderLength + cbFrameSize ; |
| 1358 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1359 | //Set FragCtl in TxBufferHead |
Andres More | 3eaca0d | 2013-02-25 20:32:52 -0500 | [diff] [blame] | 1360 | pTxBufHead->wFragCtl |= (u16)byFragType; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1361 | |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 1362 | return true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1363 | |
| 1364 | } |
| 1365 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1366 | /*+ |
| 1367 | * |
| 1368 | * Description: |
| 1369 | * Translate 802.3 to 802.11 header |
| 1370 | * |
| 1371 | * Parameters: |
| 1372 | * In: |
Justin P. Mattock | a0a1f61 | 2012-08-26 08:16:43 -0700 | [diff] [blame] | 1373 | * pDevice - Pointer to adapter |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1374 | * dwTxBufferAddr - Transmit Buffer |
| 1375 | * pPacket - Packet from upper layer |
| 1376 | * cbPacketSize - Transmit Data Length |
| 1377 | * Out: |
| 1378 | * pcbHeadSize - Header size of MAC&Baseband control and 802.11 Header |
| 1379 | * pcbAppendPayload - size of append payload for 802.1H translation |
| 1380 | * |
| 1381 | * Return Value: none |
| 1382 | * |
| 1383 | -*/ |
| 1384 | |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 1385 | static void s_vGenerateMACHeader(struct vnt_private *pDevice, |
Andres More | ceb8c5d | 2013-03-18 20:33:49 -0500 | [diff] [blame] | 1386 | u8 *pbyBufferAddr, u16 wDuration, struct ethhdr *psEthHeader, |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 1387 | int bNeedEncrypt, u16 wFragType, u32 uDMAIdx, u32 uFragIdx) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1388 | { |
Andres More | 1cac4a4 | 2013-03-18 20:33:50 -0500 | [diff] [blame] | 1389 | struct ieee80211_hdr *pMACHeader = (struct ieee80211_hdr *)pbyBufferAddr; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1390 | |
Malcolm Priestley | c921cc8 | 2013-08-20 20:47:49 +0100 | [diff] [blame] | 1391 | pMACHeader->frame_control = TYPE_802_11_DATA; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1392 | |
| 1393 | if (pDevice->eOPMode == OP_MODE_AP) { |
Andres More | 1cac4a4 | 2013-03-18 20:33:50 -0500 | [diff] [blame] | 1394 | memcpy(&(pMACHeader->addr1[0]), |
Andres More | ceb8c5d | 2013-03-18 20:33:49 -0500 | [diff] [blame] | 1395 | &(psEthHeader->h_dest[0]), |
Andres More | 9a0e756 | 2010-04-13 21:54:48 -0300 | [diff] [blame] | 1396 | ETH_ALEN); |
Andres More | 1cac4a4 | 2013-03-18 20:33:50 -0500 | [diff] [blame] | 1397 | memcpy(&(pMACHeader->addr2[0]), &(pDevice->abyBSSID[0]), ETH_ALEN); |
| 1398 | memcpy(&(pMACHeader->addr3[0]), |
Andres More | ceb8c5d | 2013-03-18 20:33:49 -0500 | [diff] [blame] | 1399 | &(psEthHeader->h_source[0]), |
Andres More | 9a0e756 | 2010-04-13 21:54:48 -0300 | [diff] [blame] | 1400 | ETH_ALEN); |
Andres More | 1cac4a4 | 2013-03-18 20:33:50 -0500 | [diff] [blame] | 1401 | pMACHeader->frame_control |= FC_FROMDS; |
Andres More | 9a0e756 | 2010-04-13 21:54:48 -0300 | [diff] [blame] | 1402 | } else { |
| 1403 | if (pDevice->eOPMode == OP_MODE_ADHOC) { |
Andres More | 1cac4a4 | 2013-03-18 20:33:50 -0500 | [diff] [blame] | 1404 | memcpy(&(pMACHeader->addr1[0]), |
Andres More | ceb8c5d | 2013-03-18 20:33:49 -0500 | [diff] [blame] | 1405 | &(psEthHeader->h_dest[0]), |
Andres More | 9a0e756 | 2010-04-13 21:54:48 -0300 | [diff] [blame] | 1406 | ETH_ALEN); |
Andres More | 1cac4a4 | 2013-03-18 20:33:50 -0500 | [diff] [blame] | 1407 | memcpy(&(pMACHeader->addr2[0]), |
Andres More | ceb8c5d | 2013-03-18 20:33:49 -0500 | [diff] [blame] | 1408 | &(psEthHeader->h_source[0]), |
Andres More | 9a0e756 | 2010-04-13 21:54:48 -0300 | [diff] [blame] | 1409 | ETH_ALEN); |
Andres More | 1cac4a4 | 2013-03-18 20:33:50 -0500 | [diff] [blame] | 1410 | memcpy(&(pMACHeader->addr3[0]), |
Andres More | 9a0e756 | 2010-04-13 21:54:48 -0300 | [diff] [blame] | 1411 | &(pDevice->abyBSSID[0]), |
| 1412 | ETH_ALEN); |
| 1413 | } else { |
Andres More | 1cac4a4 | 2013-03-18 20:33:50 -0500 | [diff] [blame] | 1414 | memcpy(&(pMACHeader->addr3[0]), |
Andres More | ceb8c5d | 2013-03-18 20:33:49 -0500 | [diff] [blame] | 1415 | &(psEthHeader->h_dest[0]), |
Andres More | 9a0e756 | 2010-04-13 21:54:48 -0300 | [diff] [blame] | 1416 | ETH_ALEN); |
Andres More | 1cac4a4 | 2013-03-18 20:33:50 -0500 | [diff] [blame] | 1417 | memcpy(&(pMACHeader->addr2[0]), |
Andres More | ceb8c5d | 2013-03-18 20:33:49 -0500 | [diff] [blame] | 1418 | &(psEthHeader->h_source[0]), |
Andres More | 9a0e756 | 2010-04-13 21:54:48 -0300 | [diff] [blame] | 1419 | ETH_ALEN); |
Andres More | 1cac4a4 | 2013-03-18 20:33:50 -0500 | [diff] [blame] | 1420 | memcpy(&(pMACHeader->addr1[0]), |
Andres More | 9a0e756 | 2010-04-13 21:54:48 -0300 | [diff] [blame] | 1421 | &(pDevice->abyBSSID[0]), |
| 1422 | ETH_ALEN); |
Andres More | 1cac4a4 | 2013-03-18 20:33:50 -0500 | [diff] [blame] | 1423 | pMACHeader->frame_control |= FC_TODS; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1424 | } |
| 1425 | } |
| 1426 | |
| 1427 | if (bNeedEncrypt) |
Andres More | 1cac4a4 | 2013-03-18 20:33:50 -0500 | [diff] [blame] | 1428 | pMACHeader->frame_control |= cpu_to_le16((u16)WLAN_SET_FC_ISWEP(1)); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1429 | |
Andres More | 1cac4a4 | 2013-03-18 20:33:50 -0500 | [diff] [blame] | 1430 | pMACHeader->duration_id = cpu_to_le16(wDuration); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1431 | |
| 1432 | if (pDevice->bLongHeader) { |
| 1433 | PWLAN_80211HDR_A4 pMACA4Header = (PWLAN_80211HDR_A4) pbyBufferAddr; |
Andres More | 1cac4a4 | 2013-03-18 20:33:50 -0500 | [diff] [blame] | 1434 | pMACHeader->frame_control |= (FC_TODS | FC_FROMDS); |
Jim Lieb | 3e36259 | 2009-08-12 14:54:11 -0700 | [diff] [blame] | 1435 | memcpy(pMACA4Header->abyAddr4, pDevice->abyBSSID, WLAN_ADDR_LEN); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1436 | } |
Andres More | 1cac4a4 | 2013-03-18 20:33:50 -0500 | [diff] [blame] | 1437 | pMACHeader->seq_ctrl = cpu_to_le16(pDevice->wSeqCounter << 4); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1438 | |
| 1439 | //Set FragNumber in Sequence Control |
Andres More | 1cac4a4 | 2013-03-18 20:33:50 -0500 | [diff] [blame] | 1440 | pMACHeader->seq_ctrl |= cpu_to_le16((u16)uFragIdx); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1441 | |
| 1442 | if ((wFragType == FRAGCTL_ENDFRAG) || (wFragType == FRAGCTL_NONFRAG)) { |
| 1443 | pDevice->wSeqCounter++; |
| 1444 | if (pDevice->wSeqCounter > 0x0fff) |
| 1445 | pDevice->wSeqCounter = 0; |
| 1446 | } |
| 1447 | |
| 1448 | if ((wFragType == FRAGCTL_STAFRAG) || (wFragType == FRAGCTL_MIDFRAG)) { //StartFrag or MidFrag |
Andres More | 1cac4a4 | 2013-03-18 20:33:50 -0500 | [diff] [blame] | 1449 | pMACHeader->frame_control |= FC_MOREFRAG; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1450 | } |
| 1451 | } |
| 1452 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1453 | /*+ |
| 1454 | * |
| 1455 | * Description: |
| 1456 | * Request instructs a MAC to transmit a 802.11 management packet through |
| 1457 | * the adapter onto the medium. |
| 1458 | * |
| 1459 | * Parameters: |
| 1460 | * In: |
| 1461 | * hDeviceContext - Pointer to the adapter |
| 1462 | * pPacket - A pointer to a descriptor for the packet to transmit |
| 1463 | * Out: |
| 1464 | * none |
| 1465 | * |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 1466 | * Return Value: CMD_STATUS_PENDING if MAC Tx resource available; otherwise false |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1467 | * |
| 1468 | -*/ |
| 1469 | |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 1470 | CMD_STATUS csMgmt_xmit(struct vnt_private *pDevice, |
| 1471 | struct vnt_tx_mgmt *pPacket) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1472 | { |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 1473 | struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; |
Malcolm Priestley | f39c0d8 | 2013-08-15 19:34:37 +0100 | [diff] [blame] | 1474 | struct vnt_tx_buffer *pTX_Buffer; |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 1475 | PSTxBufHead pTxBufHead; |
| 1476 | PUSB_SEND_CONTEXT pContext; |
Andres More | 1cac4a4 | 2013-03-18 20:33:50 -0500 | [diff] [blame] | 1477 | struct ieee80211_hdr *pMACHeader; |
Malcolm Priestley | f0c5ba2 | 2013-08-15 21:27:22 +0100 | [diff] [blame] | 1478 | struct vnt_cts *pCTS; |
Andres More | ceb8c5d | 2013-03-18 20:33:49 -0500 | [diff] [blame] | 1479 | struct ethhdr sEthHeader; |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 1480 | u8 byPktType, *pbyTxBufferAddr; |
| 1481 | void *pvRTS, *pvTxDataHd, *pvRrvTime, *pMICHDR; |
| 1482 | u32 uDuration, cbReqCount, cbHeaderSize, cbFrameBodySize, cbFrameSize; |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 1483 | int bNeedACK, bIsPSPOLL = false; |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 1484 | u32 cbIVlen = 0, cbICVlen = 0, cbMIClen = 0, cbFCSlen = 4; |
| 1485 | u32 uPadding = 0; |
| 1486 | u16 wTxBufSize; |
| 1487 | u32 cbMacHdLen; |
| 1488 | u16 wCurrentRate = RATE_1M; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1489 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1490 | pContext = (PUSB_SEND_CONTEXT)s_vGetFreeContext(pDevice); |
| 1491 | |
| 1492 | if (NULL == pContext) { |
| 1493 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ManagementSend TX...NO CONTEXT!\n"); |
| 1494 | return CMD_STATUS_RESOURCES; |
| 1495 | } |
| 1496 | |
Malcolm Priestley | f39c0d8 | 2013-08-15 19:34:37 +0100 | [diff] [blame] | 1497 | pTX_Buffer = (struct vnt_tx_buffer *)&pContext->Data[0]; |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 1498 | pbyTxBufferAddr = (u8 *)&(pTX_Buffer->adwTxKey[0]); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1499 | cbFrameBodySize = pPacket->cbPayloadLen; |
| 1500 | pTxBufHead = (PSTxBufHead) pbyTxBufferAddr; |
| 1501 | wTxBufSize = sizeof(STxBufHead); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1502 | |
| 1503 | if (pDevice->byBBType == BB_TYPE_11A) { |
| 1504 | wCurrentRate = RATE_6M; |
| 1505 | byPktType = PK_TYPE_11A; |
| 1506 | } else { |
| 1507 | wCurrentRate = RATE_1M; |
| 1508 | byPktType = PK_TYPE_11B; |
| 1509 | } |
| 1510 | |
| 1511 | // SetPower will cause error power TX state for OFDM Date packet in TX buffer. |
| 1512 | // 2004.11.11 Kyle -- Using OFDM power to tx MngPkt will decrease the connection capability. |
| 1513 | // And cmd timer will wait data pkt TX finish before scanning so it's OK |
| 1514 | // to set power here. |
| 1515 | if (pMgmt->eScanState != WMAC_NO_SCANNING) { |
| 1516 | RFbSetPower(pDevice, wCurrentRate, pDevice->byCurrentCh); |
| 1517 | } else { |
| 1518 | RFbSetPower(pDevice, wCurrentRate, pMgmt->uCurrChannel); |
| 1519 | } |
| 1520 | pDevice->wCurrentRate = wCurrentRate; |
| 1521 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1522 | //Set packet type |
| 1523 | if (byPktType == PK_TYPE_11A) {//0000 0000 0000 0000 |
| 1524 | pTxBufHead->wFIFOCtl = 0; |
| 1525 | } |
| 1526 | else if (byPktType == PK_TYPE_11B) {//0000 0001 0000 0000 |
| 1527 | pTxBufHead->wFIFOCtl |= FIFOCTL_11B; |
| 1528 | } |
| 1529 | else if (byPktType == PK_TYPE_11GB) {//0000 0010 0000 0000 |
| 1530 | pTxBufHead->wFIFOCtl |= FIFOCTL_11GB; |
| 1531 | } |
| 1532 | else if (byPktType == PK_TYPE_11GA) {//0000 0011 0000 0000 |
| 1533 | pTxBufHead->wFIFOCtl |= FIFOCTL_11GA; |
| 1534 | } |
| 1535 | |
| 1536 | pTxBufHead->wFIFOCtl |= FIFOCTL_TMOEN; |
| 1537 | pTxBufHead->wTimeStamp = cpu_to_le16(DEFAULT_MGN_LIFETIME_RES_64us); |
| 1538 | |
Andres More | 22040bb | 2010-08-02 20:21:44 -0300 | [diff] [blame] | 1539 | if (is_multicast_ether_addr(pPacket->p80211Header->sA3.abyAddr1)) { |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 1540 | bNeedACK = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1541 | } |
| 1542 | else { |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 1543 | bNeedACK = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1544 | pTxBufHead->wFIFOCtl |= FIFOCTL_NEEDACK; |
| 1545 | }; |
| 1546 | |
| 1547 | if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) || |
| 1548 | (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) ) { |
| 1549 | |
| 1550 | pTxBufHead->wFIFOCtl |= FIFOCTL_LRETRY; |
| 1551 | //Set Preamble type always long |
| 1552 | //pDevice->byPreambleType = PREAMBLE_LONG; |
| 1553 | // probe-response don't retry |
| 1554 | //if ((pPacket->p80211Header->sA4.wFrameCtl & TYPE_SUBTYPE_MASK) == TYPE_MGMT_PROBE_RSP) { |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 1555 | // bNeedACK = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1556 | // pTxBufHead->wFIFOCtl &= (~FIFOCTL_NEEDACK); |
| 1557 | //} |
| 1558 | } |
| 1559 | |
| 1560 | pTxBufHead->wFIFOCtl |= (FIFOCTL_GENINT | FIFOCTL_ISDMA0); |
| 1561 | |
| 1562 | if ((pPacket->p80211Header->sA4.wFrameCtl & TYPE_SUBTYPE_MASK) == TYPE_CTL_PSPOLL) { |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 1563 | bIsPSPOLL = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1564 | cbMacHdLen = WLAN_HDR_ADDR2_LEN; |
| 1565 | } else { |
| 1566 | cbMacHdLen = WLAN_HDR_ADDR3_LEN; |
| 1567 | } |
| 1568 | |
| 1569 | //Set FRAGCTL_MACHDCNT |
Andres More | 3eaca0d | 2013-02-25 20:32:52 -0500 | [diff] [blame] | 1570 | pTxBufHead->wFragCtl |= cpu_to_le16((u16)(cbMacHdLen << 10)); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1571 | |
| 1572 | // Notes: |
| 1573 | // Although spec says MMPDU can be fragmented; In most case, |
| 1574 | // no one will send a MMPDU under fragmentation. With RTS may occur. |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 1575 | pDevice->bAES = false; //Set FRAGCTL_WEPTYP |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1576 | |
| 1577 | if (WLAN_GET_FC_ISWEP(pPacket->p80211Header->sA4.wFrameCtl) != 0) { |
| 1578 | if (pDevice->eEncryptionStatus == Ndis802_11Encryption1Enabled) { |
| 1579 | cbIVlen = 4; |
| 1580 | cbICVlen = 4; |
| 1581 | pTxBufHead->wFragCtl |= FRAGCTL_LEGACY; |
| 1582 | } |
| 1583 | else if (pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled) { |
| 1584 | cbIVlen = 8;//IV+ExtIV |
| 1585 | cbMIClen = 8; |
| 1586 | cbICVlen = 4; |
| 1587 | pTxBufHead->wFragCtl |= FRAGCTL_TKIP; |
| 1588 | //We need to get seed here for filling TxKey entry. |
| 1589 | //TKIPvMixKey(pTransmitKey->abyKey, pDevice->abyCurrentNetAddr, |
| 1590 | // pTransmitKey->wTSC15_0, pTransmitKey->dwTSC47_16, pDevice->abyPRNG); |
| 1591 | } |
| 1592 | else if (pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled) { |
| 1593 | cbIVlen = 8;//RSN Header |
| 1594 | cbICVlen = 8;//MIC |
| 1595 | pTxBufHead->wFragCtl |= FRAGCTL_AES; |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 1596 | pDevice->bAES = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1597 | } |
| 1598 | //MAC Header should be padding 0 to DW alignment. |
| 1599 | uPadding = 4 - (cbMacHdLen%4); |
| 1600 | uPadding %= 4; |
| 1601 | } |
| 1602 | |
| 1603 | cbFrameSize = cbMacHdLen + cbFrameBodySize + cbIVlen + cbMIClen + cbICVlen + cbFCSlen; |
| 1604 | |
| 1605 | //Set FIFOCTL_GrpAckPolicy |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 1606 | if (pDevice->bGrpAckPolicy == true) {//0000 0100 0000 0000 |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1607 | pTxBufHead->wFIFOCtl |= FIFOCTL_GRPACK; |
| 1608 | } |
| 1609 | //the rest of pTxBufHead->wFragCtl:FragTyp will be set later in s_vFillFragParameter() |
| 1610 | |
| 1611 | //Set RrvTime/RTS/CTS Buffer |
| 1612 | if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) {//802.11g packet |
| 1613 | |
Malcolm Priestley | 4f99005 | 2013-08-16 23:38:57 +0100 | [diff] [blame] | 1614 | pvRrvTime = (struct vnt_rrv_time_cts *) (pbyTxBufferAddr + wTxBufSize); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1615 | pMICHDR = NULL; |
| 1616 | pvRTS = NULL; |
Malcolm Priestley | f0c5ba2 | 2013-08-15 21:27:22 +0100 | [diff] [blame] | 1617 | pCTS = (struct vnt_cts *) (pbyTxBufferAddr + wTxBufSize + |
Malcolm Priestley | 4f99005 | 2013-08-16 23:38:57 +0100 | [diff] [blame] | 1618 | sizeof(struct vnt_rrv_time_cts)); |
Malcolm Priestley | 7e60a3de | 2013-08-16 23:48:03 +0100 | [diff] [blame] | 1619 | pvTxDataHd = (struct vnt_tx_datahead_g *)(pbyTxBufferAddr + wTxBufSize + |
Malcolm Priestley | 4f99005 | 2013-08-16 23:38:57 +0100 | [diff] [blame] | 1620 | sizeof(struct vnt_rrv_time_cts) + sizeof(struct vnt_cts)); |
| 1621 | cbHeaderSize = wTxBufSize + sizeof(struct vnt_rrv_time_cts) + |
Malcolm Priestley | 7e60a3de | 2013-08-16 23:48:03 +0100 | [diff] [blame] | 1622 | sizeof(struct vnt_cts) + sizeof(struct vnt_tx_datahead_g); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1623 | } |
| 1624 | else { // 802.11a/b packet |
Malcolm Priestley | 976467d | 2013-08-16 23:44:04 +0100 | [diff] [blame] | 1625 | pvRrvTime = (struct vnt_rrv_time_ab *) (pbyTxBufferAddr + wTxBufSize); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1626 | pMICHDR = NULL; |
| 1627 | pvRTS = NULL; |
| 1628 | pCTS = NULL; |
Malcolm Priestley | 558becf | 2013-08-16 23:50:32 +0100 | [diff] [blame] | 1629 | pvTxDataHd = (struct vnt_tx_datahead_ab *) (pbyTxBufferAddr + |
| 1630 | wTxBufSize + sizeof(struct vnt_rrv_time_ab)); |
Malcolm Priestley | 976467d | 2013-08-16 23:44:04 +0100 | [diff] [blame] | 1631 | cbHeaderSize = wTxBufSize + sizeof(struct vnt_rrv_time_ab) + |
Malcolm Priestley | 558becf | 2013-08-16 23:50:32 +0100 | [diff] [blame] | 1632 | sizeof(struct vnt_tx_datahead_ab); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1633 | } |
| 1634 | |
Andres More | ceb8c5d | 2013-03-18 20:33:49 -0500 | [diff] [blame] | 1635 | memcpy(&(sEthHeader.h_dest[0]), |
Andres More | 9a0e756 | 2010-04-13 21:54:48 -0300 | [diff] [blame] | 1636 | &(pPacket->p80211Header->sA3.abyAddr1[0]), |
| 1637 | ETH_ALEN); |
Andres More | ceb8c5d | 2013-03-18 20:33:49 -0500 | [diff] [blame] | 1638 | memcpy(&(sEthHeader.h_source[0]), |
Andres More | 9a0e756 | 2010-04-13 21:54:48 -0300 | [diff] [blame] | 1639 | &(pPacket->p80211Header->sA3.abyAddr2[0]), |
| 1640 | ETH_ALEN); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1641 | //========================= |
| 1642 | // No Fragmentation |
| 1643 | //========================= |
Andres More | 3eaca0d | 2013-02-25 20:32:52 -0500 | [diff] [blame] | 1644 | pTxBufHead->wFragCtl |= (u16)FRAGCTL_NONFRAG; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1645 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1646 | //Fill FIFO,RrvTime,RTS,and CTS |
| 1647 | s_vGenerateTxParameter(pDevice, byPktType, wCurrentRate, pbyTxBufferAddr, pvRrvTime, pvRTS, pCTS, |
| 1648 | cbFrameSize, bNeedACK, TYPE_TXDMA0, &sEthHeader); |
| 1649 | |
| 1650 | //Fill DataHead |
| 1651 | uDuration = s_uFillDataHead(pDevice, byPktType, wCurrentRate, pvTxDataHd, cbFrameSize, TYPE_TXDMA0, bNeedACK, |
Malcolm Priestley | ab01fed | 2013-08-07 21:31:48 +0100 | [diff] [blame] | 1652 | AUTO_FB_NONE); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1653 | |
Andres More | 1cac4a4 | 2013-03-18 20:33:50 -0500 | [diff] [blame] | 1654 | pMACHeader = (struct ieee80211_hdr *) (pbyTxBufferAddr + cbHeaderSize); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1655 | |
| 1656 | cbReqCount = cbHeaderSize + cbMacHdLen + uPadding + cbIVlen + cbFrameBodySize; |
| 1657 | |
| 1658 | if (WLAN_GET_FC_ISWEP(pPacket->p80211Header->sA4.wFrameCtl) != 0) { |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 1659 | u8 * pbyIVHead; |
| 1660 | u8 * pbyPayloadHead; |
| 1661 | u8 * pbyBSSID; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1662 | PSKeyItem pTransmitKey = NULL; |
| 1663 | |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 1664 | pbyIVHead = (u8 *)(pbyTxBufferAddr + cbHeaderSize + cbMacHdLen + uPadding); |
| 1665 | pbyPayloadHead = (u8 *)(pbyTxBufferAddr + cbHeaderSize + cbMacHdLen + uPadding + cbIVlen); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1666 | do { |
| 1667 | if ((pDevice->eOPMode == OP_MODE_INFRASTRUCTURE) && |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 1668 | (pDevice->bLinkPass == true)) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1669 | pbyBSSID = pDevice->abyBSSID; |
| 1670 | // get pairwise key |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 1671 | if (KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, PAIRWISE_KEY, &pTransmitKey) == false) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1672 | // get group key |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 1673 | if(KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, GROUP_KEY, &pTransmitKey) == true) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1674 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Get GTK.\n"); |
| 1675 | break; |
| 1676 | } |
| 1677 | } else { |
| 1678 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Get PTK.\n"); |
| 1679 | break; |
| 1680 | } |
| 1681 | } |
| 1682 | // get group key |
| 1683 | pbyBSSID = pDevice->abyBroadcastAddr; |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 1684 | if(KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, GROUP_KEY, &pTransmitKey) == false) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1685 | pTransmitKey = NULL; |
| 1686 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"KEY is NULL. OP Mode[%d]\n", pDevice->eOPMode); |
| 1687 | } else { |
| 1688 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Get GTK.\n"); |
| 1689 | } |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 1690 | } while(false); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1691 | //Fill TXKEY |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 1692 | s_vFillTxKey(pDevice, (u8 *)(pTxBufHead->adwTxKey), pbyIVHead, pTransmitKey, |
Andres More | 3eaca0d | 2013-02-25 20:32:52 -0500 | [diff] [blame] | 1693 | (u8 *)pMACHeader, (u16)cbFrameBodySize, NULL); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1694 | |
Jim Lieb | 3e36259 | 2009-08-12 14:54:11 -0700 | [diff] [blame] | 1695 | memcpy(pMACHeader, pPacket->p80211Header, cbMacHdLen); |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 1696 | memcpy(pbyPayloadHead, ((u8 *)(pPacket->p80211Header) + cbMacHdLen), |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1697 | cbFrameBodySize); |
| 1698 | } |
| 1699 | else { |
| 1700 | // Copy the Packet into a tx Buffer |
Jim Lieb | 3e36259 | 2009-08-12 14:54:11 -0700 | [diff] [blame] | 1701 | memcpy(pMACHeader, pPacket->p80211Header, pPacket->cbMPDULen); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1702 | } |
| 1703 | |
Andres More | 1cac4a4 | 2013-03-18 20:33:50 -0500 | [diff] [blame] | 1704 | pMACHeader->seq_ctrl = cpu_to_le16(pDevice->wSeqCounter << 4); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1705 | pDevice->wSeqCounter++ ; |
| 1706 | if (pDevice->wSeqCounter > 0x0fff) |
| 1707 | pDevice->wSeqCounter = 0; |
| 1708 | |
| 1709 | if (bIsPSPOLL) { |
| 1710 | // The MAC will automatically replace the Duration-field of MAC header by Duration-field |
Justin P. Mattock | a0a1f61 | 2012-08-26 08:16:43 -0700 | [diff] [blame] | 1711 | // of FIFO control header. |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1712 | // This will cause AID-field of PS-POLL packet be incorrect (Because PS-POLL's AID field is |
| 1713 | // in the same place of other packet's Duration-field). |
| 1714 | // And it will cause Cisco-AP to issue Disassociation-packet |
Malcolm Priestley | 7e60a3de | 2013-08-16 23:48:03 +0100 | [diff] [blame] | 1715 | if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) { |
| 1716 | ((struct vnt_tx_datahead_g *)pvTxDataHd)->wDuration_a = |
| 1717 | cpu_to_le16(pPacket->p80211Header->sA2.wDurationID); |
| 1718 | ((struct vnt_tx_datahead_g *)pvTxDataHd)->wDuration_b = |
| 1719 | cpu_to_le16(pPacket->p80211Header->sA2.wDurationID); |
| 1720 | } else { |
Malcolm Priestley | 558becf | 2013-08-16 23:50:32 +0100 | [diff] [blame] | 1721 | ((struct vnt_tx_datahead_ab *)pvTxDataHd)->wDuration = |
| 1722 | cpu_to_le16(pPacket->p80211Header->sA2.wDurationID); |
| 1723 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1724 | } |
| 1725 | |
Andres More | 3eaca0d | 2013-02-25 20:32:52 -0500 | [diff] [blame] | 1726 | pTX_Buffer->wTxByteCount = cpu_to_le16((u16)(cbReqCount)); |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 1727 | pTX_Buffer->byPKTNO = (u8) (((wCurrentRate<<4) &0x00F0) | ((pDevice->wSeqCounter - 1) & 0x000F)); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1728 | pTX_Buffer->byType = 0x00; |
| 1729 | |
| 1730 | pContext->pPacket = NULL; |
| 1731 | pContext->Type = CONTEXT_MGMT_PACKET; |
Andres More | 3eaca0d | 2013-02-25 20:32:52 -0500 | [diff] [blame] | 1732 | pContext->uBufLen = (u16)cbReqCount + 4; //USB header |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1733 | |
Andres More | 1cac4a4 | 2013-03-18 20:33:50 -0500 | [diff] [blame] | 1734 | if (WLAN_GET_FC_TODS(pMACHeader->frame_control) == 0) { |
| 1735 | s_vSaveTxPktInfo(pDevice, (u8) (pTX_Buffer->byPKTNO & 0x0F), &(pMACHeader->addr1[0]), (u16)cbFrameSize, pTX_Buffer->wFIFOCtl); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1736 | } |
| 1737 | else { |
Andres More | 1cac4a4 | 2013-03-18 20:33:50 -0500 | [diff] [blame] | 1738 | s_vSaveTxPktInfo(pDevice, (u8) (pTX_Buffer->byPKTNO & 0x0F), &(pMACHeader->addr3[0]), (u16)cbFrameSize, pTX_Buffer->wFIFOCtl); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1739 | } |
| 1740 | |
| 1741 | PIPEnsSendBulkOut(pDevice,pContext); |
| 1742 | return CMD_STATUS_PENDING; |
| 1743 | } |
| 1744 | |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 1745 | CMD_STATUS csBeacon_xmit(struct vnt_private *pDevice, |
| 1746 | struct vnt_tx_mgmt *pPacket) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1747 | { |
Malcolm Priestley | 01f865b | 2013-08-15 19:40:08 +0100 | [diff] [blame] | 1748 | struct vnt_beacon_buffer *pTX_Buffer; |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 1749 | u32 cbFrameSize = pPacket->cbMPDULen + WLAN_FCS_LEN; |
| 1750 | u32 cbHeaderSize = 0; |
| 1751 | u16 wTxBufSize = sizeof(STxShortBufHead); |
| 1752 | PSTxShortBufHead pTxBufHead; |
Andres More | 1cac4a4 | 2013-03-18 20:33:50 -0500 | [diff] [blame] | 1753 | struct ieee80211_hdr *pMACHeader; |
Malcolm Priestley | 558becf | 2013-08-16 23:50:32 +0100 | [diff] [blame] | 1754 | struct vnt_tx_datahead_ab *pTxDataHead; |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 1755 | u16 wCurrentRate; |
| 1756 | u32 cbFrameBodySize; |
| 1757 | u32 cbReqCount; |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 1758 | u8 *pbyTxBufferAddr; |
| 1759 | PUSB_SEND_CONTEXT pContext; |
| 1760 | CMD_STATUS status; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1761 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1762 | pContext = (PUSB_SEND_CONTEXT)s_vGetFreeContext(pDevice); |
| 1763 | if (NULL == pContext) { |
| 1764 | status = CMD_STATUS_RESOURCES; |
| 1765 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ManagementSend TX...NO CONTEXT!\n"); |
| 1766 | return status ; |
| 1767 | } |
Malcolm Priestley | 01f865b | 2013-08-15 19:40:08 +0100 | [diff] [blame] | 1768 | |
| 1769 | pTX_Buffer = (struct vnt_beacon_buffer *)&pContext->Data[0]; |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 1770 | pbyTxBufferAddr = (u8 *)&(pTX_Buffer->wFIFOCtl); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1771 | |
| 1772 | cbFrameBodySize = pPacket->cbPayloadLen; |
| 1773 | |
| 1774 | pTxBufHead = (PSTxShortBufHead) pbyTxBufferAddr; |
| 1775 | wTxBufSize = sizeof(STxShortBufHead); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1776 | |
| 1777 | if (pDevice->byBBType == BB_TYPE_11A) { |
| 1778 | wCurrentRate = RATE_6M; |
Malcolm Priestley | 558becf | 2013-08-16 23:50:32 +0100 | [diff] [blame] | 1779 | pTxDataHead = (struct vnt_tx_datahead_ab *) |
| 1780 | (pbyTxBufferAddr + wTxBufSize); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1781 | //Get SignalField,ServiceField,Length |
Malcolm Priestley | aed387c | 2013-08-20 22:52:30 +0100 | [diff] [blame] | 1782 | BBvCalculateParameter(pDevice, cbFrameSize, wCurrentRate, PK_TYPE_11A, |
| 1783 | &pTxDataHead->ab); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1784 | //Get Duration and TimeStampOff |
Malcolm Priestley | d500595 | 2013-08-21 21:58:37 +0100 | [diff] [blame] | 1785 | pTxDataHead->wDuration = s_uGetDataDuration(pDevice, |
Malcolm Priestley | 6b5ad9d | 2013-08-21 22:16:04 +0100 | [diff] [blame] | 1786 | PK_TYPE_11A, false); |
Malcolm Priestley | f115e76 | 2013-08-23 11:48:46 +0100 | [diff] [blame] | 1787 | pTxDataHead->wTimeStampOff = vnt_time_stamp_off(pDevice, wCurrentRate); |
Malcolm Priestley | 558becf | 2013-08-16 23:50:32 +0100 | [diff] [blame] | 1788 | cbHeaderSize = wTxBufSize + sizeof(struct vnt_tx_datahead_ab); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1789 | } else { |
| 1790 | wCurrentRate = RATE_1M; |
| 1791 | pTxBufHead->wFIFOCtl |= FIFOCTL_11B; |
Malcolm Priestley | 558becf | 2013-08-16 23:50:32 +0100 | [diff] [blame] | 1792 | pTxDataHead = (struct vnt_tx_datahead_ab *) |
| 1793 | (pbyTxBufferAddr + wTxBufSize); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1794 | //Get SignalField,ServiceField,Length |
Malcolm Priestley | aed387c | 2013-08-20 22:52:30 +0100 | [diff] [blame] | 1795 | BBvCalculateParameter(pDevice, cbFrameSize, wCurrentRate, PK_TYPE_11B, |
| 1796 | &pTxDataHead->ab); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1797 | //Get Duration and TimeStampOff |
Malcolm Priestley | d500595 | 2013-08-21 21:58:37 +0100 | [diff] [blame] | 1798 | pTxDataHead->wDuration = s_uGetDataDuration(pDevice, |
Malcolm Priestley | 6b5ad9d | 2013-08-21 22:16:04 +0100 | [diff] [blame] | 1799 | PK_TYPE_11B, false); |
Malcolm Priestley | f115e76 | 2013-08-23 11:48:46 +0100 | [diff] [blame] | 1800 | pTxDataHead->wTimeStampOff = vnt_time_stamp_off(pDevice, wCurrentRate); |
Malcolm Priestley | 558becf | 2013-08-16 23:50:32 +0100 | [diff] [blame] | 1801 | cbHeaderSize = wTxBufSize + sizeof(struct vnt_tx_datahead_ab); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1802 | } |
| 1803 | |
| 1804 | //Generate Beacon Header |
Andres More | 1cac4a4 | 2013-03-18 20:33:50 -0500 | [diff] [blame] | 1805 | pMACHeader = (struct ieee80211_hdr *)(pbyTxBufferAddr + cbHeaderSize); |
Jim Lieb | 3e36259 | 2009-08-12 14:54:11 -0700 | [diff] [blame] | 1806 | memcpy(pMACHeader, pPacket->p80211Header, pPacket->cbMPDULen); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1807 | |
Andres More | 1cac4a4 | 2013-03-18 20:33:50 -0500 | [diff] [blame] | 1808 | pMACHeader->duration_id = 0; |
| 1809 | pMACHeader->seq_ctrl = cpu_to_le16(pDevice->wSeqCounter << 4); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1810 | pDevice->wSeqCounter++ ; |
| 1811 | if (pDevice->wSeqCounter > 0x0fff) |
| 1812 | pDevice->wSeqCounter = 0; |
| 1813 | |
| 1814 | cbReqCount = cbHeaderSize + WLAN_HDR_ADDR3_LEN + cbFrameBodySize; |
| 1815 | |
Andres More | 3eaca0d | 2013-02-25 20:32:52 -0500 | [diff] [blame] | 1816 | pTX_Buffer->wTxByteCount = (u16)cbReqCount; |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 1817 | pTX_Buffer->byPKTNO = (u8) (((wCurrentRate<<4) &0x00F0) | ((pDevice->wSeqCounter - 1) & 0x000F)); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1818 | pTX_Buffer->byType = 0x01; |
| 1819 | |
| 1820 | pContext->pPacket = NULL; |
| 1821 | pContext->Type = CONTEXT_MGMT_PACKET; |
Andres More | 3eaca0d | 2013-02-25 20:32:52 -0500 | [diff] [blame] | 1822 | pContext->uBufLen = (u16)cbReqCount + 4; //USB header |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1823 | |
| 1824 | PIPEnsSendBulkOut(pDevice,pContext); |
| 1825 | return CMD_STATUS_PENDING; |
| 1826 | |
| 1827 | } |
| 1828 | |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 1829 | void vDMA0_tx_80211(struct vnt_private *pDevice, struct sk_buff *skb) |
| 1830 | { |
| 1831 | struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; |
Malcolm Priestley | f39c0d8 | 2013-08-15 19:34:37 +0100 | [diff] [blame] | 1832 | struct vnt_tx_buffer *pTX_Buffer; |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 1833 | u8 byPktType; |
| 1834 | u8 *pbyTxBufferAddr; |
| 1835 | void *pvRTS, *pvCTS, *pvTxDataHd; |
| 1836 | u32 uDuration, cbReqCount; |
Andres More | 1cac4a4 | 2013-03-18 20:33:50 -0500 | [diff] [blame] | 1837 | struct ieee80211_hdr *pMACHeader; |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 1838 | u32 cbHeaderSize, cbFrameBodySize; |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 1839 | int bNeedACK, bIsPSPOLL = false; |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 1840 | PSTxBufHead pTxBufHead; |
| 1841 | u32 cbFrameSize; |
| 1842 | u32 cbIVlen = 0, cbICVlen = 0, cbMIClen = 0, cbFCSlen = 4; |
| 1843 | u32 uPadding = 0; |
| 1844 | u32 cbMICHDR = 0, uLength = 0; |
| 1845 | u32 dwMICKey0, dwMICKey1; |
| 1846 | u32 dwMIC_Priority; |
| 1847 | u32 *pdwMIC_L, *pdwMIC_R; |
| 1848 | u16 wTxBufSize; |
| 1849 | u32 cbMacHdLen; |
Andres More | ceb8c5d | 2013-03-18 20:33:49 -0500 | [diff] [blame] | 1850 | struct ethhdr sEthHeader; |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 1851 | void *pvRrvTime, *pMICHDR; |
| 1852 | u32 wCurrentRate = RATE_1M; |
| 1853 | PUWLAN_80211HDR p80211Header; |
| 1854 | u32 uNodeIndex = 0; |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 1855 | int bNodeExist = false; |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 1856 | SKeyItem STempKey; |
| 1857 | PSKeyItem pTransmitKey = NULL; |
| 1858 | u8 *pbyIVHead, *pbyPayloadHead, *pbyMacHdr; |
| 1859 | u32 cbExtSuppRate = 0; |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 1860 | PUSB_SEND_CONTEXT pContext; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1861 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1862 | pvRrvTime = pMICHDR = pvRTS = pvCTS = pvTxDataHd = NULL; |
| 1863 | |
| 1864 | if(skb->len <= WLAN_HDR_ADDR3_LEN) { |
| 1865 | cbFrameBodySize = 0; |
| 1866 | } |
| 1867 | else { |
| 1868 | cbFrameBodySize = skb->len - WLAN_HDR_ADDR3_LEN; |
| 1869 | } |
| 1870 | p80211Header = (PUWLAN_80211HDR)skb->data; |
| 1871 | |
| 1872 | pContext = (PUSB_SEND_CONTEXT)s_vGetFreeContext(pDevice); |
| 1873 | |
| 1874 | if (NULL == pContext) { |
| 1875 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"DMA0 TX...NO CONTEXT!\n"); |
| 1876 | dev_kfree_skb_irq(skb); |
| 1877 | return ; |
| 1878 | } |
| 1879 | |
Malcolm Priestley | f39c0d8 | 2013-08-15 19:34:37 +0100 | [diff] [blame] | 1880 | pTX_Buffer = (struct vnt_tx_buffer *)&pContext->Data[0]; |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 1881 | pbyTxBufferAddr = (u8 *)(&pTX_Buffer->adwTxKey[0]); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1882 | pTxBufHead = (PSTxBufHead) pbyTxBufferAddr; |
| 1883 | wTxBufSize = sizeof(STxBufHead); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1884 | |
| 1885 | if (pDevice->byBBType == BB_TYPE_11A) { |
| 1886 | wCurrentRate = RATE_6M; |
| 1887 | byPktType = PK_TYPE_11A; |
| 1888 | } else { |
| 1889 | wCurrentRate = RATE_1M; |
| 1890 | byPktType = PK_TYPE_11B; |
| 1891 | } |
| 1892 | |
| 1893 | // SetPower will cause error power TX state for OFDM Date packet in TX buffer. |
| 1894 | // 2004.11.11 Kyle -- Using OFDM power to tx MngPkt will decrease the connection capability. |
| 1895 | // And cmd timer will wait data pkt TX finish before scanning so it's OK |
| 1896 | // to set power here. |
| 1897 | if (pMgmt->eScanState != WMAC_NO_SCANNING) { |
| 1898 | RFbSetPower(pDevice, wCurrentRate, pDevice->byCurrentCh); |
| 1899 | } else { |
| 1900 | RFbSetPower(pDevice, wCurrentRate, pMgmt->uCurrChannel); |
| 1901 | } |
| 1902 | |
| 1903 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"vDMA0_tx_80211: p80211Header->sA3.wFrameCtl = %x \n", p80211Header->sA3.wFrameCtl); |
| 1904 | |
| 1905 | //Set packet type |
| 1906 | if (byPktType == PK_TYPE_11A) {//0000 0000 0000 0000 |
| 1907 | pTxBufHead->wFIFOCtl = 0; |
| 1908 | } |
| 1909 | else if (byPktType == PK_TYPE_11B) {//0000 0001 0000 0000 |
| 1910 | pTxBufHead->wFIFOCtl |= FIFOCTL_11B; |
| 1911 | } |
| 1912 | else if (byPktType == PK_TYPE_11GB) {//0000 0010 0000 0000 |
| 1913 | pTxBufHead->wFIFOCtl |= FIFOCTL_11GB; |
| 1914 | } |
| 1915 | else if (byPktType == PK_TYPE_11GA) {//0000 0011 0000 0000 |
| 1916 | pTxBufHead->wFIFOCtl |= FIFOCTL_11GA; |
| 1917 | } |
| 1918 | |
| 1919 | pTxBufHead->wFIFOCtl |= FIFOCTL_TMOEN; |
| 1920 | pTxBufHead->wTimeStamp = cpu_to_le16(DEFAULT_MGN_LIFETIME_RES_64us); |
| 1921 | |
Andres More | 22040bb | 2010-08-02 20:21:44 -0300 | [diff] [blame] | 1922 | if (is_multicast_ether_addr(p80211Header->sA3.abyAddr1)) { |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 1923 | bNeedACK = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1924 | if (pDevice->bEnableHostWEP) { |
| 1925 | uNodeIndex = 0; |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 1926 | bNodeExist = true; |
Joe Perches | 9fc8602 | 2011-04-10 14:31:32 -0700 | [diff] [blame] | 1927 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1928 | } |
| 1929 | else { |
| 1930 | if (pDevice->bEnableHostWEP) { |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 1931 | if (BSSbIsSTAInNodeDB(pDevice, (u8 *)(p80211Header->sA3.abyAddr1), &uNodeIndex)) |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 1932 | bNodeExist = true; |
Joe Perches | 9fc8602 | 2011-04-10 14:31:32 -0700 | [diff] [blame] | 1933 | } |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 1934 | bNeedACK = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1935 | pTxBufHead->wFIFOCtl |= FIFOCTL_NEEDACK; |
| 1936 | }; |
| 1937 | |
| 1938 | if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) || |
| 1939 | (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) ) { |
| 1940 | |
| 1941 | pTxBufHead->wFIFOCtl |= FIFOCTL_LRETRY; |
| 1942 | //Set Preamble type always long |
| 1943 | //pDevice->byPreambleType = PREAMBLE_LONG; |
| 1944 | |
| 1945 | // probe-response don't retry |
| 1946 | //if ((p80211Header->sA4.wFrameCtl & TYPE_SUBTYPE_MASK) == TYPE_MGMT_PROBE_RSP) { |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 1947 | // bNeedACK = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1948 | // pTxBufHead->wFIFOCtl &= (~FIFOCTL_NEEDACK); |
| 1949 | //} |
| 1950 | } |
| 1951 | |
| 1952 | pTxBufHead->wFIFOCtl |= (FIFOCTL_GENINT | FIFOCTL_ISDMA0); |
| 1953 | |
| 1954 | if ((p80211Header->sA4.wFrameCtl & TYPE_SUBTYPE_MASK) == TYPE_CTL_PSPOLL) { |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 1955 | bIsPSPOLL = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1956 | cbMacHdLen = WLAN_HDR_ADDR2_LEN; |
| 1957 | } else { |
| 1958 | cbMacHdLen = WLAN_HDR_ADDR3_LEN; |
| 1959 | } |
| 1960 | |
Justin P. Mattock | a0a1f61 | 2012-08-26 08:16:43 -0700 | [diff] [blame] | 1961 | // hostapd daemon ext support rate patch |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1962 | if (WLAN_GET_FC_FSTYPE(p80211Header->sA4.wFrameCtl) == WLAN_FSTYPE_ASSOCRESP) { |
| 1963 | |
| 1964 | if (((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates)->len != 0) { |
| 1965 | cbExtSuppRate += ((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates)->len + WLAN_IEHDR_LEN; |
| 1966 | } |
| 1967 | |
| 1968 | if (((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates)->len != 0) { |
| 1969 | cbExtSuppRate += ((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates)->len + WLAN_IEHDR_LEN; |
| 1970 | } |
| 1971 | |
| 1972 | if (cbExtSuppRate >0) { |
| 1973 | cbFrameBodySize = WLAN_ASSOCRESP_OFF_SUPP_RATES; |
| 1974 | } |
| 1975 | } |
| 1976 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1977 | //Set FRAGCTL_MACHDCNT |
Andres More | 3eaca0d | 2013-02-25 20:32:52 -0500 | [diff] [blame] | 1978 | pTxBufHead->wFragCtl |= cpu_to_le16((u16)cbMacHdLen << 10); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1979 | |
| 1980 | // Notes: |
| 1981 | // Although spec says MMPDU can be fragmented; In most case, |
| 1982 | // no one will send a MMPDU under fragmentation. With RTS may occur. |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 1983 | pDevice->bAES = false; //Set FRAGCTL_WEPTYP |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1984 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1985 | if (WLAN_GET_FC_ISWEP(p80211Header->sA4.wFrameCtl) != 0) { |
| 1986 | if (pDevice->eEncryptionStatus == Ndis802_11Encryption1Enabled) { |
| 1987 | cbIVlen = 4; |
| 1988 | cbICVlen = 4; |
| 1989 | pTxBufHead->wFragCtl |= FRAGCTL_LEGACY; |
| 1990 | } |
| 1991 | else if (pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled) { |
| 1992 | cbIVlen = 8;//IV+ExtIV |
| 1993 | cbMIClen = 8; |
| 1994 | cbICVlen = 4; |
| 1995 | pTxBufHead->wFragCtl |= FRAGCTL_TKIP; |
| 1996 | //We need to get seed here for filling TxKey entry. |
| 1997 | //TKIPvMixKey(pTransmitKey->abyKey, pDevice->abyCurrentNetAddr, |
| 1998 | // pTransmitKey->wTSC15_0, pTransmitKey->dwTSC47_16, pDevice->abyPRNG); |
| 1999 | } |
| 2000 | else if (pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled) { |
| 2001 | cbIVlen = 8;//RSN Header |
| 2002 | cbICVlen = 8;//MIC |
Malcolm Priestley | 5a5d6a8 | 2013-08-23 14:33:55 +0100 | [diff] [blame] | 2003 | cbMICHDR = sizeof(struct vnt_mic_hdr); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2004 | pTxBufHead->wFragCtl |= FRAGCTL_AES; |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 2005 | pDevice->bAES = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2006 | } |
| 2007 | //MAC Header should be padding 0 to DW alignment. |
| 2008 | uPadding = 4 - (cbMacHdLen%4); |
| 2009 | uPadding %= 4; |
| 2010 | } |
| 2011 | |
| 2012 | cbFrameSize = cbMacHdLen + cbFrameBodySize + cbIVlen + cbMIClen + cbICVlen + cbFCSlen + cbExtSuppRate; |
| 2013 | |
| 2014 | //Set FIFOCTL_GrpAckPolicy |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 2015 | if (pDevice->bGrpAckPolicy == true) {//0000 0100 0000 0000 |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2016 | pTxBufHead->wFIFOCtl |= FIFOCTL_GRPACK; |
| 2017 | } |
| 2018 | //the rest of pTxBufHead->wFragCtl:FragTyp will be set later in s_vFillFragParameter() |
| 2019 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2020 | if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) {//802.11g packet |
Malcolm Priestley | 4f99005 | 2013-08-16 23:38:57 +0100 | [diff] [blame] | 2021 | pvRrvTime = (struct vnt_rrv_time_cts *) (pbyTxBufferAddr + wTxBufSize); |
Malcolm Priestley | 5a5d6a8 | 2013-08-23 14:33:55 +0100 | [diff] [blame] | 2022 | pMICHDR = (struct vnt_mic_hdr *) (pbyTxBufferAddr + wTxBufSize + |
Malcolm Priestley | 4f99005 | 2013-08-16 23:38:57 +0100 | [diff] [blame] | 2023 | sizeof(struct vnt_rrv_time_cts)); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2024 | pvRTS = NULL; |
Malcolm Priestley | f0c5ba2 | 2013-08-15 21:27:22 +0100 | [diff] [blame] | 2025 | pvCTS = (struct vnt_cts *) (pbyTxBufferAddr + wTxBufSize + |
Malcolm Priestley | 4f99005 | 2013-08-16 23:38:57 +0100 | [diff] [blame] | 2026 | sizeof(struct vnt_rrv_time_cts) + cbMICHDR); |
Malcolm Priestley | 7e60a3de | 2013-08-16 23:48:03 +0100 | [diff] [blame] | 2027 | pvTxDataHd = (struct vnt_tx_datahead_g *) (pbyTxBufferAddr + |
| 2028 | wTxBufSize + sizeof(struct vnt_rrv_time_cts) + cbMICHDR + |
Malcolm Priestley | 4f99005 | 2013-08-16 23:38:57 +0100 | [diff] [blame] | 2029 | sizeof(struct vnt_cts)); |
| 2030 | cbHeaderSize = wTxBufSize + sizeof(struct vnt_rrv_time_cts) + cbMICHDR + |
Malcolm Priestley | 7e60a3de | 2013-08-16 23:48:03 +0100 | [diff] [blame] | 2031 | sizeof(struct vnt_cts) + sizeof(struct vnt_tx_datahead_g); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2032 | |
| 2033 | } |
| 2034 | else {//802.11a/b packet |
| 2035 | |
Malcolm Priestley | 976467d | 2013-08-16 23:44:04 +0100 | [diff] [blame] | 2036 | pvRrvTime = (struct vnt_rrv_time_ab *) (pbyTxBufferAddr + wTxBufSize); |
Malcolm Priestley | 5a5d6a8 | 2013-08-23 14:33:55 +0100 | [diff] [blame] | 2037 | pMICHDR = (struct vnt_mic_hdr *) (pbyTxBufferAddr + wTxBufSize + |
Malcolm Priestley | 976467d | 2013-08-16 23:44:04 +0100 | [diff] [blame] | 2038 | sizeof(struct vnt_rrv_time_ab)); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2039 | pvRTS = NULL; |
| 2040 | pvCTS = NULL; |
Malcolm Priestley | 558becf | 2013-08-16 23:50:32 +0100 | [diff] [blame] | 2041 | pvTxDataHd = (struct vnt_tx_datahead_ab *)(pbyTxBufferAddr + |
| 2042 | wTxBufSize + sizeof(struct vnt_rrv_time_ab) + cbMICHDR); |
Malcolm Priestley | 976467d | 2013-08-16 23:44:04 +0100 | [diff] [blame] | 2043 | cbHeaderSize = wTxBufSize + sizeof(struct vnt_rrv_time_ab) + cbMICHDR + |
Malcolm Priestley | 558becf | 2013-08-16 23:50:32 +0100 | [diff] [blame] | 2044 | sizeof(struct vnt_tx_datahead_ab); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2045 | } |
Andres More | ceb8c5d | 2013-03-18 20:33:49 -0500 | [diff] [blame] | 2046 | memcpy(&(sEthHeader.h_dest[0]), |
Andres More | 9a0e756 | 2010-04-13 21:54:48 -0300 | [diff] [blame] | 2047 | &(p80211Header->sA3.abyAddr1[0]), |
| 2048 | ETH_ALEN); |
Andres More | ceb8c5d | 2013-03-18 20:33:49 -0500 | [diff] [blame] | 2049 | memcpy(&(sEthHeader.h_source[0]), |
Andres More | 9a0e756 | 2010-04-13 21:54:48 -0300 | [diff] [blame] | 2050 | &(p80211Header->sA3.abyAddr2[0]), |
| 2051 | ETH_ALEN); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2052 | //========================= |
| 2053 | // No Fragmentation |
| 2054 | //========================= |
Andres More | 3eaca0d | 2013-02-25 20:32:52 -0500 | [diff] [blame] | 2055 | pTxBufHead->wFragCtl |= (u16)FRAGCTL_NONFRAG; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2056 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2057 | //Fill FIFO,RrvTime,RTS,and CTS |
| 2058 | s_vGenerateTxParameter(pDevice, byPktType, wCurrentRate, pbyTxBufferAddr, pvRrvTime, pvRTS, pvCTS, |
| 2059 | cbFrameSize, bNeedACK, TYPE_TXDMA0, &sEthHeader); |
| 2060 | |
| 2061 | //Fill DataHead |
| 2062 | uDuration = s_uFillDataHead(pDevice, byPktType, wCurrentRate, pvTxDataHd, cbFrameSize, TYPE_TXDMA0, bNeedACK, |
Malcolm Priestley | ab01fed | 2013-08-07 21:31:48 +0100 | [diff] [blame] | 2063 | AUTO_FB_NONE); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2064 | |
Andres More | 1cac4a4 | 2013-03-18 20:33:50 -0500 | [diff] [blame] | 2065 | pMACHeader = (struct ieee80211_hdr *) (pbyTxBufferAddr + cbHeaderSize); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2066 | |
| 2067 | cbReqCount = cbHeaderSize + cbMacHdLen + uPadding + cbIVlen + (cbFrameBodySize + cbMIClen) + cbExtSuppRate; |
| 2068 | |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 2069 | pbyMacHdr = (u8 *)(pbyTxBufferAddr + cbHeaderSize); |
| 2070 | pbyPayloadHead = (u8 *)(pbyMacHdr + cbMacHdLen + uPadding + cbIVlen); |
| 2071 | pbyIVHead = (u8 *)(pbyMacHdr + cbMacHdLen + uPadding); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2072 | |
| 2073 | // Copy the Packet into a tx Buffer |
| 2074 | memcpy(pbyMacHdr, skb->data, cbMacHdLen); |
| 2075 | |
| 2076 | // version set to 0, patch for hostapd deamon |
Andres More | 1cac4a4 | 2013-03-18 20:33:50 -0500 | [diff] [blame] | 2077 | pMACHeader->frame_control &= cpu_to_le16(0xfffc); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2078 | memcpy(pbyPayloadHead, (skb->data + cbMacHdLen), cbFrameBodySize); |
| 2079 | |
Justin P. Mattock | a0a1f61 | 2012-08-26 08:16:43 -0700 | [diff] [blame] | 2080 | // replace support rate, patch for hostapd daemon( only support 11M) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2081 | if (WLAN_GET_FC_FSTYPE(p80211Header->sA4.wFrameCtl) == WLAN_FSTYPE_ASSOCRESP) { |
| 2082 | if (cbExtSuppRate != 0) { |
| 2083 | if (((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates)->len != 0) |
| 2084 | memcpy((pbyPayloadHead + cbFrameBodySize), |
| 2085 | pMgmt->abyCurrSuppRates, |
| 2086 | ((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates)->len + WLAN_IEHDR_LEN |
| 2087 | ); |
| 2088 | if (((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates)->len != 0) |
| 2089 | memcpy((pbyPayloadHead + cbFrameBodySize) + ((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates)->len + WLAN_IEHDR_LEN, |
| 2090 | pMgmt->abyCurrExtSuppRates, |
| 2091 | ((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates)->len + WLAN_IEHDR_LEN |
| 2092 | ); |
| 2093 | } |
| 2094 | } |
| 2095 | |
| 2096 | // Set wep |
| 2097 | if (WLAN_GET_FC_ISWEP(p80211Header->sA4.wFrameCtl) != 0) { |
| 2098 | |
| 2099 | if (pDevice->bEnableHostWEP) { |
| 2100 | pTransmitKey = &STempKey; |
| 2101 | pTransmitKey->byCipherSuite = pMgmt->sNodeDBTable[uNodeIndex].byCipherSuite; |
| 2102 | pTransmitKey->dwKeyIndex = pMgmt->sNodeDBTable[uNodeIndex].dwKeyIndex; |
| 2103 | pTransmitKey->uKeyLength = pMgmt->sNodeDBTable[uNodeIndex].uWepKeyLength; |
| 2104 | pTransmitKey->dwTSC47_16 = pMgmt->sNodeDBTable[uNodeIndex].dwTSC47_16; |
| 2105 | pTransmitKey->wTSC15_0 = pMgmt->sNodeDBTable[uNodeIndex].wTSC15_0; |
| 2106 | memcpy(pTransmitKey->abyKey, |
| 2107 | &pMgmt->sNodeDBTable[uNodeIndex].abyWepKey[0], |
| 2108 | pTransmitKey->uKeyLength |
| 2109 | ); |
| 2110 | } |
| 2111 | |
| 2112 | if ((pTransmitKey != NULL) && (pTransmitKey->byCipherSuite == KEY_CTL_TKIP)) { |
| 2113 | |
Andres More | 52a7e64 | 2013-02-25 20:32:53 -0500 | [diff] [blame] | 2114 | dwMICKey0 = *(u32 *)(&pTransmitKey->abyKey[16]); |
| 2115 | dwMICKey1 = *(u32 *)(&pTransmitKey->abyKey[20]); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2116 | |
| 2117 | // DO Software Michael |
| 2118 | MIC_vInit(dwMICKey0, dwMICKey1); |
Andres More | ceb8c5d | 2013-03-18 20:33:49 -0500 | [diff] [blame] | 2119 | MIC_vAppend((u8 *)&(sEthHeader.h_dest[0]), 12); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2120 | dwMIC_Priority = 0; |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 2121 | MIC_vAppend((u8 *)&dwMIC_Priority, 4); |
Malcolm Priestley | b4dc03a | 2012-11-11 15:45:52 +0000 | [diff] [blame] | 2122 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"DMA0_tx_8021:MIC KEY:"\ |
| 2123 | " %X, %X\n", dwMICKey0, dwMICKey1); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2124 | |
| 2125 | uLength = cbHeaderSize + cbMacHdLen + uPadding + cbIVlen; |
| 2126 | |
| 2127 | MIC_vAppend((pbyTxBufferAddr + uLength), cbFrameBodySize); |
| 2128 | |
Andres More | 52a7e64 | 2013-02-25 20:32:53 -0500 | [diff] [blame] | 2129 | pdwMIC_L = (u32 *)(pbyTxBufferAddr + uLength + cbFrameBodySize); |
| 2130 | pdwMIC_R = (u32 *)(pbyTxBufferAddr + uLength + cbFrameBodySize + 4); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2131 | |
| 2132 | MIC_vGetMIC(pdwMIC_L, pdwMIC_R); |
| 2133 | MIC_vUnInit(); |
| 2134 | |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 2135 | if (pDevice->bTxMICFail == true) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2136 | *pdwMIC_L = 0; |
| 2137 | *pdwMIC_R = 0; |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 2138 | pDevice->bTxMICFail = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2139 | } |
| 2140 | |
| 2141 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"uLength: %d, %d\n", uLength, cbFrameBodySize); |
| 2142 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"cbReqCount:%d, %d, %d, %d\n", cbReqCount, cbHeaderSize, uPadding, cbIVlen); |
Malcolm Priestley | b4dc03a | 2012-11-11 15:45:52 +0000 | [diff] [blame] | 2143 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"MIC:%x, %x\n", |
| 2144 | *pdwMIC_L, *pdwMIC_R); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2145 | |
| 2146 | } |
| 2147 | |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 2148 | s_vFillTxKey(pDevice, (u8 *)(pTxBufHead->adwTxKey), pbyIVHead, pTransmitKey, |
Malcolm Priestley | ec37d8b | 2013-08-23 14:37:48 +0100 | [diff] [blame] | 2149 | pbyMacHdr, (u16)cbFrameBodySize, pMICHDR); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2150 | |
| 2151 | if (pDevice->bEnableHostWEP) { |
| 2152 | pMgmt->sNodeDBTable[uNodeIndex].dwTSC47_16 = pTransmitKey->dwTSC47_16; |
| 2153 | pMgmt->sNodeDBTable[uNodeIndex].wTSC15_0 = pTransmitKey->wTSC15_0; |
| 2154 | } |
| 2155 | |
| 2156 | if ((pDevice->byLocalID <= REV_ID_VT3253_A1)) { |
Andres More | 3eaca0d | 2013-02-25 20:32:52 -0500 | [diff] [blame] | 2157 | s_vSWencryption(pDevice, pTransmitKey, pbyPayloadHead, (u16)(cbFrameBodySize + cbMIClen)); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2158 | } |
| 2159 | } |
| 2160 | |
Andres More | 1cac4a4 | 2013-03-18 20:33:50 -0500 | [diff] [blame] | 2161 | pMACHeader->seq_ctrl = cpu_to_le16(pDevice->wSeqCounter << 4); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2162 | pDevice->wSeqCounter++ ; |
| 2163 | if (pDevice->wSeqCounter > 0x0fff) |
| 2164 | pDevice->wSeqCounter = 0; |
| 2165 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2166 | if (bIsPSPOLL) { |
| 2167 | // The MAC will automatically replace the Duration-field of MAC header by Duration-field |
| 2168 | // of FIFO control header. |
| 2169 | // This will cause AID-field of PS-POLL packet be incorrect (Because PS-POLL's AID field is |
| 2170 | // in the same place of other packet's Duration-field). |
| 2171 | // And it will cause Cisco-AP to issue Disassociation-packet |
Malcolm Priestley | 7e60a3de | 2013-08-16 23:48:03 +0100 | [diff] [blame] | 2172 | if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) { |
| 2173 | ((struct vnt_tx_datahead_g *)pvTxDataHd)->wDuration_a = |
| 2174 | cpu_to_le16(p80211Header->sA2.wDurationID); |
| 2175 | ((struct vnt_tx_datahead_g *)pvTxDataHd)->wDuration_b = |
| 2176 | cpu_to_le16(p80211Header->sA2.wDurationID); |
| 2177 | } else { |
Malcolm Priestley | 558becf | 2013-08-16 23:50:32 +0100 | [diff] [blame] | 2178 | ((struct vnt_tx_datahead_ab *)pvTxDataHd)->wDuration = |
| 2179 | cpu_to_le16(p80211Header->sA2.wDurationID); |
| 2180 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2181 | } |
| 2182 | |
Andres More | 3eaca0d | 2013-02-25 20:32:52 -0500 | [diff] [blame] | 2183 | pTX_Buffer->wTxByteCount = cpu_to_le16((u16)(cbReqCount)); |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 2184 | pTX_Buffer->byPKTNO = (u8) (((wCurrentRate<<4) &0x00F0) | ((pDevice->wSeqCounter - 1) & 0x000F)); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2185 | pTX_Buffer->byType = 0x00; |
| 2186 | |
| 2187 | pContext->pPacket = skb; |
| 2188 | pContext->Type = CONTEXT_MGMT_PACKET; |
Andres More | 3eaca0d | 2013-02-25 20:32:52 -0500 | [diff] [blame] | 2189 | pContext->uBufLen = (u16)cbReqCount + 4; //USB header |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2190 | |
Andres More | 1cac4a4 | 2013-03-18 20:33:50 -0500 | [diff] [blame] | 2191 | if (WLAN_GET_FC_TODS(pMACHeader->frame_control) == 0) { |
| 2192 | s_vSaveTxPktInfo(pDevice, (u8) (pTX_Buffer->byPKTNO & 0x0F), &(pMACHeader->addr1[0]), (u16)cbFrameSize, pTX_Buffer->wFIFOCtl); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2193 | } |
| 2194 | else { |
Andres More | 1cac4a4 | 2013-03-18 20:33:50 -0500 | [diff] [blame] | 2195 | s_vSaveTxPktInfo(pDevice, (u8) (pTX_Buffer->byPKTNO & 0x0F), &(pMACHeader->addr3[0]), (u16)cbFrameSize, pTX_Buffer->wFIFOCtl); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2196 | } |
| 2197 | PIPEnsSendBulkOut(pDevice,pContext); |
| 2198 | return ; |
| 2199 | |
| 2200 | } |
| 2201 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2202 | //TYPE_AC0DMA data tx |
| 2203 | /* |
| 2204 | * Description: |
| 2205 | * Tx packet via AC0DMA(DMA1) |
| 2206 | * |
| 2207 | * Parameters: |
| 2208 | * In: |
| 2209 | * pDevice - Pointer to the adapter |
| 2210 | * skb - Pointer to tx skb packet |
| 2211 | * Out: |
| 2212 | * void |
| 2213 | * |
| 2214 | * Return Value: NULL |
| 2215 | */ |
| 2216 | |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 2217 | int nsDMA_tx_packet(struct vnt_private *pDevice, |
| 2218 | u32 uDMAIdx, struct sk_buff *skb) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2219 | { |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 2220 | struct net_device_stats *pStats = &pDevice->stats; |
| 2221 | struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; |
Malcolm Priestley | f39c0d8 | 2013-08-15 19:34:37 +0100 | [diff] [blame] | 2222 | struct vnt_tx_buffer *pTX_Buffer; |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 2223 | u32 BytesToWrite = 0, uHeaderLen = 0; |
| 2224 | u32 uNodeIndex = 0; |
| 2225 | u8 byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80}; |
| 2226 | u16 wAID; |
| 2227 | u8 byPktType; |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 2228 | int bNeedEncryption = false; |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 2229 | PSKeyItem pTransmitKey = NULL; |
| 2230 | SKeyItem STempKey; |
| 2231 | int ii; |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 2232 | int bTKIP_UseGTK = false; |
| 2233 | int bNeedDeAuth = false; |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 2234 | u8 *pbyBSSID; |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 2235 | int bNodeExist = false; |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 2236 | PUSB_SEND_CONTEXT pContext; |
Andres More | dfdcc42 | 2013-02-12 20:36:28 -0500 | [diff] [blame] | 2237 | bool fConvertedPacket; |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 2238 | u32 status; |
| 2239 | u16 wKeepRate = pDevice->wCurrentRate; |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 2240 | int bTxeapol_key = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2241 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2242 | if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) { |
| 2243 | |
| 2244 | if (pDevice->uAssocCount == 0) { |
| 2245 | dev_kfree_skb_irq(skb); |
| 2246 | return 0; |
| 2247 | } |
| 2248 | |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 2249 | if (is_multicast_ether_addr((u8 *)(skb->data))) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2250 | uNodeIndex = 0; |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 2251 | bNodeExist = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2252 | if (pMgmt->sNodeDBTable[0].bPSEnable) { |
| 2253 | |
| 2254 | skb_queue_tail(&(pMgmt->sNodeDBTable[0].sTxPSQueue), skb); |
| 2255 | pMgmt->sNodeDBTable[0].wEnQueueCnt++; |
| 2256 | // set tx map |
| 2257 | pMgmt->abyPSTxMap[0] |= byMask[0]; |
| 2258 | return 0; |
| 2259 | } |
Masanari Iida | 9318469 | 2012-08-13 21:21:50 +0900 | [diff] [blame] | 2260 | // multicast/broadcast data rate |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2261 | |
| 2262 | if (pDevice->byBBType != BB_TYPE_11A) |
| 2263 | pDevice->wCurrentRate = RATE_2M; |
| 2264 | else |
| 2265 | pDevice->wCurrentRate = RATE_24M; |
| 2266 | // long preamble type |
| 2267 | pDevice->byPreambleType = PREAMBLE_SHORT; |
| 2268 | |
| 2269 | }else { |
| 2270 | |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 2271 | if (BSSbIsSTAInNodeDB(pDevice, (u8 *)(skb->data), &uNodeIndex)) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2272 | |
| 2273 | if (pMgmt->sNodeDBTable[uNodeIndex].bPSEnable) { |
| 2274 | |
| 2275 | skb_queue_tail(&pMgmt->sNodeDBTable[uNodeIndex].sTxPSQueue, skb); |
| 2276 | |
| 2277 | pMgmt->sNodeDBTable[uNodeIndex].wEnQueueCnt++; |
| 2278 | // set tx map |
| 2279 | wAID = pMgmt->sNodeDBTable[uNodeIndex].wAID; |
| 2280 | pMgmt->abyPSTxMap[wAID >> 3] |= byMask[wAID & 7]; |
| 2281 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set:pMgmt->abyPSTxMap[%d]= %d\n", |
| 2282 | (wAID >> 3), pMgmt->abyPSTxMap[wAID >> 3]); |
| 2283 | |
| 2284 | return 0; |
| 2285 | } |
| 2286 | // AP rate decided from node |
| 2287 | pDevice->wCurrentRate = pMgmt->sNodeDBTable[uNodeIndex].wTxDataRate; |
| 2288 | // tx preamble decided from node |
| 2289 | |
| 2290 | if (pMgmt->sNodeDBTable[uNodeIndex].bShortPreamble) { |
| 2291 | pDevice->byPreambleType = pDevice->byShortPreamble; |
| 2292 | |
| 2293 | }else { |
| 2294 | pDevice->byPreambleType = PREAMBLE_LONG; |
| 2295 | } |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 2296 | bNodeExist = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2297 | } |
| 2298 | } |
| 2299 | |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 2300 | if (bNodeExist == false) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2301 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG"Unknown STA not found in node DB \n"); |
| 2302 | dev_kfree_skb_irq(skb); |
| 2303 | return 0; |
| 2304 | } |
| 2305 | } |
| 2306 | |
| 2307 | pContext = (PUSB_SEND_CONTEXT)s_vGetFreeContext(pDevice); |
| 2308 | |
| 2309 | if (pContext == NULL) { |
| 2310 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG" pContext == NULL\n"); |
| 2311 | dev_kfree_skb_irq(skb); |
| 2312 | return STATUS_RESOURCES; |
| 2313 | } |
| 2314 | |
Andres More | ceb8c5d | 2013-03-18 20:33:49 -0500 | [diff] [blame] | 2315 | memcpy(pDevice->sTxEthHeader.h_dest, (u8 *)(skb->data), ETH_HLEN); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2316 | |
| 2317 | //mike add:station mode check eapol-key challenge---> |
| 2318 | { |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 2319 | u8 Protocol_Version; //802.1x Authentication |
| 2320 | u8 Packet_Type; //802.1x Authentication |
| 2321 | u8 Descriptor_type; |
Andres More | 3eaca0d | 2013-02-25 20:32:52 -0500 | [diff] [blame] | 2322 | u16 Key_info; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2323 | |
Charles Clément | 21ec51f | 2010-05-18 10:08:14 -0700 | [diff] [blame] | 2324 | Protocol_Version = skb->data[ETH_HLEN]; |
| 2325 | Packet_Type = skb->data[ETH_HLEN+1]; |
| 2326 | Descriptor_type = skb->data[ETH_HLEN+1+1+2]; |
| 2327 | Key_info = (skb->data[ETH_HLEN+1+1+2+1] << 8)|(skb->data[ETH_HLEN+1+1+2+2]); |
Andres More | ceb8c5d | 2013-03-18 20:33:49 -0500 | [diff] [blame] | 2328 | if (pDevice->sTxEthHeader.h_proto == cpu_to_be16(ETH_P_PAE)) { |
Malcolm Priestley | aa209ee | 2012-08-29 23:08:21 +0100 | [diff] [blame] | 2329 | /* 802.1x OR eapol-key challenge frame transfer */ |
| 2330 | if (((Protocol_Version == 1) || (Protocol_Version == 2)) && |
| 2331 | (Packet_Type == 3)) { |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 2332 | bTxeapol_key = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2333 | if(!(Key_info & BIT3) && //WPA or RSN group-key challenge |
| 2334 | (Key_info & BIT8) && (Key_info & BIT9)) { //send 2/2 key |
| 2335 | if(Descriptor_type==254) { |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 2336 | pDevice->fWPA_Authened = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2337 | PRINT_K("WPA "); |
| 2338 | } |
| 2339 | else { |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 2340 | pDevice->fWPA_Authened = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2341 | PRINT_K("WPA2(re-keying) "); |
| 2342 | } |
| 2343 | PRINT_K("Authentication completed!!\n"); |
| 2344 | } |
Justin P. Mattock | a0a1f61 | 2012-08-26 08:16:43 -0700 | [diff] [blame] | 2345 | else if((Key_info & BIT3) && (Descriptor_type==2) && //RSN pairwise-key challenge |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2346 | (Key_info & BIT8) && (Key_info & BIT9)) { |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 2347 | pDevice->fWPA_Authened = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2348 | PRINT_K("WPA2 Authentication completed!!\n"); |
| 2349 | } |
| 2350 | } |
| 2351 | } |
| 2352 | } |
| 2353 | //mike add:station mode check eapol-key challenge<--- |
| 2354 | |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 2355 | if (pDevice->bEncryptionEnable == true) { |
| 2356 | bNeedEncryption = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2357 | // get Transmit key |
| 2358 | do { |
| 2359 | if ((pMgmt->eCurrMode == WMAC_MODE_ESS_STA) && |
| 2360 | (pMgmt->eCurrState == WMAC_STATE_ASSOC)) { |
| 2361 | pbyBSSID = pDevice->abyBSSID; |
| 2362 | // get pairwise key |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 2363 | if (KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, PAIRWISE_KEY, &pTransmitKey) == false) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2364 | // get group key |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 2365 | if(KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, GROUP_KEY, &pTransmitKey) == true) { |
| 2366 | bTKIP_UseGTK = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2367 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG"Get GTK.\n"); |
| 2368 | break; |
| 2369 | } |
| 2370 | } else { |
| 2371 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG"Get PTK.\n"); |
| 2372 | break; |
| 2373 | } |
| 2374 | }else if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) { |
Andres More | ceb8c5d | 2013-03-18 20:33:49 -0500 | [diff] [blame] | 2375 | /* TO_DS = 0 and FROM_DS = 0 --> 802.11 MAC Address1 */ |
| 2376 | pbyBSSID = pDevice->sTxEthHeader.h_dest; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2377 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG"IBSS Serach Key: \n"); |
| 2378 | for (ii = 0; ii< 6; ii++) |
| 2379 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG"%x \n", *(pbyBSSID+ii)); |
| 2380 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG"\n"); |
| 2381 | |
| 2382 | // get pairwise key |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 2383 | if(KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, PAIRWISE_KEY, &pTransmitKey) == true) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2384 | break; |
| 2385 | } |
| 2386 | // get group key |
| 2387 | pbyBSSID = pDevice->abyBroadcastAddr; |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 2388 | if(KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, GROUP_KEY, &pTransmitKey) == false) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2389 | pTransmitKey = NULL; |
| 2390 | if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) { |
| 2391 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG"IBSS and KEY is NULL. [%d]\n", pMgmt->eCurrMode); |
| 2392 | } |
| 2393 | else |
| 2394 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG"NOT IBSS and KEY is NULL. [%d]\n", pMgmt->eCurrMode); |
| 2395 | } else { |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 2396 | bTKIP_UseGTK = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2397 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG"Get GTK.\n"); |
| 2398 | } |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 2399 | } while(false); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2400 | } |
| 2401 | |
| 2402 | if (pDevice->bEnableHostWEP) { |
| 2403 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG"acdma0: STA index %d\n", uNodeIndex); |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 2404 | if (pDevice->bEncryptionEnable == true) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2405 | pTransmitKey = &STempKey; |
| 2406 | pTransmitKey->byCipherSuite = pMgmt->sNodeDBTable[uNodeIndex].byCipherSuite; |
| 2407 | pTransmitKey->dwKeyIndex = pMgmt->sNodeDBTable[uNodeIndex].dwKeyIndex; |
| 2408 | pTransmitKey->uKeyLength = pMgmt->sNodeDBTable[uNodeIndex].uWepKeyLength; |
| 2409 | pTransmitKey->dwTSC47_16 = pMgmt->sNodeDBTable[uNodeIndex].dwTSC47_16; |
| 2410 | pTransmitKey->wTSC15_0 = pMgmt->sNodeDBTable[uNodeIndex].wTSC15_0; |
| 2411 | memcpy(pTransmitKey->abyKey, |
| 2412 | &pMgmt->sNodeDBTable[uNodeIndex].abyWepKey[0], |
| 2413 | pTransmitKey->uKeyLength |
| 2414 | ); |
| 2415 | } |
| 2416 | } |
| 2417 | |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 2418 | byPktType = (u8)pDevice->byPacketType; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2419 | |
| 2420 | if (pDevice->bFixRate) { |
| 2421 | if (pDevice->byBBType == BB_TYPE_11B) { |
| 2422 | if (pDevice->uConnectionRate >= RATE_11M) { |
| 2423 | pDevice->wCurrentRate = RATE_11M; |
| 2424 | } else { |
Andres More | 3eaca0d | 2013-02-25 20:32:52 -0500 | [diff] [blame] | 2425 | pDevice->wCurrentRate = (u16)pDevice->uConnectionRate; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2426 | } |
| 2427 | } else { |
| 2428 | if ((pDevice->byBBType == BB_TYPE_11A) && |
| 2429 | (pDevice->uConnectionRate <= RATE_6M)) { |
| 2430 | pDevice->wCurrentRate = RATE_6M; |
| 2431 | } else { |
| 2432 | if (pDevice->uConnectionRate >= RATE_54M) |
| 2433 | pDevice->wCurrentRate = RATE_54M; |
| 2434 | else |
Andres More | 3eaca0d | 2013-02-25 20:32:52 -0500 | [diff] [blame] | 2435 | pDevice->wCurrentRate = (u16)pDevice->uConnectionRate; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2436 | } |
| 2437 | } |
| 2438 | } |
| 2439 | else { |
| 2440 | if (pDevice->eOPMode == OP_MODE_ADHOC) { |
| 2441 | // Adhoc Tx rate decided from node DB |
Andres More | ceb8c5d | 2013-03-18 20:33:49 -0500 | [diff] [blame] | 2442 | if (is_multicast_ether_addr(pDevice->sTxEthHeader.h_dest)) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2443 | // Multicast use highest data rate |
| 2444 | pDevice->wCurrentRate = pMgmt->sNodeDBTable[0].wTxDataRate; |
| 2445 | // preamble type |
| 2446 | pDevice->byPreambleType = pDevice->byShortPreamble; |
| 2447 | } |
| 2448 | else { |
Andres More | ceb8c5d | 2013-03-18 20:33:49 -0500 | [diff] [blame] | 2449 | if (BSSbIsSTAInNodeDB(pDevice, &(pDevice->sTxEthHeader.h_dest[0]), &uNodeIndex)) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2450 | pDevice->wCurrentRate = pMgmt->sNodeDBTable[uNodeIndex].wTxDataRate; |
| 2451 | if (pMgmt->sNodeDBTable[uNodeIndex].bShortPreamble) { |
| 2452 | pDevice->byPreambleType = pDevice->byShortPreamble; |
| 2453 | |
| 2454 | } |
| 2455 | else { |
| 2456 | pDevice->byPreambleType = PREAMBLE_LONG; |
| 2457 | } |
| 2458 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Found Node Index is [%d] Tx Data Rate:[%d]\n",uNodeIndex, pDevice->wCurrentRate); |
| 2459 | } |
| 2460 | else { |
| 2461 | if (pDevice->byBBType != BB_TYPE_11A) |
| 2462 | pDevice->wCurrentRate = RATE_2M; |
| 2463 | else |
| 2464 | pDevice->wCurrentRate = RATE_24M; // refer to vMgrCreateOwnIBSS()'s |
| 2465 | // abyCurrExtSuppRates[] |
| 2466 | pDevice->byPreambleType = PREAMBLE_SHORT; |
| 2467 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Not Found Node use highest basic Rate.....\n"); |
| 2468 | } |
| 2469 | } |
| 2470 | } |
| 2471 | if (pDevice->eOPMode == OP_MODE_INFRASTRUCTURE) { |
| 2472 | // Infra STA rate decided from AP Node, index = 0 |
| 2473 | pDevice->wCurrentRate = pMgmt->sNodeDBTable[0].wTxDataRate; |
| 2474 | } |
| 2475 | } |
| 2476 | |
Andres More | ceb8c5d | 2013-03-18 20:33:49 -0500 | [diff] [blame] | 2477 | if (pDevice->sTxEthHeader.h_proto == cpu_to_be16(ETH_P_PAE)) { |
Malcolm Priestley | aa209ee | 2012-08-29 23:08:21 +0100 | [diff] [blame] | 2478 | if (pDevice->byBBType != BB_TYPE_11A) { |
| 2479 | pDevice->wCurrentRate = RATE_1M; |
| 2480 | pDevice->byACKRate = RATE_1M; |
| 2481 | pDevice->byTopCCKBasicRate = RATE_1M; |
| 2482 | pDevice->byTopOFDMBasicRate = RATE_6M; |
| 2483 | } else { |
| 2484 | pDevice->wCurrentRate = RATE_6M; |
| 2485 | pDevice->byACKRate = RATE_6M; |
| 2486 | pDevice->byTopCCKBasicRate = RATE_1M; |
| 2487 | pDevice->byTopOFDMBasicRate = RATE_6M; |
| 2488 | } |
| 2489 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2490 | |
Andres More | 0cbd8d9 | 2010-05-06 20:34:29 -0300 | [diff] [blame] | 2491 | DBG_PRT(MSG_LEVEL_DEBUG, |
| 2492 | KERN_INFO "dma_tx: pDevice->wCurrentRate = %d\n", |
| 2493 | pDevice->wCurrentRate); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2494 | |
| 2495 | if (wKeepRate != pDevice->wCurrentRate) { |
Andres More | 0cbd8d9 | 2010-05-06 20:34:29 -0300 | [diff] [blame] | 2496 | bScheduleCommand((void *) pDevice, WLAN_CMD_SETPOWER, NULL); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2497 | } |
| 2498 | |
| 2499 | if (pDevice->wCurrentRate <= RATE_11M) { |
| 2500 | byPktType = PK_TYPE_11B; |
| 2501 | } |
| 2502 | |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 2503 | if (bNeedEncryption == true) { |
Andres More | ceb8c5d | 2013-03-18 20:33:49 -0500 | [diff] [blame] | 2504 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ntohs Pkt Type=%04x\n", ntohs(pDevice->sTxEthHeader.h_proto)); |
| 2505 | if ((pDevice->sTxEthHeader.h_proto) == cpu_to_be16(ETH_P_PAE)) { |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 2506 | bNeedEncryption = false; |
Andres More | ceb8c5d | 2013-03-18 20:33:49 -0500 | [diff] [blame] | 2507 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Pkt Type=%04x\n", (pDevice->sTxEthHeader.h_proto)); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2508 | if ((pMgmt->eCurrMode == WMAC_MODE_ESS_STA) && (pMgmt->eCurrState == WMAC_STATE_ASSOC)) { |
| 2509 | if (pTransmitKey == NULL) { |
| 2510 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Don't Find TX KEY\n"); |
| 2511 | } |
| 2512 | else { |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 2513 | if (bTKIP_UseGTK == true) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2514 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"error: KEY is GTK!!~~\n"); |
| 2515 | } |
| 2516 | else { |
Malcolm Priestley | b4dc03a | 2012-11-11 15:45:52 +0000 | [diff] [blame] | 2517 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Find PTK [%X]\n", |
| 2518 | pTransmitKey->dwKeyIndex); |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 2519 | bNeedEncryption = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2520 | } |
| 2521 | } |
| 2522 | } |
| 2523 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2524 | if (pDevice->bEnableHostWEP) { |
| 2525 | if ((uNodeIndex != 0) && |
| 2526 | (pMgmt->sNodeDBTable[uNodeIndex].dwKeyIndex & PAIRWISE_KEY)) { |
Malcolm Priestley | b4dc03a | 2012-11-11 15:45:52 +0000 | [diff] [blame] | 2527 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Find PTK [%X]\n", |
| 2528 | pTransmitKey->dwKeyIndex); |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 2529 | bNeedEncryption = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2530 | } |
| 2531 | } |
| 2532 | } |
| 2533 | else { |
| 2534 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2535 | if (pTransmitKey == NULL) { |
| 2536 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"return no tx key\n"); |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 2537 | pContext->bBoolInUse = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2538 | dev_kfree_skb_irq(skb); |
| 2539 | pStats->tx_dropped++; |
| 2540 | return STATUS_FAILURE; |
| 2541 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2542 | } |
| 2543 | } |
| 2544 | |
Malcolm Priestley | d0a2b8f | 2013-08-15 19:37:04 +0100 | [diff] [blame] | 2545 | pTX_Buffer = (struct vnt_tx_buffer *)&pContext->Data[0]; |
| 2546 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2547 | fConvertedPacket = s_bPacketToWirelessUsb(pDevice, byPktType, |
Malcolm Priestley | d0a2b8f | 2013-08-15 19:37:04 +0100 | [diff] [blame] | 2548 | pTX_Buffer, bNeedEncryption, |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2549 | skb->len, uDMAIdx, &pDevice->sTxEthHeader, |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 2550 | (u8 *)skb->data, pTransmitKey, uNodeIndex, |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2551 | pDevice->wCurrentRate, |
| 2552 | &uHeaderLen, &BytesToWrite |
| 2553 | ); |
| 2554 | |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 2555 | if (fConvertedPacket == false) { |
| 2556 | pContext->bBoolInUse = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2557 | dev_kfree_skb_irq(skb); |
| 2558 | return STATUS_FAILURE; |
| 2559 | } |
| 2560 | |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 2561 | if ( pDevice->bEnablePSMode == true ) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2562 | if ( !pDevice->bPSModeTxBurst ) { |
Andres More | 0cbd8d9 | 2010-05-06 20:34:29 -0300 | [diff] [blame] | 2563 | bScheduleCommand((void *) pDevice, |
| 2564 | WLAN_CMD_MAC_DISPOWERSAVING, |
| 2565 | NULL); |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 2566 | pDevice->bPSModeTxBurst = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2567 | } |
| 2568 | } |
| 2569 | |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 2570 | pTX_Buffer->byPKTNO = (u8) (((pDevice->wCurrentRate<<4) &0x00F0) | ((pDevice->wSeqCounter - 1) & 0x000F)); |
Andres More | 3eaca0d | 2013-02-25 20:32:52 -0500 | [diff] [blame] | 2571 | pTX_Buffer->wTxByteCount = (u16)BytesToWrite; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2572 | |
| 2573 | pContext->pPacket = skb; |
| 2574 | pContext->Type = CONTEXT_DATA_PACKET; |
Andres More | 3eaca0d | 2013-02-25 20:32:52 -0500 | [diff] [blame] | 2575 | pContext->uBufLen = (u16)BytesToWrite + 4 ; //USB header |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2576 | |
Andres More | ceb8c5d | 2013-03-18 20:33:49 -0500 | [diff] [blame] | 2577 | s_vSaveTxPktInfo(pDevice, (u8) (pTX_Buffer->byPKTNO & 0x0F), &(pContext->sEthHeader.h_dest[0]), (u16) (BytesToWrite-uHeaderLen), pTX_Buffer->wFIFOCtl); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2578 | |
| 2579 | status = PIPEnsSendBulkOut(pDevice,pContext); |
| 2580 | |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 2581 | if (bNeedDeAuth == true) { |
Andres More | 3eaca0d | 2013-02-25 20:32:52 -0500 | [diff] [blame] | 2582 | u16 wReason = WLAN_MGMT_REASON_MIC_FAILURE; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2583 | |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 2584 | bScheduleCommand((void *) pDevice, WLAN_CMD_DEAUTH, (u8 *) &wReason); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2585 | } |
| 2586 | |
| 2587 | if(status!=STATUS_PENDING) { |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 2588 | pContext->bBoolInUse = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2589 | dev_kfree_skb_irq(skb); |
| 2590 | return STATUS_FAILURE; |
| 2591 | } |
| 2592 | else |
| 2593 | return 0; |
| 2594 | |
| 2595 | } |
| 2596 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2597 | /* |
| 2598 | * Description: |
| 2599 | * Relay packet send (AC1DMA) from rx dpc. |
| 2600 | * |
| 2601 | * Parameters: |
| 2602 | * In: |
| 2603 | * pDevice - Pointer to the adapter |
| 2604 | * pPacket - Pointer to rx packet |
| 2605 | * cbPacketSize - rx ethernet frame size |
| 2606 | * Out: |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 2607 | * TURE, false |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2608 | * |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 2609 | * Return Value: Return true if packet is copy to dma1; otherwise false |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2610 | */ |
| 2611 | |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 2612 | int bRelayPacketSend(struct vnt_private *pDevice, u8 *pbySkbData, u32 uDataLen, |
| 2613 | u32 uNodeIndex) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2614 | { |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 2615 | struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; |
Malcolm Priestley | f39c0d8 | 2013-08-15 19:34:37 +0100 | [diff] [blame] | 2616 | struct vnt_tx_buffer *pTX_Buffer; |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 2617 | u32 BytesToWrite = 0, uHeaderLen = 0; |
| 2618 | u8 byPktType = PK_TYPE_11B; |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 2619 | int bNeedEncryption = false; |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 2620 | SKeyItem STempKey; |
| 2621 | PSKeyItem pTransmitKey = NULL; |
| 2622 | u8 *pbyBSSID; |
| 2623 | PUSB_SEND_CONTEXT pContext; |
| 2624 | u8 byPktTyp; |
| 2625 | int fConvertedPacket; |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 2626 | u32 status; |
| 2627 | u16 wKeepRate = pDevice->wCurrentRate; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2628 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2629 | pContext = (PUSB_SEND_CONTEXT)s_vGetFreeContext(pDevice); |
| 2630 | |
| 2631 | if (NULL == pContext) { |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 2632 | return false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2633 | } |
| 2634 | |
Andres More | ceb8c5d | 2013-03-18 20:33:49 -0500 | [diff] [blame] | 2635 | memcpy(pDevice->sTxEthHeader.h_dest, (u8 *)pbySkbData, ETH_HLEN); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2636 | |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 2637 | if (pDevice->bEncryptionEnable == true) { |
| 2638 | bNeedEncryption = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2639 | // get group key |
| 2640 | pbyBSSID = pDevice->abyBroadcastAddr; |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 2641 | if(KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, GROUP_KEY, &pTransmitKey) == false) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2642 | pTransmitKey = NULL; |
| 2643 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG"KEY is NULL. [%d]\n", pMgmt->eCurrMode); |
| 2644 | } else { |
| 2645 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG"Get GTK.\n"); |
| 2646 | } |
| 2647 | } |
| 2648 | |
| 2649 | if (pDevice->bEnableHostWEP) { |
Roel Kluin | ee93e19 | 2009-10-16 20:17:57 +0200 | [diff] [blame] | 2650 | if (uNodeIndex < MAX_NODE_NUM + 1) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2651 | pTransmitKey = &STempKey; |
| 2652 | pTransmitKey->byCipherSuite = pMgmt->sNodeDBTable[uNodeIndex].byCipherSuite; |
| 2653 | pTransmitKey->dwKeyIndex = pMgmt->sNodeDBTable[uNodeIndex].dwKeyIndex; |
| 2654 | pTransmitKey->uKeyLength = pMgmt->sNodeDBTable[uNodeIndex].uWepKeyLength; |
| 2655 | pTransmitKey->dwTSC47_16 = pMgmt->sNodeDBTable[uNodeIndex].dwTSC47_16; |
| 2656 | pTransmitKey->wTSC15_0 = pMgmt->sNodeDBTable[uNodeIndex].wTSC15_0; |
| 2657 | memcpy(pTransmitKey->abyKey, |
| 2658 | &pMgmt->sNodeDBTable[uNodeIndex].abyWepKey[0], |
| 2659 | pTransmitKey->uKeyLength |
| 2660 | ); |
| 2661 | } |
| 2662 | } |
| 2663 | |
| 2664 | if ( bNeedEncryption && (pTransmitKey == NULL) ) { |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 2665 | pContext->bBoolInUse = false; |
| 2666 | return false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2667 | } |
| 2668 | |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 2669 | byPktTyp = (u8)pDevice->byPacketType; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2670 | |
| 2671 | if (pDevice->bFixRate) { |
| 2672 | if (pDevice->byBBType == BB_TYPE_11B) { |
| 2673 | if (pDevice->uConnectionRate >= RATE_11M) { |
| 2674 | pDevice->wCurrentRate = RATE_11M; |
| 2675 | } else { |
Andres More | 3eaca0d | 2013-02-25 20:32:52 -0500 | [diff] [blame] | 2676 | pDevice->wCurrentRate = (u16)pDevice->uConnectionRate; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2677 | } |
| 2678 | } else { |
| 2679 | if ((pDevice->byBBType == BB_TYPE_11A) && |
| 2680 | (pDevice->uConnectionRate <= RATE_6M)) { |
| 2681 | pDevice->wCurrentRate = RATE_6M; |
| 2682 | } else { |
| 2683 | if (pDevice->uConnectionRate >= RATE_54M) |
| 2684 | pDevice->wCurrentRate = RATE_54M; |
| 2685 | else |
Andres More | 3eaca0d | 2013-02-25 20:32:52 -0500 | [diff] [blame] | 2686 | pDevice->wCurrentRate = (u16)pDevice->uConnectionRate; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2687 | } |
| 2688 | } |
| 2689 | } |
| 2690 | else { |
| 2691 | pDevice->wCurrentRate = pMgmt->sNodeDBTable[uNodeIndex].wTxDataRate; |
| 2692 | } |
| 2693 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2694 | if (wKeepRate != pDevice->wCurrentRate) { |
Andres More | 0cbd8d9 | 2010-05-06 20:34:29 -0300 | [diff] [blame] | 2695 | bScheduleCommand((void *) pDevice, WLAN_CMD_SETPOWER, NULL); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2696 | } |
| 2697 | |
| 2698 | if (pDevice->wCurrentRate <= RATE_11M) |
| 2699 | byPktType = PK_TYPE_11B; |
| 2700 | |
Andres More | abad19d | 2010-07-12 16:28:32 -0300 | [diff] [blame] | 2701 | BytesToWrite = uDataLen + ETH_FCS_LEN; |
| 2702 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2703 | // Convert the packet to an usb frame and copy into our buffer |
| 2704 | // and send the irp. |
| 2705 | |
Malcolm Priestley | d0a2b8f | 2013-08-15 19:37:04 +0100 | [diff] [blame] | 2706 | pTX_Buffer = (struct vnt_tx_buffer *)&pContext->Data[0]; |
| 2707 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2708 | fConvertedPacket = s_bPacketToWirelessUsb(pDevice, byPktType, |
Malcolm Priestley | d0a2b8f | 2013-08-15 19:37:04 +0100 | [diff] [blame] | 2709 | pTX_Buffer, bNeedEncryption, |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2710 | uDataLen, TYPE_AC0DMA, &pDevice->sTxEthHeader, |
| 2711 | pbySkbData, pTransmitKey, uNodeIndex, |
| 2712 | pDevice->wCurrentRate, |
| 2713 | &uHeaderLen, &BytesToWrite |
| 2714 | ); |
| 2715 | |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 2716 | if (fConvertedPacket == false) { |
| 2717 | pContext->bBoolInUse = false; |
| 2718 | return false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2719 | } |
| 2720 | |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 2721 | pTX_Buffer->byPKTNO = (u8) (((pDevice->wCurrentRate<<4) &0x00F0) | ((pDevice->wSeqCounter - 1) & 0x000F)); |
Andres More | 3eaca0d | 2013-02-25 20:32:52 -0500 | [diff] [blame] | 2722 | pTX_Buffer->wTxByteCount = (u16)BytesToWrite; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2723 | |
| 2724 | pContext->pPacket = NULL; |
| 2725 | pContext->Type = CONTEXT_DATA_PACKET; |
Andres More | 3eaca0d | 2013-02-25 20:32:52 -0500 | [diff] [blame] | 2726 | pContext->uBufLen = (u16)BytesToWrite + 4 ; //USB header |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2727 | |
Andres More | ceb8c5d | 2013-03-18 20:33:49 -0500 | [diff] [blame] | 2728 | s_vSaveTxPktInfo(pDevice, (u8) (pTX_Buffer->byPKTNO & 0x0F), &(pContext->sEthHeader.h_dest[0]), (u16) (BytesToWrite-uHeaderLen), pTX_Buffer->wFIFOCtl); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2729 | |
| 2730 | status = PIPEnsSendBulkOut(pDevice,pContext); |
| 2731 | |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 2732 | return true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 2733 | } |
| 2734 | |