Merge branch 'drm-next' of git://people.freedesktop.org/~airlied/linux
[deliverable/linux.git] / drivers / staging / vt6656 / wcmd.c
CommitLineData
92b96797
FB
1/*
2 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
3 * All rights reserved.
4 *
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.
9 *
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.
14 *
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.
18 *
19 * File: wcmd.c
20 *
21 * Purpose: Handles the management command interface functions
22 *
23 * Author: Lyndon Chen
24 *
25 * Date: May 8, 2003
26 *
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 * s_bClearBSSID_SCAN- Clear BSSID_SCAN cmd in CMD Queue
36 *
37 * Revision History:
38 *
39 */
40
92b96797 41#include "tmacro.h"
92b96797 42#include "device.h"
92b96797 43#include "mac.h"
92b96797 44#include "card.h"
92b96797 45#include "80211hdr.h"
92b96797 46#include "wcmd.h"
92b96797 47#include "wmgr.h"
92b96797 48#include "power.h"
92b96797 49#include "wctl.h"
92b96797 50#include "baseband.h"
62c8526d 51#include "usbpipe.h"
92b96797 52#include "rxtx.h"
92b96797 53#include "rf.h"
92b96797 54#include "channel.h"
92b96797 55#include "iowpa.h"
92b96797 56
ebd381d9
NH
57static int msglevel = MSG_LEVEL_INFO;
58//static int msglevel = MSG_LEVEL_DEBUG;
92b96797 59
98583c09 60static void s_vProbeChannel(struct vnt_private *);
92b96797 61
98583c09
MP
62static struct vnt_tx_mgmt *s_MgrMakeProbeRequest(struct vnt_private *,
63 struct vnt_manager *pMgmt, u8 *pScanBSSID, PWLAN_IE_SSID pSSID,
64 PWLAN_IE_SUPP_RATES pCurrRates, PWLAN_IE_SUPP_RATES pCurrExtSuppRates);
92b96797 65
98583c09 66static int s_bCommandComplete(struct vnt_private *);
92b96797 67
98583c09 68static int s_bClearBSSID_SCAN(struct vnt_private *);
92b96797 69
92b96797
FB
70/*
71 * Description:
72 * Stop AdHoc beacon during scan process
73 *
74 * Parameters:
75 * In:
76 * pDevice - Pointer to the adapter
77 * Out:
78 * none
79 *
80 * Return Value: none
81 *
82 */
0cbd8d98 83
98583c09 84static void vAdHocBeaconStop(struct vnt_private *pDevice)
92b96797 85{
98583c09
MP
86 struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
87 int bStop;
92b96797 88
97d59f87
NH
89 /*
90 * temporarily stop Beacon packet for AdHoc Server
91 * if all of the following coditions are met:
92 * (1) STA is in AdHoc mode
93 * (2) VT3253 is programmed as automatic Beacon Transmitting
94 * (3) One of the following conditions is met
95 * (3.1) AdHoc channel is in B/G band and the
96 * current scan channel is in A band
97 * or
98 * (3.2) AdHoc channel is in A mode
99 */
100 bStop = false;
cab086d3
NH
101 if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) &&
102 (pMgmt->eCurrState >= WMAC_STATE_STARTED)) {
103 if ((pMgmt->uIBSSChannel <= CB_MAX_CHANNEL_24G) &&
104 (pMgmt->uScanChannel > CB_MAX_CHANNEL_24G)) {
105 bStop = true;
106 }
107 if (pMgmt->uIBSSChannel > CB_MAX_CHANNEL_24G)
108 bStop = true;
109 }
110
111 if (bStop) {
112 //PMESG(("STOP_BEACON: IBSSChannel = %u, ScanChannel = %u\n",
113 // pMgmt->uIBSSChannel, pMgmt->uScanChannel));
114 MACvRegBitsOff(pDevice, MAC_REG_TCR, TCR_AUTOBCNTX);
115 }
92b96797
FB
116
117} /* vAdHocBeaconStop */
118
92b96797
FB
119/*
120 * Description:
121 * Restart AdHoc beacon after scan process complete
122 *
123 * Parameters:
124 * In:
125 * pDevice - Pointer to the adapter
126 * Out:
127 * none
128 *
129 * Return Value: none
130 *
131 */
98583c09 132static void vAdHocBeaconRestart(struct vnt_private *pDevice)
92b96797 133{
98583c09 134 struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
92b96797
FB
135
136 /*
137 * Restart Beacon packet for AdHoc Server
138 * if all of the following coditions are met:
139 * (1) STA is in AdHoc mode
140 * (2) VT3253 is programmed as automatic Beacon Transmitting
141 */
cab086d3
NH
142 if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) &&
143 (pMgmt->eCurrState >= WMAC_STATE_STARTED)) {
144 //PMESG(("RESTART_BEACON\n"));
145 MACvRegBitsOn(pDevice, MAC_REG_TCR, TCR_AUTOBCNTX);
146 }
92b96797
FB
147
148}
149
92b96797
FB
150/*+
151 *
152 * Routine Description:
153 * Prepare and send probe request management frames.
154 *
155 *
156 * Return Value:
157 * none.
158 *
159-*/
160
98583c09 161static void s_vProbeChannel(struct vnt_private *pDevice)
92b96797 162{
98583c09
MP
163 struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
164 struct vnt_tx_mgmt *pTxPacket;
165 u8 abyCurrSuppRatesG[] = {WLAN_EID_SUPP_RATES,
166 8, 0x02, 0x04, 0x0B, 0x16, 0x24, 0x30, 0x48, 0x6C};
167 /* 1M, 2M, 5M, 11M, 18M, 24M, 36M, 54M*/
168 u8 abyCurrExtSuppRatesG[] = {WLAN_EID_EXTSUPP_RATES,
169 4, 0x0C, 0x12, 0x18, 0x60};
170 /* 6M, 9M, 12M, 48M*/
171 u8 abyCurrSuppRatesA[] = {WLAN_EID_SUPP_RATES,
172 8, 0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C};
173 u8 abyCurrSuppRatesB[] = {WLAN_EID_SUPP_RATES,
174 4, 0x02, 0x04, 0x0B, 0x16};
175 u8 *pbyRate;
176 int ii;
92b96797 177
566597a3
NH
178 if (pDevice->byBBType == BB_TYPE_11A)
179 pbyRate = &abyCurrSuppRatesA[0];
180 else if (pDevice->byBBType == BB_TYPE_11B)
181 pbyRate = &abyCurrSuppRatesB[0];
182 else
183 pbyRate = &abyCurrSuppRatesG[0];
184
97d59f87
NH
185 // build an assocreq frame and send it
186 pTxPacket = s_MgrMakeProbeRequest
187 (
188 pDevice,
189 pMgmt,
190 pMgmt->abyScanBSSID,
191 (PWLAN_IE_SSID)pMgmt->abyScanSSID,
192 (PWLAN_IE_SUPP_RATES)pbyRate,
193 (PWLAN_IE_SUPP_RATES)abyCurrExtSuppRatesG
194 );
92b96797 195
cab086d3
NH
196 if (pTxPacket != NULL) {
197 for (ii = 0; ii < 1; ii++) {
198 if (csMgmt_xmit(pDevice, pTxPacket) != CMD_STATUS_PENDING) {
199 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Probe request sending fail..\n");
200 } else {
201 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Probe request is sending..\n");
202 }
203 }
204 }
92b96797
FB
205
206}
207
92b96797
FB
208/*+
209 *
210 * Routine Description:
211 * Constructs an probe request frame
212 *
213 *
214 * Return Value:
a0a1f61a 215 * A ptr to Tx frame or NULL on allocation failure
92b96797
FB
216 *
217-*/
218
3b138851 219static struct vnt_tx_mgmt *s_MgrMakeProbeRequest(struct vnt_private *pDevice,
98583c09
MP
220 struct vnt_manager *pMgmt, u8 *pScanBSSID, PWLAN_IE_SSID pSSID,
221 PWLAN_IE_SUPP_RATES pCurrRates, PWLAN_IE_SUPP_RATES pCurrExtSuppRates)
92b96797 222{
98583c09
MP
223 struct vnt_tx_mgmt *pTxPacket = NULL;
224 WLAN_FR_PROBEREQ sFrame;
92b96797 225
98583c09
MP
226 pTxPacket = (struct vnt_tx_mgmt *)pMgmt->pbyMgmtPacketPool;
227 memset(pTxPacket, 0, sizeof(struct vnt_tx_mgmt)
228 + WLAN_PROBEREQ_FR_MAXLEN);
229 pTxPacket->p80211Header = (PUWLAN_80211HDR)((u8 *)pTxPacket
230 + sizeof(struct vnt_tx_mgmt));
97d59f87
NH
231 sFrame.pBuf = (u8 *)pTxPacket->p80211Header;
232 sFrame.len = WLAN_PROBEREQ_FR_MAXLEN;
233 vMgrEncodeProbeRequest(&sFrame);
234 sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16(
235 (
236 WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) |
237 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_PROBEREQ)
238 ));
239 memcpy(sFrame.pHdr->sA3.abyAddr1, pScanBSSID, WLAN_ADDR_LEN);
240 memcpy(sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN);
241 memcpy(sFrame.pHdr->sA3.abyAddr3, pScanBSSID, WLAN_BSSID_LEN);
242 // Copy the SSID, pSSID->len=0 indicate broadcast SSID
243 sFrame.pSSID = (PWLAN_IE_SSID)(sFrame.pBuf + sFrame.len);
244 sFrame.len += pSSID->len + WLAN_IEHDR_LEN;
245 memcpy(sFrame.pSSID, pSSID, pSSID->len + WLAN_IEHDR_LEN);
246 sFrame.pSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len);
247 sFrame.len += pCurrRates->len + WLAN_IEHDR_LEN;
248 memcpy(sFrame.pSuppRates, pCurrRates, pCurrRates->len + WLAN_IEHDR_LEN);
249 // Copy the extension rate set
cab086d3
NH
250 if (pDevice->byBBType == BB_TYPE_11G) {
251 sFrame.pExtSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len);
252 sFrame.len += pCurrExtSuppRates->len + WLAN_IEHDR_LEN;
253 memcpy(sFrame.pExtSuppRates, pCurrExtSuppRates, pCurrExtSuppRates->len + WLAN_IEHDR_LEN);
254 }
97d59f87
NH
255 pTxPacket->cbMPDULen = sFrame.len;
256 pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN;
92b96797 257
97d59f87 258 return pTxPacket;
92b96797
FB
259}
260
3b138851
VM
261static void
262vCommandTimerWait(struct vnt_private *pDevice, unsigned long MSecond)
92b96797 263{
94488a7e
MP
264 schedule_delayed_work(&pDevice->run_command_work,
265 msecs_to_jiffies(MSecond));
92b96797
FB
266}
267
94488a7e 268void vRunCommand(struct work_struct *work)
92b96797 269{
94488a7e
MP
270 struct vnt_private *pDevice =
271 container_of(work, struct vnt_private, run_command_work.work);
98583c09
MP
272 struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
273 PWLAN_IE_SSID pItemSSID;
274 PWLAN_IE_SSID pItemSSIDCurr;
275 CMD_STATUS Status;
276 struct sk_buff *skb;
0fdb56da 277 union iwreq_data wrqu;
98583c09
MP
278 int ii;
279 u8 byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80};
280 u8 byData;
97641ca2 281 unsigned long flags;
92b96797 282
17f3ced0
MP
283 if (pDevice->Flags & fMP_DISCONNECTED)
284 return;
285
cab086d3
NH
286 if (pDevice->bCmdRunning != true)
287 return;
92b96797 288
97d59f87 289 switch (pDevice->eCommandState) {
92b96797 290
97d59f87 291 case WLAN_CMD_SCAN_START:
92b96797
FB
292
293 pDevice->byReAssocCount = 0;
2ae2777c
MP
294 if (pDevice->bRadioOff == true)
295 break;
cab086d3 296
2ae2777c
MP
297 if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP)
298 break;
92b96797 299
97d59f87 300 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyScanSSID;
92b96797 301
cab086d3
NH
302 if (pMgmt->uScanChannel == 0)
303 pMgmt->uScanChannel = pDevice->byMinChannel;
304 if (pMgmt->uScanChannel > pDevice->byMaxChannel) {
305 pDevice->eCommandState = WLAN_CMD_SCAN_END;
2ae2777c 306 break;
cab086d3
NH
307 } else {
308 if (!ChannelValid(pDevice->byZoneType, pMgmt->uScanChannel)) {
309 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Invalid channel pMgmt->uScanChannel = %d\n", pMgmt->uScanChannel);
310 pMgmt->uScanChannel++;
2ae2777c 311 break;
cab086d3
NH
312 }
313 if (pMgmt->uScanChannel == pDevice->byMinChannel) {
314 // pMgmt->eScanType = WMAC_SCAN_ACTIVE; //mike mark
315 pMgmt->abyScanBSSID[0] = 0xFF;
316 pMgmt->abyScanBSSID[1] = 0xFF;
317 pMgmt->abyScanBSSID[2] = 0xFF;
318 pMgmt->abyScanBSSID[3] = 0xFF;
319 pMgmt->abyScanBSSID[4] = 0xFF;
320 pMgmt->abyScanBSSID[5] = 0xFF;
321 pItemSSID->byElementID = WLAN_EID_SSID;
322 // clear bssid list
323 /* BSSvClearBSSList((void *) pDevice, pDevice->bLinkPass); */
324 pMgmt->eScanState = WMAC_IS_SCANNING;
325 pDevice->byScanBBType = pDevice->byBBType; //lucas
326 pDevice->bStopDataPkt = true;
327 // Turn off RCR_BSSID filter every time
328 MACvRegBitsOff(pDevice, MAC_REG_RCR, RCR_BSSID);
329 pDevice->byRxMode &= ~RCR_BSSID;
330 }
331 //lucas
332 vAdHocBeaconStop(pDevice);
333 if ((pDevice->byBBType != BB_TYPE_11A) &&
334 (pMgmt->uScanChannel > CB_MAX_CHANNEL_24G)) {
335 pDevice->byBBType = BB_TYPE_11A;
336 CARDvSetBSSMode(pDevice);
337 } else if ((pDevice->byBBType == BB_TYPE_11A) &&
338 (pMgmt->uScanChannel <= CB_MAX_CHANNEL_24G)) {
339 pDevice->byBBType = BB_TYPE_11G;
340 CARDvSetBSSMode(pDevice);
341 }
342 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Scanning.... channel: [%d]\n", pMgmt->uScanChannel);
343 // Set channel
344 CARDbSetMediaChannel(pDevice, pMgmt->uScanChannel);
345 // Set Baseband to be more sensitive.
346
9cade5ac
MP
347 BBvSetShortSlotTime(pDevice);
348 BBvSetVGAGainOffset(pDevice, pDevice->abyBBVGA[0]);
349 BBvUpdatePreEDThreshold(pDevice, true);
350
257f6580 351 pMgmt->uScanChannel++;
cab086d3
NH
352
353 while (!ChannelValid(pDevice->byZoneType, pMgmt->uScanChannel) &&
354 pMgmt->uScanChannel <= pDevice->byMaxChannel){
355 pMgmt->uScanChannel++;
356 }
357
358 if (pMgmt->uScanChannel > pDevice->byMaxChannel) {
359 // Set Baseband to be not sensitive and rescan
360 pDevice->eCommandState = WLAN_CMD_SCAN_END;
361 }
362 if ((pMgmt->b11hEnable == false) ||
363 (pMgmt->uScanChannel < CB_MAX_CHANNEL_24G)) {
364 s_vProbeChannel(pDevice);
cab086d3
NH
365 vCommandTimerWait((void *) pDevice, 100);
366 return;
367 } else {
cab086d3
NH
368 vCommandTimerWait((void *) pDevice, WCMD_PASSIVE_SCAN_TIME);
369 return;
370 }
371 }
92b96797 372
97d59f87 373 break;
92b96797 374
97d59f87 375 case WLAN_CMD_SCAN_END:
92b96797 376
97d59f87 377 // Set Baseband's sensitivity back.
cab086d3
NH
378 if (pDevice->byBBType != pDevice->byScanBBType) {
379 pDevice->byBBType = pDevice->byScanBBType;
380 CARDvSetBSSMode(pDevice);
381 }
92b96797 382
9cade5ac
MP
383 BBvSetShortSlotTime(pDevice);
384 BBvSetVGAGainOffset(pDevice, pDevice->byBBVGACurrent);
385 BBvUpdatePreEDThreshold(pDevice, false);
92b96797 386
97d59f87
NH
387 // Set channel back
388 vAdHocBeaconRestart(pDevice);
389 // Set channel back
390 CARDbSetMediaChannel(pDevice, pMgmt->uCurrChannel);
391 // Set Filter
cab086d3
NH
392 if (pMgmt->bCurrBSSIDFilterOn) {
393 MACvRegBitsOn(pDevice, MAC_REG_RCR, RCR_BSSID);
394 pDevice->byRxMode |= RCR_BSSID;
395 }
97d59f87 396 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Scanning, set back to channel: [%d]\n", pMgmt->uCurrChannel);
257f6580 397 pMgmt->uScanChannel = 0;
97d59f87
NH
398 pMgmt->eScanState = WMAC_NO_SCANNING;
399 pDevice->bStopDataPkt = false;
465711b3 400
0fdb56da
MP
401 /*send scan event to wpa_Supplicant*/
402 PRINT_K("wireless_send_event--->SIOCGIWSCAN(scan done)\n");
403 memset(&wrqu, 0, sizeof(wrqu));
404 wireless_send_event(pDevice->dev, SIOCGIWSCAN, &wrqu, NULL);
405
97d59f87 406 break;
92b96797 407
97d59f87 408 case WLAN_CMD_DISASSOCIATE_START:
92b96797 409 pDevice->byReAssocCount = 0;
cab086d3
NH
410 if ((pMgmt->eCurrMode == WMAC_MODE_ESS_STA) &&
411 (pMgmt->eCurrState != WMAC_STATE_ASSOC)) {
2ae2777c 412 break;
cab086d3
NH
413 } else {
414 pDevice->bwextstep0 = false;
415 pDevice->bwextstep1 = false;
416 pDevice->bwextstep2 = false;
417 pDevice->bwextstep3 = false;
418 pDevice->bWPASuppWextEnabled = false;
419 pDevice->fWPA_Authened = false;
420
421 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Send Disassociation Packet..\n");
422 // reason = 8 : disassoc because sta has left
423 vMgrDisassocBeginSta((void *) pDevice,
424 pMgmt,
425 pMgmt->abyCurrBSSID,
426 (8),
427 &Status);
428 pDevice->bLinkPass = false;
96f6975b
MP
429
430 vnt_mac_set_led(pDevice, LEDSTS_STS, LEDSTS_SLOW);
431
cab086d3
NH
432 // unlock command busy
433 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
434 pItemSSID->len = 0;
435 memset(pItemSSID->abySSID, 0, WLAN_SSID_MAXLEN);
436 pMgmt->eCurrState = WMAC_STATE_IDLE;
437 pMgmt->sNodeDBTable[0].bActive = false;
438// pDevice->bBeaconBufReady = false;
439 }
97d59f87
NH
440 netif_stop_queue(pDevice->dev);
441 if (pDevice->bNeedRadioOFF == true)
442 CARDbRadioPowerOff(pDevice);
2ae2777c 443
97d59f87 444 break;
92b96797 445
97d59f87 446 case WLAN_CMD_SSID_START:
92b96797
FB
447
448 pDevice->byReAssocCount = 0;
2ae2777c
MP
449 if (pDevice->bRadioOff == true)
450 break;
92b96797 451
97d59f87
NH
452 memcpy(pMgmt->abyAdHocSSID, pMgmt->abyDesireSSID,
453 ((PWLAN_IE_SSID)pMgmt->abyDesireSSID)->len + WLAN_IEHDR_LEN);
5926b9ae 454
97d59f87
NH
455 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID;
456 pItemSSIDCurr = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
457 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" cmd: desire ssid = %s\n", pItemSSID->abySSID);
458 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" cmd: curr ssid = %s\n", pItemSSIDCurr->abySSID);
92b96797 459
cab086d3
NH
460 if (pMgmt->eCurrState == WMAC_STATE_ASSOC) {
461 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" Cmd pMgmt->eCurrState == WMAC_STATE_ASSOC\n");
462 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pItemSSID->len =%d\n", pItemSSID->len);
463 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pItemSSIDCurr->len = %d\n", pItemSSIDCurr->len);
464 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" desire ssid = %s\n", pItemSSID->abySSID);
465 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" curr ssid = %s\n", pItemSSIDCurr->abySSID);
466 }
467
468 if ((pMgmt->eCurrState == WMAC_STATE_ASSOC) ||
469 ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) && (pMgmt->eCurrState == WMAC_STATE_JOINTED))) {
470 if (pItemSSID->len == pItemSSIDCurr->len) {
2ae2777c
MP
471 if (!memcmp(pItemSSID->abySSID,
472 pItemSSIDCurr->abySSID, pItemSSID->len))
473 break;
cab086d3
NH
474 }
475 netif_stop_queue(pDevice->dev);
476 pDevice->bLinkPass = false;
96f6975b
MP
477
478 vnt_mac_set_led(pDevice, LEDSTS_STS, LEDSTS_SLOW);
cab086d3 479 }
97d59f87
NH
480 // set initial state
481 pMgmt->eCurrState = WMAC_STATE_IDLE;
482 pMgmt->eCurrMode = WMAC_MODE_STANDBY;
483 PSvDisablePowerSaving((void *) pDevice);
484 BSSvClearNodeDBTable(pDevice, 0);
485 vMgrJoinBSSBegin((void *) pDevice, &Status);
486 // if Infra mode
cab086d3
NH
487 if ((pMgmt->eCurrMode == WMAC_MODE_ESS_STA) && (pMgmt->eCurrState == WMAC_STATE_JOINTED)) {
488 // Call mgr to begin the deauthentication
489 // reason = (3) because sta has left ESS
490 if (pMgmt->eCurrState >= WMAC_STATE_AUTH) {
491 vMgrDeAuthenBeginSta((void *)pDevice,
492 pMgmt,
493 pMgmt->abyCurrBSSID,
494 (3),
495 &Status);
496 }
497 // Call mgr to begin the authentication
498 vMgrAuthenBeginSta((void *) pDevice, pMgmt, &Status);
499 if (Status == CMD_STATUS_SUCCESS) {
500 pDevice->byLinkWaitCount = 0;
501 pDevice->eCommandState = WLAN_AUTHENTICATE_WAIT;
502 vCommandTimerWait((void *) pDevice, AUTHENTICATE_TIMEOUT);
cab086d3
NH
503 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" Set eCommandState = WLAN_AUTHENTICATE_WAIT\n");
504 return;
505 }
506 }
507 // if Adhoc mode
508 else if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) {
509 if (pMgmt->eCurrState == WMAC_STATE_JOINTED) {
510 if (netif_queue_stopped(pDevice->dev))
511 netif_wake_queue(pDevice->dev);
512 pDevice->bLinkPass = true;
96f6975b
MP
513
514 vnt_mac_set_led(pDevice, LEDSTS_STS, LEDSTS_INTER);
515
cab086d3
NH
516 pMgmt->sNodeDBTable[0].bActive = true;
517 pMgmt->sNodeDBTable[0].uInActiveCount = 0;
518 } else {
519 // start own IBSS
520 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "CreateOwn IBSS by CurrMode = IBSS_STA\n");
521 vMgrCreateOwnIBSS((void *) pDevice, &Status);
522 if (Status != CMD_STATUS_SUCCESS) {
523 DBG_PRT(MSG_LEVEL_DEBUG,
524 KERN_INFO "WLAN_CMD_IBSS_CREATE fail!\n");
525 }
526 BSSvAddMulticastNode(pDevice);
527 }
528 s_bClearBSSID_SCAN(pDevice);
529 }
530 // if SSID not found
531 else if (pMgmt->eCurrMode == WMAC_MODE_STANDBY) {
532 if (pMgmt->eConfigMode == WMAC_CONFIG_IBSS_STA ||
533 pMgmt->eConfigMode == WMAC_CONFIG_AUTO) {
534 // start own IBSS
535 DBG_PRT(MSG_LEVEL_DEBUG,
536 KERN_INFO "CreateOwn IBSS by CurrMode = STANDBY\n");
537 vMgrCreateOwnIBSS((void *) pDevice, &Status);
538 if (Status != CMD_STATUS_SUCCESS) {
539 DBG_PRT(MSG_LEVEL_DEBUG,
540 KERN_INFO "WLAN_CMD_IBSS_CREATE fail!\n");
541 }
542 BSSvAddMulticastNode(pDevice);
543 s_bClearBSSID_SCAN(pDevice);
92b96797 544/*
cab086d3 545 pDevice->bLinkPass = true;
cab086d3
NH
546 if (netif_queue_stopped(pDevice->dev)){
547 netif_wake_queue(pDevice->dev);
548 }
549 s_bClearBSSID_SCAN(pDevice);
92b96797 550*/
cab086d3
NH
551 } else {
552 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disconnect SSID none\n");
553 // if(pDevice->bWPASuppWextEnabled == true)
554 {
555 union iwreq_data wrqu;
556 memset(&wrqu, 0, sizeof(wrqu));
557 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
558 PRINT_K("wireless_send_event--->SIOCGIWAP(disassociated:vMgrJoinBSSBegin Fail !!)\n");
559 wireless_send_event(pDevice->dev, SIOCGIWAP, &wrqu, NULL);
560 }
561 }
562 }
97d59f87 563 break;
92b96797 564
97d59f87
NH
565 case WLAN_AUTHENTICATE_WAIT:
566 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState == WLAN_AUTHENTICATE_WAIT\n");
cab086d3
NH
567 if (pMgmt->eCurrState == WMAC_STATE_AUTH) {
568 pDevice->byLinkWaitCount = 0;
569 // Call mgr to begin the association
570 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCurrState == WMAC_STATE_AUTH\n");
571 vMgrAssocBeginSta((void *) pDevice, pMgmt, &Status);
572 if (Status == CMD_STATUS_SUCCESS) {
573 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState = WLAN_ASSOCIATE_WAIT\n");
574 pDevice->byLinkWaitCount = 0;
575 pDevice->eCommandState = WLAN_ASSOCIATE_WAIT;
576 vCommandTimerWait((void *) pDevice, ASSOCIATE_TIMEOUT);
cab086d3
NH
577 return;
578 }
579 } else if (pMgmt->eCurrState < WMAC_STATE_AUTHPENDING) {
580 printk("WLAN_AUTHENTICATE_WAIT:Authen Fail???\n");
df6b8513
NH
581 } else if (pDevice->byLinkWaitCount <= 4) {
582 //mike add:wait another 2 sec if authenticated_frame delay!
cab086d3
NH
583 pDevice->byLinkWaitCount++;
584 printk("WLAN_AUTHENTICATE_WAIT:wait %d times!!\n", pDevice->byLinkWaitCount);
cab086d3
NH
585 vCommandTimerWait((void *) pDevice, AUTHENTICATE_TIMEOUT/2);
586 return;
587 }
97d59f87 588 pDevice->byLinkWaitCount = 0;
92b96797 589
97d59f87 590 break;
92b96797 591
97d59f87 592 case WLAN_ASSOCIATE_WAIT:
cab086d3
NH
593 if (pMgmt->eCurrState == WMAC_STATE_ASSOC) {
594 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCurrState == WMAC_STATE_ASSOC\n");
595 if (pDevice->ePSMode != WMAC_POWER_CAM) {
596 PSvEnablePowerSaving((void *) pDevice,
597 pMgmt->wListenInterval);
598 }
92b96797 599/*
cab086d3
NH
600 if (pMgmt->eAuthenMode >= WMAC_AUTH_WPA) {
601 KeybRemoveAllKey(pDevice, &(pDevice->sKey), pDevice->abyBSSID);
602 }
92b96797 603*/
cab086d3
NH
604 pDevice->byLinkWaitCount = 0;
605 pDevice->byReAssocCount = 0;
606 pDevice->bLinkPass = true;
96f6975b
MP
607
608 vnt_mac_set_led(pDevice, LEDSTS_STS, LEDSTS_INTER);
609
cab086d3
NH
610 s_bClearBSSID_SCAN(pDevice);
611
612 if (netif_queue_stopped(pDevice->dev))
613 netif_wake_queue(pDevice->dev);
614
615 } else if (pMgmt->eCurrState < WMAC_STATE_ASSOCPENDING) {
616 printk("WLAN_ASSOCIATE_WAIT:Association Fail???\n");
df6b8513
NH
617 } else if (pDevice->byLinkWaitCount <= 4) {
618 //mike add:wait another 2 sec if associated_frame delay!
cab086d3
NH
619 pDevice->byLinkWaitCount++;
620 printk("WLAN_ASSOCIATE_WAIT:wait %d times!!\n", pDevice->byLinkWaitCount);
cab086d3
NH
621 vCommandTimerWait((void *) pDevice, ASSOCIATE_TIMEOUT/2);
622 return;
623 }
92b96797 624
97d59f87 625 break;
92b96797 626
97d59f87 627 case WLAN_CMD_AP_MODE_START:
2eca4ead 628 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState == WLAN_CMD_AP_MODE_START\n");
92b96797 629
cab086d3
NH
630 if (pMgmt->eConfigMode == WMAC_CONFIG_AP) {
631 cancel_delayed_work_sync(&pDevice->second_callback_work);
632 pMgmt->eCurrState = WMAC_STATE_IDLE;
633 pMgmt->eCurrMode = WMAC_MODE_STANDBY;
634 pDevice->bLinkPass = false;
96f6975b
MP
635
636 vnt_mac_set_led(pDevice, LEDSTS_STS, LEDSTS_SLOW);
90f96acd
MP
637
638 BSSvClearNodeDBTable(pDevice, 0);
639
cab086d3
NH
640 pDevice->uAssocCount = 0;
641 pMgmt->eCurrState = WMAC_STATE_IDLE;
642 pDevice->bFixRate = false;
643
644 vMgrCreateOwnIBSS((void *) pDevice, &Status);
645 if (Status != CMD_STATUS_SUCCESS) {
646 DBG_PRT(MSG_LEVEL_DEBUG,
647 KERN_INFO "vMgrCreateOwnIBSS fail!\n");
648 }
649 // always turn off unicast bit
650 MACvRegBitsOff(pDevice, MAC_REG_RCR, RCR_UNICAST);
651 pDevice->byRxMode &= ~RCR_UNICAST;
652 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "wcmd: rx_mode = %x\n", pDevice->byRxMode);
653 BSSvAddMulticastNode(pDevice);
654 if (netif_queue_stopped(pDevice->dev))
655 netif_wake_queue(pDevice->dev);
656 pDevice->bLinkPass = true;
96f6975b
MP
657
658 vnt_mac_set_led(pDevice, LEDSTS_STS, LEDSTS_INTER);
659
cab086d3
NH
660 schedule_delayed_work(&pDevice->second_callback_work, HZ);
661 }
2eca4ead 662 break;
92b96797 663
97d59f87
NH
664 case WLAN_CMD_TX_PSPACKET_START:
665 // DTIM Multicast tx
cab086d3
NH
666 if (pMgmt->sNodeDBTable[0].bRxPSPoll) {
667 while ((skb = skb_dequeue(&pMgmt->sNodeDBTable[0].sTxPSQueue)) != NULL) {
668 if (skb_queue_empty(&pMgmt->sNodeDBTable[0].sTxPSQueue)) {
669 pMgmt->abyPSTxMap[0] &= ~byMask[0];
670 pDevice->bMoreData = false;
671 } else {
672 pDevice->bMoreData = true;
673 }
674
97641ca2
MP
675 spin_lock_irqsave(&pDevice->lock, flags);
676
05cc617b 677 if (nsDMA_tx_packet(pDevice, skb) != 0)
cab086d3
NH
678 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Multicast ps tx fail\n");
679
97641ca2
MP
680 spin_unlock_irqrestore(&pDevice->lock, flags);
681
cab086d3
NH
682 pMgmt->sNodeDBTable[0].wEnQueueCnt--;
683 }
684 }
92b96797 685
2eca4ead 686 // PS nodes tx
cab086d3
NH
687 for (ii = 1; ii < (MAX_NODE_NUM + 1); ii++) {
688 if (pMgmt->sNodeDBTable[ii].bActive &&
689 pMgmt->sNodeDBTable[ii].bRxPSPoll) {
690 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Index=%d Enqueu Cnt= %d\n",
691 ii, pMgmt->sNodeDBTable[ii].wEnQueueCnt);
692 while ((skb = skb_dequeue(&pMgmt->sNodeDBTable[ii].sTxPSQueue)) != NULL) {
693 if (skb_queue_empty(&pMgmt->sNodeDBTable[ii].sTxPSQueue)) {
694 // clear tx map
695 pMgmt->abyPSTxMap[pMgmt->sNodeDBTable[ii].wAID >> 3] &=
696 ~byMask[pMgmt->sNodeDBTable[ii].wAID & 7];
697 pDevice->bMoreData = false;
698 } else {
699 pDevice->bMoreData = true;
700 }
701
97641ca2
MP
702 spin_lock_irqsave(&pDevice->lock, flags);
703
05cc617b 704 if (nsDMA_tx_packet(pDevice, skb) != 0)
cab086d3
NH
705 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "sta ps tx fail\n");
706
97641ca2
MP
707 spin_unlock_irqrestore(&pDevice->lock, flags);
708
cab086d3
NH
709 pMgmt->sNodeDBTable[ii].wEnQueueCnt--;
710 // check if sta ps enable, wait next pspoll
711 // if sta ps disable, send all pending buffers.
712 if (pMgmt->sNodeDBTable[ii].bPSEnable)
713 break;
714 }
715 if (skb_queue_empty(&pMgmt->sNodeDBTable[ii].sTxPSQueue)) {
716 // clear tx map
717 pMgmt->abyPSTxMap[pMgmt->sNodeDBTable[ii].wAID >> 3] &=
718 ~byMask[pMgmt->sNodeDBTable[ii].wAID & 7];
719 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Index=%d PS queue clear\n", ii);
720 }
721 pMgmt->sNodeDBTable[ii].bRxPSPoll = false;
722 }
723 }
97d59f87 724 break;
92b96797 725
97d59f87 726 case WLAN_CMD_RADIO_START:
92b96797 727
97d59f87 728 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState == WLAN_CMD_RADIO_START\n");
cab086d3
NH
729// if (pDevice->bRadioCmd == true)
730// CARDbRadioPowerOn(pDevice);
731// else
732// CARDbRadioPowerOff(pDevice);
733 {
734 int ntStatus = STATUS_SUCCESS;
735 u8 byTmp;
736
441c21c3 737 ntStatus = vnt_control_in(pDevice,
cab086d3
NH
738 MESSAGE_TYPE_READ,
739 MAC_REG_GPIOCTL1,
740 MESSAGE_REQUEST_MACREG,
741 1,
742 &byTmp);
743
2ae2777c
MP
744 if (ntStatus != STATUS_SUCCESS)
745 break;
cab086d3
NH
746 if ((byTmp & GPIO3_DATA) == 0) {
747 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" WLAN_CMD_RADIO_START_OFF........................\n");
748 // Old commands are useless.
749 // empty command Q
750 pDevice->cbFreeCmdQueue = CMD_Q_SIZE;
751 pDevice->uCmdDequeueIdx = 0;
752 pDevice->uCmdEnqueueIdx = 0;
753 //0415pDevice->bCmdRunning = false;
754 pDevice->bCmdClear = true;
755 pDevice->bStopTx0Pkt = false;
756 pDevice->bStopDataPkt = true;
757
758 pDevice->byKeyIndex = 0;
759 pDevice->bTransmitKey = false;
d1d4120f 760
cab086d3 761 KeyvInitTable(pDevice, &pDevice->sKey);
d1d4120f 762
cab086d3
NH
763 pMgmt->byCSSPK = KEY_CTL_NONE;
764 pMgmt->byCSSGK = KEY_CTL_NONE;
765
766 if (pDevice->bLinkPass == true) {
767 // reason = 8 : disassoc because sta has left
768 vMgrDisassocBeginSta((void *) pDevice,
769 pMgmt,
770 pMgmt->abyCurrBSSID,
771 (8),
772 &Status);
773 pDevice->bLinkPass = false;
774 // unlock command busy
775 pMgmt->eCurrState = WMAC_STATE_IDLE;
776 pMgmt->sNodeDBTable[0].bActive = false;
777 // if(pDevice->bWPASuppWextEnabled == true)
778 {
779 union iwreq_data wrqu;
780 memset(&wrqu, 0, sizeof(wrqu));
781 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
782 PRINT_K("wireless_send_event--->SIOCGIWAP(disassociated)\n");
783 wireless_send_event(pDevice->dev, SIOCGIWAP, &wrqu, NULL);
784 }
785 }
786 pDevice->bwextstep0 = false;
787 pDevice->bwextstep1 = false;
788 pDevice->bwextstep2 = false;
789 pDevice->bwextstep3 = false;
790 pDevice->bWPASuppWextEnabled = false;
791 //clear current SSID
792 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
793 pItemSSID->len = 0;
794 memset(pItemSSID->abySSID, 0, WLAN_SSID_MAXLEN);
795 //clear desired SSID
796 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID;
797 pItemSSID->len = 0;
798 memset(pItemSSID->abySSID, 0, WLAN_SSID_MAXLEN);
799
800 netif_stop_queue(pDevice->dev);
801 CARDbRadioPowerOff(pDevice);
802 MACvRegBitsOn(pDevice, MAC_REG_GPIOCTL1, GPIO3_INTMD);
96f6975b
MP
803
804 vnt_mac_set_led(pDevice, LEDSTS_STS, LEDSTS_OFF);
805
cab086d3
NH
806 pDevice->bHWRadioOff = true;
807 } else {
808 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" WLAN_CMD_RADIO_START_ON........................\n");
809 pDevice->bHWRadioOff = false;
810 CARDbRadioPowerOn(pDevice);
811 MACvRegBitsOff(pDevice, MAC_REG_GPIOCTL1, GPIO3_INTMD);
96f6975b
MP
812
813 vnt_mac_set_led(pDevice, LEDSTS_STS, LEDSTS_ON);
cab086d3
NH
814 }
815 }
92b96797 816
97d59f87 817 break;
92b96797 818
97d59f87 819 case WLAN_CMD_CHANGE_BBSENSITIVITY_START:
92b96797 820
97d59f87
NH
821 pDevice->bStopDataPkt = true;
822 pDevice->byBBVGACurrent = pDevice->byBBVGANew;
823 BBvSetVGAGainOffset(pDevice, pDevice->byBBVGACurrent);
824 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Change sensitivity pDevice->byBBVGACurrent = %x\n", pDevice->byBBVGACurrent);
825 pDevice->bStopDataPkt = false;
97d59f87 826 break;
92b96797 827
97d59f87
NH
828 case WLAN_CMD_TBTT_WAKEUP_START:
829 PSbIsNextTBTTWakeUp(pDevice);
97d59f87 830 break;
92b96797 831
97d59f87
NH
832 case WLAN_CMD_BECON_SEND_START:
833 bMgrPrepareBeaconToSend(pDevice, pMgmt);
97d59f87 834 break;
92b96797 835
97d59f87 836 case WLAN_CMD_SETPOWER_START:
92b96797 837
4f5290ea
MP
838 vnt_rf_setpower(pDevice, pDevice->wCurrentRate,
839 pMgmt->uCurrChannel);
92b96797 840
97d59f87 841 break;
92b96797 842
97d59f87
NH
843 case WLAN_CMD_CHANGE_ANTENNA_START:
844 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Change from Antenna%d to", (int)pDevice->dwRxAntennaSel);
cab086d3
NH
845 if (pDevice->dwRxAntennaSel == 0) {
846 pDevice->dwRxAntennaSel = 1;
847 if (pDevice->bTxRxAntInv == true)
848 BBvSetAntennaMode(pDevice, ANT_RXA);
849 else
850 BBvSetAntennaMode(pDevice, ANT_RXB);
851 } else {
852 pDevice->dwRxAntennaSel = 0;
853 if (pDevice->bTxRxAntInv == true)
854 BBvSetAntennaMode(pDevice, ANT_RXB);
855 else
856 BBvSetAntennaMode(pDevice, ANT_RXA);
857 }
97d59f87 858 break;
92b96797 859
97d59f87
NH
860 case WLAN_CMD_REMOVE_ALLKEY_START:
861 KeybRemoveAllKey(pDevice, &(pDevice->sKey), pDevice->abyBSSID);
97d59f87 862 break;
92b96797 863
97d59f87 864 case WLAN_CMD_MAC_DISPOWERSAVING_START:
53742906 865 vnt_control_in_u8(pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_PSCTL, &byData);
cab086d3
NH
866 if ((byData & PSCTL_PS) != 0) {
867 // disable power saving hw function
1390b02a 868 vnt_control_out(pDevice,
cab086d3
NH
869 MESSAGE_TYPE_DISABLE_PS,
870 0,
871 0,
872 0,
873 NULL
874 );
875 }
97d59f87 876 break;
92b96797 877
97d59f87
NH
878 case WLAN_CMD_11H_CHSW_START:
879 CARDbSetMediaChannel(pDevice, pDevice->byNewChannel);
880 pDevice->bChannelSwitch = false;
881 pMgmt->uCurrChannel = pDevice->byNewChannel;
882 pDevice->bStopDataPkt = false;
97d59f87 883 break;
92b96797 884
edd20e96
MP
885 case WLAN_CMD_CONFIGURE_FILTER_START:
886 vnt_configure_filter(pDevice);
edd20e96 887 break;
97d59f87 888 default:
97d59f87
NH
889 break;
890 } //switch
92b96797 891
2ae2777c
MP
892 s_bCommandComplete(pDevice);
893
97d59f87 894 return;
92b96797
FB
895}
896
98583c09 897static int s_bCommandComplete(struct vnt_private *pDevice)
92b96797 898{
98583c09
MP
899 struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
900 PWLAN_IE_SSID pSSID;
e269fc2d 901 int bRadioCmd = false;
4e9b5e2b 902 int bForceSCAN = true;
92b96797 903
97d59f87 904 pDevice->eCommandState = WLAN_CMD_IDLE;
cab086d3
NH
905 if (pDevice->cbFreeCmdQueue == CMD_Q_SIZE) {
906 //Command Queue Empty
907 pDevice->bCmdRunning = false;
908 return true;
909 } else {
910 pDevice->eCommand = pDevice->eCmdQueue[pDevice->uCmdDequeueIdx].eCmd;
911 pSSID = (PWLAN_IE_SSID)pDevice->eCmdQueue[pDevice->uCmdDequeueIdx].abyCmdDesireSSID;
912 bRadioCmd = pDevice->eCmdQueue[pDevice->uCmdDequeueIdx].bRadioCmd;
913 bForceSCAN = pDevice->eCmdQueue[pDevice->uCmdDequeueIdx].bForceSCAN;
914 ADD_ONE_WITH_WRAP_AROUND(pDevice->uCmdDequeueIdx, CMD_Q_SIZE);
915 pDevice->cbFreeCmdQueue++;
916 pDevice->bCmdRunning = true;
917 switch (pDevice->eCommand) {
918 case WLAN_CMD_BSSID_SCAN:
919 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState= WLAN_CMD_BSSID_SCAN\n");
920 pDevice->eCommandState = WLAN_CMD_SCAN_START;
921 pMgmt->uScanChannel = 0;
922 if (pSSID->len != 0)
923 memcpy(pMgmt->abyScanSSID, pSSID, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
924 else
925 memset(pMgmt->abyScanSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
92b96797 926/*
cab086d3
NH
927 if ((bForceSCAN == false) && (pDevice->bLinkPass == true)) {
928 if ((pSSID->len == ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->len) &&
929 ( !memcmp(pSSID->abySSID, ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->abySSID, pSSID->len))) {
930 pDevice->eCommandState = WLAN_CMD_IDLE;
931 }
932 }
92b96797 933*/
cab086d3
NH
934 break;
935 case WLAN_CMD_SSID:
936 pDevice->eCommandState = WLAN_CMD_SSID_START;
937 if (pSSID->len > WLAN_SSID_MAXLEN)
938 pSSID->len = WLAN_SSID_MAXLEN;
939 if (pSSID->len != 0)
940 memcpy(pMgmt->abyDesireSSID, pSSID, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
941 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState= WLAN_CMD_SSID_START\n");
942 break;
943 case WLAN_CMD_DISASSOCIATE:
944 pDevice->eCommandState = WLAN_CMD_DISASSOCIATE_START;
945 break;
946 case WLAN_CMD_RX_PSPOLL:
947 pDevice->eCommandState = WLAN_CMD_TX_PSPACKET_START;
948 break;
949 case WLAN_CMD_RUN_AP:
950 pDevice->eCommandState = WLAN_CMD_AP_MODE_START;
951 break;
952 case WLAN_CMD_RADIO:
953 pDevice->eCommandState = WLAN_CMD_RADIO_START;
954 pDevice->bRadioCmd = bRadioCmd;
955 break;
956 case WLAN_CMD_CHANGE_BBSENSITIVITY:
957 pDevice->eCommandState = WLAN_CMD_CHANGE_BBSENSITIVITY_START;
958 break;
959
960 case WLAN_CMD_TBTT_WAKEUP:
961 pDevice->eCommandState = WLAN_CMD_TBTT_WAKEUP_START;
962 break;
963
964 case WLAN_CMD_BECON_SEND:
965 pDevice->eCommandState = WLAN_CMD_BECON_SEND_START;
966 break;
967
968 case WLAN_CMD_SETPOWER:
969 pDevice->eCommandState = WLAN_CMD_SETPOWER_START;
970 break;
971
972 case WLAN_CMD_CHANGE_ANTENNA:
973 pDevice->eCommandState = WLAN_CMD_CHANGE_ANTENNA_START;
974 break;
975
976 case WLAN_CMD_REMOVE_ALLKEY:
977 pDevice->eCommandState = WLAN_CMD_REMOVE_ALLKEY_START;
978 break;
979
980 case WLAN_CMD_MAC_DISPOWERSAVING:
981 pDevice->eCommandState = WLAN_CMD_MAC_DISPOWERSAVING_START;
982 break;
983
984 case WLAN_CMD_11H_CHSW:
985 pDevice->eCommandState = WLAN_CMD_11H_CHSW_START;
986 break;
987
edd20e96
MP
988 case WLAN_CMD_CONFIGURE_FILTER:
989 pDevice->eCommandState =
990 WLAN_CMD_CONFIGURE_FILTER_START;
991 break;
992
cab086d3
NH
993 default:
994 break;
995 }
996 vCommandTimerWait(pDevice, 0);
997 }
92b96797 998
97d59f87 999 return true;
92b96797
FB
1000}
1001
98583c09
MP
1002int bScheduleCommand(struct vnt_private *pDevice,
1003 CMD_CODE eCommand, u8 *pbyItem0)
92b96797 1004{
92b96797 1005
cab086d3 1006 if (pDevice->cbFreeCmdQueue == 0)
820c9b12 1007 return false;
cab086d3
NH
1008 pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].eCmd = eCommand;
1009 pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].bForceSCAN = true;
1010 memset(pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].abyCmdDesireSSID, 0 , WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
1011 if (pbyItem0 != NULL) {
1012 switch (eCommand) {
1013 case WLAN_CMD_BSSID_SCAN:
1014 pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].bForceSCAN = false;
1015 memcpy(pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].abyCmdDesireSSID,
1016 pbyItem0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
1017 break;
1018
1019 case WLAN_CMD_SSID:
1020 memcpy(pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].abyCmdDesireSSID,
1021 pbyItem0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
1022 break;
1023
1024 case WLAN_CMD_DISASSOCIATE:
1025 pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].bNeedRadioOFF = *((int *)pbyItem0);
1026 break;
92b96797 1027/*
cab086d3
NH
1028 case WLAN_CMD_DEAUTH:
1029 pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].wDeAuthenReason = *((u16 *)pbyItem0);
1030 break;
92b96797
FB
1031*/
1032
cab086d3
NH
1033 case WLAN_CMD_RADIO:
1034 pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].bRadioCmd = *((int *)pbyItem0);
1035 break;
92b96797 1036
cab086d3
NH
1037 default:
1038 break;
1039 }
1040 }
92b96797 1041
97d59f87
NH
1042 ADD_ONE_WITH_WRAP_AROUND(pDevice->uCmdEnqueueIdx, CMD_Q_SIZE);
1043 pDevice->cbFreeCmdQueue--;
92b96797 1044
cab086d3
NH
1045 if (pDevice->bCmdRunning == false)
1046 s_bCommandComplete(pDevice);
566597a3 1047
820c9b12 1048 return true;
92b96797
FB
1049
1050}
1051
1052/*
1053 * Description:
1054 * Clear BSSID_SCAN cmd in CMD Queue
1055 *
1056 * Parameters:
1057 * In:
1058 * hDeviceContext - Pointer to the adapter
1059 * eCommand - Command
1060 * Out:
1061 * none
1062 *
4e9b5e2b 1063 * Return Value: true if success; otherwise false
92b96797
FB
1064 *
1065 */
98583c09 1066static int s_bClearBSSID_SCAN(struct vnt_private *pDevice)
92b96797 1067{
98583c09
MP
1068 unsigned int uCmdDequeueIdx = pDevice->uCmdDequeueIdx;
1069 unsigned int ii;
92b96797 1070
cab086d3
NH
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;
1078 }
1079 }
97d59f87 1080 return true;
92b96797
FB
1081}
1082
92b96797 1083//mike add:reset command timer
98583c09 1084void vResetCommandTimer(struct vnt_private *pDevice)
92b96797 1085{
94488a7e 1086 cancel_delayed_work_sync(&pDevice->run_command_work);
92b96797 1087
3afe5f6c
DN
1088 pDevice->cbFreeCmdQueue = CMD_Q_SIZE;
1089 pDevice->uCmdDequeueIdx = 0;
1090 pDevice->uCmdEnqueueIdx = 0;
1091 pDevice->eCommandState = WLAN_CMD_IDLE;
e269fc2d
AM
1092 pDevice->bCmdRunning = false;
1093 pDevice->bCmdClear = false;
92b96797 1094}
This page took 0.565668 seconds and 5 git commands to generate.