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