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