]> git.ipfire.org Git - ipfire-2.x.git/blame - src/patches/suse-2.6.27.39/patches.drivers/staging-rt2860-sync-driver-up-with-2.6.30-version.patch
Fix oinkmaster patch.
[ipfire-2.x.git] / src / patches / suse-2.6.27.39 / patches.drivers / staging-rt2860-sync-driver-up-with-2.6.30-version.patch
CommitLineData
2cb7cef9
BS
1From foo@baz Mon Jul 27 15:37:03 PDT 2009
2Date: Mon, 27 Jul 2009 15:37:03 -0700
3From: Greg Kroah-Hartman <gregkh@suse.de>
4Subject: Staging: rt2860: sync driver up with 2.6.30 version
5References: bnc#512070
6Patch-mainline: 2.6.30
7
8This is needed to get the driver to work properly with some hardware types.
9
10The 2.6.30 version was backported, minus the netdev_ops changes, which
11will not work in the 2.6.27 kernel version.
12
13Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14
15---
16 drivers/staging/rt2860/2860_main_dev.c | 64 +----
17 drivers/staging/rt2860/Makefile | 1
18 drivers/staging/rt2860/TODO | 4
19 drivers/staging/rt2860/common/ba_action.c | 18 -
20 drivers/staging/rt2860/common/cmm_data.c | 32 --
21 drivers/staging/rt2860/common/cmm_data_2860.c | 150 +++++++++----
22 drivers/staging/rt2860/common/cmm_info.c | 8
23 drivers/staging/rt2860/common/cmm_sync.c | 2
24 drivers/staging/rt2860/common/cmm_wpa.c | 40 +++
25 drivers/staging/rt2860/common/dfs.c | 4
26 drivers/staging/rt2860/common/mlme.c | 289 ++++++++++++++++++++------
27 drivers/staging/rt2860/common/rtmp_init.c | 196 ++++++++++++-----
28 drivers/staging/rt2860/common/spectrum.c | 44 +--
29 drivers/staging/rt2860/config.mk | 4
30 drivers/staging/rt2860/oid.h | 2
31 drivers/staging/rt2860/rt2860.h | 26 --
32 drivers/staging/rt2860/rt28xx.h | 4
33 drivers/staging/rt2860/rt_ate.c | 50 +---
34 drivers/staging/rt2860/rt_ate.h | 6
35 drivers/staging/rt2860/rt_config.h | 2
36 drivers/staging/rt2860/rt_linux.c | 45 ----
37 drivers/staging/rt2860/rt_linux.h | 51 +---
38 drivers/staging/rt2860/rt_main_dev.c | 183 ++--------------
39 drivers/staging/rt2860/rt_profile.c | 29 +-
40 drivers/staging/rt2860/rtmp.h | 61 ++---
41 drivers/staging/rt2860/rtmp_def.h | 31 +-
42 drivers/staging/rt2860/sta/assoc.c | 23 --
43 drivers/staging/rt2860/sta/connect.c | 45 ++--
44 drivers/staging/rt2860/sta/dls.c | 4
45 drivers/staging/rt2860/sta/rtmp_data.c | 29 +-
46 drivers/staging/rt2860/sta/sync.c | 18 -
47 drivers/staging/rt2860/sta/wpa.c | 10
48 drivers/staging/rt2860/sta_ioctl.c | 278 ++++++++++++++-----------
49 drivers/staging/rt2860/wpa.h | 1
50 34 files changed, 935 insertions(+), 819 deletions(-)
51
52--- a/drivers/staging/rt2860/2860_main_dev.c
53+++ b/drivers/staging/rt2860/2860_main_dev.c
54@@ -90,12 +90,10 @@ void init_thread_task(PRTMP_ADAPTER pAd)
55 static void __exit rt2860_cleanup_module(void);
56 static int __init rt2860_init_module(void);
57
58-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
59 #ifdef CONFIG_PM
60 static int rt2860_suspend(struct pci_dev *pci_dev, pm_message_t state);
61 static int rt2860_resume(struct pci_dev *pci_dev);
62 #endif // CONFIG_PM //
63-#endif
64
65
66 //
67@@ -128,22 +126,15 @@ static struct pci_driver rt2860_driver =
68 name: "rt2860",
69 id_table: rt2860_pci_tbl,
70 probe: rt2860_init_one,
71-#if LINUX_VERSION_CODE >= 0x20412
72 remove: __devexit_p(rt2860_remove_one),
73-#else
74- remove: __devexit(rt2860_remove_one),
75-#endif
76
77-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
78 #ifdef CONFIG_PM
79 suspend: rt2860_suspend,
80 resume: rt2860_resume,
81 #endif
82-#endif
83 };
84
85
86-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
87 #ifdef CONFIG_PM
88
89 VOID RT2860RejectPendingPackets(
90@@ -170,7 +161,7 @@ static int rt2860_suspend(
91 }
92 else
93 {
94- pAd = (PRTMP_ADAPTER)net_dev->priv;
95+ pAd = net_dev->ml_priv;
96
97 /* we can not use IFF_UP because ra0 down but ra1 up */
98 /* and 1 suspend/resume function for 1 module, not for each interface */
99@@ -249,7 +240,7 @@ static int rt2860_resume(
100 DBGPRINT(RT_DEBUG_ERROR, ("net_dev == NULL!\n"));
101 }
102 else
103- pAd = (PRTMP_ADAPTER)net_dev->priv;
104+ pAd = net_dev->ml_priv;
105
106 if (pAd != NULL)
107 {
108@@ -284,16 +275,11 @@ static int rt2860_resume(
109 return 0;
110 }
111 #endif // CONFIG_PM //
112-#endif
113
114
115 static INT __init rt2860_init_module(VOID)
116 {
117-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
118 return pci_register_driver(&rt2860_driver);
119-#else
120- return pci_module_init(&rt2860_driver);
121-#endif
122 }
123
124
125@@ -336,7 +322,7 @@ static VOID __devexit rt2860_remove_one(
126 IN struct pci_dev *pci_dev)
127 {
128 struct net_device *net_dev = pci_get_drvdata(pci_dev);
129- RTMP_ADAPTER *pAd = net_dev->priv;
130+ RTMP_ADAPTER *pAd = net_dev->ml_priv;
131
132 DBGPRINT(RT_DEBUG_TRACE, ("===> rt2860_remove_one\n"));
133
134@@ -374,11 +360,7 @@ static VOID __devexit rt2860_remove_one(
135 }
136
137 // Free pre-allocated net_device memory
138-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
139 free_netdev(net_dev);
140-#else
141- kfree(net_dev);
142-#endif
143 }
144
145 //
146@@ -758,16 +740,13 @@ static void ac0_dma_done_tasklet(unsigne
147 int print_int_count;
148
149 IRQ_HANDLE_TYPE
150-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19))
151 rt2860_interrupt(int irq, void *dev_instance)
152-#else
153-rt2860_interrupt(int irq, void *dev_instance, struct pt_regs *regs)
154-#endif
155 {
156 struct net_device *net_dev = (struct net_device *) dev_instance;
157- PRTMP_ADAPTER pAd = (PRTMP_ADAPTER) net_dev->priv;
158+ PRTMP_ADAPTER pAd = net_dev->ml_priv;
159 INT_SOURCE_CSR_STRUC IntSource;
160 POS_COOKIE pObj;
161+ BOOLEAN bOldValue;
162
163 pObj = (POS_COOKIE) pAd->OS_Cookie;
164
165@@ -800,20 +779,19 @@ rt2860_interrupt(int irq, void *dev_inst
166 // RT2661 => when ASIC is sleeping, MAC register cannot be read and written.
167 // RT2860 => when ASIC is sleeping, MAC register can be read and written.
168
169+ bOldValue = pAd->bPCIclkOff;
170+ pAd->bPCIclkOff = FALSE;
171 {
172 RTMP_IO_READ32(pAd, INT_SOURCE_CSR, &IntSource.word);
173 RTMP_IO_WRITE32(pAd, INT_SOURCE_CSR, IntSource.word); // write 1 to clear
174 }
175+ pAd->bPCIclkOff = bOldValue;
176
177 // Do nothing if Reset in progress
178 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS) ||
179 RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS))
180 {
181-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
182- return IRQ_HANDLED;
183-#else
184- return;
185-#endif
186+ return IRQ_HANDLED;
187 }
188
189 //
190@@ -822,8 +800,6 @@ rt2860_interrupt(int irq, void *dev_inst
191 // The priority can be adjust by altering processing if statement
192 //
193
194- pAd->bPCIclkOff = FALSE;
195-
196 // If required spinlock, each interrupt service routine has to acquire
197 // and release itself.
198 //
199@@ -832,11 +808,8 @@ rt2860_interrupt(int irq, void *dev_inst
200 if (IntSource.word == 0xffffffff)
201 {
202 RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST | fRTMP_ADAPTER_HALT_IN_PROGRESS);
203-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
204- return IRQ_HANDLED;
205-#else
206- return;
207-#endif
208+ printk("snowpin - IntSource.word == 0xffffffff\n");
209+ return IRQ_HANDLED;
210 }
211
212 if (IntSource.word & TxCoherent)
213@@ -970,10 +943,7 @@ rt2860_interrupt(int irq, void *dev_inst
214 }
215 #endif // CONFIG_STA_SUPPORT //
216
217-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
218 return IRQ_HANDLED;
219-#endif
220-
221 }
222
223 /*
224@@ -1022,15 +992,11 @@ BOOLEAN RT28XXNetDevInit(
225 IN RTMP_ADAPTER *pAd)
226 {
227 struct pci_dev *pci_dev = (struct pci_dev *)_dev_p;
228- CHAR *print_name;
229+ const CHAR *print_name;
230 ULONG csr_addr;
231
232
233-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
234- print_name = pci_dev ? pci_name(pci_dev) : "rt2860";
235-#else
236- print_name = pci_dev ? pci_dev->slot_name : "rt2860";
237-#endif // LINUX_VERSION_CODE //
238+ print_name = pci_dev ? pci_name(pci_dev) : "rt2860";
239
240 net_dev->base_addr = 0;
241 net_dev->irq = 0;
242@@ -1202,7 +1168,7 @@ VOID RT28xx_UpdateBeaconToAsic(
243 UCHAR bcn_idx = 0;
244
245 {
246- DBGPRINT(RT_DEBUG_ERROR, ("%s() : No valid Interface be found.\n", __FUNCTION__));
247+ DBGPRINT(RT_DEBUG_ERROR, ("%s() : No valid Interface be found.\n", __func__));
248 return;
249 }
250
251@@ -1300,7 +1266,7 @@ VOID rt2860_stop(struct net_device *net_
252 DBGPRINT(RT_DEBUG_ERROR, ("net_dev == NULL!\n"));
253 }
254 else
255- pAd = (PRTMP_ADAPTER)net_dev->priv;
256+ pAd = net_dev->ml_priv;
257
258 if (pAd != NULL)
259 {
260--- a/drivers/staging/rt2860/Makefile
261+++ b/drivers/staging/rt2860/Makefile
262@@ -2,7 +2,6 @@ obj-$(CONFIG_RT2860) += rt2860sta.o
263
264 # TODO: all of these should be removed
265 EXTRA_CFLAGS += -DLINUX -DAGGREGATION_SUPPORT -DPIGGYBACK_SUPPORT -DWMM_SUPPORT
266-EXTRA_CFLAGS += -DRT2860
267 EXTRA_CFLAGS += -DCONFIG_STA_SUPPORT
268 EXTRA_CFLAGS += -DDBG
269 EXTRA_CFLAGS += -DDOT11_N_SUPPORT
270--- a/drivers/staging/rt2860/TODO
271+++ b/drivers/staging/rt2860/TODO
272@@ -1,6 +1,6 @@
273 I'm hesitant to add a TODO file here, as the wireless developers would
274 really have people help them out on the "clean" rt2860 driver that can
275-be found at the rt2860.sf.net site.
276+be found at the http://rt2x00.serialmonkey.com/ site.
277
278 But, if you wish to clean up this driver instead, here's a short list of
279 things that need to be done to get it into a more mergable shape:
280@@ -8,7 +8,7 @@ things that need to be done to get it in
281 TODO:
282 - checkpatch.pl clean
283 - sparse clean
284- - port to in-kernel 80211 stack
285+ - port to in-kernel 80211 stack and common rt2x00 infrastructure
286 - remove reading from /etc/ config files
287 - review by the wireless developer community
288
289--- a/drivers/staging/rt2860/common/ba_action.c
290+++ b/drivers/staging/rt2860/common/ba_action.c
291@@ -599,7 +599,7 @@ VOID BAOriSessionAdd(
292
293 pBAEntry->ORIBATimer.TimerValue = 0; //pFrame->TimeOutValue;
294
295- DBGPRINT(RT_DEBUG_TRACE,("%s : TXBAbitmap = %x, BAWinSize = %d, TimeOut = %ld\n", __FUNCTION__, pEntry->TXBAbitmap,
296+ DBGPRINT(RT_DEBUG_TRACE,("%s : TXBAbitmap = %x, BAWinSize = %d, TimeOut = %ld\n", __func__, pEntry->TXBAbitmap,
297 pBAEntry->BAWinSize, pBAEntry->ORIBATimer.TimerValue));
298
299 // SEND BAR ;
300@@ -673,7 +673,7 @@ BOOLEAN BARecSessionAdd(
301 ba_refresh_reordering_mpdus(pAd, pBAEntry);
302 }
303
304- DBGPRINT(RT_DEBUG_TRACE,("%s(%ld): Idx = %d, BAWinSize(req %d) = %d\n", __FUNCTION__, pAd->BATable.numAsRecipient, Idx,
305+ DBGPRINT(RT_DEBUG_TRACE,("%s(%ld): Idx = %d, BAWinSize(req %d) = %d\n", __func__, pAd->BATable.numAsRecipient, Idx,
306 pFrame->BaParm.BufSize, BAWinSize));
307
308 // Start fill in parameters.
309@@ -915,7 +915,7 @@ VOID BAOriSessionTearDown(
310 return;
311 }
312
313- DBGPRINT(RT_DEBUG_TRACE,("%s===>Wcid=%d.TID=%d \n", __FUNCTION__, Wcid, TID));
314+ DBGPRINT(RT_DEBUG_TRACE,("%s===>Wcid=%d.TID=%d \n", __func__, Wcid, TID));
315
316 pBAEntry = &pAd->BATable.BAOriEntry[Idx];
317 DBGPRINT(RT_DEBUG_TRACE,("\t===>Idx = %ld, Wcid=%d.TID=%d, ORI_BA_Status = %d \n", Idx, Wcid, TID, pBAEntry->ORI_BA_Status));
318@@ -974,7 +974,7 @@ VOID BARecSessionTearDown(
319 if (Idx == 0)
320 return;
321
322- DBGPRINT(RT_DEBUG_TRACE,("%s===>Wcid=%d.TID=%d \n", __FUNCTION__, Wcid, TID));
323+ DBGPRINT(RT_DEBUG_TRACE,("%s===>Wcid=%d.TID=%d \n", __func__, Wcid, TID));
324
325
326 pBAEntry = &pAd->BATable.BARecEntry[Idx];
327@@ -1185,7 +1185,7 @@ VOID PeerAddBAReqAction(
328 PULONG ptemp;
329 PMAC_TABLE_ENTRY pMacEntry;
330
331- DBGPRINT(RT_DEBUG_TRACE, ("%s ==> (Wcid = %d)\n", __FUNCTION__, Elem->Wcid));
332+ DBGPRINT(RT_DEBUG_TRACE, ("%s ==> (Wcid = %d)\n", __func__, Elem->Wcid));
333
334 //hex_dump("AddBAReq", Elem->Msg, Elem->MsgLen);
335
336@@ -1269,7 +1269,7 @@ VOID PeerAddBAReqAction(
337 MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
338 MlmeFreeMemory(pAd, pOutBuffer);
339
340- DBGPRINT(RT_DEBUG_TRACE, ("%s(%d): TID(%d), BufSize(%d) <== \n", __FUNCTION__, Elem->Wcid, ADDframe.BaParm.TID,
341+ DBGPRINT(RT_DEBUG_TRACE, ("%s(%d): TID(%d), BufSize(%d) <== \n", __func__, Elem->Wcid, ADDframe.BaParm.TID,
342 ADDframe.BaParm.BufSize));
343 }
344
345@@ -1288,7 +1288,7 @@ VOID PeerAddBARspAction(
346 if (Elem->Wcid >= MAX_LEN_OF_MAC_TABLE)
347 return;
348
349- DBGPRINT(RT_DEBUG_TRACE, ("%s ==> Wcid(%d)\n", __FUNCTION__, Elem->Wcid));
350+ DBGPRINT(RT_DEBUG_TRACE, ("%s ==> Wcid(%d)\n", __func__, Elem->Wcid));
351
352 //hex_dump("PeerAddBARspAction()", Elem->Msg, Elem->MsgLen);
353
354@@ -1329,7 +1329,7 @@ VOID PeerDelBAAction(
355 //PUCHAR pOutBuffer = NULL;
356 PFRAME_DELBA_REQ pDelFrame = NULL;
357
358- DBGPRINT(RT_DEBUG_TRACE,("%s ==>\n", __FUNCTION__));
359+ DBGPRINT(RT_DEBUG_TRACE,("%s ==>\n", __func__));
360 //DELBA Request from unknown peer, ignore this.
361 if (PeerDelBAActionSanity(pAd, Elem->Wcid, Elem->Msg, Elem->MsgLen))
362 {
363@@ -1366,7 +1366,7 @@ BOOLEAN CntlEnqueueForRecv(
364
365 TID = (UCHAR)pFrame->BARControl.TID;
366
367- DBGPRINT(RT_DEBUG_TRACE, ("%s(): BAR-Wcid(%ld), Tid (%d)\n", __FUNCTION__, Wcid, TID));
368+ DBGPRINT(RT_DEBUG_TRACE, ("%s(): BAR-Wcid(%ld), Tid (%d)\n", __func__, Wcid, TID));
369 //hex_dump("BAR", (PCHAR) pFrame, MsgLen);
370 // Do nothing if the driver is starting halt state.
371 // This might happen when timer already been fired before cancel timer with mlmehalt
372--- a/drivers/staging/rt2860/common/cmm_data.c
373+++ b/drivers/staging/rt2860/common/cmm_data.c
374@@ -105,9 +105,7 @@ NDIS_STATUS MiniportMMRequest(
375 PNDIS_PACKET pPacket;
376 NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
377 ULONG FreeNum;
378-#ifdef RT2860
379 unsigned long IrqFlags = 0;
380-#endif // RT2860 //
381 UCHAR IrqState;
382 UCHAR rtmpHwHdr[TXINFO_SIZE + TXWI_SIZE]; //RTMP_HW_HDR_LEN];
383
384@@ -118,10 +116,9 @@ NDIS_STATUS MiniportMMRequest(
385 // 2860C use Tx Ring
386
387 IrqState = pAd->irq_disabled;
388-#ifdef RT2860
389+
390 if ((pAd->MACVersion == 0x28600100) && (!IrqState))
391 RTMP_IRQ_LOCK(&pAd->irq_lock, IrqFlags);
392-#endif // RT2860 //
393
394 do
395 {
396@@ -175,17 +172,14 @@ NDIS_STATUS MiniportMMRequest(
397
398 } while (FALSE);
399
400-#ifdef RT2860
401 // 2860C use Tx Ring
402 if ((pAd->MACVersion == 0x28600100) && (!IrqState))
403 RTMP_IRQ_UNLOCK(&pAd->irq_lock, IrqFlags);
404-#endif // RT2860 //
405
406 return Status;
407 }
408
409
410-#ifdef RT2860
411 NDIS_STATUS MiniportMMRequestUnlock(
412 IN PRTMP_ADAPTER pAd,
413 IN UCHAR QueIdx,
414@@ -253,7 +247,6 @@ NDIS_STATUS MiniportMMRequestUnlock(
415
416 return Status;
417 }
418-#endif // RT2860 //
419
420
421 /*
422@@ -290,17 +283,14 @@ NDIS_STATUS MlmeHardTransmit(
423 return NDIS_STATUS_FAILURE;
424 }
425
426-#ifdef RT2860
427 if ( pAd->MACVersion == 0x28600100 )
428 return MlmeHardTransmitTxRing(pAd,QueIdx,pPacket);
429 else
430-#endif // RT2860 //
431 return MlmeHardTransmitMgmtRing(pAd,QueIdx,pPacket);
432
433 }
434
435
436-#ifdef RT2860
437 NDIS_STATUS MlmeHardTransmitTxRing(
438 IN PRTMP_ADAPTER pAd,
439 IN UCHAR QueIdx,
440@@ -366,7 +356,7 @@ NDIS_STATUS MlmeHardTransmitTxRing(
441 {
442 // outgoing frame always wakeup PHY to prevent frame lost
443 if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
444- AsicForceWakeup(pAd, TRUE);
445+ AsicForceWakeup(pAd, FROM_TX);
446 }
447 #endif // CONFIG_STA_SUPPORT //
448 pFirstTxWI =(PTXWI_STRUC)pSrcBufVA;
449@@ -509,7 +499,6 @@ NDIS_STATUS MlmeHardTransmitTxRing(
450
451 return NDIS_STATUS_SUCCESS;
452 }
453-#endif // RT2860 //
454
455
456 NDIS_STATUS MlmeHardTransmitMgmtRing(
457@@ -541,7 +530,7 @@ NDIS_STATUS MlmeHardTransmitMgmtRing(
458 {
459 // outgoing frame always wakeup PHY to prevent frame lost
460 if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
461- AsicForceWakeup(pAd, TRUE);
462+ AsicForceWakeup(pAd, FROM_TX);
463 }
464 #endif // CONFIG_STA_SUPPORT //
465
466@@ -943,9 +932,6 @@ BOOLEAN RTMP_FillTxBlkInfo(
467 }
468
469 return TRUE;
470-
471-FillTxBlkErr:
472- return FALSE;
473 }
474
475
476@@ -1079,7 +1065,6 @@ VOID RTMPDeQueuePacket(
477 break;
478 }
479
480-#ifdef RT2860
481 FreeNumber[QueIdx] = GET_TXRING_FREENO(pAd, QueIdx);
482
483 #ifdef DBG_DIAGNOSE
484@@ -1104,7 +1089,6 @@ VOID RTMPDeQueuePacket(
485 RTMPFreeTXDUponTxDmaDone(pAd, QueIdx);
486 FreeNumber[QueIdx] = GET_TXRING_FREENO(pAd, QueIdx);
487 }
488-#endif // RT2860 //
489
490 // probe the Queue Head
491 pQueue = &pAd->TxSwQueue[QueIdx];
492@@ -1183,12 +1167,10 @@ VOID RTMPDeQueuePacket(
493 Status = STAHardTransmit(pAd, pTxBlk, QueIdx);
494 #endif // CONFIG_STA_SUPPORT //
495
496-#ifdef RT2860
497 DEQUEUE_UNLOCK(&pAd->irq_lock, bIntContext, IrqFlags);
498 // static rate also need NICUpdateFifoStaCounters() function.
499 //if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_TX_RATE_SWITCH_ENABLED))
500 NICUpdateFifoStaCounters(pAd);
501-#endif // RT2860 //
502 }
503
504 RT28XX_STOP_DEQUEUE(pAd, QueIdx, IrqFlags);
505@@ -1767,7 +1749,6 @@ PQUEUE_HEADER RTMPCheckTxSwQueue(
506 }
507
508
509-#ifdef RT2860
510 BOOLEAN RTMPFreeTXDUponTxDmaDone(
511 IN PRTMP_ADAPTER pAd,
512 IN UCHAR QueIdx)
513@@ -2312,7 +2293,6 @@ VOID DBGPRINT_RX_RING(
514 DBGPRINT_RAW(RT_DEBUG_TRACE,(" RxSwReadIdx [%d]=", AC0freeIdx));
515 DBGPRINT_RAW(RT_DEBUG_TRACE,(" pending-NDIS=%ld\n", pAd->RalinkCounters.PendingNdisPacketCount));
516 }
517-#endif // RT2860 //
518
519 /*
520 ========================================================================
521@@ -2637,9 +2617,7 @@ MAC_TABLE_ENTRY *MacTableInsertEntry(
522 pEntry->AuthMode = pAd->StaCfg.AuthMode;
523 pEntry->WepStatus = pAd->StaCfg.WepStatus;
524 pEntry->PrivacyFilter = Ndis802_11PrivFilterAcceptAll;
525-#ifdef RT2860
526 AsicRemovePairwiseKeyEntry(pAd, pEntry->apidx, (UCHAR)i);
527-#endif // RT2860 //
528 }
529 #endif // CONFIG_STA_SUPPORT //
530 }
531@@ -2790,7 +2768,7 @@ BOOLEAN MacTableDeleteEntry(
532 }
533 else
534 {
535- printk("\n%s: Impossible Wcid = %d !!!!!\n", __FUNCTION__, wcid);
536+ printk("\n%s: Impossible Wcid = %d !!!!!\n", __func__, wcid);
537 }
538 }
539
540@@ -2826,9 +2804,7 @@ VOID MacTableReset(
541
542 for (i=1; i<MAX_LEN_OF_MAC_TABLE; i++)
543 {
544-#ifdef RT2860
545 RT28XX_STA_ENTRY_MAC_RESET(pAd, i);
546-#endif // RT2860 //
547 if (pAd->MacTab.Content[i].ValidAsCLI == TRUE)
548 {
549
550--- a/drivers/staging/rt2860/common/cmm_data_2860.c
551+++ b/drivers/staging/rt2860/common/cmm_data_2860.c
552@@ -634,7 +634,7 @@ VOID RT28xxPciAsicRadioOff(
553 }
554
555 // Once go into this function, disable tx because don't want too many packets in queue to prevent HW stops.
556- pAd->bPCIclkOffDisableTx = TRUE;
557+ RTMP_SET_PSFLAG(pAd, fRTMP_PS_DISABLE_TX);
558
559 if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_ADVANCE_POWER_SAVE_PCIE_DEVICE))
560 {
561@@ -651,7 +651,7 @@ VOID RT28xxPciAsicRadioOff(
562 {
563 DBGPRINT(RT_DEBUG_TRACE, ("TbTTTime = 0x%x , give up this sleep. \n", TbTTTime));
564 OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_DOZE);
565- pAd->bPCIclkOffDisableTx = FALSE;
566+ RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_DISABLE_TX);
567 return;
568 }
569 else
570@@ -688,18 +688,25 @@ VOID RT28xxPciAsicRadioOff(
571 if (i >= 50)
572 {
573 DBGPRINT(RT_DEBUG_TRACE, ("DMA keeps busy. return on RT28xxPciAsicRadioOff ()\n"));
574- pAd->bPCIclkOffDisableTx = FALSE;
575 RTMP_IO_READ32(pAd, WPDMA_GLO_CFG, &DmaCfg.word);
576 DmaCfg.field.EnableTxDMA = 1;
577 RTMP_IO_WRITE32(pAd, WPDMA_GLO_CFG, DmaCfg.word);
578+ pAd->CheckDmaBusyCount++;
579 return;
580 }
581+ else
582+ {
583+ pAd->CheckDmaBusyCount = 0;
584+ }
585
586 RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_IDLE_RADIO_OFF);
587
588 // Set to 1R.
589- tempBBP_R3 = (pAd->StaCfg.BBPR3 & 0xE7);
590- RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, tempBBP_R3);
591+ if (pAd->Antenna.field.RxPath > 1)
592+ {
593+ tempBBP_R3 = (pAd->StaCfg.BBPR3 & 0xE7);
594+ RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, tempBBP_R3);
595+ }
596
597 // In Radio Off, we turn off RF clk, So now need to call ASICSwitchChannel again.
598 if (INFRA_ON(pAd) && (pAd->CommonCfg.CentralChannel != pAd->CommonCfg.Channel)
599@@ -714,8 +721,15 @@ VOID RT28xxPciAsicRadioOff(
600 AsicTurnOffRFClk(pAd, pAd->CommonCfg.Channel);
601 }
602
603- // When PCI clock is off, don't want to service interrupt.
604- RTMP_IO_WRITE32(pAd, INT_MASK_CSR, AutoWakeupInt);
605+ if (Level != RTMP_HALT)
606+ {
607+ // Change Interrupt bitmask.
608+ RTMP_IO_WRITE32(pAd, INT_MASK_CSR, AutoWakeupInt);
609+ }
610+ else
611+ {
612+ NICDisableInterrupt(pAd);
613+ }
614
615 RTMP_IO_WRITE32(pAd, RX_CRX_IDX, pAd->RxRing.RxCpuIdx);
616 // Disable MAC Rx
617@@ -726,7 +740,8 @@ VOID RT28xxPciAsicRadioOff(
618 // 2. Send Sleep command
619 RTMP_IO_WRITE32(pAd, H2M_MAILBOX_STATUS, 0xffffffff);
620 RTMP_IO_WRITE32(pAd, H2M_MAILBOX_CID, 0xffffffff);
621- AsicSendCommandToMcu(pAd, 0x30, PowerSafeCID, 0xff, 0x00); // send POWER-SAVE command to MCU. Timeout unit:40us.
622+ // send POWER-SAVE command to MCU. high-byte = 1 save power as much as possible. high byte = 0 save less power
623+ AsicSendCommandToMcu(pAd, 0x30, PowerSafeCID, 0xff, 0x1);
624 // 2-1. Wait command success
625 // Status = 1 : success, Status = 2, already sleep, Status = 3, Maybe MAC is busy so can't finish this task.
626 brc = AsicCheckCommanOk(pAd, PowerSafeCID);
627@@ -734,7 +749,7 @@ VOID RT28xxPciAsicRadioOff(
628 if (brc == FALSE)
629 {
630 // try again
631- AsicSendCommandToMcu(pAd, 0x30, PowerSafeCID, 0xff, 0x00); // send POWER-SAVE command to MCU. Timeout unit:40us.
632+ AsicSendCommandToMcu(pAd, 0x30, PowerSafeCID, 0xff, 0x01); // send POWER-SAVE command to MCU. Timeout unit:40us.
633 //RTMPusecDelay(200);
634 brc = AsicCheckCommanOk(pAd, PowerSafeCID);
635 }
636@@ -759,7 +774,7 @@ VOID RT28xxPciAsicRadioOff(
637 do
638 {
639 RTMP_IO_READ32(pAd, WPDMA_GLO_CFG, &DmaCfg.word);
640- if (DmaCfg.field.RxDMABusy == 0)
641+ if ((DmaCfg.field.RxDMABusy == 0) && (DmaCfg.field.TxDMABusy == 0))
642 break;
643 RTMPusecDelay(20);
644 i++;
645@@ -767,13 +782,12 @@ VOID RT28xxPciAsicRadioOff(
646
647 if (i >= 50)
648 {
649+ pAd->CheckDmaBusyCount++;
650 DBGPRINT(RT_DEBUG_TRACE, ("DMA Rx keeps busy. on RT28xxPciAsicRadioOff ()\n"));
651 }
652- // disable DMA Rx.
653+ else
654 {
655- RTMP_IO_READ32(pAd, WPDMA_GLO_CFG, &DmaCfg.word);
656- DmaCfg.field.EnableRxDMA = 0;
657- RTMP_IO_WRITE32(pAd, WPDMA_GLO_CFG, DmaCfg.word);
658+ pAd->CheckDmaBusyCount = 0;
659 }
660
661 if (Level == DOT11POWERSAVE)
662@@ -799,7 +813,7 @@ VOID RT28xxPciAsicRadioOff(
663 if (Level == RTMP_HALT)
664 {
665 if ((brc == TRUE) && (i < 50))
666- RTMPPCIeLinkCtrlSetting(pAd, 1);
667+ RTMPPCIeLinkCtrlSetting(pAd, 0);
668 }
669 // 4. Set PCI configuration Space Link Comtrol fields. Only Radio Off needs to call this function
670 else
671@@ -808,7 +822,7 @@ VOID RT28xxPciAsicRadioOff(
672 RTMPPCIeLinkCtrlSetting(pAd, 3);
673 }
674
675- pAd->bPCIclkOffDisableTx = FALSE;
676+ RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_DISABLE_TX);
677 }
678
679
680@@ -835,7 +849,8 @@ BOOLEAN RT28xxPciAsicRadioOn(
681 {
682 pAd->Mlme.bPsPollTimerRunning = FALSE;
683 RTMPCancelTimer(&pAd->Mlme.PsPollTimer, &Cancelled);
684- if ((Level == GUIRADIO_OFF) || (Level == GUI_IDLE_POWER_SAVE))
685+ if ((Level == GUIRADIO_OFF) || (Level == GUI_IDLE_POWER_SAVE)
686+ || (RTMP_TEST_PSFLAG(pAd, fRTMP_PS_SET_PCI_CLK_OFF_COMMAND)))
687 {
688 DBGPRINT(RT_DEBUG_TRACE, ("RT28xxPciAsicRadioOn ()\n"));
689 // 1. Set PCI Link Control in Configuration Space.
690@@ -845,15 +860,14 @@ BOOLEAN RT28xxPciAsicRadioOn(
691 }
692
693 pAd->bPCIclkOff = FALSE;
694-
695+ RTMP_IO_WRITE32(pAd, PBF_SYS_CTRL, 0x3a80);
696 // 2. Send wake up command.
697- AsicSendCommandToMcu(pAd, 0x31, PowerWakeCID, 0x00, 0x00);
698+ AsicSendCommandToMcu(pAd, 0x31, PowerWakeCID, 0x00, 0x02);
699
700 // 2-1. wait command ok.
701 brv = AsicCheckCommanOk(pAd, PowerWakeCID);
702 if (brv)
703 {
704- //RTMP_IO_WRITE32(pAd, INT_MASK_CSR, (DELAYINTMASK|RxINT));
705 NICEnableInterrupt(pAd);
706
707 // 3. Enable Tx DMA.
708@@ -893,13 +907,10 @@ BOOLEAN RT28xxPciAsicRadioOn(
709
710 VOID RT28xxPciStaAsicForceWakeup(
711 IN PRTMP_ADAPTER pAd,
712- IN BOOLEAN bFromTx)
713+ IN UCHAR Level)
714 {
715 AUTO_WAKEUP_STRUC AutoWakeupCfg;
716
717- if (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
718- return;
719-
720 if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_WAKEUP_NOW))
721 {
722 DBGPRINT(RT_DEBUG_TRACE, ("waking up now!\n"));
723@@ -907,38 +918,48 @@ VOID RT28xxPciStaAsicForceWakeup(
724 }
725
726 OPSTATUS_SET_FLAG(pAd, fOP_STATUS_WAKEUP_NOW);
727+ RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_GO_TO_SLEEP_NOW);
728
729 if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_ADVANCE_POWER_SAVE_PCIE_DEVICE))
730 {
731 // Support PCIe Advance Power Save
732- if (bFromTx == TRUE)
733+ if (((Level == FROM_TX) && (pAd->Mlme.bPsPollTimerRunning == TRUE)) ||
734+ (Level == RTMP_HALT))
735 {
736 pAd->Mlme.bPsPollTimerRunning = FALSE;
737 RTMPPCIeLinkCtrlValueRestore(pAd, RESTORE_WAKEUP);
738- RTMPusecDelay(3000);
739+ RTMPusecDelay(5000);
740 DBGPRINT(RT_DEBUG_TRACE, ("=======AsicForceWakeup===bFromTx\n"));
741 }
742
743 AutoWakeupCfg.word = 0;
744 RTMP_IO_WRITE32(pAd, AUTO_WAKEUP_CFG, AutoWakeupCfg.word);
745
746- if (RT28xxPciAsicRadioOn(pAd, DOT11POWERSAVE))
747- {
748- // In Radio Off, we turn off RF clk, So now need to call ASICSwitchChannel again.
749- if (INFRA_ON(pAd) && (pAd->CommonCfg.CentralChannel != pAd->CommonCfg.Channel)
750- && (pAd->MlmeAux.HtCapability.HtCapInfo.ChannelWidth == BW_40))
751- {
752- // Must using 40MHz.
753- AsicSwitchChannel(pAd, pAd->CommonCfg.CentralChannel, FALSE);
754- AsicLockChannel(pAd, pAd->CommonCfg.CentralChannel);
755- }
756- else
757- {
758- // Must using 20MHz.
759- AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
760- AsicLockChannel(pAd, pAd->CommonCfg.Channel);
761- }
762- }
763+ // If this is called from Halt. ALWAYS force wakeup!!!
764+ if (Level == RTMP_HALT)
765+ {
766+ RT28xxPciAsicRadioOn(pAd, RTMP_HALT);
767+ }
768+ else
769+ {
770+ if (RT28xxPciAsicRadioOn(pAd, DOT11POWERSAVE))
771+ {
772+ // In Radio Off, we turn off RF clk, So now need to call ASICSwitchChannel again.
773+ if (INFRA_ON(pAd) && (pAd->CommonCfg.CentralChannel != pAd->CommonCfg.Channel)
774+ && (pAd->MlmeAux.HtCapability.HtCapInfo.ChannelWidth == BW_40))
775+ {
776+ // Must using 40MHz.
777+ AsicSwitchChannel(pAd, pAd->CommonCfg.CentralChannel, FALSE);
778+ AsicLockChannel(pAd, pAd->CommonCfg.CentralChannel);
779+ }
780+ else
781+ {
782+ // Must using 20MHz.
783+ AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
784+ AsicLockChannel(pAd, pAd->CommonCfg.Channel);
785+ }
786+ }
787+ }
788 }
789 else
790 {
791@@ -1002,7 +1023,7 @@ VOID RT28xxPciStaAsicSleepThenAutoWakeup
792 AutoWakeupCfg.field.AutoLeadTime = 5;
793 RTMP_IO_WRITE32(pAd, AUTO_WAKEUP_CFG, AutoWakeupCfg.word);
794 AsicSendCommandToMcu(pAd, 0x30, 0xff, 0xff, 0x00); // send POWER-SAVE command to MCU. Timeout 40us.
795- DBGPRINT(RT_DEBUG_TRACE, ("<-- %s, TbttNumToNextWakeUp=%d \n", __FUNCTION__, TbttNumToNextWakeUp));
796+ DBGPRINT(RT_DEBUG_TRACE, ("<-- %s, TbttNumToNextWakeUp=%d \n", __func__, TbttNumToNextWakeUp));
797 }
798 OPSTATUS_SET_FLAG(pAd, fOP_STATUS_DOZE);
799 }
800@@ -1115,13 +1136,14 @@ VOID RT28xxPciMlmeRadioOn(
801 if (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF))
802 return;
803
804- DBGPRINT(RT_DEBUG_TRACE,("%s===>\n", __FUNCTION__));
805+ DBGPRINT(RT_DEBUG_TRACE,("%s===>\n", __func__));
806
807 if ((pAd->OpMode == OPMODE_AP) ||
808 ((pAd->OpMode == OPMODE_STA) && (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_ADVANCE_POWER_SAVE_PCIE_DEVICE))))
809 {
810 NICResetFromError(pAd);
811
812+ /*
813 RTMPRingCleanUp(pAd, QID_AC_BK);
814 RTMPRingCleanUp(pAd, QID_AC_BE);
815 RTMPRingCleanUp(pAd, QID_AC_VI);
816@@ -1129,6 +1151,7 @@ VOID RT28xxPciMlmeRadioOn(
817 RTMPRingCleanUp(pAd, QID_HCCA);
818 RTMPRingCleanUp(pAd, QID_MGMT);
819 RTMPRingCleanUp(pAd, QID_RX);
820+ */
821
822 // Enable Tx/Rx
823 RTMPEnableRxTx(pAd);
824@@ -1162,20 +1185,25 @@ VOID RT28xxPciMlmeRadioOFF(
825 WPDMA_GLO_CFG_STRUC GloCfg;
826 UINT32 i;
827
828+ if (pAd->StaCfg.bRadio == TRUE)
829+ {
830+ DBGPRINT(RT_DEBUG_TRACE,("-->MlmeRadioOff() return on bRadio == TRUE; \n"));
831+ return;
832+ }
833+
834 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF))
835 return;
836
837- DBGPRINT(RT_DEBUG_TRACE,("%s===>\n", __FUNCTION__));
838+ DBGPRINT(RT_DEBUG_TRACE,("%s===>\n", __func__));
839
840 // Set LED
841 RTMPSetLED(pAd, LED_RADIO_OFF);
842- // Set Radio off flag
843- RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF);
844
845 #ifdef CONFIG_STA_SUPPORT
846 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
847 {
848 BOOLEAN Cancelled;
849+
850 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
851 {
852 RTMPCancelTimer(&pAd->MlmeAux.ScanTimer, &Cancelled);
853@@ -1185,6 +1213,15 @@ VOID RT28xxPciMlmeRadioOFF(
854 if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_ADVANCE_POWER_SAVE_PCIE_DEVICE))
855 {
856 BOOLEAN Cancelled;
857+
858+ // Always radio on since the NIC needs to set the MCU command (LED_RADIO_OFF).\r
859+ if ((pAd->OpMode == OPMODE_STA) && \r
860+ (IDLE_ON(pAd)) && \r
861+ (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_IDLE_RADIO_OFF)))\r
862+ {\r
863+ RT28xxPciAsicRadioOn(pAd, GUI_IDLE_POWER_SAVE);\r
864+ }
865+
866 pAd->Mlme.bPsPollTimerRunning = FALSE;
867 RTMPCancelTimer(&pAd->Mlme.PsPollTimer, &Cancelled);
868 RTMPCancelTimer(&pAd->Mlme.RadioOnOffTimer, &Cancelled);
869@@ -1197,9 +1234,26 @@ VOID RT28xxPciMlmeRadioOFF(
870 //==========================================
871 // Clean up old bss table
872 BssTableInit(&pAd->ScanTab);
873+
874+ RTMPRingCleanUp(pAd, QID_AC_BK);
875+ RTMPRingCleanUp(pAd, QID_AC_BE);
876+ RTMPRingCleanUp(pAd, QID_AC_VI);
877+ RTMPRingCleanUp(pAd, QID_AC_VO);
878+ RTMPRingCleanUp(pAd, QID_HCCA);
879+ RTMPRingCleanUp(pAd, QID_MGMT);
880+ RTMPRingCleanUp(pAd, QID_RX);
881+
882+ if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_ADVANCE_POWER_SAVE_PCIE_DEVICE))
883+ {
884+ RTMPSetTimer(&pAd->Mlme.RadioOnOffTimer, 500);
885+ return;
886+ }
887 }
888 #endif // CONFIG_STA_SUPPORT //
889
890+ // Set Radio off flag
891+ RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF);
892+
893 // Disable Tx/Rx DMA
894 RTMP_IO_READ32(pAd, WPDMA_GLO_CFG, &GloCfg.word); // disable DMA
895 GloCfg.field.EnableTxDMA = 0;
896--- a/drivers/staging/rt2860/common/cmm_info.c
897+++ b/drivers/staging/rt2860/common/cmm_info.c
898@@ -814,7 +814,6 @@ INT Show_DescInfo_Proc(
899 IN PRTMP_ADAPTER pAd,
900 IN PUCHAR arg)
901 {
902-#ifdef RT2860
903 INT i, QueIdx=0;
904 PRT28XX_RXD_STRUC pRxD;
905 PTXD_STRUC pTxD;
906@@ -845,7 +844,6 @@ INT Show_DescInfo_Proc(
907 hex_dump("Rx Descriptor", (char *)pRxD, 16);
908 printk("pRxD->DDONE = %x\n", pRxD->DDONE);
909 }
910-#endif // RT2860 //
911
912 return TRUE;
913 }
914@@ -1803,9 +1801,7 @@ VOID RTMPAddWcidAttributeEntry(
915 }
916
917 // For key index and ext IV bit, so only need to update the position(offset+3).
918-#ifdef RT2860
919 RTMP_IO_WRITE8(pAd, offset+3, IVEIV);
920-#endif // RT2860 //
921
922 DBGPRINT(RT_DEBUG_TRACE,("RTMPAddWcidAttributeEntry: WCID #%d, KeyIndex #%d, Alg=%s\n",Wcid, KeyIdx, CipherName[CipherAlg]));
923 DBGPRINT(RT_DEBUG_TRACE,(" WCIDAttri = 0x%x \n", WCIDAttri));
924@@ -2039,7 +2035,7 @@ VOID RTMPIoctlGetMacTable(
925 wrq->u.data.length = sizeof(RT_802_11_MAC_TABLE);
926 if (copy_to_user(wrq->u.data.pointer, &MacTab, wrq->u.data.length))
927 {
928- DBGPRINT(RT_DEBUG_TRACE, ("%s: copy_to_user() fail\n", __FUNCTION__));
929+ DBGPRINT(RT_DEBUG_TRACE, ("%s: copy_to_user() fail\n", __func__));
930 }
931
932 msg = (CHAR *) kmalloc(sizeof(CHAR)*(MAX_LEN_OF_MAC_TABLE*MAC_LINE_LEN), MEM_ALLOC_FLAG);
933@@ -2827,9 +2823,7 @@ INT Set_OpMode_Proc(
934
935 Value = simple_strtol(arg, 0, 10);
936
937-#ifdef RT2860
938 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
939-#endif // RT2860 //
940 {
941 DBGPRINT(RT_DEBUG_ERROR, ("Can not switch operate mode on interface up !! \n"));
942 return FALSE;
943--- a/drivers/staging/rt2860/common/cmm_sync.c
944+++ b/drivers/staging/rt2860/common/cmm_sync.c
945@@ -470,7 +470,7 @@ VOID ScanNextChannel(
946 {
947 // BBP and RF are not accessible in PS mode, we has to wake them up first
948 if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
949- AsicForceWakeup(pAd, TRUE);
950+ AsicForceWakeup(pAd, FROM_TX);
951
952 // leave PSM during scanning. otherwise we may lost ProbeRsp & BEACON
953 if (pAd->StaCfg.Psm == PWR_SAVE)
954--- a/drivers/staging/rt2860/common/cmm_wpa.c
955+++ b/drivers/staging/rt2860/common/cmm_wpa.c
956@@ -39,8 +39,10 @@
957 // WPA OUI
958 UCHAR OUI_WPA_NONE_AKM[4] = {0x00, 0x50, 0xF2, 0x00};
959 UCHAR OUI_WPA_VERSION[4] = {0x00, 0x50, 0xF2, 0x01};
960+UCHAR OUI_WPA_WEP40[4] = {0x00, 0x50, 0xF2, 0x01};
961 UCHAR OUI_WPA_TKIP[4] = {0x00, 0x50, 0xF2, 0x02};
962 UCHAR OUI_WPA_CCMP[4] = {0x00, 0x50, 0xF2, 0x04};
963+UCHAR OUI_WPA_WEP104[4] = {0x00, 0x50, 0xF2, 0x05};
964 UCHAR OUI_WPA_8021X_AKM[4] = {0x00, 0x50, 0xF2, 0x01};
965 UCHAR OUI_WPA_PSK_AKM[4] = {0x00, 0x50, 0xF2, 0x02};
966 // WPA2 OUI
967@@ -49,6 +51,7 @@ UCHAR OUI_WPA2_TKIP[4] = {0
968 UCHAR OUI_WPA2_CCMP[4] = {0x00, 0x0F, 0xAC, 0x04};
969 UCHAR OUI_WPA2_8021X_AKM[4] = {0x00, 0x0F, 0xAC, 0x01};
970 UCHAR OUI_WPA2_PSK_AKM[4] = {0x00, 0x0F, 0xAC, 0x02};
971+UCHAR OUI_WPA2_WEP104[4] = {0x00, 0x0F, 0xAC, 0x05};
972 // MSA OUI
973 UCHAR OUI_MSA_8021X_AKM[4] = {0x00, 0x0F, 0xAC, 0x05}; // Not yet final - IEEE 802.11s-D1.06
974 UCHAR OUI_MSA_PSK_AKM[4] = {0x00, 0x0F, 0xAC, 0x06}; // Not yet final - IEEE 802.11s-D1.06
975@@ -367,6 +370,24 @@ static VOID RTMPInsertRsnIeCipher(
976 break;
977 }
978
979+#ifdef CONFIG_STA_SUPPORT
980+ if ((pAd->OpMode == OPMODE_STA) &&
981+ (pAd->StaCfg.GroupCipher != Ndis802_11Encryption2Enabled) &&
982+ (pAd->StaCfg.GroupCipher != Ndis802_11Encryption3Enabled))
983+ {
984+ UINT GroupCipher = pAd->StaCfg.GroupCipher;
985+ switch(GroupCipher)
986+ {
987+ case Ndis802_11GroupWEP40Enabled:
988+ NdisMoveMemory(pRsnie_cipher->mcast, OUI_WPA2_WEP40, 4);
989+ break;
990+ case Ndis802_11GroupWEP104Enabled:
991+ NdisMoveMemory(pRsnie_cipher->mcast, OUI_WPA2_WEP104, 4);
992+ break;
993+ }
994+ }
995+#endif // CONFIG_STA_SUPPORT //
996+
997 // swap for big-endian platform
998 pRsnie_cipher->version = cpu2le16(pRsnie_cipher->version);
999 pRsnie_cipher->ucount = cpu2le16(pRsnie_cipher->ucount);
1000@@ -427,11 +448,28 @@ static VOID RTMPInsertRsnIeCipher(
1001 break;
1002 }
1003
1004+#ifdef CONFIG_STA_SUPPORT
1005+ if ((pAd->OpMode == OPMODE_STA) &&
1006+ (pAd->StaCfg.GroupCipher != Ndis802_11Encryption2Enabled) &&
1007+ (pAd->StaCfg.GroupCipher != Ndis802_11Encryption3Enabled))
1008+ {
1009+ UINT GroupCipher = pAd->StaCfg.GroupCipher;
1010+ switch(GroupCipher)
1011+ {
1012+ case Ndis802_11GroupWEP40Enabled:
1013+ NdisMoveMemory(pRsnie_cipher->mcast, OUI_WPA_WEP40, 4);
1014+ break;
1015+ case Ndis802_11GroupWEP104Enabled:
1016+ NdisMoveMemory(pRsnie_cipher->mcast, OUI_WPA_WEP104, 4);
1017+ break;
1018+ }
1019+ }
1020+#endif // CONFIG_STA_SUPPORT //
1021+
1022 // swap for big-endian platform
1023 pRsnie_cipher->version = cpu2le16(pRsnie_cipher->version);
1024 pRsnie_cipher->ucount = cpu2le16(pRsnie_cipher->ucount);
1025 }
1026-
1027 }
1028
1029 /*
1030--- a/drivers/staging/rt2860/common/dfs.c
1031+++ b/drivers/staging/rt2860/common/dfs.c
1032@@ -428,7 +428,7 @@ INT Set_ChMovingTime_Proc(
1033
1034 pAd->CommonCfg.RadarDetect.ChMovingTime = Value;
1035
1036- DBGPRINT(RT_DEBUG_TRACE, ("%s:: %d\n", __FUNCTION__,
1037+ DBGPRINT(RT_DEBUG_TRACE, ("%s:: %d\n", __func__,
1038 pAd->CommonCfg.RadarDetect.ChMovingTime));
1039
1040 return TRUE;
1041@@ -444,7 +444,7 @@ INT Set_LongPulseRadarTh_Proc(
1042
1043 pAd->CommonCfg.RadarDetect.LongPulseRadarTh = Value;
1044
1045- DBGPRINT(RT_DEBUG_TRACE, ("%s:: %d\n", __FUNCTION__,
1046+ DBGPRINT(RT_DEBUG_TRACE, ("%s:: %d\n", __func__,
1047 pAd->CommonCfg.RadarDetect.LongPulseRadarTh));
1048
1049 return TRUE;
1050--- a/drivers/staging/rt2860/common/mlme.c
1051+++ b/drivers/staging/rt2860/common/mlme.c
1052@@ -527,7 +527,6 @@ NDIS_STATUS MlmeInit(
1053
1054
1055 #ifdef CONFIG_STA_SUPPORT
1056-#ifdef RT2860
1057 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
1058 {
1059 if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_ADVANCE_POWER_SAVE_PCIE_DEVICE))
1060@@ -537,7 +536,6 @@ NDIS_STATUS MlmeInit(
1061 RTMPInitTimer(pAd, &pAd->Mlme.RadioOnOffTimer, GET_TIMER_FUNCTION(RadioOnExec), pAd, FALSE);
1062 }
1063 }
1064-#endif // RT2860 //
1065 #endif // CONFIG_STA_SUPPORT //
1066
1067 } while (FALSE);
1068@@ -711,13 +709,11 @@ VOID MlmeHalt(
1069 RTMPCancelTimer(&pAd->MlmeAux.AuthTimer, &Cancelled);
1070 RTMPCancelTimer(&pAd->MlmeAux.BeaconTimer, &Cancelled);
1071 RTMPCancelTimer(&pAd->MlmeAux.ScanTimer, &Cancelled);
1072-#ifdef RT2860
1073 if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_ADVANCE_POWER_SAVE_PCIE_DEVICE))
1074 {
1075 RTMPCancelTimer(&pAd->Mlme.PsPollTimer, &Cancelled);
1076 RTMPCancelTimer(&pAd->Mlme.RadioOnOffTimer, &Cancelled);
1077 }
1078-#endif // RT2860 //
1079
1080 #ifdef QOS_DLS_SUPPORT
1081 for (i=0; i<MAX_NUM_OF_DLS_ENTRY; i++)
1082@@ -808,21 +804,34 @@ VOID MlmePeriodicExec(
1083 ULONG TxTotalCnt;
1084 PRTMP_ADAPTER pAd = (RTMP_ADAPTER *)FunctionContext;
1085
1086+ //Baron 2008/07/10
1087+ //printk("Baron_Test:\t%s", RTMPGetRalinkEncryModeStr(pAd->StaCfg.WepStatus));
1088+ //If the STA security setting is OPEN or WEP, pAd->StaCfg.WpaSupplicantUP = 0.
1089+ //If the STA security setting is WPAPSK or WPA2PSK, pAd->StaCfg.WpaSupplicantUP = 1.
1090+ if(pAd->StaCfg.WepStatus<2)
1091+ {
1092+ pAd->StaCfg.WpaSupplicantUP = 0;
1093+ }
1094+ else
1095+ {
1096+ pAd->StaCfg.WpaSupplicantUP = 1;
1097+ }
1098+
1099 #ifdef CONFIG_STA_SUPPORT
1100-#ifdef RT2860
1101 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
1102 {
1103 // If Hardware controlled Radio enabled, we have to check GPIO pin2 every 2 second.
1104 // Move code to here, because following code will return when radio is off
1105- if ((pAd->Mlme.PeriodicRound % (MLME_TASK_EXEC_MULTIPLE * 2) == 0) && (pAd->StaCfg.bHardwareRadio == TRUE) &&
1106+ if ((pAd->Mlme.PeriodicRound % (MLME_TASK_EXEC_MULTIPLE * 2) == 0) &&
1107+ (pAd->StaCfg.bHardwareRadio == TRUE) &&
1108+ (RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_START_UP)) &&
1109 (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)) &&
1110- (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS)) &&
1111- (pAd->bPCIclkOff == FALSE))
1112+ (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS)))
1113 {
1114 UINT32 data = 0;
1115
1116 // Read GPIO pin2 as Hardware controlled radio state
1117- RTMP_IO_READ32(pAd, GPIO_CTRL_CFG, &data);
1118+ RTMP_IO_FORCE_READ32(pAd, GPIO_CTRL_CFG, &data);
1119 if (data & 0x04)
1120 {
1121 pAd->StaCfg.bHwRadio = TRUE;
1122@@ -849,7 +858,6 @@ VOID MlmePeriodicExec(
1123 }
1124 }
1125 }
1126-#endif // RT2860 //
1127 #endif // CONFIG_STA_SUPPORT //
1128
1129 // Do nothing if the driver is starting halt state.
1130@@ -860,6 +868,45 @@ VOID MlmePeriodicExec(
1131 fRTMP_ADAPTER_RESET_IN_PROGRESS))))
1132 return;
1133
1134+ IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
1135+ {
1136+ if ((pAd->RalinkCounters.LastReceivedByteCount == pAd->RalinkCounters.ReceivedByteCount) && (pAd->StaCfg.bRadio == TRUE))
1137+ {
1138+ // If ReceiveByteCount doesn't change, increase SameRxByteCount by 1.
1139+ pAd->SameRxByteCount++;
1140+ }
1141+ else
1142+ pAd->SameRxByteCount = 0;
1143+
1144+ // If after BBP, still not work...need to check to reset PBF&MAC.
1145+ if (pAd->SameRxByteCount == 702)
1146+ {
1147+ pAd->SameRxByteCount = 0;
1148+ AsicResetPBF(pAd);
1149+ AsicResetMAC(pAd);
1150+ }
1151+
1152+ // If SameRxByteCount keeps happens for 2 second in infra mode, or for 60 seconds in idle mode.
1153+ if (((INFRA_ON(pAd)) && (pAd->SameRxByteCount > 20)) || ((IDLE_ON(pAd)) && (pAd->SameRxByteCount > 600)))
1154+ {
1155+ if ((pAd->StaCfg.bRadio == TRUE) && (pAd->SameRxByteCount < 700))
1156+ {
1157+ DBGPRINT(RT_DEBUG_TRACE, ("---> SameRxByteCount = %lu !!!!!!!!!!!!!!! \n", pAd->SameRxByteCount));
1158+ pAd->SameRxByteCount = 700;
1159+ AsicResetBBP(pAd);
1160+ }
1161+ }
1162+
1163+ // Update lastReceiveByteCount.
1164+ pAd->RalinkCounters.LastReceivedByteCount = pAd->RalinkCounters.ReceivedByteCount;
1165+
1166+ if ((pAd->CheckDmaBusyCount > 3) && (IDLE_ON(pAd)))
1167+ {
1168+ pAd->CheckDmaBusyCount = 0;
1169+ AsicResetFromDMABusy(pAd);
1170+ }
1171+ }
1172+
1173 RT28XX_MLME_PRE_SANITY_CHECK(pAd);
1174
1175 #ifdef RALINK_ATE
1176@@ -1022,9 +1069,7 @@ VOID MlmePeriodicExec(
1177 #ifdef CONFIG_STA_SUPPORT
1178 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
1179 {
1180-#ifdef RT2860
1181 if (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST) && (pAd->bPCIclkOff == FALSE))
1182-#endif // RT2860 //
1183 {
1184 // When Adhoc beacon is enabled and RTS/CTS is enabled, there is a chance that hardware MAC FSM will run into a deadlock
1185 // and sending CTS-to-self over and over.
1186@@ -1081,6 +1126,19 @@ VOID STAMlmePeriodicExec(
1187 pAd->StaCfg.bBlockAssoc = FALSE;
1188 }
1189
1190+ //Baron 2008/07/10
1191+ //printk("Baron_Test:\t%s", RTMPGetRalinkEncryModeStr(pAd->StaCfg.WepStatus));
1192+ //If the STA security setting is OPEN or WEP, pAd->StaCfg.WpaSupplicantUP = 0.
1193+ //If the STA security setting is WPAPSK or WPA2PSK, pAd->StaCfg.WpaSupplicantUP = 1.
1194+ if(pAd->StaCfg.WepStatus<2)
1195+ {
1196+ pAd->StaCfg.WpaSupplicantUP = 0;
1197+ }
1198+ else
1199+ {
1200+ pAd->StaCfg.WpaSupplicantUP = 1;
1201+ }
1202+
1203 if ((pAd->PreMediaState != pAd->IndicateMediaState) && (pAd->CommonCfg.bWirelessEvent))
1204 {
1205 if (pAd->IndicateMediaState == NdisMediaStateConnected)
1206@@ -1090,6 +1148,15 @@ VOID STAMlmePeriodicExec(
1207 pAd->PreMediaState = pAd->IndicateMediaState;
1208 }
1209
1210+ if ((pAd->OpMode == OPMODE_STA) && (IDLE_ON(pAd)) &&
1211+ (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_ADVANCE_POWER_SAVE_PCIE_DEVICE)) &&
1212+ (pAd->Mlme.SyncMachine.CurrState == SYNC_IDLE) &&
1213+ (pAd->Mlme.CntlMachine.CurrState == CNTL_IDLE) &&
1214+ (RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_START_UP)) &&
1215+ (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_IDLE_RADIO_OFF)))
1216+ {
1217+ RT28xxPciAsicRadioOff(pAd, GUI_IDLE_POWER_SAVE, 0);
1218+ }
1219
1220
1221
1222@@ -2781,7 +2848,7 @@ VOID MlmeCheckPsmChange(
1223 if (INFRA_ON(pAd) &&
1224 (PowerMode != Ndis802_11PowerModeCAM) &&
1225 (pAd->StaCfg.Psm == PWR_ACTIVE) &&
1226- (pAd->Mlme.CntlMachine.CurrState == CNTL_IDLE))
1227+ RTMP_TEST_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP))
1228 {
1229 NdisGetSystemUpTime(&pAd->Mlme.LastSendNULLpsmTime);
1230 pAd->RalinkCounters.RxCountSinceLastNULL = 0;
1231@@ -4065,7 +4132,9 @@ VOID BssTableSsidSort(
1232 continue;
1233
1234 // check group cipher
1235- if (pAd->StaCfg.WepStatus < pInBss->WPA.GroupCipher)
1236+ if ((pAd->StaCfg.WepStatus < pInBss->WPA.GroupCipher) &&
1237+ (pInBss->WPA.GroupCipher != Ndis802_11GroupWEP40Enabled) &&
1238+ (pInBss->WPA.GroupCipher != Ndis802_11GroupWEP104Enabled))
1239 continue;
1240
1241 // check pairwise cipher, skip if none matched
1242@@ -4084,7 +4153,9 @@ VOID BssTableSsidSort(
1243 continue;
1244
1245 // check group cipher
1246- if (pAd->StaCfg.WepStatus < pInBss->WPA2.GroupCipher)
1247+ if ((pAd->StaCfg.WepStatus < pInBss->WPA.GroupCipher) &&
1248+ (pInBss->WPA2.GroupCipher != Ndis802_11GroupWEP40Enabled) &&
1249+ (pInBss->WPA2.GroupCipher != Ndis802_11GroupWEP104Enabled))
1250 continue;
1251
1252 // check pairwise cipher, skip if none matched
1253@@ -4371,8 +4442,10 @@ VOID BssCipherParse(
1254 switch (*pTmp)
1255 {
1256 case 1:
1257- case 5: // Although WEP is not allowed in WPA related auth mode, we parse it anyway
1258- pBss->WPA.GroupCipher = Ndis802_11Encryption1Enabled;
1259+ pBss->WPA.GroupCipher = Ndis802_11GroupWEP40Enabled;
1260+ break;
1261+ case 5:
1262+ pBss->WPA.GroupCipher = Ndis802_11GroupWEP104Enabled;
1263 break;
1264 case 2:
1265 pBss->WPA.GroupCipher = Ndis802_11Encryption2Enabled;
1266@@ -4489,8 +4562,10 @@ VOID BssCipherParse(
1267 switch (pCipher->Type)
1268 {
1269 case 1:
1270- case 5: // Although WEP is not allowed in WPA related auth mode, we parse it anyway
1271- pBss->WPA2.GroupCipher = Ndis802_11Encryption1Enabled;
1272+ pBss->WPA2.GroupCipher = Ndis802_11GroupWEP40Enabled;
1273+ break;
1274+ case 5:
1275+ pBss->WPA2.GroupCipher = Ndis802_11GroupWEP104Enabled;
1276 break;
1277 case 2:
1278 pBss->WPA2.GroupCipher = Ndis802_11Encryption2Enabled;
1279@@ -4953,16 +5028,13 @@ BOOLEAN MlmeDequeue(
1280 VOID MlmeRestartStateMachine(
1281 IN PRTMP_ADAPTER pAd)
1282 {
1283-#ifdef RT2860
1284 MLME_QUEUE_ELEM *Elem = NULL;
1285-#endif // RT2860 //
1286 #ifdef CONFIG_STA_SUPPORT
1287 BOOLEAN Cancelled;
1288 #endif // CONFIG_STA_SUPPORT //
1289
1290 DBGPRINT(RT_DEBUG_TRACE, ("MlmeRestartStateMachine \n"));
1291
1292-#ifdef RT2860
1293 NdisAcquireSpinLock(&pAd->Mlme.TaskLock);
1294 if(pAd->Mlme.bRunning)
1295 {
1296@@ -4990,7 +5062,6 @@ VOID MlmeRestartStateMachine(
1297 DBGPRINT_ERR(("MlmeRestartStateMachine: MlmeQueue empty\n"));
1298 }
1299 }
1300-#endif // RT2860 //
1301
1302 #ifdef CONFIG_STA_SUPPORT
1303 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
1304@@ -5039,12 +5110,10 @@ VOID MlmeRestartStateMachine(
1305 }
1306 #endif // CONFIG_STA_SUPPORT //
1307
1308-#ifdef RT2860
1309 // Remove running state
1310 NdisAcquireSpinLock(&pAd->Mlme.TaskLock);
1311 pAd->Mlme.bRunning = FALSE;
1312 NdisReleaseSpinLock(&pAd->Mlme.TaskLock);
1313-#endif // RT2860 //
1314 }
1315
1316 /*! \brief test if the MLME Queue is empty
1317@@ -6149,6 +6218,12 @@ VOID AsicAdjustTxPower(
1318 ULONG TxPwr[5];
1319 CHAR Value;
1320
1321+ if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE)
1322+ || (pAd->bPCIclkOff == TRUE)
1323+ || RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_IDLE_RADIO_OFF)
1324+ || RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
1325+ return;
1326+
1327 if (pAd->CommonCfg.BBPCurrentBW == BW_40)
1328 {
1329 if (pAd->CommonCfg.CentralChannel > 14)
1330@@ -6493,10 +6568,10 @@ VOID AsicForceSleep(
1331 */
1332 VOID AsicForceWakeup(
1333 IN PRTMP_ADAPTER pAd,
1334- IN BOOLEAN bFromTx)
1335+ IN UCHAR Level)
1336 {
1337 DBGPRINT(RT_DEBUG_TRACE, ("--> AsicForceWakeup \n"));
1338- RT28XX_STA_FORCE_WAKEUP(pAd, bFromTx);
1339+ RT28XX_STA_FORCE_WAKEUP(pAd, Level);
1340 }
1341 #endif // CONFIG_STA_SUPPORT //
1342 /*
1343@@ -6710,7 +6785,6 @@ VOID AsicEnableIbssSync(
1344 csr9.field.bTsfTicking = 0;
1345 RTMP_IO_WRITE32(pAd, BCN_TIME_CFG, csr9.word);
1346
1347-#ifdef RT2860
1348 // move BEACON TXD and frame content to on-chip memory
1349 ptr = (PUCHAR)&pAd->BeaconTxWI;
1350 for (i=0; i<TXWI_SIZE; i+=4) // 16-byte TXWI field
1351@@ -6728,7 +6802,6 @@ VOID AsicEnableIbssSync(
1352 RTMP_IO_WRITE32(pAd, HW_BEACON_BASE0 + TXWI_SIZE + i, longptr);
1353 ptr +=4;
1354 }
1355-#endif // RT2860 //
1356
1357 // start sending BEACON
1358 csr9.field.BeaconInterval = pAd->CommonCfg.BeaconPeriod << 4; // ASIC register in units of 1/16 TU
1359@@ -7097,9 +7170,7 @@ VOID AsicAddSharedKeyEntry(
1360 {
1361 ULONG offset; //, csr0;
1362 SHAREDKEY_MODE_STRUC csr1;
1363-#ifdef RT2860
1364 INT i;
1365-#endif // RT2860 //
1366
1367 DBGPRINT(RT_DEBUG_TRACE, ("AsicAddSharedKeyEntry BssIndex=%d, KeyIdx=%d\n", BssIndex,KeyIdx));
1368 //============================================================================================
1369@@ -7121,7 +7192,6 @@ VOID AsicAddSharedKeyEntry(
1370 //
1371 // fill key material - key + TX MIC + RX MIC
1372 //
1373-#ifdef RT2860
1374 offset = SHARED_KEY_TABLE_BASE + (4*BssIndex + KeyIdx)*HW_KEY_ENTRY_SIZE;
1375 for (i=0; i<MAX_LEN_OF_SHARE_KEY; i++)
1376 {
1377@@ -7145,7 +7215,6 @@ VOID AsicAddSharedKeyEntry(
1378 RTMP_IO_WRITE8(pAd, offset + i, pRxMic[i]);
1379 }
1380 }
1381-#endif // RT2860 //
1382
1383
1384 //
1385@@ -7320,9 +7389,7 @@ VOID AsicAddKeyEntry(
1386 PUCHAR pTxtsc = pCipherKey->TxTsc;
1387 UCHAR CipherAlg = pCipherKey->CipherAlg;
1388 SHAREDKEY_MODE_STRUC csr1;
1389-#ifdef RT2860
1390 UCHAR i;
1391-#endif // RT2860 //
1392
1393 DBGPRINT(RT_DEBUG_TRACE, ("==> AsicAddKeyEntry\n"));
1394 //
1395@@ -7337,7 +7404,6 @@ VOID AsicAddKeyEntry(
1396 // 2.) Set Key to Asic
1397 //
1398 //for (i = 0; i < KeyLen; i++)
1399-#ifdef RT2860
1400 for (i = 0; i < MAX_LEN_OF_PEER_KEY; i++)
1401 {
1402 RTMP_IO_WRITE8(pAd, offset + i, pKey[i]);
1403@@ -7363,7 +7429,6 @@ VOID AsicAddKeyEntry(
1404 RTMP_IO_WRITE8(pAd, offset + i, pRxMic[i]);
1405 }
1406 }
1407-#endif // RT2860 //
1408
1409
1410 //
1411@@ -7372,7 +7437,6 @@ VOID AsicAddKeyEntry(
1412 //
1413 if (bTxKey)
1414 {
1415-#ifdef RT2860
1416 offset = MAC_IVEIV_TABLE_BASE + (WCID * HW_IVEIV_ENTRY_SIZE);
1417 //
1418 // Write IV
1419@@ -7395,7 +7459,6 @@ VOID AsicAddKeyEntry(
1420 {
1421 RTMP_IO_WRITE8(pAd, offset + i, pTxtsc[i + 2]);
1422 }
1423-#endif // RT2860 //
1424
1425 AsicUpdateWCIDAttribute(pAd, WCID, BssIndex, CipherAlg, bUsePairewiseKeyTable);
1426 }
1427@@ -7461,12 +7524,10 @@ VOID AsicAddPairwiseKeyEntry(
1428
1429 // EKEY
1430 offset = PAIRWISE_KEY_TABLE_BASE + (WCID * HW_KEY_ENTRY_SIZE);
1431-#ifdef RT2860
1432 for (i=0; i<MAX_LEN_OF_PEER_KEY; i++)
1433 {
1434 RTMP_IO_WRITE8(pAd, offset + i, pKey[i]);
1435 }
1436-#endif // RT2860 //
1437 for (i=0; i<MAX_LEN_OF_PEER_KEY; i+=4)
1438 {
1439 UINT32 Value;
1440@@ -7478,22 +7539,18 @@ VOID AsicAddPairwiseKeyEntry(
1441 // MIC KEY
1442 if (pTxMic)
1443 {
1444-#ifdef RT2860
1445 for (i=0; i<8; i++)
1446 {
1447 RTMP_IO_WRITE8(pAd, offset+i, pTxMic[i]);
1448 }
1449-#endif // RT2860 //
1450 }
1451 offset += 8;
1452 if (pRxMic)
1453 {
1454-#ifdef RT2860
1455 for (i=0; i<8; i++)
1456 {
1457 RTMP_IO_WRITE8(pAd, offset+i, pRxMic[i]);
1458 }
1459-#endif // RT2860 //
1460 }
1461
1462 DBGPRINT(RT_DEBUG_TRACE,("AsicAddPairwiseKeyEntry: WCID #%d Alg=%s\n",WCID, CipherName[CipherAlg]));
1463@@ -7542,11 +7599,9 @@ BOOLEAN AsicSendCommandToMcu(
1464 HOST_CMD_CSR_STRUC H2MCmd;
1465 H2M_MAILBOX_STRUC H2MMailbox;
1466 ULONG i = 0;
1467-#ifdef RT2860
1468 #ifdef RALINK_ATE
1469 static UINT32 j = 0;
1470 #endif // RALINK_ATE //
1471-#endif // RT2860 //
1472 do
1473 {
1474 RTMP_IO_READ32(pAd, H2M_MAILBOX_CSR, &H2MMailbox.word);
1475@@ -7558,7 +7613,6 @@ BOOLEAN AsicSendCommandToMcu(
1476
1477 if (i >= 100)
1478 {
1479-#ifdef RT2860
1480 #ifdef RALINK_ATE
1481 if (pAd->ate.bFWLoading == TRUE)
1482 {
1483@@ -7583,14 +7637,33 @@ BOOLEAN AsicSendCommandToMcu(
1484 }
1485 else
1486 #endif // RALINK_ATE //
1487-#endif // RT2860 //
1488 {
1489+ UINT32 Data;
1490+
1491+ // Reset DMA
1492+ RTMP_IO_READ32(pAd, PBF_SYS_CTRL, &Data);
1493+ Data |= 0x2;
1494+ RTMP_IO_WRITE32(pAd, PBF_SYS_CTRL, Data);
1495+
1496+ // After Reset DMA, DMA index will become Zero. So Driver need to reset all ring indexs too.
1497+ // Reset DMA/CPU ring index
1498+ RTMPRingCleanUp(pAd, QID_AC_BK);
1499+ RTMPRingCleanUp(pAd, QID_AC_BE);
1500+ RTMPRingCleanUp(pAd, QID_AC_VI);
1501+ RTMPRingCleanUp(pAd, QID_AC_VO);
1502+ RTMPRingCleanUp(pAd, QID_HCCA);
1503+ RTMPRingCleanUp(pAd, QID_MGMT);
1504+ RTMPRingCleanUp(pAd, QID_RX);
1505+
1506+ // Clear Reset
1507+ RTMP_IO_READ32(pAd, PBF_SYS_CTRL, &Data);
1508+ Data &= 0xfffffffd;
1509+ RTMP_IO_WRITE32(pAd, PBF_SYS_CTRL, Data);
1510 DBGPRINT_ERR(("H2M_MAILBOX still hold by MCU. command fail\n"));
1511 }
1512- return FALSE;
1513+ //return FALSE;
1514 }
1515
1516-#ifdef RT2860
1517 #ifdef RALINK_ATE
1518 else if (pAd->ate.bFWLoading == TRUE)
1519 {
1520@@ -7600,7 +7673,6 @@ BOOLEAN AsicSendCommandToMcu(
1521 j = 0;
1522 }
1523 #endif // RALINK_ATE //
1524-#endif // RT2860 //
1525
1526 H2MMailbox.field.Owner = 1; // pass ownership to MCU
1527 H2MMailbox.field.CmdToken = Token;
1528@@ -7619,7 +7691,6 @@ BOOLEAN AsicSendCommandToMcu(
1529 return TRUE;
1530 }
1531
1532-#ifdef RT2860
1533 BOOLEAN AsicCheckCommanOk(
1534 IN PRTMP_ADAPTER pAd,
1535 IN UCHAR Command)
1536@@ -7684,7 +7755,6 @@ BOOLEAN AsicCheckCommanOk(
1537
1538 return FALSE;
1539 }
1540-#endif // RT2860 //
1541
1542 /*
1543 ========================================================================
1544@@ -8096,10 +8166,8 @@ VOID AsicEvaluateRxAnt(
1545 }
1546 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BBPR3);
1547 #ifdef CONFIG_STA_SUPPORT
1548-#ifdef RT2860
1549 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
1550 pAd->StaCfg.BBPR3 = BBPR3;
1551-#endif // RT2860 //
1552 #endif // CONFIG_STA_SUPPORT //
1553 if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED)
1554 )
1555@@ -8211,9 +8279,7 @@ VOID AsicRxAntEvalTimeout(
1556 BBPR3 |= (0x0);
1557 }
1558 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BBPR3);
1559-#ifdef RT2860
1560- pAd->StaCfg.BBPR3 = BBPR3;
1561-#endif // RT2860 //
1562+ pAd->StaCfg.BBPR3 = BBPR3;
1563 }
1564
1565 #endif // CONFIG_STA_SUPPORT //
1566@@ -8439,10 +8505,7 @@ VOID AsicStaBbpTuning(
1567 && (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED)
1568 )
1569 && !(OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
1570-#ifdef RT2860
1571- && (pAd->bPCIclkOff == FALSE)
1572-#endif // RT2860 //
1573- )
1574+ && (pAd->bPCIclkOff == FALSE))
1575 {
1576 RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R66, &OrigR66Value);
1577 R66 = OrigR66Value;
1578@@ -8518,6 +8581,106 @@ VOID AsicStaBbpTuning(
1579
1580 }
1581 }
1582+
1583+VOID AsicResetFromDMABusy(
1584+ IN PRTMP_ADAPTER pAd)
1585+{
1586+ UINT32 Data;
1587+ BOOLEAN bCtrl = FALSE;
1588+
1589+ DBGPRINT(RT_DEBUG_TRACE, ("---> AsicResetFromDMABusy !!!!!!!!!!!!!!!!!!!!!!! \n"));
1590+
1591+ // Be sure restore link control value so we can write register.
1592+ RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
1593+ if (RTMP_TEST_PSFLAG(pAd, fRTMP_PS_SET_PCI_CLK_OFF_COMMAND))
1594+ {
1595+ DBGPRINT(RT_DEBUG_TRACE,("AsicResetFromDMABusy==>\n"));
1596+ RTMPPCIeLinkCtrlValueRestore(pAd, RESTORE_HALT);
1597+ RTMPusecDelay(6000);
1598+ pAd->bPCIclkOff = FALSE;
1599+ bCtrl = TRUE;
1600+ }
1601+ // Reset DMA
1602+ RTMP_IO_READ32(pAd, PBF_SYS_CTRL, &Data);
1603+ Data |= 0x2;
1604+ RTMP_IO_WRITE32(pAd, PBF_SYS_CTRL, Data);
1605+
1606+ // After Reset DMA, DMA index will become Zero. So Driver need to reset all ring indexs too.
1607+ // Reset DMA/CPU ring index
1608+ RTMPRingCleanUp(pAd, QID_AC_BK);
1609+ RTMPRingCleanUp(pAd, QID_AC_BE);
1610+ RTMPRingCleanUp(pAd, QID_AC_VI);
1611+ RTMPRingCleanUp(pAd, QID_AC_VO);
1612+ RTMPRingCleanUp(pAd, QID_HCCA);
1613+ RTMPRingCleanUp(pAd, QID_MGMT);
1614+ RTMPRingCleanUp(pAd, QID_RX);
1615+
1616+ // Clear Reset
1617+ RTMP_IO_READ32(pAd, PBF_SYS_CTRL, &Data);
1618+ Data &= 0xfffffffd;
1619+ RTMP_IO_WRITE32(pAd, PBF_SYS_CTRL, Data);
1620+
1621+ // If in Radio off, should call RTMPPCIePowerLinkCtrl again.
1622+ if ((bCtrl == TRUE) && (pAd->StaCfg.bRadio == FALSE))
1623+ RTMPPCIeLinkCtrlSetting(pAd, 3);
1624+
1625+ RTMP_SET_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
1626+ RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST | fRTMP_ADAPTER_HALT_IN_PROGRESS);
1627+ DBGPRINT(RT_DEBUG_TRACE, ("<--- AsicResetFromDMABusy !!!!!!!!!!!!!!!!!!!!!!! \n"));
1628+}
1629+
1630+VOID AsicResetBBP(
1631+ IN PRTMP_ADAPTER pAd)
1632+{
1633+ DBGPRINT(RT_DEBUG_TRACE, ("---> Asic HardReset BBP !!!!!!!!!!!!!!!!!!!!!!! \n"));
1634+
1635+ RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0x0);
1636+ RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0x2);
1637+ RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0xc);
1638+
1639+ // After hard-reset BBP, initialize all BBP values.
1640+ NICRestoreBBPValue(pAd);
1641+ DBGPRINT(RT_DEBUG_TRACE, ("<--- Asic HardReset BBP !!!!!!!!!!!!!!!!!!!!!!! \n"));
1642+}
1643+
1644+VOID AsicResetMAC(
1645+ IN PRTMP_ADAPTER pAd)
1646+{
1647+ ULONG Data;
1648+
1649+ DBGPRINT(RT_DEBUG_TRACE, ("---> AsicResetMAC !!!! \n"));
1650+ RTMP_IO_READ32(pAd, PBF_SYS_CTRL, &Data);
1651+ Data |= 0x4;
1652+ RTMP_IO_WRITE32(pAd, PBF_SYS_CTRL, Data);
1653+ Data &= 0xfffffffb;
1654+ RTMP_IO_WRITE32(pAd, PBF_SYS_CTRL, Data);
1655+
1656+ DBGPRINT(RT_DEBUG_TRACE, ("<--- AsicResetMAC !!!! \n"));
1657+}
1658+
1659+VOID AsicResetPBF(
1660+ IN PRTMP_ADAPTER pAd)
1661+{
1662+ ULONG Value1, Value2;
1663+ ULONG Data;
1664+
1665+ RTMP_IO_READ32(pAd, TXRXQ_PCNT, &Value1);
1666+ RTMP_IO_READ32(pAd, PBF_DBG, &Value2);
1667+
1668+ Value2 &= 0xff;
1669+ // sum should be equals to 0xff, which is the total buffer size.
1670+ if ((Value1 + Value2) < 0xff)
1671+ {
1672+ DBGPRINT(RT_DEBUG_TRACE, ("---> Asic HardReset PBF !!!! \n"));
1673+ RTMP_IO_READ32(pAd, PBF_SYS_CTRL, &Data);
1674+ Data |= 0x8;
1675+ RTMP_IO_WRITE32(pAd, PBF_SYS_CTRL, Data);
1676+ Data &= 0xfffffff7;
1677+ RTMP_IO_WRITE32(pAd, PBF_SYS_CTRL, Data);
1678+
1679+ DBGPRINT(RT_DEBUG_TRACE, ("<--- Asic HardReset PBF !!!! \n"));
1680+ }
1681+}
1682 #endif // CONFIG_STA_SUPPORT //
1683
1684 VOID RTMPSetAGCInitValue(
1685--- a/drivers/staging/rt2860/common/rtmp_init.c
1686+++ b/drivers/staging/rt2860/common/rtmp_init.c
1687@@ -39,6 +39,7 @@
1688 */
1689 #include "../rt_config.h"
1690 #include "firmware.h"
1691+#include <linux/bitrev.h>
1692
1693 UCHAR BIT8[] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80};
1694 ULONG BIT32[] = {0x00000001, 0x00000002, 0x00000004, 0x00000008,
1695@@ -89,20 +90,6 @@ const unsigned short ccitt_16Table[] = {
1696 #define ByteCRC16(v, crc) \
1697 (unsigned short)((crc << 8) ^ ccitt_16Table[((crc >> 8) ^ (v)) & 255])
1698
1699-unsigned char BitReverse(unsigned char x)
1700-{
1701- int i;
1702- unsigned char Temp=0;
1703- for(i=0; ; i++)
1704- {
1705- if(x & 0x80) Temp |= 0x80;
1706- if(i==7) break;
1707- x <<= 1;
1708- Temp >>= 1;
1709- }
1710- return Temp;
1711-}
1712-
1713 //
1714 // BBP register initialization set
1715 //
1716@@ -162,9 +149,7 @@ RTMP_REG_PAIR MACRegTable[] = {
1717 {GF20_PROT_CFG, 0x01744004}, // set 19:18 --> Short NAV for MIMO PS
1718 {GF40_PROT_CFG, 0x03F44084},
1719 {MM20_PROT_CFG, 0x01744004},
1720-#ifdef RT2860
1721 {MM40_PROT_CFG, 0x03F54084},
1722-#endif // RT2860 //
1723 {TXOP_CTRL_CFG, 0x0000583f, /*0x0000243f*/ /*0x000024bf*/}, //Extension channel backoff.
1724 {TX_RTS_CFG, 0x00092b20},
1725 {EXP_ACK_TIME, 0x002400ca}, // default value
1726@@ -201,9 +186,7 @@ RTMP_REG_PAIR STAMACRegTable[] = {
1727 #define FIRMWAREIMAGEV1_LENGTH 0x1000
1728 #define FIRMWAREIMAGEV2_LENGTH 0x1000
1729
1730-#ifdef RT2860
1731 #define FIRMWARE_MINOR_VERSION 2
1732-#endif // RT2860 //
1733
1734
1735 /*
1736@@ -261,9 +244,7 @@ NDIS_STATUS RTMPAllocAdapterBlock(
1737
1738 // Init spin locks
1739 NdisAllocateSpinLock(&pAd->MgmtRingLock);
1740-#ifdef RT2860
1741 NdisAllocateSpinLock(&pAd->RxRingLock);
1742-#endif // RT2860 //
1743
1744 for (index =0 ; index < NUM_OF_TX_RING; index++)
1745 {
1746@@ -1568,10 +1549,7 @@ VOID NICInitAsicFromEEPROM(
1747 pAd->LedCntl.word = 0x01;
1748 pAd->Led1 = 0x5555;
1749 pAd->Led2 = 0x2221;
1750-
1751-#ifdef RT2860
1752 pAd->Led3 = 0xA9F8;
1753-#endif // RT2860 //
1754 }
1755
1756 AsicSendCommandToMcu(pAd, 0x52, 0xff, (UCHAR)pAd->Led1, (UCHAR)(pAd->Led1 >> 8));
1757@@ -1607,12 +1585,10 @@ VOID NICInitAsicFromEEPROM(
1758 else
1759 {
1760 RTMPSetLED(pAd, LED_RADIO_ON);
1761-#ifdef RT2860
1762 AsicSendCommandToMcu(pAd, 0x30, 0xff, 0xff, 0x02);
1763 AsicSendCommandToMcu(pAd, 0x31, PowerWakeCID, 0x00, 0x00);
1764 // 2-1. wait command ok.
1765 AsicCheckCommanOk(pAd, PowerWakeCID);
1766-#endif // RT2860 //
1767 }
1768 }
1769 #endif // CONFIG_STA_SUPPORT //
1770@@ -1690,10 +1666,8 @@ NDIS_STATUS NICInitializeAdapter(
1771 {
1772 NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
1773 WPDMA_GLO_CFG_STRUC GloCfg;
1774-#ifdef RT2860
1775 UINT32 Value;
1776 DELAY_INT_CFG_STRUC IntCfg;
1777-#endif // RT2860 //
1778 ULONG i =0, j=0;
1779 AC_TXOP_CSR0_STRUC csr0;
1780
1781@@ -1732,11 +1706,9 @@ retry:
1782
1783 // asic simulation sequence put this ahead before loading firmware.
1784 // pbf hardware reset
1785-#ifdef RT2860
1786 RTMP_IO_WRITE32(pAd, WPDMA_RST_IDX, 0x1003f); // 0x10000 for reset rx, 0x3f resets all 6 tx rings.
1787 RTMP_IO_WRITE32(pAd, PBF_SYS_CTRL, 0xe1f);
1788 RTMP_IO_WRITE32(pAd, PBF_SYS_CTRL, 0xe00);
1789-#endif // RT2860 //
1790
1791 // Initialze ASIC for TX & Rx operation
1792 if (NICInitializeAsic(pAd , bHardReset) != NDIS_STATUS_SUCCESS)
1793@@ -1750,7 +1722,6 @@ retry:
1794 }
1795
1796
1797-#ifdef RT2860
1798 // Write AC_BK base address register
1799 Value = RTMP_GetPhysicalAddressLow(pAd->TxRing[QID_AC_BK].Cell[0].AllocPa);
1800 RTMP_IO_WRITE32(pAd, TX_BASE_PTR1, Value);
1801@@ -1823,7 +1794,6 @@ retry:
1802 // Write RX_RING_CSR register
1803 Value = RX_RING_SIZE;
1804 RTMP_IO_WRITE32(pAd, RX_MAX_CNT, Value);
1805-#endif // RT2860 //
1806
1807
1808 // WMM parameter
1809@@ -1842,7 +1812,6 @@ retry:
1810 RTMP_IO_WRITE32(pAd, WMM_TXOP1_CFG, csr0.word);
1811
1812
1813-#ifdef RT2860
1814 // 3. Set DMA global configuration except TX_DMA_EN and RX_DMA_EN bits:
1815 i = 0;
1816 do
1817@@ -1861,7 +1830,6 @@ retry:
1818
1819 IntCfg.word = 0;
1820 RTMP_IO_WRITE32(pAd, DELAY_INT_CFG, IntCfg.word);
1821-#endif // RT2860 //
1822
1823
1824 // reset action
1825@@ -1902,7 +1870,6 @@ NDIS_STATUS NICInitializeAsic(
1826
1827 DBGPRINT(RT_DEBUG_TRACE, ("--> NICInitializeAsic\n"));
1828
1829-#ifdef RT2860
1830 if (bHardReset == TRUE)
1831 {
1832 RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0x3);
1833@@ -1927,7 +1894,6 @@ NDIS_STATUS NICInitializeAsic(
1834 }
1835 }
1836 #endif // CONFIG_STA_SUPPORT //
1837-#endif // RT2860 //
1838
1839
1840 //
1841@@ -2054,6 +2020,131 @@ NDIS_STATUS NICInitializeAsic(
1842 return NDIS_STATUS_SUCCESS;
1843 }
1844
1845+
1846+VOID NICRestoreBBPValue(
1847+ IN PRTMP_ADAPTER pAd)
1848+{
1849+ UCHAR index;
1850+ UCHAR Value = 0;
1851+ ULONG Data;
1852+
1853+ DBGPRINT(RT_DEBUG_TRACE, ("---> NICRestoreBBPValue !!!!!!!!!!!!!!!!!!!!!!! \n"));
1854+ // Initialize BBP register to default value (rtmp_init.c)
1855+ for (index = 0; index < NUM_BBP_REG_PARMS; index++)
1856+ {
1857+ RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBPRegTable[index].Register, BBPRegTable[index].Value);
1858+ }
1859+ // copy from (rtmp_init.c)
1860+ if (pAd->MACVersion == 0x28600100)
1861+ {
1862+ RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R69, 0x16);
1863+ RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R73, 0x12);
1864+ }
1865+
1866+ // copy from (connect.c LinkUp function)
1867+ if (INFRA_ON(pAd))
1868+ {
1869+ // Change to AP channel
1870+ if ((pAd->CommonCfg.CentralChannel > pAd->CommonCfg.Channel) && (pAd->MlmeAux.HtCapability.HtCapInfo.ChannelWidth == BW_40))
1871+ {
1872+ // Must using 40MHz.
1873+ pAd->CommonCfg.BBPCurrentBW = BW_40;
1874+ AsicSwitchChannel(pAd, pAd->CommonCfg.CentralChannel, FALSE);
1875+ AsicLockChannel(pAd, pAd->CommonCfg.CentralChannel);
1876+
1877+ RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &Value);
1878+ Value &= (~0x18);
1879+ Value |= 0x10;
1880+ RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, Value);
1881+
1882+ // RX : control channel at lower
1883+ RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &Value);
1884+ Value &= (~0x20);
1885+ RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, Value);
1886+ // Record BBPR3 setting, But don't keep R Antenna # information.
1887+ pAd->StaCfg.BBPR3 = Value;
1888+
1889+ RTMP_IO_READ32(pAd, TX_BAND_CFG, &Data);
1890+ Data &= 0xfffffffe;
1891+ RTMP_IO_WRITE32(pAd, TX_BAND_CFG, Data);
1892+
1893+ if (pAd->MACVersion == 0x28600100)
1894+ {
1895+ RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R69, 0x1A);
1896+ RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R70, 0x0A);
1897+ RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R73, 0x16);
1898+ DBGPRINT(RT_DEBUG_TRACE, ("!!!rt2860C !!! \n" ));
1899+ }
1900+
1901+ DBGPRINT(RT_DEBUG_TRACE, ("!!!40MHz Lower LINK UP !!! Control Channel at Below. Central = %d \n", pAd->CommonCfg.CentralChannel ));
1902+ }
1903+ else if ((pAd->CommonCfg.CentralChannel < pAd->CommonCfg.Channel) && (pAd->MlmeAux.HtCapability.HtCapInfo.ChannelWidth == BW_40))
1904+ {
1905+ // Must using 40MHz.
1906+ pAd->CommonCfg.BBPCurrentBW = BW_40;
1907+ AsicSwitchChannel(pAd, pAd->CommonCfg.CentralChannel, FALSE);
1908+ AsicLockChannel(pAd, pAd->CommonCfg.CentralChannel);
1909+
1910+ RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &Value);
1911+ Value &= (~0x18);
1912+ Value |= 0x10;
1913+ RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, Value);
1914+
1915+ RTMP_IO_READ32(pAd, TX_BAND_CFG, &Data);
1916+ Data |= 0x1;
1917+ RTMP_IO_WRITE32(pAd, TX_BAND_CFG, Data);
1918+
1919+ RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &Value);
1920+ Value |= (0x20);
1921+ RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, Value);
1922+ // Record BBPR3 setting, But don't keep R Antenna # information.
1923+ pAd->StaCfg.BBPR3 = Value;
1924+
1925+ if (pAd->MACVersion == 0x28600100)
1926+ {
1927+ RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R69, 0x1A);
1928+ RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R70, 0x0A);
1929+ RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R73, 0x16);
1930+ DBGPRINT(RT_DEBUG_TRACE, ("!!!rt2860C !!! \n" ));
1931+ }
1932+
1933+ DBGPRINT(RT_DEBUG_TRACE, ("!!!40MHz Upper LINK UP !!! Control Channel at UpperCentral = %d \n", pAd->CommonCfg.CentralChannel ));
1934+ }
1935+ else
1936+ {
1937+ pAd->CommonCfg.BBPCurrentBW = BW_20;
1938+ AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
1939+ AsicLockChannel(pAd, pAd->CommonCfg.Channel);
1940+
1941+ RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &Value);
1942+ Value &= (~0x18);
1943+ RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, Value);
1944+
1945+ RTMP_IO_READ32(pAd, TX_BAND_CFG, &Data);
1946+ Data &= 0xfffffffe;
1947+ RTMP_IO_WRITE32(pAd, TX_BAND_CFG, Data);
1948+
1949+ RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &Value);
1950+ Value &= (~0x20);
1951+ RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, Value);
1952+ // Record BBPR3 setting, But don't keep R Antenna # information.
1953+ pAd->StaCfg.BBPR3 = Value;
1954+
1955+ if (pAd->MACVersion == 0x28600100)
1956+ {
1957+ RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R69, 0x16);
1958+ RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R70, 0x08);
1959+ RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R73, 0x11);
1960+ DBGPRINT(RT_DEBUG_TRACE, ("!!!rt2860C !!! \n" ));
1961+ }
1962+
1963+ DBGPRINT(RT_DEBUG_TRACE, ("!!!20MHz LINK UP !!! \n" ));
1964+ }
1965+ }
1966+
1967+ DBGPRINT(RT_DEBUG_TRACE, ("<--- NICRestoreBBPValue !!!!!!!!!!!!!!!!!!!!!!! \n"));
1968+}
1969+
1970 /*
1971 ========================================================================
1972
1973@@ -2555,7 +2646,7 @@ NDIS_STATUS NICLoadFirmware(
1974 #ifdef BIN_IN_FILE
1975 #define NICLF_DEFAULT_USE() \
1976 flg_default_firm_use = TRUE; \
1977- printk("%s - Use default firmware!\n", __FUNCTION__);
1978+ printk("%s - Use default firmware!\n", __func__);
1979
1980 NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
1981 PUCHAR src;
1982@@ -2570,7 +2661,7 @@ NDIS_STATUS NICLoadFirmware(
1983 BOOLEAN flg_default_firm_use = FALSE;
1984
1985
1986- DBGPRINT(RT_DEBUG_TRACE, ("===> %s\n", __FUNCTION__));
1987+ DBGPRINT(RT_DEBUG_TRACE, ("===> %s\n", __func__));
1988
1989 /* init */
1990 pFirmwareImage = NULL;
1991@@ -2593,7 +2684,7 @@ NDIS_STATUS NICLoadFirmware(
1992 if (pFirmwareImage == NULL)
1993 {
1994 /* allocate fail, use default firmware array in firmware.h */
1995- printk("%s - Allocate memory fail!\n", __FUNCTION__);
1996+ printk("%s - Allocate memory fail!\n", __func__);
1997 NICLF_DEFAULT_USE();
1998 }
1999 else
2000@@ -2614,7 +2705,7 @@ NDIS_STATUS NICLoadFirmware(
2001 if (IS_ERR(srcf))
2002 {
2003 printk("%s - Error %ld opening %s\n",
2004- __FUNCTION__, -PTR_ERR(srcf), src);
2005+ __func__, -PTR_ERR(srcf), src);
2006 NICLF_DEFAULT_USE();
2007 break;
2008 } /* End of if */
2009@@ -2622,7 +2713,7 @@ NDIS_STATUS NICLoadFirmware(
2010 /* the object must have a read method */
2011 if ((srcf->f_op == NULL) || (srcf->f_op->read == NULL))
2012 {
2013- printk("%s - %s does not have a write method\n", __FUNCTION__, src);
2014+ printk("%s - %s does not have a write method\n", __func__, src);
2015 NICLF_DEFAULT_USE();
2016 break;
2017 } /* End of if */
2018@@ -2636,7 +2727,7 @@ NDIS_STATUS NICLoadFirmware(
2019 if (FileLength != MAX_FIRMWARE_IMAGE_SIZE)
2020 {
2021 printk("%s: error file length (=%d) in RT2860AP.BIN\n",
2022- __FUNCTION__, FileLength);
2023+ __func__, FileLength);
2024 NICLF_DEFAULT_USE();
2025 break;
2026 }
2027@@ -2648,18 +2739,18 @@ NDIS_STATUS NICLoadFirmware(
2028
2029 /* calculate firmware CRC */
2030 for(i=0; i<(MAX_FIRMWARE_IMAGE_SIZE-2); i++, ptr++)
2031- crc = ByteCRC16(BitReverse(*ptr), crc);
2032+ crc = ByteCRC16(bitrev8(*ptr), crc);
2033 /* End of for */
2034
2035 if ((pFirmwareImage[MAX_FIRMWARE_IMAGE_SIZE-2] != \
2036- (UCHAR)BitReverse((UCHAR)(crc>>8))) ||
2037+ (UCHAR)bitrev8((UCHAR)(crc>>8))) ||
2038 (pFirmwareImage[MAX_FIRMWARE_IMAGE_SIZE-1] != \
2039- (UCHAR)BitReverse((UCHAR)crc)))
2040+ (UCHAR)bitrev8((UCHAR)crc)))
2041 {
2042 /* CRC fail */
2043 printk("%s: CRC = 0x%02x 0x%02x "
2044 "error, should be 0x%02x 0x%02x\n",
2045- __FUNCTION__,
2046+ __func__,
2047 pFirmwareImage[MAX_FIRMWARE_IMAGE_SIZE-2],
2048 pFirmwareImage[MAX_FIRMWARE_IMAGE_SIZE-1],
2049 (UCHAR)(crc>>8), (UCHAR)(crc));
2050@@ -2678,7 +2769,7 @@ NDIS_STATUS NICLoadFirmware(
2051 ((FIRMWARE_MAJOR_VERSION << 8) +
2052 FIRMWARE_MINOR_VERSION))
2053 {
2054- printk("%s: firmware version too old!\n", __FUNCTION__);
2055+ printk("%s: firmware version too old!\n", __func__);
2056 NICLF_DEFAULT_USE();
2057 break;
2058 } /* End of if */
2059@@ -2783,7 +2874,7 @@ NDIS_STATUS NICLoadFirmware(
2060 } /* End of if */
2061
2062 DBGPRINT(RT_DEBUG_TRACE,
2063- ("<=== %s (status=%d)\n", __FUNCTION__, Status));
2064+ ("<=== %s (status=%d)\n", __func__, Status));
2065 return Status;
2066 } /* End of NICLoadFirmware */
2067
2068@@ -3041,11 +3132,10 @@ VOID UserCfgInit(
2069 pAd->CommonCfg.BBPCurrentBW = BW_20;
2070
2071 pAd->LedCntl.word = 0;
2072-#ifdef RT2860
2073 pAd->LedIndicatorStregth = 0;
2074 pAd->RLnkCtrlOffset = 0;
2075 pAd->HostLnkCtrlOffset = 0;
2076-#endif // RT2860 //
2077+ pAd->CheckDmaBusyCount = 0;
2078
2079 pAd->bAutoTxAgcA = FALSE; // Default is OFF
2080 pAd->bAutoTxAgcG = FALSE; // Default is OFF
2081@@ -3305,9 +3395,7 @@ VOID UserCfgInit(
2082 pAd->ate.bRxFer = 0;
2083 pAd->ate.bQATxStart = FALSE;
2084 pAd->ate.bQARxStart = FALSE;
2085-#ifdef RT2860
2086 pAd->ate.bFWLoading = FALSE;
2087-#endif // RT2860 //
2088 #ifdef RALINK_28xx_QA
2089 //pAd->ate.Repeat = 0;
2090 pAd->ate.TxStatus = 0;
2091@@ -3317,11 +3405,9 @@ VOID UserCfgInit(
2092
2093
2094 pAd->CommonCfg.bWiFiTest = FALSE;
2095-#ifdef RT2860
2096- pAd->bPCIclkOff = FALSE;
2097-#endif // RT2860 //
2098-
2099+ pAd->bPCIclkOff = FALSE;
2100
2101+ RTMP_SET_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
2102 DBGPRINT(RT_DEBUG_TRACE, ("<-- UserCfgInit\n"));
2103 }
2104
2105--- a/drivers/staging/rt2860/common/spectrum.c
2106+++ b/drivers/staging/rt2860/common/spectrum.c
2107@@ -49,7 +49,7 @@ VOID MeasureReqTabInit(
2108 if (pAd->CommonCfg.pMeasureReqTab)
2109 NdisZeroMemory(pAd->CommonCfg.pMeasureReqTab, sizeof(MEASURE_REQ_TAB));
2110 else
2111- DBGPRINT(RT_DEBUG_ERROR, ("%s Fail to alloc memory for pAd->CommonCfg.pMeasureReqTab.\n", __FUNCTION__));
2112+ DBGPRINT(RT_DEBUG_ERROR, ("%s Fail to alloc memory for pAd->CommonCfg.pMeasureReqTab.\n", __func__));
2113
2114 return;
2115 }
2116@@ -77,7 +77,7 @@ static PMEASURE_REQ_ENTRY MeasureReqLook
2117
2118 if (pTab == NULL)
2119 {
2120- DBGPRINT(RT_DEBUG_ERROR, ("%s: pMeasureReqTab doesn't exist.\n", __FUNCTION__));
2121+ DBGPRINT(RT_DEBUG_ERROR, ("%s: pMeasureReqTab doesn't exist.\n", __func__));
2122 return NULL;
2123 }
2124
2125@@ -114,7 +114,7 @@ static PMEASURE_REQ_ENTRY MeasureReqInse
2126
2127 if(pTab == NULL)
2128 {
2129- DBGPRINT(RT_DEBUG_ERROR, ("%s: pMeasureReqTab doesn't exist.\n", __FUNCTION__));
2130+ DBGPRINT(RT_DEBUG_ERROR, ("%s: pMeasureReqTab doesn't exist.\n", __func__));
2131 return NULL;
2132 }
2133
2134@@ -175,7 +175,7 @@ static PMEASURE_REQ_ENTRY MeasureReqInse
2135 else
2136 {
2137 pEntry = NULL;
2138- DBGPRINT(RT_DEBUG_ERROR, ("%s: pMeasureReqTab tab full.\n", __FUNCTION__));
2139+ DBGPRINT(RT_DEBUG_ERROR, ("%s: pMeasureReqTab tab full.\n", __func__));
2140 }
2141
2142 // add this Neighbor entry into HASH table
2143@@ -210,7 +210,7 @@ static VOID MeasureReqDelete(
2144
2145 if(pTab == NULL)
2146 {
2147- DBGPRINT(RT_DEBUG_ERROR, ("%s: pMeasureReqTab doesn't exist.\n", __FUNCTION__));
2148+ DBGPRINT(RT_DEBUG_ERROR, ("%s: pMeasureReqTab doesn't exist.\n", __func__));
2149 return;
2150 }
2151
2152@@ -267,7 +267,7 @@ VOID TpcReqTabInit(
2153 if (pAd->CommonCfg.pTpcReqTab)
2154 NdisZeroMemory(pAd->CommonCfg.pTpcReqTab, sizeof(TPC_REQ_TAB));
2155 else
2156- DBGPRINT(RT_DEBUG_ERROR, ("%s Fail to alloc memory for pAd->CommonCfg.pTpcReqTab.\n", __FUNCTION__));
2157+ DBGPRINT(RT_DEBUG_ERROR, ("%s Fail to alloc memory for pAd->CommonCfg.pTpcReqTab.\n", __func__));
2158
2159 return;
2160 }
2161@@ -295,7 +295,7 @@ static PTPC_REQ_ENTRY TpcReqLookUp(
2162
2163 if (pTab == NULL)
2164 {
2165- DBGPRINT(RT_DEBUG_ERROR, ("%s: pTpcReqTab doesn't exist.\n", __FUNCTION__));
2166+ DBGPRINT(RT_DEBUG_ERROR, ("%s: pTpcReqTab doesn't exist.\n", __func__));
2167 return NULL;
2168 }
2169
2170@@ -333,7 +333,7 @@ static PTPC_REQ_ENTRY TpcReqInsert(
2171
2172 if(pTab == NULL)
2173 {
2174- DBGPRINT(RT_DEBUG_ERROR, ("%s: pTpcReqTab doesn't exist.\n", __FUNCTION__));
2175+ DBGPRINT(RT_DEBUG_ERROR, ("%s: pTpcReqTab doesn't exist.\n", __func__));
2176 return NULL;
2177 }
2178
2179@@ -394,7 +394,7 @@ static PTPC_REQ_ENTRY TpcReqInsert(
2180 else
2181 {
2182 pEntry = NULL;
2183- DBGPRINT(RT_DEBUG_ERROR, ("%s: pTpcReqTab tab full.\n", __FUNCTION__));
2184+ DBGPRINT(RT_DEBUG_ERROR, ("%s: pTpcReqTab tab full.\n", __func__));
2185 }
2186
2187 // add this Neighbor entry into HASH table
2188@@ -429,7 +429,7 @@ static VOID TpcReqDelete(
2189
2190 if(pTab == NULL)
2191 {
2192- DBGPRINT(RT_DEBUG_ERROR, ("%s: pTpcReqTab doesn't exist.\n", __FUNCTION__));
2193+ DBGPRINT(RT_DEBUG_ERROR, ("%s: pTpcReqTab doesn't exist.\n", __func__));
2194 return;
2195 }
2196
2197@@ -782,7 +782,7 @@ VOID EnqueueMeasurementReq(
2198 NStatus = MlmeAllocateMemory(pAd, (PVOID)&pOutBuffer); //Get an unused nonpaged memory
2199 if(NStatus != NDIS_STATUS_SUCCESS)
2200 {
2201- DBGPRINT(RT_DEBUG_TRACE, ("%s() allocate memory failed \n", __FUNCTION__));
2202+ DBGPRINT(RT_DEBUG_TRACE, ("%s() allocate memory failed \n", __func__));
2203 return;
2204 }
2205 NdisMoveMemory(pOutBuffer, (PCHAR)&ActHdr, sizeof(HEADER_802_11));
2206@@ -844,7 +844,7 @@ VOID EnqueueMeasurementRep(
2207 NStatus = MlmeAllocateMemory(pAd, (PVOID)&pOutBuffer); //Get an unused nonpaged memory
2208 if(NStatus != NDIS_STATUS_SUCCESS)
2209 {
2210- DBGPRINT(RT_DEBUG_TRACE, ("%s() allocate memory failed \n", __FUNCTION__));
2211+ DBGPRINT(RT_DEBUG_TRACE, ("%s() allocate memory failed \n", __func__));
2212 return;
2213 }
2214 NdisMoveMemory(pOutBuffer, (PCHAR)&ActHdr, sizeof(HEADER_802_11));
2215@@ -898,7 +898,7 @@ VOID EnqueueTPCReq(
2216 NStatus = MlmeAllocateMemory(pAd, (PVOID)&pOutBuffer); //Get an unused nonpaged memory
2217 if(NStatus != NDIS_STATUS_SUCCESS)
2218 {
2219- DBGPRINT(RT_DEBUG_TRACE, ("%s() allocate memory failed \n", __FUNCTION__));
2220+ DBGPRINT(RT_DEBUG_TRACE, ("%s() allocate memory failed \n", __func__));
2221 return;
2222 }
2223 NdisMoveMemory(pOutBuffer, (PCHAR)&ActHdr, sizeof(HEADER_802_11));
2224@@ -950,7 +950,7 @@ VOID EnqueueTPCRep(
2225 NStatus = MlmeAllocateMemory(pAd, (PVOID)&pOutBuffer); //Get an unused nonpaged memory
2226 if(NStatus != NDIS_STATUS_SUCCESS)
2227 {
2228- DBGPRINT(RT_DEBUG_TRACE, ("%s() allocate memory failed \n", __FUNCTION__));
2229+ DBGPRINT(RT_DEBUG_TRACE, ("%s() allocate memory failed \n", __func__));
2230 return;
2231 }
2232 NdisMoveMemory(pOutBuffer, (PCHAR)&ActHdr, sizeof(HEADER_802_11));
2233@@ -1003,7 +1003,7 @@ VOID EnqueueChSwAnn(
2234 NStatus = MlmeAllocateMemory(pAd, (PVOID)&pOutBuffer); //Get an unused nonpaged memory
2235 if(NStatus != NDIS_STATUS_SUCCESS)
2236 {
2237- DBGPRINT(RT_DEBUG_TRACE, ("%s() allocate memory failed \n", __FUNCTION__));
2238+ DBGPRINT(RT_DEBUG_TRACE, ("%s() allocate memory failed \n", __func__));
2239 return;
2240 }
2241 NdisMoveMemory(pOutBuffer, (PCHAR)&ActHdr, sizeof(HEADER_802_11));
2242@@ -1596,7 +1596,7 @@ static VOID PeerMeasureReportAction(
2243
2244 if ((pMeasureReportInfo = kmalloc(sizeof(MEASURE_RPI_REPORT), GFP_ATOMIC)) == NULL)
2245 {
2246- DBGPRINT(RT_DEBUG_ERROR, ("%s unable to alloc memory for measure report buffer (size=%d).\n", __FUNCTION__, sizeof(MEASURE_RPI_REPORT)));
2247+ DBGPRINT(RT_DEBUG_ERROR, ("%s unable to alloc memory for measure report buffer (size=%zu).\n", __func__, sizeof(MEASURE_RPI_REPORT)));
2248 return;
2249 }
2250
2251@@ -1705,7 +1705,7 @@ static VOID PeerTpcRepAction(
2252 {
2253 TpcReqDelete(pAd, pEntry->DialogToken);
2254 DBGPRINT(RT_DEBUG_TRACE, ("%s: DialogToken=%x, TxPwr=%d, LinkMargin=%d\n",
2255- __FUNCTION__, DialogToken, TpcRepInfo.TxPwr, TpcRepInfo.LinkMargin));
2256+ __func__, DialogToken, TpcRepInfo.TxPwr, TpcRepInfo.LinkMargin));
2257 }
2258 }
2259
2260@@ -1821,7 +1821,7 @@ INT Set_MeasureReq_Proc(
2261 MeasureReqType = simple_strtol(thisChar, 0, 16);
2262 if (MeasureReqType > 3)
2263 {
2264- DBGPRINT(RT_DEBUG_ERROR, ("%s: unknow MeasureReqType(%d)\n", __FUNCTION__, MeasureReqType));
2265+ DBGPRINT(RT_DEBUG_ERROR, ("%s: unknow MeasureReqType(%d)\n", __func__, MeasureReqType));
2266 return TRUE;
2267 }
2268 break;
2269@@ -1833,10 +1833,10 @@ INT Set_MeasureReq_Proc(
2270 ArgIdx++;
2271 }
2272
2273- DBGPRINT(RT_DEBUG_TRACE, ("%s::Aid = %d, MeasureReqType=%d MeasureCh=%d\n", __FUNCTION__, Aid, MeasureReqType, MeasureCh));
2274+ DBGPRINT(RT_DEBUG_TRACE, ("%s::Aid = %d, MeasureReqType=%d MeasureCh=%d\n", __func__, Aid, MeasureReqType, MeasureCh));
2275 if (!VALID_WCID(Aid))
2276 {
2277- DBGPRINT(RT_DEBUG_ERROR, ("%s: unknow sta of Aid(%d)\n", __FUNCTION__, Aid));
2278+ DBGPRINT(RT_DEBUG_ERROR, ("%s: unknow sta of Aid(%d)\n", __func__, Aid));
2279 return TRUE;
2280 }
2281
2282@@ -1861,10 +1861,10 @@ INT Set_TpcReq_Proc(
2283
2284 Aid = simple_strtol(arg, 0, 16);
2285
2286- DBGPRINT(RT_DEBUG_TRACE, ("%s::Aid = %d\n", __FUNCTION__, Aid));
2287+ DBGPRINT(RT_DEBUG_TRACE, ("%s::Aid = %d\n", __func__, Aid));
2288 if (!VALID_WCID(Aid))
2289 {
2290- DBGPRINT(RT_DEBUG_ERROR, ("%s: unknow sta of Aid(%d)\n", __FUNCTION__, Aid));
2291+ DBGPRINT(RT_DEBUG_ERROR, ("%s: unknow sta of Aid(%d)\n", __func__, Aid));
2292 return TRUE;
2293 }
2294
2295--- a/drivers/staging/rt2860/config.mk
2296+++ b/drivers/staging/rt2860/config.mk
2297@@ -108,10 +108,6 @@ ifeq ($(HAS_EXT_BUILD_CHANNEL_LIST),y)
2298 WFLAGS += -DEXT_BUILD_CHANNEL_LIST
2299 endif
2300
2301-ifeq ($(CHIPSET),2860)
2302-WFLAGS +=-DRT2860
2303-endif
2304-
2305 ifeq ($(CHIPSET),2870)
2306 WFLAGS +=-DRT2870
2307 endif
2308--- a/drivers/staging/rt2860/oid.h
2309+++ b/drivers/staging/rt2860/oid.h
2310@@ -544,6 +544,8 @@ typedef enum _NDIS_802_11_WEP_STATUS
2311 Ndis802_11Encryption3KeyAbsent,
2312 Ndis802_11Encryption4Enabled, // TKIP or AES mix
2313 Ndis802_11Encryption4KeyAbsent,
2314+ Ndis802_11GroupWEP40Enabled,
2315+ Ndis802_11GroupWEP104Enabled,
2316 } NDIS_802_11_WEP_STATUS, *PNDIS_802_11_WEP_STATUS,
2317 NDIS_802_11_ENCRYPTION_STATUS, *PNDIS_802_11_ENCRYPTION_STATUS;
2318
2319--- a/drivers/staging/rt2860/rt2860.h
2320+++ b/drivers/staging/rt2860/rt2860.h
2321@@ -46,18 +46,10 @@
2322 Status = NDIS_STATUS_SUCCESS;
2323
2324 /* function declarations */
2325-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
2326 #define IRQ_HANDLE_TYPE irqreturn_t
2327-#else
2328-#define IRQ_HANDLE_TYPE void
2329-#endif
2330
2331 IRQ_HANDLE_TYPE
2332-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19))
2333 rt2860_interrupt(int irq, void *dev_instance);
2334-#else
2335-rt2860_interrupt(int irq, void *dev_instance, struct pt_regs *regs);
2336-#endif
2337
2338 /* ----------------- Frimware Related MACRO ----------------- */
2339 #define RT28XX_WRITE_FIRMWARE(_pAd, _pFwImage, _FwLen) \
2340@@ -237,12 +229,10 @@ rt2860_interrupt(int irq, void *dev_inst
2341 #define RTMP_MSI_DISABLE(_pAd)
2342 #endif // PCI_MSI_SUPPORT //
2343
2344-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
2345 #define SA_SHIRQ IRQF_SHARED
2346-#endif
2347
2348 #define RT28XX_IRQ_REQUEST(net_dev) \
2349-{ PRTMP_ADAPTER _pAd = (PRTMP_ADAPTER)((net_dev)->priv); \
2350+{ PRTMP_ADAPTER _pAd = (PRTMP_ADAPTER)((net_dev)->ml_priv); \
2351 POS_COOKIE _pObj = (POS_COOKIE)(_pAd->OS_Cookie); \
2352 RTMP_MSI_ENABLE(_pAd); \
2353 if ((retval = request_irq(_pObj->pci_dev->irq, \
2354@@ -251,20 +241,12 @@ rt2860_interrupt(int irq, void *dev_inst
2355 printk("RT2860: request_irq ERROR(%d)\n", retval); \
2356 return retval; } }
2357
2358-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
2359 #define RT28XX_IRQ_RELEASE(net_dev) \
2360-{ PRTMP_ADAPTER _pAd = (PRTMP_ADAPTER)((net_dev)->priv); \
2361+{ PRTMP_ADAPTER _pAd = (PRTMP_ADAPTER)((net_dev)->ml_priv); \
2362 POS_COOKIE _pObj = (POS_COOKIE)(_pAd->OS_Cookie); \
2363 synchronize_irq(_pObj->pci_dev->irq); \
2364 free_irq(_pObj->pci_dev->irq, (net_dev)); \
2365 RTMP_MSI_DISABLE(_pAd); }
2366-#else
2367-#define RT28XX_IRQ_RELEASE(net_dev) \
2368-{ PRTMP_ADAPTER _pAd = (PRTMP_ADAPTER)((net_dev)->priv); \
2369- POS_COOKIE _pObj = (POS_COOKIE)(_pAd->OS_Cookie); \
2370- free_irq(_pObj->pci_dev->irq, (net_dev)); \
2371- RTMP_MSI_DISABLE(_pAd); }
2372-#endif
2373
2374 #define RT28XX_IRQ_INIT(pAd) \
2375 { pAd->int_enable_reg = ((DELAYINTMASK) | \
2376@@ -333,8 +315,8 @@ rt2860_interrupt(int irq, void *dev_inst
2377 reg16 = cpu2le16(Configuration); \
2378 pci_write_config_word(pci_dev, offset, reg16); \
2379
2380-#define RT28XX_STA_FORCE_WAKEUP(pAd, bFromTx) \
2381- RT28xxPciStaAsicForceWakeup(pAd, bFromTx);
2382+#define RT28XX_STA_FORCE_WAKEUP(pAd, Level) \
2383+ RT28xxPciStaAsicForceWakeup(pAd, Level);
2384
2385 #define RT28XX_STA_SLEEP_THEN_AUTO_WAKEUP(pAd, TbttNumToNextWakeUp) \
2386 RT28xxPciStaAsicSleepThenAutoWakeup(pAd, TbttNumToNextWakeUp);
2387--- a/drivers/staging/rt2860/rt28xx.h
2388+++ b/drivers/staging/rt2860/rt28xx.h
2389@@ -1670,11 +1670,9 @@ typedef struct _HW_WCID_ENTRY { // 8-by
2390 #define E2PROM_CSR 0x0004
2391 #define IO_CNTL_CSR 0x77d0
2392
2393-#ifdef RT2860
2394 // 8051 firmware image for RT2860 - base address = 0x4000
2395 #define FIRMWARE_IMAGE_BASE 0x2000
2396 #define MAX_FIRMWARE_IMAGE_SIZE 0x2000 // 8kbyte
2397-#endif // RT2860 //
2398
2399
2400 // ================================================================
2401@@ -2029,7 +2027,6 @@ typedef struct PACKED _TXWI_STRUC {
2402 //
2403 // Rx descriptor format, Rx Ring
2404 //
2405-#ifdef RT2860
2406 #ifdef RT_BIG_ENDIAN
2407 typedef struct PACKED _RXD_STRUC {
2408 // Word 0
2409@@ -2098,7 +2095,6 @@ typedef struct PACKED _RXD_STRUC {
2410 UINT32 Rsv1:13;
2411 } RXD_STRUC, *PRXD_STRUC, RT28XX_RXD_STRUC, *PRT28XX_RXD_STRUC;
2412 #endif
2413-#endif // RT2860 //
2414 //
2415 // RXWI wireless information format, in PBF. invisible in driver.
2416 //
2417--- a/drivers/staging/rt2860/rt_ate.c
2418+++ b/drivers/staging/rt2860/rt_ate.c
2419@@ -68,7 +68,6 @@ static int CheckMCSValid(
2420 IN UCHAR Mode,
2421 IN UCHAR Mcs);
2422
2423-#ifdef RT2860
2424 static VOID ATEWriteTxWI(
2425 IN PRTMP_ADAPTER pAd,
2426 IN PTXWI_STRUC pOutTxWI,
2427@@ -87,7 +86,6 @@ static VOID ATEWriteTxWI(
2428 IN UCHAR Txopmode,
2429 IN BOOLEAN CfAck,
2430 IN HTTRANSMIT_SETTING *pTransmit);
2431-#endif // RT2860 //
2432
2433
2434 static VOID SetJapanFilter(
2435@@ -95,7 +93,6 @@ static VOID SetJapanFilter(
2436
2437 /*=========================end of prototype=========================*/
2438
2439-#ifdef RT2860
2440 static INT TxDmaBusy(
2441 IN PRTMP_ADAPTER pAd)
2442 {
2443@@ -153,7 +150,6 @@ static VOID RtmpDmaEnable(
2444
2445 return;
2446 }
2447-#endif // RT2860 //
2448
2449
2450 static VOID BbpSoftReset(
2451@@ -291,7 +287,7 @@ static INT ATETxPwrHandler(
2452 Bbp94 = BBPR94_DEFAULT;
2453 }
2454
2455- ATEDBGPRINT(RT_DEBUG_TRACE, ("%s (TxPower=%d, R=%ld, BBP_R94=%d)\n", __FUNCTION__, TxPower, R, Bbp94));
2456+ ATEDBGPRINT(RT_DEBUG_TRACE, ("%s (TxPower=%d, R=%ld, BBP_R94=%d)\n", __func__, TxPower, R, Bbp94));
2457 }
2458 else// 5.5 GHz
2459 {
2460@@ -318,7 +314,7 @@ static INT ATETxPwrHandler(
2461 R = (ULONG) TxPower;
2462 }
2463
2464- ATEDBGPRINT(RT_DEBUG_TRACE, ("%s (TxPower=%d, R=%lu)\n", __FUNCTION__, TxPower, R));
2465+ ATEDBGPRINT(RT_DEBUG_TRACE, ("%s (TxPower=%d, R=%lu)\n", __func__, TxPower, R));
2466 }
2467
2468 if (pAd->ate.Channel <= 14)
2469@@ -431,7 +427,7 @@ static INT ATETxPwrHandler(
2470 Bbp94 = BBPR94_DEFAULT;
2471 }
2472
2473- ATEDBGPRINT(RT_DEBUG_TRACE, ("%s (TxPower=%d, R3=%ld, BBP_R94=%d)\n", __FUNCTION__, TxPower, R, Bbp94));
2474+ ATEDBGPRINT(RT_DEBUG_TRACE, ("%s (TxPower=%d, R3=%ld, BBP_R94=%d)\n", __func__, TxPower, R, Bbp94));
2475
2476 if (pAd->ate.Channel <= 14)
2477 {
2478@@ -488,7 +484,6 @@ static INT ATETxPwrHandler(
2479 TRUE if all parameters are OK, FALSE otherwise
2480 ==========================================================================
2481 */
2482-#ifdef RT2860
2483 static INT ATECmdHandler(
2484 IN PRTMP_ADAPTER pAd,
2485 IN PUCHAR arg)
2486@@ -1297,7 +1292,6 @@ static INT ATECmdHandler(
2487
2488 return TRUE;
2489 }
2490-#endif // RT2860 //
2491 /* */
2492 /* */
2493 /*=======================End of RT2860=======================*/
2494@@ -2098,7 +2092,7 @@ INT Set_ATE_Load_E2P_Proc(
2495 UINT32 FileLength = 0;
2496 UINT32 value = simple_strtol(arg, 0, 10);
2497
2498- ATEDBGPRINT(RT_DEBUG_ERROR, ("===> %s (value=%d)\n\n", __FUNCTION__, value));
2499+ ATEDBGPRINT(RT_DEBUG_ERROR, ("===> %s (value=%d)\n\n", __func__, value));
2500
2501 if (value > 0)
2502 {
2503@@ -2122,14 +2116,14 @@ INT Set_ATE_Load_E2P_Proc(
2504
2505 if (IS_ERR(srcf))
2506 {
2507- ate_print("%s - Error %ld opening %s\n", __FUNCTION__, -PTR_ERR(srcf), src);
2508+ ate_print("%s - Error %ld opening %s\n", __func__, -PTR_ERR(srcf), src);
2509 break;
2510 }
2511
2512 /* the object must have a read method */
2513 if ((srcf->f_op == NULL) || (srcf->f_op->read == NULL))
2514 {
2515- ate_print("%s - %s does not have a read method\n", __FUNCTION__, src);
2516+ ate_print("%s - %s does not have a read method\n", __func__, src);
2517 break;
2518 }
2519
2520@@ -2142,7 +2136,7 @@ INT Set_ATE_Load_E2P_Proc(
2521 if (FileLength != EEPROM_SIZE)
2522 {
2523 ate_print("%s: error file length (=%d) in e2p.bin\n",
2524- __FUNCTION__, FileLength);
2525+ __func__, FileLength);
2526 break;
2527 }
2528 else
2529@@ -2174,7 +2168,7 @@ INT Set_ATE_Load_E2P_Proc(
2530 current->fsuid = orgfsuid;
2531 current->fsgid = orgfsgid;
2532 }
2533- ATEDBGPRINT(RT_DEBUG_ERROR, ("<=== %s (ret=%d)\n", __FUNCTION__, ret));
2534+ ATEDBGPRINT(RT_DEBUG_ERROR, ("<=== %s (ret=%d)\n", __func__, ret));
2535
2536 return ret;
2537
2538@@ -2187,12 +2181,12 @@ INT Set_ATE_Load_E2P_Proc(
2539 USHORT WriteEEPROM[(EEPROM_SIZE/2)];
2540 struct iwreq *wrq = (struct iwreq *)arg;
2541
2542- ATEDBGPRINT(RT_DEBUG_TRACE, ("===> %s (wrq->u.data.length = %d)\n\n", __FUNCTION__, wrq->u.data.length));
2543+ ATEDBGPRINT(RT_DEBUG_TRACE, ("===> %s (wrq->u.data.length = %d)\n\n", __func__, wrq->u.data.length));
2544
2545 if (wrq->u.data.length != EEPROM_SIZE)
2546 {
2547 ate_print("%s: error length (=%d) from host\n",
2548- __FUNCTION__, wrq->u.data.length);
2549+ __func__, wrq->u.data.length);
2550 return FALSE;
2551 }
2552 else/* (wrq->u.data.length == EEPROM_SIZE) */
2553@@ -2211,7 +2205,7 @@ INT Set_ATE_Load_E2P_Proc(
2554 } while(FALSE);
2555 }
2556
2557- ATEDBGPRINT(RT_DEBUG_TRACE, ("<=== %s\n", __FUNCTION__));
2558+ ATEDBGPRINT(RT_DEBUG_TRACE, ("<=== %s\n", __func__));
2559
2560 return TRUE;
2561
2562@@ -2907,7 +2901,6 @@ VOID ATEAsicAdjustTxPower(
2563 None
2564 ========================================================================
2565 */
2566-#ifdef RT2860
2567 static VOID ATEWriteTxWI(
2568 IN PRTMP_ADAPTER pAd,
2569 IN PTXWI_STRUC pOutTxWI,
2570@@ -2972,7 +2965,6 @@ static VOID ATEWriteTxWI(
2571
2572 return;
2573 }
2574-#endif // RT2860 //
2575
2576 /*
2577 ========================================================================
2578@@ -3249,13 +3241,11 @@ VOID RTMPStationStart(
2579 IN PRTMP_ADAPTER pAd)
2580 {
2581 ATEDBGPRINT(RT_DEBUG_TRACE, ("==> RTMPStationStart\n"));
2582-#ifdef RT2860
2583- pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
2584+epAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
2585 //
2586 // We did not cancel this timer when entering ATE mode.
2587 //
2588 // RTMPSetTimer(&pAd->Mlme.PeriodicTimer, MLME_TASK_EXEC_INTV);
2589-#endif // RT2860 //
2590 ATEDBGPRINT(RT_DEBUG_TRACE, ("<== RTMPStationStart\n"));
2591 }
2592 #endif // CONFIG_STA_SUPPORT //
2593@@ -3268,7 +3258,6 @@ VOID RTMPStationStart(
2594 This routine should only be used in ATE mode.
2595 ==========================================================================
2596 */
2597-#ifdef RT2860
2598 static INT ATESetUpFrame(
2599 IN PRTMP_ADAPTER pAd,
2600 IN UINT32 TxIdx)
2601@@ -3353,7 +3342,7 @@ static INT ATESetUpFrame(
2602 if (pPacket == NULL)
2603 {
2604 pAd->ate.TxCount = 0;
2605- ATEDBGPRINT(RT_DEBUG_TRACE, ("%s fail to alloc packet space.\n", __FUNCTION__));
2606+ ATEDBGPRINT(RT_DEBUG_TRACE, ("%s fail to alloc packet space.\n", __func__));
2607 return -1;
2608 }
2609 pTxRing->Cell[TxIdx].pNextNdisPacket = pPacket;
2610@@ -3455,7 +3444,6 @@ static INT ATESetUpFrame(
2611 /* */
2612 /* */
2613 /*=======================End of RT2860=======================*/
2614-#endif // RT2860 //
2615
2616
2617 VOID rt_ee_read_all(PRTMP_ADAPTER pAd, USHORT *Data)
2618@@ -3646,7 +3634,7 @@ VOID RtmpDoAte(
2619
2620 Command_Id = ntohs(pRaCfg->command_id);
2621
2622- ATEDBGPRINT(RT_DEBUG_TRACE,("\n%s: Command_Id = 0x%04x !\n", __FUNCTION__, Command_Id));
2623+ ATEDBGPRINT(RT_DEBUG_TRACE,("\n%s: Command_Id = 0x%04x !\n", __func__, Command_Id));
2624
2625 switch (Command_Id)
2626 {
2627@@ -4578,9 +4566,7 @@ VOID RtmpDoAte(
2628 {
2629 if (pAdapter->ate.TxCount == 0)
2630 {
2631-#ifdef RT2860
2632 pAdapter->ate.TxCount = 0xFFFFFFFF;
2633-#endif // RT2860 //
2634 }
2635 ATEDBGPRINT(RT_DEBUG_TRACE,("START TXFRAME\n"));
2636 pAdapter->ate.bQATxStart = TRUE;
2637@@ -5375,7 +5361,6 @@ TX_START_ERROR:
2638
2639 memcpy((PUCHAR)&value, (PUCHAR)&(pRaCfg->status), 2);
2640 value = ntohs(value);
2641-#ifdef RT2860
2642 /* TX_FRAME_COUNT == 0 means tx infinitely */
2643 if (value == 0)
2644 {
2645@@ -5387,7 +5372,6 @@ TX_START_ERROR:
2646
2647 }
2648 else
2649-#endif // RT2860 //
2650 {
2651 sprintf((PCHAR)str, "%d", value);
2652 Set_ATE_TX_COUNT_Proc(pAdapter, str);
2653@@ -5690,7 +5674,7 @@ BOOLEAN SyncTxRxConfig(PRTMP_ADAPTER pAd
2654 pAd->ate.TxAntennaSel = 2;
2655 break;
2656 default:
2657- DBGPRINT(RT_DEBUG_TRACE, ("%s -- Sth. wrong! : return FALSE; \n", __FUNCTION__));
2658+ DBGPRINT(RT_DEBUG_TRACE, ("%s -- Sth. wrong! : return FALSE; \n", __func__));
2659 return FALSE;
2660 }
2661 break;/* case BBP_R1 */
2662@@ -5728,13 +5712,13 @@ BOOLEAN SyncTxRxConfig(PRTMP_ADAPTER pAd
2663 pAd->ate.RxAntennaSel = 3;
2664 break;
2665 default:
2666- DBGPRINT(RT_DEBUG_ERROR, ("%s -- Impossible! : return FALSE; \n", __FUNCTION__));
2667+ DBGPRINT(RT_DEBUG_ERROR, ("%s -- Impossible! : return FALSE; \n", __func__));
2668 return FALSE;
2669 }
2670 break;/* case BBP_R3 */
2671
2672 default:
2673- DBGPRINT(RT_DEBUG_ERROR, ("%s -- Sth. wrong! : return FALSE; \n", __FUNCTION__));
2674+ DBGPRINT(RT_DEBUG_ERROR, ("%s -- Sth. wrong! : return FALSE; \n", __func__));
2675 return FALSE;
2676
2677 }
2678--- a/drivers/staging/rt2860/rt_ate.h
2679+++ b/drivers/staging/rt2860/rt_ate.h
2680@@ -31,12 +31,10 @@
2681 #ifndef UCOS
2682 #define ate_print printk
2683 #define ATEDBGPRINT DBGPRINT
2684-#ifdef RT2860
2685 #define EEPROM_SIZE 0x200
2686 #ifdef CONFIG_STA_SUPPORT
2687 #define EEPROM_BIN_FILE_NAME "/etc/Wireless/RT2860STA/e2p.bin"
2688 #endif // CONFIG_STA_SUPPORT //
2689-#endif // RT2860 //
2690
2691 #else // !UCOS //
2692 #define fATE_LOAD_EEPROM 0x0C43
2693@@ -69,7 +67,6 @@ do{ int (*org_remote_display)(char *)
2694 #define ATE_ON(_p) (((_p)->ate.Mode) != ATE_STOP)
2695
2696 /* RT2880_iNIC will define "RT2860". */
2697-#ifdef RT2860
2698 #define ATE_BBP_IO_READ8_BY_REG_ID(_A, _I, _pV) \
2699 { \
2700 BBP_CSR_CFG_STRUC BbpCsr; \
2701@@ -131,10 +128,8 @@ do{ int (*org_remote_display)(char *)
2702 ATEDBGPRINT(RT_DEBUG_ERROR, ("BBP write R%d fail\n", _I)); \
2703 } \
2704 }
2705-#endif // RT2860 //
2706
2707 /* RT2880_iNIC will define RT2860. */
2708-#ifdef RT2860
2709 #define EEPROM_SIZE 0x200
2710 /* iNIC has its own EEPROM_BIN_FILE_NAME */
2711 #ifndef UCOS
2712@@ -142,7 +137,6 @@ do{ int (*org_remote_display)(char *)
2713 #define EEPROM_BIN_FILE_NAME "/etc/Wireless/RT2860STA/e2p.bin"
2714 #endif // CONFIG_STA_SUPPORT //
2715 #endif // !UCOS //
2716-#endif // RT2860 //
2717
2718
2719
2720--- a/drivers/staging/rt2860/rt_config.h
2721+++ b/drivers/staging/rt2860/rt_config.h
2722@@ -53,9 +53,7 @@
2723 #include "rtmp_def.h"
2724 #include "rt28xx.h"
2725
2726-#ifdef RT2860
2727 #include "rt2860.h"
2728-#endif // RT2860 //
2729
2730
2731 #include "oid.h"
2732--- a/drivers/staging/rt2860/rt_linux.c
2733+++ b/drivers/staging/rt2860/rt_linux.c
2734@@ -48,10 +48,8 @@ BUILD_TIMER_FUNCTION(LeapAuthTimeout);
2735 #endif
2736 BUILD_TIMER_FUNCTION(StaQuickResponeForRateUpExec);
2737 BUILD_TIMER_FUNCTION(WpaDisassocApAndBlockAssoc);
2738-#ifdef RT2860
2739 BUILD_TIMER_FUNCTION(PsPollWakeExec);
2740 BUILD_TIMER_FUNCTION(RadioOnExec);
2741-#endif // RT2860 //
2742 #ifdef QOS_DLS_SUPPORT
2743 BUILD_TIMER_FUNCTION(DlsTimeoutAction);
2744 #endif // QOS_DLS_SUPPORT //
2745@@ -293,9 +291,7 @@ VOID RTMPFreeAdapter(
2746
2747 NdisFreeSpinLock(&pAd->MgmtRingLock);
2748
2749-#ifdef RT2860
2750 NdisFreeSpinLock(&pAd->RxRingLock);
2751-#endif // RT2860 //
2752
2753 for (index =0 ; index < NUM_OF_TX_RING; index++)
2754 {
2755@@ -406,7 +402,7 @@ NDIS_STATUS RTMPAllocateNdisPacket(
2756 skb_put(GET_OS_PKT_TYPE(pPacket), HeaderLen+DataLen);
2757
2758 RTMP_SET_PACKET_SOURCE(pPacket, PKTSRC_NDIS);
2759-// printk("%s : pPacket = %p, len = %d\n", __FUNCTION__, pPacket, GET_OS_PKT_LEN(pPacket));
2760+// printk("%s : pPacket = %p, len = %d\n", __func__, pPacket, GET_OS_PKT_LEN(pPacket));
2761 *ppPacket = pPacket;
2762 return NDIS_STATUS_SUCCESS;
2763 }
2764@@ -773,13 +769,13 @@ VOID RTMPSendWirelessEvent(
2765
2766 if (event_table_len == 0)
2767 {
2768- DBGPRINT(RT_DEBUG_ERROR, ("%s : The type(%0x02x) is not valid.\n", __FUNCTION__, type));
2769+ DBGPRINT(RT_DEBUG_ERROR, ("%s : The type(%0x02x) is not valid.\n", __func__, type));
2770 return;
2771 }
2772
2773 if (event >= event_table_len)
2774 {
2775- DBGPRINT(RT_DEBUG_ERROR, ("%s : The event(%0x02x) is not valid.\n", __FUNCTION__, event));
2776+ DBGPRINT(RT_DEBUG_ERROR, ("%s : The event(%0x02x) is not valid.\n", __func__, event));
2777 return;
2778 }
2779
2780@@ -817,14 +813,14 @@ VOID RTMPSendWirelessEvent(
2781 //send wireless event
2782 wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, pBuf);
2783
2784- //DBGPRINT(RT_DEBUG_TRACE, ("%s : %s\n", __FUNCTION__, pBuf));
2785+ //DBGPRINT(RT_DEBUG_TRACE, ("%s : %s\n", __func__, pBuf));
2786
2787 kfree(pBuf);
2788 }
2789 else
2790- DBGPRINT(RT_DEBUG_ERROR, ("%s : Can't allocate memory for wireless event.\n", __FUNCTION__));
2791+ DBGPRINT(RT_DEBUG_ERROR, ("%s : Can't allocate memory for wireless event.\n", __func__));
2792 #else
2793- DBGPRINT(RT_DEBUG_ERROR, ("%s : The Wireless Extension MUST be v15 or newer.\n", __FUNCTION__));
2794+ DBGPRINT(RT_DEBUG_ERROR, ("%s : The Wireless Extension MUST be v15 or newer.\n", __func__));
2795 #endif /* WIRELESS_EXT >= 15 */
2796 }
2797
2798@@ -848,13 +844,13 @@ void send_monitor_packets(
2799 ASSERT(pRxBlk->pRxPacket);
2800 if (pRxBlk->DataSize < 10)
2801 {
2802- DBGPRINT(RT_DEBUG_ERROR, ("%s : Size is too small! (%d)\n", __FUNCTION__, pRxBlk->DataSize));
2803+ DBGPRINT(RT_DEBUG_ERROR, ("%s : Size is too small! (%d)\n", __func__, pRxBlk->DataSize));
2804 goto err_free_sk_buff;
2805 }
2806
2807 if (pRxBlk->DataSize + sizeof(wlan_ng_prism2_header) > RX_BUFFER_AGGRESIZE)
2808 {
2809- DBGPRINT(RT_DEBUG_ERROR, ("%s : Size is too large! (%d)\n", __FUNCTION__, pRxBlk->DataSize + sizeof(wlan_ng_prism2_header)));
2810+ DBGPRINT(RT_DEBUG_ERROR, ("%s : Size is too large! (%zu)\n", __func__, pRxBlk->DataSize + sizeof(wlan_ng_prism2_header)));
2811 goto err_free_sk_buff;
2812 }
2813
2814@@ -910,7 +906,7 @@ void send_monitor_packets(
2815
2816 if (skb_headroom(pOSPkt) < (sizeof(wlan_ng_prism2_header)+ header_len)) {
2817 if (pskb_expand_head(pOSPkt, (sizeof(wlan_ng_prism2_header) + header_len), 0, GFP_ATOMIC)) {
2818- DBGPRINT(RT_DEBUG_ERROR, ("%s : Reallocate header size of sk_buff fail!\n", __FUNCTION__));
2819+ DBGPRINT(RT_DEBUG_ERROR, ("%s : Reallocate header size of sk_buff fail!\n", __func__));
2820 goto err_free_sk_buff;
2821 } //end if
2822 } //end if
2823@@ -1005,35 +1001,14 @@ err_free_sk_buff:
2824
2825 void rtmp_os_thread_init(PUCHAR pThreadName, PVOID pNotify)
2826 {
2827-
2828-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
2829 daemonize(pThreadName /*"%s",pAd->net_dev->name*/);
2830
2831 allow_signal(SIGTERM);
2832 allow_signal(SIGKILL);
2833 current->flags |= PF_NOFREEZE;
2834-#else
2835- unsigned long flags;
2836-
2837- daemonize();
2838- reparent_to_init();
2839- strcpy(current->comm, pThreadName);
2840-
2841- siginitsetinv(&current->blocked, sigmask(SIGTERM) | sigmask(SIGKILL));
2842-
2843- /* Allow interception of SIGKILL only
2844- * Don't allow other signals to interrupt the transmission */
2845-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,4,22)
2846- spin_lock_irqsave(&current->sigmask_lock, flags);
2847- flush_signals(current);
2848- recalc_sigpending(current);
2849- spin_unlock_irqrestore(&current->sigmask_lock, flags);
2850-#endif
2851-#endif
2852
2853- /* signal that we've started the thread */
2854+ /* signal that we've started the thread */
2855 complete(pNotify);
2856-
2857 }
2858
2859 void RTMP_IndicateMediaState(
2860--- a/drivers/staging/rt2860/rt_linux.h
2861+++ b/drivers/staging/rt2860/rt_linux.h
2862@@ -65,7 +65,6 @@
2863 #include <linux/vmalloc.h>
2864
2865
2866-#include <linux/wireless.h>
2867 #include <net/iw_handler.h>
2868
2869 // load firmware
2870@@ -90,28 +89,22 @@ typedef int (*HARD_START_XMIT_FUNC)(stru
2871 // add by kathy
2872
2873 #ifdef CONFIG_STA_SUPPORT
2874-#ifdef RT2860
2875 #define STA_PROFILE_PATH "/etc/Wireless/RT2860STA/RT2860STA.dat"
2876 #define STA_RTMP_FIRMWARE_FILE_NAME "/etc/Wireless/RT2860STA/RT2860STA.bin"
2877 #define STA_NIC_DEVICE_NAME "RT2860STA"
2878-#define STA_DRIVER_VERSION "1.8.0.0"
2879+#define STA_DRIVER_VERSION "1.8.1.1"
2880 #ifdef MULTIPLE_CARD_SUPPORT
2881 #define CARD_INFO_PATH "/etc/Wireless/RT2860STA/RT2860STACard.dat"
2882 #endif // MULTIPLE_CARD_SUPPORT //
2883-#endif // RT2860 //
2884
2885
2886 #endif // CONFIG_STA_SUPPORT //
2887
2888-#ifdef RT2860
2889 #ifndef PCI_DEVICE
2890 #define PCI_DEVICE(vend,dev) \
2891 .vendor = (vend), .device = (dev), \
2892 .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID
2893 #endif // PCI_DEVICE //
2894-#endif // RT2860 //
2895-
2896-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
2897
2898 #define RTMP_TIME_AFTER(a,b) \
2899 (typecheck(unsigned long, (unsigned long)a) && \
2900@@ -123,23 +116,15 @@ typedef int (*HARD_START_XMIT_FUNC)(stru
2901 typecheck(unsigned long, (unsigned long)b) && \
2902 ((long)(a) - (long)(b) >= 0))
2903 #define RTMP_TIME_BEFORE(a,b) RTMP_TIME_AFTER_EQ(b,a)
2904-#else
2905-#define RTMP_TIME_AFTER(a,b) time_after(a, b)
2906-#endif
2907
2908-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
2909 #define RT_MOD_INC_USE_COUNT() \
2910 if (!try_module_get(THIS_MODULE)) \
2911 { \
2912- DBGPRINT(RT_DEBUG_ERROR, ("%s: cannot reserve module\n", __FUNCTION__)); \
2913+ DBGPRINT(RT_DEBUG_ERROR, ("%s: cannot reserve module\n", __func__)); \
2914 return -1; \
2915 }
2916
2917 #define RT_MOD_DEC_USE_COUNT() module_put(THIS_MODULE);
2918-#else
2919-#define RT_MOD_INC_USE_COUNT() MOD_INC_USE_COUNT;
2920-#define RT_MOD_DEC_USE_COUNT() MOD_DEC_USE_COUNT;
2921-#endif
2922
2923 #define OS_HZ HZ
2924
2925@@ -171,21 +156,12 @@ typedef int (*HARD_START_XMIT_FUNC)(stru
2926 #define NDIS_PACKET_TYPE_ALL_MULTICAST 3
2927 #endif // CONFIG_STA_SUPPORT //
2928
2929-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
2930 typedef struct pid * THREAD_PID;
2931 #define THREAD_PID_INIT_VALUE NULL
2932 #define GET_PID(_v) find_get_pid(_v)
2933 #define GET_PID_NUMBER(_v) pid_nr(_v)
2934 #define CHECK_PID_LEGALITY(_pid) if (pid_nr(_pid) >= 0)
2935 #define KILL_THREAD_PID(_A, _B, _C) kill_pid(_A, _B, _C)
2936-#else
2937-typedef pid_t THREAD_PID;
2938-#define THREAD_PID_INIT_VALUE -1
2939-#define GET_PID(_v) _v
2940-#define GET_PID_NUMBER(_v) _v
2941-#define CHECK_PID_LEGALITY(_pid) if (_pid >= 0)
2942-#define KILL_THREAD_PID(_A, _B, _C) kill_proc(_A, _B, _C)
2943-#endif
2944
2945 struct os_lock {
2946 spinlock_t lock;
2947@@ -194,11 +170,9 @@ struct os_lock {
2948
2949
2950 struct os_cookie {
2951-#ifdef RT2860
2952 struct pci_dev *pci_dev;
2953 struct pci_dev *parent_pci_dev;
2954 dma_addr_t pAd_pa;
2955-#endif // RT2860 //
2956
2957
2958 struct tasklet_struct rx_done_task;
2959@@ -209,9 +183,7 @@ struct os_cookie {
2960 struct tasklet_struct ac3_dma_done_task;
2961 struct tasklet_struct hcca_dma_done_task;
2962 struct tasklet_struct tbtt_task;
2963-#ifdef RT2860
2964 struct tasklet_struct fifo_statistic_full_task;
2965-#endif // RT2860 //
2966
2967
2968 unsigned long apd_pid; //802.1x daemon pid
2969@@ -266,7 +238,6 @@ void linux_pci_unmap_single(void *handle
2970
2971 #define RT2860_PCI_DEVICE_ID 0x0601
2972
2973-#ifdef RT2860
2974 #define PCI_MAP_SINGLE(_handle, _ptr, _size, _sd_idx, _dir) \
2975 linux_pci_map_single(_handle, _ptr, _size, _sd_idx, _dir)
2976
2977@@ -281,7 +252,6 @@ void linux_pci_unmap_single(void *handle
2978
2979 #define DEV_ALLOC_SKB(_length) \
2980 dev_alloc_skb(_length)
2981-#endif // RT2860 //
2982
2983
2984
2985@@ -401,7 +371,6 @@ extern ULONG RTDebugLevel;
2986 spin_unlock_irqrestore((spinlock_t *)(__lock), ((unsigned long)__irqflag)); \
2987 }
2988
2989-#ifdef RT2860
2990 #if defined(INF_TWINPASS) || defined(INF_DANUBE) || defined(IKANOS_VX_1X0)
2991 //Patch for ASIC turst read/write bug, needs to remove after metel fix
2992 #define RTMP_IO_READ32(_A, _R, _pV) \
2993@@ -413,6 +382,12 @@ extern ULONG RTDebugLevel;
2994 (*_pV = SWAP32(*((UINT32 *)(_pV)))); \
2995 } \
2996 }
2997+#define RTMP_IO_FORCE_READ32(_A, _R, _pV) \
2998+{ \
2999+ (*_pV = readl((void *)((_A)->CSRBaseAddress + MAC_CSR0))); \
3000+ (*_pV = readl((void *)((_A)->CSRBaseAddress + (_R)))); \
3001+ (*_pV = SWAP32(*((UINT32 *)(_pV)))); \
3002+}
3003 #define RTMP_IO_READ8(_A, _R, _pV) \
3004 { \
3005 (*_pV = readl((void *)((_A)->CSRBaseAddress + MAC_CSR0))); \
3006@@ -452,6 +427,11 @@ extern ULONG RTDebugLevel;
3007 else \
3008 *_pV = 0; \
3009 }
3010+#define RTMP_IO_FORCE_READ32(_A, _R, _pV) \
3011+{ \
3012+ (*_pV = readl((void *)((_A)->CSRBaseAddress + MAC_CSR0))); \
3013+ (*_pV = readl((void *)((_A)->CSRBaseAddress + (_R)))); \
3014+}
3015 #define RTMP_IO_READ8(_A, _R, _pV) \
3016 { \
3017 (*_pV = readl((void *)((_A)->CSRBaseAddress + MAC_CSR0))); \
3018@@ -492,7 +472,6 @@ extern ULONG RTDebugLevel;
3019 writew((_V), (PUSHORT)((_A)->CSRBaseAddress + (_R))); \
3020 }
3021 #endif
3022-#endif // RT2860 //
3023
3024
3025 #ifndef wait_event_interruptible_timeout
3026@@ -544,7 +523,6 @@ typedef void (*TIMER_FUNCTION)(unsigned
3027 #define MlmeAllocateMemory(_pAd, _ppVA) os_alloc_mem(_pAd, _ppVA, MGMT_DMA_BUFFER_SIZE)
3028 #define MlmeFreeMemory(_pAd, _pVA) os_free_mem(_pAd, _pVA)
3029
3030-#ifdef RT2860
3031 #define BUILD_TIMER_FUNCTION(_func) \
3032 void linux_##_func(unsigned long data) \
3033 { \
3034@@ -554,7 +532,6 @@ void linux_##_func(unsigned long data)
3035 if (pTimer->Repeat) \
3036 RTMP_OS_Add_Timer(&pTimer->TimerObj, pTimer->TimerValue); \
3037 }
3038-#endif // RT2860 //
3039
3040
3041
3042@@ -907,7 +884,6 @@ int rt28xx_packet_xmit(struct sk_buff *s
3043
3044 void rtmp_os_thread_init(PUCHAR pThreadName, PVOID pNotify);
3045
3046-#ifdef RT2860
3047 #if !defined(PCI_CAP_ID_EXP)
3048 #define PCI_CAP_ID_EXP 0x10
3049 #endif
3050@@ -921,6 +897,5 @@ void rtmp_os_thread_init(PUCHAR pThreadN
3051 #endif
3052
3053 #define PCIBUS_INTEL_VENDOR 0x8086
3054-#endif // RT2860 //
3055
3056
3057--- a/drivers/staging/rt2860/rt_main_dev.c
3058+++ b/drivers/staging/rt2860/rt_main_dev.c
3059@@ -58,11 +58,7 @@ UINT32 CW_MAX_IN_BITS;
3060
3061 char *mac = ""; // default 00:00:00:00:00:00
3062 char *hostname = ""; // default CMPC
3063-#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,12)
3064-MODULE_PARM (mac, "s");
3065-#else
3066 module_param (mac, charp, 0);
3067-#endif
3068 MODULE_PARM_DESC (mac, "rt28xx: wireless mac addr");
3069
3070
3071@@ -75,9 +71,7 @@ extern void ba_reordering_resource_relea
3072 #endif // DOT11_N_SUPPORT //
3073 extern NDIS_STATUS NICLoadRateSwitchingParams(IN PRTMP_ADAPTER pAd);
3074
3075-#ifdef RT2860
3076 extern void init_thread_task(PRTMP_ADAPTER pAd);
3077-#endif // RT2860 //
3078
3079 // public function prototype
3080 INT __devinit rt28xx_probe(IN void *_dev_p, IN void *_dev_id_p,
3081@@ -87,13 +81,6 @@ INT __devinit rt28xx_probe(IN void *_dev
3082 static int rt28xx_init(IN struct net_device *net_dev);
3083 INT rt28xx_send_packets(IN struct sk_buff *skb_p, IN struct net_device *net_dev);
3084
3085-#if LINUX_VERSION_CODE <= 0x20402 // Red Hat 7.1
3086-struct net_device *alloc_netdev(
3087- int sizeof_priv,
3088- const char *mask,
3089- void (*setup)(struct net_device *));
3090-#endif // LINUX_VERSION_CODE //
3091-
3092 static void CfgInitHook(PRTMP_ADAPTER pAd);
3093
3094 #ifdef CONFIG_STA_SUPPORT
3095@@ -135,7 +122,7 @@ Note:
3096 */
3097 int MainVirtualIF_close(IN struct net_device *net_dev)
3098 {
3099- RTMP_ADAPTER *pAd = net_dev->priv;
3100+ RTMP_ADAPTER *pAd = net_dev->ml_priv;
3101
3102 // Sanity check for pAd
3103 if (pAd == NULL)
3104@@ -174,7 +161,7 @@ Note:
3105 */
3106 int MainVirtualIF_open(IN struct net_device *net_dev)
3107 {
3108- RTMP_ADAPTER *pAd = net_dev->priv;
3109+ RTMP_ADAPTER *pAd = net_dev->ml_priv;
3110
3111 // Sanity check for pAd
3112 if (pAd == NULL)
3113@@ -216,7 +203,7 @@ Note:
3114 int rt28xx_close(IN PNET_DEV dev)
3115 {
3116 struct net_device * net_dev = (struct net_device *)dev;
3117- RTMP_ADAPTER *pAd = net_dev->priv;
3118+ RTMP_ADAPTER *pAd = net_dev->ml_priv;
3119 BOOLEAN Cancelled = FALSE;
3120 UINT32 i = 0;
3121
3122@@ -235,15 +222,13 @@ int rt28xx_close(IN PNET_DEV dev)
3123 #ifdef CONFIG_STA_SUPPORT
3124 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
3125 {
3126-#ifdef RT2860
3127- RTMPPCIeLinkCtrlValueRestore(pAd, RESTORE_CLOSE);
3128-#endif // RT2860 //
3129-
3130 // If dirver doesn't wake up firmware here,
3131 // NICLoadFirmware will hang forever when interface is up again.
3132- if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
3133+ if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE) ||
3134+ RTMP_SET_PSFLAG(pAd, fRTMP_PS_SET_PCI_CLK_OFF_COMMAND) ||
3135+ RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_IDLE_RADIO_OFF))
3136 {
3137- AsicForceWakeup(pAd, TRUE);
3138+ AsicForceWakeup(pAd, RTMP_HALT);
3139 }
3140
3141 #ifdef QOS_DLS_SUPPORT
3142@@ -323,9 +308,7 @@ int rt28xx_close(IN PNET_DEV dev)
3143 #endif // WPA_SUPPLICANT_SUPPORT //
3144
3145 MlmeRadioOff(pAd);
3146-#ifdef RT2860
3147 pAd->bPCIclkOff = FALSE;
3148-#endif // RT2860 //
3149 }
3150 #endif // CONFIG_STA_SUPPORT //
3151
3152@@ -359,7 +342,6 @@ int rt28xx_close(IN PNET_DEV dev)
3153 TpcReqTabExit(pAd);
3154
3155
3156-#ifdef RT2860
3157 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_ACTIVE))
3158 {
3159 NICDisableInterrupt(pAd);
3160@@ -375,7 +357,6 @@ int rt28xx_close(IN PNET_DEV dev)
3161 RT28XX_IRQ_RELEASE(net_dev)
3162 RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE);
3163 }
3164-#endif // RT2860 //
3165
3166
3167 // Free Ring or USB buffers
3168@@ -396,7 +377,7 @@ int rt28xx_close(IN PNET_DEV dev)
3169
3170 static int rt28xx_init(IN struct net_device *net_dev)
3171 {
3172- PRTMP_ADAPTER pAd = (PRTMP_ADAPTER)net_dev->priv;
3173+ PRTMP_ADAPTER pAd = (PRTMP_ADAPTER)net_dev->ml_priv;
3174 UINT index;
3175 UCHAR TmpPhy;
3176 NDIS_STATUS Status;
3177@@ -439,12 +420,10 @@ static int rt28xx_init(IN struct net_dev
3178
3179 // Disable interrupts here which is as soon as possible
3180 // This statement should never be true. We might consider to remove it later
3181-#ifdef RT2860
3182 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_ACTIVE))
3183 {
3184 NICDisableInterrupt(pAd);
3185 }
3186-#endif // RT2860 //
3187
3188 Status = RTMPAllocTxRxRingMemory(pAd);
3189 if (Status != NDIS_STATUS_SUCCESS)
3190@@ -605,8 +584,8 @@ err1:
3191 #endif // DOT11_N_SUPPORT //
3192 RT28XX_IRQ_RELEASE(net_dev);
3193
3194- // shall not set priv to NULL here because the priv didn't been free yet.
3195- //net_dev->priv = 0;
3196+ // shall not set ml_priv to NULL here because the ml_priv didn't been free yet.
3197+ //net_dev->ml_priv = 0;
3198 #ifdef INF_AMAZON_SE
3199 err0:
3200 #endif // INF_AMAZON_SE //
3201@@ -633,7 +612,7 @@ Note:
3202 int rt28xx_open(IN PNET_DEV dev)
3203 {
3204 struct net_device * net_dev = (struct net_device *)dev;
3205- PRTMP_ADAPTER pAd = (PRTMP_ADAPTER)net_dev->priv;
3206+ PRTMP_ADAPTER pAd = net_dev->ml_priv;
3207 int retval = 0;
3208 POS_COOKIE pObj;
3209
3210@@ -642,7 +621,7 @@ int rt28xx_open(IN PNET_DEV dev)
3211 if (pAd == NULL)
3212 {
3213 /* if 1st open fail, pAd will be free;
3214- So the net_dev->priv will be NULL in 2rd open */
3215+ So the net_dev->ml_priv will be NULL in 2rd open */
3216 return -1;
3217 }
3218
3219@@ -667,26 +646,6 @@ int rt28xx_open(IN PNET_DEV dev)
3220 #endif // WIRELESS_EXT >= 12 //
3221 #endif // CONFIG_APSTA_MIXED_SUPPORT //
3222
3223-#ifdef CONFIG_STA_SUPPORT
3224-#ifdef RT2860
3225- IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
3226- {
3227- // If dirver doesn't wake up firmware here,
3228- // NICLoadFirmware will hang forever when interface is up again.
3229- // RT2860 PCI
3230- if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE) &&
3231- OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_ADVANCE_POWER_SAVE_PCIE_DEVICE))
3232- {
3233- AUTO_WAKEUP_STRUC AutoWakeupCfg;
3234- AsicForceWakeup(pAd, TRUE);
3235- AutoWakeupCfg.word = 0;
3236- RTMP_IO_WRITE32(pAd, AUTO_WAKEUP_CFG, AutoWakeupCfg.word);
3237- OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_DOZE);
3238- }
3239- }
3240-#endif // RT2860 //
3241-#endif // CONFIG_STA_SUPPORT //
3242-
3243 // Init
3244 pObj = (POS_COOKIE)pAd->OS_Cookie;
3245
3246@@ -753,10 +712,8 @@ int rt28xx_open(IN PNET_DEV dev)
3247 }
3248
3249 #ifdef CONFIG_STA_SUPPORT
3250-#ifdef RT2860
3251 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
3252 RTMPInitPCIeLinkCtrlValue(pAd);
3253-#endif // RT2860 //
3254 #endif // CONFIG_STA_SUPPORT //
3255
3256 return (retval);
3257@@ -808,9 +765,7 @@ static NDIS_STATUS rt_ieee80211_if_setup
3258 dev->stop = MainVirtualIF_close; //rt28xx_close;
3259 dev->priv_flags = INT_MAIN;
3260 dev->do_ioctl = rt28xx_ioctl;
3261-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
3262- dev->validate_addr = NULL;
3263-#endif
3264+ dev->validate_addr = NULL;
3265 // find available device name
3266 for (i = 0; i < 8; i++)
3267 {
3268@@ -821,25 +776,11 @@ static NDIS_STATUS rt_ieee80211_if_setup
3269 #endif // MULTIPLE_CARD_SUPPORT //
3270 sprintf(slot_name, "ra%d", i);
3271
3272-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
3273-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
3274-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)
3275- device = dev_get_by_name(dev_net(dev), slot_name);
3276-#else
3277- device = dev_get_by_name(dev->nd_net, slot_name);
3278-#endif
3279-#else
3280- device = dev_get_by_name(slot_name);
3281-#endif
3282- if (device != NULL) dev_put(device);
3283-#else
3284- for (device = dev_base; device != NULL; device = device->next)
3285- {
3286- if (strncmp(device->name, slot_name, 4) == 0)
3287- break;
3288- }
3289-#endif
3290- if(device == NULL)
3291+ device = dev_get_by_name(dev_net(dev), slot_name);
3292+ if (device != NULL)
3293+ dev_put(device);
3294+
3295+ if (device == NULL)
3296 break;
3297 }
3298
3299@@ -1252,47 +1193,28 @@ INT __devinit rt28xx_probe(
3300 PRTMP_ADAPTER pAd = (PRTMP_ADAPTER) NULL;
3301 INT status;
3302 PVOID handle;
3303-#ifdef RT2860
3304 struct pci_dev *dev_p = (struct pci_dev *)_dev_p;
3305-#endif // RT2860 //
3306
3307
3308 #ifdef CONFIG_STA_SUPPORT
3309 DBGPRINT(RT_DEBUG_TRACE, ("STA Driver version-%s\n", STA_DRIVER_VERSION));
3310 #endif // CONFIG_STA_SUPPORT //
3311
3312-#if LINUX_VERSION_CODE <= 0x20402 // Red Hat 7.1
3313- net_dev = alloc_netdev(sizeof(PRTMP_ADAPTER), "eth%d", ether_setup);
3314-#else
3315 net_dev = alloc_etherdev(sizeof(PRTMP_ADAPTER));
3316-#endif
3317 if (net_dev == NULL)
3318 {
3319 printk("alloc_netdev failed\n");
3320
3321-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
3322-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15)
3323- module_put(THIS_MODULE);
3324-#endif //LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15)
3325-#else
3326- MOD_DEC_USE_COUNT;
3327-#endif
3328 goto err_out;
3329 }
3330
3331-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
3332- SET_MODULE_OWNER(net_dev);
3333-#endif
3334-
3335 netif_stop_queue(net_dev);
3336 #ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
3337 /* for supporting Network Manager */
3338 /* Set the sysfs physical device reference for the network logical device
3339 * if set prior to registration will cause a symlink during initialization.
3340 */
3341-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
3342 SET_NETDEV_DEV(net_dev, &(dev_p->dev));
3343-#endif
3344 #endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
3345
3346 // Allocate RTMP_ADAPTER miniport adapter structure
3347@@ -1303,7 +1225,7 @@ INT __devinit rt28xx_probe(
3348 if (status != NDIS_STATUS_SUCCESS)
3349 goto err_out_free_netdev;
3350
3351- net_dev->priv = (PVOID)pAd;
3352+ net_dev->ml_priv = (PVOID)pAd;
3353 pAd->net_dev = net_dev; // must be before RT28XXNetDevInit()
3354
3355 RT28XXNetDevInit(_dev_p, net_dev, pAd);
3356@@ -1313,13 +1235,8 @@ INT __devinit rt28xx_probe(
3357 #endif // CONFIG_STA_SUPPORT //
3358
3359 // Post config
3360-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
3361- if (RT28XXProbePostConfig(_dev_p, pAd, argc) == FALSE)
3362- goto err_out_unmap;
3363-#else
3364 if (RT28XXProbePostConfig(_dev_p, pAd, 0) == FALSE)
3365 goto err_out_unmap;
3366-#endif // LINUX_VERSION_CODE //
3367
3368 #ifdef CONFIG_STA_SUPPORT
3369 pAd->OpMode = OPMODE_STA;
3370@@ -1362,20 +1279,12 @@ err_out_unmap:
3371 RT28XX_UNMAP();
3372
3373 err_out_free_netdev:
3374-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
3375- free_netdev(net_dev);
3376-#else
3377- kfree(net_dev);
3378-#endif
3379+ free_netdev(net_dev);
3380
3381 err_out:
3382 RT28XX_PUT_DEVICE(dev_p);
3383
3384-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
3385- return (LONG)NULL;
3386-#else
3387- return -ENODEV; /* probe fail */
3388-#endif // LINUX_VERSION_CODE //
3389+ return -ENODEV; /* probe fail */
3390 } /* End of rt28xx_probe */
3391
3392
3393@@ -1399,7 +1308,7 @@ Note:
3394 int rt28xx_packet_xmit(struct sk_buff *skb)
3395 {
3396 struct net_device *net_dev = skb->dev;
3397- PRTMP_ADAPTER pAd = (PRTMP_ADAPTER) net_dev->priv;
3398+ PRTMP_ADAPTER pAd = net_dev->ml_priv;
3399 int status = 0;
3400 PNDIS_PACKET pPacket = (PNDIS_PACKET) skb;
3401
3402@@ -1478,7 +1387,7 @@ INT rt28xx_send_packets(
3403 IN struct sk_buff *skb_p,
3404 IN struct net_device *net_dev)
3405 {
3406- RTMP_ADAPTER *pAd = net_dev->priv;
3407+ RTMP_ADAPTER *pAd = net_dev->ml_priv;
3408 if (!(net_dev->flags & IFF_UP))
3409 {
3410 RELEASE_NDIS_PACKET(pAd, (PNDIS_PACKET)skb_p, NDIS_STATUS_FAILURE);
3411@@ -1495,40 +1404,6 @@ INT rt28xx_send_packets(
3412
3413
3414
3415-#if LINUX_VERSION_CODE <= 0x20402 // Red Hat 7.1
3416-struct net_device *alloc_netdev(
3417- int sizeof_priv,
3418- const char *mask,
3419- void (*setup)(struct net_device *))
3420-{
3421- struct net_device *dev;
3422- INT alloc_size;
3423-
3424-
3425- /* ensure 32-byte alignment of the private area */
3426- alloc_size = sizeof (*dev) + sizeof_priv + 31;
3427-
3428- dev = (struct net_device *) kmalloc(alloc_size, GFP_KERNEL);
3429- if (dev == NULL)
3430- {
3431- DBGPRINT(RT_DEBUG_ERROR,
3432- ("alloc_netdev: Unable to allocate device memory.\n"));
3433- return NULL;
3434- }
3435-
3436- memset(dev, 0, alloc_size);
3437-
3438- if (sizeof_priv)
3439- dev->priv = (void *) (((long)(dev + 1) + 31) & ~31);
3440-
3441- setup(dev);
3442- strcpy(dev->name, mask);
3443-
3444- return dev;
3445-}
3446-#endif // LINUX_VERSION_CODE //
3447-
3448-
3449 void CfgInitHook(PRTMP_ADAPTER pAd)
3450 {
3451 pAd->bBroadComHT = TRUE;
3452@@ -1540,7 +1415,7 @@ void CfgInitHook(PRTMP_ADAPTER pAd)
3453 struct iw_statistics *rt28xx_get_wireless_stats(
3454 IN struct net_device *net_dev)
3455 {
3456- PRTMP_ADAPTER pAd = (PRTMP_ADAPTER) net_dev->priv;
3457+ PRTMP_ADAPTER pAd = net_dev->ml_priv;
3458
3459
3460 DBGPRINT(RT_DEBUG_TRACE, ("rt28xx_get_wireless_stats --->\n"));
3461@@ -1592,18 +1467,18 @@ INT rt28xx_ioctl(
3462
3463 if (net_dev->priv_flags == INT_MAIN)
3464 {
3465- pAd = net_dev->priv;
3466+ pAd = net_dev->ml_priv;
3467 }
3468 else
3469 {
3470- pVirtualAd = net_dev->priv;
3471- pAd = pVirtualAd->RtmpDev->priv;
3472+ pVirtualAd = net_dev->ml_priv;
3473+ pAd = pVirtualAd->RtmpDev->ml_priv;
3474 }
3475
3476 if (pAd == NULL)
3477 {
3478 /* if 1st open fail, pAd will be free;
3479- So the net_dev->priv will be NULL in 2rd open */
3480+ So the net_dev->ml_priv will be NULL in 2rd open */
3481 return -ENETDOWN;
3482 }
3483
3484@@ -1640,7 +1515,7 @@ struct net_device_stats *RT28xx_get_ethe
3485 RTMP_ADAPTER *pAd = NULL;
3486
3487 if (net_dev)
3488- pAd = net_dev->priv;
3489+ pAd = net_dev->ml_priv;
3490
3491 if (pAd)
3492 {
3493--- a/drivers/staging/rt2860/rt_profile.c
3494+++ b/drivers/staging/rt2860/rt_profile.c
3495@@ -925,9 +925,11 @@ NDIS_STATUS RTMPReadParametersHook(
3496
3497 // Save uid and gid used for filesystem access.
3498 // Set user and group to 0 (root)
3499- orgfsuid = current->fsuid;
3500- orgfsgid = current->fsgid;
3501- current->fsuid=current->fsgid = 0;
3502+ orgfsuid = current_fsuid();
3503+ orgfsgid = current_fsgid();
3504+ /* Hm, can't really do this nicely anymore, so rely on these files
3505+ * being set to the proper permission to read them... */
3506+ /* current->cred->fsuid = current->cred->fsgid = 0; */
3507 orgfs = get_fs();
3508 set_fs(KERNEL_DS);
3509
3510@@ -1022,7 +1024,7 @@ NDIS_STATUS RTMPReadParametersHook(
3511 pAd->MlmeAux.SsidLen = pAd->CommonCfg.SsidLen;
3512 NdisZeroMemory(pAd->MlmeAux.Ssid, NDIS_802_11_LENGTH_SSID);
3513 NdisMoveMemory(pAd->MlmeAux.Ssid, tmpbuf, pAd->MlmeAux.SsidLen);
3514- DBGPRINT(RT_DEBUG_TRACE, ("%s::(SSID=%s)\n", __FUNCTION__, tmpbuf));
3515+ DBGPRINT(RT_DEBUG_TRACE, ("%s::(SSID=%s)\n", __func__, tmpbuf));
3516 }
3517 }
3518 }
3519@@ -1041,7 +1043,7 @@ NDIS_STATUS RTMPReadParametersHook(
3520 pAd->StaCfg.BssType = BSS_INFRA;
3521 // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
3522 pAd->StaCfg.WpaState = SS_NOTUSE;
3523- DBGPRINT(RT_DEBUG_TRACE, ("%s::(NetworkType=%d)\n", __FUNCTION__, pAd->StaCfg.BssType));
3524+ DBGPRINT(RT_DEBUG_TRACE, ("%s::(NetworkType=%d)\n", __func__, pAd->StaCfg.BssType));
3525 }
3526 }
3527 #endif // CONFIG_STA_SUPPORT //
3528@@ -1335,7 +1337,7 @@ NDIS_STATUS RTMPReadParametersHook(
3529
3530 pAd->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
3531
3532- DBGPRINT(RT_DEBUG_TRACE, ("%s::(EncrypType=%d)\n", __FUNCTION__, pAd->StaCfg.WepStatus));
3533+ DBGPRINT(RT_DEBUG_TRACE, ("%s::(EncrypType=%d)\n", __func__, pAd->StaCfg.WepStatus));
3534 }
3535 #endif // CONFIG_STA_SUPPORT //
3536 }
3537@@ -1361,7 +1363,7 @@ NDIS_STATUS RTMPReadParametersHook(
3538 pAd->StaCfg.OrigWepStatus = pAd->StaCfg.WepStatus;
3539 pAd->StaCfg.bMixCipher = FALSE;
3540
3541- DBGPRINT(RT_DEBUG_TRACE, ("%s::(EncrypType=%d)\n", __FUNCTION__, pAd->StaCfg.WepStatus));
3542+ DBGPRINT(RT_DEBUG_TRACE, ("%s::(EncrypType=%d)\n", __func__, pAd->StaCfg.WepStatus));
3543 }
3544 #endif // CONFIG_STA_SUPPORT //
3545 }
3546@@ -1398,7 +1400,7 @@ NDIS_STATUS RTMPReadParametersHook(
3547 else
3548 {
3549 err = 1;
3550- DBGPRINT(RT_DEBUG_ERROR, ("%s::(WPAPSK key-string required 8 ~ 64 characters!)\n", __FUNCTION__));
3551+ DBGPRINT(RT_DEBUG_ERROR, ("%s::(WPAPSK key-string required 8 ~ 64 characters!)\n", __func__));
3552 }
3553
3554 if (err == 0)
3555@@ -1414,7 +1416,7 @@ NDIS_STATUS RTMPReadParametersHook(
3556 pAd->StaCfg.WpaState = SS_NOTUSE;
3557 }
3558
3559- DBGPRINT(RT_DEBUG_TRACE, ("%s::(WPAPSK=%s)\n", __FUNCTION__, tmpbuf));
3560+ DBGPRINT(RT_DEBUG_TRACE, ("%s::(WPAPSK=%s)\n", __func__, tmpbuf));
3561 }
3562 }
3563 }
3564@@ -1449,7 +1451,7 @@ NDIS_STATUS RTMPReadParametersHook(
3565 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
3566 {
3567 //PSMode
3568- if (RTMPGetKeyParameter("PSMode", tmpbuf, 10, buffer))
3569+ if (RTMPGetKeyParameter("PSMode", tmpbuf, 32, buffer))
3570 {
3571 if (pAd->StaCfg.BssType == BSS_INFRA)
3572 {
3573@@ -1551,8 +1553,11 @@ NDIS_STATUS RTMPReadParametersHook(
3574 }
3575
3576 set_fs(orgfs);
3577- current->fsuid = orgfsuid;
3578- current->fsgid = orgfsgid;
3579+
3580+#if 0
3581+ current->cred->fsuid = orgfsuid;
3582+ current->cred->fsgid = orgfsgid;
3583+#endif
3584
3585 kfree(buffer);
3586 kfree(tmpbuf);
3587--- a/drivers/staging/rt2860/rtmp.h
3588+++ b/drivers/staging/rt2860/rtmp.h
3589@@ -203,9 +203,7 @@ typedef struct _ATE_INFO {
3590 BOOLEAN bRxFer;
3591 BOOLEAN bQATxStart; // Have compiled QA in and use it to ATE tx.
3592 BOOLEAN bQARxStart; // Have compiled QA in and use it to ATE rx.
3593-#ifdef RT2860
3594 BOOLEAN bFWLoading; // Reload firmware when ATE is done.
3595-#endif // RT2860 //
3596 UINT32 RxTotalCnt;
3597 UINT32 RxCntPerSec;
3598
3599@@ -366,6 +364,13 @@ typedef struct _QUEUE_HEADER {
3600 #define RTMP_TEST_FLAG(_M, _F) (((_M)->Flags & (_F)) != 0)
3601 #define RTMP_TEST_FLAGS(_M, _F) (((_M)->Flags & (_F)) == (_F))
3602
3603+// Macro for power save flag.
3604+#define RTMP_SET_PSFLAG(_M, _F) ((_M)->PSFlags |= (_F))
3605+#define RTMP_CLEAR_PSFLAG(_M, _F) ((_M)->PSFlags &= ~(_F))
3606+#define RTMP_CLEAR_PSFLAGS(_M) ((_M)->PSFlags = 0)
3607+#define RTMP_TEST_PSFLAG(_M, _F) (((_M)->PSFlags & (_F)) != 0)
3608+#define RTMP_TEST_PSFLAGS(_M, _F) (((_M)->PSFlags & (_F)) == (_F))
3609+
3610 #define OPSTATUS_SET_FLAG(_pAd, _F) ((_pAd)->CommonCfg.OpStatusFlags |= (_F))
3611 #define OPSTATUS_CLEAR_FLAG(_pAd, _F) ((_pAd)->CommonCfg.OpStatusFlags &= ~(_F))
3612 #define OPSTATUS_TEST_FLAG(_pAd, _F) (((_pAd)->CommonCfg.OpStatusFlags & (_F)) != 0)
3613@@ -478,7 +483,6 @@ typedef struct _QUEUE_HEADER {
3614 //
3615 #define MAX_BUSY_COUNT 100 // Number of retry before failing access BBP & RF indirect register
3616 //
3617-#ifdef RT2860
3618 #define RTMP_RF_IO_WRITE32(_A, _V) \
3619 { \
3620 PHY_CSR4_STRUC Value; \
3621@@ -642,7 +646,6 @@ typedef struct _QUEUE_HEADER {
3622 } \
3623 } \
3624 }
3625-#endif // RT2860 //
3626
3627
3628 #define MAP_CHANNEL_ID_TO_KHZ(ch, khz) { \
3629@@ -894,7 +897,6 @@ typedef struct _RTMP_SCATTER_GATHER_LIST
3630 // Enqueue this frame to MLME engine
3631 // We need to enqueue the whole frame because MLME need to pass data type
3632 // information from 802.11 header
3633-#ifdef RT2860
3634 #define REPORT_MGMT_FRAME_TO_MLME(_pAd, Wcid, _pFrame, _FrameSize, _Rssi0, _Rssi1, _Rssi2, _PlcpSignal) \
3635 { \
3636 UINT32 High32TSF, Low32TSF; \
3637@@ -902,7 +904,6 @@ typedef struct _RTMP_SCATTER_GATHER_LIST
3638 RTMP_IO_READ32(_pAd, TSF_TIMER_DW0, &Low32TSF); \
3639 MlmeEnqueueForRecv(_pAd, Wcid, High32TSF, Low32TSF, (UCHAR)_Rssi0, (UCHAR)_Rssi1,(UCHAR)_Rssi2,_FrameSize, _pFrame, (UCHAR)_PlcpSignal); \
3640 }
3641-#endif // RT2860 //
3642
3643 #define NDIS_QUERY_BUFFER(_NdisBuf, _ppVA, _pBufLen) \
3644 NdisQueryBuffer(_NdisBuf, _ppVA, _pBufLen)
3645@@ -919,9 +920,10 @@ typedef struct _RTMP_SCATTER_GATHER_LIST
3646 #define STA_PORT_SECURED(_pAd) \
3647 { \
3648 _pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED; \
3649- NdisAcquireSpinLock(&_pAd->MacTabLock); \
3650+ RTMP_SET_PSFLAG(_pAd, fRTMP_PS_CAN_GO_SLEEP); \
3651+ NdisAcquireSpinLock(&(_pAd)->MacTabLock); \
3652 _pAd->MacTab.Content[BSSID_WCID].PortSecured = _pAd->StaCfg.PortSecured; \
3653- NdisReleaseSpinLock(&_pAd->MacTabLock); \
3654+ NdisReleaseSpinLock(&(_pAd)->MacTabLock); \
3655 }
3656 #endif // CONFIG_STA_SUPPORT //
3657
3658@@ -1000,9 +1002,7 @@ typedef struct _RTMP_REORDERBUF
3659 UCHAR DataOffset;
3660 USHORT Datasize;
3661 ULONG AllocSize;
3662-#ifdef RT2860
3663 NDIS_PHYSICAL_ADDRESS AllocPa; // TxBuf physical address
3664-#endif // RT2860 //
3665 } RTMP_REORDERBUF, *PRTMP_REORDERBUF;
3666
3667 //
3668@@ -1101,6 +1101,7 @@ typedef struct _COUNTER_802_11 {
3669
3670 typedef struct _COUNTER_RALINK {
3671 ULONG TransmittedByteCount; // both successful and failure, used to calculate TX throughput
3672+ ULONG LastReceivedByteCount;
3673 ULONG ReceivedByteCount; // both CRC okay and CRC error, used to calculate RX throughput
3674 ULONG BeenDisassociatedCount;
3675 ULONG BadCQIAutoRecoveryCount;
3676@@ -1436,11 +1437,9 @@ typedef struct _MLME_STRUCT {
3677 RALINK_TIMER_STRUCT APSDPeriodicTimer;
3678 RALINK_TIMER_STRUCT LinkDownTimer;
3679 RALINK_TIMER_STRUCT LinkUpTimer;
3680-#ifdef RT2860
3681 UCHAR bPsPollTimerRunning;
3682 RALINK_TIMER_STRUCT PsPollTimer;
3683 RALINK_TIMER_STRUCT RadioOnOffTimer;
3684-#endif // RT2860 //
3685 ULONG PeriodicRound;
3686 ULONG OneSecPeriodicRound;
3687
3688@@ -2228,9 +2227,7 @@ typedef struct _STA_ADMIN_CONFIG {
3689 RT_HT_PHY_INFO DesiredHtPhyInfo;
3690 BOOLEAN bAutoTxRateSwitch;
3691
3692-#ifdef RT2860
3693 UCHAR BBPR3;
3694-#endif // RT2860 //
3695
3696 #ifdef EXT_BUILD_CHANNEL_LIST
3697 UCHAR IEEE80211dClientMode;
3698@@ -2663,7 +2660,6 @@ typedef struct _RTMP_ADAPTER
3699 PNET_DEV net_dev;
3700 ULONG VirtualIfCnt;
3701
3702-#ifdef RT2860
3703 USHORT LnkCtrlBitMask;
3704 USHORT RLnkCtrlConfiguration;
3705 USHORT RLnkCtrlOffset;
3706@@ -2671,7 +2667,9 @@ typedef struct _RTMP_ADAPTER
3707 USHORT HostLnkCtrlOffset;
3708 USHORT PCIePowerSaveLevel;
3709 BOOLEAN bPCIclkOff; // flag that indicate if the PICE power status in Configuration SPace..
3710- BOOLEAN bPCIclkOffDisableTx; //
3711+ ULONG CheckDmaBusyCount; // Check Interrupt Status Register Count.
3712+ USHORT ThisTbttNumToNextWakeUp;
3713+ ULONG SameRxByteCount;
3714
3715
3716 /*****************************************************************************************/
3717@@ -2688,7 +2686,6 @@ typedef struct _RTMP_ADAPTER
3718 RTMP_DMABUF RxDescRing; // Shared memory for RX descriptors
3719 RTMP_DMABUF TxDescRing[NUM_OF_TX_RING]; // Shared memory for Tx descriptors
3720 RTMP_TX_RING TxRing[NUM_OF_TX_RING]; // AC0~4 + HCCA
3721-#endif // RT2860 //
3722
3723
3724 NDIS_SPIN_LOCK irq_lock;
3725@@ -2721,10 +2718,8 @@ typedef struct _RTMP_ADAPTER
3726 /* Rx related parameters */
3727 /*****************************************************************************************/
3728
3729-#ifdef RT2860
3730 RTMP_RX_RING RxRing;
3731 NDIS_SPIN_LOCK RxRingLock; // Rx Ring spinlock
3732-#endif // RT2860 //
3733
3734
3735
3736@@ -2895,6 +2890,7 @@ typedef struct _RTMP_ADAPTER
3737
3738 // flags, see fRTMP_ADAPTER_xxx flags
3739 ULONG Flags; // Represent current device status
3740+ ULONG PSFlags; // Power Save operation flag.
3741
3742 // current TX sequence #
3743 USHORT Sequence;
3744@@ -3181,7 +3177,6 @@ typedef struct _TX_BLK_
3745 //------------------------------------------------------------------------------------------
3746
3747
3748-#ifdef RT2860
3749 //
3750 // Enable & Disable NIC interrupt via writing interrupt mask register
3751 // Since it use ADAPTER structure, it have to be put after structure definition.
3752@@ -3214,7 +3209,6 @@ __inline VOID NICEnableInterrupt(
3753 //RTMP_IO_WRITE32(pAd, PBF_INT_ENA, 0x00000030); // 1 : enable
3754 RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_ACTIVE);
3755 }
3756-#endif // RT2860 //
3757
3758 #ifdef RT_BIG_ENDIAN
3759 static inline VOID WriteBackToDescriptor(
3760@@ -3291,7 +3285,6 @@ static inline VOID RTMPWIEndianChange(
3761 Call this function when read or update descriptor
3762 ========================================================================
3763 */
3764-#ifdef RT2860
3765 static inline VOID RTMPDescriptorEndianChange(
3766 IN PUCHAR pData,
3767 IN ULONG DescriptorType)
3768@@ -3301,7 +3294,6 @@ static inline VOID RTMPDescriptorEndianC
3769 *((UINT32 *)(pData +12)) = SWAP32(*((UINT32 *)(pData + 12))); // Byte 12~15
3770 *((UINT32 *)(pData + 4)) = SWAP32(*((UINT32 *)(pData + 4))); // Byte 4~7, this must be swapped last
3771 }
3772-#endif // RT2860 //
3773
3774 /*
3775 ========================================================================
3776@@ -3550,6 +3542,9 @@ NDIS_STATUS NICInitializeAsic(
3777 IN PRTMP_ADAPTER pAd,
3778 IN BOOLEAN bHardReset);
3779
3780+VOID NICRestoreBBPValue(
3781+ IN PRTMP_ADAPTER pAd);
3782+
3783 VOID NICIssueReset(
3784 IN PRTMP_ADAPTER pAd);
3785
3786@@ -4208,7 +4203,7 @@ VOID AsicForceSleep(
3787
3788 VOID AsicForceWakeup(
3789 IN PRTMP_ADAPTER pAd,
3790- IN BOOLEAN bFromTx);
3791+ IN UCHAR Level);
3792 #endif // CONFIG_STA_SUPPORT //
3793
3794 VOID AsicSetBssid(
3795@@ -4304,11 +4299,9 @@ BOOLEAN AsicSendCommandToMcu(
3796 IN UCHAR Arg0,
3797 IN UCHAR Arg1);
3798
3799-#ifdef RT2860
3800 BOOLEAN AsicCheckCommanOk(
3801 IN PRTMP_ADAPTER pAd,
3802 IN UCHAR Command);
3803-#endif // RT2860 //
3804
3805 VOID MacAddrRandomBssid(
3806 IN PRTMP_ADAPTER pAd,
3807@@ -6978,7 +6971,6 @@ void kill_thread_task(PRTMP_ADAPTER pAd)
3808
3809 void tbtt_tasklet(unsigned long data);
3810
3811-#ifdef RT2860
3812 //
3813 // Function Prototype in cmm_data_2860.c
3814 //
3815@@ -7069,7 +7061,7 @@ BOOLEAN RT28xxPciAsicRadioOn(
3816
3817 VOID RT28xxPciStaAsicForceWakeup(
3818 IN PRTMP_ADAPTER pAd,
3819- IN BOOLEAN bFromTx);
3820+ IN UCHAR Level);
3821
3822 VOID RT28xxPciStaAsicSleepThenAutoWakeup(
3823 IN PRTMP_ADAPTER pAd,
3824@@ -7093,7 +7085,6 @@ VOID RT28xxPciMlmeRadioOn(
3825
3826 VOID RT28xxPciMlmeRadioOFF(
3827 IN PRTMP_ADAPTER pAd);
3828-#endif // RT2860 //
3829
3830 VOID AsicTurnOffRFClk(
3831 IN PRTMP_ADAPTER pAd,
3832@@ -7132,6 +7123,18 @@ PCHAR RTMPGetRalinkEncryModeStr(
3833 #ifdef CONFIG_STA_SUPPORT
3834 VOID AsicStaBbpTuning(
3835 IN PRTMP_ADAPTER pAd);
3836+
3837+VOID AsicResetFromDMABusy(
3838+ IN PRTMP_ADAPTER pAd);
3839+
3840+VOID AsicResetBBP(
3841+ IN PRTMP_ADAPTER pAd);
3842+
3843+VOID AsicResetMAC(
3844+ IN PRTMP_ADAPTER pAd);
3845+
3846+VOID AsicResetPBF(
3847+ IN PRTMP_ADAPTER pAd);
3848 #endif // CONFIG_STA_SUPPORT //
3849
3850 void RTMP_IndicateMediaState(
3851--- a/drivers/staging/rt2860/rtmp_def.h
3852+++ b/drivers/staging/rt2860/rtmp_def.h
3853@@ -111,7 +111,6 @@
3854 // Entry number for each DMA descriptor ring
3855 //
3856
3857-#ifdef RT2860
3858 #define TX_RING_SIZE 64 //64
3859 #define MGMT_RING_SIZE 128
3860 #define RX_RING_SIZE 128 //64
3861@@ -119,7 +118,6 @@
3862 #define MAX_DMA_DONE_PROCESS TX_RING_SIZE
3863 #define MAX_TX_DONE_PROCESS TX_RING_SIZE //8
3864 #define LOCAL_TXBUF_SIZE 2
3865-#endif // RT2860 //
3866
3867
3868 #ifdef MULTIPLE_CARD_SUPPORT
3869@@ -212,6 +210,19 @@
3870 #define fOP_STATUS_WAKEUP_NOW 0x00008000
3871 #define fOP_STATUS_ADVANCE_POWER_SAVE_PCIE_DEVICE 0x00020000
3872
3873+//
3874+// RTMP_ADAPTER PSFlags : related to advanced power save.
3875+//
3876+// Indicate whether driver can go to sleep mode from now. This flag is useful AFTER link up
3877+#define fRTMP_PS_CAN_GO_SLEEP 0x00000001
3878+// Indicate whether driver has issue a LinkControl command to PCIe L1
3879+#define fRTMP_PS_SET_PCI_CLK_OFF_COMMAND 0x00000002
3880+// Indicate driver should disable kick off hardware to send packets from now.
3881+#define fRTMP_PS_DISABLE_TX 0x00000004
3882+// Indicate driver should IMMEDIATELY fo to sleep after receiving AP's beacon in which doesn't indicate unicate nor multicast packets for me
3883+//. This flag is used ONLY in RTMPHandleRxDoneInterrupt routine.
3884+#define fRTMP_PS_GO_TO_SLEEP_NOW 0x00000008
3885+
3886 #ifdef DOT11N_DRAFT3
3887 #define fOP_STATUS_SCAN_2040 0x00040000
3888 #endif // DOT11N_DRAFT3 //
3889@@ -333,7 +344,7 @@
3890 /* sanity check for apidx */
3891 #define MBSS_MR_APIDX_SANITY_CHECK(apidx) \
3892 { if (apidx > MAX_MBSSID_NUM) { \
3893- printk("%s> Error! apidx = %d > MAX_MBSSID_NUM!\n", __FUNCTION__, apidx); \
3894+ printk("%s> Error! apidx = %d > MAX_MBSSID_NUM!\n", __func__, apidx); \
3895 apidx = MAIN_MBSSID; } }
3896
3897 #define VALID_WCID(_wcid) ((_wcid) > 0 && (_wcid) < MAX_LEN_OF_MAC_TABLE )
3898@@ -1514,12 +1525,14 @@
3899 #define MCAST_HTMIX 3
3900 #endif // MCAST_RATE_SPECIFIC //
3901
3902-// For AsicRadioOff/AsicRadioOn function
3903-#define DOT11POWERSAVE 0
3904-#define GUIRADIO_OFF 1
3905-#define RTMP_HALT 2
3906-#define GUI_IDLE_POWER_SAVE 3
3907-// --
3908+// For AsicRadioOff/AsicRadioOn/AsicForceWakeup function
3909+// This is to indicate from where to call this function.
3910+#define DOT11POWERSAVE 0 // TO do .11 power save sleep
3911+#define GUIRADIO_OFF 1 // To perform Radio OFf command from GUI
3912+#define RTMP_HALT 2 // Called from Halt handler.
3913+#define GUI_IDLE_POWER_SAVE 3 // Call to sleep before link up with AP
3914+#define FROM_TX 4 // Force wake up from Tx packet.
3915+
3916
3917
3918 // definition for WpaSupport flag
3919--- a/drivers/staging/rt2860/sta/assoc.c
3920+++ b/drivers/staging/rt2860/sta/assoc.c
3921@@ -473,12 +473,7 @@ VOID MlmeAssocReqAction(
3922 RSNIe = IE_WPA2;
3923 }
3924
3925-#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
3926-#ifdef SIOCSIWGENIE
3927- if (pAd->StaCfg.WpaSupplicantUP != 1)
3928-#endif // SIOCSIWGENIE //
3929-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
3930- RTMPMakeRSNIE(pAd, pAd->StaCfg.AuthMode, pAd->StaCfg.WepStatus, BSS0);
3931+ RTMPMakeRSNIE(pAd, pAd->StaCfg.AuthMode, pAd->StaCfg.WepStatus, BSS0);
3932
3933 // Check for WPA PMK cache list
3934 if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2)
3935@@ -504,17 +499,6 @@ VOID MlmeAssocReqAction(
3936 }
3937 }
3938
3939-#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
3940-#ifdef SIOCSIWGENIE
3941- if (pAd->StaCfg.WpaSupplicantUP == 1)
3942- {
3943- MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
3944- pAd->StaCfg.RSNIE_Len, pAd->StaCfg.RSN_IE,
3945- END_OF_ARGS);
3946- }
3947- else
3948-#endif
3949-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
3950 {
3951 MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
3952 1, &RSNIe,
3953@@ -525,11 +509,6 @@ VOID MlmeAssocReqAction(
3954
3955 FrameLen += tmp;
3956
3957-#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
3958-#ifdef SIOCSIWGENIE
3959- if (pAd->StaCfg.WpaSupplicantUP != 1)
3960-#endif
3961-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
3962 {
3963 // Append Variable IE
3964 NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset, &RSNIe, 1);
3965--- a/drivers/staging/rt2860/sta/connect.c
3966+++ b/drivers/staging/rt2860/sta/connect.c
3967@@ -337,6 +337,10 @@ VOID CntlOidSsidProc(
3968 MLME_DISASSOC_REQ_STRUCT DisassocReq;
3969 ULONG Now;
3970
3971+ // BBP and RF are not accessible in PS mode, we has to wake them up first
3972+ if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
3973+ AsicForceWakeup(pAd, RTMP_HALT);
3974+
3975 // Step 1. record the desired user settings to MlmeAux
3976 NdisZeroMemory(pAd->MlmeAux.Ssid, MAX_LEN_OF_SSID);
3977 NdisMoveMemory(pAd->MlmeAux.Ssid, pOidSsid->Ssid, pOidSsid->SsidLength);
3978@@ -1240,6 +1244,13 @@ VOID LinkUp(
3979 UCHAR Value = 0, idx;
3980 MAC_TABLE_ENTRY *pEntry = NULL, *pCurrEntry;
3981
3982+ if (RTMP_TEST_PSFLAG(pAd, fRTMP_PS_SET_PCI_CLK_OFF_COMMAND))
3983+ {
3984+ RTMPPCIeLinkCtrlValueRestore(pAd, RESTORE_HALT);
3985+ RTMPusecDelay(6000);
3986+ pAd->bPCIclkOff = FALSE;
3987+ }
3988+
3989 pEntry = &pAd->MacTab.Content[BSSID_WCID];
3990
3991 //
3992@@ -1264,7 +1275,6 @@ VOID LinkUp(
3993 //rt2860b. Don't know why need this
3994 SwitchBetweenWepAndCkip(pAd);
3995
3996-#ifdef RT2860
3997 // Before power save before link up function, We will force use 1R.
3998 // So after link up, check Rx antenna # again.
3999 RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &Value);
4000@@ -1282,7 +1292,6 @@ VOID LinkUp(
4001 }
4002 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, Value);
4003 pAd->StaCfg.BBPR3 = Value;
4004-#endif // RT2860 //
4005
4006 if (BssType == BSS_ADHOC)
4007 {
4008@@ -1330,9 +1339,7 @@ VOID LinkUp(
4009 RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &Value);
4010 Value &= (~0x20);
4011 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, Value);
4012-#ifdef RT2860
4013 pAd->StaCfg.BBPR3 = Value;
4014-#endif // RT2860 //
4015
4016 RTMP_IO_READ32(pAd, TX_BAND_CFG, &Data);
4017 Data &= 0xfffffffe;
4018@@ -1367,9 +1374,7 @@ VOID LinkUp(
4019 RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &Value);
4020 Value |= (0x20);
4021 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, Value);
4022-#ifdef RT2860
4023 pAd->StaCfg.BBPR3 = Value;
4024-#endif // RT2860 //
4025
4026 if (pAd->MACVersion == 0x28600100)
4027 {
4028@@ -1400,9 +1405,7 @@ VOID LinkUp(
4029 RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &Value);
4030 Value &= (~0x20);
4031 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, Value);
4032-#ifdef RT2860
4033 pAd->StaCfg.BBPR3 = Value;
4034-#endif // RT2860 //
4035
4036 if (pAd->MACVersion == 0x28600100)
4037 {
4038@@ -1598,6 +1601,8 @@ VOID LinkUp(
4039 IV = 0;
4040 IV |= (pAd->StaCfg.DefaultKeyId << 30);
4041 AsicUpdateWCIDIVEIV(pAd, BSSID_WCID, IV, 0);
4042+
4043+ RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
4044 }
4045 // NOTE:
4046 // the decision of using "short slot time" or not may change dynamically due to
4047@@ -1919,6 +1924,7 @@ VOID LinkUp(
4048 }
4049
4050 RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS);
4051+ RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_GO_TO_SLEEP_NOW);
4052
4053 #ifdef DOT11_N_SUPPORT
4054 #ifdef DOT11N_DRAFT3
4055@@ -1961,6 +1967,7 @@ VOID LinkDown(
4056 IN BOOLEAN IsReqFromAP)
4057 {
4058 UCHAR i, ByteValue = 0;
4059+ BOOLEAN Cancelled;
4060
4061 // Do nothing if monitor mode is on
4062 if (MONITOR_ON(pAd))
4063@@ -1972,6 +1979,12 @@ VOID LinkDown(
4064 return;
4065 #endif // RALINK_ATE //
4066
4067+ RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_GO_TO_SLEEP_NOW);
4068+ RTMPCancelTimer(&pAd->Mlme.PsPollTimer, &Cancelled);
4069+
4070+ // Not allow go to sleep within linkdown function.
4071+ RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
4072+
4073 if (pAd->CommonCfg.bWirelessEvent)
4074 {
4075 RTMPSendWirelessEvent(pAd, IW_STA_LINKDOWN_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
4076@@ -1980,7 +1993,6 @@ VOID LinkDown(
4077 DBGPRINT(RT_DEBUG_TRACE, ("!!! LINK DOWN !!!\n"));
4078 OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_AGGREGATION_INUSED);
4079
4080-#ifdef RT2860
4081 if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_ADVANCE_POWER_SAVE_PCIE_DEVICE))
4082 {
4083 BOOLEAN Cancelled;
4084@@ -1988,17 +2000,15 @@ VOID LinkDown(
4085 RTMPCancelTimer(&pAd->Mlme.PsPollTimer, &Cancelled);
4086 }
4087
4088- if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
4089+ if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE) ||
4090+ RTMP_TEST_PSFLAG(pAd, fRTMP_PS_SET_PCI_CLK_OFF_COMMAND) ||
4091+ RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_IDLE_RADIO_OFF))
4092 {
4093- AUTO_WAKEUP_STRUC AutoWakeupCfg;
4094- AsicForceWakeup(pAd, TRUE);
4095- AutoWakeupCfg.word = 0;
4096- RTMP_IO_WRITE32(pAd, AUTO_WAKEUP_CFG, AutoWakeupCfg.word);
4097+ AsicForceWakeup(pAd, RTMP_HALT);
4098 OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_DOZE);
4099 }
4100
4101 pAd->bPCIclkOff = FALSE;
4102-#endif // RT2860 //
4103 if (ADHOC_ON(pAd)) // Adhoc mode link down
4104 {
4105 DBGPRINT(RT_DEBUG_TRACE, ("!!! LINK DOWN 1!!!\n"));
4106@@ -2266,6 +2276,9 @@ VOID LinkDown(
4107 RTMP_IO_WRITE32(pAd, MAX_LEN_CFG, 0x1fff);
4108 RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS);
4109
4110+ // Allow go to sleep after linkdown steps.
4111+ RTMP_SET_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
4112+
4113 #ifdef WPA_SUPPLICANT_SUPPORT
4114 #ifndef NATIVE_WPA_SUPPLICANT_SUPPORT
4115 if (pAd->StaCfg.WpaSupplicantUP) {
4116@@ -2510,7 +2523,6 @@ VOID AuthParmFill(
4117
4118 ==========================================================================
4119 */
4120-#ifdef RT2860
4121 VOID ComposePsPoll(
4122 IN PRTMP_ADAPTER pAd)
4123 {
4124@@ -2534,7 +2546,6 @@ VOID ComposeNullFrame(
4125 COPY_MAC_ADDR(pAd->NullFrame.Addr2, pAd->CurrentAddress);
4126 COPY_MAC_ADDR(pAd->NullFrame.Addr3, pAd->CommonCfg.Bssid);
4127 }
4128-#endif // RT2860 //
4129
4130
4131
4132--- a/drivers/staging/rt2860/sta/dls.c
4133+++ b/drivers/staging/rt2860/sta/dls.c
4134@@ -1419,7 +1419,6 @@ BOOLEAN RTMPRcvFrameDLSCheck(
4135 //AsicAddKeyEntry(pAd, (USHORT)(i + 2), BSS0, 0, &PairwiseKey, TRUE, TRUE); // reserve 0 for multicast, 1 for unicast
4136 //AsicUpdateRxWCIDTable(pAd, (USHORT)(i + 2), pAddr);
4137 // Add Pair-wise key to Asic
4138-#ifdef RT2860
4139 AsicAddPairwiseKeyEntry(pAd,
4140 pAd->StaCfg.DLSEntry[i].MacAddr,
4141 (UCHAR)pAd->StaCfg.DLSEntry[i].MacTabMatchWCID,
4142@@ -1431,7 +1430,6 @@ BOOLEAN RTMPRcvFrameDLSCheck(
4143 PairwiseKey.CipherAlg,
4144 pEntry);
4145
4146-#endif // RT2860 //
4147 NdisMoveMemory(&pEntry->PairwiseKey, &PairwiseKey, sizeof(CIPHER_KEY));
4148 DBGPRINT(RT_DEBUG_TRACE,("DLS - Receive STAKey Message-1 (Peer STA MAC Address STAKey) \n"));
4149
4150@@ -1477,7 +1475,6 @@ BOOLEAN RTMPRcvFrameDLSCheck(
4151 //AsicAddKeyEntry(pAd, (USHORT)(i + 2), BSS0, 0, &PairwiseKey, TRUE, TRUE); // reserve 0 for multicast, 1 for unicast
4152 //AsicUpdateRxWCIDTable(pAd, (USHORT)(i + 2), pAddr);
4153 // Add Pair-wise key to Asic
4154-#ifdef RT2860
4155 AsicAddPairwiseKeyEntry(pAd,
4156 pAd->StaCfg.DLSEntry[i].MacAddr,
4157 (UCHAR)pAd->StaCfg.DLSEntry[i].MacTabMatchWCID,
4158@@ -1488,7 +1485,6 @@ BOOLEAN RTMPRcvFrameDLSCheck(
4159 0,
4160 PairwiseKey.CipherAlg,
4161 pEntry);
4162-#endif // RT2860 //
4163 NdisMoveMemory(&pEntry->PairwiseKey, &PairwiseKey, sizeof(CIPHER_KEY));
4164 DBGPRINT(RT_DEBUG_TRACE,("DLS - Receive STAKey Message-1 (Initiator STA MAC Address STAKey)\n"));
4165
4166--- a/drivers/staging/rt2860/sta/rtmp_data.c
4167+++ b/drivers/staging/rt2860/sta/rtmp_data.c
4168@@ -75,7 +75,6 @@ VOID STARxEAPOLFrameIndicate(
4169
4170 if (pAd->StaCfg.DesireSharedKey[idx].KeyLen > 0)
4171 {
4172-#ifdef RT2860
4173 MAC_TABLE_ENTRY *pEntry = &pAd->MacTab.Content[BSSID_WCID];
4174
4175 // Set key material and cipherAlg to Asic
4176@@ -89,7 +88,6 @@ VOID STARxEAPOLFrameIndicate(
4177
4178 pAd->IndicateMediaState = NdisMediaStateConnected;
4179 pAd->ExtraInfo = GENERAL_LINK_UP;
4180-#endif // RT2860 //
4181 // For Preventing ShardKey Table is cleared by remove key procedure.
4182 pAd->SharedKey[BSS0][idx].CipherAlg = CipherAlg;
4183 pAd->SharedKey[BSS0][idx].KeyLen = pAd->StaCfg.DesireSharedKey[idx].KeyLen;
4184@@ -693,14 +691,12 @@ BOOLEAN STARxDoneInterruptHandle(
4185 break;
4186 }
4187
4188-#ifdef RT2860
4189 if (RxProcessed++ > MAX_RX_PROCESS_CNT)
4190 {
4191 // need to reschedule rx handle
4192 bReschedule = TRUE;
4193 break;
4194 }
4195-#endif // RT2860 //
4196
4197 RxProcessed ++; // test
4198
4199@@ -811,6 +807,13 @@ BOOLEAN STARxDoneInterruptHandle(
4200 }
4201 }
4202
4203+ // fRTMP_PS_GO_TO_SLEEP_NOW is set if receiving beacon.
4204+ if (RTMP_TEST_PSFLAG(pAd, fRTMP_PS_GO_TO_SLEEP_NOW) && (INFRA_ON(pAd)))
4205+ {
4206+ RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_GO_TO_SLEEP_NOW);
4207+ AsicSleepThenAutoWakeup(pAd, pAd->ThisTbttNumToNextWakeUp);
4208+ bReschedule = FALSE;
4209+ }
4210 return bReschedule;
4211 }
4212
4213@@ -828,7 +831,7 @@ BOOLEAN STARxDoneInterruptHandle(
4214 VOID RTMPHandleTwakeupInterrupt(
4215 IN PRTMP_ADAPTER pAd)
4216 {
4217- AsicForceWakeup(pAd, FALSE);
4218+ AsicForceWakeup(pAd, DOT11POWERSAVE);
4219 }
4220
4221 /*
4222@@ -1220,7 +1223,6 @@ NDIS_STATUS STASendPacket(
4223
4224 ========================================================================
4225 */
4226-#ifdef RT2860
4227 NDIS_STATUS RTMPFreeTXDRequest(
4228 IN PRTMP_ADAPTER pAd,
4229 IN UCHAR QueIdx,
4230@@ -1264,7 +1266,6 @@ NDIS_STATUS RTMPFreeTXDRequest(
4231
4232 return (Status);
4233 }
4234-#endif // RT2860 //
4235
4236
4237
4238@@ -1889,7 +1890,8 @@ VOID STA_AMPDU_Frame_Tx(
4239 //
4240 // Kick out Tx
4241 //
4242- HAL_KickOutTx(pAd, pTxBlk, pTxBlk->QueIdx);
4243+ if (!RTMP_TEST_PSFLAG(pAd, fRTMP_PS_DISABLE_TX))
4244+ HAL_KickOutTx(pAd, pTxBlk, pTxBlk->QueIdx);
4245
4246 pAd->RalinkCounters.KickTxCount++;
4247 pAd->RalinkCounters.OneSecTxDoneCount++;
4248@@ -2019,7 +2021,8 @@ VOID STA_AMSDU_Frame_Tx(
4249 //
4250 // Kick out Tx
4251 //
4252- HAL_KickOutTx(pAd, pTxBlk, pTxBlk->QueIdx);
4253+ if (!RTMP_TEST_PSFLAG(pAd, fRTMP_PS_DISABLE_TX))
4254+ HAL_KickOutTx(pAd, pTxBlk, pTxBlk->QueIdx);
4255 }
4256 #endif // DOT11_N_SUPPORT //
4257
4258@@ -2139,7 +2142,8 @@ VOID STA_Legacy_Frame_Tx(
4259 //
4260 // Kick out Tx
4261 //
4262- HAL_KickOutTx(pAd, pTxBlk, pTxBlk->QueIdx);
4263+ if (!RTMP_TEST_PSFLAG(pAd, fRTMP_PS_DISABLE_TX))
4264+ HAL_KickOutTx(pAd, pTxBlk, pTxBlk->QueIdx);
4265 }
4266
4267
4268@@ -2249,7 +2253,8 @@ VOID STA_ARalink_Frame_Tx(
4269 //
4270 // Kick out Tx
4271 //
4272- HAL_KickOutTx(pAd, pTxBlk, pTxBlk->QueIdx);
4273+ if (!RTMP_TEST_PSFLAG(pAd, fRTMP_PS_DISABLE_TX))
4274+ HAL_KickOutTx(pAd, pTxBlk, pTxBlk->QueIdx);
4275
4276 }
4277
4278@@ -2526,7 +2531,7 @@ NDIS_STATUS STAHardTransmit(
4279 if ((pAd->StaCfg.Psm == PWR_SAVE) && OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
4280 {
4281 DBGPRINT_RAW(RT_DEBUG_TRACE, ("AsicForceWakeup At HardTx\n"));
4282- AsicForceWakeup(pAd, TRUE);
4283+ AsicForceWakeup(pAd, FROM_TX);
4284 }
4285
4286 // It should not change PSM bit, when APSD turn on.
4287--- a/drivers/staging/rt2860/sta/sync.c
4288+++ b/drivers/staging/rt2860/sta/sync.c
4289@@ -228,7 +228,6 @@ VOID MlmeScanReqAction(
4290 // Increase the scan retry counters.
4291 pAd->StaCfg.ScanCnt++;
4292
4293-#ifdef RT2860
4294 if ((OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_ADVANCE_POWER_SAVE_PCIE_DEVICE)) &&
4295 (IDLE_ON(pAd)) &&
4296 (pAd->StaCfg.bRadio == TRUE) &&
4297@@ -236,7 +235,6 @@ VOID MlmeScanReqAction(
4298 {
4299 RT28xxPciAsicRadioOn(pAd, GUI_IDLE_POWER_SAVE);
4300 }
4301-#endif // RT2860 //
4302
4303 // first check the parameter sanity
4304 if (MlmeScanReqSanity(pAd,
4305@@ -349,7 +347,6 @@ VOID MlmeJoinReqAction(
4306
4307 DBGPRINT(RT_DEBUG_TRACE, ("SYNC - MlmeJoinReqAction(BSS #%ld)\n", pInfo->BssIdx));
4308
4309-#ifdef RT2860
4310 if ((OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_ADVANCE_POWER_SAVE_PCIE_DEVICE)) &&
4311 (IDLE_ON(pAd)) &&
4312 (pAd->StaCfg.bRadio == TRUE) &&
4313@@ -357,7 +354,6 @@ VOID MlmeJoinReqAction(
4314 {
4315 RT28xxPciAsicRadioOn(pAd, GUI_IDLE_POWER_SAVE);
4316 }
4317-#endif // RT2860 //
4318
4319 // reset all the timers
4320 RTMPCancelTimer(&pAd->MlmeAux.ScanTimer, &TimerCancelled);
4321@@ -1300,8 +1296,6 @@ VOID PeerBeacon(
4322 {
4323 if (pAd->StaCfg.Adhoc20NJoined == FALSE)
4324 {
4325- UCHAR ByteValue = 0;
4326-
4327 pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel;
4328
4329 pAd->StaCfg.Adhoc20NJoined = TRUE;
4330@@ -1534,13 +1528,10 @@ VOID PeerBeacon(
4331 // 5. otherwise, put PHY back to sleep to save battery.
4332 if (MessageToMe)
4333 {
4334-#ifdef RT2860
4335 if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_ADVANCE_POWER_SAVE_PCIE_DEVICE))
4336 {
4337 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, pAd->StaCfg.BBPR3);
4338- // Turn clk to 80Mhz.
4339 }
4340-#endif // RT2860 //
4341 if (pAd->CommonCfg.bAPSDCapable && pAd->CommonCfg.APEdcaParm.bAPSDCapable &&
4342 pAd->CommonCfg.bAPSDAC_BE && pAd->CommonCfg.bAPSDAC_BK && pAd->CommonCfg.bAPSDAC_VI && pAd->CommonCfg.bAPSDAC_VO)
4343 {
4344@@ -1551,12 +1542,10 @@ VOID PeerBeacon(
4345 }
4346 else if (BcastFlag && (DtimCount == 0) && OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM))
4347 {
4348-#ifdef RT2860
4349 if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_ADVANCE_POWER_SAVE_PCIE_DEVICE))
4350 {
4351 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, pAd->StaCfg.BBPR3);
4352 }
4353-#endif // RT2860 //
4354 }
4355 else if ((pAd->TxSwQueue[QID_AC_BK].Number != 0) ||
4356 (pAd->TxSwQueue[QID_AC_BE].Number != 0) ||
4357@@ -1570,12 +1559,10 @@ VOID PeerBeacon(
4358 {
4359 // TODO: consider scheduled HCCA. might not be proper to use traditional DTIM-based power-saving scheme
4360 // can we cheat here (i.e. just check MGMT & AC_BE) for better performance?
4361-#ifdef RT2860
4362 if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_ADVANCE_POWER_SAVE_PCIE_DEVICE))
4363 {
4364 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, pAd->StaCfg.BBPR3);
4365 }
4366-#endif // RT2860 //
4367 }
4368 else
4369 {
4370@@ -1590,7 +1577,10 @@ VOID PeerBeacon(
4371
4372 if (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
4373 {
4374- AsicSleepThenAutoWakeup(pAd, TbttNumToNextWakeUp);
4375+ // Set a flag to go to sleep . Then after parse this RxDoneInterrupt, will go to sleep mode.
4376+ RTMP_SET_PSFLAG(pAd, fRTMP_PS_GO_TO_SLEEP_NOW);
4377+ pAd->ThisTbttNumToNextWakeUp = TbttNumToNextWakeUp;
4378+ //AsicSleepThenAutoWakeup(pAd, TbttNumToNextWakeUp);
4379 }
4380 }
4381 }
4382--- a/drivers/staging/rt2860/sta/wpa.c
4383+++ b/drivers/staging/rt2860/sta/wpa.c
4384@@ -1384,6 +1384,10 @@ VOID WpaGroupMsg1Action(
4385 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_TKIP;
4386 else if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption3Enabled)
4387 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_AES;
4388+ else if (pAd->StaCfg.GroupCipher == Ndis802_11GroupWEP40Enabled)
4389+ pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_WEP64;
4390+ else if (pAd->StaCfg.GroupCipher == Ndis802_11GroupWEP104Enabled)
4391+ pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_WEP128;
4392
4393 //hex_dump("Group Key :", pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key, LEN_TKIP_EK);
4394 }
4395@@ -1760,7 +1764,7 @@ BOOLEAN ParseKeyData(
4396 // Get GTK length - refer to IEEE 802.11i-2004 p.82
4397 GTKLEN = pKDE->Len -6;
4398
4399- if (GTKLEN < LEN_AES_KEY)
4400+ if (GTKLEN < MIN_LEN_OF_GTK)
4401 {
4402 DBGPRINT(RT_DEBUG_ERROR, ("ERROR: GTK Key length is too short (%d) \n", GTKLEN));
4403 return FALSE;
4404@@ -1786,6 +1790,10 @@ BOOLEAN ParseKeyData(
4405 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_TKIP;
4406 else if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption3Enabled)
4407 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_AES;
4408+ else if (pAd->StaCfg.GroupCipher == Ndis802_11GroupWEP40Enabled)
4409+ pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_WEP64;
4410+ else if (pAd->StaCfg.GroupCipher == Ndis802_11GroupWEP104Enabled)
4411+ pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_WEP128;
4412
4413 return TRUE;
4414
4415--- a/drivers/staging/rt2860/sta_ioctl.c
4416+++ b/drivers/staging/rt2860/sta_ioctl.c
4417@@ -49,15 +49,9 @@ extern ULONG RTDebugLevel;
4418
4419 #define GROUP_KEY_NO 4
4420
4421-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
4422 #define IWE_STREAM_ADD_EVENT(_A, _B, _C, _D, _E) iwe_stream_add_event(_A, _B, _C, _D, _E)
4423 #define IWE_STREAM_ADD_POINT(_A, _B, _C, _D, _E) iwe_stream_add_point(_A, _B, _C, _D, _E)
4424 #define IWE_STREAM_ADD_VALUE(_A, _B, _C, _D, _E, _F) iwe_stream_add_value(_A, _B, _C, _D, _E, _F)
4425-#else
4426-#define IWE_STREAM_ADD_EVENT(_A, _B, _C, _D, _E) iwe_stream_add_event(_B, _C, _D, _E)
4427-#define IWE_STREAM_ADD_POINT(_A, _B, _C, _D, _E) iwe_stream_add_point(_B, _C, _D, _E)
4428-#define IWE_STREAM_ADD_VALUE(_A, _B, _C, _D, _E, _F) iwe_stream_add_value(_B, _C, _D, _E, _F)
4429-#endif
4430
4431 extern UCHAR CipherWpa2Template[];
4432 extern UCHAR CipherWpaPskTkip[];
4433@@ -358,6 +352,20 @@ VOID RTMPAddKey(
4434
4435 DBGPRINT(RT_DEBUG_TRACE, ("RTMPAddKey ------>\n"));
4436
4437+ RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
4438+ if (RTMP_TEST_PSFLAG(pAd, fRTMP_PS_SET_PCI_CLK_OFF_COMMAND))
4439+ {
4440+ if (pAd->StaCfg.bRadio == FALSE)
4441+ {
4442+ RTMP_SET_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
4443+ return;
4444+ }
4445+ DBGPRINT(RT_DEBUG_TRACE,("RTMPWPAAddKeyProc1==>\n"));
4446+ RTMPPCIeLinkCtrlValueRestore(pAd, RESTORE_HALT);
4447+ RTMPusecDelay(6000);
4448+ pAd->bPCIclkOff = FALSE;
4449+ }
4450+
4451 if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
4452 {
4453 if (pKey->KeyIndex & 0x80000000)
4454@@ -551,6 +559,8 @@ VOID RTMPAddKey(
4455 }
4456 }
4457 end:
4458+ RTMP_SET_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
4459+ DBGPRINT(RT_DEBUG_INFO, ("<------ RTMPAddKey\n"));
4460 return;
4461 }
4462
4463@@ -571,11 +581,9 @@ rt_ioctl_giwname(struct net_device *dev,
4464 struct iw_request_info *info,
4465 char *name, char *extra)
4466 {
4467-// PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;
4468+// PRTMP_ADAPTER pAdapter = dev->ml_priv;
4469
4470-#ifdef RT2860
4471 strncpy(name, "RT2860 Wireless", IFNAMSIZ);
4472-#endif // RT2860 //
4473 return 0;
4474 }
4475
4476@@ -583,7 +591,7 @@ int rt_ioctl_siwfreq(struct net_device *
4477 struct iw_request_info *info,
4478 struct iw_freq *freq, char *extra)
4479 {
4480- PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;
4481+ PRTMP_ADAPTER pAdapter = dev->ml_priv;
4482 int chan = -1;
4483
4484 //check if the interface is down
4485@@ -623,19 +631,19 @@ int rt_ioctl_giwfreq(struct net_device *
4486
4487 if (dev->priv_flags == INT_MAIN)
4488 {
4489- pAdapter = dev->priv;
4490+ pAdapter = dev->ml_priv;
4491 }
4492 else
4493 {
4494- pVirtualAd = dev->priv;
4495+ pVirtualAd = dev->ml_priv;
4496 if (pVirtualAd && pVirtualAd->RtmpDev)
4497- pAdapter = pVirtualAd->RtmpDev->priv;
4498+ pAdapter = pVirtualAd->RtmpDev->ml_priv;
4499 }
4500
4501 if (pAdapter == NULL)
4502 {
4503 /* if 1st open fail, pAd will be free;
4504- So the net_dev->priv will be NULL in 2rd open */
4505+ So the net_dev->ml_priv will be NULL in 2rd open */
4506 return -ENETDOWN;
4507 }
4508
4509@@ -653,7 +661,7 @@ int rt_ioctl_siwmode(struct net_device *
4510 struct iw_request_info *info,
4511 __u32 *mode, char *extra)
4512 {
4513- PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;
4514+ PRTMP_ADAPTER pAdapter = dev->ml_priv;
4515
4516 //check if the interface is down
4517 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
4518@@ -670,11 +678,9 @@ int rt_ioctl_siwmode(struct net_device *
4519 case IW_MODE_INFRA:
4520 Set_NetworkType_Proc(pAdapter, "Infra");
4521 break;
4522-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,4,20))
4523 case IW_MODE_MONITOR:
4524 Set_NetworkType_Proc(pAdapter, "Monitor");
4525 break;
4526-#endif
4527 default:
4528 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_siwmode::SIOCSIWMODE (unknown %d)\n", *mode));
4529 return -EINVAL;
4530@@ -695,19 +701,19 @@ int rt_ioctl_giwmode(struct net_device *
4531
4532 if (dev->priv_flags == INT_MAIN)
4533 {
4534- pAdapter = dev->priv;
4535+ pAdapter = dev->ml_priv;
4536 }
4537 else
4538 {
4539- pVirtualAd = dev->priv;
4540+ pVirtualAd = dev->ml_priv;
4541 if (pVirtualAd && pVirtualAd->RtmpDev)
4542- pAdapter = pVirtualAd->RtmpDev->priv;
4543+ pAdapter = pVirtualAd->RtmpDev->ml_priv;
4544 }
4545
4546 if (pAdapter == NULL)
4547 {
4548 /* if 1st open fail, pAd will be free;
4549- So the net_dev->priv will be NULL in 2rd open */
4550+ So the net_dev->ml_priv will be NULL in 2rd open */
4551 return -ENETDOWN;
4552 }
4553
4554@@ -715,12 +721,10 @@ int rt_ioctl_giwmode(struct net_device *
4555 *mode = IW_MODE_ADHOC;
4556 else if (INFRA_ON(pAdapter))
4557 *mode = IW_MODE_INFRA;
4558-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,4,20))
4559 else if (MONITOR_ON(pAdapter))
4560 {
4561 *mode = IW_MODE_MONITOR;
4562 }
4563-#endif
4564 else
4565 *mode = IW_MODE_AUTO;
4566
4567@@ -732,7 +736,7 @@ int rt_ioctl_siwsens(struct net_device *
4568 struct iw_request_info *info,
4569 char *name, char *extra)
4570 {
4571- PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;
4572+ PRTMP_ADAPTER pAdapter = dev->ml_priv;
4573
4574 //check if the interface is down
4575 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
4576@@ -763,19 +767,19 @@ int rt_ioctl_giwrange(struct net_device
4577
4578 if (dev->priv_flags == INT_MAIN)
4579 {
4580- pAdapter = dev->priv;
4581+ pAdapter = dev->ml_priv;
4582 }
4583 else
4584 {
4585- pVirtualAd = dev->priv;
4586+ pVirtualAd = dev->ml_priv;
4587 if (pVirtualAd && pVirtualAd->RtmpDev)
4588- pAdapter = pVirtualAd->RtmpDev->priv;
4589+ pAdapter = pVirtualAd->RtmpDev->ml_priv;
4590 }
4591
4592 if (pAdapter == NULL)
4593 {
4594 /* if 1st open fail, pAd will be free;
4595- So the net_dev->priv will be NULL in 2rd open */
4596+ So the net_dev->ml_priv will be NULL in 2rd open */
4597 return -ENETDOWN;
4598 }
4599
4600@@ -857,7 +861,7 @@ int rt_ioctl_siwap(struct net_device *de
4601 struct iw_request_info *info,
4602 struct sockaddr *ap_addr, char *extra)
4603 {
4604- PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;
4605+ PRTMP_ADAPTER pAdapter = dev->ml_priv;
4606 NDIS_802_11_MAC_ADDRESS Bssid;
4607
4608 //check if the interface is down
4609@@ -902,19 +906,19 @@ int rt_ioctl_giwap(struct net_device *de
4610
4611 if (dev->priv_flags == INT_MAIN)
4612 {
4613- pAdapter = dev->priv;
4614+ pAdapter = dev->ml_priv;
4615 }
4616 else
4617 {
4618- pVirtualAd = dev->priv;
4619+ pVirtualAd = dev->ml_priv;
4620 if (pVirtualAd && pVirtualAd->RtmpDev)
4621- pAdapter = pVirtualAd->RtmpDev->priv;
4622+ pAdapter = pVirtualAd->RtmpDev->ml_priv;
4623 }
4624
4625 if (pAdapter == NULL)
4626 {
4627 /* if 1st open fail, pAd will be free;
4628- So the net_dev->priv will be NULL in 2rd open */
4629+ So the net_dev->ml_priv will be NULL in 2rd open */
4630 return -ENETDOWN;
4631 }
4632
4633@@ -984,7 +988,7 @@ int rt_ioctl_iwaplist(struct net_device
4634 struct iw_request_info *info,
4635 struct iw_point *data, char *extra)
4636 {
4637- PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;
4638+ PRTMP_ADAPTER pAdapter = dev->ml_priv;
4639
4640 struct sockaddr addr[IW_MAX_AP];
4641 struct iw_quality qual[IW_MAX_AP];
4642@@ -1020,7 +1024,7 @@ int rt_ioctl_siwscan(struct net_device *
4643 struct iw_request_info *info,
4644 struct iw_point *data, char *extra)
4645 {
4646- PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;
4647+ PRTMP_ADAPTER pAdapter = dev->ml_priv;
4648
4649 ULONG Now;
4650 int Status = NDIS_STATUS_SUCCESS;
4651@@ -1038,6 +1042,15 @@ int rt_ioctl_siwscan(struct net_device *
4652 return -EINVAL;
4653 }
4654
4655+ if ((pAdapter->OpMode == OPMODE_STA) && (IDLE_ON(pAdapter))
4656+ && (pAdapter->StaCfg.bRadio == TRUE)
4657+ && (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_IDLE_RADIO_OFF)))
4658+ {
4659+ RT28xxPciAsicRadioOn(pAdapter, GUI_IDLE_POWER_SAVE);
4660+ }
4661+ // Check if still radio off.
4662+ else if (pAdapter->bPCIclkOff == TRUE)
4663+ return 0;
4664
4665 #ifdef WPA_SUPPLICANT_SUPPORT
4666 if (pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
4667@@ -1102,7 +1115,7 @@ int rt_ioctl_giwscan(struct net_device *
4668 struct iw_point *data, char *extra)
4669 {
4670
4671- PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;
4672+ PRTMP_ADAPTER pAdapter = dev->ml_priv;
4673 int i=0;
4674 char *current_ev = extra, *previous_ev = extra;
4675 char *end_buf;
4676@@ -1391,7 +1404,7 @@ int rt_ioctl_siwessid(struct net_device
4677 struct iw_request_info *info,
4678 struct iw_point *data, char *essid)
4679 {
4680- PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;
4681+ PRTMP_ADAPTER pAdapter = dev->ml_priv;
4682
4683 //check if the interface is down
4684 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
4685@@ -1437,19 +1450,19 @@ int rt_ioctl_giwessid(struct net_device
4686
4687 if (dev->priv_flags == INT_MAIN)
4688 {
4689- pAdapter = dev->priv;
4690+ pAdapter = dev->ml_priv;
4691 }
4692 else
4693 {
4694- pVirtualAd = dev->priv;
4695+ pVirtualAd = dev->ml_priv;
4696 if (pVirtualAd && pVirtualAd->RtmpDev)
4697- pAdapter = pVirtualAd->RtmpDev->priv;
4698+ pAdapter = pVirtualAd->RtmpDev->ml_priv;
4699 }
4700
4701 if (pAdapter == NULL)
4702 {
4703 /* if 1st open fail, pAd will be free;
4704- So the net_dev->priv will be NULL in 2rd open */
4705+ So the net_dev->ml_priv will be NULL in 2rd open */
4706 return -ENETDOWN;
4707 }
4708
4709@@ -1480,7 +1493,7 @@ int rt_ioctl_siwnickn(struct net_device
4710 struct iw_request_info *info,
4711 struct iw_point *data, char *nickname)
4712 {
4713- PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;
4714+ PRTMP_ADAPTER pAdapter = dev->ml_priv;
4715
4716 //check if the interface is down
4717 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
4718@@ -1508,19 +1521,19 @@ int rt_ioctl_giwnickn(struct net_device
4719
4720 if (dev->priv_flags == INT_MAIN)
4721 {
4722- pAdapter = dev->priv;
4723+ pAdapter = dev->ml_priv;
4724 }
4725 else
4726 {
4727- pVirtualAd = dev->priv;
4728+ pVirtualAd = dev->ml_priv;
4729 if (pVirtualAd && pVirtualAd->RtmpDev)
4730- pAdapter = pVirtualAd->RtmpDev->priv;
4731+ pAdapter = pVirtualAd->RtmpDev->ml_priv;
4732 }
4733
4734 if (pAdapter == NULL)
4735 {
4736 /* if 1st open fail, pAd will be free;
4737- So the net_dev->priv will be NULL in 2rd open */
4738+ So the net_dev->ml_priv will be NULL in 2rd open */
4739 return -ENETDOWN;
4740 }
4741
4742@@ -1537,7 +1550,7 @@ int rt_ioctl_siwrts(struct net_device *d
4743 struct iw_request_info *info,
4744 struct iw_param *rts, char *extra)
4745 {
4746- PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;
4747+ PRTMP_ADAPTER pAdapter = dev->ml_priv;
4748 u16 val;
4749
4750 //check if the interface is down
4751@@ -1571,19 +1584,19 @@ int rt_ioctl_giwrts(struct net_device *d
4752
4753 if (dev->priv_flags == INT_MAIN)
4754 {
4755- pAdapter = dev->priv;
4756+ pAdapter = dev->ml_priv;
4757 }
4758 else
4759 {
4760- pVirtualAd = dev->priv;
4761+ pVirtualAd = dev->ml_priv;
4762 if (pVirtualAd && pVirtualAd->RtmpDev)
4763- pAdapter = pVirtualAd->RtmpDev->priv;
4764+ pAdapter = pVirtualAd->RtmpDev->ml_priv;
4765 }
4766
4767 if (pAdapter == NULL)
4768 {
4769 /* if 1st open fail, pAd will be free;
4770- So the net_dev->priv will be NULL in 2rd open */
4771+ So the net_dev->ml_priv will be NULL in 2rd open */
4772 return -ENETDOWN;
4773 }
4774
4775@@ -1605,7 +1618,7 @@ int rt_ioctl_siwfrag(struct net_device *
4776 struct iw_request_info *info,
4777 struct iw_param *frag, char *extra)
4778 {
4779- PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;
4780+ PRTMP_ADAPTER pAdapter = dev->ml_priv;
4781 u16 val;
4782
4783 //check if the interface is down
4784@@ -1637,19 +1650,19 @@ int rt_ioctl_giwfrag(struct net_device *
4785
4786 if (dev->priv_flags == INT_MAIN)
4787 {
4788- pAdapter = dev->priv;
4789+ pAdapter = dev->ml_priv;
4790 }
4791 else
4792 {
4793- pVirtualAd = dev->priv;
4794+ pVirtualAd = dev->ml_priv;
4795 if (pVirtualAd && pVirtualAd->RtmpDev)
4796- pAdapter = pVirtualAd->RtmpDev->priv;
4797+ pAdapter = pVirtualAd->RtmpDev->ml_priv;
4798 }
4799
4800 if (pAdapter == NULL)
4801 {
4802 /* if 1st open fail, pAd will be free;
4803- So the net_dev->priv will be NULL in 2rd open */
4804+ So the net_dev->ml_priv will be NULL in 2rd open */
4805 return -ENETDOWN;
4806 }
4807
4808@@ -1673,7 +1686,7 @@ int rt_ioctl_siwencode(struct net_device
4809 struct iw_request_info *info,
4810 struct iw_point *erq, char *extra)
4811 {
4812- PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;
4813+ PRTMP_ADAPTER pAdapter = dev->ml_priv;
4814
4815 //check if the interface is down
4816 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
4817@@ -1756,7 +1769,7 @@ int rt_ioctl_siwencode(struct net_device
4818 }
4819 else
4820 /* Don't complain if only change the mode */
4821- if(!erq->flags & IW_ENCODE_MODE) {
4822+ if (!(erq->flags & IW_ENCODE_MODE)) {
4823 return -EINVAL;
4824 }
4825 }
4826@@ -1780,19 +1793,19 @@ rt_ioctl_giwencode(struct net_device *de
4827
4828 if (dev->priv_flags == INT_MAIN)
4829 {
4830- pAdapter = dev->priv;
4831+ pAdapter = dev->ml_priv;
4832 }
4833 else
4834 {
4835- pVirtualAd = dev->priv;
4836+ pVirtualAd = dev->ml_priv;
4837 if (pVirtualAd && pVirtualAd->RtmpDev)
4838- pAdapter = pVirtualAd->RtmpDev->priv;
4839+ pAdapter = pVirtualAd->RtmpDev->ml_priv;
4840 }
4841
4842 if (pAdapter == NULL)
4843 {
4844 /* if 1st open fail, pAd will be free;
4845- So the net_dev->priv will be NULL in 2rd open */
4846+ So the net_dev->ml_priv will be NULL in 2rd open */
4847 return -ENETDOWN;
4848 }
4849
4850@@ -1860,19 +1873,19 @@ rt_ioctl_setparam(struct net_device *dev
4851
4852 if (dev->priv_flags == INT_MAIN)
4853 {
4854- pAdapter = dev->priv;
4855+ pAdapter = dev->ml_priv;
4856 }
4857 else
4858 {
4859- pVirtualAd = dev->priv;
4860- pAdapter = pVirtualAd->RtmpDev->priv;
4861+ pVirtualAd = dev->ml_priv;
4862+ pAdapter = pVirtualAd->RtmpDev->ml_priv;
4863 }
4864 pObj = (POS_COOKIE) pAdapter->OS_Cookie;
4865
4866 if (pAdapter == NULL)
4867 {
4868 /* if 1st open fail, pAd will be free;
4869- So the net_dev->priv will be NULL in 2rd open */
4870+ So the net_dev->ml_priv will be NULL in 2rd open */
4871 return -ENETDOWN;
4872 }
4873
4874@@ -1928,7 +1941,7 @@ rt_private_get_statistics(struct net_dev
4875 struct iw_point *wrq, char *extra)
4876 {
4877 INT Status = 0;
4878- PRTMP_ADAPTER pAd = (PRTMP_ADAPTER) dev->priv;
4879+ PRTMP_ADAPTER pAd = dev->ml_priv;
4880
4881 if (extra == NULL)
4882 {
4883@@ -2055,18 +2068,18 @@ rt_private_show(struct net_device *dev,
4884 u32 subcmd = wrq->flags;
4885
4886 if (dev->priv_flags == INT_MAIN)
4887- pAd = dev->priv;
4888+ pAd = dev->ml_priv;
4889 else
4890 {
4891- pVirtualAd = dev->priv;
4892- pAd = pVirtualAd->RtmpDev->priv;
4893+ pVirtualAd = dev->ml_priv;
4894+ pAd = pVirtualAd->RtmpDev->ml_priv;
4895 }
4896 pObj = (POS_COOKIE) pAd->OS_Cookie;
4897
4898 if (pAd == NULL)
4899 {
4900 /* if 1st open fail, pAd will be free;
4901- So the net_dev->priv will be NULL in 2rd open */
4902+ So the net_dev->ml_priv will be NULL in 2rd open */
4903 return -ENETDOWN;
4904 }
4905
4906@@ -2161,12 +2174,6 @@ rt_private_show(struct net_device *dev,
4907 wrq->length = strlen(extra) + 1; // 1: size of '\0'
4908 break;
4909 case RAIO_ON:
4910- if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
4911- {
4912- sprintf(extra, "Scanning\n");
4913- wrq->length = strlen(extra) + 1; // 1: size of '\0'
4914- break;
4915- }
4916 pAd->StaCfg.bSwRadio = TRUE;
4917 //if (pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio))
4918 {
4919@@ -2200,7 +2207,7 @@ rt_private_show(struct net_device *dev,
4920 }
4921 break;
4922 default:
4923- DBGPRINT(RT_DEBUG_TRACE, ("%s - unknow subcmd = %d\n", __FUNCTION__, subcmd));
4924+ DBGPRINT(RT_DEBUG_TRACE, ("%s - unknow subcmd = %d\n", __func__, subcmd));
4925 break;
4926 }
4927
4928@@ -2213,13 +2220,13 @@ int rt_ioctl_siwmlme(struct net_device *
4929 union iwreq_data *wrqu,
4930 char *extra)
4931 {
4932- PRTMP_ADAPTER pAd = (PRTMP_ADAPTER) dev->priv;
4933+ PRTMP_ADAPTER pAd = dev->ml_priv;
4934 struct iw_mlme *pMlme = (struct iw_mlme *)wrqu->data.pointer;
4935 MLME_QUEUE_ELEM MsgElem;
4936 MLME_DISASSOC_REQ_STRUCT DisAssocReq;
4937 MLME_DEAUTH_REQ_STRUCT DeAuthReq;
4938
4939- DBGPRINT(RT_DEBUG_TRACE, ("====> %s\n", __FUNCTION__));
4940+ DBGPRINT(RT_DEBUG_TRACE, ("====> %s\n", __func__));
4941
4942 if (pMlme == NULL)
4943 return -EINVAL;
4944@@ -2228,7 +2235,7 @@ int rt_ioctl_siwmlme(struct net_device *
4945 {
4946 #ifdef IW_MLME_DEAUTH
4947 case IW_MLME_DEAUTH:
4948- DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DEAUTH\n", __FUNCTION__));
4949+ DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DEAUTH\n", __func__));
4950 COPY_MAC_ADDR(DeAuthReq.Addr, pAd->CommonCfg.Bssid);
4951 DeAuthReq.Reason = pMlme->reason_code;
4952 MsgElem.MsgLen = sizeof(MLME_DEAUTH_REQ_STRUCT);
4953@@ -2243,7 +2250,7 @@ int rt_ioctl_siwmlme(struct net_device *
4954 #endif // IW_MLME_DEAUTH //
4955 #ifdef IW_MLME_DISASSOC
4956 case IW_MLME_DISASSOC:
4957- DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DISASSOC\n", __FUNCTION__));
4958+ DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DISASSOC\n", __func__));
4959 COPY_MAC_ADDR(DisAssocReq.Addr, pAd->CommonCfg.Bssid);
4960 DisAssocReq.Reason = pMlme->reason_code;
4961
4962@@ -2257,7 +2264,7 @@ int rt_ioctl_siwmlme(struct net_device *
4963 break;
4964 #endif // IW_MLME_DISASSOC //
4965 default:
4966- DBGPRINT(RT_DEBUG_TRACE, ("====> %s - Unknow Command\n", __FUNCTION__));
4967+ DBGPRINT(RT_DEBUG_TRACE, ("====> %s - Unknow Command\n", __func__));
4968 break;
4969 }
4970
4971@@ -2270,7 +2277,7 @@ int rt_ioctl_siwauth(struct net_device *
4972 struct iw_request_info *info,
4973 union iwreq_data *wrqu, char *extra)
4974 {
4975- PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;
4976+ PRTMP_ADAPTER pAdapter = dev->ml_priv;
4977 struct iw_param *param = &wrqu->param;
4978
4979 //check if the interface is down
4980@@ -2290,7 +2297,7 @@ int rt_ioctl_siwauth(struct net_device *
4981 else if (param->value == IW_AUTH_WPA_VERSION_WPA2)
4982 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
4983
4984- DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __FUNCTION__, param->value));
4985+ DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __func__, param->value));
4986 break;
4987 case IW_AUTH_CIPHER_PAIRWISE:
4988 if (param->value == IW_AUTH_CIPHER_NONE)
4989@@ -2321,7 +2328,7 @@ int rt_ioctl_siwauth(struct net_device *
4990 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
4991 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption3Enabled;
4992 }
4993- DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_PAIRWISE - param->value = %d!\n", __FUNCTION__, param->value));
4994+ DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_PAIRWISE - param->value = %d!\n", __func__, param->value));
4995 break;
4996 case IW_AUTH_CIPHER_GROUP:
4997 if (param->value == IW_AUTH_CIPHER_NONE)
4998@@ -2341,7 +2348,7 @@ int rt_ioctl_siwauth(struct net_device *
4999 {
5000 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption3Enabled;
5001 }
5002- DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_GROUP - param->value = %d!\n", __FUNCTION__, param->value));
5003+ DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_GROUP - param->value = %d!\n", __func__, param->value));
5004 break;
5005 case IW_AUTH_KEY_MGMT:
5006 if (param->value == IW_AUTH_KEY_MGMT_802_1X)
5007@@ -2370,12 +2377,12 @@ int rt_ioctl_siwauth(struct net_device *
5008 {
5009 STA_PORT_SECURED(pAdapter);
5010 }
5011- DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_KEY_MGMT - param->value = %d!\n", __FUNCTION__, param->value));
5012+ DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_KEY_MGMT - param->value = %d!\n", __func__, param->value));
5013 break;
5014 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
5015 break;
5016 case IW_AUTH_PRIVACY_INVOKED:
5017- DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_PRIVACY_INVOKED - param->value = %d!\n", __FUNCTION__, param->value));
5018+ DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_PRIVACY_INVOKED - param->value = %d!\n", __func__, param->value));
5019 break;
5020 case IW_AUTH_DROP_UNENCRYPTED:
5021 if (param->value != 0)
5022@@ -2384,7 +2391,7 @@ int rt_ioctl_siwauth(struct net_device *
5023 {
5024 STA_PORT_SECURED(pAdapter);
5025 }
5026- DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __FUNCTION__, param->value));
5027+ DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __func__, param->value));
5028 break;
5029 case IW_AUTH_80211_AUTH_ALG:
5030 if (param->value & IW_AUTH_ALG_SHARED_KEY)
5031@@ -2397,10 +2404,10 @@ int rt_ioctl_siwauth(struct net_device *
5032 }
5033 else
5034 return -EINVAL;
5035- DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_80211_AUTH_ALG - param->value = %d!\n", __FUNCTION__, param->value));
5036+ DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_80211_AUTH_ALG - param->value = %d!\n", __func__, param->value));
5037 break;
5038 case IW_AUTH_WPA_ENABLED:
5039- DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_ENABLED - Driver supports WPA!(param->value = %d)\n", __FUNCTION__, param->value));
5040+ DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_ENABLED - Driver supports WPA!(param->value = %d)\n", __func__, param->value));
5041 break;
5042 default:
5043 return -EOPNOTSUPP;
5044@@ -2413,7 +2420,7 @@ int rt_ioctl_giwauth(struct net_device *
5045 struct iw_request_info *info,
5046 union iwreq_data *wrqu, char *extra)
5047 {
5048- PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;
5049+ PRTMP_ADAPTER pAdapter = dev->ml_priv;
5050 struct iw_param *param = &wrqu->param;
5051
5052 //check if the interface is down
5053@@ -2450,6 +2457,20 @@ void fnSetCipherKey(
5054 IN BOOLEAN bGTK,
5055 IN struct iw_encode_ext *ext)
5056 {
5057+ RTMP_CLEAR_PSFLAG(pAdapter, fRTMP_PS_CAN_GO_SLEEP);
5058+ if (RTMP_TEST_PSFLAG(pAdapter, fRTMP_PS_SET_PCI_CLK_OFF_COMMAND))
5059+ {
5060+ if (pAdapter->StaCfg.bRadio == FALSE)
5061+ {
5062+ RTMP_SET_PSFLAG(pAdapter, fRTMP_PS_CAN_GO_SLEEP);
5063+ return;
5064+ }
5065+ DBGPRINT(RT_DEBUG_TRACE,("RTMPWPAAddKeyProc1==>\n"));
5066+ RTMPPCIeLinkCtrlValueRestore(pAdapter, RESTORE_HALT);
5067+ RTMPusecDelay(6000);
5068+ pAdapter->bPCIclkOff = FALSE;
5069+ }
5070+
5071 NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY));
5072 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = LEN_TKIP_EK;
5073 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, LEN_TKIP_EK);
5074@@ -2480,6 +2501,8 @@ void fnSetCipherKey(
5075 keyIdx,
5076 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
5077 &pAdapter->MacTab.Content[BSSID_WCID]);
5078+
5079+ RTMP_SET_PSFLAG(pAdapter, fRTMP_PS_CAN_GO_SLEEP);
5080 }
5081
5082 int rt_ioctl_siwencodeext(struct net_device *dev,
5083@@ -2487,7 +2510,7 @@ int rt_ioctl_siwencodeext(struct net_dev
5084 union iwreq_data *wrqu,
5085 char *extra)
5086 {
5087- PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;
5088+ PRTMP_ADAPTER pAdapter = dev->ml_priv;
5089 struct iw_point *encoding = &wrqu->encoding;
5090 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
5091 int keyIdx, alg = ext->alg;
5092@@ -2508,7 +2531,7 @@ int rt_ioctl_siwencodeext(struct net_dev
5093 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_NONE;
5094 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)keyIdx);
5095 NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY));
5096- DBGPRINT(RT_DEBUG_TRACE, ("%s::Remove all keys!(encoding->flags = %x)\n", __FUNCTION__, encoding->flags));
5097+ DBGPRINT(RT_DEBUG_TRACE, ("%s::Remove all keys!(encoding->flags = %x)\n", __func__, encoding->flags));
5098 }
5099 else
5100 {
5101@@ -2520,15 +2543,15 @@ int rt_ioctl_siwencodeext(struct net_dev
5102 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
5103 {
5104 pAdapter->StaCfg.DefaultKeyId = keyIdx;
5105- DBGPRINT(RT_DEBUG_TRACE, ("%s::DefaultKeyId = %d\n", __FUNCTION__, pAdapter->StaCfg.DefaultKeyId));
5106+ DBGPRINT(RT_DEBUG_TRACE, ("%s::DefaultKeyId = %d\n", __func__, pAdapter->StaCfg.DefaultKeyId));
5107 }
5108
5109 switch (alg) {
5110 case IW_ENCODE_ALG_NONE:
5111- DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_NONE\n", __FUNCTION__));
5112+ DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_NONE\n", __func__));
5113 break;
5114 case IW_ENCODE_ALG_WEP:
5115- DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_WEP - ext->key_len = %d, keyIdx = %d\n", __FUNCTION__, ext->key_len, keyIdx));
5116+ DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_WEP - ext->key_len = %d, keyIdx = %d\n", __func__, ext->key_len, keyIdx));
5117 if (ext->key_len == MAX_WEP_KEY_SIZE)
5118 {
5119 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE;
5120@@ -2544,9 +2567,24 @@ int rt_ioctl_siwencodeext(struct net_dev
5121
5122 NdisZeroMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, 16);
5123 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, ext->key_len);
5124+
5125+ if (pAdapter->StaCfg.GroupCipher == Ndis802_11GroupWEP40Enabled ||
5126+ pAdapter->StaCfg.GroupCipher == Ndis802_11GroupWEP104Enabled)
5127+ {
5128+ // Set Group key material to Asic
5129+ AsicAddSharedKeyEntry(pAdapter, BSS0, keyIdx, pAdapter->SharedKey[BSS0][keyIdx].CipherAlg, pAdapter->SharedKey[BSS0][keyIdx].Key, NULL, NULL);
5130+
5131+ // Update WCID attribute table and IVEIV table for this group key table
5132+ RTMPAddWcidAttributeEntry(pAdapter, BSS0, keyIdx, pAdapter->SharedKey[BSS0][keyIdx].CipherAlg, NULL);
5133+
5134+ STA_PORT_SECURED(pAdapter);
5135+
5136+ // Indicate Connected for GUI
5137+ pAdapter->IndicateMediaState = NdisMediaStateConnected;
5138+ }
5139 break;
5140 case IW_ENCODE_ALG_TKIP:
5141- DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_TKIP - keyIdx = %d, ext->key_len = %d\n", __FUNCTION__, keyIdx, ext->key_len));
5142+ DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_TKIP - keyIdx = %d, ext->key_len = %d\n", __func__, keyIdx, ext->key_len));
5143 if (ext->key_len == 32)
5144 {
5145 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
5146@@ -2596,7 +2634,7 @@ rt_ioctl_giwencodeext(struct net_device
5147 struct iw_request_info *info,
5148 union iwreq_data *wrqu, char *extra)
5149 {
5150- PRTMP_ADAPTER pAd = (PRTMP_ADAPTER) dev->priv;
5151+ PRTMP_ADAPTER pAd = dev->ml_priv;
5152 PCHAR pKey = NULL;
5153 struct iw_point *encoding = &wrqu->encoding;
5154 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
5155@@ -2680,7 +2718,7 @@ int rt_ioctl_siwgenie(struct net_device
5156 struct iw_request_info *info,
5157 union iwreq_data *wrqu, char *extra)
5158 {
5159- PRTMP_ADAPTER pAd = (PRTMP_ADAPTER) dev->priv;
5160+ PRTMP_ADAPTER pAd = dev->ml_priv;
5161
5162 if (wrqu->data.length > MAX_LEN_OF_RSNIE ||
5163 (wrqu->data.length && extra == NULL))
5164@@ -2705,7 +2743,7 @@ int rt_ioctl_giwgenie(struct net_device
5165 struct iw_request_info *info,
5166 union iwreq_data *wrqu, char *extra)
5167 {
5168- PRTMP_ADAPTER pAd = (PRTMP_ADAPTER) dev->priv;
5169+ PRTMP_ADAPTER pAd = dev->ml_priv;
5170
5171 if ((pAd->StaCfg.RSNIE_Len == 0) ||
5172 (pAd->StaCfg.AuthMode < Ndis802_11AuthModeWPA))
5173@@ -2751,7 +2789,7 @@ int rt_ioctl_siwpmksa(struct net_device
5174 union iwreq_data *wrqu,
5175 char *extra)
5176 {
5177- PRTMP_ADAPTER pAd = (PRTMP_ADAPTER) dev->priv;
5178+ PRTMP_ADAPTER pAd = dev->ml_priv;
5179 struct iw_pmksa *pPmksa = (struct iw_pmksa *)wrqu->data.pointer;
5180 INT CachedIdx = 0, idx = 0;
5181
5182@@ -2834,7 +2872,7 @@ rt_private_ioctl_bbp(struct net_device *
5183 UINT32 bbpValue;
5184 BOOLEAN bIsPrintAllBBP = FALSE;
5185 INT Status = 0;
5186- PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;
5187+ PRTMP_ADAPTER pAdapter = dev->ml_priv;
5188
5189
5190 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
5191@@ -2961,7 +2999,7 @@ int rt_ioctl_siwrate(struct net_device *
5192 struct iw_request_info *info,
5193 union iwreq_data *wrqu, char *extra)
5194 {
5195- PRTMP_ADAPTER pAd = (PRTMP_ADAPTER) dev->priv;
5196+ PRTMP_ADAPTER pAd = dev->ml_priv;
5197 UINT32 rate = wrqu->bitrate.value, fixed = wrqu->bitrate.fixed;
5198
5199 //check if the interface is down
5200@@ -3019,7 +3057,7 @@ int rt_ioctl_giwrate(struct net_device *
5201 struct iw_request_info *info,
5202 union iwreq_data *wrqu, char *extra)
5203 {
5204- PRTMP_ADAPTER pAd = (PRTMP_ADAPTER) dev->priv;
5205+ PRTMP_ADAPTER pAd = dev->ml_priv;
5206 int rate_index = 0, rate_count = 0;
5207 HTTRANSMIT_SETTING ht_setting;
5208 __s32 ralinkrate[] =
5209@@ -4259,7 +4297,23 @@ INT RTMPSetInformation(
5210 }
5211
5212 #ifdef WPA_SUPPLICANT_SUPPORT
5213- if (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_SECURED)
5214+ if ((pAdapter->StaCfg.WpaSupplicantUP != 0) &&
5215+ (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA))
5216+ {
5217+ Key = pWepKey->KeyMaterial;
5218+
5219+ // Set Group key material to Asic
5220+ AsicAddSharedKeyEntry(pAdapter, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
5221+
5222+ // Update WCID attribute table and IVEIV table for this group key table
5223+ RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, NULL);
5224+
5225+ STA_PORT_SECURED(pAdapter);
5226+
5227+ // Indicate Connected for GUI
5228+ pAdapter->IndicateMediaState = NdisMediaStateConnected;
5229+ }
5230+ else if (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_SECURED)
5231 #endif // WPA_SUPPLICANT_SUPPORT
5232 {
5233 Key = pAdapter->SharedKey[BSS0][KeyIdx].Key;
5234@@ -5265,7 +5319,6 @@ INT RTMPQueryInformation(
5235 case RT_OID_802_11_PRODUCTID:
5236 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PRODUCTID \n"));
5237
5238-#ifdef RT2860
5239 {
5240
5241 USHORT device_id;
5242@@ -5275,7 +5328,6 @@ INT RTMPQueryInformation(
5243 DBGPRINT(RT_DEBUG_TRACE, (" pci_dev = NULL\n"));
5244 sprintf(tmp, "%04x %04x\n", NIC_PCI_VENDOR_ID, device_id);
5245 }
5246-#endif // RT2860 //
5247 wrq->u.data.length = strlen(tmp);
5248 Status = copy_to_user(wrq->u.data.pointer, tmp, wrq->u.data.length);
5249 break;
5250@@ -5409,19 +5461,19 @@ INT rt28xx_sta_ioctl(
5251
5252 if (net_dev->priv_flags == INT_MAIN)
5253 {
5254- pAd = net_dev->priv;
5255+ pAd = net_dev->ml_priv;
5256 }
5257 else
5258 {
5259- pVirtualAd = net_dev->priv;
5260- pAd = pVirtualAd->RtmpDev->priv;
5261+ pVirtualAd = net_dev->ml_priv;
5262+ pAd = pVirtualAd->RtmpDev->ml_priv;
5263 }
5264 pObj = (POS_COOKIE) pAd->OS_Cookie;
5265
5266 if (pAd == NULL)
5267 {
5268 /* if 1st open fail, pAd will be free;
5269- So the net_dev->priv will be NULL in 2rd open */
5270+ So the net_dev->ml_priv will be NULL in 2rd open */
5271 return -ENETDOWN;
5272 }
5273
5274--- a/drivers/staging/rt2860/wpa.h
5275+++ b/drivers/staging/rt2860/wpa.h
5276@@ -90,6 +90,7 @@
5277 #define TKIP_AP_RXMICK_OFFSET (TKIP_AP_TXMICK_OFFSET+LEN_TKIP_TXMICK)
5278 #define TKIP_GTK_LENGTH ((LEN_TKIP_EK)+(LEN_TKIP_RXMICK)+(LEN_TKIP_TXMICK))
5279 #define LEN_PTK ((LEN_EAP_KEY)+(LEN_TKIP_KEY))
5280+#define MIN_LEN_OF_GTK 5
5281
5282 // RSN IE Length definition
5283 #define MAX_LEN_OF_RSNIE 90