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