2 *************************************************************************
4 * 5F., No.36, Taiyuan St., Jhubei City,
8 * (c) Copyright 2002-2007, Ralink Technology, Inc.
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
15 * This program is distributed in the hope that it will be useful, *
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18 * GNU General Public License for more details. *
20 * You should have received a copy of the GNU General Public License *
21 * along with this program; if not, write to the *
22 * Free Software Foundation, Inc., *
23 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
25 *************************************************************************
28 #include "rt_config.h"
31 INT
IoctlResponse(PUCHAR payload
, PUCHAR msg
, INT len
);
35 UCHAR TemplateFrame
[24] = {0x08/* Data type */,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0xAA,0xBB,0x12,0x34,0x56,0x00,0x11,0x22,0xAA,0xBB,0xCC,0x00,0x00}; // 802.11 MAC Header, Type:Data, Length:24bytes
36 extern RTMP_RF_REGS RF2850RegTable
[];
37 extern UCHAR NUM_OF_2850_CHNL
;
40 extern UCHAR EpToQueue
[];
41 extern VOID
RTUSBRejectPendingPackets( IN PRTMP_ADAPTER pAd
);
45 extern INT
ConsoleResponse(IN PUCHAR buff
);
46 extern int (*remote_display
)(char *);
49 static CHAR CCKRateTable
[] = {0, 1, 2, 3, 8, 9, 10, 11, -1}; /* CCK Mode. */
50 static CHAR OFDMRateTable
[] = {0, 1, 2, 3, 4, 5, 6, 7, -1}; /* OFDM Mode. */
51 static CHAR HTMIXRateTable
[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -1}; /* HT Mix Mode. */
54 IN PRTMP_ADAPTER pAd
);
57 IN PRTMP_ADAPTER pAd
);
59 static VOID
RtmpDmaEnable(
63 static VOID
BbpSoftReset(
64 IN PRTMP_ADAPTER pAd
);
66 static VOID
RtmpRfIoWrite(
67 IN PRTMP_ADAPTER pAd
);
69 static INT
ATESetUpFrame(
73 static INT
ATETxPwrHandler(
77 static INT
ATECmdHandler(
81 static int CheckMCSValid(
87 static VOID
ATEWriteTxInfo(
89 IN PTXINFO_STRUC pTxInfo
,
90 IN USHORT USBDMApktLen
,
96 static VOID
ATEWriteTxWI(
100 IN BOOLEAN InsTimestamp
,
103 IN BOOLEAN NSeq
, // HW new a sequence.
111 IN HTTRANSMIT_SETTING Transmit
);
115 static VOID
SetJapanFilter(
116 IN PRTMP_ADAPTER pAd
);
118 /*=========================end of prototype=========================*/
122 static INT
TxDmaBusy(
123 IN PRTMP_ADAPTER pAd
)
126 USB_DMA_CFG_STRUC UsbCfg
;
128 RTMP_IO_READ32(pAd
, USB_DMA_CFG
, &UsbCfg
.word
); // disable DMA
129 if (UsbCfg
.field
.TxBusy
)
137 static INT
RxDmaBusy(
138 IN PRTMP_ADAPTER pAd
)
141 USB_DMA_CFG_STRUC UsbCfg
;
143 RTMP_IO_READ32(pAd
, USB_DMA_CFG
, &UsbCfg
.word
); // disable DMA
144 if (UsbCfg
.field
.RxBusy
)
152 static VOID
RtmpDmaEnable(
153 IN PRTMP_ADAPTER pAd
,
158 USB_DMA_CFG_STRUC UsbCfg
;
160 value
= Enable
> 0 ? 1 : 0;
162 // check DMA is in busy mode.
164 while (TxDmaBusy(pAd
) || RxDmaBusy(pAd
))
171 //Why not to clear USB DMA TX path first ???
172 RTMP_IO_READ32(pAd
, USB_DMA_CFG
, &UsbCfg
.word
); // disable DMA
173 UsbCfg
.field
.TxBulkEn
= value
;
174 UsbCfg
.field
.RxBulkEn
= value
;
175 RTMP_IO_WRITE32(pAd
, USB_DMA_CFG
, UsbCfg
.word
); // abort all TX rings
182 static VOID
BbpSoftReset(
183 IN PRTMP_ADAPTER pAd
)
187 // Soft reset, set BBP R21 bit0=1->0
188 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R21
, &BbpData
);
189 BbpData
|= 0x00000001; //set bit0=1
190 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R21
, BbpData
);
192 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R21
, &BbpData
);
193 BbpData
&= ~(0x00000001); //set bit0=0
194 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R21
, BbpData
);
199 static VOID
RtmpRfIoWrite(
200 IN PRTMP_ADAPTER pAd
)
202 // Set RF value 1's set R3[bit2] = [0]
203 RTMP_RF_IO_WRITE32(pAd
, pAd
->LatchRfRegs
.R1
);
204 RTMP_RF_IO_WRITE32(pAd
, pAd
->LatchRfRegs
.R2
);
205 RTMP_RF_IO_WRITE32(pAd
, (pAd
->LatchRfRegs
.R3
& (~0x04)));
206 RTMP_RF_IO_WRITE32(pAd
, pAd
->LatchRfRegs
.R4
);
210 // Set RF value 2's set R3[bit2] = [1]
211 RTMP_RF_IO_WRITE32(pAd
, pAd
->LatchRfRegs
.R1
);
212 RTMP_RF_IO_WRITE32(pAd
, pAd
->LatchRfRegs
.R2
);
213 RTMP_RF_IO_WRITE32(pAd
, (pAd
->LatchRfRegs
.R3
| 0x04));
214 RTMP_RF_IO_WRITE32(pAd
, pAd
->LatchRfRegs
.R4
);
218 // Set RF value 3's set R3[bit2] = [0]
219 RTMP_RF_IO_WRITE32(pAd
, pAd
->LatchRfRegs
.R1
);
220 RTMP_RF_IO_WRITE32(pAd
, pAd
->LatchRfRegs
.R2
);
221 RTMP_RF_IO_WRITE32(pAd
, (pAd
->LatchRfRegs
.R3
& (~0x04)));
222 RTMP_RF_IO_WRITE32(pAd
, pAd
->LatchRfRegs
.R4
);
227 static int CheckMCSValid(
237 pRateTab
= CCKRateTable
;
240 pRateTab
= OFDMRateTable
;
244 pRateTab
= HTMIXRateTable
;
247 ATEDBGPRINT(RT_DEBUG_ERROR
, ("unrecognizable Tx Mode %d\n", Mode
));
253 while(pRateTab
[i
] != -1)
255 if (pRateTab
[i
] == Mcs
)
264 static INT
ATETxPwrHandler(
265 IN PRTMP_ADAPTER pAd
,
271 BOOLEAN bPowerReduce
= FALSE
;
273 #ifdef RALINK_28xx_QA
274 if ((pAd
->ate
.bQATxStart
== TRUE
) || (pAd
->ate
.bQARxStart
== TRUE
))
276 /* When QA is used for Tx, pAd->ate.TxPower0/1 and real tx power
277 ** are not synchronized.
280 pAd->ate.TxPower0 = pAd->LatchRfRegs.xxx;
281 pAd->ate.TxPower1 = pAd->LatchRfRegs.xxx;
286 #endif // RALINK_28xx_QA //
288 TxPower
= index
== 0 ? pAd
->ate
.TxPower0
: pAd
->ate
.TxPower1
;
290 if (pAd
->ate
.Channel
<= 14)
295 // R3, R4 can't large than 31 (0x24), 31 ~ 36 used by BBP 94
299 Bbp94
= BBPR94_DEFAULT
+ (UCHAR
)(TxPower
- 31);
301 else if (TxPower
< 0)
304 // R3, R4 can't less than 0, -1 ~ -6 used by BBP 94
308 Bbp94
= BBPR94_DEFAULT
+ TxPower
;
314 Bbp94
= BBPR94_DEFAULT
;
317 ATEDBGPRINT(RT_DEBUG_TRACE
, ("%s (TxPower=%d, R=%ld, BBP_R94=%d)\n", __func__
, TxPower
, R
, Bbp94
));
324 // R3, R4 can't large than 15 (0x0F)
328 else if (TxPower
< 0)
331 // R3, R4 can't less than 0
334 ASSERT((TxPower
>= -7));
335 R
= (ULONG
)(TxPower
+ 7);
344 ATEDBGPRINT(RT_DEBUG_TRACE
, ("%s (TxPower=%d, R=%lu)\n", __func__
, TxPower
, R
));
347 if (pAd
->ate
.Channel
<= 14)
351 R
= R
<< 9; // shift TX power control to correct RF(R3) register bit position
352 R
|= (pAd
->LatchRfRegs
.R3
& 0xffffc1ff);
353 pAd
->LatchRfRegs
.R3
= R
;
357 R
= R
<< 6; // shift TX power control to correct RF(R4) register bit position
358 R
|= (pAd
->LatchRfRegs
.R4
& 0xfffff83f);
359 pAd
->LatchRfRegs
.R4
= R
;
364 if (bPowerReduce
== FALSE
)
368 R
= (R
<< 10) | (1 << 9); // shift TX power control to correct RF(R3) register bit position
369 R
|= (pAd
->LatchRfRegs
.R3
& 0xffffc1ff);
370 pAd
->LatchRfRegs
.R3
= R
;
374 R
= (R
<< 7) | (1 << 6); // shift TX power control to correct RF(R4) register bit position
375 R
|= (pAd
->LatchRfRegs
.R4
& 0xfffff83f);
376 pAd
->LatchRfRegs
.R4
= R
;
383 R
= (R
<< 10); // shift TX power control to correct RF(R3) register bit position
384 R
|= (pAd
->LatchRfRegs
.R3
& 0xffffc1ff);
386 /* Clear bit 9 of R3 to reduce 7dB. */
387 pAd
->LatchRfRegs
.R3
= (R
& (~(1 << 9)));
391 R
= (R
<< 7); // shift TX power control to correct RF(R4) register bit position
392 R
|= (pAd
->LatchRfRegs
.R4
& 0xfffff83f);
394 /* Clear bit 6 of R4 to reduce 7dB. */
395 pAd
->LatchRfRegs
.R4
= (R
& (~(1 << 6)));
406 static INT
ATETxPwrHandler(
407 IN PRTMP_ADAPTER pAd
,
414 #ifdef RALINK_28xx_QA
415 if ((pAd
->ate
.bQATxStart
== TRUE
) || (pAd
->ate
.bQARxStart
== TRUE
))
417 // TODO: how to get current TxPower0/1 from pAd->LatchRfRegs ?
418 /* When QA is used for Tx, pAd->ate.TxPower0/1 and real tx power
419 ** are not synchronized.
422 pAd->ate.TxPower0 = pAd->LatchRfRegs.xxx;
423 pAd->ate.TxPower1 = pAd->LatchRfRegs.xxx;
428 #endif // RALINK_28xx_QA //
430 TxPower
= index
== 0 ? pAd
->ate
.TxPower0
: pAd
->ate
.TxPower1
;
435 // R3, R4 can't large than 36 (0x24), 31 ~ 36 used by BBP 94
439 Bbp94
= BBPR94_DEFAULT
+ (UCHAR
)(TxPower
- 31);
441 else if (TxPower
< 0)
444 // R3, R4 can't less than 0, -1 ~ -6 used by BBP 94
448 Bbp94
= BBPR94_DEFAULT
+ TxPower
;
454 Bbp94
= BBPR94_DEFAULT
;
457 ATEDBGPRINT(RT_DEBUG_TRACE
, ("%s (TxPower=%d, R3=%ld, BBP_R94=%d)\n", __func__
, TxPower
, R
, Bbp94
));
459 if (pAd
->ate
.Channel
<= 14)
463 R
= R
<< 9; // shift TX power control to correct RF(R3) register bit position
464 R
|= (pAd
->LatchRfRegs
.R3
& 0xffffc1ff);
465 pAd
->LatchRfRegs
.R3
= R
;
469 R
= R
<< 6; // shift TX power control to correct RF(R4) register bit position
470 R
|= (pAd
->LatchRfRegs
.R4
& 0xfffff83f);
471 pAd
->LatchRfRegs
.R4
= R
;
478 R
= (R
<< 10) | (1 << 9); // shift TX power control to correct RF(R3) register bit position
479 R
|= (pAd
->LatchRfRegs
.R3
& 0xffffc1ff);
480 pAd
->LatchRfRegs
.R3
= R
;
484 R
= (R
<< 7) | (1 << 6); // shift TX power control to correct RF(R4) register bit position
485 R
|= (pAd
->LatchRfRegs
.R4
& 0xfffff83f);
486 pAd
->LatchRfRegs
.R4
= R
;
497 ==========================================================================
499 Set ATE operation mode to
500 0. ATESTART = Start ATE Mode
501 1. ATESTOP = Stop ATE Mode
502 2. TXCONT = Continuous Transmit
503 3. TXCARR = Transmit Carrier
504 4. TXFRAME = Transmit Frames
505 5. RXFRAME = Receive Frames
506 #ifdef RALINK_28xx_QA
507 6. TXSTOP = Stop Any Type of Transmition
508 7. RXSTOP = Stop Receiving Frames
509 #endif // RALINK_28xx_QA //
511 TRUE if all parameters are OK, FALSE otherwise
512 ==========================================================================
516 /*=======================End of RT2860=======================*/
519 /*======================Start of RT2870======================*/
524 static INT
ATECmdHandler(
525 IN PRTMP_ADAPTER pAd
,
532 //NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
537 ATEDBGPRINT(RT_DEBUG_TRACE
, ("===> ATECmdHandler()\n"));
538 ATEAsicSwitchChannel(pAd
);
539 /* AsicLockChannel() is empty function so far in fact */
540 AsicLockChannel(pAd
, pAd
->ate
.Channel
);
544 // Default value in BBP R22 is 0x0.
547 /* Enter ATE mode and set Tx/Rx Idle */
548 if (!strcmp(arg
, "ATESTART"))
550 #ifdef CONFIG_STA_SUPPORT
552 #endif // CONFIG_STA_SUPPORT //
553 ATEDBGPRINT(RT_DEBUG_TRACE
, ("ATE: ATESTART\n"));
555 netif_stop_queue(pAd
->net_dev
);
557 atemode
= pAd
->ate
.Mode
;
558 pAd
->ate
.Mode
= ATE_START
;
559 // pAd->ate.TxDoneCount = pAd->ate.TxCount;
561 RTMP_IO_READ32(pAd
, MAC_SYS_CTRL
, &Value
);
563 RTMP_IO_WRITE32(pAd
, MAC_SYS_CTRL
, Value
);
565 // Disable auto responder
566 RTMP_IO_READ32(pAd
, AUTO_RSP_CFG
, &temp
);
567 temp
= temp
& 0xFFFFFFFE;
568 RTMP_IO_WRITE32(pAd
, AUTO_RSP_CFG
, temp
);
570 // read MAC_SYS_CTRL and backup MAC_SYS_CTRL value.
571 RTMP_IO_READ32(pAd
, MAC_SYS_CTRL
, &MacData
);
572 // clean bit4 to stop continuous Tx production test.
573 MacData
&= 0xFFFFFFEF;
574 // Stop continuous TX production test.
575 RTMP_IO_WRITE32(pAd
, MAC_SYS_CTRL
, MacData
);//disable or cancel pending irp first ???
577 if (atemode
& ATE_TXCARR
)
579 // No Carrier Test set BBP R22 bit7=0, bit6=0, bit[5~0]=0x0
580 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R22
, &BbpData
);
581 BbpData
&= 0xFFFFFF00; //clear bit7, bit6, bit[5~0]
582 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R22
, BbpData
);
584 else if (atemode
& ATE_TXCARRSUPP
)
586 // No Cont. TX set BBP R22 bit7=0
587 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R22
, &BbpData
);
588 BbpData
&= ~(1 << 7); //set bit7=0
589 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R22
, BbpData
);
591 // No Carrier Suppression set BBP R24 bit0=0
592 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R24
, &BbpData
);
593 BbpData
&= 0xFFFFFFFE; //clear bit0
594 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R24
, BbpData
);
596 // We should free some resource which allocate when ATE_TXFRAME , ATE_STOP, and ATE_TXCONT.
597 // TODO:Should we free some resource which was allocated when LoopBack and ATE_STOP ?
598 else if ((atemode
& ATE_TXFRAME
) || (atemode
== ATE_STOP
))
600 if (atemode
& ATE_TXCONT
)
602 // Not Cont. TX anymore, so set BBP R22 bit7=0
603 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R22
, &BbpData
);
604 BbpData
&= ~(1 << 7); //set bit7=0
605 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R22
, BbpData
);
608 RtmpDmaEnable(pAd
, 0);
611 // It seems nothing to free,
612 // because we didn't allocate any resource when we entered ATE_TXFRAME mode latestly.
616 RtmpDmaEnable(pAd
, 1);
619 RTUSBRejectPendingPackets(pAd
);
620 RTUSBCleanUpDataBulkOutQueue(pAd
);
622 #ifdef CONFIG_STA_SUPPORT
624 // It will be called in MlmeSuspend().
626 // Cancel pending timers
627 RTMPCancelTimer(&pAd
->MlmeAux
.AssocTimer
, &Cancelled
);
628 RTMPCancelTimer(&pAd
->MlmeAux
.ReassocTimer
, &Cancelled
);
629 RTMPCancelTimer(&pAd
->MlmeAux
.DisassocTimer
, &Cancelled
);
630 RTMPCancelTimer(&pAd
->MlmeAux
.AuthTimer
, &Cancelled
);
631 RTMPCancelTimer(&pAd
->MlmeAux
.BeaconTimer
, &Cancelled
);
632 RTMPCancelTimer(&pAd
->MlmeAux
.ScanTimer
, &Cancelled
);
633 #endif // CONFIG_STA_SUPPORT //
635 //RTUSBCleanUpMLMEWaitQueue(pAd); /* not used in RT28xx */
636 RTUSBCleanUpMLMEBulkOutQueue(pAd
);
638 // Sometimes kernel will hang on, so we avoid calling MlmeSuspend().
639 // MlmeSuspend(pAd, TRUE);
640 //RTMPCancelTimer(&pAd->Mlme.PeriodicTimer, &Cancelled);
643 RTMP_IO_READ32(pAd
, MAC_SYS_CTRL
, &Value
);
645 RTMP_IO_WRITE32(pAd
, MAC_SYS_CTRL
, Value
);
648 RtmpDmaEnable(pAd
, 0);
651 RTMP_IO_READ32(pAd
, MAC_SYS_CTRL
, &Value
);
653 RTMP_IO_WRITE32(pAd
, MAC_SYS_CTRL
, Value
);
655 // Make sure there are no pending bulk in/out IRPs before we go on.
656 /*=========================================================================*/
657 /* pAd->PendingRx is not of type atomic_t anymore in 28xx */
658 // while ((atomic_read(&pAd->PendingRx) > 0)) //pAd->BulkFlags != 0 wait bulk out finish
659 while ((pAd
->PendingRx
> 0)) //pAd->BulkFlags != 0 wait bulk out finish
662 ATE_RTUSBCancelPendingBulkInIRP(pAd
);
664 NdisInterlockedDecrement(&pAd
->PendingRx
);
666 /* delay 0.5 seconds */
667 RTMPusecDelay(500000);
670 /* peter : why don't we have to get BulkOutLock first ? */
671 while (((pAd
->BulkOutPending
[0] == TRUE
) ||
672 (pAd
->BulkOutPending
[1] == TRUE
) ||
673 (pAd
->BulkOutPending
[2] == TRUE
) ||
674 (pAd
->BulkOutPending
[3] == TRUE
)) && (pAd
->BulkFlags
!= 0)) //pAd->BulkFlags != 0 wait bulk out finish
678 /* pAd->BulkOutPending[y] will be set to FALSE in RTUSBCancelPendingBulkOutIRP(pAd) */
679 RTUSBCancelPendingBulkOutIRP(pAd
);
682 /* we have enough time delay in RTUSBCancelPendingBulkOutIRP(pAd)
683 ** so this is not necessary
685 // RTMPusecDelay(500000);
688 /* pAd->PendingRx is not of type atomic_t anymore in 28xx */
689 // ASSERT(atomic_read(&pAd->PendingRx) == 0);
690 ASSERT(pAd
->PendingRx
== 0);
691 /*=========================================================================*/
693 // reset Rx statistics.
694 pAd
->ate
.LastSNR0
= 0;
695 pAd
->ate
.LastSNR1
= 0;
696 pAd
->ate
.LastRssi0
= 0;
697 pAd
->ate
.LastRssi1
= 0;
698 pAd
->ate
.LastRssi2
= 0;
699 pAd
->ate
.AvgRssi0
= 0;
700 pAd
->ate
.AvgRssi1
= 0;
701 pAd
->ate
.AvgRssi2
= 0;
702 pAd
->ate
.AvgRssi0X8
= 0;
703 pAd
->ate
.AvgRssi1X8
= 0;
704 pAd
->ate
.AvgRssi2X8
= 0;
705 pAd
->ate
.NumOfAvgRssiSample
= 0;
707 #ifdef RALINK_28xx_QA
709 pAd
->ate
.bQATxStart
= FALSE
;
710 pAd
->ate
.bQARxStart
= FALSE
;
715 pAd
->ate
.OtherData
= 0;
717 pAd
->ate
.OtherCount
= 0;
731 pAd
->ate
.TxDoneCount
= 0;
732 pAd
->ate
.TxStatus
= 0; // task Tx status // 0 --> task is idle, 1 --> task is running
733 #endif // RALINK_28xx_QA //
739 #ifdef CONFIG_STA_SUPPORT
740 AsicDisableSync(pAd
);
743 ** If we skip "LinkDown()", we should disable protection
744 ** to prevent from sending out RTS or CTS-to-self.
746 ATEDisableAsicProtect(pAd
);
747 RTMPStationStop(pAd
);
748 #endif // CONFIG_STA_SUPPORT //
750 // Default value in BBP R22 is 0x0.
752 RTMP_IO_READ32(pAd
, MAC_SYS_CTRL
, &MacData
);
754 // Clean bit4 to stop continuous Tx production test.
755 MacData
&= 0xFFFFFFEF;
756 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R22
, BbpData
);
757 RTMP_IO_WRITE32(pAd
, MAC_SYS_CTRL
, MacData
);
758 //Clean ATE Bulk in/out counter and continue setup
759 InterlockedExchange(&pAd
->BulkOutRemained
, 0);
761 /* NdisAcquireSpinLock()/NdisReleaseSpinLock() need only one argument in RT28xx */
762 NdisAcquireSpinLock(&pAd
->GenericLock
);
763 pAd
->ContinBulkOut
= FALSE
;
764 pAd
->ContinBulkIn
= FALSE
;
765 NdisReleaseSpinLock(&pAd
->GenericLock
);
767 RTUSB_CLEAR_BULK_FLAG(pAd
, fRTUSB_BULK_OUT_DATA_ATE
);
769 else if (!strcmp(arg
, "ATESTOP"))
771 ATEDBGPRINT(RT_DEBUG_TRACE
, ("ATE : ATESTOP ===>\n"));
773 // Default value in BBP R22 is 0x0.
775 RTMP_IO_READ32(pAd
, MAC_SYS_CTRL
, &MacData
);//0820
776 // Clean bit4 to stop continuous Tx production test.
777 MacData
&= 0xFFFFFFEF;
778 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R22
, BbpData
);
779 RTMP_IO_WRITE32(pAd
, MAC_SYS_CTRL
, MacData
); // recover the MAC_SYS_CTRL register back.
782 RTMP_IO_READ32(pAd
, MAC_SYS_CTRL
, &Value
);
784 RTMP_IO_WRITE32(pAd
, MAC_SYS_CTRL
, Value
);
788 ** Q : How to do the following I/O if Tx, Rx DMA is aborted ?
789 ** Ans : Bulk endpoints are aborted, while the control endpoint is not.
791 RtmpDmaEnable(pAd
, 0);
794 RTMP_IO_READ32(pAd
, MAC_SYS_CTRL
, &Value
);
796 RTMP_IO_WRITE32(pAd
, MAC_SYS_CTRL
, Value
);
798 /* Make sure there are no pending bulk in/out IRPs before we go on. */
799 /*=========================================================================*/
800 // while ((atomic_read(&pAd->PendingRx) > 0)) //pAd->BulkFlags != 0 wait bulk out finish
801 while (pAd
->PendingRx
> 0)
804 ATE_RTUSBCancelPendingBulkInIRP(pAd
);
806 // NdisInterlockedDecrement(&pAd->PendingRx);
809 RTMPusecDelay(500000);
812 while (((pAd
->BulkOutPending
[0] == TRUE
) ||
813 (pAd
->BulkOutPending
[1] == TRUE
) ||
814 (pAd
->BulkOutPending
[2] == TRUE
) ||
815 (pAd
->BulkOutPending
[3] == TRUE
)) && (pAd
->BulkFlags
!= 0)) //pAd->BulkFlags != 0 wait bulk out finish
819 RTUSBCancelPendingBulkOutIRP(pAd
);
822 RTMPusecDelay(500000);
825 // ASSERT(atomic_read(&pAd->PendingRx) == 0);
826 ASSERT(pAd
->PendingRx
== 0);
827 /*=========================================================================*/
829 /*=========================================================================*/
830 // InterlockedExchange(&pAd->PendingRx, 0);
832 pAd
->NextRxBulkInReadIndex
= 0; // Next Rx Read index
833 pAd
->NextRxBulkInIndex
= RX_RING_SIZE
- 1; // Rx Bulk pointer
834 pAd
->NextRxBulkInPosition
= 0;
835 for (i
= 0; i
< (RX_RING_SIZE
); i
++)
837 PRX_CONTEXT pRxContext
= &(pAd
->RxContext
[i
]);
838 NdisZeroMemory(pRxContext
->TransferBuffer
, MAX_RXBULK_SIZE
);
839 /* peter : why don't we have to get BulkInLock first ? */
840 pRxContext
->pAd
= pAd
;
841 pRxContext
->pIrp
= NULL
;
843 pRxContext
->BulkInOffset
= 0;
844 pRxContext
->bRxHandling
= FALSE
;
846 pRxContext
->InUse
= FALSE
;
847 pRxContext
->IRPPending
= FALSE
;
848 pRxContext
->Readable
= FALSE
;
849 // pRxContext->ReorderInUse = FALSE;
850 // pRxContext->ReadPosOffset = 0;
853 /*=========================================================================*/
855 /*=========================================================================*/
858 RTUSBCancelPendingBulkOutIRP(pAd
);
861 /*=========================================================================*/
862 // Enable auto responder.
863 RTMP_IO_READ32(pAd
, AUTO_RSP_CFG
, &temp
);
864 temp
= temp
| (0x01);
865 RTMP_IO_WRITE32(pAd
, AUTO_RSP_CFG
, temp
);
867 /*================================================*/
868 AsicEnableBssSync(pAd
);
871 /* In 2870 chipset, ATE_BBP_IO_READ8_BY_REG_ID() == RTMP_BBP_IO_READ8_BY_REG_ID() */
872 /* Both rt2870ap and rt2870sta use BbpSoftReset(pAd) to do BBP soft reset */
874 /*================================================*/
876 #ifdef CONFIG_STA_SUPPORT
877 // Set all state machines back IDLE
878 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_IDLE
;
879 pAd
->Mlme
.AssocMachine
.CurrState
= ASSOC_IDLE
;
880 pAd
->Mlme
.AuthMachine
.CurrState
= AUTH_REQ_IDLE
;
881 pAd
->Mlme
.AuthRspMachine
.CurrState
= AUTH_RSP_IDLE
;
882 pAd
->Mlme
.SyncMachine
.CurrState
= SYNC_IDLE
;
883 pAd
->Mlme
.ActMachine
.CurrState
= ACT_IDLE
;
884 #endif // CONFIG_STA_SUPPORT //
887 // ===> refer to MlmeRestartStateMachine().
888 // When we entered ATE_START mode, PeriodicTimer was not cancelled.
889 // So we don't have to set it here.
891 //RTMPSetTimer(pAd, &pAd->Mlme.PeriodicTimer, MLME_TASK_EXEC_INTV);
893 ASSERT(pAd
->CommonCfg
.Channel
!= 0);
895 AsicSwitchChannel(pAd
, pAd
->CommonCfg
.Channel
, FALSE
);
896 AsicLockChannel(pAd
, pAd
->CommonCfg
.Channel
);
899 #ifdef CONFIG_STA_SUPPORT
900 RTMPStationStart(pAd
);
901 #endif // CONFIG_STA_SUPPORT //
904 // These two steps have been done when entering ATE_STOP mode.
907 RTUSBWriteBBPRegister(pAd
, BBP_R22
, BbpData
);
908 RTUSBWriteMACRegister(pAd
, MAC_SYS_CTRL
, MacData
);
910 // Clean ATE Bulk in/out counter and continue setup.
911 InterlockedExchange(&pAd
->BulkOutRemained
, 0);
912 NdisAcquireSpinLock(&pAd
->GenericLock
);
913 pAd
->ContinBulkOut
= FALSE
;
914 pAd
->ContinBulkIn
= FALSE
;
915 NdisReleaseSpinLock(&pAd
->GenericLock
);
917 /* Wait 50ms to prevent next URB to bulkout during HW reset. */
918 /* todo : remove this if not necessary */
921 pAd
->ate
.Mode
= ATE_STOP
;
924 RTMP_IO_READ32(pAd
, MAC_SYS_CTRL
, &Value
);
926 RTMP_IO_WRITE32(pAd
, MAC_SYS_CTRL
, Value
);
928 /*=========================================================================*/
929 /* restore RX_FILTR_CFG */
930 #ifdef CONFIG_STA_SUPPORT
931 /* restore RX_FILTR_CFG in order that QA maybe set it to 0x3 */
932 RTMP_IO_WRITE32(pAd
, RX_FILTR_CFG
, STANORMAL
);
933 #endif // CONFIG_STA_SUPPORT //
934 /*=========================================================================*/
936 // Enable Tx, RX DMA.
937 RtmpDmaEnable(pAd
, 1);
940 RTMP_IO_READ32(pAd
, MAC_SYS_CTRL
, &Value
);
942 RTMP_IO_WRITE32(pAd
, MAC_SYS_CTRL
, Value
);
944 // Wait 10ms to wait all of the bulk-in URBs to complete.
945 /* todo : remove this if not necessary */
948 // Everything is ready to start normal Tx/Rx.
949 RTUSBBulkReceive(pAd
);
950 netif_start_queue(pAd
->net_dev
);
952 ATEDBGPRINT(RT_DEBUG_TRACE
, ("<=== ATE : ATESTOP \n"));
954 else if (!strcmp(arg
, "TXCARR")) // Tx Carrier
956 ATEDBGPRINT(RT_DEBUG_TRACE
, ("ATE: TXCARR\n"));
957 pAd
->ate
.Mode
|= ATE_TXCARR
;
960 // May be we need not to do this, because these have been done in ATE_START mode ???
961 RTMP_IO_READ32(pAd
, MAC_SYS_CTRL
, &Value
);
963 RTMP_IO_WRITE32(pAd
, MAC_SYS_CTRL
, Value
);
965 // QA has done the following steps if it is used.
966 if (pAd
->ate
.bQATxStart
== FALSE
)
971 // Carrier Test set BBP R22 bit7=1, bit6=1, bit[5~0]=0x01
972 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R22
, &BbpData
);
973 BbpData
&= 0xFFFFFF00; //clear bit7, bit6, bit[5~0]
974 BbpData
|= 0x000000C1; //set bit7=1, bit6=1, bit[5~0]=0x01
975 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R22
, BbpData
);
977 // set MAC_SYS_CTRL(0x1004) Continuous Tx Production Test (bit4) = 1
978 RTMP_IO_READ32(pAd
, MAC_SYS_CTRL
, &Value
);
979 Value
= Value
| 0x00000010;
980 RTMP_IO_WRITE32(pAd
, MAC_SYS_CTRL
, Value
);
983 else if (!strcmp(arg
, "TXCONT")) // Tx Continue
985 if (pAd
->ate
.bQATxStart
== TRUE
)
987 /* set MAC_SYS_CTRL(0x1004) bit4(Continuous Tx Production Test)
988 and bit2(MAC TX enable) back to zero. */
989 RTMP_IO_READ32(pAd
, MAC_SYS_CTRL
, &MacData
);
990 MacData
&= 0xFFFFFFEB;
991 RTMP_IO_WRITE32(pAd
, MAC_SYS_CTRL
, MacData
);
993 // set BBP R22 bit7=0
994 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R22
, &BbpData
);
995 BbpData
&= 0xFFFFFF7F; //set bit7=0
996 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R22
, BbpData
);
1000 ** Step 1: Send 50 packets first then wait for a moment.
1001 ** Step 2: Send more 50 packet then start continue mode.
1003 ATEDBGPRINT(RT_DEBUG_TRACE
, ("ATE: TXCONT\n"));
1004 // Step 1: send 50 packets first.
1005 pAd
->ate
.Mode
|= ATE_TXCONT
;
1006 pAd
->ate
.TxCount
= 50;
1007 pAd
->ate
.TxDoneCount
= 0;
1012 // Abort Tx, RX DMA.
1013 RtmpDmaEnable(pAd
, 0);
1016 /* Only needed if we have to send some normal frames. */
1017 SetJapanFilter(pAd
);
1019 // Setup frame format.
1020 ATESetUpFrame(pAd
, 0);
1023 RTMP_IO_READ32(pAd
, MAC_SYS_CTRL
, &Value
);
1025 RTMP_IO_WRITE32(pAd
, MAC_SYS_CTRL
, Value
);
1028 RTMP_IO_READ32(pAd
, MAC_SYS_CTRL
, &Value
);
1030 RTMP_IO_WRITE32(pAd
, MAC_SYS_CTRL
, Value
);
1032 // Start Tx, RX DMA.
1033 RtmpDmaEnable(pAd
, 1);
1035 InterlockedExchange(&pAd
->BulkOutRemained
, pAd
->ate
.TxCount
);
1037 #ifdef RALINK_28xx_QA
1038 if (pAd
->ate
.bQATxStart
== TRUE
)
1040 pAd
->ate
.TxStatus
= 1;
1041 //pAd->ate.Repeat = 0;
1043 #endif // RALINK_28xx_QA //
1045 NdisAcquireSpinLock(&pAd
->GenericLock
);//0820
1046 pAd
->ContinBulkOut
= FALSE
;
1047 NdisReleaseSpinLock(&pAd
->GenericLock
);
1049 RTUSB_SET_BULK_FLAG(pAd
, fRTUSB_BULK_OUT_DATA_ATE
);
1052 RTUSBKickBulkOut(pAd
);
1054 /* To make sure all the 50 frames have been bulk out before executing step 2 */
1055 while (atomic_read(&pAd
->BulkOutRemained
) > 0)
1057 RTMPusecDelay(5000);
1060 // Step 2: send more 50 packets then start continue mode.
1061 // Abort Tx, RX DMA.
1062 RtmpDmaEnable(pAd
, 0);
1064 // Cont. TX set BBP R22 bit7=1
1065 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R22
, &BbpData
);
1066 BbpData
|= 0x00000080; //set bit7=1
1067 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R22
, BbpData
);
1069 pAd
->ate
.TxCount
= 50;
1070 pAd
->ate
.TxDoneCount
= 0;
1072 SetJapanFilter(pAd
);
1074 // Setup frame format.
1075 ATESetUpFrame(pAd
, 0);
1078 RTMP_IO_READ32(pAd
, MAC_SYS_CTRL
, &Value
);
1080 RTMP_IO_WRITE32(pAd
, MAC_SYS_CTRL
, Value
);
1083 RTMP_IO_READ32(pAd
, MAC_SYS_CTRL
, &Value
);
1086 // Start Tx, RX DMA.
1087 RtmpDmaEnable(pAd
, 1);
1089 InterlockedExchange(&pAd
->BulkOutRemained
, pAd
->ate
.TxCount
);
1091 #ifdef RALINK_28xx_QA
1092 if (pAd
->ate
.bQATxStart
== TRUE
)
1094 pAd
->ate
.TxStatus
= 1;
1095 //pAd->ate.Repeat = 0;
1097 #endif // RALINK_28xx_QA //
1099 NdisAcquireSpinLock(&pAd
->GenericLock
);//0820
1100 pAd
->ContinBulkOut
= FALSE
;
1101 NdisReleaseSpinLock(&pAd
->GenericLock
);
1103 RTUSB_SET_BULK_FLAG(pAd
, fRTUSB_BULK_OUT_DATA_ATE
);
1105 RTUSBKickBulkOut(pAd
);
1110 while (atomic_read(&pAd
->BulkOutRemained
) > 0)
1112 RTMPusecDelay(5000);
1116 // Set MAC_SYS_CTRL(0x1004) Continuous Tx Production Test (bit4) = 1.
1117 RTMP_IO_READ32(pAd
, MAC_SYS_CTRL
, &MacData
);
1118 MacData
|= 0x00000010;
1119 RTMP_IO_WRITE32(pAd
, MAC_SYS_CTRL
, MacData
);
1121 else if (!strcmp(arg
, "TXFRAME")) // Tx Frames
1123 ATEDBGPRINT(RT_DEBUG_TRACE
, ("ATE: TXFRAME(Count=0x%08x)\n", pAd
->ate
.TxCount
));
1124 pAd
->ate
.Mode
|= ATE_TXFRAME
;
1129 // Default value in BBP R22 is 0x0.
1132 RTMP_IO_READ32(pAd
, MAC_SYS_CTRL
, &MacData
);
1134 // Clean bit4 to stop continuous Tx production test.
1135 MacData
&= 0xFFFFFFEF;
1137 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R22
, BbpData
);
1138 RTMP_IO_WRITE32(pAd
, MAC_SYS_CTRL
, MacData
);
1140 #ifdef RALINK_28xx_QA
1141 // add this for LoopBack mode
1142 if (pAd
->ate
.bQARxStart
== FALSE
)
1145 RTMP_IO_READ32(pAd
, MAC_SYS_CTRL
, &Value
);
1147 RTMP_IO_WRITE32(pAd
, MAC_SYS_CTRL
, Value
);
1150 if (pAd
->ate
.bQATxStart
== TRUE
)
1152 pAd
->ate
.TxStatus
= 1;
1153 //pAd->ate.Repeat = 0;
1157 RTMP_IO_READ32(pAd
, MAC_SYS_CTRL
, &Value
);
1159 RTMP_IO_WRITE32(pAd
, MAC_SYS_CTRL
, Value
);
1160 #endif // RALINK_28xx_QA //
1163 RTMP_IO_READ32(pAd
, MAC_SYS_CTRL
, &Value
);
1165 RTMP_IO_WRITE32(pAd
, MAC_SYS_CTRL
, Value
);
1167 SetJapanFilter(pAd
);
1169 // Abort Tx, RX DMA.
1170 RtmpDmaEnable(pAd
, 0);
1172 pAd
->ate
.TxDoneCount
= 0;
1174 // Setup frame format
1175 ATESetUpFrame(pAd
, 0);
1177 // Start Tx, RX DMA.
1178 RtmpDmaEnable(pAd
, 1);
1180 // Check count is continuous or not yet.
1182 // Due to the type mismatch between "pAd->BulkOutRemained"(atomic_t) and "pAd->ate.TxCount"(UINT32)
1184 if (pAd
->ate
.TxCount
== 0)
1186 InterlockedExchange(&pAd
->BulkOutRemained
, 0);
1190 InterlockedExchange(&pAd
->BulkOutRemained
, pAd
->ate
.TxCount
);
1192 ATEDBGPRINT(RT_DEBUG_TRACE
, ("bulk out count = %d\n", atomic_read(&pAd
->BulkOutRemained
)));
1193 ASSERT((atomic_read(&pAd
->BulkOutRemained
) >= 0));
1195 if (atomic_read(&pAd
->BulkOutRemained
) == 0)
1197 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Send packet countinuously\n"));
1199 /* In 28xx, NdisAcquireSpinLock() == spin_lock_bh() */
1200 /* NdisAcquireSpinLock only need one argument in 28xx. */
1201 NdisAcquireSpinLock(&pAd
->GenericLock
);
1202 pAd
->ContinBulkOut
= TRUE
;
1203 NdisReleaseSpinLock(&pAd
->GenericLock
);
1205 /* In 28xx, BULK_OUT_LOCK() == spin_lock_irqsave() */
1206 BULK_OUT_LOCK(&pAd
->BulkOutLock
[0], IrqFlags
);// peter : NdisAcquireSpinLock ==> BULK_OUT_LOCK
1207 pAd
->BulkOutPending
[0] = FALSE
;
1208 BULK_OUT_UNLOCK(&pAd
->BulkOutLock
[0], IrqFlags
);// peter : NdisAcquireSpinLock ==> BULK_OUT_LOCK
1212 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Send packets depend on counter\n"));
1214 NdisAcquireSpinLock(&pAd
->GenericLock
);
1215 pAd
->ContinBulkOut
= FALSE
;
1216 NdisReleaseSpinLock(&pAd
->GenericLock
);
1218 BULK_OUT_LOCK(&pAd
->BulkOutLock
[0], IrqFlags
);
1219 pAd
->BulkOutPending
[0] = FALSE
;
1220 BULK_OUT_UNLOCK(&pAd
->BulkOutLock
[0], IrqFlags
);
1223 RTUSB_SET_BULK_FLAG(pAd
, fRTUSB_BULK_OUT_DATA_ATE
);
1226 RTUSBKickBulkOut(pAd
);
1228 #ifdef RALINK_28xx_QA
1229 else if (!strcmp(arg
, "TXSTOP")) //Enter ATE mode and set Tx/Rx Idle
1231 ATEDBGPRINT(RT_DEBUG_TRACE
, ("ATE: TXSTOP\n"));
1233 atemode
= pAd
->ate
.Mode
;
1234 pAd
->ate
.Mode
&= ATE_TXSTOP
;
1235 pAd
->ate
.bQATxStart
= FALSE
;
1236 // pAd->ate.TxDoneCount = pAd->ate.TxCount;
1238 /*=========================================================================*/
1239 if (atemode
& ATE_TXCARR
)
1241 // No Carrier Test set BBP R22 bit7=0, bit6=0, bit[5~0]=0x0
1242 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R22
, &BbpData
);
1243 BbpData
&= 0xFFFFFF00; //clear bit7, bit6, bit[5~0]
1244 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R22
, BbpData
);
1246 else if (atemode
& ATE_TXCARRSUPP
)
1248 // No Cont. TX set BBP R22 bit7=0
1249 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R22
, &BbpData
);
1250 BbpData
&= ~(1 << 7); //set bit7=0
1251 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R22
, BbpData
);
1253 // No Carrier Suppression set BBP R24 bit0=0
1254 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R24
, &BbpData
);
1255 BbpData
&= 0xFFFFFFFE; //clear bit0
1256 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R24
, BbpData
);
1258 else if ((atemode
& ATE_TXFRAME
) || (atemode
== ATE_STOP
))
1260 if (atemode
& ATE_TXCONT
)
1262 // No Cont. TX set BBP R22 bit7=0
1263 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R22
, &BbpData
);
1264 BbpData
&= ~(1 << 7); //set bit7=0
1265 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R22
, BbpData
);
1269 /*=========================================================================*/
1270 RTUSBRejectPendingPackets(pAd
);
1271 RTUSBCleanUpDataBulkOutQueue(pAd
);
1273 /* not used in RT28xx */
1274 //RTUSBCleanUpMLMEWaitQueue(pAd);
1275 /* empty function so far */
1276 RTUSBCleanUpMLMEBulkOutQueue(pAd
);
1277 /*=========================================================================*/
1278 // Abort Tx, RX DMA.
1279 RtmpDmaEnable(pAd
, 0);
1280 /*=========================================================================*/
1282 /* In 28xx, pAd->PendingRx is not of type atomic_t anymore */
1283 // while ((atomic_read(&pAd->PendingRx) > 0)) //pAd->BulkFlags != 0 wait bulk out finish
1284 /* peter todo : BulkInLock */
1285 while (pAd
->PendingRx
> 0)
1288 ATE_RTUSBCancelPendingBulkInIRP(pAd
);
1290 // NdisInterlockedDecrement(&pAd->PendingRx);
1293 RTMPusecDelay(500000);
1296 while (((pAd
->BulkOutPending
[0] == TRUE
) ||
1297 (pAd
->BulkOutPending
[1] == TRUE
) ||
1298 (pAd
->BulkOutPending
[2] == TRUE
) ||
1299 (pAd
->BulkOutPending
[3] == TRUE
)) && (pAd
->BulkFlags
!= 0)) //pAd->BulkFlags != 0 wait bulk out finish
1303 RTUSBCancelPendingBulkOutIRP(pAd
);
1306 RTMPusecDelay(500000);
1309 ASSERT(pAd
->PendingRx
== 0);
1310 /*=========================================================================*/
1311 // Enable Tx, Rx DMA.
1312 RtmpDmaEnable(pAd
, 1);
1314 /* task Tx status : 0 --> task is idle, 1 --> task is running */
1315 pAd
->ate
.TxStatus
= 0;
1321 RTMP_IO_READ32(pAd
, MAC_SYS_CTRL
, &MacData
);
1322 MacData
&= (0xfffffffb);
1323 RTMP_IO_WRITE32(pAd
, MAC_SYS_CTRL
, MacData
);
1325 //Clean ATE Bulk in/out counter and continue setup
1326 InterlockedExchange(&pAd
->BulkOutRemained
, 0);
1328 pAd
->ContinBulkOut
= FALSE
;
1330 else if (!strcmp(arg
, "RXSTOP"))
1332 ATEDBGPRINT(RT_DEBUG_TRACE
, ("ATE: RXSTOP\n"));
1333 atemode
= pAd
->ate
.Mode
;
1336 RTMP_IO_READ32(pAd
, MAC_SYS_CTRL
, &Value
);
1338 RTMP_IO_WRITE32(pAd
, MAC_SYS_CTRL
, Value
);
1340 pAd
->ate
.Mode
&= ATE_RXSTOP
;
1341 pAd
->ate
.bQARxStart
= FALSE
;
1342 // pAd->ate.TxDoneCount = pAd->ate.TxCount;
1344 /*=========================================================================*/
1345 RTUSBRejectPendingPackets(pAd
);
1346 RTUSBCleanUpDataBulkOutQueue(pAd
);
1348 /* not used in RT28xx */
1349 //RTUSBCleanUpMLMEWaitQueue(pAd);
1350 RTUSBCleanUpMLMEBulkOutQueue(pAd
);
1351 /*=========================================================================*/
1353 // Abort Tx, RX DMA.
1354 RtmpDmaEnable(pAd
, 0);
1355 /*=========================================================================*/
1356 // while ((atomic_read(&pAd->PendingRx) > 0))
1357 while (pAd
->PendingRx
> 0)
1360 ATE_RTUSBCancelPendingBulkInIRP(pAd
);
1362 // NdisInterlockedDecrement(&pAd->PendingRx);
1365 RTMPusecDelay(500000);
1368 while (((pAd
->BulkOutPending
[0] == TRUE
) ||
1369 (pAd
->BulkOutPending
[1] == TRUE
) ||
1370 (pAd
->BulkOutPending
[2] == TRUE
) ||
1371 (pAd
->BulkOutPending
[3] == TRUE
)) && (pAd
->BulkFlags
!= 0)) //pAd->BulkFlags != 0 wait bulk out finish
1375 RTUSBCancelPendingBulkOutIRP(pAd
);
1378 RTMPusecDelay(500000);
1381 ASSERT(pAd
->PendingRx
== 0);
1382 /*=========================================================================*/
1386 pAd
->ContinBulkIn
= FALSE
;
1388 #endif // RALINK_28xx_QA //
1389 else if (!strcmp(arg
, "RXFRAME")) // Rx Frames
1391 ATEDBGPRINT(RT_DEBUG_TRACE
, ("ATE: RXFRAME\n"));
1393 // Disable Rx of MAC block
1394 RTMP_IO_READ32(pAd
, MAC_SYS_CTRL
, &Value
);
1396 RTMP_IO_WRITE32(pAd
, MAC_SYS_CTRL
, Value
);
1398 // Default value in BBP R22 is 0x0.
1401 RTMP_IO_READ32(pAd
, MAC_SYS_CTRL
, &MacData
);
1402 // Clean bit4 to stop continuous Tx production test.
1403 MacData
&= 0xFFFFFFEF;
1405 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R22
, BbpData
);
1406 RTMP_IO_WRITE32(pAd
, MAC_SYS_CTRL
, MacData
);
1408 pAd
->ate
.Mode
|= ATE_RXFRAME
;
1410 // Abort Tx, RX DMA.
1411 RtmpDmaEnable(pAd
, 0);
1413 // Disable TX of MAC block
1414 RTMP_IO_READ32(pAd
, MAC_SYS_CTRL
, &Value
);
1416 RTMP_IO_WRITE32(pAd
, MAC_SYS_CTRL
, Value
);
1419 for ( i
= 0; i
< (RX_RING_SIZE
); i
++)
1421 PRX_CONTEXT pRxContext
= &(pAd
->RxContext
[i
]);
1423 pRxContext
->InUse
= FALSE
;
1424 pRxContext
->IRPPending
= FALSE
;
1425 pRxContext
->Readable
= FALSE
;
1428 // Get the urb from kernel back to driver.
1430 RTUSB_UNLINK_URB(pRxContext
->pUrb
);
1432 /* Sleep 200 microsecs to give cancellation time to work. */
1436 // InterlockedExchange(&pAd->PendingRx, 0);
1438 pAd
->NextRxBulkInReadIndex
= 0; // Next Rx Read index
1439 pAd
->NextRxBulkInIndex
= RX_RING_SIZE
- 1; // Rx Bulk pointer
1440 pAd
->NextRxBulkInPosition
= 0;
1443 // read to clear counters
1444 RTUSBReadMACRegister(pAd
, RX_STA_CNT0
, &temp
); //RX PHY & RX CRC count
1445 RTUSBReadMACRegister(pAd
, RX_STA_CNT1
, &temp
); //RX PLCP error count & CCA false alarm count
1446 RTUSBReadMACRegister(pAd
, RX_STA_CNT2
, &temp
); //RX FIFO overflow frame count & RX duplicated filtered frame count
1448 pAd
->ContinBulkIn
= TRUE
;
1450 // Enable Tx, RX DMA.
1451 RtmpDmaEnable(pAd
, 1);
1453 // Enable RX of MAC block
1454 RTMP_IO_READ32(pAd
, MAC_SYS_CTRL
, &Value
);
1456 RTMP_IO_WRITE32(pAd
, MAC_SYS_CTRL
, Value
);
1459 RTUSBBulkReceive(pAd
);
1463 ATEDBGPRINT(RT_DEBUG_TRACE
, ("ATE: Invalid arg!\n"));
1466 RTMPusecDelay(5000);
1468 ATEDBGPRINT(RT_DEBUG_TRACE
, ("<=== ATECmdHandler()\n"));
1475 IN PRTMP_ADAPTER pAd
,
1478 if (ATECmdHandler(pAd
, arg
))
1480 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Ralink: Set_ATE_Proc Success\n"));
1487 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Ralink: Set_ATE_Proc Failed\n"));
1493 ==========================================================================
1495 Set ATE ADDR1=DA for TxFrame(AP : To DS = 0 ; From DS = 1)
1497 Set ATE ADDR3=DA for TxFrame(STA : To DS = 1 ; From DS = 0)
1500 TRUE if all parameters are OK, FALSE otherwise
1501 ==========================================================================
1503 INT
Set_ATE_DA_Proc(
1504 IN PRTMP_ADAPTER pAd
,
1510 if(strlen(arg
) != 17) //Mac address acceptable format 01:02:03:04:05:06 length 17
1513 for (i
=0, value
= rstrtok(arg
, ":"); value
; value
= rstrtok(NULL
, ":"))
1515 if((strlen(value
) != 2) || (!isxdigit(*value
)) || (!isxdigit(*(value
+1))) )
1516 return FALSE
; //Invalid
1519 #ifdef CONFIG_STA_SUPPORT
1520 AtoH(value
, &pAd
->ate
.Addr3
[i
++], 1);
1521 #endif // CONFIG_STA_SUPPORT //
1525 return FALSE
; //Invalid
1528 #ifdef CONFIG_STA_SUPPORT
1529 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Set_ATE_DA_Proc (DA = %2X:%2X:%2X:%2X:%2X:%2X)\n", pAd
->ate
.Addr3
[0],
1530 pAd
->ate
.Addr3
[1], pAd
->ate
.Addr3
[2], pAd
->ate
.Addr3
[3], pAd
->ate
.Addr3
[4], pAd
->ate
.Addr3
[5]));
1531 #endif // CONFIG_STA_SUPPORT //
1533 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Ralink: Set_ATE_DA_Proc Success\n"));
1539 ==========================================================================
1541 Set ATE ADDR3=SA for TxFrame(AP : To DS = 0 ; From DS = 1)
1543 Set ATE ADDR2=SA for TxFrame(STA : To DS = 1 ; From DS = 0)
1546 TRUE if all parameters are OK, FALSE otherwise
1547 ==========================================================================
1549 INT
Set_ATE_SA_Proc(
1550 IN PRTMP_ADAPTER pAd
,
1556 if(strlen(arg
) != 17) //Mac address acceptable format 01:02:03:04:05:06 length 17
1559 for (i
=0, value
= rstrtok(arg
, ":"); value
; value
= rstrtok(NULL
, ":"))
1561 if((strlen(value
) != 2) || (!isxdigit(*value
)) || (!isxdigit(*(value
+1))) )
1562 return FALSE
; //Invalid
1565 #ifdef CONFIG_STA_SUPPORT
1566 AtoH(value
, &pAd
->ate
.Addr2
[i
++], 1);
1567 #endif // CONFIG_STA_SUPPORT //
1571 return FALSE
; //Invalid
1574 #ifdef CONFIG_STA_SUPPORT
1575 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Set_ATE_SA_Proc (SA = %2X:%2X:%2X:%2X:%2X:%2X)\n", pAd
->ate
.Addr2
[0],
1576 pAd
->ate
.Addr2
[1], pAd
->ate
.Addr2
[2], pAd
->ate
.Addr2
[3], pAd
->ate
.Addr2
[4], pAd
->ate
.Addr2
[5]));
1577 #endif // CONFIG_STA_SUPPORT //
1579 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Ralink: Set_ATE_SA_Proc Success\n"));
1585 ==========================================================================
1587 Set ATE ADDR2=BSSID for TxFrame(AP : To DS = 0 ; From DS = 1)
1589 Set ATE ADDR1=BSSID for TxFrame(STA : To DS = 1 ; From DS = 0)
1592 TRUE if all parameters are OK, FALSE otherwise
1593 ==========================================================================
1595 INT
Set_ATE_BSSID_Proc(
1596 IN PRTMP_ADAPTER pAd
,
1602 if(strlen(arg
) != 17) //Mac address acceptable format 01:02:03:04:05:06 length 17
1605 for (i
=0, value
= rstrtok(arg
, ":"); value
; value
= rstrtok(NULL
, ":"))
1607 if((strlen(value
) != 2) || (!isxdigit(*value
)) || (!isxdigit(*(value
+1))) )
1608 return FALSE
; //Invalid
1611 #ifdef CONFIG_STA_SUPPORT
1612 AtoH(value
, &pAd
->ate
.Addr1
[i
++], 1);
1613 #endif // CONFIG_STA_SUPPORT //
1617 return FALSE
; //Invalid
1620 #ifdef CONFIG_STA_SUPPORT
1621 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Set_ATE_BSSID_Proc (BSSID = %2X:%2X:%2X:%2X:%2X:%2X)\n", pAd
->ate
.Addr1
[0],
1622 pAd
->ate
.Addr1
[1], pAd
->ate
.Addr1
[2], pAd
->ate
.Addr1
[3], pAd
->ate
.Addr1
[4], pAd
->ate
.Addr1
[5]));
1623 #endif // CONFIG_STA_SUPPORT //
1625 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Ralink: Set_ATE_BSSID_Proc Success\n"));
1631 ==========================================================================
1636 TRUE if all parameters are OK, FALSE otherwise
1637 ==========================================================================
1639 INT
Set_ATE_CHANNEL_Proc(
1640 IN PRTMP_ADAPTER pAd
,
1645 channel
= simple_strtol(arg
, 0, 10);
1647 if ((channel
< 1) || (channel
> 216))// to allow A band channel : ((channel < 1) || (channel > 14))
1649 ATEDBGPRINT(RT_DEBUG_ERROR
, ("Set_ATE_CHANNEL_Proc::Out of range, it should be in range of 1~14.\n"));
1652 pAd
->ate
.Channel
= channel
;
1654 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Set_ATE_CHANNEL_Proc (ATE Channel = %d)\n", pAd
->ate
.Channel
));
1655 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Ralink: Set_ATE_CHANNEL_Proc Success\n"));
1662 ==========================================================================
1667 TRUE if all parameters are OK, FALSE otherwise
1668 ==========================================================================
1670 INT
Set_ATE_TX_POWER0_Proc(
1671 IN PRTMP_ADAPTER pAd
,
1676 TxPower
= simple_strtol(arg
, 0, 10);
1678 if (pAd
->ate
.Channel
<= 14)
1680 if ((TxPower
> 31) || (TxPower
< 0))
1682 ATEDBGPRINT(RT_DEBUG_ERROR
, ("Set_ATE_TX_POWER0_Proc::Out of range (Value=%d)\n", TxPower
));
1688 if ((TxPower
> 15) || (TxPower
< -7))
1690 ATEDBGPRINT(RT_DEBUG_ERROR
, ("Set_ATE_TX_POWER0_Proc::Out of range (Value=%d)\n", TxPower
));
1695 pAd
->ate
.TxPower0
= TxPower
;
1696 ATETxPwrHandler(pAd
, 0);
1697 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Ralink: Set_ATE_TX_POWER0_Proc Success\n"));
1704 ==========================================================================
1709 TRUE if all parameters are OK, FALSE otherwise
1710 ==========================================================================
1712 INT
Set_ATE_TX_POWER1_Proc(
1713 IN PRTMP_ADAPTER pAd
,
1718 TxPower
= simple_strtol(arg
, 0, 10);
1720 if (pAd
->ate
.Channel
<= 14)
1722 if ((TxPower
> 31) || (TxPower
< 0))
1724 ATEDBGPRINT(RT_DEBUG_ERROR
, ("Set_ATE_TX_POWER1_Proc::Out of range (Value=%d)\n", TxPower
));
1730 if ((TxPower
> 15) || (TxPower
< -7))
1732 ATEDBGPRINT(RT_DEBUG_ERROR
, ("Set_ATE_TX_POWER1_Proc::Out of range (Value=%d)\n", TxPower
));
1737 pAd
->ate
.TxPower1
= TxPower
;
1738 ATETxPwrHandler(pAd
, 1);
1739 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Ralink: Set_ATE_TX_POWER1_Proc Success\n"));
1746 ==========================================================================
1751 TRUE if all parameters are OK, FALSE otherwise
1752 ==========================================================================
1754 INT
Set_ATE_TX_Antenna_Proc(
1755 IN PRTMP_ADAPTER pAd
,
1760 value
= simple_strtol(arg
, 0, 10);
1762 if ((value
> 2) || (value
< 0))
1764 ATEDBGPRINT(RT_DEBUG_ERROR
, ("Set_ATE_TX_Antenna_Proc::Out of range (Value=%d)\n", value
));
1768 pAd
->ate
.TxAntennaSel
= value
;
1770 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Set_ATE_TX_Antenna_Proc (Antenna = %d)\n", pAd
->ate
.TxAntennaSel
));
1771 ATEDBGPRINT(RT_DEBUG_TRACE
,("Ralink: Set_ATE_TX_Antenna_Proc Success\n"));
1778 ==========================================================================
1783 TRUE if all parameters are OK, FALSE otherwise
1784 ==========================================================================
1786 INT
Set_ATE_RX_Antenna_Proc(
1787 IN PRTMP_ADAPTER pAd
,
1792 value
= simple_strtol(arg
, 0, 10);
1794 if ((value
> 3) || (value
< 0))
1796 ATEDBGPRINT(RT_DEBUG_ERROR
, ("Set_ATE_RX_Antenna_Proc::Out of range (Value=%d)\n", value
));
1800 pAd
->ate
.RxAntennaSel
= value
;
1802 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Set_ATE_RX_Antenna_Proc (Antenna = %d)\n", pAd
->ate
.RxAntennaSel
));
1803 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Ralink: Set_ATE_RX_Antenna_Proc Success\n"));
1810 ==========================================================================
1812 Set ATE RF frequence offset
1815 TRUE if all parameters are OK, FALSE otherwise
1816 ==========================================================================
1818 INT
Set_ATE_TX_FREQOFFSET_Proc(
1819 IN PRTMP_ADAPTER pAd
,
1825 RFFreqOffset
= simple_strtol(arg
, 0, 10);
1827 if(RFFreqOffset
>= 64)
1829 ATEDBGPRINT(RT_DEBUG_ERROR
, ("Set_ATE_TX_FREQOFFSET_Proc::Out of range, it should be in range of 0~63.\n"));
1833 pAd
->ate
.RFFreqOffset
= RFFreqOffset
;
1834 R4
= pAd
->ate
.RFFreqOffset
<< 15; // shift TX power control to correct RF register bit position
1835 R4
|= (pAd
->LatchRfRegs
.R4
& ((~0x001f8000)));
1836 pAd
->LatchRfRegs
.R4
= R4
;
1840 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Set_ATE_TX_FREQOFFSET_Proc (RFFreqOffset = %d)\n", pAd
->ate
.RFFreqOffset
));
1841 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Ralink: Set_ATE_TX_FREQOFFSET_Proc Success\n"));
1848 ==========================================================================
1853 TRUE if all parameters are OK, FALSE otherwise
1854 ==========================================================================
1856 INT
Set_ATE_TX_BW_Proc(
1857 IN PRTMP_ADAPTER pAd
,
1864 BBPCurrentBW
= simple_strtol(arg
, 0, 10);
1866 if(BBPCurrentBW
== 0)
1867 pAd
->ate
.TxWI
.BW
= BW_20
;
1869 pAd
->ate
.TxWI
.BW
= BW_40
;
1871 if(pAd
->ate
.TxWI
.BW
== BW_20
)
1873 if(pAd
->ate
.Channel
<= 14)
1877 if (pAd
->Tx20MPwrCfgGBand
[i
] != 0xffffffff)
1879 RTMP_IO_WRITE32(pAd
, TX_PWR_CFG_0
+ i
*4, pAd
->Tx20MPwrCfgGBand
[i
]);
1880 RTMPusecDelay(5000);
1888 if (pAd
->Tx20MPwrCfgABand
[i
] != 0xffffffff)
1890 RTMP_IO_WRITE32(pAd
, TX_PWR_CFG_0
+ i
*4, pAd
->Tx20MPwrCfgABand
[i
]);
1891 RTMPusecDelay(5000);
1896 //Set BBP R4 bit[4:3]=0:0
1897 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R4
, &value
);
1899 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R4
, value
);
1903 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R66
, value
);
1905 //to improve Rx sensitivity.
1907 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R68
, value
);
1910 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R69
, value
);
1913 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R70
, value
);
1916 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R73
, value
);
1918 // If Channel=14, Bandwidth=20M and Mode=CCK, Set BBP R4 bit5=1
1919 // (Japan filter coefficients)
1920 // This segment of code will only works when ATETXMODE and ATECHANNEL
1921 // were set to MODE_CCK and 14 respectively before ATETXBW is set to 0.
1922 //=====================================================================
1923 if (pAd
->ate
.Channel
== 14)
1925 int TxMode
= pAd
->ate
.TxWI
.PHYMODE
;
1926 if (TxMode
== MODE_CCK
)
1928 // when Channel==14 && Mode==CCK && BandWidth==20M, BBP R4 bit5=1
1929 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R4
, &value
);
1930 value
|= 0x20; //set bit5=1
1931 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R4
, value
);
1935 //=====================================================================
1936 // If bandwidth != 40M, RF Reg4 bit 21 = 0.
1937 pAd
->LatchRfRegs
.R4
&= ~0x00200000;
1940 else if(pAd
->ate
.TxWI
.BW
== BW_40
)
1942 if(pAd
->ate
.Channel
<= 14)
1946 if (pAd
->Tx40MPwrCfgGBand
[i
] != 0xffffffff)
1948 RTMP_IO_WRITE32(pAd
, TX_PWR_CFG_0
+ i
*4, pAd
->Tx40MPwrCfgGBand
[i
]);
1949 RTMPusecDelay(5000);
1957 if (pAd
->Tx40MPwrCfgABand
[i
] != 0xffffffff)
1959 RTMP_IO_WRITE32(pAd
, TX_PWR_CFG_0
+ i
*4, pAd
->Tx40MPwrCfgABand
[i
]);
1960 RTMPusecDelay(5000);
1963 #ifdef DOT11_N_SUPPORT
1964 if ((pAd
->ate
.TxWI
.PHYMODE
>= MODE_HTMIX
) && (pAd
->ate
.TxWI
.MCS
== 7))
1967 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R67
, value
);
1969 #endif // DOT11_N_SUPPORT //
1972 //Set BBP R4 bit[4:3]=1:0
1973 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R4
, &value
);
1976 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R4
, value
);
1980 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R66
, value
);
1982 //to improve Rx sensitivity.
1984 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R68
, value
);
1987 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R69
, value
);
1990 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R70
, value
);
1993 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R73
, value
);
1995 // If bandwidth = 40M, set RF Reg4 bit 21 = 1.
1996 pAd
->LatchRfRegs
.R4
|= 0x00200000;
2000 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Set_ATE_TX_BW_Proc (BBPCurrentBW = %d)\n", pAd
->ate
.TxWI
.BW
));
2001 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Ralink: Set_ATE_TX_BW_Proc Success\n"));
2008 ==========================================================================
2010 Set ATE Tx frame length
2013 TRUE if all parameters are OK, FALSE otherwise
2014 ==========================================================================
2016 INT
Set_ATE_TX_LENGTH_Proc(
2017 IN PRTMP_ADAPTER pAd
,
2020 pAd
->ate
.TxLength
= simple_strtol(arg
, 0, 10);
2022 if((pAd
->ate
.TxLength
< 24) || (pAd
->ate
.TxLength
> (MAX_FRAME_SIZE
- 34/* == 2312 */)))
2024 pAd
->ate
.TxLength
= (MAX_FRAME_SIZE
- 34/* == 2312 */);
2025 ATEDBGPRINT(RT_DEBUG_ERROR
, ("Set_ATE_TX_LENGTH_Proc::Out of range, it should be in range of 24~%d.\n", (MAX_FRAME_SIZE
- 34/* == 2312 */)));
2029 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Set_ATE_TX_LENGTH_Proc (TxLength = %d)\n", pAd
->ate
.TxLength
));
2030 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Ralink: Set_ATE_TX_LENGTH_Proc Success\n"));
2037 ==========================================================================
2039 Set ATE Tx frame count
2042 TRUE if all parameters are OK, FALSE otherwise
2043 ==========================================================================
2045 INT
Set_ATE_TX_COUNT_Proc(
2046 IN PRTMP_ADAPTER pAd
,
2049 pAd
->ate
.TxCount
= simple_strtol(arg
, 0, 10);
2051 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Set_ATE_TX_COUNT_Proc (TxCount = %d)\n", pAd
->ate
.TxCount
));
2052 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Ralink: Set_ATE_TX_COUNT_Proc Success\n"));
2059 ==========================================================================
2061 Set ATE Tx frame MCS
2064 TRUE if all parameters are OK, FALSE otherwise
2065 ==========================================================================
2067 INT
Set_ATE_TX_MCS_Proc(
2068 IN PRTMP_ADAPTER pAd
,
2074 MCS
= simple_strtol(arg
, 0, 10);
2075 result
= CheckMCSValid(pAd
->ate
.TxWI
.PHYMODE
, MCS
);
2079 pAd
->ate
.TxWI
.MCS
= (UCHAR
)MCS
;
2083 ATEDBGPRINT(RT_DEBUG_ERROR
, ("Set_ATE_TX_MCS_Proc::Out of range, refer to rate table.\n"));
2087 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Set_ATE_TX_MCS_Proc (MCS = %d)\n", pAd
->ate
.TxWI
.MCS
));
2088 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Ralink: Set_ATE_TX_MCS_Proc Success\n"));
2095 ==========================================================================
2097 Set ATE Tx frame Mode
2101 3: MODE_HTGREENFIELD
2104 TRUE if all parameters are OK, FALSE otherwise
2105 ==========================================================================
2107 INT
Set_ATE_TX_MODE_Proc(
2108 IN PRTMP_ADAPTER pAd
,
2111 pAd
->ate
.TxWI
.PHYMODE
= simple_strtol(arg
, 0, 10);
2113 if(pAd
->ate
.TxWI
.PHYMODE
> 3)
2115 pAd
->ate
.TxWI
.PHYMODE
= 0;
2116 ATEDBGPRINT(RT_DEBUG_ERROR
, ("Set_ATE_TX_MODE_Proc::Out of range. it should be in range of 0~3\n"));
2117 ATEDBGPRINT(RT_DEBUG_ERROR
, ("0: CCK, 1: OFDM, 2: HT_MIX, 3: HT_GREEN_FIELD.\n"));
2121 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Set_ATE_TX_MODE_Proc (TxMode = %d)\n", pAd
->ate
.TxWI
.PHYMODE
));
2122 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Ralink: Set_ATE_TX_MODE_Proc Success\n"));
2129 ==========================================================================
2134 TRUE if all parameters are OK, FALSE otherwise
2135 ==========================================================================
2137 INT
Set_ATE_TX_GI_Proc(
2138 IN PRTMP_ADAPTER pAd
,
2141 pAd
->ate
.TxWI
.ShortGI
= simple_strtol(arg
, 0, 10);
2143 if(pAd
->ate
.TxWI
.ShortGI
> 1)
2145 pAd
->ate
.TxWI
.ShortGI
= 0;
2146 ATEDBGPRINT(RT_DEBUG_ERROR
, ("Set_ATE_TX_GI_Proc::Out of range\n"));
2150 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Set_ATE_TX_GI_Proc (GI = %d)\n", pAd
->ate
.TxWI
.ShortGI
));
2151 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Ralink: Set_ATE_TX_GI_Proc Success\n"));
2158 ==========================================================================
2160 ==========================================================================
2162 INT
Set_ATE_RX_FER_Proc(
2163 IN PRTMP_ADAPTER pAd
,
2166 pAd
->ate
.bRxFer
= simple_strtol(arg
, 0, 10);
2168 if (pAd
->ate
.bRxFer
== 1)
2170 pAd
->ate
.RxCntPerSec
= 0;
2171 pAd
->ate
.RxTotalCnt
= 0;
2174 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Set_ATE_RX_FER_Proc (bRxFer = %d)\n", pAd
->ate
.bRxFer
));
2175 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Ralink: Set_ATE_RX_FER_Proc Success\n"));
2181 INT
Set_ATE_Read_RF_Proc(
2182 IN PRTMP_ADAPTER pAd
,
2185 ate_print(KERN_EMERG
"R1 = %lx\n", pAd
->LatchRfRegs
.R1
);
2186 ate_print(KERN_EMERG
"R2 = %lx\n", pAd
->LatchRfRegs
.R2
);
2187 ate_print(KERN_EMERG
"R3 = %lx\n", pAd
->LatchRfRegs
.R3
);
2188 ate_print(KERN_EMERG
"R4 = %lx\n", pAd
->LatchRfRegs
.R4
);
2193 INT
Set_ATE_Write_RF1_Proc(
2194 IN PRTMP_ADAPTER pAd
,
2197 UINT32 value
= simple_strtol(arg
, 0, 16);
2199 pAd
->LatchRfRegs
.R1
= value
;
2205 INT
Set_ATE_Write_RF2_Proc(
2206 IN PRTMP_ADAPTER pAd
,
2209 UINT32 value
= simple_strtol(arg
, 0, 16);
2211 pAd
->LatchRfRegs
.R2
= value
;
2217 INT
Set_ATE_Write_RF3_Proc(
2218 IN PRTMP_ADAPTER pAd
,
2221 UINT32 value
= simple_strtol(arg
, 0, 16);
2223 pAd
->LatchRfRegs
.R3
= value
;
2229 INT
Set_ATE_Write_RF4_Proc(
2230 IN PRTMP_ADAPTER pAd
,
2233 UINT32 value
= simple_strtol(arg
, 0, 16);
2235 pAd
->LatchRfRegs
.R4
= value
;
2242 ==========================================================================
2244 Load and Write EEPROM from a binary file prepared in advance.
2247 TRUE if all parameters are OK, FALSE otherwise
2248 ==========================================================================
2251 INT
Set_ATE_Load_E2P_Proc(
2252 IN PRTMP_ADAPTER pAd
,
2255 BOOLEAN ret
= FALSE
;
2256 PUCHAR src
= EEPROM_BIN_FILE_NAME
;
2258 INT32 retval
, orgfsuid
, orgfsgid
;
2260 USHORT WriteEEPROM
[(EEPROM_SIZE
/2)];
2261 UINT32 FileLength
= 0;
2262 UINT32 value
= simple_strtol(arg
, 0, 10);
2264 ATEDBGPRINT(RT_DEBUG_ERROR
, ("===> %s (value=%d)\n\n", __func__
, value
));
2268 /* zero the e2p buffer */
2269 NdisZeroMemory((PUCHAR
)WriteEEPROM
, EEPROM_SIZE
);
2271 /* save uid and gid used for filesystem access.
2272 ** set user and group to 0 (root)
2274 orgfsuid
= current
->fsuid
;
2275 orgfsgid
= current
->fsgid
;
2277 current
->fsuid
= current
->fsgid
= 0;
2283 /* open the bin file */
2284 srcf
= filp_open(src
, O_RDONLY
, 0);
2288 ate_print("%s - Error %ld opening %s\n", __func__
, -PTR_ERR(srcf
), src
);
2292 /* the object must have a read method */
2293 if ((srcf
->f_op
== NULL
) || (srcf
->f_op
->read
== NULL
))
2295 ate_print("%s - %s does not have a read method\n", __func__
, src
);
2299 /* read the firmware from the file *.bin */
2300 FileLength
= srcf
->f_op
->read(srcf
,
2301 (PUCHAR
)WriteEEPROM
,
2305 if (FileLength
!= EEPROM_SIZE
)
2307 ate_print("%s: error file length (=%d) in e2p.bin\n",
2308 __func__
, FileLength
);
2313 /* write the content of .bin file to EEPROM */
2314 rt_ee_write_all(pAd
, WriteEEPROM
);
2320 /* close firmware file */
2327 retval
= filp_close(srcf
, NULL
);
2330 ATEDBGPRINT(RT_DEBUG_ERROR
, ("--> Error %d closing %s\n", -retval
, src
));
2337 current
->fsuid
= orgfsuid
;
2338 current
->fsgid
= orgfsgid
;
2340 ATEDBGPRINT(RT_DEBUG_ERROR
, ("<=== %s (ret=%d)\n", __func__
, ret
));
2346 INT
Set_ATE_Load_E2P_Proc(
2347 IN PRTMP_ADAPTER pAd
,
2350 USHORT WriteEEPROM
[(EEPROM_SIZE
/2)];
2351 struct iwreq
*wrq
= (struct iwreq
*)arg
;
2353 ATEDBGPRINT(RT_DEBUG_TRACE
, ("===> %s (wrq->u.data.length = %d)\n\n", __func__
, wrq
->u
.data
.length
));
2355 if (wrq
->u
.data
.length
!= EEPROM_SIZE
)
2357 ate_print("%s: error length (=%d) from host\n",
2358 __func__
, wrq
->u
.data
.length
);
2361 else/* (wrq->u.data.length == EEPROM_SIZE) */
2363 /* zero the e2p buffer */
2364 NdisZeroMemory((PUCHAR
)WriteEEPROM
, EEPROM_SIZE
);
2366 /* fill the local buffer */
2367 NdisMoveMemory((PUCHAR
)WriteEEPROM
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
2371 /* write the content of .bin file to EEPROM */
2372 rt_ee_write_all(pAd
, WriteEEPROM
);
2377 ATEDBGPRINT(RT_DEBUG_TRACE
, ("<=== %s\n", __func__
));
2384 INT
Set_ATE_Read_E2P_Proc(
2385 IN PRTMP_ADAPTER pAd
,
2388 USHORT buffer
[EEPROM_SIZE
/2];
2392 rt_ee_read_all(pAd
, (USHORT
*)buffer
);
2394 for (i
= 0; i
< (EEPROM_SIZE
/2); i
++)
2396 ate_print("%4.4x ", *p
);
2397 if (((i
+1) % 16) == 0)
2404 INT
Set_ATE_Show_Proc(
2405 IN PRTMP_ADAPTER pAd
,
2408 ate_print("Mode=%d\n", pAd
->ate
.Mode
);
2409 ate_print("TxPower0=%d\n", pAd
->ate
.TxPower0
);
2410 ate_print("TxPower1=%d\n", pAd
->ate
.TxPower1
);
2411 ate_print("TxAntennaSel=%d\n", pAd
->ate
.TxAntennaSel
);
2412 ate_print("RxAntennaSel=%d\n", pAd
->ate
.RxAntennaSel
);
2413 ate_print("BBPCurrentBW=%d\n", pAd
->ate
.TxWI
.BW
);
2414 ate_print("GI=%d\n", pAd
->ate
.TxWI
.ShortGI
);
2415 ate_print("MCS=%d\n", pAd
->ate
.TxWI
.MCS
);
2416 ate_print("TxMode=%d\n", pAd
->ate
.TxWI
.PHYMODE
);
2417 ate_print("Addr1=%02x:%02x:%02x:%02x:%02x:%02x\n",
2418 pAd
->ate
.Addr1
[0], pAd
->ate
.Addr1
[1], pAd
->ate
.Addr1
[2], pAd
->ate
.Addr1
[3], pAd
->ate
.Addr1
[4], pAd
->ate
.Addr1
[5]);
2419 ate_print("Addr2=%02x:%02x:%02x:%02x:%02x:%02x\n",
2420 pAd
->ate
.Addr2
[0], pAd
->ate
.Addr2
[1], pAd
->ate
.Addr2
[2], pAd
->ate
.Addr2
[3], pAd
->ate
.Addr2
[4], pAd
->ate
.Addr2
[5]);
2421 ate_print("Addr3=%02x:%02x:%02x:%02x:%02x:%02x\n",
2422 pAd
->ate
.Addr3
[0], pAd
->ate
.Addr3
[1], pAd
->ate
.Addr3
[2], pAd
->ate
.Addr3
[3], pAd
->ate
.Addr3
[4], pAd
->ate
.Addr3
[5]);
2423 ate_print("Channel=%d\n", pAd
->ate
.Channel
);
2424 ate_print("TxLength=%d\n", pAd
->ate
.TxLength
);
2425 ate_print("TxCount=%u\n", pAd
->ate
.TxCount
);
2426 ate_print("RFFreqOffset=%d\n", pAd
->ate
.RFFreqOffset
);
2427 ate_print(KERN_EMERG
"Set_ATE_Show_Proc Success\n");
2431 INT
Set_ATE_Help_Proc(
2432 IN PRTMP_ADAPTER pAd
,
2435 ate_print("ATE=ATESTART, ATESTOP, TXCONT, TXCARR, TXFRAME, RXFRAME\n");
2436 ate_print("ATEDA\n");
2437 ate_print("ATESA\n");
2438 ate_print("ATEBSSID\n");
2439 ate_print("ATECHANNEL, range:0~14(unless A band !)\n");
2440 ate_print("ATETXPOW0, set power level of antenna 1.\n");
2441 ate_print("ATETXPOW1, set power level of antenna 2.\n");
2442 ate_print("ATETXANT, set TX antenna. 0:all, 1:antenna one, 2:antenna two.\n");
2443 ate_print("ATERXANT, set RX antenna.0:all, 1:antenna one, 2:antenna two, 3:antenna three.\n");
2444 ate_print("ATETXFREQOFFSET, set frequency offset, range 0~63\n");
2445 ate_print("ATETXBW, set BandWidth, 0:20MHz, 1:40MHz.\n");
2446 ate_print("ATETXLEN, set Frame length, range 24~%d\n", (MAX_FRAME_SIZE
- 34/* == 2312 */));
2447 ate_print("ATETXCNT, set how many frame going to transmit.\n");
2448 ate_print("ATETXMCS, set MCS, reference to rate table.\n");
2449 ate_print("ATETXMODE, set Mode 0:CCK, 1:OFDM, 2:HT-Mix, 3:GreenField, reference to rate table.\n");
2450 ate_print("ATETXGI, set GI interval, 0:Long, 1:Short\n");
2451 ate_print("ATERXFER, 0:disable Rx Frame error rate. 1:enable Rx Frame error rate.\n");
2452 ate_print("ATERRF, show all RF registers.\n");
2453 ate_print("ATEWRF1, set RF1 register.\n");
2454 ate_print("ATEWRF2, set RF2 register.\n");
2455 ate_print("ATEWRF3, set RF3 register.\n");
2456 ate_print("ATEWRF4, set RF4 register.\n");
2457 ate_print("ATELDE2P, load EEPROM from .bin file.\n");
2458 ate_print("ATERE2P, display all EEPROM content.\n");
2459 ate_print("ATESHOW, display all parameters of ATE.\n");
2460 ate_print("ATEHELP, online help.\n");
2466 ==========================================================================
2469 AsicSwitchChannel() dedicated for ATE.
2471 ==========================================================================
2473 VOID
ATEAsicSwitchChannel(
2474 IN PRTMP_ADAPTER pAd
)
2476 UINT32 R2
= 0, R3
= DEFAULT_RF_TX_POWER
, R4
= 0, Value
= 0;
2477 CHAR TxPwer
= 0, TxPwer2
= 0;
2478 UCHAR index
, BbpValue
= 0, R66
= 0x30;
2479 RTMP_RF_REGS
*RFRegTable
;
2482 #ifdef RALINK_28xx_QA
2483 if ((pAd
->ate
.bQATxStart
== TRUE
) || (pAd
->ate
.bQARxStart
== TRUE
))
2485 if (pAd
->ate
.Channel
!= pAd
->LatchRfRegs
.Channel
)
2487 pAd
->ate
.Channel
= pAd
->LatchRfRegs
.Channel
;
2492 #endif // RALINK_28xx_QA //
2493 Channel
= pAd
->ate
.Channel
;
2496 AsicAntennaSelect(pAd
, Channel
);
2498 // fill Tx power value
2499 TxPwer
= pAd
->ate
.TxPower0
;
2500 TxPwer2
= pAd
->ate
.TxPower1
;
2502 RFRegTable
= RF2850RegTable
;
2504 switch (pAd
->RfIcType
)
2506 /* But only 2850 and 2750 support 5.5GHz band... */
2512 for (index
= 0; index
< NUM_OF_2850_CHNL
; index
++)
2514 if (Channel
== RFRegTable
[index
].Channel
)
2516 R2
= RFRegTable
[index
].R2
;
2517 if (pAd
->Antenna
.field
.TxPath
== 1)
2519 R2
|= 0x4000; // If TXpath is 1, bit 14 = 1;
2522 if (pAd
->Antenna
.field
.RxPath
== 2)
2524 switch (pAd
->ate
.RxAntennaSel
)
2528 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R3
, &BbpValue
);
2531 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R3
, BbpValue
);
2535 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R3
, &BbpValue
);
2538 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R3
, BbpValue
);
2542 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R3
, &BbpValue
);
2544 /* Only enable two Antenna to receive. */
2546 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R3
, BbpValue
);
2550 else if (pAd
->Antenna
.field
.RxPath
== 1)
2552 R2
|= 0x20040; // write 1 to off RxPath
2555 if (pAd
->Antenna
.field
.TxPath
== 2)
2557 if (pAd
->ate
.TxAntennaSel
== 1)
2559 R2
|= 0x4000; // If TX Antenna select is 1 , bit 14 = 1; Disable Ant 2
2560 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R1
, &BbpValue
);
2561 BbpValue
&= 0xE7; //11100111B
2562 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R1
, BbpValue
);
2564 else if (pAd
->ate
.TxAntennaSel
== 2)
2566 R2
|= 0x8000; // If TX Antenna select is 2 , bit 15 = 1; Disable Ant 1
2567 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R1
, &BbpValue
);
2570 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R1
, BbpValue
);
2574 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R1
, &BbpValue
);
2577 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R1
, BbpValue
);
2580 if (pAd
->Antenna
.field
.RxPath
== 3)
2582 switch (pAd
->ate
.RxAntennaSel
)
2586 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R3
, &BbpValue
);
2589 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R3
, BbpValue
);
2593 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R3
, &BbpValue
);
2596 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R3
, BbpValue
);
2600 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R3
, &BbpValue
);
2603 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R3
, BbpValue
);
2606 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R3
, &BbpValue
);
2609 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R3
, BbpValue
);
2616 // initialize R3, R4
2617 R3
= (RFRegTable
[index
].R3
& 0xffffc1ff);
2618 R4
= (RFRegTable
[index
].R4
& (~0x001f87c0)) | (pAd
->ate
.RFFreqOffset
<< 15);
2620 // According the Rory's suggestion to solve the middle range issue.
2621 // 5.5G band power range: 0xF9~0X0F, TX0 Reg3 bit9/TX1 Reg4 bit6="0" means the TX power reduce 7dB
2623 if ((TxPwer
>= -7) && (TxPwer
< 0))
2625 TxPwer
= (7+TxPwer
);
2626 TxPwer
= (TxPwer
> 0xF) ? (0xF) : (TxPwer
);
2627 R3
|= (TxPwer
<< 10);
2628 ATEDBGPRINT(RT_DEBUG_TRACE
, ("ATEAsicSwitchChannel: TxPwer=%d \n", TxPwer
));
2632 TxPwer
= (TxPwer
> 0xF) ? (0xF) : (TxPwer
);
2633 R3
|= (TxPwer
<< 10) | (1 << 9);
2637 if ((TxPwer2
>= -7) && (TxPwer2
< 0))
2639 TxPwer2
= (7+TxPwer2
);
2640 TxPwer2
= (TxPwer2
> 0xF) ? (0xF) : (TxPwer2
);
2641 R4
|= (TxPwer2
<< 7);
2642 ATEDBGPRINT(RT_DEBUG_TRACE
, ("ATEAsicSwitchChannel: TxPwer2=%d \n", TxPwer2
));
2646 TxPwer2
= (TxPwer2
> 0xF) ? (0xF) : (TxPwer2
);
2647 R4
|= (TxPwer2
<< 7) | (1 << 6);
2652 R3
= (RFRegTable
[index
].R3
& 0xffffc1ff) | (TxPwer
<< 9); // set TX power0
2653 R4
= (RFRegTable
[index
].R4
& (~0x001f87c0)) | (pAd
->ate
.RFFreqOffset
<< 15) | (TxPwer2
<<6);// Set freq offset & TxPwr1
2656 // Based on BBP current mode before changing RF channel.
2657 if (pAd
->ate
.TxWI
.BW
== BW_40
)
2663 pAd
->LatchRfRegs
.Channel
= Channel
;
2664 pAd
->LatchRfRegs
.R1
= RFRegTable
[index
].R1
;
2665 pAd
->LatchRfRegs
.R2
= R2
;
2666 pAd
->LatchRfRegs
.R3
= R3
;
2667 pAd
->LatchRfRegs
.R4
= R4
;
2680 // Change BBP setting during switch from a->g, g->a
2683 ULONG TxPinCfg
= 0x00050F0A;// 2007.10.09 by Brian : 0x0005050A ==> 0x00050F0A
2685 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R62
, (0x37 - GET_LNA_GAIN(pAd
)));
2686 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R63
, (0x37 - GET_LNA_GAIN(pAd
)));
2687 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R64
, (0x37 - GET_LNA_GAIN(pAd
)));
2689 /* For 1T/2R chip only... */
2690 if (pAd
->NicConfig2
.field
.ExternalLNAForG
)
2692 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R82
, 0x62);
2696 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R82
, 0x84);
2699 // According the Rory's suggestion to solve the middle range issue.
2700 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R86
, &BbpValue
);
2701 ASSERT((BbpValue
== 0x00));
2702 if ((BbpValue
!= 0x00))
2704 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R86
, 0x00);
2707 // 5.5GHz band selection PIN, bit1 and bit2 are complement
2708 RTMP_IO_READ32(pAd
, TX_BAND_CFG
, &Value
);
2711 RTMP_IO_WRITE32(pAd
, TX_BAND_CFG
, Value
);
2713 // Turn off unused PA or LNA when only 1T or 1R.
2714 if (pAd
->Antenna
.field
.TxPath
== 1)
2716 TxPinCfg
&= 0xFFFFFFF3;
2718 if (pAd
->Antenna
.field
.RxPath
== 1)
2720 TxPinCfg
&= 0xFFFFF3FF;
2723 RTMP_IO_WRITE32(pAd
, TX_PIN_CFG
, TxPinCfg
);
2727 ULONG TxPinCfg
= 0x00050F05;//2007.10.09 by Brian : 0x00050505 ==> 0x00050F05
2729 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R62
, (0x37 - GET_LNA_GAIN(pAd
)));
2730 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R63
, (0x37 - GET_LNA_GAIN(pAd
)));
2731 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R64
, (0x37 - GET_LNA_GAIN(pAd
)));
2732 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R82
, 0xF2);
2734 // According the Rory's suggestion to solve the middle range issue.
2735 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R86
, &BbpValue
);
2736 ASSERT((BbpValue
== 0x00));
2737 if ((BbpValue
!= 0x00))
2739 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R86
, 0x00);
2741 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R91
, &BbpValue
);
2742 ASSERT((BbpValue
== 0x04));
2744 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R92
, &BbpValue
);
2745 ASSERT((BbpValue
== 0x00));
2747 // 5.5GHz band selection PIN, bit1 and bit2 are complement
2748 RTMP_IO_READ32(pAd
, TX_BAND_CFG
, &Value
);
2751 RTMP_IO_WRITE32(pAd
, TX_BAND_CFG
, Value
);
2753 // Turn off unused PA or LNA when only 1T or 1R.
2754 if (pAd
->Antenna
.field
.TxPath
== 1)
2756 TxPinCfg
&= 0xFFFFFFF3;
2758 if (pAd
->Antenna
.field
.RxPath
== 1)
2760 TxPinCfg
&= 0xFFFFF3FF;
2763 RTMP_IO_WRITE32(pAd
, TX_PIN_CFG
, TxPinCfg
);
2766 // R66 should be set according to Channel and use 20MHz when scanning
2770 R66
= 0x2E + GET_LNA_GAIN(pAd
);
2771 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R66
, R66
);
2776 if (pAd
->ate
.TxWI
.BW
== BW_20
)
2778 R66
= (UCHAR
)(0x32 + (GET_LNA_GAIN(pAd
)*5)/3);
2779 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R66
, R66
);
2783 R66
= (UCHAR
)(0x3A + (GET_LNA_GAIN(pAd
)*5)/3);
2784 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R66
, R66
);
2789 // On 11A, We should delay and wait RF/BBP to be stable
2790 // and the appropriate time should be 1000 micro seconds
2791 // 2005/06/05 - On 11G, We also need this delay time. Otherwise it's difficult to pass the WHQL.
2793 RTMPusecDelay(1000);
2797 // When 5.5GHz band the LSB of TxPwr will be used to reduced 7dB or not.
2798 ATEDBGPRINT(RT_DEBUG_TRACE
, ("SwitchChannel#%d(RF=%d, %dT) to , R1=0x%08lx, R2=0x%08lx, R3=0x%08lx, R4=0x%08lx\n",
2801 pAd
->Antenna
.field
.TxPath
,
2802 pAd
->LatchRfRegs
.R1
,
2803 pAd
->LatchRfRegs
.R2
,
2804 pAd
->LatchRfRegs
.R3
,
2805 pAd
->LatchRfRegs
.R4
));
2809 ATEDBGPRINT(RT_DEBUG_TRACE
, ("SwitchChannel#%d(RF=%d, Pwr0=%u, Pwr1=%u, %dT) to , R1=0x%08lx, R2=0x%08lx, R3=0x%08lx, R4=0x%08lx\n",
2812 (R3
& 0x00003e00) >> 9,
2813 (R4
& 0x000007c0) >> 6,
2814 pAd
->Antenna
.field
.TxPath
,
2815 pAd
->LatchRfRegs
.R1
,
2816 pAd
->LatchRfRegs
.R2
,
2817 pAd
->LatchRfRegs
.R3
,
2818 pAd
->LatchRfRegs
.R4
));
2823 // In fact, no one will call this routine so far !
2826 ==========================================================================
2828 Gives CCK TX rate 2 more dB TX power.
2829 This routine works only in ATE mode.
2831 calculate desired Tx power in RF R3.Tx0~5, should consider -
2832 0. if current radio is a noisy environment (pAd->DrsCounters.fNoisyEnvironment)
2833 1. TxPowerPercentage
2834 2. auto calibration based on TSSI feedback
2835 3. extra 2 db for CCK
2836 4. -10 db upon very-short distance (AvgRSSI >= -40db) to AP
2838 NOTE: Since this routine requires the value of (pAd->DrsCounters.fNoisyEnvironment),
2839 it should be called AFTER MlmeDynamicTxRateSwitching()
2840 ==========================================================================
2842 VOID
ATEAsicAdjustTxPower(
2843 IN PRTMP_ADAPTER pAd
)
2847 BOOLEAN bAutoTxAgc
= FALSE
;
2848 UCHAR TssiRef
, *pTssiMinusBoundary
, *pTssiPlusBoundary
, TxAgcStep
;
2849 UCHAR BbpR49
= 0, idx
;
2850 PCHAR pTxAgcCompensate
;
2854 /* no one calls this procedure so far */
2855 if (pAd
->ate
.TxWI
.BW
== BW_40
)
2857 if (pAd
->ate
.Channel
> 14)
2859 TxPwr
[0] = pAd
->Tx40MPwrCfgABand
[0];
2860 TxPwr
[1] = pAd
->Tx40MPwrCfgABand
[1];
2861 TxPwr
[2] = pAd
->Tx40MPwrCfgABand
[2];
2862 TxPwr
[3] = pAd
->Tx40MPwrCfgABand
[3];
2863 TxPwr
[4] = pAd
->Tx40MPwrCfgABand
[4];
2867 TxPwr
[0] = pAd
->Tx40MPwrCfgGBand
[0];
2868 TxPwr
[1] = pAd
->Tx40MPwrCfgGBand
[1];
2869 TxPwr
[2] = pAd
->Tx40MPwrCfgGBand
[2];
2870 TxPwr
[3] = pAd
->Tx40MPwrCfgGBand
[3];
2871 TxPwr
[4] = pAd
->Tx40MPwrCfgGBand
[4];
2876 if (pAd
->ate
.Channel
> 14)
2878 TxPwr
[0] = pAd
->Tx20MPwrCfgABand
[0];
2879 TxPwr
[1] = pAd
->Tx20MPwrCfgABand
[1];
2880 TxPwr
[2] = pAd
->Tx20MPwrCfgABand
[2];
2881 TxPwr
[3] = pAd
->Tx20MPwrCfgABand
[3];
2882 TxPwr
[4] = pAd
->Tx20MPwrCfgABand
[4];
2886 TxPwr
[0] = pAd
->Tx20MPwrCfgGBand
[0];
2887 TxPwr
[1] = pAd
->Tx20MPwrCfgGBand
[1];
2888 TxPwr
[2] = pAd
->Tx20MPwrCfgGBand
[2];
2889 TxPwr
[3] = pAd
->Tx20MPwrCfgGBand
[3];
2890 TxPwr
[4] = pAd
->Tx20MPwrCfgGBand
[4];
2894 // TX power compensation for temperature variation based on TSSI.
2895 // Do it per 4 seconds.
2896 if (pAd
->Mlme
.OneSecPeriodicRound
% 4 == 0)
2898 if (pAd
->ate
.Channel
<= 14)
2901 bAutoTxAgc
= pAd
->bAutoTxAgcG
;
2902 TssiRef
= pAd
->TssiRefG
;
2903 pTssiMinusBoundary
= &pAd
->TssiMinusBoundaryG
[0];
2904 pTssiPlusBoundary
= &pAd
->TssiPlusBoundaryG
[0];
2905 TxAgcStep
= pAd
->TxAgcStepG
;
2906 pTxAgcCompensate
= &pAd
->TxAgcCompensateG
;
2911 bAutoTxAgc
= pAd
->bAutoTxAgcA
;
2912 TssiRef
= pAd
->TssiRefA
;
2913 pTssiMinusBoundary
= &pAd
->TssiMinusBoundaryA
[0];
2914 pTssiPlusBoundary
= &pAd
->TssiPlusBoundaryA
[0];
2915 TxAgcStep
= pAd
->TxAgcStepA
;
2916 pTxAgcCompensate
= &pAd
->TxAgcCompensateA
;
2921 /* BbpR49 is unsigned char */
2922 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R49
, &BbpR49
);
2924 /* (p) TssiPlusBoundaryG[0] = 0 = (m) TssiMinusBoundaryG[0] */
2925 /* compensate: +4 +3 +2 +1 0 -1 -2 -3 -4 * steps */
2926 /* step value is defined in pAd->TxAgcStepG for tx power value */
2928 /* [4]+1+[4] p4 p3 p2 p1 o1 m1 m2 m3 m4 */
2929 /* ex: 0x00 0x15 0x25 0x45 0x88 0xA0 0xB5 0xD0 0xF0
2930 above value are examined in mass factory production */
2931 /* [4] [3] [2] [1] [0] [1] [2] [3] [4] */
2933 /* plus is 0x10 ~ 0x40, minus is 0x60 ~ 0x90 */
2934 /* if value is between p1 ~ o1 or o1 ~ s1, no need to adjust tx power */
2935 /* if value is 0x65, tx power will be -= TxAgcStep*(2-1) */
2937 if (BbpR49
> pTssiMinusBoundary
[1])
2939 // Reading is larger than the reference value.
2940 // Check for how large we need to decrease the Tx power.
2941 for (idx
= 1; idx
< 5; idx
++)
2943 if (BbpR49
<= pTssiMinusBoundary
[idx
]) // Found the range
2946 // The index is the step we should decrease, idx = 0 means there is nothing to compensate
2947 // if (R3 > (ULONG) (TxAgcStep * (idx-1)))
2948 *pTxAgcCompensate
= -(TxAgcStep
* (idx
-1));
2950 // *pTxAgcCompensate = -((UCHAR)R3);
2952 DeltaPwr
+= (*pTxAgcCompensate
);
2953 ATEDBGPRINT(RT_DEBUG_TRACE
, ("-- Tx Power, BBP R1=%x, TssiRef=%x, TxAgcStep=%x, step = -%d\n",
2954 BbpR49
, TssiRef
, TxAgcStep
, idx
-1));
2956 else if (BbpR49
< pTssiPlusBoundary
[1])
2958 // Reading is smaller than the reference value
2959 // check for how large we need to increase the Tx power
2960 for (idx
= 1; idx
< 5; idx
++)
2962 if (BbpR49
>= pTssiPlusBoundary
[idx
]) // Found the range
2965 // The index is the step we should increase, idx = 0 means there is nothing to compensate
2966 *pTxAgcCompensate
= TxAgcStep
* (idx
-1);
2967 DeltaPwr
+= (*pTxAgcCompensate
);
2968 ATEDBGPRINT(RT_DEBUG_TRACE
, ("++ Tx Power, BBP R1=%x, TssiRef=%x, TxAgcStep=%x, step = +%d\n",
2969 BbpR49
, TssiRef
, TxAgcStep
, idx
-1));
2973 *pTxAgcCompensate
= 0;
2974 ATEDBGPRINT(RT_DEBUG_TRACE
, (" Tx Power, BBP R1=%x, TssiRef=%x, TxAgcStep=%x, step = +%d\n",
2975 BbpR49
, TssiRef
, TxAgcStep
, 0));
2981 if (pAd
->ate
.Channel
<= 14)
2983 bAutoTxAgc
= pAd
->bAutoTxAgcG
;
2984 pTxAgcCompensate
= &pAd
->TxAgcCompensateG
;
2988 bAutoTxAgc
= pAd
->bAutoTxAgcA
;
2989 pTxAgcCompensate
= &pAd
->TxAgcCompensateA
;
2993 DeltaPwr
+= (*pTxAgcCompensate
);
2996 /* calculate delta power based on the percentage specified from UI */
2997 // E2PROM setting is calibrated for maximum TX power (i.e. 100%)
2998 // We lower TX power here according to the percentage specified from UI
2999 if (pAd
->CommonCfg
.TxPowerPercentage
== 0xffffffff) // AUTO TX POWER control
3001 else if (pAd
->CommonCfg
.TxPowerPercentage
> 90) // 91 ~ 100% & AUTO, treat as 100% in terms of mW
3003 else if (pAd
->CommonCfg
.TxPowerPercentage
> 60) // 61 ~ 90%, treat as 75% in terms of mW
3007 else if (pAd
->CommonCfg
.TxPowerPercentage
> 30) // 31 ~ 60%, treat as 50% in terms of mW
3011 else if (pAd
->CommonCfg
.TxPowerPercentage
> 15) // 16 ~ 30%, treat as 25% in terms of mW
3015 else if (pAd
->CommonCfg
.TxPowerPercentage
> 9) // 10 ~ 15%, treat as 12.5% in terms of mW
3019 else // 0 ~ 9 %, treat as MIN(~3%) in terms of mW
3024 /* reset different new tx power for different TX rate */
3027 if (TxPwr
[i
] != 0xffffffff)
3031 Value
= (CHAR
)((TxPwr
[i
] >> j
*4) & 0x0F); /* 0 ~ 15 */
3033 if ((Value
+ DeltaPwr
) < 0)
3035 Value
= 0; /* min */
3037 else if ((Value
+ DeltaPwr
) > 0xF)
3039 Value
= 0xF; /* max */
3043 Value
+= DeltaPwr
; /* temperature compensation */
3046 /* fill new value to CSR offset */
3047 TxPwr
[i
] = (TxPwr
[i
] & ~(0x0000000F << j
*4)) | (Value
<< j
*4);
3050 /* write tx power value to CSR */
3051 /* TX_PWR_CFG_0 (8 tx rate) for TX power for OFDM 12M/18M
3052 TX power for OFDM 6M/9M
3053 TX power for CCK5.5M/11M
3054 TX power for CCK1M/2M */
3055 /* TX_PWR_CFG_1 ~ TX_PWR_CFG_4 */
3056 RTMP_IO_WRITE32(pAd
, TX_PWR_CFG_0
+ i
*4, TxPwr
[i
]);
3065 ========================================================================
3066 Routine Description:
3067 Write TxWI for ATE mode.
3071 ========================================================================
3075 static VOID
ATEWriteTxWI(
3076 IN PRTMP_ADAPTER pAd
,
3077 IN PTXWI_STRUC pTxWI
,
3079 IN BOOLEAN InsTimestamp
,
3082 IN BOOLEAN NSeq
, // HW new a sequence.
3090 IN HTTRANSMIT_SETTING Transmit
)
3093 // Always use Long preamble before verifiation short preamble functionality works well.
3094 // Todo: remove the following line if short preamble functionality works
3096 OPSTATUS_CLEAR_FLAG(pAd
, fOP_STATUS_SHORT_PREAMBLE_INUSED
);
3098 pTxWI
->TS
= InsTimestamp
;
3099 pTxWI
->AMPDU
= AMPDU
;
3101 pTxWI
->MIMOps
= PWR_ACTIVE
;
3102 pTxWI
->MpduDensity
= 4;
3104 pTxWI
->txop
= Txopmode
;
3106 pTxWI
->BAWinSize
= BASize
;
3108 pTxWI
->WirelessCliID
= WCID
;
3109 pTxWI
->MPDUtotalByteCount
= Length
;
3110 pTxWI
->PacketId
= PID
;
3112 pTxWI
->BW
= Transmit
.field
.BW
;
3113 pTxWI
->ShortGI
= Transmit
.field
.ShortGI
;
3114 pTxWI
->STBC
= Transmit
.field
.STBC
;
3116 pTxWI
->MCS
= Transmit
.field
.MCS
;
3117 pTxWI
->PHYMODE
= Transmit
.field
.MODE
;
3119 #ifdef DOT11_N_SUPPORT
3121 // MMPS is 802.11n features. Because TxWI->MCS > 7 must be HT mode,
3122 // so need not check if it's HT rate.
3124 if ((MIMOps
== MMPS_STATIC
) && (pTxWI
->MCS
> 7))
3127 if ((MIMOps
== MMPS_DYNAMIC
) && (pTxWI
->MCS
> 7)) // SMPS protect 2 spatial.
3129 #endif // DOT11_N_SUPPORT //
3131 pTxWI
->CFACK
= CfAck
;
3137 ========================================================================
3139 Routine Description:
3140 Disable protection for ATE.
3141 ========================================================================
3143 VOID
ATEDisableAsicProtect(
3144 IN PRTMP_ADAPTER pAd
)
3146 PROT_CFG_STRUC ProtCfg
, ProtCfg4
;
3152 // Config ASIC RTS threshold register
3153 RTMP_IO_READ32(pAd
, TX_RTS_CFG
, &MacReg
);
3154 MacReg
&= 0xFF0000FF;
3155 MacReg
|= (pAd
->CommonCfg
.RtsThreshold
<< 8);
3156 RTMP_IO_WRITE32(pAd
, TX_RTS_CFG
, MacReg
);
3158 // Initial common protection settings
3159 RTMPZeroMemory(Protect
, sizeof(Protect
));
3162 ProtCfg
.field
.TxopAllowGF40
= 1;
3163 ProtCfg
.field
.TxopAllowGF20
= 1;
3164 ProtCfg
.field
.TxopAllowMM40
= 1;
3165 ProtCfg
.field
.TxopAllowMM20
= 1;
3166 ProtCfg
.field
.TxopAllowOfdm
= 1;
3167 ProtCfg
.field
.TxopAllowCck
= 1;
3168 ProtCfg
.field
.RTSThEn
= 1;
3169 ProtCfg
.field
.ProtectNav
= ASIC_SHORTNAV
;
3171 // Handle legacy(B/G) protection
3172 ProtCfg
.field
.ProtectRate
= pAd
->CommonCfg
.RtsRate
;
3173 ProtCfg
.field
.ProtectCtrl
= 0;
3174 Protect
[0] = ProtCfg
.word
;
3175 Protect
[1] = ProtCfg
.word
;
3178 // 1.All STAs in the BSS are 20/40 MHz HT
3179 // 2. in ai 20/40MHz BSS
3180 // 3. all STAs are 20MHz in a 20MHz BSS
3181 // Pure HT. no protection.
3185 // PROT_TXOP(25:20) -- 010111
3186 // PROT_NAV(19:18) -- 01 (Short NAV protection)
3187 // PROT_CTRL(17:16) -- 00 (None)
3188 // PROT_RATE(15:0) -- 0x4004 (OFDM 24M)
3189 Protect
[2] = 0x01744004;
3193 // PROT_TXOP(25:20) -- 111111
3194 // PROT_NAV(19:18) -- 01 (Short NAV protection)
3195 // PROT_CTRL(17:16) -- 00 (None)
3196 // PROT_RATE(15:0) -- 0x4084 (duplicate OFDM 24M)
3197 Protect
[3] = 0x03f44084;
3201 // PROT_TXOP(25:20) -- 010111
3202 // PROT_NAV(19:18) -- 01 (Short NAV protection)
3203 // PROT_CTRL(17:16) -- 00 (None)
3204 // PROT_RATE(15:0) -- 0x4004 (OFDM 24M)
3205 Protect
[4] = 0x01744004;
3209 // PROT_TXOP(25:20) -- 111111
3210 // PROT_NAV(19:18) -- 01 (Short NAV protection)
3211 // PROT_CTRL(17:16) -- 00 (None)
3212 // PROT_RATE(15:0) -- 0x4084 (duplicate OFDM 24M)
3213 Protect
[5] = 0x03f44084;
3215 pAd
->CommonCfg
.IOTestParm
.bRTSLongProtOn
= FALSE
;
3217 offset
= CCK_PROT_CFG
;
3218 for (i
= 0;i
< 6;i
++)
3219 RTMP_IO_WRITE32(pAd
, offset
+ i
*4, Protect
[i
]);
3225 ========================================================================
3226 Routine Description:
3227 Write TxInfo for ATE mode.
3231 ========================================================================
3233 static VOID
ATEWriteTxInfo(
3234 IN PRTMP_ADAPTER pAd
,
3235 IN PTXINFO_STRUC pTxInfo
,
3236 IN USHORT USBDMApktLen
,
3242 pTxInfo
->USBDMATxPktLen
= USBDMApktLen
;
3243 pTxInfo
->QSEL
= QueueSel
;
3245 if (QueueSel
!= FIFO_EDCA
)
3246 ATEDBGPRINT(RT_DEBUG_TRACE
, ("=======> QueueSel != FIFO_EDCA<=======\n"));
3248 pTxInfo
->USBDMANextVLD
= NextValid
;
3249 pTxInfo
->USBDMATxburst
= TxBurst
;
3250 pTxInfo
->WIV
= bWiv
;
3251 pTxInfo
->SwUseLastRound
= 0;
3259 /* There are two ways to convert Rssi */
3262 // The way used with GET_LNA_GAIN().
3264 CHAR
ATEConvertToRssi(
3265 IN PRTMP_ADAPTER pAd
,
3267 IN UCHAR RssiNumber
)
3269 UCHAR RssiOffset
, LNAGain
;
3271 // Rssi equals to zero should be an invalid value
3275 LNAGain
= GET_LNA_GAIN(pAd
);
3276 if (pAd
->LatchRfRegs
.Channel
> 14)
3278 if (RssiNumber
== 0)
3279 RssiOffset
= pAd
->ARssiOffset0
;
3280 else if (RssiNumber
== 1)
3281 RssiOffset
= pAd
->ARssiOffset1
;
3283 RssiOffset
= pAd
->ARssiOffset2
;
3287 if (RssiNumber
== 0)
3288 RssiOffset
= pAd
->BGRssiOffset0
;
3289 else if (RssiNumber
== 1)
3290 RssiOffset
= pAd
->BGRssiOffset1
;
3292 RssiOffset
= pAd
->BGRssiOffset2
;
3295 return (-12 - RssiOffset
- LNAGain
- Rssi
);
3299 // The way originally used in ATE of rt2860ap.
3301 CHAR
ATEConvertToRssi(
3302 IN PRTMP_ADAPTER pAd
,
3304 IN UCHAR RssiNumber
)
3306 UCHAR RssiOffset
, LNAGain
;
3308 // Rssi equals to zero should be an invalid value
3312 if (pAd
->LatchRfRegs
.Channel
> 14)
3314 LNAGain
= pAd
->ALNAGain
;
3315 if (RssiNumber
== 0)
3316 RssiOffset
= pAd
->ARssiOffset0
;
3317 else if (RssiNumber
== 1)
3318 RssiOffset
= pAd
->ARssiOffset1
;
3320 RssiOffset
= pAd
->ARssiOffset2
;
3324 LNAGain
= pAd
->BLNAGain
;
3325 if (RssiNumber
== 0)
3326 RssiOffset
= pAd
->BGRssiOffset0
;
3327 else if (RssiNumber
== 1)
3328 RssiOffset
= pAd
->BGRssiOffset1
;
3330 RssiOffset
= pAd
->BGRssiOffset2
;
3333 return (-32 - RssiOffset
+ LNAGain
- Rssi
);
3335 #endif /* end of #if 1 */
3338 ========================================================================
3340 Routine Description:
3341 Set Japan filter coefficients if needed.
3343 This routine should only be called when
3344 entering TXFRAME mode or TXCONT mode.
3346 ========================================================================
3348 static VOID
SetJapanFilter(
3349 IN PRTMP_ADAPTER pAd
)
3354 // If Channel=14 and Bandwidth=20M and Mode=CCK, set BBP R4 bit5=1
3355 // (Japan Tx filter coefficients)when (TXFRAME or TXCONT).
3357 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R4
, &BbpData
);
3359 if ((pAd
->ate
.TxWI
.PHYMODE
== MODE_CCK
) && (pAd
->ate
.Channel
== 14) && (pAd
->ate
.TxWI
.BW
== BW_20
))
3361 BbpData
|= 0x20; // turn on
3362 ATEDBGPRINT(RT_DEBUG_TRACE
, ("SetJapanFilter!!!\n"));
3366 BbpData
&= 0xdf; // turn off
3367 ATEDBGPRINT(RT_DEBUG_TRACE
, ("ClearJapanFilter!!!\n"));
3370 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R4
, BbpData
);
3374 IN PRTMP_ADAPTER pAd
,
3375 IN PRXWI_STRUC pRxWI
)
3377 /* There are two ways to collect RSSI. */
3379 //pAd->LastRxRate = (USHORT)((pRxWI->MCS) + (pRxWI->BW <<7) + (pRxWI->ShortGI <<8)+ (pRxWI->PHYMODE <<14)) ;
3380 if (pRxWI
->RSSI0
!= 0)
3382 pAd
->ate
.LastRssi0
= ATEConvertToRssi(pAd
, (CHAR
) pRxWI
->RSSI0
, RSSI_0
);
3383 pAd
->ate
.AvgRssi0X8
= (pAd
->ate
.AvgRssi0X8
- pAd
->ate
.AvgRssi0
) + pAd
->ate
.LastRssi0
;
3384 pAd
->ate
.AvgRssi0
= pAd
->ate
.AvgRssi0X8
>> 3;
3386 if (pRxWI
->RSSI1
!= 0)
3388 pAd
->ate
.LastRssi1
= ATEConvertToRssi(pAd
, (CHAR
) pRxWI
->RSSI1
, RSSI_1
);
3389 pAd
->ate
.AvgRssi1X8
= (pAd
->ate
.AvgRssi1X8
- pAd
->ate
.AvgRssi1
) + pAd
->ate
.LastRssi1
;
3390 pAd
->ate
.AvgRssi1
= pAd
->ate
.AvgRssi1X8
>> 3;
3392 if (pRxWI
->RSSI2
!= 0)
3394 pAd
->ate
.LastRssi2
= ATEConvertToRssi(pAd
, (CHAR
) pRxWI
->RSSI2
, RSSI_2
);
3395 pAd
->ate
.AvgRssi2X8
= (pAd
->ate
.AvgRssi2X8
- pAd
->ate
.AvgRssi2
) + pAd
->ate
.LastRssi2
;
3396 pAd
->ate
.AvgRssi2
= pAd
->ate
.AvgRssi2X8
>> 3;
3399 pAd
->ate
.LastSNR0
= (CHAR
)(pRxWI
->SNR0
);// CHAR ==> UCHAR ?
3400 pAd
->ate
.LastSNR1
= (CHAR
)(pRxWI
->SNR1
);// CHAR ==> UCHAR ?
3402 pAd
->ate
.NumOfAvgRssiSample
++;
3404 pAd
->ate
.LastSNR0
= (CHAR
)(pRxWI
->SNR0
);
3405 pAd
->ate
.LastSNR1
= (CHAR
)(pRxWI
->SNR1
);
3406 pAd
->ate
.RxCntPerSec
++;
3407 pAd
->ate
.LastRssi0
= ATEConvertToRssi(pAd
, (CHAR
) pRxWI
->RSSI0
, RSSI_0
);
3408 pAd
->ate
.LastRssi1
= ATEConvertToRssi(pAd
, (CHAR
) pRxWI
->RSSI1
, RSSI_1
);
3409 pAd
->ate
.LastRssi2
= ATEConvertToRssi(pAd
, (CHAR
) pRxWI
->RSSI2
, RSSI_2
);
3410 pAd
->ate
.AvgRssi0X8
= (pAd
->ate
.AvgRssi0X8
- pAd
->ate
.AvgRssi0
) + pAd
->ate
.LastRssi0
;
3411 pAd
->ate
.AvgRssi0
= pAd
->ate
.AvgRssi0X8
>> 3;
3412 pAd
->ate
.AvgRssi1X8
= (pAd
->ate
.AvgRssi1X8
- pAd
->ate
.AvgRssi1
) + pAd
->ate
.LastRssi1
;
3413 pAd
->ate
.AvgRssi1
= pAd
->ate
.AvgRssi1X8
>> 3;
3414 pAd
->ate
.AvgRssi2X8
= (pAd
->ate
.AvgRssi2X8
- pAd
->ate
.AvgRssi2
) + pAd
->ate
.LastRssi2
;
3415 pAd
->ate
.AvgRssi2
= pAd
->ate
.AvgRssi2X8
>> 3;
3416 pAd
->ate
.NumOfAvgRssiSample
++;
3420 #ifdef CONFIG_STA_SUPPORT
3421 VOID
RTMPStationStop(
3422 IN PRTMP_ADAPTER pAd
)
3424 // BOOLEAN Cancelled;
3426 ATEDBGPRINT(RT_DEBUG_TRACE
, ("==> RTMPStationStop\n"));
3429 RTMPCancelTimer(&pAd
->MlmeAux
.AssocTimer
, &Cancelled
);
3430 RTMPCancelTimer(&pAd
->MlmeAux
.ReassocTimer
, &Cancelled
);
3431 RTMPCancelTimer(&pAd
->MlmeAux
.DisassocTimer
, &Cancelled
);
3432 RTMPCancelTimer(&pAd
->MlmeAux
.AuthTimer
, &Cancelled
);
3433 RTMPCancelTimer(&pAd
->MlmeAux
.BeaconTimer
, &Cancelled
);
3434 RTMPCancelTimer(&pAd
->MlmeAux
.ScanTimer
, &Cancelled
);
3436 // For rx statistics, we need to keep this timer running.
3437 // RTMPCancelTimer(&pAd->Mlme.PeriodicTimer, &Cancelled);
3439 ATEDBGPRINT(RT_DEBUG_TRACE
, ("<== RTMPStationStop\n"));
3442 VOID
RTMPStationStart(
3443 IN PRTMP_ADAPTER pAd
)
3445 ATEDBGPRINT(RT_DEBUG_TRACE
, ("==> RTMPStationStart\n"));
3446 ATEDBGPRINT(RT_DEBUG_TRACE
, ("<== RTMPStationStart\n"));
3448 #endif // CONFIG_STA_SUPPORT //
3451 ==========================================================================
3455 This routine should only be used in ATE mode.
3456 ==========================================================================
3460 /*======================Start of RT2870======================*/
3463 static INT
ATESetUpFrame(
3464 IN PRTMP_ADAPTER pAd
,
3468 PTX_CONTEXT pNullContext
;
3470 HTTRANSMIT_SETTING TxHTPhyMode
;
3472 PTXINFO_STRUC pTxInfo
;
3473 UINT32 TransferBufferLength
, OrgBufferLength
= 0;
3475 #ifdef RALINK_28xx_QA
3476 PHEADER_802_11 pHeader80211
= NULL
;
3477 #endif // RALINK_28xx_QA //
3479 if ((RTMP_TEST_FLAG(pAd
, fRTMP_ADAPTER_RESET_IN_PROGRESS
)) ||
3480 (RTMP_TEST_FLAG(pAd
, fRTMP_ADAPTER_BULKOUT_RESET
)) ||
3481 (RTMP_TEST_FLAG(pAd
, fRTMP_ADAPTER_HALT_IN_PROGRESS
)) ||
3482 (RTMP_TEST_FLAG(pAd
, fRTMP_ADAPTER_NIC_NOT_EXIST
)))
3487 /* We always use QID_AC_BE and FIFO_EDCA in ATE mode. */
3489 pNullContext
= &(pAd
->NullContext
);
3490 ASSERT(pNullContext
!= NULL
);
3492 if (pNullContext
->InUse
== FALSE
)
3494 // Set the in use bit
3495 pNullContext
->InUse
= TRUE
;
3496 NdisZeroMemory(&(pAd
->NullFrame
), sizeof(HEADER_802_11
));
3498 // Fill 802.11 header.
3499 #ifdef RALINK_28xx_QA
3500 if (pAd
->ate
.bQATxStart
== TRUE
)
3502 pHeader80211
= NdisMoveMemory(&(pAd
->NullFrame
), pAd
->ate
.Header
, pAd
->ate
.HLen
);
3503 // pDest = NdisMoveMemory(&(pAd->NullFrame), pAd->ate.Header, pAd->ate.HLen);
3504 // pHeader80211 = (PHEADER_802_11)pDest;
3507 #endif // RALINK_28xx_QA //
3509 // Fill 802.11 header.
3510 NdisMoveMemory(&(pAd
->NullFrame
), TemplateFrame
, sizeof(HEADER_802_11
));
3512 #ifdef RT_BIG_ENDIAN
3513 RTMPFrameEndianChange(pAd
, (PUCHAR
)&(pAd
->NullFrame
), DIR_READ
, FALSE
);
3514 #endif // RT_BIG_ENDIAN //
3516 #ifdef RALINK_28xx_QA
3517 if (pAd
->ate
.bQATxStart
== TRUE
)
3519 /* modify sequence number.... */
3520 if (pAd
->ate
.TxDoneCount
== 0)
3522 pAd
->ate
.seq
= pHeader80211
->Sequence
;
3526 pHeader80211
->Sequence
= ++pAd
->ate
.seq
;
3528 /* We already got all the addr. fields from QA GUI. */
3531 #endif // RALINK_28xx_QA //
3533 COPY_MAC_ADDR(pAd
->NullFrame
.Addr1
, pAd
->ate
.Addr1
);
3534 COPY_MAC_ADDR(pAd
->NullFrame
.Addr2
, pAd
->ate
.Addr2
);
3535 COPY_MAC_ADDR(pAd
->NullFrame
.Addr3
, pAd
->ate
.Addr3
);
3538 RTMPZeroMemory(&pAd
->NullContext
.TransferBuffer
->field
.WirelessPacket
[0], TX_BUFFER_NORMSIZE
);//???
3539 pTxInfo
= (PTXINFO_STRUC
)&pAd
->NullContext
.TransferBuffer
->field
.WirelessPacket
[0];
3541 #ifdef RALINK_28xx_QA
3542 if (pAd
->ate
.bQATxStart
== TRUE
)
3544 // Avoid to exceed the range of WirelessPacket[].
3545 ASSERT(pAd
->ate
.TxInfo
.USBDMATxPktLen
<= (MAX_FRAME_SIZE
- 34/* == 2312 */));
3546 NdisMoveMemory(pTxInfo
, &(pAd
->ate
.TxInfo
), sizeof(pAd
->ate
.TxInfo
));
3549 #endif // RALINK_28xx_QA //
3551 // Avoid to exceed the range of WirelessPacket[].
3552 ASSERT(pAd
->ate
.TxLength
<= (MAX_FRAME_SIZE
- 34/* == 2312 */));
3554 // pTxInfo->USBDMATxPktLen will be updated to include padding later.
3555 ATEWriteTxInfo(pAd
, pTxInfo
, (USHORT
)(TXWI_SIZE
+ pAd
->ate
.TxLength
), TRUE
, EpToQueue
[MGMTPIPEIDX
], FALSE
, FALSE
);
3556 pTxInfo
->QSEL
= FIFO_EDCA
;
3559 pTxWI
= (PTXWI_STRUC
)&pAd
->NullContext
.TransferBuffer
->field
.WirelessPacket
[TXINFO_SIZE
];
3562 if (pAd
->ate
.bQATxStart
== TRUE
)
3564 TxHTPhyMode
.field
.BW
= pAd
->ate
.TxWI
.BW
;
3565 TxHTPhyMode
.field
.ShortGI
= pAd
->ate
.TxWI
.ShortGI
;
3566 TxHTPhyMode
.field
.STBC
= pAd
->ate
.TxWI
.STBC
;
3567 TxHTPhyMode
.field
.MCS
= pAd
->ate
.TxWI
.MCS
;
3568 TxHTPhyMode
.field
.MODE
= pAd
->ate
.TxWI
.PHYMODE
;
3569 ATEWriteTxWI(pAd
, pTxWI
, pAd
->ate
.TxWI
.FRAG
, pAd
->ate
.TxWI
.TS
, pAd
->ate
.TxWI
.AMPDU
, pAd
->ate
.TxWI
.ACK
, pAd
->ate
.TxWI
.NSEQ
,
3570 pAd
->ate
.TxWI
.BAWinSize
, BSSID_WCID
, pAd
->ate
.TxWI
.MPDUtotalByteCount
/* include 802.11 header */, pAd
->ate
.TxWI
.PacketId
, 0, pAd
->ate
.TxWI
.txop
/*IFS_HTTXOP*/, pAd
->ate
.TxWI
.CFACK
/*FALSE*/, TxHTPhyMode
);
3574 TxHTPhyMode
.field
.BW
= pAd
->ate
.TxWI
.BW
;
3575 TxHTPhyMode
.field
.ShortGI
= pAd
->ate
.TxWI
.ShortGI
;
3576 TxHTPhyMode
.field
.STBC
= 0;
3577 TxHTPhyMode
.field
.MCS
= pAd
->ate
.TxWI
.MCS
;
3578 TxHTPhyMode
.field
.MODE
= pAd
->ate
.TxWI
.PHYMODE
;
3580 ATEWriteTxWI(pAd
, pTxWI
, FALSE
, FALSE
, FALSE
, FALSE
/* No ack required. */, FALSE
, 0, BSSID_WCID
, pAd
->ate
.TxLength
,
3581 0, 0, IFS_HTTXOP
, FALSE
, TxHTPhyMode
);// "MMPS_STATIC" instead of "MMPS_DYNAMIC" ???
3584 RTMPMoveMemory(&pAd
->NullContext
.TransferBuffer
->field
.WirelessPacket
[TXINFO_SIZE
+TXWI_SIZE
], &pAd
->NullFrame
, sizeof(HEADER_802_11
));
3586 pDest
= &(pAd
->NullContext
.TransferBuffer
->field
.WirelessPacket
[TXINFO_SIZE
+TXWI_SIZE
+sizeof(HEADER_802_11
)]);
3588 // Prepare frame payload
3589 #ifdef RALINK_28xx_QA
3590 if (pAd
->ate
.bQATxStart
== TRUE
)
3593 if ((pAd
->ate
.PLen
!= 0))
3595 for (j
= 0; j
< pAd
->ate
.DLen
; j
+=pAd
->ate
.PLen
)
3597 RTMPMoveMemory(pDest
, pAd
->ate
.Pattern
, pAd
->ate
.PLen
);
3598 pDest
+= pAd
->ate
.PLen
;
3601 TransferBufferLength
= TXINFO_SIZE
+ TXWI_SIZE
+ pAd
->ate
.TxWI
.MPDUtotalByteCount
;
3604 #endif // RALINK_28xx_QA //
3606 for (j
= 0; j
< (pAd
->ate
.TxLength
- sizeof(HEADER_802_11
)); j
++)
3611 TransferBufferLength
= TXINFO_SIZE
+ TXWI_SIZE
+ pAd
->ate
.TxLength
;
3615 OrgBufferLength
= TransferBufferLength
;
3616 TransferBufferLength
= (TransferBufferLength
+ 3) & (~3);
3618 // Always add 4 extra bytes at every packet.
3619 padLen
= TransferBufferLength
- OrgBufferLength
+ 4;/* 4 == last packet padding */
3620 ASSERT((padLen
<= (RTMP_PKT_TAIL_PADDING
- 4/* 4 == MaxBulkOutsize alignment padding */)));
3622 /* Now memzero all extra padding bytes. */
3623 NdisZeroMemory(pDest
, padLen
);
3626 if ((TransferBufferLength
% 4) == 1)
3628 NdisZeroMemory(pDest
, 7);
3630 TransferBufferLength
+= 3;
3632 else if ((TransferBufferLength
% 4) == 2)
3634 NdisZeroMemory(pDest
, 6);
3636 TransferBufferLength
+= 2;
3638 else if ((TransferBufferLength
% 4) == 3)
3640 NdisZeroMemory(pDest
, 5);
3642 TransferBufferLength
+= 1;
3646 // Update pTxInfo->USBDMATxPktLen to include padding.
3647 pTxInfo
->USBDMATxPktLen
= TransferBufferLength
- TXINFO_SIZE
;
3649 TransferBufferLength
+= 4;
3651 // If TransferBufferLength is multiple of 64, add extra 4 bytes again.
3652 if ((TransferBufferLength
% pAd
->BulkOutMaxPacketSize
) == 0)
3654 NdisZeroMemory(pDest
, 4);
3655 TransferBufferLength
+= 4;
3658 // Fill out frame length information for global Bulk out arbitor
3659 pAd
->NullContext
.BulkOutSize
= TransferBufferLength
;
3661 #ifdef RT_BIG_ENDIAN
3662 RTMPWIEndianChange((PUCHAR
)pTxWI
, TYPE_TXWI
);
3663 RTMPFrameEndianChange(pAd
, (((PUCHAR
)pTxInfo
)+TXWI_SIZE
+TXINFO_SIZE
), DIR_WRITE
, FALSE
);
3664 RTMPDescriptorEndianChange((PUCHAR
)pTxInfo
, TYPE_TXINFO
);
3665 #endif // RT_BIG_ENDIAN //
3669 VOID
ATE_RTUSBBulkOutDataPacketComplete(purbb_t pUrb
, struct pt_regs
*pt_regs
)
3672 PTX_CONTEXT pNullContext
;
3673 UCHAR BulkOutPipeId
;
3675 unsigned long IrqFlags
;
3678 pNullContext
= (PTX_CONTEXT
)pUrb
->context
;
3679 pAd
= pNullContext
->pAd
;
3682 // Reset Null frame context flags
3683 pNullContext
->IRPPending
= FALSE
;
3684 pNullContext
->InUse
= FALSE
;
3685 Status
= pUrb
->status
;
3687 // Store BulkOut PipeId
3688 BulkOutPipeId
= pNullContext
->BulkOutPipeId
;
3689 pAd
->BulkOutDataOneSecCount
++;
3691 if (Status
== USB_ST_NOERROR
)
3693 #ifdef RALINK_28xx_QA
3694 if ((ATE_ON(pAd
)) && (pAd
->ate
.bQATxStart
== TRUE
))
3696 if (pAd
->ate
.QID
== BulkOutPipeId
)
3698 // Let Rx can have a chance to break in during Tx process,
3699 // especially for loopback mode in QA ATE.
3700 // To trade off between tx performance and loopback mode integrity.
3701 /* Q : Now Rx is handled by tasklet, do we still need this delay ? */
3702 /* Ans : Even tasklet is used, Rx/Tx < 1 if we do not delay for a while right here. */
3704 pAd
->ate
.TxDoneCount
++;
3705 pAd
->RalinkCounters
.KickTxCount
++;
3706 ASSERT(pAd
->ate
.QID
== 0);
3710 #endif // RALINK_28xx_QA //
3711 pAd
->BulkOutComplete
++;
3713 pAd
->Counters8023
.GoodTransmits
++;
3715 /* Don't worry about the queue is empty or not. This function will check itself. */
3716 RTMPDeQueuePacket(pAd
, TRUE
, BulkOutPipeId
, MAX_TX_PROCESS
);
3718 /* In 28xx, SendTxWaitQueue ==> TxSwQueue */
3720 if (pAd->SendTxWaitQueue[BulkOutPipeId].Number > 0)
3722 RTMPDeQueuePacket(pAd, BulkOutPipeId);
3726 else // STATUS_OTHER
3728 pAd
->BulkOutCompleteOther
++;
3730 ATEDBGPRINT(RT_DEBUG_ERROR
, ("BulkOutDataPacket Failed STATUS_OTHER = 0x%x . \n", Status
));
3731 ATEDBGPRINT(RT_DEBUG_ERROR
, (">>BulkOutReq=0x%lx, BulkOutComplete=0x%lx\n", pAd
->BulkOutReq
, pAd
->BulkOutComplete
));
3733 if ((!RTMP_TEST_FLAG(pAd
, fRTMP_ADAPTER_RESET_IN_PROGRESS
)) &&
3734 (!RTMP_TEST_FLAG(pAd
, fRTMP_ADAPTER_HALT_IN_PROGRESS
)) &&
3735 (!RTMP_TEST_FLAG(pAd
, fRTMP_ADAPTER_NIC_NOT_EXIST
)) &&
3736 (!RTMP_TEST_FLAG(pAd
, fRTMP_ADAPTER_BULKOUT_RESET
)))
3738 RTMP_SET_FLAG(pAd
, fRTMP_ADAPTER_BULKOUT_RESET
);
3739 /* In 28xx, RT_OID_USB_RESET_BULK_OUT ==> CMDTHREAD_RESET_BULK_OUT */
3740 RTUSBEnqueueInternalCmd(pAd
, CMDTHREAD_RESET_BULK_OUT
, NULL
, 0);
3742 BULK_OUT_LOCK(&pAd
->BulkOutLock
[BulkOutPipeId
], IrqFlags
);
3743 pAd
->BulkOutPending
[BulkOutPipeId
] = FALSE
;
3744 pAd
->bulkResetPipeid
= BulkOutPipeId
;
3745 BULK_OUT_UNLOCK(&pAd
->BulkOutLock
[BulkOutPipeId
], IrqFlags
);
3752 if (atomic_read(&pAd
->BulkOutRemained
) > 0)
3754 atomic_dec(&pAd
->BulkOutRemained
);
3757 // 1st - Transmit Success
3758 OldValue
= pAd
->WlanCounters
.TransmittedFragmentCount
.u
.LowPart
;
3759 pAd
->WlanCounters
.TransmittedFragmentCount
.u
.LowPart
++;
3761 if (pAd
->WlanCounters
.TransmittedFragmentCount
.u
.LowPart
< OldValue
)
3763 pAd
->WlanCounters
.TransmittedFragmentCount
.u
.HighPart
++;
3766 if(((pAd
->ContinBulkOut
== TRUE
) ||(atomic_read(&pAd
->BulkOutRemained
) > 0)) && (pAd
->ate
.Mode
& ATE_TXFRAME
))
3768 RTUSB_SET_BULK_FLAG(pAd
, fRTUSB_BULK_OUT_DATA_ATE
);
3772 RTUSB_CLEAR_BULK_FLAG(pAd
, fRTUSB_BULK_OUT_DATA_ATE
);
3773 #ifdef RALINK_28xx_QA
3774 pAd
->ate
.TxStatus
= 0;
3775 #endif // RALINK_28xx_QA //
3778 BULK_OUT_LOCK(&pAd
->BulkOutLock
[BulkOutPipeId
], IrqFlags
);
3779 pAd
->BulkOutPending
[BulkOutPipeId
] = FALSE
;
3780 BULK_OUT_UNLOCK(&pAd
->BulkOutLock
[BulkOutPipeId
], IrqFlags
);
3782 // Always call Bulk routine, even reset bulk.
3783 // The protection of rest bulk should be in BulkOut routine.
3784 RTUSBKickBulkOut(pAd
);
3788 ========================================================================
3790 Routine Description:
3798 ========================================================================
3800 VOID
ATE_RTUSBBulkOutDataPacket(
3801 IN PRTMP_ADAPTER pAd
,
3802 IN UCHAR BulkOutPipeId
)
3804 PTX_CONTEXT pNullContext
= &(pAd
->NullContext
);
3807 unsigned long IrqFlags
;
3810 ASSERT(BulkOutPipeId
== 0);
3812 /* Build up the frame first. */
3813 // ATESetUpFrame(pAd, 0);
3815 BULK_OUT_LOCK(&pAd
->BulkOutLock
[BulkOutPipeId
], IrqFlags
);
3817 if (pAd
->BulkOutPending
[BulkOutPipeId
] == TRUE
)
3819 BULK_OUT_UNLOCK(&pAd
->BulkOutLock
[BulkOutPipeId
], IrqFlags
);
3823 pAd
->BulkOutPending
[BulkOutPipeId
] = TRUE
;
3824 BULK_OUT_UNLOCK(&pAd
->BulkOutLock
[BulkOutPipeId
], IrqFlags
);
3826 // Increase Total transmit byte counter
3827 pAd
->RalinkCounters
.OneSecTransmittedByteCount
+= pNullContext
->BulkOutSize
;
3828 pAd
->RalinkCounters
.TransmittedByteCount
+= pNullContext
->BulkOutSize
;
3830 // Clear ATE frame bulk out flag
3831 RTUSB_CLEAR_BULK_FLAG(pAd
, fRTUSB_BULK_OUT_DATA_ATE
);
3833 // Init Tx context descriptor
3834 pNullContext
->IRPPending
= TRUE
;
3835 RTUSBInitTxDesc(pAd
, pNullContext
, BulkOutPipeId
, (usb_complete_t
)ATE_RTUSBBulkOutDataPacketComplete
);
3836 pUrb
= pNullContext
->pUrb
;
3838 if((ret
= RTUSB_SUBMIT_URB(pUrb
))!=0)
3840 ATEDBGPRINT(RT_DEBUG_ERROR
, ("ATE_RTUSBBulkOutDataPacket: Submit Tx URB failed %d\n", ret
));
3850 ========================================================================
3852 Routine Description:
3860 ========================================================================
3862 VOID
ATE_RTUSBCancelPendingBulkInIRP(
3863 IN PRTMP_ADAPTER pAd
)
3865 PRX_CONTEXT pRxContext
;
3868 ATEDBGPRINT(RT_DEBUG_TRACE
, ("--->ATE_RTUSBCancelPendingBulkInIRP\n"));
3870 for ( i
= 0; i
< (RX_RING_SIZE
); i
++)
3872 pRxContext
= &(pAd
->RxContext
[i
]);
3873 if(pRxContext
->IRPPending
== TRUE
)
3875 RTUSB_UNLINK_URB(pRxContext
->pUrb
);
3876 pRxContext
->IRPPending
= FALSE
;
3877 pRxContext
->InUse
= FALSE
;
3878 //NdisInterlockedDecrement(&pAd->PendingRx);
3883 for ( i
= 0; i
< (RX_RING_SIZE
); i
++)
3885 pRxContext
= &(pAd
->RxContext
[i
]);
3886 if(atomic_read(&pRxContext
->IrpLock
) == IRPLOCK_CANCELABLE
)
3888 RTUSB_UNLINK_URB(pRxContext
->pUrb
);
3890 InterlockedExchange(&pRxContext
->IrpLock
, IRPLOCK_CANCE_START
);
3893 ATEDBGPRINT(RT_DEBUG_TRACE
, ("<---ATE_RTUSBCancelPendingBulkInIRP\n"));
3898 VOID
rt_ee_read_all(PRTMP_ADAPTER pAd
, USHORT
*Data
)
3903 for (i
= 0 ; i
< EEPROM_SIZE
/2 ; )
3905 /* "value" is expecially for some compilers... */
3906 RT28xx_EEPROM_READ16(pAd
, i
*2, value
);
3912 VOID
rt_ee_write_all(PRTMP_ADAPTER pAd
, USHORT
*Data
)
3917 for (i
= 0 ; i
< EEPROM_SIZE
/2 ; )
3919 /* "value" is expecially for some compilers... */
3921 RT28xx_EEPROM_WRITE16(pAd
, i
*2, value
);
3925 #ifdef RALINK_28xx_QA
3926 VOID
ATE_QA_Statistics(
3927 IN PRTMP_ADAPTER pAd
,
3928 IN PRXWI_STRUC pRxWI
,
3929 IN PRT28XX_RXD_STRUC pRxD
,
3930 IN PHEADER_802_11 pHeader
)
3932 // update counter first
3933 if (pHeader
!= NULL
)
3935 if (pHeader
->FC
.Type
== BTYPE_DATA
)
3940 pAd
->ate
.OtherData
++;
3942 else if (pHeader
->FC
.Type
== BTYPE_MGMT
)
3944 if (pHeader
->FC
.SubType
== SUBTYPE_BEACON
)
3947 pAd
->ate
.OtherCount
++;
3949 else if (pHeader
->FC
.Type
== BTYPE_CNTL
)
3951 pAd
->ate
.OtherCount
++;
3954 pAd
->ate
.RSSI0
= pRxWI
->RSSI0
;
3955 pAd
->ate
.RSSI1
= pRxWI
->RSSI1
;
3956 pAd
->ate
.RSSI2
= pRxWI
->RSSI2
;
3957 pAd
->ate
.SNR0
= pRxWI
->SNR0
;
3958 pAd
->ate
.SNR1
= pRxWI
->SNR1
;
3961 /* command id with Cmd Type == 0x0008(for 28xx)/0x0005(for iNIC) */
3962 #define RACFG_CMD_RF_WRITE_ALL 0x0000
3963 #define RACFG_CMD_E2PROM_READ16 0x0001
3964 #define RACFG_CMD_E2PROM_WRITE16 0x0002
3965 #define RACFG_CMD_E2PROM_READ_ALL 0x0003
3966 #define RACFG_CMD_E2PROM_WRITE_ALL 0x0004
3967 #define RACFG_CMD_IO_READ 0x0005
3968 #define RACFG_CMD_IO_WRITE 0x0006
3969 #define RACFG_CMD_IO_READ_BULK 0x0007
3970 #define RACFG_CMD_BBP_READ8 0x0008
3971 #define RACFG_CMD_BBP_WRITE8 0x0009
3972 #define RACFG_CMD_BBP_READ_ALL 0x000a
3973 #define RACFG_CMD_GET_COUNTER 0x000b
3974 #define RACFG_CMD_CLEAR_COUNTER 0x000c
3976 #define RACFG_CMD_RSV1 0x000d
3977 #define RACFG_CMD_RSV2 0x000e
3978 #define RACFG_CMD_RSV3 0x000f
3980 #define RACFG_CMD_TX_START 0x0010
3981 #define RACFG_CMD_GET_TX_STATUS 0x0011
3982 #define RACFG_CMD_TX_STOP 0x0012
3983 #define RACFG_CMD_RX_START 0x0013
3984 #define RACFG_CMD_RX_STOP 0x0014
3985 #define RACFG_CMD_GET_NOISE_LEVEL 0x0015
3987 #define RACFG_CMD_ATE_START 0x0080
3988 #define RACFG_CMD_ATE_STOP 0x0081
3990 #define RACFG_CMD_ATE_START_TX_CARRIER 0x0100
3991 #define RACFG_CMD_ATE_START_TX_CONT 0x0101
3992 #define RACFG_CMD_ATE_START_TX_FRAME 0x0102
3993 #define RACFG_CMD_ATE_SET_BW 0x0103
3994 #define RACFG_CMD_ATE_SET_TX_POWER0 0x0104
3995 #define RACFG_CMD_ATE_SET_TX_POWER1 0x0105
3996 #define RACFG_CMD_ATE_SET_FREQ_OFFSET 0x0106
3997 #define RACFG_CMD_ATE_GET_STATISTICS 0x0107
3998 #define RACFG_CMD_ATE_RESET_COUNTER 0x0108
3999 #define RACFG_CMD_ATE_SEL_TX_ANTENNA 0x0109
4000 #define RACFG_CMD_ATE_SEL_RX_ANTENNA 0x010a
4001 #define RACFG_CMD_ATE_SET_PREAMBLE 0x010b
4002 #define RACFG_CMD_ATE_SET_CHANNEL 0x010c
4003 #define RACFG_CMD_ATE_SET_ADDR1 0x010d
4004 #define RACFG_CMD_ATE_SET_ADDR2 0x010e
4005 #define RACFG_CMD_ATE_SET_ADDR3 0x010f
4006 #define RACFG_CMD_ATE_SET_RATE 0x0110
4007 #define RACFG_CMD_ATE_SET_TX_FRAME_LEN 0x0111
4008 #define RACFG_CMD_ATE_SET_TX_FRAME_COUNT 0x0112
4009 #define RACFG_CMD_ATE_START_RX_FRAME 0x0113
4010 #define RACFG_CMD_ATE_E2PROM_READ_BULK 0x0114
4011 #define RACFG_CMD_ATE_E2PROM_WRITE_BULK 0x0115
4012 #define RACFG_CMD_ATE_IO_WRITE_BULK 0x0116
4013 #define RACFG_CMD_ATE_BBP_READ_BULK 0x0117
4014 #define RACFG_CMD_ATE_BBP_WRITE_BULK 0x0118
4015 #define RACFG_CMD_ATE_RF_READ_BULK 0x0119
4016 #define RACFG_CMD_ATE_RF_WRITE_BULK 0x011a
4020 #define A2Hex(_X, _p) \
4025 while (((*p >= 'a') && (*p <= 'f')) || ((*p >= 'A') && (*p <= 'F')) || ((*p >= '0') && (*p <= '9'))) \
4027 if ((*p >= 'a') && (*p <= 'f')) \
4028 _X = _X * 16 + *p - 87; \
4029 else if ((*p >= 'A') && (*p <= 'F')) \
4030 _X = _X * 16 + *p - 55; \
4031 else if ((*p >= '0') && (*p <= '9')) \
4032 _X = _X * 16 + *p - 48; \
4038 static VOID
memcpy_exl(PRTMP_ADAPTER pAd
, UCHAR
*dst
, UCHAR
*src
, ULONG len
);
4039 static VOID
memcpy_exs(PRTMP_ADAPTER pAd
, UCHAR
*dst
, UCHAR
*src
, ULONG len
);
4040 static VOID
RTMP_IO_READ_BULK(PRTMP_ADAPTER pAd
, UCHAR
*dst
, UCHAR
*src
, UINT32 len
);
4043 int ate_copy_to_user(
4048 memmove(payload
, msg
, len
);
4053 #define copy_to_user(x,y,z) ate_copy_to_user((PUCHAR)x, (PUCHAR)y, z)
4056 #define LEN_OF_ARG 16
4059 IN PRTMP_ADAPTER pAdapter
,
4060 IN
struct iwreq
*wrq
)
4062 unsigned short Command_Id
;
4063 struct ate_racfghdr
*pRaCfg
;
4064 INT Status
= NDIS_STATUS_SUCCESS
;
4068 if((pRaCfg
= kmalloc(sizeof(struct ate_racfghdr
), GFP_KERNEL
)) == NULL
)
4074 NdisZeroMemory(pRaCfg
, sizeof(struct ate_racfghdr
));
4076 if (copy_from_user((PUCHAR
)pRaCfg
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
))
4084 Command_Id
= ntohs(pRaCfg
->command_id
);
4086 ATEDBGPRINT(RT_DEBUG_TRACE
,("\n%s: Command_Id = 0x%04x !\n", __func__
, Command_Id
));
4090 // We will get this command when QA starts.
4091 case RACFG_CMD_ATE_START
:
4093 ATEDBGPRINT(RT_DEBUG_TRACE
,("RACFG_CMD_ATE_START\n"));
4095 // prepare feedback as soon as we can to avoid QA timeout.
4096 pRaCfg
->length
= htons(2);
4097 pRaCfg
->status
= htons(0);
4099 wrq
->u
.data
.length
= sizeof(pRaCfg
->magic_no
) + sizeof(pRaCfg
->command_type
)
4100 + sizeof(pRaCfg
->command_id
) + sizeof(pRaCfg
->length
)
4101 + sizeof(pRaCfg
->sequence
) + ntohs(pRaCfg
->length
);
4103 ATEDBGPRINT(RT_DEBUG_TRACE
, ("wrq->u.data.length = %d\n", wrq
->u
.data
.length
));
4105 if (copy_to_user(wrq
->u
.data
.pointer
, pRaCfg
, wrq
->u
.data
.length
))
4107 ATEDBGPRINT(RT_DEBUG_TRACE
, ("copy_to_user() fail in case RACFG_CMD_ATE_START\n"));
4112 ATEDBGPRINT(RT_DEBUG_TRACE
, ("RACFG_CMD_ATE_START is done !\n"));
4114 Set_ATE_Proc(pAdapter
, "ATESTART");
4118 // We will get this command either QA is closed or ated is killed by user.
4119 case RACFG_CMD_ATE_STOP
:
4125 ATEDBGPRINT(RT_DEBUG_TRACE
,("RACFG_CMD_ATE_STOP\n"));
4127 // Distinguish this command came from QA(via ated)
4128 // or ate daemon according to the existence of pid in payload.
4129 // No need to prepare feedback if this cmd came directly from ate daemon.
4130 pRaCfg
->length
= ntohs(pRaCfg
->length
);
4132 if (pRaCfg
->length
== sizeof(pAdapter
->ate
.AtePid
))
4134 // This command came from QA.
4135 // Get the pid of ATE daemon.
4136 memcpy((UCHAR
*)&pAdapter
->ate
.AtePid
,
4137 (&pRaCfg
->data
[0]) - 2/* == &(pRaCfg->status) */,
4138 sizeof(pAdapter
->ate
.AtePid
));
4140 // prepare feedback as soon as we can to avoid QA timeout.
4141 pRaCfg
->length
= htons(2);
4142 pRaCfg
->status
= htons(0);
4144 wrq
->u
.data
.length
= sizeof(pRaCfg
->magic_no
) + sizeof(pRaCfg
->command_type
)
4145 + sizeof(pRaCfg
->command_id
) + sizeof(pRaCfg
->length
)
4146 + sizeof(pRaCfg
->sequence
) + ntohs(pRaCfg
->length
);
4148 ATEDBGPRINT(RT_DEBUG_TRACE
, ("wrq->u.data.length = %d\n", wrq
->u
.data
.length
));
4150 if (copy_to_user(wrq
->u
.data
.pointer
, pRaCfg
, wrq
->u
.data
.length
))
4152 ATEDBGPRINT(RT_DEBUG_ERROR
, ("copy_to_user() fail in case RACFG_CMD_ATE_STOP\n"));
4157 // kill ATE daemon when leaving ATE mode.
4158 // We must kill ATE daemon first before setting ATESTOP,
4159 // or Microsoft will report sth. wrong.
4161 ret
= KILL_THREAD_PID(pAdapter
->ate
.AtePid
, SIGTERM
, 1);
4164 ATEDBGPRINT(RT_DEBUG_ERROR
, ("%s: unable to signal thread\n", pAdapter
->net_dev
->name
));
4169 // AP might have in ATE_STOP mode due to cmd from QA.
4170 if (ATE_ON(pAdapter
))
4172 // Someone has killed ate daemon while QA GUI is still open.
4173 Set_ATE_Proc(pAdapter
, "ATESTOP");
4174 ATEDBGPRINT(RT_DEBUG_TRACE
, ("RACFG_CMD_AP_START is done !\n"));
4179 case RACFG_CMD_RF_WRITE_ALL
:
4181 UINT32 R1
, R2
, R3
, R4
;
4184 memcpy(&R1
, pRaCfg
->data
-2, 4);
4185 memcpy(&R2
, pRaCfg
->data
+2, 4);
4186 memcpy(&R3
, pRaCfg
->data
+6, 4);
4187 memcpy(&R4
, pRaCfg
->data
+10, 4);
4188 memcpy(&channel
, pRaCfg
->data
+14, 2);
4190 pAdapter
->LatchRfRegs
.R1
= ntohl(R1
);
4191 pAdapter
->LatchRfRegs
.R2
= ntohl(R2
);
4192 pAdapter
->LatchRfRegs
.R3
= ntohl(R3
);
4193 pAdapter
->LatchRfRegs
.R4
= ntohl(R4
);
4194 pAdapter
->LatchRfRegs
.Channel
= ntohs(channel
);
4196 RTMP_RF_IO_WRITE32(pAdapter
, pAdapter
->LatchRfRegs
.R1
);
4197 RTMP_RF_IO_WRITE32(pAdapter
, pAdapter
->LatchRfRegs
.R2
);
4198 RTMP_RF_IO_WRITE32(pAdapter
, pAdapter
->LatchRfRegs
.R3
);
4199 RTMP_RF_IO_WRITE32(pAdapter
, pAdapter
->LatchRfRegs
.R4
);
4202 pRaCfg
->length
= htons(2);
4203 pRaCfg
->status
= htons(0);
4205 wrq
->u
.data
.length
= sizeof(pRaCfg
->magic_no
) + sizeof(pRaCfg
->command_type
)
4206 + sizeof(pRaCfg
->command_id
) + sizeof(pRaCfg
->length
)
4207 + sizeof(pRaCfg
->sequence
) + ntohs(pRaCfg
->length
);
4209 ATEDBGPRINT(RT_DEBUG_TRACE
, ("wrq->u.data.length = %d\n", wrq
->u
.data
.length
));
4210 if (copy_to_user(wrq
->u
.data
.pointer
, pRaCfg
, wrq
->u
.data
.length
))
4212 ATEDBGPRINT(RT_DEBUG_ERROR
, ("copy_to_user() fail in case RACFG_CMD_RF_WRITE_ALL\n"));
4217 ATEDBGPRINT(RT_DEBUG_TRACE
, ("RACFG_CMD_RF_WRITE_ALL is done !\n"));
4222 case RACFG_CMD_E2PROM_READ16
:
4224 USHORT offset
, value
, tmp
;
4226 offset
= ntohs(pRaCfg
->status
);
4227 /* "tmp" is expecially for some compilers... */
4228 RT28xx_EEPROM_READ16(pAdapter
, offset
, tmp
);
4230 value
= htons(value
);
4232 ATEDBGPRINT(RT_DEBUG_TRACE
,("EEPROM Read offset = 0x%04x, value = 0x%04x\n", offset
, value
));
4235 pRaCfg
->length
= htons(4);
4236 pRaCfg
->status
= htons(0);
4237 memcpy(pRaCfg
->data
, &value
, 2);
4239 wrq
->u
.data
.length
= sizeof(pRaCfg
->magic_no
) + sizeof(pRaCfg
->command_type
)
4240 + sizeof(pRaCfg
->command_id
) + sizeof(pRaCfg
->length
)
4241 + sizeof(pRaCfg
->sequence
) + ntohs(pRaCfg
->length
);
4243 ATEDBGPRINT(RT_DEBUG_TRACE
, ("sizeof(struct ate_racfghdr) = %d\n", sizeof(struct ate_racfghdr
)));
4244 ATEDBGPRINT(RT_DEBUG_TRACE
, ("wrq->u.data.length = %d\n", wrq
->u
.data
.length
));
4246 if (copy_to_user(wrq
->u
.data
.pointer
, pRaCfg
, wrq
->u
.data
.length
))
4248 ATEDBGPRINT(RT_DEBUG_ERROR
, ("copy_to_user() fail in case RACFG_CMD_E2PROM_READ16\n"));
4253 ATEDBGPRINT(RT_DEBUG_TRACE
, ("RACFG_CMD_E2PROM_READ16 is done !\n"));
4258 case RACFG_CMD_E2PROM_WRITE16
:
4260 USHORT offset
, value
;
4262 offset
= ntohs(pRaCfg
->status
);
4263 memcpy(&value
, pRaCfg
->data
, 2);
4264 value
= ntohs(value
);
4265 RT28xx_EEPROM_WRITE16(pAdapter
, offset
, value
);
4268 pRaCfg
->length
= htons(2);
4269 pRaCfg
->status
= htons(0);
4270 wrq
->u
.data
.length
= sizeof(pRaCfg
->magic_no
) + sizeof(pRaCfg
->command_type
)
4271 + sizeof(pRaCfg
->command_id
) + sizeof(pRaCfg
->length
)
4272 + sizeof(pRaCfg
->sequence
) + ntohs(pRaCfg
->length
);
4274 if (copy_to_user(wrq
->u
.data
.pointer
, pRaCfg
, wrq
->u
.data
.length
))
4276 ATEDBGPRINT(RT_DEBUG_ERROR
, ("copy_to_user() fail in case RACFG_CMD_E2PROM_WRITE16\n"));
4281 ATEDBGPRINT(RT_DEBUG_TRACE
, ("RACFG_CMD_E2PROM_WRITE16 is done !\n"));
4286 case RACFG_CMD_E2PROM_READ_ALL
:
4288 USHORT buffer
[EEPROM_SIZE
/2];
4290 rt_ee_read_all(pAdapter
,(USHORT
*)buffer
);
4291 memcpy_exs(pAdapter
, pRaCfg
->data
, (UCHAR
*)buffer
, EEPROM_SIZE
);
4294 pRaCfg
->length
= htons(2+EEPROM_SIZE
);
4295 pRaCfg
->status
= htons(0);
4296 wrq
->u
.data
.length
= sizeof(pRaCfg
->magic_no
) + sizeof(pRaCfg
->command_type
)
4297 + sizeof(pRaCfg
->command_id
) + sizeof(pRaCfg
->length
)
4298 + sizeof(pRaCfg
->sequence
) + ntohs(pRaCfg
->length
);
4300 if (copy_to_user(wrq
->u
.data
.pointer
, pRaCfg
, wrq
->u
.data
.length
))
4302 ATEDBGPRINT(RT_DEBUG_ERROR
, ("copy_to_user() fail in case RACFG_CMD_E2PROM_READ_ALL\n"));
4307 ATEDBGPRINT(RT_DEBUG_TRACE
, ("RACFG_CMD_E2PROM_READ_ALL is done !\n"));
4312 case RACFG_CMD_E2PROM_WRITE_ALL
:
4314 USHORT buffer
[EEPROM_SIZE
/2];
4316 NdisZeroMemory((UCHAR
*)buffer
, EEPROM_SIZE
);
4317 memcpy_exs(pAdapter
, (UCHAR
*)buffer
, (UCHAR
*)&pRaCfg
->status
, EEPROM_SIZE
);
4318 rt_ee_write_all(pAdapter
,(USHORT
*)buffer
);
4321 pRaCfg
->length
= htons(2);
4322 pRaCfg
->status
= htons(0);
4323 wrq
->u
.data
.length
= sizeof(pRaCfg
->magic_no
) + sizeof(pRaCfg
->command_type
)
4324 + sizeof(pRaCfg
->command_id
) + sizeof(pRaCfg
->length
)
4325 + sizeof(pRaCfg
->sequence
) + ntohs(pRaCfg
->length
);
4327 if (copy_to_user(wrq
->u
.data
.pointer
, pRaCfg
, wrq
->u
.data
.length
))
4329 ATEDBGPRINT(RT_DEBUG_ERROR
, ("copy_to_user() fail in case RACFG_CMD_E2PROM_WRITE_ALL\n"));
4334 ATEDBGPRINT(RT_DEBUG_ERROR
, ("RACFG_CMD_E2PROM_WRITE_ALL is done !\n"));
4340 case RACFG_CMD_IO_READ
:
4345 memcpy(&offset
, &pRaCfg
->status
, 4);
4346 offset
= ntohl(offset
);
4348 // We do not need the base address.
4349 // So just extract the offset out.
4350 offset
&= 0x0000FFFF;
4351 RTMP_IO_READ32(pAdapter
, offset
, &value
);
4352 value
= htonl(value
);
4355 pRaCfg
->length
= htons(6);
4356 pRaCfg
->status
= htons(0);
4357 memcpy(pRaCfg
->data
, &value
, 4);
4359 wrq
->u
.data
.length
= sizeof(pRaCfg
->magic_no
) + sizeof(pRaCfg
->command_type
)
4360 + sizeof(pRaCfg
->command_id
) + sizeof(pRaCfg
->length
)
4361 + sizeof(pRaCfg
->sequence
) + ntohs(pRaCfg
->length
);
4363 if (copy_to_user(wrq
->u
.data
.pointer
, pRaCfg
, wrq
->u
.data
.length
))
4365 ATEDBGPRINT(RT_DEBUG_ERROR
, ("copy_to_user() fail in case RACFG_CMD_IO_READ\n"));
4370 ATEDBGPRINT(RT_DEBUG_TRACE
, ("RACFG_CMD_IO_READ is done !\n"));
4375 case RACFG_CMD_IO_WRITE
:
4377 UINT32 offset
, value
;
4379 memcpy(&offset
, pRaCfg
->data
-2, 4);
4380 memcpy(&value
, pRaCfg
->data
+2, 4);
4382 offset
= ntohl(offset
);
4384 // We do not need the base address.
4385 // So just extract out the offset.
4386 offset
&= 0x0000FFFF;
4387 value
= ntohl(value
);
4388 ATEDBGPRINT(RT_DEBUG_TRACE
,("RACFG_CMD_IO_WRITE: offset = %x, value = %x\n", offset
, value
));
4389 RTMP_IO_WRITE32(pAdapter
, offset
, value
);
4392 pRaCfg
->length
= htons(2);
4393 pRaCfg
->status
= htons(0);
4394 wrq
->u
.data
.length
= sizeof(pRaCfg
->magic_no
) + sizeof(pRaCfg
->command_type
)
4395 + sizeof(pRaCfg
->command_id
) + sizeof(pRaCfg
->length
)
4396 + sizeof(pRaCfg
->sequence
) + ntohs(pRaCfg
->length
);
4398 if (copy_to_user(wrq
->u
.data
.pointer
, pRaCfg
, wrq
->u
.data
.length
))
4400 ATEDBGPRINT(RT_DEBUG_ERROR
, ("copy_to_user() fail in case RACFG_CMD_IO_WRITE\n"));
4405 ATEDBGPRINT(RT_DEBUG_TRACE
, ("RACFG_CMD_IO_WRITE is done !\n"));
4410 case RACFG_CMD_IO_READ_BULK
:
4415 memcpy(&offset
, &pRaCfg
->status
, 4);
4416 offset
= ntohl(offset
);
4418 // We do not need the base address.
4419 // So just extract the offset.
4420 offset
&= 0x0000FFFF;
4421 memcpy(&len
, pRaCfg
->data
+2, 2);
4426 ATEDBGPRINT(RT_DEBUG_TRACE
,("len is too large, make it smaller\n"));
4427 pRaCfg
->length
= htons(2);
4428 pRaCfg
->status
= htons(1);
4432 RTMP_IO_READ_BULK(pAdapter
, pRaCfg
->data
, (UCHAR
*)offset
, len
*4);// unit in four bytes
4435 pRaCfg
->length
= htons(2+len
*4);// unit in four bytes
4436 pRaCfg
->status
= htons(0);
4437 wrq
->u
.data
.length
= sizeof(pRaCfg
->magic_no
) + sizeof(pRaCfg
->command_type
)
4438 + sizeof(pRaCfg
->command_id
) + sizeof(pRaCfg
->length
)
4439 + sizeof(pRaCfg
->sequence
) + ntohs(pRaCfg
->length
);
4441 if (copy_to_user(wrq
->u
.data
.pointer
, pRaCfg
, wrq
->u
.data
.length
))
4443 ATEDBGPRINT(RT_DEBUG_ERROR
, ("copy_to_user() fail in case RACFG_CMD_IO_READ_BULK\n"));
4448 ATEDBGPRINT(RT_DEBUG_TRACE
, ("RACFG_CMD_IO_READ_BULK is done !\n"));
4453 case RACFG_CMD_BBP_READ8
:
4459 offset
= ntohs(pRaCfg
->status
);
4461 if (ATE_ON(pAdapter
))
4463 ATE_BBP_IO_READ8_BY_REG_ID(pAdapter
, offset
, &value
);
4467 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter
, offset
, &value
);
4470 pRaCfg
->length
= htons(3);
4471 pRaCfg
->status
= htons(0);
4472 pRaCfg
->data
[0] = value
;
4474 ATEDBGPRINT(RT_DEBUG_TRACE
,("BBP value = %x\n", value
));
4476 wrq
->u
.data
.length
= sizeof(pRaCfg
->magic_no
) + sizeof(pRaCfg
->command_type
)
4477 + sizeof(pRaCfg
->command_id
) + sizeof(pRaCfg
->length
)
4478 + sizeof(pRaCfg
->sequence
) + ntohs(pRaCfg
->length
);
4480 if (copy_to_user(wrq
->u
.data
.pointer
, pRaCfg
, wrq
->u
.data
.length
))
4482 ATEDBGPRINT(RT_DEBUG_ERROR
, ("copy_to_user() fail in case RACFG_CMD_BBP_READ8\n"));
4487 ATEDBGPRINT(RT_DEBUG_TRACE
, ("RACFG_CMD_BBP_READ8 is done !\n"));
4491 case RACFG_CMD_BBP_WRITE8
:
4496 offset
= ntohs(pRaCfg
->status
);
4497 memcpy(&value
, pRaCfg
->data
, 1);
4499 if (ATE_ON(pAdapter
))
4501 ATE_BBP_IO_WRITE8_BY_REG_ID(pAdapter
, offset
, value
);
4505 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter
, offset
, value
);
4508 if ((offset
== BBP_R1
) || (offset
== BBP_R3
))
4510 SyncTxRxConfig(pAdapter
, offset
, value
);
4514 pRaCfg
->length
= htons(2);
4515 pRaCfg
->status
= htons(0);
4516 wrq
->u
.data
.length
= sizeof(pRaCfg
->magic_no
) + sizeof(pRaCfg
->command_type
)
4517 + sizeof(pRaCfg
->command_id
) + sizeof(pRaCfg
->length
)
4518 + sizeof(pRaCfg
->sequence
) + ntohs(pRaCfg
->length
);
4520 if (copy_to_user(wrq
->u
.data
.pointer
, pRaCfg
, wrq
->u
.data
.length
))
4522 ATEDBGPRINT(RT_DEBUG_ERROR
, ("copy_to_user() fail in case RACFG_CMD_BBP_WRITE8\n"));
4527 ATEDBGPRINT(RT_DEBUG_TRACE
, ("RACFG_CMD_BBP_WRITE8 is done !\n"));
4532 case RACFG_CMD_BBP_READ_ALL
:
4536 for (j
= 0; j
< 137; j
++)
4538 pRaCfg
->data
[j
] = 0;
4540 if (ATE_ON(pAdapter
))
4542 ATE_BBP_IO_READ8_BY_REG_ID(pAdapter
, j
, &pRaCfg
->data
[j
]);
4546 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter
, j
, &pRaCfg
->data
[j
]);
4551 pRaCfg
->length
= htons(2+137);
4552 pRaCfg
->status
= htons(0);
4554 wrq
->u
.data
.length
= sizeof(pRaCfg
->magic_no
) + sizeof(pRaCfg
->command_type
)
4555 + sizeof(pRaCfg
->command_id
) + sizeof(pRaCfg
->length
)
4556 + sizeof(pRaCfg
->sequence
) + ntohs(pRaCfg
->length
);
4558 if (copy_to_user(wrq
->u
.data
.pointer
, pRaCfg
, wrq
->u
.data
.length
))
4560 ATEDBGPRINT(RT_DEBUG_ERROR
, ("copy_to_user() fail in case RACFG_CMD_BBP_READ_ALL\n"));
4565 ATEDBGPRINT(RT_DEBUG_TRACE
, ("RACFG_CMD_BBP_READ_ALL is done !\n"));
4571 case RACFG_CMD_ATE_E2PROM_READ_BULK
:
4575 USHORT buffer
[EEPROM_SIZE
/2];
4577 offset
= ntohs(pRaCfg
->status
);
4578 memcpy(&len
, pRaCfg
->data
, 2);
4581 rt_ee_read_all(pAdapter
,(USHORT
*)buffer
);
4582 if (offset
+ len
<= EEPROM_SIZE
)
4583 memcpy_exs(pAdapter
, pRaCfg
->data
, (UCHAR
*)buffer
+offset
, len
);
4585 ATEDBGPRINT(RT_DEBUG_ERROR
, ("exceed EEPROM size\n"));
4588 pRaCfg
->length
= htons(2+len
);
4589 pRaCfg
->status
= htons(0);
4590 wrq
->u
.data
.length
= sizeof(pRaCfg
->magic_no
) + sizeof(pRaCfg
->command_type
)
4591 + sizeof(pRaCfg
->command_id
) + sizeof(pRaCfg
->length
)
4592 + sizeof(pRaCfg
->sequence
) + ntohs(pRaCfg
->length
);
4594 if (copy_to_user(wrq
->u
.data
.pointer
, pRaCfg
, wrq
->u
.data
.length
))
4596 ATEDBGPRINT(RT_DEBUG_ERROR
, ("copy_to_user() fail in case RACFG_CMD_ATE_E2PROM_READ_BULK\n"));
4601 ATEDBGPRINT(RT_DEBUG_TRACE
, ("RACFG_CMD_ATE_E2PROM_READ_BULK is done !\n"));
4607 case RACFG_CMD_ATE_E2PROM_WRITE_BULK
:
4611 USHORT buffer
[EEPROM_SIZE
/2];
4613 offset
= ntohs(pRaCfg
->status
);
4614 memcpy(&len
, pRaCfg
->data
, 2);
4617 rt_ee_read_all(pAdapter
,(USHORT
*)buffer
);
4618 memcpy_exs(pAdapter
, (UCHAR
*)buffer
+ offset
, (UCHAR
*)pRaCfg
->data
+ 2, len
);
4619 rt_ee_write_all(pAdapter
,(USHORT
*)buffer
);
4622 pRaCfg
->length
= htons(2);
4623 pRaCfg
->status
= htons(0);
4624 wrq
->u
.data
.length
= sizeof(pRaCfg
->magic_no
) + sizeof(pRaCfg
->command_type
)
4625 + sizeof(pRaCfg
->command_id
) + sizeof(pRaCfg
->length
)
4626 + sizeof(pRaCfg
->sequence
) + ntohs(pRaCfg
->length
);
4627 if (copy_to_user(wrq
->u
.data
.pointer
, pRaCfg
, wrq
->u
.data
.length
))
4629 ATEDBGPRINT(RT_DEBUG_ERROR
, ("copy_to_user() fail in case RACFG_CMD_ATE_E2PROM_WRITE_BULK\n"));
4634 ATEDBGPRINT(RT_DEBUG_ERROR
, ("RACFG_CMD_ATE_E2PROM_WRITE_BULK is done !\n"));
4640 case RACFG_CMD_ATE_IO_WRITE_BULK
:
4642 UINT32 offset
, i
, value
;
4645 memcpy(&offset
, &pRaCfg
->status
, 4);
4646 offset
= ntohl(offset
);
4647 memcpy(&len
, pRaCfg
->data
+2, 2);
4650 for (i
= 0; i
< len
; i
+= 4)
4652 memcpy_exl(pAdapter
, (UCHAR
*)&value
, pRaCfg
->data
+4+i
, 4);
4653 printk("Write %x %x\n", offset
+ i
, value
);
4654 RTMP_IO_WRITE32(pAdapter
, (offset
+i
) & 0xffff, value
);
4658 pRaCfg
->length
= htons(2);
4659 pRaCfg
->status
= htons(0);
4660 wrq
->u
.data
.length
= sizeof(pRaCfg
->magic_no
) + sizeof(pRaCfg
->command_type
)
4661 + sizeof(pRaCfg
->command_id
) + sizeof(pRaCfg
->length
)
4662 + sizeof(pRaCfg
->sequence
) + ntohs(pRaCfg
->length
);
4663 if (copy_to_user(wrq
->u
.data
.pointer
, pRaCfg
, wrq
->u
.data
.length
))
4665 ATEDBGPRINT(RT_DEBUG_ERROR
, ("copy_to_user() fail in case RACFG_CMD_ATE_IO_WRITE_BULK\n"));
4670 ATEDBGPRINT(RT_DEBUG_ERROR
, ("RACFG_CMD_ATE_IO_WRITE_BULK is done !\n"));
4676 case RACFG_CMD_ATE_BBP_READ_BULK
:
4682 offset
= ntohs(pRaCfg
->status
);
4683 memcpy(&len
, pRaCfg
->data
, 2);
4687 for (j
= offset
; j
< (offset
+len
); j
++)
4689 pRaCfg
->data
[j
- offset
] = 0;
4691 if (pAdapter
->ate
.Mode
== ATE_STOP
)
4693 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter
, j
, &pRaCfg
->data
[j
- offset
]);
4697 ATE_BBP_IO_READ8_BY_REG_ID(pAdapter
, j
, &pRaCfg
->data
[j
- offset
]);
4702 pRaCfg
->length
= htons(2+len
);
4703 pRaCfg
->status
= htons(0);
4704 wrq
->u
.data
.length
= sizeof(pRaCfg
->magic_no
) + sizeof(pRaCfg
->command_type
)
4705 + sizeof(pRaCfg
->command_id
) + sizeof(pRaCfg
->length
)
4706 + sizeof(pRaCfg
->sequence
) + ntohs(pRaCfg
->length
);
4708 if (copy_to_user(wrq
->u
.data
.pointer
, pRaCfg
, wrq
->u
.data
.length
))
4710 ATEDBGPRINT(RT_DEBUG_ERROR
, ("copy_to_user() fail in case RACFG_CMD_ATE_BBP_READ_BULK\n"));
4715 ATEDBGPRINT(RT_DEBUG_TRACE
, ("RACFG_CMD_ATE_BBP_READ_BULK is done !\n"));
4721 case RACFG_CMD_ATE_BBP_WRITE_BULK
:
4728 offset
= ntohs(pRaCfg
->status
);
4729 memcpy(&len
, pRaCfg
->data
, 2);
4732 for (j
= offset
; j
< (offset
+len
); j
++)
4734 value
= pRaCfg
->data
+ 2 + (j
- offset
);
4735 if (pAdapter
->ate
.Mode
== ATE_STOP
)
4737 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter
, j
, *value
);
4741 ATE_BBP_IO_WRITE8_BY_REG_ID(pAdapter
, j
, *value
);
4746 pRaCfg
->length
= htons(2);
4747 pRaCfg
->status
= htons(0);
4748 wrq
->u
.data
.length
= sizeof(pRaCfg
->magic_no
) + sizeof(pRaCfg
->command_type
)
4749 + sizeof(pRaCfg
->command_id
) + sizeof(pRaCfg
->length
)
4750 + sizeof(pRaCfg
->sequence
) + ntohs(pRaCfg
->length
);
4752 if (copy_to_user(wrq
->u
.data
.pointer
, pRaCfg
, wrq
->u
.data
.length
))
4754 ATEDBGPRINT(RT_DEBUG_ERROR
, ("copy_to_user() fail in case RACFG_CMD_ATE_BBP_WRITE_BULK\n"));
4759 ATEDBGPRINT(RT_DEBUG_TRACE
, ("RACFG_CMD_ATE_BBP_WRITE_BULK is done !\n"));
4764 #ifdef CONFIG_RALINK_RT3052
4765 case RACFG_CMD_ATE_RF_READ_BULK
:
4771 offset
= ntohs(pRaCfg
->status
);
4772 memcpy(&len
, pRaCfg
->data
, 2);
4775 for (j
= offset
; j
< (offset
+len
); j
++)
4777 pRaCfg
->data
[j
- offset
] = 0;
4778 RT30xxReadRFRegister(pAdapter
, j
, &pRaCfg
->data
[j
- offset
]);
4782 pRaCfg
->length
= htons(2+len
);
4783 pRaCfg
->status
= htons(0);
4784 wrq
->u
.data
.length
= sizeof(pRaCfg
->magic_no
) + sizeof(pRaCfg
->command_type
)
4785 + sizeof(pRaCfg
->command_id
) + sizeof(pRaCfg
->length
)
4786 + sizeof(pRaCfg
->sequence
) + ntohs(pRaCfg
->length
);
4788 if (copy_to_user(wrq
->u
.data
.pointer
, pRaCfg
, wrq
->u
.data
.length
))
4790 ATEDBGPRINT(RT_DEBUG_ERROR
, ("copy_to_user() fail in case RACFG_CMD_ATE_RF_READ_BULK\n"));
4795 ATEDBGPRINT(RT_DEBUG_TRACE
, ("RACFG_CMD_ATE_RF_READ_BULK is done !\n"));
4801 case RACFG_CMD_ATE_RF_WRITE_BULK
:
4808 offset
= ntohs(pRaCfg
->status
);
4809 memcpy(&len
, pRaCfg
->data
, 2);
4812 for (j
= offset
; j
< (offset
+len
); j
++)
4814 value
= pRaCfg
->data
+ 2 + (j
- offset
);
4815 RT30xxWriteRFRegister(pAdapter
, j
, *value
);
4819 pRaCfg
->length
= htons(2);
4820 pRaCfg
->status
= htons(0);
4821 wrq
->u
.data
.length
= sizeof(pRaCfg
->magic_no
) + sizeof(pRaCfg
->command_type
)
4822 + sizeof(pRaCfg
->command_id
) + sizeof(pRaCfg
->length
)
4823 + sizeof(pRaCfg
->sequence
) + ntohs(pRaCfg
->length
);
4825 if (copy_to_user(wrq
->u
.data
.pointer
, pRaCfg
, wrq
->u
.data
.length
))
4827 ATEDBGPRINT(RT_DEBUG_ERROR
, ("copy_to_user() fail in case RACFG_CMD_ATE_RF_WRITE_BULK\n"));
4832 ATEDBGPRINT(RT_DEBUG_TRACE
, ("RACFG_CMD_ATE_RF_WRITE_BULK is done !\n"));
4840 case RACFG_CMD_GET_NOISE_LEVEL
:
4843 INT32 buffer
[3][10];/* 3 : RxPath ; 10 : no. of per rssi samples */
4845 channel
= (ntohs(pRaCfg
->status
) & 0x00FF);
4846 CalNoiseLevel(pAdapter
, channel
, buffer
);
4847 memcpy_exl(pAdapter
, (UCHAR
*)pRaCfg
->data
, (UCHAR
*)&(buffer
[0][0]), (sizeof(INT32
)*3*10));
4850 pRaCfg
->length
= htons(2 + (sizeof(INT32
)*3*10));
4851 pRaCfg
->status
= htons(0);
4852 wrq
->u
.data
.length
= sizeof(pRaCfg
->magic_no
) + sizeof(pRaCfg
->command_type
)
4853 + sizeof(pRaCfg
->command_id
) + sizeof(pRaCfg
->length
)
4854 + sizeof(pRaCfg
->sequence
) + ntohs(pRaCfg
->length
);
4856 if (copy_to_user(wrq
->u
.data
.pointer
, pRaCfg
, wrq
->u
.data
.length
))
4858 ATEDBGPRINT(RT_DEBUG_ERROR
, ("copy_to_user() fail in case RACFG_CMD_GET_NOISE_LEVEL\n"));
4863 ATEDBGPRINT(RT_DEBUG_TRACE
, ("RACFG_CMD_GET_NOISE_LEVEL is done !\n"));
4868 case RACFG_CMD_GET_COUNTER
:
4870 memcpy_exl(pAdapter
, &pRaCfg
->data
[0], (UCHAR
*)&pAdapter
->ate
.U2M
, 4);
4871 memcpy_exl(pAdapter
, &pRaCfg
->data
[4], (UCHAR
*)&pAdapter
->ate
.OtherData
, 4);
4872 memcpy_exl(pAdapter
, &pRaCfg
->data
[8], (UCHAR
*)&pAdapter
->ate
.Beacon
, 4);
4873 memcpy_exl(pAdapter
, &pRaCfg
->data
[12], (UCHAR
*)&pAdapter
->ate
.OtherCount
, 4);
4874 memcpy_exl(pAdapter
, &pRaCfg
->data
[16], (UCHAR
*)&pAdapter
->ate
.TxAc0
, 4);
4875 memcpy_exl(pAdapter
, &pRaCfg
->data
[20], (UCHAR
*)&pAdapter
->ate
.TxAc1
, 4);
4876 memcpy_exl(pAdapter
, &pRaCfg
->data
[24], (UCHAR
*)&pAdapter
->ate
.TxAc2
, 4);
4877 memcpy_exl(pAdapter
, &pRaCfg
->data
[28], (UCHAR
*)&pAdapter
->ate
.TxAc3
, 4);
4878 memcpy_exl(pAdapter
, &pRaCfg
->data
[32], (UCHAR
*)&pAdapter
->ate
.TxHCCA
, 4);
4879 memcpy_exl(pAdapter
, &pRaCfg
->data
[36], (UCHAR
*)&pAdapter
->ate
.TxMgmt
, 4);
4880 memcpy_exl(pAdapter
, &pRaCfg
->data
[40], (UCHAR
*)&pAdapter
->ate
.RSSI0
, 4);
4881 memcpy_exl(pAdapter
, &pRaCfg
->data
[44], (UCHAR
*)&pAdapter
->ate
.RSSI1
, 4);
4882 memcpy_exl(pAdapter
, &pRaCfg
->data
[48], (UCHAR
*)&pAdapter
->ate
.RSSI2
, 4);
4883 memcpy_exl(pAdapter
, &pRaCfg
->data
[52], (UCHAR
*)&pAdapter
->ate
.SNR0
, 4);
4884 memcpy_exl(pAdapter
, &pRaCfg
->data
[56], (UCHAR
*)&pAdapter
->ate
.SNR1
, 4);
4886 pRaCfg
->length
= htons(2+60);
4887 pRaCfg
->status
= htons(0);
4888 wrq
->u
.data
.length
= sizeof(pRaCfg
->magic_no
) + sizeof(pRaCfg
->command_type
)
4889 + sizeof(pRaCfg
->command_id
) + sizeof(pRaCfg
->length
)
4890 + sizeof(pRaCfg
->sequence
) + ntohs(pRaCfg
->length
);
4892 if (copy_to_user(wrq
->u
.data
.pointer
, pRaCfg
, wrq
->u
.data
.length
))
4894 ATEDBGPRINT(RT_DEBUG_ERROR
, ("copy_to_user() fail in case RACFG_CMD_GET_COUNTER\n"));
4899 ATEDBGPRINT(RT_DEBUG_TRACE
, ("RACFG_CMD_GET_COUNTER is done !\n"));
4904 case RACFG_CMD_CLEAR_COUNTER
:
4906 pAdapter
->ate
.U2M
= 0;
4907 pAdapter
->ate
.OtherData
= 0;
4908 pAdapter
->ate
.Beacon
= 0;
4909 pAdapter
->ate
.OtherCount
= 0;
4910 pAdapter
->ate
.TxAc0
= 0;
4911 pAdapter
->ate
.TxAc1
= 0;
4912 pAdapter
->ate
.TxAc2
= 0;
4913 pAdapter
->ate
.TxAc3
= 0;
4914 pAdapter
->ate
.TxHCCA
= 0;
4915 pAdapter
->ate
.TxMgmt
= 0;
4916 pAdapter
->ate
.TxDoneCount
= 0;
4918 pRaCfg
->length
= htons(2);
4919 pRaCfg
->status
= htons(0);
4921 wrq
->u
.data
.length
= sizeof(pRaCfg
->magic_no
) + sizeof(pRaCfg
->command_type
)
4922 + sizeof(pRaCfg
->command_id
) + sizeof(pRaCfg
->length
)
4923 + sizeof(pRaCfg
->sequence
) + ntohs(pRaCfg
->length
);
4925 if (copy_to_user(wrq
->u
.data
.pointer
, pRaCfg
, wrq
->u
.data
.length
))
4927 ATEDBGPRINT(RT_DEBUG_ERROR
, ("copy_to_user() fail in case RACFG_CMD_CLEAR_COUNTER\n"));
4932 ATEDBGPRINT(RT_DEBUG_TRACE
, ("RACFG_CMD_CLEAR_COUNTER is done !\n"));
4938 case RACFG_CMD_TX_START
:
4942 UCHAR Bbp22Value
= 0, Bbp24Value
= 0;
4944 if ((pAdapter
->ate
.TxStatus
!= 0) && (pAdapter
->ate
.Mode
& ATE_TXFRAME
))
4946 ATEDBGPRINT(RT_DEBUG_TRACE
,("Ate Tx is already running, to run next Tx, you must stop it first\n"));
4948 goto TX_START_ERROR
;
4950 else if ((pAdapter
->ate
.TxStatus
!= 0) && !(pAdapter
->ate
.Mode
& ATE_TXFRAME
))
4954 while ((i
++ < 10) && (pAdapter
->ate
.TxStatus
!= 0))
4956 RTMPusecDelay(5000);
4960 pAdapter
->ate
.TxStatus
= 0;
4961 pAdapter
->ate
.TxDoneCount
= 0;
4962 //pAdapter->ate.Repeat = 0;
4963 pAdapter
->ate
.bQATxStart
= FALSE
;
4966 // If pRaCfg->length == 0, this "RACFG_CMD_TX_START" is for Carrier test or Carrier Suppression.
4967 if (ntohs(pRaCfg
->length
) != 0)
4971 NdisMoveMemory(&pAdapter
->ate
.TxInfo
, pRaCfg
->data
- 2, 4);
4972 #ifdef RT_BIG_ENDIAN
4973 RTMPDescriptorEndianChange((PUCHAR
) &pAdapter
->ate
.TxInfo
, TYPE_TXINFO
);
4974 #endif // RT_BIG_ENDIAN //
4977 NdisMoveMemory(&pAdapter
->ate
.TxWI
, pRaCfg
->data
+ 2, 16);
4978 #ifdef RT_BIG_ENDIAN
4979 RTMPWIEndianChange((PUCHAR
)&pAdapter
->ate
.TxWI
, TYPE_TXWI
);
4980 #endif // RT_BIG_ENDIAN //
4982 NdisMoveMemory(&pAdapter
->ate
.TxCount
, pRaCfg
->data
+ 18, 4);
4983 pAdapter
->ate
.TxCount
= ntohl(pAdapter
->ate
.TxCount
);
4985 p
= (USHORT
*)(&pRaCfg
->data
[22]);
4986 //p = pRaCfg->data + 22;
4987 // always use QID_AC_BE
4988 pAdapter
->ate
.QID
= 0;
4989 p
= (USHORT
*)(&pRaCfg
->data
[24]);
4990 //p = pRaCfg->data + 24;
4991 pAdapter
->ate
.HLen
= ntohs(*p
);
4993 if (pAdapter
->ate
.HLen
> 32)
4995 ATEDBGPRINT(RT_DEBUG_ERROR
,("pAdapter->ate.HLen > 32\n"));
4997 goto TX_START_ERROR
;
5000 NdisMoveMemory(&pAdapter
->ate
.Header
, pRaCfg
->data
+ 26, pAdapter
->ate
.HLen
);
5003 pAdapter
->ate
.PLen
= ntohs(pRaCfg
->length
) - (pAdapter
->ate
.HLen
+ 28);
5005 if (pAdapter
->ate
.PLen
> 32)
5007 ATEDBGPRINT(RT_DEBUG_ERROR
,("pAdapter->ate.PLen > 32\n"));
5009 goto TX_START_ERROR
;
5012 NdisMoveMemory(&pAdapter
->ate
.Pattern
, pRaCfg
->data
+ 26 + pAdapter
->ate
.HLen
, pAdapter
->ate
.PLen
);
5013 pAdapter
->ate
.DLen
= pAdapter
->ate
.TxWI
.MPDUtotalByteCount
- pAdapter
->ate
.HLen
;
5016 ATE_BBP_IO_READ8_BY_REG_ID(pAdapter
, BBP_R22
, &Bbp22Value
);
5022 if (pAdapter
->ate
.TxCount
== 0)
5025 ATEDBGPRINT(RT_DEBUG_TRACE
,("START TXFRAME\n"));
5026 pAdapter
->ate
.bQATxStart
= TRUE
;
5027 Set_ATE_Proc(pAdapter
, "TXFRAME");
5031 case BBP22_TXCONT_OR_CARRSUPP
:
5033 ATEDBGPRINT(RT_DEBUG_TRACE
,("BBP22_TXCONT_OR_CARRSUPP\n"));
5034 ATE_BBP_IO_READ8_BY_REG_ID(pAdapter
, 24, &Bbp24Value
);
5040 ATEDBGPRINT(RT_DEBUG_TRACE
,("START TXCONT\n"));
5041 pAdapter
->ate
.bQATxStart
= TRUE
;
5042 Set_ATE_Proc(pAdapter
, "TXCONT");
5046 case BBP24_CARRSUPP
:
5048 ATEDBGPRINT(RT_DEBUG_TRACE
,("START TXCARRSUPP\n"));
5049 pAdapter
->ate
.bQATxStart
= TRUE
;
5050 pAdapter
->ate
.Mode
|= ATE_TXCARRSUPP
;
5056 ATEDBGPRINT(RT_DEBUG_ERROR
,("Unknown Start TX subtype !"));
5065 ATEDBGPRINT(RT_DEBUG_TRACE
,("START TXCARR\n"));
5066 pAdapter
->ate
.bQATxStart
= TRUE
;
5067 Set_ATE_Proc(pAdapter
, "TXCARR");
5073 ATEDBGPRINT(RT_DEBUG_ERROR
,("Unknown Start TX subtype !"));
5078 if (pAdapter
->ate
.bQATxStart
== TRUE
)
5081 pRaCfg
->length
= htons(2);
5082 pRaCfg
->status
= htons(0);
5084 wrq
->u
.data
.length
= sizeof(pRaCfg
->magic_no
) + sizeof(pRaCfg
->command_type
)
5085 + sizeof(pRaCfg
->command_id
) + sizeof(pRaCfg
->length
)
5086 + sizeof(pRaCfg
->sequence
) + ntohs(pRaCfg
->length
);
5088 if (copy_to_user(wrq
->u
.data
.pointer
, pRaCfg
, wrq
->u
.data
.length
))
5090 ATEDBGPRINT(RT_DEBUG_ERROR
, ("copy_to_user() was failed in case RACFG_CMD_TX_START\n"));
5095 ATEDBGPRINT(RT_DEBUG_TRACE
, ("RACFG_CMD_TX_START is done !\n"));
5102 pRaCfg
->length
= htons(2);
5103 pRaCfg
->status
= htons(err
);
5105 wrq
->u
.data
.length
= sizeof(pRaCfg
->magic_no
) + sizeof(pRaCfg
->command_type
)
5106 + sizeof(pRaCfg
->command_id
) + sizeof(pRaCfg
->length
)
5107 + sizeof(pRaCfg
->sequence
) + ntohs(pRaCfg
->length
);
5108 if (copy_to_user(wrq
->u
.data
.pointer
, pRaCfg
, wrq
->u
.data
.length
))
5110 ATEDBGPRINT(RT_DEBUG_ERROR
, ("copy_to_user() fail in case RACFG_CMD_TX_START\n"));
5115 ATEDBGPRINT(RT_DEBUG_TRACE
, ("feedback of TX_START_ERROR is done !\n"));
5120 case RACFG_CMD_GET_TX_STATUS
:
5125 pRaCfg
->length
= htons(6);
5126 pRaCfg
->status
= htons(0);
5127 count
= htonl(pAdapter
->ate
.TxDoneCount
);
5128 NdisMoveMemory(pRaCfg
->data
, &count
, 4);
5129 wrq
->u
.data
.length
= sizeof(pRaCfg
->magic_no
) + sizeof(pRaCfg
->command_type
)
5130 + sizeof(pRaCfg
->command_id
) + sizeof(pRaCfg
->length
)
5131 + sizeof(pRaCfg
->sequence
) + ntohs(pRaCfg
->length
);
5133 if (copy_to_user(wrq
->u
.data
.pointer
, pRaCfg
, wrq
->u
.data
.length
))
5135 ATEDBGPRINT(RT_DEBUG_ERROR
, ("copy_to_user() fail in case RACFG_CMD_GET_TX_STATUS\n"));
5140 ATEDBGPRINT(RT_DEBUG_TRACE
, ("RACFG_CMD_GET_TX_STATUS is done !\n"));
5145 case RACFG_CMD_TX_STOP
:
5147 ATEDBGPRINT(RT_DEBUG_TRACE
,("RACFG_CMD_TX_STOP\n"));
5149 Set_ATE_Proc(pAdapter
, "TXSTOP");
5152 pRaCfg
->length
= htons(2);
5153 pRaCfg
->status
= htons(0);
5154 wrq
->u
.data
.length
= sizeof(pRaCfg
->magic_no
) + sizeof(pRaCfg
->command_type
)
5155 + sizeof(pRaCfg
->command_id
) + sizeof(pRaCfg
->length
)
5156 + sizeof(pRaCfg
->sequence
) + ntohs(pRaCfg
->length
);
5158 if (copy_to_user(wrq
->u
.data
.pointer
, pRaCfg
, wrq
->u
.data
.length
))
5160 ATEDBGPRINT(RT_DEBUG_TRACE
, ("copy_to_user() fail in case RACFG_CMD_TX_STOP\n"));
5165 ATEDBGPRINT(RT_DEBUG_TRACE
, ("RACFG_CMD_TX_STOP is done !\n"));
5170 case RACFG_CMD_RX_START
:
5172 ATEDBGPRINT(RT_DEBUG_TRACE
,("RACFG_CMD_RX_START\n"));
5174 pAdapter
->ate
.bQARxStart
= TRUE
;
5175 Set_ATE_Proc(pAdapter
, "RXFRAME");
5178 pRaCfg
->length
= htons(2);
5179 pRaCfg
->status
= htons(0);
5180 wrq
->u
.data
.length
= sizeof(pRaCfg
->magic_no
) + sizeof(pRaCfg
->command_type
)
5181 + sizeof(pRaCfg
->command_id
) + sizeof(pRaCfg
->length
)
5182 + sizeof(pRaCfg
->sequence
) + ntohs(pRaCfg
->length
);
5184 if (copy_to_user(wrq
->u
.data
.pointer
, pRaCfg
, wrq
->u
.data
.length
))
5186 ATEDBGPRINT(RT_DEBUG_ERROR
, ("copy_to_user() fail in case RACFG_CMD_RX_START\n"));
5191 ATEDBGPRINT(RT_DEBUG_TRACE
, ("RACFG_CMD_RX_START is done !\n"));
5196 case RACFG_CMD_RX_STOP
:
5198 ATEDBGPRINT(RT_DEBUG_TRACE
,("RACFG_CMD_RX_STOP\n"));
5200 Set_ATE_Proc(pAdapter
, "RXSTOP");
5203 pRaCfg
->length
= htons(2);
5204 pRaCfg
->status
= htons(0);
5205 wrq
->u
.data
.length
= sizeof(pRaCfg
->magic_no
) + sizeof(pRaCfg
->command_type
)
5206 + sizeof(pRaCfg
->command_id
) + sizeof(pRaCfg
->length
)
5207 + sizeof(pRaCfg
->sequence
) + ntohs(pRaCfg
->length
);
5209 if (copy_to_user(wrq
->u
.data
.pointer
, pRaCfg
, wrq
->u
.data
.length
))
5211 ATEDBGPRINT(RT_DEBUG_ERROR
, ("copy_to_user() fail in case RACFG_CMD_RX_STOP\n"));
5216 ATEDBGPRINT(RT_DEBUG_TRACE
, ("RACFG_CMD_RX_STOP is done !\n"));
5221 /* The following cases are for new ATE GUI(not QA). */
5222 /*==================================================*/
5223 case RACFG_CMD_ATE_START_TX_CARRIER
:
5225 ATEDBGPRINT(RT_DEBUG_TRACE
,("RACFG_CMD_ATE_START_TX_CARRIER\n"));
5227 Set_ATE_Proc(pAdapter
, "TXCARR");
5229 pRaCfg
->length
= htons(2);
5230 pRaCfg
->status
= htons(0);
5232 wrq
->u
.data
.length
= sizeof(pRaCfg
->magic_no
) + sizeof(pRaCfg
->command_type
)
5233 + sizeof(pRaCfg
->command_id
) + sizeof(pRaCfg
->length
)
5234 + sizeof(pRaCfg
->sequence
) + ntohs(pRaCfg
->length
);
5236 ATEDBGPRINT(RT_DEBUG_TRACE
, ("wrq->u.data.length = %d\n", wrq
->u
.data
.length
));
5238 if (copy_to_user(wrq
->u
.data
.pointer
, pRaCfg
, wrq
->u
.data
.length
))
5240 ATEDBGPRINT(RT_DEBUG_ERROR
, ("copy_to_user() fail in case RACFG_CMD_ATE_START_TX_CARRIER\n"));
5245 ATEDBGPRINT(RT_DEBUG_TRACE
, ("RACFG_CMD_ATE_START_TX_CARRIER is done !\n"));
5250 case RACFG_CMD_ATE_START_TX_CONT
:
5252 ATEDBGPRINT(RT_DEBUG_TRACE
,("RACFG_CMD_ATE_START_TX_CONT\n"));
5254 Set_ATE_Proc(pAdapter
, "TXCONT");
5256 pRaCfg
->length
= htons(2);
5257 pRaCfg
->status
= htons(0);
5259 wrq
->u
.data
.length
= sizeof(pRaCfg
->magic_no
) + sizeof(pRaCfg
->command_type
)
5260 + sizeof(pRaCfg
->command_id
) + sizeof(pRaCfg
->length
)
5261 + sizeof(pRaCfg
->sequence
) + ntohs(pRaCfg
->length
);
5263 ATEDBGPRINT(RT_DEBUG_TRACE
, ("wrq->u.data.length = %d\n", wrq
->u
.data
.length
));
5265 if (copy_to_user(wrq
->u
.data
.pointer
, pRaCfg
, wrq
->u
.data
.length
))
5267 ATEDBGPRINT(RT_DEBUG_ERROR
, ("copy_to_user() fail in case RACFG_CMD_ATE_START_TX_CONT\n"));
5272 ATEDBGPRINT(RT_DEBUG_TRACE
, ("RACFG_CMD_ATE_START_TX_CONT is done !\n"));
5277 case RACFG_CMD_ATE_START_TX_FRAME
:
5279 ATEDBGPRINT(RT_DEBUG_TRACE
,("RACFG_CMD_ATE_START_TX_FRAME\n"));
5281 Set_ATE_Proc(pAdapter
, "TXFRAME");
5283 pRaCfg
->length
= htons(2);
5284 pRaCfg
->status
= htons(0);
5286 wrq
->u
.data
.length
= sizeof(pRaCfg
->magic_no
) + sizeof(pRaCfg
->command_type
)
5287 + sizeof(pRaCfg
->command_id
) + sizeof(pRaCfg
->length
)
5288 + sizeof(pRaCfg
->sequence
) + ntohs(pRaCfg
->length
);
5290 ATEDBGPRINT(RT_DEBUG_TRACE
, ("wrq->u.data.length = %d\n", wrq
->u
.data
.length
));
5292 if (copy_to_user(wrq
->u
.data
.pointer
, pRaCfg
, wrq
->u
.data
.length
))
5294 ATEDBGPRINT(RT_DEBUG_ERROR
, ("copy_to_user() fail in case RACFG_CMD_ATE_START_TX_FRAME\n"));
5299 ATEDBGPRINT(RT_DEBUG_TRACE
, ("RACFG_CMD_ATE_START_TX_FRAME is done !\n"));
5304 case RACFG_CMD_ATE_SET_BW
:
5307 UCHAR str
[LEN_OF_ARG
];
5309 NdisZeroMemory(str
, LEN_OF_ARG
);
5311 ATEDBGPRINT(RT_DEBUG_TRACE
,("RACFG_CMD_ATE_SET_BW\n"));
5313 memcpy((PUCHAR
)&value
, (PUCHAR
)&(pRaCfg
->status
), 2);
5314 value
= ntohs(value
);
5315 sprintf((PCHAR
)str
, "%d", value
);
5317 Set_ATE_TX_BW_Proc(pAdapter
, str
);
5320 pRaCfg
->length
= htons(2);
5321 pRaCfg
->status
= htons(0);
5322 wrq
->u
.data
.length
= sizeof(pRaCfg
->magic_no
) + sizeof(pRaCfg
->command_type
)
5323 + sizeof(pRaCfg
->command_id
) + sizeof(pRaCfg
->length
)
5324 + sizeof(pRaCfg
->sequence
) + ntohs(pRaCfg
->length
);
5326 if (copy_to_user(wrq
->u
.data
.pointer
, pRaCfg
, wrq
->u
.data
.length
))
5328 ATEDBGPRINT(RT_DEBUG_ERROR
, ("copy_to_user() fail in case RACFG_CMD_ATE_SET_BW\n"));
5333 ATEDBGPRINT(RT_DEBUG_TRACE
, ("RACFG_CMD_ATE_SET_BW is done !\n"));
5338 case RACFG_CMD_ATE_SET_TX_POWER0
:
5341 UCHAR str
[LEN_OF_ARG
];
5343 NdisZeroMemory(str
, LEN_OF_ARG
);
5345 ATEDBGPRINT(RT_DEBUG_TRACE
,("RACFG_CMD_ATE_SET_TX_POWER0\n"));
5347 memcpy((PUCHAR
)&value
, (PUCHAR
)&(pRaCfg
->status
), 2);
5348 value
= ntohs(value
);
5349 sprintf((PCHAR
)str
, "%d", value
);
5350 Set_ATE_TX_POWER0_Proc(pAdapter
, str
);
5353 pRaCfg
->length
= htons(2);
5354 pRaCfg
->status
= htons(0);
5355 wrq
->u
.data
.length
= sizeof(pRaCfg
->magic_no
) + sizeof(pRaCfg
->command_type
)
5356 + sizeof(pRaCfg
->command_id
) + sizeof(pRaCfg
->length
)
5357 + sizeof(pRaCfg
->sequence
) + ntohs(pRaCfg
->length
);
5359 if (copy_to_user(wrq
->u
.data
.pointer
, pRaCfg
, wrq
->u
.data
.length
))
5361 ATEDBGPRINT(RT_DEBUG_ERROR
, ("copy_to_user() fail in case RACFG_CMD_ATE_SET_TX_POWER0\n"));
5366 ATEDBGPRINT(RT_DEBUG_TRACE
, ("RACFG_CMD_ATE_SET_TX_POWER0 is done !\n"));
5371 case RACFG_CMD_ATE_SET_TX_POWER1
:
5374 UCHAR str
[LEN_OF_ARG
];
5376 NdisZeroMemory(str
, LEN_OF_ARG
);
5378 ATEDBGPRINT(RT_DEBUG_TRACE
,("RACFG_CMD_ATE_SET_TX_POWER1\n"));
5380 memcpy((PUCHAR
)&value
, (PUCHAR
)&(pRaCfg
->status
), 2);
5381 value
= ntohs(value
);
5382 sprintf((PCHAR
)str
, "%d", value
);
5383 Set_ATE_TX_POWER1_Proc(pAdapter
, str
);
5386 pRaCfg
->length
= htons(2);
5387 pRaCfg
->status
= htons(0);
5388 wrq
->u
.data
.length
= sizeof(pRaCfg
->magic_no
) + sizeof(pRaCfg
->command_type
)
5389 + sizeof(pRaCfg
->command_id
) + sizeof(pRaCfg
->length
)
5390 + sizeof(pRaCfg
->sequence
) + ntohs(pRaCfg
->length
);
5392 if (copy_to_user(wrq
->u
.data
.pointer
, pRaCfg
, wrq
->u
.data
.length
))
5394 ATEDBGPRINT(RT_DEBUG_ERROR
, ("copy_to_user() fail in case RACFG_CMD_ATE_SET_TX_POWER1\n"));
5399 ATEDBGPRINT(RT_DEBUG_TRACE
, ("RACFG_CMD_ATE_SET_TX_POWER1 is done !\n"));
5404 case RACFG_CMD_ATE_SET_FREQ_OFFSET
:
5407 UCHAR str
[LEN_OF_ARG
];
5409 NdisZeroMemory(str
, LEN_OF_ARG
);
5411 ATEDBGPRINT(RT_DEBUG_TRACE
,("RACFG_CMD_ATE_SET_FREQ_OFFSET\n"));
5413 memcpy((PUCHAR
)&value
, (PUCHAR
)&(pRaCfg
->status
), 2);
5414 value
= ntohs(value
);
5415 sprintf((PCHAR
)str
, "%d", value
);
5416 Set_ATE_TX_FREQOFFSET_Proc(pAdapter
, str
);
5419 pRaCfg
->length
= htons(2);
5420 pRaCfg
->status
= htons(0);
5421 wrq
->u
.data
.length
= sizeof(pRaCfg
->magic_no
) + sizeof(pRaCfg
->command_type
)
5422 + sizeof(pRaCfg
->command_id
) + sizeof(pRaCfg
->length
)
5423 + sizeof(pRaCfg
->sequence
) + ntohs(pRaCfg
->length
);
5425 if (copy_to_user(wrq
->u
.data
.pointer
, pRaCfg
, wrq
->u
.data
.length
))
5427 ATEDBGPRINT(RT_DEBUG_ERROR
, ("copy_to_user() fail in case RACFG_CMD_ATE_SET_FREQ_OFFSET\n"));
5432 ATEDBGPRINT(RT_DEBUG_TRACE
, ("RACFG_CMD_ATE_SET_FREQ_OFFSET is done !\n"));
5437 case RACFG_CMD_ATE_GET_STATISTICS
:
5439 ATEDBGPRINT(RT_DEBUG_TRACE
,("RACFG_CMD_ATE_GET_STATISTICS\n"));
5441 memcpy_exl(pAdapter
, &pRaCfg
->data
[0], (UCHAR
*)&pAdapter
->ate
.TxDoneCount
, 4);
5442 memcpy_exl(pAdapter
, &pRaCfg
->data
[4], (UCHAR
*)&pAdapter
->WlanCounters
.RetryCount
.u
.LowPart
, 4);
5443 memcpy_exl(pAdapter
, &pRaCfg
->data
[8], (UCHAR
*)&pAdapter
->WlanCounters
.FailedCount
.u
.LowPart
, 4);
5444 memcpy_exl(pAdapter
, &pRaCfg
->data
[12], (UCHAR
*)&pAdapter
->WlanCounters
.RTSSuccessCount
.u
.LowPart
, 4);
5445 memcpy_exl(pAdapter
, &pRaCfg
->data
[16], (UCHAR
*)&pAdapter
->WlanCounters
.RTSFailureCount
.u
.LowPart
, 4);
5446 memcpy_exl(pAdapter
, &pRaCfg
->data
[20], (UCHAR
*)&pAdapter
->WlanCounters
.ReceivedFragmentCount
.QuadPart
, 4);
5447 memcpy_exl(pAdapter
, &pRaCfg
->data
[24], (UCHAR
*)&pAdapter
->WlanCounters
.FCSErrorCount
.u
.LowPart
, 4);
5448 memcpy_exl(pAdapter
, &pRaCfg
->data
[28], (UCHAR
*)&pAdapter
->Counters8023
.RxNoBuffer
, 4);
5449 memcpy_exl(pAdapter
, &pRaCfg
->data
[32], (UCHAR
*)&pAdapter
->WlanCounters
.FrameDuplicateCount
.u
.LowPart
, 4);
5450 memcpy_exl(pAdapter
, &pRaCfg
->data
[36], (UCHAR
*)&pAdapter
->RalinkCounters
.OneSecFalseCCACnt
, 4);
5452 if (pAdapter
->ate
.RxAntennaSel
== 0)
5458 RSSI0
= (INT32
)(pAdapter
->ate
.LastRssi0
- pAdapter
->BbpRssiToDbmDelta
);
5459 RSSI1
= (INT32
)(pAdapter
->ate
.LastRssi1
- pAdapter
->BbpRssiToDbmDelta
);
5460 RSSI2
= (INT32
)(pAdapter
->ate
.LastRssi2
- pAdapter
->BbpRssiToDbmDelta
);
5461 memcpy_exl(pAdapter
, &pRaCfg
->data
[40], (UCHAR
*)&RSSI0
, 4);
5462 memcpy_exl(pAdapter
, &pRaCfg
->data
[44], (UCHAR
*)&RSSI1
, 4);
5463 memcpy_exl(pAdapter
, &pRaCfg
->data
[48], (UCHAR
*)&RSSI2
, 4);
5464 pRaCfg
->length
= htons(2+52);
5470 RSSI0
= (INT32
)(pAdapter
->ate
.LastRssi0
- pAdapter
->BbpRssiToDbmDelta
);
5471 memcpy_exl(pAdapter
, &pRaCfg
->data
[40], (UCHAR
*)&RSSI0
, 4);
5472 pRaCfg
->length
= htons(2+44);
5474 pRaCfg
->status
= htons(0);
5475 wrq
->u
.data
.length
= sizeof(pRaCfg
->magic_no
) + sizeof(pRaCfg
->command_type
)
5476 + sizeof(pRaCfg
->command_id
) + sizeof(pRaCfg
->length
)
5477 + sizeof(pRaCfg
->sequence
) + ntohs(pRaCfg
->length
);
5479 if (copy_to_user(wrq
->u
.data
.pointer
, pRaCfg
, wrq
->u
.data
.length
))
5481 ATEDBGPRINT(RT_DEBUG_ERROR
, ("copy_to_user() fail in case RACFG_CMD_ATE_GET_STATISTICS\n"));
5486 ATEDBGPRINT(RT_DEBUG_TRACE
, ("RACFG_CMD_ATE_GET_STATISTICS is done !\n"));
5491 case RACFG_CMD_ATE_RESET_COUNTER
:
5494 UCHAR str
[LEN_OF_ARG
];
5496 NdisZeroMemory(str
, LEN_OF_ARG
);
5498 ATEDBGPRINT(RT_DEBUG_TRACE
,("RACFG_CMD_ATE_RESET_COUNTER\n"));
5500 sprintf((PCHAR
)str
, "%d", value
);
5501 Set_ResetStatCounter_Proc(pAdapter
, str
);
5503 pAdapter
->ate
.TxDoneCount
= 0;
5505 pRaCfg
->length
= htons(2);
5506 pRaCfg
->status
= htons(0);
5508 wrq
->u
.data
.length
= sizeof(pRaCfg
->magic_no
) + sizeof(pRaCfg
->command_type
)
5509 + sizeof(pRaCfg
->command_id
) + sizeof(pRaCfg
->length
)
5510 + sizeof(pRaCfg
->sequence
) + ntohs(pRaCfg
->length
);
5512 if (copy_to_user(wrq
->u
.data
.pointer
, pRaCfg
, wrq
->u
.data
.length
))
5514 ATEDBGPRINT(RT_DEBUG_ERROR
, ("copy_to_user() fail in case RACFG_CMD_ATE_RESET_COUNTER\n"));
5519 ATEDBGPRINT(RT_DEBUG_TRACE
, ("RACFG_CMD_ATE_RESET_COUNTER is done !\n"));
5525 case RACFG_CMD_ATE_SEL_TX_ANTENNA
:
5528 UCHAR str
[LEN_OF_ARG
];
5530 NdisZeroMemory(str
, LEN_OF_ARG
);
5532 ATEDBGPRINT(RT_DEBUG_TRACE
,("RACFG_CMD_ATE_SEL_TX_ANTENNA\n"));
5534 memcpy((PUCHAR
)&value
, (PUCHAR
)&(pRaCfg
->status
), 2);
5535 value
= ntohs(value
);
5536 sprintf((PCHAR
)str
, "%d", value
);
5537 Set_ATE_TX_Antenna_Proc(pAdapter
, str
);
5540 pRaCfg
->length
= htons(2);
5541 pRaCfg
->status
= htons(0);
5542 wrq
->u
.data
.length
= sizeof(pRaCfg
->magic_no
) + sizeof(pRaCfg
->command_type
)
5543 + sizeof(pRaCfg
->command_id
) + sizeof(pRaCfg
->length
)
5544 + sizeof(pRaCfg
->sequence
) + ntohs(pRaCfg
->length
);
5546 if (copy_to_user(wrq
->u
.data
.pointer
, pRaCfg
, wrq
->u
.data
.length
))
5548 ATEDBGPRINT(RT_DEBUG_ERROR
, ("copy_to_user() fail in case RACFG_CMD_ATE_SEL_TX_ANTENNA\n"));
5553 ATEDBGPRINT(RT_DEBUG_TRACE
, ("RACFG_CMD_ATE_SEL_TX_ANTENNA is done !\n"));
5558 case RACFG_CMD_ATE_SEL_RX_ANTENNA
:
5561 UCHAR str
[LEN_OF_ARG
];
5563 NdisZeroMemory(str
, LEN_OF_ARG
);
5565 ATEDBGPRINT(RT_DEBUG_TRACE
,("RACFG_CMD_ATE_SEL_RX_ANTENNA\n"));
5567 memcpy((PUCHAR
)&value
, (PUCHAR
)&(pRaCfg
->status
), 2);
5568 value
= ntohs(value
);
5569 sprintf((PCHAR
)str
, "%d", value
);
5570 Set_ATE_RX_Antenna_Proc(pAdapter
, str
);
5573 pRaCfg
->length
= htons(2);
5574 pRaCfg
->status
= htons(0);
5575 wrq
->u
.data
.length
= sizeof(pRaCfg
->magic_no
) + sizeof(pRaCfg
->command_type
)
5576 + sizeof(pRaCfg
->command_id
) + sizeof(pRaCfg
->length
)
5577 + sizeof(pRaCfg
->sequence
) + ntohs(pRaCfg
->length
);
5579 if (copy_to_user(wrq
->u
.data
.pointer
, pRaCfg
, wrq
->u
.data
.length
))
5581 ATEDBGPRINT(RT_DEBUG_ERROR
, ("copy_to_user() fail in case RACFG_CMD_ATE_SEL_RX_ANTENNA\n"));
5586 ATEDBGPRINT(RT_DEBUG_TRACE
, ("RACFG_CMD_ATE_SEL_RX_ANTENNA is done !\n"));
5591 case RACFG_CMD_ATE_SET_PREAMBLE
:
5594 UCHAR str
[LEN_OF_ARG
];
5596 NdisZeroMemory(str
, LEN_OF_ARG
);
5598 ATEDBGPRINT(RT_DEBUG_TRACE
,("RACFG_CMD_ATE_SET_PREAMBLE\n"));
5600 memcpy((PUCHAR
)&value
, (PUCHAR
)&(pRaCfg
->status
), 2);
5601 value
= ntohs(value
);
5602 sprintf((PCHAR
)str
, "%d", value
);
5603 Set_ATE_TX_MODE_Proc(pAdapter
, str
);
5606 pRaCfg
->length
= htons(2);
5607 pRaCfg
->status
= htons(0);
5608 wrq
->u
.data
.length
= sizeof(pRaCfg
->magic_no
) + sizeof(pRaCfg
->command_type
)
5609 + sizeof(pRaCfg
->command_id
) + sizeof(pRaCfg
->length
)
5610 + sizeof(pRaCfg
->sequence
) + ntohs(pRaCfg
->length
);
5612 if (copy_to_user(wrq
->u
.data
.pointer
, pRaCfg
, wrq
->u
.data
.length
))
5614 ATEDBGPRINT(RT_DEBUG_ERROR
, ("copy_to_user() fail in case RACFG_CMD_ATE_SET_PREAMBLE\n"));
5619 ATEDBGPRINT(RT_DEBUG_TRACE
, ("RACFG_CMD_ATE_SET_PREAMBLE is done !\n"));
5624 case RACFG_CMD_ATE_SET_CHANNEL
:
5627 UCHAR str
[LEN_OF_ARG
];
5629 NdisZeroMemory(str
, LEN_OF_ARG
);
5631 ATEDBGPRINT(RT_DEBUG_TRACE
,("RACFG_CMD_ATE_SET_CHANNEL\n"));
5633 memcpy((PUCHAR
)&value
, (PUCHAR
)&(pRaCfg
->status
), 2);
5634 value
= ntohs(value
);
5635 sprintf((PCHAR
)str
, "%d", value
);
5636 Set_ATE_CHANNEL_Proc(pAdapter
, str
);
5639 pRaCfg
->length
= htons(2);
5640 pRaCfg
->status
= htons(0);
5641 wrq
->u
.data
.length
= sizeof(pRaCfg
->magic_no
) + sizeof(pRaCfg
->command_type
)
5642 + sizeof(pRaCfg
->command_id
) + sizeof(pRaCfg
->length
)
5643 + sizeof(pRaCfg
->sequence
) + ntohs(pRaCfg
->length
);
5645 if (copy_to_user(wrq
->u
.data
.pointer
, pRaCfg
, wrq
->u
.data
.length
))
5647 ATEDBGPRINT(RT_DEBUG_ERROR
, ("copy_to_user() fail in case RACFG_CMD_ATE_SET_CHANNEL\n"));
5652 ATEDBGPRINT(RT_DEBUG_TRACE
, ("RACFG_CMD_ATE_SET_CHANNEL is done !\n"));
5657 case RACFG_CMD_ATE_SET_ADDR1
:
5659 ATEDBGPRINT(RT_DEBUG_TRACE
,("RACFG_CMD_ATE_SET_ADDR1\n"));
5661 // Addr is an array of UCHAR,
5662 // so no need to perform endian swap.
5663 memcpy(pAdapter
->ate
.Addr1
, (PUCHAR
)(pRaCfg
->data
- 2), MAC_ADDR_LEN
);
5666 pRaCfg
->length
= htons(2);
5667 pRaCfg
->status
= htons(0);
5668 wrq
->u
.data
.length
= sizeof(pRaCfg
->magic_no
) + sizeof(pRaCfg
->command_type
)
5669 + sizeof(pRaCfg
->command_id
) + sizeof(pRaCfg
->length
)
5670 + sizeof(pRaCfg
->sequence
) + ntohs(pRaCfg
->length
);
5672 if (copy_to_user(wrq
->u
.data
.pointer
, pRaCfg
, wrq
->u
.data
.length
))
5674 ATEDBGPRINT(RT_DEBUG_ERROR
, ("copy_to_user() fail in case RACFG_CMD_ATE_SET_ADDR1\n"));
5679 ATEDBGPRINT(RT_DEBUG_TRACE
, ("RACFG_CMD_ATE_SET_ADDR1 is done !\n (ADDR1 = %2X:%2X:%2X:%2X:%2X:%2X)\n", pAdapter
->ate
.Addr1
[0],
5680 pAdapter
->ate
.Addr1
[1], pAdapter
->ate
.Addr1
[2], pAdapter
->ate
.Addr1
[3], pAdapter
->ate
.Addr1
[4], pAdapter
->ate
.Addr1
[5]));
5685 case RACFG_CMD_ATE_SET_ADDR2
:
5687 ATEDBGPRINT(RT_DEBUG_TRACE
,("RACFG_CMD_ATE_SET_ADDR2\n"));
5689 // Addr is an array of UCHAR,
5690 // so no need to perform endian swap.
5691 memcpy(pAdapter
->ate
.Addr2
, (PUCHAR
)(pRaCfg
->data
- 2), MAC_ADDR_LEN
);
5694 pRaCfg
->length
= htons(2);
5695 pRaCfg
->status
= htons(0);
5696 wrq
->u
.data
.length
= sizeof(pRaCfg
->magic_no
) + sizeof(pRaCfg
->command_type
)
5697 + sizeof(pRaCfg
->command_id
) + sizeof(pRaCfg
->length
)
5698 + sizeof(pRaCfg
->sequence
) + ntohs(pRaCfg
->length
);
5700 if (copy_to_user(wrq
->u
.data
.pointer
, pRaCfg
, wrq
->u
.data
.length
))
5702 ATEDBGPRINT(RT_DEBUG_ERROR
, ("copy_to_user() fail in case RACFG_CMD_ATE_SET_ADDR2\n"));
5707 ATEDBGPRINT(RT_DEBUG_TRACE
, ("RACFG_CMD_ATE_SET_ADDR2 is done !\n (ADDR2 = %2X:%2X:%2X:%2X:%2X:%2X)\n", pAdapter
->ate
.Addr2
[0],
5708 pAdapter
->ate
.Addr2
[1], pAdapter
->ate
.Addr2
[2], pAdapter
->ate
.Addr2
[3], pAdapter
->ate
.Addr2
[4], pAdapter
->ate
.Addr2
[5]));
5713 case RACFG_CMD_ATE_SET_ADDR3
:
5715 ATEDBGPRINT(RT_DEBUG_TRACE
,("RACFG_CMD_ATE_SET_ADDR3\n"));
5717 // Addr is an array of UCHAR,
5718 // so no need to perform endian swap.
5719 memcpy(pAdapter
->ate
.Addr3
, (PUCHAR
)(pRaCfg
->data
- 2), MAC_ADDR_LEN
);
5722 pRaCfg
->length
= htons(2);
5723 pRaCfg
->status
= htons(0);
5724 wrq
->u
.data
.length
= sizeof(pRaCfg
->magic_no
) + sizeof(pRaCfg
->command_type
)
5725 + sizeof(pRaCfg
->command_id
) + sizeof(pRaCfg
->length
)
5726 + sizeof(pRaCfg
->sequence
) + ntohs(pRaCfg
->length
);
5728 if (copy_to_user(wrq
->u
.data
.pointer
, pRaCfg
, wrq
->u
.data
.length
))
5730 ATEDBGPRINT(RT_DEBUG_ERROR
, ("copy_to_user() fail in case RACFG_CMD_ATE_SET_ADDR3\n"));
5735 ATEDBGPRINT(RT_DEBUG_TRACE
, ("RACFG_CMD_ATE_SET_ADDR3 is done !\n (ADDR3 = %2X:%2X:%2X:%2X:%2X:%2X)\n", pAdapter
->ate
.Addr3
[0],
5736 pAdapter
->ate
.Addr3
[1], pAdapter
->ate
.Addr3
[2], pAdapter
->ate
.Addr3
[3], pAdapter
->ate
.Addr3
[4], pAdapter
->ate
.Addr3
[5]));
5741 case RACFG_CMD_ATE_SET_RATE
:
5744 UCHAR str
[LEN_OF_ARG
];
5746 NdisZeroMemory(str
, LEN_OF_ARG
);
5748 ATEDBGPRINT(RT_DEBUG_TRACE
,("RACFG_CMD_ATE_SET_RATE\n"));
5750 memcpy((PUCHAR
)&value
, (PUCHAR
)&(pRaCfg
->status
), 2);
5751 value
= ntohs(value
);
5752 sprintf((PCHAR
)str
, "%d", value
);
5753 Set_ATE_TX_MCS_Proc(pAdapter
, str
);
5756 pRaCfg
->length
= htons(2);
5757 pRaCfg
->status
= htons(0);
5758 wrq
->u
.data
.length
= sizeof(pRaCfg
->magic_no
) + sizeof(pRaCfg
->command_type
)
5759 + sizeof(pRaCfg
->command_id
) + sizeof(pRaCfg
->length
)
5760 + sizeof(pRaCfg
->sequence
) + ntohs(pRaCfg
->length
);
5762 if (copy_to_user(wrq
->u
.data
.pointer
, pRaCfg
, wrq
->u
.data
.length
))
5764 ATEDBGPRINT(RT_DEBUG_ERROR
, ("copy_to_user() fail in case RACFG_CMD_ATE_SET_RATE\n"));
5769 ATEDBGPRINT(RT_DEBUG_TRACE
, ("RACFG_CMD_ATE_SET_RATE is done !\n"));
5774 case RACFG_CMD_ATE_SET_TX_FRAME_LEN
:
5777 UCHAR str
[LEN_OF_ARG
];
5779 NdisZeroMemory(str
, LEN_OF_ARG
);
5781 ATEDBGPRINT(RT_DEBUG_TRACE
,("RACFG_CMD_ATE_SET_TX_FRAME_LEN\n"));
5783 memcpy((PUCHAR
)&value
, (PUCHAR
)&(pRaCfg
->status
), 2);
5784 value
= ntohs(value
);
5785 sprintf((PCHAR
)str
, "%d", value
);
5786 Set_ATE_TX_LENGTH_Proc(pAdapter
, str
);
5789 pRaCfg
->length
= htons(2);
5790 pRaCfg
->status
= htons(0);
5791 wrq
->u
.data
.length
= sizeof(pRaCfg
->magic_no
) + sizeof(pRaCfg
->command_type
)
5792 + sizeof(pRaCfg
->command_id
) + sizeof(pRaCfg
->length
)
5793 + sizeof(pRaCfg
->sequence
) + ntohs(pRaCfg
->length
);
5795 if (copy_to_user(wrq
->u
.data
.pointer
, pRaCfg
, wrq
->u
.data
.length
))
5797 ATEDBGPRINT(RT_DEBUG_ERROR
, ("copy_to_user() fail in case RACFG_CMD_ATE_SET_TX_FRAME_LEN\n"));
5802 ATEDBGPRINT(RT_DEBUG_TRACE
, ("RACFG_CMD_ATE_SET_TX_FRAME_LEN is done !\n"));
5807 case RACFG_CMD_ATE_SET_TX_FRAME_COUNT
:
5810 UCHAR str
[LEN_OF_ARG
];
5812 NdisZeroMemory(str
, LEN_OF_ARG
);
5814 ATEDBGPRINT(RT_DEBUG_TRACE
,("RACFG_CMD_ATE_SET_TX_FRAME_COUNT\n"));
5816 memcpy((PUCHAR
)&value
, (PUCHAR
)&(pRaCfg
->status
), 2);
5817 value
= ntohs(value
);
5819 sprintf((PCHAR
)str
, "%d", value
);
5820 Set_ATE_TX_COUNT_Proc(pAdapter
, str
);
5824 pRaCfg
->length
= htons(2);
5825 pRaCfg
->status
= htons(0);
5826 wrq
->u
.data
.length
= sizeof(pRaCfg
->magic_no
) + sizeof(pRaCfg
->command_type
)
5827 + sizeof(pRaCfg
->command_id
) + sizeof(pRaCfg
->length
)
5828 + sizeof(pRaCfg
->sequence
) + ntohs(pRaCfg
->length
);
5830 if (copy_to_user(wrq
->u
.data
.pointer
, pRaCfg
, wrq
->u
.data
.length
))
5832 ATEDBGPRINT(RT_DEBUG_ERROR
, ("copy_to_user() fail in case RACFG_CMD_ATE_SET_TX_FRAME_COUNT\n"));
5837 ATEDBGPRINT(RT_DEBUG_TRACE
, ("RACFG_CMD_ATE_SET_TX_FRAME_COUNT is done !\n"));
5842 case RACFG_CMD_ATE_START_RX_FRAME
:
5844 ATEDBGPRINT(RT_DEBUG_TRACE
,("RACFG_CMD_RX_START\n"));
5846 Set_ATE_Proc(pAdapter
, "RXFRAME");
5849 pRaCfg
->length
= htons(2);
5850 pRaCfg
->status
= htons(0);
5851 wrq
->u
.data
.length
= sizeof(pRaCfg
->magic_no
) + sizeof(pRaCfg
->command_type
)
5852 + sizeof(pRaCfg
->command_id
) + sizeof(pRaCfg
->length
)
5853 + sizeof(pRaCfg
->sequence
) + ntohs(pRaCfg
->length
);
5855 if (copy_to_user(wrq
->u
.data
.pointer
, pRaCfg
, wrq
->u
.data
.length
))
5857 ATEDBGPRINT(RT_DEBUG_ERROR
, ("copy_to_user() fail in case RACFG_CMD_RX_START\n"));
5862 ATEDBGPRINT(RT_DEBUG_TRACE
, ("RACFG_CMD_RX_START is done !\n"));
5869 ASSERT(pRaCfg
!= NULL
);
5877 VOID
BubbleSort(INT32 n
, INT32 a
[])
5881 for (k
= n
-1; k
>0; k
--)
5883 for (j
= 0; j
<k
; j
++)
5895 VOID
CalNoiseLevel(PRTMP_ADAPTER pAd
, UCHAR channel
, INT32 RSSI
[3][10])
5897 INT32 RSSI0
, RSSI1
, RSSI2
;
5898 CHAR Rssi0Offset
, Rssi1Offset
, Rssi2Offset
;
5899 UCHAR BbpR50Rssi0
= 0, BbpR51Rssi1
= 0, BbpR52Rssi2
= 0;
5900 UCHAR Org_BBP66value
= 0, Org_BBP69value
= 0, Org_BBP70value
= 0, data
= 0;
5901 USHORT LNA_Gain
= 0;
5903 UCHAR Org_Channel
= pAd
->ate
.Channel
;
5904 USHORT GainValue
= 0, OffsetValue
= 0;
5906 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R66
, &Org_BBP66value
);
5907 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R69
, &Org_BBP69value
);
5908 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R70
, &Org_BBP70value
);
5910 //**********************************************************************
5911 // Read the value of LNA gain and Rssi offset
5912 //**********************************************************************
5913 RT28xx_EEPROM_READ16(pAd
, EEPROM_LNA_OFFSET
, GainValue
);
5918 LNA_Gain
= GainValue
& 0x00FF;
5920 RT28xx_EEPROM_READ16(pAd
, EEPROM_RSSI_BG_OFFSET
, OffsetValue
);
5921 Rssi0Offset
= OffsetValue
& 0x00FF;
5922 Rssi1Offset
= (OffsetValue
& 0xFF00) >> 8;
5923 RT28xx_EEPROM_READ16(pAd
, (EEPROM_RSSI_BG_OFFSET
+ 2)/* 0x48 */, OffsetValue
);
5924 Rssi2Offset
= OffsetValue
& 0x00FF;
5928 LNA_Gain
= (GainValue
& 0xFF00) >> 8;
5930 RT28xx_EEPROM_READ16(pAd
, EEPROM_RSSI_A_OFFSET
, OffsetValue
);
5931 Rssi0Offset
= OffsetValue
& 0x00FF;
5932 Rssi1Offset
= (OffsetValue
& 0xFF00) >> 8;
5933 RT28xx_EEPROM_READ16(pAd
, (EEPROM_RSSI_A_OFFSET
+ 2)/* 0x4C */, OffsetValue
);
5934 Rssi2Offset
= OffsetValue
& 0x00FF;
5936 //**********************************************************************
5938 pAd
->ate
.Channel
= channel
;
5939 ATEAsicSwitchChannel(pAd
);
5943 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R66
, data
);
5945 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R69
, data
);
5947 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R70
, data
);
5951 pAd
->ate
.bQARxStart
= TRUE
;
5952 Set_ATE_Proc(pAd
, "RXFRAME");
5956 for (j
= 0; j
< 10; j
++)
5958 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R50
, &BbpR50Rssi0
);
5959 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R51
, &BbpR51Rssi1
);
5960 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R52
, &BbpR52Rssi2
);
5965 if (BbpR50Rssi0
== 0)
5971 RSSI0
= (INT32
)(-12 - BbpR50Rssi0
- LNA_Gain
- Rssi0Offset
);
5975 if ( pAd
->Antenna
.field
.RxPath
>= 2 ) // 2R
5978 if (BbpR51Rssi1
== 0)
5984 RSSI1
= (INT32
)(-12 - BbpR51Rssi1
- LNA_Gain
- Rssi1Offset
);
5989 if ( pAd
->Antenna
.field
.RxPath
>= 3 ) // 3R
5992 if (BbpR52Rssi2
== 0)
5995 RSSI2
= (INT32
)(-12 - BbpR52Rssi2
- LNA_Gain
- Rssi2Offset
);
6002 Set_ATE_Proc(pAd
, "RXSTOP");
6006 #if 0// Debug Message................
6007 ate_print("\n**********************************************************\n");
6008 ate_print("Noise Level: Channel %d\n", channel
);
6009 ate_print("RSSI0 = %d, %d, %d, %d, %d, %d, %d, %d, %d, %d\n",
6010 RSSI
[0][0], RSSI
[0][1], RSSI
[0][2],
6011 RSSI
[0][3], RSSI
[0][4], RSSI
[0][5],
6012 RSSI
[0][6], RSSI
[0][7], RSSI
[0][8],
6014 if ( pAd
->Antenna
.field
.RxPath
>= 2 ) // 2R
6016 ate_print("RSSI1 = %d, %d, %d, %d, %d, %d, %d, %d, %d, %d\n",
6017 RSSI
[1][0], RSSI
[1][1], RSSI
[1][2],
6018 RSSI
[1][3], RSSI
[1][4], RSSI
[1][5],
6019 RSSI
[1][6], RSSI
[1][7], RSSI
[1][8],
6022 if ( pAd
->Antenna
.field
.RxPath
>= 3 ) // 3R
6024 ate_print("RSSI2 = %d, %d, %d, %d, %d, %d, %d, %d, %d, %d\n",
6025 RSSI
[2][0], RSSI
[2][1], RSSI
[2][2],
6026 RSSI
[2][3], RSSI
[2][4], RSSI
[2][5],
6027 RSSI
[2][6], RSSI
[2][7], RSSI
[2][8],
6031 BubbleSort(10, RSSI
[0]); // 1R
6033 if ( pAd
->Antenna
.field
.RxPath
>= 2 ) // 2R
6035 BubbleSort(10, RSSI
[1]);
6038 if ( pAd
->Antenna
.field
.RxPath
>= 3 ) // 3R
6040 BubbleSort(10, RSSI
[2]);
6043 #if 0// Debug Message................
6044 ate_print("\nAfter Sorting....Channel %d\n", channel
);
6045 ate_print("RSSI0 = %d, %d, %d, %d, %d, %d, %d, %d, %d, %d\n",
6046 RSSI
[0][0], RSSI
[0][1], RSSI
[0][2],
6047 RSSI
[0][3], RSSI
[0][4], RSSI
[0][5],
6048 RSSI
[0][6], RSSI
[0][7], RSSI
[0][8],
6050 if ( pAd
->Antenna
.field
.RxPath
>= 2 ) // 2R
6052 ate_print("RSSI1 = %d, %d, %d, %d, %d, %d, %d, %d, %d, %d\n",
6053 RSSI
[1][0], RSSI
[1][1], RSSI
[1][2],
6054 RSSI
[1][3], RSSI
[1][4], RSSI
[1][5],
6055 RSSI
[1][6], RSSI
[1][7], RSSI
[1][8],
6058 if ( pAd
->Antenna
.field
.RxPath
>= 3 ) // 3R
6060 ate_print("RSSI2 = %d, %d, %d, %d, %d, %d, %d, %d, %d, %d\n",
6061 RSSI
[2][0], RSSI
[2][1], RSSI
[2][2],
6062 RSSI
[2][3], RSSI
[2][4], RSSI
[2][5],
6063 RSSI
[2][6], RSSI
[2][7], RSSI
[2][8],
6066 ate_print("**********************************************************\n");
6070 pAd
->ate
.Channel
= Org_Channel
;
6071 ATEAsicSwitchChannel(pAd
);
6073 // Restore original value
6074 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R66
, Org_BBP66value
);
6075 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R69
, Org_BBP69value
);
6076 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R70
, Org_BBP70value
);
6081 BOOLEAN
SyncTxRxConfig(PRTMP_ADAPTER pAd
, USHORT offset
, UCHAR value
)
6083 UCHAR tmp
= 0, bbp_data
= 0;
6087 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, offset
, &bbp_data
);
6091 RTMP_BBP_IO_READ8_BY_REG_ID(pAd
, offset
, &bbp_data
);
6095 ASSERT(bbp_data
== value
);
6100 /* Need to sync. tx configuration with legacy ATE. */
6101 tmp
= (bbp_data
& ((1 << 4) | (1 << 3))/* 0x18 */) >> 3;
6104 /* The BBP R1 bit[4:3] = 2 :: Both DACs will be used by QA. */
6107 pAd
->ate
.TxAntennaSel
= 0;
6109 /* The BBP R1 bit[4:3] = 0 :: DAC 0 will be used by QA. */
6112 pAd
->ate
.TxAntennaSel
= 1;
6114 /* The BBP R1 bit[4:3] = 1 :: DAC 1 will be used by QA. */
6117 pAd
->ate
.TxAntennaSel
= 2;
6120 DBGPRINT(RT_DEBUG_TRACE
, ("%s -- Sth. wrong! : return FALSE; \n", __func__
));
6123 break;/* case BBP_R1 */
6126 /* Need to sync. rx configuration with legacy ATE. */
6127 tmp
= (bbp_data
& ((1 << 1) | (1 << 0))/* 0x03 */);
6130 /* The BBP R3 bit[1:0] = 3 :: All ADCs will be used by QA. */
6133 pAd
->ate
.RxAntennaSel
= 0;
6135 /* The BBP R3 bit[1:0] = 0 :: ADC 0 will be used by QA, */
6136 /* unless the BBP R3 bit[4:3] = 2 */
6139 pAd
->ate
.RxAntennaSel
= 1;
6140 tmp
= ((bbp_data
& ((1 << 4) | (1 << 3))/* 0x03 */) >> 3);
6143 /* Default : All ADCs will be used by QA */
6144 pAd
->ate
.RxAntennaSel
= 0;
6147 /* The BBP R3 bit[1:0] = 1 :: ADC 1 will be used by QA. */
6150 pAd
->ate
.RxAntennaSel
= 2;
6152 /* The BBP R3 bit[1:0] = 2 :: ADC 2 will be used by QA. */
6155 pAd
->ate
.RxAntennaSel
= 3;
6158 DBGPRINT(RT_DEBUG_ERROR
, ("%s -- Impossible! : return FALSE; \n", __func__
));
6161 break;/* case BBP_R3 */
6164 DBGPRINT(RT_DEBUG_ERROR
, ("%s -- Sth. wrong! : return FALSE; \n", __func__
));
6171 static VOID
memcpy_exl(PRTMP_ADAPTER pAd
, UCHAR
*dst
, UCHAR
*src
, ULONG len
)
6178 pDst
= (ULONG
*) dst
;
6179 pSrc
= (ULONG
*) src
;
6181 for (i
= 0 ; i
< (len
/4); i
++)
6183 /* For alignment issue, we need a variable "Value". */
6184 memmove(&Value
, pSrc
, 4);
6185 Value
= htonl(Value
);
6186 memmove(pDst
, &Value
, 4);
6192 /* wish that it will never reach here */
6193 memmove(&Value
, pSrc
, (len
% 4));
6194 Value
= htonl(Value
);
6195 memmove(pDst
, &Value
, (len
% 4));
6199 static VOID
memcpy_exs(PRTMP_ADAPTER pAd
, UCHAR
*dst
, UCHAR
*src
, ULONG len
)
6207 for (i
= 0; i
< (len
/2); i
++)
6209 memmove(pDst
, pSrc
, 2);
6210 *((USHORT
*)pDst
) = htons(*((USHORT
*)pDst
));
6217 memmove(pDst
, pSrc
, 1);
6221 static VOID
RTMP_IO_READ_BULK(PRTMP_ADAPTER pAd
, UCHAR
*dst
, UCHAR
*src
, UINT32 len
)
6224 UINT32
*pDst
, *pSrc
;
6226 pDst
= (UINT32
*) dst
;
6227 pSrc
= (UINT32
*) src
;
6229 for (i
= 0 ; i
< (len
/4); i
++)
6231 RTMP_IO_READ32(pAd
, (ULONG
)pSrc
, &Value
);
6232 Value
= htonl(Value
);
6233 memmove(pDst
, &Value
, 4);
6242 /* These work only when RALINK_ATE is defined */
6243 INT
Set_TxStart_Proc(
6244 IN PRTMP_ADAPTER pAd
,
6247 ULONG value
= simple_strtol(arg
, 0, 10);
6248 UCHAR buffer
[26] = {0x88, 0x02, 0x2c, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x00, 0x55, 0x44, 0x33, 0x22, 0x11, 0xc0, 0x22, 0x00, 0x00};
6251 if (pAd
->ate
.TxStatus
!= 0)
6254 pAd
->ate
.TxInfo
= 0x04000000;
6255 bzero(&pAd
->ate
.TxWI
, sizeof(TXWI_STRUC
));
6256 pAd
->ate
.TxWI
.PHYMODE
= 0;// MODE_CCK
6257 pAd
->ate
.TxWI
.MPDUtotalByteCount
= 1226;
6258 pAd
->ate
.TxWI
.MCS
= 3;
6259 //pAd->ate.Mode = ATE_START;
6260 pAd
->ate
.Mode
|= ATE_TXFRAME
;
6261 pAd
->ate
.TxCount
= value
;
6265 pAd
->ate
.DLen
= 1200;
6266 memcpy(pAd
->ate
.Header
, buffer
, 26);
6267 pAd
->ate
.bQATxStart
= TRUE
;
6268 //pObj = (POS_COOKIE) pAd->OS_Cookie;
6269 //tasklet_hi_schedule(&pObj->AteTxTask);
6272 #endif /* end of #if 0 */
6274 INT
Set_TxStop_Proc(
6275 IN PRTMP_ADAPTER pAd
,
6278 ATEDBGPRINT(RT_DEBUG_TRACE
,("Set_TxStop_Proc\n"));
6280 if (Set_ATE_Proc(pAd
, "TXSTOP"))
6290 INT
Set_RxStop_Proc(
6291 IN PRTMP_ADAPTER pAd
,
6294 ATEDBGPRINT(RT_DEBUG_TRACE
,("Set_RxStop_Proc\n"));
6296 if (Set_ATE_Proc(pAd
, "RXSTOP"))
6307 INT
Set_EEWrite_Proc(
6308 IN PRTMP_ADAPTER pAd
,
6311 USHORT offset
= 0, value
;
6314 while((*p2
!= ':') && (*p2
!= '\0'))
6322 A2Hex(value
, p2
+ 1);
6329 if (offset
>= EEPROM_SIZE
)
6331 ate_print("Offset can not exceed EEPROM_SIZE( == 0x%04x)\n", EEPROM_SIZE
);
6335 RTMP_EEPROM_WRITE16(pAd
, offset
, value
);
6340 INT
Set_BBPRead_Proc(
6341 IN PRTMP_ADAPTER pAd
,
6344 UCHAR value
= 0, offset
;
6350 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, offset
, &value
);
6354 RTMP_BBP_IO_READ8_BY_REG_ID(pAd
, offset
, &value
);
6357 ate_print("%x\n", value
);
6363 INT
Set_BBPWrite_Proc(
6364 IN PRTMP_ADAPTER pAd
,
6371 while((*p2
!= ':') && (*p2
!= '\0'))
6379 A2Hex(value
, p2
+ 1);
6388 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, offset
, value
);
6392 RTNP_BBP_IO_WRITE8_BY_REG_ID(pAd
, offset
, value
);
6398 INT
Set_RFWrite_Proc(
6399 IN PRTMP_ADAPTER pAd
,
6403 ULONG R1
, R2
, R3
, R4
;
6407 while((*p2
!= ':') && (*p2
!= '\0'))
6417 while((*p3
!= ':') && (*p3
!= '\0'))
6427 while((*p4
!= ':') && (*p4
!= '\0'))
6441 RTMP_RF_IO_WRITE32(pAd
, R1
);
6442 RTMP_RF_IO_WRITE32(pAd
, R2
);
6443 RTMP_RF_IO_WRITE32(pAd
, R3
);
6444 RTMP_RF_IO_WRITE32(pAd
, R4
);
6448 #endif // end of #if 0 //
6449 #endif // RALINK_28xx_QA //
6451 #endif // RALINK_ATE //