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