xref: /OK3568_Linux_fs/kernel/drivers/net/wireless/rockchip_wlan/rtl8723bu/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 typedef struct _RT_PMAC_PKT_INFO {
144 	UCHAR			MCS;
145 	UCHAR			Nss;
146 	UCHAR			Nsts;
147 	UINT			N_sym;
148 	UCHAR			SIGA2B3;
149 } RT_PMAC_PKT_INFO, *PRT_PMAC_PKT_INFO;
150 
151 typedef struct _RT_PMAC_TX_INFO {
152 	u8			bEnPMacTx:1;		/* 0: Disable PMac 1: Enable PMac */
153 	u8			Mode:3;				/* 0: Packet TX 3:Continuous TX */
154 	u8			Ntx:4;				/* 0-7 */
155 	u8			TX_RATE;			/* MPT_RATE_E */
156 	u8			TX_RATE_HEX;
157 	u8			TX_SC;
158 	u8			bSGI:1;
159 	u8			bSPreamble:1;
160 	u8			bSTBC:1;
161 	u8			bLDPC:1;
162 	u8			NDP_sound:1;
163 	u8			BandWidth:3;		/* 0: 20 1:40 2:80Mhz */
164 	u8			m_STBC;			/* bSTBC + 1 */
165 	USHORT			PacketPeriod;
166 	UINT		PacketCount;
167 	UINT		PacketLength;
168 	u8			PacketPattern;
169 	USHORT			SFD;
170 	u8			SignalField;
171 	u8			ServiceField;
172 	USHORT			LENGTH;
173 	u8			CRC16[2];
174 	u8			LSIG[3];
175 	u8			HT_SIG[6];
176 	u8			VHT_SIG_A[6];
177 	u8			VHT_SIG_B[4];
178 	u8			VHT_SIG_B_CRC;
179 	u8			VHT_Delimiter[4];
180 	u8			MacAddress[6];
181 } RT_PMAC_TX_INFO, *PRT_PMAC_TX_INFO;
182 
183 
184 typedef VOID (*MPT_WORK_ITEM_HANDLER)(IN PVOID Adapter);
185 typedef struct _MPT_CONTEXT
186 {
187 	// Indicate if we have started Mass Production Test.
188 	BOOLEAN			bMassProdTest;
189 
190 	// Indicate if the driver is unloading or unloaded.
191 	BOOLEAN			bMptDrvUnload;
192 
193 	_sema			MPh2c_Sema;
194 	_timer			MPh2c_timeout_timer;
195 // Event used to sync H2c for BT control
196 
197 	BOOLEAN		MptH2cRspEvent;
198 	BOOLEAN		MptBtC2hEvent;
199 	BOOLEAN		bMPh2c_timeout;
200 
201 	/* 8190 PCI does not support NDIS_WORK_ITEM. */
202 	// Work Item for Mass Production Test.
203 	//NDIS_WORK_ITEM	MptWorkItem;
204 //	RT_WORK_ITEM		MptWorkItem;
205 	// Event used to sync the case unloading driver and MptWorkItem is still in progress.
206 //	NDIS_EVENT		MptWorkItemEvent;
207 	// To protect the following variables.
208 //	NDIS_SPIN_LOCK		MptWorkItemSpinLock;
209 	// Indicate a MptWorkItem is scheduled and not yet finished.
210 	BOOLEAN			bMptWorkItemInProgress;
211 	// An instance which implements function and context of MptWorkItem.
212 	MPT_WORK_ITEM_HANDLER	CurrMptAct;
213 
214 	// 1=Start, 0=Stop from UI.
215 	ULONG			MptTestStart;
216 	// _TEST_MODE, defined in MPT_Req2.h
217 	ULONG			MptTestItem;
218 	// Variable needed in each implementation of CurrMptAct.
219 	ULONG			MptActType; 	// Type of action performed in CurrMptAct.
220 	// The Offset of IO operation is depend of MptActType.
221 	ULONG			MptIoOffset;
222 	// The Value of IO operation is depend of MptActType.
223 	ULONG			MptIoValue;
224 	// The RfPath of IO operation is depend of MptActType.
225 	ULONG			MptRfPath;
226 
227 	WIRELESS_MODE		MptWirelessModeToSw;	// Wireless mode to switch.
228 	u8			MptChannelToSw; 	// Channel to switch.
229 	u8			MptInitGainToSet; 	// Initial gain to set.
230 	//ULONG			bMptAntennaA; 		// TRUE if we want to use antenna A.
231 	ULONG			MptBandWidth;		// bandwidth to switch.
232 	ULONG			MptRateIndex;		// rate index.
233 	// Register value kept for Single Carrier Tx test.
234 	u8			btMpCckTxPower;
235 	// Register value kept for Single Carrier Tx test.
236 	u8			btMpOfdmTxPower;
237 	// For MP Tx Power index
238 	u8			TxPwrLevel[4];	/* rf-A, rf-B*/
239 	u32			RegTxPwrLimit;
240 	// Content of RCR Regsiter for Mass Production Test.
241 	ULONG			MptRCR;
242 	// TRUE if we only receive packets with specific pattern.
243 	BOOLEAN			bMptFilterPattern;
244  	// Rx OK count, statistics used in Mass Production Test.
245  	ULONG			MptRxOkCnt;
246  	// Rx CRC32 error count, statistics used in Mass Production Test.
247  	ULONG			MptRxCrcErrCnt;
248 
249 	BOOLEAN			bCckContTx;	// TRUE if we are in CCK Continuous Tx test.
250  	BOOLEAN			bOfdmContTx;	// TRUE if we are in OFDM Continuous Tx test.
251 	BOOLEAN			bStartContTx; 	// TRUE if we have start Continuous Tx test.
252 	// TRUE if we are in Single Carrier Tx test.
253 	BOOLEAN			bSingleCarrier;
254 	// TRUE if we are in Carrier Suppression Tx Test.
255 	BOOLEAN			bCarrierSuppression;
256 	//TRUE if we are in Single Tone Tx test.
257 	BOOLEAN			bSingleTone;
258 
259 	// ACK counter asked by K.Y..
260 	BOOLEAN			bMptEnableAckCounter;
261 	ULONG			MptAckCounter;
262 
263 	// SD3 Willis For 8192S to save 1T/2T RF table for ACUT	Only fro ACUT delete later ~~~!
264 	//s1Byte		BufOfLines[2][MAX_LINES_HWCONFIG_TXT][MAX_BYTES_LINE_HWCONFIG_TXT];
265 	//s1Byte			BufOfLines[2][MP_MAX_LINES][MP_MAX_LINES_BYTES];
266 	//s4Byte			RfReadLine[2];
267 
268 	u8		APK_bound[2];	//for APK	path A/path B
269 	BOOLEAN		bMptIndexEven;
270 
271 	u8		backup0xc50;
272 	u8		backup0xc58;
273 	u8		backup0xc30;
274 	u8 		backup0x52_RF_A;
275 	u8 		backup0x52_RF_B;
276 
277 	u4Byte			backup0x58_RF_A;
278 	u4Byte			backup0x58_RF_B;
279 
280 	u1Byte			h2cReqNum;
281 	u1Byte			c2hBuf[32];
282 
283     u1Byte          btInBuf[100];
284 	ULONG			mptOutLen;
285     u1Byte          mptOutBuf[100];
286 	RT_PMAC_TX_INFO	PMacTxInfo;
287 	RT_PMAC_PKT_INFO	PMacPktInfo;
288 	u8 HWTxmode;
289 
290 	BOOLEAN			bldpc;
291 	BOOLEAN			bstbc;
292 }MPT_CONTEXT, *PMPT_CONTEXT;
293 //#endif
294 
295 /* E-Fuse */
296 #ifdef CONFIG_RTL8188E
297 #define EFUSE_MAP_SIZE		512
298 #endif
299 #if defined(CONFIG_RTL8812A) || defined(CONFIG_RTL8821A) || defined(CONFIG_RTL8814A)
300 #define EFUSE_MAP_SIZE		512
301 #endif
302 #ifdef CONFIG_RTL8192E
303 #define EFUSE_MAP_SIZE		512
304 #endif
305 #ifdef CONFIG_RTL8723B
306 #define EFUSE_MAP_SIZE		512
307 #endif
308 #ifdef CONFIG_RTL8814A
309 #define EFUSE_MAP_SIZE		512
310 #endif
311 #ifdef CONFIG_RTL8703B
312 #define EFUSE_MAP_SIZE		512
313 #endif
314 #ifdef CONFIG_RTL8188F
315 #define EFUSE_MAP_SIZE		512
316 #endif
317 
318 #if defined(CONFIG_RTL8814A)
319 #define EFUSE_MAX_SIZE		1024
320 #elif defined(CONFIG_RTL8188E) || defined(CONFIG_RTL8188F) || defined(CONFIG_RTL8703B)
321 #define EFUSE_MAX_SIZE		256
322 #else
323 #define EFUSE_MAX_SIZE		512
324 #endif
325 /* end of E-Fuse */
326 
327 //#define RTPRIV_IOCTL_MP 					( SIOCIWFIRSTPRIV + 0x17)
328 enum {
329 	WRITE_REG = 1,
330 	READ_REG,
331 	WRITE_RF,
332 	READ_RF,
333 	MP_START,
334 	MP_STOP,
335 	MP_RATE,
336 	MP_CHANNEL,
337 	MP_BANDWIDTH,
338 	MP_TXPOWER,
339 	MP_ANT_TX,
340 	MP_ANT_RX,
341 	MP_CTX,
342 	MP_QUERY,
343 	MP_ARX,
344 	MP_PSD,
345 	MP_PWRTRK,
346 	MP_THER,
347 	MP_IOCTL,
348 	EFUSE_GET,
349 	EFUSE_SET,
350 	MP_RESET_STATS,
351 	MP_DUMP,
352 	MP_PHYPARA,
353 	MP_SetRFPathSwh,
354 	MP_QueryDrvStats,
355 	MP_SetBT,
356 	CTA_TEST,
357 	MP_DISABLE_BT_COEXIST,
358 	MP_PwrCtlDM,
359 	MP_GETVER,
360 	MP_MON,
361 	EFUSE_MASK,
362 	EFUSE_FILE,
363 	MP_TX,
364 	MP_RX,
365 	MP_HW_TX_MODE,
366 #ifdef CONFIG_WOWLAN
367 	MP_WOW_ENABLE,
368 	MP_WOW_SET_PATTERN,
369 #endif
370 #ifdef CONFIG_AP_WOWLAN
371 	MP_AP_WOW_ENABLE,
372 #endif
373 	MP_NULL,
374 	MP_GET_TXPOWER_INX,
375 
376 	MP_SD_IREAD,
377 	MP_SD_IWRITE,
378 };
379 
380 struct mp_priv
381 {
382 	_adapter *papdater;
383 
384 	//Testing Flag
385 	u32 mode;//0 for normal type packet, 1 for loopback packet (16bytes TXCMD)
386 
387 	u32 prev_fw_state;
388 
389 	//OID cmd handler
390 	struct mp_wiparam workparam;
391 //	u8 act_in_progress;
392 
393 	//Tx Section
394 	u8 TID;
395 	u32 tx_pktcount;
396 	u32 pktInterval;
397 	u32 pktLength;
398 	struct mp_tx tx;
399 
400 	//Rx Section
401 	u32 rx_bssidpktcount;
402 	u32 rx_pktcount;
403 	u32 rx_pktcount_filter_out;
404 	u32 rx_crcerrpktcount;
405 	u32 rx_pktloss;
406 	BOOLEAN  rx_bindicatePkt;
407 	struct recv_stat rxstat;
408 
409 	//RF/BB relative
410 	u8 channel;
411 	u8 bandwidth;
412 	u8 prime_channel_offset;
413 	u8 txpoweridx;
414 	u8 rateidx;
415 	u32 preamble;
416 //	u8 modem;
417 	u32 CrystalCap;
418 //	u32 curr_crystalcap;
419 
420 	u16 antenna_tx;
421 	u16 antenna_rx;
422 //	u8 curr_rfpath;
423 
424 	u8 check_mp_pkt;
425 
426 	u8 bSetTxPower;
427 //	uint ForcedDataRate;
428 	u8 mp_dm;
429 	u8 mac_filter[ETH_ALEN];
430 	u8 bmac_filter;
431 
432 	struct wlan_network mp_network;
433 	NDIS_802_11_MAC_ADDRESS network_macaddr;
434 
435 #ifdef PLATFORM_WINDOWS
436 	u32 rx_testcnt;
437 	u32 rx_testcnt1;
438 	u32 rx_testcnt2;
439 	u32 tx_testcnt;
440 	u32 tx_testcnt1;
441 
442 	struct mp_wi_cntx wi_cntx;
443 
444 	u8 h2c_result;
445 	u8 h2c_seqnum;
446 	u16 h2c_cmdcode;
447 	u8 h2c_resp_parambuf[512];
448 	_lock h2c_lock;
449 	_lock wkitm_lock;
450 	u32 h2c_cmdcnt;
451 	NDIS_EVENT h2c_cmd_evt;
452 	NDIS_EVENT c2h_set;
453 	NDIS_EVENT h2c_clr;
454 	NDIS_EVENT cpwm_int;
455 
456 	NDIS_EVENT scsir_full_evt;
457 	NDIS_EVENT scsiw_empty_evt;
458 #endif
459 
460 	u8 *pallocated_mp_xmitframe_buf;
461 	u8 *pmp_xmtframe_buf;
462 	_queue free_mp_xmitqueue;
463 	u32 free_mp_xmitframe_cnt;
464 	BOOLEAN bSetRxBssid;
465 	BOOLEAN bTxBufCkFail;
466 	BOOLEAN bRTWSmbCfg;
467 	MPT_CONTEXT MptCtx;
468 
469 	u8		*TXradomBuffer;
470 };
471 
472 typedef struct _IOCMD_STRUCT_ {
473 	u8	cmdclass;
474 	u16	value;
475 	u8	index;
476 }IOCMD_STRUCT;
477 
478 struct rf_reg_param {
479 	u32 path;
480 	u32 offset;
481 	u32 value;
482 };
483 
484 struct bb_reg_param {
485 	u32 offset;
486 	u32 value;
487 };
488 
489 typedef struct _MP_FIRMWARE {
490 	FIRMWARE_SOURCE eFWSource;
491 #ifdef CONFIG_EMBEDDED_FWIMG
492 	u8* 		szFwBuffer;
493 #else
494 	u8			szFwBuffer[0x8000];
495 #endif
496 	u32 		ulFwLength;
497 } RT_MP_FIRMWARE, *PRT_MP_FIRMWARE;
498 
499 
500 
501 
502 //=======================================================================
503 
504 #define LOWER 	_TRUE
505 #define RAISE	_FALSE
506 
507 /* Hardware Registers */
508 #if 0
509 #if 0
510 #define IOCMD_CTRL_REG			0x102502C0
511 #define IOCMD_DATA_REG			0x102502C4
512 #else
513 #define IOCMD_CTRL_REG			0x10250370
514 #define IOCMD_DATA_REG			0x10250374
515 #endif
516 
517 #define IOCMD_GET_THERMAL_METER		0xFD000028
518 
519 #define IOCMD_CLASS_BB_RF		0xF0
520 #define IOCMD_BB_READ_IDX		0x00
521 #define IOCMD_BB_WRITE_IDX		0x01
522 #define IOCMD_RF_READ_IDX		0x02
523 #define IOCMD_RF_WRIT_IDX		0x03
524 #endif
525 #define BB_REG_BASE_ADDR		0x800
526 
527 /* MP variables */
528 #if 0
529 #define _2MAC_MODE_	0
530 #define _LOOPBOOK_MODE_	1
531 #endif
532 typedef enum _MP_MODE_ {
533 	MP_OFF,
534 	MP_ON,
535 	MP_ERR,
536 	MP_CONTINUOUS_TX,
537 	MP_SINGLE_CARRIER_TX,
538 	MP_CARRIER_SUPPRISSION_TX,
539 	MP_SINGLE_TONE_TX,
540 	MP_PACKET_TX,
541 	MP_PACKET_RX
542 } MP_MODE;
543 
544 typedef enum _TEST_MODE {
545 	TEST_NONE                 ,
546 	PACKETS_TX                ,
547 	PACKETS_RX                ,
548 	CONTINUOUS_TX             ,
549 	OFDM_Single_Tone_TX       ,
550 	CCK_Carrier_Suppression_TX
551 } TEST_MODE;
552 
553 
554 typedef enum _MPT_BANDWIDTH {
555 	MPT_BW_20MHZ = 0,
556 	MPT_BW_40MHZ_DUPLICATE = 1,
557 	MPT_BW_40MHZ_ABOVE = 2,
558 	MPT_BW_40MHZ_BELOW = 3,
559 	MPT_BW_40MHZ = 4,
560 	MPT_BW_80MHZ = 5,
561 	MPT_BW_80MHZ_20_ABOVE = 6,
562 	MPT_BW_80MHZ_20_BELOW = 7,
563 	MPT_BW_80MHZ_20_BOTTOM = 8,
564 	MPT_BW_80MHZ_20_TOP = 9,
565 	MPT_BW_80MHZ_40_ABOVE = 10,
566 	MPT_BW_80MHZ_40_BELOW = 11,
567 } MPT_BANDWIDTHE, *PMPT_BANDWIDTH;
568 
569 #define MAX_RF_PATH_NUMS	RF_PATH_MAX
570 
571 
572 extern u8 mpdatarate[NumRates];
573 
574 /* MP set force data rate base on the definition. */
575 typedef enum _MPT_RATE_INDEX
576 {
577 	/* CCK rate. */
578 	MPT_RATE_1M = 1 ,	/* 0 */
579 	MPT_RATE_2M,
580 	MPT_RATE_55M,
581 	MPT_RATE_11M,	/* 3 */
582 
583 	/* OFDM rate. */
584 	MPT_RATE_6M,	/* 4 */
585 	MPT_RATE_9M,
586 	MPT_RATE_12M,
587 	MPT_RATE_18M,
588 	MPT_RATE_24M,
589 	MPT_RATE_36M,
590 	MPT_RATE_48M,
591 	MPT_RATE_54M,	/* 11 */
592 
593 	/* HT rate. */
594 	MPT_RATE_MCS0,	/* 12 */
595 	MPT_RATE_MCS1,
596 	MPT_RATE_MCS2,
597 	MPT_RATE_MCS3,
598 	MPT_RATE_MCS4,
599 	MPT_RATE_MCS5,
600 	MPT_RATE_MCS6,
601 	MPT_RATE_MCS7,	/* 19 */
602 	MPT_RATE_MCS8,
603 	MPT_RATE_MCS9,
604 	MPT_RATE_MCS10,
605 	MPT_RATE_MCS11,
606 	MPT_RATE_MCS12,
607 	MPT_RATE_MCS13,
608 	MPT_RATE_MCS14,
609 	MPT_RATE_MCS15,	/* 27 */
610 	MPT_RATE_MCS16,
611 	MPT_RATE_MCS17, // #29
612 	MPT_RATE_MCS18,
613 	MPT_RATE_MCS19,
614 	MPT_RATE_MCS20,
615 	MPT_RATE_MCS21,
616 	MPT_RATE_MCS22, // #34
617 	MPT_RATE_MCS23,
618 	MPT_RATE_MCS24,
619 	MPT_RATE_MCS25,
620 	MPT_RATE_MCS26,
621 	MPT_RATE_MCS27, // #39
622 	MPT_RATE_MCS28, // #40
623 	MPT_RATE_MCS29, // #41
624 	MPT_RATE_MCS30, // #42
625 	MPT_RATE_MCS31, // #43
626 	/* VHT rate. Total: 20*/
627 	MPT_RATE_VHT1SS_MCS0 = 100,/*  #44*/
628 	MPT_RATE_VHT1SS_MCS1, // #
629 	MPT_RATE_VHT1SS_MCS2,
630 	MPT_RATE_VHT1SS_MCS3,
631 	MPT_RATE_VHT1SS_MCS4,
632 	MPT_RATE_VHT1SS_MCS5,
633 	MPT_RATE_VHT1SS_MCS6, // #
634 	MPT_RATE_VHT1SS_MCS7,
635 	MPT_RATE_VHT1SS_MCS8,
636 	MPT_RATE_VHT1SS_MCS9, //#53
637 	MPT_RATE_VHT2SS_MCS0, //#54
638 	MPT_RATE_VHT2SS_MCS1,
639 	MPT_RATE_VHT2SS_MCS2,
640 	MPT_RATE_VHT2SS_MCS3,
641 	MPT_RATE_VHT2SS_MCS4,
642 	MPT_RATE_VHT2SS_MCS5,
643 	MPT_RATE_VHT2SS_MCS6,
644 	MPT_RATE_VHT2SS_MCS7,
645 	MPT_RATE_VHT2SS_MCS8,
646 	MPT_RATE_VHT2SS_MCS9, //#63
647 	MPT_RATE_VHT3SS_MCS0,
648 	MPT_RATE_VHT3SS_MCS1,
649 	MPT_RATE_VHT3SS_MCS2,
650 	MPT_RATE_VHT3SS_MCS3,
651 	MPT_RATE_VHT3SS_MCS4,
652 	MPT_RATE_VHT3SS_MCS5,
653 	MPT_RATE_VHT3SS_MCS6, // #126
654 	MPT_RATE_VHT3SS_MCS7,
655 	MPT_RATE_VHT3SS_MCS8,
656 	MPT_RATE_VHT3SS_MCS9,
657 	MPT_RATE_VHT4SS_MCS0,
658 	MPT_RATE_VHT4SS_MCS1, // #131
659 	MPT_RATE_VHT4SS_MCS2,
660 	MPT_RATE_VHT4SS_MCS3,
661 	MPT_RATE_VHT4SS_MCS4,
662 	MPT_RATE_VHT4SS_MCS5,
663 	MPT_RATE_VHT4SS_MCS6, // #136
664 	MPT_RATE_VHT4SS_MCS7,
665 	MPT_RATE_VHT4SS_MCS8,
666 	MPT_RATE_VHT4SS_MCS9,
667 	MPT_RATE_LAST
668 }MPT_RATE_E, *PMPT_RATE_E;
669 
670 #define MAX_TX_PWR_INDEX_N_MODE 64	// 0x3F
671 
672 #define MPT_IS_CCK_RATE(_value)		(MPT_RATE_1M <= _value && _value <= MPT_RATE_11M)
673 #define MPT_IS_OFDM_RATE(_value)	(MPT_RATE_6M <= _value && _value <= MPT_RATE_54M)
674 #define MPT_IS_HT_RATE(_value)		(MPT_RATE_MCS0 <= _value && _value <= MPT_RATE_MCS31)
675 #define MPT_IS_HT_1S_RATE(_value)	(MPT_RATE_MCS0 <= _value && _value <= MPT_RATE_MCS7)
676 #define MPT_IS_HT_2S_RATE(_value)	(MPT_RATE_MCS8 <= _value && _value <= MPT_RATE_MCS15)
677 #define MPT_IS_HT_3S_RATE(_value)	(MPT_RATE_MCS16 <= _value && _value <= MPT_RATE_MCS23)
678 #define MPT_IS_HT_4S_RATE(_value)	(MPT_RATE_MCS24 <= _value && _value <= MPT_RATE_MCS31)
679 
680 #define MPT_IS_VHT_RATE(_value)		(MPT_RATE_VHT1SS_MCS0 <= _value && _value <= MPT_RATE_VHT4SS_MCS9)
681 #define MPT_IS_VHT_1S_RATE(_value)	(MPT_RATE_VHT1SS_MCS0 <= _value && _value <= MPT_RATE_VHT1SS_MCS9)
682 #define MPT_IS_VHT_2S_RATE(_value)	(MPT_RATE_VHT2SS_MCS0 <= _value && _value <= MPT_RATE_VHT2SS_MCS9)
683 #define MPT_IS_VHT_3S_RATE(_value)	(MPT_RATE_VHT3SS_MCS0 <= _value && _value <= MPT_RATE_VHT3SS_MCS9)
684 #define MPT_IS_VHT_4S_RATE(_value)	(MPT_RATE_VHT4SS_MCS0 <= _value && _value <= MPT_RATE_VHT4SS_MCS9)
685 
686 #define MPT_IS_2SS_RATE(_rate) ((MPT_RATE_MCS8 <= _rate && _rate <= MPT_RATE_MCS15) ||\
687 							(MPT_RATE_VHT2SS_MCS0 <= _rate && _rate <= MPT_RATE_VHT2SS_MCS9))
688 #define MPT_IS_3SS_RATE(_rate) ((MPT_RATE_MCS16 <= _rate && _rate <= MPT_RATE_MCS23) ||\
689 							(MPT_RATE_VHT3SS_MCS0 <= _rate && _rate <= MPT_RATE_VHT3SS_MCS9))
690 #define MPT_IS_4SS_RATE(_rate) ((MPT_RATE_MCS24 <= _rate && _rate <= MPT_RATE_MCS31) ||\
691 							(MPT_RATE_VHT4SS_MCS0 <= _rate && _rate <= MPT_RATE_VHT4SS_MCS9))
692 
693 typedef enum _POWER_MODE_ {
694 	POWER_LOW = 0,
695 	POWER_NORMAL
696 }POWER_MODE;
697 
698 // The following enumeration is used to define the value of Reg0xD00[30:28] or JaguarReg0x914[18:16].
699 typedef enum _OFDM_TX_MODE {
700 	OFDM_ALL_OFF		= 0,
701 	OFDM_ContinuousTx	= 1,
702 	OFDM_SingleCarrier	= 2,
703 	OFDM_SingleTone 	= 4,
704 } OFDM_TX_MODE;
705 
706 
707 #define RX_PKT_BROADCAST	1
708 #define RX_PKT_DEST_ADDR	2
709 #define RX_PKT_PHY_MATCH	3
710 
711 #define Mac_OFDM_OK 			0x00000000
712 #define Mac_OFDM_Fail			0x10000000
713 #define Mac_OFDM_FasleAlarm 	0x20000000
714 #define Mac_CCK_OK				0x30000000
715 #define Mac_CCK_Fail			0x40000000
716 #define Mac_CCK_FasleAlarm		0x50000000
717 #define Mac_HT_OK				0x60000000
718 #define Mac_HT_Fail 			0x70000000
719 #define Mac_HT_FasleAlarm		0x90000000
720 #define Mac_DropPacket			0xA0000000
721 
722 typedef enum _ENCRY_CTRL_STATE_ {
723 	HW_CONTROL,		//hw encryption& decryption
724 	SW_CONTROL,		//sw encryption& decryption
725 	HW_ENCRY_SW_DECRY,	//hw encryption & sw decryption
726 	SW_ENCRY_HW_DECRY	//sw encryption & hw decryption
727 }ENCRY_CTRL_STATE;
728 
729 typedef enum	_MPT_TXPWR_DEF{
730 	MPT_CCK,
731 	MPT_OFDM, // L and HT OFDM
732 	MPT_OFDM_AND_HT,
733 	MPT_HT,
734 	MPT_VHT
735 }MPT_TXPWR_DEF;
736 
737 #ifdef CONFIG_RF_GAIN_OFFSET
738 
739 #if defined(CONFIG_RTL8723B)
740 	#define 	REG_RF_BB_GAIN_OFFSET	0x7f
741 	#define 	RF_GAIN_OFFSET_MASK 	0xfffff
742 #elif defined(CONFIG_RTL8188E)
743 	#define 	REG_RF_BB_GAIN_OFFSET	0x55
744 	#define 	RF_GAIN_OFFSET_MASK 	0xfffff
745 #else
746 	#define 	REG_RF_BB_GAIN_OFFSET	0x55
747 	#define 	RF_GAIN_OFFSET_MASK 	0xfffff
748 #endif	//CONFIG_RTL8723B
749 
750 #endif //CONFIG_RF_GAIN_OFFSET
751 
752 #define IS_MPT_HT_RATE(_rate)			(_rate >= MPT_RATE_MCS0 && _rate <= MPT_RATE_MCS31)
753 #define IS_MPT_VHT_RATE(_rate)			(_rate >= MPT_RATE_VHT1SS_MCS0 && _rate <= MPT_RATE_VHT4SS_MCS9)
754 #define IS_MPT_CCK_RATE(_rate)			(_rate >= MPT_RATE_1M && _rate <= MPT_RATE_11M)
755 #define IS_MPT_OFDM_RATE(_rate)			(_rate >= MPT_RATE_6M && _rate <= MPT_RATE_54M)
756 //=======================================================================
757 //extern struct mp_xmit_frame *alloc_mp_xmitframe(struct mp_priv *pmp_priv);
758 //extern int free_mp_xmitframe(struct xmit_priv *pxmitpriv, struct mp_xmit_frame *pmp_xmitframe);
759 
760 extern s32 init_mp_priv(PADAPTER padapter);
761 extern void free_mp_priv(struct mp_priv *pmp_priv);
762 extern s32 MPT_InitializeAdapter(PADAPTER padapter, u8 Channel);
763 extern void MPT_DeInitAdapter(PADAPTER padapter);
764 extern s32 mp_start_test(PADAPTER padapter);
765 extern void mp_stop_test(PADAPTER padapter);
766 
767 extern u32 _read_rfreg(PADAPTER padapter, u8 rfpath, u32 addr, u32 bitmask);
768 extern void _write_rfreg(PADAPTER padapter, u8 rfpath, u32 addr, u32 bitmask, u32 val);
769 
770 extern u32 read_macreg(_adapter *padapter, u32 addr, u32 sz);
771 extern void write_macreg(_adapter *padapter, u32 addr, u32 val, u32 sz);
772 extern u32 read_bbreg(_adapter *padapter, u32 addr, u32 bitmask);
773 extern void write_bbreg(_adapter *padapter, u32 addr, u32 bitmask, u32 val);
774 extern u32 read_rfreg(PADAPTER padapter, u8 rfpath, u32 addr);
775 extern void write_rfreg(PADAPTER padapter, u8 rfpath, u32 addr, u32 val);
776 
777 void	SetChannel(PADAPTER pAdapter);
778 void	SetBandwidth(PADAPTER pAdapter);
779 int	SetTxPower(PADAPTER pAdapter);
780 void	SetAntenna(PADAPTER pAdapter);
781 void	SetDataRate(PADAPTER pAdapter);
782 void	SetAntenna(PADAPTER pAdapter);
783 s32	SetThermalMeter(PADAPTER pAdapter, u8 target_ther);
784 void	GetThermalMeter(PADAPTER pAdapter, u8 *value);
785 void	SetContinuousTx(PADAPTER pAdapter, u8 bStart);
786 void	SetSingleCarrierTx(PADAPTER pAdapter, u8 bStart);
787 void	SetSingleToneTx(PADAPTER pAdapter, u8 bStart);
788 void	SetCarrierSuppressionTx(PADAPTER pAdapter, u8 bStart);
789 void	PhySetTxPowerLevel(PADAPTER pAdapter);
790 void	fill_txdesc_for_mp(PADAPTER padapter, u8 *ptxdesc);
791 void	SetPacketTx(PADAPTER padapter);
792 void	SetPacketRx(PADAPTER pAdapter, u8 bStartRx, u8 bAB);
793 void	ResetPhyRxPktCount(PADAPTER pAdapter);
794 u32	GetPhyRxPktReceived(PADAPTER pAdapter);
795 u32	GetPhyRxPktCRC32Error(PADAPTER pAdapter);
796 s32	SetPowerTracking(PADAPTER padapter, u8 enable);
797 void	GetPowerTracking(PADAPTER padapter, u8 *enable);
798 u32	mp_query_psd(PADAPTER pAdapter, u8 *data);
799 
800 
801 
802 void hal_mpt_SwitchRfSetting(PADAPTER pAdapter);
803 s32 hal_mpt_SetPowerTracking(PADAPTER padapter, u8 enable);
804 void hal_mpt_GetPowerTracking(PADAPTER padapter, u8 *enable);
805 void hal_mpt_CCKTxPowerAdjust(PADAPTER Adapter, BOOLEAN bInCH14);
806 void hal_mpt_SetChannel(PADAPTER pAdapter);
807 void hal_mpt_SetBandwidth(PADAPTER pAdapter);
808 void hal_mpt_SetTxPower(PADAPTER pAdapter);
809 void hal_mpt_SetDataRate(PADAPTER pAdapter);
810 void hal_mpt_SetAntenna(PADAPTER pAdapter);
811 s32 hal_mpt_SetThermalMeter(PADAPTER pAdapter, u8 target_ther);
812 void hal_mpt_TriggerRFThermalMeter(PADAPTER pAdapter);
813 u8 hal_mpt_ReadRFThermalMeter(PADAPTER pAdapter);
814 void hal_mpt_GetThermalMeter(PADAPTER pAdapter, u8 *value);
815 void hal_mpt_CCKTxPowerAdjustbyIndex(PADAPTER pAdapter, BOOLEAN beven);
816 void hal_mpt_SetContinuousTx(PADAPTER pAdapter, u8 bStart);
817 void hal_mpt_SetSingleCarrierTx(PADAPTER pAdapter, u8 bStart);
818 void hal_mpt_SetSingleToneTx(PADAPTER pAdapter, u8 bStart);
819 void hal_mpt_SetCarrierSuppressionTx(PADAPTER pAdapter, u8 bStart);
820 void hal_mpt_SetCCKContinuousTx(PADAPTER pAdapter, u8 bStart);
821 void hal_mpt_SetOFDMContinuousTx(PADAPTER pAdapter, u8 bStart);
822 void mpt_ProSetPMacTx(PADAPTER	Adapter);
823 
824 void MP_PHY_SetRFPathSwitch(PADAPTER pAdapter , BOOLEAN bMain);
825 ULONG mpt_ProQueryCalTxPower(PADAPTER	pAdapter, u8 RfPath);
826 void MPT_PwrCtlDM(PADAPTER padapter, u32 bstart);
827 u8 MptToMgntRate(u32	MptRateIdx);
828 u8 rtw_mpRateParseFunc(PADAPTER pAdapter, u8 *targetStr);
829 u32 mp_join(PADAPTER padapter, u8 mode);
830 
831 void
832 PMAC_Get_Pkt_Param(
833 	PRT_PMAC_TX_INFO	pPMacTxInfo,
834 	PRT_PMAC_PKT_INFO	pPMacPktInfo
835 	);
836 void
837 CCK_generator(
838 	PRT_PMAC_TX_INFO	pPMacTxInfo,
839 	PRT_PMAC_PKT_INFO	pPMacPktInfo
840 	);
841 void
842 PMAC_Nsym_generator(
843 	PRT_PMAC_TX_INFO	pPMacTxInfo,
844 	PRT_PMAC_PKT_INFO	pPMacPktInfo
845 	);
846 void
847 L_SIG_generator(
848 	UINT	N_SYM,		/* Max: 750*/
849 	PRT_PMAC_TX_INFO	pPMacTxInfo,
850 	PRT_PMAC_PKT_INFO	pPMacPktInfo
851 	);
852 
853 void HT_SIG_generator(
854 	PRT_PMAC_TX_INFO	pPMacTxInfo,
855 	PRT_PMAC_PKT_INFO	pPMacPktInfo);
856 
857 void VHT_SIG_A_generator(
858 	PRT_PMAC_TX_INFO	pPMacTxInfo,
859 	PRT_PMAC_PKT_INFO	pPMacPktInfo);
860 
861 void VHT_SIG_B_generator(
862 	PRT_PMAC_TX_INFO	pPMacTxInfo);
863 
864 void VHT_Delimiter_generator(
865 	PRT_PMAC_TX_INFO	pPMacTxInfo);
866 
867 
868 int rtw_mp_write_reg(struct net_device *dev,
869 			struct iw_request_info *info,
870 			struct iw_point *wrqu, char *extra);
871 int rtw_mp_read_reg(struct net_device *dev,
872 			struct iw_request_info *info,
873 			struct iw_point *wrqu, char *extra);
874 int rtw_mp_write_rf(struct net_device *dev,
875 			struct iw_request_info *info,
876 			struct iw_point *wrqu, char *extra);
877 int rtw_mp_read_rf(struct net_device *dev,
878 			struct iw_request_info *info,
879 			struct iw_point *wrqu, char *extra);
880 int rtw_mp_start(struct net_device *dev,
881 			struct iw_request_info *info,
882 			struct iw_point *wrqu, char *extra);
883 int rtw_mp_stop(struct net_device *dev,
884 			struct iw_request_info *info,
885 			struct iw_point *wrqu, char *extra);
886 int rtw_mp_rate(struct net_device *dev,
887 			struct iw_request_info *info,
888 			struct iw_point *wrqu, char *extra);
889 int rtw_mp_channel(struct net_device *dev,
890 			struct iw_request_info *info,
891 			struct iw_point *wrqu, char *extra);
892 int rtw_mp_bandwidth(struct net_device *dev,
893 			struct iw_request_info *info,
894 			struct iw_point *wrqu, char *extra);
895 int rtw_mp_txpower_index(struct net_device *dev,
896 			struct iw_request_info *info,
897 			struct iw_point *wrqu, char *extra);
898 int rtw_mp_txpower(struct net_device *dev,
899 			struct iw_request_info *info,
900 			struct iw_point *wrqu, char *extra);
901 int rtw_mp_txpower(struct net_device *dev,
902 			struct iw_request_info *info,
903 			struct iw_point *wrqu, char *extra);
904 int rtw_mp_ant_tx(struct net_device *dev,
905 			struct iw_request_info *info,
906 			struct iw_point *wrqu, char *extra);
907 int rtw_mp_ant_rx(struct net_device *dev,
908 			struct iw_request_info *info,
909 			struct iw_point *wrqu, char *extra);
910 int rtw_set_ctx_destAddr(struct net_device *dev,
911 			struct iw_request_info *info,
912 			struct iw_point *wrqu, char *extra);
913 int rtw_mp_ctx(struct net_device *dev,
914 			struct iw_request_info *info,
915 			struct iw_point *wrqu, char *extra);
916 int rtw_mp_disable_bt_coexist(struct net_device *dev,
917 			struct iw_request_info *info,
918 			union iwreq_data *wrqu, char *extra);
919 int rtw_mp_disable_bt_coexist(struct net_device *dev,
920 			struct iw_request_info *info,
921 			union iwreq_data *wrqu, char *extra);
922 int rtw_mp_arx(struct net_device *dev,
923 			struct iw_request_info *info,
924 			struct iw_point *wrqu, char *extra);
925 int rtw_mp_trx_query(struct net_device *dev,
926 			struct iw_request_info *info,
927 			struct iw_point *wrqu, char *extra);
928 int rtw_mp_pwrtrk(struct net_device *dev,
929 			struct iw_request_info *info,
930 			struct iw_point *wrqu, char *extra);
931 int rtw_mp_psd(struct net_device *dev,
932 			struct iw_request_info *info,
933 			struct iw_point *wrqu, char *extra);
934 int rtw_mp_thermal(struct net_device *dev,
935 			struct iw_request_info *info,
936 			struct iw_point *wrqu, char *extra);
937 int rtw_mp_reset_stats(struct net_device *dev,
938 			struct iw_request_info *info,
939 			struct iw_point *wrqu, char *extra);
940 int rtw_mp_dump(struct net_device *dev,
941 			struct iw_request_info *info,
942 			struct iw_point *wrqu, char *extra);
943 int rtw_mp_phypara(struct net_device *dev,
944 			struct iw_request_info *info,
945 			struct iw_point *wrqu, char *extra);
946 int rtw_mp_SetRFPath(struct net_device *dev,
947 			struct iw_request_info *info,
948 			union iwreq_data *wrqu, char *extra);
949 int rtw_mp_QueryDrv(struct net_device *dev,
950 			struct iw_request_info *info,
951 			union iwreq_data *wrqu, char *extra);
952 int rtw_mp_PwrCtlDM(struct net_device *dev,
953 			struct iw_request_info *info,
954 			struct iw_point *wrqu, char *extra);
955 int rtw_mp_getver(struct net_device *dev,
956 			struct iw_request_info *info,
957 			union iwreq_data *wrqu, char *extra);
958 int rtw_mp_mon(struct net_device *dev,
959 			struct iw_request_info *info,
960 			union iwreq_data *wrqu, char *extra);
961 int rtw_efuse_mask_file(struct net_device *dev,
962 			struct iw_request_info *info,
963 			union iwreq_data *wrqu, char *extra);
964 int rtw_efuse_file_map(struct net_device *dev,
965 			struct iw_request_info *info,
966 			union iwreq_data *wrqu, char *extra);
967 int rtw_mp_SetBT(struct net_device *dev,
968 			struct iw_request_info *info,
969 			union iwreq_data *wrqu, char *extra);
970 int rtw_mp_pretx_proc(PADAPTER padapter, u8 bStartTest, char *extra);
971 int rtw_mp_tx(struct net_device *dev,
972 			struct iw_request_info *info,
973 			union iwreq_data *wrqu, char *extra);
974 int rtw_mp_rx(struct net_device *dev,
975 			struct iw_request_info *info,
976 			union iwreq_data *wrqu, char *extra);
977 int rtw_mp_hwtx(struct net_device *dev,
978 			struct iw_request_info *info,
979 			union iwreq_data *wrqu, char *extra);
980 u8 HwRateToMPTRate(u8 rate);
981 
982 #endif //_RTW_MP_H_
983 
984