blob: da72d4df6fcaf54512d584187bac9c873a54201e [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"
Malcolm Priestley62c85262014-05-26 13:59:07 +010051#include "usbpipe.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 "channel.h"
Forest Bond92b96792009-06-13 07:38:31 -040055#include "iowpa.h"
Forest Bond92b96792009-06-13 07:38:31 -040056
Nandini Hanumanthagowdaebd381d2013-11-03 18:30:52 +053057static int msglevel = MSG_LEVEL_INFO;
58//static int msglevel = MSG_LEVEL_DEBUG;
Forest Bond92b96792009-06-13 07:38:31 -040059
Malcolm Priestley98583c02012-12-10 22:01:23 +000060static void s_vProbeChannel(struct vnt_private *);
61
62static struct vnt_tx_mgmt *s_MgrMakeProbeRequest(struct vnt_private *,
63 struct vnt_manager *pMgmt, u8 *pScanBSSID, PWLAN_IE_SSID pSSID,
64 PWLAN_IE_SUPP_RATES pCurrRates, PWLAN_IE_SUPP_RATES pCurrExtSuppRates);
Forest Bond92b96792009-06-13 07:38:31 -040065
Malcolm Priestley98583c02012-12-10 22:01:23 +000066static int s_bCommandComplete(struct vnt_private *);
Forest Bond92b96792009-06-13 07:38:31 -040067
Malcolm Priestley98583c02012-12-10 22:01:23 +000068static int s_bClearBSSID_SCAN(struct vnt_private *);
Forest Bond92b96792009-06-13 07:38:31 -040069
Forest Bond92b96792009-06-13 07:38:31 -040070/*
71 * Description:
72 * Stop AdHoc beacon during scan process
73 *
74 * Parameters:
75 * In:
76 * pDevice - Pointer to the adapter
77 * Out:
78 * none
79 *
80 * Return Value: none
81 *
82 */
Andres More0cbd8d92010-05-06 20:34:29 -030083
Malcolm Priestley98583c02012-12-10 22:01:23 +000084static void vAdHocBeaconStop(struct vnt_private *pDevice)
Forest Bond92b96792009-06-13 07:38:31 -040085{
Malcolm Priestley98583c02012-12-10 22:01:23 +000086 struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
87 int bStop;
Forest Bond92b96792009-06-13 07:38:31 -040088
Nandini Hanumanthagowda97d59f82013-11-12 23:05:36 +053089 /*
90 * temporarily stop Beacon packet for AdHoc Server
91 * if all of the following coditions are met:
92 * (1) STA is in AdHoc mode
93 * (2) VT3253 is programmed as automatic Beacon Transmitting
94 * (3) One of the following conditions is met
95 * (3.1) AdHoc channel is in B/G band and the
96 * current scan channel is in A band
97 * or
98 * (3.2) AdHoc channel is in A mode
99 */
100 bStop = false;
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530101 if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) &&
102 (pMgmt->eCurrState >= WMAC_STATE_STARTED)) {
103 if ((pMgmt->uIBSSChannel <= CB_MAX_CHANNEL_24G) &&
104 (pMgmt->uScanChannel > CB_MAX_CHANNEL_24G)) {
105 bStop = true;
106 }
107 if (pMgmt->uIBSSChannel > CB_MAX_CHANNEL_24G)
108 bStop = true;
109 }
Forest Bond92b96792009-06-13 07:38:31 -0400110
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530111 if (bStop) {
112 //PMESG(("STOP_BEACON: IBSSChannel = %u, ScanChannel = %u\n",
113 // pMgmt->uIBSSChannel, pMgmt->uScanChannel));
114 MACvRegBitsOff(pDevice, MAC_REG_TCR, TCR_AUTOBCNTX);
115 }
Forest Bond92b96792009-06-13 07:38:31 -0400116
117} /* vAdHocBeaconStop */
118
Forest Bond92b96792009-06-13 07:38:31 -0400119/*
120 * Description:
121 * Restart AdHoc beacon after scan process complete
122 *
123 * Parameters:
124 * In:
125 * pDevice - Pointer to the adapter
126 * Out:
127 * none
128 *
129 * Return Value: none
130 *
131 */
Malcolm Priestley98583c02012-12-10 22:01:23 +0000132static void vAdHocBeaconRestart(struct vnt_private *pDevice)
Forest Bond92b96792009-06-13 07:38:31 -0400133{
Malcolm Priestley98583c02012-12-10 22:01:23 +0000134 struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
Forest Bond92b96792009-06-13 07:38:31 -0400135
136 /*
137 * Restart Beacon packet for AdHoc Server
138 * if all of the following coditions are met:
139 * (1) STA is in AdHoc mode
140 * (2) VT3253 is programmed as automatic Beacon Transmitting
141 */
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530142 if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) &&
143 (pMgmt->eCurrState >= WMAC_STATE_STARTED)) {
144 //PMESG(("RESTART_BEACON\n"));
145 MACvRegBitsOn(pDevice, MAC_REG_TCR, TCR_AUTOBCNTX);
146 }
Forest Bond92b96792009-06-13 07:38:31 -0400147
148}
149
Forest Bond92b96792009-06-13 07:38:31 -0400150/*+
151 *
152 * Routine Description:
153 * Prepare and send probe request management frames.
154 *
155 *
156 * Return Value:
157 * none.
158 *
159-*/
160
Malcolm Priestley98583c02012-12-10 22:01:23 +0000161static void s_vProbeChannel(struct vnt_private *pDevice)
Forest Bond92b96792009-06-13 07:38:31 -0400162{
Malcolm Priestley98583c02012-12-10 22:01:23 +0000163 struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
164 struct vnt_tx_mgmt *pTxPacket;
165 u8 abyCurrSuppRatesG[] = {WLAN_EID_SUPP_RATES,
166 8, 0x02, 0x04, 0x0B, 0x16, 0x24, 0x30, 0x48, 0x6C};
167 /* 1M, 2M, 5M, 11M, 18M, 24M, 36M, 54M*/
168 u8 abyCurrExtSuppRatesG[] = {WLAN_EID_EXTSUPP_RATES,
169 4, 0x0C, 0x12, 0x18, 0x60};
170 /* 6M, 9M, 12M, 48M*/
171 u8 abyCurrSuppRatesA[] = {WLAN_EID_SUPP_RATES,
172 8, 0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C};
173 u8 abyCurrSuppRatesB[] = {WLAN_EID_SUPP_RATES,
174 4, 0x02, 0x04, 0x0B, 0x16};
175 u8 *pbyRate;
176 int ii;
Forest Bond92b96792009-06-13 07:38:31 -0400177
Nandini Hanumanthagowda566597a2013-11-12 23:05:30 +0530178 if (pDevice->byBBType == BB_TYPE_11A)
179 pbyRate = &abyCurrSuppRatesA[0];
180 else if (pDevice->byBBType == BB_TYPE_11B)
181 pbyRate = &abyCurrSuppRatesB[0];
182 else
183 pbyRate = &abyCurrSuppRatesG[0];
184
Nandini Hanumanthagowda97d59f82013-11-12 23:05:36 +0530185 // build an assocreq frame and send it
186 pTxPacket = s_MgrMakeProbeRequest
187 (
188 pDevice,
189 pMgmt,
190 pMgmt->abyScanBSSID,
191 (PWLAN_IE_SSID)pMgmt->abyScanSSID,
192 (PWLAN_IE_SUPP_RATES)pbyRate,
193 (PWLAN_IE_SUPP_RATES)abyCurrExtSuppRatesG
194 );
Forest Bond92b96792009-06-13 07:38:31 -0400195
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530196 if (pTxPacket != NULL) {
197 for (ii = 0; ii < 1; ii++) {
198 if (csMgmt_xmit(pDevice, pTxPacket) != CMD_STATUS_PENDING) {
199 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Probe request sending fail..\n");
200 } else {
201 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Probe request is sending..\n");
202 }
203 }
204 }
Forest Bond92b96792009-06-13 07:38:31 -0400205
206}
207
Forest Bond92b96792009-06-13 07:38:31 -0400208/*+
209 *
210 * Routine Description:
211 * Constructs an probe request frame
212 *
213 *
214 * Return Value:
Justin P. Mattocka0a1f612012-08-26 08:16:43 -0700215 * A ptr to Tx frame or NULL on allocation failure
Forest Bond92b96792009-06-13 07:38:31 -0400216 *
217-*/
218
Valentina Manea3b138852013-11-04 10:44:02 +0200219static struct vnt_tx_mgmt *s_MgrMakeProbeRequest(struct vnt_private *pDevice,
Malcolm Priestley98583c02012-12-10 22:01:23 +0000220 struct vnt_manager *pMgmt, u8 *pScanBSSID, PWLAN_IE_SSID pSSID,
221 PWLAN_IE_SUPP_RATES pCurrRates, PWLAN_IE_SUPP_RATES pCurrExtSuppRates)
Forest Bond92b96792009-06-13 07:38:31 -0400222{
Malcolm Priestley98583c02012-12-10 22:01:23 +0000223 struct vnt_tx_mgmt *pTxPacket = NULL;
224 WLAN_FR_PROBEREQ sFrame;
Forest Bond92b96792009-06-13 07:38:31 -0400225
Malcolm Priestley98583c02012-12-10 22:01:23 +0000226 pTxPacket = (struct vnt_tx_mgmt *)pMgmt->pbyMgmtPacketPool;
227 memset(pTxPacket, 0, sizeof(struct vnt_tx_mgmt)
228 + WLAN_PROBEREQ_FR_MAXLEN);
229 pTxPacket->p80211Header = (PUWLAN_80211HDR)((u8 *)pTxPacket
230 + sizeof(struct vnt_tx_mgmt));
Nandini Hanumanthagowda97d59f82013-11-12 23:05:36 +0530231 sFrame.pBuf = (u8 *)pTxPacket->p80211Header;
232 sFrame.len = WLAN_PROBEREQ_FR_MAXLEN;
233 vMgrEncodeProbeRequest(&sFrame);
234 sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16(
235 (
236 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) |
237 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_PROBEREQ)
238 ));
239 memcpy(sFrame.pHdr->sA3.abyAddr1, pScanBSSID, WLAN_ADDR_LEN);
240 memcpy(sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN);
241 memcpy(sFrame.pHdr->sA3.abyAddr3, pScanBSSID, WLAN_BSSID_LEN);
242 // Copy the SSID, pSSID->len=0 indicate broadcast SSID
243 sFrame.pSSID = (PWLAN_IE_SSID)(sFrame.pBuf + sFrame.len);
244 sFrame.len += pSSID->len + WLAN_IEHDR_LEN;
245 memcpy(sFrame.pSSID, pSSID, pSSID->len + WLAN_IEHDR_LEN);
246 sFrame.pSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len);
247 sFrame.len += pCurrRates->len + WLAN_IEHDR_LEN;
248 memcpy(sFrame.pSuppRates, pCurrRates, pCurrRates->len + WLAN_IEHDR_LEN);
249 // Copy the extension rate set
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530250 if (pDevice->byBBType == BB_TYPE_11G) {
251 sFrame.pExtSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len);
252 sFrame.len += pCurrExtSuppRates->len + WLAN_IEHDR_LEN;
253 memcpy(sFrame.pExtSuppRates, pCurrExtSuppRates, pCurrExtSuppRates->len + WLAN_IEHDR_LEN);
254 }
Nandini Hanumanthagowda97d59f82013-11-12 23:05:36 +0530255 pTxPacket->cbMPDULen = sFrame.len;
256 pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN;
Forest Bond92b96792009-06-13 07:38:31 -0400257
Nandini Hanumanthagowda97d59f82013-11-12 23:05:36 +0530258 return pTxPacket;
Forest Bond92b96792009-06-13 07:38:31 -0400259}
260
Valentina Manea3b138852013-11-04 10:44:02 +0200261static void
262vCommandTimerWait(struct vnt_private *pDevice, unsigned long MSecond)
Forest Bond92b96792009-06-13 07:38:31 -0400263{
Malcolm Priestley94488a72013-09-27 16:48:14 +0100264 schedule_delayed_work(&pDevice->run_command_work,
265 msecs_to_jiffies(MSecond));
Forest Bond92b96792009-06-13 07:38:31 -0400266}
267
Malcolm Priestley94488a72013-09-27 16:48:14 +0100268void vRunCommand(struct work_struct *work)
Forest Bond92b96792009-06-13 07:38:31 -0400269{
Malcolm Priestley94488a72013-09-27 16:48:14 +0100270 struct vnt_private *pDevice =
271 container_of(work, struct vnt_private, run_command_work.work);
Malcolm Priestley98583c02012-12-10 22:01:23 +0000272 struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
273 PWLAN_IE_SSID pItemSSID;
274 PWLAN_IE_SSID pItemSSIDCurr;
275 CMD_STATUS Status;
276 struct sk_buff *skb;
Malcolm Priestley0fdb56d2012-11-24 14:53:07 +0000277 union iwreq_data wrqu;
Malcolm Priestley98583c02012-12-10 22:01:23 +0000278 int ii;
279 u8 byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80};
280 u8 byData;
Malcolm Priestley97641ca2014-05-15 22:49:18 +0100281 unsigned long flags;
Forest Bond92b96792009-06-13 07:38:31 -0400282
Malcolm Priestley17f3ced2013-10-14 19:51:45 +0100283 if (pDevice->Flags & fMP_DISCONNECTED)
284 return;
285
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530286 if (pDevice->bCmdRunning != true)
287 return;
Forest Bond92b96792009-06-13 07:38:31 -0400288
Nandini Hanumanthagowda97d59f82013-11-12 23:05:36 +0530289 switch (pDevice->eCommandState) {
Forest Bond92b96792009-06-13 07:38:31 -0400290
Nandini Hanumanthagowda97d59f82013-11-12 23:05:36 +0530291 case WLAN_CMD_SCAN_START:
Forest Bond92b96792009-06-13 07:38:31 -0400292
293 pDevice->byReAssocCount = 0;
Malcolm Priestley2ae27772014-02-19 19:35:16 +0000294 if (pDevice->bRadioOff == true)
295 break;
Forest Bond92b96792009-06-13 07:38:31 -0400296
Malcolm Priestley2ae27772014-02-19 19:35:16 +0000297 if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP)
298 break;
Forest Bond92b96792009-06-13 07:38:31 -0400299
Nandini Hanumanthagowda97d59f82013-11-12 23:05:36 +0530300 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyScanSSID;
Forest Bond92b96792009-06-13 07:38:31 -0400301
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530302 if (pMgmt->uScanChannel == 0)
303 pMgmt->uScanChannel = pDevice->byMinChannel;
304 if (pMgmt->uScanChannel > pDevice->byMaxChannel) {
305 pDevice->eCommandState = WLAN_CMD_SCAN_END;
Malcolm Priestley2ae27772014-02-19 19:35:16 +0000306 break;
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530307 } else {
308 if (!ChannelValid(pDevice->byZoneType, pMgmt->uScanChannel)) {
309 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Invalid channel pMgmt->uScanChannel = %d\n", pMgmt->uScanChannel);
310 pMgmt->uScanChannel++;
Malcolm Priestley2ae27772014-02-19 19:35:16 +0000311 break;
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530312 }
313 if (pMgmt->uScanChannel == pDevice->byMinChannel) {
314 // pMgmt->eScanType = WMAC_SCAN_ACTIVE; //mike mark
315 pMgmt->abyScanBSSID[0] = 0xFF;
316 pMgmt->abyScanBSSID[1] = 0xFF;
317 pMgmt->abyScanBSSID[2] = 0xFF;
318 pMgmt->abyScanBSSID[3] = 0xFF;
319 pMgmt->abyScanBSSID[4] = 0xFF;
320 pMgmt->abyScanBSSID[5] = 0xFF;
321 pItemSSID->byElementID = WLAN_EID_SSID;
322 // clear bssid list
323 /* BSSvClearBSSList((void *) pDevice, pDevice->bLinkPass); */
324 pMgmt->eScanState = WMAC_IS_SCANNING;
325 pDevice->byScanBBType = pDevice->byBBType; //lucas
326 pDevice->bStopDataPkt = true;
327 // Turn off RCR_BSSID filter every time
328 MACvRegBitsOff(pDevice, MAC_REG_RCR, RCR_BSSID);
329 pDevice->byRxMode &= ~RCR_BSSID;
330 }
331 //lucas
332 vAdHocBeaconStop(pDevice);
333 if ((pDevice->byBBType != BB_TYPE_11A) &&
334 (pMgmt->uScanChannel > CB_MAX_CHANNEL_24G)) {
335 pDevice->byBBType = BB_TYPE_11A;
336 CARDvSetBSSMode(pDevice);
337 } else if ((pDevice->byBBType == BB_TYPE_11A) &&
338 (pMgmt->uScanChannel <= CB_MAX_CHANNEL_24G)) {
339 pDevice->byBBType = BB_TYPE_11G;
340 CARDvSetBSSMode(pDevice);
341 }
342 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Scanning.... channel: [%d]\n", pMgmt->uScanChannel);
343 // Set channel
344 CARDbSetMediaChannel(pDevice, pMgmt->uScanChannel);
345 // Set Baseband to be more sensitive.
Forest Bond92b96792009-06-13 07:38:31 -0400346
Malcolm Priestley9cade5a2014-05-17 09:50:39 +0100347 BBvSetShortSlotTime(pDevice);
348 BBvSetVGAGainOffset(pDevice, pDevice->abyBBVGA[0]);
349 BBvUpdatePreEDThreshold(pDevice, true);
350
Malcolm Priestley257f6582013-03-25 19:50:44 +0000351 pMgmt->uScanChannel++;
Forest Bond92b96792009-06-13 07:38:31 -0400352
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530353 while (!ChannelValid(pDevice->byZoneType, pMgmt->uScanChannel) &&
354 pMgmt->uScanChannel <= pDevice->byMaxChannel){
355 pMgmt->uScanChannel++;
356 }
Forest Bond92b96792009-06-13 07:38:31 -0400357
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530358 if (pMgmt->uScanChannel > pDevice->byMaxChannel) {
359 // Set Baseband to be not sensitive and rescan
360 pDevice->eCommandState = WLAN_CMD_SCAN_END;
361 }
362 if ((pMgmt->b11hEnable == false) ||
363 (pMgmt->uScanChannel < CB_MAX_CHANNEL_24G)) {
364 s_vProbeChannel(pDevice);
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530365 vCommandTimerWait((void *) pDevice, 100);
366 return;
367 } else {
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530368 vCommandTimerWait((void *) pDevice, WCMD_PASSIVE_SCAN_TIME);
369 return;
370 }
371 }
Forest Bond92b96792009-06-13 07:38:31 -0400372
Nandini Hanumanthagowda97d59f82013-11-12 23:05:36 +0530373 break;
Forest Bond92b96792009-06-13 07:38:31 -0400374
Nandini Hanumanthagowda97d59f82013-11-12 23:05:36 +0530375 case WLAN_CMD_SCAN_END:
Forest Bond92b96792009-06-13 07:38:31 -0400376
Nandini Hanumanthagowda97d59f82013-11-12 23:05:36 +0530377 // Set Baseband's sensitivity back.
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530378 if (pDevice->byBBType != pDevice->byScanBBType) {
379 pDevice->byBBType = pDevice->byScanBBType;
380 CARDvSetBSSMode(pDevice);
381 }
Forest Bond92b96792009-06-13 07:38:31 -0400382
Malcolm Priestley9cade5a2014-05-17 09:50:39 +0100383 BBvSetShortSlotTime(pDevice);
384 BBvSetVGAGainOffset(pDevice, pDevice->byBBVGACurrent);
385 BBvUpdatePreEDThreshold(pDevice, false);
Forest Bond92b96792009-06-13 07:38:31 -0400386
Nandini Hanumanthagowda97d59f82013-11-12 23:05:36 +0530387 // Set channel back
388 vAdHocBeaconRestart(pDevice);
389 // Set channel back
390 CARDbSetMediaChannel(pDevice, pMgmt->uCurrChannel);
391 // Set Filter
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530392 if (pMgmt->bCurrBSSIDFilterOn) {
393 MACvRegBitsOn(pDevice, MAC_REG_RCR, RCR_BSSID);
394 pDevice->byRxMode |= RCR_BSSID;
395 }
Nandini Hanumanthagowda97d59f82013-11-12 23:05:36 +0530396 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Scanning, set back to channel: [%d]\n", pMgmt->uCurrChannel);
Malcolm Priestley257f6582013-03-25 19:50:44 +0000397 pMgmt->uScanChannel = 0;
Nandini Hanumanthagowda97d59f82013-11-12 23:05:36 +0530398 pMgmt->eScanState = WMAC_NO_SCANNING;
399 pDevice->bStopDataPkt = false;
Andres More465711b2010-08-03 20:25:50 -0300400
Malcolm Priestley0fdb56d2012-11-24 14:53:07 +0000401 /*send scan event to wpa_Supplicant*/
402 PRINT_K("wireless_send_event--->SIOCGIWSCAN(scan done)\n");
403 memset(&wrqu, 0, sizeof(wrqu));
404 wireless_send_event(pDevice->dev, SIOCGIWSCAN, &wrqu, NULL);
405
Nandini Hanumanthagowda97d59f82013-11-12 23:05:36 +0530406 break;
Forest Bond92b96792009-06-13 07:38:31 -0400407
Nandini Hanumanthagowda97d59f82013-11-12 23:05:36 +0530408 case WLAN_CMD_DISASSOCIATE_START:
Forest Bond92b96792009-06-13 07:38:31 -0400409 pDevice->byReAssocCount = 0;
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530410 if ((pMgmt->eCurrMode == WMAC_MODE_ESS_STA) &&
411 (pMgmt->eCurrState != WMAC_STATE_ASSOC)) {
Malcolm Priestley2ae27772014-02-19 19:35:16 +0000412 break;
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530413 } else {
414 pDevice->bwextstep0 = false;
415 pDevice->bwextstep1 = false;
416 pDevice->bwextstep2 = false;
417 pDevice->bwextstep3 = false;
418 pDevice->bWPASuppWextEnabled = false;
419 pDevice->fWPA_Authened = false;
Forest Bond92b96792009-06-13 07:38:31 -0400420
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530421 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Send Disassociation Packet..\n");
422 // reason = 8 : disassoc because sta has left
423 vMgrDisassocBeginSta((void *) pDevice,
424 pMgmt,
425 pMgmt->abyCurrBSSID,
426 (8),
427 &Status);
428 pDevice->bLinkPass = false;
Malcolm Priestley96f69752014-05-26 13:59:04 +0100429
430 vnt_mac_set_led(pDevice, LEDSTS_STS, LEDSTS_SLOW);
431
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530432 // unlock command busy
433 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
434 pItemSSID->len = 0;
435 memset(pItemSSID->abySSID, 0, WLAN_SSID_MAXLEN);
436 pMgmt->eCurrState = WMAC_STATE_IDLE;
437 pMgmt->sNodeDBTable[0].bActive = false;
438// pDevice->bBeaconBufReady = false;
439 }
Nandini Hanumanthagowda97d59f82013-11-12 23:05:36 +0530440 netif_stop_queue(pDevice->dev);
441 if (pDevice->bNeedRadioOFF == true)
442 CARDbRadioPowerOff(pDevice);
Malcolm Priestley2ae27772014-02-19 19:35:16 +0000443
Nandini Hanumanthagowda97d59f82013-11-12 23:05:36 +0530444 break;
Forest Bond92b96792009-06-13 07:38:31 -0400445
Nandini Hanumanthagowda97d59f82013-11-12 23:05:36 +0530446 case WLAN_CMD_SSID_START:
Forest Bond92b96792009-06-13 07:38:31 -0400447
448 pDevice->byReAssocCount = 0;
Malcolm Priestley2ae27772014-02-19 19:35:16 +0000449 if (pDevice->bRadioOff == true)
450 break;
Forest Bond92b96792009-06-13 07:38:31 -0400451
Nandini Hanumanthagowda97d59f82013-11-12 23:05:36 +0530452 memcpy(pMgmt->abyAdHocSSID, pMgmt->abyDesireSSID,
453 ((PWLAN_IE_SSID)pMgmt->abyDesireSSID)->len + WLAN_IEHDR_LEN);
Andres More5926b9a2010-07-12 13:55:43 -0300454
Nandini Hanumanthagowda97d59f82013-11-12 23:05:36 +0530455 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID;
456 pItemSSIDCurr = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
457 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" cmd: desire ssid = %s\n", pItemSSID->abySSID);
458 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" cmd: curr ssid = %s\n", pItemSSIDCurr->abySSID);
Forest Bond92b96792009-06-13 07:38:31 -0400459
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530460 if (pMgmt->eCurrState == WMAC_STATE_ASSOC) {
461 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" Cmd pMgmt->eCurrState == WMAC_STATE_ASSOC\n");
462 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pItemSSID->len =%d\n", pItemSSID->len);
463 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pItemSSIDCurr->len = %d\n", pItemSSIDCurr->len);
464 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" desire ssid = %s\n", pItemSSID->abySSID);
465 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" curr ssid = %s\n", pItemSSIDCurr->abySSID);
466 }
Forest Bond92b96792009-06-13 07:38:31 -0400467
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530468 if ((pMgmt->eCurrState == WMAC_STATE_ASSOC) ||
469 ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) && (pMgmt->eCurrState == WMAC_STATE_JOINTED))) {
470 if (pItemSSID->len == pItemSSIDCurr->len) {
Malcolm Priestley2ae27772014-02-19 19:35:16 +0000471 if (!memcmp(pItemSSID->abySSID,
472 pItemSSIDCurr->abySSID, pItemSSID->len))
473 break;
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530474 }
475 netif_stop_queue(pDevice->dev);
476 pDevice->bLinkPass = false;
Malcolm Priestley96f69752014-05-26 13:59:04 +0100477
478 vnt_mac_set_led(pDevice, LEDSTS_STS, LEDSTS_SLOW);
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530479 }
Nandini Hanumanthagowda97d59f82013-11-12 23:05:36 +0530480 // set initial state
481 pMgmt->eCurrState = WMAC_STATE_IDLE;
482 pMgmt->eCurrMode = WMAC_MODE_STANDBY;
483 PSvDisablePowerSaving((void *) pDevice);
484 BSSvClearNodeDBTable(pDevice, 0);
485 vMgrJoinBSSBegin((void *) pDevice, &Status);
486 // if Infra mode
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530487 if ((pMgmt->eCurrMode == WMAC_MODE_ESS_STA) && (pMgmt->eCurrState == WMAC_STATE_JOINTED)) {
488 // Call mgr to begin the deauthentication
489 // reason = (3) because sta has left ESS
490 if (pMgmt->eCurrState >= WMAC_STATE_AUTH) {
491 vMgrDeAuthenBeginSta((void *)pDevice,
492 pMgmt,
493 pMgmt->abyCurrBSSID,
494 (3),
495 &Status);
496 }
497 // Call mgr to begin the authentication
498 vMgrAuthenBeginSta((void *) pDevice, pMgmt, &Status);
499 if (Status == CMD_STATUS_SUCCESS) {
500 pDevice->byLinkWaitCount = 0;
501 pDevice->eCommandState = WLAN_AUTHENTICATE_WAIT;
502 vCommandTimerWait((void *) pDevice, AUTHENTICATE_TIMEOUT);
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530503 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" Set eCommandState = WLAN_AUTHENTICATE_WAIT\n");
504 return;
505 }
506 }
507 // if Adhoc mode
508 else if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) {
509 if (pMgmt->eCurrState == WMAC_STATE_JOINTED) {
510 if (netif_queue_stopped(pDevice->dev))
511 netif_wake_queue(pDevice->dev);
512 pDevice->bLinkPass = true;
Malcolm Priestley96f69752014-05-26 13:59:04 +0100513
514 vnt_mac_set_led(pDevice, LEDSTS_STS, LEDSTS_INTER);
515
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530516 pMgmt->sNodeDBTable[0].bActive = true;
517 pMgmt->sNodeDBTable[0].uInActiveCount = 0;
518 } else {
519 // start own IBSS
520 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "CreateOwn IBSS by CurrMode = IBSS_STA\n");
521 vMgrCreateOwnIBSS((void *) pDevice, &Status);
522 if (Status != CMD_STATUS_SUCCESS) {
523 DBG_PRT(MSG_LEVEL_DEBUG,
524 KERN_INFO "WLAN_CMD_IBSS_CREATE fail!\n");
525 }
526 BSSvAddMulticastNode(pDevice);
527 }
528 s_bClearBSSID_SCAN(pDevice);
529 }
530 // if SSID not found
531 else if (pMgmt->eCurrMode == WMAC_MODE_STANDBY) {
532 if (pMgmt->eConfigMode == WMAC_CONFIG_IBSS_STA ||
533 pMgmt->eConfigMode == WMAC_CONFIG_AUTO) {
534 // start own IBSS
535 DBG_PRT(MSG_LEVEL_DEBUG,
536 KERN_INFO "CreateOwn IBSS by CurrMode = STANDBY\n");
537 vMgrCreateOwnIBSS((void *) pDevice, &Status);
538 if (Status != CMD_STATUS_SUCCESS) {
539 DBG_PRT(MSG_LEVEL_DEBUG,
540 KERN_INFO "WLAN_CMD_IBSS_CREATE fail!\n");
541 }
542 BSSvAddMulticastNode(pDevice);
543 s_bClearBSSID_SCAN(pDevice);
Forest Bond92b96792009-06-13 07:38:31 -0400544/*
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530545 pDevice->bLinkPass = true;
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530546 if (netif_queue_stopped(pDevice->dev)){
547 netif_wake_queue(pDevice->dev);
548 }
549 s_bClearBSSID_SCAN(pDevice);
Forest Bond92b96792009-06-13 07:38:31 -0400550*/
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530551 } else {
552 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disconnect SSID none\n");
553 // if(pDevice->bWPASuppWextEnabled == true)
554 {
555 union iwreq_data wrqu;
556 memset(&wrqu, 0, sizeof(wrqu));
557 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
558 PRINT_K("wireless_send_event--->SIOCGIWAP(disassociated:vMgrJoinBSSBegin Fail !!)\n");
559 wireless_send_event(pDevice->dev, SIOCGIWAP, &wrqu, NULL);
560 }
561 }
562 }
Nandini Hanumanthagowda97d59f82013-11-12 23:05:36 +0530563 break;
Forest Bond92b96792009-06-13 07:38:31 -0400564
Nandini Hanumanthagowda97d59f82013-11-12 23:05:36 +0530565 case WLAN_AUTHENTICATE_WAIT:
566 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState == WLAN_AUTHENTICATE_WAIT\n");
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530567 if (pMgmt->eCurrState == WMAC_STATE_AUTH) {
568 pDevice->byLinkWaitCount = 0;
569 // Call mgr to begin the association
570 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCurrState == WMAC_STATE_AUTH\n");
571 vMgrAssocBeginSta((void *) pDevice, pMgmt, &Status);
572 if (Status == CMD_STATUS_SUCCESS) {
573 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState = WLAN_ASSOCIATE_WAIT\n");
574 pDevice->byLinkWaitCount = 0;
575 pDevice->eCommandState = WLAN_ASSOCIATE_WAIT;
576 vCommandTimerWait((void *) pDevice, ASSOCIATE_TIMEOUT);
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530577 return;
578 }
579 } else if (pMgmt->eCurrState < WMAC_STATE_AUTHPENDING) {
580 printk("WLAN_AUTHENTICATE_WAIT:Authen Fail???\n");
Nandini Hanumanthagowdadf6b8512013-11-12 23:05:40 +0530581 } else if (pDevice->byLinkWaitCount <= 4) {
582 //mike add:wait another 2 sec if authenticated_frame delay!
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530583 pDevice->byLinkWaitCount++;
584 printk("WLAN_AUTHENTICATE_WAIT:wait %d times!!\n", pDevice->byLinkWaitCount);
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530585 vCommandTimerWait((void *) pDevice, AUTHENTICATE_TIMEOUT/2);
586 return;
587 }
Nandini Hanumanthagowda97d59f82013-11-12 23:05:36 +0530588 pDevice->byLinkWaitCount = 0;
Forest Bond92b96792009-06-13 07:38:31 -0400589
Nandini Hanumanthagowda97d59f82013-11-12 23:05:36 +0530590 break;
Forest Bond92b96792009-06-13 07:38:31 -0400591
Nandini Hanumanthagowda97d59f82013-11-12 23:05:36 +0530592 case WLAN_ASSOCIATE_WAIT:
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530593 if (pMgmt->eCurrState == WMAC_STATE_ASSOC) {
594 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCurrState == WMAC_STATE_ASSOC\n");
595 if (pDevice->ePSMode != WMAC_POWER_CAM) {
596 PSvEnablePowerSaving((void *) pDevice,
597 pMgmt->wListenInterval);
598 }
Forest Bond92b96792009-06-13 07:38:31 -0400599/*
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530600 if (pMgmt->eAuthenMode >= WMAC_AUTH_WPA) {
601 KeybRemoveAllKey(pDevice, &(pDevice->sKey), pDevice->abyBSSID);
602 }
Forest Bond92b96792009-06-13 07:38:31 -0400603*/
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530604 pDevice->byLinkWaitCount = 0;
605 pDevice->byReAssocCount = 0;
606 pDevice->bLinkPass = true;
Malcolm Priestley96f69752014-05-26 13:59:04 +0100607
608 vnt_mac_set_led(pDevice, LEDSTS_STS, LEDSTS_INTER);
609
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530610 s_bClearBSSID_SCAN(pDevice);
Forest Bond92b96792009-06-13 07:38:31 -0400611
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530612 if (netif_queue_stopped(pDevice->dev))
613 netif_wake_queue(pDevice->dev);
Forest Bond92b96792009-06-13 07:38:31 -0400614
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530615 } else if (pMgmt->eCurrState < WMAC_STATE_ASSOCPENDING) {
616 printk("WLAN_ASSOCIATE_WAIT:Association Fail???\n");
Nandini Hanumanthagowdadf6b8512013-11-12 23:05:40 +0530617 } else if (pDevice->byLinkWaitCount <= 4) {
618 //mike add:wait another 2 sec if associated_frame delay!
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530619 pDevice->byLinkWaitCount++;
620 printk("WLAN_ASSOCIATE_WAIT:wait %d times!!\n", pDevice->byLinkWaitCount);
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530621 vCommandTimerWait((void *) pDevice, ASSOCIATE_TIMEOUT/2);
622 return;
623 }
Forest Bond92b96792009-06-13 07:38:31 -0400624
Nandini Hanumanthagowda97d59f82013-11-12 23:05:36 +0530625 break;
Forest Bond92b96792009-06-13 07:38:31 -0400626
Nandini Hanumanthagowda97d59f82013-11-12 23:05:36 +0530627 case WLAN_CMD_AP_MODE_START:
Nandini Hanumanthagowda2eca4ea2013-11-12 23:05:38 +0530628 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState == WLAN_CMD_AP_MODE_START\n");
Forest Bond92b96792009-06-13 07:38:31 -0400629
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530630 if (pMgmt->eConfigMode == WMAC_CONFIG_AP) {
631 cancel_delayed_work_sync(&pDevice->second_callback_work);
632 pMgmt->eCurrState = WMAC_STATE_IDLE;
633 pMgmt->eCurrMode = WMAC_MODE_STANDBY;
634 pDevice->bLinkPass = false;
Malcolm Priestley96f69752014-05-26 13:59:04 +0100635
636 vnt_mac_set_led(pDevice, LEDSTS_STS, LEDSTS_SLOW);
Malcolm Priestley90f96ac2014-05-19 20:32:54 +0100637
638 BSSvClearNodeDBTable(pDevice, 0);
639
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530640 pDevice->uAssocCount = 0;
641 pMgmt->eCurrState = WMAC_STATE_IDLE;
642 pDevice->bFixRate = false;
Forest Bond92b96792009-06-13 07:38:31 -0400643
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530644 vMgrCreateOwnIBSS((void *) pDevice, &Status);
645 if (Status != CMD_STATUS_SUCCESS) {
646 DBG_PRT(MSG_LEVEL_DEBUG,
647 KERN_INFO "vMgrCreateOwnIBSS fail!\n");
648 }
649 // always turn off unicast bit
650 MACvRegBitsOff(pDevice, MAC_REG_RCR, RCR_UNICAST);
651 pDevice->byRxMode &= ~RCR_UNICAST;
652 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "wcmd: rx_mode = %x\n", pDevice->byRxMode);
653 BSSvAddMulticastNode(pDevice);
654 if (netif_queue_stopped(pDevice->dev))
655 netif_wake_queue(pDevice->dev);
656 pDevice->bLinkPass = true;
Malcolm Priestley96f69752014-05-26 13:59:04 +0100657
658 vnt_mac_set_led(pDevice, LEDSTS_STS, LEDSTS_INTER);
659
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530660 schedule_delayed_work(&pDevice->second_callback_work, HZ);
661 }
Nandini Hanumanthagowda2eca4ea2013-11-12 23:05:38 +0530662 break;
Forest Bond92b96792009-06-13 07:38:31 -0400663
Nandini Hanumanthagowda97d59f82013-11-12 23:05:36 +0530664 case WLAN_CMD_TX_PSPACKET_START:
665 // DTIM Multicast tx
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530666 if (pMgmt->sNodeDBTable[0].bRxPSPoll) {
667 while ((skb = skb_dequeue(&pMgmt->sNodeDBTable[0].sTxPSQueue)) != NULL) {
668 if (skb_queue_empty(&pMgmt->sNodeDBTable[0].sTxPSQueue)) {
669 pMgmt->abyPSTxMap[0] &= ~byMask[0];
670 pDevice->bMoreData = false;
671 } else {
672 pDevice->bMoreData = true;
673 }
Forest Bond92b96792009-06-13 07:38:31 -0400674
Malcolm Priestley97641ca2014-05-15 22:49:18 +0100675 spin_lock_irqsave(&pDevice->lock, flags);
676
Malcolm Priestley05cc6172014-04-30 21:31:12 +0100677 if (nsDMA_tx_packet(pDevice, skb) != 0)
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530678 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Multicast ps tx fail\n");
Forest Bond92b96792009-06-13 07:38:31 -0400679
Malcolm Priestley97641ca2014-05-15 22:49:18 +0100680 spin_unlock_irqrestore(&pDevice->lock, flags);
681
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530682 pMgmt->sNodeDBTable[0].wEnQueueCnt--;
683 }
684 }
Forest Bond92b96792009-06-13 07:38:31 -0400685
Nandini Hanumanthagowda2eca4ea2013-11-12 23:05:38 +0530686 // PS nodes tx
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530687 for (ii = 1; ii < (MAX_NODE_NUM + 1); ii++) {
688 if (pMgmt->sNodeDBTable[ii].bActive &&
689 pMgmt->sNodeDBTable[ii].bRxPSPoll) {
690 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Index=%d Enqueu Cnt= %d\n",
691 ii, pMgmt->sNodeDBTable[ii].wEnQueueCnt);
692 while ((skb = skb_dequeue(&pMgmt->sNodeDBTable[ii].sTxPSQueue)) != NULL) {
693 if (skb_queue_empty(&pMgmt->sNodeDBTable[ii].sTxPSQueue)) {
694 // clear tx map
695 pMgmt->abyPSTxMap[pMgmt->sNodeDBTable[ii].wAID >> 3] &=
696 ~byMask[pMgmt->sNodeDBTable[ii].wAID & 7];
697 pDevice->bMoreData = false;
698 } else {
699 pDevice->bMoreData = true;
700 }
Forest Bond92b96792009-06-13 07:38:31 -0400701
Malcolm Priestley97641ca2014-05-15 22:49:18 +0100702 spin_lock_irqsave(&pDevice->lock, flags);
703
Malcolm Priestley05cc6172014-04-30 21:31:12 +0100704 if (nsDMA_tx_packet(pDevice, skb) != 0)
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530705 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "sta ps tx fail\n");
Forest Bond92b96792009-06-13 07:38:31 -0400706
Malcolm Priestley97641ca2014-05-15 22:49:18 +0100707 spin_unlock_irqrestore(&pDevice->lock, flags);
708
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530709 pMgmt->sNodeDBTable[ii].wEnQueueCnt--;
710 // check if sta ps enable, wait next pspoll
711 // if sta ps disable, send all pending buffers.
712 if (pMgmt->sNodeDBTable[ii].bPSEnable)
713 break;
714 }
715 if (skb_queue_empty(&pMgmt->sNodeDBTable[ii].sTxPSQueue)) {
716 // clear tx map
717 pMgmt->abyPSTxMap[pMgmt->sNodeDBTable[ii].wAID >> 3] &=
718 ~byMask[pMgmt->sNodeDBTable[ii].wAID & 7];
719 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Index=%d PS queue clear\n", ii);
720 }
721 pMgmt->sNodeDBTable[ii].bRxPSPoll = false;
722 }
723 }
Nandini Hanumanthagowda97d59f82013-11-12 23:05:36 +0530724 break;
Forest Bond92b96792009-06-13 07:38:31 -0400725
Nandini Hanumanthagowda97d59f82013-11-12 23:05:36 +0530726 case WLAN_CMD_RADIO_START:
Forest Bond92b96792009-06-13 07:38:31 -0400727
Nandini Hanumanthagowda97d59f82013-11-12 23:05:36 +0530728 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState == WLAN_CMD_RADIO_START\n");
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530729// if (pDevice->bRadioCmd == true)
730// CARDbRadioPowerOn(pDevice);
731// else
732// CARDbRadioPowerOff(pDevice);
733 {
734 int ntStatus = STATUS_SUCCESS;
735 u8 byTmp;
Andres More465711b2010-08-03 20:25:50 -0300736
Malcolm Priestley441c21c2014-05-26 13:59:02 +0100737 ntStatus = vnt_control_in(pDevice,
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530738 MESSAGE_TYPE_READ,
739 MAC_REG_GPIOCTL1,
740 MESSAGE_REQUEST_MACREG,
741 1,
742 &byTmp);
Forest Bond92b96792009-06-13 07:38:31 -0400743
Malcolm Priestley2ae27772014-02-19 19:35:16 +0000744 if (ntStatus != STATUS_SUCCESS)
745 break;
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530746 if ((byTmp & GPIO3_DATA) == 0) {
747 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" WLAN_CMD_RADIO_START_OFF........................\n");
748 // Old commands are useless.
749 // empty command Q
750 pDevice->cbFreeCmdQueue = CMD_Q_SIZE;
751 pDevice->uCmdDequeueIdx = 0;
752 pDevice->uCmdEnqueueIdx = 0;
753 //0415pDevice->bCmdRunning = false;
754 pDevice->bCmdClear = true;
755 pDevice->bStopTx0Pkt = false;
756 pDevice->bStopDataPkt = true;
Forest Bond92b96792009-06-13 07:38:31 -0400757
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530758 pDevice->byKeyIndex = 0;
759 pDevice->bTransmitKey = false;
Malcolm Priestleyd1d41202014-05-15 22:49:13 +0100760
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530761 KeyvInitTable(pDevice, &pDevice->sKey);
Malcolm Priestleyd1d41202014-05-15 22:49:13 +0100762
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530763 pMgmt->byCSSPK = KEY_CTL_NONE;
764 pMgmt->byCSSGK = KEY_CTL_NONE;
Forest Bond92b96792009-06-13 07:38:31 -0400765
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530766 if (pDevice->bLinkPass == true) {
767 // reason = 8 : disassoc because sta has left
768 vMgrDisassocBeginSta((void *) pDevice,
769 pMgmt,
770 pMgmt->abyCurrBSSID,
771 (8),
772 &Status);
773 pDevice->bLinkPass = false;
774 // unlock command busy
775 pMgmt->eCurrState = WMAC_STATE_IDLE;
776 pMgmt->sNodeDBTable[0].bActive = false;
777 // if(pDevice->bWPASuppWextEnabled == true)
778 {
779 union iwreq_data wrqu;
780 memset(&wrqu, 0, sizeof(wrqu));
781 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
782 PRINT_K("wireless_send_event--->SIOCGIWAP(disassociated)\n");
783 wireless_send_event(pDevice->dev, SIOCGIWAP, &wrqu, NULL);
784 }
785 }
786 pDevice->bwextstep0 = false;
787 pDevice->bwextstep1 = false;
788 pDevice->bwextstep2 = false;
789 pDevice->bwextstep3 = false;
790 pDevice->bWPASuppWextEnabled = false;
791 //clear current SSID
792 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
793 pItemSSID->len = 0;
794 memset(pItemSSID->abySSID, 0, WLAN_SSID_MAXLEN);
795 //clear desired SSID
796 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID;
797 pItemSSID->len = 0;
798 memset(pItemSSID->abySSID, 0, WLAN_SSID_MAXLEN);
Forest Bond92b96792009-06-13 07:38:31 -0400799
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530800 netif_stop_queue(pDevice->dev);
801 CARDbRadioPowerOff(pDevice);
802 MACvRegBitsOn(pDevice, MAC_REG_GPIOCTL1, GPIO3_INTMD);
Malcolm Priestley96f69752014-05-26 13:59:04 +0100803
804 vnt_mac_set_led(pDevice, LEDSTS_STS, LEDSTS_OFF);
805
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530806 pDevice->bHWRadioOff = true;
807 } else {
808 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" WLAN_CMD_RADIO_START_ON........................\n");
809 pDevice->bHWRadioOff = false;
810 CARDbRadioPowerOn(pDevice);
811 MACvRegBitsOff(pDevice, MAC_REG_GPIOCTL1, GPIO3_INTMD);
Malcolm Priestley96f69752014-05-26 13:59:04 +0100812
813 vnt_mac_set_led(pDevice, LEDSTS_STS, LEDSTS_ON);
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530814 }
815 }
Forest Bond92b96792009-06-13 07:38:31 -0400816
Nandini Hanumanthagowda97d59f82013-11-12 23:05:36 +0530817 break;
Forest Bond92b96792009-06-13 07:38:31 -0400818
Nandini Hanumanthagowda97d59f82013-11-12 23:05:36 +0530819 case WLAN_CMD_CHANGE_BBSENSITIVITY_START:
Forest Bond92b96792009-06-13 07:38:31 -0400820
Nandini Hanumanthagowda97d59f82013-11-12 23:05:36 +0530821 pDevice->bStopDataPkt = true;
822 pDevice->byBBVGACurrent = pDevice->byBBVGANew;
823 BBvSetVGAGainOffset(pDevice, pDevice->byBBVGACurrent);
824 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Change sensitivity pDevice->byBBVGACurrent = %x\n", pDevice->byBBVGACurrent);
825 pDevice->bStopDataPkt = false;
Nandini Hanumanthagowda97d59f82013-11-12 23:05:36 +0530826 break;
Forest Bond92b96792009-06-13 07:38:31 -0400827
Nandini Hanumanthagowda97d59f82013-11-12 23:05:36 +0530828 case WLAN_CMD_TBTT_WAKEUP_START:
829 PSbIsNextTBTTWakeUp(pDevice);
Nandini Hanumanthagowda97d59f82013-11-12 23:05:36 +0530830 break;
Forest Bond92b96792009-06-13 07:38:31 -0400831
Nandini Hanumanthagowda97d59f82013-11-12 23:05:36 +0530832 case WLAN_CMD_BECON_SEND_START:
833 bMgrPrepareBeaconToSend(pDevice, pMgmt);
Nandini Hanumanthagowda97d59f82013-11-12 23:05:36 +0530834 break;
Forest Bond92b96792009-06-13 07:38:31 -0400835
Nandini Hanumanthagowda97d59f82013-11-12 23:05:36 +0530836 case WLAN_CMD_SETPOWER_START:
Forest Bond92b96792009-06-13 07:38:31 -0400837
Malcolm Priestley4f5290e2014-05-27 21:05:21 +0100838 vnt_rf_setpower(pDevice, pDevice->wCurrentRate,
839 pMgmt->uCurrChannel);
Forest Bond92b96792009-06-13 07:38:31 -0400840
Nandini Hanumanthagowda97d59f82013-11-12 23:05:36 +0530841 break;
Forest Bond92b96792009-06-13 07:38:31 -0400842
Nandini Hanumanthagowda97d59f82013-11-12 23:05:36 +0530843 case WLAN_CMD_CHANGE_ANTENNA_START:
844 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Change from Antenna%d to", (int)pDevice->dwRxAntennaSel);
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530845 if (pDevice->dwRxAntennaSel == 0) {
846 pDevice->dwRxAntennaSel = 1;
847 if (pDevice->bTxRxAntInv == true)
848 BBvSetAntennaMode(pDevice, ANT_RXA);
849 else
850 BBvSetAntennaMode(pDevice, ANT_RXB);
851 } else {
852 pDevice->dwRxAntennaSel = 0;
853 if (pDevice->bTxRxAntInv == true)
854 BBvSetAntennaMode(pDevice, ANT_RXB);
855 else
856 BBvSetAntennaMode(pDevice, ANT_RXA);
857 }
Nandini Hanumanthagowda97d59f82013-11-12 23:05:36 +0530858 break;
Forest Bond92b96792009-06-13 07:38:31 -0400859
Nandini Hanumanthagowda97d59f82013-11-12 23:05:36 +0530860 case WLAN_CMD_REMOVE_ALLKEY_START:
861 KeybRemoveAllKey(pDevice, &(pDevice->sKey), pDevice->abyBSSID);
Nandini Hanumanthagowda97d59f82013-11-12 23:05:36 +0530862 break;
Forest Bond92b96792009-06-13 07:38:31 -0400863
Nandini Hanumanthagowda97d59f82013-11-12 23:05:36 +0530864 case WLAN_CMD_MAC_DISPOWERSAVING_START:
Malcolm Priestley53742902014-05-26 13:59:06 +0100865 vnt_control_in_u8(pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_PSCTL, &byData);
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530866 if ((byData & PSCTL_PS) != 0) {
867 // disable power saving hw function
Malcolm Priestley1390b022014-05-26 13:59:01 +0100868 vnt_control_out(pDevice,
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530869 MESSAGE_TYPE_DISABLE_PS,
870 0,
871 0,
872 0,
873 NULL
874 );
875 }
Nandini Hanumanthagowda97d59f82013-11-12 23:05:36 +0530876 break;
Forest Bond92b96792009-06-13 07:38:31 -0400877
Nandini Hanumanthagowda97d59f82013-11-12 23:05:36 +0530878 case WLAN_CMD_11H_CHSW_START:
879 CARDbSetMediaChannel(pDevice, pDevice->byNewChannel);
880 pDevice->bChannelSwitch = false;
881 pMgmt->uCurrChannel = pDevice->byNewChannel;
882 pDevice->bStopDataPkt = false;
Nandini Hanumanthagowda97d59f82013-11-12 23:05:36 +0530883 break;
Forest Bond92b96792009-06-13 07:38:31 -0400884
Malcolm Priestleyedd20e962014-02-19 19:34:18 +0000885 case WLAN_CMD_CONFIGURE_FILTER_START:
886 vnt_configure_filter(pDevice);
Malcolm Priestleyedd20e962014-02-19 19:34:18 +0000887 break;
Nandini Hanumanthagowda97d59f82013-11-12 23:05:36 +0530888 default:
Nandini Hanumanthagowda97d59f82013-11-12 23:05:36 +0530889 break;
890 } //switch
Forest Bond92b96792009-06-13 07:38:31 -0400891
Malcolm Priestley2ae27772014-02-19 19:35:16 +0000892 s_bCommandComplete(pDevice);
893
Nandini Hanumanthagowda97d59f82013-11-12 23:05:36 +0530894 return;
Forest Bond92b96792009-06-13 07:38:31 -0400895}
896
Malcolm Priestley98583c02012-12-10 22:01:23 +0000897static int s_bCommandComplete(struct vnt_private *pDevice)
Forest Bond92b96792009-06-13 07:38:31 -0400898{
Malcolm Priestley98583c02012-12-10 22:01:23 +0000899 struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
900 PWLAN_IE_SSID pSSID;
Andres Moree269fc22013-02-12 20:36:29 -0500901 int bRadioCmd = false;
Andres More4e9b5e22013-02-12 20:36:30 -0500902 int bForceSCAN = true;
Forest Bond92b96792009-06-13 07:38:31 -0400903
Nandini Hanumanthagowda97d59f82013-11-12 23:05:36 +0530904 pDevice->eCommandState = WLAN_CMD_IDLE;
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530905 if (pDevice->cbFreeCmdQueue == CMD_Q_SIZE) {
906 //Command Queue Empty
907 pDevice->bCmdRunning = false;
908 return true;
909 } else {
910 pDevice->eCommand = pDevice->eCmdQueue[pDevice->uCmdDequeueIdx].eCmd;
911 pSSID = (PWLAN_IE_SSID)pDevice->eCmdQueue[pDevice->uCmdDequeueIdx].abyCmdDesireSSID;
912 bRadioCmd = pDevice->eCmdQueue[pDevice->uCmdDequeueIdx].bRadioCmd;
913 bForceSCAN = pDevice->eCmdQueue[pDevice->uCmdDequeueIdx].bForceSCAN;
914 ADD_ONE_WITH_WRAP_AROUND(pDevice->uCmdDequeueIdx, CMD_Q_SIZE);
915 pDevice->cbFreeCmdQueue++;
916 pDevice->bCmdRunning = true;
917 switch (pDevice->eCommand) {
918 case WLAN_CMD_BSSID_SCAN:
919 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState= WLAN_CMD_BSSID_SCAN\n");
920 pDevice->eCommandState = WLAN_CMD_SCAN_START;
921 pMgmt->uScanChannel = 0;
922 if (pSSID->len != 0)
923 memcpy(pMgmt->abyScanSSID, pSSID, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
924 else
925 memset(pMgmt->abyScanSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
Forest Bond92b96792009-06-13 07:38:31 -0400926/*
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530927 if ((bForceSCAN == false) && (pDevice->bLinkPass == true)) {
928 if ((pSSID->len == ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->len) &&
929 ( !memcmp(pSSID->abySSID, ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->abySSID, pSSID->len))) {
930 pDevice->eCommandState = WLAN_CMD_IDLE;
931 }
932 }
Forest Bond92b96792009-06-13 07:38:31 -0400933*/
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530934 break;
935 case WLAN_CMD_SSID:
936 pDevice->eCommandState = WLAN_CMD_SSID_START;
937 if (pSSID->len > WLAN_SSID_MAXLEN)
938 pSSID->len = WLAN_SSID_MAXLEN;
939 if (pSSID->len != 0)
940 memcpy(pMgmt->abyDesireSSID, pSSID, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
941 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState= WLAN_CMD_SSID_START\n");
942 break;
943 case WLAN_CMD_DISASSOCIATE:
944 pDevice->eCommandState = WLAN_CMD_DISASSOCIATE_START;
945 break;
946 case WLAN_CMD_RX_PSPOLL:
947 pDevice->eCommandState = WLAN_CMD_TX_PSPACKET_START;
948 break;
949 case WLAN_CMD_RUN_AP:
950 pDevice->eCommandState = WLAN_CMD_AP_MODE_START;
951 break;
952 case WLAN_CMD_RADIO:
953 pDevice->eCommandState = WLAN_CMD_RADIO_START;
954 pDevice->bRadioCmd = bRadioCmd;
955 break;
956 case WLAN_CMD_CHANGE_BBSENSITIVITY:
957 pDevice->eCommandState = WLAN_CMD_CHANGE_BBSENSITIVITY_START;
958 break;
Forest Bond92b96792009-06-13 07:38:31 -0400959
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530960 case WLAN_CMD_TBTT_WAKEUP:
961 pDevice->eCommandState = WLAN_CMD_TBTT_WAKEUP_START;
962 break;
Forest Bond92b96792009-06-13 07:38:31 -0400963
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530964 case WLAN_CMD_BECON_SEND:
965 pDevice->eCommandState = WLAN_CMD_BECON_SEND_START;
966 break;
Forest Bond92b96792009-06-13 07:38:31 -0400967
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530968 case WLAN_CMD_SETPOWER:
969 pDevice->eCommandState = WLAN_CMD_SETPOWER_START;
970 break;
Forest Bond92b96792009-06-13 07:38:31 -0400971
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530972 case WLAN_CMD_CHANGE_ANTENNA:
973 pDevice->eCommandState = WLAN_CMD_CHANGE_ANTENNA_START;
974 break;
Forest Bond92b96792009-06-13 07:38:31 -0400975
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530976 case WLAN_CMD_REMOVE_ALLKEY:
977 pDevice->eCommandState = WLAN_CMD_REMOVE_ALLKEY_START;
978 break;
Forest Bond92b96792009-06-13 07:38:31 -0400979
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530980 case WLAN_CMD_MAC_DISPOWERSAVING:
981 pDevice->eCommandState = WLAN_CMD_MAC_DISPOWERSAVING_START;
982 break;
Forest Bond92b96792009-06-13 07:38:31 -0400983
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530984 case WLAN_CMD_11H_CHSW:
985 pDevice->eCommandState = WLAN_CMD_11H_CHSW_START;
986 break;
Forest Bond92b96792009-06-13 07:38:31 -0400987
Malcolm Priestleyedd20e962014-02-19 19:34:18 +0000988 case WLAN_CMD_CONFIGURE_FILTER:
989 pDevice->eCommandState =
990 WLAN_CMD_CONFIGURE_FILTER_START;
991 break;
992
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +0530993 default:
994 break;
995 }
996 vCommandTimerWait(pDevice, 0);
997 }
Forest Bond92b96792009-06-13 07:38:31 -0400998
Nandini Hanumanthagowda97d59f82013-11-12 23:05:36 +0530999 return true;
Forest Bond92b96792009-06-13 07:38:31 -04001000}
1001
Malcolm Priestley98583c02012-12-10 22:01:23 +00001002int bScheduleCommand(struct vnt_private *pDevice,
1003 CMD_CODE eCommand, u8 *pbyItem0)
Forest Bond92b96792009-06-13 07:38:31 -04001004{
Forest Bond92b96792009-06-13 07:38:31 -04001005
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +05301006 if (pDevice->cbFreeCmdQueue == 0)
Nandini Hanumanthagowda820c9b12013-11-12 23:05:37 +05301007 return false;
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +05301008 pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].eCmd = eCommand;
1009 pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].bForceSCAN = true;
1010 memset(pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].abyCmdDesireSSID, 0 , WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
1011 if (pbyItem0 != NULL) {
1012 switch (eCommand) {
1013 case WLAN_CMD_BSSID_SCAN:
1014 pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].bForceSCAN = false;
1015 memcpy(pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].abyCmdDesireSSID,
1016 pbyItem0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
1017 break;
Forest Bond92b96792009-06-13 07:38:31 -04001018
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +05301019 case WLAN_CMD_SSID:
1020 memcpy(pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].abyCmdDesireSSID,
1021 pbyItem0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
1022 break;
Forest Bond92b96792009-06-13 07:38:31 -04001023
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +05301024 case WLAN_CMD_DISASSOCIATE:
1025 pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].bNeedRadioOFF = *((int *)pbyItem0);
1026 break;
Forest Bond92b96792009-06-13 07:38:31 -04001027/*
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +05301028 case WLAN_CMD_DEAUTH:
1029 pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].wDeAuthenReason = *((u16 *)pbyItem0);
1030 break;
Forest Bond92b96792009-06-13 07:38:31 -04001031*/
1032
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +05301033 case WLAN_CMD_RADIO:
1034 pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].bRadioCmd = *((int *)pbyItem0);
1035 break;
Forest Bond92b96792009-06-13 07:38:31 -04001036
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +05301037 default:
1038 break;
1039 }
1040 }
Forest Bond92b96792009-06-13 07:38:31 -04001041
Nandini Hanumanthagowda97d59f82013-11-12 23:05:36 +05301042 ADD_ONE_WITH_WRAP_AROUND(pDevice->uCmdEnqueueIdx, CMD_Q_SIZE);
1043 pDevice->cbFreeCmdQueue--;
Forest Bond92b96792009-06-13 07:38:31 -04001044
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +05301045 if (pDevice->bCmdRunning == false)
1046 s_bCommandComplete(pDevice);
Nandini Hanumanthagowda566597a2013-11-12 23:05:30 +05301047
Nandini Hanumanthagowda820c9b12013-11-12 23:05:37 +05301048 return true;
Forest Bond92b96792009-06-13 07:38:31 -04001049
1050}
1051
1052/*
1053 * Description:
1054 * Clear BSSID_SCAN cmd in CMD Queue
1055 *
1056 * Parameters:
1057 * In:
1058 * hDeviceContext - Pointer to the adapter
1059 * eCommand - Command
1060 * Out:
1061 * none
1062 *
Andres More4e9b5e22013-02-12 20:36:30 -05001063 * Return Value: true if success; otherwise false
Forest Bond92b96792009-06-13 07:38:31 -04001064 *
1065 */
Malcolm Priestley98583c02012-12-10 22:01:23 +00001066static int s_bClearBSSID_SCAN(struct vnt_private *pDevice)
Forest Bond92b96792009-06-13 07:38:31 -04001067{
Malcolm Priestley98583c02012-12-10 22:01:23 +00001068 unsigned int uCmdDequeueIdx = pDevice->uCmdDequeueIdx;
1069 unsigned int ii;
Forest Bond92b96792009-06-13 07:38:31 -04001070
Nandini Hanumanthagowdacab086d2013-11-12 23:05:35 +05301071 if ((pDevice->cbFreeCmdQueue < CMD_Q_SIZE) && (uCmdDequeueIdx != pDevice->uCmdEnqueueIdx)) {
1072 for (ii = 0; ii < (CMD_Q_SIZE - pDevice->cbFreeCmdQueue); ii++) {
1073 if (pDevice->eCmdQueue[uCmdDequeueIdx].eCmd == WLAN_CMD_BSSID_SCAN)
1074 pDevice->eCmdQueue[uCmdDequeueIdx].eCmd = WLAN_CMD_IDLE;
1075 ADD_ONE_WITH_WRAP_AROUND(uCmdDequeueIdx, CMD_Q_SIZE);
1076 if (uCmdDequeueIdx == pDevice->uCmdEnqueueIdx)
1077 break;
1078 }
1079 }
Nandini Hanumanthagowda97d59f82013-11-12 23:05:36 +05301080 return true;
Forest Bond92b96792009-06-13 07:38:31 -04001081}
1082
Forest Bond92b96792009-06-13 07:38:31 -04001083//mike add:reset command timer
Malcolm Priestley98583c02012-12-10 22:01:23 +00001084void vResetCommandTimer(struct vnt_private *pDevice)
Forest Bond92b96792009-06-13 07:38:31 -04001085{
Malcolm Priestley94488a72013-09-27 16:48:14 +01001086 cancel_delayed_work_sync(&pDevice->run_command_work);
Forest Bond92b96792009-06-13 07:38:31 -04001087
Devendra Naga3afe5f62012-07-14 02:07:18 +05451088 pDevice->cbFreeCmdQueue = CMD_Q_SIZE;
1089 pDevice->uCmdDequeueIdx = 0;
1090 pDevice->uCmdEnqueueIdx = 0;
1091 pDevice->eCommandState = WLAN_CMD_IDLE;
Andres Moree269fc22013-02-12 20:36:29 -05001092 pDevice->bCmdRunning = false;
1093 pDevice->bCmdClear = false;
Forest Bond92b96792009-06-13 07:38:31 -04001094}