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