video: Kconfig: move drm and fb into separate menus
[linux-2.6/btrfs-unstable.git] / drivers / staging / vt6656 / wcmd.c
blob3cf3f24247a3f847d59be8dc702dbf831fe098e5
1 /*
2 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
3 * All rights reserved.
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.
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.
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.
19 * File: wcmd.c
21 * Purpose: Handles the management command interface functions
23 * Author: Lyndon Chen
25 * Date: May 8, 2003
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
37 * Revision History:
41 #include "tmacro.h"
42 #include "device.h"
43 #include "mac.h"
44 #include "card.h"
45 #include "80211hdr.h"
46 #include "wcmd.h"
47 #include "wmgr.h"
48 #include "power.h"
49 #include "wctl.h"
50 #include "baseband.h"
51 #include "control.h"
52 #include "rxtx.h"
53 #include "rf.h"
54 #include "rndis.h"
55 #include "channel.h"
56 #include "iowpa.h"
58 static int msglevel = MSG_LEVEL_INFO;
59 //static int msglevel = MSG_LEVEL_DEBUG;
61 static void s_vProbeChannel(struct vnt_private *);
63 static 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);
67 static int s_bCommandComplete(struct vnt_private *);
69 static int s_bClearBSSID_SCAN(struct vnt_private *);
72 * Description:
73 * Stop AdHoc beacon during scan process
75 * Parameters:
76 * In:
77 * pDevice - Pointer to the adapter
78 * Out:
79 * none
81 * Return Value: none
85 static void vAdHocBeaconStop(struct vnt_private *pDevice)
87 struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
88 int bStop;
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
101 bStop = false;
102 if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) &&
103 (pMgmt->eCurrState >= WMAC_STATE_STARTED)) {
104 if ((pMgmt->uIBSSChannel <= CB_MAX_CHANNEL_24G) &&
105 (pMgmt->uScanChannel > CB_MAX_CHANNEL_24G)) {
106 bStop = true;
108 if (pMgmt->uIBSSChannel > CB_MAX_CHANNEL_24G)
109 bStop = true;
112 if (bStop) {
113 //PMESG(("STOP_BEACON: IBSSChannel = %u, ScanChannel = %u\n",
114 // pMgmt->uIBSSChannel, pMgmt->uScanChannel));
115 MACvRegBitsOff(pDevice, MAC_REG_TCR, TCR_AUTOBCNTX);
118 } /* vAdHocBeaconStop */
121 * Description:
122 * Restart AdHoc beacon after scan process complete
124 * Parameters:
125 * In:
126 * pDevice - Pointer to the adapter
127 * Out:
128 * none
130 * Return Value: none
133 static void vAdHocBeaconRestart(struct vnt_private *pDevice)
135 struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
138 * Restart Beacon packet for AdHoc Server
139 * if all of the following coditions are met:
140 * (1) STA is in AdHoc mode
141 * (2) VT3253 is programmed as automatic Beacon Transmitting
143 if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) &&
144 (pMgmt->eCurrState >= WMAC_STATE_STARTED)) {
145 //PMESG(("RESTART_BEACON\n"));
146 MACvRegBitsOn(pDevice, MAC_REG_TCR, TCR_AUTOBCNTX);
153 * Routine Description:
154 * Prepare and send probe request management frames.
157 * Return Value:
158 * none.
162 static void s_vProbeChannel(struct vnt_private *pDevice)
164 struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
165 struct vnt_tx_mgmt *pTxPacket;
166 u8 abyCurrSuppRatesG[] = {WLAN_EID_SUPP_RATES,
167 8, 0x02, 0x04, 0x0B, 0x16, 0x24, 0x30, 0x48, 0x6C};
168 /* 1M, 2M, 5M, 11M, 18M, 24M, 36M, 54M*/
169 u8 abyCurrExtSuppRatesG[] = {WLAN_EID_EXTSUPP_RATES,
170 4, 0x0C, 0x12, 0x18, 0x60};
171 /* 6M, 9M, 12M, 48M*/
172 u8 abyCurrSuppRatesA[] = {WLAN_EID_SUPP_RATES,
173 8, 0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C};
174 u8 abyCurrSuppRatesB[] = {WLAN_EID_SUPP_RATES,
175 4, 0x02, 0x04, 0x0B, 0x16};
176 u8 *pbyRate;
177 int ii;
179 if (pDevice->byBBType == BB_TYPE_11A)
180 pbyRate = &abyCurrSuppRatesA[0];
181 else if (pDevice->byBBType == BB_TYPE_11B)
182 pbyRate = &abyCurrSuppRatesB[0];
183 else
184 pbyRate = &abyCurrSuppRatesG[0];
186 // build an assocreq frame and send it
187 pTxPacket = s_MgrMakeProbeRequest
189 pDevice,
190 pMgmt,
191 pMgmt->abyScanBSSID,
192 (PWLAN_IE_SSID)pMgmt->abyScanSSID,
193 (PWLAN_IE_SUPP_RATES)pbyRate,
194 (PWLAN_IE_SUPP_RATES)abyCurrExtSuppRatesG
197 if (pTxPacket != NULL) {
198 for (ii = 0; ii < 1; ii++) {
199 if (csMgmt_xmit(pDevice, pTxPacket) != CMD_STATUS_PENDING) {
200 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Probe request sending fail..\n");
201 } else {
202 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Probe request is sending..\n");
211 * Routine Description:
212 * Constructs an probe request frame
215 * Return Value:
216 * A ptr to Tx frame or NULL on allocation failure
220 static struct vnt_tx_mgmt *s_MgrMakeProbeRequest(struct vnt_private *pDevice,
221 struct vnt_manager *pMgmt, u8 *pScanBSSID, PWLAN_IE_SSID pSSID,
222 PWLAN_IE_SUPP_RATES pCurrRates, PWLAN_IE_SUPP_RATES pCurrExtSuppRates)
224 struct vnt_tx_mgmt *pTxPacket = NULL;
225 WLAN_FR_PROBEREQ sFrame;
227 pTxPacket = (struct vnt_tx_mgmt *)pMgmt->pbyMgmtPacketPool;
228 memset(pTxPacket, 0, sizeof(struct vnt_tx_mgmt)
229 + WLAN_PROBEREQ_FR_MAXLEN);
230 pTxPacket->p80211Header = (PUWLAN_80211HDR)((u8 *)pTxPacket
231 + sizeof(struct vnt_tx_mgmt));
232 sFrame.pBuf = (u8 *)pTxPacket->p80211Header;
233 sFrame.len = WLAN_PROBEREQ_FR_MAXLEN;
234 vMgrEncodeProbeRequest(&sFrame);
235 sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16(
237 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) |
238 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_PROBEREQ)
240 memcpy(sFrame.pHdr->sA3.abyAddr1, pScanBSSID, WLAN_ADDR_LEN);
241 memcpy(sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN);
242 memcpy(sFrame.pHdr->sA3.abyAddr3, pScanBSSID, WLAN_BSSID_LEN);
243 // Copy the SSID, pSSID->len=0 indicate broadcast SSID
244 sFrame.pSSID = (PWLAN_IE_SSID)(sFrame.pBuf + sFrame.len);
245 sFrame.len += pSSID->len + WLAN_IEHDR_LEN;
246 memcpy(sFrame.pSSID, pSSID, pSSID->len + WLAN_IEHDR_LEN);
247 sFrame.pSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len);
248 sFrame.len += pCurrRates->len + WLAN_IEHDR_LEN;
249 memcpy(sFrame.pSuppRates, pCurrRates, pCurrRates->len + WLAN_IEHDR_LEN);
250 // Copy the extension rate set
251 if (pDevice->byBBType == BB_TYPE_11G) {
252 sFrame.pExtSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len);
253 sFrame.len += pCurrExtSuppRates->len + WLAN_IEHDR_LEN;
254 memcpy(sFrame.pExtSuppRates, pCurrExtSuppRates, pCurrExtSuppRates->len + WLAN_IEHDR_LEN);
256 pTxPacket->cbMPDULen = sFrame.len;
257 pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN;
259 return pTxPacket;
262 static void
263 vCommandTimerWait(struct vnt_private *pDevice, unsigned long MSecond)
265 schedule_delayed_work(&pDevice->run_command_work,
266 msecs_to_jiffies(MSecond));
269 void vRunCommand(struct work_struct *work)
271 struct vnt_private *pDevice =
272 container_of(work, struct vnt_private, run_command_work.work);
273 struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
274 PWLAN_IE_SSID pItemSSID;
275 PWLAN_IE_SSID pItemSSIDCurr;
276 CMD_STATUS Status;
277 struct sk_buff *skb;
278 union iwreq_data wrqu;
279 int ii;
280 u8 byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80};
281 u8 byData;
283 if (pDevice->Flags & fMP_DISCONNECTED)
284 return;
286 if (pDevice->bCmdRunning != true)
287 return;
289 spin_lock_irq(&pDevice->lock);
291 switch (pDevice->eCommandState) {
293 case WLAN_CMD_SCAN_START:
295 pDevice->byReAssocCount = 0;
296 if (pDevice->bRadioOff == true)
297 break;
299 if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP)
300 break;
302 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyScanSSID;
304 if (pMgmt->uScanChannel == 0)
305 pMgmt->uScanChannel = pDevice->byMinChannel;
306 if (pMgmt->uScanChannel > pDevice->byMaxChannel) {
307 pDevice->eCommandState = WLAN_CMD_SCAN_END;
308 break;
309 } else {
310 if (!ChannelValid(pDevice->byZoneType, pMgmt->uScanChannel)) {
311 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Invalid channel pMgmt->uScanChannel = %d\n", pMgmt->uScanChannel);
312 pMgmt->uScanChannel++;
313 break;
315 if (pMgmt->uScanChannel == pDevice->byMinChannel) {
316 // pMgmt->eScanType = WMAC_SCAN_ACTIVE; //mike mark
317 pMgmt->abyScanBSSID[0] = 0xFF;
318 pMgmt->abyScanBSSID[1] = 0xFF;
319 pMgmt->abyScanBSSID[2] = 0xFF;
320 pMgmt->abyScanBSSID[3] = 0xFF;
321 pMgmt->abyScanBSSID[4] = 0xFF;
322 pMgmt->abyScanBSSID[5] = 0xFF;
323 pItemSSID->byElementID = WLAN_EID_SSID;
324 // clear bssid list
325 /* BSSvClearBSSList((void *) pDevice, pDevice->bLinkPass); */
326 pMgmt->eScanState = WMAC_IS_SCANNING;
327 pDevice->byScanBBType = pDevice->byBBType; //lucas
328 pDevice->bStopDataPkt = true;
329 // Turn off RCR_BSSID filter every time
330 MACvRegBitsOff(pDevice, MAC_REG_RCR, RCR_BSSID);
331 pDevice->byRxMode &= ~RCR_BSSID;
333 //lucas
334 vAdHocBeaconStop(pDevice);
335 if ((pDevice->byBBType != BB_TYPE_11A) &&
336 (pMgmt->uScanChannel > CB_MAX_CHANNEL_24G)) {
337 pDevice->byBBType = BB_TYPE_11A;
338 CARDvSetBSSMode(pDevice);
339 } else if ((pDevice->byBBType == BB_TYPE_11A) &&
340 (pMgmt->uScanChannel <= CB_MAX_CHANNEL_24G)) {
341 pDevice->byBBType = BB_TYPE_11G;
342 CARDvSetBSSMode(pDevice);
344 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Scanning.... channel: [%d]\n", pMgmt->uScanChannel);
345 // Set channel
346 CARDbSetMediaChannel(pDevice, pMgmt->uScanChannel);
347 // Set Baseband to be more sensitive.
349 if (pDevice->bUpdateBBVGA) {
350 BBvSetShortSlotTime(pDevice);
351 BBvSetVGAGainOffset(pDevice, pDevice->abyBBVGA[0]);
352 BBvUpdatePreEDThreshold(pDevice, true);
354 pMgmt->uScanChannel++;
356 while (!ChannelValid(pDevice->byZoneType, pMgmt->uScanChannel) &&
357 pMgmt->uScanChannel <= pDevice->byMaxChannel){
358 pMgmt->uScanChannel++;
361 if (pMgmt->uScanChannel > pDevice->byMaxChannel) {
362 // Set Baseband to be not sensitive and rescan
363 pDevice->eCommandState = WLAN_CMD_SCAN_END;
365 if ((pMgmt->b11hEnable == false) ||
366 (pMgmt->uScanChannel < CB_MAX_CHANNEL_24G)) {
367 s_vProbeChannel(pDevice);
368 spin_unlock_irq(&pDevice->lock);
369 vCommandTimerWait((void *) pDevice, 100);
370 return;
371 } else {
372 spin_unlock_irq(&pDevice->lock);
373 vCommandTimerWait((void *) pDevice, WCMD_PASSIVE_SCAN_TIME);
374 return;
378 break;
380 case WLAN_CMD_SCAN_END:
382 // Set Baseband's sensitivity back.
383 if (pDevice->byBBType != pDevice->byScanBBType) {
384 pDevice->byBBType = pDevice->byScanBBType;
385 CARDvSetBSSMode(pDevice);
388 if (pDevice->bUpdateBBVGA) {
389 BBvSetShortSlotTime(pDevice);
390 BBvSetVGAGainOffset(pDevice, pDevice->byBBVGACurrent);
391 BBvUpdatePreEDThreshold(pDevice, false);
394 // Set channel back
395 vAdHocBeaconRestart(pDevice);
396 // Set channel back
397 CARDbSetMediaChannel(pDevice, pMgmt->uCurrChannel);
398 // Set Filter
399 if (pMgmt->bCurrBSSIDFilterOn) {
400 MACvRegBitsOn(pDevice, MAC_REG_RCR, RCR_BSSID);
401 pDevice->byRxMode |= RCR_BSSID;
403 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Scanning, set back to channel: [%d]\n", pMgmt->uCurrChannel);
404 pMgmt->uScanChannel = 0;
405 pMgmt->eScanState = WMAC_NO_SCANNING;
406 pDevice->bStopDataPkt = false;
408 /*send scan event to wpa_Supplicant*/
409 PRINT_K("wireless_send_event--->SIOCGIWSCAN(scan done)\n");
410 memset(&wrqu, 0, sizeof(wrqu));
411 wireless_send_event(pDevice->dev, SIOCGIWSCAN, &wrqu, NULL);
413 break;
415 case WLAN_CMD_DISASSOCIATE_START:
416 pDevice->byReAssocCount = 0;
417 if ((pMgmt->eCurrMode == WMAC_MODE_ESS_STA) &&
418 (pMgmt->eCurrState != WMAC_STATE_ASSOC)) {
419 break;
420 } else {
421 pDevice->bwextstep0 = false;
422 pDevice->bwextstep1 = false;
423 pDevice->bwextstep2 = false;
424 pDevice->bwextstep3 = false;
425 pDevice->bWPASuppWextEnabled = false;
426 pDevice->fWPA_Authened = false;
428 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Send Disassociation Packet..\n");
429 // reason = 8 : disassoc because sta has left
430 vMgrDisassocBeginSta((void *) pDevice,
431 pMgmt,
432 pMgmt->abyCurrBSSID,
433 (8),
434 &Status);
435 pDevice->bLinkPass = false;
436 ControlvMaskByte(pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_PAPEDELAY, LEDSTS_STS, LEDSTS_SLOW);
437 // unlock command busy
438 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
439 pItemSSID->len = 0;
440 memset(pItemSSID->abySSID, 0, WLAN_SSID_MAXLEN);
441 pMgmt->eCurrState = WMAC_STATE_IDLE;
442 pMgmt->sNodeDBTable[0].bActive = false;
443 // pDevice->bBeaconBufReady = false;
445 netif_stop_queue(pDevice->dev);
446 if (pDevice->bNeedRadioOFF == true)
447 CARDbRadioPowerOff(pDevice);
449 break;
451 case WLAN_CMD_SSID_START:
453 pDevice->byReAssocCount = 0;
454 if (pDevice->bRadioOff == true)
455 break;
457 memcpy(pMgmt->abyAdHocSSID, pMgmt->abyDesireSSID,
458 ((PWLAN_IE_SSID)pMgmt->abyDesireSSID)->len + WLAN_IEHDR_LEN);
460 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID;
461 pItemSSIDCurr = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
462 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" cmd: desire ssid = %s\n", pItemSSID->abySSID);
463 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" cmd: curr ssid = %s\n", pItemSSIDCurr->abySSID);
465 if (pMgmt->eCurrState == WMAC_STATE_ASSOC) {
466 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" Cmd pMgmt->eCurrState == WMAC_STATE_ASSOC\n");
467 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pItemSSID->len =%d\n", pItemSSID->len);
468 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pItemSSIDCurr->len = %d\n", pItemSSIDCurr->len);
469 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" desire ssid = %s\n", pItemSSID->abySSID);
470 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" curr ssid = %s\n", pItemSSIDCurr->abySSID);
473 if ((pMgmt->eCurrState == WMAC_STATE_ASSOC) ||
474 ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) && (pMgmt->eCurrState == WMAC_STATE_JOINTED))) {
475 if (pItemSSID->len == pItemSSIDCurr->len) {
476 if (!memcmp(pItemSSID->abySSID,
477 pItemSSIDCurr->abySSID, pItemSSID->len))
478 break;
480 netif_stop_queue(pDevice->dev);
481 pDevice->bLinkPass = false;
482 ControlvMaskByte(pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_PAPEDELAY, LEDSTS_STS, LEDSTS_SLOW);
484 // set initial state
485 pMgmt->eCurrState = WMAC_STATE_IDLE;
486 pMgmt->eCurrMode = WMAC_MODE_STANDBY;
487 PSvDisablePowerSaving((void *) pDevice);
488 BSSvClearNodeDBTable(pDevice, 0);
489 vMgrJoinBSSBegin((void *) pDevice, &Status);
490 // if Infra mode
491 if ((pMgmt->eCurrMode == WMAC_MODE_ESS_STA) && (pMgmt->eCurrState == WMAC_STATE_JOINTED)) {
492 // Call mgr to begin the deauthentication
493 // reason = (3) because sta has left ESS
494 if (pMgmt->eCurrState >= WMAC_STATE_AUTH) {
495 vMgrDeAuthenBeginSta((void *)pDevice,
496 pMgmt,
497 pMgmt->abyCurrBSSID,
498 (3),
499 &Status);
501 // Call mgr to begin the authentication
502 vMgrAuthenBeginSta((void *) pDevice, pMgmt, &Status);
503 if (Status == CMD_STATUS_SUCCESS) {
504 pDevice->byLinkWaitCount = 0;
505 pDevice->eCommandState = WLAN_AUTHENTICATE_WAIT;
506 vCommandTimerWait((void *) pDevice, AUTHENTICATE_TIMEOUT);
507 spin_unlock_irq(&pDevice->lock);
508 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" Set eCommandState = WLAN_AUTHENTICATE_WAIT\n");
509 return;
512 // if Adhoc mode
513 else if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) {
514 if (pMgmt->eCurrState == WMAC_STATE_JOINTED) {
515 if (netif_queue_stopped(pDevice->dev))
516 netif_wake_queue(pDevice->dev);
517 pDevice->bLinkPass = true;
518 ControlvMaskByte(pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_PAPEDELAY, LEDSTS_STS, LEDSTS_INTER);
519 pMgmt->sNodeDBTable[0].bActive = true;
520 pMgmt->sNodeDBTable[0].uInActiveCount = 0;
521 } else {
522 // start own IBSS
523 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "CreateOwn IBSS by CurrMode = IBSS_STA\n");
524 vMgrCreateOwnIBSS((void *) pDevice, &Status);
525 if (Status != CMD_STATUS_SUCCESS) {
526 DBG_PRT(MSG_LEVEL_DEBUG,
527 KERN_INFO "WLAN_CMD_IBSS_CREATE fail!\n");
529 BSSvAddMulticastNode(pDevice);
531 s_bClearBSSID_SCAN(pDevice);
533 // if SSID not found
534 else if (pMgmt->eCurrMode == WMAC_MODE_STANDBY) {
535 if (pMgmt->eConfigMode == WMAC_CONFIG_IBSS_STA ||
536 pMgmt->eConfigMode == WMAC_CONFIG_AUTO) {
537 // start own IBSS
538 DBG_PRT(MSG_LEVEL_DEBUG,
539 KERN_INFO "CreateOwn IBSS by CurrMode = STANDBY\n");
540 vMgrCreateOwnIBSS((void *) pDevice, &Status);
541 if (Status != CMD_STATUS_SUCCESS) {
542 DBG_PRT(MSG_LEVEL_DEBUG,
543 KERN_INFO "WLAN_CMD_IBSS_CREATE fail!\n");
545 BSSvAddMulticastNode(pDevice);
546 s_bClearBSSID_SCAN(pDevice);
548 pDevice->bLinkPass = true;
549 ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_INTER);
550 if (netif_queue_stopped(pDevice->dev)){
551 netif_wake_queue(pDevice->dev);
553 s_bClearBSSID_SCAN(pDevice);
555 } else {
556 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disconnect SSID none\n");
557 // if(pDevice->bWPASuppWextEnabled == true)
559 union iwreq_data wrqu;
560 memset(&wrqu, 0, sizeof(wrqu));
561 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
562 PRINT_K("wireless_send_event--->SIOCGIWAP(disassociated:vMgrJoinBSSBegin Fail !!)\n");
563 wireless_send_event(pDevice->dev, SIOCGIWAP, &wrqu, NULL);
567 break;
569 case WLAN_AUTHENTICATE_WAIT:
570 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState == WLAN_AUTHENTICATE_WAIT\n");
571 if (pMgmt->eCurrState == WMAC_STATE_AUTH) {
572 pDevice->byLinkWaitCount = 0;
573 // Call mgr to begin the association
574 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCurrState == WMAC_STATE_AUTH\n");
575 vMgrAssocBeginSta((void *) pDevice, pMgmt, &Status);
576 if (Status == CMD_STATUS_SUCCESS) {
577 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState = WLAN_ASSOCIATE_WAIT\n");
578 pDevice->byLinkWaitCount = 0;
579 pDevice->eCommandState = WLAN_ASSOCIATE_WAIT;
580 vCommandTimerWait((void *) pDevice, ASSOCIATE_TIMEOUT);
581 spin_unlock_irq(&pDevice->lock);
582 return;
584 } else if (pMgmt->eCurrState < WMAC_STATE_AUTHPENDING) {
585 printk("WLAN_AUTHENTICATE_WAIT:Authen Fail???\n");
586 } else if (pDevice->byLinkWaitCount <= 4) {
587 //mike add:wait another 2 sec if authenticated_frame delay!
588 pDevice->byLinkWaitCount++;
589 printk("WLAN_AUTHENTICATE_WAIT:wait %d times!!\n", pDevice->byLinkWaitCount);
590 spin_unlock_irq(&pDevice->lock);
591 vCommandTimerWait((void *) pDevice, AUTHENTICATE_TIMEOUT/2);
592 return;
594 pDevice->byLinkWaitCount = 0;
596 break;
598 case WLAN_ASSOCIATE_WAIT:
599 if (pMgmt->eCurrState == WMAC_STATE_ASSOC) {
600 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCurrState == WMAC_STATE_ASSOC\n");
601 if (pDevice->ePSMode != WMAC_POWER_CAM) {
602 PSvEnablePowerSaving((void *) pDevice,
603 pMgmt->wListenInterval);
606 if (pMgmt->eAuthenMode >= WMAC_AUTH_WPA) {
607 KeybRemoveAllKey(pDevice, &(pDevice->sKey), pDevice->abyBSSID);
610 pDevice->byLinkWaitCount = 0;
611 pDevice->byReAssocCount = 0;
612 pDevice->bLinkPass = true;
613 ControlvMaskByte(pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_PAPEDELAY, LEDSTS_STS, LEDSTS_INTER);
614 s_bClearBSSID_SCAN(pDevice);
616 if (netif_queue_stopped(pDevice->dev))
617 netif_wake_queue(pDevice->dev);
619 } else if (pMgmt->eCurrState < WMAC_STATE_ASSOCPENDING) {
620 printk("WLAN_ASSOCIATE_WAIT:Association Fail???\n");
621 } else if (pDevice->byLinkWaitCount <= 4) {
622 //mike add:wait another 2 sec if associated_frame delay!
623 pDevice->byLinkWaitCount++;
624 printk("WLAN_ASSOCIATE_WAIT:wait %d times!!\n", pDevice->byLinkWaitCount);
625 spin_unlock_irq(&pDevice->lock);
626 vCommandTimerWait((void *) pDevice, ASSOCIATE_TIMEOUT/2);
627 return;
630 break;
632 case WLAN_CMD_AP_MODE_START:
633 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState == WLAN_CMD_AP_MODE_START\n");
635 if (pMgmt->eConfigMode == WMAC_CONFIG_AP) {
636 cancel_delayed_work_sync(&pDevice->second_callback_work);
637 pMgmt->eCurrState = WMAC_STATE_IDLE;
638 pMgmt->eCurrMode = WMAC_MODE_STANDBY;
639 pDevice->bLinkPass = false;
640 ControlvMaskByte(pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_PAPEDELAY, LEDSTS_STS, LEDSTS_SLOW);
641 if (pDevice->bEnableHostWEP == true)
642 BSSvClearNodeDBTable(pDevice, 1);
643 else
644 BSSvClearNodeDBTable(pDevice, 0);
645 pDevice->uAssocCount = 0;
646 pMgmt->eCurrState = WMAC_STATE_IDLE;
647 pDevice->bFixRate = false;
649 vMgrCreateOwnIBSS((void *) pDevice, &Status);
650 if (Status != CMD_STATUS_SUCCESS) {
651 DBG_PRT(MSG_LEVEL_DEBUG,
652 KERN_INFO "vMgrCreateOwnIBSS fail!\n");
654 // always turn off unicast bit
655 MACvRegBitsOff(pDevice, MAC_REG_RCR, RCR_UNICAST);
656 pDevice->byRxMode &= ~RCR_UNICAST;
657 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "wcmd: rx_mode = %x\n", pDevice->byRxMode);
658 BSSvAddMulticastNode(pDevice);
659 if (netif_queue_stopped(pDevice->dev))
660 netif_wake_queue(pDevice->dev);
661 pDevice->bLinkPass = true;
662 ControlvMaskByte(pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_PAPEDELAY, LEDSTS_STS, LEDSTS_INTER);
663 schedule_delayed_work(&pDevice->second_callback_work, HZ);
665 break;
667 case WLAN_CMD_TX_PSPACKET_START:
668 // DTIM Multicast tx
669 if (pMgmt->sNodeDBTable[0].bRxPSPoll) {
670 while ((skb = skb_dequeue(&pMgmt->sNodeDBTable[0].sTxPSQueue)) != NULL) {
671 if (skb_queue_empty(&pMgmt->sNodeDBTable[0].sTxPSQueue)) {
672 pMgmt->abyPSTxMap[0] &= ~byMask[0];
673 pDevice->bMoreData = false;
674 } else {
675 pDevice->bMoreData = true;
678 if (nsDMA_tx_packet(pDevice, TYPE_AC0DMA, skb) != 0)
679 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Multicast ps tx fail\n");
681 pMgmt->sNodeDBTable[0].wEnQueueCnt--;
685 // PS nodes tx
686 for (ii = 1; ii < (MAX_NODE_NUM + 1); ii++) {
687 if (pMgmt->sNodeDBTable[ii].bActive &&
688 pMgmt->sNodeDBTable[ii].bRxPSPoll) {
689 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Index=%d Enqueu Cnt= %d\n",
690 ii, pMgmt->sNodeDBTable[ii].wEnQueueCnt);
691 while ((skb = skb_dequeue(&pMgmt->sNodeDBTable[ii].sTxPSQueue)) != NULL) {
692 if (skb_queue_empty(&pMgmt->sNodeDBTable[ii].sTxPSQueue)) {
693 // clear tx map
694 pMgmt->abyPSTxMap[pMgmt->sNodeDBTable[ii].wAID >> 3] &=
695 ~byMask[pMgmt->sNodeDBTable[ii].wAID & 7];
696 pDevice->bMoreData = false;
697 } else {
698 pDevice->bMoreData = true;
701 if (nsDMA_tx_packet(pDevice, TYPE_AC0DMA, skb) != 0)
702 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "sta ps tx fail\n");
704 pMgmt->sNodeDBTable[ii].wEnQueueCnt--;
705 // check if sta ps enable, wait next pspoll
706 // if sta ps disable, send all pending buffers.
707 if (pMgmt->sNodeDBTable[ii].bPSEnable)
708 break;
710 if (skb_queue_empty(&pMgmt->sNodeDBTable[ii].sTxPSQueue)) {
711 // clear tx map
712 pMgmt->abyPSTxMap[pMgmt->sNodeDBTable[ii].wAID >> 3] &=
713 ~byMask[pMgmt->sNodeDBTable[ii].wAID & 7];
714 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Index=%d PS queue clear\n", ii);
716 pMgmt->sNodeDBTable[ii].bRxPSPoll = false;
719 break;
721 case WLAN_CMD_RADIO_START:
723 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState == WLAN_CMD_RADIO_START\n");
724 // if (pDevice->bRadioCmd == true)
725 // CARDbRadioPowerOn(pDevice);
726 // else
727 // CARDbRadioPowerOff(pDevice);
729 int ntStatus = STATUS_SUCCESS;
730 u8 byTmp;
732 ntStatus = CONTROLnsRequestIn(pDevice,
733 MESSAGE_TYPE_READ,
734 MAC_REG_GPIOCTL1,
735 MESSAGE_REQUEST_MACREG,
737 &byTmp);
739 if (ntStatus != STATUS_SUCCESS)
740 break;
741 if ((byTmp & GPIO3_DATA) == 0) {
742 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" WLAN_CMD_RADIO_START_OFF........................\n");
743 // Old commands are useless.
744 // empty command Q
745 pDevice->cbFreeCmdQueue = CMD_Q_SIZE;
746 pDevice->uCmdDequeueIdx = 0;
747 pDevice->uCmdEnqueueIdx = 0;
748 //0415pDevice->bCmdRunning = false;
749 pDevice->bCmdClear = true;
750 pDevice->bStopTx0Pkt = false;
751 pDevice->bStopDataPkt = true;
753 pDevice->byKeyIndex = 0;
754 pDevice->bTransmitKey = false;
755 spin_unlock_irq(&pDevice->lock);
756 KeyvInitTable(pDevice, &pDevice->sKey);
757 spin_lock_irq(&pDevice->lock);
758 pMgmt->byCSSPK = KEY_CTL_NONE;
759 pMgmt->byCSSGK = KEY_CTL_NONE;
761 if (pDevice->bLinkPass == true) {
762 // reason = 8 : disassoc because sta has left
763 vMgrDisassocBeginSta((void *) pDevice,
764 pMgmt,
765 pMgmt->abyCurrBSSID,
766 (8),
767 &Status);
768 pDevice->bLinkPass = false;
769 // unlock command busy
770 pMgmt->eCurrState = WMAC_STATE_IDLE;
771 pMgmt->sNodeDBTable[0].bActive = false;
772 // if(pDevice->bWPASuppWextEnabled == true)
774 union iwreq_data wrqu;
775 memset(&wrqu, 0, sizeof(wrqu));
776 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
777 PRINT_K("wireless_send_event--->SIOCGIWAP(disassociated)\n");
778 wireless_send_event(pDevice->dev, SIOCGIWAP, &wrqu, NULL);
781 pDevice->bwextstep0 = false;
782 pDevice->bwextstep1 = false;
783 pDevice->bwextstep2 = false;
784 pDevice->bwextstep3 = false;
785 pDevice->bWPASuppWextEnabled = false;
786 //clear current SSID
787 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
788 pItemSSID->len = 0;
789 memset(pItemSSID->abySSID, 0, WLAN_SSID_MAXLEN);
790 //clear desired SSID
791 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID;
792 pItemSSID->len = 0;
793 memset(pItemSSID->abySSID, 0, WLAN_SSID_MAXLEN);
795 netif_stop_queue(pDevice->dev);
796 CARDbRadioPowerOff(pDevice);
797 MACvRegBitsOn(pDevice, MAC_REG_GPIOCTL1, GPIO3_INTMD);
798 ControlvMaskByte(pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_PAPEDELAY, LEDSTS_STS, LEDSTS_OFF);
799 pDevice->bHWRadioOff = true;
800 } else {
801 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" WLAN_CMD_RADIO_START_ON........................\n");
802 pDevice->bHWRadioOff = false;
803 CARDbRadioPowerOn(pDevice);
804 MACvRegBitsOff(pDevice, MAC_REG_GPIOCTL1, GPIO3_INTMD);
805 ControlvMaskByte(pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_PAPEDELAY, LEDSTS_STS, LEDSTS_ON);
809 break;
811 case WLAN_CMD_CHANGE_BBSENSITIVITY_START:
813 pDevice->bStopDataPkt = true;
814 pDevice->byBBVGACurrent = pDevice->byBBVGANew;
815 BBvSetVGAGainOffset(pDevice, pDevice->byBBVGACurrent);
816 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Change sensitivity pDevice->byBBVGACurrent = %x\n", pDevice->byBBVGACurrent);
817 pDevice->bStopDataPkt = false;
818 break;
820 case WLAN_CMD_TBTT_WAKEUP_START:
821 PSbIsNextTBTTWakeUp(pDevice);
822 break;
824 case WLAN_CMD_BECON_SEND_START:
825 bMgrPrepareBeaconToSend(pDevice, pMgmt);
826 break;
828 case WLAN_CMD_SETPOWER_START:
830 RFbSetPower(pDevice, pDevice->wCurrentRate, pMgmt->uCurrChannel);
832 break;
834 case WLAN_CMD_CHANGE_ANTENNA_START:
835 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Change from Antenna%d to", (int)pDevice->dwRxAntennaSel);
836 if (pDevice->dwRxAntennaSel == 0) {
837 pDevice->dwRxAntennaSel = 1;
838 if (pDevice->bTxRxAntInv == true)
839 BBvSetAntennaMode(pDevice, ANT_RXA);
840 else
841 BBvSetAntennaMode(pDevice, ANT_RXB);
842 } else {
843 pDevice->dwRxAntennaSel = 0;
844 if (pDevice->bTxRxAntInv == true)
845 BBvSetAntennaMode(pDevice, ANT_RXB);
846 else
847 BBvSetAntennaMode(pDevice, ANT_RXA);
849 break;
851 case WLAN_CMD_REMOVE_ALLKEY_START:
852 KeybRemoveAllKey(pDevice, &(pDevice->sKey), pDevice->abyBSSID);
853 break;
855 case WLAN_CMD_MAC_DISPOWERSAVING_START:
856 ControlvReadByte(pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_PSCTL, &byData);
857 if ((byData & PSCTL_PS) != 0) {
858 // disable power saving hw function
859 CONTROLnsRequestOut(pDevice,
860 MESSAGE_TYPE_DISABLE_PS,
864 NULL
867 break;
869 case WLAN_CMD_11H_CHSW_START:
870 CARDbSetMediaChannel(pDevice, pDevice->byNewChannel);
871 pDevice->bChannelSwitch = false;
872 pMgmt->uCurrChannel = pDevice->byNewChannel;
873 pDevice->bStopDataPkt = false;
874 break;
876 case WLAN_CMD_CONFIGURE_FILTER_START:
877 vnt_configure_filter(pDevice);
878 break;
879 default:
880 break;
881 } //switch
883 s_bCommandComplete(pDevice);
885 spin_unlock_irq(&pDevice->lock);
886 return;
889 static int s_bCommandComplete(struct vnt_private *pDevice)
891 struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
892 PWLAN_IE_SSID pSSID;
893 int bRadioCmd = false;
894 int bForceSCAN = true;
896 pDevice->eCommandState = WLAN_CMD_IDLE;
897 if (pDevice->cbFreeCmdQueue == CMD_Q_SIZE) {
898 //Command Queue Empty
899 pDevice->bCmdRunning = false;
900 return true;
901 } else {
902 pDevice->eCommand = pDevice->eCmdQueue[pDevice->uCmdDequeueIdx].eCmd;
903 pSSID = (PWLAN_IE_SSID)pDevice->eCmdQueue[pDevice->uCmdDequeueIdx].abyCmdDesireSSID;
904 bRadioCmd = pDevice->eCmdQueue[pDevice->uCmdDequeueIdx].bRadioCmd;
905 bForceSCAN = pDevice->eCmdQueue[pDevice->uCmdDequeueIdx].bForceSCAN;
906 ADD_ONE_WITH_WRAP_AROUND(pDevice->uCmdDequeueIdx, CMD_Q_SIZE);
907 pDevice->cbFreeCmdQueue++;
908 pDevice->bCmdRunning = true;
909 switch (pDevice->eCommand) {
910 case WLAN_CMD_BSSID_SCAN:
911 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState= WLAN_CMD_BSSID_SCAN\n");
912 pDevice->eCommandState = WLAN_CMD_SCAN_START;
913 pMgmt->uScanChannel = 0;
914 if (pSSID->len != 0)
915 memcpy(pMgmt->abyScanSSID, pSSID, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
916 else
917 memset(pMgmt->abyScanSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
919 if ((bForceSCAN == false) && (pDevice->bLinkPass == true)) {
920 if ((pSSID->len == ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->len) &&
921 ( !memcmp(pSSID->abySSID, ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->abySSID, pSSID->len))) {
922 pDevice->eCommandState = WLAN_CMD_IDLE;
926 break;
927 case WLAN_CMD_SSID:
928 pDevice->eCommandState = WLAN_CMD_SSID_START;
929 if (pSSID->len > WLAN_SSID_MAXLEN)
930 pSSID->len = WLAN_SSID_MAXLEN;
931 if (pSSID->len != 0)
932 memcpy(pMgmt->abyDesireSSID, pSSID, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
933 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState= WLAN_CMD_SSID_START\n");
934 break;
935 case WLAN_CMD_DISASSOCIATE:
936 pDevice->eCommandState = WLAN_CMD_DISASSOCIATE_START;
937 break;
938 case WLAN_CMD_RX_PSPOLL:
939 pDevice->eCommandState = WLAN_CMD_TX_PSPACKET_START;
940 break;
941 case WLAN_CMD_RUN_AP:
942 pDevice->eCommandState = WLAN_CMD_AP_MODE_START;
943 break;
944 case WLAN_CMD_RADIO:
945 pDevice->eCommandState = WLAN_CMD_RADIO_START;
946 pDevice->bRadioCmd = bRadioCmd;
947 break;
948 case WLAN_CMD_CHANGE_BBSENSITIVITY:
949 pDevice->eCommandState = WLAN_CMD_CHANGE_BBSENSITIVITY_START;
950 break;
952 case WLAN_CMD_TBTT_WAKEUP:
953 pDevice->eCommandState = WLAN_CMD_TBTT_WAKEUP_START;
954 break;
956 case WLAN_CMD_BECON_SEND:
957 pDevice->eCommandState = WLAN_CMD_BECON_SEND_START;
958 break;
960 case WLAN_CMD_SETPOWER:
961 pDevice->eCommandState = WLAN_CMD_SETPOWER_START;
962 break;
964 case WLAN_CMD_CHANGE_ANTENNA:
965 pDevice->eCommandState = WLAN_CMD_CHANGE_ANTENNA_START;
966 break;
968 case WLAN_CMD_REMOVE_ALLKEY:
969 pDevice->eCommandState = WLAN_CMD_REMOVE_ALLKEY_START;
970 break;
972 case WLAN_CMD_MAC_DISPOWERSAVING:
973 pDevice->eCommandState = WLAN_CMD_MAC_DISPOWERSAVING_START;
974 break;
976 case WLAN_CMD_11H_CHSW:
977 pDevice->eCommandState = WLAN_CMD_11H_CHSW_START;
978 break;
980 case WLAN_CMD_CONFIGURE_FILTER:
981 pDevice->eCommandState =
982 WLAN_CMD_CONFIGURE_FILTER_START;
983 break;
985 default:
986 break;
988 vCommandTimerWait(pDevice, 0);
991 return true;
994 int bScheduleCommand(struct vnt_private *pDevice,
995 CMD_CODE eCommand, u8 *pbyItem0)
998 if (pDevice->cbFreeCmdQueue == 0)
999 return false;
1000 pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].eCmd = eCommand;
1001 pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].bForceSCAN = true;
1002 memset(pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].abyCmdDesireSSID, 0 , WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
1003 if (pbyItem0 != NULL) {
1004 switch (eCommand) {
1005 case WLAN_CMD_BSSID_SCAN:
1006 pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].bForceSCAN = false;
1007 memcpy(pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].abyCmdDesireSSID,
1008 pbyItem0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
1009 break;
1011 case WLAN_CMD_SSID:
1012 memcpy(pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].abyCmdDesireSSID,
1013 pbyItem0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
1014 break;
1016 case WLAN_CMD_DISASSOCIATE:
1017 pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].bNeedRadioOFF = *((int *)pbyItem0);
1018 break;
1020 case WLAN_CMD_DEAUTH:
1021 pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].wDeAuthenReason = *((u16 *)pbyItem0);
1022 break;
1025 case WLAN_CMD_RADIO:
1026 pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].bRadioCmd = *((int *)pbyItem0);
1027 break;
1029 default:
1030 break;
1034 ADD_ONE_WITH_WRAP_AROUND(pDevice->uCmdEnqueueIdx, CMD_Q_SIZE);
1035 pDevice->cbFreeCmdQueue--;
1037 if (pDevice->bCmdRunning == false)
1038 s_bCommandComplete(pDevice);
1040 return true;
1045 * Description:
1046 * Clear BSSID_SCAN cmd in CMD Queue
1048 * Parameters:
1049 * In:
1050 * hDeviceContext - Pointer to the adapter
1051 * eCommand - Command
1052 * Out:
1053 * none
1055 * Return Value: true if success; otherwise false
1058 static int s_bClearBSSID_SCAN(struct vnt_private *pDevice)
1060 unsigned int uCmdDequeueIdx = pDevice->uCmdDequeueIdx;
1061 unsigned int ii;
1063 if ((pDevice->cbFreeCmdQueue < CMD_Q_SIZE) && (uCmdDequeueIdx != pDevice->uCmdEnqueueIdx)) {
1064 for (ii = 0; ii < (CMD_Q_SIZE - pDevice->cbFreeCmdQueue); ii++) {
1065 if (pDevice->eCmdQueue[uCmdDequeueIdx].eCmd == WLAN_CMD_BSSID_SCAN)
1066 pDevice->eCmdQueue[uCmdDequeueIdx].eCmd = WLAN_CMD_IDLE;
1067 ADD_ONE_WITH_WRAP_AROUND(uCmdDequeueIdx, CMD_Q_SIZE);
1068 if (uCmdDequeueIdx == pDevice->uCmdEnqueueIdx)
1069 break;
1072 return true;
1075 //mike add:reset command timer
1076 void vResetCommandTimer(struct vnt_private *pDevice)
1078 cancel_delayed_work_sync(&pDevice->run_command_work);
1080 pDevice->cbFreeCmdQueue = CMD_Q_SIZE;
1081 pDevice->uCmdDequeueIdx = 0;
1082 pDevice->uCmdEnqueueIdx = 0;
1083 pDevice->eCommandState = WLAN_CMD_IDLE;
1084 pDevice->bCmdRunning = false;
1085 pDevice->bCmdClear = false;