Merge branch 'fix/pcm-hwptr' into for-linus
[linux/fpc-iii.git] / drivers / staging / vt6655 / wcmd.c
blob92563bd011b2c09c7786b03210e8f996df202298
1 /*
2 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
3 * All rights reserved.
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.
20 * File: wcmd.c
22 * Purpose: Handles the management command interface functions
24 * Author: Lyndon Chen
26 * Date: May 8, 2003
28 * Functions:
29 * s_vProbeChannel - Active scan channel
30 * s_MgrMakeProbeRequest - Make ProbeRequest packet
31 * CommandTimer - Timer function to handle command
32 * s_bCommandComplete - Command Complete function
33 * bScheduleCommand - Push Command and wait Command Scheduler to do
34 * vCommandTimer- Command call back functions
35 * vCommandTimerWait- Call back timer
36 * bClearBSSID_SCAN- Clear BSSID_SCAN cmd in CMD Queue
38 * Revision History:
45 #if !defined(__TTYPE_H__)
46 #include "ttype.h"
47 #endif
48 #if !defined(__TMACRO_H__)
49 #include "tmacro.h"
50 #endif
51 #if !defined(__DEVICE_H__)
52 #include "device.h"
53 #endif
54 #if !defined(__MAC_H__)
55 #include "mac.h"
56 #endif
57 #if !defined(__CARD_H__)
58 #include "card.h"
59 #endif
60 #if !defined(__80211HDR_H__)
61 #include "80211hdr.h"
62 #endif
63 #if !defined(__WCMD_H__)
64 #include "wcmd.h"
65 #endif
66 #if !defined(__WMGR_H__)
67 #include "wmgr.h"
68 #endif
69 #if !defined(__POWER_H__)
70 #include "power.h"
71 #endif
72 #if !defined(__WCTL_H__)
73 #include "wctl.h"
74 #endif
75 #if !defined(__CARD_H__)
76 #include "card.h"
77 #endif
78 #if !defined(__BASEBAND_H__)
79 #include "baseband.h"
80 #endif
81 #if !defined(__UMEM_H__)
82 #include "umem.h"
83 #endif
84 #if !defined(__RXTX_H__)
85 #include "rxtx.h"
86 #endif
87 #if !defined(__RF_H__)
88 #include "rf.h"
89 #endif
90 //DavidWang
91 #if !defined(__IOWPA_H__)
92 #include "iowpa.h"
93 #endif
95 /*--------------------- Static Definitions -------------------------*/
100 /*--------------------- Static Classes ----------------------------*/
102 /*--------------------- Static Variables --------------------------*/
103 static int msglevel =MSG_LEVEL_INFO;
104 //static int msglevel =MSG_LEVEL_DEBUG;
105 /*--------------------- Static Functions --------------------------*/
107 static
108 VOID
109 s_vProbeChannel(
110 IN PSDevice pDevice
114 static
115 PSTxMgmtPacket
116 s_MgrMakeProbeRequest(
117 IN PSDevice pDevice,
118 IN PSMgmtObject pMgmt,
119 IN PBYTE pScanBSSID,
120 IN PWLAN_IE_SSID pSSID,
121 IN PWLAN_IE_SUPP_RATES pCurrRates,
122 IN PWLAN_IE_SUPP_RATES pCurrExtSuppRates
125 static
126 BOOL
127 s_bCommandComplete (
128 PSDevice pDevice
131 /*--------------------- Export Variables --------------------------*/
134 /*--------------------- Export Functions --------------------------*/
138 * Description:
139 * Stop AdHoc beacon during scan process
141 * Parameters:
142 * In:
143 * pDevice - Pointer to the adapter
144 * Out:
145 * none
147 * Return Value: none
150 static
151 void
152 vAdHocBeaconStop(PSDevice pDevice)
155 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
156 BOOL bStop;
159 * temporarily stop Beacon packet for AdHoc Server
160 * if all of the following coditions are met:
161 * (1) STA is in AdHoc mode
162 * (2) VT3253 is programmed as automatic Beacon Transmitting
163 * (3) One of the following conditions is met
164 * (3.1) AdHoc channel is in B/G band and the
165 * current scan channel is in A band
166 * or
167 * (3.2) AdHoc channel is in A mode
169 bStop = FALSE;
170 if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) &&
171 (pMgmt->eCurrState >= WMAC_STATE_STARTED))
173 if ((pMgmt->uIBSSChannel <= CB_MAX_CHANNEL_24G) &&
174 (pMgmt->uScanChannel > CB_MAX_CHANNEL_24G))
176 bStop = TRUE;
178 if (pMgmt->uIBSSChannel > CB_MAX_CHANNEL_24G)
180 bStop = TRUE;
184 if (bStop)
186 MACvRegBitsOff(pDevice->PortOffset, MAC_REG_TCR, TCR_AUTOBCNTX);
192 * Description:
193 * Restart AdHoc beacon after scan process complete
195 * Parameters:
196 * In:
197 * pDevice - Pointer to the adapter
198 * Out:
199 * none
201 * Return Value: none
204 static
205 void
206 vAdHocBeaconRestart(PSDevice pDevice)
208 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
211 * Restart Beacon packet for AdHoc Server
212 * if all of the following coditions are met:
213 * (1) STA is in AdHoc mode
214 * (2) VT3253 is programmed as automatic Beacon Transmitting
216 if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) &&
217 (pMgmt->eCurrState >= WMAC_STATE_STARTED))
219 MACvRegBitsOn(pDevice->PortOffset, MAC_REG_TCR, TCR_AUTOBCNTX);
229 * Routine Description:
230 * Prepare and send probe request management frames.
233 * Return Value:
234 * none.
238 static
239 VOID
240 s_vProbeChannel(
241 IN PSDevice pDevice
244 //1M, 2M, 5M, 11M, 18M, 24M, 36M, 54M
245 BYTE abyCurrSuppRatesG[] = {WLAN_EID_SUPP_RATES, 8, 0x02, 0x04, 0x0B, 0x16, 0x24, 0x30, 0x48, 0x6C};
246 BYTE abyCurrExtSuppRatesG[] = {WLAN_EID_EXTSUPP_RATES, 4, 0x0C, 0x12, 0x18, 0x60};
247 //6M, 9M, 12M, 48M
248 BYTE abyCurrSuppRatesA[] = {WLAN_EID_SUPP_RATES, 8, 0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C};
249 BYTE abyCurrSuppRatesB[] = {WLAN_EID_SUPP_RATES, 4, 0x02, 0x04, 0x0B, 0x16};
250 PBYTE pbyRate;
251 PSTxMgmtPacket pTxPacket;
252 PSMgmtObject pMgmt = pDevice->pMgmt;
253 UINT ii;
256 if (pDevice->eCurrentPHYType == PHY_TYPE_11A) {
257 pbyRate = &abyCurrSuppRatesA[0];
258 } else if (pDevice->eCurrentPHYType == PHY_TYPE_11B) {
259 pbyRate = &abyCurrSuppRatesB[0];
260 } else {
261 pbyRate = &abyCurrSuppRatesG[0];
263 // build an assocreq frame and send it
264 pTxPacket = s_MgrMakeProbeRequest
266 pDevice,
267 pMgmt,
268 pMgmt->abyScanBSSID,
269 (PWLAN_IE_SSID)pMgmt->abyScanSSID,
270 (PWLAN_IE_SUPP_RATES)pbyRate,
271 (PWLAN_IE_SUPP_RATES)abyCurrExtSuppRatesG
274 if (pTxPacket != NULL ){
275 for (ii = 0; ii < 2 ; ii++) {
276 if (csMgmt_xmit(pDevice, pTxPacket) != CMD_STATUS_PENDING) {
277 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Probe request sending fail.. \n");
279 else {
280 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Probe request is sending.. \n");
292 * Routine Description:
293 * Constructs an probe request frame
296 * Return Value:
297 * A ptr to Tx frame or NULL on allocation failue
302 PSTxMgmtPacket
303 s_MgrMakeProbeRequest(
304 IN PSDevice pDevice,
305 IN PSMgmtObject pMgmt,
306 IN PBYTE pScanBSSID,
307 IN PWLAN_IE_SSID pSSID,
308 IN PWLAN_IE_SUPP_RATES pCurrRates,
309 IN PWLAN_IE_SUPP_RATES pCurrExtSuppRates
313 PSTxMgmtPacket pTxPacket = NULL;
314 WLAN_FR_PROBEREQ sFrame;
317 pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool;
318 memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_PROBEREQ_FR_MAXLEN);
319 pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket));
320 sFrame.pBuf = (PBYTE)pTxPacket->p80211Header;
321 sFrame.len = WLAN_PROBEREQ_FR_MAXLEN;
322 vMgrEncodeProbeRequest(&sFrame);
323 sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16(
325 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) |
326 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_PROBEREQ)
328 memcpy( sFrame.pHdr->sA3.abyAddr1, pScanBSSID, WLAN_ADDR_LEN);
329 memcpy( sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN);
330 memcpy( sFrame.pHdr->sA3.abyAddr3, pScanBSSID, WLAN_BSSID_LEN);
331 // Copy the SSID, pSSID->len=0 indicate broadcast SSID
332 sFrame.pSSID = (PWLAN_IE_SSID)(sFrame.pBuf + sFrame.len);
333 sFrame.len += pSSID->len + WLAN_IEHDR_LEN;
334 memcpy(sFrame.pSSID, pSSID, pSSID->len + WLAN_IEHDR_LEN);
335 sFrame.pSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len);
336 sFrame.len += pCurrRates->len + WLAN_IEHDR_LEN;
337 memcpy(sFrame.pSuppRates, pCurrRates, pCurrRates->len + WLAN_IEHDR_LEN);
338 // Copy the extension rate set
339 if (pDevice->eCurrentPHYType == PHY_TYPE_11G) {
340 sFrame.pExtSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len);
341 sFrame.len += pCurrExtSuppRates->len + WLAN_IEHDR_LEN;
342 memcpy(sFrame.pExtSuppRates, pCurrExtSuppRates, pCurrExtSuppRates->len + WLAN_IEHDR_LEN);
344 pTxPacket->cbMPDULen = sFrame.len;
345 pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN;
347 return pTxPacket;
353 VOID
354 vCommandTimerWait(
355 IN HANDLE hDeviceContext,
356 IN UINT MSecond
359 PSDevice pDevice = (PSDevice)hDeviceContext;
361 init_timer(&pDevice->sTimerCommand);
362 pDevice->sTimerCommand.data = (ULONG)pDevice;
363 pDevice->sTimerCommand.function = (TimerFunction)vCommandTimer;
364 // RUN_AT :1 msec ~= (HZ/1024)
365 pDevice->sTimerCommand.expires = (UINT)RUN_AT((MSecond * HZ) >> 10);
366 add_timer(&pDevice->sTimerCommand);
367 return;
372 VOID
373 vCommandTimer (
374 IN HANDLE hDeviceContext
377 PSDevice pDevice = (PSDevice)hDeviceContext;
378 PSMgmtObject pMgmt = pDevice->pMgmt;
379 PWLAN_IE_SSID pItemSSID;
380 PWLAN_IE_SSID pItemSSIDCurr;
381 CMD_STATUS Status;
382 UINT ii;
383 BYTE byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80};
384 struct sk_buff *skb;
387 if (pDevice->dwDiagRefCount != 0)
388 return;
389 if (pDevice->bCmdRunning != TRUE)
390 return;
392 spin_lock_irq(&pDevice->lock);
394 switch ( pDevice->eCommandState ) {
396 case WLAN_CMD_SCAN_START:
398 pDevice->byReAssocCount = 0;
399 if (pDevice->bRadioOff == TRUE) {
400 s_bCommandComplete(pDevice);
401 spin_unlock_irq(&pDevice->lock);
402 return;
405 if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
406 s_bCommandComplete(pDevice);
407 CARDbSetBSSID(pMgmt->pAdapter, pMgmt->abyCurrBSSID, OP_MODE_AP);
408 spin_unlock_irq(&pDevice->lock);
409 return;
412 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState= WLAN_CMD_SCAN_START\n");
413 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyScanSSID;
414 // wait all Data TD complete
415 if (pDevice->iTDUsed[TYPE_AC0DMA] != 0){
416 spin_unlock_irq(&pDevice->lock);
417 vCommandTimerWait((HANDLE)pDevice, 10);
418 return;
421 if (pMgmt->uScanChannel == 0 ) {
422 pMgmt->uScanChannel = pDevice->byMinChannel;
423 // Set Baseband to be more sensitive.
426 if (pMgmt->uScanChannel > pDevice->byMaxChannel) {
427 pMgmt->eScanState = WMAC_NO_SCANNING;
429 // Set Baseband's sensitivity back.
430 // Set channel back
431 CARDbSetChannel(pMgmt->pAdapter, pMgmt->uCurrChannel);
432 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Scanning, set back to channel: [%d]\n", pMgmt->uCurrChannel);
433 if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) {
434 CARDbSetBSSID(pMgmt->pAdapter, pMgmt->abyCurrBSSID, OP_MODE_ADHOC);
435 } else {
436 CARDbSetBSSID(pMgmt->pAdapter, pMgmt->abyCurrBSSID, OP_MODE_INFRASTRUCTURE);
438 vAdHocBeaconRestart(pDevice);
439 s_bCommandComplete(pDevice);
441 } else {
442 //2008-8-4 <add> by chester
443 if (!ChannelValid(pDevice->byZoneType, pMgmt->uScanChannel)) {
444 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Invalid channel pMgmt->uScanChannel = %d \n",pMgmt->uScanChannel);
445 s_bCommandComplete(pDevice);
446 return;
448 //printk("chester-pMgmt->uScanChannel=%d,pDevice->byMaxChannel=%d\n",pMgmt->uScanChannel,pDevice->byMaxChannel);
449 if (pMgmt->uScanChannel == pDevice->byMinChannel) {
450 //pMgmt->eScanType = WMAC_SCAN_ACTIVE;
451 pMgmt->abyScanBSSID[0] = 0xFF;
452 pMgmt->abyScanBSSID[1] = 0xFF;
453 pMgmt->abyScanBSSID[2] = 0xFF;
454 pMgmt->abyScanBSSID[3] = 0xFF;
455 pMgmt->abyScanBSSID[4] = 0xFF;
456 pMgmt->abyScanBSSID[5] = 0xFF;
457 pItemSSID->byElementID = WLAN_EID_SSID;
458 // clear bssid list
459 // BSSvClearBSSList((HANDLE)pDevice, pDevice->bLinkPass);
460 pMgmt->eScanState = WMAC_IS_SCANNING;
464 vAdHocBeaconStop(pDevice);
466 if (CARDbSetChannel(pMgmt->pAdapter, pMgmt->uScanChannel) == TRUE) {
467 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"SCAN Channel: %d\n", pMgmt->uScanChannel);
468 } else {
469 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"SET SCAN Channel Fail: %d\n", pMgmt->uScanChannel);
471 CARDbSetBSSID(pMgmt->pAdapter, pMgmt->abyCurrBSSID, OP_MODE_UNKNOWN);
472 // printk("chester-mxch=%d\n",pDevice->byMaxChannel);
473 // printk("chester-ch=%d\n",pMgmt->uScanChannel);
474 pMgmt->uScanChannel++;
475 //2008-8-4 <modify> by chester
476 if (!ChannelValid(pDevice->byZoneType, pMgmt->uScanChannel) &&
477 pMgmt->uScanChannel <= pDevice->byMaxChannel ){
478 pMgmt->uScanChannel=pDevice->byMaxChannel+1;
479 pMgmt->eCommandState = WLAN_CMD_SCAN_END;
484 if ((pMgmt->b11hEnable == FALSE) ||
485 (pMgmt->uScanChannel < CB_MAX_CHANNEL_24G)) {
486 s_vProbeChannel(pDevice);
487 spin_unlock_irq(&pDevice->lock);
488 vCommandTimerWait((HANDLE)pDevice, WCMD_ACTIVE_SCAN_TIME);
489 return;
490 } else {
491 spin_unlock_irq(&pDevice->lock);
492 vCommandTimerWait((HANDLE)pDevice, WCMD_PASSIVE_SCAN_TIME);
493 return;
498 break;
500 case WLAN_CMD_SCAN_END:
502 // Set Baseband's sensitivity back.
503 // Set channel back
504 CARDbSetChannel(pMgmt->pAdapter, pMgmt->uCurrChannel);
505 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Scanning, set back to channel: [%d]\n", pMgmt->uCurrChannel);
506 if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) {
507 CARDbSetBSSID(pMgmt->pAdapter, pMgmt->abyCurrBSSID, OP_MODE_ADHOC);
508 } else {
509 CARDbSetBSSID(pMgmt->pAdapter, pMgmt->abyCurrBSSID, OP_MODE_INFRASTRUCTURE);
512 pMgmt->eScanState = WMAC_NO_SCANNING;
513 vAdHocBeaconRestart(pDevice);
514 //2008-0409-07, <Add> by Einsn Liu
515 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
516 if(pMgmt->eScanType == WMAC_SCAN_PASSIVE)
517 {//send scan event to wpa_Supplicant
518 union iwreq_data wrqu;
519 memset(&wrqu, 0, sizeof(wrqu));
520 wireless_send_event(pDevice->dev, SIOCGIWSCAN, &wrqu, NULL);
522 #endif
523 s_bCommandComplete(pDevice);
524 break;
526 case WLAN_CMD_DISASSOCIATE_START :
527 pDevice->byReAssocCount = 0;
528 if ((pMgmt->eCurrMode == WMAC_MODE_ESS_STA) &&
529 (pMgmt->eCurrState != WMAC_STATE_ASSOC)) {
530 s_bCommandComplete(pDevice);
531 spin_unlock_irq(&pDevice->lock);
532 return;
533 } else {
534 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Send Disassociation Packet..\n");
535 // reason = 8 : disassoc because sta has left
536 vMgrDisassocBeginSta((HANDLE)pDevice, pMgmt, pMgmt->abyCurrBSSID, (8), &Status);
537 pDevice->bLinkPass = FALSE;
538 // unlock command busy
539 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
540 pItemSSID->len = 0;
541 memset(pItemSSID->abySSID, 0, WLAN_SSID_MAXLEN);
542 pMgmt->eCurrState = WMAC_STATE_IDLE;
543 pMgmt->sNodeDBTable[0].bActive = FALSE;
544 // pDevice->bBeaconBufReady = FALSE;
546 netif_stop_queue(pDevice->dev);
547 pDevice->eCommandState = WLAN_DISASSOCIATE_WAIT;
548 // wait all Control TD complete
549 if (pDevice->iTDUsed[TYPE_TXDMA0] != 0){
550 vCommandTimerWait((HANDLE)pDevice, 10);
551 spin_unlock_irq(&pDevice->lock);
552 return;
554 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" CARDbRadioPowerOff\n");
555 //2008-09-02 <mark> by chester
556 // CARDbRadioPowerOff(pDevice);
557 s_bCommandComplete(pDevice);
558 break;
560 case WLAN_DISASSOCIATE_WAIT :
561 // wait all Control TD complete
562 if (pDevice->iTDUsed[TYPE_TXDMA0] != 0){
563 vCommandTimerWait((HANDLE)pDevice, 10);
564 spin_unlock_irq(&pDevice->lock);
565 return;
567 //2008-09-02 <mark> by chester
568 // CARDbRadioPowerOff(pDevice);
569 s_bCommandComplete(pDevice);
570 break;
572 case WLAN_CMD_SSID_START:
573 pDevice->byReAssocCount = 0;
574 if (pDevice->bRadioOff == TRUE) {
575 s_bCommandComplete(pDevice);
576 spin_unlock_irq(&pDevice->lock);
577 return;
579 //printk("chester-currmode=%d\n",pMgmt->eCurrMode);
580 printk("chester-abyDesireSSID=%s\n",((PWLAN_IE_SSID)pMgmt->abyDesireSSID)->abySSID);
581 //memcpy(pMgmt->abyAdHocSSID,pMgmt->abyDesireSSID,
582 //((PWLAN_IE_SSID)pMgmt->abyDesireSSID)->len + WLAN_IEHDR_LEN);
583 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID;
584 pItemSSIDCurr = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
585 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" cmd: desire ssid = %s\n", pItemSSID->abySSID);
586 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" cmd: curr ssid = %s\n", pItemSSIDCurr->abySSID);
588 if (pMgmt->eCurrState == WMAC_STATE_ASSOC) {
589 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" Cmd pMgmt->eCurrState == WMAC_STATE_ASSOC\n");
590 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pItemSSID->len =%d\n",pItemSSID->len);
591 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pItemSSIDCurr->len = %d\n",pItemSSIDCurr->len);
592 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" desire ssid = %s\n", pItemSSID->abySSID);
593 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" curr ssid = %s\n", pItemSSIDCurr->abySSID);
596 if ((pMgmt->eCurrState == WMAC_STATE_ASSOC) ||
597 ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA)&& (pMgmt->eCurrState == WMAC_STATE_JOINTED))) {
599 if (pItemSSID->len == pItemSSIDCurr->len) {
600 if (memcmp(pItemSSID->abySSID, pItemSSIDCurr->abySSID, pItemSSID->len) == 0) {
601 s_bCommandComplete(pDevice);
602 spin_unlock_irq(&pDevice->lock);
603 return;
607 netif_stop_queue(pDevice->dev);
608 pDevice->bLinkPass = FALSE;
610 // set initial state
611 pMgmt->eCurrState = WMAC_STATE_IDLE;
612 pMgmt->eCurrMode = WMAC_MODE_STANDBY;
613 PSvDisablePowerSaving((HANDLE)pDevice);
614 BSSvClearNodeDBTable(pDevice, 0);
616 vMgrJoinBSSBegin((HANDLE)pDevice, &Status);
617 // if Infra mode
618 if ((pMgmt->eCurrMode == WMAC_MODE_ESS_STA) && (pMgmt->eCurrState == WMAC_STATE_JOINTED)) {
620 // Call mgr to begin the deauthentication
621 // reason = (3) beacuse sta has left ESS
622 if (pMgmt->eCurrState>= WMAC_STATE_AUTH) {
623 vMgrDeAuthenBeginSta((HANDLE)pDevice, pMgmt, pMgmt->abyCurrBSSID, (3), &Status);
625 // Call mgr to begin the authentication
626 vMgrAuthenBeginSta((HANDLE)pDevice, pMgmt, &Status);
627 if (Status == CMD_STATUS_SUCCESS) {
628 pDevice->byLinkWaitCount = 0;
629 pDevice->eCommandState = WLAN_AUTHENTICATE_WAIT;
630 vCommandTimerWait((HANDLE)pDevice, AUTHENTICATE_TIMEOUT);
631 spin_unlock_irq(&pDevice->lock);
632 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" Set eCommandState = WLAN_AUTHENTICATE_WAIT\n");
633 return;
636 // if Adhoc mode
637 else if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) {
638 if (pMgmt->eCurrState == WMAC_STATE_JOINTED) {
639 if (netif_queue_stopped(pDevice->dev)){
640 netif_wake_queue(pDevice->dev);
642 pDevice->bLinkPass = TRUE;
644 pMgmt->sNodeDBTable[0].bActive = TRUE;
645 pMgmt->sNodeDBTable[0].uInActiveCount = 0;
646 bClearBSSID_SCAN(pDevice);
648 else {
649 // start own IBSS
650 vMgrCreateOwnIBSS((HANDLE)pDevice, &Status);
651 if (Status != CMD_STATUS_SUCCESS){
652 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " WLAN_CMD_IBSS_CREATE fail ! \n");
654 BSSvAddMulticastNode(pDevice);
657 // if SSID not found
658 else if (pMgmt->eCurrMode == WMAC_MODE_STANDBY) {
659 if (pMgmt->eConfigMode == WMAC_CONFIG_IBSS_STA ||
660 pMgmt->eConfigMode == WMAC_CONFIG_AUTO) {
661 // start own IBSS
662 vMgrCreateOwnIBSS((HANDLE)pDevice, &Status);
663 if (Status != CMD_STATUS_SUCCESS){
664 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO" WLAN_CMD_IBSS_CREATE fail ! \n");
666 BSSvAddMulticastNode(pDevice);
667 if (netif_queue_stopped(pDevice->dev)){
668 netif_wake_queue(pDevice->dev);
670 pDevice->bLinkPass = TRUE;
672 else {
673 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disconnect SSID none\n");
674 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
675 // if(pDevice->bWPASuppWextEnabled == TRUE)
677 union iwreq_data wrqu;
678 memset(&wrqu, 0, sizeof (wrqu));
679 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
680 printk("wireless_send_event--->SIOCGIWAP(disassociated:vMgrJoinBSSBegin Fail !!)\n");
681 wireless_send_event(pDevice->dev, SIOCGIWAP, &wrqu, NULL);
683 #endif
687 s_bCommandComplete(pDevice);
688 break;
690 case WLAN_AUTHENTICATE_WAIT :
691 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState == WLAN_AUTHENTICATE_WAIT\n");
692 if (pMgmt->eCurrState == WMAC_STATE_AUTH) {
693 // Call mgr to begin the association
694 pDevice->byLinkWaitCount = 0;
695 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCurrState == WMAC_STATE_AUTH\n");
696 vMgrAssocBeginSta((HANDLE)pDevice, pMgmt, &Status);
697 if (Status == CMD_STATUS_SUCCESS) {
698 pDevice->byLinkWaitCount = 0;
699 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState = WLAN_ASSOCIATE_WAIT\n");
700 pDevice->eCommandState = WLAN_ASSOCIATE_WAIT;
701 vCommandTimerWait((HANDLE)pDevice, ASSOCIATE_TIMEOUT);
702 spin_unlock_irq(&pDevice->lock);
703 return;
707 else if(pMgmt->eCurrState < WMAC_STATE_AUTHPENDING) {
708 printk("WLAN_AUTHENTICATE_WAIT:Authen Fail???\n");
710 else if(pDevice->byLinkWaitCount <= 4){ //mike add:wait another 2 sec if authenticated_frame delay!
711 pDevice->byLinkWaitCount ++;
712 printk("WLAN_AUTHENTICATE_WAIT:wait %d times!!\n",pDevice->byLinkWaitCount);
713 spin_unlock_irq(&pDevice->lock);
714 vCommandTimerWait((HANDLE)pDevice, AUTHENTICATE_TIMEOUT/2);
715 return;
717 pDevice->byLinkWaitCount = 0;
718 #if 0
719 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
720 // if(pDevice->bWPASuppWextEnabled == TRUE)
722 union iwreq_data wrqu;
723 memset(&wrqu, 0, sizeof (wrqu));
724 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
725 printk("wireless_send_event--->SIOCGIWAP(disassociated:AUTHENTICATE_WAIT_timeout)\n");
726 wireless_send_event(pDevice->dev, SIOCGIWAP, &wrqu, NULL);
728 #endif
729 #endif
730 s_bCommandComplete(pDevice);
731 break;
733 case WLAN_ASSOCIATE_WAIT :
734 if (pMgmt->eCurrState == WMAC_STATE_ASSOC) {
735 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCurrState == WMAC_STATE_ASSOC\n");
736 if (pDevice->ePSMode != WMAC_POWER_CAM) {
737 PSvEnablePowerSaving((HANDLE)pDevice, pMgmt->wListenInterval);
739 if (pMgmt->eAuthenMode >= WMAC_AUTH_WPA) {
740 KeybRemoveAllKey(&(pDevice->sKey), pDevice->abyBSSID, pDevice->PortOffset);
742 pDevice->bLinkPass = TRUE;
743 pDevice->byLinkWaitCount = 0;
744 pDevice->byReAssocCount = 0;
745 bClearBSSID_SCAN(pDevice);
746 if (pDevice->byFOETuning) {
747 BBvSetFOE(pDevice->PortOffset);
748 PSbSendNullPacket(pDevice);
750 if (netif_queue_stopped(pDevice->dev)){
751 netif_wake_queue(pDevice->dev);
753 #ifdef TxInSleep
754 if(pDevice->IsTxDataTrigger != FALSE) { //TxDataTimer is not triggered at the first time
755 // printk("Re-initial TxDataTimer****\n");
756 del_timer(&pDevice->sTimerTxData);
757 init_timer(&pDevice->sTimerTxData);
758 pDevice->sTimerTxData.data = (ULONG)pDevice;
759 pDevice->sTimerTxData.function = (TimerFunction)BSSvSecondTxData;
760 pDevice->sTimerTxData.expires = RUN_AT(10*HZ); //10s callback
761 pDevice->fTxDataInSleep = FALSE;
762 pDevice->nTxDataTimeCout = 0;
764 else {
765 // printk("mike:-->First time triger TimerTxData InSleep\n");
767 pDevice->IsTxDataTrigger = TRUE;
768 add_timer(&pDevice->sTimerTxData);
769 #endif
771 else if(pMgmt->eCurrState < WMAC_STATE_ASSOCPENDING) {
772 printk("WLAN_ASSOCIATE_WAIT:Association Fail???\n");
774 else if(pDevice->byLinkWaitCount <= 4){ //mike add:wait another 2 sec if associated_frame delay!
775 pDevice->byLinkWaitCount ++;
776 printk("WLAN_ASSOCIATE_WAIT:wait %d times!!\n",pDevice->byLinkWaitCount);
777 spin_unlock_irq(&pDevice->lock);
778 vCommandTimerWait((HANDLE)pDevice, ASSOCIATE_TIMEOUT/2);
779 return;
781 pDevice->byLinkWaitCount = 0;
782 #if 0
783 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
784 // if(pDevice->bWPASuppWextEnabled == TRUE)
786 union iwreq_data wrqu;
787 memset(&wrqu, 0, sizeof (wrqu));
788 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
789 printk("wireless_send_event--->SIOCGIWAP(disassociated:ASSOCIATE_WAIT_timeout)\n");
790 wireless_send_event(pDevice->dev, SIOCGIWAP, &wrqu, NULL);
792 #endif
793 #endif
795 s_bCommandComplete(pDevice);
796 break;
798 case WLAN_CMD_AP_MODE_START :
799 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState == WLAN_CMD_AP_MODE_START\n");
801 if (pMgmt->eConfigMode == WMAC_CONFIG_AP) {
802 del_timer(&pMgmt->sTimerSecondCallback);
803 pMgmt->eCurrState = WMAC_STATE_IDLE;
804 pMgmt->eCurrMode = WMAC_MODE_STANDBY;
805 pDevice->bLinkPass = FALSE;
806 if (pDevice->bEnableHostWEP == TRUE)
807 BSSvClearNodeDBTable(pDevice, 1);
808 else
809 BSSvClearNodeDBTable(pDevice, 0);
810 pDevice->uAssocCount = 0;
811 pMgmt->eCurrState = WMAC_STATE_IDLE;
812 pDevice->bFixRate = FALSE;
814 vMgrCreateOwnIBSS((HANDLE)pDevice, &Status);
815 if (Status != CMD_STATUS_SUCCESS){
816 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " vMgrCreateOwnIBSS fail ! \n");
818 // alway turn off unicast bit
819 MACvRegBitsOff(pDevice->PortOffset, MAC_REG_RCR, RCR_UNICAST);
820 pDevice->byRxMode &= ~RCR_UNICAST;
821 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "wcmd: rx_mode = %x\n", pDevice->byRxMode );
822 BSSvAddMulticastNode(pDevice);
823 if (netif_queue_stopped(pDevice->dev)){
824 netif_wake_queue(pDevice->dev);
826 pDevice->bLinkPass = TRUE;
827 add_timer(&pMgmt->sTimerSecondCallback);
829 s_bCommandComplete(pDevice);
830 break;
832 case WLAN_CMD_TX_PSPACKET_START :
833 // DTIM Multicast tx
834 if (pMgmt->sNodeDBTable[0].bRxPSPoll) {
835 while ((skb = skb_dequeue(&pMgmt->sNodeDBTable[0].sTxPSQueue)) != NULL) {
836 if (skb_queue_empty(&pMgmt->sNodeDBTable[0].sTxPSQueue)) {
837 pMgmt->abyPSTxMap[0] &= ~byMask[0];
838 pDevice->bMoreData = FALSE;
840 else {
841 pDevice->bMoreData = TRUE;
843 if (!device_dma0_xmit(pDevice, skb, 0)) {
844 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Multicast ps tx fail \n");
846 pMgmt->sNodeDBTable[0].wEnQueueCnt--;
850 // PS nodes tx
851 for (ii = 1; ii < (MAX_NODE_NUM + 1); ii++) {
852 if (pMgmt->sNodeDBTable[ii].bActive &&
853 pMgmt->sNodeDBTable[ii].bRxPSPoll) {
854 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Index=%d Enqueu Cnt= %d\n",
855 ii, pMgmt->sNodeDBTable[ii].wEnQueueCnt);
856 while ((skb = skb_dequeue(&pMgmt->sNodeDBTable[ii].sTxPSQueue)) != NULL) {
857 if (skb_queue_empty(&pMgmt->sNodeDBTable[ii].sTxPSQueue)) {
858 // clear tx map
859 pMgmt->abyPSTxMap[pMgmt->sNodeDBTable[ii].wAID >> 3] &=
860 ~byMask[pMgmt->sNodeDBTable[ii].wAID & 7];
861 pDevice->bMoreData = FALSE;
863 else {
864 pDevice->bMoreData = TRUE;
866 if (!device_dma0_xmit(pDevice, skb, ii)) {
867 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "sta ps tx fail \n");
869 pMgmt->sNodeDBTable[ii].wEnQueueCnt--;
870 // check if sta ps enable, wait next pspoll
871 // if sta ps disable, send all pending buffers.
872 if (pMgmt->sNodeDBTable[ii].bPSEnable)
873 break;
875 if (skb_queue_empty(&pMgmt->sNodeDBTable[ii].sTxPSQueue)) {
876 // clear tx map
877 pMgmt->abyPSTxMap[pMgmt->sNodeDBTable[ii].wAID >> 3] &=
878 ~byMask[pMgmt->sNodeDBTable[ii].wAID & 7];
879 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Index=%d PS queue clear \n", ii);
881 pMgmt->sNodeDBTable[ii].bRxPSPoll = FALSE;
885 s_bCommandComplete(pDevice);
886 break;
889 case WLAN_CMD_RADIO_START :
890 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState == WLAN_CMD_RADIO_START\n");
891 if (pDevice->bRadioCmd == TRUE)
892 CARDbRadioPowerOn(pDevice);
893 else
894 CARDbRadioPowerOff(pDevice);
896 s_bCommandComplete(pDevice);
897 break;
900 case WLAN_CMD_CHECK_BBSENSITIVITY_CHANGE :
901 //DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState == WLAN_CMD_CHECK_BBSENSITIVITY_START\n");
902 // wait all TD complete
903 if (pDevice->iTDUsed[TYPE_AC0DMA] != 0){
904 vCommandTimerWait((HANDLE)pDevice, 10);
905 spin_unlock_irq(&pDevice->lock);
906 return;
908 if (pDevice->iTDUsed[TYPE_TXDMA0] != 0){
909 vCommandTimerWait((HANDLE)pDevice, 10);
910 spin_unlock_irq(&pDevice->lock);
911 return;
913 pDevice->byBBVGACurrent = pDevice->byBBVGANew;
914 BBvSetVGAGainOffset(pDevice, pDevice->byBBVGACurrent);
915 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"SetVGAGainOffset %02X\n", pDevice->byBBVGACurrent);
916 s_bCommandComplete(pDevice);
917 break;
919 default :
920 s_bCommandComplete(pDevice);
921 break;
923 } //switch
924 spin_unlock_irq(&pDevice->lock);
925 return;
930 static
931 BOOL
932 s_bCommandComplete (
933 PSDevice pDevice
936 PWLAN_IE_SSID pSSID;
937 BOOL bRadioCmd = FALSE;
938 //WORD wDeAuthenReason = 0;
939 BOOL bForceSCAN = TRUE;
940 PSMgmtObject pMgmt = pDevice->pMgmt;
943 pDevice->eCommandState = WLAN_CMD_IDLE;
944 if (pDevice->cbFreeCmdQueue == CMD_Q_SIZE) {
945 //Command Queue Empty
946 pDevice->bCmdRunning = FALSE;
947 return TRUE;
949 else {
950 pDevice->eCommand = pDevice->eCmdQueue[pDevice->uCmdDequeueIdx].eCmd;
951 pSSID = (PWLAN_IE_SSID)pDevice->eCmdQueue[pDevice->uCmdDequeueIdx].abyCmdDesireSSID;
952 bRadioCmd = pDevice->eCmdQueue[pDevice->uCmdDequeueIdx].bRadioCmd;
953 bForceSCAN = pDevice->eCmdQueue[pDevice->uCmdDequeueIdx].bForceSCAN;
954 ADD_ONE_WITH_WRAP_AROUND(pDevice->uCmdDequeueIdx, CMD_Q_SIZE);
955 pDevice->cbFreeCmdQueue++;
956 pDevice->bCmdRunning = TRUE;
957 switch ( pDevice->eCommand ) {
958 case WLAN_CMD_BSSID_SCAN:
959 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState= WLAN_CMD_BSSID_SCAN\n");
960 pDevice->eCommandState = WLAN_CMD_SCAN_START;
961 pMgmt->uScanChannel = 0;
962 if (pSSID->len != 0) {
963 MEMvCopy(pMgmt->abyScanSSID, pSSID, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
964 } else {
965 memset(pMgmt->abyScanSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
968 if ((bForceSCAN == FALSE) && (pDevice->bLinkPass == TRUE)) {
969 if ((pSSID->len == ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->len) &&
970 (MEMEqualMemory(pSSID->abySSID, ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->abySSID, pSSID->len))) {
971 pDevice->eCommandState = WLAN_CMD_IDLE;
975 break;
976 case WLAN_CMD_SSID:
977 pDevice->eCommandState = WLAN_CMD_SSID_START;
978 if (pSSID->len > WLAN_SSID_MAXLEN)
979 pSSID->len = WLAN_SSID_MAXLEN;
980 if (pSSID->len != 0)
981 MEMvCopy(pDevice->pMgmt->abyDesireSSID, pSSID, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
982 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState= WLAN_CMD_SSID_START\n");
983 break;
984 case WLAN_CMD_DISASSOCIATE:
985 pDevice->eCommandState = WLAN_CMD_DISASSOCIATE_START;
986 break;
987 case WLAN_CMD_RX_PSPOLL:
988 pDevice->eCommandState = WLAN_CMD_TX_PSPACKET_START;
989 break;
990 case WLAN_CMD_RUN_AP:
991 pDevice->eCommandState = WLAN_CMD_AP_MODE_START;
992 break;
993 case WLAN_CMD_RADIO:
994 pDevice->eCommandState = WLAN_CMD_RADIO_START;
995 pDevice->bRadioCmd = bRadioCmd;
996 break;
997 case WLAN_CMD_CHANGE_BBSENSITIVITY:
998 pDevice->eCommandState = WLAN_CMD_CHECK_BBSENSITIVITY_CHANGE;
999 break;
1001 default:
1002 break;
1006 vCommandTimerWait((HANDLE)pDevice, 0);
1009 return TRUE;
1014 BOOL bScheduleCommand (
1015 IN HANDLE hDeviceContext,
1016 IN CMD_CODE eCommand,
1017 IN PBYTE pbyItem0
1020 PSDevice pDevice = (PSDevice)hDeviceContext;
1023 if (pDevice->cbFreeCmdQueue == 0) {
1024 return (FALSE);
1026 pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].eCmd = eCommand;
1027 pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].bForceSCAN = TRUE;
1028 memset(pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].abyCmdDesireSSID, 0 , WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
1030 if (pbyItem0 != NULL) {
1031 switch (eCommand) {
1033 case WLAN_CMD_BSSID_SCAN:
1034 MEMvCopy(pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].abyCmdDesireSSID,
1035 pbyItem0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
1036 pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].bForceSCAN = FALSE;
1037 break;
1039 case WLAN_CMD_SSID:
1040 MEMvCopy(pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].abyCmdDesireSSID,
1041 pbyItem0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
1042 break;
1044 case WLAN_CMD_DISASSOCIATE:
1045 pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].bNeedRadioOFF = *((PBOOL)pbyItem0);
1046 break;
1048 case WLAN_CMD_DEAUTH:
1049 pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].wDeAuthenReason = *((PWORD)pbyItem0);
1050 break;
1053 case WLAN_CMD_RX_PSPOLL:
1054 break;
1056 case WLAN_CMD_RADIO:
1057 pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].bRadioCmd = *((PBOOL)pbyItem0);
1058 break;
1060 case WLAN_CMD_CHANGE_BBSENSITIVITY:
1061 pDevice->eCommandState = WLAN_CMD_CHECK_BBSENSITIVITY_CHANGE;
1062 break;
1064 default:
1065 break;
1069 ADD_ONE_WITH_WRAP_AROUND(pDevice->uCmdEnqueueIdx, CMD_Q_SIZE);
1070 pDevice->cbFreeCmdQueue--;
1072 if (pDevice->bCmdRunning == FALSE) {
1073 s_bCommandComplete(pDevice);
1075 else {
1077 return (TRUE);
1082 * Description:
1083 * Clear BSSID_SCAN cmd in CMD Queue
1085 * Parameters:
1086 * In:
1087 * hDeviceContext - Pointer to the adapter
1088 * eCommand - Command
1089 * Out:
1090 * none
1092 * Return Value: TRUE if success; otherwise FALSE
1095 BOOL bClearBSSID_SCAN (
1096 IN HANDLE hDeviceContext
1099 PSDevice pDevice = (PSDevice)hDeviceContext;
1100 UINT uCmdDequeueIdx = pDevice->uCmdDequeueIdx;
1101 UINT ii;
1103 if ((pDevice->cbFreeCmdQueue < CMD_Q_SIZE) && (uCmdDequeueIdx != pDevice->uCmdEnqueueIdx)) {
1104 for (ii = 0; ii < (CMD_Q_SIZE - pDevice->cbFreeCmdQueue); ii ++) {
1105 if (pDevice->eCmdQueue[uCmdDequeueIdx].eCmd == WLAN_CMD_BSSID_SCAN)
1106 pDevice->eCmdQueue[uCmdDequeueIdx].eCmd = WLAN_CMD_IDLE;
1107 ADD_ONE_WITH_WRAP_AROUND(uCmdDequeueIdx, CMD_Q_SIZE);
1108 if (uCmdDequeueIdx == pDevice->uCmdEnqueueIdx)
1109 break;
1112 return TRUE;
1115 //mike add:reset command timer
1116 VOID
1117 vResetCommandTimer(
1118 IN HANDLE hDeviceContext
1121 PSDevice pDevice = (PSDevice)hDeviceContext;
1123 //delete timer
1124 del_timer(&pDevice->sTimerCommand);
1125 //init timer
1126 init_timer(&pDevice->sTimerCommand);
1127 pDevice->sTimerCommand.data = (ULONG)pDevice;
1128 pDevice->sTimerCommand.function = (TimerFunction)vCommandTimer;
1129 pDevice->sTimerCommand.expires = RUN_AT(HZ);
1130 pDevice->cbFreeCmdQueue = CMD_Q_SIZE;
1131 pDevice->uCmdDequeueIdx = 0;
1132 pDevice->uCmdEnqueueIdx = 0;
1133 pDevice->eCommandState = WLAN_CMD_IDLE;
1134 pDevice->bCmdRunning = FALSE;
1135 pDevice->bCmdClear = FALSE;
1139 #ifdef TxInSleep
1140 VOID
1141 BSSvSecondTxData(
1142 IN HANDLE hDeviceContext
1145 PSDevice pDevice = (PSDevice)hDeviceContext;
1146 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1147 pDevice->nTxDataTimeCout++;
1149 if(pDevice->nTxDataTimeCout<4) //don't tx data if timer less than 40s
1151 // printk("mike:%s-->no data Tx not exceed the desired Time as %d\n",__FUNCTION__,
1152 // (int)pDevice->nTxDataTimeCout);
1153 pDevice->sTimerTxData.expires = RUN_AT(10*HZ); //10s callback
1154 add_timer(&pDevice->sTimerTxData);
1155 return;
1158 spin_lock_irq(&pDevice->lock);
1159 #if 1
1160 if(((pDevice->bLinkPass ==TRUE)&&(pMgmt->eAuthenMode < WMAC_AUTH_WPA)) || //open && sharekey linking
1161 (pDevice->fWPA_Authened == TRUE)) { //wpa linking
1162 #else
1163 if(pDevice->bLinkPass ==TRUE) {
1164 #endif
1166 // printk("mike:%s-->InSleep Tx Data Procedure\n",__FUNCTION__);
1167 pDevice->fTxDataInSleep = TRUE;
1168 PSbSendNullPacket(pDevice); //send null packet
1169 pDevice->fTxDataInSleep = FALSE;
1171 spin_unlock_irq(&pDevice->lock);
1173 pDevice->sTimerTxData.expires = RUN_AT(10*HZ); //10s callback
1174 add_timer(&pDevice->sTimerTxData);
1175 return;
1177 #endif