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