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
60 /*--------------------- Static Definitions -------------------------*/
65 /*--------------------- Static Classes ----------------------------*/
67 /*--------------------- Static Variables --------------------------*/
68 static int msglevel
=MSG_LEVEL_INFO
;
69 //static int msglevel =MSG_LEVEL_DEBUG;
70 /*--------------------- Static Functions --------------------------*/
81 s_MgrMakeProbeRequest(
83 IN PSMgmtObject pMgmt
,
85 IN PWLAN_IE_SSID pSSID
,
86 IN PWLAN_IE_SUPP_RATES pCurrRates
,
87 IN PWLAN_IE_SUPP_RATES pCurrExtSuppRates
99 BOOL
s_bClearBSSID_SCAN (
100 IN HANDLE hDeviceContext
103 /*--------------------- Export Variables --------------------------*/
106 /*--------------------- Export Functions --------------------------*/
112 * Stop AdHoc beacon during scan process
116 * pDevice - Pointer to the adapter
125 vAdHocBeaconStop(PSDevice pDevice
)
128 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
132 * temporarily stop Beacon packet for AdHoc Server
133 * if all of the following coditions are met:
134 * (1) STA is in AdHoc mode
135 * (2) VT3253 is programmed as automatic Beacon Transmitting
136 * (3) One of the following conditions is met
137 * (3.1) AdHoc channel is in B/G band and the
138 * current scan channel is in A band
140 * (3.2) AdHoc channel is in A mode
143 if ((pMgmt
->eCurrMode
== WMAC_MODE_IBSS_STA
) &&
144 (pMgmt
->eCurrState
>= WMAC_STATE_STARTED
))
146 if ((pMgmt
->uIBSSChannel
<= CB_MAX_CHANNEL_24G
) &&
147 (pMgmt
->uScanChannel
> CB_MAX_CHANNEL_24G
))
151 if (pMgmt
->uIBSSChannel
> CB_MAX_CHANNEL_24G
)
159 //PMESG(("STOP_BEACON: IBSSChannel = %u, ScanChannel = %u\n",
160 // pMgmt->uIBSSChannel, pMgmt->uScanChannel));
161 MACvRegBitsOff(pDevice
, MAC_REG_TCR
, TCR_AUTOBCNTX
);
164 } /* vAdHocBeaconStop */
169 * Restart AdHoc beacon after scan process complete
173 * pDevice - Pointer to the adapter
182 vAdHocBeaconRestart(PSDevice pDevice
)
184 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
187 * Restart Beacon packet for AdHoc Server
188 * if all of the following coditions are met:
189 * (1) STA is in AdHoc mode
190 * (2) VT3253 is programmed as automatic Beacon Transmitting
192 if ((pMgmt
->eCurrMode
== WMAC_MODE_IBSS_STA
) &&
193 (pMgmt
->eCurrState
>= WMAC_STATE_STARTED
))
195 //PMESG(("RESTART_BEACON\n"));
196 MACvRegBitsOn(pDevice
, MAC_REG_TCR
, TCR_AUTOBCNTX
);
204 * Routine Description:
205 * Prepare and send probe request management frames.
219 //1M, 2M, 5M, 11M, 18M, 24M, 36M, 54M
220 BYTE abyCurrSuppRatesG
[] = {WLAN_EID_SUPP_RATES
, 8, 0x02, 0x04, 0x0B, 0x16, 0x24, 0x30, 0x48, 0x6C};
221 BYTE abyCurrExtSuppRatesG
[] = {WLAN_EID_EXTSUPP_RATES
, 4, 0x0C, 0x12, 0x18, 0x60};
223 BYTE abyCurrSuppRatesA
[] = {WLAN_EID_SUPP_RATES
, 8, 0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C};
224 BYTE abyCurrSuppRatesB
[] = {WLAN_EID_SUPP_RATES
, 4, 0x02, 0x04, 0x0B, 0x16};
226 PSTxMgmtPacket pTxPacket
;
227 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
231 if (pDevice
->byBBType
== BB_TYPE_11A
) {
232 pbyRate
= &abyCurrSuppRatesA
[0];
233 } else if (pDevice
->byBBType
== BB_TYPE_11B
) {
234 pbyRate
= &abyCurrSuppRatesB
[0];
236 pbyRate
= &abyCurrSuppRatesG
[0];
238 // build an assocreq frame and send it
239 pTxPacket
= s_MgrMakeProbeRequest
244 (PWLAN_IE_SSID
)pMgmt
->abyScanSSID
,
245 (PWLAN_IE_SUPP_RATES
)pbyRate
,
246 (PWLAN_IE_SUPP_RATES
)abyCurrExtSuppRatesG
249 if (pTxPacket
!= NULL
){
250 for (ii
= 0; ii
< 1 ; ii
++) {
251 if (csMgmt_xmit(pDevice
, pTxPacket
) != CMD_STATUS_PENDING
) {
252 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Probe request sending fail.. \n");
255 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Probe request is sending.. \n");
267 * Routine Description:
268 * Constructs an probe request frame
272 * A ptr to Tx frame or NULL on allocation failue
278 s_MgrMakeProbeRequest(
280 IN PSMgmtObject pMgmt
,
282 IN PWLAN_IE_SSID pSSID
,
283 IN PWLAN_IE_SUPP_RATES pCurrRates
,
284 IN PWLAN_IE_SUPP_RATES pCurrExtSuppRates
288 PSTxMgmtPacket pTxPacket
= NULL
;
289 WLAN_FR_PROBEREQ sFrame
;
292 pTxPacket
= (PSTxMgmtPacket
)pMgmt
->pbyMgmtPacketPool
;
293 memset(pTxPacket
, 0, sizeof(STxMgmtPacket
) + WLAN_PROBEREQ_FR_MAXLEN
);
294 pTxPacket
->p80211Header
= (PUWLAN_80211HDR
)((PBYTE
)pTxPacket
+ sizeof(STxMgmtPacket
));
295 sFrame
.pBuf
= (PBYTE
)pTxPacket
->p80211Header
;
296 sFrame
.len
= WLAN_PROBEREQ_FR_MAXLEN
;
297 vMgrEncodeProbeRequest(&sFrame
);
298 sFrame
.pHdr
->sA3
.wFrameCtl
= cpu_to_le16(
300 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR
) |
301 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_PROBEREQ
)
303 memcpy( sFrame
.pHdr
->sA3
.abyAddr1
, pScanBSSID
, WLAN_ADDR_LEN
);
304 memcpy( sFrame
.pHdr
->sA3
.abyAddr2
, pMgmt
->abyMACAddr
, WLAN_ADDR_LEN
);
305 memcpy( sFrame
.pHdr
->sA3
.abyAddr3
, pScanBSSID
, WLAN_BSSID_LEN
);
306 // Copy the SSID, pSSID->len=0 indicate broadcast SSID
307 sFrame
.pSSID
= (PWLAN_IE_SSID
)(sFrame
.pBuf
+ sFrame
.len
);
308 sFrame
.len
+= pSSID
->len
+ WLAN_IEHDR_LEN
;
309 memcpy(sFrame
.pSSID
, pSSID
, pSSID
->len
+ WLAN_IEHDR_LEN
);
310 sFrame
.pSuppRates
= (PWLAN_IE_SUPP_RATES
)(sFrame
.pBuf
+ sFrame
.len
);
311 sFrame
.len
+= pCurrRates
->len
+ WLAN_IEHDR_LEN
;
312 memcpy(sFrame
.pSuppRates
, pCurrRates
, pCurrRates
->len
+ WLAN_IEHDR_LEN
);
313 // Copy the extension rate set
314 if (pDevice
->byBBType
== BB_TYPE_11G
) {
315 sFrame
.pExtSuppRates
= (PWLAN_IE_SUPP_RATES
)(sFrame
.pBuf
+ sFrame
.len
);
316 sFrame
.len
+= pCurrExtSuppRates
->len
+ WLAN_IEHDR_LEN
;
317 memcpy(sFrame
.pExtSuppRates
, pCurrExtSuppRates
, pCurrExtSuppRates
->len
+ WLAN_IEHDR_LEN
);
319 pTxPacket
->cbMPDULen
= sFrame
.len
;
320 pTxPacket
->cbPayloadLen
= sFrame
.len
- WLAN_HDR_ADDR3_LEN
;
331 IN HANDLE hDeviceContext
,
335 PSDevice pDevice
= (PSDevice
)hDeviceContext
;
337 init_timer(&pDevice
->sTimerCommand
);
338 pDevice
->sTimerCommand
.data
= (ULONG
)pDevice
;
339 pDevice
->sTimerCommand
.function
= (TimerFunction
)vRunCommand
;
340 // RUN_AT :1 msec ~= (HZ/1024)
341 pDevice
->sTimerCommand
.expires
= (UINT
)RUN_AT((MSecond
* HZ
) >> 10);
342 add_timer(&pDevice
->sTimerCommand
);
351 IN HANDLE hDeviceContext
354 PSDevice pDevice
= (PSDevice
)hDeviceContext
;
355 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
356 PWLAN_IE_SSID pItemSSID
;
357 PWLAN_IE_SSID pItemSSIDCurr
;
360 BYTE byMask
[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80};
365 if (pDevice
->dwDiagRefCount
!= 0)
367 if (pDevice
->bCmdRunning
!= TRUE
)
370 spin_lock_irq(&pDevice
->lock
);
372 switch ( pDevice
->eCommandState
) {
374 case WLAN_CMD_SCAN_START
:
376 pDevice
->byReAssocCount
= 0;
377 if (pDevice
->bRadioOff
== TRUE
) {
378 s_bCommandComplete(pDevice
);
379 spin_unlock_irq(&pDevice
->lock
);
383 if (pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
) {
384 s_bCommandComplete(pDevice
);
385 spin_unlock_irq(&pDevice
->lock
);
389 pItemSSID
= (PWLAN_IE_SSID
)pMgmt
->abyScanSSID
;
391 if (pMgmt
->uScanChannel
== 0 ) {
392 pMgmt
->uScanChannel
= pDevice
->byMinChannel
;
394 if (pMgmt
->uScanChannel
> pDevice
->byMaxChannel
) {
395 pMgmt
->eScanState
= WMAC_NO_SCANNING
;
397 if (pDevice
->byBBType
!= pDevice
->byScanBBType
) {
398 pDevice
->byBBType
= pDevice
->byScanBBType
;
399 CARDvSetBSSMode(pDevice
);
402 if (pDevice
->bUpdateBBVGA
) {
403 BBvSetShortSlotTime(pDevice
);
404 BBvSetVGAGainOffset(pDevice
, pDevice
->byBBVGACurrent
);
405 BBvUpdatePreEDThreshold(pDevice
, FALSE
);
408 vAdHocBeaconRestart(pDevice
);
410 CARDbSetMediaChannel(pDevice
, pMgmt
->uCurrChannel
);
412 if (pMgmt
->bCurrBSSIDFilterOn
) {
413 MACvRegBitsOn(pDevice
, MAC_REG_RCR
, RCR_BSSID
);
414 pDevice
->byRxMode
|= RCR_BSSID
;
416 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Scanning, set back to channel: [%d]\n", pMgmt
->uCurrChannel
);
417 pDevice
->bStopDataPkt
= FALSE
;
418 s_bCommandComplete(pDevice
);
419 spin_unlock_irq(&pDevice
->lock
);
423 if (!ChannelValid(pDevice
->byZoneType
, pMgmt
->uScanChannel
)) {
424 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Invalid channel pMgmt->uScanChannel = %d \n",pMgmt
->uScanChannel
);
425 s_bCommandComplete(pDevice
);
426 spin_unlock_irq(&pDevice
->lock
);
429 if (pMgmt
->uScanChannel
== pDevice
->byMinChannel
) {
430 // pMgmt->eScanType = WMAC_SCAN_ACTIVE; //mike mark
431 pMgmt
->abyScanBSSID
[0] = 0xFF;
432 pMgmt
->abyScanBSSID
[1] = 0xFF;
433 pMgmt
->abyScanBSSID
[2] = 0xFF;
434 pMgmt
->abyScanBSSID
[3] = 0xFF;
435 pMgmt
->abyScanBSSID
[4] = 0xFF;
436 pMgmt
->abyScanBSSID
[5] = 0xFF;
437 pItemSSID
->byElementID
= WLAN_EID_SSID
;
439 // BSSvClearBSSList((HANDLE)pDevice, pDevice->bLinkPass);
440 pMgmt
->eScanState
= WMAC_IS_SCANNING
;
441 pDevice
->byScanBBType
= pDevice
->byBBType
; //lucas
442 pDevice
->bStopDataPkt
= TRUE
;
443 // Turn off RCR_BSSID filter everytime
444 MACvRegBitsOff(pDevice
, MAC_REG_RCR
, RCR_BSSID
);
445 pDevice
->byRxMode
&= ~RCR_BSSID
;
449 vAdHocBeaconStop(pDevice
);
450 if ((pDevice
->byBBType
!= BB_TYPE_11A
) && (pMgmt
->uScanChannel
> CB_MAX_CHANNEL_24G
)) {
451 pDevice
->byBBType
= BB_TYPE_11A
;
452 CARDvSetBSSMode(pDevice
);
454 else if ((pDevice
->byBBType
== BB_TYPE_11A
) && (pMgmt
->uScanChannel
<= CB_MAX_CHANNEL_24G
)) {
455 pDevice
->byBBType
= BB_TYPE_11G
;
456 CARDvSetBSSMode(pDevice
);
458 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Scanning.... channel: [%d]\n", pMgmt
->uScanChannel
);
460 CARDbSetMediaChannel(pDevice
, pMgmt
->uScanChannel
);
461 // Set Baseband to be more sensitive.
463 if (pDevice
->bUpdateBBVGA
) {
464 BBvSetShortSlotTime(pDevice
);
465 BBvSetVGAGainOffset(pDevice
, pDevice
->abyBBVGA
[0]);
466 BBvUpdatePreEDThreshold(pDevice
, TRUE
);
468 pMgmt
->uScanChannel
++;
470 while (!ChannelValid(pDevice
->byZoneType
, pMgmt
->uScanChannel
) &&
471 pMgmt
->uScanChannel
<= pDevice
->byMaxChannel
){
472 pMgmt
->uScanChannel
++;
475 if (pMgmt
->uScanChannel
> pDevice
->byMaxChannel
) {
476 // Set Baseband to be not sensitive and rescan
477 pDevice
->eCommandState
= WLAN_CMD_SCAN_END
;
480 if ((pMgmt
->b11hEnable
== FALSE
) ||
481 (pMgmt
->uScanChannel
< CB_MAX_CHANNEL_24G
)) {
482 s_vProbeChannel(pDevice
);
483 spin_unlock_irq(&pDevice
->lock
);
484 vCommandTimerWait((HANDLE
)pDevice
, 100);
487 spin_unlock_irq(&pDevice
->lock
);
488 vCommandTimerWait((HANDLE
)pDevice
, WCMD_PASSIVE_SCAN_TIME
);
496 case WLAN_CMD_SCAN_END
:
498 // Set Baseband's sensitivity back.
499 if (pDevice
->byBBType
!= pDevice
->byScanBBType
) {
500 pDevice
->byBBType
= pDevice
->byScanBBType
;
501 CARDvSetBSSMode(pDevice
);
504 if (pDevice
->bUpdateBBVGA
) {
505 BBvSetShortSlotTime(pDevice
);
506 BBvSetVGAGainOffset(pDevice
, pDevice
->byBBVGACurrent
);
507 BBvUpdatePreEDThreshold(pDevice
, FALSE
);
511 vAdHocBeaconRestart(pDevice
);
513 CARDbSetMediaChannel(pDevice
, pMgmt
->uCurrChannel
);
515 if (pMgmt
->bCurrBSSIDFilterOn
) {
516 MACvRegBitsOn(pDevice
, MAC_REG_RCR
, RCR_BSSID
);
517 pDevice
->byRxMode
|= RCR_BSSID
;
519 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Scanning, set back to channel: [%d]\n", pMgmt
->uCurrChannel
);
520 pMgmt
->eScanState
= WMAC_NO_SCANNING
;
521 pDevice
->bStopDataPkt
= FALSE
;
522 //2008-0409-07, <Add> by Einsn Liu
523 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
524 if(pMgmt
->eScanType
== WMAC_SCAN_PASSIVE
)
526 //send scan event to wpa_Supplicant
527 union iwreq_data wrqu
;
528 PRINT_K("wireless_send_event--->SIOCGIWSCAN(scan done)\n");
529 memset(&wrqu
, 0, sizeof(wrqu
));
530 wireless_send_event(pDevice
->dev
, SIOCGIWSCAN
, &wrqu
, NULL
);
533 s_bCommandComplete(pDevice
);
536 case WLAN_CMD_DISASSOCIATE_START
:
537 pDevice
->byReAssocCount
= 0;
538 if ((pMgmt
->eCurrMode
== WMAC_MODE_ESS_STA
) &&
539 (pMgmt
->eCurrState
!= WMAC_STATE_ASSOC
)) {
540 s_bCommandComplete(pDevice
);
541 spin_unlock_irq(&pDevice
->lock
);
545 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
546 pDevice
->bwextstep0
= FALSE
;
547 pDevice
->bwextstep1
= FALSE
;
548 pDevice
->bwextstep2
= FALSE
;
549 pDevice
->bwextstep3
= FALSE
;
550 pDevice
->bWPASuppWextEnabled
= FALSE
;
552 pDevice
->fWPA_Authened
= FALSE
;
554 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Send Disassociation Packet..\n");
555 // reason = 8 : disassoc because sta has left
556 vMgrDisassocBeginSta((HANDLE
)pDevice
, pMgmt
, pMgmt
->abyCurrBSSID
, (8), &Status
);
557 pDevice
->bLinkPass
= FALSE
;
558 ControlvMaskByte(pDevice
,MESSAGE_REQUEST_MACREG
,MAC_REG_PAPEDELAY
,LEDSTS_STS
,LEDSTS_SLOW
);
559 // unlock command busy
560 pItemSSID
= (PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
;
562 memset(pItemSSID
->abySSID
, 0, WLAN_SSID_MAXLEN
);
563 pMgmt
->eCurrState
= WMAC_STATE_IDLE
;
564 pMgmt
->sNodeDBTable
[0].bActive
= FALSE
;
565 // pDevice->bBeaconBufReady = FALSE;
567 netif_stop_queue(pDevice
->dev
);
568 if (pDevice
->bNeedRadioOFF
== TRUE
)
569 CARDbRadioPowerOff(pDevice
);
570 s_bCommandComplete(pDevice
);
574 case WLAN_CMD_SSID_START
:
576 pDevice
->byReAssocCount
= 0;
577 if (pDevice
->bRadioOff
== TRUE
) {
578 s_bCommandComplete(pDevice
);
579 spin_unlock_irq(&pDevice
->lock
);
583 //20080131-03,<Add> by Mike Liu
585 memcpy(pMgmt
->abyAdHocSSID
,pMgmt
->abyDesireSSID
,
586 ((PWLAN_IE_SSID
)pMgmt
->abyDesireSSID
)->len
+ WLAN_IEHDR_LEN
);
588 pItemSSID
= (PWLAN_IE_SSID
)pMgmt
->abyDesireSSID
;
589 pItemSSIDCurr
= (PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
;
590 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" cmd: desire ssid = %s\n", pItemSSID
->abySSID
);
591 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" cmd: curr ssid = %s\n", pItemSSIDCurr
->abySSID
);
593 if (pMgmt
->eCurrState
== WMAC_STATE_ASSOC
) {
594 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" Cmd pMgmt->eCurrState == WMAC_STATE_ASSOC\n");
595 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" pItemSSID->len =%d\n",pItemSSID
->len
);
596 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" pItemSSIDCurr->len = %d\n",pItemSSIDCurr
->len
);
597 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" desire ssid = %s\n", pItemSSID
->abySSID
);
598 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" curr ssid = %s\n", pItemSSIDCurr
->abySSID
);
601 if ((pMgmt
->eCurrState
== WMAC_STATE_ASSOC
) ||
602 ((pMgmt
->eCurrMode
== WMAC_MODE_IBSS_STA
)&& (pMgmt
->eCurrState
== WMAC_STATE_JOINTED
))) {
604 if (pItemSSID
->len
== pItemSSIDCurr
->len
) {
605 if (memcmp(pItemSSID
->abySSID
, pItemSSIDCurr
->abySSID
, pItemSSID
->len
) == 0) {
606 s_bCommandComplete(pDevice
);
607 spin_unlock_irq(&pDevice
->lock
);
611 netif_stop_queue(pDevice
->dev
);
612 pDevice
->bLinkPass
= FALSE
;
613 ControlvMaskByte(pDevice
,MESSAGE_REQUEST_MACREG
,MAC_REG_PAPEDELAY
,LEDSTS_STS
,LEDSTS_SLOW
);
616 pMgmt
->eCurrState
= WMAC_STATE_IDLE
;
617 pMgmt
->eCurrMode
= WMAC_MODE_STANDBY
;
618 PSvDisablePowerSaving((HANDLE
)pDevice
);
619 BSSvClearNodeDBTable(pDevice
, 0);
620 vMgrJoinBSSBegin((HANDLE
)pDevice
, &Status
);
622 if ((pMgmt
->eCurrMode
== WMAC_MODE_ESS_STA
) && (pMgmt
->eCurrState
== WMAC_STATE_JOINTED
)) {
623 // Call mgr to begin the deauthentication
624 // reason = (3) beacuse sta has left ESS
625 if (pMgmt
->eCurrState
>= WMAC_STATE_AUTH
) {
626 vMgrDeAuthenBeginSta((HANDLE
)pDevice
, pMgmt
, pMgmt
->abyCurrBSSID
, (3), &Status
);
628 // Call mgr to begin the authentication
629 vMgrAuthenBeginSta((HANDLE
)pDevice
, pMgmt
, &Status
);
630 if (Status
== CMD_STATUS_SUCCESS
) {
631 pDevice
->byLinkWaitCount
= 0;
632 pDevice
->eCommandState
= WLAN_AUTHENTICATE_WAIT
;
633 vCommandTimerWait((HANDLE
)pDevice
, AUTHENTICATE_TIMEOUT
);
634 spin_unlock_irq(&pDevice
->lock
);
635 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" Set eCommandState = WLAN_AUTHENTICATE_WAIT\n");
640 else if (pMgmt
->eCurrMode
== WMAC_MODE_IBSS_STA
) {
641 if (pMgmt
->eCurrState
== WMAC_STATE_JOINTED
) {
642 if (netif_queue_stopped(pDevice
->dev
)){
643 netif_wake_queue(pDevice
->dev
);
645 pDevice
->bLinkPass
= TRUE
;
646 ControlvMaskByte(pDevice
,MESSAGE_REQUEST_MACREG
,MAC_REG_PAPEDELAY
,LEDSTS_STS
,LEDSTS_INTER
);
647 pMgmt
->sNodeDBTable
[0].bActive
= TRUE
;
648 pMgmt
->sNodeDBTable
[0].uInActiveCount
= 0;
652 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"CreateOwn IBSS by CurrMode = IBSS_STA \n");
653 vMgrCreateOwnIBSS((HANDLE
)pDevice
, &Status
);
654 if (Status
!= CMD_STATUS_SUCCESS
){
655 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" WLAN_CMD_IBSS_CREATE fail ! \n");
657 BSSvAddMulticastNode(pDevice
);
659 s_bClearBSSID_SCAN(pDevice
);
662 else if (pMgmt
->eCurrMode
== WMAC_MODE_STANDBY
) {
663 if (pMgmt
->eConfigMode
== WMAC_CONFIG_IBSS_STA
||
664 pMgmt
->eConfigMode
== WMAC_CONFIG_AUTO
) {
666 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"CreateOwn IBSS by CurrMode = STANDBY \n");
667 vMgrCreateOwnIBSS((HANDLE
)pDevice
, &Status
);
668 if (Status
!= CMD_STATUS_SUCCESS
){
669 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" WLAN_CMD_IBSS_CREATE fail ! \n");
671 BSSvAddMulticastNode(pDevice
);
672 s_bClearBSSID_SCAN(pDevice
);
674 pDevice->bLinkPass = TRUE;
675 ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_INTER);
676 if (netif_queue_stopped(pDevice->dev)){
677 netif_wake_queue(pDevice->dev);
679 s_bClearBSSID_SCAN(pDevice);
683 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Disconnect SSID none\n");
684 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
685 // if(pDevice->bWPASuppWextEnabled == TRUE)
687 union iwreq_data wrqu
;
688 memset(&wrqu
, 0, sizeof (wrqu
));
689 wrqu
.ap_addr
.sa_family
= ARPHRD_ETHER
;
690 PRINT_K("wireless_send_event--->SIOCGIWAP(disassociated:vMgrJoinBSSBegin Fail !!)\n");
691 wireless_send_event(pDevice
->dev
, SIOCGIWAP
, &wrqu
, NULL
);
696 s_bCommandComplete(pDevice
);
699 case WLAN_AUTHENTICATE_WAIT
:
700 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"eCommandState == WLAN_AUTHENTICATE_WAIT\n");
701 if (pMgmt
->eCurrState
== WMAC_STATE_AUTH
) {
702 pDevice
->byLinkWaitCount
= 0;
703 // Call mgr to begin the association
704 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"eCurrState == WMAC_STATE_AUTH\n");
705 vMgrAssocBeginSta((HANDLE
)pDevice
, pMgmt
, &Status
);
706 if (Status
== CMD_STATUS_SUCCESS
) {
707 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"eCommandState = WLAN_ASSOCIATE_WAIT\n");
708 pDevice
->byLinkWaitCount
= 0;
709 pDevice
->eCommandState
= WLAN_ASSOCIATE_WAIT
;
710 vCommandTimerWait((HANDLE
)pDevice
, ASSOCIATE_TIMEOUT
);
711 spin_unlock_irq(&pDevice
->lock
);
715 else if(pMgmt
->eCurrState
< WMAC_STATE_AUTHPENDING
) {
716 printk("WLAN_AUTHENTICATE_WAIT:Authen Fail???\n");
718 else if(pDevice
->byLinkWaitCount
<= 4){ //mike add:wait another 2 sec if authenticated_frame delay!
719 pDevice
->byLinkWaitCount
++;
720 printk("WLAN_AUTHENTICATE_WAIT:wait %d times!!\n",pDevice
->byLinkWaitCount
);
721 spin_unlock_irq(&pDevice
->lock
);
722 vCommandTimerWait((HANDLE
)pDevice
, AUTHENTICATE_TIMEOUT
/2);
725 pDevice
->byLinkWaitCount
= 0;
727 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
728 // if(pDevice->bWPASuppWextEnabled == TRUE)
730 union iwreq_data wrqu
;
731 memset(&wrqu
, 0, sizeof (wrqu
));
732 wrqu
.ap_addr
.sa_family
= ARPHRD_ETHER
;
733 printk("wireless_send_event--->SIOCGIWAP(disassociated:AUTHENTICATE_WAIT_timeout)\n");
734 wireless_send_event(pDevice
->dev
, SIOCGIWAP
, &wrqu
, NULL
);
739 s_bCommandComplete(pDevice
);
742 case WLAN_ASSOCIATE_WAIT
:
743 if (pMgmt
->eCurrState
== WMAC_STATE_ASSOC
) {
744 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"eCurrState == WMAC_STATE_ASSOC\n");
745 if (pDevice
->ePSMode
!= WMAC_POWER_CAM
) {
746 PSvEnablePowerSaving((HANDLE
)pDevice
, pMgmt
->wListenInterval
);
749 if (pMgmt->eAuthenMode >= WMAC_AUTH_WPA) {
750 KeybRemoveAllKey(pDevice, &(pDevice->sKey), pDevice->abyBSSID);
753 pDevice
->byLinkWaitCount
= 0;
754 pDevice
->byReAssocCount
= 0;
755 pDevice
->bLinkPass
= TRUE
;
756 ControlvMaskByte(pDevice
,MESSAGE_REQUEST_MACREG
,MAC_REG_PAPEDELAY
,LEDSTS_STS
,LEDSTS_INTER
);
757 s_bClearBSSID_SCAN(pDevice
);
759 if (netif_queue_stopped(pDevice
->dev
)){
760 netif_wake_queue(pDevice
->dev
);
763 //2007-0115-07<Add>by MikeLiu
765 if(pDevice
->IsTxDataTrigger
!= FALSE
) { //TxDataTimer is not triggered at the first time
766 // printk("Re-initial TxDataTimer****\n");
767 del_timer(&pDevice
->sTimerTxData
);
768 init_timer(&pDevice
->sTimerTxData
);
769 pDevice
->sTimerTxData
.data
= (ULONG
)pDevice
;
770 pDevice
->sTimerTxData
.function
= (TimerFunction
)BSSvSecondTxData
;
771 pDevice
->sTimerTxData
.expires
= RUN_AT(10*HZ
); //10s callback
772 pDevice
->fTxDataInSleep
= FALSE
;
773 pDevice
->nTxDataTimeCout
= 0;
776 // printk("mike:-->First time triger TimerTxData InSleep\n");
778 pDevice
->IsTxDataTrigger
= TRUE
;
779 add_timer(&pDevice
->sTimerTxData
);
783 else if(pMgmt
->eCurrState
< WMAC_STATE_ASSOCPENDING
) {
784 printk("WLAN_ASSOCIATE_WAIT:Association Fail???\n");
786 else if(pDevice
->byLinkWaitCount
<= 4){ //mike add:wait another 2 sec if associated_frame delay!
787 pDevice
->byLinkWaitCount
++;
788 printk("WLAN_ASSOCIATE_WAIT:wait %d times!!\n",pDevice
->byLinkWaitCount
);
789 spin_unlock_irq(&pDevice
->lock
);
790 vCommandTimerWait((HANDLE
)pDevice
, ASSOCIATE_TIMEOUT
/2);
793 pDevice
->byLinkWaitCount
= 0;
795 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
796 // if(pDevice->bWPASuppWextEnabled == TRUE)
798 union iwreq_data wrqu
;
799 memset(&wrqu
, 0, sizeof (wrqu
));
800 wrqu
.ap_addr
.sa_family
= ARPHRD_ETHER
;
801 printk("wireless_send_event--->SIOCGIWAP(disassociated:ASSOCIATE_WAIT_timeout)\n");
802 wireless_send_event(pDevice
->dev
, SIOCGIWAP
, &wrqu
, NULL
);
807 s_bCommandComplete(pDevice
);
810 case WLAN_CMD_AP_MODE_START
:
811 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"eCommandState == WLAN_CMD_AP_MODE_START\n");
813 if (pMgmt
->eConfigMode
== WMAC_CONFIG_AP
) {
814 del_timer(&pMgmt
->sTimerSecondCallback
);
815 pMgmt
->eCurrState
= WMAC_STATE_IDLE
;
816 pMgmt
->eCurrMode
= WMAC_MODE_STANDBY
;
817 pDevice
->bLinkPass
= FALSE
;
818 ControlvMaskByte(pDevice
,MESSAGE_REQUEST_MACREG
,MAC_REG_PAPEDELAY
,LEDSTS_STS
,LEDSTS_SLOW
);
819 if (pDevice
->bEnableHostWEP
== TRUE
)
820 BSSvClearNodeDBTable(pDevice
, 1);
822 BSSvClearNodeDBTable(pDevice
, 0);
823 pDevice
->uAssocCount
= 0;
824 pMgmt
->eCurrState
= WMAC_STATE_IDLE
;
825 pDevice
->bFixRate
= FALSE
;
827 vMgrCreateOwnIBSS((HANDLE
)pDevice
, &Status
);
828 if (Status
!= CMD_STATUS_SUCCESS
){
829 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" vMgrCreateOwnIBSS fail ! \n");
831 // alway turn off unicast bit
832 MACvRegBitsOff(pDevice
, MAC_REG_RCR
, RCR_UNICAST
);
833 pDevice
->byRxMode
&= ~RCR_UNICAST
;
834 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"wcmd: rx_mode = %x\n", pDevice
->byRxMode
);
835 BSSvAddMulticastNode(pDevice
);
836 if (netif_queue_stopped(pDevice
->dev
)){
837 netif_wake_queue(pDevice
->dev
);
839 pDevice
->bLinkPass
= TRUE
;
840 ControlvMaskByte(pDevice
,MESSAGE_REQUEST_MACREG
,MAC_REG_PAPEDELAY
,LEDSTS_STS
,LEDSTS_INTER
);
841 add_timer(&pMgmt
->sTimerSecondCallback
);
843 s_bCommandComplete(pDevice
);
846 case WLAN_CMD_TX_PSPACKET_START
:
848 if (pMgmt
->sNodeDBTable
[0].bRxPSPoll
) {
849 while ((skb
= skb_dequeue(&pMgmt
->sNodeDBTable
[0].sTxPSQueue
)) != NULL
) {
850 if (skb_queue_empty(&pMgmt
->sNodeDBTable
[0].sTxPSQueue
)) {
851 pMgmt
->abyPSTxMap
[0] &= ~byMask
[0];
852 pDevice
->bMoreData
= FALSE
;
855 pDevice
->bMoreData
= TRUE
;
858 if (nsDMA_tx_packet(pDevice
, TYPE_AC0DMA
, skb
) != 0) {
859 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Multicast ps tx fail \n");
862 pMgmt
->sNodeDBTable
[0].wEnQueueCnt
--;
867 for (ii
= 1; ii
< (MAX_NODE_NUM
+ 1); ii
++) {
868 if (pMgmt
->sNodeDBTable
[ii
].bActive
&&
869 pMgmt
->sNodeDBTable
[ii
].bRxPSPoll
) {
870 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Index=%d Enqueu Cnt= %d\n",
871 ii
, pMgmt
->sNodeDBTable
[ii
].wEnQueueCnt
);
872 while ((skb
= skb_dequeue(&pMgmt
->sNodeDBTable
[ii
].sTxPSQueue
)) != NULL
) {
873 if (skb_queue_empty(&pMgmt
->sNodeDBTable
[ii
].sTxPSQueue
)) {
875 pMgmt
->abyPSTxMap
[pMgmt
->sNodeDBTable
[ii
].wAID
>> 3] &=
876 ~byMask
[pMgmt
->sNodeDBTable
[ii
].wAID
& 7];
877 pDevice
->bMoreData
= FALSE
;
880 pDevice
->bMoreData
= TRUE
;
883 if (nsDMA_tx_packet(pDevice
, TYPE_AC0DMA
, skb
) != 0) {
884 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"sta ps tx fail \n");
887 pMgmt
->sNodeDBTable
[ii
].wEnQueueCnt
--;
888 // check if sta ps enable, wait next pspoll
889 // if sta ps disable, send all pending buffers.
890 if (pMgmt
->sNodeDBTable
[ii
].bPSEnable
)
893 if (skb_queue_empty(&pMgmt
->sNodeDBTable
[ii
].sTxPSQueue
)) {
895 pMgmt
->abyPSTxMap
[pMgmt
->sNodeDBTable
[ii
].wAID
>> 3] &=
896 ~byMask
[pMgmt
->sNodeDBTable
[ii
].wAID
& 7];
897 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Index=%d PS queue clear \n", ii
);
899 pMgmt
->sNodeDBTable
[ii
].bRxPSPoll
= FALSE
;
903 s_bCommandComplete(pDevice
);
906 case WLAN_CMD_RADIO_START
:
908 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"eCommandState == WLAN_CMD_RADIO_START\n");
909 // if (pDevice->bRadioCmd == TRUE)
910 // CARDbRadioPowerOn(pDevice);
912 // CARDbRadioPowerOff(pDevice);
913 //2008-09-09<Add> BY Mike:Hot Key for Radio On/Off
915 NTSTATUS ntStatus
= STATUS_SUCCESS
;
918 ntStatus
= CONTROLnsRequestIn(pDevice
,
921 MESSAGE_REQUEST_MACREG
,
925 if ( ntStatus
!= STATUS_SUCCESS
) {
926 s_bCommandComplete(pDevice
);
927 spin_unlock_irq(&pDevice
->lock
);
930 if ( (byTmp
& GPIO3_DATA
) == 0 ) {
931 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" WLAN_CMD_RADIO_START_OFF........................\n");
932 // Old commands are useless.
934 pDevice
->cbFreeCmdQueue
= CMD_Q_SIZE
;
935 pDevice
->uCmdDequeueIdx
= 0;
936 pDevice
->uCmdEnqueueIdx
= 0;
937 //0415pDevice->bCmdRunning = FALSE;
938 pDevice
->bCmdClear
= TRUE
;
939 pDevice
->bStopTx0Pkt
= FALSE
;
940 pDevice
->bStopDataPkt
= TRUE
;
942 pDevice
->byKeyIndex
= 0;
943 pDevice
->bTransmitKey
= FALSE
;
944 spin_unlock_irq(&pDevice
->lock
);
945 KeyvInitTable(pDevice
,&pDevice
->sKey
);
946 spin_lock_irq(&pDevice
->lock
);
947 pMgmt
->byCSSPK
= KEY_CTL_NONE
;
948 pMgmt
->byCSSGK
= KEY_CTL_NONE
;
950 if (pDevice
->bLinkPass
== TRUE
) {
951 // reason = 8 : disassoc because sta has left
952 vMgrDisassocBeginSta((HANDLE
)pDevice
, pMgmt
, pMgmt
->abyCurrBSSID
, (8), &Status
);
953 pDevice
->bLinkPass
= FALSE
;
954 // unlock command busy
955 pMgmt
->eCurrState
= WMAC_STATE_IDLE
;
956 pMgmt
->sNodeDBTable
[0].bActive
= FALSE
;
957 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
958 // if(pDevice->bWPASuppWextEnabled == TRUE)
960 union iwreq_data wrqu
;
961 memset(&wrqu
, 0, sizeof (wrqu
));
962 wrqu
.ap_addr
.sa_family
= ARPHRD_ETHER
;
963 PRINT_K("wireless_send_event--->SIOCGIWAP(disassociated)\n");
964 wireless_send_event(pDevice
->dev
, SIOCGIWAP
, &wrqu
, NULL
);
968 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
969 pDevice
->bwextstep0
= FALSE
;
970 pDevice
->bwextstep1
= FALSE
;
971 pDevice
->bwextstep2
= FALSE
;
972 pDevice
->bwextstep3
= FALSE
;
973 pDevice
->bWPASuppWextEnabled
= FALSE
;
976 pItemSSID
= (PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
;
978 memset(pItemSSID
->abySSID
, 0, WLAN_SSID_MAXLEN
);
980 pItemSSID
= (PWLAN_IE_SSID
)pMgmt
->abyDesireSSID
;
982 memset(pItemSSID
->abySSID
, 0, WLAN_SSID_MAXLEN
);
984 netif_stop_queue(pDevice
->dev
);
985 CARDbRadioPowerOff(pDevice
);
986 MACvRegBitsOn(pDevice
,MAC_REG_GPIOCTL1
,GPIO3_INTMD
);
987 ControlvMaskByte(pDevice
,MESSAGE_REQUEST_MACREG
,MAC_REG_PAPEDELAY
,LEDSTS_STS
,LEDSTS_OFF
);
988 pDevice
->bHWRadioOff
= TRUE
;
990 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" WLAN_CMD_RADIO_START_ON........................\n");
991 pDevice
->bHWRadioOff
= FALSE
;
992 CARDbRadioPowerOn(pDevice
);
993 MACvRegBitsOff(pDevice
,MAC_REG_GPIOCTL1
,GPIO3_INTMD
);
994 ControlvMaskByte(pDevice
,MESSAGE_REQUEST_MACREG
,MAC_REG_PAPEDELAY
,LEDSTS_STS
,LEDSTS_ON
);
998 s_bCommandComplete(pDevice
);
1002 case WLAN_CMD_CHANGE_BBSENSITIVITY_START
:
1004 pDevice
->bStopDataPkt
= TRUE
;
1005 pDevice
->byBBVGACurrent
= pDevice
->byBBVGANew
;
1006 BBvSetVGAGainOffset(pDevice
, pDevice
->byBBVGACurrent
);
1007 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Change sensitivity pDevice->byBBVGACurrent = %x\n", pDevice
->byBBVGACurrent
);
1008 pDevice
->bStopDataPkt
= FALSE
;
1009 s_bCommandComplete(pDevice
);
1012 case WLAN_CMD_TBTT_WAKEUP_START
:
1013 PSbIsNextTBTTWakeUp(pDevice
);
1014 s_bCommandComplete(pDevice
);
1017 case WLAN_CMD_BECON_SEND_START
:
1018 bMgrPrepareBeaconToSend(pDevice
, pMgmt
);
1019 s_bCommandComplete(pDevice
);
1022 case WLAN_CMD_SETPOWER_START
:
1024 RFbSetPower(pDevice
, pDevice
->wCurrentRate
, pMgmt
->uCurrChannel
);
1026 s_bCommandComplete(pDevice
);
1029 case WLAN_CMD_CHANGE_ANTENNA_START
:
1030 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Change from Antenna%d to", (int)pDevice
->dwRxAntennaSel
);
1031 if ( pDevice
->dwRxAntennaSel
== 0) {
1032 pDevice
->dwRxAntennaSel
=1;
1033 if (pDevice
->bTxRxAntInv
== TRUE
)
1034 BBvSetAntennaMode(pDevice
, ANT_RXA
);
1036 BBvSetAntennaMode(pDevice
, ANT_RXB
);
1038 pDevice
->dwRxAntennaSel
=0;
1039 if (pDevice
->bTxRxAntInv
== TRUE
)
1040 BBvSetAntennaMode(pDevice
, ANT_RXB
);
1042 BBvSetAntennaMode(pDevice
, ANT_RXA
);
1044 s_bCommandComplete(pDevice
);
1047 case WLAN_CMD_REMOVE_ALLKEY_START
:
1048 KeybRemoveAllKey(pDevice
, &(pDevice
->sKey
), pDevice
->abyBSSID
);
1049 s_bCommandComplete(pDevice
);
1053 case WLAN_CMD_MAC_DISPOWERSAVING_START
:
1054 ControlvReadByte (pDevice
, MESSAGE_REQUEST_MACREG
, MAC_REG_PSCTL
, &byData
);
1055 if ( (byData
& PSCTL_PS
) != 0 ) {
1056 // disable power saving hw function
1057 CONTROLnsRequestOut(pDevice
,
1058 MESSAGE_TYPE_DISABLE_PS
,
1065 s_bCommandComplete(pDevice
);
1068 case WLAN_CMD_11H_CHSW_START
:
1069 CARDbSetMediaChannel(pDevice
, pDevice
->byNewChannel
);
1070 pDevice
->bChannelSwitch
= FALSE
;
1071 pMgmt
->uCurrChannel
= pDevice
->byNewChannel
;
1072 pDevice
->bStopDataPkt
= FALSE
;
1073 s_bCommandComplete(pDevice
);
1077 s_bCommandComplete(pDevice
);
1081 spin_unlock_irq(&pDevice
->lock
);
1088 s_bCommandComplete (
1092 PWLAN_IE_SSID pSSID
;
1093 BOOL bRadioCmd
= FALSE
;
1094 //WORD wDeAuthenReason = 0;
1095 BOOL bForceSCAN
= TRUE
;
1096 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
1099 pDevice
->eCommandState
= WLAN_CMD_IDLE
;
1100 if (pDevice
->cbFreeCmdQueue
== CMD_Q_SIZE
) {
1101 //Command Queue Empty
1102 pDevice
->bCmdRunning
= FALSE
;
1106 pDevice
->eCommand
= pDevice
->eCmdQueue
[pDevice
->uCmdDequeueIdx
].eCmd
;
1107 pSSID
= (PWLAN_IE_SSID
)pDevice
->eCmdQueue
[pDevice
->uCmdDequeueIdx
].abyCmdDesireSSID
;
1108 bRadioCmd
= pDevice
->eCmdQueue
[pDevice
->uCmdDequeueIdx
].bRadioCmd
;
1109 bForceSCAN
= pDevice
->eCmdQueue
[pDevice
->uCmdDequeueIdx
].bForceSCAN
;
1110 ADD_ONE_WITH_WRAP_AROUND(pDevice
->uCmdDequeueIdx
, CMD_Q_SIZE
);
1111 pDevice
->cbFreeCmdQueue
++;
1112 pDevice
->bCmdRunning
= TRUE
;
1113 switch ( pDevice
->eCommand
) {
1114 case WLAN_CMD_BSSID_SCAN
:
1115 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"eCommandState= WLAN_CMD_BSSID_SCAN\n");
1116 pDevice
->eCommandState
= WLAN_CMD_SCAN_START
;
1117 pMgmt
->uScanChannel
= 0;
1118 if (pSSID
->len
!= 0) {
1119 memcpy(pMgmt
->abyScanSSID
, pSSID
, WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1);
1121 memset(pMgmt
->abyScanSSID
, 0, WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1);
1124 if ((bForceSCAN == FALSE) && (pDevice->bLinkPass == TRUE)) {
1125 if ((pSSID->len == ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->len) &&
1126 ( !memcmp(pSSID->abySSID, ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->abySSID, pSSID->len))) {
1127 pDevice->eCommandState = WLAN_CMD_IDLE;
1133 pDevice
->eCommandState
= WLAN_CMD_SSID_START
;
1134 if (pSSID
->len
> WLAN_SSID_MAXLEN
)
1135 pSSID
->len
= WLAN_SSID_MAXLEN
;
1136 if (pSSID
->len
!= 0)
1137 memcpy(pMgmt
->abyDesireSSID
, pSSID
, WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1);
1138 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"eCommandState= WLAN_CMD_SSID_START\n");
1140 case WLAN_CMD_DISASSOCIATE
:
1141 pDevice
->eCommandState
= WLAN_CMD_DISASSOCIATE_START
;
1143 case WLAN_CMD_RX_PSPOLL
:
1144 pDevice
->eCommandState
= WLAN_CMD_TX_PSPACKET_START
;
1146 case WLAN_CMD_RUN_AP
:
1147 pDevice
->eCommandState
= WLAN_CMD_AP_MODE_START
;
1149 case WLAN_CMD_RADIO
:
1150 pDevice
->eCommandState
= WLAN_CMD_RADIO_START
;
1151 pDevice
->bRadioCmd
= bRadioCmd
;
1153 case WLAN_CMD_CHANGE_BBSENSITIVITY
:
1154 pDevice
->eCommandState
= WLAN_CMD_CHANGE_BBSENSITIVITY_START
;
1157 case WLAN_CMD_TBTT_WAKEUP
:
1158 pDevice
->eCommandState
= WLAN_CMD_TBTT_WAKEUP_START
;
1161 case WLAN_CMD_BECON_SEND
:
1162 pDevice
->eCommandState
= WLAN_CMD_BECON_SEND_START
;
1165 case WLAN_CMD_SETPOWER
:
1166 pDevice
->eCommandState
= WLAN_CMD_SETPOWER_START
;
1169 case WLAN_CMD_CHANGE_ANTENNA
:
1170 pDevice
->eCommandState
= WLAN_CMD_CHANGE_ANTENNA_START
;
1173 case WLAN_CMD_REMOVE_ALLKEY
:
1174 pDevice
->eCommandState
= WLAN_CMD_REMOVE_ALLKEY_START
;
1177 case WLAN_CMD_MAC_DISPOWERSAVING
:
1178 pDevice
->eCommandState
= WLAN_CMD_MAC_DISPOWERSAVING_START
;
1181 case WLAN_CMD_11H_CHSW
:
1182 pDevice
->eCommandState
= WLAN_CMD_11H_CHSW_START
;
1190 vCommandTimerWait((HANDLE
)pDevice
, 0);
1196 BOOL
bScheduleCommand (
1197 IN HANDLE hDeviceContext
,
1198 IN CMD_CODE eCommand
,
1202 PSDevice pDevice
= (PSDevice
)hDeviceContext
;
1205 if (pDevice
->cbFreeCmdQueue
== 0) {
1208 pDevice
->eCmdQueue
[pDevice
->uCmdEnqueueIdx
].eCmd
= eCommand
;
1209 pDevice
->eCmdQueue
[pDevice
->uCmdEnqueueIdx
].bForceSCAN
= TRUE
;
1210 memset(pDevice
->eCmdQueue
[pDevice
->uCmdEnqueueIdx
].abyCmdDesireSSID
, 0 , WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1);
1211 if (pbyItem0
!= NULL
) {
1213 case WLAN_CMD_BSSID_SCAN
:
1214 pDevice
->eCmdQueue
[pDevice
->uCmdEnqueueIdx
].bForceSCAN
= FALSE
;
1215 memcpy(pDevice
->eCmdQueue
[pDevice
->uCmdEnqueueIdx
].abyCmdDesireSSID
,
1216 pbyItem0
, WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1);
1220 memcpy(pDevice
->eCmdQueue
[pDevice
->uCmdEnqueueIdx
].abyCmdDesireSSID
,
1221 pbyItem0
, WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1);
1224 case WLAN_CMD_DISASSOCIATE
:
1225 pDevice
->eCmdQueue
[pDevice
->uCmdEnqueueIdx
].bNeedRadioOFF
= *((int *)pbyItem0
);
1228 case WLAN_CMD_DEAUTH:
1229 pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].wDeAuthenReason = *((PWORD)pbyItem0);
1233 case WLAN_CMD_RADIO
:
1234 pDevice
->eCmdQueue
[pDevice
->uCmdEnqueueIdx
].bRadioCmd
= *((int *)pbyItem0
);
1242 ADD_ONE_WITH_WRAP_AROUND(pDevice
->uCmdEnqueueIdx
, CMD_Q_SIZE
);
1243 pDevice
->cbFreeCmdQueue
--;
1245 if (pDevice
->bCmdRunning
== FALSE
) {
1246 s_bCommandComplete(pDevice
);
1256 * Clear BSSID_SCAN cmd in CMD Queue
1260 * hDeviceContext - Pointer to the adapter
1261 * eCommand - Command
1265 * Return Value: TRUE if success; otherwise FALSE
1269 BOOL
s_bClearBSSID_SCAN (
1270 IN HANDLE hDeviceContext
1273 PSDevice pDevice
= (PSDevice
)hDeviceContext
;
1274 UINT uCmdDequeueIdx
= pDevice
->uCmdDequeueIdx
;
1277 if ((pDevice
->cbFreeCmdQueue
< CMD_Q_SIZE
) && (uCmdDequeueIdx
!= pDevice
->uCmdEnqueueIdx
)) {
1278 for (ii
= 0; ii
< (CMD_Q_SIZE
- pDevice
->cbFreeCmdQueue
); ii
++) {
1279 if (pDevice
->eCmdQueue
[uCmdDequeueIdx
].eCmd
== WLAN_CMD_BSSID_SCAN
)
1280 pDevice
->eCmdQueue
[uCmdDequeueIdx
].eCmd
= WLAN_CMD_IDLE
;
1281 ADD_ONE_WITH_WRAP_AROUND(uCmdDequeueIdx
, CMD_Q_SIZE
);
1282 if (uCmdDequeueIdx
== pDevice
->uCmdEnqueueIdx
)
1290 //mike add:reset command timer
1293 IN HANDLE hDeviceContext
1296 PSDevice pDevice
= (PSDevice
)hDeviceContext
;
1299 del_timer(&pDevice
->sTimerCommand
);
1301 init_timer(&pDevice
->sTimerCommand
);
1302 pDevice
->sTimerCommand
.data
= (ULONG
)pDevice
;
1303 pDevice
->sTimerCommand
.function
= (TimerFunction
)vRunCommand
;
1304 pDevice
->sTimerCommand
.expires
= RUN_AT(HZ
);
1305 pDevice
->cbFreeCmdQueue
= CMD_Q_SIZE
;
1306 pDevice
->uCmdDequeueIdx
= 0;
1307 pDevice
->uCmdEnqueueIdx
= 0;
1308 pDevice
->eCommandState
= WLAN_CMD_IDLE
;
1309 pDevice
->bCmdRunning
= FALSE
;
1310 pDevice
->bCmdClear
= FALSE
;
1313 //2007-0115-08<Add>by MikeLiu
1317 IN HANDLE hDeviceContext
1320 PSDevice pDevice
= (PSDevice
)hDeviceContext
;
1321 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
1323 pDevice
->nTxDataTimeCout
++;
1325 if(pDevice
->nTxDataTimeCout
<4) //don't tx data if timer less than 40s
1327 // printk("mike:%s-->no data Tx not exceed the desired Time as %d\n",__FUNCTION__,
1328 // (int)pDevice->nTxDataTimeCout);
1329 pDevice
->sTimerTxData
.expires
= RUN_AT(10*HZ
); //10s callback
1330 add_timer(&pDevice
->sTimerTxData
);
1334 spin_lock_irq(&pDevice
->lock
);
1335 //is wap_supplicant running sucessful OR only open && sharekey mode!
1337 if(((pDevice
->bLinkPass
==TRUE
)&&(pMgmt
->eAuthenMode
< WMAC_AUTH_WPA
)) || //open && sharekey linking
1338 (pDevice
->fWPA_Authened
== TRUE
)) { //wpa linking
1340 if(pDevice
->bLinkPass
==TRUE
) {
1342 // printk("mike:%s-->InSleep Tx Data Procedure\n",__FUNCTION__);
1343 pDevice
->fTxDataInSleep
= TRUE
;
1344 PSbSendNullPacket(pDevice
); //send null packet
1345 pDevice
->fTxDataInSleep
= FALSE
;
1347 spin_unlock_irq(&pDevice
->lock
);
1349 pDevice
->sTimerTxData
.expires
= RUN_AT(10*HZ
); //10s callback
1350 add_timer(&pDevice
->sTimerTxData
);