ACPI: thinkpad-acpi: add development version tag
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / staging / vt6655 / wcmd.c
blobc9eabf9995dfd740f4ff6b221f4a247d6056f3ee
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.
19 * File: wcmd.c
21 * Purpose: Handles the management command interface functions
23 * Author: Lyndon Chen
25 * Date: May 8, 2003
27 * 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 * bClearBSSID_SCAN- Clear BSSID_SCAN cmd in CMD Queue
37 * Revision History:
41 #include "ttype.h"
42 #include "tmacro.h"
43 #include "device.h"
44 #include "mac.h"
45 #include "card.h"
46 #include "80211hdr.h"
47 #include "wcmd.h"
48 #include "wmgr.h"
49 #include "power.h"
50 #include "wctl.h"
51 #include "baseband.h"
52 #include "rxtx.h"
53 #include "rf.h"
54 #include "iowpa.h"
56 /*--------------------- Static Definitions -------------------------*/
61 /*--------------------- Static Classes ----------------------------*/
63 /*--------------------- Static Variables --------------------------*/
64 static int msglevel =MSG_LEVEL_INFO;
65 //static int msglevel =MSG_LEVEL_DEBUG;
66 /*--------------------- Static Functions --------------------------*/
68 static
69 VOID
70 s_vProbeChannel(
71 IN PSDevice pDevice
75 static
76 PSTxMgmtPacket
77 s_MgrMakeProbeRequest(
78 IN PSDevice pDevice,
79 IN PSMgmtObject pMgmt,
80 IN PBYTE pScanBSSID,
81 IN PWLAN_IE_SSID pSSID,
82 IN PWLAN_IE_SUPP_RATES pCurrRates,
83 IN PWLAN_IE_SUPP_RATES pCurrExtSuppRates
87 static
88 BOOL
89 s_bCommandComplete (
90 PSDevice pDevice
93 /*--------------------- Export Variables --------------------------*/
96 /*--------------------- Export Functions --------------------------*/
101 * Description:
102 * Stop AdHoc beacon during scan process
104 * Parameters:
105 * In:
106 * pDevice - Pointer to the adapter
107 * Out:
108 * none
110 * Return Value: none
113 static
114 void
115 vAdHocBeaconStop(PSDevice pDevice)
118 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
119 BOOL bStop;
122 * temporarily stop Beacon packet for AdHoc Server
123 * if all of the following coditions are met:
124 * (1) STA is in AdHoc mode
125 * (2) VT3253 is programmed as automatic Beacon Transmitting
126 * (3) One of the following conditions is met
127 * (3.1) AdHoc channel is in B/G band and the
128 * current scan channel is in A band
129 * or
130 * (3.2) AdHoc channel is in A mode
132 bStop = FALSE;
133 if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) &&
134 (pMgmt->eCurrState >= WMAC_STATE_STARTED))
136 if ((pMgmt->uIBSSChannel <= CB_MAX_CHANNEL_24G) &&
137 (pMgmt->uScanChannel > CB_MAX_CHANNEL_24G))
139 bStop = TRUE;
141 if (pMgmt->uIBSSChannel > CB_MAX_CHANNEL_24G)
143 bStop = TRUE;
147 if (bStop)
149 MACvRegBitsOff(pDevice->PortOffset, MAC_REG_TCR, TCR_AUTOBCNTX);
152 } /* vAdHocBeaconStop */
156 * Description:
157 * Restart AdHoc beacon after scan process complete
159 * Parameters:
160 * In:
161 * pDevice - Pointer to the adapter
162 * Out:
163 * none
165 * Return Value: none
168 static
169 void
170 vAdHocBeaconRestart(PSDevice pDevice)
172 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
175 * Restart Beacon packet for AdHoc Server
176 * if all of the following coditions are met:
177 * (1) STA is in AdHoc mode
178 * (2) VT3253 is programmed as automatic Beacon Transmitting
180 if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) &&
181 (pMgmt->eCurrState >= WMAC_STATE_STARTED))
183 MACvRegBitsOn(pDevice->PortOffset, MAC_REG_TCR, TCR_AUTOBCNTX);
195 * Routine Description:
196 * Prepare and send probe request management frames.
199 * Return Value:
200 * none.
204 static
205 VOID
206 s_vProbeChannel(
207 IN PSDevice pDevice
210 //1M, 2M, 5M, 11M, 18M, 24M, 36M, 54M
211 BYTE abyCurrSuppRatesG[] = {WLAN_EID_SUPP_RATES, 8, 0x02, 0x04, 0x0B, 0x16, 0x24, 0x30, 0x48, 0x6C};
212 BYTE abyCurrExtSuppRatesG[] = {WLAN_EID_EXTSUPP_RATES, 4, 0x0C, 0x12, 0x18, 0x60};
213 //6M, 9M, 12M, 48M
214 BYTE abyCurrSuppRatesA[] = {WLAN_EID_SUPP_RATES, 8, 0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C};
215 BYTE abyCurrSuppRatesB[] = {WLAN_EID_SUPP_RATES, 4, 0x02, 0x04, 0x0B, 0x16};
216 PBYTE pbyRate;
217 PSTxMgmtPacket pTxPacket;
218 PSMgmtObject pMgmt = pDevice->pMgmt;
219 UINT ii;
222 if (pDevice->eCurrentPHYType == PHY_TYPE_11A) {
223 pbyRate = &abyCurrSuppRatesA[0];
224 } else if (pDevice->eCurrentPHYType == PHY_TYPE_11B) {
225 pbyRate = &abyCurrSuppRatesB[0];
226 } else {
227 pbyRate = &abyCurrSuppRatesG[0];
229 // build an assocreq frame and send it
230 pTxPacket = s_MgrMakeProbeRequest
232 pDevice,
233 pMgmt,
234 pMgmt->abyScanBSSID,
235 (PWLAN_IE_SSID)pMgmt->abyScanSSID,
236 (PWLAN_IE_SUPP_RATES)pbyRate,
237 (PWLAN_IE_SUPP_RATES)abyCurrExtSuppRatesG
240 if (pTxPacket != NULL ){
241 for (ii = 0; ii < 2 ; ii++) {
242 if (csMgmt_xmit(pDevice, pTxPacket) != CMD_STATUS_PENDING) {
243 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Probe request sending fail.. \n");
245 else {
246 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Probe request is sending.. \n");
258 * Routine Description:
259 * Constructs an probe request frame
262 * Return Value:
263 * A ptr to Tx frame or NULL on allocation failue
268 PSTxMgmtPacket
269 s_MgrMakeProbeRequest(
270 IN PSDevice pDevice,
271 IN PSMgmtObject pMgmt,
272 IN PBYTE pScanBSSID,
273 IN PWLAN_IE_SSID pSSID,
274 IN PWLAN_IE_SUPP_RATES pCurrRates,
275 IN PWLAN_IE_SUPP_RATES pCurrExtSuppRates
279 PSTxMgmtPacket pTxPacket = NULL;
280 WLAN_FR_PROBEREQ sFrame;
283 pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool;
284 memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_PROBEREQ_FR_MAXLEN);
285 pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket));
286 sFrame.pBuf = (PBYTE)pTxPacket->p80211Header;
287 sFrame.len = WLAN_PROBEREQ_FR_MAXLEN;
288 vMgrEncodeProbeRequest(&sFrame);
289 sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16(
291 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) |
292 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_PROBEREQ)
294 memcpy( sFrame.pHdr->sA3.abyAddr1, pScanBSSID, WLAN_ADDR_LEN);
295 memcpy( sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN);
296 memcpy( sFrame.pHdr->sA3.abyAddr3, pScanBSSID, WLAN_BSSID_LEN);
297 // Copy the SSID, pSSID->len=0 indicate broadcast SSID
298 sFrame.pSSID = (PWLAN_IE_SSID)(sFrame.pBuf + sFrame.len);
299 sFrame.len += pSSID->len + WLAN_IEHDR_LEN;
300 memcpy(sFrame.pSSID, pSSID, pSSID->len + WLAN_IEHDR_LEN);
301 sFrame.pSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len);
302 sFrame.len += pCurrRates->len + WLAN_IEHDR_LEN;
303 memcpy(sFrame.pSuppRates, pCurrRates, pCurrRates->len + WLAN_IEHDR_LEN);
304 // Copy the extension rate set
305 if (pDevice->eCurrentPHYType == PHY_TYPE_11G) {
306 sFrame.pExtSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len);
307 sFrame.len += pCurrExtSuppRates->len + WLAN_IEHDR_LEN;
308 memcpy(sFrame.pExtSuppRates, pCurrExtSuppRates, pCurrExtSuppRates->len + WLAN_IEHDR_LEN);
310 pTxPacket->cbMPDULen = sFrame.len;
311 pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN;
313 return pTxPacket;
320 VOID
321 vCommandTimerWait(
322 IN HANDLE hDeviceContext,
323 IN UINT MSecond
326 PSDevice pDevice = (PSDevice)hDeviceContext;
328 init_timer(&pDevice->sTimerCommand);
329 pDevice->sTimerCommand.data = (ULONG)pDevice;
330 pDevice->sTimerCommand.function = (TimerFunction)vCommandTimer;
331 // RUN_AT :1 msec ~= (HZ/1024)
332 pDevice->sTimerCommand.expires = (UINT)RUN_AT((MSecond * HZ) >> 10);
333 add_timer(&pDevice->sTimerCommand);
334 return;
340 VOID
341 vCommandTimer (
342 IN HANDLE hDeviceContext
345 PSDevice pDevice = (PSDevice)hDeviceContext;
346 PSMgmtObject pMgmt = pDevice->pMgmt;
347 PWLAN_IE_SSID pItemSSID;
348 PWLAN_IE_SSID pItemSSIDCurr;
349 CMD_STATUS Status;
350 UINT ii;
351 BYTE byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80};
352 struct sk_buff *skb;
355 if (pDevice->dwDiagRefCount != 0)
356 return;
357 if (pDevice->bCmdRunning != TRUE)
358 return;
360 spin_lock_irq(&pDevice->lock);
362 switch ( pDevice->eCommandState ) {
364 case WLAN_CMD_SCAN_START:
366 pDevice->byReAssocCount = 0;
367 if (pDevice->bRadioOff == TRUE) {
368 s_bCommandComplete(pDevice);
369 spin_unlock_irq(&pDevice->lock);
370 return;
373 if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
374 s_bCommandComplete(pDevice);
375 CARDbSetBSSID(pMgmt->pAdapter, pMgmt->abyCurrBSSID, OP_MODE_AP);
376 spin_unlock_irq(&pDevice->lock);
377 return;
380 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState= WLAN_CMD_SCAN_START\n");
381 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyScanSSID;
382 // wait all Data TD complete
383 if (pDevice->iTDUsed[TYPE_AC0DMA] != 0){
384 spin_unlock_irq(&pDevice->lock);
385 vCommandTimerWait((HANDLE)pDevice, 10);
386 return;
389 if (pMgmt->uScanChannel == 0 ) {
390 pMgmt->uScanChannel = pDevice->byMinChannel;
391 // Set Baseband to be more sensitive.
394 if (pMgmt->uScanChannel > pDevice->byMaxChannel) {
395 pMgmt->eScanState = WMAC_NO_SCANNING;
397 // Set Baseband's sensitivity back.
398 // Set channel back
399 CARDbSetChannel(pMgmt->pAdapter, pMgmt->uCurrChannel);
400 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Scanning, set back to channel: [%d]\n", pMgmt->uCurrChannel);
401 if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) {
402 CARDbSetBSSID(pMgmt->pAdapter, pMgmt->abyCurrBSSID, OP_MODE_ADHOC);
403 } else {
404 CARDbSetBSSID(pMgmt->pAdapter, pMgmt->abyCurrBSSID, OP_MODE_INFRASTRUCTURE);
406 vAdHocBeaconRestart(pDevice);
407 s_bCommandComplete(pDevice);
409 } else {
410 //2008-8-4 <add> by chester
411 if (!ChannelValid(pDevice->byZoneType, pMgmt->uScanChannel)) {
412 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Invalid channel pMgmt->uScanChannel = %d \n",pMgmt->uScanChannel);
413 s_bCommandComplete(pDevice);
414 return;
416 //printk("chester-pMgmt->uScanChannel=%d,pDevice->byMaxChannel=%d\n",pMgmt->uScanChannel,pDevice->byMaxChannel);
417 if (pMgmt->uScanChannel == pDevice->byMinChannel) {
418 //pMgmt->eScanType = WMAC_SCAN_ACTIVE;
419 pMgmt->abyScanBSSID[0] = 0xFF;
420 pMgmt->abyScanBSSID[1] = 0xFF;
421 pMgmt->abyScanBSSID[2] = 0xFF;
422 pMgmt->abyScanBSSID[3] = 0xFF;
423 pMgmt->abyScanBSSID[4] = 0xFF;
424 pMgmt->abyScanBSSID[5] = 0xFF;
425 pItemSSID->byElementID = WLAN_EID_SSID;
426 // clear bssid list
427 // BSSvClearBSSList((HANDLE)pDevice, pDevice->bLinkPass);
428 pMgmt->eScanState = WMAC_IS_SCANNING;
432 vAdHocBeaconStop(pDevice);
434 if (CARDbSetChannel(pMgmt->pAdapter, pMgmt->uScanChannel) == TRUE) {
435 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"SCAN Channel: %d\n", pMgmt->uScanChannel);
436 } else {
437 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"SET SCAN Channel Fail: %d\n", pMgmt->uScanChannel);
439 CARDbSetBSSID(pMgmt->pAdapter, pMgmt->abyCurrBSSID, OP_MODE_UNKNOWN);
440 // printk("chester-mxch=%d\n",pDevice->byMaxChannel);
441 // printk("chester-ch=%d\n",pMgmt->uScanChannel);
442 pMgmt->uScanChannel++;
443 //2008-8-4 <modify> by chester
444 if (!ChannelValid(pDevice->byZoneType, pMgmt->uScanChannel) &&
445 pMgmt->uScanChannel <= pDevice->byMaxChannel ){
446 pMgmt->uScanChannel=pDevice->byMaxChannel+1;
447 pMgmt->eCommandState = WLAN_CMD_SCAN_END;
452 if ((pMgmt->b11hEnable == FALSE) ||
453 (pMgmt->uScanChannel < CB_MAX_CHANNEL_24G)) {
454 s_vProbeChannel(pDevice);
455 spin_unlock_irq(&pDevice->lock);
456 vCommandTimerWait((HANDLE)pDevice, WCMD_ACTIVE_SCAN_TIME);
457 return;
458 } else {
459 spin_unlock_irq(&pDevice->lock);
460 vCommandTimerWait((HANDLE)pDevice, WCMD_PASSIVE_SCAN_TIME);
461 return;
466 break;
468 case WLAN_CMD_SCAN_END:
470 // Set Baseband's sensitivity back.
471 // Set channel back
472 CARDbSetChannel(pMgmt->pAdapter, pMgmt->uCurrChannel);
473 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Scanning, set back to channel: [%d]\n", pMgmt->uCurrChannel);
474 if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) {
475 CARDbSetBSSID(pMgmt->pAdapter, pMgmt->abyCurrBSSID, OP_MODE_ADHOC);
476 } else {
477 CARDbSetBSSID(pMgmt->pAdapter, pMgmt->abyCurrBSSID, OP_MODE_INFRASTRUCTURE);
480 pMgmt->eScanState = WMAC_NO_SCANNING;
481 vAdHocBeaconRestart(pDevice);
482 //2008-0409-07, <Add> by Einsn Liu
483 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
484 if(pMgmt->eScanType == WMAC_SCAN_PASSIVE)
485 {//send scan event to wpa_Supplicant
486 union iwreq_data wrqu;
487 memset(&wrqu, 0, sizeof(wrqu));
488 wireless_send_event(pDevice->dev, SIOCGIWSCAN, &wrqu, NULL);
490 #endif
491 s_bCommandComplete(pDevice);
492 break;
494 case WLAN_CMD_DISASSOCIATE_START :
495 pDevice->byReAssocCount = 0;
496 if ((pMgmt->eCurrMode == WMAC_MODE_ESS_STA) &&
497 (pMgmt->eCurrState != WMAC_STATE_ASSOC)) {
498 s_bCommandComplete(pDevice);
499 spin_unlock_irq(&pDevice->lock);
500 return;
501 } else {
502 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Send Disassociation Packet..\n");
503 // reason = 8 : disassoc because sta has left
504 vMgrDisassocBeginSta((HANDLE)pDevice, pMgmt, pMgmt->abyCurrBSSID, (8), &Status);
505 pDevice->bLinkPass = FALSE;
506 // unlock command busy
507 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
508 pItemSSID->len = 0;
509 memset(pItemSSID->abySSID, 0, WLAN_SSID_MAXLEN);
510 pMgmt->eCurrState = WMAC_STATE_IDLE;
511 pMgmt->sNodeDBTable[0].bActive = FALSE;
512 // pDevice->bBeaconBufReady = FALSE;
514 netif_stop_queue(pDevice->dev);
515 pDevice->eCommandState = WLAN_DISASSOCIATE_WAIT;
516 // wait all Control TD complete
517 if (pDevice->iTDUsed[TYPE_TXDMA0] != 0){
518 vCommandTimerWait((HANDLE)pDevice, 10);
519 spin_unlock_irq(&pDevice->lock);
520 return;
522 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" CARDbRadioPowerOff\n");
523 //2008-09-02 <mark> by chester
524 // CARDbRadioPowerOff(pDevice);
525 s_bCommandComplete(pDevice);
526 break;
528 case WLAN_DISASSOCIATE_WAIT :
529 // wait all Control TD complete
530 if (pDevice->iTDUsed[TYPE_TXDMA0] != 0){
531 vCommandTimerWait((HANDLE)pDevice, 10);
532 spin_unlock_irq(&pDevice->lock);
533 return;
535 //2008-09-02 <mark> by chester
536 // CARDbRadioPowerOff(pDevice);
537 s_bCommandComplete(pDevice);
538 break;
540 case WLAN_CMD_SSID_START:
541 pDevice->byReAssocCount = 0;
542 if (pDevice->bRadioOff == TRUE) {
543 s_bCommandComplete(pDevice);
544 spin_unlock_irq(&pDevice->lock);
545 return;
547 //printk("chester-currmode=%d\n",pMgmt->eCurrMode);
548 printk("chester-abyDesireSSID=%s\n",((PWLAN_IE_SSID)pMgmt->abyDesireSSID)->abySSID);
549 //memcpy(pMgmt->abyAdHocSSID,pMgmt->abyDesireSSID,
550 //((PWLAN_IE_SSID)pMgmt->abyDesireSSID)->len + WLAN_IEHDR_LEN);
551 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID;
552 pItemSSIDCurr = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
553 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" cmd: desire ssid = %s\n", pItemSSID->abySSID);
554 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" cmd: curr ssid = %s\n", pItemSSIDCurr->abySSID);
556 if (pMgmt->eCurrState == WMAC_STATE_ASSOC) {
557 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" Cmd pMgmt->eCurrState == WMAC_STATE_ASSOC\n");
558 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pItemSSID->len =%d\n",pItemSSID->len);
559 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pItemSSIDCurr->len = %d\n",pItemSSIDCurr->len);
560 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" desire ssid = %s\n", pItemSSID->abySSID);
561 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" curr ssid = %s\n", pItemSSIDCurr->abySSID);
564 if ((pMgmt->eCurrState == WMAC_STATE_ASSOC) ||
565 ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA)&& (pMgmt->eCurrState == WMAC_STATE_JOINTED))) {
567 if (pItemSSID->len == pItemSSIDCurr->len) {
568 if (memcmp(pItemSSID->abySSID, pItemSSIDCurr->abySSID, pItemSSID->len) == 0) {
569 s_bCommandComplete(pDevice);
570 spin_unlock_irq(&pDevice->lock);
571 return;
575 netif_stop_queue(pDevice->dev);
576 pDevice->bLinkPass = FALSE;
578 // set initial state
579 pMgmt->eCurrState = WMAC_STATE_IDLE;
580 pMgmt->eCurrMode = WMAC_MODE_STANDBY;
581 PSvDisablePowerSaving((HANDLE)pDevice);
582 BSSvClearNodeDBTable(pDevice, 0);
584 vMgrJoinBSSBegin((HANDLE)pDevice, &Status);
585 // if Infra mode
586 if ((pMgmt->eCurrMode == WMAC_MODE_ESS_STA) && (pMgmt->eCurrState == WMAC_STATE_JOINTED)) {
588 // Call mgr to begin the deauthentication
589 // reason = (3) beacuse sta has left ESS
590 if (pMgmt->eCurrState>= WMAC_STATE_AUTH) {
591 vMgrDeAuthenBeginSta((HANDLE)pDevice, pMgmt, pMgmt->abyCurrBSSID, (3), &Status);
593 // Call mgr to begin the authentication
594 vMgrAuthenBeginSta((HANDLE)pDevice, pMgmt, &Status);
595 if (Status == CMD_STATUS_SUCCESS) {
596 pDevice->byLinkWaitCount = 0;
597 pDevice->eCommandState = WLAN_AUTHENTICATE_WAIT;
598 vCommandTimerWait((HANDLE)pDevice, AUTHENTICATE_TIMEOUT);
599 spin_unlock_irq(&pDevice->lock);
600 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" Set eCommandState = WLAN_AUTHENTICATE_WAIT\n");
601 return;
604 // if Adhoc mode
605 else if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) {
606 if (pMgmt->eCurrState == WMAC_STATE_JOINTED) {
607 if (netif_queue_stopped(pDevice->dev)){
608 netif_wake_queue(pDevice->dev);
610 pDevice->bLinkPass = TRUE;
612 pMgmt->sNodeDBTable[0].bActive = TRUE;
613 pMgmt->sNodeDBTable[0].uInActiveCount = 0;
614 bClearBSSID_SCAN(pDevice);
616 else {
617 // start own IBSS
618 vMgrCreateOwnIBSS((HANDLE)pDevice, &Status);
619 if (Status != CMD_STATUS_SUCCESS){
620 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " WLAN_CMD_IBSS_CREATE fail ! \n");
622 BSSvAddMulticastNode(pDevice);
625 // if SSID not found
626 else if (pMgmt->eCurrMode == WMAC_MODE_STANDBY) {
627 if (pMgmt->eConfigMode == WMAC_CONFIG_IBSS_STA ||
628 pMgmt->eConfigMode == WMAC_CONFIG_AUTO) {
629 // start own IBSS
630 vMgrCreateOwnIBSS((HANDLE)pDevice, &Status);
631 if (Status != CMD_STATUS_SUCCESS){
632 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" WLAN_CMD_IBSS_CREATE fail ! \n");
634 BSSvAddMulticastNode(pDevice);
635 if (netif_queue_stopped(pDevice->dev)){
636 netif_wake_queue(pDevice->dev);
638 pDevice->bLinkPass = TRUE;
640 else {
641 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disconnect SSID none\n");
642 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
643 // if(pDevice->bWPASuppWextEnabled == TRUE)
645 union iwreq_data wrqu;
646 memset(&wrqu, 0, sizeof (wrqu));
647 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
648 printk("wireless_send_event--->SIOCGIWAP(disassociated:vMgrJoinBSSBegin Fail !!)\n");
649 wireless_send_event(pDevice->dev, SIOCGIWAP, &wrqu, NULL);
651 #endif
655 s_bCommandComplete(pDevice);
656 break;
658 case WLAN_AUTHENTICATE_WAIT :
659 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState == WLAN_AUTHENTICATE_WAIT\n");
660 if (pMgmt->eCurrState == WMAC_STATE_AUTH) {
661 // Call mgr to begin the association
662 pDevice->byLinkWaitCount = 0;
663 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCurrState == WMAC_STATE_AUTH\n");
664 vMgrAssocBeginSta((HANDLE)pDevice, pMgmt, &Status);
665 if (Status == CMD_STATUS_SUCCESS) {
666 pDevice->byLinkWaitCount = 0;
667 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState = WLAN_ASSOCIATE_WAIT\n");
668 pDevice->eCommandState = WLAN_ASSOCIATE_WAIT;
669 vCommandTimerWait((HANDLE)pDevice, ASSOCIATE_TIMEOUT);
670 spin_unlock_irq(&pDevice->lock);
671 return;
675 else if(pMgmt->eCurrState < WMAC_STATE_AUTHPENDING) {
676 printk("WLAN_AUTHENTICATE_WAIT:Authen Fail???\n");
678 else if(pDevice->byLinkWaitCount <= 4){ //mike add:wait another 2 sec if authenticated_frame delay!
679 pDevice->byLinkWaitCount ++;
680 printk("WLAN_AUTHENTICATE_WAIT:wait %d times!!\n",pDevice->byLinkWaitCount);
681 spin_unlock_irq(&pDevice->lock);
682 vCommandTimerWait((HANDLE)pDevice, AUTHENTICATE_TIMEOUT/2);
683 return;
685 pDevice->byLinkWaitCount = 0;
686 #if 0
687 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
688 // if(pDevice->bWPASuppWextEnabled == TRUE)
690 union iwreq_data wrqu;
691 memset(&wrqu, 0, sizeof (wrqu));
692 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
693 printk("wireless_send_event--->SIOCGIWAP(disassociated:AUTHENTICATE_WAIT_timeout)\n");
694 wireless_send_event(pDevice->dev, SIOCGIWAP, &wrqu, NULL);
696 #endif
697 #endif
698 s_bCommandComplete(pDevice);
699 break;
701 case WLAN_ASSOCIATE_WAIT :
702 if (pMgmt->eCurrState == WMAC_STATE_ASSOC) {
703 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCurrState == WMAC_STATE_ASSOC\n");
704 if (pDevice->ePSMode != WMAC_POWER_CAM) {
705 PSvEnablePowerSaving((HANDLE)pDevice, pMgmt->wListenInterval);
707 if (pMgmt->eAuthenMode >= WMAC_AUTH_WPA) {
708 KeybRemoveAllKey(&(pDevice->sKey), pDevice->abyBSSID, pDevice->PortOffset);
710 pDevice->bLinkPass = TRUE;
711 pDevice->byLinkWaitCount = 0;
712 pDevice->byReAssocCount = 0;
713 bClearBSSID_SCAN(pDevice);
714 if (pDevice->byFOETuning) {
715 BBvSetFOE(pDevice->PortOffset);
716 PSbSendNullPacket(pDevice);
718 if (netif_queue_stopped(pDevice->dev)){
719 netif_wake_queue(pDevice->dev);
721 #ifdef TxInSleep
722 if(pDevice->IsTxDataTrigger != FALSE) { //TxDataTimer is not triggered at the first time
723 // printk("Re-initial TxDataTimer****\n");
724 del_timer(&pDevice->sTimerTxData);
725 init_timer(&pDevice->sTimerTxData);
726 pDevice->sTimerTxData.data = (ULONG)pDevice;
727 pDevice->sTimerTxData.function = (TimerFunction)BSSvSecondTxData;
728 pDevice->sTimerTxData.expires = RUN_AT(10*HZ); //10s callback
729 pDevice->fTxDataInSleep = FALSE;
730 pDevice->nTxDataTimeCout = 0;
732 else {
733 // printk("mike:-->First time triger TimerTxData InSleep\n");
735 pDevice->IsTxDataTrigger = TRUE;
736 add_timer(&pDevice->sTimerTxData);
737 #endif
739 else if(pMgmt->eCurrState < WMAC_STATE_ASSOCPENDING) {
740 printk("WLAN_ASSOCIATE_WAIT:Association Fail???\n");
742 else if(pDevice->byLinkWaitCount <= 4){ //mike add:wait another 2 sec if associated_frame delay!
743 pDevice->byLinkWaitCount ++;
744 printk("WLAN_ASSOCIATE_WAIT:wait %d times!!\n",pDevice->byLinkWaitCount);
745 spin_unlock_irq(&pDevice->lock);
746 vCommandTimerWait((HANDLE)pDevice, ASSOCIATE_TIMEOUT/2);
747 return;
749 pDevice->byLinkWaitCount = 0;
750 #if 0
751 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
752 // if(pDevice->bWPASuppWextEnabled == TRUE)
754 union iwreq_data wrqu;
755 memset(&wrqu, 0, sizeof (wrqu));
756 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
757 printk("wireless_send_event--->SIOCGIWAP(disassociated:ASSOCIATE_WAIT_timeout)\n");
758 wireless_send_event(pDevice->dev, SIOCGIWAP, &wrqu, NULL);
760 #endif
761 #endif
763 s_bCommandComplete(pDevice);
764 break;
766 case WLAN_CMD_AP_MODE_START :
767 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState == WLAN_CMD_AP_MODE_START\n");
769 if (pMgmt->eConfigMode == WMAC_CONFIG_AP) {
770 del_timer(&pMgmt->sTimerSecondCallback);
771 pMgmt->eCurrState = WMAC_STATE_IDLE;
772 pMgmt->eCurrMode = WMAC_MODE_STANDBY;
773 pDevice->bLinkPass = FALSE;
774 if (pDevice->bEnableHostWEP == TRUE)
775 BSSvClearNodeDBTable(pDevice, 1);
776 else
777 BSSvClearNodeDBTable(pDevice, 0);
778 pDevice->uAssocCount = 0;
779 pMgmt->eCurrState = WMAC_STATE_IDLE;
780 pDevice->bFixRate = FALSE;
782 vMgrCreateOwnIBSS((HANDLE)pDevice, &Status);
783 if (Status != CMD_STATUS_SUCCESS){
784 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " vMgrCreateOwnIBSS fail ! \n");
786 // alway turn off unicast bit
787 MACvRegBitsOff(pDevice->PortOffset, MAC_REG_RCR, RCR_UNICAST);
788 pDevice->byRxMode &= ~RCR_UNICAST;
789 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "wcmd: rx_mode = %x\n", pDevice->byRxMode );
790 BSSvAddMulticastNode(pDevice);
791 if (netif_queue_stopped(pDevice->dev)){
792 netif_wake_queue(pDevice->dev);
794 pDevice->bLinkPass = TRUE;
795 add_timer(&pMgmt->sTimerSecondCallback);
797 s_bCommandComplete(pDevice);
798 break;
800 case WLAN_CMD_TX_PSPACKET_START :
801 // DTIM Multicast tx
802 if (pMgmt->sNodeDBTable[0].bRxPSPoll) {
803 while ((skb = skb_dequeue(&pMgmt->sNodeDBTable[0].sTxPSQueue)) != NULL) {
804 if (skb_queue_empty(&pMgmt->sNodeDBTable[0].sTxPSQueue)) {
805 pMgmt->abyPSTxMap[0] &= ~byMask[0];
806 pDevice->bMoreData = FALSE;
808 else {
809 pDevice->bMoreData = TRUE;
811 if (!device_dma0_xmit(pDevice, skb, 0)) {
812 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Multicast ps tx fail \n");
814 pMgmt->sNodeDBTable[0].wEnQueueCnt--;
818 // PS nodes tx
819 for (ii = 1; ii < (MAX_NODE_NUM + 1); ii++) {
820 if (pMgmt->sNodeDBTable[ii].bActive &&
821 pMgmt->sNodeDBTable[ii].bRxPSPoll) {
822 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Index=%d Enqueu Cnt= %d\n",
823 ii, pMgmt->sNodeDBTable[ii].wEnQueueCnt);
824 while ((skb = skb_dequeue(&pMgmt->sNodeDBTable[ii].sTxPSQueue)) != NULL) {
825 if (skb_queue_empty(&pMgmt->sNodeDBTable[ii].sTxPSQueue)) {
826 // clear tx map
827 pMgmt->abyPSTxMap[pMgmt->sNodeDBTable[ii].wAID >> 3] &=
828 ~byMask[pMgmt->sNodeDBTable[ii].wAID & 7];
829 pDevice->bMoreData = FALSE;
831 else {
832 pDevice->bMoreData = TRUE;
834 if (!device_dma0_xmit(pDevice, skb, ii)) {
835 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "sta ps tx fail \n");
837 pMgmt->sNodeDBTable[ii].wEnQueueCnt--;
838 // check if sta ps enable, wait next pspoll
839 // if sta ps disable, send all pending buffers.
840 if (pMgmt->sNodeDBTable[ii].bPSEnable)
841 break;
843 if (skb_queue_empty(&pMgmt->sNodeDBTable[ii].sTxPSQueue)) {
844 // clear tx map
845 pMgmt->abyPSTxMap[pMgmt->sNodeDBTable[ii].wAID >> 3] &=
846 ~byMask[pMgmt->sNodeDBTable[ii].wAID & 7];
847 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Index=%d PS queue clear \n", ii);
849 pMgmt->sNodeDBTable[ii].bRxPSPoll = FALSE;
853 s_bCommandComplete(pDevice);
854 break;
857 case WLAN_CMD_RADIO_START :
858 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState == WLAN_CMD_RADIO_START\n");
859 if (pDevice->bRadioCmd == TRUE)
860 CARDbRadioPowerOn(pDevice);
861 else
862 CARDbRadioPowerOff(pDevice);
864 s_bCommandComplete(pDevice);
865 break;
868 case WLAN_CMD_CHECK_BBSENSITIVITY_CHANGE :
869 //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState == WLAN_CMD_CHECK_BBSENSITIVITY_START\n");
870 // wait all TD complete
871 if (pDevice->iTDUsed[TYPE_AC0DMA] != 0){
872 vCommandTimerWait((HANDLE)pDevice, 10);
873 spin_unlock_irq(&pDevice->lock);
874 return;
876 if (pDevice->iTDUsed[TYPE_TXDMA0] != 0){
877 vCommandTimerWait((HANDLE)pDevice, 10);
878 spin_unlock_irq(&pDevice->lock);
879 return;
881 pDevice->byBBVGACurrent = pDevice->byBBVGANew;
882 BBvSetVGAGainOffset(pDevice, pDevice->byBBVGACurrent);
883 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"SetVGAGainOffset %02X\n", pDevice->byBBVGACurrent);
884 s_bCommandComplete(pDevice);
885 break;
887 default :
888 s_bCommandComplete(pDevice);
889 break;
891 } //switch
892 spin_unlock_irq(&pDevice->lock);
893 return;
898 static
899 BOOL
900 s_bCommandComplete (
901 PSDevice pDevice
904 PWLAN_IE_SSID pSSID;
905 BOOL bRadioCmd = FALSE;
906 //WORD wDeAuthenReason = 0;
907 BOOL bForceSCAN = TRUE;
908 PSMgmtObject pMgmt = pDevice->pMgmt;
911 pDevice->eCommandState = WLAN_CMD_IDLE;
912 if (pDevice->cbFreeCmdQueue == CMD_Q_SIZE) {
913 //Command Queue Empty
914 pDevice->bCmdRunning = FALSE;
915 return TRUE;
917 else {
918 pDevice->eCommand = pDevice->eCmdQueue[pDevice->uCmdDequeueIdx].eCmd;
919 pSSID = (PWLAN_IE_SSID)pDevice->eCmdQueue[pDevice->uCmdDequeueIdx].abyCmdDesireSSID;
920 bRadioCmd = pDevice->eCmdQueue[pDevice->uCmdDequeueIdx].bRadioCmd;
921 bForceSCAN = pDevice->eCmdQueue[pDevice->uCmdDequeueIdx].bForceSCAN;
922 ADD_ONE_WITH_WRAP_AROUND(pDevice->uCmdDequeueIdx, CMD_Q_SIZE);
923 pDevice->cbFreeCmdQueue++;
924 pDevice->bCmdRunning = TRUE;
925 switch ( pDevice->eCommand ) {
926 case WLAN_CMD_BSSID_SCAN:
927 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState= WLAN_CMD_BSSID_SCAN\n");
928 pDevice->eCommandState = WLAN_CMD_SCAN_START;
929 pMgmt->uScanChannel = 0;
930 if (pSSID->len != 0) {
931 memcpy(pMgmt->abyScanSSID, pSSID, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
932 } else {
933 memset(pMgmt->abyScanSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
936 if ((bForceSCAN == FALSE) && (pDevice->bLinkPass == TRUE)) {
937 if ((pSSID->len == ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->len) &&
938 ( !memcmp(pSSID->abySSID, ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->abySSID, pSSID->len))) {
939 pDevice->eCommandState = WLAN_CMD_IDLE;
943 break;
944 case WLAN_CMD_SSID:
945 pDevice->eCommandState = WLAN_CMD_SSID_START;
946 if (pSSID->len > WLAN_SSID_MAXLEN)
947 pSSID->len = WLAN_SSID_MAXLEN;
948 if (pSSID->len != 0)
949 memcpy(pDevice->pMgmt->abyDesireSSID, pSSID, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
950 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState= WLAN_CMD_SSID_START\n");
951 break;
952 case WLAN_CMD_DISASSOCIATE:
953 pDevice->eCommandState = WLAN_CMD_DISASSOCIATE_START;
954 break;
955 case WLAN_CMD_RX_PSPOLL:
956 pDevice->eCommandState = WLAN_CMD_TX_PSPACKET_START;
957 break;
958 case WLAN_CMD_RUN_AP:
959 pDevice->eCommandState = WLAN_CMD_AP_MODE_START;
960 break;
961 case WLAN_CMD_RADIO:
962 pDevice->eCommandState = WLAN_CMD_RADIO_START;
963 pDevice->bRadioCmd = bRadioCmd;
964 break;
965 case WLAN_CMD_CHANGE_BBSENSITIVITY:
966 pDevice->eCommandState = WLAN_CMD_CHECK_BBSENSITIVITY_CHANGE;
967 break;
969 default:
970 break;
974 vCommandTimerWait((HANDLE)pDevice, 0);
977 return TRUE;
982 BOOL bScheduleCommand (
983 IN HANDLE hDeviceContext,
984 IN CMD_CODE eCommand,
985 IN PBYTE pbyItem0
988 PSDevice pDevice = (PSDevice)hDeviceContext;
991 if (pDevice->cbFreeCmdQueue == 0) {
992 return (FALSE);
994 pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].eCmd = eCommand;
995 pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].bForceSCAN = TRUE;
996 memset(pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].abyCmdDesireSSID, 0 , WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
998 if (pbyItem0 != NULL) {
999 switch (eCommand) {
1001 case WLAN_CMD_BSSID_SCAN:
1002 memcpy(pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].abyCmdDesireSSID,
1003 pbyItem0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
1004 pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].bForceSCAN = FALSE;
1005 break;
1007 case WLAN_CMD_SSID:
1008 memcpy(pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].abyCmdDesireSSID,
1009 pbyItem0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
1010 break;
1012 case WLAN_CMD_DISASSOCIATE:
1013 pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].bNeedRadioOFF = *((int *)pbyItem0);
1014 break;
1016 case WLAN_CMD_DEAUTH:
1017 pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].wDeAuthenReason = *((PWORD)pbyItem0);
1018 break;
1021 case WLAN_CMD_RX_PSPOLL:
1022 break;
1024 case WLAN_CMD_RADIO:
1025 pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].bRadioCmd = *((int *)pbyItem0);
1026 break;
1028 case WLAN_CMD_CHANGE_BBSENSITIVITY:
1029 pDevice->eCommandState = WLAN_CMD_CHECK_BBSENSITIVITY_CHANGE;
1030 break;
1032 default:
1033 break;
1037 ADD_ONE_WITH_WRAP_AROUND(pDevice->uCmdEnqueueIdx, CMD_Q_SIZE);
1038 pDevice->cbFreeCmdQueue--;
1040 if (pDevice->bCmdRunning == FALSE) {
1041 s_bCommandComplete(pDevice);
1043 else {
1045 return (TRUE);
1050 * Description:
1051 * Clear BSSID_SCAN cmd in CMD Queue
1053 * Parameters:
1054 * In:
1055 * hDeviceContext - Pointer to the adapter
1056 * eCommand - Command
1057 * Out:
1058 * none
1060 * Return Value: TRUE if success; otherwise FALSE
1063 BOOL bClearBSSID_SCAN (
1064 IN HANDLE hDeviceContext
1067 PSDevice pDevice = (PSDevice)hDeviceContext;
1068 UINT uCmdDequeueIdx = pDevice->uCmdDequeueIdx;
1069 UINT ii;
1071 if ((pDevice->cbFreeCmdQueue < CMD_Q_SIZE) && (uCmdDequeueIdx != pDevice->uCmdEnqueueIdx)) {
1072 for (ii = 0; ii < (CMD_Q_SIZE - pDevice->cbFreeCmdQueue); ii ++) {
1073 if (pDevice->eCmdQueue[uCmdDequeueIdx].eCmd == WLAN_CMD_BSSID_SCAN)
1074 pDevice->eCmdQueue[uCmdDequeueIdx].eCmd = WLAN_CMD_IDLE;
1075 ADD_ONE_WITH_WRAP_AROUND(uCmdDequeueIdx, CMD_Q_SIZE);
1076 if (uCmdDequeueIdx == pDevice->uCmdEnqueueIdx)
1077 break;
1080 return TRUE;
1083 //mike add:reset command timer
1084 VOID
1085 vResetCommandTimer(
1086 IN HANDLE hDeviceContext
1089 PSDevice pDevice = (PSDevice)hDeviceContext;
1091 //delete timer
1092 del_timer(&pDevice->sTimerCommand);
1093 //init timer
1094 init_timer(&pDevice->sTimerCommand);
1095 pDevice->sTimerCommand.data = (ULONG)pDevice;
1096 pDevice->sTimerCommand.function = (TimerFunction)vCommandTimer;
1097 pDevice->sTimerCommand.expires = RUN_AT(HZ);
1098 pDevice->cbFreeCmdQueue = CMD_Q_SIZE;
1099 pDevice->uCmdDequeueIdx = 0;
1100 pDevice->uCmdEnqueueIdx = 0;
1101 pDevice->eCommandState = WLAN_CMD_IDLE;
1102 pDevice->bCmdRunning = FALSE;
1103 pDevice->bCmdClear = FALSE;
1107 #ifdef TxInSleep
1108 VOID
1109 BSSvSecondTxData(
1110 IN HANDLE hDeviceContext
1113 PSDevice pDevice = (PSDevice)hDeviceContext;
1114 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1115 pDevice->nTxDataTimeCout++;
1117 if(pDevice->nTxDataTimeCout<4) //don't tx data if timer less than 40s
1119 // printk("mike:%s-->no data Tx not exceed the desired Time as %d\n",__FUNCTION__,
1120 // (int)pDevice->nTxDataTimeCout);
1121 pDevice->sTimerTxData.expires = RUN_AT(10*HZ); //10s callback
1122 add_timer(&pDevice->sTimerTxData);
1123 return;
1126 spin_lock_irq(&pDevice->lock);
1127 #if 1
1128 if(((pDevice->bLinkPass ==TRUE)&&(pMgmt->eAuthenMode < WMAC_AUTH_WPA)) || //open && sharekey linking
1129 (pDevice->fWPA_Authened == TRUE)) { //wpa linking
1130 #else
1131 if(pDevice->bLinkPass ==TRUE) {
1132 #endif
1134 // printk("mike:%s-->InSleep Tx Data Procedure\n",__FUNCTION__);
1135 pDevice->fTxDataInSleep = TRUE;
1136 PSbSendNullPacket(pDevice); //send null packet
1137 pDevice->fTxDataInSleep = FALSE;
1139 spin_unlock_irq(&pDevice->lock);
1141 pDevice->sTimerTxData.expires = RUN_AT(10*HZ); //10s callback
1142 add_timer(&pDevice->sTimerTxData);
1143 return;
1145 #endif