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 failue
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};
347 if (pDevice->dwDiagRefCount != 0)
349 if (pDevice->bCmdRunning != TRUE)
352 spin_lock_irq(&pDevice->lock);
354 switch ( pDevice->eCommandState ) {
356 case WLAN_CMD_SCAN_START:
358 pDevice->byReAssocCount = 0;
359 if (pDevice->bRadioOff == TRUE) {
360 s_bCommandComplete(pDevice);
361 spin_unlock_irq(&pDevice->lock);
365 if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
366 s_bCommandComplete(pDevice);
367 spin_unlock_irq(&pDevice->lock);
371 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyScanSSID;
373 if (pMgmt->uScanChannel == 0 ) {
374 pMgmt->uScanChannel = pDevice->byMinChannel;
376 if (pMgmt->uScanChannel > pDevice->byMaxChannel) {
377 pMgmt->eScanState = WMAC_NO_SCANNING;
379 if (pDevice->byBBType != pDevice->byScanBBType) {
380 pDevice->byBBType = pDevice->byScanBBType;
381 CARDvSetBSSMode(pDevice);
384 if (pDevice->bUpdateBBVGA) {
385 BBvSetShortSlotTime(pDevice);
386 BBvSetVGAGainOffset(pDevice, pDevice->byBBVGACurrent);
387 BBvUpdatePreEDThreshold(pDevice, FALSE);
390 vAdHocBeaconRestart(pDevice);
392 CARDbSetMediaChannel(pDevice, pMgmt->uCurrChannel);
394 if (pMgmt->bCurrBSSIDFilterOn) {
395 MACvRegBitsOn(pDevice, MAC_REG_RCR, RCR_BSSID);
396 pDevice->byRxMode |= RCR_BSSID;
398 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Scanning, set back to channel: [%d]\n", pMgmt->uCurrChannel);
399 pDevice->bStopDataPkt = FALSE;
400 s_bCommandComplete(pDevice);
401 spin_unlock_irq(&pDevice->lock);
405 if (!ChannelValid(pDevice->byZoneType, pMgmt->uScanChannel)) {
406 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Invalid channel pMgmt->uScanChannel = %d \n",pMgmt->uScanChannel);
407 s_bCommandComplete(pDevice);
408 spin_unlock_irq(&pDevice->lock);
411 if (pMgmt->uScanChannel == pDevice->byMinChannel) {
412 // pMgmt->eScanType = WMAC_SCAN_ACTIVE; //mike mark
413 pMgmt->abyScanBSSID[0] = 0xFF;
414 pMgmt->abyScanBSSID[1] = 0xFF;
415 pMgmt->abyScanBSSID[2] = 0xFF;
416 pMgmt->abyScanBSSID[3] = 0xFF;
417 pMgmt->abyScanBSSID[4] = 0xFF;
418 pMgmt->abyScanBSSID[5] = 0xFF;
419 pItemSSID->byElementID = WLAN_EID_SSID;
421 /* BSSvClearBSSList((void *) pDevice,
422 pDevice->bLinkPass); */
423 pMgmt->eScanState = WMAC_IS_SCANNING;
424 pDevice->byScanBBType = pDevice->byBBType; //lucas
425 pDevice->bStopDataPkt = TRUE;
426 // Turn off RCR_BSSID filter every time
427 MACvRegBitsOff(pDevice, MAC_REG_RCR, RCR_BSSID);
428 pDevice->byRxMode &= ~RCR_BSSID;
432 vAdHocBeaconStop(pDevice);
433 if ((pDevice->byBBType != BB_TYPE_11A) && (pMgmt->uScanChannel > CB_MAX_CHANNEL_24G)) {
434 pDevice->byBBType = BB_TYPE_11A;
435 CARDvSetBSSMode(pDevice);
437 else if ((pDevice->byBBType == BB_TYPE_11A) && (pMgmt->uScanChannel <= CB_MAX_CHANNEL_24G)) {
438 pDevice->byBBType = BB_TYPE_11G;
439 CARDvSetBSSMode(pDevice);
441 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Scanning.... channel: [%d]\n", pMgmt->uScanChannel);
443 CARDbSetMediaChannel(pDevice, pMgmt->uScanChannel);
444 // Set Baseband to be more sensitive.
446 if (pDevice->bUpdateBBVGA) {
447 BBvSetShortSlotTime(pDevice);
448 BBvSetVGAGainOffset(pDevice, pDevice->abyBBVGA[0]);
449 BBvUpdatePreEDThreshold(pDevice, TRUE);
451 pMgmt->uScanChannel++;
453 while (!ChannelValid(pDevice->byZoneType, pMgmt->uScanChannel) &&
454 pMgmt->uScanChannel <= pDevice->byMaxChannel ){
455 pMgmt->uScanChannel++;
458 if (pMgmt->uScanChannel > pDevice->byMaxChannel) {
459 // Set Baseband to be not sensitive and rescan
460 pDevice->eCommandState = WLAN_CMD_SCAN_END;
463 if ((pMgmt->b11hEnable == FALSE) ||
464 (pMgmt->uScanChannel < CB_MAX_CHANNEL_24G)) {
465 s_vProbeChannel(pDevice);
466 spin_unlock_irq(&pDevice->lock);
467 vCommandTimerWait((void *) pDevice, 100);
470 spin_unlock_irq(&pDevice->lock);
471 vCommandTimerWait((void *) pDevice, WCMD_PASSIVE_SCAN_TIME);
479 case WLAN_CMD_SCAN_END:
481 // Set Baseband's sensitivity back.
482 if (pDevice->byBBType != pDevice->byScanBBType) {
483 pDevice->byBBType = pDevice->byScanBBType;
484 CARDvSetBSSMode(pDevice);
487 if (pDevice->bUpdateBBVGA) {
488 BBvSetShortSlotTime(pDevice);
489 BBvSetVGAGainOffset(pDevice, pDevice->byBBVGACurrent);
490 BBvUpdatePreEDThreshold(pDevice, FALSE);
494 vAdHocBeaconRestart(pDevice);
496 CARDbSetMediaChannel(pDevice, pMgmt->uCurrChannel);
498 if (pMgmt->bCurrBSSIDFilterOn) {
499 MACvRegBitsOn(pDevice, MAC_REG_RCR, RCR_BSSID);
500 pDevice->byRxMode |= RCR_BSSID;
502 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Scanning, set back to channel: [%d]\n", pMgmt->uCurrChannel);
503 pMgmt->eScanState = WMAC_NO_SCANNING;
504 pDevice->bStopDataPkt = FALSE;
506 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
507 if(pMgmt->eScanType == WMAC_SCAN_PASSIVE)
509 //send scan event to wpa_Supplicant
510 union iwreq_data wrqu;
511 PRINT_K("wireless_send_event--->SIOCGIWSCAN(scan done)\n");
512 memset(&wrqu, 0, sizeof(wrqu));
513 wireless_send_event(pDevice->dev, SIOCGIWSCAN, &wrqu, NULL);
516 s_bCommandComplete(pDevice);
519 case WLAN_CMD_DISASSOCIATE_START :
520 pDevice->byReAssocCount = 0;
521 if ((pMgmt->eCurrMode == WMAC_MODE_ESS_STA) &&
522 (pMgmt->eCurrState != WMAC_STATE_ASSOC)) {
523 s_bCommandComplete(pDevice);
524 spin_unlock_irq(&pDevice->lock);
528 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
529 pDevice->bwextstep0 = FALSE;
530 pDevice->bwextstep1 = FALSE;
531 pDevice->bwextstep2 = FALSE;
532 pDevice->bwextstep3 = FALSE;
533 pDevice->bWPASuppWextEnabled = FALSE;
535 pDevice->fWPA_Authened = FALSE;
537 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Send Disassociation Packet..\n");
538 // reason = 8 : disassoc because sta has left
539 vMgrDisassocBeginSta((void *) pDevice,
544 pDevice->bLinkPass = FALSE;
545 ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_SLOW);
546 // unlock command busy
547 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
549 memset(pItemSSID->abySSID, 0, WLAN_SSID_MAXLEN);
550 pMgmt->eCurrState = WMAC_STATE_IDLE;
551 pMgmt->sNodeDBTable[0].bActive = FALSE;
552 // pDevice->bBeaconBufReady = FALSE;
554 netif_stop_queue(pDevice->dev);
555 if (pDevice->bNeedRadioOFF == TRUE)
556 CARDbRadioPowerOff(pDevice);
557 s_bCommandComplete(pDevice);
561 case WLAN_CMD_SSID_START:
563 pDevice->byReAssocCount = 0;
564 if (pDevice->bRadioOff == TRUE) {
565 s_bCommandComplete(pDevice);
566 spin_unlock_irq(&pDevice->lock);
570 memcpy(pMgmt->abyAdHocSSID,pMgmt->abyDesireSSID,
571 ((PWLAN_IE_SSID)pMgmt->abyDesireSSID)->len + WLAN_IEHDR_LEN);
573 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID;
574 pItemSSIDCurr = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
575 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" cmd: desire ssid = %s\n", pItemSSID->abySSID);
576 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" cmd: curr ssid = %s\n", pItemSSIDCurr->abySSID);
578 if (pMgmt->eCurrState == WMAC_STATE_ASSOC) {
579 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" Cmd pMgmt->eCurrState == WMAC_STATE_ASSOC\n");
580 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pItemSSID->len =%d\n",pItemSSID->len);
581 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pItemSSIDCurr->len = %d\n",pItemSSIDCurr->len);
582 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" desire ssid = %s\n", pItemSSID->abySSID);
583 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" curr ssid = %s\n", pItemSSIDCurr->abySSID);
586 if ((pMgmt->eCurrState == WMAC_STATE_ASSOC) ||
587 ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA)&& (pMgmt->eCurrState == WMAC_STATE_JOINTED))) {
589 if (pItemSSID->len == pItemSSIDCurr->len) {
590 if (memcmp(pItemSSID->abySSID, pItemSSIDCurr->abySSID, pItemSSID->len) == 0) {
591 s_bCommandComplete(pDevice);
592 spin_unlock_irq(&pDevice->lock);
596 netif_stop_queue(pDevice->dev);
597 pDevice->bLinkPass = FALSE;
598 ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_SLOW);
601 pMgmt->eCurrState = WMAC_STATE_IDLE;
602 pMgmt->eCurrMode = WMAC_MODE_STANDBY;
603 PSvDisablePowerSaving((void *) pDevice);
604 BSSvClearNodeDBTable(pDevice, 0);
605 vMgrJoinBSSBegin((void *) pDevice, &Status);
607 if ((pMgmt->eCurrMode == WMAC_MODE_ESS_STA) && (pMgmt->eCurrState == WMAC_STATE_JOINTED)) {
608 // Call mgr to begin the deauthentication
609 // reason = (3) because sta has left ESS
610 if (pMgmt->eCurrState >= WMAC_STATE_AUTH) {
611 vMgrDeAuthenBeginSta((void *)pDevice,
617 // Call mgr to begin the authentication
618 vMgrAuthenBeginSta((void *) pDevice, pMgmt, &Status);
619 if (Status == CMD_STATUS_SUCCESS) {
620 pDevice->byLinkWaitCount = 0;
621 pDevice->eCommandState = WLAN_AUTHENTICATE_WAIT;
622 vCommandTimerWait((void *) pDevice, AUTHENTICATE_TIMEOUT);
623 spin_unlock_irq(&pDevice->lock);
624 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" Set eCommandState = WLAN_AUTHENTICATE_WAIT\n");
629 else if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) {
630 if (pMgmt->eCurrState == WMAC_STATE_JOINTED) {
631 if (netif_queue_stopped(pDevice->dev)){
632 netif_wake_queue(pDevice->dev);
634 pDevice->bLinkPass = TRUE;
635 ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_INTER);
636 pMgmt->sNodeDBTable[0].bActive = TRUE;
637 pMgmt->sNodeDBTable[0].uInActiveCount = 0;
641 DBG_PRT(MSG_LEVEL_DEBUG,
642 KERN_INFO "CreateOwn IBSS by CurrMode = IBSS_STA\n");
643 vMgrCreateOwnIBSS((void *) pDevice, &Status);
644 if (Status != CMD_STATUS_SUCCESS){
645 DBG_PRT(MSG_LEVEL_DEBUG,
646 KERN_INFO "WLAN_CMD_IBSS_CREATE fail!\n");
648 BSSvAddMulticastNode(pDevice);
650 s_bClearBSSID_SCAN(pDevice);
653 else if (pMgmt->eCurrMode == WMAC_MODE_STANDBY) {
654 if (pMgmt->eConfigMode == WMAC_CONFIG_IBSS_STA ||
655 pMgmt->eConfigMode == WMAC_CONFIG_AUTO) {
657 DBG_PRT(MSG_LEVEL_DEBUG,
658 KERN_INFO "CreateOwn IBSS by CurrMode = STANDBY\n");
659 vMgrCreateOwnIBSS((void *) pDevice, &Status);
660 if (Status != CMD_STATUS_SUCCESS){
661 DBG_PRT(MSG_LEVEL_DEBUG,
662 KERN_INFO "WLAN_CMD_IBSS_CREATE fail!\n");
664 BSSvAddMulticastNode(pDevice);
665 s_bClearBSSID_SCAN(pDevice);
667 pDevice->bLinkPass = TRUE;
668 ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_INTER);
669 if (netif_queue_stopped(pDevice->dev)){
670 netif_wake_queue(pDevice->dev);
672 s_bClearBSSID_SCAN(pDevice);
676 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disconnect SSID none\n");
677 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
678 // if(pDevice->bWPASuppWextEnabled == TRUE)
680 union iwreq_data wrqu;
681 memset(&wrqu, 0, sizeof (wrqu));
682 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
683 PRINT_K("wireless_send_event--->SIOCGIWAP(disassociated:vMgrJoinBSSBegin Fail !!)\n");
684 wireless_send_event(pDevice->dev, SIOCGIWAP, &wrqu, NULL);
689 s_bCommandComplete(pDevice);
692 case WLAN_AUTHENTICATE_WAIT :
693 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState == WLAN_AUTHENTICATE_WAIT\n");
694 if (pMgmt->eCurrState == WMAC_STATE_AUTH) {
695 pDevice->byLinkWaitCount = 0;
696 // Call mgr to begin the association
697 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCurrState == WMAC_STATE_AUTH\n");
698 vMgrAssocBeginSta((void *) pDevice, pMgmt, &Status);
699 if (Status == CMD_STATUS_SUCCESS) {
700 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState = WLAN_ASSOCIATE_WAIT\n");
701 pDevice->byLinkWaitCount = 0;
702 pDevice->eCommandState = WLAN_ASSOCIATE_WAIT;
703 vCommandTimerWait((void *) pDevice, ASSOCIATE_TIMEOUT);
704 spin_unlock_irq(&pDevice->lock);
708 else if(pMgmt->eCurrState < WMAC_STATE_AUTHPENDING) {
709 printk("WLAN_AUTHENTICATE_WAIT:Authen Fail???\n");
711 else if(pDevice->byLinkWaitCount <= 4){ //mike add:wait another 2 sec if authenticated_frame delay!
712 pDevice->byLinkWaitCount ++;
713 printk("WLAN_AUTHENTICATE_WAIT:wait %d times!!\n",pDevice->byLinkWaitCount);
714 spin_unlock_irq(&pDevice->lock);
715 vCommandTimerWait((void *) pDevice, AUTHENTICATE_TIMEOUT/2);
718 pDevice->byLinkWaitCount = 0;
720 s_bCommandComplete(pDevice);
723 case WLAN_ASSOCIATE_WAIT :
724 if (pMgmt->eCurrState == WMAC_STATE_ASSOC) {
725 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCurrState == WMAC_STATE_ASSOC\n");
726 if (pDevice->ePSMode != WMAC_POWER_CAM) {
727 PSvEnablePowerSaving((void *) pDevice,
728 pMgmt->wListenInterval);
731 if (pMgmt->eAuthenMode >= WMAC_AUTH_WPA) {
732 KeybRemoveAllKey(pDevice, &(pDevice->sKey), pDevice->abyBSSID);
735 pDevice->byLinkWaitCount = 0;
736 pDevice->byReAssocCount = 0;
737 pDevice->bLinkPass = TRUE;
738 ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_INTER);
739 s_bClearBSSID_SCAN(pDevice);
741 if (netif_queue_stopped(pDevice->dev)){
742 netif_wake_queue(pDevice->dev);
745 if(pDevice->IsTxDataTrigger != FALSE) { //TxDataTimer is not triggered at the first time
746 // printk("Re-initial TxDataTimer****\n");
747 del_timer(&pDevice->sTimerTxData);
748 init_timer(&pDevice->sTimerTxData);
749 pDevice->sTimerTxData.data = (unsigned long) pDevice;
750 pDevice->sTimerTxData.function = (TimerFunction)BSSvSecondTxData;
751 pDevice->sTimerTxData.expires = RUN_AT(10*HZ); //10s callback
752 pDevice->fTxDataInSleep = FALSE;
753 pDevice->nTxDataTimeCout = 0;
756 // printk("mike:-->First time triger TimerTxData InSleep\n");
758 pDevice->IsTxDataTrigger = TRUE;
759 add_timer(&pDevice->sTimerTxData);
762 else if(pMgmt->eCurrState < WMAC_STATE_ASSOCPENDING) {
763 printk("WLAN_ASSOCIATE_WAIT:Association Fail???\n");
765 else if(pDevice->byLinkWaitCount <= 4){ //mike add:wait another 2 sec if associated_frame delay!
766 pDevice->byLinkWaitCount ++;
767 printk("WLAN_ASSOCIATE_WAIT:wait %d times!!\n",pDevice->byLinkWaitCount);
768 spin_unlock_irq(&pDevice->lock);
769 vCommandTimerWait((void *) pDevice, ASSOCIATE_TIMEOUT/2);
772 pDevice->byLinkWaitCount = 0;
774 s_bCommandComplete(pDevice);
777 case WLAN_CMD_AP_MODE_START :
778 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState == WLAN_CMD_AP_MODE_START\n");
780 if (pMgmt->eConfigMode == WMAC_CONFIG_AP) {
781 del_timer(&pMgmt->sTimerSecondCallback);
782 pMgmt->eCurrState = WMAC_STATE_IDLE;
783 pMgmt->eCurrMode = WMAC_MODE_STANDBY;
784 pDevice->bLinkPass = FALSE;
785 ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_SLOW);
786 if (pDevice->bEnableHostWEP == TRUE)
787 BSSvClearNodeDBTable(pDevice, 1);
789 BSSvClearNodeDBTable(pDevice, 0);
790 pDevice->uAssocCount = 0;
791 pMgmt->eCurrState = WMAC_STATE_IDLE;
792 pDevice->bFixRate = FALSE;
794 vMgrCreateOwnIBSS((void *) pDevice, &Status);
795 if (Status != CMD_STATUS_SUCCESS) {
796 DBG_PRT(MSG_LEVEL_DEBUG,
797 KERN_INFO "vMgrCreateOwnIBSS fail!\n");
799 // alway turn off unicast bit
800 MACvRegBitsOff(pDevice, MAC_REG_RCR, RCR_UNICAST);
801 pDevice->byRxMode &= ~RCR_UNICAST;
802 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "wcmd: rx_mode = %x\n", pDevice->byRxMode );
803 BSSvAddMulticastNode(pDevice);
804 if (netif_queue_stopped(pDevice->dev)){
805 netif_wake_queue(pDevice->dev);
807 pDevice->bLinkPass = TRUE;
808 ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_INTER);
809 add_timer(&pMgmt->sTimerSecondCallback);
811 s_bCommandComplete(pDevice);
814 case WLAN_CMD_TX_PSPACKET_START :
816 if (pMgmt->sNodeDBTable[0].bRxPSPoll) {
817 while ((skb = skb_dequeue(&pMgmt->sNodeDBTable[0].sTxPSQueue)) != NULL) {
818 if (skb_queue_empty(&pMgmt->sNodeDBTable[0].sTxPSQueue)) {
819 pMgmt->abyPSTxMap[0] &= ~byMask[0];
820 pDevice->bMoreData = FALSE;
823 pDevice->bMoreData = TRUE;
826 if (nsDMA_tx_packet(pDevice, TYPE_AC0DMA, skb) != 0) {
827 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Multicast ps tx fail \n");
830 pMgmt->sNodeDBTable[0].wEnQueueCnt--;
835 for (ii = 1; ii < (MAX_NODE_NUM + 1); ii++) {
836 if (pMgmt->sNodeDBTable[ii].bActive &&
837 pMgmt->sNodeDBTable[ii].bRxPSPoll) {
838 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Index=%d Enqueu Cnt= %d\n",
839 ii, pMgmt->sNodeDBTable[ii].wEnQueueCnt);
840 while ((skb = skb_dequeue(&pMgmt->sNodeDBTable[ii].sTxPSQueue)) != NULL) {
841 if (skb_queue_empty(&pMgmt->sNodeDBTable[ii].sTxPSQueue)) {
843 pMgmt->abyPSTxMap[pMgmt->sNodeDBTable[ii].wAID >> 3] &=
844 ~byMask[pMgmt->sNodeDBTable[ii].wAID & 7];
845 pDevice->bMoreData = FALSE;
848 pDevice->bMoreData = TRUE;
851 if (nsDMA_tx_packet(pDevice, TYPE_AC0DMA, skb) != 0) {
852 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "sta ps tx fail \n");
855 pMgmt->sNodeDBTable[ii].wEnQueueCnt--;
856 // check if sta ps enable, wait next pspoll
857 // if sta ps disable, send all pending buffers.
858 if (pMgmt->sNodeDBTable[ii].bPSEnable)
861 if (skb_queue_empty(&pMgmt->sNodeDBTable[ii].sTxPSQueue)) {
863 pMgmt->abyPSTxMap[pMgmt->sNodeDBTable[ii].wAID >> 3] &=
864 ~byMask[pMgmt->sNodeDBTable[ii].wAID & 7];
865 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Index=%d PS queue clear \n", ii);
867 pMgmt->sNodeDBTable[ii].bRxPSPoll = FALSE;
871 s_bCommandComplete(pDevice);
874 case WLAN_CMD_RADIO_START:
876 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState == WLAN_CMD_RADIO_START\n");
877 // if (pDevice->bRadioCmd == TRUE)
878 // CARDbRadioPowerOn(pDevice);
880 // CARDbRadioPowerOff(pDevice);
883 int ntStatus = STATUS_SUCCESS;
886 ntStatus = CONTROLnsRequestIn(pDevice,
889 MESSAGE_REQUEST_MACREG,
893 if ( ntStatus != STATUS_SUCCESS ) {
894 s_bCommandComplete(pDevice);
895 spin_unlock_irq(&pDevice->lock);
898 if ( (byTmp & GPIO3_DATA) == 0 ) {
899 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" WLAN_CMD_RADIO_START_OFF........................\n");
900 // Old commands are useless.
902 pDevice->cbFreeCmdQueue = CMD_Q_SIZE;
903 pDevice->uCmdDequeueIdx = 0;
904 pDevice->uCmdEnqueueIdx = 0;
905 //0415pDevice->bCmdRunning = FALSE;
906 pDevice->bCmdClear = TRUE;
907 pDevice->bStopTx0Pkt = FALSE;
908 pDevice->bStopDataPkt = TRUE;
910 pDevice->byKeyIndex = 0;
911 pDevice->bTransmitKey = FALSE;
912 spin_unlock_irq(&pDevice->lock);
913 KeyvInitTable(pDevice,&pDevice->sKey);
914 spin_lock_irq(&pDevice->lock);
915 pMgmt->byCSSPK = KEY_CTL_NONE;
916 pMgmt->byCSSGK = KEY_CTL_NONE;
918 if (pDevice->bLinkPass == TRUE) {
919 // reason = 8 : disassoc because sta has left
920 vMgrDisassocBeginSta((void *) pDevice,
925 pDevice->bLinkPass = FALSE;
926 // unlock command busy
927 pMgmt->eCurrState = WMAC_STATE_IDLE;
928 pMgmt->sNodeDBTable[0].bActive = FALSE;
929 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
930 // if(pDevice->bWPASuppWextEnabled == TRUE)
932 union iwreq_data wrqu;
933 memset(&wrqu, 0, sizeof (wrqu));
934 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
935 PRINT_K("wireless_send_event--->SIOCGIWAP(disassociated)\n");
936 wireless_send_event(pDevice->dev, SIOCGIWAP, &wrqu, NULL);
940 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
941 pDevice->bwextstep0 = FALSE;
942 pDevice->bwextstep1 = FALSE;
943 pDevice->bwextstep2 = FALSE;
944 pDevice->bwextstep3 = FALSE;
945 pDevice->bWPASuppWextEnabled = FALSE;
948 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
950 memset(pItemSSID->abySSID, 0, WLAN_SSID_MAXLEN);
952 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID;
954 memset(pItemSSID->abySSID, 0, WLAN_SSID_MAXLEN);
956 netif_stop_queue(pDevice->dev);
957 CARDbRadioPowerOff(pDevice);
958 MACvRegBitsOn(pDevice,MAC_REG_GPIOCTL1,GPIO3_INTMD);
959 ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_OFF);
960 pDevice->bHWRadioOff = TRUE;
962 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" WLAN_CMD_RADIO_START_ON........................\n");
963 pDevice->bHWRadioOff = FALSE;
964 CARDbRadioPowerOn(pDevice);
965 MACvRegBitsOff(pDevice,MAC_REG_GPIOCTL1,GPIO3_INTMD);
966 ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_ON);
970 s_bCommandComplete(pDevice);
974 case WLAN_CMD_CHANGE_BBSENSITIVITY_START:
976 pDevice->bStopDataPkt = TRUE;
977 pDevice->byBBVGACurrent = pDevice->byBBVGANew;
978 BBvSetVGAGainOffset(pDevice, pDevice->byBBVGACurrent);
979 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Change sensitivity pDevice->byBBVGACurrent = %x\n", pDevice->byBBVGACurrent);
980 pDevice->bStopDataPkt = FALSE;
981 s_bCommandComplete(pDevice);
984 case WLAN_CMD_TBTT_WAKEUP_START:
985 PSbIsNextTBTTWakeUp(pDevice);
986 s_bCommandComplete(pDevice);
989 case WLAN_CMD_BECON_SEND_START:
990 bMgrPrepareBeaconToSend(pDevice, pMgmt);
991 s_bCommandComplete(pDevice);
994 case WLAN_CMD_SETPOWER_START:
996 RFbSetPower(pDevice, pDevice->wCurrentRate, pMgmt->uCurrChannel);
998 s_bCommandComplete(pDevice);
1001 case WLAN_CMD_CHANGE_ANTENNA_START:
1002 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Change from Antenna%d to", (int)pDevice->dwRxAntennaSel);
1003 if ( pDevice->dwRxAntennaSel == 0) {
1004 pDevice->dwRxAntennaSel=1;
1005 if (pDevice->bTxRxAntInv == TRUE)
1006 BBvSetAntennaMode(pDevice, ANT_RXA);
1008 BBvSetAntennaMode(pDevice, ANT_RXB);
1010 pDevice->dwRxAntennaSel=0;
1011 if (pDevice->bTxRxAntInv == TRUE)
1012 BBvSetAntennaMode(pDevice, ANT_RXB);
1014 BBvSetAntennaMode(pDevice, ANT_RXA);
1016 s_bCommandComplete(pDevice);
1019 case WLAN_CMD_REMOVE_ALLKEY_START:
1020 KeybRemoveAllKey(pDevice, &(pDevice->sKey), pDevice->abyBSSID);
1021 s_bCommandComplete(pDevice);
1025 case WLAN_CMD_MAC_DISPOWERSAVING_START:
1026 ControlvReadByte (pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_PSCTL, &byData);
1027 if ( (byData & PSCTL_PS) != 0 ) {
1028 // disable power saving hw function
1029 CONTROLnsRequestOut(pDevice,
1030 MESSAGE_TYPE_DISABLE_PS,
1037 s_bCommandComplete(pDevice);
1040 case WLAN_CMD_11H_CHSW_START:
1041 CARDbSetMediaChannel(pDevice, pDevice->byNewChannel);
1042 pDevice->bChannelSwitch = FALSE;
1043 pMgmt->uCurrChannel = pDevice->byNewChannel;
1044 pDevice->bStopDataPkt = FALSE;
1045 s_bCommandComplete(pDevice);
1049 s_bCommandComplete(pDevice);
1053 spin_unlock_irq(&pDevice->lock);
1060 s_bCommandComplete (
1064 PWLAN_IE_SSID pSSID;
1065 BOOL bRadioCmd = FALSE;
1066 //WORD wDeAuthenReason = 0;
1067 BOOL bForceSCAN = TRUE;
1068 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1071 pDevice->eCommandState = WLAN_CMD_IDLE;
1072 if (pDevice->cbFreeCmdQueue == CMD_Q_SIZE) {
1073 //Command Queue Empty
1074 pDevice->bCmdRunning = FALSE;
1078 pDevice->eCommand = pDevice->eCmdQueue[pDevice->uCmdDequeueIdx].eCmd;
1079 pSSID = (PWLAN_IE_SSID)pDevice->eCmdQueue[pDevice->uCmdDequeueIdx].abyCmdDesireSSID;
1080 bRadioCmd = pDevice->eCmdQueue[pDevice->uCmdDequeueIdx].bRadioCmd;
1081 bForceSCAN = pDevice->eCmdQueue[pDevice->uCmdDequeueIdx].bForceSCAN;
1082 ADD_ONE_WITH_WRAP_AROUND(pDevice->uCmdDequeueIdx, CMD_Q_SIZE);
1083 pDevice->cbFreeCmdQueue++;
1084 pDevice->bCmdRunning = TRUE;
1085 switch ( pDevice->eCommand ) {
1086 case WLAN_CMD_BSSID_SCAN:
1087 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState= WLAN_CMD_BSSID_SCAN\n");
1088 pDevice->eCommandState = WLAN_CMD_SCAN_START;
1089 pMgmt->uScanChannel = 0;
1090 if (pSSID->len != 0) {
1091 memcpy(pMgmt->abyScanSSID, pSSID, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
1093 memset(pMgmt->abyScanSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
1096 if ((bForceSCAN == FALSE) && (pDevice->bLinkPass == TRUE)) {
1097 if ((pSSID->len == ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->len) &&
1098 ( !memcmp(pSSID->abySSID, ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->abySSID, pSSID->len))) {
1099 pDevice->eCommandState = WLAN_CMD_IDLE;
1105 pDevice->eCommandState = WLAN_CMD_SSID_START;
1106 if (pSSID->len > WLAN_SSID_MAXLEN)
1107 pSSID->len = WLAN_SSID_MAXLEN;
1108 if (pSSID->len != 0)
1109 memcpy(pMgmt->abyDesireSSID, pSSID, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
1110 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState= WLAN_CMD_SSID_START\n");
1112 case WLAN_CMD_DISASSOCIATE:
1113 pDevice->eCommandState = WLAN_CMD_DISASSOCIATE_START;
1115 case WLAN_CMD_RX_PSPOLL:
1116 pDevice->eCommandState = WLAN_CMD_TX_PSPACKET_START;
1118 case WLAN_CMD_RUN_AP:
1119 pDevice->eCommandState = WLAN_CMD_AP_MODE_START;
1121 case WLAN_CMD_RADIO:
1122 pDevice->eCommandState = WLAN_CMD_RADIO_START;
1123 pDevice->bRadioCmd = bRadioCmd;
1125 case WLAN_CMD_CHANGE_BBSENSITIVITY:
1126 pDevice->eCommandState = WLAN_CMD_CHANGE_BBSENSITIVITY_START;
1129 case WLAN_CMD_TBTT_WAKEUP:
1130 pDevice->eCommandState = WLAN_CMD_TBTT_WAKEUP_START;
1133 case WLAN_CMD_BECON_SEND:
1134 pDevice->eCommandState = WLAN_CMD_BECON_SEND_START;
1137 case WLAN_CMD_SETPOWER:
1138 pDevice->eCommandState = WLAN_CMD_SETPOWER_START;
1141 case WLAN_CMD_CHANGE_ANTENNA:
1142 pDevice->eCommandState = WLAN_CMD_CHANGE_ANTENNA_START;
1145 case WLAN_CMD_REMOVE_ALLKEY:
1146 pDevice->eCommandState = WLAN_CMD_REMOVE_ALLKEY_START;
1149 case WLAN_CMD_MAC_DISPOWERSAVING:
1150 pDevice->eCommandState = WLAN_CMD_MAC_DISPOWERSAVING_START;
1153 case WLAN_CMD_11H_CHSW:
1154 pDevice->eCommandState = WLAN_CMD_11H_CHSW_START;
1161 vCommandTimerWait((void *) pDevice, 0);
1167 BOOL bScheduleCommand(void *hDeviceContext,
1171 PSDevice pDevice = (PSDevice)hDeviceContext;
1174 if (pDevice->cbFreeCmdQueue == 0) {
1177 pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].eCmd = eCommand;
1178 pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].bForceSCAN = TRUE;
1179 memset(pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].abyCmdDesireSSID, 0 , WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
1180 if (pbyItem0 != NULL) {
1182 case WLAN_CMD_BSSID_SCAN:
1183 pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].bForceSCAN = FALSE;
1184 memcpy(pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].abyCmdDesireSSID,
1185 pbyItem0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
1189 memcpy(pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].abyCmdDesireSSID,
1190 pbyItem0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
1193 case WLAN_CMD_DISASSOCIATE:
1194 pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].bNeedRadioOFF = *((int *)pbyItem0);
1197 case WLAN_CMD_DEAUTH:
1198 pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].wDeAuthenReason = *((PWORD)pbyItem0);
1202 case WLAN_CMD_RADIO:
1203 pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].bRadioCmd = *((int *)pbyItem0);
1211 ADD_ONE_WITH_WRAP_AROUND(pDevice->uCmdEnqueueIdx, CMD_Q_SIZE);
1212 pDevice->cbFreeCmdQueue--;
1214 if (pDevice->bCmdRunning == FALSE) {
1215 s_bCommandComplete(pDevice);
1225 * Clear BSSID_SCAN cmd in CMD Queue
1229 * hDeviceContext - Pointer to the adapter
1230 * eCommand - Command
1234 * Return Value: TRUE if success; otherwise FALSE
1237 static BOOL s_bClearBSSID_SCAN(void *hDeviceContext)
1239 PSDevice pDevice = (PSDevice)hDeviceContext;
1240 unsigned int uCmdDequeueIdx = pDevice->uCmdDequeueIdx;
1243 if ((pDevice->cbFreeCmdQueue < CMD_Q_SIZE) && (uCmdDequeueIdx != pDevice->uCmdEnqueueIdx)) {
1244 for (ii = 0; ii < (CMD_Q_SIZE - pDevice->cbFreeCmdQueue); ii ++) {
1245 if (pDevice->eCmdQueue[uCmdDequeueIdx].eCmd == WLAN_CMD_BSSID_SCAN)
1246 pDevice->eCmdQueue[uCmdDequeueIdx].eCmd = WLAN_CMD_IDLE;
1247 ADD_ONE_WITH_WRAP_AROUND(uCmdDequeueIdx, CMD_Q_SIZE);
1248 if (uCmdDequeueIdx == pDevice->uCmdEnqueueIdx)
1256 //mike add:reset command timer
1257 void vResetCommandTimer(void *hDeviceContext)
1259 PSDevice pDevice = (PSDevice)hDeviceContext;
1262 del_timer(&pDevice->sTimerCommand);
1264 init_timer(&pDevice->sTimerCommand);
1265 pDevice->sTimerCommand.data = (unsigned long)pDevice;
1266 pDevice->sTimerCommand.function = (TimerFunction)vRunCommand;
1267 pDevice->sTimerCommand.expires = RUN_AT(HZ);
1268 pDevice->cbFreeCmdQueue = CMD_Q_SIZE;
1269 pDevice->uCmdDequeueIdx = 0;
1270 pDevice->uCmdEnqueueIdx = 0;
1271 pDevice->eCommandState = WLAN_CMD_IDLE;
1272 pDevice->bCmdRunning = FALSE;
1273 pDevice->bCmdClear = FALSE;
1276 void BSSvSecondTxData(void *hDeviceContext)
1278 PSDevice pDevice = (PSDevice)hDeviceContext;
1279 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1281 pDevice->nTxDataTimeCout++;
1283 if(pDevice->nTxDataTimeCout<4) //don't tx data if timer less than 40s
1285 // printk("mike:%s-->no data Tx not exceed the desired Time as %d\n",__FUNCTION__,
1286 // (int)pDevice->nTxDataTimeCout);
1287 pDevice->sTimerTxData.expires = RUN_AT(10*HZ); //10s callback
1288 add_timer(&pDevice->sTimerTxData);
1292 spin_lock_irq(&pDevice->lock);
1293 //is wap_supplicant running successful OR only open && sharekey mode!
1294 if(((pDevice->bLinkPass ==TRUE)&&(pMgmt->eAuthenMode < WMAC_AUTH_WPA)) || //open && sharekey linking
1295 (pDevice->fWPA_Authened == TRUE)) { //wpa linking
1296 // printk("mike:%s-->InSleep Tx Data Procedure\n",__FUNCTION__);
1297 pDevice->fTxDataInSleep = TRUE;
1298 PSbSendNullPacket(pDevice); //send null packet
1299 pDevice->fTxDataInSleep = FALSE;
1301 spin_unlock_irq(&pDevice->lock);
1303 pDevice->sTimerTxData.expires = RUN_AT(10*HZ); //10s callback
1304 add_timer(&pDevice->sTimerTxData);