blob: ca57fc37d6090717e094ecee849530fe25d2d355 [file] [log] [blame]
Forest Bond92b96792009-06-13 07:38:31 -04001/*
2 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
3 * All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * File: wcmd.c
20 *
21 * Purpose: Handles the management command interface functions
22 *
23 * Author: Lyndon Chen
24 *
25 * Date: May 8, 2003
26 *
27 * Functions:
28 * s_vProbeChannel - Active scan channel
29 * s_MgrMakeProbeRequest - Make ProbeRequest packet
30 * CommandTimer - Timer function to handle command
31 * s_bCommandComplete - Command Complete function
32 * bScheduleCommand - Push Command and wait Command Scheduler to do
33 * vCommandTimer- Command call back functions
34 * vCommandTimerWait- Call back timer
35 * s_bClearBSSID_SCAN- Clear BSSID_SCAN cmd in CMD Queue
36 *
37 * Revision History:
38 *
39 */
40
Forest Bond92b96792009-06-13 07:38:31 -040041#include "tmacro.h"
Forest Bond92b96792009-06-13 07:38:31 -040042#include "device.h"
Forest Bond92b96792009-06-13 07:38:31 -040043#include "mac.h"
Forest Bond92b96792009-06-13 07:38:31 -040044#include "card.h"
Forest Bond92b96792009-06-13 07:38:31 -040045#include "80211hdr.h"
Forest Bond92b96792009-06-13 07:38:31 -040046#include "wcmd.h"
Forest Bond92b96792009-06-13 07:38:31 -040047#include "wmgr.h"
Forest Bond92b96792009-06-13 07:38:31 -040048#include "power.h"
Forest Bond92b96792009-06-13 07:38:31 -040049#include "wctl.h"
Forest Bond92b96792009-06-13 07:38:31 -040050#include "baseband.h"
Forest Bond92b96792009-06-13 07:38:31 -040051#include "control.h"
Forest Bond92b96792009-06-13 07:38:31 -040052#include "rxtx.h"
Forest Bond92b96792009-06-13 07:38:31 -040053#include "rf.h"
Forest Bond92b96792009-06-13 07:38:31 -040054#include "rndis.h"
Forest Bond92b96792009-06-13 07:38:31 -040055#include "channel.h"
Forest Bond92b96792009-06-13 07:38:31 -040056#include "iowpa.h"
Forest Bond92b96792009-06-13 07:38:31 -040057
Nandini Hanumanthagowdaebd381d2013-11-03 18:30:52 +053058static int msglevel = MSG_LEVEL_INFO;
59//static int msglevel = MSG_LEVEL_DEBUG;
Forest Bond92b96792009-06-13 07:38:31 -040060
Malcolm Priestley98583c02012-12-10 22:01:23 +000061static void s_vProbeChannel(struct vnt_private *);
62
63static struct vnt_tx_mgmt *s_MgrMakeProbeRequest(struct vnt_private *,
64 struct vnt_manager *pMgmt, u8 *pScanBSSID, PWLAN_IE_SSID pSSID,
65 PWLAN_IE_SUPP_RATES pCurrRates, PWLAN_IE_SUPP_RATES pCurrExtSuppRates);
Forest Bond92b96792009-06-13 07:38:31 -040066
Malcolm Priestley98583c02012-12-10 22:01:23 +000067static int s_bCommandComplete(struct vnt_private *);
Forest Bond92b96792009-06-13 07:38:31 -040068
Malcolm Priestley98583c02012-12-10 22:01:23 +000069static int s_bClearBSSID_SCAN(struct vnt_private *);
Forest Bond92b96792009-06-13 07:38:31 -040070
Forest Bond92b96792009-06-13 07:38:31 -040071/*
72 * Description:
73 * Stop AdHoc beacon during scan process
74 *
75 * Parameters:
76 * In:
77 * pDevice - Pointer to the adapter
78 * Out:
79 * none
80 *
81 * Return Value: none
82 *
83 */
Andres More0cbd8d92010-05-06 20:34:29 -030084
Malcolm Priestley98583c02012-12-10 22:01:23 +000085static void vAdHocBeaconStop(struct vnt_private *pDevice)
Forest Bond92b96792009-06-13 07:38:31 -040086{
Malcolm Priestley98583c02012-12-10 22:01:23 +000087 struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
88 int bStop;
Forest Bond92b96792009-06-13 07:38:31 -040089
90 /*
91 * temporarily stop Beacon packet for AdHoc Server
92 * if all of the following coditions are met:
93 * (1) STA is in AdHoc mode
94 * (2) VT3253 is programmed as automatic Beacon Transmitting
95 * (3) One of the following conditions is met
96 * (3.1) AdHoc channel is in B/G band and the
97 * current scan channel is in A band
98 * or
99 * (3.2) AdHoc channel is in A mode
100 */
Andres Moree269fc22013-02-12 20:36:29 -0500101 bStop = false;
Forest Bond92b96792009-06-13 07:38:31 -0400102 if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) &&
103 (pMgmt->eCurrState >= WMAC_STATE_STARTED))
104 {
105 if ((pMgmt->uIBSSChannel <= CB_MAX_CHANNEL_24G) &&
106 (pMgmt->uScanChannel > CB_MAX_CHANNEL_24G))
107 {
Andres More4e9b5e22013-02-12 20:36:30 -0500108 bStop = true;
Forest Bond92b96792009-06-13 07:38:31 -0400109 }
110 if (pMgmt->uIBSSChannel > CB_MAX_CHANNEL_24G)
111 {
Andres More4e9b5e22013-02-12 20:36:30 -0500112 bStop = true;
Forest Bond92b96792009-06-13 07:38:31 -0400113 }
114 }
115
116 if (bStop)
117 {
118 //PMESG(("STOP_BEACON: IBSSChannel = %u, ScanChannel = %u\n",
119 // pMgmt->uIBSSChannel, pMgmt->uScanChannel));
120 MACvRegBitsOff(pDevice, MAC_REG_TCR, TCR_AUTOBCNTX);
121 }
122
123} /* vAdHocBeaconStop */
124
Forest Bond92b96792009-06-13 07:38:31 -0400125/*
126 * Description:
127 * Restart AdHoc beacon after scan process complete
128 *
129 * Parameters:
130 * In:
131 * pDevice - Pointer to the adapter
132 * Out:
133 * none
134 *
135 * Return Value: none
136 *
137 */
Malcolm Priestley98583c02012-12-10 22:01:23 +0000138static void vAdHocBeaconRestart(struct vnt_private *pDevice)
Forest Bond92b96792009-06-13 07:38:31 -0400139{
Malcolm Priestley98583c02012-12-10 22:01:23 +0000140 struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
Forest Bond92b96792009-06-13 07:38:31 -0400141
142 /*
143 * Restart Beacon packet for AdHoc Server
144 * if all of the following coditions are met:
145 * (1) STA is in AdHoc mode
146 * (2) VT3253 is programmed as automatic Beacon Transmitting
147 */
148 if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) &&
149 (pMgmt->eCurrState >= WMAC_STATE_STARTED))
150 {
151 //PMESG(("RESTART_BEACON\n"));
152 MACvRegBitsOn(pDevice, MAC_REG_TCR, TCR_AUTOBCNTX);
153 }
154
155}
156
Forest Bond92b96792009-06-13 07:38:31 -0400157/*+
158 *
159 * Routine Description:
160 * Prepare and send probe request management frames.
161 *
162 *
163 * Return Value:
164 * none.
165 *
166-*/
167
Malcolm Priestley98583c02012-12-10 22:01:23 +0000168static void s_vProbeChannel(struct vnt_private *pDevice)
Forest Bond92b96792009-06-13 07:38:31 -0400169{
Malcolm Priestley98583c02012-12-10 22:01:23 +0000170 struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
171 struct vnt_tx_mgmt *pTxPacket;
172 u8 abyCurrSuppRatesG[] = {WLAN_EID_SUPP_RATES,
173 8, 0x02, 0x04, 0x0B, 0x16, 0x24, 0x30, 0x48, 0x6C};
174 /* 1M, 2M, 5M, 11M, 18M, 24M, 36M, 54M*/
175 u8 abyCurrExtSuppRatesG[] = {WLAN_EID_EXTSUPP_RATES,
176 4, 0x0C, 0x12, 0x18, 0x60};
177 /* 6M, 9M, 12M, 48M*/
178 u8 abyCurrSuppRatesA[] = {WLAN_EID_SUPP_RATES,
179 8, 0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C};
180 u8 abyCurrSuppRatesB[] = {WLAN_EID_SUPP_RATES,
181 4, 0x02, 0x04, 0x0B, 0x16};
182 u8 *pbyRate;
183 int ii;
Forest Bond92b96792009-06-13 07:38:31 -0400184
Forest Bond92b96792009-06-13 07:38:31 -0400185 if (pDevice->byBBType == BB_TYPE_11A) {
186 pbyRate = &abyCurrSuppRatesA[0];
187 } else if (pDevice->byBBType == BB_TYPE_11B) {
188 pbyRate = &abyCurrSuppRatesB[0];
189 } else {
190 pbyRate = &abyCurrSuppRatesG[0];
191 }
192 // build an assocreq frame and send it
193 pTxPacket = s_MgrMakeProbeRequest
194 (
195 pDevice,
196 pMgmt,
197 pMgmt->abyScanBSSID,
198 (PWLAN_IE_SSID)pMgmt->abyScanSSID,
199 (PWLAN_IE_SUPP_RATES)pbyRate,
200 (PWLAN_IE_SUPP_RATES)abyCurrExtSuppRatesG
201 );
202
Nandini Hanumanthagowdaebd381d2013-11-03 18:30:52 +0530203 if (pTxPacket != NULL) {
204 for (ii = 0; ii < 1; ii++) {
Forest Bond92b96792009-06-13 07:38:31 -0400205 if (csMgmt_xmit(pDevice, pTxPacket) != CMD_STATUS_PENDING) {
206 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Probe request sending fail.. \n");
207 }
208 else {
209 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Probe request is sending.. \n");
210 }
211 }
212 }
213
214}
215
Forest Bond92b96792009-06-13 07:38:31 -0400216/*+
217 *
218 * Routine Description:
219 * Constructs an probe request frame
220 *
221 *
222 * Return Value:
Justin P. Mattocka0a1f612012-08-26 08:16:43 -0700223 * A ptr to Tx frame or NULL on allocation failure
Forest Bond92b96792009-06-13 07:38:31 -0400224 *
225-*/
226
Valentina Manea3b138852013-11-04 10:44:02 +0200227static struct vnt_tx_mgmt *s_MgrMakeProbeRequest(struct vnt_private *pDevice,
Malcolm Priestley98583c02012-12-10 22:01:23 +0000228 struct vnt_manager *pMgmt, u8 *pScanBSSID, PWLAN_IE_SSID pSSID,
229 PWLAN_IE_SUPP_RATES pCurrRates, PWLAN_IE_SUPP_RATES pCurrExtSuppRates)
Forest Bond92b96792009-06-13 07:38:31 -0400230{
Malcolm Priestley98583c02012-12-10 22:01:23 +0000231 struct vnt_tx_mgmt *pTxPacket = NULL;
232 WLAN_FR_PROBEREQ sFrame;
Forest Bond92b96792009-06-13 07:38:31 -0400233
Malcolm Priestley98583c02012-12-10 22:01:23 +0000234 pTxPacket = (struct vnt_tx_mgmt *)pMgmt->pbyMgmtPacketPool;
235 memset(pTxPacket, 0, sizeof(struct vnt_tx_mgmt)
236 + WLAN_PROBEREQ_FR_MAXLEN);
237 pTxPacket->p80211Header = (PUWLAN_80211HDR)((u8 *)pTxPacket
238 + sizeof(struct vnt_tx_mgmt));
Andres Moreb902fbf2013-02-25 20:32:51 -0500239 sFrame.pBuf = (u8 *)pTxPacket->p80211Header;
Forest Bond92b96792009-06-13 07:38:31 -0400240 sFrame.len = WLAN_PROBEREQ_FR_MAXLEN;
241 vMgrEncodeProbeRequest(&sFrame);
242 sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16(
243 (
244 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) |
245 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_PROBEREQ)
246 ));
Nandini Hanumanthagowdaebd381d2013-11-03 18:30:52 +0530247 memcpy(sFrame.pHdr->sA3.abyAddr1, pScanBSSID, WLAN_ADDR_LEN);
248 memcpy(sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN);
249 memcpy(sFrame.pHdr->sA3.abyAddr3, pScanBSSID, WLAN_BSSID_LEN);
Forest Bond92b96792009-06-13 07:38:31 -0400250 // Copy the SSID, pSSID->len=0 indicate broadcast SSID
251 sFrame.pSSID = (PWLAN_IE_SSID)(sFrame.pBuf + sFrame.len);
252 sFrame.len += pSSID->len + WLAN_IEHDR_LEN;
253 memcpy(sFrame.pSSID, pSSID, pSSID->len + WLAN_IEHDR_LEN);
254 sFrame.pSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len);
255 sFrame.len += pCurrRates->len + WLAN_IEHDR_LEN;
256 memcpy(sFrame.pSuppRates, pCurrRates, pCurrRates->len + WLAN_IEHDR_LEN);
257 // Copy the extension rate set
258 if (pDevice->byBBType == BB_TYPE_11G) {
259 sFrame.pExtSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len);
260 sFrame.len += pCurrExtSuppRates->len + WLAN_IEHDR_LEN;
261 memcpy(sFrame.pExtSuppRates, pCurrExtSuppRates, pCurrExtSuppRates->len + WLAN_IEHDR_LEN);
262 }
263 pTxPacket->cbMPDULen = sFrame.len;
264 pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN;
265
266 return pTxPacket;
267}
268
Valentina Manea3b138852013-11-04 10:44:02 +0200269static void
270vCommandTimerWait(struct vnt_private *pDevice, unsigned long MSecond)
Forest Bond92b96792009-06-13 07:38:31 -0400271{
Malcolm Priestley94488a72013-09-27 16:48:14 +0100272 schedule_delayed_work(&pDevice->run_command_work,
273 msecs_to_jiffies(MSecond));
Forest Bond92b96792009-06-13 07:38:31 -0400274}
275
Malcolm Priestley94488a72013-09-27 16:48:14 +0100276void vRunCommand(struct work_struct *work)
Forest Bond92b96792009-06-13 07:38:31 -0400277{
Malcolm Priestley94488a72013-09-27 16:48:14 +0100278 struct vnt_private *pDevice =
279 container_of(work, struct vnt_private, run_command_work.work);
Malcolm Priestley98583c02012-12-10 22:01:23 +0000280 struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
281 PWLAN_IE_SSID pItemSSID;
282 PWLAN_IE_SSID pItemSSIDCurr;
283 CMD_STATUS Status;
284 struct sk_buff *skb;
Malcolm Priestley0fdb56d2012-11-24 14:53:07 +0000285 union iwreq_data wrqu;
Malcolm Priestley98583c02012-12-10 22:01:23 +0000286 int ii;
287 u8 byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80};
288 u8 byData;
Forest Bond92b96792009-06-13 07:38:31 -0400289
Malcolm Priestley17f3ced2013-10-14 19:51:45 +0100290 if (pDevice->Flags & fMP_DISCONNECTED)
291 return;
292
Forest Bond92b96792009-06-13 07:38:31 -0400293 if (pDevice->dwDiagRefCount != 0)
294 return;
Andres More4e9b5e22013-02-12 20:36:30 -0500295 if (pDevice->bCmdRunning != true)
Forest Bond92b96792009-06-13 07:38:31 -0400296 return;
297
298 spin_lock_irq(&pDevice->lock);
299
Nandini Hanumanthagowdaebd381d2013-11-03 18:30:52 +0530300 switch (pDevice->eCommandState) {
Forest Bond92b96792009-06-13 07:38:31 -0400301
302 case WLAN_CMD_SCAN_START:
303
304 pDevice->byReAssocCount = 0;
Andres More4e9b5e22013-02-12 20:36:30 -0500305 if (pDevice->bRadioOff == true) {
Forest Bond92b96792009-06-13 07:38:31 -0400306 s_bCommandComplete(pDevice);
307 spin_unlock_irq(&pDevice->lock);
308 return;
309 }
310
311 if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
312 s_bCommandComplete(pDevice);
313 spin_unlock_irq(&pDevice->lock);
314 return;
315 }
316
317 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyScanSSID;
318
Nandini Hanumanthagowdaebd381d2013-11-03 18:30:52 +0530319 if (pMgmt->uScanChannel == 0) {
Forest Bond92b96792009-06-13 07:38:31 -0400320 pMgmt->uScanChannel = pDevice->byMinChannel;
321 }
322 if (pMgmt->uScanChannel > pDevice->byMaxChannel) {
Malcolm Priestley257f6582013-03-25 19:50:44 +0000323 pDevice->eCommandState = WLAN_CMD_SCAN_END;
Forest Bond92b96792009-06-13 07:38:31 -0400324 s_bCommandComplete(pDevice);
325 spin_unlock_irq(&pDevice->lock);
326 return;
327
328 } else {
329 if (!ChannelValid(pDevice->byZoneType, pMgmt->uScanChannel)) {
Nandini Hanumanthagowdaebd381d2013-11-03 18:30:52 +0530330 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Invalid channel pMgmt->uScanChannel = %d \n", pMgmt->uScanChannel);
Malcolm Priestley257f6582013-03-25 19:50:44 +0000331 pMgmt->uScanChannel++;
Forest Bond92b96792009-06-13 07:38:31 -0400332 s_bCommandComplete(pDevice);
333 spin_unlock_irq(&pDevice->lock);
334 return;
335 }
336 if (pMgmt->uScanChannel == pDevice->byMinChannel) {
337 // pMgmt->eScanType = WMAC_SCAN_ACTIVE; //mike mark
338 pMgmt->abyScanBSSID[0] = 0xFF;
339 pMgmt->abyScanBSSID[1] = 0xFF;
340 pMgmt->abyScanBSSID[2] = 0xFF;
341 pMgmt->abyScanBSSID[3] = 0xFF;
342 pMgmt->abyScanBSSID[4] = 0xFF;
343 pMgmt->abyScanBSSID[5] = 0xFF;
344 pItemSSID->byElementID = WLAN_EID_SSID;
345 // clear bssid list
Andres More0cbd8d92010-05-06 20:34:29 -0300346 /* BSSvClearBSSList((void *) pDevice,
347 pDevice->bLinkPass); */
Forest Bond92b96792009-06-13 07:38:31 -0400348 pMgmt->eScanState = WMAC_IS_SCANNING;
349 pDevice->byScanBBType = pDevice->byBBType; //lucas
Andres More4e9b5e22013-02-12 20:36:30 -0500350 pDevice->bStopDataPkt = true;
Lucas De Marchi25985ed2011-03-30 22:57:33 -0300351 // Turn off RCR_BSSID filter every time
Forest Bond92b96792009-06-13 07:38:31 -0400352 MACvRegBitsOff(pDevice, MAC_REG_RCR, RCR_BSSID);
353 pDevice->byRxMode &= ~RCR_BSSID;
354
355 }
356 //lucas
357 vAdHocBeaconStop(pDevice);
358 if ((pDevice->byBBType != BB_TYPE_11A) && (pMgmt->uScanChannel > CB_MAX_CHANNEL_24G)) {
359 pDevice->byBBType = BB_TYPE_11A;
360 CARDvSetBSSMode(pDevice);
361 }
362 else if ((pDevice->byBBType == BB_TYPE_11A) && (pMgmt->uScanChannel <= CB_MAX_CHANNEL_24G)) {
363 pDevice->byBBType = BB_TYPE_11G;
364 CARDvSetBSSMode(pDevice);
365 }
366 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Scanning.... channel: [%d]\n", pMgmt->uScanChannel);
367 // Set channel
368 CARDbSetMediaChannel(pDevice, pMgmt->uScanChannel);
369 // Set Baseband to be more sensitive.
370
371 if (pDevice->bUpdateBBVGA) {
372 BBvSetShortSlotTime(pDevice);
373 BBvSetVGAGainOffset(pDevice, pDevice->abyBBVGA[0]);
Andres More4e9b5e22013-02-12 20:36:30 -0500374 BBvUpdatePreEDThreshold(pDevice, true);
Forest Bond92b96792009-06-13 07:38:31 -0400375 }
376 pMgmt->uScanChannel++;
377
378 while (!ChannelValid(pDevice->byZoneType, pMgmt->uScanChannel) &&
Nandini Hanumanthagowdaebd381d2013-11-03 18:30:52 +0530379 pMgmt->uScanChannel <= pDevice->byMaxChannel){
Forest Bond92b96792009-06-13 07:38:31 -0400380 pMgmt->uScanChannel++;
381 }
382
383 if (pMgmt->uScanChannel > pDevice->byMaxChannel) {
384 // Set Baseband to be not sensitive and rescan
385 pDevice->eCommandState = WLAN_CMD_SCAN_END;
386
387 }
Andres Moree269fc22013-02-12 20:36:29 -0500388 if ((pMgmt->b11hEnable == false) ||
Forest Bond92b96792009-06-13 07:38:31 -0400389 (pMgmt->uScanChannel < CB_MAX_CHANNEL_24G)) {
390 s_vProbeChannel(pDevice);
391 spin_unlock_irq(&pDevice->lock);
Andres More0cbd8d92010-05-06 20:34:29 -0300392 vCommandTimerWait((void *) pDevice, 100);
Forest Bond92b96792009-06-13 07:38:31 -0400393 return;
394 } else {
395 spin_unlock_irq(&pDevice->lock);
Andres More0cbd8d92010-05-06 20:34:29 -0300396 vCommandTimerWait((void *) pDevice, WCMD_PASSIVE_SCAN_TIME);
Forest Bond92b96792009-06-13 07:38:31 -0400397 return;
398 }
399
400 }
401
402 break;
403
404 case WLAN_CMD_SCAN_END:
405
406 // Set Baseband's sensitivity back.
407 if (pDevice->byBBType != pDevice->byScanBBType) {
408 pDevice->byBBType = pDevice->byScanBBType;
409 CARDvSetBSSMode(pDevice);
410 }
411
412 if (pDevice->bUpdateBBVGA) {
413 BBvSetShortSlotTime(pDevice);
414 BBvSetVGAGainOffset(pDevice, pDevice->byBBVGACurrent);
Andres Moree269fc22013-02-12 20:36:29 -0500415 BBvUpdatePreEDThreshold(pDevice, false);
Forest Bond92b96792009-06-13 07:38:31 -0400416 }
417
418 // Set channel back
419 vAdHocBeaconRestart(pDevice);
420 // Set channel back
421 CARDbSetMediaChannel(pDevice, pMgmt->uCurrChannel);
422 // Set Filter
423 if (pMgmt->bCurrBSSIDFilterOn) {
424 MACvRegBitsOn(pDevice, MAC_REG_RCR, RCR_BSSID);
425 pDevice->byRxMode |= RCR_BSSID;
426 }
427 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Scanning, set back to channel: [%d]\n", pMgmt->uCurrChannel);
Malcolm Priestley257f6582013-03-25 19:50:44 +0000428 pMgmt->uScanChannel = 0;
Forest Bond92b96792009-06-13 07:38:31 -0400429 pMgmt->eScanState = WMAC_NO_SCANNING;
Andres Moree269fc22013-02-12 20:36:29 -0500430 pDevice->bStopDataPkt = false;
Andres More465711b2010-08-03 20:25:50 -0300431
Malcolm Priestley0fdb56d2012-11-24 14:53:07 +0000432 /*send scan event to wpa_Supplicant*/
433 PRINT_K("wireless_send_event--->SIOCGIWSCAN(scan done)\n");
434 memset(&wrqu, 0, sizeof(wrqu));
435 wireless_send_event(pDevice->dev, SIOCGIWSCAN, &wrqu, NULL);
436
Forest Bond92b96792009-06-13 07:38:31 -0400437 s_bCommandComplete(pDevice);
438 break;
439
Nandini Hanumanthagowdaebd381d2013-11-03 18:30:52 +0530440 case WLAN_CMD_DISASSOCIATE_START:
Forest Bond92b96792009-06-13 07:38:31 -0400441 pDevice->byReAssocCount = 0;
442 if ((pMgmt->eCurrMode == WMAC_MODE_ESS_STA) &&
443 (pMgmt->eCurrState != WMAC_STATE_ASSOC)) {
444 s_bCommandComplete(pDevice);
445 spin_unlock_irq(&pDevice->lock);
446 return;
447 } else {
448
Andres Moree269fc22013-02-12 20:36:29 -0500449 pDevice->bwextstep0 = false;
450 pDevice->bwextstep1 = false;
451 pDevice->bwextstep2 = false;
452 pDevice->bwextstep3 = false;
453 pDevice->bWPASuppWextEnabled = false;
454 pDevice->fWPA_Authened = false;
Forest Bond92b96792009-06-13 07:38:31 -0400455
456 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Send Disassociation Packet..\n");
457 // reason = 8 : disassoc because sta has left
Andres More0cbd8d92010-05-06 20:34:29 -0300458 vMgrDisassocBeginSta((void *) pDevice,
459 pMgmt,
460 pMgmt->abyCurrBSSID,
461 (8),
462 &Status);
Andres Moree269fc22013-02-12 20:36:29 -0500463 pDevice->bLinkPass = false;
Nandini Hanumanthagowdaebd381d2013-11-03 18:30:52 +0530464 ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG, MAC_REG_PAPEDELAY, LEDSTS_STS, LEDSTS_SLOW);
Forest Bond92b96792009-06-13 07:38:31 -0400465 // unlock command busy
466 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
467 pItemSSID->len = 0;
468 memset(pItemSSID->abySSID, 0, WLAN_SSID_MAXLEN);
469 pMgmt->eCurrState = WMAC_STATE_IDLE;
Andres Moree269fc22013-02-12 20:36:29 -0500470 pMgmt->sNodeDBTable[0].bActive = false;
471// pDevice->bBeaconBufReady = false;
Forest Bond92b96792009-06-13 07:38:31 -0400472 }
473 netif_stop_queue(pDevice->dev);
Andres More4e9b5e22013-02-12 20:36:30 -0500474 if (pDevice->bNeedRadioOFF == true)
Forest Bond92b96792009-06-13 07:38:31 -0400475 CARDbRadioPowerOff(pDevice);
476 s_bCommandComplete(pDevice);
477 break;
478
Forest Bond92b96792009-06-13 07:38:31 -0400479 case WLAN_CMD_SSID_START:
480
481 pDevice->byReAssocCount = 0;
Andres More4e9b5e22013-02-12 20:36:30 -0500482 if (pDevice->bRadioOff == true) {
Forest Bond92b96792009-06-13 07:38:31 -0400483 s_bCommandComplete(pDevice);
484 spin_unlock_irq(&pDevice->lock);
485 return;
486 }
487
Nandini Hanumanthagowdaebd381d2013-11-03 18:30:52 +0530488 memcpy(pMgmt->abyAdHocSSID, pMgmt->abyDesireSSID,
Forest Bond92b96792009-06-13 07:38:31 -0400489 ((PWLAN_IE_SSID)pMgmt->abyDesireSSID)->len + WLAN_IEHDR_LEN);
Andres More5926b9a2010-07-12 13:55:43 -0300490
Forest Bond92b96792009-06-13 07:38:31 -0400491 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID;
492 pItemSSIDCurr = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
493 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" cmd: desire ssid = %s\n", pItemSSID->abySSID);
494 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" cmd: curr ssid = %s\n", pItemSSIDCurr->abySSID);
495
496 if (pMgmt->eCurrState == WMAC_STATE_ASSOC) {
497 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" Cmd pMgmt->eCurrState == WMAC_STATE_ASSOC\n");
Nandini Hanumanthagowdaebd381d2013-11-03 18:30:52 +0530498 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pItemSSID->len =%d\n", pItemSSID->len);
499 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pItemSSIDCurr->len = %d\n", pItemSSIDCurr->len);
Forest Bond92b96792009-06-13 07:38:31 -0400500 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" desire ssid = %s\n", pItemSSID->abySSID);
501 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" curr ssid = %s\n", pItemSSIDCurr->abySSID);
502 }
503
504 if ((pMgmt->eCurrState == WMAC_STATE_ASSOC) ||
Nandini Hanumanthagowdaebd381d2013-11-03 18:30:52 +0530505 ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) && (pMgmt->eCurrState == WMAC_STATE_JOINTED))) {
Forest Bond92b96792009-06-13 07:38:31 -0400506
507 if (pItemSSID->len == pItemSSIDCurr->len) {
508 if (memcmp(pItemSSID->abySSID, pItemSSIDCurr->abySSID, pItemSSID->len) == 0) {
509 s_bCommandComplete(pDevice);
510 spin_unlock_irq(&pDevice->lock);
511 return;
512 }
513 }
514 netif_stop_queue(pDevice->dev);
Andres Moree269fc22013-02-12 20:36:29 -0500515 pDevice->bLinkPass = false;
Nandini Hanumanthagowdaebd381d2013-11-03 18:30:52 +0530516 ControlvMaskByte(pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_PAPEDELAY, LEDSTS_STS, LEDSTS_SLOW);
Forest Bond92b96792009-06-13 07:38:31 -0400517 }
518 // set initial state
519 pMgmt->eCurrState = WMAC_STATE_IDLE;
520 pMgmt->eCurrMode = WMAC_MODE_STANDBY;
Andres More0cbd8d92010-05-06 20:34:29 -0300521 PSvDisablePowerSaving((void *) pDevice);
Forest Bond92b96792009-06-13 07:38:31 -0400522 BSSvClearNodeDBTable(pDevice, 0);
Andres More0cbd8d92010-05-06 20:34:29 -0300523 vMgrJoinBSSBegin((void *) pDevice, &Status);
Forest Bond92b96792009-06-13 07:38:31 -0400524 // if Infra mode
525 if ((pMgmt->eCurrMode == WMAC_MODE_ESS_STA) && (pMgmt->eCurrState == WMAC_STATE_JOINTED)) {
526 // Call mgr to begin the deauthentication
Lucas De Marchi25985ed2011-03-30 22:57:33 -0300527 // reason = (3) because sta has left ESS
Andres More0cbd8d92010-05-06 20:34:29 -0300528 if (pMgmt->eCurrState >= WMAC_STATE_AUTH) {
529 vMgrDeAuthenBeginSta((void *)pDevice,
530 pMgmt,
531 pMgmt->abyCurrBSSID,
532 (3),
533 &Status);
534 }
Forest Bond92b96792009-06-13 07:38:31 -0400535 // Call mgr to begin the authentication
Andres More0cbd8d92010-05-06 20:34:29 -0300536 vMgrAuthenBeginSta((void *) pDevice, pMgmt, &Status);
Forest Bond92b96792009-06-13 07:38:31 -0400537 if (Status == CMD_STATUS_SUCCESS) {
538 pDevice->byLinkWaitCount = 0;
539 pDevice->eCommandState = WLAN_AUTHENTICATE_WAIT;
Andres More0cbd8d92010-05-06 20:34:29 -0300540 vCommandTimerWait((void *) pDevice, AUTHENTICATE_TIMEOUT);
Forest Bond92b96792009-06-13 07:38:31 -0400541 spin_unlock_irq(&pDevice->lock);
542 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" Set eCommandState = WLAN_AUTHENTICATE_WAIT\n");
543 return;
544 }
545 }
546 // if Adhoc mode
547 else if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) {
548 if (pMgmt->eCurrState == WMAC_STATE_JOINTED) {
Nandini Hanumanthagowdaebd381d2013-11-03 18:30:52 +0530549 if (netif_queue_stopped(pDevice->dev)) {
Forest Bond92b96792009-06-13 07:38:31 -0400550 netif_wake_queue(pDevice->dev);
551 }
Andres More4e9b5e22013-02-12 20:36:30 -0500552 pDevice->bLinkPass = true;
Nandini Hanumanthagowdaebd381d2013-11-03 18:30:52 +0530553 ControlvMaskByte(pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_PAPEDELAY, LEDSTS_STS, LEDSTS_INTER);
Andres More4e9b5e22013-02-12 20:36:30 -0500554 pMgmt->sNodeDBTable[0].bActive = true;
Forest Bond92b96792009-06-13 07:38:31 -0400555 pMgmt->sNodeDBTable[0].uInActiveCount = 0;
556 }
557 else {
558 // start own IBSS
Andres More0cbd8d92010-05-06 20:34:29 -0300559 DBG_PRT(MSG_LEVEL_DEBUG,
560 KERN_INFO "CreateOwn IBSS by CurrMode = IBSS_STA\n");
561 vMgrCreateOwnIBSS((void *) pDevice, &Status);
Nandini Hanumanthagowdaebd381d2013-11-03 18:30:52 +0530562 if (Status != CMD_STATUS_SUCCESS) {
Andres More0cbd8d92010-05-06 20:34:29 -0300563 DBG_PRT(MSG_LEVEL_DEBUG,
564 KERN_INFO "WLAN_CMD_IBSS_CREATE fail!\n");
Joe Perches9fc86022011-04-10 14:31:32 -0700565 }
Forest Bond92b96792009-06-13 07:38:31 -0400566 BSSvAddMulticastNode(pDevice);
567 }
568 s_bClearBSSID_SCAN(pDevice);
569 }
570 // if SSID not found
571 else if (pMgmt->eCurrMode == WMAC_MODE_STANDBY) {
572 if (pMgmt->eConfigMode == WMAC_CONFIG_IBSS_STA ||
573 pMgmt->eConfigMode == WMAC_CONFIG_AUTO) {
574 // start own IBSS
Andres More0cbd8d92010-05-06 20:34:29 -0300575 DBG_PRT(MSG_LEVEL_DEBUG,
576 KERN_INFO "CreateOwn IBSS by CurrMode = STANDBY\n");
577 vMgrCreateOwnIBSS((void *) pDevice, &Status);
Nandini Hanumanthagowdaebd381d2013-11-03 18:30:52 +0530578 if (Status != CMD_STATUS_SUCCESS) {
Andres More0cbd8d92010-05-06 20:34:29 -0300579 DBG_PRT(MSG_LEVEL_DEBUG,
580 KERN_INFO "WLAN_CMD_IBSS_CREATE fail!\n");
Joe Perches9fc86022011-04-10 14:31:32 -0700581 }
Forest Bond92b96792009-06-13 07:38:31 -0400582 BSSvAddMulticastNode(pDevice);
583 s_bClearBSSID_SCAN(pDevice);
584/*
Andres More4e9b5e22013-02-12 20:36:30 -0500585 pDevice->bLinkPass = true;
Forest Bond92b96792009-06-13 07:38:31 -0400586 ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_INTER);
587 if (netif_queue_stopped(pDevice->dev)){
588 netif_wake_queue(pDevice->dev);
589 }
590 s_bClearBSSID_SCAN(pDevice);
591*/
592 }
593 else {
594 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disconnect SSID none\n");
Andres More4e9b5e22013-02-12 20:36:30 -0500595 // if(pDevice->bWPASuppWextEnabled == true)
Forest Bond92b96792009-06-13 07:38:31 -0400596 {
597 union iwreq_data wrqu;
Nandini Hanumanthagowdaebd381d2013-11-03 18:30:52 +0530598 memset(&wrqu, 0, sizeof(wrqu));
Forest Bond92b96792009-06-13 07:38:31 -0400599 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
600 PRINT_K("wireless_send_event--->SIOCGIWAP(disassociated:vMgrJoinBSSBegin Fail !!)\n");
601 wireless_send_event(pDevice->dev, SIOCGIWAP, &wrqu, NULL);
602 }
Forest Bond92b96792009-06-13 07:38:31 -0400603 }
604 }
605 s_bCommandComplete(pDevice);
606 break;
607
Nandini Hanumanthagowdaebd381d2013-11-03 18:30:52 +0530608 case WLAN_AUTHENTICATE_WAIT:
Forest Bond92b96792009-06-13 07:38:31 -0400609 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState == WLAN_AUTHENTICATE_WAIT\n");
610 if (pMgmt->eCurrState == WMAC_STATE_AUTH) {
611 pDevice->byLinkWaitCount = 0;
612 // Call mgr to begin the association
613 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCurrState == WMAC_STATE_AUTH\n");
Andres More0cbd8d92010-05-06 20:34:29 -0300614 vMgrAssocBeginSta((void *) pDevice, pMgmt, &Status);
Forest Bond92b96792009-06-13 07:38:31 -0400615 if (Status == CMD_STATUS_SUCCESS) {
616 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState = WLAN_ASSOCIATE_WAIT\n");
617 pDevice->byLinkWaitCount = 0;
618 pDevice->eCommandState = WLAN_ASSOCIATE_WAIT;
Andres More0cbd8d92010-05-06 20:34:29 -0300619 vCommandTimerWait((void *) pDevice, ASSOCIATE_TIMEOUT);
Forest Bond92b96792009-06-13 07:38:31 -0400620 spin_unlock_irq(&pDevice->lock);
621 return;
622 }
623 }
Nandini Hanumanthagowdaebd381d2013-11-03 18:30:52 +0530624 else if (pMgmt->eCurrState < WMAC_STATE_AUTHPENDING) {
Forest Bond92b96792009-06-13 07:38:31 -0400625 printk("WLAN_AUTHENTICATE_WAIT:Authen Fail???\n");
626 }
Nandini Hanumanthagowdaebd381d2013-11-03 18:30:52 +0530627 else if (pDevice->byLinkWaitCount <= 4) { //mike add:wait another 2 sec if authenticated_frame delay!
628 pDevice->byLinkWaitCount++;
629 printk("WLAN_AUTHENTICATE_WAIT:wait %d times!!\n", pDevice->byLinkWaitCount);
Forest Bond92b96792009-06-13 07:38:31 -0400630 spin_unlock_irq(&pDevice->lock);
Andres More0cbd8d92010-05-06 20:34:29 -0300631 vCommandTimerWait((void *) pDevice, AUTHENTICATE_TIMEOUT/2);
Forest Bond92b96792009-06-13 07:38:31 -0400632 return;
633 }
634 pDevice->byLinkWaitCount = 0;
Forest Bond92b96792009-06-13 07:38:31 -0400635
636 s_bCommandComplete(pDevice);
637 break;
638
Nandini Hanumanthagowdaebd381d2013-11-03 18:30:52 +0530639 case WLAN_ASSOCIATE_WAIT:
Forest Bond92b96792009-06-13 07:38:31 -0400640 if (pMgmt->eCurrState == WMAC_STATE_ASSOC) {
641 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCurrState == WMAC_STATE_ASSOC\n");
642 if (pDevice->ePSMode != WMAC_POWER_CAM) {
Andres More0cbd8d92010-05-06 20:34:29 -0300643 PSvEnablePowerSaving((void *) pDevice,
644 pMgmt->wListenInterval);
Forest Bond92b96792009-06-13 07:38:31 -0400645 }
646/*
647 if (pMgmt->eAuthenMode >= WMAC_AUTH_WPA) {
648 KeybRemoveAllKey(pDevice, &(pDevice->sKey), pDevice->abyBSSID);
649 }
650*/
651 pDevice->byLinkWaitCount = 0;
652 pDevice->byReAssocCount = 0;
Andres More4e9b5e22013-02-12 20:36:30 -0500653 pDevice->bLinkPass = true;
Nandini Hanumanthagowdaebd381d2013-11-03 18:30:52 +0530654 ControlvMaskByte(pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_PAPEDELAY, LEDSTS_STS, LEDSTS_INTER);
Forest Bond92b96792009-06-13 07:38:31 -0400655 s_bClearBSSID_SCAN(pDevice);
656
Nandini Hanumanthagowdaebd381d2013-11-03 18:30:52 +0530657 if (netif_queue_stopped(pDevice->dev)) {
Forest Bond92b96792009-06-13 07:38:31 -0400658 netif_wake_queue(pDevice->dev);
659 }
660
Forest Bond92b96792009-06-13 07:38:31 -0400661 }
Nandini Hanumanthagowdaebd381d2013-11-03 18:30:52 +0530662 else if (pMgmt->eCurrState < WMAC_STATE_ASSOCPENDING) {
Forest Bond92b96792009-06-13 07:38:31 -0400663 printk("WLAN_ASSOCIATE_WAIT:Association Fail???\n");
664 }
Nandini Hanumanthagowdaebd381d2013-11-03 18:30:52 +0530665 else if (pDevice->byLinkWaitCount <= 4) { //mike add:wait another 2 sec if associated_frame delay!
666 pDevice->byLinkWaitCount++;
667 printk("WLAN_ASSOCIATE_WAIT:wait %d times!!\n", pDevice->byLinkWaitCount);
Forest Bond92b96792009-06-13 07:38:31 -0400668 spin_unlock_irq(&pDevice->lock);
Andres More0cbd8d92010-05-06 20:34:29 -0300669 vCommandTimerWait((void *) pDevice, ASSOCIATE_TIMEOUT/2);
Forest Bond92b96792009-06-13 07:38:31 -0400670 return;
671 }
Forest Bond92b96792009-06-13 07:38:31 -0400672
673 s_bCommandComplete(pDevice);
674 break;
675
Nandini Hanumanthagowdaebd381d2013-11-03 18:30:52 +0530676 case WLAN_CMD_AP_MODE_START:
Forest Bond92b96792009-06-13 07:38:31 -0400677 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState == WLAN_CMD_AP_MODE_START\n");
678
679 if (pMgmt->eConfigMode == WMAC_CONFIG_AP) {
Malcolm Priestleybd9a6db2013-09-27 16:51:13 +0100680 cancel_delayed_work_sync(&pDevice->second_callback_work);
Forest Bond92b96792009-06-13 07:38:31 -0400681 pMgmt->eCurrState = WMAC_STATE_IDLE;
682 pMgmt->eCurrMode = WMAC_MODE_STANDBY;
Andres Moree269fc22013-02-12 20:36:29 -0500683 pDevice->bLinkPass = false;
Nandini Hanumanthagowdaebd381d2013-11-03 18:30:52 +0530684 ControlvMaskByte(pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_PAPEDELAY, LEDSTS_STS, LEDSTS_SLOW);
Andres More4e9b5e22013-02-12 20:36:30 -0500685 if (pDevice->bEnableHostWEP == true)
Forest Bond92b96792009-06-13 07:38:31 -0400686 BSSvClearNodeDBTable(pDevice, 1);
687 else
688 BSSvClearNodeDBTable(pDevice, 0);
689 pDevice->uAssocCount = 0;
690 pMgmt->eCurrState = WMAC_STATE_IDLE;
Andres Moree269fc22013-02-12 20:36:29 -0500691 pDevice->bFixRate = false;
Forest Bond92b96792009-06-13 07:38:31 -0400692
Andres More0cbd8d92010-05-06 20:34:29 -0300693 vMgrCreateOwnIBSS((void *) pDevice, &Status);
694 if (Status != CMD_STATUS_SUCCESS) {
695 DBG_PRT(MSG_LEVEL_DEBUG,
696 KERN_INFO "vMgrCreateOwnIBSS fail!\n");
Joe Perches9fc86022011-04-10 14:31:32 -0700697 }
Justin P. Mattocka0a1f612012-08-26 08:16:43 -0700698 // always turn off unicast bit
Forest Bond92b96792009-06-13 07:38:31 -0400699 MACvRegBitsOff(pDevice, MAC_REG_RCR, RCR_UNICAST);
700 pDevice->byRxMode &= ~RCR_UNICAST;
Nandini Hanumanthagowdaebd381d2013-11-03 18:30:52 +0530701 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "wcmd: rx_mode = %x\n", pDevice->byRxMode);
Forest Bond92b96792009-06-13 07:38:31 -0400702 BSSvAddMulticastNode(pDevice);
Nandini Hanumanthagowdaebd381d2013-11-03 18:30:52 +0530703 if (netif_queue_stopped(pDevice->dev)) {
Forest Bond92b96792009-06-13 07:38:31 -0400704 netif_wake_queue(pDevice->dev);
705 }
Andres More4e9b5e22013-02-12 20:36:30 -0500706 pDevice->bLinkPass = true;
Nandini Hanumanthagowdaebd381d2013-11-03 18:30:52 +0530707 ControlvMaskByte(pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_PAPEDELAY, LEDSTS_STS, LEDSTS_INTER);
Malcolm Priestleybd9a6db2013-09-27 16:51:13 +0100708 schedule_delayed_work(&pDevice->second_callback_work, HZ);
Forest Bond92b96792009-06-13 07:38:31 -0400709 }
710 s_bCommandComplete(pDevice);
711 break;
712
Nandini Hanumanthagowdaebd381d2013-11-03 18:30:52 +0530713 case WLAN_CMD_TX_PSPACKET_START:
Forest Bond92b96792009-06-13 07:38:31 -0400714 // DTIM Multicast tx
715 if (pMgmt->sNodeDBTable[0].bRxPSPoll) {
716 while ((skb = skb_dequeue(&pMgmt->sNodeDBTable[0].sTxPSQueue)) != NULL) {
717 if (skb_queue_empty(&pMgmt->sNodeDBTable[0].sTxPSQueue)) {
718 pMgmt->abyPSTxMap[0] &= ~byMask[0];
Andres Moree269fc22013-02-12 20:36:29 -0500719 pDevice->bMoreData = false;
Forest Bond92b96792009-06-13 07:38:31 -0400720 }
721 else {
Andres More4e9b5e22013-02-12 20:36:30 -0500722 pDevice->bMoreData = true;
Forest Bond92b96792009-06-13 07:38:31 -0400723 }
724
725 if (nsDMA_tx_packet(pDevice, TYPE_AC0DMA, skb) != 0) {
726 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Multicast ps tx fail \n");
727 }
728
729 pMgmt->sNodeDBTable[0].wEnQueueCnt--;
730 }
Joe Perches9fc86022011-04-10 14:31:32 -0700731 }
Forest Bond92b96792009-06-13 07:38:31 -0400732
733 // PS nodes tx
734 for (ii = 1; ii < (MAX_NODE_NUM + 1); ii++) {
735 if (pMgmt->sNodeDBTable[ii].bActive &&
736 pMgmt->sNodeDBTable[ii].bRxPSPoll) {
737 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Index=%d Enqueu Cnt= %d\n",
738 ii, pMgmt->sNodeDBTable[ii].wEnQueueCnt);
739 while ((skb = skb_dequeue(&pMgmt->sNodeDBTable[ii].sTxPSQueue)) != NULL) {
740 if (skb_queue_empty(&pMgmt->sNodeDBTable[ii].sTxPSQueue)) {
741 // clear tx map
742 pMgmt->abyPSTxMap[pMgmt->sNodeDBTable[ii].wAID >> 3] &=
743 ~byMask[pMgmt->sNodeDBTable[ii].wAID & 7];
Andres Moree269fc22013-02-12 20:36:29 -0500744 pDevice->bMoreData = false;
Forest Bond92b96792009-06-13 07:38:31 -0400745 }
746 else {
Andres More4e9b5e22013-02-12 20:36:30 -0500747 pDevice->bMoreData = true;
Forest Bond92b96792009-06-13 07:38:31 -0400748 }
749
750 if (nsDMA_tx_packet(pDevice, TYPE_AC0DMA, skb) != 0) {
751 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "sta ps tx fail \n");
752 }
753
754 pMgmt->sNodeDBTable[ii].wEnQueueCnt--;
755 // check if sta ps enable, wait next pspoll
756 // if sta ps disable, send all pending buffers.
757 if (pMgmt->sNodeDBTable[ii].bPSEnable)
758 break;
759 }
760 if (skb_queue_empty(&pMgmt->sNodeDBTable[ii].sTxPSQueue)) {
761 // clear tx map
762 pMgmt->abyPSTxMap[pMgmt->sNodeDBTable[ii].wAID >> 3] &=
763 ~byMask[pMgmt->sNodeDBTable[ii].wAID & 7];
764 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Index=%d PS queue clear \n", ii);
765 }
Andres Moree269fc22013-02-12 20:36:29 -0500766 pMgmt->sNodeDBTable[ii].bRxPSPoll = false;
Forest Bond92b96792009-06-13 07:38:31 -0400767 }
768 }
769
770 s_bCommandComplete(pDevice);
771 break;
772
773 case WLAN_CMD_RADIO_START:
774
775 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState == WLAN_CMD_RADIO_START\n");
Andres More4e9b5e22013-02-12 20:36:30 -0500776 // if (pDevice->bRadioCmd == true)
Forest Bond92b96792009-06-13 07:38:31 -0400777 // CARDbRadioPowerOn(pDevice);
778 // else
779 // CARDbRadioPowerOff(pDevice);
Andres More465711b2010-08-03 20:25:50 -0300780
Forest Bond92b96792009-06-13 07:38:31 -0400781 {
Andres More6487c492010-08-02 20:51:57 -0300782 int ntStatus = STATUS_SUCCESS;
Andres Moreb902fbf2013-02-25 20:32:51 -0500783 u8 byTmp;
Forest Bond92b96792009-06-13 07:38:31 -0400784
785 ntStatus = CONTROLnsRequestIn(pDevice,
786 MESSAGE_TYPE_READ,
787 MAC_REG_GPIOCTL1,
788 MESSAGE_REQUEST_MACREG,
789 1,
790 &byTmp);
791
Nandini Hanumanthagowdaebd381d2013-11-03 18:30:52 +0530792 if (ntStatus != STATUS_SUCCESS) {
Forest Bond92b96792009-06-13 07:38:31 -0400793 s_bCommandComplete(pDevice);
794 spin_unlock_irq(&pDevice->lock);
795 return;
796 }
Nandini Hanumanthagowdaebd381d2013-11-03 18:30:52 +0530797 if ((byTmp & GPIO3_DATA) == 0) {
Forest Bond92b96792009-06-13 07:38:31 -0400798 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" WLAN_CMD_RADIO_START_OFF........................\n");
799 // Old commands are useless.
800 // empty command Q
801 pDevice->cbFreeCmdQueue = CMD_Q_SIZE;
802 pDevice->uCmdDequeueIdx = 0;
803 pDevice->uCmdEnqueueIdx = 0;
Andres Moree269fc22013-02-12 20:36:29 -0500804 //0415pDevice->bCmdRunning = false;
Andres More4e9b5e22013-02-12 20:36:30 -0500805 pDevice->bCmdClear = true;
Andres Moree269fc22013-02-12 20:36:29 -0500806 pDevice->bStopTx0Pkt = false;
Andres More4e9b5e22013-02-12 20:36:30 -0500807 pDevice->bStopDataPkt = true;
Forest Bond92b96792009-06-13 07:38:31 -0400808
809 pDevice->byKeyIndex = 0;
Andres Moree269fc22013-02-12 20:36:29 -0500810 pDevice->bTransmitKey = false;
Forest Bond92b96792009-06-13 07:38:31 -0400811 spin_unlock_irq(&pDevice->lock);
Nandini Hanumanthagowdaebd381d2013-11-03 18:30:52 +0530812 KeyvInitTable(pDevice, &pDevice->sKey);
Forest Bond92b96792009-06-13 07:38:31 -0400813 spin_lock_irq(&pDevice->lock);
814 pMgmt->byCSSPK = KEY_CTL_NONE;
815 pMgmt->byCSSGK = KEY_CTL_NONE;
816
Andres More4e9b5e22013-02-12 20:36:30 -0500817 if (pDevice->bLinkPass == true) {
Forest Bond92b96792009-06-13 07:38:31 -0400818 // reason = 8 : disassoc because sta has left
Andres More0cbd8d92010-05-06 20:34:29 -0300819 vMgrDisassocBeginSta((void *) pDevice,
820 pMgmt,
821 pMgmt->abyCurrBSSID,
822 (8),
823 &Status);
Andres Moree269fc22013-02-12 20:36:29 -0500824 pDevice->bLinkPass = false;
Forest Bond92b96792009-06-13 07:38:31 -0400825 // unlock command busy
826 pMgmt->eCurrState = WMAC_STATE_IDLE;
Andres Moree269fc22013-02-12 20:36:29 -0500827 pMgmt->sNodeDBTable[0].bActive = false;
Andres More4e9b5e22013-02-12 20:36:30 -0500828 // if(pDevice->bWPASuppWextEnabled == true)
Forest Bond92b96792009-06-13 07:38:31 -0400829 {
830 union iwreq_data wrqu;
Nandini Hanumanthagowdaebd381d2013-11-03 18:30:52 +0530831 memset(&wrqu, 0, sizeof(wrqu));
Forest Bond92b96792009-06-13 07:38:31 -0400832 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
833 PRINT_K("wireless_send_event--->SIOCGIWAP(disassociated)\n");
834 wireless_send_event(pDevice->dev, SIOCGIWAP, &wrqu, NULL);
835 }
Forest Bond92b96792009-06-13 07:38:31 -0400836 }
Andres Moree269fc22013-02-12 20:36:29 -0500837 pDevice->bwextstep0 = false;
838 pDevice->bwextstep1 = false;
839 pDevice->bwextstep2 = false;
840 pDevice->bwextstep3 = false;
841 pDevice->bWPASuppWextEnabled = false;
Forest Bond92b96792009-06-13 07:38:31 -0400842 //clear current SSID
843 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
844 pItemSSID->len = 0;
845 memset(pItemSSID->abySSID, 0, WLAN_SSID_MAXLEN);
Justin P. Mattocka0a1f612012-08-26 08:16:43 -0700846 //clear desired SSID
Forest Bond92b96792009-06-13 07:38:31 -0400847 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID;
848 pItemSSID->len = 0;
849 memset(pItemSSID->abySSID, 0, WLAN_SSID_MAXLEN);
850
851 netif_stop_queue(pDevice->dev);
852 CARDbRadioPowerOff(pDevice);
Nandini Hanumanthagowdaebd381d2013-11-03 18:30:52 +0530853 MACvRegBitsOn(pDevice, MAC_REG_GPIOCTL1, GPIO3_INTMD);
854 ControlvMaskByte(pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_PAPEDELAY, LEDSTS_STS, LEDSTS_OFF);
Andres More4e9b5e22013-02-12 20:36:30 -0500855 pDevice->bHWRadioOff = true;
Forest Bond92b96792009-06-13 07:38:31 -0400856 } else {
857 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" WLAN_CMD_RADIO_START_ON........................\n");
Andres Moree269fc22013-02-12 20:36:29 -0500858 pDevice->bHWRadioOff = false;
Forest Bond92b96792009-06-13 07:38:31 -0400859 CARDbRadioPowerOn(pDevice);
Nandini Hanumanthagowdaebd381d2013-11-03 18:30:52 +0530860 MACvRegBitsOff(pDevice, MAC_REG_GPIOCTL1, GPIO3_INTMD);
861 ControlvMaskByte(pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_PAPEDELAY, LEDSTS_STS, LEDSTS_ON);
Forest Bond92b96792009-06-13 07:38:31 -0400862 }
863 }
864
865 s_bCommandComplete(pDevice);
866 break;
867
Forest Bond92b96792009-06-13 07:38:31 -0400868 case WLAN_CMD_CHANGE_BBSENSITIVITY_START:
869
Andres More4e9b5e22013-02-12 20:36:30 -0500870 pDevice->bStopDataPkt = true;
Forest Bond92b96792009-06-13 07:38:31 -0400871 pDevice->byBBVGACurrent = pDevice->byBBVGANew;
872 BBvSetVGAGainOffset(pDevice, pDevice->byBBVGACurrent);
873 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Change sensitivity pDevice->byBBVGACurrent = %x\n", pDevice->byBBVGACurrent);
Andres Moree269fc22013-02-12 20:36:29 -0500874 pDevice->bStopDataPkt = false;
Forest Bond92b96792009-06-13 07:38:31 -0400875 s_bCommandComplete(pDevice);
876 break;
877
878 case WLAN_CMD_TBTT_WAKEUP_START:
879 PSbIsNextTBTTWakeUp(pDevice);
880 s_bCommandComplete(pDevice);
881 break;
882
883 case WLAN_CMD_BECON_SEND_START:
884 bMgrPrepareBeaconToSend(pDevice, pMgmt);
885 s_bCommandComplete(pDevice);
886 break;
887
888 case WLAN_CMD_SETPOWER_START:
889
890 RFbSetPower(pDevice, pDevice->wCurrentRate, pMgmt->uCurrChannel);
891
892 s_bCommandComplete(pDevice);
893 break;
894
895 case WLAN_CMD_CHANGE_ANTENNA_START:
896 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Change from Antenna%d to", (int)pDevice->dwRxAntennaSel);
Nandini Hanumanthagowdaebd381d2013-11-03 18:30:52 +0530897 if (pDevice->dwRxAntennaSel == 0) {
898 pDevice->dwRxAntennaSel = 1;
Andres More4e9b5e22013-02-12 20:36:30 -0500899 if (pDevice->bTxRxAntInv == true)
Forest Bond92b96792009-06-13 07:38:31 -0400900 BBvSetAntennaMode(pDevice, ANT_RXA);
901 else
902 BBvSetAntennaMode(pDevice, ANT_RXB);
903 } else {
Nandini Hanumanthagowdaebd381d2013-11-03 18:30:52 +0530904 pDevice->dwRxAntennaSel = 0;
Andres More4e9b5e22013-02-12 20:36:30 -0500905 if (pDevice->bTxRxAntInv == true)
Forest Bond92b96792009-06-13 07:38:31 -0400906 BBvSetAntennaMode(pDevice, ANT_RXB);
907 else
908 BBvSetAntennaMode(pDevice, ANT_RXA);
909 }
910 s_bCommandComplete(pDevice);
911 break;
912
913 case WLAN_CMD_REMOVE_ALLKEY_START:
914 KeybRemoveAllKey(pDevice, &(pDevice->sKey), pDevice->abyBSSID);
915 s_bCommandComplete(pDevice);
916 break;
917
Forest Bond92b96792009-06-13 07:38:31 -0400918 case WLAN_CMD_MAC_DISPOWERSAVING_START:
Nandini Hanumanthagowdaebd381d2013-11-03 18:30:52 +0530919 ControlvReadByte(pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_PSCTL, &byData);
920 if ((byData & PSCTL_PS) != 0) {
Forest Bond92b96792009-06-13 07:38:31 -0400921 // disable power saving hw function
922 CONTROLnsRequestOut(pDevice,
923 MESSAGE_TYPE_DISABLE_PS,
924 0,
925 0,
926 0,
927 NULL
928 );
929 }
930 s_bCommandComplete(pDevice);
931 break;
932
933 case WLAN_CMD_11H_CHSW_START:
934 CARDbSetMediaChannel(pDevice, pDevice->byNewChannel);
Andres Moree269fc22013-02-12 20:36:29 -0500935 pDevice->bChannelSwitch = false;
Forest Bond92b96792009-06-13 07:38:31 -0400936 pMgmt->uCurrChannel = pDevice->byNewChannel;
Andres Moree269fc22013-02-12 20:36:29 -0500937 pDevice->bStopDataPkt = false;
Forest Bond92b96792009-06-13 07:38:31 -0400938 s_bCommandComplete(pDevice);
939 break;
940
941 default:
942 s_bCommandComplete(pDevice);
943 break;
944 } //switch
945
946 spin_unlock_irq(&pDevice->lock);
947 return;
948}
949
Malcolm Priestley98583c02012-12-10 22:01:23 +0000950static int s_bCommandComplete(struct vnt_private *pDevice)
Forest Bond92b96792009-06-13 07:38:31 -0400951{
Malcolm Priestley98583c02012-12-10 22:01:23 +0000952 struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
953 PWLAN_IE_SSID pSSID;
Andres Moree269fc22013-02-12 20:36:29 -0500954 int bRadioCmd = false;
Andres More4e9b5e22013-02-12 20:36:30 -0500955 int bForceSCAN = true;
Forest Bond92b96792009-06-13 07:38:31 -0400956
Forest Bond92b96792009-06-13 07:38:31 -0400957 pDevice->eCommandState = WLAN_CMD_IDLE;
958 if (pDevice->cbFreeCmdQueue == CMD_Q_SIZE) {
959 //Command Queue Empty
Andres Moree269fc22013-02-12 20:36:29 -0500960 pDevice->bCmdRunning = false;
Andres More4e9b5e22013-02-12 20:36:30 -0500961 return true;
Forest Bond92b96792009-06-13 07:38:31 -0400962 }
963 else {
964 pDevice->eCommand = pDevice->eCmdQueue[pDevice->uCmdDequeueIdx].eCmd;
965 pSSID = (PWLAN_IE_SSID)pDevice->eCmdQueue[pDevice->uCmdDequeueIdx].abyCmdDesireSSID;
966 bRadioCmd = pDevice->eCmdQueue[pDevice->uCmdDequeueIdx].bRadioCmd;
967 bForceSCAN = pDevice->eCmdQueue[pDevice->uCmdDequeueIdx].bForceSCAN;
968 ADD_ONE_WITH_WRAP_AROUND(pDevice->uCmdDequeueIdx, CMD_Q_SIZE);
969 pDevice->cbFreeCmdQueue++;
Andres More4e9b5e22013-02-12 20:36:30 -0500970 pDevice->bCmdRunning = true;
Nandini Hanumanthagowdaebd381d2013-11-03 18:30:52 +0530971 switch (pDevice->eCommand) {
Forest Bond92b96792009-06-13 07:38:31 -0400972 case WLAN_CMD_BSSID_SCAN:
973 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState= WLAN_CMD_BSSID_SCAN\n");
974 pDevice->eCommandState = WLAN_CMD_SCAN_START;
975 pMgmt->uScanChannel = 0;
976 if (pSSID->len != 0) {
Jim Lieb3e362592009-08-12 14:54:11 -0700977 memcpy(pMgmt->abyScanSSID, pSSID, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
Forest Bond92b96792009-06-13 07:38:31 -0400978 } else {
979 memset(pMgmt->abyScanSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
980 }
981/*
Andres More4e9b5e22013-02-12 20:36:30 -0500982 if ((bForceSCAN == false) && (pDevice->bLinkPass == true)) {
Forest Bond92b96792009-06-13 07:38:31 -0400983 if ((pSSID->len == ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->len) &&
Jim Lieb3e362592009-08-12 14:54:11 -0700984 ( !memcmp(pSSID->abySSID, ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->abySSID, pSSID->len))) {
Forest Bond92b96792009-06-13 07:38:31 -0400985 pDevice->eCommandState = WLAN_CMD_IDLE;
986 }
987 }
988*/
989 break;
990 case WLAN_CMD_SSID:
991 pDevice->eCommandState = WLAN_CMD_SSID_START;
992 if (pSSID->len > WLAN_SSID_MAXLEN)
993 pSSID->len = WLAN_SSID_MAXLEN;
994 if (pSSID->len != 0)
Jim Lieb3e362592009-08-12 14:54:11 -0700995 memcpy(pMgmt->abyDesireSSID, pSSID, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
Forest Bond92b96792009-06-13 07:38:31 -0400996 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState= WLAN_CMD_SSID_START\n");
997 break;
998 case WLAN_CMD_DISASSOCIATE:
999 pDevice->eCommandState = WLAN_CMD_DISASSOCIATE_START;
1000 break;
1001 case WLAN_CMD_RX_PSPOLL:
1002 pDevice->eCommandState = WLAN_CMD_TX_PSPACKET_START;
1003 break;
1004 case WLAN_CMD_RUN_AP:
1005 pDevice->eCommandState = WLAN_CMD_AP_MODE_START;
1006 break;
1007 case WLAN_CMD_RADIO:
1008 pDevice->eCommandState = WLAN_CMD_RADIO_START;
1009 pDevice->bRadioCmd = bRadioCmd;
1010 break;
1011 case WLAN_CMD_CHANGE_BBSENSITIVITY:
1012 pDevice->eCommandState = WLAN_CMD_CHANGE_BBSENSITIVITY_START;
1013 break;
1014
1015 case WLAN_CMD_TBTT_WAKEUP:
1016 pDevice->eCommandState = WLAN_CMD_TBTT_WAKEUP_START;
1017 break;
1018
1019 case WLAN_CMD_BECON_SEND:
1020 pDevice->eCommandState = WLAN_CMD_BECON_SEND_START;
1021 break;
1022
1023 case WLAN_CMD_SETPOWER:
1024 pDevice->eCommandState = WLAN_CMD_SETPOWER_START;
1025 break;
1026
1027 case WLAN_CMD_CHANGE_ANTENNA:
1028 pDevice->eCommandState = WLAN_CMD_CHANGE_ANTENNA_START;
1029 break;
1030
1031 case WLAN_CMD_REMOVE_ALLKEY:
1032 pDevice->eCommandState = WLAN_CMD_REMOVE_ALLKEY_START;
1033 break;
1034
1035 case WLAN_CMD_MAC_DISPOWERSAVING:
1036 pDevice->eCommandState = WLAN_CMD_MAC_DISPOWERSAVING_START;
1037 break;
1038
1039 case WLAN_CMD_11H_CHSW:
1040 pDevice->eCommandState = WLAN_CMD_11H_CHSW_START;
1041 break;
1042
1043 default:
1044 break;
1045
1046 }
Malcolm Priestley98583c02012-12-10 22:01:23 +00001047 vCommandTimerWait(pDevice, 0);
Forest Bond92b96792009-06-13 07:38:31 -04001048 }
1049
Andres More4e9b5e22013-02-12 20:36:30 -05001050 return true;
Forest Bond92b96792009-06-13 07:38:31 -04001051}
1052
Malcolm Priestley98583c02012-12-10 22:01:23 +00001053int bScheduleCommand(struct vnt_private *pDevice,
1054 CMD_CODE eCommand, u8 *pbyItem0)
Forest Bond92b96792009-06-13 07:38:31 -04001055{
Forest Bond92b96792009-06-13 07:38:31 -04001056
1057 if (pDevice->cbFreeCmdQueue == 0) {
Andres Moree269fc22013-02-12 20:36:29 -05001058 return (false);
Forest Bond92b96792009-06-13 07:38:31 -04001059 }
1060 pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].eCmd = eCommand;
Andres More4e9b5e22013-02-12 20:36:30 -05001061 pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].bForceSCAN = true;
Forest Bond92b96792009-06-13 07:38:31 -04001062 memset(pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].abyCmdDesireSSID, 0 , WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
1063 if (pbyItem0 != NULL) {
1064 switch (eCommand) {
1065 case WLAN_CMD_BSSID_SCAN:
Andres Moree269fc22013-02-12 20:36:29 -05001066 pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].bForceSCAN = false;
Jim Lieb3e362592009-08-12 14:54:11 -07001067 memcpy(pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].abyCmdDesireSSID,
Forest Bond92b96792009-06-13 07:38:31 -04001068 pbyItem0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
1069 break;
1070
1071 case WLAN_CMD_SSID:
Jim Lieb3e362592009-08-12 14:54:11 -07001072 memcpy(pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].abyCmdDesireSSID,
Forest Bond92b96792009-06-13 07:38:31 -04001073 pbyItem0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
1074 break;
1075
1076 case WLAN_CMD_DISASSOCIATE:
Jim Lieb193a8232009-08-12 14:54:06 -07001077 pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].bNeedRadioOFF = *((int *)pbyItem0);
Forest Bond92b96792009-06-13 07:38:31 -04001078 break;
1079/*
1080 case WLAN_CMD_DEAUTH:
Andres More3eaca0d2013-02-25 20:32:52 -05001081 pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].wDeAuthenReason = *((u16 *)pbyItem0);
Forest Bond92b96792009-06-13 07:38:31 -04001082 break;
1083*/
1084
1085 case WLAN_CMD_RADIO:
Jim Lieb193a8232009-08-12 14:54:06 -07001086 pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].bRadioCmd = *((int *)pbyItem0);
Forest Bond92b96792009-06-13 07:38:31 -04001087 break;
1088
1089 default:
1090 break;
1091 }
1092 }
1093
1094 ADD_ONE_WITH_WRAP_AROUND(pDevice->uCmdEnqueueIdx, CMD_Q_SIZE);
1095 pDevice->cbFreeCmdQueue--;
1096
Andres Moree269fc22013-02-12 20:36:29 -05001097 if (pDevice->bCmdRunning == false) {
Forest Bond92b96792009-06-13 07:38:31 -04001098 s_bCommandComplete(pDevice);
1099 }
1100 else {
1101 }
Andres More4e9b5e22013-02-12 20:36:30 -05001102 return (true);
Forest Bond92b96792009-06-13 07:38:31 -04001103
1104}
1105
1106/*
1107 * Description:
1108 * Clear BSSID_SCAN cmd in CMD Queue
1109 *
1110 * Parameters:
1111 * In:
1112 * hDeviceContext - Pointer to the adapter
1113 * eCommand - Command
1114 * Out:
1115 * none
1116 *
Andres More4e9b5e22013-02-12 20:36:30 -05001117 * Return Value: true if success; otherwise false
Forest Bond92b96792009-06-13 07:38:31 -04001118 *
1119 */
Malcolm Priestley98583c02012-12-10 22:01:23 +00001120static int s_bClearBSSID_SCAN(struct vnt_private *pDevice)
Forest Bond92b96792009-06-13 07:38:31 -04001121{
Malcolm Priestley98583c02012-12-10 22:01:23 +00001122 unsigned int uCmdDequeueIdx = pDevice->uCmdDequeueIdx;
1123 unsigned int ii;
Forest Bond92b96792009-06-13 07:38:31 -04001124
1125 if ((pDevice->cbFreeCmdQueue < CMD_Q_SIZE) && (uCmdDequeueIdx != pDevice->uCmdEnqueueIdx)) {
Nandini Hanumanthagowdaebd381d2013-11-03 18:30:52 +05301126 for (ii = 0; ii < (CMD_Q_SIZE - pDevice->cbFreeCmdQueue); ii++) {
Forest Bond92b96792009-06-13 07:38:31 -04001127 if (pDevice->eCmdQueue[uCmdDequeueIdx].eCmd == WLAN_CMD_BSSID_SCAN)
1128 pDevice->eCmdQueue[uCmdDequeueIdx].eCmd = WLAN_CMD_IDLE;
1129 ADD_ONE_WITH_WRAP_AROUND(uCmdDequeueIdx, CMD_Q_SIZE);
1130 if (uCmdDequeueIdx == pDevice->uCmdEnqueueIdx)
1131 break;
1132 }
1133 }
Andres More4e9b5e22013-02-12 20:36:30 -05001134 return true;
Forest Bond92b96792009-06-13 07:38:31 -04001135}
1136
Forest Bond92b96792009-06-13 07:38:31 -04001137//mike add:reset command timer
Malcolm Priestley98583c02012-12-10 22:01:23 +00001138void vResetCommandTimer(struct vnt_private *pDevice)
Forest Bond92b96792009-06-13 07:38:31 -04001139{
Malcolm Priestley94488a72013-09-27 16:48:14 +01001140 cancel_delayed_work_sync(&pDevice->run_command_work);
Forest Bond92b96792009-06-13 07:38:31 -04001141
Devendra Naga3afe5f62012-07-14 02:07:18 +05451142 pDevice->cbFreeCmdQueue = CMD_Q_SIZE;
1143 pDevice->uCmdDequeueIdx = 0;
1144 pDevice->uCmdEnqueueIdx = 0;
1145 pDevice->eCommandState = WLAN_CMD_IDLE;
Andres Moree269fc22013-02-12 20:36:29 -05001146 pDevice->bCmdRunning = false;
1147 pDevice->bCmdClear = false;
Forest Bond92b96792009-06-13 07:38:31 -04001148}