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