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