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 int MSecond
)
321 PSDevice pDevice
= (PSDevice
)hDeviceContext
;
323 init_timer(&pDevice
->sTimerCommand
);
324 pDevice
->sTimerCommand
.data
= (unsigned long)pDevice
;
325 pDevice
->sTimerCommand
.function
= (TimerFunction
)vRunCommand
;
326 // RUN_AT :1 msec ~= (HZ/1024)
327 pDevice
->sTimerCommand
.expires
= (unsigned int)RUN_AT((MSecond
* HZ
) >> 10);
328 add_timer(&pDevice
->sTimerCommand
);
332 void vRunCommand(void *hDeviceContext
)
334 PSDevice pDevice
= (PSDevice
)hDeviceContext
;
335 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
336 PWLAN_IE_SSID pItemSSID
;
337 PWLAN_IE_SSID pItemSSIDCurr
;
340 BYTE byMask
[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80};
345 if (pDevice
->dwDiagRefCount
!= 0)
347 if (pDevice
->bCmdRunning
!= TRUE
)
350 spin_lock_irq(&pDevice
->lock
);
352 switch ( pDevice
->eCommandState
) {
354 case WLAN_CMD_SCAN_START
:
356 pDevice
->byReAssocCount
= 0;
357 if (pDevice
->bRadioOff
== TRUE
) {
358 s_bCommandComplete(pDevice
);
359 spin_unlock_irq(&pDevice
->lock
);
363 if (pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
) {
364 s_bCommandComplete(pDevice
);
365 spin_unlock_irq(&pDevice
->lock
);
369 pItemSSID
= (PWLAN_IE_SSID
)pMgmt
->abyScanSSID
;
371 if (pMgmt
->uScanChannel
== 0 ) {
372 pMgmt
->uScanChannel
= pDevice
->byMinChannel
;
374 if (pMgmt
->uScanChannel
> pDevice
->byMaxChannel
) {
375 pMgmt
->eScanState
= WMAC_NO_SCANNING
;
377 if (pDevice
->byBBType
!= pDevice
->byScanBBType
) {
378 pDevice
->byBBType
= pDevice
->byScanBBType
;
379 CARDvSetBSSMode(pDevice
);
382 if (pDevice
->bUpdateBBVGA
) {
383 BBvSetShortSlotTime(pDevice
);
384 BBvSetVGAGainOffset(pDevice
, pDevice
->byBBVGACurrent
);
385 BBvUpdatePreEDThreshold(pDevice
, FALSE
);
388 vAdHocBeaconRestart(pDevice
);
390 CARDbSetMediaChannel(pDevice
, pMgmt
->uCurrChannel
);
392 if (pMgmt
->bCurrBSSIDFilterOn
) {
393 MACvRegBitsOn(pDevice
, MAC_REG_RCR
, RCR_BSSID
);
394 pDevice
->byRxMode
|= RCR_BSSID
;
396 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Scanning, set back to channel: [%d]\n", pMgmt
->uCurrChannel
);
397 pDevice
->bStopDataPkt
= FALSE
;
398 s_bCommandComplete(pDevice
);
399 spin_unlock_irq(&pDevice
->lock
);
403 if (!ChannelValid(pDevice
->byZoneType
, pMgmt
->uScanChannel
)) {
404 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Invalid channel pMgmt->uScanChannel = %d \n",pMgmt
->uScanChannel
);
405 s_bCommandComplete(pDevice
);
406 spin_unlock_irq(&pDevice
->lock
);
409 if (pMgmt
->uScanChannel
== pDevice
->byMinChannel
) {
410 // pMgmt->eScanType = WMAC_SCAN_ACTIVE; //mike mark
411 pMgmt
->abyScanBSSID
[0] = 0xFF;
412 pMgmt
->abyScanBSSID
[1] = 0xFF;
413 pMgmt
->abyScanBSSID
[2] = 0xFF;
414 pMgmt
->abyScanBSSID
[3] = 0xFF;
415 pMgmt
->abyScanBSSID
[4] = 0xFF;
416 pMgmt
->abyScanBSSID
[5] = 0xFF;
417 pItemSSID
->byElementID
= WLAN_EID_SSID
;
419 /* BSSvClearBSSList((void *) pDevice,
420 pDevice->bLinkPass); */
421 pMgmt
->eScanState
= WMAC_IS_SCANNING
;
422 pDevice
->byScanBBType
= pDevice
->byBBType
; //lucas
423 pDevice
->bStopDataPkt
= TRUE
;
424 // Turn off RCR_BSSID filter every time
425 MACvRegBitsOff(pDevice
, MAC_REG_RCR
, RCR_BSSID
);
426 pDevice
->byRxMode
&= ~RCR_BSSID
;
430 vAdHocBeaconStop(pDevice
);
431 if ((pDevice
->byBBType
!= BB_TYPE_11A
) && (pMgmt
->uScanChannel
> CB_MAX_CHANNEL_24G
)) {
432 pDevice
->byBBType
= BB_TYPE_11A
;
433 CARDvSetBSSMode(pDevice
);
435 else if ((pDevice
->byBBType
== BB_TYPE_11A
) && (pMgmt
->uScanChannel
<= CB_MAX_CHANNEL_24G
)) {
436 pDevice
->byBBType
= BB_TYPE_11G
;
437 CARDvSetBSSMode(pDevice
);
439 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Scanning.... channel: [%d]\n", pMgmt
->uScanChannel
);
441 CARDbSetMediaChannel(pDevice
, pMgmt
->uScanChannel
);
442 // Set Baseband to be more sensitive.
444 if (pDevice
->bUpdateBBVGA
) {
445 BBvSetShortSlotTime(pDevice
);
446 BBvSetVGAGainOffset(pDevice
, pDevice
->abyBBVGA
[0]);
447 BBvUpdatePreEDThreshold(pDevice
, TRUE
);
449 pMgmt
->uScanChannel
++;
451 while (!ChannelValid(pDevice
->byZoneType
, pMgmt
->uScanChannel
) &&
452 pMgmt
->uScanChannel
<= pDevice
->byMaxChannel
){
453 pMgmt
->uScanChannel
++;
456 if (pMgmt
->uScanChannel
> pDevice
->byMaxChannel
) {
457 // Set Baseband to be not sensitive and rescan
458 pDevice
->eCommandState
= WLAN_CMD_SCAN_END
;
461 if ((pMgmt
->b11hEnable
== FALSE
) ||
462 (pMgmt
->uScanChannel
< CB_MAX_CHANNEL_24G
)) {
463 s_vProbeChannel(pDevice
);
464 spin_unlock_irq(&pDevice
->lock
);
465 vCommandTimerWait((void *) pDevice
, 100);
468 spin_unlock_irq(&pDevice
->lock
);
469 vCommandTimerWait((void *) pDevice
, WCMD_PASSIVE_SCAN_TIME
);
477 case WLAN_CMD_SCAN_END
:
479 // Set Baseband's sensitivity back.
480 if (pDevice
->byBBType
!= pDevice
->byScanBBType
) {
481 pDevice
->byBBType
= pDevice
->byScanBBType
;
482 CARDvSetBSSMode(pDevice
);
485 if (pDevice
->bUpdateBBVGA
) {
486 BBvSetShortSlotTime(pDevice
);
487 BBvSetVGAGainOffset(pDevice
, pDevice
->byBBVGACurrent
);
488 BBvUpdatePreEDThreshold(pDevice
, FALSE
);
492 vAdHocBeaconRestart(pDevice
);
494 CARDbSetMediaChannel(pDevice
, pMgmt
->uCurrChannel
);
496 if (pMgmt
->bCurrBSSIDFilterOn
) {
497 MACvRegBitsOn(pDevice
, MAC_REG_RCR
, RCR_BSSID
);
498 pDevice
->byRxMode
|= RCR_BSSID
;
500 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Scanning, set back to channel: [%d]\n", pMgmt
->uCurrChannel
);
501 pMgmt
->eScanState
= WMAC_NO_SCANNING
;
502 pDevice
->bStopDataPkt
= FALSE
;
504 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
505 if(pMgmt
->eScanType
== WMAC_SCAN_PASSIVE
)
507 //send scan event to wpa_Supplicant
508 union iwreq_data wrqu
;
509 PRINT_K("wireless_send_event--->SIOCGIWSCAN(scan done)\n");
510 memset(&wrqu
, 0, sizeof(wrqu
));
511 wireless_send_event(pDevice
->dev
, SIOCGIWSCAN
, &wrqu
, NULL
);
514 s_bCommandComplete(pDevice
);
517 case WLAN_CMD_DISASSOCIATE_START
:
518 pDevice
->byReAssocCount
= 0;
519 if ((pMgmt
->eCurrMode
== WMAC_MODE_ESS_STA
) &&
520 (pMgmt
->eCurrState
!= WMAC_STATE_ASSOC
)) {
521 s_bCommandComplete(pDevice
);
522 spin_unlock_irq(&pDevice
->lock
);
526 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
527 pDevice
->bwextstep0
= FALSE
;
528 pDevice
->bwextstep1
= FALSE
;
529 pDevice
->bwextstep2
= FALSE
;
530 pDevice
->bwextstep3
= FALSE
;
531 pDevice
->bWPASuppWextEnabled
= FALSE
;
533 pDevice
->fWPA_Authened
= FALSE
;
535 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Send Disassociation Packet..\n");
536 // reason = 8 : disassoc because sta has left
537 vMgrDisassocBeginSta((void *) pDevice
,
542 pDevice
->bLinkPass
= FALSE
;
543 ControlvMaskByte(pDevice
,MESSAGE_REQUEST_MACREG
,MAC_REG_PAPEDELAY
,LEDSTS_STS
,LEDSTS_SLOW
);
544 // unlock command busy
545 pItemSSID
= (PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
;
547 memset(pItemSSID
->abySSID
, 0, WLAN_SSID_MAXLEN
);
548 pMgmt
->eCurrState
= WMAC_STATE_IDLE
;
549 pMgmt
->sNodeDBTable
[0].bActive
= FALSE
;
550 // pDevice->bBeaconBufReady = FALSE;
552 netif_stop_queue(pDevice
->dev
);
553 if (pDevice
->bNeedRadioOFF
== TRUE
)
554 CARDbRadioPowerOff(pDevice
);
555 s_bCommandComplete(pDevice
);
559 case WLAN_CMD_SSID_START
:
561 pDevice
->byReAssocCount
= 0;
562 if (pDevice
->bRadioOff
== TRUE
) {
563 s_bCommandComplete(pDevice
);
564 spin_unlock_irq(&pDevice
->lock
);
568 memcpy(pMgmt
->abyAdHocSSID
,pMgmt
->abyDesireSSID
,
569 ((PWLAN_IE_SSID
)pMgmt
->abyDesireSSID
)->len
+ WLAN_IEHDR_LEN
);
571 pItemSSID
= (PWLAN_IE_SSID
)pMgmt
->abyDesireSSID
;
572 pItemSSIDCurr
= (PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
;
573 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" cmd: desire ssid = %s\n", pItemSSID
->abySSID
);
574 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" cmd: curr ssid = %s\n", pItemSSIDCurr
->abySSID
);
576 if (pMgmt
->eCurrState
== WMAC_STATE_ASSOC
) {
577 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" Cmd pMgmt->eCurrState == WMAC_STATE_ASSOC\n");
578 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" pItemSSID->len =%d\n",pItemSSID
->len
);
579 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" pItemSSIDCurr->len = %d\n",pItemSSIDCurr
->len
);
580 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" desire ssid = %s\n", pItemSSID
->abySSID
);
581 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" curr ssid = %s\n", pItemSSIDCurr
->abySSID
);
584 if ((pMgmt
->eCurrState
== WMAC_STATE_ASSOC
) ||
585 ((pMgmt
->eCurrMode
== WMAC_MODE_IBSS_STA
)&& (pMgmt
->eCurrState
== WMAC_STATE_JOINTED
))) {
587 if (pItemSSID
->len
== pItemSSIDCurr
->len
) {
588 if (memcmp(pItemSSID
->abySSID
, pItemSSIDCurr
->abySSID
, pItemSSID
->len
) == 0) {
589 s_bCommandComplete(pDevice
);
590 spin_unlock_irq(&pDevice
->lock
);
594 netif_stop_queue(pDevice
->dev
);
595 pDevice
->bLinkPass
= FALSE
;
596 ControlvMaskByte(pDevice
,MESSAGE_REQUEST_MACREG
,MAC_REG_PAPEDELAY
,LEDSTS_STS
,LEDSTS_SLOW
);
599 pMgmt
->eCurrState
= WMAC_STATE_IDLE
;
600 pMgmt
->eCurrMode
= WMAC_MODE_STANDBY
;
601 PSvDisablePowerSaving((void *) pDevice
);
602 BSSvClearNodeDBTable(pDevice
, 0);
603 vMgrJoinBSSBegin((void *) pDevice
, &Status
);
605 if ((pMgmt
->eCurrMode
== WMAC_MODE_ESS_STA
) && (pMgmt
->eCurrState
== WMAC_STATE_JOINTED
)) {
606 // Call mgr to begin the deauthentication
607 // reason = (3) because sta has left ESS
608 if (pMgmt
->eCurrState
>= WMAC_STATE_AUTH
) {
609 vMgrDeAuthenBeginSta((void *)pDevice
,
615 // Call mgr to begin the authentication
616 vMgrAuthenBeginSta((void *) pDevice
, pMgmt
, &Status
);
617 if (Status
== CMD_STATUS_SUCCESS
) {
618 pDevice
->byLinkWaitCount
= 0;
619 pDevice
->eCommandState
= WLAN_AUTHENTICATE_WAIT
;
620 vCommandTimerWait((void *) pDevice
, AUTHENTICATE_TIMEOUT
);
621 spin_unlock_irq(&pDevice
->lock
);
622 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" Set eCommandState = WLAN_AUTHENTICATE_WAIT\n");
627 else if (pMgmt
->eCurrMode
== WMAC_MODE_IBSS_STA
) {
628 if (pMgmt
->eCurrState
== WMAC_STATE_JOINTED
) {
629 if (netif_queue_stopped(pDevice
->dev
)){
630 netif_wake_queue(pDevice
->dev
);
632 pDevice
->bLinkPass
= TRUE
;
633 ControlvMaskByte(pDevice
,MESSAGE_REQUEST_MACREG
,MAC_REG_PAPEDELAY
,LEDSTS_STS
,LEDSTS_INTER
);
634 pMgmt
->sNodeDBTable
[0].bActive
= TRUE
;
635 pMgmt
->sNodeDBTable
[0].uInActiveCount
= 0;
639 DBG_PRT(MSG_LEVEL_DEBUG
,
640 KERN_INFO
"CreateOwn IBSS by CurrMode = IBSS_STA\n");
641 vMgrCreateOwnIBSS((void *) pDevice
, &Status
);
642 if (Status
!= CMD_STATUS_SUCCESS
){
643 DBG_PRT(MSG_LEVEL_DEBUG
,
644 KERN_INFO
"WLAN_CMD_IBSS_CREATE fail!\n");
646 BSSvAddMulticastNode(pDevice
);
648 s_bClearBSSID_SCAN(pDevice
);
651 else if (pMgmt
->eCurrMode
== WMAC_MODE_STANDBY
) {
652 if (pMgmt
->eConfigMode
== WMAC_CONFIG_IBSS_STA
||
653 pMgmt
->eConfigMode
== WMAC_CONFIG_AUTO
) {
655 DBG_PRT(MSG_LEVEL_DEBUG
,
656 KERN_INFO
"CreateOwn IBSS by CurrMode = STANDBY\n");
657 vMgrCreateOwnIBSS((void *) pDevice
, &Status
);
658 if (Status
!= CMD_STATUS_SUCCESS
){
659 DBG_PRT(MSG_LEVEL_DEBUG
,
660 KERN_INFO
"WLAN_CMD_IBSS_CREATE fail!\n");
662 BSSvAddMulticastNode(pDevice
);
663 s_bClearBSSID_SCAN(pDevice
);
665 pDevice->bLinkPass = TRUE;
666 ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_INTER);
667 if (netif_queue_stopped(pDevice->dev)){
668 netif_wake_queue(pDevice->dev);
670 s_bClearBSSID_SCAN(pDevice);
674 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Disconnect SSID none\n");
675 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
676 // if(pDevice->bWPASuppWextEnabled == TRUE)
678 union iwreq_data wrqu
;
679 memset(&wrqu
, 0, sizeof (wrqu
));
680 wrqu
.ap_addr
.sa_family
= ARPHRD_ETHER
;
681 PRINT_K("wireless_send_event--->SIOCGIWAP(disassociated:vMgrJoinBSSBegin Fail !!)\n");
682 wireless_send_event(pDevice
->dev
, SIOCGIWAP
, &wrqu
, NULL
);
687 s_bCommandComplete(pDevice
);
690 case WLAN_AUTHENTICATE_WAIT
:
691 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"eCommandState == WLAN_AUTHENTICATE_WAIT\n");
692 if (pMgmt
->eCurrState
== WMAC_STATE_AUTH
) {
693 pDevice
->byLinkWaitCount
= 0;
694 // Call mgr to begin the association
695 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"eCurrState == WMAC_STATE_AUTH\n");
696 vMgrAssocBeginSta((void *) pDevice
, pMgmt
, &Status
);
697 if (Status
== CMD_STATUS_SUCCESS
) {
698 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"eCommandState = WLAN_ASSOCIATE_WAIT\n");
699 pDevice
->byLinkWaitCount
= 0;
700 pDevice
->eCommandState
= WLAN_ASSOCIATE_WAIT
;
701 vCommandTimerWait((void *) pDevice
, ASSOCIATE_TIMEOUT
);
702 spin_unlock_irq(&pDevice
->lock
);
706 else if(pMgmt
->eCurrState
< WMAC_STATE_AUTHPENDING
) {
707 printk("WLAN_AUTHENTICATE_WAIT:Authen Fail???\n");
709 else if(pDevice
->byLinkWaitCount
<= 4){ //mike add:wait another 2 sec if authenticated_frame delay!
710 pDevice
->byLinkWaitCount
++;
711 printk("WLAN_AUTHENTICATE_WAIT:wait %d times!!\n",pDevice
->byLinkWaitCount
);
712 spin_unlock_irq(&pDevice
->lock
);
713 vCommandTimerWait((void *) pDevice
, AUTHENTICATE_TIMEOUT
/2);
716 pDevice
->byLinkWaitCount
= 0;
718 s_bCommandComplete(pDevice
);
721 case WLAN_ASSOCIATE_WAIT
:
722 if (pMgmt
->eCurrState
== WMAC_STATE_ASSOC
) {
723 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"eCurrState == WMAC_STATE_ASSOC\n");
724 if (pDevice
->ePSMode
!= WMAC_POWER_CAM
) {
725 PSvEnablePowerSaving((void *) pDevice
,
726 pMgmt
->wListenInterval
);
729 if (pMgmt->eAuthenMode >= WMAC_AUTH_WPA) {
730 KeybRemoveAllKey(pDevice, &(pDevice->sKey), pDevice->abyBSSID);
733 pDevice
->byLinkWaitCount
= 0;
734 pDevice
->byReAssocCount
= 0;
735 pDevice
->bLinkPass
= TRUE
;
736 ControlvMaskByte(pDevice
,MESSAGE_REQUEST_MACREG
,MAC_REG_PAPEDELAY
,LEDSTS_STS
,LEDSTS_INTER
);
737 s_bClearBSSID_SCAN(pDevice
);
739 if (netif_queue_stopped(pDevice
->dev
)){
740 netif_wake_queue(pDevice
->dev
);
743 if(pDevice
->IsTxDataTrigger
!= FALSE
) { //TxDataTimer is not triggered at the first time
744 // printk("Re-initial TxDataTimer****\n");
745 del_timer(&pDevice
->sTimerTxData
);
746 init_timer(&pDevice
->sTimerTxData
);
747 pDevice
->sTimerTxData
.data
= (unsigned long) pDevice
;
748 pDevice
->sTimerTxData
.function
= (TimerFunction
)BSSvSecondTxData
;
749 pDevice
->sTimerTxData
.expires
= RUN_AT(10*HZ
); //10s callback
750 pDevice
->fTxDataInSleep
= FALSE
;
751 pDevice
->nTxDataTimeCout
= 0;
754 // printk("mike:-->First time triger TimerTxData InSleep\n");
756 pDevice
->IsTxDataTrigger
= TRUE
;
757 add_timer(&pDevice
->sTimerTxData
);
760 else if(pMgmt
->eCurrState
< WMAC_STATE_ASSOCPENDING
) {
761 printk("WLAN_ASSOCIATE_WAIT:Association Fail???\n");
763 else if(pDevice
->byLinkWaitCount
<= 4){ //mike add:wait another 2 sec if associated_frame delay!
764 pDevice
->byLinkWaitCount
++;
765 printk("WLAN_ASSOCIATE_WAIT:wait %d times!!\n",pDevice
->byLinkWaitCount
);
766 spin_unlock_irq(&pDevice
->lock
);
767 vCommandTimerWait((void *) pDevice
, ASSOCIATE_TIMEOUT
/2);
770 pDevice
->byLinkWaitCount
= 0;
772 s_bCommandComplete(pDevice
);
775 case WLAN_CMD_AP_MODE_START
:
776 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"eCommandState == WLAN_CMD_AP_MODE_START\n");
778 if (pMgmt
->eConfigMode
== WMAC_CONFIG_AP
) {
779 del_timer(&pMgmt
->sTimerSecondCallback
);
780 pMgmt
->eCurrState
= WMAC_STATE_IDLE
;
781 pMgmt
->eCurrMode
= WMAC_MODE_STANDBY
;
782 pDevice
->bLinkPass
= FALSE
;
783 ControlvMaskByte(pDevice
,MESSAGE_REQUEST_MACREG
,MAC_REG_PAPEDELAY
,LEDSTS_STS
,LEDSTS_SLOW
);
784 if (pDevice
->bEnableHostWEP
== TRUE
)
785 BSSvClearNodeDBTable(pDevice
, 1);
787 BSSvClearNodeDBTable(pDevice
, 0);
788 pDevice
->uAssocCount
= 0;
789 pMgmt
->eCurrState
= WMAC_STATE_IDLE
;
790 pDevice
->bFixRate
= FALSE
;
792 vMgrCreateOwnIBSS((void *) pDevice
, &Status
);
793 if (Status
!= CMD_STATUS_SUCCESS
) {
794 DBG_PRT(MSG_LEVEL_DEBUG
,
795 KERN_INFO
"vMgrCreateOwnIBSS fail!\n");
797 // alway turn off unicast bit
798 MACvRegBitsOff(pDevice
, MAC_REG_RCR
, RCR_UNICAST
);
799 pDevice
->byRxMode
&= ~RCR_UNICAST
;
800 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"wcmd: rx_mode = %x\n", pDevice
->byRxMode
);
801 BSSvAddMulticastNode(pDevice
);
802 if (netif_queue_stopped(pDevice
->dev
)){
803 netif_wake_queue(pDevice
->dev
);
805 pDevice
->bLinkPass
= TRUE
;
806 ControlvMaskByte(pDevice
,MESSAGE_REQUEST_MACREG
,MAC_REG_PAPEDELAY
,LEDSTS_STS
,LEDSTS_INTER
);
807 add_timer(&pMgmt
->sTimerSecondCallback
);
809 s_bCommandComplete(pDevice
);
812 case WLAN_CMD_TX_PSPACKET_START
:
814 if (pMgmt
->sNodeDBTable
[0].bRxPSPoll
) {
815 while ((skb
= skb_dequeue(&pMgmt
->sNodeDBTable
[0].sTxPSQueue
)) != NULL
) {
816 if (skb_queue_empty(&pMgmt
->sNodeDBTable
[0].sTxPSQueue
)) {
817 pMgmt
->abyPSTxMap
[0] &= ~byMask
[0];
818 pDevice
->bMoreData
= FALSE
;
821 pDevice
->bMoreData
= TRUE
;
824 if (nsDMA_tx_packet(pDevice
, TYPE_AC0DMA
, skb
) != 0) {
825 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Multicast ps tx fail \n");
828 pMgmt
->sNodeDBTable
[0].wEnQueueCnt
--;
833 for (ii
= 1; ii
< (MAX_NODE_NUM
+ 1); ii
++) {
834 if (pMgmt
->sNodeDBTable
[ii
].bActive
&&
835 pMgmt
->sNodeDBTable
[ii
].bRxPSPoll
) {
836 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Index=%d Enqueu Cnt= %d\n",
837 ii
, pMgmt
->sNodeDBTable
[ii
].wEnQueueCnt
);
838 while ((skb
= skb_dequeue(&pMgmt
->sNodeDBTable
[ii
].sTxPSQueue
)) != NULL
) {
839 if (skb_queue_empty(&pMgmt
->sNodeDBTable
[ii
].sTxPSQueue
)) {
841 pMgmt
->abyPSTxMap
[pMgmt
->sNodeDBTable
[ii
].wAID
>> 3] &=
842 ~byMask
[pMgmt
->sNodeDBTable
[ii
].wAID
& 7];
843 pDevice
->bMoreData
= FALSE
;
846 pDevice
->bMoreData
= TRUE
;
849 if (nsDMA_tx_packet(pDevice
, TYPE_AC0DMA
, skb
) != 0) {
850 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"sta ps tx fail \n");
853 pMgmt
->sNodeDBTable
[ii
].wEnQueueCnt
--;
854 // check if sta ps enable, wait next pspoll
855 // if sta ps disable, send all pending buffers.
856 if (pMgmt
->sNodeDBTable
[ii
].bPSEnable
)
859 if (skb_queue_empty(&pMgmt
->sNodeDBTable
[ii
].sTxPSQueue
)) {
861 pMgmt
->abyPSTxMap
[pMgmt
->sNodeDBTable
[ii
].wAID
>> 3] &=
862 ~byMask
[pMgmt
->sNodeDBTable
[ii
].wAID
& 7];
863 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Index=%d PS queue clear \n", ii
);
865 pMgmt
->sNodeDBTable
[ii
].bRxPSPoll
= FALSE
;
869 s_bCommandComplete(pDevice
);
872 case WLAN_CMD_RADIO_START
:
874 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"eCommandState == WLAN_CMD_RADIO_START\n");
875 // if (pDevice->bRadioCmd == TRUE)
876 // CARDbRadioPowerOn(pDevice);
878 // CARDbRadioPowerOff(pDevice);
881 int ntStatus
= STATUS_SUCCESS
;
884 ntStatus
= CONTROLnsRequestIn(pDevice
,
887 MESSAGE_REQUEST_MACREG
,
891 if ( ntStatus
!= STATUS_SUCCESS
) {
892 s_bCommandComplete(pDevice
);
893 spin_unlock_irq(&pDevice
->lock
);
896 if ( (byTmp
& GPIO3_DATA
) == 0 ) {
897 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" WLAN_CMD_RADIO_START_OFF........................\n");
898 // Old commands are useless.
900 pDevice
->cbFreeCmdQueue
= CMD_Q_SIZE
;
901 pDevice
->uCmdDequeueIdx
= 0;
902 pDevice
->uCmdEnqueueIdx
= 0;
903 //0415pDevice->bCmdRunning = FALSE;
904 pDevice
->bCmdClear
= TRUE
;
905 pDevice
->bStopTx0Pkt
= FALSE
;
906 pDevice
->bStopDataPkt
= TRUE
;
908 pDevice
->byKeyIndex
= 0;
909 pDevice
->bTransmitKey
= FALSE
;
910 spin_unlock_irq(&pDevice
->lock
);
911 KeyvInitTable(pDevice
,&pDevice
->sKey
);
912 spin_lock_irq(&pDevice
->lock
);
913 pMgmt
->byCSSPK
= KEY_CTL_NONE
;
914 pMgmt
->byCSSGK
= KEY_CTL_NONE
;
916 if (pDevice
->bLinkPass
== TRUE
) {
917 // reason = 8 : disassoc because sta has left
918 vMgrDisassocBeginSta((void *) pDevice
,
923 pDevice
->bLinkPass
= FALSE
;
924 // unlock command busy
925 pMgmt
->eCurrState
= WMAC_STATE_IDLE
;
926 pMgmt
->sNodeDBTable
[0].bActive
= FALSE
;
927 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
928 // if(pDevice->bWPASuppWextEnabled == TRUE)
930 union iwreq_data wrqu
;
931 memset(&wrqu
, 0, sizeof (wrqu
));
932 wrqu
.ap_addr
.sa_family
= ARPHRD_ETHER
;
933 PRINT_K("wireless_send_event--->SIOCGIWAP(disassociated)\n");
934 wireless_send_event(pDevice
->dev
, SIOCGIWAP
, &wrqu
, NULL
);
938 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
939 pDevice
->bwextstep0
= FALSE
;
940 pDevice
->bwextstep1
= FALSE
;
941 pDevice
->bwextstep2
= FALSE
;
942 pDevice
->bwextstep3
= FALSE
;
943 pDevice
->bWPASuppWextEnabled
= FALSE
;
946 pItemSSID
= (PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
;
948 memset(pItemSSID
->abySSID
, 0, WLAN_SSID_MAXLEN
);
950 pItemSSID
= (PWLAN_IE_SSID
)pMgmt
->abyDesireSSID
;
952 memset(pItemSSID
->abySSID
, 0, WLAN_SSID_MAXLEN
);
954 netif_stop_queue(pDevice
->dev
);
955 CARDbRadioPowerOff(pDevice
);
956 MACvRegBitsOn(pDevice
,MAC_REG_GPIOCTL1
,GPIO3_INTMD
);
957 ControlvMaskByte(pDevice
,MESSAGE_REQUEST_MACREG
,MAC_REG_PAPEDELAY
,LEDSTS_STS
,LEDSTS_OFF
);
958 pDevice
->bHWRadioOff
= TRUE
;
960 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" WLAN_CMD_RADIO_START_ON........................\n");
961 pDevice
->bHWRadioOff
= FALSE
;
962 CARDbRadioPowerOn(pDevice
);
963 MACvRegBitsOff(pDevice
,MAC_REG_GPIOCTL1
,GPIO3_INTMD
);
964 ControlvMaskByte(pDevice
,MESSAGE_REQUEST_MACREG
,MAC_REG_PAPEDELAY
,LEDSTS_STS
,LEDSTS_ON
);
968 s_bCommandComplete(pDevice
);
972 case WLAN_CMD_CHANGE_BBSENSITIVITY_START
:
974 pDevice
->bStopDataPkt
= TRUE
;
975 pDevice
->byBBVGACurrent
= pDevice
->byBBVGANew
;
976 BBvSetVGAGainOffset(pDevice
, pDevice
->byBBVGACurrent
);
977 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Change sensitivity pDevice->byBBVGACurrent = %x\n", pDevice
->byBBVGACurrent
);
978 pDevice
->bStopDataPkt
= FALSE
;
979 s_bCommandComplete(pDevice
);
982 case WLAN_CMD_TBTT_WAKEUP_START
:
983 PSbIsNextTBTTWakeUp(pDevice
);
984 s_bCommandComplete(pDevice
);
987 case WLAN_CMD_BECON_SEND_START
:
988 bMgrPrepareBeaconToSend(pDevice
, pMgmt
);
989 s_bCommandComplete(pDevice
);
992 case WLAN_CMD_SETPOWER_START
:
994 RFbSetPower(pDevice
, pDevice
->wCurrentRate
, pMgmt
->uCurrChannel
);
996 s_bCommandComplete(pDevice
);
999 case WLAN_CMD_CHANGE_ANTENNA_START
:
1000 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Change from Antenna%d to", (int)pDevice
->dwRxAntennaSel
);
1001 if ( pDevice
->dwRxAntennaSel
== 0) {
1002 pDevice
->dwRxAntennaSel
=1;
1003 if (pDevice
->bTxRxAntInv
== TRUE
)
1004 BBvSetAntennaMode(pDevice
, ANT_RXA
);
1006 BBvSetAntennaMode(pDevice
, ANT_RXB
);
1008 pDevice
->dwRxAntennaSel
=0;
1009 if (pDevice
->bTxRxAntInv
== TRUE
)
1010 BBvSetAntennaMode(pDevice
, ANT_RXB
);
1012 BBvSetAntennaMode(pDevice
, ANT_RXA
);
1014 s_bCommandComplete(pDevice
);
1017 case WLAN_CMD_REMOVE_ALLKEY_START
:
1018 KeybRemoveAllKey(pDevice
, &(pDevice
->sKey
), pDevice
->abyBSSID
);
1019 s_bCommandComplete(pDevice
);
1023 case WLAN_CMD_MAC_DISPOWERSAVING_START
:
1024 ControlvReadByte (pDevice
, MESSAGE_REQUEST_MACREG
, MAC_REG_PSCTL
, &byData
);
1025 if ( (byData
& PSCTL_PS
) != 0 ) {
1026 // disable power saving hw function
1027 CONTROLnsRequestOut(pDevice
,
1028 MESSAGE_TYPE_DISABLE_PS
,
1035 s_bCommandComplete(pDevice
);
1038 case WLAN_CMD_11H_CHSW_START
:
1039 CARDbSetMediaChannel(pDevice
, pDevice
->byNewChannel
);
1040 pDevice
->bChannelSwitch
= FALSE
;
1041 pMgmt
->uCurrChannel
= pDevice
->byNewChannel
;
1042 pDevice
->bStopDataPkt
= FALSE
;
1043 s_bCommandComplete(pDevice
);
1047 s_bCommandComplete(pDevice
);
1051 spin_unlock_irq(&pDevice
->lock
);
1058 s_bCommandComplete (
1062 PWLAN_IE_SSID pSSID
;
1063 BOOL bRadioCmd
= FALSE
;
1064 //WORD wDeAuthenReason = 0;
1065 BOOL bForceSCAN
= TRUE
;
1066 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
1069 pDevice
->eCommandState
= WLAN_CMD_IDLE
;
1070 if (pDevice
->cbFreeCmdQueue
== CMD_Q_SIZE
) {
1071 //Command Queue Empty
1072 pDevice
->bCmdRunning
= FALSE
;
1076 pDevice
->eCommand
= pDevice
->eCmdQueue
[pDevice
->uCmdDequeueIdx
].eCmd
;
1077 pSSID
= (PWLAN_IE_SSID
)pDevice
->eCmdQueue
[pDevice
->uCmdDequeueIdx
].abyCmdDesireSSID
;
1078 bRadioCmd
= pDevice
->eCmdQueue
[pDevice
->uCmdDequeueIdx
].bRadioCmd
;
1079 bForceSCAN
= pDevice
->eCmdQueue
[pDevice
->uCmdDequeueIdx
].bForceSCAN
;
1080 ADD_ONE_WITH_WRAP_AROUND(pDevice
->uCmdDequeueIdx
, CMD_Q_SIZE
);
1081 pDevice
->cbFreeCmdQueue
++;
1082 pDevice
->bCmdRunning
= TRUE
;
1083 switch ( pDevice
->eCommand
) {
1084 case WLAN_CMD_BSSID_SCAN
:
1085 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"eCommandState= WLAN_CMD_BSSID_SCAN\n");
1086 pDevice
->eCommandState
= WLAN_CMD_SCAN_START
;
1087 pMgmt
->uScanChannel
= 0;
1088 if (pSSID
->len
!= 0) {
1089 memcpy(pMgmt
->abyScanSSID
, pSSID
, WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1);
1091 memset(pMgmt
->abyScanSSID
, 0, WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1);
1094 if ((bForceSCAN == FALSE) && (pDevice->bLinkPass == TRUE)) {
1095 if ((pSSID->len == ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->len) &&
1096 ( !memcmp(pSSID->abySSID, ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->abySSID, pSSID->len))) {
1097 pDevice->eCommandState = WLAN_CMD_IDLE;
1103 pDevice
->eCommandState
= WLAN_CMD_SSID_START
;
1104 if (pSSID
->len
> WLAN_SSID_MAXLEN
)
1105 pSSID
->len
= WLAN_SSID_MAXLEN
;
1106 if (pSSID
->len
!= 0)
1107 memcpy(pMgmt
->abyDesireSSID
, pSSID
, WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1);
1108 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"eCommandState= WLAN_CMD_SSID_START\n");
1110 case WLAN_CMD_DISASSOCIATE
:
1111 pDevice
->eCommandState
= WLAN_CMD_DISASSOCIATE_START
;
1113 case WLAN_CMD_RX_PSPOLL
:
1114 pDevice
->eCommandState
= WLAN_CMD_TX_PSPACKET_START
;
1116 case WLAN_CMD_RUN_AP
:
1117 pDevice
->eCommandState
= WLAN_CMD_AP_MODE_START
;
1119 case WLAN_CMD_RADIO
:
1120 pDevice
->eCommandState
= WLAN_CMD_RADIO_START
;
1121 pDevice
->bRadioCmd
= bRadioCmd
;
1123 case WLAN_CMD_CHANGE_BBSENSITIVITY
:
1124 pDevice
->eCommandState
= WLAN_CMD_CHANGE_BBSENSITIVITY_START
;
1127 case WLAN_CMD_TBTT_WAKEUP
:
1128 pDevice
->eCommandState
= WLAN_CMD_TBTT_WAKEUP_START
;
1131 case WLAN_CMD_BECON_SEND
:
1132 pDevice
->eCommandState
= WLAN_CMD_BECON_SEND_START
;
1135 case WLAN_CMD_SETPOWER
:
1136 pDevice
->eCommandState
= WLAN_CMD_SETPOWER_START
;
1139 case WLAN_CMD_CHANGE_ANTENNA
:
1140 pDevice
->eCommandState
= WLAN_CMD_CHANGE_ANTENNA_START
;
1143 case WLAN_CMD_REMOVE_ALLKEY
:
1144 pDevice
->eCommandState
= WLAN_CMD_REMOVE_ALLKEY_START
;
1147 case WLAN_CMD_MAC_DISPOWERSAVING
:
1148 pDevice
->eCommandState
= WLAN_CMD_MAC_DISPOWERSAVING_START
;
1151 case WLAN_CMD_11H_CHSW
:
1152 pDevice
->eCommandState
= WLAN_CMD_11H_CHSW_START
;
1159 vCommandTimerWait((void *) pDevice
, 0);
1165 BOOL
bScheduleCommand(void *hDeviceContext
,
1169 PSDevice pDevice
= (PSDevice
)hDeviceContext
;
1172 if (pDevice
->cbFreeCmdQueue
== 0) {
1175 pDevice
->eCmdQueue
[pDevice
->uCmdEnqueueIdx
].eCmd
= eCommand
;
1176 pDevice
->eCmdQueue
[pDevice
->uCmdEnqueueIdx
].bForceSCAN
= TRUE
;
1177 memset(pDevice
->eCmdQueue
[pDevice
->uCmdEnqueueIdx
].abyCmdDesireSSID
, 0 , WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1);
1178 if (pbyItem0
!= NULL
) {
1180 case WLAN_CMD_BSSID_SCAN
:
1181 pDevice
->eCmdQueue
[pDevice
->uCmdEnqueueIdx
].bForceSCAN
= FALSE
;
1182 memcpy(pDevice
->eCmdQueue
[pDevice
->uCmdEnqueueIdx
].abyCmdDesireSSID
,
1183 pbyItem0
, WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1);
1187 memcpy(pDevice
->eCmdQueue
[pDevice
->uCmdEnqueueIdx
].abyCmdDesireSSID
,
1188 pbyItem0
, WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1);
1191 case WLAN_CMD_DISASSOCIATE
:
1192 pDevice
->eCmdQueue
[pDevice
->uCmdEnqueueIdx
].bNeedRadioOFF
= *((int *)pbyItem0
);
1195 case WLAN_CMD_DEAUTH:
1196 pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].wDeAuthenReason = *((PWORD)pbyItem0);
1200 case WLAN_CMD_RADIO
:
1201 pDevice
->eCmdQueue
[pDevice
->uCmdEnqueueIdx
].bRadioCmd
= *((int *)pbyItem0
);
1209 ADD_ONE_WITH_WRAP_AROUND(pDevice
->uCmdEnqueueIdx
, CMD_Q_SIZE
);
1210 pDevice
->cbFreeCmdQueue
--;
1212 if (pDevice
->bCmdRunning
== FALSE
) {
1213 s_bCommandComplete(pDevice
);
1223 * Clear BSSID_SCAN cmd in CMD Queue
1227 * hDeviceContext - Pointer to the adapter
1228 * eCommand - Command
1232 * Return Value: TRUE if success; otherwise FALSE
1235 static BOOL
s_bClearBSSID_SCAN(void *hDeviceContext
)
1237 PSDevice pDevice
= (PSDevice
)hDeviceContext
;
1238 unsigned int uCmdDequeueIdx
= pDevice
->uCmdDequeueIdx
;
1241 if ((pDevice
->cbFreeCmdQueue
< CMD_Q_SIZE
) && (uCmdDequeueIdx
!= pDevice
->uCmdEnqueueIdx
)) {
1242 for (ii
= 0; ii
< (CMD_Q_SIZE
- pDevice
->cbFreeCmdQueue
); ii
++) {
1243 if (pDevice
->eCmdQueue
[uCmdDequeueIdx
].eCmd
== WLAN_CMD_BSSID_SCAN
)
1244 pDevice
->eCmdQueue
[uCmdDequeueIdx
].eCmd
= WLAN_CMD_IDLE
;
1245 ADD_ONE_WITH_WRAP_AROUND(uCmdDequeueIdx
, CMD_Q_SIZE
);
1246 if (uCmdDequeueIdx
== pDevice
->uCmdEnqueueIdx
)
1254 //mike add:reset command timer
1255 void vResetCommandTimer(void *hDeviceContext
)
1257 PSDevice pDevice
= (PSDevice
)hDeviceContext
;
1260 del_timer(&pDevice
->sTimerCommand
);
1262 init_timer(&pDevice
->sTimerCommand
);
1263 pDevice
->sTimerCommand
.data
= (unsigned long)pDevice
;
1264 pDevice
->sTimerCommand
.function
= (TimerFunction
)vRunCommand
;
1265 pDevice
->sTimerCommand
.expires
= RUN_AT(HZ
);
1266 pDevice
->cbFreeCmdQueue
= CMD_Q_SIZE
;
1267 pDevice
->uCmdDequeueIdx
= 0;
1268 pDevice
->uCmdEnqueueIdx
= 0;
1269 pDevice
->eCommandState
= WLAN_CMD_IDLE
;
1270 pDevice
->bCmdRunning
= FALSE
;
1271 pDevice
->bCmdClear
= FALSE
;
1274 void BSSvSecondTxData(void *hDeviceContext
)
1276 PSDevice pDevice
= (PSDevice
)hDeviceContext
;
1277 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
1279 pDevice
->nTxDataTimeCout
++;
1281 if (pDevice
->nTxDataTimeCout
< 4) { //don't tx data if timer less than 40s
1282 // printk("mike:%s-->no data Tx not exceed the desired Time as %d\n",__FUNCTION__,
1283 // (int)pDevice->nTxDataTimeCout);
1284 pDevice
->sTimerTxData
.expires
= RUN_AT(10 * HZ
); //10s callback
1285 add_timer(&pDevice
->sTimerTxData
);
1289 spin_lock_irq(&pDevice
->lock
);
1290 //is wap_supplicant running successful OR only open && sharekey mode!
1291 if (((pDevice
->bLinkPass
== TRUE
) &&
1292 (pMgmt
->eAuthenMode
< WMAC_AUTH_WPA
)) || //open && sharekey linking
1293 (pDevice
->fWPA_Authened
== TRUE
)) { //wpa linking
1294 // printk("mike:%s-->InSleep Tx Data Procedure\n",__FUNCTION__);
1295 pDevice
->fTxDataInSleep
= TRUE
;
1296 PSbSendNullPacket(pDevice
); //send null packet
1297 pDevice
->fTxDataInSleep
= FALSE
;
1299 spin_unlock_irq(&pDevice
->lock
);
1301 pDevice
->sTimerTxData
.expires
= RUN_AT(10 * HZ
); //10s callback
1302 add_timer(&pDevice
->sTimerTxData
);