• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  * Copyright(c) 2007 - 2017 Realtek Corporation.
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  *****************************************************************************/
15 #ifndef _RTW_MP_H_
16 #define _RTW_MP_H_
17 
18 #define RTWPRIV_VER_INFO	1
19 
20 #define MAX_MP_XMITBUF_SZ	2048
21 #define NR_MP_XMITFRAME		8
22 #define MP_READ_REG_MAX_OFFSET 0x4FFF
23 
24 struct mp_xmit_frame {
25 	_list	list;
26 
27 	struct pkt_attrib attrib;
28 
29 	_pkt *pkt;
30 
31 	int frame_tag;
32 
33 	_adapter *padapter;
34 
35 #ifdef CONFIG_USB_HCI
36 
37 	/* insert urb, irp, and irpcnt info below... */
38 	/* max frag_cnt = 8 */
39 	u8 *mem_addr;
40 	u32 sz[8];
41 	u8 bpending[8];
42 	sint ac_tag[8];
43 	sint last[8];
44 	uint irpcnt;
45 	uint fragcnt;
46 #endif /* CONFIG_USB_HCI */
47 
48 	uint mem[(MAX_MP_XMITBUF_SZ >> 2)];
49 };
50 
51 struct mp_wiparam {
52 	u32 bcompleted;
53 	u32 act_type;
54 	u32 io_offset;
55 	u32 io_value;
56 };
57 
58 typedef void(*wi_act_func)(void *padapter);
59 
60 struct mp_tx {
61 	u8 stop;
62 	u32 count, sended;
63 	u8 payload;
64 	struct pkt_attrib attrib;
65 	/* struct tx_desc desc; */
66 	/* u8 resvdtx[7]; */
67 	u8 desc[TXDESC_SIZE];
68 	u8 *pallocated_buf;
69 	u8 *buf;
70 	u32 buf_size, write_size;
71 	_thread_hdl_ PktTxThread;
72 };
73 
74 #define MP_MAX_LINES		1000
75 #define MP_MAX_LINES_BYTES	256
76 
77 
78 typedef struct _RT_PMAC_PKT_INFO {
79 	u8			MCS;
80 	u8			Nss;
81 	u8			Nsts;
82 	u32			N_sym;
83 	u8			SIGA2B3;
84 } RT_PMAC_PKT_INFO, *PRT_PMAC_PKT_INFO;
85 
86 typedef struct _RT_PMAC_TX_INFO {
87 	u8			bEnPMacTx:1;		/* 0: Disable PMac 1: Enable PMac */
88 	u8			Mode:3;				/* 0: Packet TX 3:Continuous TX */
89 	u8			Ntx:4;				/* 0-7 */
90 	u8			TX_RATE;			/* MPT_RATE_E */
91 	u8			TX_RATE_HEX;
92 	u8			TX_SC;
93 	u8			bSGI:1;
94 	u8			bSPreamble:1;
95 	u8			bSTBC:1;
96 	u8			bLDPC:1;
97 	u8			NDP_sound:1;
98 	u8			BandWidth:3;		/* 0: 20 1:40 2:80Mhz */
99 	u8			m_STBC;			/* bSTBC + 1 */
100 	u16			PacketPeriod;
101 	u32		PacketCount;
102 	u32		PacketLength;
103 	u8			PacketPattern;
104 	u16			SFD;
105 	u8			SignalField;
106 	u8			ServiceField;
107 	u16			LENGTH;
108 	u8			CRC16[2];
109 	u8			LSIG[3];
110 	u8			HT_SIG[6];
111 	u8			VHT_SIG_A[6];
112 	u8			VHT_SIG_B[4];
113 	u8			VHT_SIG_B_CRC;
114 	u8			VHT_Delimiter[4];
115 	u8			MacAddress[6];
116 } RT_PMAC_TX_INFO, *PRT_PMAC_TX_INFO;
117 
118 
119 typedef void (*MPT_WORK_ITEM_HANDLER)(void *Adapter);
120 typedef struct _MPT_CONTEXT {
121 	/* Indicate if we have started Mass Production Test. */
122 	BOOLEAN			bMassProdTest;
123 
124 	/* Indicate if the driver is unloading or unloaded. */
125 	BOOLEAN			bMptDrvUnload;
126 
127 	_sema			MPh2c_Sema;
128 	_timer			MPh2c_timeout_timer;
129 	/* Event used to sync H2c for BT control */
130 
131 	BOOLEAN		MptH2cRspEvent;
132 	BOOLEAN		MptBtC2hEvent;
133 	BOOLEAN		bMPh2c_timeout;
134 
135 	/* 8190 PCI does not support NDIS_WORK_ITEM. */
136 	/* Work Item for Mass Production Test. */
137 	/* NDIS_WORK_ITEM	MptWorkItem;
138 	*	RT_WORK_ITEM		MptWorkItem; */
139 	/* Event used to sync the case unloading driver and MptWorkItem is still in progress.
140 	*	NDIS_EVENT		MptWorkItemEvent; */
141 	/* To protect the following variables.
142 	*	NDIS_SPIN_LOCK		MptWorkItemSpinLock; */
143 	/* Indicate a MptWorkItem is scheduled and not yet finished. */
144 	BOOLEAN			bMptWorkItemInProgress;
145 	/* An instance which implements function and context of MptWorkItem. */
146 	MPT_WORK_ITEM_HANDLER	CurrMptAct;
147 
148 	/* 1=Start, 0=Stop from UI. */
149 	u32			MptTestStart;
150 	/* _TEST_MODE, defined in MPT_Req2.h */
151 	u32			MptTestItem;
152 	/* Variable needed in each implementation of CurrMptAct. */
153 	u32			MptActType;	/* Type of action performed in CurrMptAct. */
154 	/* The Offset of IO operation is depend of MptActType. */
155 	u32			MptIoOffset;
156 	/* The Value of IO operation is depend of MptActType. */
157 	u32			MptIoValue;
158 	/* The RfPath of IO operation is depend of MptActType. */
159 
160 	u32			mpt_rf_path;
161 
162 
163 	WIRELESS_MODE		MptWirelessModeToSw;	/* Wireless mode to switch. */
164 	u8			MptChannelToSw;	/* Channel to switch. */
165 	u8			MptInitGainToSet;	/* Initial gain to set. */
166 	/* u32			bMptAntennaA;		 */ /* TRUE if we want to use antenna A. */
167 	u32			MptBandWidth;		/* bandwidth to switch. */
168 
169 	u32			mpt_rate_index;/* rate index. */
170 
171 	/* Register value kept for Single Carrier Tx test. */
172 	u8			btMpCckTxPower;
173 	/* Register value kept for Single Carrier Tx test. */
174 	u8			btMpOfdmTxPower;
175 	/* For MP Tx Power index */
176 	u8			TxPwrLevel[4];	/* rf-A, rf-B*/
177 	u32			RegTxPwrLimit;
178 	/* Content of RCR Regsiter for Mass Production Test. */
179 	u32			MptRCR;
180 	/* TRUE if we only receive packets with specific pattern. */
181 	BOOLEAN			bMptFilterPattern;
182 	/* Rx OK count, statistics used in Mass Production Test. */
183 	u32			MptRxOkCnt;
184 	/* Rx CRC32 error count, statistics used in Mass Production Test. */
185 	u32			MptRxCrcErrCnt;
186 
187 	BOOLEAN			bCckContTx;	/* TRUE if we are in CCK Continuous Tx test. */
188 	BOOLEAN			bOfdmContTx;	/* TRUE if we are in OFDM Continuous Tx test. */
189 		/* TRUE if we have start Continuous Tx test. */
190 	BOOLEAN			is_start_cont_tx;
191 
192 	/* TRUE if we are in Single Carrier Tx test. */
193 	BOOLEAN			bSingleCarrier;
194 	/* TRUE if we are in Carrier Suppression Tx Test. */
195 
196 	BOOLEAN			is_carrier_suppression;
197 
198 	/* TRUE if we are in Single Tone Tx test. */
199 
200 	BOOLEAN			is_single_tone;
201 
202 
203 	/* ACK counter asked by K.Y.. */
204 	BOOLEAN			bMptEnableAckCounter;
205 	u32			MptAckCounter;
206 
207 	/* SD3 Willis For 8192S to save 1T/2T RF table for ACUT	Only fro ACUT delete later ~~~! */
208 	/* s8		BufOfLines[2][MAX_LINES_HWCONFIG_TXT][MAX_BYTES_LINE_HWCONFIG_TXT]; */
209 	/* s8			BufOfLines[2][MP_MAX_LINES][MP_MAX_LINES_BYTES]; */
210 	/* s32			RfReadLine[2]; */
211 
212 	u8		APK_bound[2];	/* for APK	path A/path B */
213 	BOOLEAN		bMptIndexEven;
214 
215 	u8		backup0xc50;
216 	u8		backup0xc58;
217 	u8		backup0xc30;
218 	u8		backup0x52_RF_A;
219 	u8		backup0x52_RF_B;
220 
221 	u32			backup0x58_RF_A;
222 	u32			backup0x58_RF_B;
223 
224 	u8			h2cReqNum;
225 	u8			c2hBuf[32];
226 
227 	u8          btInBuf[100];
228 	u32			mptOutLen;
229 	u8          mptOutBuf[100];
230 	RT_PMAC_TX_INFO	PMacTxInfo;
231 	RT_PMAC_PKT_INFO	PMacPktInfo;
232 	u8 HWTxmode;
233 
234 	BOOLEAN			bldpc;
235 	BOOLEAN			bstbc;
236 } MPT_CONTEXT, *PMPT_CONTEXT;
237 /* #endif */
238 
239 
240 /* #define RTPRIV_IOCTL_MP					( SIOCIWFIRSTPRIV + 0x17) */
241 enum {
242 	WRITE_REG = 1,
243 	READ_REG,
244 	WRITE_RF,
245 	READ_RF,
246 	MP_START,
247 	MP_STOP,
248 	MP_RATE,
249 	MP_CHANNEL,
250 	MP_CHL_OFFSET,
251 	MP_BANDWIDTH,
252 	MP_TXPOWER,
253 	MP_ANT_TX,
254 	MP_ANT_RX,
255 	MP_CTX,
256 	MP_QUERY,
257 	MP_ARX,
258 	MP_PSD,
259 	MP_PWRTRK,
260 	MP_THER,
261 	MP_IOCTL,
262 	EFUSE_GET,
263 	EFUSE_SET,
264 	MP_RESET_STATS,
265 	MP_DUMP,
266 	MP_PHYPARA,
267 	MP_SetRFPathSwh,
268 	MP_QueryDrvStats,
269 	CTA_TEST,
270 	MP_DISABLE_BT_COEXIST,
271 	MP_PwrCtlDM,
272 	MP_GETVER,
273 	MP_MON,
274 	EFUSE_BT_MASK,
275 	EFUSE_MASK,
276 	EFUSE_FILE,
277 	EFUSE_FILE_STORE,
278 	MP_TX,
279 	MP_RX,
280 	MP_IQK,
281 	MP_LCK,
282 	MP_HW_TX_MODE,
283 	MP_GET_TXPOWER_INX,
284 	MP_CUSTOMER_STR,
285 	MP_PWRLMT,
286 	MP_PWRBYRATE,
287 	BT_EFUSE_FILE,
288 	MP_SetBT,
289 	MP_SWRFPath,
290 	MP_LINK,
291 	MP_DPK_TRK,
292 	MP_DPK,
293 	MP_GET_TSSIDE,
294 	MP_SET_TSSIDE,
295 	MP_NULL,
296 #ifdef CONFIG_APPEND_VENDOR_IE_ENABLE
297 	VENDOR_IE_SET ,
298 	VENDOR_IE_GET ,
299 #endif
300 #ifdef CONFIG_WOWLAN
301 	MP_WOW_ENABLE,
302 	MP_WOW_SET_PATTERN,
303 #ifdef CONFIG_WOW_KEEP_ALIVE_PATTERN
304 	MP_WOW_SET_KEEP_ALIVE_PATTERN,
305 #endif /*CONFIG_WOW_KEEP_ALIVE_PATTERN*/
306 
307 #endif
308 #ifdef CONFIG_AP_WOWLAN
309 	MP_AP_WOW_ENABLE,
310 #endif
311 	MP_SD_IREAD,
312 	MP_SD_IWRITE,
313 	GET_IC_TYPE,
314 };
315 
316 struct mp_priv {
317 	_adapter *papdater;
318 
319 	/* Testing Flag */
320 	u32 mode;/* 0 for normal type packet, 1 for loopback packet (16bytes TXCMD) */
321 
322 	u32 prev_fw_state;
323 
324 	/* OID cmd handler */
325 	struct mp_wiparam workparam;
326 	/*	u8 act_in_progress; */
327 
328 	/* Tx Section */
329 	u8 TID;
330 	u32 tx_pktcount;
331 	u32 pktInterval;
332 	u32 pktLength;
333 	struct mp_tx tx;
334 
335 	/* Rx Section */
336 	u32 rx_bssidpktcount;
337 	u32 rx_pktcount;
338 	u32 rx_pktcount_filter_out;
339 	u32 rx_crcerrpktcount;
340 	u32 rx_pktloss;
341 	BOOLEAN  rx_bindicatePkt;
342 	struct recv_stat rxstat;
343 	BOOLEAN brx_filter_beacon;
344 
345 	/* RF/BB relative */
346 	u8 channel;
347 	u8 bandwidth;
348 	u8 prime_channel_offset;
349 	u8 txpoweridx;
350 	s8 txpower_dbm_offset;
351 	u8 rateidx;
352 	u32 preamble;
353 	/*	u8 modem; */
354 	u32 CrystalCap;
355 	/*	u32 curr_crystalcap; */
356 
357 	u16 antenna_tx;
358 	u16 antenna_rx;
359 	/*	u8 curr_rfpath; */
360 
361 	u8 check_mp_pkt;
362 
363 	u8 bSetTxPower;
364 	/*	uint ForcedDataRate; */
365 	u8 mp_dm;
366 	u8 mac_filter[ETH_ALEN];
367 	u8 bmac_filter;
368 
369 	/* RF PATH Setting for WLG WLA BTG BT */
370 	u8 rf_path_cfg;
371 
372 	struct wlan_network mp_network;
373 	NDIS_802_11_MAC_ADDRESS network_macaddr;
374 
375 	u8 *pallocated_mp_xmitframe_buf;
376 	u8 *pmp_xmtframe_buf;
377 	_queue free_mp_xmitqueue;
378 	u32 free_mp_xmitframe_cnt;
379 	BOOLEAN bSetRxBssid;
380 	BOOLEAN bTxBufCkFail;
381 	BOOLEAN bRTWSmbCfg;
382 	BOOLEAN bloopback;
383 	BOOLEAN bloadefusemap;
384 	BOOLEAN bloadBTefusemap;
385 	BOOLEAN bprocess_mp_mode;
386 
387 	MPT_CONTEXT	mpt_ctx;
388 
389 	u8		*TXradomBuffer;
390 	u8		CureFuseBTCoex;
391     u8		mplink_buf[2048];
392     u32		mplink_rx_len;
393 	BOOLEAN mplink_brx;
394 	BOOLEAN mplink_btx;
395 
396 	bool tssitrk_on;
397 	bool efuse_update_on;
398 	bool efuse_update_file;
399 	char efuse_file_path[128];
400 };
401 
402 typedef struct _IOCMD_STRUCT_ {
403 	u8	cmdclass;
404 	u16	value;
405 	u8	index;
406 } IOCMD_STRUCT;
407 
408 struct rf_reg_param {
409 	u32 path;
410 	u32 offset;
411 	u32 value;
412 };
413 
414 struct bb_reg_param {
415 	u32 offset;
416 	u32 value;
417 };
418 
419 typedef struct _MP_FIRMWARE {
420 	FIRMWARE_SOURCE eFWSource;
421 #ifdef CONFIG_EMBEDDED_FWIMG
422 	u8		*szFwBuffer;
423 #else
424 	u8			szFwBuffer[0x8000];
425 #endif
426 	u32		ulFwLength;
427 } RT_MP_FIRMWARE, *PRT_MP_FIRMWARE;
428 
429 
430 #define GET_MPPRIV(__padapter) (struct mp_priv*)(&(((struct _ADAPTER*)__padapter)->mppriv))
431 #define GET_EFUSE_UPDATE_ON(_padapter)	(GET_MPPRIV(_padapter)->efuse_update_on)
432 
433 /* *********************************************************************** */
434 
435 #define LOWER	_TRUE
436 #define RAISE	_FALSE
437 
438 /* Hardware Registers */
439 #if 0
440 #if 0
441 #define IOCMD_CTRL_REG			0x102502C0
442 #define IOCMD_DATA_REG			0x102502C4
443 #else
444 #define IOCMD_CTRL_REG			0x10250370
445 #define IOCMD_DATA_REG			0x10250374
446 #endif
447 
448 #define IOCMD_GET_THERMAL_METER		0xFD000028
449 
450 #define IOCMD_CLASS_BB_RF		0xF0
451 #define IOCMD_BB_READ_IDX		0x00
452 #define IOCMD_BB_WRITE_IDX		0x01
453 #define IOCMD_RF_READ_IDX		0x02
454 #define IOCMD_RF_WRIT_IDX		0x03
455 #endif
456 #define BB_REG_BASE_ADDR		0x800
457 
458 /* MP variables */
459 #if 0
460 #define _2MAC_MODE_	0
461 #define _LOOPBOOK_MODE_	1
462 #endif
463 typedef enum _MP_MODE_ {
464 	MP_OFF,
465 	MP_ON,
466 	MP_ERR,
467 	MP_CONTINUOUS_TX,
468 	MP_SINGLE_CARRIER_TX,
469 	MP_CARRIER_SUPPRISSION_TX,
470 	MP_SINGLE_TONE_TX,
471 	MP_PACKET_TX,
472 	MP_PACKET_RX
473 } MP_MODE;
474 
475 typedef enum _TEST_MODE {
476 	TEST_NONE                 ,
477 	PACKETS_TX                ,
478 	PACKETS_RX                ,
479 	CONTINUOUS_TX             ,
480 	OFDM_Single_Tone_TX       ,
481 	CCK_Carrier_Suppression_TX
482 } TEST_MODE;
483 
484 
485 typedef enum _MPT_BANDWIDTH {
486 	MPT_BW_20MHZ = 0,
487 	MPT_BW_40MHZ_DUPLICATE = 1,
488 	MPT_BW_40MHZ_ABOVE = 2,
489 	MPT_BW_40MHZ_BELOW = 3,
490 	MPT_BW_40MHZ = 4,
491 	MPT_BW_80MHZ = 5,
492 	MPT_BW_80MHZ_20_ABOVE = 6,
493 	MPT_BW_80MHZ_20_BELOW = 7,
494 	MPT_BW_80MHZ_20_BOTTOM = 8,
495 	MPT_BW_80MHZ_20_TOP = 9,
496 	MPT_BW_80MHZ_40_ABOVE = 10,
497 	MPT_BW_80MHZ_40_BELOW = 11,
498 } MPT_BANDWIDTHE, *PMPT_BANDWIDTH;
499 
500 #define MAX_RF_PATH_NUMS	RF_PATH_MAX
501 
502 
503 extern u8 mpdatarate[NumRates];
504 
505 /* MP set force data rate base on the definition. */
506 typedef enum _MPT_RATE_INDEX {
507 	/* CCK rate. */
508 	MPT_RATE_1M = 1 ,	/* 0 */
509 	MPT_RATE_2M,
510 	MPT_RATE_55M,
511 	MPT_RATE_11M,	/* 3 */
512 
513 	/* OFDM rate. */
514 	MPT_RATE_6M,	/* 4 */
515 	MPT_RATE_9M,
516 	MPT_RATE_12M,
517 	MPT_RATE_18M,
518 	MPT_RATE_24M,
519 	MPT_RATE_36M,
520 	MPT_RATE_48M,
521 	MPT_RATE_54M,	/* 11 */
522 
523 	/* HT rate. */
524 	MPT_RATE_MCS0,	/* 12 */
525 	MPT_RATE_MCS1,
526 	MPT_RATE_MCS2,
527 	MPT_RATE_MCS3,
528 	MPT_RATE_MCS4,
529 	MPT_RATE_MCS5,
530 	MPT_RATE_MCS6,
531 	MPT_RATE_MCS7,	/* 19 */
532 	MPT_RATE_MCS8,
533 	MPT_RATE_MCS9,
534 	MPT_RATE_MCS10,
535 	MPT_RATE_MCS11,
536 	MPT_RATE_MCS12,
537 	MPT_RATE_MCS13,
538 	MPT_RATE_MCS14,
539 	MPT_RATE_MCS15,	/* 27 */
540 	MPT_RATE_MCS16,
541 	MPT_RATE_MCS17, /*  #29 */
542 	MPT_RATE_MCS18,
543 	MPT_RATE_MCS19,
544 	MPT_RATE_MCS20,
545 	MPT_RATE_MCS21,
546 	MPT_RATE_MCS22, /*  #34 */
547 	MPT_RATE_MCS23,
548 	MPT_RATE_MCS24,
549 	MPT_RATE_MCS25,
550 	MPT_RATE_MCS26,
551 	MPT_RATE_MCS27, /*  #39 */
552 	MPT_RATE_MCS28, /*  #40 */
553 	MPT_RATE_MCS29, /*  #41 */
554 	MPT_RATE_MCS30, /*  #42 */
555 	MPT_RATE_MCS31, /*  #43 */
556 	/* VHT rate. Total: 20*/
557 	MPT_RATE_VHT1SS_MCS0 = 100,/*  #44*/
558 	MPT_RATE_VHT1SS_MCS1, /*  # */
559 	MPT_RATE_VHT1SS_MCS2,
560 	MPT_RATE_VHT1SS_MCS3,
561 	MPT_RATE_VHT1SS_MCS4,
562 	MPT_RATE_VHT1SS_MCS5,
563 	MPT_RATE_VHT1SS_MCS6, /*  # */
564 	MPT_RATE_VHT1SS_MCS7,
565 	MPT_RATE_VHT1SS_MCS8,
566 	MPT_RATE_VHT1SS_MCS9, /* #53 */
567 	MPT_RATE_VHT2SS_MCS0, /* #54 */
568 	MPT_RATE_VHT2SS_MCS1,
569 	MPT_RATE_VHT2SS_MCS2,
570 	MPT_RATE_VHT2SS_MCS3,
571 	MPT_RATE_VHT2SS_MCS4,
572 	MPT_RATE_VHT2SS_MCS5,
573 	MPT_RATE_VHT2SS_MCS6,
574 	MPT_RATE_VHT2SS_MCS7,
575 	MPT_RATE_VHT2SS_MCS8,
576 	MPT_RATE_VHT2SS_MCS9, /* #63 */
577 	MPT_RATE_VHT3SS_MCS0,
578 	MPT_RATE_VHT3SS_MCS1,
579 	MPT_RATE_VHT3SS_MCS2,
580 	MPT_RATE_VHT3SS_MCS3,
581 	MPT_RATE_VHT3SS_MCS4,
582 	MPT_RATE_VHT3SS_MCS5,
583 	MPT_RATE_VHT3SS_MCS6, /*  #126 */
584 	MPT_RATE_VHT3SS_MCS7,
585 	MPT_RATE_VHT3SS_MCS8,
586 	MPT_RATE_VHT3SS_MCS9,
587 	MPT_RATE_VHT4SS_MCS0,
588 	MPT_RATE_VHT4SS_MCS1, /*  #131 */
589 	MPT_RATE_VHT4SS_MCS2,
590 	MPT_RATE_VHT4SS_MCS3,
591 	MPT_RATE_VHT4SS_MCS4,
592 	MPT_RATE_VHT4SS_MCS5,
593 	MPT_RATE_VHT4SS_MCS6, /*  #136 */
594 	MPT_RATE_VHT4SS_MCS7,
595 	MPT_RATE_VHT4SS_MCS8,
596 	MPT_RATE_VHT4SS_MCS9,
597 	MPT_RATE_LAST
598 } MPT_RATE_E, *PMPT_RATE_E;
599 
600 #define MAX_TX_PWR_INDEX_N_MODE 64	/* 0x3F */
601 
602 #define MPT_IS_CCK_RATE(_value)		(MPT_RATE_1M <= _value && _value <= MPT_RATE_11M)
603 #define MPT_IS_OFDM_RATE(_value)	(MPT_RATE_6M <= _value && _value <= MPT_RATE_54M)
604 #define MPT_IS_HT_RATE(_value)		(MPT_RATE_MCS0 <= _value && _value <= MPT_RATE_MCS31)
605 #define MPT_IS_HT_1S_RATE(_value)	(MPT_RATE_MCS0 <= _value && _value <= MPT_RATE_MCS7)
606 #define MPT_IS_HT_2S_RATE(_value)	(MPT_RATE_MCS8 <= _value && _value <= MPT_RATE_MCS15)
607 #define MPT_IS_HT_3S_RATE(_value)	(MPT_RATE_MCS16 <= _value && _value <= MPT_RATE_MCS23)
608 #define MPT_IS_HT_4S_RATE(_value)	(MPT_RATE_MCS24 <= _value && _value <= MPT_RATE_MCS31)
609 
610 #define MPT_IS_VHT_RATE(_value)		(MPT_RATE_VHT1SS_MCS0 <= _value && _value <= MPT_RATE_VHT4SS_MCS9)
611 #define MPT_IS_VHT_1S_RATE(_value)	(MPT_RATE_VHT1SS_MCS0 <= _value && _value <= MPT_RATE_VHT1SS_MCS9)
612 #define MPT_IS_VHT_2S_RATE(_value)	(MPT_RATE_VHT2SS_MCS0 <= _value && _value <= MPT_RATE_VHT2SS_MCS9)
613 #define MPT_IS_VHT_3S_RATE(_value)	(MPT_RATE_VHT3SS_MCS0 <= _value && _value <= MPT_RATE_VHT3SS_MCS9)
614 #define MPT_IS_VHT_4S_RATE(_value)	(MPT_RATE_VHT4SS_MCS0 <= _value && _value <= MPT_RATE_VHT4SS_MCS9)
615 
616 #define MPT_IS_2SS_RATE(_rate) ((MPT_RATE_MCS8 <= _rate && _rate <= MPT_RATE_MCS15) || \
617 	(MPT_RATE_VHT2SS_MCS0 <= _rate && _rate <= MPT_RATE_VHT2SS_MCS9))
618 #define MPT_IS_3SS_RATE(_rate) ((MPT_RATE_MCS16 <= _rate && _rate <= MPT_RATE_MCS23) || \
619 	(MPT_RATE_VHT3SS_MCS0 <= _rate && _rate <= MPT_RATE_VHT3SS_MCS9))
620 #define MPT_IS_4SS_RATE(_rate) ((MPT_RATE_MCS24 <= _rate && _rate <= MPT_RATE_MCS31) || \
621 	(MPT_RATE_VHT4SS_MCS0 <= _rate && _rate <= MPT_RATE_VHT4SS_MCS9))
622 
623 typedef enum _POWER_MODE_ {
624 	POWER_LOW = 0,
625 	POWER_NORMAL
626 } POWER_MODE;
627 
628 /* The following enumeration is used to define the value of Reg0xD00[30:28] or JaguarReg0x914[18:16]. */
629 typedef enum _OFDM_TX_MODE {
630 	OFDM_ALL_OFF		= 0,
631 	OFDM_ContinuousTx	= 1,
632 	OFDM_SingleCarrier	= 2,
633 	OFDM_SingleTone	= 4,
634 } OFDM_TX_MODE;
635 
636 
637 #define RX_PKT_BROADCAST	1
638 #define RX_PKT_DEST_ADDR	2
639 #define RX_PKT_PHY_MATCH	3
640 
641 typedef enum _ENCRY_CTRL_STATE_ {
642 	HW_CONTROL,		/* hw encryption& decryption */
643 	SW_CONTROL,		/* sw encryption& decryption */
644 	HW_ENCRY_SW_DECRY,	/* hw encryption & sw decryption */
645 	SW_ENCRY_HW_DECRY	/* sw encryption & hw decryption */
646 } ENCRY_CTRL_STATE;
647 
648 typedef enum	_MPT_TXPWR_DEF {
649 	MPT_CCK,
650 	MPT_OFDM, /* L and HT OFDM */
651 	MPT_OFDM_AND_HT,
652 	MPT_HT,
653 	MPT_VHT
654 } MPT_TXPWR_DEF;
655 
656 
657 #define IS_MPT_HT_RATE(_rate)			(_rate >= MPT_RATE_MCS0 && _rate <= MPT_RATE_MCS31)
658 #define IS_MPT_VHT_RATE(_rate)			(_rate >= MPT_RATE_VHT1SS_MCS0 && _rate <= MPT_RATE_VHT4SS_MCS9)
659 #define IS_MPT_CCK_RATE(_rate)			(_rate >= MPT_RATE_1M && _rate <= MPT_RATE_11M)
660 #define IS_MPT_OFDM_RATE(_rate)			(_rate >= MPT_RATE_6M && _rate <= MPT_RATE_54M)
661 
662 typedef enum _mp_tx_pkt_payload{
663 	MP_TX_Payload_00 = 0,
664 	MP_TX_Payload_a5,
665 	MP_TX_Payload_5a,
666 	MP_TX_Payload_ff,
667 	MP_TX_Payload_prbs9,
668 	MP_TX_Payload_default_random
669 } mp_tx_pkt_payload;
670 
671 /*************************************************************************/
672 #if 0
673 extern struct mp_xmit_frame *alloc_mp_xmitframe(struct mp_priv *pmp_priv);
674 extern int free_mp_xmitframe(struct xmit_priv *pxmitpriv, struct mp_xmit_frame *pmp_xmitframe);
675 #endif
676 
677 extern s32 init_mp_priv(PADAPTER padapter);
678 extern void free_mp_priv(struct mp_priv *pmp_priv);
679 extern s32 MPT_InitializeAdapter(PADAPTER padapter, u8 Channel);
680 extern void MPT_DeInitAdapter(PADAPTER padapter);
681 extern s32 mp_start_test(PADAPTER padapter);
682 extern void mp_stop_test(PADAPTER padapter);
683 
684 extern u32 _read_rfreg(PADAPTER padapter, u8 rfpath, u32 addr, u32 bitmask);
685 extern void _write_rfreg(PADAPTER padapter, u8 rfpath, u32 addr, u32 bitmask, u32 val);
686 
687 extern u32 read_macreg(_adapter *padapter, u32 addr, u32 sz);
688 extern void write_macreg(_adapter *padapter, u32 addr, u32 val, u32 sz);
689 extern u32 read_bbreg(_adapter *padapter, u32 addr, u32 bitmask);
690 extern void write_bbreg(_adapter *padapter, u32 addr, u32 bitmask, u32 val);
691 extern u32 read_rfreg(PADAPTER padapter, u8 rfpath, u32 addr);
692 extern void write_rfreg(PADAPTER padapter, u8 rfpath, u32 addr, u32 val);
693 #ifdef CONFIG_ANTENNA_DIVERSITY
694 u8 rtw_mp_set_antdiv(PADAPTER padapter, BOOLEAN bMain);
695 #endif
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 rfpath ,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 void	rtw_mp_trigger_iqk(PADAPTER padapter);
719 void	rtw_mp_trigger_lck(PADAPTER padapter);
720 void	rtw_mp_trigger_dpk(PADAPTER padapter);
721 u8 rtw_mp_mode_check(PADAPTER padapter);
722 bool rtw_is_mp_tssitrk_on(_adapter *adapter);
723 
724 void hal_mpt_SwitchRfSetting(PADAPTER pAdapter);
725 s32 hal_mpt_SetPowerTracking(PADAPTER padapter, u8 enable);
726 void hal_mpt_GetPowerTracking(PADAPTER padapter, u8 *enable);
727 void hal_mpt_CCKTxPowerAdjust(PADAPTER Adapter, BOOLEAN bInCH14);
728 void hal_mpt_SetChannel(PADAPTER pAdapter);
729 void hal_mpt_SetBandwidth(PADAPTER pAdapter);
730 void hal_mpt_SetTxPower(PADAPTER pAdapter);
731 void hal_mpt_SetDataRate(PADAPTER pAdapter);
732 void hal_mpt_SetAntenna(PADAPTER pAdapter);
733 s32 hal_mpt_SetThermalMeter(PADAPTER pAdapter, u8 target_ther);
734 void hal_mpt_TriggerRFThermalMeter(PADAPTER pAdapter);
735 u8 hal_mpt_ReadRFThermalMeter(PADAPTER pAdapter, u8 rf_path);
736 void hal_mpt_GetThermalMeter(PADAPTER pAdapter, u8 rfpath, u8 *value);
737 void hal_mpt_SetContinuousTx(PADAPTER pAdapter, u8 bStart);
738 void hal_mpt_SetSingleCarrierTx(PADAPTER pAdapter, u8 bStart);
739 void hal_mpt_SetSingleToneTx(PADAPTER pAdapter, u8 bStart);
740 void hal_mpt_SetCarrierSuppressionTx(PADAPTER pAdapter, u8 bStart);
741 u8 mpt_ProSetPMacTx(PADAPTER	Adapter);
742 void MP_PHY_SetRFPathSwitch(PADAPTER pAdapter , BOOLEAN bMain);
743 void mp_phy_switch_rf_path_set(PADAPTER pAdapter , u8 *pstate);
744 u8 MP_PHY_QueryRFPathSwitch(PADAPTER pAdapter);
745 u32 mpt_ProQueryCalTxPower(PADAPTER	pAdapter, u8 RfPath);
746 void MPT_PwrCtlDM(PADAPTER padapter, u32 trk_type);
747 u8 mpt_to_mgnt_rate(u32	MptRateIdx);
748 u8 rtw_mpRateParseFunc(PADAPTER pAdapter, u8 *targetStr);
749 u32 mp_join(PADAPTER padapter, u8 mode);
750 u32 hal_mpt_query_phytxok(PADAPTER	pAdapter);
751 u32 mpt_get_tx_power_finalabs_val(PADAPTER	padapter, u8 rf_path);
752 void mpt_trigger_tssi_tracking(PADAPTER pAdapter, u8 rf_path);
753 u32 hal_mpt_tssi_turn_target_power(PADAPTER padapter, s16 power_offset, u8 path);
754 s16 hal_mpt_get_tx_power_mdbm(_adapter *padapter, u8 rf_path);
755 
756 
757 void
758 PMAC_Get_Pkt_Param(
759 	PRT_PMAC_TX_INFO	pPMacTxInfo,
760 	PRT_PMAC_PKT_INFO	pPMacPktInfo
761 );
762 void
763 CCK_generator(
764 	PRT_PMAC_TX_INFO	pPMacTxInfo,
765 	PRT_PMAC_PKT_INFO	pPMacPktInfo
766 );
767 void
768 PMAC_Nsym_generator(
769 	PRT_PMAC_TX_INFO	pPMacTxInfo,
770 	PRT_PMAC_PKT_INFO	pPMacPktInfo
771 );
772 void
773 L_SIG_generator(
774 	u32	N_SYM,		/* Max: 750*/
775 	PRT_PMAC_TX_INFO	pPMacTxInfo,
776 	PRT_PMAC_PKT_INFO	pPMacPktInfo
777 );
778 
779 void HT_SIG_generator(
780 	PRT_PMAC_TX_INFO	pPMacTxInfo,
781 	PRT_PMAC_PKT_INFO	pPMacPktInfo);
782 
783 void VHT_SIG_A_generator(
784 	PRT_PMAC_TX_INFO	pPMacTxInfo,
785 	PRT_PMAC_PKT_INFO	pPMacPktInfo);
786 
787 void VHT_SIG_B_generator(
788 	PRT_PMAC_TX_INFO	pPMacTxInfo);
789 
790 void VHT_Delimiter_generator(
791 	PRT_PMAC_TX_INFO	pPMacTxInfo);
792 
793 
794 int rtw_mp_write_reg(struct net_device *dev,
795 		struct iw_request_info *info,
796 		struct iw_point *wrqu, char *extra);
797 int rtw_mp_read_reg(struct net_device *dev,
798 		struct iw_request_info *info,
799 		struct iw_point *wrqu, char *extra);
800 int rtw_mp_write_rf(struct net_device *dev,
801 		struct iw_request_info *info,
802 		struct iw_point *wrqu, char *extra);
803 int rtw_mp_read_rf(struct net_device *dev,
804 		struct iw_request_info *info,
805 		struct iw_point *wrqu, char *extra);
806 int rtw_mp_start(struct net_device *dev,
807 		struct iw_request_info *info,
808 		struct iw_point *wrqu, char *extra);
809 int rtw_mp_stop(struct net_device *dev,
810 		struct iw_request_info *info,
811 		struct iw_point *wrqu, char *extra);
812 int rtw_mp_rate(struct net_device *dev,
813 		struct iw_request_info *info,
814 		struct iw_point *wrqu, char *extra);
815 int rtw_mp_channel(struct net_device *dev,
816 		struct iw_request_info *info,
817 		struct iw_point *wrqu, char *extra);
818 int rtw_mp_ch_offset(struct net_device *dev,
819 		struct iw_request_info *info,
820 		struct iw_point *wrqu, char *extra);
821 int rtw_mp_bandwidth(struct net_device *dev,
822 		struct iw_request_info *info,
823 		struct iw_point *wrqu, char *extra);
824 int rtw_mp_txpower_index(struct net_device *dev,
825 		struct iw_request_info *info,
826 		struct iw_point *wrqu, char *extra);
827 int rtw_mp_txpower(struct net_device *dev,
828 		struct iw_request_info *info,
829 		struct iw_point *wrqu, char *extra);
830 int rtw_mp_txpower(struct net_device *dev,
831 		struct iw_request_info *info,
832 		struct iw_point *wrqu, char *extra);
833 int rtw_mp_ant_tx(struct net_device *dev,
834 		struct iw_request_info *info,
835 		struct iw_point *wrqu, char *extra);
836 int rtw_mp_ant_rx(struct net_device *dev,
837 		struct iw_request_info *info,
838 		struct iw_point *wrqu, char *extra);
839 int rtw_set_ctx_destAddr(struct net_device *dev,
840 		struct iw_request_info *info,
841 		struct iw_point *wrqu, char *extra);
842 int rtw_mp_ctx(struct net_device *dev,
843 		struct iw_request_info *info,
844 		struct iw_point *wrqu, char *extra);
845 int rtw_mp_disable_bt_coexist(struct net_device *dev,
846 		struct iw_request_info *info,
847 		union iwreq_data *wrqu, char *extra);
848 int rtw_mp_disable_bt_coexist(struct net_device *dev,
849 		struct iw_request_info *info,
850 		union iwreq_data *wrqu, char *extra);
851 int rtw_mp_arx(struct net_device *dev,
852 		struct iw_request_info *info,
853 		struct iw_point *wrqu, char *extra);
854 int rtw_mp_trx_query(struct net_device *dev,
855 		struct iw_request_info *info,
856 		struct iw_point *wrqu, char *extra);
857 int rtw_mp_pwrtrk(struct net_device *dev,
858 		struct iw_request_info *info,
859 		struct iw_point *wrqu, char *extra);
860 int rtw_mp_psd(struct net_device *dev,
861 		struct iw_request_info *info,
862 		struct iw_point *wrqu, char *extra);
863 int rtw_mp_thermal(struct net_device *dev,
864 		struct iw_request_info *info,
865 		struct iw_point *wrqu, char *extra);
866 int rtw_mp_reset_stats(struct net_device *dev,
867 		struct iw_request_info *info,
868 		struct iw_point *wrqu, char *extra);
869 int rtw_mp_dump(struct net_device *dev,
870 		struct iw_request_info *info,
871 		struct iw_point *wrqu, char *extra);
872 int rtw_mp_phypara(struct net_device *dev,
873 		struct iw_request_info *info,
874 		struct iw_point *wrqu, char *extra);
875 int rtw_mp_SetRFPath(struct net_device *dev,
876 		struct iw_request_info *info,
877 		struct iw_point *wrqu, char *extra);
878 int rtw_mp_switch_rf_path(struct net_device *dev,
879 			struct iw_request_info *info,
880 			struct iw_point *wrqu, char *extra);
881 int rtw_mp_link(struct net_device *dev,
882 		struct iw_request_info *info,
883 		struct iw_point *wrqu, char *extra);
884 int rtw_mp_QueryDrv(struct net_device *dev,
885 		struct iw_request_info *info,
886 		union iwreq_data *wrqu, char *extra);
887 int rtw_mp_PwrCtlDM(struct net_device *dev,
888 		struct iw_request_info *info,
889 		struct iw_point *wrqu, char *extra);
890 int rtw_mp_getver(struct net_device *dev,
891 		struct iw_request_info *info,
892 		union iwreq_data *wrqu, char *extra);
893 int rtw_mp_mon(struct net_device *dev,
894 		struct iw_request_info *info,
895 		union iwreq_data *wrqu, char *extra);
896 int rtw_mp_pwrlmt(struct net_device *dev,
897 		struct iw_request_info *info,
898 		union iwreq_data *wrqu, char *extra);
899 int rtw_mp_pwrbyrate(struct net_device *dev,
900 		struct iw_request_info *info,
901 		union iwreq_data *wrqu, char *extra);
902 int rtw_mp_dpk_track(struct net_device *dev,
903 			struct iw_request_info *info,
904 			union iwreq_data *wrqu, char *extra);
905 int rtw_mp_dpk(struct net_device *dev,
906 			struct iw_request_info *info,
907 			union iwreq_data *wrqu, char *extra);
908 int rtw_efuse_mask_file(struct net_device *dev,
909 		struct iw_request_info *info,
910 		union iwreq_data *wrqu, char *extra);
911 int rtw_bt_efuse_mask_file(struct net_device *dev,
912 		struct iw_request_info *info,
913 		union iwreq_data *wrqu, char *extra);
914 int rtw_efuse_file_map(struct net_device *dev,
915 		struct iw_request_info *info,
916 		union iwreq_data *wrqu, char *extra);
917 #if !defined(CONFIG_RTW_ANDROID_GKI)
918 int rtw_efuse_file_map_store(struct net_device *dev,
919 		struct iw_request_info *info,
920 		union iwreq_data *wrqu, char *extra);
921 #endif /* !defined(CONFIG_RTW_ANDROID_GKI) */
922 int rtw_bt_efuse_file_map(struct net_device *dev,
923 		struct iw_request_info *info,
924 		union iwreq_data *wrqu, char *extra);
925 int rtw_mp_SetBT(struct net_device *dev,
926 		struct iw_request_info *info,
927 		union iwreq_data *wrqu, char *extra);
928 int rtw_mp_pretx_proc(PADAPTER padapter, u8 bStartTest, char *extra);
929 int rtw_mp_tx(struct net_device *dev,
930 		struct iw_request_info *info,
931 		union iwreq_data *wrqu, char *extra);
932 int rtw_mp_rx(struct net_device *dev,
933 		struct iw_request_info *info,
934 		union iwreq_data *wrqu, char *extra);
935 int rtw_mp_hwtx(struct net_device *dev,
936 		struct iw_request_info *info,
937 		union iwreq_data *wrqu, char *extra);
938 u8 HwRateToMPTRate(u8 rate);
939 int rtw_mp_iqk(struct net_device *dev,
940 		 struct iw_request_info *info,
941 		 struct iw_point *wrqu, char *extra);
942 int rtw_mp_lck(struct net_device *dev,
943 		struct iw_request_info *info,
944 		struct iw_point *wrqu, char *extra);
945 int rtw_mp_get_tsside(struct net_device *dev,
946 		struct iw_request_info *info,
947 		struct iw_point *wrqu, char *extra);
948 int rtw_mp_set_tsside(struct net_device *dev,
949 		struct iw_request_info *info,
950 		struct iw_point *wrqu, char *extra);
951 #endif /* _RTW_MP_H_ */
952