xref: /OK3568_Linux_fs/kernel/drivers/net/wireless/rockchip_wlan/rtl8189es/include/rtw_mp.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /******************************************************************************
2  *
3  * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of version 2 of the GNU General Public License as
7  * published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12  * more details.
13  *
14  * You should have received a copy of the GNU General Public License along with
15  * this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
17  *
18  *
19  ******************************************************************************/
20 #ifndef _RTW_MP_H_
21 #define _RTW_MP_H_
22 
23 #define RTWPRIV_VER_INFO	1
24 
25 #define MAX_MP_XMITBUF_SZ 	2048
26 #define NR_MP_XMITFRAME		8
27 
28 struct mp_xmit_frame
29 {
30 	_list	list;
31 
32 	struct pkt_attrib attrib;
33 
34 	_pkt *pkt;
35 
36 	int frame_tag;
37 
38 	_adapter *padapter;
39 
40 #ifdef CONFIG_USB_HCI
41 
42 	//insert urb, irp, and irpcnt info below...
43 	//max frag_cnt = 8
44 
45 	u8 *mem_addr;
46 	u32 sz[8];
47 
48 #if defined(PLATFORM_OS_XP) || defined(PLATFORM_LINUX)
49 	PURB pxmit_urb[8];
50 #endif
51 
52 #ifdef PLATFORM_OS_XP
53 	PIRP pxmit_irp[8];
54 #endif
55 
56 	u8 bpending[8];
57 	sint ac_tag[8];
58 	sint last[8];
59 	uint irpcnt;
60 	uint fragcnt;
61 #endif /* CONFIG_USB_HCI */
62 
63 	uint mem[(MAX_MP_XMITBUF_SZ >> 2)];
64 };
65 
66 struct mp_wiparam
67 {
68 	u32 bcompleted;
69 	u32 act_type;
70 	u32 io_offset;
71 	u32 io_value;
72 };
73 
74 typedef void(*wi_act_func)(void* padapter);
75 
76 #ifdef PLATFORM_WINDOWS
77 struct mp_wi_cntx
78 {
79 	u8 bmpdrv_unload;
80 
81 	// Work Item
82 	NDIS_WORK_ITEM mp_wi;
83 	NDIS_EVENT mp_wi_evt;
84 	_lock mp_wi_lock;
85 	u8 bmp_wi_progress;
86 	wi_act_func curractfunc;
87 	// Variable needed in each implementation of CurrActFunc.
88 	struct mp_wiparam param;
89 };
90 #endif
91 
92 struct mp_tx
93 {
94 	u8 stop;
95 	u32 count, sended;
96 	u8 payload;
97 	struct pkt_attrib attrib;
98 	//struct tx_desc desc;
99 	//u8 resvdtx[7];
100 	u8 desc[TXDESC_SIZE];
101 	u8 *pallocated_buf;
102 	u8 *buf;
103 	u32 buf_size, write_size;
104 	_thread_hdl_ PktTxThread;
105 };
106 
107 #define MP_MAX_LINES		1000
108 #define MP_MAX_LINES_BYTES	256
109 #define u1Byte u8
110 #define s1Byte s8
111 #define u4Byte u32
112 #define s4Byte s32
113 #define u1Byte		u8
114 #define pu1Byte 		u8*
115 
116 #define u2Byte		u16
117 #define pu2Byte 		u16*
118 
119 #define u4Byte		u32
120 #define pu4Byte 		u32*
121 
122 #define u8Byte		u64
123 #define pu8Byte 		u64*
124 
125 #define s1Byte		s8
126 #define ps1Byte 		s8*
127 
128 #define s2Byte		s16
129 #define ps2Byte 		s16*
130 
131 #define s4Byte		s32
132 #define ps4Byte 		s32*
133 
134 #define s8Byte		s64
135 #define ps8Byte 		s64*
136 
137 #define UCHAR u8
138 #define USHORT u16
139 #define UINT u32
140 #define ULONG u32
141 #define PULONG u32*
142 
143 
144 
145 typedef VOID (*MPT_WORK_ITEM_HANDLER)(IN PVOID Adapter);
146 typedef struct _MPT_CONTEXT
147 {
148 	// Indicate if we have started Mass Production Test.
149 	BOOLEAN			bMassProdTest;
150 
151 	// Indicate if the driver is unloading or unloaded.
152 	BOOLEAN			bMptDrvUnload;
153 
154 	_sema			MPh2c_Sema;
155 	_timer			MPh2c_timeout_timer;
156 // Event used to sync H2c for BT control
157 
158 	BOOLEAN		MptH2cRspEvent;
159 	BOOLEAN		MptBtC2hEvent;
160 	BOOLEAN		bMPh2c_timeout;
161 
162 	/* 8190 PCI does not support NDIS_WORK_ITEM. */
163 	// Work Item for Mass Production Test.
164 	//NDIS_WORK_ITEM	MptWorkItem;
165 //	RT_WORK_ITEM		MptWorkItem;
166 	// Event used to sync the case unloading driver and MptWorkItem is still in progress.
167 //	NDIS_EVENT		MptWorkItemEvent;
168 	// To protect the following variables.
169 //	NDIS_SPIN_LOCK		MptWorkItemSpinLock;
170 	// Indicate a MptWorkItem is scheduled and not yet finished.
171 	BOOLEAN			bMptWorkItemInProgress;
172 	// An instance which implements function and context of MptWorkItem.
173 	MPT_WORK_ITEM_HANDLER	CurrMptAct;
174 
175 	// 1=Start, 0=Stop from UI.
176 	ULONG			MptTestStart;
177 	// _TEST_MODE, defined in MPT_Req2.h
178 	ULONG			MptTestItem;
179 	// Variable needed in each implementation of CurrMptAct.
180 	ULONG			MptActType; 	// Type of action performed in CurrMptAct.
181 	// The Offset of IO operation is depend of MptActType.
182 	ULONG			MptIoOffset;
183 	// The Value of IO operation is depend of MptActType.
184 	ULONG			MptIoValue;
185 	// The RfPath of IO operation is depend of MptActType.
186 	ULONG			MptRfPath;
187 
188 	WIRELESS_MODE		MptWirelessModeToSw;	// Wireless mode to switch.
189 	u8			MptChannelToSw; 	// Channel to switch.
190 	u8			MptInitGainToSet; 	// Initial gain to set.
191 	//ULONG			bMptAntennaA; 		// TRUE if we want to use antenna A.
192 	ULONG			MptBandWidth;		// bandwidth to switch.
193 	ULONG			MptRateIndex;		// rate index.
194 	// Register value kept for Single Carrier Tx test.
195 	u8			btMpCckTxPower;
196 	// Register value kept for Single Carrier Tx test.
197 	u8			btMpOfdmTxPower;
198 	// For MP Tx Power index
199 	u8			TxPwrLevel[4];	/* rf-A, rf-B*/
200 	u32			RegTxPwrLimit;
201 	// Content of RCR Regsiter for Mass Production Test.
202 	ULONG			MptRCR;
203 	// TRUE if we only receive packets with specific pattern.
204 	BOOLEAN			bMptFilterPattern;
205  	// Rx OK count, statistics used in Mass Production Test.
206  	ULONG			MptRxOkCnt;
207  	// Rx CRC32 error count, statistics used in Mass Production Test.
208  	ULONG			MptRxCrcErrCnt;
209 
210 	BOOLEAN			bCckContTx;	// TRUE if we are in CCK Continuous Tx test.
211  	BOOLEAN			bOfdmContTx;	// TRUE if we are in OFDM Continuous Tx test.
212 	BOOLEAN			bStartContTx; 	// TRUE if we have start Continuous Tx test.
213 	// TRUE if we are in Single Carrier Tx test.
214 	BOOLEAN			bSingleCarrier;
215 	// TRUE if we are in Carrier Suppression Tx Test.
216 	BOOLEAN			bCarrierSuppression;
217 	//TRUE if we are in Single Tone Tx test.
218 	BOOLEAN			bSingleTone;
219 
220 	// ACK counter asked by K.Y..
221 	BOOLEAN			bMptEnableAckCounter;
222 	ULONG			MptAckCounter;
223 
224 	// SD3 Willis For 8192S to save 1T/2T RF table for ACUT	Only fro ACUT delete later ~~~!
225 	//s1Byte		BufOfLines[2][MAX_LINES_HWCONFIG_TXT][MAX_BYTES_LINE_HWCONFIG_TXT];
226 	//s1Byte			BufOfLines[2][MP_MAX_LINES][MP_MAX_LINES_BYTES];
227 	//s4Byte			RfReadLine[2];
228 
229 	u8		APK_bound[2];	//for APK	path A/path B
230 	BOOLEAN		bMptIndexEven;
231 
232 	u8		backup0xc50;
233 	u8		backup0xc58;
234 	u8		backup0xc30;
235 	u8 		backup0x52_RF_A;
236 	u8 		backup0x52_RF_B;
237 
238 	u4Byte			backup0x58_RF_A;
239 	u4Byte			backup0x58_RF_B;
240 
241 	u1Byte			h2cReqNum;
242 	u1Byte			c2hBuf[32];
243 
244     u1Byte          btInBuf[100];
245 	ULONG			mptOutLen;
246     u1Byte          mptOutBuf[100];
247 
248 }MPT_CONTEXT, *PMPT_CONTEXT;
249 //#endif
250 
251 /* E-Fuse */
252 #ifdef CONFIG_RTL8188E
253 #define EFUSE_MAP_SIZE		512
254 #endif
255 #if defined(CONFIG_RTL8812A) || defined(CONFIG_RTL8821A) || defined(CONFIG_RTL8814A)
256 #define EFUSE_MAP_SIZE		512
257 #endif
258 #ifdef CONFIG_RTL8192E
259 #define EFUSE_MAP_SIZE		512
260 #endif
261 #ifdef CONFIG_RTL8723B
262 #define EFUSE_MAP_SIZE		512
263 #endif
264 #ifdef CONFIG_RTL8814A
265 #define EFUSE_MAP_SIZE		512
266 #endif
267 #ifdef CONFIG_RTL8703B
268 #define EFUSE_MAP_SIZE		512
269 #endif
270 #ifdef CONFIG_RTL8188F
271 #define EFUSE_MAP_SIZE		512
272 #endif
273 
274 #if defined(CONFIG_RTL8814A)
275 #define EFUSE_MAX_SIZE		1024
276 #elif defined(CONFIG_RTL8188E) || defined(CONFIG_RTL8188F)
277 #define EFUSE_MAX_SIZE		256
278 #else
279 #define EFUSE_MAX_SIZE		512
280 #endif
281 /* end of E-Fuse */
282 
283 //#define RTPRIV_IOCTL_MP 					( SIOCIWFIRSTPRIV + 0x17)
284 enum {
285 	WRITE_REG = 1,
286 	READ_REG,
287 	WRITE_RF,
288 	READ_RF,
289 	MP_START,
290 	MP_STOP,
291 	MP_RATE,
292 	MP_CHANNEL,
293 	MP_BANDWIDTH,
294 	MP_TXPOWER,
295 	MP_ANT_TX,
296 	MP_ANT_RX,
297 	MP_CTX,
298 	MP_QUERY,
299 	MP_ARX,
300 	MP_PSD,
301 	MP_PWRTRK,
302 	MP_THER,
303 	MP_IOCTL,
304 	EFUSE_GET,
305 	EFUSE_SET,
306 	MP_RESET_STATS,
307 	MP_DUMP,
308 	MP_PHYPARA,
309 	MP_SetRFPathSwh,
310 	MP_QueryDrvStats,
311 	CTA_TEST,
312 	MP_DISABLE_BT_COEXIST,
313 	MP_PwrCtlDM,
314 	MP_GETVER,
315 	MP_MON,
316 	EFUSE_MASK,
317 	EFUSE_FILE,
318 	MP_TX,
319 	MP_RX,
320 	MP_HW_TX_MODE,
321 	MP_GET_TXPOWER_INX,
322 	MP_NULL,
323 	MP_SetBT,
324 #ifdef CONFIG_WOWLAN
325 	MP_WOW_ENABLE,
326 	MP_WOW_SET_PATTERN,
327 #endif
328 #ifdef CONFIG_AP_WOWLAN
329 	MP_AP_WOW_ENABLE,
330 #endif
331 	MP_SD_IREAD,
332 	MP_SD_IWRITE,
333 };
334 
335 struct mp_priv
336 {
337 	_adapter *papdater;
338 
339 	//Testing Flag
340 	u32 mode;//0 for normal type packet, 1 for loopback packet (16bytes TXCMD)
341 
342 	u32 prev_fw_state;
343 
344 	//OID cmd handler
345 	struct mp_wiparam workparam;
346 //	u8 act_in_progress;
347 
348 	//Tx Section
349 	u8 TID;
350 	u32 tx_pktcount;
351 	u32 pktInterval;
352 	struct mp_tx tx;
353 
354 	//Rx Section
355 	u32 rx_bssidpktcount;
356 	u32 rx_pktcount;
357 	u32 rx_pktcount_filter_out;
358 	u32 rx_crcerrpktcount;
359 	u32 rx_pktloss;
360 	BOOLEAN  rx_bindicatePkt;
361 	struct recv_stat rxstat;
362 
363 	//RF/BB relative
364 	u8 channel;
365 	u8 bandwidth;
366 	u8 prime_channel_offset;
367 	u8 txpoweridx;
368 	u8 rateidx;
369 	u32 preamble;
370 //	u8 modem;
371 	u32 CrystalCap;
372 //	u32 curr_crystalcap;
373 
374 	u16 antenna_tx;
375 	u16 antenna_rx;
376 //	u8 curr_rfpath;
377 
378 	u8 check_mp_pkt;
379 
380 	u8 bSetTxPower;
381 //	uint ForcedDataRate;
382 	u8 mp_dm;
383 	u8 mac_filter[ETH_ALEN];
384 	u8 bmac_filter;
385 
386 	struct wlan_network mp_network;
387 	NDIS_802_11_MAC_ADDRESS network_macaddr;
388 
389 #ifdef PLATFORM_WINDOWS
390 	u32 rx_testcnt;
391 	u32 rx_testcnt1;
392 	u32 rx_testcnt2;
393 	u32 tx_testcnt;
394 	u32 tx_testcnt1;
395 
396 	struct mp_wi_cntx wi_cntx;
397 
398 	u8 h2c_result;
399 	u8 h2c_seqnum;
400 	u16 h2c_cmdcode;
401 	u8 h2c_resp_parambuf[512];
402 	_lock h2c_lock;
403 	_lock wkitm_lock;
404 	u32 h2c_cmdcnt;
405 	NDIS_EVENT h2c_cmd_evt;
406 	NDIS_EVENT c2h_set;
407 	NDIS_EVENT h2c_clr;
408 	NDIS_EVENT cpwm_int;
409 
410 	NDIS_EVENT scsir_full_evt;
411 	NDIS_EVENT scsiw_empty_evt;
412 #endif
413 
414 	u8 *pallocated_mp_xmitframe_buf;
415 	u8 *pmp_xmtframe_buf;
416 	_queue free_mp_xmitqueue;
417 	u32 free_mp_xmitframe_cnt;
418 	BOOLEAN bSetRxBssid;
419 	BOOLEAN bTxBufCkFail;
420 	BOOLEAN bRTWSmbCfg;
421 	MPT_CONTEXT MptCtx;
422 
423 	u8		*TXradomBuffer;
424 };
425 
426 typedef struct _IOCMD_STRUCT_ {
427 	u8	cmdclass;
428 	u16	value;
429 	u8	index;
430 }IOCMD_STRUCT;
431 
432 struct rf_reg_param {
433 	u32 path;
434 	u32 offset;
435 	u32 value;
436 };
437 
438 struct bb_reg_param {
439 	u32 offset;
440 	u32 value;
441 };
442 
443 typedef struct _MP_FIRMWARE {
444 	FIRMWARE_SOURCE eFWSource;
445 #ifdef CONFIG_EMBEDDED_FWIMG
446 	u8* 		szFwBuffer;
447 #else
448 	u8			szFwBuffer[0x8000];
449 #endif
450 	u32 		ulFwLength;
451 } RT_MP_FIRMWARE, *PRT_MP_FIRMWARE;
452 
453 
454 
455 
456 //=======================================================================
457 
458 #define LOWER 	_TRUE
459 #define RAISE	_FALSE
460 
461 /* Hardware Registers */
462 #if 0
463 #if 0
464 #define IOCMD_CTRL_REG			0x102502C0
465 #define IOCMD_DATA_REG			0x102502C4
466 #else
467 #define IOCMD_CTRL_REG			0x10250370
468 #define IOCMD_DATA_REG			0x10250374
469 #endif
470 
471 #define IOCMD_GET_THERMAL_METER		0xFD000028
472 
473 #define IOCMD_CLASS_BB_RF		0xF0
474 #define IOCMD_BB_READ_IDX		0x00
475 #define IOCMD_BB_WRITE_IDX		0x01
476 #define IOCMD_RF_READ_IDX		0x02
477 #define IOCMD_RF_WRIT_IDX		0x03
478 #endif
479 #define BB_REG_BASE_ADDR		0x800
480 
481 /* MP variables */
482 #if 0
483 #define _2MAC_MODE_	0
484 #define _LOOPBOOK_MODE_	1
485 #endif
486 typedef enum _MP_MODE_ {
487 	MP_OFF,
488 	MP_ON,
489 	MP_ERR,
490 	MP_CONTINUOUS_TX,
491 	MP_SINGLE_CARRIER_TX,
492 	MP_CARRIER_SUPPRISSION_TX,
493 	MP_SINGLE_TONE_TX,
494 	MP_PACKET_TX,
495 	MP_PACKET_RX
496 } MP_MODE;
497 
498 typedef enum _MPT_BANDWIDTH {
499 	MPT_BW_20MHZ = 0,
500 	MPT_BW_40MHZ_DUPLICATE = 1,
501 	MPT_BW_40MHZ_ABOVE = 2,
502 	MPT_BW_40MHZ_BELOW = 3,
503 	MPT_BW_40MHZ = 4,
504 	MPT_BW_80MHZ = 5,
505 	MPT_BW_80MHZ_20_ABOVE = 6,
506 	MPT_BW_80MHZ_20_BELOW = 7,
507 	MPT_BW_80MHZ_20_BOTTOM = 8,
508 	MPT_BW_80MHZ_20_TOP = 9,
509 	MPT_BW_80MHZ_40_ABOVE = 10,
510 	MPT_BW_80MHZ_40_BELOW = 11,
511 } MPT_BANDWIDTHE, *PMPT_BANDWIDTH;
512 
513 #define MAX_RF_PATH_NUMS	RF_PATH_MAX
514 
515 
516 extern u8 mpdatarate[NumRates];
517 
518 /* MP set force data rate base on the definition. */
519 typedef enum _MPT_RATE_INDEX
520 {
521 	/* CCK rate. */
522 	MPT_RATE_1M =0 ,	/* 0 */
523 	MPT_RATE_2M,
524 	MPT_RATE_55M,
525 	MPT_RATE_11M,	/* 3 */
526 
527 	/* OFDM rate. */
528 	MPT_RATE_6M,	/* 4 */
529 	MPT_RATE_9M,
530 	MPT_RATE_12M,
531 	MPT_RATE_18M,
532 	MPT_RATE_24M,
533 	MPT_RATE_36M,
534 	MPT_RATE_48M,
535 	MPT_RATE_54M,	/* 11 */
536 
537 	/* HT rate. */
538 	MPT_RATE_MCS0,	/* 12 */
539 	MPT_RATE_MCS1,
540 	MPT_RATE_MCS2,
541 	MPT_RATE_MCS3,
542 	MPT_RATE_MCS4,
543 	MPT_RATE_MCS5,
544 	MPT_RATE_MCS6,
545 	MPT_RATE_MCS7,	/* 19 */
546 	MPT_RATE_MCS8,
547 	MPT_RATE_MCS9,
548 	MPT_RATE_MCS10,
549 	MPT_RATE_MCS11,
550 	MPT_RATE_MCS12,
551 	MPT_RATE_MCS13,
552 	MPT_RATE_MCS14,
553 	MPT_RATE_MCS15,	/* 27 */
554 	MPT_RATE_MCS16,
555 	MPT_RATE_MCS17, // #29
556 	MPT_RATE_MCS18,
557 	MPT_RATE_MCS19,
558 	MPT_RATE_MCS20,
559 	MPT_RATE_MCS21,
560 	MPT_RATE_MCS22, // #34
561 	MPT_RATE_MCS23,
562 	MPT_RATE_MCS24,
563 	MPT_RATE_MCS25,
564 	MPT_RATE_MCS26,
565 	MPT_RATE_MCS27, // #39
566 	MPT_RATE_MCS28, // #40
567 	MPT_RATE_MCS29, // #41
568 	MPT_RATE_MCS30, // #42
569 	MPT_RATE_MCS31, // #43
570 	/* VHT rate. Total: 20*/
571 	MPT_RATE_VHT1SS_MCS0,//  #44
572 	MPT_RATE_VHT1SS_MCS1, // #
573 	MPT_RATE_VHT1SS_MCS2,
574 	MPT_RATE_VHT1SS_MCS3,
575 	MPT_RATE_VHT1SS_MCS4,
576 	MPT_RATE_VHT1SS_MCS5,
577 	MPT_RATE_VHT1SS_MCS6, // #
578 	MPT_RATE_VHT1SS_MCS7,
579 	MPT_RATE_VHT1SS_MCS8,
580 	MPT_RATE_VHT1SS_MCS9, //#53
581 	MPT_RATE_VHT2SS_MCS0, //#54
582 	MPT_RATE_VHT2SS_MCS1,
583 	MPT_RATE_VHT2SS_MCS2,
584 	MPT_RATE_VHT2SS_MCS3,
585 	MPT_RATE_VHT2SS_MCS4,
586 	MPT_RATE_VHT2SS_MCS5,
587 	MPT_RATE_VHT2SS_MCS6,
588 	MPT_RATE_VHT2SS_MCS7,
589 	MPT_RATE_VHT2SS_MCS8,
590 	MPT_RATE_VHT2SS_MCS9, //#63
591 	MPT_RATE_VHT3SS_MCS0,
592 	MPT_RATE_VHT3SS_MCS1,
593 	MPT_RATE_VHT3SS_MCS2,
594 	MPT_RATE_VHT3SS_MCS3,
595 	MPT_RATE_VHT3SS_MCS4,
596 	MPT_RATE_VHT3SS_MCS5,
597 	MPT_RATE_VHT3SS_MCS6, // #126
598 	MPT_RATE_VHT3SS_MCS7,
599 	MPT_RATE_VHT3SS_MCS8,
600 	MPT_RATE_VHT3SS_MCS9,
601 	MPT_RATE_VHT4SS_MCS0,
602 	MPT_RATE_VHT4SS_MCS1, // #131
603 	MPT_RATE_VHT4SS_MCS2,
604 	MPT_RATE_VHT4SS_MCS3,
605 	MPT_RATE_VHT4SS_MCS4,
606 	MPT_RATE_VHT4SS_MCS5,
607 	MPT_RATE_VHT4SS_MCS6, // #136
608 	MPT_RATE_VHT4SS_MCS7,
609 	MPT_RATE_VHT4SS_MCS8,
610 	MPT_RATE_VHT4SS_MCS9,
611 	MPT_RATE_LAST
612 }MPT_RATE_E, *PMPT_RATE_E;
613 
614 #define MAX_TX_PWR_INDEX_N_MODE 64	// 0x3F
615 
616 typedef enum _POWER_MODE_ {
617 	POWER_LOW = 0,
618 	POWER_NORMAL
619 }POWER_MODE;
620 
621 // The following enumeration is used to define the value of Reg0xD00[30:28] or JaguarReg0x914[18:16].
622 typedef enum _OFDM_TX_MODE {
623 	OFDM_ALL_OFF		= 0,
624 	OFDM_ContinuousTx	= 1,
625 	OFDM_SingleCarrier	= 2,
626 	OFDM_SingleTone 	= 4,
627 } OFDM_TX_MODE;
628 
629 
630 #define RX_PKT_BROADCAST	1
631 #define RX_PKT_DEST_ADDR	2
632 #define RX_PKT_PHY_MATCH	3
633 
634 #define Mac_OFDM_OK 			0x00000000
635 #define Mac_OFDM_Fail			0x10000000
636 #define Mac_OFDM_FasleAlarm 	0x20000000
637 #define Mac_CCK_OK				0x30000000
638 #define Mac_CCK_Fail			0x40000000
639 #define Mac_CCK_FasleAlarm		0x50000000
640 #define Mac_HT_OK				0x60000000
641 #define Mac_HT_Fail 			0x70000000
642 #define Mac_HT_FasleAlarm		0x90000000
643 #define Mac_DropPacket			0xA0000000
644 
645 typedef enum _ENCRY_CTRL_STATE_ {
646 	HW_CONTROL,		//hw encryption& decryption
647 	SW_CONTROL,		//sw encryption& decryption
648 	HW_ENCRY_SW_DECRY,	//hw encryption & sw decryption
649 	SW_ENCRY_HW_DECRY	//sw encryption & hw decryption
650 }ENCRY_CTRL_STATE;
651 
652 typedef enum	_MPT_TXPWR_DEF{
653 	MPT_CCK,
654 	MPT_OFDM, // L and HT OFDM
655 	MPT_OFDM_AND_HT,
656 	MPT_HT,
657 	MPT_VHT
658 }MPT_TXPWR_DEF;
659 
660 #ifdef CONFIG_RF_GAIN_OFFSET
661 
662 #if defined(CONFIG_RTL8723B)
663 	#define 	REG_RF_BB_GAIN_OFFSET	0x7f
664 	#define 	RF_GAIN_OFFSET_MASK 	0xfffff
665 #elif defined(CONFIG_RTL8188E)
666 	#define 	REG_RF_BB_GAIN_OFFSET	0x55
667 	#define 	RF_GAIN_OFFSET_MASK 	0xfffff
668 #else
669 	#define 	REG_RF_BB_GAIN_OFFSET	0x55
670 	#define 	RF_GAIN_OFFSET_MASK 	0xfffff
671 #endif	//CONFIG_RTL8723B
672 
673 #endif //CONFIG_RF_GAIN_OFFSET
674 
675 //=======================================================================
676 //extern struct mp_xmit_frame *alloc_mp_xmitframe(struct mp_priv *pmp_priv);
677 //extern int free_mp_xmitframe(struct xmit_priv *pxmitpriv, struct mp_xmit_frame *pmp_xmitframe);
678 
679 extern s32 init_mp_priv(PADAPTER padapter);
680 extern void free_mp_priv(struct mp_priv *pmp_priv);
681 extern s32 MPT_InitializeAdapter(PADAPTER padapter, u8 Channel);
682 extern void MPT_DeInitAdapter(PADAPTER padapter);
683 extern s32 mp_start_test(PADAPTER padapter);
684 extern void mp_stop_test(PADAPTER padapter);
685 
686 extern u32 _read_rfreg(PADAPTER padapter, u8 rfpath, u32 addr, u32 bitmask);
687 extern void _write_rfreg(PADAPTER padapter, u8 rfpath, u32 addr, u32 bitmask, u32 val);
688 
689 extern u32 read_macreg(_adapter *padapter, u32 addr, u32 sz);
690 extern void write_macreg(_adapter *padapter, u32 addr, u32 val, u32 sz);
691 extern u32 read_bbreg(_adapter *padapter, u32 addr, u32 bitmask);
692 extern void write_bbreg(_adapter *padapter, u32 addr, u32 bitmask, u32 val);
693 extern u32 read_rfreg(PADAPTER padapter, u8 rfpath, u32 addr);
694 extern void write_rfreg(PADAPTER padapter, u8 rfpath, u32 addr, u32 val);
695 
696 void	SetChannel(PADAPTER pAdapter);
697 void	SetBandwidth(PADAPTER pAdapter);
698 int	SetTxPower(PADAPTER pAdapter);
699 void	SetAntenna(PADAPTER pAdapter);
700 void	SetDataRate(PADAPTER pAdapter);
701 void	SetAntenna(PADAPTER pAdapter);
702 s32	SetThermalMeter(PADAPTER pAdapter, u8 target_ther);
703 void	GetThermalMeter(PADAPTER pAdapter, u8 *value);
704 void	SetContinuousTx(PADAPTER pAdapter, u8 bStart);
705 void	SetSingleCarrierTx(PADAPTER pAdapter, u8 bStart);
706 void	SetSingleToneTx(PADAPTER pAdapter, u8 bStart);
707 void	SetCarrierSuppressionTx(PADAPTER pAdapter, u8 bStart);
708 void	PhySetTxPowerLevel(PADAPTER pAdapter);
709 void	fill_txdesc_for_mp(PADAPTER padapter, u8 *ptxdesc);
710 void	SetPacketTx(PADAPTER padapter);
711 void	SetPacketRx(PADAPTER pAdapter, u8 bStartRx, u8 bAB);
712 void	ResetPhyRxPktCount(PADAPTER pAdapter);
713 u32	GetPhyRxPktReceived(PADAPTER pAdapter);
714 u32	GetPhyRxPktCRC32Error(PADAPTER pAdapter);
715 s32	SetPowerTracking(PADAPTER padapter, u8 enable);
716 void	GetPowerTracking(PADAPTER padapter, u8 *enable);
717 u32	mp_query_psd(PADAPTER pAdapter, u8 *data);
718 
719 
720 
721 void hal_mpt_SwitchRfSetting(PADAPTER pAdapter);
722 s32 hal_mpt_SetPowerTracking(PADAPTER padapter, u8 enable);
723 void hal_mpt_GetPowerTracking(PADAPTER padapter, u8 *enable);
724 void hal_mpt_CCKTxPowerAdjust(PADAPTER Adapter, BOOLEAN bInCH14);
725 void hal_mpt_SetChannel(PADAPTER pAdapter);
726 void hal_mpt_SetBandwidth(PADAPTER pAdapter);
727 void hal_mpt_SetTxPower(PADAPTER pAdapter);
728 void hal_mpt_SetDataRate(PADAPTER pAdapter);
729 void hal_mpt_SetAntenna(PADAPTER pAdapter);
730 s32 hal_mpt_SetThermalMeter(PADAPTER pAdapter, u8 target_ther);
731 void hal_mpt_TriggerRFThermalMeter(PADAPTER pAdapter);
732 u8 hal_mpt_ReadRFThermalMeter(PADAPTER pAdapter);
733 void hal_mpt_GetThermalMeter(PADAPTER pAdapter, u8 *value);
734 void hal_mpt_CCKTxPowerAdjustbyIndex(PADAPTER pAdapter, BOOLEAN beven);
735 void hal_mpt_SetContinuousTx(PADAPTER pAdapter, u8 bStart);
736 void hal_mpt_SetSingleCarrierTx(PADAPTER pAdapter, u8 bStart);
737 void hal_mpt_SetSingleToneTx(PADAPTER pAdapter, u8 bStart);
738 void hal_mpt_SetCarrierSuppressionTx(PADAPTER pAdapter, u8 bStart);
739 void hal_mpt_SetCCKContinuousTx(PADAPTER pAdapter, u8 bStart);
740 void hal_mpt_SetOFDMContinuousTx(PADAPTER pAdapter, u8 bStart);
741 
742 
743 void Hal_ProSetCrystalCap(PADAPTER pAdapter , u32 CrystalCapVal);
744 void MP_PHY_SetRFPathSwitch(PADAPTER pAdapter , BOOLEAN bMain);
745 ULONG mpt_ProQueryCalTxPower(PADAPTER	pAdapter, u8 RfPath);
746 void MPT_PwrCtlDM(PADAPTER padapter, u32 bstart);
747 u8 MptToMgntRate(u32	MptRateIdx);
748 u8 rtw_mpRateParseFunc(PADAPTER pAdapter, u8 *targetStr);
749 u32 mp_join(PADAPTER padapter, u8 mode);
750 
751 int rtw_mp_write_reg(struct net_device *dev,
752 			struct iw_request_info *info,
753 			struct iw_point *wrqu, char *extra);
754 int rtw_mp_read_reg(struct net_device *dev,
755 			struct iw_request_info *info,
756 			struct iw_point *wrqu, char *extra);
757 int rtw_mp_write_rf(struct net_device *dev,
758 			struct iw_request_info *info,
759 			struct iw_point *wrqu, char *extra);
760 int rtw_mp_read_rf(struct net_device *dev,
761 			struct iw_request_info *info,
762 			struct iw_point *wrqu, char *extra);
763 int rtw_mp_start(struct net_device *dev,
764 			struct iw_request_info *info,
765 			struct iw_point *wrqu, char *extra);
766 int rtw_mp_stop(struct net_device *dev,
767 			struct iw_request_info *info,
768 			struct iw_point *wrqu, char *extra);
769 int rtw_mp_rate(struct net_device *dev,
770 			struct iw_request_info *info,
771 			struct iw_point *wrqu, char *extra);
772 int rtw_mp_channel(struct net_device *dev,
773 			struct iw_request_info *info,
774 			struct iw_point *wrqu, char *extra);
775 int rtw_mp_bandwidth(struct net_device *dev,
776 			struct iw_request_info *info,
777 			struct iw_point *wrqu, char *extra);
778 int rtw_mp_txpower_index(struct net_device *dev,
779 			struct iw_request_info *info,
780 			struct iw_point *wrqu, char *extra);
781 int rtw_mp_txpower(struct net_device *dev,
782 			struct iw_request_info *info,
783 			struct iw_point *wrqu, char *extra);
784 int rtw_mp_txpower(struct net_device *dev,
785 			struct iw_request_info *info,
786 			struct iw_point *wrqu, char *extra);
787 int rtw_mp_ant_tx(struct net_device *dev,
788 			struct iw_request_info *info,
789 			struct iw_point *wrqu, char *extra);
790 int rtw_mp_ant_rx(struct net_device *dev,
791 			struct iw_request_info *info,
792 			struct iw_point *wrqu, char *extra);
793 int rtw_set_ctx_destAddr(struct net_device *dev,
794 			struct iw_request_info *info,
795 			struct iw_point *wrqu, char *extra);
796 int rtw_mp_ctx(struct net_device *dev,
797 			struct iw_request_info *info,
798 			struct iw_point *wrqu, char *extra);
799 int rtw_mp_disable_bt_coexist(struct net_device *dev,
800 			struct iw_request_info *info,
801 			union iwreq_data *wrqu, char *extra);
802 int rtw_mp_disable_bt_coexist(struct net_device *dev,
803 			struct iw_request_info *info,
804 			union iwreq_data *wrqu, char *extra);
805 int rtw_mp_arx(struct net_device *dev,
806 			struct iw_request_info *info,
807 			struct iw_point *wrqu, char *extra);
808 int rtw_mp_trx_query(struct net_device *dev,
809 			struct iw_request_info *info,
810 			struct iw_point *wrqu, char *extra);
811 int rtw_mp_pwrtrk(struct net_device *dev,
812 			struct iw_request_info *info,
813 			struct iw_point *wrqu, char *extra);
814 int rtw_mp_psd(struct net_device *dev,
815 			struct iw_request_info *info,
816 			struct iw_point *wrqu, char *extra);
817 int rtw_mp_thermal(struct net_device *dev,
818 			struct iw_request_info *info,
819 			struct iw_point *wrqu, char *extra);
820 int rtw_mp_reset_stats(struct net_device *dev,
821 			struct iw_request_info *info,
822 			struct iw_point *wrqu, char *extra);
823 int rtw_mp_dump(struct net_device *dev,
824 			struct iw_request_info *info,
825 			struct iw_point *wrqu, char *extra);
826 int rtw_mp_phypara(struct net_device *dev,
827 			struct iw_request_info *info,
828 			struct iw_point *wrqu, char *extra);
829 int rtw_mp_SetRFPath(struct net_device *dev,
830 			struct iw_request_info *info,
831 			union iwreq_data *wrqu, char *extra);
832 int rtw_mp_QueryDrv(struct net_device *dev,
833 			struct iw_request_info *info,
834 			union iwreq_data *wrqu, char *extra);
835 int rtw_mp_PwrCtlDM(struct net_device *dev,
836 			struct iw_request_info *info,
837 			struct iw_point *wrqu, char *extra);
838 int rtw_mp_getver(struct net_device *dev,
839 			struct iw_request_info *info,
840 			union iwreq_data *wrqu, char *extra);
841 int rtw_mp_mon(struct net_device *dev,
842 			struct iw_request_info *info,
843 			union iwreq_data *wrqu, char *extra);
844 int rtw_efuse_mask_file(struct net_device *dev,
845 			struct iw_request_info *info,
846 			union iwreq_data *wrqu, char *extra);
847 int rtw_efuse_file_map(struct net_device *dev,
848 			struct iw_request_info *info,
849 			union iwreq_data *wrqu, char *extra);
850 int rtw_mp_SetBT(struct net_device *dev,
851 			struct iw_request_info *info,
852 			union iwreq_data *wrqu, char *extra);
853 int rtw_mp_pretx_proc(PADAPTER padapter, u8 bStartTest, char *extra);
854 int rtw_mp_tx(struct net_device *dev,
855 			struct iw_request_info *info,
856 			union iwreq_data *wrqu, char *extra);
857 int rtw_mp_rx(struct net_device *dev,
858 			struct iw_request_info *info,
859 			union iwreq_data *wrqu, char *extra);
860 int rtw_mp_hwtx(struct net_device *dev,
861 			struct iw_request_info *info,
862 			union iwreq_data *wrqu, char *extra);
863 #endif //_RTW_MP_H_
864 
865