Forest Bond | 5449c68 | 2009-04-25 10:30:44 -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 | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 29 | * vGenerateMACHeader - Translate 802.3 to 802.11 header |
Justin P. Mattock | 7664ec8 | 2012-08-20 08:43:15 -0700 | [diff] [blame] | 30 | * cbGetFragCount - Calculate fragment number count |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 31 | * csBeacon_xmit - beacon tx function |
| 32 | * csMgmt_xmit - management tx function |
| 33 | * s_cbFillTxBufHead - fulfill tx dma buffer header |
| 34 | * s_uGetDataDuration - get tx data required duration |
| 35 | * s_uFillDataHead- fulfill tx data duration header |
Gilles Espinasse | f77f13e | 2010-03-29 15:41:47 +0200 | [diff] [blame] | 36 | * s_uGetRTSCTSDuration- get rtx/cts required duration |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 37 | * s_uGetRTSCTSRsvTime- get rts/cts reserved time |
| 38 | * s_uGetTxRsvTime- get frame reserved time |
| 39 | * s_vFillCTSHead- fulfill CTS ctl header |
Gilles Espinasse | f77f13e | 2010-03-29 15:41:47 +0200 | [diff] [blame] | 40 | * s_vFillFragParameter- Set fragment ctl parameter. |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 41 | * s_vFillRTSHead- fulfill RTS ctl header |
| 42 | * s_vFillTxKey- fulfill tx encrypt key |
| 43 | * s_vSWencryption- Software encrypt header |
| 44 | * vDMA0_tx_80211- tx 802.11 frame via dma0 |
| 45 | * vGenerateFIFOHeader- Generate tx FIFO ctl header |
| 46 | * |
| 47 | * Revision History: |
| 48 | * |
| 49 | */ |
| 50 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 51 | #include "device.h" |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 52 | #include "rxtx.h" |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 53 | #include "card.h" |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 54 | #include "mac.h" |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 55 | #include "baseband.h" |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 56 | #include "rf.h" |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 57 | |
| 58 | /*--------------------- Static Definitions -------------------------*/ |
| 59 | |
| 60 | /*--------------------- Static Classes ----------------------------*/ |
| 61 | |
| 62 | /*--------------------- Static Variables --------------------------*/ |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 63 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 64 | /*--------------------- Static Functions --------------------------*/ |
| 65 | |
| 66 | /*--------------------- Static Definitions -------------------------*/ |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 67 | #define CRITICAL_PACKET_LEN 256 /* if packet size < 256 -> in-direct send |
| 68 | packet size >= 256 -> direct send */ |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 69 | |
Anton Protopopov | 83e771f | 2014-07-01 21:06:29 +0400 | [diff] [blame] | 70 | static const unsigned short wTimeStampOff[2][MAX_RATE] = { |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 71 | {384, 288, 226, 209, 54, 43, 37, 31, 28, 25, 24, 23}, /* Long Preamble */ |
| 72 | {384, 192, 130, 113, 54, 43, 37, 31, 28, 25, 24, 23}, /* Short Preamble */ |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 73 | }; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 74 | |
Anton Protopopov | 83e771f | 2014-07-01 21:06:29 +0400 | [diff] [blame] | 75 | static const unsigned short wFB_Opt0[2][5] = { |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 76 | {RATE_12M, RATE_18M, RATE_24M, RATE_36M, RATE_48M}, /* fallback_rate0 */ |
| 77 | {RATE_12M, RATE_12M, RATE_18M, RATE_24M, RATE_36M}, /* fallback_rate1 */ |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 78 | }; |
Anton Protopopov | 83e771f | 2014-07-01 21:06:29 +0400 | [diff] [blame] | 79 | static const unsigned short wFB_Opt1[2][5] = { |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 80 | {RATE_12M, RATE_18M, RATE_24M, RATE_24M, RATE_36M}, /* fallback_rate0 */ |
| 81 | {RATE_6M , RATE_6M, RATE_12M, RATE_12M, RATE_18M}, /* fallback_rate1 */ |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 82 | }; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 83 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 84 | #define RTSDUR_BB 0 |
| 85 | #define RTSDUR_BA 1 |
| 86 | #define RTSDUR_AA 2 |
| 87 | #define CTSDUR_BA 3 |
| 88 | #define RTSDUR_BA_F0 4 |
| 89 | #define RTSDUR_AA_F0 5 |
| 90 | #define RTSDUR_BA_F1 6 |
| 91 | #define RTSDUR_AA_F1 7 |
| 92 | #define CTSDUR_BA_F0 8 |
| 93 | #define CTSDUR_BA_F1 9 |
| 94 | #define DATADUR_B 10 |
| 95 | #define DATADUR_A 11 |
| 96 | #define DATADUR_A_F0 12 |
| 97 | #define DATADUR_A_F1 13 |
| 98 | |
| 99 | /*--------------------- Static Functions --------------------------*/ |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 100 | static |
Charles Clément | 6b35b7b | 2010-05-07 12:30:19 -0700 | [diff] [blame] | 101 | void |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 102 | s_vFillRTSHead( |
Malcolm Priestley | cf76dc4 | 2014-08-10 15:46:59 +0100 | [diff] [blame] | 103 | struct vnt_private *pDevice, |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 104 | unsigned char byPktType, |
| 105 | void *pvRTS, |
| 106 | unsigned int cbFrameLength, |
| 107 | bool bNeedAck, |
| 108 | bool bDisCRC, |
Malcolm Priestley | 7c0496d | 2014-10-29 17:43:41 +0000 | [diff] [blame] | 109 | struct ieee80211_hdr *hdr, |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 110 | unsigned short wCurrentRate, |
| 111 | unsigned char byFBOption |
| 112 | ); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 113 | |
| 114 | static |
Charles Clément | 6b35b7b | 2010-05-07 12:30:19 -0700 | [diff] [blame] | 115 | void |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 116 | s_vGenerateTxParameter( |
Malcolm Priestley | cf76dc4 | 2014-08-10 15:46:59 +0100 | [diff] [blame] | 117 | struct vnt_private *pDevice, |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 118 | unsigned char byPktType, |
Malcolm Priestley | df18480 | 2015-04-01 22:32:51 +0100 | [diff] [blame] | 119 | struct vnt_tx_fifo_head *, |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 120 | void *pvRrvTime, |
| 121 | void *pvRTS, |
| 122 | void *pvCTS, |
| 123 | unsigned int cbFrameSize, |
| 124 | bool bNeedACK, |
| 125 | unsigned int uDMAIdx, |
Malcolm Priestley | cfd9f0d | 2014-10-29 17:43:39 +0000 | [diff] [blame] | 126 | void *psEthHeader, |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 127 | unsigned short wCurrentRate |
| 128 | ); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 129 | |
Charles Clément | fe4f34b | 2010-06-25 10:48:53 -0700 | [diff] [blame] | 130 | static unsigned int |
Malcolm Priestley | cf76dc4 | 2014-08-10 15:46:59 +0100 | [diff] [blame] | 131 | s_cbFillTxBufHead(struct vnt_private *pDevice, unsigned char byPktType, |
Malcolm Priestley | 19f3ed3 | 2014-11-29 00:02:03 +0000 | [diff] [blame] | 132 | unsigned char *pbyTxBufferAddr, |
Malcolm Priestley | cf76dc4 | 2014-08-10 15:46:59 +0100 | [diff] [blame] | 133 | unsigned int uDMAIdx, PSTxDesc pHeadTD, |
Malcolm Priestley | 154bb8b | 2014-11-29 00:02:02 +0000 | [diff] [blame] | 134 | unsigned int uNodeIndex); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 135 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 136 | static |
Malcolm Priestley | a479ffc | 2014-08-30 22:25:38 +0100 | [diff] [blame] | 137 | __le16 |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 138 | s_uFillDataHead( |
Malcolm Priestley | cf76dc4 | 2014-08-10 15:46:59 +0100 | [diff] [blame] | 139 | struct vnt_private *pDevice, |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 140 | unsigned char byPktType, |
| 141 | void *pTxDataHead, |
| 142 | unsigned int cbFrameLength, |
| 143 | unsigned int uDMAIdx, |
| 144 | bool bNeedAck, |
| 145 | unsigned int uFragIdx, |
| 146 | unsigned int cbLastFragmentSize, |
| 147 | unsigned int uMACfragNum, |
| 148 | unsigned char byFBOption, |
Malcolm Priestley | 89cf9be | 2014-10-29 17:43:42 +0000 | [diff] [blame] | 149 | unsigned short wCurrentRate, |
| 150 | bool is_pspoll |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 151 | ); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 152 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 153 | /*--------------------- Export Variables --------------------------*/ |
| 154 | |
Malcolm Priestley | d6b95c0 | 2014-08-30 22:25:33 +0100 | [diff] [blame] | 155 | static __le16 vnt_time_stamp_off(struct vnt_private *priv, u16 rate) |
| 156 | { |
| 157 | return cpu_to_le16(wTimeStampOff[priv->byPreambleType % 2] |
| 158 | [rate % MAX_RATE]); |
| 159 | } |
| 160 | |
Jim Lieb | 7e809a9 | 2009-07-30 10:27:21 -0700 | [diff] [blame] | 161 | /*byPktType : PK_TYPE_11A 0 |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 162 | PK_TYPE_11B 1 |
| 163 | PK_TYPE_11GB 2 |
| 164 | PK_TYPE_11GA 3 |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 165 | */ |
| 166 | static |
Charles Clément | b6e95cd | 2010-06-02 09:52:01 -0700 | [diff] [blame] | 167 | unsigned int |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 168 | s_uGetTxRsvTime( |
Malcolm Priestley | cf76dc4 | 2014-08-10 15:46:59 +0100 | [diff] [blame] | 169 | struct vnt_private *pDevice, |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 170 | unsigned char byPktType, |
| 171 | unsigned int cbFrameLength, |
| 172 | unsigned short wRate, |
| 173 | bool bNeedAck |
| 174 | ) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 175 | { |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 176 | unsigned int uDataTime, uAckTime; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 177 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 178 | uDataTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, cbFrameLength, wRate); |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 179 | if (byPktType == PK_TYPE_11B) /* llb,CCK mode */ |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 180 | uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, (unsigned short)pDevice->byTopCCKBasicRate); |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 181 | else /* 11g 2.4G OFDM mode & 11a 5G OFDM mode */ |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 182 | uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, (unsigned short)pDevice->byTopOFDMBasicRate); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 183 | |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 184 | if (bNeedAck) |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 185 | return uDataTime + pDevice->uSIFS + uAckTime; |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 186 | else |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 187 | return uDataTime; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 188 | } |
| 189 | |
Malcolm Priestley | e7a3481b | 2014-08-30 22:25:30 +0100 | [diff] [blame] | 190 | static __le16 vnt_rxtx_rsvtime_le16(struct vnt_private *priv, u8 pkt_type, |
| 191 | u32 frame_length, u16 rate, bool need_ack) |
| 192 | { |
| 193 | return cpu_to_le16((u16)s_uGetTxRsvTime(priv, pkt_type, |
| 194 | frame_length, rate, need_ack)); |
| 195 | } |
| 196 | |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 197 | /* byFreqType: 0=>5GHZ 1=>2.4GHZ */ |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 198 | static |
Malcolm Priestley | 853532d | 2014-08-30 22:25:31 +0100 | [diff] [blame] | 199 | __le16 |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 200 | s_uGetRTSCTSRsvTime( |
Malcolm Priestley | cf76dc4 | 2014-08-10 15:46:59 +0100 | [diff] [blame] | 201 | struct vnt_private *pDevice, |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 202 | unsigned char byRTSRsvType, |
| 203 | unsigned char byPktType, |
| 204 | unsigned int cbFrameLength, |
| 205 | unsigned short wCurrentRate |
| 206 | ) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 207 | { |
Piotr Kubus | bc22b49 | 2015-01-10 15:35:45 +0100 | [diff] [blame] | 208 | unsigned int uRrvTime, uRTSTime, uCTSTime, uAckTime, uDataTime; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 209 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 210 | uRrvTime = uRTSTime = uCTSTime = uAckTime = uDataTime = 0; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 211 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 212 | uDataTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, cbFrameLength, wCurrentRate); |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 213 | if (byRTSRsvType == 0) { /* RTSTxRrvTime_bb */ |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 214 | uRTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 20, pDevice->byTopCCKBasicRate); |
| 215 | uCTSTime = uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopCCKBasicRate); |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 216 | } else if (byRTSRsvType == 1) { /* RTSTxRrvTime_ba, only in 2.4GHZ */ |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 217 | uRTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 20, pDevice->byTopCCKBasicRate); |
| 218 | uCTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopCCKBasicRate); |
| 219 | uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate); |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 220 | } else if (byRTSRsvType == 2) { /* RTSTxRrvTime_aa */ |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 221 | uRTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 20, pDevice->byTopOFDMBasicRate); |
| 222 | uCTSTime = uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate); |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 223 | } else if (byRTSRsvType == 3) { /* CTSTxRrvTime_ba, only in 2.4GHZ */ |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 224 | uCTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopCCKBasicRate); |
| 225 | uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate); |
| 226 | uRrvTime = uCTSTime + uAckTime + uDataTime + 2*pDevice->uSIFS; |
Malcolm Priestley | 853532d | 2014-08-30 22:25:31 +0100 | [diff] [blame] | 227 | return cpu_to_le16((u16)uRrvTime); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 228 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 229 | |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 230 | /* RTSRrvTime */ |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 231 | uRrvTime = uRTSTime + uCTSTime + uAckTime + uDataTime + 3*pDevice->uSIFS; |
Malcolm Priestley | 853532d | 2014-08-30 22:25:31 +0100 | [diff] [blame] | 232 | return cpu_to_le16((u16)uRrvTime); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 233 | } |
| 234 | |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 235 | /* byFreqType 0: 5GHz, 1:2.4Ghz */ |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 236 | static |
Charles Clément | b6e95cd | 2010-06-02 09:52:01 -0700 | [diff] [blame] | 237 | unsigned int |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 238 | s_uGetDataDuration( |
Malcolm Priestley | cf76dc4 | 2014-08-10 15:46:59 +0100 | [diff] [blame] | 239 | struct vnt_private *pDevice, |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 240 | unsigned char byDurType, |
| 241 | unsigned int cbFrameLength, |
| 242 | unsigned char byPktType, |
| 243 | unsigned short wRate, |
| 244 | bool bNeedAck, |
| 245 | unsigned int uFragIdx, |
| 246 | unsigned int cbLastFragmentSize, |
| 247 | unsigned int uMACfragNum, |
| 248 | unsigned char byFBOption |
| 249 | ) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 250 | { |
Cristina Opriceana | 19cd229 | 2015-03-04 12:37:28 +0200 | [diff] [blame] | 251 | bool bLastFrag = false; |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 252 | unsigned int uAckTime = 0, uNextPktTime = 0; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 253 | |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 254 | if (uFragIdx == (uMACfragNum-1)) |
Cristina Opriceana | 19cd229 | 2015-03-04 12:37:28 +0200 | [diff] [blame] | 255 | bLastFrag = true; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 256 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 257 | switch (byDurType) { |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 258 | case DATADUR_B: /* DATADUR_B */ |
| 259 | if (((uMACfragNum == 1)) || bLastFrag) {/* Non Frag or Last Frag */ |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 260 | if (bNeedAck) { |
| 261 | uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopCCKBasicRate); |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 262 | return pDevice->uSIFS + uAckTime; |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 263 | } else { |
| 264 | return 0; |
| 265 | } |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 266 | } else {/* First Frag or Mid Frag */ |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 267 | if (uFragIdx == (uMACfragNum-2)) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 268 | uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbLastFragmentSize, wRate, bNeedAck); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 269 | else |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 270 | uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wRate, bNeedAck); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 271 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 272 | if (bNeedAck) { |
| 273 | uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopCCKBasicRate); |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 274 | return pDevice->uSIFS + uAckTime + uNextPktTime; |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 275 | } else { |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 276 | return pDevice->uSIFS + uNextPktTime; |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 277 | } |
| 278 | } |
| 279 | break; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 280 | |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 281 | case DATADUR_A: /* DATADUR_A */ |
| 282 | if (((uMACfragNum == 1)) || bLastFrag) {/* Non Frag or Last Frag */ |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 283 | if (bNeedAck) { |
| 284 | uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate); |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 285 | return pDevice->uSIFS + uAckTime; |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 286 | } else { |
| 287 | return 0; |
| 288 | } |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 289 | } else {/* First Frag or Mid Frag */ |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 290 | if (uFragIdx == (uMACfragNum-2)) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 291 | uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbLastFragmentSize, wRate, bNeedAck); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 292 | else |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 293 | uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wRate, bNeedAck); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 294 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 295 | if (bNeedAck) { |
| 296 | uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate); |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 297 | return pDevice->uSIFS + uAckTime + uNextPktTime; |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 298 | } else { |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 299 | return pDevice->uSIFS + uNextPktTime; |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 300 | } |
| 301 | } |
| 302 | break; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 303 | |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 304 | case DATADUR_A_F0: /* DATADUR_A_F0 */ |
| 305 | if (((uMACfragNum == 1)) || bLastFrag) {/* Non Frag or Last Frag */ |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 306 | if (bNeedAck) { |
| 307 | uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate); |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 308 | return pDevice->uSIFS + uAckTime; |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 309 | } else { |
| 310 | return 0; |
| 311 | } |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 312 | } else { /* First Frag or Mid Frag */ |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 313 | if (byFBOption == AUTO_FB_0) { |
| 314 | if (wRate < RATE_18M) |
| 315 | wRate = RATE_18M; |
| 316 | else if (wRate > RATE_54M) |
| 317 | wRate = RATE_54M; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 318 | |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 319 | if (uFragIdx == (uMACfragNum-2)) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 320 | uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbLastFragmentSize, wFB_Opt0[FB_RATE0][wRate-RATE_18M], bNeedAck); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 321 | else |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 322 | uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt0[FB_RATE0][wRate-RATE_18M], bNeedAck); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 323 | |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 324 | } else { /* (byFBOption == AUTO_FB_1) */ |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 325 | if (wRate < RATE_18M) |
| 326 | wRate = RATE_18M; |
| 327 | else if (wRate > RATE_54M) |
| 328 | wRate = RATE_54M; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 329 | |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 330 | if (uFragIdx == (uMACfragNum-2)) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 331 | uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbLastFragmentSize, wFB_Opt1[FB_RATE0][wRate-RATE_18M], bNeedAck); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 332 | else |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 333 | uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt1[FB_RATE0][wRate-RATE_18M], bNeedAck); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 334 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 335 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 336 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 337 | if (bNeedAck) { |
| 338 | uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate); |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 339 | return pDevice->uSIFS + uAckTime + uNextPktTime; |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 340 | } else { |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 341 | return pDevice->uSIFS + uNextPktTime; |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 342 | } |
| 343 | } |
| 344 | break; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 345 | |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 346 | case DATADUR_A_F1: /* DATADUR_A_F1 */ |
| 347 | if (((uMACfragNum == 1)) || bLastFrag) { /* Non Frag or Last Frag */ |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 348 | if (bNeedAck) { |
| 349 | uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate); |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 350 | return pDevice->uSIFS + uAckTime; |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 351 | } else { |
| 352 | return 0; |
| 353 | } |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 354 | } else { /* First Frag or Mid Frag */ |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 355 | if (byFBOption == AUTO_FB_0) { |
| 356 | if (wRate < RATE_18M) |
| 357 | wRate = RATE_18M; |
| 358 | else if (wRate > RATE_54M) |
| 359 | wRate = RATE_54M; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 360 | |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 361 | if (uFragIdx == (uMACfragNum-2)) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 362 | uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbLastFragmentSize, wFB_Opt0[FB_RATE1][wRate-RATE_18M], bNeedAck); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 363 | else |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 364 | uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt0[FB_RATE1][wRate-RATE_18M], bNeedAck); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 365 | |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 366 | } else { /* (byFBOption == AUTO_FB_1) */ |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 367 | if (wRate < RATE_18M) |
| 368 | wRate = RATE_18M; |
| 369 | else if (wRate > RATE_54M) |
| 370 | wRate = RATE_54M; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 371 | |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 372 | if (uFragIdx == (uMACfragNum-2)) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 373 | uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbLastFragmentSize, wFB_Opt1[FB_RATE1][wRate-RATE_18M], bNeedAck); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 374 | else |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 375 | uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt1[FB_RATE1][wRate-RATE_18M], bNeedAck); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 376 | } |
| 377 | if (bNeedAck) { |
| 378 | uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate); |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 379 | return pDevice->uSIFS + uAckTime + uNextPktTime; |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 380 | } else { |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 381 | return pDevice->uSIFS + uNextPktTime; |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 382 | } |
| 383 | } |
| 384 | break; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 385 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 386 | default: |
| 387 | break; |
| 388 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 389 | |
Charles Clément | 5a5a2a6 | 2010-08-01 17:15:49 +0200 | [diff] [blame] | 390 | ASSERT(false); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 391 | return 0; |
| 392 | } |
| 393 | |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 394 | /* byFreqType: 0=>5GHZ 1=>2.4GHZ */ |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 395 | static |
Malcolm Priestley | 96372bd | 2014-08-30 22:25:48 +0100 | [diff] [blame] | 396 | __le16 |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 397 | s_uGetRTSCTSDuration( |
Malcolm Priestley | cf76dc4 | 2014-08-10 15:46:59 +0100 | [diff] [blame] | 398 | struct vnt_private *pDevice, |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 399 | unsigned char byDurType, |
| 400 | unsigned int cbFrameLength, |
| 401 | unsigned char byPktType, |
| 402 | unsigned short wRate, |
| 403 | bool bNeedAck, |
| 404 | unsigned char byFBOption |
| 405 | ) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 406 | { |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 407 | unsigned int uCTSTime = 0, uDurTime = 0; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 408 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 409 | switch (byDurType) { |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 410 | case RTSDUR_BB: /* RTSDuration_bb */ |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 411 | uCTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopCCKBasicRate); |
| 412 | uDurTime = uCTSTime + 2*pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wRate, bNeedAck); |
| 413 | break; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 414 | |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 415 | case RTSDUR_BA: /* RTSDuration_ba */ |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 416 | uCTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopCCKBasicRate); |
| 417 | uDurTime = uCTSTime + 2*pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wRate, bNeedAck); |
| 418 | break; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 419 | |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 420 | case RTSDUR_AA: /* RTSDuration_aa */ |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 421 | uCTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate); |
| 422 | uDurTime = uCTSTime + 2*pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wRate, bNeedAck); |
| 423 | break; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 424 | |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 425 | case CTSDUR_BA: /* CTSDuration_ba */ |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 426 | uDurTime = pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wRate, bNeedAck); |
| 427 | break; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 428 | |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 429 | case RTSDUR_BA_F0: /* RTSDuration_ba_f0 */ |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 430 | uCTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopCCKBasicRate); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 431 | if ((byFBOption == AUTO_FB_0) && (wRate >= RATE_18M) && (wRate <= RATE_54M)) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 432 | uDurTime = uCTSTime + 2 * pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt0[FB_RATE0][wRate-RATE_18M], bNeedAck); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 433 | else if ((byFBOption == AUTO_FB_1) && (wRate >= RATE_18M) && (wRate <= RATE_54M)) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 434 | uDurTime = uCTSTime + 2 * pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt1[FB_RATE0][wRate-RATE_18M], bNeedAck); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 435 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 436 | break; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 437 | |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 438 | case RTSDUR_AA_F0: /* RTSDuration_aa_f0 */ |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 439 | uCTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 440 | if ((byFBOption == AUTO_FB_0) && (wRate >= RATE_18M) && (wRate <= RATE_54M)) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 441 | uDurTime = uCTSTime + 2*pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt0[FB_RATE0][wRate-RATE_18M], bNeedAck); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 442 | else if ((byFBOption == AUTO_FB_1) && (wRate >= RATE_18M) && (wRate <= RATE_54M)) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 443 | uDurTime = uCTSTime + 2*pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt1[FB_RATE0][wRate-RATE_18M], bNeedAck); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 444 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 445 | break; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 446 | |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 447 | case RTSDUR_BA_F1: /* RTSDuration_ba_f1 */ |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 448 | uCTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopCCKBasicRate); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 449 | if ((byFBOption == AUTO_FB_0) && (wRate >= RATE_18M) && (wRate <= RATE_54M)) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 450 | uDurTime = uCTSTime + 2*pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt0[FB_RATE1][wRate-RATE_18M], bNeedAck); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 451 | else if ((byFBOption == AUTO_FB_1) && (wRate >= RATE_18M) && (wRate <= RATE_54M)) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 452 | uDurTime = uCTSTime + 2*pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt1[FB_RATE1][wRate-RATE_18M], bNeedAck); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 453 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 454 | break; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 455 | |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 456 | case RTSDUR_AA_F1: /* RTSDuration_aa_f1 */ |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 457 | uCTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 458 | if ((byFBOption == AUTO_FB_0) && (wRate >= RATE_18M) && (wRate <= RATE_54M)) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 459 | uDurTime = uCTSTime + 2*pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt0[FB_RATE1][wRate-RATE_18M], bNeedAck); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 460 | else if ((byFBOption == AUTO_FB_1) && (wRate >= RATE_18M) && (wRate <= RATE_54M)) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 461 | uDurTime = uCTSTime + 2*pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt1[FB_RATE1][wRate-RATE_18M], bNeedAck); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 462 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 463 | break; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 464 | |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 465 | case CTSDUR_BA_F0: /* CTSDuration_ba_f0 */ |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 466 | if ((byFBOption == AUTO_FB_0) && (wRate >= RATE_18M) && (wRate <= RATE_54M)) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 467 | uDurTime = pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt0[FB_RATE0][wRate-RATE_18M], bNeedAck); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 468 | else if ((byFBOption == AUTO_FB_1) && (wRate >= RATE_18M) && (wRate <= RATE_54M)) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 469 | uDurTime = pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt1[FB_RATE0][wRate-RATE_18M], bNeedAck); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 470 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 471 | break; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 472 | |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 473 | case CTSDUR_BA_F1: /* CTSDuration_ba_f1 */ |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 474 | if ((byFBOption == AUTO_FB_0) && (wRate >= RATE_18M) && (wRate <= RATE_54M)) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 475 | uDurTime = pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt0[FB_RATE1][wRate-RATE_18M], bNeedAck); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 476 | else if ((byFBOption == AUTO_FB_1) && (wRate >= RATE_18M) && (wRate <= RATE_54M)) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 477 | uDurTime = pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt1[FB_RATE1][wRate-RATE_18M], bNeedAck); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 478 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 479 | break; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 480 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 481 | default: |
| 482 | break; |
| 483 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 484 | |
Malcolm Priestley | 96372bd | 2014-08-30 22:25:48 +0100 | [diff] [blame] | 485 | return cpu_to_le16((u16)uDurTime); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 486 | } |
| 487 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 488 | static |
Malcolm Priestley | a479ffc | 2014-08-30 22:25:38 +0100 | [diff] [blame] | 489 | __le16 |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 490 | s_uFillDataHead( |
Malcolm Priestley | cf76dc4 | 2014-08-10 15:46:59 +0100 | [diff] [blame] | 491 | struct vnt_private *pDevice, |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 492 | unsigned char byPktType, |
| 493 | void *pTxDataHead, |
| 494 | unsigned int cbFrameLength, |
| 495 | unsigned int uDMAIdx, |
| 496 | bool bNeedAck, |
| 497 | unsigned int uFragIdx, |
| 498 | unsigned int cbLastFragmentSize, |
| 499 | unsigned int uMACfragNum, |
| 500 | unsigned char byFBOption, |
Malcolm Priestley | 89cf9be | 2014-10-29 17:43:42 +0000 | [diff] [blame] | 501 | unsigned short wCurrentRate, |
| 502 | bool is_pspoll |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 503 | ) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 504 | { |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 505 | |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 506 | if (pTxDataHead == NULL) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 507 | return 0; |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 508 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 509 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 510 | if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) { |
| 511 | if (byFBOption == AUTO_FB_NONE) { |
Malcolm Priestley | 72edb7e | 2014-08-30 22:25:34 +0100 | [diff] [blame] | 512 | struct vnt_tx_datahead_g *buf = pTxDataHead; |
Malcolm Priestley | 429a247 | 2014-08-20 22:30:29 +0100 | [diff] [blame] | 513 | /* Get SignalField, ServiceField & Length */ |
| 514 | vnt_get_phy_field(pDevice, cbFrameLength, wCurrentRate, |
Malcolm Priestley | 72edb7e | 2014-08-30 22:25:34 +0100 | [diff] [blame] | 515 | byPktType, &buf->a); |
Malcolm Priestley | 429a247 | 2014-08-20 22:30:29 +0100 | [diff] [blame] | 516 | |
| 517 | vnt_get_phy_field(pDevice, cbFrameLength, |
| 518 | pDevice->byTopCCKBasicRate, |
Malcolm Priestley | 72edb7e | 2014-08-30 22:25:34 +0100 | [diff] [blame] | 519 | PK_TYPE_11B, &buf->b); |
Malcolm Priestley | 429a247 | 2014-08-20 22:30:29 +0100 | [diff] [blame] | 520 | |
Malcolm Priestley | 89cf9be | 2014-10-29 17:43:42 +0000 | [diff] [blame] | 521 | if (is_pspoll) { |
| 522 | __le16 dur = cpu_to_le16(pDevice->current_aid | BIT(14) | BIT(15)); |
| 523 | |
| 524 | buf->duration_a = dur; |
| 525 | buf->duration_b = dur; |
| 526 | } else { |
| 527 | /* Get Duration and TimeStamp */ |
| 528 | buf->duration_a = |
| 529 | cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_A, cbFrameLength, |
| 530 | byPktType, wCurrentRate, bNeedAck, uFragIdx, |
| 531 | cbLastFragmentSize, uMACfragNum, |
| 532 | byFBOption)); |
| 533 | buf->duration_b = |
| 534 | cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_B, cbFrameLength, |
| 535 | PK_TYPE_11B, pDevice->byTopCCKBasicRate, |
| 536 | bNeedAck, uFragIdx, cbLastFragmentSize, |
| 537 | uMACfragNum, byFBOption)); |
| 538 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 539 | |
Malcolm Priestley | 72edb7e | 2014-08-30 22:25:34 +0100 | [diff] [blame] | 540 | buf->time_stamp_off_a = vnt_time_stamp_off(pDevice, wCurrentRate); |
| 541 | buf->time_stamp_off_b = vnt_time_stamp_off(pDevice, pDevice->byTopCCKBasicRate); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 542 | |
Malcolm Priestley | 72edb7e | 2014-08-30 22:25:34 +0100 | [diff] [blame] | 543 | return buf->duration_a; |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 544 | } else { |
Malcolm Priestley | 2dd7667 | 2014-08-30 22:25:35 +0100 | [diff] [blame] | 545 | /* Auto Fallback */ |
| 546 | struct vnt_tx_datahead_g_fb *buf = pTxDataHead; |
Malcolm Priestley | 429a247 | 2014-08-20 22:30:29 +0100 | [diff] [blame] | 547 | /* Get SignalField, ServiceField & Length */ |
| 548 | vnt_get_phy_field(pDevice, cbFrameLength, wCurrentRate, |
Malcolm Priestley | 2dd7667 | 2014-08-30 22:25:35 +0100 | [diff] [blame] | 549 | byPktType, &buf->a); |
Malcolm Priestley | 429a247 | 2014-08-20 22:30:29 +0100 | [diff] [blame] | 550 | |
| 551 | vnt_get_phy_field(pDevice, cbFrameLength, |
| 552 | pDevice->byTopCCKBasicRate, |
Malcolm Priestley | 2dd7667 | 2014-08-30 22:25:35 +0100 | [diff] [blame] | 553 | PK_TYPE_11B, &buf->b); |
| 554 | /* Get Duration and TimeStamp */ |
| 555 | buf->duration_a = cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_A, cbFrameLength, byPktType, |
| 556 | wCurrentRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption)); |
| 557 | buf->duration_b = cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_B, cbFrameLength, PK_TYPE_11B, |
| 558 | pDevice->byTopCCKBasicRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption)); |
| 559 | buf->duration_a_f0 = cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_A_F0, cbFrameLength, byPktType, |
| 560 | wCurrentRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption)); |
| 561 | buf->duration_a_f1 = cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_A_F1, cbFrameLength, byPktType, |
| 562 | wCurrentRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption)); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 563 | |
Malcolm Priestley | 2dd7667 | 2014-08-30 22:25:35 +0100 | [diff] [blame] | 564 | buf->time_stamp_off_a = vnt_time_stamp_off(pDevice, wCurrentRate); |
| 565 | buf->time_stamp_off_b = vnt_time_stamp_off(pDevice, pDevice->byTopCCKBasicRate); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 566 | |
Malcolm Priestley | 2dd7667 | 2014-08-30 22:25:35 +0100 | [diff] [blame] | 567 | return buf->duration_a; |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 568 | } /* if (byFBOption == AUTO_FB_NONE) */ |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 569 | } else if (byPktType == PK_TYPE_11A) { |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 570 | if ((byFBOption != AUTO_FB_NONE)) { |
Malcolm Priestley | 9c62c7a | 2014-08-30 22:25:37 +0100 | [diff] [blame] | 571 | /* Auto Fallback */ |
| 572 | struct vnt_tx_datahead_a_fb *buf = pTxDataHead; |
Malcolm Priestley | 429a247 | 2014-08-20 22:30:29 +0100 | [diff] [blame] | 573 | /* Get SignalField, ServiceField & Length */ |
| 574 | vnt_get_phy_field(pDevice, cbFrameLength, wCurrentRate, |
Malcolm Priestley | 9c62c7a | 2014-08-30 22:25:37 +0100 | [diff] [blame] | 575 | byPktType, &buf->a); |
Malcolm Priestley | 429a247 | 2014-08-20 22:30:29 +0100 | [diff] [blame] | 576 | |
Malcolm Priestley | 9c62c7a | 2014-08-30 22:25:37 +0100 | [diff] [blame] | 577 | /* Get Duration and TimeStampOff */ |
| 578 | buf->duration = cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_A, cbFrameLength, byPktType, |
| 579 | wCurrentRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption)); |
| 580 | buf->duration_f0 = cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_A_F0, cbFrameLength, byPktType, |
| 581 | wCurrentRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption)); |
| 582 | buf->duration_f1 = cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_A_F1, cbFrameLength, byPktType, |
| 583 | wCurrentRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption)); |
| 584 | buf->time_stamp_off = vnt_time_stamp_off(pDevice, wCurrentRate); |
| 585 | return buf->duration; |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 586 | } else { |
Malcolm Priestley | 9ce842a | 2014-08-30 22:25:36 +0100 | [diff] [blame] | 587 | struct vnt_tx_datahead_ab *buf = pTxDataHead; |
Malcolm Priestley | 429a247 | 2014-08-20 22:30:29 +0100 | [diff] [blame] | 588 | /* Get SignalField, ServiceField & Length */ |
| 589 | vnt_get_phy_field(pDevice, cbFrameLength, wCurrentRate, |
Malcolm Priestley | 9ce842a | 2014-08-30 22:25:36 +0100 | [diff] [blame] | 590 | byPktType, &buf->ab); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 591 | |
Malcolm Priestley | 89cf9be | 2014-10-29 17:43:42 +0000 | [diff] [blame] | 592 | if (is_pspoll) { |
| 593 | __le16 dur = cpu_to_le16(pDevice->current_aid | BIT(14) | BIT(15)); |
| 594 | |
| 595 | buf->duration = dur; |
| 596 | } else { |
| 597 | /* Get Duration and TimeStampOff */ |
| 598 | buf->duration = |
| 599 | cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_A, cbFrameLength, byPktType, |
Malcolm Priestley | 9ce842a | 2014-08-30 22:25:36 +0100 | [diff] [blame] | 600 | wCurrentRate, bNeedAck, uFragIdx, |
| 601 | cbLastFragmentSize, uMACfragNum, |
| 602 | byFBOption)); |
Malcolm Priestley | 89cf9be | 2014-10-29 17:43:42 +0000 | [diff] [blame] | 603 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 604 | |
Malcolm Priestley | 9ce842a | 2014-08-30 22:25:36 +0100 | [diff] [blame] | 605 | buf->time_stamp_off = vnt_time_stamp_off(pDevice, wCurrentRate); |
| 606 | return buf->duration; |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 607 | } |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 608 | } else { |
Malcolm Priestley | 9ce842a | 2014-08-30 22:25:36 +0100 | [diff] [blame] | 609 | struct vnt_tx_datahead_ab *buf = pTxDataHead; |
Malcolm Priestley | 429a247 | 2014-08-20 22:30:29 +0100 | [diff] [blame] | 610 | /* Get SignalField, ServiceField & Length */ |
| 611 | vnt_get_phy_field(pDevice, cbFrameLength, wCurrentRate, |
Malcolm Priestley | 9ce842a | 2014-08-30 22:25:36 +0100 | [diff] [blame] | 612 | byPktType, &buf->ab); |
Malcolm Priestley | 89cf9be | 2014-10-29 17:43:42 +0000 | [diff] [blame] | 613 | |
| 614 | if (is_pspoll) { |
| 615 | __le16 dur = cpu_to_le16(pDevice->current_aid | BIT(14) | BIT(15)); |
| 616 | |
| 617 | buf->duration = dur; |
| 618 | } else { |
| 619 | /* Get Duration and TimeStampOff */ |
| 620 | buf->duration = |
| 621 | cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_B, cbFrameLength, byPktType, |
Malcolm Priestley | 9ce842a | 2014-08-30 22:25:36 +0100 | [diff] [blame] | 622 | wCurrentRate, bNeedAck, uFragIdx, |
| 623 | cbLastFragmentSize, uMACfragNum, |
| 624 | byFBOption)); |
Malcolm Priestley | 89cf9be | 2014-10-29 17:43:42 +0000 | [diff] [blame] | 625 | } |
| 626 | |
Malcolm Priestley | 9ce842a | 2014-08-30 22:25:36 +0100 | [diff] [blame] | 627 | buf->time_stamp_off = vnt_time_stamp_off(pDevice, wCurrentRate); |
| 628 | return buf->duration; |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 629 | } |
| 630 | return 0; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 631 | } |
| 632 | |
Malcolm Priestley | 89cf9be | 2014-10-29 17:43:42 +0000 | [diff] [blame] | 633 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 634 | static |
Charles Clément | 6b35b7b | 2010-05-07 12:30:19 -0700 | [diff] [blame] | 635 | void |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 636 | s_vFillRTSHead( |
Malcolm Priestley | cf76dc4 | 2014-08-10 15:46:59 +0100 | [diff] [blame] | 637 | struct vnt_private *pDevice, |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 638 | unsigned char byPktType, |
| 639 | void *pvRTS, |
| 640 | unsigned int cbFrameLength, |
| 641 | bool bNeedAck, |
| 642 | bool bDisCRC, |
Malcolm Priestley | 7c0496d | 2014-10-29 17:43:41 +0000 | [diff] [blame] | 643 | struct ieee80211_hdr *hdr, |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 644 | unsigned short wCurrentRate, |
| 645 | unsigned char byFBOption |
| 646 | ) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 647 | { |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 648 | unsigned int uRTSFrameLen = 20; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 649 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 650 | if (pvRTS == NULL) |
| 651 | return; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 652 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 653 | if (bDisCRC) { |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 654 | /* When CRCDIS bit is on, H/W forgot to generate FCS for RTS frame, |
| 655 | in this case we need to decrease its length by 4. */ |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 656 | uRTSFrameLen -= 4; |
| 657 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 658 | |
Carlos E. Garcia | 69e98df | 2015-04-24 09:40:42 -0400 | [diff] [blame] | 659 | /* Note: So far RTSHead doesn't appear in ATIM & Beacom DMA, so we don't need to take them into account. |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 660 | Otherwise, we need to modify codes for them. */ |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 661 | if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) { |
| 662 | if (byFBOption == AUTO_FB_NONE) { |
Malcolm Priestley | 17434f0 | 2014-08-30 22:25:41 +0100 | [diff] [blame] | 663 | struct vnt_rts_g *buf = pvRTS; |
Malcolm Priestley | 429a247 | 2014-08-20 22:30:29 +0100 | [diff] [blame] | 664 | /* Get SignalField, ServiceField & Length */ |
| 665 | vnt_get_phy_field(pDevice, uRTSFrameLen, |
| 666 | pDevice->byTopCCKBasicRate, |
Malcolm Priestley | 17434f0 | 2014-08-30 22:25:41 +0100 | [diff] [blame] | 667 | PK_TYPE_11B, &buf->b); |
Malcolm Priestley | 429a247 | 2014-08-20 22:30:29 +0100 | [diff] [blame] | 668 | |
| 669 | vnt_get_phy_field(pDevice, uRTSFrameLen, |
| 670 | pDevice->byTopOFDMBasicRate, |
Malcolm Priestley | 17434f0 | 2014-08-30 22:25:41 +0100 | [diff] [blame] | 671 | byPktType, &buf->a); |
| 672 | /* Get Duration */ |
| 673 | buf->duration_bb = |
Malcolm Priestley | 96372bd | 2014-08-30 22:25:48 +0100 | [diff] [blame] | 674 | s_uGetRTSCTSDuration(pDevice, RTSDUR_BB, |
| 675 | cbFrameLength, PK_TYPE_11B, |
| 676 | pDevice->byTopCCKBasicRate, |
| 677 | bNeedAck, byFBOption); |
Malcolm Priestley | 17434f0 | 2014-08-30 22:25:41 +0100 | [diff] [blame] | 678 | buf->duration_aa = |
Malcolm Priestley | 96372bd | 2014-08-30 22:25:48 +0100 | [diff] [blame] | 679 | s_uGetRTSCTSDuration(pDevice, RTSDUR_AA, |
| 680 | cbFrameLength, byPktType, |
| 681 | wCurrentRate, bNeedAck, |
| 682 | byFBOption); |
Malcolm Priestley | 17434f0 | 2014-08-30 22:25:41 +0100 | [diff] [blame] | 683 | buf->duration_ba = |
Malcolm Priestley | 96372bd | 2014-08-30 22:25:48 +0100 | [diff] [blame] | 684 | s_uGetRTSCTSDuration(pDevice, RTSDUR_BA, |
| 685 | cbFrameLength, byPktType, |
| 686 | wCurrentRate, bNeedAck, |
| 687 | byFBOption); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 688 | |
Malcolm Priestley | 17434f0 | 2014-08-30 22:25:41 +0100 | [diff] [blame] | 689 | buf->data.duration = buf->duration_aa; |
Malcolm Priestley | 52c4130 | 2014-08-30 22:25:39 +0100 | [diff] [blame] | 690 | /* Get RTS Frame body */ |
Malcolm Priestley | 17434f0 | 2014-08-30 22:25:41 +0100 | [diff] [blame] | 691 | buf->data.frame_control = |
Malcolm Priestley | 52c4130 | 2014-08-30 22:25:39 +0100 | [diff] [blame] | 692 | cpu_to_le16(IEEE80211_FTYPE_CTL | |
| 693 | IEEE80211_STYPE_RTS); |
| 694 | |
Malcolm Priestley | 7c0496d | 2014-10-29 17:43:41 +0000 | [diff] [blame] | 695 | ether_addr_copy(buf->data.ra, hdr->addr1); |
| 696 | ether_addr_copy(buf->data.ta, hdr->addr2); |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 697 | } else { |
Malcolm Priestley | 9587b09 | 2014-08-30 22:25:42 +0100 | [diff] [blame] | 698 | struct vnt_rts_g_fb *buf = pvRTS; |
Malcolm Priestley | 429a247 | 2014-08-20 22:30:29 +0100 | [diff] [blame] | 699 | /* Get SignalField, ServiceField & Length */ |
| 700 | vnt_get_phy_field(pDevice, uRTSFrameLen, |
| 701 | pDevice->byTopCCKBasicRate, |
Malcolm Priestley | 9587b09 | 2014-08-30 22:25:42 +0100 | [diff] [blame] | 702 | PK_TYPE_11B, &buf->b); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 703 | |
Malcolm Priestley | 429a247 | 2014-08-20 22:30:29 +0100 | [diff] [blame] | 704 | vnt_get_phy_field(pDevice, uRTSFrameLen, |
| 705 | pDevice->byTopOFDMBasicRate, |
Malcolm Priestley | 9587b09 | 2014-08-30 22:25:42 +0100 | [diff] [blame] | 706 | byPktType, &buf->a); |
| 707 | /* Get Duration */ |
| 708 | buf->duration_bb = |
Malcolm Priestley | 96372bd | 2014-08-30 22:25:48 +0100 | [diff] [blame] | 709 | s_uGetRTSCTSDuration(pDevice, RTSDUR_BB, |
| 710 | cbFrameLength, PK_TYPE_11B, |
| 711 | pDevice->byTopCCKBasicRate, |
| 712 | bNeedAck, byFBOption); |
Malcolm Priestley | 9587b09 | 2014-08-30 22:25:42 +0100 | [diff] [blame] | 713 | buf->duration_aa = |
Malcolm Priestley | 96372bd | 2014-08-30 22:25:48 +0100 | [diff] [blame] | 714 | s_uGetRTSCTSDuration(pDevice, RTSDUR_AA, |
| 715 | cbFrameLength, byPktType, |
| 716 | wCurrentRate, bNeedAck, |
| 717 | byFBOption); |
Malcolm Priestley | 9587b09 | 2014-08-30 22:25:42 +0100 | [diff] [blame] | 718 | buf->duration_ba = |
Malcolm Priestley | 96372bd | 2014-08-30 22:25:48 +0100 | [diff] [blame] | 719 | s_uGetRTSCTSDuration(pDevice, RTSDUR_BA, |
| 720 | cbFrameLength, byPktType, |
| 721 | wCurrentRate, bNeedAck, |
| 722 | byFBOption); |
Malcolm Priestley | 9587b09 | 2014-08-30 22:25:42 +0100 | [diff] [blame] | 723 | buf->rts_duration_ba_f0 = |
Malcolm Priestley | 96372bd | 2014-08-30 22:25:48 +0100 | [diff] [blame] | 724 | s_uGetRTSCTSDuration(pDevice, RTSDUR_BA_F0, |
| 725 | cbFrameLength, byPktType, |
| 726 | wCurrentRate, bNeedAck, |
| 727 | byFBOption); |
Malcolm Priestley | 9587b09 | 2014-08-30 22:25:42 +0100 | [diff] [blame] | 728 | buf->rts_duration_aa_f0 = |
Malcolm Priestley | 96372bd | 2014-08-30 22:25:48 +0100 | [diff] [blame] | 729 | s_uGetRTSCTSDuration(pDevice, RTSDUR_AA_F0, |
| 730 | cbFrameLength, byPktType, |
| 731 | wCurrentRate, bNeedAck, |
| 732 | byFBOption); |
Malcolm Priestley | 9587b09 | 2014-08-30 22:25:42 +0100 | [diff] [blame] | 733 | buf->rts_duration_ba_f1 = |
Malcolm Priestley | 96372bd | 2014-08-30 22:25:48 +0100 | [diff] [blame] | 734 | s_uGetRTSCTSDuration(pDevice, RTSDUR_BA_F1, |
| 735 | cbFrameLength, byPktType, |
| 736 | wCurrentRate, bNeedAck, |
| 737 | byFBOption); |
Malcolm Priestley | 9587b09 | 2014-08-30 22:25:42 +0100 | [diff] [blame] | 738 | buf->rts_duration_aa_f1 = |
Malcolm Priestley | 96372bd | 2014-08-30 22:25:48 +0100 | [diff] [blame] | 739 | s_uGetRTSCTSDuration(pDevice, RTSDUR_AA_F1, |
| 740 | cbFrameLength, byPktType, |
| 741 | wCurrentRate, bNeedAck, |
| 742 | byFBOption); |
Malcolm Priestley | 9587b09 | 2014-08-30 22:25:42 +0100 | [diff] [blame] | 743 | buf->data.duration = buf->duration_aa; |
Malcolm Priestley | 52c4130 | 2014-08-30 22:25:39 +0100 | [diff] [blame] | 744 | /* Get RTS Frame body */ |
Malcolm Priestley | 9587b09 | 2014-08-30 22:25:42 +0100 | [diff] [blame] | 745 | buf->data.frame_control = |
Malcolm Priestley | 52c4130 | 2014-08-30 22:25:39 +0100 | [diff] [blame] | 746 | cpu_to_le16(IEEE80211_FTYPE_CTL | |
| 747 | IEEE80211_STYPE_RTS); |
| 748 | |
Malcolm Priestley | 7c0496d | 2014-10-29 17:43:41 +0000 | [diff] [blame] | 749 | ether_addr_copy(buf->data.ra, hdr->addr1); |
| 750 | ether_addr_copy(buf->data.ta, hdr->addr2); |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 751 | } /* if (byFBOption == AUTO_FB_NONE) */ |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 752 | } else if (byPktType == PK_TYPE_11A) { |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 753 | if (byFBOption == AUTO_FB_NONE) { |
Malcolm Priestley | e21eb1c | 2014-08-30 22:25:43 +0100 | [diff] [blame] | 754 | struct vnt_rts_ab *buf = pvRTS; |
Malcolm Priestley | 429a247 | 2014-08-20 22:30:29 +0100 | [diff] [blame] | 755 | /* Get SignalField, ServiceField & Length */ |
| 756 | vnt_get_phy_field(pDevice, uRTSFrameLen, |
| 757 | pDevice->byTopOFDMBasicRate, |
Malcolm Priestley | e21eb1c | 2014-08-30 22:25:43 +0100 | [diff] [blame] | 758 | byPktType, &buf->ab); |
| 759 | /* Get Duration */ |
| 760 | buf->duration = |
Malcolm Priestley | 96372bd | 2014-08-30 22:25:48 +0100 | [diff] [blame] | 761 | s_uGetRTSCTSDuration(pDevice, RTSDUR_AA, |
| 762 | cbFrameLength, byPktType, |
| 763 | wCurrentRate, bNeedAck, |
| 764 | byFBOption); |
Malcolm Priestley | e21eb1c | 2014-08-30 22:25:43 +0100 | [diff] [blame] | 765 | buf->data.duration = buf->duration; |
Malcolm Priestley | 52c4130 | 2014-08-30 22:25:39 +0100 | [diff] [blame] | 766 | /* Get RTS Frame body */ |
Malcolm Priestley | e21eb1c | 2014-08-30 22:25:43 +0100 | [diff] [blame] | 767 | buf->data.frame_control = |
Malcolm Priestley | 52c4130 | 2014-08-30 22:25:39 +0100 | [diff] [blame] | 768 | cpu_to_le16(IEEE80211_FTYPE_CTL | |
| 769 | IEEE80211_STYPE_RTS); |
| 770 | |
Malcolm Priestley | 7c0496d | 2014-10-29 17:43:41 +0000 | [diff] [blame] | 771 | ether_addr_copy(buf->data.ra, hdr->addr1); |
| 772 | ether_addr_copy(buf->data.ta, hdr->addr2); |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 773 | } else { |
Malcolm Priestley | 8e44804 | 2014-08-30 22:25:44 +0100 | [diff] [blame] | 774 | struct vnt_rts_a_fb *buf = pvRTS; |
Malcolm Priestley | 429a247 | 2014-08-20 22:30:29 +0100 | [diff] [blame] | 775 | /* Get SignalField, ServiceField & Length */ |
| 776 | vnt_get_phy_field(pDevice, uRTSFrameLen, |
| 777 | pDevice->byTopOFDMBasicRate, |
Malcolm Priestley | 8e44804 | 2014-08-30 22:25:44 +0100 | [diff] [blame] | 778 | byPktType, &buf->a); |
| 779 | /* Get Duration */ |
| 780 | buf->duration = |
Malcolm Priestley | 96372bd | 2014-08-30 22:25:48 +0100 | [diff] [blame] | 781 | s_uGetRTSCTSDuration(pDevice, RTSDUR_AA, |
| 782 | cbFrameLength, byPktType, |
| 783 | wCurrentRate, bNeedAck, |
| 784 | byFBOption); |
Malcolm Priestley | 8e44804 | 2014-08-30 22:25:44 +0100 | [diff] [blame] | 785 | buf->rts_duration_f0 = |
Malcolm Priestley | 96372bd | 2014-08-30 22:25:48 +0100 | [diff] [blame] | 786 | s_uGetRTSCTSDuration(pDevice, RTSDUR_AA_F0, |
| 787 | cbFrameLength, byPktType, |
| 788 | wCurrentRate, bNeedAck, |
| 789 | byFBOption); |
Malcolm Priestley | 8e44804 | 2014-08-30 22:25:44 +0100 | [diff] [blame] | 790 | buf->rts_duration_f1 = |
Malcolm Priestley | 96372bd | 2014-08-30 22:25:48 +0100 | [diff] [blame] | 791 | s_uGetRTSCTSDuration(pDevice, RTSDUR_AA_F1, |
| 792 | cbFrameLength, byPktType, |
| 793 | wCurrentRate, bNeedAck, |
| 794 | byFBOption); |
Malcolm Priestley | 8e44804 | 2014-08-30 22:25:44 +0100 | [diff] [blame] | 795 | buf->data.duration = buf->duration; |
Malcolm Priestley | 52c4130 | 2014-08-30 22:25:39 +0100 | [diff] [blame] | 796 | /* Get RTS Frame body */ |
Malcolm Priestley | 8e44804 | 2014-08-30 22:25:44 +0100 | [diff] [blame] | 797 | buf->data.frame_control = |
Malcolm Priestley | 52c4130 | 2014-08-30 22:25:39 +0100 | [diff] [blame] | 798 | cpu_to_le16(IEEE80211_FTYPE_CTL | |
| 799 | IEEE80211_STYPE_RTS); |
| 800 | |
Malcolm Priestley | 7c0496d | 2014-10-29 17:43:41 +0000 | [diff] [blame] | 801 | ether_addr_copy(buf->data.ra, hdr->addr1); |
| 802 | ether_addr_copy(buf->data.ta, hdr->addr2); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 803 | } |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 804 | } else if (byPktType == PK_TYPE_11B) { |
Malcolm Priestley | e21eb1c | 2014-08-30 22:25:43 +0100 | [diff] [blame] | 805 | struct vnt_rts_ab *buf = pvRTS; |
Malcolm Priestley | 429a247 | 2014-08-20 22:30:29 +0100 | [diff] [blame] | 806 | /* Get SignalField, ServiceField & Length */ |
| 807 | vnt_get_phy_field(pDevice, uRTSFrameLen, |
| 808 | pDevice->byTopCCKBasicRate, |
Malcolm Priestley | e21eb1c | 2014-08-30 22:25:43 +0100 | [diff] [blame] | 809 | PK_TYPE_11B, &buf->ab); |
| 810 | /* Get Duration */ |
| 811 | buf->duration = |
Malcolm Priestley | 96372bd | 2014-08-30 22:25:48 +0100 | [diff] [blame] | 812 | s_uGetRTSCTSDuration(pDevice, RTSDUR_BB, cbFrameLength, |
| 813 | byPktType, wCurrentRate, bNeedAck, |
| 814 | byFBOption); |
| 815 | |
Malcolm Priestley | e21eb1c | 2014-08-30 22:25:43 +0100 | [diff] [blame] | 816 | buf->data.duration = buf->duration; |
Malcolm Priestley | 52c4130 | 2014-08-30 22:25:39 +0100 | [diff] [blame] | 817 | /* Get RTS Frame body */ |
Malcolm Priestley | e21eb1c | 2014-08-30 22:25:43 +0100 | [diff] [blame] | 818 | buf->data.frame_control = |
Malcolm Priestley | 52c4130 | 2014-08-30 22:25:39 +0100 | [diff] [blame] | 819 | cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_RTS); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 820 | |
Malcolm Priestley | 7c0496d | 2014-10-29 17:43:41 +0000 | [diff] [blame] | 821 | ether_addr_copy(buf->data.ra, hdr->addr1); |
| 822 | ether_addr_copy(buf->data.ta, hdr->addr2); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 823 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 824 | } |
| 825 | |
| 826 | static |
Charles Clément | 6b35b7b | 2010-05-07 12:30:19 -0700 | [diff] [blame] | 827 | void |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 828 | s_vFillCTSHead( |
Malcolm Priestley | cf76dc4 | 2014-08-10 15:46:59 +0100 | [diff] [blame] | 829 | struct vnt_private *pDevice, |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 830 | unsigned int uDMAIdx, |
| 831 | unsigned char byPktType, |
| 832 | void *pvCTS, |
| 833 | unsigned int cbFrameLength, |
| 834 | bool bNeedAck, |
| 835 | bool bDisCRC, |
| 836 | unsigned short wCurrentRate, |
| 837 | unsigned char byFBOption |
| 838 | ) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 839 | { |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 840 | unsigned int uCTSFrameLen = 14; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 841 | |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 842 | if (pvCTS == NULL) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 843 | return; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 844 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 845 | if (bDisCRC) { |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 846 | /* When CRCDIS bit is on, H/W forgot to generate FCS for CTS frame, |
| 847 | in this case we need to decrease its length by 4. */ |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 848 | uCTSFrameLen -= 4; |
| 849 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 850 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 851 | if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) { |
| 852 | if (byFBOption != AUTO_FB_NONE && uDMAIdx != TYPE_ATIMDMA && uDMAIdx != TYPE_BEACONDMA) { |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 853 | /* Auto Fall back */ |
Malcolm Priestley | db1afd1 | 2014-08-30 22:25:46 +0100 | [diff] [blame] | 854 | struct vnt_cts_fb *buf = pvCTS; |
Malcolm Priestley | 429a247 | 2014-08-20 22:30:29 +0100 | [diff] [blame] | 855 | /* Get SignalField, ServiceField & Length */ |
| 856 | vnt_get_phy_field(pDevice, uCTSFrameLen, |
| 857 | pDevice->byTopCCKBasicRate, |
Malcolm Priestley | db1afd1 | 2014-08-30 22:25:46 +0100 | [diff] [blame] | 858 | PK_TYPE_11B, &buf->b); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 859 | |
Malcolm Priestley | 96372bd | 2014-08-30 22:25:48 +0100 | [diff] [blame] | 860 | buf->duration_ba = |
| 861 | s_uGetRTSCTSDuration(pDevice, CTSDUR_BA, |
| 862 | cbFrameLength, byPktType, |
| 863 | wCurrentRate, bNeedAck, |
| 864 | byFBOption); |
| 865 | |
Malcolm Priestley | db1afd1 | 2014-08-30 22:25:46 +0100 | [diff] [blame] | 866 | /* Get CTSDuration_ba_f0 */ |
Malcolm Priestley | 96372bd | 2014-08-30 22:25:48 +0100 | [diff] [blame] | 867 | buf->cts_duration_ba_f0 = |
| 868 | s_uGetRTSCTSDuration(pDevice, CTSDUR_BA_F0, |
| 869 | cbFrameLength, byPktType, |
| 870 | wCurrentRate, bNeedAck, |
| 871 | byFBOption); |
Malcolm Priestley | db1afd1 | 2014-08-30 22:25:46 +0100 | [diff] [blame] | 872 | |
Malcolm Priestley | 96372bd | 2014-08-30 22:25:48 +0100 | [diff] [blame] | 873 | /* Get CTSDuration_ba_f1 */ |
| 874 | buf->cts_duration_ba_f1 = |
| 875 | s_uGetRTSCTSDuration(pDevice, CTSDUR_BA_F1, |
| 876 | cbFrameLength, byPktType, |
| 877 | wCurrentRate, bNeedAck, |
| 878 | byFBOption); |
Malcolm Priestley | 0864db1 | 2014-08-30 22:25:40 +0100 | [diff] [blame] | 879 | |
Malcolm Priestley | db1afd1 | 2014-08-30 22:25:46 +0100 | [diff] [blame] | 880 | /* Get CTS Frame body */ |
| 881 | buf->data.duration = buf->duration_ba; |
| 882 | |
| 883 | buf->data.frame_control = |
Malcolm Priestley | 0864db1 | 2014-08-30 22:25:40 +0100 | [diff] [blame] | 884 | cpu_to_le16(IEEE80211_FTYPE_CTL | |
| 885 | IEEE80211_STYPE_CTS); |
| 886 | |
Malcolm Priestley | db1afd1 | 2014-08-30 22:25:46 +0100 | [diff] [blame] | 887 | buf->reserved2 = 0x0; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 888 | |
Aya Mahfouz | 2359b5c | 2014-10-11 02:42:45 +0200 | [diff] [blame] | 889 | ether_addr_copy(buf->data.ra, |
| 890 | pDevice->abyCurrentNetAddr); |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 891 | } else { /* if (byFBOption != AUTO_FB_NONE && uDMAIdx != TYPE_ATIMDMA && uDMAIdx != TYPE_BEACONDMA) */ |
Malcolm Priestley | f5172b0 | 2014-08-30 22:25:45 +0100 | [diff] [blame] | 892 | struct vnt_cts *buf = pvCTS; |
Malcolm Priestley | 429a247 | 2014-08-20 22:30:29 +0100 | [diff] [blame] | 893 | /* Get SignalField, ServiceField & Length */ |
| 894 | vnt_get_phy_field(pDevice, uCTSFrameLen, |
| 895 | pDevice->byTopCCKBasicRate, |
Malcolm Priestley | f5172b0 | 2014-08-30 22:25:45 +0100 | [diff] [blame] | 896 | PK_TYPE_11B, &buf->b); |
Malcolm Priestley | 429a247 | 2014-08-20 22:30:29 +0100 | [diff] [blame] | 897 | |
Malcolm Priestley | f5172b0 | 2014-08-30 22:25:45 +0100 | [diff] [blame] | 898 | /* Get CTSDuration_ba */ |
| 899 | buf->duration_ba = |
Malcolm Priestley | 96372bd | 2014-08-30 22:25:48 +0100 | [diff] [blame] | 900 | s_uGetRTSCTSDuration(pDevice, CTSDUR_BA, |
| 901 | cbFrameLength, byPktType, |
| 902 | wCurrentRate, bNeedAck, |
| 903 | byFBOption); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 904 | |
Malcolm Priestley | f5172b0 | 2014-08-30 22:25:45 +0100 | [diff] [blame] | 905 | /* Get CTS Frame body */ |
| 906 | buf->data.duration = buf->duration_ba; |
Malcolm Priestley | 0864db1 | 2014-08-30 22:25:40 +0100 | [diff] [blame] | 907 | |
Malcolm Priestley | f5172b0 | 2014-08-30 22:25:45 +0100 | [diff] [blame] | 908 | buf->data.frame_control = |
Malcolm Priestley | 0864db1 | 2014-08-30 22:25:40 +0100 | [diff] [blame] | 909 | cpu_to_le16(IEEE80211_FTYPE_CTL | |
| 910 | IEEE80211_STYPE_CTS); |
| 911 | |
Malcolm Priestley | f5172b0 | 2014-08-30 22:25:45 +0100 | [diff] [blame] | 912 | buf->reserved2 = 0x0; |
Aya Mahfouz | 2359b5c | 2014-10-11 02:42:45 +0200 | [diff] [blame] | 913 | ether_addr_copy(buf->data.ra, |
| 914 | pDevice->abyCurrentNetAddr); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 915 | } |
| 916 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 917 | } |
| 918 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 919 | /*+ |
| 920 | * |
| 921 | * Description: |
| 922 | * Generate FIFO control for MAC & Baseband controller |
| 923 | * |
| 924 | * Parameters: |
| 925 | * In: |
Gilles Espinasse | f77f13e | 2010-03-29 15:41:47 +0200 | [diff] [blame] | 926 | * pDevice - Pointer to adapter |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 927 | * pTxDataHead - Transmit Data Buffer |
| 928 | * pTxBufHead - pTxBufHead |
| 929 | * pvRrvTime - pvRrvTime |
| 930 | * pvRTS - RTS Buffer |
| 931 | * pCTS - CTS Buffer |
| 932 | * cbFrameSize - Transmit Data Length (Hdr+Payload+FCS) |
| 933 | * bNeedACK - If need ACK |
| 934 | * uDescIdx - Desc Index |
| 935 | * Out: |
| 936 | * none |
| 937 | * |
| 938 | * Return Value: none |
| 939 | * |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 940 | - |
| 941 | * unsigned int cbFrameSize, Hdr+Payload+FCS */ |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 942 | static |
Charles Clément | 6b35b7b | 2010-05-07 12:30:19 -0700 | [diff] [blame] | 943 | void |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 944 | s_vGenerateTxParameter( |
Malcolm Priestley | cf76dc4 | 2014-08-10 15:46:59 +0100 | [diff] [blame] | 945 | struct vnt_private *pDevice, |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 946 | unsigned char byPktType, |
Malcolm Priestley | df18480 | 2015-04-01 22:32:51 +0100 | [diff] [blame] | 947 | struct vnt_tx_fifo_head *tx_buffer_head, |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 948 | void *pvRrvTime, |
| 949 | void *pvRTS, |
| 950 | void *pvCTS, |
| 951 | unsigned int cbFrameSize, |
| 952 | bool bNeedACK, |
| 953 | unsigned int uDMAIdx, |
Malcolm Priestley | cfd9f0d | 2014-10-29 17:43:39 +0000 | [diff] [blame] | 954 | void *psEthHeader, |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 955 | unsigned short wCurrentRate |
| 956 | ) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 957 | { |
Malcolm Priestley | df18480 | 2015-04-01 22:32:51 +0100 | [diff] [blame] | 958 | u16 fifo_ctl = le16_to_cpu(tx_buffer_head->fifo_ctl); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 959 | bool bDisCRC = false; |
| 960 | unsigned char byFBOption = AUTO_FB_NONE; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 961 | |
Malcolm Priestley | df18480 | 2015-04-01 22:32:51 +0100 | [diff] [blame] | 962 | tx_buffer_head->current_rate = cpu_to_le16(wCurrentRate); |
Guillaume Clement | 6b71127 | 2014-07-25 01:06:16 +0200 | [diff] [blame] | 963 | |
Malcolm Priestley | df18480 | 2015-04-01 22:32:51 +0100 | [diff] [blame] | 964 | if (fifo_ctl & FIFOCTL_CRCDIS) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 965 | bDisCRC = true; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 966 | |
Malcolm Priestley | df18480 | 2015-04-01 22:32:51 +0100 | [diff] [blame] | 967 | if (fifo_ctl & FIFOCTL_AUTO_FB_0) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 968 | byFBOption = AUTO_FB_0; |
Malcolm Priestley | df18480 | 2015-04-01 22:32:51 +0100 | [diff] [blame] | 969 | else if (fifo_ctl & FIFOCTL_AUTO_FB_1) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 970 | byFBOption = AUTO_FB_1; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 971 | |
Malcolm Priestley | c00a378 | 2014-08-30 22:25:32 +0100 | [diff] [blame] | 972 | if (!pvRrvTime) |
| 973 | return; |
| 974 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 975 | if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) { |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 976 | if (pvRTS != NULL) { /* RTS_need |
| 977 | Fill RsvTime */ |
Malcolm Priestley | c00a378 | 2014-08-30 22:25:32 +0100 | [diff] [blame] | 978 | struct vnt_rrv_time_rts *buf = pvRrvTime; |
Guillaume Clement | 6b71127 | 2014-07-25 01:06:16 +0200 | [diff] [blame] | 979 | |
Malcolm Priestley | c00a378 | 2014-08-30 22:25:32 +0100 | [diff] [blame] | 980 | buf->rts_rrv_time_aa = s_uGetRTSCTSRsvTime(pDevice, 2, byPktType, cbFrameSize, wCurrentRate); |
| 981 | buf->rts_rrv_time_ba = s_uGetRTSCTSRsvTime(pDevice, 1, byPktType, cbFrameSize, wCurrentRate); |
| 982 | buf->rts_rrv_time_bb = s_uGetRTSCTSRsvTime(pDevice, 0, byPktType, cbFrameSize, wCurrentRate); |
| 983 | buf->rrv_time_a = vnt_rxtx_rsvtime_le16(pDevice, byPktType, cbFrameSize, wCurrentRate, bNeedACK); |
| 984 | buf->rrv_time_b = vnt_rxtx_rsvtime_le16(pDevice, PK_TYPE_11B, cbFrameSize, pDevice->byTopCCKBasicRate, bNeedACK); |
| 985 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 986 | s_vFillRTSHead(pDevice, byPktType, pvRTS, cbFrameSize, bNeedACK, bDisCRC, psEthHeader, wCurrentRate, byFBOption); |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 987 | } else {/* RTS_needless, PCF mode */ |
Malcolm Priestley | c00a378 | 2014-08-30 22:25:32 +0100 | [diff] [blame] | 988 | struct vnt_rrv_time_cts *buf = pvRrvTime; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 989 | |
Malcolm Priestley | c00a378 | 2014-08-30 22:25:32 +0100 | [diff] [blame] | 990 | buf->rrv_time_a = vnt_rxtx_rsvtime_le16(pDevice, byPktType, cbFrameSize, wCurrentRate, bNeedACK); |
| 991 | buf->rrv_time_b = vnt_rxtx_rsvtime_le16(pDevice, PK_TYPE_11B, cbFrameSize, pDevice->byTopCCKBasicRate, bNeedACK); |
| 992 | buf->cts_rrv_time_ba = s_uGetRTSCTSRsvTime(pDevice, 3, byPktType, cbFrameSize, wCurrentRate); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 993 | |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 994 | /* Fill CTS */ |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 995 | s_vFillCTSHead(pDevice, uDMAIdx, byPktType, pvCTS, cbFrameSize, bNeedACK, bDisCRC, wCurrentRate, byFBOption); |
| 996 | } |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 997 | } else if (byPktType == PK_TYPE_11A) { |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 998 | if (pvRTS != NULL) {/* RTS_need, non PCF mode */ |
Malcolm Priestley | c00a378 | 2014-08-30 22:25:32 +0100 | [diff] [blame] | 999 | struct vnt_rrv_time_ab *buf = pvRrvTime; |
Guillaume Clement | 6b71127 | 2014-07-25 01:06:16 +0200 | [diff] [blame] | 1000 | |
Malcolm Priestley | c00a378 | 2014-08-30 22:25:32 +0100 | [diff] [blame] | 1001 | buf->rts_rrv_time = s_uGetRTSCTSRsvTime(pDevice, 2, byPktType, cbFrameSize, wCurrentRate); |
| 1002 | buf->rrv_time = vnt_rxtx_rsvtime_le16(pDevice, byPktType, cbFrameSize, wCurrentRate, bNeedACK); |
| 1003 | |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 1004 | /* Fill RTS */ |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1005 | s_vFillRTSHead(pDevice, byPktType, pvRTS, cbFrameSize, bNeedACK, bDisCRC, psEthHeader, wCurrentRate, byFBOption); |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 1006 | } else if (pvRTS == NULL) {/* RTS_needless, non PCF mode */ |
Malcolm Priestley | c00a378 | 2014-08-30 22:25:32 +0100 | [diff] [blame] | 1007 | struct vnt_rrv_time_ab *buf = pvRrvTime; |
Guillaume Clement | 6b71127 | 2014-07-25 01:06:16 +0200 | [diff] [blame] | 1008 | |
Malcolm Priestley | c00a378 | 2014-08-30 22:25:32 +0100 | [diff] [blame] | 1009 | buf->rrv_time = vnt_rxtx_rsvtime_le16(pDevice, PK_TYPE_11A, cbFrameSize, wCurrentRate, bNeedACK); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1010 | } |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 1011 | } else if (byPktType == PK_TYPE_11B) { |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 1012 | if ((pvRTS != NULL)) {/* RTS_need, non PCF mode */ |
Malcolm Priestley | c00a378 | 2014-08-30 22:25:32 +0100 | [diff] [blame] | 1013 | struct vnt_rrv_time_ab *buf = pvRrvTime; |
Guillaume Clement | 6b71127 | 2014-07-25 01:06:16 +0200 | [diff] [blame] | 1014 | |
Malcolm Priestley | c00a378 | 2014-08-30 22:25:32 +0100 | [diff] [blame] | 1015 | buf->rts_rrv_time = s_uGetRTSCTSRsvTime(pDevice, 0, byPktType, cbFrameSize, wCurrentRate); |
| 1016 | buf->rrv_time = vnt_rxtx_rsvtime_le16(pDevice, PK_TYPE_11B, cbFrameSize, wCurrentRate, bNeedACK); |
| 1017 | |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 1018 | /* Fill RTS */ |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1019 | s_vFillRTSHead(pDevice, byPktType, pvRTS, cbFrameSize, bNeedACK, bDisCRC, psEthHeader, wCurrentRate, byFBOption); |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 1020 | } else { /* RTS_needless, non PCF mode */ |
Malcolm Priestley | c00a378 | 2014-08-30 22:25:32 +0100 | [diff] [blame] | 1021 | struct vnt_rrv_time_ab *buf = pvRrvTime; |
Guillaume Clement | 6b71127 | 2014-07-25 01:06:16 +0200 | [diff] [blame] | 1022 | |
Malcolm Priestley | c00a378 | 2014-08-30 22:25:32 +0100 | [diff] [blame] | 1023 | buf->rrv_time = vnt_rxtx_rsvtime_le16(pDevice, PK_TYPE_11B, cbFrameSize, wCurrentRate, bNeedACK); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1024 | } |
| 1025 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1026 | } |
Guido Martínez | 4e8a7e5 | 2014-04-19 16:44:59 -0300 | [diff] [blame] | 1027 | |
Charles Clément | fe4f34b | 2010-06-25 10:48:53 -0700 | [diff] [blame] | 1028 | static unsigned int |
Malcolm Priestley | cf76dc4 | 2014-08-10 15:46:59 +0100 | [diff] [blame] | 1029 | s_cbFillTxBufHead(struct vnt_private *pDevice, unsigned char byPktType, |
Malcolm Priestley | 19f3ed3 | 2014-11-29 00:02:03 +0000 | [diff] [blame] | 1030 | unsigned char *pbyTxBufferAddr, |
Malcolm Priestley | cf76dc4 | 2014-08-10 15:46:59 +0100 | [diff] [blame] | 1031 | unsigned int uDMAIdx, PSTxDesc pHeadTD, |
Malcolm Priestley | 154bb8b | 2014-11-29 00:02:02 +0000 | [diff] [blame] | 1032 | unsigned int is_pspoll) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1033 | { |
Malcolm Priestley | cfd9f0d | 2014-10-29 17:43:39 +0000 | [diff] [blame] | 1034 | PDEVICE_TD_INFO td_info = pHeadTD->pTDInfo; |
| 1035 | struct sk_buff *skb = td_info->skb; |
| 1036 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); |
| 1037 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; |
| 1038 | struct vnt_tx_fifo_head *tx_buffer_head = |
| 1039 | (struct vnt_tx_fifo_head *)td_info->buf; |
| 1040 | u16 fifo_ctl = le16_to_cpu(tx_buffer_head->fifo_ctl); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1041 | unsigned int cbFrameSize; |
Malcolm Priestley | a479ffc | 2014-08-30 22:25:38 +0100 | [diff] [blame] | 1042 | __le16 uDuration; |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1043 | unsigned char *pbyBuffer; |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1044 | unsigned int uLength = 0; |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1045 | unsigned int cbMICHDR = 0; |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1046 | unsigned int uMACfragNum = 1; |
| 1047 | unsigned int uPadding = 0; |
| 1048 | unsigned int cbReqCount = 0; |
Malcolm Priestley | cfd9f0d | 2014-10-29 17:43:39 +0000 | [diff] [blame] | 1049 | bool bNeedACK = (bool)(fifo_ctl & FIFOCTL_NEEDACK); |
| 1050 | bool bRTS = (bool)(fifo_ctl & FIFOCTL_RTS); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1051 | PSTxDesc ptdCurr; |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1052 | unsigned int cbHeaderLength = 0; |
| 1053 | void *pvRrvTime; |
Malcolm Priestley | 11a72e5 | 2014-08-09 20:15:56 +0100 | [diff] [blame] | 1054 | struct vnt_mic_hdr *pMICHDR; |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1055 | void *pvRTS; |
| 1056 | void *pvCTS; |
| 1057 | void *pvTxDataHd; |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 1058 | unsigned short wTxBufSize; /* FFinfo size */ |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1059 | unsigned char byFBOption = AUTO_FB_NONE; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1060 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1061 | pvRrvTime = pMICHDR = pvRTS = pvCTS = pvTxDataHd = NULL; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1062 | |
Malcolm Priestley | cfd9f0d | 2014-10-29 17:43:39 +0000 | [diff] [blame] | 1063 | cbFrameSize = skb->len + 4; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1064 | |
Malcolm Priestley | cfd9f0d | 2014-10-29 17:43:39 +0000 | [diff] [blame] | 1065 | if (info->control.hw_key) { |
| 1066 | switch (info->control.hw_key->cipher) { |
| 1067 | case WLAN_CIPHER_SUITE_CCMP: |
Malcolm Priestley | 11a72e5 | 2014-08-09 20:15:56 +0100 | [diff] [blame] | 1068 | cbMICHDR = sizeof(struct vnt_mic_hdr); |
Malcolm Priestley | cfd9f0d | 2014-10-29 17:43:39 +0000 | [diff] [blame] | 1069 | default: |
| 1070 | break; |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1071 | } |
Malcolm Priestley | cfd9f0d | 2014-10-29 17:43:39 +0000 | [diff] [blame] | 1072 | |
| 1073 | cbFrameSize += info->control.hw_key->icv_len; |
| 1074 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1075 | if (pDevice->byLocalID > REV_ID_VT3253_A1) { |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 1076 | /* MAC Header should be padding 0 to DW alignment. */ |
Malcolm Priestley | cfd9f0d | 2014-10-29 17:43:39 +0000 | [diff] [blame] | 1077 | uPadding = 4 - (ieee80211_get_hdrlen_from_skb(skb) % 4); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1078 | uPadding %= 4; |
| 1079 | } |
| 1080 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1081 | |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 1082 | /* |
| 1083 | * Use for AUTO FALL BACK |
| 1084 | */ |
Malcolm Priestley | cfd9f0d | 2014-10-29 17:43:39 +0000 | [diff] [blame] | 1085 | if (fifo_ctl & FIFOCTL_AUTO_FB_0) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1086 | byFBOption = AUTO_FB_0; |
Malcolm Priestley | cfd9f0d | 2014-10-29 17:43:39 +0000 | [diff] [blame] | 1087 | else if (fifo_ctl & FIFOCTL_AUTO_FB_1) |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1088 | byFBOption = AUTO_FB_1; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1089 | |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 1090 | |
| 1091 | /* Set RrvTime/RTS/CTS Buffer */ |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1092 | wTxBufSize = sizeof(STxBufHead); |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 1093 | if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) {/* 802.11g packet */ |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1094 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1095 | if (byFBOption == AUTO_FB_NONE) { |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 1096 | if (bRTS == true) {/* RTS_need */ |
Malcolm Priestley | a9e6a2d | 2014-08-30 22:25:27 +0100 | [diff] [blame] | 1097 | pvRrvTime = (void *)(pbyTxBufferAddr + wTxBufSize); |
| 1098 | pMICHDR = (struct vnt_mic_hdr *)(pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_rts)); |
Malcolm Priestley | 17434f0 | 2014-08-30 22:25:41 +0100 | [diff] [blame] | 1099 | pvRTS = (void *)(pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_rts) + cbMICHDR); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1100 | pvCTS = NULL; |
Malcolm Priestley | 17434f0 | 2014-08-30 22:25:41 +0100 | [diff] [blame] | 1101 | pvTxDataHd = (void *)(pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_rts) + |
| 1102 | cbMICHDR + sizeof(struct vnt_rts_g)); |
Malcolm Priestley | 72edb7e | 2014-08-30 22:25:34 +0100 | [diff] [blame] | 1103 | cbHeaderLength = wTxBufSize + sizeof(struct vnt_rrv_time_rts) + |
Malcolm Priestley | 17434f0 | 2014-08-30 22:25:41 +0100 | [diff] [blame] | 1104 | cbMICHDR + sizeof(struct vnt_rts_g) + |
| 1105 | sizeof(struct vnt_tx_datahead_g); |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 1106 | } else { /* RTS_needless */ |
Malcolm Priestley | d66a5a7 | 2014-08-30 22:25:28 +0100 | [diff] [blame] | 1107 | pvRrvTime = (void *)(pbyTxBufferAddr + wTxBufSize); |
| 1108 | pMICHDR = (struct vnt_mic_hdr *) (pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_cts)); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1109 | pvRTS = NULL; |
Malcolm Priestley | f5172b0 | 2014-08-30 22:25:45 +0100 | [diff] [blame] | 1110 | pvCTS = (void *) (pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_cts) + cbMICHDR); |
| 1111 | pvTxDataHd = (void *)(pbyTxBufferAddr + wTxBufSize + |
| 1112 | sizeof(struct vnt_rrv_time_cts) + cbMICHDR + sizeof(struct vnt_cts)); |
Malcolm Priestley | 72edb7e | 2014-08-30 22:25:34 +0100 | [diff] [blame] | 1113 | cbHeaderLength = wTxBufSize + sizeof(struct vnt_rrv_time_cts) + |
Malcolm Priestley | f5172b0 | 2014-08-30 22:25:45 +0100 | [diff] [blame] | 1114 | cbMICHDR + sizeof(struct vnt_cts) + sizeof(struct vnt_tx_datahead_g); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1115 | } |
| 1116 | } else { |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 1117 | /* Auto Fall Back */ |
| 1118 | if (bRTS == true) {/* RTS_need */ |
Malcolm Priestley | a9e6a2d | 2014-08-30 22:25:27 +0100 | [diff] [blame] | 1119 | pvRrvTime = (void *)(pbyTxBufferAddr + wTxBufSize); |
| 1120 | pMICHDR = (struct vnt_mic_hdr *) (pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_rts)); |
Malcolm Priestley | 9587b09 | 2014-08-30 22:25:42 +0100 | [diff] [blame] | 1121 | pvRTS = (void *) (pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_rts) + cbMICHDR); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1122 | pvCTS = NULL; |
Malcolm Priestley | 9587b09 | 2014-08-30 22:25:42 +0100 | [diff] [blame] | 1123 | pvTxDataHd = (void *)(pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_rts) + |
| 1124 | cbMICHDR + sizeof(struct vnt_rts_g_fb)); |
Malcolm Priestley | 2dd7667 | 2014-08-30 22:25:35 +0100 | [diff] [blame] | 1125 | cbHeaderLength = wTxBufSize + sizeof(struct vnt_rrv_time_rts) + |
Malcolm Priestley | 9587b09 | 2014-08-30 22:25:42 +0100 | [diff] [blame] | 1126 | cbMICHDR + sizeof(struct vnt_rts_g_fb) + sizeof(struct vnt_tx_datahead_g_fb); |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 1127 | } else { /* RTS_needless */ |
Malcolm Priestley | d66a5a7 | 2014-08-30 22:25:28 +0100 | [diff] [blame] | 1128 | pvRrvTime = (void *)(pbyTxBufferAddr + wTxBufSize); |
| 1129 | pMICHDR = (struct vnt_mic_hdr *) (pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_cts)); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1130 | pvRTS = NULL; |
Malcolm Priestley | db1afd1 | 2014-08-30 22:25:46 +0100 | [diff] [blame] | 1131 | pvCTS = (void *)(pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_cts) + cbMICHDR); |
| 1132 | pvTxDataHd = (void *)(pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_cts) + |
| 1133 | cbMICHDR + sizeof(struct vnt_cts_fb)); |
Malcolm Priestley | 2dd7667 | 2014-08-30 22:25:35 +0100 | [diff] [blame] | 1134 | cbHeaderLength = wTxBufSize + sizeof(struct vnt_rrv_time_cts) + |
Malcolm Priestley | db1afd1 | 2014-08-30 22:25:46 +0100 | [diff] [blame] | 1135 | cbMICHDR + sizeof(struct vnt_cts_fb) + sizeof(struct vnt_tx_datahead_g_fb); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1136 | } |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 1137 | } /* Auto Fall Back */ |
| 1138 | } else {/* 802.11a/b packet */ |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1139 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1140 | if (byFBOption == AUTO_FB_NONE) { |
| 1141 | if (bRTS == true) { |
Malcolm Priestley | f6a634c | 2014-08-30 22:25:29 +0100 | [diff] [blame] | 1142 | pvRrvTime = (void *)(pbyTxBufferAddr + wTxBufSize); |
| 1143 | pMICHDR = (struct vnt_mic_hdr *) (pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_ab)); |
Malcolm Priestley | e21eb1c | 2014-08-30 22:25:43 +0100 | [diff] [blame] | 1144 | pvRTS = (void *)(pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_ab) + cbMICHDR); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1145 | pvCTS = NULL; |
Malcolm Priestley | 9ce842a | 2014-08-30 22:25:36 +0100 | [diff] [blame] | 1146 | pvTxDataHd = (void *)(pbyTxBufferAddr + wTxBufSize + |
Malcolm Priestley | e21eb1c | 2014-08-30 22:25:43 +0100 | [diff] [blame] | 1147 | sizeof(struct vnt_rrv_time_ab) + cbMICHDR + sizeof(struct vnt_rts_ab)); |
Malcolm Priestley | 9ce842a | 2014-08-30 22:25:36 +0100 | [diff] [blame] | 1148 | cbHeaderLength = wTxBufSize + sizeof(struct vnt_rrv_time_ab) + |
Malcolm Priestley | e21eb1c | 2014-08-30 22:25:43 +0100 | [diff] [blame] | 1149 | cbMICHDR + sizeof(struct vnt_rts_ab) + sizeof(struct vnt_tx_datahead_ab); |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 1150 | } else { /* RTS_needless, need MICHDR */ |
Malcolm Priestley | f6a634c | 2014-08-30 22:25:29 +0100 | [diff] [blame] | 1151 | pvRrvTime = (void *)(pbyTxBufferAddr + wTxBufSize); |
| 1152 | pMICHDR = (struct vnt_mic_hdr *) (pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_ab)); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1153 | pvRTS = NULL; |
| 1154 | pvCTS = NULL; |
Malcolm Priestley | 9ce842a | 2014-08-30 22:25:36 +0100 | [diff] [blame] | 1155 | pvTxDataHd = (void *)(pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_ab) + cbMICHDR); |
| 1156 | cbHeaderLength = wTxBufSize + sizeof(struct vnt_rrv_time_ab) + |
| 1157 | cbMICHDR + sizeof(struct vnt_tx_datahead_ab); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1158 | } |
| 1159 | } else { |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 1160 | /* Auto Fall Back */ |
| 1161 | if (bRTS == true) { /* RTS_need */ |
Malcolm Priestley | f6a634c | 2014-08-30 22:25:29 +0100 | [diff] [blame] | 1162 | pvRrvTime = (void *)(pbyTxBufferAddr + wTxBufSize); |
| 1163 | pMICHDR = (struct vnt_mic_hdr *) (pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_ab)); |
Malcolm Priestley | 8e44804 | 2014-08-30 22:25:44 +0100 | [diff] [blame] | 1164 | pvRTS = (void *)(pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_ab) + cbMICHDR); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1165 | pvCTS = NULL; |
Malcolm Priestley | 8e44804 | 2014-08-30 22:25:44 +0100 | [diff] [blame] | 1166 | pvTxDataHd = (void *)(pbyTxBufferAddr + wTxBufSize + |
| 1167 | sizeof(struct vnt_rrv_time_ab) + cbMICHDR + sizeof(struct vnt_rts_a_fb)); |
Malcolm Priestley | 9c62c7a | 2014-08-30 22:25:37 +0100 | [diff] [blame] | 1168 | cbHeaderLength = wTxBufSize + sizeof(struct vnt_rrv_time_ab) + |
Malcolm Priestley | 8e44804 | 2014-08-30 22:25:44 +0100 | [diff] [blame] | 1169 | cbMICHDR + sizeof(struct vnt_rts_a_fb) + sizeof(struct vnt_tx_datahead_a_fb); |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 1170 | } else { /* RTS_needless */ |
Malcolm Priestley | f6a634c | 2014-08-30 22:25:29 +0100 | [diff] [blame] | 1171 | pvRrvTime = (void *)(pbyTxBufferAddr + wTxBufSize); |
| 1172 | pMICHDR = (struct vnt_mic_hdr *)(pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_ab)); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1173 | pvRTS = NULL; |
| 1174 | pvCTS = NULL; |
Malcolm Priestley | 9c62c7a | 2014-08-30 22:25:37 +0100 | [diff] [blame] | 1175 | pvTxDataHd = (void *)(pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_ab) + cbMICHDR); |
| 1176 | cbHeaderLength = wTxBufSize + sizeof(struct vnt_rrv_time_ab) + |
| 1177 | cbMICHDR + sizeof(struct vnt_tx_datahead_a_fb); |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1178 | } |
Hatice ERTÜRK | 7a48a09 | 2015-03-19 23:09:43 +0200 | [diff] [blame] | 1179 | } /* Auto Fall Back */ |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1180 | } |
Malcolm Priestley | cfd9f0d | 2014-10-29 17:43:39 +0000 | [diff] [blame] | 1181 | |
| 1182 | td_info->mic_hdr = pMICHDR; |
| 1183 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1184 | memset((void *)(pbyTxBufferAddr + wTxBufSize), 0, (cbHeaderLength - wTxBufSize)); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1185 | |
Malcolm Priestley | cfd9f0d | 2014-10-29 17:43:39 +0000 | [diff] [blame] | 1186 | /* Fill FIFO,RrvTime,RTS,and CTS */ |
| 1187 | s_vGenerateTxParameter(pDevice, byPktType, tx_buffer_head, pvRrvTime, pvRTS, pvCTS, |
| 1188 | cbFrameSize, bNeedACK, uDMAIdx, hdr, pDevice->wCurrentRate); |
| 1189 | /* Fill DataHead */ |
| 1190 | uDuration = s_uFillDataHead(pDevice, byPktType, pvTxDataHd, cbFrameSize, uDMAIdx, bNeedACK, |
Malcolm Priestley | 89cf9be | 2014-10-29 17:43:42 +0000 | [diff] [blame] | 1191 | 0, 0, uMACfragNum, byFBOption, pDevice->wCurrentRate, is_pspoll); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1192 | |
Malcolm Priestley | cfd9f0d | 2014-10-29 17:43:39 +0000 | [diff] [blame] | 1193 | hdr->duration_id = uDuration; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1194 | |
Malcolm Priestley | 19f3ed3 | 2014-11-29 00:02:03 +0000 | [diff] [blame] | 1195 | cbReqCount = cbHeaderLength + uPadding + skb->len; |
Malcolm Priestley | cfd9f0d | 2014-10-29 17:43:39 +0000 | [diff] [blame] | 1196 | pbyBuffer = (unsigned char *)pHeadTD->pTDInfo->buf; |
| 1197 | uLength = cbHeaderLength + uPadding; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1198 | |
Malcolm Priestley | cfd9f0d | 2014-10-29 17:43:39 +0000 | [diff] [blame] | 1199 | /* Copy the Packet into a tx Buffer */ |
Malcolm Priestley | 19f3ed3 | 2014-11-29 00:02:03 +0000 | [diff] [blame] | 1200 | memcpy((pbyBuffer + uLength), skb->data, skb->len); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 1201 | |
Malcolm Priestley | cfd9f0d | 2014-10-29 17:43:39 +0000 | [diff] [blame] | 1202 | ptdCurr = (PSTxDesc)pHeadTD; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1203 | |
Malcolm Priestley | b574529 | 2014-12-21 12:56:34 +0000 | [diff] [blame] | 1204 | ptdCurr->pTDInfo->dwReqCount = cbReqCount; |
Malcolm Priestley | cfd9f0d | 2014-10-29 17:43:39 +0000 | [diff] [blame] | 1205 | ptdCurr->pTDInfo->dwHeaderLength = cbHeaderLength; |
| 1206 | ptdCurr->pTDInfo->skb_dma = ptdCurr->pTDInfo->buf_dma; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1207 | |
Joe Perches | 547f1cf | 2013-03-18 10:45:01 -0700 | [diff] [blame] | 1208 | return cbHeaderLength; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1209 | } |
| 1210 | |
Malcolm Priestley | 01eec15 | 2014-10-29 17:43:38 +0000 | [diff] [blame] | 1211 | static void vnt_fill_txkey(struct ieee80211_hdr *hdr, u8 *key_buffer, |
| 1212 | struct ieee80211_key_conf *tx_key, |
| 1213 | struct sk_buff *skb, u16 payload_len, |
| 1214 | struct vnt_mic_hdr *mic_hdr) |
| 1215 | { |
| 1216 | struct ieee80211_key_seq seq; |
| 1217 | u8 *iv = ((u8 *)hdr + ieee80211_get_hdrlen_from_skb(skb)); |
| 1218 | |
| 1219 | /* strip header and icv len from payload */ |
| 1220 | payload_len -= ieee80211_get_hdrlen_from_skb(skb); |
| 1221 | payload_len -= tx_key->icv_len; |
| 1222 | |
| 1223 | switch (tx_key->cipher) { |
| 1224 | case WLAN_CIPHER_SUITE_WEP40: |
| 1225 | case WLAN_CIPHER_SUITE_WEP104: |
| 1226 | memcpy(key_buffer, iv, 3); |
| 1227 | memcpy(key_buffer + 3, tx_key->key, tx_key->keylen); |
| 1228 | |
| 1229 | if (tx_key->keylen == WLAN_KEY_LEN_WEP40) { |
| 1230 | memcpy(key_buffer + 8, iv, 3); |
| 1231 | memcpy(key_buffer + 11, |
| 1232 | tx_key->key, WLAN_KEY_LEN_WEP40); |
| 1233 | } |
| 1234 | |
| 1235 | break; |
| 1236 | case WLAN_CIPHER_SUITE_TKIP: |
| 1237 | ieee80211_get_tkip_p2k(tx_key, skb, key_buffer); |
| 1238 | |
| 1239 | break; |
| 1240 | case WLAN_CIPHER_SUITE_CCMP: |
| 1241 | |
| 1242 | if (!mic_hdr) |
| 1243 | return; |
| 1244 | |
| 1245 | mic_hdr->id = 0x59; |
| 1246 | mic_hdr->payload_len = cpu_to_be16(payload_len); |
| 1247 | ether_addr_copy(mic_hdr->mic_addr2, hdr->addr2); |
| 1248 | |
| 1249 | ieee80211_get_key_tx_seq(tx_key, &seq); |
| 1250 | |
| 1251 | memcpy(mic_hdr->ccmp_pn, seq.ccmp.pn, IEEE80211_CCMP_PN_LEN); |
| 1252 | |
| 1253 | if (ieee80211_has_a4(hdr->frame_control)) |
| 1254 | mic_hdr->hlen = cpu_to_be16(28); |
| 1255 | else |
| 1256 | mic_hdr->hlen = cpu_to_be16(22); |
| 1257 | |
| 1258 | ether_addr_copy(mic_hdr->addr1, hdr->addr1); |
| 1259 | ether_addr_copy(mic_hdr->addr2, hdr->addr2); |
| 1260 | ether_addr_copy(mic_hdr->addr3, hdr->addr3); |
| 1261 | |
| 1262 | mic_hdr->frame_control = cpu_to_le16( |
| 1263 | le16_to_cpu(hdr->frame_control) & 0xc78f); |
| 1264 | mic_hdr->seq_ctrl = cpu_to_le16( |
| 1265 | le16_to_cpu(hdr->seq_ctrl) & 0xf); |
| 1266 | |
| 1267 | if (ieee80211_has_a4(hdr->frame_control)) |
| 1268 | ether_addr_copy(mic_hdr->addr4, hdr->addr4); |
| 1269 | |
| 1270 | memcpy(key_buffer, tx_key->key, WLAN_KEY_LEN_CCMP); |
| 1271 | |
| 1272 | break; |
| 1273 | default: |
| 1274 | break; |
| 1275 | } |
| 1276 | } |
| 1277 | |
| 1278 | int vnt_generate_fifo_header(struct vnt_private *priv, u32 dma_idx, |
| 1279 | PSTxDesc head_td, struct sk_buff *skb) |
| 1280 | { |
| 1281 | PDEVICE_TD_INFO td_info = head_td->pTDInfo; |
| 1282 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); |
| 1283 | struct ieee80211_tx_rate *tx_rate = &info->control.rates[0]; |
| 1284 | struct ieee80211_rate *rate; |
| 1285 | struct ieee80211_key_conf *tx_key; |
| 1286 | struct ieee80211_hdr *hdr; |
| 1287 | struct vnt_tx_fifo_head *tx_buffer_head = |
| 1288 | (struct vnt_tx_fifo_head *)td_info->buf; |
Malcolm Priestley | 01eec15 | 2014-10-29 17:43:38 +0000 | [diff] [blame] | 1289 | u16 tx_body_size = skb->len, current_rate; |
| 1290 | u8 pkt_type; |
| 1291 | bool is_pspoll = false; |
| 1292 | |
| 1293 | memset(tx_buffer_head, 0, sizeof(*tx_buffer_head)); |
| 1294 | |
| 1295 | hdr = (struct ieee80211_hdr *)(skb->data); |
| 1296 | |
| 1297 | rate = ieee80211_get_tx_rate(priv->hw, info); |
| 1298 | |
| 1299 | current_rate = rate->hw_value; |
| 1300 | if (priv->wCurrentRate != current_rate && |
| 1301 | !(priv->hw->conf.flags & IEEE80211_CONF_OFFCHANNEL)) { |
| 1302 | priv->wCurrentRate = current_rate; |
| 1303 | |
| 1304 | RFbSetPower(priv, priv->wCurrentRate, |
| 1305 | priv->hw->conf.chandef.chan->hw_value); |
| 1306 | } |
| 1307 | |
Malcolm Priestley | a6388e6 | 2015-04-01 22:32:52 +0100 | [diff] [blame] | 1308 | if (current_rate > RATE_11M) { |
| 1309 | if (info->band == IEEE80211_BAND_5GHZ) { |
| 1310 | pkt_type = PK_TYPE_11A; |
| 1311 | } else { |
| 1312 | if (tx_rate->flags & IEEE80211_TX_RC_USE_CTS_PROTECT) |
| 1313 | pkt_type = PK_TYPE_11GB; |
| 1314 | else |
| 1315 | pkt_type = PK_TYPE_11GA; |
| 1316 | } |
| 1317 | } else { |
Malcolm Priestley | 01eec15 | 2014-10-29 17:43:38 +0000 | [diff] [blame] | 1318 | pkt_type = PK_TYPE_11B; |
Malcolm Priestley | a6388e6 | 2015-04-01 22:32:52 +0100 | [diff] [blame] | 1319 | } |
Malcolm Priestley | 01eec15 | 2014-10-29 17:43:38 +0000 | [diff] [blame] | 1320 | |
| 1321 | /*Set fifo controls */ |
| 1322 | if (pkt_type == PK_TYPE_11A) |
| 1323 | tx_buffer_head->fifo_ctl = 0; |
| 1324 | else if (pkt_type == PK_TYPE_11B) |
| 1325 | tx_buffer_head->fifo_ctl = cpu_to_le16(FIFOCTL_11B); |
| 1326 | else if (pkt_type == PK_TYPE_11GB) |
| 1327 | tx_buffer_head->fifo_ctl = cpu_to_le16(FIFOCTL_11GB); |
| 1328 | else if (pkt_type == PK_TYPE_11GA) |
| 1329 | tx_buffer_head->fifo_ctl = cpu_to_le16(FIFOCTL_11GA); |
| 1330 | |
| 1331 | /* generate interrupt */ |
| 1332 | tx_buffer_head->fifo_ctl |= cpu_to_le16(FIFOCTL_GENINT); |
| 1333 | |
| 1334 | if (!ieee80211_is_data(hdr->frame_control)) { |
| 1335 | tx_buffer_head->fifo_ctl |= cpu_to_le16(FIFOCTL_TMOEN); |
| 1336 | tx_buffer_head->fifo_ctl |= cpu_to_le16(FIFOCTL_ISDMA0); |
| 1337 | tx_buffer_head->time_stamp = |
| 1338 | cpu_to_le16(DEFAULT_MGN_LIFETIME_RES_64us); |
| 1339 | } else { |
| 1340 | tx_buffer_head->time_stamp = |
| 1341 | cpu_to_le16(DEFAULT_MSDU_LIFETIME_RES_64us); |
| 1342 | } |
| 1343 | |
| 1344 | if (!(info->flags & IEEE80211_TX_CTL_NO_ACK)) |
| 1345 | tx_buffer_head->fifo_ctl |= cpu_to_le16(FIFOCTL_NEEDACK); |
| 1346 | |
| 1347 | if (ieee80211_has_retry(hdr->frame_control)) |
| 1348 | tx_buffer_head->fifo_ctl |= cpu_to_le16(FIFOCTL_LRETRY); |
| 1349 | |
| 1350 | if (tx_rate->flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE) |
| 1351 | priv->byPreambleType = PREAMBLE_SHORT; |
| 1352 | else |
| 1353 | priv->byPreambleType = PREAMBLE_LONG; |
| 1354 | |
| 1355 | if (tx_rate->flags & IEEE80211_TX_RC_USE_RTS_CTS) |
| 1356 | tx_buffer_head->fifo_ctl |= cpu_to_le16(FIFOCTL_RTS); |
| 1357 | |
| 1358 | if (ieee80211_has_a4(hdr->frame_control)) { |
| 1359 | tx_buffer_head->fifo_ctl |= cpu_to_le16(FIFOCTL_LHEAD); |
| 1360 | priv->bLongHeader = true; |
| 1361 | } |
| 1362 | |
| 1363 | if (info->flags & IEEE80211_TX_CTL_NO_PS_BUFFER) |
| 1364 | is_pspoll = true; |
| 1365 | |
| 1366 | tx_buffer_head->frag_ctl = |
| 1367 | cpu_to_le16(ieee80211_get_hdrlen_from_skb(skb) << 10); |
| 1368 | |
| 1369 | if (info->control.hw_key) { |
| 1370 | tx_key = info->control.hw_key; |
| 1371 | |
| 1372 | switch (info->control.hw_key->cipher) { |
| 1373 | case WLAN_CIPHER_SUITE_WEP40: |
| 1374 | case WLAN_CIPHER_SUITE_WEP104: |
| 1375 | tx_buffer_head->frag_ctl |= cpu_to_le16(FRAGCTL_LEGACY); |
| 1376 | break; |
| 1377 | case WLAN_CIPHER_SUITE_TKIP: |
| 1378 | tx_buffer_head->frag_ctl |= cpu_to_le16(FRAGCTL_TKIP); |
| 1379 | break; |
| 1380 | case WLAN_CIPHER_SUITE_CCMP: |
| 1381 | tx_buffer_head->frag_ctl |= cpu_to_le16(FRAGCTL_AES); |
| 1382 | default: |
| 1383 | break; |
| 1384 | } |
| 1385 | } |
| 1386 | |
| 1387 | tx_buffer_head->current_rate = cpu_to_le16(current_rate); |
| 1388 | |
| 1389 | /* legacy rates TODO use ieee80211_tx_rate */ |
| 1390 | if (current_rate >= RATE_18M && ieee80211_is_data(hdr->frame_control)) { |
| 1391 | if (priv->byAutoFBCtrl == AUTO_FB_0) |
| 1392 | tx_buffer_head->fifo_ctl |= |
| 1393 | cpu_to_le16(FIFOCTL_AUTO_FB_0); |
| 1394 | else if (priv->byAutoFBCtrl == AUTO_FB_1) |
| 1395 | tx_buffer_head->fifo_ctl |= |
| 1396 | cpu_to_le16(FIFOCTL_AUTO_FB_1); |
| 1397 | |
| 1398 | } |
| 1399 | |
| 1400 | tx_buffer_head->frag_ctl |= cpu_to_le16(FRAGCTL_NONFRAG); |
| 1401 | |
Malcolm Priestley | 19f3ed3 | 2014-11-29 00:02:03 +0000 | [diff] [blame] | 1402 | s_cbFillTxBufHead(priv, pkt_type, (u8 *)tx_buffer_head, |
Malcolm Priestley | 154bb8b | 2014-11-29 00:02:02 +0000 | [diff] [blame] | 1403 | dma_idx, head_td, is_pspoll); |
Malcolm Priestley | 01eec15 | 2014-10-29 17:43:38 +0000 | [diff] [blame] | 1404 | |
| 1405 | if (info->control.hw_key) { |
| 1406 | tx_key = info->control.hw_key; |
| 1407 | if (tx_key->keylen > 0) |
| 1408 | vnt_fill_txkey(hdr, tx_buffer_head->tx_key, |
| 1409 | tx_key, skb, tx_body_size, td_info->mic_hdr); |
| 1410 | } |
| 1411 | |
| 1412 | return 0; |
| 1413 | } |
| 1414 | |
| 1415 | static int vnt_beacon_xmit(struct vnt_private *priv, |
| 1416 | struct sk_buff *skb) |
| 1417 | { |
| 1418 | struct vnt_tx_short_buf_head *short_head = |
| 1419 | (struct vnt_tx_short_buf_head *)priv->tx_beacon_bufs; |
| 1420 | struct ieee80211_mgmt *mgmt_hdr = (struct ieee80211_mgmt *) |
| 1421 | (priv->tx_beacon_bufs + sizeof(*short_head)); |
| 1422 | struct ieee80211_tx_info *info; |
| 1423 | u32 frame_size = skb->len + 4; |
| 1424 | u16 current_rate; |
| 1425 | |
| 1426 | memset(priv->tx_beacon_bufs, 0, sizeof(*short_head)); |
| 1427 | |
| 1428 | if (priv->byBBType == BB_TYPE_11A) { |
| 1429 | current_rate = RATE_6M; |
| 1430 | |
| 1431 | /* Get SignalField,ServiceField,Length */ |
| 1432 | vnt_get_phy_field(priv, frame_size, current_rate, |
| 1433 | PK_TYPE_11A, &short_head->ab); |
| 1434 | |
| 1435 | /* Get Duration and TimeStampOff */ |
| 1436 | short_head->duration = |
| 1437 | cpu_to_le16((u16)s_uGetDataDuration(priv, DATADUR_B, |
| 1438 | frame_size, PK_TYPE_11A, current_rate, |
| 1439 | false, 0, 0, 1, AUTO_FB_NONE)); |
| 1440 | |
| 1441 | short_head->time_stamp_off = |
| 1442 | vnt_time_stamp_off(priv, current_rate); |
| 1443 | } else { |
| 1444 | current_rate = RATE_1M; |
| 1445 | short_head->fifo_ctl |= cpu_to_le16(FIFOCTL_11B); |
| 1446 | |
| 1447 | /* Get SignalField,ServiceField,Length */ |
| 1448 | vnt_get_phy_field(priv, frame_size, current_rate, |
| 1449 | PK_TYPE_11B, &short_head->ab); |
| 1450 | |
| 1451 | /* Get Duration and TimeStampOff */ |
| 1452 | short_head->duration = |
| 1453 | cpu_to_le16((u16)s_uGetDataDuration(priv, DATADUR_B, |
| 1454 | frame_size, PK_TYPE_11B, current_rate, |
| 1455 | false, 0, 0, 1, AUTO_FB_NONE)); |
| 1456 | |
| 1457 | short_head->time_stamp_off = |
| 1458 | vnt_time_stamp_off(priv, current_rate); |
| 1459 | } |
| 1460 | |
| 1461 | short_head->fifo_ctl |= cpu_to_le16(FIFOCTL_GENINT); |
| 1462 | |
| 1463 | /* Copy Beacon */ |
| 1464 | memcpy(mgmt_hdr, skb->data, skb->len); |
| 1465 | |
| 1466 | /* time stamp always 0 */ |
| 1467 | mgmt_hdr->u.beacon.timestamp = 0; |
| 1468 | |
| 1469 | info = IEEE80211_SKB_CB(skb); |
| 1470 | if (info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ) { |
| 1471 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)mgmt_hdr; |
| 1472 | |
| 1473 | hdr->duration_id = 0; |
| 1474 | hdr->seq_ctrl = cpu_to_le16(priv->wSeqCounter << 4); |
| 1475 | } |
| 1476 | |
| 1477 | priv->wSeqCounter++; |
| 1478 | if (priv->wSeqCounter > 0x0fff) |
| 1479 | priv->wSeqCounter = 0; |
| 1480 | |
| 1481 | priv->wBCNBufLen = sizeof(*short_head) + skb->len; |
| 1482 | |
| 1483 | MACvSetCurrBCNTxDescAddr(priv->PortOffset, priv->tx_beacon_dma); |
| 1484 | |
| 1485 | MACvSetCurrBCNLength(priv->PortOffset, priv->wBCNBufLen); |
| 1486 | /* Set auto Transmit on */ |
| 1487 | MACvRegBitsOn(priv->PortOffset, MAC_REG_TCR, TCR_AUTOBCNTX); |
| 1488 | /* Poll Transmit the adapter */ |
| 1489 | MACvTransmitBCN(priv->PortOffset); |
| 1490 | |
| 1491 | return 0; |
| 1492 | } |
| 1493 | |
| 1494 | int vnt_beacon_make(struct vnt_private *priv, struct ieee80211_vif *vif) |
| 1495 | { |
| 1496 | struct sk_buff *beacon; |
| 1497 | |
| 1498 | beacon = ieee80211_beacon_get(priv->hw, vif); |
| 1499 | if (!beacon) |
| 1500 | return -ENOMEM; |
| 1501 | |
| 1502 | if (vnt_beacon_xmit(priv, beacon)) { |
| 1503 | ieee80211_free_txskb(priv->hw, beacon); |
| 1504 | return -ENODEV; |
| 1505 | } |
| 1506 | |
| 1507 | return 0; |
| 1508 | } |
| 1509 | |
| 1510 | int vnt_beacon_enable(struct vnt_private *priv, struct ieee80211_vif *vif, |
| 1511 | struct ieee80211_bss_conf *conf) |
| 1512 | { |
Malcolm Priestley | 01eec15 | 2014-10-29 17:43:38 +0000 | [diff] [blame] | 1513 | VNSvOutPortB(priv->PortOffset + MAC_REG_TFTCTL, TFTCTL_TSFCNTRST); |
| 1514 | |
| 1515 | VNSvOutPortB(priv->PortOffset + MAC_REG_TFTCTL, TFTCTL_TSFCNTREN); |
| 1516 | |
Malcolm Priestley | 738487f | 2014-11-12 21:11:09 +0000 | [diff] [blame] | 1517 | CARDvSetFirstNextTBTT(priv, conf->beacon_int); |
Malcolm Priestley | 01eec15 | 2014-10-29 17:43:38 +0000 | [diff] [blame] | 1518 | |
| 1519 | CARDbSetBeaconPeriod(priv, conf->beacon_int); |
| 1520 | |
Aya Mahfouz | 0c596a3 | 2015-02-27 14:51:29 +0200 | [diff] [blame] | 1521 | return vnt_beacon_make(priv, vif); |
Malcolm Priestley | 01eec15 | 2014-10-29 17:43:38 +0000 | [diff] [blame] | 1522 | } |