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