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