2 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
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.
21 * Purpose: Handles the management command interface 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
59 /*--------------------- Static Definitions -------------------------*/
64 /*--------------------- Static Classes ----------------------------*/
66 /*--------------------- Static Variables --------------------------*/
67 static int msglevel =MSG_LEVEL_INFO;
68 //static int msglevel =MSG_LEVEL_DEBUG;
69 /*--------------------- Static Functions --------------------------*/
80 s_MgrMakeProbeRequest(
85 PWLAN_IE_SUPP_RATES pCurrRates,
86 PWLAN_IE_SUPP_RATES pCurrExtSuppRates
97 static BOOL s_bClearBSSID_SCAN(void *hDeviceContext);
99 /*--------------------- Export Variables --------------------------*/
101 /*--------------------- Export Functions --------------------------*/
105 * Stop AdHoc beacon during scan process
109 * pDevice - Pointer to the adapter
119 vAdHocBeaconStop(PSDevice pDevice)
122 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
126 * temporarily stop Beacon packet for AdHoc Server
127 * if all of the following coditions are met:
128 * (1) STA is in AdHoc mode
129 * (2) VT3253 is programmed as automatic Beacon Transmitting
130 * (3) One of the following conditions is met
131 * (3.1) AdHoc channel is in B/G band and the
132 * current scan channel is in A band
134 * (3.2) AdHoc channel is in A mode
137 if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) &&
138 (pMgmt->eCurrState >= WMAC_STATE_STARTED))
140 if ((pMgmt->uIBSSChannel <= CB_MAX_CHANNEL_24G) &&
141 (pMgmt->uScanChannel > CB_MAX_CHANNEL_24G))
145 if (pMgmt->uIBSSChannel > CB_MAX_CHANNEL_24G)
153 //PMESG(("STOP_BEACON: IBSSChannel = %u, ScanChannel = %u\n",
154 // pMgmt->uIBSSChannel, pMgmt->uScanChannel));
155 MACvRegBitsOff(pDevice, MAC_REG_TCR, TCR_AUTOBCNTX);
158 } /* vAdHocBeaconStop */
163 * Restart AdHoc beacon after scan process complete
167 * pDevice - Pointer to the adapter
176 vAdHocBeaconRestart(PSDevice pDevice)
178 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
181 * Restart Beacon packet for AdHoc Server
182 * if all of the following coditions are met:
183 * (1) STA is in AdHoc mode
184 * (2) VT3253 is programmed as automatic Beacon Transmitting
186 if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) &&
187 (pMgmt->eCurrState >= WMAC_STATE_STARTED))
189 //PMESG(("RESTART_BEACON\n"));
190 MACvRegBitsOn(pDevice, MAC_REG_TCR, TCR_AUTOBCNTX);
198 * Routine Description:
199 * Prepare and send probe request management frames.
213 //1M, 2M, 5M, 11M, 18M, 24M, 36M, 54M
214 BYTE abyCurrSuppRatesG[] = {WLAN_EID_SUPP_RATES, 8, 0x02, 0x04, 0x0B, 0x16, 0x24, 0x30, 0x48, 0x6C};
215 BYTE abyCurrExtSuppRatesG[] = {WLAN_EID_EXTSUPP_RATES, 4, 0x0C, 0x12, 0x18, 0x60};
217 BYTE abyCurrSuppRatesA[] = {WLAN_EID_SUPP_RATES, 8, 0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C};
218 BYTE abyCurrSuppRatesB[] = {WLAN_EID_SUPP_RATES, 4, 0x02, 0x04, 0x0B, 0x16};
220 PSTxMgmtPacket pTxPacket;
221 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
225 if (pDevice->byBBType == BB_TYPE_11A) {
226 pbyRate = &abyCurrSuppRatesA[0];
227 } else if (pDevice->byBBType == BB_TYPE_11B) {
228 pbyRate = &abyCurrSuppRatesB[0];
230 pbyRate = &abyCurrSuppRatesG[0];
232 // build an assocreq frame and send it
233 pTxPacket = s_MgrMakeProbeRequest
238 (PWLAN_IE_SSID)pMgmt->abyScanSSID,
239 (PWLAN_IE_SUPP_RATES)pbyRate,
240 (PWLAN_IE_SUPP_RATES)abyCurrExtSuppRatesG
243 if (pTxPacket != NULL ){
244 for (ii = 0; ii < 1 ; ii++) {
245 if (csMgmt_xmit(pDevice, pTxPacket) != CMD_STATUS_PENDING) {
246 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Probe request sending fail.. \n");
249 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Probe request is sending.. \n");
261 * Routine Description:
262 * Constructs an probe request frame
266 * A ptr to Tx frame or NULL on allocation failure
272 s_MgrMakeProbeRequest(
277 PWLAN_IE_SUPP_RATES pCurrRates,
278 PWLAN_IE_SUPP_RATES pCurrExtSuppRates
282 PSTxMgmtPacket pTxPacket = NULL;
283 WLAN_FR_PROBEREQ sFrame;
286 pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool;
287 memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_PROBEREQ_FR_MAXLEN);
288 pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket));
289 sFrame.pBuf = (PBYTE)pTxPacket->p80211Header;
290 sFrame.len = WLAN_PROBEREQ_FR_MAXLEN;
291 vMgrEncodeProbeRequest(&sFrame);
292 sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16(
294 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) |
295 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_PROBEREQ)
297 memcpy( sFrame.pHdr->sA3.abyAddr1, pScanBSSID, WLAN_ADDR_LEN);
298 memcpy( sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN);
299 memcpy( sFrame.pHdr->sA3.abyAddr3, pScanBSSID, WLAN_BSSID_LEN);
300 // Copy the SSID, pSSID->len=0 indicate broadcast SSID
301 sFrame.pSSID = (PWLAN_IE_SSID)(sFrame.pBuf + sFrame.len);
302 sFrame.len += pSSID->len + WLAN_IEHDR_LEN;
303 memcpy(sFrame.pSSID, pSSID, pSSID->len + WLAN_IEHDR_LEN);
304 sFrame.pSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len);
305 sFrame.len += pCurrRates->len + WLAN_IEHDR_LEN;
306 memcpy(sFrame.pSuppRates, pCurrRates, pCurrRates->len + WLAN_IEHDR_LEN);
307 // Copy the extension rate set
308 if (pDevice->byBBType == BB_TYPE_11G) {
309 sFrame.pExtSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len);
310 sFrame.len += pCurrExtSuppRates->len + WLAN_IEHDR_LEN;
311 memcpy(sFrame.pExtSuppRates, pCurrExtSuppRates, pCurrExtSuppRates->len + WLAN_IEHDR_LEN);
313 pTxPacket->cbMPDULen = sFrame.len;
314 pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN;
319 void vCommandTimerWait(void *hDeviceContext, unsigned long MSecond)
321 PSDevice pDevice = (PSDevice)hDeviceContext;
323 init_timer(&pDevice->sTimerCommand);
325 pDevice->sTimerCommand.data = (unsigned long)pDevice;
326 pDevice->sTimerCommand.function = (TimerFunction)vRunCommand;
327 pDevice->sTimerCommand.expires = RUN_AT((MSecond * HZ) / 1000);
329 add_timer(&pDevice->sTimerCommand);
334 void vRunCommand(void *hDeviceContext)
336 PSDevice pDevice = (PSDevice)hDeviceContext;
337 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
338 PWLAN_IE_SSID pItemSSID;
339 PWLAN_IE_SSID pItemSSIDCurr;
342 BYTE byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80};
345 union iwreq_data wrqu;
348 if (pDevice->dwDiagRefCount != 0)
350 if (pDevice->bCmdRunning != TRUE)
353 spin_lock_irq(&pDevice->lock);
355 switch ( pDevice->eCommandState ) {
357 case WLAN_CMD_SCAN_START:
359 pDevice->byReAssocCount = 0;
360 if (pDevice->bRadioOff == TRUE) {
361 s_bCommandComplete(pDevice);
362 spin_unlock_irq(&pDevice->lock);
366 if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
367 s_bCommandComplete(pDevice);
368 spin_unlock_irq(&pDevice->lock);
372 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyScanSSID;
374 if (pMgmt->uScanChannel == 0 ) {
375 pMgmt->uScanChannel = pDevice->byMinChannel;
377 if (pMgmt->uScanChannel > pDevice->byMaxChannel) {
378 pMgmt->eScanState = WMAC_NO_SCANNING;
380 if (pDevice->byBBType != pDevice->byScanBBType) {
381 pDevice->byBBType = pDevice->byScanBBType;
382 CARDvSetBSSMode(pDevice);
385 if (pDevice->bUpdateBBVGA) {
386 BBvSetShortSlotTime(pDevice);
387 BBvSetVGAGainOffset(pDevice, pDevice->byBBVGACurrent);
388 BBvUpdatePreEDThreshold(pDevice, FALSE);
391 vAdHocBeaconRestart(pDevice);
393 CARDbSetMediaChannel(pDevice, pMgmt->uCurrChannel);
395 if (pMgmt->bCurrBSSIDFilterOn) {
396 MACvRegBitsOn(pDevice, MAC_REG_RCR, RCR_BSSID);
397 pDevice->byRxMode |= RCR_BSSID;
399 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Scanning, set back to channel: [%d]\n", pMgmt->uCurrChannel);
400 pDevice->bStopDataPkt = FALSE;
401 s_bCommandComplete(pDevice);
402 spin_unlock_irq(&pDevice->lock);
406 if (!ChannelValid(pDevice->byZoneType, pMgmt->uScanChannel)) {
407 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Invalid channel pMgmt->uScanChannel = %d \n",pMgmt->uScanChannel);
408 s_bCommandComplete(pDevice);
409 spin_unlock_irq(&pDevice->lock);
412 if (pMgmt->uScanChannel == pDevice->byMinChannel) {
413 // pMgmt->eScanType = WMAC_SCAN_ACTIVE; //mike mark
414 pMgmt->abyScanBSSID[0] = 0xFF;
415 pMgmt->abyScanBSSID[1] = 0xFF;
416 pMgmt->abyScanBSSID[2] = 0xFF;
417 pMgmt->abyScanBSSID[3] = 0xFF;
418 pMgmt->abyScanBSSID[4] = 0xFF;
419 pMgmt->abyScanBSSID[5] = 0xFF;
420 pItemSSID->byElementID = WLAN_EID_SSID;
422 /* BSSvClearBSSList((void *) pDevice,
423 pDevice->bLinkPass); */
424 pMgmt->eScanState = WMAC_IS_SCANNING;
425 pDevice->byScanBBType = pDevice->byBBType; //lucas
426 pDevice->bStopDataPkt = TRUE;
427 // Turn off RCR_BSSID filter every time
428 MACvRegBitsOff(pDevice, MAC_REG_RCR, RCR_BSSID);
429 pDevice->byRxMode &= ~RCR_BSSID;
433 vAdHocBeaconStop(pDevice);
434 if ((pDevice->byBBType != BB_TYPE_11A) && (pMgmt->uScanChannel > CB_MAX_CHANNEL_24G)) {
435 pDevice->byBBType = BB_TYPE_11A;
436 CARDvSetBSSMode(pDevice);
438 else if ((pDevice->byBBType == BB_TYPE_11A) && (pMgmt->uScanChannel <= CB_MAX_CHANNEL_24G)) {
439 pDevice->byBBType = BB_TYPE_11G;
440 CARDvSetBSSMode(pDevice);
442 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Scanning.... channel: [%d]\n", pMgmt->uScanChannel);
444 CARDbSetMediaChannel(pDevice, pMgmt->uScanChannel);
445 // Set Baseband to be more sensitive.
447 if (pDevice->bUpdateBBVGA) {
448 BBvSetShortSlotTime(pDevice);
449 BBvSetVGAGainOffset(pDevice, pDevice->abyBBVGA[0]);
450 BBvUpdatePreEDThreshold(pDevice, TRUE);
452 pMgmt->uScanChannel++;
454 while (!ChannelValid(pDevice->byZoneType, pMgmt->uScanChannel) &&
455 pMgmt->uScanChannel <= pDevice->byMaxChannel ){
456 pMgmt->uScanChannel++;
459 if (pMgmt->uScanChannel > pDevice->byMaxChannel) {
460 // Set Baseband to be not sensitive and rescan
461 pDevice->eCommandState = WLAN_CMD_SCAN_END;
464 if ((pMgmt->b11hEnable == FALSE) ||
465 (pMgmt->uScanChannel < CB_MAX_CHANNEL_24G)) {
466 s_vProbeChannel(pDevice);
467 spin_unlock_irq(&pDevice->lock);
468 vCommandTimerWait((void *) pDevice, 100);
471 spin_unlock_irq(&pDevice->lock);
472 vCommandTimerWait((void *) pDevice, WCMD_PASSIVE_SCAN_TIME);
480 case WLAN_CMD_SCAN_END:
482 // Set Baseband's sensitivity back.
483 if (pDevice->byBBType != pDevice->byScanBBType) {
484 pDevice->byBBType = pDevice->byScanBBType;
485 CARDvSetBSSMode(pDevice);
488 if (pDevice->bUpdateBBVGA) {
489 BBvSetShortSlotTime(pDevice);
490 BBvSetVGAGainOffset(pDevice, pDevice->byBBVGACurrent);
491 BBvUpdatePreEDThreshold(pDevice, FALSE);
495 vAdHocBeaconRestart(pDevice);
497 CARDbSetMediaChannel(pDevice, pMgmt->uCurrChannel);
499 if (pMgmt->bCurrBSSIDFilterOn) {
500 MACvRegBitsOn(pDevice, MAC_REG_RCR, RCR_BSSID);
501 pDevice->byRxMode |= RCR_BSSID;
503 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Scanning, set back to channel: [%d]\n", pMgmt->uCurrChannel);
504 pMgmt->eScanState = WMAC_NO_SCANNING;
505 pDevice->bStopDataPkt = FALSE;
507 /*send scan event to wpa_Supplicant*/
508 PRINT_K("wireless_send_event--->SIOCGIWSCAN(scan done)\n");
509 memset(&wrqu, 0, sizeof(wrqu));
510 wireless_send_event(pDevice->dev, SIOCGIWSCAN, &wrqu, NULL);
512 s_bCommandComplete(pDevice);
515 case WLAN_CMD_DISASSOCIATE_START :
516 pDevice->byReAssocCount = 0;
517 if ((pMgmt->eCurrMode == WMAC_MODE_ESS_STA) &&
518 (pMgmt->eCurrState != WMAC_STATE_ASSOC)) {
519 s_bCommandComplete(pDevice);
520 spin_unlock_irq(&pDevice->lock);
524 pDevice->bwextstep0 = FALSE;
525 pDevice->bwextstep1 = FALSE;
526 pDevice->bwextstep2 = FALSE;
527 pDevice->bwextstep3 = FALSE;
528 pDevice->bWPASuppWextEnabled = FALSE;
529 pDevice->fWPA_Authened = FALSE;
531 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Send Disassociation Packet..\n");
532 // reason = 8 : disassoc because sta has left
533 vMgrDisassocBeginSta((void *) pDevice,
538 pDevice->bLinkPass = FALSE;
539 ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_SLOW);
540 // unlock command busy
541 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
543 memset(pItemSSID->abySSID, 0, WLAN_SSID_MAXLEN);
544 pMgmt->eCurrState = WMAC_STATE_IDLE;
545 pMgmt->sNodeDBTable[0].bActive = FALSE;
546 // pDevice->bBeaconBufReady = FALSE;
548 netif_stop_queue(pDevice->dev);
549 if (pDevice->bNeedRadioOFF == TRUE)
550 CARDbRadioPowerOff(pDevice);
551 s_bCommandComplete(pDevice);
555 case WLAN_CMD_SSID_START:
557 pDevice->byReAssocCount = 0;
558 if (pDevice->bRadioOff == TRUE) {
559 s_bCommandComplete(pDevice);
560 spin_unlock_irq(&pDevice->lock);
564 memcpy(pMgmt->abyAdHocSSID,pMgmt->abyDesireSSID,
565 ((PWLAN_IE_SSID)pMgmt->abyDesireSSID)->len + WLAN_IEHDR_LEN);
567 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID;
568 pItemSSIDCurr = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
569 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" cmd: desire ssid = %s\n", pItemSSID->abySSID);
570 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" cmd: curr ssid = %s\n", pItemSSIDCurr->abySSID);
572 if (pMgmt->eCurrState == WMAC_STATE_ASSOC) {
573 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" Cmd pMgmt->eCurrState == WMAC_STATE_ASSOC\n");
574 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pItemSSID->len =%d\n",pItemSSID->len);
575 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pItemSSIDCurr->len = %d\n",pItemSSIDCurr->len);
576 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" desire ssid = %s\n", pItemSSID->abySSID);
577 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" curr ssid = %s\n", pItemSSIDCurr->abySSID);
580 if ((pMgmt->eCurrState == WMAC_STATE_ASSOC) ||
581 ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA)&& (pMgmt->eCurrState == WMAC_STATE_JOINTED))) {
583 if (pItemSSID->len == pItemSSIDCurr->len) {
584 if (memcmp(pItemSSID->abySSID, pItemSSIDCurr->abySSID, pItemSSID->len) == 0) {
585 s_bCommandComplete(pDevice);
586 spin_unlock_irq(&pDevice->lock);
590 netif_stop_queue(pDevice->dev);
591 pDevice->bLinkPass = FALSE;
592 ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_SLOW);
595 pMgmt->eCurrState = WMAC_STATE_IDLE;
596 pMgmt->eCurrMode = WMAC_MODE_STANDBY;
597 PSvDisablePowerSaving((void *) pDevice);
598 BSSvClearNodeDBTable(pDevice, 0);
599 vMgrJoinBSSBegin((void *) pDevice, &Status);
601 if ((pMgmt->eCurrMode == WMAC_MODE_ESS_STA) && (pMgmt->eCurrState == WMAC_STATE_JOINTED)) {
602 // Call mgr to begin the deauthentication
603 // reason = (3) because sta has left ESS
604 if (pMgmt->eCurrState >= WMAC_STATE_AUTH) {
605 vMgrDeAuthenBeginSta((void *)pDevice,
611 // Call mgr to begin the authentication
612 vMgrAuthenBeginSta((void *) pDevice, pMgmt, &Status);
613 if (Status == CMD_STATUS_SUCCESS) {
614 pDevice->byLinkWaitCount = 0;
615 pDevice->eCommandState = WLAN_AUTHENTICATE_WAIT;
616 vCommandTimerWait((void *) pDevice, AUTHENTICATE_TIMEOUT);
617 spin_unlock_irq(&pDevice->lock);
618 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" Set eCommandState = WLAN_AUTHENTICATE_WAIT\n");
623 else if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) {
624 if (pMgmt->eCurrState == WMAC_STATE_JOINTED) {
625 if (netif_queue_stopped(pDevice->dev)){
626 netif_wake_queue(pDevice->dev);
628 pDevice->bLinkPass = TRUE;
629 ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_INTER);
630 pMgmt->sNodeDBTable[0].bActive = TRUE;
631 pMgmt->sNodeDBTable[0].uInActiveCount = 0;
635 DBG_PRT(MSG_LEVEL_DEBUG,
636 KERN_INFO "CreateOwn IBSS by CurrMode = IBSS_STA\n");
637 vMgrCreateOwnIBSS((void *) pDevice, &Status);
638 if (Status != CMD_STATUS_SUCCESS){
639 DBG_PRT(MSG_LEVEL_DEBUG,
640 KERN_INFO "WLAN_CMD_IBSS_CREATE fail!\n");
642 BSSvAddMulticastNode(pDevice);
644 s_bClearBSSID_SCAN(pDevice);
647 else if (pMgmt->eCurrMode == WMAC_MODE_STANDBY) {
648 if (pMgmt->eConfigMode == WMAC_CONFIG_IBSS_STA ||
649 pMgmt->eConfigMode == WMAC_CONFIG_AUTO) {
651 DBG_PRT(MSG_LEVEL_DEBUG,
652 KERN_INFO "CreateOwn IBSS by CurrMode = STANDBY\n");
653 vMgrCreateOwnIBSS((void *) pDevice, &Status);
654 if (Status != CMD_STATUS_SUCCESS){
655 DBG_PRT(MSG_LEVEL_DEBUG,
656 KERN_INFO "WLAN_CMD_IBSS_CREATE fail!\n");
658 BSSvAddMulticastNode(pDevice);
659 s_bClearBSSID_SCAN(pDevice);
661 pDevice->bLinkPass = TRUE;
662 ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_INTER);
663 if (netif_queue_stopped(pDevice->dev)){
664 netif_wake_queue(pDevice->dev);
666 s_bClearBSSID_SCAN(pDevice);
670 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disconnect SSID none\n");
671 // if(pDevice->bWPASuppWextEnabled == TRUE)
673 union iwreq_data wrqu;
674 memset(&wrqu, 0, sizeof (wrqu));
675 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
676 PRINT_K("wireless_send_event--->SIOCGIWAP(disassociated:vMgrJoinBSSBegin Fail !!)\n");
677 wireless_send_event(pDevice->dev, SIOCGIWAP, &wrqu, NULL);
681 s_bCommandComplete(pDevice);
684 case WLAN_AUTHENTICATE_WAIT :
685 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState == WLAN_AUTHENTICATE_WAIT\n");
686 if (pMgmt->eCurrState == WMAC_STATE_AUTH) {
687 pDevice->byLinkWaitCount = 0;
688 // Call mgr to begin the association
689 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCurrState == WMAC_STATE_AUTH\n");
690 vMgrAssocBeginSta((void *) pDevice, pMgmt, &Status);
691 if (Status == CMD_STATUS_SUCCESS) {
692 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState = WLAN_ASSOCIATE_WAIT\n");
693 pDevice->byLinkWaitCount = 0;
694 pDevice->eCommandState = WLAN_ASSOCIATE_WAIT;
695 vCommandTimerWait((void *) pDevice, ASSOCIATE_TIMEOUT);
696 spin_unlock_irq(&pDevice->lock);
700 else if(pMgmt->eCurrState < WMAC_STATE_AUTHPENDING) {
701 printk("WLAN_AUTHENTICATE_WAIT:Authen Fail???\n");
703 else if(pDevice->byLinkWaitCount <= 4){ //mike add:wait another 2 sec if authenticated_frame delay!
704 pDevice->byLinkWaitCount ++;
705 printk("WLAN_AUTHENTICATE_WAIT:wait %d times!!\n",pDevice->byLinkWaitCount);
706 spin_unlock_irq(&pDevice->lock);
707 vCommandTimerWait((void *) pDevice, AUTHENTICATE_TIMEOUT/2);
710 pDevice->byLinkWaitCount = 0;
712 s_bCommandComplete(pDevice);
715 case WLAN_ASSOCIATE_WAIT :
716 if (pMgmt->eCurrState == WMAC_STATE_ASSOC) {
717 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCurrState == WMAC_STATE_ASSOC\n");
718 if (pDevice->ePSMode != WMAC_POWER_CAM) {
719 PSvEnablePowerSaving((void *) pDevice,
720 pMgmt->wListenInterval);
723 if (pMgmt->eAuthenMode >= WMAC_AUTH_WPA) {
724 KeybRemoveAllKey(pDevice, &(pDevice->sKey), pDevice->abyBSSID);
727 pDevice->byLinkWaitCount = 0;
728 pDevice->byReAssocCount = 0;
729 pDevice->bLinkPass = TRUE;
730 ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_INTER);
731 s_bClearBSSID_SCAN(pDevice);
733 if (netif_queue_stopped(pDevice->dev)){
734 netif_wake_queue(pDevice->dev);
737 if(pDevice->IsTxDataTrigger != FALSE) { //TxDataTimer is not triggered at the first time
738 // printk("Re-initial TxDataTimer****\n");
739 del_timer(&pDevice->sTimerTxData);
740 init_timer(&pDevice->sTimerTxData);
741 pDevice->sTimerTxData.data = (unsigned long) pDevice;
742 pDevice->sTimerTxData.function = (TimerFunction)BSSvSecondTxData;
743 pDevice->sTimerTxData.expires = RUN_AT(10*HZ); //10s callback
744 pDevice->fTxDataInSleep = FALSE;
745 pDevice->nTxDataTimeCout = 0;
748 // printk("mike:-->First time trigger TimerTxData InSleep\n");
750 pDevice->IsTxDataTrigger = TRUE;
751 add_timer(&pDevice->sTimerTxData);
754 else if(pMgmt->eCurrState < WMAC_STATE_ASSOCPENDING) {
755 printk("WLAN_ASSOCIATE_WAIT:Association Fail???\n");
757 else if(pDevice->byLinkWaitCount <= 4){ //mike add:wait another 2 sec if associated_frame delay!
758 pDevice->byLinkWaitCount ++;
759 printk("WLAN_ASSOCIATE_WAIT:wait %d times!!\n",pDevice->byLinkWaitCount);
760 spin_unlock_irq(&pDevice->lock);
761 vCommandTimerWait((void *) pDevice, ASSOCIATE_TIMEOUT/2);
764 pDevice->byLinkWaitCount = 0;
766 s_bCommandComplete(pDevice);
769 case WLAN_CMD_AP_MODE_START :
770 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState == WLAN_CMD_AP_MODE_START\n");
772 if (pMgmt->eConfigMode == WMAC_CONFIG_AP) {
773 del_timer(&pMgmt->sTimerSecondCallback);
774 pMgmt->eCurrState = WMAC_STATE_IDLE;
775 pMgmt->eCurrMode = WMAC_MODE_STANDBY;
776 pDevice->bLinkPass = FALSE;
777 ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_SLOW);
778 if (pDevice->bEnableHostWEP == TRUE)
779 BSSvClearNodeDBTable(pDevice, 1);
781 BSSvClearNodeDBTable(pDevice, 0);
782 pDevice->uAssocCount = 0;
783 pMgmt->eCurrState = WMAC_STATE_IDLE;
784 pDevice->bFixRate = FALSE;
786 vMgrCreateOwnIBSS((void *) pDevice, &Status);
787 if (Status != CMD_STATUS_SUCCESS) {
788 DBG_PRT(MSG_LEVEL_DEBUG,
789 KERN_INFO "vMgrCreateOwnIBSS fail!\n");
791 // always turn off unicast bit
792 MACvRegBitsOff(pDevice, MAC_REG_RCR, RCR_UNICAST);
793 pDevice->byRxMode &= ~RCR_UNICAST;
794 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "wcmd: rx_mode = %x\n", pDevice->byRxMode );
795 BSSvAddMulticastNode(pDevice);
796 if (netif_queue_stopped(pDevice->dev)){
797 netif_wake_queue(pDevice->dev);
799 pDevice->bLinkPass = TRUE;
800 ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_INTER);
801 add_timer(&pMgmt->sTimerSecondCallback);
803 s_bCommandComplete(pDevice);
806 case WLAN_CMD_TX_PSPACKET_START :
808 if (pMgmt->sNodeDBTable[0].bRxPSPoll) {
809 while ((skb = skb_dequeue(&pMgmt->sNodeDBTable[0].sTxPSQueue)) != NULL) {
810 if (skb_queue_empty(&pMgmt->sNodeDBTable[0].sTxPSQueue)) {
811 pMgmt->abyPSTxMap[0] &= ~byMask[0];
812 pDevice->bMoreData = FALSE;
815 pDevice->bMoreData = TRUE;
818 if (nsDMA_tx_packet(pDevice, TYPE_AC0DMA, skb) != 0) {
819 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Multicast ps tx fail \n");
822 pMgmt->sNodeDBTable[0].wEnQueueCnt--;
827 for (ii = 1; ii < (MAX_NODE_NUM + 1); ii++) {
828 if (pMgmt->sNodeDBTable[ii].bActive &&
829 pMgmt->sNodeDBTable[ii].bRxPSPoll) {
830 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Index=%d Enqueu Cnt= %d\n",
831 ii, pMgmt->sNodeDBTable[ii].wEnQueueCnt);
832 while ((skb = skb_dequeue(&pMgmt->sNodeDBTable[ii].sTxPSQueue)) != NULL) {
833 if (skb_queue_empty(&pMgmt->sNodeDBTable[ii].sTxPSQueue)) {
835 pMgmt->abyPSTxMap[pMgmt->sNodeDBTable[ii].wAID >> 3] &=
836 ~byMask[pMgmt->sNodeDBTable[ii].wAID & 7];
837 pDevice->bMoreData = FALSE;
840 pDevice->bMoreData = TRUE;
843 if (nsDMA_tx_packet(pDevice, TYPE_AC0DMA, skb) != 0) {
844 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "sta ps tx fail \n");
847 pMgmt->sNodeDBTable[ii].wEnQueueCnt--;
848 // check if sta ps enable, wait next pspoll
849 // if sta ps disable, send all pending buffers.
850 if (pMgmt->sNodeDBTable[ii].bPSEnable)
853 if (skb_queue_empty(&pMgmt->sNodeDBTable[ii].sTxPSQueue)) {
855 pMgmt->abyPSTxMap[pMgmt->sNodeDBTable[ii].wAID >> 3] &=
856 ~byMask[pMgmt->sNodeDBTable[ii].wAID & 7];
857 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Index=%d PS queue clear \n", ii);
859 pMgmt->sNodeDBTable[ii].bRxPSPoll = FALSE;
863 s_bCommandComplete(pDevice);
866 case WLAN_CMD_RADIO_START:
868 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState == WLAN_CMD_RADIO_START\n");
869 // if (pDevice->bRadioCmd == TRUE)
870 // CARDbRadioPowerOn(pDevice);
872 // CARDbRadioPowerOff(pDevice);
875 int ntStatus = STATUS_SUCCESS;
878 ntStatus = CONTROLnsRequestIn(pDevice,
881 MESSAGE_REQUEST_MACREG,
885 if ( ntStatus != STATUS_SUCCESS ) {
886 s_bCommandComplete(pDevice);
887 spin_unlock_irq(&pDevice->lock);
890 if ( (byTmp & GPIO3_DATA) == 0 ) {
891 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" WLAN_CMD_RADIO_START_OFF........................\n");
892 // Old commands are useless.
894 pDevice->cbFreeCmdQueue = CMD_Q_SIZE;
895 pDevice->uCmdDequeueIdx = 0;
896 pDevice->uCmdEnqueueIdx = 0;
897 //0415pDevice->bCmdRunning = FALSE;
898 pDevice->bCmdClear = TRUE;
899 pDevice->bStopTx0Pkt = FALSE;
900 pDevice->bStopDataPkt = TRUE;
902 pDevice->byKeyIndex = 0;
903 pDevice->bTransmitKey = FALSE;
904 spin_unlock_irq(&pDevice->lock);
905 KeyvInitTable(pDevice,&pDevice->sKey);
906 spin_lock_irq(&pDevice->lock);
907 pMgmt->byCSSPK = KEY_CTL_NONE;
908 pMgmt->byCSSGK = KEY_CTL_NONE;
910 if (pDevice->bLinkPass == TRUE) {
911 // reason = 8 : disassoc because sta has left
912 vMgrDisassocBeginSta((void *) pDevice,
917 pDevice->bLinkPass = FALSE;
918 // unlock command busy
919 pMgmt->eCurrState = WMAC_STATE_IDLE;
920 pMgmt->sNodeDBTable[0].bActive = FALSE;
921 // if(pDevice->bWPASuppWextEnabled == TRUE)
923 union iwreq_data wrqu;
924 memset(&wrqu, 0, sizeof (wrqu));
925 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
926 PRINT_K("wireless_send_event--->SIOCGIWAP(disassociated)\n");
927 wireless_send_event(pDevice->dev, SIOCGIWAP, &wrqu, NULL);
930 pDevice->bwextstep0 = FALSE;
931 pDevice->bwextstep1 = FALSE;
932 pDevice->bwextstep2 = FALSE;
933 pDevice->bwextstep3 = FALSE;
934 pDevice->bWPASuppWextEnabled = FALSE;
936 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
938 memset(pItemSSID->abySSID, 0, WLAN_SSID_MAXLEN);
940 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID;
942 memset(pItemSSID->abySSID, 0, WLAN_SSID_MAXLEN);
944 netif_stop_queue(pDevice->dev);
945 CARDbRadioPowerOff(pDevice);
946 MACvRegBitsOn(pDevice,MAC_REG_GPIOCTL1,GPIO3_INTMD);
947 ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_OFF);
948 pDevice->bHWRadioOff = TRUE;
950 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" WLAN_CMD_RADIO_START_ON........................\n");
951 pDevice->bHWRadioOff = FALSE;
952 CARDbRadioPowerOn(pDevice);
953 MACvRegBitsOff(pDevice,MAC_REG_GPIOCTL1,GPIO3_INTMD);
954 ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_ON);
958 s_bCommandComplete(pDevice);
962 case WLAN_CMD_CHANGE_BBSENSITIVITY_START:
964 pDevice->bStopDataPkt = TRUE;
965 pDevice->byBBVGACurrent = pDevice->byBBVGANew;
966 BBvSetVGAGainOffset(pDevice, pDevice->byBBVGACurrent);
967 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Change sensitivity pDevice->byBBVGACurrent = %x\n", pDevice->byBBVGACurrent);
968 pDevice->bStopDataPkt = FALSE;
969 s_bCommandComplete(pDevice);
972 case WLAN_CMD_TBTT_WAKEUP_START:
973 PSbIsNextTBTTWakeUp(pDevice);
974 s_bCommandComplete(pDevice);
977 case WLAN_CMD_BECON_SEND_START:
978 bMgrPrepareBeaconToSend(pDevice, pMgmt);
979 s_bCommandComplete(pDevice);
982 case WLAN_CMD_SETPOWER_START:
984 RFbSetPower(pDevice, pDevice->wCurrentRate, pMgmt->uCurrChannel);
986 s_bCommandComplete(pDevice);
989 case WLAN_CMD_CHANGE_ANTENNA_START:
990 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Change from Antenna%d to", (int)pDevice->dwRxAntennaSel);
991 if ( pDevice->dwRxAntennaSel == 0) {
992 pDevice->dwRxAntennaSel=1;
993 if (pDevice->bTxRxAntInv == TRUE)
994 BBvSetAntennaMode(pDevice, ANT_RXA);
996 BBvSetAntennaMode(pDevice, ANT_RXB);
998 pDevice->dwRxAntennaSel=0;
999 if (pDevice->bTxRxAntInv == TRUE)
1000 BBvSetAntennaMode(pDevice, ANT_RXB);
1002 BBvSetAntennaMode(pDevice, ANT_RXA);
1004 s_bCommandComplete(pDevice);
1007 case WLAN_CMD_REMOVE_ALLKEY_START:
1008 KeybRemoveAllKey(pDevice, &(pDevice->sKey), pDevice->abyBSSID);
1009 s_bCommandComplete(pDevice);
1013 case WLAN_CMD_MAC_DISPOWERSAVING_START:
1014 ControlvReadByte (pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_PSCTL, &byData);
1015 if ( (byData & PSCTL_PS) != 0 ) {
1016 // disable power saving hw function
1017 CONTROLnsRequestOut(pDevice,
1018 MESSAGE_TYPE_DISABLE_PS,
1025 s_bCommandComplete(pDevice);
1028 case WLAN_CMD_11H_CHSW_START:
1029 CARDbSetMediaChannel(pDevice, pDevice->byNewChannel);
1030 pDevice->bChannelSwitch = FALSE;
1031 pMgmt->uCurrChannel = pDevice->byNewChannel;
1032 pDevice->bStopDataPkt = FALSE;
1033 s_bCommandComplete(pDevice);
1037 s_bCommandComplete(pDevice);
1041 spin_unlock_irq(&pDevice->lock);
1048 s_bCommandComplete (
1052 PWLAN_IE_SSID pSSID;
1053 BOOL bRadioCmd = FALSE;
1054 //WORD wDeAuthenReason = 0;
1055 BOOL bForceSCAN = TRUE;
1056 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1059 pDevice->eCommandState = WLAN_CMD_IDLE;
1060 if (pDevice->cbFreeCmdQueue == CMD_Q_SIZE) {
1061 //Command Queue Empty
1062 pDevice->bCmdRunning = FALSE;
1066 pDevice->eCommand = pDevice->eCmdQueue[pDevice->uCmdDequeueIdx].eCmd;
1067 pSSID = (PWLAN_IE_SSID)pDevice->eCmdQueue[pDevice->uCmdDequeueIdx].abyCmdDesireSSID;
1068 bRadioCmd = pDevice->eCmdQueue[pDevice->uCmdDequeueIdx].bRadioCmd;
1069 bForceSCAN = pDevice->eCmdQueue[pDevice->uCmdDequeueIdx].bForceSCAN;
1070 ADD_ONE_WITH_WRAP_AROUND(pDevice->uCmdDequeueIdx, CMD_Q_SIZE);
1071 pDevice->cbFreeCmdQueue++;
1072 pDevice->bCmdRunning = TRUE;
1073 switch ( pDevice->eCommand ) {
1074 case WLAN_CMD_BSSID_SCAN:
1075 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState= WLAN_CMD_BSSID_SCAN\n");
1076 pDevice->eCommandState = WLAN_CMD_SCAN_START;
1077 pMgmt->uScanChannel = 0;
1078 if (pSSID->len != 0) {
1079 memcpy(pMgmt->abyScanSSID, pSSID, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
1081 memset(pMgmt->abyScanSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
1084 if ((bForceSCAN == FALSE) && (pDevice->bLinkPass == TRUE)) {
1085 if ((pSSID->len == ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->len) &&
1086 ( !memcmp(pSSID->abySSID, ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->abySSID, pSSID->len))) {
1087 pDevice->eCommandState = WLAN_CMD_IDLE;
1093 pDevice->eCommandState = WLAN_CMD_SSID_START;
1094 if (pSSID->len > WLAN_SSID_MAXLEN)
1095 pSSID->len = WLAN_SSID_MAXLEN;
1096 if (pSSID->len != 0)
1097 memcpy(pMgmt->abyDesireSSID, pSSID, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
1098 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState= WLAN_CMD_SSID_START\n");
1100 case WLAN_CMD_DISASSOCIATE:
1101 pDevice->eCommandState = WLAN_CMD_DISASSOCIATE_START;
1103 case WLAN_CMD_RX_PSPOLL:
1104 pDevice->eCommandState = WLAN_CMD_TX_PSPACKET_START;
1106 case WLAN_CMD_RUN_AP:
1107 pDevice->eCommandState = WLAN_CMD_AP_MODE_START;
1109 case WLAN_CMD_RADIO:
1110 pDevice->eCommandState = WLAN_CMD_RADIO_START;
1111 pDevice->bRadioCmd = bRadioCmd;
1113 case WLAN_CMD_CHANGE_BBSENSITIVITY:
1114 pDevice->eCommandState = WLAN_CMD_CHANGE_BBSENSITIVITY_START;
1117 case WLAN_CMD_TBTT_WAKEUP:
1118 pDevice->eCommandState = WLAN_CMD_TBTT_WAKEUP_START;
1121 case WLAN_CMD_BECON_SEND:
1122 pDevice->eCommandState = WLAN_CMD_BECON_SEND_START;
1125 case WLAN_CMD_SETPOWER:
1126 pDevice->eCommandState = WLAN_CMD_SETPOWER_START;
1129 case WLAN_CMD_CHANGE_ANTENNA:
1130 pDevice->eCommandState = WLAN_CMD_CHANGE_ANTENNA_START;
1133 case WLAN_CMD_REMOVE_ALLKEY:
1134 pDevice->eCommandState = WLAN_CMD_REMOVE_ALLKEY_START;
1137 case WLAN_CMD_MAC_DISPOWERSAVING:
1138 pDevice->eCommandState = WLAN_CMD_MAC_DISPOWERSAVING_START;
1141 case WLAN_CMD_11H_CHSW:
1142 pDevice->eCommandState = WLAN_CMD_11H_CHSW_START;
1149 vCommandTimerWait((void *) pDevice, 0);
1155 BOOL bScheduleCommand(void *hDeviceContext,
1159 PSDevice pDevice = (PSDevice)hDeviceContext;
1162 if (pDevice->cbFreeCmdQueue == 0) {
1165 pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].eCmd = eCommand;
1166 pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].bForceSCAN = TRUE;
1167 memset(pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].abyCmdDesireSSID, 0 , WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
1168 if (pbyItem0 != NULL) {
1170 case WLAN_CMD_BSSID_SCAN:
1171 pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].bForceSCAN = FALSE;
1172 memcpy(pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].abyCmdDesireSSID,
1173 pbyItem0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
1177 memcpy(pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].abyCmdDesireSSID,
1178 pbyItem0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
1181 case WLAN_CMD_DISASSOCIATE:
1182 pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].bNeedRadioOFF = *((int *)pbyItem0);
1185 case WLAN_CMD_DEAUTH:
1186 pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].wDeAuthenReason = *((PWORD)pbyItem0);
1190 case WLAN_CMD_RADIO:
1191 pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].bRadioCmd = *((int *)pbyItem0);
1199 ADD_ONE_WITH_WRAP_AROUND(pDevice->uCmdEnqueueIdx, CMD_Q_SIZE);
1200 pDevice->cbFreeCmdQueue--;
1202 if (pDevice->bCmdRunning == FALSE) {
1203 s_bCommandComplete(pDevice);
1213 * Clear BSSID_SCAN cmd in CMD Queue
1217 * hDeviceContext - Pointer to the adapter
1218 * eCommand - Command
1222 * Return Value: TRUE if success; otherwise FALSE
1225 static BOOL s_bClearBSSID_SCAN(void *hDeviceContext)
1227 PSDevice pDevice = (PSDevice)hDeviceContext;
1228 unsigned int uCmdDequeueIdx = pDevice->uCmdDequeueIdx;
1231 if ((pDevice->cbFreeCmdQueue < CMD_Q_SIZE) && (uCmdDequeueIdx != pDevice->uCmdEnqueueIdx)) {
1232 for (ii = 0; ii < (CMD_Q_SIZE - pDevice->cbFreeCmdQueue); ii ++) {
1233 if (pDevice->eCmdQueue[uCmdDequeueIdx].eCmd == WLAN_CMD_BSSID_SCAN)
1234 pDevice->eCmdQueue[uCmdDequeueIdx].eCmd = WLAN_CMD_IDLE;
1235 ADD_ONE_WITH_WRAP_AROUND(uCmdDequeueIdx, CMD_Q_SIZE);
1236 if (uCmdDequeueIdx == pDevice->uCmdEnqueueIdx)
1244 //mike add:reset command timer
1245 void vResetCommandTimer(void *hDeviceContext)
1247 PSDevice pDevice = (PSDevice)hDeviceContext;
1250 del_timer(&pDevice->sTimerCommand);
1252 init_timer(&pDevice->sTimerCommand);
1253 pDevice->sTimerCommand.data = (unsigned long)pDevice;
1254 pDevice->sTimerCommand.function = (TimerFunction)vRunCommand;
1255 pDevice->sTimerCommand.expires = RUN_AT(HZ);
1256 pDevice->cbFreeCmdQueue = CMD_Q_SIZE;
1257 pDevice->uCmdDequeueIdx = 0;
1258 pDevice->uCmdEnqueueIdx = 0;
1259 pDevice->eCommandState = WLAN_CMD_IDLE;
1260 pDevice->bCmdRunning = FALSE;
1261 pDevice->bCmdClear = FALSE;
1264 void BSSvSecondTxData(void *hDeviceContext)
1266 PSDevice pDevice = (PSDevice)hDeviceContext;
1267 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1269 pDevice->nTxDataTimeCout++;
1271 if (pDevice->nTxDataTimeCout < 4) { //don't tx data if timer less than 40s
1272 // printk("mike:%s-->no data Tx not exceed the desired Time as %d\n",__FUNCTION__,
1273 // (int)pDevice->nTxDataTimeCout);
1274 pDevice->sTimerTxData.expires = RUN_AT(10 * HZ); //10s callback
1275 add_timer(&pDevice->sTimerTxData);
1279 spin_lock_irq(&pDevice->lock);
1280 //is wap_supplicant running successful OR only open && sharekey mode!
1281 if (((pDevice->bLinkPass == TRUE) &&
1282 (pMgmt->eAuthenMode < WMAC_AUTH_WPA)) || //open && sharekey linking
1283 (pDevice->fWPA_Authened == TRUE)) { //wpa linking
1284 // printk("mike:%s-->InSleep Tx Data Procedure\n",__FUNCTION__);
1285 pDevice->fTxDataInSleep = TRUE;
1286 PSbSendNullPacket(pDevice); //send null packet
1287 pDevice->fTxDataInSleep = FALSE;
1289 spin_unlock_irq(&pDevice->lock);
1291 pDevice->sTimerTxData.expires = RUN_AT(10 * HZ); //10s callback
1292 add_timer(&pDevice->sTimerTxData);