Forest Bond | 5449c68 | 2009-04-25 10:30:44 -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 | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 29 | * vGenerateMACHeader - Translate 802.3 to 802.11 header |
Justin P. Mattock | 7664ec8 | 2012-08-20 08:43:15 -0700 | [diff] [blame] | 30 | * cbGetFragCount - Calculate fragment number count |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 31 | * csBeacon_xmit - beacon tx function |
| 32 | * csMgmt_xmit - management tx function |
| 33 | * s_cbFillTxBufHead - fulfill tx dma buffer header |
| 34 | * s_uGetDataDuration - get tx data required duration |
| 35 | * s_uFillDataHead- fulfill tx data duration header |
Gilles Espinasse | f77f13e | 2010-03-29 15:41:47 +0200 | [diff] [blame] | 36 | * s_uGetRTSCTSDuration- get rtx/cts required duration |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 37 | * s_uGetRTSCTSRsvTime- get rts/cts reserved time |
| 38 | * s_uGetTxRsvTime- get frame reserved time |
| 39 | * s_vFillCTSHead- fulfill CTS ctl header |
Gilles Espinasse | f77f13e | 2010-03-29 15:41:47 +0200 | [diff] [blame] | 40 | * s_vFillFragParameter- Set fragment ctl parameter. |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 41 | * s_vFillRTSHead- fulfill RTS ctl header |
| 42 | * s_vFillTxKey- fulfill tx encrypt key |
| 43 | * s_vSWencryption- Software encrypt header |
| 44 | * vDMA0_tx_80211- tx 802.11 frame via dma0 |
| 45 | * vGenerateFIFOHeader- Generate tx FIFO ctl header |
| 46 | * |
| 47 | * Revision History: |
| 48 | * |
| 49 | */ |
| 50 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 51 | #include "device.h" |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 52 | #include "rxtx.h" |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 53 | #include "tether.h" |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 54 | #include "card.h" |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 55 | #include "bssdb.h" |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 56 | #include "mac.h" |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 57 | #include "baseband.h" |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 58 | #include "michael.h" |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 59 | #include "tkip.h" |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 60 | #include "tcrc.h" |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 61 | #include "wctl.h" |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 62 | #include "wroute.h" |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 63 | #include "hostap.h" |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 64 | #include "rf.h" |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 65 | |
| 66 | /*--------------------- Static Definitions -------------------------*/ |
| 67 | |
| 68 | /*--------------------- Static Classes ----------------------------*/ |
| 69 | |
| 70 | /*--------------------- Static Variables --------------------------*/ |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 71 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 72 | /*--------------------- Static Functions --------------------------*/ |
| 73 | |
| 74 | /*--------------------- Static Definitions -------------------------*/ |
| 75 | #define CRITICAL_PACKET_LEN 256 // if packet size < 256 -> in-direct send |
| 76 | // packet size >= 256 -> direct send |
| 77 | |
Anton Protopopov | 83e771f | 2014-07-01 21:06:29 +0400 | [diff] [blame] | 78 | static const unsigned short wTimeStampOff[2][MAX_RATE] = { |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 79 | {384, 288, 226, 209, 54, 43, 37, 31, 28, 25, 24, 23}, // Long Preamble |
| 80 | {384, 192, 130, 113, 54, 43, 37, 31, 28, 25, 24, 23}, // Short Preamble |
| 81 | }; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 82 | |
Anton Protopopov | 83e771f | 2014-07-01 21:06:29 +0400 | [diff] [blame] | 83 | static const unsigned short wFB_Opt0[2][5] = { |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 84 | {RATE_12M, RATE_18M, RATE_24M, RATE_36M, RATE_48M}, // fallback_rate0 |
| 85 | {RATE_12M, RATE_12M, RATE_18M, RATE_24M, RATE_36M}, // fallback_rate1 |
| 86 | }; |
Anton Protopopov | 83e771f | 2014-07-01 21:06:29 +0400 | [diff] [blame] | 87 | static const unsigned short wFB_Opt1[2][5] = { |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 88 | {RATE_12M, RATE_18M, RATE_24M, RATE_24M, RATE_36M}, // fallback_rate0 |
| 89 | {RATE_6M , RATE_6M, RATE_12M, RATE_12M, RATE_18M}, // fallback_rate1 |
| 90 | }; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 91 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 92 | #define RTSDUR_BB 0 |
| 93 | #define RTSDUR_BA 1 |
| 94 | #define RTSDUR_AA 2 |
| 95 | #define CTSDUR_BA 3 |
| 96 | #define RTSDUR_BA_F0 4 |
| 97 | #define RTSDUR_AA_F0 5 |
| 98 | #define RTSDUR_BA_F1 6 |
| 99 | #define RTSDUR_AA_F1 7 |
| 100 | #define CTSDUR_BA_F0 8 |
| 101 | #define CTSDUR_BA_F1 9 |
| 102 | #define DATADUR_B 10 |
| 103 | #define DATADUR_A 11 |
| 104 | #define DATADUR_A_F0 12 |
| 105 | #define DATADUR_A_F1 13 |
| 106 | |
| 107 | /*--------------------- Static Functions --------------------------*/ |
| 108 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 109 | static |
Charles Clément | 6b35b7b | 2010-05-07 12:30:19 -0700 | [diff] [blame] | 110 | void |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 111 | s_vFillTxKey( |
Malcolm Priestley | cf76dc4 | 2014-08-10 15:46:59 +0100 | [diff] [blame] | 112 | struct vnt_private *pDevice, |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 113 | unsigned char *pbyBuf, |
| 114 | unsigned char *pbyIVHead, |
| 115 | PSKeyItem pTransmitKey, |
| 116 | unsigned char *pbyHdrBuf, |
| 117 | unsigned short wPayloadLen, |
| 118 | unsigned char *pMICHDR |
| 119 | ); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 120 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 121 | static |
Charles Clément | 6b35b7b | 2010-05-07 12:30:19 -0700 | [diff] [blame] | 122 | void |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 123 | s_vFillRTSHead( |
Malcolm Priestley | cf76dc4 | 2014-08-10 15:46:59 +0100 | [diff] [blame] | 124 | struct vnt_private *pDevice, |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 125 | unsigned char byPktType, |
| 126 | void *pvRTS, |
| 127 | unsigned int cbFrameLength, |
| 128 | bool bNeedAck, |
| 129 | bool bDisCRC, |
| 130 | PSEthernetHeader psEthHeader, |
| 131 | unsigned short wCurrentRate, |
| 132 | unsigned char byFBOption |
| 133 | ); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 134 | |
| 135 | static |
Charles Clément | 6b35b7b | 2010-05-07 12:30:19 -0700 | [diff] [blame] | 136 | void |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 137 | s_vGenerateTxParameter( |
Malcolm Priestley | cf76dc4 | 2014-08-10 15:46:59 +0100 | [diff] [blame] | 138 | struct vnt_private *pDevice, |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 139 | unsigned char byPktType, |
| 140 | void *pTxBufHead, |
| 141 | void *pvRrvTime, |
| 142 | void *pvRTS, |
| 143 | void *pvCTS, |
| 144 | unsigned int cbFrameSize, |
| 145 | bool bNeedACK, |
| 146 | unsigned int uDMAIdx, |
| 147 | PSEthernetHeader psEthHeader, |
| 148 | unsigned short wCurrentRate |
| 149 | ); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 150 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 151 | static void s_vFillFragParameter( |
Malcolm Priestley | cf76dc4 | 2014-08-10 15:46:59 +0100 | [diff] [blame] | 152 | struct vnt_private *pDevice, |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 153 | unsigned char *pbyBuffer, |
| 154 | unsigned int uTxType, |
| 155 | void *pvtdCurr, |
| 156 | unsigned short wFragType, |
| 157 | unsigned int cbReqCount |
| 158 | ); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 159 | |
Charles Clément | fe4f34b | 2010-06-25 10:48:53 -0700 | [diff] [blame] | 160 | static unsigned int |
Malcolm Priestley | cf76dc4 | 2014-08-10 15:46:59 +0100 | [diff] [blame] | 161 | s_cbFillTxBufHead(struct vnt_private *pDevice, unsigned char byPktType, |
| 162 | unsigned char *pbyTxBufferAddr, unsigned int cbFrameBodySize, |
| 163 | unsigned int uDMAIdx, PSTxDesc pHeadTD, |
| 164 | PSEthernetHeader psEthHeader, unsigned char *pPacket, |
| 165 | bool bNeedEncrypt, PSKeyItem pTransmitKey, |
| 166 | unsigned int uNodeIndex, unsigned int *puMACfragNum); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 167 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 168 | static |
Malcolm Priestley | a479ffc | 2014-08-30 22:25:38 +0100 | [diff] [blame] | 169 | __le16 |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 170 | s_uFillDataHead( |
Malcolm Priestley | cf76dc4 | 2014-08-10 15:46:59 +0100 | [diff] [blame] | 171 | struct vnt_private *pDevice, |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 172 | unsigned char byPktType, |
| 173 | void *pTxDataHead, |
| 174 | unsigned int cbFrameLength, |
| 175 | unsigned int uDMAIdx, |
| 176 | bool bNeedAck, |
| 177 | unsigned int uFragIdx, |
| 178 | unsigned int cbLastFragmentSize, |
| 179 | unsigned int uMACfragNum, |
| 180 | unsigned char byFBOption, |
| 181 | unsigned short wCurrentRate |
| 182 | ); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 183 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 184 | /*--------------------- Export Variables --------------------------*/ |
| 185 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 186 | static |
Charles Clément | 6b35b7b | 2010-05-07 12:30:19 -0700 | [diff] [blame] | 187 | void |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 188 | s_vFillTxKey( |
Malcolm Priestley | cf76dc4 | 2014-08-10 15:46:59 +0100 | [diff] [blame] | 189 | struct vnt_private *pDevice, |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 190 | unsigned char *pbyBuf, |
| 191 | unsigned char *pbyIVHead, |
| 192 | PSKeyItem pTransmitKey, |
| 193 | unsigned char *pbyHdrBuf, |
| 194 | unsigned short wPayloadLen, |
| 195 | unsigned char *pMICHDR |
| 196 | ) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 197 | { |
Malcolm Priestley | 11a72e5 | 2014-08-09 20:15:56 +0100 | [diff] [blame] | 198 | struct vnt_mic_hdr *mic_hdr = (struct vnt_mic_hdr *)pMICHDR; |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 199 | unsigned long *pdwIV = (unsigned long *)pbyIVHead; |
| 200 | unsigned long *pdwExtIV = (unsigned long *)((unsigned char *)pbyIVHead+4); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 201 | PS802_11Header pMACHeader = (PS802_11Header)pbyHdrBuf; |
| 202 | unsigned long dwRevIVCounter; |
| 203 | unsigned char byKeyIndex = 0; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 204 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 205 | //Fill TXKEY |
| 206 | if (pTransmitKey == NULL) |
| 207 | return; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 208 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 209 | dwRevIVCounter = cpu_to_le32(pDevice->dwIVCounter); |
| 210 | *pdwIV = pDevice->dwIVCounter; |
| 211 | byKeyIndex = pTransmitKey->dwKeyIndex & 0xf; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 212 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 213 | if (pTransmitKey->byCipherSuite == KEY_CTL_WEP) { |
| 214 | if (pTransmitKey->uKeyLength == WLAN_WEP232_KEYLEN) { |
| 215 | memcpy(pDevice->abyPRNG, (unsigned char *)&(dwRevIVCounter), 3); |
| 216 | memcpy(pDevice->abyPRNG+3, pTransmitKey->abyKey, pTransmitKey->uKeyLength); |
| 217 | } else { |
| 218 | memcpy(pbyBuf, (unsigned char *)&(dwRevIVCounter), 3); |
| 219 | memcpy(pbyBuf+3, pTransmitKey->abyKey, pTransmitKey->uKeyLength); |
| 220 | if (pTransmitKey->uKeyLength == WLAN_WEP40_KEYLEN) { |
| 221 | memcpy(pbyBuf+8, (unsigned char *)&(dwRevIVCounter), 3); |
| 222 | memcpy(pbyBuf+11, pTransmitKey->abyKey, pTransmitKey->uKeyLength); |
| 223 | } |
| 224 | memcpy(pDevice->abyPRNG, pbyBuf, 16); |
| 225 | } |
| 226 | // Append IV after Mac Header |
| 227 | *pdwIV &= WEP_IV_MASK;//00000000 11111111 11111111 11111111 |
| 228 | *pdwIV |= (unsigned long)byKeyIndex << 30; |
| 229 | *pdwIV = cpu_to_le32(*pdwIV); |
| 230 | pDevice->dwIVCounter++; |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 231 | if (pDevice->dwIVCounter > WEP_IV_MASK) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 232 | pDevice->dwIVCounter = 0; |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 233 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 234 | } else if (pTransmitKey->byCipherSuite == KEY_CTL_TKIP) { |
| 235 | pTransmitKey->wTSC15_0++; |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 236 | if (pTransmitKey->wTSC15_0 == 0) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 237 | pTransmitKey->dwTSC47_16++; |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 238 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 239 | TKIPvMixKey(pTransmitKey->abyKey, pDevice->abyCurrentNetAddr, |
| 240 | pTransmitKey->wTSC15_0, pTransmitKey->dwTSC47_16, pDevice->abyPRNG); |
| 241 | memcpy(pbyBuf, pDevice->abyPRNG, 16); |
| 242 | // Make IV |
| 243 | memcpy(pdwIV, pDevice->abyPRNG, 3); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 244 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 245 | *(pbyIVHead+3) = (unsigned char)(((byKeyIndex << 6) & 0xc0) | 0x20); // 0x20 is ExtIV |
| 246 | // Append IV&ExtIV after Mac Header |
| 247 | *pdwExtIV = cpu_to_le32(pTransmitKey->dwTSC47_16); |
Joe Perches | 48caf5a | 2014-08-17 09:17:04 -0700 | [diff] [blame] | 248 | pr_debug("vFillTxKey()---- pdwExtIV: %lx\n", *pdwExtIV); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 249 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 250 | } else if (pTransmitKey->byCipherSuite == KEY_CTL_CCMP) { |
| 251 | pTransmitKey->wTSC15_0++; |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 252 | if (pTransmitKey->wTSC15_0 == 0) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 253 | pTransmitKey->dwTSC47_16++; |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 254 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 255 | memcpy(pbyBuf, pTransmitKey->abyKey, 16); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 256 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 257 | // Make IV |
| 258 | *pdwIV = 0; |
| 259 | *(pbyIVHead+3) = (unsigned char)(((byKeyIndex << 6) & 0xc0) | 0x20); // 0x20 is ExtIV |
| 260 | *pdwIV |= cpu_to_le16((unsigned short)(pTransmitKey->wTSC15_0)); |
| 261 | //Append IV&ExtIV after Mac Header |
| 262 | *pdwExtIV = cpu_to_le32(pTransmitKey->dwTSC47_16); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 263 | |
Malcolm Priestley | 11a72e5 | 2014-08-09 20:15:56 +0100 | [diff] [blame] | 264 | /* MICHDR0 */ |
| 265 | mic_hdr->id = 0x59; |
| 266 | mic_hdr->tx_priority = 0; |
Aya Mahfouz | 2359b5c | 2014-10-11 02:42:45 +0200 | [diff] [blame^] | 267 | ether_addr_copy(mic_hdr->mic_addr2, pMACHeader->abyAddr2); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 268 | |
Malcolm Priestley | 11a72e5 | 2014-08-09 20:15:56 +0100 | [diff] [blame] | 269 | /* ccmp pn big endian order */ |
| 270 | mic_hdr->ccmp_pn[0] = (u8)(pTransmitKey->dwTSC47_16 >> 24); |
| 271 | mic_hdr->ccmp_pn[1] = (u8)(pTransmitKey->dwTSC47_16 >> 16); |
| 272 | mic_hdr->ccmp_pn[2] = (u8)(pTransmitKey->dwTSC47_16 >> 8); |
| 273 | mic_hdr->ccmp_pn[3] = (u8)pTransmitKey->dwTSC47_16; |
| 274 | mic_hdr->ccmp_pn[4] = (u8)(pTransmitKey->wTSC15_0 >> 8); |
| 275 | mic_hdr->ccmp_pn[5] = (u8)pTransmitKey->wTSC15_0; |
| 276 | |
| 277 | /* MICHDR1 */ |
| 278 | mic_hdr->payload_len = cpu_to_be16(wPayloadLen); |
| 279 | |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 280 | if (pDevice->bLongHeader) |
Malcolm Priestley | 11a72e5 | 2014-08-09 20:15:56 +0100 | [diff] [blame] | 281 | mic_hdr->hlen = cpu_to_be16(28); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 282 | else |
Malcolm Priestley | 11a72e5 | 2014-08-09 20:15:56 +0100 | [diff] [blame] | 283 | mic_hdr->hlen = cpu_to_be16(22); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 284 | |
Aya Mahfouz | 2359b5c | 2014-10-11 02:42:45 +0200 | [diff] [blame^] | 285 | ether_addr_copy(mic_hdr->addr1, pMACHeader->abyAddr1); |
| 286 | ether_addr_copy(mic_hdr->addr2, pMACHeader->abyAddr2); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 287 | |
Malcolm Priestley | 11a72e5 | 2014-08-09 20:15:56 +0100 | [diff] [blame] | 288 | /* MICHDR2 */ |
Aya Mahfouz | 2359b5c | 2014-10-11 02:42:45 +0200 | [diff] [blame^] | 289 | ether_addr_copy(mic_hdr->addr3, pMACHeader->abyAddr3); |
Malcolm Priestley | 11a72e5 | 2014-08-09 20:15:56 +0100 | [diff] [blame] | 290 | mic_hdr->frame_control = |
| 291 | cpu_to_le16(pMACHeader->wFrameCtl & 0xc78f); |
| 292 | mic_hdr->seq_ctrl = cpu_to_le16(pMACHeader->wSeqCtl & 0xf); |
| 293 | |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 294 | if (pDevice->bLongHeader) |
Aya Mahfouz | 2359b5c | 2014-10-11 02:42:45 +0200 | [diff] [blame^] | 295 | ether_addr_copy(mic_hdr->addr4, pMACHeader->abyAddr4); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 296 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 297 | } |
| 298 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 299 | static |
Charles Clément | 6b35b7b | 2010-05-07 12:30:19 -0700 | [diff] [blame] | 300 | void |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 301 | s_vSWencryption( |
Malcolm Priestley | cf76dc4 | 2014-08-10 15:46:59 +0100 | [diff] [blame] | 302 | struct vnt_private *pDevice, |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 303 | PSKeyItem pTransmitKey, |
| 304 | unsigned char *pbyPayloadHead, |
| 305 | unsigned short wPayloadSize |
| 306 | ) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 307 | { |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 308 | unsigned int cbICVlen = 4; |
| 309 | unsigned long dwICV = 0xFFFFFFFFL; |
| 310 | unsigned long *pdwICV; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 311 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 312 | if (pTransmitKey == NULL) |
| 313 | return; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 314 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 315 | if (pTransmitKey->byCipherSuite == KEY_CTL_WEP) { |
| 316 | //======================================================================= |
| 317 | // Append ICV after payload |
| 318 | dwICV = CRCdwGetCrc32Ex(pbyPayloadHead, wPayloadSize, dwICV);//ICV(Payload) |
| 319 | pdwICV = (unsigned long *)(pbyPayloadHead + wPayloadSize); |
| 320 | // finally, we must invert dwCRC to get the correct answer |
| 321 | *pdwICV = cpu_to_le32(~dwICV); |
| 322 | // RC4 encryption |
| 323 | rc4_init(&pDevice->SBox, pDevice->abyPRNG, pTransmitKey->uKeyLength + 3); |
| 324 | rc4_encrypt(&pDevice->SBox, pbyPayloadHead, pbyPayloadHead, wPayloadSize+cbICVlen); |
| 325 | //======================================================================= |
| 326 | } else if (pTransmitKey->byCipherSuite == KEY_CTL_TKIP) { |
| 327 | //======================================================================= |
| 328 | //Append ICV after payload |
| 329 | dwICV = CRCdwGetCrc32Ex(pbyPayloadHead, wPayloadSize, dwICV);//ICV(Payload) |
| 330 | pdwICV = (unsigned long *)(pbyPayloadHead + wPayloadSize); |
| 331 | // finally, we must invert dwCRC to get the correct answer |
| 332 | *pdwICV = cpu_to_le32(~dwICV); |
| 333 | // RC4 encryption |
| 334 | rc4_init(&pDevice->SBox, pDevice->abyPRNG, TKIP_KEY_LEN); |
| 335 | rc4_encrypt(&pDevice->SBox, pbyPayloadHead, pbyPayloadHead, wPayloadSize+cbICVlen); |
| 336 | //======================================================================= |
| 337 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 338 | } |
| 339 | |
Malcolm Priestley | d6b95c0 | 2014-08-30 22:25:33 +0100 | [diff] [blame] | 340 | static __le16 vnt_time_stamp_off(struct vnt_private *priv, u16 rate) |
| 341 | { |
| 342 | return cpu_to_le16(wTimeStampOff[priv->byPreambleType % 2] |
| 343 | [rate % MAX_RATE]); |
| 344 | } |
| 345 | |
Jim Lieb | 7e809a9 | 2009-07-30 10:27:21 -0700 | [diff] [blame] | 346 | /*byPktType : PK_TYPE_11A 0 |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 347 | PK_TYPE_11B 1 |
| 348 | PK_TYPE_11GB 2 |
| 349 | PK_TYPE_11GA 3 |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 350 | */ |
| 351 | static |
Charles Clément | b6e95cd | 2010-06-02 09:52:01 -0700 | [diff] [blame] | 352 | unsigned int |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 353 | s_uGetTxRsvTime( |
Malcolm Priestley | cf76dc4 | 2014-08-10 15:46:59 +0100 | [diff] [blame] | 354 | struct vnt_private *pDevice, |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 355 | unsigned char byPktType, |
| 356 | unsigned int cbFrameLength, |
| 357 | unsigned short wRate, |
| 358 | bool bNeedAck |
| 359 | ) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 360 | { |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 361 | unsigned int uDataTime, uAckTime; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 362 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 363 | uDataTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, cbFrameLength, wRate); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 364 | if (byPktType == PK_TYPE_11B) //llb,CCK mode |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 365 | uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, (unsigned short)pDevice->byTopCCKBasicRate); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 366 | else //11g 2.4G OFDM mode & 11a 5G OFDM mode |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 367 | uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, (unsigned short)pDevice->byTopOFDMBasicRate); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 368 | |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 369 | if (bNeedAck) |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 370 | return uDataTime + pDevice->uSIFS + uAckTime; |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 371 | else |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 372 | return uDataTime; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 373 | } |
| 374 | |
Malcolm Priestley | e7a3481b | 2014-08-30 22:25:30 +0100 | [diff] [blame] | 375 | static __le16 vnt_rxtx_rsvtime_le16(struct vnt_private *priv, u8 pkt_type, |
| 376 | u32 frame_length, u16 rate, bool need_ack) |
| 377 | { |
| 378 | return cpu_to_le16((u16)s_uGetTxRsvTime(priv, pkt_type, |
| 379 | frame_length, rate, need_ack)); |
| 380 | } |
| 381 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 382 | //byFreqType: 0=>5GHZ 1=>2.4GHZ |
| 383 | static |
Malcolm Priestley | 853532d | 2014-08-30 22:25:31 +0100 | [diff] [blame] | 384 | __le16 |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 385 | s_uGetRTSCTSRsvTime( |
Malcolm Priestley | cf76dc4 | 2014-08-10 15:46:59 +0100 | [diff] [blame] | 386 | struct vnt_private *pDevice, |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 387 | unsigned char byRTSRsvType, |
| 388 | unsigned char byPktType, |
| 389 | unsigned int cbFrameLength, |
| 390 | unsigned short wCurrentRate |
| 391 | ) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 392 | { |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 393 | unsigned int uRrvTime , uRTSTime, uCTSTime, uAckTime, uDataTime; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 394 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 395 | uRrvTime = uRTSTime = uCTSTime = uAckTime = uDataTime = 0; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 396 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 397 | uDataTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, cbFrameLength, wCurrentRate); |
| 398 | if (byRTSRsvType == 0) { //RTSTxRrvTime_bb |
| 399 | uRTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 20, pDevice->byTopCCKBasicRate); |
| 400 | uCTSTime = uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopCCKBasicRate); |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 401 | } else if (byRTSRsvType == 1) { //RTSTxRrvTime_ba, only in 2.4GHZ |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 402 | uRTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 20, pDevice->byTopCCKBasicRate); |
| 403 | uCTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopCCKBasicRate); |
| 404 | uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate); |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 405 | } else if (byRTSRsvType == 2) { //RTSTxRrvTime_aa |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 406 | uRTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 20, pDevice->byTopOFDMBasicRate); |
| 407 | uCTSTime = uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate); |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 408 | } else if (byRTSRsvType == 3) { //CTSTxRrvTime_ba, only in 2.4GHZ |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 409 | uCTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopCCKBasicRate); |
| 410 | uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate); |
| 411 | uRrvTime = uCTSTime + uAckTime + uDataTime + 2*pDevice->uSIFS; |
Malcolm Priestley | 853532d | 2014-08-30 22:25:31 +0100 | [diff] [blame] | 412 | return cpu_to_le16((u16)uRrvTime); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 413 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 414 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 415 | //RTSRrvTime |
| 416 | uRrvTime = uRTSTime + uCTSTime + uAckTime + uDataTime + 3*pDevice->uSIFS; |
Malcolm Priestley | 853532d | 2014-08-30 22:25:31 +0100 | [diff] [blame] | 417 | return cpu_to_le16((u16)uRrvTime); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 418 | } |
| 419 | |
| 420 | //byFreqType 0: 5GHz, 1:2.4Ghz |
| 421 | static |
Charles Clément | b6e95cd | 2010-06-02 09:52:01 -0700 | [diff] [blame] | 422 | unsigned int |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 423 | s_uGetDataDuration( |
Malcolm Priestley | cf76dc4 | 2014-08-10 15:46:59 +0100 | [diff] [blame] | 424 | struct vnt_private *pDevice, |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 425 | unsigned char byDurType, |
| 426 | unsigned int cbFrameLength, |
| 427 | unsigned char byPktType, |
| 428 | unsigned short wRate, |
| 429 | bool bNeedAck, |
| 430 | unsigned int uFragIdx, |
| 431 | unsigned int cbLastFragmentSize, |
| 432 | unsigned int uMACfragNum, |
| 433 | unsigned char byFBOption |
| 434 | ) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 435 | { |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 436 | bool bLastFrag = 0; |
| 437 | unsigned int uAckTime = 0, uNextPktTime = 0; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 438 | |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 439 | if (uFragIdx == (uMACfragNum-1)) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 440 | bLastFrag = 1; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 441 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 442 | switch (byDurType) { |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 443 | case DATADUR_B: //DATADUR_B |
Teodora Baluta | 649520b | 2013-11-10 17:12:44 +0200 | [diff] [blame] | 444 | if (((uMACfragNum == 1)) || bLastFrag) {//Non Frag or Last Frag |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 445 | if (bNeedAck) { |
| 446 | uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopCCKBasicRate); |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 447 | return pDevice->uSIFS + uAckTime; |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 448 | } else { |
| 449 | return 0; |
| 450 | } |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 451 | } else {//First Frag or Mid Frag |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 452 | if (uFragIdx == (uMACfragNum-2)) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 453 | uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbLastFragmentSize, wRate, bNeedAck); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 454 | else |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 455 | uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wRate, bNeedAck); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 456 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 457 | if (bNeedAck) { |
| 458 | uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopCCKBasicRate); |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 459 | return pDevice->uSIFS + uAckTime + uNextPktTime; |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 460 | } else { |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 461 | return pDevice->uSIFS + uNextPktTime; |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 462 | } |
| 463 | } |
| 464 | break; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 465 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 466 | case DATADUR_A: //DATADUR_A |
Teodora Baluta | 649520b | 2013-11-10 17:12:44 +0200 | [diff] [blame] | 467 | if (((uMACfragNum == 1)) || bLastFrag) {//Non Frag or Last Frag |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 468 | if (bNeedAck) { |
| 469 | uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate); |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 470 | return pDevice->uSIFS + uAckTime; |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 471 | } else { |
| 472 | return 0; |
| 473 | } |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 474 | } else {//First Frag or Mid Frag |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 475 | if (uFragIdx == (uMACfragNum-2)) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 476 | uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbLastFragmentSize, wRate, bNeedAck); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 477 | else |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 478 | uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wRate, bNeedAck); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 479 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 480 | if (bNeedAck) { |
| 481 | uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate); |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 482 | return pDevice->uSIFS + uAckTime + uNextPktTime; |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 483 | } else { |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 484 | return pDevice->uSIFS + uNextPktTime; |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 485 | } |
| 486 | } |
| 487 | break; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 488 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 489 | case DATADUR_A_F0: //DATADUR_A_F0 |
Teodora Baluta | 649520b | 2013-11-10 17:12:44 +0200 | [diff] [blame] | 490 | if (((uMACfragNum == 1)) || bLastFrag) {//Non Frag or Last Frag |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 491 | if (bNeedAck) { |
| 492 | uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate); |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 493 | return pDevice->uSIFS + uAckTime; |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 494 | } else { |
| 495 | return 0; |
| 496 | } |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 497 | } else { //First Frag or Mid Frag |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 498 | if (byFBOption == AUTO_FB_0) { |
| 499 | if (wRate < RATE_18M) |
| 500 | wRate = RATE_18M; |
| 501 | else if (wRate > RATE_54M) |
| 502 | wRate = RATE_54M; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 503 | |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 504 | if (uFragIdx == (uMACfragNum-2)) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 505 | uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbLastFragmentSize, wFB_Opt0[FB_RATE0][wRate-RATE_18M], bNeedAck); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 506 | else |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 507 | uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt0[FB_RATE0][wRate-RATE_18M], bNeedAck); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 508 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 509 | } else { // (byFBOption == AUTO_FB_1) |
| 510 | if (wRate < RATE_18M) |
| 511 | wRate = RATE_18M; |
| 512 | else if (wRate > RATE_54M) |
| 513 | wRate = RATE_54M; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 514 | |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 515 | if (uFragIdx == (uMACfragNum-2)) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 516 | uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbLastFragmentSize, wFB_Opt1[FB_RATE0][wRate-RATE_18M], bNeedAck); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 517 | else |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 518 | uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt1[FB_RATE0][wRate-RATE_18M], bNeedAck); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 519 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 520 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 521 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 522 | if (bNeedAck) { |
| 523 | uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate); |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 524 | return pDevice->uSIFS + uAckTime + uNextPktTime; |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 525 | } else { |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 526 | return pDevice->uSIFS + uNextPktTime; |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 527 | } |
| 528 | } |
| 529 | break; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 530 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 531 | case DATADUR_A_F1: //DATADUR_A_F1 |
Teodora Baluta | 649520b | 2013-11-10 17:12:44 +0200 | [diff] [blame] | 532 | if (((uMACfragNum == 1)) || bLastFrag) {//Non Frag or Last Frag |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 533 | if (bNeedAck) { |
| 534 | uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate); |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 535 | return pDevice->uSIFS + uAckTime; |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 536 | } else { |
| 537 | return 0; |
| 538 | } |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 539 | } else { //First Frag or Mid Frag |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 540 | if (byFBOption == AUTO_FB_0) { |
| 541 | if (wRate < RATE_18M) |
| 542 | wRate = RATE_18M; |
| 543 | else if (wRate > RATE_54M) |
| 544 | wRate = RATE_54M; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 545 | |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 546 | if (uFragIdx == (uMACfragNum-2)) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 547 | uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbLastFragmentSize, wFB_Opt0[FB_RATE1][wRate-RATE_18M], bNeedAck); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 548 | else |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 549 | uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt0[FB_RATE1][wRate-RATE_18M], bNeedAck); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 550 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 551 | } else { // (byFBOption == AUTO_FB_1) |
| 552 | if (wRate < RATE_18M) |
| 553 | wRate = RATE_18M; |
| 554 | else if (wRate > RATE_54M) |
| 555 | wRate = RATE_54M; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 556 | |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 557 | if (uFragIdx == (uMACfragNum-2)) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 558 | uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbLastFragmentSize, wFB_Opt1[FB_RATE1][wRate-RATE_18M], bNeedAck); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 559 | else |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 560 | uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt1[FB_RATE1][wRate-RATE_18M], bNeedAck); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 561 | } |
| 562 | if (bNeedAck) { |
| 563 | uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate); |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 564 | return pDevice->uSIFS + uAckTime + uNextPktTime; |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 565 | } else { |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 566 | return pDevice->uSIFS + uNextPktTime; |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 567 | } |
| 568 | } |
| 569 | break; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 570 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 571 | default: |
| 572 | break; |
| 573 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 574 | |
Charles Clément | 5a5a2a6 | 2010-08-01 17:15:49 +0200 | [diff] [blame] | 575 | ASSERT(false); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 576 | return 0; |
| 577 | } |
| 578 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 579 | //byFreqType: 0=>5GHZ 1=>2.4GHZ |
| 580 | static |
Malcolm Priestley | 96372bd | 2014-08-30 22:25:48 +0100 | [diff] [blame] | 581 | __le16 |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 582 | s_uGetRTSCTSDuration( |
Malcolm Priestley | cf76dc4 | 2014-08-10 15:46:59 +0100 | [diff] [blame] | 583 | struct vnt_private *pDevice, |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 584 | unsigned char byDurType, |
| 585 | unsigned int cbFrameLength, |
| 586 | unsigned char byPktType, |
| 587 | unsigned short wRate, |
| 588 | bool bNeedAck, |
| 589 | unsigned char byFBOption |
| 590 | ) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 591 | { |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 592 | unsigned int uCTSTime = 0, uDurTime = 0; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 593 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 594 | switch (byDurType) { |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 595 | case RTSDUR_BB: //RTSDuration_bb |
| 596 | uCTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopCCKBasicRate); |
| 597 | uDurTime = uCTSTime + 2*pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wRate, bNeedAck); |
| 598 | break; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 599 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 600 | case RTSDUR_BA: //RTSDuration_ba |
| 601 | uCTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopCCKBasicRate); |
| 602 | uDurTime = uCTSTime + 2*pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wRate, bNeedAck); |
| 603 | break; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 604 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 605 | case RTSDUR_AA: //RTSDuration_aa |
| 606 | uCTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate); |
| 607 | uDurTime = uCTSTime + 2*pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wRate, bNeedAck); |
| 608 | break; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 609 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 610 | case CTSDUR_BA: //CTSDuration_ba |
| 611 | uDurTime = pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wRate, bNeedAck); |
| 612 | break; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 613 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 614 | case RTSDUR_BA_F0: //RTSDuration_ba_f0 |
| 615 | uCTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopCCKBasicRate); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 616 | if ((byFBOption == AUTO_FB_0) && (wRate >= RATE_18M) && (wRate <= RATE_54M)) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 617 | uDurTime = uCTSTime + 2 * pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt0[FB_RATE0][wRate-RATE_18M], bNeedAck); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 618 | else if ((byFBOption == AUTO_FB_1) && (wRate >= RATE_18M) && (wRate <= RATE_54M)) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 619 | uDurTime = uCTSTime + 2 * pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt1[FB_RATE0][wRate-RATE_18M], bNeedAck); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 620 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 621 | break; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 622 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 623 | case RTSDUR_AA_F0: //RTSDuration_aa_f0 |
| 624 | uCTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 625 | if ((byFBOption == AUTO_FB_0) && (wRate >= RATE_18M) && (wRate <= RATE_54M)) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 626 | uDurTime = uCTSTime + 2*pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt0[FB_RATE0][wRate-RATE_18M], bNeedAck); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 627 | else if ((byFBOption == AUTO_FB_1) && (wRate >= RATE_18M) && (wRate <= RATE_54M)) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 628 | uDurTime = uCTSTime + 2*pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt1[FB_RATE0][wRate-RATE_18M], bNeedAck); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 629 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 630 | break; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 631 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 632 | case RTSDUR_BA_F1: //RTSDuration_ba_f1 |
| 633 | uCTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopCCKBasicRate); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 634 | if ((byFBOption == AUTO_FB_0) && (wRate >= RATE_18M) && (wRate <= RATE_54M)) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 635 | uDurTime = uCTSTime + 2*pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt0[FB_RATE1][wRate-RATE_18M], bNeedAck); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 636 | else if ((byFBOption == AUTO_FB_1) && (wRate >= RATE_18M) && (wRate <= RATE_54M)) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 637 | uDurTime = uCTSTime + 2*pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt1[FB_RATE1][wRate-RATE_18M], bNeedAck); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 638 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 639 | break; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 640 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 641 | case RTSDUR_AA_F1: //RTSDuration_aa_f1 |
| 642 | uCTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 643 | if ((byFBOption == AUTO_FB_0) && (wRate >= RATE_18M) && (wRate <= RATE_54M)) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 644 | uDurTime = uCTSTime + 2*pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt0[FB_RATE1][wRate-RATE_18M], bNeedAck); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 645 | else if ((byFBOption == AUTO_FB_1) && (wRate >= RATE_18M) && (wRate <= RATE_54M)) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 646 | uDurTime = uCTSTime + 2*pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt1[FB_RATE1][wRate-RATE_18M], bNeedAck); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 647 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 648 | break; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 649 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 650 | case CTSDUR_BA_F0: //CTSDuration_ba_f0 |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 651 | if ((byFBOption == AUTO_FB_0) && (wRate >= RATE_18M) && (wRate <= RATE_54M)) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 652 | uDurTime = pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt0[FB_RATE0][wRate-RATE_18M], bNeedAck); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 653 | else if ((byFBOption == AUTO_FB_1) && (wRate >= RATE_18M) && (wRate <= RATE_54M)) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 654 | uDurTime = pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt1[FB_RATE0][wRate-RATE_18M], bNeedAck); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 655 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 656 | break; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 657 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 658 | case CTSDUR_BA_F1: //CTSDuration_ba_f1 |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 659 | if ((byFBOption == AUTO_FB_0) && (wRate >= RATE_18M) && (wRate <= RATE_54M)) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 660 | uDurTime = pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt0[FB_RATE1][wRate-RATE_18M], bNeedAck); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 661 | else if ((byFBOption == AUTO_FB_1) && (wRate >= RATE_18M) && (wRate <= RATE_54M)) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 662 | uDurTime = pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt1[FB_RATE1][wRate-RATE_18M], bNeedAck); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 663 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 664 | break; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 665 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 666 | default: |
| 667 | break; |
| 668 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 669 | |
Malcolm Priestley | 96372bd | 2014-08-30 22:25:48 +0100 | [diff] [blame] | 670 | return cpu_to_le16((u16)uDurTime); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 671 | } |
| 672 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 673 | static |
Malcolm Priestley | a479ffc | 2014-08-30 22:25:38 +0100 | [diff] [blame] | 674 | __le16 |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 675 | s_uFillDataHead( |
Malcolm Priestley | cf76dc4 | 2014-08-10 15:46:59 +0100 | [diff] [blame] | 676 | struct vnt_private *pDevice, |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 677 | unsigned char byPktType, |
| 678 | void *pTxDataHead, |
| 679 | unsigned int cbFrameLength, |
| 680 | unsigned int uDMAIdx, |
| 681 | bool bNeedAck, |
| 682 | unsigned int uFragIdx, |
| 683 | unsigned int cbLastFragmentSize, |
| 684 | unsigned int uMACfragNum, |
| 685 | unsigned char byFBOption, |
| 686 | unsigned short wCurrentRate |
| 687 | ) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 688 | { |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 689 | |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 690 | if (pTxDataHead == NULL) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 691 | return 0; |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 692 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 693 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 694 | if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) { |
| 695 | if (byFBOption == AUTO_FB_NONE) { |
Malcolm Priestley | 72edb7e | 2014-08-30 22:25:34 +0100 | [diff] [blame] | 696 | struct vnt_tx_datahead_g *buf = pTxDataHead; |
Malcolm Priestley | 429a247 | 2014-08-20 22:30:29 +0100 | [diff] [blame] | 697 | /* Get SignalField, ServiceField & Length */ |
| 698 | vnt_get_phy_field(pDevice, cbFrameLength, wCurrentRate, |
Malcolm Priestley | 72edb7e | 2014-08-30 22:25:34 +0100 | [diff] [blame] | 699 | byPktType, &buf->a); |
Malcolm Priestley | 429a247 | 2014-08-20 22:30:29 +0100 | [diff] [blame] | 700 | |
| 701 | vnt_get_phy_field(pDevice, cbFrameLength, |
| 702 | pDevice->byTopCCKBasicRate, |
Malcolm Priestley | 72edb7e | 2014-08-30 22:25:34 +0100 | [diff] [blame] | 703 | PK_TYPE_11B, &buf->b); |
Malcolm Priestley | 429a247 | 2014-08-20 22:30:29 +0100 | [diff] [blame] | 704 | |
Malcolm Priestley | 72edb7e | 2014-08-30 22:25:34 +0100 | [diff] [blame] | 705 | /* Get Duration and TimeStamp */ |
| 706 | buf->duration_a = cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_A, cbFrameLength, |
| 707 | byPktType, wCurrentRate, bNeedAck, uFragIdx, |
| 708 | cbLastFragmentSize, uMACfragNum, |
| 709 | byFBOption)); |
| 710 | buf->duration_b = cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_B, cbFrameLength, |
| 711 | PK_TYPE_11B, pDevice->byTopCCKBasicRate, |
| 712 | bNeedAck, uFragIdx, cbLastFragmentSize, |
| 713 | uMACfragNum, byFBOption)); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 714 | |
Malcolm Priestley | 72edb7e | 2014-08-30 22:25:34 +0100 | [diff] [blame] | 715 | buf->time_stamp_off_a = vnt_time_stamp_off(pDevice, wCurrentRate); |
| 716 | buf->time_stamp_off_b = vnt_time_stamp_off(pDevice, pDevice->byTopCCKBasicRate); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 717 | |
Malcolm Priestley | 72edb7e | 2014-08-30 22:25:34 +0100 | [diff] [blame] | 718 | return buf->duration_a; |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 719 | } else { |
Malcolm Priestley | 2dd7667 | 2014-08-30 22:25:35 +0100 | [diff] [blame] | 720 | /* Auto Fallback */ |
| 721 | struct vnt_tx_datahead_g_fb *buf = pTxDataHead; |
Malcolm Priestley | 429a247 | 2014-08-20 22:30:29 +0100 | [diff] [blame] | 722 | /* Get SignalField, ServiceField & Length */ |
| 723 | vnt_get_phy_field(pDevice, cbFrameLength, wCurrentRate, |
Malcolm Priestley | 2dd7667 | 2014-08-30 22:25:35 +0100 | [diff] [blame] | 724 | byPktType, &buf->a); |
Malcolm Priestley | 429a247 | 2014-08-20 22:30:29 +0100 | [diff] [blame] | 725 | |
| 726 | vnt_get_phy_field(pDevice, cbFrameLength, |
| 727 | pDevice->byTopCCKBasicRate, |
Malcolm Priestley | 2dd7667 | 2014-08-30 22:25:35 +0100 | [diff] [blame] | 728 | PK_TYPE_11B, &buf->b); |
| 729 | /* Get Duration and TimeStamp */ |
| 730 | buf->duration_a = cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_A, cbFrameLength, byPktType, |
| 731 | wCurrentRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption)); |
| 732 | buf->duration_b = cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_B, cbFrameLength, PK_TYPE_11B, |
| 733 | pDevice->byTopCCKBasicRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption)); |
| 734 | buf->duration_a_f0 = cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_A_F0, cbFrameLength, byPktType, |
| 735 | wCurrentRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption)); |
| 736 | buf->duration_a_f1 = cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_A_F1, cbFrameLength, byPktType, |
| 737 | wCurrentRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption)); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 738 | |
Malcolm Priestley | 2dd7667 | 2014-08-30 22:25:35 +0100 | [diff] [blame] | 739 | buf->time_stamp_off_a = vnt_time_stamp_off(pDevice, wCurrentRate); |
| 740 | buf->time_stamp_off_b = vnt_time_stamp_off(pDevice, pDevice->byTopCCKBasicRate); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 741 | |
Malcolm Priestley | 2dd7667 | 2014-08-30 22:25:35 +0100 | [diff] [blame] | 742 | return buf->duration_a; |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 743 | } //if (byFBOption == AUTO_FB_NONE) |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 744 | } else if (byPktType == PK_TYPE_11A) { |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 745 | if ((byFBOption != AUTO_FB_NONE)) { |
Malcolm Priestley | 9c62c7a | 2014-08-30 22:25:37 +0100 | [diff] [blame] | 746 | /* Auto Fallback */ |
| 747 | struct vnt_tx_datahead_a_fb *buf = pTxDataHead; |
Malcolm Priestley | 429a247 | 2014-08-20 22:30:29 +0100 | [diff] [blame] | 748 | /* Get SignalField, ServiceField & Length */ |
| 749 | vnt_get_phy_field(pDevice, cbFrameLength, wCurrentRate, |
Malcolm Priestley | 9c62c7a | 2014-08-30 22:25:37 +0100 | [diff] [blame] | 750 | byPktType, &buf->a); |
Malcolm Priestley | 429a247 | 2014-08-20 22:30:29 +0100 | [diff] [blame] | 751 | |
Malcolm Priestley | 9c62c7a | 2014-08-30 22:25:37 +0100 | [diff] [blame] | 752 | /* Get Duration and TimeStampOff */ |
| 753 | buf->duration = cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_A, cbFrameLength, byPktType, |
| 754 | wCurrentRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption)); |
| 755 | buf->duration_f0 = cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_A_F0, cbFrameLength, byPktType, |
| 756 | wCurrentRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption)); |
| 757 | buf->duration_f1 = cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_A_F1, cbFrameLength, byPktType, |
| 758 | wCurrentRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption)); |
| 759 | buf->time_stamp_off = vnt_time_stamp_off(pDevice, wCurrentRate); |
| 760 | return buf->duration; |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 761 | } else { |
Malcolm Priestley | 9ce842a | 2014-08-30 22:25:36 +0100 | [diff] [blame] | 762 | struct vnt_tx_datahead_ab *buf = pTxDataHead; |
Malcolm Priestley | 429a247 | 2014-08-20 22:30:29 +0100 | [diff] [blame] | 763 | /* Get SignalField, ServiceField & Length */ |
| 764 | vnt_get_phy_field(pDevice, cbFrameLength, wCurrentRate, |
Malcolm Priestley | 9ce842a | 2014-08-30 22:25:36 +0100 | [diff] [blame] | 765 | byPktType, &buf->ab); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 766 | |
Malcolm Priestley | 9ce842a | 2014-08-30 22:25:36 +0100 | [diff] [blame] | 767 | /* Get Duration and TimeStampOff */ |
| 768 | buf->duration = cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_A, cbFrameLength, byPktType, |
| 769 | wCurrentRate, bNeedAck, uFragIdx, |
| 770 | cbLastFragmentSize, uMACfragNum, |
| 771 | byFBOption)); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 772 | |
Malcolm Priestley | 9ce842a | 2014-08-30 22:25:36 +0100 | [diff] [blame] | 773 | buf->time_stamp_off = vnt_time_stamp_off(pDevice, wCurrentRate); |
| 774 | return buf->duration; |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 775 | } |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 776 | } else { |
Malcolm Priestley | 9ce842a | 2014-08-30 22:25:36 +0100 | [diff] [blame] | 777 | struct vnt_tx_datahead_ab *buf = pTxDataHead; |
Malcolm Priestley | 429a247 | 2014-08-20 22:30:29 +0100 | [diff] [blame] | 778 | /* Get SignalField, ServiceField & Length */ |
| 779 | vnt_get_phy_field(pDevice, cbFrameLength, wCurrentRate, |
Malcolm Priestley | 9ce842a | 2014-08-30 22:25:36 +0100 | [diff] [blame] | 780 | byPktType, &buf->ab); |
| 781 | /* Get Duration and TimeStampOff */ |
| 782 | buf->duration = cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_B, cbFrameLength, byPktType, |
| 783 | wCurrentRate, bNeedAck, uFragIdx, |
| 784 | cbLastFragmentSize, uMACfragNum, |
| 785 | byFBOption)); |
| 786 | buf->time_stamp_off = vnt_time_stamp_off(pDevice, wCurrentRate); |
| 787 | return buf->duration; |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 788 | } |
| 789 | return 0; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 790 | } |
| 791 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 792 | static |
Charles Clément | 6b35b7b | 2010-05-07 12:30:19 -0700 | [diff] [blame] | 793 | void |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 794 | s_vFillRTSHead( |
Malcolm Priestley | cf76dc4 | 2014-08-10 15:46:59 +0100 | [diff] [blame] | 795 | struct vnt_private *pDevice, |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 796 | unsigned char byPktType, |
| 797 | void *pvRTS, |
| 798 | unsigned int cbFrameLength, |
| 799 | bool bNeedAck, |
| 800 | bool bDisCRC, |
| 801 | PSEthernetHeader psEthHeader, |
| 802 | unsigned short wCurrentRate, |
| 803 | unsigned char byFBOption |
| 804 | ) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 805 | { |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 806 | unsigned int uRTSFrameLen = 20; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 807 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 808 | if (pvRTS == NULL) |
| 809 | return; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 810 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 811 | if (bDisCRC) { |
| 812 | // When CRCDIS bit is on, H/W forgot to generate FCS for RTS frame, |
| 813 | // in this case we need to decrease its length by 4. |
| 814 | uRTSFrameLen -= 4; |
| 815 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 816 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 817 | // Note: So far RTSHead dosen't appear in ATIM & Beacom DMA, so we don't need to take them into account. |
| 818 | // Otherwise, we need to modify codes for them. |
| 819 | if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) { |
| 820 | if (byFBOption == AUTO_FB_NONE) { |
Malcolm Priestley | 17434f0 | 2014-08-30 22:25:41 +0100 | [diff] [blame] | 821 | struct vnt_rts_g *buf = pvRTS; |
Malcolm Priestley | 429a247 | 2014-08-20 22:30:29 +0100 | [diff] [blame] | 822 | /* Get SignalField, ServiceField & Length */ |
| 823 | vnt_get_phy_field(pDevice, uRTSFrameLen, |
| 824 | pDevice->byTopCCKBasicRate, |
Malcolm Priestley | 17434f0 | 2014-08-30 22:25:41 +0100 | [diff] [blame] | 825 | PK_TYPE_11B, &buf->b); |
Malcolm Priestley | 429a247 | 2014-08-20 22:30:29 +0100 | [diff] [blame] | 826 | |
| 827 | vnt_get_phy_field(pDevice, uRTSFrameLen, |
| 828 | pDevice->byTopOFDMBasicRate, |
Malcolm Priestley | 17434f0 | 2014-08-30 22:25:41 +0100 | [diff] [blame] | 829 | byPktType, &buf->a); |
| 830 | /* Get Duration */ |
| 831 | buf->duration_bb = |
Malcolm Priestley | 96372bd | 2014-08-30 22:25:48 +0100 | [diff] [blame] | 832 | s_uGetRTSCTSDuration(pDevice, RTSDUR_BB, |
| 833 | cbFrameLength, PK_TYPE_11B, |
| 834 | pDevice->byTopCCKBasicRate, |
| 835 | bNeedAck, byFBOption); |
Malcolm Priestley | 17434f0 | 2014-08-30 22:25:41 +0100 | [diff] [blame] | 836 | buf->duration_aa = |
Malcolm Priestley | 96372bd | 2014-08-30 22:25:48 +0100 | [diff] [blame] | 837 | s_uGetRTSCTSDuration(pDevice, RTSDUR_AA, |
| 838 | cbFrameLength, byPktType, |
| 839 | wCurrentRate, bNeedAck, |
| 840 | byFBOption); |
Malcolm Priestley | 17434f0 | 2014-08-30 22:25:41 +0100 | [diff] [blame] | 841 | buf->duration_ba = |
Malcolm Priestley | 96372bd | 2014-08-30 22:25:48 +0100 | [diff] [blame] | 842 | s_uGetRTSCTSDuration(pDevice, RTSDUR_BA, |
| 843 | cbFrameLength, byPktType, |
| 844 | wCurrentRate, bNeedAck, |
| 845 | byFBOption); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 846 | |
Malcolm Priestley | 17434f0 | 2014-08-30 22:25:41 +0100 | [diff] [blame] | 847 | buf->data.duration = buf->duration_aa; |
Malcolm Priestley | 52c4130 | 2014-08-30 22:25:39 +0100 | [diff] [blame] | 848 | /* Get RTS Frame body */ |
Malcolm Priestley | 17434f0 | 2014-08-30 22:25:41 +0100 | [diff] [blame] | 849 | buf->data.frame_control = |
Malcolm Priestley | 52c4130 | 2014-08-30 22:25:39 +0100 | [diff] [blame] | 850 | cpu_to_le16(IEEE80211_FTYPE_CTL | |
| 851 | IEEE80211_STYPE_RTS); |
| 852 | |
| 853 | |
Malcolm Priestley | a987367 | 2014-08-30 22:25:49 +0100 | [diff] [blame] | 854 | if ((pDevice->op_mode == NL80211_IFTYPE_ADHOC) || |
| 855 | (pDevice->op_mode == NL80211_IFTYPE_AP)) { |
Aya Mahfouz | 2359b5c | 2014-10-11 02:42:45 +0200 | [diff] [blame^] | 856 | ether_addr_copy(buf->data.ra, |
| 857 | psEthHeader->abyDstAddr); |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 858 | } else { |
Aya Mahfouz | 2359b5c | 2014-10-11 02:42:45 +0200 | [diff] [blame^] | 859 | ether_addr_copy(buf->data.ra, |
| 860 | pDevice->abyBSSID); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 861 | } |
Malcolm Priestley | a987367 | 2014-08-30 22:25:49 +0100 | [diff] [blame] | 862 | if (pDevice->op_mode == NL80211_IFTYPE_AP) |
Aya Mahfouz | 2359b5c | 2014-10-11 02:42:45 +0200 | [diff] [blame^] | 863 | ether_addr_copy(buf->data.ta, |
| 864 | pDevice->abyBSSID); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 865 | else |
Aya Mahfouz | 2359b5c | 2014-10-11 02:42:45 +0200 | [diff] [blame^] | 866 | ether_addr_copy(buf->data.ta, |
| 867 | psEthHeader->abySrcAddr); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 868 | |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 869 | } else { |
Malcolm Priestley | 9587b09 | 2014-08-30 22:25:42 +0100 | [diff] [blame] | 870 | struct vnt_rts_g_fb *buf = pvRTS; |
Malcolm Priestley | 429a247 | 2014-08-20 22:30:29 +0100 | [diff] [blame] | 871 | /* Get SignalField, ServiceField & Length */ |
| 872 | vnt_get_phy_field(pDevice, uRTSFrameLen, |
| 873 | pDevice->byTopCCKBasicRate, |
Malcolm Priestley | 9587b09 | 2014-08-30 22:25:42 +0100 | [diff] [blame] | 874 | PK_TYPE_11B, &buf->b); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 875 | |
Malcolm Priestley | 429a247 | 2014-08-20 22:30:29 +0100 | [diff] [blame] | 876 | vnt_get_phy_field(pDevice, uRTSFrameLen, |
| 877 | pDevice->byTopOFDMBasicRate, |
Malcolm Priestley | 9587b09 | 2014-08-30 22:25:42 +0100 | [diff] [blame] | 878 | byPktType, &buf->a); |
| 879 | /* Get Duration */ |
| 880 | buf->duration_bb = |
Malcolm Priestley | 96372bd | 2014-08-30 22:25:48 +0100 | [diff] [blame] | 881 | s_uGetRTSCTSDuration(pDevice, RTSDUR_BB, |
| 882 | cbFrameLength, PK_TYPE_11B, |
| 883 | pDevice->byTopCCKBasicRate, |
| 884 | bNeedAck, byFBOption); |
Malcolm Priestley | 9587b09 | 2014-08-30 22:25:42 +0100 | [diff] [blame] | 885 | buf->duration_aa = |
Malcolm Priestley | 96372bd | 2014-08-30 22:25:48 +0100 | [diff] [blame] | 886 | s_uGetRTSCTSDuration(pDevice, RTSDUR_AA, |
| 887 | cbFrameLength, byPktType, |
| 888 | wCurrentRate, bNeedAck, |
| 889 | byFBOption); |
Malcolm Priestley | 9587b09 | 2014-08-30 22:25:42 +0100 | [diff] [blame] | 890 | buf->duration_ba = |
Malcolm Priestley | 96372bd | 2014-08-30 22:25:48 +0100 | [diff] [blame] | 891 | s_uGetRTSCTSDuration(pDevice, RTSDUR_BA, |
| 892 | cbFrameLength, byPktType, |
| 893 | wCurrentRate, bNeedAck, |
| 894 | byFBOption); |
Malcolm Priestley | 9587b09 | 2014-08-30 22:25:42 +0100 | [diff] [blame] | 895 | buf->rts_duration_ba_f0 = |
Malcolm Priestley | 96372bd | 2014-08-30 22:25:48 +0100 | [diff] [blame] | 896 | s_uGetRTSCTSDuration(pDevice, RTSDUR_BA_F0, |
| 897 | cbFrameLength, byPktType, |
| 898 | wCurrentRate, bNeedAck, |
| 899 | byFBOption); |
Malcolm Priestley | 9587b09 | 2014-08-30 22:25:42 +0100 | [diff] [blame] | 900 | buf->rts_duration_aa_f0 = |
Malcolm Priestley | 96372bd | 2014-08-30 22:25:48 +0100 | [diff] [blame] | 901 | s_uGetRTSCTSDuration(pDevice, RTSDUR_AA_F0, |
| 902 | cbFrameLength, byPktType, |
| 903 | wCurrentRate, bNeedAck, |
| 904 | byFBOption); |
Malcolm Priestley | 9587b09 | 2014-08-30 22:25:42 +0100 | [diff] [blame] | 905 | buf->rts_duration_ba_f1 = |
Malcolm Priestley | 96372bd | 2014-08-30 22:25:48 +0100 | [diff] [blame] | 906 | s_uGetRTSCTSDuration(pDevice, RTSDUR_BA_F1, |
| 907 | cbFrameLength, byPktType, |
| 908 | wCurrentRate, bNeedAck, |
| 909 | byFBOption); |
Malcolm Priestley | 9587b09 | 2014-08-30 22:25:42 +0100 | [diff] [blame] | 910 | buf->rts_duration_aa_f1 = |
Malcolm Priestley | 96372bd | 2014-08-30 22:25:48 +0100 | [diff] [blame] | 911 | s_uGetRTSCTSDuration(pDevice, RTSDUR_AA_F1, |
| 912 | cbFrameLength, byPktType, |
| 913 | wCurrentRate, bNeedAck, |
| 914 | byFBOption); |
Malcolm Priestley | 9587b09 | 2014-08-30 22:25:42 +0100 | [diff] [blame] | 915 | buf->data.duration = buf->duration_aa; |
Malcolm Priestley | 52c4130 | 2014-08-30 22:25:39 +0100 | [diff] [blame] | 916 | /* Get RTS Frame body */ |
Malcolm Priestley | 9587b09 | 2014-08-30 22:25:42 +0100 | [diff] [blame] | 917 | buf->data.frame_control = |
Malcolm Priestley | 52c4130 | 2014-08-30 22:25:39 +0100 | [diff] [blame] | 918 | cpu_to_le16(IEEE80211_FTYPE_CTL | |
| 919 | IEEE80211_STYPE_RTS); |
| 920 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 921 | |
Malcolm Priestley | a987367 | 2014-08-30 22:25:49 +0100 | [diff] [blame] | 922 | if ((pDevice->op_mode == NL80211_IFTYPE_ADHOC) || |
| 923 | (pDevice->op_mode == NL80211_IFTYPE_AP)) { |
Aya Mahfouz | 2359b5c | 2014-10-11 02:42:45 +0200 | [diff] [blame^] | 924 | ether_addr_copy(buf->data.ra, |
| 925 | psEthHeader->abyDstAddr); |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 926 | } else { |
Aya Mahfouz | 2359b5c | 2014-10-11 02:42:45 +0200 | [diff] [blame^] | 927 | ether_addr_copy(buf->data.ra, |
| 928 | pDevice->abyBSSID); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 929 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 930 | |
Malcolm Priestley | a987367 | 2014-08-30 22:25:49 +0100 | [diff] [blame] | 931 | if (pDevice->op_mode == NL80211_IFTYPE_AP) |
Aya Mahfouz | 2359b5c | 2014-10-11 02:42:45 +0200 | [diff] [blame^] | 932 | ether_addr_copy(buf->data.ta, |
| 933 | pDevice->abyBSSID); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 934 | else |
Aya Mahfouz | 2359b5c | 2014-10-11 02:42:45 +0200 | [diff] [blame^] | 935 | ether_addr_copy(buf->data.ta, |
| 936 | psEthHeader->abySrcAddr); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 937 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 938 | } // if (byFBOption == AUTO_FB_NONE) |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 939 | } else if (byPktType == PK_TYPE_11A) { |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 940 | if (byFBOption == AUTO_FB_NONE) { |
Malcolm Priestley | e21eb1c | 2014-08-30 22:25:43 +0100 | [diff] [blame] | 941 | struct vnt_rts_ab *buf = pvRTS; |
Malcolm Priestley | 429a247 | 2014-08-20 22:30:29 +0100 | [diff] [blame] | 942 | /* Get SignalField, ServiceField & Length */ |
| 943 | vnt_get_phy_field(pDevice, uRTSFrameLen, |
| 944 | pDevice->byTopOFDMBasicRate, |
Malcolm Priestley | e21eb1c | 2014-08-30 22:25:43 +0100 | [diff] [blame] | 945 | byPktType, &buf->ab); |
| 946 | /* Get Duration */ |
| 947 | buf->duration = |
Malcolm Priestley | 96372bd | 2014-08-30 22:25:48 +0100 | [diff] [blame] | 948 | s_uGetRTSCTSDuration(pDevice, RTSDUR_AA, |
| 949 | cbFrameLength, byPktType, |
| 950 | wCurrentRate, bNeedAck, |
| 951 | byFBOption); |
Malcolm Priestley | e21eb1c | 2014-08-30 22:25:43 +0100 | [diff] [blame] | 952 | buf->data.duration = buf->duration; |
Malcolm Priestley | 52c4130 | 2014-08-30 22:25:39 +0100 | [diff] [blame] | 953 | /* Get RTS Frame body */ |
Malcolm Priestley | e21eb1c | 2014-08-30 22:25:43 +0100 | [diff] [blame] | 954 | buf->data.frame_control = |
Malcolm Priestley | 52c4130 | 2014-08-30 22:25:39 +0100 | [diff] [blame] | 955 | cpu_to_le16(IEEE80211_FTYPE_CTL | |
| 956 | IEEE80211_STYPE_RTS); |
| 957 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 958 | |
Malcolm Priestley | a987367 | 2014-08-30 22:25:49 +0100 | [diff] [blame] | 959 | if ((pDevice->op_mode == NL80211_IFTYPE_ADHOC) || |
| 960 | (pDevice->op_mode == NL80211_IFTYPE_AP)) { |
Aya Mahfouz | 2359b5c | 2014-10-11 02:42:45 +0200 | [diff] [blame^] | 961 | ether_addr_copy(buf->data.ra, |
| 962 | psEthHeader->abyDstAddr); |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 963 | } else { |
Aya Mahfouz | 2359b5c | 2014-10-11 02:42:45 +0200 | [diff] [blame^] | 964 | ether_addr_copy(buf->data.ra, |
| 965 | pDevice->abyBSSID); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 966 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 967 | |
Malcolm Priestley | a987367 | 2014-08-30 22:25:49 +0100 | [diff] [blame] | 968 | if (pDevice->op_mode == NL80211_IFTYPE_AP) |
Aya Mahfouz | 2359b5c | 2014-10-11 02:42:45 +0200 | [diff] [blame^] | 969 | ether_addr_copy(buf->data.ta, |
| 970 | pDevice->abyBSSID); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 971 | else |
Aya Mahfouz | 2359b5c | 2014-10-11 02:42:45 +0200 | [diff] [blame^] | 972 | ether_addr_copy(buf->data.ta, |
| 973 | psEthHeader->abySrcAddr); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 974 | |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 975 | } else { |
Malcolm Priestley | 8e44804 | 2014-08-30 22:25:44 +0100 | [diff] [blame] | 976 | struct vnt_rts_a_fb *buf = pvRTS; |
Malcolm Priestley | 429a247 | 2014-08-20 22:30:29 +0100 | [diff] [blame] | 977 | /* Get SignalField, ServiceField & Length */ |
| 978 | vnt_get_phy_field(pDevice, uRTSFrameLen, |
| 979 | pDevice->byTopOFDMBasicRate, |
Malcolm Priestley | 8e44804 | 2014-08-30 22:25:44 +0100 | [diff] [blame] | 980 | byPktType, &buf->a); |
| 981 | /* Get Duration */ |
| 982 | buf->duration = |
Malcolm Priestley | 96372bd | 2014-08-30 22:25:48 +0100 | [diff] [blame] | 983 | s_uGetRTSCTSDuration(pDevice, RTSDUR_AA, |
| 984 | cbFrameLength, byPktType, |
| 985 | wCurrentRate, bNeedAck, |
| 986 | byFBOption); |
Malcolm Priestley | 8e44804 | 2014-08-30 22:25:44 +0100 | [diff] [blame] | 987 | buf->rts_duration_f0 = |
Malcolm Priestley | 96372bd | 2014-08-30 22:25:48 +0100 | [diff] [blame] | 988 | s_uGetRTSCTSDuration(pDevice, RTSDUR_AA_F0, |
| 989 | cbFrameLength, byPktType, |
| 990 | wCurrentRate, bNeedAck, |
| 991 | byFBOption); |
Malcolm Priestley | 8e44804 | 2014-08-30 22:25:44 +0100 | [diff] [blame] | 992 | buf->rts_duration_f1 = |
Malcolm Priestley | 96372bd | 2014-08-30 22:25:48 +0100 | [diff] [blame] | 993 | s_uGetRTSCTSDuration(pDevice, RTSDUR_AA_F1, |
| 994 | cbFrameLength, byPktType, |
| 995 | wCurrentRate, bNeedAck, |
| 996 | byFBOption); |
Malcolm Priestley | 8e44804 | 2014-08-30 22:25:44 +0100 | [diff] [blame] | 997 | buf->data.duration = buf->duration; |
Malcolm Priestley | 52c4130 | 2014-08-30 22:25:39 +0100 | [diff] [blame] | 998 | /* Get RTS Frame body */ |
Malcolm Priestley | 8e44804 | 2014-08-30 22:25:44 +0100 | [diff] [blame] | 999 | buf->data.frame_control = |
Malcolm Priestley | 52c4130 | 2014-08-30 22:25:39 +0100 | [diff] [blame] | 1000 | cpu_to_le16(IEEE80211_FTYPE_CTL | |
| 1001 | IEEE80211_STYPE_RTS); |
| 1002 | |
Malcolm Priestley | a987367 | 2014-08-30 22:25:49 +0100 | [diff] [blame] | 1003 | if ((pDevice->op_mode == NL80211_IFTYPE_ADHOC) || |
| 1004 | (pDevice->op_mode == NL80211_IFTYPE_AP)) { |
Aya Mahfouz | 2359b5c | 2014-10-11 02:42:45 +0200 | [diff] [blame^] | 1005 | ether_addr_copy(buf->data.ra, |
| 1006 | psEthHeader->abyDstAddr); |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 1007 | } else { |
Aya Mahfouz | 2359b5c | 2014-10-11 02:42:45 +0200 | [diff] [blame^] | 1008 | ether_addr_copy(buf->data.ra, |
| 1009 | pDevice->abyBSSID); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1010 | } |
Malcolm Priestley | a987367 | 2014-08-30 22:25:49 +0100 | [diff] [blame] | 1011 | if (pDevice->op_mode == NL80211_IFTYPE_AP) |
Aya Mahfouz | 2359b5c | 2014-10-11 02:42:45 +0200 | [diff] [blame^] | 1012 | ether_addr_copy(buf->data.ta, |
| 1013 | pDevice->abyBSSID); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 1014 | else |
Aya Mahfouz | 2359b5c | 2014-10-11 02:42:45 +0200 | [diff] [blame^] | 1015 | ether_addr_copy(buf->data.ta, |
| 1016 | psEthHeader->abySrcAddr); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1017 | } |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 1018 | } else if (byPktType == PK_TYPE_11B) { |
Malcolm Priestley | e21eb1c | 2014-08-30 22:25:43 +0100 | [diff] [blame] | 1019 | struct vnt_rts_ab *buf = pvRTS; |
Malcolm Priestley | 429a247 | 2014-08-20 22:30:29 +0100 | [diff] [blame] | 1020 | /* Get SignalField, ServiceField & Length */ |
| 1021 | vnt_get_phy_field(pDevice, uRTSFrameLen, |
| 1022 | pDevice->byTopCCKBasicRate, |
Malcolm Priestley | e21eb1c | 2014-08-30 22:25:43 +0100 | [diff] [blame] | 1023 | PK_TYPE_11B, &buf->ab); |
| 1024 | /* Get Duration */ |
| 1025 | buf->duration = |
Malcolm Priestley | 96372bd | 2014-08-30 22:25:48 +0100 | [diff] [blame] | 1026 | s_uGetRTSCTSDuration(pDevice, RTSDUR_BB, cbFrameLength, |
| 1027 | byPktType, wCurrentRate, bNeedAck, |
| 1028 | byFBOption); |
| 1029 | |
Malcolm Priestley | e21eb1c | 2014-08-30 22:25:43 +0100 | [diff] [blame] | 1030 | buf->data.duration = buf->duration; |
Malcolm Priestley | 52c4130 | 2014-08-30 22:25:39 +0100 | [diff] [blame] | 1031 | /* Get RTS Frame body */ |
Malcolm Priestley | e21eb1c | 2014-08-30 22:25:43 +0100 | [diff] [blame] | 1032 | buf->data.frame_control = |
Malcolm Priestley | 52c4130 | 2014-08-30 22:25:39 +0100 | [diff] [blame] | 1033 | cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_RTS); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1034 | |
Malcolm Priestley | a987367 | 2014-08-30 22:25:49 +0100 | [diff] [blame] | 1035 | if ((pDevice->op_mode == NL80211_IFTYPE_ADHOC) || |
| 1036 | (pDevice->op_mode == NL80211_IFTYPE_AP)) { |
Aya Mahfouz | 2359b5c | 2014-10-11 02:42:45 +0200 | [diff] [blame^] | 1037 | ether_addr_copy(buf->data.ra, |
| 1038 | psEthHeader->abyDstAddr); |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 1039 | } else { |
Aya Mahfouz | 2359b5c | 2014-10-11 02:42:45 +0200 | [diff] [blame^] | 1040 | ether_addr_copy(buf->data.ra, pDevice->abyBSSID); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1041 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1042 | |
Malcolm Priestley | a987367 | 2014-08-30 22:25:49 +0100 | [diff] [blame] | 1043 | if (pDevice->op_mode == NL80211_IFTYPE_AP) |
Aya Mahfouz | 2359b5c | 2014-10-11 02:42:45 +0200 | [diff] [blame^] | 1044 | ether_addr_copy(buf->data.ta, pDevice->abyBSSID); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 1045 | else |
Aya Mahfouz | 2359b5c | 2014-10-11 02:42:45 +0200 | [diff] [blame^] | 1046 | ether_addr_copy(buf->data.ta, |
| 1047 | psEthHeader->abySrcAddr); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1048 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1049 | } |
| 1050 | |
| 1051 | static |
Charles Clément | 6b35b7b | 2010-05-07 12:30:19 -0700 | [diff] [blame] | 1052 | void |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1053 | s_vFillCTSHead( |
Malcolm Priestley | cf76dc4 | 2014-08-10 15:46:59 +0100 | [diff] [blame] | 1054 | struct vnt_private *pDevice, |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1055 | unsigned int uDMAIdx, |
| 1056 | unsigned char byPktType, |
| 1057 | void *pvCTS, |
| 1058 | unsigned int cbFrameLength, |
| 1059 | bool bNeedAck, |
| 1060 | bool bDisCRC, |
| 1061 | unsigned short wCurrentRate, |
| 1062 | unsigned char byFBOption |
| 1063 | ) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1064 | { |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1065 | unsigned int uCTSFrameLen = 14; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1066 | |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 1067 | if (pvCTS == NULL) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1068 | return; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1069 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1070 | if (bDisCRC) { |
| 1071 | // When CRCDIS bit is on, H/W forgot to generate FCS for CTS frame, |
| 1072 | // in this case we need to decrease its length by 4. |
| 1073 | uCTSFrameLen -= 4; |
| 1074 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1075 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1076 | if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) { |
| 1077 | if (byFBOption != AUTO_FB_NONE && uDMAIdx != TYPE_ATIMDMA && uDMAIdx != TYPE_BEACONDMA) { |
| 1078 | // Auto Fall back |
Malcolm Priestley | db1afd1 | 2014-08-30 22:25:46 +0100 | [diff] [blame] | 1079 | struct vnt_cts_fb *buf = pvCTS; |
Malcolm Priestley | 429a247 | 2014-08-20 22:30:29 +0100 | [diff] [blame] | 1080 | /* Get SignalField, ServiceField & Length */ |
| 1081 | vnt_get_phy_field(pDevice, uCTSFrameLen, |
| 1082 | pDevice->byTopCCKBasicRate, |
Malcolm Priestley | db1afd1 | 2014-08-30 22:25:46 +0100 | [diff] [blame] | 1083 | PK_TYPE_11B, &buf->b); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1084 | |
Malcolm Priestley | 96372bd | 2014-08-30 22:25:48 +0100 | [diff] [blame] | 1085 | buf->duration_ba = |
| 1086 | s_uGetRTSCTSDuration(pDevice, CTSDUR_BA, |
| 1087 | cbFrameLength, byPktType, |
| 1088 | wCurrentRate, bNeedAck, |
| 1089 | byFBOption); |
| 1090 | |
Malcolm Priestley | db1afd1 | 2014-08-30 22:25:46 +0100 | [diff] [blame] | 1091 | /* Get CTSDuration_ba_f0 */ |
Malcolm Priestley | 96372bd | 2014-08-30 22:25:48 +0100 | [diff] [blame] | 1092 | buf->cts_duration_ba_f0 = |
| 1093 | s_uGetRTSCTSDuration(pDevice, CTSDUR_BA_F0, |
| 1094 | cbFrameLength, byPktType, |
| 1095 | wCurrentRate, bNeedAck, |
| 1096 | byFBOption); |
Malcolm Priestley | db1afd1 | 2014-08-30 22:25:46 +0100 | [diff] [blame] | 1097 | |
Malcolm Priestley | 96372bd | 2014-08-30 22:25:48 +0100 | [diff] [blame] | 1098 | /* Get CTSDuration_ba_f1 */ |
| 1099 | buf->cts_duration_ba_f1 = |
| 1100 | s_uGetRTSCTSDuration(pDevice, CTSDUR_BA_F1, |
| 1101 | cbFrameLength, byPktType, |
| 1102 | wCurrentRate, bNeedAck, |
| 1103 | byFBOption); |
Malcolm Priestley | 0864db1 | 2014-08-30 22:25:40 +0100 | [diff] [blame] | 1104 | |
Malcolm Priestley | db1afd1 | 2014-08-30 22:25:46 +0100 | [diff] [blame] | 1105 | /* Get CTS Frame body */ |
| 1106 | buf->data.duration = buf->duration_ba; |
| 1107 | |
| 1108 | buf->data.frame_control = |
Malcolm Priestley | 0864db1 | 2014-08-30 22:25:40 +0100 | [diff] [blame] | 1109 | cpu_to_le16(IEEE80211_FTYPE_CTL | |
| 1110 | IEEE80211_STYPE_CTS); |
| 1111 | |
Malcolm Priestley | db1afd1 | 2014-08-30 22:25:46 +0100 | [diff] [blame] | 1112 | buf->reserved2 = 0x0; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1113 | |
Aya Mahfouz | 2359b5c | 2014-10-11 02:42:45 +0200 | [diff] [blame^] | 1114 | ether_addr_copy(buf->data.ra, |
| 1115 | pDevice->abyCurrentNetAddr); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1116 | } else { //if (byFBOption != AUTO_FB_NONE && uDMAIdx != TYPE_ATIMDMA && uDMAIdx != TYPE_BEACONDMA) |
Malcolm Priestley | f5172b0 | 2014-08-30 22:25:45 +0100 | [diff] [blame] | 1117 | struct vnt_cts *buf = pvCTS; |
Malcolm Priestley | 429a247 | 2014-08-20 22:30:29 +0100 | [diff] [blame] | 1118 | /* Get SignalField, ServiceField & Length */ |
| 1119 | vnt_get_phy_field(pDevice, uCTSFrameLen, |
| 1120 | pDevice->byTopCCKBasicRate, |
Malcolm Priestley | f5172b0 | 2014-08-30 22:25:45 +0100 | [diff] [blame] | 1121 | PK_TYPE_11B, &buf->b); |
Malcolm Priestley | 429a247 | 2014-08-20 22:30:29 +0100 | [diff] [blame] | 1122 | |
Malcolm Priestley | f5172b0 | 2014-08-30 22:25:45 +0100 | [diff] [blame] | 1123 | /* Get CTSDuration_ba */ |
| 1124 | buf->duration_ba = |
Malcolm Priestley | 96372bd | 2014-08-30 22:25:48 +0100 | [diff] [blame] | 1125 | s_uGetRTSCTSDuration(pDevice, CTSDUR_BA, |
| 1126 | cbFrameLength, byPktType, |
| 1127 | wCurrentRate, bNeedAck, |
| 1128 | byFBOption); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1129 | |
Malcolm Priestley | f5172b0 | 2014-08-30 22:25:45 +0100 | [diff] [blame] | 1130 | /* Get CTS Frame body */ |
| 1131 | buf->data.duration = buf->duration_ba; |
Malcolm Priestley | 0864db1 | 2014-08-30 22:25:40 +0100 | [diff] [blame] | 1132 | |
Malcolm Priestley | f5172b0 | 2014-08-30 22:25:45 +0100 | [diff] [blame] | 1133 | buf->data.frame_control = |
Malcolm Priestley | 0864db1 | 2014-08-30 22:25:40 +0100 | [diff] [blame] | 1134 | cpu_to_le16(IEEE80211_FTYPE_CTL | |
| 1135 | IEEE80211_STYPE_CTS); |
| 1136 | |
Malcolm Priestley | f5172b0 | 2014-08-30 22:25:45 +0100 | [diff] [blame] | 1137 | buf->reserved2 = 0x0; |
Aya Mahfouz | 2359b5c | 2014-10-11 02:42:45 +0200 | [diff] [blame^] | 1138 | ether_addr_copy(buf->data.ra, |
| 1139 | pDevice->abyCurrentNetAddr); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1140 | } |
| 1141 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1142 | } |
| 1143 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1144 | /*+ |
| 1145 | * |
| 1146 | * Description: |
| 1147 | * Generate FIFO control for MAC & Baseband controller |
| 1148 | * |
| 1149 | * Parameters: |
| 1150 | * In: |
Gilles Espinasse | f77f13e | 2010-03-29 15:41:47 +0200 | [diff] [blame] | 1151 | * pDevice - Pointer to adapter |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1152 | * pTxDataHead - Transmit Data Buffer |
| 1153 | * pTxBufHead - pTxBufHead |
| 1154 | * pvRrvTime - pvRrvTime |
| 1155 | * pvRTS - RTS Buffer |
| 1156 | * pCTS - CTS Buffer |
| 1157 | * cbFrameSize - Transmit Data Length (Hdr+Payload+FCS) |
| 1158 | * bNeedACK - If need ACK |
| 1159 | * uDescIdx - Desc Index |
| 1160 | * Out: |
| 1161 | * none |
| 1162 | * |
| 1163 | * Return Value: none |
| 1164 | * |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1165 | -*/ |
Charles Clément | b6e95cd | 2010-06-02 09:52:01 -0700 | [diff] [blame] | 1166 | // unsigned int cbFrameSize,//Hdr+Payload+FCS |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1167 | static |
Charles Clément | 6b35b7b | 2010-05-07 12:30:19 -0700 | [diff] [blame] | 1168 | void |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1169 | s_vGenerateTxParameter( |
Malcolm Priestley | cf76dc4 | 2014-08-10 15:46:59 +0100 | [diff] [blame] | 1170 | struct vnt_private *pDevice, |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1171 | unsigned char byPktType, |
| 1172 | void *pTxBufHead, |
| 1173 | void *pvRrvTime, |
| 1174 | void *pvRTS, |
| 1175 | void *pvCTS, |
| 1176 | unsigned int cbFrameSize, |
| 1177 | bool bNeedACK, |
| 1178 | unsigned int uDMAIdx, |
| 1179 | PSEthernetHeader psEthHeader, |
| 1180 | unsigned short wCurrentRate |
| 1181 | ) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1182 | { |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1183 | unsigned int cbMACHdLen = WLAN_HDR_ADDR3_LEN; //24 |
| 1184 | unsigned short wFifoCtl; |
| 1185 | bool bDisCRC = false; |
| 1186 | unsigned char byFBOption = AUTO_FB_NONE; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1187 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1188 | PSTxBufHead pFifoHead = (PSTxBufHead)pTxBufHead; |
Guillaume Clement | 6b71127 | 2014-07-25 01:06:16 +0200 | [diff] [blame] | 1189 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1190 | pFifoHead->wReserved = wCurrentRate; |
| 1191 | wFifoCtl = pFifoHead->wFIFOCtl; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1192 | |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 1193 | if (wFifoCtl & FIFOCTL_CRCDIS) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1194 | bDisCRC = true; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1195 | |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 1196 | if (wFifoCtl & FIFOCTL_AUTO_FB_0) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1197 | byFBOption = AUTO_FB_0; |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 1198 | else if (wFifoCtl & FIFOCTL_AUTO_FB_1) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1199 | byFBOption = AUTO_FB_1; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1200 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1201 | if (pDevice->bLongHeader) |
| 1202 | cbMACHdLen = WLAN_HDR_ADDR3_LEN + 6; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1203 | |
Malcolm Priestley | c00a378 | 2014-08-30 22:25:32 +0100 | [diff] [blame] | 1204 | if (!pvRrvTime) |
| 1205 | return; |
| 1206 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1207 | if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) { |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1208 | if (pvRTS != NULL) { //RTS_need |
Malcolm Priestley | c00a378 | 2014-08-30 22:25:32 +0100 | [diff] [blame] | 1209 | /* Fill RsvTime */ |
| 1210 | struct vnt_rrv_time_rts *buf = pvRrvTime; |
Guillaume Clement | 6b71127 | 2014-07-25 01:06:16 +0200 | [diff] [blame] | 1211 | |
Malcolm Priestley | c00a378 | 2014-08-30 22:25:32 +0100 | [diff] [blame] | 1212 | buf->rts_rrv_time_aa = s_uGetRTSCTSRsvTime(pDevice, 2, byPktType, cbFrameSize, wCurrentRate); |
| 1213 | buf->rts_rrv_time_ba = s_uGetRTSCTSRsvTime(pDevice, 1, byPktType, cbFrameSize, wCurrentRate); |
| 1214 | buf->rts_rrv_time_bb = s_uGetRTSCTSRsvTime(pDevice, 0, byPktType, cbFrameSize, wCurrentRate); |
| 1215 | buf->rrv_time_a = vnt_rxtx_rsvtime_le16(pDevice, byPktType, cbFrameSize, wCurrentRate, bNeedACK); |
| 1216 | buf->rrv_time_b = vnt_rxtx_rsvtime_le16(pDevice, PK_TYPE_11B, cbFrameSize, pDevice->byTopCCKBasicRate, bNeedACK); |
| 1217 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1218 | s_vFillRTSHead(pDevice, byPktType, pvRTS, cbFrameSize, bNeedACK, bDisCRC, psEthHeader, wCurrentRate, byFBOption); |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 1219 | } else {//RTS_needless, PCF mode |
Malcolm Priestley | c00a378 | 2014-08-30 22:25:32 +0100 | [diff] [blame] | 1220 | struct vnt_rrv_time_cts *buf = pvRrvTime; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1221 | |
Malcolm Priestley | c00a378 | 2014-08-30 22:25:32 +0100 | [diff] [blame] | 1222 | buf->rrv_time_a = vnt_rxtx_rsvtime_le16(pDevice, byPktType, cbFrameSize, wCurrentRate, bNeedACK); |
| 1223 | buf->rrv_time_b = vnt_rxtx_rsvtime_le16(pDevice, PK_TYPE_11B, cbFrameSize, pDevice->byTopCCKBasicRate, bNeedACK); |
| 1224 | buf->cts_rrv_time_ba = s_uGetRTSCTSRsvTime(pDevice, 3, byPktType, cbFrameSize, wCurrentRate); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1225 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1226 | //Fill CTS |
| 1227 | s_vFillCTSHead(pDevice, uDMAIdx, byPktType, pvCTS, cbFrameSize, bNeedACK, bDisCRC, wCurrentRate, byFBOption); |
| 1228 | } |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 1229 | } else if (byPktType == PK_TYPE_11A) { |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1230 | if (pvRTS != NULL) {//RTS_need, non PCF mode |
Malcolm Priestley | c00a378 | 2014-08-30 22:25:32 +0100 | [diff] [blame] | 1231 | struct vnt_rrv_time_ab *buf = pvRrvTime; |
Guillaume Clement | 6b71127 | 2014-07-25 01:06:16 +0200 | [diff] [blame] | 1232 | |
Malcolm Priestley | c00a378 | 2014-08-30 22:25:32 +0100 | [diff] [blame] | 1233 | buf->rts_rrv_time = s_uGetRTSCTSRsvTime(pDevice, 2, byPktType, cbFrameSize, wCurrentRate); |
| 1234 | buf->rrv_time = vnt_rxtx_rsvtime_le16(pDevice, byPktType, cbFrameSize, wCurrentRate, bNeedACK); |
| 1235 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1236 | //Fill RTS |
| 1237 | s_vFillRTSHead(pDevice, byPktType, pvRTS, cbFrameSize, bNeedACK, bDisCRC, psEthHeader, wCurrentRate, byFBOption); |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 1238 | } else if (pvRTS == NULL) {//RTS_needless, non PCF mode |
Malcolm Priestley | c00a378 | 2014-08-30 22:25:32 +0100 | [diff] [blame] | 1239 | struct vnt_rrv_time_ab *buf = pvRrvTime; |
Guillaume Clement | 6b71127 | 2014-07-25 01:06:16 +0200 | [diff] [blame] | 1240 | |
Malcolm Priestley | c00a378 | 2014-08-30 22:25:32 +0100 | [diff] [blame] | 1241 | buf->rrv_time = vnt_rxtx_rsvtime_le16(pDevice, PK_TYPE_11A, cbFrameSize, wCurrentRate, bNeedACK); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1242 | } |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 1243 | } else if (byPktType == PK_TYPE_11B) { |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1244 | if ((pvRTS != NULL)) {//RTS_need, non PCF mode |
Malcolm Priestley | c00a378 | 2014-08-30 22:25:32 +0100 | [diff] [blame] | 1245 | struct vnt_rrv_time_ab *buf = pvRrvTime; |
Guillaume Clement | 6b71127 | 2014-07-25 01:06:16 +0200 | [diff] [blame] | 1246 | |
Malcolm Priestley | c00a378 | 2014-08-30 22:25:32 +0100 | [diff] [blame] | 1247 | buf->rts_rrv_time = s_uGetRTSCTSRsvTime(pDevice, 0, byPktType, cbFrameSize, wCurrentRate); |
| 1248 | buf->rrv_time = vnt_rxtx_rsvtime_le16(pDevice, PK_TYPE_11B, cbFrameSize, wCurrentRate, bNeedACK); |
| 1249 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1250 | //Fill RTS |
| 1251 | s_vFillRTSHead(pDevice, byPktType, pvRTS, cbFrameSize, bNeedACK, bDisCRC, psEthHeader, wCurrentRate, byFBOption); |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 1252 | } else { //RTS_needless, non PCF mode |
Malcolm Priestley | c00a378 | 2014-08-30 22:25:32 +0100 | [diff] [blame] | 1253 | struct vnt_rrv_time_ab *buf = pvRrvTime; |
Guillaume Clement | 6b71127 | 2014-07-25 01:06:16 +0200 | [diff] [blame] | 1254 | |
Malcolm Priestley | c00a378 | 2014-08-30 22:25:32 +0100 | [diff] [blame] | 1255 | buf->rrv_time = vnt_rxtx_rsvtime_le16(pDevice, PK_TYPE_11B, cbFrameSize, wCurrentRate, bNeedACK); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1256 | } |
| 1257 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1258 | } |
Guido Martínez | 4e8a7e5 | 2014-04-19 16:44:59 -0300 | [diff] [blame] | 1259 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1260 | static |
Charles Clément | 6b35b7b | 2010-05-07 12:30:19 -0700 | [diff] [blame] | 1261 | void |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1262 | s_vFillFragParameter( |
Malcolm Priestley | cf76dc4 | 2014-08-10 15:46:59 +0100 | [diff] [blame] | 1263 | struct vnt_private *pDevice, |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1264 | unsigned char *pbyBuffer, |
| 1265 | unsigned int uTxType, |
| 1266 | void *pvtdCurr, |
| 1267 | unsigned short wFragType, |
| 1268 | unsigned int cbReqCount |
| 1269 | ) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1270 | { |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1271 | PSTxBufHead pTxBufHead = (PSTxBufHead) pbyBuffer; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1272 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1273 | if (uTxType == TYPE_SYNCDMA) { |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1274 | PSTxSyncDesc ptdCurr = (PSTxSyncDesc)pvtdCurr; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1275 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1276 | //Set FIFOCtl & TimeStamp in TxSyncDesc |
| 1277 | ptdCurr->m_wFIFOCtl = pTxBufHead->wFIFOCtl; |
| 1278 | ptdCurr->m_wTimeStamp = pTxBufHead->wTimeStamp; |
| 1279 | //Set TSR1 & ReqCount in TxDescHead |
| 1280 | ptdCurr->m_td1TD1.wReqCount = cpu_to_le16((unsigned short)(cbReqCount)); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 1281 | if (wFragType == FRAGCTL_ENDFRAG) //Last Fragmentation |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1282 | ptdCurr->m_td1TD1.byTCR |= (TCR_STP | TCR_EDP | EDMSDU); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 1283 | else |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1284 | ptdCurr->m_td1TD1.byTCR |= (TCR_STP | TCR_EDP); |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 1285 | } else { |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1286 | PSTxDesc ptdCurr = (PSTxDesc)pvtdCurr; |
| 1287 | //Set TSR1 & ReqCount in TxDescHead |
| 1288 | ptdCurr->m_td1TD1.wReqCount = cpu_to_le16((unsigned short)(cbReqCount)); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 1289 | if (wFragType == FRAGCTL_ENDFRAG) //Last Fragmentation |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1290 | ptdCurr->m_td1TD1.byTCR |= (TCR_STP | TCR_EDP | EDMSDU); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 1291 | else |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1292 | ptdCurr->m_td1TD1.byTCR |= (TCR_STP | TCR_EDP); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1293 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1294 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1295 | pTxBufHead->wFragCtl |= (unsigned short)wFragType;//0x0001; //0000 0000 0000 0001 |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1296 | } |
| 1297 | |
Charles Clément | fe4f34b | 2010-06-25 10:48:53 -0700 | [diff] [blame] | 1298 | static unsigned int |
Malcolm Priestley | cf76dc4 | 2014-08-10 15:46:59 +0100 | [diff] [blame] | 1299 | s_cbFillTxBufHead(struct vnt_private *pDevice, unsigned char byPktType, |
| 1300 | unsigned char *pbyTxBufferAddr, unsigned int cbFrameBodySize, |
| 1301 | unsigned int uDMAIdx, PSTxDesc pHeadTD, |
| 1302 | PSEthernetHeader psEthHeader, unsigned char *pPacket, |
| 1303 | bool bNeedEncrypt, PSKeyItem pTransmitKey, |
| 1304 | unsigned int uNodeIndex, unsigned int *puMACfragNum) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1305 | { |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1306 | unsigned int cbMACHdLen; |
| 1307 | unsigned int cbFrameSize; |
| 1308 | unsigned int cbFragmentSize; //Hdr+(IV)+payoad+(MIC)+(ICV)+FCS |
| 1309 | unsigned int cbFragPayloadSize; |
| 1310 | unsigned int cbLastFragmentSize; //Hdr+(IV)+payoad+(MIC)+(ICV)+FCS |
| 1311 | unsigned int cbLastFragPayloadSize; |
| 1312 | unsigned int uFragIdx; |
| 1313 | unsigned char *pbyPayloadHead; |
| 1314 | unsigned char *pbyIVHead; |
| 1315 | unsigned char *pbyMacHdr; |
| 1316 | unsigned short wFragType; //00:Non-Frag, 01:Start, 10:Mid, 11:Last |
Malcolm Priestley | a479ffc | 2014-08-30 22:25:38 +0100 | [diff] [blame] | 1317 | __le16 uDuration; |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1318 | unsigned char *pbyBuffer; |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1319 | unsigned int cbIVlen = 0; |
| 1320 | unsigned int cbICVlen = 0; |
| 1321 | unsigned int cbMIClen = 0; |
| 1322 | unsigned int cbFCSlen = 4; |
| 1323 | unsigned int cb802_1_H_len = 0; |
| 1324 | unsigned int uLength = 0; |
| 1325 | unsigned int uTmpLen = 0; |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1326 | unsigned int cbMICHDR = 0; |
Malcolm Priestley | 12ca22b | 2014-03-06 22:44:25 +0000 | [diff] [blame] | 1327 | u32 dwMICKey0, dwMICKey1; |
| 1328 | u32 dwMIC_Priority; |
Malcolm Priestley | d0daef3 | 2014-03-06 22:44:23 +0000 | [diff] [blame] | 1329 | u32 *pdwMIC_L; |
| 1330 | u32 *pdwMIC_R; |
Malcolm Priestley | 12ca22b | 2014-03-06 22:44:25 +0000 | [diff] [blame] | 1331 | u32 dwSafeMIC_L, dwSafeMIC_R; /* Fix "Last Frag Size" < "MIC length". */ |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1332 | bool bMIC2Frag = false; |
| 1333 | unsigned int uMICFragLen = 0; |
| 1334 | unsigned int uMACfragNum = 1; |
| 1335 | unsigned int uPadding = 0; |
| 1336 | unsigned int cbReqCount = 0; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1337 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1338 | bool bNeedACK; |
| 1339 | bool bRTS; |
| 1340 | bool bIsAdhoc; |
| 1341 | unsigned char *pbyType; |
| 1342 | PSTxDesc ptdCurr; |
| 1343 | PSTxBufHead psTxBufHd = (PSTxBufHead) pbyTxBufferAddr; |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1344 | unsigned int cbHeaderLength = 0; |
| 1345 | void *pvRrvTime; |
Malcolm Priestley | 11a72e5 | 2014-08-09 20:15:56 +0100 | [diff] [blame] | 1346 | struct vnt_mic_hdr *pMICHDR; |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1347 | void *pvRTS; |
| 1348 | void *pvCTS; |
| 1349 | void *pvTxDataHd; |
| 1350 | unsigned short wTxBufSize; // FFinfo size |
| 1351 | unsigned int uTotalCopyLength = 0; |
| 1352 | unsigned char byFBOption = AUTO_FB_NONE; |
| 1353 | bool bIsWEP256 = false; |
| 1354 | PSMgmtObject pMgmt = pDevice->pMgmt; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1355 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1356 | pvRrvTime = pMICHDR = pvRTS = pvCTS = pvTxDataHd = NULL; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1357 | |
Malcolm Priestley | a987367 | 2014-08-30 22:25:49 +0100 | [diff] [blame] | 1358 | if ((pDevice->op_mode == NL80211_IFTYPE_ADHOC) || |
| 1359 | (pDevice->op_mode == NL80211_IFTYPE_AP)) { |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1360 | if (is_multicast_ether_addr(&(psEthHeader->abyDstAddr[0]))) |
| 1361 | bNeedACK = false; |
| 1362 | else |
| 1363 | bNeedACK = true; |
| 1364 | bIsAdhoc = true; |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 1365 | } else { |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1366 | // MSDUs in Infra mode always need ACK |
| 1367 | bNeedACK = true; |
| 1368 | bIsAdhoc = false; |
| 1369 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1370 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1371 | if (pDevice->bLongHeader) |
| 1372 | cbMACHdLen = WLAN_HDR_ADDR3_LEN + 6; |
| 1373 | else |
| 1374 | cbMACHdLen = WLAN_HDR_ADDR3_LEN; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1375 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1376 | if ((bNeedEncrypt == true) && (pTransmitKey != NULL)) { |
| 1377 | if (pTransmitKey->byCipherSuite == KEY_CTL_WEP) { |
| 1378 | cbIVlen = 4; |
| 1379 | cbICVlen = 4; |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 1380 | if (pTransmitKey->uKeyLength == WLAN_WEP232_KEYLEN) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1381 | bIsWEP256 = true; |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1382 | } |
| 1383 | if (pTransmitKey->byCipherSuite == KEY_CTL_TKIP) { |
| 1384 | cbIVlen = 8;//IV+ExtIV |
| 1385 | cbMIClen = 8; |
| 1386 | cbICVlen = 4; |
| 1387 | } |
| 1388 | if (pTransmitKey->byCipherSuite == KEY_CTL_CCMP) { |
| 1389 | cbIVlen = 8;//RSN Header |
| 1390 | cbICVlen = 8;//MIC |
Malcolm Priestley | 11a72e5 | 2014-08-09 20:15:56 +0100 | [diff] [blame] | 1391 | cbMICHDR = sizeof(struct vnt_mic_hdr); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1392 | } |
| 1393 | if (pDevice->byLocalID > REV_ID_VT3253_A1) { |
| 1394 | //MAC Header should be padding 0 to DW alignment. |
| 1395 | uPadding = 4 - (cbMACHdLen%4); |
| 1396 | uPadding %= 4; |
| 1397 | } |
| 1398 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1399 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1400 | cbFrameSize = cbMACHdLen + cbIVlen + (cbFrameBodySize + cbMIClen) + cbICVlen + cbFCSlen; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1401 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1402 | if ((bNeedACK == false) || |
| 1403 | (cbFrameSize < pDevice->wRTSThreshold) || |
| 1404 | ((cbFrameSize >= pDevice->wFragmentationThreshold) && (pDevice->wFragmentationThreshold <= pDevice->wRTSThreshold)) |
| 1405 | ) { |
| 1406 | bRTS = false; |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 1407 | } else { |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1408 | bRTS = true; |
| 1409 | psTxBufHd->wFIFOCtl |= (FIFOCTL_RTS | FIFOCTL_LRETRY); |
| 1410 | } |
| 1411 | // |
| 1412 | // Use for AUTO FALL BACK |
| 1413 | // |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 1414 | if (psTxBufHd->wFIFOCtl & FIFOCTL_AUTO_FB_0) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1415 | byFBOption = AUTO_FB_0; |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 1416 | else if (psTxBufHd->wFIFOCtl & FIFOCTL_AUTO_FB_1) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1417 | byFBOption = AUTO_FB_1; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1418 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1419 | ////////////////////////////////////////////////////// |
| 1420 | //Set RrvTime/RTS/CTS Buffer |
| 1421 | wTxBufSize = sizeof(STxBufHead); |
| 1422 | if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) {//802.11g packet |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1423 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1424 | if (byFBOption == AUTO_FB_NONE) { |
| 1425 | if (bRTS == true) {//RTS_need |
Malcolm Priestley | a9e6a2d | 2014-08-30 22:25:27 +0100 | [diff] [blame] | 1426 | pvRrvTime = (void *)(pbyTxBufferAddr + wTxBufSize); |
| 1427 | pMICHDR = (struct vnt_mic_hdr *)(pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_rts)); |
Malcolm Priestley | 17434f0 | 2014-08-30 22:25:41 +0100 | [diff] [blame] | 1428 | pvRTS = (void *)(pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_rts) + cbMICHDR); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1429 | pvCTS = NULL; |
Malcolm Priestley | 17434f0 | 2014-08-30 22:25:41 +0100 | [diff] [blame] | 1430 | pvTxDataHd = (void *)(pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_rts) + |
| 1431 | cbMICHDR + sizeof(struct vnt_rts_g)); |
Malcolm Priestley | 72edb7e | 2014-08-30 22:25:34 +0100 | [diff] [blame] | 1432 | cbHeaderLength = wTxBufSize + sizeof(struct vnt_rrv_time_rts) + |
Malcolm Priestley | 17434f0 | 2014-08-30 22:25:41 +0100 | [diff] [blame] | 1433 | cbMICHDR + sizeof(struct vnt_rts_g) + |
| 1434 | sizeof(struct vnt_tx_datahead_g); |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 1435 | } else { //RTS_needless |
Malcolm Priestley | d66a5a7 | 2014-08-30 22:25:28 +0100 | [diff] [blame] | 1436 | pvRrvTime = (void *)(pbyTxBufferAddr + wTxBufSize); |
| 1437 | pMICHDR = (struct vnt_mic_hdr *) (pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_cts)); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1438 | pvRTS = NULL; |
Malcolm Priestley | f5172b0 | 2014-08-30 22:25:45 +0100 | [diff] [blame] | 1439 | pvCTS = (void *) (pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_cts) + cbMICHDR); |
| 1440 | pvTxDataHd = (void *)(pbyTxBufferAddr + wTxBufSize + |
| 1441 | sizeof(struct vnt_rrv_time_cts) + cbMICHDR + sizeof(struct vnt_cts)); |
Malcolm Priestley | 72edb7e | 2014-08-30 22:25:34 +0100 | [diff] [blame] | 1442 | cbHeaderLength = wTxBufSize + sizeof(struct vnt_rrv_time_cts) + |
Malcolm Priestley | f5172b0 | 2014-08-30 22:25:45 +0100 | [diff] [blame] | 1443 | cbMICHDR + sizeof(struct vnt_cts) + sizeof(struct vnt_tx_datahead_g); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1444 | } |
| 1445 | } else { |
| 1446 | // Auto Fall Back |
| 1447 | if (bRTS == true) {//RTS_need |
Malcolm Priestley | a9e6a2d | 2014-08-30 22:25:27 +0100 | [diff] [blame] | 1448 | pvRrvTime = (void *)(pbyTxBufferAddr + wTxBufSize); |
| 1449 | pMICHDR = (struct vnt_mic_hdr *) (pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_rts)); |
Malcolm Priestley | 9587b09 | 2014-08-30 22:25:42 +0100 | [diff] [blame] | 1450 | pvRTS = (void *) (pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_rts) + cbMICHDR); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1451 | pvCTS = NULL; |
Malcolm Priestley | 9587b09 | 2014-08-30 22:25:42 +0100 | [diff] [blame] | 1452 | pvTxDataHd = (void *)(pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_rts) + |
| 1453 | cbMICHDR + sizeof(struct vnt_rts_g_fb)); |
Malcolm Priestley | 2dd7667 | 2014-08-30 22:25:35 +0100 | [diff] [blame] | 1454 | cbHeaderLength = wTxBufSize + sizeof(struct vnt_rrv_time_rts) + |
Malcolm Priestley | 9587b09 | 2014-08-30 22:25:42 +0100 | [diff] [blame] | 1455 | cbMICHDR + sizeof(struct vnt_rts_g_fb) + sizeof(struct vnt_tx_datahead_g_fb); |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 1456 | } else { //RTS_needless |
Malcolm Priestley | d66a5a7 | 2014-08-30 22:25:28 +0100 | [diff] [blame] | 1457 | pvRrvTime = (void *)(pbyTxBufferAddr + wTxBufSize); |
| 1458 | pMICHDR = (struct vnt_mic_hdr *) (pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_cts)); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1459 | pvRTS = NULL; |
Malcolm Priestley | db1afd1 | 2014-08-30 22:25:46 +0100 | [diff] [blame] | 1460 | pvCTS = (void *)(pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_cts) + cbMICHDR); |
| 1461 | pvTxDataHd = (void *)(pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_cts) + |
| 1462 | cbMICHDR + sizeof(struct vnt_cts_fb)); |
Malcolm Priestley | 2dd7667 | 2014-08-30 22:25:35 +0100 | [diff] [blame] | 1463 | cbHeaderLength = wTxBufSize + sizeof(struct vnt_rrv_time_cts) + |
Malcolm Priestley | db1afd1 | 2014-08-30 22:25:46 +0100 | [diff] [blame] | 1464 | cbMICHDR + sizeof(struct vnt_cts_fb) + sizeof(struct vnt_tx_datahead_g_fb); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1465 | } |
| 1466 | } // Auto Fall Back |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 1467 | } else {//802.11a/b packet |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1468 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1469 | if (byFBOption == AUTO_FB_NONE) { |
| 1470 | if (bRTS == true) { |
Malcolm Priestley | f6a634c | 2014-08-30 22:25:29 +0100 | [diff] [blame] | 1471 | pvRrvTime = (void *)(pbyTxBufferAddr + wTxBufSize); |
| 1472 | pMICHDR = (struct vnt_mic_hdr *) (pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_ab)); |
Malcolm Priestley | e21eb1c | 2014-08-30 22:25:43 +0100 | [diff] [blame] | 1473 | pvRTS = (void *)(pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_ab) + cbMICHDR); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1474 | pvCTS = NULL; |
Malcolm Priestley | 9ce842a | 2014-08-30 22:25:36 +0100 | [diff] [blame] | 1475 | pvTxDataHd = (void *)(pbyTxBufferAddr + wTxBufSize + |
Malcolm Priestley | e21eb1c | 2014-08-30 22:25:43 +0100 | [diff] [blame] | 1476 | sizeof(struct vnt_rrv_time_ab) + cbMICHDR + sizeof(struct vnt_rts_ab)); |
Malcolm Priestley | 9ce842a | 2014-08-30 22:25:36 +0100 | [diff] [blame] | 1477 | cbHeaderLength = wTxBufSize + sizeof(struct vnt_rrv_time_ab) + |
Malcolm Priestley | e21eb1c | 2014-08-30 22:25:43 +0100 | [diff] [blame] | 1478 | cbMICHDR + sizeof(struct vnt_rts_ab) + sizeof(struct vnt_tx_datahead_ab); |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 1479 | } else { //RTS_needless, need MICHDR |
Malcolm Priestley | f6a634c | 2014-08-30 22:25:29 +0100 | [diff] [blame] | 1480 | pvRrvTime = (void *)(pbyTxBufferAddr + wTxBufSize); |
| 1481 | pMICHDR = (struct vnt_mic_hdr *) (pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_ab)); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1482 | pvRTS = NULL; |
| 1483 | pvCTS = NULL; |
Malcolm Priestley | 9ce842a | 2014-08-30 22:25:36 +0100 | [diff] [blame] | 1484 | pvTxDataHd = (void *)(pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_ab) + cbMICHDR); |
| 1485 | cbHeaderLength = wTxBufSize + sizeof(struct vnt_rrv_time_ab) + |
| 1486 | cbMICHDR + sizeof(struct vnt_tx_datahead_ab); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1487 | } |
| 1488 | } else { |
| 1489 | // Auto Fall Back |
| 1490 | if (bRTS == true) {//RTS_need |
Malcolm Priestley | f6a634c | 2014-08-30 22:25:29 +0100 | [diff] [blame] | 1491 | pvRrvTime = (void *)(pbyTxBufferAddr + wTxBufSize); |
| 1492 | pMICHDR = (struct vnt_mic_hdr *) (pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_ab)); |
Malcolm Priestley | 8e44804 | 2014-08-30 22:25:44 +0100 | [diff] [blame] | 1493 | pvRTS = (void *)(pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_ab) + cbMICHDR); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1494 | pvCTS = NULL; |
Malcolm Priestley | 8e44804 | 2014-08-30 22:25:44 +0100 | [diff] [blame] | 1495 | pvTxDataHd = (void *)(pbyTxBufferAddr + wTxBufSize + |
| 1496 | sizeof(struct vnt_rrv_time_ab) + cbMICHDR + sizeof(struct vnt_rts_a_fb)); |
Malcolm Priestley | 9c62c7a | 2014-08-30 22:25:37 +0100 | [diff] [blame] | 1497 | cbHeaderLength = wTxBufSize + sizeof(struct vnt_rrv_time_ab) + |
Malcolm Priestley | 8e44804 | 2014-08-30 22:25:44 +0100 | [diff] [blame] | 1498 | cbMICHDR + sizeof(struct vnt_rts_a_fb) + sizeof(struct vnt_tx_datahead_a_fb); |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 1499 | } else { //RTS_needless |
Malcolm Priestley | f6a634c | 2014-08-30 22:25:29 +0100 | [diff] [blame] | 1500 | pvRrvTime = (void *)(pbyTxBufferAddr + wTxBufSize); |
| 1501 | pMICHDR = (struct vnt_mic_hdr *)(pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_ab)); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1502 | pvRTS = NULL; |
| 1503 | pvCTS = NULL; |
Malcolm Priestley | 9c62c7a | 2014-08-30 22:25:37 +0100 | [diff] [blame] | 1504 | pvTxDataHd = (void *)(pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_ab) + cbMICHDR); |
| 1505 | cbHeaderLength = wTxBufSize + sizeof(struct vnt_rrv_time_ab) + |
| 1506 | cbMICHDR + sizeof(struct vnt_tx_datahead_a_fb); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1507 | } |
| 1508 | } // Auto Fall Back |
| 1509 | } |
| 1510 | memset((void *)(pbyTxBufferAddr + wTxBufSize), 0, (cbHeaderLength - wTxBufSize)); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1511 | |
| 1512 | ////////////////////////////////////////////////////////////////// |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1513 | if ((bNeedEncrypt == true) && (pTransmitKey != NULL) && (pTransmitKey->byCipherSuite == KEY_CTL_TKIP)) { |
| 1514 | if (pDevice->pMgmt->eAuthenMode == WMAC_AUTH_WPANONE) { |
Malcolm Priestley | 12ca22b | 2014-03-06 22:44:25 +0000 | [diff] [blame] | 1515 | dwMICKey0 = *(u32 *)(&pTransmitKey->abyKey[16]); |
| 1516 | dwMICKey1 = *(u32 *)(&pTransmitKey->abyKey[20]); |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 1517 | } else if ((pTransmitKey->dwKeyIndex & AUTHENTICATOR_KEY) != 0) { |
Malcolm Priestley | 12ca22b | 2014-03-06 22:44:25 +0000 | [diff] [blame] | 1518 | dwMICKey0 = *(u32 *)(&pTransmitKey->abyKey[16]); |
| 1519 | dwMICKey1 = *(u32 *)(&pTransmitKey->abyKey[20]); |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 1520 | } else { |
Malcolm Priestley | 12ca22b | 2014-03-06 22:44:25 +0000 | [diff] [blame] | 1521 | dwMICKey0 = *(u32 *)(&pTransmitKey->abyKey[24]); |
| 1522 | dwMICKey1 = *(u32 *)(&pTransmitKey->abyKey[28]); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1523 | } |
| 1524 | // DO Software Michael |
| 1525 | MIC_vInit(dwMICKey0, dwMICKey1); |
| 1526 | MIC_vAppend((unsigned char *)&(psEthHeader->abyDstAddr[0]), 12); |
| 1527 | dwMIC_Priority = 0; |
| 1528 | MIC_vAppend((unsigned char *)&dwMIC_Priority, 4); |
Joe Perches | 48caf5a | 2014-08-17 09:17:04 -0700 | [diff] [blame] | 1529 | pr_debug("MIC KEY: %X, %X\n", dwMICKey0, dwMICKey1); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1530 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1531 | |
| 1532 | /////////////////////////////////////////////////////////////////// |
| 1533 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1534 | pbyMacHdr = (unsigned char *)(pbyTxBufferAddr + cbHeaderLength); |
| 1535 | pbyPayloadHead = (unsigned char *)(pbyMacHdr + cbMACHdLen + uPadding + cbIVlen); |
| 1536 | pbyIVHead = (unsigned char *)(pbyMacHdr + cbMACHdLen + uPadding); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1537 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1538 | if ((cbFrameSize > pDevice->wFragmentationThreshold) && (bNeedACK == true) && (bIsWEP256 == false)) { |
| 1539 | // Fragmentation |
| 1540 | // FragThreshold = Fragment size(Hdr+(IV)+fragment payload+(MIC)+(ICV)+FCS) |
| 1541 | cbFragmentSize = pDevice->wFragmentationThreshold; |
| 1542 | cbFragPayloadSize = cbFragmentSize - cbMACHdLen - cbIVlen - cbICVlen - cbFCSlen; |
| 1543 | //FragNum = (FrameSize-(Hdr+FCS))/(Fragment Size -(Hrd+FCS))) |
| 1544 | uMACfragNum = (unsigned short) ((cbFrameBodySize + cbMIClen) / cbFragPayloadSize); |
| 1545 | cbLastFragPayloadSize = (cbFrameBodySize + cbMIClen) % cbFragPayloadSize; |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 1546 | if (cbLastFragPayloadSize == 0) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1547 | cbLastFragPayloadSize = cbFragPayloadSize; |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 1548 | else |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1549 | uMACfragNum++; |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 1550 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1551 | //[Hdr+(IV)+last fragment payload+(MIC)+(ICV)+FCS] |
| 1552 | cbLastFragmentSize = cbMACHdLen + cbLastFragPayloadSize + cbIVlen + cbICVlen + cbFCSlen; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1553 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1554 | for (uFragIdx = 0; uFragIdx < uMACfragNum; uFragIdx++) { |
| 1555 | if (uFragIdx == 0) { |
| 1556 | //========================= |
| 1557 | // Start Fragmentation |
| 1558 | //========================= |
Joe Perches | 48caf5a | 2014-08-17 09:17:04 -0700 | [diff] [blame] | 1559 | pr_debug("Start Fragmentation...\n"); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1560 | wFragType = FRAGCTL_STAFRAG; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1561 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1562 | //Fill FIFO,RrvTime,RTS,and CTS |
| 1563 | s_vGenerateTxParameter(pDevice, byPktType, (void *)psTxBufHd, pvRrvTime, pvRTS, pvCTS, |
| 1564 | cbFragmentSize, bNeedACK, uDMAIdx, psEthHeader, pDevice->wCurrentRate); |
| 1565 | //Fill DataHead |
| 1566 | uDuration = s_uFillDataHead(pDevice, byPktType, pvTxDataHd, cbFragmentSize, uDMAIdx, bNeedACK, |
| 1567 | uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption, pDevice->wCurrentRate); |
| 1568 | // Generate TX MAC Header |
Malcolm Priestley | a479ffc | 2014-08-30 22:25:38 +0100 | [diff] [blame] | 1569 | vGenerateMACHeader(pDevice, pbyMacHdr, uDuration, psEthHeader, bNeedEncrypt, |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1570 | wFragType, uDMAIdx, uFragIdx); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1571 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1572 | if (bNeedEncrypt == true) { |
| 1573 | //Fill TXKEY |
| 1574 | s_vFillTxKey(pDevice, (unsigned char *)(psTxBufHd->adwTxKey), pbyIVHead, pTransmitKey, |
| 1575 | pbyMacHdr, (unsigned short)cbFragPayloadSize, (unsigned char *)pMICHDR); |
| 1576 | //Fill IV(ExtIV,RSNHDR) |
| 1577 | if (pDevice->bEnableHostWEP) { |
| 1578 | pMgmt->sNodeDBTable[uNodeIndex].dwTSC47_16 = pTransmitKey->dwTSC47_16; |
| 1579 | pMgmt->sNodeDBTable[uNodeIndex].wTSC15_0 = pTransmitKey->wTSC15_0; |
| 1580 | } |
| 1581 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1582 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1583 | // 802.1H |
| 1584 | if (ntohs(psEthHeader->wType) > ETH_DATA_LEN) { |
| 1585 | if ((psEthHeader->wType == TYPE_PKT_IPX) || |
| 1586 | (psEthHeader->wType == cpu_to_le16(0xF380))) { |
| 1587 | memcpy((unsigned char *)(pbyPayloadHead), &pDevice->abySNAP_Bridgetunnel[0], 6); |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 1588 | } else { |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1589 | memcpy((unsigned char *)(pbyPayloadHead), &pDevice->abySNAP_RFC1042[0], 6); |
| 1590 | } |
| 1591 | pbyType = (unsigned char *)(pbyPayloadHead + 6); |
| 1592 | memcpy(pbyType, &(psEthHeader->wType), sizeof(unsigned short)); |
| 1593 | cb802_1_H_len = 8; |
| 1594 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1595 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1596 | cbReqCount = cbHeaderLength + cbMACHdLen + uPadding + cbIVlen + cbFragPayloadSize; |
| 1597 | //--------------------------- |
| 1598 | // S/W or H/W Encryption |
| 1599 | //--------------------------- |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1600 | pbyBuffer = (unsigned char *)pHeadTD->pTDInfo->buf; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1601 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1602 | uLength = cbHeaderLength + cbMACHdLen + uPadding + cbIVlen + cb802_1_H_len; |
| 1603 | //copy TxBufferHeader + MacHeader to desc |
| 1604 | memcpy(pbyBuffer, (void *)psTxBufHd, uLength); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1605 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1606 | // Copy the Packet into a tx Buffer |
| 1607 | memcpy((pbyBuffer + uLength), (pPacket + 14), (cbFragPayloadSize - cb802_1_H_len)); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1608 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1609 | uTotalCopyLength += cbFragPayloadSize - cb802_1_H_len; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1610 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1611 | if ((bNeedEncrypt == true) && (pTransmitKey != NULL) && (pTransmitKey->byCipherSuite == KEY_CTL_TKIP)) { |
Joe Perches | 48caf5a | 2014-08-17 09:17:04 -0700 | [diff] [blame] | 1612 | pr_debug("Start MIC: %d\n", |
| 1613 | cbFragPayloadSize); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1614 | MIC_vAppend((pbyBuffer + uLength - cb802_1_H_len), cbFragPayloadSize); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1615 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1616 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1617 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1618 | //--------------------------- |
| 1619 | // S/W Encryption |
| 1620 | //--------------------------- |
| 1621 | if ((pDevice->byLocalID <= REV_ID_VT3253_A1)) { |
| 1622 | if (bNeedEncrypt) { |
| 1623 | s_vSWencryption(pDevice, pTransmitKey, (pbyBuffer + uLength - cb802_1_H_len), (unsigned short)cbFragPayloadSize); |
| 1624 | cbReqCount += cbICVlen; |
| 1625 | } |
| 1626 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1627 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1628 | ptdCurr = (PSTxDesc)pHeadTD; |
| 1629 | //-------------------- |
| 1630 | //1.Set TSR1 & ReqCount in TxDescHead |
| 1631 | //2.Set FragCtl in TxBufferHead |
| 1632 | //3.Set Frame Control |
| 1633 | //4.Set Sequence Control |
| 1634 | //5.Get S/W generate FCS |
| 1635 | //-------------------- |
| 1636 | s_vFillFragParameter(pDevice, pbyBuffer, uDMAIdx, (void *)ptdCurr, wFragType, cbReqCount); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1637 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1638 | ptdCurr->pTDInfo->dwReqCount = cbReqCount - uPadding; |
| 1639 | ptdCurr->pTDInfo->dwHeaderLength = cbHeaderLength; |
| 1640 | ptdCurr->pTDInfo->skb_dma = ptdCurr->pTDInfo->buf_dma; |
| 1641 | ptdCurr->buff_addr = cpu_to_le32(ptdCurr->pTDInfo->skb_dma); |
| 1642 | pDevice->iTDUsed[uDMAIdx]++; |
| 1643 | pHeadTD = ptdCurr->next; |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 1644 | } else if (uFragIdx == (uMACfragNum-1)) { |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1645 | //========================= |
| 1646 | // Last Fragmentation |
| 1647 | //========================= |
Joe Perches | 48caf5a | 2014-08-17 09:17:04 -0700 | [diff] [blame] | 1648 | pr_debug("Last Fragmentation...\n"); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1649 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1650 | wFragType = FRAGCTL_ENDFRAG; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1651 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1652 | //Fill FIFO,RrvTime,RTS,and CTS |
| 1653 | s_vGenerateTxParameter(pDevice, byPktType, (void *)psTxBufHd, pvRrvTime, pvRTS, pvCTS, |
| 1654 | cbLastFragmentSize, bNeedACK, uDMAIdx, psEthHeader, pDevice->wCurrentRate); |
| 1655 | //Fill DataHead |
| 1656 | uDuration = s_uFillDataHead(pDevice, byPktType, pvTxDataHd, cbLastFragmentSize, uDMAIdx, bNeedACK, |
| 1657 | uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption, pDevice->wCurrentRate); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1658 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1659 | // Generate TX MAC Header |
Malcolm Priestley | a479ffc | 2014-08-30 22:25:38 +0100 | [diff] [blame] | 1660 | vGenerateMACHeader(pDevice, pbyMacHdr, uDuration, psEthHeader, bNeedEncrypt, |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1661 | wFragType, uDMAIdx, uFragIdx); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1662 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1663 | if (bNeedEncrypt == true) { |
| 1664 | //Fill TXKEY |
| 1665 | s_vFillTxKey(pDevice, (unsigned char *)(psTxBufHd->adwTxKey), pbyIVHead, pTransmitKey, |
| 1666 | pbyMacHdr, (unsigned short)cbLastFragPayloadSize, (unsigned char *)pMICHDR); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1667 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1668 | if (pDevice->bEnableHostWEP) { |
| 1669 | pMgmt->sNodeDBTable[uNodeIndex].dwTSC47_16 = pTransmitKey->dwTSC47_16; |
| 1670 | pMgmt->sNodeDBTable[uNodeIndex].wTSC15_0 = pTransmitKey->wTSC15_0; |
| 1671 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1672 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1673 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1674 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1675 | cbReqCount = cbHeaderLength + cbMACHdLen + uPadding + cbIVlen + cbLastFragPayloadSize; |
| 1676 | //--------------------------- |
| 1677 | // S/W or H/W Encryption |
| 1678 | //--------------------------- |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1679 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1680 | pbyBuffer = (unsigned char *)pHeadTD->pTDInfo->buf; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1681 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1682 | uLength = cbHeaderLength + cbMACHdLen + uPadding + cbIVlen; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1683 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1684 | //copy TxBufferHeader + MacHeader to desc |
| 1685 | memcpy(pbyBuffer, (void *)psTxBufHd, uLength); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1686 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1687 | // Copy the Packet into a tx Buffer |
| 1688 | if (bMIC2Frag == false) { |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1689 | memcpy((pbyBuffer + uLength), |
| 1690 | (pPacket + 14 + uTotalCopyLength), |
| 1691 | (cbLastFragPayloadSize - cbMIClen) |
| 1692 | ); |
| 1693 | //TODO check uTmpLen ! |
| 1694 | uTmpLen = cbLastFragPayloadSize - cbMIClen; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1695 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1696 | } |
| 1697 | if ((bNeedEncrypt == true) && (pTransmitKey != NULL) && (pTransmitKey->byCipherSuite == KEY_CTL_TKIP)) { |
Joe Perches | 48caf5a | 2014-08-17 09:17:04 -0700 | [diff] [blame] | 1698 | pr_debug("LAST: uMICFragLen:%d, cbLastFragPayloadSize:%d, uTmpLen:%d\n", |
| 1699 | uMICFragLen, |
| 1700 | cbLastFragPayloadSize, |
| 1701 | uTmpLen); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1702 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1703 | if (bMIC2Frag == false) { |
| 1704 | if (uTmpLen != 0) |
| 1705 | MIC_vAppend((pbyBuffer + uLength), uTmpLen); |
Malcolm Priestley | d0daef3 | 2014-03-06 22:44:23 +0000 | [diff] [blame] | 1706 | pdwMIC_L = (u32 *)(pbyBuffer + uLength + uTmpLen); |
| 1707 | pdwMIC_R = (u32 *)(pbyBuffer + uLength + uTmpLen + 4); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1708 | MIC_vGetMIC(pdwMIC_L, pdwMIC_R); |
Joe Perches | 48caf5a | 2014-08-17 09:17:04 -0700 | [diff] [blame] | 1709 | pr_debug("Last MIC:%X, %X\n", |
| 1710 | *pdwMIC_L, *pdwMIC_R); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1711 | } else { |
| 1712 | if (uMICFragLen >= 4) { |
| 1713 | memcpy((pbyBuffer + uLength), ((unsigned char *)&dwSafeMIC_R + (uMICFragLen - 4)), |
| 1714 | (cbMIClen - uMICFragLen)); |
Joe Perches | 48caf5a | 2014-08-17 09:17:04 -0700 | [diff] [blame] | 1715 | pr_debug("LAST: uMICFragLen >= 4: %X, %d\n", |
| 1716 | *(unsigned char *)((unsigned char *)&dwSafeMIC_R + (uMICFragLen - 4)), |
| 1717 | (cbMIClen - uMICFragLen)); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1718 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1719 | } else { |
| 1720 | memcpy((pbyBuffer + uLength), ((unsigned char *)&dwSafeMIC_L + uMICFragLen), |
| 1721 | (4 - uMICFragLen)); |
| 1722 | memcpy((pbyBuffer + uLength + (4 - uMICFragLen)), &dwSafeMIC_R, 4); |
Joe Perches | 48caf5a | 2014-08-17 09:17:04 -0700 | [diff] [blame] | 1723 | pr_debug("LAST: uMICFragLen < 4: %X, %d\n", |
| 1724 | *(unsigned char *)((unsigned char *)&dwSafeMIC_R + uMICFragLen - 4), |
| 1725 | (cbMIClen - uMICFragLen)); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1726 | } |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1727 | } |
| 1728 | MIC_vUnInit(); |
| 1729 | } else { |
| 1730 | ASSERT(uTmpLen == (cbLastFragPayloadSize - cbMIClen)); |
| 1731 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1732 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1733 | //--------------------------- |
| 1734 | // S/W Encryption |
| 1735 | //--------------------------- |
| 1736 | if ((pDevice->byLocalID <= REV_ID_VT3253_A1)) { |
| 1737 | if (bNeedEncrypt) { |
| 1738 | s_vSWencryption(pDevice, pTransmitKey, (pbyBuffer + uLength), (unsigned short)cbLastFragPayloadSize); |
| 1739 | cbReqCount += cbICVlen; |
| 1740 | } |
| 1741 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1742 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1743 | ptdCurr = (PSTxDesc)pHeadTD; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1744 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1745 | //-------------------- |
| 1746 | //1.Set TSR1 & ReqCount in TxDescHead |
| 1747 | //2.Set FragCtl in TxBufferHead |
| 1748 | //3.Set Frame Control |
| 1749 | //4.Set Sequence Control |
| 1750 | //5.Get S/W generate FCS |
| 1751 | //-------------------- |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1752 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1753 | s_vFillFragParameter(pDevice, pbyBuffer, uDMAIdx, (void *)ptdCurr, wFragType, cbReqCount); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1754 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1755 | ptdCurr->pTDInfo->dwReqCount = cbReqCount - uPadding; |
| 1756 | ptdCurr->pTDInfo->dwHeaderLength = cbHeaderLength; |
| 1757 | ptdCurr->pTDInfo->skb_dma = ptdCurr->pTDInfo->buf_dma; |
| 1758 | ptdCurr->buff_addr = cpu_to_le32(ptdCurr->pTDInfo->skb_dma); |
| 1759 | pDevice->iTDUsed[uDMAIdx]++; |
| 1760 | pHeadTD = ptdCurr->next; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1761 | |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 1762 | } else { |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1763 | //========================= |
| 1764 | // Middle Fragmentation |
| 1765 | //========================= |
Joe Perches | 48caf5a | 2014-08-17 09:17:04 -0700 | [diff] [blame] | 1766 | pr_debug("Middle Fragmentation...\n"); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1767 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1768 | wFragType = FRAGCTL_MIDFRAG; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1769 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1770 | //Fill FIFO,RrvTime,RTS,and CTS |
| 1771 | s_vGenerateTxParameter(pDevice, byPktType, (void *)psTxBufHd, pvRrvTime, pvRTS, pvCTS, |
| 1772 | cbFragmentSize, bNeedACK, uDMAIdx, psEthHeader, pDevice->wCurrentRate); |
| 1773 | //Fill DataHead |
| 1774 | uDuration = s_uFillDataHead(pDevice, byPktType, pvTxDataHd, cbFragmentSize, uDMAIdx, bNeedACK, |
| 1775 | uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption, pDevice->wCurrentRate); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1776 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1777 | // Generate TX MAC Header |
Malcolm Priestley | a479ffc | 2014-08-30 22:25:38 +0100 | [diff] [blame] | 1778 | vGenerateMACHeader(pDevice, pbyMacHdr, uDuration, psEthHeader, bNeedEncrypt, |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1779 | wFragType, uDMAIdx, uFragIdx); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1780 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1781 | if (bNeedEncrypt == true) { |
| 1782 | //Fill TXKEY |
| 1783 | s_vFillTxKey(pDevice, (unsigned char *)(psTxBufHd->adwTxKey), pbyIVHead, pTransmitKey, |
| 1784 | pbyMacHdr, (unsigned short)cbFragPayloadSize, (unsigned char *)pMICHDR); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1785 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1786 | if (pDevice->bEnableHostWEP) { |
| 1787 | pMgmt->sNodeDBTable[uNodeIndex].dwTSC47_16 = pTransmitKey->dwTSC47_16; |
| 1788 | pMgmt->sNodeDBTable[uNodeIndex].wTSC15_0 = pTransmitKey->wTSC15_0; |
| 1789 | } |
| 1790 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1791 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1792 | cbReqCount = cbHeaderLength + cbMACHdLen + uPadding + cbIVlen + cbFragPayloadSize; |
| 1793 | //--------------------------- |
| 1794 | // S/W or H/W Encryption |
| 1795 | //--------------------------- |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1796 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1797 | pbyBuffer = (unsigned char *)pHeadTD->pTDInfo->buf; |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1798 | uLength = cbHeaderLength + cbMACHdLen + uPadding + cbIVlen; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1799 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1800 | //copy TxBufferHeader + MacHeader to desc |
| 1801 | memcpy(pbyBuffer, (void *)psTxBufHd, uLength); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1802 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1803 | // Copy the Packet into a tx Buffer |
| 1804 | memcpy((pbyBuffer + uLength), |
| 1805 | (pPacket + 14 + uTotalCopyLength), |
| 1806 | cbFragPayloadSize |
| 1807 | ); |
| 1808 | uTmpLen = cbFragPayloadSize; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1809 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1810 | uTotalCopyLength += uTmpLen; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1811 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1812 | if ((bNeedEncrypt == true) && (pTransmitKey != NULL) && (pTransmitKey->byCipherSuite == KEY_CTL_TKIP)) { |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1813 | MIC_vAppend((pbyBuffer + uLength), uTmpLen); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1814 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1815 | if (uTmpLen < cbFragPayloadSize) { |
| 1816 | bMIC2Frag = true; |
| 1817 | uMICFragLen = cbFragPayloadSize - uTmpLen; |
| 1818 | ASSERT(uMICFragLen < cbMIClen); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1819 | |
Malcolm Priestley | d0daef3 | 2014-03-06 22:44:23 +0000 | [diff] [blame] | 1820 | pdwMIC_L = (u32 *)(pbyBuffer + uLength + uTmpLen); |
| 1821 | pdwMIC_R = (u32 *)(pbyBuffer + uLength + uTmpLen + 4); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1822 | MIC_vGetMIC(pdwMIC_L, pdwMIC_R); |
| 1823 | dwSafeMIC_L = *pdwMIC_L; |
| 1824 | dwSafeMIC_R = *pdwMIC_R; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1825 | |
Joe Perches | 48caf5a | 2014-08-17 09:17:04 -0700 | [diff] [blame] | 1826 | pr_debug("MIDDLE: uMICFragLen:%d, cbFragPayloadSize:%d, uTmpLen:%d\n", |
| 1827 | uMICFragLen, |
| 1828 | cbFragPayloadSize, |
| 1829 | uTmpLen); |
| 1830 | pr_debug("Fill MIC in Middle frag [%d]\n", |
| 1831 | uMICFragLen); |
| 1832 | pr_debug("Get MIC:%X, %X\n", |
| 1833 | *pdwMIC_L, *pdwMIC_R); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1834 | } |
Joe Perches | 48caf5a | 2014-08-17 09:17:04 -0700 | [diff] [blame] | 1835 | pr_debug("Middle frag len: %d\n", |
| 1836 | uTmpLen); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1837 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1838 | } else { |
| 1839 | ASSERT(uTmpLen == (cbFragPayloadSize)); |
| 1840 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1841 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1842 | if ((pDevice->byLocalID <= REV_ID_VT3253_A1)) { |
| 1843 | if (bNeedEncrypt) { |
| 1844 | s_vSWencryption(pDevice, pTransmitKey, (pbyBuffer + uLength), (unsigned short)cbFragPayloadSize); |
| 1845 | cbReqCount += cbICVlen; |
| 1846 | } |
| 1847 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1848 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1849 | ptdCurr = (PSTxDesc)pHeadTD; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1850 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1851 | //-------------------- |
| 1852 | //1.Set TSR1 & ReqCount in TxDescHead |
| 1853 | //2.Set FragCtl in TxBufferHead |
| 1854 | //3.Set Frame Control |
| 1855 | //4.Set Sequence Control |
| 1856 | //5.Get S/W generate FCS |
| 1857 | //-------------------- |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1858 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1859 | s_vFillFragParameter(pDevice, pbyBuffer, uDMAIdx, (void *)ptdCurr, wFragType, cbReqCount); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1860 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1861 | ptdCurr->pTDInfo->dwReqCount = cbReqCount - uPadding; |
| 1862 | ptdCurr->pTDInfo->dwHeaderLength = cbHeaderLength; |
| 1863 | ptdCurr->pTDInfo->skb_dma = ptdCurr->pTDInfo->buf_dma; |
| 1864 | ptdCurr->buff_addr = cpu_to_le32(ptdCurr->pTDInfo->skb_dma); |
| 1865 | pDevice->iTDUsed[uDMAIdx]++; |
| 1866 | pHeadTD = ptdCurr->next; |
| 1867 | } |
| 1868 | } // for (uMACfragNum) |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 1869 | } else { |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1870 | //========================= |
| 1871 | // No Fragmentation |
| 1872 | //========================= |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1873 | wFragType = FRAGCTL_NONFRAG; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1874 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1875 | //Set FragCtl in TxBufferHead |
| 1876 | psTxBufHd->wFragCtl |= (unsigned short)wFragType; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1877 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1878 | //Fill FIFO,RrvTime,RTS,and CTS |
| 1879 | s_vGenerateTxParameter(pDevice, byPktType, (void *)psTxBufHd, pvRrvTime, pvRTS, pvCTS, |
| 1880 | cbFrameSize, bNeedACK, uDMAIdx, psEthHeader, pDevice->wCurrentRate); |
| 1881 | //Fill DataHead |
| 1882 | uDuration = s_uFillDataHead(pDevice, byPktType, pvTxDataHd, cbFrameSize, uDMAIdx, bNeedACK, |
| 1883 | 0, 0, uMACfragNum, byFBOption, pDevice->wCurrentRate); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1884 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1885 | // Generate TX MAC Header |
Malcolm Priestley | a479ffc | 2014-08-30 22:25:38 +0100 | [diff] [blame] | 1886 | vGenerateMACHeader(pDevice, pbyMacHdr, uDuration, psEthHeader, bNeedEncrypt, |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1887 | wFragType, uDMAIdx, 0); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1888 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1889 | if (bNeedEncrypt == true) { |
| 1890 | //Fill TXKEY |
| 1891 | s_vFillTxKey(pDevice, (unsigned char *)(psTxBufHd->adwTxKey), pbyIVHead, pTransmitKey, |
| 1892 | pbyMacHdr, (unsigned short)cbFrameBodySize, (unsigned char *)pMICHDR); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1893 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1894 | if (pDevice->bEnableHostWEP) { |
| 1895 | pMgmt->sNodeDBTable[uNodeIndex].dwTSC47_16 = pTransmitKey->dwTSC47_16; |
| 1896 | pMgmt->sNodeDBTable[uNodeIndex].wTSC15_0 = pTransmitKey->wTSC15_0; |
| 1897 | } |
| 1898 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1899 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1900 | // 802.1H |
| 1901 | if (ntohs(psEthHeader->wType) > ETH_DATA_LEN) { |
| 1902 | if ((psEthHeader->wType == TYPE_PKT_IPX) || |
| 1903 | (psEthHeader->wType == cpu_to_le16(0xF380))) { |
| 1904 | memcpy((unsigned char *)(pbyPayloadHead), &pDevice->abySNAP_Bridgetunnel[0], 6); |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 1905 | } else { |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1906 | memcpy((unsigned char *)(pbyPayloadHead), &pDevice->abySNAP_RFC1042[0], 6); |
| 1907 | } |
| 1908 | pbyType = (unsigned char *)(pbyPayloadHead + 6); |
| 1909 | memcpy(pbyType, &(psEthHeader->wType), sizeof(unsigned short)); |
| 1910 | cb802_1_H_len = 8; |
| 1911 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1912 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1913 | cbReqCount = cbHeaderLength + cbMACHdLen + uPadding + cbIVlen + (cbFrameBodySize + cbMIClen); |
| 1914 | //--------------------------- |
| 1915 | // S/W or H/W Encryption |
| 1916 | //--------------------------- |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1917 | pbyBuffer = (unsigned char *)pHeadTD->pTDInfo->buf; |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1918 | uLength = cbHeaderLength + cbMACHdLen + uPadding + cbIVlen + cb802_1_H_len; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1919 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1920 | //copy TxBufferHeader + MacHeader to desc |
| 1921 | memcpy(pbyBuffer, (void *)psTxBufHd, uLength); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1922 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1923 | // Copy the Packet into a tx Buffer |
| 1924 | memcpy((pbyBuffer + uLength), |
| 1925 | (pPacket + 14), |
| 1926 | cbFrameBodySize - cb802_1_H_len |
| 1927 | ); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1928 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1929 | if ((bNeedEncrypt == true) && (pTransmitKey != NULL) && (pTransmitKey->byCipherSuite == KEY_CTL_TKIP)) { |
Joe Perches | 48caf5a | 2014-08-17 09:17:04 -0700 | [diff] [blame] | 1930 | pr_debug("Length:%d, %d\n", |
| 1931 | cbFrameBodySize - cb802_1_H_len, uLength); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1932 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1933 | MIC_vAppend((pbyBuffer + uLength - cb802_1_H_len), cbFrameBodySize); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1934 | |
Malcolm Priestley | d0daef3 | 2014-03-06 22:44:23 +0000 | [diff] [blame] | 1935 | pdwMIC_L = (u32 *)(pbyBuffer + uLength - cb802_1_H_len + cbFrameBodySize); |
| 1936 | pdwMIC_R = (u32 *)(pbyBuffer + uLength - cb802_1_H_len + cbFrameBodySize + 4); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1937 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1938 | MIC_vGetMIC(pdwMIC_L, pdwMIC_R); |
| 1939 | MIC_vUnInit(); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1940 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1941 | if (pDevice->bTxMICFail == true) { |
| 1942 | *pdwMIC_L = 0; |
| 1943 | *pdwMIC_R = 0; |
| 1944 | pDevice->bTxMICFail = false; |
| 1945 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1946 | |
Joe Perches | 48caf5a | 2014-08-17 09:17:04 -0700 | [diff] [blame] | 1947 | pr_debug("uLength: %d, %d\n", uLength, cbFrameBodySize); |
| 1948 | pr_debug("cbReqCount:%d, %d, %d, %d\n", |
| 1949 | cbReqCount, cbHeaderLength, uPadding, cbIVlen); |
| 1950 | pr_debug("MIC:%x, %x\n", *pdwMIC_L, *pdwMIC_R); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1951 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1952 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1953 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1954 | if ((pDevice->byLocalID <= REV_ID_VT3253_A1)) { |
| 1955 | if (bNeedEncrypt) { |
| 1956 | s_vSWencryption(pDevice, pTransmitKey, (pbyBuffer + uLength - cb802_1_H_len), |
| 1957 | (unsigned short)(cbFrameBodySize + cbMIClen)); |
| 1958 | cbReqCount += cbICVlen; |
| 1959 | } |
| 1960 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1961 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1962 | ptdCurr = (PSTxDesc)pHeadTD; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1963 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1964 | ptdCurr->pTDInfo->dwReqCount = cbReqCount - uPadding; |
| 1965 | ptdCurr->pTDInfo->dwHeaderLength = cbHeaderLength; |
| 1966 | ptdCurr->pTDInfo->skb_dma = ptdCurr->pTDInfo->buf_dma; |
| 1967 | ptdCurr->buff_addr = cpu_to_le32(ptdCurr->pTDInfo->skb_dma); |
| 1968 | //Set TSR1 & ReqCount in TxDescHead |
| 1969 | ptdCurr->m_td1TD1.byTCR |= (TCR_STP | TCR_EDP | EDMSDU); |
| 1970 | ptdCurr->m_td1TD1.wReqCount = cpu_to_le16((unsigned short)(cbReqCount)); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1971 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1972 | pDevice->iTDUsed[uDMAIdx]++; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1973 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1974 | } |
| 1975 | *puMACfragNum = uMACfragNum; |
Guido Martínez | 4e8a7e5 | 2014-04-19 16:44:59 -0300 | [diff] [blame] | 1976 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1977 | return cbHeaderLength; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1978 | } |
| 1979 | |
Charles Clément | 6b35b7b | 2010-05-07 12:30:19 -0700 | [diff] [blame] | 1980 | void |
Malcolm Priestley | cf76dc4 | 2014-08-10 15:46:59 +0100 | [diff] [blame] | 1981 | vGenerateFIFOHeader(struct vnt_private *pDevice, unsigned char byPktType, |
| 1982 | unsigned char *pbyTxBufferAddr, bool bNeedEncrypt, |
| 1983 | unsigned int cbPayloadSize, unsigned int uDMAIdx, |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1984 | PSTxDesc pHeadTD, PSEthernetHeader psEthHeader, unsigned char *pPacket, |
| 1985 | PSKeyItem pTransmitKey, unsigned int uNodeIndex, unsigned int *puMACfragNum, |
| 1986 | unsigned int *pcbHeaderSize) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1987 | { |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1988 | unsigned int wTxBufSize; // FFinfo size |
| 1989 | bool bNeedACK; |
| 1990 | bool bIsAdhoc; |
| 1991 | unsigned short cbMacHdLen; |
| 1992 | PSTxBufHead pTxBufHead = (PSTxBufHead) pbyTxBufferAddr; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1993 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1994 | wTxBufSize = sizeof(STxBufHead); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1995 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1996 | memset(pTxBufHead, 0, wTxBufSize); |
| 1997 | //Set FIFOCTL_NEEDACK |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1998 | |
Malcolm Priestley | a987367 | 2014-08-30 22:25:49 +0100 | [diff] [blame] | 1999 | if ((pDevice->op_mode == NL80211_IFTYPE_ADHOC) || |
| 2000 | (pDevice->op_mode == NL80211_IFTYPE_AP)) { |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2001 | if (is_multicast_ether_addr(&(psEthHeader->abyDstAddr[0]))) { |
| 2002 | bNeedACK = false; |
| 2003 | pTxBufHead->wFIFOCtl = pTxBufHead->wFIFOCtl & (~FIFOCTL_NEEDACK); |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 2004 | } else { |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2005 | bNeedACK = true; |
| 2006 | pTxBufHead->wFIFOCtl |= FIFOCTL_NEEDACK; |
| 2007 | } |
| 2008 | bIsAdhoc = true; |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 2009 | } else { |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2010 | // MSDUs in Infra mode always need ACK |
| 2011 | bNeedACK = true; |
| 2012 | pTxBufHead->wFIFOCtl |= FIFOCTL_NEEDACK; |
| 2013 | bIsAdhoc = false; |
| 2014 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2015 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2016 | pTxBufHead->wFIFOCtl |= FIFOCTL_TMOEN; |
| 2017 | pTxBufHead->wTimeStamp = cpu_to_le16(DEFAULT_MSDU_LIFETIME_RES_64us); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2018 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2019 | //Set FIFOCTL_LHEAD |
| 2020 | if (pDevice->bLongHeader) |
| 2021 | pTxBufHead->wFIFOCtl |= FIFOCTL_LHEAD; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2022 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2023 | //Set FIFOCTL_GENINT |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2024 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2025 | pTxBufHead->wFIFOCtl |= FIFOCTL_GENINT; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2026 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2027 | //Set FIFOCTL_ISDMA0 |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 2028 | if (TYPE_TXDMA0 == uDMAIdx) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2029 | pTxBufHead->wFIFOCtl |= FIFOCTL_ISDMA0; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2030 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2031 | //Set FRAGCTL_MACHDCNT |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 2032 | if (pDevice->bLongHeader) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2033 | cbMacHdLen = WLAN_HDR_ADDR3_LEN + 6; |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 2034 | else |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2035 | cbMacHdLen = WLAN_HDR_ADDR3_LEN; |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 2036 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2037 | pTxBufHead->wFragCtl |= cpu_to_le16((unsigned short)(cbMacHdLen << 10)); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2038 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2039 | //Set packet type |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 2040 | if (byPktType == PK_TYPE_11A) //0000 0000 0000 0000 |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2041 | ; |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 2042 | else if (byPktType == PK_TYPE_11B) //0000 0001 0000 0000 |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2043 | pTxBufHead->wFIFOCtl |= FIFOCTL_11B; |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 2044 | else if (byPktType == PK_TYPE_11GB) //0000 0010 0000 0000 |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2045 | pTxBufHead->wFIFOCtl |= FIFOCTL_11GB; |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 2046 | else if (byPktType == PK_TYPE_11GA) //0000 0011 0000 0000 |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2047 | pTxBufHead->wFIFOCtl |= FIFOCTL_11GA; |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 2048 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2049 | //Set FIFOCTL_GrpAckPolicy |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 2050 | if (pDevice->bGrpAckPolicy == true) //0000 0100 0000 0000 |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2051 | pTxBufHead->wFIFOCtl |= FIFOCTL_GRPACK; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2052 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2053 | //Set Auto Fallback Ctl |
| 2054 | if (pDevice->wCurrentRate >= RATE_18M) { |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 2055 | if (pDevice->byAutoFBCtrl == AUTO_FB_0) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2056 | pTxBufHead->wFIFOCtl |= FIFOCTL_AUTO_FB_0; |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 2057 | else if (pDevice->byAutoFBCtrl == AUTO_FB_1) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2058 | pTxBufHead->wFIFOCtl |= FIFOCTL_AUTO_FB_1; |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2059 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2060 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2061 | //Set FRAGCTL_WEPTYP |
| 2062 | pDevice->bAES = false; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2063 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2064 | //Set FRAGCTL_WEPTYP |
| 2065 | if (pDevice->byLocalID > REV_ID_VT3253_A1) { |
| 2066 | if ((bNeedEncrypt) && (pTransmitKey != NULL)) { //WEP enabled |
| 2067 | if (pTransmitKey->byCipherSuite == KEY_CTL_TKIP) { |
| 2068 | pTxBufHead->wFragCtl |= FRAGCTL_TKIP; |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 2069 | } else if (pTransmitKey->byCipherSuite == KEY_CTL_WEP) { //WEP40 or WEP104 |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2070 | if (pTransmitKey->uKeyLength != WLAN_WEP232_KEYLEN) |
| 2071 | pTxBufHead->wFragCtl |= FRAGCTL_LEGACY; |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 2072 | } else if (pTransmitKey->byCipherSuite == KEY_CTL_CCMP) { //CCMP |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2073 | pTxBufHead->wFragCtl |= FRAGCTL_AES; |
| 2074 | } |
| 2075 | } |
| 2076 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2077 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2078 | RFbSetPower(pDevice, pDevice->wCurrentRate, pDevice->byCurrentCh); |
Malcolm Priestley | 281a19d | 2014-08-17 20:42:27 +0100 | [diff] [blame] | 2079 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2080 | pTxBufHead->byTxPower = pDevice->byCurPwr; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2081 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2082 | *pcbHeaderSize = s_cbFillTxBufHead(pDevice, byPktType, pbyTxBufferAddr, cbPayloadSize, |
| 2083 | uDMAIdx, pHeadTD, psEthHeader, pPacket, bNeedEncrypt, |
| 2084 | pTransmitKey, uNodeIndex, puMACfragNum); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2085 | } |
| 2086 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2087 | /*+ |
| 2088 | * |
| 2089 | * Description: |
| 2090 | * Translate 802.3 to 802.11 header |
| 2091 | * |
| 2092 | * Parameters: |
| 2093 | * In: |
Gilles Espinasse | f77f13e | 2010-03-29 15:41:47 +0200 | [diff] [blame] | 2094 | * pDevice - Pointer to adapter |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2095 | * dwTxBufferAddr - Transmit Buffer |
| 2096 | * pPacket - Packet from upper layer |
| 2097 | * cbPacketSize - Transmit Data Length |
| 2098 | * Out: |
| 2099 | * pcbHeadSize - Header size of MAC&Baseband control and 802.11 Header |
| 2100 | * pcbAppendPayload - size of append payload for 802.1H translation |
| 2101 | * |
| 2102 | * Return Value: none |
| 2103 | * |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2104 | -*/ |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2105 | |
Charles Clément | 6b35b7b | 2010-05-07 12:30:19 -0700 | [diff] [blame] | 2106 | void |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2107 | vGenerateMACHeader( |
Malcolm Priestley | cf76dc4 | 2014-08-10 15:46:59 +0100 | [diff] [blame] | 2108 | struct vnt_private *pDevice, |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2109 | unsigned char *pbyBufferAddr, |
Malcolm Priestley | a479ffc | 2014-08-30 22:25:38 +0100 | [diff] [blame] | 2110 | __le16 wDuration, |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2111 | PSEthernetHeader psEthHeader, |
| 2112 | bool bNeedEncrypt, |
| 2113 | unsigned short wFragType, |
| 2114 | unsigned int uDMAIdx, |
| 2115 | unsigned int uFragIdx |
| 2116 | ) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2117 | { |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2118 | PS802_11Header pMACHeader = (PS802_11Header)pbyBufferAddr; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2119 | |
Guido Martínez | 4e8a7e5 | 2014-04-19 16:44:59 -0300 | [diff] [blame] | 2120 | memset(pMACHeader, 0, (sizeof(S802_11Header))); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2121 | |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 2122 | if (uDMAIdx == TYPE_ATIMDMA) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2123 | pMACHeader->wFrameCtl = TYPE_802_11_ATIM; |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 2124 | else |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2125 | pMACHeader->wFrameCtl = TYPE_802_11_DATA; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2126 | |
Malcolm Priestley | a987367 | 2014-08-30 22:25:49 +0100 | [diff] [blame] | 2127 | if (pDevice->op_mode == NL80211_IFTYPE_AP) { |
Aya Mahfouz | 2359b5c | 2014-10-11 02:42:45 +0200 | [diff] [blame^] | 2128 | ether_addr_copy(&(pMACHeader->abyAddr1[0]), |
| 2129 | &(psEthHeader->abyDstAddr[0])); |
| 2130 | ether_addr_copy(&(pMACHeader->abyAddr2[0]), |
| 2131 | &(pDevice->abyBSSID[0])); |
| 2132 | ether_addr_copy(&(pMACHeader->abyAddr3[0]), |
| 2133 | &(psEthHeader->abySrcAddr[0])); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2134 | pMACHeader->wFrameCtl |= FC_FROMDS; |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 2135 | } else { |
Malcolm Priestley | a987367 | 2014-08-30 22:25:49 +0100 | [diff] [blame] | 2136 | if (pDevice->op_mode == NL80211_IFTYPE_ADHOC) { |
Aya Mahfouz | 2359b5c | 2014-10-11 02:42:45 +0200 | [diff] [blame^] | 2137 | ether_addr_copy(&(pMACHeader->abyAddr1[0]), |
| 2138 | &(psEthHeader->abyDstAddr[0])); |
| 2139 | ether_addr_copy(&(pMACHeader->abyAddr2[0]), |
| 2140 | &(psEthHeader->abySrcAddr[0])); |
| 2141 | ether_addr_copy(&(pMACHeader->abyAddr3[0]), |
| 2142 | &(pDevice->abyBSSID[0])); |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 2143 | } else { |
Aya Mahfouz | 2359b5c | 2014-10-11 02:42:45 +0200 | [diff] [blame^] | 2144 | ether_addr_copy(&(pMACHeader->abyAddr3[0]), |
| 2145 | &(psEthHeader->abyDstAddr[0])); |
| 2146 | ether_addr_copy(&(pMACHeader->abyAddr2[0]), |
| 2147 | &(psEthHeader->abySrcAddr[0])); |
| 2148 | ether_addr_copy(&(pMACHeader->abyAddr1[0]), |
| 2149 | &(pDevice->abyBSSID[0])); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2150 | pMACHeader->wFrameCtl |= FC_TODS; |
| 2151 | } |
| 2152 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2153 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2154 | if (bNeedEncrypt) |
| 2155 | pMACHeader->wFrameCtl |= cpu_to_le16((unsigned short)WLAN_SET_FC_ISWEP(1)); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2156 | |
Malcolm Priestley | a479ffc | 2014-08-30 22:25:38 +0100 | [diff] [blame] | 2157 | pMACHeader->wDurationID = le16_to_cpu(wDuration); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2158 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2159 | if (pDevice->bLongHeader) { |
| 2160 | PWLAN_80211HDR_A4 pMACA4Header = (PWLAN_80211HDR_A4) pbyBufferAddr; |
Guillaume Clement | 6b71127 | 2014-07-25 01:06:16 +0200 | [diff] [blame] | 2161 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2162 | pMACHeader->wFrameCtl |= (FC_TODS | FC_FROMDS); |
| 2163 | memcpy(pMACA4Header->abyAddr4, pDevice->abyBSSID, WLAN_ADDR_LEN); |
| 2164 | } |
| 2165 | pMACHeader->wSeqCtl = cpu_to_le16(pDevice->wSeqCounter << 4); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2166 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2167 | //Set FragNumber in Sequence Control |
| 2168 | pMACHeader->wSeqCtl |= cpu_to_le16((unsigned short)uFragIdx); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2169 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2170 | if ((wFragType == FRAGCTL_ENDFRAG) || (wFragType == FRAGCTL_NONFRAG)) { |
| 2171 | pDevice->wSeqCounter++; |
| 2172 | if (pDevice->wSeqCounter > 0x0fff) |
| 2173 | pDevice->wSeqCounter = 0; |
| 2174 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2175 | |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 2176 | if ((wFragType == FRAGCTL_STAFRAG) || (wFragType == FRAGCTL_MIDFRAG)) //StartFrag or MidFrag |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2177 | pMACHeader->wFrameCtl |= FC_MOREFRAG; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2178 | } |
| 2179 | |
Malcolm Priestley | cf76dc4 | 2014-08-10 15:46:59 +0100 | [diff] [blame] | 2180 | CMD_STATUS csMgmt_xmit(struct vnt_private *pDevice, PSTxMgmtPacket pPacket) |
Guillaume Clement | 84b5076 | 2014-07-25 01:06:18 +0200 | [diff] [blame] | 2181 | { |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2182 | PSTxDesc pFrstTD; |
| 2183 | unsigned char byPktType; |
| 2184 | unsigned char *pbyTxBufferAddr; |
| 2185 | void *pvRTS; |
Malcolm Priestley | f5172b0 | 2014-08-30 22:25:45 +0100 | [diff] [blame] | 2186 | struct vnt_cts *pCTS; |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2187 | void *pvTxDataHd; |
| 2188 | unsigned int uDuration; |
| 2189 | unsigned int cbReqCount; |
| 2190 | PS802_11Header pMACHeader; |
| 2191 | unsigned int cbHeaderSize; |
| 2192 | unsigned int cbFrameBodySize; |
| 2193 | bool bNeedACK; |
| 2194 | bool bIsPSPOLL = false; |
| 2195 | PSTxBufHead pTxBufHead; |
| 2196 | unsigned int cbFrameSize; |
| 2197 | unsigned int cbIVlen = 0; |
| 2198 | unsigned int cbICVlen = 0; |
| 2199 | unsigned int cbMIClen = 0; |
| 2200 | unsigned int cbFCSlen = 4; |
| 2201 | unsigned int uPadding = 0; |
| 2202 | unsigned short wTxBufSize; |
| 2203 | unsigned int cbMacHdLen; |
| 2204 | SEthernetHeader sEthHeader; |
| 2205 | void *pvRrvTime; |
| 2206 | void *pMICHDR; |
| 2207 | PSMgmtObject pMgmt = pDevice->pMgmt; |
| 2208 | unsigned short wCurrentRate = RATE_1M; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2209 | |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 2210 | if (AVAIL_TD(pDevice, TYPE_TXDMA0) <= 0) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2211 | return CMD_STATUS_RESOURCES; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2212 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2213 | pFrstTD = pDevice->apCurrTD[TYPE_TXDMA0]; |
| 2214 | pbyTxBufferAddr = (unsigned char *)pFrstTD->pTDInfo->buf; |
| 2215 | cbFrameBodySize = pPacket->cbPayloadLen; |
| 2216 | pTxBufHead = (PSTxBufHead) pbyTxBufferAddr; |
| 2217 | wTxBufSize = sizeof(STxBufHead); |
| 2218 | memset(pTxBufHead, 0, wTxBufSize); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2219 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2220 | if (pDevice->eCurrentPHYType == PHY_TYPE_11A) { |
| 2221 | wCurrentRate = RATE_6M; |
| 2222 | byPktType = PK_TYPE_11A; |
| 2223 | } else { |
| 2224 | wCurrentRate = RATE_1M; |
| 2225 | byPktType = PK_TYPE_11B; |
| 2226 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2227 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2228 | // SetPower will cause error power TX state for OFDM Date packet in TX buffer. |
| 2229 | // 2004.11.11 Kyle -- Using OFDM power to tx MngPkt will decrease the connection capability. |
| 2230 | // And cmd timer will wait data pkt TX finish before scanning so it's OK |
| 2231 | // to set power here. |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 2232 | if (pDevice->pMgmt->eScanState != WMAC_NO_SCANNING) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2233 | RFbSetPower(pDevice, wCurrentRate, pDevice->byCurrentCh); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 2234 | else |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2235 | RFbSetPower(pDevice, wCurrentRate, pMgmt->uCurrChannel); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 2236 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2237 | pTxBufHead->byTxPower = pDevice->byCurPwr; |
| 2238 | //+++++++++++++++++++++ Patch VT3253 A1 performance +++++++++++++++++++++++++++ |
| 2239 | if (pDevice->byFOETuning) { |
| 2240 | if ((pPacket->p80211Header->sA3.wFrameCtl & TYPE_DATE_NULL) == TYPE_DATE_NULL) { |
| 2241 | wCurrentRate = RATE_24M; |
| 2242 | byPktType = PK_TYPE_11GA; |
| 2243 | } |
| 2244 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2245 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2246 | //Set packet type |
| 2247 | if (byPktType == PK_TYPE_11A) {//0000 0000 0000 0000 |
| 2248 | pTxBufHead->wFIFOCtl = 0; |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 2249 | } else if (byPktType == PK_TYPE_11B) {//0000 0001 0000 0000 |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2250 | pTxBufHead->wFIFOCtl |= FIFOCTL_11B; |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 2251 | } else if (byPktType == PK_TYPE_11GB) {//0000 0010 0000 0000 |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2252 | pTxBufHead->wFIFOCtl |= FIFOCTL_11GB; |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 2253 | } else if (byPktType == PK_TYPE_11GA) {//0000 0011 0000 0000 |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2254 | pTxBufHead->wFIFOCtl |= FIFOCTL_11GA; |
| 2255 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2256 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2257 | pTxBufHead->wFIFOCtl |= FIFOCTL_TMOEN; |
| 2258 | pTxBufHead->wTimeStamp = cpu_to_le16(DEFAULT_MGN_LIFETIME_RES_64us); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2259 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2260 | if (is_multicast_ether_addr(&(pPacket->p80211Header->sA3.abyAddr1[0]))) |
| 2261 | bNeedACK = false; |
| 2262 | else { |
| 2263 | bNeedACK = true; |
| 2264 | pTxBufHead->wFIFOCtl |= FIFOCTL_NEEDACK; |
Teodora Baluta | 88cc850 | 2013-11-10 17:12:45 +0200 | [diff] [blame] | 2265 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2266 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2267 | if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) || |
| 2268 | (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA)) { |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2269 | pTxBufHead->wFIFOCtl |= FIFOCTL_LRETRY; |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2270 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2271 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2272 | pTxBufHead->wFIFOCtl |= (FIFOCTL_GENINT | FIFOCTL_ISDMA0); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2273 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2274 | if ((pPacket->p80211Header->sA4.wFrameCtl & TYPE_SUBTYPE_MASK) == TYPE_CTL_PSPOLL) { |
| 2275 | bIsPSPOLL = true; |
| 2276 | cbMacHdLen = WLAN_HDR_ADDR2_LEN; |
| 2277 | } else { |
| 2278 | cbMacHdLen = WLAN_HDR_ADDR3_LEN; |
| 2279 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2280 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2281 | //Set FRAGCTL_MACHDCNT |
| 2282 | pTxBufHead->wFragCtl |= cpu_to_le16((unsigned short)(cbMacHdLen << 10)); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2283 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2284 | // Notes: |
| 2285 | // Although spec says MMPDU can be fragmented; In most cases, |
| 2286 | // no one will send a MMPDU under fragmentation. With RTS may occur. |
| 2287 | pDevice->bAES = false; //Set FRAGCTL_WEPTYP |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2288 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2289 | if (WLAN_GET_FC_ISWEP(pPacket->p80211Header->sA4.wFrameCtl) != 0) { |
| 2290 | if (pDevice->eEncryptionStatus == Ndis802_11Encryption1Enabled) { |
| 2291 | cbIVlen = 4; |
| 2292 | cbICVlen = 4; |
| 2293 | pTxBufHead->wFragCtl |= FRAGCTL_LEGACY; |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 2294 | } else if (pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled) { |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2295 | cbIVlen = 8;//IV+ExtIV |
| 2296 | cbMIClen = 8; |
| 2297 | cbICVlen = 4; |
| 2298 | pTxBufHead->wFragCtl |= FRAGCTL_TKIP; |
| 2299 | //We need to get seed here for filling TxKey entry. |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 2300 | } else if (pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled) { |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2301 | cbIVlen = 8;//RSN Header |
| 2302 | cbICVlen = 8;//MIC |
| 2303 | pTxBufHead->wFragCtl |= FRAGCTL_AES; |
| 2304 | pDevice->bAES = true; |
| 2305 | } |
| 2306 | //MAC Header should be padding 0 to DW alignment. |
| 2307 | uPadding = 4 - (cbMacHdLen%4); |
| 2308 | uPadding %= 4; |
| 2309 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2310 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2311 | cbFrameSize = cbMacHdLen + cbFrameBodySize + cbIVlen + cbMIClen + cbICVlen + cbFCSlen; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2312 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2313 | //Set FIFOCTL_GrpAckPolicy |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 2314 | if (pDevice->bGrpAckPolicy == true) //0000 0100 0000 0000 |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2315 | pTxBufHead->wFIFOCtl |= FIFOCTL_GRPACK; |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 2316 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2317 | //the rest of pTxBufHead->wFragCtl:FragTyp will be set later in s_vFillFragParameter() |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2318 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2319 | //Set RrvTime/RTS/CTS Buffer |
| 2320 | if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) {//802.11g packet |
Malcolm Priestley | d66a5a7 | 2014-08-30 22:25:28 +0100 | [diff] [blame] | 2321 | pvRrvTime = (void *) (pbyTxBufferAddr + wTxBufSize); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2322 | pMICHDR = NULL; |
| 2323 | pvRTS = NULL; |
Malcolm Priestley | f5172b0 | 2014-08-30 22:25:45 +0100 | [diff] [blame] | 2324 | pCTS = (struct vnt_cts *)(pbyTxBufferAddr + wTxBufSize + |
Malcolm Priestley | d66a5a7 | 2014-08-30 22:25:28 +0100 | [diff] [blame] | 2325 | sizeof(struct vnt_rrv_time_cts)); |
Malcolm Priestley | 72edb7e | 2014-08-30 22:25:34 +0100 | [diff] [blame] | 2326 | pvTxDataHd = (void *)(pbyTxBufferAddr + wTxBufSize + |
Malcolm Priestley | f5172b0 | 2014-08-30 22:25:45 +0100 | [diff] [blame] | 2327 | sizeof(struct vnt_rrv_time_cts) + sizeof(struct vnt_cts)); |
Malcolm Priestley | d66a5a7 | 2014-08-30 22:25:28 +0100 | [diff] [blame] | 2328 | cbHeaderSize = wTxBufSize + sizeof(struct vnt_rrv_time_cts) + |
Malcolm Priestley | f5172b0 | 2014-08-30 22:25:45 +0100 | [diff] [blame] | 2329 | sizeof(struct vnt_cts) + sizeof(struct vnt_tx_datahead_g); |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 2330 | } else { // 802.11a/b packet |
Malcolm Priestley | f6a634c | 2014-08-30 22:25:29 +0100 | [diff] [blame] | 2331 | pvRrvTime = (void *)(pbyTxBufferAddr + wTxBufSize); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2332 | pMICHDR = NULL; |
| 2333 | pvRTS = NULL; |
| 2334 | pCTS = NULL; |
Malcolm Priestley | 9ce842a | 2014-08-30 22:25:36 +0100 | [diff] [blame] | 2335 | pvTxDataHd = (void *)(pbyTxBufferAddr + wTxBufSize + |
| 2336 | sizeof(struct vnt_rrv_time_ab)); |
| 2337 | cbHeaderSize = wTxBufSize + sizeof(struct vnt_rrv_time_ab) + |
| 2338 | sizeof(struct vnt_tx_datahead_ab); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2339 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2340 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2341 | memset((void *)(pbyTxBufferAddr + wTxBufSize), 0, (cbHeaderSize - wTxBufSize)); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2342 | |
Aya Mahfouz | 2359b5c | 2014-10-11 02:42:45 +0200 | [diff] [blame^] | 2343 | ether_addr_copy(&(sEthHeader.abyDstAddr[0]), |
| 2344 | &(pPacket->p80211Header->sA3.abyAddr1[0])); |
| 2345 | ether_addr_copy(&(sEthHeader.abySrcAddr[0]), |
| 2346 | &(pPacket->p80211Header->sA3.abyAddr2[0])); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2347 | //========================= |
| 2348 | // No Fragmentation |
| 2349 | //========================= |
| 2350 | pTxBufHead->wFragCtl |= (unsigned short)FRAGCTL_NONFRAG; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2351 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2352 | //Fill FIFO,RrvTime,RTS,and CTS |
| 2353 | s_vGenerateTxParameter(pDevice, byPktType, pbyTxBufferAddr, pvRrvTime, pvRTS, pCTS, |
| 2354 | cbFrameSize, bNeedACK, TYPE_TXDMA0, &sEthHeader, wCurrentRate); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2355 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2356 | //Fill DataHead |
| 2357 | uDuration = s_uFillDataHead(pDevice, byPktType, pvTxDataHd, cbFrameSize, TYPE_TXDMA0, bNeedACK, |
| 2358 | 0, 0, 1, AUTO_FB_NONE, wCurrentRate); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2359 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2360 | pMACHeader = (PS802_11Header) (pbyTxBufferAddr + cbHeaderSize); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2361 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2362 | cbReqCount = cbHeaderSize + cbMacHdLen + uPadding + cbIVlen + cbFrameBodySize; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2363 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2364 | if (WLAN_GET_FC_ISWEP(pPacket->p80211Header->sA4.wFrameCtl) != 0) { |
| 2365 | unsigned char *pbyIVHead; |
| 2366 | unsigned char *pbyPayloadHead; |
| 2367 | unsigned char *pbyBSSID; |
| 2368 | PSKeyItem pTransmitKey = NULL; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2369 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2370 | pbyIVHead = (unsigned char *)(pbyTxBufferAddr + cbHeaderSize + cbMacHdLen + uPadding); |
| 2371 | pbyPayloadHead = (unsigned char *)(pbyTxBufferAddr + cbHeaderSize + cbMacHdLen + uPadding + cbIVlen); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2372 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2373 | //Fill TXKEY |
| 2374 | //Kyle: Need fix: TKIP and AES did't encrypt Mnt Packet. |
| 2375 | //s_vFillTxKey(pDevice, (unsigned char *)pTxBufHead->adwTxKey, NULL); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2376 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2377 | //Fill IV(ExtIV,RSNHDR) |
| 2378 | //s_vFillPrePayload(pDevice, pbyIVHead, NULL); |
| 2379 | //--------------------------- |
| 2380 | // S/W or H/W Encryption |
| 2381 | //--------------------------- |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2382 | do { |
Malcolm Priestley | a987367 | 2014-08-30 22:25:49 +0100 | [diff] [blame] | 2383 | if ((pDevice->op_mode == NL80211_IFTYPE_STATION) && |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2384 | (pDevice->bLinkPass == true)) { |
| 2385 | pbyBSSID = pDevice->abyBSSID; |
| 2386 | // get pairwise key |
| 2387 | if (KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, PAIRWISE_KEY, &pTransmitKey) == false) { |
| 2388 | // get group key |
| 2389 | if (KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, GROUP_KEY, &pTransmitKey) == true) { |
Joe Perches | 48caf5a | 2014-08-17 09:17:04 -0700 | [diff] [blame] | 2390 | pr_debug("Get GTK\n"); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2391 | break; |
| 2392 | } |
| 2393 | } else { |
Joe Perches | 48caf5a | 2014-08-17 09:17:04 -0700 | [diff] [blame] | 2394 | pr_debug("Get PTK\n"); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2395 | break; |
| 2396 | } |
| 2397 | } |
| 2398 | // get group key |
| 2399 | pbyBSSID = pDevice->abyBroadcastAddr; |
| 2400 | if (KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, GROUP_KEY, &pTransmitKey) == false) { |
| 2401 | pTransmitKey = NULL; |
Joe Perches | 48caf5a | 2014-08-17 09:17:04 -0700 | [diff] [blame] | 2402 | pr_debug("KEY is NULL. OP Mode[%d]\n", |
Malcolm Priestley | a987367 | 2014-08-30 22:25:49 +0100 | [diff] [blame] | 2403 | pDevice->op_mode); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2404 | } else { |
Joe Perches | 48caf5a | 2014-08-17 09:17:04 -0700 | [diff] [blame] | 2405 | pr_debug("Get GTK\n"); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2406 | } |
| 2407 | } while (false); |
| 2408 | //Fill TXKEY |
| 2409 | s_vFillTxKey(pDevice, (unsigned char *)(pTxBufHead->adwTxKey), pbyIVHead, pTransmitKey, |
| 2410 | (unsigned char *)pMACHeader, (unsigned short)cbFrameBodySize, NULL); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2411 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2412 | memcpy(pMACHeader, pPacket->p80211Header, cbMacHdLen); |
| 2413 | memcpy(pbyPayloadHead, ((unsigned char *)(pPacket->p80211Header) + cbMacHdLen), |
| 2414 | cbFrameBodySize); |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 2415 | } else { |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2416 | // Copy the Packet into a tx Buffer |
| 2417 | memcpy(pMACHeader, pPacket->p80211Header, pPacket->cbMPDULen); |
| 2418 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2419 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2420 | pMACHeader->wSeqCtl = cpu_to_le16(pDevice->wSeqCounter << 4); |
| 2421 | pDevice->wSeqCounter++; |
| 2422 | if (pDevice->wSeqCounter > 0x0fff) |
| 2423 | pDevice->wSeqCounter = 0; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2424 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2425 | if (bIsPSPOLL) { |
| 2426 | // The MAC will automatically replace the Duration-field of MAC header by Duration-field |
| 2427 | // of FIFO control header. |
| 2428 | // This will cause AID-field of PS-POLL packet to be incorrect (Because PS-POLL's AID field is |
| 2429 | // in the same place of other packet's Duration-field). |
| 2430 | // And it will cause Cisco-AP to issue Disassociation-packet |
| 2431 | if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) { |
Malcolm Priestley | 72edb7e | 2014-08-30 22:25:34 +0100 | [diff] [blame] | 2432 | ((struct vnt_tx_datahead_g *)pvTxDataHd)->duration_a = cpu_to_le16(pPacket->p80211Header->sA2.wDurationID); |
| 2433 | ((struct vnt_tx_datahead_g *)pvTxDataHd)->duration_b = cpu_to_le16(pPacket->p80211Header->sA2.wDurationID); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2434 | } else { |
Malcolm Priestley | 9ce842a | 2014-08-30 22:25:36 +0100 | [diff] [blame] | 2435 | ((struct vnt_tx_datahead_ab *)pvTxDataHd)->duration = cpu_to_le16(pPacket->p80211Header->sA2.wDurationID); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2436 | } |
| 2437 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2438 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2439 | // first TD is the only TD |
| 2440 | //Set TSR1 & ReqCount in TxDescHead |
| 2441 | pFrstTD->m_td1TD1.byTCR = (TCR_STP | TCR_EDP | EDMSDU); |
| 2442 | pFrstTD->pTDInfo->skb_dma = pFrstTD->pTDInfo->buf_dma; |
| 2443 | pFrstTD->m_td1TD1.wReqCount = cpu_to_le16((unsigned short)(cbReqCount)); |
| 2444 | pFrstTD->buff_addr = cpu_to_le32(pFrstTD->pTDInfo->skb_dma); |
| 2445 | pFrstTD->pTDInfo->byFlags = 0; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2446 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2447 | if (MACbIsRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_PS)) { |
| 2448 | // Disable PS |
| 2449 | MACbPSWakeup(pDevice->PortOffset); |
| 2450 | } |
| 2451 | pDevice->bPWBitOn = false; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2452 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2453 | wmb(); |
| 2454 | pFrstTD->m_td0TD0.f1Owner = OWNED_BY_NIC; |
| 2455 | wmb(); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2456 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2457 | pDevice->iTDUsed[TYPE_TXDMA0]++; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2458 | |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 2459 | if (AVAIL_TD(pDevice, TYPE_TXDMA0) <= 1) |
Joe Perches | 48caf5a | 2014-08-17 09:17:04 -0700 | [diff] [blame] | 2460 | pr_debug(" available td0 <= 1\n"); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2461 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2462 | pDevice->apCurrTD[TYPE_TXDMA0] = pFrstTD->next; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2463 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2464 | pDevice->nTxDataTimeCout = 0; //2008-8-21 chester <add> for send null packet |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2465 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2466 | // Poll Transmit the adapter |
| 2467 | MACvTransmit0(pDevice->PortOffset); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2468 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2469 | return CMD_STATUS_PENDING; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2470 | } |
| 2471 | |
Malcolm Priestley | cf76dc4 | 2014-08-10 15:46:59 +0100 | [diff] [blame] | 2472 | CMD_STATUS csBeacon_xmit(struct vnt_private *pDevice, PSTxMgmtPacket pPacket) |
Guillaume Clement | 84b5076 | 2014-07-25 01:06:18 +0200 | [diff] [blame] | 2473 | { |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2474 | unsigned char byPktType; |
| 2475 | unsigned char *pbyBuffer = (unsigned char *)pDevice->tx_beacon_bufs; |
| 2476 | unsigned int cbFrameSize = pPacket->cbMPDULen + WLAN_FCS_LEN; |
| 2477 | unsigned int cbHeaderSize = 0; |
Malcolm Priestley | 9641723 | 2014-08-22 22:35:11 +0100 | [diff] [blame] | 2478 | struct vnt_tx_short_buf_head *short_head = |
| 2479 | (struct vnt_tx_short_buf_head *)pbyBuffer; |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2480 | PS802_11Header pMACHeader; |
| 2481 | unsigned short wCurrentRate; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2482 | |
Malcolm Priestley | 9641723 | 2014-08-22 22:35:11 +0100 | [diff] [blame] | 2483 | memset(short_head, 0, sizeof(*short_head)); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2484 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2485 | if (pDevice->eCurrentPHYType == PHY_TYPE_11A) { |
| 2486 | wCurrentRate = RATE_6M; |
| 2487 | byPktType = PK_TYPE_11A; |
| 2488 | } else { |
| 2489 | wCurrentRate = RATE_2M; |
| 2490 | byPktType = PK_TYPE_11B; |
| 2491 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2492 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2493 | //Set Preamble type always long |
| 2494 | pDevice->byPreambleType = PREAMBLE_LONG; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2495 | |
Malcolm Priestley | 9641723 | 2014-08-22 22:35:11 +0100 | [diff] [blame] | 2496 | /* Set FIFOCTL_GENINT */ |
| 2497 | short_head->fifo_ctl |= cpu_to_le16(FIFOCTL_GENINT); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2498 | |
Malcolm Priestley | 9641723 | 2014-08-22 22:35:11 +0100 | [diff] [blame] | 2499 | /* Set packet type & Get Duration */ |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2500 | if (byPktType == PK_TYPE_11A) {//0000 0000 0000 0000 |
Malcolm Priestley | 9641723 | 2014-08-22 22:35:11 +0100 | [diff] [blame] | 2501 | short_head->duration = |
| 2502 | cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_A, |
| 2503 | cbFrameSize, byPktType, wCurrentRate, false, |
| 2504 | 0, 0, 1, AUTO_FB_NONE)); |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 2505 | } else if (byPktType == PK_TYPE_11B) {//0000 0001 0000 0000 |
Malcolm Priestley | 9641723 | 2014-08-22 22:35:11 +0100 | [diff] [blame] | 2506 | short_head->fifo_ctl |= cpu_to_le16(FIFOCTL_11B); |
| 2507 | |
| 2508 | short_head->duration = |
| 2509 | cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_B, |
| 2510 | cbFrameSize, byPktType, wCurrentRate, false, |
| 2511 | 0, 0, 1, AUTO_FB_NONE)); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2512 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2513 | |
Malcolm Priestley | 429a247 | 2014-08-20 22:30:29 +0100 | [diff] [blame] | 2514 | vnt_get_phy_field(pDevice, cbFrameSize, |
Malcolm Priestley | 9641723 | 2014-08-22 22:35:11 +0100 | [diff] [blame] | 2515 | wCurrentRate, byPktType, &short_head->ab); |
Malcolm Priestley | 429a247 | 2014-08-20 22:30:29 +0100 | [diff] [blame] | 2516 | |
Malcolm Priestley | 9641723 | 2014-08-22 22:35:11 +0100 | [diff] [blame] | 2517 | /* Get TimeStampOff */ |
Malcolm Priestley | d6b95c0 | 2014-08-30 22:25:33 +0100 | [diff] [blame] | 2518 | short_head->time_stamp_off = vnt_time_stamp_off(pDevice, wCurrentRate); |
Malcolm Priestley | 9641723 | 2014-08-22 22:35:11 +0100 | [diff] [blame] | 2519 | cbHeaderSize = sizeof(struct vnt_tx_short_buf_head); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2520 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2521 | //Generate Beacon Header |
| 2522 | pMACHeader = (PS802_11Header)(pbyBuffer + cbHeaderSize); |
| 2523 | memcpy(pMACHeader, pPacket->p80211Header, pPacket->cbMPDULen); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2524 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2525 | pMACHeader->wDurationID = 0; |
| 2526 | pMACHeader->wSeqCtl = cpu_to_le16(pDevice->wSeqCounter << 4); |
| 2527 | pDevice->wSeqCounter++; |
| 2528 | if (pDevice->wSeqCounter > 0x0fff) |
| 2529 | pDevice->wSeqCounter = 0; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2530 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2531 | // Set Beacon buffer length |
| 2532 | pDevice->wBCNBufLen = pPacket->cbMPDULen + cbHeaderSize; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2533 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2534 | MACvSetCurrBCNTxDescAddr(pDevice->PortOffset, (pDevice->tx_beacon_dma)); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2535 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2536 | MACvSetCurrBCNLength(pDevice->PortOffset, pDevice->wBCNBufLen); |
| 2537 | // Set auto Transmit on |
| 2538 | MACvRegBitsOn(pDevice->PortOffset, MAC_REG_TCR, TCR_AUTOBCNTX); |
| 2539 | // Poll Transmit the adapter |
| 2540 | MACvTransmitBCN(pDevice->PortOffset); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2541 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2542 | return CMD_STATUS_PENDING; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2543 | } |
| 2544 | |
Charles Clément | b6e95cd | 2010-06-02 09:52:01 -0700 | [diff] [blame] | 2545 | unsigned int |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2546 | cbGetFragCount( |
Malcolm Priestley | cf76dc4 | 2014-08-10 15:46:59 +0100 | [diff] [blame] | 2547 | struct vnt_private *pDevice, |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2548 | PSKeyItem pTransmitKey, |
| 2549 | unsigned int cbFrameBodySize, |
| 2550 | PSEthernetHeader psEthHeader |
| 2551 | ) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2552 | { |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2553 | unsigned int cbMACHdLen; |
| 2554 | unsigned int cbFrameSize; |
| 2555 | unsigned int cbFragmentSize; //Hdr+(IV)+payoad+(MIC)+(ICV)+FCS |
| 2556 | unsigned int cbFragPayloadSize; |
| 2557 | unsigned int cbLastFragPayloadSize; |
| 2558 | unsigned int cbIVlen = 0; |
| 2559 | unsigned int cbICVlen = 0; |
| 2560 | unsigned int cbMIClen = 0; |
| 2561 | unsigned int cbFCSlen = 4; |
| 2562 | unsigned int uMACfragNum = 1; |
| 2563 | bool bNeedACK; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2564 | |
Malcolm Priestley | a987367 | 2014-08-30 22:25:49 +0100 | [diff] [blame] | 2565 | if ((pDevice->op_mode == NL80211_IFTYPE_ADHOC) || |
| 2566 | (pDevice->op_mode == NL80211_IFTYPE_AP)) { |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2567 | if (is_multicast_ether_addr(&(psEthHeader->abyDstAddr[0]))) |
| 2568 | bNeedACK = false; |
| 2569 | else |
| 2570 | bNeedACK = true; |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 2571 | } else { |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2572 | // MSDUs in Infra mode always need ACK |
| 2573 | bNeedACK = true; |
| 2574 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2575 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2576 | if (pDevice->bLongHeader) |
| 2577 | cbMACHdLen = WLAN_HDR_ADDR3_LEN + 6; |
| 2578 | else |
| 2579 | cbMACHdLen = WLAN_HDR_ADDR3_LEN; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2580 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2581 | if (pDevice->bEncryptionEnable == true) { |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2582 | if (pTransmitKey == NULL) { |
| 2583 | if ((pDevice->eEncryptionStatus == Ndis802_11Encryption1Enabled) || |
| 2584 | (pDevice->pMgmt->eAuthenMode < WMAC_AUTH_WPA)) { |
| 2585 | cbIVlen = 4; |
| 2586 | cbICVlen = 4; |
| 2587 | } else if (pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled) { |
| 2588 | cbIVlen = 8;//IV+ExtIV |
| 2589 | cbMIClen = 8; |
| 2590 | cbICVlen = 4; |
| 2591 | } else if (pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled) { |
| 2592 | cbIVlen = 8;//RSN Header |
| 2593 | cbICVlen = 8;//MIC |
| 2594 | } |
| 2595 | } else if (pTransmitKey->byCipherSuite == KEY_CTL_WEP) { |
| 2596 | cbIVlen = 4; |
| 2597 | cbICVlen = 4; |
| 2598 | } else if (pTransmitKey->byCipherSuite == KEY_CTL_TKIP) { |
| 2599 | cbIVlen = 8;//IV+ExtIV |
| 2600 | cbMIClen = 8; |
| 2601 | cbICVlen = 4; |
| 2602 | } else if (pTransmitKey->byCipherSuite == KEY_CTL_CCMP) { |
| 2603 | cbIVlen = 8;//RSN Header |
| 2604 | cbICVlen = 8;//MIC |
| 2605 | } |
| 2606 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2607 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2608 | cbFrameSize = cbMACHdLen + cbIVlen + (cbFrameBodySize + cbMIClen) + cbICVlen + cbFCSlen; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2609 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2610 | if ((cbFrameSize > pDevice->wFragmentationThreshold) && (bNeedACK == true)) { |
| 2611 | // Fragmentation |
| 2612 | cbFragmentSize = pDevice->wFragmentationThreshold; |
| 2613 | cbFragPayloadSize = cbFragmentSize - cbMACHdLen - cbIVlen - cbICVlen - cbFCSlen; |
| 2614 | uMACfragNum = (unsigned short) ((cbFrameBodySize + cbMIClen) / cbFragPayloadSize); |
| 2615 | cbLastFragPayloadSize = (cbFrameBodySize + cbMIClen) % cbFragPayloadSize; |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 2616 | if (cbLastFragPayloadSize == 0) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2617 | cbLastFragPayloadSize = cbFragPayloadSize; |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 2618 | else |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2619 | uMACfragNum++; |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2620 | } |
| 2621 | return uMACfragNum; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2622 | } |
| 2623 | |
Malcolm Priestley | cf76dc4 | 2014-08-10 15:46:59 +0100 | [diff] [blame] | 2624 | void vDMA0_tx_80211(struct vnt_private *pDevice, struct sk_buff *skb, |
| 2625 | unsigned char *pbMPDU, unsigned int cbMPDULen) |
| 2626 | { |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2627 | PSTxDesc pFrstTD; |
| 2628 | unsigned char byPktType; |
| 2629 | unsigned char *pbyTxBufferAddr; |
| 2630 | void *pvRTS; |
| 2631 | void *pvCTS; |
| 2632 | void *pvTxDataHd; |
| 2633 | unsigned int uDuration; |
| 2634 | unsigned int cbReqCount; |
| 2635 | PS802_11Header pMACHeader; |
| 2636 | unsigned int cbHeaderSize; |
| 2637 | unsigned int cbFrameBodySize; |
| 2638 | bool bNeedACK; |
| 2639 | bool bIsPSPOLL = false; |
| 2640 | PSTxBufHead pTxBufHead; |
| 2641 | unsigned int cbFrameSize; |
| 2642 | unsigned int cbIVlen = 0; |
| 2643 | unsigned int cbICVlen = 0; |
| 2644 | unsigned int cbMIClen = 0; |
| 2645 | unsigned int cbFCSlen = 4; |
| 2646 | unsigned int uPadding = 0; |
| 2647 | unsigned int cbMICHDR = 0; |
| 2648 | unsigned int uLength = 0; |
Malcolm Priestley | 12ca22b | 2014-03-06 22:44:25 +0000 | [diff] [blame] | 2649 | u32 dwMICKey0, dwMICKey1; |
| 2650 | u32 dwMIC_Priority; |
Malcolm Priestley | d0daef3 | 2014-03-06 22:44:23 +0000 | [diff] [blame] | 2651 | u32 *pdwMIC_L; |
| 2652 | u32 *pdwMIC_R; |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2653 | unsigned short wTxBufSize; |
| 2654 | unsigned int cbMacHdLen; |
| 2655 | SEthernetHeader sEthHeader; |
| 2656 | void *pvRrvTime; |
| 2657 | void *pMICHDR; |
| 2658 | PSMgmtObject pMgmt = pDevice->pMgmt; |
| 2659 | unsigned short wCurrentRate = RATE_1M; |
| 2660 | PUWLAN_80211HDR p80211Header; |
| 2661 | unsigned int uNodeIndex = 0; |
| 2662 | bool bNodeExist = false; |
| 2663 | SKeyItem STempKey; |
| 2664 | PSKeyItem pTransmitKey = NULL; |
| 2665 | unsigned char *pbyIVHead; |
| 2666 | unsigned char *pbyPayloadHead; |
| 2667 | unsigned char *pbyMacHdr; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2668 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2669 | unsigned int cbExtSuppRate = 0; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2670 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2671 | pvRrvTime = pMICHDR = pvRTS = pvCTS = pvTxDataHd = NULL; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2672 | |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 2673 | if (cbMPDULen <= WLAN_HDR_ADDR3_LEN) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2674 | cbFrameBodySize = 0; |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 2675 | else |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2676 | cbFrameBodySize = cbMPDULen - WLAN_HDR_ADDR3_LEN; |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 2677 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2678 | p80211Header = (PUWLAN_80211HDR)pbMPDU; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2679 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2680 | pFrstTD = pDevice->apCurrTD[TYPE_TXDMA0]; |
| 2681 | pbyTxBufferAddr = (unsigned char *)pFrstTD->pTDInfo->buf; |
| 2682 | pTxBufHead = (PSTxBufHead) pbyTxBufferAddr; |
| 2683 | wTxBufSize = sizeof(STxBufHead); |
| 2684 | memset(pTxBufHead, 0, wTxBufSize); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2685 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2686 | if (pDevice->eCurrentPHYType == PHY_TYPE_11A) { |
| 2687 | wCurrentRate = RATE_6M; |
| 2688 | byPktType = PK_TYPE_11A; |
| 2689 | } else { |
| 2690 | wCurrentRate = RATE_1M; |
| 2691 | byPktType = PK_TYPE_11B; |
| 2692 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2693 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2694 | // SetPower will cause error power TX state for OFDM Date packet in TX buffer. |
| 2695 | // 2004.11.11 Kyle -- Using OFDM power to tx MngPkt will decrease the connection capability. |
| 2696 | // And cmd timer will wait data pkt TX to finish before scanning so it's OK |
| 2697 | // to set power here. |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 2698 | if (pDevice->pMgmt->eScanState != WMAC_NO_SCANNING) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2699 | RFbSetPower(pDevice, wCurrentRate, pDevice->byCurrentCh); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 2700 | else |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2701 | RFbSetPower(pDevice, wCurrentRate, pMgmt->uCurrChannel); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 2702 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2703 | pTxBufHead->byTxPower = pDevice->byCurPwr; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2704 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2705 | //+++++++++++++++++++++ Patch VT3253 A1 performance +++++++++++++++++++++++++++ |
| 2706 | if (pDevice->byFOETuning) { |
| 2707 | if ((p80211Header->sA3.wFrameCtl & TYPE_DATE_NULL) == TYPE_DATE_NULL) { |
| 2708 | wCurrentRate = RATE_24M; |
| 2709 | byPktType = PK_TYPE_11GA; |
| 2710 | } |
| 2711 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2712 | |
Joe Perches | 48caf5a | 2014-08-17 09:17:04 -0700 | [diff] [blame] | 2713 | pr_debug("vDMA0_tx_80211: p80211Header->sA3.wFrameCtl = %x\n", |
| 2714 | p80211Header->sA3.wFrameCtl); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2715 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2716 | //Set packet type |
| 2717 | if (byPktType == PK_TYPE_11A) {//0000 0000 0000 0000 |
| 2718 | pTxBufHead->wFIFOCtl = 0; |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 2719 | } else if (byPktType == PK_TYPE_11B) {//0000 0001 0000 0000 |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2720 | pTxBufHead->wFIFOCtl |= FIFOCTL_11B; |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 2721 | } else if (byPktType == PK_TYPE_11GB) {//0000 0010 0000 0000 |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2722 | pTxBufHead->wFIFOCtl |= FIFOCTL_11GB; |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 2723 | } else if (byPktType == PK_TYPE_11GA) {//0000 0011 0000 0000 |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2724 | pTxBufHead->wFIFOCtl |= FIFOCTL_11GA; |
| 2725 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2726 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2727 | pTxBufHead->wFIFOCtl |= FIFOCTL_TMOEN; |
| 2728 | pTxBufHead->wTimeStamp = cpu_to_le16(DEFAULT_MGN_LIFETIME_RES_64us); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2729 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2730 | if (is_multicast_ether_addr(&(p80211Header->sA3.abyAddr1[0]))) { |
| 2731 | bNeedACK = false; |
| 2732 | if (pDevice->bEnableHostWEP) { |
| 2733 | uNodeIndex = 0; |
| 2734 | bNodeExist = true; |
| 2735 | } |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 2736 | } else { |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2737 | if (pDevice->bEnableHostWEP) { |
| 2738 | if (BSSDBbIsSTAInNodeDB(pDevice->pMgmt, (unsigned char *)(p80211Header->sA3.abyAddr1), &uNodeIndex)) |
| 2739 | bNodeExist = true; |
| 2740 | } |
| 2741 | bNeedACK = true; |
| 2742 | pTxBufHead->wFIFOCtl |= FIFOCTL_NEEDACK; |
Teodora Baluta | 88cc850 | 2013-11-10 17:12:45 +0200 | [diff] [blame] | 2743 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2744 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2745 | if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) || |
| 2746 | (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA)) { |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2747 | pTxBufHead->wFIFOCtl |= FIFOCTL_LRETRY; |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2748 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2749 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2750 | pTxBufHead->wFIFOCtl |= (FIFOCTL_GENINT | FIFOCTL_ISDMA0); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2751 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2752 | if ((p80211Header->sA4.wFrameCtl & TYPE_SUBTYPE_MASK) == TYPE_CTL_PSPOLL) { |
| 2753 | bIsPSPOLL = true; |
| 2754 | cbMacHdLen = WLAN_HDR_ADDR2_LEN; |
| 2755 | } else { |
| 2756 | cbMacHdLen = WLAN_HDR_ADDR3_LEN; |
| 2757 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2758 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2759 | // hostapd deamon ext support rate patch |
| 2760 | if (WLAN_GET_FC_FSTYPE(p80211Header->sA4.wFrameCtl) == WLAN_FSTYPE_ASSOCRESP) { |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 2761 | if (((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates)->len != 0) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2762 | cbExtSuppRate += ((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates)->len + WLAN_IEHDR_LEN; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2763 | |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 2764 | if (((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates)->len != 0) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2765 | cbExtSuppRate += ((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates)->len + WLAN_IEHDR_LEN; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2766 | |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 2767 | if (cbExtSuppRate > 0) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2768 | cbFrameBodySize = WLAN_ASSOCRESP_OFF_SUPP_RATES; |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2769 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2770 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2771 | //Set FRAGCTL_MACHDCNT |
| 2772 | pTxBufHead->wFragCtl |= cpu_to_le16((unsigned short)cbMacHdLen << 10); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2773 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2774 | // Notes: |
| 2775 | // Although spec says MMPDU can be fragmented; In most cases, |
| 2776 | // no one will send a MMPDU under fragmentation. With RTS may occur. |
| 2777 | pDevice->bAES = false; //Set FRAGCTL_WEPTYP |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2778 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2779 | if (WLAN_GET_FC_ISWEP(p80211Header->sA4.wFrameCtl) != 0) { |
| 2780 | if (pDevice->eEncryptionStatus == Ndis802_11Encryption1Enabled) { |
| 2781 | cbIVlen = 4; |
| 2782 | cbICVlen = 4; |
| 2783 | pTxBufHead->wFragCtl |= FRAGCTL_LEGACY; |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 2784 | } else if (pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled) { |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2785 | cbIVlen = 8;//IV+ExtIV |
| 2786 | cbMIClen = 8; |
| 2787 | cbICVlen = 4; |
| 2788 | pTxBufHead->wFragCtl |= FRAGCTL_TKIP; |
| 2789 | //We need to get seed here for filling TxKey entry. |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 2790 | } else if (pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled) { |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2791 | cbIVlen = 8;//RSN Header |
| 2792 | cbICVlen = 8;//MIC |
Malcolm Priestley | 11a72e5 | 2014-08-09 20:15:56 +0100 | [diff] [blame] | 2793 | cbMICHDR = sizeof(struct vnt_mic_hdr); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2794 | pTxBufHead->wFragCtl |= FRAGCTL_AES; |
| 2795 | pDevice->bAES = true; |
| 2796 | } |
| 2797 | //MAC Header should be padding 0 to DW alignment. |
| 2798 | uPadding = 4 - (cbMacHdLen%4); |
| 2799 | uPadding %= 4; |
| 2800 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2801 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2802 | cbFrameSize = cbMacHdLen + cbFrameBodySize + cbIVlen + cbMIClen + cbICVlen + cbFCSlen + cbExtSuppRate; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2803 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2804 | //Set FIFOCTL_GrpAckPolicy |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 2805 | if (pDevice->bGrpAckPolicy == true) //0000 0100 0000 0000 |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2806 | pTxBufHead->wFIFOCtl |= FIFOCTL_GRPACK; |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 2807 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2808 | //the rest of pTxBufHead->wFragCtl:FragTyp will be set later in s_vFillFragParameter() |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2809 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2810 | if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) {//802.11g packet |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2811 | |
Malcolm Priestley | d66a5a7 | 2014-08-30 22:25:28 +0100 | [diff] [blame] | 2812 | pvRrvTime = (void *)(pbyTxBufferAddr + wTxBufSize); |
| 2813 | pMICHDR = (struct vnt_mic_hdr *)(pbyTxBufferAddr + wTxBufSize + |
| 2814 | sizeof(struct vnt_rrv_time_cts)); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2815 | pvRTS = NULL; |
Malcolm Priestley | f5172b0 | 2014-08-30 22:25:45 +0100 | [diff] [blame] | 2816 | pvCTS = (struct vnt_cts *)(pbyTxBufferAddr + wTxBufSize + |
Malcolm Priestley | d66a5a7 | 2014-08-30 22:25:28 +0100 | [diff] [blame] | 2817 | sizeof(struct vnt_rrv_time_cts) + cbMICHDR); |
Malcolm Priestley | 72edb7e | 2014-08-30 22:25:34 +0100 | [diff] [blame] | 2818 | pvTxDataHd = (void *)(pbyTxBufferAddr + wTxBufSize + |
Malcolm Priestley | f5172b0 | 2014-08-30 22:25:45 +0100 | [diff] [blame] | 2819 | sizeof(struct vnt_rrv_time_cts) + cbMICHDR + sizeof(struct vnt_cts)); |
Malcolm Priestley | d66a5a7 | 2014-08-30 22:25:28 +0100 | [diff] [blame] | 2820 | cbHeaderSize = wTxBufSize + sizeof(struct vnt_rrv_time_cts) + |
Malcolm Priestley | f5172b0 | 2014-08-30 22:25:45 +0100 | [diff] [blame] | 2821 | cbMICHDR + sizeof(struct vnt_cts) + sizeof(struct vnt_tx_datahead_g); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2822 | |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 2823 | } else {//802.11a/b packet |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2824 | |
Malcolm Priestley | f6a634c | 2014-08-30 22:25:29 +0100 | [diff] [blame] | 2825 | pvRrvTime = (void *)(pbyTxBufferAddr + wTxBufSize); |
| 2826 | pMICHDR = (struct vnt_mic_hdr *) (pbyTxBufferAddr + |
| 2827 | wTxBufSize + sizeof(struct vnt_rrv_time_ab)); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2828 | pvRTS = NULL; |
| 2829 | pvCTS = NULL; |
Malcolm Priestley | 9ce842a | 2014-08-30 22:25:36 +0100 | [diff] [blame] | 2830 | pvTxDataHd = (void *)(pbyTxBufferAddr + |
Malcolm Priestley | f6a634c | 2014-08-30 22:25:29 +0100 | [diff] [blame] | 2831 | wTxBufSize + sizeof(struct vnt_rrv_time_ab) + cbMICHDR); |
| 2832 | cbHeaderSize = wTxBufSize + sizeof(struct vnt_rrv_time_ab) + |
Malcolm Priestley | 9ce842a | 2014-08-30 22:25:36 +0100 | [diff] [blame] | 2833 | cbMICHDR + sizeof(struct vnt_tx_datahead_ab); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2834 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2835 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2836 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2837 | memset((void *)(pbyTxBufferAddr + wTxBufSize), 0, (cbHeaderSize - wTxBufSize)); |
Aya Mahfouz | 2359b5c | 2014-10-11 02:42:45 +0200 | [diff] [blame^] | 2838 | ether_addr_copy(&(sEthHeader.abyDstAddr[0]), |
| 2839 | &(p80211Header->sA3.abyAddr1[0])); |
| 2840 | ether_addr_copy(&(sEthHeader.abySrcAddr[0]), |
| 2841 | &(p80211Header->sA3.abyAddr2[0])); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2842 | //========================= |
| 2843 | // No Fragmentation |
| 2844 | //========================= |
| 2845 | pTxBufHead->wFragCtl |= (unsigned short)FRAGCTL_NONFRAG; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2846 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2847 | //Fill FIFO,RrvTime,RTS,and CTS |
| 2848 | s_vGenerateTxParameter(pDevice, byPktType, pbyTxBufferAddr, pvRrvTime, pvRTS, pvCTS, |
| 2849 | cbFrameSize, bNeedACK, TYPE_TXDMA0, &sEthHeader, wCurrentRate); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2850 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2851 | //Fill DataHead |
| 2852 | uDuration = s_uFillDataHead(pDevice, byPktType, pvTxDataHd, cbFrameSize, TYPE_TXDMA0, bNeedACK, |
| 2853 | 0, 0, 1, AUTO_FB_NONE, wCurrentRate); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2854 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2855 | pMACHeader = (PS802_11Header) (pbyTxBufferAddr + cbHeaderSize); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2856 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2857 | cbReqCount = cbHeaderSize + cbMacHdLen + uPadding + cbIVlen + (cbFrameBodySize + cbMIClen) + cbExtSuppRate; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2858 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2859 | pbyMacHdr = (unsigned char *)(pbyTxBufferAddr + cbHeaderSize); |
| 2860 | pbyPayloadHead = (unsigned char *)(pbyMacHdr + cbMacHdLen + uPadding + cbIVlen); |
| 2861 | pbyIVHead = (unsigned char *)(pbyMacHdr + cbMacHdLen + uPadding); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2862 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2863 | // Copy the Packet into a tx Buffer |
| 2864 | memcpy(pbyMacHdr, pbMPDU, cbMacHdLen); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2865 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2866 | // version set to 0, patch for hostapd deamon |
| 2867 | pMACHeader->wFrameCtl &= cpu_to_le16(0xfffc); |
| 2868 | memcpy(pbyPayloadHead, (pbMPDU + cbMacHdLen), cbFrameBodySize); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2869 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2870 | // replace support rate, patch for hostapd deamon(only support 11M) |
| 2871 | if (WLAN_GET_FC_FSTYPE(p80211Header->sA4.wFrameCtl) == WLAN_FSTYPE_ASSOCRESP) { |
| 2872 | if (cbExtSuppRate != 0) { |
| 2873 | if (((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates)->len != 0) |
| 2874 | memcpy((pbyPayloadHead + cbFrameBodySize), |
| 2875 | pMgmt->abyCurrSuppRates, |
| 2876 | ((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates)->len + WLAN_IEHDR_LEN |
| 2877 | ); |
| 2878 | if (((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates)->len != 0) |
| 2879 | memcpy((pbyPayloadHead + cbFrameBodySize) + ((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates)->len + WLAN_IEHDR_LEN, |
| 2880 | pMgmt->abyCurrExtSuppRates, |
| 2881 | ((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates)->len + WLAN_IEHDR_LEN |
| 2882 | ); |
| 2883 | } |
| 2884 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2885 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2886 | // Set wep |
| 2887 | if (WLAN_GET_FC_ISWEP(p80211Header->sA4.wFrameCtl) != 0) { |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2888 | if (pDevice->bEnableHostWEP) { |
| 2889 | pTransmitKey = &STempKey; |
| 2890 | pTransmitKey->byCipherSuite = pMgmt->sNodeDBTable[uNodeIndex].byCipherSuite; |
| 2891 | pTransmitKey->dwKeyIndex = pMgmt->sNodeDBTable[uNodeIndex].dwKeyIndex; |
| 2892 | pTransmitKey->uKeyLength = pMgmt->sNodeDBTable[uNodeIndex].uWepKeyLength; |
| 2893 | pTransmitKey->dwTSC47_16 = pMgmt->sNodeDBTable[uNodeIndex].dwTSC47_16; |
| 2894 | pTransmitKey->wTSC15_0 = pMgmt->sNodeDBTable[uNodeIndex].wTSC15_0; |
| 2895 | memcpy(pTransmitKey->abyKey, |
| 2896 | &pMgmt->sNodeDBTable[uNodeIndex].abyWepKey[0], |
| 2897 | pTransmitKey->uKeyLength |
| 2898 | ); |
| 2899 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2900 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2901 | if ((pTransmitKey != NULL) && (pTransmitKey->byCipherSuite == KEY_CTL_TKIP)) { |
Malcolm Priestley | 12ca22b | 2014-03-06 22:44:25 +0000 | [diff] [blame] | 2902 | dwMICKey0 = *(u32 *)(&pTransmitKey->abyKey[16]); |
| 2903 | dwMICKey1 = *(u32 *)(&pTransmitKey->abyKey[20]); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2904 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2905 | // DO Software Michael |
| 2906 | MIC_vInit(dwMICKey0, dwMICKey1); |
| 2907 | MIC_vAppend((unsigned char *)&(sEthHeader.abyDstAddr[0]), 12); |
| 2908 | dwMIC_Priority = 0; |
| 2909 | MIC_vAppend((unsigned char *)&dwMIC_Priority, 4); |
Joe Perches | 48caf5a | 2014-08-17 09:17:04 -0700 | [diff] [blame] | 2910 | pr_debug("DMA0_tx_8021:MIC KEY: %X, %X\n", |
| 2911 | dwMICKey0, dwMICKey1); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2912 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2913 | uLength = cbHeaderSize + cbMacHdLen + uPadding + cbIVlen; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2914 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2915 | MIC_vAppend((pbyTxBufferAddr + uLength), cbFrameBodySize); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2916 | |
Malcolm Priestley | d0daef3 | 2014-03-06 22:44:23 +0000 | [diff] [blame] | 2917 | pdwMIC_L = (u32 *)(pbyTxBufferAddr + uLength + cbFrameBodySize); |
| 2918 | pdwMIC_R = (u32 *)(pbyTxBufferAddr + uLength + cbFrameBodySize + 4); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2919 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2920 | MIC_vGetMIC(pdwMIC_L, pdwMIC_R); |
| 2921 | MIC_vUnInit(); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2922 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2923 | if (pDevice->bTxMICFail == true) { |
| 2924 | *pdwMIC_L = 0; |
| 2925 | *pdwMIC_R = 0; |
| 2926 | pDevice->bTxMICFail = false; |
| 2927 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2928 | |
Joe Perches | 48caf5a | 2014-08-17 09:17:04 -0700 | [diff] [blame] | 2929 | pr_debug("uLength: %d, %d\n", uLength, cbFrameBodySize); |
| 2930 | pr_debug("cbReqCount:%d, %d, %d, %d\n", |
| 2931 | cbReqCount, cbHeaderSize, uPadding, cbIVlen); |
| 2932 | pr_debug("MIC:%x, %x\n", *pdwMIC_L, *pdwMIC_R); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2933 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2934 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2935 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2936 | s_vFillTxKey(pDevice, (unsigned char *)(pTxBufHead->adwTxKey), pbyIVHead, pTransmitKey, |
| 2937 | pbyMacHdr, (unsigned short)cbFrameBodySize, (unsigned char *)pMICHDR); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2938 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2939 | if (pDevice->bEnableHostWEP) { |
| 2940 | pMgmt->sNodeDBTable[uNodeIndex].dwTSC47_16 = pTransmitKey->dwTSC47_16; |
| 2941 | pMgmt->sNodeDBTable[uNodeIndex].wTSC15_0 = pTransmitKey->wTSC15_0; |
| 2942 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2943 | |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 2944 | if ((pDevice->byLocalID <= REV_ID_VT3253_A1)) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2945 | s_vSWencryption(pDevice, pTransmitKey, pbyPayloadHead, (unsigned short)(cbFrameBodySize + cbMIClen)); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2946 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2947 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2948 | pMACHeader->wSeqCtl = cpu_to_le16(pDevice->wSeqCounter << 4); |
| 2949 | pDevice->wSeqCounter++; |
| 2950 | if (pDevice->wSeqCounter > 0x0fff) |
| 2951 | pDevice->wSeqCounter = 0; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2952 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2953 | if (bIsPSPOLL) { |
| 2954 | // The MAC will automatically replace the Duration-field of MAC header by Duration-field |
| 2955 | // of FIFO control header. |
| 2956 | // This will cause AID-field of PS-POLL packet be incorrect (Because PS-POLL's AID field is |
| 2957 | // in the same place of other packet's Duration-field). |
| 2958 | // And it will cause Cisco-AP to issue Disassociation-packet |
| 2959 | if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) { |
Malcolm Priestley | 72edb7e | 2014-08-30 22:25:34 +0100 | [diff] [blame] | 2960 | ((struct vnt_tx_datahead_g *)pvTxDataHd)->duration_a = cpu_to_le16(p80211Header->sA2.wDurationID); |
| 2961 | ((struct vnt_tx_datahead_g *)pvTxDataHd)->duration_b = cpu_to_le16(p80211Header->sA2.wDurationID); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2962 | } else { |
Malcolm Priestley | 9ce842a | 2014-08-30 22:25:36 +0100 | [diff] [blame] | 2963 | ((struct vnt_tx_datahead_ab *)pvTxDataHd)->duration = cpu_to_le16(p80211Header->sA2.wDurationID); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2964 | } |
| 2965 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2966 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2967 | // first TD is the only TD |
| 2968 | //Set TSR1 & ReqCount in TxDescHead |
| 2969 | pFrstTD->pTDInfo->skb = skb; |
| 2970 | pFrstTD->m_td1TD1.byTCR = (TCR_STP | TCR_EDP | EDMSDU); |
| 2971 | pFrstTD->pTDInfo->skb_dma = pFrstTD->pTDInfo->buf_dma; |
| 2972 | pFrstTD->m_td1TD1.wReqCount = cpu_to_le16(cbReqCount); |
| 2973 | pFrstTD->buff_addr = cpu_to_le32(pFrstTD->pTDInfo->skb_dma); |
| 2974 | pFrstTD->pTDInfo->byFlags = 0; |
| 2975 | pFrstTD->pTDInfo->byFlags |= TD_FLAGS_PRIV_SKB; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2976 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2977 | if (MACbIsRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_PS)) { |
| 2978 | // Disable PS |
| 2979 | MACbPSWakeup(pDevice->PortOffset); |
| 2980 | } |
| 2981 | pDevice->bPWBitOn = false; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2982 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2983 | wmb(); |
| 2984 | pFrstTD->m_td0TD0.f1Owner = OWNED_BY_NIC; |
| 2985 | wmb(); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2986 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2987 | pDevice->iTDUsed[TYPE_TXDMA0]++; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2988 | |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 2989 | if (AVAIL_TD(pDevice, TYPE_TXDMA0) <= 1) |
Joe Perches | 48caf5a | 2014-08-17 09:17:04 -0700 | [diff] [blame] | 2990 | pr_debug(" available td0 <= 1\n"); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2991 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2992 | pDevice->apCurrTD[TYPE_TXDMA0] = pFrstTD->next; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2993 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 2994 | // Poll Transmit the adapter |
| 2995 | MACvTransmit0(pDevice->PortOffset); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2996 | } |