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
58 static int msglevel
=MSG_LEVEL_INFO
;
59 //static int msglevel =MSG_LEVEL_DEBUG;
61 static void s_vProbeChannel(struct vnt_private
*);
63 static struct vnt_tx_mgmt
*s_MgrMakeProbeRequest(struct vnt_private
*,
64 struct vnt_manager
*pMgmt
, u8
*pScanBSSID
, PWLAN_IE_SSID pSSID
,
65 PWLAN_IE_SUPP_RATES pCurrRates
, PWLAN_IE_SUPP_RATES pCurrExtSuppRates
);
67 static int s_bCommandComplete(struct vnt_private
*);
69 static int s_bClearBSSID_SCAN(struct vnt_private
*);
73 * Stop AdHoc beacon during scan process
77 * pDevice - Pointer to the adapter
85 static void vAdHocBeaconStop(struct vnt_private
*pDevice
)
87 struct vnt_manager
*pMgmt
= &pDevice
->vnt_mgmt
;
91 * temporarily stop Beacon packet for AdHoc Server
92 * if all of the following coditions are met:
93 * (1) STA is in AdHoc mode
94 * (2) VT3253 is programmed as automatic Beacon Transmitting
95 * (3) One of the following conditions is met
96 * (3.1) AdHoc channel is in B/G band and the
97 * current scan channel is in A band
99 * (3.2) AdHoc channel is in A mode
102 if ((pMgmt
->eCurrMode
== WMAC_MODE_IBSS_STA
) &&
103 (pMgmt
->eCurrState
>= WMAC_STATE_STARTED
))
105 if ((pMgmt
->uIBSSChannel
<= CB_MAX_CHANNEL_24G
) &&
106 (pMgmt
->uScanChannel
> CB_MAX_CHANNEL_24G
))
110 if (pMgmt
->uIBSSChannel
> CB_MAX_CHANNEL_24G
)
118 //PMESG(("STOP_BEACON: IBSSChannel = %u, ScanChannel = %u\n",
119 // pMgmt->uIBSSChannel, pMgmt->uScanChannel));
120 MACvRegBitsOff(pDevice
, MAC_REG_TCR
, TCR_AUTOBCNTX
);
123 } /* vAdHocBeaconStop */
127 * Restart AdHoc beacon after scan process complete
131 * pDevice - Pointer to the adapter
138 static void vAdHocBeaconRestart(struct vnt_private
*pDevice
)
140 struct vnt_manager
*pMgmt
= &pDevice
->vnt_mgmt
;
143 * Restart Beacon packet for AdHoc Server
144 * if all of the following coditions are met:
145 * (1) STA is in AdHoc mode
146 * (2) VT3253 is programmed as automatic Beacon Transmitting
148 if ((pMgmt
->eCurrMode
== WMAC_MODE_IBSS_STA
) &&
149 (pMgmt
->eCurrState
>= WMAC_STATE_STARTED
))
151 //PMESG(("RESTART_BEACON\n"));
152 MACvRegBitsOn(pDevice
, MAC_REG_TCR
, TCR_AUTOBCNTX
);
159 * Routine Description:
160 * Prepare and send probe request management frames.
168 static void s_vProbeChannel(struct vnt_private
*pDevice
)
170 struct vnt_manager
*pMgmt
= &pDevice
->vnt_mgmt
;
171 struct vnt_tx_mgmt
*pTxPacket
;
172 u8 abyCurrSuppRatesG
[] = {WLAN_EID_SUPP_RATES
,
173 8, 0x02, 0x04, 0x0B, 0x16, 0x24, 0x30, 0x48, 0x6C};
174 /* 1M, 2M, 5M, 11M, 18M, 24M, 36M, 54M*/
175 u8 abyCurrExtSuppRatesG
[] = {WLAN_EID_EXTSUPP_RATES
,
176 4, 0x0C, 0x12, 0x18, 0x60};
177 /* 6M, 9M, 12M, 48M*/
178 u8 abyCurrSuppRatesA
[] = {WLAN_EID_SUPP_RATES
,
179 8, 0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C};
180 u8 abyCurrSuppRatesB
[] = {WLAN_EID_SUPP_RATES
,
181 4, 0x02, 0x04, 0x0B, 0x16};
185 if (pDevice
->byBBType
== BB_TYPE_11A
) {
186 pbyRate
= &abyCurrSuppRatesA
[0];
187 } else if (pDevice
->byBBType
== BB_TYPE_11B
) {
188 pbyRate
= &abyCurrSuppRatesB
[0];
190 pbyRate
= &abyCurrSuppRatesG
[0];
192 // build an assocreq frame and send it
193 pTxPacket
= s_MgrMakeProbeRequest
198 (PWLAN_IE_SSID
)pMgmt
->abyScanSSID
,
199 (PWLAN_IE_SUPP_RATES
)pbyRate
,
200 (PWLAN_IE_SUPP_RATES
)abyCurrExtSuppRatesG
203 if (pTxPacket
!= NULL
){
204 for (ii
= 0; ii
< 1 ; ii
++) {
205 if (csMgmt_xmit(pDevice
, pTxPacket
) != CMD_STATUS_PENDING
) {
206 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Probe request sending fail.. \n");
209 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Probe request is sending.. \n");
218 * Routine Description:
219 * Constructs an probe request frame
223 * A ptr to Tx frame or NULL on allocation failure
227 struct vnt_tx_mgmt
*s_MgrMakeProbeRequest(struct vnt_private
*pDevice
,
228 struct vnt_manager
*pMgmt
, u8
*pScanBSSID
, PWLAN_IE_SSID pSSID
,
229 PWLAN_IE_SUPP_RATES pCurrRates
, PWLAN_IE_SUPP_RATES pCurrExtSuppRates
)
231 struct vnt_tx_mgmt
*pTxPacket
= NULL
;
232 WLAN_FR_PROBEREQ sFrame
;
234 pTxPacket
= (struct vnt_tx_mgmt
*)pMgmt
->pbyMgmtPacketPool
;
235 memset(pTxPacket
, 0, sizeof(struct vnt_tx_mgmt
)
236 + WLAN_PROBEREQ_FR_MAXLEN
);
237 pTxPacket
->p80211Header
= (PUWLAN_80211HDR
)((u8
*)pTxPacket
238 + sizeof(struct vnt_tx_mgmt
));
239 sFrame
.pBuf
= (u8
*)pTxPacket
->p80211Header
;
240 sFrame
.len
= WLAN_PROBEREQ_FR_MAXLEN
;
241 vMgrEncodeProbeRequest(&sFrame
);
242 sFrame
.pHdr
->sA3
.wFrameCtl
= cpu_to_le16(
244 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR
) |
245 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_PROBEREQ
)
247 memcpy( sFrame
.pHdr
->sA3
.abyAddr1
, pScanBSSID
, WLAN_ADDR_LEN
);
248 memcpy( sFrame
.pHdr
->sA3
.abyAddr2
, pMgmt
->abyMACAddr
, WLAN_ADDR_LEN
);
249 memcpy( sFrame
.pHdr
->sA3
.abyAddr3
, pScanBSSID
, WLAN_BSSID_LEN
);
250 // Copy the SSID, pSSID->len=0 indicate broadcast SSID
251 sFrame
.pSSID
= (PWLAN_IE_SSID
)(sFrame
.pBuf
+ sFrame
.len
);
252 sFrame
.len
+= pSSID
->len
+ WLAN_IEHDR_LEN
;
253 memcpy(sFrame
.pSSID
, pSSID
, pSSID
->len
+ WLAN_IEHDR_LEN
);
254 sFrame
.pSuppRates
= (PWLAN_IE_SUPP_RATES
)(sFrame
.pBuf
+ sFrame
.len
);
255 sFrame
.len
+= pCurrRates
->len
+ WLAN_IEHDR_LEN
;
256 memcpy(sFrame
.pSuppRates
, pCurrRates
, pCurrRates
->len
+ WLAN_IEHDR_LEN
);
257 // Copy the extension rate set
258 if (pDevice
->byBBType
== BB_TYPE_11G
) {
259 sFrame
.pExtSuppRates
= (PWLAN_IE_SUPP_RATES
)(sFrame
.pBuf
+ sFrame
.len
);
260 sFrame
.len
+= pCurrExtSuppRates
->len
+ WLAN_IEHDR_LEN
;
261 memcpy(sFrame
.pExtSuppRates
, pCurrExtSuppRates
, pCurrExtSuppRates
->len
+ WLAN_IEHDR_LEN
);
263 pTxPacket
->cbMPDULen
= sFrame
.len
;
264 pTxPacket
->cbPayloadLen
= sFrame
.len
- WLAN_HDR_ADDR3_LEN
;
269 void vCommandTimerWait(struct vnt_private
*pDevice
, unsigned long MSecond
)
271 schedule_delayed_work(&pDevice
->run_command_work
,
272 msecs_to_jiffies(MSecond
));
275 void vRunCommand(struct work_struct
*work
)
277 struct vnt_private
*pDevice
=
278 container_of(work
, struct vnt_private
, run_command_work
.work
);
279 struct vnt_manager
*pMgmt
= &pDevice
->vnt_mgmt
;
280 PWLAN_IE_SSID pItemSSID
;
281 PWLAN_IE_SSID pItemSSIDCurr
;
284 union iwreq_data wrqu
;
286 u8 byMask
[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80};
289 if (pDevice
->dwDiagRefCount
!= 0)
291 if (pDevice
->bCmdRunning
!= true)
294 spin_lock_irq(&pDevice
->lock
);
296 switch ( pDevice
->eCommandState
) {
298 case WLAN_CMD_SCAN_START
:
300 pDevice
->byReAssocCount
= 0;
301 if (pDevice
->bRadioOff
== true) {
302 s_bCommandComplete(pDevice
);
303 spin_unlock_irq(&pDevice
->lock
);
307 if (pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
) {
308 s_bCommandComplete(pDevice
);
309 spin_unlock_irq(&pDevice
->lock
);
313 pItemSSID
= (PWLAN_IE_SSID
)pMgmt
->abyScanSSID
;
315 if (pMgmt
->uScanChannel
== 0 ) {
316 pMgmt
->uScanChannel
= pDevice
->byMinChannel
;
318 if (pMgmt
->uScanChannel
> pDevice
->byMaxChannel
) {
319 pDevice
->eCommandState
= WLAN_CMD_SCAN_END
;
320 s_bCommandComplete(pDevice
);
321 spin_unlock_irq(&pDevice
->lock
);
325 if (!ChannelValid(pDevice
->byZoneType
, pMgmt
->uScanChannel
)) {
326 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Invalid channel pMgmt->uScanChannel = %d \n",pMgmt
->uScanChannel
);
327 pMgmt
->uScanChannel
++;
328 s_bCommandComplete(pDevice
);
329 spin_unlock_irq(&pDevice
->lock
);
332 if (pMgmt
->uScanChannel
== pDevice
->byMinChannel
) {
333 // pMgmt->eScanType = WMAC_SCAN_ACTIVE; //mike mark
334 pMgmt
->abyScanBSSID
[0] = 0xFF;
335 pMgmt
->abyScanBSSID
[1] = 0xFF;
336 pMgmt
->abyScanBSSID
[2] = 0xFF;
337 pMgmt
->abyScanBSSID
[3] = 0xFF;
338 pMgmt
->abyScanBSSID
[4] = 0xFF;
339 pMgmt
->abyScanBSSID
[5] = 0xFF;
340 pItemSSID
->byElementID
= WLAN_EID_SSID
;
342 /* BSSvClearBSSList((void *) pDevice,
343 pDevice->bLinkPass); */
344 pMgmt
->eScanState
= WMAC_IS_SCANNING
;
345 pDevice
->byScanBBType
= pDevice
->byBBType
; //lucas
346 pDevice
->bStopDataPkt
= true;
347 // Turn off RCR_BSSID filter every time
348 MACvRegBitsOff(pDevice
, MAC_REG_RCR
, RCR_BSSID
);
349 pDevice
->byRxMode
&= ~RCR_BSSID
;
353 vAdHocBeaconStop(pDevice
);
354 if ((pDevice
->byBBType
!= BB_TYPE_11A
) && (pMgmt
->uScanChannel
> CB_MAX_CHANNEL_24G
)) {
355 pDevice
->byBBType
= BB_TYPE_11A
;
356 CARDvSetBSSMode(pDevice
);
358 else if ((pDevice
->byBBType
== BB_TYPE_11A
) && (pMgmt
->uScanChannel
<= CB_MAX_CHANNEL_24G
)) {
359 pDevice
->byBBType
= BB_TYPE_11G
;
360 CARDvSetBSSMode(pDevice
);
362 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Scanning.... channel: [%d]\n", pMgmt
->uScanChannel
);
364 CARDbSetMediaChannel(pDevice
, pMgmt
->uScanChannel
);
365 // Set Baseband to be more sensitive.
367 if (pDevice
->bUpdateBBVGA
) {
368 BBvSetShortSlotTime(pDevice
);
369 BBvSetVGAGainOffset(pDevice
, pDevice
->abyBBVGA
[0]);
370 BBvUpdatePreEDThreshold(pDevice
, true);
372 pMgmt
->uScanChannel
++;
374 while (!ChannelValid(pDevice
->byZoneType
, pMgmt
->uScanChannel
) &&
375 pMgmt
->uScanChannel
<= pDevice
->byMaxChannel
){
376 pMgmt
->uScanChannel
++;
379 if (pMgmt
->uScanChannel
> pDevice
->byMaxChannel
) {
380 // Set Baseband to be not sensitive and rescan
381 pDevice
->eCommandState
= WLAN_CMD_SCAN_END
;
384 if ((pMgmt
->b11hEnable
== false) ||
385 (pMgmt
->uScanChannel
< CB_MAX_CHANNEL_24G
)) {
386 s_vProbeChannel(pDevice
);
387 spin_unlock_irq(&pDevice
->lock
);
388 vCommandTimerWait((void *) pDevice
, 100);
391 spin_unlock_irq(&pDevice
->lock
);
392 vCommandTimerWait((void *) pDevice
, WCMD_PASSIVE_SCAN_TIME
);
400 case WLAN_CMD_SCAN_END
:
402 // Set Baseband's sensitivity back.
403 if (pDevice
->byBBType
!= pDevice
->byScanBBType
) {
404 pDevice
->byBBType
= pDevice
->byScanBBType
;
405 CARDvSetBSSMode(pDevice
);
408 if (pDevice
->bUpdateBBVGA
) {
409 BBvSetShortSlotTime(pDevice
);
410 BBvSetVGAGainOffset(pDevice
, pDevice
->byBBVGACurrent
);
411 BBvUpdatePreEDThreshold(pDevice
, false);
415 vAdHocBeaconRestart(pDevice
);
417 CARDbSetMediaChannel(pDevice
, pMgmt
->uCurrChannel
);
419 if (pMgmt
->bCurrBSSIDFilterOn
) {
420 MACvRegBitsOn(pDevice
, MAC_REG_RCR
, RCR_BSSID
);
421 pDevice
->byRxMode
|= RCR_BSSID
;
423 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Scanning, set back to channel: [%d]\n", pMgmt
->uCurrChannel
);
424 pMgmt
->uScanChannel
= 0;
425 pMgmt
->eScanState
= WMAC_NO_SCANNING
;
426 pDevice
->bStopDataPkt
= false;
428 /*send scan event to wpa_Supplicant*/
429 PRINT_K("wireless_send_event--->SIOCGIWSCAN(scan done)\n");
430 memset(&wrqu
, 0, sizeof(wrqu
));
431 wireless_send_event(pDevice
->dev
, SIOCGIWSCAN
, &wrqu
, NULL
);
433 s_bCommandComplete(pDevice
);
436 case WLAN_CMD_DISASSOCIATE_START
:
437 pDevice
->byReAssocCount
= 0;
438 if ((pMgmt
->eCurrMode
== WMAC_MODE_ESS_STA
) &&
439 (pMgmt
->eCurrState
!= WMAC_STATE_ASSOC
)) {
440 s_bCommandComplete(pDevice
);
441 spin_unlock_irq(&pDevice
->lock
);
445 pDevice
->bwextstep0
= false;
446 pDevice
->bwextstep1
= false;
447 pDevice
->bwextstep2
= false;
448 pDevice
->bwextstep3
= false;
449 pDevice
->bWPASuppWextEnabled
= false;
450 pDevice
->fWPA_Authened
= false;
452 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Send Disassociation Packet..\n");
453 // reason = 8 : disassoc because sta has left
454 vMgrDisassocBeginSta((void *) pDevice
,
459 pDevice
->bLinkPass
= false;
460 ControlvMaskByte(pDevice
,MESSAGE_REQUEST_MACREG
,MAC_REG_PAPEDELAY
,LEDSTS_STS
,LEDSTS_SLOW
);
461 // unlock command busy
462 pItemSSID
= (PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
;
464 memset(pItemSSID
->abySSID
, 0, WLAN_SSID_MAXLEN
);
465 pMgmt
->eCurrState
= WMAC_STATE_IDLE
;
466 pMgmt
->sNodeDBTable
[0].bActive
= false;
467 // pDevice->bBeaconBufReady = false;
469 netif_stop_queue(pDevice
->dev
);
470 if (pDevice
->bNeedRadioOFF
== true)
471 CARDbRadioPowerOff(pDevice
);
472 s_bCommandComplete(pDevice
);
475 case WLAN_CMD_SSID_START
:
477 pDevice
->byReAssocCount
= 0;
478 if (pDevice
->bRadioOff
== true) {
479 s_bCommandComplete(pDevice
);
480 spin_unlock_irq(&pDevice
->lock
);
484 memcpy(pMgmt
->abyAdHocSSID
,pMgmt
->abyDesireSSID
,
485 ((PWLAN_IE_SSID
)pMgmt
->abyDesireSSID
)->len
+ WLAN_IEHDR_LEN
);
487 pItemSSID
= (PWLAN_IE_SSID
)pMgmt
->abyDesireSSID
;
488 pItemSSIDCurr
= (PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
;
489 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" cmd: desire ssid = %s\n", pItemSSID
->abySSID
);
490 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" cmd: curr ssid = %s\n", pItemSSIDCurr
->abySSID
);
492 if (pMgmt
->eCurrState
== WMAC_STATE_ASSOC
) {
493 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" Cmd pMgmt->eCurrState == WMAC_STATE_ASSOC\n");
494 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" pItemSSID->len =%d\n",pItemSSID
->len
);
495 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" pItemSSIDCurr->len = %d\n",pItemSSIDCurr
->len
);
496 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" desire ssid = %s\n", pItemSSID
->abySSID
);
497 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" curr ssid = %s\n", pItemSSIDCurr
->abySSID
);
500 if ((pMgmt
->eCurrState
== WMAC_STATE_ASSOC
) ||
501 ((pMgmt
->eCurrMode
== WMAC_MODE_IBSS_STA
)&& (pMgmt
->eCurrState
== WMAC_STATE_JOINTED
))) {
503 if (pItemSSID
->len
== pItemSSIDCurr
->len
) {
504 if (memcmp(pItemSSID
->abySSID
, pItemSSIDCurr
->abySSID
, pItemSSID
->len
) == 0) {
505 s_bCommandComplete(pDevice
);
506 spin_unlock_irq(&pDevice
->lock
);
510 netif_stop_queue(pDevice
->dev
);
511 pDevice
->bLinkPass
= false;
512 ControlvMaskByte(pDevice
,MESSAGE_REQUEST_MACREG
,MAC_REG_PAPEDELAY
,LEDSTS_STS
,LEDSTS_SLOW
);
515 pMgmt
->eCurrState
= WMAC_STATE_IDLE
;
516 pMgmt
->eCurrMode
= WMAC_MODE_STANDBY
;
517 PSvDisablePowerSaving((void *) pDevice
);
518 BSSvClearNodeDBTable(pDevice
, 0);
519 vMgrJoinBSSBegin((void *) pDevice
, &Status
);
521 if ((pMgmt
->eCurrMode
== WMAC_MODE_ESS_STA
) && (pMgmt
->eCurrState
== WMAC_STATE_JOINTED
)) {
522 // Call mgr to begin the deauthentication
523 // reason = (3) because sta has left ESS
524 if (pMgmt
->eCurrState
>= WMAC_STATE_AUTH
) {
525 vMgrDeAuthenBeginSta((void *)pDevice
,
531 // Call mgr to begin the authentication
532 vMgrAuthenBeginSta((void *) pDevice
, pMgmt
, &Status
);
533 if (Status
== CMD_STATUS_SUCCESS
) {
534 pDevice
->byLinkWaitCount
= 0;
535 pDevice
->eCommandState
= WLAN_AUTHENTICATE_WAIT
;
536 vCommandTimerWait((void *) pDevice
, AUTHENTICATE_TIMEOUT
);
537 spin_unlock_irq(&pDevice
->lock
);
538 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" Set eCommandState = WLAN_AUTHENTICATE_WAIT\n");
543 else if (pMgmt
->eCurrMode
== WMAC_MODE_IBSS_STA
) {
544 if (pMgmt
->eCurrState
== WMAC_STATE_JOINTED
) {
545 if (netif_queue_stopped(pDevice
->dev
)){
546 netif_wake_queue(pDevice
->dev
);
548 pDevice
->bLinkPass
= true;
549 ControlvMaskByte(pDevice
,MESSAGE_REQUEST_MACREG
,MAC_REG_PAPEDELAY
,LEDSTS_STS
,LEDSTS_INTER
);
550 pMgmt
->sNodeDBTable
[0].bActive
= true;
551 pMgmt
->sNodeDBTable
[0].uInActiveCount
= 0;
555 DBG_PRT(MSG_LEVEL_DEBUG
,
556 KERN_INFO
"CreateOwn IBSS by CurrMode = IBSS_STA\n");
557 vMgrCreateOwnIBSS((void *) pDevice
, &Status
);
558 if (Status
!= CMD_STATUS_SUCCESS
){
559 DBG_PRT(MSG_LEVEL_DEBUG
,
560 KERN_INFO
"WLAN_CMD_IBSS_CREATE fail!\n");
562 BSSvAddMulticastNode(pDevice
);
564 s_bClearBSSID_SCAN(pDevice
);
567 else if (pMgmt
->eCurrMode
== WMAC_MODE_STANDBY
) {
568 if (pMgmt
->eConfigMode
== WMAC_CONFIG_IBSS_STA
||
569 pMgmt
->eConfigMode
== WMAC_CONFIG_AUTO
) {
571 DBG_PRT(MSG_LEVEL_DEBUG
,
572 KERN_INFO
"CreateOwn IBSS by CurrMode = STANDBY\n");
573 vMgrCreateOwnIBSS((void *) pDevice
, &Status
);
574 if (Status
!= CMD_STATUS_SUCCESS
){
575 DBG_PRT(MSG_LEVEL_DEBUG
,
576 KERN_INFO
"WLAN_CMD_IBSS_CREATE fail!\n");
578 BSSvAddMulticastNode(pDevice
);
579 s_bClearBSSID_SCAN(pDevice
);
581 pDevice->bLinkPass = true;
582 ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_INTER);
583 if (netif_queue_stopped(pDevice->dev)){
584 netif_wake_queue(pDevice->dev);
586 s_bClearBSSID_SCAN(pDevice);
590 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Disconnect SSID none\n");
591 // if(pDevice->bWPASuppWextEnabled == true)
593 union iwreq_data wrqu
;
594 memset(&wrqu
, 0, sizeof (wrqu
));
595 wrqu
.ap_addr
.sa_family
= ARPHRD_ETHER
;
596 PRINT_K("wireless_send_event--->SIOCGIWAP(disassociated:vMgrJoinBSSBegin Fail !!)\n");
597 wireless_send_event(pDevice
->dev
, SIOCGIWAP
, &wrqu
, NULL
);
601 s_bCommandComplete(pDevice
);
604 case WLAN_AUTHENTICATE_WAIT
:
605 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"eCommandState == WLAN_AUTHENTICATE_WAIT\n");
606 if (pMgmt
->eCurrState
== WMAC_STATE_AUTH
) {
607 pDevice
->byLinkWaitCount
= 0;
608 // Call mgr to begin the association
609 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"eCurrState == WMAC_STATE_AUTH\n");
610 vMgrAssocBeginSta((void *) pDevice
, pMgmt
, &Status
);
611 if (Status
== CMD_STATUS_SUCCESS
) {
612 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"eCommandState = WLAN_ASSOCIATE_WAIT\n");
613 pDevice
->byLinkWaitCount
= 0;
614 pDevice
->eCommandState
= WLAN_ASSOCIATE_WAIT
;
615 vCommandTimerWait((void *) pDevice
, ASSOCIATE_TIMEOUT
);
616 spin_unlock_irq(&pDevice
->lock
);
620 else if(pMgmt
->eCurrState
< WMAC_STATE_AUTHPENDING
) {
621 printk("WLAN_AUTHENTICATE_WAIT:Authen Fail???\n");
623 else if(pDevice
->byLinkWaitCount
<= 4){ //mike add:wait another 2 sec if authenticated_frame delay!
624 pDevice
->byLinkWaitCount
++;
625 printk("WLAN_AUTHENTICATE_WAIT:wait %d times!!\n",pDevice
->byLinkWaitCount
);
626 spin_unlock_irq(&pDevice
->lock
);
627 vCommandTimerWait((void *) pDevice
, AUTHENTICATE_TIMEOUT
/2);
630 pDevice
->byLinkWaitCount
= 0;
632 s_bCommandComplete(pDevice
);
635 case WLAN_ASSOCIATE_WAIT
:
636 if (pMgmt
->eCurrState
== WMAC_STATE_ASSOC
) {
637 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"eCurrState == WMAC_STATE_ASSOC\n");
638 if (pDevice
->ePSMode
!= WMAC_POWER_CAM
) {
639 PSvEnablePowerSaving((void *) pDevice
,
640 pMgmt
->wListenInterval
);
643 if (pMgmt->eAuthenMode >= WMAC_AUTH_WPA) {
644 KeybRemoveAllKey(pDevice, &(pDevice->sKey), pDevice->abyBSSID);
647 pDevice
->byLinkWaitCount
= 0;
648 pDevice
->byReAssocCount
= 0;
649 pDevice
->bLinkPass
= true;
650 ControlvMaskByte(pDevice
,MESSAGE_REQUEST_MACREG
,MAC_REG_PAPEDELAY
,LEDSTS_STS
,LEDSTS_INTER
);
651 s_bClearBSSID_SCAN(pDevice
);
653 if (netif_queue_stopped(pDevice
->dev
)){
654 netif_wake_queue(pDevice
->dev
);
657 if(pDevice
->IsTxDataTrigger
!= false) { //TxDataTimer is not triggered at the first time
658 // printk("Re-initial TxDataTimer****\n");
659 del_timer(&pDevice
->sTimerTxData
);
660 init_timer(&pDevice
->sTimerTxData
);
661 pDevice
->sTimerTxData
.data
= (unsigned long) pDevice
;
662 pDevice
->sTimerTxData
.function
= (TimerFunction
)BSSvSecondTxData
;
663 pDevice
->sTimerTxData
.expires
= RUN_AT(10*HZ
); //10s callback
664 pDevice
->fTxDataInSleep
= false;
665 pDevice
->nTxDataTimeCout
= 0;
668 // printk("mike:-->First time trigger TimerTxData InSleep\n");
670 pDevice
->IsTxDataTrigger
= true;
671 add_timer(&pDevice
->sTimerTxData
);
674 else if(pMgmt
->eCurrState
< WMAC_STATE_ASSOCPENDING
) {
675 printk("WLAN_ASSOCIATE_WAIT:Association Fail???\n");
677 else if(pDevice
->byLinkWaitCount
<= 4){ //mike add:wait another 2 sec if associated_frame delay!
678 pDevice
->byLinkWaitCount
++;
679 printk("WLAN_ASSOCIATE_WAIT:wait %d times!!\n",pDevice
->byLinkWaitCount
);
680 spin_unlock_irq(&pDevice
->lock
);
681 vCommandTimerWait((void *) pDevice
, ASSOCIATE_TIMEOUT
/2);
684 pDevice
->byLinkWaitCount
= 0;
686 s_bCommandComplete(pDevice
);
689 case WLAN_CMD_AP_MODE_START
:
690 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"eCommandState == WLAN_CMD_AP_MODE_START\n");
692 if (pMgmt
->eConfigMode
== WMAC_CONFIG_AP
) {
693 cancel_delayed_work_sync(&pDevice
->second_callback_work
);
694 pMgmt
->eCurrState
= WMAC_STATE_IDLE
;
695 pMgmt
->eCurrMode
= WMAC_MODE_STANDBY
;
696 pDevice
->bLinkPass
= false;
697 ControlvMaskByte(pDevice
,MESSAGE_REQUEST_MACREG
,MAC_REG_PAPEDELAY
,LEDSTS_STS
,LEDSTS_SLOW
);
698 if (pDevice
->bEnableHostWEP
== true)
699 BSSvClearNodeDBTable(pDevice
, 1);
701 BSSvClearNodeDBTable(pDevice
, 0);
702 pDevice
->uAssocCount
= 0;
703 pMgmt
->eCurrState
= WMAC_STATE_IDLE
;
704 pDevice
->bFixRate
= false;
706 vMgrCreateOwnIBSS((void *) pDevice
, &Status
);
707 if (Status
!= CMD_STATUS_SUCCESS
) {
708 DBG_PRT(MSG_LEVEL_DEBUG
,
709 KERN_INFO
"vMgrCreateOwnIBSS fail!\n");
711 // always turn off unicast bit
712 MACvRegBitsOff(pDevice
, MAC_REG_RCR
, RCR_UNICAST
);
713 pDevice
->byRxMode
&= ~RCR_UNICAST
;
714 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"wcmd: rx_mode = %x\n", pDevice
->byRxMode
);
715 BSSvAddMulticastNode(pDevice
);
716 if (netif_queue_stopped(pDevice
->dev
)){
717 netif_wake_queue(pDevice
->dev
);
719 pDevice
->bLinkPass
= true;
720 ControlvMaskByte(pDevice
,MESSAGE_REQUEST_MACREG
,MAC_REG_PAPEDELAY
,LEDSTS_STS
,LEDSTS_INTER
);
721 schedule_delayed_work(&pDevice
->second_callback_work
, HZ
);
723 s_bCommandComplete(pDevice
);
726 case WLAN_CMD_TX_PSPACKET_START
:
728 if (pMgmt
->sNodeDBTable
[0].bRxPSPoll
) {
729 while ((skb
= skb_dequeue(&pMgmt
->sNodeDBTable
[0].sTxPSQueue
)) != NULL
) {
730 if (skb_queue_empty(&pMgmt
->sNodeDBTable
[0].sTxPSQueue
)) {
731 pMgmt
->abyPSTxMap
[0] &= ~byMask
[0];
732 pDevice
->bMoreData
= false;
735 pDevice
->bMoreData
= true;
738 if (nsDMA_tx_packet(pDevice
, TYPE_AC0DMA
, skb
) != 0) {
739 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Multicast ps tx fail \n");
742 pMgmt
->sNodeDBTable
[0].wEnQueueCnt
--;
747 for (ii
= 1; ii
< (MAX_NODE_NUM
+ 1); ii
++) {
748 if (pMgmt
->sNodeDBTable
[ii
].bActive
&&
749 pMgmt
->sNodeDBTable
[ii
].bRxPSPoll
) {
750 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Index=%d Enqueu Cnt= %d\n",
751 ii
, pMgmt
->sNodeDBTable
[ii
].wEnQueueCnt
);
752 while ((skb
= skb_dequeue(&pMgmt
->sNodeDBTable
[ii
].sTxPSQueue
)) != NULL
) {
753 if (skb_queue_empty(&pMgmt
->sNodeDBTable
[ii
].sTxPSQueue
)) {
755 pMgmt
->abyPSTxMap
[pMgmt
->sNodeDBTable
[ii
].wAID
>> 3] &=
756 ~byMask
[pMgmt
->sNodeDBTable
[ii
].wAID
& 7];
757 pDevice
->bMoreData
= false;
760 pDevice
->bMoreData
= true;
763 if (nsDMA_tx_packet(pDevice
, TYPE_AC0DMA
, skb
) != 0) {
764 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"sta ps tx fail \n");
767 pMgmt
->sNodeDBTable
[ii
].wEnQueueCnt
--;
768 // check if sta ps enable, wait next pspoll
769 // if sta ps disable, send all pending buffers.
770 if (pMgmt
->sNodeDBTable
[ii
].bPSEnable
)
773 if (skb_queue_empty(&pMgmt
->sNodeDBTable
[ii
].sTxPSQueue
)) {
775 pMgmt
->abyPSTxMap
[pMgmt
->sNodeDBTable
[ii
].wAID
>> 3] &=
776 ~byMask
[pMgmt
->sNodeDBTable
[ii
].wAID
& 7];
777 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Index=%d PS queue clear \n", ii
);
779 pMgmt
->sNodeDBTable
[ii
].bRxPSPoll
= false;
783 s_bCommandComplete(pDevice
);
786 case WLAN_CMD_RADIO_START
:
788 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"eCommandState == WLAN_CMD_RADIO_START\n");
789 // if (pDevice->bRadioCmd == true)
790 // CARDbRadioPowerOn(pDevice);
792 // CARDbRadioPowerOff(pDevice);
795 int ntStatus
= STATUS_SUCCESS
;
798 ntStatus
= CONTROLnsRequestIn(pDevice
,
801 MESSAGE_REQUEST_MACREG
,
805 if ( ntStatus
!= STATUS_SUCCESS
) {
806 s_bCommandComplete(pDevice
);
807 spin_unlock_irq(&pDevice
->lock
);
810 if ( (byTmp
& GPIO3_DATA
) == 0 ) {
811 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" WLAN_CMD_RADIO_START_OFF........................\n");
812 // Old commands are useless.
814 pDevice
->cbFreeCmdQueue
= CMD_Q_SIZE
;
815 pDevice
->uCmdDequeueIdx
= 0;
816 pDevice
->uCmdEnqueueIdx
= 0;
817 //0415pDevice->bCmdRunning = false;
818 pDevice
->bCmdClear
= true;
819 pDevice
->bStopTx0Pkt
= false;
820 pDevice
->bStopDataPkt
= true;
822 pDevice
->byKeyIndex
= 0;
823 pDevice
->bTransmitKey
= false;
824 spin_unlock_irq(&pDevice
->lock
);
825 KeyvInitTable(pDevice
,&pDevice
->sKey
);
826 spin_lock_irq(&pDevice
->lock
);
827 pMgmt
->byCSSPK
= KEY_CTL_NONE
;
828 pMgmt
->byCSSGK
= KEY_CTL_NONE
;
830 if (pDevice
->bLinkPass
== true) {
831 // reason = 8 : disassoc because sta has left
832 vMgrDisassocBeginSta((void *) pDevice
,
837 pDevice
->bLinkPass
= false;
838 // unlock command busy
839 pMgmt
->eCurrState
= WMAC_STATE_IDLE
;
840 pMgmt
->sNodeDBTable
[0].bActive
= false;
841 // if(pDevice->bWPASuppWextEnabled == true)
843 union iwreq_data wrqu
;
844 memset(&wrqu
, 0, sizeof (wrqu
));
845 wrqu
.ap_addr
.sa_family
= ARPHRD_ETHER
;
846 PRINT_K("wireless_send_event--->SIOCGIWAP(disassociated)\n");
847 wireless_send_event(pDevice
->dev
, SIOCGIWAP
, &wrqu
, NULL
);
850 pDevice
->bwextstep0
= false;
851 pDevice
->bwextstep1
= false;
852 pDevice
->bwextstep2
= false;
853 pDevice
->bwextstep3
= false;
854 pDevice
->bWPASuppWextEnabled
= false;
856 pItemSSID
= (PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
;
858 memset(pItemSSID
->abySSID
, 0, WLAN_SSID_MAXLEN
);
860 pItemSSID
= (PWLAN_IE_SSID
)pMgmt
->abyDesireSSID
;
862 memset(pItemSSID
->abySSID
, 0, WLAN_SSID_MAXLEN
);
864 netif_stop_queue(pDevice
->dev
);
865 CARDbRadioPowerOff(pDevice
);
866 MACvRegBitsOn(pDevice
,MAC_REG_GPIOCTL1
,GPIO3_INTMD
);
867 ControlvMaskByte(pDevice
,MESSAGE_REQUEST_MACREG
,MAC_REG_PAPEDELAY
,LEDSTS_STS
,LEDSTS_OFF
);
868 pDevice
->bHWRadioOff
= true;
870 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" WLAN_CMD_RADIO_START_ON........................\n");
871 pDevice
->bHWRadioOff
= false;
872 CARDbRadioPowerOn(pDevice
);
873 MACvRegBitsOff(pDevice
,MAC_REG_GPIOCTL1
,GPIO3_INTMD
);
874 ControlvMaskByte(pDevice
,MESSAGE_REQUEST_MACREG
,MAC_REG_PAPEDELAY
,LEDSTS_STS
,LEDSTS_ON
);
878 s_bCommandComplete(pDevice
);
881 case WLAN_CMD_CHANGE_BBSENSITIVITY_START
:
883 pDevice
->bStopDataPkt
= true;
884 pDevice
->byBBVGACurrent
= pDevice
->byBBVGANew
;
885 BBvSetVGAGainOffset(pDevice
, pDevice
->byBBVGACurrent
);
886 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Change sensitivity pDevice->byBBVGACurrent = %x\n", pDevice
->byBBVGACurrent
);
887 pDevice
->bStopDataPkt
= false;
888 s_bCommandComplete(pDevice
);
891 case WLAN_CMD_TBTT_WAKEUP_START
:
892 PSbIsNextTBTTWakeUp(pDevice
);
893 s_bCommandComplete(pDevice
);
896 case WLAN_CMD_BECON_SEND_START
:
897 bMgrPrepareBeaconToSend(pDevice
, pMgmt
);
898 s_bCommandComplete(pDevice
);
901 case WLAN_CMD_SETPOWER_START
:
903 RFbSetPower(pDevice
, pDevice
->wCurrentRate
, pMgmt
->uCurrChannel
);
905 s_bCommandComplete(pDevice
);
908 case WLAN_CMD_CHANGE_ANTENNA_START
:
909 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Change from Antenna%d to", (int)pDevice
->dwRxAntennaSel
);
910 if ( pDevice
->dwRxAntennaSel
== 0) {
911 pDevice
->dwRxAntennaSel
=1;
912 if (pDevice
->bTxRxAntInv
== true)
913 BBvSetAntennaMode(pDevice
, ANT_RXA
);
915 BBvSetAntennaMode(pDevice
, ANT_RXB
);
917 pDevice
->dwRxAntennaSel
=0;
918 if (pDevice
->bTxRxAntInv
== true)
919 BBvSetAntennaMode(pDevice
, ANT_RXB
);
921 BBvSetAntennaMode(pDevice
, ANT_RXA
);
923 s_bCommandComplete(pDevice
);
926 case WLAN_CMD_REMOVE_ALLKEY_START
:
927 KeybRemoveAllKey(pDevice
, &(pDevice
->sKey
), pDevice
->abyBSSID
);
928 s_bCommandComplete(pDevice
);
931 case WLAN_CMD_MAC_DISPOWERSAVING_START
:
932 ControlvReadByte (pDevice
, MESSAGE_REQUEST_MACREG
, MAC_REG_PSCTL
, &byData
);
933 if ( (byData
& PSCTL_PS
) != 0 ) {
934 // disable power saving hw function
935 CONTROLnsRequestOut(pDevice
,
936 MESSAGE_TYPE_DISABLE_PS
,
943 s_bCommandComplete(pDevice
);
946 case WLAN_CMD_11H_CHSW_START
:
947 CARDbSetMediaChannel(pDevice
, pDevice
->byNewChannel
);
948 pDevice
->bChannelSwitch
= false;
949 pMgmt
->uCurrChannel
= pDevice
->byNewChannel
;
950 pDevice
->bStopDataPkt
= false;
951 s_bCommandComplete(pDevice
);
955 s_bCommandComplete(pDevice
);
959 spin_unlock_irq(&pDevice
->lock
);
963 static int s_bCommandComplete(struct vnt_private
*pDevice
)
965 struct vnt_manager
*pMgmt
= &pDevice
->vnt_mgmt
;
967 int bRadioCmd
= false;
968 int bForceSCAN
= true;
970 pDevice
->eCommandState
= WLAN_CMD_IDLE
;
971 if (pDevice
->cbFreeCmdQueue
== CMD_Q_SIZE
) {
972 //Command Queue Empty
973 pDevice
->bCmdRunning
= false;
977 pDevice
->eCommand
= pDevice
->eCmdQueue
[pDevice
->uCmdDequeueIdx
].eCmd
;
978 pSSID
= (PWLAN_IE_SSID
)pDevice
->eCmdQueue
[pDevice
->uCmdDequeueIdx
].abyCmdDesireSSID
;
979 bRadioCmd
= pDevice
->eCmdQueue
[pDevice
->uCmdDequeueIdx
].bRadioCmd
;
980 bForceSCAN
= pDevice
->eCmdQueue
[pDevice
->uCmdDequeueIdx
].bForceSCAN
;
981 ADD_ONE_WITH_WRAP_AROUND(pDevice
->uCmdDequeueIdx
, CMD_Q_SIZE
);
982 pDevice
->cbFreeCmdQueue
++;
983 pDevice
->bCmdRunning
= true;
984 switch ( pDevice
->eCommand
) {
985 case WLAN_CMD_BSSID_SCAN
:
986 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"eCommandState= WLAN_CMD_BSSID_SCAN\n");
987 pDevice
->eCommandState
= WLAN_CMD_SCAN_START
;
988 pMgmt
->uScanChannel
= 0;
989 if (pSSID
->len
!= 0) {
990 memcpy(pMgmt
->abyScanSSID
, pSSID
, WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1);
992 memset(pMgmt
->abyScanSSID
, 0, WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1);
995 if ((bForceSCAN == false) && (pDevice->bLinkPass == true)) {
996 if ((pSSID->len == ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->len) &&
997 ( !memcmp(pSSID->abySSID, ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->abySSID, pSSID->len))) {
998 pDevice->eCommandState = WLAN_CMD_IDLE;
1004 pDevice
->eCommandState
= WLAN_CMD_SSID_START
;
1005 if (pSSID
->len
> WLAN_SSID_MAXLEN
)
1006 pSSID
->len
= WLAN_SSID_MAXLEN
;
1007 if (pSSID
->len
!= 0)
1008 memcpy(pMgmt
->abyDesireSSID
, pSSID
, WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1);
1009 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"eCommandState= WLAN_CMD_SSID_START\n");
1011 case WLAN_CMD_DISASSOCIATE
:
1012 pDevice
->eCommandState
= WLAN_CMD_DISASSOCIATE_START
;
1014 case WLAN_CMD_RX_PSPOLL
:
1015 pDevice
->eCommandState
= WLAN_CMD_TX_PSPACKET_START
;
1017 case WLAN_CMD_RUN_AP
:
1018 pDevice
->eCommandState
= WLAN_CMD_AP_MODE_START
;
1020 case WLAN_CMD_RADIO
:
1021 pDevice
->eCommandState
= WLAN_CMD_RADIO_START
;
1022 pDevice
->bRadioCmd
= bRadioCmd
;
1024 case WLAN_CMD_CHANGE_BBSENSITIVITY
:
1025 pDevice
->eCommandState
= WLAN_CMD_CHANGE_BBSENSITIVITY_START
;
1028 case WLAN_CMD_TBTT_WAKEUP
:
1029 pDevice
->eCommandState
= WLAN_CMD_TBTT_WAKEUP_START
;
1032 case WLAN_CMD_BECON_SEND
:
1033 pDevice
->eCommandState
= WLAN_CMD_BECON_SEND_START
;
1036 case WLAN_CMD_SETPOWER
:
1037 pDevice
->eCommandState
= WLAN_CMD_SETPOWER_START
;
1040 case WLAN_CMD_CHANGE_ANTENNA
:
1041 pDevice
->eCommandState
= WLAN_CMD_CHANGE_ANTENNA_START
;
1044 case WLAN_CMD_REMOVE_ALLKEY
:
1045 pDevice
->eCommandState
= WLAN_CMD_REMOVE_ALLKEY_START
;
1048 case WLAN_CMD_MAC_DISPOWERSAVING
:
1049 pDevice
->eCommandState
= WLAN_CMD_MAC_DISPOWERSAVING_START
;
1052 case WLAN_CMD_11H_CHSW
:
1053 pDevice
->eCommandState
= WLAN_CMD_11H_CHSW_START
;
1060 vCommandTimerWait(pDevice
, 0);
1066 int bScheduleCommand(struct vnt_private
*pDevice
,
1067 CMD_CODE eCommand
, u8
*pbyItem0
)
1070 if (pDevice
->cbFreeCmdQueue
== 0) {
1073 pDevice
->eCmdQueue
[pDevice
->uCmdEnqueueIdx
].eCmd
= eCommand
;
1074 pDevice
->eCmdQueue
[pDevice
->uCmdEnqueueIdx
].bForceSCAN
= true;
1075 memset(pDevice
->eCmdQueue
[pDevice
->uCmdEnqueueIdx
].abyCmdDesireSSID
, 0 , WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1);
1076 if (pbyItem0
!= NULL
) {
1078 case WLAN_CMD_BSSID_SCAN
:
1079 pDevice
->eCmdQueue
[pDevice
->uCmdEnqueueIdx
].bForceSCAN
= false;
1080 memcpy(pDevice
->eCmdQueue
[pDevice
->uCmdEnqueueIdx
].abyCmdDesireSSID
,
1081 pbyItem0
, WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1);
1085 memcpy(pDevice
->eCmdQueue
[pDevice
->uCmdEnqueueIdx
].abyCmdDesireSSID
,
1086 pbyItem0
, WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1);
1089 case WLAN_CMD_DISASSOCIATE
:
1090 pDevice
->eCmdQueue
[pDevice
->uCmdEnqueueIdx
].bNeedRadioOFF
= *((int *)pbyItem0
);
1093 case WLAN_CMD_DEAUTH:
1094 pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].wDeAuthenReason = *((u16 *)pbyItem0);
1098 case WLAN_CMD_RADIO
:
1099 pDevice
->eCmdQueue
[pDevice
->uCmdEnqueueIdx
].bRadioCmd
= *((int *)pbyItem0
);
1107 ADD_ONE_WITH_WRAP_AROUND(pDevice
->uCmdEnqueueIdx
, CMD_Q_SIZE
);
1108 pDevice
->cbFreeCmdQueue
--;
1110 if (pDevice
->bCmdRunning
== false) {
1111 s_bCommandComplete(pDevice
);
1121 * Clear BSSID_SCAN cmd in CMD Queue
1125 * hDeviceContext - Pointer to the adapter
1126 * eCommand - Command
1130 * Return Value: true if success; otherwise false
1133 static int s_bClearBSSID_SCAN(struct vnt_private
*pDevice
)
1135 unsigned int uCmdDequeueIdx
= pDevice
->uCmdDequeueIdx
;
1138 if ((pDevice
->cbFreeCmdQueue
< CMD_Q_SIZE
) && (uCmdDequeueIdx
!= pDevice
->uCmdEnqueueIdx
)) {
1139 for (ii
= 0; ii
< (CMD_Q_SIZE
- pDevice
->cbFreeCmdQueue
); ii
++) {
1140 if (pDevice
->eCmdQueue
[uCmdDequeueIdx
].eCmd
== WLAN_CMD_BSSID_SCAN
)
1141 pDevice
->eCmdQueue
[uCmdDequeueIdx
].eCmd
= WLAN_CMD_IDLE
;
1142 ADD_ONE_WITH_WRAP_AROUND(uCmdDequeueIdx
, CMD_Q_SIZE
);
1143 if (uCmdDequeueIdx
== pDevice
->uCmdEnqueueIdx
)
1150 //mike add:reset command timer
1151 void vResetCommandTimer(struct vnt_private
*pDevice
)
1153 cancel_delayed_work_sync(&pDevice
->run_command_work
);
1155 pDevice
->cbFreeCmdQueue
= CMD_Q_SIZE
;
1156 pDevice
->uCmdDequeueIdx
= 0;
1157 pDevice
->uCmdEnqueueIdx
= 0;
1158 pDevice
->eCommandState
= WLAN_CMD_IDLE
;
1159 pDevice
->bCmdRunning
= false;
1160 pDevice
->bCmdClear
= false;
1163 void BSSvSecondTxData(struct vnt_private
*pDevice
)
1165 struct vnt_manager
*pMgmt
= &pDevice
->vnt_mgmt
;
1167 pDevice
->nTxDataTimeCout
++;
1169 if (pDevice
->nTxDataTimeCout
< 4) { //don't tx data if timer less than 40s
1170 // printk("mike:%s-->no data Tx not exceed the desired Time as %d\n",__FUNCTION__,
1171 // (int)pDevice->nTxDataTimeCout);
1172 pDevice
->sTimerTxData
.expires
= RUN_AT(10 * HZ
); //10s callback
1173 add_timer(&pDevice
->sTimerTxData
);
1177 spin_lock_irq(&pDevice
->lock
);
1178 //is wap_supplicant running successful OR only open && sharekey mode!
1179 if (((pDevice
->bLinkPass
== true) &&
1180 (pMgmt
->eAuthenMode
< WMAC_AUTH_WPA
)) || //open && sharekey linking
1181 (pDevice
->fWPA_Authened
== true)) { //wpa linking
1182 // printk("mike:%s-->InSleep Tx Data Procedure\n",__FUNCTION__);
1183 pDevice
->fTxDataInSleep
= true;
1184 PSbSendNullPacket(pDevice
); //send null packet
1185 pDevice
->fTxDataInSleep
= false;
1187 spin_unlock_irq(&pDevice
->lock
);
1189 pDevice
->sTimerTxData
.expires
= RUN_AT(10 * HZ
); //10s callback
1190 add_timer(&pDevice
->sTimerTxData
);