Forest Bond | 92b9679 | 2009-06-13 07:38:31 -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: bssdb.c |
| 20 | * |
| 21 | * Purpose: Handles the Basic Service Set & Node Database functions |
| 22 | * |
| 23 | * Functions: |
| 24 | * BSSpSearchBSSList - Search known BSS list for Desire SSID or BSSID |
| 25 | * BSSvClearBSSList - Clear BSS List |
| 26 | * BSSbInsertToBSSList - Insert a BSS set into known BSS list |
| 27 | * BSSbUpdateToBSSList - Update BSS set in known BSS list |
| 28 | * BSSbIsSTAInNodeDB - Search Node DB table to find the index of matched DstAddr |
| 29 | * BSSvCreateOneNode - Allocate an Node for Node DB |
| 30 | * BSSvUpdateAPNode - Update AP Node content in Index 0 of KnownNodeDB |
| 31 | * BSSvSecondCallBack - One second timer callback function to update Node DB info & AP link status |
| 32 | * BSSvUpdateNodeTxCounter - Update Tx attemps, Tx failure counter in Node DB for auto-fall back rate control |
| 33 | * |
| 34 | * Revision History: |
| 35 | * |
| 36 | * Author: Lyndon Chen |
| 37 | * |
| 38 | * Date: July 17, 2002 |
| 39 | * |
| 40 | */ |
| 41 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 42 | #include "tmacro.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 43 | #include "tether.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 44 | #include "device.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 45 | #include "80211hdr.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 46 | #include "bssdb.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 47 | #include "wmgr.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 48 | #include "datarate.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 49 | #include "desc.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 50 | #include "wcmd.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 51 | #include "wpa.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 52 | #include "baseband.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 53 | #include "rf.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 54 | #include "card.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 55 | #include "mac.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 56 | #include "wpa2.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 57 | #include "control.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 58 | #include "rndis.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 59 | #include "iowpa.h" |
Malcolm Priestley | 60cc274 | 2013-10-14 19:46:52 +0100 | [diff] [blame] | 60 | #include "power.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 61 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 62 | static int msglevel =MSG_LEVEL_INFO; |
| 63 | //static int msglevel =MSG_LEVEL_DEBUG; |
| 64 | |
Valentina Manea | 3b13885 | 2013-11-04 10:44:02 +0200 | [diff] [blame] | 65 | static const u16 awHWRetry0[5][5] = { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 66 | {RATE_18M, RATE_18M, RATE_12M, RATE_12M, RATE_12M}, |
| 67 | {RATE_24M, RATE_24M, RATE_18M, RATE_12M, RATE_12M}, |
| 68 | {RATE_36M, RATE_36M, RATE_24M, RATE_18M, RATE_18M}, |
| 69 | {RATE_48M, RATE_48M, RATE_36M, RATE_24M, RATE_24M}, |
| 70 | {RATE_54M, RATE_54M, RATE_48M, RATE_36M, RATE_36M} |
| 71 | }; |
Valentina Manea | 3b13885 | 2013-11-04 10:44:02 +0200 | [diff] [blame] | 72 | static const u16 awHWRetry1[5][5] = { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 73 | {RATE_18M, RATE_18M, RATE_12M, RATE_6M, RATE_6M}, |
| 74 | {RATE_24M, RATE_24M, RATE_18M, RATE_6M, RATE_6M}, |
| 75 | {RATE_36M, RATE_36M, RATE_24M, RATE_12M, RATE_12M}, |
| 76 | {RATE_48M, RATE_48M, RATE_24M, RATE_12M, RATE_12M}, |
| 77 | {RATE_54M, RATE_54M, RATE_36M, RATE_18M, RATE_18M} |
| 78 | }; |
| 79 | |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 80 | static void s_vCheckSensitivity(struct vnt_private *pDevice); |
| 81 | static void s_vCheckPreEDThreshold(struct vnt_private *pDevice); |
| 82 | static void s_uCalculateLinkQual(struct vnt_private *pDevice); |
Andres More | 0cbd8d9 | 2010-05-06 20:34:29 -0300 | [diff] [blame] | 83 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 84 | /*+ |
| 85 | * |
| 86 | * Routine Description: |
| 87 | * Search known BSS list for Desire SSID or BSSID. |
| 88 | * |
| 89 | * Return Value: |
| 90 | * PTR to KnownBSS or NULL |
| 91 | * |
| 92 | -*/ |
| 93 | |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 94 | PKnownBSS BSSpSearchBSSList(struct vnt_private *pDevice, |
| 95 | u8 *pbyDesireBSSID, u8 *pbyDesireSSID, |
| 96 | CARD_PHY_TYPE ePhyType) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 97 | { |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 98 | struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; |
| 99 | u8 *pbyBSSID = NULL; |
| 100 | PWLAN_IE_SSID pSSID = NULL; |
| 101 | PKnownBSS pCurrBSS = NULL; |
| 102 | PKnownBSS pSelect = NULL; |
| 103 | u8 ZeroBSSID[WLAN_BSSID_LEN] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
| 104 | int ii = 0; |
| 105 | int jj = 0; |
| 106 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 107 | if (pbyDesireBSSID != NULL) { |
Andy Shevchenko | d3cc13a | 2012-07-06 18:28:17 +0300 | [diff] [blame] | 108 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO |
| 109 | "BSSpSearchBSSList BSSID[%pM]\n", pbyDesireBSSID); |
Andres More | 4b50fb4 | 2010-06-22 21:57:42 -0300 | [diff] [blame] | 110 | if ((!is_broadcast_ether_addr(pbyDesireBSSID)) && |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 111 | (memcmp(pbyDesireBSSID, ZeroBSSID, 6)!= 0)){ |
| 112 | pbyBSSID = pbyDesireBSSID; |
| 113 | } |
| 114 | } |
| 115 | if (pbyDesireSSID != NULL) { |
| 116 | if (((PWLAN_IE_SSID)pbyDesireSSID)->len != 0) { |
| 117 | pSSID = (PWLAN_IE_SSID) pbyDesireSSID; |
| 118 | } |
| 119 | } |
| 120 | |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 121 | if ((pbyBSSID != NULL)&&(pDevice->bRoaming == false)) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 122 | // match BSSID first |
| 123 | for (ii = 0; ii <MAX_BSS_NUM; ii++) { |
| 124 | pCurrBSS = &(pMgmt->sBSSList[ii]); |
| 125 | |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 126 | pCurrBSS->bSelected = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 127 | |
| 128 | if ((pCurrBSS->bActive) && |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 129 | (pCurrBSS->bSelected == false)) { |
Joe Perches | 8329419 | 2013-09-01 12:15:47 -0700 | [diff] [blame] | 130 | if (ether_addr_equal(pCurrBSS->abyBSSID, pbyBSSID)) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 131 | if (pSSID != NULL) { |
| 132 | // compare ssid |
Jim Lieb | 3e36259 | 2009-08-12 14:54:11 -0700 | [diff] [blame] | 133 | if ( !memcmp(pSSID->abySSID, |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 134 | ((PWLAN_IE_SSID)pCurrBSS->abySSID)->abySSID, |
| 135 | pSSID->len)) { |
| 136 | if ((pMgmt->eConfigMode == WMAC_CONFIG_AUTO) || |
| 137 | ((pMgmt->eConfigMode == WMAC_CONFIG_IBSS_STA) && WLAN_GET_CAP_INFO_IBSS(pCurrBSS->wCapInfo)) || |
| 138 | ((pMgmt->eConfigMode == WMAC_CONFIG_ESS_STA) && WLAN_GET_CAP_INFO_ESS(pCurrBSS->wCapInfo)) |
| 139 | ) { |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 140 | pCurrBSS->bSelected = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 141 | return(pCurrBSS); |
| 142 | } |
| 143 | } |
| 144 | } else { |
| 145 | if ((pMgmt->eConfigMode == WMAC_CONFIG_AUTO) || |
| 146 | ((pMgmt->eConfigMode == WMAC_CONFIG_IBSS_STA) && WLAN_GET_CAP_INFO_IBSS(pCurrBSS->wCapInfo)) || |
| 147 | ((pMgmt->eConfigMode == WMAC_CONFIG_ESS_STA) && WLAN_GET_CAP_INFO_ESS(pCurrBSS->wCapInfo)) |
| 148 | ) { |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 149 | pCurrBSS->bSelected = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 150 | return(pCurrBSS); |
| 151 | } |
| 152 | } |
| 153 | } |
| 154 | } |
| 155 | } |
| 156 | } else { |
| 157 | // ignore BSSID |
| 158 | for (ii = 0; ii <MAX_BSS_NUM; ii++) { |
| 159 | pCurrBSS = &(pMgmt->sBSSList[ii]); |
| 160 | |
| 161 | //2007-0721-01<Mark>by MikeLiu |
| 162 | // if ((pCurrBSS->bActive) && |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 163 | // (pCurrBSS->bSelected == false)) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 164 | |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 165 | pCurrBSS->bSelected = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 166 | if (pCurrBSS->bActive) { |
| 167 | |
| 168 | if (pSSID != NULL) { |
| 169 | // matched SSID |
Jim Lieb | 3e36259 | 2009-08-12 14:54:11 -0700 | [diff] [blame] | 170 | if (memcmp(pSSID->abySSID, |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 171 | ((PWLAN_IE_SSID)pCurrBSS->abySSID)->abySSID, |
| 172 | pSSID->len) || |
| 173 | (pSSID->len != ((PWLAN_IE_SSID)pCurrBSS->abySSID)->len)) { |
| 174 | // SSID not match skip this BSS |
| 175 | continue; |
| 176 | } |
| 177 | } |
| 178 | if (((pMgmt->eConfigMode == WMAC_CONFIG_IBSS_STA) && WLAN_GET_CAP_INFO_ESS(pCurrBSS->wCapInfo)) || |
| 179 | ((pMgmt->eConfigMode == WMAC_CONFIG_ESS_STA) && WLAN_GET_CAP_INFO_IBSS(pCurrBSS->wCapInfo)) |
| 180 | ){ |
| 181 | // Type not match skip this BSS |
| 182 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"BSS type mismatch.... Config[%d] BSS[0x%04x]\n", pMgmt->eConfigMode, pCurrBSS->wCapInfo); |
| 183 | continue; |
| 184 | } |
| 185 | |
| 186 | if (ePhyType != PHY_TYPE_AUTO) { |
| 187 | if (((ePhyType == PHY_TYPE_11A) && (PHY_TYPE_11A != pCurrBSS->eNetworkTypeInUse)) || |
| 188 | ((ePhyType != PHY_TYPE_11A) && (PHY_TYPE_11A == pCurrBSS->eNetworkTypeInUse))) { |
| 189 | // PhyType not match skip this BSS |
| 190 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Physical type mismatch.... ePhyType[%d] BSS[%d]\n", ePhyType, pCurrBSS->eNetworkTypeInUse); |
| 191 | continue; |
| 192 | } |
| 193 | } |
Andres More | 465711b | 2010-08-03 20:25:50 -0300 | [diff] [blame] | 194 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 195 | pMgmt->pSameBSS[jj].uChannel = pCurrBSS->uChannel; |
Andy Shevchenko | d3cc13a | 2012-07-06 18:28:17 +0300 | [diff] [blame] | 196 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO |
| 197 | "BSSpSearchBSSList pSelect1[%pM]\n", |
| 198 | pCurrBSS->abyBSSID); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 199 | jj++; |
| 200 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 201 | if (pSelect == NULL) { |
| 202 | pSelect = pCurrBSS; |
| 203 | } else { |
Justin P. Mattock | a0a1f61 | 2012-08-26 08:16:43 -0700 | [diff] [blame] | 204 | // compare RSSI, select the strongest signal |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 205 | if (pCurrBSS->uRSSI < pSelect->uRSSI) { |
| 206 | pSelect = pCurrBSS; |
| 207 | } |
| 208 | } |
| 209 | } |
| 210 | } |
Andres More | 465711b | 2010-08-03 20:25:50 -0300 | [diff] [blame] | 211 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 212 | pDevice->bSameBSSMaxNum = jj; |
Andres More | 465711b | 2010-08-03 20:25:50 -0300 | [diff] [blame] | 213 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 214 | if (pSelect != NULL) { |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 215 | pSelect->bSelected = true; |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 216 | if (pDevice->bRoaming == false) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 217 | // Einsn Add @20070907 |
Jim Lieb | 3e36259 | 2009-08-12 14:54:11 -0700 | [diff] [blame] | 218 | memcpy(pbyDesireSSID,pCurrBSS->abySSID,WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1) ; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 219 | } |
| 220 | |
| 221 | return(pSelect); |
| 222 | } |
| 223 | } |
| 224 | return(NULL); |
| 225 | |
| 226 | } |
| 227 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 228 | /*+ |
| 229 | * |
| 230 | * Routine Description: |
| 231 | * Clear BSS List |
| 232 | * |
| 233 | * Return Value: |
| 234 | * None. |
| 235 | * |
| 236 | -*/ |
| 237 | |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 238 | void BSSvClearBSSList(struct vnt_private *pDevice, int bKeepCurrBSSID) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 239 | { |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 240 | struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; |
| 241 | int ii; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 242 | |
| 243 | for (ii = 0; ii < MAX_BSS_NUM; ii++) { |
| 244 | if (bKeepCurrBSSID) { |
| 245 | if (pMgmt->sBSSList[ii].bActive && |
Joe Perches | 8329419 | 2013-09-01 12:15:47 -0700 | [diff] [blame] | 246 | ether_addr_equal(pMgmt->sBSSList[ii].abyBSSID, |
| 247 | pMgmt->abyCurrBSSID)) { |
Justin P. Mattock | a0a1f61 | 2012-08-26 08:16:43 -0700 | [diff] [blame] | 248 | //mike mark: there are two BSSID's in list. If that AP is in hidden ssid mode, one SSID is null, |
| 249 | // but other's might not be obvious, so if it associate's with your STA, |
| 250 | // you must keep the two of them!! |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 251 | // bKeepCurrBSSID = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 252 | continue; |
| 253 | } |
| 254 | } |
Marcos Paulo de Souza | ca76ede | 2011-11-30 00:19:25 -0200 | [diff] [blame] | 255 | |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 256 | pMgmt->sBSSList[ii].bActive = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 257 | memset(&pMgmt->sBSSList[ii], 0, sizeof(KnownBSS)); |
| 258 | } |
| 259 | BSSvClearAnyBSSJoinRecord(pDevice); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 260 | } |
| 261 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 262 | /*+ |
| 263 | * |
| 264 | * Routine Description: |
| 265 | * search BSS list by BSSID & SSID if matched |
| 266 | * |
| 267 | * Return Value: |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 268 | * true if found. |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 269 | * |
| 270 | -*/ |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 271 | PKnownBSS BSSpAddrIsInBSSList(struct vnt_private *pDevice, |
| 272 | u8 *abyBSSID, PWLAN_IE_SSID pSSID) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 273 | { |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 274 | struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; |
| 275 | PKnownBSS pBSSList = NULL; |
| 276 | int ii; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 277 | |
| 278 | for (ii = 0; ii < MAX_BSS_NUM; ii++) { |
| 279 | pBSSList = &(pMgmt->sBSSList[ii]); |
| 280 | if (pBSSList->bActive) { |
Joe Perches | 8329419 | 2013-09-01 12:15:47 -0700 | [diff] [blame] | 281 | if (ether_addr_equal(pBSSList->abyBSSID, abyBSSID)) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 282 | if (pSSID->len == ((PWLAN_IE_SSID)pBSSList->abySSID)->len){ |
| 283 | if (memcmp(pSSID->abySSID, |
| 284 | ((PWLAN_IE_SSID)pBSSList->abySSID)->abySSID, |
| 285 | pSSID->len) == 0) |
| 286 | return pBSSList; |
| 287 | } |
| 288 | } |
| 289 | } |
| 290 | } |
| 291 | |
| 292 | return NULL; |
| 293 | }; |
| 294 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 295 | /*+ |
| 296 | * |
| 297 | * Routine Description: |
| 298 | * Insert a BSS set into known BSS list |
| 299 | * |
| 300 | * Return Value: |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 301 | * true if success. |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 302 | * |
| 303 | -*/ |
| 304 | |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 305 | int BSSbInsertToBSSList(struct vnt_private *pDevice, |
| 306 | u8 *abyBSSIDAddr, |
Malcolm Priestley | 7c65fa2 | 2012-11-28 21:11:02 +0000 | [diff] [blame] | 307 | u64 qwTimestamp, |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 308 | u16 wBeaconInterval, |
| 309 | u16 wCapInfo, |
| 310 | u8 byCurrChannel, |
| 311 | PWLAN_IE_SSID pSSID, |
| 312 | PWLAN_IE_SUPP_RATES pSuppRates, |
| 313 | PWLAN_IE_SUPP_RATES pExtSuppRates, |
| 314 | PERPObject psERP, |
| 315 | PWLAN_IE_RSN pRSN, |
| 316 | PWLAN_IE_RSN_EXT pRSNWPA, |
| 317 | PWLAN_IE_COUNTRY pIE_Country, |
| 318 | PWLAN_IE_QUIET pIE_Quiet, |
| 319 | u32 uIELength, |
| 320 | u8 *pbyIEs, |
| 321 | void *pRxPacketContext) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 322 | { |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 323 | struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; |
| 324 | struct vnt_rx_mgmt *pRxPacket = |
| 325 | (struct vnt_rx_mgmt *)pRxPacketContext; |
| 326 | PKnownBSS pBSSList = NULL; |
| 327 | unsigned int ii; |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 328 | bool bParsingQuiet = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 329 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 330 | pBSSList = (PKnownBSS)&(pMgmt->sBSSList[0]); |
| 331 | |
| 332 | for (ii = 0; ii < MAX_BSS_NUM; ii++) { |
| 333 | pBSSList = (PKnownBSS)&(pMgmt->sBSSList[ii]); |
| 334 | if (!pBSSList->bActive) |
| 335 | break; |
| 336 | } |
| 337 | |
| 338 | if (ii == MAX_BSS_NUM){ |
| 339 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Get free KnowBSS node failed.\n"); |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 340 | return false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 341 | } |
| 342 | // save the BSS info |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 343 | pBSSList->bActive = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 344 | memcpy( pBSSList->abyBSSID, abyBSSIDAddr, WLAN_BSSID_LEN); |
Malcolm Priestley | 7c65fa2 | 2012-11-28 21:11:02 +0000 | [diff] [blame] | 345 | pBSSList->qwBSSTimestamp = cpu_to_le64(qwTimestamp); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 346 | pBSSList->wBeaconInterval = cpu_to_le16(wBeaconInterval); |
| 347 | pBSSList->wCapInfo = cpu_to_le16(wCapInfo); |
| 348 | pBSSList->uClearCount = 0; |
| 349 | |
| 350 | if (pSSID->len > WLAN_SSID_MAXLEN) |
| 351 | pSSID->len = WLAN_SSID_MAXLEN; |
| 352 | memcpy( pBSSList->abySSID, pSSID, pSSID->len + WLAN_IEHDR_LEN); |
| 353 | |
| 354 | pBSSList->uChannel = byCurrChannel; |
| 355 | |
| 356 | if (pSuppRates->len > WLAN_RATES_MAXLEN) |
| 357 | pSuppRates->len = WLAN_RATES_MAXLEN; |
| 358 | memcpy( pBSSList->abySuppRates, pSuppRates, pSuppRates->len + WLAN_IEHDR_LEN); |
| 359 | |
| 360 | if (pExtSuppRates != NULL) { |
| 361 | if (pExtSuppRates->len > WLAN_RATES_MAXLEN) |
| 362 | pExtSuppRates->len = WLAN_RATES_MAXLEN; |
| 363 | memcpy(pBSSList->abyExtSuppRates, pExtSuppRates, pExtSuppRates->len + WLAN_IEHDR_LEN); |
| 364 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"BSSbInsertToBSSList: pExtSuppRates->len = %d\n", pExtSuppRates->len); |
| 365 | |
| 366 | } else { |
| 367 | memset(pBSSList->abyExtSuppRates, 0, WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1); |
| 368 | } |
| 369 | pBSSList->sERP.byERP = psERP->byERP; |
| 370 | pBSSList->sERP.bERPExist = psERP->bERPExist; |
| 371 | |
| 372 | // Check if BSS is 802.11a/b/g |
| 373 | if (pBSSList->uChannel > CB_MAX_CHANNEL_24G) { |
| 374 | pBSSList->eNetworkTypeInUse = PHY_TYPE_11A; |
| 375 | } else { |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 376 | if (pBSSList->sERP.bERPExist == true) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 377 | pBSSList->eNetworkTypeInUse = PHY_TYPE_11G; |
| 378 | } else { |
| 379 | pBSSList->eNetworkTypeInUse = PHY_TYPE_11B; |
| 380 | } |
| 381 | } |
| 382 | |
| 383 | pBSSList->byRxRate = pRxPacket->byRxRate; |
| 384 | pBSSList->qwLocalTSF = pRxPacket->qwLocalTSF; |
| 385 | pBSSList->uRSSI = pRxPacket->uRSSI; |
| 386 | pBSSList->bySQ = pRxPacket->bySQ; |
| 387 | |
| 388 | if ((pMgmt->eCurrMode == WMAC_MODE_ESS_STA) && |
| 389 | (pMgmt->eCurrState == WMAC_STATE_ASSOC)) { |
| 390 | // assoc with BSS |
| 391 | if (pBSSList == pMgmt->pCurrBSS) { |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 392 | bParsingQuiet = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 393 | } |
| 394 | } |
| 395 | |
| 396 | WPA_ClearRSN(pBSSList); |
| 397 | |
| 398 | if (pRSNWPA != NULL) { |
Andres More | cc856e6 | 2010-05-17 21:34:01 -0300 | [diff] [blame] | 399 | unsigned int uLen = pRSNWPA->len + 2; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 400 | |
Andres More | cc856e6 | 2010-05-17 21:34:01 -0300 | [diff] [blame] | 401 | if (uLen <= (uIELength - |
Andres More | 1f9eedc | 2013-02-25 20:32:54 -0500 | [diff] [blame] | 402 | (unsigned int) (u32) ((u8 *) pRSNWPA - pbyIEs))) { |
Andres More | cc856e6 | 2010-05-17 21:34:01 -0300 | [diff] [blame] | 403 | pBSSList->wWPALen = uLen; |
| 404 | memcpy(pBSSList->byWPAIE, pRSNWPA, uLen); |
| 405 | WPA_ParseRSN(pBSSList, pRSNWPA); |
| 406 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 407 | } |
| 408 | |
| 409 | WPA2_ClearRSN(pBSSList); |
| 410 | |
| 411 | if (pRSN != NULL) { |
Andres More | cc856e6 | 2010-05-17 21:34:01 -0300 | [diff] [blame] | 412 | unsigned int uLen = pRSN->len + 2; |
| 413 | |
| 414 | if (uLen <= (uIELength - |
Andres More | 1f9eedc | 2013-02-25 20:32:54 -0500 | [diff] [blame] | 415 | (unsigned int) (u32) ((u8 *) pRSN - pbyIEs))) { |
Andres More | cc856e6 | 2010-05-17 21:34:01 -0300 | [diff] [blame] | 416 | pBSSList->wRSNLen = uLen; |
| 417 | memcpy(pBSSList->byRSNIE, pRSN, uLen); |
| 418 | WPA2vParseRSN(pBSSList, pRSN); |
| 419 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 420 | } |
| 421 | |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 422 | if ((pMgmt->eAuthenMode == WMAC_AUTH_WPA2) || (pBSSList->bWPA2Valid == true)) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 423 | |
| 424 | PSKeyItem pTransmitKey = NULL; |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 425 | bool bIs802_1x = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 426 | |
| 427 | for (ii = 0; ii < pBSSList->wAKMSSAuthCount; ii ++) { |
| 428 | if (pBSSList->abyAKMSSAuthType[ii] == WLAN_11i_AKMSS_802_1X) { |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 429 | bIs802_1x = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 430 | break; |
| 431 | } |
| 432 | } |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 433 | if ((bIs802_1x == true) && (pSSID->len == ((PWLAN_IE_SSID)pMgmt->abyDesireSSID)->len) && |
Jim Lieb | 3e36259 | 2009-08-12 14:54:11 -0700 | [diff] [blame] | 434 | ( !memcmp(pSSID->abySSID, ((PWLAN_IE_SSID)pMgmt->abyDesireSSID)->abySSID, pSSID->len))) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 435 | |
Andres More | 0cbd8d9 | 2010-05-06 20:34:29 -0300 | [diff] [blame] | 436 | bAdd_PMKID_Candidate((void *) pDevice, |
| 437 | pBSSList->abyBSSID, |
| 438 | &pBSSList->sRSNCapObj); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 439 | |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 440 | if ((pDevice->bLinkPass == true) && (pMgmt->eCurrState == WMAC_STATE_ASSOC)) { |
| 441 | if ((KeybGetTransmitKey(&(pDevice->sKey), pDevice->abyBSSID, PAIRWISE_KEY, &pTransmitKey) == true) || |
| 442 | (KeybGetTransmitKey(&(pDevice->sKey), pDevice->abyBSSID, GROUP_KEY, &pTransmitKey) == true)) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 443 | pDevice->gsPMKIDCandidate.StatusType = Ndis802_11StatusType_PMKID_CandidateList; |
| 444 | pDevice->gsPMKIDCandidate.Version = 1; |
| 445 | |
| 446 | } |
| 447 | |
| 448 | } |
| 449 | } |
| 450 | } |
| 451 | |
| 452 | if (pDevice->bUpdateBBVGA) { |
Justin P. Mattock | a0a1f61 | 2012-08-26 08:16:43 -0700 | [diff] [blame] | 453 | // Monitor if RSSI is too strong. |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 454 | pBSSList->byRSSIStatCnt = 0; |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 455 | RFvRSSITodBm(pDevice, (u8)(pRxPacket->uRSSI), &pBSSList->ldBmMAX); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 456 | pBSSList->ldBmAverage[0] = pBSSList->ldBmMAX; |
| 457 | pBSSList->ldBmAverRange = pBSSList->ldBmMAX; |
| 458 | for (ii = 1; ii < RSSI_STAT_COUNT; ii++) |
| 459 | pBSSList->ldBmAverage[ii] = 0; |
| 460 | } |
| 461 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 462 | pBSSList->uIELength = uIELength; |
| 463 | if (pBSSList->uIELength > WLAN_BEACON_FR_MAXLEN) |
| 464 | pBSSList->uIELength = WLAN_BEACON_FR_MAXLEN; |
Jim Lieb | 3e36259 | 2009-08-12 14:54:11 -0700 | [diff] [blame] | 465 | memcpy(pBSSList->abyIEs, pbyIEs, pBSSList->uIELength); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 466 | |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 467 | return true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 468 | } |
| 469 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 470 | /*+ |
| 471 | * |
| 472 | * Routine Description: |
| 473 | * Update BSS set in known BSS list |
| 474 | * |
| 475 | * Return Value: |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 476 | * true if success. |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 477 | * |
| 478 | -*/ |
| 479 | // TODO: input structure modify |
| 480 | |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 481 | int BSSbUpdateToBSSList(struct vnt_private *pDevice, |
Malcolm Priestley | 7c65fa2 | 2012-11-28 21:11:02 +0000 | [diff] [blame] | 482 | u64 qwTimestamp, |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 483 | u16 wBeaconInterval, |
| 484 | u16 wCapInfo, |
| 485 | u8 byCurrChannel, |
| 486 | int bChannelHit, |
| 487 | PWLAN_IE_SSID pSSID, |
| 488 | PWLAN_IE_SUPP_RATES pSuppRates, |
| 489 | PWLAN_IE_SUPP_RATES pExtSuppRates, |
| 490 | PERPObject psERP, |
| 491 | PWLAN_IE_RSN pRSN, |
| 492 | PWLAN_IE_RSN_EXT pRSNWPA, |
| 493 | PWLAN_IE_COUNTRY pIE_Country, |
| 494 | PWLAN_IE_QUIET pIE_Quiet, |
| 495 | PKnownBSS pBSSList, |
| 496 | u32 uIELength, |
| 497 | u8 *pbyIEs, |
| 498 | void *pRxPacketContext) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 499 | { |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 500 | struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; |
| 501 | struct vnt_rx_mgmt *pRxPacket = |
| 502 | (struct vnt_rx_mgmt *)pRxPacketContext; |
| 503 | int ii, jj; |
| 504 | signed long ldBm, ldBmSum; |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 505 | bool bParsingQuiet = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 506 | |
| 507 | if (pBSSList == NULL) |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 508 | return false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 509 | |
Malcolm Priestley | 7c65fa2 | 2012-11-28 21:11:02 +0000 | [diff] [blame] | 510 | pBSSList->qwBSSTimestamp = cpu_to_le64(qwTimestamp); |
| 511 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 512 | pBSSList->wBeaconInterval = cpu_to_le16(wBeaconInterval); |
| 513 | pBSSList->wCapInfo = cpu_to_le16(wCapInfo); |
| 514 | pBSSList->uClearCount = 0; |
| 515 | pBSSList->uChannel = byCurrChannel; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 516 | |
| 517 | if (pSSID->len > WLAN_SSID_MAXLEN) |
| 518 | pSSID->len = WLAN_SSID_MAXLEN; |
| 519 | |
| 520 | if ((pSSID->len != 0) && (pSSID->abySSID[0] != 0)) |
| 521 | memcpy(pBSSList->abySSID, pSSID, pSSID->len + WLAN_IEHDR_LEN); |
| 522 | memcpy(pBSSList->abySuppRates, pSuppRates,pSuppRates->len + WLAN_IEHDR_LEN); |
| 523 | |
| 524 | if (pExtSuppRates != NULL) { |
| 525 | memcpy(pBSSList->abyExtSuppRates, pExtSuppRates,pExtSuppRates->len + WLAN_IEHDR_LEN); |
| 526 | } else { |
| 527 | memset(pBSSList->abyExtSuppRates, 0, WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1); |
| 528 | } |
| 529 | pBSSList->sERP.byERP = psERP->byERP; |
| 530 | pBSSList->sERP.bERPExist = psERP->bERPExist; |
| 531 | |
| 532 | // Check if BSS is 802.11a/b/g |
| 533 | if (pBSSList->uChannel > CB_MAX_CHANNEL_24G) { |
| 534 | pBSSList->eNetworkTypeInUse = PHY_TYPE_11A; |
| 535 | } else { |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 536 | if (pBSSList->sERP.bERPExist == true) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 537 | pBSSList->eNetworkTypeInUse = PHY_TYPE_11G; |
| 538 | } else { |
| 539 | pBSSList->eNetworkTypeInUse = PHY_TYPE_11B; |
| 540 | } |
| 541 | } |
| 542 | |
| 543 | pBSSList->byRxRate = pRxPacket->byRxRate; |
| 544 | pBSSList->qwLocalTSF = pRxPacket->qwLocalTSF; |
| 545 | if(bChannelHit) |
| 546 | pBSSList->uRSSI = pRxPacket->uRSSI; |
| 547 | pBSSList->bySQ = pRxPacket->bySQ; |
| 548 | |
| 549 | if ((pMgmt->eCurrMode == WMAC_MODE_ESS_STA) && |
| 550 | (pMgmt->eCurrState == WMAC_STATE_ASSOC)) { |
| 551 | // assoc with BSS |
| 552 | if (pBSSList == pMgmt->pCurrBSS) { |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 553 | bParsingQuiet = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 554 | } |
| 555 | } |
| 556 | |
| 557 | WPA_ClearRSN(pBSSList); //mike update |
| 558 | |
Andres More | cc856e6 | 2010-05-17 21:34:01 -0300 | [diff] [blame] | 559 | if (pRSNWPA != NULL) { |
| 560 | unsigned int uLen = pRSNWPA->len + 2; |
| 561 | if (uLen <= (uIELength - |
Andres More | 1f9eedc | 2013-02-25 20:32:54 -0500 | [diff] [blame] | 562 | (unsigned int) (u32) ((u8 *) pRSNWPA - pbyIEs))) { |
Andres More | cc856e6 | 2010-05-17 21:34:01 -0300 | [diff] [blame] | 563 | pBSSList->wWPALen = uLen; |
| 564 | memcpy(pBSSList->byWPAIE, pRSNWPA, uLen); |
| 565 | WPA_ParseRSN(pBSSList, pRSNWPA); |
| 566 | } |
| 567 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 568 | |
| 569 | WPA2_ClearRSN(pBSSList); //mike update |
| 570 | |
| 571 | if (pRSN != NULL) { |
Andres More | cc856e6 | 2010-05-17 21:34:01 -0300 | [diff] [blame] | 572 | unsigned int uLen = pRSN->len + 2; |
| 573 | if (uLen <= (uIELength - |
Andres More | 1f9eedc | 2013-02-25 20:32:54 -0500 | [diff] [blame] | 574 | (unsigned int) (u32) ((u8 *) pRSN - pbyIEs))) { |
Andres More | cc856e6 | 2010-05-17 21:34:01 -0300 | [diff] [blame] | 575 | pBSSList->wRSNLen = uLen; |
| 576 | memcpy(pBSSList->byRSNIE, pRSN, uLen); |
| 577 | WPA2vParseRSN(pBSSList, pRSN); |
| 578 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 579 | } |
| 580 | |
| 581 | if (pRxPacket->uRSSI != 0) { |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 582 | RFvRSSITodBm(pDevice, (u8)(pRxPacket->uRSSI), &ldBm); |
Justin P. Mattock | a0a1f61 | 2012-08-26 08:16:43 -0700 | [diff] [blame] | 583 | // Monitor if RSSI is too strong. |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 584 | pBSSList->byRSSIStatCnt++; |
| 585 | pBSSList->byRSSIStatCnt %= RSSI_STAT_COUNT; |
| 586 | pBSSList->ldBmAverage[pBSSList->byRSSIStatCnt] = ldBm; |
| 587 | ldBmSum = 0; |
Andres More | 33d33e42 | 2010-05-19 23:50:00 -0300 | [diff] [blame] | 588 | for (ii = 0, jj = 0; ii < RSSI_STAT_COUNT; ii++) { |
| 589 | if (pBSSList->ldBmAverage[ii] != 0) { |
| 590 | pBSSList->ldBmMAX = |
| 591 | max(pBSSList->ldBmAverage[ii], ldBm); |
| 592 | ldBmSum += |
| 593 | pBSSList->ldBmAverage[ii]; |
| 594 | jj++; |
| 595 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 596 | } |
| 597 | pBSSList->ldBmAverRange = ldBmSum /jj; |
| 598 | } |
| 599 | |
| 600 | pBSSList->uIELength = uIELength; |
| 601 | if (pBSSList->uIELength > WLAN_BEACON_FR_MAXLEN) |
| 602 | pBSSList->uIELength = WLAN_BEACON_FR_MAXLEN; |
| 603 | memcpy(pBSSList->abyIEs, pbyIEs, pBSSList->uIELength); |
| 604 | |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 605 | return true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 606 | } |
| 607 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 608 | /*+ |
| 609 | * |
| 610 | * Routine Description: |
| 611 | * Search Node DB table to find the index of matched DstAddr |
| 612 | * |
| 613 | * Return Value: |
| 614 | * None |
| 615 | * |
| 616 | -*/ |
| 617 | |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 618 | int BSSbIsSTAInNodeDB(struct vnt_private *pDevice, |
| 619 | u8 *abyDstAddr, u32 *puNodeIndex) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 620 | { |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 621 | struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; |
| 622 | unsigned int ii; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 623 | |
| 624 | // Index = 0 reserved for AP Node |
| 625 | for (ii = 1; ii < (MAX_NODE_NUM + 1); ii++) { |
| 626 | if (pMgmt->sNodeDBTable[ii].bActive) { |
Joe Perches | 8329419 | 2013-09-01 12:15:47 -0700 | [diff] [blame] | 627 | if (ether_addr_equal(abyDstAddr, |
| 628 | pMgmt->sNodeDBTable[ii].abyMACAddr)) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 629 | *puNodeIndex = ii; |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 630 | return true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 631 | } |
| 632 | } |
| 633 | } |
| 634 | |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 635 | return false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 636 | }; |
| 637 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 638 | /*+ |
| 639 | * |
| 640 | * Routine Description: |
Justin P. Mattock | a0a1f61 | 2012-08-26 08:16:43 -0700 | [diff] [blame] | 641 | * Find an empty node and allocate it; if no empty node |
| 642 | * is found, then use the most inactive one. |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 643 | * |
| 644 | * Return Value: |
| 645 | * None |
| 646 | * |
| 647 | -*/ |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 648 | void BSSvCreateOneNode(struct vnt_private *pDevice, u32 *puNodeIndex) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 649 | { |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 650 | struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; |
| 651 | int ii; |
| 652 | u32 BigestCount = 0; |
| 653 | u32 SelectIndex; |
| 654 | struct sk_buff *skb; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 655 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 656 | // Index = 0 reserved for AP Node (In STA mode) |
| 657 | // Index = 0 reserved for Broadcast/MultiCast (In AP mode) |
| 658 | SelectIndex = 1; |
| 659 | for (ii = 1; ii < (MAX_NODE_NUM + 1); ii++) { |
| 660 | if (pMgmt->sNodeDBTable[ii].bActive) { |
| 661 | if (pMgmt->sNodeDBTable[ii].uInActiveCount > BigestCount) { |
| 662 | BigestCount = pMgmt->sNodeDBTable[ii].uInActiveCount; |
| 663 | SelectIndex = ii; |
| 664 | } |
| 665 | } |
| 666 | else { |
| 667 | break; |
| 668 | } |
| 669 | } |
| 670 | |
Justin P. Mattock | a0a1f61 | 2012-08-26 08:16:43 -0700 | [diff] [blame] | 671 | // if not found replace uInActiveCount with the largest one. |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 672 | if ( ii == (MAX_NODE_NUM + 1)) { |
| 673 | *puNodeIndex = SelectIndex; |
| 674 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Replace inactive node = %d\n", SelectIndex); |
| 675 | // clear ps buffer |
| 676 | if (pMgmt->sNodeDBTable[*puNodeIndex].sTxPSQueue.next != NULL) { |
| 677 | while ((skb = skb_dequeue(&pMgmt->sNodeDBTable[*puNodeIndex].sTxPSQueue)) != NULL) |
| 678 | dev_kfree_skb(skb); |
| 679 | } |
| 680 | } |
| 681 | else { |
| 682 | *puNodeIndex = ii; |
| 683 | } |
| 684 | |
| 685 | memset(&pMgmt->sNodeDBTable[*puNodeIndex], 0, sizeof(KnownNodeDB)); |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 686 | pMgmt->sNodeDBTable[*puNodeIndex].bActive = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 687 | pMgmt->sNodeDBTable[*puNodeIndex].uRatePollTimeout = FALLBACK_POLL_SECOND; |
| 688 | // for AP mode PS queue |
| 689 | skb_queue_head_init(&pMgmt->sNodeDBTable[*puNodeIndex].sTxPSQueue); |
| 690 | pMgmt->sNodeDBTable[*puNodeIndex].byAuthSequence = 0; |
| 691 | pMgmt->sNodeDBTable[*puNodeIndex].wEnQueueCnt = 0; |
| 692 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Create node index = %d\n", ii); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 693 | }; |
| 694 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 695 | /*+ |
| 696 | * |
| 697 | * Routine Description: |
| 698 | * Remove Node by NodeIndex |
| 699 | * |
| 700 | * |
| 701 | * Return Value: |
| 702 | * None |
| 703 | * |
| 704 | -*/ |
Andres More | 0cbd8d9 | 2010-05-06 20:34:29 -0300 | [diff] [blame] | 705 | |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 706 | void BSSvRemoveOneNode(struct vnt_private *pDevice, u32 uNodeIndex) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 707 | { |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 708 | struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; |
| 709 | u8 byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80}; |
| 710 | struct sk_buff *skb; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 711 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 712 | while ((skb = skb_dequeue(&pMgmt->sNodeDBTable[uNodeIndex].sTxPSQueue)) != NULL) |
| 713 | dev_kfree_skb(skb); |
| 714 | // clear context |
| 715 | memset(&pMgmt->sNodeDBTable[uNodeIndex], 0, sizeof(KnownNodeDB)); |
| 716 | // clear tx bit map |
| 717 | pMgmt->abyPSTxMap[pMgmt->sNodeDBTable[uNodeIndex].wAID >> 3] &= ~byMask[pMgmt->sNodeDBTable[uNodeIndex].wAID & 7]; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 718 | }; |
| 719 | /*+ |
| 720 | * |
| 721 | * Routine Description: |
| 722 | * Update AP Node content in Index 0 of KnownNodeDB |
| 723 | * |
| 724 | * |
| 725 | * Return Value: |
| 726 | * None |
| 727 | * |
| 728 | -*/ |
| 729 | |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 730 | void BSSvUpdateAPNode(struct vnt_private *pDevice, u16 *pwCapInfo, |
| 731 | PWLAN_IE_SUPP_RATES pSuppRates, PWLAN_IE_SUPP_RATES pExtSuppRates) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 732 | { |
Malcolm Priestley | 14c5ef5 | 2013-01-17 23:19:37 +0000 | [diff] [blame] | 733 | struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 734 | u32 uRateLen = WLAN_RATES_MAXLEN; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 735 | |
| 736 | memset(&pMgmt->sNodeDBTable[0], 0, sizeof(KnownNodeDB)); |
| 737 | |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 738 | pMgmt->sNodeDBTable[0].bActive = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 739 | if (pDevice->byBBType == BB_TYPE_11B) { |
| 740 | uRateLen = WLAN_RATES_MAXLEN_11B; |
| 741 | } |
| 742 | pMgmt->abyCurrSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)pSuppRates, |
| 743 | (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates, |
| 744 | uRateLen); |
| 745 | pMgmt->abyCurrExtSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)pExtSuppRates, |
| 746 | (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates, |
| 747 | uRateLen); |
Andres More | 8611a29 | 2010-05-01 14:25:00 -0300 | [diff] [blame] | 748 | RATEvParseMaxRate((void *) pDevice, |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 749 | (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates, |
| 750 | (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates, |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 751 | true, |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 752 | &(pMgmt->sNodeDBTable[0].wMaxBasicRate), |
| 753 | &(pMgmt->sNodeDBTable[0].wMaxSuppRate), |
| 754 | &(pMgmt->sNodeDBTable[0].wSuppRate), |
| 755 | &(pMgmt->sNodeDBTable[0].byTopCCKBasicRate), |
| 756 | &(pMgmt->sNodeDBTable[0].byTopOFDMBasicRate) |
| 757 | ); |
| 758 | memcpy(pMgmt->sNodeDBTable[0].abyMACAddr, pMgmt->abyCurrBSSID, WLAN_ADDR_LEN); |
| 759 | pMgmt->sNodeDBTable[0].wTxDataRate = pMgmt->sNodeDBTable[0].wMaxSuppRate; |
| 760 | pMgmt->sNodeDBTable[0].bShortPreamble = WLAN_GET_CAP_INFO_SHORTPREAMBLE(*pwCapInfo); |
| 761 | pMgmt->sNodeDBTable[0].uRatePollTimeout = FALLBACK_POLL_SECOND; |
| 762 | // Auto rate fallback function initiation. |
| 763 | // RATEbInit(pDevice); |
| 764 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pMgmt->sNodeDBTable[0].wTxDataRate = %d \n", pMgmt->sNodeDBTable[0].wTxDataRate); |
| 765 | |
| 766 | }; |
| 767 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 768 | /*+ |
| 769 | * |
| 770 | * Routine Description: |
| 771 | * Add Multicast Node content in Index 0 of KnownNodeDB |
| 772 | * |
| 773 | * |
| 774 | * Return Value: |
| 775 | * None |
| 776 | * |
| 777 | -*/ |
| 778 | |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 779 | void BSSvAddMulticastNode(struct vnt_private *pDevice) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 780 | { |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 781 | struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 782 | |
| 783 | if (!pDevice->bEnableHostWEP) |
| 784 | memset(&pMgmt->sNodeDBTable[0], 0, sizeof(KnownNodeDB)); |
| 785 | memset(pMgmt->sNodeDBTable[0].abyMACAddr, 0xff, WLAN_ADDR_LEN); |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 786 | pMgmt->sNodeDBTable[0].bActive = true; |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 787 | pMgmt->sNodeDBTable[0].bPSEnable = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 788 | skb_queue_head_init(&pMgmt->sNodeDBTable[0].sTxPSQueue); |
Andres More | 8611a29 | 2010-05-01 14:25:00 -0300 | [diff] [blame] | 789 | RATEvParseMaxRate((void *) pDevice, |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 790 | (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates, |
| 791 | (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates, |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 792 | true, |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 793 | &(pMgmt->sNodeDBTable[0].wMaxBasicRate), |
| 794 | &(pMgmt->sNodeDBTable[0].wMaxSuppRate), |
| 795 | &(pMgmt->sNodeDBTable[0].wSuppRate), |
| 796 | &(pMgmt->sNodeDBTable[0].byTopCCKBasicRate), |
| 797 | &(pMgmt->sNodeDBTable[0].byTopOFDMBasicRate) |
| 798 | ); |
| 799 | pMgmt->sNodeDBTable[0].wTxDataRate = pMgmt->sNodeDBTable[0].wMaxBasicRate; |
| 800 | pMgmt->sNodeDBTable[0].uRatePollTimeout = FALLBACK_POLL_SECOND; |
| 801 | |
| 802 | }; |
| 803 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 804 | /*+ |
| 805 | * |
| 806 | * Routine Description: |
| 807 | * |
| 808 | * |
| 809 | * Second call back function to update Node DB info & AP link status |
| 810 | * |
| 811 | * |
| 812 | * Return Value: |
| 813 | * none. |
| 814 | * |
| 815 | -*/ |
| 816 | |
Malcolm Priestley | bd9a6db | 2013-09-27 16:51:13 +0100 | [diff] [blame] | 817 | void BSSvSecondCallBack(struct work_struct *work) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 818 | { |
Malcolm Priestley | bd9a6db | 2013-09-27 16:51:13 +0100 | [diff] [blame] | 819 | struct vnt_private *pDevice = container_of(work, |
| 820 | struct vnt_private, second_callback_work.work); |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 821 | struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; |
| 822 | int ii; |
| 823 | PWLAN_IE_SSID pItemSSID, pCurrSSID; |
| 824 | u32 uSleepySTACnt = 0; |
| 825 | u32 uNonShortSlotSTACnt = 0; |
| 826 | u32 uLongPreambleSTACnt = 0; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 827 | |
Malcolm Priestley | 17f3ced | 2013-10-14 19:51:45 +0100 | [diff] [blame] | 828 | if (pDevice->Flags & fMP_DISCONNECTED) |
| 829 | return; |
| 830 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 831 | spin_lock_irq(&pDevice->lock); |
| 832 | |
| 833 | pDevice->uAssocCount = 0; |
| 834 | |
| 835 | //Power Saving Mode Tx Burst |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 836 | if ( pDevice->bEnablePSMode == true ) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 837 | pDevice->ulPSModeWaitTx++; |
| 838 | if ( pDevice->ulPSModeWaitTx >= 2 ) { |
| 839 | pDevice->ulPSModeWaitTx = 0; |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 840 | pDevice->bPSModeTxBurst = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 841 | } |
| 842 | } |
| 843 | |
| 844 | pDevice->byERPFlag &= |
| 845 | ~(WLAN_SET_ERP_BARKER_MODE(1) | WLAN_SET_ERP_NONERP_PRESENT(1)); |
| 846 | |
| 847 | if (pDevice->wUseProtectCntDown > 0) { |
| 848 | pDevice->wUseProtectCntDown --; |
| 849 | } |
| 850 | else { |
| 851 | // disable protect mode |
| 852 | pDevice->byERPFlag &= ~(WLAN_SET_ERP_USE_PROTECTION(1)); |
| 853 | } |
| 854 | |
| 855 | if(pDevice->byReAssocCount > 0) { |
| 856 | pDevice->byReAssocCount++; |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 857 | if((pDevice->byReAssocCount > 10) && (pDevice->bLinkPass != true)) { //10 sec timeout |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 858 | printk("Re-association timeout!!!\n"); |
| 859 | pDevice->byReAssocCount = 0; |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 860 | // if(pDevice->bWPASuppWextEnabled == true) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 861 | { |
| 862 | union iwreq_data wrqu; |
| 863 | memset(&wrqu, 0, sizeof (wrqu)); |
| 864 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 865 | PRINT_K("wireless_send_event--->SIOCGIWAP(disassociated)\n"); |
| 866 | wireless_send_event(pDevice->dev, SIOCGIWAP, &wrqu, NULL); |
| 867 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 868 | } |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 869 | else if(pDevice->bLinkPass == true) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 870 | pDevice->byReAssocCount = 0; |
| 871 | } |
| 872 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 873 | pMgmt->eLastState = pMgmt->eCurrState ; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 874 | |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 875 | s_uCalculateLinkQual(pDevice); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 876 | |
| 877 | for (ii = 0; ii < (MAX_NODE_NUM + 1); ii++) { |
| 878 | |
| 879 | if (pMgmt->sNodeDBTable[ii].bActive) { |
| 880 | // Increase in-activity counter |
| 881 | pMgmt->sNodeDBTable[ii].uInActiveCount++; |
| 882 | |
| 883 | if (ii > 0) { |
| 884 | if (pMgmt->sNodeDBTable[ii].uInActiveCount > MAX_INACTIVE_COUNT) { |
| 885 | BSSvRemoveOneNode(pDevice, ii); |
| 886 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO |
| 887 | "Inactive timeout [%d] sec, STA index = [%d] remove\n", MAX_INACTIVE_COUNT, ii); |
| 888 | continue; |
| 889 | } |
| 890 | |
| 891 | if (pMgmt->sNodeDBTable[ii].eNodeState >= NODE_ASSOC) { |
| 892 | |
| 893 | pDevice->uAssocCount++; |
| 894 | |
| 895 | // check if Non ERP exist |
| 896 | if (pMgmt->sNodeDBTable[ii].uInActiveCount < ERP_RECOVER_COUNT) { |
| 897 | if (!pMgmt->sNodeDBTable[ii].bShortPreamble) { |
| 898 | pDevice->byERPFlag |= WLAN_SET_ERP_BARKER_MODE(1); |
| 899 | uLongPreambleSTACnt ++; |
| 900 | } |
| 901 | if (!pMgmt->sNodeDBTable[ii].bERPExist) { |
| 902 | pDevice->byERPFlag |= WLAN_SET_ERP_NONERP_PRESENT(1); |
| 903 | pDevice->byERPFlag |= WLAN_SET_ERP_USE_PROTECTION(1); |
| 904 | } |
| 905 | if (!pMgmt->sNodeDBTable[ii].bShortSlotTime) |
| 906 | uNonShortSlotSTACnt++; |
| 907 | } |
| 908 | } |
| 909 | |
| 910 | // check if any STA in PS mode |
| 911 | if (pMgmt->sNodeDBTable[ii].bPSEnable) |
| 912 | uSleepySTACnt++; |
| 913 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 914 | } |
| 915 | |
| 916 | // Rate fallback check |
| 917 | if (!pDevice->bFixRate) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 918 | if (ii > 0) { |
| 919 | // ii = 0 for multicast node (AP & Adhoc) |
Andres More | 8611a29 | 2010-05-01 14:25:00 -0300 | [diff] [blame] | 920 | RATEvTxRateFallBack((void *)pDevice, |
| 921 | &(pMgmt->sNodeDBTable[ii])); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 922 | } |
| 923 | else { |
| 924 | // ii = 0 reserved for unicast AP node (Infra STA) |
Andres More | 8611a29 | 2010-05-01 14:25:00 -0300 | [diff] [blame] | 925 | if (pMgmt->eCurrMode == WMAC_MODE_ESS_STA) |
| 926 | RATEvTxRateFallBack((void *)pDevice, |
| 927 | &(pMgmt->sNodeDBTable[ii])); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 928 | } |
| 929 | |
| 930 | } |
| 931 | |
| 932 | // check if pending PS queue |
| 933 | if (pMgmt->sNodeDBTable[ii].wEnQueueCnt != 0) { |
| 934 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Index= %d, Queue = %d pending \n", |
| 935 | ii, pMgmt->sNodeDBTable[ii].wEnQueueCnt); |
| 936 | if ((ii >0) && (pMgmt->sNodeDBTable[ii].wEnQueueCnt > 15)) { |
| 937 | BSSvRemoveOneNode(pDevice, ii); |
| 938 | DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Pending many queues PS STA Index = %d remove \n", ii); |
| 939 | continue; |
| 940 | } |
| 941 | } |
| 942 | } |
| 943 | |
| 944 | } |
| 945 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 946 | if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) && (pDevice->byBBType == BB_TYPE_11G)) { |
| 947 | |
| 948 | // on/off protect mode |
| 949 | if (WLAN_GET_ERP_USE_PROTECTION(pDevice->byERPFlag)) { |
| 950 | if (!pDevice->bProtectMode) { |
| 951 | MACvEnableProtectMD(pDevice); |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 952 | pDevice->bProtectMode = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 953 | } |
| 954 | } |
| 955 | else { |
| 956 | if (pDevice->bProtectMode) { |
| 957 | MACvDisableProtectMD(pDevice); |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 958 | pDevice->bProtectMode = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 959 | } |
| 960 | } |
| 961 | // on/off short slot time |
| 962 | |
| 963 | if (uNonShortSlotSTACnt > 0) { |
| 964 | if (pDevice->bShortSlotTime) { |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 965 | pDevice->bShortSlotTime = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 966 | BBvSetShortSlotTime(pDevice); |
Andres More | 8611a29 | 2010-05-01 14:25:00 -0300 | [diff] [blame] | 967 | vUpdateIFS((void *)pDevice); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 968 | } |
| 969 | } |
| 970 | else { |
| 971 | if (!pDevice->bShortSlotTime) { |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 972 | pDevice->bShortSlotTime = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 973 | BBvSetShortSlotTime(pDevice); |
Andres More | 8611a29 | 2010-05-01 14:25:00 -0300 | [diff] [blame] | 974 | vUpdateIFS((void *)pDevice); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 975 | } |
| 976 | } |
| 977 | |
| 978 | // on/off barker long preamble mode |
| 979 | |
| 980 | if (uLongPreambleSTACnt > 0) { |
| 981 | if (!pDevice->bBarkerPreambleMd) { |
| 982 | MACvEnableBarkerPreambleMd(pDevice); |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 983 | pDevice->bBarkerPreambleMd = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 984 | } |
| 985 | } |
| 986 | else { |
| 987 | if (pDevice->bBarkerPreambleMd) { |
| 988 | MACvDisableBarkerPreambleMd(pDevice); |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 989 | pDevice->bBarkerPreambleMd = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 990 | } |
| 991 | } |
| 992 | |
| 993 | } |
| 994 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 995 | // Check if any STA in PS mode, enable DTIM multicast deliver |
| 996 | if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) { |
| 997 | if (uSleepySTACnt > 0) |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 998 | pMgmt->sNodeDBTable[0].bPSEnable = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 999 | else |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 1000 | pMgmt->sNodeDBTable[0].bPSEnable = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1001 | } |
| 1002 | |
| 1003 | pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID; |
| 1004 | pCurrSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID; |
| 1005 | |
| 1006 | if ((pMgmt->eCurrMode == WMAC_MODE_STANDBY) || |
| 1007 | (pMgmt->eCurrMode == WMAC_MODE_ESS_STA)) { |
| 1008 | |
| 1009 | if (pMgmt->sNodeDBTable[0].bActive) { // Assoc with BSS |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1010 | |
| 1011 | if (pDevice->bUpdateBBVGA) { |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 1012 | s_vCheckSensitivity(pDevice); |
| 1013 | s_vCheckPreEDThreshold(pDevice); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1014 | } |
| 1015 | |
| 1016 | if ((pMgmt->sNodeDBTable[0].uInActiveCount >= (LOST_BEACON_COUNT/2)) && |
| 1017 | (pDevice->byBBVGACurrent != pDevice->abyBBVGA[0]) ) { |
| 1018 | pDevice->byBBVGANew = pDevice->abyBBVGA[0]; |
Andres More | 0cbd8d9 | 2010-05-06 20:34:29 -0300 | [diff] [blame] | 1019 | bScheduleCommand((void *) pDevice, |
| 1020 | WLAN_CMD_CHANGE_BBSENSITIVITY, |
| 1021 | NULL); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1022 | } |
| 1023 | |
| 1024 | if (pMgmt->sNodeDBTable[0].uInActiveCount >= LOST_BEACON_COUNT) { |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 1025 | pMgmt->sNodeDBTable[0].bActive = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1026 | pMgmt->eCurrMode = WMAC_MODE_STANDBY; |
| 1027 | pMgmt->eCurrState = WMAC_STATE_IDLE; |
| 1028 | netif_stop_queue(pDevice->dev); |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 1029 | pDevice->bLinkPass = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1030 | ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_SLOW); |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 1031 | pDevice->bRoaming = true; |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 1032 | pDevice->bIsRoaming = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1033 | |
| 1034 | DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Lost AP beacon [%d] sec, disconnected !\n", pMgmt->sNodeDBTable[0].uInActiveCount); |
Andres More | 465711b | 2010-08-03 20:25:50 -0300 | [diff] [blame] | 1035 | /* let wpa supplicant know AP may disconnect */ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1036 | { |
| 1037 | union iwreq_data wrqu; |
| 1038 | memset(&wrqu, 0, sizeof (wrqu)); |
| 1039 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 1040 | PRINT_K("wireless_send_event--->SIOCGIWAP(disassociated)\n"); |
| 1041 | wireless_send_event(pDevice->dev, SIOCGIWAP, &wrqu, NULL); |
| 1042 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1043 | } |
| 1044 | } |
| 1045 | else if (pItemSSID->len != 0) { |
| 1046 | //Davidwang |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 1047 | if ((pDevice->bEnableRoaming == true)&&(!(pMgmt->Cisco_cckm))) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1048 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "bRoaming %d, !\n", pDevice->bRoaming ); |
| 1049 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "bIsRoaming %d, !\n", pDevice->bIsRoaming ); |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 1050 | if ((pDevice->bRoaming == true)&&(pDevice->bIsRoaming == true)){ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1051 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Fast Roaming ...\n"); |
Andres More | 0cbd8d9 | 2010-05-06 20:34:29 -0300 | [diff] [blame] | 1052 | BSSvClearBSSList((void *) pDevice, pDevice->bLinkPass); |
| 1053 | bScheduleCommand((void *) pDevice, |
| 1054 | WLAN_CMD_BSSID_SCAN, |
| 1055 | pMgmt->abyDesireSSID); |
| 1056 | bScheduleCommand((void *) pDevice, |
| 1057 | WLAN_CMD_SSID, |
| 1058 | pMgmt->abyDesireSSID); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1059 | pDevice->uAutoReConnectTime = 0; |
| 1060 | pDevice->uIsroamingTime = 0; |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 1061 | pDevice->bRoaming = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1062 | } |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 1063 | else if ((pDevice->bRoaming == false)&&(pDevice->bIsRoaming == true)) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1064 | pDevice->uIsroamingTime++; |
| 1065 | if (pDevice->uIsroamingTime >= 20) |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 1066 | pDevice->bIsRoaming = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1067 | } |
| 1068 | |
| 1069 | } |
| 1070 | else { |
| 1071 | if (pDevice->uAutoReConnectTime < 10) { |
| 1072 | pDevice->uAutoReConnectTime++; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1073 | //network manager support need not do Roaming scan??? |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 1074 | if(pDevice->bWPASuppWextEnabled ==true) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1075 | pDevice->uAutoReConnectTime = 0; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1076 | } |
| 1077 | else { |
| 1078 | //mike use old encryption status for wpa reauthen |
| 1079 | if(pDevice->bWPADEVUp) |
| 1080 | pDevice->eEncryptionStatus = pDevice->eOldEncryptionStatus; |
| 1081 | |
| 1082 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Roaming ...\n"); |
Andres More | 0cbd8d9 | 2010-05-06 20:34:29 -0300 | [diff] [blame] | 1083 | BSSvClearBSSList((void *) pDevice, pDevice->bLinkPass); |
| 1084 | pMgmt->eScanType = WMAC_SCAN_ACTIVE; |
| 1085 | bScheduleCommand((void *) pDevice, |
| 1086 | WLAN_CMD_BSSID_SCAN, |
| 1087 | pMgmt->abyDesireSSID); |
| 1088 | bScheduleCommand((void *) pDevice, |
| 1089 | WLAN_CMD_SSID, |
| 1090 | pMgmt->abyDesireSSID); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1091 | pDevice->uAutoReConnectTime = 0; |
| 1092 | } |
| 1093 | } |
| 1094 | } |
| 1095 | } |
| 1096 | |
| 1097 | if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) { |
Masanari Iida | 3e495b2 | 2012-02-20 23:31:31 +0900 | [diff] [blame] | 1098 | // if adhoc started which essid is NULL string, rescanning. |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1099 | if ((pMgmt->eCurrState == WMAC_STATE_STARTED) && (pCurrSSID->len == 0)) { |
| 1100 | if (pDevice->uAutoReConnectTime < 10) { |
| 1101 | pDevice->uAutoReConnectTime++; |
| 1102 | } |
| 1103 | else { |
Masanari Iida | 3e495b2 | 2012-02-20 23:31:31 +0900 | [diff] [blame] | 1104 | DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Adhoc re-scanning ...\n"); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1105 | pMgmt->eScanType = WMAC_SCAN_ACTIVE; |
Andres More | 0cbd8d9 | 2010-05-06 20:34:29 -0300 | [diff] [blame] | 1106 | bScheduleCommand((void *) pDevice, WLAN_CMD_BSSID_SCAN, NULL); |
| 1107 | bScheduleCommand((void *) pDevice, WLAN_CMD_SSID, NULL); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1108 | pDevice->uAutoReConnectTime = 0; |
| 1109 | }; |
| 1110 | } |
| 1111 | if (pMgmt->eCurrState == WMAC_STATE_JOINTED) { |
| 1112 | |
Andres More | 0cbd8d9 | 2010-05-06 20:34:29 -0300 | [diff] [blame] | 1113 | if (pDevice->bUpdateBBVGA) { |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 1114 | s_vCheckSensitivity(pDevice); |
| 1115 | s_vCheckPreEDThreshold(pDevice); |
Andres More | 0cbd8d9 | 2010-05-06 20:34:29 -0300 | [diff] [blame] | 1116 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1117 | if (pMgmt->sNodeDBTable[0].uInActiveCount >=ADHOC_LOST_BEACON_COUNT) { |
| 1118 | DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Lost other STA beacon [%d] sec, started !\n", pMgmt->sNodeDBTable[0].uInActiveCount); |
| 1119 | pMgmt->sNodeDBTable[0].uInActiveCount = 0; |
| 1120 | pMgmt->eCurrState = WMAC_STATE_STARTED; |
| 1121 | netif_stop_queue(pDevice->dev); |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 1122 | pDevice->bLinkPass = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1123 | ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_SLOW); |
| 1124 | } |
| 1125 | } |
| 1126 | } |
| 1127 | |
Malcolm Priestley | 60cc274 | 2013-10-14 19:46:52 +0100 | [diff] [blame] | 1128 | if (pDevice->bLinkPass == true) { |
| 1129 | if (pMgmt->eAuthenMode < WMAC_AUTH_WPA || |
| 1130 | pDevice->fWPA_Authened == true) { |
| 1131 | if (++pDevice->tx_data_time_out > 40) { |
| 1132 | pDevice->tx_trigger = true; |
| 1133 | |
| 1134 | PSbSendNullPacket(pDevice); |
| 1135 | |
| 1136 | pDevice->tx_trigger = false; |
| 1137 | pDevice->tx_data_time_out = 0; |
| 1138 | } |
| 1139 | } |
| 1140 | |
| 1141 | if (netif_queue_stopped(pDevice->dev)) |
| 1142 | netif_wake_queue(pDevice->dev); |
| 1143 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1144 | |
| 1145 | spin_unlock_irq(&pDevice->lock); |
| 1146 | |
Malcolm Priestley | bd9a6db | 2013-09-27 16:51:13 +0100 | [diff] [blame] | 1147 | schedule_delayed_work(&pDevice->second_callback_work, HZ); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1148 | } |
| 1149 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1150 | /*+ |
| 1151 | * |
| 1152 | * Routine Description: |
| 1153 | * |
| 1154 | * |
| 1155 | * Update Tx attemps, Tx failure counter in Node DB |
| 1156 | * |
| 1157 | * |
| 1158 | * Return Value: |
| 1159 | * none. |
| 1160 | * |
| 1161 | -*/ |
| 1162 | |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 1163 | void BSSvUpdateNodeTxCounter(struct vnt_private *pDevice, |
| 1164 | PSStatCounter pStatistic, u8 byTSR, u8 byPktNO) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1165 | { |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 1166 | struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; |
| 1167 | u32 uNodeIndex = 0; |
| 1168 | u8 byTxRetry; |
| 1169 | u16 wRate; |
| 1170 | u16 wFallBackRate = RATE_1M; |
| 1171 | u8 byFallBack; |
| 1172 | int ii; |
| 1173 | u8 *pbyDestAddr; |
| 1174 | u8 byPktNum; |
| 1175 | u16 wFIFOCtl; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1176 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1177 | byPktNum = (byPktNO & 0x0F) >> 4; |
| 1178 | byTxRetry = (byTSR & 0xF0) >> 4; |
Andres More | 3eaca0d | 2013-02-25 20:32:52 -0500 | [diff] [blame] | 1179 | wRate = (u16) (byPktNO & 0xF0) >> 4; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1180 | wFIFOCtl = pStatistic->abyTxPktInfo[byPktNum].wFIFOCtl; |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 1181 | pbyDestAddr = (u8 *) &( pStatistic->abyTxPktInfo[byPktNum].abyDestAddr[0]); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1182 | |
| 1183 | if (wFIFOCtl & FIFOCTL_AUTO_FB_0) { |
| 1184 | byFallBack = AUTO_FB_0; |
| 1185 | } else if (wFIFOCtl & FIFOCTL_AUTO_FB_1) { |
| 1186 | byFallBack = AUTO_FB_1; |
| 1187 | } else { |
| 1188 | byFallBack = AUTO_FB_NONE; |
| 1189 | } |
| 1190 | |
| 1191 | // Only Unicast using support rates |
| 1192 | if (wFIFOCtl & FIFOCTL_NEEDACK) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1193 | if (pMgmt->eCurrMode == WMAC_MODE_ESS_STA) { |
| 1194 | pMgmt->sNodeDBTable[0].uTxAttempts += 1; |
Jim Lieb | 8a3d91b | 2009-08-12 14:54:15 -0700 | [diff] [blame] | 1195 | if ( !(byTSR & (TSR_TMO | TSR_RETRYTMO))) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1196 | // transmit success, TxAttempts at least plus one |
| 1197 | pMgmt->sNodeDBTable[0].uTxOk[MAX_RATE]++; |
| 1198 | if ( (byFallBack == AUTO_FB_NONE) || |
| 1199 | (wRate < RATE_18M) ) { |
| 1200 | wFallBackRate = wRate; |
| 1201 | } else if (byFallBack == AUTO_FB_0) { |
| 1202 | if (byTxRetry < 5) |
| 1203 | wFallBackRate = awHWRetry0[wRate-RATE_18M][byTxRetry]; |
| 1204 | else |
| 1205 | wFallBackRate = awHWRetry0[wRate-RATE_18M][4]; |
| 1206 | } else if (byFallBack == AUTO_FB_1) { |
| 1207 | if (byTxRetry < 5) |
| 1208 | wFallBackRate = awHWRetry1[wRate-RATE_18M][byTxRetry]; |
| 1209 | else |
| 1210 | wFallBackRate = awHWRetry1[wRate-RATE_18M][4]; |
| 1211 | } |
| 1212 | pMgmt->sNodeDBTable[0].uTxOk[wFallBackRate]++; |
| 1213 | } else { |
| 1214 | pMgmt->sNodeDBTable[0].uTxFailures ++; |
| 1215 | } |
| 1216 | pMgmt->sNodeDBTable[0].uTxRetry += byTxRetry; |
| 1217 | if (byTxRetry != 0) { |
| 1218 | pMgmt->sNodeDBTable[0].uTxFail[MAX_RATE]+=byTxRetry; |
| 1219 | if ( (byFallBack == AUTO_FB_NONE) || |
| 1220 | (wRate < RATE_18M) ) { |
| 1221 | pMgmt->sNodeDBTable[0].uTxFail[wRate]+=byTxRetry; |
| 1222 | } else if (byFallBack == AUTO_FB_0) { |
Andres More | 33d33e42 | 2010-05-19 23:50:00 -0300 | [diff] [blame] | 1223 | for (ii = 0; ii < byTxRetry; ii++) { |
| 1224 | if (ii < 5) |
| 1225 | wFallBackRate = |
| 1226 | awHWRetry0[wRate-RATE_18M][ii]; |
| 1227 | else |
| 1228 | wFallBackRate = |
| 1229 | awHWRetry0[wRate-RATE_18M][4]; |
| 1230 | pMgmt->sNodeDBTable[0].uTxFail[wFallBackRate]++; |
| 1231 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1232 | } else if (byFallBack == AUTO_FB_1) { |
Andres More | 33d33e42 | 2010-05-19 23:50:00 -0300 | [diff] [blame] | 1233 | for (ii = 0; ii < byTxRetry; ii++) { |
| 1234 | if (ii < 5) |
| 1235 | wFallBackRate = |
| 1236 | awHWRetry1[wRate-RATE_18M][ii]; |
| 1237 | else |
| 1238 | wFallBackRate = |
| 1239 | awHWRetry1[wRate-RATE_18M][4]; |
| 1240 | pMgmt->sNodeDBTable[0].uTxFail[wFallBackRate]++; |
| 1241 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1242 | } |
| 1243 | } |
Joe Perches | 9fc8602 | 2011-04-10 14:31:32 -0700 | [diff] [blame] | 1244 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1245 | |
Andres More | 0cbd8d9 | 2010-05-06 20:34:29 -0300 | [diff] [blame] | 1246 | if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) || |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1247 | (pMgmt->eCurrMode == WMAC_MODE_ESS_AP)) { |
| 1248 | |
Andres More | 0cbd8d9 | 2010-05-06 20:34:29 -0300 | [diff] [blame] | 1249 | if (BSSbIsSTAInNodeDB((void *) pDevice, |
| 1250 | pbyDestAddr, |
| 1251 | &uNodeIndex)) { |
| 1252 | pMgmt->sNodeDBTable[uNodeIndex].uTxAttempts += 1; |
Jim Lieb | 8a3d91b | 2009-08-12 14:54:15 -0700 | [diff] [blame] | 1253 | if ( !(byTSR & (TSR_TMO | TSR_RETRYTMO))) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1254 | // transmit success, TxAttempts at least plus one |
| 1255 | pMgmt->sNodeDBTable[uNodeIndex].uTxOk[MAX_RATE]++; |
| 1256 | if ( (byFallBack == AUTO_FB_NONE) || |
| 1257 | (wRate < RATE_18M) ) { |
| 1258 | wFallBackRate = wRate; |
| 1259 | } else if (byFallBack == AUTO_FB_0) { |
| 1260 | if (byTxRetry < 5) |
| 1261 | wFallBackRate = awHWRetry0[wRate-RATE_18M][byTxRetry]; |
| 1262 | else |
| 1263 | wFallBackRate = awHWRetry0[wRate-RATE_18M][4]; |
| 1264 | } else if (byFallBack == AUTO_FB_1) { |
| 1265 | if (byTxRetry < 5) |
| 1266 | wFallBackRate = awHWRetry1[wRate-RATE_18M][byTxRetry]; |
| 1267 | else |
| 1268 | wFallBackRate = awHWRetry1[wRate-RATE_18M][4]; |
| 1269 | } |
| 1270 | pMgmt->sNodeDBTable[uNodeIndex].uTxOk[wFallBackRate]++; |
| 1271 | } else { |
| 1272 | pMgmt->sNodeDBTable[uNodeIndex].uTxFailures ++; |
| 1273 | } |
| 1274 | pMgmt->sNodeDBTable[uNodeIndex].uTxRetry += byTxRetry; |
| 1275 | if (byTxRetry != 0) { |
| 1276 | pMgmt->sNodeDBTable[uNodeIndex].uTxFail[MAX_RATE]+=byTxRetry; |
| 1277 | if ( (byFallBack == AUTO_FB_NONE) || |
| 1278 | (wRate < RATE_18M) ) { |
| 1279 | pMgmt->sNodeDBTable[uNodeIndex].uTxFail[wRate]+=byTxRetry; |
| 1280 | } else if (byFallBack == AUTO_FB_0) { |
Andres More | 33d33e42 | 2010-05-19 23:50:00 -0300 | [diff] [blame] | 1281 | for (ii = 0; ii < byTxRetry; ii++) { |
| 1282 | if (ii < 5) |
| 1283 | wFallBackRate = |
| 1284 | awHWRetry0[wRate-RATE_18M][ii]; |
| 1285 | else |
| 1286 | wFallBackRate = |
| 1287 | awHWRetry0[wRate-RATE_18M][4]; |
| 1288 | pMgmt->sNodeDBTable[uNodeIndex].uTxFail[wFallBackRate]++; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1289 | } |
| 1290 | } else if (byFallBack == AUTO_FB_1) { |
Andres More | 33d33e42 | 2010-05-19 23:50:00 -0300 | [diff] [blame] | 1291 | for (ii = 0; ii < byTxRetry; ii++) { |
| 1292 | if (ii < 5) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1293 | wFallBackRate = awHWRetry1[wRate-RATE_18M][ii]; |
Andres More | 33d33e42 | 2010-05-19 23:50:00 -0300 | [diff] [blame] | 1294 | else |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1295 | wFallBackRate = awHWRetry1[wRate-RATE_18M][4]; |
Andres More | 33d33e42 | 2010-05-19 23:50:00 -0300 | [diff] [blame] | 1296 | pMgmt->sNodeDBTable[uNodeIndex].uTxFail[wFallBackRate]++; |
| 1297 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1298 | } |
| 1299 | } |
Joe Perches | 9fc8602 | 2011-04-10 14:31:32 -0700 | [diff] [blame] | 1300 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1301 | } |
Joe Perches | 9fc8602 | 2011-04-10 14:31:32 -0700 | [diff] [blame] | 1302 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1303 | } |
| 1304 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1305 | /*+ |
| 1306 | * |
| 1307 | * Routine Description: |
| 1308 | * Clear Nodes & skb in DB Table |
| 1309 | * |
| 1310 | * |
| 1311 | * Parameters: |
| 1312 | * In: |
| 1313 | * hDeviceContext - The adapter context. |
| 1314 | * uStartIndex - starting index |
| 1315 | * Out: |
| 1316 | * none |
| 1317 | * |
| 1318 | * Return Value: |
| 1319 | * None. |
| 1320 | * |
| 1321 | -*/ |
| 1322 | |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 1323 | void BSSvClearNodeDBTable(struct vnt_private *pDevice, u32 uStartIndex) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1324 | { |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 1325 | struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; |
| 1326 | struct sk_buff *skb; |
| 1327 | int ii; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1328 | |
| 1329 | for (ii = uStartIndex; ii < (MAX_NODE_NUM + 1); ii++) { |
| 1330 | if (pMgmt->sNodeDBTable[ii].bActive) { |
| 1331 | // check if sTxPSQueue has been initial |
| 1332 | if (pMgmt->sNodeDBTable[ii].sTxPSQueue.next != NULL) { |
| 1333 | while ((skb = skb_dequeue(&pMgmt->sNodeDBTable[ii].sTxPSQueue)) != NULL){ |
| 1334 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "PS skb != NULL %d\n", ii); |
| 1335 | dev_kfree_skb(skb); |
| 1336 | } |
| 1337 | } |
| 1338 | memset(&pMgmt->sNodeDBTable[ii], 0, sizeof(KnownNodeDB)); |
| 1339 | } |
| 1340 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1341 | }; |
| 1342 | |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 1343 | static void s_vCheckSensitivity(struct vnt_private *pDevice) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1344 | { |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 1345 | PKnownBSS pBSSList = NULL; |
| 1346 | struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; |
| 1347 | int ii; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1348 | |
| 1349 | if ((pMgmt->eCurrState == WMAC_STATE_ASSOC) || |
| 1350 | ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) && (pMgmt->eCurrState == WMAC_STATE_JOINTED))) { |
| 1351 | pBSSList = BSSpAddrIsInBSSList(pDevice, pMgmt->abyCurrBSSID, (PWLAN_IE_SSID)pMgmt->abyCurrSSID); |
| 1352 | if (pBSSList != NULL) { |
Andres More | 213d2e9 | 2010-05-17 21:34:00 -0300 | [diff] [blame] | 1353 | /* Update BB register if RSSI is too strong */ |
| 1354 | signed long LocalldBmAverage = 0; |
| 1355 | signed long uNumofdBm = 0; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1356 | for (ii = 0; ii < RSSI_STAT_COUNT; ii++) { |
| 1357 | if (pBSSList->ldBmAverage[ii] != 0) { |
| 1358 | uNumofdBm ++; |
| 1359 | LocalldBmAverage += pBSSList->ldBmAverage[ii]; |
| 1360 | } |
| 1361 | } |
| 1362 | if (uNumofdBm > 0) { |
| 1363 | LocalldBmAverage = LocalldBmAverage/uNumofdBm; |
| 1364 | for (ii=0;ii<BB_VGA_LEVEL;ii++) { |
| 1365 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"LocalldBmAverage:%ld, %ld %02x\n", LocalldBmAverage, pDevice->ldBmThreshold[ii], pDevice->abyBBVGA[ii]); |
| 1366 | if (LocalldBmAverage < pDevice->ldBmThreshold[ii]) { |
| 1367 | pDevice->byBBVGANew = pDevice->abyBBVGA[ii]; |
| 1368 | break; |
| 1369 | } |
| 1370 | } |
| 1371 | if (pDevice->byBBVGANew != pDevice->byBBVGACurrent) { |
| 1372 | pDevice->uBBVGADiffCount++; |
| 1373 | if (pDevice->uBBVGADiffCount >= BB_VGA_CHANGE_THRESHOLD) |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 1374 | bScheduleCommand(pDevice, |
Andres More | 0cbd8d9 | 2010-05-06 20:34:29 -0300 | [diff] [blame] | 1375 | WLAN_CMD_CHANGE_BBSENSITIVITY, |
| 1376 | NULL); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1377 | } else { |
| 1378 | pDevice->uBBVGADiffCount = 0; |
| 1379 | } |
| 1380 | } |
| 1381 | } |
| 1382 | } |
| 1383 | } |
| 1384 | |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 1385 | static void s_uCalculateLinkQual(struct vnt_private *pDevice) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1386 | { |
Malcolm Priestley | 854f775 | 2013-12-09 22:25:48 +0000 | [diff] [blame] | 1387 | struct net_device_stats *stats = &pDevice->stats; |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 1388 | unsigned long TxOkRatio, TxCnt; |
| 1389 | unsigned long RxOkRatio, RxCnt; |
| 1390 | unsigned long RssiRatio; |
Malcolm Priestley | 854f775 | 2013-12-09 22:25:48 +0000 | [diff] [blame] | 1391 | unsigned long qual; |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 1392 | long ldBm; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1393 | |
Malcolm Priestley | 854f775 | 2013-12-09 22:25:48 +0000 | [diff] [blame] | 1394 | TxCnt = stats->tx_packets + pDevice->wstats.discard.retries; |
| 1395 | |
Malcolm Priestley | 9a450f9 | 2013-12-09 22:28:24 +0000 | [diff] [blame^] | 1396 | RxCnt = stats->rx_packets + stats->rx_frame_errors; |
Malcolm Priestley | 854f775 | 2013-12-09 22:25:48 +0000 | [diff] [blame] | 1397 | |
| 1398 | TxOkRatio = (TxCnt < 6) ? 4000:((stats->tx_packets * 4000) / TxCnt); |
| 1399 | |
| 1400 | RxOkRatio = (RxCnt < 6) ? 2000 : |
Malcolm Priestley | 9a450f9 | 2013-12-09 22:28:24 +0000 | [diff] [blame^] | 1401 | ((stats->rx_packets * 2000) / RxCnt); |
Malcolm Priestley | 854f775 | 2013-12-09 22:25:48 +0000 | [diff] [blame] | 1402 | |
| 1403 | /* decide link quality */ |
| 1404 | if (pDevice->bLinkPass != true) { |
| 1405 | pDevice->wstats.qual.qual = 0; |
| 1406 | pDevice->scStatistic.SignalStren = 0; |
| 1407 | } else { |
| 1408 | RFvRSSITodBm(pDevice, (u8)(pDevice->uCurrRSSI), &ldBm); |
| 1409 | if (-ldBm < 50) |
| 1410 | RssiRatio = 4000; |
| 1411 | else if (-ldBm > 90) |
| 1412 | RssiRatio = 0; |
| 1413 | else |
| 1414 | RssiRatio = (40-(-ldBm-50)) * 4000 / 40; |
| 1415 | |
| 1416 | pDevice->scStatistic.SignalStren = RssiRatio / 40; |
| 1417 | qual = (RssiRatio + TxOkRatio + RxOkRatio) / 100; |
| 1418 | if (qual < 100) |
| 1419 | pDevice->wstats.qual.qual = (u8)qual; |
| 1420 | else |
| 1421 | pDevice->wstats.qual.qual = 100; |
| 1422 | } |
| 1423 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1424 | pDevice->scStatistic.RxFcsErrCnt = 0; |
| 1425 | pDevice->scStatistic.RxOkCnt = 0; |
| 1426 | pDevice->scStatistic.TxFailCount = 0; |
| 1427 | pDevice->scStatistic.TxNoRetryOkCount = 0; |
| 1428 | pDevice->scStatistic.TxRetryOkCount = 0; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1429 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1430 | |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 1431 | void BSSvClearAnyBSSJoinRecord(struct vnt_private *pDevice) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1432 | { |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 1433 | struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; |
| 1434 | int ii; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1435 | |
Marcos Paulo de Souza | ca76ede | 2011-11-30 00:19:25 -0200 | [diff] [blame] | 1436 | for (ii = 0; ii < MAX_BSS_NUM; ii++) |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 1437 | pMgmt->sBSSList[ii].bSelected = false; |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 1438 | |
| 1439 | return; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1440 | } |
| 1441 | |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 1442 | static void s_vCheckPreEDThreshold(struct vnt_private *pDevice) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1443 | { |
Malcolm Priestley | d56131d | 2013-01-17 23:15:22 +0000 | [diff] [blame] | 1444 | PKnownBSS pBSSList = NULL; |
| 1445 | struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1446 | |
| 1447 | if ((pMgmt->eCurrState == WMAC_STATE_ASSOC) || |
| 1448 | ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) && (pMgmt->eCurrState == WMAC_STATE_JOINTED))) { |
| 1449 | pBSSList = BSSpAddrIsInBSSList(pDevice, pMgmt->abyCurrBSSID, (PWLAN_IE_SSID)pMgmt->abyCurrSSID); |
| 1450 | if (pBSSList != NULL) { |
Andres More | b902fbf | 2013-02-25 20:32:51 -0500 | [diff] [blame] | 1451 | pDevice->byBBPreEDRSSI = (u8) (~(pBSSList->ldBmAverRange) + 1); |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 1452 | BBvUpdatePreEDThreshold(pDevice, false); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1453 | } |
| 1454 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1455 | } |
| 1456 | |