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