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 |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 24 | * CARDvUpdateBasicTopRate - Update BasicTopRate |
| 25 | * CARDbAddBasicRate - Add to BasicRateSet |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 26 | * CARDbIsOFDMinBasicRate - Check if any OFDM rate is in BasicRateSet |
| 27 | * CARDvSetLoopbackMode - Set Loopback mode |
| 28 | * CARDbSoftwareReset - Sortware reset NIC |
Justin P. Mattock | 7664ec8 | 2012-08-20 08:43:15 -0700 | [diff] [blame] | 29 | * CARDqGetTSFOffset - Calculate TSFOffset |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 30 | * CARDbGetCurrentTSF - Read Current NIC TSF counter |
Justin P. Mattock | 7664ec8 | 2012-08-20 08:43:15 -0700 | [diff] [blame] | 31 | * CARDqGetNextTBTT - Calculate Next Beacon TSF counter |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 32 | * CARDvSetFirstNextTBTT - Set NIC Beacon time |
| 33 | * CARDvUpdateNextTBTT - Sync. NIC Beacon time |
| 34 | * CARDbRadioPowerOff - Turn Off NIC Radio Power |
| 35 | * CARDbRadioPowerOn - Turn On NIC Radio Power |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 36 | * |
| 37 | * Revision History: |
| 38 | * 06-10-2003 Bryan YC Fan: Re-write codes to support VT3253 spec. |
| 39 | * 08-26-2003 Kyle Hsu: Modify the defination type of dwIoBase. |
| 40 | * 09-01-2003 Bryan YC Fan: Add vUpdateIFS(). |
| 41 | * |
| 42 | */ |
| 43 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 44 | #include "tmacro.h" |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 45 | #include "card.h" |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 46 | #include "baseband.h" |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 47 | #include "mac.h" |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 48 | #include "desc.h" |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 49 | #include "rf.h" |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 50 | #include "power.h" |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 51 | |
| 52 | /*--------------------- Static Definitions -------------------------*/ |
| 53 | |
Veronika Kabatova | 77b6a6a | 2014-10-25 22:34:38 +0200 | [diff] [blame] | 54 | #define C_SIFS_A 16 /* micro sec. */ |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 55 | #define C_SIFS_BG 10 |
| 56 | |
Veronika Kabatova | 77b6a6a | 2014-10-25 22:34:38 +0200 | [diff] [blame] | 57 | #define C_EIFS 80 /* micro sec. */ |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 58 | |
Veronika Kabatova | 77b6a6a | 2014-10-25 22:34:38 +0200 | [diff] [blame] | 59 | #define C_SLOT_SHORT 9 /* micro sec. */ |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 60 | #define C_SLOT_LONG 20 |
| 61 | |
Veronika Kabatova | 77b6a6a | 2014-10-25 22:34:38 +0200 | [diff] [blame] | 62 | #define C_CWMIN_A 15 /* slot time */ |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 63 | #define C_CWMIN_B 31 |
| 64 | |
Veronika Kabatova | 77b6a6a | 2014-10-25 22:34:38 +0200 | [diff] [blame] | 65 | #define C_CWMAX 1023 /* slot time */ |
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 WAIT_BEACON_TX_DOWN_TMO 3 /* Times */ |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 68 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 69 | /*--------------------- Static Variables --------------------------*/ |
| 70 | |
Mariam Mohamed Fawzy | 1167ff9 | 2015-01-26 11:24:36 +0200 | [diff] [blame] | 71 | static const unsigned short cwRXBCNTSFOff[MAX_RATE] = { |
| 72 | 17, 17, 17, 17, 34, 23, 17, 11, 8, 5, 4, 3}; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 73 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 74 | /*--------------------- Static Functions --------------------------*/ |
| 75 | |
| 76 | static |
Charles Clément | 6b35b7b | 2010-05-07 12:30:19 -0700 | [diff] [blame] | 77 | void |
Justin P. Mattock | 7664ec8 | 2012-08-20 08:43:15 -0700 | [diff] [blame] | 78 | s_vCalculateOFDMRParameter( |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 79 | unsigned char byRate, |
Malcolm Priestley | d1ab520 | 2014-11-07 19:06:04 +0000 | [diff] [blame] | 80 | u8 bb_type, |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 81 | unsigned char *pbyTxRate, |
| 82 | unsigned char *pbyRsvTime |
| 83 | ); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 84 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 85 | /*--------------------- Export Functions --------------------------*/ |
| 86 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 87 | /* |
Justin P. Mattock | 7664ec8 | 2012-08-20 08:43:15 -0700 | [diff] [blame] | 88 | * Description: Calculate TxRate and RsvTime fields for RSPINF in OFDM mode. |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 89 | * |
| 90 | * Parameters: |
| 91 | * In: |
| 92 | * wRate - Tx Rate |
| 93 | * byPktType - Tx Packet type |
| 94 | * Out: |
| 95 | * pbyTxRate - pointer to RSPINF TxRate field |
| 96 | * pbyRsvTime - pointer to RSPINF RsvTime field |
| 97 | * |
| 98 | * Return Value: none |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 99 | */ |
| 100 | static |
Charles Clément | 6b35b7b | 2010-05-07 12:30:19 -0700 | [diff] [blame] | 101 | void |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 102 | s_vCalculateOFDMRParameter( |
| 103 | unsigned char byRate, |
Malcolm Priestley | d1ab520 | 2014-11-07 19:06:04 +0000 | [diff] [blame] | 104 | u8 bb_type, |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 105 | unsigned char *pbyTxRate, |
| 106 | unsigned char *pbyRsvTime |
| 107 | ) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 108 | { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 109 | switch (byRate) { |
| 110 | case RATE_6M: |
Malcolm Priestley | d1ab520 | 2014-11-07 19:06:04 +0000 | [diff] [blame] | 111 | if (bb_type == BB_TYPE_11A) { /* 5GHZ */ |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 112 | *pbyTxRate = 0x9B; |
| 113 | *pbyRsvTime = 44; |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 114 | } else { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 115 | *pbyTxRate = 0x8B; |
| 116 | *pbyRsvTime = 50; |
| 117 | } |
| 118 | break; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 119 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 120 | case RATE_9M: |
Malcolm Priestley | d1ab520 | 2014-11-07 19:06:04 +0000 | [diff] [blame] | 121 | if (bb_type == BB_TYPE_11A) { /* 5GHZ */ |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 122 | *pbyTxRate = 0x9F; |
| 123 | *pbyRsvTime = 36; |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 124 | } else { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 125 | *pbyTxRate = 0x8F; |
| 126 | *pbyRsvTime = 42; |
| 127 | } |
| 128 | break; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 129 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 130 | case RATE_12M: |
Malcolm Priestley | d1ab520 | 2014-11-07 19:06:04 +0000 | [diff] [blame] | 131 | if (bb_type == BB_TYPE_11A) { /* 5GHZ */ |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 132 | *pbyTxRate = 0x9A; |
| 133 | *pbyRsvTime = 32; |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 134 | } else { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 135 | *pbyTxRate = 0x8A; |
| 136 | *pbyRsvTime = 38; |
| 137 | } |
| 138 | break; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 139 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 140 | case RATE_18M: |
Malcolm Priestley | d1ab520 | 2014-11-07 19:06:04 +0000 | [diff] [blame] | 141 | if (bb_type == BB_TYPE_11A) { /* 5GHZ */ |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 142 | *pbyTxRate = 0x9E; |
| 143 | *pbyRsvTime = 28; |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 144 | } else { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 145 | *pbyTxRate = 0x8E; |
| 146 | *pbyRsvTime = 34; |
| 147 | } |
| 148 | break; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 149 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 150 | case RATE_36M: |
Malcolm Priestley | d1ab520 | 2014-11-07 19:06:04 +0000 | [diff] [blame] | 151 | if (bb_type == BB_TYPE_11A) { /* 5GHZ */ |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 152 | *pbyTxRate = 0x9D; |
| 153 | *pbyRsvTime = 24; |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 154 | } else { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 155 | *pbyTxRate = 0x8D; |
| 156 | *pbyRsvTime = 30; |
| 157 | } |
| 158 | break; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 159 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 160 | case RATE_48M: |
Malcolm Priestley | d1ab520 | 2014-11-07 19:06:04 +0000 | [diff] [blame] | 161 | if (bb_type == BB_TYPE_11A) { /* 5GHZ */ |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 162 | *pbyTxRate = 0x98; |
| 163 | *pbyRsvTime = 24; |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 164 | } else { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 165 | *pbyTxRate = 0x88; |
| 166 | *pbyRsvTime = 30; |
| 167 | } |
| 168 | break; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 169 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 170 | case RATE_54M: |
Malcolm Priestley | d1ab520 | 2014-11-07 19:06:04 +0000 | [diff] [blame] | 171 | if (bb_type == BB_TYPE_11A) { /* 5GHZ */ |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 172 | *pbyTxRate = 0x9C; |
| 173 | *pbyRsvTime = 24; |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 174 | } else { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 175 | *pbyTxRate = 0x8C; |
| 176 | *pbyRsvTime = 30; |
| 177 | } |
| 178 | break; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 179 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 180 | case RATE_24M: |
| 181 | default: |
Malcolm Priestley | d1ab520 | 2014-11-07 19:06:04 +0000 | [diff] [blame] | 182 | if (bb_type == BB_TYPE_11A) { /* 5GHZ */ |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 183 | *pbyTxRate = 0x99; |
| 184 | *pbyRsvTime = 28; |
Joe Perches | 5e0cc8a | 2013-03-18 20:55:37 -0700 | [diff] [blame] | 185 | } else { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 186 | *pbyTxRate = 0x89; |
| 187 | *pbyRsvTime = 34; |
| 188 | } |
| 189 | break; |
| 190 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 191 | } |
| 192 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 193 | /*--------------------- Export Functions --------------------------*/ |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 194 | |
| 195 | /* |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 196 | * Description: Update IFS |
| 197 | * |
| 198 | * Parameters: |
| 199 | * In: |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 200 | * priv - The adapter to be set |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 201 | * Out: |
| 202 | * none |
| 203 | * |
| 204 | * Return Value: None. |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 205 | */ |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 206 | bool CARDbSetPhyParameter(struct vnt_private *priv, u8 bb_type) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 207 | { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 208 | unsigned char byCWMaxMin = 0; |
| 209 | unsigned char bySlot = 0; |
| 210 | unsigned char bySIFS = 0; |
| 211 | unsigned char byDIFS = 0; |
| 212 | unsigned char byData; |
Malcolm Priestley | 0614a0e | 2014-10-29 17:43:51 +0000 | [diff] [blame] | 213 | int i; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 214 | |
Veronika Kabatova | 77b6a6a | 2014-10-25 22:34:38 +0200 | [diff] [blame] | 215 | /* Set SIFS, DIFS, EIFS, SlotTime, CwMin */ |
Malcolm Priestley | a558e3d | 2014-11-07 19:06:02 +0000 | [diff] [blame] | 216 | if (bb_type == BB_TYPE_11A) { |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 217 | if (priv->byRFType == RF_AIROHA7230) { |
Veronika Kabatova | 77b6a6a | 2014-10-25 22:34:38 +0200 | [diff] [blame] | 218 | /* AL7230 use single PAPE and connect to PAPE_2.4G */ |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 219 | MACvSetBBType(priv->PortOffset, BB_TYPE_11G); |
| 220 | priv->abyBBVGA[0] = 0x20; |
| 221 | priv->abyBBVGA[2] = 0x10; |
| 222 | priv->abyBBVGA[3] = 0x10; |
| 223 | BBbReadEmbedded(priv, 0xE7, &byData); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 224 | if (byData == 0x1C) |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 225 | BBbWriteEmbedded(priv, 0xE7, priv->abyBBVGA[0]); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 226 | |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 227 | } else if (priv->byRFType == RF_UW2452) { |
| 228 | MACvSetBBType(priv->PortOffset, BB_TYPE_11A); |
| 229 | priv->abyBBVGA[0] = 0x18; |
| 230 | BBbReadEmbedded(priv, 0xE7, &byData); |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 231 | if (byData == 0x14) { |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 232 | BBbWriteEmbedded(priv, 0xE7, priv->abyBBVGA[0]); |
| 233 | BBbWriteEmbedded(priv, 0xE1, 0x57); |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 234 | } |
| 235 | } else { |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 236 | MACvSetBBType(priv->PortOffset, BB_TYPE_11A); |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 237 | } |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 238 | BBbWriteEmbedded(priv, 0x88, 0x03); |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 239 | bySlot = C_SLOT_SHORT; |
| 240 | bySIFS = C_SIFS_A; |
Burcin Akalin | 0cddeac | 2015-10-22 00:48:29 +0300 | [diff] [blame] | 241 | byDIFS = C_SIFS_A + 2 * C_SLOT_SHORT; |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 242 | byCWMaxMin = 0xA4; |
Malcolm Priestley | a558e3d | 2014-11-07 19:06:02 +0000 | [diff] [blame] | 243 | } else if (bb_type == BB_TYPE_11B) { |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 244 | MACvSetBBType(priv->PortOffset, BB_TYPE_11B); |
| 245 | if (priv->byRFType == RF_AIROHA7230) { |
| 246 | priv->abyBBVGA[0] = 0x1C; |
| 247 | priv->abyBBVGA[2] = 0x00; |
| 248 | priv->abyBBVGA[3] = 0x00; |
| 249 | BBbReadEmbedded(priv, 0xE7, &byData); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 250 | if (byData == 0x20) |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 251 | BBbWriteEmbedded(priv, 0xE7, priv->abyBBVGA[0]); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 252 | |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 253 | } else if (priv->byRFType == RF_UW2452) { |
| 254 | priv->abyBBVGA[0] = 0x14; |
| 255 | BBbReadEmbedded(priv, 0xE7, &byData); |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 256 | if (byData == 0x18) { |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 257 | BBbWriteEmbedded(priv, 0xE7, priv->abyBBVGA[0]); |
| 258 | BBbWriteEmbedded(priv, 0xE1, 0xD3); |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 259 | } |
| 260 | } |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 261 | BBbWriteEmbedded(priv, 0x88, 0x02); |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 262 | bySlot = C_SLOT_LONG; |
| 263 | bySIFS = C_SIFS_BG; |
| 264 | byDIFS = C_SIFS_BG + 2*C_SLOT_LONG; |
| 265 | byCWMaxMin = 0xA5; |
Veronika Kabatova | 77b6a6a | 2014-10-25 22:34:38 +0200 | [diff] [blame] | 266 | } else { /* PK_TYPE_11GA & PK_TYPE_11GB */ |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 267 | MACvSetBBType(priv->PortOffset, BB_TYPE_11G); |
| 268 | if (priv->byRFType == RF_AIROHA7230) { |
| 269 | priv->abyBBVGA[0] = 0x1C; |
| 270 | priv->abyBBVGA[2] = 0x00; |
| 271 | priv->abyBBVGA[3] = 0x00; |
| 272 | BBbReadEmbedded(priv, 0xE7, &byData); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 273 | if (byData == 0x20) |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 274 | BBbWriteEmbedded(priv, 0xE7, priv->abyBBVGA[0]); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 275 | |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 276 | } else if (priv->byRFType == RF_UW2452) { |
| 277 | priv->abyBBVGA[0] = 0x14; |
| 278 | BBbReadEmbedded(priv, 0xE7, &byData); |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 279 | if (byData == 0x18) { |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 280 | BBbWriteEmbedded(priv, 0xE7, priv->abyBBVGA[0]); |
| 281 | BBbWriteEmbedded(priv, 0xE1, 0xD3); |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 282 | } |
| 283 | } |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 284 | BBbWriteEmbedded(priv, 0x88, 0x08); |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 285 | bySIFS = C_SIFS_BG; |
Malcolm Priestley | 0614a0e | 2014-10-29 17:43:51 +0000 | [diff] [blame] | 286 | |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 287 | if (priv->bShortSlotTime) { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 288 | bySlot = C_SLOT_SHORT; |
Burcin Akalin | 68535a1 | 2015-10-22 15:15:39 +0300 | [diff] [blame] | 289 | byDIFS = C_SIFS_BG + 2 * C_SLOT_SHORT; |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 290 | } else { |
| 291 | bySlot = C_SLOT_LONG; |
| 292 | byDIFS = C_SIFS_BG + 2*C_SLOT_LONG; |
| 293 | } |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 294 | |
Malcolm Priestley | 0614a0e | 2014-10-29 17:43:51 +0000 | [diff] [blame] | 295 | byCWMaxMin = 0xa4; |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 296 | |
Malcolm Priestley | 0614a0e | 2014-10-29 17:43:51 +0000 | [diff] [blame] | 297 | for (i = RATE_54M; i >= RATE_6M; i--) { |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 298 | if (priv->basic_rates & ((u32)(0x1 << i))) { |
Malcolm Priestley | 0614a0e | 2014-10-29 17:43:51 +0000 | [diff] [blame] | 299 | byCWMaxMin |= 0x1; |
| 300 | break; |
| 301 | } |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 302 | } |
| 303 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 304 | |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 305 | if (priv->byRFType == RF_RFMD2959) { |
Veronika Kabatova | 77b6a6a | 2014-10-25 22:34:38 +0200 | [diff] [blame] | 306 | /* |
| 307 | * bcs TX_PE will reserve 3 us hardware's processing |
| 308 | * time here is 2 us. |
| 309 | */ |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 310 | bySIFS -= 3; |
| 311 | byDIFS -= 3; |
Veronika Kabatova | 77b6a6a | 2014-10-25 22:34:38 +0200 | [diff] [blame] | 312 | /* |
| 313 | * TX_PE will reserve 3 us for MAX2829 A mode only, it is for |
| 314 | * better TX throughput; MAC will need 2 us to process, so the |
| 315 | * SIFS, DIFS can be shorter by 2 us. |
| 316 | */ |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 317 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 318 | |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 319 | if (priv->bySIFS != bySIFS) { |
| 320 | priv->bySIFS = bySIFS; |
| 321 | VNSvOutPortB(priv->PortOffset + MAC_REG_SIFS, priv->bySIFS); |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 322 | } |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 323 | if (priv->byDIFS != byDIFS) { |
| 324 | priv->byDIFS = byDIFS; |
| 325 | VNSvOutPortB(priv->PortOffset + MAC_REG_DIFS, priv->byDIFS); |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 326 | } |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 327 | if (priv->byEIFS != C_EIFS) { |
| 328 | priv->byEIFS = C_EIFS; |
| 329 | VNSvOutPortB(priv->PortOffset + MAC_REG_EIFS, priv->byEIFS); |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 330 | } |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 331 | if (priv->bySlot != bySlot) { |
| 332 | priv->bySlot = bySlot; |
| 333 | VNSvOutPortB(priv->PortOffset + MAC_REG_SLOT, priv->bySlot); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 334 | |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 335 | BBvSetShortSlotTime(priv); |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 336 | } |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 337 | if (priv->byCWMaxMin != byCWMaxMin) { |
| 338 | priv->byCWMaxMin = byCWMaxMin; |
Kathryn Hampton | 5150d01 | 2016-03-15 18:16:24 -0700 | [diff] [blame] | 339 | VNSvOutPortB(priv->PortOffset + MAC_REG_CWMAXMIN0, |
| 340 | priv->byCWMaxMin); |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 341 | } |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 342 | |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 343 | priv->byPacketType = CARDbyGetPktType(priv); |
Malcolm Priestley | 61b9099 | 2014-11-06 20:02:05 +0000 | [diff] [blame] | 344 | |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 345 | CARDvSetRSPINF(priv, bb_type); |
Malcolm Priestley | 0614a0e | 2014-10-29 17:43:51 +0000 | [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: Sync. TSF counter to BSS |
| 352 | * Get TSF offset and write to HW |
| 353 | * |
| 354 | * Parameters: |
| 355 | * In: |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 356 | * priv - The adapter to be sync. |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 357 | * byRxRate - data rate of receive beacon |
| 358 | * qwBSSTimestamp - Rx BCN's TSF |
| 359 | * qwLocalTSF - Local TSF |
| 360 | * Out: |
| 361 | * none |
| 362 | * |
| 363 | * Return Value: none |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 364 | */ |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 365 | bool CARDbUpdateTSF(struct vnt_private *priv, unsigned char byRxRate, |
Malcolm Priestley | 032ed34 | 2015-04-21 22:33:01 +0100 | [diff] [blame] | 366 | u64 qwBSSTimestamp) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 367 | { |
Malcolm Priestley | 032ed34 | 2015-04-21 22:33:01 +0100 | [diff] [blame] | 368 | u64 local_tsf; |
Malcolm Priestley | 0fc2a76 | 2014-08-10 12:21:58 +0100 | [diff] [blame] | 369 | u64 qwTSFOffset = 0; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 370 | |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 371 | CARDbGetCurrentTSF(priv, &local_tsf); |
Malcolm Priestley | 032ed34 | 2015-04-21 22:33:01 +0100 | [diff] [blame] | 372 | |
| 373 | if (qwBSSTimestamp != local_tsf) { |
| 374 | qwTSFOffset = CARDqGetTSFOffset(byRxRate, qwBSSTimestamp, |
| 375 | local_tsf); |
Veronika Kabatova | 77b6a6a | 2014-10-25 22:34:38 +0200 | [diff] [blame] | 376 | /* adjust TSF, HW's TSF add TSF Offset reg */ |
Kathryn Hampton | 5150d01 | 2016-03-15 18:16:24 -0700 | [diff] [blame] | 377 | VNSvOutPortD(priv->PortOffset + MAC_REG_TSFOFST, |
| 378 | (u32)qwTSFOffset); |
| 379 | VNSvOutPortD(priv->PortOffset + MAC_REG_TSFOFST + 4, |
| 380 | (u32)(qwTSFOffset >> 32)); |
| 381 | MACvRegBitsOn(priv->PortOffset, MAC_REG_TFTCTL, |
| 382 | TFTCTL_TSFSYNCEN); |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 383 | } |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 384 | return true; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 385 | } |
| 386 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 387 | /* |
| 388 | * Description: Set NIC TSF counter for first Beacon time |
| 389 | * Get NEXTTBTT from adjusted TSF and Beacon Interval |
| 390 | * |
| 391 | * Parameters: |
| 392 | * In: |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 393 | * priv - The adapter to be set. |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 394 | * wBeaconInterval - Beacon Interval |
| 395 | * Out: |
| 396 | * none |
| 397 | * |
Charles Clément | 5a5a2a6 | 2010-08-01 17:15:49 +0200 | [diff] [blame] | 398 | * Return Value: true if succeed; otherwise false |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 399 | */ |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 400 | bool CARDbSetBeaconPeriod(struct vnt_private *priv, |
Malcolm Priestley | d052270 | 2014-08-10 15:46:57 +0100 | [diff] [blame] | 401 | unsigned short wBeaconInterval) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 402 | { |
Malcolm Priestley | 0fc2a76 | 2014-08-10 12:21:58 +0100 | [diff] [blame] | 403 | u64 qwNextTBTT = 0; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 404 | |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 405 | CARDbGetCurrentTSF(priv, &qwNextTBTT); /* Get Local TSF counter */ |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 406 | |
Malcolm Priestley | 4a5f718 | 2014-08-10 12:22:00 +0100 | [diff] [blame] | 407 | qwNextTBTT = CARDqGetNextTBTT(qwNextTBTT, wBeaconInterval); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 408 | |
Veronika Kabatova | 77b6a6a | 2014-10-25 22:34:38 +0200 | [diff] [blame] | 409 | /* set HW beacon interval */ |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 410 | VNSvOutPortW(priv->PortOffset + MAC_REG_BI, wBeaconInterval); |
| 411 | priv->wBeaconInterval = wBeaconInterval; |
Veronika Kabatova | 77b6a6a | 2014-10-25 22:34:38 +0200 | [diff] [blame] | 412 | /* Set NextTBTT */ |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 413 | VNSvOutPortD(priv->PortOffset + MAC_REG_NEXTTBTT, (u32)qwNextTBTT); |
Kathryn Hampton | 5150d01 | 2016-03-15 18:16:24 -0700 | [diff] [blame] | 414 | VNSvOutPortD(priv->PortOffset + MAC_REG_NEXTTBTT + 4, |
| 415 | (u32)(qwNextTBTT >> 32)); |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 416 | MACvRegBitsOn(priv->PortOffset, MAC_REG_TFTCTL, TFTCTL_TBTTSYNCEN); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 417 | |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 418 | return true; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 419 | } |
| 420 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 421 | /* |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 422 | * Description: Turn off Radio power |
| 423 | * |
| 424 | * Parameters: |
| 425 | * In: |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 426 | * priv - The adapter to be turned off |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 427 | * Out: |
| 428 | * none |
| 429 | * |
Charles Clément | 5a5a2a6 | 2010-08-01 17:15:49 +0200 | [diff] [blame] | 430 | * Return Value: true if success; otherwise false |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 431 | */ |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 432 | bool CARDbRadioPowerOff(struct vnt_private *priv) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 433 | { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 434 | bool bResult = true; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 435 | |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 436 | if (priv->bRadioOff) |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 437 | return true; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 438 | |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 439 | switch (priv->byRFType) { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 440 | case RF_RFMD2959: |
Kathryn Hampton | 5150d01 | 2016-03-15 18:16:24 -0700 | [diff] [blame] | 441 | MACvWordRegBitsOff(priv->PortOffset, MAC_REG_SOFTPWRCTL, |
| 442 | SOFTPWRCTL_TXPEINV); |
| 443 | MACvWordRegBitsOn(priv->PortOffset, MAC_REG_SOFTPWRCTL, |
| 444 | SOFTPWRCTL_SWPE1); |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 445 | break; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 446 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 447 | case RF_AIROHA: |
| 448 | case RF_AL2230S: |
Veronika Kabatova | 77b6a6a | 2014-10-25 22:34:38 +0200 | [diff] [blame] | 449 | case RF_AIROHA7230: |
Kathryn Hampton | 5150d01 | 2016-03-15 18:16:24 -0700 | [diff] [blame] | 450 | MACvWordRegBitsOff(priv->PortOffset, MAC_REG_SOFTPWRCTL, |
| 451 | SOFTPWRCTL_SWPE2); |
| 452 | MACvWordRegBitsOff(priv->PortOffset, MAC_REG_SOFTPWRCTL, |
| 453 | SOFTPWRCTL_SWPE3); |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 454 | break; |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 455 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 456 | |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 457 | MACvRegBitsOff(priv->PortOffset, MAC_REG_HOSTCR, HOSTCR_RXON); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 458 | |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 459 | BBvSetDeepSleep(priv, priv->byLocalID); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 460 | |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 461 | priv->bRadioOff = true; |
Guillaume Clement | 941ead9 | 2014-07-25 01:06:21 +0200 | [diff] [blame] | 462 | pr_debug("chester power off\n"); |
Kathryn Hampton | 5150d01 | 2016-03-15 18:16:24 -0700 | [diff] [blame] | 463 | MACvRegBitsOn(priv->PortOffset, MAC_REG_GPIOCTL0, |
| 464 | LED_ACTSET); /* LED issue */ |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 465 | return bResult; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 466 | } |
| 467 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 468 | /* |
| 469 | * Description: Turn on Radio power |
| 470 | * |
| 471 | * Parameters: |
| 472 | * In: |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 473 | * priv - The adapter to be turned on |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 474 | * Out: |
| 475 | * none |
| 476 | * |
Charles Clément | 5a5a2a6 | 2010-08-01 17:15:49 +0200 | [diff] [blame] | 477 | * Return Value: true if success; otherwise false |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 478 | */ |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 479 | bool CARDbRadioPowerOn(struct vnt_private *priv) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 480 | { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 481 | bool bResult = true; |
Igor Bezukh | f9dc1a8 | 2014-07-16 10:45:30 +0300 | [diff] [blame] | 482 | |
Guillaume Clement | 941ead9 | 2014-07-25 01:06:21 +0200 | [diff] [blame] | 483 | pr_debug("chester power on\n"); |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 484 | if (priv->bRadioControlOff) { |
| 485 | if (priv->bHWRadioOff) |
Guillaume Clement | a161342 | 2014-07-25 01:06:22 +0200 | [diff] [blame] | 486 | pr_debug("chester bHWRadioOff\n"); |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 487 | if (priv->bRadioControlOff) |
Guillaume Clement | a161342 | 2014-07-25 01:06:22 +0200 | [diff] [blame] | 488 | pr_debug("chester bRadioControlOff\n"); |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 489 | return false; } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 490 | |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 491 | if (!priv->bRadioOff) { |
Guillaume Clement | 941ead9 | 2014-07-25 01:06:21 +0200 | [diff] [blame] | 492 | pr_debug("chester pbRadioOff\n"); |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 493 | return true; } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 494 | |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 495 | BBvExitDeepSleep(priv, priv->byLocalID); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 496 | |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 497 | MACvRegBitsOn(priv->PortOffset, MAC_REG_HOSTCR, HOSTCR_RXON); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 498 | |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 499 | switch (priv->byRFType) { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 500 | case RF_RFMD2959: |
Kathryn Hampton | 5150d01 | 2016-03-15 18:16:24 -0700 | [diff] [blame] | 501 | MACvWordRegBitsOn(priv->PortOffset, MAC_REG_SOFTPWRCTL, |
| 502 | SOFTPWRCTL_TXPEINV); |
| 503 | MACvWordRegBitsOff(priv->PortOffset, MAC_REG_SOFTPWRCTL, |
| 504 | SOFTPWRCTL_SWPE1); |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 505 | break; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 506 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 507 | case RF_AIROHA: |
| 508 | case RF_AL2230S: |
Veronika Kabatova | 77b6a6a | 2014-10-25 22:34:38 +0200 | [diff] [blame] | 509 | case RF_AIROHA7230: |
Kathryn Hampton | 5150d01 | 2016-03-15 18:16:24 -0700 | [diff] [blame] | 510 | MACvWordRegBitsOn(priv->PortOffset, MAC_REG_SOFTPWRCTL, |
| 511 | (SOFTPWRCTL_SWPE2 | SOFTPWRCTL_SWPE3)); |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 512 | break; |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 513 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 514 | |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 515 | priv->bRadioOff = false; |
Guillaume Clement | 941ead9 | 2014-07-25 01:06:21 +0200 | [diff] [blame] | 516 | pr_debug("chester power on\n"); |
Kathryn Hampton | 5150d01 | 2016-03-15 18:16:24 -0700 | [diff] [blame] | 517 | MACvRegBitsOff(priv->PortOffset, MAC_REG_GPIOCTL0, |
| 518 | LED_ACTSET); /* LED issue */ |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 519 | return bResult; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 520 | } |
| 521 | |
Charles Clément | 6b35b7b | 2010-05-07 12:30:19 -0700 | [diff] [blame] | 522 | void |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 523 | CARDvSafeResetTx( |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 524 | struct vnt_private *priv |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 525 | ) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 526 | { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 527 | unsigned int uu; |
Malcolm Priestley | e235727 | 2015-08-14 22:58:51 +0100 | [diff] [blame] | 528 | struct vnt_tx_desc *pCurrTD; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 529 | |
Veronika Kabatova | 77b6a6a | 2014-10-25 22:34:38 +0200 | [diff] [blame] | 530 | /* initialize TD index */ |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 531 | priv->apTailTD[0] = priv->apCurrTD[0] = &(priv->apTD0Rings[0]); |
| 532 | priv->apTailTD[1] = priv->apCurrTD[1] = &(priv->apTD1Rings[0]); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 533 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 534 | for (uu = 0; uu < TYPE_MAXTD; uu++) |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 535 | priv->iTDUsed[uu] = 0; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 536 | |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 537 | for (uu = 0; uu < priv->opts.tx_descs[0]; uu++) { |
| 538 | pCurrTD = &(priv->apTD0Rings[uu]); |
Malcolm Priestley | 5235ff6 | 2015-08-14 22:58:46 +0100 | [diff] [blame] | 539 | pCurrTD->td0.owner = OWNED_BY_HOST; |
Veronika Kabatova | 77b6a6a | 2014-10-25 22:34:38 +0200 | [diff] [blame] | 540 | /* init all Tx Packet pointer to NULL */ |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 541 | } |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 542 | for (uu = 0; uu < priv->opts.tx_descs[1]; uu++) { |
| 543 | pCurrTD = &(priv->apTD1Rings[uu]); |
Malcolm Priestley | 5235ff6 | 2015-08-14 22:58:46 +0100 | [diff] [blame] | 544 | pCurrTD->td0.owner = OWNED_BY_HOST; |
Veronika Kabatova | 77b6a6a | 2014-10-25 22:34:38 +0200 | [diff] [blame] | 545 | /* init all Tx Packet pointer to NULL */ |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 546 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 547 | |
Veronika Kabatova | 77b6a6a | 2014-10-25 22:34:38 +0200 | [diff] [blame] | 548 | /* set MAC TD pointer */ |
Malcolm Priestley | f9f853a | 2015-11-22 09:07:22 +0000 | [diff] [blame] | 549 | MACvSetCurrTXDescAddr(TYPE_TXDMA0, priv, priv->td0_pool_dma); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 550 | |
Malcolm Priestley | f9f853a | 2015-11-22 09:07:22 +0000 | [diff] [blame] | 551 | MACvSetCurrTXDescAddr(TYPE_AC0DMA, priv, priv->td1_pool_dma); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 552 | |
Veronika Kabatova | 77b6a6a | 2014-10-25 22:34:38 +0200 | [diff] [blame] | 553 | /* set MAC Beacon TX pointer */ |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 554 | MACvSetCurrBCNTxDescAddr(priv->PortOffset, |
| 555 | (priv->tx_beacon_dma)); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 556 | } |
| 557 | |
Veronika Kabatova | 77b6a6a | 2014-10-25 22:34:38 +0200 | [diff] [blame] | 558 | /* |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 559 | * Description: |
| 560 | * Reset Rx |
| 561 | * |
| 562 | * Parameters: |
| 563 | * In: |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 564 | * priv - Pointer to the adapter |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 565 | * Out: |
| 566 | * none |
| 567 | * |
| 568 | * Return Value: none |
Veronika Kabatova | 77b6a6a | 2014-10-25 22:34:38 +0200 | [diff] [blame] | 569 | */ |
Charles Clément | 6b35b7b | 2010-05-07 12:30:19 -0700 | [diff] [blame] | 570 | void |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 571 | CARDvSafeResetRx( |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 572 | struct vnt_private *priv |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 573 | ) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 574 | { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 575 | unsigned int uu; |
Malcolm Priestley | 9cb693f | 2015-08-15 21:57:35 +0100 | [diff] [blame] | 576 | struct vnt_rx_desc *pDesc; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 577 | |
Veronika Kabatova | 77b6a6a | 2014-10-25 22:34:38 +0200 | [diff] [blame] | 578 | /* initialize RD index */ |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 579 | priv->pCurrRD[0] = &(priv->aRD0Ring[0]); |
| 580 | priv->pCurrRD[1] = &(priv->aRD1Ring[0]); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 581 | |
Veronika Kabatova | 77b6a6a | 2014-10-25 22:34:38 +0200 | [diff] [blame] | 582 | /* init state, all RD is chip's */ |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 583 | for (uu = 0; uu < priv->opts.rx_descs0; uu++) { |
| 584 | pDesc = &(priv->aRD0Ring[uu]); |
| 585 | pDesc->rd0.res_count = cpu_to_le16(priv->rx_buf_sz); |
Malcolm Priestley | de1c186 | 2015-08-15 21:57:32 +0100 | [diff] [blame] | 586 | pDesc->rd0.owner = OWNED_BY_NIC; |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 587 | pDesc->rd1.req_count = cpu_to_le16(priv->rx_buf_sz); |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 588 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 589 | |
Veronika Kabatova | 77b6a6a | 2014-10-25 22:34:38 +0200 | [diff] [blame] | 590 | /* init state, all RD is chip's */ |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 591 | for (uu = 0; uu < priv->opts.rx_descs1; uu++) { |
| 592 | pDesc = &(priv->aRD1Ring[uu]); |
| 593 | pDesc->rd0.res_count = cpu_to_le16(priv->rx_buf_sz); |
Malcolm Priestley | de1c186 | 2015-08-15 21:57:32 +0100 | [diff] [blame] | 594 | pDesc->rd0.owner = OWNED_BY_NIC; |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 595 | pDesc->rd1.req_count = cpu_to_le16(priv->rx_buf_sz); |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 596 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 597 | |
Veronika Kabatova | 77b6a6a | 2014-10-25 22:34:38 +0200 | [diff] [blame] | 598 | /* set perPkt mode */ |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 599 | MACvRx0PerPktMode(priv->PortOffset); |
| 600 | MACvRx1PerPktMode(priv->PortOffset); |
Veronika Kabatova | 77b6a6a | 2014-10-25 22:34:38 +0200 | [diff] [blame] | 601 | /* set MAC RD pointer */ |
Malcolm Priestley | f9f853a | 2015-11-22 09:07:22 +0000 | [diff] [blame] | 602 | MACvSetCurrRx0DescAddr(priv, priv->rd0_pool_dma); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 603 | |
Malcolm Priestley | f9f853a | 2015-11-22 09:07:22 +0000 | [diff] [blame] | 604 | MACvSetCurrRx1DescAddr(priv, priv->rd1_pool_dma); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 605 | } |
| 606 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 607 | /* |
| 608 | * Description: Get response Control frame rate in CCK mode |
| 609 | * |
| 610 | * Parameters: |
| 611 | * In: |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 612 | * priv - The adapter to be set |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 613 | * wRateIdx - Receiving data rate |
| 614 | * Out: |
| 615 | * none |
| 616 | * |
| 617 | * Return Value: response Control frame rate |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 618 | */ |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 619 | static unsigned short CARDwGetCCKControlRate(struct vnt_private *priv, |
Malcolm Priestley | d052270 | 2014-08-10 15:46:57 +0100 | [diff] [blame] | 620 | unsigned short wRateIdx) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 621 | { |
Sandhya Bankar | 58d4474 | 2016-09-19 17:47:21 +0530 | [diff] [blame] | 622 | unsigned int ui = (unsigned int)wRateIdx; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 623 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 624 | while (ui > RATE_1M) { |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 625 | if (priv->basic_rates & ((u32)0x1 << ui)) |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 626 | return (unsigned short)ui; |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 627 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 628 | ui--; |
| 629 | } |
| 630 | return (unsigned short)RATE_1M; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 631 | } |
| 632 | |
| 633 | /* |
| 634 | * Description: Get response Control frame rate in OFDM mode |
| 635 | * |
| 636 | * Parameters: |
| 637 | * In: |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 638 | * priv - The adapter to be set |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 639 | * wRateIdx - Receiving data rate |
| 640 | * Out: |
| 641 | * none |
| 642 | * |
| 643 | * Return Value: response Control frame rate |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 644 | */ |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 645 | static unsigned short CARDwGetOFDMControlRate(struct vnt_private *priv, |
Malcolm Priestley | d052270 | 2014-08-10 15:46:57 +0100 | [diff] [blame] | 646 | unsigned short wRateIdx) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 647 | { |
Sandhya Bankar | 58d4474 | 2016-09-19 17:47:21 +0530 | [diff] [blame] | 648 | unsigned int ui = (unsigned int)wRateIdx; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 649 | |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 650 | pr_debug("BASIC RATE: %X\n", priv->basic_rates); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 651 | |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 652 | if (!CARDbIsOFDMinBasicRate((void *)priv)) { |
Joe Perches | 48caf5a | 2014-08-17 09:17:04 -0700 | [diff] [blame] | 653 | pr_debug("CARDwGetOFDMControlRate:(NO OFDM) %d\n", wRateIdx); |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 654 | if (wRateIdx > RATE_24M) |
| 655 | wRateIdx = RATE_24M; |
| 656 | return wRateIdx; |
| 657 | } |
| 658 | while (ui > RATE_11M) { |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 659 | if (priv->basic_rates & ((u32)0x1 << ui)) { |
Joe Perches | 48caf5a | 2014-08-17 09:17:04 -0700 | [diff] [blame] | 660 | pr_debug("CARDwGetOFDMControlRate : %d\n", ui); |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 661 | return (unsigned short)ui; |
| 662 | } |
| 663 | ui--; |
| 664 | } |
Joe Perches | 48caf5a | 2014-08-17 09:17:04 -0700 | [diff] [blame] | 665 | pr_debug("CARDwGetOFDMControlRate: 6M\n"); |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 666 | return (unsigned short)RATE_24M; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 667 | } |
| 668 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 669 | /* |
| 670 | * Description: Set RSPINF |
| 671 | * |
| 672 | * Parameters: |
| 673 | * In: |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 674 | * priv - The adapter to be set |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 675 | * Out: |
| 676 | * none |
| 677 | * |
| 678 | * Return Value: None. |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 679 | */ |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 680 | void CARDvSetRSPINF(struct vnt_private *priv, u8 bb_type) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 681 | { |
Malcolm Priestley | 864a5a3 | 2014-08-20 22:30:30 +0100 | [diff] [blame] | 682 | union vnt_phy_field_swap phy; |
Veronika Kabatova | 77b6a6a | 2014-10-25 22:34:38 +0200 | [diff] [blame] | 683 | unsigned char byTxRate, byRsvTime; /* For OFDM */ |
Malcolm Priestley | 95775d1 | 2015-01-11 10:26:12 +0000 | [diff] [blame] | 684 | unsigned long flags; |
| 685 | |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 686 | spin_lock_irqsave(&priv->lock, flags); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 687 | |
Veronika Kabatova | 77b6a6a | 2014-10-25 22:34:38 +0200 | [diff] [blame] | 688 | /* Set to Page1 */ |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 689 | MACvSelectPage1(priv->PortOffset); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 690 | |
Malcolm Priestley | 864a5a3 | 2014-08-20 22:30:30 +0100 | [diff] [blame] | 691 | /* RSPINF_b_1 */ |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 692 | vnt_get_phy_field(priv, 14, |
| 693 | CARDwGetCCKControlRate(priv, RATE_1M), |
Malcolm Priestley | 864a5a3 | 2014-08-20 22:30:30 +0100 | [diff] [blame] | 694 | PK_TYPE_11B, &phy.field_read); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 695 | |
Malcolm Priestley | 864a5a3 | 2014-08-20 22:30:30 +0100 | [diff] [blame] | 696 | /* swap over to get correct write order */ |
| 697 | swap(phy.swap[0], phy.swap[1]); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 698 | |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 699 | VNSvOutPortD(priv->PortOffset + MAC_REG_RSPINF_B_1, phy.field_write); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 700 | |
Malcolm Priestley | 864a5a3 | 2014-08-20 22:30:30 +0100 | [diff] [blame] | 701 | /* RSPINF_b_2 */ |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 702 | vnt_get_phy_field(priv, 14, |
| 703 | CARDwGetCCKControlRate(priv, RATE_2M), |
Malcolm Priestley | 864a5a3 | 2014-08-20 22:30:30 +0100 | [diff] [blame] | 704 | PK_TYPE_11B, &phy.field_read); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 705 | |
Malcolm Priestley | 864a5a3 | 2014-08-20 22:30:30 +0100 | [diff] [blame] | 706 | swap(phy.swap[0], phy.swap[1]); |
| 707 | |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 708 | VNSvOutPortD(priv->PortOffset + MAC_REG_RSPINF_B_2, phy.field_write); |
Malcolm Priestley | 864a5a3 | 2014-08-20 22:30:30 +0100 | [diff] [blame] | 709 | |
| 710 | /* RSPINF_b_5 */ |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 711 | vnt_get_phy_field(priv, 14, |
| 712 | CARDwGetCCKControlRate(priv, RATE_5M), |
Malcolm Priestley | 864a5a3 | 2014-08-20 22:30:30 +0100 | [diff] [blame] | 713 | PK_TYPE_11B, &phy.field_read); |
| 714 | |
| 715 | swap(phy.swap[0], phy.swap[1]); |
| 716 | |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 717 | VNSvOutPortD(priv->PortOffset + MAC_REG_RSPINF_B_5, phy.field_write); |
Malcolm Priestley | 864a5a3 | 2014-08-20 22:30:30 +0100 | [diff] [blame] | 718 | |
| 719 | /* RSPINF_b_11 */ |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 720 | vnt_get_phy_field(priv, 14, |
| 721 | CARDwGetCCKControlRate(priv, RATE_11M), |
Malcolm Priestley | 864a5a3 | 2014-08-20 22:30:30 +0100 | [diff] [blame] | 722 | PK_TYPE_11B, &phy.field_read); |
| 723 | |
| 724 | swap(phy.swap[0], phy.swap[1]); |
| 725 | |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 726 | VNSvOutPortD(priv->PortOffset + MAC_REG_RSPINF_B_11, phy.field_write); |
Malcolm Priestley | 864a5a3 | 2014-08-20 22:30:30 +0100 | [diff] [blame] | 727 | |
Veronika Kabatova | 77b6a6a | 2014-10-25 22:34:38 +0200 | [diff] [blame] | 728 | /* RSPINF_a_6 */ |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 729 | s_vCalculateOFDMRParameter(RATE_6M, |
Malcolm Priestley | 6e1d14a | 2014-11-07 19:06:03 +0000 | [diff] [blame] | 730 | bb_type, |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 731 | &byTxRate, |
| 732 | &byRsvTime); |
Kathryn Hampton | 5150d01 | 2016-03-15 18:16:24 -0700 | [diff] [blame] | 733 | VNSvOutPortW(priv->PortOffset + MAC_REG_RSPINF_A_6, |
| 734 | MAKEWORD(byTxRate, byRsvTime)); |
Veronika Kabatova | 77b6a6a | 2014-10-25 22:34:38 +0200 | [diff] [blame] | 735 | /* RSPINF_a_9 */ |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 736 | s_vCalculateOFDMRParameter(RATE_9M, |
Malcolm Priestley | 6e1d14a | 2014-11-07 19:06:03 +0000 | [diff] [blame] | 737 | bb_type, |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 738 | &byTxRate, |
| 739 | &byRsvTime); |
Kathryn Hampton | 5150d01 | 2016-03-15 18:16:24 -0700 | [diff] [blame] | 740 | VNSvOutPortW(priv->PortOffset + MAC_REG_RSPINF_A_9, |
| 741 | MAKEWORD(byTxRate, byRsvTime)); |
Veronika Kabatova | 77b6a6a | 2014-10-25 22:34:38 +0200 | [diff] [blame] | 742 | /* RSPINF_a_12 */ |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 743 | s_vCalculateOFDMRParameter(RATE_12M, |
Malcolm Priestley | 6e1d14a | 2014-11-07 19:06:03 +0000 | [diff] [blame] | 744 | bb_type, |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 745 | &byTxRate, |
| 746 | &byRsvTime); |
Kathryn Hampton | 5150d01 | 2016-03-15 18:16:24 -0700 | [diff] [blame] | 747 | VNSvOutPortW(priv->PortOffset + MAC_REG_RSPINF_A_12, |
| 748 | MAKEWORD(byTxRate, byRsvTime)); |
Veronika Kabatova | 77b6a6a | 2014-10-25 22:34:38 +0200 | [diff] [blame] | 749 | /* RSPINF_a_18 */ |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 750 | s_vCalculateOFDMRParameter(RATE_18M, |
Malcolm Priestley | 6e1d14a | 2014-11-07 19:06:03 +0000 | [diff] [blame] | 751 | bb_type, |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 752 | &byTxRate, |
| 753 | &byRsvTime); |
Kathryn Hampton | 5150d01 | 2016-03-15 18:16:24 -0700 | [diff] [blame] | 754 | VNSvOutPortW(priv->PortOffset + MAC_REG_RSPINF_A_18, |
| 755 | MAKEWORD(byTxRate, byRsvTime)); |
Veronika Kabatova | 77b6a6a | 2014-10-25 22:34:38 +0200 | [diff] [blame] | 756 | /* RSPINF_a_24 */ |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 757 | s_vCalculateOFDMRParameter(RATE_24M, |
Malcolm Priestley | 6e1d14a | 2014-11-07 19:06:03 +0000 | [diff] [blame] | 758 | bb_type, |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 759 | &byTxRate, |
| 760 | &byRsvTime); |
Kathryn Hampton | 5150d01 | 2016-03-15 18:16:24 -0700 | [diff] [blame] | 761 | VNSvOutPortW(priv->PortOffset + MAC_REG_RSPINF_A_24, |
| 762 | MAKEWORD(byTxRate, byRsvTime)); |
Veronika Kabatova | 77b6a6a | 2014-10-25 22:34:38 +0200 | [diff] [blame] | 763 | /* RSPINF_a_36 */ |
Kathryn Hampton | 5150d01 | 2016-03-15 18:16:24 -0700 | [diff] [blame] | 764 | s_vCalculateOFDMRParameter(CARDwGetOFDMControlRate( |
| 765 | (void *)priv, |
| 766 | RATE_36M), |
Malcolm Priestley | 6e1d14a | 2014-11-07 19:06:03 +0000 | [diff] [blame] | 767 | bb_type, |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 768 | &byTxRate, |
| 769 | &byRsvTime); |
Kathryn Hampton | 5150d01 | 2016-03-15 18:16:24 -0700 | [diff] [blame] | 770 | VNSvOutPortW(priv->PortOffset + MAC_REG_RSPINF_A_36, |
| 771 | MAKEWORD(byTxRate, byRsvTime)); |
Veronika Kabatova | 77b6a6a | 2014-10-25 22:34:38 +0200 | [diff] [blame] | 772 | /* RSPINF_a_48 */ |
Kathryn Hampton | 5150d01 | 2016-03-15 18:16:24 -0700 | [diff] [blame] | 773 | s_vCalculateOFDMRParameter(CARDwGetOFDMControlRate( |
| 774 | (void *)priv, |
| 775 | RATE_48M), |
Malcolm Priestley | 6e1d14a | 2014-11-07 19:06:03 +0000 | [diff] [blame] | 776 | bb_type, |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 777 | &byTxRate, |
| 778 | &byRsvTime); |
Kathryn Hampton | 5150d01 | 2016-03-15 18:16:24 -0700 | [diff] [blame] | 779 | VNSvOutPortW(priv->PortOffset + MAC_REG_RSPINF_A_48, |
| 780 | MAKEWORD(byTxRate, byRsvTime)); |
Veronika Kabatova | 77b6a6a | 2014-10-25 22:34:38 +0200 | [diff] [blame] | 781 | /* RSPINF_a_54 */ |
Kathryn Hampton | 5150d01 | 2016-03-15 18:16:24 -0700 | [diff] [blame] | 782 | s_vCalculateOFDMRParameter(CARDwGetOFDMControlRate( |
| 783 | (void *)priv, |
| 784 | RATE_54M), |
Malcolm Priestley | 6e1d14a | 2014-11-07 19:06:03 +0000 | [diff] [blame] | 785 | bb_type, |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 786 | &byTxRate, |
| 787 | &byRsvTime); |
Kathryn Hampton | 5150d01 | 2016-03-15 18:16:24 -0700 | [diff] [blame] | 788 | VNSvOutPortW(priv->PortOffset + MAC_REG_RSPINF_A_54, |
| 789 | MAKEWORD(byTxRate, byRsvTime)); |
Veronika Kabatova | 77b6a6a | 2014-10-25 22:34:38 +0200 | [diff] [blame] | 790 | /* RSPINF_a_72 */ |
Kathryn Hampton | 5150d01 | 2016-03-15 18:16:24 -0700 | [diff] [blame] | 791 | s_vCalculateOFDMRParameter(CARDwGetOFDMControlRate( |
| 792 | (void *)priv, |
| 793 | RATE_54M), |
Malcolm Priestley | 6e1d14a | 2014-11-07 19:06:03 +0000 | [diff] [blame] | 794 | bb_type, |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 795 | &byTxRate, |
| 796 | &byRsvTime); |
Kathryn Hampton | 5150d01 | 2016-03-15 18:16:24 -0700 | [diff] [blame] | 797 | VNSvOutPortW(priv->PortOffset + MAC_REG_RSPINF_A_72, |
| 798 | MAKEWORD(byTxRate, byRsvTime)); |
Veronika Kabatova | 77b6a6a | 2014-10-25 22:34:38 +0200 | [diff] [blame] | 799 | /* Set to Page0 */ |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 800 | MACvSelectPage0(priv->PortOffset); |
Malcolm Priestley | 95775d1 | 2015-01-11 10:26:12 +0000 | [diff] [blame] | 801 | |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 802 | spin_unlock_irqrestore(&priv->lock, flags); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 803 | } |
| 804 | |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 805 | void CARDvUpdateBasicTopRate(struct vnt_private *priv) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 806 | { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 807 | unsigned char byTopOFDM = RATE_24M, byTopCCK = RATE_1M; |
| 808 | unsigned char ii; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 809 | |
Veronika Kabatova | 77b6a6a | 2014-10-25 22:34:38 +0200 | [diff] [blame] | 810 | /* Determines the highest basic rate. */ |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 811 | for (ii = RATE_54M; ii >= RATE_6M; ii--) { |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 812 | if ((priv->basic_rates) & ((u32)(1 << ii))) { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 813 | byTopOFDM = ii; |
| 814 | break; |
| 815 | } |
| 816 | } |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 817 | priv->byTopOFDMBasicRate = byTopOFDM; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 818 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 819 | for (ii = RATE_11M;; ii--) { |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 820 | if ((priv->basic_rates) & ((u32)(1 << ii))) { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 821 | byTopCCK = ii; |
| 822 | break; |
| 823 | } |
| 824 | if (ii == RATE_1M) |
| 825 | break; |
| 826 | } |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 827 | priv->byTopCCKBasicRate = byTopCCK; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 828 | } |
| 829 | |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 830 | bool CARDbIsOFDMinBasicRate(struct vnt_private *priv) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 831 | { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 832 | int ii; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 833 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 834 | for (ii = RATE_54M; ii >= RATE_6M; ii--) { |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 835 | if ((priv->basic_rates) & ((u32)BIT(ii))) |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 836 | return true; |
| 837 | } |
| 838 | return false; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 839 | } |
| 840 | |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 841 | unsigned char CARDbyGetPktType(struct vnt_private *priv) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 842 | { |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 843 | if (priv->byBBType == BB_TYPE_11A || priv->byBBType == BB_TYPE_11B) |
| 844 | return (unsigned char)priv->byBBType; |
| 845 | else if (CARDbIsOFDMinBasicRate((void *)priv)) |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 846 | return PK_TYPE_11GA; |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 847 | else |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 848 | return PK_TYPE_11GB; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 849 | } |
| 850 | |
| 851 | /* |
| 852 | * Description: Set NIC Loopback mode |
| 853 | * |
| 854 | * Parameters: |
| 855 | * In: |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 856 | * priv - The adapter to be set |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 857 | * wLoopbackMode - Loopback mode to be set |
| 858 | * Out: |
| 859 | * none |
| 860 | * |
| 861 | * Return Value: none |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 862 | */ |
Kathryn Hampton | 5150d01 | 2016-03-15 18:16:24 -0700 | [diff] [blame] | 863 | void CARDvSetLoopbackMode(struct vnt_private *priv, |
| 864 | unsigned short wLoopbackMode) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 865 | { |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 866 | switch (wLoopbackMode) { |
| 867 | case CARD_LB_NONE: |
| 868 | case CARD_LB_MAC: |
| 869 | case CARD_LB_PHY: |
| 870 | break; |
| 871 | default: |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 872 | break; |
| 873 | } |
Veronika Kabatova | 77b6a6a | 2014-10-25 22:34:38 +0200 | [diff] [blame] | 874 | /* set MAC loopback */ |
Malcolm Priestley | f9f853a | 2015-11-22 09:07:22 +0000 | [diff] [blame] | 875 | MACvSetLoopbackMode(priv, LOBYTE(wLoopbackMode)); |
Veronika Kabatova | 77b6a6a | 2014-10-25 22:34:38 +0200 | [diff] [blame] | 876 | /* set Baseband loopback */ |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 877 | } |
| 878 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 879 | /* |
| 880 | * Description: Software Reset NIC |
| 881 | * |
| 882 | * Parameters: |
| 883 | * In: |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 884 | * priv - The adapter to be reset |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 885 | * Out: |
| 886 | * none |
| 887 | * |
| 888 | * Return Value: none |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 889 | */ |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 890 | bool CARDbSoftwareReset(struct vnt_private *priv) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 891 | { |
Veronika Kabatova | 77b6a6a | 2014-10-25 22:34:38 +0200 | [diff] [blame] | 892 | /* reset MAC */ |
Malcolm Priestley | f9f853a | 2015-11-22 09:07:22 +0000 | [diff] [blame] | 893 | if (!MACbSafeSoftwareReset(priv)) |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 894 | return false; |
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 | return true; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 897 | } |
| 898 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 899 | /* |
Justin P. Mattock | 7664ec8 | 2012-08-20 08:43:15 -0700 | [diff] [blame] | 900 | * Description: Calculate TSF offset of two TSF input |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 901 | * Get TSF Offset from RxBCN's TSF and local TSF |
| 902 | * |
| 903 | * Parameters: |
| 904 | * In: |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 905 | * priv - The adapter to be sync. |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 906 | * qwTSF1 - Rx BCN's TSF |
| 907 | * qwTSF2 - Local TSF |
| 908 | * Out: |
| 909 | * none |
| 910 | * |
| 911 | * Return Value: TSF Offset value |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 912 | */ |
Malcolm Priestley | 0fc2a76 | 2014-08-10 12:21:58 +0100 | [diff] [blame] | 913 | u64 CARDqGetTSFOffset(unsigned char byRxRate, u64 qwTSF1, u64 qwTSF2) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 914 | { |
Malcolm Priestley | 0fc2a76 | 2014-08-10 12:21:58 +0100 | [diff] [blame] | 915 | u64 qwTSFOffset = 0; |
Amitoj Kaur Chawla | 5309c5b | 2015-10-15 13:45:39 +0530 | [diff] [blame] | 916 | unsigned short wRxBcnTSFOffst; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 917 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 918 | wRxBcnTSFOffst = cwRXBCNTSFOff[byRxRate%MAX_RATE]; |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 919 | |
Malcolm Priestley | 0fc2a76 | 2014-08-10 12:21:58 +0100 | [diff] [blame] | 920 | qwTSF2 += (u64)wRxBcnTSFOffst; |
| 921 | |
| 922 | qwTSFOffset = qwTSF1 - qwTSF2; |
| 923 | |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 924 | return qwTSFOffset; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 925 | } |
| 926 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 927 | /* |
| 928 | * Description: Read NIC TSF counter |
| 929 | * Get local TSF counter |
| 930 | * |
| 931 | * Parameters: |
| 932 | * In: |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 933 | * priv - The adapter to be read |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 934 | * Out: |
| 935 | * qwCurrTSF - Current TSF counter |
| 936 | * |
Charles Clément | 5a5a2a6 | 2010-08-01 17:15:49 +0200 | [diff] [blame] | 937 | * Return Value: true if success; otherwise false |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 938 | */ |
Malcolm Priestley | 738487f | 2014-11-12 21:11:09 +0000 | [diff] [blame] | 939 | bool CARDbGetCurrentTSF(struct vnt_private *priv, u64 *pqwCurrTSF) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 940 | { |
Malcolm Priestley | 738487f | 2014-11-12 21:11:09 +0000 | [diff] [blame] | 941 | void __iomem *dwIoBase = priv->PortOffset; |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 942 | unsigned short ww; |
| 943 | unsigned char byData; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 944 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 945 | MACvRegBitsOn(dwIoBase, MAC_REG_TFTCTL, TFTCTL_TSFCNTRRD); |
| 946 | for (ww = 0; ww < W_MAX_TIMEOUT; ww++) { |
| 947 | VNSvInPortB(dwIoBase + MAC_REG_TFTCTL, &byData); |
| 948 | if (!(byData & TFTCTL_TSFCNTRRD)) |
| 949 | break; |
| 950 | } |
| 951 | if (ww == W_MAX_TIMEOUT) |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 952 | return false; |
Malcolm Priestley | 0fc2a76 | 2014-08-10 12:21:58 +0100 | [diff] [blame] | 953 | VNSvInPortD(dwIoBase + MAC_REG_TSFCNTR, (u32 *)pqwCurrTSF); |
| 954 | VNSvInPortD(dwIoBase + MAC_REG_TSFCNTR + 4, (u32 *)pqwCurrTSF + 1); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 955 | |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 956 | return true; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 957 | } |
| 958 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 959 | /* |
| 960 | * Description: Read NIC TSF counter |
| 961 | * Get NEXTTBTT from adjusted TSF and Beacon Interval |
| 962 | * |
| 963 | * Parameters: |
| 964 | * In: |
| 965 | * qwTSF - Current TSF counter |
| 966 | * wbeaconInterval - Beacon Interval |
| 967 | * Out: |
| 968 | * qwCurrTSF - Current TSF counter |
| 969 | * |
| 970 | * Return Value: TSF value of next Beacon |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 971 | */ |
Malcolm Priestley | 0fc2a76 | 2014-08-10 12:21:58 +0100 | [diff] [blame] | 972 | u64 CARDqGetNextTBTT(u64 qwTSF, unsigned short wBeaconInterval) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 973 | { |
Malcolm Priestley | 989ae86 | 2014-08-10 12:21:59 +0100 | [diff] [blame] | 974 | u32 beacon_int; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 975 | |
Malcolm Priestley | 989ae86 | 2014-08-10 12:21:59 +0100 | [diff] [blame] | 976 | beacon_int = wBeaconInterval * 1024; |
Malcolm Priestley | 989ae86 | 2014-08-10 12:21:59 +0100 | [diff] [blame] | 977 | if (beacon_int) { |
| 978 | do_div(qwTSF, beacon_int); |
| 979 | qwTSF += 1; |
| 980 | qwTSF *= beacon_int; |
| 981 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 982 | |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 983 | return qwTSF; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 984 | } |
| 985 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 986 | /* |
| 987 | * Description: Set NIC TSF counter for first Beacon time |
| 988 | * Get NEXTTBTT from adjusted TSF and Beacon Interval |
| 989 | * |
| 990 | * Parameters: |
| 991 | * In: |
| 992 | * dwIoBase - IO Base |
| 993 | * wBeaconInterval - Beacon Interval |
| 994 | * Out: |
| 995 | * none |
| 996 | * |
| 997 | * Return Value: none |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 998 | */ |
Kathryn Hampton | 5150d01 | 2016-03-15 18:16:24 -0700 | [diff] [blame] | 999 | void CARDvSetFirstNextTBTT(struct vnt_private *priv, |
| 1000 | unsigned short wBeaconInterval) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1001 | { |
Malcolm Priestley | 738487f | 2014-11-12 21:11:09 +0000 | [diff] [blame] | 1002 | void __iomem *dwIoBase = priv->PortOffset; |
Malcolm Priestley | 0fc2a76 | 2014-08-10 12:21:58 +0100 | [diff] [blame] | 1003 | u64 qwNextTBTT = 0; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1004 | |
Malcolm Priestley | 738487f | 2014-11-12 21:11:09 +0000 | [diff] [blame] | 1005 | CARDbGetCurrentTSF(priv, &qwNextTBTT); /* Get Local TSF counter */ |
Malcolm Priestley | 0fc2a76 | 2014-08-10 12:21:58 +0100 | [diff] [blame] | 1006 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1007 | qwNextTBTT = CARDqGetNextTBTT(qwNextTBTT, wBeaconInterval); |
Veronika Kabatova | 77b6a6a | 2014-10-25 22:34:38 +0200 | [diff] [blame] | 1008 | /* Set NextTBTT */ |
Malcolm Priestley | 0fc2a76 | 2014-08-10 12:21:58 +0100 | [diff] [blame] | 1009 | VNSvOutPortD(dwIoBase + MAC_REG_NEXTTBTT, (u32)qwNextTBTT); |
| 1010 | VNSvOutPortD(dwIoBase + MAC_REG_NEXTTBTT + 4, (u32)(qwNextTBTT >> 32)); |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1011 | MACvRegBitsOn(dwIoBase, MAC_REG_TFTCTL, TFTCTL_TBTTSYNCEN); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1012 | } |
| 1013 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1014 | /* |
| 1015 | * Description: Sync NIC TSF counter for Beacon time |
| 1016 | * Get NEXTTBTT and write to HW |
| 1017 | * |
| 1018 | * Parameters: |
| 1019 | * In: |
Malcolm Priestley | 9196124 | 2015-10-17 11:33:02 +0100 | [diff] [blame] | 1020 | * priv - The adapter to be set |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1021 | * qwTSF - Current TSF counter |
| 1022 | * wBeaconInterval - Beacon Interval |
| 1023 | * Out: |
| 1024 | * none |
| 1025 | * |
| 1026 | * Return Value: none |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1027 | */ |
Kathryn Hampton | 5150d01 | 2016-03-15 18:16:24 -0700 | [diff] [blame] | 1028 | void CARDvUpdateNextTBTT(struct vnt_private *priv, u64 qwTSF, |
| 1029 | unsigned short wBeaconInterval) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1030 | { |
Malcolm Priestley | 738487f | 2014-11-12 21:11:09 +0000 | [diff] [blame] | 1031 | void __iomem *dwIoBase = priv->PortOffset; |
| 1032 | |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1033 | qwTSF = CARDqGetNextTBTT(qwTSF, wBeaconInterval); |
Veronika Kabatova | 77b6a6a | 2014-10-25 22:34:38 +0200 | [diff] [blame] | 1034 | /* Set NextTBTT */ |
Malcolm Priestley | 0fc2a76 | 2014-08-10 12:21:58 +0100 | [diff] [blame] | 1035 | VNSvOutPortD(dwIoBase + MAC_REG_NEXTTBTT, (u32)qwTSF); |
| 1036 | VNSvOutPortD(dwIoBase + MAC_REG_NEXTTBTT + 4, (u32)(qwTSF >> 32)); |
Joe Perches | d4945f0 | 2013-03-18 10:44:40 -0700 | [diff] [blame] | 1037 | MACvRegBitsOn(dwIoBase, MAC_REG_TFTCTL, TFTCTL_TBTTSYNCEN); |
Joe Perches | 48caf5a | 2014-08-17 09:17:04 -0700 | [diff] [blame] | 1038 | pr_debug("Card:Update Next TBTT[%8llx]\n", qwTSF); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1039 | } |