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"
33 #define ATE_BBP_REG_NUM 168
34 UCHAR restore_BBP
[ATE_BBP_REG_NUM
]={0};
37 // 802.11 MAC Header, Type:Data, Length:24bytes
38 UCHAR TemplateFrame
[24] = {0x08,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
39 0x00,0xAA,0xBB,0x12,0x34,0x56,0x00,0x11,0x22,0xAA,0xBB,0xCC,0x00,0x00};
41 extern RTMP_RF_REGS RF2850RegTable
[];
42 extern UCHAR NUM_OF_2850_CHNL
;
44 extern FREQUENCY_ITEM FreqItems3020
[];
45 extern UCHAR NUM_OF_3020_CHNL
;
50 static CHAR CCKRateTable
[] = {0, 1, 2, 3, 8, 9, 10, 11, -1}; /* CCK Mode. */
51 static CHAR OFDMRateTable
[] = {0, 1, 2, 3, 4, 5, 6, 7, -1}; /* OFDM Mode. */
52 static CHAR HTMIXRateTable
[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -1}; /* HT Mix Mode. */
55 IN PRTMP_ADAPTER pAd
);
58 IN PRTMP_ADAPTER pAd
);
60 static VOID
RtmpDmaEnable(
64 static VOID
BbpSoftReset(
65 IN PRTMP_ADAPTER pAd
);
67 static VOID
RtmpRfIoWrite(
68 IN PRTMP_ADAPTER pAd
);
70 static INT
ATESetUpFrame(
74 static INT
ATETxPwrHandler(
78 static INT
ATECmdHandler(
83 static int CheckMCSValid(
89 static int CheckMCSValid(
96 static VOID
ATEWriteTxWI(
98 IN PTXWI_STRUC pOutTxWI
,
101 IN BOOLEAN InsTimestamp
,
104 IN BOOLEAN NSeq
, // HW new a sequence.
113 IN HTTRANSMIT_SETTING
*pTransmit
);
114 #endif // RTMP_MAC_PCI //
117 static VOID
SetJapanFilter(
118 IN PRTMP_ADAPTER pAd
);
121 #ifdef RALINK_28xx_QA
122 static inline INT
DO_RACFG_CMD_ATE_START(
123 IN PRTMP_ADAPTER pAdapter
,
124 IN
struct iwreq
*wrq
,
125 IN
struct ate_racfghdr
*pRaCfg
128 static inline INT
DO_RACFG_CMD_ATE_STOP(
129 IN PRTMP_ADAPTER pAdapter
,
130 IN
struct iwreq
*wrq
,
131 IN
struct ate_racfghdr
*pRaCfg
134 static inline INT
DO_RACFG_CMD_RF_WRITE_ALL(
135 IN PRTMP_ADAPTER pAdapter
,
136 IN
struct iwreq
*wrq
,
137 IN
struct ate_racfghdr
*pRaCfg
140 static inline INT
DO_RACFG_CMD_E2PROM_READ16(
141 IN PRTMP_ADAPTER pAdapter
,
142 IN
struct iwreq
*wrq
,
143 IN
struct ate_racfghdr
*pRaCfg
146 static inline INT
DO_RACFG_CMD_E2PROM_WRITE16(
147 IN PRTMP_ADAPTER pAdapter
,
148 IN
struct iwreq
*wrq
,
149 IN
struct ate_racfghdr
*pRaCfg
152 static inline INT DO_RACFG_CMD_E2PROM_READ_ALL
154 IN PRTMP_ADAPTER pAdapter
,
155 IN
struct iwreq
*wrq
,
156 IN
struct ate_racfghdr
*pRaCfg
159 static inline INT
DO_RACFG_CMD_E2PROM_WRITE_ALL(
160 IN PRTMP_ADAPTER pAdapter
,
161 IN
struct iwreq
*wrq
,
162 IN
struct ate_racfghdr
*pRaCfg
165 static inline INT
DO_RACFG_CMD_IO_READ(
166 IN PRTMP_ADAPTER pAdapter
,
167 IN
struct iwreq
*wrq
,
168 IN
struct ate_racfghdr
*pRaCfg
171 static inline INT
DO_RACFG_CMD_IO_WRITE(
172 IN PRTMP_ADAPTER pAdapter
,
173 IN
struct iwreq
*wrq
,
174 IN
struct ate_racfghdr
*pRaCfg
177 static inline INT
DO_RACFG_CMD_IO_READ_BULK(
178 IN PRTMP_ADAPTER pAdapter
,
179 IN
struct iwreq
*wrq
,
180 IN
struct ate_racfghdr
*pRaCfg
183 static inline INT
DO_RACFG_CMD_BBP_READ8(
184 IN PRTMP_ADAPTER pAdapter
,
185 IN
struct iwreq
*wrq
,
186 IN
struct ate_racfghdr
*pRaCfg
189 static inline INT
DO_RACFG_CMD_BBP_WRITE8(
190 IN PRTMP_ADAPTER pAdapter
,
191 IN
struct iwreq
*wrq
,
192 IN
struct ate_racfghdr
*pRaCfg
195 static inline INT
DO_RACFG_CMD_BBP_READ_ALL(
196 IN PRTMP_ADAPTER pAdapter
,
197 IN
struct iwreq
*wrq
,
198 IN
struct ate_racfghdr
*pRaCfg
201 static inline INT
DO_RACFG_CMD_GET_NOISE_LEVEL(
202 IN PRTMP_ADAPTER pAdapter
,
203 IN
struct iwreq
*wrq
,
204 IN
struct ate_racfghdr
*pRaCfg
207 static inline INT
DO_RACFG_CMD_GET_COUNTER(
208 IN PRTMP_ADAPTER pAdapter
,
209 IN
struct iwreq
*wrq
,
210 IN
struct ate_racfghdr
*pRaCfg
213 static inline INT
DO_RACFG_CMD_CLEAR_COUNTER(
214 IN PRTMP_ADAPTER pAdapter
,
215 IN
struct iwreq
*wrq
,
216 IN
struct ate_racfghdr
*pRaCfg
219 static inline INT
DO_RACFG_CMD_TX_START(
220 IN PRTMP_ADAPTER pAdapter
,
221 IN
struct iwreq
*wrq
,
222 IN
struct ate_racfghdr
*pRaCfg
225 static inline INT
DO_RACFG_CMD_GET_TX_STATUS(
226 IN PRTMP_ADAPTER pAdapter
,
227 IN
struct iwreq
*wrq
,
228 IN
struct ate_racfghdr
*pRaCfg
231 static inline INT
DO_RACFG_CMD_TX_STOP(
232 IN PRTMP_ADAPTER pAdapter
,
233 IN
struct iwreq
*wrq
,
234 IN
struct ate_racfghdr
*pRaCfg
237 static inline INT
DO_RACFG_CMD_RX_START(
238 IN PRTMP_ADAPTER pAdapter
,
239 IN
struct iwreq
*wrq
,
240 IN
struct ate_racfghdr
*pRaCfg
243 static inline INT
DO_RACFG_CMD_RX_STOP(
244 IN PRTMP_ADAPTER pAdapter
,
245 IN
struct iwreq
*wrq
,
246 IN
struct ate_racfghdr
*pRaCfg
249 static inline INT
DO_RACFG_CMD_RX_STOP(
250 IN PRTMP_ADAPTER pAdapter
,
251 IN
struct iwreq
*wrq
,
252 IN
struct ate_racfghdr
*pRaCfg
255 static inline INT
DO_RACFG_CMD_ATE_START_TX_CARRIER(
256 IN PRTMP_ADAPTER pAdapter
,
257 IN
struct iwreq
*wrq
,
258 IN
struct ate_racfghdr
*pRaCfg
261 static inline INT
DO_RACFG_CMD_ATE_START_TX_CONT(
262 IN PRTMP_ADAPTER pAdapter
,
263 IN
struct iwreq
*wrq
,
264 IN
struct ate_racfghdr
*pRaCfg
267 static inline INT
DO_RACFG_CMD_ATE_START_TX_FRAME(
268 IN PRTMP_ADAPTER pAdapter
,
269 IN
struct iwreq
*wrq
,
270 IN
struct ate_racfghdr
*pRaCfg
273 static inline INT
DO_RACFG_CMD_ATE_SET_BW(
274 IN PRTMP_ADAPTER pAdapter
,
275 IN
struct iwreq
*wrq
,
276 IN
struct ate_racfghdr
*pRaCfg
279 static inline INT
DO_RACFG_CMD_ATE_SET_TX_POWER0(
280 IN PRTMP_ADAPTER pAdapter
,
281 IN
struct iwreq
*wrq
,
282 IN
struct ate_racfghdr
*pRaCfg
285 static inline INT
DO_RACFG_CMD_ATE_SET_TX_POWER1(
286 IN PRTMP_ADAPTER pAdapter
,
287 IN
struct iwreq
*wrq
,
288 IN
struct ate_racfghdr
*pRaCfg
291 static inline INT
DO_RACFG_CMD_ATE_SET_FREQ_OFFSET(
292 IN PRTMP_ADAPTER pAdapter
,
293 IN
struct iwreq
*wrq
,
294 IN
struct ate_racfghdr
*pRaCfg
297 static inline INT
DO_RACFG_CMD_ATE_GET_STATISTICS(
298 IN PRTMP_ADAPTER pAdapter
,
299 IN
struct iwreq
*wrq
,
300 IN
struct ate_racfghdr
*pRaCfg
303 static inline INT
DO_RACFG_CMD_ATE_RESET_COUNTER(
304 IN PRTMP_ADAPTER pAdapter
,
305 IN
struct iwreq
*wrq
,
306 IN
struct ate_racfghdr
*pRaCfg
309 static inline INT
DO_RACFG_CMD_ATE_SEL_TX_ANTENNA(
310 IN PRTMP_ADAPTER pAdapter
,
311 IN
struct iwreq
*wrq
,
312 IN
struct ate_racfghdr
*pRaCfg
315 static inline INT
DO_RACFG_CMD_ATE_SEL_RX_ANTENNA(
316 IN PRTMP_ADAPTER pAdapter
,
317 IN
struct iwreq
*wrq
,
318 IN
struct ate_racfghdr
*pRaCfg
321 static inline INT
DO_RACFG_CMD_ATE_SET_PREAMBLE(
322 IN PRTMP_ADAPTER pAdapter
,
323 IN
struct iwreq
*wrq
,
324 IN
struct ate_racfghdr
*pRaCfg
327 static inline INT
DO_RACFG_CMD_ATE_SET_CHANNEL(
328 IN PRTMP_ADAPTER pAdapter
,
329 IN
struct iwreq
*wrq
,
330 IN
struct ate_racfghdr
*pRaCfg
333 static inline INT
DO_RACFG_CMD_ATE_SET_ADDR1(
334 IN PRTMP_ADAPTER pAdapter
,
335 IN
struct iwreq
*wrq
,
336 IN
struct ate_racfghdr
*pRaCfg
339 static inline INT
DO_RACFG_CMD_ATE_SET_ADDR2(
340 IN PRTMP_ADAPTER pAdapter
,
341 IN
struct iwreq
*wrq
,
342 IN
struct ate_racfghdr
*pRaCfg
345 static inline INT
DO_RACFG_CMD_ATE_SET_ADDR3(
346 IN PRTMP_ADAPTER pAdapter
,
347 IN
struct iwreq
*wrq
,
348 IN
struct ate_racfghdr
*pRaCfg
351 static inline INT
DO_RACFG_CMD_ATE_SET_RATE(
352 IN PRTMP_ADAPTER pAdapter
,
353 IN
struct iwreq
*wrq
,
354 IN
struct ate_racfghdr
*pRaCfg
357 static inline INT
DO_RACFG_CMD_ATE_SET_TX_FRAME_LEN(
358 IN PRTMP_ADAPTER pAdapter
,
359 IN
struct iwreq
*wrq
,
360 IN
struct ate_racfghdr
*pRaCfg
363 static inline INT
DO_RACFG_CMD_ATE_SET_TX_FRAME_COUNT(
364 IN PRTMP_ADAPTER pAdapter
,
365 IN
struct iwreq
*wrq
,
366 IN
struct ate_racfghdr
*pRaCfg
369 static inline INT
DO_RACFG_CMD_ATE_START_RX_FRAME(
370 IN PRTMP_ADAPTER pAdapter
,
371 IN
struct iwreq
*wrq
,
372 IN
struct ate_racfghdr
*pRaCfg
375 static inline INT
DO_RACFG_CMD_ATE_E2PROM_READ_BULK(
376 IN PRTMP_ADAPTER pAdapter
,
377 IN
struct iwreq
*wrq
,
378 IN
struct ate_racfghdr
*pRaCfg
381 static inline INT
DO_RACFG_CMD_ATE_E2PROM_WRITE_BULK(
382 IN PRTMP_ADAPTER pAdapter
,
383 IN
struct iwreq
*wrq
,
384 IN
struct ate_racfghdr
*pRaCfg
387 static inline INT
DO_RACFG_CMD_ATE_IO_WRITE_BULK(
388 IN PRTMP_ADAPTER pAdapter
,
389 IN
struct iwreq
*wrq
,
390 IN
struct ate_racfghdr
*pRaCfg
393 static inline INT
DO_RACFG_CMD_ATE_BBP_READ_BULK(
394 IN PRTMP_ADAPTER pAdapter
,
395 IN
struct iwreq
*wrq
,
396 IN
struct ate_racfghdr
*pRaCfg
399 static inline INT
DO_RACFG_CMD_ATE_BBP_WRITE_BULK(
400 IN PRTMP_ADAPTER pAdapter
,
401 IN
struct iwreq
*wrq
,
402 IN
struct ate_racfghdr
*pRaCfg
405 #endif // RALINK_28xx_QA //
409 static INT
TxDmaBusy(
410 IN PRTMP_ADAPTER pAd
)
413 WPDMA_GLO_CFG_STRUC GloCfg
;
415 RTMP_IO_READ32(pAd
, WPDMA_GLO_CFG
, &GloCfg
.word
); // disable DMA
416 if (GloCfg
.field
.TxDMABusy
)
425 static INT
RxDmaBusy(
426 IN PRTMP_ADAPTER pAd
)
429 WPDMA_GLO_CFG_STRUC GloCfg
;
431 RTMP_IO_READ32(pAd
, WPDMA_GLO_CFG
, &GloCfg
.word
); // disable DMA
432 if (GloCfg
.field
.RxDMABusy
)
441 static VOID
RtmpDmaEnable(
442 IN PRTMP_ADAPTER pAd
,
447 WPDMA_GLO_CFG_STRUC GloCfg
;
449 value
= Enable
> 0 ? 1 : 0;
451 // check DMA is in busy mode.
454 while (TxDmaBusy(pAd
) || RxDmaBusy(pAd
))
461 RTMP_IO_READ32(pAd
, WPDMA_GLO_CFG
, &GloCfg
.word
); // disable DMA
462 GloCfg
.field
.EnableTxDMA
= value
;
463 GloCfg
.field
.EnableRxDMA
= value
;
464 RTMP_IO_WRITE32(pAd
, WPDMA_GLO_CFG
, GloCfg
.word
); // abort all TX rings
469 #endif // RTMP_MAC_PCI //
474 static VOID
BbpSoftReset(
475 IN PRTMP_ADAPTER pAd
)
479 // Soft reset, set BBP R21 bit0=1->0
480 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R21
, &BbpData
);
481 BbpData
|= 0x00000001; //set bit0=1
482 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R21
, BbpData
);
484 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R21
, &BbpData
);
485 BbpData
&= ~(0x00000001); //set bit0=0
486 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R21
, BbpData
);
492 static VOID
RtmpRfIoWrite(
493 IN PRTMP_ADAPTER pAd
)
495 // Set RF value 1's set R3[bit2] = [0]
496 RTMP_RF_IO_WRITE32(pAd
, pAd
->LatchRfRegs
.R1
);
497 RTMP_RF_IO_WRITE32(pAd
, pAd
->LatchRfRegs
.R2
);
498 RTMP_RF_IO_WRITE32(pAd
, (pAd
->LatchRfRegs
.R3
& (~0x04)));
499 RTMP_RF_IO_WRITE32(pAd
, pAd
->LatchRfRegs
.R4
);
503 // Set RF value 2's set R3[bit2] = [1]
504 RTMP_RF_IO_WRITE32(pAd
, pAd
->LatchRfRegs
.R1
);
505 RTMP_RF_IO_WRITE32(pAd
, pAd
->LatchRfRegs
.R2
);
506 RTMP_RF_IO_WRITE32(pAd
, (pAd
->LatchRfRegs
.R3
| 0x04));
507 RTMP_RF_IO_WRITE32(pAd
, pAd
->LatchRfRegs
.R4
);
511 // Set RF value 3's set R3[bit2] = [0]
512 RTMP_RF_IO_WRITE32(pAd
, pAd
->LatchRfRegs
.R1
);
513 RTMP_RF_IO_WRITE32(pAd
, pAd
->LatchRfRegs
.R2
);
514 RTMP_RF_IO_WRITE32(pAd
, (pAd
->LatchRfRegs
.R3
& (~0x04)));
515 RTMP_RF_IO_WRITE32(pAd
, pAd
->LatchRfRegs
.R4
);
522 static int CheckMCSValid(
528 static int CheckMCSValid(
539 pRateTab
= CCKRateTable
;
542 pRateTab
= OFDMRateTable
;
548 pRateTab
= OFDMRateTable
;
551 pRateTab
= HTMIXRateTable
;
554 ATEDBGPRINT(RT_DEBUG_ERROR
, ("unrecognizable Tx Mode %d\n", Mode
));
560 while (pRateTab
[i
] != -1)
562 if (pRateTab
[i
] == Mcs
)
571 static INT
ATETxPwrHandler(
572 IN PRTMP_ADAPTER pAd
,
578 BOOLEAN bPowerReduce
= FALSE
;
579 #ifdef RTMP_RF_RW_SUPPORT
581 #endif // RTMP_RF_RW_SUPPORT //
582 #ifdef RALINK_28xx_QA
583 if ((pAd
->ate
.bQATxStart
== TRUE
) || (pAd
->ate
.bQARxStart
== TRUE
))
586 When QA is used for Tx, pAd->ate.TxPower0/1 and real tx power
587 are not synchronized.
592 #endif // RALINK_28xx_QA //
594 TxPower
= index
== 0 ? pAd
->ate
.TxPower0
: pAd
->ate
.TxPower1
;
596 if (pAd
->ate
.Channel
<= 14)
601 // R3, R4 can't large than 31 (0x24), 31 ~ 36 used by BBP 94
604 Bbp94
= BBPR94_DEFAULT
+ (UCHAR
)(TxPower
- 31);
606 else if (TxPower
< 0)
609 // R3, R4 can't less than 0, -1 ~ -6 used by BBP 94
612 Bbp94
= BBPR94_DEFAULT
+ TxPower
;
618 Bbp94
= BBPR94_DEFAULT
;
621 ATEDBGPRINT(RT_DEBUG_TRACE
, ("%s (TxPower=%d, R=%ld, BBP_R94=%d)\n", __FUNCTION__
, TxPower
, R
, Bbp94
));
628 // R3, R4 can't large than 15 (0x0F)
631 else if (TxPower
< 0)
634 // R3, R4 can't less than 0
636 ASSERT((TxPower
>= -7));
637 R
= (ULONG
)(TxPower
+ 7);
646 ATEDBGPRINT(RT_DEBUG_TRACE
, ("%s (TxPower=%d, R=%lu)\n", __FUNCTION__
, TxPower
, R
));
648 //2008/09/10:KH adds to support 3070 ATE TX Power tunning real time<--
649 #ifdef RTMP_RF_RW_SUPPORT
653 ATE_RF_IO_READ8_BY_REG_ID(pAd
, RF_R12
, (PUCHAR
)&RFValue
);
654 RFValue
= (RFValue
& 0xE0) | TxPower
;
655 ATE_RF_IO_WRITE8_BY_REG_ID(pAd
, RF_R12
, (UCHAR
)RFValue
);
656 ATEDBGPRINT(RT_DEBUG_TRACE
, ("3070 or 2070:%s (TxPower=%d, RFValue=%x)\n", __FUNCTION__
, TxPower
, RFValue
));
659 #endif // RTMP_RF_RW_SUPPORT //
661 if (pAd
->ate
.Channel
<= 14)
665 // shift TX power control to correct RF(R3) register bit position
667 R
|= (pAd
->LatchRfRegs
.R3
& 0xffffc1ff);
668 pAd
->LatchRfRegs
.R3
= R
;
672 // shift TX power control to correct RF(R4) register bit position
674 R
|= (pAd
->LatchRfRegs
.R4
& 0xfffff83f);
675 pAd
->LatchRfRegs
.R4
= R
;
680 if (bPowerReduce
== FALSE
)
684 // shift TX power control to correct RF(R3) register bit position
685 R
= (R
<< 10) | (1 << 9);
686 R
|= (pAd
->LatchRfRegs
.R3
& 0xffffc1ff);
687 pAd
->LatchRfRegs
.R3
= R
;
691 // shift TX power control to correct RF(R4) register bit position
692 R
= (R
<< 7) | (1 << 6);
693 R
|= (pAd
->LatchRfRegs
.R4
& 0xfffff83f);
694 pAd
->LatchRfRegs
.R4
= R
;
701 // shift TX power control to correct RF(R3) register bit position
703 R
|= (pAd
->LatchRfRegs
.R3
& 0xffffc1ff);
705 /* Clear bit 9 of R3 to reduce 7dB. */
706 pAd
->LatchRfRegs
.R3
= (R
& (~(1 << 9)));
710 // shift TX power control to correct RF(R4) register bit position
712 R
|= (pAd
->LatchRfRegs
.R4
& 0xfffff83f);
714 /* Clear bit 6 of R4 to reduce 7dB. */
715 pAd
->LatchRfRegs
.R4
= (R
& (~(1 << 6)));
721 //2008/09/10:KH adds to support 3070 ATE TX Power tunning real time-->
729 ==========================================================================
731 Set ATE operation mode to
732 0. ATESTART = Start ATE Mode
733 1. ATESTOP = Stop ATE Mode
734 2. TXCONT = Continuous Transmit
735 3. TXCARR = Transmit Carrier
736 4. TXFRAME = Transmit Frames
737 5. RXFRAME = Receive Frames
738 #ifdef RALINK_28xx_QA
739 6. TXSTOP = Stop Any Type of Transmition
740 7. RXSTOP = Stop Receiving Frames
741 #endif // RALINK_28xx_QA //
743 TRUE if all parameters are OK, FALSE otherwise
744 ==========================================================================
747 static INT
ATECmdHandler(
748 IN PRTMP_ADAPTER pAd
,
756 UINT i
= 0, atemode
= 0;
758 PRTMP_TX_RING pTxRing
= &pAd
->TxRing
[QID_AC_BE
];
759 NDIS_STATUS Status
= NDIS_STATUS_SUCCESS
;
765 ATEDBGPRINT(RT_DEBUG_TRACE
, ("===> ATECmdHandler()\n"));
767 ATEAsicSwitchChannel(pAd
);
770 AsicLockChannel(pAd
, pAd
->ate
.Channel
);
774 // read MAC_SYS_CTRL and backup MAC_SYS_CTRL value.
775 RTMP_IO_READ32(pAd
, MAC_SYS_CTRL
, &MacData
);
777 // Default value in BBP R22 is 0x0.
780 // clean bit4 to stop continuous Tx production test.
781 MacData
&= 0xFFFFFFEF;
783 // Enter ATE mode and set Tx/Rx Idle
784 if (!strcmp(arg
, "ATESTART"))
786 ATEDBGPRINT(RT_DEBUG_TRACE
, ("ATE: ATESTART\n"));
788 #if defined(LINUX) || defined(VXWORKS)
789 // check if we have removed the firmware
792 NICEraseFirmware(pAd
);
794 #endif // defined(LINUX) || defined(VXWORKS) //
796 atemode
= pAd
->ate
.Mode
;
797 pAd
->ate
.Mode
= ATE_START
;
798 RTMP_IO_WRITE32(pAd
, MAC_SYS_CTRL
, MacData
);
800 if (atemode
== ATE_TXCARR
)
802 // No Carrier Test set BBP R22 bit7=0, bit6=0, bit[5~0]=0x0
803 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R22
, &BbpData
);
804 BbpData
&= 0xFFFFFF00; // clear bit7, bit6, bit[5~0]
805 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R22
, BbpData
);
807 else if (atemode
== ATE_TXCARRSUPP
)
809 // No Cont. TX set BBP R22 bit7=0
810 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R22
, &BbpData
);
811 BbpData
&= ~(1 << 7); // set bit7=0
812 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R22
, BbpData
);
814 // No Carrier Suppression set BBP R24 bit0=0
815 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R24
, &BbpData
);
816 BbpData
&= 0xFFFFFFFE; // clear bit0
817 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R24
, BbpData
);
821 We should free some resource which was allocated
822 when ATE_TXFRAME , ATE_STOP, and ATE_TXCONT.
824 else if ((atemode
& ATE_TXFRAME
) || (atemode
== ATE_STOP
))
826 PRTMP_TX_RING pTxRing
= &pAd
->TxRing
[QID_AC_BE
];
828 if (atemode
== ATE_TXCONT
)
830 // No Cont. TX set BBP R22 bit7=0
831 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R22
, &BbpData
);
832 BbpData
&= ~(1 << 7); // set bit7=0
833 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R22
, BbpData
);
837 RtmpDmaEnable(pAd
, 0);
838 for (i
=0; i
<TX_RING_SIZE
; i
++)
840 PNDIS_PACKET pPacket
;
842 #ifndef RT_BIG_ENDIAN
843 pTxD
= (PTXD_STRUC
)pAd
->TxRing
[QID_AC_BE
].Cell
[i
].AllocVa
;
845 pDestTxD
= (PTXD_STRUC
)pAd
->TxRing
[QID_AC_BE
].Cell
[i
].AllocVa
;
848 RTMPDescriptorEndianChange((PUCHAR
)pTxD
, TYPE_TXD
);
851 pPacket
= pTxRing
->Cell
[i
].pNdisPacket
;
855 PCI_UNMAP_SINGLE(pAd
, pTxD
->SDPtr0
, pTxD
->SDLen0
, PCI_DMA_TODEVICE
);
856 RELEASE_NDIS_PACKET(pAd
, pPacket
, NDIS_STATUS_SUCCESS
);
859 // Always assign pNdisPacket as NULL after clear
860 pTxRing
->Cell
[i
].pNdisPacket
= NULL
;
862 pPacket
= pTxRing
->Cell
[i
].pNextNdisPacket
;
866 PCI_UNMAP_SINGLE(pAd
, pTxD
->SDPtr1
, pTxD
->SDLen1
, PCI_DMA_TODEVICE
);
867 RELEASE_NDIS_PACKET(pAd
, pPacket
, NDIS_STATUS_SUCCESS
);
870 // Always assign pNextNdisPacket as NULL after clear
871 pTxRing
->Cell
[i
].pNextNdisPacket
= NULL
;
873 RTMPDescriptorEndianChange((PUCHAR
)pTxD
, TYPE_TXD
);
874 WriteBackToDescriptor((PUCHAR
)pDestTxD
, (PUCHAR
)pTxD
, FALSE
, TYPE_TXD
);
879 RtmpDmaEnable(pAd
, 1);
882 // reset Rx statistics.
883 pAd
->ate
.LastSNR0
= 0;
884 pAd
->ate
.LastSNR1
= 0;
885 pAd
->ate
.LastRssi0
= 0;
886 pAd
->ate
.LastRssi1
= 0;
887 pAd
->ate
.LastRssi2
= 0;
888 pAd
->ate
.AvgRssi0
= 0;
889 pAd
->ate
.AvgRssi1
= 0;
890 pAd
->ate
.AvgRssi2
= 0;
891 pAd
->ate
.AvgRssi0X8
= 0;
892 pAd
->ate
.AvgRssi1X8
= 0;
893 pAd
->ate
.AvgRssi2X8
= 0;
894 pAd
->ate
.NumOfAvgRssiSample
= 0;
896 #ifdef RALINK_28xx_QA
898 pAd
->ate
.bQATxStart
= FALSE
;
899 pAd
->ate
.bQARxStart
= FALSE
;
904 pAd
->ate
.OtherData
= 0;
906 pAd
->ate
.OtherCount
= 0;
911 /*pAd->ate.TxHCCA = 0;*/
920 pAd
->ate
.TxDoneCount
= 0;
921 // TxStatus : 0 --> task is idle, 1 --> task is running
922 pAd
->ate
.TxStatus
= 0;
923 #endif // RALINK_28xx_QA //
929 #ifdef CONFIG_STA_SUPPORT
930 /* LinkDown() has "AsicDisableSync();" and "RTMP_BBP_IO_R/W8_BY_REG_ID();" inside. */
931 // LinkDown(pAd, FALSE);
932 // AsicEnableBssSync(pAd);
934 #if defined(LINUX) || defined(VXWORKS)
935 RTMP_OS_NETDEV_STOP_QUEUE(pAd
->net_dev
);
936 #endif // defined(LINUX) || defined(VXWORKS) //
939 If we skip "LinkDown()", we should disable protection
940 to prevent from sending out RTS or CTS-to-self.
942 ATEDisableAsicProtect(pAd
);
943 RTMPStationStop(pAd
);
944 #endif // CONFIG_STA_SUPPORT //
947 RTMP_IO_READ32(pAd
, MAC_SYS_CTRL
, &Value
);
949 RTMP_IO_WRITE32(pAd
, MAC_SYS_CTRL
, Value
);
952 RTMP_IO_READ32(pAd
, MAC_SYS_CTRL
, &Value
);
954 RTMP_IO_WRITE32(pAd
, MAC_SYS_CTRL
, Value
);
956 else if (!strcmp(arg
, "ATESTOP"))
958 ATEDBGPRINT(RT_DEBUG_TRACE
, ("ATE: ATESTOP\n"));
960 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R22
, BbpData
);
962 // recover the MAC_SYS_CTRL register back
963 RTMP_IO_WRITE32(pAd
, MAC_SYS_CTRL
, MacData
);
966 RTMP_IO_READ32(pAd
, MAC_SYS_CTRL
, &Value
);
967 Value
&= (0xfffffff3);
968 RTMP_IO_WRITE32(pAd
, MAC_SYS_CTRL
, Value
);
971 RtmpDmaEnable(pAd
, 0);
974 pAd
->ate
.bFWLoading
= TRUE
;
976 Status
= NICLoadFirmware(pAd
);
978 if (Status
!= NDIS_STATUS_SUCCESS
)
980 ATEDBGPRINT(RT_DEBUG_ERROR
, ("NICLoadFirmware failed, Status[=0x%08x]\n", Status
));
984 pAd
->ate
.Mode
= ATE_STOP
;
987 Even the firmware has been loaded,
988 we still could use ATE_BBP_IO_READ8_BY_REG_ID().
989 But this is not suggested.
993 RTMP_ASIC_INTERRUPT_DISABLE(pAd
);
995 NICInitializeAdapter(pAd
, TRUE
);
998 Reinitialize Rx Ring before Rx DMA is enabled.
999 >>>RxCoherent<<< was gone !
1001 for (index
= 0; index
< RX_RING_SIZE
; index
++)
1003 pRxD
= (PRXD_STRUC
) pAd
->RxRing
.Cell
[index
].AllocVa
;
1007 // We should read EEPROM for all cases.
1008 NICReadEEPROMParameters(pAd
, NULL
);
1009 NICInitAsicFromEEPROM(pAd
);
1011 AsicSwitchChannel(pAd
, pAd
->CommonCfg
.Channel
, FALSE
);
1013 /* empty function */
1014 AsicLockChannel(pAd
, pAd
->CommonCfg
.Channel
);
1016 /* clear garbage interrupts */
1017 RTMP_IO_WRITE32(pAd
, INT_SOURCE_CSR
, 0xffffffff);
1018 /* Enable Interrupt */
1019 RTMP_ASIC_INTERRUPT_ENABLE(pAd
);
1021 /* restore RX_FILTR_CFG */
1023 #ifdef CONFIG_STA_SUPPORT
1024 /* restore RX_FILTR_CFG due to that QA maybe set it to 0x3 */
1025 RTMP_IO_WRITE32(pAd
, RX_FILTR_CFG
, STANORMAL
);
1026 #endif // CONFIG_STA_SUPPORT //
1029 RTMP_IO_READ32(pAd
, MAC_SYS_CTRL
, &Value
);
1031 RTMP_IO_WRITE32(pAd
, MAC_SYS_CTRL
, Value
);
1033 // Enable Tx, Rx DMA.
1034 RtmpDmaEnable(pAd
, 1);
1037 RTMP_IO_READ32(pAd
, MAC_SYS_CTRL
, &Value
);
1039 RTMP_IO_WRITE32(pAd
, MAC_SYS_CTRL
, Value
);
1042 #ifdef CONFIG_STA_SUPPORT
1043 RTMPStationStart(pAd
);
1044 #endif // CONFIG_STA_SUPPORT //
1046 #if defined(LINUX) || defined(VXWORKS)
1047 RTMP_OS_NETDEV_START_QUEUE(pAd
->net_dev
);
1048 #endif // defined(LINUX) || defined(VXWORKS) //
1050 else if (!strcmp(arg
, "TXCARR"))
1052 ATEDBGPRINT(RT_DEBUG_TRACE
, ("ATE: TXCARR\n"));
1053 pAd
->ate
.Mode
= ATE_TXCARR
;
1055 // QA has done the following steps if it is used.
1056 if (pAd
->ate
.bQATxStart
== FALSE
)
1061 // Carrier Test set BBP R22 bit7=1, bit6=1, bit[5~0]=0x01
1062 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R22
, &BbpData
);
1063 BbpData
&= 0xFFFFFF00; //clear bit7, bit6, bit[5~0]
1064 BbpData
|= 0x000000C1; //set bit7=1, bit6=1, bit[5~0]=0x01
1065 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R22
, BbpData
);
1067 // set MAC_SYS_CTRL(0x1004) Continuous Tx Production Test (bit4) = 1
1068 RTMP_IO_READ32(pAd
, MAC_SYS_CTRL
, &Value
);
1069 Value
= Value
| 0x00000010;
1070 RTMP_IO_WRITE32(pAd
, MAC_SYS_CTRL
, Value
);
1073 else if (!strcmp(arg
, "TXCONT"))
1075 if (pAd
->ate
.bQATxStart
== TRUE
)
1078 set MAC_SYS_CTRL(0x1004) bit4(Continuous Tx Production Test)
1079 and bit2(MAC TX enable) back to zero.
1081 RTMP_IO_READ32(pAd
, MAC_SYS_CTRL
, &MacData
);
1082 MacData
&= 0xFFFFFFEB;
1083 RTMP_IO_WRITE32(pAd
, MAC_SYS_CTRL
, MacData
);
1085 // set BBP R22 bit7=0
1086 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R22
, &BbpData
);
1087 BbpData
&= 0xFFFFFF7F; //set bit7=0
1088 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R22
, BbpData
);
1093 Step 1: Send 50 packets first then wait for a moment.
1094 Step 2: Send more 50 packet then start continue mode.
1096 ATEDBGPRINT(RT_DEBUG_TRACE
, ("ATE: TXCONT\n"));
1098 // Step 1: send 50 packets first.
1099 pAd
->ate
.Mode
= ATE_TXCONT
;
1100 pAd
->ate
.TxCount
= 50;
1102 /* Do it after Tx/Rx DMA is aborted. */
1103 // pAd->ate.TxDoneCount = 0;
1108 // Abort Tx, RX DMA.
1109 RtmpDmaEnable(pAd
, 0);
1111 // Fix can't smooth kick
1113 RTMP_IO_READ32(pAd
, TX_DTX_IDX0
+ QID_AC_BE
* 0x10, &pTxRing
->TxDmaIdx
);
1114 pTxRing
->TxSwFreeIdx
= pTxRing
->TxDmaIdx
;
1115 pTxRing
->TxCpuIdx
= pTxRing
->TxDmaIdx
;
1116 RTMP_IO_WRITE32(pAd
, TX_CTX_IDX0
+ QID_AC_BE
* 0x10, pTxRing
->TxCpuIdx
);
1119 pAd
->ate
.TxDoneCount
= 0;
1121 /* Only needed if we have to send some normal frames. */
1122 SetJapanFilter(pAd
);
1124 for (i
= 0; (i
< TX_RING_SIZE
-1) && (i
< pAd
->ate
.TxCount
); i
++)
1126 PNDIS_PACKET pPacket
;
1127 UINT32 TxIdx
= pTxRing
->TxCpuIdx
;
1129 #ifndef RT_BIG_ENDIAN
1130 pTxD
= (PTXD_STRUC
)pTxRing
->Cell
[TxIdx
].AllocVa
;
1132 pDestTxD
= (PTXD_STRUC
)pTxRing
->Cell
[TxIdx
].AllocVa
;
1135 RTMPDescriptorEndianChange((PUCHAR
)pTxD
, TYPE_TXD
);
1137 // Clean current cell.
1138 pPacket
= pTxRing
->Cell
[TxIdx
].pNdisPacket
;
1142 PCI_UNMAP_SINGLE(pAd
, pTxD
->SDPtr0
, pTxD
->SDLen0
, PCI_DMA_TODEVICE
);
1143 RELEASE_NDIS_PACKET(pAd
, pPacket
, NDIS_STATUS_SUCCESS
);
1146 // Always assign pNdisPacket as NULL after clear
1147 pTxRing
->Cell
[TxIdx
].pNdisPacket
= NULL
;
1149 pPacket
= pTxRing
->Cell
[TxIdx
].pNextNdisPacket
;
1153 PCI_UNMAP_SINGLE(pAd
, pTxD
->SDPtr1
, pTxD
->SDLen1
, PCI_DMA_TODEVICE
);
1154 RELEASE_NDIS_PACKET(pAd
, pPacket
, NDIS_STATUS_SUCCESS
);
1157 // Always assign pNextNdisPacket as NULL after clear
1158 pTxRing
->Cell
[TxIdx
].pNextNdisPacket
= NULL
;
1160 #ifdef RT_BIG_ENDIAN
1161 RTMPDescriptorEndianChange((PUCHAR
)pTxD
, TYPE_TXD
);
1162 WriteBackToDescriptor((PUCHAR
)pDestTxD
, (PUCHAR
)pTxD
, FALSE
, TYPE_TXD
);
1165 if (ATESetUpFrame(pAd
, TxIdx
) != 0)
1168 INC_RING_INDEX(pTxRing
->TxCpuIdx
, TX_RING_SIZE
);
1171 // Setup frame format.
1172 ATESetUpFrame(pAd
, pTxRing
->TxCpuIdx
);
1174 // Start Tx, RX DMA.
1175 RtmpDmaEnable(pAd
, 1);
1178 RTMP_IO_READ32(pAd
, MAC_SYS_CTRL
, &Value
);
1180 RTMP_IO_WRITE32(pAd
, MAC_SYS_CTRL
, Value
);
1183 RTMP_IO_READ32(pAd
, MAC_SYS_CTRL
, &Value
);
1185 RTMP_IO_WRITE32(pAd
, MAC_SYS_CTRL
, Value
);
1187 #ifdef RALINK_28xx_QA
1188 if (pAd
->ate
.bQATxStart
== TRUE
)
1190 pAd
->ate
.TxStatus
= 1;
1192 #endif // RALINK_28xx_QA //
1195 RTMP_IO_WRITE32(pAd
, TX_CTX_IDX0
+ QID_AC_BE
* RINGREG_DIFF
, pAd
->TxRing
[QID_AC_BE
].TxCpuIdx
);
1197 RTMPusecDelay(5000);
1200 // Step 2: send more 50 packets then start continue mode.
1201 // Abort Tx, RX DMA.
1202 RtmpDmaEnable(pAd
, 0);
1204 // Cont. TX set BBP R22 bit7=1
1205 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R22
, &BbpData
);
1206 BbpData
|= 0x00000080; //set bit7=1
1207 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R22
, BbpData
);
1209 pAd
->ate
.TxCount
= 50;
1211 // Fix can't smooth kick
1213 RTMP_IO_READ32(pAd
, TX_DTX_IDX0
+ QID_AC_BE
* 0x10, &pTxRing
->TxDmaIdx
);
1214 pTxRing
->TxSwFreeIdx
= pTxRing
->TxDmaIdx
;
1215 pTxRing
->TxCpuIdx
= pTxRing
->TxDmaIdx
;
1216 RTMP_IO_WRITE32(pAd
, TX_CTX_IDX0
+ QID_AC_BE
* 0x10, pTxRing
->TxCpuIdx
);
1219 pAd
->ate
.TxDoneCount
= 0;
1221 SetJapanFilter(pAd
);
1223 for (i
= 0; (i
< TX_RING_SIZE
-1) && (i
< pAd
->ate
.TxCount
); i
++)
1225 PNDIS_PACKET pPacket
;
1226 UINT32 TxIdx
= pTxRing
->TxCpuIdx
;
1228 #ifndef RT_BIG_ENDIAN
1229 pTxD
= (PTXD_STRUC
)pTxRing
->Cell
[TxIdx
].AllocVa
;
1231 pDestTxD
= (PTXD_STRUC
)pTxRing
->Cell
[TxIdx
].AllocVa
;
1234 RTMPDescriptorEndianChange((PUCHAR
)pTxD
, TYPE_TXD
);
1236 // clean current cell.
1237 pPacket
= pTxRing
->Cell
[TxIdx
].pNdisPacket
;
1241 PCI_UNMAP_SINGLE(pAd
, pTxD
->SDPtr0
, pTxD
->SDLen0
, PCI_DMA_TODEVICE
);
1242 RELEASE_NDIS_PACKET(pAd
, pPacket
, NDIS_STATUS_SUCCESS
);
1245 // Always assign pNdisPacket as NULL after clear
1246 pTxRing
->Cell
[TxIdx
].pNdisPacket
= NULL
;
1248 pPacket
= pTxRing
->Cell
[TxIdx
].pNextNdisPacket
;
1252 PCI_UNMAP_SINGLE(pAd
, pTxD
->SDPtr1
, pTxD
->SDLen1
, PCI_DMA_TODEVICE
);
1253 RELEASE_NDIS_PACKET(pAd
, pPacket
, NDIS_STATUS_SUCCESS
);
1256 // Always assign pNextNdisPacket as NULL after clear
1257 pTxRing
->Cell
[TxIdx
].pNextNdisPacket
= NULL
;
1259 #ifdef RT_BIG_ENDIAN
1260 RTMPDescriptorEndianChange((PUCHAR
)pTxD
, TYPE_TXD
);
1261 WriteBackToDescriptor((PUCHAR
)pDestTxD
, (PUCHAR
)pTxD
, FALSE
, TYPE_TXD
);
1264 if (ATESetUpFrame(pAd
, TxIdx
) != 0)
1267 INC_RING_INDEX(pTxRing
->TxCpuIdx
, TX_RING_SIZE
);
1270 ATESetUpFrame(pAd
, pTxRing
->TxCpuIdx
);
1272 // Start Tx, RX DMA.
1273 RtmpDmaEnable(pAd
, 1);
1276 RTMP_IO_READ32(pAd
, MAC_SYS_CTRL
, &Value
);
1278 RTMP_IO_WRITE32(pAd
, MAC_SYS_CTRL
, Value
);
1281 RTMP_IO_READ32(pAd
, MAC_SYS_CTRL
, &Value
);
1283 RTMP_IO_WRITE32(pAd
, MAC_SYS_CTRL
, Value
);
1285 #ifdef RALINK_28xx_QA
1286 if (pAd
->ate
.bQATxStart
== TRUE
)
1288 pAd
->ate
.TxStatus
= 1;
1290 #endif // RALINK_28xx_QA //
1293 RTMP_IO_WRITE32(pAd
, TX_CTX_IDX0
+ QID_AC_BE
* RINGREG_DIFF
, pAd
->TxRing
[QID_AC_BE
].TxCpuIdx
);
1297 RTMP_IO_READ32(pAd
, MAC_SYS_CTRL
, &MacData
);
1298 MacData
|= 0x00000010;
1299 RTMP_IO_WRITE32(pAd
, MAC_SYS_CTRL
, MacData
);
1301 else if (!strcmp(arg
, "TXFRAME"))
1303 ATEDBGPRINT(RT_DEBUG_TRACE
, ("ATE: TXFRAME(Count=%d)\n", pAd
->ate
.TxCount
));
1304 pAd
->ate
.Mode
|= ATE_TXFRAME
;
1305 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R22
, BbpData
);
1309 RTMP_IO_WRITE32(pAd
, MAC_SYS_CTRL
, MacData
);
1311 // Abort Tx, RX DMA.
1312 RtmpDmaEnable(pAd
, 0);
1314 // Fix can't smooth kick
1316 RTMP_IO_READ32(pAd
, TX_DTX_IDX0
+ QID_AC_BE
* 0x10, &pTxRing
->TxDmaIdx
);
1317 pTxRing
->TxSwFreeIdx
= pTxRing
->TxDmaIdx
;
1318 pTxRing
->TxCpuIdx
= pTxRing
->TxDmaIdx
;
1319 RTMP_IO_WRITE32(pAd
, TX_CTX_IDX0
+ QID_AC_BE
* 0x10, pTxRing
->TxCpuIdx
);
1322 pAd
->ate
.TxDoneCount
= 0;
1324 SetJapanFilter(pAd
);
1326 for (i
= 0; (i
< TX_RING_SIZE
-1) && (i
< pAd
->ate
.TxCount
); i
++)
1328 PNDIS_PACKET pPacket
;
1329 UINT32 TxIdx
= pTxRing
->TxCpuIdx
;
1331 #ifndef RT_BIG_ENDIAN
1332 pTxD
= (PTXD_STRUC
)pTxRing
->Cell
[TxIdx
].AllocVa
;
1334 pDestTxD
= (PTXD_STRUC
)pTxRing
->Cell
[TxIdx
].AllocVa
;
1337 RTMPDescriptorEndianChange((PUCHAR
)pTxD
, TYPE_TXD
);
1339 // Clean current cell.
1340 pPacket
= pTxRing
->Cell
[TxIdx
].pNdisPacket
;
1344 PCI_UNMAP_SINGLE(pAd
, pTxD
->SDPtr0
, pTxD
->SDLen0
, PCI_DMA_TODEVICE
);
1345 RELEASE_NDIS_PACKET(pAd
, pPacket
, NDIS_STATUS_SUCCESS
);
1348 // Always assign pNdisPacket as NULL after clear
1349 pTxRing
->Cell
[TxIdx
].pNdisPacket
= NULL
;
1351 pPacket
= pTxRing
->Cell
[TxIdx
].pNextNdisPacket
;
1355 PCI_UNMAP_SINGLE(pAd
, pTxD
->SDPtr1
, pTxD
->SDLen1
, PCI_DMA_TODEVICE
);
1356 RELEASE_NDIS_PACKET(pAd
, pPacket
, NDIS_STATUS_SUCCESS
);
1359 // Always assign pNextNdisPacket as NULL after clear
1360 pTxRing
->Cell
[TxIdx
].pNextNdisPacket
= NULL
;
1362 #ifdef RT_BIG_ENDIAN
1363 RTMPDescriptorEndianChange((PUCHAR
)pTxD
, TYPE_TXD
);
1364 WriteBackToDescriptor((PUCHAR
)pDestTxD
, (PUCHAR
)pTxD
, FALSE
, TYPE_TXD
);
1367 if (ATESetUpFrame(pAd
, TxIdx
) != 0)
1370 INC_RING_INDEX(pTxRing
->TxCpuIdx
, TX_RING_SIZE
);
1374 ATESetUpFrame(pAd
, pTxRing
->TxCpuIdx
);
1376 // Start Tx, Rx DMA.
1377 RtmpDmaEnable(pAd
, 1);
1380 RTMP_IO_READ32(pAd
, MAC_SYS_CTRL
, &Value
);
1382 RTMP_IO_WRITE32(pAd
, MAC_SYS_CTRL
, Value
);
1384 #ifdef RALINK_28xx_QA
1385 // add this for LoopBack mode
1386 if (pAd
->ate
.bQARxStart
== FALSE
)
1389 RTMP_IO_READ32(pAd
, MAC_SYS_CTRL
, &Value
);
1391 RTMP_IO_WRITE32(pAd
, MAC_SYS_CTRL
, Value
);
1394 if (pAd
->ate
.bQATxStart
== TRUE
)
1396 pAd
->ate
.TxStatus
= 1;
1400 RTMP_IO_READ32(pAd
, MAC_SYS_CTRL
, &Value
);
1402 RTMP_IO_WRITE32(pAd
, MAC_SYS_CTRL
, Value
);
1403 #endif // RALINK_28xx_QA //
1405 RTMP_IO_READ32(pAd
, TX_DTX_IDX0
+ QID_AC_BE
* RINGREG_DIFF
, &pAd
->TxRing
[QID_AC_BE
].TxDmaIdx
);
1407 RTMP_IO_WRITE32(pAd
, TX_CTX_IDX0
+ QID_AC_BE
* RINGREG_DIFF
, pAd
->TxRing
[QID_AC_BE
].TxCpuIdx
);
1409 pAd
->RalinkCounters
.KickTxCount
++;
1411 #ifdef RALINK_28xx_QA
1412 else if (!strcmp(arg
, "TXSTOP"))
1414 ATEDBGPRINT(RT_DEBUG_TRACE
, ("ATE: TXSTOP\n"));
1415 atemode
= pAd
->ate
.Mode
;
1416 pAd
->ate
.Mode
&= ATE_TXSTOP
;
1417 pAd
->ate
.bQATxStart
= FALSE
;
1418 // pAd->ate.TxDoneCount = pAd->ate.TxCount;
1420 if (atemode
== ATE_TXCARR
)
1422 // No Carrier Test set BBP R22 bit7=0, bit6=0, bit[5~0]=0x0
1423 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R22
, &BbpData
);
1424 BbpData
&= 0xFFFFFF00; //clear bit7, bit6, bit[5~0]
1425 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R22
, BbpData
);
1427 else if (atemode
== ATE_TXCARRSUPP
)
1429 // No Cont. TX set BBP R22 bit7=0
1430 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R22
, &BbpData
);
1431 BbpData
&= ~(1 << 7); //set bit7=0
1432 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R22
, BbpData
);
1434 // No Carrier Suppression set BBP R24 bit0=0
1435 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R24
, &BbpData
);
1436 BbpData
&= 0xFFFFFFFE; //clear bit0
1437 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R24
, BbpData
);
1441 We should free some resource which was allocated
1442 when ATE_TXFRAME, ATE_STOP, and ATE_TXCONT.
1444 else if ((atemode
& ATE_TXFRAME
) || (atemode
== ATE_STOP
))
1446 PRTMP_TX_RING pTxRing
= &pAd
->TxRing
[QID_AC_BE
];
1448 if (atemode
== ATE_TXCONT
)
1450 // No Cont. TX set BBP R22 bit7=0
1451 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R22
, &BbpData
);
1452 BbpData
&= ~(1 << 7); //set bit7=0
1453 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R22
, BbpData
);
1456 // Abort Tx, Rx DMA.
1457 RtmpDmaEnable(pAd
, 0);
1459 for (i
=0; i
<TX_RING_SIZE
; i
++)
1461 PNDIS_PACKET pPacket
;
1463 #ifndef RT_BIG_ENDIAN
1464 pTxD
= (PTXD_STRUC
)pAd
->TxRing
[QID_AC_BE
].Cell
[i
].AllocVa
;
1466 pDestTxD
= (PTXD_STRUC
)pAd
->TxRing
[QID_AC_BE
].Cell
[i
].AllocVa
;
1469 RTMPDescriptorEndianChange((PUCHAR
)pTxD
, TYPE_TXD
);
1472 pPacket
= pTxRing
->Cell
[i
].pNdisPacket
;
1476 PCI_UNMAP_SINGLE(pAd
, pTxD
->SDPtr0
, pTxD
->SDLen0
, PCI_DMA_TODEVICE
);
1477 RELEASE_NDIS_PACKET(pAd
, pPacket
, NDIS_STATUS_SUCCESS
);
1480 // Always assign pNdisPacket as NULL after clear
1481 pTxRing
->Cell
[i
].pNdisPacket
= NULL
;
1483 pPacket
= pTxRing
->Cell
[i
].pNextNdisPacket
;
1487 PCI_UNMAP_SINGLE(pAd
, pTxD
->SDPtr1
, pTxD
->SDLen1
, PCI_DMA_TODEVICE
);
1488 RELEASE_NDIS_PACKET(pAd
, pPacket
, NDIS_STATUS_SUCCESS
);
1491 // Always assign pNextNdisPacket as NULL after clear
1492 pTxRing
->Cell
[i
].pNextNdisPacket
= NULL
;
1493 #ifdef RT_BIG_ENDIAN
1494 RTMPDescriptorEndianChange((PUCHAR
)pTxD
, TYPE_TXD
);
1495 WriteBackToDescriptor((PUCHAR
)pDestTxD
, (PUCHAR
)pTxD
, FALSE
, TYPE_TXD
);
1498 // Enable Tx, Rx DMA
1499 RtmpDmaEnable(pAd
, 1);
1503 // TxStatus : 0 --> task is idle, 1 --> task is running
1504 pAd
->ate
.TxStatus
= 0;
1510 RTMP_IO_READ32(pAd
, MAC_SYS_CTRL
, &Value
);
1512 RTMP_IO_WRITE32(pAd
, MAC_SYS_CTRL
, Value
);
1514 else if (!strcmp(arg
, "RXSTOP"))
1516 ATEDBGPRINT(RT_DEBUG_TRACE
, ("ATE: RXSTOP\n"));
1517 atemode
= pAd
->ate
.Mode
;
1518 pAd
->ate
.Mode
&= ATE_RXSTOP
;
1519 pAd
->ate
.bQARxStart
= FALSE
;
1520 // pAd->ate.TxDoneCount = pAd->ate.TxCount;
1522 if (atemode
== ATE_TXCARR
)
1526 else if (atemode
== ATE_TXCARRSUPP
)
1532 We should free some resource which was allocated
1533 when ATE_TXFRAME, ATE_STOP, and ATE_TXCONT.
1535 else if ((atemode
& ATE_TXFRAME
) || (atemode
== ATE_STOP
))
1537 if (atemode
== ATE_TXCONT
)
1547 RTMP_IO_READ32(pAd
, MAC_SYS_CTRL
, &Value
);
1549 RTMP_IO_WRITE32(pAd
, MAC_SYS_CTRL
, Value
);
1551 #endif // RALINK_28xx_QA //
1552 else if (!strcmp(arg
, "RXFRAME"))
1554 ATEDBGPRINT(RT_DEBUG_TRACE
, ("ATE: RXFRAME\n"));
1556 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R22
, BbpData
);
1557 RTMP_IO_WRITE32(pAd
, MAC_SYS_CTRL
, MacData
);
1559 pAd
->ate
.Mode
|= ATE_RXFRAME
;
1561 // Disable Tx of MAC block.
1562 RTMP_IO_READ32(pAd
, MAC_SYS_CTRL
, &Value
);
1564 RTMP_IO_WRITE32(pAd
, MAC_SYS_CTRL
, Value
);
1566 // Enable Rx of MAC block.
1567 RTMP_IO_READ32(pAd
, MAC_SYS_CTRL
, &Value
);
1569 RTMP_IO_WRITE32(pAd
, MAC_SYS_CTRL
, Value
);
1573 ATEDBGPRINT(RT_DEBUG_TRACE
, ("ATE: Invalid arg!\n"));
1576 RTMPusecDelay(5000);
1578 ATEDBGPRINT(RT_DEBUG_TRACE
, ("<=== ATECmdHandler()\n"));
1582 /*=======================End of RTMP_MAC_PCI =======================*/
1583 #endif // RTMP_MAC_PCI //
1589 IN PRTMP_ADAPTER pAd
,
1592 if (ATECmdHandler(pAd
, arg
))
1594 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Ralink: Set_ATE_Proc Success\n"));
1601 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Ralink: Set_ATE_Proc Failed\n"));
1608 ==========================================================================
1610 Set ATE ADDR1=DA for TxFrame(AP : To DS = 0 ; From DS = 1)
1612 Set ATE ADDR3=DA for TxFrame(STA : To DS = 1 ; From DS = 0)
1615 TRUE if all parameters are OK, FALSE otherwise
1616 ==========================================================================
1618 INT
Set_ATE_DA_Proc(
1619 IN PRTMP_ADAPTER pAd
,
1625 // Mac address acceptable format 01:02:03:04:05:06 length 17
1626 if (strlen(arg
) != 17)
1629 for (i
= 0, value
= rstrtok(arg
, ":"); value
; value
= rstrtok(NULL
, ":"))
1632 if ((strlen(value
) != 2) || (!isxdigit(*value
)) || (!isxdigit(*(value
+1))))
1637 #ifdef CONFIG_STA_SUPPORT
1638 AtoH(value
, &pAd
->ate
.Addr3
[i
++], 1);
1639 #endif // CONFIG_STA_SUPPORT //
1648 #ifdef CONFIG_STA_SUPPORT
1649 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Set_ATE_DA_Proc (DA = %2X:%2X:%2X:%2X:%2X:%2X)\n", pAd
->ate
.Addr3
[0],
1650 pAd
->ate
.Addr3
[1], pAd
->ate
.Addr3
[2], pAd
->ate
.Addr3
[3], pAd
->ate
.Addr3
[4], pAd
->ate
.Addr3
[5]));
1651 #endif // CONFIG_STA_SUPPORT //
1653 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Ralink: Set_ATE_DA_Proc Success\n"));
1660 ==========================================================================
1662 Set ATE ADDR3=SA for TxFrame(AP : To DS = 0 ; From DS = 1)
1664 Set ATE ADDR2=SA for TxFrame(STA : To DS = 1 ; From DS = 0)
1667 TRUE if all parameters are OK, FALSE otherwise
1668 ==========================================================================
1670 INT
Set_ATE_SA_Proc(
1671 IN PRTMP_ADAPTER pAd
,
1677 // Mac address acceptable format 01:02:03:04:05:06 length 17
1678 if (strlen(arg
) != 17)
1681 for (i
=0, value
= rstrtok(arg
, ":"); value
; value
= rstrtok(NULL
, ":"))
1684 if ((strlen(value
) != 2) || (!isxdigit(*value
)) || (!isxdigit(*(value
+1))))
1689 #ifdef CONFIG_STA_SUPPORT
1690 AtoH(value
, &pAd
->ate
.Addr2
[i
++], 1);
1691 #endif // CONFIG_STA_SUPPORT //
1700 #ifdef CONFIG_STA_SUPPORT
1701 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Set_ATE_SA_Proc (SA = %2X:%2X:%2X:%2X:%2X:%2X)\n", pAd
->ate
.Addr2
[0],
1702 pAd
->ate
.Addr2
[1], pAd
->ate
.Addr2
[2], pAd
->ate
.Addr2
[3], pAd
->ate
.Addr2
[4], pAd
->ate
.Addr2
[5]));
1703 #endif // CONFIG_STA_SUPPORT //
1705 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Ralink: Set_ATE_SA_Proc Success\n"));
1712 ==========================================================================
1714 Set ATE ADDR2=BSSID for TxFrame(AP : To DS = 0 ; From DS = 1)
1716 Set ATE ADDR1=BSSID for TxFrame(STA : To DS = 1 ; From DS = 0)
1719 TRUE if all parameters are OK, FALSE otherwise
1720 ==========================================================================
1722 INT
Set_ATE_BSSID_Proc(
1723 IN PRTMP_ADAPTER pAd
,
1729 // Mac address acceptable format 01:02:03:04:05:06 length 17
1730 if (strlen(arg
) != 17)
1733 for (i
=0, value
= rstrtok(arg
, ":"); value
; value
= rstrtok(NULL
, ":"))
1736 if ((strlen(value
) != 2) || (!isxdigit(*value
)) || (!isxdigit(*(value
+1))))
1741 #ifdef CONFIG_STA_SUPPORT
1742 AtoH(value
, &pAd
->ate
.Addr1
[i
++], 1);
1743 #endif // CONFIG_STA_SUPPORT //
1752 #ifdef CONFIG_STA_SUPPORT
1753 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Set_ATE_BSSID_Proc (BSSID = %2X:%2X:%2X:%2X:%2X:%2X)\n", pAd
->ate
.Addr1
[0],
1754 pAd
->ate
.Addr1
[1], pAd
->ate
.Addr1
[2], pAd
->ate
.Addr1
[3], pAd
->ate
.Addr1
[4], pAd
->ate
.Addr1
[5]));
1755 #endif // CONFIG_STA_SUPPORT //
1757 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Ralink: Set_ATE_BSSID_Proc Success\n"));
1764 ==========================================================================
1769 TRUE if all parameters are OK, FALSE otherwise
1770 ==========================================================================
1772 INT
Set_ATE_CHANNEL_Proc(
1773 IN PRTMP_ADAPTER pAd
,
1778 channel
= simple_strtol(arg
, 0, 10);
1780 // to allow A band channel : ((channel < 1) || (channel > 14))
1781 if ((channel
< 1) || (channel
> 216))
1783 ATEDBGPRINT(RT_DEBUG_ERROR
, ("Set_ATE_CHANNEL_Proc::Out of range, it should be in range of 1~14.\n"));
1786 pAd
->ate
.Channel
= channel
;
1788 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Set_ATE_CHANNEL_Proc (ATE Channel = %d)\n", pAd
->ate
.Channel
));
1789 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Ralink: Set_ATE_CHANNEL_Proc Success\n"));
1797 ==========================================================================
1802 TRUE if all parameters are OK, FALSE otherwise
1803 ==========================================================================
1805 INT
Set_ATE_TX_POWER0_Proc(
1806 IN PRTMP_ADAPTER pAd
,
1811 TxPower
= simple_strtol(arg
, 0, 10);
1813 if (pAd
->ate
.Channel
<= 14)
1815 if ((TxPower
> 31) || (TxPower
< 0))
1817 ATEDBGPRINT(RT_DEBUG_ERROR
, ("Set_ATE_TX_POWER0_Proc::Out of range (Value=%d)\n", TxPower
));
1823 if ((TxPower
> 15) || (TxPower
< -7))
1825 ATEDBGPRINT(RT_DEBUG_ERROR
, ("Set_ATE_TX_POWER0_Proc::Out of range (Value=%d)\n", TxPower
));
1830 pAd
->ate
.TxPower0
= TxPower
;
1831 ATETxPwrHandler(pAd
, 0);
1832 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Ralink: Set_ATE_TX_POWER0_Proc Success\n"));
1840 ==========================================================================
1845 TRUE if all parameters are OK, FALSE otherwise
1846 ==========================================================================
1848 INT
Set_ATE_TX_POWER1_Proc(
1849 IN PRTMP_ADAPTER pAd
,
1854 TxPower
= simple_strtol(arg
, 0, 10);
1856 if (pAd
->ate
.Channel
<= 14)
1858 if ((TxPower
> 31) || (TxPower
< 0))
1860 ATEDBGPRINT(RT_DEBUG_ERROR
, ("Set_ATE_TX_POWER1_Proc::Out of range (Value=%d)\n", TxPower
));
1866 if ((TxPower
> 15) || (TxPower
< -7))
1868 ATEDBGPRINT(RT_DEBUG_ERROR
, ("Set_ATE_TX_POWER1_Proc::Out of range (Value=%d)\n", TxPower
));
1873 pAd
->ate
.TxPower1
= TxPower
;
1874 ATETxPwrHandler(pAd
, 1);
1875 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Ralink: Set_ATE_TX_POWER1_Proc Success\n"));
1883 ==========================================================================
1888 TRUE if all parameters are OK, FALSE otherwise
1889 ==========================================================================
1891 INT
Set_ATE_TX_Antenna_Proc(
1892 IN PRTMP_ADAPTER pAd
,
1897 value
= simple_strtol(arg
, 0, 10);
1899 if ((value
> 2) || (value
< 0))
1901 ATEDBGPRINT(RT_DEBUG_ERROR
, ("Set_ATE_TX_Antenna_Proc::Out of range (Value=%d)\n", value
));
1905 pAd
->ate
.TxAntennaSel
= value
;
1907 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Set_ATE_TX_Antenna_Proc (Antenna = %d)\n", pAd
->ate
.TxAntennaSel
));
1908 ATEDBGPRINT(RT_DEBUG_TRACE
,("Ralink: Set_ATE_TX_Antenna_Proc Success\n"));
1910 // calibration power unbalance issues, merged from Arch Team
1911 ATEAsicSwitchChannel(pAd
);
1919 ==========================================================================
1924 TRUE if all parameters are OK, FALSE otherwise
1925 ==========================================================================
1927 INT
Set_ATE_RX_Antenna_Proc(
1928 IN PRTMP_ADAPTER pAd
,
1933 value
= simple_strtol(arg
, 0, 10);
1935 if ((value
> 3) || (value
< 0))
1937 ATEDBGPRINT(RT_DEBUG_ERROR
, ("Set_ATE_RX_Antenna_Proc::Out of range (Value=%d)\n", value
));
1941 pAd
->ate
.RxAntennaSel
= value
;
1943 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Set_ATE_RX_Antenna_Proc (Antenna = %d)\n", pAd
->ate
.RxAntennaSel
));
1944 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Ralink: Set_ATE_RX_Antenna_Proc Success\n"));
1946 // calibration power unbalance issues, merged from Arch Team
1947 ATEAsicSwitchChannel(pAd
);
1955 ==========================================================================
1957 Set ATE RF frequence offset
1960 TRUE if all parameters are OK, FALSE otherwise
1961 ==========================================================================
1963 INT
Set_ATE_TX_FREQOFFSET_Proc(
1964 IN PRTMP_ADAPTER pAd
,
1967 UCHAR RFFreqOffset
= 0;
1970 RFFreqOffset
= simple_strtol(arg
, 0, 10);
1971 #ifndef RTMP_RF_RW_SUPPORT
1972 if (RFFreqOffset
>= 64)
1973 #endif // RTMP_RF_RW_SUPPORT //
1974 /* RT35xx ATE will reuse this code segment. */
1975 #ifdef RTMP_RF_RW_SUPPORT
1976 //2008/08/06: KH modified the limit of offset value from 65 to 95(0x5F)
1977 if (RFFreqOffset
>= 95)
1978 #endif // RTMP_RF_RW_SUPPORT //
1980 ATEDBGPRINT(RT_DEBUG_ERROR
, ("Set_ATE_TX_FREQOFFSET_Proc::Out of range, it should be in range of 0~63.\n"));
1984 pAd
->ate
.RFFreqOffset
= RFFreqOffset
;
1985 #ifdef RTMP_RF_RW_SUPPORT
1986 if (IS_RT30xx(pAd
) || IS_RT3572(pAd
))
1990 ATE_RF_IO_READ8_BY_REG_ID(pAd
, RF_R23
, (PUCHAR
)&RFValue
);
1991 //2008/08/06: KH modified "pAd->RFFreqOffset" to "pAd->ate.RFFreqOffset"
1992 RFValue
= ((RFValue
& 0x80) | pAd
->ate
.RFFreqOffset
);
1993 ATE_RF_IO_WRITE8_BY_REG_ID(pAd
, RF_R23
, (UCHAR
)RFValue
);
1996 #endif // RTMP_RF_RW_SUPPORT //
1999 // shift TX power control to correct RF register bit position
2000 R4
= pAd
->ate
.RFFreqOffset
<< 15;
2001 R4
|= (pAd
->LatchRfRegs
.R4
& ((~0x001f8000)));
2002 pAd
->LatchRfRegs
.R4
= R4
;
2006 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Set_ATE_TX_FREQOFFSET_Proc (RFFreqOffset = %d)\n", pAd
->ate
.RFFreqOffset
));
2007 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Ralink: Set_ATE_TX_FREQOFFSET_Proc Success\n"));
2015 ==========================================================================
2020 TRUE if all parameters are OK, FALSE otherwise
2021 ==========================================================================
2023 INT
Set_ATE_TX_BW_Proc(
2024 IN PRTMP_ADAPTER pAd
,
2031 BBPCurrentBW
= simple_strtol(arg
, 0, 10);
2033 if ((BBPCurrentBW
== 0)
2039 pAd
->ate
.TxWI
.BW
= BW_20
;
2043 pAd
->ate
.TxWI
.BW
= BW_40
;
2046 /* RT35xx ATE will reuse this code segment. */
2047 // Fix the error spectrum of CCK-40MHZ
2048 // Turn on BBP 20MHz mode by request here.
2049 if ((pAd
->ate
.TxWI
.PHYMODE
== MODE_CCK
) && (pAd
->ate
.TxWI
.BW
== BW_40
))
2051 ATEDBGPRINT(RT_DEBUG_ERROR
, ("Set_ATE_TX_BW_Proc!! Warning!! CCK only supports 20MHZ!!\nBandwidth switch to 20\n"));
2052 pAd
->ate
.TxWI
.BW
= BW_20
;
2055 if (pAd
->ate
.TxWI
.BW
== BW_20
)
2057 if (pAd
->ate
.Channel
<= 14)
2061 if (pAd
->Tx20MPwrCfgGBand
[i
] != 0xffffffff)
2063 RTMP_IO_WRITE32(pAd
, TX_PWR_CFG_0
+ i
*4, pAd
->Tx20MPwrCfgGBand
[i
]);
2064 RTMPusecDelay(5000);
2072 if (pAd
->Tx20MPwrCfgABand
[i
] != 0xffffffff)
2074 RTMP_IO_WRITE32(pAd
, TX_PWR_CFG_0
+ i
*4, pAd
->Tx20MPwrCfgABand
[i
]);
2075 RTMPusecDelay(5000);
2080 // Set BBP R4 bit[4:3]=0:0
2081 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R4
, &value
);
2083 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R4
, value
);
2088 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R66
, value
);
2091 // to improve Rx sensitivity.
2093 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R68
, value
);
2096 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R69
, value
);
2099 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R70
, value
);
2102 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R73
, value
);
2105 If Channel=14, Bandwidth=20M and Mode=CCK, Set BBP R4 bit5=1
2106 (to set Japan filter coefficients).
2107 This segment of code will only works when ATETXMODE and ATECHANNEL
2108 were set to MODE_CCK and 14 respectively before ATETXBW is set to 0.
2110 if (pAd
->ate
.Channel
== 14)
2112 INT TxMode
= pAd
->ate
.TxWI
.PHYMODE
;
2114 if (TxMode
== MODE_CCK
)
2116 // when Channel==14 && Mode==CCK && BandWidth==20M, BBP R4 bit5=1
2117 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R4
, &value
);
2118 value
|= 0x20; //set bit5=1
2119 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R4
, value
);
2126 ATE_RF_IO_WRITE8_BY_REG_ID(pAd
, RF_R24
, (UCHAR
) pAd
->Mlme
.CaliBW20RfR24
);
2131 pAd
->LatchRfRegs
.R4
&= ~0x00200000;
2136 // If bandwidth = 40M, set RF Reg4 bit 21 = 0.
2137 else if (pAd
->ate
.TxWI
.BW
== BW_40
)
2139 if (pAd
->ate
.Channel
<= 14)
2143 if (pAd
->Tx40MPwrCfgGBand
[i
] != 0xffffffff)
2145 RTMP_IO_WRITE32(pAd
, TX_PWR_CFG_0
+ i
*4, pAd
->Tx40MPwrCfgGBand
[i
]);
2146 RTMPusecDelay(5000);
2154 if (pAd
->Tx40MPwrCfgABand
[i
] != 0xffffffff)
2156 RTMP_IO_WRITE32(pAd
, TX_PWR_CFG_0
+ i
*4, pAd
->Tx40MPwrCfgABand
[i
]);
2157 RTMPusecDelay(5000);
2160 #ifdef DOT11_N_SUPPORT
2161 if ((pAd
->ate
.TxWI
.PHYMODE
>= MODE_HTMIX
) && (pAd
->ate
.TxWI
.MCS
== 7))
2164 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R67
, value
);
2166 #endif // DOT11_N_SUPPORT //
2169 // Set BBP R4 bit[4:3]=1:0
2170 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R4
, &value
);
2173 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R4
, value
);
2178 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R66
, value
);
2181 // to improve Rx sensitivity
2183 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R68
, value
);
2186 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R69
, value
);
2189 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R70
, value
);
2192 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R73
, value
);
2194 // If bandwidth = 40M, set RF Reg4 bit 21 = 1.
2198 ATE_RF_IO_WRITE8_BY_REG_ID(pAd
, RF_R24
, (UCHAR
) pAd
->Mlme
.CaliBW40RfR24
);
2203 pAd
->LatchRfRegs
.R4
|= 0x00200000;
2208 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Set_ATE_TX_BW_Proc (BBPCurrentBW = %d)\n", pAd
->ate
.TxWI
.BW
));
2209 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Ralink: Set_ATE_TX_BW_Proc Success\n"));
2217 ==========================================================================
2219 Set ATE Tx frame length
2222 TRUE if all parameters are OK, FALSE otherwise
2223 ==========================================================================
2225 INT
Set_ATE_TX_LENGTH_Proc(
2226 IN PRTMP_ADAPTER pAd
,
2229 pAd
->ate
.TxLength
= simple_strtol(arg
, 0, 10);
2231 if ((pAd
->ate
.TxLength
< 24) || (pAd
->ate
.TxLength
> (MAX_FRAME_SIZE
- 34/* == 2312 */)))
2233 pAd
->ate
.TxLength
= (MAX_FRAME_SIZE
- 34/* == 2312 */);
2234 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 */)));
2238 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Set_ATE_TX_LENGTH_Proc (TxLength = %d)\n", pAd
->ate
.TxLength
));
2239 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Ralink: Set_ATE_TX_LENGTH_Proc Success\n"));
2247 ==========================================================================
2249 Set ATE Tx frame count
2252 TRUE if all parameters are OK, FALSE otherwise
2253 ==========================================================================
2255 INT
Set_ATE_TX_COUNT_Proc(
2256 IN PRTMP_ADAPTER pAd
,
2259 pAd
->ate
.TxCount
= simple_strtol(arg
, 0, 10);
2261 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Set_ATE_TX_COUNT_Proc (TxCount = %d)\n", pAd
->ate
.TxCount
));
2262 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Ralink: Set_ATE_TX_COUNT_Proc Success\n"));
2270 ==========================================================================
2272 Set ATE Tx frame MCS
2275 TRUE if all parameters are OK, FALSE otherwise
2276 ==========================================================================
2278 INT
Set_ATE_TX_MCS_Proc(
2279 IN PRTMP_ADAPTER pAd
,
2285 MCS
= simple_strtol(arg
, 0, 10);
2287 result
= CheckMCSValid(pAd
->ate
.TxWI
.PHYMODE
, MCS
);
2290 /* RT35xx ATE will reuse this code segment. */
2292 result
= CheckMCSValid(pAd
->ate
.TxWI
.PHYMODE
, MCS
, IS_RT2070(pAd
));
2298 pAd
->ate
.TxWI
.MCS
= (UCHAR
)MCS
;
2302 ATEDBGPRINT(RT_DEBUG_ERROR
, ("Set_ATE_TX_MCS_Proc::Out of range, refer to rate table.\n"));
2306 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Set_ATE_TX_MCS_Proc (MCS = %d)\n", pAd
->ate
.TxWI
.MCS
));
2307 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Ralink: Set_ATE_TX_MCS_Proc Success\n"));
2315 ==========================================================================
2317 Set ATE Tx frame Mode
2321 3: MODE_HTGREENFIELD
2324 TRUE if all parameters are OK, FALSE otherwise
2325 ==========================================================================
2327 INT
Set_ATE_TX_MODE_Proc(
2328 IN PRTMP_ADAPTER pAd
,
2333 pAd
->ate
.TxWI
.PHYMODE
= simple_strtol(arg
, 0, 10);
2335 if (pAd
->ate
.TxWI
.PHYMODE
> 3)
2337 pAd
->ate
.TxWI
.PHYMODE
= 0;
2338 ATEDBGPRINT(RT_DEBUG_ERROR
, ("Set_ATE_TX_MODE_Proc::Out of range.\nIt should be in range of 0~3\n"));
2339 ATEDBGPRINT(RT_DEBUG_ERROR
, ("0: CCK, 1: OFDM, 2: HT_MIX, 3: HT_GREEN_FIELD.\n"));
2343 // Turn on BBP 20MHz mode by request here.
2344 if (pAd
->ate
.TxWI
.PHYMODE
== MODE_CCK
)
2346 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R4
, &BbpData
);
2348 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R4
, BbpData
);
2349 pAd
->ate
.TxWI
.BW
= BW_20
;
2350 ATEDBGPRINT(RT_DEBUG_ERROR
, ("Set_ATE_TX_MODE_Proc::CCK Only support 20MHZ. Switch to 20MHZ.\n"));
2353 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Set_ATE_TX_MODE_Proc (TxMode = %d)\n", pAd
->ate
.TxWI
.PHYMODE
));
2354 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Ralink: Set_ATE_TX_MODE_Proc Success\n"));
2362 ==========================================================================
2367 TRUE if all parameters are OK, FALSE otherwise
2368 ==========================================================================
2370 INT
Set_ATE_TX_GI_Proc(
2371 IN PRTMP_ADAPTER pAd
,
2374 pAd
->ate
.TxWI
.ShortGI
= simple_strtol(arg
, 0, 10);
2376 if (pAd
->ate
.TxWI
.ShortGI
> 1)
2378 pAd
->ate
.TxWI
.ShortGI
= 0;
2379 ATEDBGPRINT(RT_DEBUG_ERROR
, ("Set_ATE_TX_GI_Proc::Out of range\n"));
2383 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Set_ATE_TX_GI_Proc (GI = %d)\n", pAd
->ate
.TxWI
.ShortGI
));
2384 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Ralink: Set_ATE_TX_GI_Proc Success\n"));
2391 INT
Set_ATE_RX_FER_Proc(
2392 IN PRTMP_ADAPTER pAd
,
2395 pAd
->ate
.bRxFER
= simple_strtol(arg
, 0, 10);
2397 if (pAd
->ate
.bRxFER
== 1)
2399 pAd
->ate
.RxCntPerSec
= 0;
2400 pAd
->ate
.RxTotalCnt
= 0;
2403 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Set_ATE_RX_FER_Proc (bRxFER = %d)\n", pAd
->ate
.bRxFER
));
2404 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Ralink: Set_ATE_RX_FER_Proc Success\n"));
2411 INT
Set_ATE_Read_RF_Proc(
2412 IN PRTMP_ADAPTER pAd
,
2415 #ifdef RTMP_RF_RW_SUPPORT
2416 //2008/07/10:KH add to support RT30xx ATE<--
2417 if (IS_RT30xx(pAd
) || IS_RT3572(pAd
))
2419 /* modify by WY for Read RF Reg. error */
2423 for (index
= 0; index
< 32; index
++)
2425 ATE_RF_IO_READ8_BY_REG_ID(pAd
, index
, (PUCHAR
)&RFValue
);
2426 ate_print("R%d=%d\n",index
,RFValue
);
2430 //2008/07/10:KH add to support RT30xx ATE-->
2431 #endif // RTMP_RF_RW_SUPPORT //
2433 ate_print(KERN_EMERG
"R1 = %lx\n", pAd
->LatchRfRegs
.R1
);
2434 ate_print(KERN_EMERG
"R2 = %lx\n", pAd
->LatchRfRegs
.R2
);
2435 ate_print(KERN_EMERG
"R3 = %lx\n", pAd
->LatchRfRegs
.R3
);
2436 ate_print(KERN_EMERG
"R4 = %lx\n", pAd
->LatchRfRegs
.R4
);
2442 INT
Set_ATE_Write_RF1_Proc(
2443 IN PRTMP_ADAPTER pAd
,
2446 UINT32 value
= (UINT32
) simple_strtol(arg
, 0, 16);
2448 #ifdef RTMP_RF_RW_SUPPORT
2449 //2008/07/10:KH add to support 3070 ATE<--
2450 if (IS_RT30xx(pAd
) || IS_RT3572(pAd
))
2452 ate_print("Warning!! RT3xxx Don't Support !\n");
2457 //2008/07/10:KH add to support 3070 ATE-->
2458 #endif // RTMP_RF_RW_SUPPORT //
2460 pAd
->LatchRfRegs
.R1
= value
;
2467 INT
Set_ATE_Write_RF2_Proc(
2468 IN PRTMP_ADAPTER pAd
,
2471 UINT32 value
= (UINT32
) simple_strtol(arg
, 0, 16);
2473 #ifdef RTMP_RF_RW_SUPPORT
2474 //2008/07/10:KH add to support 3070 ATE<--
2475 if (IS_RT30xx(pAd
) || IS_RT3572(pAd
))
2477 ate_print("Warning!! RT3xxx Don't Support !\n");
2482 //2008/07/10:KH add to support 3070 ATE-->
2483 #endif // RTMP_RF_RW_SUPPORT //
2485 pAd
->LatchRfRegs
.R2
= value
;
2492 INT
Set_ATE_Write_RF3_Proc(
2493 IN PRTMP_ADAPTER pAd
,
2496 UINT32 value
= simple_strtol(arg
, 0, 16);
2498 #ifdef RTMP_RF_RW_SUPPORT
2499 //2008/07/10:KH add to support 3070 ATE<--
2500 if (IS_RT30xx(pAd
) || IS_RT3572(pAd
))
2502 ate_print("Warning!! RT3xxx Don't Support !\n");
2507 //2008/07/10:KH add to support 3070 ATE-->
2508 #endif // RTMP_RF_RW_SUPPORT //
2510 pAd
->LatchRfRegs
.R3
= value
;
2517 INT
Set_ATE_Write_RF4_Proc(
2518 IN PRTMP_ADAPTER pAd
,
2521 UINT32 value
= (UINT32
) simple_strtol(arg
, 0, 16);
2523 #ifdef RTMP_RF_RW_SUPPORT
2524 //2008/07/10:KH add to support 3070 ATE<--
2525 if (IS_RT30xx(pAd
) || IS_RT3572(pAd
))
2527 ate_print("Warning!! RT3xxx Don't Support !\n");
2532 //2008/07/10:KH add to support 3070 ATE-->
2533 #endif // RTMP_RF_RW_SUPPORT //
2535 pAd
->LatchRfRegs
.R4
= value
;
2543 ==========================================================================
2545 Load and Write EEPROM from a binary file prepared in advance.
2548 TRUE if all parameters are OK, FALSE otherwise
2549 ==========================================================================
2551 #if defined(LINUX) || defined(VXWORKS)
2552 INT
Set_ATE_Load_E2P_Proc(
2553 IN PRTMP_ADAPTER pAd
,
2556 BOOLEAN ret
= FALSE
;
2557 PSTRING src
= EEPROM_BIN_FILE_NAME
;
2560 USHORT WriteEEPROM
[(EEPROM_SIZE
/2)];
2562 UINT32 value
= (UINT32
) simple_strtol(arg
, 0, 10);
2563 RTMP_OS_FS_INFO osFSInfo
;
2565 ATEDBGPRINT(RT_DEBUG_ERROR
, ("===> %s (value=%d)\n\n", __FUNCTION__
, value
));
2569 /* zero the e2p buffer */
2570 NdisZeroMemory((PUCHAR
)WriteEEPROM
, EEPROM_SIZE
);
2572 RtmpOSFSInfoChange(&osFSInfo
, TRUE
);
2576 /* open the bin file */
2577 srcf
= RtmpOSFileOpen(src
, O_RDONLY
, 0);
2579 if (IS_FILE_OPEN_ERR(srcf
))
2581 ate_print("%s - Error opening file %s\n", __FUNCTION__
, src
);
2585 /* read the firmware from the file *.bin */
2586 FileLength
= RtmpOSFileRead(srcf
, (PSTRING
)WriteEEPROM
, EEPROM_SIZE
);
2588 if (FileLength
!= EEPROM_SIZE
)
2590 ate_print("%s: error file length (=%d) in e2p.bin\n",
2591 __FUNCTION__
, FileLength
);
2596 /* write the content of .bin file to EEPROM */
2597 rt_ee_write_all(pAd
, WriteEEPROM
);
2603 /* close firmware file */
2604 if (IS_FILE_OPEN_ERR(srcf
))
2610 retval
= RtmpOSFileClose(srcf
);
2614 ATEDBGPRINT(RT_DEBUG_ERROR
, ("--> Error %d closing %s\n", -retval
, src
));
2620 RtmpOSFSInfoChange(&osFSInfo
, FALSE
);
2623 ATEDBGPRINT(RT_DEBUG_ERROR
, ("<=== %s (ret=%d)\n", __FUNCTION__
, ret
));
2628 #endif // defined(LINUX) || defined(VXWORKS) //
2633 INT
Set_ATE_Read_E2P_Proc(
2634 IN PRTMP_ADAPTER pAd
,
2637 USHORT buffer
[EEPROM_SIZE
/2];
2641 rt_ee_read_all(pAd
, (USHORT
*)buffer
);
2643 for (i
= 0; i
< (EEPROM_SIZE
/2); i
++)
2645 ate_print("%4.4x ", *p
);
2646 if (((i
+1) % 16) == 0)
2656 INT
Set_ATE_Show_Proc(
2657 IN PRTMP_ADAPTER pAd
,
2660 ate_print("Mode=%d\n", pAd
->ate
.Mode
);
2661 ate_print("TxPower0=%d\n", pAd
->ate
.TxPower0
);
2662 ate_print("TxPower1=%d\n", pAd
->ate
.TxPower1
);
2663 ate_print("TxAntennaSel=%d\n", pAd
->ate
.TxAntennaSel
);
2664 ate_print("RxAntennaSel=%d\n", pAd
->ate
.RxAntennaSel
);
2665 ate_print("BBPCurrentBW=%d\n", pAd
->ate
.TxWI
.BW
);
2666 ate_print("GI=%d\n", pAd
->ate
.TxWI
.ShortGI
);
2667 ate_print("MCS=%d\n", pAd
->ate
.TxWI
.MCS
);
2668 ate_print("TxMode=%d\n", pAd
->ate
.TxWI
.PHYMODE
);
2669 ate_print("Addr1=%02x:%02x:%02x:%02x:%02x:%02x\n",
2670 pAd
->ate
.Addr1
[0], pAd
->ate
.Addr1
[1], pAd
->ate
.Addr1
[2], pAd
->ate
.Addr1
[3], pAd
->ate
.Addr1
[4], pAd
->ate
.Addr1
[5]);
2671 ate_print("Addr2=%02x:%02x:%02x:%02x:%02x:%02x\n",
2672 pAd
->ate
.Addr2
[0], pAd
->ate
.Addr2
[1], pAd
->ate
.Addr2
[2], pAd
->ate
.Addr2
[3], pAd
->ate
.Addr2
[4], pAd
->ate
.Addr2
[5]);
2673 ate_print("Addr3=%02x:%02x:%02x:%02x:%02x:%02x\n",
2674 pAd
->ate
.Addr3
[0], pAd
->ate
.Addr3
[1], pAd
->ate
.Addr3
[2], pAd
->ate
.Addr3
[3], pAd
->ate
.Addr3
[4], pAd
->ate
.Addr3
[5]);
2675 ate_print("Channel=%d\n", pAd
->ate
.Channel
);
2676 ate_print("TxLength=%d\n", pAd
->ate
.TxLength
);
2677 ate_print("TxCount=%u\n", pAd
->ate
.TxCount
);
2678 ate_print("RFFreqOffset=%d\n", pAd
->ate
.RFFreqOffset
);
2679 ate_print(KERN_EMERG
"Set_ATE_Show_Proc Success\n");
2684 INT
Set_ATE_Help_Proc(
2685 IN PRTMP_ADAPTER pAd
,
2688 ate_print("ATE=ATESTART, ATESTOP, TXCONT, TXCARR, TXFRAME, RXFRAME\n");
2689 ate_print("ATEDA\n");
2690 ate_print("ATESA\n");
2691 ate_print("ATEBSSID\n");
2692 ate_print("ATECHANNEL, range:0~14(unless A band !)\n");
2693 ate_print("ATETXPOW0, set power level of antenna 1.\n");
2694 ate_print("ATETXPOW1, set power level of antenna 2.\n");
2695 ate_print("ATETXANT, set TX antenna. 0:all, 1:antenna one, 2:antenna two.\n");
2696 ate_print("ATERXANT, set RX antenna.0:all, 1:antenna one, 2:antenna two, 3:antenna three.\n");
2697 ate_print("ATETXFREQOFFSET, set frequency offset, range 0~63\n");
2698 ate_print("ATETXBW, set BandWidth, 0:20MHz, 1:40MHz.\n");
2699 ate_print("ATETXLEN, set Frame length, range 24~%d\n", (MAX_FRAME_SIZE
- 34/* == 2312 */));
2700 ate_print("ATETXCNT, set how many frame going to transmit.\n");
2701 ate_print("ATETXMCS, set MCS, reference to rate table.\n");
2702 ate_print("ATETXMODE, set Mode 0:CCK, 1:OFDM, 2:HT-Mix, 3:GreenField, reference to rate table.\n");
2703 ate_print("ATETXGI, set GI interval, 0:Long, 1:Short\n");
2704 ate_print("ATERXFER, 0:disable Rx Frame error rate. 1:enable Rx Frame error rate.\n");
2705 ate_print("ATERRF, show all RF registers.\n");
2706 ate_print("ATEWRF1, set RF1 register.\n");
2707 ate_print("ATEWRF2, set RF2 register.\n");
2708 ate_print("ATEWRF3, set RF3 register.\n");
2709 ate_print("ATEWRF4, set RF4 register.\n");
2710 ate_print("ATELDE2P, load EEPROM from .bin file.\n");
2711 ate_print("ATERE2P, display all EEPROM content.\n");
2712 ate_print("ATESHOW, display all parameters of ATE.\n");
2713 ate_print("ATEHELP, online help.\n");
2722 ==========================================================================
2725 AsicSwitchChannel() dedicated for ATE.
2727 ==========================================================================
2729 VOID
ATEAsicSwitchChannel(
2730 IN PRTMP_ADAPTER pAd
)
2732 UINT32 R2
= 0, R3
= DEFAULT_RF_TX_POWER
, R4
= 0, Value
= 0;
2733 CHAR TxPwer
= 0, TxPwer2
= 0;
2734 UCHAR index
= 0, BbpValue
= 0, R66
= 0x30;
2735 RTMP_RF_REGS
*RFRegTable
;
2740 #ifdef RALINK_28xx_QA
2741 // for QA mode, TX power values are passed from UI
2742 if ((pAd
->ate
.bQATxStart
== TRUE
) || (pAd
->ate
.bQARxStart
== TRUE
))
2744 if (pAd
->ate
.Channel
!= pAd
->LatchRfRegs
.Channel
)
2746 pAd
->ate
.Channel
= pAd
->LatchRfRegs
.Channel
;
2751 #endif // RALINK_28xx_QA //
2752 Channel
= pAd
->ate
.Channel
;
2754 // select antenna for RT3090
2755 AsicAntennaSelect(pAd
, Channel
);
2757 // fill Tx power value
2758 TxPwer
= pAd
->ate
.TxPower0
;
2759 TxPwer2
= pAd
->ate
.TxPower1
;
2761 //2008/07/10:KH add to support 3070 ATE<--
2764 The RF programming sequence is difference between 3xxx and 2xxx.
2765 The 3070 is 1T1R. Therefore, we don't need to set the number of Tx/Rx path
2766 and the only job is to set the parameters of channels.
2768 if (IS_RT30xx(pAd
) && ((pAd
->RfIcType
== RFIC_3020
) ||
2769 (pAd
->RfIcType
== RFIC_3021
) || (pAd
->RfIcType
== RFIC_3022
) ||
2770 (pAd
->RfIcType
== RFIC_2020
)))
2772 /* modify by WY for Read RF Reg. error */
2775 for (index
= 0; index
< NUM_OF_3020_CHNL
; index
++)
2777 if (Channel
== FreqItems3020
[index
].Channel
)
2779 // Programming channel parameters.
2780 ATE_RF_IO_WRITE8_BY_REG_ID(pAd
, RF_R02
, FreqItems3020
[index
].N
);
2781 ATE_RF_IO_WRITE8_BY_REG_ID(pAd
, RF_R03
, FreqItems3020
[index
].K
);
2783 ATE_RF_IO_READ8_BY_REG_ID(pAd
, RF_R06
, (PUCHAR
)&RFValue
);
2784 RFValue
= (RFValue
& 0xFC) | FreqItems3020
[index
].R
;
2785 ATE_RF_IO_WRITE8_BY_REG_ID(pAd
, RF_R06
, (UCHAR
)RFValue
);
2788 ATE_RF_IO_READ8_BY_REG_ID(pAd
, RF_R12
, (PUCHAR
)&RFValue
);
2789 RFValue
= (RFValue
& 0xE0) | TxPwer
;
2790 ATE_RF_IO_WRITE8_BY_REG_ID(pAd
, RF_R12
, (UCHAR
)RFValue
);
2793 ATE_RF_IO_READ8_BY_REG_ID(pAd
, RF_R23
, (PUCHAR
)&RFValue
);
2794 //2008/08/06: KH modified "pAd->RFFreqOffset" to "pAd->ate.RFFreqOffset"
2795 RFValue
= (RFValue
& 0x80) | pAd
->ate
.RFFreqOffset
;
2796 ATE_RF_IO_WRITE8_BY_REG_ID(pAd
, RF_R23
, (UCHAR
)RFValue
);
2799 if (pAd
->ate
.TxWI
.BW
== BW_40
)
2801 RFValue
= pAd
->Mlme
.CaliBW40RfR24
;
2802 // DISABLE_11N_CHECK(pAd);
2806 RFValue
= pAd
->Mlme
.CaliBW20RfR24
;
2808 ATE_RF_IO_WRITE8_BY_REG_ID(pAd
, RF_R24
, (UCHAR
)RFValue
);
2811 ATE_RF_IO_READ8_BY_REG_ID(pAd
, RF_R07
, (PUCHAR
)&RFValue
);
2812 RFValue
= RFValue
| 0x1;
2813 ATE_RF_IO_WRITE8_BY_REG_ID(pAd
, RF_R07
, (UCHAR
)RFValue
);
2815 // latch channel for future usage
2816 pAd
->LatchRfRegs
.Channel
= Channel
;
2822 ATEDBGPRINT(RT_DEBUG_TRACE
, ("SwitchChannel#%d(RF=%d, Pwr0=%d, Pwr1=%d, %dT), N=0x%02X, K=0x%02X, R=0x%02X\n",
2827 pAd
->Antenna
.field
.TxPath
,
2828 FreqItems3020
[index
].N
,
2829 FreqItems3020
[index
].K
,
2830 FreqItems3020
[index
].R
));
2833 //2008/07/10:KH add to support 3070 ATE-->
2837 RFRegTable
= RF2850RegTable
;
2839 switch (pAd
->RfIcType
)
2841 /* But only 2850 and 2750 support 5.5GHz band... */
2847 for (index
= 0; index
< NUM_OF_2850_CHNL
; index
++)
2849 if (Channel
== RFRegTable
[index
].Channel
)
2851 R2
= RFRegTable
[index
].R2
;
2853 // If TX path is 1, bit 14 = 1;
2854 if (pAd
->Antenna
.field
.TxPath
== 1)
2859 if (pAd
->Antenna
.field
.RxPath
== 2)
2861 switch (pAd
->ate
.RxAntennaSel
)
2865 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R3
, &BbpValue
);
2868 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R3
, BbpValue
);
2872 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R3
, &BbpValue
);
2875 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R3
, BbpValue
);
2879 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R3
, &BbpValue
);
2881 /* Only enable two Antenna to receive. */
2883 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R3
, BbpValue
);
2887 else if (pAd
->Antenna
.field
.RxPath
== 1)
2889 // write 1 to off RxPath
2893 if (pAd
->Antenna
.field
.TxPath
== 2)
2895 if (pAd
->ate
.TxAntennaSel
== 1)
2897 // If TX Antenna select is 1 , bit 14 = 1; Disable Ant 2
2899 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R1
, &BbpValue
);
2900 BbpValue
&= 0xE7; // 11100111B
2901 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R1
, BbpValue
);
2903 else if (pAd
->ate
.TxAntennaSel
== 2)
2905 // If TX Antenna select is 2 , bit 15 = 1; Disable Ant 1
2907 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R1
, &BbpValue
);
2910 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R1
, BbpValue
);
2914 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R1
, &BbpValue
);
2917 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R1
, BbpValue
);
2920 if (pAd
->Antenna
.field
.RxPath
== 3)
2922 switch (pAd
->ate
.RxAntennaSel
)
2926 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R3
, &BbpValue
);
2929 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R3
, BbpValue
);
2933 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R3
, &BbpValue
);
2936 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R3
, BbpValue
);
2940 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R3
, &BbpValue
);
2943 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R3
, BbpValue
);
2946 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R3
, &BbpValue
);
2949 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R3
, BbpValue
);
2956 // initialize R3, R4
2957 R3
= (RFRegTable
[index
].R3
& 0xffffc1ff);
2958 R4
= (RFRegTable
[index
].R4
& (~0x001f87c0)) | (pAd
->ate
.RFFreqOffset
<< 15);
2961 According the Rory's suggestion to solve the middle range issue.
2963 5.5G band power range : 0xF9~0X0F, TX0 Reg3 bit9/TX1 Reg4 bit6="0"
2964 means the TX power reduce 7dB.
2967 if ((TxPwer
>= -7) && (TxPwer
< 0))
2969 TxPwer
= (7+TxPwer
);
2970 TxPwer
= (TxPwer
> 0xF) ? (0xF) : (TxPwer
);
2971 R3
|= (TxPwer
<< 10);
2972 ATEDBGPRINT(RT_DEBUG_TRACE
, ("ATEAsicSwitchChannel: TxPwer=%d \n", TxPwer
));
2976 TxPwer
= (TxPwer
> 0xF) ? (0xF) : (TxPwer
);
2977 R3
|= (TxPwer
<< 10) | (1 << 9);
2981 if ((TxPwer2
>= -7) && (TxPwer2
< 0))
2983 TxPwer2
= (7+TxPwer2
);
2984 TxPwer2
= (TxPwer2
> 0xF) ? (0xF) : (TxPwer2
);
2985 R4
|= (TxPwer2
<< 7);
2986 ATEDBGPRINT(RT_DEBUG_TRACE
, ("ATEAsicSwitchChannel: TxPwer2=%d \n", TxPwer2
));
2990 TxPwer2
= (TxPwer2
> 0xF) ? (0xF) : (TxPwer2
);
2991 R4
|= (TxPwer2
<< 7) | (1 << 6);
2997 R3
= (RFRegTable
[index
].R3
& 0xffffc1ff) | (TxPwer
<< 9);
2998 // Set frequency offset and TX power1.
2999 R4
= (RFRegTable
[index
].R4
& (~0x001f87c0)) | (pAd
->ate
.RFFreqOffset
<< 15) | (TxPwer2
<<6);
3002 // based on BBP current mode before changing RF channel
3003 if (pAd
->ate
.TxWI
.BW
== BW_40
)
3008 // Update variables.
3009 pAd
->LatchRfRegs
.Channel
= Channel
;
3010 pAd
->LatchRfRegs
.R1
= RFRegTable
[index
].R1
;
3011 pAd
->LatchRfRegs
.R2
= R2
;
3012 pAd
->LatchRfRegs
.R3
= R3
;
3013 pAd
->LatchRfRegs
.R4
= R4
;
3027 // Change BBP setting during switch from a->g, g->a
3030 UINT32 TxPinCfg
= 0x00050F0A;// 2007.10.09 by Brian : 0x0005050A ==> 0x00050F0A
3032 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R62
, (0x37 - GET_LNA_GAIN(pAd
)));
3033 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R63
, (0x37 - GET_LNA_GAIN(pAd
)));
3034 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R64
, (0x37 - GET_LNA_GAIN(pAd
)));
3036 /* For 1T/2R chip only... */
3037 if (pAd
->NicConfig2
.field
.ExternalLNAForG
)
3039 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R82
, 0x62);
3043 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R82
, 0x84);
3046 // According the Rory's suggestion to solve the middle range issue.
3047 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R86
, &BbpValue
);// may be removed for RT35xx ++
3049 ASSERT((BbpValue
== 0x00));
3050 if ((BbpValue
!= 0x00))
3052 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R86
, 0x00);
3053 }// may be removed for RT35xx --
3055 // 5.5 GHz band selection PIN, bit1 and bit2 are complement
3056 RTMP_IO_READ32(pAd
, TX_BAND_CFG
, &Value
);
3059 RTMP_IO_WRITE32(pAd
, TX_BAND_CFG
, Value
);
3061 // Turn off unused PA or LNA when only 1T or 1R.
3062 if (pAd
->Antenna
.field
.TxPath
== 1)
3064 TxPinCfg
&= 0xFFFFFFF3;
3066 if (pAd
->Antenna
.field
.RxPath
== 1)
3068 TxPinCfg
&= 0xFFFFF3FF;
3071 // calibration power unbalance issues
3072 if (pAd
->Antenna
.field
.TxPath
== 2)
3074 if (pAd
->ate
.TxAntennaSel
== 1)
3076 TxPinCfg
&= 0xFFFFFFF7;
3078 else if (pAd
->ate
.TxAntennaSel
== 2)
3080 TxPinCfg
&= 0xFFFFFFFD;
3084 RTMP_IO_WRITE32(pAd
, TX_PIN_CFG
, TxPinCfg
);
3088 UINT32 TxPinCfg
= 0x00050F05;// 2007.10.09 by Brian : 0x00050505 ==> 0x00050F05
3090 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R62
, (0x37 - GET_LNA_GAIN(pAd
)));
3091 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R63
, (0x37 - GET_LNA_GAIN(pAd
)));
3092 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R64
, (0x37 - GET_LNA_GAIN(pAd
)));
3093 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R82
, 0xF2);
3095 // According the Rory's suggestion to solve the middle range issue.
3096 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R86
, &BbpValue
);// may be removed for RT35xx ++
3098 ASSERT((BbpValue
== 0x00));
3099 if ((BbpValue
!= 0x00))
3101 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R86
, 0x00);
3104 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R91
, &BbpValue
);
3105 ASSERT((BbpValue
== 0x04));
3107 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R92
, &BbpValue
);
3108 ASSERT((BbpValue
== 0x00));// may be removed for RT35xx --
3110 // 5.5 GHz band selection PIN, bit1 and bit2 are complement
3111 RTMP_IO_READ32(pAd
, TX_BAND_CFG
, &Value
);
3114 RTMP_IO_WRITE32(pAd
, TX_BAND_CFG
, Value
);
3116 // Turn off unused PA or LNA when only 1T or 1R.
3117 if (pAd
->Antenna
.field
.TxPath
== 1)
3119 TxPinCfg
&= 0xFFFFFFF3;
3121 if (pAd
->Antenna
.field
.RxPath
== 1)
3123 TxPinCfg
&= 0xFFFFF3FF;
3126 RTMP_IO_WRITE32(pAd
, TX_PIN_CFG
, TxPinCfg
);
3130 // R66 should be set according to Channel and use 20MHz when scanning
3134 R66
= 0x2E + GET_LNA_GAIN(pAd
);
3135 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R66
, R66
);
3140 if (pAd
->ate
.TxWI
.BW
== BW_20
)
3142 R66
= (UCHAR
)(0x32 + (GET_LNA_GAIN(pAd
)*5)/3);
3143 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R66
, R66
);
3147 R66
= (UCHAR
)(0x3A + (GET_LNA_GAIN(pAd
)*5)/3);
3148 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R66
, R66
);
3153 On 11A, We should delay and wait RF/BBP to be stable
3154 and the appropriate time should be 1000 micro seconds.
3156 2005/06/05 - On 11G, We also need this delay time. Otherwise it's difficult to pass the WHQL.
3158 RTMPusecDelay(1000);
3160 #ifndef RTMP_RF_RW_SUPPORT
3163 // When 5.5GHz band the LSB of TxPwr will be used to reduced 7dB or not.
3164 ATEDBGPRINT(RT_DEBUG_TRACE
, ("SwitchChannel#%d(RF=%d, %dT) to , R1=0x%08lx, R2=0x%08lx, R3=0x%08lx, R4=0x%08lx\n",
3167 pAd
->Antenna
.field
.TxPath
,
3168 pAd
->LatchRfRegs
.R1
,
3169 pAd
->LatchRfRegs
.R2
,
3170 pAd
->LatchRfRegs
.R3
,
3171 pAd
->LatchRfRegs
.R4
));
3175 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",
3178 (R3
& 0x00003e00) >> 9,
3179 (R4
& 0x000007c0) >> 6,
3180 pAd
->Antenna
.field
.TxPath
,
3181 pAd
->LatchRfRegs
.R1
,
3182 pAd
->LatchRfRegs
.R2
,
3183 pAd
->LatchRfRegs
.R3
,
3184 pAd
->LatchRfRegs
.R4
));
3186 #endif // RTMP_RF_RW_SUPPORT //
3191 /* In fact, no one will call this routine so far ! */
3194 ==========================================================================
3196 Gives CCK TX rate 2 more dB TX power.
3197 This routine works only in ATE mode.
3199 calculate desired Tx power in RF R3.Tx0~5, should consider -
3200 0. if current radio is a noisy environment (pAd->DrsCounters.fNoisyEnvironment)
3201 1. TxPowerPercentage
3202 2. auto calibration based on TSSI feedback
3203 3. extra 2 db for CCK
3204 4. -10 db upon very-short distance (AvgRSSI >= -40db) to AP
3206 NOTE: Since this routine requires the value of (pAd->DrsCounters.fNoisyEnvironment),
3207 it should be called AFTER MlmeDynamicTxRateSwitching()
3208 ==========================================================================
3210 VOID
ATEAsicAdjustTxPower(
3211 IN PRTMP_ADAPTER pAd
)
3215 BOOLEAN bAutoTxAgc
= FALSE
;
3216 UCHAR TssiRef
, *pTssiMinusBoundary
, *pTssiPlusBoundary
, TxAgcStep
;
3217 UCHAR BbpR49
= 0, idx
;
3218 PCHAR pTxAgcCompensate
;
3222 /* no one calls this procedure so far */
3223 if (pAd
->ate
.TxWI
.BW
== BW_40
)
3225 if (pAd
->ate
.Channel
> 14)
3227 TxPwr
[0] = pAd
->Tx40MPwrCfgABand
[0];
3228 TxPwr
[1] = pAd
->Tx40MPwrCfgABand
[1];
3229 TxPwr
[2] = pAd
->Tx40MPwrCfgABand
[2];
3230 TxPwr
[3] = pAd
->Tx40MPwrCfgABand
[3];
3231 TxPwr
[4] = pAd
->Tx40MPwrCfgABand
[4];
3235 TxPwr
[0] = pAd
->Tx40MPwrCfgGBand
[0];
3236 TxPwr
[1] = pAd
->Tx40MPwrCfgGBand
[1];
3237 TxPwr
[2] = pAd
->Tx40MPwrCfgGBand
[2];
3238 TxPwr
[3] = pAd
->Tx40MPwrCfgGBand
[3];
3239 TxPwr
[4] = pAd
->Tx40MPwrCfgGBand
[4];
3244 if (pAd
->ate
.Channel
> 14)
3246 TxPwr
[0] = pAd
->Tx20MPwrCfgABand
[0];
3247 TxPwr
[1] = pAd
->Tx20MPwrCfgABand
[1];
3248 TxPwr
[2] = pAd
->Tx20MPwrCfgABand
[2];
3249 TxPwr
[3] = pAd
->Tx20MPwrCfgABand
[3];
3250 TxPwr
[4] = pAd
->Tx20MPwrCfgABand
[4];
3254 TxPwr
[0] = pAd
->Tx20MPwrCfgGBand
[0];
3255 TxPwr
[1] = pAd
->Tx20MPwrCfgGBand
[1];
3256 TxPwr
[2] = pAd
->Tx20MPwrCfgGBand
[2];
3257 TxPwr
[3] = pAd
->Tx20MPwrCfgGBand
[3];
3258 TxPwr
[4] = pAd
->Tx20MPwrCfgGBand
[4];
3262 // TX power compensation for temperature variation based on TSSI.
3263 // Do it per 4 seconds.
3264 if (pAd
->Mlme
.OneSecPeriodicRound
% 4 == 0)
3266 if (pAd
->ate
.Channel
<= 14)
3269 bAutoTxAgc
= pAd
->bAutoTxAgcG
;
3270 TssiRef
= pAd
->TssiRefG
;
3271 pTssiMinusBoundary
= &pAd
->TssiMinusBoundaryG
[0];
3272 pTssiPlusBoundary
= &pAd
->TssiPlusBoundaryG
[0];
3273 TxAgcStep
= pAd
->TxAgcStepG
;
3274 pTxAgcCompensate
= &pAd
->TxAgcCompensateG
;
3279 bAutoTxAgc
= pAd
->bAutoTxAgcA
;
3280 TssiRef
= pAd
->TssiRefA
;
3281 pTssiMinusBoundary
= &pAd
->TssiMinusBoundaryA
[0];
3282 pTssiPlusBoundary
= &pAd
->TssiPlusBoundaryA
[0];
3283 TxAgcStep
= pAd
->TxAgcStepA
;
3284 pTxAgcCompensate
= &pAd
->TxAgcCompensateA
;
3289 /* BbpR49 is unsigned char. */
3290 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R49
, &BbpR49
);
3292 /* (p) TssiPlusBoundaryG[0] = 0 = (m) TssiMinusBoundaryG[0] */
3293 /* compensate: +4 +3 +2 +1 0 -1 -2 -3 -4 * steps */
3294 /* step value is defined in pAd->TxAgcStepG for tx power value */
3296 /* [4]+1+[4] p4 p3 p2 p1 o1 m1 m2 m3 m4 */
3297 /* ex: 0x00 0x15 0x25 0x45 0x88 0xA0 0xB5 0xD0 0xF0
3298 above value are examined in mass factory production */
3299 /* [4] [3] [2] [1] [0] [1] [2] [3] [4] */
3301 /* plus is 0x10 ~ 0x40, minus is 0x60 ~ 0x90 */
3302 /* if value is between p1 ~ o1 or o1 ~ s1, no need to adjust tx power */
3303 /* if value is 0x65, tx power will be -= TxAgcStep*(2-1) */
3305 if (BbpR49
> pTssiMinusBoundary
[1])
3307 // Reading is larger than the reference value.
3308 // Check for how large we need to decrease the Tx power.
3309 for (idx
= 1; idx
< 5; idx
++)
3312 if (BbpR49
<= pTssiMinusBoundary
[idx
])
3316 // The index is the step we should decrease, idx = 0 means there is nothing to compensate.
3317 // if (R3 > (ULONG) (TxAgcStep * (idx-1)))
3318 *pTxAgcCompensate
= -(TxAgcStep
* (idx
-1));
3320 // *pTxAgcCompensate = -((UCHAR)R3);
3322 DeltaPwr
+= (*pTxAgcCompensate
);
3323 ATEDBGPRINT(RT_DEBUG_TRACE
, ("-- Tx Power, BBP R1=%x, TssiRef=%x, TxAgcStep=%x, step = -%d\n",
3324 BbpR49
, TssiRef
, TxAgcStep
, idx
-1));
3326 else if (BbpR49
< pTssiPlusBoundary
[1])
3328 // Reading is smaller than the reference value.
3329 // Check for how large we need to increase the Tx power.
3330 for (idx
= 1; idx
< 5; idx
++)
3333 if (BbpR49
>= pTssiPlusBoundary
[idx
])
3337 // The index is the step we should increase, idx = 0 means there is nothing to compensate.
3338 *pTxAgcCompensate
= TxAgcStep
* (idx
-1);
3339 DeltaPwr
+= (*pTxAgcCompensate
);
3340 ATEDBGPRINT(RT_DEBUG_TRACE
, ("++ Tx Power, BBP R1=%x, TssiRef=%x, TxAgcStep=%x, step = +%d\n",
3341 BbpR49
, TssiRef
, TxAgcStep
, idx
-1));
3345 *pTxAgcCompensate
= 0;
3346 ATEDBGPRINT(RT_DEBUG_TRACE
, (" Tx Power, BBP R1=%x, TssiRef=%x, TxAgcStep=%x, step = +%d\n",
3347 BbpR49
, TssiRef
, TxAgcStep
, 0));
3353 if (pAd
->ate
.Channel
<= 14)
3355 bAutoTxAgc
= pAd
->bAutoTxAgcG
;
3356 pTxAgcCompensate
= &pAd
->TxAgcCompensateG
;
3360 bAutoTxAgc
= pAd
->bAutoTxAgcA
;
3361 pTxAgcCompensate
= &pAd
->TxAgcCompensateA
;
3365 DeltaPwr
+= (*pTxAgcCompensate
);
3368 /* Calculate delta power based on the percentage specified from UI. */
3369 // E2PROM setting is calibrated for maximum TX power (i.e. 100%)
3370 // We lower TX power here according to the percentage specified from UI.
3371 if (pAd
->CommonCfg
.TxPowerPercentage
== 0xffffffff) // AUTO TX POWER control
3373 else if (pAd
->CommonCfg
.TxPowerPercentage
> 90) // 91 ~ 100% & AUTO, treat as 100% in terms of mW
3375 else if (pAd
->CommonCfg
.TxPowerPercentage
> 60) // 61 ~ 90%, treat as 75% in terms of mW
3379 else if (pAd
->CommonCfg
.TxPowerPercentage
> 30) // 31 ~ 60%, treat as 50% in terms of mW
3383 else if (pAd
->CommonCfg
.TxPowerPercentage
> 15) // 16 ~ 30%, treat as 25% in terms of mW
3387 else if (pAd
->CommonCfg
.TxPowerPercentage
> 9) // 10 ~ 15%, treat as 12.5% in terms of mW
3391 else // 0 ~ 9 %, treat as MIN(~3%) in terms of mW
3396 /* Reset different new tx power for different TX rate. */
3399 if (TxPwr
[i
] != 0xffffffff)
3403 Value
= (CHAR
)((TxPwr
[i
] >> j
*4) & 0x0F); /* 0 ~ 15 */
3405 if ((Value
+ DeltaPwr
) < 0)
3407 Value
= 0; /* min */
3409 else if ((Value
+ DeltaPwr
) > 0xF)
3411 Value
= 0xF; /* max */
3415 Value
+= DeltaPwr
; /* temperature compensation */
3418 /* fill new value to CSR offset */
3419 TxPwr
[i
] = (TxPwr
[i
] & ~(0x0000000F << j
*4)) | (Value
<< j
*4);
3422 /* write tx power value to CSR */
3423 /* TX_PWR_CFG_0 (8 tx rate) for TX power for OFDM 12M/18M
3424 TX power for OFDM 6M/9M
3425 TX power for CCK5.5M/11M
3426 TX power for CCK1M/2M */
3427 /* TX_PWR_CFG_1 ~ TX_PWR_CFG_4 */
3428 RTMP_IO_WRITE32(pAd
, TX_PWR_CFG_0
+ i
*4, TxPwr
[i
]);
3438 ========================================================================
3439 Routine Description:
3440 Write TxWI for ATE mode.
3444 ========================================================================
3447 static VOID
ATEWriteTxWI(
3448 IN PRTMP_ADAPTER pAd
,
3449 IN PTXWI_STRUC pOutTxWI
,
3452 IN BOOLEAN InsTimestamp
,
3455 IN BOOLEAN NSeq
, // HW new a sequence.
3464 IN HTTRANSMIT_SETTING
*pTransmit
)
3470 // Always use Long preamble before verifiation short preamble functionality works well.
3471 // Todo: remove the following line if short preamble functionality works
3473 OPSTATUS_CLEAR_FLAG(pAd
, fOP_STATUS_SHORT_PREAMBLE_INUSED
);
3474 NdisZeroMemory(&TxWI
, TXWI_SIZE
);
3479 pTxWI
->CFACK
= CFACK
;
3480 pTxWI
->TS
= InsTimestamp
;
3481 pTxWI
->AMPDU
= AMPDU
;
3483 pTxWI
->txop
= Txopmode
;
3487 // John tune the performace with Intel Client in 20 MHz performance
3491 pTxWI
->BAWinSize
= BASize
;
3492 pTxWI
->WirelessCliID
= WCID
;
3493 pTxWI
->MPDUtotalByteCount
= Length
;
3494 pTxWI
->PacketId
= PID
;
3496 // If CCK or OFDM, BW must be 20
3497 pTxWI
->BW
= (pTransmit
->field
.MODE
<= MODE_OFDM
) ? (BW_20
) : (pTransmit
->field
.BW
);
3498 pTxWI
->ShortGI
= pTransmit
->field
.ShortGI
;
3499 pTxWI
->STBC
= pTransmit
->field
.STBC
;
3501 pTxWI
->MCS
= pTransmit
->field
.MCS
;
3502 pTxWI
->PHYMODE
= pTransmit
->field
.MODE
;
3503 pTxWI
->CFACK
= CfAck
;
3505 pTxWI
->MpduDensity
= 0;
3507 pTxWI
->PacketId
= pTxWI
->MCS
;
3508 NdisMoveMemory(pOutTxWI
, &TxWI
, sizeof(TXWI_STRUC
));
3512 #endif // RTMP_MAC_PCI //
3518 ========================================================================
3520 Routine Description:
3521 Disable protection for ATE.
3522 ========================================================================
3524 VOID
ATEDisableAsicProtect(
3525 IN PRTMP_ADAPTER pAd
)
3527 PROT_CFG_STRUC ProtCfg
, ProtCfg4
;
3533 // Config ASIC RTS threshold register
3534 RTMP_IO_READ32(pAd
, TX_RTS_CFG
, &MacReg
);
3535 MacReg
&= 0xFF0000FF;
3536 MacReg
|= (pAd
->CommonCfg
.RtsThreshold
<< 8);
3537 RTMP_IO_WRITE32(pAd
, TX_RTS_CFG
, MacReg
);
3539 // Initial common protection settings
3540 RTMPZeroMemory(Protect
, sizeof(Protect
));
3543 ProtCfg
.field
.TxopAllowGF40
= 1;
3544 ProtCfg
.field
.TxopAllowGF20
= 1;
3545 ProtCfg
.field
.TxopAllowMM40
= 1;
3546 ProtCfg
.field
.TxopAllowMM20
= 1;
3547 ProtCfg
.field
.TxopAllowOfdm
= 1;
3548 ProtCfg
.field
.TxopAllowCck
= 1;
3549 ProtCfg
.field
.RTSThEn
= 1;
3550 ProtCfg
.field
.ProtectNav
= ASIC_SHORTNAV
;
3552 // Handle legacy(B/G) protection
3553 ProtCfg
.field
.ProtectRate
= pAd
->CommonCfg
.RtsRate
;
3554 ProtCfg
.field
.ProtectCtrl
= 0;
3555 Protect
[0] = ProtCfg
.word
;
3556 Protect
[1] = ProtCfg
.word
;
3559 // 1.All STAs in the BSS are 20/40 MHz HT
3560 // 2. in ai 20/40MHz BSS
3561 // 3. all STAs are 20MHz in a 20MHz BSS
3562 // Pure HT. no protection.
3566 // PROT_TXOP(25:20) -- 010111
3567 // PROT_NAV(19:18) -- 01 (Short NAV protection)
3568 // PROT_CTRL(17:16) -- 00 (None)
3569 // PROT_RATE(15:0) -- 0x4004 (OFDM 24M)
3570 Protect
[2] = 0x01744004;
3574 // PROT_TXOP(25:20) -- 111111
3575 // PROT_NAV(19:18) -- 01 (Short NAV protection)
3576 // PROT_CTRL(17:16) -- 00 (None)
3577 // PROT_RATE(15:0) -- 0x4084 (duplicate OFDM 24M)
3578 Protect
[3] = 0x03f44084;
3582 // PROT_TXOP(25:20) -- 010111
3583 // PROT_NAV(19:18) -- 01 (Short NAV protection)
3584 // PROT_CTRL(17:16) -- 00 (None)
3585 // PROT_RATE(15:0) -- 0x4004 (OFDM 24M)
3586 Protect
[4] = 0x01744004;
3590 // PROT_TXOP(25:20) -- 111111
3591 // PROT_NAV(19:18) -- 01 (Short NAV protection)
3592 // PROT_CTRL(17:16) -- 00 (None)
3593 // PROT_RATE(15:0) -- 0x4084 (duplicate OFDM 24M)
3594 Protect
[5] = 0x03f44084;
3596 pAd
->CommonCfg
.IOTestParm
.bRTSLongProtOn
= FALSE
;
3598 offset
= CCK_PROT_CFG
;
3599 for (i
= 0;i
< 6;i
++)
3600 RTMP_IO_WRITE32(pAd
, offset
+ i
*4, Protect
[i
]);
3607 /* There are two ways to convert Rssi */
3608 /* the way used with GET_LNA_GAIN() */
3609 CHAR
ATEConvertToRssi(
3610 IN PRTMP_ADAPTER pAd
,
3612 IN UCHAR RssiNumber
)
3614 UCHAR RssiOffset
, LNAGain
;
3616 // Rssi equals to zero should be an invalid value
3620 LNAGain
= GET_LNA_GAIN(pAd
);
3621 if (pAd
->LatchRfRegs
.Channel
> 14)
3623 if (RssiNumber
== 0)
3624 RssiOffset
= pAd
->ARssiOffset0
;
3625 else if (RssiNumber
== 1)
3626 RssiOffset
= pAd
->ARssiOffset1
;
3628 RssiOffset
= pAd
->ARssiOffset2
;
3632 if (RssiNumber
== 0)
3633 RssiOffset
= pAd
->BGRssiOffset0
;
3634 else if (RssiNumber
== 1)
3635 RssiOffset
= pAd
->BGRssiOffset1
;
3637 RssiOffset
= pAd
->BGRssiOffset2
;
3640 return (-12 - RssiOffset
- LNAGain
- Rssi
);
3645 ========================================================================
3647 Routine Description:
3648 Set Japan filter coefficients if needed.
3650 This routine should only be called when
3651 entering TXFRAME mode or TXCONT mode.
3653 ========================================================================
3655 static VOID
SetJapanFilter(
3656 IN PRTMP_ADAPTER pAd
)
3661 // If Channel=14 and Bandwidth=20M and Mode=CCK, set BBP R4 bit5=1
3662 // (Japan Tx filter coefficients)when (TXFRAME or TXCONT).
3664 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R4
, &BbpData
);
3666 if ((pAd
->ate
.TxWI
.PHYMODE
== MODE_CCK
) && (pAd
->ate
.Channel
== 14) && (pAd
->ate
.TxWI
.BW
== BW_20
))
3668 BbpData
|= 0x20; // turn on
3669 ATEDBGPRINT(RT_DEBUG_TRACE
, ("SetJapanFilter!!!\n"));
3673 BbpData
&= 0xdf; // turn off
3674 ATEDBGPRINT(RT_DEBUG_TRACE
, ("ClearJapanFilter!!!\n"));
3677 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R4
, BbpData
);
3682 IN PRTMP_ADAPTER pAd
,
3683 IN PRXWI_STRUC pRxWI
)
3685 /* There are two ways to collect RSSI. */
3686 // pAd->LastRxRate = (USHORT)((pRxWI->MCS) + (pRxWI->BW <<7) + (pRxWI->ShortGI <<8)+ (pRxWI->PHYMODE <<14)) ;
3687 if (pRxWI
->RSSI0
!= 0)
3689 pAd
->ate
.LastRssi0
= ATEConvertToRssi(pAd
, (CHAR
) pRxWI
->RSSI0
, RSSI_0
);
3690 pAd
->ate
.AvgRssi0X8
= (pAd
->ate
.AvgRssi0X8
- pAd
->ate
.AvgRssi0
) + pAd
->ate
.LastRssi0
;
3691 pAd
->ate
.AvgRssi0
= pAd
->ate
.AvgRssi0X8
>> 3;
3693 if (pRxWI
->RSSI1
!= 0)
3695 pAd
->ate
.LastRssi1
= ATEConvertToRssi(pAd
, (CHAR
) pRxWI
->RSSI1
, RSSI_1
);
3696 pAd
->ate
.AvgRssi1X8
= (pAd
->ate
.AvgRssi1X8
- pAd
->ate
.AvgRssi1
) + pAd
->ate
.LastRssi1
;
3697 pAd
->ate
.AvgRssi1
= pAd
->ate
.AvgRssi1X8
>> 3;
3699 if (pRxWI
->RSSI2
!= 0)
3701 pAd
->ate
.LastRssi2
= ATEConvertToRssi(pAd
, (CHAR
) pRxWI
->RSSI2
, RSSI_2
);
3702 pAd
->ate
.AvgRssi2X8
= (pAd
->ate
.AvgRssi2X8
- pAd
->ate
.AvgRssi2
) + pAd
->ate
.LastRssi2
;
3703 pAd
->ate
.AvgRssi2
= pAd
->ate
.AvgRssi2X8
>> 3;
3706 pAd
->ate
.LastSNR0
= (CHAR
)(pRxWI
->SNR0
);// CHAR ==> UCHAR ?
3707 pAd
->ate
.LastSNR1
= (CHAR
)(pRxWI
->SNR1
);// CHAR ==> UCHAR ?
3709 pAd
->ate
.NumOfAvgRssiSample
++;
3713 #ifdef CONFIG_STA_SUPPORT
3714 VOID
RTMPStationStop(
3715 IN PRTMP_ADAPTER pAd
)
3717 // BOOLEAN Cancelled;
3719 ATEDBGPRINT(RT_DEBUG_TRACE
, ("==> RTMPStationStop\n"));
3721 // For rx statistics, we need to keep this timer running.
3722 // RTMPCancelTimer(&pAd->Mlme.PeriodicTimer, &Cancelled);
3724 ATEDBGPRINT(RT_DEBUG_TRACE
, ("<== RTMPStationStop\n"));
3728 VOID
RTMPStationStart(
3729 IN PRTMP_ADAPTER pAd
)
3731 ATEDBGPRINT(RT_DEBUG_TRACE
, ("==> RTMPStationStart\n"));
3734 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_IDLE
;
3736 /* We did not cancel this timer when entering ATE mode. */
3737 // RTMPSetTimer(&pAd->Mlme.PeriodicTimer, MLME_TASK_EXEC_INTV);
3738 #endif // RTMP_MAC_PCI //
3740 ATEDBGPRINT(RT_DEBUG_TRACE
, ("<== RTMPStationStart\n"));
3742 #endif // CONFIG_STA_SUPPORT //
3746 ==========================================================================
3750 This routine should only be used in ATE mode.
3751 ==========================================================================
3754 static INT
ATESetUpFrame(
3755 IN PRTMP_ADAPTER pAd
,
3760 #ifdef RT_BIG_ENDIAN
3761 PTXD_STRUC pDestTxD
;
3764 PNDIS_PACKET pPacket
;
3767 NDIS_PHYSICAL_ADDRESS AllocPa
;
3768 HTTRANSMIT_SETTING TxHTPhyMode
;
3770 PRTMP_TX_RING pTxRing
= &pAd
->TxRing
[QID_AC_BE
];
3771 PTXWI_STRUC pTxWI
= (PTXWI_STRUC
) pTxRing
->Cell
[TxIdx
].DmaBuf
.AllocVa
;
3772 PUCHAR pDMAHeaderBufVA
= (PUCHAR
) pTxRing
->Cell
[TxIdx
].DmaBuf
.AllocVa
;
3774 #ifdef RALINK_28xx_QA
3775 PHEADER_802_11 pHeader80211
;
3776 #endif // RALINK_28xx_QA //
3778 if (pAd
->ate
.bQATxStart
== TRUE
)
3780 // always use QID_AC_BE and FIFO_EDCA
3783 TxHTPhyMode
.field
.BW
= pAd
->ate
.TxWI
.BW
;
3784 TxHTPhyMode
.field
.ShortGI
= pAd
->ate
.TxWI
.ShortGI
;
3785 TxHTPhyMode
.field
.STBC
= 0;
3786 TxHTPhyMode
.field
.MCS
= pAd
->ate
.TxWI
.MCS
;
3787 TxHTPhyMode
.field
.MODE
= pAd
->ate
.TxWI
.PHYMODE
;
3789 ATEWriteTxWI(pAd
, pTxWI
, pAd
->ate
.TxWI
.FRAG
, pAd
->ate
.TxWI
.CFACK
,
3790 pAd
->ate
.TxWI
.TS
, pAd
->ate
.TxWI
.AMPDU
, pAd
->ate
.TxWI
.ACK
, pAd
->ate
.TxWI
.NSEQ
,
3791 pAd
->ate
.TxWI
.BAWinSize
, 0, pAd
->ate
.TxWI
.MPDUtotalByteCount
, pAd
->ate
.TxWI
.PacketId
, 0, 0,
3792 pAd
->ate
.TxWI
.txop
/*IFS_HTTXOP*/, pAd
->ate
.TxWI
.CFACK
/*FALSE*/, &TxHTPhyMode
);
3796 TxHTPhyMode
.field
.BW
= pAd
->ate
.TxWI
.BW
;
3797 TxHTPhyMode
.field
.ShortGI
= pAd
->ate
.TxWI
.ShortGI
;
3798 TxHTPhyMode
.field
.STBC
= 0;
3799 TxHTPhyMode
.field
.MCS
= pAd
->ate
.TxWI
.MCS
;
3800 TxHTPhyMode
.field
.MODE
= pAd
->ate
.TxWI
.PHYMODE
;
3801 ATEWriteTxWI(pAd
, pTxWI
, FALSE
, FALSE
, FALSE
, FALSE
, FALSE
, FALSE
,
3802 4, 0, pAd
->ate
.TxLength
, 0, 0, 0, IFS_HTTXOP
, FALSE
, &TxHTPhyMode
);
3805 // fill 802.11 header
3806 #ifdef RALINK_28xx_QA
3807 if (pAd
->ate
.bQATxStart
== TRUE
)
3809 NdisMoveMemory(pDMAHeaderBufVA
+TXWI_SIZE
, pAd
->ate
.Header
, pAd
->ate
.HLen
);
3812 #endif // RALINK_28xx_QA //
3814 NdisMoveMemory(pDMAHeaderBufVA
+TXWI_SIZE
, TemplateFrame
, LENGTH_802_11
);
3815 NdisMoveMemory(pDMAHeaderBufVA
+TXWI_SIZE
+4, pAd
->ate
.Addr1
, ETH_LENGTH_OF_ADDRESS
);
3816 NdisMoveMemory(pDMAHeaderBufVA
+TXWI_SIZE
+10, pAd
->ate
.Addr2
, ETH_LENGTH_OF_ADDRESS
);
3817 NdisMoveMemory(pDMAHeaderBufVA
+TXWI_SIZE
+16, pAd
->ate
.Addr3
, ETH_LENGTH_OF_ADDRESS
);
3820 #ifdef RT_BIG_ENDIAN
3821 RTMPFrameEndianChange(pAd
, (((PUCHAR
)pDMAHeaderBufVA
)+TXWI_SIZE
), DIR_READ
, FALSE
);
3822 #endif // RT_BIG_ENDIAN //
3824 /* alloc buffer for payload */
3825 #ifdef RALINK_28xx_QA
3826 if (pAd
->ate
.bQATxStart
== TRUE
)
3828 pPacket
= RTMP_AllocateRxPacketBuffer(pAd
, pAd
->ate
.DLen
+ 0x100, FALSE
, &AllocVa
, &AllocPa
);
3831 #endif // RALINK_28xx_QA //
3833 pPacket
= RTMP_AllocateRxPacketBuffer(pAd
, pAd
->ate
.TxLength
, FALSE
, &AllocVa
, &AllocPa
);
3836 if (pPacket
== NULL
)
3838 pAd
->ate
.TxCount
= 0;
3839 ATEDBGPRINT(RT_DEBUG_TRACE
, ("%s fail to alloc packet space.\n", __FUNCTION__
));
3842 pTxRing
->Cell
[TxIdx
].pNextNdisPacket
= pPacket
;
3844 pDest
= (PUCHAR
) AllocVa
;
3846 #ifdef RALINK_28xx_QA
3847 if (pAd
->ate
.bQATxStart
== TRUE
)
3849 RTPKT_TO_OSPKT(pPacket
)->len
= pAd
->ate
.DLen
;
3852 #endif // RALINK_28xx_QA //
3854 RTPKT_TO_OSPKT(pPacket
)->len
= pAd
->ate
.TxLength
- LENGTH_802_11
;
3857 // prepare frame payload
3858 #ifdef RALINK_28xx_QA
3859 if (pAd
->ate
.bQATxStart
== TRUE
)
3862 if ((pAd
->ate
.PLen
!= 0))
3866 for (j
= 0; j
< pAd
->ate
.DLen
; j
+=pAd
->ate
.PLen
)
3868 memcpy(RTPKT_TO_OSPKT(pPacket
)->data
+ j
, pAd
->ate
.Pattern
, pAd
->ate
.PLen
);
3873 #endif // RALINK_28xx_QA //
3875 for (j
= 0; j
< RTPKT_TO_OSPKT(pPacket
)->len
; j
++)
3881 /* build Tx Descriptor */
3882 #ifndef RT_BIG_ENDIAN
3883 pTxD
= (PTXD_STRUC
) pTxRing
->Cell
[TxIdx
].AllocVa
;
3885 pDestTxD
= (PTXD_STRUC
)pTxRing
->Cell
[TxIdx
].AllocVa
;
3888 #endif // !RT_BIG_ENDIAN //
3890 #ifdef RALINK_28xx_QA
3891 if (pAd
->ate
.bQATxStart
== TRUE
)
3894 NdisZeroMemory(pTxD
, TXD_SIZE
);
3895 RTMPWriteTxDescriptor(pAd
, pTxD
, FALSE
, FIFO_EDCA
);
3897 pTxD
->SDPtr0
= RTMP_GetPhysicalAddressLow(pTxRing
->Cell
[TxIdx
].DmaBuf
.AllocPa
);
3898 pTxD
->SDLen0
= TXWI_SIZE
+ pAd
->ate
.HLen
;
3900 pTxD
->SDPtr1
= AllocPa
;
3901 pTxD
->SDLen1
= RTPKT_TO_OSPKT(pPacket
)->len
;
3904 pDest
= (PUCHAR
)pTxWI
;
3906 pHeader80211
= (PHEADER_802_11
)pDest
;
3908 // modify sequence number...
3909 if (pAd
->ate
.TxDoneCount
== 0)
3911 pAd
->ate
.seq
= pHeader80211
->Sequence
;
3914 pHeader80211
->Sequence
= ++pAd
->ate
.seq
;
3917 #endif // RALINK_28xx_QA //
3919 NdisZeroMemory(pTxD
, TXD_SIZE
);
3920 RTMPWriteTxDescriptor(pAd
, pTxD
, FALSE
, FIFO_EDCA
);
3922 pTxD
->SDPtr0
= RTMP_GetPhysicalAddressLow (pTxRing
->Cell
[TxIdx
].DmaBuf
.AllocPa
);
3923 pTxD
->SDLen0
= TXWI_SIZE
+ LENGTH_802_11
;
3925 pTxD
->SDPtr1
= AllocPa
;
3926 pTxD
->SDLen1
= RTPKT_TO_OSPKT(pPacket
)->len
;
3930 #ifdef RT_BIG_ENDIAN
3931 RTMPWIEndianChange((PUCHAR
)pTxWI
, TYPE_TXWI
);
3932 RTMPFrameEndianChange(pAd
, (((PUCHAR
)pDMAHeaderBufVA
)+TXWI_SIZE
), DIR_WRITE
, FALSE
);
3933 RTMPDescriptorEndianChange((PUCHAR
)pTxD
, TYPE_TXD
);
3934 WriteBackToDescriptor((PUCHAR
)pDestTxD
, (PUCHAR
)pTxD
, FALSE
, TYPE_TXD
);
3935 #endif // RT_BIG_ENDIAN //
3939 /*=======================End of RTMP_MAC_PCI =======================*/
3940 #endif // RTMP_MAC_PCI //
3945 VOID
rt_ee_read_all(PRTMP_ADAPTER pAd
, USHORT
*Data
)
3951 for (i
= 0 ; i
< EEPROM_SIZE
/2 ; )
3953 /* "value" is especially for some compilers... */
3954 RT28xx_EEPROM_READ16(pAd
, i
*2, value
);
3961 VOID
rt_ee_write_all(PRTMP_ADAPTER pAd
, USHORT
*Data
)
3967 for (i
= 0 ; i
< EEPROM_SIZE
/2 ; )
3969 /* "value" is especially for some compilers... */
3971 RT28xx_EEPROM_WRITE16(pAd
, i
*2, value
);
3977 #ifdef RALINK_28xx_QA
3978 VOID
ATE_QA_Statistics(
3979 IN PRTMP_ADAPTER pAd
,
3980 IN PRXWI_STRUC pRxWI
,
3981 IN PRT28XX_RXD_STRUC pRxD
,
3982 IN PHEADER_802_11 pHeader
)
3984 // update counter first
3985 if (pHeader
!= NULL
)
3987 if (pHeader
->FC
.Type
== BTYPE_DATA
)
3992 pAd
->ate
.OtherData
++;
3994 else if (pHeader
->FC
.Type
== BTYPE_MGMT
)
3996 if (pHeader
->FC
.SubType
== SUBTYPE_BEACON
)
3999 pAd
->ate
.OtherCount
++;
4001 else if (pHeader
->FC
.Type
== BTYPE_CNTL
)
4003 pAd
->ate
.OtherCount
++;
4006 pAd
->ate
.RSSI0
= pRxWI
->RSSI0
;
4007 pAd
->ate
.RSSI1
= pRxWI
->RSSI1
;
4008 pAd
->ate
.RSSI2
= pRxWI
->RSSI2
;
4009 pAd
->ate
.SNR0
= pRxWI
->SNR0
;
4010 pAd
->ate
.SNR1
= pRxWI
->SNR1
;
4014 /* command id with Cmd Type == 0x0008(for 28xx)/0x0005(for iNIC) */
4015 #define RACFG_CMD_RF_WRITE_ALL 0x0000
4016 #define RACFG_CMD_E2PROM_READ16 0x0001
4017 #define RACFG_CMD_E2PROM_WRITE16 0x0002
4018 #define RACFG_CMD_E2PROM_READ_ALL 0x0003
4019 #define RACFG_CMD_E2PROM_WRITE_ALL 0x0004
4020 #define RACFG_CMD_IO_READ 0x0005
4021 #define RACFG_CMD_IO_WRITE 0x0006
4022 #define RACFG_CMD_IO_READ_BULK 0x0007
4023 #define RACFG_CMD_BBP_READ8 0x0008
4024 #define RACFG_CMD_BBP_WRITE8 0x0009
4025 #define RACFG_CMD_BBP_READ_ALL 0x000a
4026 #define RACFG_CMD_GET_COUNTER 0x000b
4027 #define RACFG_CMD_CLEAR_COUNTER 0x000c
4029 #define RACFG_CMD_RSV1 0x000d
4030 #define RACFG_CMD_RSV2 0x000e
4031 #define RACFG_CMD_RSV3 0x000f
4033 #define RACFG_CMD_TX_START 0x0010
4034 #define RACFG_CMD_GET_TX_STATUS 0x0011
4035 #define RACFG_CMD_TX_STOP 0x0012
4036 #define RACFG_CMD_RX_START 0x0013
4037 #define RACFG_CMD_RX_STOP 0x0014
4038 #define RACFG_CMD_GET_NOISE_LEVEL 0x0015
4040 #define RACFG_CMD_ATE_START 0x0080
4041 #define RACFG_CMD_ATE_STOP 0x0081
4043 #define RACFG_CMD_ATE_START_TX_CARRIER 0x0100
4044 #define RACFG_CMD_ATE_START_TX_CONT 0x0101
4045 #define RACFG_CMD_ATE_START_TX_FRAME 0x0102
4046 #define RACFG_CMD_ATE_SET_BW 0x0103
4047 #define RACFG_CMD_ATE_SET_TX_POWER0 0x0104
4048 #define RACFG_CMD_ATE_SET_TX_POWER1 0x0105
4049 #define RACFG_CMD_ATE_SET_FREQ_OFFSET 0x0106
4050 #define RACFG_CMD_ATE_GET_STATISTICS 0x0107
4051 #define RACFG_CMD_ATE_RESET_COUNTER 0x0108
4052 #define RACFG_CMD_ATE_SEL_TX_ANTENNA 0x0109
4053 #define RACFG_CMD_ATE_SEL_RX_ANTENNA 0x010a
4054 #define RACFG_CMD_ATE_SET_PREAMBLE 0x010b
4055 #define RACFG_CMD_ATE_SET_CHANNEL 0x010c
4056 #define RACFG_CMD_ATE_SET_ADDR1 0x010d
4057 #define RACFG_CMD_ATE_SET_ADDR2 0x010e
4058 #define RACFG_CMD_ATE_SET_ADDR3 0x010f
4059 #define RACFG_CMD_ATE_SET_RATE 0x0110
4060 #define RACFG_CMD_ATE_SET_TX_FRAME_LEN 0x0111
4061 #define RACFG_CMD_ATE_SET_TX_FRAME_COUNT 0x0112
4062 #define RACFG_CMD_ATE_START_RX_FRAME 0x0113
4063 #define RACFG_CMD_ATE_E2PROM_READ_BULK 0x0114
4064 #define RACFG_CMD_ATE_E2PROM_WRITE_BULK 0x0115
4065 #define RACFG_CMD_ATE_IO_WRITE_BULK 0x0116
4066 #define RACFG_CMD_ATE_BBP_READ_BULK 0x0117
4067 #define RACFG_CMD_ATE_BBP_WRITE_BULK 0x0118
4068 #define RACFG_CMD_ATE_RF_READ_BULK 0x0119
4069 #define RACFG_CMD_ATE_RF_WRITE_BULK 0x011a
4072 static VOID
memcpy_exl(PRTMP_ADAPTER pAd
, UCHAR
*dst
, UCHAR
*src
, ULONG len
);
4073 static VOID
memcpy_exs(PRTMP_ADAPTER pAd
, UCHAR
*dst
, UCHAR
*src
, ULONG len
);
4074 static VOID
RTMP_IO_READ_BULK(PRTMP_ADAPTER pAd
, UCHAR
*dst
, UCHAR
*src
, UINT32 len
);
4079 IN PRTMP_ADAPTER pAdapter
,
4080 IN
struct iwreq
*wrq
)
4083 INT Status
= NDIS_STATUS_SUCCESS
;
4084 struct ate_racfghdr
*pRaCfg
;
4087 if ((pRaCfg
= kmalloc(sizeof(struct ate_racfghdr
), GFP_KERNEL
)) == NULL
)
4093 NdisZeroMemory(pRaCfg
, sizeof(struct ate_racfghdr
));
4095 if (copy_from_user((PUCHAR
)pRaCfg
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
))
4102 Command_Id
= ntohs(pRaCfg
->command_id
);
4104 ATEDBGPRINT(RT_DEBUG_TRACE
,("\n%s: Command_Id = 0x%04x !\n", __FUNCTION__
, Command_Id
));
4108 /* We will get this command when QA starts. */
4109 case RACFG_CMD_ATE_START
:
4110 Status
=DO_RACFG_CMD_ATE_START(pAdapter
,wrq
,pRaCfg
);
4113 /* We will get this command either QA is closed or ated is killed by user. */
4114 case RACFG_CMD_ATE_STOP
:
4115 Status
=DO_RACFG_CMD_ATE_STOP(pAdapter
,wrq
,pRaCfg
);
4118 case RACFG_CMD_RF_WRITE_ALL
:
4119 Status
=DO_RACFG_CMD_RF_WRITE_ALL(pAdapter
,wrq
,pRaCfg
);
4122 case RACFG_CMD_E2PROM_READ16
:
4123 Status
=DO_RACFG_CMD_E2PROM_READ16(pAdapter
,wrq
,pRaCfg
);
4126 case RACFG_CMD_E2PROM_WRITE16
:
4127 Status
=DO_RACFG_CMD_E2PROM_WRITE16(pAdapter
,wrq
,pRaCfg
);
4130 case RACFG_CMD_E2PROM_READ_ALL
:
4131 Status
=DO_RACFG_CMD_E2PROM_READ_ALL(pAdapter
,wrq
,pRaCfg
);
4134 case RACFG_CMD_E2PROM_WRITE_ALL
:
4135 Status
=DO_RACFG_CMD_E2PROM_WRITE_ALL(pAdapter
,wrq
,pRaCfg
);
4138 case RACFG_CMD_IO_READ
:
4139 Status
=DO_RACFG_CMD_IO_READ(pAdapter
,wrq
,pRaCfg
);
4142 case RACFG_CMD_IO_WRITE
:
4143 Status
=DO_RACFG_CMD_IO_WRITE(pAdapter
,wrq
,pRaCfg
);
4146 case RACFG_CMD_IO_READ_BULK
:
4147 Status
=DO_RACFG_CMD_IO_READ_BULK(pAdapter
,wrq
,pRaCfg
);
4150 case RACFG_CMD_BBP_READ8
:
4151 Status
=DO_RACFG_CMD_BBP_READ8(pAdapter
,wrq
,pRaCfg
);
4153 case RACFG_CMD_BBP_WRITE8
:
4154 Status
=DO_RACFG_CMD_BBP_WRITE8(pAdapter
,wrq
,pRaCfg
);
4157 case RACFG_CMD_BBP_READ_ALL
:
4158 Status
=DO_RACFG_CMD_BBP_READ_ALL(pAdapter
,wrq
,pRaCfg
);
4161 case RACFG_CMD_ATE_E2PROM_READ_BULK
:
4162 Status
=DO_RACFG_CMD_ATE_E2PROM_READ_BULK(pAdapter
,wrq
,pRaCfg
);
4165 case RACFG_CMD_ATE_E2PROM_WRITE_BULK
:
4166 Status
=DO_RACFG_CMD_ATE_E2PROM_WRITE_BULK(pAdapter
,wrq
,pRaCfg
);
4169 case RACFG_CMD_ATE_IO_WRITE_BULK
:
4170 Status
=DO_RACFG_CMD_ATE_IO_WRITE_BULK(pAdapter
,wrq
,pRaCfg
);
4173 case RACFG_CMD_ATE_BBP_READ_BULK
:
4174 Status
=DO_RACFG_CMD_ATE_BBP_READ_BULK(pAdapter
,wrq
,pRaCfg
);
4177 case RACFG_CMD_ATE_BBP_WRITE_BULK
:
4178 Status
=DO_RACFG_CMD_ATE_BBP_WRITE_BULK(pAdapter
,wrq
,pRaCfg
);
4182 case RACFG_CMD_GET_NOISE_LEVEL
:
4183 Status
=DO_RACFG_CMD_GET_NOISE_LEVEL(pAdapter
,wrq
,pRaCfg
);
4186 case RACFG_CMD_GET_COUNTER
:
4187 Status
=DO_RACFG_CMD_GET_COUNTER(pAdapter
,wrq
,pRaCfg
);
4190 case RACFG_CMD_CLEAR_COUNTER
:
4191 Status
=DO_RACFG_CMD_CLEAR_COUNTER(pAdapter
,wrq
,pRaCfg
);
4194 case RACFG_CMD_TX_START
:
4195 Status
=DO_RACFG_CMD_TX_START(pAdapter
,wrq
,pRaCfg
);
4198 case RACFG_CMD_GET_TX_STATUS
:
4199 Status
=DO_RACFG_CMD_GET_TX_STATUS(pAdapter
,wrq
,pRaCfg
);
4202 case RACFG_CMD_TX_STOP
:
4203 Status
=DO_RACFG_CMD_TX_STOP(pAdapter
,wrq
,pRaCfg
);
4206 case RACFG_CMD_RX_START
:
4207 Status
=DO_RACFG_CMD_RX_START(pAdapter
,wrq
,pRaCfg
);
4210 case RACFG_CMD_RX_STOP
:
4211 Status
=DO_RACFG_CMD_RX_STOP(pAdapter
,wrq
,pRaCfg
);
4214 /* The following cases are for new ATE GUI(not QA). */
4215 /*==================================================*/
4216 case RACFG_CMD_ATE_START_TX_CARRIER
:
4217 Status
=DO_RACFG_CMD_ATE_START_TX_CARRIER(pAdapter
,wrq
,pRaCfg
);
4220 case RACFG_CMD_ATE_START_TX_CONT
:
4221 Status
=DO_RACFG_CMD_ATE_START_TX_CONT(pAdapter
,wrq
,pRaCfg
);
4224 case RACFG_CMD_ATE_START_TX_FRAME
:
4225 Status
=DO_RACFG_CMD_ATE_START_TX_FRAME(pAdapter
,wrq
,pRaCfg
);
4228 case RACFG_CMD_ATE_SET_BW
:
4229 Status
=DO_RACFG_CMD_ATE_SET_BW(pAdapter
,wrq
,pRaCfg
);
4232 case RACFG_CMD_ATE_SET_TX_POWER0
:
4233 Status
=DO_RACFG_CMD_ATE_SET_TX_POWER0(pAdapter
,wrq
,pRaCfg
);
4236 case RACFG_CMD_ATE_SET_TX_POWER1
:
4237 Status
=DO_RACFG_CMD_ATE_SET_TX_POWER1(pAdapter
,wrq
,pRaCfg
);
4240 case RACFG_CMD_ATE_SET_FREQ_OFFSET
:
4241 Status
=DO_RACFG_CMD_ATE_SET_TX_POWER1(pAdapter
,wrq
,pRaCfg
);
4244 case RACFG_CMD_ATE_GET_STATISTICS
:
4245 Status
=DO_RACFG_CMD_ATE_GET_STATISTICS(pAdapter
,wrq
,pRaCfg
);
4248 case RACFG_CMD_ATE_RESET_COUNTER
:
4249 Status
=DO_RACFG_CMD_ATE_RESET_COUNTER(pAdapter
,wrq
,pRaCfg
);
4252 case RACFG_CMD_ATE_SEL_TX_ANTENNA
:
4253 Status
=DO_RACFG_CMD_ATE_SEL_TX_ANTENNA(pAdapter
,wrq
,pRaCfg
);
4256 case RACFG_CMD_ATE_SEL_RX_ANTENNA
:
4257 Status
=DO_RACFG_CMD_ATE_SEL_TX_ANTENNA(pAdapter
,wrq
,pRaCfg
);
4260 case RACFG_CMD_ATE_SET_PREAMBLE
:
4261 Status
=DO_RACFG_CMD_ATE_SET_PREAMBLE(pAdapter
,wrq
,pRaCfg
);
4264 case RACFG_CMD_ATE_SET_CHANNEL
:
4265 Status
=DO_RACFG_CMD_ATE_SET_CHANNEL(pAdapter
,wrq
,pRaCfg
);
4268 case RACFG_CMD_ATE_SET_ADDR1
:
4269 Status
=DO_RACFG_CMD_ATE_SET_ADDR1(pAdapter
,wrq
,pRaCfg
);
4272 case RACFG_CMD_ATE_SET_ADDR2
:
4273 Status
=DO_RACFG_CMD_ATE_SET_ADDR2(pAdapter
,wrq
,pRaCfg
);
4276 case RACFG_CMD_ATE_SET_ADDR3
:
4277 Status
=DO_RACFG_CMD_ATE_SET_ADDR3(pAdapter
,wrq
,pRaCfg
);
4280 case RACFG_CMD_ATE_SET_RATE
:
4281 Status
=DO_RACFG_CMD_ATE_SET_RATE(pAdapter
,wrq
,pRaCfg
);
4284 case RACFG_CMD_ATE_SET_TX_FRAME_LEN
:
4285 Status
=DO_RACFG_CMD_ATE_SET_TX_FRAME_LEN(pAdapter
,wrq
,pRaCfg
);
4288 case RACFG_CMD_ATE_SET_TX_FRAME_COUNT
:
4289 Status
=DO_RACFG_CMD_ATE_SET_TX_FRAME_COUNT(pAdapter
,wrq
,pRaCfg
);
4292 case RACFG_CMD_ATE_START_RX_FRAME
:
4293 Status
=DO_RACFG_CMD_ATE_START_RX_FRAME(pAdapter
,wrq
,pRaCfg
);
4299 ASSERT(pRaCfg
!= NULL
);
4308 VOID
BubbleSort(INT32 n
, INT32 a
[])
4312 for (k
= n
-1; k
>0; k
--)
4314 for (j
= 0; j
<k
; j
++)
4327 VOID
CalNoiseLevel(PRTMP_ADAPTER pAd
, UCHAR channel
, INT32 RSSI
[3][10])
4329 INT32 RSSI0
, RSSI1
, RSSI2
;
4330 CHAR Rssi0Offset
, Rssi1Offset
, Rssi2Offset
;
4331 UCHAR BbpR50Rssi0
= 0, BbpR51Rssi1
= 0, BbpR52Rssi2
= 0;
4332 UCHAR Org_BBP66value
= 0, Org_BBP69value
= 0, Org_BBP70value
= 0, data
= 0;
4333 USHORT LNA_Gain
= 0;
4335 UCHAR Org_Channel
= pAd
->ate
.Channel
;
4336 USHORT GainValue
= 0, OffsetValue
= 0;
4338 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R66
, &Org_BBP66value
);
4339 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R69
, &Org_BBP69value
);
4340 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R70
, &Org_BBP70value
);
4342 //**********************************************************************
4343 // Read the value of LNA gain and Rssi offset
4344 //**********************************************************************
4345 RT28xx_EEPROM_READ16(pAd
, EEPROM_LNA_OFFSET
, GainValue
);
4350 LNA_Gain
= GainValue
& 0x00FF;
4352 RT28xx_EEPROM_READ16(pAd
, EEPROM_RSSI_BG_OFFSET
, OffsetValue
);
4353 Rssi0Offset
= OffsetValue
& 0x00FF;
4354 Rssi1Offset
= (OffsetValue
& 0xFF00) >> 8;
4355 RT28xx_EEPROM_READ16(pAd
, (EEPROM_RSSI_BG_OFFSET
+ 2)/* 0x48 */, OffsetValue
);
4356 Rssi2Offset
= OffsetValue
& 0x00FF;
4360 LNA_Gain
= (GainValue
& 0xFF00) >> 8;
4362 RT28xx_EEPROM_READ16(pAd
, EEPROM_RSSI_A_OFFSET
, OffsetValue
);
4363 Rssi0Offset
= OffsetValue
& 0x00FF;
4364 Rssi1Offset
= (OffsetValue
& 0xFF00) >> 8;
4365 RT28xx_EEPROM_READ16(pAd
, (EEPROM_RSSI_A_OFFSET
+ 2)/* 0x4C */, OffsetValue
);
4366 Rssi2Offset
= OffsetValue
& 0x00FF;
4368 //**********************************************************************
4370 pAd
->ate
.Channel
= channel
;
4371 ATEAsicSwitchChannel(pAd
);
4375 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R66
, data
);
4377 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R69
, data
);
4379 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R70
, data
);
4383 pAd
->ate
.bQARxStart
= TRUE
;
4384 Set_ATE_Proc(pAd
, "RXFRAME");
4388 for (j
= 0; j
< 10; j
++)
4390 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R50
, &BbpR50Rssi0
);
4391 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R51
, &BbpR51Rssi1
);
4392 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, BBP_R52
, &BbpR52Rssi2
);
4397 if (BbpR50Rssi0
== 0)
4403 RSSI0
= (INT32
)(-12 - BbpR50Rssi0
- LNA_Gain
- Rssi0Offset
);
4407 if ( pAd
->Antenna
.field
.RxPath
>= 2 ) // 2R
4410 if (BbpR51Rssi1
== 0)
4416 RSSI1
= (INT32
)(-12 - BbpR51Rssi1
- LNA_Gain
- Rssi1Offset
);
4421 if ( pAd
->Antenna
.field
.RxPath
>= 3 ) // 3R
4424 if (BbpR52Rssi2
== 0)
4427 RSSI2
= (INT32
)(-12 - BbpR52Rssi2
- LNA_Gain
- Rssi2Offset
);
4434 Set_ATE_Proc(pAd
, "RXSTOP");
4438 BubbleSort(10, RSSI
[0]); // 1R
4440 if ( pAd
->Antenna
.field
.RxPath
>= 2 ) // 2R
4442 BubbleSort(10, RSSI
[1]);
4445 if ( pAd
->Antenna
.field
.RxPath
>= 3 ) // 3R
4447 BubbleSort(10, RSSI
[2]);
4451 pAd
->ate
.Channel
= Org_Channel
;
4452 ATEAsicSwitchChannel(pAd
);
4454 // restore original value
4455 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R66
, Org_BBP66value
);
4456 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R69
, Org_BBP69value
);
4457 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, BBP_R70
, Org_BBP70value
);
4463 BOOLEAN
SyncTxRxConfig(PRTMP_ADAPTER pAd
, USHORT offset
, UCHAR value
)
4465 UCHAR tmp
= 0, bbp_data
= 0;
4469 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, offset
, &bbp_data
);
4473 RTMP_BBP_IO_READ8_BY_REG_ID(pAd
, offset
, &bbp_data
);
4477 ASSERT(bbp_data
== value
);
4482 /* Need to synchronize tx configuration with legacy ATE. */
4483 tmp
= (bbp_data
& ((1 << 4) | (1 << 3))/* 0x18 */) >> 3;
4486 /* The BBP R1 bit[4:3] = 2 :: Both DACs will be used by QA. */
4489 pAd
->ate
.TxAntennaSel
= 0;
4491 /* The BBP R1 bit[4:3] = 0 :: DAC 0 will be used by QA. */
4494 pAd
->ate
.TxAntennaSel
= 1;
4496 /* The BBP R1 bit[4:3] = 1 :: DAC 1 will be used by QA. */
4499 pAd
->ate
.TxAntennaSel
= 2;
4502 DBGPRINT(RT_DEBUG_TRACE
, ("%s -- Sth. wrong! : return FALSE; \n", __FUNCTION__
));
4505 break;/* case BBP_R1 */
4508 /* Need to synchronize rx configuration with legacy ATE. */
4509 tmp
= (bbp_data
& ((1 << 1) | (1 << 0))/* 0x03 */);
4512 /* The BBP R3 bit[1:0] = 3 :: All ADCs will be used by QA. */
4515 pAd
->ate
.RxAntennaSel
= 0;
4518 The BBP R3 bit[1:0] = 0 :: ADC 0 will be used by QA,
4519 unless the BBP R3 bit[4:3] = 2
4523 pAd
->ate
.RxAntennaSel
= 1;
4524 tmp
= ((bbp_data
& ((1 << 4) | (1 << 3))/* 0x03 */) >> 3);
4527 /* Default : All ADCs will be used by QA */
4528 pAd
->ate
.RxAntennaSel
= 0;
4531 /* The BBP R3 bit[1:0] = 1 :: ADC 1 will be used by QA. */
4534 pAd
->ate
.RxAntennaSel
= 2;
4536 /* The BBP R3 bit[1:0] = 2 :: ADC 2 will be used by QA. */
4539 pAd
->ate
.RxAntennaSel
= 3;
4542 DBGPRINT(RT_DEBUG_ERROR
, ("%s -- Impossible! : return FALSE; \n", __FUNCTION__
));
4545 break;/* case BBP_R3 */
4548 DBGPRINT(RT_DEBUG_ERROR
, ("%s -- Sth. wrong! : return FALSE; \n", __FUNCTION__
));
4556 static VOID
memcpy_exl(PRTMP_ADAPTER pAd
, UCHAR
*dst
, UCHAR
*src
, ULONG len
)
4563 pDst
= (ULONG
*) dst
;
4564 pSrc
= (ULONG
*) src
;
4566 for (i
= 0 ; i
< (len
/4); i
++)
4568 /* For alignment issue, we need a variable "Value". */
4569 memmove(&Value
, pSrc
, 4);
4570 Value
= htonl(Value
);
4571 memmove(pDst
, &Value
, 4);
4577 /* wish that it will never reach here */
4578 memmove(&Value
, pSrc
, (len
% 4));
4579 Value
= htonl(Value
);
4580 memmove(pDst
, &Value
, (len
% 4));
4585 static VOID
memcpy_exs(PRTMP_ADAPTER pAd
, UCHAR
*dst
, UCHAR
*src
, ULONG len
)
4593 for (i
= 0; i
< (len
/2); i
++)
4595 memmove(pDst
, pSrc
, 2);
4596 *((USHORT
*)pDst
) = htons(*((USHORT
*)pDst
));
4603 memmove(pDst
, pSrc
, 1);
4608 static VOID
RTMP_IO_READ_BULK(PRTMP_ADAPTER pAd
, UCHAR
*dst
, UCHAR
*src
, UINT32 len
)
4611 UINT32
*pDst
, *pSrc
;
4613 pDst
= (UINT32
*) dst
;
4614 pSrc
= (UINT32
*) src
;
4616 for (i
= 0 ; i
< (len
/4); i
++)
4618 RTMP_IO_READ32(pAd
, (ULONG
)pSrc
, &Value
);
4619 Value
= htonl(Value
);
4620 memmove(pDst
, &Value
, 4);
4628 INT
Set_TxStop_Proc(
4629 IN PRTMP_ADAPTER pAd
,
4632 ATEDBGPRINT(RT_DEBUG_TRACE
,("Set_TxStop_Proc\n"));
4634 if (Set_ATE_Proc(pAd
, "TXSTOP"))
4645 INT
Set_RxStop_Proc(
4646 IN PRTMP_ADAPTER pAd
,
4649 ATEDBGPRINT(RT_DEBUG_TRACE
,("Set_RxStop_Proc\n"));
4651 if (Set_ATE_Proc(pAd
, "RXSTOP"))
4663 INT
Set_EERead_Proc(
4664 IN PRTMP_ADAPTER pAd
,
4667 USHORT buffer
[EEPROM_SIZE
/2];
4671 rt_ee_read_all(pAd
, (USHORT
*)buffer
);
4674 for (i
= 0; i
< (EEPROM_SIZE
/2); i
++)
4676 ate_print(KERN_EMERG
"%4.4x ", *p
);
4677 if (((i
+1) % 16) == 0)
4678 ate_print(KERN_EMERG
"\n");
4686 INT
Set_EEWrite_Proc(
4687 IN PRTMP_ADAPTER pAd
,
4690 USHORT offset
= 0, value
;
4693 while ((*p2
!= ':') && (*p2
!= '\0'))
4701 A2Hex(value
, p2
+ 1);
4708 if (offset
>= EEPROM_SIZE
)
4710 ate_print(KERN_EMERG
"Offset can not exceed EEPROM_SIZE( == 0x%04x)\n", EEPROM_SIZE
);
4714 RT28xx_EEPROM_WRITE16(pAd
, offset
, value
);
4720 INT
Set_BBPRead_Proc(
4721 IN PRTMP_ADAPTER pAd
,
4724 UCHAR value
= 0, offset
;
4730 ATE_BBP_IO_READ8_BY_REG_ID(pAd
, offset
, &value
);
4734 RTMP_BBP_IO_READ8_BY_REG_ID(pAd
, offset
, &value
);
4737 ate_print(KERN_EMERG
"%x\n", value
);
4743 INT
Set_BBPWrite_Proc(
4744 IN PRTMP_ADAPTER pAd
,
4751 while ((*p2
!= ':') && (*p2
!= '\0'))
4759 A2Hex(value
, p2
+ 1);
4768 ATE_BBP_IO_WRITE8_BY_REG_ID(pAd
, offset
, value
);
4772 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd
, offset
, value
);
4779 INT
Set_RFWrite_Proc(
4780 IN PRTMP_ADAPTER pAd
,
4784 UINT32 R1
, R2
, R3
, R4
;
4788 while ((*p2
!= ':') && (*p2
!= '\0'))
4798 while((*p3
!= ':') && (*p3
!= '\0'))
4808 while ((*p4
!= ':') && (*p4
!= '\0'))
4822 RTMP_RF_IO_WRITE32(pAd
, R1
);
4823 RTMP_RF_IO_WRITE32(pAd
, R2
);
4824 RTMP_RF_IO_WRITE32(pAd
, R3
);
4825 RTMP_RF_IO_WRITE32(pAd
, R4
);
4830 #endif // RALINK_28xx_QA //
4835 #ifdef RALINK_28xx_QA
4836 #define LEN_OF_ARG 16
4838 #define RESPONSE_TO_GUI(__pRaCfg, __pwrq, __Length, __Status) \
4839 (__pRaCfg)->length = htons((__Length)); \
4840 (__pRaCfg)->status = htons((__Status)); \
4841 (__pwrq)->u.data.length = sizeof((__pRaCfg)->magic_no) + sizeof((__pRaCfg)->command_type) \
4842 + sizeof((__pRaCfg)->command_id) + sizeof((__pRaCfg)->length) \
4843 + sizeof((__pRaCfg)->sequence) + ntohs((__pRaCfg)->length); \
4844 ATEDBGPRINT(RT_DEBUG_TRACE, ("wrq->u.data.length = %d\n", (__pwrq)->u.data.length)); \
4845 if (copy_to_user((__pwrq)->u.data.pointer, (UCHAR *)(__pRaCfg), (__pwrq)->u.data.length)) \
4847 ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in %s\n", __FUNCTION__)); \
4852 ATEDBGPRINT(RT_DEBUG_TRACE, ("%s is done !\n", __FUNCTION__)); \
4855 static inline INT
DO_RACFG_CMD_ATE_START(
4856 IN PRTMP_ADAPTER pAdapter
,
4857 IN
struct iwreq
*wrq
,
4858 IN
struct ate_racfghdr
*pRaCfg
)
4860 ATEDBGPRINT(RT_DEBUG_TRACE
,("RACFG_CMD_ATE_START\n"));
4862 /* Prepare feedback as soon as we can to avoid QA timeout. */
4863 RESPONSE_TO_GUI(pRaCfg
, wrq
, sizeof(pRaCfg
->status
), NDIS_STATUS_SUCCESS
);
4864 Set_ATE_Proc(pAdapter
, "ATESTART");
4866 return NDIS_STATUS_SUCCESS
;
4870 static inline INT
DO_RACFG_CMD_ATE_STOP(
4871 IN PRTMP_ADAPTER pAdapter
,
4872 IN
struct iwreq
*wrq
,
4873 IN
struct ate_racfghdr
*pRaCfg
)
4877 ATEDBGPRINT(RT_DEBUG_TRACE
,("RACFG_CMD_ATE_STOP\n"));
4880 Distinguish this command came from QA(via ate agent)
4881 or ate agent according to the existence of pid in payload.
4883 No need to prepare feedback if this cmd came directly from ate agent,
4886 pRaCfg
->length
= ntohs(pRaCfg
->length
);
4888 if (pRaCfg
->length
== sizeof(pAdapter
->ate
.AtePid
))
4891 This command came from QA.
4892 Get the pid of ATE agent.
4894 memcpy((UCHAR
*)&pAdapter
->ate
.AtePid
,
4895 (&pRaCfg
->data
[0]) - 2/* == sizeof(pRaCfg->status) */,
4896 sizeof(pAdapter
->ate
.AtePid
));
4898 /* Prepare feedback as soon as we can to avoid QA timeout. */
4899 RESPONSE_TO_GUI(pRaCfg
, wrq
, sizeof(pRaCfg
->status
), NDIS_STATUS_SUCCESS
);
4902 Kill ATE agent when leaving ATE mode.
4904 We must kill ATE agent first before setting ATESTOP,
4905 or Microsoft will report sth. wrong.
4907 ret
= KILL_THREAD_PID(pAdapter
->ate
.AtePid
, SIGTERM
, 1);
4911 ATEDBGPRINT(RT_DEBUG_ERROR
, ("%s: unable to kill ate thread\n", pAdapter
->net_dev
->name
));
4916 /* AP/STA might have in ATE_STOP mode due to cmd from QA. */
4917 if (ATE_ON(pAdapter
))
4919 /* Someone has killed ate agent while QA GUI is still open. */
4920 Set_ATE_Proc(pAdapter
, "ATESTOP");
4921 ATEDBGPRINT(RT_DEBUG_TRACE
, ("RACFG_CMD_AP_START is done !\n"));
4924 return NDIS_STATUS_SUCCESS
;
4928 static inline INT
DO_RACFG_CMD_RF_WRITE_ALL(
4929 IN PRTMP_ADAPTER pAdapter
,
4930 IN
struct iwreq
*wrq
,
4931 IN
struct ate_racfghdr
*pRaCfg
)
4933 UINT32 R1
, R2
, R3
, R4
;
4936 memcpy(&R1
, pRaCfg
->data
-2, 4);
4937 memcpy(&R2
, pRaCfg
->data
+2, 4);
4938 memcpy(&R3
, pRaCfg
->data
+6, 4);
4939 memcpy(&R4
, pRaCfg
->data
+10, 4);
4940 memcpy(&channel
, pRaCfg
->data
+14, 2);
4942 pAdapter
->LatchRfRegs
.R1
= ntohl(R1
);
4943 pAdapter
->LatchRfRegs
.R2
= ntohl(R2
);
4944 pAdapter
->LatchRfRegs
.R3
= ntohl(R3
);
4945 pAdapter
->LatchRfRegs
.R4
= ntohl(R4
);
4946 pAdapter
->LatchRfRegs
.Channel
= ntohs(channel
);
4948 RTMP_RF_IO_WRITE32(pAdapter
, pAdapter
->LatchRfRegs
.R1
);
4949 RTMP_RF_IO_WRITE32(pAdapter
, pAdapter
->LatchRfRegs
.R2
);
4950 RTMP_RF_IO_WRITE32(pAdapter
, pAdapter
->LatchRfRegs
.R3
);
4951 RTMP_RF_IO_WRITE32(pAdapter
, pAdapter
->LatchRfRegs
.R4
);
4953 RESPONSE_TO_GUI(pRaCfg
, wrq
, sizeof(pRaCfg
->status
), NDIS_STATUS_SUCCESS
);
4955 return NDIS_STATUS_SUCCESS
;
4959 static inline INT
DO_RACFG_CMD_E2PROM_READ16(
4960 IN PRTMP_ADAPTER pAdapter
,
4961 IN
struct iwreq
*wrq
,
4962 IN
struct ate_racfghdr
*pRaCfg
)
4964 UINT16 offset
=0, value
=0;
4967 offset
= ntohs(pRaCfg
->status
);
4969 /* "tmp" is especially for some compilers... */
4970 RT28xx_EEPROM_READ16(pAdapter
, offset
, tmp
);
4972 value
= htons(value
);
4974 ATEDBGPRINT(RT_DEBUG_TRACE
,("EEPROM Read offset = 0x%04x, value = 0x%04x\n", offset
, value
));
4975 memcpy(pRaCfg
->data
, &value
, 2);
4977 RESPONSE_TO_GUI(pRaCfg
, wrq
, sizeof(pRaCfg
->status
)+2, NDIS_STATUS_SUCCESS
);
4979 return NDIS_STATUS_SUCCESS
;
4983 static inline INT
DO_RACFG_CMD_E2PROM_WRITE16(
4984 IN PRTMP_ADAPTER pAdapter
,
4985 IN
struct iwreq
*wrq
,
4986 IN
struct ate_racfghdr
*pRaCfg
)
4988 USHORT offset
, value
;
4990 offset
= ntohs(pRaCfg
->status
);
4991 memcpy(&value
, pRaCfg
->data
, 2);
4992 value
= ntohs(value
);
4993 RT28xx_EEPROM_WRITE16(pAdapter
, offset
, value
);
4995 RESPONSE_TO_GUI(pRaCfg
, wrq
, sizeof(pRaCfg
->status
), NDIS_STATUS_SUCCESS
);
4997 return NDIS_STATUS_SUCCESS
;
5001 static inline INT
DO_RACFG_CMD_E2PROM_READ_ALL(
5002 IN PRTMP_ADAPTER pAdapter
,
5003 IN
struct iwreq
*wrq
,
5004 IN
struct ate_racfghdr
*pRaCfg
)
5006 USHORT buffer
[EEPROM_SIZE
/2];
5008 rt_ee_read_all(pAdapter
,(USHORT
*)buffer
);
5009 memcpy_exs(pAdapter
, pRaCfg
->data
, (UCHAR
*)buffer
, EEPROM_SIZE
);
5011 RESPONSE_TO_GUI(pRaCfg
, wrq
, sizeof(pRaCfg
->status
)+EEPROM_SIZE
, NDIS_STATUS_SUCCESS
);
5013 return NDIS_STATUS_SUCCESS
;
5017 static inline INT
DO_RACFG_CMD_E2PROM_WRITE_ALL(
5018 IN PRTMP_ADAPTER pAdapter
,
5019 IN
struct iwreq
*wrq
,
5020 IN
struct ate_racfghdr
*pRaCfg
)
5022 USHORT buffer
[EEPROM_SIZE
/2];
5024 NdisZeroMemory((UCHAR
*)buffer
, EEPROM_SIZE
);
5025 memcpy_exs(pAdapter
, (UCHAR
*)buffer
, (UCHAR
*)&pRaCfg
->status
, EEPROM_SIZE
);
5026 rt_ee_write_all(pAdapter
,(USHORT
*)buffer
);
5028 RESPONSE_TO_GUI(pRaCfg
, wrq
, sizeof(pRaCfg
->status
), NDIS_STATUS_SUCCESS
);
5030 return NDIS_STATUS_SUCCESS
;
5034 static inline INT
DO_RACFG_CMD_IO_READ(
5035 IN PRTMP_ADAPTER pAdapter
,
5036 IN
struct iwreq
*wrq
,
5037 IN
struct ate_racfghdr
*pRaCfg
)
5042 memcpy(&offset
, &pRaCfg
->status
, 4);
5043 offset
= ntohl(offset
);
5046 We do not need the base address.
5047 So just extract the offset out.
5049 offset
&= 0x0000FFFF;
5050 RTMP_IO_READ32(pAdapter
, offset
, &value
);
5051 value
= htonl(value
);
5052 memcpy(pRaCfg
->data
, &value
, 4);
5054 RESPONSE_TO_GUI(pRaCfg
, wrq
, sizeof(pRaCfg
->status
)+4, NDIS_STATUS_SUCCESS
);
5056 return NDIS_STATUS_SUCCESS
;
5060 static inline INT
DO_RACFG_CMD_IO_WRITE(
5061 IN PRTMP_ADAPTER pAdapter
,
5062 IN
struct iwreq
*wrq
,
5063 IN
struct ate_racfghdr
*pRaCfg
)
5065 UINT32 offset
, value
;
5067 memcpy(&offset
, pRaCfg
->data
-2, 4);
5068 memcpy(&value
, pRaCfg
->data
+2, 4);
5070 offset
= ntohl(offset
);
5073 We do not need the base address.
5074 So just extract the offset out.
5076 offset
&= 0x0000FFFF;
5077 value
= ntohl(value
);
5078 ATEDBGPRINT(RT_DEBUG_TRACE
,("RACFG_CMD_IO_WRITE: offset = %x, value = %x\n", offset
, value
));
5079 RTMP_IO_WRITE32(pAdapter
, offset
, value
);
5081 RESPONSE_TO_GUI(pRaCfg
, wrq
, sizeof(pRaCfg
->status
), NDIS_STATUS_SUCCESS
);
5083 return NDIS_STATUS_SUCCESS
;
5087 static inline INT
DO_RACFG_CMD_IO_READ_BULK(
5088 IN PRTMP_ADAPTER pAdapter
,
5089 IN
struct iwreq
*wrq
,
5090 IN
struct ate_racfghdr
*pRaCfg
)
5095 memcpy(&offset
, &pRaCfg
->status
, 4);
5096 offset
= ntohl(offset
);
5099 We do not need the base address.
5100 So just extract the offset out.
5102 offset
&= 0x0000FFFF;
5103 memcpy(&len
, pRaCfg
->data
+2, 2);
5108 ATEDBGPRINT(RT_DEBUG_TRACE
,("length requested is too large, make it smaller\n"));
5109 pRaCfg
->length
= htons(2);
5110 pRaCfg
->status
= htons(1);
5114 RTMP_IO_READ_BULK(pAdapter
, pRaCfg
->data
, (UCHAR
*)offset
, len
*4);// unit in four bytes
5116 RESPONSE_TO_GUI(pRaCfg
, wrq
, sizeof(pRaCfg
->status
)+(len
*4), NDIS_STATUS_SUCCESS
);
5118 return NDIS_STATUS_SUCCESS
;
5122 static inline INT
DO_RACFG_CMD_BBP_READ8(
5123 IN PRTMP_ADAPTER pAdapter
,
5124 IN
struct iwreq
*wrq
,
5125 IN
struct ate_racfghdr
*pRaCfg
)
5131 offset
= ntohs(pRaCfg
->status
);
5133 if (ATE_ON(pAdapter
))
5135 ATE_BBP_IO_READ8_BY_REG_ID(pAdapter
, offset
, &value
);
5139 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter
, offset
, &value
);
5142 pRaCfg
->data
[0] = value
;
5144 RESPONSE_TO_GUI(pRaCfg
, wrq
, sizeof(pRaCfg
->status
)+1, NDIS_STATUS_SUCCESS
);
5146 return NDIS_STATUS_SUCCESS
;
5150 static inline INT
DO_RACFG_CMD_BBP_WRITE8(
5151 IN PRTMP_ADAPTER pAdapter
,
5152 IN
struct iwreq
*wrq
,
5153 IN
struct ate_racfghdr
*pRaCfg
)
5158 offset
= ntohs(pRaCfg
->status
);
5159 memcpy(&value
, pRaCfg
->data
, 1);
5161 if (ATE_ON(pAdapter
))
5163 ATE_BBP_IO_WRITE8_BY_REG_ID(pAdapter
, offset
, value
);
5167 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter
, offset
, value
);
5170 if ((offset
== BBP_R1
) || (offset
== BBP_R3
))
5172 SyncTxRxConfig(pAdapter
, offset
, value
);
5175 RESPONSE_TO_GUI(pRaCfg
, wrq
, sizeof(pRaCfg
->status
), NDIS_STATUS_SUCCESS
);
5177 return NDIS_STATUS_SUCCESS
;
5181 static inline INT
DO_RACFG_CMD_BBP_READ_ALL(
5182 IN PRTMP_ADAPTER pAdapter
,
5183 IN
struct iwreq
*wrq
,
5184 IN
struct ate_racfghdr
*pRaCfg
)
5186 USHORT bbp_reg_index
;
5188 for (bbp_reg_index
= 0; bbp_reg_index
< MAX_BBP_ID
+1; bbp_reg_index
++)
5190 pRaCfg
->data
[bbp_reg_index
] = 0;
5192 if (ATE_ON(pAdapter
))
5194 ATE_BBP_IO_READ8_BY_REG_ID(pAdapter
, bbp_reg_index
, &pRaCfg
->data
[bbp_reg_index
]);
5198 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter
, bbp_reg_index
, &pRaCfg
->data
[bbp_reg_index
]);
5202 RESPONSE_TO_GUI(pRaCfg
, wrq
, sizeof(pRaCfg
->status
)+MAX_BBP_ID
+1, NDIS_STATUS_SUCCESS
);
5204 return NDIS_STATUS_SUCCESS
;
5208 static inline INT
DO_RACFG_CMD_GET_NOISE_LEVEL(
5209 IN PRTMP_ADAPTER pAdapter
,
5210 IN
struct iwreq
*wrq
,
5211 IN
struct ate_racfghdr
*pRaCfg
)
5214 INT32 buffer
[3][10];/* 3 : RxPath ; 10 : no. of per rssi samples */
5216 channel
= (ntohs(pRaCfg
->status
) & 0x00FF);
5217 CalNoiseLevel(pAdapter
, channel
, buffer
);
5218 memcpy_exl(pAdapter
, (UCHAR
*)pRaCfg
->data
, (UCHAR
*)&(buffer
[0][0]), (sizeof(INT32
)*3*10));
5220 RESPONSE_TO_GUI(pRaCfg
, wrq
, sizeof(pRaCfg
->status
)+(sizeof(INT32
)*3*10), NDIS_STATUS_SUCCESS
);
5222 return NDIS_STATUS_SUCCESS
;
5226 static inline INT
DO_RACFG_CMD_GET_COUNTER(
5227 IN PRTMP_ADAPTER pAdapter
,
5228 IN
struct iwreq
*wrq
,
5229 IN
struct ate_racfghdr
*pRaCfg
)
5231 memcpy_exl(pAdapter
, &pRaCfg
->data
[0], (UCHAR
*)&pAdapter
->ate
.U2M
, 4);
5232 memcpy_exl(pAdapter
, &pRaCfg
->data
[4], (UCHAR
*)&pAdapter
->ate
.OtherData
, 4);
5233 memcpy_exl(pAdapter
, &pRaCfg
->data
[8], (UCHAR
*)&pAdapter
->ate
.Beacon
, 4);
5234 memcpy_exl(pAdapter
, &pRaCfg
->data
[12], (UCHAR
*)&pAdapter
->ate
.OtherCount
, 4);
5235 memcpy_exl(pAdapter
, &pRaCfg
->data
[16], (UCHAR
*)&pAdapter
->ate
.TxAc0
, 4);
5236 memcpy_exl(pAdapter
, &pRaCfg
->data
[20], (UCHAR
*)&pAdapter
->ate
.TxAc1
, 4);
5237 memcpy_exl(pAdapter
, &pRaCfg
->data
[24], (UCHAR
*)&pAdapter
->ate
.TxAc2
, 4);
5238 memcpy_exl(pAdapter
, &pRaCfg
->data
[28], (UCHAR
*)&pAdapter
->ate
.TxAc3
, 4);
5239 /*memcpy_exl(pAdapter, &pRaCfg->data[32], (UCHAR *)&pAdapter->ate.TxHCCA, 4);*/
5240 memcpy_exl(pAdapter
, &pRaCfg
->data
[36], (UCHAR
*)&pAdapter
->ate
.TxMgmt
, 4);
5241 memcpy_exl(pAdapter
, &pRaCfg
->data
[40], (UCHAR
*)&pAdapter
->ate
.RSSI0
, 4);
5242 memcpy_exl(pAdapter
, &pRaCfg
->data
[44], (UCHAR
*)&pAdapter
->ate
.RSSI1
, 4);
5243 memcpy_exl(pAdapter
, &pRaCfg
->data
[48], (UCHAR
*)&pAdapter
->ate
.RSSI2
, 4);
5244 memcpy_exl(pAdapter
, &pRaCfg
->data
[52], (UCHAR
*)&pAdapter
->ate
.SNR0
, 4);
5245 memcpy_exl(pAdapter
, &pRaCfg
->data
[56], (UCHAR
*)&pAdapter
->ate
.SNR1
, 4);
5247 RESPONSE_TO_GUI(pRaCfg
, wrq
, sizeof(pRaCfg
->status
)+60, NDIS_STATUS_SUCCESS
);
5249 return NDIS_STATUS_SUCCESS
;
5253 static inline INT
DO_RACFG_CMD_CLEAR_COUNTER(
5254 IN PRTMP_ADAPTER pAdapter
,
5255 IN
struct iwreq
*wrq
,
5256 IN
struct ate_racfghdr
*pRaCfg
)
5258 pAdapter
->ate
.U2M
= 0;
5259 pAdapter
->ate
.OtherData
= 0;
5260 pAdapter
->ate
.Beacon
= 0;
5261 pAdapter
->ate
.OtherCount
= 0;
5262 pAdapter
->ate
.TxAc0
= 0;
5263 pAdapter
->ate
.TxAc1
= 0;
5264 pAdapter
->ate
.TxAc2
= 0;
5265 pAdapter
->ate
.TxAc3
= 0;
5266 /*pAdapter->ate.TxHCCA = 0;*/
5267 pAdapter
->ate
.TxMgmt
= 0;
5268 pAdapter
->ate
.TxDoneCount
= 0;
5270 RESPONSE_TO_GUI(pRaCfg
, wrq
, sizeof(pRaCfg
->status
), NDIS_STATUS_SUCCESS
);
5272 return NDIS_STATUS_SUCCESS
;
5276 static inline INT
DO_RACFG_CMD_TX_START(
5277 IN PRTMP_ADAPTER pAdapter
,
5278 IN
struct iwreq
*wrq
,
5279 IN
struct ate_racfghdr
*pRaCfg
)
5283 UCHAR Bbp22Value
= 0, Bbp24Value
= 0;
5285 if ((pAdapter
->ate
.TxStatus
!= 0) && (pAdapter
->ate
.Mode
& ATE_TXFRAME
))
5287 ATEDBGPRINT(RT_DEBUG_TRACE
,("Ate Tx is already running, to run next Tx, you must stop it first\n"));
5289 goto TX_START_ERROR
;
5291 else if ((pAdapter
->ate
.TxStatus
!= 0) && !(pAdapter
->ate
.Mode
& ATE_TXFRAME
))
5295 while ((i
++ < 10) && (pAdapter
->ate
.TxStatus
!= 0))
5297 RTMPusecDelay(5000);
5300 /* force it to stop */
5301 pAdapter
->ate
.TxStatus
= 0;
5302 pAdapter
->ate
.TxDoneCount
= 0;
5303 pAdapter
->ate
.bQATxStart
= FALSE
;
5307 If pRaCfg->length == 0, this "RACFG_CMD_TX_START"
5308 is for Carrier test or Carrier Suppression.
5310 if (ntohs(pRaCfg
->length
) != 0)
5312 /* get frame info */
5314 NdisMoveMemory(&pAdapter
->ate
.TxWI
, pRaCfg
->data
+ 2, 16);
5315 #ifdef RT_BIG_ENDIAN
5316 RTMPWIEndianChange((PUCHAR
)&pAdapter
->ate
.TxWI
, TYPE_TXWI
);
5317 #endif // RT_BIG_ENDIAN //
5319 NdisMoveMemory(&pAdapter
->ate
.TxCount
, pRaCfg
->data
+ 18, 4);
5320 pAdapter
->ate
.TxCount
= ntohl(pAdapter
->ate
.TxCount
);
5322 p
= (USHORT
*)(&pRaCfg
->data
[22]);
5324 /* always use QID_AC_BE */
5325 pAdapter
->ate
.QID
= 0;
5327 p
= (USHORT
*)(&pRaCfg
->data
[24]);
5328 pAdapter
->ate
.HLen
= ntohs(*p
);
5330 if (pAdapter
->ate
.HLen
> 32)
5332 ATEDBGPRINT(RT_DEBUG_ERROR
,("pAdapter->ate.HLen > 32\n"));
5334 goto TX_START_ERROR
;
5337 NdisMoveMemory(&pAdapter
->ate
.Header
, pRaCfg
->data
+ 26, pAdapter
->ate
.HLen
);
5339 pAdapter
->ate
.PLen
= ntohs(pRaCfg
->length
) - (pAdapter
->ate
.HLen
+ 28);
5341 if (pAdapter
->ate
.PLen
> 32)
5343 ATEDBGPRINT(RT_DEBUG_ERROR
,("pAdapter->ate.PLen > 32\n"));
5345 goto TX_START_ERROR
;
5348 NdisMoveMemory(&pAdapter
->ate
.Pattern
, pRaCfg
->data
+ 26 + pAdapter
->ate
.HLen
, pAdapter
->ate
.PLen
);
5349 pAdapter
->ate
.DLen
= pAdapter
->ate
.TxWI
.MPDUtotalByteCount
- pAdapter
->ate
.HLen
;
5352 ATE_BBP_IO_READ8_BY_REG_ID(pAdapter
, BBP_R22
, &Bbp22Value
);
5358 if (pAdapter
->ate
.TxCount
== 0)
5361 pAdapter
->ate
.TxCount
= 0xFFFFFFFF;
5362 #endif // RTMP_MAC_PCI //
5364 ATEDBGPRINT(RT_DEBUG_TRACE
,("START TXFRAME\n"));
5365 pAdapter
->ate
.bQATxStart
= TRUE
;
5366 Set_ATE_Proc(pAdapter
, "TXFRAME");
5370 case BBP22_TXCONT_OR_CARRSUPP
:
5372 ATEDBGPRINT(RT_DEBUG_TRACE
,("BBP22_TXCONT_OR_CARRSUPP\n"));
5373 ATE_BBP_IO_READ8_BY_REG_ID(pAdapter
, BBP_R24
, &Bbp24Value
);
5379 ATEDBGPRINT(RT_DEBUG_TRACE
,("START TXCONT\n"));
5380 pAdapter
->ate
.bQATxStart
= TRUE
;
5381 Set_ATE_Proc(pAdapter
, "TXCONT");
5385 case BBP24_CARRSUPP
:
5387 ATEDBGPRINT(RT_DEBUG_TRACE
,("START TXCARRSUPP\n"));
5388 pAdapter
->ate
.bQATxStart
= TRUE
;
5389 pAdapter
->ate
.Mode
|= ATE_TXCARRSUPP
;
5395 ATEDBGPRINT(RT_DEBUG_ERROR
,("Unknown TX subtype !"));
5404 ATEDBGPRINT(RT_DEBUG_TRACE
,("START TXCARR\n"));
5405 pAdapter
->ate
.bQATxStart
= TRUE
;
5406 Set_ATE_Proc(pAdapter
, "TXCARR");
5412 ATEDBGPRINT(RT_DEBUG_ERROR
,("Unknown Start TX subtype !"));
5417 if (pAdapter
->ate
.bQATxStart
== TRUE
)
5419 RESPONSE_TO_GUI(pRaCfg
, wrq
, sizeof(pRaCfg
->status
), NDIS_STATUS_SUCCESS
);
5420 return NDIS_STATUS_SUCCESS
;
5424 RESPONSE_TO_GUI(pRaCfg
, wrq
, sizeof(pRaCfg
->status
), err
);
5430 static inline INT
DO_RACFG_CMD_GET_TX_STATUS(
5431 IN PRTMP_ADAPTER pAdapter
,
5432 IN
struct iwreq
*wrq
,
5433 IN
struct ate_racfghdr
*pRaCfg
)
5437 count
= htonl(pAdapter
->ate
.TxDoneCount
);
5438 NdisMoveMemory(pRaCfg
->data
, &count
, 4);
5440 RESPONSE_TO_GUI(pRaCfg
, wrq
, sizeof(pRaCfg
->status
)+4, NDIS_STATUS_SUCCESS
);
5442 return NDIS_STATUS_SUCCESS
;
5446 static inline INT
DO_RACFG_CMD_TX_STOP(
5447 IN PRTMP_ADAPTER pAdapter
,
5448 IN
struct iwreq
*wrq
,
5449 IN
struct ate_racfghdr
*pRaCfg
)
5451 ATEDBGPRINT(RT_DEBUG_TRACE
,("RACFG_CMD_TX_STOP\n"));
5453 Set_ATE_Proc(pAdapter
, "TXSTOP");
5455 RESPONSE_TO_GUI(pRaCfg
, wrq
, sizeof(pRaCfg
->status
), NDIS_STATUS_SUCCESS
);
5457 return NDIS_STATUS_SUCCESS
;
5461 static inline INT
DO_RACFG_CMD_RX_START(
5462 IN PRTMP_ADAPTER pAdapter
,
5463 IN
struct iwreq
*wrq
,
5464 IN
struct ate_racfghdr
*pRaCfg
)
5466 ATEDBGPRINT(RT_DEBUG_TRACE
,("RACFG_CMD_RX_START\n"));
5468 pAdapter
->ate
.bQARxStart
= TRUE
;
5469 Set_ATE_Proc(pAdapter
, "RXFRAME");
5471 RESPONSE_TO_GUI(pRaCfg
, wrq
, sizeof(pRaCfg
->status
), NDIS_STATUS_SUCCESS
);
5473 return NDIS_STATUS_SUCCESS
;
5477 static inline INT
DO_RACFG_CMD_RX_STOP(
5478 IN PRTMP_ADAPTER pAdapter
,
5479 IN
struct iwreq
*wrq
,
5480 IN
struct ate_racfghdr
*pRaCfg
)
5482 ATEDBGPRINT(RT_DEBUG_TRACE
,("RACFG_CMD_RX_STOP\n"));
5484 Set_ATE_Proc(pAdapter
, "RXSTOP");
5486 RESPONSE_TO_GUI(pRaCfg
, wrq
, sizeof(pRaCfg
->status
), NDIS_STATUS_SUCCESS
);
5488 return NDIS_STATUS_SUCCESS
;
5492 static inline INT
DO_RACFG_CMD_ATE_START_TX_CARRIER(
5493 IN PRTMP_ADAPTER pAdapter
,
5494 IN
struct iwreq
*wrq
,
5495 IN
struct ate_racfghdr
*pRaCfg
)
5497 ATEDBGPRINT(RT_DEBUG_TRACE
,("RACFG_CMD_ATE_START_TX_CARRIER\n"));
5499 Set_ATE_Proc(pAdapter
, "TXCARR");
5501 RESPONSE_TO_GUI(pRaCfg
, wrq
, sizeof(pRaCfg
->status
), NDIS_STATUS_SUCCESS
);
5503 return NDIS_STATUS_SUCCESS
;
5507 static inline INT
DO_RACFG_CMD_ATE_START_TX_CONT(
5508 IN PRTMP_ADAPTER pAdapter
,
5509 IN
struct iwreq
*wrq
,
5510 IN
struct ate_racfghdr
*pRaCfg
)
5512 ATEDBGPRINT(RT_DEBUG_TRACE
,("RACFG_CMD_ATE_START_TX_CONT\n"));
5514 Set_ATE_Proc(pAdapter
, "TXCONT");
5516 RESPONSE_TO_GUI(pRaCfg
, wrq
, sizeof(pRaCfg
->status
), NDIS_STATUS_SUCCESS
);
5518 return NDIS_STATUS_SUCCESS
;
5522 static inline INT
DO_RACFG_CMD_ATE_START_TX_FRAME(
5523 IN PRTMP_ADAPTER pAdapter
,
5524 IN
struct iwreq
*wrq
,
5525 IN
struct ate_racfghdr
*pRaCfg
)
5527 ATEDBGPRINT(RT_DEBUG_TRACE
,("RACFG_CMD_ATE_START_TX_FRAME\n"));
5529 Set_ATE_Proc(pAdapter
, "TXFRAME");
5531 RESPONSE_TO_GUI(pRaCfg
, wrq
, sizeof(pRaCfg
->status
), NDIS_STATUS_SUCCESS
);
5533 return NDIS_STATUS_SUCCESS
;
5537 static inline INT
DO_RACFG_CMD_ATE_SET_BW(
5538 IN PRTMP_ADAPTER pAdapter
,
5539 IN
struct iwreq
*wrq
,
5540 IN
struct ate_racfghdr
*pRaCfg
)
5543 STRING str
[LEN_OF_ARG
];
5545 NdisZeroMemory(str
, LEN_OF_ARG
);
5547 ATEDBGPRINT(RT_DEBUG_TRACE
,("RACFG_CMD_ATE_SET_BW\n"));
5549 memcpy((PUCHAR
)&value
, (PUCHAR
)&(pRaCfg
->status
), 2);
5550 value
= ntohs(value
);
5551 sprintf((char *)str
, "%d", value
);
5553 Set_ATE_TX_BW_Proc(pAdapter
, str
);
5555 RESPONSE_TO_GUI(pRaCfg
, wrq
, sizeof(pRaCfg
->status
), NDIS_STATUS_SUCCESS
);
5557 return NDIS_STATUS_SUCCESS
;
5561 static inline INT
DO_RACFG_CMD_ATE_SET_TX_POWER0(
5562 IN PRTMP_ADAPTER pAdapter
,
5563 IN
struct iwreq
*wrq
,
5564 IN
struct ate_racfghdr
*pRaCfg
)
5567 STRING str
[LEN_OF_ARG
];
5569 NdisZeroMemory(str
, LEN_OF_ARG
);
5571 ATEDBGPRINT(RT_DEBUG_TRACE
,("RACFG_CMD_ATE_SET_TX_POWER0\n"));
5573 memcpy((PUCHAR
)&value
, (PUCHAR
)&(pRaCfg
->status
), 2);
5574 value
= ntohs(value
);
5575 sprintf((char *)str
, "%d", value
);
5576 Set_ATE_TX_POWER0_Proc(pAdapter
, str
);
5578 RESPONSE_TO_GUI(pRaCfg
, wrq
, sizeof(pRaCfg
->status
), NDIS_STATUS_SUCCESS
);
5580 return NDIS_STATUS_SUCCESS
;
5584 static inline INT
DO_RACFG_CMD_ATE_SET_TX_POWER1(
5585 IN PRTMP_ADAPTER pAdapter
,
5586 IN
struct iwreq
*wrq
,
5587 IN
struct ate_racfghdr
*pRaCfg
)
5590 STRING str
[LEN_OF_ARG
];
5592 NdisZeroMemory(str
, LEN_OF_ARG
);
5594 ATEDBGPRINT(RT_DEBUG_TRACE
,("RACFG_CMD_ATE_SET_TX_POWER1\n"));
5596 memcpy((PUCHAR
)&value
, (PUCHAR
)&(pRaCfg
->status
), 2);
5597 value
= ntohs(value
);
5598 sprintf((char *)str
, "%d", value
);
5599 Set_ATE_TX_POWER1_Proc(pAdapter
, str
);
5601 RESPONSE_TO_GUI(pRaCfg
, wrq
, sizeof(pRaCfg
->status
), NDIS_STATUS_SUCCESS
);
5603 return NDIS_STATUS_SUCCESS
;
5607 static inline INT
DO_RACFG_CMD_ATE_SET_FREQ_OFFSET(
5608 IN PRTMP_ADAPTER pAdapter
,
5609 IN
struct iwreq
*wrq
,
5610 IN
struct ate_racfghdr
*pRaCfg
)
5613 STRING str
[LEN_OF_ARG
];
5615 NdisZeroMemory(str
, LEN_OF_ARG
);
5617 ATEDBGPRINT(RT_DEBUG_TRACE
,("RACFG_CMD_ATE_SET_FREQ_OFFSET\n"));
5619 memcpy((PUCHAR
)&value
, (PUCHAR
)&(pRaCfg
->status
), 2);
5620 value
= ntohs(value
);
5621 sprintf((char *)str
, "%d", value
);
5622 Set_ATE_TX_FREQOFFSET_Proc(pAdapter
, str
);
5624 RESPONSE_TO_GUI(pRaCfg
, wrq
, sizeof(pRaCfg
->status
), NDIS_STATUS_SUCCESS
);
5626 return NDIS_STATUS_SUCCESS
;
5630 static inline INT
DO_RACFG_CMD_ATE_GET_STATISTICS(
5631 IN PRTMP_ADAPTER pAdapter
,
5632 IN
struct iwreq
*wrq
,
5633 IN
struct ate_racfghdr
*pRaCfg
)
5635 ATEDBGPRINT(RT_DEBUG_TRACE
,("RACFG_CMD_ATE_GET_STATISTICS\n"));
5637 memcpy_exl(pAdapter
, &pRaCfg
->data
[0], (UCHAR
*)&pAdapter
->ate
.TxDoneCount
, 4);
5638 memcpy_exl(pAdapter
, &pRaCfg
->data
[4], (UCHAR
*)&pAdapter
->WlanCounters
.RetryCount
.u
.LowPart
, 4);
5639 memcpy_exl(pAdapter
, &pRaCfg
->data
[8], (UCHAR
*)&pAdapter
->WlanCounters
.FailedCount
.u
.LowPart
, 4);
5640 memcpy_exl(pAdapter
, &pRaCfg
->data
[12], (UCHAR
*)&pAdapter
->WlanCounters
.RTSSuccessCount
.u
.LowPart
, 4);
5641 memcpy_exl(pAdapter
, &pRaCfg
->data
[16], (UCHAR
*)&pAdapter
->WlanCounters
.RTSFailureCount
.u
.LowPart
, 4);
5642 memcpy_exl(pAdapter
, &pRaCfg
->data
[20], (UCHAR
*)&pAdapter
->WlanCounters
.ReceivedFragmentCount
.QuadPart
, 4);
5643 memcpy_exl(pAdapter
, &pRaCfg
->data
[24], (UCHAR
*)&pAdapter
->WlanCounters
.FCSErrorCount
.u
.LowPart
, 4);
5644 memcpy_exl(pAdapter
, &pRaCfg
->data
[28], (UCHAR
*)&pAdapter
->Counters8023
.RxNoBuffer
, 4);
5645 memcpy_exl(pAdapter
, &pRaCfg
->data
[32], (UCHAR
*)&pAdapter
->WlanCounters
.FrameDuplicateCount
.u
.LowPart
, 4);
5646 memcpy_exl(pAdapter
, &pRaCfg
->data
[36], (UCHAR
*)&pAdapter
->RalinkCounters
.OneSecFalseCCACnt
, 4);
5648 if (pAdapter
->ate
.RxAntennaSel
== 0)
5654 RSSI0
= (INT32
)(pAdapter
->ate
.LastRssi0
- pAdapter
->BbpRssiToDbmDelta
);
5655 RSSI1
= (INT32
)(pAdapter
->ate
.LastRssi1
- pAdapter
->BbpRssiToDbmDelta
);
5656 RSSI2
= (INT32
)(pAdapter
->ate
.LastRssi2
- pAdapter
->BbpRssiToDbmDelta
);
5657 memcpy_exl(pAdapter
, &pRaCfg
->data
[40], (UCHAR
*)&RSSI0
, 4);
5658 memcpy_exl(pAdapter
, &pRaCfg
->data
[44], (UCHAR
*)&RSSI1
, 4);
5659 memcpy_exl(pAdapter
, &pRaCfg
->data
[48], (UCHAR
*)&RSSI2
, 4);
5660 RESPONSE_TO_GUI(pRaCfg
, wrq
, sizeof(pRaCfg
->status
)+52, NDIS_STATUS_SUCCESS
);
5666 RSSI0
= (INT32
)(pAdapter
->ate
.LastRssi0
- pAdapter
->BbpRssiToDbmDelta
);
5667 memcpy_exl(pAdapter
, &pRaCfg
->data
[40], (UCHAR
*)&RSSI0
, 4);
5668 RESPONSE_TO_GUI(pRaCfg
, wrq
, sizeof(pRaCfg
->status
)+44, NDIS_STATUS_SUCCESS
);
5671 return NDIS_STATUS_SUCCESS
;
5675 static inline INT
DO_RACFG_CMD_ATE_RESET_COUNTER(
5676 IN PRTMP_ADAPTER pAdapter
,
5677 IN
struct iwreq
*wrq
,
5678 IN
struct ate_racfghdr
*pRaCfg
)
5681 STRING str
[LEN_OF_ARG
];
5683 NdisZeroMemory(str
, LEN_OF_ARG
);
5685 ATEDBGPRINT(RT_DEBUG_TRACE
,("RACFG_CMD_ATE_RESET_COUNTER\n"));
5687 sprintf((char *)str
, "%d", value
);
5688 Set_ResetStatCounter_Proc(pAdapter
, str
);
5690 pAdapter
->ate
.TxDoneCount
= 0;
5692 RESPONSE_TO_GUI(pRaCfg
, wrq
, sizeof(pRaCfg
->status
), NDIS_STATUS_SUCCESS
);
5694 return NDIS_STATUS_SUCCESS
;
5698 static inline INT
DO_RACFG_CMD_ATE_SEL_TX_ANTENNA(
5699 IN PRTMP_ADAPTER pAdapter
,
5700 IN
struct iwreq
*wrq
,
5701 IN
struct ate_racfghdr
*pRaCfg
)
5704 STRING str
[LEN_OF_ARG
];
5706 NdisZeroMemory(str
, LEN_OF_ARG
);
5708 ATEDBGPRINT(RT_DEBUG_TRACE
,("RACFG_CMD_ATE_SEL_TX_ANTENNA\n"));
5710 memcpy((PUCHAR
)&value
, (PUCHAR
)&(pRaCfg
->status
), 2);
5711 value
= ntohs(value
);
5712 sprintf((char *)str
, "%d", value
);
5713 Set_ATE_TX_Antenna_Proc(pAdapter
, str
);
5715 RESPONSE_TO_GUI(pRaCfg
, wrq
, sizeof(pRaCfg
->status
), NDIS_STATUS_SUCCESS
);
5717 return NDIS_STATUS_SUCCESS
;
5721 static inline INT
DO_RACFG_CMD_ATE_SEL_RX_ANTENNA(
5722 IN PRTMP_ADAPTER pAdapter
,
5723 IN
struct iwreq
*wrq
,
5724 IN
struct ate_racfghdr
*pRaCfg
)
5727 STRING str
[LEN_OF_ARG
];
5729 NdisZeroMemory(str
, LEN_OF_ARG
);
5731 ATEDBGPRINT(RT_DEBUG_TRACE
,("RACFG_CMD_ATE_SEL_RX_ANTENNA\n"));
5733 memcpy((PUCHAR
)&value
, (PUCHAR
)&(pRaCfg
->status
), 2);
5734 value
= ntohs(value
);
5735 sprintf((char *)str
, "%d", value
);
5736 Set_ATE_RX_Antenna_Proc(pAdapter
, str
);
5738 RESPONSE_TO_GUI(pRaCfg
, wrq
, sizeof(pRaCfg
->status
), NDIS_STATUS_SUCCESS
);
5740 return NDIS_STATUS_SUCCESS
;
5744 static inline INT
DO_RACFG_CMD_ATE_SET_PREAMBLE(
5745 IN PRTMP_ADAPTER pAdapter
,
5746 IN
struct iwreq
*wrq
,
5747 IN
struct ate_racfghdr
*pRaCfg
)
5750 STRING str
[LEN_OF_ARG
];
5752 NdisZeroMemory(str
, LEN_OF_ARG
);
5754 ATEDBGPRINT(RT_DEBUG_TRACE
,("RACFG_CMD_ATE_SET_PREAMBLE\n"));
5756 memcpy((PUCHAR
)&value
, (PUCHAR
)&(pRaCfg
->status
), 2);
5757 value
= ntohs(value
);
5758 sprintf((char *)str
, "%d", value
);
5759 Set_ATE_TX_MODE_Proc(pAdapter
, str
);
5761 RESPONSE_TO_GUI(pRaCfg
, wrq
, sizeof(pRaCfg
->status
), NDIS_STATUS_SUCCESS
);
5763 return NDIS_STATUS_SUCCESS
;
5767 static inline INT
DO_RACFG_CMD_ATE_SET_CHANNEL(
5768 IN PRTMP_ADAPTER pAdapter
,
5769 IN
struct iwreq
*wrq
,
5770 IN
struct ate_racfghdr
*pRaCfg
)
5773 STRING str
[LEN_OF_ARG
];
5775 NdisZeroMemory(str
, LEN_OF_ARG
);
5777 ATEDBGPRINT(RT_DEBUG_TRACE
,("RACFG_CMD_ATE_SET_CHANNEL\n"));
5779 memcpy((PUCHAR
)&value
, (PUCHAR
)&(pRaCfg
->status
), 2);
5780 value
= ntohs(value
);
5781 sprintf((char *)str
, "%d", value
);
5782 Set_ATE_CHANNEL_Proc(pAdapter
, str
);
5784 RESPONSE_TO_GUI(pRaCfg
, wrq
, sizeof(pRaCfg
->status
), NDIS_STATUS_SUCCESS
);
5786 return NDIS_STATUS_SUCCESS
;
5790 static inline INT
DO_RACFG_CMD_ATE_SET_ADDR1(
5791 IN PRTMP_ADAPTER pAdapter
,
5792 IN
struct iwreq
*wrq
,
5793 IN
struct ate_racfghdr
*pRaCfg
)
5795 ATEDBGPRINT(RT_DEBUG_TRACE
,("RACFG_CMD_ATE_SET_ADDR1\n"));
5798 Addr is an array of UCHAR,
5799 so no need to perform endian swap.
5801 memcpy(pAdapter
->ate
.Addr1
, (PUCHAR
)(pRaCfg
->data
- 2), MAC_ADDR_LEN
);
5803 RESPONSE_TO_GUI(pRaCfg
, wrq
, sizeof(pRaCfg
->status
), NDIS_STATUS_SUCCESS
);
5805 return NDIS_STATUS_SUCCESS
;
5809 static inline INT
DO_RACFG_CMD_ATE_SET_ADDR2(
5810 IN PRTMP_ADAPTER pAdapter
,
5811 IN
struct iwreq
*wrq
,
5812 IN
struct ate_racfghdr
*pRaCfg
)
5814 ATEDBGPRINT(RT_DEBUG_TRACE
,("RACFG_CMD_ATE_SET_ADDR2\n"));
5817 Addr is an array of UCHAR,
5818 so no need to perform endian swap.
5820 memcpy(pAdapter
->ate
.Addr2
, (PUCHAR
)(pRaCfg
->data
- 2), MAC_ADDR_LEN
);
5822 RESPONSE_TO_GUI(pRaCfg
, wrq
, sizeof(pRaCfg
->status
), NDIS_STATUS_SUCCESS
);
5824 return NDIS_STATUS_SUCCESS
;
5828 static inline INT
DO_RACFG_CMD_ATE_SET_ADDR3(
5829 IN PRTMP_ADAPTER pAdapter
,
5830 IN
struct iwreq
*wrq
,
5831 IN
struct ate_racfghdr
*pRaCfg
)
5833 ATEDBGPRINT(RT_DEBUG_TRACE
,("RACFG_CMD_ATE_SET_ADDR3\n"));
5836 Addr is an array of UCHAR,
5837 so no need to perform endian swap.
5839 memcpy(pAdapter
->ate
.Addr3
, (PUCHAR
)(pRaCfg
->data
- 2), MAC_ADDR_LEN
);
5841 RESPONSE_TO_GUI(pRaCfg
, wrq
, sizeof(pRaCfg
->status
), NDIS_STATUS_SUCCESS
);
5843 return NDIS_STATUS_SUCCESS
;
5847 static inline INT
DO_RACFG_CMD_ATE_SET_RATE(
5848 IN PRTMP_ADAPTER pAdapter
,
5849 IN
struct iwreq
*wrq
,
5850 IN
struct ate_racfghdr
*pRaCfg
)
5853 STRING str
[LEN_OF_ARG
];
5855 NdisZeroMemory(str
, LEN_OF_ARG
);
5857 ATEDBGPRINT(RT_DEBUG_TRACE
,("RACFG_CMD_ATE_SET_RATE\n"));
5859 memcpy((PUCHAR
)&value
, (PUCHAR
)&(pRaCfg
->status
), 2);
5860 value
= ntohs(value
);
5861 sprintf((char *)str
, "%d", value
);
5862 Set_ATE_TX_MCS_Proc(pAdapter
, str
);
5864 RESPONSE_TO_GUI(pRaCfg
, wrq
, sizeof(pRaCfg
->status
), NDIS_STATUS_SUCCESS
);
5866 return NDIS_STATUS_SUCCESS
;
5870 static inline INT
DO_RACFG_CMD_ATE_SET_TX_FRAME_LEN(
5871 IN PRTMP_ADAPTER pAdapter
,
5872 IN
struct iwreq
*wrq
,
5873 IN
struct ate_racfghdr
*pRaCfg
)
5876 STRING str
[LEN_OF_ARG
];
5878 NdisZeroMemory(str
, LEN_OF_ARG
);
5880 ATEDBGPRINT(RT_DEBUG_TRACE
,("RACFG_CMD_ATE_SET_TX_FRAME_LEN\n"));
5882 memcpy((PUCHAR
)&value
, (PUCHAR
)&(pRaCfg
->status
), 2);
5883 value
= ntohs(value
);
5884 sprintf((char *)str
, "%d", value
);
5885 Set_ATE_TX_LENGTH_Proc(pAdapter
, str
);
5887 RESPONSE_TO_GUI(pRaCfg
, wrq
, sizeof(pRaCfg
->status
), NDIS_STATUS_SUCCESS
);
5889 return NDIS_STATUS_SUCCESS
;
5893 static inline INT
DO_RACFG_CMD_ATE_SET_TX_FRAME_COUNT(
5894 IN PRTMP_ADAPTER pAdapter
,
5895 IN
struct iwreq
*wrq
,
5896 IN
struct ate_racfghdr
*pRaCfg
)
5899 STRING str
[LEN_OF_ARG
];
5901 NdisZeroMemory(str
, LEN_OF_ARG
);
5903 ATEDBGPRINT(RT_DEBUG_TRACE
,("RACFG_CMD_ATE_SET_TX_FRAME_COUNT\n"));
5905 memcpy((PUCHAR
)&value
, (PUCHAR
)&(pRaCfg
->status
), 2);
5906 value
= ntohs(value
);
5909 /* TX_FRAME_COUNT == 0 means tx infinitely */
5912 /* Use TxCount = 0xFFFFFFFF to approximate the infinity. */
5913 pAdapter
->ate
.TxCount
= 0xFFFFFFFF;
5914 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Set_ATE_TX_COUNT_Proc (TxCount = %d)\n", pAdapter
->ate
.TxCount
));
5915 ATEDBGPRINT(RT_DEBUG_TRACE
, ("Ralink: Set_ATE_TX_COUNT_Proc Success\n"));
5920 #endif // RTMP_MAC_PCI //
5922 sprintf((char *)str
, "%d", value
);
5923 Set_ATE_TX_COUNT_Proc(pAdapter
, str
);
5926 RESPONSE_TO_GUI(pRaCfg
, wrq
, sizeof(pRaCfg
->status
), NDIS_STATUS_SUCCESS
);
5928 return NDIS_STATUS_SUCCESS
;
5932 static inline INT
DO_RACFG_CMD_ATE_START_RX_FRAME(
5933 IN PRTMP_ADAPTER pAdapter
,
5934 IN
struct iwreq
*wrq
,
5935 IN
struct ate_racfghdr
*pRaCfg
)
5937 ATEDBGPRINT(RT_DEBUG_TRACE
,("RACFG_CMD_RX_START\n"));
5939 Set_ATE_Proc(pAdapter
, "RXFRAME");
5941 RESPONSE_TO_GUI(pRaCfg
, wrq
, sizeof(pRaCfg
->status
), NDIS_STATUS_SUCCESS
);
5943 return NDIS_STATUS_SUCCESS
;
5947 static inline INT
DO_RACFG_CMD_ATE_E2PROM_READ_BULK(
5948 IN PRTMP_ADAPTER pAdapter
,
5949 IN
struct iwreq
*wrq
,
5950 IN
struct ate_racfghdr
*pRaCfg
)
5954 USHORT buffer
[EEPROM_SIZE
/2];
5956 offset
= ntohs(pRaCfg
->status
);
5957 memcpy(&len
, pRaCfg
->data
, 2);
5960 rt_ee_read_all(pAdapter
, (USHORT
*)buffer
);
5962 if (offset
+ len
<= EEPROM_SIZE
)
5963 memcpy_exs(pAdapter
, pRaCfg
->data
, (UCHAR
*)buffer
+offset
, len
);
5965 ATEDBGPRINT(RT_DEBUG_ERROR
, ("exceed EEPROM size\n"));
5967 RESPONSE_TO_GUI(pRaCfg
, wrq
, sizeof(pRaCfg
->status
)+len
, NDIS_STATUS_SUCCESS
);
5969 return NDIS_STATUS_SUCCESS
;
5973 static inline INT
DO_RACFG_CMD_ATE_E2PROM_WRITE_BULK(
5974 IN PRTMP_ADAPTER pAdapter
,
5975 IN
struct iwreq
*wrq
,
5976 IN
struct ate_racfghdr
*pRaCfg
)
5980 USHORT buffer
[EEPROM_SIZE
/2];
5982 offset
= ntohs(pRaCfg
->status
);
5983 memcpy(&len
, pRaCfg
->data
, 2);
5986 rt_ee_read_all(pAdapter
,(USHORT
*)buffer
);
5987 memcpy_exs(pAdapter
, (UCHAR
*)buffer
+ offset
, (UCHAR
*)pRaCfg
->data
+ 2, len
);
5988 rt_ee_write_all(pAdapter
,(USHORT
*)buffer
);
5990 RESPONSE_TO_GUI(pRaCfg
, wrq
, sizeof(pRaCfg
->status
), NDIS_STATUS_SUCCESS
);
5992 return NDIS_STATUS_SUCCESS
;
5996 static inline INT
DO_RACFG_CMD_ATE_IO_WRITE_BULK(
5997 IN PRTMP_ADAPTER pAdapter
,
5998 IN
struct iwreq
*wrq
,
5999 IN
struct ate_racfghdr
*pRaCfg
)
6001 UINT32 offset
, i
, value
;
6004 memcpy(&offset
, &pRaCfg
->status
, 4);
6005 offset
= ntohl(offset
);
6006 memcpy(&len
, pRaCfg
->data
+2, 2);
6009 for (i
= 0; i
< len
; i
+= 4)
6011 memcpy_exl(pAdapter
, (UCHAR
*)&value
, pRaCfg
->data
+4+i
, 4);
6012 ATEDBGPRINT(RT_DEBUG_TRACE
,("Write %x %x\n", offset
+ i
, value
));
6013 RTMP_IO_WRITE32(pAdapter
, ((offset
+i
) & (0xffff)), value
);
6016 RESPONSE_TO_GUI(pRaCfg
, wrq
, sizeof(pRaCfg
->status
), NDIS_STATUS_SUCCESS
);
6018 return NDIS_STATUS_SUCCESS
;
6022 static inline INT
DO_RACFG_CMD_ATE_BBP_READ_BULK(
6023 IN PRTMP_ADAPTER pAdapter
,
6024 IN
struct iwreq
*wrq
,
6025 IN
struct ate_racfghdr
*pRaCfg
)
6031 offset
= ntohs(pRaCfg
->status
);
6032 memcpy(&len
, pRaCfg
->data
, 2);
6035 for (j
= offset
; j
< (offset
+len
); j
++)
6037 pRaCfg
->data
[j
- offset
] = 0;
6039 if (pAdapter
->ate
.Mode
== ATE_STOP
)
6041 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter
, j
, &pRaCfg
->data
[j
- offset
]);
6045 ATE_BBP_IO_READ8_BY_REG_ID(pAdapter
, j
, &pRaCfg
->data
[j
- offset
]);
6049 RESPONSE_TO_GUI(pRaCfg
, wrq
, sizeof(pRaCfg
->status
)+len
, NDIS_STATUS_SUCCESS
);
6051 return NDIS_STATUS_SUCCESS
;
6055 static inline INT
DO_RACFG_CMD_ATE_BBP_WRITE_BULK(
6056 IN PRTMP_ADAPTER pAdapter
,
6057 IN
struct iwreq
*wrq
,
6058 IN
struct ate_racfghdr
*pRaCfg
)
6065 offset
= ntohs(pRaCfg
->status
);
6066 memcpy(&len
, pRaCfg
->data
, 2);
6069 for (j
= offset
; j
< (offset
+len
); j
++)
6071 value
= pRaCfg
->data
+ 2 + (j
- offset
);
6072 if (pAdapter
->ate
.Mode
== ATE_STOP
)
6074 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter
, j
, *value
);
6078 ATE_BBP_IO_WRITE8_BY_REG_ID(pAdapter
, j
, *value
);
6082 RESPONSE_TO_GUI(pRaCfg
, wrq
, sizeof(pRaCfg
->status
), NDIS_STATUS_SUCCESS
);
6084 return NDIS_STATUS_SUCCESS
;
6088 #endif // RALINK_28xx_QA //
6089 #endif // RALINK_ATE //