Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1 | /* |
| 2 | ************************************************************************* |
| 3 | * Ralink Tech Inc. |
| 4 | * 5F., No.36, Taiyuan St., Jhubei City, |
| 5 | * Hsinchu County 302, |
| 6 | * Taiwan, R.O.C. |
| 7 | * |
| 8 | * (c) Copyright 2002-2007, Ralink Technology, Inc. |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify * |
| 11 | * it under the terms of the GNU General Public License as published by * |
| 12 | * the Free Software Foundation; either version 2 of the License, or * |
| 13 | * (at your option) any later version. * |
| 14 | * * |
| 15 | * This program is distributed in the hope that it will be useful, * |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
| 18 | * GNU General Public License for more details. * |
| 19 | * * |
| 20 | * You should have received a copy of the GNU General Public License * |
| 21 | * along with this program; if not, write to the * |
| 22 | * Free Software Foundation, Inc., * |
| 23 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
| 24 | * * |
| 25 | ************************************************************************* |
| 26 | |
| 27 | Module Name: |
| 28 | connect.c |
| 29 | |
| 30 | Abstract: |
| 31 | |
| 32 | Revision History: |
| 33 | Who When What |
| 34 | -------- ---------- ---------------------------------------------- |
| 35 | John 2004-08-08 Major modification from RT2560 |
| 36 | */ |
| 37 | #include "../rt_config.h" |
| 38 | |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 39 | u8 CipherSuiteWpaNoneTkip[] = { |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 40 | 0x00, 0x50, 0xf2, 0x01, /* oui */ |
| 41 | 0x01, 0x00, /* Version */ |
| 42 | 0x00, 0x50, 0xf2, 0x02, /* Multicast */ |
| 43 | 0x01, 0x00, /* Number of unicast */ |
| 44 | 0x00, 0x50, 0xf2, 0x02, /* unicast */ |
| 45 | 0x01, 0x00, /* number of authentication method */ |
| 46 | 0x00, 0x50, 0xf2, 0x00 /* authentication */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 47 | }; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 48 | |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 49 | u8 CipherSuiteWpaNoneTkipLen = |
| 50 | (sizeof(CipherSuiteWpaNoneTkip) / sizeof(u8)); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 51 | |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 52 | u8 CipherSuiteWpaNoneAes[] = { |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 53 | 0x00, 0x50, 0xf2, 0x01, /* oui */ |
| 54 | 0x01, 0x00, /* Version */ |
| 55 | 0x00, 0x50, 0xf2, 0x04, /* Multicast */ |
| 56 | 0x01, 0x00, /* Number of unicast */ |
| 57 | 0x00, 0x50, 0xf2, 0x04, /* unicast */ |
| 58 | 0x01, 0x00, /* number of authentication method */ |
| 59 | 0x00, 0x50, 0xf2, 0x00 /* authentication */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 60 | }; |
| 61 | |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 62 | u8 CipherSuiteWpaNoneAesLen = |
| 63 | (sizeof(CipherSuiteWpaNoneAes) / sizeof(u8)); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 64 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 65 | /* The following MACRO is called after 1. starting an new IBSS, 2. succesfully JOIN an IBSS, */ |
| 66 | /* or 3. succesfully ASSOCIATE to a BSS, 4. successfully RE_ASSOCIATE to a BSS */ |
| 67 | /* All settings successfuly negotiated furing MLME state machines become final settings */ |
| 68 | /* and are copied to pAd->StaActive */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 69 | #define COPY_SETTINGS_FROM_MLME_AUX_TO_ACTIVE_CFG(_pAd) \ |
| 70 | { \ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 71 | NdisZeroMemory((_pAd)->CommonCfg.Ssid, MAX_LEN_OF_SSID); \ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 72 | (_pAd)->CommonCfg.SsidLen = (_pAd)->MlmeAux.SsidLen; \ |
| 73 | NdisMoveMemory((_pAd)->CommonCfg.Ssid, (_pAd)->MlmeAux.Ssid, (_pAd)->MlmeAux.SsidLen); \ |
| 74 | COPY_MAC_ADDR((_pAd)->CommonCfg.Bssid, (_pAd)->MlmeAux.Bssid); \ |
| 75 | (_pAd)->CommonCfg.Channel = (_pAd)->MlmeAux.Channel; \ |
| 76 | (_pAd)->CommonCfg.CentralChannel = (_pAd)->MlmeAux.CentralChannel; \ |
| 77 | (_pAd)->StaActive.Aid = (_pAd)->MlmeAux.Aid; \ |
| 78 | (_pAd)->StaActive.AtimWin = (_pAd)->MlmeAux.AtimWin; \ |
| 79 | (_pAd)->StaActive.CapabilityInfo = (_pAd)->MlmeAux.CapabilityInfo; \ |
| 80 | (_pAd)->CommonCfg.BeaconPeriod = (_pAd)->MlmeAux.BeaconPeriod; \ |
| 81 | (_pAd)->StaActive.CfpMaxDuration = (_pAd)->MlmeAux.CfpMaxDuration; \ |
| 82 | (_pAd)->StaActive.CfpPeriod = (_pAd)->MlmeAux.CfpPeriod; \ |
| 83 | (_pAd)->StaActive.SupRateLen = (_pAd)->MlmeAux.SupRateLen; \ |
| 84 | NdisMoveMemory((_pAd)->StaActive.SupRate, (_pAd)->MlmeAux.SupRate, (_pAd)->MlmeAux.SupRateLen);\ |
| 85 | (_pAd)->StaActive.ExtRateLen = (_pAd)->MlmeAux.ExtRateLen; \ |
| 86 | NdisMoveMemory((_pAd)->StaActive.ExtRate, (_pAd)->MlmeAux.ExtRate, (_pAd)->MlmeAux.ExtRateLen);\ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 87 | NdisMoveMemory(&(_pAd)->CommonCfg.APEdcaParm, &(_pAd)->MlmeAux.APEdcaParm, sizeof(struct rt_edca_parm));\ |
| 88 | NdisMoveMemory(&(_pAd)->CommonCfg.APQosCapability, &(_pAd)->MlmeAux.APQosCapability, sizeof(struct rt_qos_capability_parm));\ |
| 89 | NdisMoveMemory(&(_pAd)->CommonCfg.APQbssLoad, &(_pAd)->MlmeAux.APQbssLoad, sizeof(struct rt_qbss_load_parm));\ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 90 | COPY_MAC_ADDR((_pAd)->MacTab.Content[BSSID_WCID].Addr, (_pAd)->MlmeAux.Bssid); \ |
| 91 | (_pAd)->MacTab.Content[BSSID_WCID].Aid = (_pAd)->MlmeAux.Aid; \ |
| 92 | (_pAd)->MacTab.Content[BSSID_WCID].PairwiseKey.CipherAlg = (_pAd)->StaCfg.PairCipher;\ |
| 93 | COPY_MAC_ADDR((_pAd)->MacTab.Content[BSSID_WCID].PairwiseKey.BssId, (_pAd)->MlmeAux.Bssid);\ |
| 94 | (_pAd)->MacTab.Content[BSSID_WCID].RateLen = (_pAd)->StaActive.SupRateLen + (_pAd)->StaActive.ExtRateLen;\ |
| 95 | } |
| 96 | |
| 97 | /* |
| 98 | ========================================================================== |
| 99 | Description: |
| 100 | |
| 101 | IRQL = PASSIVE_LEVEL |
| 102 | |
| 103 | ========================================================================== |
| 104 | */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 105 | void MlmeCntlInit(struct rt_rtmp_adapter *pAd, |
| 106 | struct rt_state_machine *S, OUT STATE_MACHINE_FUNC Trans[]) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 107 | { |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 108 | /* Control state machine differs from other state machines, the interface */ |
| 109 | /* follows the standard interface */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 110 | pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE; |
| 111 | } |
| 112 | |
| 113 | /* |
| 114 | ========================================================================== |
| 115 | Description: |
| 116 | |
| 117 | IRQL = DISPATCH_LEVEL |
| 118 | |
| 119 | ========================================================================== |
| 120 | */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 121 | void MlmeCntlMachinePerformAction(struct rt_rtmp_adapter *pAd, |
| 122 | struct rt_state_machine *S, |
| 123 | struct rt_mlme_queue_elem *Elem) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 124 | { |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 125 | switch (pAd->Mlme.CntlMachine.CurrState) { |
| 126 | case CNTL_IDLE: |
| 127 | CntlIdleProc(pAd, Elem); |
| 128 | break; |
| 129 | case CNTL_WAIT_DISASSOC: |
| 130 | CntlWaitDisassocProc(pAd, Elem); |
| 131 | break; |
| 132 | case CNTL_WAIT_JOIN: |
| 133 | CntlWaitJoinProc(pAd, Elem); |
| 134 | break; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 135 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 136 | /* CNTL_WAIT_REASSOC is the only state in CNTL machine that does */ |
| 137 | /* not triggered directly or indirectly by "RTMPSetInformation(OID_xxx)". */ |
| 138 | /* Therefore not protected by NDIS's "only one outstanding OID request" */ |
| 139 | /* rule. Which means NDIS may SET OID in the middle of ROAMing attempts. */ |
| 140 | /* Current approach is to block new SET request at RTMPSetInformation() */ |
| 141 | /* when CntlMachine.CurrState is not CNTL_IDLE */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 142 | case CNTL_WAIT_REASSOC: |
| 143 | CntlWaitReassocProc(pAd, Elem); |
| 144 | break; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 145 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 146 | case CNTL_WAIT_START: |
| 147 | CntlWaitStartProc(pAd, Elem); |
| 148 | break; |
| 149 | case CNTL_WAIT_AUTH: |
| 150 | CntlWaitAuthProc(pAd, Elem); |
| 151 | break; |
| 152 | case CNTL_WAIT_AUTH2: |
| 153 | CntlWaitAuthProc2(pAd, Elem); |
| 154 | break; |
| 155 | case CNTL_WAIT_ASSOC: |
| 156 | CntlWaitAssocProc(pAd, Elem); |
| 157 | break; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 158 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 159 | case CNTL_WAIT_OID_LIST_SCAN: |
| 160 | if (Elem->MsgType == MT2_SCAN_CONF) { |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 161 | /* Resume TxRing after SCANING complete. We hope the out-of-service time */ |
| 162 | /* won't be too long to let upper layer time-out the waiting frames */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 163 | RTMPResumeMsduTransmission(pAd); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 164 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 165 | pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 166 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 167 | /* */ |
| 168 | /* Set LED status to previous status. */ |
| 169 | /* */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 170 | if (pAd->bLedOnScanning) { |
| 171 | pAd->bLedOnScanning = FALSE; |
| 172 | RTMPSetLED(pAd, pAd->LedStatus); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 173 | } |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 174 | } |
| 175 | break; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 176 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 177 | case CNTL_WAIT_OID_DISASSOC: |
| 178 | if (Elem->MsgType == MT2_DISASSOC_CONF) { |
| 179 | LinkDown(pAd, FALSE); |
| 180 | pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE; |
| 181 | } |
| 182 | break; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 183 | #ifdef RTMP_MAC_USB |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 184 | /* */ |
| 185 | /* This state is for that we want to connect to an AP but */ |
| 186 | /* it didn't find on BSS List table. So we need to scan the air first, */ |
| 187 | /* after that we can try to connect to the desired AP if available. */ |
| 188 | /* */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 189 | case CNTL_WAIT_SCAN_FOR_CONNECT: |
| 190 | if (Elem->MsgType == MT2_SCAN_CONF) { |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 191 | /* Resume TxRing after SCANING complete. We hope the out-of-service time */ |
| 192 | /* won't be too long to let upper layer time-out the waiting frames */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 193 | RTMPResumeMsduTransmission(pAd); |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 194 | #ifdef CCX_SUPPORT |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 195 | if (pAd->StaCfg.CCXReqType != MSRN_TYPE_UNUSED) { |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 196 | /* Cisco scan request is finished, prepare beacon report */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 197 | MlmeEnqueue(pAd, AIRONET_STATE_MACHINE, |
| 198 | MT2_AIRONET_SCAN_DONE, 0, NULL); |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 199 | } |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 200 | #endif /* CCX_SUPPORT // */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 201 | pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE; |
| 202 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 203 | /* */ |
| 204 | /* Check if we can connect to. */ |
| 205 | /* */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 206 | BssTableSsidSort(pAd, &pAd->MlmeAux.SsidBssTab, |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 207 | (char *) pAd->MlmeAux. |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 208 | AutoReconnectSsid, |
| 209 | pAd->MlmeAux.AutoReconnectSsidLen); |
| 210 | if (pAd->MlmeAux.SsidBssTab.BssNr > 0) { |
| 211 | MlmeAutoReconnectLastSSID(pAd); |
| 212 | } |
| 213 | } |
| 214 | break; |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 215 | #endif /* RTMP_MAC_USB // */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 216 | default: |
| 217 | DBGPRINT_ERR(("!ERROR! CNTL - Illegal message type(=%ld)", |
| 218 | Elem->MsgType)); |
| 219 | break; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 220 | } |
| 221 | } |
| 222 | |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 223 | /* |
| 224 | ========================================================================== |
| 225 | Description: |
| 226 | |
| 227 | IRQL = DISPATCH_LEVEL |
| 228 | |
| 229 | ========================================================================== |
| 230 | */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 231 | void CntlIdleProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 232 | { |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 233 | struct rt_mlme_disassoc_req DisassocReq; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 234 | |
| 235 | if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF)) |
| 236 | return; |
| 237 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 238 | switch (Elem->MsgType) { |
| 239 | case OID_802_11_SSID: |
| 240 | CntlOidSsidProc(pAd, Elem); |
| 241 | break; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 242 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 243 | case OID_802_11_BSSID: |
| 244 | CntlOidRTBssidProc(pAd, Elem); |
| 245 | break; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 246 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 247 | case OID_802_11_BSSID_LIST_SCAN: |
| 248 | CntlOidScanProc(pAd, Elem); |
| 249 | break; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 250 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 251 | case OID_802_11_DISASSOCIATE: |
| 252 | DisassocParmFill(pAd, &DisassocReq, pAd->CommonCfg.Bssid, |
| 253 | REASON_DISASSOC_STA_LEAVING); |
| 254 | MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_MLME_DISASSOC_REQ, |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 255 | sizeof(struct rt_mlme_disassoc_req), &DisassocReq); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 256 | pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_DISASSOC; |
Bartlomiej Zolnierkiewicz | e08bae5 | 2009-04-26 16:05:56 +0200 | [diff] [blame] | 257 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 258 | if (pAd->StaCfg.WpaSupplicantUP != |
| 259 | WPA_SUPPLICANT_ENABLE_WITH_WEB_UI) { |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 260 | /* Set the AutoReconnectSsid to prevent it reconnect to old SSID */ |
| 261 | /* Since calling this indicate user don't want to connect to that SSID anymore. */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 262 | pAd->MlmeAux.AutoReconnectSsidLen = 32; |
| 263 | NdisZeroMemory(pAd->MlmeAux.AutoReconnectSsid, |
| 264 | pAd->MlmeAux.AutoReconnectSsidLen); |
| 265 | } |
| 266 | break; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 267 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 268 | case MT2_MLME_ROAMING_REQ: |
| 269 | CntlMlmeRoamingProc(pAd, Elem); |
| 270 | break; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 271 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 272 | case OID_802_11_MIC_FAILURE_REPORT_FRAME: |
| 273 | WpaMicFailureReportFrame(pAd, Elem); |
| 274 | break; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 275 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 276 | default: |
| 277 | DBGPRINT(RT_DEBUG_TRACE, |
| 278 | ("CNTL - Illegal message in CntlIdleProc(MsgType=%ld)\n", |
| 279 | Elem->MsgType)); |
| 280 | break; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 281 | } |
| 282 | } |
| 283 | |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 284 | void CntlOidScanProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 285 | { |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 286 | struct rt_mlme_scan_req ScanReq; |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 287 | unsigned long BssIdx = BSS_NOT_FOUND; |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 288 | struct rt_bss_entry CurrBss; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 289 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 290 | /* record current BSS if network is connected. */ |
| 291 | /* 2003-2-13 do not include current IBSS if this is the only STA in this IBSS. */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 292 | if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED)) { |
| 293 | BssIdx = |
| 294 | BssSsidTableSearch(&pAd->ScanTab, pAd->CommonCfg.Bssid, |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 295 | (u8 *)pAd->CommonCfg.Ssid, |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 296 | pAd->CommonCfg.SsidLen, |
| 297 | pAd->CommonCfg.Channel); |
| 298 | if (BssIdx != BSS_NOT_FOUND) { |
| 299 | NdisMoveMemory(&CurrBss, &pAd->ScanTab.BssEntry[BssIdx], |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 300 | sizeof(struct rt_bss_entry)); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 301 | } |
| 302 | } |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 303 | /* clean up previous SCAN result, add current BSS back to table if any */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 304 | BssTableInit(&pAd->ScanTab); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 305 | if (BssIdx != BSS_NOT_FOUND) { |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 306 | /* DDK Note: If the NIC is associated with a particular BSSID and SSID */ |
| 307 | /* that are not contained in the list of BSSIDs generated by this scan, the */ |
| 308 | /* BSSID description of the currently associated BSSID and SSID should be */ |
| 309 | /* appended to the list of BSSIDs in the NIC's database. */ |
| 310 | /* To ensure this, we append this BSS as the first entry in SCAN result */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 311 | NdisMoveMemory(&pAd->ScanTab.BssEntry[0], &CurrBss, |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 312 | sizeof(struct rt_bss_entry)); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 313 | pAd->ScanTab.BssNr = 1; |
| 314 | } |
| 315 | |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 316 | ScanParmFill(pAd, &ScanReq, (char *)Elem->Msg, Elem->MsgLen, BSS_ANY, |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 317 | SCAN_ACTIVE); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 318 | MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_MLME_SCAN_REQ, |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 319 | sizeof(struct rt_mlme_scan_req), &ScanReq); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 320 | pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_LIST_SCAN; |
| 321 | } |
| 322 | |
| 323 | /* |
| 324 | ========================================================================== |
| 325 | Description: |
| 326 | Before calling this routine, user desired SSID should already been |
| 327 | recorded in CommonCfg.Ssid[] |
| 328 | IRQL = DISPATCH_LEVEL |
| 329 | |
| 330 | ========================================================================== |
| 331 | */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 332 | void CntlOidSsidProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 333 | { |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 334 | struct rt_ndis_802_11_ssid * pOidSsid = (struct rt_ndis_802_11_ssid *) Elem->Msg; |
| 335 | struct rt_mlme_disassoc_req DisassocReq; |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 336 | unsigned long Now; |
Adam McDaniel | ed291e8 | 2009-02-23 08:01:07 -0700 | [diff] [blame] | 337 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 338 | /* Step 1. record the desired user settings to MlmeAux */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 339 | NdisZeroMemory(pAd->MlmeAux.Ssid, MAX_LEN_OF_SSID); |
| 340 | NdisMoveMemory(pAd->MlmeAux.Ssid, pOidSsid->Ssid, pOidSsid->SsidLength); |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 341 | pAd->MlmeAux.SsidLen = (u8)pOidSsid->SsidLength; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 342 | NdisZeroMemory(pAd->MlmeAux.Bssid, MAC_ADDR_LEN); |
| 343 | pAd->MlmeAux.BssType = pAd->StaCfg.BssType; |
| 344 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 345 | pAd->StaCfg.bAutoConnectByBssid = FALSE; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 346 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 347 | /* */ |
| 348 | /* Update Reconnect Ssid, that user desired to connect. */ |
| 349 | /* */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 350 | NdisZeroMemory(pAd->MlmeAux.AutoReconnectSsid, MAX_LEN_OF_SSID); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 351 | NdisMoveMemory(pAd->MlmeAux.AutoReconnectSsid, pAd->MlmeAux.Ssid, |
| 352 | pAd->MlmeAux.SsidLen); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 353 | pAd->MlmeAux.AutoReconnectSsidLen = pAd->MlmeAux.SsidLen; |
| 354 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 355 | /* step 2. find all matching BSS in the lastest SCAN result (inBssTab) */ |
| 356 | /* & log them into MlmeAux.SsidBssTab for later-on iteration. Sort by RSSI order */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 357 | BssTableSsidSort(pAd, &pAd->MlmeAux.SsidBssTab, |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 358 | (char *)pAd->MlmeAux.Ssid, pAd->MlmeAux.SsidLen); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 359 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 360 | DBGPRINT(RT_DEBUG_TRACE, |
| 361 | ("CntlOidSsidProc():CNTL - %d BSS of %d BSS match the desire (%d)SSID - %s\n", |
| 362 | pAd->MlmeAux.SsidBssTab.BssNr, pAd->ScanTab.BssNr, |
| 363 | pAd->MlmeAux.SsidLen, pAd->MlmeAux.Ssid)); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 364 | NdisGetSystemUpTime(&Now); |
| 365 | |
| 366 | if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED) && |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 367 | (pAd->CommonCfg.SsidLen == |
| 368 | pAd->MlmeAux.SsidBssTab.BssEntry[0].SsidLen) |
| 369 | && NdisEqualMemory(pAd->CommonCfg.Ssid, |
| 370 | pAd->MlmeAux.SsidBssTab.BssEntry[0].Ssid, |
| 371 | pAd->CommonCfg.SsidLen) |
| 372 | && MAC_ADDR_EQUAL(pAd->CommonCfg.Bssid, |
| 373 | pAd->MlmeAux.SsidBssTab.BssEntry[0].Bssid)) { |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 374 | /* Case 1. already connected with an AP who has the desired SSID */ |
| 375 | /* with highest RSSI */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 376 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 377 | /* Add checking Mode "LEAP" for CCX 1.0 */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 378 | if (((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA) || |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 379 | (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) || |
| 380 | (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) || |
| 381 | (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) |
| 382 | ) && |
| 383 | (pAd->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED)) { |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 384 | /* case 1.1 For WPA, WPA-PSK, if the 1x port is not secured, we have to redo */ |
| 385 | /* connection process */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 386 | DBGPRINT(RT_DEBUG_TRACE, |
| 387 | ("CntlOidSsidProc():CNTL - disassociate with current AP...\n")); |
| 388 | DisassocParmFill(pAd, &DisassocReq, |
| 389 | pAd->CommonCfg.Bssid, |
| 390 | REASON_DISASSOC_STA_LEAVING); |
| 391 | MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, |
| 392 | MT2_MLME_DISASSOC_REQ, |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 393 | sizeof(struct rt_mlme_disassoc_req), |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 394 | &DisassocReq); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 395 | pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_DISASSOC; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 396 | } else if (pAd->bConfigChanged == TRUE) { |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 397 | /* case 1.2 Important Config has changed, we have to reconnect to the same AP */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 398 | DBGPRINT(RT_DEBUG_TRACE, |
| 399 | ("CntlOidSsidProc():CNTL - disassociate with current AP Because config changed...\n")); |
| 400 | DisassocParmFill(pAd, &DisassocReq, |
| 401 | pAd->CommonCfg.Bssid, |
| 402 | REASON_DISASSOC_STA_LEAVING); |
| 403 | MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, |
| 404 | MT2_MLME_DISASSOC_REQ, |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 405 | sizeof(struct rt_mlme_disassoc_req), |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 406 | &DisassocReq); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 407 | pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_DISASSOC; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 408 | } else { |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 409 | /* case 1.3. already connected to the SSID with highest RSSI. */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 410 | DBGPRINT(RT_DEBUG_TRACE, |
| 411 | ("CntlOidSsidProc():CNTL - already with this BSSID. ignore this SET_SSID request\n")); |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 412 | /* */ |
| 413 | /* (HCT 12.1) 1c_wlan_mediaevents required */ |
| 414 | /* media connect events are indicated when associating with the same AP */ |
| 415 | /* */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 416 | if (INFRA_ON(pAd)) { |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 417 | /* */ |
| 418 | /* Since MediaState already is NdisMediaStateConnected */ |
| 419 | /* We just indicate the connect event again to meet the WHQL required. */ |
| 420 | /* */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 421 | pAd->IndicateMediaState = |
| 422 | NdisMediaStateConnected; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 423 | RTMP_IndicateMediaState(pAd); |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 424 | pAd->ExtraInfo = GENERAL_LINK_UP; /* Update extra information to link is up */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 425 | } |
| 426 | |
| 427 | pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 428 | RtmpOSWrielessEventSend(pAd, SIOCGIWAP, -1, |
| 429 | &pAd->MlmeAux.Bssid[0], NULL, |
| 430 | 0); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 431 | } |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 432 | } else if (INFRA_ON(pAd)) { |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 433 | /* */ |
| 434 | /* For RT61 */ |
| 435 | /* [88888] OID_802_11_SSID should have returned NDTEST_WEP_AP2(Returned: ) */ |
| 436 | /* RT61 may lost SSID, and not connect to NDTEST_WEP_AP2 and will connect to NDTEST_WEP_AP2 by Autoreconnect */ |
| 437 | /* But media status is connected, so the SSID not report correctly. */ |
| 438 | /* */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 439 | if (!SSID_EQUAL |
| 440 | (pAd->CommonCfg.Ssid, pAd->CommonCfg.SsidLen, |
| 441 | pAd->MlmeAux.Ssid, pAd->MlmeAux.SsidLen)) { |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 442 | /* */ |
| 443 | /* Different SSID means not Roaming case, so we let LinkDown() to Indicate a disconnect event. */ |
| 444 | /* */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 445 | pAd->MlmeAux.CurrReqIsFromNdis = TRUE; |
| 446 | } |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 447 | /* case 2. active INFRA association existent */ |
| 448 | /* roaming is done within miniport driver, nothing to do with configuration */ |
| 449 | /* utility. so upon a new SET(OID_802_11_SSID) is received, we just */ |
| 450 | /* disassociate with the current associated AP, */ |
| 451 | /* then perform a new association with this new SSID, no matter the */ |
| 452 | /* new/old SSID are the same or not. */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 453 | DBGPRINT(RT_DEBUG_TRACE, |
| 454 | ("CntlOidSsidProc():CNTL - disassociate with current AP...\n")); |
| 455 | DisassocParmFill(pAd, &DisassocReq, pAd->CommonCfg.Bssid, |
| 456 | REASON_DISASSOC_STA_LEAVING); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 457 | MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_MLME_DISASSOC_REQ, |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 458 | sizeof(struct rt_mlme_disassoc_req), &DisassocReq); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 459 | pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_DISASSOC; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 460 | } else { |
| 461 | if (ADHOC_ON(pAd)) { |
| 462 | DBGPRINT(RT_DEBUG_TRACE, |
| 463 | ("CntlOidSsidProc():CNTL - drop current ADHOC\n")); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 464 | LinkDown(pAd, FALSE); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 465 | OPSTATUS_CLEAR_FLAG(pAd, |
| 466 | fOP_STATUS_MEDIA_STATE_CONNECTED); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 467 | pAd->IndicateMediaState = NdisMediaStateDisconnected; |
| 468 | RTMP_IndicateMediaState(pAd); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 469 | pAd->ExtraInfo = GENERAL_LINK_DOWN; |
| 470 | DBGPRINT(RT_DEBUG_TRACE, |
| 471 | ("CntlOidSsidProc():NDIS_STATUS_MEDIA_DISCONNECT Event C!\n")); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 472 | } |
| 473 | |
| 474 | if ((pAd->MlmeAux.SsidBssTab.BssNr == 0) && |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 475 | (pAd->StaCfg.bAutoReconnect == TRUE) && |
| 476 | (pAd->MlmeAux.BssType == BSS_INFRA) && |
| 477 | (MlmeValidateSSID(pAd->MlmeAux.Ssid, pAd->MlmeAux.SsidLen) |
| 478 | == TRUE) |
| 479 | ) { |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 480 | struct rt_mlme_scan_req ScanReq; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 481 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 482 | DBGPRINT(RT_DEBUG_TRACE, |
| 483 | ("CntlOidSsidProc():CNTL - No matching BSS, start a new scan\n")); |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 484 | ScanParmFill(pAd, &ScanReq, (char *)pAd->MlmeAux.Ssid, |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 485 | pAd->MlmeAux.SsidLen, BSS_ANY, |
| 486 | SCAN_ACTIVE); |
| 487 | MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_MLME_SCAN_REQ, |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 488 | sizeof(struct rt_mlme_scan_req), &ScanReq); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 489 | pAd->Mlme.CntlMachine.CurrState = |
| 490 | CNTL_WAIT_OID_LIST_SCAN; |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 491 | /* Reset Missed scan number */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 492 | pAd->StaCfg.LastScanTime = Now; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 493 | } else { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 494 | pAd->MlmeAux.BssIdx = 0; |
| 495 | IterateOnBssTab(pAd); |
| 496 | } |
| 497 | } |
| 498 | } |
| 499 | |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 500 | /* |
| 501 | ========================================================================== |
| 502 | Description: |
| 503 | |
| 504 | IRQL = DISPATCH_LEVEL |
| 505 | |
| 506 | ========================================================================== |
| 507 | */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 508 | void CntlOidRTBssidProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 509 | { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 510 | unsigned long BssIdx; |
| 511 | u8 *pOidBssid = (u8 *)Elem->Msg; |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 512 | struct rt_mlme_disassoc_req DisassocReq; |
| 513 | struct rt_mlme_join_req JoinReq; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 514 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 515 | /* record user desired settings */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 516 | COPY_MAC_ADDR(pAd->MlmeAux.Bssid, pOidBssid); |
| 517 | pAd->MlmeAux.BssType = pAd->StaCfg.BssType; |
| 518 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 519 | /* find the desired BSS in the latest SCAN result table */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 520 | BssIdx = BssTableSearch(&pAd->ScanTab, pOidBssid, pAd->MlmeAux.Channel); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 521 | if (BssIdx == BSS_NOT_FOUND) { |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 522 | struct rt_mlme_scan_req ScanReq; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 523 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 524 | DBGPRINT(RT_DEBUG_TRACE, |
| 525 | ("CNTL - BSSID not found. reply NDIS_STATUS_NOT_ACCEPTED\n")); |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 526 | /*pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE; */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 527 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 528 | DBGPRINT(RT_DEBUG_TRACE, |
| 529 | ("CNTL - BSSID not found. start a new scan\n")); |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 530 | ScanParmFill(pAd, &ScanReq, (char *)pAd->MlmeAux.Ssid, |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 531 | pAd->MlmeAux.SsidLen, BSS_ANY, SCAN_ACTIVE); |
| 532 | MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_MLME_SCAN_REQ, |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 533 | sizeof(struct rt_mlme_scan_req), &ScanReq); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 534 | pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_LIST_SCAN; |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 535 | /* Reset Missed scan number */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 536 | NdisGetSystemUpTime(&pAd->StaCfg.LastScanTime); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 537 | return; |
| 538 | } |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 539 | /* */ |
| 540 | /* Update Reconnect Ssid, that user desired to connect. */ |
| 541 | /* */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 542 | NdisZeroMemory(pAd->MlmeAux.AutoReconnectSsid, MAX_LEN_OF_SSID); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 543 | pAd->MlmeAux.AutoReconnectSsidLen = |
| 544 | pAd->ScanTab.BssEntry[BssIdx].SsidLen; |
| 545 | NdisMoveMemory(pAd->MlmeAux.AutoReconnectSsid, |
| 546 | pAd->ScanTab.BssEntry[BssIdx].Ssid, |
| 547 | pAd->ScanTab.BssEntry[BssIdx].SsidLen); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 548 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 549 | /* copy the matched BSS entry from ScanTab to MlmeAux.SsidBssTab. Why? */ |
| 550 | /* Because we need this entry to become the JOIN target in later on SYNC state machine */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 551 | pAd->MlmeAux.BssIdx = 0; |
| 552 | pAd->MlmeAux.SsidBssTab.BssNr = 1; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 553 | NdisMoveMemory(&pAd->MlmeAux.SsidBssTab.BssEntry[0], |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 554 | &pAd->ScanTab.BssEntry[BssIdx], sizeof(struct rt_bss_entry)); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 555 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 556 | /* Add SSID into MlmeAux for site surey joining hidden SSID */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 557 | pAd->MlmeAux.SsidLen = pAd->ScanTab.BssEntry[BssIdx].SsidLen; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 558 | NdisMoveMemory(pAd->MlmeAux.Ssid, pAd->ScanTab.BssEntry[BssIdx].Ssid, |
| 559 | pAd->MlmeAux.SsidLen); |
Bartlomiej Zolnierkiewicz | 2684d16 | 2009-04-26 16:05:51 +0200 | [diff] [blame] | 560 | |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 561 | { |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 562 | if (INFRA_ON(pAd)) { |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 563 | /* disassoc from current AP first */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 564 | DBGPRINT(RT_DEBUG_TRACE, |
| 565 | ("CNTL - disassociate with current AP ...\n")); |
| 566 | DisassocParmFill(pAd, &DisassocReq, |
| 567 | pAd->CommonCfg.Bssid, |
| 568 | REASON_DISASSOC_STA_LEAVING); |
| 569 | MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, |
| 570 | MT2_MLME_DISASSOC_REQ, |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 571 | sizeof(struct rt_mlme_disassoc_req), |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 572 | &DisassocReq); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 573 | |
| 574 | pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_DISASSOC; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 575 | } else { |
| 576 | if (ADHOC_ON(pAd)) { |
| 577 | DBGPRINT(RT_DEBUG_TRACE, |
| 578 | ("CNTL - drop current ADHOC\n")); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 579 | LinkDown(pAd, FALSE); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 580 | OPSTATUS_CLEAR_FLAG(pAd, |
| 581 | fOP_STATUS_MEDIA_STATE_CONNECTED); |
| 582 | pAd->IndicateMediaState = |
| 583 | NdisMediaStateDisconnected; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 584 | RTMP_IndicateMediaState(pAd); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 585 | pAd->ExtraInfo = GENERAL_LINK_DOWN; |
| 586 | DBGPRINT(RT_DEBUG_TRACE, |
| 587 | ("NDIS_STATUS_MEDIA_DISCONNECT Event C!\n")); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 588 | } |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 589 | /* Change the wepstatus to original wepstatus */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 590 | pAd->StaCfg.WepStatus = pAd->StaCfg.OrigWepStatus; |
| 591 | pAd->StaCfg.PairCipher = pAd->StaCfg.OrigWepStatus; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 592 | pAd->StaCfg.GroupCipher = pAd->StaCfg.OrigWepStatus; |
| 593 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 594 | /* Check cipher suite, AP must have more secured cipher than station setting */ |
| 595 | /* Set the Pairwise and Group cipher to match the intended AP setting */ |
| 596 | /* We can only connect to AP with less secured cipher setting */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 597 | if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA) |
| 598 | || (pAd->StaCfg.AuthMode == |
| 599 | Ndis802_11AuthModeWPAPSK)) { |
| 600 | pAd->StaCfg.GroupCipher = |
| 601 | pAd->ScanTab.BssEntry[BssIdx].WPA. |
| 602 | GroupCipher; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 603 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 604 | if (pAd->StaCfg.WepStatus == |
| 605 | pAd->ScanTab.BssEntry[BssIdx].WPA. |
| 606 | PairCipher) |
| 607 | pAd->StaCfg.PairCipher = |
| 608 | pAd->ScanTab.BssEntry[BssIdx].WPA. |
| 609 | PairCipher; |
| 610 | else if (pAd->ScanTab.BssEntry[BssIdx].WPA. |
| 611 | PairCipherAux != Ndis802_11WEPDisabled) |
| 612 | pAd->StaCfg.PairCipher = |
| 613 | pAd->ScanTab.BssEntry[BssIdx].WPA. |
| 614 | PairCipherAux; |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 615 | else /* There is no PairCipher Aux, downgrade our capability to TKIP */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 616 | pAd->StaCfg.PairCipher = |
| 617 | Ndis802_11Encryption2Enabled; |
| 618 | } else |
| 619 | if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) |
| 620 | || (pAd->StaCfg.AuthMode == |
| 621 | Ndis802_11AuthModeWPA2PSK)) { |
| 622 | pAd->StaCfg.GroupCipher = |
| 623 | pAd->ScanTab.BssEntry[BssIdx].WPA2. |
| 624 | GroupCipher; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 625 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 626 | if (pAd->StaCfg.WepStatus == |
| 627 | pAd->ScanTab.BssEntry[BssIdx].WPA2. |
| 628 | PairCipher) |
| 629 | pAd->StaCfg.PairCipher = |
| 630 | pAd->ScanTab.BssEntry[BssIdx].WPA2. |
| 631 | PairCipher; |
| 632 | else if (pAd->ScanTab.BssEntry[BssIdx].WPA2. |
| 633 | PairCipherAux != Ndis802_11WEPDisabled) |
| 634 | pAd->StaCfg.PairCipher = |
| 635 | pAd->ScanTab.BssEntry[BssIdx].WPA2. |
| 636 | PairCipherAux; |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 637 | else /* There is no PairCipher Aux, downgrade our capability to TKIP */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 638 | pAd->StaCfg.PairCipher = |
| 639 | Ndis802_11Encryption2Enabled; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 640 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 641 | /* RSN capability */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 642 | pAd->StaCfg.RsnCapability = |
| 643 | pAd->ScanTab.BssEntry[BssIdx].WPA2. |
| 644 | RsnCapability; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 645 | } |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 646 | /* Set Mix cipher flag */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 647 | pAd->StaCfg.bMixCipher = |
| 648 | (pAd->StaCfg.PairCipher == |
| 649 | pAd->StaCfg.GroupCipher) ? FALSE : TRUE; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 650 | /*if (pAd->StaCfg.bMixCipher == TRUE) |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 651 | { |
| 652 | // If mix cipher, re-build RSNIE |
| 653 | RTMPMakeRSNIE(pAd, pAd->StaCfg.AuthMode, pAd->StaCfg.WepStatus, 0); |
| 654 | } */ |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 655 | /* No active association, join the BSS immediately */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 656 | DBGPRINT(RT_DEBUG_TRACE, |
| 657 | ("CNTL - joining %02x:%02x:%02x:%02x:%02x:%02x ...\n", |
| 658 | pOidBssid[0], pOidBssid[1], pOidBssid[2], |
| 659 | pOidBssid[3], pOidBssid[4], pOidBssid[5])); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 660 | |
| 661 | JoinParmFill(pAd, &JoinReq, pAd->MlmeAux.BssIdx); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 662 | MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_MLME_JOIN_REQ, |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 663 | sizeof(struct rt_mlme_join_req), &JoinReq); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 664 | |
| 665 | pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_JOIN; |
| 666 | } |
| 667 | } |
| 668 | } |
| 669 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 670 | /* Roaming is the only external request triggering CNTL state machine */ |
| 671 | /* despite of other "SET OID" operation. All "SET OID" related oerations */ |
| 672 | /* happen in sequence, because no other SET OID will be sent to this device */ |
| 673 | /* until the the previous SET operation is complete (successful o failed). */ |
| 674 | /* So, how do we quarantee this ROAMING request won't corrupt other "SET OID"? */ |
| 675 | /* or been corrupted by other "SET OID"? */ |
| 676 | /* */ |
| 677 | /* IRQL = DISPATCH_LEVEL */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 678 | void CntlMlmeRoamingProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 679 | { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 680 | u8 BBPValue = 0; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 681 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 682 | DBGPRINT(RT_DEBUG_TRACE, ("CNTL - Roaming in MlmeAux.RoamTab...\n")); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 683 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 684 | { |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 685 | /*Let BBP register at 20MHz to do (fast) roaming. */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 686 | RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue); |
| 687 | BBPValue &= (~0x18); |
| 688 | RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue); |
| 689 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 690 | NdisMoveMemory(&pAd->MlmeAux.SsidBssTab, &pAd->MlmeAux.RoamTab, |
| 691 | sizeof(pAd->MlmeAux.RoamTab)); |
| 692 | pAd->MlmeAux.SsidBssTab.BssNr = pAd->MlmeAux.RoamTab.BssNr; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 693 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 694 | BssTableSortByRssi(&pAd->MlmeAux.SsidBssTab); |
| 695 | pAd->MlmeAux.BssIdx = 0; |
| 696 | IterateOnBssTab(pAd); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 697 | } |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 698 | } |
| 699 | |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 700 | /* |
| 701 | ========================================================================== |
| 702 | Description: |
| 703 | |
| 704 | IRQL = DISPATCH_LEVEL |
| 705 | |
| 706 | ========================================================================== |
| 707 | */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 708 | void CntlWaitDisassocProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 709 | { |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 710 | struct rt_mlme_start_req StartReq; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 711 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 712 | if (Elem->MsgType == MT2_DISASSOC_CONF) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 713 | DBGPRINT(RT_DEBUG_TRACE, ("CNTL - Dis-associate successful\n")); |
| 714 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 715 | if (pAd->CommonCfg.bWirelessEvent) { |
| 716 | RTMPSendWirelessEvent(pAd, IW_DISASSOC_EVENT_FLAG, |
| 717 | pAd->MacTab.Content[BSSID_WCID]. |
| 718 | Addr, BSS0, 0); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 719 | } |
| 720 | |
| 721 | LinkDown(pAd, FALSE); |
| 722 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 723 | /* case 1. no matching BSS, and user wants ADHOC, so we just start a new one */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 724 | if ((pAd->MlmeAux.SsidBssTab.BssNr == 0) |
| 725 | && (pAd->StaCfg.BssType == BSS_ADHOC)) { |
| 726 | DBGPRINT(RT_DEBUG_TRACE, |
| 727 | ("CNTL - No matching BSS, start a new ADHOC (Ssid=%s)...\n", |
| 728 | pAd->MlmeAux.Ssid)); |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 729 | StartParmFill(pAd, &StartReq, (char *)pAd->MlmeAux.Ssid, |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 730 | pAd->MlmeAux.SsidLen); |
| 731 | MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_MLME_START_REQ, |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 732 | sizeof(struct rt_mlme_start_req), &StartReq); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 733 | pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_START; |
| 734 | } |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 735 | /* case 2. try each matched BSS */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 736 | else { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 737 | pAd->MlmeAux.BssIdx = 0; |
| 738 | |
| 739 | IterateOnBssTab(pAd); |
| 740 | } |
| 741 | } |
| 742 | } |
| 743 | |
| 744 | /* |
| 745 | ========================================================================== |
| 746 | Description: |
| 747 | |
| 748 | IRQL = DISPATCH_LEVEL |
| 749 | |
| 750 | ========================================================================== |
| 751 | */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 752 | void CntlWaitJoinProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 753 | { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 754 | u16 Reason; |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 755 | struct rt_mlme_auth_req AuthReq; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 756 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 757 | if (Elem->MsgType == MT2_JOIN_CONF) { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 758 | NdisMoveMemory(&Reason, Elem->Msg, sizeof(u16)); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 759 | if (Reason == MLME_SUCCESS) { |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 760 | /* 1. joined an IBSS, we are pretty much done here */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 761 | if (pAd->MlmeAux.BssType == BSS_ADHOC) { |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 762 | /* */ |
| 763 | /* 5G bands rules of Japan: */ |
| 764 | /* Ad hoc must be disabled in W53(ch52,56,60,64) channels. */ |
| 765 | /* */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 766 | if ((pAd->CommonCfg.bIEEE80211H == 1) && |
| 767 | RadarChannelCheck(pAd, |
| 768 | pAd->CommonCfg.Channel) |
| 769 | ) { |
| 770 | pAd->Mlme.CntlMachine.CurrState = |
| 771 | CNTL_IDLE; |
| 772 | DBGPRINT(RT_DEBUG_TRACE, |
| 773 | ("CNTL - Channel=%d, Join adhoc on W53(52,56,60,64) Channels are not accepted\n", |
| 774 | pAd->CommonCfg.Channel)); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 775 | return; |
| 776 | } |
| 777 | |
| 778 | LinkUp(pAd, BSS_ADHOC); |
| 779 | pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 780 | DBGPRINT(RT_DEBUG_TRACE, |
| 781 | ("CNTL - join the IBSS = %02x:%02x:%02x:%02x:%02x:%02x ...\n", |
| 782 | pAd->CommonCfg.Bssid[0], |
| 783 | pAd->CommonCfg.Bssid[1], |
| 784 | pAd->CommonCfg.Bssid[2], |
| 785 | pAd->CommonCfg.Bssid[3], |
| 786 | pAd->CommonCfg.Bssid[4], |
| 787 | pAd->CommonCfg.Bssid[5])); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 788 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 789 | pAd->IndicateMediaState = |
| 790 | NdisMediaStateConnected; |
| 791 | pAd->ExtraInfo = GENERAL_LINK_UP; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 792 | } |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 793 | /* 2. joined a new INFRA network, start from authentication */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 794 | else { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 795 | { |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 796 | /* either Ndis802_11AuthModeShared or Ndis802_11AuthModeAutoSwitch, try shared key first */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 797 | if ((pAd->StaCfg.AuthMode == |
| 798 | Ndis802_11AuthModeShared) |
| 799 | || (pAd->StaCfg.AuthMode == |
| 800 | Ndis802_11AuthModeAutoSwitch)) { |
| 801 | AuthParmFill(pAd, &AuthReq, |
| 802 | pAd->MlmeAux.Bssid, |
| 803 | AUTH_MODE_KEY); |
| 804 | } else { |
| 805 | AuthParmFill(pAd, &AuthReq, |
| 806 | pAd->MlmeAux.Bssid, |
| 807 | AUTH_MODE_OPEN); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 808 | } |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 809 | MlmeEnqueue(pAd, AUTH_STATE_MACHINE, |
| 810 | MT2_MLME_AUTH_REQ, |
| 811 | sizeof |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 812 | (struct rt_mlme_auth_req), |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 813 | &AuthReq); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 814 | } |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 815 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 816 | pAd->Mlme.CntlMachine.CurrState = |
| 817 | CNTL_WAIT_AUTH; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 818 | } |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 819 | } else { |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 820 | /* 3. failed, try next BSS */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 821 | pAd->MlmeAux.BssIdx++; |
| 822 | IterateOnBssTab(pAd); |
| 823 | } |
| 824 | } |
| 825 | } |
| 826 | |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 827 | /* |
| 828 | ========================================================================== |
| 829 | Description: |
| 830 | |
| 831 | IRQL = DISPATCH_LEVEL |
| 832 | |
| 833 | ========================================================================== |
| 834 | */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 835 | void CntlWaitStartProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 836 | { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 837 | u16 Result; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 838 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 839 | if (Elem->MsgType == MT2_START_CONF) { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 840 | NdisMoveMemory(&Result, Elem->Msg, sizeof(u16)); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 841 | if (Result == MLME_SUCCESS) { |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 842 | /* */ |
| 843 | /* 5G bands rules of Japan: */ |
| 844 | /* Ad hoc must be disabled in W53(ch52,56,60,64) channels. */ |
| 845 | /* */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 846 | if ((pAd->CommonCfg.bIEEE80211H == 1) && |
| 847 | RadarChannelCheck(pAd, pAd->CommonCfg.Channel) |
| 848 | ) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 849 | pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 850 | DBGPRINT(RT_DEBUG_TRACE, |
| 851 | ("CNTL - Channel=%d, Start adhoc on W53(52,56,60,64) Channels are not accepted\n", |
| 852 | pAd->CommonCfg.Channel)); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 853 | return; |
| 854 | } |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 855 | NdisZeroMemory(&pAd->StaActive.SupportedPhyInfo. |
| 856 | MCSSet[0], 16); |
| 857 | if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 858 | N_ChannelCheck(pAd); |
| 859 | SetCommonHT(pAd); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 860 | NdisMoveMemory(&pAd->MlmeAux.AddHtInfo, |
| 861 | &pAd->CommonCfg.AddHTInfo, |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 862 | sizeof(struct rt_add_ht_info_ie)); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 863 | RTMPCheckHt(pAd, BSSID_WCID, |
| 864 | &pAd->CommonCfg.HtCapability, |
| 865 | &pAd->CommonCfg.AddHTInfo); |
| 866 | pAd->StaActive.SupportedPhyInfo.bHtEnable = |
| 867 | TRUE; |
| 868 | NdisMoveMemory(&pAd->StaActive.SupportedPhyInfo. |
| 869 | MCSSet[0], |
| 870 | &pAd->CommonCfg.HtCapability. |
| 871 | MCSSet[0], 16); |
| 872 | COPY_HTSETTINGS_FROM_MLME_AUX_TO_ACTIVE_CFG |
| 873 | (pAd); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 874 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 875 | if ((pAd->CommonCfg.HtCapability.HtCapInfo. |
| 876 | ChannelWidth == BW_40) |
| 877 | && (pAd->CommonCfg.AddHTInfo.AddHtInfo. |
| 878 | ExtChanOffset == EXTCHA_ABOVE)) { |
| 879 | pAd->MlmeAux.CentralChannel = |
| 880 | pAd->CommonCfg.Channel + 2; |
| 881 | } else |
| 882 | if ((pAd->CommonCfg.HtCapability.HtCapInfo. |
| 883 | ChannelWidth == BW_40) |
| 884 | && (pAd->CommonCfg.AddHTInfo.AddHtInfo. |
| 885 | ExtChanOffset == EXTCHA_BELOW)) { |
| 886 | pAd->MlmeAux.CentralChannel = |
| 887 | pAd->CommonCfg.Channel - 2; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 888 | } |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 889 | } else { |
| 890 | pAd->StaActive.SupportedPhyInfo.bHtEnable = |
| 891 | FALSE; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 892 | } |
| 893 | LinkUp(pAd, BSS_ADHOC); |
| 894 | pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE; |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 895 | /* Before send beacon, driver need do radar detection */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 896 | if ((pAd->CommonCfg.Channel > 14) |
| 897 | && (pAd->CommonCfg.bIEEE80211H == 1) |
| 898 | && RadarChannelCheck(pAd, pAd->CommonCfg.Channel)) { |
| 899 | pAd->CommonCfg.RadarDetect.RDMode = |
| 900 | RD_SILENCE_MODE; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 901 | pAd->CommonCfg.RadarDetect.RDCount = 0; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 902 | } |
| 903 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 904 | DBGPRINT(RT_DEBUG_TRACE, |
| 905 | ("CNTL - start a new IBSS = %02x:%02x:%02x:%02x:%02x:%02x ...\n", |
| 906 | pAd->CommonCfg.Bssid[0], |
| 907 | pAd->CommonCfg.Bssid[1], |
| 908 | pAd->CommonCfg.Bssid[2], |
| 909 | pAd->CommonCfg.Bssid[3], |
| 910 | pAd->CommonCfg.Bssid[4], |
| 911 | pAd->CommonCfg.Bssid[5])); |
| 912 | } else { |
| 913 | DBGPRINT(RT_DEBUG_TRACE, |
| 914 | ("CNTL - Start IBSS fail. BUG!!!!!\n")); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 915 | pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE; |
| 916 | } |
| 917 | } |
| 918 | } |
| 919 | |
| 920 | /* |
| 921 | ========================================================================== |
| 922 | Description: |
| 923 | |
| 924 | IRQL = DISPATCH_LEVEL |
| 925 | |
| 926 | ========================================================================== |
| 927 | */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 928 | void CntlWaitAuthProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 929 | { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 930 | u16 Reason; |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 931 | struct rt_mlme_assoc_req AssocReq; |
| 932 | struct rt_mlme_auth_req AuthReq; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 933 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 934 | if (Elem->MsgType == MT2_AUTH_CONF) { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 935 | NdisMoveMemory(&Reason, Elem->Msg, sizeof(u16)); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 936 | if (Reason == MLME_SUCCESS) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 937 | DBGPRINT(RT_DEBUG_TRACE, ("CNTL - AUTH OK\n")); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 938 | AssocParmFill(pAd, &AssocReq, pAd->MlmeAux.Bssid, |
| 939 | pAd->MlmeAux.CapabilityInfo, |
| 940 | ASSOC_TIMEOUT, |
| 941 | pAd->StaCfg.DefaultListenCount); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 942 | |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 943 | { |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 944 | MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, |
| 945 | MT2_MLME_ASSOC_REQ, |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 946 | sizeof(struct rt_mlme_assoc_req), |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 947 | &AssocReq); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 948 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 949 | pAd->Mlme.CntlMachine.CurrState = |
| 950 | CNTL_WAIT_ASSOC; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 951 | } |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 952 | } else { |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 953 | /* This fail may because of the AP already keep us in its MAC table without */ |
| 954 | /* ageing-out. The previous authentication attempt must have let it remove us. */ |
| 955 | /* so try Authentication again may help. For D-Link DWL-900AP+ compatibility. */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 956 | DBGPRINT(RT_DEBUG_TRACE, |
| 957 | ("CNTL - AUTH FAIL, try again...\n")); |
Bartlomiej Zolnierkiewicz | 720613f | 2009-04-26 16:05:24 +0200 | [diff] [blame] | 958 | |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 959 | { |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 960 | if ((pAd->StaCfg.AuthMode == |
| 961 | Ndis802_11AuthModeShared) |
| 962 | || (pAd->StaCfg.AuthMode == |
| 963 | Ndis802_11AuthModeAutoSwitch)) { |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 964 | /* either Ndis802_11AuthModeShared or Ndis802_11AuthModeAutoSwitch, try shared key first */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 965 | AuthParmFill(pAd, &AuthReq, |
| 966 | pAd->MlmeAux.Bssid, |
| 967 | AUTH_MODE_KEY); |
| 968 | } else { |
| 969 | AuthParmFill(pAd, &AuthReq, |
| 970 | pAd->MlmeAux.Bssid, |
| 971 | AUTH_MODE_OPEN); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 972 | } |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 973 | MlmeEnqueue(pAd, AUTH_STATE_MACHINE, |
| 974 | MT2_MLME_AUTH_REQ, |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 975 | sizeof(struct rt_mlme_auth_req), |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 976 | &AuthReq); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 977 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 978 | } |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 979 | pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_AUTH2; |
| 980 | } |
| 981 | } |
| 982 | } |
| 983 | |
| 984 | /* |
| 985 | ========================================================================== |
| 986 | Description: |
| 987 | |
| 988 | IRQL = DISPATCH_LEVEL |
| 989 | |
| 990 | ========================================================================== |
| 991 | */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 992 | void CntlWaitAuthProc2(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 993 | { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 994 | u16 Reason; |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 995 | struct rt_mlme_assoc_req AssocReq; |
| 996 | struct rt_mlme_auth_req AuthReq; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 997 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 998 | if (Elem->MsgType == MT2_AUTH_CONF) { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 999 | NdisMoveMemory(&Reason, Elem->Msg, sizeof(u16)); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1000 | if (Reason == MLME_SUCCESS) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1001 | DBGPRINT(RT_DEBUG_TRACE, ("CNTL - AUTH OK\n")); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1002 | AssocParmFill(pAd, &AssocReq, pAd->MlmeAux.Bssid, |
| 1003 | pAd->MlmeAux.CapabilityInfo, |
| 1004 | ASSOC_TIMEOUT, |
| 1005 | pAd->StaCfg.DefaultListenCount); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1006 | { |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1007 | MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, |
| 1008 | MT2_MLME_ASSOC_REQ, |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 1009 | sizeof(struct rt_mlme_assoc_req), |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1010 | &AssocReq); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1011 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1012 | pAd->Mlme.CntlMachine.CurrState = |
| 1013 | CNTL_WAIT_ASSOC; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1014 | } |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1015 | } else { |
| 1016 | if ((pAd->StaCfg.AuthMode == |
| 1017 | Ndis802_11AuthModeAutoSwitch) |
| 1018 | && (pAd->MlmeAux.Alg == Ndis802_11AuthModeShared)) { |
| 1019 | DBGPRINT(RT_DEBUG_TRACE, |
| 1020 | ("CNTL - AUTH FAIL, try OPEN system...\n")); |
| 1021 | AuthParmFill(pAd, &AuthReq, pAd->MlmeAux.Bssid, |
| 1022 | Ndis802_11AuthModeOpen); |
| 1023 | MlmeEnqueue(pAd, AUTH_STATE_MACHINE, |
| 1024 | MT2_MLME_AUTH_REQ, |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 1025 | sizeof(struct rt_mlme_auth_req), |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1026 | &AuthReq); |
| 1027 | |
| 1028 | pAd->Mlme.CntlMachine.CurrState = |
| 1029 | CNTL_WAIT_AUTH2; |
| 1030 | } else { |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1031 | /* not success, try next BSS */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1032 | DBGPRINT(RT_DEBUG_TRACE, |
| 1033 | ("CNTL - AUTH FAIL, give up; try next BSS\n")); |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1034 | pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE; /*??????? */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1035 | pAd->MlmeAux.BssIdx++; |
| 1036 | IterateOnBssTab(pAd); |
| 1037 | } |
| 1038 | } |
| 1039 | } |
| 1040 | } |
| 1041 | |
| 1042 | /* |
| 1043 | ========================================================================== |
| 1044 | Description: |
| 1045 | |
| 1046 | IRQL = DISPATCH_LEVEL |
| 1047 | |
| 1048 | ========================================================================== |
| 1049 | */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 1050 | void CntlWaitAssocProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1051 | { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1052 | u16 Reason; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1053 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1054 | if (Elem->MsgType == MT2_ASSOC_CONF) { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1055 | NdisMoveMemory(&Reason, Elem->Msg, sizeof(u16)); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1056 | if (Reason == MLME_SUCCESS) { |
| 1057 | if (pAd->CommonCfg.bWirelessEvent) { |
| 1058 | RTMPSendWirelessEvent(pAd, IW_ASSOC_EVENT_FLAG, |
| 1059 | pAd->MacTab. |
| 1060 | Content[BSSID_WCID].Addr, |
| 1061 | BSS0, 0); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1062 | } |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1063 | |
| 1064 | LinkUp(pAd, BSS_INFRA); |
| 1065 | pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1066 | DBGPRINT(RT_DEBUG_TRACE, |
| 1067 | ("CNTL - Association successful on BSS #%ld\n", |
| 1068 | pAd->MlmeAux.BssIdx)); |
| 1069 | } else { |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1070 | /* not success, try next BSS */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1071 | DBGPRINT(RT_DEBUG_TRACE, |
| 1072 | ("CNTL - Association fails on BSS #%ld\n", |
| 1073 | pAd->MlmeAux.BssIdx)); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1074 | pAd->MlmeAux.BssIdx++; |
| 1075 | IterateOnBssTab(pAd); |
| 1076 | } |
| 1077 | } |
| 1078 | } |
| 1079 | |
| 1080 | /* |
| 1081 | ========================================================================== |
| 1082 | Description: |
| 1083 | |
| 1084 | IRQL = DISPATCH_LEVEL |
| 1085 | |
| 1086 | ========================================================================== |
| 1087 | */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 1088 | void CntlWaitReassocProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1089 | { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1090 | u16 Result; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1091 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1092 | if (Elem->MsgType == MT2_REASSOC_CONF) { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1093 | NdisMoveMemory(&Result, Elem->Msg, sizeof(u16)); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1094 | if (Result == MLME_SUCCESS) { |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1095 | /* send wireless event - for association */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1096 | if (pAd->CommonCfg.bWirelessEvent) |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1097 | RTMPSendWirelessEvent(pAd, IW_ASSOC_EVENT_FLAG, |
| 1098 | pAd->MacTab. |
| 1099 | Content[BSSID_WCID].Addr, |
| 1100 | BSS0, 0); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1101 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1102 | /* */ |
| 1103 | /* NDIS requires a new Link UP indication but no Link Down for RE-ASSOC */ |
| 1104 | /* */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1105 | LinkUp(pAd, BSS_INFRA); |
| 1106 | |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1107 | pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1108 | DBGPRINT(RT_DEBUG_TRACE, |
| 1109 | ("CNTL - Re-assocition successful on BSS #%ld\n", |
| 1110 | pAd->MlmeAux.RoamIdx)); |
| 1111 | } else { |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1112 | /* reassoc failed, try to pick next BSS in the BSS Table */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1113 | DBGPRINT(RT_DEBUG_TRACE, |
| 1114 | ("CNTL - Re-assocition fails on BSS #%ld\n", |
| 1115 | pAd->MlmeAux.RoamIdx)); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1116 | { |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1117 | pAd->MlmeAux.RoamIdx++; |
| 1118 | IterateOnBssTab2(pAd); |
| 1119 | } |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1120 | } |
| 1121 | } |
| 1122 | } |
| 1123 | |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 1124 | void AdhocTurnOnQos(struct rt_rtmp_adapter *pAd) |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 1125 | { |
| 1126 | #define AC0_DEF_TXOP 0 |
| 1127 | #define AC1_DEF_TXOP 0 |
| 1128 | #define AC2_DEF_TXOP 94 |
| 1129 | #define AC3_DEF_TXOP 47 |
| 1130 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1131 | /* Turn on QOs if use HT rate. */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1132 | if (pAd->CommonCfg.APEdcaParm.bValid == FALSE) { |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 1133 | pAd->CommonCfg.APEdcaParm.bValid = TRUE; |
| 1134 | pAd->CommonCfg.APEdcaParm.Aifsn[0] = 3; |
| 1135 | pAd->CommonCfg.APEdcaParm.Aifsn[1] = 7; |
| 1136 | pAd->CommonCfg.APEdcaParm.Aifsn[2] = 1; |
| 1137 | pAd->CommonCfg.APEdcaParm.Aifsn[3] = 1; |
| 1138 | |
| 1139 | pAd->CommonCfg.APEdcaParm.Cwmin[0] = 4; |
| 1140 | pAd->CommonCfg.APEdcaParm.Cwmin[1] = 4; |
| 1141 | pAd->CommonCfg.APEdcaParm.Cwmin[2] = 3; |
| 1142 | pAd->CommonCfg.APEdcaParm.Cwmin[3] = 2; |
| 1143 | |
| 1144 | pAd->CommonCfg.APEdcaParm.Cwmax[0] = 10; |
| 1145 | pAd->CommonCfg.APEdcaParm.Cwmax[1] = 6; |
| 1146 | pAd->CommonCfg.APEdcaParm.Cwmax[2] = 4; |
| 1147 | pAd->CommonCfg.APEdcaParm.Cwmax[3] = 3; |
| 1148 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1149 | pAd->CommonCfg.APEdcaParm.Txop[0] = 0; |
| 1150 | pAd->CommonCfg.APEdcaParm.Txop[1] = 0; |
| 1151 | pAd->CommonCfg.APEdcaParm.Txop[2] = AC2_DEF_TXOP; |
| 1152 | pAd->CommonCfg.APEdcaParm.Txop[3] = AC3_DEF_TXOP; |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 1153 | } |
| 1154 | AsicSetEdcaParm(pAd, &pAd->CommonCfg.APEdcaParm); |
| 1155 | } |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 1156 | |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1157 | /* |
| 1158 | ========================================================================== |
| 1159 | Description: |
| 1160 | |
| 1161 | IRQL = DISPATCH_LEVEL |
| 1162 | |
| 1163 | ========================================================================== |
| 1164 | */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 1165 | void LinkUp(struct rt_rtmp_adapter *pAd, u8 BssType) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1166 | { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1167 | unsigned long Now; |
| 1168 | u32 Data; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1169 | BOOLEAN Cancelled; |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1170 | u8 Value = 0, idx = 0, HashIdx = 0; |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 1171 | struct rt_mac_table_entry *pEntry = NULL, *pCurrEntry = NULL; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1172 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1173 | /* Init ChannelQuality to prevent DEAD_CQI at initial LinkUp */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1174 | pAd->Mlme.ChannelQuality = 50; |
| 1175 | |
| 1176 | pEntry = MacTableLookup(pAd, pAd->CommonCfg.Bssid); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1177 | if (pEntry) { |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1178 | MacTableDeleteEntry(pAd, pEntry->Aid, pEntry->Addr); |
| 1179 | pEntry = NULL; |
Adam McDaniel | ed291e8 | 2009-02-23 08:01:07 -0700 | [diff] [blame] | 1180 | } |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1181 | |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1182 | pEntry = &pAd->MacTab.Content[BSSID_WCID]; |
| 1183 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1184 | /* */ |
| 1185 | /* ASSOC - DisassocTimeoutAction */ |
| 1186 | /* CNTL - Dis-associate successful */ |
| 1187 | /* !!! LINK DOWN !!! */ |
| 1188 | /* [88888] OID_802_11_SSID should have returned NDTEST_WEP_AP2(Returned: ) */ |
| 1189 | /* */ |
| 1190 | /* To prevent DisassocTimeoutAction to call Link down after we link up, */ |
| 1191 | /* cancel the DisassocTimer no matter what it start or not. */ |
| 1192 | /* */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1193 | RTMPCancelTimer(&pAd->MlmeAux.DisassocTimer, &Cancelled); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1194 | |
| 1195 | COPY_SETTINGS_FROM_MLME_AUX_TO_ACTIVE_CFG(pAd); |
| 1196 | |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1197 | COPY_HTSETTINGS_FROM_MLME_AUX_TO_ACTIVE_CFG(pAd); |
Bartlomiej Zolnierkiewicz | 1623267 | 2009-04-26 16:06:00 +0200 | [diff] [blame] | 1198 | |
Bartlomiej Zolnierkiewicz | e44fd1c | 2009-09-22 20:44:24 +0200 | [diff] [blame] | 1199 | #ifdef RTMP_MAC_PCI |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1200 | /* Before power save before link up function, We will force use 1R. */ |
| 1201 | /* So after link up, check Rx antenna # again. */ |
Bartlomiej Zolnierkiewicz | e44fd1c | 2009-09-22 20:44:24 +0200 | [diff] [blame] | 1202 | RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &Value); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1203 | if (pAd->Antenna.field.RxPath == 3) { |
Bartlomiej Zolnierkiewicz | e44fd1c | 2009-09-22 20:44:24 +0200 | [diff] [blame] | 1204 | Value |= (0x10); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1205 | } else if (pAd->Antenna.field.RxPath == 2) { |
Bartlomiej Zolnierkiewicz | e44fd1c | 2009-09-22 20:44:24 +0200 | [diff] [blame] | 1206 | Value |= (0x8); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1207 | } else if (pAd->Antenna.field.RxPath == 1) { |
Bartlomiej Zolnierkiewicz | e44fd1c | 2009-09-22 20:44:24 +0200 | [diff] [blame] | 1208 | Value |= (0x0); |
| 1209 | } |
| 1210 | RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, Value); |
| 1211 | pAd->StaCfg.BBPR3 = Value; |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1212 | #endif /* RTMP_MAC_PCI // */ |
Bartlomiej Zolnierkiewicz | e44fd1c | 2009-09-22 20:44:24 +0200 | [diff] [blame] | 1213 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1214 | if (BssType == BSS_ADHOC) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1215 | OPSTATUS_SET_FLAG(pAd, fOP_STATUS_ADHOC_ON); |
| 1216 | OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_INFRA_ON); |
| 1217 | |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 1218 | if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED) |
| 1219 | AdhocTurnOnQos(pAd); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1220 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1221 | DBGPRINT(RT_DEBUG_TRACE, ("!!!Adhoc LINK UP !!! \n")); |
| 1222 | } else { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1223 | OPSTATUS_SET_FLAG(pAd, fOP_STATUS_INFRA_ON); |
| 1224 | OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_ADHOC_ON); |
| 1225 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1226 | DBGPRINT(RT_DEBUG_TRACE, ("!!!Infra LINK UP !!! \n")); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1227 | } |
| 1228 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1229 | /* 3*3 */ |
| 1230 | /* reset Tx beamforming bit */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1231 | RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &Value); |
| 1232 | Value &= (~0x01); |
| 1233 | Value |= pAd->CommonCfg.RegTransmitSetting.field.TxBF; |
| 1234 | RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, Value); |
| 1235 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1236 | /* Change to AP channel */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1237 | if ((pAd->CommonCfg.CentralChannel > pAd->CommonCfg.Channel) |
| 1238 | && (pAd->MlmeAux.HtCapability.HtCapInfo.ChannelWidth == BW_40)) { |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1239 | /* Must using 40MHz. */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1240 | pAd->CommonCfg.BBPCurrentBW = BW_40; |
| 1241 | AsicSwitchChannel(pAd, pAd->CommonCfg.CentralChannel, FALSE); |
| 1242 | AsicLockChannel(pAd, pAd->CommonCfg.CentralChannel); |
| 1243 | |
| 1244 | RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &Value); |
| 1245 | Value &= (~0x18); |
| 1246 | Value |= 0x10; |
| 1247 | RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, Value); |
| 1248 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1249 | /* RX : control channel at lower */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1250 | RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &Value); |
| 1251 | Value &= (~0x20); |
| 1252 | RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, Value); |
Bartlomiej Zolnierkiewicz | e44fd1c | 2009-09-22 20:44:24 +0200 | [diff] [blame] | 1253 | #ifdef RTMP_MAC_PCI |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1254 | pAd->StaCfg.BBPR3 = Value; |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1255 | #endif /* RTMP_MAC_PCI // */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1256 | |
| 1257 | RTMP_IO_READ32(pAd, TX_BAND_CFG, &Data); |
| 1258 | Data &= 0xfffffffe; |
| 1259 | RTMP_IO_WRITE32(pAd, TX_BAND_CFG, Data); |
| 1260 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1261 | if (pAd->MACVersion == 0x28600100) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1262 | RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R69, 0x1A); |
| 1263 | RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R70, 0x0A); |
| 1264 | RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R73, 0x16); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1265 | DBGPRINT(RT_DEBUG_TRACE, ("!!!rt2860C !!! \n")); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1266 | } |
| 1267 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1268 | DBGPRINT(RT_DEBUG_TRACE, |
| 1269 | ("!!!40MHz Lower LINK UP !!! Control Channel at Below. Central = %d \n", |
| 1270 | pAd->CommonCfg.CentralChannel)); |
| 1271 | } else if ((pAd->CommonCfg.CentralChannel < pAd->CommonCfg.Channel) |
| 1272 | && (pAd->MlmeAux.HtCapability.HtCapInfo.ChannelWidth == |
| 1273 | BW_40)) { |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1274 | /* Must using 40MHz. */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1275 | pAd->CommonCfg.BBPCurrentBW = BW_40; |
| 1276 | AsicSwitchChannel(pAd, pAd->CommonCfg.CentralChannel, FALSE); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1277 | AsicLockChannel(pAd, pAd->CommonCfg.CentralChannel); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1278 | |
| 1279 | RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &Value); |
| 1280 | Value &= (~0x18); |
| 1281 | Value |= 0x10; |
| 1282 | RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, Value); |
| 1283 | |
| 1284 | RTMP_IO_READ32(pAd, TX_BAND_CFG, &Data); |
| 1285 | Data |= 0x1; |
| 1286 | RTMP_IO_WRITE32(pAd, TX_BAND_CFG, Data); |
| 1287 | |
| 1288 | RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &Value); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1289 | Value |= (0x20); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1290 | RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, Value); |
Bartlomiej Zolnierkiewicz | e44fd1c | 2009-09-22 20:44:24 +0200 | [diff] [blame] | 1291 | #ifdef RTMP_MAC_PCI |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1292 | pAd->StaCfg.BBPR3 = Value; |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1293 | #endif /* RTMP_MAC_PCI // */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1294 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1295 | if (pAd->MACVersion == 0x28600100) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1296 | RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R69, 0x1A); |
| 1297 | RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R70, 0x0A); |
| 1298 | RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R73, 0x16); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1299 | DBGPRINT(RT_DEBUG_TRACE, ("!!!rt2860C !!! \n")); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1300 | } |
| 1301 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1302 | DBGPRINT(RT_DEBUG_TRACE, |
| 1303 | ("!!! 40MHz Upper LINK UP !!! Control Channel at UpperCentral = %d \n", |
| 1304 | pAd->CommonCfg.CentralChannel)); |
| 1305 | } else { |
| 1306 | pAd->CommonCfg.BBPCurrentBW = BW_20; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1307 | pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel; |
| 1308 | AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE); |
| 1309 | AsicLockChannel(pAd, pAd->CommonCfg.Channel); |
| 1310 | |
| 1311 | RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &Value); |
| 1312 | Value &= (~0x18); |
| 1313 | RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, Value); |
| 1314 | |
| 1315 | RTMP_IO_READ32(pAd, TX_BAND_CFG, &Data); |
| 1316 | Data &= 0xfffffffe; |
| 1317 | RTMP_IO_WRITE32(pAd, TX_BAND_CFG, Data); |
| 1318 | |
| 1319 | RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &Value); |
| 1320 | Value &= (~0x20); |
| 1321 | RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, Value); |
Bartlomiej Zolnierkiewicz | e44fd1c | 2009-09-22 20:44:24 +0200 | [diff] [blame] | 1322 | #ifdef RTMP_MAC_PCI |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1323 | pAd->StaCfg.BBPR3 = Value; |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1324 | #endif /* RTMP_MAC_PCI // */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1325 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1326 | if (pAd->MACVersion == 0x28600100) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1327 | RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R69, 0x16); |
| 1328 | RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R70, 0x08); |
| 1329 | RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R73, 0x11); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1330 | DBGPRINT(RT_DEBUG_TRACE, ("!!!rt2860C !!! \n")); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1331 | } |
| 1332 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1333 | DBGPRINT(RT_DEBUG_TRACE, ("!!! 20MHz LINK UP !!! \n")); |
| 1334 | } |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1335 | |
| 1336 | RTMPSetAGCInitValue(pAd, pAd->CommonCfg.BBPCurrentBW); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1337 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1338 | /* */ |
| 1339 | /* Save BBP_R66 value, it will be used in RTUSBResumeMsduTransmission */ |
| 1340 | /* */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1341 | RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R66, |
| 1342 | &pAd->BbpTuning.R66CurrentValue); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1343 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1344 | DBGPRINT(RT_DEBUG_TRACE, |
| 1345 | ("!!! LINK UP !!! (BssType=%d, AID=%d, ssid=%s, Channel=%d, CentralChannel = %d)\n", |
| 1346 | BssType, pAd->StaActive.Aid, pAd->CommonCfg.Ssid, |
| 1347 | pAd->CommonCfg.Channel, pAd->CommonCfg.CentralChannel)); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1348 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1349 | DBGPRINT(RT_DEBUG_TRACE, |
| 1350 | ("!!! LINK UP !!! (Density =%d, )\n", |
| 1351 | pAd->MacTab.Content[BSSID_WCID].MpduDensity)); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1352 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1353 | AsicSetBssid(pAd, pAd->CommonCfg.Bssid); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1354 | |
| 1355 | AsicSetSlotTime(pAd, TRUE); |
| 1356 | AsicSetEdcaParm(pAd, &pAd->CommonCfg.APEdcaParm); |
| 1357 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1358 | /* Call this for RTS protectionfor legacy rate, we will always enable RTS threshold, but normally it will not hit */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1359 | AsicUpdateProtect(pAd, 0, (OFDMSETPROTECT | CCKSETPROTECT), TRUE, |
| 1360 | FALSE); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1361 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1362 | if ((pAd->StaActive.SupportedPhyInfo.bHtEnable == TRUE)) { |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1363 | /* Update HT protectionfor based on AP's operating mode. */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1364 | if (pAd->MlmeAux.AddHtInfo.AddHtInfo2.NonGfPresent == 1) { |
| 1365 | AsicUpdateProtect(pAd, |
| 1366 | pAd->MlmeAux.AddHtInfo.AddHtInfo2. |
| 1367 | OperaionMode, ALLN_SETPROTECT, FALSE, |
| 1368 | TRUE); |
| 1369 | } else |
| 1370 | AsicUpdateProtect(pAd, |
| 1371 | pAd->MlmeAux.AddHtInfo.AddHtInfo2. |
| 1372 | OperaionMode, ALLN_SETPROTECT, FALSE, |
| 1373 | FALSE); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1374 | } |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1375 | |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 1376 | NdisZeroMemory(&pAd->DrsCounters, sizeof(struct rt_counter_drs)); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1377 | |
| 1378 | NdisGetSystemUpTime(&Now); |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1379 | pAd->StaCfg.LastBeaconRxTime = Now; /* last RX timestamp */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1380 | |
| 1381 | if ((pAd->CommonCfg.TxPreamble != Rt802_11PreambleLong) && |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1382 | CAP_IS_SHORT_PREAMBLE_ON(pAd->StaActive.CapabilityInfo)) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1383 | MlmeSetTxPreamble(pAd, Rt802_11PreambleShort); |
| 1384 | } |
| 1385 | |
| 1386 | OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_AGGREGATION_INUSED); |
| 1387 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1388 | if (pAd->CommonCfg.RadarDetect.RDMode == RD_SILENCE_MODE) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1389 | } |
| 1390 | pAd->CommonCfg.RadarDetect.RDMode = RD_NORMAL_MODE; |
| 1391 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1392 | if (BssType == BSS_ADHOC) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1393 | MakeIbssBeacon(pAd); |
| 1394 | if ((pAd->CommonCfg.Channel > 14) |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1395 | && (pAd->CommonCfg.bIEEE80211H == 1) |
| 1396 | && RadarChannelCheck(pAd, pAd->CommonCfg.Channel)) { |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1397 | ; /*Do nothing */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1398 | } else { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1399 | AsicEnableIbssSync(pAd); |
| 1400 | } |
| 1401 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1402 | /* In ad hoc mode, use MAC table from index 1. */ |
| 1403 | /* p.s ASIC use all 0xff as termination of WCID table search.To prevent it's 0xff-ff-ff-ff-ff-ff, Write 0 here. */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1404 | RTMP_IO_WRITE32(pAd, MAC_WCID_BASE, 0x00); |
| 1405 | RTMP_IO_WRITE32(pAd, 0x1808, 0x00); |
| 1406 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1407 | /* If WEP is enabled, add key material and cipherAlg into Asic */ |
| 1408 | /* Fill in Shared Key Table(offset: 0x6c00) and Shared Key Mode(offset: 0x7000) */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1409 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1410 | if (pAd->StaCfg.WepStatus == Ndis802_11WEPEnabled) { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1411 | u8 *Key; |
| 1412 | u8 CipherAlg; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1413 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1414 | for (idx = 0; idx < SHARE_KEY_NUM; idx++) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1415 | CipherAlg = pAd->SharedKey[BSS0][idx].CipherAlg; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1416 | Key = pAd->SharedKey[BSS0][idx].Key; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1417 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1418 | if (pAd->SharedKey[BSS0][idx].KeyLen > 0) { |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1419 | /* Set key material and cipherAlg to Asic */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1420 | AsicAddSharedKeyEntry(pAd, BSS0, idx, |
| 1421 | CipherAlg, Key, |
| 1422 | NULL, NULL); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1423 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1424 | if (idx == pAd->StaCfg.DefaultKeyId) { |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1425 | /* Update WCID attribute table and IVEIV table for this group key table */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1426 | RTMPAddWcidAttributeEntry(pAd, |
| 1427 | BSS0, |
| 1428 | idx, |
| 1429 | CipherAlg, |
| 1430 | NULL); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1431 | } |
| 1432 | } |
| 1433 | |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1434 | } |
| 1435 | } |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1436 | /* If WPANone is enabled, add key material and cipherAlg into Asic */ |
| 1437 | /* Fill in Shared Key Table(offset: 0x6c00) and Shared Key Mode(offset: 0x7000) */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1438 | else if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone) { |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1439 | pAd->StaCfg.DefaultKeyId = 0; /* always be zero */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1440 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1441 | NdisZeroMemory(&pAd->SharedKey[BSS0][0], |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 1442 | sizeof(struct rt_cipher_key)); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1443 | pAd->SharedKey[BSS0][0].KeyLen = LEN_TKIP_EK; |
| 1444 | NdisMoveMemory(pAd->SharedKey[BSS0][0].Key, |
| 1445 | pAd->StaCfg.PMK, LEN_TKIP_EK); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1446 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1447 | if (pAd->StaCfg.PairCipher == |
| 1448 | Ndis802_11Encryption2Enabled) { |
| 1449 | NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, |
| 1450 | &pAd->StaCfg.PMK[16], |
| 1451 | LEN_TKIP_RXMICK); |
| 1452 | NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, |
| 1453 | &pAd->StaCfg.PMK[16], |
| 1454 | LEN_TKIP_TXMICK); |
| 1455 | } |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1456 | /* Decide its ChiperAlg */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1457 | if (pAd->StaCfg.PairCipher == |
| 1458 | Ndis802_11Encryption2Enabled) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1459 | pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_TKIP; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1460 | else if (pAd->StaCfg.PairCipher == |
| 1461 | Ndis802_11Encryption3Enabled) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1462 | pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_AES; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1463 | else { |
| 1464 | DBGPRINT(RT_DEBUG_TRACE, |
| 1465 | ("Unknow Cipher (=%d), set Cipher to AES\n", |
| 1466 | pAd->StaCfg.PairCipher)); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1467 | pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_AES; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1468 | } |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1469 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1470 | /* Set key material and cipherAlg to Asic */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1471 | AsicAddSharedKeyEntry(pAd, |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1472 | BSS0, |
| 1473 | 0, |
| 1474 | pAd->SharedKey[BSS0][0].CipherAlg, |
| 1475 | pAd->SharedKey[BSS0][0].Key, |
| 1476 | pAd->SharedKey[BSS0][0].TxMic, |
| 1477 | pAd->SharedKey[BSS0][0].RxMic); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1478 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1479 | /* Update WCID attribute table and IVEIV table for this group key table */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1480 | RTMPAddWcidAttributeEntry(pAd, BSS0, 0, |
| 1481 | pAd->SharedKey[BSS0][0]. |
| 1482 | CipherAlg, NULL); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1483 | |
| 1484 | } |
| 1485 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1486 | } else /* BSS_INFRA */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1487 | { |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1488 | /* Check the new SSID with last SSID */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1489 | while (Cancelled == TRUE) { |
| 1490 | if (pAd->CommonCfg.LastSsidLen == |
| 1491 | pAd->CommonCfg.SsidLen) { |
| 1492 | if (RTMPCompareMemory |
| 1493 | (pAd->CommonCfg.LastSsid, |
| 1494 | pAd->CommonCfg.Ssid, |
| 1495 | pAd->CommonCfg.LastSsidLen) == 0) { |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1496 | /* Link to the old one no linkdown is required. */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1497 | break; |
| 1498 | } |
| 1499 | } |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1500 | /* Send link down event before set to link up */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1501 | pAd->IndicateMediaState = NdisMediaStateDisconnected; |
| 1502 | RTMP_IndicateMediaState(pAd); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1503 | pAd->ExtraInfo = GENERAL_LINK_DOWN; |
| 1504 | DBGPRINT(RT_DEBUG_TRACE, |
| 1505 | ("NDIS_STATUS_MEDIA_DISCONNECT Event AA!\n")); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1506 | break; |
| 1507 | } |
| 1508 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1509 | /* */ |
| 1510 | /* On WPA mode, Remove All Keys if not connect to the last BSSID */ |
| 1511 | /* Key will be set after 4-way handshake. */ |
| 1512 | /* */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1513 | if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1514 | unsigned long IV; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1515 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1516 | /* Remove all WPA keys */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1517 | RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1518 | RTMPWPARemoveAllKeys(pAd); |
| 1519 | pAd->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1520 | pAd->StaCfg.PrivacyFilter = |
| 1521 | Ndis802_11PrivFilter8021xWEP; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1522 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1523 | /* Fixed connection failed with Range Maximizer - 515 AP (Marvell Chip) when security is WPAPSK/TKIP */ |
| 1524 | /* If IV related values are too large in GroupMsg2, AP would ignore this message. */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1525 | IV = 1; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1526 | IV |= (pAd->StaCfg.DefaultKeyId << 30); |
| 1527 | AsicUpdateWCIDIVEIV(pAd, BSSID_WCID, IV, 0); |
| 1528 | } |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1529 | /* NOTE: */ |
| 1530 | /* the decision of using "short slot time" or not may change dynamically due to */ |
| 1531 | /* new STA association to the AP. so we have to decide that upon parsing BEACON, not here */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1532 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1533 | /* NOTE: */ |
| 1534 | /* the decision to use "RTC/CTS" or "CTS-to-self" protection or not may change dynamically */ |
| 1535 | /* due to new STA association to the AP. so we have to decide that upon parsing BEACON, not here */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1536 | |
| 1537 | ComposePsPoll(pAd); |
| 1538 | ComposeNullFrame(pAd); |
| 1539 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1540 | AsicEnableBssSync(pAd); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1541 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1542 | /* Add BSSID to WCID search table */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1543 | AsicUpdateRxWCIDTable(pAd, BSSID_WCID, pAd->CommonCfg.Bssid); |
| 1544 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1545 | /* If WEP is enabled, add paiewise and shared key */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1546 | if (((pAd->StaCfg.WpaSupplicantUP) && |
| 1547 | (pAd->StaCfg.WepStatus == Ndis802_11WEPEnabled) && |
| 1548 | (pAd->StaCfg.PortSecured == WPA_802_1X_PORT_SECURED)) || |
| 1549 | ((pAd->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_DISABLE) && |
| 1550 | (pAd->StaCfg.WepStatus == Ndis802_11WEPEnabled))) { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1551 | u8 *Key; |
| 1552 | u8 CipherAlg; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1553 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1554 | for (idx = 0; idx < SHARE_KEY_NUM; idx++) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1555 | CipherAlg = pAd->SharedKey[BSS0][idx].CipherAlg; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1556 | Key = pAd->SharedKey[BSS0][idx].Key; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1557 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1558 | if (pAd->SharedKey[BSS0][idx].KeyLen > 0) { |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1559 | /* Set key material and cipherAlg to Asic */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1560 | AsicAddSharedKeyEntry(pAd, BSS0, idx, |
| 1561 | CipherAlg, Key, |
| 1562 | NULL, NULL); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1563 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1564 | if (idx == pAd->StaCfg.DefaultKeyId) { |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1565 | /* Assign group key info */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1566 | RTMPAddWcidAttributeEntry(pAd, |
| 1567 | BSS0, |
| 1568 | idx, |
| 1569 | CipherAlg, |
| 1570 | NULL); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1571 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1572 | pEntry->Aid = BSSID_WCID; |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1573 | /* Assign pairwise key info */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1574 | RTMPAddWcidAttributeEntry(pAd, |
| 1575 | BSS0, |
| 1576 | idx, |
| 1577 | CipherAlg, |
| 1578 | pEntry); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1579 | } |
| 1580 | } |
| 1581 | } |
| 1582 | } |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1583 | /* only INFRASTRUCTURE mode need to indicate connectivity immediately; ADHOC mode */ |
| 1584 | /* should wait until at least 2 active nodes in this BSSID. */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1585 | OPSTATUS_SET_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED); |
| 1586 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1587 | /* For GUI ++ */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1588 | if (pAd->StaCfg.AuthMode < Ndis802_11AuthModeWPA) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1589 | pAd->IndicateMediaState = NdisMediaStateConnected; |
| 1590 | pAd->ExtraInfo = GENERAL_LINK_UP; |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 1591 | RTMP_IndicateMediaState(pAd); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1592 | } else if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) || |
| 1593 | (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)) |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1594 | { |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1595 | if (pAd->StaCfg.WpaSupplicantUP == |
| 1596 | WPA_SUPPLICANT_DISABLE) |
| 1597 | RTMPSetTimer(&pAd->Mlme.LinkDownTimer, |
| 1598 | LINK_DOWN_TIMEOUT); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1599 | } |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1600 | /* -- */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1601 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1602 | /* Add BSSID in my MAC Table. */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1603 | NdisAcquireSpinLock(&pAd->MacTabLock); |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1604 | /* add this MAC entry into HASH table */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1605 | if (pEntry) { |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1606 | HashIdx = MAC_ADDR_HASH_INDEX(pAd->CommonCfg.Bssid); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1607 | if (pAd->MacTab.Hash[HashIdx] == NULL) { |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1608 | pAd->MacTab.Hash[HashIdx] = pEntry; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1609 | } else { |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1610 | pCurrEntry = pAd->MacTab.Hash[HashIdx]; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1611 | while (pCurrEntry->pNext != NULL) { |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1612 | pCurrEntry = pCurrEntry->pNext; |
| 1613 | } |
| 1614 | pCurrEntry->pNext = pEntry; |
| 1615 | } |
| 1616 | } |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1617 | RTMPMoveMemory(pEntry->Addr, pAd->CommonCfg.Bssid, |
| 1618 | MAC_ADDR_LEN); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1619 | pEntry->Aid = BSSID_WCID; |
| 1620 | pEntry->pAd = pAd; |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1621 | pEntry->ValidAsCLI = TRUE; /*Although this is bssid..still set ValidAsCl */ |
| 1622 | pAd->MacTab.Size = 1; /* infra mode always set MACtab size =1. */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1623 | pEntry->Sst = SST_ASSOC; |
| 1624 | pEntry->AuthState = SST_ASSOC; |
| 1625 | pEntry->AuthMode = pAd->StaCfg.AuthMode; |
| 1626 | pEntry->WepStatus = pAd->StaCfg.WepStatus; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1627 | if (pEntry->AuthMode < Ndis802_11AuthModeWPA) { |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1628 | pEntry->WpaState = AS_NOTUSE; |
| 1629 | pEntry->PrivacyFilter = Ndis802_11PrivFilterAcceptAll; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1630 | } else { |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1631 | pEntry->WpaState = AS_PTKSTART; |
| 1632 | pEntry->PrivacyFilter = Ndis802_11PrivFilter8021xWEP; |
| 1633 | } |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1634 | NdisReleaseSpinLock(&pAd->MacTabLock); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1635 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1636 | DBGPRINT(RT_DEBUG_TRACE, |
| 1637 | ("!!! LINK UP !!! ClientStatusFlags=%lx)\n", |
| 1638 | pAd->MacTab.Content[BSSID_WCID].ClientStatusFlags)); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1639 | |
| 1640 | MlmeUpdateTxRates(pAd, TRUE, BSS0); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1641 | MlmeUpdateHtTxRates(pAd, BSS0); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1642 | DBGPRINT(RT_DEBUG_TRACE, |
| 1643 | ("!!! LINK UP !! (StaActive.bHtEnable =%d, )\n", |
| 1644 | pAd->StaActive.SupportedPhyInfo.bHtEnable)); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1645 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1646 | if (pAd->CommonCfg.bAggregationCapable) { |
| 1647 | if ((pAd->CommonCfg.bPiggyBackCapable) |
| 1648 | && (pAd->MlmeAux.APRalinkIe & 0x00000003) == 3) { |
| 1649 | OPSTATUS_SET_FLAG(pAd, |
| 1650 | fOP_STATUS_PIGGYBACK_INUSED); |
| 1651 | OPSTATUS_SET_FLAG(pAd, |
| 1652 | fOP_STATUS_AGGREGATION_INUSED); |
| 1653 | CLIENT_STATUS_SET_FLAG(pEntry, |
| 1654 | fCLIENT_STATUS_AGGREGATION_CAPABLE); |
| 1655 | CLIENT_STATUS_SET_FLAG(pEntry, |
| 1656 | fCLIENT_STATUS_PIGGYBACK_CAPABLE); |
| 1657 | RTMPSetPiggyBack(pAd, TRUE); |
| 1658 | DBGPRINT(RT_DEBUG_TRACE, |
| 1659 | ("Turn on Piggy-Back\n")); |
| 1660 | } else if (pAd->MlmeAux.APRalinkIe & 0x00000001) { |
| 1661 | OPSTATUS_SET_FLAG(pAd, |
| 1662 | fOP_STATUS_AGGREGATION_INUSED); |
| 1663 | CLIENT_STATUS_SET_FLAG(pEntry, |
| 1664 | fCLIENT_STATUS_AGGREGATION_CAPABLE); |
| 1665 | DBGPRINT(RT_DEBUG_TRACE, |
| 1666 | ("Ralink Aggregation\n")); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1667 | } |
| 1668 | } |
| 1669 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1670 | if (pAd->MlmeAux.APRalinkIe != 0x0) { |
| 1671 | if (CLIENT_STATUS_TEST_FLAG |
| 1672 | (pEntry, fCLIENT_STATUS_RDG_CAPABLE)) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1673 | AsicEnableRDG(pAd); |
| 1674 | } |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1675 | OPSTATUS_SET_FLAG(pAd, fCLIENT_STATUS_RALINK_CHIPSET); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1676 | CLIENT_STATUS_SET_FLAG(pEntry, |
| 1677 | fCLIENT_STATUS_RALINK_CHIPSET); |
| 1678 | } else { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1679 | OPSTATUS_CLEAR_FLAG(pAd, fCLIENT_STATUS_RALINK_CHIPSET); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1680 | CLIENT_STATUS_CLEAR_FLAG(pEntry, |
| 1681 | fCLIENT_STATUS_RALINK_CHIPSET); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1682 | } |
| 1683 | } |
| 1684 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1685 | DBGPRINT(RT_DEBUG_TRACE, |
| 1686 | ("NDIS_STATUS_MEDIA_CONNECT Event B!.BACapability = %x. ClientStatusFlags = %lx\n", |
| 1687 | pAd->CommonCfg.BACapability.word, |
| 1688 | pAd->MacTab.Content[BSSID_WCID].ClientStatusFlags)); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1689 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1690 | /* Set LED */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1691 | RTMPSetLED(pAd, LED_LINK_UP); |
| 1692 | |
| 1693 | pAd->Mlme.PeriodicRound = 0; |
| 1694 | pAd->Mlme.OneSecPeriodicRound = 0; |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1695 | pAd->bConfigChanged = FALSE; /* Reset config flag */ |
| 1696 | pAd->ExtraInfo = GENERAL_LINK_UP; /* Update extra information to link is up */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1697 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1698 | /* Set asic auto fall back */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1699 | { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1700 | u8 *pTable; |
| 1701 | u8 TableSize = 0; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1702 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1703 | MlmeSelectTxRateTable(pAd, &pAd->MacTab.Content[BSSID_WCID], |
| 1704 | &pTable, &TableSize, |
| 1705 | &pAd->CommonCfg.TxRateIndex); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1706 | AsicUpdateAutoFallBackTable(pAd, pTable); |
| 1707 | } |
| 1708 | |
| 1709 | NdisAcquireSpinLock(&pAd->MacTabLock); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1710 | pEntry->HTPhyMode.word = pAd->StaCfg.HTPhyMode.word; |
| 1711 | pEntry->MaxHTPhyMode.word = pAd->StaCfg.HTPhyMode.word; |
| 1712 | if (pAd->StaCfg.bAutoTxRateSwitch == FALSE) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1713 | pEntry->bAutoTxRateSwitch = FALSE; |
Bartlomiej Zolnierkiewicz | 1623267 | 2009-04-26 16:06:00 +0200 | [diff] [blame] | 1714 | |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1715 | if (pEntry->HTPhyMode.field.MCS == 32) |
| 1716 | pEntry->HTPhyMode.field.ShortGI = GI_800; |
| 1717 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1718 | if ((pEntry->HTPhyMode.field.MCS > MCS_7) |
| 1719 | || (pEntry->HTPhyMode.field.MCS == 32)) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1720 | pEntry->HTPhyMode.field.STBC = STBC_NONE; |
Bartlomiej Zolnierkiewicz | 1623267 | 2009-04-26 16:06:00 +0200 | [diff] [blame] | 1721 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1722 | /* If the legacy mode is set, overwrite the transmit setting of this entry. */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1723 | if (pEntry->HTPhyMode.field.MODE <= MODE_OFDM) |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1724 | RTMPUpdateLegacyTxSetting((u8)pAd->StaCfg. |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1725 | DesiredTransmitSetting.field. |
| 1726 | FixedTxMode, pEntry); |
| 1727 | } else |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1728 | pEntry->bAutoTxRateSwitch = TRUE; |
| 1729 | NdisReleaseSpinLock(&pAd->MacTabLock); |
| 1730 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1731 | /* Let Link Status Page display first initial rate. */ |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1732 | pAd->LastTxRate = (u16)(pEntry->HTPhyMode.word); |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1733 | /* Select DAC according to HT or Legacy */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1734 | if (pAd->StaActive.SupportedPhyInfo.MCSSet[0] != 0x00) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1735 | RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R1, &Value); |
| 1736 | Value &= (~0x18); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1737 | if (pAd->Antenna.field.TxPath == 2) { |
| 1738 | Value |= 0x10; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1739 | } |
| 1740 | RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R1, Value); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1741 | } else { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1742 | RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R1, &Value); |
| 1743 | Value &= (~0x18); |
| 1744 | RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R1, Value); |
| 1745 | } |
| 1746 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1747 | if (pAd->StaActive.SupportedPhyInfo.bHtEnable == FALSE) { |
| 1748 | } else if (pEntry->MaxRAmpduFactor == 0) { |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1749 | /* If HT AP doesn't support MaxRAmpduFactor = 1, we need to set max PSDU to 0. */ |
| 1750 | /* Because our Init value is 1 at MACRegTable. */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1751 | RTMP_IO_WRITE32(pAd, MAX_LEN_CFG, 0x0fff); |
| 1752 | } |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1753 | /* Patch for Marvel AP to gain high throughput */ |
| 1754 | /* Need to set as following, */ |
| 1755 | /* 1. Set txop in register-EDCA_AC0_CFG as 0x60 */ |
| 1756 | /* 2. Set EnTXWriteBackDDONE in register-WPDMA_GLO_CFG as zero */ |
| 1757 | /* 3. PBF_MAX_PCNT as 0x1F3FBF9F */ |
| 1758 | /* 4. kick per two packets when dequeue */ |
| 1759 | /* */ |
| 1760 | /* Txop can only be modified when RDG is off, WMM is disable and TxBurst is enable */ |
| 1761 | /* */ |
| 1762 | /* if 1. Legacy AP WMM on, or 2. 11n AP, AMPDU disable. Force turn off burst no matter what bEnableTxBurst is. */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1763 | if (!((pAd->CommonCfg.RxStream == 1) && (pAd->CommonCfg.TxStream == 1)) |
| 1764 | && (pAd->StaCfg.bForceTxBurst == FALSE) |
| 1765 | && |
| 1766 | (((pAd->StaActive.SupportedPhyInfo.bHtEnable == FALSE) |
| 1767 | && OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_WMM_INUSED)) |
| 1768 | || ((pAd->StaActive.SupportedPhyInfo.bHtEnable == TRUE) |
| 1769 | && (pAd->CommonCfg.BACapability.field.Policy == BA_NOTUSE)))) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1770 | RTMP_IO_READ32(pAd, EDCA_AC0_CFG, &Data); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1771 | Data &= 0xFFFFFF00; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1772 | RTMP_IO_WRITE32(pAd, EDCA_AC0_CFG, Data); |
| 1773 | |
| 1774 | RTMP_IO_WRITE32(pAd, PBF_MAX_PCNT, 0x1F3F7F9F); |
| 1775 | DBGPRINT(RT_DEBUG_TRACE, ("Txburst 1\n")); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1776 | } else if (pAd->CommonCfg.bEnableTxBurst) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1777 | RTMP_IO_READ32(pAd, EDCA_AC0_CFG, &Data); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1778 | Data &= 0xFFFFFF00; |
| 1779 | Data |= 0x60; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1780 | RTMP_IO_WRITE32(pAd, EDCA_AC0_CFG, Data); |
| 1781 | pAd->CommonCfg.IOTestParm.bNowAtherosBurstOn = TRUE; |
| 1782 | |
| 1783 | RTMP_IO_WRITE32(pAd, PBF_MAX_PCNT, 0x1F3FBF9F); |
| 1784 | DBGPRINT(RT_DEBUG_TRACE, ("Txburst 2\n")); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1785 | } else { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1786 | RTMP_IO_READ32(pAd, EDCA_AC0_CFG, &Data); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1787 | Data &= 0xFFFFFF00; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1788 | RTMP_IO_WRITE32(pAd, EDCA_AC0_CFG, Data); |
| 1789 | |
| 1790 | RTMP_IO_WRITE32(pAd, PBF_MAX_PCNT, 0x1F3F7F9F); |
| 1791 | DBGPRINT(RT_DEBUG_TRACE, ("Txburst 3\n")); |
| 1792 | } |
| 1793 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1794 | /* Re-check to turn on TX burst or not. */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1795 | if ((pAd->CommonCfg.IOTestParm.bLastAtheros == TRUE) |
| 1796 | && ((STA_WEP_ON(pAd)) || (STA_TKIP_ON(pAd)))) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1797 | pAd->CommonCfg.IOTestParm.bNextDisableRxBA = TRUE; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1798 | if (pAd->CommonCfg.bEnableTxBurst) { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1799 | u32 MACValue = 0; |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1800 | /* Force disable TXOP value in this case. The same action in MLMEUpdateProtect too. */ |
| 1801 | /* I didn't change PBF_MAX_PCNT setting. */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1802 | RTMP_IO_READ32(pAd, EDCA_AC0_CFG, &MACValue); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1803 | MACValue &= 0xFFFFFF00; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1804 | RTMP_IO_WRITE32(pAd, EDCA_AC0_CFG, MACValue); |
| 1805 | pAd->CommonCfg.IOTestParm.bNowAtherosBurstOn = FALSE; |
| 1806 | } |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1807 | } else { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1808 | pAd->CommonCfg.IOTestParm.bNextDisableRxBA = FALSE; |
| 1809 | } |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1810 | |
| 1811 | pAd->CommonCfg.IOTestParm.bLastAtheros = FALSE; |
| 1812 | COPY_MAC_ADDR(pAd->CommonCfg.LastBssid, pAd->CommonCfg.Bssid); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1813 | DBGPRINT(RT_DEBUG_TRACE, |
| 1814 | ("!!!pAd->bNextDisableRxBA= %d \n", |
| 1815 | pAd->CommonCfg.IOTestParm.bNextDisableRxBA)); |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1816 | /* BSSID add in one MAC entry too. Because in Tx, ASIC need to check Cipher and IV/EIV, BAbitmap */ |
| 1817 | /* Pther information in MACTab.Content[BSSID_WCID] is not necessary for driver. */ |
| 1818 | /* Note: As STA, The MACTab.Content[BSSID_WCID]. PairwiseKey and Shared Key for BSS0 are the same. */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1819 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1820 | if (pAd->StaCfg.WepStatus <= Ndis802_11WEPDisabled) { |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1821 | if (pAd->StaCfg.WpaSupplicantUP && |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1822 | (pAd->StaCfg.WepStatus == Ndis802_11WEPEnabled) && |
| 1823 | (pAd->StaCfg.IEEE8021X == TRUE)) ; |
| 1824 | else { |
| 1825 | pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED; |
| 1826 | pAd->StaCfg.PrivacyFilter = |
| 1827 | Ndis802_11PrivFilterAcceptAll; |
| 1828 | } |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1829 | } |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1830 | |
| 1831 | NdisAcquireSpinLock(&pAd->MacTabLock); |
| 1832 | pEntry->PortSecured = pAd->StaCfg.PortSecured; |
| 1833 | NdisReleaseSpinLock(&pAd->MacTabLock); |
| 1834 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1835 | /* */ |
| 1836 | /* Patch Atheros AP TX will breakdown issue. */ |
| 1837 | /* AP Model: DLink DWL-8200AP */ |
| 1838 | /* */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1839 | if (INFRA_ON(pAd) && OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_WMM_INUSED) |
| 1840 | && STA_TKIP_ON(pAd)) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1841 | RTMP_IO_WRITE32(pAd, RX_PARSER_CFG, 0x01); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1842 | } else { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1843 | RTMP_IO_WRITE32(pAd, RX_PARSER_CFG, 0x00); |
| 1844 | } |
| 1845 | |
| 1846 | RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1847 | |
Adam McDaniel | ed291e8 | 2009-02-23 08:01:07 -0700 | [diff] [blame] | 1848 | RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_GO_TO_SLEEP_NOW); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1849 | } |
| 1850 | |
| 1851 | /* |
| 1852 | ========================================================================== |
| 1853 | |
| 1854 | Routine Description: |
| 1855 | Disconnect current BSSID |
| 1856 | |
| 1857 | Arguments: |
| 1858 | pAd - Pointer to our adapter |
| 1859 | IsReqFromAP - Request from AP |
| 1860 | |
| 1861 | Return Value: |
| 1862 | None |
| 1863 | |
| 1864 | IRQL = DISPATCH_LEVEL |
| 1865 | |
| 1866 | Note: |
| 1867 | We need more information to know it's this requst from AP. |
| 1868 | If yes! we need to do extra handling, for example, remove the WPA key. |
| 1869 | Otherwise on 4-way handshaking will faied, since the WPA key didn't be |
| 1870 | remove while auto reconnect. |
| 1871 | Disconnect request from AP, it means we will start afresh 4-way handshaking |
| 1872 | on WPA mode. |
| 1873 | |
| 1874 | ========================================================================== |
| 1875 | */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 1876 | void LinkDown(struct rt_rtmp_adapter *pAd, IN BOOLEAN IsReqFromAP) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1877 | { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1878 | u8 i, ByteValue = 0; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1879 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1880 | /* Do nothing if monitor mode is on */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1881 | if (MONITOR_ON(pAd)) |
| 1882 | return; |
| 1883 | |
Adam McDaniel | ed291e8 | 2009-02-23 08:01:07 -0700 | [diff] [blame] | 1884 | RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_GO_TO_SLEEP_NOW); |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1885 | /*Comment the codes, beasue the line 2291 call the same function. */ |
| 1886 | /*RTMPCancelTimer(&pAd->Mlme.PsPollTimer, &Cancelled); */ |
| 1887 | /* Not allow go to sleep within linkdown function. */ |
Adam McDaniel | ed291e8 | 2009-02-23 08:01:07 -0700 | [diff] [blame] | 1888 | RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP); |
| 1889 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1890 | if (pAd->CommonCfg.bWirelessEvent) { |
| 1891 | RTMPSendWirelessEvent(pAd, IW_STA_LINKDOWN_EVENT_FLAG, |
| 1892 | pAd->MacTab.Content[BSSID_WCID].Addr, |
| 1893 | BSS0, 0); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1894 | } |
| 1895 | |
| 1896 | DBGPRINT(RT_DEBUG_TRACE, ("!!! LINK DOWN !!!\n")); |
| 1897 | OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_AGGREGATION_INUSED); |
| 1898 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1899 | #ifdef RTMP_MAC_PCI |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1900 | if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE)) { |
| 1901 | BOOLEAN Cancelled; |
| 1902 | pAd->Mlme.bPsPollTimerRunning = FALSE; |
| 1903 | RTMPCancelTimer(&pAd->Mlme.PsPollTimer, &Cancelled); |
| 1904 | } |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1905 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1906 | pAd->bPCIclkOff = FALSE; |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1907 | #endif /* RTMP_MAC_PCI // */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1908 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1909 | if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE) |
| 1910 | || RTMP_TEST_PSFLAG(pAd, fRTMP_PS_SET_PCI_CLK_OFF_COMMAND) |
| 1911 | || RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_IDLE_RADIO_OFF)) { |
| 1912 | AUTO_WAKEUP_STRUC AutoWakeupCfg; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1913 | AsicForceWakeup(pAd, TRUE); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1914 | AutoWakeupCfg.word = 0; |
| 1915 | RTMP_IO_WRITE32(pAd, AUTO_WAKEUP_CFG, AutoWakeupCfg.word); |
| 1916 | OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_DOZE); |
| 1917 | } |
Bartlomiej Zolnierkiewicz | e44fd1c | 2009-09-22 20:44:24 +0200 | [diff] [blame] | 1918 | #ifdef RTMP_MAC_PCI |
| 1919 | pAd->bPCIclkOff = FALSE; |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1920 | #endif /* RTMP_MAC_PCI // */ |
Bartlomiej Zolnierkiewicz | e44fd1c | 2009-09-22 20:44:24 +0200 | [diff] [blame] | 1921 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1922 | if (ADHOC_ON(pAd)) /* Adhoc mode link down */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1923 | { |
| 1924 | DBGPRINT(RT_DEBUG_TRACE, ("!!! LINK DOWN 1!!!\n")); |
| 1925 | |
| 1926 | OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_ADHOC_ON); |
| 1927 | OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED); |
| 1928 | pAd->IndicateMediaState = NdisMediaStateDisconnected; |
| 1929 | RTMP_IndicateMediaState(pAd); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1930 | pAd->ExtraInfo = GENERAL_LINK_DOWN; |
| 1931 | BssTableDeleteEntry(&pAd->ScanTab, pAd->CommonCfg.Bssid, |
| 1932 | pAd->CommonCfg.Channel); |
| 1933 | DBGPRINT(RT_DEBUG_TRACE, |
| 1934 | ("!!! MacTab.Size=%d !!!\n", pAd->MacTab.Size)); |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1935 | } else /* Infra structure mode */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1936 | { |
| 1937 | DBGPRINT(RT_DEBUG_TRACE, ("!!! LINK DOWN 2!!!\n")); |
| 1938 | |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1939 | OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_INFRA_ON); |
| 1940 | OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED); |
| 1941 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1942 | /* Saved last SSID for linkup comparison */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1943 | pAd->CommonCfg.LastSsidLen = pAd->CommonCfg.SsidLen; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1944 | NdisMoveMemory(pAd->CommonCfg.LastSsid, pAd->CommonCfg.Ssid, |
| 1945 | pAd->CommonCfg.LastSsidLen); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1946 | COPY_MAC_ADDR(pAd->CommonCfg.LastBssid, pAd->CommonCfg.Bssid); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1947 | if (pAd->MlmeAux.CurrReqIsFromNdis == TRUE) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1948 | pAd->IndicateMediaState = NdisMediaStateDisconnected; |
| 1949 | RTMP_IndicateMediaState(pAd); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1950 | pAd->ExtraInfo = GENERAL_LINK_DOWN; |
| 1951 | DBGPRINT(RT_DEBUG_TRACE, |
| 1952 | ("NDIS_STATUS_MEDIA_DISCONNECT Event A!\n")); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1953 | pAd->MlmeAux.CurrReqIsFromNdis = FALSE; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1954 | } else { |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1955 | /* */ |
| 1956 | /* If disassociation request is from NDIS, then we don't need to delete BSSID from entry. */ |
| 1957 | /* Otherwise lost beacon or receive De-Authentication from AP, */ |
| 1958 | /* then we should delete BSSID from BssTable. */ |
| 1959 | /* If we don't delete from entry, roaming will fail. */ |
| 1960 | /* */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1961 | BssTableDeleteEntry(&pAd->ScanTab, pAd->CommonCfg.Bssid, |
| 1962 | pAd->CommonCfg.Channel); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1963 | } |
| 1964 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1965 | /* restore back to - */ |
| 1966 | /* 1. long slot (20 us) or short slot (9 us) time */ |
| 1967 | /* 2. turn on/off RTS/CTS and/or CTS-to-self protection */ |
| 1968 | /* 3. short preamble */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1969 | OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_BG_PROTECTION_INUSED); |
| 1970 | |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1971 | } |
| 1972 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1973 | for (i = 1; i < MAX_LEN_OF_MAC_TABLE; i++) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1974 | if (pAd->MacTab.Content[i].ValidAsCLI == TRUE) |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1975 | MacTableDeleteEntry(pAd, pAd->MacTab.Content[i].Aid, |
| 1976 | pAd->MacTab.Content[i].Addr); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1977 | } |
| 1978 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1979 | AsicSetSlotTime(pAd, TRUE); /*FALSE); */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1980 | AsicSetEdcaParm(pAd, NULL); |
| 1981 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1982 | /* Set LED */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1983 | RTMPSetLED(pAd, LED_LINK_DOWN); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1984 | pAd->LedIndicatorStrength = 0xF0; |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1985 | RTMPSetSignalLED(pAd, -100); /* Force signal strength Led to be turned off, firmware is not done it. */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1986 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1987 | AsicDisableSync(pAd); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1988 | |
| 1989 | pAd->Mlme.PeriodicRound = 0; |
| 1990 | pAd->Mlme.OneSecPeriodicRound = 0; |
| 1991 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 1992 | if (pAd->StaCfg.BssType == BSS_INFRA) { |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1993 | /* Remove StaCfg Information after link down */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1994 | NdisZeroMemory(pAd->CommonCfg.Bssid, MAC_ADDR_LEN); |
| 1995 | NdisZeroMemory(pAd->CommonCfg.Ssid, MAX_LEN_OF_SSID); |
| 1996 | pAd->CommonCfg.SsidLen = 0; |
| 1997 | } |
Bartlomiej Zolnierkiewicz | 1623267 | 2009-04-26 16:06:00 +0200 | [diff] [blame] | 1998 | |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 1999 | NdisZeroMemory(&pAd->MlmeAux.HtCapability, sizeof(struct rt_ht_capability_ie)); |
| 2000 | NdisZeroMemory(&pAd->MlmeAux.AddHtInfo, sizeof(struct rt_add_ht_info_ie)); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2001 | pAd->MlmeAux.HtCapabilityLen = 0; |
| 2002 | pAd->MlmeAux.NewExtChannelOffset = 0xff; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2003 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2004 | /* Reset WPA-PSK state. Only reset when supplicant enabled */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 2005 | if (pAd->StaCfg.WpaState != SS_NOTUSE) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2006 | pAd->StaCfg.WpaState = SS_START; |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2007 | /* Clear Replay counter */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2008 | NdisZeroMemory(pAd->StaCfg.ReplayCounter, 8); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2009 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 2010 | } |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2011 | /* */ |
| 2012 | /* if link down come from AP, we need to remove all WPA keys on WPA mode. */ |
| 2013 | /* otherwise will cause 4-way handshaking failed, since the WPA key not empty. */ |
| 2014 | /* */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 2015 | if ((IsReqFromAP) && (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)) { |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2016 | /* Remove all WPA keys */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2017 | RTMPWPARemoveAllKeys(pAd); |
| 2018 | } |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2019 | /* 802.1x port control */ |
Bartlomiej Zolnierkiewicz | e08bae5 | 2009-04-26 16:05:56 +0200 | [diff] [blame] | 2020 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2021 | /* Prevent clear PortSecured here with static WEP */ |
| 2022 | /* NetworkManger set security policy first then set SSID to connect AP. */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2023 | if (pAd->StaCfg.WpaSupplicantUP && |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 2024 | (pAd->StaCfg.WepStatus == Ndis802_11WEPEnabled) && |
| 2025 | (pAd->StaCfg.IEEE8021X == FALSE)) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2026 | pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 2027 | } else { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2028 | pAd->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED; |
| 2029 | pAd->StaCfg.PrivacyFilter = Ndis802_11PrivFilter8021xWEP; |
| 2030 | } |
| 2031 | |
| 2032 | NdisAcquireSpinLock(&pAd->MacTabLock); |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 2033 | NdisZeroMemory(&pAd->MacTab, sizeof(struct rt_mac_table)); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2034 | pAd->MacTab.Content[BSSID_WCID].PortSecured = pAd->StaCfg.PortSecured; |
| 2035 | NdisReleaseSpinLock(&pAd->MacTabLock); |
| 2036 | |
| 2037 | pAd->StaCfg.MicErrCnt = 0; |
| 2038 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 2039 | pAd->IndicateMediaState = NdisMediaStateDisconnected; |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2040 | /* Update extra information to link is up */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2041 | pAd->ExtraInfo = GENERAL_LINK_DOWN; |
| 2042 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 2043 | pAd->StaActive.SupportedPhyInfo.bHtEnable = FALSE; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2044 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 2045 | #ifdef RTMP_MAC_USB |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 2046 | pAd->bUsbTxBulkAggre = FALSE; |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2047 | #endif /* RTMP_MAC_USB // */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2048 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2049 | /* Clean association information */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 2050 | NdisZeroMemory(&pAd->StaCfg.AssocInfo, |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 2051 | sizeof(struct rt_ndis_802_11_association_information)); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 2052 | pAd->StaCfg.AssocInfo.Length = |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 2053 | sizeof(struct rt_ndis_802_11_association_information); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2054 | pAd->StaCfg.ReqVarIELen = 0; |
| 2055 | pAd->StaCfg.ResVarIELen = 0; |
| 2056 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2057 | /* */ |
| 2058 | /* Reset RSSI value after link down */ |
| 2059 | /* */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2060 | pAd->StaCfg.RssiSample.AvgRssi0 = 0; |
| 2061 | pAd->StaCfg.RssiSample.AvgRssi0X8 = 0; |
| 2062 | pAd->StaCfg.RssiSample.AvgRssi1 = 0; |
| 2063 | pAd->StaCfg.RssiSample.AvgRssi1X8 = 0; |
| 2064 | pAd->StaCfg.RssiSample.AvgRssi2 = 0; |
| 2065 | pAd->StaCfg.RssiSample.AvgRssi2X8 = 0; |
| 2066 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2067 | /* Restore MlmeRate */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2068 | pAd->CommonCfg.MlmeRate = pAd->CommonCfg.BasicMlmeRate; |
| 2069 | pAd->CommonCfg.RtsRate = pAd->CommonCfg.BasicMlmeRate; |
| 2070 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2071 | /* */ |
| 2072 | /* After Link down, reset piggy-back setting in ASIC. Disable RDG. */ |
| 2073 | /* */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 2074 | if (pAd->CommonCfg.BBPCurrentBW == BW_40) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2075 | pAd->CommonCfg.BBPCurrentBW = BW_20; |
| 2076 | RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &ByteValue); |
| 2077 | ByteValue &= (~0x18); |
| 2078 | RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, ByteValue); |
| 2079 | } |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2080 | /* Reset DAC */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2081 | RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R1, &ByteValue); |
| 2082 | ByteValue &= (~0x18); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 2083 | if (pAd->Antenna.field.TxPath == 2) { |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2084 | ByteValue |= 0x10; |
| 2085 | } |
| 2086 | RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R1, ByteValue); |
| 2087 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 2088 | RTMPSetPiggyBack(pAd, FALSE); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2089 | OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_PIGGYBACK_INUSED); |
| 2090 | |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2091 | pAd->CommonCfg.BACapability.word = pAd->CommonCfg.REGBACapability.word; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2092 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2093 | /* Restore all settings in the following. */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 2094 | AsicUpdateProtect(pAd, 0, |
| 2095 | (ALLN_SETPROTECT | CCKSETPROTECT | OFDMSETPROTECT), |
| 2096 | TRUE, FALSE); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2097 | AsicDisableRDG(pAd); |
| 2098 | pAd->CommonCfg.IOTestParm.bCurrentAtheros = FALSE; |
| 2099 | pAd->CommonCfg.IOTestParm.bNowAtherosBurstOn = FALSE; |
| 2100 | |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2101 | RTMP_IO_WRITE32(pAd, MAX_LEN_CFG, 0x1fff); |
| 2102 | RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS); |
| 2103 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2104 | /* Allow go to sleep after linkdown steps. */ |
Adam McDaniel | ed291e8 | 2009-02-23 08:01:07 -0700 | [diff] [blame] | 2105 | RTMP_SET_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP); |
| 2106 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 2107 | RtmpOSWrielessEventSend(pAd, SIOCGIWAP, -1, NULL, NULL, 0); |
| 2108 | |
| 2109 | #ifdef RT30xx |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 2110 | if ((IS_RT30xx(pAd) || IS_RT3090(pAd) || IS_RT3390(pAd)) |
| 2111 | && (pAd->Antenna.field.RxPath > 1 || pAd->Antenna.field.TxPath > 1)) { |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 2112 | RTMP_ASIC_MMPS_DISABLE(pAd); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2113 | } |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2114 | #endif /* RT30xx // */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2115 | } |
| 2116 | |
| 2117 | /* |
| 2118 | ========================================================================== |
| 2119 | Description: |
| 2120 | |
| 2121 | IRQL = DISPATCH_LEVEL |
| 2122 | |
| 2123 | ========================================================================== |
| 2124 | */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 2125 | void IterateOnBssTab(struct rt_rtmp_adapter *pAd) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2126 | { |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 2127 | struct rt_mlme_start_req StartReq; |
| 2128 | struct rt_mlme_join_req JoinReq; |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2129 | unsigned long BssIdx; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2130 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2131 | /* Change the wepstatus to original wepstatus */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 2132 | pAd->StaCfg.WepStatus = pAd->StaCfg.OrigWepStatus; |
| 2133 | pAd->StaCfg.PairCipher = pAd->StaCfg.OrigWepStatus; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2134 | pAd->StaCfg.GroupCipher = pAd->StaCfg.OrigWepStatus; |
| 2135 | |
| 2136 | BssIdx = pAd->MlmeAux.BssIdx; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 2137 | if (BssIdx < pAd->MlmeAux.SsidBssTab.BssNr) { |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2138 | /* Check cipher suite, AP must have more secured cipher than station setting */ |
| 2139 | /* Set the Pairwise and Group cipher to match the intended AP setting */ |
| 2140 | /* We can only connect to AP with less secured cipher setting */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 2141 | if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA) |
| 2142 | || (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)) { |
| 2143 | pAd->StaCfg.GroupCipher = |
| 2144 | pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx].WPA. |
| 2145 | GroupCipher; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2146 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 2147 | if (pAd->StaCfg.WepStatus == |
| 2148 | pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx].WPA. |
| 2149 | PairCipher) |
| 2150 | pAd->StaCfg.PairCipher = |
| 2151 | pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx]. |
| 2152 | WPA.PairCipher; |
| 2153 | else if (pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx].WPA. |
| 2154 | PairCipherAux != Ndis802_11WEPDisabled) |
| 2155 | pAd->StaCfg.PairCipher = |
| 2156 | pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx]. |
| 2157 | WPA.PairCipherAux; |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2158 | else /* There is no PairCipher Aux, downgrade our capability to TKIP */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 2159 | pAd->StaCfg.PairCipher = |
| 2160 | Ndis802_11Encryption2Enabled; |
| 2161 | } else if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) |
| 2162 | || (pAd->StaCfg.AuthMode == |
| 2163 | Ndis802_11AuthModeWPA2PSK)) { |
| 2164 | pAd->StaCfg.GroupCipher = |
| 2165 | pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx].WPA2. |
| 2166 | GroupCipher; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2167 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 2168 | if (pAd->StaCfg.WepStatus == |
| 2169 | pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx].WPA2. |
| 2170 | PairCipher) |
| 2171 | pAd->StaCfg.PairCipher = |
| 2172 | pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx]. |
| 2173 | WPA2.PairCipher; |
| 2174 | else if (pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx].WPA2. |
| 2175 | PairCipherAux != Ndis802_11WEPDisabled) |
| 2176 | pAd->StaCfg.PairCipher = |
| 2177 | pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx]. |
| 2178 | WPA2.PairCipherAux; |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2179 | else /* There is no PairCipher Aux, downgrade our capability to TKIP */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 2180 | pAd->StaCfg.PairCipher = |
| 2181 | Ndis802_11Encryption2Enabled; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2182 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2183 | /* RSN capability */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 2184 | pAd->StaCfg.RsnCapability = |
| 2185 | pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx].WPA2. |
| 2186 | RsnCapability; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2187 | } |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2188 | /* Set Mix cipher flag */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 2189 | pAd->StaCfg.bMixCipher = |
| 2190 | (pAd->StaCfg.PairCipher == |
| 2191 | pAd->StaCfg.GroupCipher) ? FALSE : TRUE; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 2192 | /*if (pAd->StaCfg.bMixCipher == TRUE) |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 2193 | { |
| 2194 | // If mix cipher, re-build RSNIE |
| 2195 | RTMPMakeRSNIE(pAd, pAd->StaCfg.AuthMode, pAd->StaCfg.WepStatus, 0); |
| 2196 | } */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2197 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 2198 | DBGPRINT(RT_DEBUG_TRACE, |
| 2199 | ("CNTL - iterate BSS %ld of %d\n", BssIdx, |
| 2200 | pAd->MlmeAux.SsidBssTab.BssNr)); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2201 | JoinParmFill(pAd, &JoinReq, BssIdx); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 2202 | MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_MLME_JOIN_REQ, |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 2203 | sizeof(struct rt_mlme_join_req), &JoinReq); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2204 | pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_JOIN; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 2205 | } else if (pAd->StaCfg.BssType == BSS_ADHOC) { |
| 2206 | DBGPRINT(RT_DEBUG_TRACE, |
| 2207 | ("CNTL - All BSS fail; start a new ADHOC (Ssid=%s)...\n", |
| 2208 | pAd->MlmeAux.Ssid)); |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2209 | StartParmFill(pAd, &StartReq, (char *)pAd->MlmeAux.Ssid, |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 2210 | pAd->MlmeAux.SsidLen); |
| 2211 | MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_MLME_START_REQ, |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 2212 | sizeof(struct rt_mlme_start_req), &StartReq); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2213 | pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_START; |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2214 | } else /* no more BSS */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2215 | { |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 2216 | |
| 2217 | { |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 2218 | AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE); |
| 2219 | AsicLockChannel(pAd, pAd->CommonCfg.Channel); |
| 2220 | DBGPRINT(RT_DEBUG_TRACE, |
| 2221 | ("CNTL - All roaming failed, restore to channel %d, Total BSS[%02d]\n", |
| 2222 | pAd->CommonCfg.Channel, pAd->ScanTab.BssNr)); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 2223 | } |
| 2224 | |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2225 | pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE; |
| 2226 | } |
| 2227 | } |
| 2228 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2229 | /* for re-association only */ |
| 2230 | /* IRQL = DISPATCH_LEVEL */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 2231 | void IterateOnBssTab2(struct rt_rtmp_adapter *pAd) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2232 | { |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 2233 | struct rt_mlme_assoc_req ReassocReq; |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2234 | unsigned long BssIdx; |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 2235 | struct rt_bss_entry *pBss; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2236 | |
| 2237 | BssIdx = pAd->MlmeAux.RoamIdx; |
| 2238 | pBss = &pAd->MlmeAux.RoamTab.BssEntry[BssIdx]; |
| 2239 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 2240 | if (BssIdx < pAd->MlmeAux.RoamTab.BssNr) { |
| 2241 | DBGPRINT(RT_DEBUG_TRACE, |
| 2242 | ("CNTL - iterate BSS %ld of %d\n", BssIdx, |
| 2243 | pAd->MlmeAux.RoamTab.BssNr)); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2244 | |
| 2245 | AsicSwitchChannel(pAd, pBss->Channel, FALSE); |
| 2246 | AsicLockChannel(pAd, pBss->Channel); |
| 2247 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2248 | /* reassociate message has the same structure as associate message */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 2249 | AssocParmFill(pAd, &ReassocReq, pBss->Bssid, |
| 2250 | pBss->CapabilityInfo, ASSOC_TIMEOUT, |
| 2251 | pAd->StaCfg.DefaultListenCount); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2252 | MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_MLME_REASSOC_REQ, |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 2253 | sizeof(struct rt_mlme_assoc_req), &ReassocReq); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2254 | |
| 2255 | pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_REASSOC; |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2256 | } else /* no more BSS */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2257 | { |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 2258 | |
| 2259 | { |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 2260 | AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE); |
| 2261 | AsicLockChannel(pAd, pAd->CommonCfg.Channel); |
| 2262 | DBGPRINT(RT_DEBUG_TRACE, |
| 2263 | ("CNTL - All roaming failed, restore to channel %d, Total BSS[%02d]\n", |
| 2264 | pAd->CommonCfg.Channel, pAd->ScanTab.BssNr)); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 2265 | } |
| 2266 | |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2267 | pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE; |
| 2268 | } |
| 2269 | } |
| 2270 | |
| 2271 | /* |
| 2272 | ========================================================================== |
| 2273 | Description: |
| 2274 | |
| 2275 | IRQL = DISPATCH_LEVEL |
| 2276 | |
| 2277 | ========================================================================== |
| 2278 | */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 2279 | void JoinParmFill(struct rt_rtmp_adapter *pAd, |
| 2280 | struct rt_mlme_join_req *JoinReq, unsigned long BssIdx) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2281 | { |
| 2282 | JoinReq->BssIdx = BssIdx; |
| 2283 | } |
| 2284 | |
| 2285 | /* |
| 2286 | ========================================================================== |
| 2287 | Description: |
| 2288 | |
| 2289 | IRQL = DISPATCH_LEVEL |
| 2290 | |
| 2291 | ========================================================================== |
| 2292 | */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 2293 | void ScanParmFill(struct rt_rtmp_adapter *pAd, |
| 2294 | struct rt_mlme_scan_req *ScanReq, |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2295 | char Ssid[], |
| 2296 | u8 SsidLen, u8 BssType, u8 ScanType) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2297 | { |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 2298 | NdisZeroMemory(ScanReq->Ssid, MAX_LEN_OF_SSID); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2299 | ScanReq->SsidLen = SsidLen; |
| 2300 | NdisMoveMemory(ScanReq->Ssid, Ssid, SsidLen); |
| 2301 | ScanReq->BssType = BssType; |
| 2302 | ScanReq->ScanType = ScanType; |
| 2303 | } |
| 2304 | |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2305 | /* |
| 2306 | ========================================================================== |
| 2307 | Description: |
| 2308 | |
| 2309 | IRQL = DISPATCH_LEVEL |
| 2310 | |
| 2311 | ========================================================================== |
| 2312 | */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 2313 | void StartParmFill(struct rt_rtmp_adapter *pAd, |
| 2314 | struct rt_mlme_start_req *StartReq, |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2315 | char Ssid[], u8 SsidLen) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2316 | { |
| 2317 | ASSERT(SsidLen <= MAX_LEN_OF_SSID); |
| 2318 | NdisMoveMemory(StartReq->Ssid, Ssid, SsidLen); |
| 2319 | StartReq->SsidLen = SsidLen; |
| 2320 | } |
| 2321 | |
| 2322 | /* |
| 2323 | ========================================================================== |
| 2324 | Description: |
| 2325 | |
| 2326 | IRQL = DISPATCH_LEVEL |
| 2327 | |
| 2328 | ========================================================================== |
| 2329 | */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 2330 | void AuthParmFill(struct rt_rtmp_adapter *pAd, |
| 2331 | struct rt_mlme_auth_req *AuthReq, |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2332 | u8 *pAddr, u16 Alg) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2333 | { |
| 2334 | COPY_MAC_ADDR(AuthReq->Addr, pAddr); |
| 2335 | AuthReq->Alg = Alg; |
| 2336 | AuthReq->Timeout = AUTH_TIMEOUT; |
| 2337 | } |
| 2338 | |
| 2339 | /* |
| 2340 | ========================================================================== |
| 2341 | Description: |
| 2342 | |
| 2343 | IRQL = DISPATCH_LEVEL |
| 2344 | |
| 2345 | ========================================================================== |
| 2346 | */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 2347 | #ifdef RTMP_MAC_PCI |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 2348 | void ComposePsPoll(struct rt_rtmp_adapter *pAd) |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 2349 | { |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 2350 | NdisZeroMemory(&pAd->PsPollFrame, sizeof(struct rt_pspoll_frame)); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 2351 | pAd->PsPollFrame.FC.Type = BTYPE_CNTL; |
| 2352 | pAd->PsPollFrame.FC.SubType = SUBTYPE_PS_POLL; |
| 2353 | pAd->PsPollFrame.Aid = pAd->StaActive.Aid | 0xC000; |
| 2354 | COPY_MAC_ADDR(pAd->PsPollFrame.Bssid, pAd->CommonCfg.Bssid); |
| 2355 | COPY_MAC_ADDR(pAd->PsPollFrame.Ta, pAd->CurrentAddress); |
| 2356 | } |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 2357 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2358 | /* IRQL = DISPATCH_LEVEL */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 2359 | void ComposeNullFrame(struct rt_rtmp_adapter *pAd) |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 2360 | { |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 2361 | NdisZeroMemory(&pAd->NullFrame, sizeof(struct rt_header_802_11)); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 2362 | pAd->NullFrame.FC.Type = BTYPE_DATA; |
| 2363 | pAd->NullFrame.FC.SubType = SUBTYPE_NULL_FUNC; |
| 2364 | pAd->NullFrame.FC.ToDs = 1; |
| 2365 | COPY_MAC_ADDR(pAd->NullFrame.Addr1, pAd->CommonCfg.Bssid); |
| 2366 | COPY_MAC_ADDR(pAd->NullFrame.Addr2, pAd->CurrentAddress); |
| 2367 | COPY_MAC_ADDR(pAd->NullFrame.Addr3, pAd->CommonCfg.Bssid); |
| 2368 | } |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2369 | #endif /* RTMP_MAC_PCI // */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 2370 | #ifdef RTMP_MAC_USB |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 2371 | void MlmeCntlConfirm(struct rt_rtmp_adapter *pAd, unsigned long MsgType, u16 Msg) |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 2372 | { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2373 | MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MsgType, sizeof(u16), |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 2374 | &Msg); |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 2375 | } |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 2376 | |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 2377 | void ComposePsPoll(struct rt_rtmp_adapter *pAd) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2378 | { |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 2379 | struct rt_txinfo *pTxInfo; |
| 2380 | struct rt_txwi * pTxWI; |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 2381 | |
| 2382 | DBGPRINT(RT_DEBUG_TRACE, ("ComposePsPoll\n")); |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 2383 | NdisZeroMemory(&pAd->PsPollFrame, sizeof(struct rt_pspoll_frame)); |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 2384 | |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 2385 | pAd->PsPollFrame.FC.PwrMgmt = 0; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2386 | pAd->PsPollFrame.FC.Type = BTYPE_CNTL; |
| 2387 | pAd->PsPollFrame.FC.SubType = SUBTYPE_PS_POLL; |
| 2388 | pAd->PsPollFrame.Aid = pAd->StaActive.Aid | 0xC000; |
| 2389 | COPY_MAC_ADDR(pAd->PsPollFrame.Bssid, pAd->CommonCfg.Bssid); |
| 2390 | COPY_MAC_ADDR(pAd->PsPollFrame.Ta, pAd->CurrentAddress); |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 2391 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 2392 | RTMPZeroMemory(&pAd->PsPollContext.TransferBuffer->field. |
| 2393 | WirelessPacket[0], 100); |
| 2394 | pTxInfo = |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 2395 | (struct rt_txinfo *)& pAd->PsPollContext.TransferBuffer->field. |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 2396 | WirelessPacket[0]; |
| 2397 | RTMPWriteTxInfo(pAd, pTxInfo, |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 2398 | (u16)(sizeof(struct rt_pspoll_frame) + TXWI_SIZE), TRUE, |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 2399 | EpToQueue[MGMTPIPEIDX], FALSE, FALSE); |
| 2400 | pTxWI = |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 2401 | (struct rt_txwi *) & pAd->PsPollContext.TransferBuffer->field. |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 2402 | WirelessPacket[TXINFO_SIZE]; |
| 2403 | RTMPWriteTxWI(pAd, pTxWI, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, 0, |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 2404 | BSSID_WCID, (sizeof(struct rt_pspoll_frame)), 0, 0, |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2405 | (u8)pAd->CommonCfg.MlmeTransmit.field.MCS, |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 2406 | IFS_BACKOFF, FALSE, &pAd->CommonCfg.MlmeTransmit); |
| 2407 | RTMPMoveMemory(&pAd->PsPollContext.TransferBuffer->field. |
| 2408 | WirelessPacket[TXWI_SIZE + TXINFO_SIZE], |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 2409 | &pAd->PsPollFrame, sizeof(struct rt_pspoll_frame)); |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2410 | /* Append 4 extra zero bytes. */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 2411 | pAd->PsPollContext.BulkOutSize = |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 2412 | TXINFO_SIZE + TXWI_SIZE + sizeof(struct rt_pspoll_frame) + 4; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2413 | } |
| 2414 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2415 | /* IRQL = DISPATCH_LEVEL */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 2416 | void ComposeNullFrame(struct rt_rtmp_adapter *pAd) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2417 | { |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 2418 | struct rt_txinfo *pTxInfo; |
| 2419 | struct rt_txwi * pTxWI; |
Bartlomiej Zolnierkiewicz | 5f5d2df | 2009-04-26 16:06:29 +0200 | [diff] [blame] | 2420 | |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 2421 | NdisZeroMemory(&pAd->NullFrame, sizeof(struct rt_header_802_11)); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2422 | pAd->NullFrame.FC.Type = BTYPE_DATA; |
| 2423 | pAd->NullFrame.FC.SubType = SUBTYPE_NULL_FUNC; |
| 2424 | pAd->NullFrame.FC.ToDs = 1; |
| 2425 | COPY_MAC_ADDR(pAd->NullFrame.Addr1, pAd->CommonCfg.Bssid); |
| 2426 | COPY_MAC_ADDR(pAd->NullFrame.Addr2, pAd->CurrentAddress); |
| 2427 | COPY_MAC_ADDR(pAd->NullFrame.Addr3, pAd->CommonCfg.Bssid); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 2428 | RTMPZeroMemory(&pAd->NullContext.TransferBuffer->field. |
| 2429 | WirelessPacket[0], 100); |
| 2430 | pTxInfo = |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 2431 | (struct rt_txinfo *)& pAd->NullContext.TransferBuffer->field. |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 2432 | WirelessPacket[0]; |
| 2433 | RTMPWriteTxInfo(pAd, pTxInfo, |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 2434 | (u16)(sizeof(struct rt_header_802_11) + TXWI_SIZE), TRUE, |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 2435 | EpToQueue[MGMTPIPEIDX], FALSE, FALSE); |
| 2436 | pTxWI = |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 2437 | (struct rt_txwi *) & pAd->NullContext.TransferBuffer->field. |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 2438 | WirelessPacket[TXINFO_SIZE]; |
| 2439 | RTMPWriteTxWI(pAd, pTxWI, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, 0, |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 2440 | BSSID_WCID, (sizeof(struct rt_header_802_11)), 0, 0, |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2441 | (u8)pAd->CommonCfg.MlmeTransmit.field.MCS, |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 2442 | IFS_BACKOFF, FALSE, &pAd->CommonCfg.MlmeTransmit); |
| 2443 | RTMPMoveMemory(&pAd->NullContext.TransferBuffer->field. |
| 2444 | WirelessPacket[TXWI_SIZE + TXINFO_SIZE], &pAd->NullFrame, |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 2445 | sizeof(struct rt_header_802_11)); |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 2446 | pAd->NullContext.BulkOutSize = |
| 2447 | TXINFO_SIZE + TXWI_SIZE + sizeof(pAd->NullFrame) + 4; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2448 | } |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2449 | #endif /* RTMP_MAC_USB // */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2450 | |
| 2451 | /* |
| 2452 | ========================================================================== |
| 2453 | Description: |
| 2454 | Pre-build a BEACON frame in the shared memory |
| 2455 | |
| 2456 | IRQL = PASSIVE_LEVEL |
| 2457 | IRQL = DISPATCH_LEVEL |
| 2458 | |
| 2459 | ========================================================================== |
| 2460 | */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 2461 | unsigned long MakeIbssBeacon(struct rt_rtmp_adapter *pAd) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2462 | { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2463 | u8 DsLen = 1, IbssLen = 2; |
| 2464 | u8 LocalErpIe[3] = { IE_ERP, 1, 0x04 }; |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 2465 | struct rt_header_802_11 BcnHdr; |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2466 | u16 CapabilityInfo; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2467 | LARGE_INTEGER FakeTimestamp; |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2468 | unsigned long FrameLen = 0; |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 2469 | struct rt_txwi * pTxWI = &pAd->BeaconTxWI; |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2470 | u8 *pBeaconFrame = pAd->BeaconBuf; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 2471 | BOOLEAN Privacy; |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2472 | u8 SupRate[MAX_LEN_OF_SUPPORTED_RATES]; |
| 2473 | u8 SupRateLen = 0; |
| 2474 | u8 ExtRate[MAX_LEN_OF_SUPPORTED_RATES]; |
| 2475 | u8 ExtRateLen = 0; |
| 2476 | u8 RSNIe = IE_WPA; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2477 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 2478 | if ((pAd->CommonCfg.PhyMode == PHY_11B) |
| 2479 | && (pAd->CommonCfg.Channel <= 14)) { |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2480 | SupRate[0] = 0x82; /* 1 mbps */ |
| 2481 | SupRate[1] = 0x84; /* 2 mbps */ |
| 2482 | SupRate[2] = 0x8b; /* 5.5 mbps */ |
| 2483 | SupRate[3] = 0x96; /* 11 mbps */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2484 | SupRateLen = 4; |
| 2485 | ExtRateLen = 0; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 2486 | } else if (pAd->CommonCfg.Channel > 14) { |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2487 | SupRate[0] = 0x8C; /* 6 mbps, in units of 0.5 Mbps, basic rate */ |
| 2488 | SupRate[1] = 0x12; /* 9 mbps, in units of 0.5 Mbps */ |
| 2489 | SupRate[2] = 0x98; /* 12 mbps, in units of 0.5 Mbps, basic rate */ |
| 2490 | SupRate[3] = 0x24; /* 18 mbps, in units of 0.5 Mbps */ |
| 2491 | SupRate[4] = 0xb0; /* 24 mbps, in units of 0.5 Mbps, basic rate */ |
| 2492 | SupRate[5] = 0x48; /* 36 mbps, in units of 0.5 Mbps */ |
| 2493 | SupRate[6] = 0x60; /* 48 mbps, in units of 0.5 Mbps */ |
| 2494 | SupRate[7] = 0x6c; /* 54 mbps, in units of 0.5 Mbps */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 2495 | SupRateLen = 8; |
| 2496 | ExtRateLen = 0; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2497 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2498 | /* */ |
| 2499 | /* Also Update MlmeRate & RtsRate for G only & A only */ |
| 2500 | /* */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2501 | pAd->CommonCfg.MlmeRate = RATE_6; |
| 2502 | pAd->CommonCfg.RtsRate = RATE_6; |
| 2503 | pAd->CommonCfg.MlmeTransmit.field.MODE = MODE_OFDM; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 2504 | pAd->CommonCfg.MlmeTransmit.field.MCS = |
| 2505 | OfdmRateToRxwiMCS[pAd->CommonCfg.MlmeRate]; |
| 2506 | pAd->MacTab.Content[BSS0Mcast_WCID].HTPhyMode.field.MODE = |
| 2507 | MODE_OFDM; |
| 2508 | pAd->MacTab.Content[BSS0Mcast_WCID].HTPhyMode.field.MCS = |
| 2509 | OfdmRateToRxwiMCS[pAd->CommonCfg.MlmeRate]; |
| 2510 | } else { |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2511 | SupRate[0] = 0x82; /* 1 mbps */ |
| 2512 | SupRate[1] = 0x84; /* 2 mbps */ |
| 2513 | SupRate[2] = 0x8b; /* 5.5 mbps */ |
| 2514 | SupRate[3] = 0x96; /* 11 mbps */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2515 | SupRateLen = 4; |
| 2516 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2517 | ExtRate[0] = 0x0C; /* 6 mbps, in units of 0.5 Mbps, */ |
| 2518 | ExtRate[1] = 0x12; /* 9 mbps, in units of 0.5 Mbps */ |
| 2519 | ExtRate[2] = 0x18; /* 12 mbps, in units of 0.5 Mbps, */ |
| 2520 | ExtRate[3] = 0x24; /* 18 mbps, in units of 0.5 Mbps */ |
| 2521 | ExtRate[4] = 0x30; /* 24 mbps, in units of 0.5 Mbps, */ |
| 2522 | ExtRate[5] = 0x48; /* 36 mbps, in units of 0.5 Mbps */ |
| 2523 | ExtRate[6] = 0x60; /* 48 mbps, in units of 0.5 Mbps */ |
| 2524 | ExtRate[7] = 0x6c; /* 54 mbps, in units of 0.5 Mbps */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 2525 | ExtRateLen = 8; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2526 | } |
| 2527 | |
| 2528 | pAd->StaActive.SupRateLen = SupRateLen; |
| 2529 | NdisMoveMemory(pAd->StaActive.SupRate, SupRate, SupRateLen); |
| 2530 | pAd->StaActive.ExtRateLen = ExtRateLen; |
| 2531 | NdisMoveMemory(pAd->StaActive.ExtRate, ExtRate, ExtRateLen); |
| 2532 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2533 | /* compose IBSS beacon frame */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 2534 | MgtMacHeaderInit(pAd, &BcnHdr, SUBTYPE_BEACON, 0, BROADCAST_ADDR, |
| 2535 | pAd->CommonCfg.Bssid); |
| 2536 | Privacy = (pAd->StaCfg.WepStatus == Ndis802_11Encryption1Enabled) |
| 2537 | || (pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled) |
| 2538 | || (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled); |
| 2539 | CapabilityInfo = |
| 2540 | CAP_GENERATE(0, 1, Privacy, |
| 2541 | (pAd->CommonCfg.TxPreamble == Rt802_11PreambleShort), |
| 2542 | 0, 0); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2543 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 2544 | MakeOutgoingFrame(pBeaconFrame, &FrameLen, |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 2545 | sizeof(struct rt_header_802_11), &BcnHdr, |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 2546 | TIMESTAMP_LEN, &FakeTimestamp, |
| 2547 | 2, &pAd->CommonCfg.BeaconPeriod, |
| 2548 | 2, &CapabilityInfo, |
| 2549 | 1, &SsidIe, |
| 2550 | 1, &pAd->CommonCfg.SsidLen, |
| 2551 | pAd->CommonCfg.SsidLen, pAd->CommonCfg.Ssid, |
| 2552 | 1, &SupRateIe, |
| 2553 | 1, &SupRateLen, |
| 2554 | SupRateLen, SupRate, |
| 2555 | 1, &DsIe, |
| 2556 | 1, &DsLen, |
| 2557 | 1, &pAd->CommonCfg.Channel, |
| 2558 | 1, &IbssIe, |
| 2559 | 1, &IbssLen, 2, &pAd->StaActive.AtimWin, END_OF_ARGS); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2560 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2561 | /* add ERP_IE and EXT_RAE IE of in 802.11g */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 2562 | if (ExtRateLen) { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2563 | unsigned long tmp; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2564 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 2565 | MakeOutgoingFrame(pBeaconFrame + FrameLen, &tmp, |
| 2566 | 3, LocalErpIe, |
| 2567 | 1, &ExtRateIe, |
| 2568 | 1, &ExtRateLen, |
| 2569 | ExtRateLen, ExtRate, END_OF_ARGS); |
| 2570 | FrameLen += tmp; |
| 2571 | } |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2572 | /* If adhoc secruity is set for WPA-None, append the cipher suite IE */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 2573 | if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone) { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2574 | unsigned long tmp; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 2575 | RTMPMakeRSNIE(pAd, pAd->StaCfg.AuthMode, pAd->StaCfg.WepStatus, |
| 2576 | BSS0); |
| 2577 | |
| 2578 | MakeOutgoingFrame(pBeaconFrame + FrameLen, &tmp, |
| 2579 | 1, &RSNIe, |
| 2580 | 1, &pAd->StaCfg.RSNIE_Len, |
| 2581 | pAd->StaCfg.RSNIE_Len, pAd->StaCfg.RSN_IE, |
| 2582 | END_OF_ARGS); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2583 | FrameLen += tmp; |
| 2584 | } |
| 2585 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 2586 | if ((pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)) { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2587 | unsigned long TmpLen; |
| 2588 | u8 HtLen, HtLen1; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2589 | |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2590 | /* add HT Capability IE */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2591 | HtLen = sizeof(pAd->CommonCfg.HtCapability); |
| 2592 | HtLen1 = sizeof(pAd->CommonCfg.AddHTInfo); |
Bartlomiej Zolnierkiewicz | 51f94a7 | 2009-04-26 16:05:39 +0200 | [diff] [blame] | 2593 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 2594 | MakeOutgoingFrame(pBeaconFrame + FrameLen, &TmpLen, |
| 2595 | 1, &HtCapIe, |
| 2596 | 1, &HtLen, |
| 2597 | HtLen, &pAd->CommonCfg.HtCapability, |
| 2598 | 1, &AddHtInfoIe, |
| 2599 | 1, &HtLen1, |
| 2600 | HtLen1, &pAd->CommonCfg.AddHTInfo, |
| 2601 | END_OF_ARGS); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2602 | |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2603 | FrameLen += TmpLen; |
| 2604 | } |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2605 | /*beacon use reserved WCID 0xff */ |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 2606 | if (pAd->CommonCfg.Channel > 14) { |
| 2607 | RTMPWriteTxWI(pAd, pTxWI, FALSE, FALSE, TRUE, FALSE, FALSE, |
| 2608 | TRUE, 0, 0xff, FrameLen, PID_MGMT, PID_BEACON, |
| 2609 | RATE_1, IFS_HTTXOP, FALSE, |
| 2610 | &pAd->CommonCfg.MlmeTransmit); |
| 2611 | } else { |
Bartlomiej Zolnierkiewicz | 8281958 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 2612 | /* Set to use 1Mbps for Adhoc beacon. */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2613 | HTTRANSMIT_SETTING Transmit; |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 2614 | Transmit.word = 0; |
| 2615 | RTMPWriteTxWI(pAd, pTxWI, FALSE, FALSE, TRUE, FALSE, FALSE, |
| 2616 | TRUE, 0, 0xff, FrameLen, PID_MGMT, PID_BEACON, |
| 2617 | RATE_1, IFS_HTTXOP, FALSE, &Transmit); |
| 2618 | } |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2619 | |
Bartlomiej Zolnierkiewicz | 0f65bec | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 2620 | DBGPRINT(RT_DEBUG_TRACE, |
| 2621 | ("MakeIbssBeacon (len=%ld), SupRateLen=%d, ExtRateLen=%d, Channel=%d, PhyMode=%d\n", |
| 2622 | FrameLen, SupRateLen, ExtRateLen, pAd->CommonCfg.Channel, |
| 2623 | pAd->CommonCfg.PhyMode)); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 2624 | return FrameLen; |
| 2625 | } |