1
2
3
4
5
6
7 #ifndef _RTW_MP_H_
8 #define _RTW_MP_H_
9
10 #define MAX_MP_XMITBUF_SZ 2048
11 #define NR_MP_XMITFRAME 8
12
13 struct mp_xmit_frame
14 {
15 struct list_head list;
16
17 struct pkt_attrib attrib;
18
19 _pkt *pkt;
20
21 int frame_tag;
22
23 struct adapter *padapter;
24
25 uint mem[(MAX_MP_XMITBUF_SZ >> 2)];
26 };
27
28 struct mp_wiparam
29 {
30 u32 bcompleted;
31 u32 act_type;
32 u32 io_offset;
33 u32 io_value;
34 };
35
36 typedef void(*wi_act_func)(void* padapter);
37
38 struct mp_tx
39 {
40 u8 stop;
41 u32 count, sended;
42 u8 payload;
43 struct pkt_attrib attrib;
44
45
46 u8 desc[TXDESC_SIZE];
47 u8 *pallocated_buf;
48 u8 *buf;
49 u32 buf_size, write_size;
50 void *PktTxThread;
51 };
52
53 #define MP_MAX_LINES 1000
54 #define MP_MAX_LINES_BYTES 256
55
56 typedef void (*MPT_WORK_ITEM_HANDLER)(void *Adapter);
57 typedef struct _MPT_CONTEXT
58 {
59
60 bool bMassProdTest;
61
62
63 bool bMptDrvUnload;
64
65 _timer MPh2c_timeout_timer;
66
67
68 bool MptH2cRspEvent;
69 bool MptBtC2hEvent;
70 bool bMPh2c_timeout;
71
72
73
74
75
76
77
78
79
80
81 bool bMptWorkItemInProgress;
82
83 MPT_WORK_ITEM_HANDLER CurrMptAct;
84
85
86 u32 MptTestStart;
87
88 u32 MptTestItem;
89
90 u32 MptActType;
91
92 u32 MptIoOffset;
93
94 u32 MptIoValue;
95
96 u32 MptRfPath;
97
98 enum WIRELESS_MODE MptWirelessModeToSw;
99 u8 MptChannelToSw;
100 u8 MptInitGainToSet;
101 u32 MptBandWidth;
102 u32 MptRateIndex;
103
104 u8 btMpCckTxPower;
105
106 u8 btMpOfdmTxPower;
107
108 u8 TxPwrLevel[2];
109 u32 RegTxPwrLimit;
110
111 u32 MptRCR;
112
113 bool bMptFilterPattern;
114
115 u32 MptRxOkCnt;
116
117 u32 MptRxCrcErrCnt;
118
119 bool bCckContTx;
120 bool bOfdmContTx;
121 bool bStartContTx;
122
123 bool bSingleCarrier;
124
125 bool bCarrierSuppression;
126
127 bool bSingleTone;
128
129
130 bool bMptEnableAckCounter;
131 u32 MptAckCounter;
132
133
134
135
136
137
138 u8 APK_bound[2];
139 bool bMptIndexEven;
140
141 u8 backup0xc50;
142 u8 backup0xc58;
143 u8 backup0xc30;
144 u8 backup0x52_RF_A;
145 u8 backup0x52_RF_B;
146
147 u32 backup0x58_RF_A;
148 u32 backup0x58_RF_B;
149
150 u8 h2cReqNum;
151 u8 c2hBuf[32];
152
153 u8 btInBuf[100];
154 u32 mptOutLen;
155 u8 mptOutBuf[100];
156
157 }MPT_CONTEXT, *PMPT_CONTEXT;
158
159
160
161 #define EFUSE_MAP_SIZE 512
162
163 #define EFUSE_MAX_SIZE 512
164
165
166
167 enum {
168 WRITE_REG = 1,
169 READ_REG,
170 WRITE_RF,
171 READ_RF,
172 MP_START,
173 MP_STOP,
174 MP_RATE,
175 MP_CHANNEL,
176 MP_BANDWIDTH,
177 MP_TXPOWER,
178 MP_ANT_TX,
179 MP_ANT_RX,
180 MP_CTX,
181 MP_QUERY,
182 MP_ARX,
183 MP_PSD,
184 MP_PWRTRK,
185 MP_THER,
186 MP_IOCTL,
187 EFUSE_GET,
188 EFUSE_SET,
189 MP_RESET_STATS,
190 MP_DUMP,
191 MP_PHYPARA,
192 MP_SetRFPathSwh,
193 MP_QueryDrvStats,
194 MP_SetBT,
195 CTA_TEST,
196 MP_DISABLE_BT_COEXIST,
197 MP_PwrCtlDM,
198 #ifdef CONFIG_WOWLAN
199 MP_WOW_ENABLE,
200 #endif
201 #ifdef CONFIG_AP_WOWLAN
202 MP_AP_WOW_ENABLE,
203 #endif
204 MP_NULL,
205 MP_GET_TXPOWER_INX,
206 };
207
208 struct mp_priv
209 {
210 struct adapter *papdater;
211
212
213 u32 mode;
214
215 u32 prev_fw_state;
216
217
218 struct mp_wiparam workparam;
219
220
221
222 u8 TID;
223 u32 tx_pktcount;
224 u32 pktInterval;
225 struct mp_tx tx;
226
227
228 u32 rx_bssidpktcount;
229 u32 rx_pktcount;
230 u32 rx_pktcount_filter_out;
231 u32 rx_crcerrpktcount;
232 u32 rx_pktloss;
233 bool rx_bindicatePkt;
234 struct recv_stat rxstat;
235
236
237 u8 channel;
238 u8 bandwidth;
239 u8 prime_channel_offset;
240 u8 txpoweridx;
241 u8 txpoweridx_b;
242 u8 rateidx;
243 u32 preamble;
244
245 u32 CrystalCap;
246
247
248 u16 antenna_tx;
249 u16 antenna_rx;
250
251
252 u8 check_mp_pkt;
253
254 u8 bSetTxPower;
255
256 u8 mp_dm;
257 u8 mac_filter[ETH_ALEN];
258 u8 bmac_filter;
259
260 struct wlan_network mp_network;
261 NDIS_802_11_MAC_ADDRESS network_macaddr;
262
263 u8 *pallocated_mp_xmitframe_buf;
264 u8 *pmp_xmtframe_buf;
265 struct __queue free_mp_xmitqueue;
266 u32 free_mp_xmitframe_cnt;
267 bool bSetRxBssid;
268 bool bTxBufCkFail;
269
270 MPT_CONTEXT MptCtx;
271
272 u8 *TXradomBuffer;
273 };
274
275 typedef struct _IOCMD_STRUCT_ {
276 u8 cmdclass;
277 u16 value;
278 u8 index;
279 }IOCMD_STRUCT;
280
281 struct rf_reg_param {
282 u32 path;
283 u32 offset;
284 u32 value;
285 };
286
287 struct bb_reg_param {
288 u32 offset;
289 u32 value;
290 };
291
292 #define LOWER true
293 #define RAISE false
294
295
296 #define BB_REG_BASE_ADDR 0x800
297
298
299 enum MP_MODE {
300 MP_OFF,
301 MP_ON,
302 MP_ERR,
303 MP_CONTINUOUS_TX,
304 MP_SINGLE_CARRIER_TX,
305 MP_CARRIER_SUPPRISSION_TX,
306 MP_SINGLE_TONE_TX,
307 MP_PACKET_TX,
308 MP_PACKET_RX
309 };
310
311 #define MAX_RF_PATH_NUMS RF_PATH_MAX
312
313 extern u8 mpdatarate[NumRates];
314
315
316 enum MPT_RATE_INDEX {
317
318 MPT_RATE_1M = 0 ,
319 MPT_RATE_2M,
320 MPT_RATE_55M,
321 MPT_RATE_11M,
322
323
324 MPT_RATE_6M,
325 MPT_RATE_9M,
326 MPT_RATE_12M,
327 MPT_RATE_18M,
328 MPT_RATE_24M,
329 MPT_RATE_36M,
330 MPT_RATE_48M,
331 MPT_RATE_54M,
332
333
334 MPT_RATE_MCS0,
335 MPT_RATE_MCS1,
336 MPT_RATE_MCS2,
337 MPT_RATE_MCS3,
338 MPT_RATE_MCS4,
339 MPT_RATE_MCS5,
340 MPT_RATE_MCS6,
341 MPT_RATE_MCS7,
342 MPT_RATE_MCS8,
343 MPT_RATE_MCS9,
344 MPT_RATE_MCS10,
345 MPT_RATE_MCS11,
346 MPT_RATE_MCS12,
347 MPT_RATE_MCS13,
348 MPT_RATE_MCS14,
349 MPT_RATE_MCS15,
350
351 MPT_RATE_VHT1SS_MCS0 = 100,
352 MPT_RATE_VHT1SS_MCS1,
353 MPT_RATE_VHT1SS_MCS2,
354 MPT_RATE_VHT1SS_MCS3,
355 MPT_RATE_VHT1SS_MCS4,
356 MPT_RATE_VHT1SS_MCS5,
357 MPT_RATE_VHT1SS_MCS6,
358 MPT_RATE_VHT1SS_MCS7,
359 MPT_RATE_VHT1SS_MCS8,
360 MPT_RATE_VHT1SS_MCS9,
361 MPT_RATE_VHT2SS_MCS0,
362 MPT_RATE_VHT2SS_MCS1,
363 MPT_RATE_VHT2SS_MCS2,
364 MPT_RATE_VHT2SS_MCS3,
365 MPT_RATE_VHT2SS_MCS4,
366 MPT_RATE_VHT2SS_MCS5,
367 MPT_RATE_VHT2SS_MCS6,
368 MPT_RATE_VHT2SS_MCS7,
369 MPT_RATE_VHT2SS_MCS8,
370 MPT_RATE_VHT2SS_MCS9,
371 MPT_RATE_LAST
372 };
373
374 #define MAX_TX_PWR_INDEX_N_MODE 64
375
376 enum POWER_MODE {
377 POWER_LOW = 0,
378 POWER_NORMAL
379 };
380
381
382 enum OFDM_TX_MODE {
383 OFDM_ALL_OFF = 0,
384 OFDM_ContinuousTx = 1,
385 OFDM_SingleCarrier = 2,
386 OFDM_SingleTone = 4,
387 };
388
389 #define RX_PKT_BROADCAST 1
390 #define RX_PKT_DEST_ADDR 2
391 #define RX_PKT_PHY_MATCH 3
392
393 #define Mac_OFDM_OK 0x00000000
394 #define Mac_OFDM_Fail 0x10000000
395 #define Mac_OFDM_FasleAlarm 0x20000000
396 #define Mac_CCK_OK 0x30000000
397 #define Mac_CCK_Fail 0x40000000
398 #define Mac_CCK_FasleAlarm 0x50000000
399 #define Mac_HT_OK 0x60000000
400 #define Mac_HT_Fail 0x70000000
401 #define Mac_HT_FasleAlarm 0x90000000
402 #define Mac_DropPacket 0xA0000000
403
404 enum ENCRY_CTRL_STATE {
405 HW_CONTROL,
406 SW_CONTROL,
407 HW_ENCRY_SW_DECRY,
408 SW_ENCRY_HW_DECRY
409 };
410
411 enum MPT_TXPWR_DEF {
412 MPT_CCK,
413 MPT_OFDM,
414 MPT_VHT_OFDM
415 };
416
417 #define REG_RF_BB_GAIN_OFFSET 0x7f
418 #define RF_GAIN_OFFSET_MASK 0xfffff
419
420
421
422
423
424 s32 init_mp_priv(struct adapter *padapter);
425 void free_mp_priv(struct mp_priv *pmp_priv);
426 s32 MPT_InitializeAdapter(struct adapter *padapter, u8 Channel);
427 void MPT_DeInitAdapter(struct adapter *padapter);
428 s32 mp_start_test(struct adapter *padapter);
429 void mp_stop_test(struct adapter *padapter);
430
431 u32 _read_rfreg(struct adapter *padapter, u8 rfpath, u32 addr, u32 bitmask);
432 void _write_rfreg(struct adapter *padapter, u8 rfpath, u32 addr, u32 bitmask, u32 val);
433
434 u32 read_macreg(struct adapter *padapter, u32 addr, u32 sz);
435 void write_macreg(struct adapter *padapter, u32 addr, u32 val, u32 sz);
436 u32 read_bbreg(struct adapter *padapter, u32 addr, u32 bitmask);
437 void write_bbreg(struct adapter *padapter, u32 addr, u32 bitmask, u32 val);
438 u32 read_rfreg(struct adapter *padapter, u8 rfpath, u32 addr);
439 void write_rfreg(struct adapter *padapter, u8 rfpath, u32 addr, u32 val);
440
441 void SetChannel(struct adapter *padapter);
442 void SetBandwidth(struct adapter *padapter);
443 int SetTxPower(struct adapter *padapter);
444 void SetAntennaPathPower(struct adapter *padapter);
445 void SetDataRate(struct adapter *padapter);
446
447 void SetAntenna(struct adapter *padapter);
448
449 s32 SetThermalMeter(struct adapter *padapter, u8 target_ther);
450 void GetThermalMeter(struct adapter *padapter, u8 *value);
451
452 void SetContinuousTx(struct adapter *padapter, u8 bStart);
453 void SetSingleCarrierTx(struct adapter *padapter, u8 bStart);
454 void SetSingleToneTx(struct adapter *padapter, u8 bStart);
455 void SetCarrierSuppressionTx(struct adapter *padapter, u8 bStart);
456 void PhySetTxPowerLevel(struct adapter *padapter);
457
458 void fill_txdesc_for_mp(struct adapter *padapter, u8 *ptxdesc);
459 void SetPacketTx(struct adapter *padapter);
460 void SetPacketRx(struct adapter *padapter, u8 bStartRx);
461
462 void ResetPhyRxPktCount(struct adapter *padapter);
463 u32 GetPhyRxPktReceived(struct adapter *padapter);
464 u32 GetPhyRxPktCRC32Error(struct adapter *padapter);
465
466 s32 SetPowerTracking(struct adapter *padapter, u8 enable);
467 void GetPowerTracking(struct adapter *padapter, u8 *enable);
468
469 u32 mp_query_psd(struct adapter *padapter, u8 *data);
470
471 void Hal_SetAntenna(struct adapter *padapter);
472 void Hal_SetBandwidth(struct adapter *padapter);
473
474 void Hal_SetTxPower(struct adapter *padapter);
475 void Hal_SetCarrierSuppressionTx(struct adapter *padapter, u8 bStart);
476 void Hal_SetSingleToneTx (struct adapter *padapter , u8 bStart);
477 void Hal_SetSingleCarrierTx (struct adapter *padapter, u8 bStart);
478 void Hal_SetContinuousTx (struct adapter *padapter, u8 bStart);
479 void Hal_SetBandwidth(struct adapter *padapter);
480
481 void Hal_SetDataRate(struct adapter *padapter);
482 void Hal_SetChannel(struct adapter *padapter);
483 void Hal_SetAntennaPathPower(struct adapter *padapter);
484 s32 Hal_SetThermalMeter(struct adapter *padapter, u8 target_ther);
485 s32 Hal_SetPowerTracking(struct adapter *padapter, u8 enable);
486 void Hal_GetPowerTracking(struct adapter *padapter, u8 * enable);
487 void Hal_GetThermalMeter(struct adapter *padapter, u8 *value);
488 void Hal_mpt_SwitchRfSetting(struct adapter *padapter);
489 void Hal_MPT_CCKTxPowerAdjust(struct adapter * Adapter, bool bInCH14);
490 void Hal_MPT_CCKTxPowerAdjustbyIndex(struct adapter *padapter, bool beven);
491 void Hal_SetCCKTxPower(struct adapter *padapter, u8 * TxPower);
492 void Hal_SetOFDMTxPower(struct adapter *padapter, u8 * TxPower);
493 void Hal_TriggerRFThermalMeter(struct adapter *padapter);
494 u8 Hal_ReadRFThermalMeter(struct adapter *padapter);
495 void Hal_SetCCKContinuousTx(struct adapter *padapter, u8 bStart);
496 void Hal_SetOFDMContinuousTx(struct adapter *padapter, u8 bStart);
497 void Hal_ProSetCrystalCap (struct adapter *padapter , u32 CrystalCapVal);
498 void MP_PHY_SetRFPathSwitch(struct adapter *padapter , bool bMain);
499 u32 mpt_ProQueryCalTxPower(struct adapter *padapter, u8 RfPath);
500 void MPT_PwrCtlDM(struct adapter *padapter, u32 bstart);
501 u8 MptToMgntRate(u32 MptRateIdx);
502
503 #endif