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