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: card.c |
| 20 | * Purpose: Provide functions to setup NIC operation mode |
| 21 | * Functions: |
| 22 | * s_vSafeResetTx - Rest Tx |
| 23 | * CARDvSetRSPINF - Set RSPINF |
| 24 | * vUpdateIFS - Update slotTime,SIFS,DIFS, and EIFS |
| 25 | * CARDvUpdateBasicTopRate - Update BasicTopRate |
| 26 | * CARDbAddBasicRate - Add to BasicRateSet |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 27 | * CARDbIsOFDMinBasicRate - Check if any OFDM rate is in BasicRateSet |
| 28 | * CARDvSetLoopbackMode - Set Loopback mode |
| 29 | * CARDbSoftwareReset - Sortware reset NIC |
Justin P. Mattock | 7664ec8 | 2012-08-20 08:43:15 -0700 | [diff] [blame] | 30 | * CARDqGetTSFOffset - Calculate TSFOffset |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 31 | * CARDbGetCurrentTSF - Read Current NIC TSF counter |
Justin P. Mattock | 7664ec8 | 2012-08-20 08:43:15 -0700 | [diff] [blame] | 32 | * CARDqGetNextTBTT - Calculate Next Beacon TSF counter |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 33 | * CARDvSetFirstNextTBTT - Set NIC Beacon time |
| 34 | * CARDvUpdateNextTBTT - Sync. NIC Beacon time |
| 35 | * CARDbRadioPowerOff - Turn Off NIC Radio Power |
| 36 | * CARDbRadioPowerOn - Turn On NIC Radio Power |
| 37 | * CARDbSetWEPMode - Set NIC Wep mode |
| 38 | * CARDbSetTxPower - Set NIC tx power |
| 39 | * |
| 40 | * Revision History: |
| 41 | * 06-10-2003 Bryan YC Fan: Re-write codes to support VT3253 spec. |
| 42 | * 08-26-2003 Kyle Hsu: Modify the defination type of dwIoBase. |
| 43 | * 09-01-2003 Bryan YC Fan: Add vUpdateIFS(). |
| 44 | * |
| 45 | */ |
| 46 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 47 | #include "tmacro.h" |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 48 | #include "card.h" |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 49 | #include "baseband.h" |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 50 | #include "mac.h" |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 51 | #include "desc.h" |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 52 | #include "rf.h" |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 53 | #include "vntwifi.h" |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 54 | #include "power.h" |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 55 | #include "key.h" |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 56 | #include "rc4.h" |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 57 | #include "country.h" |
Charles Clément | 79566eb | 2010-06-21 10:39:51 -0700 | [diff] [blame] | 58 | #include "channel.h" |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 59 | |
| 60 | /*--------------------- Static Definitions -------------------------*/ |
| 61 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 62 | static int msglevel = MSG_LEVEL_INFO; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 63 | |
| 64 | #define C_SIFS_A 16 // micro sec. |
| 65 | #define C_SIFS_BG 10 |
| 66 | |
| 67 | #define C_EIFS 80 // micro sec. |
| 68 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 69 | #define C_SLOT_SHORT 9 // micro sec. |
| 70 | #define C_SLOT_LONG 20 |
| 71 | |
| 72 | #define C_CWMIN_A 15 // slot time |
| 73 | #define C_CWMIN_B 31 |
| 74 | |
| 75 | #define C_CWMAX 1023 // slot time |
| 76 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 77 | #define WAIT_BEACON_TX_DOWN_TMO 3 // Times |
| 78 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 79 | //1M, 2M, 5M, 11M, 18M, 24M, 36M, 54M |
Charles Clément | 3fc9b58 | 2010-06-24 11:02:27 -0700 | [diff] [blame] | 80 | static unsigned char abyDefaultSuppRatesG[] = {WLAN_EID_SUPP_RATES, 8, 0x02, 0x04, 0x0B, 0x16, 0x24, 0x30, 0x48, 0x6C}; |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 81 | //6M, 9M, 12M, 48M |
Charles Clément | 3fc9b58 | 2010-06-24 11:02:27 -0700 | [diff] [blame] | 82 | static unsigned char abyDefaultExtSuppRatesG[] = {WLAN_EID_EXTSUPP_RATES, 4, 0x0C, 0x12, 0x18, 0x60}; |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 83 | //6M, 9M, 12M, 18M, 24M, 36M, 48M, 54M |
Charles Clément | 3fc9b58 | 2010-06-24 11:02:27 -0700 | [diff] [blame] | 84 | static unsigned char abyDefaultSuppRatesA[] = {WLAN_EID_SUPP_RATES, 8, 0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C}; |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 85 | //1M, 2M, 5M, 11M, |
Charles Clément | 3fc9b58 | 2010-06-24 11:02:27 -0700 | [diff] [blame] | 86 | static unsigned char abyDefaultSuppRatesB[] = {WLAN_EID_SUPP_RATES, 4, 0x02, 0x04, 0x0B, 0x16}; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 87 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 88 | /*--------------------- Static Variables --------------------------*/ |
| 89 | |
Guillaume Clement | 9e4c5c2 | 2014-07-22 22:08:28 +0200 | [diff] [blame] | 90 | static const unsigned short cwRXBCNTSFOff[MAX_RATE] = |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 91 | {17, 17, 17, 17, 34, 23, 17, 11, 8, 5, 4, 3}; |
| 92 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 93 | /*--------------------- Static Functions --------------------------*/ |
| 94 | |
| 95 | static |
Charles Clément | 6b35b7b | 2010-05-07 12:30:19 -0700 | [diff] [blame] | 96 | void |
Justin P. Mattock | 7664ec8 | 2012-08-20 08:43:15 -0700 | [diff] [blame] | 97 | s_vCalculateOFDMRParameter( |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 98 | unsigned char byRate, |
| 99 | CARD_PHY_TYPE ePHYType, |
| 100 | unsigned char *pbyTxRate, |
| 101 | unsigned char *pbyRsvTime |
| 102 | ); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 103 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 104 | /*--------------------- Export Functions --------------------------*/ |
| 105 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 106 | /* |
Justin P. Mattock | 7664ec8 | 2012-08-20 08:43:15 -0700 | [diff] [blame] | 107 | * Description: Calculate TxRate and RsvTime fields for RSPINF in OFDM mode. |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 108 | * |
| 109 | * Parameters: |
| 110 | * In: |
| 111 | * wRate - Tx Rate |
| 112 | * byPktType - Tx Packet type |
| 113 | * Out: |
| 114 | * pbyTxRate - pointer to RSPINF TxRate field |
| 115 | * pbyRsvTime - pointer to RSPINF RsvTime field |
| 116 | * |
| 117 | * Return Value: none |
| 118 | * |
| 119 | */ |
| 120 | static |
Charles Clément | 6b35b7b | 2010-05-07 12:30:19 -0700 | [diff] [blame] | 121 | void |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 122 | s_vCalculateOFDMRParameter( |
| 123 | unsigned char byRate, |
| 124 | CARD_PHY_TYPE ePHYType, |
| 125 | unsigned char *pbyTxRate, |
| 126 | unsigned char *pbyRsvTime |
| 127 | ) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 128 | { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 129 | switch (byRate) { |
| 130 | case RATE_6M: |
| 131 | if (ePHYType == PHY_TYPE_11A) {//5GHZ |
| 132 | *pbyTxRate = 0x9B; |
| 133 | *pbyRsvTime = 44; |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 134 | } else { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 135 | *pbyTxRate = 0x8B; |
| 136 | *pbyRsvTime = 50; |
| 137 | } |
| 138 | break; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 139 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 140 | case RATE_9M: |
| 141 | if (ePHYType == PHY_TYPE_11A) {//5GHZ |
| 142 | *pbyTxRate = 0x9F; |
| 143 | *pbyRsvTime = 36; |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 144 | } else { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 145 | *pbyTxRate = 0x8F; |
| 146 | *pbyRsvTime = 42; |
| 147 | } |
| 148 | break; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 149 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 150 | case RATE_12M: |
| 151 | if (ePHYType == PHY_TYPE_11A) {//5GHZ |
| 152 | *pbyTxRate = 0x9A; |
| 153 | *pbyRsvTime = 32; |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 154 | } else { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 155 | *pbyTxRate = 0x8A; |
| 156 | *pbyRsvTime = 38; |
| 157 | } |
| 158 | break; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 159 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 160 | case RATE_18M: |
| 161 | if (ePHYType == PHY_TYPE_11A) {//5GHZ |
| 162 | *pbyTxRate = 0x9E; |
| 163 | *pbyRsvTime = 28; |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 164 | } else { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 165 | *pbyTxRate = 0x8E; |
| 166 | *pbyRsvTime = 34; |
| 167 | } |
| 168 | break; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 169 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 170 | case RATE_36M: |
| 171 | if (ePHYType == PHY_TYPE_11A) {//5GHZ |
| 172 | *pbyTxRate = 0x9D; |
| 173 | *pbyRsvTime = 24; |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 174 | } else { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 175 | *pbyTxRate = 0x8D; |
| 176 | *pbyRsvTime = 30; |
| 177 | } |
| 178 | break; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 179 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 180 | case RATE_48M: |
| 181 | if (ePHYType == PHY_TYPE_11A) {//5GHZ |
| 182 | *pbyTxRate = 0x98; |
| 183 | *pbyRsvTime = 24; |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 184 | } else { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 185 | *pbyTxRate = 0x88; |
| 186 | *pbyRsvTime = 30; |
| 187 | } |
| 188 | break; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 189 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 190 | case RATE_54M: |
| 191 | if (ePHYType == PHY_TYPE_11A) {//5GHZ |
| 192 | *pbyTxRate = 0x9C; |
| 193 | *pbyRsvTime = 24; |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 194 | } else { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 195 | *pbyTxRate = 0x8C; |
| 196 | *pbyRsvTime = 30; |
| 197 | } |
| 198 | break; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 199 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 200 | case RATE_24M: |
| 201 | default: |
| 202 | if (ePHYType == PHY_TYPE_11A) {//5GHZ |
| 203 | *pbyTxRate = 0x99; |
| 204 | *pbyRsvTime = 28; |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 205 | } else { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 206 | *pbyTxRate = 0x89; |
| 207 | *pbyRsvTime = 34; |
| 208 | } |
| 209 | break; |
| 210 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 211 | } |
| 212 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 213 | /* |
| 214 | * Description: Set RSPINF |
| 215 | * |
| 216 | * Parameters: |
| 217 | * In: |
| 218 | * pDevice - The adapter to be set |
| 219 | * Out: |
| 220 | * none |
| 221 | * |
| 222 | * Return Value: None. |
| 223 | * |
| 224 | */ |
| 225 | static |
Charles Clément | 6b35b7b | 2010-05-07 12:30:19 -0700 | [diff] [blame] | 226 | void |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 227 | s_vSetRSPINF(PSDevice pDevice, CARD_PHY_TYPE ePHYType, void *pvSupportRateIEs, void *pvExtSupportRateIEs) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 228 | { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 229 | unsigned char byServ = 0, bySignal = 0; // For CCK |
| 230 | unsigned short wLen = 0; |
| 231 | unsigned char byTxRate = 0, byRsvTime = 0; // For OFDM |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 232 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 233 | //Set to Page1 |
| 234 | MACvSelectPage1(pDevice->PortOffset); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 235 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 236 | //RSPINF_b_1 |
| 237 | BBvCalculateParameter(pDevice, |
| 238 | 14, |
| 239 | VNTWIFIbyGetACKTxRate(RATE_1M, pvSupportRateIEs, pvExtSupportRateIEs), |
| 240 | PK_TYPE_11B, |
| 241 | &wLen, |
| 242 | &byServ, |
| 243 | &bySignal |
| 244 | ); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 245 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 246 | VNSvOutPortD(pDevice->PortOffset + MAC_REG_RSPINF_B_1, MAKEDWORD(wLen, MAKEWORD(bySignal, byServ))); |
| 247 | ///RSPINF_b_2 |
| 248 | BBvCalculateParameter(pDevice, |
| 249 | 14, |
| 250 | VNTWIFIbyGetACKTxRate(RATE_2M, pvSupportRateIEs, pvExtSupportRateIEs), |
| 251 | PK_TYPE_11B, |
| 252 | &wLen, |
| 253 | &byServ, |
| 254 | &bySignal |
| 255 | ); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 256 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 257 | VNSvOutPortD(pDevice->PortOffset + MAC_REG_RSPINF_B_2, MAKEDWORD(wLen, MAKEWORD(bySignal, byServ))); |
| 258 | //RSPINF_b_5 |
| 259 | BBvCalculateParameter(pDevice, |
| 260 | 14, |
| 261 | VNTWIFIbyGetACKTxRate(RATE_5M, pvSupportRateIEs, pvExtSupportRateIEs), |
| 262 | PK_TYPE_11B, |
| 263 | &wLen, |
| 264 | &byServ, |
| 265 | &bySignal |
| 266 | ); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 267 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 268 | VNSvOutPortD(pDevice->PortOffset + MAC_REG_RSPINF_B_5, MAKEDWORD(wLen, MAKEWORD(bySignal, byServ))); |
| 269 | //RSPINF_b_11 |
| 270 | BBvCalculateParameter(pDevice, |
| 271 | 14, |
| 272 | VNTWIFIbyGetACKTxRate(RATE_11M, pvSupportRateIEs, pvExtSupportRateIEs), |
| 273 | PK_TYPE_11B, |
| 274 | &wLen, |
| 275 | &byServ, |
| 276 | &bySignal |
| 277 | ); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 278 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 279 | VNSvOutPortD(pDevice->PortOffset + MAC_REG_RSPINF_B_11, MAKEDWORD(wLen, MAKEWORD(bySignal, byServ))); |
| 280 | //RSPINF_a_6 |
| 281 | s_vCalculateOFDMRParameter(RATE_6M, |
| 282 | ePHYType, |
| 283 | &byTxRate, |
| 284 | &byRsvTime); |
| 285 | VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_6, MAKEWORD(byTxRate, byRsvTime)); |
| 286 | //RSPINF_a_9 |
| 287 | s_vCalculateOFDMRParameter(RATE_9M, |
| 288 | ePHYType, |
| 289 | &byTxRate, |
| 290 | &byRsvTime); |
| 291 | VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_9, MAKEWORD(byTxRate, byRsvTime)); |
| 292 | //RSPINF_a_12 |
| 293 | s_vCalculateOFDMRParameter(RATE_12M, |
| 294 | ePHYType, |
| 295 | &byTxRate, |
| 296 | &byRsvTime); |
| 297 | VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_12, MAKEWORD(byTxRate, byRsvTime)); |
| 298 | //RSPINF_a_18 |
| 299 | s_vCalculateOFDMRParameter(RATE_18M, |
| 300 | ePHYType, |
| 301 | &byTxRate, |
| 302 | &byRsvTime); |
| 303 | VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_18, MAKEWORD(byTxRate, byRsvTime)); |
| 304 | //RSPINF_a_24 |
| 305 | s_vCalculateOFDMRParameter(RATE_24M, |
| 306 | ePHYType, |
| 307 | &byTxRate, |
| 308 | &byRsvTime); |
| 309 | VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_24, MAKEWORD(byTxRate, byRsvTime)); |
| 310 | //RSPINF_a_36 |
| 311 | s_vCalculateOFDMRParameter( |
| 312 | VNTWIFIbyGetACKTxRate(RATE_36M, pvSupportRateIEs, pvExtSupportRateIEs), |
| 313 | ePHYType, |
| 314 | &byTxRate, |
| 315 | &byRsvTime); |
| 316 | VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_36, MAKEWORD(byTxRate, byRsvTime)); |
| 317 | //RSPINF_a_48 |
| 318 | s_vCalculateOFDMRParameter( |
| 319 | VNTWIFIbyGetACKTxRate(RATE_48M, pvSupportRateIEs, pvExtSupportRateIEs), |
| 320 | ePHYType, |
| 321 | &byTxRate, |
| 322 | &byRsvTime); |
| 323 | VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_48, MAKEWORD(byTxRate, byRsvTime)); |
| 324 | //RSPINF_a_54 |
| 325 | s_vCalculateOFDMRParameter( |
| 326 | VNTWIFIbyGetACKTxRate(RATE_54M, pvSupportRateIEs, pvExtSupportRateIEs), |
| 327 | ePHYType, |
| 328 | &byTxRate, |
| 329 | &byRsvTime); |
| 330 | VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_54, MAKEWORD(byTxRate, byRsvTime)); |
| 331 | //RSPINF_a_72 |
| 332 | VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_72, MAKEWORD(byTxRate, byRsvTime)); |
| 333 | //Set to Page0 |
| 334 | MACvSelectPage0(pDevice->PortOffset); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 335 | } |
| 336 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 337 | /*--------------------- Export Functions --------------------------*/ |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 338 | |
| 339 | /* |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 340 | * Description: Get Card short preamble option value |
| 341 | * |
| 342 | * Parameters: |
| 343 | * In: |
| 344 | * pDevice - The adapter to be set |
| 345 | * Out: |
| 346 | * none |
| 347 | * |
Charles Clément | 5a5a2a6 | 2010-08-01 17:15:49 +0200 | [diff] [blame] | 348 | * Return Value: true if short preamble; otherwise false |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 349 | * |
| 350 | */ |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 351 | bool CARDbIsShortPreamble(void *pDeviceHandler) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 352 | { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 353 | PSDevice pDevice = (PSDevice) pDeviceHandler; |
Igor Bezukh | f9dc1a8 | 2014-07-16 10:45:30 +0300 | [diff] [blame] | 354 | |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 355 | if (pDevice->byPreambleType == 0) |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 356 | return false; |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 357 | |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 358 | return true; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 359 | } |
| 360 | |
| 361 | /* |
| 362 | * Description: Get Card short slot time option value |
| 363 | * |
| 364 | * Parameters: |
| 365 | * In: |
| 366 | * pDevice - The adapter to be set |
| 367 | * Out: |
| 368 | * none |
| 369 | * |
Charles Clément | 5a5a2a6 | 2010-08-01 17:15:49 +0200 | [diff] [blame] | 370 | * Return Value: true if short slot time; otherwise false |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 371 | * |
| 372 | */ |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 373 | bool CARDbIsShorSlotTime(void *pDeviceHandler) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 374 | { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 375 | PSDevice pDevice = (PSDevice) pDeviceHandler; |
Igor Bezukh | f9dc1a8 | 2014-07-16 10:45:30 +0300 | [diff] [blame] | 376 | |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 377 | return pDevice->bShortSlotTime; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 378 | } |
| 379 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 380 | /* |
| 381 | * Description: Update IFS |
| 382 | * |
| 383 | * Parameters: |
| 384 | * In: |
| 385 | * pDevice - The adapter to be set |
| 386 | * Out: |
| 387 | * none |
| 388 | * |
| 389 | * Return Value: None. |
| 390 | * |
| 391 | */ |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 392 | bool CARDbSetPhyParameter(void *pDeviceHandler, CARD_PHY_TYPE ePHYType, unsigned short wCapInfo, unsigned char byERPField, void *pvSupportRateIEs, void *pvExtSupportRateIEs) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 393 | { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 394 | PSDevice pDevice = (PSDevice) pDeviceHandler; |
| 395 | unsigned char byCWMaxMin = 0; |
| 396 | unsigned char bySlot = 0; |
| 397 | unsigned char bySIFS = 0; |
| 398 | unsigned char byDIFS = 0; |
| 399 | unsigned char byData; |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 400 | PWLAN_IE_SUPP_RATES pSupportRates = (PWLAN_IE_SUPP_RATES) pvSupportRateIEs; |
| 401 | PWLAN_IE_SUPP_RATES pExtSupportRates = (PWLAN_IE_SUPP_RATES) pvExtSupportRateIEs; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 402 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 403 | //Set SIFS, DIFS, EIFS, SlotTime, CwMin |
| 404 | if (ePHYType == PHY_TYPE_11A) { |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 405 | if (pSupportRates == NULL) |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 406 | pSupportRates = (PWLAN_IE_SUPP_RATES) abyDefaultSuppRatesA; |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 407 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 408 | if (pDevice->byRFType == RF_AIROHA7230) { |
| 409 | // AL7230 use single PAPE and connect to PAPE_2.4G |
| 410 | MACvSetBBType(pDevice->PortOffset, BB_TYPE_11G); |
| 411 | pDevice->abyBBVGA[0] = 0x20; |
| 412 | pDevice->abyBBVGA[2] = 0x10; |
| 413 | pDevice->abyBBVGA[3] = 0x10; |
| 414 | BBbReadEmbedded(pDevice->PortOffset, 0xE7, &byData); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 415 | if (byData == 0x1C) |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 416 | BBbWriteEmbedded(pDevice->PortOffset, 0xE7, pDevice->abyBBVGA[0]); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 417 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 418 | } else if (pDevice->byRFType == RF_UW2452) { |
| 419 | MACvSetBBType(pDevice->PortOffset, BB_TYPE_11A); |
| 420 | pDevice->abyBBVGA[0] = 0x18; |
| 421 | BBbReadEmbedded(pDevice->PortOffset, 0xE7, &byData); |
| 422 | if (byData == 0x14) { |
| 423 | BBbWriteEmbedded(pDevice->PortOffset, 0xE7, pDevice->abyBBVGA[0]); |
| 424 | BBbWriteEmbedded(pDevice->PortOffset, 0xE1, 0x57); |
| 425 | } |
| 426 | } else { |
| 427 | MACvSetBBType(pDevice->PortOffset, BB_TYPE_11A); |
| 428 | } |
| 429 | BBbWriteEmbedded(pDevice->PortOffset, 0x88, 0x03); |
| 430 | bySlot = C_SLOT_SHORT; |
| 431 | bySIFS = C_SIFS_A; |
| 432 | byDIFS = C_SIFS_A + 2*C_SLOT_SHORT; |
| 433 | byCWMaxMin = 0xA4; |
| 434 | } else if (ePHYType == PHY_TYPE_11B) { |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 435 | if (pSupportRates == NULL) |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 436 | pSupportRates = (PWLAN_IE_SUPP_RATES) abyDefaultSuppRatesB; |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 437 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 438 | MACvSetBBType(pDevice->PortOffset, BB_TYPE_11B); |
| 439 | if (pDevice->byRFType == RF_AIROHA7230) { |
| 440 | pDevice->abyBBVGA[0] = 0x1C; |
| 441 | pDevice->abyBBVGA[2] = 0x00; |
| 442 | pDevice->abyBBVGA[3] = 0x00; |
| 443 | BBbReadEmbedded(pDevice->PortOffset, 0xE7, &byData); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 444 | if (byData == 0x20) |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 445 | BBbWriteEmbedded(pDevice->PortOffset, 0xE7, pDevice->abyBBVGA[0]); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 446 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 447 | } else if (pDevice->byRFType == RF_UW2452) { |
| 448 | pDevice->abyBBVGA[0] = 0x14; |
| 449 | BBbReadEmbedded(pDevice->PortOffset, 0xE7, &byData); |
| 450 | if (byData == 0x18) { |
| 451 | BBbWriteEmbedded(pDevice->PortOffset, 0xE7, pDevice->abyBBVGA[0]); |
| 452 | BBbWriteEmbedded(pDevice->PortOffset, 0xE1, 0xD3); |
| 453 | } |
| 454 | } |
| 455 | BBbWriteEmbedded(pDevice->PortOffset, 0x88, 0x02); |
| 456 | bySlot = C_SLOT_LONG; |
| 457 | bySIFS = C_SIFS_BG; |
| 458 | byDIFS = C_SIFS_BG + 2*C_SLOT_LONG; |
| 459 | byCWMaxMin = 0xA5; |
| 460 | } else {// PK_TYPE_11GA & PK_TYPE_11GB |
| 461 | if (pSupportRates == NULL) { |
| 462 | pSupportRates = (PWLAN_IE_SUPP_RATES) abyDefaultSuppRatesG; |
| 463 | pExtSupportRates = (PWLAN_IE_SUPP_RATES) abyDefaultExtSuppRatesG; |
| 464 | } |
| 465 | MACvSetBBType(pDevice->PortOffset, BB_TYPE_11G); |
| 466 | if (pDevice->byRFType == RF_AIROHA7230) { |
| 467 | pDevice->abyBBVGA[0] = 0x1C; |
| 468 | pDevice->abyBBVGA[2] = 0x00; |
| 469 | pDevice->abyBBVGA[3] = 0x00; |
| 470 | BBbReadEmbedded(pDevice->PortOffset, 0xE7, &byData); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 471 | if (byData == 0x20) |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 472 | BBbWriteEmbedded(pDevice->PortOffset, 0xE7, pDevice->abyBBVGA[0]); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 473 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 474 | } else if (pDevice->byRFType == RF_UW2452) { |
| 475 | pDevice->abyBBVGA[0] = 0x14; |
| 476 | BBbReadEmbedded(pDevice->PortOffset, 0xE7, &byData); |
| 477 | if (byData == 0x18) { |
| 478 | BBbWriteEmbedded(pDevice->PortOffset, 0xE7, pDevice->abyBBVGA[0]); |
| 479 | BBbWriteEmbedded(pDevice->PortOffset, 0xE1, 0xD3); |
| 480 | } |
| 481 | } |
| 482 | BBbWriteEmbedded(pDevice->PortOffset, 0x88, 0x08); |
| 483 | bySIFS = C_SIFS_BG; |
| 484 | if (VNTWIFIbIsShortSlotTime(wCapInfo)) { |
| 485 | bySlot = C_SLOT_SHORT; |
| 486 | byDIFS = C_SIFS_BG + 2*C_SLOT_SHORT; |
| 487 | } else { |
| 488 | bySlot = C_SLOT_LONG; |
| 489 | byDIFS = C_SIFS_BG + 2*C_SLOT_LONG; |
| 490 | } |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 491 | if (VNTWIFIbyGetMaxSupportRate(pSupportRates, pExtSupportRates) > RATE_11M) |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 492 | byCWMaxMin = 0xA4; |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 493 | else |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 494 | byCWMaxMin = 0xA5; |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 495 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 496 | if (pDevice->bProtectMode != VNTWIFIbIsProtectMode(byERPField)) { |
| 497 | pDevice->bProtectMode = VNTWIFIbIsProtectMode(byERPField); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 498 | if (pDevice->bProtectMode) |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 499 | MACvEnableProtectMD(pDevice->PortOffset); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 500 | else |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 501 | MACvDisableProtectMD(pDevice->PortOffset); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 502 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 503 | } |
| 504 | if (pDevice->bBarkerPreambleMd != VNTWIFIbIsBarkerMode(byERPField)) { |
| 505 | pDevice->bBarkerPreambleMd = VNTWIFIbIsBarkerMode(byERPField); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 506 | if (pDevice->bBarkerPreambleMd) |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 507 | MACvEnableBarkerPreambleMd(pDevice->PortOffset); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 508 | else |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 509 | MACvDisableBarkerPreambleMd(pDevice->PortOffset); |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 510 | } |
| 511 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 512 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 513 | if (pDevice->byRFType == RF_RFMD2959) { |
| 514 | // bcs TX_PE will reserve 3 us |
| 515 | // hardware's processing time here is 2 us. |
| 516 | bySIFS -= 3; |
| 517 | byDIFS -= 3; |
| 518 | //{{ RobertYu: 20041202 |
| 519 | //// TX_PE will reserve 3 us for MAX2829 A mode only, it is for better TX throughput |
| 520 | //// MAC will need 2 us to process, so the SIFS, DIFS can be shorter by 2 us. |
| 521 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 522 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 523 | if (pDevice->bySIFS != bySIFS) { |
| 524 | pDevice->bySIFS = bySIFS; |
| 525 | VNSvOutPortB(pDevice->PortOffset + MAC_REG_SIFS, pDevice->bySIFS); |
| 526 | } |
| 527 | if (pDevice->byDIFS != byDIFS) { |
| 528 | pDevice->byDIFS = byDIFS; |
| 529 | VNSvOutPortB(pDevice->PortOffset + MAC_REG_DIFS, pDevice->byDIFS); |
| 530 | } |
| 531 | if (pDevice->byEIFS != C_EIFS) { |
| 532 | pDevice->byEIFS = C_EIFS; |
| 533 | VNSvOutPortB(pDevice->PortOffset + MAC_REG_EIFS, pDevice->byEIFS); |
| 534 | } |
| 535 | if (pDevice->bySlot != bySlot) { |
| 536 | pDevice->bySlot = bySlot; |
| 537 | VNSvOutPortB(pDevice->PortOffset + MAC_REG_SLOT, pDevice->bySlot); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 538 | if (pDevice->bySlot == C_SLOT_SHORT) |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 539 | pDevice->bShortSlotTime = true; |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 540 | else |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 541 | pDevice->bShortSlotTime = false; |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 542 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 543 | BBvSetShortSlotTime(pDevice); |
| 544 | } |
| 545 | if (pDevice->byCWMaxMin != byCWMaxMin) { |
| 546 | pDevice->byCWMaxMin = byCWMaxMin; |
| 547 | VNSvOutPortB(pDevice->PortOffset + MAC_REG_CWMAXMIN0, pDevice->byCWMaxMin); |
| 548 | } |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 549 | if (VNTWIFIbIsShortPreamble(wCapInfo)) |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 550 | pDevice->byPreambleType = pDevice->byShortPreamble; |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 551 | else |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 552 | pDevice->byPreambleType = 0; |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 553 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 554 | s_vSetRSPINF(pDevice, ePHYType, pSupportRates, pExtSupportRates); |
| 555 | pDevice->eCurrentPHYType = ePHYType; |
| 556 | // set for NDIS OID_802_11SUPPORTED_RATES |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 557 | return true; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 558 | } |
| 559 | |
| 560 | /* |
| 561 | * Description: Sync. TSF counter to BSS |
| 562 | * Get TSF offset and write to HW |
| 563 | * |
| 564 | * Parameters: |
| 565 | * In: |
| 566 | * pDevice - The adapter to be sync. |
| 567 | * byRxRate - data rate of receive beacon |
| 568 | * qwBSSTimestamp - Rx BCN's TSF |
| 569 | * qwLocalTSF - Local TSF |
| 570 | * Out: |
| 571 | * none |
| 572 | * |
| 573 | * Return Value: none |
| 574 | * |
| 575 | */ |
Malcolm Priestley | 0fc2a76 | 2014-08-10 12:21:58 +0100 | [diff] [blame^] | 576 | bool CARDbUpdateTSF(void *pDeviceHandler, unsigned char byRxRate, u64 qwBSSTimestamp, u64 qwLocalTSF) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 577 | { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 578 | PSDevice pDevice = (PSDevice) pDeviceHandler; |
Malcolm Priestley | 0fc2a76 | 2014-08-10 12:21:58 +0100 | [diff] [blame^] | 579 | u64 qwTSFOffset = 0; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 580 | |
Malcolm Priestley | 0fc2a76 | 2014-08-10 12:21:58 +0100 | [diff] [blame^] | 581 | if (qwBSSTimestamp != qwLocalTSF) { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 582 | qwTSFOffset = CARDqGetTSFOffset(byRxRate, qwBSSTimestamp, qwLocalTSF); |
| 583 | // adjust TSF |
| 584 | // HW's TSF add TSF Offset reg |
Malcolm Priestley | 0fc2a76 | 2014-08-10 12:21:58 +0100 | [diff] [blame^] | 585 | VNSvOutPortD(pDevice->PortOffset + MAC_REG_TSFOFST, (u32)qwTSFOffset); |
| 586 | VNSvOutPortD(pDevice->PortOffset + MAC_REG_TSFOFST + 4, (u32)(qwTSFOffset >> 32)); |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 587 | MACvRegBitsOn(pDevice->PortOffset, MAC_REG_TFTCTL, TFTCTL_TSFSYNCEN); |
| 588 | } |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 589 | return true; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 590 | } |
| 591 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 592 | /* |
| 593 | * Description: Set NIC TSF counter for first Beacon time |
| 594 | * Get NEXTTBTT from adjusted TSF and Beacon Interval |
| 595 | * |
| 596 | * Parameters: |
| 597 | * In: |
| 598 | * pDevice - The adapter to be set. |
| 599 | * wBeaconInterval - Beacon Interval |
| 600 | * Out: |
| 601 | * none |
| 602 | * |
Charles Clément | 5a5a2a6 | 2010-08-01 17:15:49 +0200 | [diff] [blame] | 603 | * Return Value: true if succeed; otherwise false |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 604 | * |
| 605 | */ |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 606 | bool CARDbSetBeaconPeriod(void *pDeviceHandler, unsigned short wBeaconInterval) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 607 | { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 608 | PSDevice pDevice = (PSDevice) pDeviceHandler; |
| 609 | unsigned int uBeaconInterval = 0; |
| 610 | unsigned int uLowNextTBTT = 0; |
| 611 | unsigned int uHighRemain = 0; |
| 612 | unsigned int uLowRemain = 0; |
Malcolm Priestley | 0fc2a76 | 2014-08-10 12:21:58 +0100 | [diff] [blame^] | 613 | u64 qwNextTBTT = 0; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 614 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 615 | CARDbGetCurrentTSF(pDevice->PortOffset, &qwNextTBTT); //Get Local TSF counter |
| 616 | uBeaconInterval = wBeaconInterval * 1024; |
| 617 | // Next TBTT = ((local_current_TSF / beacon_interval) + 1) * beacon_interval |
Malcolm Priestley | 0fc2a76 | 2014-08-10 12:21:58 +0100 | [diff] [blame^] | 618 | uLowNextTBTT = ((qwNextTBTT & 0xffffffffULL) >> 10) << 10; |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 619 | uLowRemain = (uLowNextTBTT) % uBeaconInterval; |
| 620 | // high dword (mod) bcn |
Malcolm Priestley | 0fc2a76 | 2014-08-10 12:21:58 +0100 | [diff] [blame^] | 621 | uHighRemain = (((0xffffffff % uBeaconInterval) + 1) * (u32)(qwNextTBTT >> 32)) |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 622 | % uBeaconInterval; |
| 623 | uLowRemain = (uHighRemain + uLowRemain) % uBeaconInterval; |
| 624 | uLowRemain = uBeaconInterval - uLowRemain; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 625 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 626 | // check if carry when add one beacon interval |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 627 | if ((~uLowNextTBTT) < uLowRemain) |
Malcolm Priestley | 0fc2a76 | 2014-08-10 12:21:58 +0100 | [diff] [blame^] | 628 | qwNextTBTT = ((qwNextTBTT >> 32) + 1) << 32; |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 629 | |
Malcolm Priestley | 0fc2a76 | 2014-08-10 12:21:58 +0100 | [diff] [blame^] | 630 | qwNextTBTT = (qwNextTBTT & 0xffffffff00000000ULL) | |
| 631 | (u64)(uLowNextTBTT + uLowRemain); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 632 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 633 | // set HW beacon interval |
| 634 | VNSvOutPortW(pDevice->PortOffset + MAC_REG_BI, wBeaconInterval); |
| 635 | pDevice->wBeaconInterval = wBeaconInterval; |
| 636 | // Set NextTBTT |
Malcolm Priestley | 0fc2a76 | 2014-08-10 12:21:58 +0100 | [diff] [blame^] | 637 | VNSvOutPortD(pDevice->PortOffset + MAC_REG_NEXTTBTT, (u32)qwNextTBTT); |
| 638 | VNSvOutPortD(pDevice->PortOffset + MAC_REG_NEXTTBTT + 4, (u32)(qwNextTBTT >> 32)); |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 639 | MACvRegBitsOn(pDevice->PortOffset, MAC_REG_TFTCTL, TFTCTL_TBTTSYNCEN); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 640 | |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 641 | return true; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 642 | } |
| 643 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 644 | /* |
| 645 | * Description: Card Stop Hardware Tx |
| 646 | * |
| 647 | * Parameters: |
| 648 | * In: |
| 649 | * pDeviceHandler - The adapter to be set |
| 650 | * ePktType - Packet type to stop |
| 651 | * Out: |
| 652 | * none |
| 653 | * |
Charles Clément | 5a5a2a6 | 2010-08-01 17:15:49 +0200 | [diff] [blame] | 654 | * Return Value: true if all data packet complete; otherwise false. |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 655 | * |
| 656 | */ |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 657 | bool CARDbStopTxPacket(void *pDeviceHandler, CARD_PKT_TYPE ePktType) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 658 | { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 659 | PSDevice pDevice = (PSDevice) pDeviceHandler; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 660 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 661 | if (ePktType == PKT_TYPE_802_11_ALL) { |
| 662 | pDevice->bStopBeacon = true; |
| 663 | pDevice->bStopTx0Pkt = true; |
| 664 | pDevice->bStopDataPkt = true; |
| 665 | } else if (ePktType == PKT_TYPE_802_11_BCN) { |
| 666 | pDevice->bStopBeacon = true; |
| 667 | } else if (ePktType == PKT_TYPE_802_11_MNG) { |
| 668 | pDevice->bStopTx0Pkt = true; |
| 669 | } else if (ePktType == PKT_TYPE_802_11_DATA) { |
| 670 | pDevice->bStopDataPkt = true; |
| 671 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 672 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 673 | if (pDevice->bStopBeacon == true) { |
| 674 | if (pDevice->bIsBeaconBufReadySet == true) { |
| 675 | if (pDevice->cbBeaconBufReadySetCnt < WAIT_BEACON_TX_DOWN_TMO) { |
| 676 | pDevice->cbBeaconBufReadySetCnt++; |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 677 | return false; |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 678 | } |
| 679 | } |
| 680 | pDevice->bIsBeaconBufReadySet = false; |
| 681 | pDevice->cbBeaconBufReadySetCnt = 0; |
| 682 | MACvRegBitsOff(pDevice->PortOffset, MAC_REG_TCR, TCR_AUTOBCNTX); |
| 683 | } |
| 684 | // wait all TD0 complete |
| 685 | if (pDevice->bStopTx0Pkt == true) { |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 686 | if (pDevice->iTDUsed[TYPE_TXDMA0] != 0) |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 687 | return false; |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 688 | } |
| 689 | // wait all Data TD complete |
| 690 | if (pDevice->bStopDataPkt == true) { |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 691 | if (pDevice->iTDUsed[TYPE_AC0DMA] != 0) |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 692 | return false; |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 693 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 694 | |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 695 | return true; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 696 | } |
| 697 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 698 | /* |
| 699 | * Description: Card Start Hardware Tx |
| 700 | * |
| 701 | * Parameters: |
| 702 | * In: |
| 703 | * pDeviceHandler - The adapter to be set |
| 704 | * ePktType - Packet type to start |
| 705 | * Out: |
| 706 | * none |
| 707 | * |
Charles Clément | 5a5a2a6 | 2010-08-01 17:15:49 +0200 | [diff] [blame] | 708 | * Return Value: true if success; false if failed. |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 709 | * |
| 710 | */ |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 711 | bool CARDbStartTxPacket(void *pDeviceHandler, CARD_PKT_TYPE ePktType) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 712 | { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 713 | PSDevice pDevice = (PSDevice) pDeviceHandler; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 714 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 715 | if (ePktType == PKT_TYPE_802_11_ALL) { |
| 716 | pDevice->bStopBeacon = false; |
| 717 | pDevice->bStopTx0Pkt = false; |
| 718 | pDevice->bStopDataPkt = false; |
| 719 | } else if (ePktType == PKT_TYPE_802_11_BCN) { |
| 720 | pDevice->bStopBeacon = false; |
| 721 | } else if (ePktType == PKT_TYPE_802_11_MNG) { |
| 722 | pDevice->bStopTx0Pkt = false; |
| 723 | } else if (ePktType == PKT_TYPE_802_11_DATA) { |
| 724 | pDevice->bStopDataPkt = false; |
| 725 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 726 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 727 | if ((pDevice->bStopBeacon == false) && |
| 728 | (pDevice->bBeaconBufReady == true) && |
| 729 | (pDevice->eOPMode == OP_MODE_ADHOC)) { |
| 730 | MACvRegBitsOn(pDevice->PortOffset, MAC_REG_TCR, TCR_AUTOBCNTX); |
| 731 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 732 | |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 733 | return true; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 734 | } |
| 735 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 736 | /* |
| 737 | * Description: Card Set BSSID value |
| 738 | * |
| 739 | * Parameters: |
| 740 | * In: |
| 741 | * pDeviceHandler - The adapter to be set |
| 742 | * pbyBSSID - pointer to BSSID field |
| 743 | * bAdhoc - flag to indicate IBSS |
| 744 | * Out: |
| 745 | * none |
| 746 | * |
Charles Clément | 5a5a2a6 | 2010-08-01 17:15:49 +0200 | [diff] [blame] | 747 | * Return Value: true if success; false if failed. |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 748 | * |
| 749 | */ |
Charles Clément | 7b6a001 | 2010-08-01 17:15:50 +0200 | [diff] [blame] | 750 | bool CARDbSetBSSID(void *pDeviceHandler, unsigned char *pbyBSSID, CARD_OP_MODE eOPMode) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 751 | { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 752 | PSDevice pDevice = (PSDevice) pDeviceHandler; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 753 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 754 | MACvWriteBSSIDAddress(pDevice->PortOffset, pbyBSSID); |
| 755 | memcpy(pDevice->abyBSSID, pbyBSSID, WLAN_BSSID_LEN); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 756 | if (eOPMode == OP_MODE_ADHOC) |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 757 | MACvRegBitsOn(pDevice->PortOffset, MAC_REG_HOSTCR, HOSTCR_ADHOC); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 758 | else |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 759 | MACvRegBitsOff(pDevice->PortOffset, MAC_REG_HOSTCR, HOSTCR_ADHOC); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 760 | |
| 761 | if (eOPMode == OP_MODE_AP) |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 762 | MACvRegBitsOn(pDevice->PortOffset, MAC_REG_HOSTCR, HOSTCR_AP); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 763 | else |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 764 | MACvRegBitsOff(pDevice->PortOffset, MAC_REG_HOSTCR, HOSTCR_AP); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 765 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 766 | if (eOPMode == OP_MODE_UNKNOWN) { |
| 767 | MACvRegBitsOff(pDevice->PortOffset, MAC_REG_RCR, RCR_BSSID); |
| 768 | pDevice->bBSSIDFilter = false; |
| 769 | pDevice->byRxMode &= ~RCR_BSSID; |
| 770 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "wcmd: rx_mode = %x\n", pDevice->byRxMode); |
| 771 | } else { |
| 772 | if (is_zero_ether_addr(pDevice->abyBSSID) == false) { |
| 773 | MACvRegBitsOn(pDevice->PortOffset, MAC_REG_RCR, RCR_BSSID); |
| 774 | pDevice->bBSSIDFilter = true; |
| 775 | pDevice->byRxMode |= RCR_BSSID; |
| 776 | } |
| 777 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "wmgr: rx_mode = %x\n", pDevice->byRxMode); |
| 778 | } |
| 779 | // Adopt BSS state in Adapter Device Object |
| 780 | pDevice->eOPMode = eOPMode; |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 781 | return true; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 782 | } |
| 783 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 784 | /* |
| 785 | * Description: Card indicate status |
| 786 | * |
| 787 | * Parameters: |
| 788 | * In: |
| 789 | * pDeviceHandler - The adapter to be set |
| 790 | * eStatus - Status |
| 791 | * Out: |
| 792 | * none |
| 793 | * |
Charles Clément | 5a5a2a6 | 2010-08-01 17:15:49 +0200 | [diff] [blame] | 794 | * Return Value: true if success; false if failed. |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 795 | * |
| 796 | */ |
| 797 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 798 | /* |
| 799 | * Description: Save Assoc info. contain in assoc. response frame |
| 800 | * |
| 801 | * Parameters: |
| 802 | * In: |
| 803 | * pDevice - The adapter to be set |
| 804 | * wCapabilityInfo - Capability information |
| 805 | * wStatus - Status code |
| 806 | * wAID - Assoc. ID |
| 807 | * uLen - Length of IEs |
| 808 | * pbyIEs - pointer to IEs |
| 809 | * Out: |
| 810 | * none |
| 811 | * |
Charles Clément | 5a5a2a6 | 2010-08-01 17:15:49 +0200 | [diff] [blame] | 812 | * Return Value: true if succeed; otherwise false |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 813 | * |
| 814 | */ |
Charles Clément | 7b6a001 | 2010-08-01 17:15:50 +0200 | [diff] [blame] | 815 | bool CARDbSetTxDataRate( |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 816 | void *pDeviceHandler, |
| 817 | unsigned short wDataRate |
| 818 | ) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 819 | { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 820 | PSDevice pDevice = (PSDevice) pDeviceHandler; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 821 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 822 | pDevice->wCurrentRate = wDataRate; |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 823 | return true; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 824 | } |
| 825 | |
| 826 | /*+ |
| 827 | * |
| 828 | * Routine Description: |
| 829 | * Consider to power down when no more packets to tx or rx. |
| 830 | * |
| 831 | * Parameters: |
| 832 | * In: |
| 833 | * pDevice - The adapter to be set |
| 834 | * Out: |
| 835 | * none |
| 836 | * |
Charles Clément | 5a5a2a6 | 2010-08-01 17:15:49 +0200 | [diff] [blame] | 837 | * Return Value: true if power down success; otherwise false |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 838 | * |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 839 | -*/ |
Charles Clément | 7b6a001 | 2010-08-01 17:15:50 +0200 | [diff] [blame] | 840 | bool |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 841 | CARDbPowerDown( |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 842 | void *pDeviceHandler |
| 843 | ) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 844 | { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 845 | PSDevice pDevice = (PSDevice)pDeviceHandler; |
| 846 | unsigned int uIdx; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 847 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 848 | // check if already in Doze mode |
| 849 | if (MACbIsRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_PS)) |
| 850 | return true; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 851 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 852 | // Froce PSEN on |
| 853 | MACvRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_PSEN); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 854 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 855 | // check if all TD are empty, |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 856 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 857 | for (uIdx = 0; uIdx < TYPE_MAXTD; uIdx++) { |
| 858 | if (pDevice->iTDUsed[uIdx] != 0) |
| 859 | return false; |
| 860 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 861 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 862 | MACvRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_GO2DOZE); |
| 863 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Go to Doze ZZZZZZZZZZZZZZZ\n"); |
| 864 | return true; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 865 | } |
| 866 | |
| 867 | /* |
| 868 | * Description: Turn off Radio power |
| 869 | * |
| 870 | * Parameters: |
| 871 | * In: |
| 872 | * pDevice - The adapter to be turned off |
| 873 | * Out: |
| 874 | * none |
| 875 | * |
Charles Clément | 5a5a2a6 | 2010-08-01 17:15:49 +0200 | [diff] [blame] | 876 | * Return Value: true if success; otherwise false |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 877 | * |
| 878 | */ |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 879 | bool CARDbRadioPowerOff(void *pDeviceHandler) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 880 | { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 881 | PSDevice pDevice = (PSDevice)pDeviceHandler; |
| 882 | bool bResult = true; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 883 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 884 | if (pDevice->bRadioOff == true) |
| 885 | return true; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 886 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 887 | switch (pDevice->byRFType) { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 888 | case RF_RFMD2959: |
| 889 | MACvWordRegBitsOff(pDevice->PortOffset, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_TXPEINV); |
| 890 | MACvWordRegBitsOn(pDevice->PortOffset, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_SWPE1); |
| 891 | break; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 892 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 893 | case RF_AIROHA: |
| 894 | case RF_AL2230S: |
| 895 | case RF_AIROHA7230: //RobertYu:20050104 |
| 896 | MACvWordRegBitsOff(pDevice->PortOffset, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_SWPE2); |
| 897 | MACvWordRegBitsOff(pDevice->PortOffset, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_SWPE3); |
| 898 | break; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 899 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 900 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 901 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 902 | MACvRegBitsOff(pDevice->PortOffset, MAC_REG_HOSTCR, HOSTCR_RXON); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 903 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 904 | BBvSetDeepSleep(pDevice->PortOffset, pDevice->byLocalID); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 905 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 906 | pDevice->bRadioOff = true; |
| 907 | //2007-0409-03,<Add> by chester |
Guillaume Clement | 941ead9 | 2014-07-25 01:06:21 +0200 | [diff] [blame] | 908 | pr_debug("chester power off\n"); |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 909 | MACvRegBitsOn(pDevice->PortOffset, MAC_REG_GPIOCTL0, LED_ACTSET); //LED issue |
| 910 | return bResult; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 911 | } |
| 912 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 913 | /* |
| 914 | * Description: Turn on Radio power |
| 915 | * |
| 916 | * Parameters: |
| 917 | * In: |
| 918 | * pDevice - The adapter to be turned on |
| 919 | * Out: |
| 920 | * none |
| 921 | * |
Charles Clément | 5a5a2a6 | 2010-08-01 17:15:49 +0200 | [diff] [blame] | 922 | * Return Value: true if success; otherwise false |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 923 | * |
| 924 | */ |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 925 | bool CARDbRadioPowerOn(void *pDeviceHandler) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 926 | { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 927 | PSDevice pDevice = (PSDevice) pDeviceHandler; |
| 928 | bool bResult = true; |
Igor Bezukh | f9dc1a8 | 2014-07-16 10:45:30 +0300 | [diff] [blame] | 929 | |
Guillaume Clement | 941ead9 | 2014-07-25 01:06:21 +0200 | [diff] [blame] | 930 | pr_debug("chester power on\n"); |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 931 | if (pDevice->bRadioControlOff == true) { |
Guillaume Clement | a161342 | 2014-07-25 01:06:22 +0200 | [diff] [blame] | 932 | if (pDevice->bHWRadioOff == true) |
| 933 | pr_debug("chester bHWRadioOff\n"); |
| 934 | if (pDevice->bRadioControlOff == true) |
| 935 | pr_debug("chester bRadioControlOff\n"); |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 936 | return false; } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 937 | |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 938 | if (pDevice->bRadioOff == false) { |
Guillaume Clement | 941ead9 | 2014-07-25 01:06:21 +0200 | [diff] [blame] | 939 | pr_debug("chester pbRadioOff\n"); |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 940 | return true; } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 941 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 942 | BBvExitDeepSleep(pDevice->PortOffset, pDevice->byLocalID); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 943 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 944 | MACvRegBitsOn(pDevice->PortOffset, MAC_REG_HOSTCR, HOSTCR_RXON); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 945 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 946 | switch (pDevice->byRFType) { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 947 | case RF_RFMD2959: |
| 948 | MACvWordRegBitsOn(pDevice->PortOffset, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_TXPEINV); |
| 949 | MACvWordRegBitsOff(pDevice->PortOffset, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_SWPE1); |
| 950 | break; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 951 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 952 | case RF_AIROHA: |
| 953 | case RF_AL2230S: |
| 954 | case RF_AIROHA7230: //RobertYu:20050104 |
| 955 | MACvWordRegBitsOn(pDevice->PortOffset, MAC_REG_SOFTPWRCTL, (SOFTPWRCTL_SWPE2 | |
| 956 | SOFTPWRCTL_SWPE3)); |
| 957 | break; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 958 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 959 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 960 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 961 | pDevice->bRadioOff = false; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 962 | // 2007-0409-03,<Add> by chester |
Guillaume Clement | 941ead9 | 2014-07-25 01:06:21 +0200 | [diff] [blame] | 963 | pr_debug("chester power on\n"); |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 964 | MACvRegBitsOff(pDevice->PortOffset, MAC_REG_GPIOCTL0, LED_ACTSET); //LED issue |
| 965 | return bResult; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 966 | } |
| 967 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 968 | bool CARDbRemoveKey(void *pDeviceHandler, unsigned char *pbyBSSID) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 969 | { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 970 | PSDevice pDevice = (PSDevice) pDeviceHandler; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 971 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 972 | KeybRemoveAllKey(&(pDevice->sKey), pbyBSSID, pDevice->PortOffset); |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 973 | return true; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 974 | } |
| 975 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 976 | /* |
| 977 | * |
| 978 | * Description: |
| 979 | * Add BSSID in PMKID Candidate list. |
| 980 | * |
| 981 | * Parameters: |
| 982 | * In: |
| 983 | * hDeviceContext - device structure point |
| 984 | * pbyBSSID - BSSID address for adding |
| 985 | * wRSNCap - BSS's RSN capability |
| 986 | * Out: |
| 987 | * none |
| 988 | * |
| 989 | * Return Value: none. |
| 990 | * |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 991 | -*/ |
Charles Clément | 7b6a001 | 2010-08-01 17:15:50 +0200 | [diff] [blame] | 992 | bool |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 993 | CARDbAdd_PMKID_Candidate( |
| 994 | void *pDeviceHandler, |
| 995 | unsigned char *pbyBSSID, |
| 996 | bool bRSNCapExist, |
| 997 | unsigned short wRSNCap |
| 998 | ) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 999 | { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1000 | PSDevice pDevice = (PSDevice) pDeviceHandler; |
Martin Kepplinger | ff87dbc | 2014-06-16 18:05:36 +0200 | [diff] [blame] | 1001 | struct pmkid_candidate *pCandidateList; |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1002 | unsigned int ii = 0; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1003 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1004 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "bAdd_PMKID_Candidate START: (%d)\n", (int)pDevice->gsPMKIDCandidate.NumCandidates); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1005 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1006 | if (pDevice->gsPMKIDCandidate.NumCandidates >= MAX_PMKIDLIST) { |
| 1007 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "vFlush_PMKID_Candidate: 3\n"); |
| 1008 | memset(&pDevice->gsPMKIDCandidate, 0, sizeof(SPMKIDCandidateEvent)); |
| 1009 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1010 | |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 1011 | for (ii = 0; ii < 6; ii++) |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1012 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%02X ", *(pbyBSSID + ii)); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 1013 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1014 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "\n"); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1015 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1016 | // Update Old Candidate |
| 1017 | for (ii = 0; ii < pDevice->gsPMKIDCandidate.NumCandidates; ii++) { |
| 1018 | pCandidateList = &pDevice->gsPMKIDCandidate.CandidateList[ii]; |
| 1019 | if (!memcmp(pCandidateList->BSSID, pbyBSSID, ETH_ALEN)) { |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 1020 | if (bRSNCapExist && (wRSNCap & BIT0)) |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1021 | pCandidateList->Flags |= NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED; |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 1022 | else |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1023 | pCandidateList->Flags &= ~(NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 1024 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1025 | return true; |
| 1026 | } |
| 1027 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1028 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1029 | // New Candidate |
| 1030 | pCandidateList = &pDevice->gsPMKIDCandidate.CandidateList[pDevice->gsPMKIDCandidate.NumCandidates]; |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 1031 | if (bRSNCapExist && (wRSNCap & BIT0)) |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1032 | pCandidateList->Flags |= NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED; |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 1033 | else |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1034 | pCandidateList->Flags &= ~(NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 1035 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1036 | memcpy(pCandidateList->BSSID, pbyBSSID, ETH_ALEN); |
| 1037 | pDevice->gsPMKIDCandidate.NumCandidates++; |
| 1038 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "NumCandidates:%d\n", (int)pDevice->gsPMKIDCandidate.NumCandidates); |
| 1039 | return true; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1040 | } |
| 1041 | |
Charles Clément | 830a619 | 2010-05-07 12:30:20 -0700 | [diff] [blame] | 1042 | void * |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1043 | CARDpGetCurrentAddress( |
| 1044 | void *pDeviceHandler |
| 1045 | ) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1046 | { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1047 | PSDevice pDevice = (PSDevice) pDeviceHandler; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1048 | |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 1049 | return pDevice->abyCurrentNetAddr; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1050 | } |
| 1051 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1052 | /* |
| 1053 | * |
| 1054 | * Description: |
| 1055 | * Start Spectrum Measure defined in 802.11h |
| 1056 | * |
| 1057 | * Parameters: |
| 1058 | * In: |
| 1059 | * hDeviceContext - device structure point |
| 1060 | * Out: |
| 1061 | * none |
| 1062 | * |
| 1063 | * Return Value: none. |
| 1064 | * |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1065 | -*/ |
Charles Clément | 7b6a001 | 2010-08-01 17:15:50 +0200 | [diff] [blame] | 1066 | bool |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1067 | CARDbStartMeasure( |
| 1068 | void *pDeviceHandler, |
| 1069 | void *pvMeasureEIDs, |
| 1070 | unsigned int uNumOfMeasureEIDs |
| 1071 | ) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1072 | { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1073 | PSDevice pDevice = (PSDevice) pDeviceHandler; |
| 1074 | PWLAN_IE_MEASURE_REQ pEID = (PWLAN_IE_MEASURE_REQ) pvMeasureEIDs; |
Malcolm Priestley | 0fc2a76 | 2014-08-10 12:21:58 +0100 | [diff] [blame^] | 1075 | u64 qwCurrTSF; |
| 1076 | u64 qwStartTSF; |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1077 | bool bExpired = true; |
| 1078 | unsigned short wDuration = 0; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1079 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1080 | if ((pEID == NULL) || |
| 1081 | (uNumOfMeasureEIDs == 0)) { |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 1082 | return true; |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1083 | } |
| 1084 | CARDbGetCurrentTSF(pDevice->PortOffset, &qwCurrTSF); |
| 1085 | if (pDevice->bMeasureInProgress == true) { |
| 1086 | pDevice->bMeasureInProgress = false; |
| 1087 | VNSvOutPortB(pDevice->PortOffset + MAC_REG_RCR, pDevice->byOrgRCR); |
| 1088 | MACvSelectPage1(pDevice->PortOffset); |
| 1089 | VNSvOutPortD(pDevice->PortOffset + MAC_REG_MAR0, pDevice->dwOrgMAR0); |
| 1090 | VNSvOutPortD(pDevice->PortOffset + MAC_REG_MAR4, pDevice->dwOrgMAR4); |
| 1091 | // clear measure control |
| 1092 | MACvRegBitsOff(pDevice->PortOffset, MAC_REG_MSRCTL, MSRCTL_EN); |
| 1093 | MACvSelectPage0(pDevice->PortOffset); |
| 1094 | set_channel(pDevice, pDevice->byOrgChannel); |
| 1095 | MACvSelectPage1(pDevice->PortOffset); |
| 1096 | MACvRegBitsOn(pDevice->PortOffset, MAC_REG_MSRCTL+1, MSRCTL1_TXPAUSE); |
| 1097 | MACvSelectPage0(pDevice->PortOffset); |
| 1098 | } |
| 1099 | pDevice->uNumOfMeasureEIDs = uNumOfMeasureEIDs; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1100 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1101 | do { |
| 1102 | pDevice->pCurrMeasureEID = pEID; |
| 1103 | pEID++; |
| 1104 | pDevice->uNumOfMeasureEIDs--; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1105 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1106 | if (pDevice->byLocalID > REV_ID_VT3253_B1) { |
Malcolm Priestley | 0fc2a76 | 2014-08-10 12:21:58 +0100 | [diff] [blame^] | 1107 | qwStartTSF = *((u64 *)(pDevice->pCurrMeasureEID->sReq.abyStartTime)); |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1108 | wDuration = *((unsigned short *)(pDevice->pCurrMeasureEID->sReq.abyDuration)); |
| 1109 | wDuration += 1; // 1 TU for channel switching |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1110 | |
Malcolm Priestley | 0fc2a76 | 2014-08-10 12:21:58 +0100 | [diff] [blame^] | 1111 | if (qwStartTSF == 0) { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1112 | // start immediately by setting start TSF == current TSF + 2 TU |
Malcolm Priestley | 0fc2a76 | 2014-08-10 12:21:58 +0100 | [diff] [blame^] | 1113 | qwStartTSF = qwCurrTSF + 2048; |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 1114 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1115 | bExpired = false; |
| 1116 | break; |
| 1117 | } else { |
| 1118 | // start at setting start TSF - 1TU(for channel switching) |
Malcolm Priestley | 0fc2a76 | 2014-08-10 12:21:58 +0100 | [diff] [blame^] | 1119 | qwStartTSF -= 1024; |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1120 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1121 | |
Malcolm Priestley | 0fc2a76 | 2014-08-10 12:21:58 +0100 | [diff] [blame^] | 1122 | if (qwCurrTSF < qwStartTSF) { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1123 | bExpired = false; |
| 1124 | break; |
| 1125 | } |
| 1126 | VNTWIFIbMeasureReport(pDevice->pMgmt, |
| 1127 | false, |
| 1128 | pDevice->pCurrMeasureEID, |
| 1129 | MEASURE_MODE_LATE, |
| 1130 | pDevice->byBasicMap, |
| 1131 | pDevice->byCCAFraction, |
| 1132 | pDevice->abyRPIs |
| 1133 | ); |
| 1134 | } else { |
| 1135 | // hardware do not support measure |
| 1136 | VNTWIFIbMeasureReport(pDevice->pMgmt, |
| 1137 | false, |
| 1138 | pDevice->pCurrMeasureEID, |
| 1139 | MEASURE_MODE_INCAPABLE, |
| 1140 | pDevice->byBasicMap, |
| 1141 | pDevice->byCCAFraction, |
| 1142 | pDevice->abyRPIs |
| 1143 | ); |
| 1144 | } |
| 1145 | } while (pDevice->uNumOfMeasureEIDs != 0); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1146 | |
Teodora Baluta | 1208f14 | 2013-11-10 17:12:42 +0200 | [diff] [blame] | 1147 | if (!bExpired) { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1148 | MACvSelectPage1(pDevice->PortOffset); |
Malcolm Priestley | 0fc2a76 | 2014-08-10 12:21:58 +0100 | [diff] [blame^] | 1149 | VNSvOutPortD(pDevice->PortOffset + MAC_REG_MSRSTART, (u32)qwStartTSF); |
| 1150 | VNSvOutPortD(pDevice->PortOffset + MAC_REG_MSRSTART + 4, (u32)(qwStartTSF >> 32)); |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1151 | VNSvOutPortW(pDevice->PortOffset + MAC_REG_MSRDURATION, wDuration); |
| 1152 | MACvRegBitsOn(pDevice->PortOffset, MAC_REG_MSRCTL, MSRCTL_EN); |
| 1153 | MACvSelectPage0(pDevice->PortOffset); |
| 1154 | } else { |
| 1155 | // all measure start time expired we should complete action |
| 1156 | VNTWIFIbMeasureReport(pDevice->pMgmt, |
| 1157 | true, |
| 1158 | NULL, |
| 1159 | 0, |
| 1160 | pDevice->byBasicMap, |
| 1161 | pDevice->byCCAFraction, |
| 1162 | pDevice->abyRPIs |
| 1163 | ); |
| 1164 | } |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 1165 | return true; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1166 | } |
| 1167 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1168 | /* |
| 1169 | * |
| 1170 | * Description: |
| 1171 | * Do Channel Switch defined in 802.11h |
| 1172 | * |
| 1173 | * Parameters: |
| 1174 | * In: |
| 1175 | * hDeviceContext - device structure point |
| 1176 | * Out: |
| 1177 | * none |
| 1178 | * |
| 1179 | * Return Value: none. |
| 1180 | * |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1181 | -*/ |
Charles Clément | 7b6a001 | 2010-08-01 17:15:50 +0200 | [diff] [blame] | 1182 | bool |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1183 | CARDbChannelSwitch( |
| 1184 | void *pDeviceHandler, |
| 1185 | unsigned char byMode, |
| 1186 | unsigned char byNewChannel, |
| 1187 | unsigned char byCount |
| 1188 | ) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1189 | { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1190 | PSDevice pDevice = (PSDevice) pDeviceHandler; |
| 1191 | bool bResult = true; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1192 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1193 | if (byCount == 0) { |
| 1194 | bResult = set_channel(pDevice, byNewChannel); |
| 1195 | VNTWIFIbChannelSwitch(pDevice->pMgmt, byNewChannel); |
| 1196 | MACvSelectPage1(pDevice->PortOffset); |
| 1197 | MACvRegBitsOn(pDevice->PortOffset, MAC_REG_MSRCTL+1, MSRCTL1_TXPAUSE); |
| 1198 | MACvSelectPage0(pDevice->PortOffset); |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 1199 | return bResult; |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1200 | } |
| 1201 | pDevice->byChannelSwitchCount = byCount; |
| 1202 | pDevice->byNewChannel = byNewChannel; |
| 1203 | pDevice->bChannelSwitch = true; |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 1204 | if (byMode == 1) |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1205 | bResult = CARDbStopTxPacket(pDevice, PKT_TYPE_802_11_ALL); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 1206 | |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 1207 | return bResult; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1208 | } |
| 1209 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1210 | /* |
| 1211 | * |
| 1212 | * Description: |
| 1213 | * Handle Quiet EID defined in 802.11h |
| 1214 | * |
| 1215 | * Parameters: |
| 1216 | * In: |
| 1217 | * hDeviceContext - device structure point |
| 1218 | * Out: |
| 1219 | * none |
| 1220 | * |
| 1221 | * Return Value: none. |
| 1222 | * |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1223 | -*/ |
Charles Clément | 7b6a001 | 2010-08-01 17:15:50 +0200 | [diff] [blame] | 1224 | bool |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1225 | CARDbSetQuiet( |
| 1226 | void *pDeviceHandler, |
| 1227 | bool bResetQuiet, |
| 1228 | unsigned char byQuietCount, |
| 1229 | unsigned char byQuietPeriod, |
| 1230 | unsigned short wQuietDuration, |
| 1231 | unsigned short wQuietOffset |
| 1232 | ) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1233 | { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1234 | PSDevice pDevice = (PSDevice) pDeviceHandler; |
| 1235 | unsigned int ii = 0; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1236 | |
Teodora Baluta | 1208f14 | 2013-11-10 17:12:42 +0200 | [diff] [blame] | 1237 | if (bResetQuiet) { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1238 | MACvRegBitsOff(pDevice->PortOffset, MAC_REG_MSRCTL, (MSRCTL_QUIETTXCHK | MSRCTL_QUIETEN)); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 1239 | for (ii = 0; ii < MAX_QUIET_COUNT; ii++) |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1240 | pDevice->sQuiet[ii].bEnable = false; |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 1241 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1242 | pDevice->uQuietEnqueue = 0; |
| 1243 | pDevice->bEnableFirstQuiet = false; |
| 1244 | pDevice->bQuietEnable = false; |
| 1245 | pDevice->byQuietStartCount = byQuietCount; |
| 1246 | } |
| 1247 | if (pDevice->sQuiet[pDevice->uQuietEnqueue].bEnable == false) { |
| 1248 | pDevice->sQuiet[pDevice->uQuietEnqueue].bEnable = true; |
| 1249 | pDevice->sQuiet[pDevice->uQuietEnqueue].byPeriod = byQuietPeriod; |
| 1250 | pDevice->sQuiet[pDevice->uQuietEnqueue].wDuration = wQuietDuration; |
| 1251 | pDevice->sQuiet[pDevice->uQuietEnqueue].dwStartTime = (unsigned long) byQuietCount; |
| 1252 | pDevice->sQuiet[pDevice->uQuietEnqueue].dwStartTime *= pDevice->wBeaconInterval; |
| 1253 | pDevice->sQuiet[pDevice->uQuietEnqueue].dwStartTime += wQuietOffset; |
| 1254 | pDevice->uQuietEnqueue++; |
| 1255 | pDevice->uQuietEnqueue %= MAX_QUIET_COUNT; |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 1256 | if (pDevice->byQuietStartCount < byQuietCount) |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1257 | pDevice->byQuietStartCount = byQuietCount; |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1258 | } |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 1259 | return true; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1260 | } |
| 1261 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1262 | /* |
| 1263 | * |
| 1264 | * Description: |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1265 | * Do Quiet, It will be called by either ISR(after start) |
Justin P. Mattock | 789d1ae | 2012-08-20 08:43:13 -0700 | [diff] [blame] | 1266 | * or VNTWIFI(before start) so we do not need a SPINLOCK |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1267 | * |
| 1268 | * Parameters: |
| 1269 | * In: |
| 1270 | * hDeviceContext - device structure point |
| 1271 | * Out: |
| 1272 | * none |
| 1273 | * |
| 1274 | * Return Value: none. |
| 1275 | * |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1276 | -*/ |
Charles Clément | 7b6a001 | 2010-08-01 17:15:50 +0200 | [diff] [blame] | 1277 | bool |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1278 | CARDbStartQuiet( |
| 1279 | void *pDeviceHandler |
| 1280 | ) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1281 | { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1282 | PSDevice pDevice = (PSDevice) pDeviceHandler; |
| 1283 | unsigned int ii = 0; |
| 1284 | unsigned long dwStartTime = 0xFFFFFFFF; |
| 1285 | unsigned int uCurrentQuietIndex = 0; |
| 1286 | unsigned long dwNextTime = 0; |
| 1287 | unsigned long dwGap = 0; |
| 1288 | unsigned long dwDuration = 0; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1289 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1290 | for (ii = 0; ii < MAX_QUIET_COUNT; ii++) { |
| 1291 | if ((pDevice->sQuiet[ii].bEnable == true) && |
| 1292 | (dwStartTime > pDevice->sQuiet[ii].dwStartTime)) { |
| 1293 | dwStartTime = pDevice->sQuiet[ii].dwStartTime; |
| 1294 | uCurrentQuietIndex = ii; |
| 1295 | } |
| 1296 | } |
| 1297 | if (dwStartTime == 0xFFFFFFFF) { |
| 1298 | // no more quiet |
| 1299 | pDevice->bQuietEnable = false; |
| 1300 | MACvRegBitsOff(pDevice->PortOffset, MAC_REG_MSRCTL, (MSRCTL_QUIETTXCHK | MSRCTL_QUIETEN)); |
| 1301 | } else { |
| 1302 | if (pDevice->bQuietEnable == false) { |
| 1303 | // first quiet |
| 1304 | pDevice->byQuietStartCount--; |
| 1305 | dwNextTime = pDevice->sQuiet[uCurrentQuietIndex].dwStartTime; |
| 1306 | dwNextTime %= pDevice->wBeaconInterval; |
| 1307 | MACvSelectPage1(pDevice->PortOffset); |
| 1308 | VNSvOutPortW(pDevice->PortOffset + MAC_REG_QUIETINIT, (unsigned short) dwNextTime); |
| 1309 | VNSvOutPortW(pDevice->PortOffset + MAC_REG_QUIETDUR, (unsigned short) pDevice->sQuiet[uCurrentQuietIndex].wDuration); |
| 1310 | if (pDevice->byQuietStartCount == 0) { |
| 1311 | pDevice->bEnableFirstQuiet = false; |
| 1312 | MACvRegBitsOn(pDevice->PortOffset, MAC_REG_MSRCTL, (MSRCTL_QUIETTXCHK | MSRCTL_QUIETEN)); |
| 1313 | } else { |
| 1314 | pDevice->bEnableFirstQuiet = true; |
| 1315 | } |
| 1316 | MACvSelectPage0(pDevice->PortOffset); |
| 1317 | } else { |
| 1318 | if (pDevice->dwCurrentQuietEndTime > pDevice->sQuiet[uCurrentQuietIndex].dwStartTime) { |
| 1319 | // overlap with previous Quiet |
| 1320 | dwGap = pDevice->dwCurrentQuietEndTime - pDevice->sQuiet[uCurrentQuietIndex].dwStartTime; |
| 1321 | if (dwGap >= pDevice->sQuiet[uCurrentQuietIndex].wDuration) { |
| 1322 | // return false to indicate next quiet expired, should call this function again |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 1323 | return false; |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1324 | } |
| 1325 | dwDuration = pDevice->sQuiet[uCurrentQuietIndex].wDuration - dwGap; |
| 1326 | dwGap = 0; |
| 1327 | } else { |
| 1328 | dwGap = pDevice->sQuiet[uCurrentQuietIndex].dwStartTime - pDevice->dwCurrentQuietEndTime; |
| 1329 | dwDuration = pDevice->sQuiet[uCurrentQuietIndex].wDuration; |
| 1330 | } |
| 1331 | // set GAP and Next duration |
| 1332 | MACvSelectPage1(pDevice->PortOffset); |
| 1333 | VNSvOutPortW(pDevice->PortOffset + MAC_REG_QUIETGAP, (unsigned short) dwGap); |
| 1334 | VNSvOutPortW(pDevice->PortOffset + MAC_REG_QUIETDUR, (unsigned short) dwDuration); |
| 1335 | MACvRegBitsOn(pDevice->PortOffset, MAC_REG_MSRCTL, MSRCTL_QUIETRPT); |
| 1336 | MACvSelectPage0(pDevice->PortOffset); |
| 1337 | } |
| 1338 | pDevice->bQuietEnable = true; |
| 1339 | pDevice->dwCurrentQuietEndTime = pDevice->sQuiet[uCurrentQuietIndex].dwStartTime; |
| 1340 | pDevice->dwCurrentQuietEndTime += pDevice->sQuiet[uCurrentQuietIndex].wDuration; |
| 1341 | if (pDevice->sQuiet[uCurrentQuietIndex].byPeriod == 0) { |
| 1342 | // not period disable current quiet element |
| 1343 | pDevice->sQuiet[uCurrentQuietIndex].bEnable = false; |
| 1344 | } else { |
| 1345 | // set next period start time |
| 1346 | dwNextTime = (unsigned long) pDevice->sQuiet[uCurrentQuietIndex].byPeriod; |
| 1347 | dwNextTime *= pDevice->wBeaconInterval; |
| 1348 | pDevice->sQuiet[uCurrentQuietIndex].dwStartTime = dwNextTime; |
| 1349 | } |
| 1350 | if (pDevice->dwCurrentQuietEndTime > 0x80010000) { |
| 1351 | // decreament all time to avoid wrap around |
| 1352 | for (ii = 0; ii < MAX_QUIET_COUNT; ii++) { |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 1353 | if (pDevice->sQuiet[ii].bEnable == true) |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1354 | pDevice->sQuiet[ii].dwStartTime -= 0x80000000; |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 1355 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1356 | } |
| 1357 | pDevice->dwCurrentQuietEndTime -= 0x80000000; |
| 1358 | } |
| 1359 | } |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 1360 | return true; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1361 | } |
| 1362 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1363 | /* |
| 1364 | * |
| 1365 | * Description: |
| 1366 | * Set Local Power Constraint |
| 1367 | * |
| 1368 | * Parameters: |
| 1369 | * In: |
| 1370 | * hDeviceContext - device structure point |
| 1371 | * Out: |
| 1372 | * none |
| 1373 | * |
| 1374 | * Return Value: none. |
| 1375 | * |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1376 | -*/ |
Charles Clément | 6b35b7b | 2010-05-07 12:30:19 -0700 | [diff] [blame] | 1377 | void |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1378 | CARDvSetPowerConstraint( |
| 1379 | void *pDeviceHandler, |
| 1380 | unsigned char byChannel, |
| 1381 | char byPower |
| 1382 | ) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1383 | { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1384 | PSDevice pDevice = (PSDevice) pDeviceHandler; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1385 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1386 | if (byChannel > CB_MAX_CHANNEL_24G) { |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 1387 | if (pDevice->bCountryInfo5G == true) |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1388 | pDevice->abyLocalPwr[byChannel] = pDevice->abyRegPwr[byChannel] - byPower; |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 1389 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1390 | } else { |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 1391 | if (pDevice->bCountryInfo24G == true) |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1392 | pDevice->abyLocalPwr[byChannel] = pDevice->abyRegPwr[byChannel] - byPower; |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 1393 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1394 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1395 | } |
| 1396 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1397 | /* |
| 1398 | * |
| 1399 | * Description: |
| 1400 | * Set Local Power Constraint |
| 1401 | * |
| 1402 | * Parameters: |
| 1403 | * In: |
| 1404 | * hDeviceContext - device structure point |
| 1405 | * Out: |
| 1406 | * none |
| 1407 | * |
| 1408 | * Return Value: none. |
| 1409 | * |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1410 | -*/ |
Charles Clément | 6b35b7b | 2010-05-07 12:30:19 -0700 | [diff] [blame] | 1411 | void |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1412 | CARDvGetPowerCapability( |
| 1413 | void *pDeviceHandler, |
| 1414 | unsigned char *pbyMinPower, |
| 1415 | unsigned char *pbyMaxPower |
| 1416 | ) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1417 | { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1418 | PSDevice pDevice = (PSDevice) pDeviceHandler; |
| 1419 | unsigned char byDec = 0; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1420 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1421 | *pbyMaxPower = pDevice->abyOFDMDefaultPwr[pDevice->byCurrentCh]; |
| 1422 | byDec = pDevice->abyOFDMPwrTbl[pDevice->byCurrentCh]; |
| 1423 | if (pDevice->byRFType == RF_UW2452) { |
| 1424 | byDec *= 3; |
| 1425 | byDec >>= 1; |
| 1426 | } else { |
| 1427 | byDec <<= 1; |
| 1428 | } |
| 1429 | *pbyMinPower = pDevice->abyOFDMDefaultPwr[pDevice->byCurrentCh] - byDec; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1430 | } |
| 1431 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1432 | /* |
| 1433 | * |
| 1434 | * Description: |
| 1435 | * Get Current Tx Power |
| 1436 | * |
| 1437 | * Parameters: |
| 1438 | * In: |
| 1439 | * hDeviceContext - device structure point |
| 1440 | * Out: |
| 1441 | * none |
| 1442 | * |
| 1443 | * Return Value: none. |
| 1444 | * |
Charles Clément | 79566eb | 2010-06-21 10:39:51 -0700 | [diff] [blame] | 1445 | */ |
Charles Clément | ec28c7f | 2010-05-28 12:34:18 -0700 | [diff] [blame] | 1446 | char |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1447 | CARDbyGetTransmitPower( |
| 1448 | void *pDeviceHandler |
| 1449 | ) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1450 | { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1451 | PSDevice pDevice = (PSDevice) pDeviceHandler; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1452 | |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 1453 | return pDevice->byCurPwrdBm; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1454 | } |
| 1455 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1456 | //xxx |
Charles Clément | 6b35b7b | 2010-05-07 12:30:19 -0700 | [diff] [blame] | 1457 | void |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1458 | CARDvSafeResetTx( |
| 1459 | void *pDeviceHandler |
| 1460 | ) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1461 | { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1462 | PSDevice pDevice = (PSDevice) pDeviceHandler; |
| 1463 | unsigned int uu; |
| 1464 | PSTxDesc pCurrTD; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1465 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1466 | // initialize TD index |
| 1467 | pDevice->apTailTD[0] = pDevice->apCurrTD[0] = &(pDevice->apTD0Rings[0]); |
| 1468 | pDevice->apTailTD[1] = pDevice->apCurrTD[1] = &(pDevice->apTD1Rings[0]); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1469 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1470 | for (uu = 0; uu < TYPE_MAXTD; uu++) |
| 1471 | pDevice->iTDUsed[uu] = 0; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1472 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1473 | for (uu = 0; uu < pDevice->sOpts.nTxDescs[0]; uu++) { |
| 1474 | pCurrTD = &(pDevice->apTD0Rings[uu]); |
| 1475 | pCurrTD->m_td0TD0.f1Owner = OWNED_BY_HOST; |
| 1476 | // init all Tx Packet pointer to NULL |
| 1477 | } |
| 1478 | for (uu = 0; uu < pDevice->sOpts.nTxDescs[1]; uu++) { |
| 1479 | pCurrTD = &(pDevice->apTD1Rings[uu]); |
| 1480 | pCurrTD->m_td0TD0.f1Owner = OWNED_BY_HOST; |
| 1481 | // init all Tx Packet pointer to NULL |
| 1482 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1483 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1484 | // set MAC TD pointer |
| 1485 | MACvSetCurrTXDescAddr(TYPE_TXDMA0, pDevice->PortOffset, |
| 1486 | (pDevice->td0_pool_dma)); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1487 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1488 | MACvSetCurrTXDescAddr(TYPE_AC0DMA, pDevice->PortOffset, |
| 1489 | (pDevice->td1_pool_dma)); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1490 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1491 | // set MAC Beacon TX pointer |
| 1492 | MACvSetCurrBCNTxDescAddr(pDevice->PortOffset, |
| 1493 | (pDevice->tx_beacon_dma)); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1494 | } |
| 1495 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1496 | /*+ |
| 1497 | * |
| 1498 | * Description: |
| 1499 | * Reset Rx |
| 1500 | * |
| 1501 | * Parameters: |
| 1502 | * In: |
| 1503 | * pDevice - Pointer to the adapter |
| 1504 | * Out: |
| 1505 | * none |
| 1506 | * |
| 1507 | * Return Value: none |
| 1508 | * |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1509 | -*/ |
Charles Clément | 6b35b7b | 2010-05-07 12:30:19 -0700 | [diff] [blame] | 1510 | void |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1511 | CARDvSafeResetRx( |
| 1512 | void *pDeviceHandler |
| 1513 | ) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1514 | { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1515 | PSDevice pDevice = (PSDevice) pDeviceHandler; |
| 1516 | unsigned int uu; |
| 1517 | PSRxDesc pDesc; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1518 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1519 | // initialize RD index |
| 1520 | pDevice->pCurrRD[0] = &(pDevice->aRD0Ring[0]); |
| 1521 | pDevice->pCurrRD[1] = &(pDevice->aRD1Ring[0]); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1522 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1523 | // init state, all RD is chip's |
| 1524 | for (uu = 0; uu < pDevice->sOpts.nRxDescs0; uu++) { |
| 1525 | pDesc = &(pDevice->aRD0Ring[uu]); |
| 1526 | pDesc->m_rd0RD0.wResCount = (unsigned short)(pDevice->rx_buf_sz); |
| 1527 | pDesc->m_rd0RD0.f1Owner = OWNED_BY_NIC; |
| 1528 | pDesc->m_rd1RD1.wReqCount = (unsigned short)(pDevice->rx_buf_sz); |
| 1529 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1530 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1531 | // init state, all RD is chip's |
| 1532 | for (uu = 0; uu < pDevice->sOpts.nRxDescs1; uu++) { |
| 1533 | pDesc = &(pDevice->aRD1Ring[uu]); |
| 1534 | pDesc->m_rd0RD0.wResCount = (unsigned short)(pDevice->rx_buf_sz); |
| 1535 | pDesc->m_rd0RD0.f1Owner = OWNED_BY_NIC; |
| 1536 | pDesc->m_rd1RD1.wReqCount = (unsigned short)(pDevice->rx_buf_sz); |
| 1537 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1538 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1539 | pDevice->cbDFCB = CB_MAX_RX_FRAG; |
| 1540 | pDevice->cbFreeDFCB = pDevice->cbDFCB; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1541 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1542 | // set perPkt mode |
| 1543 | MACvRx0PerPktMode(pDevice->PortOffset); |
| 1544 | MACvRx1PerPktMode(pDevice->PortOffset); |
| 1545 | // set MAC RD pointer |
| 1546 | MACvSetCurrRx0DescAddr(pDevice->PortOffset, |
| 1547 | pDevice->rd0_pool_dma); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1548 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1549 | MACvSetCurrRx1DescAddr(pDevice->PortOffset, |
| 1550 | pDevice->rd1_pool_dma); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1551 | } |
| 1552 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1553 | /* |
| 1554 | * Description: Get response Control frame rate in CCK mode |
| 1555 | * |
| 1556 | * Parameters: |
| 1557 | * In: |
| 1558 | * pDevice - The adapter to be set |
| 1559 | * wRateIdx - Receiving data rate |
| 1560 | * Out: |
| 1561 | * none |
| 1562 | * |
| 1563 | * Return Value: response Control frame rate |
| 1564 | * |
| 1565 | */ |
Guillaume Clement | 9e4c5c2 | 2014-07-22 22:08:28 +0200 | [diff] [blame] | 1566 | static unsigned short CARDwGetCCKControlRate(void *pDeviceHandler, unsigned short wRateIdx) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1567 | { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1568 | PSDevice pDevice = (PSDevice) pDeviceHandler; |
| 1569 | unsigned int ui = (unsigned int) wRateIdx; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1570 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1571 | while (ui > RATE_1M) { |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 1572 | if (pDevice->wBasicRate & ((unsigned short)1 << ui)) |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1573 | return (unsigned short)ui; |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 1574 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1575 | ui--; |
| 1576 | } |
| 1577 | return (unsigned short)RATE_1M; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1578 | } |
| 1579 | |
| 1580 | /* |
| 1581 | * Description: Get response Control frame rate in OFDM mode |
| 1582 | * |
| 1583 | * Parameters: |
| 1584 | * In: |
| 1585 | * pDevice - The adapter to be set |
| 1586 | * wRateIdx - Receiving data rate |
| 1587 | * Out: |
| 1588 | * none |
| 1589 | * |
| 1590 | * Return Value: response Control frame rate |
| 1591 | * |
| 1592 | */ |
Guillaume Clement | 9e4c5c2 | 2014-07-22 22:08:28 +0200 | [diff] [blame] | 1593 | static unsigned short CARDwGetOFDMControlRate(void *pDeviceHandler, unsigned short wRateIdx) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1594 | { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1595 | PSDevice pDevice = (PSDevice) pDeviceHandler; |
| 1596 | unsigned int ui = (unsigned int) wRateIdx; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1597 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1598 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "BASIC RATE: %X\n", pDevice->wBasicRate); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1599 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1600 | if (!CARDbIsOFDMinBasicRate((void *)pDevice)) { |
| 1601 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "CARDwGetOFDMControlRate:(NO OFDM) %d\n", wRateIdx); |
| 1602 | if (wRateIdx > RATE_24M) |
| 1603 | wRateIdx = RATE_24M; |
| 1604 | return wRateIdx; |
| 1605 | } |
| 1606 | while (ui > RATE_11M) { |
| 1607 | if (pDevice->wBasicRate & ((unsigned short)1 << ui)) { |
| 1608 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "CARDwGetOFDMControlRate : %d\n", ui); |
| 1609 | return (unsigned short)ui; |
| 1610 | } |
| 1611 | ui--; |
| 1612 | } |
| 1613 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "CARDwGetOFDMControlRate: 6M\n"); |
| 1614 | return (unsigned short)RATE_24M; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1615 | } |
| 1616 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1617 | /* |
| 1618 | * Description: Set RSPINF |
| 1619 | * |
| 1620 | * Parameters: |
| 1621 | * In: |
| 1622 | * pDevice - The adapter to be set |
| 1623 | * Out: |
| 1624 | * none |
| 1625 | * |
| 1626 | * Return Value: None. |
| 1627 | * |
| 1628 | */ |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1629 | void CARDvSetRSPINF(void *pDeviceHandler, CARD_PHY_TYPE ePHYType) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1630 | { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1631 | PSDevice pDevice = (PSDevice) pDeviceHandler; |
| 1632 | unsigned char byServ = 0x00, bySignal = 0x00; //For CCK |
| 1633 | unsigned short wLen = 0x0000; |
| 1634 | unsigned char byTxRate, byRsvTime; //For OFDM |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1635 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1636 | //Set to Page1 |
| 1637 | MACvSelectPage1(pDevice->PortOffset); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1638 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1639 | //RSPINF_b_1 |
| 1640 | BBvCalculateParameter(pDevice, |
| 1641 | 14, |
| 1642 | CARDwGetCCKControlRate((void *)pDevice, RATE_1M), |
| 1643 | PK_TYPE_11B, |
| 1644 | &wLen, |
| 1645 | &byServ, |
| 1646 | &bySignal |
| 1647 | ); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1648 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1649 | VNSvOutPortD(pDevice->PortOffset + MAC_REG_RSPINF_B_1, MAKEDWORD(wLen, MAKEWORD(bySignal, byServ))); |
| 1650 | ///RSPINF_b_2 |
| 1651 | BBvCalculateParameter(pDevice, |
| 1652 | 14, |
| 1653 | CARDwGetCCKControlRate((void *)pDevice, RATE_2M), |
| 1654 | PK_TYPE_11B, |
| 1655 | &wLen, |
| 1656 | &byServ, |
| 1657 | &bySignal |
| 1658 | ); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1659 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1660 | VNSvOutPortD(pDevice->PortOffset + MAC_REG_RSPINF_B_2, MAKEDWORD(wLen, MAKEWORD(bySignal, byServ))); |
| 1661 | //RSPINF_b_5 |
| 1662 | BBvCalculateParameter(pDevice, |
| 1663 | 14, |
| 1664 | CARDwGetCCKControlRate((void *)pDevice, RATE_5M), |
| 1665 | PK_TYPE_11B, |
| 1666 | &wLen, |
| 1667 | &byServ, |
| 1668 | &bySignal |
| 1669 | ); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1670 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1671 | VNSvOutPortD(pDevice->PortOffset + MAC_REG_RSPINF_B_5, MAKEDWORD(wLen, MAKEWORD(bySignal, byServ))); |
| 1672 | //RSPINF_b_11 |
| 1673 | BBvCalculateParameter(pDevice, |
| 1674 | 14, |
| 1675 | CARDwGetCCKControlRate((void *)pDevice, RATE_11M), |
| 1676 | PK_TYPE_11B, |
| 1677 | &wLen, |
| 1678 | &byServ, |
| 1679 | &bySignal |
| 1680 | ); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1681 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1682 | VNSvOutPortD(pDevice->PortOffset + MAC_REG_RSPINF_B_11, MAKEDWORD(wLen, MAKEWORD(bySignal, byServ))); |
| 1683 | //RSPINF_a_6 |
| 1684 | s_vCalculateOFDMRParameter(RATE_6M, |
| 1685 | ePHYType, |
| 1686 | &byTxRate, |
| 1687 | &byRsvTime); |
| 1688 | VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_6, MAKEWORD(byTxRate, byRsvTime)); |
| 1689 | //RSPINF_a_9 |
| 1690 | s_vCalculateOFDMRParameter(RATE_9M, |
| 1691 | ePHYType, |
| 1692 | &byTxRate, |
| 1693 | &byRsvTime); |
| 1694 | VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_9, MAKEWORD(byTxRate, byRsvTime)); |
| 1695 | //RSPINF_a_12 |
| 1696 | s_vCalculateOFDMRParameter(RATE_12M, |
| 1697 | ePHYType, |
| 1698 | &byTxRate, |
| 1699 | &byRsvTime); |
| 1700 | VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_12, MAKEWORD(byTxRate, byRsvTime)); |
| 1701 | //RSPINF_a_18 |
| 1702 | s_vCalculateOFDMRParameter(RATE_18M, |
| 1703 | ePHYType, |
| 1704 | &byTxRate, |
| 1705 | &byRsvTime); |
| 1706 | VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_18, MAKEWORD(byTxRate, byRsvTime)); |
| 1707 | //RSPINF_a_24 |
| 1708 | s_vCalculateOFDMRParameter(RATE_24M, |
| 1709 | ePHYType, |
| 1710 | &byTxRate, |
| 1711 | &byRsvTime); |
| 1712 | VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_24, MAKEWORD(byTxRate, byRsvTime)); |
| 1713 | //RSPINF_a_36 |
| 1714 | s_vCalculateOFDMRParameter(CARDwGetOFDMControlRate((void *)pDevice, RATE_36M), |
| 1715 | ePHYType, |
| 1716 | &byTxRate, |
| 1717 | &byRsvTime); |
| 1718 | VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_36, MAKEWORD(byTxRate, byRsvTime)); |
| 1719 | //RSPINF_a_48 |
| 1720 | s_vCalculateOFDMRParameter(CARDwGetOFDMControlRate((void *)pDevice, RATE_48M), |
| 1721 | ePHYType, |
| 1722 | &byTxRate, |
| 1723 | &byRsvTime); |
| 1724 | VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_48, MAKEWORD(byTxRate, byRsvTime)); |
| 1725 | //RSPINF_a_54 |
| 1726 | s_vCalculateOFDMRParameter(CARDwGetOFDMControlRate((void *)pDevice, RATE_54M), |
| 1727 | ePHYType, |
| 1728 | &byTxRate, |
| 1729 | &byRsvTime); |
| 1730 | VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_54, MAKEWORD(byTxRate, byRsvTime)); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1731 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1732 | //RSPINF_a_72 |
| 1733 | s_vCalculateOFDMRParameter(CARDwGetOFDMControlRate((void *)pDevice, RATE_54M), |
| 1734 | ePHYType, |
| 1735 | &byTxRate, |
| 1736 | &byRsvTime); |
| 1737 | VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_72, MAKEWORD(byTxRate, byRsvTime)); |
| 1738 | //Set to Page0 |
| 1739 | MACvSelectPage0(pDevice->PortOffset); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1740 | } |
| 1741 | |
| 1742 | /* |
| 1743 | * Description: Update IFS |
| 1744 | * |
| 1745 | * Parameters: |
| 1746 | * In: |
| 1747 | * pDevice - The adapter to be set |
| 1748 | * Out: |
| 1749 | * none |
| 1750 | * |
| 1751 | * Return Value: None. |
| 1752 | * |
| 1753 | */ |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1754 | void vUpdateIFS(void *pDeviceHandler) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1755 | { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1756 | //Set SIFS, DIFS, EIFS, SlotTime, CwMin |
| 1757 | PSDevice pDevice = (PSDevice) pDeviceHandler; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1758 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1759 | unsigned char byMaxMin = 0; |
Guillaume Clement | 6b71127 | 2014-07-25 01:06:16 +0200 | [diff] [blame] | 1760 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1761 | if (pDevice->byPacketType == PK_TYPE_11A) {//0000 0000 0000 0000,11a |
| 1762 | pDevice->uSlot = C_SLOT_SHORT; |
| 1763 | pDevice->uSIFS = C_SIFS_A; |
| 1764 | pDevice->uDIFS = C_SIFS_A + 2*C_SLOT_SHORT; |
| 1765 | pDevice->uCwMin = C_CWMIN_A; |
| 1766 | byMaxMin = 4; |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 1767 | } else if (pDevice->byPacketType == PK_TYPE_11B) {//0000 0001 0000 0000,11b |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1768 | pDevice->uSlot = C_SLOT_LONG; |
| 1769 | pDevice->uSIFS = C_SIFS_BG; |
| 1770 | pDevice->uDIFS = C_SIFS_BG + 2*C_SLOT_LONG; |
| 1771 | pDevice->uCwMin = C_CWMIN_B; |
| 1772 | byMaxMin = 5; |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 1773 | } else { // PK_TYPE_11GA & PK_TYPE_11GB |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1774 | pDevice->uSIFS = C_SIFS_BG; |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 1775 | if (pDevice->bShortSlotTime) |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1776 | pDevice->uSlot = C_SLOT_SHORT; |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 1777 | else |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1778 | pDevice->uSlot = C_SLOT_LONG; |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 1779 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1780 | pDevice->uDIFS = C_SIFS_BG + 2*pDevice->uSlot; |
| 1781 | if (pDevice->wBasicRate & 0x0150) { //0000 0001 0101 0000,24M,12M,6M |
| 1782 | pDevice->uCwMin = C_CWMIN_A; |
| 1783 | byMaxMin = 4; |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 1784 | } else { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1785 | pDevice->uCwMin = C_CWMIN_B; |
| 1786 | byMaxMin = 5; |
| 1787 | } |
| 1788 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1789 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1790 | pDevice->uCwMax = C_CWMAX; |
| 1791 | pDevice->uEIFS = C_EIFS; |
| 1792 | if (pDevice->byRFType == RF_RFMD2959) { |
| 1793 | // bcs TX_PE will reserve 3 us |
| 1794 | VNSvOutPortB(pDevice->PortOffset + MAC_REG_SIFS, (unsigned char)(pDevice->uSIFS - 3)); |
| 1795 | VNSvOutPortB(pDevice->PortOffset + MAC_REG_DIFS, (unsigned char)(pDevice->uDIFS - 3)); |
| 1796 | } else { |
| 1797 | VNSvOutPortB(pDevice->PortOffset + MAC_REG_SIFS, (unsigned char)pDevice->uSIFS); |
| 1798 | VNSvOutPortB(pDevice->PortOffset + MAC_REG_DIFS, (unsigned char)pDevice->uDIFS); |
| 1799 | } |
| 1800 | VNSvOutPortB(pDevice->PortOffset + MAC_REG_EIFS, (unsigned char)pDevice->uEIFS); |
| 1801 | VNSvOutPortB(pDevice->PortOffset + MAC_REG_SLOT, (unsigned char)pDevice->uSlot); |
| 1802 | byMaxMin |= 0xA0;//1010 1111,C_CWMAX = 1023 |
| 1803 | VNSvOutPortB(pDevice->PortOffset + MAC_REG_CWMAXMIN0, (unsigned char)byMaxMin); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1804 | } |
| 1805 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1806 | void CARDvUpdateBasicTopRate(void *pDeviceHandler) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1807 | { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1808 | PSDevice pDevice = (PSDevice) pDeviceHandler; |
| 1809 | unsigned char byTopOFDM = RATE_24M, byTopCCK = RATE_1M; |
| 1810 | unsigned char ii; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1811 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1812 | //Determines the highest basic rate. |
| 1813 | for (ii = RATE_54M; ii >= RATE_6M; ii--) { |
| 1814 | if ((pDevice->wBasicRate) & ((unsigned short)(1<<ii))) { |
| 1815 | byTopOFDM = ii; |
| 1816 | break; |
| 1817 | } |
| 1818 | } |
| 1819 | pDevice->byTopOFDMBasicRate = byTopOFDM; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1820 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1821 | for (ii = RATE_11M;; ii--) { |
| 1822 | if ((pDevice->wBasicRate) & ((unsigned short)(1<<ii))) { |
| 1823 | byTopCCK = ii; |
| 1824 | break; |
| 1825 | } |
| 1826 | if (ii == RATE_1M) |
| 1827 | break; |
| 1828 | } |
| 1829 | pDevice->byTopCCKBasicRate = byTopCCK; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1830 | } |
| 1831 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1832 | bool CARDbAddBasicRate(void *pDeviceHandler, unsigned short wRateIdx) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1833 | { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1834 | PSDevice pDevice = (PSDevice) pDeviceHandler; |
| 1835 | unsigned short wRate = (unsigned short)(1<<wRateIdx); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1836 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1837 | pDevice->wBasicRate |= wRate; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1838 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1839 | //Determines the highest basic rate. |
| 1840 | CARDvUpdateBasicTopRate((void *)pDevice); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1841 | |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 1842 | return true; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1843 | } |
| 1844 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1845 | bool CARDbIsOFDMinBasicRate(void *pDeviceHandler) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1846 | { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1847 | PSDevice pDevice = (PSDevice)pDeviceHandler; |
| 1848 | int ii; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1849 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1850 | for (ii = RATE_54M; ii >= RATE_6M; ii--) { |
| 1851 | if ((pDevice->wBasicRate) & ((unsigned short)(1 << ii))) |
| 1852 | return true; |
| 1853 | } |
| 1854 | return false; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1855 | } |
| 1856 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1857 | unsigned char CARDbyGetPktType(void *pDeviceHandler) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1858 | { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1859 | PSDevice pDevice = (PSDevice) pDeviceHandler; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1860 | |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 1861 | if (pDevice->byBBType == BB_TYPE_11A || pDevice->byBBType == BB_TYPE_11B) |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1862 | return (unsigned char)pDevice->byBBType; |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 1863 | else if (CARDbIsOFDMinBasicRate((void *)pDevice)) |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1864 | return PK_TYPE_11GA; |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 1865 | else |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1866 | return PK_TYPE_11GB; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1867 | } |
| 1868 | |
| 1869 | /* |
| 1870 | * Description: Set NIC Loopback mode |
| 1871 | * |
| 1872 | * Parameters: |
| 1873 | * In: |
| 1874 | * pDevice - The adapter to be set |
| 1875 | * wLoopbackMode - Loopback mode to be set |
| 1876 | * Out: |
| 1877 | * none |
| 1878 | * |
| 1879 | * Return Value: none |
| 1880 | * |
| 1881 | */ |
Guillaume Clement | 1683440 | 2014-07-22 22:08:26 +0200 | [diff] [blame] | 1882 | void CARDvSetLoopbackMode(void __iomem *dwIoBase, unsigned short wLoopbackMode) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1883 | { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1884 | switch (wLoopbackMode) { |
| 1885 | case CARD_LB_NONE: |
| 1886 | case CARD_LB_MAC: |
| 1887 | case CARD_LB_PHY: |
| 1888 | break; |
| 1889 | default: |
| 1890 | ASSERT(false); |
| 1891 | break; |
| 1892 | } |
| 1893 | // set MAC loopback |
| 1894 | MACvSetLoopbackMode(dwIoBase, LOBYTE(wLoopbackMode)); |
| 1895 | // set Baseband loopback |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1896 | } |
| 1897 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1898 | /* |
| 1899 | * Description: Software Reset NIC |
| 1900 | * |
| 1901 | * Parameters: |
| 1902 | * In: |
| 1903 | * pDevice - The adapter to be reset |
| 1904 | * Out: |
| 1905 | * none |
| 1906 | * |
| 1907 | * Return Value: none |
| 1908 | * |
| 1909 | */ |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1910 | bool CARDbSoftwareReset(void *pDeviceHandler) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1911 | { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1912 | PSDevice pDevice = (PSDevice) pDeviceHandler; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1913 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1914 | // reset MAC |
| 1915 | if (!MACbSafeSoftwareReset(pDevice->PortOffset)) |
| 1916 | return false; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1917 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1918 | return true; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1919 | } |
| 1920 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1921 | /* |
Justin P. Mattock | 7664ec8 | 2012-08-20 08:43:15 -0700 | [diff] [blame] | 1922 | * Description: Calculate TSF offset of two TSF input |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1923 | * Get TSF Offset from RxBCN's TSF and local TSF |
| 1924 | * |
| 1925 | * Parameters: |
| 1926 | * In: |
| 1927 | * pDevice - The adapter to be sync. |
| 1928 | * qwTSF1 - Rx BCN's TSF |
| 1929 | * qwTSF2 - Local TSF |
| 1930 | * Out: |
| 1931 | * none |
| 1932 | * |
| 1933 | * Return Value: TSF Offset value |
| 1934 | * |
| 1935 | */ |
Malcolm Priestley | 0fc2a76 | 2014-08-10 12:21:58 +0100 | [diff] [blame^] | 1936 | u64 CARDqGetTSFOffset(unsigned char byRxRate, u64 qwTSF1, u64 qwTSF2) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1937 | { |
Malcolm Priestley | 0fc2a76 | 2014-08-10 12:21:58 +0100 | [diff] [blame^] | 1938 | u64 qwTSFOffset = 0; |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1939 | unsigned short wRxBcnTSFOffst = 0; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1940 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1941 | wRxBcnTSFOffst = cwRXBCNTSFOff[byRxRate%MAX_RATE]; |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 1942 | |
Malcolm Priestley | 0fc2a76 | 2014-08-10 12:21:58 +0100 | [diff] [blame^] | 1943 | qwTSF2 += (u64)wRxBcnTSFOffst; |
| 1944 | |
| 1945 | qwTSFOffset = qwTSF1 - qwTSF2; |
| 1946 | |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 1947 | return qwTSFOffset; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1948 | } |
| 1949 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1950 | /* |
| 1951 | * Description: Read NIC TSF counter |
| 1952 | * Get local TSF counter |
| 1953 | * |
| 1954 | * Parameters: |
| 1955 | * In: |
| 1956 | * pDevice - The adapter to be read |
| 1957 | * Out: |
| 1958 | * qwCurrTSF - Current TSF counter |
| 1959 | * |
Charles Clément | 5a5a2a6 | 2010-08-01 17:15:49 +0200 | [diff] [blame] | 1960 | * Return Value: true if success; otherwise false |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1961 | * |
| 1962 | */ |
Malcolm Priestley | 0fc2a76 | 2014-08-10 12:21:58 +0100 | [diff] [blame^] | 1963 | bool CARDbGetCurrentTSF(void __iomem *dwIoBase, u64 *pqwCurrTSF) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1964 | { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1965 | unsigned short ww; |
| 1966 | unsigned char byData; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1967 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1968 | MACvRegBitsOn(dwIoBase, MAC_REG_TFTCTL, TFTCTL_TSFCNTRRD); |
| 1969 | for (ww = 0; ww < W_MAX_TIMEOUT; ww++) { |
| 1970 | VNSvInPortB(dwIoBase + MAC_REG_TFTCTL, &byData); |
| 1971 | if (!(byData & TFTCTL_TSFCNTRRD)) |
| 1972 | break; |
| 1973 | } |
| 1974 | if (ww == W_MAX_TIMEOUT) |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 1975 | return false; |
Malcolm Priestley | 0fc2a76 | 2014-08-10 12:21:58 +0100 | [diff] [blame^] | 1976 | VNSvInPortD(dwIoBase + MAC_REG_TSFCNTR, (u32 *)pqwCurrTSF); |
| 1977 | VNSvInPortD(dwIoBase + MAC_REG_TSFCNTR + 4, (u32 *)pqwCurrTSF + 1); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1978 | |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 1979 | return true; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1980 | } |
| 1981 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1982 | /* |
| 1983 | * Description: Read NIC TSF counter |
| 1984 | * Get NEXTTBTT from adjusted TSF and Beacon Interval |
| 1985 | * |
| 1986 | * Parameters: |
| 1987 | * In: |
| 1988 | * qwTSF - Current TSF counter |
| 1989 | * wbeaconInterval - Beacon Interval |
| 1990 | * Out: |
| 1991 | * qwCurrTSF - Current TSF counter |
| 1992 | * |
| 1993 | * Return Value: TSF value of next Beacon |
| 1994 | * |
| 1995 | */ |
Malcolm Priestley | 0fc2a76 | 2014-08-10 12:21:58 +0100 | [diff] [blame^] | 1996 | u64 CARDqGetNextTBTT(u64 qwTSF, unsigned short wBeaconInterval) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1997 | { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1998 | unsigned int uLowNextTBTT; |
| 1999 | unsigned int uHighRemain, uLowRemain; |
| 2000 | unsigned int uBeaconInterval; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2001 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 2002 | uBeaconInterval = wBeaconInterval * 1024; |
| 2003 | // Next TBTT = ((local_current_TSF / beacon_interval) + 1) * beacon_interval |
Malcolm Priestley | 0fc2a76 | 2014-08-10 12:21:58 +0100 | [diff] [blame^] | 2004 | uLowNextTBTT = ((qwTSF & 0xffffffffULL) >> 10) << 10; |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 2005 | // low dword (mod) bcn |
| 2006 | uLowRemain = (uLowNextTBTT) % uBeaconInterval; |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 2007 | // high dword (mod) bcn |
Malcolm Priestley | 0fc2a76 | 2014-08-10 12:21:58 +0100 | [diff] [blame^] | 2008 | uHighRemain = (((0xffffffff % uBeaconInterval) + 1) * (u32)(qwTSF >> 32)) |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 2009 | % uBeaconInterval; |
| 2010 | uLowRemain = (uHighRemain + uLowRemain) % uBeaconInterval; |
| 2011 | uLowRemain = uBeaconInterval - uLowRemain; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2012 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 2013 | // check if carry when add one beacon interval |
| 2014 | if ((~uLowNextTBTT) < uLowRemain) |
Malcolm Priestley | 0fc2a76 | 2014-08-10 12:21:58 +0100 | [diff] [blame^] | 2015 | qwTSF = ((qwTSF >> 32) + 1) << 32; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2016 | |
Malcolm Priestley | 0fc2a76 | 2014-08-10 12:21:58 +0100 | [diff] [blame^] | 2017 | qwTSF = (qwTSF & 0xffffffff00000000ULL) | |
| 2018 | (u64)(uLowNextTBTT + uLowRemain); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2019 | |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 2020 | return qwTSF; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2021 | } |
| 2022 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2023 | /* |
| 2024 | * Description: Set NIC TSF counter for first Beacon time |
| 2025 | * Get NEXTTBTT from adjusted TSF and Beacon Interval |
| 2026 | * |
| 2027 | * Parameters: |
| 2028 | * In: |
| 2029 | * dwIoBase - IO Base |
| 2030 | * wBeaconInterval - Beacon Interval |
| 2031 | * Out: |
| 2032 | * none |
| 2033 | * |
| 2034 | * Return Value: none |
| 2035 | * |
| 2036 | */ |
Guillaume Clement | 1683440 | 2014-07-22 22:08:26 +0200 | [diff] [blame] | 2037 | void CARDvSetFirstNextTBTT(void __iomem *dwIoBase, unsigned short wBeaconInterval) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2038 | { |
Malcolm Priestley | 0fc2a76 | 2014-08-10 12:21:58 +0100 | [diff] [blame^] | 2039 | u64 qwNextTBTT = 0; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2040 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 2041 | CARDbGetCurrentTSF(dwIoBase, &qwNextTBTT); //Get Local TSF counter |
Malcolm Priestley | 0fc2a76 | 2014-08-10 12:21:58 +0100 | [diff] [blame^] | 2042 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 2043 | qwNextTBTT = CARDqGetNextTBTT(qwNextTBTT, wBeaconInterval); |
| 2044 | // Set NextTBTT |
Malcolm Priestley | 0fc2a76 | 2014-08-10 12:21:58 +0100 | [diff] [blame^] | 2045 | VNSvOutPortD(dwIoBase + MAC_REG_NEXTTBTT, (u32)qwNextTBTT); |
| 2046 | VNSvOutPortD(dwIoBase + MAC_REG_NEXTTBTT + 4, (u32)(qwNextTBTT >> 32)); |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 2047 | MACvRegBitsOn(dwIoBase, MAC_REG_TFTCTL, TFTCTL_TBTTSYNCEN); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2048 | } |
| 2049 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2050 | /* |
| 2051 | * Description: Sync NIC TSF counter for Beacon time |
| 2052 | * Get NEXTTBTT and write to HW |
| 2053 | * |
| 2054 | * Parameters: |
| 2055 | * In: |
| 2056 | * pDevice - The adapter to be set |
| 2057 | * qwTSF - Current TSF counter |
| 2058 | * wBeaconInterval - Beacon Interval |
| 2059 | * Out: |
| 2060 | * none |
| 2061 | * |
| 2062 | * Return Value: none |
| 2063 | * |
| 2064 | */ |
Malcolm Priestley | 0fc2a76 | 2014-08-10 12:21:58 +0100 | [diff] [blame^] | 2065 | void CARDvUpdateNextTBTT(void __iomem *dwIoBase, u64 qwTSF, unsigned short wBeaconInterval) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2066 | { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 2067 | qwTSF = CARDqGetNextTBTT(qwTSF, wBeaconInterval); |
| 2068 | // Set NextTBTT |
Malcolm Priestley | 0fc2a76 | 2014-08-10 12:21:58 +0100 | [diff] [blame^] | 2069 | VNSvOutPortD(dwIoBase + MAC_REG_NEXTTBTT, (u32)qwTSF); |
| 2070 | VNSvOutPortD(dwIoBase + MAC_REG_NEXTTBTT + 4, (u32)(qwTSF >> 32)); |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 2071 | MACvRegBitsOn(dwIoBase, MAC_REG_TFTCTL, TFTCTL_TBTTSYNCEN); |
Malcolm Priestley | 0fc2a76 | 2014-08-10 12:21:58 +0100 | [diff] [blame^] | 2072 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Card:Update Next TBTT[%8llx]\n", qwTSF); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 2073 | } |